Commit d7732fe7 authored by hezhuozhi's avatar hezhuozhi

处理空指针问题

parent e89aed7a
......@@ -162,8 +162,13 @@ public class TDBigScreenAnalyseController extends BaseController {
wrapper.eq(FanHealthIndex::getAnalysisObjType, "场站");
wrapper.eq(FanHealthIndex::getGatewayId, stationCode);
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 {
LambdaQueryWrapper<PvHealthIndex> pvwrapper = new LambdaQueryWrapper<PvHealthIndex>();
pvwrapper.eq(PvHealthIndex::getAnalysisObjType, "场站");
......@@ -171,8 +176,13 @@ public class TDBigScreenAnalyseController extends BaseController {
pvwrapper.orderByDesc(PvHealthIndex::getTs);
pvwrapper.last("limit 1");
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);
......
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