Merge branch 'feature/REQ-5965' into pre
This commit is contained in:
commit
dc596d7841
@ -119,7 +119,7 @@ public class CustomGetProcessInstanceVariablesToObjectCmd extends AbstractComman
|
||||
|
||||
Map<String, Object> processVariables = historicProcessInstance.getProcessVariables();
|
||||
// 添加流程业务 ID 和业务下分组变量信息
|
||||
addProcessDefinitionKeyAndVariables(returnVariables, (Map<String, Object>) processVariables.getOrDefault(SIGN_VARIABLE, new HashMap<String, Object>()), historicProcessInstance);
|
||||
addProcessDefinitionKeyAndVariables(returnVariables, historicProcessInstance);
|
||||
|
||||
// 发起人流程引擎内部模型,需要外部调用该命令时,再解析; 当前命令所在 module 不支持调用二方接口
|
||||
returnVariables.add(VariableObjectDTO.builder()
|
||||
@ -227,6 +227,14 @@ public class CustomGetProcessInstanceVariablesToObjectCmd extends AbstractComman
|
||||
.type(convert(field.getType()))
|
||||
.build());
|
||||
}
|
||||
} else {
|
||||
// 为了在审批最终结束时,配合审批业务的替换为空串的配置使用
|
||||
variables.add(VariableObjectDTO.builder()
|
||||
.key(field.getId())
|
||||
.desc(field.getName())
|
||||
.value(null)
|
||||
.type(convert(field.getType()))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -250,9 +258,8 @@ public class CustomGetProcessInstanceVariablesToObjectCmd extends AbstractComman
|
||||
});
|
||||
}
|
||||
|
||||
private void addProcessDefinitionKeyAndVariables(List<VariableObjectDTO> variables, Map<String, Object> bizVariables, HistoricProcessInstance historicProcessInstance) {
|
||||
private void addProcessDefinitionKeyAndVariables(List<VariableObjectDTO> variables, HistoricProcessInstance historicProcessInstance) {
|
||||
CategoryService categoryService = SpringContextUtils.getBean(CategoryService.class);
|
||||
Map<String, Object> processVariables = historicProcessInstance.getProcessVariables();
|
||||
categoryService.get(BPM_MODEL_CATEGORY, historicProcessInstance.getProcessDefinitionKey()).ifPresent(category -> {
|
||||
variables.add(VariableObjectDTO.builder()
|
||||
.key(PRINT_VAR_PROCESS_DEFINITION_KEY)
|
||||
@ -260,11 +267,13 @@ public class CustomGetProcessInstanceVariablesToObjectCmd extends AbstractComman
|
||||
.value(category.getLabel() + "(" + category.getValue() + ")")
|
||||
.build());
|
||||
// 添加业务下的变量
|
||||
addVariables(variables, category, bizVariables, processVariables);
|
||||
addVariables(variables, category, historicProcessInstance);
|
||||
});
|
||||
}
|
||||
|
||||
private void addVariables(List<VariableObjectDTO> variables, CategoryItemVO category, Map<String, Object> bizVariables, Map<String, Object> processVariables) {
|
||||
private void addVariables(List<VariableObjectDTO> variables, CategoryItemVO category, HistoricProcessInstance historicProcessInstance) {
|
||||
Map<String, Object> bizVariables = (Map<String, Object>) historicProcessInstance.getProcessVariables().getOrDefault(SIGN_VARIABLE, new HashMap<String, Object>());
|
||||
|
||||
CategoryGroupService categoryServiceGroup = SpringContextUtils.getBean(CategoryGroupService.class);
|
||||
List<CategoryGroupVarItemVo> groupVariables = categoryServiceGroup.searchGroupAndVarList(CategoryGroupVarSearchDto.builder()
|
||||
.dictId(category.getId())
|
||||
@ -277,12 +286,20 @@ public class CustomGetProcessInstanceVariablesToObjectCmd extends AbstractComman
|
||||
variables.add(VariableObjectDTO.builder()
|
||||
.key(variable.getCode())
|
||||
.desc(group.getGroupName() + variable.getName())
|
||||
.value(processVariables.getOrDefault(variable.getCode(), bizVariables.getOrDefault(variable.getCode(), null)))
|
||||
.value(bizVariables.getOrDefault(variable.getCode(), null))
|
||||
.type(convert(variable.getType()))
|
||||
.build());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addVariables(List<VariableObjectDTO> variables, CategoryItemVO category, Map<String, Object> bizVariables, Map<String, Object> processVariables) {
|
||||
CategoryGroupService categoryServiceGroup = SpringContextUtils.getBean(CategoryGroupService.class);
|
||||
List<CategoryGroupVarItemVo> groupVariables = categoryServiceGroup.searchGroupAndVarList(CategoryGroupVarSearchDto.builder()
|
||||
.dictId(category.getId())
|
||||
.category(category.getValue())
|
||||
.build());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
package cn.axzo.workflow.core.engine.cmd;
|
||||
|
||||
import cn.axzo.workflow.common.exception.WorkflowEngineException;
|
||||
import cn.axzo.workflow.common.model.request.category.CategoryGroupVarSearchDto;
|
||||
import cn.axzo.workflow.common.model.response.category.CategoryGroupVarItemVo;
|
||||
import cn.axzo.workflow.core.common.utils.SpringContextUtils;
|
||||
import cn.axzo.workflow.core.service.CategoryGroupService;
|
||||
import cn.axzo.workflow.core.service.CategoryService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||
@ -12,10 +17,13 @@ import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.axzo.workflow.common.code.BpmnInstanceRespCode.PROCESS_INSTANCE_NOT_EXISTS;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.BPM_MODEL_CATEGORY;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.SIGN_VARIABLE;
|
||||
|
||||
/**
|
||||
* 覆写指定流程中的变量
|
||||
@ -55,6 +63,29 @@ public class CustomOverrideProcessVariablesCmd extends AbstractCommand<Void> imp
|
||||
throw new WorkflowEngineException(PROCESS_INSTANCE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
Map<String, Object> signVariables = new HashMap<>();
|
||||
CategoryService categoryService = SpringContextUtils.getBean(CategoryService.class);
|
||||
CategoryGroupService categoryServiceGroup = SpringContextUtils.getBean(CategoryGroupService.class);
|
||||
categoryService.get(BPM_MODEL_CATEGORY, processInstance.getProcessDefinitionKey()).ifPresent(category -> {
|
||||
List<CategoryGroupVarItemVo> groupVariables = categoryServiceGroup.searchGroupAndVarList(CategoryGroupVarSearchDto.builder()
|
||||
.dictId(category.getId())
|
||||
.category(category.getValue())
|
||||
.build());
|
||||
|
||||
groupVariables.forEach(group -> {
|
||||
if (!CollectionUtils.isEmpty(group.getVars())) {
|
||||
group.getVars().forEach(variable -> {
|
||||
if (variables.containsKey(variable.getCode())) {
|
||||
signVariables.put(variable.getCode(), variables.get(variable.getCode()));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
if (!CollectionUtils.isEmpty(signVariables)) {
|
||||
variables.put(SIGN_VARIABLE, signVariables);
|
||||
}
|
||||
|
||||
runtimeService.setVariables(processInstanceId, variables);
|
||||
return null;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user