1
10 小时以前 a750c6ca527c0d209473b8593df679aa6ef58854
rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java
@@ -113,19 +113,17 @@
    @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_UNBIND.type,
                MissionStepType.MISSION_STEP_TYPE_BIND.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));
                .eq(FlowStepInstance::getStatus, 1).in(FlowStepInstance::getStepType,MissionStepType.getTaskISSUE()));
        for (FlowStepInstance flowStepInstance : flowStepInstanceList) {
            FlowInstance flowInstance = flowInstanceService.getById(flowStepInstance.getFlowInstanceId());
            if (Cools.isEmpty(flowInstance)) { continue;}
            List<FlowStepInstance> flowStepInstances = flowStepInstanceService.list(new LambdaQueryWrapper<FlowStepInstance>()
                    .eq(FlowStepInstance::getFlowInstanceId, flowInstance.getId()).eq(FlowStepInstance::getStatus, (short) 0));
            flowInstance.setStatus(flowStepInstances.isEmpty()? (short) 2:(short) 1);
            TaskInstanceNode taskInstanceNode = taskInstanceNodeService.getById(flowInstance.getNodeInstanceId());
            if (Cools.isEmpty(taskInstanceNode)) { continue;}
            taskInstanceNode.setStatus(flowInstance.getStatus());
            TaskInstance taskInstance = taskInstanceService.getById(flowInstance.getTaskId());
            if (Cools.isEmpty(taskInstance)) { continue;}
            Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskCode, taskInstance.getTaskNo()));
@@ -147,14 +145,21 @@
                    if (flowStepInstance.getWmsNextTaskStatus() != 9999) {
                        FlowStepInstance nextFlowStepInstance = flowStepInstanceService.getOne(new LambdaQueryWrapper<FlowStepInstance>()
                                .eq(FlowStepInstance::getFlowInstanceId, flowStepInstance.getFlowInstanceId())
                                .eq(FlowStepInstance::getFlowInstanceNo, flowStepInstance.getFlowInstanceNo())
                                .eq(FlowStepInstance::getStatus, (short)0)
                                .eq(FlowStepInstance::getStepOrder, flowStepInstance.getStepOrder() + 1)
                                .eq(FlowStepInstance::getWmsNowTaskStatus, flowStepInstance.getWmsNextTaskStatus()));
                        if (Cools.isEmpty(nextFlowStepInstance)) {
                            throw new CoolException("任务号"+task.getTaskCode()+"任务步骤丢失!!!");
                        }
                        nextFlowStepInstance.setStatus((short)1);
                        flowStepInstanceService.updateById(nextFlowStepInstance);
                    } else {
                        taskInstance.setStatus((short)2);
                        taskInstanceService.updateById(taskInstance);
                    }
                    flowInstanceService.updateById(flowInstance);
                    taskInstanceNodeService.updateById(taskInstanceNode);
                } catch (Exception e) {
                    throw new CoolException(e.getMessage());
                }
@@ -192,13 +197,18 @@
                            if (flowStepInstance.getWmsNextTaskStatus() != 9999) {
                                FlowStepInstance nextFlowStepInstance = flowStepInstanceService.getOne(new LambdaQueryWrapper<FlowStepInstance>()
                                        .eq(FlowStepInstance::getFlowInstanceId, flowStepInstance.getFlowInstanceId())
                                        .eq(FlowStepInstance::getFlowInstanceNo, flowStepInstance.getFlowInstanceNo())
                                        .eq(FlowStepInstance::getStatus, (short)0)
                                        .eq(FlowStepInstance::getStepOrder, flowStepInstance.getStepOrder() + 1)
                                        .eq(FlowStepInstance::getWmsNowTaskStatus, flowStepInstance.getWmsNextTaskStatus()));
                                if (Cools.isEmpty(nextFlowStepInstance)) {
                                    throw new CoolException("任务号"+task.getTaskCode()+"任务步骤丢失!!!");
                                }
                                nextFlowStepInstance.setStatus((short)1);
                                flowStepInstanceService.updateById(nextFlowStepInstance);
                            } else {
                                taskInstance.setStatus((short)2);
                                taskInstanceService.updateById(taskInstance);
                            }
                        } else {
                            flowStepInstance.setRetryTimes(flowStepInstance.getRetryTimes() + 1);
@@ -237,7 +247,51 @@
    public void completeStock9999() throws Exception {
        try{
            List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getTaskStatus, TaskStsType.MISSION_TRANSFER.id).select(Task::getId));
            List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getTaskStatus, TaskStsType.MISSION_TRANSFER.id));
            if (tasks.isEmpty()) {
                return;
            }
            for (Task task : tasks) {
                /**任务下发接口*/
                String pubTakUrl = rcsApi.getHost() + ":" + rcsApi.getPort() + RcsConstant.REPORT_TASKS;
                /**基础配置链接*/
                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(task, 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( TaskStsType.MISSION_TRANSFER_END.id);
                            taskService.updateById(task);
                        }
                    } catch (JsonProcessingException e) {
                        throw new CoolException(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);
        } catch (Exception e) {
            log.error(e.getMessage());
        }
    }
    public void completeStock10000() throws Exception {
        try{
            List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getTaskStatus, TaskStsType.MISSION_TRANSFER_END.id));
            if (tasks.isEmpty()) {
                return;
            }