Commit d758da489c8caefc210c210a9ecfcbb6a359ea8f

Authored by Lesan
1 parent 25c86c05

feat: 审批意见

yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java
... ... @@ -55,6 +55,7 @@ public interface ErrorCodeConstants {
55 55 ErrorCode TASK_TRANSFER_FAIL_USER_NOT_EXISTS = new ErrorCode(1_009_005_014, "任务转办失败,转办人不存在");
56 56 ErrorCode TASK_CREATE_FAIL_NO_CANDIDATE_USER = new ErrorCode(1_009_006_003, "操作失败,原因:找不到任务的审批人!");
57 57 ErrorCode TASK_SIGNATURE_NOT_EXISTS = new ErrorCode(1_009_005_015, "签名不能为空!");
  58 + ErrorCode TASK_REASON_REQUIRE = new ErrorCode(1_009_005_016, "审批意见不能为空!");
58 59  
59 60 // ========== 动态表单模块 1-009-010-000 ==========
60 61 ErrorCode FORM_NOT_EXISTS = new ErrorCode(1_009_010_000, "动态表单不存在");
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/simple/BpmSimpleModelNodeVO.java
... ... @@ -63,6 +63,9 @@ public class BpmSimpleModelNodeVO {
63 63 @Schema(description = "是否需要签名", example = "false")
64 64 private Boolean signEnable;
65 65  
  66 + @Schema(description = "审批意见", example = "false")
  67 + private Boolean reasonRequire;
  68 +
66 69 /**
67 70 * 审批节点拒绝处理
68 71 */
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskApproveReqVO.java
... ... @@ -15,7 +15,6 @@ public class BpmTaskApproveReqVO {
15 15 private String id;
16 16  
17 17 @Schema(description = "审批意见", requiredMode = Schema.RequiredMode.REQUIRED, example = "不错不错!")
18   - @NotEmpty(message = "审批意见不能为空")
19 18 private String reason;
20 19  
21 20 @Schema(description = "签名", example = "https://www.iocoder.cn/sign.png")
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRejectReqVO.java
... ... @@ -14,7 +14,6 @@ public class BpmTaskRejectReqVO {
14 14 private String id;
15 15  
16 16 @Schema(description = "审批意见", requiredMode = Schema.RequiredMode.REQUIRED, example = "不错不错!")
17   - @NotEmpty(message = "审批意见不能为空")
18 17 private String reason;
19 18  
20 19 }
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRespVO.java
... ... @@ -81,6 +81,9 @@ public class BpmTaskRespVO {
81 81 @Schema(description = "是否需要签名")
82 82 private Boolean signEnable;
83 83  
  84 + @Schema(description = "审批意见")
  85 + private Boolean reasonRequire;
  86 +
84 87 @Data
85 88 @Schema(description = "流程实例")
86 89 public static class ProcessInstance {
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmnModelConstants.java
... ... @@ -115,4 +115,9 @@ public interface BpmnModelConstants {
115 115 */
116 116 String SIGN_ENABLE = "signEnable";
117 117  
  118 + /**
  119 + * 审批意见是否必填
  120 + */
  121 + String REASON_REQUIRE = "reasonRequire";
  122 +
118 123 }
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java
... ... @@ -365,6 +365,23 @@ public class BpmnModelUtils {
365 365 return Convert.toBool(extensionElements.get(0).getElementText(), false);
366 366 }
367 367  
  368 + public static void addReasonRequire(Boolean reasonRequire, FlowElement userTask) {
  369 + addExtensionElement(userTask, REASON_REQUIRE,
  370 + ObjUtil.isNotNull(reasonRequire) ? reasonRequire.toString() : Boolean.FALSE.toString());
  371 + }
  372 +
  373 + public static Boolean parseReasonRequire(BpmnModel bpmnModel, String flowElementId) {
  374 + FlowElement flowElement = getFlowElementById(bpmnModel, flowElementId);
  375 + if (flowElement == null) {
  376 + return false;
  377 + }
  378 + List<ExtensionElement> extensionElements = flowElement.getExtensionElements().get(REASON_REQUIRE);
  379 + if (CollUtil.isEmpty(extensionElements)) {
  380 + return false;
  381 + }
  382 + return Convert.toBool(extensionElements.get(0).getElementText(), false);
  383 + }
  384 +
368 385 public static void addListenerConfig(FlowableListener flowableListener, BpmSimpleModelNodeVO.ListenerHandler handler) {
369 386 FieldExtension fieldExtension = new FieldExtension();
370 387 fieldExtension.setFieldName("listenerConfig");
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java
... ... @@ -441,6 +441,8 @@ public class SimpleModelUtils {
441 441 addUserTaskListener(node, userTask);
442 442 // 添加是否需要签名
443 443 addSignEnable(node.getSignEnable(), userTask);
  444 + // 审批意见
  445 + addReasonRequire(node.getReasonRequire(), userTask);
444 446 return userTask;
445 447 }
446 448  
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
... ... @@ -64,6 +64,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
64 64 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
65 65 import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
66 66 import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG;
  67 +import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.parseReasonRequire;
67 68 import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.parseSignEnable;
68 69  
69 70 /**
... ... @@ -163,6 +164,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
163 164 Map<Integer, BpmTaskRespVO.OperationButtonSetting> buttonsSetting = BpmnModelUtils.parseButtonsSetting(
164 165 bpmnModel, todoTask.getTaskDefinitionKey());
165 166 Boolean signEnable = parseSignEnable(bpmnModel, todoTask.getTaskDefinitionKey());
  167 + Boolean reasonRequire = parseReasonRequire(bpmnModel, todoTask.getTaskDefinitionKey());
166 168  
167 169 // 4. 任务表单
168 170 BpmFormDO taskForm = null;
... ... @@ -171,7 +173,8 @@ public class BpmTaskServiceImpl implements BpmTaskService {
171 173 }
172 174  
173 175 return BpmTaskConvert.INSTANCE.buildTodoTask(todoTask, childrenTasks, buttonsSetting, taskForm)
174   - .setSignEnable(signEnable);
  176 + .setSignEnable(signEnable)
  177 + .setReasonRequire(reasonRequire);
175 178 }
176 179  
177 180 @Override
... ... @@ -488,6 +491,11 @@ public class BpmTaskServiceImpl implements BpmTaskService {
488 491 if (signEnable && StrUtil.isEmpty(reqVO.getSignPicUrl())) {
489 492 throw exception(TASK_SIGNATURE_NOT_EXISTS);
490 493 }
  494 + // 1.4 校验审批意见
  495 + Boolean reasonRequire = parseReasonRequire(bpmnModel, task.getTaskDefinitionKey());
  496 + if (reasonRequire && StrUtil.isEmpty(reqVO.getReason())) {
  497 + throw exception(TASK_REASON_REQUIRE);
  498 + }
491 499  
492 500 // 情况一:被委派的任务,不调用 complete 去完成任务
493 501 if (DelegationState.PENDING.equals(task.getDelegationState())) {
... ...