提交 | 用户 | 时间
|
e57a89
|
1 |
package com.jcdm.main.bs.formulaChild.service.impl; |
懒 |
2 |
|
5316c5
|
3 |
import java.util.ArrayList; |
b64ed2
|
4 |
import java.util.Date; |
e57a89
|
5 |
import java.util.List; |
3c2299
|
6 |
import java.util.Map; |
982c84
|
7 |
import java.util.regex.Matcher; |
A |
8 |
import java.util.regex.Pattern; |
7bee80
|
9 |
import java.util.stream.Collectors; |
e57a89
|
10 |
|
d545f1
|
11 |
import cn.hutool.core.util.StrUtil; |
7bee80
|
12 |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
懒 |
13 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
0ce25f
|
14 |
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
e57a89
|
15 |
import com.jcdm.common.core.domain.AjaxResult; |
懒 |
16 |
import com.jcdm.common.utils.DateUtils; |
3c2299
|
17 |
import com.jcdm.framework.websocket.WebSocketUsers; |
b64ed2
|
18 |
import com.jcdm.main.da.paramCollection.domain.DaParamCollection; |
懒 |
19 |
import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper; |
a320dc
|
20 |
import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; |
32483a
|
21 |
import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; |
懒 |
22 |
import com.jcdm.main.da.passingStationCollection.mapper.DaPassingStationCollectionMapper; |
a759f5
|
23 |
import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService; |
a320dc
|
24 |
import com.jcdm.main.da.testDeviceInterface.service.IDaTestDeviceInterfaceService; |
982c84
|
25 |
import com.jcdm.main.plcserver.util.TimeUtil; |
3c2299
|
26 |
import com.kangaroohy.milo.model.ReadWriteEntity; |
懒 |
27 |
import com.kangaroohy.milo.service.MiloService; |
a759f5
|
28 |
import lombok.extern.slf4j.Slf4j; |
b77303
|
29 |
import org.aspectj.weaver.loadtime.Aj; |
a759f5
|
30 |
import org.slf4j.Logger; |
A |
31 |
import org.slf4j.LoggerFactory; |
e57a89
|
32 |
import org.springframework.beans.factory.annotation.Autowired; |
懒 |
33 |
import org.springframework.stereotype.Service; |
|
34 |
import com.jcdm.main.bs.formulaChild.mapper.BsFormulaChildInfoMapper; |
|
35 |
import com.jcdm.main.bs.formulaChild.domain.BsFormulaChildInfo; |
|
36 |
import com.jcdm.main.bs.formulaChild.service.IBsFormulaChildInfoService; |
3c2299
|
37 |
|
懒 |
38 |
import javax.websocket.Session; |
e57a89
|
39 |
|
懒 |
40 |
/** |
|
41 |
* 配方配置子信息Service业务层处理 |
|
42 |
* |
|
43 |
* @author ruimin |
|
44 |
* @date 2023-12-26 |
|
45 |
*/ |
|
46 |
@Service |
a759f5
|
47 |
@Slf4j |
0ce25f
|
48 |
public class BsFormulaChildInfoServiceImpl extends ServiceImpl<BsFormulaChildInfoMapper,BsFormulaChildInfo> implements IBsFormulaChildInfoService |
e57a89
|
49 |
{ |
a759f5
|
50 |
private static final Logger logger = LoggerFactory.getLogger("sys-user"); |
e57a89
|
51 |
@Autowired |
懒 |
52 |
private BsFormulaChildInfoMapper bsFormulaChildInfoMapper; |
b64ed2
|
53 |
|
懒 |
54 |
@Autowired |
63b254
|
55 |
private IBsFormulaChildInfoService bsFormulaChildInfoService; |
懒 |
56 |
|
|
57 |
@Autowired |
b64ed2
|
58 |
private DaParamCollectionMapper daParamCollectionMapper; |
3c2299
|
59 |
|
懒 |
60 |
@Autowired |
|
61 |
private MiloService miloService; |
32483a
|
62 |
|
懒 |
63 |
@Autowired |
|
64 |
private DaPassingStationCollectionMapper daPassingStationCollectionMapper; |
a320dc
|
65 |
|
A |
66 |
@Autowired |
|
67 |
private IDaTestDeviceInterfaceService daTestDeviceInterfaceService; |
|
68 |
|
|
69 |
@Autowired |
|
70 |
private IDaParamCollectionService daParamCollectionService; |
a759f5
|
71 |
|
A |
72 |
@Autowired |
|
73 |
private IDaPassingStationCollectionService daPassingStationCollectionService; |
3c2299
|
74 |
|
懒 |
75 |
Map<String, Session> map = WebSocketUsers.getUsers(); |
e57a89
|
76 |
|
懒 |
77 |
/** |
|
78 |
* 查询配方配置子信息 |
|
79 |
* |
|
80 |
* @param id 配方配置子信息主键 |
|
81 |
* @return 配方配置子信息 |
|
82 |
*/ |
|
83 |
@Override |
|
84 |
public BsFormulaChildInfo selectBsFormulaChildInfoById(Long id) |
|
85 |
{ |
|
86 |
return bsFormulaChildInfoMapper.selectBsFormulaChildInfoById(id); |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* 查询配方配置子信息列表 |
|
91 |
* |
|
92 |
* @param bsFormulaChildInfo 配方配置子信息 |
|
93 |
* @return 配方配置子信息 |
|
94 |
*/ |
|
95 |
@Override |
|
96 |
public List<BsFormulaChildInfo> selectBsFormulaChildInfoList(BsFormulaChildInfo bsFormulaChildInfo) |
|
97 |
{ |
|
98 |
return bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(bsFormulaChildInfo); |
|
99 |
} |
|
100 |
|
|
101 |
/** |
|
102 |
* 新增配方配置子信息 |
|
103 |
* |
|
104 |
* @param bsFormulaChildInfo 配方配置子信息 |
|
105 |
* @return 结果 |
|
106 |
*/ |
|
107 |
@Override |
|
108 |
public int insertBsFormulaChildInfo(BsFormulaChildInfo bsFormulaChildInfo) |
|
109 |
{ |
|
110 |
bsFormulaChildInfo.setCreateTime(DateUtils.getNowDate()); |
|
111 |
return bsFormulaChildInfoMapper.insertBsFormulaChildInfo(bsFormulaChildInfo); |
|
112 |
} |
|
113 |
|
|
114 |
/** |
|
115 |
* 修改配方配置子信息 |
|
116 |
* |
|
117 |
* @param bsFormulaChildInfo 配方配置子信息 |
|
118 |
* @return 结果 |
|
119 |
*/ |
|
120 |
@Override |
|
121 |
public int updateBsFormulaChildInfo(BsFormulaChildInfo bsFormulaChildInfo) |
|
122 |
{ |
|
123 |
bsFormulaChildInfo.setUpdateTime(DateUtils.getNowDate()); |
|
124 |
return bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfo); |
|
125 |
} |
|
126 |
|
|
127 |
/** |
|
128 |
* 批量删除配方配置子信息 |
|
129 |
* |
|
130 |
* @param ids 需要删除的配方配置子信息主键 |
|
131 |
* @return 结果 |
|
132 |
*/ |
|
133 |
@Override |
|
134 |
public int deleteBsFormulaChildInfoByIds(Long[] ids) |
|
135 |
{ |
|
136 |
return bsFormulaChildInfoMapper.deleteBsFormulaChildInfoByIds(ids); |
|
137 |
} |
|
138 |
|
|
139 |
/** |
|
140 |
* 删除配方配置子信息信息 |
|
141 |
* |
|
142 |
* @param id 配方配置子信息主键 |
|
143 |
* @return 结果 |
|
144 |
*/ |
|
145 |
@Override |
|
146 |
public int deleteBsFormulaChildInfoById(Long id) |
|
147 |
{ |
|
148 |
return bsFormulaChildInfoMapper.deleteBsFormulaChildInfoById(id); |
|
149 |
} |
|
150 |
|
|
151 |
@Override |
|
152 |
public BsFormulaChildInfo selectBsFormulaChildInfoByTypeTopOne(String type,String productCode,String processesCode) { |
|
153 |
BsFormulaChildInfo info = new BsFormulaChildInfo(); |
|
154 |
info.setOperationType(type); |
|
155 |
info.setProcessesCode(processesCode); |
|
156 |
info.setProductCode(productCode); |
|
157 |
return bsFormulaChildInfoMapper.selectBsFormulaChildInfoByTypeTopOne(info); |
|
158 |
} |
|
159 |
|
|
160 |
@Override |
b77303
|
161 |
public BsFormulaChildInfo getCount(String productCode, String processesCode) { |
懒 |
162 |
BsFormulaChildInfo info = new BsFormulaChildInfo(); |
|
163 |
info.setProcessesCode(processesCode); |
|
164 |
info.setProductCode(productCode); |
|
165 |
return bsFormulaChildInfoMapper.getCount(info); |
|
166 |
} |
|
167 |
|
|
168 |
@Override |
2c7661
|
169 |
public AjaxResult yzUpdateResults(BsFormulaChildInfo bsFormulaChildInfo) { |
A |
170 |
String result = ""; |
|
171 |
List<BsFormulaChildInfo> bsFormulaChildInfos = new ArrayList<>(); |
|
172 |
List<BsFormulaChildInfo> infos = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>() |
|
173 |
.eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getLocationCode()) |
|
174 |
.eq(BsFormulaChildInfo::getProductCode, bsFormulaChildInfo.getProductCode()) |
|
175 |
.eq(BsFormulaChildInfo::getOperationType, "2") |
|
176 |
); |
|
177 |
for (BsFormulaChildInfo formulaChildInfo : infos) { |
|
178 |
if(bsFormulaChildInfo.getScanBarcode().contains(formulaChildInfo.getMaterialCode())){ |
|
179 |
bsFormulaChildInfos.add(formulaChildInfo); |
|
180 |
break; |
|
181 |
} |
|
182 |
} |
|
183 |
if(bsFormulaChildInfos.size()>0){ |
|
184 |
String spareField4 = bsFormulaChildInfos.get(0).getSpareField4(); |
|
185 |
bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getScanBarcode()); |
|
186 |
bsFormulaChildInfos.get(0).setResults("OK"); |
|
187 |
bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0)); |
|
188 |
bsFormulaChildInfo.setParamValue(bsFormulaChildInfo.getScanBarcode()); |
|
189 |
bsFormulaChildInfo.setParamCode(bsFormulaChildInfos.get(0).getParamCode()); |
|
190 |
bsFormulaChildInfo.setSfcBarcode(bsFormulaChildInfo.getSfcBarcode()); |
|
191 |
addParameterCollection(bsFormulaChildInfo); |
|
192 |
if (spareField4 != null && !spareField4.isEmpty()) { |
|
193 |
// 执行操作 |
|
194 |
if(bsFormulaChildInfos.get(0).getSpareField4().equals("1")){ |
|
195 |
try { |
|
196 |
result = "3"; |
|
197 |
} catch (Exception e) { |
|
198 |
throw new RuntimeException(e); |
|
199 |
} |
|
200 |
} |
|
201 |
} |
|
202 |
}else { |
|
203 |
result = "1"; |
|
204 |
} |
|
205 |
return AjaxResult.success(result); |
|
206 |
} |
|
207 |
|
|
208 |
@Override |
|
209 |
public AjaxResult yzUpdateTighteningFormula(BsFormulaChildInfo bsFormulaChildInfo) { |
a846f2
|
210 |
Boolean b = true; |
2c7661
|
211 |
String result = "1"; |
A |
212 |
BsFormulaChildInfo getMaterTwo = new BsFormulaChildInfo(); |
|
213 |
getMaterTwo.setProcessesCode(bsFormulaChildInfo.getLocationCode()); |
|
214 |
getMaterTwo.setOperationType("2"); |
|
215 |
List<BsFormulaChildInfo> operationType = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(getMaterTwo); |
|
216 |
List<String> collect = operationType.stream().map(BsFormulaChildInfo::getResults).collect(Collectors.toList()); |
|
217 |
for (String s : collect) { |
|
218 |
if(s.equals("")){ |
a846f2
|
219 |
// return AjaxResult.success("扫描未完成,禁止拧紧操作!"); |
2c7661
|
220 |
} |
A |
221 |
} |
|
222 |
BsFormulaChildInfo listQuery = new BsFormulaChildInfo(); |
|
223 |
listQuery.setParamCode(bsFormulaChildInfo.getParamCode()); |
16714e
|
224 |
listQuery.setProcessesCode(bsFormulaChildInfo.getLocationCode()); |
2c7661
|
225 |
String paramCode = bsFormulaChildInfo.getTightenTheArray(); |
A |
226 |
if(paramCode.contains("N")){ |
a846f2
|
227 |
result = "3"; |
2c7661
|
228 |
List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery); |
A |
229 |
bsFormulaChildInfos.get(0).setResults("NG"); |
|
230 |
bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getTightenTheArray()); |
|
231 |
bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0)); |
a846f2
|
232 |
// return AjaxResult.success("扫描结果NG,请重新扫描!"); |
2c7661
|
233 |
}else { |
A |
234 |
List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery); |
a846f2
|
235 |
if(bsFormulaChildInfos.get(0).getSpareField2()!=null&&bsFormulaChildInfos.get(0).getSpareField3()!=null){ |
A |
236 |
String tightenArray = bsFormulaChildInfo.getTightenTheArray().replace("[", "").replace("]", "").replace(" ", ""); |
|
237 |
String[] tightenDataParts = tightenArray.split(","); |
|
238 |
b = TimeUtil.isNumberInRange(Double.parseDouble(tightenDataParts[0]),Double.parseDouble(bsFormulaChildInfos.get(0).getSpareField2()),Double.parseDouble(bsFormulaChildInfos.get(0).getSpareField3())); |
4a5f2a
|
239 |
} |
a846f2
|
240 |
if(b){ |
A |
241 |
result = "3"; |
|
242 |
bsFormulaChildInfos.get(0).setResults("OK"); |
|
243 |
bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getTightenTheArray()); |
|
244 |
bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0)); |
a759f5
|
245 |
logger.info("yzUpdateTighteningFormula--查询条件参数:"+listQuery); |
A |
246 |
logger.info("yzUpdateTighteningFormula--查询结果:"+bsFormulaChildInfos.get(0)); |
a846f2
|
247 |
Integer stepNumber = Integer.valueOf(bsFormulaChildInfos.get(0).getStepSort()); |
A |
248 |
try { |
|
249 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".MStepNumber").value(stepNumber+1).build()); |
|
250 |
} catch (Exception e) { |
|
251 |
throw new RuntimeException(e); |
|
252 |
} |
|
253 |
|
|
254 |
String spareField4 = bsFormulaChildInfos.get(0).getSpareField4(); |
|
255 |
if (spareField4 != null && !spareField4.isEmpty()) { |
|
256 |
// 执行操作 |
|
257 |
if(bsFormulaChildInfos.get(0).getSpareField4().equals("1")){ |
|
258 |
try { |
2c7661
|
259 |
// WebSocketUsers.sendMessageToUserByText(map.get(bsFormulaChildInfo.getLocationCode()), "OUT"); |
a846f2
|
260 |
result = "2"; |
A |
261 |
} catch (Exception e) { |
|
262 |
throw new RuntimeException(e); |
|
263 |
} |
2c7661
|
264 |
} |
A |
265 |
} |
a846f2
|
266 |
}else { |
A |
267 |
result = "3"; |
|
268 |
List<BsFormulaChildInfo> bsFormulaChildInfos1 = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery); |
|
269 |
bsFormulaChildInfos1.get(0).setResults("NG"); |
|
270 |
String originalString = bsFormulaChildInfo.getTightenTheArray(); |
|
271 |
String modifiedString = originalString.replaceFirst("OK", "NG"); |
|
272 |
bsFormulaChildInfos1.get(0).setCollectData(modifiedString); |
|
273 |
bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos1.get(0)); |
|
274 |
// return AjaxResult.success("扫描结果NG,请重新扫描!"); |
2c7661
|
275 |
} |
A |
276 |
} |
|
277 |
return AjaxResult.success(result); |
|
278 |
} |
|
279 |
|
|
280 |
@Override |
06713a
|
281 |
public AjaxResult jrmUpdateResults(BsFormulaChildInfo bsFormulaChildInfo) { |
A |
282 |
String result = ""; |
|
283 |
List<BsFormulaChildInfo> bsFormulaChildInfos = new ArrayList<>(); |
|
284 |
List<BsFormulaChildInfo> infos = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>() |
|
285 |
.eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getLocationCode()) |
|
286 |
.eq(BsFormulaChildInfo::getProductCode, bsFormulaChildInfo.getProductCode()) |
|
287 |
.eq(BsFormulaChildInfo::getOperationType, "2") |
d545f1
|
288 |
).stream().filter(x -> StrUtil.isBlank(x.getCollectData())).collect(Collectors.toList()); |
A |
289 |
|
|
290 |
|
06713a
|
291 |
for (BsFormulaChildInfo formulaChildInfo : infos) { |
A |
292 |
if(bsFormulaChildInfo.getScanBarcode().contains(formulaChildInfo.getMaterialCode())){ |
|
293 |
bsFormulaChildInfos.add(formulaChildInfo); |
|
294 |
break; |
|
295 |
} |
|
296 |
} |
|
297 |
if(bsFormulaChildInfos.size()>0){ |
|
298 |
String spareField4 = bsFormulaChildInfos.get(0).getSpareField4(); |
|
299 |
bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getScanBarcode()); |
|
300 |
bsFormulaChildInfos.get(0).setResults("OK"); |
|
301 |
bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0)); |
|
302 |
bsFormulaChildInfo.setParamValue(bsFormulaChildInfo.getScanBarcode()); |
|
303 |
bsFormulaChildInfo.setParamCode(bsFormulaChildInfos.get(0).getParamCode()); |
|
304 |
bsFormulaChildInfo.setSfcBarcode(bsFormulaChildInfo.getSfcBarcode()); |
|
305 |
jrmAddParameterCollection(bsFormulaChildInfo); |
|
306 |
|
|
307 |
if (spareField4 != null && !spareField4.isEmpty()) { |
|
308 |
// 执行操作 |
|
309 |
if(bsFormulaChildInfos.get(0).getSpareField4().equals("1")){ |
|
310 |
try { |
|
311 |
result = "3"; |
1ccd69
|
312 |
// String strA = bsFormulaChildInfo.getLocationCode() + "A"; |
A |
313 |
// String strB = bsFormulaChildInfo.getLocationCode() + "B"; |
|
314 |
// miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+strA+".RecordDataDone").value(21).build()); |
|
315 |
// miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+strB+".RecordDataDone").value(21).build()); |
|
316 |
String locationCode = bsFormulaChildInfo.getLocationCode(); |
|
317 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+locationCode+".RecordDataDone").value(21).build()); |
06713a
|
318 |
} catch (Exception e) { |
A |
319 |
throw new RuntimeException(e); |
|
320 |
} |
|
321 |
} |
|
322 |
} |
|
323 |
}else { |
|
324 |
result = "1"; |
|
325 |
} |
|
326 |
return AjaxResult.success(result); |
|
327 |
} |
|
328 |
|
|
329 |
@Override |
b77303
|
330 |
public BsFormulaChildInfo releaseCheck(BsFormulaChildInfo bsFormulaChildInfo) { |
e57a89
|
331 |
return bsFormulaChildInfoMapper.releaseCheck(bsFormulaChildInfo); |
懒 |
332 |
} |
|
333 |
|
c5e9c5
|
334 |
//1-非本工位物料 2-正常扫描可继续下次 3-扫描结束已经是最后一位工步 |
e57a89
|
335 |
@Override |
懒 |
336 |
public AjaxResult updateResults(BsFormulaChildInfo bsFormulaChildInfo) { |
c5e9c5
|
337 |
String result = ""; |
5316c5
|
338 |
List<BsFormulaChildInfo> bsFormulaChildInfos = new ArrayList<>(); |
A |
339 |
List<BsFormulaChildInfo> infos = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>() |
e70fb4
|
340 |
.eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getLocationCode()) |
A |
341 |
.eq(BsFormulaChildInfo::getProductCode, bsFormulaChildInfo.getProductCode()) |
5316c5
|
342 |
.eq(BsFormulaChildInfo::getOperationType, "2") |
e70fb4
|
343 |
); |
5316c5
|
344 |
for (BsFormulaChildInfo formulaChildInfo : infos) { |
A |
345 |
if(bsFormulaChildInfo.getScanBarcode().contains(formulaChildInfo.getMaterialCode())){ |
|
346 |
bsFormulaChildInfos.add(formulaChildInfo); |
|
347 |
break; |
|
348 |
} |
|
349 |
} |
e57a89
|
350 |
if(bsFormulaChildInfos.size()>0){ |
c5e9c5
|
351 |
String spareField4 = bsFormulaChildInfos.get(0).getSpareField4(); |
3c2299
|
352 |
bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getScanBarcode()); |
e57a89
|
353 |
bsFormulaChildInfos.get(0).setResults("OK"); |
懒 |
354 |
bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0)); |
49c784
|
355 |
bsFormulaChildInfo.setParamValue(bsFormulaChildInfo.getScanBarcode()); |
b64ed2
|
356 |
bsFormulaChildInfo.setParamCode(bsFormulaChildInfos.get(0).getParamCode()); |
49c784
|
357 |
bsFormulaChildInfo.setSfcBarcode(bsFormulaChildInfo.getSfcBarcode()); |
b64ed2
|
358 |
addParameterCollection(bsFormulaChildInfo); |
4a5f2a
|
359 |
|
A |
360 |
// Integer stepNumber = Integer.valueOf(bsFormulaChildInfos.get(0).getStepSort()); |
|
361 |
// try { |
|
362 |
// miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".StepNumber").value(stepNumber).build()); |
|
363 |
// } catch (Exception e) { |
|
364 |
// throw new RuntimeException(e); |
|
365 |
// } |
|
366 |
|
c5e9c5
|
367 |
if (spareField4 != null && !spareField4.isEmpty()) { |
懒 |
368 |
// 执行操作 |
|
369 |
if(bsFormulaChildInfos.get(0).getSpareField4().equals("1")){ |
|
370 |
try { |
|
371 |
result = "3"; |
|
372 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".RecordDataDone").value(21).build()); |
|
373 |
} catch (Exception e) { |
|
374 |
throw new RuntimeException(e); |
|
375 |
} |
|
376 |
} |
|
377 |
} |
e57a89
|
378 |
}else { |
c5e9c5
|
379 |
result = "1"; |
e57a89
|
380 |
} |
c5e9c5
|
381 |
return AjaxResult.success(result); |
e57a89
|
382 |
} |
懒 |
383 |
|
b64ed2
|
384 |
public void addParameterCollection(BsFormulaChildInfo bsFormulaChildInfo){ |
懒 |
385 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
386 |
daParamCollection.setParamCode(bsFormulaChildInfo.getParamCode()); |
|
387 |
daParamCollection.setWorkOrderNo(bsFormulaChildInfo.getWorkOrderNo()); |
|
388 |
daParamCollection.setLocationCode(bsFormulaChildInfo.getLocationCode()); |
|
389 |
daParamCollection.setParamValue(bsFormulaChildInfo.getParamValue()); |
|
390 |
daParamCollection.setProductCode(bsFormulaChildInfo.getProductCode()); |
|
391 |
daParamCollection.setCollectionTime(new Date()); |
49c784
|
392 |
daParamCollection.setSfcCode(bsFormulaChildInfo.getSfcBarcode()); |
b64ed2
|
393 |
daParamCollectionMapper.insertDaParamCollection(daParamCollection); |
懒 |
394 |
} |
|
395 |
|
06713a
|
396 |
public void jrmAddParameterCollection(BsFormulaChildInfo bsFormulaChildInfo){ |
A |
397 |
String scanBarCode = bsFormulaChildInfo.getSfcBarcode(); |
|
398 |
String[] modeleSplit = scanBarCode.split(","); |
d545f1
|
399 |
// for (String modele : modeleSplit) { |
06713a
|
400 |
DaParamCollection daParamCollection = new DaParamCollection(); |
A |
401 |
daParamCollection.setParamCode(bsFormulaChildInfo.getParamCode()); |
|
402 |
daParamCollection.setWorkOrderNo(bsFormulaChildInfo.getWorkOrderNo()); |
|
403 |
daParamCollection.setLocationCode(bsFormulaChildInfo.getLocationCode()); |
|
404 |
daParamCollection.setParamValue(bsFormulaChildInfo.getParamValue()); |
|
405 |
daParamCollection.setProductCode(bsFormulaChildInfo.getProductCode()); |
|
406 |
daParamCollection.setCollectionTime(new Date()); |
d545f1
|
407 |
if(bsFormulaChildInfo.getParamCode().contains("B")){ |
A |
408 |
daParamCollection.setSfcCode(modeleSplit[1]); |
|
409 |
}else { |
|
410 |
daParamCollection.setSfcCode(modeleSplit[0]); |
|
411 |
} |
|
412 |
// daParamCollection.setSfcCode(modele); |
06713a
|
413 |
daParamCollectionMapper.insertDaParamCollection(daParamCollection); |
d545f1
|
414 |
// } |
06713a
|
415 |
|
A |
416 |
} |
|
417 |
|
e57a89
|
418 |
@Override |
懒 |
419 |
public AjaxResult workpieceRelease(BsFormulaChildInfo bsFormulaChildInfo) { |
63b254
|
420 |
List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>() |
懒 |
421 |
.eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getLocationCode()) |
|
422 |
.eq(BsFormulaChildInfo::getProductCode, bsFormulaChildInfo.getProductCode())); |
|
423 |
for (BsFormulaChildInfo info : list) { |
e70fb4
|
424 |
info.setCollectData(""); |
63b254
|
425 |
info.setResults(""); |
懒 |
426 |
bsFormulaChildInfoService.saveOrUpdate(info); |
a759f5
|
427 |
} |
A |
428 |
try { |
|
429 |
daParamCollectionService.pushGeelycvMesFeedback(bsFormulaChildInfo.getProductBarcode(), bsFormulaChildInfo.getLocationCode()); |
|
430 |
String barCode = bsFormulaChildInfo.getProductBarcode(); |
|
431 |
String locationCode = bsFormulaChildInfo.getLocationCode(); |
|
432 |
DaPassingStationCollection passingStationCollectionOne = daPassingStationCollectionService.getOne(new LambdaQueryWrapper<DaPassingStationCollection>().eq(DaPassingStationCollection::getSfcCode, barCode).eq(DaPassingStationCollection::getLocationCode, locationCode)); |
|
433 |
if (passingStationCollectionOne != null) { |
|
434 |
passingStationCollectionOne.setOutRsSign("1"); |
|
435 |
passingStationCollectionOne.setOutboundTime(new Date()); |
|
436 |
daPassingStationCollectionService.saveOrUpdate(passingStationCollectionOne); |
|
437 |
} |
|
438 |
}catch (Exception e){ |
63b254
|
439 |
} |
e57a89
|
440 |
return AjaxResult.success(); |
懒 |
441 |
} |
b77303
|
442 |
|
懒 |
443 |
@Override |
|
444 |
public AjaxResult updateTighteningFormula(BsFormulaChildInfo bsFormulaChildInfo) { |
982c84
|
445 |
Boolean b = true; |
7bee80
|
446 |
BsFormulaChildInfo getMaterTwo = new BsFormulaChildInfo(); |
懒 |
447 |
getMaterTwo.setProcessesCode(bsFormulaChildInfo.getLocationCode()); |
|
448 |
getMaterTwo.setOperationType("2"); |
|
449 |
List<BsFormulaChildInfo> operationType = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(getMaterTwo); |
|
450 |
List<String> collect = operationType.stream().map(BsFormulaChildInfo::getResults).collect(Collectors.toList()); |
|
451 |
for (String s : collect) { |
|
452 |
if(s.equals("")){ |
|
453 |
return AjaxResult.error("扫描未完成,禁止拧紧操作!"); |
|
454 |
} |
|
455 |
} |
b77303
|
456 |
BsFormulaChildInfo listQuery = new BsFormulaChildInfo(); |
懒 |
457 |
listQuery.setParamCode(bsFormulaChildInfo.getParamCode()); |
16714e
|
458 |
listQuery.setProcessesCode(bsFormulaChildInfo.getLocationCode()); |
b77303
|
459 |
String paramCode = bsFormulaChildInfo.getTightenTheArray(); |
懒 |
460 |
if(paramCode.contains("N")){ |
|
461 |
List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery); |
|
462 |
bsFormulaChildInfos.get(0).setResults("NG"); |
|
463 |
bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getTightenTheArray()); |
|
464 |
bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0)); |
|
465 |
return AjaxResult.error("扫描结果NG,请重新扫描!"); |
|
466 |
}else { |
|
467 |
List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery); |
982c84
|
468 |
if(bsFormulaChildInfos.get(0).getSpareField2()!=null&&bsFormulaChildInfos.get(0).getSpareField3()!=null){ |
A |
469 |
String tightenArray = bsFormulaChildInfo.getTightenTheArray().replace("[", "").replace("]", "").replace(" ", ""); |
|
470 |
String[] tightenDataParts = tightenArray.split(","); |
|
471 |
b = TimeUtil.isNumberInRange(Double.parseDouble(tightenDataParts[0]),Double.parseDouble(bsFormulaChildInfos.get(0).getSpareField2()),Double.parseDouble(bsFormulaChildInfos.get(0).getSpareField3())); |
4a5f2a
|
472 |
} |
982c84
|
473 |
if(b){ |
A |
474 |
bsFormulaChildInfos.get(0).setResults("OK"); |
|
475 |
bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getTightenTheArray()); |
|
476 |
bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0)); |
a759f5
|
477 |
logger.info("查询条件参数:"+listQuery); |
A |
478 |
logger.info("查询结果:"+bsFormulaChildInfos.get(0)); |
982c84
|
479 |
Integer stepNumber = Integer.valueOf(bsFormulaChildInfos.get(0).getStepSort()); |
A |
480 |
try { |
|
481 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".MStepNumber").value(stepNumber+1).build()); |
|
482 |
} catch (Exception e) { |
|
483 |
throw new RuntimeException(e); |
|
484 |
} |
4a5f2a
|
485 |
|
982c84
|
486 |
String spareField4 = bsFormulaChildInfos.get(0).getSpareField4(); |
A |
487 |
if (spareField4 != null && !spareField4.isEmpty()) { |
|
488 |
// 执行操作 |
|
489 |
if(bsFormulaChildInfos.get(0).getSpareField4().equals("1")){ |
|
490 |
try { |
|
491 |
// //更新过站记录表出站时间 |
|
492 |
// DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection(); |
|
493 |
// daPassingStationCollection.setWorkOrderNo(bsFormulaChildInfo.getWorkOrderNo()); |
|
494 |
// List<DaPassingStationCollection> daPassingStationCollections = daPassingStationCollectionMapper.selectDaPassingStationCollectionList(daPassingStationCollection); |
|
495 |
// daPassingStationCollections.get(0).setOutboundTime(new Date()); |
|
496 |
// daPassingStationCollectionMapper.updateDaPassingStationCollection(daPassingStationCollections.get(0)); |
|
497 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".RecordDataDone").value(21).build()); |
|
498 |
WebSocketUsers.sendMessageToUserByText(map.get(bsFormulaChildInfo.getLocationCode()), "OUT"); |
|
499 |
} catch (Exception e) { |
|
500 |
throw new RuntimeException(e); |
|
501 |
} |
3c2299
|
502 |
} |
懒 |
503 |
} |
982c84
|
504 |
}else { |
A |
505 |
List<BsFormulaChildInfo> bsFormulaChildInfos1 = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery); |
|
506 |
bsFormulaChildInfos1.get(0).setResults("NG"); |
|
507 |
String originalString = bsFormulaChildInfo.getTightenTheArray(); |
|
508 |
String modifiedString = originalString.replaceFirst("OK", "NG"); |
|
509 |
bsFormulaChildInfos1.get(0).setCollectData(modifiedString); |
|
510 |
bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos1.get(0)); |
|
511 |
return AjaxResult.error("扫描结果NG,请重新扫描!"); |
3c2299
|
512 |
} |
懒 |
513 |
|
b77303
|
514 |
} |
懒 |
515 |
return AjaxResult.success("扫描成功!"); |
|
516 |
} |
|
517 |
|
|
518 |
|
|
519 |
|
|
520 |
|
e57a89
|
521 |
} |