From 6c0b7b84f1671462ca0893b109c26e7d49afb23a Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期二, 23 九月 2025 13:26:22 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/shuttle_rcs_gateway' into shuttle_rcs_gateway

---
 src/main/java/com/zy/core/thread/impl/NyLiftThread.java |   63 ++++++++++++-------------------
 1 files changed, 24 insertions(+), 39 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/impl/NyLiftThread.java b/src/main/java/com/zy/core/thread/impl/NyLiftThread.java
index 8135de8..b555f70 100644
--- a/src/main/java/com/zy/core/thread/impl/NyLiftThread.java
+++ b/src/main/java/com/zy/core/thread/impl/NyLiftThread.java
@@ -106,12 +106,10 @@
         JSONObject commandObj = JSON.parseObject(command);
 
         HashMap<String, Object> resultData = new HashMap<>();
-        resultData.put("result", "false");
+        resultData.put("result", "success");
 
         String deviceMsgType = "command";
-        OperateResult result = null;
-        OperateResult result2 = null;
-        if (commandObj.getInteger("mode") == 3) {
+        if (commandObj.getInteger("mode") == 1) {
             //鍙栨斁璐�
             short[] array = new short[4];
             array[0] = 1;//浠诲姟绫诲瀷
@@ -120,13 +118,11 @@
             array[3] = commandObj.getShort("taskNo");//浠诲姟鍙�
             resultData.put("commandData", array);
 
-            result = siemensS7Net.Write("DB83.0", array);
+            OperateResult result = siemensS7Net.Write("DB83.0", array);
             if (result.IsSuccess) {
                 resultData.put("result", "success");
             }
-
-            resultData.put("commandResult1", JSON.toJSONString(result));
-        } else if (commandObj.getInteger("mode") == 4) {
+        } else if (commandObj.getInteger("mode") == 2) {
             //灏忚溅鎹㈠眰
             short[] array = new short[4];
             array[0] = 2;//浠诲姟绫诲瀷
@@ -135,13 +131,11 @@
             array[3] = commandObj.getShort("taskNo");//浠诲姟鍙�
             resultData.put("commandData", array);
 
-            result = siemensS7Net.Write("DB83.0", array);
+            OperateResult result = siemensS7Net.Write("DB83.0", array);
             if (result.IsSuccess) {
                 resultData.put("result", "success");
             }
-
-            resultData.put("commandResult1", JSON.toJSONString(result));
-        } else if (commandObj.getInteger("mode") == 5) {
+        } else if (commandObj.getInteger("mode") == 3) {
             //鎻愬崌鏈虹Щ鍔�
             short[] array = new short[4];
             array[0] = 2;//浠诲姟绫诲瀷
@@ -150,51 +144,40 @@
             array[3] = commandObj.getShort("taskNo");//浠诲姟鍙�
             resultData.put("commandData", array);
 
-            result = siemensS7Net.Write("DB83.0", array);
+            OperateResult result = siemensS7Net.Write("DB83.0", array);
             if (result.IsSuccess) {
                 resultData.put("result", "success");
             }
-
-            resultData.put("commandResult1", JSON.toJSONString(result));
         } else if (commandObj.getInteger("mode") == 9996) {
             //澶嶄綅
             short[] array = new short[1];
             array[0] = 1;
             resultData.put("commandData", array);
 
-            result = siemensS7Net.Write("DB103.10", array);
+            OperateResult result = siemensS7Net.Write("DB103.10", array);
             if (result.IsSuccess) {
                 resultData.put("result", "success");
             }
-
-            resultData.put("commandResult1", JSON.toJSONString(result));
-            resultData.put("commandResult2", JSON.toJSONString(result2));
         } else if (commandObj.getInteger("mode") == 9997) {
             //鍒囨崲鍏ュ簱妯″紡
             short[] array = new short[1];
             array[0] = 1;
             resultData.put("commandData", array);
 
-            result = siemensS7Net.Write("DB103.12", array);
+            OperateResult result = siemensS7Net.Write("DB103.12", array);
             if (result.IsSuccess) {
                 resultData.put("result", "success");
             }
-
-            resultData.put("commandResult1", JSON.toJSONString(result));
-            resultData.put("commandResult2", JSON.toJSONString(result2));
         } else if (commandObj.getInteger("mode") == 9998) {
             //鍒囨崲鍑哄簱妯″紡
             short[] array = new short[1];
             array[0] = 2;
             resultData.put("commandData", array);
 
-            result = siemensS7Net.Write("DB103.12", array);
+            OperateResult result = siemensS7Net.Write("DB103.12", array);
             if (result.IsSuccess) {
                 resultData.put("result", "success");
             }
-
-            resultData.put("commandResult1", JSON.toJSONString(result));
-            resultData.put("commandResult2", JSON.toJSONString(result2));
         } else if (commandObj.getInteger("mode") == 9999) {
             //璇诲彇鐘舵��
             JSONObject device = new JSONObject();
@@ -210,9 +193,9 @@
                 //妯″紡
                 device.put("model", status1[0] ? 2 : 1);
                 //PLC浠诲姟鍙�
-                device.put("wrkNo", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 6));
+                device.put("plcTaskNo", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 6));
                 //璁惧鐘舵��
