From 9d0acfb65c80c4948c305ca01338f894b87346a0 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期一, 08 四月 2024 09:44:37 +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/core/action/ShuttleAction.java | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 46 insertions(+), 6 deletions(-) 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..0314e53 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; } @@ -75,10 +85,8 @@ return false; } - //鍥涘悜绌挎杞︾┖闂层�佹湁浠诲姟銆佹爣璁颁负true銆佸瓨鍦ㄤ换鍔℃寚浠わ紝闇�瑕佹墽琛屼换鍔$殑涓嬩竴鏉℃寚浠� - if (!shuttleProtocol.getIdle() - || shuttleProtocol.getTaskNo() == 0 - || !shuttleProtocol.getPakMk()) { + //鍒ゆ柇璁惧鏄惁绌洪棽 + if (!shuttleThread.isIdle()) { return false; } @@ -126,8 +134,8 @@ if (!shuttleProtocol.getHasLift()) { command.setComplete(true); } - } else if (command.getMode() == ShuttleCommandModeType.CHARGE.id) { - // 鍏呯數寮�鍏� + } else if (command.getMode() == ShuttleCommandModeType.CHARGE_OPEN.id) { + // 鍏呯數寮� //鍒ゆ柇灏忚溅鍏呯數鐘舵�� if (shuttleProtocol.getHasCharge()) { command.setComplete(true); @@ -175,7 +183,39 @@ } } + //鍙栧嚭鍛戒护 + 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_OPEN.id + || command.getMode() == ShuttleCommandModeType.CHARGE_CLOSE.id) {//鍏呯數 + result = shuttleThread.charge(command); + } else if (command.getMode() == ShuttleCommandModeType.RESET.id) {//澶嶄綅 + result = shuttleThread.reset(command); + } + return result; + } + } -- Gitblit v1.9.1