mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-07-26 07:28:58 +08:00
fix(smart-cam-car-data): 修复车辆信息统计中的空指针异常
- 在 SmartCamCarDataService 类中,对 carInfo 的 weightEntryCnt 和 weightExitCnt 字段进行空值检查 - 使用 ObjectUtils.defaultIfNull 方法避免空指针异常,确保计数器正确递增
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user