mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-30 07:06:39 +08:00
fix 解决设计器选择设置流程发起人设置变量有问题
This commit is contained in:
parent
dc3c86f0d7
commit
d58ccebe30
@ -59,4 +59,14 @@ public interface FlowConstant {
|
||||
*/
|
||||
String PROCESS_INSTANCE_VO = "processInstanceVo";
|
||||
|
||||
/**
|
||||
* 流程发起人
|
||||
*/
|
||||
String INITIATOR = "INITIATOR";
|
||||
|
||||
/**
|
||||
* 开启跳过表达式变量
|
||||
*/
|
||||
String FLOWABLE_SKIP_EXPRESSION_ENABLED = "_FLOWABLE_SKIP_EXPRESSION_ENABLED";
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import cn.hutool.core.util.ZipUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
@ -231,7 +232,24 @@ public class ActModelServiceImpl implements IActModelService {
|
||||
});
|
||||
model.setKey(key);
|
||||
repositoryService.saveModel(model);
|
||||
byte[] xmlBytes = WorkflowUtils.bpmnJsonToXmlBytes(Objects.requireNonNull(values.getFirst("json_xml")).getBytes(StandardCharsets.UTF_8));
|
||||
//解决设计器选择设置流程发起人设置变量有问题
|
||||
JsonNode jsonNode = objectMapper.readTree(values.getFirst("json_xml"));
|
||||
JsonNode childShapes = jsonNode.get("childShapes");
|
||||
for (JsonNode childShape : childShapes) {
|
||||
JsonNode properties = childShape.get("properties");
|
||||
if(!properties.path("usertaskassignment").isMissingNode()){
|
||||
JsonNode usertaskassignment = properties.get("usertaskassignment");
|
||||
if(!usertaskassignment.path("assignment").isMissingNode()){
|
||||
JsonNode assignment = usertaskassignment.get("assignment");
|
||||
if(!assignment.path("assignee").isMissingNode()){
|
||||
if ("$INITIATOR".equals(assignment.get("assignee").textValue())) {
|
||||
((ObjectNode) assignment).put("assignee", "${INITIATOR}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
byte[] xmlBytes = WorkflowUtils.bpmnJsonToXmlBytes(Objects.requireNonNull(JsonUtils.toJsonString(jsonNode)).getBytes(StandardCharsets.UTF_8));
|
||||
if (ArrayUtil.isEmpty(xmlBytes)) {
|
||||
throw new ServiceException("模型不能为空!");
|
||||
}
|
||||
|
@ -41,6 +41,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.dromara.workflow.common.constant.FlowConstant.FLOWABLE_SKIP_EXPRESSION_ENABLED;
|
||||
import static org.dromara.workflow.common.constant.FlowConstant.INITIATOR;
|
||||
|
||||
/**
|
||||
* 任务 服务层实现
|
||||
*
|
||||
@ -87,7 +90,9 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
// 启动流程实例(提交申请)
|
||||
Map<String, Object> variables = startProcessBo.getVariables();
|
||||
// 启动跳过表达式
|
||||
variables.put("_FLOWABLE_SKIP_EXPRESSION_ENABLED", true);
|
||||
variables.put(FLOWABLE_SKIP_EXPRESSION_ENABLED, true);
|
||||
// 流程发起人
|
||||
variables.put(INITIATOR, (String.valueOf(LoginHelper.getUserId())));
|
||||
ProcessInstance pi = runtimeService.startProcessInstanceByKeyAndTenantId(startProcessBo.getProcessKey(), startProcessBo.getBusinessKey(), variables, TenantHelper.getTenantId());
|
||||
// 将流程定义名称 作为 流程实例名称
|
||||
runtimeService.setProcessInstanceName(pi.getProcessInstanceId(), pi.getProcessDefinitionName());
|
||||
|
Loading…
Reference in New Issue
Block a user