Commit b65ccd769f1d5c65940264cf2a7ce1d4bc359af7

Authored by YunaiV
1 parent 51917c74

【同步】BPM:合并 master-jdk17 代码

... ... @@ -16,7 +16,7 @@
16 16 <module>yudao-module-system</module>
17 17 <module>yudao-module-infra</module>
18 18 <!-- <module>yudao-module-member</module>-->
19   -<!-- <module>yudao-module-bpm</module>-->
  19 + <module>yudao-module-bpm</module>
20 20 <!-- <module>yudao-module-report</module>-->
21 21 <!-- <module>yudao-module-mp</module>-->
22 22 <!-- <module>yudao-module-pay</module>-->
... ...
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java
... ... @@ -75,4 +75,8 @@ public interface ErrorCodeConstants {
75 75 // ========== BPM 流程表达式 1-009-014-000 ==========
76 76 ErrorCode PROCESS_EXPRESSION_NOT_EXISTS = new ErrorCode(1_009_014_000, "流程表达式不存在");
77 77  
  78 + // ========== BPM 仿钉钉流程设计器 1-009-015-000 ==========
  79 + // TODO @芋艿:这个错误码,需要关注下
  80 + ErrorCode CONVERT_TO_SIMPLE_MODEL_NOT_SUPPORT = new ErrorCode(1_009_015_000, "该流程模型不支持仿钉钉设计流程");
  81 +
78 82 }
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmSimpleModelController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.bpm.controller.admin.definition;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  4 +import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.simple.BpmSimpleModelNodeVO;
  5 +import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.simple.BpmSimpleModelSaveReqVO;
  6 +import cn.iocoder.yudao.module.bpm.service.definition.BpmSimpleModelService;
  7 +import io.swagger.v3.oas.annotations.Operation;
  8 +import io.swagger.v3.oas.annotations.Parameter;
  9 +import io.swagger.v3.oas.annotations.tags.Tag;
  10 +import jakarta.annotation.Resource;
  11 +import jakarta.validation.Valid;
  12 +import org.springframework.security.access.prepost.PreAuthorize;
  13 +import org.springframework.web.bind.annotation.*;
  14 +
  15 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  16 +
  17 +// TODO @芋艿:后续考虑下,怎么放这个 Controller
  18 +@Tag(name = "管理后台 - BPM 仿钉钉流程设计器")
  19 +@RestController
  20 +@RequestMapping("/bpm/simple")
  21 +public class BpmSimpleModelController {
  22 + @Resource
  23 + private BpmSimpleModelService bpmSimpleModelService;
  24 +
  25 + @PostMapping("/save")
  26 + @Operation(summary = "保存仿钉钉流程设计模型")
  27 + @PreAuthorize("@ss.hasPermission('bpm:model:update')")
  28 + public CommonResult<Boolean> saveSimpleModel(@Valid @RequestBody BpmSimpleModelSaveReqVO reqVO) {
  29 + return success(bpmSimpleModelService.saveSimpleModel(reqVO));
  30 + }
  31 +
  32 + @GetMapping("/get")
  33 + @Operation(summary = "获得仿钉钉流程设计模型")
  34 + @Parameter(name = "modelId", description = "流程模型编号", required = true, example = "a2c5eee0-eb6c-11ee-abf4-0c37967c420a")
  35 + public CommonResult<BpmSimpleModelNodeVO> getSimpleModel(@RequestParam("modelId") String modelId){
  36 + return success(bpmSimpleModelService.getSimpleModel(modelId));
  37 + }
  38 +
  39 +}
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/simple/BpmSimpleModelSaveReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.simple;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import jakarta.validation.Valid;
  5 +import jakarta.validation.constraints.NotEmpty;
  6 +import jakarta.validation.constraints.NotNull;
  7 +import lombok.Data;
  8 +
  9 +// TODO @芋艿:或许挪到 model 里的 simple 包
  10 +@Schema(description = "管理后台 - 仿钉钉流程设计模型的新增/修改 Request VO")
  11 +@Data
  12 +public class BpmSimpleModelSaveReqVO {
  13 +
  14 + @Schema(description = "流程模型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  15 + @NotEmpty(message = "流程模型编号不能为空")
  16 + private String modelId; // 对应 Flowable act_re_model 表 ID_ 字段
  17 +
  18 + @Schema(description = "仿钉钉流程设计模型对象", requiredMode = Schema.RequiredMode.REQUIRED)
  19 + @NotNull(message = "仿钉钉流程设计模型对象不能为空")
  20 + @Valid
  21 + private BpmSimpleModelNodeVO simpleModelBody;
  22 +
  23 +}
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmnModelConstants.java
1 1 package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums;
2 2  
  3 +import com.google.common.collect.ImmutableSet;
  4 +import org.flowable.bpmn.model.EndEvent;
  5 +import org.flowable.bpmn.model.FlowNode;
  6 +import org.flowable.bpmn.model.UserTask;
  7 +
  8 +import java.util.Set;
  9 +
3 10 /**
4 11 * BPMN XML 常量信息
5 12 *
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java
... ... @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.util;
3 3 import cn.hutool.core.collection.CollUtil;
4 4 import cn.hutool.core.map.MapUtil;
5 5 import cn.hutool.core.util.ArrayUtil;
  6 +import cn.hutool.core.util.StrUtil;
6 7 import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
7 8 import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants;
8 9 import org.flowable.bpmn.converter.BpmnXMLConverter;
... ... @@ -14,7 +15,6 @@ import java.util.*;
14 15  
15 16 import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.*;
16 17 import static org.flowable.bpmn.constants.BpmnXMLConstants.FLOWABLE_EXTENSIONS_NAMESPACE;
17   -import java.util.*;
18 18  
19 19 /**
20 20 * 流程模型转操作工具类
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java
1 1 package cn.iocoder.yudao.module.bpm.service.definition;
2 2  
  3 +import cn.hutool.core.util.ArrayUtil;
3 4 import cn.hutool.core.util.StrUtil;
4 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 6 import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
... ... @@ -103,7 +104,7 @@ public class BpmModelServiceImpl implements BpmModelService {
103 104 // 保存流程定义
104 105 repositoryService.saveModel(model);
105 106 // 保存 BPMN XML
106   - saveModelBpmnXml(model, bpmnXml);
  107 + saveModelBpmnXml(model.getId(), StrUtil.utf8Bytes(bpmnXml));
107 108 return model.getId();
108 109 }
109 110  
... ... @@ -121,7 +122,7 @@ public class BpmModelServiceImpl implements BpmModelService {
121 122 // 更新模型
122 123 repositoryService.saveModel(model);
123 124 // 更新 BPMN XML
124   - saveModelBpmnXml(model, updateReqVO.getBpmnXml());
  125 + saveModelBpmnXml(model.getId(), StrUtil.utf8Bytes(updateReqVO.getBpmnXml()));
125 126 }
126 127  
127 128 @Override
... ... @@ -236,11 +237,25 @@ public class BpmModelServiceImpl implements BpmModelService {
236 237 }
237 238 }
238 239  
239   - private void saveModelBpmnXml(Model model, String bpmnXml) {
240   - if (StrUtil.isEmpty(bpmnXml)) {
  240 + @Override
  241 + public void saveModelBpmnXml(String id, byte[] xmlBytes) {
  242 + if (ArrayUtil.isEmpty(xmlBytes)) {
  243 + return;
  244 + }
  245 + repositoryService.addModelEditorSource(id, xmlBytes);
  246 + }
  247 +
  248 + @Override
  249 + public byte[] getModelSimpleJson(String id) {
  250 + return repositoryService.getModelEditorSourceExtra(id);
  251 + }
  252 +
  253 + @Override
  254 + public void saveModelSimpleJson(String id, byte[] jsonBytes) {
  255 + if (ArrayUtil.isEmpty(jsonBytes)) {
241 256 return;
242 257 }
243   - repositoryService.addModelEditorSource(model.getId(), StrUtil.utf8Bytes(bpmnXml));
  258 + repositoryService.addModelEditorSourceExtra(id, jsonBytes);
244 259 }
245 260  
246 261 /**
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmSimpleModelService.java 0 → 100644
  1 +package cn.iocoder.yudao.module.bpm.service.definition;
  2 +
  3 +import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.simple.BpmSimpleModelNodeVO;
  4 +import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.simple.BpmSimpleModelSaveReqVO;
  5 +import jakarta.validation.Valid;
  6 +
  7 +/**
  8 + * 仿钉钉流程设计 Service 接口
  9 + *
  10 + * @author jason
  11 + */
  12 +public interface BpmSimpleModelService {
  13 +
  14 + /**
  15 + * 保存仿钉钉流程设计模型
  16 + *
  17 + * @param reqVO 请求信息
  18 + */
  19 + Boolean saveSimpleModel(@Valid BpmSimpleModelSaveReqVO reqVO);
  20 +
  21 + /**
  22 + * 获取仿钉钉流程设计模型结构
  23 + *
  24 + * @param modelId 流程模型编号
  25 + * @return 仿钉钉流程设计模型结构
  26 + */
  27 + BpmSimpleModelNodeVO getSimpleModel(String modelId);
  28 +
  29 +}
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceCopyService.java
... ... @@ -17,9 +17,11 @@ public interface BpmProcessInstanceCopyService {
17 17 * 流程实例的抄送
18 18 *
19 19 * @param userIds 抄送的用户编号
20   - * @param taskId 流程任务编号
  20 + * @param processInstanceId 流程编号
  21 + * @param taskId 任务编号
  22 + * @param taskName 任务名称
21 23 */
22   - void createProcessInstanceCopy(Collection<Long> userIds, String taskId);
  24 + void createProcessInstanceCopy(Collection<Long> userIds, String processInstanceId, String taskId, String taskName);
23 25  
24 26 /**
25 27 * 获得抄送的流程的分页
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
... ... @@ -186,7 +186,8 @@ public class BpmTaskServiceImpl implements BpmTaskService {
186 186  
187 187 // 2. 抄送用户
188 188 if (CollUtil.isNotEmpty(reqVO.getCopyUserIds())) {
189   - processInstanceCopyService.createProcessInstanceCopy(reqVO.getCopyUserIds(), reqVO.getId());
  189 + processInstanceCopyService.createProcessInstanceCopy(reqVO.getCopyUserIds(), instance.getProcessInstanceId(),
  190 + reqVO.getId(), task.getName());
190 191 }
191 192  
192 193 // 情况一:被委派的任务,不调用 complete 去完成任务
... ...
yudao-server/pom.xml
... ... @@ -46,11 +46,11 @@
46 46 <!-- <version>${revision}</version>-->
47 47 <!-- </dependency>-->
48 48 <!-- 工作流。默认注释,保证编译速度 -->
49   -<!-- <dependency>-->
50   -<!-- <groupId>cn.iocoder.boot</groupId>-->
51   -<!-- <artifactId>yudao-module-bpm-biz</artifactId>-->
52   -<!-- <version>${revision}</version>-->
53   -<!-- </dependency>-->
  49 + <dependency>
  50 + <groupId>cn.iocoder.boot</groupId>
  51 + <artifactId>yudao-module-bpm-biz</artifactId>
  52 + <version>${revision}</version>
  53 + </dependency>
54 54 <!-- 支付服务。默认注释,保证编译速度 -->
55 55 <!-- <dependency>-->
56 56 <!-- <groupId>cn.iocoder.boot</groupId>-->
... ...