修改电能质量评估查询过慢问题
This commit is contained in:
@@ -4,7 +4,10 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
||||
import com.njcn.device.pq.pojo.dto.PollutionLineDTO;
|
||||
import com.njcn.device.pq.pojo.dto.PollutionParamDTO;
|
||||
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
||||
import com.njcn.harmonic.mapper.RStatComassesDMapper;
|
||||
import com.njcn.harmonic.pojo.dto.ComAssessDTO;
|
||||
@@ -13,19 +16,15 @@ import com.njcn.harmonic.pojo.po.day.RStatComassesDPO;
|
||||
import com.njcn.harmonic.pojo.vo.ComAssessVO;
|
||||
import com.njcn.harmonic.service.ComAssessService;
|
||||
import com.njcn.harmonic.utils.HarmonicComAssesUtil;
|
||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.influxdb.impl.InfluxDBResultMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -38,60 +37,69 @@ import java.util.stream.Collectors;
|
||||
public class ComAssessServiceImpl extends ServiceImpl<RStatComassesDMapper, RStatComassesDPO> implements ComAssessService {
|
||||
|
||||
private final GeneralDeviceInfoClient generalDeviceInfoClient;
|
||||
|
||||
private final HarmonicComAssesUtil comAssesUtil;
|
||||
private final LineFeignClient lineFeignClient;
|
||||
|
||||
@Override
|
||||
public List<ComAssessVO> getComAccessData(DeviceInfoParam.BusinessParam comAccessParam) {
|
||||
List<ComAssessVO> comAssessVOList = new ArrayList<>();
|
||||
List<ComAssessDTO> comAssessDTOS = new ArrayList<>();
|
||||
List<String> lineList = new ArrayList<>();
|
||||
//监测点信息
|
||||
List<PollutionLineDTO> lineInfo = new ArrayList<>();
|
||||
//按部门分类的实际运行终端综合信息
|
||||
List<GeneralDeviceDTO> deviceDataList = generalDeviceInfoClient.getPracticalRunDeviceInfo(comAccessParam).getData();
|
||||
deviceDataList.forEach(dept->{
|
||||
lineList.addAll(dept.getLineIndexes());
|
||||
});
|
||||
if (!CollectionUtils.isEmpty(lineList)){
|
||||
PollutionParamDTO paramDTO = new PollutionParamDTO();
|
||||
paramDTO.setLineList(lineList);
|
||||
lineInfo = lineFeignClient.getLineInfo(paramDTO).getData();
|
||||
}
|
||||
Map<String,List<PollutionLineDTO>> map = lineInfo.stream().collect(Collectors.groupingBy(PollutionLineDTO::getSubstationId));
|
||||
//查询所有信息
|
||||
List<PQSComAssesPO> comAccessData = getComAccessData(lineList, comAccessParam.getSearchBeginTime(), comAccessParam.getSearchEndTime());
|
||||
|
||||
//按变电站分类的实际运行终端综合信息
|
||||
List<GeneralDeviceDTO> subDataList = generalDeviceInfoClient.getPracticalRunDeviceInfoAsSubstation(comAccessParam).getData();
|
||||
// List<GeneralDeviceDTO> subDataList = generalDeviceInfoClient.getPracticalRunDeviceInfoAsSubstation(comAccessParam).getData();
|
||||
if (!CollectionUtils.isEmpty(deviceDataList)) {
|
||||
for (GeneralDeviceDTO generalDeviceDTO: deviceDataList){
|
||||
List<String> lineIndexes = generalDeviceDTO.getLineIndexes();
|
||||
deviceDataList.forEach(dept-> {
|
||||
ComAssessVO comAssessVO = new ComAssessVO();
|
||||
comAssessVO.setName(generalDeviceDTO.getName());
|
||||
comAssessVO.setMonitors(lineIndexes.size());
|
||||
if (!CollectionUtils.isEmpty(lineIndexes)) {
|
||||
List<PQSComAssesPO> pqsComAssesPOS = getComAccessData(lineIndexes, comAccessParam.getSearchBeginTime(), comAccessParam.getSearchEndTime());
|
||||
setResults(pqsComAssesPOS,comAssessDTOS);
|
||||
float allComAss = comAssesUtil.getAllComAss(comAssessDTOS);
|
||||
comAssessVO.setName(dept.getName());
|
||||
comAssessVO.setMonitors(dept.getLineIndexes().size());
|
||||
|
||||
List<ComAssessDTO> childrenDTOS = new ArrayList<>();
|
||||
List<ComAssessVO> children=new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(dept.getSubIndexes())) {
|
||||
dept.getSubIndexes().forEach(sub -> {
|
||||
//获取变电站信息
|
||||
List<PollutionLineDTO> l1 = map.get(sub);
|
||||
ComAssessVO child = new ComAssessVO();
|
||||
child.setName(l1.get(0).getSubstation());
|
||||
child.setMonitors(l1.size());
|
||||
//监测点id
|
||||
List<String> lineIds = l1.stream().map(PollutionLineDTO::getId).collect(Collectors.toList());
|
||||
List<PQSComAssesPO> collect = comAccessData.stream().filter(x -> lineIds.contains(x.getLineId())).collect(Collectors.toList());
|
||||
setResults(collect,childrenDTOS);
|
||||
float allComAss = comAssesUtil.getAllComAss(childrenDTOS);
|
||||
String lv = getLevel(allComAss);
|
||||
child.setData(allComAss);
|
||||
child.setLevel(lv);
|
||||
children.add(child);
|
||||
});
|
||||
}
|
||||
List<String> lineIds = dept.getLineIndexes();
|
||||
List<PQSComAssesPO> collect = comAccessData.stream().filter(x -> lineIds.contains(x.getLineId())).collect(Collectors.toList());
|
||||
List<ComAssessDTO> dtos = new ArrayList<>();
|
||||
setResults(collect,dtos);
|
||||
float allComAss = comAssesUtil.getAllComAss(dtos);
|
||||
String lv = getLevel(allComAss);
|
||||
comAssessVO.setData(allComAss);
|
||||
comAssessVO.setLevel(lv);
|
||||
}
|
||||
List<ComAssessVO> children = new ArrayList<>();
|
||||
List<ComAssessDTO> childrenDTOS = new ArrayList<>();
|
||||
|
||||
List<GeneralDeviceDTO> tempList = new ArrayList<>();
|
||||
List<String> subIndexes = generalDeviceDTO.getSubIndexes();
|
||||
if (!CollectionUtils.isEmpty(subIndexes)) {
|
||||
for (String s: subIndexes) {
|
||||
GeneralDeviceDTO subData = subDataList.stream().filter(item -> item.getIndex().equals(s)).collect(Collectors.toList()).get(0);
|
||||
tempList.add(subData);
|
||||
}
|
||||
for (GeneralDeviceDTO generalSubDTO: tempList){
|
||||
List<String> lines = generalSubDTO.getLineIndexes();
|
||||
ComAssessVO assessVO = new ComAssessVO();
|
||||
assessVO.setName(generalSubDTO.getName());
|
||||
assessVO.setMonitors(lines.size());
|
||||
if (!CollectionUtils.isEmpty(lines)) {
|
||||
List<PQSComAssesPO> pqsComAssesPOS = getComAccessData(lines, comAccessParam.getSearchBeginTime(), comAccessParam.getSearchEndTime());
|
||||
setResults(pqsComAssesPOS,childrenDTOS);
|
||||
float allComAss = comAssesUtil.getAllComAss(childrenDTOS);
|
||||
String lv = getLevel(allComAss);
|
||||
assessVO.setData(allComAss);
|
||||
assessVO.setLevel(lv);
|
||||
}
|
||||
children.add(assessVO);
|
||||
comAssessVO.setChildren(children);
|
||||
}
|
||||
}
|
||||
comAssessVOList.add(comAssessVO);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
List<ComAssessVO> list = comAssessVOList.stream().sorted(Comparator.comparing(ComAssessVO::getData).reversed()).collect(Collectors.toList());
|
||||
return list;
|
||||
|
||||
Reference in New Issue
Block a user