| | |
| | | if (Objects.isNull(tasks)) { |
| | | throw new CoolException("任务已处执行状态不可一键置顶!!"); |
| | | } |
| | | //判断子任务,修改任务优先级 |
| | | modiftyTaskSort(tasks); |
| | | |
| | | if (!LocUtils.isShallowLoc(tasks.getOrgLoc())) { |
| | | String shallowLoc = LocUtils.getShallowLoc(tasks.getOrgLoc()); |
| | | if (!taskService.updateById(tasks)) { |
| | | throw new CoolException("置顶失败!!"); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 手动完成任务 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Task operateComplete(Long id) { |
| | | List<Integer> longs = Arrays.asList(TaskStsType.GENERATE_IN.id, TaskStsType.GENERATE_OUT.id); |
| | | Task task = taskService.getOne(new LambdaQueryWrapper<Task>() |
| | | .eq(Task::getId, id) |
| | | .in(Task::getTaskStatus, longs)); |
| | | |
| | | if (Objects.isNull(task)) { |
| | | throw new CoolException("当前任务正在执行中,不可取消!!"); |
| | | } |
| | | |
| | | modiftyTaskSort(task); |
| | | |
| | | task.setTaskStatus(task.getTaskType() < 100 ? TaskStsType.COMPLETE_IN.id : TaskStsType.COMPLETE_OUT.id); |
| | | if (!this.updateById(task)) { |
| | | throw new CoolException("完成任务失败"); |
| | | } |
| | | return task; |
| | | } |
| | | |
| | | /** |
| | | * 修改任务优先级 |
| | | * @param task |
| | | */ |
| | | private Task modiftyTaskSort(Task task) { |
| | | String curLoc; |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) { |
| | | curLoc = task.getTargLoc(); |
| | | } else { |
| | | curLoc = task.getOrgLoc(); |
| | | } |
| | | if (!LocUtils.isShallowLoc(curLoc)) { |
| | | String shallowLoc = LocUtils.getShallowLoc(curLoc); |
| | | if (StringUtils.isNotBlank(shallowLoc)) { |
| | | throw new CoolException("数据异常,请联系管理员!"); |
| | | } |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLoc)); |
| | | if (Objects.isNull(loc)) { |
| | | throw new CoolException("数据错误,库位不存在!!"); |
| | |
| | | .or() |
| | | .eq(Task::getTargLoc, loc.getCode())); |
| | | if (Objects.isNull(serviceOne)) { |
| | | tasks.setSort(999); |
| | | task.setSort(999); |
| | | } else { |
| | | int i = serviceOne.getSort() - 1; |
| | | tasks.setSort(i); |
| | | task.setSort(i); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!taskService.updateById(tasks)) { |
| | | throw new CoolException("置顶失败!!"); |
| | | } |
| | | return null; |
| | | return task; |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |