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