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