| | |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.SnowflakeIdWorker; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.acs.manager.common.domain.BaseParam; |
| | | import com.zy.acs.manager.common.domain.PageParam; |
| | | import com.zy.acs.manager.common.domain.PageResult; |
| | | import com.zy.acs.manager.common.exception.BusinessException; |
| | | import com.zy.acs.manager.core.domain.Lane; |
| | | import com.zy.acs.manager.core.service.LaneService; |
| | |
| | | public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService { |
| | | |
| | | @Autowired |
| | | private BusService busService; |
| | | @Autowired |
| | | private CodeService codeService; |
| | | @Autowired |
| | | private LocService locService; |
| | |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private LaneService laneService; |
| | | |
| | | @Override |
| | | public PageResult<Task> pageRel(PageParam<Task, BaseParam> pageParam) { |
| | | return new PageResult<>(this.baseMapper.selectPageRel(pageParam, pageParam.checkoutMap()), pageParam.getTotal()); |
| | | } |
| | | |
| | | @Override |
| | | public synchronized String generateSeqNum() { |
| | |
| | | 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 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Task> findRunningTasksByAgv(Long agvId) { |
| | | public List<Task> findTransportTasksByAgv(Long agvId) { |
| | | if (null == agvId) { |
| | | return new ArrayList<>(); |
| | | } |
| | |
| | | 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 Integer findTransportTasksCountByAgv(Long agvId) { |
| | | 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.count(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 |
| | |
| | | oriLoc.setLocSts(complete?LocStsType.IDLE.val():LocStsType.STOCK.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("Loc [" + task.getOriLoc$() + "] 库位修改状态失败 !!!"); |
| | | 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 [" + task.getDestLoc$() + "] 库位修改状态失败 !!!"); |
| | | throw new BusinessException("Loc [" + destLoc.getLocNo() + "] 库位修改状态失败 !!!"); |
| | | } |
| | | break; |
| | | case LOC_TO_STA: |
| | |
| | | oriLoc.setLocSts(complete?LocStsType.IDLE.val():LocStsType.STOCK.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("Loc [" + task.getOriLoc$() + "] 库位修改状态失败 !!!"); |
| | | throw new BusinessException("Loc [" + oriLoc.getLocNo() + "] 库位修改状态失败 !!!"); |
| | | } |
| | | |
| | | 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() + "] 站点修改状态失败 !!!"); |
| | | } |
| | | 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() + "] 站点修改状态失败 !!!"); |
| | | } |
| | | |
| | | 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$() + "] 库位修改状态失败 !!!"); |
| | | throw new BusinessException("Loc [" + destLoc.getLocNo() + "] 库位修改状态失败 !!!"); |
| | | } |
| | | 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() + "] 站点修改状态失败 !!!"); |
| | | } |
| | | |
| | | 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() + "] 站点修改状态失败 !!!"); |
| | | } |
| | | break; |
| | | case TO_CHARGE: |
| | | case TO_STANDBY: |