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