From f033da325dd16825bbca0d1ac71cc76420dfc8a2 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期五, 09 一月 2026 11:14:36 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/network/real/ZyStationRealConnect.java |   43 +++++++++++++++++++++++++++++++++++++++----
 1 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/zy/core/network/real/ZyStationRealConnect.java b/src/main/java/com/zy/core/network/real/ZyStationRealConnect.java
index 0399061..97b1c6c 100644
--- a/src/main/java/com/zy/core/network/real/ZyStationRealConnect.java
+++ b/src/main/java/com/zy/core/network/real/ZyStationRealConnect.java
@@ -4,6 +4,7 @@
 import HslCommunication.Core.Types.OperateResultExOne;
 import HslCommunication.Profinet.Siemens.SiemensPLCS;
 import HslCommunication.Profinet.Siemens.SiemensS7Net;
+import com.zy.common.utils.RedisUtil;
 import lombok.extern.slf4j.Slf4j;
 
 import com.alibaba.fastjson.JSON;
@@ -21,6 +22,7 @@
 import com.zy.core.network.api.ZyStationConnectApi;
 import com.zy.core.network.entity.ZyStationStatusEntity;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 
 import java.text.MessageFormat;
@@ -36,9 +38,11 @@
     private List<ZyStationStatusEntity> barcodeStatusList;
     private SiemensS7Net siemensNet;
     private DeviceConfig deviceConfig;
+    private RedisUtil redisUtil;
 
-    public ZyStationRealConnect(DeviceConfig deviceConfig) {
+    public ZyStationRealConnect(DeviceConfig deviceConfig, RedisUtil redisUtil) {
         this.deviceConfig = deviceConfig;
+        this.redisUtil = redisUtil;
     }
 
     @Override
@@ -70,7 +74,7 @@
     }
 
     @Override
-    public List<ZyStationStatusEntity> getStatus() {
+    public List<ZyStationStatusEntity> getStatus(Integer deviceNo) {
         if (statusList == null) {
             BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class);
             if (basDevpService == null) {
@@ -84,6 +88,9 @@
             }
 
             statusList = JSONObject.parseArray(basDevp.getStationList(), ZyStationStatusEntity.class);
+            if (statusList != null) {
+                statusList.sort(Comparator.comparing(ZyStationStatusEntity::getStationId));
+            }
             barcodeStatusList = JSONObject.parseArray(basDevp.getBarcodeStationList(), ZyStationStatusEntity.class);
         }
 
@@ -129,7 +136,7 @@
     }
 
     @Override
-    public CommandResponse sendCommand(StationCommand command) {
+    public CommandResponse sendCommand(Integer deviceNo, StationCommand command) {
         CommandResponse commandResponse = new CommandResponse(false);
         if (null == command) {
             commandResponse.setMessage("鍛戒护涓虹┖");
@@ -183,6 +190,34 @@
         return commandResponse;
     }
 
+    @Override
+    public CommandResponse sendOriginCommand(String address, short[] data) {
+        CommandResponse commandResponse = new CommandResponse(false);
+        if (null == data || data.length == 0) {
+            commandResponse.setMessage("鏁版嵁涓虹┖");
+            return commandResponse;
+        }
+
+        OperateResult write = siemensNet.Write(address, data);
+        if (write.IsSuccess) {
+            log.info("鍐欏叆鍘熷鍛戒护鎴愬姛銆傚湴鍧�={}锛屾暟鎹�={}", address, JSON.toJSON(data));
+            commandResponse.setResult(true);
+        } else {
+            log.error("鍐欏叆鍘熷鍛戒护澶辫触銆傚湴鍧�={}锛屾暟鎹�={}", address, JSON.toJSON(data));
+            commandResponse.setResult(false);
+        }
+        return commandResponse;
+    }
+
+    @Override
+    public byte[] readOriginCommand(String address, int length) {
+        OperateResultExOne<byte[]> result = siemensNet.Read(address, (short) length);
+        if (result.IsSuccess) {
+            return result.Content;
+        }
+        return new byte[0];
+    }
+
     private ZyStationStatusEntity findStatusEntity(Integer stationId) {
         for (ZyStationStatusEntity statusEntity : statusList) {
             if (statusEntity.getStationId().equals(stationId)) {
@@ -201,4 +236,4 @@
         }
         return -1;
     }
-}
\ No newline at end of file
+}

--
Gitblit v1.9.1