代码调整

This commit is contained in:
2023-06-25 21:51:19 +08:00
parent e19cb5e732
commit 3855accc61
8 changed files with 309 additions and 193 deletions

View File

@@ -74,5 +74,5 @@ public interface EventReportService {
* @param info
* @return
*/
List<CoordsVO> getCoords(List<EventDetail> info);
Integer[][] getCoords(List<EventDetail> info);
}

View File

@@ -1,4 +1,5 @@
package com.njcn.event.service.majornetwork.Impl;
import com.google.common.collect.Lists;
import cn.hutool.core.date.DateUtil;
@@ -822,7 +823,7 @@ public class EventReportServiceImpl implements EventReportService {
}
@Override
public List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam,List<EventDetail> info) throws ParseException {
public List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam, List<EventDetail> info) throws ParseException {
List<TimeVO> list = new ArrayList<>();
//参数
StringBuilder builder1 = new StringBuilder();
@@ -837,7 +838,7 @@ public class EventReportServiceImpl implements EventReportService {
Integer endMonth = Integer.parseInt(endTime.substring(5, 7));
Integer startYear = Integer.parseInt(startTime.substring(0, 4));
Integer endYear = Integer.parseInt(endTime.substring(0, 4));
if (statisticsParam.getFlag()==0){
if (statisticsParam.getFlag() == 0) {
while (!startYear.equals(endYear) && !startMonth.equals(endMonth)) {
builder1.delete(0, builder1.length());
builder2.delete(0, builder2.length());
@@ -847,14 +848,14 @@ public class EventReportServiceImpl implements EventReportService {
} else {
builder2.append(startYear).append("-").append(startMonth + 1).append("-").append(startDays);
}
query = MonitorQuery(new StatisticsParam(statisticsParam.getLineIndex(),builder1.toString(), builder2.toString(), statisticsParam.getFlag()));
query = MonitorQuery(new StatisticsParam(statisticsParam.getLineIndex(), builder1.toString(), builder2.toString(), statisticsParam.getFlag()));
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
List<EventDetail> eventDetailList = influxDBResultMapper.toPOJO(query, EventDetail.class);
long count = eventDetailList.stream().filter(x -> x.getEventType() == "1").count();
if (startMonth < 10) {
list.add(new TimeVO(null, null,"", "0" + startMonth.toString(), count+"", startYear.toString(), startYear.toString()+"-"+"0"+startMonth.toString()));
list.add(new TimeVO(null, null, "", "0" + startMonth.toString(), count + "", startYear.toString(), startYear.toString() + "-" + "0" + startMonth.toString()));
} else {
list.add(new TimeVO(null, null,"", startMonth.toString(), count+"", startYear.toString(),startYear.toString()+"-"+startMonth.toString()));
list.add(new TimeVO(null, null, "", startMonth.toString(), count + "", startYear.toString(), startYear.toString() + "-" + startMonth.toString()));
}
startMonth++;
if (startMonth == 13) {
@@ -866,63 +867,62 @@ public class EventReportServiceImpl implements EventReportService {
builder2.delete(0, builder2.length());
builder1.append(startYear).append("-").append(startMonth).append("-").append(startDays);
builder2.append(startYear).append("-").append(startMonth).append("-").append(endDays);
query = MonitorQuery(new StatisticsParam(statisticsParam.getLineIndex(),builder1.toString(), builder2.toString(), statisticsParam.getFlag()));
query = MonitorQuery(new StatisticsParam(statisticsParam.getLineIndex(), builder1.toString(), builder2.toString(), statisticsParam.getFlag()));
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
List<EventDetail> eventDetailList = influxDBResultMapper.toPOJO(query, EventDetail.class);
long count1 = eventDetailList.stream().filter(x -> x.getEventType() == "1").count();
if (startMonth < 10) {
list.add(new TimeVO(null, null,"", "0" + startMonth.toString(), count1+"", startYear.toString(), startYear.toString()+"-"+"0"+startMonth.toString()));
list.add(new TimeVO(null, null, "", "0" + startMonth.toString(), count1 + "", startYear.toString(), startYear.toString() + "-" + "0" + startMonth.toString()));
} else {
list.add(new TimeVO(null, null,"", startMonth.toString(), count1+"", startYear.toString(),startYear.toString()+"-"+startMonth.toString()));
list.add(new TimeVO(null, null, "", startMonth.toString(), count1 + "", startYear.toString(), startYear.toString() + "-" + startMonth.toString()));
}
return list;
}
else {
} else {
QueryResult monitorQuery = MonitorQuery(statisticsParam);
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
List<EventDetailNew> eventDetailList = influxDBResultMapper.toPOJO(monitorQuery, EventDetailNew.class);
Map<String, List<EventDetailNew>> map = eventDetailList.stream().filter(x -> x.getEventType()=="1").collect(Collectors.groupingBy(s -> s.getStartTime().substring(0, 10)));
Map<String, List<EventDetailNew>> map = eventDetailList.stream().filter(x -> x.getEventType() == "1").collect(Collectors.groupingBy(s -> s.getStartTime().substring(0, 10)));
Set<String> keySet = map.keySet();
LocalDate parse1 = LocalDate.parse(startTime);
LocalDate parse2 = LocalDate.parse(endTime);
while (!parse1.equals(parse2.plus(1, ChronoUnit.DAYS))){
if (keySet.contains(parse1.toString())){
while (!parse1.equals(parse2.plus(1, ChronoUnit.DAYS))) {
if (keySet.contains(parse1.toString())) {
List<EventDetailNew> eventDetailNews = map.get(parse1.toString());
TimeVO timeVO = new TimeVO();
timeVO.setTimes(eventDetailNews.size()+"");
if (parse1.getDayOfMonth()<10){
timeVO.setDay("0"+parse1.getDayOfMonth()+"");
}else {
timeVO.setDay(parse1.getDayOfMonth()+"");
timeVO.setTimes(eventDetailNews.size() + "");
if (parse1.getDayOfMonth() < 10) {
timeVO.setDay("0" + parse1.getDayOfMonth() + "");
} else {
timeVO.setDay(parse1.getDayOfMonth() + "");
}
timeVO.setYear(parse1.getYear()+"");
if (parse1.getMonthValue()<10){
timeVO.setMonth("0"+parse1.getMonthValue()+"");
}else {
timeVO.setMonth(parse1.getMonthValue()+"");
timeVO.setYear(parse1.getYear() + "");
if (parse1.getMonthValue() < 10) {
timeVO.setMonth("0" + parse1.getMonthValue() + "");
} else {
timeVO.setMonth(parse1.getMonthValue() + "");
}
timeVO.setFulltime(parse1.toString());
list.add(timeVO);
}else {
} else {
TimeVO timeVO = new TimeVO();
timeVO.setTimes("0");
if (parse1.getDayOfMonth()<10){
timeVO.setDay("0"+parse1.getDayOfMonth()+"");
}else {
timeVO.setDay(parse1.getDayOfMonth()+"");
if (parse1.getDayOfMonth() < 10) {
timeVO.setDay("0" + parse1.getDayOfMonth() + "");
} else {
timeVO.setDay(parse1.getDayOfMonth() + "");
}
timeVO.setYear(parse1.getYear()+"");
if (parse1.getMonthValue()<10){
timeVO.setMonth("0"+parse1.getMonthValue()+"");
}else {
timeVO.setMonth(parse1.getMonthValue()+"");
timeVO.setYear(parse1.getYear() + "");
if (parse1.getMonthValue() < 10) {
timeVO.setMonth("0" + parse1.getMonthValue() + "");
} else {
timeVO.setMonth(parse1.getMonthValue() + "");
}
timeVO.setFulltime(parse1.toString());
list.add(timeVO);
}
parse1=parse1.plus(1, ChronoUnit.DAYS);
parse1 = parse1.plus(1, ChronoUnit.DAYS);
}
return list;
}
@@ -931,10 +931,11 @@ public class EventReportServiceImpl implements EventReportService {
/**
* 暂降事件点图
*
* @author wr
*/
@Override
public List<EventDetail> getPlot(List<EventDetail> info,List<DictData> reasonData,List<DictData> typeData) {
public List<EventDetail> getPlot(List<EventDetail> info, List<DictData> reasonData, List<DictData> typeData) {
//添加detail
for (EventDetail detail : info) {
for (DictData data : reasonData) {
@@ -952,7 +953,7 @@ public class EventReportServiceImpl implements EventReportService {
}
@Override
public StatisticVO getStatistic(List<EventDetail> info,List<DictData> reasonData,List<DictData>typeData) {
public StatisticVO getStatistic(List<EventDetail> info, List<DictData> reasonData, List<DictData> typeData) {
StatisticVO result = new StatisticVO();
List<EventDetail> list = new ArrayList<>();
List<ReasonsVO> reasonsVOS = new ArrayList<>();
@@ -963,13 +964,13 @@ public class EventReportServiceImpl implements EventReportService {
//添加detail
for (EventDetail detail : info) {
for (DictData data : reasonData) {
reasonMap.put(data.getName(),0);
reasonMap.put(data.getName(), 0);
if (detail.getAdvanceReason().equals(data.getId())) {
detail.setAdvanceReason(data.getName());
}
}
for (DictData data : typeData) {
typeMap.put(data.getName(),0);
typeMap.put(data.getName(), 0);
if (detail.getAdvanceType().equals(data.getId())) {
detail.setAdvanceType(data.getName());
}
@@ -1002,17 +1003,18 @@ public class EventReportServiceImpl implements EventReportService {
return result;
}
@Override
public List<CoordsVO> getCoords(List<EventDetail> info) {
List<CoordsVO> result = new ArrayList<>();
public Integer[][] getCoords(List<EventDetail> info) {
Integer[][] eventDensityData = new Integer[90][3];
for (int i = 0; i < 10; i++) {
// eventDensityData[i] = new Integer[]{i % 10, i % 9, 0};
for (int j = 0; j < 9; j++) {
result.add(new CoordsVO(i, j, 0));
eventDensityData[i * 9 + j] = new Integer[]{i, j % 9, 0};
}
}
for (int i = 0; i < info.size(); i++) {
Integer index = null;
CoordsVO dto = new CoordsVO();
if (info.get(i).getFeatureAmplitude() >= 0 && info.get(i).getFeatureAmplitude() <= 0.1) {
if (info.get(i).getDuration() / 1000 > 0 && info.get(i).getDuration() / 1000 <= 0.020) {
index = 0;
@@ -1215,11 +1217,11 @@ public class EventReportServiceImpl implements EventReportService {
}
}
if (Objects.nonNull(index)) {
CoordsVO coordsVO = result.get(index);
coordsVO.setZ(coordsVO.getZ() + 1);
Integer[] temNumber = eventDensityData[index];
temNumber[2] = temNumber[2] + 1;
}
}
return result;
return eventDensityData;
}
/**

View File

@@ -1848,11 +1848,8 @@ public class ReportServiceImpl implements ReportService {
int two = 1;
if (exportParam.isMdtx()) {
createTitle(doc, "4." + i + "." + two + " 暂降密度点图", "标题 3", 400, 15);
List<CoordsVO> coords = eventReportService.getCoords(info);
Integer[][] a = new Integer[87][];
HashMap<String, Object> map = new HashMap<>();
map.put("data", JSONArray.fromObject(coords).toString());
String str = getStr("bar10.ftl", map);
Integer[][] eventDensityData = eventReportService.getCoords(info);
String str = drawPicUtil.drawEventDensity(eventDensityData);
createPic(doc, str, "暂降密度图");
two++;
}