From ff13e6159eab48d53bb528a10d0ab8850fdf7ad5 Mon Sep 17 00:00:00 2001
From: cl <418351270@qq.com>
Date: 星期二, 23 一月 2024 13:28:22 +0800
Subject: [PATCH] 修改数据采集

---
 guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/OP050Callback.java |   45 +++++++++++++---------
 guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/OP090Callback.java |   37 +++++++++++-------
 guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/InitCallback.java  |    8 ++-
 3 files changed, 54 insertions(+), 36 deletions(-)

diff --git a/guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/InitCallback.java b/guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/InitCallback.java
index a21f8d7..70a62e2 100644
--- a/guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/InitCallback.java
+++ b/guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/InitCallback.java
@@ -482,9 +482,10 @@
                 }
                 //PLC鍑虹珯
                 else if (identifier.equals(OPCElement.OP050_J_PLC_FINISH) && null != value && "true".equals(value.toString())) {
-                    OP050Callback.handleMaterial();
-                    OP050Callback.handleInfo();
                     OP050Callback.handleFinsh();
+                    OP050Callback.handleInfo();
+
+                    OP050Callback.handleMaterial();
                 }
 
                 //OP070
@@ -539,9 +540,10 @@
                 }
                 //PLC鍑虹珯
                 else if (identifier.equals(OPCElement.OP090_J_PLC_FINISH) && null != value && "true".equals(value.toString())) {
+                    OP090Callback.handleFinsh();
                     OP090Callback.handleMaterial();
                     OP090Callback.handleInfo();
-                    OP090Callback.handleFinsh();
+
                 }
 
                 //OP100
