1.趋势图查询添加多线程处理

2.变压器策略调整
This commit is contained in:
2025-11-11 14:33:16 +08:00
parent b7e3bb9796
commit e9ac024f73
3 changed files with 424 additions and 341 deletions

View File

@@ -8,6 +8,7 @@ import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.line.mapper.LineMapper; import com.njcn.device.line.mapper.LineMapper;
import com.njcn.device.pq.enums.LineBaseEnum; import com.njcn.device.pq.enums.LineBaseEnum;
@@ -176,9 +177,9 @@ public class PqsTransformerServiceImpl extends ServiceImpl<PqsTransformerMapper,
.eq(PqsTflgass::getLogicNext, param.getDownNode()) .eq(PqsTflgass::getLogicNext, param.getDownNode())
) )
); );
if(ObjectUtil.isNotNull(tflgass)){ if (ObjectUtil.isNotNull(tflgass)) {
throw new BusinessException(PvDeviceResponseEnum.TRANSFORMER_NAME_REPEAT); throw new BusinessException(PvDeviceResponseEnum.TRANSFORMER_NAME_REPEAT);
}else{ } else {
fly = iPqsTflgassService.save(ass); fly = iPqsTflgassService.save(ass);
} }
@@ -198,6 +199,59 @@ public class PqsTransformerServiceImpl extends ServiceImpl<PqsTransformerMapper,
PqsTflgass one = iPqsTflgassService.getOne(new LambdaQueryWrapper<PqsTflgass>() PqsTflgass one = iPqsTflgassService.getOne(new LambdaQueryWrapper<PqsTflgass>()
.eq(PqsTflgass::getTfIndex, id)); .eq(PqsTflgass::getTfIndex, id));
List<String> arr = new ArrayList<>();
if (Objects.nonNull(one)) {
arr.add(one.getLogicBefore());
arr.add(one.getLogicNext());
}
voltage.put("bind", arr);
//1.获取当前变电站下,所拥有的母线条数
List<TerminalTree> downVoltage = lineMapper.getvoltage(subId, 1);
if(CollUtil.isNotEmpty(arr)) {
downVoltage.forEach(item->{
if(Objects.equals(item.getId(),arr.get(1))){
item.setLevel(LineBaseEnum.SUB_V_LEVEL.getCode());
}
});
}
//获取所有母线层级
List<Line> UpBusList = lineMapper.selectList(new LambdaQueryWrapper<Line>().eq(Line::getLevel, LineBaseEnum.SUB_V_LEVEL.getCode()).eq(Line::getState, DataStateEnum.ENABLE.getCode()).orderByAsc(Line::getSort));
List<TerminalTree> upTreeList = UpBusList.stream().map(it -> {
TerminalTree terminalTree = new TerminalTree();
terminalTree.setId(it.getId());
terminalTree.setName(it.getName());
terminalTree.setPid(it.getPids().split(StrUtil.COMMA)[LineBaseEnum.SUB_LEVEL.getCode()]);
terminalTree.setSort(it.getSort());
if(CollUtil.isNotEmpty(arr)) {
if (it.getId().equals(arr.get(0))) {
terminalTree.setLevel(LineBaseEnum.SUB_V_LEVEL.getCode());
}
}
return terminalTree;
}).collect(Collectors.toList());
//获取母线id
//List<String> ids = downVoltage.stream().map(TerminalTree::getId).collect(Collectors.toList());
List<TerminalTree> upList = TreedChildren(upTreeList, "变压器上节点设备树", subId);
voltage.put("upNode", upList);
List<TerminalTree> downList = TreedChildren(downVoltage, "变压器下节点设备树", subId);
voltage.put("downNode", downList);
return voltage;
}
public Map<String, Object> getGeneratrixOld(String subId, String id) {
Map<String, Object> voltage = new HashMap<>();
//先判断当前,变电站是否已添加了节点
PqsTflgass one = iPqsTflgassService.getOne(new LambdaQueryWrapper<PqsTflgass>()
.eq(PqsTflgass::getTfIndex, id));
//1.获取当前变电站下,所拥有的母线条数 //1.获取当前变电站下,所拥有的母线条数
List<TerminalTree> downVoltage = lineMapper.getvoltage(subId, 1); List<TerminalTree> downVoltage = lineMapper.getvoltage(subId, 1);
//获取母线id //获取母线id
@@ -304,8 +358,8 @@ public class PqsTransformerServiceImpl extends ServiceImpl<PqsTransformerMapper,
//判断是否已经全部绑定 //判断是否已经全部绑定
String chain = chain(pqsTflgasses); String chain = chain(pqsTflgasses);
String chain2 = chain2(pqsTflgasses); String chain2 = chain2(pqsTflgasses);
if (StrUtil.isNotBlank(chain) && not.size() == 0&& pqsTflgasses.size()+1!=ids.size()&&straddleList.size()==0 if (StrUtil.isNotBlank(chain) && not.size() == 0 && pqsTflgasses.size() + 1 != ids.size() && straddleList.size() == 0
|| StrUtil.isNotBlank(chain2) && not.size() == 0&& pqsTflgasses.size()+1!=ids.size()&&straddleList.size()==0) { || StrUtil.isNotBlank(chain2) && not.size() == 0 && pqsTflgasses.size() + 1 != ids.size() && straddleList.size() == 0) {
List<String> logicBefore = pqsTflgasses.stream().map(PqsTflgass::getLogicBefore).collect(Collectors.toList()); List<String> logicBefore = pqsTflgasses.stream().map(PqsTflgass::getLogicBefore).collect(Collectors.toList());
List<String> logicNext = pqsTflgasses.stream().map(PqsTflgass::getLogicNext).collect(Collectors.toList()); List<String> logicNext = pqsTflgasses.stream().map(PqsTflgass::getLogicNext).collect(Collectors.toList());
List<TerminalTree> up = downVoltage.stream().filter(x -> !logicBefore.contains(x.getId())).collect(Collectors.toList()); List<TerminalTree> up = downVoltage.stream().filter(x -> !logicBefore.contains(x.getId())).collect(Collectors.toList());
@@ -335,7 +389,7 @@ public class PqsTransformerServiceImpl extends ServiceImpl<PqsTransformerMapper,
List<String> downIDs = pqsTflgasses.stream().map(PqsTflgass::getLogicNext).collect(Collectors.toList()); List<String> downIDs = pqsTflgasses.stream().map(PqsTflgass::getLogicNext).collect(Collectors.toList());
List<TerminalTree> downVOList = downVoltage.stream().filter(x -> !downIDs.contains(x.getId())).collect(Collectors.toList()); List<TerminalTree> downVOList = downVoltage.stream().filter(x -> !downIDs.contains(x.getId())).collect(Collectors.toList());
if(not.size() ==1){ if (not.size() == 1) {
List<String> logicBefore = pqsTflgasses.stream().map(PqsTflgass::getLogicBefore).collect(Collectors.toList()); List<String> logicBefore = pqsTflgasses.stream().map(PqsTflgass::getLogicBefore).collect(Collectors.toList());
downVOList = downVOList.stream().filter(x -> !logicBefore.contains(x.getId())).collect(Collectors.toList()); downVOList = downVOList.stream().filter(x -> !logicBefore.contains(x.getId())).collect(Collectors.toList());
} }
@@ -371,30 +425,31 @@ public class PqsTransformerServiceImpl extends ServiceImpl<PqsTransformerMapper,
} }
} }
return voltage; return voltage;
} }
@Override
public List<TerminalTree> getTransformerTree() { @Override
public List<TerminalTree> getTransformerTree() {
List<TerminalTree> terminalTrees = this.baseMapper.listTransformer(); List<TerminalTree> terminalTrees = this.baseMapper.listTransformer();
return TreedChildren(terminalTrees, "变压器设备树", null); return TreedChildren(terminalTrees, "变压器设备树", null);
} }
@Override @Override
public List<EntityLogicDTO> getLogic() { public List<EntityLogicDTO> getLogic() {
return pqsTflgassMapper.getLogic(); return pqsTflgassMapper.getLogic();
} }
/** /**
* 获取全部子节点 * 获取全部子节点
* *
* @author cdf * @author cdf
* @date 2021/7/19 * @date 2021/7/19
*/ */
public List<TerminalTree> getChildren(TerminalTree item, List<TerminalTree> all) { public List<TerminalTree> getChildren(TerminalTree item, List<TerminalTree> all) {
return all.stream().filter(allItem -> allItem.getPid().equals(item.getId())).collect(Collectors.toList()); return all.stream().filter(allItem -> allItem.getPid().equals(item.getId())).collect(Collectors.toList());
} }
/** /**
* 初始化设备树 * 初始化设备树
* *
* @param children 子节点 * @param children 子节点
@@ -402,7 +457,7 @@ public class PqsTransformerServiceImpl extends ServiceImpl<PqsTransformerMapper,
* @param subId 不为空则只展示,当前变电站节点的信息,为空则展示所有信息 * @param subId 不为空则只展示,当前变电站节点的信息,为空则展示所有信息
* @return * @return
*/ */
public List<TerminalTree> TreedChildren(List<TerminalTree> children, String name, String subId) { public List<TerminalTree> TreedChildren(List<TerminalTree> children, String name, String subId) {
List<TerminalTree> taiZhang = new ArrayList<>(); List<TerminalTree> taiZhang = new ArrayList<>();
List<TerminalTree> allList = lineMapper.getAllList(); List<TerminalTree> allList = lineMapper.getAllList();
@@ -439,15 +494,15 @@ public class PqsTransformerServiceImpl extends ServiceImpl<PqsTransformerMapper,
taiZhang.add(terminalTree); taiZhang.add(terminalTree);
} }
return taiZhang; return taiZhang;
} }
/** /**
* 查找最顶层节点信息 * 查找最顶层节点信息
* *
* @param pqsTflgasses * @param pqsTflgasses
* @return * @return
*/ */
private static String mostBefore(List<PqsTflgass> pqsTflgasses) { private static String mostBefore(List<PqsTflgass> pqsTflgasses) {
String logicBefore = null; String logicBefore = null;
for (PqsTflgass pqsTflgass : pqsTflgasses) { for (PqsTflgass pqsTflgass : pqsTflgasses) {
//根据获取的的上节点判断是否存在,这上节点是否是尾节点 //根据获取的的上节点判断是否存在,这上节点是否是尾节点
@@ -471,15 +526,15 @@ public class PqsTransformerServiceImpl extends ServiceImpl<PqsTransformerMapper,
} }
} }
return logicBefore; return logicBefore;
} }
/** /**
* 查找最底层节点信息 * 查找最底层节点信息
* *
* @param pqsTflgasses * @param pqsTflgasses
* @return * @return
*/ */
private static String mostNext(List<PqsTflgass> pqsTflgasses) { private static String mostNext(List<PqsTflgass> pqsTflgasses) {
String logicNext = null; String logicNext = null;
for (PqsTflgass pqsTflgass : pqsTflgasses) { for (PqsTflgass pqsTflgass : pqsTflgasses) {
//根据获取的的上节点判断是否存在,这上节点是否是尾节点 //根据获取的的上节点判断是否存在,这上节点是否是尾节点
@@ -503,16 +558,16 @@ public class PqsTransformerServiceImpl extends ServiceImpl<PqsTransformerMapper,
} }
} }
return logicNext; return logicNext;
} }
/** /**
* 判断是否已经成为链行 * 判断是否已经成为链行
* *
* @param pqsTflgasses * @param pqsTflgasses
* @return * @return
*/ */
private static String chain(List<PqsTflgass> pqsTflgasses) { private static String chain(List<PqsTflgass> pqsTflgasses) {
if(pqsTflgasses.size()<2){ if (pqsTflgasses.size() < 2) {
return null; return null;
} }
String logicNext = null; String logicNext = null;
@@ -539,10 +594,10 @@ public class PqsTransformerServiceImpl extends ServiceImpl<PqsTransformerMapper,
} }
} }
return logicNext; return logicNext;
} }
private static String chain2(List<PqsTflgass> pqsTflgasses) { private static String chain2(List<PqsTflgass> pqsTflgasses) {
if(pqsTflgasses.size()<2){ if (pqsTflgasses.size() < 2) {
return null; return null;
} }
String logicBefore = null; String logicBefore = null;
@@ -569,19 +624,19 @@ public class PqsTransformerServiceImpl extends ServiceImpl<PqsTransformerMapper,
} }
} }
return logicBefore; return logicBefore;
} }
/** /**
* 根据母线获取信息 * 根据母线获取信息
* *
* @param id * @param id
* @return * @return
*/ */
public TerminalTree addTree(String id) { public TerminalTree addTree(String id) {
List<TerminalTree> getvoltage = lineMapper.getvoltage(id, 2); List<TerminalTree> getvoltage = lineMapper.getvoltage(id, 2);
getvoltage.get(0).setLevel(5); getvoltage.get(0).setLevel(5);
return getvoltage.get(0); return getvoltage.get(0);
} }

