admin
6 天以前 768498719683f85e5ed19c73eb3d14cdbf420df4
提交 | 用户 | 时间
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();
bdb404 341 //                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+locationCode+".RecordDataDone").value(21).build());
06713a 342                     } catch (Exception e) {
A 343                         throw new RuntimeException(e);
344                     }
345                 }
346             }
347         }else {
348             result = "1";
349         }
350         return AjaxResult.success(result);
351     }
352
353     @Override
8cfe20 354     public AjaxResult jrmWorkpieceRelease(BsFormulaChildInfo bsFormulaChildInfo) {
768498 355         this.clearCollectDataAndResultsByProcessesCode(bsFormulaChildInfo);
A 356 //        List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>()
357 //                .eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getLocationCode())
358 //                .eq(BsFormulaChildInfo::getProductCode, bsFormulaChildInfo.getProductCode()));
359 //        for (BsFormulaChildInfo info : list) {
360 //            info.setCollectData("");
361 //            info.setResults("");
362 //            bsFormulaChildInfoService.saveOrUpdate(info);
363 //        }
8cfe20 364         String[] split = bsFormulaChildInfo.getProductBarcode().split(",");
A 365         try {
366             for (int i = 0; i < split.length; i++) {
367                 daParamCollectionService.pushGeelycvMesFeedback(split[i], bsFormulaChildInfo.getLocationCode());
2fbce7 368
A 369                 String barCode = split[i];
8cfe20 370                 String locationCode = bsFormulaChildInfo.getLocationCode();
2fbce7 371
A 372                 if(StringUtils.isNotBlank(locationCode)&&StringUtils.isNotBlank(barCode)){
373                     DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection();
374                     daPassingStationCollection.setOutRsSign("1");
375                     daPassingStationCollection.setOutboundTime(new Date());
376                     daPassingStationCollection.setSfcCode(barCode);
377                     daPassingStationCollection.setLocationCode(locationCode);
378                     int updateDaPassingStation = daPassingStationCollectionService.updateDaPassingStationCollectionBySfcCodeAndLocationCode(daPassingStationCollection);
379                     logger.info("加热膜人工工位更新过站记录updateDaPassingStationCollectionBySfcCodeAndLocationCode:更新了{}条数据-更新条件pack码{}-工位{}",updateDaPassingStation,barCode,locationCode);
8cfe20 380                 }
2fbce7 381
A 382 //                DaPassingStationCollection passingStationCollectionOne = daPassingStationCollectionService.getOne(new LambdaQueryWrapper<DaPassingStationCollection>().eq(DaPassingStationCollection::getSfcCode, barCode).eq(DaPassingStationCollection::getLocationCode, locationCode));
383 //                if (passingStationCollectionOne != null) {
384 //                    passingStationCollectionOne.setOutRsSign("1");
385 //                    passingStationCollectionOne.setOutboundTime(new Date());
386 //                    daPassingStationCollectionService.saveOrUpdate(passingStationCollectionOne);
387 //                }
8cfe20 388             }
A 389         }catch (Exception e){
390         }
391         return AjaxResult.success();
392     }
393
394     @Override
395     public AjaxResult clearWorkpieceRelease(BsFormulaChildInfo bsFormulaChildInfo) {
768498 396 //        List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>()
A 397 //                .eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getLocationCode())
398 //                .eq(BsFormulaChildInfo::getProductCode, bsFormulaChildInfo.getProductCode()));
399 //        for (BsFormulaChildInfo info : list) {
400 //            info.setCollectData("");
401 //            info.setResults("");
402 //            bsFormulaChildInfoService.saveOrUpdate(info);
403 //        }
404         this.clearCollectDataAndResultsByProcessesCode(bsFormulaChildInfo);
8cfe20 405         return AjaxResult.success();
A 406     }
407
408     @Override
bdb404 409     public AjaxResult checkMaterialCode(BsFormulaChildInfo bsFormulaChildInfo) {
A 410         String result = "1";
411         BsFormulaChildInfo getMaterTwo = new BsFormulaChildInfo();
412         getMaterTwo.setProcessesCode(bsFormulaChildInfo.getLocationCode());
413         getMaterTwo.setOperationType("2");
414         List<BsFormulaChildInfo> operationType = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(getMaterTwo);
415         List<String> collect = operationType.stream().map(BsFormulaChildInfo::getResults).collect(Collectors.toList());
416         for (String s : collect) {
417             if(s.equals("")){
418                 result = "2";
419             }
420         }
421         return AjaxResult.success(result);
768498 422     }
A 423
424     @Override
425     public AjaxResult clearCollectDataAndResultsByProcessesCode(BsFormulaChildInfo bsFormulaChildInfo) {
426         LambdaUpdateWrapper<BsFormulaChildInfo> updateWrapper = new LambdaUpdateWrapper();
427         updateWrapper.set(BsFormulaChildInfo::getCollectData, "");
428         updateWrapper.set(BsFormulaChildInfo::getResults,"");
429         updateWrapper.eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getLocationCode());
430         BsFormulaChildInfo info = new BsFormulaChildInfo();
431         boolean update = this.update(info,updateWrapper);
432         return AjaxResult.success(update);
bdb404 433     }
A 434
435     @Override
b77303 436     public BsFormulaChildInfo releaseCheck(BsFormulaChildInfo bsFormulaChildInfo) {
e57a89 437         return bsFormulaChildInfoMapper.releaseCheck(bsFormulaChildInfo);
438     }
439
c5e9c5 440     //1-非本工位物料 2-正常扫描可继续下次 3-扫描结束已经是最后一位工步
e57a89 441     @Override
442     public AjaxResult updateResults(BsFormulaChildInfo bsFormulaChildInfo) {
c5e9c5 443         String result = "";
5316c5 444         List<BsFormulaChildInfo> bsFormulaChildInfos = new ArrayList<>();
A 445         List<BsFormulaChildInfo> infos = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>()
e70fb4 446                 .eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getLocationCode())
A 447                 .eq(BsFormulaChildInfo::getProductCode, bsFormulaChildInfo.getProductCode())
5316c5 448                 .eq(BsFormulaChildInfo::getOperationType, "2")
e70fb4 449         );
5316c5 450         for (BsFormulaChildInfo formulaChildInfo : infos) {
A 451             if(bsFormulaChildInfo.getScanBarcode().contains(formulaChildInfo.getMaterialCode())){
2fbce7 452                 if(null != formulaChildInfo.getCollectData()){
A 453                     if(!formulaChildInfo.getCollectData().equals(bsFormulaChildInfo.getScanBarcode())){
454                         bsFormulaChildInfos.add(formulaChildInfo);
455                     }else{
456                         result = "2";
457                         return AjaxResult.success(result);
458                     }
459                 }else{
460                     bsFormulaChildInfos.add(formulaChildInfo);
461                 }
5316c5 462                 break;
A 463             }
464         }
e57a89 465         if(bsFormulaChildInfos.size()>0){
c5e9c5 466             String spareField4 = bsFormulaChildInfos.get(0).getSpareField4();
3c2299 467             bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getScanBarcode());
e57a89 468             bsFormulaChildInfos.get(0).setResults("OK");
469             bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0));
49c784 470             bsFormulaChildInfo.setParamValue(bsFormulaChildInfo.getScanBarcode());
b64ed2 471             bsFormulaChildInfo.setParamCode(bsFormulaChildInfos.get(0).getParamCode());
49c784 472             bsFormulaChildInfo.setSfcBarcode(bsFormulaChildInfo.getSfcBarcode());
b64ed2 473             addParameterCollection(bsFormulaChildInfo);
4a5f2a 474
A 475 //            Integer stepNumber = Integer.valueOf(bsFormulaChildInfos.get(0).getStepSort());
476 //            try {
477 //                miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".StepNumber").value(stepNumber).build());
478 //            } catch (Exception e) {
479 //                throw new RuntimeException(e);
480 //            }
481
c5e9c5 482             if (spareField4 != null && !spareField4.isEmpty()) {
483                 // 执行操作
484                 if(bsFormulaChildInfos.get(0).getSpareField4().equals("1")){
485                     try {
486                         result = "3";
bdb404 487 //                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".RecordDataDone").value(21).build());
c5e9c5 488                     } catch (Exception e) {
489                         throw new RuntimeException(e);
490                     }
491                 }
492             }
e57a89 493         }
c5e9c5 494         return AjaxResult.success(result);
e57a89 495     }
496
b64ed2 497     public void addParameterCollection(BsFormulaChildInfo bsFormulaChildInfo){
498         DaParamCollection daParamCollection = new DaParamCollection();
499         daParamCollection.setParamCode(bsFormulaChildInfo.getParamCode());
500         daParamCollection.setWorkOrderNo(bsFormulaChildInfo.getWorkOrderNo());
501         daParamCollection.setLocationCode(bsFormulaChildInfo.getLocationCode());
502         daParamCollection.setParamValue(bsFormulaChildInfo.getParamValue());
503         daParamCollection.setProductCode(bsFormulaChildInfo.getProductCode());
504         daParamCollection.setCollectionTime(new Date());
49c784 505         daParamCollection.setSfcCode(bsFormulaChildInfo.getSfcBarcode());
b64ed2 506         daParamCollectionMapper.insertDaParamCollection(daParamCollection);
8cfe20 507
A 508         DaParamCollectionTemp daParamCollectionTemp = new DaParamCollectionTemp();
509         daParamCollectionTemp.setParamCode(bsFormulaChildInfo.getParamCode());
510         daParamCollectionTemp.setWorkOrderNo(bsFormulaChildInfo.getWorkOrderNo());
511         daParamCollectionTemp.setLocationCode(bsFormulaChildInfo.getLocationCode());
512         daParamCollectionTemp.setParamValue(bsFormulaChildInfo.getParamValue());
513         daParamCollectionTemp.setProductCode(bsFormulaChildInfo.getProductCode());
514         daParamCollectionTemp.setCollectionTime(new Date());
515         daParamCollectionTemp.setSfcCode(bsFormulaChildInfo.getSfcBarcode());
516         daParamCollectionTempService.save(daParamCollectionTemp);
b64ed2 517     }
518
06713a 519     public void jrmAddParameterCollection(BsFormulaChildInfo bsFormulaChildInfo){
A 520         String scanBarCode = bsFormulaChildInfo.getSfcBarcode();
521         String[] modeleSplit = scanBarCode.split(",");
d545f1 522 //        for (String modele : modeleSplit) {
06713a 523             DaParamCollection daParamCollection = new DaParamCollection();
A 524             daParamCollection.setParamCode(bsFormulaChildInfo.getParamCode());
525             daParamCollection.setWorkOrderNo(bsFormulaChildInfo.getWorkOrderNo());
526             daParamCollection.setLocationCode(bsFormulaChildInfo.getLocationCode());
527             daParamCollection.setParamValue(bsFormulaChildInfo.getParamValue());
528             daParamCollection.setProductCode(bsFormulaChildInfo.getProductCode());
529             daParamCollection.setCollectionTime(new Date());
d545f1 530             if(bsFormulaChildInfo.getParamCode().contains("B")){
A 531                 daParamCollection.setSfcCode(modeleSplit[1]);
532             }else {
533                 daParamCollection.setSfcCode(modeleSplit[0]);
534             }
535 //            daParamCollection.setSfcCode(modele);
06713a 536             daParamCollectionMapper.insertDaParamCollection(daParamCollection);
d545f1 537 //        }
06713a 538
8cfe20 539             DaParamCollectionTemp daParamCollectionTemp = new DaParamCollectionTemp();
A 540             daParamCollectionTemp.setParamCode(bsFormulaChildInfo.getParamCode());
541             daParamCollectionTemp.setWorkOrderNo(bsFormulaChildInfo.getWorkOrderNo());
542             daParamCollectionTemp.setLocationCode(bsFormulaChildInfo.getLocationCode());
543             daParamCollectionTemp.setParamValue(bsFormulaChildInfo.getParamValue());
544             daParamCollectionTemp.setProductCode(bsFormulaChildInfo.getProductCode());
545             daParamCollectionTemp.setCollectionTime(new Date());
546             if(bsFormulaChildInfo.getParamCode().contains("B")){
547                 daParamCollectionTemp.setSfcCode(modeleSplit[1]);
548             }else {
549                 daParamCollectionTemp.setSfcCode(modeleSplit[0]);
550             }
551             daParamCollectionTempService.save(daParamCollectionTemp);
06713a 552     }
A 553
e57a89 554     @Override
555     public AjaxResult workpieceRelease(BsFormulaChildInfo bsFormulaChildInfo) {
768498 556         this.clearCollectDataAndResultsByProcessesCode(bsFormulaChildInfo);
A 557 //        List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>()
558 //                .eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getLocationCode())
559 //                .eq(BsFormulaChildInfo::getProductCode, bsFormulaChildInfo.getProductCode()));
560 //        for (BsFormulaChildInfo info : list) {
561 //            info.setCollectData("");
562 //            info.setResults("");
563 //            bsFormulaChildInfoService.saveOrUpdate(info);
564 //        }
a759f5 565         try {
A 566             daParamCollectionService.pushGeelycvMesFeedback(bsFormulaChildInfo.getProductBarcode(), bsFormulaChildInfo.getLocationCode());
768498 567 //            String barCode = bsFormulaChildInfo.getProductBarcode();
A 568 //            String locationCode = bsFormulaChildInfo.getLocationCode();
569 //
570 //            if(StringUtils.isNotBlank(locationCode)&&StringUtils.isNotBlank(barCode)){
571 //                DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection();
572 //                daPassingStationCollection.setOutRsSign("1");
573 //                daPassingStationCollection.setOutboundTime(new Date());
574 //                daPassingStationCollection.setSfcCode(barCode);
575 //                daPassingStationCollection.setLocationCode(locationCode);
576 //                int updateDaPassingStation = daPassingStationCollectionService.updateDaPassingStationCollectionBySfcCodeAndLocationCode(daPassingStationCollection);
577 //                logger.info("普通人工工位更新过站记录updateDaPassingStationCollectionBySfcCodeAndLocationCode:更新了{}条数据-更新条件pack码{}-工位{}",updateDaPassingStation,barCode,locationCode);
578 //            }
2fbce7 579
A 580 //            DaPassingStationCollection passingStationCollectionOne = daPassingStationCollectionService.getOne(new LambdaQueryWrapper<DaPassingStationCollection>().eq(DaPassingStationCollection::getSfcCode, barCode).eq(DaPassingStationCollection::getLocationCode, locationCode));
581 //            if (passingStationCollectionOne != null) {
582 //                passingStationCollectionOne.setOutRsSign("1");
583 //                passingStationCollectionOne.setOutboundTime(new Date());
584 //                daPassingStationCollectionService.saveOrUpdate(passingStationCollectionOne);
585 //            }
a759f5 586         }catch (Exception e){
63b254 587         }
e57a89 588         return AjaxResult.success();
589     }
b77303 590
591     @Override
592     public AjaxResult updateTighteningFormula(BsFormulaChildInfo bsFormulaChildInfo) {
982c84 593         Boolean b = true;
7bee80 594         BsFormulaChildInfo getMaterTwo = new BsFormulaChildInfo();
595         getMaterTwo.setProcessesCode(bsFormulaChildInfo.getLocationCode());
596         getMaterTwo.setOperationType("2");
597         List<BsFormulaChildInfo> operationType = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(getMaterTwo);
598         List<String> collect = operationType.stream().map(BsFormulaChildInfo::getResults).collect(Collectors.toList());
599         for (String s : collect) {
600             if(s.equals("")){
2fbce7 601                 return AjaxResult.error("扫码未完成,禁止拧紧操作!");
7bee80 602             }
603         }
2fbce7 604
A 605         //添加拧紧参数-参数采集表
606         DaParamCollection daParamCollection = new DaParamCollection();
607         daParamCollection.setParamCode(bsFormulaChildInfo.getParamCode());
608         daParamCollection.setTightenTheArray(bsFormulaChildInfo.getTightenTheArray());
609         daParamCollection.setProductBarcode(bsFormulaChildInfo.getProductBarcode());
610         daParamCollection.setWorkOrderNo(bsFormulaChildInfo.getWorkOrderNo());
611         daParamCollection.setLocationCode(bsFormulaChildInfo.getLocationCode());
612         daParamCollection.setProductCode(bsFormulaChildInfo.getProductCode());
613         daParamCollectionService.addTighteningParameters(daParamCollection);
614
b77303 615         String paramCode = bsFormulaChildInfo.getTightenTheArray();
2fbce7 616         if(paramCode.contains("NG")){
A 617        /*     List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery);
b77303 618             bsFormulaChildInfos.get(0).setResults("NG");
619             bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getTightenTheArray());
2fbce7 620 */
A 621             bsFormulaChildInfo.setResults("NG");
622             bsFormulaChildInfo.setCollectData(bsFormulaChildInfo.getTightenTheArray());
623             bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfo);
624             return AjaxResult.error("拧紧结果NG,请重新拧紧!");
b77303 625         }else {
2fbce7 626             //List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery);
A 627             if(bsFormulaChildInfo.getSpareField2()!=null&&bsFormulaChildInfo.getSpareField3()!=null){
982c84 628                 String tightenArray = bsFormulaChildInfo.getTightenTheArray().replace("[", "").replace("]", "").replace(" ", "");
A 629                 String[] tightenDataParts = tightenArray.split(",");
2fbce7 630                 b = TimeUtil.isNumberInRange(Double.parseDouble(tightenDataParts[0]),Double.parseDouble(bsFormulaChildInfo.getSpareField2()),Double.parseDouble(bsFormulaChildInfo.getSpareField3()));
4a5f2a 631             }
982c84 632             if(b){
2fbce7 633                 bsFormulaChildInfo.setResults("OK");
A 634                 bsFormulaChildInfo.setCollectData(bsFormulaChildInfo.getTightenTheArray());
635                 bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfo);
636
637                 Integer stepNumber = Integer.valueOf(bsFormulaChildInfo.getStepSort());
982c84 638                 try {
A 639                     miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".MStepNumber").value(stepNumber+1).build());
640                 } catch (Exception e) {
641                     throw new RuntimeException(e);
642                 }
4a5f2a 643
2fbce7 644                 String spareField4 = bsFormulaChildInfo.getSpareField4();
982c84 645                 if (spareField4 != null && !spareField4.isEmpty()) {
A 646                     // 执行操作
2fbce7 647                     if(spareField4.equals("1")){
982c84 648                         try {
A 649     //                        //更新过站记录表出站时间
650     //                        DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection();
651     //                        daPassingStationCollection.setWorkOrderNo(bsFormulaChildInfo.getWorkOrderNo());
652     //                        List<DaPassingStationCollection> daPassingStationCollections = daPassingStationCollectionMapper.selectDaPassingStationCollectionList(daPassingStationCollection);
653     //                        daPassingStationCollections.get(0).setOutboundTime(new Date());
654     //                        daPassingStationCollectionMapper.updateDaPassingStationCollection(daPassingStationCollections.get(0));
bdb404 655 //                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".RecordDataDone").value(21).build());
982c84 656                             WebSocketUsers.sendMessageToUserByText(map.get(bsFormulaChildInfo.getLocationCode()), "OUT");
A 657                         } catch (Exception e) {
658                             throw new RuntimeException(e);
659                         }
3c2299 660                     }
661                 }
982c84 662             }else {
2fbce7 663                 //List<BsFormulaChildInfo> bsFormulaChildInfos1 = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery);
A 664                 bsFormulaChildInfo.setResults("NG");
982c84 665                 String originalString = bsFormulaChildInfo.getTightenTheArray();
A 666                 String modifiedString = originalString.replaceFirst("OK", "NG");
2fbce7 667                 bsFormulaChildInfo.setCollectData(modifiedString);
A 668                 bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfo);
669                 return AjaxResult.error("拧紧结果NG,请重新拧紧!");
3c2299 670             }
671
b77303 672         }
2fbce7 673
A 674
675         return AjaxResult.success("拧紧成功!");
b77303 676     }
677
678
679
680
e57a89 681 }