From 537bfb7e43c78d5b3b98ba8a135b638f0461ea60 Mon Sep 17 00:00:00 2001
From: admin <15939171744@163.com>
Date: 星期日, 20 十月 2024 15:50:30 +0800
Subject: [PATCH] 优化

---
 jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 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 d151a22..09ebfc2 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
@@ -127,13 +127,19 @@
 
                         }
                     }else {//鑷姩宸ヤ綅
-                        //鎵�鏈夎繘绔欏皢杩涚珯鏃堕棿鍐欑粰PLC
-                        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                        String currentDate = dateFormat.format(new Date());
-                        miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".StartTime").value(currentDate).build());
+                        Object snCodeObject = miloService.readFromOpcUa(thoroughfare + "." + device + ".SNCode").getValue();
+                        if (ObjectUtil.isNull(snCodeObject)){
+                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build());
+                        }else{
+                            //鎵�鏈夎繘绔欏皢杩涚珯鏃堕棿鍐欑粰PLC
+                            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                            String currentDate = dateFormat.format(new Date());
+                            miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".StartTime").value(currentDate).build());
 
-                        Integer recordDataDone = 11;
-                        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(recordDataDone).build());
+                            Integer recordDataDone = 11;
+                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(recordDataDone).build());
+                        }
+
                     }
 
                 } else if(Constants.TWO.equals(valueString)){//鍑虹珯
@@ -185,10 +191,12 @@
                                             }
                                         }
                                         if(Constants.OP230.equals(device)){
+                                            WebSocketUsers.sendMessageToUserByText(map.get(device), "twoHundredAndThirtyEND");
                                             CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> {
                                                 updateOrderStatus(snCode, "5","");//OP230宸ヤ綅鏇存柊宸ュ崟鐘舵�佷负宸插畬鎴�
                                                 reportFactoryMes(snCode, "OP240", format.format(new Date()));//宸ュ巶MES鎶ュ伐   //鏆傛椂 OP240宸ヤ綅杩樻病鏈夊ソ锛屽湪230鎶�240鐨勫伐
                                             });
+                                            miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".SNCode").value("").build());
                                         }
                                         if(result == 21){
                                             result = savePassingStation(thoroughfare, device, snCode, orderNumber, stationStatus);//淇濆瓨杩囩珯

--
Gitblit v1.9.3