From 2b6156951c18ea9ff60ed5578db633cebbe99fa7 Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期四, 25 九月 2025 10:46:16 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/impl/NyLiftThread.java | 114 +++++++++++++++++++++-----------------------------------
1 files changed, 43 insertions(+), 71 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 9221ceb..e97c073 100644
--- a/src/main/java/com/zy/core/thread/impl/NyLiftThread.java
+++ b/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();
@@ -288,26 +261,27 @@
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 +289,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 +301,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