View File

@@ -61,6 +61,7 @@ public class HistoryResultController extends BaseController {
public HttpResult<List<HistoryDataResultVO>> getHistoryResult(@RequestBody @Validated HistoryParam historyParam) { public HttpResult<List<HistoryDataResultVO>> getHistoryResult(@RequestBody @Validated HistoryParam historyParam) {
String methodDescribe = getMethodDescribe("getHistoryResult"); String methodDescribe = getMethodDescribe("getHistoryResult");
List<HistoryDataResultVO> list; List<HistoryDataResultVO> list;
//针对河北现场特殊处理pmswifi_开头监测点为无线装置需要查询influxdb,其他测点查询oracle
if (HistoryDataSource == 1 && !historyParam.getLineId()[0].contains("pmswifi_")) { if (HistoryDataSource == 1 && !historyParam.getLineId()[0].contains("pmswifi_")) {
list = oracleResultService.getHistoryResult(historyParam); list = oracleResultService.getHistoryResult(historyParam);
} else { } else {

View File

@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.TimeInterval;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.common.pojo.constant.BizParamConstant; import com.njcn.common.pojo.constant.BizParamConstant;
@@ -54,6 +55,9 @@ import lombok.AllArgsConstructor;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@@ -62,8 +66,11 @@ import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@@ -102,16 +109,24 @@ public class HistoryResultServiceImpl implements HistoryResultService {
private final RStatDataVDMapper dataVDMapper; private final RStatDataVDMapper dataVDMapper;
private final RStatDataHarmRateVDMapper dataHarmRateVDMapper; private final RStatDataHarmRateVDMapper dataHarmRateVDMapper;
private final RStatDataHarmRateIDMapper dataHarmRateIDMapper; private final RStatDataHarmRateIDMapper dataHarmRateIDMapper;
@Autowired
@Qualifier("asyncExecutor")
private Executor asyncExecutor;
@Override @Override
public List<HistoryDataResultVO> getHistoryResult(HistoryParam historyParam) { public List<HistoryDataResultVO> getHistoryResult(HistoryParam historyParam) {
System.out.println("begin============================="+ LocalDateTime.now());
TimeInterval timeInterval = new TimeInterval();
List<HistoryDataResultVO> historyDataResultVOList = new ArrayList<>(); List<HistoryDataResultVO> historyDataResultVOList = new ArrayList<>();
//获取监测点 //获取监测点
String[] points = historyParam.getLineId(); String[] points = historyParam.getLineId();
Integer number = 0;
for (int i = 0; i < points.length; i++) { for (int i = 0; i < points.length; i++) {
HistoryDataResultVO historyDataResultVO; long a = timeInterval.intervalMs();
List<EventDetail> eventDetailList = eventDetailFeignClient.getEventDetailData(points[i], historyParam.getSearchBeginTime(), historyParam.getSearchEndTime()).getData(); List<EventDetail> eventDetailList = eventDetailFeignClient.getEventDetailData(points[i], historyParam.getSearchBeginTime(), historyParam.getSearchEndTime()).getData();
List<EventDetailVO> eventDetailVOList = new ArrayList<>(); List<EventDetailVO> eventDetailVOList = new ArrayList<>();
if (!eventDetailList.isEmpty()) { if (!eventDetailList.isEmpty()) {
for (EventDetail eventdetail : eventDetailList) { for (EventDetail eventdetail : eventDetailList) {
@@ -122,9 +137,21 @@ public class HistoryResultServiceImpl implements HistoryResultService {
eventDetailVOList.add(eventDetailVO); eventDetailVOList.add(eventDetailVO);
} }
} }
//获取监测点的数据单位kV还是v kW还是w
PqsDeviceUnit pqsDeviceUnit = commTerminalGeneralClient.lineUnitDetail(points[i]).getData();
//获取监测点信息
LineDevGetDTO lineDetailDataVO = commTerminalGeneralClient.getMonitorDetail(points[i]).getData();
//获取限值
Overlimit overlimit = commTerminalGeneralClient.getOverLimitData(points[i]).getData();
long b = timeInterval.intervalMs();
System.out.println("feign调用"+(b-a));
//获取指标 //获取指标
String[] contions = historyParam.getCondition(); String[] contions = historyParam.getCondition();
List<CompletableFuture<Void>> futures = new ArrayList<>();
for (int j = 0; j < contions.length; j++) { for (int j = 0; j < contions.length; j++) {
Integer number = 0;
if ("40".equals(contions[j]) || "41".equals(contions[j]) || "42".equals(contions[j]) || "43".equals(contions[j]) if ("40".equals(contions[j]) || "41".equals(contions[j]) || "42".equals(contions[j]) || "43".equals(contions[j])
|| "44".equals(contions[j]) || "45".equals(contions[j]) || "50".equals(contions[j]) || "51".equals(contions[j]) || "44".equals(contions[j]) || "45".equals(contions[j]) || "50".equals(contions[j]) || "51".equals(contions[j])
|| "52".equals(contions[j])) { || "52".equals(contions[j])) {
@@ -133,20 +160,33 @@ public class HistoryResultServiceImpl implements HistoryResultService {
if ("46".equals(contions[j]) || "47".equals(contions[j]) || "48".equals(contions[j]) || "49".equals(contions[j])) { if ("46".equals(contions[j]) || "47".equals(contions[j]) || "48".equals(contions[j]) || "49".equals(contions[j])) {
number = historyParam.getInHarmonic(); number = historyParam.getInHarmonic();
} }
historyDataResultVO = getCondition(historyParam.getSearchBeginTime(), historyParam.getSearchEndTime(), points[i], contions[j], number, historyParam.getValueType(), historyParam.getPtType()); //每个指标独立一个线程去查库,针对现场网络环境比较复杂的场景,正常场景看不太出来效果
/* if (points.length == 1 && j == 0) { asyncMethodWithCustomExecutor(contions[j],number,historyParam,eventDetailVOList,points[i],pqsDeviceUnit,lineDetailDataVO,overlimit,historyDataResultVOList,futures);
historyDataResultVO.setEventDetail(eventDetailVOList); }
} else if (points.length > 1) { // 等待所有任务完成
historyDataResultVO.setEventDetail(eventDetailVOList); CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
}*/
historyDataResultVO.setEventDetail(eventDetailVOList);
historyDataResultVOList.add(historyDataResultVO);
} }
}
System.out.println("end============================="+LocalDateTime.now());
System.out.println("共计耗时:"+timeInterval.intervalMs()/1000.0);
return historyDataResultVOList; return historyDataResultVOList;
} }
//处理指标查询
public void asyncMethodWithCustomExecutor(String target,Integer number,HistoryParam historyParam,List<EventDetailVO> eventDetailVOList,String point,PqsDeviceUnit pqsDeviceUnit,LineDevGetDTO lineDetailDataVO,Overlimit overlimit,List<HistoryDataResultVO> historyDataResultVOList,List<CompletableFuture<Void>> futures) {
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
HistoryDataResultVO historyDataResultVO = getCondition(historyParam.getSearchBeginTime(), historyParam.getSearchEndTime(), point, target, number, historyParam.getValueType(), historyParam.getPtType(),pqsDeviceUnit,lineDetailDataVO,overlimit);
historyDataResultVO.setEventDetail(eventDetailVOList);
synchronized (historyDataResultVOList) { // 同步块保证线程安全
historyDataResultVOList.add(historyDataResultVO);
}
System.out.println("执行异步任务,线程名:" + Thread.currentThread().getName());
}, asyncExecutor);
futures.add(future);
}
@Override @Override
public List<HistoryDataResultVO> getHistoryLineData(NormHistoryParam normHistoryParam) { public List<HistoryDataResultVO> getHistoryLineData(NormHistoryParam normHistoryParam) {
List<HistoryDataResultVO> historyDataResultVOList = new ArrayList<>(); List<HistoryDataResultVO> historyDataResultVOList = new ArrayList<>();
@@ -160,9 +200,9 @@ public class HistoryResultServiceImpl implements HistoryResultService {
* 查询稳态数据分析 * 查询稳态数据分析
*/ */
@SneakyThrows @SneakyThrows
private HistoryDataResultVO getCondition(String startTime, String endTime, String lineId, String contion, Integer number, Integer valueType, Integer ptType) { public HistoryDataResultVO getCondition(String startTime, String endTime, String lineId, String contion, Integer number, Integer valueType, Integer ptType,PqsDeviceUnit pqsDeviceUnit,LineDevGetDTO lineDetailDataVO,Overlimit overlimit) {
HistoryDataResultVO historyDataResultVO = new HistoryDataResultVO(); HistoryDataResultVO historyDataResultVO = new HistoryDataResultVO();
QueryResultLimitVO queryResultLimitVO = getQueryResult(startTime, endTime, lineId, contion, number, valueType, ptType); QueryResultLimitVO queryResultLimitVO = getQueryResult(startTime, endTime, lineId, contion, number, valueType, ptType,pqsDeviceUnit,lineDetailDataVO,overlimit);
List<HarmonicHistoryData> harmonicHistoryDataList = queryResultLimitVO.getHarmonicHistoryDataList(); List<HarmonicHistoryData> harmonicHistoryDataList = queryResultLimitVO.getHarmonicHistoryDataList();
BeanUtil.copyProperties(queryResultLimitVO, historyDataResultVO); BeanUtil.copyProperties(queryResultLimitVO, historyDataResultVO);
//时间轴 //时间轴
@@ -207,7 +247,6 @@ public class HistoryResultServiceImpl implements HistoryResultService {
} else { } else {
//按时间分组 //按时间分组
Map<Instant, List<HarmonicHistoryData>> map = harmonicHistoryDataList.stream().collect(Collectors.groupingBy(HarmonicHistoryData::getTime, TreeMap::new, Collectors.toList())); Map<Instant, List<HarmonicHistoryData>> map = harmonicHistoryDataList.stream().collect(Collectors.groupingBy(HarmonicHistoryData::getTime, TreeMap::new, Collectors.toList()));
Float maxI = null; Float maxI = null;
Float minI = null; Float minI = null;
for (Map.Entry<Instant, List<HarmonicHistoryData>> entry : map.entrySet()) { for (Map.Entry<Instant, List<HarmonicHistoryData>> entry : map.entrySet()) {
@@ -241,13 +280,10 @@ public class HistoryResultServiceImpl implements HistoryResultService {
objects[3] = c; objects[3] = c;
maxI = max(maxI, c.floatValue()); maxI = max(maxI, c.floatValue());
minI = min(minI, c.floatValue()); minI = min(minI, c.floatValue());
} }
} }
List<Object> list = new ArrayList<>(Arrays.asList(objects)); List<Object> list = new ArrayList<>(Arrays.asList(objects));
objectListData.add(list); objectListData.add(list);
} }
historyDataResultVO.setMaxValue(maxI); historyDataResultVO.setMaxValue(maxI);
@@ -256,7 +292,6 @@ public class HistoryResultServiceImpl implements HistoryResultService {
historyDataResultVO.setLowerLimit(queryResultLimitVO.getLowerLimit()); historyDataResultVO.setLowerLimit(queryResultLimitVO.getLowerLimit());
historyDataResultVO.setValue(objectListData); historyDataResultVO.setValue(objectListData);
} }
} else { } else {
return historyDataResultVO; return historyDataResultVO;
} }
@@ -284,19 +319,12 @@ public class HistoryResultServiceImpl implements HistoryResultService {
return ding; return ding;
} }
private QueryResultLimitVO getQueryResult(String startTime, String endTime, String lineId, String contion, Integer number, Integer valueType, Integer ptType) { private QueryResultLimitVO getQueryResult(String startTime, String endTime, String lineId, String contion, Integer number, Integer valueType, Integer ptType,PqsDeviceUnit pqsDeviceUnit,LineDevGetDTO lineDetailDataVO,Overlimit overlimit) {
PqsDeviceUnit pqsDeviceUnit = commTerminalGeneralClient.lineUnitDetail(lineId).getData();
QueryResultLimitVO queryResultLimitVO = new QueryResultLimitVO(); QueryResultLimitVO queryResultLimitVO = new QueryResultLimitVO();
if (!lineId.isEmpty()) { if (!lineId.isEmpty()) {
Float topLimit = 0f; Float topLimit = 0f;
Float lowerLimit = 0f; Float lowerLimit = 0f;
//获取监测点信息
LineDevGetDTO lineDetailDataVO = commTerminalGeneralClient.getMonitorDetail(lineId).getData();
//获取限值
Overlimit overlimit = commTerminalGeneralClient.getOverLimitData(lineId).getData();
if (Objects.isNull(overlimit)) { if (Objects.isNull(overlimit)) {
//对配网没有限值的统一处理 //对配网没有限值的统一处理
DictData dictData = dicDataFeignClient.getDicDataById(lineDetailDataVO.getVoltageLevel()).getData(); DictData dictData = dicDataFeignClient.getDicDataById(lineDetailDataVO.getVoltageLevel()).getData();
@@ -305,7 +333,6 @@ public class HistoryResultServiceImpl implements HistoryResultService {
overlimit = COverlimitUtil.globalAssemble(voltageLevel, 10f, 10f, shortVal, 1, 1); overlimit = COverlimitUtil.globalAssemble(voltageLevel, 10f, 10f, shortVal, 1, 1);
} }
//组装sql语句 //组装sql语句
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(InfluxDBTableConstant.TIME + " >= '").append(startTime).append(InfluxDBTableConstant.START_TIME).append("' and ").append(InfluxDBTableConstant.TIME).append(" <= '").append(endTime).append(InfluxDBTableConstant.END_TIME).append("' and ("); stringBuilder.append(InfluxDBTableConstant.TIME + " >= '").append(startTime).append(InfluxDBTableConstant.START_TIME).append("' and ").append(InfluxDBTableConstant.TIME).append(" <= '").append(endTime).append(InfluxDBTableConstant.END_TIME).append("' and (");