Junjie
2024-12-10 0dab5a05ed6e734a83c43f8e6e5ef1b07115f48d
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java
@@ -3,6 +3,7 @@
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.SpringUtils;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wcs.common.ExecuteSupport;
import com.zy.asrs.wcs.core.action.LiftAction;
@@ -24,6 +25,8 @@
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 com.zy.asrs.wcs.system.entity.Dict;
import com.zy.asrs.wcs.system.service.DictService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -65,6 +68,8 @@
    private ShuttleDispatcher shuttleDispatcher;
    @Autowired
    private NavigateUtils navigateUtils;
    @Autowired
    private DictService dictService;
    // 计算
    public Boolean accept(Motion motion) {
@@ -104,6 +109,14 @@
            return false;
        }
        Double similarityRef = 0.9D;
        Dict similarityRefDict = dictService.getOne(new LambdaQueryWrapper<Dict>()
                .eq(Dict::getFlag, "similarityRef")
                .eq(Dict::getStatus, 1));
        if (similarityRefDict != null) {
            similarityRef = Double.parseDouble(similarityRefDict.getValue());
        }
        ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
        assignCommand.setShuttleNo(deviceNo);
        assignCommand.setTaskNo(motion.getTaskNo());
@@ -117,6 +130,10 @@
        LiftThread liftThread = null;
        LiftProtocol liftProtocol = null;
        String movePath = null;
        List<NavigateNode> originPath = null;
        List<NavigateNode> finalPath = null;
        Double similarity = null;
        switch (Objects.requireNonNull(MotionCtgType.get(motion.getMotionCtgEl()))){
            case SHUTTLE_MOVE:
@@ -128,6 +145,16 @@
                }
                shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread);
                shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE;
                movePath = motion.getMovePath();
                originPath = JSON.parseArray(movePath, NavigateNode.class);
                finalPath = assignCommand.getNodes();
                similarity = navigateUtils.similarityPath(originPath, finalPath);
                if(similarity <= similarityRef) {
                    News.error("{} dash {} path similarity mismatch!", motion.getOrigin(), motion.getTarget());
                    return false;
                }
                break;
            case SHUTTLE_TRANSPORT://穿梭车载货行走
                // 如果已经在当前条码则过滤
@@ -138,6 +165,15 @@
                }
                shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
                shuttleTaskModeType = ShuttleTaskModeType.TRANSPORT;
                movePath = motion.getMovePath();
                originPath = JSON.parseArray(movePath, NavigateNode.class);
                finalPath = assignCommand.getNodes();
                similarity = navigateUtils.similarityPath(originPath, finalPath);
                if(similarity <= similarityRef) {
                    News.error("{} dash {} path similarity mismatch!", motion.getOrigin(), motion.getTarget());
                    return false;
                }
                if (motion.getReleaseLift() == 2) {//执行中释放提升机
                    task.setLiftNo(0);
@@ -179,15 +215,45 @@
                }
                shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
                shuttleTaskModeType = ShuttleTaskModeType.TRANSPORT_TO_CONVEYOR;
                movePath = motion.getMovePath();
                originPath = JSON.parseArray(movePath, NavigateNode.class);
                finalPath = assignCommand.getNodes();
                similarity = navigateUtils.similarityPath(originPath, finalPath);
                if(similarity <= similarityRef) {
                    News.error("{} dash {} path similarity mismatch!", motion.getOrigin(), motion.getTarget());
                    return false;
                }
                break;
            case SHUTTLE_MOVE_LIFT_PALLET://穿梭车顶升并移动
                shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
                shuttleTaskModeType = ShuttleTaskModeType.MOVE_PALLET_LIFT;
                movePath = motion.getMovePath();
                originPath = JSON.parseArray(movePath, NavigateNode.class);
                finalPath = assignCommand.getNodes();
                similarity = navigateUtils.similarityPath(originPath, finalPath);
                if(similarity <= similarityRef) {
                    News.error("{} dash {} path similarity mismatch!", motion.getOrigin(), motion.getTarget());
                    return false;
                }
                shuttleCommands.add(0, shuttleThread.getLiftCommand(motion.getTaskNo(), true));
                break;
            case SHUTTLE_MOVE_DOWN_PALLET://穿梭车移动并托盘下降
                shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
                shuttleTaskModeType = ShuttleTaskModeType.MOVE_PALLET_DOWN;
                movePath = motion.getMovePath();
                originPath = JSON.parseArray(movePath, NavigateNode.class);
                finalPath = assignCommand.getNodes();
                similarity = navigateUtils.similarityPath(originPath, finalPath);
                if(similarity <= similarityRef) {
                    News.error("{} dash {} path similarity mismatch!", motion.getOrigin(), motion.getTarget());
                    return false;
                }
                shuttleCommands.add(shuttleCommands.size(), shuttleThread.getLiftCommand(motion.getTaskNo(), false));
                break;
            case SHUTTLE_MOVE_FROM_LIFT://出提升机
@@ -297,6 +363,15 @@
                String shuttleFromLiftStandbyLoc = shuttleDispatcher.searchAvailableLocNo(Integer.valueOf(shuttleDevice.getDeviceNo()), shuttleDevice.getHostId(), shuttleThread.getStatus().getCurrentLocNo(), standbyLocs);
                shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), shuttleFromLiftStandbyLoc, NavigationMapType.NORMAL.id, assignCommand, shuttleThread);
                movePath = motion.getMovePath();
                originPath = JSON.parseArray(movePath, NavigateNode.class);
                finalPath = assignCommand.getNodes();
                similarity = navigateUtils.similarityPath(originPath, finalPath);
                if(similarity <= similarityRef) {
                    News.error("{} dash {} path similarity mismatch!", motion.getOrigin(), motion.getTarget());
                    return false;
                }
                //更新动作可用待机位
                motion.setTarget(shuttleFromLiftStandbyLoc);
                motion.setUpdateTime(new Date());