fix(bpm):优化PortalRequest可用性检查逻辑- 将null判断改为available()方法调用,确保sysCode、domain和protocol均非空- 在PortalRequest类中新增available()方法,用于检查实例是否可用
- 统一代码风格,优化条件判断和字符串判空逻辑 - 调整方法参数格式,增强代码可读性 - 修复潜在的空指针异常问题,提高系统稳定性
This commit is contained in:
@@ -59,7 +59,7 @@ public class PortalTodoServiceImpl implements IPortalTodoService {
|
|||||||
if (MapUtil.isEmpty(risk)) return false;
|
if (MapUtil.isEmpty(risk)) return false;
|
||||||
// 0.2.从容器中获取 PortalRequest 对象,如果没有配置则放弃通知
|
// 0.2.从容器中获取 PortalRequest 对象,如果没有配置则放弃通知
|
||||||
PortalRequest portalRequest = SpringUtils.getBean(PortalRequest.class);
|
PortalRequest portalRequest = SpringUtils.getBean(PortalRequest.class);
|
||||||
if (ObjectUtil.isNull(portalRequest)) return false;
|
if (!Objects.requireNonNull(portalRequest).available()) return false;
|
||||||
|
|
||||||
// 1.构建请求参数,准备推送待办信息
|
// 1.构建请求参数,准备推送待办信息
|
||||||
String creator = "";
|
String creator = "";
|
||||||
@@ -82,12 +82,10 @@ public class PortalTodoServiceImpl implements IPortalTodoService {
|
|||||||
risk.getOrDefault("check_people", "");
|
risk.getOrDefault("check_people", "");
|
||||||
// 1.2.根据代办类型取消息发送者 TODO 需要升级存储检查人的username
|
// 1.2.根据代办类型取消息发送者 TODO 需要升级存储检查人的username
|
||||||
if (todoType.equals("CHARGE_TODO") || todoType.equals("CHARGE_DONE")) {
|
if (todoType.equals("CHARGE_TODO") || todoType.equals("CHARGE_DONE")) {
|
||||||
if(todoType.equals("CHARGE_TODO"))
|
if (todoType.equals("CHARGE_TODO")) {
|
||||||
{
|
|
||||||
isRemark = WORK_STATUS_TODO;
|
isRemark = WORK_STATUS_TODO;
|
||||||
viewType = VIEW_TYPE_UNREAD;
|
viewType = VIEW_TYPE_UNREAD;
|
||||||
}else
|
} else {
|
||||||
{
|
|
||||||
isRemark = WORK_STATUS_DONE;
|
isRemark = WORK_STATUS_DONE;
|
||||||
viewType = VIEW_TYPE_READ;
|
viewType = VIEW_TYPE_READ;
|
||||||
}
|
}
|
||||||
@@ -97,11 +95,9 @@ public class PortalTodoServiceImpl implements IPortalTodoService {
|
|||||||
AdminUserRespDTO createUser = Optional.ofNullable(createUserId)
|
AdminUserRespDTO createUser = Optional.ofNullable(createUserId)
|
||||||
.map(userId -> apiAdminUserApi.getUser(userId))
|
.map(userId -> apiAdminUserApi.getUser(userId))
|
||||||
.orElse(new AdminUserRespDTO());
|
.orElse(new AdminUserRespDTO());
|
||||||
if(StringUtils.isEmpty(createUser.getUsername()))
|
if (StringUtils.isEmpty(createUser.getUsername())) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}else
|
} else {
|
||||||
{
|
|
||||||
creator = createUser.getUsername();
|
creator = createUser.getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,21 +106,16 @@ public class PortalTodoServiceImpl implements IPortalTodoService {
|
|||||||
AdminUserRespDTO receiveUser = Optional.ofNullable(receiveId)
|
AdminUserRespDTO receiveUser = Optional.ofNullable(receiveId)
|
||||||
.map(userId -> apiAdminUserApi.getUser(userId))
|
.map(userId -> apiAdminUserApi.getUser(userId))
|
||||||
.orElse(new AdminUserRespDTO());
|
.orElse(new AdminUserRespDTO());
|
||||||
if(StringUtils.isEmpty(receiveUser.getUsername()))
|
if (StringUtils.isEmpty(receiveUser.getUsername())) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}else
|
} else {
|
||||||
{
|
|
||||||
receiver = receiveUser.getUsername();
|
receiver = receiveUser.getUsername();
|
||||||
}
|
}
|
||||||
}else if(todoType.equals("CONFIRM_TODO")||todoType.equals("CONFIRM_DONE"))
|
} else if (todoType.equals("CONFIRM_TODO") || todoType.equals("CONFIRM_DONE")) {
|
||||||
{
|
if (todoType.equals("CONFIRM_TODO")) {
|
||||||
if(todoType.equals("CONFIRM_TODO"))
|
|
||||||
{
|
|
||||||
isRemark = WORK_STATUS_TODO;
|
isRemark = WORK_STATUS_TODO;
|
||||||
viewType = VIEW_TYPE_UNREAD;
|
viewType = VIEW_TYPE_UNREAD;
|
||||||
}else
|
} else {
|
||||||
{
|
|
||||||
isRemark = WORK_STATUS_DONE;
|
isRemark = WORK_STATUS_DONE;
|
||||||
viewType = VIEW_TYPE_READ;
|
viewType = VIEW_TYPE_READ;
|
||||||
}
|
}
|
||||||
@@ -134,11 +125,9 @@ public class PortalTodoServiceImpl implements IPortalTodoService {
|
|||||||
AdminUserRespDTO createUser = Optional.ofNullable(createUserId)
|
AdminUserRespDTO createUser = Optional.ofNullable(createUserId)
|
||||||
.map(userId -> apiAdminUserApi.getUser(userId))
|
.map(userId -> apiAdminUserApi.getUser(userId))
|
||||||
.orElse(new AdminUserRespDTO());
|
.orElse(new AdminUserRespDTO());
|
||||||
if(StringUtils.isEmpty(createUser.getUsername()))
|
if (StringUtils.isEmpty(createUser.getUsername())) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}else
|
} else {
|
||||||
{
|
|
||||||
creator = createUser.getUsername();
|
creator = createUser.getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,11 +136,9 @@ public class PortalTodoServiceImpl implements IPortalTodoService {
|
|||||||
AdminUserRespDTO receiveUser = Optional.ofNullable(receiveId)
|
AdminUserRespDTO receiveUser = Optional.ofNullable(receiveId)
|
||||||
.map(userId -> apiAdminUserApi.getUser(userId))
|
.map(userId -> apiAdminUserApi.getUser(userId))
|
||||||
.orElse(new AdminUserRespDTO());
|
.orElse(new AdminUserRespDTO());
|
||||||
if(StringUtils.isEmpty(receiveUser.getUsername()))
|
if (StringUtils.isEmpty(receiveUser.getUsername())) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}else
|
} else {
|
||||||
{
|
|
||||||
receiver = receiveUser.getUsername();
|
receiver = receiveUser.getUsername();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,8 +162,7 @@ public class PortalTodoServiceImpl implements IPortalTodoService {
|
|||||||
// 2.推送待办信息,使用try-catch避免影响上层调用方法的事务回滚
|
// 2.推送待办信息,使用try-catch避免影响上层调用方法的事务回滚
|
||||||
try {
|
try {
|
||||||
portalRequest.receiveRequestInfo(todoRequestDTO);
|
portalRequest.receiveRequestInfo(todoRequestDTO);
|
||||||
if(todoType.equals("CONFIRM_DONE"))
|
if (todoType.equals("CONFIRM_DONE")) {
|
||||||
{
|
|
||||||
portalRequest.receiveRequestInfo(completeRequestDTO);
|
portalRequest.receiveRequestInfo(completeRequestDTO);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -193,7 +179,7 @@ public class PortalTodoServiceImpl implements IPortalTodoService {
|
|||||||
if (MapUtil.isEmpty(risk)) return false;
|
if (MapUtil.isEmpty(risk)) return false;
|
||||||
// 0.2.从容器中获取 PortalRequest 对象,如果没有配置则放弃通知
|
// 0.2.从容器中获取 PortalRequest 对象,如果没有配置则放弃通知
|
||||||
PortalRequest portalRequest = SpringUtils.getBean(PortalRequest.class);
|
PortalRequest portalRequest = SpringUtils.getBean(PortalRequest.class);
|
||||||
if (ObjectUtil.isNull(portalRequest)) return false;
|
if (!Objects.requireNonNull(portalRequest).available()) return false;
|
||||||
|
|
||||||
// 1.构建请求参数,准备推送待办信息
|
// 1.构建请求参数,准备推送待办信息
|
||||||
DeleteRequestInfoDTO deleteRequestInfoDTO = new DeleteRequestInfoDTO()
|
DeleteRequestInfoDTO deleteRequestInfoDTO = new DeleteRequestInfoDTO()
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class RiskServiceImpl implements IRiskService {
|
|||||||
|
|
||||||
// 0.2.从容器中获取 PortalRequest 对象,如果没有配置则放弃通知
|
// 0.2.从容器中获取 PortalRequest 对象,如果没有配置则放弃通知
|
||||||
PortalRequest portalRequest = SpringUtils.getBean(PortalRequest.class);
|
PortalRequest portalRequest = SpringUtils.getBean(PortalRequest.class);
|
||||||
if (ObjectUtil.isNull(portalRequest)) return;
|
if (!Objects.requireNonNull(portalRequest).available()) return;
|
||||||
|
|
||||||
// 1.构建请求参数,准备推送待办信息
|
// 1.构建请求参数,准备推送待办信息
|
||||||
// 1.1.拼接标题
|
// 1.1.拼接标题
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public class BpmPortalTodoEventListener extends AbstractFlowableEngineEventListe
|
|||||||
protected void processCancelled(FlowableCancelledEvent event) {
|
protected void processCancelled(FlowableCancelledEvent event) {
|
||||||
// 流程取消事件,这里对应调用流程删除接口
|
// 流程取消事件,这里对应调用流程删除接口
|
||||||
PortalRequest portalRequest = SpringUtils.getBean(PortalRequest.class);
|
PortalRequest portalRequest = SpringUtils.getBean(PortalRequest.class);
|
||||||
if (Objects.isNull(portalRequest)) {
|
if (!Objects.requireNonNull(portalRequest).available()) {
|
||||||
// 如果没有配置待办平台,则结束这个监听任务的执行
|
// 如果没有配置待办平台,则结束这个监听任务的执行
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ public class BpmPortalTodoEventListener extends AbstractFlowableEngineEventListe
|
|||||||
protected void processCompleted(FlowableEngineEntityEvent event) {
|
protected void processCompleted(FlowableEngineEntityEvent event) {
|
||||||
// 流程完成事件,对应流程办结
|
// 流程完成事件,对应流程办结
|
||||||
PortalRequest portalRequest = SpringUtils.getBean(PortalRequest.class);
|
PortalRequest portalRequest = SpringUtils.getBean(PortalRequest.class);
|
||||||
if (portalRequest == null) {
|
if (!Objects.requireNonNull(portalRequest).available()) {
|
||||||
// 如果没有配置待办平台,则结束这个监听任务的执行
|
// 如果没有配置待办平台,则结束这个监听任务的执行
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -172,7 +172,7 @@ public class BpmPortalTodoEventListener extends AbstractFlowableEngineEventListe
|
|||||||
protected void taskAssigned(FlowableEngineEntityEvent event) {
|
protected void taskAssigned(FlowableEngineEntityEvent event) {
|
||||||
// 任务分配事件,对应待办
|
// 任务分配事件,对应待办
|
||||||
PortalRequest portalRequest = SpringUtils.getBean(PortalRequest.class);
|
PortalRequest portalRequest = SpringUtils.getBean(PortalRequest.class);
|
||||||
if (portalRequest == null) {
|
if (!Objects.requireNonNull(portalRequest).available()) {
|
||||||
// 如果没有配置待办平台,则结束这个监听任务的执行
|
// 如果没有配置待办平台,则结束这个监听任务的执行
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -241,7 +241,7 @@ public class BpmPortalTodoEventListener extends AbstractFlowableEngineEventListe
|
|||||||
protected void taskCompleted(FlowableEngineEntityEvent event) {
|
protected void taskCompleted(FlowableEngineEntityEvent event) {
|
||||||
// 任务完成事件,这里处理任务已办
|
// 任务完成事件,这里处理任务已办
|
||||||
PortalRequest portalRequest = SpringUtils.getBean(PortalRequest.class);
|
PortalRequest portalRequest = SpringUtils.getBean(PortalRequest.class);
|
||||||
if (portalRequest == null) {
|
if (!Objects.requireNonNull(portalRequest).available()) {
|
||||||
// 如果没有配置待办平台,则结束这个监听任务的执行
|
// 如果没有配置待办平台,则结束这个监听任务的执行
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.jeelowcode.service.bpm.config.framework.portal.core;
|
|||||||
|
|
||||||
import cn.hutool.http.Header;
|
import cn.hutool.http.Header;
|
||||||
import cn.hutool.http.HttpRequest;
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import com.jeelowcode.framework.plus.core.toolkit.StringUtils;
|
||||||
import com.jeelowcode.service.bpm.config.framework.portal.core.dto.*;
|
import com.jeelowcode.service.bpm.config.framework.portal.core.dto.*;
|
||||||
import com.jeelowcode.tool.framework.common.util.json.JsonUtils;
|
import com.jeelowcode.tool.framework.common.util.json.JsonUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -159,4 +160,13 @@ public class PortalRequest {
|
|||||||
return JsonUtils.parseObject(httpRequest.execute().body(), PortalTodoResponseDTO.class);
|
return JsonUtils.parseObject(httpRequest.execute().body(), PortalTodoResponseDTO.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查当前PortalRequest实例是否可用
|
||||||
|
*
|
||||||
|
* @return 当sysCode、domain和protocol都不为空时返回true,否则返回false
|
||||||
|
*/
|
||||||
|
public boolean available() {
|
||||||
|
return !StringUtils.isBlank(sysCode) && !StringUtils.isBlank(domain) && !StringUtils.isBlank(protocol);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ public class BpmProcessInstanceCopyServiceImpl implements IBpmProcessInstanceCop
|
|||||||
// 3.推送给待办系统
|
// 3.推送给待办系统
|
||||||
PortalRequest portalRequest = SpringUtils.getBean(PortalRequest.class);
|
PortalRequest portalRequest = SpringUtils.getBean(PortalRequest.class);
|
||||||
// 3.1 如果没有配置待办平台,则结束这个监听任务的执行
|
// 3.1 如果没有配置待办平台,则结束这个监听任务的执行
|
||||||
if (ObjectUtil.isNull(portalRequest)) return;
|
if (!Objects.requireNonNull(portalRequest).available()) return;
|
||||||
// 3.2 调用待办系统,发送待办消息
|
// 3.2 调用待办系统,发送待办消息
|
||||||
try {
|
try {
|
||||||
copyList.stream().map(copy -> {
|
copyList.stream().map(copy -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user