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