feat:任务执行流程用户输入参数
This commit is contained in:
@@ -3,6 +3,7 @@ package com.sdm.common.feign.impl.capability;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.req.capability.FlowNodeDto;
|
||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||
import com.sdm.common.entity.resp.capability.FlowTemplateResp;
|
||||
import com.sdm.common.feign.inter.capability.ISimulationFlowFeignClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -34,8 +35,8 @@ public class SimulationFlowFeignClientImpl implements ISimulationFlowFeignClient
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse queryFlowTemplateInfo(String uuid) {
|
||||
SdmResponse response;
|
||||
public SdmResponse<FlowTemplateResp> queryFlowTemplateInfo(String uuid) {
|
||||
SdmResponse<FlowTemplateResp> response;
|
||||
try {
|
||||
response = flowFeignClient.queryFlowTemplateInfo(uuid);
|
||||
if (!response.isSuccess()) {
|
||||
|
||||
@@ -60,4 +60,17 @@ public class FlowableClientFeignClientImpl implements IFlowableFeignClient {
|
||||
return SdmResponse.failed("保存节点参数失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse updateNodeParamProcessInstanceId(String processDefinitionId, String processInstanceId) {
|
||||
SdmResponse response;
|
||||
try {
|
||||
response = flowableFeignClient.updateNodeParamProcessInstanceId(processDefinitionId, processInstanceId);
|
||||
log.info("更新流程参数的流程实例id:"+ response);
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
log.error("更新流程参数的流程实例id失败", e);
|
||||
return SdmResponse.failed("更新流程参数的流程实例id失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,4 +25,7 @@ public interface IFlowableFeignClient {
|
||||
@PostMapping("/saveParamsByDefinitionId")
|
||||
SdmResponse saveParamsByDefinitionId(@RequestParam String processDefinitionId, @RequestParam String nodeId, @RequestBody Map<String, Object> params);
|
||||
|
||||
@PostMapping("/updateNodeParamProcessInstanceId")
|
||||
SdmResponse updateNodeParamProcessInstanceId(@RequestParam String processDefinitionId, @RequestParam String processInstanceId);
|
||||
|
||||
}
|
||||
|
||||
@@ -8,15 +8,15 @@ public class SpdmNodeParamReq {
|
||||
|
||||
@Schema(description = "节点uuid")
|
||||
private String nodeUuid;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "算例uuid")
|
||||
private String runId;
|
||||
|
||||
@Schema(description = "上传脚本文件id")
|
||||
private String scriptFileId;
|
||||
|
||||
|
||||
@Schema(description = "用户输入的正则表达式参数")
|
||||
private String regExp;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -920,10 +920,11 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public SdmResponse startProcessInstance(SpdmTaskRunReq req) {
|
||||
SimulationRun simulationRun = this.lambdaQuery().eq(SimulationRun::getUuid, req.getRunId()).one();
|
||||
// 启动流程实例 多次执行会生成多个流程实例id,更新算例run表
|
||||
// 启动流程实例 多次执行会生成多个流程实例id,更新算例run表、同时更新flowable流程参数的流程实例id
|
||||
SdmResponse<ProcessInstanceResp> sdmResponse = flowableFeignClient.startByProcessDefinitionId(simulationRun.getProcessDefinitionId(), null);
|
||||
if (sdmResponse.getData() != null) {
|
||||
this.lambdaUpdate().set(SimulationRun::getFlowInstanceId, sdmResponse.getData().getProcessInstanceId()).eq(SimulationRun::getUuid, req.getRunId()).update();
|
||||
flowableFeignClient.updateNodeParamProcessInstanceId(simulationRun.getProcessDefinitionId(), sdmResponse.getData().getProcessInstanceId());
|
||||
} else {
|
||||
return SdmResponse.failed("流程实例启动失败");
|
||||
}
|
||||
@@ -932,14 +933,35 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
|
||||
@Override
|
||||
public SdmResponse saveNodeParams(SpdmNodeParamReq req) {
|
||||
FlowNodeDto flowNodeReq = new FlowNodeDto();
|
||||
flowNodeReq.setUuid(req.getNodeUuid());
|
||||
SdmResponse<FlowNodeDto> sdmResponse = flowFeignClient.querySimulationFlowNode(flowNodeReq);
|
||||
if (sdmResponse.getData() != null) {
|
||||
// ProcessDefinitionDTO definitionDTO = JSON.parseObject(sdmResponse.getData().get(), ProcessDefinitionDTO.class);
|
||||
|
||||
FlowNodeDto flowNodeDto = sdmResponse.getData();
|
||||
|
||||
SimulationRun simulationRun = this.lambdaQuery().eq(SimulationRun::getUuid, req.getRunId()).one();
|
||||
SdmResponse<FlowTemplateResp> flowTemplateResp = flowFeignClient.queryFlowTemplateInfo(simulationRun.getFlowTemplate());
|
||||
if (flowTemplateResp.getData() != null) {
|
||||
ProcessDefinitionDTO definitionDTO = JSON.parseObject(flowTemplateResp.getData().getTemplateContent(), ProcessDefinitionDTO.class);
|
||||
FlowNodeDto flowNodeReq = new FlowNodeDto();
|
||||
flowNodeReq.setUuid(req.getNodeUuid());
|
||||
SdmResponse<FlowNodeDto> sdmResponse = flowFeignClient.querySimulationFlowNode(flowNodeReq);
|
||||
if (sdmResponse.getData() != null) {
|
||||
FlowNodeDto flowNodeDto = sdmResponse.getData();
|
||||
definitionDTO.getFlowElements().stream().filter(i -> StringUtils.equals(i.getId(), flowNodeDto.getNodeId())).findFirst().ifPresent(i -> {
|
||||
if (i.getExtensionElements() != null && i.getExtensionElements().getExecuteConfig() != null) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
if ("HPC".equals(i.getExtensionElements().getExecuteConfig().getExecuteType())) {
|
||||
// 计算节点 输出文件夹id 保存到用户输入参数
|
||||
params.put("outputDirId", flowNodeDto.getOutputDirId());
|
||||
} else if ("exportWordScript".equals(i.getExtensionElements().getExecuteConfig().getExecuteType())) {
|
||||
// 脚本节点
|
||||
// 处理脚本上传到当前节点文件夹下,获得 脚本文件id
|
||||
// 脚本文件id 保存到用户输入参数
|
||||
params.put("scriptFileId", req.getScriptFileId());
|
||||
// 正则表达式 保存到用户输入参数
|
||||
params.put("regExp", req.getRegExp());
|
||||
// 脚本输出文件夹id 保存到用户输入参数
|
||||
params.put("outputDirId", flowNodeDto.getOutputDirId());
|
||||
}
|
||||
flowableFeignClient.saveParamsByDefinitionId(simulationRun.getProcessDefinitionId(), flowNodeDto.getNodeId(), params);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user