From 53a71007458bdded764dc52a39d596f8c4ca28db Mon Sep 17 00:00:00 2001
From: DELL <DELL@qq.com>
Date: 星期四, 18 九月 2025 15:42:41 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/thread/fake/FakeNyLiftThread.java |   75 ++++++++++++++++++++++++-------------
 1 files changed, 49 insertions(+), 26 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/fake/FakeNyLiftThread.java b/src/main/java/com/zy/core/thread/fake/FakeNyLiftThread.java
index 5e0d063..d7543ba 100644
--- a/src/main/java/com/zy/core/thread/fake/FakeNyLiftThread.java
+++ b/src/main/java/com/zy/core/thread/fake/FakeNyLiftThread.java
@@ -1,6 +1,7 @@
 package com.zy.core.thread.fake;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.zy.common.Cools;
 import com.zy.common.SpringUtils;
@@ -28,7 +29,7 @@
 public class FakeNyLiftThread implements FakeThread {
 
     private RedisUtil redisUtil;
-    private JSONObject fakeStatusDemo = JSONObject.parseObject("{\"model\":2,\"plcTaskNo\":0,\"lev\":1,\"protocolStatus\":0,\"taskMode\":0,\"pick\":0,\"put\":0,\"iOMode\":0,\"errorCode\":0,\"hasTray\":0,\"hasCar\":0,\"trayList\":[0,0,0,0],\"carList\":[0,0,0,0],\"extend\":{\"frontOverrun\":false,\"backOverrun\":false,\"leftOverrun\":false,\"rightOverrun\":false,\"overHeight\":false,\"overWeight\":false}}");
+    private JSONObject fakeStatusDemo = JSONObject.parseObject("{\"model\":2,\"plcTaskNo\":0,\"lev\":1,\"deviceStatus\":0,\"taskMode\":0,\"pick\":0,\"put\":0,\"iOMode\":0,\"errorCode\":0,\"hasTray\":0,\"hasCar\":0,\"stationList\":[{\"siteId\":101,\"model\":1,\"busy\":0,\"hasTray\":0,\"deviceError\":0,\"taskNo\":0,\"staNo\":0,\"allowShuttleTake\":0,\"allowShuttlePut\":0,\"barcode\":\"\"},{\"siteId\":102,\"model\":1,\"busy\":0,\"hasTray\":0,\"deviceError\":0,\"taskNo\":0,\"staNo\":0,\"allowShuttleTake\":0,\"allowShuttlePut\":0,\"barcode\":\"\"},{\"siteId\":103,\"model\":1,\"busy\":0,\"hasTray\":0,\"deviceError\":0,\"taskNo\":0,\"staNo\":0,\"allowShuttleTake\":0,\"allowShuttlePut\":0,\"barcode\":\"\"},{\"siteId\":1001,\"model\":1,\"busy\":0,\"hasTray\":0,\"deviceError\":0,\"taskNo\":0,\"staNo\":0,\"allowShuttleTake\":0,\"allowShuttlePut\":0,\"barcode\":\"\"},{\"siteId\":1002,\"model\":1,\"busy\":0,\"hasTray\":0,\"deviceError\":0,\"taskNo\":0,\"staNo\":0,\"allowShuttleTake\":0,\"allowShuttlePut\":0,\"barcode\":\"\"},{\"siteId\":1003,\"model\":1,\"busy\":0,\"hasTray\":0,\"deviceError\":0,\"taskNo\":0,\"staNo\":0,\"allowShuttleTake\":0,\"allowShuttlePut\":0,\"barcode\":\"\"}],\"extend\":{\"frontOverrun\":false,\"backOverrun\":false,\"leftOverrun\":false,\"rightOverrun\":false,\"overHeight\":false,\"overWeight\":false}}");
     private ConcurrentHashMap<String, Thread> fakeThreadMap = new ConcurrentHashMap();
     private ConcurrentHashMap<String, JSONObject> fakeStatusMap = new ConcurrentHashMap();
     private ConcurrentHashMap<String, JSONObject> fakeCommandMap = new ConcurrentHashMap();
@@ -168,7 +169,7 @@
                 if (commandType == 1) {
                     //鍙栨斁璐�
                     fakeStatus.put("plcTaskNo", commandBody.getInteger("taskNo"));//浠诲姟鍙�
-                    fakeStatus.put("protocolStatus", 1);//鍙栬揣涓�
+                    fakeStatus.put("deviceStatus", 1);//鍙栬揣涓�
                     fakeStatus.put("taskMode", commandType);//浠诲姟绫诲瀷
                     fakeStatus.put("pick", commandBody.getInteger("pick"));//鍙栬揣鏁版嵁
                     fakeStatus.put("put", commandBody.getInteger("put"));//鏀捐揣鏁版嵁
@@ -177,16 +178,19 @@
                     //delay
                     Thread.sleep(5000);
 
-                    fakeStatus.put("protocolStatus", 0);
+                    Integer put = commandBody.getInteger("put");
+                    int lev = put % 100;
+
+                    fakeStatus.put("deviceStatus", 0);
                     fakeStatus.put("taskMode", 0);//浠诲姟绫诲瀷
                     fakeStatus.put("pick", 0);//鍙栬揣鏁版嵁
                     fakeStatus.put("put", 0);//鏀捐揣鏁版嵁
-                    fakeStatus.put("lev", commandBody.getInteger("put"));
+                    fakeStatus.put("lev", lev);
                     fakeStatusMap.put(key, fakeStatus);
                 } else if (commandType == 2) {
                     //灏忚溅鎹㈠眰
                     fakeStatus.put("plcTaskNo", commandBody.getInteger("taskNo"));//浠诲姟鍙�
-                    fakeStatus.put("protocolStatus", 1);//鍙栬揣涓�
+                    fakeStatus.put("deviceStatus", 1);//鍙栬揣涓�
                     fakeStatus.put("taskMode", commandType);//浠诲姟绫诲瀷
                     fakeStatus.put("pick", commandBody.getInteger("pick"));//鍙栬揣鏁版嵁
                     fakeStatus.put("put", commandBody.getInteger("put"));//鏀捐揣鏁版嵁
@@ -195,16 +199,19 @@
                     //delay
                     Thread.sleep(5000);
 
-                    fakeStatus.put("protocolStatus", 0);
+                    Integer put = commandBody.getInteger("put");
+                    int lev = put % 100;
+
+                    fakeStatus.put("deviceStatus", 0);
                     fakeStatus.put("taskMode", 0);//浠诲姟绫诲瀷
                     fakeStatus.put("pick", 0);//鍙栬揣鏁版嵁
                     fakeStatus.put("put", 0);//鏀捐揣鏁版嵁
-                    fakeStatus.put("lev", commandBody.getInteger("put"));
+                    fakeStatus.put("lev", lev);
                     fakeStatusMap.put(key, fakeStatus);
                 } else if (commandType == 3) {
                     //鎻愬崌鏈虹Щ鍔�
                     fakeStatus.put("plcTaskNo", commandBody.getInteger("taskNo"));//浠诲姟鍙�
-                    fakeStatus.put("protocolStatus", 1);//绉诲姩涓�
+                    fakeStatus.put("deviceStatus", 1);//绉诲姩涓�
                     fakeStatus.put("taskMode", commandType);//浠诲姟绫诲瀷
                     fakeStatus.put("pick", commandBody.getInteger("pick"));//鍙栬揣鏁版嵁
                     fakeStatus.put("put", commandBody.getInteger("put"));//鏀捐揣鏁版嵁
@@ -213,16 +220,19 @@
                     //delay
                     Thread.sleep(5000);
 
-                    fakeStatus.put("protocolStatus", 0);
+                    Integer put = commandBody.getInteger("put");
+                    int lev = put % 100;
+
+                    fakeStatus.put("deviceStatus", 0);
                     fakeStatus.put("taskMode", 0);//浠诲姟绫诲瀷
                     fakeStatus.put("pick", 0);//鍙栬揣鏁版嵁
                     fakeStatus.put("put", 0);//鏀捐揣鏁版嵁
-                    fakeStatus.put("lev", commandBody.getInteger("put"));
+                    fakeStatus.put("lev", lev);
                     fakeStatusMap.put(key, fakeStatus);
                 } else if (commandType == 9996) {
                     //澶嶄綅
                     fakeStatus.put("plcTaskNo", 0);//浠诲姟鍙�
-                    fakeStatus.put("protocolStatus", 0);
+                    fakeStatus.put("deviceStatus", 0);
                     fakeStatus.put("taskMode", 0);//浠诲姟绫诲瀷
                     fakeStatus.put("pick", 0);//鍙栬揣鏁版嵁
                     fakeStatus.put("put", 0);//鏀捐揣鏁版嵁
@@ -234,6 +244,27 @@
                 } else if (commandType == 9998) {
                     //鍒囨崲鍑哄簱妯″紡
                     fakeStatus.put("iOMode", 2);//鍑哄叆搴撴ā寮�
+                    fakeStatusMap.put(key, fakeStatus);
+                } else if (commandType == 10000) {
+                    //鍐欏叆杈撻�佺嚎鏁版嵁
+                    Integer siteId = commandBody.getInteger("siteId");
+                    Integer staNo = commandBody.getInteger("staNo");
+                    Integer taskNo = commandBody.getInteger("taskNo");
+                    String address = commandBody.getString("address");
+
+                    short[] array = new short[2];
+                    array[0] = staNo.shortValue();//鐩爣绔�
+                    array[1] = taskNo.shortValue();//浠诲姟鍙�
+
+                    JSONArray stationList = fakeStatus.getJSONArray("stationList");
+                    for (int i = 0; i < stationList.size(); i++) {
+                        JSONObject staObj = stationList.getJSONObject(i);
+                        if (staObj.getInteger("siteId").equals(siteId)) {
+                            staObj.put("taskNo", taskNo);
+                            staObj.put("staNo", staNo);
+                        }
+                    }
+
                     fakeStatusMap.put(key, fakeStatus);
                 }
 
@@ -324,6 +355,10 @@
             //璇诲彇鐘舵��
             response = genereateFakeStatusResponse(fakeStatus);
             deviceMsgType = "status";
+        } else if (mode == 10000) {
+            //鍐欏叆杈撻�佺嚎鏁版嵁
+            fakeCommandMap.put(String.valueOf(SlaveType.Lift) + device.getDeviceNo(), fakeCommand);
+            response = genereateFakeCommandResponse();
         }
 
         fakeStatusMap.put(String.valueOf(SlaveType.Lift) + device.getDeviceNo(), fakeStatus);
