update(REQ-2324): 调整代码,减少多层 ifelse 嵌套

This commit is contained in:
wangli 2024-05-13 10:03:17 +08:00
parent c2487725f4
commit a8b0935a99
2 changed files with 33 additions and 17 deletions

View File

@ -58,23 +58,26 @@ public class ApproveErrorReporterEventListener implements BpmnAsyncJobEventListe
JobInfo jobInfo = (JobInfo) jobEvent.getEntity();
String handlerType = jobInfo.getJobHandlerType();
//只处理审批类型任务
if (AsyncApproveTaskJobHandler.TYPE.equals(handlerType)) {
Throwable throwable = jobEvent.getCause();
if (StringUtils.isNoneBlank(jobInfo.getCustomValues())) {
BpmnTaskAuditDTO dto = JSONUtil.toBean(jobInfo.getCustomValues(), BpmnTaskAuditDTO.class);
WorkflowEngineException exception = (WorkflowEngineException) (throwable);
if (!IGNORE_ERROR_CODES.contains(exception.getCode())) {
Process process = ProcessDefinitionUtil.getProcess(((FlowableEntityExceptionEventImpl) flowableEvent).getProcessDefinitionId());
//获取消息配置
Optional<BpmnNoticeConf> noticeConfig = BpmnMetaParserHelper.getNoticeConfig(process);
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration();
FlowableEventDispatcher eventDispatcher = processEngineConfiguration.getEventDispatcher();
MessagePushEvent event = MessagePushEventBuilder.createPendingRollbackEvent(jobEvent.getProcessInstanceId(), jobInfo.getTenantId(), dto.getTaskId(), noticeConfig.orElse(new BpmnNoticeConf()));
log.info("发送恢复待办的流程事件消息: taskDto:{},event:{}", JSONUtil.toJsonStr(dto), JSONUtil.toJsonStr(event));
eventDispatcher.dispatchEvent(event, processEngineConfiguration.getEngineCfgKey());
}
} else {
log.warn("审批类型错误,CustomValues内容为空,event:{}", jobEvent);
if (!AsyncApproveTaskJobHandler.TYPE.equals(handlerType)) {
return;
}
if (StringUtils.isBlank(jobInfo.getCustomValues())) {
log.warn("审批类型错误,CustomValues内容为空,event:{}", jobEvent);
return;
}
BpmnTaskAuditDTO dto = JSONUtil.toBean(jobInfo.getCustomValues(), BpmnTaskAuditDTO.class);
if (jobEvent.getCause() instanceof WorkflowEngineException) {
WorkflowEngineException exception = (WorkflowEngineException) jobEvent.getCause();
if (!IGNORE_ERROR_CODES.contains(exception.getCode())) {
Process process = ProcessDefinitionUtil.getProcess(((FlowableEntityExceptionEventImpl) flowableEvent).getProcessDefinitionId());
//获取消息配置
Optional<BpmnNoticeConf> noticeConfig = BpmnMetaParserHelper.getNoticeConfig(process);
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration();
FlowableEventDispatcher eventDispatcher = processEngineConfiguration.getEventDispatcher();
MessagePushEvent event = MessagePushEventBuilder.createPendingRollbackEvent(jobEvent.getProcessInstanceId(), jobInfo.getTenantId(), dto.getTaskId(), noticeConfig.orElse(new BpmnNoticeConf()));
log.info("发送恢复待办的流程事件消息: taskDto:{},event:{}", JSONUtil.toJsonStr(dto), JSONUtil.toJsonStr(event));
eventDispatcher.dispatchEvent(event, processEngineConfiguration.getEngineCfgKey());
}
}
}

View File

@ -72,3 +72,16 @@ spring:
server-addr: ${NACOS_HOST:https://pre-nacos.axzo.cn}:${NACOS_PORT:443}
file-extension: yaml
namespace: ${NACOS_NAMESPACE_ID:8b4cf725-7595-4c92-b2a6-9260a51ce078}
---
#预发布环境
spring:
config:
activate:
on-profile: live
cloud:
nacos:
config:
server-addr: ${NACOS_HOST:https://live-nacos.axzo.cn}:${NACOS_PORT:443}
file-extension: yaml
namespace: ${NACOS_NAMESPACE_ID:64faf030-7112-45c3-9f06-a40571f685c2}