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