|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ShuttleCommandService shuttleCommandService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //    @Scheduled(cron = "0/1 * * * * ? ") | 
|---|
|  |  |  | @Scheduled(cron = "0/1 * * * * ? ") | 
|---|
|  |  |  | public synchronized void executeTask() { | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  | // ANALYZE_INBOUND | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @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 | 
|---|
|  |  |  | 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) { | 
|---|
|  |  |  | 
|---|
|  |  |  | Boolean executeRes = Boolean.FALSE; | 
|---|
|  |  |  | switch (Objects.requireNonNull(MotionCtgType.get(motion.getMotionCtgEl())).deviceCtg) { | 
|---|
|  |  |  | case CONVEYOR: | 
|---|
|  |  |  | //                executeRes = conveyorCommandService.accept(motion); | 
|---|
|  |  |  | executeRes = conveyorCommandService.accept(motion); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case CRANE: | 
|---|
|  |  |  | executeRes = craneCommandService.accept(motion); | 
|---|
|  |  |  | 
|---|
|  |  |  | executeRes = shuttleCommandService.finish(motion); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case CONVEYOR: | 
|---|
|  |  |  | //                executeRes = conveyorCommandService.finish(motion); | 
|---|
|  |  |  | executeRes = conveyorCommandService.finish(motion); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | default: | 
|---|
|  |  |  | break; | 
|---|