fix: 解决审批节点表单无可编辑字段时,variables流程变量值为空,流程节点流转异常问题
This commit is contained in:
parent
42eb89b243
commit
23844b930c
|
@ -907,16 +907,9 @@ public class BpmnModelUtils {
|
||||||
* @return 符合条件的路径
|
* @return 符合条件的路径
|
||||||
*/
|
*/
|
||||||
private static SequenceFlow findMatchSequenceFlowByExclusiveGateway(Gateway gateway, Map<String, Object> variables) {
|
private static SequenceFlow findMatchSequenceFlowByExclusiveGateway(Gateway gateway, Map<String, Object> variables) {
|
||||||
// TODO 表单无可编辑字段时variables为空,流程走向会出现问题,比如流程审批过程中无需要修改的字段值,
|
SequenceFlow matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
|
||||||
SequenceFlow matchSequenceFlow;
|
|
||||||
if (CollUtil.isNotEmpty(variables)){
|
|
||||||
matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
|
|
||||||
flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId())
|
flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId())
|
||||||
&& (evalConditionExpress(variables, flow.getConditionExpression())));
|
&& (evalConditionExpress(variables, flow.getConditionExpression())));
|
||||||
}else {
|
|
||||||
matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
|
|
||||||
flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId()));
|
|
||||||
}
|
|
||||||
if (matchSequenceFlow == null) {
|
if (matchSequenceFlow == null) {
|
||||||
matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
|
matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
|
||||||
flow -> ObjUtil.equal(gateway.getDefaultFlow(), flow.getId()));
|
flow -> ObjUtil.equal(gateway.getDefaultFlow(), flow.getId()));
|
||||||
|
|
|
@ -558,12 +558,21 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||||
taskService.addComment(task.getId(), task.getProcessInstanceId(), BpmCommentTypeEnum.APPROVE.getType(),
|
taskService.addComment(task.getId(), task.getProcessInstanceId(), BpmCommentTypeEnum.APPROVE.getType(),
|
||||||
BpmCommentTypeEnum.APPROVE.formatComment(reqVO.getReason()));
|
BpmCommentTypeEnum.APPROVE.formatComment(reqVO.getReason()));
|
||||||
// 2.3 调用 BPM complete 去完成任务
|
// 2.3 调用 BPM complete 去完成任务
|
||||||
|
// 如果流程变量前端传空,需要从历史实例中获取,原因:前端表单如果在当前节点无可编辑的字段时variables一定会为空
|
||||||
|
// 场景一:A节点发起,B节点表单无可编辑字段,审批通过时,C节点需要流程变量获取下一个执行节点,但因为B节点无可编辑的字段,variables为空,流程可能出现问题
|
||||||
|
// 场景二:A节点发起,B节点只有某一个字段可编辑(比如day),但C节点需要多个节点(比如workday,在发起时填写,因为B节点只有day的编辑权限,在审批后。variables会缺少work的值)
|
||||||
|
// 历史中的变量值
|
||||||
|
Map<String, Object> variables = new HashMap<>(instance.getProcessVariables());
|
||||||
|
// 如果变量值不为空,则覆盖历史变量
|
||||||
|
if (CollUtil.isNotEmpty(reqVO.getVariables())) {
|
||||||
|
variables.putAll(reqVO.getVariables());
|
||||||
|
}
|
||||||
// 校验并处理 APPROVE_USER_SELECT 当前审批人,选择下一节点审批人的逻辑
|
// 校验并处理 APPROVE_USER_SELECT 当前审批人,选择下一节点审批人的逻辑
|
||||||
Map<String, Object> variables = validateAndSetNextAssignees(task.getTaskDefinitionKey(), reqVO.getVariables(),
|
Map<String, Object> resVariables = validateAndSetNextAssignees(task.getTaskDefinitionKey(), variables,
|
||||||
bpmnModel, reqVO.getNextAssignees(), instance);
|
bpmnModel, reqVO.getNextAssignees(), instance);
|
||||||
// 完成任务
|
// 完成任务
|
||||||
runtimeService.setVariables(task.getProcessInstanceId(), variables);
|
runtimeService.setVariables(task.getProcessInstanceId(), resVariables);
|
||||||
taskService.complete(task.getId(), variables, true);
|
taskService.complete(task.getId(), resVariables, true);
|
||||||
|
|
||||||
// 【加签专属】处理加签任务
|
// 【加签专属】处理加签任务
|
||||||
handleParentTaskIfSign(task.getParentTaskId());
|
handleParentTaskIfSign(task.getParentTaskId());
|
||||||
|
|
Loading…
Reference in New Issue