From e0391b17f64e4c79f7b1d4ffa2963772c2ebed52 Mon Sep 17 00:00:00 2001
From: cl <418351270@qq.com>
Date: 星期五, 06 九月 2024 09:40:45 +0800
Subject: [PATCH] 添加报工失败二次报工

---
 jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java |   37 ++++++++++++++++++++++++++++---------
 1 files changed, 28 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 74b9e45..d001b3d 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
@@ -164,8 +164,9 @@
                             result = 16;//鐢佃姱鎸′綅涓虹┖
                         }else{
                             String cellGear = cellGearObjcet.toString();
-                           /* List<String> cellCodeList = readCellCodeList(thoroughfare, device);
-                            result = checkCellGear(thoroughfare, device,cellCodeList,cellGear);//鏍¢獙鐢佃姱鎸′綅鍜岀粍鍒�*/
+                            List<String> cellCodeList = readCellCodeList(thoroughfare, device);
+                            result = checkCellGear(thoroughfare, device,cellCodeList,cellGear);//鏍¢獙鐢佃姱鎸′綅鍜岀粍鍒�
+                            Constants.OLD_CELL_GEAR = cellGear;//鎸′綅璧嬪��
                         }
                         miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(result).build());
 
@@ -861,7 +862,7 @@
      */
     private Integer checkCellGear(String thoroughfare, String device,List<String> cellCodeList,String cellGear) throws Exception {
         Integer result = 11;
-
+        String cellSerial = "";
         for(int i = 0; i < cellCodeList.size(); i ++){
             Integer cellStatus = 1;
             String cellCode = cellCodeList.get(i);
@@ -871,20 +872,31 @@
                 if(CollUtil.isNotEmpty(list)){
                     DaCellData daCellData = list.get(0);
                     String cellValue = daCellData.getCellValue();//鏁版嵁搴撲腑鐢佃姱鎸′綅
-                    String cellSerial = daCellData.getCellSerial();//鏁版嵁搴撲腑鐢佃姱缁勫埆
+                    cellSerial = daCellData.getCellSerial();//鏁版嵁搴撲腑鐢佃姱缁勫埆
                     if(!cellValue.isEmpty() && cellValue.equals(cellGear)){
                         cellStatus = 1;
                     }else {
                         cellStatus = 2;
                         result = 16;//鎸′綅鏍¢獙涓嶅悎鏍�
+                        log.info("鐢佃姱鎸′綅鏍¢獙涓嶅悎鏍硷細鐢佃姱鐮佷负{}锛孭LC璁剧疆鎸′綅涓簕}锛屽伐鍘侻ES涓嬪彂鎸′綅涓猴細{}",cellCode,cellGear,cellValue);
                     }
-                }/*else {
+                }else {
                     cellStatus = 2;
-                    result = 17;//鏌ヤ笉鍒拌鏍¢獙鐨勬尅浣�
-                }*/
-                miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_"+(i+1)).value(cellStatus).build());
+                    result = 16;//鏌ヤ笉鍒拌鏍¢獙鐨勬尅浣�
+                    log.info("鐢佃姱鎸′綅鏍¢獙涓嶅悎鏍硷細鐢佃姱鐮佷负{}锛孭LC璁剧疆鎸′綅涓簕}锛屽伐鍘侻ES涓嬪彂鎸′綅涓虹┖锛屾煡璇笉鍒拌鏁版嵁",cellCode,cellGear);
+                }
+                miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".Cell_Status_"+(i+1)).value(cellStatus).build());
             }
         }
+
+        //褰撶數鑺尅浣嶅彂鐢熷彉鍖栨椂锛屽苟涓旇�佺殑鎸′綅涓嶄负绌猴紝鍒犻櫎褰撳墠鐢佃姱鎵规
+        if(!Constants.OLD_CELL_GEAR.isEmpty() && !cellGear.equals(Constants.OLD_CELL_GEAR)){
+            if(!cellSerial.isEmpty()){
+                daCellDataService.deleteDaCellDataByCellSerial(cellSerial);
+            }
+            log.info("鐢佃姱鎸′綅鍙戠敓鏀瑰彉锛岃�佺殑鎸′綅涓猴細{}锛屾柊鐨勬尅浣嶄负锛歿}锛屾壒娆″彿涓簕}",Constants.OLD_CELL_GEAR,cellGear,cellSerial);
+        }
+
         return result;
     }
 
@@ -1044,14 +1056,21 @@
     public static String getWorkReportResultFeedback(String productNum,String stationCode,String confirmTime)
     {
         String result = "";
+        String url = Constants.FACTORY_EMS_UAT_GET_RUL + "workReportResultFeedback?siteCode="+Constants.FACTORY_EMS_SITE_CODE+"&stationCode="+stationCode+"&productNum="+productNum+"&confirmTime="+confirmTime;
         try {
-            String url = Constants.FACTORY_EMS_UAT_GET_RUL + "workReportResultFeedback?siteCode="+Constants.FACTORY_EMS_SITE_CODE+"&stationCode="+stationCode+"&productNum="+productNum+"&confirmTime="+confirmTime;
+            log.info("鎵ц宸ュ巶MES鎶ュ伐鏂规硶start锛屽簭鍒楀彿{}宸ヤ綅鍙穥}url{}",productNum,stationCode ,url);
             HttpResponse response = HttpRequest.get(url).execute();
             //HttpRequest httpRequest = HttpRequest.get(url);
             result =  response.body();
+            log.info("鎵ц宸ュ巶MES鎶ュ伐鏂规硶绗竴娆nd锛屽簭鍒楀彿{}宸ヤ綅鍙穥}杩斿洖鏁版嵁{}",productNum,stationCode ,result);
         }catch (Exception e){
             throw new RuntimeException(e);
         }finally {
+            if(result.isEmpty()){
+                HttpResponse response = HttpRequest.get(url).execute();
+                result =  response.body();
+                log.info("鎵ц宸ュ巶MES鎶ュ伐鏂规硶绗簩娆nd锛屽簭鍒楀彿{}宸ヤ綅鍙穥}杩斿洖鏁版嵁{}",productNum,stationCode ,result);
+            }
             return result;
         }
     }

--
Gitblit v1.9.3