zbj//1.大屏中间所有数据综合评估

This commit is contained in:
zhangbaojian
2023-04-07 15:28:59 +08:00
parent 76b999a1cb
commit 5d6bc4678f
5 changed files with 198 additions and 8 deletions

View File

@@ -1,5 +1,7 @@
package com.njcn.event.service.majornetwork.Impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import com.njcn.common.pojo.dto.SimpleDTO;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
@@ -8,6 +10,9 @@ import com.njcn.device.pq.pojo.param.MonitoringPointScaleParam;
import com.njcn.device.pq.pojo.vo.*;
import com.njcn.event.mapper.majornetwork.LargeScreenMapper;
import com.njcn.event.service.majornetwork.LargeScreenService;
import com.njcn.harmonic.pojo.dto.ComAssessDTO;
import com.njcn.harmonic.pojo.po.PQSComAssesPO;
import com.njcn.harmonic.utils.HarmonicComAssesUtil;
import com.njcn.system.pojo.enums.StatisticsEnum;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -15,7 +20,9 @@ import org.apache.commons.collections.map.HashedMap;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.NumberFormat;
import java.time.LocalDate;
@@ -37,6 +44,8 @@ public class LargeScreenServiceImpl implements LargeScreenService {
private final LargeScreenMapper largeScreenMapper;
private final HarmonicComAssesUtil comAssesUtil;
/**
* 暂降事件区域
*/
@@ -308,14 +317,33 @@ public class LargeScreenServiceImpl implements LargeScreenService {
float f = 0.0f;
for (AllDataVO allDataVO : result) {
for (Map<String, Object> map : homeostasisArea) {
if (Objects.equals(map.get("id"),allDataVO.getIndex())){
f=Float.parseFloat(map.get("avg").toString());
allDataVO.setSteadyLoad(String.valueOf((1-f)*100));
}
if (Objects.equals(map.get("id"), allDataVO.getIndex())) {
f = Float.parseFloat(map.get("avg").toString());
allDataVO.setSteadyLoad(String.valueOf((1 - f) * 100));
}
}
}
List<ComAssessDTO> comAssessDTOS = new ArrayList<>();
for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {
if (!CollectionUtils.isEmpty(generalDeviceDTO.getLineIndexes())) {
List<PQSComAssesPO> pqsComAssesPOS = getComAccessData(generalDeviceDTO.getLineIndexes(), largeScreenParam.getSearchBeginTime(), largeScreenParam.getSearchEndTime());
setResults(pqsComAssesPOS, comAssessDTOS);
float allComAss = comAssesUtil.getAllComAss(comAssessDTOS);
/*String lv = getLevel(allComAss);*/
/*comAssessVO.setData(allComAss);*/
for (AllDataVO allDataVO : result) {
if (Objects.equals(generalDeviceDTO.getIndex(), allDataVO.getIndex())) {
allDataVO.setData(String.valueOf(allComAss));
}
}
}
/*comAssessVO.setLevel(lv);*/
}
for (AllDataVO allDataVO : result) {
if (Objects.isNull(allDataVO.getData())){
allDataVO.setData("-1");
}
}
//todo 该接口部分功能未完成 1.综合评估
return result;
}
@@ -395,7 +423,7 @@ public class LargeScreenServiceImpl implements LargeScreenService {
nf.setMaximumFractionDigits(2);//保留两位小数,即四舍五入到小数点后两位
nf.setRoundingMode(RoundingMode.HALF_UP);//设置四舍五入模式为四舍五入
float v = Float.parseFloat(nf.format(value));
return String.valueOf(v*100);
return String.valueOf(v * 100);
}
/**
@@ -421,4 +449,90 @@ public class LargeScreenServiceImpl implements LargeScreenService {
return largeScreenMapper.getMiddleLimitRate(lineIds, largeScreenParam.getSearchBeginTime(), largeScreenParam.getSearchEndTime());
}
}
//设置保留四位小数
private void setResults(List<PQSComAssesPO> pqsComAssesPOS, List<ComAssessDTO> comAssessDTOS) {
for (int i = 0; i < pqsComAssesPOS.size(); i++) {
float v1 = new BigDecimal(pqsComAssesPOS.get(i).getVuDev1()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
ComAssessDTO comAssessDTO = new ComAssessDTO();
comAssessDTO.setVuDev1(v1);
float v2 = new BigDecimal(pqsComAssesPOS.get(i).getVuDev2()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setVuDev2(v2);
float v3 = new BigDecimal(pqsComAssesPOS.get(i).getVuDev3()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setVuDev3(v3);
float v4 = new BigDecimal(pqsComAssesPOS.get(i).getVuDev4()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setVuDev4(v4);
float v5 = new BigDecimal(pqsComAssesPOS.get(i).getVuDev5()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setVuDev5(v5);
float f1 = new BigDecimal(pqsComAssesPOS.get(i).getFreqDev1()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setFreqDev1(f1);
float f2 = new BigDecimal(pqsComAssesPOS.get(i).getFreqDev2()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setFreqDev2(f2);
float f3 = new BigDecimal(pqsComAssesPOS.get(i).getFreqDev3()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setFreqDev3(f3);
float f4 = new BigDecimal(pqsComAssesPOS.get(i).getFreqDev4()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setFreqDev4(f4);
float f5 = new BigDecimal(pqsComAssesPOS.get(i).getFreqDev5()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setFreqDev5(f5);
float d1 = new BigDecimal(pqsComAssesPOS.get(i).getDataPlt1()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setDataPlT1(d1);
float d2 = new BigDecimal(pqsComAssesPOS.get(i).getDataPlt2()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setDataPlT2(d2);
float d3 = new BigDecimal(pqsComAssesPOS.get(i).getDataPlt3()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setDataPlT3(d3);
float d4 = new BigDecimal(pqsComAssesPOS.get(i).getDataPlt4()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setDataPlT4(d4);
float d5 = new BigDecimal(pqsComAssesPOS.get(i).getDataPlt5()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setDataPlT5(d5);
float vu1 = new BigDecimal(pqsComAssesPOS.get(i).getVUnbalance1()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setVUnbalance1(vu1);
float vu2 = new BigDecimal(pqsComAssesPOS.get(i).getVUnbalance2()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setVUnbalance2(vu2);
float vu3 = new BigDecimal(pqsComAssesPOS.get(i).getVUnbalance3()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setVUnbalance3(vu3);
float vu4 = new BigDecimal(pqsComAssesPOS.get(i).getVUnbalance4()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setVUnbalance4(vu4);
float vu5 = new BigDecimal(pqsComAssesPOS.get(i).getVUnbalance5()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setVUnbalance5(vu5);
float vt1 = new BigDecimal(pqsComAssesPOS.get(i).getVThd1()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setVTHD1(vt1);
float vt2 = new BigDecimal(pqsComAssesPOS.get(i).getVThd2()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setVTHD2(vt2);
float vt3 = new BigDecimal(pqsComAssesPOS.get(i).getVThd3()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setVTHD3(vt3);
float vt4 = new BigDecimal(pqsComAssesPOS.get(i).getVThd4()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setVTHD4(vt4);
float vt5 = new BigDecimal(pqsComAssesPOS.get(i).getVThd5()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setVTHD5(vt5);
float e1 = new BigDecimal(pqsComAssesPOS.get(i).getEvent1()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setEvent1(e1);
float e2 = new BigDecimal(pqsComAssesPOS.get(i).getEvent2()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setEvent2(e2);
float e3 = new BigDecimal(pqsComAssesPOS.get(i).getEvent3()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setEvent3(e3);
float e4 = new BigDecimal(pqsComAssesPOS.get(i).getEvent4()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setEvent4(e4);
float e5 = new BigDecimal(pqsComAssesPOS.get(i).getEvent5()).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
comAssessDTO.setEvent5(e5);
comAssessDTOS.add(comAssessDTO);
}
}
/**
* influxDB查询综合评估相关信息
* 返回每个监测点在时间段的各指标平均数
*
* @param lineIndexes
* @param searchBeginTime
* @param searchEndTime
*/
private List<PQSComAssesPO> getComAccessData(List<String> lineIndexes, String searchBeginTime, String searchEndTime) {
List<PQSComAssesPO> avgCount = largeScreenMapper.getAvgCount(lineIndexes,
DateUtil.beginOfDay(DateUtil.parse(searchBeginTime)).toString(),
DateUtil.beginOfDay(DateUtil.parse(searchEndTime)).toString());
if (CollUtil.isNotEmpty(avgCount)) {
return avgCount;
}
return new ArrayList<>();
}
}