#
Junjie
2024-04-23 2db722e23d7e5d1d2e719174938f354d804644af
#
5个文件已修改
252 ■■■■ 已修改文件
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java 228 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/constant/DeviceRedisConstant.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/LiftThread.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java
@@ -4,11 +4,14 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.exception.CoolException;
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.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.enums.*;
@@ -19,6 +22,7 @@
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;
@@ -135,21 +139,26 @@
                    return false;
                }
//                //判断提升机是否被锁定
//                if (!liftProtocol.getLock()) {
//                    //锁定提升机
//                    LiftCommand lockCommand = liftThread.getLockCommand(motion.getWrkNo(), true);//获取提升机锁定命令
//
//                    LiftAssignCommand liftAssignCommand = new LiftAssignCommand();
//                    liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo());
//                    liftAssignCommand.setTaskNo(motion.getWrkNo());
//                    ArrayList<LiftCommand> list = new ArrayList<>();
//                    list.add(lockCommand);
//                    liftAssignCommand.setCommands(list);
//
//                    liftAction.assignWork(liftThread.getDevice(), liftAssignCommand);
//                    return false;//等待下一次轮询
//                }
                //判断提升机是否被锁定
                if (!liftThread.isLock(new ExecuteSupport() {
                    @Override
                    public Boolean judgement() {
                        return true;
                    }
                })) {
                    //锁定提升机
                    LiftCommand lockCommand = liftThread.getLockCommand(motion.getTaskNo(), true);//获取提升机锁定命令
                    LiftAssignCommand liftAssignCommand = new LiftAssignCommand();
                    liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo());
                    liftAssignCommand.setTaskNo(motion.getTaskNo());
                    ArrayList<LiftCommand> list = new ArrayList<>();
                    list.add(lockCommand);
                    liftAssignCommand.setCommands(list);
                    liftAction.assignWork(liftThread.getDevice(), liftAssignCommand);
                    return false;//等待下一次轮询
                }
                //判断提升机工作号是否和当前任务相同
                if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) {
@@ -178,15 +187,29 @@
                    return false;
                }
