#
DELL
2025-09-18 53a71007458bdded764dc52a39d596f8c4ca28db
src/main/java/com/zy/core/thread/impl/NyLiftThread.java
@@ -22,10 +22,7 @@
import lombok.extern.slf4j.Slf4j;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.*;
@Slf4j
@SuppressWarnings("all")
@@ -130,6 +127,9 @@
                    resultData.put("result", "success");
                }
            }
            resultData.put("commandResult1", JSON.toJSONString(result));
            resultData.put("commandResult2", JSON.toJSONString(result2));
        } else if (commandObj.getInteger("mode") == 4) {
            //小车换层
            short[] array = new short[4];
@@ -146,6 +146,9 @@
                    resultData.put("result", "success");
                }
            }
            resultData.put("commandResult1", JSON.toJSONString(result));
            resultData.put("commandResult2", JSON.toJSONString(result2));
        } else if (commandObj.getInteger("mode") == 5) {
            //提升机移动
            short[] array = new short[4];
@@ -162,6 +165,9 @@
                    resultData.put("result", "success");
                }
            }
            resultData.put("commandResult1", JSON.toJSONString(result));
            resultData.put("commandResult2", JSON.toJSONString(result2));
        } else if (commandObj.getInteger("mode") == 9996) {
            //复位
            short[] array = new short[1];
@@ -172,6 +178,9 @@
            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];
@@ -182,6 +191,9 @@
            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];
@@ -192,64 +204,124 @@
            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();
            OperateResultExOne<byte[]> readResult1 = siemensS7Net.Read("DB101.0", (short) 18);
            OperateResultExOne<byte[]> readResult1 = siemensS7Net.Read("DB82.0", (short) 14);
            if (readResult1.IsSuccess) {
                //读取4.0-4.7数据
                boolean[] status1 = siemensS7Net.getByteTransform().TransBool(readResult1.Content, 4, 1);
                //读取5.0-5.7数据
                boolean[] status2 = siemensS7Net.getByteTransform().TransBool(readResult1.Content, 5, 1);
                //模式
                device.put("model", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 0));
                device.put("model", status1[0] ? 2 : 1);
                //PLC任务号
                device.put("wrkNo", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 2));
                device.put("wrkNo", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 6));
                //设备状态
                device.put("deviceStatus", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 4));
                device.put("deviceStatus", status1[0] ? 0 : 1);
                //任务模式
                device.put("taskMode", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 6));
                device.put("taskMode", 0);
                //取货数据
                device.put("pick", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 8));
                device.put("pick", 0);
                //放货数据
                device.put("put", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 10));
                device.put("put", 0);
                //出入库模式
                device.put("iOMode", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 12));
                device.put("iOMode", 0);
                //有托盘
                device.put("hasTray", status2[5] ? 1 : 0);
                //有小车
                device.put("hasCar", status2[6] ? 1 : 0);
                //故障码
                device.put("errorCode", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 14));
                device.put("errorCode", status2[7] ? 1 : 0);
                //层
                device.put("lev", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 16));
                device.put("lev", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 12));
                JSONObject extend = new JSONObject();
                device.put("extend", extend);
                //前超限
                extend.put("frontOverrun", status1[4] ? 1 : 0);
                //后超限
                extend.put("backOverrun", status1[5] ? 1 : 0);
                //左超限
                extend.put("leftOverrun", status1[6] ? 1 : 0);
                //右超限
                extend.put("rightOverrun", status1[7] ? 1 : 0);
                //超高
                extend.put("overHeight", status2[0] ? 1 : 0);
                //超重
                extend.put("overWeight", status2[1] ? 1 : 0);
                resultData.put("deviceStatus", device);
            }
            //站点个数
            int staCount = 4;
            //读取托盘数据
            List<Integer> trayList = new ArrayList<>();
            OperateResultExOne<byte[]> readResult2 = siemensS7Net.Read("DB102.0", (short) (staCount * 2));
            List<Integer> staList = new ArrayList<>();
            staList.add(101);
            staList.add(102);
            staList.add(103);
            staList.add(1001);
            staList.add(1002);
            staList.add(1003);
            List<JSONObject> stationList = new ArrayList<>();
            OperateResultExOne<byte[]> readResult2 = siemensS7Net.Read("DB82.14", (short) 156);
            if(readResult2.IsSuccess) {
                for (int i = 0; i < staCount; i++) {
                    short val = siemensS7Net.getByteTransform().TransInt16(readResult2.Content, i * 2);
                    trayList.add((int) val);
                int i = 0;
                for (Integer siteId : staList) {
                    //读取4.0-4.7数据
                    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);
                    String barcode = siemensS7Net.getByteTransform().TransString(readResult2.Content, i * 26 + 10, 12, "UTF-8");
                    JSONObject station = new JSONObject();
                    station.put("siteId", siteId);
                    station.put("model", status1[0] ? 1 : 0);
                    station.put("busy", status1[1] ? 1 : 0);
                    station.put("hasTray", status1[2] ? 1 : 0);
                    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("barcode", barcode);
                }
            }
            //读取小车数据
            OperateResultExOne<byte[]> readResult3 = siemensS7Net.Read("DB102.50", (short) (staCount * 2));
            List<Integer> carList = new ArrayList<>();
            if(readResult3.IsSuccess) {
                for (int i = 0; i < staCount; i++) {
                    short val = siemensS7Net.getByteTransform().TransInt16(readResult3.Content, i * 2);
                    carList.add((int) val);
                }
            }
            device.put("stationList", stationList);
            device.put("trayList", trayList);
            device.put("carList", carList);
            resultData.put("commandResult1", JSON.toJSONString(readResult1.Content));
            resultData.put("commandResult2", JSON.toJSONString(readResult2.Content));
            deviceMsgType = "status";
        }
        } else if (commandObj.getInteger("mode") == 10000) {
            //写入输送线数据
        resultData.put("commandResult1", JSON.toJSONString(result));
        resultData.put("commandResult2", JSON.toJSONString(result2));
            JSONObject commandBody = commandObj.getJSONObject("commandBody");
            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();//任务号
            resultData.put("commandData", array);
            result = siemensS7Net.Write("address", array);
            if (result.IsSuccess) {
                resultData.put("result", "success");
            }
            resultData.put("commandResult1", JSON.toJSONString(result));
        }
        if (deviceMsgType.equals("command")) {
            log.info("收到Rcs Lift Command Data: {}", JSON.toJSONString(deviceCommandMsg));