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 |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 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 e4e6c25..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
@@ -121,17 +121,25 @@
                                 productNum = "productNum,"+ productNum;
                                 WebSocketUsers.sendMessageToUserByText(map.get(device), productNum);
                                 miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build());
+                                String str = thoroughfare + "." + device + ".MESScrew";
+                                miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(str).value(1).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());
+                        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)){//鍑虹珯
@@ -178,15 +186,17 @@
                                                     CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> {
                                                         updateOrderStatus(snCode, "3",housingCode);//OP010宸ヤ綅鏇存柊宸ュ崟鐘舵�佷负鎵ц涓�,骞舵洿鏂颁富鐗╂枡澹充綋鏉$爜
                                                         reportFactoryMes(snCode, device, format.format(new Date()));//宸ュ巶MES鎶ュ伐
-                                                    });
+                                                     });
                                                 }
                                             }
                                         }
                                         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