-
admin
2024-06-18 bdb4046a1ed5358a94cc9ce846f2a1ec88e5d5ec
提交 | 用户 | 时间
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";
bdb404 217 //        BsFormulaChildInfo getMaterTwo = new BsFormulaChildInfo();
A 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("")){
224 ////                return AjaxResult.success("扫描未完成,禁止拧紧操作!");
225 //            }
226 //        }
2c7661 227         BsFormulaChildInfo listQuery = new BsFormulaChildInfo();
A 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();
bdb404 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
bdb404 376     public AjaxResult checkMaterialCode(BsFormulaChildInfo bsFormulaChildInfo) {
A 377         String result = "1";
378         BsFormulaChildInfo getMaterTwo = new BsFormulaChildInfo();
379         getMaterTwo.setProcessesCode(bsFormulaChildInfo.getLocationCode());
380         getMaterTwo.setOperationType("2");
381         List<BsFormulaChildInfo> operationType = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(getMaterTwo);
382         List<String> collect = operationType.stream().map(BsFormulaChildInfo::getResults).collect(Collectors.toList());
383         for (String s : collect) {
384             if(s.equals("")){
385                 result = "2";
386             }
387         }
388         return AjaxResult.success(result);
389     }
390
391     @Override
b77303 392     public BsFormulaChildInfo releaseCheck(BsFormulaChildInfo bsFormulaChildInfo) {
e57a89 393         return bsFormulaChildInfoMapper.releaseCheck(bsFormulaChildInfo);
394     }
395
c5e9c5 396     //1-非本工位物料 2-正常扫描可继续下次 3-扫描结束已经是最后一位工步
e57a89 397     @Override
398     public AjaxResult updateResults(BsFormulaChildInfo bsFormulaChildInfo) {
c5e9c5 399         String result = "";
5316c5 400         List<BsFormulaChildInfo> bsFormulaChildInfos = new ArrayList<>();
A 401         List<BsFormulaChildInfo> infos = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>()
e70fb4 402                 .eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getLocationCode())
A 403                 .eq(BsFormulaChildInfo::getProductCode, bsFormulaChildInfo.getProductCode())
5316c5 404                 .eq(BsFormulaChildInfo::getOperationType, "2")
e70fb4 405         );
5316c5 406         for (BsFormulaChildInfo formulaChildInfo : infos) {
A 407             if(bsFormulaChildInfo.getScanBarcode().contains(formulaChildInfo.getMaterialCode())){
408                 bsFormulaChildInfos.add(formulaChildInfo);
409                 break;
410             }
411         }
e57a89 412         if(bsFormulaChildInfos.size()>0){
c5e9c5 413             String spareField4 = bsFormulaChildInfos.get(0).getSpareField4();
3c2299 414             bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getScanBarcode());
e57a89 415             bsFormulaChildInfos.get(0).setResults("OK");
416             bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0));
49c784 417             bsFormulaChildInfo.setParamValue(bsFormulaChildInfo.getScanBarcode());
b64ed2 418             bsFormulaChildInfo.setParamCode(bsFormulaChildInfos.get(0).getParamCode());
49c784 419             bsFormulaChildInfo.setSfcBarcode(bsFormulaChildInfo.getSfcBarcode());
b64ed2 420             addParameterCollection(bsFormulaChildInfo);
4a5f2a 421
A 422 //            Integer stepNumber = Integer.valueOf(bsFormulaChildInfos.get(0).getStepSort());
423 //            try {
424 //                miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".StepNumber").value(stepNumber).build());
425 //            } catch (Exception e) {
426 //                throw new RuntimeException(e);
427 //            }
428
c5e9c5 429             if (spareField4 != null && !spareField4.isEmpty()) {
430                 // 执行操作
431                 if(bsFormulaChildInfos.get(0).getSpareField4().equals("1")){
432                     try {
433                         result = "3";
bdb404 434 //                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".RecordDataDone").value(21).build());
c5e9c5 435                     } catch (Exception e) {
436                         throw new RuntimeException(e);
437                     }
438                 }
439             }
e57a89 440         }else {
c5e9c5 441             result = "1";
e57a89 442         }
c5e9c5 443         return AjaxResult.success(result);
e57a89 444     }
445
b64ed2 446     public void addParameterCollection(BsFormulaChildInfo bsFormulaChildInfo){
447         DaParamCollection daParamCollection = new DaParamCollection();
448         daParamCollection.setParamCode(bsFormulaChildInfo.getParamCode());
449         daParamCollection.setWorkOrderNo(bsFormulaChildInfo.getWorkOrderNo());
450         daParamCollection.setLocationCode(bsFormulaChildInfo.getLocationCode());
451         daParamCollection.setParamValue(bsFormulaChildInfo.getParamValue());
452         daParamCollection.setProductCode(bsFormulaChildInfo.getProductCode());
453         daParamCollection.setCollectionTime(new Date());
49c784 454         daParamCollection.setSfcCode(bsFormulaChildInfo.getSfcBarcode());
b64ed2 455         daParamCollectionMapper.insertDaParamCollection(daParamCollection);
8cfe20 456
A 457         DaParamCollectionTemp daParamCollectionTemp = new DaParamCollectionTemp();
458         daParamCollectionTemp.setParamCode(bsFormulaChildInfo.getParamCode());
459         daParamCollectionTemp.setWorkOrderNo(bsFormulaChildInfo.getWorkOrderNo());
460         daParamCollectionTemp.setLocationCode(bsFormulaChildInfo.getLocationCode());
461         daParamCollectionTemp.setParamValue(bsFormulaChildInfo.getParamValue());
462         daParamCollectionTemp.setProductCode(bsFormulaChildInfo.getProductCode());
463         daParamCollectionTemp.setCollectionTime(new Date());
464         daParamCollectionTemp.setSfcCode(bsFormulaChildInfo.getSfcBarcode());
465         daParamCollectionTempService.save(daParamCollectionTemp);
b64ed2 466     }
467
06713a 468     public void jrmAddParameterCollection(BsFormulaChildInfo bsFormulaChildInfo){
A 469         String scanBarCode = bsFormulaChildInfo.getSfcBarcode();
470         String[] modeleSplit = scanBarCode.split(",");
d545f1 471 //        for (String modele : modeleSplit) {
06713a 472             DaParamCollection daParamCollection = new DaParamCollection();
A 473             daParamCollection.setParamCode(bsFormulaChildInfo.getParamCode());
474             daParamCollection.setWorkOrderNo(bsFormulaChildInfo.getWorkOrderNo());
475             daParamCollection.setLocationCode(bsFormulaChildInfo.getLocationCode());
476             daParamCollection.setParamValue(bsFormulaChildInfo.getParamValue());
477             daParamCollection.setProductCode(bsFormulaChildInfo.getProductCode());
478             daParamCollection.setCollectionTime(new Date());
d545f1 479             if(bsFormulaChildInfo.getParamCode().contains("B")){
A 480                 daParamCollection.setSfcCode(modeleSplit[1]);
481             }else {
482                 daParamCollection.setSfcCode(modeleSplit[0]);
483             }
484 //            daParamCollection.setSfcCode(modele);
06713a 485             daParamCollectionMapper.insertDaParamCollection(daParamCollection);
d545f1 486 //        }
06713a 487
8cfe20 488             DaParamCollectionTemp daParamCollectionTemp = new DaParamCollectionTemp();
A 489             daParamCollectionTemp.setParamCode(bsFormulaChildInfo.getParamCode());
490             daParamCollectionTemp.setWorkOrderNo(bsFormulaChildInfo.getWorkOrderNo());
491             daParamCollectionTemp.setLocationCode(bsFormulaChildInfo.getLocationCode());
492             daParamCollectionTemp.setParamValue(bsFormulaChildInfo.getParamValue());
493             daParamCollectionTemp.setProductCode(bsFormulaChildInfo.getProductCode());
494             daParamCollectionTemp.setCollectionTime(new Date());
495             if(bsFormulaChildInfo.getParamCode().contains("B")){
496                 daParamCollectionTemp.setSfcCode(modeleSplit[1]);
497             }else {
498                 daParamCollectionTemp.setSfcCode(modeleSplit[0]);
499             }
500             daParamCollectionTempService.save(daParamCollectionTemp);
06713a 501     }
A 502
e57a89 503     @Override
504     public AjaxResult workpieceRelease(BsFormulaChildInfo bsFormulaChildInfo) {
63b254 505         List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>()
506                 .eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getLocationCode())
507                 .eq(BsFormulaChildInfo::getProductCode, bsFormulaChildInfo.getProductCode()));
508         for (BsFormulaChildInfo info : list) {
e70fb4 509             info.setCollectData("");
63b254 510             info.setResults("");
511             bsFormulaChildInfoService.saveOrUpdate(info);
a759f5 512         }
A 513         try {
514             daParamCollectionService.pushGeelycvMesFeedback(bsFormulaChildInfo.getProductBarcode(), bsFormulaChildInfo.getLocationCode());
515             String barCode = bsFormulaChildInfo.getProductBarcode();
516             String locationCode = bsFormulaChildInfo.getLocationCode();
517             DaPassingStationCollection passingStationCollectionOne = daPassingStationCollectionService.getOne(new LambdaQueryWrapper<DaPassingStationCollection>().eq(DaPassingStationCollection::getSfcCode, barCode).eq(DaPassingStationCollection::getLocationCode, locationCode));
518             if (passingStationCollectionOne != null) {
519                 passingStationCollectionOne.setOutRsSign("1");
520                 passingStationCollectionOne.setOutboundTime(new Date());
521                 daPassingStationCollectionService.saveOrUpdate(passingStationCollectionOne);
522             }
523         }catch (Exception e){
63b254 524         }
e57a89 525         return AjaxResult.success();
526     }
b77303 527
528     @Override
529     public AjaxResult updateTighteningFormula(BsFormulaChildInfo bsFormulaChildInfo) {
982c84 530         Boolean b = true;
7bee80 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         }
b77303 541         BsFormulaChildInfo listQuery = new BsFormulaChildInfo();
542         listQuery.setParamCode(bsFormulaChildInfo.getParamCode());
16714e 543         listQuery.setProcessesCode(bsFormulaChildInfo.getLocationCode());
b77303 544         String paramCode = bsFormulaChildInfo.getTightenTheArray();
545         if(paramCode.contains("N")){
546             List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery);
547             bsFormulaChildInfos.get(0).setResults("NG");
548             bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getTightenTheArray());
549             bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0));
550             return AjaxResult.error("扫描结果NG,请重新扫描!");
551         }else {
552             List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery);
982c84 553             if(bsFormulaChildInfos.get(0).getSpareField2()!=null&&bsFormulaChildInfos.get(0).getSpareField3()!=null){
A 554                 String tightenArray = bsFormulaChildInfo.getTightenTheArray().replace("[", "").replace("]", "").replace(" ", "");
555                 String[] tightenDataParts = tightenArray.split(",");
556                 b = TimeUtil.isNumberInRange(Double.parseDouble(tightenDataParts[0]),Double.parseDouble(bsFormulaChildInfos.get(0).getSpareField2()),Double.parseDouble(bsFormulaChildInfos.get(0).getSpareField3()));
4a5f2a 557             }
982c84 558             if(b){
A 559                 bsFormulaChildInfos.get(0).setResults("OK");
560                 bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getTightenTheArray());
561                 bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0));
a759f5 562                 logger.info("查询条件参数:"+listQuery);
A 563                 logger.info("查询结果:"+bsFormulaChildInfos.get(0));
982c84 564                 Integer stepNumber = Integer.valueOf(bsFormulaChildInfos.get(0).getStepSort());
A 565                 try {
566                     miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".MStepNumber").value(stepNumber+1).build());
567                 } catch (Exception e) {
568                     throw new RuntimeException(e);
569                 }
4a5f2a 570
982c84 571                 String spareField4 = bsFormulaChildInfos.get(0).getSpareField4();
A 572                 if (spareField4 != null && !spareField4.isEmpty()) {
573                     // 执行操作
574                     if(bsFormulaChildInfos.get(0).getSpareField4().equals("1")){
575                         try {
576     //                        //更新过站记录表出站时间
577     //                        DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection();
578     //                        daPassingStationCollection.setWorkOrderNo(bsFormulaChildInfo.getWorkOrderNo());
579     //                        List<DaPassingStationCollection> daPassingStationCollections = daPassingStationCollectionMapper.selectDaPassingStationCollectionList(daPassingStationCollection);
580     //                        daPassingStationCollections.get(0).setOutboundTime(new Date());
581     //                        daPassingStationCollectionMapper.updateDaPassingStationCollection(daPassingStationCollections.get(0));
bdb404 582 //                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".RecordDataDone").value(21).build());
982c84 583                             WebSocketUsers.sendMessageToUserByText(map.get(bsFormulaChildInfo.getLocationCode()), "OUT");
A 584                         } catch (Exception e) {
585                             throw new RuntimeException(e);
586                         }
3c2299 587                     }
588                 }
982c84 589             }else {
A 590                 List<BsFormulaChildInfo> bsFormulaChildInfos1 = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery);
591                 bsFormulaChildInfos1.get(0).setResults("NG");
592                 String originalString = bsFormulaChildInfo.getTightenTheArray();
593                 String modifiedString = originalString.replaceFirst("OK", "NG");
594                 bsFormulaChildInfos1.get(0).setCollectData(modifiedString);
595                 bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos1.get(0));
596                 return AjaxResult.error("扫描结果NG,请重新扫描!");
3c2299 597             }
598
b77303 599         }
600         return AjaxResult.success("扫描成功!");
601     }
602
603
604
605
e57a89 606 }