//                //判断提升机是否被锁定
//                if (!liftProtocol.getLiftLock()) {
//                    //锁定提升机
//                    LiftCommand lockCommand = liftThread.getLockCommand(true);//获取提升机锁定命令
//                    lockCommand.setLiftNo(liftProtocol.getLiftNo());
//                    lockCommand.setTaskNo(motion.getWrkNo().shortValue());//获取任务号
//                    liftThread.assignWork(lockCommand);
//                    return false;//等待下一次轮询
//                }
                //判断提升机是否被锁定
                if (!liftThread.isLock(new ExecuteSupport() {
                    @Override
                    public Boolean judgement() {
                        return true;
                    }
                })) {
                    //锁定提升机
                    LiftCommand lockCommand = liftThread.getLockCommand(motion.getTaskNo(), true);//获取提升机锁定命令
                    if (lockCommand == null) {
                        return false;
                    }
                    LiftAssignCommand liftAssignCommand = new LiftAssignCommand();
                    liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo());
                    liftAssignCommand.setTaskNo(motion.getTaskNo());
                    ArrayList<LiftCommand> list = new ArrayList<>();
                    list.add(lockCommand);
                    liftAssignCommand.setCommands(list);
                    liftAction.assignWork(liftThread.getDevice(), liftAssignCommand);
                    return false;//等待下一次轮询
                }
                //判断提升机工作号是否和当前任务相同
                if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) {
@@ -284,7 +307,126 @@
                }
                break;
            case SHUTTLE_MOVE_TO_LIFT:
                liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getTemp()));
                if (liftThread == null) {
                    return false;
                }
                liftProtocol = liftThread.getStatus();
                if (!shuttleProtocol.getCurrentLocNo().equals(motion.getTarget())) {
                    return false;
                }
                //判断提升机是否被锁定
                if (liftThread.isLock(new ExecuteSupport() {
                    @Override
                    public Boolean judgement() {
                        return false;
                    }
                })) {
                    //解锁提升机
                    LiftCommand lockCommand = liftThread.getLockCommand(motion.getTaskNo(), false);//获取提升机解锁命令
                    LiftAssignCommand liftAssignCommand = new LiftAssignCommand();
                    liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo());
                    liftAssignCommand.setTaskNo(motion.getTaskNo());
                    ArrayList<LiftCommand> list = new ArrayList<>();
                    list.add(lockCommand);
                    liftAssignCommand.setCommands(list);
                    liftAction.assignWork(liftThread.getDevice(), liftAssignCommand);
                    return false;//等待下一次轮询
                }
                //判断小车是否已到位
                if (liftProtocol.getHasCar()) {
                    LiftCommand signalCommand = liftThread.getShuttleSignalCommand(motion.getTaskNo(), true);//获取小车已到位命令
                    if(signalCommand != null) {
                        boolean hasKey = redisUtil.hasKey(DeviceRedisConstant.COMMAND_TMP + motion.getTaskNo());
                        if (!hasKey) {
                            LiftAssignCommand liftAssignCommand = new LiftAssignCommand();
                            liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo());
                            liftAssignCommand.setTaskNo(motion.getTaskNo());
                            ArrayList<LiftCommand> list = new ArrayList<>();
                            list.add(signalCommand);
                            liftAssignCommand.setCommands(list);
                            liftAction.assignWork(liftThread.getDevice(), liftAssignCommand);
                            return false;
                        }
                    }
                }
                //判断提升机工作号是否和当前任务相同
                if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) {
                    return false;
                }
                if (liftProtocol.getTaskNo() != 0) {
                    //清空提升机号
                    liftThread.setSyncTaskNo(0);
                }
                break;
            case SHUTTLE_MOVE_FROM_LIFT:
                liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getTemp()));
                if (liftThread == null) {
                    return false;
                }
                liftProtocol = liftThread.getStatus();
                if (!shuttleProtocol.getCurrentLocNo().equals(motion.getTarget())) {
                    return false;
                }
                //判断提升机是否被锁定
                if (liftThread.isLock(new ExecuteSupport() {
                    @Override
                    public Boolean judgement() {
                        return false;
                    }
                })) {
                    //解锁提升机
                    LiftCommand lockCommand = liftThread.getLockCommand(motion.getTaskNo(), false);//获取提升机解锁命令
                    LiftAssignCommand liftAssignCommand = new LiftAssignCommand();
                    liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo());
                    liftAssignCommand.setTaskNo(motion.getTaskNo());
                    ArrayList<LiftCommand> list = new ArrayList<>();
                    list.add(lockCommand);
                    liftAssignCommand.setCommands(list);
                    liftAction.assignWork(liftThread.getDevice(), liftAssignCommand);
                    return false;//等待下一次轮询
                }
                //判断小车是否已离开
                if (!liftProtocol.getHasCar()) {
                    LiftCommand signalCommand = liftThread.getShuttleSignalCommand(motion.getTaskNo(), false);//获取小车已驾离命令
                    if(signalCommand != null) {
                        boolean hasKey = redisUtil.hasKey(DeviceRedisConstant.COMMAND_TMP + motion.getTaskNo());
                        if (!hasKey) {
                            redisUtil.set(DeviceRedisConstant.COMMAND_TMP + motion.getTaskNo(), JSON.toJSONString(signalCommand), 120);
                            LiftAssignCommand liftAssignCommand = new LiftAssignCommand();
                            liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo());
                            liftAssignCommand.setTaskNo(motion.getTaskNo());
                            ArrayList<LiftCommand> list = new ArrayList<>();
                            list.add(signalCommand);
                            liftAssignCommand.setCommands(list);
                            liftAction.assignWork(liftThread.getDevice(), liftAssignCommand);
                            return false;
                        }
                    }
                }
                //判断提升机工作号是否和当前任务相同
                if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) {
                    return false;
                }
                if (liftProtocol.getTaskNo() != 0) {
                    //清空提升机号
                    liftThread.setSyncTaskNo(0);
                }
                break;
            case SHUTTLE_TRANSPORT_FROM_LIFT:
            case SHUTTLE_TRANSPORT_TO_LIFT:
            case SHUTTLE_MOVE_FROM_LIFT_TO_CONVEYOR:
