| | |
| | | } |
| | | } |
| | | /**下发普通站点任务,报错回滚,不再往下执行*/ |
| | | pubTaskToWcs(task); |
| | | pubTaskToWcs(tasks); |
| | | } |
| | | } |
| | | |
| | |
| | | .in(Task::getTaskType, list) |
| | | .in(Task::getTaskStatus, integers) |
| | | .orderByDesc(Task::getSort)); |
| | | List<Task> pubTasks = new ArrayList<>(); |
| | | |
| | | Config configs = configService.getOne(new LambdaQueryWrapper<Config>().eq(Config::getFlag, GlobalConfigCode.ALLOW_MOVE_TO_DEEP_LOC)); |
| | | if (!Objects.isNull(configs) && Boolean.parseBoolean(configs.getVal())) { |
| | | for (Task task : tasks) { |
| | | /**移库不做站点操作*/ |
| | | //堆垛机任务,根据深浅库位做移库动作 |
| | | if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) { |
| | | BasStation station = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, |
| | | task.getTaskStatus().equals(TaskStsType.GENERATE_IN.id) ? task.getOrgSite() : task.getTargSite())); |
| | |
| | | if (Objects.isNull(loc)) { |
| | | continue; |
| | | } |
| | | |
| | | //判断是否深库位 |
| | | if (!LocUtils.isShallowLoc(loc.getCode())) { |
| | | //获取深库位对应的浅库位 |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | /**下发任务*/ |
| | | try { |
| | | pubTaskToWcs(task); |
| | | pubTaskToWcs(tasks); |
| | | } catch (Exception e) { |
| | | log.error("任务下发失败!!", e); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 下发任务至WCS |
| | | * |
| | | * @param task |
| | | * @param tasks |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void pubTaskToWcs(Task task) { |
| | | public void pubTaskToWcs(List<Task> tasks) { |
| | | WcsTaskParams taskParams = new WcsTaskParams(); |
| | | List<TaskItemParam> items = new ArrayList<>(); |
| | | tasks.forEach(task -> { |
| | | TaskItemParam itemParam = new TaskItemParam(); |
| | | //任务类型,任务编码 |
| | | itemParam.setTaskType(RcsTaskType.getTypeDesc(task.getTaskType())) |
| | | .setSeqNum(task.getTaskCode()); |
| | | //主参数 |
| | | taskParams.setBatch(task.getBarcode()); |
| | | |
| | | |
| | | BasStation station = null; |
| | | if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) { |
| | |
| | | throw new CoolException("站点不存在!!"); |
| | | } |
| | | } |
| | | |
| | | |
| | | /**判断是否光电站点,非光店站点需管控站点状态*/ |
| | | if (!Objects.isNull(station) && station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | List<TaskItemParam> items = Arrays.asList(itemParam); |
| | | |
| | | items.add(itemParam); |
| | | }); |
| | | taskParams.setTaskList(items); |
| | | |
| | | /**任务下发接口*/ |
| | | String pubTakUrl = rcsApi.getHost() + ":" + rcsApi.getPort() + RcsConstant.pubTask; |
| | | |
| | | /**RCS基础配置链接*/ |
| | | log.info("任务下发,请求地址: {}, 请求参数: {}", pubTakUrl, JSONObject.toJSONString(taskParams)); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | |
| | | .setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsEmpty); |
| | | CommonResponse result = objectMapper.readValue(exchange.getBody(), CommonResponse.class); |
| | | if (result.getCode() == 200) { |
| | | tasks.forEach(task -> { |
| | | BasStation curSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getOrgSite())); |
| | | if (Objects.isNull(curSta)) { |
| | | throw new CoolException("站点不存在!!"); |
| | | } |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type) |
| | |
| | | /**排除移库功能*/ |
| | | if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) { |
| | | /**如果是普通站点,修改站点状态为出库预约*/ |
| | | if (station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) { |
| | | station.setUseStatus(LocStsType.LOC_STS_TYPE_R.type); |
| | | if (!basStationService.updateById(station)) { |
| | | if (curSta.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) { |
| | | curSta.setUseStatus(LocStsType.LOC_STS_TYPE_R.type); |
| | | if (!basStationService.updateById(curSta)) { |
| | | throw new CoolException("站点预约失败!!"); |
| | | } |
| | | } |
| | |
| | | throw new CoolException("任务状态修改失败!!"); |
| | | } |
| | | /**如果是普通站点,修改站点状态为入库预约*/ |
| | | if (station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) { |
| | | station.setUseStatus(LocStsType.LOC_STS_TYPE_S.type); |
| | | if (!basStationService.updateById(station)) { |
| | | if (curSta.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) { |
| | | curSta.setUseStatus(LocStsType.LOC_STS_TYPE_S.type); |
| | | if (!basStationService.updateById(curSta)) { |
| | | throw new CoolException("站点预约失败!!"); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } else { |
| | | throw new CoolException("任务下发失败!!"); |
| | | } |