1.根据code获取字典树

2.解决数据中心bug
3.优化暂态报表的查询语句将influxdb转为mysql
This commit is contained in:
wr
2023-08-28 16:26:16 +08:00
parent 04960a3911
commit 47e6213f73
13 changed files with 203 additions and 362 deletions

View File

@@ -1,6 +1,7 @@
package com.njcn.event.mapper.majornetwork;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.event.pojo.po.Eventass;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.GeneralVO;
import org.apache.ibatis.annotations.Param;
@@ -24,4 +25,12 @@ public interface EventDetailMapper extends BaseMapper<RmpEventDetailPO> {
* @return
*/
List<GeneralVO> ListEventType( @Param("condMap") Map<String, Object> condMap);
/**
* 根据暂降事件id集合获取暂降事件
* @param ids
* @return
*/
List<Eventass> ListEventass(@Param("ids") List<String> ids);
}

View File

@@ -43,5 +43,19 @@
) a
GROUP BY id
</select>
<select id="ListEventass" resultType="com.njcn.event.pojo.po.Eventass">
select
*
from
r_mp_event_detail_ass
<where>
<if test="ids != null and ids.size() != 0">
Event_Ass_Id in
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
</where>
</select>
</mapper>

View File

@@ -105,7 +105,11 @@ public class AreaInfoServiceImpl implements AreaInfoService {
//查询监测点未处理暂态事件
List<RmpEventDetailPO> eventDetails = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
.and(x -> x.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
.isNull(RmpEventDetailPO::getEventassIndex)
.or()
.eq(RmpEventDetailPO::getEventassIndex, "")
)
.ge(StringUtils.isNotBlank(deviceInfoParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
.le(StringUtils.isNotBlank(deviceInfoParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
.orderByDesc(RmpEventDetailPO::getStartTime));

View File

@@ -5,6 +5,7 @@ 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.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -36,7 +37,6 @@ import com.njcn.echarts.util.DrawPicUtil;
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.*;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.EventDetailNew;
@@ -48,8 +48,6 @@ import com.njcn.event.service.majornetwork.EventDetailService;
import com.njcn.event.service.majornetwork.EventReportService;
import com.njcn.event.service.majornetwork.ReportService;
import com.njcn.event.utils.WordUtils;
import com.njcn.influxdb.utils.InfluxDBCommUtils;
import com.njcn.influxdb.utils.InfluxDbUtils;
import com.njcn.poi.util.PoiUtil;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
@@ -88,12 +86,10 @@ import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
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.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import sun.misc.BASE64Decoder;
@@ -108,30 +104,20 @@ public class ReportServiceImpl implements ReportService {
private final GeneralDeviceInfoClient generalDeviceInfoClient;
private final InfluxDbUtils influxDbUtils;
private final LineFeignClient lineFeignClient;
private final DicDataFeignClient dicDataFeignClient;
private final DeptFeignClient deptFeignClient;
private final RestTemplate restTemplate;
private final EventReportService eventReportService;
//调用暂降密度接口
private final EventAnalysisService eventAnalysisService;
private final PmsGeneralDeviceInfoClient pmsGeneralDeviceInfoClient;
private final MonitorClient monitorClient;
private final PwMonitorClient pwMonitorClient;
private final EventDetailService eventDetailService;
private final EventDetailMapper eventDetailMapper;
private final ReportMapper reportMapper;
private final DrawPicUtil drawPicUtil;
public List<EventDetail> getED(DeviceInfoParam.BusinessParam businessParam, String id) {
@@ -2418,7 +2404,7 @@ public class ReportServiceImpl implements ReportService {
//最后集合
List<TimeSVO> timeSVoList = new ArrayList<>();
//表格参数
String table = "";
String table;
//月
if ("0".equals(areaReportParam.getInterval())) {
@@ -2469,44 +2455,10 @@ public class ReportServiceImpl implements ReportService {
}
}
Map<String, Integer> relevanceCountMap = new HashMap<>();
//获取未关联的暂态事件
Map<String, Long> eventAssDetail = eventDetailList.stream().filter(x -> StrUtil.isBlank(x.getEventassIndex()))
.collect(Collectors.groupingBy(x -> DateUtil.format(DateUtil.parse(x.getStartTime()), fmt), Collectors.counting()));
for (String key : relevanceMap.keySet()) {
List<String> list1 = relevanceMap.get(key).stream().filter(s -> s != "").collect(Collectors.toList());
//如果集合中有id将id进行拼接
if (CollectionUtil.isNotEmpty(list1)) {
StringBuilder stringBuilder = new StringBuilder("(");
for (int i = 0; i < list1.size(); ++i) {
if (list1.size() - i != 1) {
stringBuilder.append("event_time ='").append((String) list1.get(i)).append("' or ");
} else {
stringBuilder.append("event_time ='").append((String) list1.get(i)).append("') ");
}
}
//查询sql语句总条数
StringBuilder stringTotal = new StringBuilder("SELECT COUNT(*) as aa FROM ").append("pqs_eventass").append(" WHERE ")
.append(stringBuilder);
//总条数
QueryResult resultTotal = influxDbUtils.query(stringTotal.toString());
//返回的结果
if (Objects.nonNull(resultTotal.getResults().get(0).getSeries())) {
long count = new BigDecimal(resultTotal.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).longValue();
if (relevanceCountMap.containsKey(key)) {
relevanceCountMap.put(key, relevanceCountMap.get(key) + (int) count);
} else {
relevanceCountMap.put(key, (int) count);
}
}
}
}
//开始时间
LocalDate beginTime = LocalDate.parse(areaReportParam.getSearchBeginTime());
LocalDate end = LocalDate.parse(areaReportParam.getSearchEndTime());
@@ -2536,10 +2488,10 @@ public class ReportServiceImpl implements ReportService {
timeVO.setFulltime(beginTime.toString().substring(0, 7));
//遍历 如果时间相同,将所有关联处理事件次数赋值上去
for (String s : relevanceCountMap.keySet()) {
if (beginTime.toString().substring(0, 7).equals(s)) {
timeVO.setEventAssIndex(relevanceCountMap.get(s));
}
if(eventAssDetail.containsKey(beginTime.toString().substring(0, 7))){
timeVO.setEventAssIndex(Math.toIntExact(eventAssDetail.get(beginTime.toString().substring(0, 7))));
}else{
timeVO.setEventAssIndex(0);
}
timeSVoList.add(timeVO);
} else {
@@ -2572,6 +2524,7 @@ public class ReportServiceImpl implements ReportService {
List<String> dayCount = new ArrayList<>();
List<AreaEventMonthParam> timeList = new ArrayList<>();
//进行for循环获取所有事件的时间
for (EventDetailNew eventDetail : eventDetailList) {
//获取暂降事件时间
@@ -2609,45 +2562,10 @@ public class ReportServiceImpl implements ReportService {
resultMap.put(day, 1);
}
}
//获取未关联的暂态事件
Map<String, Long> eventAssDetail = eventDetailList.stream().filter(x -> StrUtil.isBlank(x.getEventassIndex()))
.collect(Collectors.groupingBy(x -> DateUtil.formatDate(DateUtil.parse(x.getStartTime())), Collectors.counting()));
Map<String, Integer> relevanceCountMap = new HashMap<>();
for (String key : relevanceMap.keySet()) {
List<String> list1 = relevanceMap.get(key).stream().filter(s -> s != "").collect(Collectors.toList());
//如果集合中有id将id进行拼接
if (CollectionUtil.isNotEmpty(list1)) {
StringBuilder stringBuilder = new StringBuilder("(");
for (int i = 0; i < list1.size(); ++i) {
if (list1.size() - i != 1) {
stringBuilder.append("event_time ='").append((String) list1.get(i)).append("' or ");
} else {
stringBuilder.append("event_time ='").append((String) list1.get(i)).append("') ");
}
}
//查询sql语句总条数
StringBuilder stringTotal = new StringBuilder("SELECT COUNT(*) as aa FROM ").append("pqs_eventass").append(" WHERE ")
.append(stringBuilder);
//总条数
QueryResult resultTotal = influxDbUtils.query(stringTotal.toString());
//返回的结果
if (Objects.nonNull(resultTotal.getResults().get(0).getSeries())) {
long count = new BigDecimal(resultTotal.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).longValue();
if (relevanceCountMap.containsKey(key)) {
relevanceCountMap.put(key, relevanceCountMap.get(key) + (int) count);
} else {
relevanceCountMap.put(key, (int) count);
}
}
}
}
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd");
//开始时间
LocalDate beginTime = LocalDate.parse(areaReportParam.getSearchBeginTime(), fmt);
@@ -2677,12 +2595,11 @@ public class ReportServiceImpl implements ReportService {
timeVO.setMonth(beginTime.getMonthValue() + "");
}
timeVO.setFulltime(beginTime.toString());
//遍历 如果时间相同,将所有关联处理事件次数赋值上去
for (String s : relevanceCountMap.keySet()) {
if (beginTime.toString().equals(s)) {
timeVO.setEventAssIndex(relevanceCountMap.get(s));
}
if(eventAssDetail.containsKey(beginTime.toString())){
timeVO.setEventAssIndex(Math.toIntExact(eventAssDetail.get(beginTime.toString())));
}else{
timeVO.setEventAssIndex(0);
}
timeSVoList.add(timeVO);
} else {
@@ -2874,25 +2791,13 @@ public class ReportServiceImpl implements ReportService {
if (areaReportParam.isDensityTable() || areaReportParam.isDensityChart()) {
//暂降密度图形
AreaTableParam areaTableParam = new AreaTableParam();
//监测点id拼接
StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds);
areaTableParam.setStartTime(areaReportParam.getSearchBeginTime());
areaTableParam.setEndTime(areaReportParam.getSearchEndTime());
areaTableParam.setStringBuilder(stringBuilder);
//创建结果集合
// List<EventDetailNew> info = TableInfo(areaTableParam);
List<EventDetailNew> info = eventDetailList;
//将sql结果集放入,共用一个sql,减少查询时间
AreaTableParam areaTableParam1 = new AreaTableParam();
areaTableParam1.setStartTime(areaReportParam.getSearchBeginTime());
areaTableParam1.setEndTime(areaReportParam.getSearchEndTime());
areaTableParam1.setStringBuilder(stringBuilder);
areaTableParam1.setInfo(info);
@@ -4345,29 +4250,6 @@ public class ReportServiceImpl implements ReportService {
//4.itic图
if (areaReportParam.isItic()) {
//itic图
/*
AreaTableParam areaTableParam = new AreaTableParam();
//监测点id拼接
StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds);
areaTableParam.setStartTime(areaReportParam.getSearchBeginTime());
areaTableParam.setEndTime(areaReportParam.getSearchEndTime());
areaTableParam.setStringBuilder(stringBuilder);
//创建结果集合
// List<EventDetailNew> info = TableInfo(areaTableParam);
List<EventDetailNew> info = eventDetailList;
//将sql结果集放入,共用一个sql,减少查询时间
AreaTableParam areaTableParam1 = new AreaTableParam();
areaTableParam1.setStartTime(areaReportParam.getSearchBeginTime());
areaTableParam1.setEndTime(areaReportParam.getSearchEndTime());
areaTableParam1.setStringBuilder(stringBuilder);
areaTableParam1.setInfo(info);
*/
// List<EventDetailNew> detailList = getPlotArea(areaTableParam1);
List<EventDetailNew> detailList = eventDetailList;
List<OB> obs = new ArrayList<>();
@@ -4630,34 +4512,19 @@ public class ReportServiceImpl implements ReportService {
//7.暂降持续时间
if (areaReportParam.isDuration()) {
//持续时间概率分布
AreaTableParam areaTableParam = new AreaTableParam();
//监测点id拼接
StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds);
areaTableParam.setStartTime(areaReportParam.getSearchBeginTime());
areaTableParam.setEndTime(areaReportParam.getSearchEndTime());
areaTableParam.setStringBuilder(stringBuilder);
//创建结果集合
// List<EventDetailNew> info = TableInfo(areaTableParam);
List<EventDetailNew> info = eventDetailList;
//将sql结果集放入,共用一个sql,减少查询时间
AreaTableParam areaTableParam1 = new AreaTableParam();
areaTableParam1.setStartTime(areaReportParam.getSearchBeginTime());
areaTableParam1.setEndTime(areaReportParam.getSearchEndTime());
areaTableParam1.setStringBuilder(stringBuilder);
areaTableParam1.setInfo(info);
ProbabilityVO probabilityDistributionArea = getProbabilityDistributionArea(areaTableParam1);
// System.out.println(probabilityDistributionArea);
List<String> eventvalue = probabilityDistributionArea.getEventvalue();
List<AmplitudeCountParam> amplitudeList = new ArrayList<>();
List<String> xName = new ArrayList<>();
@@ -4780,48 +4647,26 @@ public class ReportServiceImpl implements ReportService {
if (areaReportParam.isEventRelevanceCountTable()) {
//事件关联统计表格
//创建存储总次数的集合
Map<String, Integer> resultCount = new HashMap<>();
//创建存储time的集合
Map<String, String> timeCount = new HashMap<>();
int resultCount1 = 0;
int resultCount = 0;
List<EventassCountParam> resultList = new ArrayList<>();
List<EventDetailNew> eventList = eventDetailList.stream().filter(e -> e.getEventassIndex() != "").collect(Collectors.toList());
List<EventDetailNew> eventList = eventDetailList.stream().filter(e ->StrUtil.isNotBlank(e.getEventassIndex())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(eventList)) {
//记录条数
resultCount.put("count", eventList.size());
resultCount= eventList.size();
List<String> ids = eventList.stream().map(EventDetailNew::getEventassIndex).collect(Collectors.toList());
List<Eventass> eventAssList = eventDetailMapper.ListEventass(ids);
//将时间数存入集合Map集合主数据
for (EventDetailNew detail : eventList) {
timeCount.put(detail.getEventassIndex(), detail.getStartTime());
}
//时间拼接 event_time=getEventassIndex
StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParamAndName(new ArrayList<>(timeCount.keySet()), "event_time");
StringBuilder stringResult1 = new StringBuilder(Param.SELECT).append("pqs_eventass").append(Param.WHERE)
.append(stringBuilder);
// .append("event_time = '").append(stringBuilder).append("' ");
//结果集
QueryResult result1 = influxDbUtils.query(stringResult1.toString());
//结果集映射到对象中
List<Eventass> eventassList = influxDBResultMapper.toPOJO(result1, Eventass.class);
for (Eventass eventass : eventassList) {
for (Eventass eventass : eventAssList) {
EventassCountParam eventassCountParam = new EventassCountParam();
eventassCountParam.setAssTime(eventass.getTimeId().toString());
String dateTime = LocalDateTimeUtil.format(eventass.getTimeId(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
eventassCountParam.setAssTime(dateTime);
//获取时间
String eventTime = timeCount.get(eventass.getEventTime());
eventassCountParam.setEventTime(eventTime);
eventassCountParam.setDescribe(eventass.getDescribe());
eventassCountParam.setEventTime(dateTime);
eventassCountParam.setDescribe(eventass.getContentDes());
resultList.add(eventassCountParam);
}
} else {
resultCount.put("count", 0);
}
createTitle(doc, "4." + oneCount + " 事件关联分析", "标题 2", 200, 11);
@@ -4830,7 +4675,7 @@ public class ReportServiceImpl implements ReportService {
p.setAlignment(ParagraphAlignment.BOTH);
XWPFRun r12 = p.createRun();//创建段落文本
//归一化需要高级算法,先字符串代替
r12.setText(" " + deptName + "电网在所选择的分析时间段内累计监测" + typeName + "记录" + resultCount.get("count") + "条,归一化统计后共" + resultCount1 + "[此为归一化后的暂态事件结果]条,,具体如下图所示:");
r12.setText(" " + deptName + "电网在所选择的分析时间段内累计监测" + typeName + "记录" + eventCount + "条,归一化统计后共" + resultCount + "[此为归一化后的暂态事件结果]条,,具体如下图所示:");
r12.setFontSize(11);//字体大小
@@ -5498,7 +5343,7 @@ public class ReportServiceImpl implements ReportService {
String table = "";
//月
if ("3".equals(areaReportParam.getInterval())) {
if ("0".equals(areaReportParam.getInterval())) {
table = "月份";
List<String> dayCount = new ArrayList<>();
@@ -5507,10 +5352,6 @@ public class ReportServiceImpl implements ReportService {
//进行for循环获取所有事件的时间
for (EventDetailNew eventDetail : eventDetailList) {
//获取暂降事件时间
/* String timeId = eventDetail.getTimeId();
Date date1 = DateUtil.parse(timeId);
int day = Integer.parseInt(String.format("%td",date1));*/
dayCount.add(DateUtil.format(DateUtil.parse(eventDetail.getStartTime()), fmt));
//创建对象
@@ -5545,45 +5386,11 @@ public class ReportServiceImpl implements ReportService {
resultMap.put(day, 1);
}
}
Map<String, Integer> relevanceCountMap = new HashMap<>();
for (String key : relevanceMap.keySet()) {
List<String> list1 = relevanceMap.get(key).stream().filter(s -> s != "").collect(Collectors.toList());
//如果集合中有id将id进行拼接
if (CollectionUtil.isNotEmpty(list1)) {
StringBuilder stringBuilder = new StringBuilder("(");
for (int i = 0; i < list1.size(); ++i) {
if (list1.size() - i != 1) {
stringBuilder.append("event_time ='").append((String) list1.get(i)).append("' or ");
} else {
stringBuilder.append("event_time ='").append((String) list1.get(i)).append("') ");
}
}
//获取未关联的暂态事件
Map<String, Long> eventAssDetail = eventDetailList.stream().filter(x -> StrUtil.isBlank(x.getEventassIndex()))
.collect(Collectors.groupingBy(x -> DateUtil.format(DateUtil.parse(x.getStartTime()), fmt), Collectors.counting()));
//查询sql语句总条数
StringBuilder stringTotal = new StringBuilder("SELECT COUNT(*) as aa FROM ").append("pqs_eventass").append(" WHERE ")
.append(stringBuilder);
//总条数
QueryResult resultTotal = influxDbUtils.query(stringTotal.toString());
//返回的结果
if (Objects.nonNull(resultTotal.getResults().get(0).getSeries())) {
long count = new BigDecimal(resultTotal.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).longValue();
if (relevanceCountMap.containsKey(key)) {
relevanceCountMap.put(key, relevanceCountMap.get(key) + (int) count);
} else {
relevanceCountMap.put(key, (int) count);
}
}
}
}
//开始时间
LocalDate beginTime = LocalDate.parse(areaReportParam.getSearchBeginTime());
LocalDate end = LocalDate.parse(areaReportParam.getSearchEndTime());
@@ -5612,12 +5419,11 @@ public class ReportServiceImpl implements ReportService {
}
timeVO.setFulltime(beginTime.toString().substring(0, 7));
//遍历 如果时间相同,将所有关联处理事件次数赋值上去
for (String s : relevanceCountMap.keySet()) {
if (beginTime.toString().substring(0, 7).equals(s)) {
timeVO.setEventAssIndex(relevanceCountMap.get(s));
}
if(eventAssDetail.containsKey(beginTime.toString().substring(0, 7))){
timeVO.setEventAssIndex(Math.toIntExact(eventAssDetail.get(beginTime.toString().substring(0, 7))));
}else{
timeVO.setEventAssIndex(0);
}
timeSVoList.add(timeVO);
} else {
@@ -5691,44 +5497,10 @@ public class ReportServiceImpl implements ReportService {
}
}
Map<String, Integer> relevanceCountMap = new HashMap<>();
//获取未关联的暂态事件
Map<String, Long> eventAssDetail = eventDetailList.stream().filter(x -> StrUtil.isBlank(x.getEventassIndex()))
.collect(Collectors.groupingBy(x -> DateUtil.formatDate(DateUtil.parse(x.getStartTime())), Collectors.counting()));
for (String key : relevanceMap.keySet()) {
List<String> list1 = relevanceMap.get(key).stream().filter(s -> s != "").collect(Collectors.toList());
//如果集合中有id将id进行拼接
if (CollectionUtil.isNotEmpty(list1)) {
StringBuilder stringBuilder = new StringBuilder("(");
for (int i = 0; i < list1.size(); ++i) {
if (list1.size() - i != 1) {
stringBuilder.append("event_time ='").append((String) list1.get(i)).append("' or ");
} else {
stringBuilder.append("event_time ='").append((String) list1.get(i)).append("') ");
}
}
//查询sql语句总条数
StringBuilder stringTotal = new StringBuilder("SELECT COUNT(*) as aa FROM ").append("pqs_eventass").append(" WHERE ")
.append(stringBuilder);
//总条数
QueryResult resultTotal = influxDbUtils.query(stringTotal.toString());
//返回的结果
if (Objects.nonNull(resultTotal.getResults().get(0).getSeries())) {
long count = new BigDecimal(resultTotal.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).longValue();
if (relevanceCountMap.containsKey(key)) {
relevanceCountMap.put(key, relevanceCountMap.get(key) + (int) count);
} else {
relevanceCountMap.put(key, (int) count);
}
}
}
}
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd");
//开始时间
LocalDate beginTime = LocalDate.parse(areaReportParam.getSearchBeginTime(), fmt);
@@ -5758,12 +5530,11 @@ public class ReportServiceImpl implements ReportService {
timeVO.setMonth(beginTime.getMonthValue() + "");
}
timeVO.setFulltime(beginTime.toString());
//遍历 如果时间相同,将所有关联处理事件次数赋值上去
for (String s : relevanceCountMap.keySet()) {
if (beginTime.toString().equals(s)) {
timeVO.setEventAssIndex(relevanceCountMap.get(s));
}
if(eventAssDetail.containsKey(beginTime.toString())){
timeVO.setEventAssIndex(Math.toIntExact(eventAssDetail.get(beginTime.toString())));
}else{
timeVO.setEventAssIndex(0);
}
timeSVoList.add(timeVO);
} else {
@@ -5957,25 +5728,13 @@ public class ReportServiceImpl implements ReportService {
if (areaReportParam.isDensityTable() || areaReportParam.isDensityChart()) {
//暂降密度图形
AreaTableParam areaTableParam = new AreaTableParam();
//监测点id拼接
StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds);
areaTableParam.setStartTime(areaReportParam.getSearchBeginTime());
areaTableParam.setEndTime(areaReportParam.getSearchEndTime());
areaTableParam.setStringBuilder(stringBuilder);
//创建结果集合
// List<EventDetailNew> info = TableInfo(areaTableParam);
List<EventDetailNew> info = eventDetailList;
//将sql结果集放入,共用一个sql,减少查询时间
AreaTableParam areaTableParam1 = new AreaTableParam();
areaTableParam1.setStartTime(areaReportParam.getSearchBeginTime());
areaTableParam1.setEndTime(areaReportParam.getSearchEndTime());
areaTableParam1.setStringBuilder(stringBuilder);
areaTableParam1.setInfo(info);
@@ -7690,30 +7449,19 @@ public class ReportServiceImpl implements ReportService {
//7.暂降持续时间
if (areaReportParam.isDuration()) {
//持续时间概率分布
AreaTableParam areaTableParam = new AreaTableParam();
//监测点id拼接
StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds);
areaTableParam.setStartTime(areaReportParam.getSearchBeginTime());
areaTableParam.setEndTime(areaReportParam.getSearchEndTime());
areaTableParam.setStringBuilder(stringBuilder);
//创建结果集合
// List<EventDetailNew> info = TableInfo(areaTableParam);
List<EventDetailNew> info = eventDetailList;
//将sql结果集放入,共用一个sql,减少查询时间
AreaTableParam areaTableParam1 = new AreaTableParam();
areaTableParam1.setStartTime(areaReportParam.getSearchBeginTime());
areaTableParam1.setEndTime(areaReportParam.getSearchEndTime());
areaTableParam1.setStringBuilder(stringBuilder);
areaTableParam1.setInfo(info);
ProbabilityVO probabilityDistributionArea = getProbabilityDistributionArea(areaTableParam1);
// System.out.println(probabilityDistributionArea);
List<String> eventvalue = probabilityDistributionArea.getEventvalue();
@@ -7838,48 +7586,27 @@ public class ReportServiceImpl implements ReportService {
//8.事件关联统计表格
if (areaReportParam.isEventRelevanceCountTable()) {
//事件关联统计表格
//创建存储总次数的集合
Map<String, Integer> resultCount = new HashMap<>();
//创建存储time的集合
Map<String, String> timeCount = new HashMap<>();
int resultCount1 = 0;
int resultCount = 0;
List<EventassCountParam> resultList = new ArrayList<>();
List<EventDetailNew> eventList = eventDetailList.stream().filter(e -> e.getEventassIndex() != "").collect(Collectors.toList());
List<EventDetailNew> eventList = eventDetailList.stream().filter(e ->StrUtil.isNotBlank(e.getEventassIndex())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(eventList)) {
//记录条数
resultCount.put("count", eventList.size());
resultCount= eventList.size();
//将时间数存入集合Map集合主数据
for (EventDetailNew detail : eventList) {
timeCount.put(detail.getEventassIndex(), detail.getStartTime());
}
List<String> ids = eventList.stream().map(EventDetailNew::getEventassIndex).collect(Collectors.toList());
List<Eventass> eventAssList = eventDetailMapper.ListEventass(ids);
//时间拼接 event_time=getEventassIndex
StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParamAndName(new ArrayList<>(timeCount.keySet()), "event_time");
StringBuilder stringResult1 = new StringBuilder(Param.SELECT).append("pqs_eventass").append(Param.WHERE).
append("event_time = '").append(stringBuilder).append("' ");
//结果集
QueryResult result1 = influxDbUtils.query(stringResult1.toString());
//结果集映射到对象中
List<Eventass> eventassList = influxDBResultMapper.toPOJO(result1, Eventass.class);
for (Eventass eventass : eventassList) {
for (Eventass eventass : eventAssList) {
EventassCountParam eventassCountParam = new EventassCountParam();
eventassCountParam.setAssTime(eventass.getTimeId().toString());
String dateTime = LocalDateTimeUtil.format(eventass.getTimeId(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
eventassCountParam.setAssTime(dateTime);
//获取时间
String eventTime = timeCount.get(eventass.getEventTime());
eventassCountParam.setEventTime(eventTime);
eventassCountParam.setDescribe(eventass.getDescribe());
eventassCountParam.setEventTime(dateTime);
eventassCountParam.setDescribe(eventass.getContentDes());
resultList.add(eventassCountParam);
}
} else {
resultCount.put("count", 0);
}
@@ -7889,7 +7616,7 @@ public class ReportServiceImpl implements ReportService {
p.setAlignment(ParagraphAlignment.BOTH);
XWPFRun r12 = p.createRun();//创建段落文本
//归一化需要高级算法,先字符串代替
r12.setText(" " + deptName + "电网在所选择的分析时间段内累计监测" + typeName + "记录" + resultCount.get("count") + "条,归一化统计后共" + resultCount1 + "[此为归一化后的暂态事件结果]条,,具体如下图所示:");
r12.setText(" " + deptName + "电网在所选择的分析时间段内累计监测" + typeName + "记录" + eventCount+ "条,归一化统计后共" + resultCount + "[此为归一化后的暂态事件结果]条,,具体如下图所示:");
r12.setFontSize(11);//字体大小