From 80a29f7eb79e5a6929437e407d6179f1542fabde Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期六, 11 四月 2026 10:17:40 +0800
Subject: [PATCH] 1

---
 zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/properties/DevpSlave.java     |    2 ++
 zy-asc-conveyor/src/main/resources/application.yml                                   |    2 ++
 zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/thread/SiemensDevpThread.java |   35 +++++++++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/properties/DevpSlave.java b/zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/properties/DevpSlave.java
index c1a30cc..9b1e241 100644
--- a/zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/properties/DevpSlave.java
+++ b/zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/properties/DevpSlave.java
@@ -27,6 +27,8 @@
 
     private List<Integer> barcodeArr = new ArrayList<>();
 
+    private List<Integer> weightArr = new ArrayList<>();
+
     private List<Integer> staNos = new ArrayList<>();
 
     private List<Integer> staNosError = new ArrayList<>();
diff --git a/zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/thread/SiemensDevpThread.java b/zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/thread/SiemensDevpThread.java
index 0c9d2ee..4df073c 100644
--- a/zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/thread/SiemensDevpThread.java
+++ b/zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/thread/SiemensDevpThread.java
@@ -17,6 +17,8 @@
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -114,6 +116,9 @@
         // 璇诲彇鏉$爜
         readBarcodes();
 
+        // 绉伴噸
+        readWeight();
+
         // 璇诲彇澶栧舰妫�娴嬮敊璇�
         readDimensionErrors();
 
@@ -175,6 +180,9 @@
 
             if (!Cools.isEmpty(barcode)) {
                 StaProtocol staProtocol = station.get(barcodeArr.get(i));
+                if (staProtocol == null) {
+                    continue;
+                }
                 staProtocol.setBarcode(barcode);
                 News.info("鏂欑鐮侊細{}", barcode);
             }
@@ -182,6 +190,33 @@
     }
 
     /**
+     * 璇诲彇鏉$爜淇℃伅
+     */
+    private void readWeight() {
+        List<Integer> weightArr = slave.getWeightArr();
+        if (weightArr == null || weightArr.isEmpty()) {
+            return;
+        }
+
+        OperateResultExOne<byte[]> result = siemensS7Net.Read(
+                DeviceField.WEIGHT.buildAddress(),
+                (short) (weightArr.size() * DeviceField.WEIGHT.getByteLength()));
+
+        if (!result.IsSuccess) {
+            log.warn("璇诲彇閲嶉噺澶辫触 [id:{}]", slave.getId());
+            return;
+        }
+        for (int i = 0; i < weightArr.size(); i++) {
+            StaProtocol staProtocol = station.get(weightArr.get(i));
+            if (staProtocol == null) {
+                continue;
+            }
+            double weight = siemensS7Net.getByteTransform().TransSingle(result.Content, i * 4);
+            staProtocol.setWeight(BigDecimal.valueOf(weight).setScale(2, RoundingMode.HALF_UP).doubleValue());
+        }
+    }
+
+    /**
      * 璇诲彇澶栧舰妫�娴嬮敊璇�
      */
     private void readDimensionErrors() {
diff --git a/zy-asc-conveyor/src/main/resources/application.yml b/zy-asc-conveyor/src/main/resources/application.yml
index c4f1655..5f095f5 100644
--- a/zy-asc-conveyor/src/main/resources/application.yml
+++ b/zy-asc-conveyor/src/main/resources/application.yml
@@ -106,6 +106,8 @@
       - 1010
     barcodeArr:
       - 1010
+    weightArr:
+      - 1010
     # ctu鏀捐揣绔欑偣
     releaseSta[0]:
       # 鏈珯鐐�

--
Gitblit v1.9.1