Commit b6054cf2 authored by tianbo's avatar tianbo

fix(jg): 修复设备事件发布时的空指针问题

- 使用 removeIf 替代 remove 方法以安全移除空元素 - 增加空列表检查,避免发布空事件 - 修复质量评分更新服务中返回空值的问题,改为返回默认值 0 - 添加数据刷新消息发送前的空校验,防止空指针异常
parent e6601a53
......@@ -61,7 +61,7 @@ public class EquipQualityScoreUpdateService extends DefaultQualityScoreUpdateSer
IdxBizJgUseInfo useInfo = getIdxBizJgUseInfo(record);
IdxBizJgRegisterInfo registerInfo = getIdxBizJgRegisterInfo(record);
if (ValidationUtil.isEmpty(useInfo) || ValidationUtil.isEmpty(registerInfo)) {
return null;
return 0;
}
matchItemDto.setBizType(bizType);
matchItemDto.setEquList(registerInfo.getEquList());
......@@ -96,6 +96,9 @@ public class EquipQualityScoreUpdateService extends DefaultQualityScoreUpdateSer
}
private void sendDataRefreshMsgEquip(List<String> records) {
if (ValidationUtil.isEmpty(records)) {
return;
}
eventPublisher.publish(new DataRefreshEvent(this, records, DataRefreshEvent.DataType.equipment.name(), DataRefreshEvent.Operation.UPDATE));
}
......
......@@ -58,7 +58,7 @@ public class ProjectQualityScoreUpdateService extends DefaultQualityScoreUpdateS
private Integer getReminderLevel(String bizType, String projectContraptionId) {
IdxBizJgProjectContraption projectContraption = idxBizJgProjectContraptionService.getById(projectContraptionId);
if (ValidationUtil.isEmpty(projectContraption)) {
return null;
return 0;
}
MatchItemDto matchItemDto = MatchItemDto.builder().build();
matchItemDto.setBizType(bizType);
......@@ -81,6 +81,9 @@ public class ProjectQualityScoreUpdateService extends DefaultQualityScoreUpdateS
* @param projectContraptionIds 装置ids
*/
private void sendDataRefreshMsg(Set<String> projectContraptionIds) {
if (ValidationUtil.isEmpty(projectContraptionIds)) {
return;
}
List<IdxBizJgUseInfo> useInfos = idxBizJgUseInfoService.list(new LambdaQueryWrapper<IdxBizJgUseInfo>()
.in(IdxBizJgUseInfo::getProjectContraptionId, projectContraptionIds)
.select(IdxBizJgUseInfo::getRecord));
......
......@@ -2395,8 +2395,9 @@ public class DataHandlerServiceImpl {
esEquipmentCategoryList.size(), projectContraptionIds.size(), equipRecord.size());
if (!ValidationUtil.isEmpty(equipRecord)) {
equipRecord.remove(null);
equipRecord.removeIf(Objects::isNull);
log.info("发布设备事件,设备数量: {}", equipRecord.size());
if (!ValidationUtil.isEmpty(equipRecord)) {
eventPublisher.publish(new EquipCreateOrEditEvent(
this,
BusinessTypeEnum.JG_NEW_EQUIP.name(),
......@@ -2404,10 +2405,12 @@ public class DataHandlerServiceImpl {
EquipCreateOrEditEvent.EquipType.equip
));
}
}
if (!ValidationUtil.isEmpty(projectContraptionIds)) {
projectContraptionIds.remove(null);
projectContraptionIds.removeIf(Objects::isNull);
log.info("发布装置设备事件,设备数量: {}", projectContraptionIds.size());
if (!ValidationUtil.isEmpty(projectContraptionIds)) {
eventPublisher.publish(new EquipCreateOrEditEvent(
this,
BusinessTypeEnum.JG_NEW_PROJECT.name(),
......@@ -2415,6 +2418,7 @@ public class DataHandlerServiceImpl {
EquipCreateOrEditEvent.EquipType.project
));
}
}
total.addAndGet(esEquipmentCategoryList.size());
log.debug("当前批次处理完成,累计处理{}条设备", total.get());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment