rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/MissionTransferStationController.java
New file @@ -0,0 +1,26 @@ package com.vincent.rsf.openApi.controller; import com.vincent.rsf.openApi.entity.dto.CommonResponse; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @Api("任务中转站") @Slf4j @RequestMapping("/mission") public class MissionTransferStationController { @ApiOperation("任务总控") @PostMapping("/task/master/control") public CommonResponse missionMasterControl(@RequestBody Object objParams) { //判断需要下发系统 //判断下发方式 //返回结果 return CommonResponse.ok(); } } rsf-server/src/main/java/com/vincent/rsf/server/api/entity/constant/RcsConstant.java
@@ -13,4 +13,7 @@ //盘点库存修改 public static String CHECK_LOCITEM_UPDATE = "/rsf-open-api/erp/check/locitem/update"; //待下发任务发送至中转站 public static String MISSION_TRANSFER_STATION = "/rsf-open-api/mission/task/master/control"; } rsf-server/src/main/java/com/vincent/rsf/server/manager/enums/MissionStepType.java
New file @@ -0,0 +1,27 @@ package com.vincent.rsf.server.manager.enums; /** * @author Ryan * @version 1.0 * @title TaskType * @description * @create 2025/3/29 17:02 */ public enum MissionStepType { MISSION_STEP_TYPE_RESPONSE("RESPONSE", "响应"), MISSION_STEP_TYPE_RECEIVE("RECEIVE", "接收"), MISSION_STEP_TYPE_REQUEST("REQUEST", "请求"), MISSION_STEP_TYPE_VALIDATE("VALIDATE", "校验"), MISSION_STEP_TYPE_TRANSFORM("TRANSFORM", "转换"), MISSION_STEP_TYPE_OBTAIN("OBTAIN", "获取"), MISSION_STEP_TYPE_NO_EXECUTE("NO_EXECUTE", "越过"), ; public String type; public String desc; MissionStepType(String type, String desc) { this.type = type; this.desc = desc; } } rsf-server/src/main/java/com/vincent/rsf/server/manager/enums/TaskStsType.java
@@ -19,34 +19,53 @@ // WCS_PUTAWAY_SUSPEND(13L, "入库任务挂起"), COMPLETE_IN("98", "入库完成"), REPORT_IN("99", "上报完成"), UPDATED_IN("100", "库存更新完成"), GENERATE_OUT("101", "创建出库任务"), WCS_EXECUTE_OUT("102", "WCS、RCS出库任务已下发"), WCS_EXECUTE_OUT_TOTE_LOAD("103", "WCS、RCS取箱完成"), WCS_EXECUTE_OUT_TOTE_UNLOAD("104", "WCS、RCS放箱完成"), WCS_EXECUTE_OUT_TASK_DONE("105", "WCS、RCS任务完成"), WCS_EXECUTE_OUT_ARRIVED("106", "WCS、RCS容器已到达"), WCS_EXECUTE_OUT_CONVEYOR("107", "WCS、RCS容器流动任务已下发"), AWAIT("196","等待确认"), GENERATE_WAVE_SEED("197", "等待容器到达"), COMPLETE_OUT("198", "出库完成"), WAVE_SEED("199", "播种中/盘点中/待确认"), UPDATED_OUT("200", "库存更新完成"), MISSION_TEMPLATE_EXECUTE_WCS_ONE1("1001", "1001.WCS请求下发中"), MISSION_TEMPLATE_EXECUTE_WCS_ONE2("1002", "1002.WCS作业中等待上报完成"), MISSION_TEMPLATE_EXECUTE_HK_RCS_ONE1("1003", "1003.RCS请求下发中"), MISSION_TEMPLATE_EXECUTE_HK_RCS_ONE2("1004", "1004.RCS作业中等待上报完成"), MISSION_TEMPLATE_EXECUTE_HK_RCS_TWO1("1005", "1005.RCS请求下发中"), MISSION_TEMPLATE_EXECUTE_HK_RCS_TWO2("1006", "1006.RCS作业中等待上报完成"), MISSION_TEMPLATE_EXECUTE_WCS_TWO1("1007", "1007.WCS请求下发中"), MISSION_TEMPLATE_EXECUTE_WCS_TWO2("1008", "1008.WCS作业中等待上报完成"), MISSION_TEMPLATE_EXECUTE_WCS_THREE1("1009", "1009.WCS请求下发中"), MISSION_TEMPLATE_EXECUTE_WCS_THREE2("1010", "1010.WCS作业中等待上报完成"), MISSION_TEMPLATE_EXECUTE_WCS_FOUR1("1011", "1011.WCS请求下发中"), MISSION_TEMPLATE_EXECUTE_WCS_FOUR2("1012", "1012.WCS作业中等待上报完成"), MISSION_TEMPLATE_EXECUTE_WCS_FIVE1("1013", "1013.WCS请求下发中"), MISSION_TEMPLATE_EXECUTE_WCS_FIVE2("1014", "1014.WCS作业中等待上报完成"), MISSION_TEMPLATE_EXECUTE_HK_RCS_THREE1("1015", "1015.RCS请求下发中"), MISSION_TEMPLATE_EXECUTE_HK_RCS_THREE2("1016", "1016.RCS作业中等待上报完成"), MISSION_TEMPLATE_EXECUTE_WCS_SIX1("1017", "1017.WCS请求下发中"), MISSION_TEMPLATE_EXECUTE_WCS_SIX2("1018", "1018.WCS作业中等待上报完成"), MISSION_TEMPLATE_EXECUTE_WCS_SEVEN1("1019", "1019.WCS请求下发中"), MISSION_TEMPLATE_EXECUTE_WCS_SEVEN2("1020", "1020.WCS作业中等待上报完成"), MISSION_TEMPLATE_EXECUTE_HK_RCS_FOUR1("1021", "1021.RCS请求下发中"), MISSION_TEMPLATE_EXECUTE_HK_RCS_FOUR2("1022", "1022.RCS作业中等待上报完成"), MISSION_TEMPLATE_EXECUTE_HK_RCS_FIVE1("1023", "1023.RCS请求下发中"), MISSION_TEMPLATE_EXECUTE_HK_RCS_FIVE2("1024", "1024.RCS作业中等待上报完成"), MISSION_TEMPLATE_EXECUTE_WCS_EIGHT1("1025", "1025.WCS请求下发中"), MISSION_TEMPLATE_EXECUTE_WCS_EIGHT2("1026", "1026.WCS作业中等待上报完成"), MISSION_TEMPLATE_NO_EXECUTE1("1027", "1027.不执行任务"), MISSION_TEMPLATE_WEIGHING_ONE2("1028", "1028.称重作业中等待上报完成"), MISSION_TRANSFER("9999", "9999.任务完成中"), ; public Integer id; rsf-server/src/main/java/com/vincent/rsf/server/manager/enums/TaskType.java
@@ -19,6 +19,7 @@ TASK_TYPE_PICK_AGAIN_OUT("103", "拣料出库"), TASK_TYPE_MERGE_OUT("104", "并板出库"), TASK_TYPE_CHECK_OUT("107", "盘点出库"), TASK_TYPE_CROSS_DOCKING_OUT("109", "越库"), TASK_TYPE_EMPTY_OUT("110", "空板出库"), ; public Integer type; rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskMissionSchedules.java
@@ -70,7 +70,7 @@ * @description: 初始任务规划路径 * @version 1.0 */ @Scheduled(cron = "0/2 * * * * ?") @Scheduled(cron = "0/1 * * * * ?") @Transactional(rollbackFor = Exception.class) public void missionTemplate() throws Exception { Config config = configService.getOne(new LambdaQueryWrapper<Config>().eq(Config::getFlag, GlobalConfigCode.AUTO_TEMPLATE_PLANNING_STEP_FLOW)); @@ -93,7 +93,6 @@ sou = task.getOrgSite(); Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getTargLoc())); end = loc.getAreaId().toString(); task.setTaskStatus(TaskStsType.GENERATE_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) @@ -102,7 +101,6 @@ Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getOrgLoc())); sou = loc.getAreaId().toString(); end = task.getTargSite(); task.setTaskStatus(TaskStsType.GENERATE_OUT.id); } List<TaskPathTemplateMerge> taskPathTemplateMergeList = taskPathTemplateMergeService.list(new LambdaQueryWrapper<TaskPathTemplateMerge>().eq(TaskPathTemplateMerge::getSourceType, sou).eq(TaskPathTemplateMerge::getTargetType, end)); if (Objects.isNull(taskPathTemplateMergeList) || taskPathTemplateMergeList.isEmpty()) { @@ -128,7 +126,7 @@ taskPathTemplateMerge.setStepSize(longList.size()); taskPathTemplateMergeService.save(taskPathTemplateMerge); } System.out.println("任务:"+task.getTaskCode()+"查询步序为:"+longs); // System.out.println("任务:"+task.getTaskCode()+"查询步序为:"+longs); } } else { //生成实际路径 @@ -147,17 +145,53 @@ Integer i = 0;//it顺序 Integer j = 0;//suT顺序 TaskInstance taskInstance = new TaskInstance(taskPathTemplateMerge,task); boolean save = taskInstanceService.save(taskInstance); if (!save) { return false; } // 用于存储所有FlowStepTemplate List<FlowStepTemplate> allFlowStepTemplates = new ArrayList<>(); // 第一遍遍历:收集所有的FlowStepTemplate for (Integer id : conditionExpression) { TaskPathTemplate taskPathTemplate = taskPathTemplateService.getById(id); if (taskPathTemplate == null) { return false; } List<TaskPathTemplateNode> taskPathTemplateNodeList = taskPathTemplateNodeService.list(new LambdaQueryWrapper<TaskPathTemplateNode>().eq(TaskPathTemplateNode::getTemplateId, taskPathTemplate.getId())); List<TaskPathTemplateNode> taskPathTemplateNodeList = taskPathTemplateNodeService.list( new LambdaQueryWrapper<TaskPathTemplateNode>() .eq(TaskPathTemplateNode::getTemplateId, taskPathTemplate.getId())); for (TaskPathTemplateNode taskPathTemplateNode : taskPathTemplateNodeList) { List<SubsystemFlowTemplate> subsystemFlowTemplateList = subsystemFlowTemplateService.list( new LambdaQueryWrapper<SubsystemFlowTemplate>() .eq(SubsystemFlowTemplate::getFlowCode, taskPathTemplateNode.getNodeCode()) .eq(SubsystemFlowTemplate::getSystemCode, taskPathTemplateNode.getSystemCode())); for (SubsystemFlowTemplate subsystemFlowTemplate : subsystemFlowTemplateList) { List<FlowStepTemplate> flowStepTemplateList = flowStepTemplateService.list( new LambdaQueryWrapper<FlowStepTemplate>() .eq(FlowStepTemplate::getFlowId, subsystemFlowTemplate.getId())); allFlowStepTemplates.addAll(flowStepTemplateList); } } } TaskInstance taskInstance = new TaskInstance(taskPathTemplateMerge,task); boolean save = taskInstanceService.save(taskInstance); if (!save) { return false; } // 当前处理的FlowStepTemplate在全局列表中的索引 int globalIndex = 0; for (Integer id : conditionExpression) { TaskPathTemplate taskPathTemplate = taskPathTemplateService.getById(id); if (taskPathTemplate == null) { return false; } List<TaskPathTemplateNode> taskPathTemplateNodeList = taskPathTemplateNodeService.list( new LambdaQueryWrapper<TaskPathTemplateNode>() .eq(TaskPathTemplateNode::getTemplateId, taskPathTemplate.getId())); for (TaskPathTemplateNode taskPathTemplateNode : taskPathTemplateNodeList) { TaskInstanceNode taskInstanceNode = new TaskInstanceNode(taskPathTemplateNode); taskInstanceNode.setTaskId(taskInstance.getId()); @@ -166,8 +200,12 @@ taskInstanceNode.setNodeOrder(i); taskInstanceNode.setNodeCode(String.valueOf(snowflakeIdWorker.nextId())); taskInstanceNodeService.save(taskInstanceNode); List<SubsystemFlowTemplate> subsystemFlowTemplateList = subsystemFlowTemplateService.list(new LambdaQueryWrapper<SubsystemFlowTemplate>().eq(SubsystemFlowTemplate::getFlowCode, taskPathTemplateNode.getNodeCode()) .eq(SubsystemFlowTemplate::getSystemCode, taskPathTemplateNode.getSystemCode())); List<SubsystemFlowTemplate> subsystemFlowTemplateList = subsystemFlowTemplateService.list( new LambdaQueryWrapper<SubsystemFlowTemplate>() .eq(SubsystemFlowTemplate::getFlowCode, taskPathTemplateNode.getNodeCode()) .eq(SubsystemFlowTemplate::getSystemCode, taskPathTemplateNode.getSystemCode())); for (SubsystemFlowTemplate subsystemFlowTemplate : subsystemFlowTemplateList) { FlowInstance flowInstance = new FlowInstance(subsystemFlowTemplate); flowInstance.setFlowInstanceNo(String.valueOf(snowflakeIdWorker.nextId())); @@ -176,7 +214,11 @@ flowInstance.setNodeInstanceId(taskInstanceNode.getId()); flowInstance.setNodeCode(String.valueOf(snowflakeIdWorker.nextId())); flowInstanceService.save(flowInstance); List<FlowStepTemplate> flowStepTemplateList = flowStepTemplateService.list(new LambdaQueryWrapper<FlowStepTemplate>().eq(FlowStepTemplate::getFlowId, subsystemFlowTemplate.getId())); List<FlowStepTemplate> flowStepTemplateList = flowStepTemplateService.list( new LambdaQueryWrapper<FlowStepTemplate>() .eq(FlowStepTemplate::getFlowId, subsystemFlowTemplate.getId())); for (FlowStepTemplate flowStepTemplate : flowStepTemplateList) { j++; FlowStepInstance flowStepInstance = new FlowStepInstance(flowStepTemplate); @@ -184,7 +226,24 @@ flowStepInstance.setFlowInstanceNo(flowInstance.getFlowInstanceNo()); flowStepInstance.setStepOrder(j); flowStepInstance.setStepCode(String.valueOf(snowflakeIdWorker.nextId())); flowStepInstance.setWmsNowTaskStatus(flowStepTemplate.getWmsNowTaskStatus()); // 判断是否是最后一个 if (globalIndex < allFlowStepTemplates.size() - 1) { // 不是最后一个,取下一个的WmsNowTaskStatus FlowStepTemplate nextFlowStep = allFlowStepTemplates.get(globalIndex + 1); flowStepInstance.setWmsNextTaskStatus(nextFlowStep.getWmsNowTaskStatus()); if (globalIndex == 0){ task.setTaskStatus(flowStepTemplate.getWmsNowTaskStatus()); flowStepInstance.setStatus((short)1); } } else { // 是最后一个,设置为9999 flowStepInstance.setWmsNextTaskStatus(9999); } flowStepInstanceService.save(flowStepInstance); globalIndex++; // 更新全局索引 } } } rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java
@@ -26,8 +26,12 @@ 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; @@ -93,42 +97,170 @@ 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()); } } /** @@ -138,15 +270,19 @@ * @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); } /** @@ -155,18 +291,22 @@ * @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) @@ -230,6 +370,7 @@ } }); // Set<Long> taskIds = taskItems.stream().map(TaskItem::getTaskId).collect(Collectors.toSet()); // List<Task> tasks = taskService.listByIds(taskIds); // if (!tasks.isEmpty()) { rsf-server/src/main/java/com/vincent/rsf/server/system/entity/FlowStepInstance.java
@@ -77,9 +77,9 @@ private Long stepTemplateId; /** * 状态:0-待执行 1-执行中 2-成功 3-失败 4-跳过 5-超时 * 状态:0-排队中 1-待执行 2-执行中 3-执行成功 4-执行失败 5-已跳过 6-已取消 */ @ApiModelProperty(value= "状态:0-待执行 1-执行中 2-成功 3-失败 4-跳过 5-超时") @ApiModelProperty(value= "状态:0-排队中 1-待执行 2-执行中 3-执行成功 4-执行失败 5-已跳过 6-已取消") private Short status; /** @@ -146,6 +146,12 @@ @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") private Date updateTime; @ApiModelProperty(value= "wms下一步任务类型ID") private Integer wmsNextTaskStatus; @ApiModelProperty(value= "wms当前任务类型ID") private Integer wmsNowTaskStatus; public FlowStepInstance() {} public FlowStepInstance(FlowStepTemplate flowStepTemplate) { this.stepTemplateId = flowStepTemplate.getId(); rsf-server/src/main/java/com/vincent/rsf/server/system/entity/FlowStepTemplate.java
@@ -134,6 +134,9 @@ @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") private Date updateTime; @ApiModelProperty(value= "wms下一步任务状态ID") private Integer wmsNowTaskStatus; public FlowStepTemplate() {} public FlowStepTemplate(Long flowId,String flowCode,Integer stepOrder,String stepCode,String stepName,String stepType,String actionType,String actionConfig,String inputMapping,String outputMapping,String conditionExpression,Short skipOnFail,Short retryEnabled,String retryConfig,Integer timeoutSeconds,Long createBy,Long updateBy,Date createTime,Date updateTime) { rsf-server/src/main/java/com/vincent/rsf/server/system/entity/TaskInstanceNode.java
@@ -93,9 +93,9 @@ private String executeParams; /** * 状态:0-待执行 1-执行中 2-执行成功 3-执行失败 4-已跳过 5-已取消 * 状态:0-排队中 1-待执行 2-执行中 3-执行成功 4-执行失败 5-已跳过 6-已取消 */ @ApiModelProperty(value= "状态:0-待执行 1-执行中 2-执行成功 3-执行失败 4-已跳过 5-已取消") @ApiModelProperty(value= "状态:0-排队中 1-待执行 2-执行中 3-执行成功 4-执行失败 5-已跳过 6-已取消") private Short status; /**