From 0994009a6d6184839359505d99fdf7be68ee1b19 Mon Sep 17 00:00:00 2001
From: hdy <1105738590@qq.com>
Date: 星期五, 14 三月 2025 12:51:12 +0800
Subject: [PATCH] 工单界面新增按钮

---
 billion-main/src/main/java/com/billion/main/plcServer/sub/OPCUaSubscription.java |   56 ++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 34 insertions(+), 22 deletions(-)

diff --git a/billion-main/src/main/java/com/billion/main/plcServer/sub/OPCUaSubscription.java b/billion-main/src/main/java/com/billion/main/plcServer/sub/OPCUaSubscription.java
index da49e78..15e7766 100644
--- a/billion-main/src/main/java/com/billion/main/plcServer/sub/OPCUaSubscription.java
+++ b/billion-main/src/main/java/com/billion/main/plcServer/sub/OPCUaSubscription.java
@@ -134,6 +134,7 @@
                     OmOrderScheduling omOrderScheduling = new OmOrderScheduling();
                     Object SFCCode = miloService.readFromOpcUa(thoroughfare + "." + device + ".SFCCode").getValue();
                     //涓婄嚎宸ヤ綅
+//                    if(Constants.ONLINE.contains(device) || Constants.TEST.equals(device) ){
                     if(Constants.ONLINE.contains(device)){
                         Object workOrderNumber = miloService.readFromOpcUa(thoroughfare + "." + device + ".WorkOrderNumber").getValue();
                         Object nowQty = miloService.readFromOpcUa(thoroughfare + "." + device + ".PalletID").getValue();
@@ -158,7 +159,6 @@
                         ReadWriteEntity TimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StopTime");
                         Time = format.parse(TimeUtil.test(TimeUtil.stringProcessing(TimeRead.getValue().toString())));
                         omOrderScheduling.setOfflineTime(Time);
-                        omOrderScheduling.setStatus("2");
                         if(Constants.C060.equals(device)){
                             omOrderScheduling.setRemarks("Head");
                             omOrderScheduling.setSfcCode(SFCCode.toString());
@@ -171,7 +171,7 @@
                             if (nowQty == headQty){
                                 UpdateWrapper<OmProductionOrderInfo> updateWrapper = new UpdateWrapper<>();
                                 updateWrapper.eq("work_order_no", omProductionOrderInfoList.get(0).getWorkOrderNo());
-                                updateWrapper.set("head_status", "3");
+                                updateWrapper.set("head_status", "2");
                                 omProductionOrderInfoService.update(new OmProductionOrderInfo(),updateWrapper);
                             }
                         } else if (Constants.OP310.equals(device)) {
@@ -186,7 +186,7 @@
                             if (nowQty == bodyQty){
                                 UpdateWrapper<OmProductionOrderInfo> updateWrapper = new UpdateWrapper<>();
                                 updateWrapper.eq("work_order_no", omProductionOrderInfoList.get(0).getWorkOrderNo());
-                                updateWrapper.set("body_status", "3");
+                                updateWrapper.set("body_status", "2");
                                 omProductionOrderInfoService.update(new OmProductionOrderInfo(),updateWrapper);
                             }
                         }
@@ -206,7 +206,7 @@
                         if (nowQty == preQty){
                             UpdateWrapper<OmProductionOrderInfo> updateWrapper = new UpdateWrapper<>();
                             updateWrapper.eq("work_order_no", omProductionOrderInfoList.get(0).getWorkOrderNo());
-                            updateWrapper.set("pre_status", "3");
+                            updateWrapper.set("pre_status", "2");
                             omProductionOrderInfoService.update(new OmProductionOrderInfo(),updateWrapper);
                         }
                     }
