mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-16 20:15:06 +08:00
工作流 Flowable 发布流程的部分实现
This commit is contained in:
@ -0,0 +1,56 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.definition;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
|
||||
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.BpmModelMetaInfoRespDTO;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
|
||||
/**
|
||||
* 流程模型通用抽象类
|
||||
* Activiti 和 flowable 通用的流程模型抽象类, Activiti 和 flowable 两边通用的方法
|
||||
*
|
||||
* @author yunlongn
|
||||
* @author jason
|
||||
*/
|
||||
public abstract class BpmAbstractModelService {
|
||||
|
||||
protected final BpmFormService bpmFormService;
|
||||
|
||||
public BpmAbstractModelService(BpmFormService bpmFormService) {
|
||||
this.bpmFormService = bpmFormService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验流程表单已配置
|
||||
*
|
||||
* @param metaInfoStr 流程模型 metaInfo 字段
|
||||
* @return 流程表单
|
||||
*/
|
||||
protected BpmFormDO checkFormConfig(String metaInfoStr) {
|
||||
BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(metaInfoStr, 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;
|
||||
}
|
||||
|
||||
|
||||
protected void checkKeyNCName(String key) {
|
||||
if (!ValidationUtils.isXmlNCName(key)) {
|
||||
throw exception(MODEL_KEY_VALID);
|
||||
}
|
||||
}
|
||||
}
|
@ -44,4 +44,26 @@ public interface BpmModelCommonService {
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateModel(@Valid BpmModelUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 将流程模型,部署成一个流程定义
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deployModel(String id);
|
||||
|
||||
/**
|
||||
* 删除模型
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteModel(String id);
|
||||
|
||||
/**
|
||||
* 修改模型的状态,实际更新的部署的流程定义的状态
|
||||
*
|
||||
* @param id 编号
|
||||
* @param state 状态
|
||||
*/
|
||||
void updateModelState(String id, Integer state);
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
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
|
||||
* 主要用于 { 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;
|
||||
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
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