@@ -298,26 +440,36 @@
                    return false;
                }
//                //判断提升机是否被锁定
//                if (liftProtocol.getLiftLock()) {
//                    //解锁提升机
//                    LiftCommand lockCommand = liftThread.getLockCommand(false);//获取提升机解锁命令
//                    lockCommand.setLiftNo(liftProtocol.getLiftNo());
//                    lockCommand.setTaskNo(motion.getWrkNo().shortValue());//获取任务号
//                    liftThread.assignWork(lockCommand);
//                    return false;
//                }
                //判断提升机是否被锁定
                if (liftThread.isLock(new ExecuteSupport() {
                    @Override
                    public Boolean judgement() {
                        return false;
                    }
                })) {
                    //解锁提升机
                    LiftCommand lockCommand = liftThread.getLockCommand(motion.getTaskNo(), false);//获取提升机解锁命令
                    LiftAssignCommand liftAssignCommand = new LiftAssignCommand();
                    liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo());
                    liftAssignCommand.setTaskNo(motion.getTaskNo());
                    ArrayList<LiftCommand> list = new ArrayList<>();
                    list.add(lockCommand);
                    liftAssignCommand.setCommands(list);
                    liftAction.assignWork(liftThread.getDevice(), liftAssignCommand);
                    return false;//等待下一次轮询
                }
                //判断提升机工作号是否和当前任务相同
                if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) {
                    return false;
                }
//                if (liftProtocol.getTaskNo() != 0) {
//                    //清空提升机号
//                    liftThread.setTaskNo(0);
//                }
                if (liftProtocol.getTaskNo() != 0) {
                    //清空提升机号
                    liftThread.setSyncTaskNo(0);
                }
                break;
            default:
                break;
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/constant/DeviceRedisConstant.java
@@ -15,4 +15,6 @@
    public static final String MAP = "realtimeBasMap_";
    public static final String COMMAND_TMP = "command_tmp_";
}
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/LiftThread.java
@@ -30,6 +30,8 @@
    boolean setSyncTaskNo(Integer taskNo);//设置工作号
    boolean isLock(ExecuteSupport support);
    //***************获取命令*****************
    LiftCommand getMoveCommand(Integer taskNo, Integer sourceLev, Integer targetLev, Integer mode);//提升机移动
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java
@@ -312,6 +312,14 @@
    }
    @Override
    public boolean isLock(ExecuteSupport support) {
        if (support != null) {
            return support.judgement();
        }
        return true;
    }
    @Override
    public LiftCommand getMoveCommand(Integer taskNo, Integer sourceLev, Integer targetLev, Integer mode) {
        /**
         * 任务类型
@@ -355,14 +363,12 @@
    @Override
    public LiftCommand getLockCommand(Integer taskNo, Boolean lock) {
        LiftCommand command = new LiftCommand();
        return command;
        return null;
    }
    @Override
    public LiftCommand getShuttleSignalCommand(Integer taskNo, Boolean signal) {
        LiftCommand command = new LiftCommand();
        return command;
        return null;
    }
    @Override
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java
@@ -339,6 +339,12 @@
        return true;
    }
    @Override
    public boolean isLock(ExecuteSupport support) {
        InnerLiftExtend extend = (InnerLiftExtend) this.liftProtocol.getExtend();
        return extend.getLock();
    }
    //***************设备层通讯-不同厂商设备通讯方案不一致***************
    //请求登录