fix(service): 修复电压等级获取和服务调用中的空指针异常

- 在CsEventUserPOServiceImpl中添加空值检查避免map.get返回null时的异常
- 移除CsGroupController中多余的空行
- 在CsGroupServiceImpl中引入PqGovernPlanFeignClient并重构敏感用户趋势数据查询逻辑
- 修改系统服务中EPD PQD树形结构构建的名称设置逻辑
- 更新PqGovernPlan服务接口增加治理类型参数支持
- 优化LineTargetServiceImpl中目标标签解析逻辑
- 在PqGovernPlanFeignClient中添加根据ID查询治理方案的接口方法
- 为PqGovernPlanClientFallbackFactory添加getById方法的降级处理
- 修复PqSensitiveUserServiceImpl中用户设备树构建的数据获取逻辑
- 重构RStatLimitRateDServiceImpl中限值统计结果分页和数据显示逻辑
This commit is contained in:
xy
2026-06-22 19:31:09 +08:00
parent de60b53dd1
commit 57d5b159ef
12 changed files with 100 additions and 97 deletions

View File

@@ -9,6 +9,7 @@ import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@@ -27,4 +28,8 @@ public interface PqGovernPlanFeignClient {
@ApiOperation("清空治理前后监测点数据")
HttpResult<List<PqGovernPlan>> getListByMonitorPoint(@RequestBody List<String> ids);
@GetMapping("/getById")
@ApiOperation("根据ID查询治理方案")
HttpResult<PqGovernPlan> getById(@RequestParam("id") String id);
}

View File

