mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 12:18:42 +08:00 
			
		
		
		
	完善工作流的注释
This commit is contained in:
		@@ -22,6 +22,7 @@ import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUti
 | 
			
		||||
@RequestMapping("/bpm/process-instance")
 | 
			
		||||
@Validated
 | 
			
		||||
public class BpmProcessInstanceController {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private BpmProcessInstanceService processInstanceService;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
package cn.iocoder.yudao.module.bpm.service.definition;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.lang.Assert;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
 | 
			
		||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormCreateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO;
 | 
			
		||||
@@ -11,9 +13,6 @@ import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmFormMapper;
 | 
			
		||||
import cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants;
 | 
			
		||||
import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum;
 | 
			
		||||
import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmFormFieldRespDTO;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
 | 
			
		||||
import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
@@ -66,7 +65,7 @@ public class BpmFormServiceImpl implements BpmFormService {
 | 
			
		||||
 | 
			
		||||
    private void validateFormExists(Long id) {
 | 
			
		||||
        if (formMapper.selectById(id) == null) {
 | 
			
		||||
            throw ServiceExceptionUtil.exception(ErrorCodeConstants.FORM_NOT_EXISTS);
 | 
			
		||||
            throw exception(ErrorCodeConstants.FORM_NOT_EXISTS);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -129,7 +128,7 @@ public class BpmFormServiceImpl implements BpmFormService {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            // 如果存在,则报错
 | 
			
		||||
            throw ServiceExceptionUtil.exception(ErrorCodeConstants.FORM_FIELD_REPEAT, oldLabel, fieldDTO.getLabel(), fieldDTO.getVModel());
 | 
			
		||||
            throw exception(ErrorCodeConstants.FORM_FIELD_REPEAT, oldLabel, fieldDTO.getLabel(), fieldDTO.getVModel());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -127,7 +127,8 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
 | 
			
		||||
                .deploy();
 | 
			
		||||
 | 
			
		||||
        // 设置 ProcessDefinition 的 category 分类
 | 
			
		||||
        ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deploy.getId()).singleResult();
 | 
			
		||||
        ProcessDefinition definition = repositoryService.createProcessDefinitionQuery()
 | 
			
		||||
                .deploymentId(deploy.getId()).singleResult();
 | 
			
		||||
        repositoryService.setProcessDefinitionCategory(definition.getId(), createReqDTO.getCategory());
 | 
			
		||||
        // 注意 1,ProcessDefinition 的 key 和 name 是通过 BPMN 中的 <bpmn2:process /> 的 id 和 name 决定
 | 
			
		||||
        // 注意 2,目前该项目的设计上,需要保证 Model、Deployment、ProcessDefinition 使用相同的 key,保证关联性。
 | 
			
		||||
@@ -198,7 +199,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
 | 
			
		||||
        // 校验 BPMN XML 信息
 | 
			
		||||
        BpmnModel newModel = buildBpmnModel(createReqDTO.getBpmnBytes());
 | 
			
		||||
        BpmnModel oldModel = getBpmnModel(oldProcessDefinition.getId());
 | 
			
		||||
        //TODO  貌似 flowable 不修改这个也不同。需要看看。 sourceSystemId 不同
 | 
			
		||||
        // TODO  貌似 flowable 不修改这个也不同。需要看看。 sourceSystemId 不同
 | 
			
		||||
        if (FlowableUtils.equals(oldModel, newModel)) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
@@ -218,8 +219,6 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
 | 
			
		||||
        return converter.convertToBpmnModel(new BytesStreamSource(bpmnBytes), true, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public BpmProcessDefinitionExtDO getProcessDefinitionExt(String id) {
 | 
			
		||||
        return processDefinitionMapper.selectByProcessDefinitionId(id);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user