| | |
| | | import com.vincent.rsf.server.manager.service.impl.LocServiceImpl; |
| | | import com.vincent.rsf.server.system.constant.GlobalConfigCode; |
| | | import com.vincent.rsf.server.system.constant.SerialRuleCode; |
| | | import com.vincent.rsf.server.system.entity.Config; |
| | | import com.vincent.rsf.server.system.entity.*; |
| | | import com.vincent.rsf.server.system.service.ConfigService; |
| | | import com.vincent.rsf.server.system.service.impl.FlowInstanceServiceImpl; |
| | | import com.vincent.rsf.server.system.service.impl.FlowStepInstanceServiceImpl; |
| | | import com.vincent.rsf.server.system.service.impl.TaskInstanceNodeServiceImpl; |
| | | import com.vincent.rsf.server.system.service.impl.TaskInstanceServiceImpl; |
| | | import com.vincent.rsf.server.system.utils.SerialRuleUtils; |
| | | import com.vincent.rsf.server.system.utils.SystemAuthUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | private RemotesInfoProperties.RcsApi rcsApi; |
| | | @Autowired |
| | | private BasStationService basStationService; |
| | | @Autowired |
| | | private FlowStepInstanceServiceImpl flowStepInstanceService; |
| | | @Autowired |
| | | private FlowInstanceServiceImpl flowInstanceService; |
| | | @Autowired |
| | | private TaskInstanceNodeServiceImpl taskInstanceNodeService; |
| | | @Autowired |
| | | private TaskInstanceServiceImpl taskInstanceService; |
| | | |
| | | |
| | | /** |
| | | * 任务下发:请求 |
| | | */ |
| | | @Scheduled(cron = "0/2 * * * * ? ") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void missionTaskEXECUTE() { |
| | | List<String> typeList = Arrays.asList(MissionStepType.MISSION_STEP_TYPE_REQUEST.type, MissionStepType.MISSION_STEP_TYPE_OBTAIN.type,MissionStepType.MISSION_STEP_TYPE_NO_EXECUTE.type); |
| | | List<FlowStepInstance> flowStepInstanceList = flowStepInstanceService.list(new LambdaQueryWrapper<FlowStepInstance>() |
| | | .eq(FlowStepInstance::getStatus, 1).in(FlowStepInstance::getStepType,typeList)); |
| | | for (FlowStepInstance flowStepInstance : flowStepInstanceList) { |
| | | FlowInstance flowInstance = flowInstanceService.getById(flowStepInstance.getFlowInstanceId()); |
| | | if (Cools.isEmpty(flowInstance)) { continue;} |
| | | TaskInstanceNode taskInstanceNode = taskInstanceNodeService.getById(flowInstance.getNodeInstanceId()); |
| | | if (Cools.isEmpty(taskInstanceNode)) { continue;} |
| | | TaskInstance taskInstance = taskInstanceService.getById(flowInstance.getTaskId()); |
| | | if (Cools.isEmpty(taskInstance)) { continue;} |
| | | Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskCode, taskInstance.getTaskNo())); |
| | | if (Cools.isEmpty(task)) { continue;} |
| | | if (!task.getTaskStatus().equals(flowStepInstance.getWmsNowTaskStatus())) { |
| | | log.error("任务号:"+task.getTaskCode()+"的任务状态与执行档案任务状态:"+flowStepInstance.getWmsNowTaskStatus()+"不一致!!!"); |
| | | continue; |
| | | } |
| | | |
| | | // /** |
| | | // * 任务下发 |
| | | // */ |
| | | // @Scheduled(cron = "0/5 * * * * ? ") |
| | | // @Transactional(rollbackFor = Exception.class) |
| | | // public void pubTaskToWcs() { |
| | | // Long loginUserId = SystemAuthUtils.getLoginUserId(); |
| | | // List<Integer> list = Arrays.asList(TaskType.TASK_TYPE_IN.type, TaskType.TASK_TYPE_OUT.type, TaskType.TASK_TYPE_LOC_MOVE.type, TaskType.TASK_TYPE_EMPTY_IN.type |
| | | // , TaskType.TASK_TYPE_CHECK_IN.type, TaskType.TASK_TYPE_MERGE_IN.type, TaskType.TASK_TYPE_EMPTY_OUT.type, TaskType.TASK_TYPE_PICK_IN.type, |
| | | // TaskType.TASK_TYPE_PICK_AGAIN_OUT.type, TaskType.TASK_TYPE_CHECK_OUT.type, TaskType.TASK_TYPE_MERGE_OUT.type); |
| | | // List<Integer> integers = Arrays.asList(TaskStsType.GENERATE_IN.id, TaskStsType.GENERATE_OUT.id); |
| | | // List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>() |
| | | // .in(Task::getTaskType, list) |
| | | // .in(Task::getTaskStatus, integers).last("limit 1") |
| | | // .orderByDesc(Task::getSort)); |
| | | // 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 (Cools.isEmpty(station)){ |
| | | // log.info("非光电站点任务下发:站点信息异常,任务信息:"+ JSON.toJSONString(task)); |
| | | // continue; |
| | | // } |
| | | // if (station.getType().equals(StationTypeEnum.STATION_TYPE_MUTI.type)) { |
| | | // continue; |
| | | // } |
| | | // } |
| | | // /**下发普通站点任务,报错回滚,不再往下执行*/ |
| | | // pubTaskToWcs(task); |
| | | // } |
| | | // } |
| | | if (flowStepInstance.getStepType().equals(MissionStepType.MISSION_STEP_TYPE_NO_EXECUTE.type)) { |
| | | /**基础配置链接*/ |
| | | log.info("任务越过, 请求参数: {}", JSONObject.toJSONString(flowStepInstance)); |
| | | try { |
| | | task.setTaskStatus(flowStepInstance.getWmsNextTaskStatus()); |
| | | flowStepInstance.setStatus((short)3); |
| | | |
| | | flowStepInstanceService.updateById(flowStepInstance); |
| | | taskService.updateById(task); |
| | | |
| | | if (flowStepInstance.getWmsNextTaskStatus() != 9999) { |
| | | FlowStepInstance nextFlowStepInstance = flowStepInstanceService.getOne(new LambdaQueryWrapper<FlowStepInstance>() |
| | | .eq(FlowStepInstance::getFlowInstanceId, flowStepInstance.getFlowInstanceId()) |
| | | .eq(FlowStepInstance::getFlowInstanceNo, flowStepInstance.getFlowInstanceNo()) |
| | | .eq(FlowStepInstance::getStepOrder, flowStepInstance.getStepOrder() + 1) |
| | | .eq(FlowStepInstance::getWmsNowTaskStatus, flowStepInstance.getWmsNextTaskStatus())); |
| | | nextFlowStepInstance.setStatus((short)1); |
| | | |
| | | flowStepInstanceService.updateById(nextFlowStepInstance); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | } else { |
| | | /**任务下发接口*/ |
| | | String pubTakUrl = rcsApi.getHost() + ":" + rcsApi.getPort() + RcsConstant.MISSION_TRANSFER_STATION; |
| | | |
| | | /**基础配置链接*/ |
| | | log.info("任务下发,请求地址: {}, 请求参数: {}", pubTakUrl, JSONObject.toJSONString("")); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.add("Content-Type", "application/json"); |
| | | headers.add("api-version", "v2.0"); |
| | | HttpEntity httpEntity = new HttpEntity(flowStepInstance, headers); |
| | | ResponseEntity<String> exchange = restTemplate.exchange(pubTakUrl, HttpMethod.POST, httpEntity, String.class); |
| | | log.info("任务下发后,响应结果: {}", exchange); |
| | | if (Objects.isNull(exchange.getBody())) { |
| | | throw new CoolException("任务下发失败!!,返回参数为空!!!"); |
| | | } else { |
| | | try { |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | objectMapper.coercionConfigDefaults() |
| | | .setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsEmpty); |
| | | CommonResponse result = objectMapper.readValue(exchange.getBody(), CommonResponse.class); |
| | | if (result.getCode() == 200) { |
| | | task.setTaskStatus(flowStepInstance.getWmsNextTaskStatus()); |
| | | flowStepInstance.setStatus((short)3); |
| | | |
| | | if (flowStepInstance.getStepType().equals(MissionStepType.MISSION_STEP_TYPE_OBTAIN.type)) { |
| | | //获取数据解析 |
| | | //录入 |
| | | } |
| | | |
| | | flowStepInstanceService.updateById(flowStepInstance); |
| | | taskService.updateById(task); |
| | | |
| | | if (flowStepInstance.getWmsNextTaskStatus() != 9999) { |
| | | FlowStepInstance nextFlowStepInstance = flowStepInstanceService.getOne(new LambdaQueryWrapper<FlowStepInstance>() |
| | | .eq(FlowStepInstance::getFlowInstanceId, flowStepInstance.getFlowInstanceId()) |
| | | .eq(FlowStepInstance::getFlowInstanceNo, flowStepInstance.getFlowInstanceNo()) |
| | | .eq(FlowStepInstance::getStepOrder, flowStepInstance.getStepOrder() + 1) |
| | | .eq(FlowStepInstance::getWmsNowTaskStatus, flowStepInstance.getWmsNextTaskStatus())); |
| | | nextFlowStepInstance.setStatus((short)1); |
| | | |
| | | flowStepInstanceService.updateById(nextFlowStepInstance); |
| | | } |
| | | } else { |
| | | flowStepInstance.setRetryTimes(flowStepInstance.getRetryTimes() + 1); |
| | | if (flowStepInstance.getRetryTimes()>5){ |
| | | flowStepInstance.setStatus((short)4); |
| | | flowStepInstanceService.updateById(flowStepInstance); |
| | | log.error("任务下发失败,重试次数大于等于五次,标记为失败!!!"); |
| | | } else { |
| | | flowStepInstanceService.updateById(flowStepInstance); |
| | | log.error("任务下发失败,等待重试...."); |
| | | } |
| | | } |
| | | } catch (JsonProcessingException e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @param |
| | | * @return |
| | | * @author Ryan |
| | | * @description 完成入库,更新为对应状态 |
| | | * @time 2026/02/02 12:45 |
| | | */ |
| | | @Scheduled(cron = "0/3 * * * * ?") |
| | | public void completeStock() throws Exception { |
| | | completeInStock(); |
| | | complateOutStock(); |
| | | completeStock9999(); |
| | | } |
| | | |
| | | |
| | | public void completeStock9999() throws Exception { |
| | | try{ |
| | | List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getTaskStatus, TaskStsType.MISSION_TRANSFER.id).select(Task::getId)); |
| | | if (tasks.isEmpty()) { |
| | | return; |
| | | } |
| | | for (Task task : tasks) { |
| | | 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) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_IN.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) { |
| | | task.setTaskStatus(TaskStsType.COMPLETE_IN.id); |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_CROSS_DOCKING_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_OUT.type)) { |
| | | task.setTaskStatus(TaskStsType.COMPLETE_OUT.id); |
| | | } |
| | | taskService.updateById(task); |
| | | } |
| | | // List<Long> longSet = tasks.stream().map(Task::getId).collect(Collectors.toList()); |
| | | // List<Task> vaildTasks = taskService.list(new LambdaQueryWrapper<Task>().in(Task::getId, longSet)); |
| | | // taskService.complateInTask(vaildTasks); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | * @description 完成入库,更新库存 |
| | | * @time 2025/4/2 12:37 |
| | | */ |
| | | @Scheduled(cron = "0/3 * * * * ?") |
| | | // @Scheduled(cron = "0/3 * * * * ?") |
| | | public void completeInStock() throws Exception { |
| | | List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getTaskStatus, TaskStsType.COMPLETE_IN.id).select(Task::getId)); |
| | | if (tasks.isEmpty()) { |
| | | return; |
| | | try{ |
| | | List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getTaskStatus, TaskStsType.COMPLETE_IN.id).select(Task::getId)); |
| | | if (tasks.isEmpty()) { |
| | | return; |
| | | } |
| | | List<Long> longSet = tasks.stream().map(Task::getId).collect(Collectors.toList()); |
| | | List<Task> vaildTasks = taskService.list(new LambdaQueryWrapper<Task>().in(Task::getId, longSet)); |
| | | taskService.complateInTask(vaildTasks); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | } |
| | | List<Long> longSet = tasks.stream().map(Task::getId).collect(Collectors.toList()); |
| | | List<Task> vaildTasks = taskService.list(new LambdaQueryWrapper<Task>().in(Task::getId, longSet)); |
| | | taskService.complateInTask(vaildTasks); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @description: 完成出库任务,更新库存 |
| | | * @version 1.0 |
| | | */ |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | | // @Scheduled(cron = "0/5 * * * * ? ") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void complateOutStock() throws Exception { |
| | | List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>() |
| | | .eq(Task::getTaskStatus, TaskStsType.COMPLETE_OUT.id) |
| | | .select(Task::getId)); |
| | | if (tasks.isEmpty()) { |
| | | return; |
| | | try{ |
| | | List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>() |
| | | .eq(Task::getTaskStatus, TaskStsType.COMPLETE_OUT.id) |
| | | .select(Task::getId)); |
| | | if (tasks.isEmpty()) { |
| | | return; |
| | | } |
| | | List<Long> longSet = tasks.stream().map(Task::getId).collect(Collectors.toList()); |
| | | List<Task> vaildTasks = taskService.list(new LambdaQueryWrapper<Task>().in(Task::getId, longSet)); |
| | | taskService.completeTask(vaildTasks); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | } |
| | | List<Long> longSet = tasks.stream().map(Task::getId).collect(Collectors.toList()); |
| | | List<Task> vaildTasks = taskService.list(new LambdaQueryWrapper<Task>().in(Task::getId, longSet)); |
| | | taskService.completeTask(vaildTasks); |
| | | |
| | | // List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>() |
| | | // .eq(TaskItem::getWkType, OrderWorkType.ORDER_WORK_TYPE_STOCK_TERANSFER.type) |
| | |
| | | } |
| | | }); |
| | | |
| | | |
| | | // Set<Long> taskIds = taskItems.stream().map(TaskItem::getTaskId).collect(Collectors.toSet()); |
| | | // List<Task> tasks = taskService.listByIds(taskIds); |
| | | // if (!tasks.isEmpty()) { |
| | |
| | | } |
| | | // |
| | | // /** |
| | | // * 非光电站点任务下发 |
| | | // * 非智能站点任务下发 |
| | | // */ |
| | | // @Scheduled(cron = "0/5 * * * * ? ") |
| | | // @Transactional(rollbackFor = Exception.class) |
| | |
| | | // .eq(BasStation::getStationName, |
| | | // task.getTaskStatus().equals(TaskStsType.GENERATE_IN.id) ? task.getOrgSite() : task.getTargSite())); |
| | | // if (Cools.isEmpty(station)){ |
| | | // log.info("非光电站点任务下发:站点信息异常,任务信息:"+ JSON.toJSONString(task)); |
| | | // log.info("非智能站点任务下发:站点信息异常,任务信息:"+ JSON.toJSONString(task)); |
| | | // continue; |
| | | // } |
| | | // if (station.getType().equals(StationTypeEnum.STATION_TYPE_MUTI.type)) { |
| | |
| | | // /** |
| | | // * @author Ryan |
| | | // * @date 2025/9/4 |
| | | // * @description: 光电站点任务下发 |
| | | // * @description: 智能站点任务下发 |
| | | // * @version 1.0 |
| | | // */ |
| | | // @Scheduled(cron = "0/5 * * * * ? ") |
| | |
| | | } |
| | | |
| | | |
| | | /**判断是否光电站点,非光店站点需管控站点状态*/ //目标站点 |
| | | /**判断是否智能站点,非光店站点需管控站点状态*/ //目标站点 |
| | | if (!Objects.isNull(station) && station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) { |
| | | if (task.getTaskType() <= TaskType.TASK_TYPE_CHECK_IN.type && !task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) { |
| | | // if (!station.getUseStatus().equals(LocStsType.LOC_STS_TYPE_F.type)) { |