自动化立体仓库 - WCS系统
Junjie
2023-08-02 b82892d4b6d7ddd51d550871223036e993f76cf6
src/main/java/com/zy/asrs/controller/ShuttleController.java
@@ -15,7 +15,10 @@
import com.zy.asrs.service.LocMastService;
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.utils.Utils;
import com.zy.common.model.NyShuttleOperaResult;
import com.zy.common.service.CommonService;
import com.zy.common.utils.NyHttpUtils;
import com.zy.common.utils.NyShuttleOperaUtils;
import com.zy.common.utils.RedisUtil;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.OutputQueue;
@@ -23,8 +26,8 @@
import com.zy.core.enums.*;
import com.zy.core.model.ShuttleSlave;
import com.zy.core.model.Task;
import com.zy.core.model.command.NyShuttleHttpCommand;
import com.zy.core.model.command.ShuttleAssignCommand;
import com.zy.core.model.command.ShuttleCommand;
import com.zy.core.model.command.ShuttleRedisCommand;
import com.zy.core.model.protocol.NyShuttleProtocol;
import com.zy.core.model.protocol.ShuttleProtocol;
@@ -184,8 +187,8 @@
        }
        ShuttleRedisCommand redisCommand = JSON.parseObject(o.toString(), ShuttleRedisCommand.class);
        ShuttleAssignCommand assignCommand = redisCommand.getAssignCommand();
        List<ShuttleCommand> commands = assignCommand.getCommands();
        ShuttleCommand command = commands.get(commandStep);
        List<NyShuttleHttpCommand> commands = assignCommand.getCommands();
        NyShuttleHttpCommand command = commands.get(commandStep);
        command.setComplete(complete != 0);
        redisUtil.set("shuttle_wrk_no_" + wrkNo, JSON.toJSONString(redisCommand));
        return R.ok();
@@ -266,6 +269,52 @@
                assignCommand.setTaskNo((short) commonService.getWorkNo(3));//获取任务号
                assignCommand.setAuto(false);//手动模式
                if (shuttleTaskModeType == ShuttleTaskModeType.TRANSPORT) {
                    //搬运货物任务
                    NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), shuttleProtocol.getCurrentLocNo(), param.getSourceLocNo(), param.getDistLocNo());
                    if (result == null) {
                        throw new CoolException("路径计算失败");
                    }
                    assignCommand.setCommands(result.getCommands());
                    assignCommand.setNodes(result.getNodes());
                } else if (shuttleTaskModeType == ShuttleTaskModeType.MOVE_LOC_NO) {
                    //移动到目标库位
                    NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), shuttleProtocol.getCurrentLocNo(), param.getDistLocNo());
                    if (result == null) {
                        throw new CoolException("路径计算失败");
                    }
                    assignCommand.setCommands(result.getCommands());
                    assignCommand.setNodes(result.getNodes());
                } else if (shuttleTaskModeType == ShuttleTaskModeType.PALLET_LIFT) {
                    //托盘顶升
                    NyShuttleHttpCommand command = NyHttpUtils.getPalletLiftCommand(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), true);
                    ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>();
                    commands.add(command);
                    assignCommand.setCommands(commands);
                } else if (shuttleTaskModeType == ShuttleTaskModeType.PALLET_DOWN) {
                    //托盘下降
                    NyShuttleHttpCommand command = NyHttpUtils.getPalletLiftCommand(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), false);
                    ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>();
                    commands.add(command);
                    assignCommand.setCommands(commands);
                } else if (shuttleTaskModeType == ShuttleTaskModeType.CHARGE) {
                    //充电开关
                    NyShuttleHttpCommand command = NyHttpUtils.getChargeCommand(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), true);
                    ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>();
                    commands.add(command);
                    assignCommand.setCommands(commands);
                } else if (shuttleTaskModeType == ShuttleTaskModeType.RESET) {
                    //复位
                    shuttleProtocol.setTaskNo(0);//工作号清空
                    shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE);//任务状态-空闲
                    shuttleProtocol.setPakMk(true);//作业标记复位
                    return R.ok();
                } else {
                    throw new CoolException("未知命令");
                }
                if (MessageQueue.offer(SlaveType.Shuttle, shuttleSlave.getId(), new Task(3, assignCommand))) {
                    return R.ok();
                } else {
@@ -279,8 +328,9 @@
    @PostMapping("/detl/update")
    @ManagerAuth(memo = "修改数据")
    public R shuttleUpdate(@RequestParam Integer shuttleNo,
                        @RequestParam Integer workNo,
                        @RequestParam String pakMk){
                           @RequestParam Integer workNo,
                           @RequestParam String pakMk,
                           @RequestParam Integer token) {
        NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
        if (shuttleThread == null) {
            return R.error("plc已掉线");
@@ -295,6 +345,9 @@
        if (pakMk != null) {
            shuttleProtocol.setPakMk(pakMk.equals("Y"));
        }
        if (token != null) {
            shuttleProtocol.setToken(token);
        }
        return R.ok();
    }