!1195 BPM:审批意见

Merge pull request !1195 from Lesan/feature/bpm-审批意见
This commit is contained in:
芋道源码 2025-01-19 10:26:14 +00:00 committed by Gitee
commit 89728fe6ff
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
9 changed files with 40 additions and 3 deletions

View File

@ -56,6 +56,7 @@ public interface ErrorCodeConstants {
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_SIGNATURE_NOT_EXISTS = new ErrorCode(1_009_005_015, "签名不能为空!");
ErrorCode TASK_REASON_REQUIRE = new ErrorCode(1_009_005_016, "审批意见不能为空!");
// ========== 动态表单模块 1-009-010-000 ==========
ErrorCode FORM_NOT_EXISTS = new ErrorCode(1_009_010_000, "动态表单不存在");

View File

@ -63,6 +63,9 @@ public class BpmSimpleModelNodeVO {
@Schema(description = "是否需要签名", example = "false")
private Boolean signEnable;
@Schema(description = "审批意见", example = "false")
private Boolean reasonRequire;
/**
* 审批节点拒绝处理
*/

View File

@ -15,7 +15,6 @@ public class BpmTaskApproveReqVO {
private String id;
@Schema(description = "审批意见", requiredMode = Schema.RequiredMode.REQUIRED, example = "不错不错!")
@NotEmpty(message = "审批意见不能为空")
private String reason;
@Schema(description = "签名", example = "https://www.iocoder.cn/sign.png")

View File

@ -14,7 +14,6 @@ public class BpmTaskRejectReqVO {
private String id;
@Schema(description = "审批意见", requiredMode = Schema.RequiredMode.REQUIRED, example = "不错不错!")
@NotEmpty(message = "审批意见不能为空")
private String reason;
}

View File

@ -81,6 +81,9 @@ public class BpmTaskRespVO {
@Schema(description = "是否需要签名")
private Boolean signEnable;
@Schema(description = "审批意见")
private Boolean reasonRequire;
@Data
@Schema(description = "流程实例")
public static class ProcessInstance {

View File

@ -115,4 +115,9 @@ public interface BpmnModelConstants {
*/
String SIGN_ENABLE = "signEnable";
/**
* 审批意见是否必填
*/
String REASON_REQUIRE = "reasonRequire";
}

View File

@ -365,6 +365,23 @@ public class BpmnModelUtils {
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) {
FieldExtension fieldExtension = new FieldExtension();
fieldExtension.setFieldName("listenerConfig");

View File

@ -441,6 +441,8 @@ public class SimpleModelUtils {
addUserTaskListener(node, userTask);
// 添加是否需要签名
addSignEnable(node.getSignEnable(), userTask);
// 审批意见
addReasonRequire(node.getReasonRequire(), userTask);
return userTask;
}

View File

@ -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.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.util.BpmnModelUtils.parseReasonRequire;
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(
bpmnModel, todoTask.getTaskDefinitionKey());
Boolean signEnable = parseSignEnable(bpmnModel, todoTask.getTaskDefinitionKey());
Boolean reasonRequire = parseReasonRequire(bpmnModel, todoTask.getTaskDefinitionKey());
// 4. 任务表单
BpmFormDO taskForm = null;
@ -171,7 +173,8 @@ public class BpmTaskServiceImpl implements BpmTaskService {
}
return BpmTaskConvert.INSTANCE.buildTodoTask(todoTask, childrenTasks, buttonsSetting, taskForm)
.setSignEnable(signEnable);
.setSignEnable(signEnable)
.setReasonRequire(reasonRequire);
}
@Override
@ -488,6 +491,11 @@ public class BpmTaskServiceImpl implements BpmTaskService {
if (signEnable && StrUtil.isEmpty(reqVO.getSignPicUrl())) {
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 去完成任务
if (DelegationState.PENDING.equals(task.getDelegationState())) {