From 9564b5da6e019b29b9779fcc13f9b82c9487befa Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 28 三月 2024 15:11:25 +0800
Subject: [PATCH] Merge branch 'Four-Way-Rack' of http://47.97.1.152:5880/r/zy-asrs-master into Four-Way-Rack
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/LiftProtocol.java | 27 +
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/LiftAssignCommand.java | 26 +
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/ShuttleRedisCommand.java | 4
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/LiftCommandModeType.java | 45 +++
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java | 234 ++++++++++++++++
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/LiftRedisCommand.java | 22 +
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/LiftThread.java | 14 +
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/DeviceTimer.java | 26 +
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java | 156 ++++++++++
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/LiftCommand.java | 58 ++++
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/ShuttleAssignCommand.java | 6
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java | 150 ++++++++++
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java | 41 ++
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java | 6
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/ShuttleThread.java | 12
15 files changed, 807 insertions(+), 20 deletions(-)
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java
new file mode 100644
index 0000000..53e0ad3
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java
@@ -0,0 +1,150 @@
+package com.zy.asrs.wcs.core.action;
+
+import com.alibaba.fastjson.JSON;
+import com.zy.asrs.wcs.core.model.command.*;
+import com.zy.asrs.wcs.core.model.enums.LiftCommandModeType;
+import com.zy.asrs.wcs.core.utils.RedisUtil;
+import com.zy.asrs.wcs.rcs.News;
+import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
+import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant;
+import com.zy.asrs.wcs.rcs.entity.Device;
+import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType;
+import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
+import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
+import com.zy.asrs.wcs.rcs.thread.LiftThread;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+@Component
+public class LiftAction {
+
+ @Autowired
+ private RedisUtil redisUtil;
+
+ public synchronized boolean assignWork(Device device, LiftAssignCommand assignCommand) {
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue());
+ if (liftThread == null) {
+ return false;
+ }
+
+ LiftProtocol liftProtocol = liftThread.getStatus();
+ if (liftProtocol == null) {
+ return false;
+ }
+
+ LiftRedisCommand redisCommand = new LiftRedisCommand();
+ redisCommand.setLiftNo(assignCommand.getLiftNo());//鎻愬崌鏈哄彿
+ redisCommand.setWrkNo(assignCommand.getTaskNo());//宸ヤ綔鍙�
+ redisCommand.setCommandStep(0);//鍛戒护鎵ц姝ュ簭
+ redisCommand.setAssignCommand(assignCommand);//鍛戒护
+ //浠诲姟鏁版嵁淇濆瓨鍒皉edis
+ if (redisUtil.set(DeviceRedisConstant.LIFT_WORK_FLAG + assignCommand.getTaskNo(), JSON.toJSONString(redisCommand))) {
+ liftProtocol.setTaskNo(assignCommand.getTaskNo());
+ return true;
+ }
+ return false;
+ }
+
+ public synchronized boolean executeWork(Device device, Integer taskNo) {
+ Object obj = redisUtil.get(DeviceRedisConstant.LIFT_WORK_FLAG + taskNo);
+ if (obj == null) {
+ return false;
+ }
+
+ LiftRedisCommand redisCommand = JSON.parseObject(obj.toString(), LiftRedisCommand.class);
+ if (redisCommand == null) {
+ return false;
+ }
+
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue());
+ if (liftThread == null) {
+ return false;
+ }
+
+ LiftProtocol liftProtocol = liftThread.getStatus();
+ if (liftProtocol == null) {
+ return false;
+ }
+
+ //鎻愬崌鏈哄浜庤嚜鍔ㄣ�佸氨缁�佺┖闂�
+ if (!(liftProtocol.getModel()
+ && liftProtocol.getReady()
+ && !liftProtocol.getRun())
+ ) {
+ return false;
+ }
+
+ List<LiftCommand> commands = redisCommand.getAssignCommand().getCommands();
+ if (commands.isEmpty()) {
+ return false;
+ }
+
+ LiftAssignCommand assignCommand = redisCommand.getAssignCommand();
+ int commandStep = redisCommand.getCommandStep();
+
+ if (commandStep != 0) {
+ LiftCommand command = commands.get(commandStep - 1);
+
+ //鐩墠娌℃湁鍒ゆ柇锛岀洿鎺ュ垽瀹氫笂涓�鏉℃寚浠ゅ畬鎴�
+ command.setComplete(true);
+
+ // 鏇存柊redis鏁版嵁
+ redisUtil.set(DeviceRedisConstant.LIFT_WORK_FLAG + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand));
+
+ if (!command.getComplete()) {
+ return false;
+ }
+
+
+ //鍒ゆ柇鏄惁涓烘渶鍚庝竴鏉″懡浠や笖鍛戒护鎵ц瀹屾垚锛屾姏鍑虹瓑寰呯‘璁ょ姸鎬�
+ LiftCommand endCommand = commands.get(commands.size() - 1);
+ if (endCommand.getComplete()) {
+ News.info("鎻愬崌鏈轰换鍔℃墽琛屼笅鍙戝畬鎴愮瓑寰呮墽琛岀粨鏉燂紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", liftProtocol.getLiftNo(), JSON.toJSON(commands));
+ return false;//绂佹鍐嶄笅鍙戝懡浠�
+ }
+ }
+
+ //鍙栧嚭鍛戒护
+ LiftCommand command = commands.get(commandStep);
+
+ boolean result = write(command, device);
+ if (!result) {
+ News.error("鎻愬崌鏈哄懡浠や笅鍙戝け璐ワ紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command));
+ return false;
+ } else {
+ News.info("鎻愬崌鏈哄懡浠や笅鍙戞垚鍔燂紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command));
+ }
+
+ redisUtil.del(DeviceRedisConstant.LIFT_WORK_FLAG + command.getTaskNo());
+ return true;
+ }
+
+ private synchronized boolean write(LiftCommand command, Device device) {
+ if (null == command) {
+ News.error("鎻愬崌鏈哄啓鍏ュ懡浠や负绌�");
+ return false;
+ }
+
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue());
+ if (liftThread == null) {
+ return false;
+ }
+
+ boolean result = false;
+ if (command.getMode() == LiftCommandModeType.MOVE.id) {
+ result = liftThread.move(command);
+ } else if (command.getMode() == LiftCommandModeType.PALLET_INOUT.id) {
+ result = liftThread.palletInOut(command);
+ } else if (command.getMode() == LiftCommandModeType.LOCK.id) {
+ result = liftThread.lock(command);
+ } else if (command.getMode() == LiftCommandModeType.UNLOCK.id) {
+ result = liftThread.unlock(command);
+ } else if (command.getMode() == LiftCommandModeType.RESET.id) {
+ result = liftThread.reset(command);
+ }
+ return result;
+ }
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java
index 873cb42..4a15a5d 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java
@@ -1,11 +1,14 @@
package com.zy.asrs.wcs.core.action;
import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.zy.asrs.wcs.core.entity.BasShuttle;
import com.zy.asrs.wcs.core.model.NavigateNode;
import com.zy.asrs.wcs.core.model.command.ShuttleAssignCommand;
import com.zy.asrs.wcs.core.model.command.ShuttleCommand;
import com.zy.asrs.wcs.core.model.command.ShuttleRedisCommand;
import com.zy.asrs.wcs.core.model.enums.ShuttleCommandModeType;
+import com.zy.asrs.wcs.core.service.BasShuttleService;
import com.zy.asrs.wcs.core.utils.NavigateMapUtils;
import com.zy.asrs.wcs.core.utils.RedisUtil;
import com.zy.asrs.wcs.core.utils.Utils;
@@ -29,6 +32,8 @@
private RedisUtil redisUtil;
@Autowired
private NavigateMapUtils navigateMapUtils;
+ @Autowired
+ private BasShuttleService basShuttleService;
public synchronized boolean assignWork(Device device, ShuttleAssignCommand assignCommand) {
ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
@@ -49,6 +54,11 @@
redisCommand.setAssignCommand(assignCommand);//鍛戒护
//浠诲姟鏁版嵁淇濆瓨鍒皉edis
if (redisUtil.set(DeviceRedisConstant.SHUTTLE_WORK_FLAG + assignCommand.getTaskNo(), JSON.toJSONString(redisCommand))) {
+ //涓嬪彂琛岄┒璺緞
+ boolean result = shuttleThread.movePath(assignCommand.getNodes(), assignCommand.getTaskNo().intValue());
+ if (!result) {
+ return false;
+ }
shuttleProtocol.setTaskNo(assignCommand.getTaskNo().intValue());
return true;
}
@@ -175,7 +185,38 @@
}
}
+ //鍙栧嚭鍛戒护
+ ShuttleCommand command = commands.get(commandStep);
+
+ // 涓嬪彂鍛戒护
+ if (!write(command, device)) {
+ News.error("鍥涘悜绌挎杞﹀懡浠や笅鍙戝け璐ワ紝绌挎杞﹀彿={}锛屼换鍔℃暟鎹�={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command));
+ return false;
+ }
+
return true;
}
+ private synchronized boolean write(ShuttleCommand command, Device device) {
+ if (null == command) {
+ News.error("鍥涘悜绌挎杞﹀啓鍏ュ懡浠や负绌�");
+ return false;
+ }
+ ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
+ boolean result = false;
+ if (command.getMode() == ShuttleCommandModeType.MOVE.id
+ || command.getMode() == ShuttleCommandModeType.IN_LIFT.id
+ || command.getMode() == ShuttleCommandModeType.OUT_LIFT.id) {//绉诲姩
+ result = shuttleThread.move(command);
+ } else if (command.getMode() == ShuttleCommandModeType.PALLET_LIFT.id
+ || command.getMode() == ShuttleCommandModeType.PALLET_DOWN.id) {//椤跺崌
+ result = shuttleThread.lift(command);
+ } else if (command.getMode() == ShuttleCommandModeType.CHARGE.id) {//鍏呯數
+ result = shuttleThread.charge(command);
+ } else if (command.getMode() == ShuttleCommandModeType.RESET.id) {//澶嶄綅
+ result = shuttleThread.reset(command);
+ }
+ return result;
+ }
+
}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java
index 4851e47..13407ef 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java
@@ -76,8 +76,8 @@
}
ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
- assignCommand.setShuttleNo(deviceNo.shortValue());
- assignCommand.setTaskNo(motion.getWrkNo().shortValue());
+ assignCommand.setShuttleNo(deviceNo);
+ assignCommand.setTaskNo(motion.getWrkNo());
assignCommand.setSourceLocNo(motion.getOrigin());
assignCommand.setLocNo(motion.getTarget());
@@ -363,7 +363,7 @@
}
assert null != shuttleTaskModeType;
- assignCommand.setTaskMode(shuttleTaskModeType.id.shortValue());//鍏ュ嚭搴撴ā寮�
+ assignCommand.setTaskMode(shuttleTaskModeType.id);//鍏ュ嚭搴撴ā寮�
assignCommand.setCommands(shuttleCommands);
if (motion.getOrigin() != null && motion.getTarget() != null) {
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/LiftAssignCommand.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/LiftAssignCommand.java
new file mode 100644
index 0000000..ab1a1d9
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/LiftAssignCommand.java
@@ -0,0 +1,26 @@
+package com.zy.asrs.wcs.core.model.command;
+
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Data
+public class LiftAssignCommand {
+
+ /**
+ * 鎻愬崌鏈哄彿
+ */
+ private Integer liftNo = 0;
+
+ /**
+ * 浠诲姟鍙�
+ */
+ private Integer taskNo = 0;
+
+ /**
+ * 鍛戒护list
+ */
+ private List<LiftCommand> commands = new ArrayList<>();
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/LiftCommand.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/LiftCommand.java
new file mode 100644
index 0000000..eb53a42
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/LiftCommand.java
@@ -0,0 +1,58 @@
+package com.zy.asrs.wcs.core.model.command;
+
+import com.zy.asrs.wcs.core.model.enums.LiftCommandModeType;
+import lombok.Data;
+
+
+/**
+ * 鎻愬崌鏈哄懡浠ゆ姤鏂�
+ */
+@Data
+public class LiftCommand {
+
+ /**
+ * 鎻愬崌鏈虹紪鍙�
+ */
+ private Integer liftNo;
+
+ /**
+ * 浠诲姟鏍囪瘑鍙�
+ */
+ private Integer taskNo;
+
+ /**
+ * 鍛戒护绫诲瀷
+ */
+ private Integer mode = LiftCommandModeType.NONE.id;
+
+ /**
+ * 婧愬眰
+ */
+ private Integer originLev;
+
+ /**
+ * 鐩爣灞�
+ */
+ private Integer targetLev;
+
+ /**
+ * 婧愮珯
+ */
+ private Integer originSta;
+
+ /**
+ * 鐩爣绔�
+ */
+ private Integer targetSta;
+
+ /**
+ * 鎶ユ枃鍐呭
+ */
+ private String body;
+
+ /**
+ * 鍛戒护鏄惁瀹屾垚,榛樿false鏈畬鎴�
+ */
+ private Boolean complete = false;
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/LiftRedisCommand.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/LiftRedisCommand.java
new file mode 100644
index 0000000..7470038
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/LiftRedisCommand.java
@@ -0,0 +1,22 @@
+package com.zy.asrs.wcs.core.model.command;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class LiftRedisCommand implements Serializable {
+
+ //鎻愬崌鏈哄彿
+ private Integer liftNo;
+
+ //宸ヤ綔鍙�
+ private Integer wrkNo;
+
+ //鍛戒护鎵ц姝ュ簭
+ private Integer commandStep;
+
+ //鍛戒护
+ private LiftAssignCommand assignCommand;
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/ShuttleAssignCommand.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/ShuttleAssignCommand.java
index 0b00083..76616ea 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/ShuttleAssignCommand.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/ShuttleAssignCommand.java
@@ -12,12 +12,12 @@
/**
* 鍥涘悜绌挎杞﹀彿
*/
- private Short shuttleNo = 0;
+ private Integer shuttleNo = 0;
/**
* 浠诲姟鍙�
*/
- private Short taskNo = 0;
+ private Integer taskNo = 0;
/**
* 浣滀笟绫诲瀷
@@ -31,7 +31,7 @@
* 8锛� 鍚庣Щ
* 9: 鍏呯數
*/
- private Short taskMode = 0;
+ private Integer taskMode = 0;
/**
* 婧愬簱浣�
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/ShuttleRedisCommand.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/ShuttleRedisCommand.java
index 9e6455c..4cfac1a 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/ShuttleRedisCommand.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/ShuttleRedisCommand.java
@@ -11,10 +11,10 @@
public class ShuttleRedisCommand implements Serializable {
//鍥涘悜绌挎杞﹀彿
- private Short shuttleNo;
+ private Integer shuttleNo;
//宸ヤ綔鍙�
- private Short wrkNo;
+ private Integer wrkNo;
//鍛戒护鎵ц姝ュ簭
private Integer commandStep;
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/LiftCommandModeType.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/LiftCommandModeType.java
new file mode 100644
index 0000000..b928589
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/LiftCommandModeType.java
@@ -0,0 +1,45 @@
+package com.zy.asrs.wcs.core.model.enums;
+
+public enum LiftCommandModeType {
+
+ NONE(-1, "鏈煡绫诲瀷"),
+ MOVE(1, "鎻愬崌鏈哄崌闄�"),
+ PALLET_INOUT(2, "鎵樼洏鍑哄叆"),
+ LOCK(3, "閿佸畾鎻愬崌鏈�"),
+ UNLOCK(4, "瑙i攣鎻愬崌鏈�"),
+ RESET(5, "澶嶄綅"),
+ ;
+
+ public Integer id;
+ public String desc;
+
+ LiftCommandModeType(Integer id, String desc) {
+ this.id = id;
+ this.desc = desc;
+ }
+
+ public static LiftCommandModeType get(Integer id) {
+ if (null == id) {
+ return null;
+ }
+ for (LiftCommandModeType type : LiftCommandModeType.values()) {
+ if (type.id.equals(id)) {
+ return type;
+ }
+ }
+ return null;
+ }
+
+ public static LiftCommandModeType get(LiftCommandModeType type) {
+ if (null == type) {
+ return null;
+ }
+ for (LiftCommandModeType type1 : LiftCommandModeType.values()) {
+ if (type1 == type) {
+ return type1;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/DeviceTimer.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/DeviceTimer.java
index 04df88d..6446488 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/DeviceTimer.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/DeviceTimer.java
@@ -1,6 +1,7 @@
package com.zy.asrs.wcs.core.timer;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zy.asrs.wcs.core.action.LiftAction;
import com.zy.asrs.wcs.core.action.ShuttleAction;
import com.zy.asrs.wcs.core.utils.RedisUtil;
import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant;
@@ -28,6 +29,8 @@
private DeviceTypeService deviceTypeService;
@Autowired
private ShuttleAction shuttleAction;
+ @Autowired
+ private LiftAction liftAction;
@Scheduled(cron = "0/1 * * * * ? ")
public synchronized void executeShuttle() {
@@ -50,14 +53,35 @@
Integer taskNo = Integer.valueOf(String.valueOf(object));
if (taskNo != 0) {
//瀛樺湪浠诲姟闇�瑕佹墽琛�
- shuttleAction.executeWork(device, taskNo);
+ boolean result = shuttleAction.executeWork(device, taskNo);
}
}
}
@Scheduled(cron = "0/1 * * * * ? ")
public synchronized void executeLift() {
+ DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>()
+ .eq(DeviceType::getFlag, String.valueOf(SlaveType.Lift))
+ .eq(DeviceType::getStatus, 1));
+ if (deviceType == null) {
+ return;
+ }
+ List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>()
+ .eq(Device::getStatus, 1)
+ .eq(Device::getDeviceType, deviceType.getId()));
+ for (Device device : list) {
+ Object object = redisUtil.get(DeviceRedisConstant.LIFT_FLAG + device.getDeviceNo());
+ if (object == null) {
+ continue;
+ }
+
+ Integer taskNo = Integer.valueOf(String.valueOf(object));
+ if (taskNo != 0) {
+ //瀛樺湪浠诲姟闇�瑕佹墽琛�
+ boolean result = liftAction.executeWork(device, taskNo);
+ }
+ }
}
@Scheduled(cron = "0/1 * * * * ? ")
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/LiftProtocol.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/LiftProtocol.java
index 7ea5a7f..920f2ff 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/LiftProtocol.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/LiftProtocol.java
@@ -1,5 +1,9 @@
package com.zy.asrs.wcs.rcs.model.protocol;
+import com.zy.asrs.framework.common.Cools;
+import com.zy.asrs.framework.common.SpringUtils;
+import com.zy.asrs.wcs.core.utils.RedisUtil;
+import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant;
import com.zy.asrs.wcs.rcs.entity.Device;
import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType;
import lombok.Data;
@@ -13,12 +17,12 @@
/**
* 鎻愬崌鏈哄彿
*/
- private String liftNo;
+ private Integer liftNo;
/**
* 浠诲姟鍙�
*/
- private String taskNo;
+ private Integer taskNo;
/**
* 鍥涘悜绌挎杞﹀彿
@@ -146,4 +150,23 @@
this.protocolStatusType = status;
}
+ public void setTaskNo(Integer taskNo) {
+ RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
+ if (null != redisUtil) {
+ redisUtil.set(DeviceRedisConstant.LIFT_FLAG + this.liftNo, taskNo);
+ this.taskNo = taskNo;
+ }
+ }
+
+ public Integer getTaskNo() {
+ RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
+ if (null != redisUtil) {
+ Object o = redisUtil.get(DeviceRedisConstant.LIFT_FLAG + this.liftNo);
+ if (!Cools.isEmpty(o)) {
+ this.taskNo = Integer.valueOf(String.valueOf(o));
+ }
+ }
+ return this.taskNo == null ? 0 : this.taskNo;
+ }
+
}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/LiftThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/LiftThread.java
index 55ef4c4..4822620 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/LiftThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/LiftThread.java
@@ -1,9 +1,23 @@
package com.zy.asrs.wcs.rcs.thread;
+import com.zy.asrs.wcs.core.model.command.LiftCommand;
+import com.zy.asrs.wcs.rcs.entity.Device;
import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
public interface LiftThread extends ThreadHandler{
LiftProtocol getStatus();//鑾峰彇鎻愬崌鏈虹姸鎬�
+ Device getDevice();//鑾峰彇璁惧淇℃伅
+
+ boolean move(LiftCommand command);//鍗囬檷绉诲姩
+
+ boolean palletInOut(LiftCommand command);//鎵樼洏鍑哄叆
+
+ boolean lock(LiftCommand command);//閿佸畾鎻愬崌鏈�
+
+ boolean unlock(LiftCommand command);//瑙i攣鎻愬崌鏈�
+
+ boolean reset(LiftCommand command);//澶嶄綅
+
}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/ShuttleThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/ShuttleThread.java
index 4488848..d703810 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/ShuttleThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/ShuttleThread.java
@@ -1,8 +1,11 @@
package com.zy.asrs.wcs.rcs.thread;
+import com.zy.asrs.wcs.core.model.NavigateNode;
import com.zy.asrs.wcs.core.model.command.ShuttleCommand;
import com.zy.asrs.wcs.rcs.entity.Device;
import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol;
+
+import java.util.List;
public interface ShuttleThread extends ThreadHandler{
@@ -10,12 +13,15 @@
Device getDevice();//鑾峰彇璁惧淇℃伅
- boolean movePath();//璺緞涓嬪彂
+ boolean movePath(List<NavigateNode> nodes, Integer taskNo);//璺緞涓嬪彂
- boolean move();//绉诲姩
+ boolean move(ShuttleCommand command);//绉诲姩
- boolean lift();//椤跺崌
+ boolean lift(ShuttleCommand command);//椤跺崌
+ boolean charge(ShuttleCommand command);//鍏呯數寮�鍏�
+
+ boolean reset(ShuttleCommand command);//澶嶄綅寮�鍏�
//***************鑾峰彇鍛戒护*****************
ShuttleCommand getMoveCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed);
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java
index 79077ae..b44bc38 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java
@@ -2,9 +2,17 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.common.utils.HttpHandler;
import com.zy.asrs.framework.common.DateUtils;
+import com.zy.asrs.framework.common.SpringUtils;
import com.zy.asrs.framework.exception.CoolException;
+import com.zy.asrs.wcs.core.entity.Loc;
+import com.zy.asrs.wcs.core.model.command.LiftCommand;
+import com.zy.asrs.wcs.core.model.command.ShuttleCommand;
+import com.zy.asrs.wcs.core.model.enums.LiftCommandModeType;
+import com.zy.asrs.wcs.core.model.enums.ShuttleCommandModeType;
+import com.zy.asrs.wcs.core.service.LocService;
import com.zy.asrs.wcs.rcs.News;
import com.zy.asrs.wcs.rcs.cache.OutputQueue;
import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType;
@@ -76,7 +84,7 @@
if (data != null) {
if (null == liftProtocol) {
liftProtocol = new LiftProtocol();
- liftProtocol.setLiftNo(device.getDeviceNo());
+ liftProtocol.setLiftNo(Integer.valueOf(device.getDeviceNo()));
liftProtocol.setProtocolStatus(LiftProtocolStatusType.IDLE);
liftProtocol.setDevice(device);
}
@@ -146,6 +154,132 @@
return this.liftProtocol;
}
+ @Override
+ public Device getDevice() {
+ return this.device;
+ }
+
+ @Override
+ public synchronized boolean move(LiftCommand command) {
+ try {
+ String loginToken = requestLoginToken();
+ if (loginToken == null) {
+ return false;
+ }
+
+ HashMap<String, Object> headers = new HashMap<>();
+ headers.put("Authorization", "Bearer " + loginToken);
+
+ String response = new HttpHandler.Builder()
+ .setUri(API_URL)
+ .setPath("/RDS/lifterTask")
+ .setHeaders(headers)
+ .setJson(command.getBody())
+ .build()
+ .doPost();
+ JSONObject jsonObject = JSON.parseObject(response);
+ Integer code = jsonObject.getInteger("code");
+ if (code.equals(200)) {
+ return true;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ @Override
+ public synchronized boolean palletInOut(LiftCommand command) {
+ try {
+ String loginToken = requestLoginToken();
+ if (loginToken == null) {
+ return false;
+ }
+
+ HashMap<String, Object> headers = new HashMap<>();
+ headers.put("Authorization", "Bearer " + loginToken);
+
+ String response = new HttpHandler.Builder()
+ .setUri(API_URL)
+ .setPath("/RDS/lifterTask")
+ .setHeaders(headers)
+ .setJson(command.getBody())
+ .build()
+ .doPost();
+ JSONObject jsonObject = JSON.parseObject(response);
+ Integer code = jsonObject.getInteger("code");
+ if (code.equals(200)) {
+ return true;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ @Override
+ public synchronized boolean lock(LiftCommand command) {
+ try {
+ String loginToken = requestLoginToken();
+ if (loginToken == null) {
+ return false;
+ }
+
+ HashMap<String, Object> headers = new HashMap<>();
+ headers.put("Authorization", "Bearer " + loginToken);
+
+ String response = new HttpHandler.Builder()
+ .setUri(API_URL)
+ .setPath("/RDS/lifterOperation")
+ .setHeaders(headers)
+ .setJson(command.getBody())
+ .build()
+ .doPost();
+ JSONObject jsonObject = JSON.parseObject(response);
+ Integer code = jsonObject.getInteger("code");
+ if (code.equals(200)) {
+ return true;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ @Override
+ public synchronized boolean unlock(LiftCommand command) {
+ try {
+ String loginToken = requestLoginToken();
+ if (loginToken == null) {
+ return false;
+ }
+
+ HashMap<String, Object> headers = new HashMap<>();
+ headers.put("Authorization", "Bearer " + loginToken);
+
+ String response = new HttpHandler.Builder()
+ .setUri(API_URL)
+ .setPath("/RDS/lifterOperation")
+ .setHeaders(headers)
+ .setJson(command.getBody())
+ .build()
+ .doPost();
+ JSONObject jsonObject = JSON.parseObject(response);
+ Integer code = jsonObject.getInteger("code");
+ if (code.equals(200)) {
+ return true;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ @Override
+ public synchronized boolean reset(LiftCommand command) {
+ return false;
+ }
+
//***************璁惧灞傞�氳-涓嶅悓鍘傚晢璁惧閫氳鏂规涓嶄竴鑷�***************
//璇锋眰鐧诲綍
@@ -207,4 +341,102 @@
// }
// return null;
}
+
+ //绌鸿浇绉诲姩
+ public LiftCommand getEmptyMoveCommand(Integer taskNo, Integer targetLev) {
+ HashMap<String, Object> body = new HashMap<>();
+ body.put("messageName", "lifterTask");
+ body.put("msgTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+ body.put("deviceNo", Integer.parseInt(this.device.getDeviceNo()));
+ body.put("taskId", taskNo);
+ body.put("startLayer", 0);
+ body.put("endLayer", targetLev);
+ body.put("model", 3);//绌鸿浇绉诲姩
+
+ LiftCommand command = new LiftCommand();
+ command.setLiftNo(Integer.valueOf(this.device.getDeviceNo()));
+ command.setBody(JSON.toJSONString(body));
+ command.setMode(LiftCommandModeType.MOVE.id);
+ command.setOriginLev(0);
+ command.setTargetLev(targetLev);
+ return command;
+ }
+
+ //杞借溅绉诲姩
+ public LiftCommand getMoveWithShuttleCommand(Integer taskNo, Integer originLev, Integer targetLev) {
+ HashMap<String, Object> body = new HashMap<>();
+ body.put("messageName", "lifterTask");
+ body.put("msgTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+ body.put("deviceNo", Integer.parseInt(this.device.getDeviceNo()));
+ body.put("taskId", taskNo);
+ body.put("startLayer", originLev);
+ body.put("endLayer", targetLev);
+ body.put("model", 2);//杞借溅绉诲姩
+
+ LiftCommand command = new LiftCommand();
+ command.setLiftNo(Integer.valueOf(this.device.getDeviceNo()));
+ command.setBody(JSON.toJSONString(body));
+ command.setMode(LiftCommandModeType.MOVE.id);
+ command.setOriginLev(originLev);
+ command.setTargetLev(targetLev);
+ return command;
+ }
+
+ //鎵樼洏鍑哄叆
+ public LiftCommand getPalletInOutCommand(Integer taskNo, Integer originLev, Integer targetLev, Integer originSta, Integer targetSta) {
+ HashMap<String, Object> body = new HashMap<>();
+ body.put("messageName", "lifterTask");
+ body.put("msgTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+ body.put("deviceNo", Integer.parseInt(this.device.getDeviceNo()));
+ body.put("taskId", taskNo);
+ body.put("startLayer", originLev);
+ body.put("endLayer", targetLev);
+ body.put("startLocation", originSta);
+ body.put("endLocation", targetSta);
+ body.put("model", 1);//鎵樼洏鍑哄叆
+
+ LiftCommand command = new LiftCommand();
+ command.setLiftNo(Integer.valueOf(this.device.getDeviceNo()));
+ command.setBody(JSON.toJSONString(body));
+ command.setMode(LiftCommandModeType.PALLET_INOUT.id);
+ command.setOriginLev(originLev);
+ command.setTargetLev(targetLev);
+ command.setOriginSta(originSta);
+ command.setTargetSta(targetSta);
+ return command;
+ }
+
+ //閿佸畾/瑙i攣鎻愬崌鏈�
+ public LiftCommand getLockCommand(Integer taskNo, Boolean lock) {
+ HashMap<String, Object> body = new HashMap<>();
+ body.put("messageName", "lifterOperation");
+ body.put("msgTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+ body.put("deviceNo", Integer.parseInt(this.device.getDeviceNo()));
+ body.put("taskId", taskNo);
+ body.put("operation", lock ? 6 : 7);
+ body.put("remark", taskNo);
+
+ LiftCommand command = new LiftCommand();
+ command.setLiftNo(Integer.valueOf(this.device.getDeviceNo()));
+ command.setBody(JSON.toJSONString(body));
+ command.setMode(lock ? LiftCommandModeType.LOCK.id : LiftCommandModeType.UNLOCK.id);
+ return command;
+ }
+
+ //灏忚溅宸插埌浣�/宸查┒绂讳俊鍙�
+ public LiftCommand getShuttleSignalCommand(Integer taskNo, Boolean signal) {
+ HashMap<String, Object> body = new HashMap<>();
+ body.put("messageName", "lifterOperation");
+ body.put("msgTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+ body.put("deviceNo", Integer.parseInt(this.device.getDeviceNo()));
+ body.put("taskId", taskNo);
+ body.put("operation", signal ? 4 : 5);
+
+ LiftCommand command = new LiftCommand();
+ command.setLiftNo(Integer.valueOf(this.device.getDeviceNo()));
+ command.setBody(JSON.toJSONString(body));
+ command.setMode(signal ? LiftCommandModeType.LOCK.id : LiftCommandModeType.UNLOCK.id);
+ return command;
+ }
+
}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java
index 0fb820e..6f679c5 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java
@@ -8,9 +8,12 @@
import com.zy.asrs.framework.common.SpringUtils;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wcs.core.entity.Loc;
+import com.zy.asrs.wcs.core.model.NavigateNode;
import com.zy.asrs.wcs.core.model.command.ShuttleCommand;
import com.zy.asrs.wcs.core.model.enums.ShuttleCommandModeType;
+import com.zy.asrs.wcs.core.model.enums.ShuttleRunDirection;
import com.zy.asrs.wcs.core.service.LocService;
+import com.zy.asrs.wcs.core.utils.NavigateUtils;
import com.zy.asrs.wcs.rcs.News;
import com.zy.asrs.wcs.rcs.cache.OutputQueue;
import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType;
@@ -22,8 +25,7 @@
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
+import java.util.*;
@Slf4j
@SuppressWarnings("all")
@@ -164,17 +166,161 @@
}
@Override
- public synchronized boolean movePath() {
+ public synchronized boolean movePath(List<NavigateNode> nodes, Integer taskNo) {
+ try {
+ String loginToken = requestLoginToken();
+ if (loginToken == null) {
+ return false;
+ }
+
+ HashMap<String, Object> headers = new HashMap<>();
+ headers.put("Authorization", "Bearer " + loginToken);
+
+ ArrayList<HashMap<String, Object>> modes = new ArrayList<>();
+ //鑾峰彇鍒嗘璺緞
+ ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(nodes);
+ for (ArrayList<NavigateNode> sectionNodes : data) {
+ boolean flag = true;
+ int oper;
+ //寮�濮嬭矾寰�
+ NavigateNode startPath = nodes.get(0);
+ if (ShuttleRunDirection.get(startPath.getDirection()) == ShuttleRunDirection.LEFT
+ || ShuttleRunDirection.get(startPath.getDirection()) == ShuttleRunDirection.RIGHT) {
+ //姣嶈建鏂瑰悜
+ oper = 5;
+ }else {
+ //瀛愯建鏂瑰悜
+ oper = 6;
+ }
+
+ for (NavigateNode node : sectionNodes) {
+ HashMap<String, Object> map = new HashMap<>();
+ map.put("nodexX", node.getX());
+ map.put("nodexY", node.getY());
+ map.put("nodexZ", node.getZ());
+ if (flag) {
+ map.put("oper", oper);
+ flag = false;
+ }
+ modes.add(map);
+ }
+ }
+
+
+ HashMap<String, Object> param = new HashMap<>();
+ param.put("messageName", "runRoute");
+ param.put("msgTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+ param.put("deviceNo", device.getDeviceNo());
+ param.put("taskId", taskNo);
+ param.put("nodeNum", nodes.size());
+ param.put("modes", modes);
+ String response = new HttpHandler.Builder()
+ .setUri(API_URL)
+ .setPath("/RDS/runRoute")
+ .setHeaders(headers)
+ .setJson(JSON.toJSONString(param))
+ .build()
+ .doPost();
+ JSONObject jsonObject = JSON.parseObject(response);
+ Integer code = jsonObject.getInteger("code");
+ if (code.equals(200)) {
+ return true;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
return false;
}
@Override
- public synchronized boolean move() {
+ public synchronized boolean move(ShuttleCommand command) {
+ try {
+ String loginToken = requestLoginToken();
+ if (loginToken == null) {
+ return false;
+ }
+
+ HashMap<String, Object> headers = new HashMap<>();
+ headers.put("Authorization", "Bearer " + loginToken);
+
+ String response = new HttpHandler.Builder()
+ .setUri(API_URL)
+ .setPath("/RDS/runOrder")
+ .setHeaders(headers)
+ .setJson(command.getBody())
+ .build()
+ .doPost();
+ JSONObject jsonObject = JSON.parseObject(response);
+ Integer code = jsonObject.getInteger("code");
+ if (code.equals(200)) {
+ return true;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
return false;
}
@Override
- public synchronized boolean lift() {
+ public synchronized boolean lift(ShuttleCommand command) {
+ try {
+ String loginToken = requestLoginToken();
+ if (loginToken == null) {
+ return false;
+ }
+
+ HashMap<String, Object> headers = new HashMap<>();
+ headers.put("Authorization", "Bearer " + loginToken);
+
+ String response = new HttpHandler.Builder()
+ .setUri(API_URL)
+ .setPath("/RDS/actionOrder")
+ .setHeaders(headers)
+ .setJson(command.getBody())
+ .build()
+ .doPost();
+ JSONObject jsonObject = JSON.parseObject(response);
+ Integer code = jsonObject.getInteger("code");
+ if (code.equals(200)) {
+ return true;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ @Override
+ public synchronized boolean charge(ShuttleCommand command) {
+ try {
+ String loginToken = requestLoginToken();
+ if (loginToken == null) {
+ return false;
+ }
+
+ HashMap<String, Object> headers = new HashMap<>();
+ headers.put("Authorization", "Bearer " + loginToken);
+
+ String response = new HttpHandler.Builder()
+ .setUri(API_URL)
+ .setPath("/RDS/actionOrder")
+ .setHeaders(headers)
+ .setJson(command.getBody())
+ .build()
+ .doPost();
+ JSONObject jsonObject = JSON.parseObject(response);
+ Integer code = jsonObject.getInteger("code");
+ if (code.equals(200)) {
+ return true;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ @Override
+ public synchronized boolean reset(ShuttleCommand command) {
return false;
}
--
Gitblit v1.9.1