1.解决审计统计没有显示的bug

2.解决数据中心数据查询过慢和数据展示bug
This commit is contained in:
wr
2023-06-01 17:16:28 +08:00
parent 4fe1039934
commit 7419142abe
33 changed files with 797 additions and 286 deletions

View File

@@ -2,6 +2,11 @@ package com.njcn.event.mapper.majornetwork;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.GeneralVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* <p>
@@ -13,4 +18,10 @@ import com.njcn.event.pojo.po.RmpEventDetailPO;
*/
public interface EventDetailMapper extends BaseMapper<RmpEventDetailPO> {
/**
* 根据时间范围查询信息数据
* @param condMap
* @return
*/
List<GeneralVO> ListEventType( @Param("condMap") Map<String, Object> condMap);
}

View File

@@ -15,5 +15,32 @@
<result column="event_describe" property="eventDescribe" />
<result column="wave_path" property="wavePath" />
</resultMap>
<select id="ListEventType" resultType="com.njcn.event.pojo.vo.GeneralVO">
SELECT
id,
IF(`event_type` =#{condMap.Voltage_Dip}, num, 0) as sagsCount,
IF(`event_type` = #{condMap.Short_Interruptions}, num, 0) as breakCount,
IF(`event_type` = #{condMap.Voltage_Rise}, num, 0) as upCount
from(
SELECT
measurement_point_id AS id,
event_type,
count(event_id) as num
FROM
r_mp_event_detail
where measurement_point_id in
<foreach collection="condMap.ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
<if test="condMap.startTime != null and condMap.startTime != ''">
and start_time &gt;= #{condMap.startTime}
</if>
<if test="condMap.endTime != null and condMap.endTime != ''">
and start_time &lt;= #{condMap.endTime}
</if>
GROUP BY
measurement_point_id,event_type
) a
</select>
</mapper>

View File

@@ -6,6 +6,9 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.biz.enums.DeviceResponseEnum;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
@@ -22,6 +25,7 @@ import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import io.swagger.models.auth.In;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@@ -50,6 +54,11 @@ public class AreaAnalysisServiceImpl implements AreaAnalysisService {
private final EventDetailService eventDetailService;
@Override
public AreaAnalysisVO getEventReason(DeviceInfoParam.BusinessParam deviceInfoParam) {
//获取暂降字典信息
// DictData voltageData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
// if(ObjectUtil.isNull(voltageData)){
// throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
// }
AreaAnalysisVO areaAnalysisVO = new AreaAnalysisVO();
List<DictData> dicReasonList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()).getData();
List<DictData> dicTypeList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()).getData();
@@ -59,18 +68,21 @@ public class AreaAnalysisServiceImpl implements AreaAnalysisService {
//查询数据
// List<AreaAnalysisVO.Children> reasonList = assData(dicReasonList, lineIds, deviceInfoParam.getSearchBeginTime(), deviceInfoParam.getSearchEndTime(), "event_reason");
List<RmpEventDetailPO> info = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
.in(RmpEventDetailPO::getAdvanceReason, dicReasonList.stream().map(DictData::getId).collect(Collectors.toList()))
.in(RmpEventDetailPO::getAdvanceType, dicTypeList.stream().map(DictData::getId).collect(Collectors.toList()))
.ge(StrUtil.isNotBlank(deviceInfoParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
.le(StrUtil.isNotBlank(deviceInfoParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
List<RmpEventDetailPO> info = eventDetailService.list(new QueryWrapper<RmpEventDetailPO>()
.select("advance_reason,advance_type,count(event_id) as count")
.in("measurement_point_id", lineIds)
// .eq("event_type", voltageData.getId())
.in("advance_reason", dicReasonList.stream().map(DictData::getId).collect(Collectors.toList()))
.in("advance_type", dicTypeList.stream().map(DictData::getId).collect(Collectors.toList()))
.ge(StrUtil.isNotBlank(deviceInfoParam.getSearchBeginTime()),"start_time" ,DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
.le(StrUtil.isNotBlank(deviceInfoParam.getSearchEndTime()), "start_time", DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
.groupBy("measurement_point_id,advance_reason,advance_type")
);
List<AreaAnalysisVO.Children> reasonList = assDataPQ(info, dicReasonList);
//暂降类型特殊处理
DictData dictData = dicReasonList.stream().filter(item->"短路故障".equals(item.getName())).findFirst().get();
DictData dictData = dicReasonList.stream().filter(item->DicDataEnum.SHORT_TROUBLE.getCode().equals(item.getCode())).findFirst().get();
//相间
List<String> dicIdsXi = dicTypeList.stream().filter(item->
ObjectUtil.equals(DicDataEnum.INTERPHASE_AB.getCode(),item.getCode())||
@@ -186,6 +198,27 @@ public class AreaAnalysisServiceImpl implements AreaAnalysisService {
}
private List<AreaAnalysisVO.Children> assDataPQ(List<RmpEventDetailPO> info,List<DictData> dicReasonList) {
List<AreaAnalysisVO.Children> reasonList = new ArrayList<>();
Map<String, List<RmpEventDetailPO>> reasonMap = info.stream().collect(Collectors.groupingBy(RmpEventDetailPO::getAdvanceReason));
AreaAnalysisVO.Children allType ;
Integer allCount = 0;
for (DictData dictData : dicReasonList) {
allType = new AreaAnalysisVO.Children();
if(reasonMap.containsKey(dictData.getId())){
Integer sum = reasonMap.get(dictData.getId()).stream().mapToInt(RmpEventDetailPO::getCount).sum();
allCount+=sum;
allType.setValue(sum);
}else{
allType.setValue(0);
}
allType.setName(dictData.getName());
reasonList.add(allType);
}
AreaAnalysisVO.Children zj = new AreaAnalysisVO.Children();
zj.setName("总计");
zj.setValue(allCount);
reasonList.add(zj);
/*
List<AreaAnalysisVO.Children> reasonList = new ArrayList<>();
//根据暂降原因分组
Map<String, String> reasonMap = dicReasonList.stream().collect(Collectors.toMap(DictData::getId,DictData::getName));
@@ -219,7 +252,7 @@ public class AreaAnalysisServiceImpl implements AreaAnalysisService {
AreaAnalysisVO.Children zj = new AreaAnalysisVO.Children();
zj.setName("总计");
zj.setValue(allCount);
reasonList.add(zj);
reasonList.add(zj);*/
return reasonList;
}
@@ -230,7 +263,7 @@ public class AreaAnalysisServiceImpl implements AreaAnalysisService {
Integer allCount = 0;
for (Map.Entry<String, List<String>> stringListEntry : stringListMap.entrySet()) {
List<String> value = stringListEntry.getValue();
Integer count = Math.toIntExact(reasons.stream().filter(x -> value.contains(x.getAdvanceType())).count());
Integer count = reasons.stream().filter(x -> value.contains(x.getAdvanceType())).mapToInt(RmpEventDetailPO::getCount).sum();
AreaAnalysisVO.Children allType = new AreaAnalysisVO.Children();
allType.setName(stringListEntry.getKey());
allType.setValue(count);

View File

@@ -3,9 +3,13 @@ package com.njcn.event.service.majornetwork.Impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.njcn.common.pojo.enums.common.ServerEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.biz.enums.DeviceResponseEnum;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
@@ -29,12 +33,14 @@ import com.njcn.harmonic.pojo.po.PQSComAssesPO;
import com.njcn.harmonic.utils.HarmonicComAssesUtil;
import com.njcn.influxdb.param.InfluxDBPublicParam;
import com.njcn.influxdb.utils.InfluxDbUtils;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.pojo.enums.StatisticsEnum;
import com.njcn.system.pojo.po.DictData;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
@@ -44,7 +50,6 @@ import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.njcn.event.influxdb.PqsOnlinerateQuery.devIdOr;
import static com.njcn.event.influxdb.QueryBuilder.*;
/**
@@ -69,10 +74,10 @@ public class AreaLineServiceImpl implements AreaLineService {
private final PqDeviceMapper pqDeviceMapper;
private final EventDetailService eventDetailService;
@Autowired
private LargeScreenService largeScreenService;
@Autowired
private HarmonicComAssesUtil comAssesUtil;
private final LargeScreenService largeScreenService;
private final HarmonicComAssesUtil comAssesUtil;
private final DicDataFeignClient dicDataFeignClient;
@Override
public AreaLineVO getAreaLineVO(DeviceInfoParam deviceInfoParam) {
@@ -164,10 +169,16 @@ public class AreaLineServiceImpl implements AreaLineService {
@Override
public EventHeatMapVO getEventHeatMap(DeviceInfoParam.BusinessParam deviceInfoParam) {
//获取暂降字典信息
DictData voltageData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
if(ObjectUtil.isNull(voltageData)){
throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
}
EventHeatMapVO eventHeatMapVO = new EventHeatMapVO();
List<List<AreaLineInfoVO>> eventHeatMapDetailList = new ArrayList<>();
deviceInfoParam.setServerName(ServerEnum.EVENT.getName());
List<BaseVO> listObject = new ArrayList<>();
// 获取暂降监测点
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData();
List<String> lineIndexs;
@@ -177,38 +188,29 @@ public class AreaLineServiceImpl implements AreaLineService {
lineIndexs = generalDeviceDTO.getLineIndexes();
// 获取暂降数据
if (lineIndexs.size() > 0) {
int tail = 0;
// List<EventHeatDeatilVO> eventdetailList = getContion(deviceInfoParam, lineIndexs);
Integer tail = 0;
//数据暂降查询
List<RmpEventDetailPO> info = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId, lineIndexs)
.ge(StrUtil.isNotBlank(deviceInfoParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
.le(StrUtil.isNotBlank(deviceInfoParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
List<RmpEventDetailPO> info = eventDetailService.list(new QueryWrapper<RmpEventDetailPO>()
.select("measurement_point_id as measurementPointId,count(file_flag) as fileFlag")
.in("measurement_point_id", lineIndexs)
.eq("event_type", voltageData.getId())
.ge(StrUtil.isNotBlank(deviceInfoParam.getSearchBeginTime()),"start_time" ,DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
.le(StrUtil.isNotBlank(deviceInfoParam.getSearchEndTime()), "start_time", DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
.groupBy("measurement_point_id")
);
List<EventHeatDeatilVO> eventdetailList = BeanUtil.copyToList(info, EventHeatDeatilVO.class);
if (eventdetailList.size() > 0) {
List<String> lineIds = eventdetailList.stream().map(EventHeatDeatilVO::getLineId).distinct().collect(Collectors.toList());
if (info.size() > 0) {
List<String> lineIds = info.stream().map(RmpEventDetailPO::getMeasurementPointId).distinct().collect(Collectors.toList());
List<AreaLineInfoVO> areaAnalysisVOList = lineFeignClient.getBaseLineAreaInfo(lineIds).getData();
/* for (EventHeatDeatilVO eventHeat : eventdetailList) {
for (AreaLineInfoVO areaLineInfoVO : areaAnalysisVOList) {
if (eventHeat.getLineId().equals(areaLineInfoVO.getLineId())) {
List<AreaLineInfoVO> ev = new ArrayList<>();
tail += eventHeat.getCount() == null ? 0 : eventHeat.getCount();
areaLineInfoVO.setTail(tail);
ev.add(areaLineInfoVO);
eventHeatMapDetailList.add(ev);
break;
}
}
}*/
for (AreaLineInfoVO areaLineInfoVO : areaAnalysisVOList) {
List<AreaLineInfoVO> ev = new ArrayList<>();
long count = eventdetailList.stream()
.filter(obj -> obj.getLineId().equals( areaLineInfoVO.getLineId()))
.count();
int c = (int) count;
areaLineInfoVO.setTail(c);
Integer count = info.stream()
.filter(obj -> obj.getMeasurementPointId().equals( areaLineInfoVO.getLineId()))
.mapToInt(RmpEventDetailPO::getFileFlag)
.sum();
tail+=count;
areaLineInfoVO.setTail(count);
ev.add(areaLineInfoVO);
eventHeatMapDetailList.add(ev);
}
@@ -221,7 +223,7 @@ public class AreaLineServiceImpl implements AreaLineService {
baseVO.setName(generalDeviceDTO.getName());
baseVO.setValue(BigDecimal.valueOf(lineIndexs.size()));
baseVO.setData(String.valueOf(allComAss));
baseVO.setCount(eventdetailList.size());
baseVO.setCount(tail);
baseVO.setSize(lineIndexs.size());
listObject.add(baseVO);
}
@@ -243,6 +245,11 @@ public class AreaLineServiceImpl implements AreaLineService {
@Override
public EventSeverityVO getEventSeverity(DeviceInfoParam.BusinessParam deviceInfoParam) {
//获取暂降字典信息
DictData voltageData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
if(ObjectUtil.isNull(voltageData)){
throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
}
EventSeverityVO eventSeverityVO = new EventSeverityVO();
List<EventSeverityValueVO> eventSeverityValueList = new ArrayList<>();
deviceInfoParam.setServerName(ServerEnum.EVENT.getName());
@@ -259,16 +266,18 @@ public class AreaLineServiceImpl implements AreaLineService {
if (lineIndexs.size() > 0) {
int tail = 0;
EventSeverityValueVO eventSeverityValueVO = new EventSeverityValueVO();
// List<EventHeatDeatilVO> eventdetailList = getContion(deviceInfoParam, lineIndexs);
List<RmpEventDetailPO> info = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId, lineIndexs)
.ge(StrUtil.isNotBlank(deviceInfoParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
.le(StrUtil.isNotBlank(deviceInfoParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
List<RmpEventDetailPO> info = eventDetailService.list(new QueryWrapper<RmpEventDetailPO>()
.select("measurement_point_id as measurementPointId,count(file_flag) as fileFlag")
.in("measurement_point_id", lineIndexs)
.eq("event_type", voltageData.getId())
.ge(StrUtil.isNotBlank(deviceInfoParam.getSearchBeginTime()),"start_time" ,DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
.le(StrUtil.isNotBlank(deviceInfoParam.getSearchEndTime()), "start_time", DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
.groupBy("measurement_point_id")
);
List<EventHeatDeatilVO> eventdetailList = BeanUtil.copyToList(info, EventHeatDeatilVO.class);
if (eventdetailList.size() > 0) {
for (int eventNum = 0; eventNum < eventdetailList.size(); eventNum++) {
tail += eventdetailList.get(eventNum).getCount();
if (info.size() > 0) {
for (int eventNum = 0; eventNum < info.size(); eventNum++) {
tail += info.get(eventNum).getFileFlag();
}
eventSeverityValueVO.setAreaName(generalDeviceDTO.getName());
eventSeverityValueVO.setLineNum(lineIndexs.size());

View File

@@ -2,13 +2,14 @@ package com.njcn.event.service.majornetwork.Impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import com.github.abel533.echarts.Label;
import com.github.abel533.echarts.Title;
import com.github.abel533.echarts.axis.AxisLabel;
@@ -26,6 +27,7 @@ import com.njcn.common.pojo.dto.SimpleDTO;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.biz.enums.DeviceResponseEnum;
import com.njcn.device.pms.api.MonitorClient;
import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient;
import com.njcn.device.pms.pojo.dto.PmsGeneralDeviceDTO;
@@ -33,13 +35,13 @@ import com.njcn.device.pms.pojo.param.PmsDeviceInfoParam;
import com.njcn.device.pms.pojo.po.Monitor;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.biz.enums.DeviceResponseEnum;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.param.LineBaseQueryParam;
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.event.enums.EventResponseEnum;
import com.njcn.event.mapper.majornetwork.EventDetailMapper;
import com.njcn.event.mapper.majornetwork.ReportMapper;
import com.njcn.event.pojo.constant.Param;
import com.njcn.event.pojo.param.*;
@@ -65,6 +67,23 @@ import com.njcn.system.pojo.enums.StatisticsEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.user.api.DeptFeignClient;
import freemarker.template.TemplateException;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import net.sf.json.JSONArray;
import org.apache.commons.lang.StringUtils;
@@ -78,7 +97,6 @@ import org.apache.poi.util.Units;
import org.apache.poi.xwpf.usermodel.*;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import org.springframework.beans.BeanUtils;
import org.springframework.http.*;
@@ -86,22 +104,6 @@ import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import sun.misc.BASE64Decoder;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author xxy
@@ -133,6 +135,7 @@ public class ReportServiceImpl implements ReportService {
private final MonitorClient monitorClient;
private final EventDetailService eventDetailService;
private final EventDetailMapper eventDetailMapper;
private final FreemarkerUtil freemarkerUtil;
@@ -190,62 +193,50 @@ public class ReportServiceImpl implements ReportService {
if(CollectionUtil.isEmpty(dictType)){
return new ArrayList<>();
}
Map<String, String> dictMap = dictType.stream().collect(Collectors.toMap(DictData::getId, DictData::getCode));
Map<String, String> dictMap = dictType.stream().collect(Collectors.toMap(DictData::getCode, DictData::getId));
//查区域
HttpResult<List<GeneralDeviceDTO>> info = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam);
List<GeneralDeviceDTO> data = info.getData();
//所有根据line_id查询出来的数据
HashMap<String, List<EventDetail>> map = new HashMap<>();
//循环查找所有数据
// QueryResult queryResult = new QueryResult();
ArrayList<GeneralVO> list = new ArrayList<>();
List<GeneralDeviceDTO> data = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
List<String> lineIds = data.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
HashMap<String, Object> condMap = new HashMap<>();
condMap.put("startTime", DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())).toString());
condMap.put("endTime", DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())).toString());
condMap.put("ids", lineIds);
condMap.put(DicDataEnum.VOLTAGE_DIP.getCode(), dictMap.get(DicDataEnum.VOLTAGE_DIP.getCode())); //电压暂降
condMap.put(DicDataEnum.SHORT_INTERRUPTIONS.getCode(), dictMap.get(DicDataEnum.SHORT_INTERRUPTIONS.getCode())); //短时中断
condMap.put(DicDataEnum.VOLTAGE_RISE.getCode(), dictMap.get(DicDataEnum.VOLTAGE_RISE.getCode())); //电压暂升
//根据id把所有的数据查询出来
List<GeneralVO> generalVOS = eventDetailMapper.ListEventType(condMap);
GeneralVO generalVO;
List<GeneralVO> list = new ArrayList<>();
for (GeneralDeviceDTO dto : data) {
list.add(new GeneralVO(dto.getName(), 0.0,0, 0, 0, 0, 0));
generalVO= new GeneralVO();
generalVO.setName(dto.getName());
// queryResult = null;
// StringBuilder stringBuilder = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL);
List<String> lineIndexes = dto.getLineIndexes();
if (lineIndexes.size() > 0) {
//数据暂降查询
List<RmpEventDetailPO> eventDetails = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId,lineIndexes)
.ge(StrUtil.isNotBlank(businessParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())))
.le(StrUtil.isNotBlank(businessParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())))
);
List<EventDetail> eventDetailList= BeanUtil.copyToList(eventDetails,EventDetail.class);
if(CollUtil.isNotEmpty(dto.getLineIndexes())){
List<GeneralVO> collect = generalVOS.stream().filter(x -> dto.getLineIndexes().contains(x.getId())).collect(Collectors.toList());
int sagsCount = collect.stream().mapToInt(GeneralVO::getSagsCount).sum();
int breakCount = collect.stream().mapToInt(GeneralVO::getBreakCount).sum();
int upCount = collect.stream().mapToInt(GeneralVO::getUpCount).sum();
Integer onLineCount = lineFeignClient.getOnLineCount(dto.getLineIndexes()).getData();
generalVO.setVol(0.0D);
generalVO.setOnLine(onLineCount);
generalVO.setOffLine(dto.getLineIndexes().size() - onLineCount);
generalVO.setSagsCount(sagsCount);
generalVO.setBreakCount(breakCount);
generalVO.setUpCount(upCount);
}else{
generalVO.setVol(0.0D);
generalVO.setOnLine(0);
generalVO.setOffLine(0);
generalVO.setSagsCount(0);
generalVO.setBreakCount(0);
generalVO.setUpCount(0);
}
list.add(generalVO);
map.put(dto.getName(), eventDetailList);
} else {
List<EventDetail> eventDetailList = new ArrayList<>();
map.put(dto.getName(), eventDetailList);
}
}
Set<String> keySet = map.keySet();
//获取状态
for (int i = 0; i < keySet.size(); i++) {
for (String s : keySet) {
GeneralVO generalVO = list.get(i);
if (map.get(s).size() > 0 && generalVO.getName().equals(s)) {
long count1 = map.get(s).stream().filter(x -> DicDataEnum.VOLTAGE_DIP.getCode().equals(dictMap.get(x.getEventType()))).count();
long count2 = map.get(s).stream().filter(x -> DicDataEnum.VOLTAGE_RISE.getCode().equals(dictMap.get(x.getEventType()))).count();
long count3 = map.get(s).stream().filter(x -> DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(dictMap.get(x.getEventType()))).count();
generalVO.setSagsCount((int) count1);
generalVO.setUpCount((int) count2);
generalVO.setBreakCount((int) count3);
}
}
}
//是否在线
for (int i = 0; i < data.size(); i++) {
GeneralVO generalVO = list.get(i);
GeneralDeviceDTO dto = data.get(i);
if (dto.getLineIndexes().size() > 0) {
HttpResult<Integer> result = lineFeignClient.getOnLineCount(dto.getLineIndexes());
generalVO.setOnLine(result.getData());
generalVO.setOffLine(dto.getLineIndexes().size() - result.getData());
}
}
return list;
}
@@ -263,66 +254,50 @@ public class ReportServiceImpl implements ReportService {
if(CollectionUtil.isEmpty(dictType)){
return new ArrayList<>();
}
Map<String, String> dictMap = dictType.stream().collect(Collectors.toMap(DictData::getId, DictData::getCode));
Map<String, String> dictMap = dictType.stream().collect(Collectors.toMap(DictData::getCode, DictData::getId));
//查电压
List<GeneralDeviceDTO> data = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
//所有根据line_id查询出来的数据
HashMap<String, List<EventDetail>> map = new HashMap<>();
//循环查找所有数据
// QueryResult queryResult = new QueryResult();
ArrayList<GeneralVO> list = new ArrayList<>();
List<String> lineIds = data.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
HashMap<String, Object> condMap = new HashMap<>();
condMap.put("startTime", DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())).toString());
condMap.put("endTime", DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())).toString());
condMap.put("ids", lineIds);
condMap.put(DicDataEnum.VOLTAGE_DIP.getCode(), dictMap.get(DicDataEnum.VOLTAGE_DIP.getCode())); //电压暂降
condMap.put(DicDataEnum.SHORT_INTERRUPTIONS.getCode(), dictMap.get(DicDataEnum.SHORT_INTERRUPTIONS.getCode())); //短时中断
condMap.put(DicDataEnum.VOLTAGE_RISE.getCode(), dictMap.get(DicDataEnum.VOLTAGE_RISE.getCode())); //电压暂升
//根据id把所有的数据查询出来
List<GeneralVO> generalVOS = eventDetailMapper.ListEventType(condMap);
GeneralVO generalVO;
List<GeneralVO> list = new ArrayList<>();
for (GeneralDeviceDTO dto : data) {
list.add(new GeneralVO(dto.getName(), 0.0,0, 0, 0, 0, 0));
// queryResult = null;
// StringBuilder stringBuilder = new StringBuilder(Param.SELECT + Param.EVENT_DETAIL);
List<String> lineIndexes = dto.getLineIndexes();
if (lineIndexes.size() > 0) {
//数据暂降查询
List<RmpEventDetailPO> eventDetails = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId,lineIndexes)
.ge(StrUtil.isNotBlank(businessParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())))
.le(StrUtil.isNotBlank(businessParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())))
);
List<EventDetail> eventDetailList= BeanUtil.copyToList(eventDetails,EventDetail.class);
// stringBuilder.append(Param.WHERE);
// lineIndexes.stream().forEach(line -> {
// stringBuilder.append("line_id = '").append(line + "' ").append("or ");
// });
// String substring = stringBuilder.substring(0, stringBuilder.length() - 3);
// queryResult = influxDbUtils.query(substring.toString());
// //结果集映射到对象中
// InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
// List<EventDetail> eventDetailList = influxDBResultMapper.toPOJO(queryResult, EventDetail.class);
map.put(dto.getName(), eventDetailList);
} else {
List<EventDetail> eventDetailList = new ArrayList<>();
map.put(dto.getName(), eventDetailList);
}
}
Set<String> keySet = map.keySet();
//获取状态
for (int i = 0; i < keySet.size(); i++) {
for (String s : keySet) {
GeneralVO generalVO = list.get(i);
if (map.get(s).size() > 0 && generalVO.getName().equals(s)) {
long count1 = map.get(s).stream().filter(x -> DicDataEnum.VOLTAGE_DIP.getCode().equals(dictMap.get(x.getEventType()))).count();
long count2 = map.get(s).stream().filter(x -> DicDataEnum.VOLTAGE_RISE.getCode().equals(dictMap.get(x.getEventType()))).count();
long count3 = map.get(s).stream().filter(x -> DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(dictMap.get(x.getEventType()))).count();
generalVO.setSagsCount((int) count1);
generalVO.setUpCount((int) count2);
generalVO.setBreakCount((int) count3);
}
}
}
//是否在线
for (int i = 0; i < data.size(); i++) {
GeneralVO generalVO = list.get(i);
GeneralDeviceDTO dto = data.get(i);
if (dto.getLineIndexes().size() > 0) {
HttpResult<Integer> result = lineFeignClient.getOnLineCount(dto.getLineIndexes());
generalVO.setOnLine(result.getData());
generalVO.setOffLine(dto.getLineIndexes().size() - result.getData());
generalVO= new GeneralVO();
generalVO.setName(dto.getName());
if(CollUtil.isNotEmpty(dto.getLineIndexes())){
List<GeneralVO> collect = generalVOS.stream().filter(x -> dto.getLineIndexes().contains(x.getId())).collect(Collectors.toList());
int sagsCount = collect.stream().mapToInt(GeneralVO::getSagsCount).sum();
int breakCount = collect.stream().mapToInt(GeneralVO::getBreakCount).sum();
int upCount = collect.stream().mapToInt(GeneralVO::getUpCount).sum();
Integer onLineCount = lineFeignClient.getOnLineCount(dto.getLineIndexes()).getData();
generalVO.setVol(0.0D);
generalVO.setOnLine(onLineCount);
generalVO.setOffLine(dto.getLineIndexes().size() - onLineCount);
generalVO.setSagsCount(sagsCount);
generalVO.setBreakCount(breakCount);
generalVO.setUpCount(upCount);
}else{
generalVO.setVol(0.0D);
generalVO.setOnLine(0);
generalVO.setOffLine(0);
generalVO.setSagsCount(0);
generalVO.setBreakCount(0);
generalVO.setUpCount(0);
}
list.add(generalVO);
}
list.forEach(item -> item.setVol(Double.parseDouble(item.getName().substring(0,item.getName().indexOf("k")))));
List<GeneralVO> sortedList = list.stream().sorted(Comparator.comparing(GeneralVO::getVol)).collect(Collectors.toList());
@@ -441,6 +416,11 @@ public class ReportServiceImpl implements ReportService {
*/
@Override
public Page<DetailVO> getContinueTime(WaveTypeParam waveTypeParam) {
//获取暂降字典信息
DictData voltageData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
if(ObjectUtil.isNull(voltageData)){
throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
}
List<String> lineIds =new ArrayList<>();
List<DetailVO> result = new ArrayList<>();
if(waveTypeParam.getType()==0){
@@ -467,7 +447,7 @@ public class ReportServiceImpl implements ReportService {
}
Page<RmpEventDetailPO> pageInfo = eventDetailService.page(new Page<>(waveTypeParam.getPageNum(), waveTypeParam.getPageSize()), new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
.eq(StrUtil.isNotBlank(waveTypeParam.getStatisticalType().getId()),RmpEventDetailPO::getEventType,waveTypeParam.getStatisticalType().getId())
.eq(StrUtil.isNotBlank(voltageData.getId()),RmpEventDetailPO::getEventType,voltageData.getId())
.ge(StringUtils.isNotBlank(waveTypeParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(waveTypeParam.getSearchBeginTime())))
.le(StringUtils.isNotBlank(waveTypeParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(waveTypeParam.getSearchEndTime())))
.orderByDesc(RmpEventDetailPO::getStartTime)
@@ -481,45 +461,47 @@ public class ReportServiceImpl implements ReportService {
result.add(vo);
idlist.add(eventDetail.getLineId());
}
if(waveTypeParam.getType()==0){
//pq系统
HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List<AreaLineInfoVO> data = AreaInfo.getData();
for (DetailVO detailVO : result) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(detailVO.getLineId())) {
BeanUtils.copyProperties(vo, detailVO);
if(CollUtil.isNotEmpty(idlist)){
if(waveTypeParam.getType()==0){
//pq系统
HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List<AreaLineInfoVO> data = AreaInfo.getData();
for (DetailVO detailVO : result) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(detailVO.getLineId())) {
BeanUtils.copyProperties(vo, detailVO);
}
}
}
}else{
//pms系统
List<Monitor> monitorInfo = monitorClient.getMonitorList(idlist).getData();
for (DetailVO detailVO : result) {
for (Monitor vo : monitorInfo) {
if (vo.getId().equals(detailVO.getLineId())) {
detailVO.setLineId(vo.getId());
detailVO.setLineName(vo.getName());
detailVO.setSubId(vo.getPowerrId());
detailVO.setSubName(vo.getPowerrName());
detailVO.setGdId(vo.getOrgId());
detailVO.setGdName(vo.getOrgName());
detailVO.setVoltageScale(vo.getVoltageLevel());
}
}
}
}
}else{
//pms系统
List<Monitor> monitorInfo = monitorClient.getMonitorList(idlist).getData();
HttpResult<List<DictData>> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName());
List<DictData> type = reason.getData();
for (DetailVO detailVO : result) {
for (Monitor vo : monitorInfo) {
if (vo.getId().equals(detailVO.getLineId())) {
detailVO.setLineId(vo.getId());
detailVO.setLineName(vo.getName());
detailVO.setSubId(vo.getPowerrId());
detailVO.setSubName(vo.getPowerrName());
detailVO.setGdId(vo.getOrgId());
detailVO.setGdName(vo.getOrgName());
detailVO.setVoltageScale(vo.getVoltageLevel());
for (DictData dictData : type) {
if (dictData.getId().equals(detailVO.getAdvanceType())) {
detailVO.setAdvanceType(dictData.getName());
}
}
}
}
HttpResult<List<DictData>> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName());
List<DictData> type = reason.getData();
for (DetailVO detailVO : result) {
for (DictData dictData : type) {
if (dictData.getId().equals(detailVO.getAdvanceType())) {
detailVO.setAdvanceType(dictData.getName());
}
}
}
}
Page<DetailVO> page = BeanUtil.copyProperties(pageInfo,Page.class);
page.setRecords(result);
@@ -575,8 +557,9 @@ public class ReportServiceImpl implements ReportService {
for (DetailVO vo : detailVO) {
idlist.add(vo.getLineId());
}
HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List<AreaLineInfoVO> data = AreaInfo.getData();
if(CollUtil.isNotEmpty(idlist)){
HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List<AreaLineInfoVO> data = AreaInfo.getData();
/*for (DetailVO detailVO : result) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(detailVO.getLineId())) {
@@ -589,13 +572,15 @@ public class ReportServiceImpl implements ReportService {
}
}
}*/
for (DetailVO v : detailVO) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(v.getLineId())) {
BeanUtils.copyProperties(vo, v);
for (DetailVO v : detailVO) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(v.getLineId())) {
BeanUtils.copyProperties(vo, v);
}
}
}
}
Page<DetailVO> page = BeanUtil.copyProperties(detail,Page.class);
page.setRecords(detailVO);
return page;
@@ -656,8 +641,9 @@ public class ReportServiceImpl implements ReportService {
for (DetailVO vo : detailVO) {
idlist.add(vo.getLineId());
}
HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List<AreaLineInfoVO> data = AreaInfo.getData();
if(CollUtil.isNotEmpty(idlist)){
HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List<AreaLineInfoVO> data = AreaInfo.getData();
/*for (DetailVO detailVO : result) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(detailVO.getLineId())) {
@@ -670,10 +656,11 @@ public class ReportServiceImpl implements ReportService {
}
}
}*/
for (DetailVO v : detailVO) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(v.getLineId())) {
BeanUtils.copyProperties(vo, v);
for (DetailVO v : detailVO) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(v.getLineId())) {
BeanUtils.copyProperties(vo, v);
}
}
}
}
@@ -737,8 +724,9 @@ public class ReportServiceImpl implements ReportService {
for (DetailVO vo : detailVO) {
idlist.add(vo.getLineId());
}
HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List<AreaLineInfoVO> data = AreaInfo.getData();
if(CollUtil.isNotEmpty(idlist)){
HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List<AreaLineInfoVO> data = AreaInfo.getData();
/* for (DetailVO detailVO : result) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(detailVO.getLineId())) {
@@ -751,13 +739,15 @@ public class ReportServiceImpl implements ReportService {
}
}
}*/
for (DetailVO v : detailVO) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(v.getLineId())) {
BeanUtils.copyProperties(vo, v);
for (DetailVO v : detailVO) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(v.getLineId())) {
BeanUtils.copyProperties(vo, v);
}
}
}
}
Page<DetailVO> page = BeanUtil.copyProperties(detail,Page.class);
page.setRecords(detailVO);
return page;
@@ -835,7 +825,7 @@ public class ReportServiceImpl implements ReportService {
//表格操作
HSSFWorkbook sheets = new HSSFWorkbook();
sheets.createSheet("sheet1");
sheets.createSheet("暂态总体概况");
HSSFSheet sheetAt = sheets.getSheetAt(0);
sheetAt.setColumnWidth(0, 24 * 256);
sheetAt.setColumnWidth(1, 9 * 256);
@@ -887,6 +877,7 @@ public class ReportServiceImpl implements ReportService {
setCellStyle(r3Cell1, "在线", cellStyle);
HSSFCell r3Cell2 = row3.createCell(2);
setCellStyle(r3Cell2, "离线", cellStyle);
int titleSize = 4;
HSSFCellStyle bodyStyle = sheets.createCellStyle();
bodyStyle.setAlignment(HorizontalAlignment.CENTER);
@@ -896,6 +887,11 @@ public class ReportServiceImpl implements ReportService {
bodyFont.setFontHeightInPoints((short) 9);
bodyStyle.setFont(bodyFont);
sheet2(sheets,cellStyle,bodyStyle,businessParam);
sheet3(sheets,cellStyle,bodyStyle,businessParam);
sheet4(sheets,cellStyle,bodyStyle,businessParam);
ArrayList<Integer> online = new ArrayList<>();
ArrayList<Integer> offline = new ArrayList<>();
ArrayList<String> xdata = new ArrayList<>();
@@ -911,7 +907,7 @@ public class ReportServiceImpl implements ReportService {
List<Integer> up2 = new ArrayList<>();
List<Integer> sag2 = new ArrayList<>();
List<Integer> break2 = new ArrayList<>();
/*
for (int i = 0; i < GereralList.size(); i++) {
GeneralVO vo = GereralList.get(i);
@@ -1076,9 +1072,341 @@ public class ReportServiceImpl implements ReportService {
drawingPatriarch.createPicture(anchor1, sheets.addPicture(bytes2, HSSFWorkbook.PICTURE_TYPE_JPEG));
drawingPatriarch.createPicture(anchor2, sheets.addPicture(bytes3, HSSFWorkbook.PICTURE_TYPE_JPEG));
drawingPatriarch.createPicture(anchor3, sheets.addPicture(bytes4, HSSFWorkbook.PICTURE_TYPE_JPEG));
*/
PoiUtil.exportFileByWorkbook(sheets, "电压暂降周报.xlsx", response);
}
public void sheet2(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam){
sheets.createSheet("暂态严重度统计");
HSSFSheet sheetAt = sheets.getSheetAt(1);
sheetAt.setColumnWidth(0, 24 * 256);
sheetAt.setColumnWidth(1, 24 * 256);
sheetAt.setColumnWidth(2, 24 * 256);
sheetAt.setColumnWidth(3, 24 * 256);
sheetAt.setColumnWidth(4, 24 * 256);
sheetAt.setColumnWidth(5, 24 * 256);
sheetAt.setColumnWidth(6, 24 * 256);
sheetAt.setColumnWidth(7, 24 * 256);
sheetAt.setColumnWidth(8, 24 * 256);
sheetAt.setColumnWidth(9, 24 * 256);
sheetAt.addMergedRegion(new CellRangeAddress(0, 0, 0, 10));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 0, 0));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 1, 1));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 2, 2));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 3, 3));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 4, 4));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 5, 5));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 6, 6));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 7, 7));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 8, 8));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 9, 9));
HSSFRow title = sheetAt.createRow(0);
HSSFRow row1 = sheetAt.createRow(1);
HSSFCell titleCell = title.createCell(0);
setCellStyle(titleCell, "暂态事件严重度(前二十)", cellStyle);
HSSFCell r1Cell0 = row1.createCell(0);
HSSFCell r1Cell1 = row1.createCell(1);
HSSFCell r1Cell2 = row1.createCell(2);
HSSFCell r1Cell3 = row1.createCell(3);
HSSFCell r1Cell4 = row1.createCell(4);
HSSFCell r1Cell5 = row1.createCell(5);
HSSFCell r1Cell6 = row1.createCell(6);
HSSFCell r1Cell7 = row1.createCell(7);
HSSFCell r1Cell8 = row1.createCell(8);
HSSFCell r1Cell9 = row1.createCell(9);
setCellStyle(r1Cell0, "序号", cellStyle);
setCellStyle(r1Cell1, "暂态事件发生时刻", cellStyle);
setCellStyle(r1Cell2, "供电公司", cellStyle);
setCellStyle(r1Cell3, "变电站", cellStyle);
setCellStyle(r1Cell4, "监测点", cellStyle);
setCellStyle(r1Cell5, "监测点电压等级", cellStyle);
setCellStyle(r1Cell6, "干扰源类型", cellStyle);
setCellStyle(r1Cell7, "暂降(骤升)幅值(%)", cellStyle);
setCellStyle(r1Cell8, "持续时间(s)", cellStyle);
setCellStyle(r1Cell9, "暂态事件严重度", cellStyle);
List<WaveTypeVO> severity = getSeverity(businessParam);
for (int i = 0; i < severity.size(); i++) {
WaveTypeVO vo = severity.get(i);
HSSFRow row = sheetAt.createRow(i + 3);
HSSFCell cell0 = row.createCell(0);
HSSFCell cell1 = row.createCell(1);
HSSFCell cell2 = row.createCell(2);
HSSFCell cell3 = row.createCell(3);
HSSFCell cell4 = row.createCell(4);
HSSFCell cell5 = row.createCell(5);
HSSFCell cell6 = row.createCell(6);
HSSFCell cell7 = row.createCell(7);
HSSFCell cell8 = row.createCell(8);
HSSFCell cell9 = row.createCell(9);
cell0.setCellStyle(bodyStyle);
cell1.setCellStyle(bodyStyle);
cell2.setCellStyle(bodyStyle);
cell3.setCellStyle(bodyStyle);
cell4.setCellStyle(bodyStyle);
cell5.setCellStyle(bodyStyle);
cell6.setCellStyle(bodyStyle);
cell7.setCellStyle(bodyStyle);
cell8.setCellStyle(bodyStyle);
cell9.setCellStyle(bodyStyle);
cell0.setCellValue(i+1);
cell1.setCellValue(vo.getStartTime());
cell2.setCellValue(vo.getGdName());
cell3.setCellValue(vo.getSubName());
cell4.setCellValue(vo.getLineName());
cell5.setCellValue(vo.getVoltageScale());
cell6.setCellValue(vo.getLoadType());
cell7.setCellValue(vo.getFeatureAmplitude()*100);
cell8.setCellValue(vo.getDuration());
cell9.setCellValue(vo.getSeverity());
}
}
public void sheet3(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam){
sheets.createSheet("暂态原因统计");
HSSFSheet sheetAt = sheets.getSheetAt(2);
sheetAt.setColumnWidth(0, 40 * 256);
sheetAt.setColumnWidth(1, 40 * 256);
sheetAt.setColumnWidth(2, 40 * 256);
sheetAt.setColumnWidth(3, 40 * 256);
sheetAt.setColumnWidth(4, 40 * 256);
sheetAt.setColumnWidth(5, 40 * 256);
sheetAt.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 0, 0));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 1, 1));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 2, 2));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 3, 3));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 4, 4));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 5, 5));
HSSFRow title = sheetAt.createRow(0);
HSSFRow row1 = sheetAt.createRow(1);
HSSFCell titleCell = title.createCell(0);
setCellStyle(titleCell, "暂态原因统计表", cellStyle);
HSSFCell r1Cell0 = row1.createCell(0);
HSSFCell r1Cell1 = row1.createCell(1);
HSSFCell r1Cell2 = row1.createCell(2);
HSSFCell r1Cell3 = row1.createCell(3);
HSSFCell r1Cell4 = row1.createCell(4);
HSSFCell r1Cell5 = row1.createCell(5);
setCellStyle(r1Cell0, "暂态原因", cellStyle);
setCellStyle(r1Cell1, "短路故障", cellStyle);
setCellStyle(r1Cell2, "变压器激磁", cellStyle);
setCellStyle(r1Cell3, "电压扰动", cellStyle);
setCellStyle(r1Cell4, "大型感应电动机启动", cellStyle);
setCellStyle(r1Cell5, "其他", cellStyle);
List<ReasonsVO> reason = getReason(businessParam);
HSSFRow row = sheetAt.createRow(3);
HSSFCell cell0 = row.createCell(0);
cell0.setCellValue("次数");
cell0.setCellStyle(bodyStyle);
HSSFRow row2 = sheetAt.createRow(4);
HSSFCell cellR0 = row2.createCell(0);
cellR0.setCellValue("占比(%)");
cellR0.setCellStyle(bodyStyle);
for (ReasonsVO reasonsVO : reason) {
if(ObjectUtil.equals(reasonsVO.getReason(),"短路故障")) {
HSSFCell cell1 = row.createCell(1);
HSSFCell cellR1 = row2.createCell(1);
cell1.setCellStyle(bodyStyle);
cellR1.setCellStyle(bodyStyle);
cell1.setCellValue(reasonsVO.getTimes());
cellR1.setCellValue(reasonsVO.getRate());
}
if(ObjectUtil.equals(reasonsVO.getReason(),"变压器激磁")) {
HSSFCell cell1 = row.createCell(2);
HSSFCell cellR1 = row2.createCell(2);
cell1.setCellStyle(bodyStyle);
cellR1.setCellStyle(bodyStyle);
cell1.setCellValue(reasonsVO.getTimes());
cellR1.setCellValue(reasonsVO.getRate());
}
if(ObjectUtil.equals(reasonsVO.getReason(),"电压扰动")) {
HSSFCell cell1 = row.createCell(3);
HSSFCell cellR1 = row2.createCell(3);
cell1.setCellStyle(bodyStyle);
cellR1.setCellStyle(bodyStyle);
cell1.setCellValue(reasonsVO.getTimes());
cellR1.setCellValue(reasonsVO.getRate());
}
if(ObjectUtil.equals(reasonsVO.getReason(),"大型感应电动机启动")) {
HSSFCell cell1 = row.createCell(4);
HSSFCell cellR1 = row2.createCell(4);
cell1.setCellStyle(bodyStyle);
cellR1.setCellStyle(bodyStyle);
cell1.setCellValue(reasonsVO.getTimes());
cellR1.setCellValue(reasonsVO.getRate());
}
if(ObjectUtil.equals(reasonsVO.getReason(),"其他")) {
HSSFCell cell1 = row.createCell(5);
HSSFCell cellR1 = row2.createCell(5);
cell1.setCellStyle(bodyStyle);
cellR1.setCellStyle(bodyStyle);
cell1.setCellValue(reasonsVO.getTimes());
cellR1.setCellValue(reasonsVO.getRate());
}
}
//todo 缺少eaches
}
public void sheet4(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam){
sheets.createSheet("详细事件列表");
HSSFSheet sheetAt = sheets.getSheetAt(3);
sheetAt.setColumnWidth(0, 24 * 256);
sheetAt.setColumnWidth(1, 24 * 256);
sheetAt.setColumnWidth(2, 24 * 256);
sheetAt.setColumnWidth(3, 24 * 256);
sheetAt.setColumnWidth(4, 24 * 256);
sheetAt.setColumnWidth(5, 24 * 256);
sheetAt.setColumnWidth(6, 24 * 256);
sheetAt.setColumnWidth(7, 24 * 256);
sheetAt.setColumnWidth(8, 24 * 256);
sheetAt.setColumnWidth(9, 24 * 256);
sheetAt.setColumnWidth(10, 24 * 256);
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 1, 1));
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 2, 2));
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 3, 3));
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 4, 4));
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 5, 5));
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 6, 6));
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 7, 7));
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 8, 8));
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 9, 9));
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 10, 10));
HSSFRow row1 = sheetAt.createRow(0);
HSSFCell r1Cell0 = row1.createCell(0);
HSSFCell r1Cell1 = row1.createCell(1);
HSSFCell r1Cell2 = row1.createCell(2);
HSSFCell r1Cell3 = row1.createCell(3);
HSSFCell r1Cell4 = row1.createCell(4);
HSSFCell r1Cell5 = row1.createCell(5);
HSSFCell r1Cell6 = row1.createCell(6);
HSSFCell r1Cell7 = row1.createCell(7);
HSSFCell r1Cell8 = row1.createCell(8);
HSSFCell r1Cell9 = row1.createCell(9);
HSSFCell r1Cell10 = row1.createCell(10);
setCellStyle(r1Cell0, "序号", cellStyle);
setCellStyle(r1Cell1, "暂态事件发生时刻", cellStyle);
setCellStyle(r1Cell2, "供电公司", cellStyle);
setCellStyle(r1Cell3, "变电站", cellStyle);
setCellStyle(r1Cell4, "监测点", cellStyle);
setCellStyle(r1Cell5, "监测点电压等级", cellStyle);
setCellStyle(r1Cell6, "干扰源类型", cellStyle);
setCellStyle(r1Cell7, "暂降(骤升)幅值(%)", cellStyle);
setCellStyle(r1Cell8, "持续时间(s)", cellStyle);
setCellStyle(r1Cell9, "暂态事件严重度", cellStyle);
setCellStyle(r1Cell10, "暂态类型(机器判断)", cellStyle);
List<DetailVO> severity = sheetDetailed(businessParam);
for (int i = 0; i < severity.size(); i++) {
DetailVO vo = severity.get(i);
HSSFRow row = sheetAt.createRow(i + 2);
HSSFCell cell0 = row.createCell(0);
HSSFCell cell1 = row.createCell(1);
HSSFCell cell2 = row.createCell(2);
HSSFCell cell3 = row.createCell(3);
HSSFCell cell4 = row.createCell(4);
HSSFCell cell5 = row.createCell(5);
HSSFCell cell6 = row.createCell(6);
HSSFCell cell7 = row.createCell(7);
HSSFCell cell8 = row.createCell(8);
HSSFCell cell9 = row.createCell(9);
HSSFCell cell10 = row.createCell(10);
cell0.setCellStyle(bodyStyle);
cell1.setCellStyle(bodyStyle);
cell2.setCellStyle(bodyStyle);
cell3.setCellStyle(bodyStyle);
cell4.setCellStyle(bodyStyle);
cell5.setCellStyle(bodyStyle);
cell6.setCellStyle(bodyStyle);
cell7.setCellStyle(bodyStyle);
cell8.setCellStyle(bodyStyle);
cell9.setCellStyle(bodyStyle);
cell10.setCellStyle(bodyStyle);
cell0.setCellValue(i+1);
cell1.setCellValue(vo.getStartTime());
cell2.setCellValue(vo.getGdName());
cell3.setCellValue(vo.getSubName());
cell4.setCellValue(vo.getLineName());
cell5.setCellValue(vo.getVoltageScale());
cell6.setCellValue(vo.getLoadType());
cell7.setCellValue(vo.getObjName());
cell8.setCellValue(vo.getFeatureAmplitude()*100);
cell9.setCellValue(vo.getDuration());
cell10.setCellValue(vo.getAdvanceType());
}
}
/**
* sheet 详细数据列表
*/
private List<DetailVO> sheetDetailed(DeviceInfoParam.BusinessParam businessParam){
//获取暂降字典信息
DictData voltageData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
if(ObjectUtil.isNull(voltageData)){
throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
}
List<DetailVO> result = new ArrayList<>();
//pq系统
List<GeneralDeviceDTO> deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
List<String> lineIds =deviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
if (CollectionUtil.isEmpty(lineIds)) {
throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
}
List<RmpEventDetailPO> info = eventDetailService.list( new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
.eq(StrUtil.isNotBlank(voltageData.getId()),RmpEventDetailPO::getEventType,voltageData.getId())
.ge(StringUtils.isNotBlank(businessParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())))
.le(StringUtils.isNotBlank(businessParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())))
.orderByDesc(RmpEventDetailPO::getStartTime)
);
if (CollectionUtil.isNotEmpty(info)) {
ArrayList<String> idlist = new ArrayList<>();
for (RmpEventDetailPO eventDetail : info) {
DetailVO vo = new DetailVO();
vo.setStartTime( eventDetail.getStartTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_MS_PATTERN)));
BeanUtils.copyProperties(eventDetail, vo);
result.add(vo);
idlist.add(eventDetail.getLineId());
}
if(CollUtil.isNotEmpty(idlist)){
//pq系统
HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List<AreaLineInfoVO> data = AreaInfo.getData();
for (DetailVO detailVO : result) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(detailVO.getLineId())) {
BeanUtils.copyProperties(vo, detailVO);
}
}
}
HttpResult<List<DictData>> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName());
List<DictData> type = reason.getData();
for (DetailVO detailVO : result) {
for (DictData dictData : type) {
if (dictData.getId().equals(detailVO.getAdvanceType())) {
detailVO.setAdvanceType(dictData.getName());
}
}
}
}
}
return result;
}
/**
* 创建标题
@@ -1261,7 +1589,7 @@ public class ReportServiceImpl implements ReportService {
EventDetail eventDetail = plot.get(j);
String s = eventDetail.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
insertRow(doc, table, centerParagraph, false, j + 1 + "", s, eventDetail.getFeatureAmplitude() + "", eventDetail.getDuration() / 1000.0 + "", eventDetail.getAdvanceType(), eventDetail.getAdvanceReason(), eventDetail.getSeverity() + "");
insertRow(doc, table, centerParagraph, false, j + 1 + "", s, eventDetail.getFeatureAmplitude()*100 + "", eventDetail.getDuration() + "", eventDetail.getAdvanceType(), eventDetail.getAdvanceReason(), eventDetail.getSeverity() + "");
}
i++;
}
@@ -1497,7 +1825,7 @@ public class ReportServiceImpl implements ReportService {
ArrayList<List<Double>> list = new ArrayList<>();
for (EventDetail eventDetail : plot) {
ArrayList<Double> doubles = new ArrayList<>();
doubles.add(Double.parseDouble(eventDetail.getDuration() / 1000 + ""));
doubles.add(eventDetail.getDuration());
doubles.add(Double.parseDouble(String.valueOf(eventDetail.getFeatureAmplitude() * 100)));
list.add(doubles);
}

View File

@@ -322,10 +322,10 @@ public class TransientServiceImpl implements TransientService {
.orderByDesc(RmpEventDetailPO::getStartTime);
//暂态幅值
if (Objects.nonNull(transientParam.getEventValueMin())) {
wrapper.ge(RmpEventDetailPO::getFeatureAmplitude, transientParam.getEventValueMin().divide(new BigDecimal(100), 2, BigDecimal.ROUND_UP));
wrapper.ge(RmpEventDetailPO::getFeatureAmplitude, transientParam.getEventValueMin());
}
if (Objects.nonNull(transientParam.getEventValueMax())) {
wrapper.le(RmpEventDetailPO::getFeatureAmplitude, transientParam.getEventValueMax().divide(new BigDecimal(100), 2, BigDecimal.ROUND_UP));
wrapper.le(RmpEventDetailPO::getFeatureAmplitude, transientParam.getEventValueMax());
}
if (Objects.nonNull(transientParam.getPersistMin()) && Objects.nonNull(transientParam.getSeverityMax())) {
wrapper.ge(RmpEventDetailPO::getDuration, transientParam.getPersistMin()).le(RmpEventDetailPO::getDuration, transientParam.getPersistMax());

View File

@@ -3,16 +3,19 @@
backgroundColor: "#FFF",
title: {
text: "ITIC曲线",
x: "center",
left: "center",
},
grid: {
left: "4%",
right: "2%",
top: "80px",
left: "40px",
right: "40px",
bottom: "10%",
},
legend: {
data: ["上限", "下限", "可容忍事件", "不可容忍事件"],
x: "left",
top:"26px",
left: "0px",
bottom: "94%",
},
color: ["#FF8C00", "#00BFFF", "green", "red"],
xAxis: [

View File

@@ -3,16 +3,19 @@
backgroundColor: "#fff",
title: {
text: "SEMI F47曲线",
x: "center",
left: "center",
},
grid: {
left: "4%",
right: "5%",
top: "80px",
left: "40px",
right: "40px",
bottom: "10%",
},
legend: {
data: ["边界线", "可容忍事件", "不可容忍事件"],
x: "left",
top:"26px",
left: "0px",
bottom: "94%",
},
color: ["yellow", "green", "red"],
xAxis: [

View File

@@ -30,10 +30,10 @@
xAxis: [
{
type: "category",
boundaryGap: false,
boundaryGap: true,
name: "暂降幅值",
nameLocation: "center",
nameGap: 20,
nameGap: 40,
nameTextStyle: {
fontSize: 15,
},
@@ -56,7 +56,7 @@
type: "value",
name: "概率分布",
nameLocation: "center",
nameGap: 40,
nameGap: 60,
nameTextStyle: {
fontSize: 15,
},
@@ -68,7 +68,7 @@
type: "value",
name: "占比",
nameLocation: "center",
nameGap: 40,
nameGap: 20,
nameTextStyle: {
fontSize: 15,
},

View File

@@ -19,10 +19,10 @@ bottom: "15%"
xAxis: [
{
type: "category",
boundaryGap: false,
boundaryGap: true,
name: "暂降持续时间(s)",
nameLocation: "center",
nameGap: 20,
nameGap: 40,
nameTextStyle: {
fontSize: 15,
},
@@ -34,7 +34,7 @@ yAxis: [
type: "value",
name: "概率分布",
nameLocation: "center",
nameGap: 40,
nameGap: 60,
nameTextStyle: {
fontSize: 15,
},
@@ -46,7 +46,7 @@ formatter: "{value} %",
type: "value",
name: "占比",
nameLocation: "center",
nameGap: 40,
nameGap: 20,
nameTextStyle: {
fontSize: 15,
},

View File

@@ -11,9 +11,10 @@ data: ["暂降次数"],
x: "left",
},
grid: {
left: "3%",
bottom: "3%",
right: "7%",
top: "80px",
left: "40px",
right: "60px",
bottom:"20px",
containLabel: true,
},
xAxis: [