update - 政务流程启动校验流程定义,政务业务只能使用代运营流程定义
This commit is contained in:
parent
57f9a0d5f1
commit
f3446a604e
@ -21,7 +21,8 @@ public enum BpmnProcessDefinitionRespCode implements IModuleRespCode {
|
||||
PROCESS_DEFINITION_IS_SUSPENDED("006", "流程定义KEY【{}】处于挂起状态"),
|
||||
PROCESS_DEFINITION_KEY_NOT_MATCH("007", "流程定义的标识不一致, 请修改 BPMN 流程图"),
|
||||
PROCESS_DEFINITION_NAME_NOT_MATCH("008", "流程定义的名字期望是({}),当前是({}),请修改 BPMN 流程图"),
|
||||
PROCESS_DEFINITION_HAS_DIRTY_DATA("009", "流程定义KEY【{}】存在脏数据,当前模型没有流程定义内容")
|
||||
PROCESS_DEFINITION_HAS_DIRTY_DATA("009", "流程定义KEY【{}】存在脏数据,当前模型没有流程定义内容"),
|
||||
PROCESS_DEFINITION_IS_INVALID("010", "暂时无法发起,请先配置流程模型")
|
||||
;
|
||||
private String code;
|
||||
private String message;
|
||||
|
||||
@ -91,6 +91,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
@ -114,9 +115,11 @@ import static cn.axzo.workflow.common.enums.BpmnFlowNodeMode.GENERAL;
|
||||
import static cn.axzo.workflow.common.enums.BpmnFlowNodeMode.OR;
|
||||
import static cn.axzo.workflow.common.enums.BpmnFlowNodeType.NODE_STARTER;
|
||||
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.PROCESSING;
|
||||
import static cn.axzo.workflow.common.enums.WorkspaceType.GOVERNMENT;
|
||||
import static cn.axzo.workflow.core.common.code.BpmnInstanceRespCode.PROCESS_INSTANCE_NOT_EXISTS;
|
||||
import static cn.axzo.workflow.core.common.code.BpmnInstanceRespCode.RUNNING_INSTANCE_ONLY_FORECAST;
|
||||
import static cn.axzo.workflow.core.common.code.BpmnProcessDefinitionRespCode.PROCESS_DEFINITION_ID_NOT_EXISTS;
|
||||
import static cn.axzo.workflow.core.common.code.BpmnProcessDefinitionRespCode.PROCESS_DEFINITION_IS_INVALID;
|
||||
import static cn.axzo.workflow.core.common.code.BpmnProcessDefinitionRespCode.PROCESS_DEFINITION_IS_SUSPENDED;
|
||||
import static cn.axzo.workflow.core.common.code.BpmnProcessDefinitionRespCode.PROCESS_DEFINITION_KEY_NOT_EXISTS;
|
||||
import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getApprovalMethod;
|
||||
@ -275,26 +278,32 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
|
||||
public String createProcessInstance(BpmnProcessInstanceCreateDTO dto) {
|
||||
BpmnProcessDefinitionVO definition = null;
|
||||
if (StringUtils.isBlank(dto.getProcessDefinitionId())) {
|
||||
definition = processDefinitionService.getActiveProcessDefinitionByKey(dto.getProcessDefinitionKey(),
|
||||
dto.getTenantId());
|
||||
// 校验流程定义
|
||||
if (definition == null) {
|
||||
throw new WorkflowEngineException(PROCESS_DEFINITION_KEY_NOT_EXISTS, dto.getProcessDefinitionKey());
|
||||
}
|
||||
if (Objects.equals(SuspensionState.SUSPENDED.getStateCode(), definition.getSuspensionState())) {
|
||||
throw new WorkflowEngineException(PROCESS_DEFINITION_IS_SUSPENDED, dto.getProcessDefinitionKey());
|
||||
definition = processDefinitionService.getActiveProcessDefinitionByKey(dto.getProcessDefinitionKey(), dto.getTenantId());
|
||||
} else {
|
||||
definition = processDefinitionService.getProcessDefinition(dto.getProcessDefinitionId());
|
||||
}
|
||||
// 校验流程定义
|
||||
if (definition == null) {
|
||||
throw new WorkflowEngineException(PROCESS_DEFINITION_KEY_NOT_EXISTS, dto.getProcessDefinitionKey());
|
||||
}
|
||||
if (Objects.equals(SuspensionState.SUSPENDED.getStateCode(), definition.getSuspensionState())) {
|
||||
throw new WorkflowEngineException(PROCESS_DEFINITION_IS_SUSPENDED, dto.getProcessDefinitionKey());
|
||||
}
|
||||
Optional<CategoryItemVO> categoryItemVO = categoryService.get(BPM_MODEL_CATEGORY, definition.getCategory());
|
||||
//政务只能使用代运营的流程定义
|
||||
if (categoryItemVO.isPresent() && categoryItemVO.get().getWorkspaceTypeCode().equals(String.valueOf(GOVERNMENT.getCode()))) {
|
||||
if (StringUtils.isBlank(definition.getTenantId())) {
|
||||
throw new WorkflowEngineException(PROCESS_DEFINITION_IS_INVALID, dto.getProcessDefinitionKey());
|
||||
}
|
||||
}
|
||||
|
||||
categoryItemVO.ifPresent(itemVO -> dto.getVariables().put(INTERNAL_PROCESS_WORKSPACE_TYPE, WorkspaceType.getType(Integer.valueOf(itemVO.getWorkspaceTypeCode())).getCode()));
|
||||
dto.getVariables().put(INTERNAL_INITIATOR, dto.getInitiator().toJson());
|
||||
dto.getVariables().put(BIZ_ORG_RELATION, dto.getCooperationOrg());
|
||||
dto.getVariables().put(WORKFLOW_ENGINE_VERSION, serviceVersion);
|
||||
dto.getVariables().put(PENDING_TEMPLATE_VARIABLE, dto.getPendingVariables());
|
||||
dto.getVariables().put(INTERNAL_PROCESS_AGENT,
|
||||
!Objects.isNull(definition) && StringUtils.isNotBlank(definition.getTenantId()));
|
||||
categoryService.get(BPM_MODEL_CATEGORY, Objects.isNull(definition) ? dto.getProcessDefinitionId() : definition.getId())
|
||||
.ifPresent(category -> dto.getVariables().put(INTERNAL_PROCESS_WORKSPACE_TYPE,
|
||||
WorkspaceType.getType(Integer.valueOf(category.getWorkspaceTypeCode())).getCode()));
|
||||
dto.getVariables().put(INTERNAL_PROCESS_AGENT, StringUtils.isNotBlank(definition.getTenantId()));
|
||||
|
||||
// if (Objects.nonNull(dto.getNextApprover())) {
|
||||
// BpmnTaskDelegateAssigner nextApprover = dto.getNextApprover();
|
||||
// nextApprover.setTenantId(Objects.nonNull(nextApprover.getTenantId()) ? nextApprover.getTenantId
|
||||
@ -306,13 +315,11 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
|
||||
// 创建流程实例
|
||||
// 设置流程实例的开始人,参考 https://wenku.baidu.com/view/5538062e7a563c1ec5da50e2524de518964bd3f9.html
|
||||
Authentication.setAuthenticatedUserId(dto.getInitiator().buildAssigneeId());
|
||||
String name = StringUtils.isNotBlank(dto.getCustomProcessInstanceName()) ?
|
||||
dto.getCustomProcessInstanceName()
|
||||
: Objects.isNull(definition) ? "" : definition.getName();
|
||||
String name = StringUtils.isNotBlank(dto.getCustomProcessInstanceName()) ? dto.getCustomProcessInstanceName() : definition.getName();
|
||||
|
||||
// 设置流程名字
|
||||
ProcessInstanceBuilder instanceBuilder = runtimeService.createProcessInstanceBuilder()
|
||||
.processDefinitionId(Objects.isNull(definition) ? dto.getProcessDefinitionId() : definition.getId())
|
||||
.processDefinitionId(definition.getId())
|
||||
.businessKey(dto.getBusinessKey())
|
||||
.variables(dto.getVariables())
|
||||
.name(name)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user