增加生成后端服务代码。
This commit is contained in:
parent
e340e3106d
commit
15d3720f5f
@ -186,11 +186,18 @@ public class WorkflowInstanceServiceImpl extends BaseServiceImpl<WorkflowInstanc
|
|||||||
public WorkflowInstanceDTO startWorkflow(WorkflowInstanceStartRequest request) {
|
public WorkflowInstanceDTO startWorkflow(WorkflowInstanceStartRequest request) {
|
||||||
try {
|
try {
|
||||||
WorkflowDefinition workflowDefinition = workflowDefinitionRepository.findByKey(request.getProcessKey()).orElseThrow(() -> new RuntimeException("Workflow definition process key not found: " + request.getProcessKey()));
|
WorkflowDefinition workflowDefinition = workflowDefinitionRepository.findByKey(request.getProcessKey()).orElseThrow(() -> new RuntimeException("Workflow definition process key not found: " + request.getProcessKey()));
|
||||||
|
|
||||||
|
// ✅ 将前端传入的 variables 包装到 "form" 变量中
|
||||||
|
// 这样流程中的 ${form.xxx} 表达式就能正确解析
|
||||||
|
Map<String, Object> variables = new HashMap<>();
|
||||||
|
if (request.getVariables() != null && !request.getVariables().isEmpty()) {
|
||||||
|
variables.put("form", request.getVariables());
|
||||||
|
}
|
||||||
|
|
||||||
ProcessInstance processInstance = runtimeService.createProcessInstanceBuilder()
|
ProcessInstance processInstance = runtimeService.createProcessInstanceBuilder()
|
||||||
.processDefinitionKey(request.getProcessKey())
|
.processDefinitionKey(request.getProcessKey())
|
||||||
.variables(request.getVariables())
|
.variables(variables) // 使用包装后的变量
|
||||||
.businessKey(request.getBusinessKey())
|
.businessKey(request.getBusinessKey())
|
||||||
.variables(request.getVariables())
|
|
||||||
.startAsync(); // 异步启动,会自动执行 shell 任务
|
.startAsync(); // 异步启动,会自动执行 shell 任务
|
||||||
// .start();
|
// .start();
|
||||||
return createWorkflowInstance(workflowDefinition.getId(), request.getBusinessKey(), processInstance);
|
return createWorkflowInstance(workflowDefinition.getId(), request.getBusinessKey(), processInstance);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user