| | |
| | | if (!busService.save(bus)) { |
| | | throw new BusinessException("Internal Server Error!"); |
| | | } |
| | | Boolean locStaStatusCheck = configService.getVal("LOC_STA_STATUS_CHECK", Boolean.class, false); |
| | | |
| | | |
| | | // 保存任务 |
| | | for (Task task : taskList) { |
| | |
| | | switch (TaskTypeType.get(task.getTaskTypeEl())) { |
| | | case LOC_TO_LOC: |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) { |
| | | if (locStaStatusCheck && !oriLoc.getLocSts().equals(LocStsType.STOCK.val())) { |
| | | throw new BusinessException("oriLoc:" + task.getOriLoc$() + " is not in STOCK status"); |
| | | } |
| | | oriLoc.setLocSts(LocStsType.PAKOUT.val()); |
| | |
| | | } |
| | | |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) { |
| | | if (locStaStatusCheck && !destLoc.getLocSts().equals(LocStsType.IDLE.val())) { |
| | | throw new BusinessException("destLoc:" + task.getDestLoc$() + " is not in IDLE status"); |
| | | } |
| | | destLoc.setLocSts(LocStsType.PAKIN.val()); |
| | |
| | | break; |
| | | case LOC_TO_STA: |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) { |
| | | if (locStaStatusCheck && !oriLoc.getLocSts().equals(LocStsType.STOCK.val())) { |
| | | throw new BusinessException("oriLoc:" + task.getOriLoc$() + " is not in STOCK status"); |
| | | } |
| | | oriLoc.setLocSts(LocStsType.PAKOUT.val()); |
| | |
| | | } |
| | | |
| | | destSta = staService.getById(task.getDestSta()); |
| | | if (!destSta.getStaSts().equals(StaStsType.IDLE.val())) { |
| | | if (locStaStatusCheck && !destSta.getStaSts().equals(StaStsType.IDLE.val())) { |
| | | throw new BusinessException("destSta:" + task.getDestSta$() + " is not in IDLE status"); |
| | | } |
| | | destSta.setStaSts(StaStsType.READY_RELEASE.val()); |
| | |
| | | break; |
| | | case STA_TO_LOC: |
| | | oriSta = staService.getById(task.getOriSta()); |
| | | if (!oriSta.getStaSts().equals(StaStsType.STOCK.val())) { |
| | | if (locStaStatusCheck && !oriSta.getStaSts().equals(StaStsType.STOCK.val())) { |
| | | throw new BusinessException("oriSta:" + task.getOriSta$() + " is not in STOCK status"); |
| | | } |
| | | oriSta.setStaSts(StaStsType.READY_TAKE.val()); |
| | |
| | | } |
| | | |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) { |
| | | if (locStaStatusCheck && !destLoc.getLocSts().equals(LocStsType.IDLE.val())) { |
| | | throw new BusinessException("destLoc:" + task.getDestLoc$() + " is not in IDLE status"); |
| | | } |
| | | destLoc.setLocSts(LocStsType.PAKIN.val()); |
| | |
| | | break; |
| | | case STA_TO_STA: |
| | | oriSta = staService.getById(task.getOriSta()); |
| | | if (!oriSta.getStaSts().equals(StaStsType.STOCK.val())) { |
| | | if (locStaStatusCheck && !oriSta.getStaSts().equals(StaStsType.STOCK.val())) { |
| | | throw new BusinessException("oriSta:" + task.getOriSta$() + " is not in STOCK status"); |
| | | } |
| | | oriSta.setStaSts(StaStsType.READY_TAKE.val()); |
| | |
| | | } |
| | | |
| | | destSta = staService.getById(task.getDestSta()); |
| | | if (!destSta.getStaSts().equals(StaStsType.IDLE.val())) { |
| | | if (locStaStatusCheck && !destSta.getStaSts().equals(StaStsType.IDLE.val())) { |
| | | throw new BusinessException("destSta:" + task.getDestSta$() + " is not in IDLE status"); |
| | | } |
| | | destSta.setStaSts(StaStsType.READY_RELEASE.val()); |
| | |
| | | if (!taskService.updateById(task)) { |
| | | throw new BusinessException("seqNum: " + task.getSeqNum() + " failed to update"); |
| | | } |
| | | report(task, TaskReportStsType.START); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("mainService.infuseAgvForTask", e); |
| | |
| | | runToWaitHeight = "800"; |
| | | } |
| | | Double runToWaitHeightValue = configService.getVal("RunToWaitHeightValue", Double.class); |
| | | if (Cools.isEmpty(runToWaitHeight) || runToWaitHeightValue == 0) { |
| | | if (runToWaitHeightValue == 0) { |
| | | runToWaitHeightValue = 1D; |
| | | } |
| | | // 修复空指针异常:检查lastCode是否为null |
| | |
| | | throw new RuntimeException("generateAction method caught an exception, rolling back transaction.", e); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Transactional |
| | | public void publishAction(String actionGroupId) { |
| | |
| | | if (agv_11_up.getCompleteType().equals(AgvCompleteType.RELEASE_FROM_SHELVES_COMPLETE)) { |
| | | WebsocketServiceImpl.taskShelfBarcode = agv_11_up.getLocCode(); |
| | | |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, String.valueOf(Integer.parseInt(agv_11_up.getLocCode())))); |
| | | if (null == loc) { |
| | | log.warn("Agv [{}] 上报往货架放货完成时,库位码[{}]无效。", protocol.getAgvNo(), agv_11_up.getLocCode()); |
| | | } else { |
| | | List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo); |
| | | for (Long taskId : taskIds) { |
| | | Task task = taskService.getById(taskId); |
| | | if (task.getDestLoc().equals(loc.getId())) { |
| | | // Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, String.valueOf(Integer.parseInt(agv_11_up.getLocCode())))); |
| | | // if (null == loc) { |
| | | // log.warn("Agv [{}] 上报往货架放货完成时,库位码[{}]无效。", protocol.getAgvNo(), agv_11_up.getLocCode()); |
| | | // } else { |
| | | // List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo); |
| | | // for (Long taskId : taskIds) { |
| | | // Task task = taskService.getById(taskId); |
| | | // if (task.getDestLoc().equals(loc.getId())) { |
| | | // |
| | | // Action action = actionService.getOne(new LambdaQueryWrapper<Action>() |
| | | // .eq(Action::getTaskId, task.getId()) |
| | | // .eq(Action::getActionType, ActionTypeType.ReadyReleaseToShelvesLoc.val()) |
| | | // .eq(Action::getActionSts, ActionStsType.ISSUED.val()) |
| | | // ); |
| | | // |
| | | // if (null != action) { |
| | | // action.setActionSts(ActionStsType.FINISH.val()); |
| | | // action.setEndTime(now); |
| | | // action.setUpdateTime(now); |
| | | // if (!actionService.updateById(action)) { |
| | | // log.error("Action [{}] 更新失败 !!!", action.getPriority() + " - " + action.getName()); |
| | | // } |
| | | // } |
| | | // //插入一条 |
| | | // report(task, TaskReportStsType.END); |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | Action action = actionService.getOne(new LambdaQueryWrapper<Action>() |
| | | .eq(Action::getTaskId, task.getId()) |
| | | .eq(Action::getActionType, ActionTypeType.ReadyReleaseToShelvesLoc.val()) |
| | | .eq(Action::getActionSts, ActionStsType.ISSUED.val()) |
| | | ); |
| | | |
| | | if (null != action) { |
| | | action.setActionSts(ActionStsType.FINISH.val()); |
| | | action.setEndTime(now); |
| | | action.setUpdateTime(now); |
| | | if (!actionService.updateById(action)) { |
| | | log.error("Action [{}] 更新失败 !!!", action.getPriority() + " - " + action.getName()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo); |
| | | for (Long taskId : taskIds) { |
| | | Task task = taskService.getById(taskId); |
| | | report(task, TaskReportStsType.END); |
| | | } |
| | | } |
| | | |
| | |
| | | if (agv_11_up.getCompleteType().equals(AgvCompleteType.TAKE_FROM_SHELVES_COMPLETE)) { |
| | | WebsocketServiceImpl.taskShelfBarcode = agv_11_up.getLocCode(); |
| | | |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, String.valueOf(Integer.parseInt(agv_11_up.getLocCode())))); |
| | | if (null == loc) { |
| | | log.warn("Agv [{}] 上报从货架取货完成,库位码[{}]无效。", protocol.getAgvNo(), agv_11_up.getLocCode()); |
| | | } else { |
| | | // Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, String.valueOf(Integer.parseInt(agv_11_up.getLocCode())))); |
| | | // if (null == loc) { |
| | | // log.warn("Agv [{}] 上报从货架取货完成,库位码[{}]无效。", protocol.getAgvNo(), agv_11_up.getLocCode()); |
| | | // } else { |
| | | // |
| | | // List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo); |
| | | // for (Long taskId : taskIds) { |
| | | // Task task = taskService.getById(taskId); |
| | | // if (task.getOriLoc().equals(loc.getId())) { |
| | | // |
| | | // Action action = actionService.getOne(new LambdaQueryWrapper<Action>() |
| | | // .eq(Action::getTaskId, task.getId()) |
| | | // .eq(Action::getActionType, ActionTypeType.ReadyTakeFromShelvesLoc.val()) |
| | | // .eq(Action::getActionSts, ActionStsType.ISSUED.val()) |
| | | // ); |
| | | // if (null != action) { |
| | | // action.setActionSts(ActionStsType.FINISH.val()); |
| | | // action.setEndTime(now); |
| | | // action.setUpdateTime(now); |
| | | // if (!actionService.updateById(action)) { |
| | | // log.error("Action [{}] 更新失败 !!!", action.getPriority() + " - " + action.getName()); |
| | | // } |
| | | // } |
| | | // report(task, TaskReportStsType.OTBIN); |
| | | // } |
| | | // } |
| | | // } |
| | | List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo); |
| | | for (Long taskId : taskIds) { |
| | | Task task = taskService.getById(taskId); |
| | | report(task, TaskReportStsType.OTBIN); |
| | | } |
| | | |
| | | List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo); |
| | | for (Long taskId : taskIds) { |
| | | Task task = taskService.getById(taskId); |
| | | if (task.getOriLoc().equals(loc.getId())) { |
| | | |
| | | Action action = actionService.getOne(new LambdaQueryWrapper<Action>() |
| | | .eq(Action::getTaskId, task.getId()) |
| | | .eq(Action::getActionType, ActionTypeType.ReadyTakeFromShelvesLoc.val()) |
| | | .eq(Action::getActionSts, ActionStsType.ISSUED.val()) |
| | | ); |
| | | if (null != action) { |
| | | action.setActionSts(ActionStsType.FINISH.val()); |
| | | action.setEndTime(now); |
| | | action.setUpdateTime(now); |
| | | if (!actionService.updateById(action)) { |
| | | log.error("Action [{}] 更新失败 !!!", action.getPriority() + " - " + action.getName()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //从输送线取货完成 |
| | | if (agv_11_up.getCompleteType().equals(AgvCompleteType.TAKE_FROM_STA_COMPLETE)) { |
| | | WebsocketServiceImpl.taskShelfBarcode = agv_11_up.getLocCode(); |
| | | List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo); |
| | | for (Long taskId : taskIds) { |
| | | Task task = taskService.getById(taskId); |
| | | report(task, TaskReportStsType.OTBIN); |
| | | } |
| | | } |
| | | //往输送线放货完成 |
| | | if (agv_11_up.getCompleteType().equals(AgvCompleteType.RELEASE_FROM_STA_COMPLETE)) { |
| | | WebsocketServiceImpl.taskShelfBarcode = agv_11_up.getLocCode(); |
| | | List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo); |
| | | for (Long taskId : taskIds) { |
| | | Task task = taskService.getById(taskId); |
| | | report(task, TaskReportStsType.END); |
| | | } |
| | | } |
| | | |
| | |
| | | log.info("Agv [{}] 料仓信息包 ===>> {}", protocol.getAgvNo(), JSON.toJSONString(agv_70_up)); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Transactional |
| | | public void settleSegmentList(List<Segment> segmentList, String serialNo) { |
| | |
| | | task.setUpdateTime(now); |
| | | if (!taskService.updateById(task)) { |
| | | log.error("Task [{}] 更新失败 !!!", task.getSeqNum()); |
| | | } else { |
| | | log.info("Task [{}] 作业完毕 ==========>> ", task.getSeqNum()); |
| | | // TODO 插入一条上报记录 |
| | | TaskReport taskReport = new TaskReport(); |
| | | taskReport.setAgvId(task.getAgvId()); |
| | | taskReport.setBusNo(task.getBusId$()); |
| | | taskReport.setCreateTime(new Date()); |
| | | taskReport.setDestLoc(task.getDestLoc()); |
| | | taskReport.setDestSta(task.getDestSta()); |
| | | taskReport.setSeqNum(task.getSeqNum()); |
| | | taskReport.setTaskSts(task.getTaskSts()); |
| | | taskReport.setOriLoc(task.getOriLoc()); |
| | | taskReport.setOriSta(task.getOriSta()); |
| | | taskReport.setZpallet(task.getZpallet()); |
| | | if (!taskReportService.save(taskReport)) { |
| | | log.info("TaskReport [{}] 插入失败 ==========>> ", JSON.toJSONString(taskReport)); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | segmentService.processNext(segmentList); |
| | | } |
| | | |
| | | /** |
| | | * 上报给上游系统,就是插入一条数据到上报表 |
| | | */ |
| | | private void report(Task task, TaskReportStsType taskReportStsType) { |
| | | // TODO 插入一条上报记录 |
| | | TaskReport taskReport = new TaskReport(); |
| | | taskReport.setAgvId(task.getAgvId()); |
| | | taskReport.setBusNo(task.getBusId$()); |
| | | taskReport.setCreateTime(new Date()); |
| | | taskReport.setReportTimes(0); |
| | | taskReport.setTaskSts(taskReportStsType.status); |
| | | taskReport.setSeqNum(task.getSeqNum()); |
| | | taskReport.setZpallet(task.getZpallet()); |
| | | if (!taskReportService.save(taskReport)) { |
| | | log.info("TaskReport [{}] 插入失败 ==========>> ", JSON.toJSONString(taskReport)); |
| | | } else { |
| | | log.info("Task [{}] 状态记录插入数据库 ==========>> ", task.getSeqNum()); |
| | | } |
| | | } |
| | | } |