|
@@ -99,7 +99,7 @@ public class BpmModelServiceImpl implements BpmModelService {
|
|
|
public String createModel(@Valid BpmModelCreateReqVO createReqVO, String bpmnXml) {
|
|
|
checkKeyNCName(createReqVO.getKey());
|
|
|
// 校验流程标识已经存在
|
|
|
- Model keyModel = this.getModelByKey(createReqVO.getKey());
|
|
|
+ Model keyModel = getModelByKey(createReqVO.getKey());
|
|
|
if (keyModel != null) {
|
|
|
throw exception(MODEL_KEY_EXISTS, createReqVO.getKey());
|
|
|
}
|
|
@@ -151,42 +151,43 @@ public class BpmModelServiceImpl implements BpmModelService {
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务
|
|
|
public void deployModel(String id) {
|
|
|
- // 校验流程模型存在
|
|
|
+ // 1.1 校验流程模型存在
|
|
|
Model model = repositoryService.getModel(id);
|
|
|
if (ObjectUtils.isEmpty(model)) {
|
|
|
throw exception(MODEL_NOT_EXISTS);
|
|
|
}
|
|
|
- // 校验流程图
|
|
|
+ // 1.2 校验流程图
|
|
|
+ // TODO 芋艿:校验流程图的有效性;例如说,是否有开始的元素,是否有结束的元素;
|
|
|
byte[] bpmnBytes = repositoryService.getModelEditorSource(model.getId());
|
|
|
if (bpmnBytes == null) {
|
|
|
throw exception(MODEL_NOT_EXISTS);
|
|
|
}
|
|
|
- // TODO 芋艿:校验流程图的有效性;例如说,是否有开始的元素,是否有结束的元素;
|
|
|
- // 校验表单已配
|
|
|
+ // 1.3 校验表单已配
|
|
|
BpmFormDO form = checkFormConfig(model.getMetaInfo());
|
|
|
- //校验任务分配规则已配置
|
|
|
+ // 1.4 校验任务分配规则已配置
|
|
|
taskAssignRuleService.checkTaskAssignRuleAllConfig(id);
|
|
|
|
|
|
+ // 1.5 校验模型是否发生修改。如果未修改,则不允许创建
|
|
|
BpmProcessDefinitionCreateReqDTO definitionCreateReqDTO = BpmModelConvert.INSTANCE.convert2(model, form).setBpmnBytes(bpmnBytes);
|
|
|
- //校验模型是否发生修改。如果未修改,则不允许创建
|
|
|
if (processDefinitionService.isProcessDefinitionEquals(definitionCreateReqDTO)) { // 流程定义的信息相等
|
|
|
- ProcessDefinition oldProcessInstance = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId());
|
|
|
- if (oldProcessInstance != null && taskAssignRuleService.isTaskAssignRulesEquals(model.getId(), oldProcessInstance.getId())) {
|
|
|
+ ProcessDefinition oldProcessDefinition = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId());
|
|
|
+ if (oldProcessDefinition != null && taskAssignRuleService.isTaskAssignRulesEquals(model.getId(), oldProcessDefinition.getId())) {
|
|
|
throw exception(MODEL_DEPLOY_FAIL_TASK_INFO_EQUALS);
|
|
|
}
|
|
|
}
|
|
|
- // 创建流程定义
|
|
|
+
|
|
|
+ // 2.1 创建流程定义
|
|
|
String definitionId = processDefinitionService.createProcessDefinition(definitionCreateReqDTO);
|
|
|
|
|
|
- // 将老的流程定义进行挂起。也就是说,只有最新部署的流程定义,才可以发起任务。
|
|
|
+ // 2.2 将老的流程定义进行挂起。也就是说,只有最新部署的流程定义,才可以发起任务。
|
|
|
updateProcessDefinitionSuspended(model.getDeploymentId());
|
|
|
|
|
|
- // 更新 model 的 deploymentId,进行关联
|
|
|
+ // 2.3 更新 model 的 deploymentId,进行关联
|
|
|
ProcessDefinition definition = processDefinitionService.getProcessDefinition(definitionId);
|
|
|
model.setDeploymentId(definition.getDeploymentId());
|
|
|
repositoryService.saveModel(model);
|
|
|
|
|
|
- //复制任务分配规则
|
|
|
+ // 2.4 复制任务分配规则
|
|
|
taskAssignRuleService.copyTaskAssignRules(id, definition.getId());
|
|
|
}
|
|
|
|