| | |
| | | import com.zy.acs.manager.core.domain.TaskPosDto; |
| | | import com.zy.acs.manager.core.integrate.conveyor.ConveyorStationService; |
| | | import com.zy.acs.manager.core.service.astart.MapDataDispatcher; |
| | | import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam; |
| | | import com.zy.acs.manager.core.integrate.dto.OpenBusSubmitParam; |
| | | import com.zy.acs.manager.manager.entity.*; |
| | | import com.zy.acs.manager.manager.enums.*; |
| | | import com.zy.acs.manager.manager.service.*; |
| | |
| | | @Transactional |
| | | public Bus generateBusAndTask(OpenBusSubmitParam busSubmitParam, String memo) { |
| | | String errorMsg = busService.checkoutValid(busSubmitParam); |
| | | Boolean maintainLocSts = configService.getVal("maintainLocSts", Boolean.class); |
| | | if (!Cools.isEmpty(errorMsg)) { |
| | | throw new BusinessException(errorMsg); |
| | | } |
| | | String batch = busSubmitParam.getBatch(); |
| | | List<TaskDto> taskDtoList = busSubmitParam.getTaskList(); |
| | | String batchNo = busSubmitParam.getBatchNo(); |
| | | List<TaskDto> taskDtoList = busSubmitParam.getTasks(); |
| | | if (Cools.isEmpty(taskDtoList)) { |
| | | throw new BusinessException("taskList can't be empty!"); |
| | | } |
| | |
| | | Date now = new Date(); |
| | | Bus bus = new Bus(); |
| | | bus.setUuid(String.valueOf(snowflakeIdWorker.nextId()).substring(3)); |
| | | bus.setBusNo(batch); |
| | | bus.setBusNo(batchNo); |
| | | bus.setStartTime(now); |
| | | bus.setBusSts(BusStsType.RECEIVE.val()); |
| | | bus.setMemo(memo); |
| | |
| | | Sta destSta = null; |
| | | switch (TaskTypeType.get(task.getTaskTypeEl())) { |
| | | case LOC_TO_LOC: |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) { |
| | | throw new BusinessException("oriLoc:" + task.getOriLoc$() + " is not in STOCK status"); |
| | | } |
| | | oriLoc.setLocSts(LocStsType.PAKOUT.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("oriLoc:" + task.getOriLoc$() + " failed to update"); |
| | | } |
| | | if (maintainLocSts) { |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) { |
| | | throw new BusinessException("oriLoc:" + task.getOriLoc$() + " is not in STOCK status"); |
| | | } |
| | | oriLoc.setLocSts(LocStsType.PAKOUT.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("oriLoc:" + task.getOriLoc$() + " failed to update"); |
| | | } |
| | | |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) { |
| | | throw new BusinessException("destLoc:" + task.getDestLoc$() + " is not in IDLE status"); |
| | | } |
| | | destLoc.setLocSts(LocStsType.PAKIN.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("destLoc:" + task.getDestLoc$() + " failed to update"); |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) { |
| | | throw new BusinessException("destLoc:" + task.getDestLoc$() + " is not in IDLE status"); |
| | | } |
| | | destLoc.setLocSts(LocStsType.PAKIN.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("destLoc:" + task.getDestLoc$() + " failed to update"); |
| | | } |
| | | } |
| | | break; |
| | | case LOC_TO_STA: |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) { |
| | | throw new BusinessException("oriLoc:" + task.getOriLoc$() + " is not in STOCK status"); |
| | | } |
| | | oriLoc.setLocSts(LocStsType.PAKOUT.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("oriLoc:" + task.getOriLoc$() + " failed to update"); |
| | | if (maintainLocSts) { |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) { |
| | | throw new BusinessException("oriLoc:" + task.getOriLoc$() + " is not in STOCK status"); |
| | | } |
| | | oriLoc.setLocSts(LocStsType.PAKOUT.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("oriLoc:" + task.getOriLoc$() + " failed to update"); |
| | | } |
| | | } |
| | | |
| | | destSta = staService.getById(task.getDestSta()); |
| | |
| | | throw new BusinessException("oriSta:" + task.getOriSta$() + " failed to reserve"); |
| | | } |
| | | |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) { |
| | | throw new BusinessException("destLoc:" + task.getDestLoc$() + " is not in IDLE status"); |
| | | } |
| | | destLoc.setLocSts(LocStsType.PAKIN.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("destLoc:" + task.getDestLoc$() + " failed to update"); |
| | | if (maintainLocSts) { |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) { |
| | | throw new BusinessException("destLoc:" + task.getDestLoc$() + " is not in IDLE status"); |
| | | } |
| | | destLoc.setLocSts(LocStsType.PAKIN.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("destLoc:" + task.getDestLoc$() + " failed to update"); |
| | | } |
| | | } |
| | | break; |
| | | case STA_TO_STA: |
| | |
| | | task.setPriority(taskType.equals(TaskTypeType.TO_CHARGE)?2:1); |
| | | task.setTaskSts(TaskStsType.ASSIGN.val()); |
| | | task.setTaskType(taskType.val()); |
| | | task.setUplinkSts(TaskUplinkStateType.SKIPPED.toString()); |
| | | task.setIoTime(now); |
| | | task.setStartTime(now); |
| | | if (!taskService.save(task)) { |
| | |
| | | } |
| | | |
| | | // 作业点动作 |
| | | AgvDirectionType agvDirectionType; |
| | | ActuatorDirectionType actuatorDirectionType; |
| | | Double staWorkDirection; |
| | | AgvBackpackType backpackType = AgvBackpackType.query(segment.getBackpack()); |
| | | switch (Objects.requireNonNull(TaskPosDto.queryPosType(segment.getPosType()))) { |
| | |
| | | // 货架取货 |
| | | Loc oriLoc = locService.getById(task.getOriLoc()); |
| | | // 计算左右方向 |
| | | agvDirectionType = mapService.calculateAgvWorkDirectionByShelf(oriLoc, lastCode); |
| | | actuatorDirectionType = ActuatorDirectionType.fromVal(oriLoc.getCompDirect()); |
| | | // actuatorDirectionType = mapService.calculateAgvWorkDirectionByShelf(oriLoc, lastCode); |
| | | actionList.add(new Action( |
| | | null, // 编号 |
| | | task.getBusId(), // 总线 |
| | |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.ReadyTakeFromShelvesLoc.desc, // 名称 |
| | | (double) agvDirectionType.val, // 属性值 |
| | | (double) actuatorDirectionType.val, // 属性值 |
| | | lastCode.getData(), // 地面码 |
| | | JSON.toJSONString(new HeightDepthDto(oriLoc.getOffset())), // 动作参数 |
| | | ActionTypeType.ReadyTakeFromShelvesLoc.val(), // 动作类型 |
| | |
| | | // 货架放货 |
| | | Loc destLoc = locService.getById(task.getDestLoc()); |
| | | // 计算左右方向 |
| | | agvDirectionType = mapService.calculateAgvWorkDirectionByShelf(destLoc, lastCode); |
| | | actuatorDirectionType = ActuatorDirectionType.fromVal(destLoc.getCompDirect()); |
| | | // actuatorDirectionType = mapService.calculateAgvWorkDirectionByShelf(destLoc, lastCode); |
| | | actionList.add(new Action( |
| | | null, // 编号 |
| | | task.getBusId(), // 总线 |
| | |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.ReadyReleaseToShelvesLoc.desc, // 名称 |
| | | (double) agvDirectionType.val, // 属性值 |
| | | (double) actuatorDirectionType.val, // 属性值 |
| | | lastCode.getData(), // 地面码 |
| | | JSON.toJSONString(new HeightDepthDto(destLoc.getOffset())), // 动作参数 |
| | | ActionTypeType.ReadyReleaseToShelvesLoc.val(), // 动作类型 |
| | |
| | | lastDirection = oriStaWorkDirection; |
| | | } |
| | | // 计算货叉工作方向 |
| | | staWorkDirection = mapService.calculateAgvWorkDirectionByStation(oriStaWorkDirection, lastDirection); |
| | | actuatorDirectionType = ActuatorDirectionType.fromVal(oriSta.getActDir()); |
| | | // staWorkDirection = mapService.calculateAgvWorkDirectionByStation(oriStaWorkDirection, lastDirection); |
| | | actionList.add(new Action( |
| | | null, // 编号 |
| | | task.getBusId(), // 总线 |
| | |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.ReadyTakeFromConveyorSta.desc, // 名称 |
| | | staWorkDirection, // 属性值 |
| | | (double) actuatorDirectionType.val, // 属性值 |
| | | lastCode.getData(), // 地面码 |
| | | JSON.toJSONString(new HeightDepthDto(oriSta.getHeight(), Optional.ofNullable(oriSta.getDepth()).orElse((double) 0))), // 动作参数 |
| | | ActionTypeType.ReadyTakeFromConveyorSta.val(), // 动作类型 |
| | |
| | | )); |
| | | } |
| | | // 计算货叉工作方向 |
| | | staWorkDirection = mapService.calculateAgvWorkDirectionByStation(destStaWorkDirection, lastDirection); |
| | | // staWorkDirection = mapService.calculateAgvWorkDirectionByStation(destStaWorkDirection, lastDirection); |
| | | actuatorDirectionType = ActuatorDirectionType.fromVal(destSta.getActDir()); |
| | | actionList.add(new Action( |
| | | null, // 编号 |
| | | task.getBusId(), // 总线 |
| | |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.ReadyReleaseToConveyorSta.desc, // 名称 |
| | | staWorkDirection, // 属性值 |
| | | (double) actuatorDirectionType.val, // 属性值 |
| | | lastCode.getData(), // 地面码 |
| | | JSON.toJSONString(new HeightDepthDto(destSta.getHeight(), Optional.ofNullable(destSta.getDepth()).orElse((double) 0))), // 动作参数 |
| | | ActionTypeType.ReadyReleaseToConveyorSta.val(), // 动作类型 |