From ddf2c28b00b38469c9119dcad42d986f849bc62d Mon Sep 17 00:00:00 2001
From: cl <418351270@qq.com>
Date: 星期日, 21 七月 2024 09:53:51 +0800
Subject: [PATCH] 添加电芯挡位校验

---
 jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java |   94 ++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 85 insertions(+), 9 deletions(-)

diff --git a/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java b/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java
index 998102a..d5288ca 100644
--- a/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java
+++ b/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java
@@ -12,6 +12,8 @@
 import com.jcdm.common.core.domain.AjaxResult;
 import com.jcdm.framework.websocket.WebSocketUsers;
 import com.jcdm.main.constant.Constants;
+import com.jcdm.main.da.cellData.domain.DaCellData;
+import com.jcdm.main.da.cellData.service.IDaCellDataService;
 import com.jcdm.main.da.collectionParamConf.domain.DaCollectionParamConf;
 import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService;
 import com.jcdm.main.da.paramCollection.domain.DaParamCollection;
@@ -62,6 +64,8 @@
 
     public static IDaTestDeviceInterfaceTempService daTestDeviceInterfaceTempService;
 
+    public static IDaCellDataService daCellDataService;
+
 /*    @Value("${orderLineUrl}")
     private static String orderLineUrl;*/
 
@@ -70,13 +74,15 @@
                              IDaCollectionParamConfService collectionParamConfService,
                              IDaParamCollectionService daParamCollectionService,
                              IOmProductionOrdeInfoService omProductionOrdeInfoService,
-                             IDaTestDeviceInterfaceTempService daTestDeviceInterfaceTempService) {
+                             IDaTestDeviceInterfaceTempService daTestDeviceInterfaceTempService,
+                             IDaCellDataService daCellDataService) {
         OPCUaSubscription.miloService = miloService;
         OPCUaSubscription.daPassingStationCollectionService = daPassingStationCollectionService;
         OPCUaSubscription.collectionParamConfService = collectionParamConfService;
         OPCUaSubscription.daParamCollectionService = daParamCollectionService;
         OPCUaSubscription.omProductionOrdeInfoService = omProductionOrdeInfoService;
         OPCUaSubscription.daTestDeviceInterfaceTempService = daTestDeviceInterfaceTempService;
+        OPCUaSubscription.daCellDataService = daCellDataService;
     }
 
 
@@ -143,9 +149,22 @@
                     miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(1).build());//娌℃湁瑕佺敓浜х殑宸ュ崟
                 }
             }else if (Constants.RECORD_DATA.equals(tab)){//鍑哄叆绔�
-                if (Constants.ONE.equals(valueString)){//鍏ョ珯
-                    //1:鍛婄煡MES鎵樼洏宸插埌绔欙紝璇锋眰涓嬪彂杩涚珯鐘舵��
-                    if (Constants.OP030.equals(device)){
+                if (Constants.ONE.equals(valueString)){//鍏ョ珯 //1:鍛婄煡MES鎵樼洏宸插埌绔欙紝璇锋眰涓嬪彂杩涚珯鐘舵��
+
+                    //OP020 鐢佃姱鎸′綅鏍¢獙
+                    if (Constants.OP020.equals(device)){
+                        Integer result = 11;
+                        Object cellGearObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellGear").getValue();
+                        if (ObjectUtil.isNull(cellGearObjcet)){
+                            result = 16;//鐢佃姱鎸′綅涓虹┖
+                        }else{
+                            String cellGear = cellGearObjcet.toString();
+                            List<String> cellCodeList = readCellCodeList(thoroughfare, device);
+                            result = checkCellGear(thoroughfare, device,cellCodeList,cellGear);//鏍¢獙鐢佃姱鎸′綅鍜岀粍鍒�
+                        }
+                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(result).build());
+
+                    }else if (Constants.OP030.equals(device)){
                         //鍙嶉鐢佃姱ocv妫�娴嬬粨鏋�
                         boolean b = OCVResultFeedBack(thoroughfare, device);//杩涚珯瀵�4涓數鑺牎楠�
                         //鍥涗釜鐢佃姱鐨勭姸鎬�
@@ -221,11 +240,32 @@
 
                             result = savePassingStation(thoroughfare, device,cellCodeList);//淇濆瓨杩囩珯
                             if(result == 21) {
-                                if(Constants.OP030.contains(device)){
-                                    daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode1);
-                                    daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode2);
-                                    daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode3);
-                                    daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode4);
+                                if(Constants.OP020.contains(device)){
+                                    if(!cellCode1.isEmpty()){
+                                        daCellDataService.deleteDaCellDataByGbCellCode(cellCode1);
+                                    }
+                                    if(!cellCode2.isEmpty()){
+                                        daCellDataService.deleteDaCellDataByGbCellCode(cellCode2);
+                                    }
+                                    if(!cellCode3.isEmpty()){
+                                        daCellDataService.deleteDaCellDataByGbCellCode(cellCode3);
+                                    }
+                                    if(!cellCode4.isEmpty()){
+                                        daCellDataService.deleteDaCellDataByGbCellCode(cellCode4);
+                                    }
+                                }else if(Constants.OP030.contains(device)){
+                                    if(!cellCode1.isEmpty()){
+                                        daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode1);
+                                    }
+                                    if(!cellCode2.isEmpty()){
+                                        daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode2);
+                                    }
+                                    if(!cellCode3.isEmpty()){
+                                        daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode3);
+                                    }
+                                    if(!cellCode4.isEmpty()) {
+                                        daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode4);
+                                    }
                                 }
                                 result = saveParamCollection(device,cellCodeList);//淇濆瓨鍙傛暟锛屽彂閫佸伐鍘侻ES
                             }
@@ -818,6 +858,42 @@
         }
         return flag;
     }
+
+    /**
+     * OP020鏍¢獙鐢佃姱鎸′綅
+     * @param thoroughfare
+     * @param device
+     * @throws Exception
+     */
+    private Integer checkCellGear(String thoroughfare, String device,List<String> cellCodeList,String cellGear) throws Exception {
+        Integer result = 11;
+
+        for(int i = 0; i < cellCodeList.size(); i ++){
+            Integer cellStatus = 1;
+            String cellCode = cellCodeList.get(i);
+            if(!cellCode.isEmpty()){
+                List<DaCellData> list = daCellDataService.list(new LambdaQueryWrapper<DaCellData>()
+                        .eq(DaCellData::getGbCellCode,cellCode));
+                if(CollUtil.isNotEmpty(list)){
+                    DaCellData daCellData = list.get(0);
+                    String cellValue = daCellData.getCellValue();//鏁版嵁搴撲腑鐢佃姱鎸′綅
+                    String cellSerial = daCellData.getCellSerial();//鏁版嵁搴撲腑鐢佃姱缁勫埆
+                    if(!cellValue.isEmpty() && cellValue.equals(cellGear)){
+                        cellStatus = 1;
+                    }else {
+                        cellStatus = 2;
+                        result = 17;//鎸′綅鏍¢獙涓嶅悎鏍�
+                    }
+                }else {
+                    cellStatus = 2;
+                    result = 17;//鏌ヤ笉鍒拌鏍¢獙鐨勬尅浣�
+                }
+                miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_"+(i+1)).value(cellStatus).build());
+            }
+        }
+        return result;
+    }
+
     /**
      * 030宸ヤ綅杩斿洖ocv娴嬭瘯缁撴灉
      * @param thoroughfare

--
Gitblit v1.9.3