| | |
| | | if (!Cools.isEmpty(taskService.selectInSts(agvId, TaskStsType.ASSIGN, TaskStsType.PROGRESS))) { |
| | | throw new CoolException("AGV[" + agv.getUuid() + "]分配任务失败,已存在执行任务..."); |
| | | } |
| | | if (!Cools.isEmpty(segmentService.getByAgvAndState(agv.getId(), SegmentStateType.WAITING.toString())) |
| | | || !Cools.isEmpty(segmentService.getByAgvAndState(agv.getId(), SegmentStateType.RUNNING.toString()))) { |
| | | throw new CoolException("AGV[" + agv.getUuid() + "] failed to assign,because already has the segment in running..."); |
| | | } |
| | | |
| | | // execute ---------------------------------------------------- |
| | | Date now = new Date(); |
| | |
| | | * 充电 回待机位任务 |
| | | */ |
| | | @Transactional(propagation = Propagation.REQUIRES_NEW) // although there is a Transactional here that the lock is isolated, but we can't join the caller's Transactional |
| | | public boolean buildMinorTask(Agv agv, AgvDetail agvDetail, TaskTypeType taskType, String destination) { |
| | | public boolean buildMinorTask(Agv agv, TaskTypeType taskType, String destination, Jam jam) { |
| | | if (Cools.isEmpty(agv, taskType)) { return false; } |
| | | try { |
| | | if (null == agvDetail) { |
| | | agvDetail = agvDetailService.selectByAgvId(agv.getId()); |
| | | } |
| | | AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId()); |
| | | if (!agvService.judgeEnable(agv.getId())) { |
| | | return false; |
| | | } |
| | | if (!Cools.isEmpty(taskService.selectInSts(agv.getId(), TaskStsType.ASSIGN, TaskStsType.PROGRESS))) { |
| | | throw new CoolException("AGV[" + agv.getUuid() + "] failed to assign,because already has the task in running..."); |
| | | } |
| | | if (!Cools.isEmpty(segmentService.getByAgvAndState(agv.getId(), SegmentStateType.WAITING.toString())) |
| | | || !Cools.isEmpty(segmentService.getByAgvAndState(agv.getId(), SegmentStateType.RUNNING.toString()))) { |
| | | throw new CoolException("AGV[" + agv.getUuid() + "] failed to assign,because already has the segment in running..."); |
| | | } |
| | | |
| | | Date now = new Date(); |
| | |
| | | } |
| | | if (!segmentService.save(next)) { |
| | | throw new BusinessException("segment failed to save"); |
| | | } else { |
| | | if (null != jam && i == 0) { |
| | | jam.setAvoSeg(next.getId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | // if (taskType.equals(TaskTypeType.TO_STANDBY)) { |
| | | // redis.setObject(RedisConstant.AGV_TO_STANDBY_FLAG, agv.getUuid(), false); |
| | | // } |
| | | |
| | | return true; |
| | | } catch (Exception e) { |