mirror of
				https://github.com/YunaiV/ruoyi-vue-pro.git
				synced 2025-10-31 02:28:03 +08:00 
			
		
		
		
	feat: 审批意见
This commit is contained in:
		| @ -55,6 +55,7 @@ public interface ErrorCodeConstants { | |||||||
|     ErrorCode TASK_TRANSFER_FAIL_USER_NOT_EXISTS = new ErrorCode(1_009_005_014, "任务转办失败,转办人不存在"); |     ErrorCode TASK_TRANSFER_FAIL_USER_NOT_EXISTS = new ErrorCode(1_009_005_014, "任务转办失败,转办人不存在"); | ||||||
|     ErrorCode TASK_CREATE_FAIL_NO_CANDIDATE_USER = new ErrorCode(1_009_006_003, "操作失败,原因:找不到任务的审批人!"); |     ErrorCode TASK_CREATE_FAIL_NO_CANDIDATE_USER = new ErrorCode(1_009_006_003, "操作失败,原因:找不到任务的审批人!"); | ||||||
|     ErrorCode TASK_SIGNATURE_NOT_EXISTS = new ErrorCode(1_009_005_015, "签名不能为空!"); |     ErrorCode TASK_SIGNATURE_NOT_EXISTS = new ErrorCode(1_009_005_015, "签名不能为空!"); | ||||||
|  |     ErrorCode TASK_REASON_REQUIRE = new ErrorCode(1_009_005_016, "审批意见不能为空!"); | ||||||
|  |  | ||||||
|     // ========== 动态表单模块 1-009-010-000 ========== |     // ========== 动态表单模块 1-009-010-000 ========== | ||||||
|     ErrorCode FORM_NOT_EXISTS = new ErrorCode(1_009_010_000, "动态表单不存在"); |     ErrorCode FORM_NOT_EXISTS = new ErrorCode(1_009_010_000, "动态表单不存在"); | ||||||
|  | |||||||
| @ -63,6 +63,9 @@ public class BpmSimpleModelNodeVO { | |||||||
|     @Schema(description = "是否需要签名", example = "false") |     @Schema(description = "是否需要签名", example = "false") | ||||||
|     private Boolean signEnable; |     private Boolean signEnable; | ||||||
|  |  | ||||||
|  |     @Schema(description = "审批意见", example = "false") | ||||||
|  |     private Boolean reasonRequire; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 审批节点拒绝处理 |      * 审批节点拒绝处理 | ||||||
|      */ |      */ | ||||||
|  | |||||||
| @ -15,7 +15,6 @@ public class BpmTaskApproveReqVO { | |||||||
|     private String id; |     private String id; | ||||||
|  |  | ||||||
|     @Schema(description = "审批意见", requiredMode = Schema.RequiredMode.REQUIRED, example = "不错不错!") |     @Schema(description = "审批意见", requiredMode = Schema.RequiredMode.REQUIRED, example = "不错不错!") | ||||||
|     @NotEmpty(message = "审批意见不能为空") |  | ||||||
|     private String reason; |     private String reason; | ||||||
|  |  | ||||||
|     @Schema(description = "签名", example = "https://www.iocoder.cn/sign.png") |     @Schema(description = "签名", example = "https://www.iocoder.cn/sign.png") | ||||||
|  | |||||||
| @ -14,7 +14,6 @@ public class BpmTaskRejectReqVO { | |||||||
|     private String id; |     private String id; | ||||||
|  |  | ||||||
|     @Schema(description = "审批意见", requiredMode = Schema.RequiredMode.REQUIRED, example = "不错不错!") |     @Schema(description = "审批意见", requiredMode = Schema.RequiredMode.REQUIRED, example = "不错不错!") | ||||||
|     @NotEmpty(message = "审批意见不能为空") |  | ||||||
|     private String reason; |     private String reason; | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -81,6 +81,9 @@ public class BpmTaskRespVO { | |||||||
|     @Schema(description = "是否需要签名") |     @Schema(description = "是否需要签名") | ||||||
|     private Boolean signEnable; |     private Boolean signEnable; | ||||||
|  |  | ||||||
|  |     @Schema(description = "审批意见") | ||||||
|  |     private Boolean reasonRequire; | ||||||
|  |  | ||||||
|     @Data |     @Data | ||||||
|     @Schema(description = "流程实例") |     @Schema(description = "流程实例") | ||||||
|     public static class ProcessInstance { |     public static class ProcessInstance { | ||||||
|  | |||||||
| @ -115,4 +115,9 @@ public interface BpmnModelConstants { | |||||||
|      */ |      */ | ||||||
|     String SIGN_ENABLE = "signEnable"; |     String SIGN_ENABLE = "signEnable"; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 审批意见是否必填 | ||||||
|  |      */ | ||||||
|  |     String REASON_REQUIRE = "reasonRequire"; | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -365,6 +365,23 @@ public class BpmnModelUtils { | |||||||
|         return Convert.toBool(extensionElements.get(0).getElementText(), false); |         return Convert.toBool(extensionElements.get(0).getElementText(), false); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public static void addReasonRequire(Boolean reasonRequire, FlowElement userTask) { | ||||||
|  |         addExtensionElement(userTask, REASON_REQUIRE, | ||||||
|  |                 ObjUtil.isNotNull(reasonRequire) ? reasonRequire.toString() : Boolean.FALSE.toString()); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static Boolean parseReasonRequire(BpmnModel bpmnModel, String flowElementId) { | ||||||
|  |         FlowElement flowElement = getFlowElementById(bpmnModel, flowElementId); | ||||||
|  |         if (flowElement == null) { | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |         List<ExtensionElement> extensionElements = flowElement.getExtensionElements().get(REASON_REQUIRE); | ||||||
|  |         if (CollUtil.isEmpty(extensionElements)) { | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |         return Convert.toBool(extensionElements.get(0).getElementText(), false); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     public static void addListenerConfig(FlowableListener flowableListener, BpmSimpleModelNodeVO.ListenerHandler handler) { |     public static void addListenerConfig(FlowableListener flowableListener, BpmSimpleModelNodeVO.ListenerHandler handler) { | ||||||
|         FieldExtension fieldExtension = new FieldExtension(); |         FieldExtension fieldExtension = new FieldExtension(); | ||||||
|         fieldExtension.setFieldName("listenerConfig"); |         fieldExtension.setFieldName("listenerConfig"); | ||||||
|  | |||||||
| @ -441,6 +441,8 @@ public class SimpleModelUtils { | |||||||
|             addUserTaskListener(node, userTask); |             addUserTaskListener(node, userTask); | ||||||
|             // 添加是否需要签名 |             // 添加是否需要签名 | ||||||
|             addSignEnable(node.getSignEnable(), userTask); |             addSignEnable(node.getSignEnable(), userTask); | ||||||
|  |             // 审批意见 | ||||||
|  |             addReasonRequire(node.getReasonRequire(), userTask); | ||||||
|             return userTask; |             return userTask; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | |||||||
| @ -64,6 +64,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU | |||||||
| import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; | ||||||
| import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; | import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; | ||||||
| import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG; | import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG; | ||||||
|  | import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.parseReasonRequire; | ||||||
| import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.parseSignEnable; | import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.parseSignEnable; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @ -163,6 +164,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | |||||||
|         Map<Integer, BpmTaskRespVO.OperationButtonSetting> buttonsSetting = BpmnModelUtils.parseButtonsSetting( |         Map<Integer, BpmTaskRespVO.OperationButtonSetting> buttonsSetting = BpmnModelUtils.parseButtonsSetting( | ||||||
|                 bpmnModel, todoTask.getTaskDefinitionKey()); |                 bpmnModel, todoTask.getTaskDefinitionKey()); | ||||||
|         Boolean signEnable = parseSignEnable(bpmnModel, todoTask.getTaskDefinitionKey()); |         Boolean signEnable = parseSignEnable(bpmnModel, todoTask.getTaskDefinitionKey()); | ||||||
|  |         Boolean reasonRequire = parseReasonRequire(bpmnModel, todoTask.getTaskDefinitionKey()); | ||||||
|  |  | ||||||
|         // 4. 任务表单 |         // 4. 任务表单 | ||||||
|         BpmFormDO taskForm = null; |         BpmFormDO taskForm = null; | ||||||
| @ -171,7 +173,8 @@ public class BpmTaskServiceImpl implements BpmTaskService { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         return BpmTaskConvert.INSTANCE.buildTodoTask(todoTask, childrenTasks, buttonsSetting, taskForm) |         return BpmTaskConvert.INSTANCE.buildTodoTask(todoTask, childrenTasks, buttonsSetting, taskForm) | ||||||
|                 .setSignEnable(signEnable); |                 .setSignEnable(signEnable) | ||||||
|  |                 .setReasonRequire(reasonRequire); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @ -488,6 +491,11 @@ public class BpmTaskServiceImpl implements BpmTaskService { | |||||||
|         if (signEnable && StrUtil.isEmpty(reqVO.getSignPicUrl())) { |         if (signEnable && StrUtil.isEmpty(reqVO.getSignPicUrl())) { | ||||||
|             throw exception(TASK_SIGNATURE_NOT_EXISTS); |             throw exception(TASK_SIGNATURE_NOT_EXISTS); | ||||||
|         } |         } | ||||||
|  |         // 1.4 校验审批意见 | ||||||
|  |         Boolean reasonRequire = parseReasonRequire(bpmnModel, task.getTaskDefinitionKey()); | ||||||
|  |         if (reasonRequire && StrUtil.isEmpty(reqVO.getReason())) { | ||||||
|  |             throw exception(TASK_REASON_REQUIRE); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         // 情况一:被委派的任务,不调用 complete 去完成任务 |         // 情况一:被委派的任务,不调用 complete 去完成任务 | ||||||
|         if (DelegationState.PENDING.equals(task.getDelegationState())) { |         if (DelegationState.PENDING.equals(task.getDelegationState())) { | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Lesan
					Lesan