@@ -37,6 +37,12 @@ public class PqGovernPlanClientFallbackFactory implements FallbackFactory<PqGove
log.error("{}异常,降级处理,异常为:{}","清空治理前后监测点数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<PqGovernPlan> getById(String id) {
log.error("{}异常,降级处理,异常为:{}","根据ID查询治理方案异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -109,7 +109,7 @@ public class PqGovernPlanController extends BaseController {
@ApiImplicitParam(name = "ids", value = "监测点id集合", required = true)
public HttpResult<List<PqGovernPlan>> getListByMonitorPoint(@RequestBody List<String> ids) {
String methodDescribe = getMethodDescribe("clearGovernPoints");
List<PqGovernPlan> result = pqGovernPlanService.getListByMonitorPoint(ids);
List<PqGovernPlan> result = pqGovernPlanService.getListByMonitorPoint(ids,null);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}

View File

@@ -67,6 +67,6 @@ public interface IPqGovernPlanService extends IService<PqGovernPlan> {
* @param ids 监测点id集合
* @return 治理方案列表
*/
List<PqGovernPlan> getListByMonitorPoint(List<String> ids);
List<PqGovernPlan> getListByMonitorPoint(List<String> ids, String governType);
}

View File

@@ -457,7 +457,9 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
temp.setEngineeringid(devDetail.getEngineeringid());
temp.setEngineeringName(devDetail.getEngineeringName());
if (ObjectUtil.isNotNull(temp.getLineId())) {
temp.setLineVoltage(map.get(temp.getLineId()).getVolGrade());
if (!Objects.isNull(map.get(temp.getLineId()))) {
temp.setLineVoltage(map.get(temp.getLineId()).getVolGrade());
}
}
EleEpdPqd ele = epdFeignClient.findByName(temp.getTag()).getData();
if (Objects.isNull(ele)) {

View File

@@ -190,22 +190,9 @@ public class LineTargetServiceImpl implements ILineTargetService {
String targetTag = null;
String phasic = null;
String dataType = null;
// String[] tmepUidName = temp.split(" / ");
// if(tmepUidName.length==2){
// targetTag = tmepUidName[0];
// phasic = "T";
// dataType = tmepUidName[1];
// }else if (tmepUidName.length==3){
// targetTag = tmepUidName[0];
// phasic = tmepUidName[1];
// dataType = tmepUidName[2];
// }
if (CollectionUtils.isEmpty(item.getUid()) || org.springframework.util.StringUtils.isEmpty(item.getLineId())){
throw new BusinessException(CsSystemResponseEnum.BIND_TARGET_ERROR);
}
// List<String> tempUid = (List<String>) item.getUid().get(i);
if (item.getUid().get(i) instanceof List) {
List<?> rawList = (List<?>) item.getUid().get(i);
List<String> tempUid = rawList.stream()
@@ -214,8 +201,8 @@ public class LineTargetServiceImpl implements ILineTargetService {
.collect(Collectors.toList());
String s = tempUid.get(tempUid.size() - 1);
String[] tempTable = s.replace("$", "").split("#");
result.add(getLineRtDataNew(item.getId(),item.getLineId(),tempTable[3],tempTable[0],Objects.equals(tempTable[1],"T")?"T":tempTable[1],tempTable[2],temp,item.getUnit().get(i)));
// result.add(getLineRtData(item.getId(),item.getLineId(),tempUid.get(3),tempUid.get(0),tempUid.get(1),tempUid.get(2).toUpperCase(),temp,"%"));
phasic = Objects.equals(tempTable[1],"M") ? "T" : tempTable[1];
result.add(getLineRtDataNew(item.getId(),item.getLineId(),tempTable[3],tempTable[0],phasic,tempTable[2],temp,item.getUnit().get(i)));
}
}
}

View File

@@ -21,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -130,11 +131,14 @@ public class PqGovernPlanServiceImpl extends ServiceImpl<PqGovernPlanMapper, PqG
}
@Override
public List<PqGovernPlan> getListByMonitorPoint(List<String> ids) {
public List<PqGovernPlan> getListByMonitorPoint(List<String> ids, String type) {
LambdaQueryWrapper<PqGovernPlan> wrapper = new LambdaQueryWrapper<>();
wrapper.and(w -> w.in(PqGovernPlan::getGovernBefore, ids)
.or()
.in(PqGovernPlan::getGovernAfter, ids));
if (!Objects.isNull(type)) {
wrapper.eq(PqGovernPlan::getGovernType, type);
}
return this.list(wrapper);
}

View File

@@ -82,7 +82,7 @@ public class PqSensitiveUserServiceImpl extends ServiceImpl<PqSensitiveUserMappe
return result;
}
//根据监测点获取用户
List<PqGovernPlan> governPlans = pqGovernPlanService.getListByMonitorPoint(lineIds);
List<PqGovernPlan> governPlans = pqGovernPlanService.getListByMonitorPoint(lineIds,null);
if (CollUtil.isEmpty(governPlans)) {
return result;
}
@@ -115,7 +115,7 @@ public class PqSensitiveUserServiceImpl extends ServiceImpl<PqSensitiveUserMappe
return result;
}
//根据监测点获取用户
List<PqGovernPlan> governPlans = pqGovernPlanService.getListByMonitorPoint(lineIds);
List<PqGovernPlan> governPlans = pqGovernPlanService.getListByMonitorPoint(lineIds,null);
if (CollUtil.isEmpty(governPlans)) {
return result;
}
@@ -146,31 +146,33 @@ public class PqSensitiveUserServiceImpl extends ServiceImpl<PqSensitiveUserMappe
@Override
public Map<String, List<PqGovernPlan>> getUserDevTree(String type) {
Map<String, List<PqGovernPlan>> map = new LinkedHashMap<>();
List<PqSensitiveUser> userList = this.list();
if (CollUtil.isNotEmpty(userList)) {
String governType = Objects.equals(type, "apf") ? "harmonic" : "event";
LambdaQueryWrapper<PqGovernPlan> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(PqGovernPlan::getGovernType, governType)
.orderByAsc(PqGovernPlan::getSort);
List<PqGovernPlan> planList = pqGovernPlanService.list(wrapper);
Map<String, List<PqGovernPlan>> planMap = new LinkedHashMap<>();
if (CollUtil.isNotEmpty(planList)) {
planMap = planList.stream()
.collect(Collectors.groupingBy(
PqGovernPlan::getPid,
LinkedHashMap::new,
Collectors.toList()
));
}
Map<String, List<PqGovernPlan>> finalPlanMap = planMap;
userList.forEach(item -> {
map.put(item.getName(), finalPlanMap.get(item.getId()));
});
//根据用户获取监测点id
List<String> lineIds = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData();
if (CollUtil.isEmpty(lineIds)) {
return map;
}
//根据监测点id获取治理用户
String governType = Objects.equals(type, "apf") ? "harmonic" : "event";
List<PqGovernPlan> governPlans = pqGovernPlanService.getListByMonitorPoint(lineIds,governType);
if (CollUtil.isEmpty(governPlans)) {
return map;
}
List<PqSensitiveUser> userList = this.list();
if (CollUtil.isEmpty(userList)) {
return map;
}
Map<String, List<PqGovernPlan>> planMap = governPlans.stream().collect(Collectors.groupingBy(
PqGovernPlan::getPid,
LinkedHashMap::new,
Collectors.toList()
));
Map<String, PqSensitiveUser> userMap = userList.stream().collect(Collectors.toMap(PqSensitiveUser::getId, item -> item));
planMap.forEach((k,v)->{
map.put(userMap.get(k).getName(), v);
});
return map;
}
private void checkParam(PqSensitiveUserParam param,boolean update){
DictData data = dicDataFeignClient.getDicDataById(param.getLoadType()).getData();
if(Objects.isNull(data)){

View File

@@ -177,26 +177,23 @@ public class RStatLimitRateDServiceImpl extends ServiceImpl<RStatLimitRateDMappe
if (CollUtil.isEmpty(keywordsLineIds)) {
return result;
}
// 根据监测点Id分组再分页
Page<RStatLimitRateDPO> ratePage = this.page(new Page<RStatLimitRateDPO>(param.getPageNum(), param.getPageSize()), new LambdaQueryWrapper<RStatLimitRateDPO>()
.eq(RStatLimitRateDPO::getPhasicType, "T")
.ge(StrUtil.isNotBlank(param.getSearchBeginTime()), RStatLimitRateDPO::getTime, param.getSearchBeginTime())
.le(StrUtil.isNotBlank(param.getSearchEndTime()), RStatLimitRateDPO::getTime, param.getSearchEndTime())
.in(RStatLimitRateDPO::getLineId, keywordsLineIds)
.groupBy(RStatLimitRateDPO::getLineId)
.select(RStatLimitRateDPO::getLineId)
);
BeanUtil.copyProperties(ratePage, result);
List<RStatLimitRateDPO> records = ratePage.getRecords();
if (CollUtil.isEmpty(records)) {
// 监测点总数手动分页,确保没有数据的监测点也能展示
result.setTotal(keywordsLineIds.size());
int fromIndex = (param.getPageNum() - 1) * param.getPageSize();
if (fromIndex >= keywordsLineIds.size()) {
return result;
}
int toIndex = Math.min(fromIndex + param.getPageSize(), keywordsLineIds.size());
List<String> pageLineIds = new ArrayList<>(keywordsLineIds.subList(fromIndex, toIndex));
List<MainLineVO> list = new ArrayList<>();
MainLineVO mainLineVO;
List<DevDetailDTO> devDetailDTOList = csCommTerminalFeignClient.getLedgerByLineId(keywordsLineIds).getData();
Map<String, DevDetailDTO> devDetailDTOMap = devDetailDTOList.stream().collect(Collectors.toMap(DevDetailDTO::getLineId, item -> item));
List<DevDetailDTO> devDetailDTOList = csCommTerminalFeignClient.getLedgerByLineId(pageLineIds).getData();
Map<String, DevDetailDTO> devDetailDTOMap = CollUtil.isEmpty(devDetailDTOList)
? Collections.emptyMap()
: devDetailDTOList.stream().collect(Collectors.toMap(DevDetailDTO::getLineId, item -> item));
//根据监测点获取治理方案
List<PqGovernPlan> pqGovernPlans = pqGovernPlanFeignClient.getListByMonitorPoint(keywordsLineIds).getData();
List<PqGovernPlan> pqGovernPlans = pqGovernPlanFeignClient.getListByMonitorPoint(pageLineIds).getData();
Map<String, PqGovernPlan> pqGovernPlanMap1 = Collections.emptyMap();
Map<String, PqGovernPlan> pqGovernPlanMap2 = Collections.emptyMap();
if (CollUtil.isNotEmpty(pqGovernPlans)) {
@@ -204,14 +201,23 @@ public class RStatLimitRateDServiceImpl extends ServiceImpl<RStatLimitRateDMappe
pqGovernPlanMap2 = pqGovernPlans.stream().collect(Collectors.toMap(PqGovernPlan::getGovernAfter, item -> item));
}
for (RStatLimitRateDPO record : records) {
String lineId = record.getLineId();
for (String lineId : pageLineIds) {
mainLineVO = new MainLineVO();
mainLineVO.setLineId(lineId);
mainLineVO.setEngineeringName(devDetailDTOMap.get(lineId).getEngineeringName());
mainLineVO.setProjectName(devDetailDTOMap.get(lineId).getProjectName());
mainLineVO.setDevName(devDetailDTOMap.get(lineId).getEquipmentName());
mainLineVO.setLineName(devDetailDTOMap.get(lineId).getLineName());
DevDetailDTO devDetailDTO = devDetailDTOMap.get(lineId);
if (devDetailDTO != null) {
mainLineVO.setEngineeringName(devDetailDTO.getEngineeringName());
mainLineVO.setProjectName(devDetailDTO.getProjectName());
mainLineVO.setDevName(devDetailDTO.getEquipmentName());
mainLineVO.setLineName(devDetailDTO.getLineName());
mainLineVO.setObjType(devDetailDTO.getObjType());
if (ObjectUtil.isNotNull(devDetailDTO.getObjType())) {
DictData dictData = dicDataFeignClient.getDicDataById(devDetailDTO.getObjType()).getData();
if (dictData != null) {
mainLineVO.setObjType(dictData.getName());
}
}
}
PqGovernPlan plan1 = pqGovernPlanMap1.get(lineId);
if (!Objects.isNull(plan1)) {
mainLineVO.setGovern(Objects.isNull(plan1.getGovernMethod()) ? "未治理" : plan1.getGovernMethod());
@@ -220,13 +226,6 @@ public class RStatLimitRateDServiceImpl extends ServiceImpl<RStatLimitRateDMappe
if (!Objects.isNull(plan2)) {
mainLineVO.setGovern(Objects.isNull(plan2.getGovernMethod()) ? "未治理" : plan2.getGovernMethod());
}
mainLineVO.setObjType(devDetailDTOMap.get(lineId).getObjType());
if (ObjectUtil.isNotNull(devDetailDTOMap.get(lineId).getObjType())) {
DictData dictData = dicDataFeignClient.getDicDataById(devDetailDTOMap.get(lineId).getObjType()).getData();
if (dictData != null) {
mainLineVO.setObjType(dictData.getName());
}
}
MainLineStatLimitRateDetailsQueryParam detailsQueryParam = new MainLineStatLimitRateDetailsQueryParam();
detailsQueryParam.setLineId(lineId);
detailsQueryParam.setSearchBeginTime(param.getSearchBeginTime());
@@ -252,12 +251,13 @@ public class RStatLimitRateDServiceImpl extends ServiceImpl<RStatLimitRateDMappe
}
}
}
if (CollUtil.isEmpty(problemList)) {
if (CollUtil.isEmpty(detailsList)) {
mainLineVO.setProblems("暂无数据");
} else if (CollUtil.isEmpty(problemList)) {
mainLineVO.setProblems("所有指标都合格");
} else {
mainLineVO.setProblems(CollUtil.join(problemList, ""));
}
list.add(mainLineVO);
}
result.setRecords(list);