diff --git a/guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/OP050Callback.java b/guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/OP050Callback.java
index f39dd75..aa181db 100644
--- a/guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/OP050Callback.java
+++ b/guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/OP050Callback.java
@@ -194,10 +194,18 @@
     }
 
     public void handleFinsh() throws Exception{
+
+
+
         logger.info("handleFinsh PC澶勭悊寮�濮嬶紒");
-        String S_PRODUCT_STATE_CODE = miloService.
+
+        Object object = miloService.
                 readFromOpcUa(OPCElement.OP050_S_PRODUCT_STATE_CODE)
-                .getValue().toString();
+                .getValue();
+        String S_PRODUCT_STATE_CODE = "";
+        if(null != object){
+            S_PRODUCT_STATE_CODE = object.toString();
+        }
 
         PassingStationCollectionParam param = new PassingStationCollectionParam();
         param.setWorkOrderNo(S_ORDER_CODE);
@@ -211,26 +219,27 @@
         passingStationCollectionService.add(param);
 
 
-        String copSfcCode = miloService.
+        Object copSfcCode = miloService.
                 readFromOpcUa(OPCElement.OP050_S_SFC_CODE_COP)
-                .getValue().toString();
-        String bopSfcCode = miloService.
+                .getValue();
+        Object bopSfcCode = miloService.
                 readFromOpcUa(OPCElement.OP050_S_SFC_CODE_BOP)
-                .getValue().toString();
+                .getValue();
 
+        if(null != copSfcCode && null != bopSfcCode){
         //鏍规嵁鍒嗘�绘垚缂栫爜锛屽皢EOP鐗╂枡鏁版嵁缁戝畾鍏崇郴淇敼涓烘�绘垚缂栫爜
-        materialTraceabilityService.updateSFC(S_SFC_CODE,copSfcCode);
-        materialTraceabilityService.updateSFC(S_SFC_CODE,bopSfcCode);
+            materialTraceabilityService.updateSFC(S_SFC_CODE,copSfcCode.toString());
+            materialTraceabilityService.updateSFC(S_SFC_CODE,bopSfcCode.toString());
 
-        //鏍规嵁鍒嗘�绘垚缂栫爜锛屽皢EOP杩囩珯鏁版嵁缁戝畾鍏崇郴淇敼涓烘�绘垚缂栫爜
-        passingStationCollectionService.updateSFC(S_SFC_CODE,copSfcCode);
-        passingStationCollectionService.updateSFC(S_SFC_CODE,bopSfcCode);
+            //鏍规嵁鍒嗘�绘垚缂栫爜锛屽皢EOP杩囩珯鏁版嵁缁戝畾鍏崇郴淇敼涓烘�绘垚缂栫爜
+            passingStationCollectionService.updateSFC(S_SFC_CODE,copSfcCode.toString());
+            passingStationCollectionService.updateSFC(S_SFC_CODE,bopSfcCode.toString());
 
 
-        //鏍规嵁鍒嗘�绘垚缂栫爜锛屽皢EOP閲囬泦鏁版嵁缁戝畾鍏崇郴淇敼涓烘�绘垚缂栫爜
-        paramCollectionService.updateSFC(S_SFC_CODE,copSfcCode);
-        paramCollectionService.updateSFC(S_SFC_CODE,bopSfcCode);
-
+            //鏍规嵁鍒嗘�绘垚缂栫爜锛屽皢EOP閲囬泦鏁版嵁缁戝畾鍏崇郴淇敼涓烘�绘垚缂栫爜
+            paramCollectionService.updateSFC(S_SFC_CODE,copSfcCode.toString());
+            paramCollectionService.updateSFC(S_SFC_CODE,bopSfcCode.toString());
+        }
         logger.info("S_SFC_CODE:"+S_SFC_CODE);
         logger.info("copSfcCode:"+copSfcCode);
         logger.info("bopSfcCode:"+bopSfcCode);
@@ -244,13 +253,13 @@
         String isProductState = "true";
         for(int i=0;i<passingStationCollectionResultList.size();i++){
             PassingStationCollectionResult passingStationCollectionResult = passingStationCollectionResultList.get(i);
-            if("false".equals(passingStationCollectionResult.getOutRsSign())){
+            if("2".equals(passingStationCollectionResult.getOutRsSign())){
                 isProductState = "false";
                 break;
             }
         }
         //淇敼鎶ュ伐璁板綍
-        if("false".equals(S_PRODUCT_STATE_CODE) || "false".equals(isProductState)){
+        if("2".equals(S_PRODUCT_STATE_CODE) || "false".equals(isProductState)){
             ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam();
             productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE);
             productionOrderRecordsParam.setProductNo(S_SFC_CODE);
@@ -258,7 +267,7 @@
             if(list.size()>0){
                 ProductionOrderRecordsResult productionOrderRecordsResult = list.get(0);
                 productionOrderRecordsParam.setId(productionOrderRecordsResult.getId());
-                productionOrderRecordsParam.setWhetherPass("false");
+                productionOrderRecordsParam.setWhetherPass("2");
                 productionOrderRecordsService.update(productionOrderRecordsParam);
             }
         }
diff --git a/guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/OP090Callback.java b/guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/OP090Callback.java
index e3a92a7..0341084 100644
--- a/guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/OP090Callback.java
+++ b/guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/OP090Callback.java
@@ -198,9 +198,15 @@
     public void handleFinsh() throws Exception {
         logger.info("handleFinsh PC澶勭悊寮�濮嬶紒");
         //澶勭悊杩囩珯淇℃伅
-        String S_PRODUCT_STATE_CODE = miloService.
+        Object object = miloService.
                 readFromOpcUa(OPCElement.OP090_S_PRODUCT_STATE_CODE)
-                .getValue().toString();
+                .getValue();
+
+        String S_PRODUCT_STATE_CODE = "";
+        if(null != object){
+            S_PRODUCT_STATE_CODE = object.toString();
+        }
+
         PassingStationCollectionParam param = new PassingStationCollectionParam();
         param.setWorkOrderNo(S_ORDER_CODE);
         param.setProductCode(S_PRODUCT_CODE);
@@ -212,22 +218,23 @@
         param.setOutRsSign(S_PRODUCT_STATE_CODE);//鍑虹珯鏄惁鍚堟牸
         passingStationCollectionService.add(param);
 
-        String eopSfcCode = miloService.
+        Object eopSfcCode = miloService.
                 readFromOpcUa(OPCElement.OP090_S_SFC_CODE_EOP)
-                .getValue().toString();
+                .getValue();
 
-        //鏍规嵁鍒嗘�绘垚缂栫爜锛屽皢EOP鐗╂枡鏁版嵁缁戝畾鍏崇郴淇敼涓烘�绘垚缂栫爜
-        materialTraceabilityService.updateSFC(S_SFC_CODE,eopSfcCode);
+        if(null != eopSfcCode) {
+            //鏍规嵁鍒嗘�绘垚缂栫爜锛屽皢EOP鐗╂枡鏁版嵁缁戝畾鍏崇郴淇敼涓烘�绘垚缂栫爜
+            materialTraceabilityService.updateSFC(S_SFC_CODE, eopSfcCode.toString());
 
-        //鏍规嵁鍒嗘�绘垚缂栫爜锛屽皢EOP杩囩珯鏁版嵁缁戝畾鍏崇郴淇敼涓烘�绘垚缂栫爜
-        passingStationCollectionService.updateSFC(S_SFC_CODE,eopSfcCode);
+            //鏍规嵁鍒嗘�绘垚缂栫爜锛屽皢EOP杩囩珯鏁版嵁缁戝畾鍏崇郴淇敼涓烘�绘垚缂栫爜
+            passingStationCollectionService.updateSFC(S_SFC_CODE, eopSfcCode.toString());
 
-        //鏍规嵁鍒嗘�绘垚缂栫爜锛屽皢EOP閲囬泦鏁版嵁缁戝畾鍏崇郴淇敼涓烘�绘垚缂栫爜
-        paramCollectionService.updateSFC(S_SFC_CODE,eopSfcCode);
+            //鏍规嵁鍒嗘�绘垚缂栫爜锛屽皢EOP閲囬泦鏁版嵁缁戝畾鍏崇郴淇敼涓烘�绘垚缂栫爜
+            paramCollectionService.updateSFC(S_SFC_CODE, eopSfcCode.toString());
 
-        logger.info("S_SFC_CODE:"+S_SFC_CODE);
-        logger.info("eopSfcCode:"+eopSfcCode);
-
+            logger.info("S_SFC_CODE:" + S_SFC_CODE);
+            logger.info("eopSfcCode:" + eopSfcCode);
+        }
         //鏌ヨCOP鍜孊OP鏄惁鍚堟牸
         PassingStationCollectionParam passingStationCollectionParam = new PassingStationCollectionParam();
         passingStationCollectionParam.setSfcCode(S_SFC_CODE);
@@ -243,7 +250,7 @@
             }
         }
         //淇敼鎶ュ伐璁板綍
-        if("false".equals(S_PRODUCT_STATE_CODE) || "false".equals(isProductState)){
+        if("2".equals(S_PRODUCT_STATE_CODE) || "false".equals(isProductState)){
             ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam();
             productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE);
             productionOrderRecordsParam.setProductNo(S_SFC_CODE);
@@ -252,7 +259,7 @@
             if(list.size()>0){
                 ProductionOrderRecordsResult productionOrderRecordsResult = list.get(0);
                 productionOrderRecordsParam.setId(productionOrderRecordsResult.getId());
-                productionOrderRecordsParam.setWhetherPass("false");
+                productionOrderRecordsParam.setWhetherPass("2");
                 productionOrderRecordsService.update(productionOrderRecordsParam);
             }
         }

--
Gitblit v1.9.3