#
qlsxk
2025-09-27 6c8d62614b055111f20435d47319a69859a9f749
src/main/java/com/zy/core/thread/impl/NyLiftThread.java
@@ -106,107 +106,78 @@
        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] = commandObj.getShort("taskNO");//任务号
            array[1] = commandObj.getShort("mode");//任务模式
            array[2] = commandObj.getShort("pick");//取货数据
            array[3] = commandObj.getShort("put");//放货数据
            array[0] = 1;//任务类型
            array[1] = commandObj.getShort("pick");//源站
            array[2] = commandObj.getShort("put");//目标站
            array[3] = commandObj.getShort("taskNo");//任务号
            resultData.put("commandData", array);
            result = siemensS7Net.Write("DB103.0", array);
            OperateResult result = siemensS7Net.Write("DB83.0", array);
            if (result.IsSuccess) {
                result2 = siemensS7Net.Write("DB103.8", (short) 1);
                if (result2.IsSuccess) {
                    resultData.put("result", "success");
                }
                resultData.put("result", "success");
            }
            resultData.put("commandResult1", JSON.toJSONString(result));
            resultData.put("commandResult2", JSON.toJSONString(result2));
        } else if (commandObj.getInteger("mode") == 4) {
        } else if (commandObj.getInteger("mode") == 2) {
            //小车换层
            short[] array = new short[4];
            array[0] = commandObj.getShort("taskNO");//任务号
            array[1] = commandObj.getShort("mode");//任务模式
            array[2] = commandObj.getShort("pick");//取货数据
            array[3] = commandObj.getShort("put");//放货数据
            array[0] = 2;//任务类型
            array[1] = commandObj.getShort("pick");//源站
            array[2] = commandObj.getShort("put");//目标站
            array[3] = commandObj.getShort("taskNo");//任务号
            resultData.put("commandData", array);
            result = siemensS7Net.Write("DB103.0", array);
            OperateResult result = siemensS7Net.Write("DB83.0", array);
            if (result.IsSuccess) {
                result2 = siemensS7Net.Write("DB103.8", (short) 1);
                if (result2.IsSuccess) {
                    resultData.put("result", "success");
                }
                resultData.put("result", "success");
            }
            resultData.put("commandResult1", JSON.toJSONString(result));
            resultData.put("commandResult2", JSON.toJSONString(result2));
        } else if (commandObj.getInteger("mode") == 5) {
        } else if (commandObj.getInteger("mode") == 3) {
            //提升机移动
            short[] array = new short[4];
            array[0] = commandObj.getShort("taskNO");//任务号
            array[1] = commandObj.getShort("mode");//任务模式
            array[2] = commandObj.getShort("pick");//取货数据
            array[3] = commandObj.getShort("put");//放货数据
            array[0] = 2;//任务类型
            array[1] = commandObj.getShort("pick");//源站
            array[2] = commandObj.getShort("put");//目标站
            array[3] = commandObj.getShort("taskNo");//任务号
            resultData.put("commandData", array);
            result = siemensS7Net.Write("DB103.0", array);
            OperateResult result = siemensS7Net.Write("DB83.0", array);
            if (result.IsSuccess) {
                result2 = siemensS7Net.Write("DB103.8", (short) 1);
                if (result2.IsSuccess) {
                    resultData.put("result", "success");
                }
                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];
            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();
@@ -222,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);
                //取货数据
@@ -256,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);
            }
@@ -275,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();
@@ -285,29 +258,32 @@
                    station.put("model", status1[0] ? 1 : 0);
                    station.put("busy", status1[1] ? 1 : 0);
                    station.put("hasTray", status1[2] ? 1 : 0);
                    station.put("inMode", status1[3] ? 1 : 0);
                    station.put("outMode", status1[4] ? 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("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) {
            //写入输送线数据
            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");
            Integer siteId = commandObj.getInteger("siteId");
            Integer staNo = commandObj.getInteger("staNo");
            Integer taskNo = commandObj.getInteger("taskNo");
            String address = commandObj.getString("address");
            short[] array = new short[2];
            array[0] = staNo.shortValue();//目标站
@@ -315,12 +291,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")) {
@@ -329,7 +303,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);