fix(flowable): 添加空值检查避免空指针异常

在LeadStartListener和BoStartListener中添加对查询结果的空值检查,防止当查询结果为空时出现空指针异常。同时添加相应的日志警告信息,便于问题排查。
This commit is contained in:
2026-04-02 12:43:22 +08:00
parent 6e4c089625
commit 7fa9a37063
2 changed files with 18 additions and 5 deletions

View File

@@ -40,6 +40,9 @@ public class BoStartListener implements ExecutionListener {
// 获取校领导信息 // 获取校领导信息
String roleKey = "xldsp"; //角色key String roleKey = "xldsp"; //角色key
List<TeacherVo> lingDataInfo = leaveMapper.getShenDataInfo(roleKey); List<TeacherVo> lingDataInfo = leaveMapper.getShenDataInfo(roleKey);
if (lingDataInfo == null || lingDataInfo.isEmpty()) {
log.warn("未找到校领导(roleKey={})信息,跳过学工领导通知。", roleKey);
}
// 设置流程变量 // 设置流程变量
//delegateExecution.setVariable("approval", secondaryLeaderInfo.getUserId()); //delegateExecution.setVariable("approval", secondaryLeaderInfo.getUserId());
@@ -52,8 +55,10 @@ public class BoStartListener implements ExecutionListener {
// 步骤 3: 检查是否成功获取到 userName // 步骤 3: 检查是否成功获取到 userName
//向系统发送通知 //向系统发送通知
NotificationManage notificationManage = new NotificationManage(); NotificationManage notificationManage = new NotificationManage();
notificationManage.setContent("您有一条【学工领导已提交请假申请审批】需待处理"); // 消息内容 if (lingDataInfo != null && !lingDataInfo.isEmpty()) {
notificationManage.setReceiver(lingDataInfo.get(0).getUserId()); notificationManage.setContent("您有一条【学工领导已提交请假申请审批】需待处理"); // 消息内容
notificationManage.setReceiver(lingDataInfo.get(0).getUserId());
}
NotificationManage userManage = leaveMapper.selectCphMsgListForFlowable(notificationManage); NotificationManage userManage = leaveMapper.selectCphMsgListForFlowable(notificationManage);
if (userManage != null) { if (userManage != null) {
//删除指定通知信息 //删除指定通知信息
@@ -62,9 +67,13 @@ public class BoStartListener implements ExecutionListener {
//向学工领导添加通知信息 //向学工领导添加通知信息
// 获取二级学院书记信息 // 获取二级学院书记信息
List<TeacherVo> secondaryLeaderInfo = leaveMapper.getSecondaryLeaderInfo(deptId); List<TeacherVo> secondaryLeaderInfo = leaveMapper.getSecondaryLeaderInfo(deptId);
//由于这里查到了多个数据,由于时间原因,暂时还没有研究到工作流中多用户节点的同时进行(所以取了第一条数据用于发消息) if (secondaryLeaderInfo == null || secondaryLeaderInfo.isEmpty()) {
notificationManage.setContent("您有一条【二级学院书记已提交请假申请审批】需待处理"); // 消息内容 log.warn("未找到二级学院书记信息deptId={},跳过通知。", deptId);
notificationManage.setSender(secondaryLeaderInfo.get(0).getUserId()); // 发送方 } else {
//由于这里查到了多个数据,由于时间原因,暂时还没有研究到工作流中多用户节点的同时进行(所以取了第一条数据用于发消息)
notificationManage.setContent("您有一条【二级学院书记已提交请假申请审批】需待处理"); // 消息内容
notificationManage.setSender(secondaryLeaderInfo.get(0).getUserId()); // 发送方
}
notificationManage.setReceiver(Long.parseLong(approval)); // 接收方 notificationManage.setReceiver(Long.parseLong(approval)); // 接收方
NotificationManage userManages = leaveMapper.selectCphMsgListForFlowable(notificationManage); NotificationManage userManages = leaveMapper.selectCphMsgListForFlowable(notificationManage);
if (userManages == null) { if (userManages == null) {

View File

@@ -42,6 +42,10 @@ public class LeadStartListener implements ExecutionListener {
// 获取学工信息 // 获取学工信息
//TeacherVo updateDeptId = leaveMapper.getUpdateDeptId(approval); //TeacherVo updateDeptId = leaveMapper.getUpdateDeptId(approval);
List<TeacherVo> updateDeptIdInfo = leaveMapper.getUpdateDeptIdInfo(1045L); List<TeacherVo> updateDeptIdInfo = leaveMapper.getUpdateDeptIdInfo(1045L);
if (updateDeptIdInfo == null || updateDeptIdInfo.isEmpty()) {
log.warn("未找到学工领导信息,跳过审批人设置与通知。");
return;
}
// 设置流程变量 // 设置流程变量
delegateExecution.setVariable("approval", updateDeptIdInfo.get(0).getUserId()); delegateExecution.setVariable("approval", updateDeptIdInfo.get(0).getUserId());