@@ -217,21 +217,29 @@
                     List<DaCollectionParamConf> daCollectionParamConfList1 = daCollectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf1);
                     for (DaCollectionParamConf conf : daCollectionParamConfList1) {
                         String gatherAddress = conf.getGatherAddress();
-                        String valueObj = miloService.readFromOpcUa(gatherAddress).getValue().toString(); // 鑾峰彇鍘熷鍊煎璞♀��:ml-citation{ref="4" data="citationList"}
-                        if (!Objects.equals(valueObj, "                                                  ")) {
-                            DaMaterialCollection materialCollection = new DaMaterialCollection();
-                            materialCollection.setSfcCode(SFCCode.toString());
-                            materialCollection.setLocationCode(device);
-                            materialCollection.setParamName(conf.getParameterSetName());
-                            materialCollection.setParamValue(miloService.readFromOpcUa(gatherAddress).getValue().toString());
-                            Date Time = new Date();
-                            ReadWriteEntity TimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StopTime");
-                            Time = format.parse(TimeUtil.test(TimeUtil.stringProcessing(TimeRead.getValue().toString())));
-                            materialCollection.setCollectTime(Time);
-                            daMaterialCollectionService.insertDaMaterialCollection(materialCollection);
-                        }
-                        else {
-                            log.debug("閲囬泦椤逛负绌�: {}", gatherAddress);
+
+                        String valueObj = null;
+                        ReadWriteEntity entity = miloService.readFromOpcUa(gatherAddress);
+                        if (entity != null) {
+                            Object value = entity.getValue();
+                            if (value != null) {
+                                valueObj = value.toString();  // 鏈�缁堣祴鍊�
+                                if (!Objects.equals(valueObj, "                                                  ")) {
+                                    DaMaterialCollection materialCollection = new DaMaterialCollection();
+                                    materialCollection.setSfcCode(SFCCode.toString());
+                                    materialCollection.setLocationCode(device);
+                                    materialCollection.setParamName(conf.getParameterSetName());
+                                    materialCollection.setParamValue(miloService.readFromOpcUa(gatherAddress).getValue().toString());
+                                    Date Time = new Date();
+                                    ReadWriteEntity TimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StopTime");
+                                    Time = format.parse(TimeUtil.test(TimeUtil.stringProcessing(TimeRead.getValue().toString())));
+                                    materialCollection.setCollectTime(Time);
+                                    daMaterialCollectionService.insertDaMaterialCollection(materialCollection);
+                                }
+                                else {
+                                    log.debug("閲囬泦椤逛负绌�: {}", gatherAddress);
+                                }
+                            }
                         }
                     }
 //                    鏌ヨdescriptive瀛楁绛変簬2鐨勯噰闆嗛」淇濆瓨鍒版壂鐮佷繚瀛樺埌da_param_collection琛ㄩ噷
@@ -280,6 +288,7 @@
             log.error(e.getMessage());
         }
 }
+
     //棣栧伐绔欎笅鍙戝伐鍗�,骞剁敓鎴怱N鐮�
     private static final String[] MONTH = {"A","B","C","D","E","F","G","H","I","J","K","L"};
     public void plackWorkOrder(String thoroughfare, String device, String tab, String valueString) {
@@ -334,7 +343,8 @@
                             if (Objects.equals(getBodyOrder2.getBodyQty(), getBodyOrder2.getPlanQty())){
                                 omProductionOrderInfoService.updateBodyStatus2();
                             }
-                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(getBodyOrder2.getBodyQty()).build());
+                            String PalletID = getBodyOrder2.getBodyQty().toString();
+                            miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(PalletID).build());
                             miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderRequestDone").value(11).build());
                     }
                     else{
@@ -386,7 +396,8 @@
                         if (Objects.equals(getHeadOrder2.getHeadQty(), getHeadOrder2.getPlanQty())){
                             omProductionOrderInfoService.updateHeadStatus2();
                         }
-                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(getHeadOrder2.getHeadQty()).build());
+                        String PalletID = getHeadOrder2.getHeadQty().toString();
+                        miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(PalletID).build());
                         miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderRequestDone").value(11).build());
                     }
                     else{
@@ -437,7 +448,8 @@
                         if (Objects.equals(getPreOrder2.getPreQty(), getPreOrder2.getPlanQty())){
                             omProductionOrderInfoService.updatePreStatus2();
                         }
-                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(getPreOrder2.getPreQty()).build());
+                        String PalletID = getPreOrder2.getPreQty().toString();
+                        miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(PalletID).build());
                         miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderRequestDone").value(11).build());
                     }
                     else{

--
Gitblit v1.9.3