Commit dc7a43438041b4ada0caabc2df8ba395823b359e
1 parent
a0c7692c
增加流程定义的 VO
Showing
12 changed files
with
223 additions
and
80 deletions
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/model/BpmModelController.java
| 1 | package cn.iocoder.yudao.adminserver.modules.bpm.controller.model; | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.controller.model; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; | ||
| 4 | -import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.ModelPageReqVO; | ||
| 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO; | 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO; |
| 6 | -import cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.BpmModelService; | 4 | +import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelRespVO; |
| 5 | +import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.ModelPageReqVO; | ||
| 6 | +import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; | ||
| 7 | +import cn.iocoder.yudao.adminserver.modules.bpm.service.model.BpmModelService; | ||
| 7 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 8 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 8 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 9 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 9 | import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; | 10 | import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; |
| 10 | import io.swagger.annotations.Api; | 11 | import io.swagger.annotations.Api; |
| 11 | import io.swagger.annotations.ApiOperation; | 12 | import io.swagger.annotations.ApiOperation; |
| 12 | -import org.activiti.engine.repository.Model; | ||
| 13 | import org.springframework.validation.annotation.Validated; | 13 | import org.springframework.validation.annotation.Validated; |
| 14 | import org.springframework.web.bind.annotation.*; | 14 | import org.springframework.web.bind.annotation.*; |
| 15 | 15 | ||
| @@ -32,7 +32,7 @@ public class BpmModelController { | @@ -32,7 +32,7 @@ public class BpmModelController { | ||
| 32 | 32 | ||
| 33 | @GetMapping ("/page") | 33 | @GetMapping ("/page") |
| 34 | @ApiOperation(value = "分页数据") | 34 | @ApiOperation(value = "分页数据") |
| 35 | - public CommonResult<PageResult<Model>> getModelPage(ModelPageReqVO pageVO) { | 35 | + public CommonResult<PageResult<BpmModelRespVO>> getModelPage(ModelPageReqVO pageVO) { |
| 36 | return success(bpmModelService.getModelPage(pageVO)); | 36 | return success(bpmModelService.getModelPage(pageVO)); |
| 37 | } | 37 | } |
| 38 | 38 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/model/vo/BpmModelBaseVO.java
| @@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty; | @@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty; | ||
| 4 | import lombok.Data; | 4 | import lombok.Data; |
| 5 | 5 | ||
| 6 | import javax.validation.constraints.NotEmpty; | 6 | import javax.validation.constraints.NotEmpty; |
| 7 | +import javax.validation.constraints.NotNull; | ||
| 7 | 8 | ||
| 8 | /** | 9 | /** |
| 9 | * 流程定义 Base VO,提供给添加、修改、详细的子 VO 使用 | 10 | * 流程定义 Base VO,提供给添加、修改、详细的子 VO 使用 |
| @@ -12,6 +13,10 @@ import javax.validation.constraints.NotEmpty; | @@ -12,6 +13,10 @@ import javax.validation.constraints.NotEmpty; | ||
| 12 | @Data | 13 | @Data |
| 13 | public class BpmModelBaseVO { | 14 | public class BpmModelBaseVO { |
| 14 | 15 | ||
| 16 | + @ApiModelProperty(value = "流程标识", required = true, example = "process_yudao") | ||
| 17 | + @NotEmpty(message = "流程标识不能为空") | ||
| 18 | + private String key; | ||
| 19 | + | ||
| 15 | @ApiModelProperty(value = "流程名称", required = true, example = "芋道") | 20 | @ApiModelProperty(value = "流程名称", required = true, example = "芋道") |
| 16 | @NotEmpty(message = "流程名称不能为空") | 21 | @NotEmpty(message = "流程名称不能为空") |
| 17 | private String name; | 22 | private String name; |
| @@ -20,4 +25,12 @@ public class BpmModelBaseVO { | @@ -20,4 +25,12 @@ public class BpmModelBaseVO { | ||
| 20 | @NotEmpty(message = "流程描述不能为空") | 25 | @NotEmpty(message = "流程描述不能为空") |
| 21 | private String description; | 26 | private String description; |
| 22 | 27 | ||
| 28 | + @ApiModelProperty(value = "流程分类", notes = "参见 bpm_model_category 数据字典", example = "1") | ||
| 29 | + @NotEmpty(message = "流程分类不能为空") | ||
| 30 | + private String category; | ||
| 31 | + | ||
| 32 | + @ApiModelProperty(value = "表单编号", example = "1024") | ||
| 33 | + @NotNull(message = "表单编号不能为空") | ||
| 34 | + private Long formId; | ||
| 35 | + | ||
| 23 | } | 36 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/model/vo/BpmModelCreateReqVO.java
| @@ -14,10 +14,6 @@ import javax.validation.constraints.NotEmpty; | @@ -14,10 +14,6 @@ import javax.validation.constraints.NotEmpty; | ||
| 14 | @ToString(callSuper = true) | 14 | @ToString(callSuper = true) |
| 15 | public class BpmModelCreateReqVO extends BpmModelBaseVO { | 15 | public class BpmModelCreateReqVO extends BpmModelBaseVO { |
| 16 | 16 | ||
| 17 | - @ApiModelProperty(value = "流程标识", required = true, example = "process_yudao") | ||
| 18 | - @NotEmpty(message = "流程标识不能为空") | ||
| 19 | - private String key; | ||
| 20 | - | ||
| 21 | @ApiModelProperty(value = "BPMN XML", required = true) | 17 | @ApiModelProperty(value = "BPMN XML", required = true) |
| 22 | @NotEmpty(message = "BPMN XML 不能为空") | 18 | @NotEmpty(message = "BPMN XML 不能为空") |
| 23 | private String bpmnXml; | 19 | private String bpmnXml; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/model/vo/BpmModelRespVO.java
| @@ -6,6 +6,8 @@ import lombok.Data; | @@ -6,6 +6,8 @@ import lombok.Data; | ||
| 6 | import lombok.EqualsAndHashCode; | 6 | import lombok.EqualsAndHashCode; |
| 7 | import lombok.ToString; | 7 | import lombok.ToString; |
| 8 | 8 | ||
| 9 | +import java.util.Date; | ||
| 10 | + | ||
| 9 | @ApiModel("流程定义 Response VO") | 11 | @ApiModel("流程定义 Response VO") |
| 10 | @Data | 12 | @Data |
| 11 | @EqualsAndHashCode(callSuper = true) | 13 | @EqualsAndHashCode(callSuper = true) |
| @@ -15,4 +17,13 @@ public class BpmModelRespVO extends BpmModelBaseVO { | @@ -15,4 +17,13 @@ public class BpmModelRespVO extends BpmModelBaseVO { | ||
| 15 | @ApiModelProperty(value = "编号", required = true, example = "1024") | 17 | @ApiModelProperty(value = "编号", required = true, example = "1024") |
| 16 | private String id; | 18 | private String id; |
| 17 | 19 | ||
| 20 | + @ApiModelProperty(value = "版本", required = true, example = "1") | ||
| 21 | + private Integer revision; | ||
| 22 | + | ||
| 23 | + @ApiModelProperty(value = "表单名字", example = "请假表单") | ||
| 24 | + private String formName; | ||
| 25 | + | ||
| 26 | + @ApiModelProperty(value = "创建时间", required = true) | ||
| 27 | + private Date createTime; | ||
| 28 | + | ||
| 18 | } | 29 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/model/ModelConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.bpm.convert.model; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO; | ||
| 4 | +import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelRespVO; | ||
| 5 | +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; | ||
| 6 | +import cn.iocoder.yudao.adminserver.modules.bpm.service.model.dto.BpmModelMetaInfoRespDTO; | ||
| 7 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 8 | +import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | ||
| 9 | +import org.activiti.engine.impl.persistence.entity.ModelEntity; | ||
| 10 | +import org.activiti.engine.repository.Model; | ||
| 11 | +import org.mapstruct.Mapper; | ||
| 12 | +import org.mapstruct.factory.Mappers; | ||
| 13 | + | ||
| 14 | +import java.util.List; | ||
| 15 | +import java.util.Map; | ||
| 16 | + | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * 流程定义 Convert | ||
| 20 | + * | ||
| 21 | + * @author yunlongn | ||
| 22 | + */ | ||
| 23 | +@Mapper | ||
| 24 | +public interface ModelConvert { | ||
| 25 | + | ||
| 26 | + ModelConvert INSTANCE = Mappers.getMapper(ModelConvert.class); | ||
| 27 | + | ||
| 28 | + default List<BpmModelRespVO> convertList(List<Model> list, Map<Long, BpmFormDO> formMap) { | ||
| 29 | + return CollectionUtils.convertList(list, model -> { | ||
| 30 | + BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); | ||
| 31 | + BpmFormDO form = metaInfo != null ? formMap.get(metaInfo.getFormId()) : null; | ||
| 32 | + return convert(model, form); | ||
| 33 | + }); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + default BpmModelRespVO convert(Model model, BpmFormDO form) { | ||
| 37 | + BpmModelRespVO modelRespVO = new BpmModelRespVO(); | ||
| 38 | + modelRespVO.setId(model.getId()); | ||
| 39 | + modelRespVO.setName(model.getName()); | ||
| 40 | + modelRespVO.setKey(model.getKey()); | ||
| 41 | + modelRespVO.setCategory(model.getCategory()); | ||
| 42 | + modelRespVO.setCreateTime(model.getCreateTime()); | ||
| 43 | + BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); | ||
| 44 | + if (metaInfo != null) { | ||
| 45 | + modelRespVO.setDescription(metaInfo.getDescription()); | ||
| 46 | + } | ||
| 47 | + if (form != null) { | ||
| 48 | + modelRespVO.setFormId(form.getId()); | ||
| 49 | + modelRespVO.setFormName(form.getName()); | ||
| 50 | + } | ||
| 51 | + if (model instanceof ModelEntity) { | ||
| 52 | + ModelEntity modelEntity = (ModelEntity) model; | ||
| 53 | + modelRespVO.setRevision(modelEntity.getRevision()); | ||
| 54 | + } | ||
| 55 | + return modelRespVO; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + default void copy(Model model, BpmModelCreateReqVO bean) { | ||
| 59 | + model.setName(bean.getName()); | ||
| 60 | + model.setKey(bean.getKey()); | ||
| 61 | + model.setCategory(bean.getCategory()); | ||
| 62 | + model.setMetaInfo(JsonUtils.toJsonString(this.buildMetaInfo(bean.getDescription(), bean.getFormId()))); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + default BpmModelMetaInfoRespDTO buildMetaInfo(String description, Long formId) { | ||
| 66 | + BpmModelMetaInfoRespDTO metaInfo = new BpmModelMetaInfoRespDTO(); | ||
| 67 | + metaInfo.setDescription(description); | ||
| 68 | + metaInfo.setFormId(formId); | ||
| 69 | + return metaInfo; | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/workflow/ModelConvert.java deleted
| 1 | -package cn.iocoder.yudao.adminserver.modules.bpm.convert.workflow; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelRespVO; | ||
| 4 | -import org.activiti.engine.repository.Model; | ||
| 5 | -import org.mapstruct.Mapper; | ||
| 6 | -import org.mapstruct.factory.Mappers; | ||
| 7 | - | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * @author yunlongn | ||
| 11 | - */ | ||
| 12 | -@Mapper | ||
| 13 | -public interface ModelConvert { | ||
| 14 | - ModelConvert INSTANCE = Mappers.getMapper(ModelConvert.class); | ||
| 15 | - | ||
| 16 | - BpmModelRespVO convert(Model model); | ||
| 17 | -} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/BpmErrorCodeConstants.java
| @@ -5,32 +5,34 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode; | @@ -5,32 +5,34 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode; | ||
| 5 | /** | 5 | /** |
| 6 | * 工作流 错误码枚举类 | 6 | * 工作流 错误码枚举类 |
| 7 | * | 7 | * |
| 8 | - * 工作流系统,使用 1-003-000-000 段 | 8 | + * 工作流系统,使用 1-009-000-000 段 |
| 9 | */ | 9 | */ |
| 10 | public interface BpmErrorCodeConstants { | 10 | public interface BpmErrorCodeConstants { |
| 11 | 11 | ||
| 12 | - // ========== 通用流程处理 模块 1-003-000-000 ========== | ||
| 13 | - ErrorCode PROCESS_INSTANCE_NOT_EXISTS = new ErrorCode(1003000001, "流程实例不存在"); | ||
| 14 | - ErrorCode HIGHLIGHT_IMG_ERROR = new ErrorCode(1003000002, "获取高亮流程图异常"); | 12 | + // ========== 通用流程处理 模块 1-009-000-000 ========== |
| 13 | + ErrorCode PROCESS_INSTANCE_NOT_EXISTS = new ErrorCode(1009000001, "流程实例不存在"); | ||
| 14 | + ErrorCode HIGHLIGHT_IMG_ERROR = new ErrorCode(1009000002, "获取高亮流程图异常"); | ||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | - // ========== OA 流程模块 1-003-001-000 ========== | ||
| 18 | - ErrorCode OA_LEAVE_NOT_EXISTS = new ErrorCode(1003001001, "请假申请不存在"); | ||
| 19 | - ErrorCode OA_PM_POST_NOT_EXISTS = new ErrorCode(1003001002, "项目经理岗位未设置"); | ||
| 20 | - ErrorCode OA_DEPART_PM_POST_NOT_EXISTS = new ErrorCode(1003001003, "部门的项目经理不存在"); | ||
| 21 | - ErrorCode OA_BM_POST_NOT_EXISTS = new ErrorCode(1003001004, "部门经理岗位未设置"); | ||
| 22 | - ErrorCode OA_DEPART_BM_POST_NOT_EXISTS = new ErrorCode(1003001005, "部门的部门经理不存在"); | ||
| 23 | - ErrorCode OA_HR_POST_NOT_EXISTS = new ErrorCode(1003001006, "HR岗位未设置"); | ||
| 24 | - ErrorCode OA_DAY_LEAVE_ERROR = new ErrorCode(1003001007, "请假天数必须>=1"); | 17 | + // ========== OA 流程模块 1-009-001-000 ========== |
| 18 | + ErrorCode OA_LEAVE_NOT_EXISTS = new ErrorCode(1009001001, "请假申请不存在"); | ||
| 19 | + ErrorCode OA_PM_POST_NOT_EXISTS = new ErrorCode(1009001002, "项目经理岗位未设置"); | ||
| 20 | + ErrorCode OA_DEPART_PM_POST_NOT_EXISTS = new ErrorCode(1009001009, "部门的项目经理不存在"); | ||
| 21 | + ErrorCode OA_BM_POST_NOT_EXISTS = new ErrorCode(1009001004, "部门经理岗位未设置"); | ||
| 22 | + ErrorCode OA_DEPART_BM_POST_NOT_EXISTS = new ErrorCode(1009001005, "部门的部门经理不存在"); | ||
| 23 | + ErrorCode OA_HR_POST_NOT_EXISTS = new ErrorCode(1009001006, "HR岗位未设置"); | ||
| 24 | + ErrorCode OA_DAY_LEAVE_ERROR = new ErrorCode(1009001007, "请假天数必须>=1"); | ||
| 25 | + | ||
| 26 | + // ========== OA 工作流模块 1-009-002-000 ========== | ||
| 27 | + ErrorCode BPM_MODEL_KEY_EXISTS = new ErrorCode(1009002000, "已经存在流程标识为【{}】的流程"); | ||
| 25 | 28 | ||
| 26 | - // ========== OA 工作流模块 1-003-002-000 ========== | ||
| 27 | ErrorCode BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS = new ErrorCode(1004001001, "模型数据为空,请先成功设计流程并保存"); | 29 | ErrorCode BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS = new ErrorCode(1004001001, "模型数据为空,请先成功设计流程并保存"); |
| 28 | ErrorCode BPMN_MODEL_ERROR = new ErrorCode(1004001002, "工作流模型异常"); | 30 | ErrorCode BPMN_MODEL_ERROR = new ErrorCode(1004001002, "工作流模型异常"); |
| 29 | - ErrorCode BPMN_MODEL_PROCESS_NOT_EXISTS = new ErrorCode(1004001003, "流程数据为空"); | 31 | + ErrorCode BPMN_MODEL_PROCESS_NOT_EXISTS = new ErrorCode(1004001009, "流程数据为空"); |
| 30 | ErrorCode BPMN_PROCESS_DEFINITION_NOT_EXISTS = new ErrorCode(1004001004, "流程定义不存在"); | 32 | ErrorCode BPMN_PROCESS_DEFINITION_NOT_EXISTS = new ErrorCode(1004001004, "流程定义不存在"); |
| 31 | 33 | ||
| 32 | - // ========== 动态表单模块 1-003-003-000 ========== | ||
| 33 | - ErrorCode BPM_FORM_NOT_EXISTS = new ErrorCode(1003003000, "动态表单不存在"); | ||
| 34 | - ErrorCode BPM_FORM_FIELD_REPEAT = new ErrorCode(1003003000, "表单项({}) 和 ({}) 使用了相同的字段名({})"); | 34 | + // ========== 动态表单模块 1-009-003-000 ========== |
| 35 | + ErrorCode BPM_FORM_NOT_EXISTS = new ErrorCode(1009003000, "动态表单不存在"); | ||
| 36 | + ErrorCode BPM_FORM_FIELD_REPEAT = new ErrorCode(1009003000, "表单项({}) 和 ({}) 使用了相同的字段名({})"); | ||
| 35 | 37 | ||
| 36 | } | 38 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/form/BpmFormService.java
| 1 | package cn.iocoder.yudao.adminserver.modules.bpm.service.form; | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.service.form; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormCreateReqVO; | 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormCreateReqVO; |
| 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormPageReqVO; | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormPageReqVO; |
| 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormUpdateReqVO; | 6 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormUpdateReqVO; |
| 6 | import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; | 7 | import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; |
| 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 8 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 9 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 8 | 10 | ||
| 9 | import javax.validation.Valid; | 11 | import javax.validation.Valid; |
| 10 | import java.util.Collection; | 12 | import java.util.Collection; |
| 13 | +import java.util.Collections; | ||
| 11 | import java.util.List; | 14 | import java.util.List; |
| 15 | +import java.util.Map; | ||
| 12 | 16 | ||
| 13 | 17 | ||
| 14 | /** | 18 | /** |
| @@ -57,6 +61,19 @@ public interface BpmFormService { | @@ -57,6 +61,19 @@ public interface BpmFormService { | ||
| 57 | List<BpmFormDO> getFormList(Collection<Long> ids); | 61 | List<BpmFormDO> getFormList(Collection<Long> ids); |
| 58 | 62 | ||
| 59 | /** | 63 | /** |
| 64 | + * 获得动态表单 Map | ||
| 65 | + * | ||
| 66 | + * @param ids 编号 | ||
| 67 | + * @return 动态表单 Map | ||
| 68 | + */ | ||
| 69 | + default Map<Long, BpmFormDO> getFormMap(Collection<Long> ids) { | ||
| 70 | + if (CollUtil.isEmpty(ids)) { | ||
| 71 | + return Collections.emptyMap(); | ||
| 72 | + } | ||
| 73 | + return CollectionUtils.convertMap(this.getFormList(ids), BpmFormDO::getId); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + /** | ||
| 60 | * 获得动态表单分页 | 77 | * 获得动态表单分页 |
| 61 | * | 78 | * |
| 62 | * @param pageReqVO 分页查询 | 79 | * @param pageReqVO 分页查询 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/BpmModelService.java renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/model/BpmModelService.java
| 1 | -package cn.iocoder.yudao.adminserver.modules.bpm.service.workflow; | 1 | +package cn.iocoder.yudao.adminserver.modules.bpm.service.model; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelRespVO; | ||
| 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; | 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; |
| 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.ModelPageReqVO; | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.ModelPageReqVO; |
| 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO; | 6 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO; |
| @@ -20,7 +21,7 @@ public interface BpmModelService { | @@ -20,7 +21,7 @@ public interface BpmModelService { | ||
| 20 | * @param pageVO 分页查询 | 21 | * @param pageVO 分页查询 |
| 21 | * @return 流程定义分页 | 22 | * @return 流程定义分页 |
| 22 | */ | 23 | */ |
| 23 | - PageResult<Model> getModelPage(ModelPageReqVO pageVO); | 24 | + PageResult<BpmModelRespVO> getModelPage(ModelPageReqVO pageVO); |
| 24 | 25 | ||
| 25 | // TODO @Li:不用返回 CommonResult | 26 | // TODO @Li:不用返回 CommonResult |
| 26 | // TODO @Li:createBpmModal。 | 27 | // TODO @Li:createBpmModal。 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/model/dto/BpmModelMetaInfoRespDTO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.bpm.service.model.dto; | ||
| 2 | + | ||
| 3 | +import lombok.Data; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * BPM 流程 MetaInfo Response DTO | ||
| 7 | + * 主要用于 {@link org.activiti.engine.repository.Model#setMetaInfo(String)} 的存储 | ||
| 8 | + * | ||
| 9 | + * @author 芋道源码 | ||
| 10 | + */ | ||
| 11 | +@Data | ||
| 12 | +public class BpmModelMetaInfoRespDTO { | ||
| 13 | + | ||
| 14 | + /** | ||
| 15 | + * 流程描述 | ||
| 16 | + */ | ||
| 17 | + private String description; | ||
| 18 | + /** | ||
| 19 | + * 表单编号 | ||
| 20 | + */ | ||
| 21 | + private Long formId; | ||
| 22 | + | ||
| 23 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/impl/BpmModelServiceImpl.java
| @@ -2,13 +2,18 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.impl; | @@ -2,13 +2,18 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.impl; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.util.StrUtil; | 3 | import cn.hutool.core.util.StrUtil; |
| 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO; | 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO; |
| 5 | +import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelRespVO; | ||
| 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.ModelPageReqVO; | 6 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.ModelPageReqVO; |
| 6 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; | 7 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; |
| 8 | +import cn.iocoder.yudao.adminserver.modules.bpm.convert.model.ModelConvert; | ||
| 9 | +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; | ||
| 7 | import cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants; | 10 | import cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants; |
| 8 | -import cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.BpmModelService; | ||
| 9 | -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; | 11 | +import cn.iocoder.yudao.adminserver.modules.bpm.service.form.BpmFormService; |
| 12 | +import cn.iocoder.yudao.adminserver.modules.bpm.service.model.BpmModelService; | ||
| 13 | +import cn.iocoder.yudao.adminserver.modules.bpm.service.model.dto.BpmModelMetaInfoRespDTO; | ||
| 10 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 14 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 11 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 15 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 16 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 12 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | 17 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 13 | import cn.iocoder.yudao.framework.common.util.object.PageUtils; | 18 | import cn.iocoder.yudao.framework.common.util.object.PageUtils; |
| 14 | import lombok.extern.slf4j.Slf4j; | 19 | import lombok.extern.slf4j.Slf4j; |
| @@ -20,6 +25,7 @@ import org.activiti.engine.repository.Model; | @@ -20,6 +25,7 @@ import org.activiti.engine.repository.Model; | ||
| 20 | import org.activiti.engine.repository.ModelQuery; | 25 | import org.activiti.engine.repository.ModelQuery; |
| 21 | import org.apache.commons.lang3.exception.ExceptionUtils; | 26 | import org.apache.commons.lang3.exception.ExceptionUtils; |
| 22 | import org.springframework.stereotype.Service; | 27 | import org.springframework.stereotype.Service; |
| 28 | +import org.springframework.transaction.annotation.Transactional; | ||
| 23 | import org.springframework.util.ObjectUtils; | 29 | import org.springframework.util.ObjectUtils; |
| 24 | import org.springframework.validation.annotation.Validated; | 30 | import org.springframework.validation.annotation.Validated; |
| 25 | 31 | ||
| @@ -30,7 +36,12 @@ import java.io.ByteArrayInputStream; | @@ -30,7 +36,12 @@ import java.io.ByteArrayInputStream; | ||
| 30 | import java.io.InputStreamReader; | 36 | import java.io.InputStreamReader; |
| 31 | import java.nio.charset.StandardCharsets; | 37 | import java.nio.charset.StandardCharsets; |
| 32 | import java.util.List; | 38 | import java.util.List; |
| 39 | +import java.util.Map; | ||
| 33 | import java.util.Optional; | 40 | import java.util.Optional; |
| 41 | +import java.util.Set; | ||
| 42 | + | ||
| 43 | +import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.BPM_MODEL_KEY_EXISTS; | ||
| 44 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 34 | 45 | ||
| 35 | /** | 46 | /** |
| 36 | * 流程定义实现 | 47 | * 流程定义实现 |
| @@ -44,9 +55,11 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -44,9 +55,11 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 44 | 55 | ||
| 45 | @Resource | 56 | @Resource |
| 46 | private RepositoryService repositoryService; | 57 | private RepositoryService repositoryService; |
| 58 | + @Resource | ||
| 59 | + private BpmFormService bpmFormService; | ||
| 47 | 60 | ||
| 48 | @Override | 61 | @Override |
| 49 | - public PageResult<Model> getModelPage(ModelPageReqVO pageVO) { | 62 | + public PageResult<BpmModelRespVO> getModelPage(ModelPageReqVO pageVO) { |
| 50 | ModelQuery modelQuery = repositoryService.createModelQuery(); | 63 | ModelQuery modelQuery = repositoryService.createModelQuery(); |
| 51 | if (StrUtil.isNotBlank(pageVO.getName())) { | 64 | if (StrUtil.isNotBlank(pageVO.getName())) { |
| 52 | modelQuery.modelNameLike("%" + pageVO.getName() + "%"); // 模糊匹配 | 65 | modelQuery.modelNameLike("%" + pageVO.getName() + "%"); // 模糊匹配 |
| @@ -55,18 +68,29 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -55,18 +68,29 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 55 | List<Model> models = modelQuery.orderByCreateTime().desc() | 68 | List<Model> models = modelQuery.orderByCreateTime().desc() |
| 56 | .listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); | 69 | .listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); |
| 57 | long modelCount = modelQuery.count(); | 70 | long modelCount = modelQuery.count(); |
| 58 | - return new PageResult<>(models, modelCount); | 71 | + |
| 72 | + // 获得 Form Map | ||
| 73 | + Set<Long> formIds = CollectionUtils.convertSet(models, model -> { | ||
| 74 | + BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); | ||
| 75 | + return metaInfo != null ? metaInfo.getFormId() : null; | ||
| 76 | + }); | ||
| 77 | + Map<Long, BpmFormDO> formMap = bpmFormService.getFormMap(formIds); | ||
| 78 | + // 拼接结果 | ||
| 79 | + return new PageResult<>(ModelConvert.INSTANCE.convertList(models, formMap), modelCount); | ||
| 59 | } | 80 | } |
| 60 | 81 | ||
| 61 | @Override | 82 | @Override |
| 83 | + @Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务 | ||
| 62 | public String createModel(BpmModelCreateReqVO createReqVO) { | 84 | public String createModel(BpmModelCreateReqVO createReqVO) { |
| 63 | - // TODO 芋艿:校验 key 是否重复 | 85 | + // 校验流程标识已经存在 |
| 86 | + Model keyModel = this.getModelByKey(createReqVO.getKey()); | ||
| 87 | + if (keyModel != null) { | ||
| 88 | + throw exception(BPM_MODEL_KEY_EXISTS); | ||
| 89 | + } | ||
| 90 | + | ||
| 64 | // 创建流程定义 | 91 | // 创建流程定义 |
| 65 | Model model = repositoryService.newModel(); | 92 | Model model = repositoryService.newModel(); |
| 66 | - model.setName(createReqVO.getName()); | ||
| 67 | - model.setKey(createReqVO.getKey()); | ||
| 68 | - // TODO 芋艿:metaInfo,description、category、formId | ||
| 69 | - model.setMetaInfo(JsonUtils.toJsonString(createReqVO)); | 93 | + ModelConvert.INSTANCE.copy(model, createReqVO); |
| 70 | // 保存流程定义 | 94 | // 保存流程定义 |
| 71 | repositoryService.saveModel(model); | 95 | repositoryService.saveModel(model); |
| 72 | // 添加 BPMN XML | 96 | // 添加 BPMN XML |
| @@ -109,11 +133,11 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -109,11 +133,11 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 109 | try { | 133 | try { |
| 110 | Model modelData = repositoryService.getModel(modelId); | 134 | Model modelData = repositoryService.getModel(modelId); |
| 111 | if (ObjectUtils.isEmpty(modelData)) { | 135 | if (ObjectUtils.isEmpty(modelData)) { |
| 112 | - throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS); | 136 | + throw exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS); |
| 113 | } | 137 | } |
| 114 | byte[] bytes = repositoryService.getModelEditorSource(modelData.getId()); | 138 | byte[] bytes = repositoryService.getModelEditorSource(modelData.getId()); |
| 115 | if (bytes == null) { | 139 | if (bytes == null) { |
| 116 | - throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS); | 140 | + throw exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS); |
| 117 | } | 141 | } |
| 118 | // 将xml转换为流 | 142 | // 将xml转换为流 |
| 119 | // TODO @Li:这里是标准逻辑,看看 hutool 有没工具类提供。如果没有,咱自己封装一个 | 143 | // TODO @Li:这里是标准逻辑,看看 hutool 有没工具类提供。如果没有,咱自己封装一个 |
| @@ -124,7 +148,7 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -124,7 +148,7 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 124 | // 流数据转化为 model | 148 | // 流数据转化为 model |
| 125 | BpmnModel model = new BpmnXMLConverter().convertToBpmnModel(xtr); | 149 | BpmnModel model = new BpmnXMLConverter().convertToBpmnModel(xtr); |
| 126 | if(ObjectUtils.isEmpty(model.getProcesses())){ | 150 | if(ObjectUtils.isEmpty(model.getProcesses())){ |
| 127 | - throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_PROCESS_NOT_EXISTS); | 151 | + throw exception(BpmErrorCodeConstants.BPMN_MODEL_PROCESS_NOT_EXISTS); |
| 128 | } | 152 | } |
| 129 | byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(model); | 153 | byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(model); |
| 130 | // 部署发布模型流程 | 154 | // 部署发布模型流程 |
| @@ -137,7 +161,7 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -137,7 +161,7 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 137 | return CommonResult.success(deployment.getId()); | 161 | return CommonResult.success(deployment.getId()); |
| 138 | } catch (Exception e) { | 162 | } catch (Exception e) { |
| 139 | log.info("模型部署失败!modelId = {} e = {} ", modelId, ExceptionUtils.getStackTrace(e)); | 163 | log.info("模型部署失败!modelId = {} e = {} ", modelId, ExceptionUtils.getStackTrace(e)); |
| 140 | - throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR); | 164 | + throw exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR); |
| 141 | } | 165 | } |
| 142 | } | 166 | } |
| 143 | 167 | ||
| @@ -146,7 +170,7 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -146,7 +170,7 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 146 | try { | 170 | try { |
| 147 | Model modelData = repositoryService.getModel(modelId); | 171 | Model modelData = repositoryService.getModel(modelId); |
| 148 | if (ObjectUtils.isEmpty(modelData)) { | 172 | if (ObjectUtils.isEmpty(modelData)) { |
| 149 | - throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS); | 173 | + throw exception(BpmErrorCodeConstants.BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS); |
| 150 | } | 174 | } |
| 151 | byte[] bytes = repositoryService.getModelEditorSource(modelData.getId()); | 175 | byte[] bytes = repositoryService.getModelEditorSource(modelData.getId()); |
| 152 | FileResp fileResp = new FileResp(); | 176 | FileResp fileResp = new FileResp(); |
| @@ -155,7 +179,7 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -155,7 +179,7 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 155 | return fileResp; | 179 | return fileResp; |
| 156 | } catch (Exception e) { | 180 | } catch (Exception e) { |
| 157 | log.info("模型部署失败!modelId = {} e = {} ", modelId, ExceptionUtils.getStackTrace(e)); | 181 | log.info("模型部署失败!modelId = {} e = {} ", modelId, ExceptionUtils.getStackTrace(e)); |
| 158 | - throw ServiceExceptionUtil.exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR); | 182 | + throw exception(BpmErrorCodeConstants.BPMN_MODEL_ERROR); |
| 159 | } | 183 | } |
| 160 | } | 184 | } |
| 161 | 185 | ||
| @@ -166,4 +190,8 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -166,4 +190,8 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 166 | return CommonResult.success("删除成功"); | 190 | return CommonResult.success("删除成功"); |
| 167 | } | 191 | } |
| 168 | 192 | ||
| 193 | + private Model getModelByKey(String key) { | ||
| 194 | + return repositoryService.createModelQuery().modelKey(key).singleResult(); | ||
| 195 | + } | ||
| 196 | + | ||
| 169 | } | 197 | } |
yudao-admin-ui/src/views/bpm/model/index.vue
| 1 | <template> | 1 | <template> |
| 2 | <div class="app-container"> | 2 | <div class="app-container"> |
| 3 | + | ||
| 4 | + <!-- 搜索工作栏 --> | ||
| 3 | <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | 5 | <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> |
| 4 | <el-form-item label="模型名字" prop="name"> | 6 | <el-form-item label="模型名字" prop="name"> |
| 5 | <el-input v-model="queryParams.name" placeholder="请输入模型名字" clearable style="width: 240px;" size="small" | 7 | <el-input v-model="queryParams.name" placeholder="请输入模型名字" clearable style="width: 240px;" size="small" |
| @@ -10,36 +12,31 @@ | @@ -10,36 +12,31 @@ | ||
| 10 | <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | 12 | <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> |
| 11 | </el-form-item> | 13 | </el-form-item> |
| 12 | </el-form> | 14 | </el-form> |
| 15 | + | ||
| 16 | + <!-- 操作工具栏 --> | ||
| 13 | <el-row :gutter="10" class="mb8"> | 17 | <el-row :gutter="10" class="mb8"> |
| 14 | <el-col :span="1.5"> | 18 | <el-col :span="1.5"> |
| 15 | - <el-button | ||
| 16 | - type="primary" | ||
| 17 | - icon="el-icon-plus" | ||
| 18 | - size="mini" | ||
| 19 | - @click="openBpmn" | ||
| 20 | - v-hasPermi="['infra:config:create']" | ||
| 21 | - >新建流程</el-button> | 19 | + <el-button type="primary" icon="el-icon-plus" size="mini" @click="openBpmn" |
| 20 | + v-hasPermi="['infra:config:create']">新建流程</el-button> | ||
| 22 | </el-col> | 21 | </el-col> |
| 23 | <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | 22 | <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> |
| 24 | </el-row> | 23 | </el-row> |
| 24 | + | ||
| 25 | + <!-- 列表 --> | ||
| 25 | <el-table v-loading="loading" :data="list"> | 26 | <el-table v-loading="loading" :data="list"> |
| 26 | - <el-table-column label="ID" align="center" prop="id" /> | ||
| 27 | - <el-table-column label="name" align="center" prop="metaInfo" > | ||
| 28 | - <template slot-scope="scope"> | ||
| 29 | - <span>{{ scope.row.metaInfo ? JSON.parse(scope.row.metaInfo).name : "" }}</span> | ||
| 30 | - </template> | ||
| 31 | - </el-table-column> | ||
| 32 | - <el-table-column label="description" align="center" prop="metaInfo" > | ||
| 33 | - <template slot-scope="scope"> | ||
| 34 | - <span>{{ JSON.parse(scope.row.metaInfo).description }}</span> | ||
| 35 | - </template> | ||
| 36 | - </el-table-column> | ||
| 37 | - <el-table-column label="创建时间" align="center" prop="createTime" > | 27 | + <el-table-column label="流程编号" align="center" prop="id" :show-overflow-tooltip="true" /> |
| 28 | + <el-table-column label="流程标识" align="center" prop="key" /> | ||
| 29 | + <el-table-column label="流程名称" align="center" prop="name" /> | ||
| 30 | + <el-table-column label="流程分类" align="center" prop="category" /> | ||
| 31 | + <el-table-column label="表单信息" align="center" prop="formName" /> | ||
| 32 | + <el-table-column label="流程版本" align="center" prop="revision" /> | ||
| 33 | + <el-table-column label="状态" align="center" prop="rversion" /> | ||
| 34 | + <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | ||
| 38 | <template slot-scope="scope"> | 35 | <template slot-scope="scope"> |
| 39 | <span>{{ parseTime(scope.row.createTime) }}</span> | 36 | <span>{{ parseTime(scope.row.createTime) }}</span> |
| 40 | </template> | 37 | </template> |
| 41 | </el-table-column> | 38 | </el-table-column> |
| 42 | - <el-table-column label="操作" align="center" > | 39 | + <el-table-column label="操作" align="center" width="240"> |
| 43 | <template slot-scope="scope"> | 40 | <template slot-scope="scope"> |
| 44 | <el-button size="mini" type="text" icon="el-icon-setting" @click="change(scope.row)">设计流程</el-button> | 41 | <el-button size="mini" type="text" icon="el-icon-setting" @click="change(scope.row)">设计流程</el-button> |
| 45 | <el-button size="mini" type="text" icon="el-icon-delete" @click="modelDelete(scope.row)">删除</el-button> | 42 | <el-button size="mini" type="text" icon="el-icon-delete" @click="modelDelete(scope.row)">删除</el-button> |