| | |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private LaneService laneService; |
| | | @Autowired |
| | | private StaReserveService staReserveService; |
| | | |
| | | @Override |
| | | public PageResult<Task> pageRel(PageParam<Task, BaseParam> pageParam) { |
| | |
| | | if (null == task) { |
| | | return Boolean.FALSE; |
| | | } |
| | | this.maintainLocSts(task, Boolean.TRUE); |
| | | this.maintainLocAndStaHandler(task, Boolean.TRUE); |
| | | |
| | | task.setTaskSts(TaskStsType.COMPLETE.val()); |
| | | task.setUpdateTime(new Date()); |
| | |
| | | if (null == task) { |
| | | return Boolean.FALSE; |
| | | } |
| | | this.maintainLocSts(task, Boolean.FALSE); |
| | | this.maintainLocAndStaHandler(task, Boolean.FALSE); |
| | | |
| | | task.setTaskSts(TaskStsType.CANCEL.val()); |
| | | task.setUpdateTime(new Date()); |
| | |
| | | return this.list(wrapper).stream().findFirst().orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public void maintainLocAndSta(Task task) { |
| | | if (null == task) { |
| | | return; |
| | | } |
| | | if (!task.getTaskSts().equals(TaskStsType.COMPLETE.val())) { |
| | | return; |
| | | } |
| | | Date now = new Date(); |
| | | // loc status |
| | | Loc oriLoc = null; |
| | | Loc destLoc = null; |
| | | Sta oriSta = null; |
| | | Sta destSta = null; |
| | | switch (Objects.requireNonNull(TaskTypeType.get(task.getTaskTypeEl()))) { |
| | | case LOC_TO_LOC: |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | if (oriLoc.getLocSts().equals(LocStsType.PAKOUT.val())) { |
| | | oriLoc.setLocSts(LocStsType.IDLE.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | log.error("Loc [{}] 库位修改状态失败", task.getOriLoc$()); |
| | | } |
| | | } |
| | | |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | if (destLoc.getLocSts().equals(LocStsType.PAKIN.val())) { |
| | | destLoc.setLocSts(LocStsType.STOCK.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | log.error("Loc [{}] 库位修改状态失败", task.getDestLoc$()); |
| | | } |
| | | } |
| | | break; |
| | | case LOC_TO_STA: |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | if (oriLoc.getLocSts().equals(LocStsType.PAKOUT.val())) { |
| | | oriLoc.setLocSts(LocStsType.IDLE.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | log.error("Loc [{}] 库位修改状态失败", task.getOriLoc$()); |
| | | } |
| | | } |
| | | |
| | | destSta = staService.getById(task.getDestSta()); |
| | | staReserveService.confirmStaReserve(destSta, task, 1, StaReserveType.IN); |
| | | break; |
| | | case STA_TO_LOC: |
| | | oriSta = staService.getById(task.getOriSta()); |
| | | staReserveService.confirmStaReserve(oriSta, task, 1, StaReserveType.OUT); |
| | | |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | if (destLoc.getLocSts().equals(LocStsType.PAKIN.val())) { |
| | | destLoc.setLocSts(LocStsType.STOCK.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | log.error("Loc [{}] 库位修改状态失败", task.getDestLoc$()); |
| | | } |
| | | } |
| | | break; |
| | | case STA_TO_STA: |
| | | oriSta = staService.getById(task.getOriSta()); |
| | | staReserveService.confirmStaReserve(oriSta, task, 1, StaReserveType.OUT); |
| | | |
| | | destSta = staService.getById(task.getDestSta()); |
| | | staReserveService.confirmStaReserve(destSta, task, 1, StaReserveType.IN); |
| | | break; |
| | | case TO_CHARGE: |
| | | case TO_STANDBY: |
| | | case MOVE: |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | @Transactional |
| | | public void maintainLocSts(Task task, Boolean complete) { |
| | | public void maintainLocAndStaHandler(Task task, Boolean complete) { |
| | | Loc oriLoc = null; Loc destLoc = null; |
| | | Sta oriSta = null; Sta destSta = null; |
| | | Date now = new Date(); |
| | |
| | | } |
| | | |
| | | destSta = staService.getById(task.getDestSta()); |
| | | destSta.setStaSts(complete?StaStsType.STOCK.val():StaStsType.IDLE.val()); |
| | | destSta.setUpdateTime(now); |
| | | if (!staService.updateById(destSta)) { |
| | | throw new BusinessException("Sta [" + destSta.getStaNo() + "] 站点修改状态失败 !!!"); |
| | | if (complete) { |
| | | staReserveService.confirmStaReserve(destSta, task, 1, StaReserveType.IN); |
| | | } else { |
| | | staReserveService.cancelStaReserve(destSta, task, 1, StaReserveType.IN); |
| | | } |
| | | break; |
| | | case STA_TO_LOC: |
| | | oriSta = staService.getById(task.getOriSta()); |
| | | oriSta.setStaSts(complete?StaStsType.IDLE.val():StaStsType.STOCK.val()); |
| | | oriSta.setUpdateTime(now); |
| | | if (!staService.updateById(oriSta)) { |
| | | throw new BusinessException("Sta [" + oriSta.getStaNo() + "] 站点修改状态失败 !!!"); |
| | | if (complete) { |
| | | staReserveService.confirmStaReserve(oriSta, task, 1, StaReserveType.OUT); |
| | | } else { |
| | | staReserveService.cancelStaReserve(oriSta, task, 1, StaReserveType.OUT); |
| | | } |
| | | |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | |
| | | break; |
| | | case STA_TO_STA: |
| | | oriSta = staService.getById(task.getOriSta()); |
| | | oriSta.setStaSts(complete?StaStsType.IDLE.val():StaStsType.STOCK.val()); |
| | | oriSta.setUpdateTime(now); |
| | | if (!staService.updateById(oriSta)) { |
| | | throw new BusinessException("Sta [" + oriSta.getStaNo() + "] 站点修改状态失败 !!!"); |
| | | if (complete) { |
| | | staReserveService.confirmStaReserve(oriSta, task, 1, StaReserveType.OUT); |
| | | } else { |
| | | staReserveService.cancelStaReserve(oriSta, task, 1, StaReserveType.OUT); |
| | | } |
| | | |
| | | destSta = staService.getById(task.getDestSta()); |
| | | destSta.setStaSts(complete?StaStsType.STOCK.val():StaStsType.IDLE.val()); |
| | | destSta.setUpdateTime(now); |
| | | if (!staService.updateById(destSta)) { |
| | | throw new BusinessException("Sta [" + destSta.getStaNo() + "] 站点修改状态失败 !!!"); |
| | | if (complete) { |
| | | staReserveService.confirmStaReserve(destSta, task, 1, StaReserveType.IN); |
| | | } else { |
| | | staReserveService.cancelStaReserve(destSta, task, 1, StaReserveType.IN); |
| | | } |
| | | break; |
| | | case TO_CHARGE: |