Commit e47d5afcfa0849ac2cc3b28dcbd809d003e927e1
1 parent
dc7a4343
完善工作流 model 的接口
Showing
11 changed files
with
122 additions
and
39 deletions
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/model/BpmModelController.java
| @@ -19,7 +19,7 @@ import java.io.IOException; | @@ -19,7 +19,7 @@ import java.io.IOException; | ||
| 19 | 19 | ||
| 20 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 20 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 21 | 21 | ||
| 22 | -@Api(tags = "流程定义") | 22 | +@Api(tags = "流程模型") |
| 23 | @RestController | 23 | @RestController |
| 24 | @RequestMapping("/bpm/model") | 24 | @RequestMapping("/bpm/model") |
| 25 | @Validated | 25 | @Validated |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/model/vo/BpmModelBaseVO.java
| @@ -7,7 +7,7 @@ import javax.validation.constraints.NotEmpty; | @@ -7,7 +7,7 @@ import javax.validation.constraints.NotEmpty; | ||
| 7 | import javax.validation.constraints.NotNull; | 7 | import javax.validation.constraints.NotNull; |
| 8 | 8 | ||
| 9 | /** | 9 | /** |
| 10 | -* 流程定义 Base VO,提供给添加、修改、详细的子 VO 使用 | 10 | +* 流程模型 Base VO,提供给添加、修改、详细的子 VO 使用 |
| 11 | * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | 11 | * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 |
| 12 | */ | 12 | */ |
| 13 | @Data | 13 | @Data |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/model/vo/BpmModelCreateReqVO.java
| @@ -8,7 +8,7 @@ import lombok.ToString; | @@ -8,7 +8,7 @@ import lombok.ToString; | ||
| 8 | 8 | ||
| 9 | import javax.validation.constraints.NotEmpty; | 9 | import javax.validation.constraints.NotEmpty; |
| 10 | 10 | ||
| 11 | -@ApiModel("流程定义的创建 Request VO") | 11 | +@ApiModel("流程模型的创建 Request VO") |
| 12 | @Data | 12 | @Data |
| 13 | @EqualsAndHashCode(callSuper = true) | 13 | @EqualsAndHashCode(callSuper = true) |
| 14 | @ToString(callSuper = true) | 14 | @ToString(callSuper = true) |
| @@ -18,6 +18,4 @@ public class BpmModelCreateReqVO extends BpmModelBaseVO { | @@ -18,6 +18,4 @@ public class BpmModelCreateReqVO extends BpmModelBaseVO { | ||
| 18 | @NotEmpty(message = "BPMN XML 不能为空") | 18 | @NotEmpty(message = "BPMN XML 不能为空") |
| 19 | private String bpmnXml; | 19 | private String bpmnXml; |
| 20 | 20 | ||
| 21 | -// @ApiModelProperty(value = "版本号") | ||
| 22 | -// private Integer revision; | ||
| 23 | } | 21 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/model/vo/BpmModelRespVO.java
| @@ -8,7 +8,7 @@ import lombok.ToString; | @@ -8,7 +8,7 @@ import lombok.ToString; | ||
| 8 | 8 | ||
| 9 | import java.util.Date; | 9 | import java.util.Date; |
| 10 | 10 | ||
| 11 | -@ApiModel("流程定义 Response VO") | 11 | +@ApiModel("流程模型 Response VO") |
| 12 | @Data | 12 | @Data |
| 13 | @EqualsAndHashCode(callSuper = true) | 13 | @EqualsAndHashCode(callSuper = true) |
| 14 | @ToString(callSuper = true) | 14 | @ToString(callSuper = true) |
| @@ -17,13 +17,27 @@ public class BpmModelRespVO extends BpmModelBaseVO { | @@ -17,13 +17,27 @@ public class BpmModelRespVO extends BpmModelBaseVO { | ||
| 17 | @ApiModelProperty(value = "编号", required = true, example = "1024") | 17 | @ApiModelProperty(value = "编号", required = true, example = "1024") |
| 18 | private String id; | 18 | private String id; |
| 19 | 19 | ||
| 20 | - @ApiModelProperty(value = "版本", required = true, example = "1") | ||
| 21 | - private Integer revision; | ||
| 22 | - | ||
| 23 | @ApiModelProperty(value = "表单名字", example = "请假表单") | 20 | @ApiModelProperty(value = "表单名字", example = "请假表单") |
| 24 | private String formName; | 21 | private String formName; |
| 25 | 22 | ||
| 26 | @ApiModelProperty(value = "创建时间", required = true) | 23 | @ApiModelProperty(value = "创建时间", required = true) |
| 27 | private Date createTime; | 24 | private Date createTime; |
| 28 | 25 | ||
| 26 | + /** | ||
| 27 | + * 最新部署的流程定义 | ||
| 28 | + */ | ||
| 29 | + private ProcessDefinition processDefinition; | ||
| 30 | + | ||
| 31 | + @ApiModel("流程定义") | ||
| 32 | + @Data | ||
| 33 | + public static class ProcessDefinition { | ||
| 34 | + | ||
| 35 | + @ApiModelProperty(value = "编号", required = true, example = "1024") | ||
| 36 | + private String id; | ||
| 37 | + | ||
| 38 | + @ApiModelProperty(value = "版本", required = true, example = "1") | ||
| 39 | + private Integer version; | ||
| 40 | + | ||
| 41 | + } | ||
| 42 | + | ||
| 29 | } | 43 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/model/vo/ModelPageReqVO.java
| @@ -8,7 +8,7 @@ import lombok.EqualsAndHashCode; | @@ -8,7 +8,7 @@ import lombok.EqualsAndHashCode; | ||
| 8 | import lombok.ToString; | 8 | import lombok.ToString; |
| 9 | 9 | ||
| 10 | 10 | ||
| 11 | -@ApiModel("流程定义分页 Request VO") | 11 | +@ApiModel("流程模型分页 Request VO") |
| 12 | @Data | 12 | @Data |
| 13 | @EqualsAndHashCode(callSuper = true) | 13 | @EqualsAndHashCode(callSuper = true) |
| 14 | @ToString(callSuper = true) | 14 | @ToString(callSuper = true) |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/ProcessDefinitionController.java
| @@ -3,7 +3,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow; | @@ -3,7 +3,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow; | ||
| 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; | 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; |
| 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionPageReqVo; | 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionPageReqVo; |
| 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO; | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO; |
| 6 | -import cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.BpmProcessDefinitionService; | 6 | +import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmDefinitionService; |
| 7 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 7 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 8 | 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.servlet.ServletUtils; | 9 | import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; |
| @@ -30,7 +30,7 @@ public class ProcessDefinitionController { | @@ -30,7 +30,7 @@ public class ProcessDefinitionController { | ||
| 30 | @Resource | 30 | @Resource |
| 31 | private ProcessRuntime processRuntime; | 31 | private ProcessRuntime processRuntime; |
| 32 | @Resource | 32 | @Resource |
| 33 | - private BpmProcessDefinitionService bpmProcessDefinitionService; | 33 | + private BpmDefinitionService bpmProcessDefinitionService; |
| 34 | 34 | ||
| 35 | 35 | ||
| 36 | @GetMapping(value = "/getStartForm") | 36 | @GetMapping(value = "/getStartForm") |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/model/ModelConvert.java
| @@ -6,8 +6,8 @@ import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; | @@ -6,8 +6,8 @@ import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; | ||
| 6 | import cn.iocoder.yudao.adminserver.modules.bpm.service.model.dto.BpmModelMetaInfoRespDTO; | 6 | import cn.iocoder.yudao.adminserver.modules.bpm.service.model.dto.BpmModelMetaInfoRespDTO; |
| 7 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 7 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 8 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | 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; | 9 | import org.activiti.engine.repository.Model; |
| 10 | +import org.activiti.engine.repository.ProcessDefinition; | ||
| 11 | import org.mapstruct.Mapper; | 11 | import org.mapstruct.Mapper; |
| 12 | import org.mapstruct.factory.Mappers; | 12 | import org.mapstruct.factory.Mappers; |
| 13 | 13 | ||
| @@ -25,15 +25,17 @@ public interface ModelConvert { | @@ -25,15 +25,17 @@ public interface ModelConvert { | ||
| 25 | 25 | ||
| 26 | ModelConvert INSTANCE = Mappers.getMapper(ModelConvert.class); | 26 | ModelConvert INSTANCE = Mappers.getMapper(ModelConvert.class); |
| 27 | 27 | ||
| 28 | - default List<BpmModelRespVO> convertList(List<Model> list, Map<Long, BpmFormDO> formMap) { | 28 | + default List<BpmModelRespVO> convertList(List<Model> list, Map<Long, BpmFormDO> formMap, |
| 29 | + Map<String, ProcessDefinition> processDefinitionMap) { | ||
| 29 | return CollectionUtils.convertList(list, model -> { | 30 | return CollectionUtils.convertList(list, model -> { |
| 30 | BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); | 31 | BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); |
| 31 | BpmFormDO form = metaInfo != null ? formMap.get(metaInfo.getFormId()) : null; | 32 | BpmFormDO form = metaInfo != null ? formMap.get(metaInfo.getFormId()) : null; |
| 32 | - return convert(model, form); | 33 | + ProcessDefinition processDefinition = model.getDeploymentId() != null ? processDefinitionMap.get(model.getDeploymentId()) : null; |
| 34 | + return convert(model, form, processDefinition); | ||
| 33 | }); | 35 | }); |
| 34 | } | 36 | } |
| 35 | 37 | ||
| 36 | - default BpmModelRespVO convert(Model model, BpmFormDO form) { | 38 | + default BpmModelRespVO convert(Model model, BpmFormDO form, ProcessDefinition processDefinition) { |
| 37 | BpmModelRespVO modelRespVO = new BpmModelRespVO(); | 39 | BpmModelRespVO modelRespVO = new BpmModelRespVO(); |
| 38 | modelRespVO.setId(model.getId()); | 40 | modelRespVO.setId(model.getId()); |
| 39 | modelRespVO.setName(model.getName()); | 41 | modelRespVO.setName(model.getName()); |
| @@ -48,10 +50,7 @@ public interface ModelConvert { | @@ -48,10 +50,7 @@ public interface ModelConvert { | ||
| 48 | modelRespVO.setFormId(form.getId()); | 50 | modelRespVO.setFormId(form.getId()); |
| 49 | modelRespVO.setFormName(form.getName()); | 51 | modelRespVO.setFormName(form.getName()); |
| 50 | } | 52 | } |
| 51 | - if (model instanceof ModelEntity) { | ||
| 52 | - ModelEntity modelEntity = (ModelEntity) model; | ||
| 53 | - modelRespVO.setRevision(modelEntity.getRevision()); | ||
| 54 | - } | 53 | + modelRespVO.setProcessDefinition(this.convert(processDefinition)); |
| 55 | return modelRespVO; | 54 | return modelRespVO; |
| 56 | } | 55 | } |
| 57 | 56 | ||
| @@ -69,4 +68,6 @@ public interface ModelConvert { | @@ -69,4 +68,6 @@ public interface ModelConvert { | ||
| 69 | return metaInfo; | 68 | return metaInfo; |
| 70 | } | 69 | } |
| 71 | 70 | ||
| 71 | + BpmModelRespVO.ProcessDefinition convert(ProcessDefinition bean); | ||
| 72 | + | ||
| 72 | } | 73 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/BpmProcessDefinitionService.java renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmDefinitionService.java
| 1 | -package cn.iocoder.yudao.adminserver.modules.bpm.service.workflow; | 1 | +package cn.iocoder.yudao.adminserver.modules.bpm.service.definition; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; | 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; |
| 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionPageReqVo; | 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionPageReqVo; |
| 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO; | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO; |
| 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | +import org.activiti.engine.repository.ProcessDefinition; | ||
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 10 | +import java.util.Set; | ||
| 7 | 11 | ||
| 8 | /** | 12 | /** |
| 9 | * 流程定义接口 | 13 | * 流程定义接口 |
| 14 | + * | ||
| 10 | * @author yunlong.li | 15 | * @author yunlong.li |
| 11 | */ | 16 | */ |
| 12 | -public interface BpmProcessDefinitionService { | 17 | +public interface BpmDefinitionService { |
| 18 | + | ||
| 13 | /** | 19 | /** |
| 14 | * 流程定义分页 | 20 | * 流程定义分页 |
| 15 | * @param processDefinitionPageReqVo 分页入参 | 21 | * @param processDefinitionPageReqVo 分页入参 |
| @@ -23,4 +29,13 @@ public interface BpmProcessDefinitionService { | @@ -23,4 +29,13 @@ public interface BpmProcessDefinitionService { | ||
| 23 | * @return 分页model | 29 | * @return 分页model |
| 24 | */ | 30 | */ |
| 25 | FileResp export(String processDefinitionId); | 31 | FileResp export(String processDefinitionId); |
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 获得 deploymentId 对应的 ProcessDefinition 数组 | ||
| 35 | + * | ||
| 36 | + * @param deploymentId 部署编号 | ||
| 37 | + * @return 流程定义的数组 | ||
| 38 | + */ | ||
| 39 | + List<ProcessDefinition> getProcessDefinitionListByDeploymentIds(Set<String> deploymentId); | ||
| 40 | + | ||
| 26 | } | 41 | } |
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.model; | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.service.model; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO; | ||
| 3 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelRespVO; | 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelRespVO; |
| 4 | -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; | ||
| 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.ModelPageReqVO; | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.ModelPageReqVO; |
| 6 | -import cn.iocoder.yudao.adminserver.modules.bpm.controller.model.vo.BpmModelCreateReqVO; | 6 | +import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; |
| 7 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 7 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 8 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 8 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 9 | -import org.activiti.engine.repository.Model; | ||
| 10 | 9 | ||
| 11 | /** | 10 | /** |
| 12 | - * 流程定义接口 | 11 | + * 流程模型接口 |
| 13 | * | 12 | * |
| 14 | * @author yunlongn | 13 | * @author yunlongn |
| 15 | */ | 14 | */ |
| 16 | public interface BpmModelService { | 15 | public interface BpmModelService { |
| 17 | 16 | ||
| 18 | /** | 17 | /** |
| 19 | - * 获得流程定义分页 | 18 | + * 获得流程模型分页 |
| 20 | * | 19 | * |
| 21 | * @param pageVO 分页查询 | 20 | * @param pageVO 分页查询 |
| 22 | - * @return 流程定义分页 | 21 | + * @return 流程模型分页 |
| 23 | */ | 22 | */ |
| 24 | PageResult<BpmModelRespVO> getModelPage(ModelPageReqVO pageVO); | 23 | PageResult<BpmModelRespVO> getModelPage(ModelPageReqVO pageVO); |
| 25 | 24 | ||
| 26 | // TODO @Li:不用返回 CommonResult | 25 | // TODO @Li:不用返回 CommonResult |
| 27 | // TODO @Li:createBpmModal。 | 26 | // TODO @Li:createBpmModal。 |
| 28 | /** | 27 | /** |
| 29 | - * 创建流程定义 | 28 | + * 创建流程模型 |
| 30 | * | 29 | * |
| 31 | * @param modelVO 创建信息 | 30 | * @param modelVO 创建信息 |
| 32 | - * @return 创建的流程定义的编号 | 31 | + * @return 创建的流程模型的编号 |
| 33 | */ | 32 | */ |
| 34 | String createModel(BpmModelCreateReqVO modelVO); | 33 | String createModel(BpmModelCreateReqVO modelVO); |
| 35 | 34 |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/impl/BpmModelServiceImpl.java renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/model/impl/BpmModelServiceImpl.java
| 1 | -package cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.impl; | 1 | +package cn.iocoder.yudao.adminserver.modules.bpm.service.model.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; |
| @@ -8,6 +8,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; | @@ -8,6 +8,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; | ||
| 8 | import cn.iocoder.yudao.adminserver.modules.bpm.convert.model.ModelConvert; | 8 | import cn.iocoder.yudao.adminserver.modules.bpm.convert.model.ModelConvert; |
| 9 | import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; | 9 | import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmFormDO; |
| 10 | import cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants; | 10 | import cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants; |
| 11 | +import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmDefinitionService; | ||
| 11 | import cn.iocoder.yudao.adminserver.modules.bpm.service.form.BpmFormService; | 12 | 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.BpmModelService; |
| 13 | import cn.iocoder.yudao.adminserver.modules.bpm.service.model.dto.BpmModelMetaInfoRespDTO; | 14 | import cn.iocoder.yudao.adminserver.modules.bpm.service.model.dto.BpmModelMetaInfoRespDTO; |
| @@ -23,6 +24,7 @@ import org.activiti.engine.RepositoryService; | @@ -23,6 +24,7 @@ import org.activiti.engine.RepositoryService; | ||
| 23 | import org.activiti.engine.repository.Deployment; | 24 | import org.activiti.engine.repository.Deployment; |
| 24 | import org.activiti.engine.repository.Model; | 25 | import org.activiti.engine.repository.Model; |
| 25 | import org.activiti.engine.repository.ModelQuery; | 26 | import org.activiti.engine.repository.ModelQuery; |
| 27 | +import org.activiti.engine.repository.ProcessDefinition; | ||
| 26 | import org.apache.commons.lang3.exception.ExceptionUtils; | 28 | import org.apache.commons.lang3.exception.ExceptionUtils; |
| 27 | import org.springframework.stereotype.Service; | 29 | import org.springframework.stereotype.Service; |
| 28 | import org.springframework.transaction.annotation.Transactional; | 30 | import org.springframework.transaction.annotation.Transactional; |
| @@ -35,16 +37,15 @@ import javax.xml.stream.XMLStreamReader; | @@ -35,16 +37,15 @@ import javax.xml.stream.XMLStreamReader; | ||
| 35 | import java.io.ByteArrayInputStream; | 37 | import java.io.ByteArrayInputStream; |
| 36 | import java.io.InputStreamReader; | 38 | import java.io.InputStreamReader; |
| 37 | import java.nio.charset.StandardCharsets; | 39 | import java.nio.charset.StandardCharsets; |
| 38 | -import java.util.List; | ||
| 39 | -import java.util.Map; | ||
| 40 | -import java.util.Optional; | ||
| 41 | -import java.util.Set; | 40 | +import java.util.*; |
| 42 | 41 | ||
| 43 | import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.BPM_MODEL_KEY_EXISTS; | 42 | 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; | 43 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 44 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | ||
| 45 | 45 | ||
| 46 | /** | 46 | /** |
| 47 | * 流程定义实现 | 47 | * 流程定义实现 |
| 48 | + * 主要进行 Activiti {@link Model} 的维护 | ||
| 48 | * | 49 | * |
| 49 | * @author yunlongn | 50 | * @author yunlongn |
| 50 | */ | 51 | */ |
| @@ -53,10 +54,14 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU | @@ -53,10 +54,14 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU | ||
| 53 | @Slf4j | 54 | @Slf4j |
| 54 | public class BpmModelServiceImpl implements BpmModelService { | 55 | public class BpmModelServiceImpl implements BpmModelService { |
| 55 | 56 | ||
| 57 | + private static final String BPMN_FILE_SUFFIX = ".bpmn"; | ||
| 58 | + | ||
| 56 | @Resource | 59 | @Resource |
| 57 | private RepositoryService repositoryService; | 60 | private RepositoryService repositoryService; |
| 58 | @Resource | 61 | @Resource |
| 59 | private BpmFormService bpmFormService; | 62 | private BpmFormService bpmFormService; |
| 63 | + @Resource | ||
| 64 | + private BpmDefinitionService bpmDefinitionService; | ||
| 60 | 65 | ||
| 61 | @Override | 66 | @Override |
| 62 | public PageResult<BpmModelRespVO> getModelPage(ModelPageReqVO pageVO) { | 67 | public PageResult<BpmModelRespVO> getModelPage(ModelPageReqVO pageVO) { |
| @@ -67,7 +72,6 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -67,7 +72,6 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 67 | // 执行查询 | 72 | // 执行查询 |
| 68 | List<Model> models = modelQuery.orderByCreateTime().desc() | 73 | List<Model> models = modelQuery.orderByCreateTime().desc() |
| 69 | .listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); | 74 | .listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); |
| 70 | - long modelCount = modelQuery.count(); | ||
| 71 | 75 | ||
| 72 | // 获得 Form Map | 76 | // 获得 Form Map |
| 73 | Set<Long> formIds = CollectionUtils.convertSet(models, model -> { | 77 | Set<Long> formIds = CollectionUtils.convertSet(models, model -> { |
| @@ -75,8 +79,16 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -75,8 +79,16 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 75 | return metaInfo != null ? metaInfo.getFormId() : null; | 79 | return metaInfo != null ? metaInfo.getFormId() : null; |
| 76 | }); | 80 | }); |
| 77 | Map<Long, BpmFormDO> formMap = bpmFormService.getFormMap(formIds); | 81 | Map<Long, BpmFormDO> formMap = bpmFormService.getFormMap(formIds); |
| 82 | + | ||
| 83 | + // 获得 ProcessDefinition Map | ||
| 84 | + Set<String> deploymentIds = new HashSet<>(); | ||
| 85 | + models.forEach(model -> CollectionUtils.addIfNotNull(deploymentIds, model.getId())); | ||
| 86 | + List<ProcessDefinition> processDefinitions = bpmDefinitionService.getProcessDefinitionListByDeploymentIds(deploymentIds); | ||
| 87 | + Map<String, ProcessDefinition> processDefinitionMap = convertMap(processDefinitions, ProcessDefinition::getDeploymentId); | ||
| 88 | + | ||
| 78 | // 拼接结果 | 89 | // 拼接结果 |
| 79 | - return new PageResult<>(ModelConvert.INSTANCE.convertList(models, formMap), modelCount); | 90 | + long modelCount = modelQuery.count(); |
| 91 | + return new PageResult<>(ModelConvert.INSTANCE.convertList(models, formMap, processDefinitionMap), modelCount); | ||
| 80 | } | 92 | } |
| 81 | 93 | ||
| 82 | @Override | 94 | @Override |
| @@ -98,6 +110,38 @@ public class BpmModelServiceImpl implements BpmModelService { | @@ -98,6 +110,38 @@ public class BpmModelServiceImpl implements BpmModelService { | ||
| 98 | return model.getId(); | 110 | return model.getId(); |
| 99 | } | 111 | } |
| 100 | 112 | ||
| 113 | +// @Override | ||
| 114 | +// @Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务 | ||
| 115 | +// public String createModel(BpmModelCreateReqVO createReqVO) { | ||
| 116 | +// Deployment deploy = repositoryService.createDeployment() | ||
| 117 | +// .key(createReqVO.getKey()).name(createReqVO.getName()).category(createReqVO.getCategory()) | ||
| 118 | +// .addString(createReqVO.getName() + BPMN_FILE_SUFFIX, createReqVO.getBpmnXml()) | ||
| 119 | +// .deploy(); | ||
| 120 | +// // 设置 ProcessDefinition 的 category 分类 | ||
| 121 | +// ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deploy.getId()).singleResult(); | ||
| 122 | +// repositoryService.setProcessDefinitionCategory(definition.getId(), createReqVO.getCategory()); | ||
| 123 | +// return definition.getId(); | ||
| 124 | +// } | ||
| 125 | + | ||
| 126 | +// @Override | ||
| 127 | +// @Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务 | ||
| 128 | +// public String createModel(BpmModelCreateReqVO createReqVO) { | ||
| 129 | +// // 校验流程标识已经存在 | ||
| 130 | +// Model keyModel = this.getModelByKey(createReqVO.getKey()); | ||
| 131 | +// if (keyModel != null) { | ||
| 132 | +// throw exception(BPM_MODEL_KEY_EXISTS); | ||
| 133 | +// } | ||
| 134 | +// | ||
| 135 | +// // 创建流程定义 | ||
| 136 | +// Model model = repositoryService.newModel(); | ||
| 137 | +// ModelConvert.INSTANCE.copy(model, createReqVO); | ||
| 138 | +// // 保存流程定义 | ||
| 139 | +// repositoryService.saveModel(model); | ||
| 140 | +// // 添加 BPMN XML | ||
| 141 | +// repositoryService.addModelEditorSource(model.getId(), StrUtil.utf8Bytes(createReqVO.getBpmnXml())); | ||
| 142 | +// return model.getId(); | ||
| 143 | +// } | ||
| 144 | + | ||
| 101 | @Override | 145 | @Override |
| 102 | public CommonResult<String> updateModel(BpmModelCreateReqVO modelVO) { | 146 | public CommonResult<String> updateModel(BpmModelCreateReqVO modelVO) { |
| 103 | // try { | 147 | // try { |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/workflow/impl/BpmProcessDefinitionServiceImpl.java
| 1 | package cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.impl; | 1 | package cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.impl; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 3 | import cn.hutool.core.util.StrUtil; | 4 | import cn.hutool.core.util.StrUtil; |
| 4 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; | 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.FileResp; |
| 5 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionPageReqVo; | 6 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionPageReqVo; |
| 6 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO; | 7 | import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.processdefinition.ProcessDefinitionRespVO; |
| 7 | import cn.iocoder.yudao.adminserver.modules.bpm.convert.workflow.ProcessDefinitionConvert; | 8 | import cn.iocoder.yudao.adminserver.modules.bpm.convert.workflow.ProcessDefinitionConvert; |
| 8 | -import cn.iocoder.yudao.adminserver.modules.bpm.service.workflow.BpmProcessDefinitionService; | 9 | +import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmDefinitionService; |
| 9 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 10 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 10 | import lombok.RequiredArgsConstructor; | 11 | import lombok.RequiredArgsConstructor; |
| 11 | import lombok.extern.slf4j.Slf4j; | 12 | import lombok.extern.slf4j.Slf4j; |
| @@ -17,7 +18,9 @@ import org.activiti.engine.repository.ProcessDefinition; | @@ -17,7 +18,9 @@ import org.activiti.engine.repository.ProcessDefinition; | ||
| 17 | import org.activiti.engine.repository.ProcessDefinitionQuery; | 18 | import org.activiti.engine.repository.ProcessDefinitionQuery; |
| 18 | import org.springframework.stereotype.Service; | 19 | import org.springframework.stereotype.Service; |
| 19 | 20 | ||
| 21 | +import java.util.Collections; | ||
| 20 | import java.util.List; | 22 | import java.util.List; |
| 23 | +import java.util.Set; | ||
| 21 | import java.util.stream.Collectors; | 24 | import java.util.stream.Collectors; |
| 22 | 25 | ||
| 23 | /** | 26 | /** |
| @@ -27,7 +30,7 @@ import java.util.stream.Collectors; | @@ -27,7 +30,7 @@ import java.util.stream.Collectors; | ||
| 27 | @Slf4j | 30 | @Slf4j |
| 28 | @Service | 31 | @Service |
| 29 | @RequiredArgsConstructor | 32 | @RequiredArgsConstructor |
| 30 | -public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionService { | 33 | +public class BpmProcessDefinitionServiceImpl implements BpmDefinitionService { |
| 31 | 34 | ||
| 32 | private final RepositoryService repositoryService; | 35 | private final RepositoryService repositoryService; |
| 33 | 36 | ||
| @@ -57,4 +60,13 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ | @@ -57,4 +60,13 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ | ||
| 57 | fileResp.setFileByte(bpmnBytes); | 60 | fileResp.setFileByte(bpmnBytes); |
| 58 | return fileResp; | 61 | return fileResp; |
| 59 | } | 62 | } |
| 63 | + | ||
| 64 | + @Override | ||
| 65 | + public List<ProcessDefinition> getProcessDefinitionListByDeploymentIds(Set<String> deploymentIds) { | ||
| 66 | + if (CollUtil.isEmpty(deploymentIds)) { | ||
| 67 | + return Collections.emptyList(); | ||
| 68 | + } | ||
| 69 | + return repositoryService.createProcessDefinitionQuery().deploymentIds(deploymentIds).list(); | ||
| 70 | + } | ||
| 71 | + | ||
| 60 | } | 72 | } |