#
Junjie
2024-03-28 0817793961918c1123328bca9a78ca29d95738b8
#
5个文件已添加
10个文件已修改
827 ■■■■■ 已修改文件
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java 150 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/LiftAssignCommand.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/LiftCommand.java 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/LiftRedisCommand.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/ShuttleAssignCommand.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/ShuttleRedisCommand.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/LiftCommandModeType.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/DeviceTimer.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/LiftProtocol.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/LiftThread.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/ShuttleThread.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java 234 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java 156 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java
New file
@@ -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);//命令
        //任务数据保存到redis
        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;
    }
}
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);//命令
        //任务数据保存到redis
        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;
    }
}
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) {
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/LiftAssignCommand.java
New file
@@ -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<>();
}
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/LiftCommand.java
New file
@@ -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;
}
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/command/LiftRedisCommand.java
New file
@@ -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;
}
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;
    /**
     * 源库位
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;
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/LiftCommandModeType.java
New file
@@ -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, "解锁提升机"),
    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;
    }
}
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 * * * * ? ")
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;
    }
}
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);//解锁提升机
    boolean reset(LiftCommand command);//复位
}
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);
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;
    }
    //锁定/解锁提升机
    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;
    }
}
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;
    }