Commit d7732fe7 authored by hezhuozhi's avatar hezhuozhi

处理空指针问题

parent e89aed7a
...@@ -162,8 +162,13 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -162,8 +162,13 @@ public class TDBigScreenAnalyseController extends BaseController {
wrapper.eq(FanHealthIndex::getAnalysisObjType, "场站"); wrapper.eq(FanHealthIndex::getAnalysisObjType, "场站");
wrapper.eq(FanHealthIndex::getGatewayId, stationCode); wrapper.eq(FanHealthIndex::getGatewayId, stationCode);
FanHealthIndex fanHealthIndex = fanHealthIndexMapper.selectOne(wrapper); FanHealthIndex fanHealthIndex = fanHealthIndexMapper.selectOne(wrapper);
stringBigDecimalHashMap.put("value", //预防空指针
BigDecimal.valueOf(fanHealthIndex.getHealthIndex()).setScale(1, BigDecimal.ROUND_HALF_UP)); if(Objects.isNull(fanHealthIndex)){
stringBigDecimalHashMap.put("value", "");
}else {
stringBigDecimalHashMap.put("value",
BigDecimal.valueOf(fanHealthIndex.getHealthIndex()).setScale(1, BigDecimal.ROUND_HALF_UP));
}
} else { } else {
LambdaQueryWrapper<PvHealthIndex> pvwrapper = new LambdaQueryWrapper<PvHealthIndex>(); LambdaQueryWrapper<PvHealthIndex> pvwrapper = new LambdaQueryWrapper<PvHealthIndex>();
pvwrapper.eq(PvHealthIndex::getAnalysisObjType, "场站"); pvwrapper.eq(PvHealthIndex::getAnalysisObjType, "场站");
...@@ -171,8 +176,13 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -171,8 +176,13 @@ public class TDBigScreenAnalyseController extends BaseController {
pvwrapper.orderByDesc(PvHealthIndex::getTs); pvwrapper.orderByDesc(PvHealthIndex::getTs);
pvwrapper.last("limit 1"); pvwrapper.last("limit 1");
PvHealthIndex pvHealthIndex = pvHealthIndexMapper.selectOne(pvwrapper); PvHealthIndex pvHealthIndex = pvHealthIndexMapper.selectOne(pvwrapper);
stringBigDecimalHashMap.put("value", //预防空指针
BigDecimal.valueOf(pvHealthIndex.getHealthIndex()).setScale(1, BigDecimal.ROUND_HALF_UP)); if(Objects.isNull(pvHealthIndex)){
stringBigDecimalHashMap.put("value", "");
}else {
stringBigDecimalHashMap.put("value",
BigDecimal.valueOf(pvHealthIndex.getHealthIndex()).setScale(1, BigDecimal.ROUND_HALF_UP));
}
} }
return ResponseHelper.buildResponse(stringBigDecimalHashMap); return ResponseHelper.buildResponse(stringBigDecimalHashMap);
......
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