-                device.put("deviceStatus", status1[0] ? 0 : 1);
+                device.put("deviceStatus", status1[1] ? 0 : 1);
                 //浠诲姟妯″紡
                 device.put("taskMode", 0);
                 //鍙栬揣鏁版嵁
@@ -244,6 +227,8 @@
                 extend.put("overHeight", status2[0] ? 1 : 0);
                 //瓒呴噸
                 extend.put("overWeight", status2[1] ? 1 : 0);
+                //PLC宸插畬鎴愪换鍔″彿
+                extend.put("plcTaskNoComplete", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 10));
 
                 resultData.put("deviceStatus", device);
             }
@@ -263,9 +248,9 @@
                 int i = 0;
                 for (Integer siteId : staList) {
                     //璇诲彇4.0-4.7鏁版嵁
-                    boolean[] status1 = siemensS7Net.getByteTransform().TransBool(readResult2.Content, i*26, 1);
+                    boolean[] status1 = siemensS7Net.getByteTransform().TransBool(readResult2.Content, i * 26, 1);
                     //璇诲彇5.0-5.7鏁版嵁
-                    boolean[] status2 = siemensS7Net.getByteTransform().TransBool(readResult2.Content, i*26 + 1, 1);
+                    boolean[] status2 = siemensS7Net.getByteTransform().TransBool(readResult2.Content, i * 26 + 1, 1);
                     String barcode = siemensS7Net.getByteTransform().TransString(readResult2.Content, i * 26 + 10, 12, "UTF-8");
 
                     JSONObject station = new JSONObject();
@@ -276,16 +261,18 @@
                     station.put("allowShuttleTake", status2[5] ? 1 : 0);
                     station.put("allowShuttlePut", status2[6] ? 1 : 0);
                     station.put("deviceError", status2[7] ? 1 : 0);
-                    station.put("taskNo", (int) siemensS7Net.getByteTransform().TransInt16(readResult2.Content, i*26 + 2));
-                    station.put("staNo", (int) siemensS7Net.getByteTransform().TransInt16(readResult2.Content, i*28 + 2));
+                    station.put("taskNo", (int) siemensS7Net.getByteTransform().TransInt16(readResult2.Content, i * 26 + 2));
+                    station.put("staNo", (int) siemensS7Net.getByteTransform().TransInt16(readResult2.Content, i * 28 + 2));
                     station.put("barcode", barcode);
+                    stationList.add(station);
+                    i++;
                 }
             }
 
             device.put("stationList", stationList);
 
-            resultData.put("commandResult1", JSON.toJSONString(readResult1.Content));
-            resultData.put("commandResult2", JSON.toJSONString(readResult2.Content));
+            resultData.put("commandResult1", readResult1.Content);
+            resultData.put("commandResult2", readResult2.Content);
 
             deviceMsgType = "status";
         } else if (commandObj.getInteger("mode") == 10000) {
@@ -303,12 +290,10 @@
 
             resultData.put("commandData", array);
 
-            result = siemensS7Net.Write("address", array);
+            OperateResult result = siemensS7Net.Write("address", array);
             if (result.IsSuccess) {
                 resultData.put("result", "success");
             }
-
-            resultData.put("commandResult1", JSON.toJSONString(result));
         }
 
         if (deviceMsgType.equals("command")) {
@@ -317,7 +302,7 @@
         DeviceMsgModel deviceMsgModel = new DeviceMsgModel();
         deviceMsgModel.setDeviceId(deviceConfig.getDeviceNo());
         deviceMsgModel.setDeviceMsgType(deviceMsgType);
-        deviceMsgModel.setDeviceMsg(JSON.toJSONString(resultData));
+        deviceMsgModel.setDeviceMsg(resultData);
         deviceMsgModel.setDeviceOriginMsg(JSON.toJSONString(resultData));
         deviceMsgModel.setResultKey(deviceCommandMsg.getResultKey());
         deviceMsgUtils.sendDeviceMsg(SlaveType.Lift, deviceConfig.getDeviceNo(), deviceMsgModel);

--
Gitblit v1.9.1