From 14a6067ac871ed3c0d73ee1d1939db7a7aefe13a Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期五, 10 五月 2024 08:43:28 +0800
Subject: [PATCH] #
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyShuttleThread.java | 62 ++++++++++++++++++++++++++++---
1 files changed, 56 insertions(+), 6 deletions(-)
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyShuttleThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyShuttleThread.java
index 1233ccd..4e4122d 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyShuttleThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyShuttleThread.java
@@ -9,6 +9,7 @@
import com.zy.asrs.framework.common.SpringUtils;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wcs.common.ExecuteSupport;
+import com.zy.asrs.wcs.core.domain.param.ShuttleMoveLocParam;
import com.zy.asrs.wcs.core.entity.BasShuttle;
import com.zy.asrs.wcs.core.entity.Loc;
import com.zy.asrs.wcs.core.model.MapNode;
@@ -190,7 +191,10 @@
NyShuttleHttpCommand readStatusCommand = getReadStatusCommand(Integer.parseInt(device.getDeviceNo()));
JSONObject data = requestCommand(readStatusCommand);
if (data == null) {
-// shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.OFFLINE);
+ if (System.currentTimeMillis() - shuttleProtocol.getLastOnlineTime() > 1000 * 60) {
+ //鏈�鍚庝竴娆′笂绾挎椂闂磋秴杩�60s锛岃瀹氱绾�
+ shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.OFFLINE);
+ }
OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆戝洓鍚戠┛姊溅Socket鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), device.getId(), device.getIp(), device.getPort()));
}else {
@@ -340,10 +344,15 @@
@Override
public ShuttleProtocol getStatus() {
+ return getStatus(true);
+ }
+
+ @Override
+ public ShuttleProtocol getStatus(boolean clone) {
if (this.shuttleProtocol == null) {
return null;
}
- return this.shuttleProtocol.clone();
+ return clone ? this.shuttleProtocol.clone() : this.shuttleProtocol;
}
@Override
@@ -361,11 +370,39 @@
try {
//鍙戝嚭璇锋眰
NyShuttleHttpCommand httpCommand = JSON.parseObject(command.getBody(), NyShuttleHttpCommand.class);
- JSONObject result = requestCommand(httpCommand);
- if (result == null) {
- return false;//璇锋眰澶辫触
+ Map<String, Object> body = httpCommand.getRequest().getBody();
+ Object pathObj = body.get("path");
+ List<JSONObject> path = JSON.parseArray(JSON.toJSONString(pathObj), JSONObject.class);
+ ArrayList<NyShuttleHttpCommand> commandList = new ArrayList<>();
+ while (!path.isEmpty()) {
+ ArrayList<Map<String, Object>> list = new ArrayList<>();
+ if (path.size() > 10) {
+ List<JSONObject> subList = path.subList(0, 10);
+ list.addAll(subList);
+ subList.clear();
+ }else {
+ list.addAll(path);
+ path.clear();
+ }
+
+ NyShuttleHttpCommand httpCommandCopy = JSON.parseObject(JSON.toJSONString(httpCommand), NyShuttleHttpCommand.class);
+ JSONObject bodyCopy = JSON.parseObject(JSON.toJSONString(body));
+
+ NyShuttleHttpCommand.NyRequest request = httpCommandCopy.getRequest();
+ bodyCopy.put("path", list);
+ request.setBody(bodyCopy);
+ httpCommandCopy.setRequest(request);
+
+ commandList.add(httpCommandCopy);//add copy
}
- this.shuttleProtocol.setSendTime(System.currentTimeMillis());//鎸囦护涓嬪彂鏃堕棿
+
+ for (NyShuttleHttpCommand requestCommand : commandList) {
+ JSONObject result = requestCommand(requestCommand);
+ if (result == null) {
+ return false;//璇锋眰澶辫触
+ }
+ this.shuttleProtocol.setSendTime(System.currentTimeMillis());//鎸囦护涓嬪彂鏃堕棿
+ }
return true;
} catch (IOException e) {
return false;
@@ -621,6 +658,19 @@
}
@Override
+ public boolean enableMoveLoc(ShuttleMoveLocParam param) {
+ shuttleProtocol.setMoveLoc(true);//寮�鍚窇搴�
+ shuttleProtocol.setMoveType(param.getMoveType());
+ shuttleProtocol.setXStart(param.getStartX());
+ shuttleProtocol.setXTarget(param.getTargetX());
+ shuttleProtocol.setXCurrent(param.getStartX());
+ shuttleProtocol.setYStart(param.getStartY());
+ shuttleProtocol.setYTarget(param.getTargetY());
+ shuttleProtocol.setYCurrent(param.getStartY());
+ return true;
+ }
+
+ @Override
public ShuttleCommand getMoveCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes) {
NavigateMapData navigateMapData = SpringUtils.getBean(NavigateMapData.class);
NyShuttleHttpCommand httpStandard = getHttpStandard(Integer.parseInt(device.getDeviceNo()), taskNo);
--
Gitblit v1.9.1