| | |
| | | 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)) { |
| | |
| | | long actionPrepareSts = ActionStsType.PREPARE.val(); |
| | | // JSONObject storeDirection = configService.getVal("storeDirection", JSONObject.class); |
| | | int angleOffsetVal = configService.getVal("mapAngleOffsetVal", Integer.class); |
| | | Double defaultShelfDepth = configService.getVal("defaultShelfDepth", Double.class); |
| | | defaultShelfDepth = Optional.ofNullable(defaultShelfDepth).orElse((double) 0); |
| | | // Double defaultShelfDepth = configService.getVal("defaultShelfDepth", Double.class); |
| | | // defaultShelfDepth = Optional.ofNullable(defaultShelfDepth).orElse((double) 0); |
| | | String agvNo = agvService.getAgvNo(agvId); |
| | | // if (!agvService.judgeEnable(agvId)) { |
| | | // throw new CoolException("AGV[" + agvNo + "]当前不可用..."); |
| | |
| | | ActionTypeType.ReadyTakeFromShelvesLoc.desc, // 名称 |
| | | (double) agvDirectionType.val, // 属性值 |
| | | lastCode.getData(), // 地面码 |
| | | JSON.toJSONString(new HeightDepthDto(oriLoc.getOffset(), defaultShelfDepth)), // 动作参数 |
| | | JSON.toJSONString(new HeightDepthDto(oriLoc.getOffset())), // 动作参数 |
| | | ActionTypeType.ReadyTakeFromShelvesLoc.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | |
| | | ActionTypeType.ReadyReleaseToShelvesLoc.desc, // 名称 |
| | | (double) agvDirectionType.val, // 属性值 |
| | | lastCode.getData(), // 地面码 |
| | | JSON.toJSONString(new HeightDepthDto(destLoc.getOffset(), defaultShelfDepth)), // 动作参数 |
| | | JSON.toJSONString(new HeightDepthDto(destLoc.getOffset())), // 动作参数 |
| | | ActionTypeType.ReadyReleaseToShelvesLoc.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | |
| | | // load from sta |
| | | sta = staService.getById(currTask.getOriSta()); |
| | | // reserve to be waiting |
| | | if (!staReserveService.waitingStaReserve(sta, currTask, 1, StaReserveType.OUT)) { |
| | | if (!staReserveService.waitingStaReserve(sta, currTask, currSeg, 1, StaReserveType.OUT)) { |
| | | break; |
| | | } |
| | | // convey plc valid |
| | |
| | | // place to sta |
| | | sta = staService.getById(currTask.getDestSta()); |
| | | // reserve to be waiting |
| | | if (!staReserveService.waitingStaReserve(sta, currTask, 1, StaReserveType.IN)) { |
| | | if (!staReserveService.waitingStaReserve(sta, currTask, currSeg, 1, StaReserveType.IN)) { |
| | | break; |
| | | } |
| | | // convey plc valid |