| | |
| | | import com.zy.acs.manager.manager.enums.*; |
| | | import com.zy.acs.manager.manager.mapper.TaskMapper; |
| | | import com.zy.acs.manager.manager.service.*; |
| | | import com.zy.acs.manager.system.service.ConfigService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private ActionService actionService; |
| | | @Autowired |
| | | private TravelService travelService; |
| | | @Autowired |
| | | private ConfigService configService; |
| | | |
| | | @Override |
| | | public PageResult<Task> pageRel(PageParam<Task, BaseParam> pageParam) { |
| | |
| | | if (!task.getTaskSts().equals(TaskStsType.COMPLETE.val())) { |
| | | return; |
| | | } |
| | | Boolean maintainLocSts = configService.getVal("maintainLocSts", Boolean.class); |
| | | Date now = new Date(); |
| | | // loc status |
| | | Loc oriLoc = 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$()); |
| | | if (maintainLocSts) { |
| | | 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$()); |
| | | 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$()); |
| | | if (maintainLocSts) { |
| | | 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$()); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | 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$()); |
| | | if (maintainLocSts) { |
| | | 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; |
| | |
| | | public void maintainLocAndStaHandler(Task task, Boolean complete) { |
| | | Loc oriLoc = null; Loc destLoc = null; |
| | | Sta oriSta = null; Sta destSta = null; |
| | | Boolean maintainLocSts = configService.getVal("maintainLocSts", Boolean.class); |
| | | 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()); |
| | | if (maintainLocSts) { |
| | | 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 [" + oriLoc.getLocNo() + "] 库位修改状态失败 !!!"); |
| | | } |
| | | oriLoc.setLocSts(complete?LocStsType.IDLE.val():LocStsType.STOCK.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("Loc [" + oriLoc.getLocNo() + "] 库位修改状态失败 !!!"); |
| | | } |
| | | |
| | | destLoc.setLocSts(complete?LocStsType.STOCK.val():LocStsType.IDLE.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("Loc [" + destLoc.getLocNo() + "] 库位修改状态失败 !!!"); |
| | | destLoc.setLocSts(complete?LocStsType.STOCK.val():LocStsType.IDLE.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("Loc [" + destLoc.getLocNo() + "] 库位修改状态失败 !!!"); |
| | | } |
| | | } |
| | | 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 [" + oriLoc.getLocNo() + "] 库位修改状态失败 !!!"); |
| | | if (maintainLocSts) { |
| | | 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 [" + oriLoc.getLocNo() + "] 库位修改状态失败 !!!"); |
| | | } |
| | | } |
| | | |
| | | destSta = staService.getById(task.getDestSta()); |
| | |
| | | staReserveService.cancelStaReserve(oriSta, task, 1, StaReserveType.OUT); |
| | | } |
| | | |
| | | 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 [" + destLoc.getLocNo() + "] 库位修改状态失败 !!!"); |
| | | if (maintainLocSts) { |
| | | 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 [" + destLoc.getLocNo() + "] 库位修改状态失败 !!!"); |
| | | } |
| | | } |
| | | break; |
| | | case STA_TO_STA: |