#
zjj
2024-07-10 c13fe87d70e81d7dcb604f8f1227de8f313cbefc
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/MotionTimer.java
@@ -41,14 +41,16 @@
    @Autowired
    private ShuttleCommandService shuttleCommandService;
//    @Scheduled(cron = "0/1 * * * * ? ")
    @Scheduled(cron = "0/1 * * * * ? ")
    public synchronized void executeTask() {
        Date now = new Date();
        // ANALYZE_INBOUND
        for (Task task : taskService.selectByAnalyzeSts()) {
            Motion executingMotion = motionService.selectOfTop1(task.getUuid(), MotionStsType.EXECUTING.val(), task.getHostId());
            if (executingMotion != null) {//存在正在执行的motion
                continue;
                if (executingMotion.getSync() == 1) {//当前执行中的动作是同步动作,等待执行完成后再执行下一个动作
                    continue;
                }
            }
            Motion motion = motionService.selectOfTop1(task.getUuid(), MotionStsType.INIT.val(), task.getHostId());
@@ -112,7 +114,9 @@
        for (Task taskCharge : taskService.selectChargeByAnalyzeSts()) {
            Motion executingMotion = motionService.selectOfTop1(taskCharge.getUuid(), MotionStsType.EXECUTING.val(), taskCharge.getHostId());
            if (executingMotion != null) {//存在正在执行的motion
                continue;
                if (executingMotion.getSync() == 1) {//当前执行中的动作是同步动作,等待执行完成后再执行下一个动作
                    continue;
                }
            }
            Motion motion = motionService.selectOfTop1(taskCharge.getUuid(), MotionStsType.INIT.val(), taskCharge.getHostId());
@@ -169,13 +173,74 @@
    }
    @Scheduled(cron = "0/1 * * * * ? ")
    public synchronized void executeLadenMoveTask() {
        Date now = new Date();
        // ANALYZE_CHARGE
        for (Task taskCharge : taskService.selectLadenMoveByAnalyzeSts()) {
            Motion executingMotion = motionService.selectOfTop1(taskCharge.getUuid(), MotionStsType.EXECUTING.val(), taskCharge.getHostId());
            if (executingMotion != null) {//存在正在执行的motion
                if (executingMotion.getSync() == 1) {//当前执行中的动作是同步动作,等待执行完成后再执行下一个动作
                    continue;
                }
            }
            Motion motion = motionService.selectOfTop1(taskCharge.getUuid(), MotionStsType.INIT.val(), taskCharge.getHostId());
            if (null != motion) {
                boolean result = this.executeMotion(motion);
                if (!result) {
                    continue;
                }
                // 更新Task
                switch (TaskStsType.query(taskCharge.getTaskSts())) {
                    case ANALYZE_LADEN_MOVE:
                        taskCharge.setTaskSts(TaskStsType.EXECUTE_LADEN_MOVE.sts);
                        break;
                }
                taskCharge.setUpdateTime(now);
                if (!taskService.updateById(taskCharge)) {
                    log.error("{}其他工作档更新状态失败!", taskCharge.getTaskNo());
                }
            }
        }
        // EXECUTE_CHARGE
        for (Task taskCharge : taskService.selectLadenMoveByExecuteSts()) {
            if (!motionService.hasRunningMotion(taskCharge.getUuid(), taskCharge.getHostId())) {
                Motion motion = motionService.selectOfTop1(taskCharge.getUuid(), MotionStsType.WAITING.val(), taskCharge.getHostId());
                if (null != motion) {
                    boolean result = this.executeMotion(motion);
                    if (!result) {
                        continue;
                    }
                } else {
                    if (motionService.selectOfTop1(taskCharge.getUuid(), MotionStsType.EXECUTING.val(), taskCharge.getHostId()) != null) {
                        continue;
                    }
                    // 更新Task
                    switch (TaskStsType.query(taskCharge.getTaskSts())) {
                        case EXECUTE_LADEN_MOVE:
                            taskCharge.setTaskSts(TaskStsType.COMPLETE_LADEN_MOVE.sts);
                            break;
                    }
                    taskCharge.setUpdateTime(now);
                    if (!taskService.updateById(taskCharge)) {
                        log.error("{}他工作档更新状态失败!", taskCharge.getTaskNo());
                    }
                }
            }
        }
    }
    @Scheduled(cron = "0/1 * * * * ? ")
    public synchronized void executeManualTask() {
        Date now = new Date();
        // ANALYZE_MANUAL
        for (Task task : taskService.selectManualByAnalyzeSts()) {
            Motion executingMotion = motionService.selectOfTop1(task.getUuid(), MotionStsType.EXECUTING.val(), task.getHostId());
            if (executingMotion != null) {//存在正在执行的motion
                continue;
                if (executingMotion.getSync() == 1) {//当前执行中的动作是同步动作,等待执行完成后再执行下一个动作
                    continue;
                }
            }
            Motion motion = motionService.selectOfTop1(task.getUuid(), MotionStsType.INIT.val(), task.getHostId());
@@ -226,6 +291,65 @@
    }
    @Scheduled(cron = "0/1 * * * * ? ")
    public synchronized void executeMoveTask() {
        Date now = new Date();
        // ANALYZE_MOVE
        for (Task task : taskService.selectMoveByAnalyzeSts()) {
            Motion executingMotion = motionService.selectOfTop1(task.getUuid(), MotionStsType.EXECUTING.val(), task.getHostId());
            if (executingMotion != null) {//存在正在执行的motion
                if (executingMotion.getSync() == 1) {//当前执行中的动作是同步动作,等待执行完成后再执行下一个动作
                    continue;
                }
            }
            Motion motion = motionService.selectOfTop1(task.getUuid(), MotionStsType.INIT.val(), task.getHostId());
            if (null != motion) {
                boolean result = this.executeMotion(motion);
                if (!result) {
                    continue;
                }
                // 更新Task
                switch (TaskStsType.query(task.getTaskSts())) {
                    case ANALYZE_MOVE:
                        task.setTaskSts(TaskStsType.EXECUTE_MOVE.sts);
                        break;
                }
                task.setUpdateTime(now);
                if (!taskService.updateById(task)) {
                    log.error("{}其他工作档更新状态失败!", task.getTaskNo());
                }
            }
        }
        // EXECUTE_MOVE
        for (Task task : taskService.selectMoveByExecuteSts()) {
            if (!motionService.hasRunningMotion(task.getUuid(), task.getHostId())) {
                Motion motion = motionService.selectOfTop1(task.getUuid(), MotionStsType.WAITING.val(), task.getHostId());
                if (null != motion) {
                    boolean result = this.executeMotion(motion);
                    if (!result) {
                        continue;
                    }
                } else {
                    if (motionService.selectOfTop1(task.getUuid(), MotionStsType.EXECUTING.val(), task.getHostId()) != null) {
                        continue;
                    }
                    // 更新Task
                    switch (TaskStsType.query(task.getTaskSts())) {
                        case EXECUTE_MOVE:
                            task.setTaskSts(TaskStsType.COMPLETE_MOVE.sts);
                            break;
                    }
                    task.setUpdateTime(now);
                    if (!taskService.updateById(task)) {
                        log.error("{}他工作档更新状态失败!", task.getTaskNo());
                    }
                }
            }
        }
    }
    @Scheduled(cron = "0/1 * * * * ? ")
    public void scanMotionByExecuting() {
        List<Motion> motionList = motionService.selectBySts(MotionStsType.EXECUTING.val());
        for (Motion motion : motionList) {