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