| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void operateTaskSts(Integer taskId, Boolean finish) { |
| | | Task task = this.getById(taskId); |
| | | Loc oriLoc = null; Loc destLoc = null; |
| | | Sta oriSta = null; Sta destSta = null; |
| | | Date now = new Date(); |
| | | TaskTypeType typeType = TaskTypeType.get(task.getTaskTypeEl()); |
| | | switch (Objects.requireNonNull(typeType)) { |
| | | case LOC_TO_LOC: |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | |
| | | oriLoc.setLocSts(finish?LocStsType.IDLE.val():LocStsType.STOCK.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("Loc [" + task.getOriLoc$() + "] 库位修改状态失败 !!!"); |
| | | } |
| | | |
| | | destLoc.setLocSts(finish?LocStsType.STOCK.val():LocStsType.IDLE.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("Loc [" + task.getDestLoc$() + "] 库位修改状态失败 !!!"); |
| | | } |
| | | break; |
| | | case LOC_TO_STA: |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | oriLoc.setLocSts(finish?LocStsType.IDLE.val():LocStsType.STOCK.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("Loc [" + task.getOriLoc$() + "] 库位修改状态失败 !!!"); |
| | | } |
| | | break; |
| | | case STA_TO_LOC: |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | destLoc.setLocSts(finish?LocStsType.STOCK.val():LocStsType.IDLE.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("Loc [" + task.getDestLoc$() + "] 库位修改状态失败 !!!"); |
| | | } |
| | | break; |
| | | case STA_TO_STA: |
| | | break; |
| | | case TO_CHARGE: |
| | | case TO_STANDBY: |
| | | FuncSta funcSta = funcStaService.getByCodeAndType(task.getDestCode(), FuncStaType.query(typeType).toString()); |
| | | if (!finish) { |
| | | funcSta.setState(FuncStaStateType.IDLE.toString()); |
| | | funcSta.setUpdateTime(now); |
| | | if (!funcStaService.updateById(funcSta)) { |
| | | throw new BusinessException("FuncSta [" + funcSta.getName() + "] 更新状态失败 !!!"); |
| | | } |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | task.setTaskSts(TaskStsType.COMPLETE.val()); |
| | | task.setUpdateTime(now); |
| | | if (!this.updateById(task)) { |
| | | throw new BusinessException(task.getSeqNum() + "任务更新状态失败"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> selectStatByLastSevenDays() { |
| | | return this.baseMapper.selectStatByLastSevenDays(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public Boolean complete(Long taskId, Long userId) { |
| | | Task task = this.getById(taskId); |
| | | if (null == task) { |
| | | return Boolean.FALSE; |
| | | } |
| | | this.maintainLocSts(task, Boolean.TRUE); |
| | | |
| | | task.setTaskSts(TaskStsType.COMPLETE.val()); |
| | | task.setUpdateTime(new Date()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public Boolean cancel(Long taskId, Long userId) { |
| | | Task task = this.getById(taskId); |
| | | if (null == task) { |
| | | return Boolean.FALSE; |
| | | } |
| | | this.maintainLocSts(task, Boolean.FALSE); |
| | | |
| | | task.setTaskSts(TaskStsType.CANCEL.val()); |
| | | task.setUpdateTime(new Date()); |
| | |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | @Transactional |
| | | public void maintainLocSts(Task task, Boolean complete) { |
| | | Loc oriLoc = null; Loc destLoc = null; |
| | | Sta oriSta = null; Sta destSta = null; |
| | | Date now = new Date(); |
| | | TaskTypeType typeType = TaskTypeType.get(task.getTaskTypeEl()); |
| | | switch (Objects.requireNonNull(typeType)) { |
| | | case LOC_TO_LOC: |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | |
| | | oriLoc.setLocSts(complete?LocStsType.IDLE.val():LocStsType.STOCK.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("Loc [" + task.getOriLoc$() + "] 库位修改状态失败 !!!"); |
| | | } |
| | | |
| | | destLoc.setLocSts(complete?LocStsType.STOCK.val():LocStsType.IDLE.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("Loc [" + task.getDestLoc$() + "] 库位修改状态失败 !!!"); |
| | | } |
| | | break; |
| | | case LOC_TO_STA: |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | oriLoc.setLocSts(complete?LocStsType.IDLE.val():LocStsType.STOCK.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("Loc [" + task.getOriLoc$() + "] 库位修改状态失败 !!!"); |
| | | } |
| | | break; |
| | | case STA_TO_LOC: |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | destLoc.setLocSts(complete?LocStsType.STOCK.val():LocStsType.IDLE.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("Loc [" + task.getDestLoc$() + "] 库位修改状态失败 !!!"); |
| | | } |
| | | break; |
| | | case STA_TO_STA: |
| | | break; |
| | | case TO_CHARGE: |
| | | case TO_STANDBY: |
| | | FuncSta funcSta = funcStaService.getByCodeAndType(task.getDestCode(), FuncStaType.query(typeType).toString()); |
| | | if (!complete) { |
| | | funcSta.setState(FuncStaStateType.IDLE.toString()); |
| | | funcSta.setUpdateTime(now); |
| | | if (!funcStaService.updateById(funcSta)) { |
| | | throw new BusinessException("FuncSta [" + funcSta.getName() + "] 更新状态失败 !!!"); |
| | | } |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |