From 96bf3f238144416b09ff7c7c346f7d88b98214b8 Mon Sep 17 00:00:00 2001
From: lsh <lsh@163.com>
Date: 星期四, 24 十月 2024 14:11:03 +0800
Subject: [PATCH] *

---
 src/main/java/com/zy/core/thread/SiemensDevpThread.java |   64 ++++++++++++++++++++++----------
 1 files changed, 44 insertions(+), 20 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index 80fce32..1d2f54c 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -133,7 +133,7 @@
     /**
      * 鏉$爜鏁伴噺
      */
-    private int barcodeSize = 9;
+    private int barcodeSize = 5;
 
     /**
      * 鍏ュ嚭搴撴ā寮�
@@ -354,11 +354,15 @@
         Thread.sleep(200);
         OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.2440",(short)(barcodeSize*8));
         if (result2.IsSuccess) {
-            int[] staNosRgv = {281,292,173,214,120,100,101,102,103};
-
-            for (int i = 0; i < barcodeSize; i++) {  //1:281  2:292  3:174(173) 4:214  5:120
+            int[] staNosRgv = new int[]{281,292,173,214,120};
+            if (slave.getId()==2){
+                staNosRgv = new int[]{453,460,518,532,607};
+            }
+            for (int i = 0; i < barcodeSize; i++) {
+                //1:281  2:292  3:174(173) 4:214  5:120
+                //6:453  7:460  8:508 9:534  10:611
                 String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,8, "UTF-8");
-                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1);
+                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, (i + 1+((slave.getId()-1)*5)));
                 if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
                     Integer siteId = staNosRgv[i]; // 绔欑偣缂栧彿
                     StaProtocol staProtocol = station.get(siteId);
@@ -371,19 +375,34 @@
             }
         }
 
-        //RGV灏忚溅
-        Thread.sleep(200);
-        OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB100.160",(short)2);
-        if (result3.IsSuccess) {
-            Integer siteId = 2000;
-            StaProtocol staProtocol = station.get(siteId);
-            if (null == staProtocol) {
-                staProtocol = new StaProtocol();
-                staProtocol.setSiteId(siteId);
-                station.put(siteId, staProtocol);
+        if (slave.getId()==2){
+            OperateResultExOne<byte[]> result464 = siemensS7Net.Read("DB101.3720",(short)(8));
+            if (result464.IsSuccess) {
+                String barcode = siemensS7Net.getByteTransform().TransString(result464.Content,0,8, "UTF-8");
+                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 11);
+                if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
+                    StaProtocol staProtocol = station.get(464);
+                    if (null != staProtocol) {
+                        staProtocol.setBarcode(barcode);
+                        barcodeThread.setBarcode(barcode);
+                    }
+                }
             }
-            staProtocol.setNearbySta(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result3.Content, 0)));
         }
+
+//        //RGV灏忚溅
+//        Thread.sleep(200);
+//        OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB100.160",(short)2);
+//        if (result3.IsSuccess) {
+//            Integer siteId = 2000;
+//            StaProtocol staProtocol = station.get(siteId);
+//            if (null == staProtocol) {
+//                staProtocol = new StaProtocol();
+//                staProtocol.setSiteId(siteId);
+//                station.put(siteId, staProtocol);
+//            }
+//            staProtocol.setNearbySta(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result3.Content, 0)));
+//        }
 
         if (result.IsSuccess) {
 
@@ -397,9 +416,13 @@
                     basDevps.add(staProtocol.toSqlModel());
                 }
 
-                BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class);
-                if (null != basDevpService && !basDevpService.updateBatchById(basDevps)) {
-                    throw new Exception("鏇存柊鏁版嵁搴撴暟鎹け璐�");
+                try{
+                    BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class);
+                    if (null != basDevpService && !basDevpService.updateBatchById(basDevps)) {
+                        throw new Exception("鏇存柊鏁版嵁搴撴暟鎹け璐�");
+                    }
+                } catch (Exception e){
+                    log.error("鏇存柊鏁版嵁搴撴暟鎹け璐� ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
                 }
             } catch (Exception e) {
                 e.printStackTrace();
@@ -1017,9 +1040,10 @@
      * 璁剧疆鍏ュ簱鏍囪
      */
     @Override
-    public void setPakMk(Integer siteId, boolean pakMk) {
+    public void setPakMk(Integer siteId, boolean pakMk,Integer i) {
         StaProtocol staProtocol = station.get(siteId);
         if (null != staProtocol) {
+            log.info("閿佸畾鍏ュ簱鏍囪锛岀珯鐐瑰彿={};pakMk={};鏃堕棿={};鏍囪={}",siteId,pakMk,new Date(),i);
             staProtocol.setPakMk(pakMk);
         }
     }

--
Gitblit v1.9.1