Commit ea6752f15e565b5451e9164e02e082680b0b4a0a
1 parent
1cab3c00
BPM: 新增通过流程标识获取流程图
Showing
5 changed files
with
45 additions
and
11 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java
| ... | ... | @@ -6,16 +6,15 @@ import cn.iocoder.yudao.framework.common.util.io.IoUtils; |
| 6 | 6 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*; |
| 7 | 7 | import cn.iocoder.yudao.module.bpm.convert.definition.BpmModelConvert; |
| 8 | 8 | import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService; |
| 9 | -import io.swagger.v3.oas.annotations.tags.Tag; | |
| 10 | -import io.swagger.v3.oas.annotations.Parameter; | |
| 11 | 9 | import io.swagger.v3.oas.annotations.Operation; |
| 10 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 11 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 12 | +import jakarta.annotation.Resource; | |
| 13 | +import jakarta.validation.Valid; | |
| 12 | 14 | import org.springframework.security.access.prepost.PreAuthorize; |
| 13 | 15 | import org.springframework.validation.annotation.Validated; |
| 14 | 16 | import org.springframework.web.bind.annotation.*; |
| 15 | 17 | |
| 16 | -import jakarta.annotation.Resource; | |
| 17 | -import jakarta.validation.Valid; | |
| 18 | - | |
| 19 | 18 | import java.io.IOException; |
| 20 | 19 | |
| 21 | 20 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| ... | ... | @@ -44,6 +43,15 @@ public class BpmModelController { |
| 44 | 43 | return success(model); |
| 45 | 44 | } |
| 46 | 45 | |
| 46 | + @GetMapping("/get-by-key") | |
| 47 | + @Operation(summary = "获得模型") | |
| 48 | + @Parameter(name = "key", description = "流程标识", required = true, example = "oa_leave") | |
| 49 | + @PreAuthorize("@ss.hasPermission('bpm:model:query')") | |
| 50 | + public CommonResult<BpmModelRespVO> getModelByKey(@RequestParam("key") String key) { | |
| 51 | + BpmModelRespVO model = modelService.getBpmnModelByKey(key); | |
| 52 | + return success(model); | |
| 53 | + } | |
| 54 | + | |
| 47 | 55 | @PostMapping("/create") |
| 48 | 56 | @Operation(summary = "新建模型") |
| 49 | 57 | @PreAuthorize("@ss.hasPermission('bpm:model:create')") | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java
| ... | ... | @@ -2,9 +2,8 @@ package cn.iocoder.yudao.module.bpm.service.definition; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*; |
| 5 | -import org.flowable.bpmn.model.BpmnModel; | |
| 6 | - | |
| 7 | 5 | import jakarta.validation.Valid; |
| 6 | +import org.flowable.bpmn.model.BpmnModel; | |
| 8 | 7 | |
| 9 | 8 | /** |
| 10 | 9 | * Flowable流程模型接口 |
| ... | ... | @@ -39,6 +38,14 @@ public interface BpmModelService { |
| 39 | 38 | BpmModelRespVO getModel(String id); |
| 40 | 39 | |
| 41 | 40 | /** |
| 41 | + * 获得流程模块 | |
| 42 | + * | |
| 43 | + * @param key 流程标识 | |
| 44 | + * @return 流程模型 | |
| 45 | + */ | |
| 46 | + BpmModelRespVO getBpmnModelByKey(String key); | |
| 47 | + | |
| 48 | + /** | |
| 42 | 49 | * 修改流程模型 |
| 43 | 50 | * |
| 44 | 51 | * @param updateReqVO 更新信息 |
| ... | ... | @@ -62,7 +69,7 @@ public interface BpmModelService { |
| 62 | 69 | /** |
| 63 | 70 | * 修改模型的状态,实际更新的部署的流程定义的状态 |
| 64 | 71 | * |
| 65 | - * @param id 编号 | |
| 72 | + * @param id 编号 | |
| 66 | 73 | * @param state 状态 |
| 67 | 74 | */ |
| 68 | 75 | void updateModelState(String id, Integer state); | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java
| ... | ... | @@ -14,6 +14,8 @@ import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; |
| 14 | 14 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; |
| 15 | 15 | import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; |
| 16 | 16 | import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO; |
| 17 | +import jakarta.annotation.Resource; | |
| 18 | +import jakarta.validation.Valid; | |
| 17 | 19 | import lombok.extern.slf4j.Slf4j; |
| 18 | 20 | import org.flowable.bpmn.converter.BpmnXMLConverter; |
| 19 | 21 | import org.flowable.bpmn.model.BpmnModel; |
| ... | ... | @@ -29,8 +31,6 @@ import org.springframework.transaction.annotation.Transactional; |
| 29 | 31 | import org.springframework.util.ObjectUtils; |
| 30 | 32 | import org.springframework.validation.annotation.Validated; |
| 31 | 33 | |
| 32 | -import jakarta.annotation.Resource; | |
| 33 | -import jakarta.validation.Valid; | |
| 34 | 34 | import java.util.*; |
| 35 | 35 | |
| 36 | 36 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| ... | ... | @@ -135,6 +135,19 @@ public class BpmModelServiceImpl implements BpmModelService { |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | @Override |
| 138 | + public BpmModelRespVO getBpmnModelByKey(String key) { | |
| 139 | + Model model = getModelByKey(key); | |
| 140 | + if (model == null) { | |
| 141 | + return null; | |
| 142 | + } | |
| 143 | + BpmModelRespVO modelRespVO = BpmModelConvert.INSTANCE.convert(model); | |
| 144 | + // 拼接 bpmn XML | |
| 145 | + byte[] bpmnBytes = repositoryService.getModelEditorSource(model.getId()); | |
| 146 | + modelRespVO.setBpmnXml(StrUtil.utf8Str(bpmnBytes)); | |
| 147 | + return modelRespVO; | |
| 148 | + } | |
| 149 | + | |
| 150 | + @Override | |
| 138 | 151 | @Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务 |
| 139 | 152 | public void updateModel(@Valid BpmModelUpdateReqVO updateReqVO) { |
| 140 | 153 | // 校验流程模型存在 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java
| ... | ... | @@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTrans |
| 12 | 12 | import cn.iocoder.yudao.module.crm.convert.contract.CrmContractConvert; |
| 13 | 13 | import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; |
| 14 | 14 | import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper; |
| 15 | +import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; | |
| 15 | 16 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| 16 | 17 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; |
| 17 | 18 | import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; |
| ... | ... | @@ -156,7 +157,8 @@ public class CrmContractServiceImpl implements CrmContractService { |
| 156 | 157 | .setProcessDefinitionKey(CONTRACT_APPROVE).setBusinessKey(String.valueOf(id))); |
| 157 | 158 | |
| 158 | 159 | // 更新合同工作流编号 |
| 159 | - contractMapper.updateById(new CrmContractDO().setId(id).setProcessInstanceId(processInstanceId)); | |
| 160 | + contractMapper.updateById(new CrmContractDO().setId(id).setProcessInstanceId(processInstanceId) | |
| 161 | + .setAuditStatus(CrmAuditStatusEnum.PROCESS.getStatus())); | |
| 160 | 162 | } |
| 161 | 163 | |
| 162 | 164 | //======================= 查询相关 ======================= | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/listener/CrmContractResultListener.java
0 → 100644