提交 | 用户 | 时间
|
e57a89
|
1 |
package com.jcdm.main.bs.formulaChild.service.impl; |
懒 |
2 |
|
b64ed2
|
3 |
import java.util.Date; |
e57a89
|
4 |
import java.util.List; |
3c2299
|
5 |
import java.util.Map; |
7bee80
|
6 |
import java.util.stream.Collectors; |
e57a89
|
7 |
|
7bee80
|
8 |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
懒 |
9 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
0ce25f
|
10 |
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
e57a89
|
11 |
import com.jcdm.common.core.domain.AjaxResult; |
懒 |
12 |
import com.jcdm.common.utils.DateUtils; |
3c2299
|
13 |
import com.jcdm.framework.websocket.WebSocketUsers; |
b64ed2
|
14 |
import com.jcdm.main.da.paramCollection.domain.DaParamCollection; |
懒 |
15 |
import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper; |
32483a
|
16 |
import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; |
懒 |
17 |
import com.jcdm.main.da.passingStationCollection.mapper.DaPassingStationCollectionMapper; |
3c2299
|
18 |
import com.kangaroohy.milo.model.ReadWriteEntity; |
懒 |
19 |
import com.kangaroohy.milo.service.MiloService; |
b77303
|
20 |
import org.aspectj.weaver.loadtime.Aj; |
e57a89
|
21 |
import org.springframework.beans.factory.annotation.Autowired; |
懒 |
22 |
import org.springframework.stereotype.Service; |
|
23 |
import com.jcdm.main.bs.formulaChild.mapper.BsFormulaChildInfoMapper; |
|
24 |
import com.jcdm.main.bs.formulaChild.domain.BsFormulaChildInfo; |
|
25 |
import com.jcdm.main.bs.formulaChild.service.IBsFormulaChildInfoService; |
3c2299
|
26 |
|
懒 |
27 |
import javax.websocket.Session; |
e57a89
|
28 |
|
懒 |
29 |
/** |
|
30 |
* 配方配置子信息Service业务层处理 |
|
31 |
* |
|
32 |
* @author ruimin |
|
33 |
* @date 2023-12-26 |
|
34 |
*/ |
|
35 |
@Service |
0ce25f
|
36 |
public class BsFormulaChildInfoServiceImpl extends ServiceImpl<BsFormulaChildInfoMapper,BsFormulaChildInfo> implements IBsFormulaChildInfoService |
e57a89
|
37 |
{ |
懒 |
38 |
@Autowired |
|
39 |
private BsFormulaChildInfoMapper bsFormulaChildInfoMapper; |
b64ed2
|
40 |
|
懒 |
41 |
@Autowired |
63b254
|
42 |
private IBsFormulaChildInfoService bsFormulaChildInfoService; |
懒 |
43 |
|
|
44 |
@Autowired |
b64ed2
|
45 |
private DaParamCollectionMapper daParamCollectionMapper; |
3c2299
|
46 |
|
懒 |
47 |
@Autowired |
|
48 |
private MiloService miloService; |
32483a
|
49 |
|
懒 |
50 |
@Autowired |
|
51 |
private DaPassingStationCollectionMapper daPassingStationCollectionMapper; |
3c2299
|
52 |
|
懒 |
53 |
Map<String, Session> map = WebSocketUsers.getUsers(); |
e57a89
|
54 |
|
懒 |
55 |
/** |
|
56 |
* 查询配方配置子信息 |
|
57 |
* |
|
58 |
* @param id 配方配置子信息主键 |
|
59 |
* @return 配方配置子信息 |
|
60 |
*/ |
|
61 |
@Override |
|
62 |
public BsFormulaChildInfo selectBsFormulaChildInfoById(Long id) |
|
63 |
{ |
|
64 |
return bsFormulaChildInfoMapper.selectBsFormulaChildInfoById(id); |
|
65 |
} |
|
66 |
|
|
67 |
/** |
|
68 |
* 查询配方配置子信息列表 |
|
69 |
* |
|
70 |
* @param bsFormulaChildInfo 配方配置子信息 |
|
71 |
* @return 配方配置子信息 |
|
72 |
*/ |
|
73 |
@Override |
|
74 |
public List<BsFormulaChildInfo> selectBsFormulaChildInfoList(BsFormulaChildInfo bsFormulaChildInfo) |
|
75 |
{ |
|
76 |
return bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(bsFormulaChildInfo); |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* 新增配方配置子信息 |
|
81 |
* |
|
82 |
* @param bsFormulaChildInfo 配方配置子信息 |
|
83 |
* @return 结果 |
|
84 |
*/ |
|
85 |
@Override |
|
86 |
public int insertBsFormulaChildInfo(BsFormulaChildInfo bsFormulaChildInfo) |
|
87 |
{ |
|
88 |
bsFormulaChildInfo.setCreateTime(DateUtils.getNowDate()); |
|
89 |
return bsFormulaChildInfoMapper.insertBsFormulaChildInfo(bsFormulaChildInfo); |
|
90 |
} |
|
91 |
|
|
92 |
/** |
|
93 |
* 修改配方配置子信息 |
|
94 |
* |
|
95 |
* @param bsFormulaChildInfo 配方配置子信息 |
|
96 |
* @return 结果 |
|
97 |
*/ |
|
98 |
@Override |
|
99 |
public int updateBsFormulaChildInfo(BsFormulaChildInfo bsFormulaChildInfo) |
|
100 |
{ |
|
101 |
bsFormulaChildInfo.setUpdateTime(DateUtils.getNowDate()); |
|
102 |
return bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfo); |
|
103 |
} |
|
104 |
|
|
105 |
/** |
|
106 |
* 批量删除配方配置子信息 |
|
107 |
* |
|
108 |
* @param ids 需要删除的配方配置子信息主键 |
|
109 |
* @return 结果 |
|
110 |
*/ |
|
111 |
@Override |
|
112 |
public int deleteBsFormulaChildInfoByIds(Long[] ids) |
|
113 |
{ |
|
114 |
return bsFormulaChildInfoMapper.deleteBsFormulaChildInfoByIds(ids); |
|
115 |
} |
|
116 |
|
|
117 |
/** |
|
118 |
* 删除配方配置子信息信息 |
|
119 |
* |
|
120 |
* @param id 配方配置子信息主键 |
|
121 |
* @return 结果 |
|
122 |
*/ |
|
123 |
@Override |
|
124 |
public int deleteBsFormulaChildInfoById(Long id) |
|
125 |
{ |
|
126 |
return bsFormulaChildInfoMapper.deleteBsFormulaChildInfoById(id); |
|
127 |
} |
|
128 |
|
|
129 |
@Override |
|
130 |
public BsFormulaChildInfo selectBsFormulaChildInfoByTypeTopOne(String type,String productCode,String processesCode) { |
|
131 |
BsFormulaChildInfo info = new BsFormulaChildInfo(); |
|
132 |
info.setOperationType(type); |
|
133 |
info.setProcessesCode(processesCode); |
|
134 |
info.setProductCode(productCode); |
|
135 |
return bsFormulaChildInfoMapper.selectBsFormulaChildInfoByTypeTopOne(info); |
|
136 |
} |
|
137 |
|
|
138 |
@Override |
b77303
|
139 |
public BsFormulaChildInfo getCount(String productCode, String processesCode) { |
懒 |
140 |
BsFormulaChildInfo info = new BsFormulaChildInfo(); |
|
141 |
info.setProcessesCode(processesCode); |
|
142 |
info.setProductCode(productCode); |
|
143 |
return bsFormulaChildInfoMapper.getCount(info); |
|
144 |
} |
|
145 |
|
|
146 |
@Override |
|
147 |
public BsFormulaChildInfo releaseCheck(BsFormulaChildInfo bsFormulaChildInfo) { |
e57a89
|
148 |
return bsFormulaChildInfoMapper.releaseCheck(bsFormulaChildInfo); |
懒 |
149 |
} |
|
150 |
|
c5e9c5
|
151 |
//1-非本工位物料 2-正常扫描可继续下次 3-扫描结束已经是最后一位工步 |
e57a89
|
152 |
@Override |
懒 |
153 |
public AjaxResult updateResults(BsFormulaChildInfo bsFormulaChildInfo) { |
c5e9c5
|
154 |
String result = ""; |
e70fb4
|
155 |
// BsFormulaChildInfo checkInfo = new BsFormulaChildInfo(); |
A |
156 |
// checkInfo.setProcessesCode(bsFormulaChildInfo.getLocationCode()); |
|
157 |
// checkInfo.setProductCode(bsFormulaChildInfo.getProductCode()); |
|
158 |
//// checkInfo.setMaterialCode(bsFormulaChildInfo.getScanBarcode()); |
|
159 |
// bsFormulaChildInfo.setMaterialCode(bsFormulaChildInfo.getScanBarcode().substring(1,2)); |
|
160 |
// List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(checkInfo); |
|
161 |
List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>() |
|
162 |
.eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getLocationCode()) |
|
163 |
.eq(BsFormulaChildInfo::getProductCode, bsFormulaChildInfo.getProductCode()) |
|
164 |
.eq(BsFormulaChildInfo::getMaterialCode, bsFormulaChildInfo.getScanBarcode().substring(1, 2)) |
|
165 |
); |
e57a89
|
166 |
if(bsFormulaChildInfos.size()>0){ |
c5e9c5
|
167 |
String spareField4 = bsFormulaChildInfos.get(0).getSpareField4(); |
3c2299
|
168 |
bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getScanBarcode()); |
e57a89
|
169 |
bsFormulaChildInfos.get(0).setResults("OK"); |
懒 |
170 |
bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0)); |
49c784
|
171 |
bsFormulaChildInfo.setParamValue(bsFormulaChildInfo.getScanBarcode()); |
b64ed2
|
172 |
bsFormulaChildInfo.setParamCode(bsFormulaChildInfos.get(0).getParamCode()); |
49c784
|
173 |
bsFormulaChildInfo.setSfcBarcode(bsFormulaChildInfo.getSfcBarcode()); |
b64ed2
|
174 |
addParameterCollection(bsFormulaChildInfo); |
c5e9c5
|
175 |
if (spareField4 != null && !spareField4.isEmpty()) { |
懒 |
176 |
// 执行操作 |
|
177 |
if(bsFormulaChildInfos.get(0).getSpareField4().equals("1")){ |
|
178 |
try { |
|
179 |
result = "3"; |
|
180 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".RecordDataDone").value(21).build()); |
|
181 |
} catch (Exception e) { |
|
182 |
throw new RuntimeException(e); |
|
183 |
} |
|
184 |
} |
|
185 |
} |
e57a89
|
186 |
}else { |
c5e9c5
|
187 |
result = "1"; |
e57a89
|
188 |
} |
c5e9c5
|
189 |
return AjaxResult.success(result); |
e57a89
|
190 |
} |
懒 |
191 |
|
b64ed2
|
192 |
public void addParameterCollection(BsFormulaChildInfo bsFormulaChildInfo){ |
懒 |
193 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
194 |
daParamCollection.setParamCode(bsFormulaChildInfo.getParamCode()); |
|
195 |
daParamCollection.setWorkOrderNo(bsFormulaChildInfo.getWorkOrderNo()); |
|
196 |
daParamCollection.setLocationCode(bsFormulaChildInfo.getLocationCode()); |
|
197 |
daParamCollection.setParamValue(bsFormulaChildInfo.getParamValue()); |
|
198 |
daParamCollection.setProductCode(bsFormulaChildInfo.getProductCode()); |
|
199 |
daParamCollection.setCollectionTime(new Date()); |
49c784
|
200 |
daParamCollection.setSfcCode(bsFormulaChildInfo.getSfcBarcode()); |
b64ed2
|
201 |
daParamCollectionMapper.insertDaParamCollection(daParamCollection); |
懒 |
202 |
} |
|
203 |
|
e57a89
|
204 |
@Override |
懒 |
205 |
public AjaxResult workpieceRelease(BsFormulaChildInfo bsFormulaChildInfo) { |
63b254
|
206 |
List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>() |
懒 |
207 |
.eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getLocationCode()) |
|
208 |
.eq(BsFormulaChildInfo::getProductCode, bsFormulaChildInfo.getProductCode())); |
|
209 |
for (BsFormulaChildInfo info : list) { |
e70fb4
|
210 |
info.setCollectData(""); |
63b254
|
211 |
info.setResults(""); |
懒 |
212 |
bsFormulaChildInfoService.saveOrUpdate(info); |
|
213 |
} |
e57a89
|
214 |
return AjaxResult.success(); |
懒 |
215 |
} |
b77303
|
216 |
|
懒 |
217 |
@Override |
|
218 |
public AjaxResult updateTighteningFormula(BsFormulaChildInfo bsFormulaChildInfo) { |
7bee80
|
219 |
BsFormulaChildInfo getMaterTwo = new BsFormulaChildInfo(); |
懒 |
220 |
getMaterTwo.setProcessesCode(bsFormulaChildInfo.getLocationCode()); |
|
221 |
getMaterTwo.setOperationType("2"); |
|
222 |
List<BsFormulaChildInfo> operationType = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(getMaterTwo); |
|
223 |
List<String> collect = operationType.stream().map(BsFormulaChildInfo::getResults).collect(Collectors.toList()); |
|
224 |
for (String s : collect) { |
|
225 |
if(s.equals("")){ |
|
226 |
return AjaxResult.error("扫描未完成,禁止拧紧操作!"); |
|
227 |
} |
|
228 |
} |
b77303
|
229 |
BsFormulaChildInfo listQuery = new BsFormulaChildInfo(); |
懒 |
230 |
listQuery.setParamCode(bsFormulaChildInfo.getParamCode()); |
|
231 |
String paramCode = bsFormulaChildInfo.getTightenTheArray(); |
|
232 |
if(paramCode.contains("N")){ |
|
233 |
List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery); |
|
234 |
bsFormulaChildInfos.get(0).setResults("NG"); |
|
235 |
bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getTightenTheArray()); |
|
236 |
bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0)); |
|
237 |
return AjaxResult.error("扫描结果NG,请重新扫描!"); |
|
238 |
}else { |
|
239 |
List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery); |
|
240 |
bsFormulaChildInfos.get(0).setResults("OK"); |
|
241 |
bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getTightenTheArray()); |
|
242 |
bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0)); |
3c2299
|
243 |
String spareField4 = bsFormulaChildInfos.get(0).getSpareField4(); |
懒 |
244 |
if (spareField4 != null && !spareField4.isEmpty()) { |
|
245 |
// 执行操作 |
|
246 |
if(bsFormulaChildInfos.get(0).getSpareField4().equals("1")){ |
|
247 |
try { |
32483a
|
248 |
// //更新过站记录表出站时间 |
懒 |
249 |
// DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection(); |
|
250 |
// daPassingStationCollection.setWorkOrderNo(bsFormulaChildInfo.getWorkOrderNo()); |
|
251 |
// List<DaPassingStationCollection> daPassingStationCollections = daPassingStationCollectionMapper.selectDaPassingStationCollectionList(daPassingStationCollection); |
|
252 |
// daPassingStationCollections.get(0).setOutboundTime(new Date()); |
|
253 |
// daPassingStationCollectionMapper.updateDaPassingStationCollection(daPassingStationCollections.get(0)); |
b5fcd8
|
254 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".RecordDataDone").value(21).build()); |
3c2299
|
255 |
WebSocketUsers.sendMessageToUserByText(map.get(bsFormulaChildInfo.getLocationCode()), "OUT"); |
懒 |
256 |
} catch (Exception e) { |
|
257 |
throw new RuntimeException(e); |
|
258 |
} |
|
259 |
} |
|
260 |
} |
|
261 |
|
b77303
|
262 |
} |
懒 |
263 |
return AjaxResult.success("扫描成功!"); |
|
264 |
} |
|
265 |
|
|
266 |
|
|
267 |
|
|
268 |
|
e57a89
|
269 |
} |