Commit cc61bb1a61e837ac62dee76045d3cd77ed4f303b

Authored by smallNorthLee
1 parent 2123d7c0

review: 校验流程设计器第一个用户任务节点的规则类型是否为“审批人自选”

yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java
@@ -40,10 +40,7 @@ import org.springframework.stereotype.Service; @@ -40,10 +40,7 @@ import org.springframework.stereotype.Service;
40 import org.springframework.transaction.annotation.Transactional; 40 import org.springframework.transaction.annotation.Transactional;
41 import org.springframework.validation.annotation.Validated; 41 import org.springframework.validation.annotation.Validated;
42 42
43 -import java.util.ArrayList;  
44 -import java.util.List;  
45 -import java.util.Map;  
46 -import java.util.Objects; 43 +import java.util.*;
47 44
48 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; 45 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
49 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; 46 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
@@ -210,11 +207,11 @@ public class BpmModelServiceImpl implements BpmModelService { @@ -210,11 +207,11 @@ public class BpmModelServiceImpl implements BpmModelService {
210 public void deployModel(Long userId, String id) { 207 public void deployModel(Long userId, String id) {
211 // 1.1 校验流程模型存在 208 // 1.1 校验流程模型存在
212 Model model = validateModelManager(id, userId); 209 Model model = validateModelManager(id, userId);
  210 + BpmModelMetaInfoVO metaInfo = BpmModelConvert.INSTANCE.parseMetaInfo(model);
213 // 1.2 校验流程图 211 // 1.2 校验流程图
214 byte[] bpmnBytes = getModelBpmnXML(model.getId()); 212 byte[] bpmnBytes = getModelBpmnXML(model.getId());
215 - validateBpmnXml(bpmnBytes); 213 + validateBpmnXml(bpmnBytes, metaInfo.getType());
216 // 1.3 校验表单已配 214 // 1.3 校验表单已配
217 - BpmModelMetaInfoVO metaInfo = BpmModelConvert.INSTANCE.parseMetaInfo(model);  
218 BpmFormDO form = validateFormConfig(metaInfo); 215 BpmFormDO form = validateFormConfig(metaInfo);
219 // 1.4 校验任务分配规则已配置 216 // 1.4 校验任务分配规则已配置
220 taskCandidateInvoker.validateBpmnConfig(bpmnBytes); 217 taskCandidateInvoker.validateBpmnConfig(bpmnBytes);
@@ -234,7 +231,7 @@ public class BpmModelServiceImpl implements BpmModelService { @@ -234,7 +231,7 @@ public class BpmModelServiceImpl implements BpmModelService {
234 repositoryService.saveModel(model); 231 repositoryService.saveModel(model);
235 } 232 }
236 233
237 - private void validateBpmnXml(byte[] bpmnBytes) { 234 + private void validateBpmnXml(byte[] bpmnBytes, int type) {
238 BpmnModel bpmnModel = BpmnModelUtils.getBpmnModel(bpmnBytes); 235 BpmnModel bpmnModel = BpmnModelUtils.getBpmnModel(bpmnBytes);
239 if (bpmnModel == null) { 236 if (bpmnModel == null) {
240 throw exception(MODEL_NOT_EXISTS); 237 throw exception(MODEL_NOT_EXISTS);
@@ -252,10 +249,14 @@ public class BpmModelServiceImpl implements BpmModelService { @@ -252,10 +249,14 @@ public class BpmModelServiceImpl implements BpmModelService {
252 } 249 }
253 }); 250 });
254 // 3. 校验第一个用户任务节点的规则类型是否为“审批人自选” 251 // 3. 校验第一个用户任务节点的规则类型是否为“审批人自选”
255 - UserTask userTask = userTasks.get(0);  
256 - Integer candidateStrategy = parseCandidateStrategy(userTask); 252 + Map<Integer, UserTask> userTaskMap = new HashMap<>();
  253 + // BPMN 设计器,校验第一个用户任务节点
  254 + userTaskMap.put(BpmModelTypeEnum.BPMN.getType(), userTasks.get(0));
  255 + // SIMPLE 设计器,第一个节点固定为发起人所以校验第二个用户任务节点
  256 + userTaskMap.put(BpmModelTypeEnum.SIMPLE.getType(), userTasks.get(1));
  257 + Integer candidateStrategy = parseCandidateStrategy(userTaskMap.get(type));
257 if (Objects.equals(candidateStrategy, BpmTaskCandidateStrategyEnum.APPROVE_USER_SELECT.getStrategy())) { 258 if (Objects.equals(candidateStrategy, BpmTaskCandidateStrategyEnum.APPROVE_USER_SELECT.getStrategy())) {
258 - throw exception(MODEL_DEPLOY_FAIL_FIRST_USER_TASK_CANDIDATE_STRATEGY_ERROR, userTask.getName()); 259 + throw exception(MODEL_DEPLOY_FAIL_FIRST_USER_TASK_CANDIDATE_STRATEGY_ERROR, userTaskMap.get(type).getName());
259 } 260 }
260 } 261 }
261 262