cl
2024-07-07 eda15ed46a021ae8ea988c9438b23b6a14359819
提交 | 用户 | 时间
0ca254 1 package com.jcdm.main.plcserver.sub;
A 2
3
4 import cn.hutool.core.collection.CollUtil;
5 import cn.hutool.core.util.ObjectUtil;
6 import cn.hutool.core.util.StrUtil;
109e2f 7 import cn.hutool.http.HttpRequest;
C 8 import cn.hutool.http.HttpResponse;
ef58b9 9 import cn.hutool.json.JSONObject;
109e2f 10 import cn.hutool.json.JSONUtil;
0ca254 11 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
ef58b9 12 import com.jcdm.common.core.domain.AjaxResult;
0ca254 13 import com.jcdm.framework.websocket.WebSocketUsers;
A 14 import com.jcdm.main.constant.Constants;
15 import com.jcdm.main.da.collectionParamConf.domain.DaCollectionParamConf;
16 import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService;
17 import com.jcdm.main.da.paramCollection.domain.DaParamCollection;
18 import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService;
19 import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection;
20 import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService;
5b755f 21 import com.jcdm.main.da.testDeviceInterfaceTemp.domain.DaTestDeviceInterfaceTemp;
C 22 import com.jcdm.main.da.testDeviceInterfaceTemp.service.IDaTestDeviceInterfaceTempService;
8c5c9c 23 import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo;
0ca254 24 import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService;
8c5c9c 25 import com.jcdm.main.plcserver.util.TimeUtil;
ef58b9 26 import com.jcdm.main.restful.factoryMes.service.RestfulService;
0ca254 27 import com.jcdm.main.restful.qingYan.doman.ChildVO;
A 28 import com.jcdm.main.restful.qingYan.doman.ParentVO;
29 import com.kangaroohy.milo.model.ReadWriteEntity;
30 import com.kangaroohy.milo.runner.subscription.SubscriptionCallback;
31 import com.kangaroohy.milo.service.MiloService;
32 import lombok.extern.slf4j.Slf4j;
109e2f 33 import org.springframework.beans.factory.annotation.Value;
0ca254 34 import org.springframework.stereotype.Component;
ef58b9 35 import org.springframework.web.bind.annotation.GetMapping;
0ca254 36
A 37 import javax.websocket.Session;
38 import java.text.SimpleDateFormat;
39 import java.util.*;
109e2f 40 import java.util.concurrent.CompletableFuture;
0ca254 41 import java.util.stream.Collectors;
109e2f 42
0ca254 43
A 44 @Slf4j
45 @Component
46 public class OPCUaSubscription implements SubscriptionCallback {
47
8c5c9c 48     public static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
0ca254 49
A 50
8c5c9c 51     Map<String, Session> map = WebSocketUsers.getUsers();
0ca254 52     public static MiloService miloService;
A 53
54
109e2f 55     public static IDaPassingStationCollectionService daPassingStationCollectionService;
0ca254 56
A 57     public static IDaCollectionParamConfService collectionParamConfService;
58
59     public static IDaParamCollectionService daParamCollectionService;
60
61     public static IOmProductionOrdeInfoService omProductionOrdeInfoService;
62
5b755f 63     public static IDaTestDeviceInterfaceTempService daTestDeviceInterfaceTempService;
C 64
0d7433 65 /*    @Value("${orderLineUrl}")
C 66     private static String orderLineUrl;*/
0ca254 67
A 68     public OPCUaSubscription(MiloService miloService,
69                              IDaPassingStationCollectionService daPassingStationCollectionService,
70                              IDaCollectionParamConfService collectionParamConfService,
71                              IDaParamCollectionService daParamCollectionService,
5b755f 72                              IOmProductionOrdeInfoService omProductionOrdeInfoService,
C 73                              IDaTestDeviceInterfaceTempService daTestDeviceInterfaceTempService) {
0ca254 74         OPCUaSubscription.miloService = miloService;
109e2f 75         OPCUaSubscription.daPassingStationCollectionService = daPassingStationCollectionService;
0ca254 76         OPCUaSubscription.collectionParamConfService = collectionParamConfService;
A 77         OPCUaSubscription.daParamCollectionService = daParamCollectionService;
78         OPCUaSubscription.omProductionOrdeInfoService = omProductionOrdeInfoService;
5b755f 79         OPCUaSubscription.daTestDeviceInterfaceTempService = daTestDeviceInterfaceTempService;
0ca254 80     }
A 81
82
83     @Override
84     public void onSubscribe(String identifier, Object value) {
109e2f 85         log.info("地址:"+identifier+"值:"+value);
0ca254 86         try {
109e2f 87             if(null != value && !Constants.ZERO.equals(value.toString())) {
0ca254 88                 String[] nodes = identifier.split("[.]");
A 89                 String thoroughfare = nodes[0];//通道
90                 String device = nodes[1];//设备
91                 String tab = nodes[2];//标记
109e2f 92                 String valueString = value.toString();//地址值
C 93                 if (Constants.RECORD_CHECK_CODE.equals(tab)){//电芯校验
94                     if (Constants.ONE.equals(valueString)){
95                         Integer scanResult = 11;
ec7e2a 96                         if (Constants.OP010.equals(device)){
109e2f 97                             //OP010工位电芯条码校验||OP030工位电芯条码校验
C 98                             Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".Scaner").getValue();
99                             if (ObjectUtil.isNotNull(value1)){
100                                 String keyCode = value1.toString();
101                                 log.info("读取到工位{}的Scaner数据:{}",device,keyCode);
102                                 //仅校验长度是否合格
103 //                                List<KeyCodeCheck> collect = keyCodeCheckService.list().stream().filter(x -> x.getKeyCode().contains(keyCode)).collect(Collectors.toList());
104 //                                if (CollUtil.isNotEmpty(collect)){
105 //                                    scanResult = 11;
0ca254 106 //                                }
A 107                             }
ec7e2a 108                         }else if(Constants.OP030.equals(device)){
C 109                             Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".Scaner").getValue();
110                             if (ObjectUtil.isNotNull(value1)){
111                                 String cellCode = value1.toString();
112                                 //反馈电芯ocv检测结果
113                                 boolean b = OCVResultFeedBack(thoroughfare, device,cellCode);
114                                 //四个电芯的状态
115                                 if (b){
116                                     scanResult = 11;
117                                 }else {
118                                     scanResult = 12;
119                                 }
120                             }else {
121                                 scanResult = 12;
122                             }
123
0ca254 124                         }
109e2f 125                         miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ScanerResult1").value(scanResult).build());
C 126                         log.info("写入到工位{}的ScanerResult1数据:{}",device,scanResult);
0ca254 127                     }
109e2f 128                 }else if (Constants.RECORD_SN.equals(tab)){//求下发模组码请9
C 129                     if (Constants.ONE.equals(valueString)){
ec7e2a 130                         miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(1).build());//没有要生产的工单
109e2f 131                     }
C 132                 }else if (Constants.RECORD_DATA.equals(tab)){//出入站
133                     if (Constants.ONE.equals(valueString)){//入站
134                         //1:告知MES托盘已到站,请求下发进站状态
135                         if (Constants.OP030.equals(device)){
136                             //反馈电芯ocv检测结果
5b755f 137                             boolean b = OCVResultFeedBack(thoroughfare, device);
2de856 138                             //四个电芯的状态
109e2f 139                             if (b){
C 140                                 miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build());
141                                 log.info("写入到工位{}的RecordDataDone数据:{}",device,11);
142                             }else {
143                                 miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build());
144                                 log.info("写入到工位{}的RecordDataDone数据:{}",device,12);
145                             }
ef58b9 146                         } else if(Constants.OP100_1.equals(device) || Constants.OP100_2.equals(device)){
C 147                             //1、进站PLC给产品类型,MES读取产品类型
e0c9c6 148                             Object productTypeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".ProductType").getValue();//产品类型
C 149                             if (ObjectUtil.isNotNull(productTypeObjcet)){
150                                 String productType = productTypeObjcet.toString();//产品类型
ef58b9 151                                 CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> {
4878fe 152                                     //调用工厂MES,保存到数据库,并且将工单传给PLC (目前临时用该方法)
ef58b9 153                                     receivingWorkOrders(thoroughfare, device);
C 154                                 });
155
156                                 miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build());
157                                 log.info("写入到工位{}的RecordDataDone数据:{}",device,11);
158                             }else{
159                                 miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build());
160                             }
161
eda15e 162                         }else if (Constants.ModuleList.contains(device)){//有模组码的工位
C 163                             Object modulCodeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue();
164                             if (ObjectUtil.isNull(modulCodeObjcet)){
165                                 miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build());
166                             }else{
167                                 miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build());
168                             }
169                         }
170                         else {
109e2f 171                             miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build());
C 172                             log.info("写入到工位{}的RecordDataDone数据:{}",device,11);
173                         }
174                     }else if (Constants.TWO.equals(valueString)){//出站
175                         //分段010-065段
176                         if (Constants.OP010.equals(device)){
177                             //010工位无过站记录,只给放行信号
178                             miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(21).build());
179                             log.info("写入到工位{}的RecordDataDone数据:{}",device,21);
aa8ab9 180                         }else if (Constants.OP020_OP090.contains(device)){
109e2f 181                             Integer result = 21;
C 182                             //读取电芯码
183                             List<String> cellCodeList = readCellCodeList(thoroughfare, device);
8c5c9c 184                             if(ObjectUtil.isNull(cellCodeList) || cellCodeList.size() != 4){
109e2f 185                                 result = 23;
C 186                             }else{
187                                 result = savePassingStation(thoroughfare, device,cellCodeList);//保存过站
2de856 188                                 if(result == 21) {
109e2f 189                                     result = saveParamCollection(thoroughfare, device,cellCodeList);//保存参数,发送工厂MES
C 190                                 }
191                             }
192                             miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(result).build());
193                             log.info("写入到工位{}的RecordDataDone数据:{}",device,result);
e0c9c6 194                         } else if (Constants.OP100_OP150.contains(device)){//人工工位
2de856 195                             WebSocketUsers.sendMessageToUserByText(map.get(device), "END");
109e2f 196                         } else {
2de856 197                             Integer result = 21;
e0c9c6 198                             Object productTypeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".ProductType").getValue();//产品类型
2de856 199                             Object modulCodeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue();
eda15e 200                             if (ObjectUtil.isNull(modulCodeObjcet)){
2de856 201                                 result = 23;
C 202                             }else{
203                                 String moduleCode = modulCodeObjcet.toString();
204                                 result = savePassingStation(thoroughfare, device,moduleCode);//保存过站
205                                 if(result == 21) {
206                                     result = saveParamCollection(thoroughfare, device,moduleCode);//保存参数,发送工厂MES
109e2f 207                                 }
C 208                             }
2de856 209                             miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(result).build());
C 210                             log.info("写入到工位{}的RecordDataDone数据:{}",device,result);
0ca254 211                         }
109e2f 212                     }
8c5c9c 213                 }  /*else if (Constants.RECORD_CHECK_CODE_1.equals(tab)) {
109e2f 214                     if (Constants.OP100_1.equals(device)){
C 215                         //钢带条码校验--发送给工厂mes
216                         miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ScanerResult11").value(11).build());
217                     } else if (Constants.OP100_2.equals(device)) {
218                         //PET带条码校验--发送给工厂mes
219                         miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ScanerResult12").value(11).build());
0ca254 220                     }
8c5c9c 221                 }*/
0ca254 222             }
A 223         } catch (Exception e) {
8c5c9c 224             log.error(e.getMessage());
109e2f 225             System.out.println(e.getMessage());
C 226             log.info(e.getMessage());
0ca254 227         }
A 228     }
229
ef58b9 230     public void receivingWorkOrders(String thoroughfare ,String device)
4878fe 231     {
C 232         String paramProductNum = "";
233         try {
234
235             List<OmProductionOrdeInfo> orderList = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>()
236                     .eq(OmProductionOrdeInfo::getOrderStatus, Constants.ONE));//工单状态
237
238             if (CollUtil.isNotEmpty(orderList)){
239                 Long id = orderList.get(0).getId();
240                 String productNum = orderList.get(0).getProductNum();//模组码
8e3998 241                 String orderNum = orderList.get(0).getWorkOrderNo();
4878fe 242                 //下发产品模组码
e0c9c6 243                 miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ModuleCode").value(productNum).build());
C 244                 miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderNumber").value(productNum).build());
4878fe 245                 //miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(1).build());
C 246
247                 //更新工单状态为执行中
248                 OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo();
249                 omProductionOrdeInfo.setId(id);
250                 omProductionOrdeInfo.setOrderStatus("3");
251                 omProductionOrdeInfoService.updateOmProductionOrdeInfo(omProductionOrdeInfo);
252
253                 //将产品SN发送到前台
254                 productNum = "productNum,"+ productNum;
255                 WebSocketUsers.sendMessageToUserByText(map.get(device), productNum);
256             }/*else{
257                 miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(2).build());//没有要生产的工单
258             }*/
259         } catch (Exception e) {
260             throw new RuntimeException(e);
261         }
262     }
263
264    /* public void receivingWorkOrders(String thoroughfare ,String device)
ef58b9 265     {
C 266         String paramProductNum = "";
267         try {
268             // 查询最新的工单信息
22c9e0 269             OmProductionOrdeInfo lastOrder = omProductionOrdeInfoService.getLastOrder();
4878fe 270             String orderJsonString = RestfulService.getProductionWorkOrderRequest(lastOrder.getProductNum(), "M1OP100");
ef58b9 271             JSONObject jsonObject = new JSONObject(orderJsonString);
C 272             // 从JSONObject中获取data对象
273             JSONObject dataObject = jsonObject.getJSONObject("data");
274             String code = jsonObject.getStr("code");
275             // 判断接单是否成功
276             if(code.equals("success")) {
277                 log.info("请求工厂MES工单:入参pack{}出参pack:{}", paramProductNum, dataObject.getStr("productNum"));
278                 OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo();
279                 omProductionOrdeInfo.setWorkOrderNo(dataObject.getStr("productionOrderNum"));
280                 omProductionOrdeInfo.setProductNum(dataObject.getStr("productNum"));
281                 omProductionOrdeInfo.setStationCode(dataObject.getStr("stationCode"));
282                 omProductionOrdeInfo.setMaterialCode(dataObject.getStr("materialCode"));
283                 omProductionOrdeInfo.setOnlineCompletionMark("0");
284                 omProductionOrdeInfo.setSfResult("0");
285                 omProductionOrdeInfo.setProductCode(dataObject.getStr("model"));
286                 omProductionOrdeInfo.setCreateTime(new Date());
287                 omProductionOrdeInfo.setCreateUser("工厂MES");
288                 omProductionOrdeInfoService.save(omProductionOrdeInfo);
289
290                 //发送给前台
291                 WebSocketUsers.sendMessageToUserByText(map.get(device), dataObject.getStr("productNum"));
292
293                 //写PLC
294                 miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MES_ModuleCode").value(dataObject.getStr("productNum")).build());
295                 miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MES_WorkOrderNumber").value(dataObject.getStr("productionOrderNum")).build());
296
297             }
298         } catch (Exception e) {
299             throw new RuntimeException(e);
300         }
4878fe 301     }*/
0ca254 302
A 303     /**
109e2f 304      * 读取电芯码
C 305      * @param thoroughfare 通道
306      * @param device 工位
307      * @return list
308      * @throws Exception e
0ca254 309      */
109e2f 310     private static List<String> readCellCodeList(String thoroughfare, String device){
C 311         List<String> cellCodeList = new ArrayList<>();
2de856 312         Map map = new HashMap();
109e2f 313         //电芯码地址
C 314         List<String> readList = new ArrayList<>();
315         readList.add(thoroughfare + "." + device +".CellCode_1");
316         readList.add(thoroughfare + "." + device +".CellCode_2");
317         readList.add(thoroughfare + "." + device +".CellCode_3");
318         readList.add(thoroughfare + "." + device +".CellCode_4");
0ca254 319         try {
109e2f 320             List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(readList);//电芯码
C 321             for (ReadWriteEntity readWriteEntity : readWriteEntityList) {
2de856 322                 if (ObjectUtil.isNotNull(readWriteEntity.getValue()) && !"".equals(readWriteEntity.getValue().toString().trim())){
C 323                     cellCodeList.add(readWriteEntity.getValue().toString());//封装电芯码
18b39c 324                 }/*else{
2de856 325                     cellCodeList.add("");//封装电芯码
18b39c 326                 }*/
0ca254 327             }
2de856 328
0ca254 329         } catch (Exception e) {
A 330             throw new RuntimeException(e);
331         }
109e2f 332         return cellCodeList;
2de856 333     }
C 334
335
336     /**
337      * 保存过站数据
338      * @param thoroughfare 通道
339      * @param device 工位
340      * @param moduleCode 模组号
341      * @return list
342      * @throws Exception e
343      */
344     private static Integer savePassingStation(String thoroughfare, String device,String moduleCode){
345         Integer result = 21;
346
347         try {
348             //读进站时间
349             Date startTime = new Date();
350             ReadWriteEntity startTimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StartTime");//进站时间
351             if (ObjectUtil.isNotNull(startTimeRead.getValue())){
352                 startTime = format.parse(TimeUtil.test(TimeUtil.stringProcessing(startTimeRead.getValue().toString())));
353             }else{
354                 result = 23;
355                 log.info("读取到工位{}的StartTime数据:{},返回RecordDataDone的值为{}",device,"IS NULL!",result);
356                 return result;
357             }
358
359             //读工站状态
360             String stationStatus = Constants.PASS;
361             ReadWriteEntity stationStatusRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus");//站状态地址
362             if (ObjectUtil.isNotNull(stationStatusRead.getValue())){
363                 String string = stationStatusRead.getValue().toString();
364                 if (Constants.TWO.equals(string)){
365                     stationStatus = Constants.UN_PASS;
366                 }
367             }else{
368                 result = 23;
369                 log.info("读取到工位{}StationStatus数据:{},返回RecordDataDone的值为{}",device,"IS NULL!",result);
370                 return result;
371             }
372
373             DaPassingStationCollection passingStationCollection = new DaPassingStationCollection();
374             passingStationCollection.setSfcCode(moduleCode);//电芯码
375             passingStationCollection.setLocationCode(device);//工位
376             passingStationCollection.setInboundTime(startTime);//进站时间
377             passingStationCollection.setOutboundTime(new Date());//出站时间
378             passingStationCollection.setOutRsSign(stationStatus);//站状态值
379             passingStationCollection.setCollectionTime(new Date());//采集时间
380             daPassingStationCollectionService.save(passingStationCollection);
381
382         } catch (Exception e) {
383             throw new RuntimeException(e);
384         }
385
386         return result;
0ca254 387     }
A 388
109e2f 389     /**
C 390      * 保存过站数据
391      * @param thoroughfare 通道
392      * @param device 工位
393      * @param cellCodeList 电芯码集合
394      * @return list
395      * @throws Exception e
396      */
397     private static Integer savePassingStation(String thoroughfare, String device,List<String> cellCodeList){
398         Integer result = 21;
399
400         try {
401             //读进站时间
402             Date startTime = new Date();
403             ReadWriteEntity startTimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StartTime");//进站时间
404             if (ObjectUtil.isNotNull(startTimeRead.getValue())){
8c5c9c 405                 startTime = format.parse(TimeUtil.test(TimeUtil.stringProcessing(startTimeRead.getValue().toString())));
109e2f 406             }else{
C 407                 result = 23;
408                 log.info("读取到工位{}的StartTime数据:{},返回RecordDataDone的值为{}",device,"IS NULL!",result);
2de856 409                 return result;
109e2f 410             }
C 411
412             //读工站状态
413             String stationStatus = Constants.PASS;
414             ReadWriteEntity stationStatusRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus");//站状态地址
415             if (ObjectUtil.isNotNull(stationStatusRead.getValue())){
416                 String string = stationStatusRead.getValue().toString();
417                 if (Constants.TWO.equals(string)){
418                     stationStatus = Constants.UN_PASS;
419                 }
420             }else{
421                 result = 23;
2de856 422                 log.info("读取到工位{}StationStatus数据:{},返回RecordDataDone的值为{}",device,"IS NULL!",result);
C 423                 return result;
109e2f 424             }
C 425
426             List<DaPassingStationCollection> passingList = new ArrayList<>();
427             for (String cellCode : cellCodeList) {
428                 DaPassingStationCollection passingStationCollection = new DaPassingStationCollection();
2de856 429                 if (ObjectUtil.isNotNull(cellCode) && !cellCode.isEmpty()){
109e2f 430                     passingStationCollection.setSfcCode(cellCode);//电芯码
C 431                     passingStationCollection.setLocationCode(device);//工位
432                     passingStationCollection.setInboundTime(startTime);//进站时间
433                     passingStationCollection.setOutboundTime(new Date());//出站时间
434                     passingStationCollection.setOutRsSign(stationStatus);//站状态值
435                     passingStationCollection.setCollectionTime(new Date());//采集时间
436                     passingList.add(passingStationCollection);
437                 }
438             }
439
440             if (CollUtil.isNotEmpty(passingList)){
441                 daPassingStationCollectionService.insertBatch(passingList);//存储过站采集数据
442             }
443
444         } catch (Exception e) {
445             throw new RuntimeException(e);
446         }
447
448         return result;
449     }
450
2de856 451
109e2f 452     /**
2de856 453      * 保存参数数据和发送工厂MES
C 454      * @param thoroughfare 通道
455      * @param device 工位
456      * @param moduleCode 模组号
457      * @return list
458      * @throws Exception e
459      */
460     private static Integer saveParamCollection(String thoroughfare, String device,String moduleCode){
461         Integer result = 21;//返回结果
5c62de 462         String sendMes = "";
2de856 463
C 464         try {
465             //查询参数配置表
466             List<DaCollectionParamConf> list = collectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>()
467                     .eq(DaCollectionParamConf::getProcessesCode, device)//工位
468                     .eq(DaCollectionParamConf::getWhetherToCollect, Constants.ONE)//是否采集
469             );
470             if (CollUtil.isNotEmpty(list)){
471
472                 List<String> collect = list.stream()
473                         .map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList());
474                 List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(collect);
475
476                 List<DaParamCollection> collectionList = new ArrayList<>();
477                 List<ChildVO> mesList = new ArrayList<>();
478                 for (int i = 0; i < readWriteEntityList.size(); i++) {
479                     DaParamCollection daParamCollection = new DaParamCollection();
480                     daParamCollection.setSfcCode(moduleCode);//模组码
481                     daParamCollection.setParamCode(list.get(i).getCollectParameterId());//参数编码
482                     daParamCollection.setParamName(list.get(i).getCollectParameterName());//参数名称
483                     String paramValue = "";
484                     if (ObjectUtil.isNotNull(readWriteEntityList.get(i).getValue())){
485                         paramValue = readWriteEntityList.get(i).getValue().toString();//参数值
e0c9c6 486                         if("DATE".equals(list.get(i).getCollectParameterType()) && !paramValue.isEmpty()){
C 487                             paramValue = format.parse(TimeUtil.test(TimeUtil.stringProcessing(paramValue))).toString();
488                         }
2de856 489                     }
C 490                     daParamCollection.setParamValue(paramValue);//参数值
491                     daParamCollection.setLocationCode(device);//工位
492                     daParamCollection.setCollectionTime(new Date());//采集时间
493                     collectionList.add(daParamCollection);//封装参数采集list
494
495                     //发送给工厂mes参数封装
496                     ChildVO childVO = new ChildVO();
497                     childVO.setItemCode(list.get(i).getCollectParameterId());//参数编码
498                     childVO.setItemType(list.get(i).getItemType());
499                     childVO.setItemValue(paramValue);//参数值
500                     childVO.setItemText(list.get(i).getCollectParameterName());
501                     childVO.setCheckResult("1");
e0c9c6 502                     childVO.setCheckTime(format.format(new Date()));
2de856 503                     mesList.add(childVO);
C 504                 }
505
506                 CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> {
507                     //插入参数采集表
508                     daParamCollectionService.insertBatch(collectionList);
509                     //上传到工厂mes
510                     ParentVO parentVO = new ParentVO();
511                     parentVO.setStationCode(device);//工位
512                     parentVO.setSiteCode("3983");
513
514                     parentVO.setRecordId(UUID.randomUUID().toString());
515                     parentVO.setTotalResult("1");
516                     parentVO.setProductNum(moduleCode);
517                     parentVO.setCheckList(mesList);
518
519                     log.info("执行工厂MES方法start,传入数据:{}",parentVO);
20635f 520                     HttpResponse execute = HttpRequest.post(Constants.FACTORY_EMS_UAT_RUL+"deviceResultFeedback").body(JSONUtil.toJsonStr(parentVO)).execute();
2de856 521                     log.info("执行工厂MES方法end,返回数据:{}",execute.body());
C 522
523                 });
524             }
525         }catch (Exception e) {
526             throw new RuntimeException(e);
527         }
528         return result;
529     }
530
531     /**
532      * 保存参数数据和发送工厂MES
109e2f 533      * @param thoroughfare 通道
C 534      * @param device 工位
535      * @param cellCodeList 电芯码集合
536      * @return list
537      * @throws Exception e
538      */
539     private static Integer saveParamCollection(String thoroughfare, String device,List<String> cellCodeList){
540         Integer result = 21;//返回结果
743e2e 541         List<ChildVO> mesChildList1 = new ArrayList<>();//封装给工厂MES发送的childlist1
C 542         List<ChildVO> mesChildList2 = new ArrayList<>();//封装给工厂MES发送的childlist2
543         List<ChildVO> mesChildList3 = new ArrayList<>();//封装给工厂MES发送的childlist3
544         List<ChildVO> mesChildList4 = new ArrayList<>();//封装给工厂MES发送的childlist4
545         List<ChildVO> mesChildList0 = new ArrayList<>();//封装给工厂MES发送的childlist4
109e2f 546         try {
C 547             //查询参数配置表
548             List<DaCollectionParamConf> list = collectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>()
549                     .eq(DaCollectionParamConf::getProcessesCode, device)//工位
8c5c9c 550                     .eq(DaCollectionParamConf::getWhetherToCollect, Constants.ONE)//是否采集
2de856 551                     );//类型
109e2f 552             if (CollUtil.isNotEmpty(list)) {
C 553                 List<DaParamCollection> saveParamList = new ArrayList<>();//封装参数采集list
554                 List<DaCollectionParamConf> confColl1 = list.stream().filter(x -> Constants.INT_ONE.equals(x.getKeyNum())).collect(Collectors.toList());
555                 List<DaCollectionParamConf> confColl2 = list.stream().filter(x -> Constants.INT_TWO.equals(x.getKeyNum())).collect(Collectors.toList());
556                 List<DaCollectionParamConf> confColl3 = list.stream().filter(x -> Constants.INT_THREE.equals(x.getKeyNum())).collect(Collectors.toList());
557                 List<DaCollectionParamConf> confColl4 = list.stream().filter(x -> Constants.INT_FOUR.equals(x.getKeyNum())).collect(Collectors.toList());
558                 List<DaCollectionParamConf> confColl0 = list.stream().filter(x -> Constants.INT_ZERO.equals(x.getKeyNum())).collect(Collectors.toList());
559
560                 List<String> collect1 = confColl1.stream()
561                         .map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList());
562                 List<ReadWriteEntity> paramCollectionList1 = miloService.readFromOpcUa(collect1);//电芯1 参数值
563
564                 List<String> collect2 = confColl2.stream()
565                         .map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList());
566                 List<ReadWriteEntity> paramCollectionList2 = miloService.readFromOpcUa(collect2);//电芯2 参数值
567
568                 List<String> collect3 = confColl3.stream()
569                         .map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList());
570                 List<ReadWriteEntity> paramCollectionList3 = miloService.readFromOpcUa(collect3);//电芯3 参数值
571
572                 List<String> collect4 = confColl4.stream()
573                         .map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList());
574                 List<ReadWriteEntity> paramCollectionList4 = miloService.readFromOpcUa(collect4);//电芯4 参数值
575
576                 List<String> collect0 = confColl0.stream()
577                         .map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList());
578                 List<ReadWriteEntity> paramCollectionList0 = miloService.readFromOpcUa(collect0);//电芯 参数值
579
580                 //第一个电芯的数据
2de856 581                 if (CollUtil.isNotEmpty(paramCollectionList1) && !cellCodeList.get(0).isEmpty()) {
109e2f 582                     for (int i = 0; i < paramCollectionList1.size(); i++) {
C 583                         DaParamCollection daParamCollection = new DaParamCollection();
584                         daParamCollection.setSfcCode(cellCodeList.get(0));//电芯码
585                         daParamCollection.setParamCode(confColl1.get(i).getCollectParameterId());//参数编码
586                         daParamCollection.setParamName(confColl1.get(i).getCollectParameterName());//参数名称
587                         String paramValue = "";
588                         if (ObjectUtil.isNotNull(paramCollectionList1.get(i).getValue())) {
589                             paramValue = paramCollectionList1.get(i).getValue().toString();//参数值
590                         }
591                         daParamCollection.setParamValue(paramValue);//参数值
592                         daParamCollection.setLocationCode(device);//工位
593                         daParamCollection.setCollectionTime(new Date());//采集时间
594                         saveParamList.add(daParamCollection);//封装参数采集list
595
596                         //发送给工厂mes参数封装
597                         ChildVO childVO = new ChildVO();
598                         childVO.setItemCode(confColl1.get(i).getCollectParameterName());//参数
599                         childVO.setItemType(confColl1.get(i).getItemType());
600                         childVO.setItemValue(paramValue);//参数值
601                         childVO.setItemText(confColl1.get(i).getParameterSetName());
602                         childVO.setCheckResult("1");
e0c9c6 603                         childVO.setCheckTime(format.format(new Date()));
109e2f 604                         mesChildList1.add(childVO);
C 605                     }
743e2e 606
109e2f 607                 }
2de856 608                 if (CollUtil.isNotEmpty(paramCollectionList2) && !cellCodeList.get(1).isEmpty()) {
109e2f 609
C 610                     for (int i = 0; i < paramCollectionList2.size(); i++) {
611                         DaParamCollection daParamCollection = new DaParamCollection();
612                         daParamCollection.setSfcCode(cellCodeList.get(1));//电芯码
613                         daParamCollection.setParamCode(confColl2.get(i).getCollectParameterId());//参数编码
614                         daParamCollection.setParamName(confColl2.get(i).getCollectParameterName());//参数名称
615                         String paramValue = "";
616                         if (ObjectUtil.isNotNull(paramCollectionList2.get(i).getValue())) {
617                             paramValue = paramCollectionList2.get(i).getValue().toString();//参数值
618                         }
619                         daParamCollection.setParamValue(paramValue);//参数值
620                         daParamCollection.setLocationCode(device);//工位
621                         daParamCollection.setCollectionTime(new Date());//采集时间
622                         saveParamList.add(daParamCollection);//封装参数采集list
623
624                         //发送给工厂mes参数封装
625                         ChildVO childVO = new ChildVO();
626                         childVO.setItemCode(confColl2.get(i).getCollectParameterName());//参数
627                         childVO.setItemType(confColl2.get(i).getItemType());
628                         childVO.setItemValue(paramValue);//参数值
629                         childVO.setItemText(confColl2.get(i).getParameterSetName());
630                         childVO.setCheckResult("1");
e0c9c6 631                         childVO.setCheckTime(format.format(new Date()));
109e2f 632                         mesChildList2.add(childVO);
C 633                     }
634                 }
2de856 635                 if (CollUtil.isNotEmpty(paramCollectionList3) && !cellCodeList.get(2).isEmpty()) {
109e2f 636                     for (int i = 0; i < paramCollectionList3.size(); i++) {
C 637                         DaParamCollection daParamCollection = new DaParamCollection();
638                         daParamCollection.setSfcCode(cellCodeList.get(2));//电芯码
639                         daParamCollection.setParamCode(confColl3.get(i).getCollectParameterId());//参数编码
640                         daParamCollection.setParamName(confColl3.get(i).getCollectParameterName());//参数名称
641                         String paramValue = "";
642                         if (ObjectUtil.isNotNull(paramCollectionList3.get(i).getValue())) {
643                             paramValue = paramCollectionList3.get(i).getValue().toString();//参数值
644                         }
645                         daParamCollection.setParamValue(paramValue);//参数值
646                         daParamCollection.setLocationCode(device);//工位
647                         daParamCollection.setCollectionTime(new Date());//采集时间
648                         saveParamList.add(daParamCollection);//封装参数采集list
649
650                         //发送给工厂mes参数封装
651                         ChildVO childVO = new ChildVO();
652                         childVO.setItemCode(confColl3.get(i).getCollectParameterName());//参数
653                         childVO.setItemType(confColl3.get(i).getItemType());
654                         childVO.setItemValue(paramValue);//参数值
655                         childVO.setItemText(confColl3.get(i).getParameterSetName());
656                         childVO.setCheckResult("1");
e0c9c6 657                         childVO.setCheckTime(format.format(new Date()));
109e2f 658                         mesChildList3.add(childVO);
C 659                     }
660                 }
2de856 661                 if (CollUtil.isNotEmpty(paramCollectionList4)&& !cellCodeList.get(3).isEmpty()) {
109e2f 662                     for (int i = 0; i < paramCollectionList4.size(); i++) {
C 663                         DaParamCollection daParamCollection = new DaParamCollection();
664                         daParamCollection.setSfcCode(cellCodeList.get(3));//电芯码
665                         daParamCollection.setParamCode(confColl4.get(i).getCollectParameterId());//参数编码
666                         daParamCollection.setParamName(confColl4.get(i).getCollectParameterName());//参数名称
667                         String paramValue = "";
668                         if (ObjectUtil.isNotNull(paramCollectionList4.get(i).getValue())) {
669                             paramValue = paramCollectionList4.get(i).getValue().toString();//参数值
670                         }
671                         daParamCollection.setParamValue(paramValue);//参数值
672                         daParamCollection.setLocationCode(device);//工位
673                         daParamCollection.setCollectionTime(new Date());//采集时间
674                         saveParamList.add(daParamCollection);//封装参数采集list
675
676                         //发送给工厂mes参数封装
677                         ChildVO childVO = new ChildVO();
678                         childVO.setItemCode(confColl4.get(i).getCollectParameterName());//参数
679                         childVO.setItemType(confColl4.get(i).getItemType());
680                         childVO.setItemValue(paramValue);//参数值
681                         childVO.setItemText(confColl4.get(i).getParameterSetName());
682                         childVO.setCheckResult("1");
e0c9c6 683                         childVO.setCheckTime(format.format(new Date()));
109e2f 684                         mesChildList4.add(childVO);
C 685                     }
686                 }
687
688                 //公共参数
689                 if (CollUtil.isNotEmpty(paramCollectionList0)) {
690                     for (int i = 0; i < cellCodeList.size(); i++) {//循环4个电芯
2de856 691                         if(!cellCodeList.get(i).isEmpty()){
C 692                             for (int j = 0; j < paramCollectionList0.size(); j++) {
693                                 DaParamCollection daParamCollection = new DaParamCollection();
694                                 daParamCollection.setSfcCode(cellCodeList.get(i));//电芯码
695                                 daParamCollection.setParamCode(confColl0.get(j).getCollectParameterId());//参数编码
696                                 daParamCollection.setParamName(confColl0.get(j).getCollectParameterName());//参数名称
697                                 String paramValue = "";
698                                 if (ObjectUtil.isNotNull(paramCollectionList0.get(j).getValue())) {
699                                     paramValue = paramCollectionList0.get(j).getValue().toString();//参数值
e0c9c6 700                                     if("DATE".equals(confColl0.get(j).getCollectParameterType()) && !paramValue.isEmpty()){
C 701                                         paramValue = TimeUtil.test(TimeUtil.stringProcessing(paramValue));
702                                     }
2de856 703                                 }
C 704                                 daParamCollection.setParamValue(paramValue);//参数值
705                                 daParamCollection.setLocationCode(device);//工位
706                                 daParamCollection.setCollectionTime(new Date());//采集时间
707                                 saveParamList.add(daParamCollection);
109e2f 708
2de856 709                                 //发送给工厂mes参数封装
C 710                                 ChildVO childVO = new ChildVO();
711                                 childVO.setItemCode(confColl0.get(j).getCollectParameterName());//参数
712                                 childVO.setItemType(confColl0.get(j).getItemType());
713                                 childVO.setItemValue(paramValue);//参数值
714                                 childVO.setItemText(confColl0.get(j).getParameterSetName());
715                                 childVO.setCheckResult("1");
e0c9c6 716                                 childVO.setCheckTime(format.format(new Date()));
2de856 717                                 mesChildList0.add(childVO);
C 718                             }
109e2f 719                         }
2de856 720
C 721                         //mesList.get(i).addAll(mesChildList0);
722
109e2f 723                     }
C 724
725                 }
726
727                 CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> {
728                     //插入参数采集表
729                     daParamCollectionService.insertBatch(saveParamList);
730                     //上传到工厂mes
731                     ParentVO parentVO = new ParentVO();
732                     parentVO.setStationCode(device);//工位
733                     parentVO.setSiteCode("3983");
734
735                     parentVO.setRecordId(UUID.randomUUID().toString());
736                     parentVO.setTotalResult("1");
737                     for (int i = 0; i < cellCodeList.size(); i++) {//循环4个电芯
2de856 738                         if(!cellCodeList.get(i).isEmpty()){
C 739                             parentVO.setProductNum(cellCodeList.get(i));//电芯码
743e2e 740                             //封装给工厂MES发送的childlist4
C 741                             List<ChildVO> mesChildList = new ArrayList<>(mesChildList0);
742                             switch (i) {
743                                 case 0 :
744                                     mesChildList.addAll(mesChildList1);
745                                     break;
746                                 case 1 :
747                                     mesChildList.addAll(mesChildList2);
748                                     break;
749                                 case 2 :
750                                     mesChildList.addAll(mesChildList3);
751                                     break;
752                                 case 3 :
753                                     mesChildList.addAll(mesChildList4);
754                                     break;
755
756                             }
757                             parentVO.setCheckList(mesChildList);//参数
2de856 758                             //CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> {
C 759                             log.info("执行工厂MES方法start,传入数据:{}",parentVO);
20635f 760                             HttpResponse execute = HttpRequest.post(Constants.FACTORY_EMS_UAT_RUL+"deviceResultFeedback").body(JSONUtil.toJsonStr(parentVO)).execute();
2de856 761                             log.info("执行工厂MES方法end,返回数据:{}",execute.body());
C 762                         }
109e2f 763                     }
C 764                 });
765             }
766         }catch (Exception e) {
743e2e 767             log.error(e.getMessage());
109e2f 768             throw new RuntimeException(e);
C 769         }
770         return result;
771     }
772
773     /**
2de856 774      * 030工位返回ocv测试结果
C 775      * @param thoroughfare
776      * @param device
ec7e2a 777      * @param cellCode
C 778      * @throws Exception
779      */
780     private boolean OCVResultFeedBack(String thoroughfare, String device,String cellCode) throws Exception {
781         boolean flag = true;
782
783         List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>()
784                 .eq(DaTestDeviceInterfaceTemp::getStationCode, device)
785                 .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode));
786         if (CollUtil.isNotEmpty(list)){
d8e6a5 787             DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1);
ec7e2a 788             if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){
C 789                 miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(1).build());
790             }else {
791                 flag = false;
792                 miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(2).build());
793             }
d8e6a5 794             daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode);
f18ebf 795         }else {
C 796             flag = false;
797             miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(2).build());
798             log.info("读取到工位{},测试设备返回的数据查询不到,电芯码为:{}",device,cellCode);
ec7e2a 799         }
C 800         return flag;
801     }
802     /**
803      * 030工位返回ocv测试结果
804      * @param thoroughfare
805      * @param device
109e2f 806      * @throws Exception
C 807      */
2de856 808     private boolean OCVResultFeedBack(String thoroughfare, String device) throws Exception {
C 809         boolean flag = true;
810         Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_1").getValue();
5b755f 811         if (ObjectUtil.isNotNull(value1)){
C 812             String cellCode = value1.toString();
813             List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>()
814                     .eq(DaTestDeviceInterfaceTemp::getStationCode, device)
815                     .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode));
2de856 816             if (CollUtil.isNotEmpty(list)){
18b39c 817                 DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1);
5b755f 818                 if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){
2de856 819                     miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(1).build());
C 820                 }else {
821                     flag = false;
822                     miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(2).build());
823                 }
18b39c 824                 daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode);
2de856 825             }
f18ebf 826         }else {
C 827             flag = false;
828             miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(2).build());
829             log.info("读取到工位{},PLC没有给电芯码",device);
5b755f 830         }
2de856 831         Object value2 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_2").getValue();
5b755f 832         if (ObjectUtil.isNotNull(value2)){
C 833             String cellCode = value2.toString();
834             List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>()
835                     .eq(DaTestDeviceInterfaceTemp::getStationCode, device)
836                     .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode));
2de856 837             if (CollUtil.isNotEmpty(list)){
18b39c 838                 DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1);
5b755f 839                 if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){
2de856 840                     miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(1).build());
C 841                 }else {
842                     flag = false;
843                     miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(2).build());
844                 }
18b39c 845                 daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode);
2de856 846             }
f18ebf 847         }else {
C 848             flag = false;
849             miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(2).build());
850             log.info("读取到工位{},PLC没有给电芯码",device);
5b755f 851         }
C 852
2de856 853         Object value3 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_3").getValue();
5b755f 854         if (ObjectUtil.isNotNull(value3)){
C 855             String cellCode = value3.toString();
856             List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>()
857                     .eq(DaTestDeviceInterfaceTemp::getStationCode, device)
858                     .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode));
2de856 859             if (CollUtil.isNotEmpty(list)){
18b39c 860                 DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1);
5b755f 861                 if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){
2de856 862                     miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(1).build());
C 863                 }else {
864                     flag = false;
865                     miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(2).build());
866                 }
18b39c 867                 daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode);
2de856 868             }
f18ebf 869         }else {
C 870             flag = false;
871             miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(2).build());
872             log.info("读取到工位{},PLC没有给电芯码",device);
5b755f 873         }
C 874
2de856 875         Object value4 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_4").getValue();
5b755f 876         if (ObjectUtil.isNotNull(value4)){
C 877             String cellCode = value4.toString();
878             List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>()
879                     .eq(DaTestDeviceInterfaceTemp::getStationCode, device)
880                     .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode));
2de856 881             if (CollUtil.isNotEmpty(list)){
18b39c 882                 DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1);
5b755f 883                 if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){
2de856 884                     miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(1).build());
C 885                 }else {
886                     flag = false;
887                     miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(2).build());
888                 }
18b39c 889                 daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode);
2de856 890             }
f18ebf 891         }else {
C 892             flag = false;
893             miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(2).build());
894             log.info("读取到工位{},PLC没有给电芯码",device);
5b755f 895         }
C 896
2de856 897         return flag;
109e2f 898     }
C 899
900
0ca254 901 }