From f46e6a76cee1e4f231fab74981a87947bf84677d Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期二, 15 十月 2024 11:02:47 +0800
Subject: [PATCH] #
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java | 155 +++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 141 insertions(+), 14 deletions(-)
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 9d49fb4..5390f51 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
@@ -7,27 +7,20 @@
import com.zy.asrs.wcs.common.ExecuteSupport;
import com.zy.asrs.wcs.core.action.LiftAction;
import com.zy.asrs.wcs.core.action.ShuttleAction;
-import com.zy.asrs.wcs.core.entity.BasShuttle;
-import com.zy.asrs.wcs.core.entity.Loc;
+import com.zy.asrs.wcs.core.entity.*;
import com.zy.asrs.wcs.core.model.NavigateNode;
-import com.zy.asrs.wcs.core.model.command.LiftAssignCommand;
-import com.zy.asrs.wcs.core.model.command.LiftCommand;
-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.*;
import com.zy.asrs.wcs.core.model.enums.*;
-import com.zy.asrs.wcs.core.service.BasShuttleService;
-import com.zy.asrs.wcs.core.service.LocService;
-import com.zy.asrs.wcs.core.service.TaskService;
+import com.zy.asrs.wcs.core.service.*;
import com.zy.asrs.wcs.core.utils.*;
import com.zy.asrs.wcs.rcs.News;
import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
-import com.zy.asrs.wcs.core.entity.Motion;
-import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant;
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.model.protocol.ShuttleProtocol;
-import com.zy.asrs.wcs.core.service.MotionService;
+import com.zy.asrs.wcs.rcs.model.protocol.StaProtocol;
+import com.zy.asrs.wcs.rcs.thread.DevpThread;
import com.zy.asrs.wcs.rcs.thread.LiftThread;
import com.zy.asrs.wcs.rcs.thread.ShuttleThread;
import lombok.extern.slf4j.Slf4j;
@@ -63,6 +56,10 @@
private LiftAction liftAction;
@Autowired
private LiftDispatcher liftDispatcher;
+ @Autowired
+ private BasConveyorService basConveyorService;
+ @Autowired
+ private BasConveyorStaService basConveyorStaService;
// 璁$畻
public Boolean accept(Motion motion) {
@@ -95,6 +92,11 @@
return false;
}
+ Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskNo, motion.getTaskNo()));
+ if (task == null) {
+ return false;
+ }
+
ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
assignCommand.setShuttleNo(deviceNo);
assignCommand.setTaskNo(motion.getTaskNo());
@@ -115,6 +117,48 @@
if (String.valueOf(shuttleProtocol.getCurrentCode()).equals(locService.getOne(new LambdaQueryWrapper<Loc>()
.eq(Loc::getLocNo, motion.getTarget())
.eq(Loc::getHostId, motion.getHostId())).getCode())) {
+ return true;
+ }
+ shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread);
+ shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO;
+ break;
+ case SHUTTLE_TRANSPORT://绌挎杞﹁浇璐ц璧�
+ // 濡傛灉宸茬粡鍦ㄥ綋鍓嶆潯鐮佸垯杩囨护
+ if (String.valueOf(shuttleProtocol.getCurrentCode()).equals(locService.getOne(new LambdaQueryWrapper<Loc>()
+ .eq(Loc::getLocNo, motion.getTarget())
+ .eq(Loc::getHostId, motion.getHostId())).getCode())) {
+ return true;
+ }
+ shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
+ shuttleTaskModeType = ShuttleTaskModeType.TRANSPORT;
+ break;
+ case SHUTTLE_TRANSPORT_TO_CONVEYOR://绌挎杞﹁浇璐ц繘杈撻�佺嚎
+ BasConveyorSta originStaObj = basConveyorStaService.selectBySiteNo(motion.getDockNo());//鑾峰彇杈撻�佺珯鐐�
+ if (originStaObj == null) {
+ return false;
+ }
+
+ BasConveyor basConveyor = basConveyorService.getById(originStaObj.getConveyorId());
+ if(basConveyor == null) {
+ return false;
+ }
+
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, basConveyor.getDeviceId().intValue());
+ if (devpThread == null) {
+ return false;
+ }
+ StaProtocol staProtocol = devpThread.getStation().get(Integer.parseInt(motion.getDockNo()));//杈撻�佺珯
+ if (staProtocol == null) {
+ return false;
+ }
+ if (!(staProtocol.isAutoing() && !staProtocol.isLoading() && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable())) {
+ return false;
+ }
+
+ // 濡傛灉宸茬粡鍦ㄥ綋鍓嶆潯鐮佸垯杩囨护
+ if (String.valueOf(shuttleProtocol.getCurrentCode()).equals(locService.getOne(new LambdaQueryWrapper<Loc>()
+ .eq(Loc::getLocNo, motion.getTarget())
+ .eq(Loc::getHostId, motion.getHostId())).getCode())) {
return true;
}
shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread);
@@ -166,7 +210,7 @@
// return false;
// }
- shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread);
+ shuttleCommands = this.shuttleInOutLiftCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread);
shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO;
break;
case SHUTTLE_MOVE_TO_LIFT://杩涙彁鍗囨満
@@ -242,7 +286,7 @@
if (motion.getOrigin() != null && motion.getTarget() != null) {
//鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢�
- boolean lockResult = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(motion.getTarget()), shuttleProtocol.getShuttleNo(), assignCommand.getNodes(), true);//鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢�
+ boolean lockResult = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(motion.getTarget()), shuttleProtocol.getShuttleNo(), assignCommand.getNodesDeepCopy(), true);//鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢�
if (!lockResult) {
return false;//閿佸畾澶辫触
}
@@ -286,6 +330,11 @@
return false;
}
+ Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskNo, motion.getTaskNo()));
+ if (task == null) {
+ return false;
+ }
+
LiftThread liftThread = null;
LiftProtocol liftProtocol = null;
@@ -295,9 +344,20 @@
case SHUTTLE_MOVE_DOWN_PALLET:
case SHUTTLE_MOVE_TO_CONVEYOR:
case SHUTTLE_MOVE_FROM_CONVEYOR:
+ case SHUTTLE_TRANSPORT_TO_CONVEYOR://绌挎杞﹁浇璐ц繘杈撻�佺嚎
+ case SHUTTLE_TRANSPORT://绌挎杞﹁浇璐ц璧�
if (!shuttleProtocol.getCurrentLocNo().equals(motion.getTarget())) {
return false;
}
+
+ if (Optional.ofNullable(motion.getReleaseShuttle()).orElse(0) == 1) {//閲婃斁绌挎杞�
+ task.setShuttleNo(0);
+ task.setUpdateTime(new Date());
+ if (!taskService.updateById(task)) {
+ return false;
+ }
+ }
+
break;
case SHUTTLE_MOVE_TO_LIFT:
liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getTemp()));
@@ -391,6 +451,16 @@
break;
case SHUTTLE_UPDATE_LOCATION://灏忚溅鍧愭爣鏇存柊
break;
+ case SHUTTLE_PALLET_LIFT://鎵樼洏椤跺崌
+ if (!shuttleProtocol.getHasLift()) {
+ return false;
+ }
+ break;
+ case SHUTTLE_PALLET_DOWN://鎵樼洏涓嬮檷
+ if (shuttleProtocol.getHasLift()) {
+ return false;
+ }
+ break;
default:
break;
}
@@ -444,5 +514,62 @@
return commands;
}
+ public synchronized List<ShuttleCommand> shuttleInOutLiftCommand(String startLocNo, String endLocNo, Integer mapType, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) {
+ NavigateNode startNode = NavigatePositionConvert.locNoToNode(startLocNo);
+ NavigateNode endNode = NavigatePositionConvert.locNoToNode(endLocNo);
+ List<NavigateNode> unlockPath = new ArrayList<>();
+ unlockPath.add(startNode);
+ unlockPath.add(endNode);
+
+ ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
+
+ //鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹�/瑙i攣
+ boolean lockResult = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(endLocNo), shuttleProtocol.getShuttleNo(), unlockPath, false);//鎵�浣跨敤鐨勮矾寰勮繘琛岃В閿�
+ if (!lockResult) {
+ News.error("{} dash {} can't find unlock path!", startLocNo, endLocNo);
+ return null;//瑙i攣澶辫触
+ }
+
+
+ //鑾峰彇灏忚溅绉诲姩閫熷害
+ Integer runSpeed = Optional.ofNullable(basShuttleService.getOne(new LambdaQueryWrapper<BasShuttle>().eq(BasShuttle::getDeviceId, assignCommand.getDeviceId())).getRunSpeed()).orElse(1000);
+ Long hostId = shuttleThread.getDevice().getHostId();
+ List<NavigateNode> nodeList = NavigateUtils.calc(startLocNo, endLocNo, mapType, Utils.getShuttlePoints(Integer.parseInt(shuttleThread.getDevice().getDeviceNo()), Utils.getLev(startLocNo)));
+ if (nodeList == null) {
+ News.error("{} dash {} can't find navigate path!", startLocNo, endLocNo);
+ return null;
+ }
+
+ List<NavigateNode> allNode = new ArrayList<>();
+ for (NavigateNode node : nodeList) {
+ allNode.add(node.clone());
+ }
+
+ List<ShuttleCommand> commands = new ArrayList<>();
+ //鑾峰彇鍒嗘璺緞
+ ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(nodeList);
+ //灏嗘瘡涓�娈佃矾寰勫垎鎴恈ommand鎸囦护
+ for (ArrayList<NavigateNode> nodes : data) {
+ //寮�濮嬭矾寰�
+ NavigateNode startPath = nodes.get(0);
+
+ //鐩爣璺緞
+ NavigateNode endPath = nodes.get(nodes.size() - 1);
+ Integer allDistance = NavigateUtils.getCurrentPathAllDistance(nodes);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
+ //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
+ String startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ(), hostId);
+ //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
+ String distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ(), hostId);
+ //鑾峰彇绉诲姩鍛戒护
+ ShuttleCommand command = shuttleThread.getMoveCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes);
+ command.setNodes(nodes);//灏嗚璧拌妭鐐规坊鍔犲埌姣忎竴姝ュ懡浠や腑
+ commands.add(command);
+ }
+
+ assignCommand.setNodes(allNode);//褰撳墠浠诲姟鎵�鍗犵敤鐨勮妭鐐筶ist
+
+ return commands;
+ }
+
}
--
Gitblit v1.9.1