feat:任务执行流程
This commit is contained in:
@@ -129,4 +129,9 @@ public class FlowController implements ISimulationFlowFeignClient {
|
||||
return simulationFlowNodeService.listSimulationFlowNode(req);
|
||||
}
|
||||
|
||||
@PostMapping("/node/querySimulationFlowNode")
|
||||
public SdmResponse<FlowNodeDto> querySimulationFlowNode(@RequestBody FlowNodeDto req) {
|
||||
return simulationFlowNodeService.querySimulationFlowNode(req);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public interface FlowMapper {
|
||||
@Insert("INSERT INTO simulation_flow_template(uuid,templateName,templateVersion,templateContent,viewContent,parentUuid,templateStatus,templateType,approveType,comment,templateCode,tenantId,createName,creator) VALUES(#{template.uuid},#{template.templateName},#{template.templateVersion},#{template.templateContent},#{template.viewContent},#{template.parentUuid},#{template.templateStatus},#{template.templateType},#{template.approveType},#{template.comment},#{template.templateCode},#{template.tenantId},#{template.createName},#{template.creator})")
|
||||
int addFlowTemplate(@Param("template") SimulationFlowTemplate template);
|
||||
|
||||
@Update("UPDATE simulation_flow_template SET templateContent=#{template.templateContent},viewContent=#{template.viewContent},approveType=#{template.approveType},templateType=#{template.templateType},templateStatus=#{template.templateStatus},comment=#{template.comment},approveFlowId=#{template.approveFlowId} WHERE uuid=#{template.uuid}")
|
||||
@Update("UPDATE simulation_flow_template SET templateContent=#{template.templateContent},viewContent=#{template.viewContent},approveType=#{template.approveType},templateType=#{template.templateType},templateStatus=#{template.templateStatus},comment=#{template.comment},approveFlowId=#{template.approveFlowId},processDefinitionId=#{template.processDefinitionId} WHERE uuid=#{template.uuid}")
|
||||
int updateFlowTemplate(@Param("template") SimulationFlowTemplate template);
|
||||
|
||||
@Delete("DELETE FROM simulation_flow_template WHERE uuid=#{uuid}")
|
||||
|
||||
@@ -32,18 +32,10 @@ public class SimulationFlowNode {
|
||||
@ApiModelProperty(value = "流程节点名称")
|
||||
private String nodeName;
|
||||
|
||||
@TableField("flowInstanceId")
|
||||
@ApiModelProperty(value = "所属流程实例ID(流程引擎)")
|
||||
private String flowInstanceId;
|
||||
|
||||
@TableField("nodeId")
|
||||
@ApiModelProperty(value = "流程引擎中的nodeId")
|
||||
private String nodeId;
|
||||
|
||||
@TableField("templateId")
|
||||
@ApiModelProperty(value = "所属流程模版ID")
|
||||
private String templateId;
|
||||
|
||||
@TableField("runId")
|
||||
@ApiModelProperty(value = "所属算例ID")
|
||||
private String runId;
|
||||
|
||||
@@ -15,6 +15,9 @@ public class SimulationFlowTemplate extends BaseEntity {
|
||||
@Schema(description = "流程模版唯一ID")
|
||||
public String uuid;
|
||||
|
||||
@Schema(description = "flowable流程完成部署后的流程定义id")
|
||||
public String processDefinitionId;
|
||||
|
||||
@Schema(description = "流程模版名称")
|
||||
public String templateName;
|
||||
|
||||
|
||||
@@ -84,5 +84,5 @@ public interface IFlowService {
|
||||
* 处理评审结果
|
||||
* @param req
|
||||
*/
|
||||
public SdmResponse handleApproveResult(LaunchApproveReq req);
|
||||
SdmResponse handleApproveResult(LaunchApproveReq req);
|
||||
}
|
||||
|
||||
@@ -16,4 +16,6 @@ public interface ISimulationFlowNodeService extends IService<SimulationFlowNode>
|
||||
|
||||
SdmResponse<List<FlowNodeDto>> listSimulationFlowNode(@RequestBody FlowNodeDto req);
|
||||
|
||||
SdmResponse<FlowNodeDto> querySimulationFlowNode(@RequestBody FlowNodeDto req);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.sdm.capability.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.sdm.capability.dao.FlowMapper;
|
||||
import com.sdm.capability.model.entity.SimulationFlowTemplate;
|
||||
@@ -8,8 +9,12 @@ import com.sdm.capability.service.IFlowService;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.entity.bo.DataPageInfo;
|
||||
import com.sdm.common.entity.constants.NumberConstants;
|
||||
import com.sdm.common.entity.flowable.dto.ProcessDefinitionDTO;
|
||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||
import com.sdm.common.entity.resp.capability.FlowTemplateResp;
|
||||
import com.sdm.common.entity.resp.flowable.DeployFlowableResp;
|
||||
import com.sdm.common.feign.impl.flowable.FlowableClientFeignClientImpl;
|
||||
import com.sdm.common.feign.impl.system.ApproveFeignClientImpl;
|
||||
import com.sdm.common.service.BaseService;
|
||||
import com.sdm.common.utils.Tools;
|
||||
@@ -33,6 +38,9 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
|
||||
@Autowired
|
||||
private ApproveFeignClientImpl approveFeignClient;
|
||||
|
||||
@Autowired
|
||||
private FlowableClientFeignClientImpl flowableClientFeignClient;
|
||||
|
||||
@Override
|
||||
public SdmResponse createFlowTemplateDraft(SimulationFlowTemplate flowTemplate)
|
||||
{
|
||||
@@ -393,6 +401,14 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
|
||||
SimulationFlowTemplate flowTemplate = getFlowTemplateInfoByUuid(flowTemplateUuid);
|
||||
if(flowTemplate != null)
|
||||
{
|
||||
// 审批通过 部署流程 保存部署流程部署id和流程定义id
|
||||
if (NumberConstants.TWO == approveStatus) {
|
||||
ProcessDefinitionDTO definitionDTO = JSON.parseObject(flowTemplate.getTemplateContent(), ProcessDefinitionDTO.class);
|
||||
SdmResponse<DeployFlowableResp> sdmResponse = flowableClientFeignClient.deploy(definitionDTO);
|
||||
if (sdmResponse.getData() != null) {
|
||||
flowTemplate.processDefinitionId = sdmResponse.getData().getProcessDefinitionId();
|
||||
}
|
||||
}
|
||||
flowTemplate.approveType = approveStatus;
|
||||
flowMapper.updateFlowTemplate(flowTemplate);
|
||||
}
|
||||
|
||||
@@ -41,9 +41,6 @@ public class ISimulationFlowNodeServiceImpl extends ServiceImpl<SimulationFlowNo
|
||||
public SdmResponse batchUpdateSimulationFlowNode(FlowNodeDto req) {
|
||||
if (StringUtils.isNotEmpty(req.getRunId())) {
|
||||
List<SimulationFlowNode> entityList = this.lambdaQuery().eq(SimulationFlowNode::getRunId, req.getRunId()).list();
|
||||
entityList.forEach(entity -> {
|
||||
entity.setFlowInstanceId(req.getFlowInstanceId());
|
||||
});
|
||||
this.updateBatchById(entityList);
|
||||
}
|
||||
return SdmResponse.success();
|
||||
@@ -55,9 +52,6 @@ public class ISimulationFlowNodeServiceImpl extends ServiceImpl<SimulationFlowNo
|
||||
if (StringUtils.isNotBlank(req.getRunId())) {
|
||||
queryWrapper.eq(SimulationFlowNode::getRunId, req.getRunId());
|
||||
}
|
||||
if (StringUtils.isNotBlank(req.getFlowInstanceId())) {
|
||||
queryWrapper.eq(SimulationFlowNode::getFlowInstanceId, req.getFlowInstanceId());
|
||||
}
|
||||
List<SimulationFlowNode> flowNodeList = this.baseMapper.selectList(queryWrapper);
|
||||
List<FlowNodeDto> dtoList = flowNodeList.stream().map(entity -> {
|
||||
FlowNodeDto dto = new FlowNodeDto();
|
||||
@@ -66,4 +60,14 @@ public class ISimulationFlowNodeServiceImpl extends ServiceImpl<SimulationFlowNo
|
||||
}).toList();
|
||||
return SdmResponse.success(dtoList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse<FlowNodeDto> querySimulationFlowNode(FlowNodeDto req) {
|
||||
SimulationFlowNode simulationFlowNode = this.lambdaQuery().eq(SimulationFlowNode::getUuid, req.getUuid()).one();
|
||||
FlowNodeDto dto = new FlowNodeDto();
|
||||
if (simulationFlowNode != null) {
|
||||
BeanUtils.copyProperties(simulationFlowNode, dto);
|
||||
}
|
||||
return SdmResponse.success(dto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.sdm.flowable.dto;
|
||||
package com.sdm.common.entity.flowable.dto;
|
||||
|
||||
import com.sdm.flowable.config.executeConfig.BaseExecuteConfig;
|
||||
import com.sdm.common.entity.flowable.executeConfig.BaseExecuteConfig;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.sdm.flowable.dto;
|
||||
package com.sdm.common.entity.flowable.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.sdm.flowable.dto;
|
||||
package com.sdm.common.entity.flowable.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.sdm.flowable.dto;
|
||||
package com.sdm.common.entity.flowable.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.sdm.flowable.config.executeConfig;
|
||||
package com.sdm.common.entity.flowable.executeConfig;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.sdm.flowable.config.executeConfig;
|
||||
package com.sdm.common.entity.flowable.executeConfig;
|
||||
|
||||
public class CloudAppExecuteConfig extends BaseExecuteConfig {
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.sdm.flowable.config.executeConfig;
|
||||
package com.sdm.common.entity.flowable.executeConfig;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.sdm.flowable.config.executeConfig;
|
||||
package com.sdm.common.entity.flowable.executeConfig;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.sdm.flowable.config.executeConfig;
|
||||
package com.sdm.common.entity.flowable.executeConfig;
|
||||
|
||||
public class ExportWordScriptExecuteConfig extends BaseExecuteConfig {
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.sdm.flowable.config.executeConfig;
|
||||
package com.sdm.common.entity.flowable.executeConfig;
|
||||
|
||||
public class HPCExecuteConfig extends BaseExecuteConfig {
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.sdm.flowable.config.executeConfig;
|
||||
package com.sdm.common.entity.flowable.executeConfig;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.sdm.flowable.config.executeConfig;
|
||||
package com.sdm.common.entity.flowable.executeConfig;
|
||||
|
||||
public class LocalAppExecuteConfig extends BaseExecuteConfig {
|
||||
}
|
||||
@@ -19,15 +19,9 @@ public class FlowNodeDto {
|
||||
@Schema(description = "流程节点名称")
|
||||
private String nodeName;
|
||||
|
||||
@Schema(description = "所属流程实例ID(流程引擎)")
|
||||
private String flowInstanceId;
|
||||
|
||||
@Schema(description = "流程引擎中的nodeId")
|
||||
private String nodeId;
|
||||
|
||||
@Schema(description = "所属流程模版ID")
|
||||
private String templateId;
|
||||
|
||||
@Schema(description = "所属算例ID")
|
||||
private String runId;
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@ public class FlowTemplateResp {
|
||||
@Schema(description = "流程模版唯一ID")
|
||||
public String uuid;
|
||||
|
||||
@Schema(description = "flowable流程完成部署后的流程定义id")
|
||||
public String processDefinitionId;
|
||||
|
||||
@Schema(description = "流程模版名称")
|
||||
public String templateName;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.sdm.flowable.dto.resp;
|
||||
package com.sdm.common.entity.resp.flowable;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -92,4 +92,19 @@ public class SimulationFlowFeignClientImpl implements ISimulationFlowFeignClient
|
||||
return SdmResponse.failed("查询流程节点信息失败异常");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse<FlowNodeDto> querySimulationFlowNode(FlowNodeDto req) {
|
||||
SdmResponse response;
|
||||
try {
|
||||
response = flowFeignClient.querySimulationFlowNode(req);
|
||||
if (!response.isSuccess()) {
|
||||
return SdmResponse.failed("查询流程节点信息失败");
|
||||
}
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
log.error("查询流程节点信息失败异常", e);
|
||||
return SdmResponse.failed("查询流程节点信息失败异常");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.sdm.common.feign.impl.flowable;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.flowable.dto.ProcessDefinitionDTO;
|
||||
import com.sdm.common.entity.resp.flowable.DeployFlowableResp;
|
||||
import com.sdm.common.entity.resp.flowable.ProcessInstanceResp;
|
||||
import com.sdm.common.feign.inter.flowable.IFlowableFeignClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -11,6 +13,9 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@@ -29,4 +34,30 @@ public class FlowableClientFeignClientImpl implements IFlowableFeignClient {
|
||||
return SdmResponse.failed("启动流程实例");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse<DeployFlowableResp> deploy(ProcessDefinitionDTO processDTO) {
|
||||
SdmResponse<DeployFlowableResp> response;
|
||||
try {
|
||||
response = flowableFeignClient.deploy(processDTO);
|
||||
log.info("部署流程实例:"+ response);
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
log.error("部署流程实例失败", e);
|
||||
return SdmResponse.failed("部署流程实例失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse saveParamsByDefinitionId(String processDefinitionId, String nodeId, Map<String, Object> params) {
|
||||
SdmResponse response;
|
||||
try {
|
||||
response = flowableFeignClient.saveParamsByDefinitionId(processDefinitionId, nodeId, params);
|
||||
log.info("保存节点参数:"+ response);
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
log.error("保存节点参数失败", e);
|
||||
return SdmResponse.failed("保存节点参数失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,4 +30,7 @@ public interface ISimulationFlowFeignClient {
|
||||
@PostMapping("/node/listSimulationFlowNode")
|
||||
SdmResponse<List<FlowNodeDto>> listSimulationFlowNode(@RequestBody FlowNodeDto req);
|
||||
|
||||
@PostMapping("/node/querySimulationFlowNode")
|
||||
SdmResponse<FlowNodeDto> querySimulationFlowNode(@RequestBody FlowNodeDto req);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.sdm.common.feign.inter.flowable;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.flowable.dto.ProcessDefinitionDTO;
|
||||
import com.sdm.common.entity.resp.flowable.DeployFlowableResp;
|
||||
import com.sdm.common.entity.resp.flowable.ProcessInstanceResp;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@@ -12,7 +15,14 @@ import java.util.Map;
|
||||
|
||||
@FeignClient(name = "flowable")
|
||||
public interface IFlowableFeignClient {
|
||||
@GetMapping("/process/startByProcessDefinitionKey")
|
||||
|
||||
@GetMapping("/process/startByProcessDefinitionId")
|
||||
SdmResponse<ProcessInstanceResp> startByProcessDefinitionId(@RequestParam String processDefinitionId, @RequestBody(required = false) Map<String, Object> variables);
|
||||
|
||||
@PostMapping("/process/deploy")
|
||||
SdmResponse<DeployFlowableResp> deploy(@RequestBody ProcessDefinitionDTO processDTO);
|
||||
|
||||
@PostMapping("/saveParamsByDefinitionId")
|
||||
SdmResponse saveParamsByDefinitionId(@RequestParam String processDefinitionId, @RequestParam String nodeId, @RequestBody Map<String, Object> params);
|
||||
|
||||
}
|
||||
|
||||
@@ -5,16 +5,17 @@ import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.feign.inter.flowable.IFlowableFeignClient;
|
||||
import com.sdm.flowable.delegate.handler.HpcHandler;
|
||||
import com.sdm.flowable.dto.NodeStructureInfo;
|
||||
import com.sdm.flowable.dto.ProcessDefinitionDTO;
|
||||
import com.sdm.common.entity.flowable.dto.ProcessDefinitionDTO;
|
||||
import com.sdm.flowable.dto.req.AsyncCallbackRequest;
|
||||
import com.sdm.flowable.dto.req.CompleteTaskReq;
|
||||
import com.sdm.flowable.dto.req.RetryRequest;
|
||||
import com.sdm.common.entity.resp.flowable.ProcessInstanceResp;
|
||||
import com.sdm.flowable.dto.resp.DeployFlowableResp;
|
||||
import com.sdm.common.entity.resp.flowable.DeployFlowableResp;
|
||||
import com.sdm.flowable.dto.resp.ProcessInstanceDetailResponse;
|
||||
import com.sdm.flowable.process.ProcessService;
|
||||
import com.sdm.flowable.service.IProcessNodeParamService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.flowable.validation.ValidationError;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.sdm.flowable.delegate;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.sdm.flowable.config.executeConfig.BaseExecuteConfig;
|
||||
import com.sdm.common.entity.flowable.executeConfig.BaseExecuteConfig;
|
||||
import com.sdm.flowable.constants.FlowableConfig;
|
||||
import com.sdm.flowable.delegate.handler.ExecutionHandler;
|
||||
import com.sdm.flowable.dto.req.AsyncCallbackRequest;
|
||||
@@ -13,7 +12,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.flowable.engine.delegate.JavaDelegate;
|
||||
import org.flowable.engine.runtime.Execution;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.sdm.flowable.delegate.handler;
|
||||
|
||||
import com.sdm.flowable.config.executeConfig.BaseExecuteConfig;
|
||||
import com.sdm.common.entity.flowable.executeConfig.BaseExecuteConfig;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.sdm.flowable.delegate.handler;
|
||||
|
||||
import com.sdm.flowable.config.executeConfig.BaseExecuteConfig;
|
||||
import com.sdm.common.entity.flowable.executeConfig.BaseExecuteConfig;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.sdm.flowable.delegate.handler;
|
||||
|
||||
import com.sdm.flowable.config.executeConfig.BaseExecuteConfig;
|
||||
import com.sdm.common.entity.flowable.executeConfig.BaseExecuteConfig;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.sdm.flowable.delegate.handler;
|
||||
import com.sdm.common.entity.req.data.UploadFilesReq;
|
||||
import com.sdm.common.feign.inter.data.IDataFeignClient;
|
||||
import com.sdm.common.utils.RandomUtil;
|
||||
import com.sdm.flowable.config.executeConfig.BaseExecuteConfig;
|
||||
import com.sdm.common.entity.flowable.executeConfig.BaseExecuteConfig;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.sdm.flowable.delegate.handler;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.req.pbs.SubmitHpcTaskRemoteReq;
|
||||
import com.sdm.common.feign.inter.pbs.ITaskFeignClient;
|
||||
import com.sdm.flowable.config.executeConfig.BaseExecuteConfig;
|
||||
import com.sdm.common.entity.flowable.executeConfig.BaseExecuteConfig;
|
||||
import com.sdm.flowable.service.IAsyncTaskRecordService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.sdm.flowable.delegate.handler;
|
||||
|
||||
import com.sdm.flowable.config.executeConfig.BaseExecuteConfig;
|
||||
import com.sdm.common.entity.flowable.executeConfig.BaseExecuteConfig;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.sdm.flowable.delegate.handler;
|
||||
|
||||
import com.sdm.flowable.config.executeConfig.BaseExecuteConfig;
|
||||
import com.sdm.common.entity.flowable.executeConfig.BaseExecuteConfig;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ import com.sdm.flowable.constants.FlowableConfig;
|
||||
import com.sdm.flowable.delegate.UniversalDelegate;
|
||||
import com.sdm.flowable.dto.NodeDetailInfo;
|
||||
import com.sdm.flowable.dto.NodeStructureInfo;
|
||||
import com.sdm.flowable.dto.ProcessDefinitionDTO;
|
||||
import com.sdm.flowable.dto.ProcessInstanceInfo;
|
||||
import com.sdm.common.entity.flowable.dto.ProcessDefinitionDTO;
|
||||
import com.sdm.flowable.dto.req.AsyncCallbackRequest;
|
||||
import com.sdm.flowable.dto.resp.DeployFlowableResp;
|
||||
import com.sdm.flowable.dto.resp.ProcessInstanceDetailResponse;
|
||||
import com.sdm.common.entity.resp.flowable.DeployFlowableResp;
|
||||
import com.sdm.flowable.enums.FlowElementTypeEnums;
|
||||
import com.sdm.flowable.util.Dto2BpmnConverter;
|
||||
import com.sdm.flowable.dto.req.CompleteTaskReq;
|
||||
|
||||
@@ -2,14 +2,11 @@ package com.sdm.flowable.util;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.sdm.flowable.dto.FlowElementDTO;
|
||||
import com.sdm.flowable.dto.ProcessDefinitionDTO;
|
||||
import com.sdm.flowable.config.executeConfig.BaseExecuteConfig;
|
||||
import com.sdm.common.entity.flowable.dto.FlowElementDTO;
|
||||
import com.sdm.common.entity.flowable.dto.ProcessDefinitionDTO;
|
||||
import com.sdm.common.entity.flowable.executeConfig.BaseExecuteConfig;
|
||||
import com.sdm.flowable.constants.FlowableConfig;
|
||||
import com.sdm.flowable.dto.FlowElementDTO;
|
||||
import com.sdm.flowable.dto.ProcessDefinitionDTO;
|
||||
import com.sdm.flowable.enums.FlowElementTypeEnums;
|
||||
import com.sdm.flowable.util.FlowNodeIdUtils;
|
||||
import org.flowable.bpmn.model.*;
|
||||
import org.flowable.bpmn.model.Process;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -186,4 +186,12 @@ public class SimulationRunController {
|
||||
return runService.startProcessInstance(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务执行 设置节点输入参数和输出参数
|
||||
*/
|
||||
@PostMapping("/saveNodeParams")
|
||||
public SdmResponse saveNodeParams(@RequestBody SpdmNodeParamReq req) {
|
||||
return runService.saveNodeParams(req);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -141,6 +141,10 @@ public class SimulationRun implements Serializable {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Schema(description = "flowable流程完成部署后的流程定义id,根据这个发起流程实例")
|
||||
@TableField("processDefinitionId")
|
||||
public String processDefinitionId;
|
||||
|
||||
@Schema(description= "流程实例id(流程引擎返回的)")
|
||||
@TableField("flowInstanceId")
|
||||
private String flowInstanceId;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.sdm.project.model.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SpdmNodeParamReq {
|
||||
|
||||
@Schema(description = "节点uuid")
|
||||
private String nodeUuid;
|
||||
|
||||
|
||||
@Schema(description = "算例uuid")
|
||||
private String runId;
|
||||
|
||||
@Schema(description = "上传脚本文件id")
|
||||
private String scriptFileId;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -59,4 +59,6 @@ public interface ISimulationRunService extends IService<SimulationRun> {
|
||||
void generateReport(SpdmReportReq req, HttpServletResponse response);
|
||||
|
||||
SdmResponse startProcessInstance(SpdmTaskRunReq req);
|
||||
|
||||
SdmResponse saveNodeParams(SpdmNodeParamReq req);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.sdm.project.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -11,6 +12,8 @@ import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.entity.enums.DirTypeEnum;
|
||||
import com.sdm.common.entity.enums.NodeTypeEnum;
|
||||
import com.sdm.common.entity.flowable.dto.FlowElementDTO;
|
||||
import com.sdm.common.entity.flowable.dto.ProcessDefinitionDTO;
|
||||
import com.sdm.common.entity.req.capability.FlowNodeDto;
|
||||
import com.sdm.common.entity.req.data.*;
|
||||
import com.sdm.common.entity.req.system.UserQueryReq;
|
||||
@@ -20,6 +23,9 @@ import com.sdm.common.entity.resp.data.BatchAddFileInfoResp;
|
||||
import com.sdm.common.entity.resp.data.FileMetadataInfoResp;
|
||||
import com.sdm.common.entity.resp.flowable.ProcessInstanceResp;
|
||||
import com.sdm.common.entity.resp.system.CIDUserResp;
|
||||
import com.sdm.common.feign.impl.capability.SimulationFlowFeignClientImpl;
|
||||
import com.sdm.common.feign.impl.data.DataClientFeignClientImpl;
|
||||
import com.sdm.common.feign.impl.flowable.FlowableClientFeignClientImpl;
|
||||
import com.sdm.common.feign.impl.system.SysUserFeignClientImpl;
|
||||
import com.sdm.common.feign.inter.capability.ISimulationFlowFeignClient;
|
||||
import com.sdm.common.feign.inter.data.IDataFeignClient;
|
||||
@@ -95,13 +101,13 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
SysUserFeignClientImpl sysUserFeignClient;
|
||||
|
||||
@Autowired
|
||||
private IDataFeignClient dataFeignClient;
|
||||
private DataClientFeignClientImpl dataFeignClient;
|
||||
|
||||
@Autowired
|
||||
private IFlowableFeignClient flowableFeignClient;
|
||||
private FlowableClientFeignClientImpl flowableFeignClient;
|
||||
|
||||
@Autowired
|
||||
private ISimulationFlowFeignClient flowFeignClient;
|
||||
private SimulationFlowFeignClientImpl flowFeignClient;
|
||||
|
||||
private static final String TEMP_REPORT_PATH = "/opt/report/";
|
||||
|
||||
@@ -557,14 +563,12 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
if (flowTemplateResp.getData() != null) {
|
||||
try {
|
||||
List<FlowNodeDto> flowNodeDtoList = new ArrayList<>();
|
||||
List<Map<String, String>> result = extractFlowElements(flowTemplateResp.getData().getTemplateContent());
|
||||
for (Map<String, String> map : result) {
|
||||
ProcessDefinitionDTO definitionDTO = JSON.parseObject(flowTemplateResp.getData().getTemplateContent(), ProcessDefinitionDTO.class);
|
||||
for (FlowElementDTO flowElement : definitionDTO.getFlowElements()) {
|
||||
FlowNodeDto flowNodeDto = new FlowNodeDto();
|
||||
flowNodeDto.setUuid(generateUuid("flow_node_"));
|
||||
flowNodeDto.setNodeName(map.get("name"));
|
||||
// flowNodeReq.setFlowInstanceId(simulationRun.getFlowInstanceId());
|
||||
flowNodeDto.setNodeId(map.get("id"));
|
||||
flowNodeDto.setTemplateId(simulationRun.getFlowTemplate());
|
||||
flowNodeDto.setNodeName(flowElement.getName());
|
||||
flowNodeDto.setNodeId(flowElement.getId());
|
||||
flowNodeDto.setRunId(simulationRun.getUuid());
|
||||
flowNodeDtoList.add(flowNodeDto);
|
||||
}
|
||||
@@ -589,6 +593,8 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
log.error("解析流程模板json文件失败,flowTemplateId:{}", simulationRun.getFlowTemplate(), e);
|
||||
throw new RuntimeException("解析流程模板json文件失败:" + e.getMessage(), e);
|
||||
}
|
||||
simulationRun.setProcessDefinitionId(flowTemplateResp.getData().getProcessDefinitionId());
|
||||
this.updateById(simulationRun);
|
||||
}
|
||||
}
|
||||
return SdmResponse.success(simulationRun.getUuid());
|
||||
@@ -608,29 +614,6 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析流程模板json结构 获取节点id和名称
|
||||
* @param jsonString
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static List<Map<String, String>> extractFlowElements(String jsonString) throws Exception {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode rootNode = mapper.readTree(jsonString);
|
||||
JsonNode flowElements = rootNode.path("flowElements");
|
||||
List<Map<String, String>> elements = new ArrayList<>();
|
||||
for (JsonNode element : flowElements) {
|
||||
if ("sequenceFlow".equals(element.get("type").asText())) {
|
||||
continue;
|
||||
}
|
||||
Map<String, String> item = new HashMap<>();
|
||||
item.put("id", element.path("id").asText());
|
||||
item.put("name", element.path("name").asText());
|
||||
elements.add(item);
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public SdmResponse deleteTaskRun(SpdmTaskRunReq req) {
|
||||
@@ -937,21 +920,31 @@ 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();
|
||||
// 启动流程实例
|
||||
SdmResponse<ProcessInstanceResp> sdmResponse = flowableFeignClient.startByProcessDefinitionKey(simulationRun.getFlowTemplate());
|
||||
// 启动流程实例 多次执行会生成多个流程实例id,更新算例run表
|
||||
SdmResponse<ProcessInstanceResp> sdmResponse = flowableFeignClient.startByProcessDefinitionId(simulationRun.getProcessDefinitionId(), null);
|
||||
if (sdmResponse.getData() != null) {
|
||||
this.lambdaUpdate().set(SimulationRun::getFlowInstanceId, sdmResponse.getData().getId()).eq(SimulationRun::getUuid, req.getRunId()).update();
|
||||
// 更新node节点的流程实例id
|
||||
FlowNodeDto flowNodeDto = new FlowNodeDto();
|
||||
flowNodeDto.setRunId(req.getRunId());
|
||||
flowNodeDto.setFlowInstanceId(sdmResponse.getData().getId());
|
||||
flowFeignClient.batchUpdateSimulationFlowNode(flowNodeDto);
|
||||
this.lambdaUpdate().set(SimulationRun::getFlowInstanceId, sdmResponse.getData().getProcessInstanceId()).eq(SimulationRun::getUuid, req.getRunId()).update();
|
||||
} else {
|
||||
return SdmResponse.failed("流程实例启动失败");
|
||||
}
|
||||
return sdmResponse;
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void deleteFolder(File folder) {
|
||||
if (folder.isDirectory()) {
|
||||
File[] files = folder.listFiles();
|
||||
|
||||
Reference in New Issue
Block a user