@@ -349,7 +384,7 @@
 
         device.put("model", fakeStatus.getInteger("model"));
         device.put("plcTaskNo", fakeStatus.getInteger("plcTaskNo"));
-        device.put("protocolStatus", fakeStatus.getInteger("protocolStatus"));
+        device.put("deviceStatus", fakeStatus.getInteger("deviceStatus"));
         device.put("taskMode", fakeStatus.getInteger("taskMode"));
         device.put("pick", fakeStatus.getInteger("pick"));
         device.put("put", fakeStatus.getInteger("put"));
@@ -359,20 +394,8 @@
         device.put("hasCar", fakeStatus.getInteger("hasCar"));
         device.put("lev", fakeStatus.getInteger("lev"));
 
-        Object trayListObj = fakeStatus.get("trayList");
-        List<Integer> trayList = new ArrayList<>();
-        if (trayListObj != null) {
-            trayList = JSON.parseArray(JSON.toJSONString(trayListObj), Integer.class);
-        }
-
-        Object carListObj = fakeStatus.get("carList");
-        List<Integer> carList = new ArrayList<>();
-        if (carListObj != null) {
-            carList = JSON.parseArray(JSON.toJSONString(carListObj), Integer.class);
-        }
-
-        device.put("trayList", trayList);
-        device.put("carList", carList);
+        JSONArray stationList = fakeStatus.getJSONArray("stationList");
+        device.put("stationList", stationList);
 
         JSONObject extend = fakeStatus.getJSONObject("extend");
         device.put("frontOverrun", extend.getBoolean("frontOverrun"));

--
Gitblit v1.9.1