| | |
| | | public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService { |
| | | |
| | | @Autowired |
| | | private BusService busService; |
| | | @Autowired |
| | | private CodeService codeService; |
| | | @Autowired |
| | | private LocService locService; |
| | |
| | | if (!this.updateById(task)) { |
| | | throw new CoolException(BaseRes.ERROR); |
| | | } |
| | | busService.checkoutComplete(task.getBusId()); |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | |
| | | if (!this.updateById(task)) { |
| | | throw new CoolException(BaseRes.ERROR); |
| | | } |
| | | busService.checkoutComplete(task.getBusId()); |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | |
| | | if (null == codeId) { |
| | | return null; |
| | | } |
| | | return laneService.search(codeService.getById(codeId).getData()); |
| | | return laneService.search(codeService.getCacheById(codeId).getData()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (null == codeId) { |
| | | return null; |
| | | } |
| | | return laneService.search(codeService.getById(codeId).getData()); |
| | | return laneService.search(codeService.getCacheById(codeId).getData()); |
| | | } |
| | | |
| | | @Override |
| | | public List<Task> findTasksByLaneHash(String laneHash) { |
| | | public List<Task> findRunningTasksByLaneHash(String laneHash) { |
| | | if (Cools.isEmpty(laneHash)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | return this.list(new LambdaQueryWrapper<Task>().eq(Task::getOriLaneHash, laneHash).or().eq(Task::getDestLaneHash, laneHash)); |
| | | return this.list(new LambdaQueryWrapper<Task>() |
| | | .in(Task::getTaskSts, TaskStsType.WAITING.val(), TaskStsType.ASSIGN.val(), TaskStsType.PROGRESS.val()) |
| | | .and(i -> { |
| | | i.eq(Task::getOriLaneHash, laneHash).or().eq(Task::getDestLaneHash, laneHash); |
| | | }) |
| | | |
| | | ); |
| | | } |
| | | |
| | | @Override |
| | | public List<Task> findTransportTasksByAgv(Long agvId) { |
| | | if (null == agvId) { |
| | | return new ArrayList<>(); |
| | | } |
| | | LambdaQueryWrapper<Task> wrapper = new LambdaQueryWrapper<Task>().eq(Task::getAgvId, agvId); |
| | | wrapper.in(Task::getTaskSts, TaskStsType.WAITING.val(), TaskStsType.ASSIGN.val(), TaskStsType.PROGRESS.val()); |
| | | wrapper.notIn(Task::getTaskType, TaskTypeType.MOVE.val(), TaskTypeType.TO_CHARGE.val(), TaskTypeType.TO_STANDBY.val()); |
| | | return this.list(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public Task findLatestTask(Long agvId, TaskStsType taskSts) { |
| | | LambdaQueryWrapper<Task> wrapper = new LambdaQueryWrapper<Task>() |
| | | .orderByDesc(Task::getCreateTime) |
| | | .last("limit 0, 1"); |
| | | if (null != agvId) { |
| | | wrapper.eq(Task::getAgvId, agvId); |
| | | } |
| | | if (null != taskSts) { |
| | | wrapper.eq(Task::getTaskSts, taskSts.val()); |
| | | } |
| | | return this.list(wrapper).stream().findFirst().orElse(null); |
| | | } |
| | | |
| | | @Transactional |