mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	工作流 Flowable 发布流程的部分实现
This commit is contained in:
		| @@ -2,11 +2,11 @@ package cn.iocoder.yudao.module.bpm.convert.definition; | ||||
|  | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*; | ||||
| import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; | ||||
| import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO; | ||||
| import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||||
| import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | ||||
| import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; | ||||
| import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; | ||||
| import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO; | ||||
| import org.activiti.engine.impl.persistence.entity.SuspensionState; | ||||
| import org.activiti.engine.repository.Deployment; | ||||
| import org.activiti.engine.repository.Model; | ||||
|   | ||||
| @@ -1,11 +1,11 @@ | ||||
| package cn.iocoder.yudao.module.bpm.convert.definition; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||||
| import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageItemRespVO; | ||||
| import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO; | ||||
| import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; | ||||
| import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO; | ||||
| import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO; | ||||
| import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||||
| import org.activiti.engine.impl.persistence.entity.SuspensionState; | ||||
| import org.activiti.engine.repository.Deployment; | ||||
| import org.activiti.engine.repository.ProcessDefinition; | ||||
|   | ||||
| @@ -13,29 +13,6 @@ import javax.validation.Valid; | ||||
|  */ | ||||
| public interface BpmModelService extends BpmModelCommonService { | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * 将流程模型,部署成一个流程定义 | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      */ | ||||
|     void deployModel(String id); | ||||
|  | ||||
|     /** | ||||
|      * 删除模型 | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      */ | ||||
|     void deleteModel(String id); | ||||
|  | ||||
|     /** | ||||
|      * 修改模型的状态,实际更新的部署的流程定义的状态 | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      * @param state 状态 {@link org.activiti.engine.impl.persistence.entity.SuspensionState} | ||||
|      */ | ||||
|     void updateModelState(String id, Integer state); | ||||
|  | ||||
|     /** | ||||
|      * 获得流程模型编号对应的 BPMN Model | ||||
|      * | ||||
|   | ||||
| @@ -6,16 +6,14 @@ import cn.hutool.core.util.StrUtil; | ||||
| import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*; | ||||
| import cn.iocoder.yudao.module.bpm.convert.definition.BpmModelConvert; | ||||
| import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; | ||||
| import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO; | ||||
| import cn.iocoder.yudao.framework.activiti.core.util.ActivitiUtils; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||||
| import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | ||||
| import cn.iocoder.yudao.framework.common.util.object.PageUtils; | ||||
| import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; | ||||
| import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleRespVO; | ||||
| import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; | ||||
| import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; | ||||
| import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.activiti.bpmn.model.BpmnModel; | ||||
| import org.activiti.engine.RepositoryService; | ||||
| @@ -47,18 +45,22 @@ import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; | ||||
| @Service | ||||
| @Validated | ||||
| @Slf4j | ||||
| public class BpmModelServiceImpl implements BpmModelService { | ||||
| public class BpmModelServiceImpl extends BpmAbstractModelService implements BpmModelService { | ||||
|  | ||||
|     @Resource | ||||
|     private RepositoryService repositoryService; | ||||
|     @Resource | ||||
|     private BpmFormService bpmFormService; | ||||
|  | ||||
|     @Resource | ||||
|     private BpmProcessDefinitionService processDefinitionService; | ||||
|     @Resource | ||||
|     @Lazy // 解决循环依赖 | ||||
|     private BpmTaskAssignRuleService taskAssignRuleService; | ||||
|  | ||||
|  | ||||
|     public BpmModelServiceImpl(BpmFormService bpmFormService) { | ||||
|         super(bpmFormService); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public PageResult<BpmModelPageItemRespVO> getModelPage(BpmModelPageReqVO pageVO) { | ||||
|         ModelQuery modelQuery = repositoryService.createModelQuery(); | ||||
| @@ -167,7 +169,7 @@ public class BpmModelServiceImpl implements BpmModelService { | ||||
|         } | ||||
|         // TODO 芋艿:校验流程图的有效性;例如说,是否有开始的元素,是否有结束的元素; | ||||
|         // 校验表单已配 | ||||
|         BpmFormDO form = checkFormConfig(model); | ||||
|         BpmFormDO form = checkFormConfig(model.getMetaInfo()); | ||||
|         // 校验任务分配规则已配置 | ||||
|         checkTaskAssignRuleAllConfig(id); | ||||
|  | ||||
| @@ -214,28 +216,6 @@ public class BpmModelServiceImpl implements BpmModelService { | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 校验流程表单已配置 | ||||
|      * | ||||
|      * @param model 流程模型 | ||||
|      * @return 流程表单 | ||||
|      */ | ||||
|     private BpmFormDO checkFormConfig(Model model) { | ||||
|         BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); | ||||
|         if (metaInfo == null || metaInfo.getFormType() == null) { | ||||
|             throw exception(MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG); | ||||
|         } | ||||
|         // 校验表单存在 | ||||
|         if (Objects.equals(metaInfo.getFormType(), BpmModelFormTypeEnum.NORMAL.getType())) { | ||||
|             BpmFormDO form = bpmFormService.getForm(metaInfo.getFormId()); | ||||
|             if (form == null) { | ||||
|                 throw exception(FORM_NOT_EXISTS); | ||||
|             } | ||||
|             return form; | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     @Transactional(rollbackFor = Exception.class) | ||||
|     public void deleteModel(String id) { | ||||
| @@ -291,10 +271,4 @@ public class BpmModelServiceImpl implements BpmModelService { | ||||
|         return repositoryService.createModelQuery().modelKey(key).singleResult(); | ||||
|     } | ||||
|  | ||||
|     private void checkKeyNCName(String key) { | ||||
|         if (!ValidationUtils.isXmlNCName(key)) { | ||||
|             throw exception(MODEL_KEY_VALID); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -5,9 +5,9 @@ import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmPro | ||||
| import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageReqVO; | ||||
| import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO; | ||||
| import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO; | ||||
| import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||||
| import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO; | ||||
| import org.activiti.bpmn.model.BpmnModel; | ||||
| import org.activiti.engine.repository.Deployment; | ||||
| import org.activiti.engine.repository.ProcessDefinition; | ||||
|   | ||||
| @@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil; | ||||
| import cn.hutool.core.util.ObjectUtil; | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import cn.iocoder.yudao.module.bpm.convert.definition.BpmProcessDefinitionConvert; | ||||
| import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO; | ||||
| import cn.iocoder.yudao.framework.activiti.core.util.ActivitiUtils; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.util.object.PageUtils; | ||||
| @@ -15,6 +14,7 @@ import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmPro | ||||
| import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; | ||||
| import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO; | ||||
| import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmProcessDefinitionExtMapper; | ||||
| import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.activiti.bpmn.model.BpmnModel; | ||||
| import org.activiti.engine.RepositoryService; | ||||
|   | ||||
| @@ -1,39 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.bpm.service.definition.dto; | ||||
|  | ||||
| import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; | ||||
| import lombok.Data; | ||||
|  | ||||
| /** | ||||
|  * BPM 流程 MetaInfo Response DTO | ||||
|  * 主要用于 {@link org.activiti.engine.repository.Model#setMetaInfo(String)} 的存储 | ||||
|  * | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| @Data | ||||
| public class BpmModelMetaInfoRespDTO { | ||||
|  | ||||
|     /** | ||||
|      * 流程描述 | ||||
|      */ | ||||
|     private String description; | ||||
|     /** | ||||
|      * 表单类型 | ||||
|      */ | ||||
|     private Integer formType; | ||||
|     /** | ||||
|      * 表单编号 | ||||
|      * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 | ||||
|      */ | ||||
|     private Long formId; | ||||
|     /** | ||||
|      * 自定义表单的提交路径,使用 Vue 的路由地址 | ||||
|      * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 | ||||
|      */ | ||||
|     private String formCustomCreatePath; | ||||
|     /** | ||||
|      * 自定义表单的查看路径,使用 Vue 的路由地址 | ||||
|      * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 | ||||
|      */ | ||||
|     private String formCustomViewPath; | ||||
|  | ||||
| } | ||||
| @@ -1,104 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.bpm.service.definition.dto; | ||||
|  | ||||
| import cn.hutool.core.collection.CollUtil; | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; | ||||
| import lombok.Data; | ||||
|  | ||||
| import javax.validation.constraints.AssertTrue; | ||||
| import javax.validation.constraints.NotEmpty; | ||||
| import javax.validation.constraints.NotNull; | ||||
| import java.util.List; | ||||
| import java.util.Objects; | ||||
|  | ||||
| /** | ||||
|  * 流程定义创建 Request DTO | ||||
|  */ | ||||
| @Data | ||||
| public class BpmProcessDefinitionCreateReqDTO { | ||||
|  | ||||
|     // ========== 模型相关 ========== | ||||
|  | ||||
|     /** | ||||
|      * 流程模型的编号 | ||||
|      */ | ||||
|     @NotEmpty(message = "流程模型编号不能为空") | ||||
|     private String modelId; | ||||
|     /** | ||||
|      * 流程标识 | ||||
|      */ | ||||
|     @NotEmpty(message = "流程标识不能为空") | ||||
|     private String key; | ||||
|     /** | ||||
|      * 流程名称 | ||||
|      */ | ||||
|     @NotEmpty(message = "流程名称不能为空") | ||||
|     private String name; | ||||
|     /** | ||||
|      * 流程描述 | ||||
|      */ | ||||
|     private String description; | ||||
|     /** | ||||
|      * 流程分类 | ||||
|      * 参见 bpm_model_category 数据字典 | ||||
|      */ | ||||
|     @NotEmpty(message = "流程分类不能为空") | ||||
|     private String category; | ||||
|     /** | ||||
|      * BPMN XML | ||||
|      */ | ||||
|     @NotEmpty(message = "BPMN XML 不能为空") | ||||
|     private byte[] bpmnBytes; | ||||
|  | ||||
|     // ========== 表单相关 ========== | ||||
|  | ||||
|     /** | ||||
|      * 表单类型 | ||||
|      */ | ||||
|     @NotNull(message = "表单类型不能为空") | ||||
|     private Integer formType; | ||||
|     /** | ||||
|      * 动态表单编号 | ||||
|      * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 | ||||
|      */ | ||||
|     private Long formId; | ||||
|     /** | ||||
|      * 表单的配置 | ||||
|      * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 | ||||
|      */ | ||||
|     private String formConf; | ||||
|     /** | ||||
|      * 表单项的数组 | ||||
|      * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 | ||||
|      */ | ||||
|     private List<String> formFields; | ||||
|     /** | ||||
|      * 自定义表单的提交路径,使用 Vue 的路由地址 | ||||
|      * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 | ||||
|      */ | ||||
|     private String formCustomCreatePath; | ||||
|     /** | ||||
|      * 自定义表单的查看路径,使用 Vue 的路由地址 | ||||
|      * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 | ||||
|      */ | ||||
|     private String formCustomViewPath; | ||||
|  | ||||
|     @AssertTrue(message = "流程表单信息不全") | ||||
|     public boolean isNormalFormTypeValid() { | ||||
|         // 如果非业务表单,则直接通过 | ||||
|         if (!Objects.equals(formType, BpmModelFormTypeEnum.NORMAL.getType())) { | ||||
|             return true; | ||||
|         } | ||||
|         return formId != null && StrUtil.isNotEmpty(formConf) && CollUtil.isNotEmpty(formFields); | ||||
|     } | ||||
|  | ||||
|     @AssertTrue(message = "业务表单信息不全") | ||||
|     public boolean isNormalCustomTypeValid() { | ||||
|         // 如果非业务表单,则直接通过 | ||||
|         if (!Objects.equals(formType, BpmModelFormTypeEnum.CUSTOM.getType())) { | ||||
|             return true; | ||||
|         } | ||||
|         return StrUtil.isNotEmpty(formCustomCreatePath) && StrUtil.isNotEmpty(formCustomViewPath); | ||||
|     } | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 jason
					jason