fix(bpm): 优化消息发送逻辑并处理空指针异常优化BpmMessageServiceImpl中消息发送的逻辑,解决因DeptRespDTO空指针异常导致的站内信发送失败问题。调整微信小程序订阅消息发送逻辑,增加null检查并捕获异常,以防止发送失败。
This commit is contained in:
parent
92655db868
commit
b1f1aace4a
@ -11,8 +11,6 @@ import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcess
|
||||
import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO;
|
||||
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAWorkTaskService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi;
|
||||
import cn.iocoder.yudao.module.system.api.subscribe.SubscribeMessageSendApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
@ -80,7 +78,7 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
||||
//站内信
|
||||
notifyMessageSendApi.sendSingleMessageToAdmin(BpmMessageConvert.INSTANCE.convert1(
|
||||
reqDTO.getStartUserId(), BpmMessageEnum.BPM_WORK_TASK_COMPLETE.getSmsTemplateCode(), templateParams));
|
||||
}else {
|
||||
} else {
|
||||
|
||||
//发送站内信息
|
||||
notifyMessageSendApi.sendSingleMessageToAdmin(BpmMessageConvert.INSTANCE.convert1(reqDTO.getStartUserId(),
|
||||
@ -98,7 +96,7 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
||||
subscribeMessageSendApi.sendWorkLogComment(BpmMessageConvert.INSTANCE.convertWorkTask(
|
||||
openId, reqDTO.getProcessInstanceName(), workTaskDO, nickName, reqDTO.getCreateTime(),
|
||||
"formal", true, userRespDTO.getDeptId()));
|
||||
}else {
|
||||
} else {
|
||||
|
||||
subscribeMessageSendApi.sendApprovalResultNotification(
|
||||
BpmMessageConvert.INSTANCE.convertApprovalResultNotification(
|
||||
@ -198,7 +196,7 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
||||
//站内信
|
||||
notifyMessageSendApi.sendSingleMessageToAdmin(BpmMessageConvert.INSTANCE.convert1(
|
||||
reqDTO.getAssigneeUserId(), BpmMessageEnum.BPM_WORK_TASK.getSmsTemplateCode(), templateParams));
|
||||
}else {
|
||||
} else {
|
||||
|
||||
//站内信
|
||||
notifyMessageSendApi.sendSingleMessageToAdmin(BpmMessageConvert.INSTANCE.convert1(
|
||||
@ -208,21 +206,21 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
||||
//微信小程序订阅消息
|
||||
//发送OA流程待办提醒
|
||||
String openId = getUserOpenId(assigneeUserId); //只有在微信小程序登陆过用户才会有openid
|
||||
if (openId != null) {
|
||||
|
||||
|
||||
if (workTaskDO != null) {
|
||||
|
||||
subscribeMessageSendApi.sendWorkLogComment(BpmMessageConvert.INSTANCE.convertWorkTask(
|
||||
openId, reqDTO.getProcessInstanceName(), workTaskDO, reqDTO.getStartUserNickname(), reqDTO.getCreateTime(),
|
||||
"formal", false, null));
|
||||
}else {
|
||||
|
||||
subscribeMessageSendApi.sendProcessToDoReminder(BpmMessageConvert.INSTANCE.convertProcessToDoReminder(
|
||||
openId, reqDTO.getProcessInstanceName(), reqDTO.getStartUserNickname(), reqDTO.getCreateTime(), reqDTO.getSchedule(),
|
||||
reqDTO.getProcessInstanceId(),
|
||||
"formal"));
|
||||
try {
|
||||
if (openId != null) {
|
||||
if (workTaskDO != null) {
|
||||
subscribeMessageSendApi.sendWorkLogComment(BpmMessageConvert.INSTANCE.convertWorkTask(
|
||||
openId, reqDTO.getProcessInstanceName(), workTaskDO, reqDTO.getStartUserNickname(), reqDTO.getCreateTime(),
|
||||
"formal", false, null));
|
||||
} else {
|
||||
subscribeMessageSendApi.sendProcessToDoReminder(BpmMessageConvert.INSTANCE.convertProcessToDoReminder(
|
||||
openId, reqDTO.getProcessInstanceName(), reqDTO.getStartUserNickname(), reqDTO.getCreateTime(), reqDTO.getSchedule(),
|
||||
reqDTO.getProcessInstanceId(),
|
||||
"formal"));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("发送OA流程待办提醒失败,openId:{}", openId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user