| | |
| | | import com.zy.asrs.wcs.core.entity.Task; |
| | | import com.zy.asrs.wcs.core.kernel.command.AgvCommandService; |
| | | import com.zy.asrs.wcs.core.kernel.command.CraneCommandService; |
| | | import com.zy.asrs.wcs.core.kernel.command.LiftCommandService; |
| | | import com.zy.asrs.wcs.core.kernel.command.ShuttleCommandService; |
| | | import com.zy.asrs.wcs.core.model.enums.DeviceCtgType; |
| | | import com.zy.asrs.wcs.core.model.enums.MotionCtgType; |
| | | import com.zy.asrs.wcs.core.model.enums.MotionStsType; |
| | | import com.zy.asrs.wcs.core.model.enums.TaskStsType; |
| | | import com.zy.asrs.wcs.core.service.TaskService; |
| | | import com.zy.asrs.wcs.rcs.entity.Motion; |
| | | import com.zy.asrs.wcs.rcs.service.MotionService; |
| | | import com.zy.asrs.wcs.core.entity.Motion; |
| | | import com.zy.asrs.wcs.core.service.MotionService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | |
| | | // private ConveyorCommandService conveyorCommandService; |
| | | @Autowired |
| | | private CraneCommandService craneCommandService; |
| | | // @Autowired |
| | | // private LiftCommandService liftCommandService; |
| | | @Autowired |
| | | private LiftCommandService liftCommandService; |
| | | @Autowired |
| | | private ShuttleCommandService shuttleCommandService; |
| | | |
| | | @Scheduled(cron = "0/1 * * * * ? ") |
| | | public synchronized void executeWrkMast() { |
| | | // @Scheduled(cron = "0/1 * * * * ? ") |
| | | public synchronized void executeTask() { |
| | | Date now = new Date(); |
| | | // ANALYZE_INBOUND |
| | | for (Task task : taskService.selectByAnalyzeSts()) { |
| | |
| | | continue; |
| | | } |
| | | |
| | | // 更新wrkMast |
| | | switch (TaskStsType.query(task.getTaskSts())) { |
| | | // 更新Task |
| | | switch (TaskStsType.queryById(task.getTaskSts())) { |
| | | case ANALYZE_INBOUND: |
| | | task.setTaskSts(TaskStsType.EXECUTE_INBOUND.sts); |
| | | task.setTaskSts(TaskStsType.EXECUTE_INBOUND.getId()); |
| | | break; |
| | | case ANALYZE_OUTBOUND: |
| | | task.setTaskSts(TaskStsType.EXECUTE_OUTBOUND.sts); |
| | | task.setTaskSts(TaskStsType.EXECUTE_OUTBOUND.getId()); |
| | | break; |
| | | } |
| | | task.setUpdateTime(now); |
| | |
| | | continue; |
| | | } |
| | | |
| | | // 更新wrkMast |
| | | switch (TaskStsType.query(task.getTaskSts())) { |
| | | // 更新Task |
| | | switch (TaskStsType.queryById(task.getTaskSts())) { |
| | | case EXECUTE_INBOUND: |
| | | task.setTaskSts(TaskStsType.COMPLETE_INBOUND.sts); |
| | | task.setTaskSts(TaskStsType.COMPLETE_INBOUND.getId()); |
| | | break; |
| | | case EXECUTE_OUTBOUND: |
| | | task.setTaskSts(TaskStsType.COMPLETE_OUTBOUND.sts); |
| | | task.setTaskSts(TaskStsType.COMPLETE_OUTBOUND.getId()); |
| | | break; |
| | | } |
| | | task.setUpdateTime(now); |
| | |
| | | // } |
| | | // } |
| | | |
| | | // @Scheduled(cron = "0/1 * * * * ? ") |
| | | public synchronized void executeManualTask() { |
| | | Date now = new Date(); |
| | | // ANALYZE_MANUAL |
| | | for (Task task : taskService.selectByAnalyzeSts()) { |
| | | 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.queryById(task.getTaskSts())) { |
| | | case ANALYZE_MANUAL: |
| | | task.setTaskSts(TaskStsType.EXECUTE_MANUAL.getId()); |
| | | break; |
| | | } |
| | | task.setUpdateTime(now); |
| | | if (!taskService.updateById(task)) { |
| | | log.error("{}其他工作档更新状态失败!", task.getTaskNo()); |
| | | } |
| | | } |
| | | } |
| | | // EXECUTE_MANUAL |
| | | for (Task task : taskService.selectManualByExecuteSts()) { |
| | | 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.queryById(task.getTaskSts())) { |
| | | case EXECUTE_MANUAL: |
| | | task.setTaskSts(TaskStsType.COMPLETE_MANUAL.getId()); |
| | | 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()); |
| | |
| | | executeRes = shuttleCommandService.accept(motion); |
| | | break; |
| | | case LIFT: |
| | | // executeRes = liftCommandService.accept(motion); |
| | | executeRes = liftCommandService.accept(motion); |
| | | break; |
| | | case AGV: |
| | | executeRes = agvCommandService.accept(motion); |
| | |
| | | case CRANE: |
| | | break; |
| | | case LIFT: |
| | | // executeRes = liftCommandService.finish(motion); |
| | | executeRes = liftCommandService.finish(motion); |
| | | break; |
| | | case SHUTTLE: |
| | | executeRes = shuttleCommandService.finish(motion); |