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

@@ -74,4 +74,10 @@ public class AllDataVO implements Serializable {
*/
@ApiModelProperty("中断")
private String breakdown;
/**
* 综合评估
*/
@ApiModelProperty("综合评估")
private String data;
}

View File

@@ -83,6 +83,12 @@
<artifactId>okio</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>harmonic-api</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@@ -3,6 +3,7 @@ package com.njcn.event.mapper.majornetwork;
import com.njcn.device.pq.pojo.vo.AllDataVO;
import com.njcn.device.pq.pojo.vo.EventVO;
import com.njcn.device.pq.pojo.vo.MiddleLimitRateVO;
import com.njcn.harmonic.pojo.po.PQSComAssesPO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -35,4 +36,14 @@ public interface LargeScreenMapper {
List<Map<String,Object>> getHomeostasisArea (@Param("indexIds") List<String> indexIds, @Param("startTime") String startTime, @Param("endTime") String endTime);
/**
* 统计综合评估平均值
* @param lineIndexes
* @param searchBeginTime
* @param searchEndTime
* @return
*/
List<PQSComAssesPO> getAvgCount(@Param("ids") List<String> lineIndexes,
@Param("statTime") String searchBeginTime,
@Param("endTime") String searchEndTime);
}

View File

@@ -214,4 +214,57 @@
</if>
group by rshom.org_no
</select>
<select id="getAvgCount" resultType="com.njcn.harmonic.pojo.po.PQSComAssesPO">
SELECT
line_id,
AVG ( vu_dev1 ) AS vu_dev1,
AVG ( vu_dev2 ) AS vu_dev2,
AVG ( vu_dev3 ) AS vu_dev3,
AVG ( vu_dev4 ) AS vu_dev4,
AVG ( vu_dev5 ) AS vu_dev5,
AVG ( freq_dev1 ) AS freq_dev1,
AVG ( freq_dev2 ) AS freq_dev2,
AVG ( freq_dev3 ) AS freq_dev3,
AVG ( freq_dev4 ) AS freq_dev4,
AVG ( freq_dev5 ) AS freq_dev5,
AVG ( data_plt1 ) AS data_plt1,
AVG ( data_plt2 ) AS data_plt2,
AVG ( data_plt3 ) AS data_plt3,
AVG ( data_plt4 ) AS data_plt4,
AVG ( data_plt5 ) AS data_plt5,
AVG ( v_unbalance1 ) AS v_unbalance1,
AVG ( v_unbalance2 ) AS v_unbalance2,
AVG ( v_unbalance3 ) AS v_unbalance3,
AVG ( v_unbalance4 ) AS v_unbalance4,
AVG ( v_unbalance5 ) AS v_unbalance5,
AVG ( v_thd1 ) AS v_thd1,
AVG ( v_thd2 ) AS v_thd2,
AVG ( v_thd3 ) AS v_thd3,
AVG ( v_thd4 ) AS v_thd4,
AVG ( v_thd5 ) AS v_thd5,
AVG ( event1 ) AS event1,
AVG ( event2 ) AS event2,
AVG ( event3 ) AS event3,
AVG ( event4 ) AS event4,
AVG ( event5 ) AS event5
FROM
r_stat_comasses_d
<where>
<if test=" ids != null and ids.size > 0">
AND line_id IN
<foreach collection='ids' item='item' index="index" open='(' separator=',' close=')'>
#{item}
</foreach>
</if>
<if test=" statTime != null and statTime !=''">
AND time_id >= #{statTime}
</if>
<if test="endTime != null and endTime != ''">
AND time_id &lt;= #{endTime}
</if>
</where>
GROUP BY line_id
</select>
</mapper>

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;
/**
* 暂降事件区域
*/
@@ -314,8 +323,27 @@ public class LargeScreenServiceImpl implements LargeScreenService {
}
}
}
//todo 该接口部分功能未完成 1.综合评估
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");
}
}
return result;
}
@@ -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<>();
}
}