fix(smart-cam-car-data): 修复车辆信息统计中的空指针异常

- 在 SmartCamCarDataService 类中,对 carInfo 的 weightEntryCnt 和 weightExitCnt 字段进行空值检查
- 使用 ObjectUtils.defaultIfNull 方法避免空指针异常,确保计数器正确递增
This commit is contained in:
2025-04-24 22:14:00 +08:00
parent 9285a1e6b4
commit 5e6d76604b

View File

@@ -24,6 +24,7 @@ import jakarta.persistence.criteria.Root;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.ConversionService;
@@ -130,10 +131,10 @@ public class SmartCamCarDataService
CompareResult.CarInfo carInfo = carInfoMap.get(weightDatum.getPlateNo());
if (weightDatum.getYcgbTIme() != null) {
carInfo.setWeightEntryCnt(carInfo.getWeightEntryCnt() + 1);
carInfo.setWeightEntryCnt(ObjectUtils.defaultIfNull(carInfo.getWeightEntryCnt(), 0) + 1);
}
if (weightDatum.getEcgbTime() != null) {
carInfo.setWeightExitCnt(carInfo.getWeightExitCnt() + 1);
carInfo.setWeightExitCnt(ObjectUtils.defaultIfNull(carInfo.getWeightExitCnt(), 0) + 1);
}
} else {