diff --git a/pqs-common/common-influxdb/src/main/java/com/njcn/influxdb/utils/InfluxDBCommUtils.java b/pqs-common/common-influxdb/src/main/java/com/njcn/influxdb/utils/InfluxDBCommUtils.java index e5593181e..9f43040ac 100644 --- a/pqs-common/common-influxdb/src/main/java/com/njcn/influxdb/utils/InfluxDBCommUtils.java +++ b/pqs-common/common-influxdb/src/main/java/com/njcn/influxdb/utils/InfluxDBCommUtils.java @@ -53,4 +53,23 @@ public class InfluxDBCommUtils { } return lineIdsStr; } + + /** + * 组装为influxdb监测点参数 + * + * @param devIds 设备ids参数 + * @param name 列明 + * @return StringBuilder + */ + public static StringBuilder assToInfluxParamAndName(@NotEmpty List devIds,String name){ + StringBuilder lineIdsStr = new StringBuilder("("); + for (int i = 0; i < devIds.size(); i++) { + if (devIds.size() - i != 1) { + lineIdsStr.append(name+" ='").append(devIds.get(i)).append("' or "); + } else { + lineIdsStr.append(name+" ='").append(devIds.get(i)).append("') "); + } + } + return lineIdsStr; + } } diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AreaTableParam.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AreaTableParam.java index 8dcd75aa5..d428fbf8e 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AreaTableParam.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AreaTableParam.java @@ -24,11 +24,9 @@ public class AreaTableParam implements Serializable { @ApiModelProperty(name = "StringBuilder", value = "监测点拼接的字符串") private StringBuilder stringBuilder; - @ApiModelProperty(name = "startTime", value = "开始时间") private String startTime; - @ApiModelProperty(name = "endTime", value = "结束时间") private String endTime; @@ -36,7 +34,7 @@ public class AreaTableParam implements Serializable { private List info; @ApiModelProperty(name = "waveType", value = "暂态类型") - private Integer waveType; + private Integer waveType; } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/ReportController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/ReportController.java index c12183c0c..cc5f30575 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/ReportController.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/ReportController.java @@ -48,80 +48,80 @@ public class ReportController extends BaseController { @PostMapping("/getGeneralSituation") @ApiOperation("暂态总体概况(区域)") @ApiImplicitParam(name = "businessParam", value = "暂态总体概况区域参数", required = true) - public HttpResult> getGeneralSituation(@RequestBody @Validated DeviceInfoParam.BusinessParam businessParam){ + public HttpResult> getGeneralSituation(@RequestBody @Validated DeviceInfoParam.BusinessParam businessParam) { String methodDescribe = getMethodDescribe("getGeneralSituation"); List page = reportService.getGeneralSituation(businessParam); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,page,methodDescribe); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe); } @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/getVoltage") @ApiOperation("暂态总体概况(电压)") @ApiImplicitParam(name = "businessParam", value = "暂态总体概况电压参数", required = true) - public HttpResult> getVoltage(@RequestBody @Validated DeviceInfoParam.BusinessParam businessParam){ + public HttpResult> getVoltage(@RequestBody @Validated DeviceInfoParam.BusinessParam businessParam) { String methodDescribe = getMethodDescribe("getVoltage"); List page = reportService.getVoltage(businessParam); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,page,methodDescribe); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe); } @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/getSeverity") @ApiOperation("暂态严重度") @ApiImplicitParam(name = "businessParam", value = "暂态严重度参数", required = true) - public HttpResult> getSeverity(@RequestBody @Validated DeviceInfoParam.BusinessParam businessParam){ + public HttpResult> getSeverity(@RequestBody @Validated DeviceInfoParam.BusinessParam businessParam) { String methodDescribe = getMethodDescribe("getSeverity"); List page = reportService.getSeverity(businessParam); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,page,methodDescribe); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe); } @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/getReason") @ApiOperation("暂态原因统计表") @ApiImplicitParam(name = "businessParam", value = "暂态严重度参数", required = true) - public HttpResult> getReason(@RequestBody @Validated DeviceInfoParam.BusinessParam businessParam){ + public HttpResult> getReason(@RequestBody @Validated DeviceInfoParam.BusinessParam businessParam) { String methodDescribe = getMethodDescribe("getSeverity"); List page = reportService.getReason(businessParam); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,page,methodDescribe); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe); } @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/getContinueTime") @ApiOperation("详细事件列表") @ApiImplicitParam(name = "businessParam", value = "详细时间列表参数", required = true) - public HttpResult> getContinueTime(@RequestBody @Validated WaveTypeParam businessParam){ + public HttpResult> getContinueTime(@RequestBody @Validated WaveTypeParam businessParam) { String methodDescribe = getMethodDescribe("getContinueTime"); Page page = reportService.getContinueTime(businessParam); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,page,methodDescribe); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe); } @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/getSagTimes") @ApiOperation("暂降次数统计") @ApiImplicitParam(name = "waveTypeParam", value = "暂降次数统计参数", required = true) - public HttpResult> getSagTimes(@RequestBody @Validated WaveTypeParam waveTypeParam){ + public HttpResult> getSagTimes(@RequestBody @Validated WaveTypeParam waveTypeParam) { String methodDescribe = getMethodDescribe("getSagTimes"); Page page = reportService.getSagTimes(waveTypeParam); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,page,methodDescribe); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe); } @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/getUpTimes") @ApiOperation("暂升次数统计") @ApiImplicitParam(name = "waveTypeParam", value = "暂升次数统计参数", required = true) - public HttpResult> getUpTimes(@RequestBody @Validated WaveTypeParam waveTypeParam){ + public HttpResult> getUpTimes(@RequestBody @Validated WaveTypeParam waveTypeParam) { String methodDescribe = getMethodDescribe("getUpTimes"); Page page = reportService.getUpTimes(waveTypeParam); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,page,methodDescribe); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe); } @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/getBreakTimes") @ApiOperation("中断次数统计") @ApiImplicitParam(name = "waveTypeParam", value = "中断次数统计参数", required = true) - public HttpResult> getBreakTimes(@RequestBody @Validated WaveTypeParam waveTypeParam){ + public HttpResult> getBreakTimes(@RequestBody @Validated WaveTypeParam waveTypeParam) { String methodDescribe = getMethodDescribe("getBreakTimes"); Page page = reportService.getBreakTimes(waveTypeParam); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,page,methodDescribe); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe); } @OperateInfo(info = LogEnum.BUSINESS_COMMON) @@ -129,7 +129,7 @@ public class ReportController extends BaseController { @ApiOperation("周报导出") @ApiImplicitParam(name = "businessParam", value = "周报导出参数", required = true) public void getExport(@RequestBody @Validated DeviceInfoParam.BusinessParam businessParam, HttpServletResponse response) throws TemplateException, IOException { - reportService.getExport(businessParam,response); + reportService.getExport(businessParam, response); } @OperateInfo(info = LogEnum.BUSINESS_COMMON) @@ -137,7 +137,7 @@ public class ReportController extends BaseController { @ApiOperation("监测点报告导出") @ApiImplicitParam(name = "exportParam", value = "监测点报告导出参数", required = true) public void getLineExport(@RequestBody @Validated ExportParam exportParam, HttpServletResponse response) throws IOException, InvalidFormatException, TemplateException, ParseException { - reportService.getLineExport(exportParam,response); + reportService.getLineExport(exportParam, response); // @RequestParam(name = "lineIndex") String lineIndex,@RequestParam(name = "startTime") String startTime,@RequestParam(name = "endTime") String endTime,@RequestParam("flag")Integer flag // ExportParam exportParam = new ExportParam(); @@ -175,7 +175,8 @@ public class ReportController extends BaseController { } /** - *获取事件报告 + * 获取事件报告 + * * @author zbj * @date 2022/7/29 */ @@ -190,7 +191,8 @@ public class ReportController extends BaseController { } /** - *获取区域报告 + * 获取区域报告 + * * @author zbj * @date 2022/8/4 */ @@ -199,10 +201,9 @@ public class ReportController extends BaseController { @ApiOperation("获取区域报告") @ApiImplicitParam(name = "areaReportParam", value = "参数体", required = true) public void getAreaReport(@RequestBody @Validated AreaReportParam areaReportParam, HttpServletResponse response) throws Exception { - reportService.getAreaReport(areaReportParam,response); + reportService.getAreaReport(areaReportParam, response); } - } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/EventReportService.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/EventReportService.java new file mode 100644 index 000000000..518f5cebd --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/EventReportService.java @@ -0,0 +1,72 @@ +package com.njcn.event.service.majornetwork; + +import com.njcn.event.pojo.param.StatisticsParam; +import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.pojo.vo.*; +import com.njcn.system.pojo.po.DictData; + +import java.text.ParseException; +import java.util.List; + +/** + * <监测点报表> + * + * @author wr + * @createTime: 2023-02-10 + */ +public interface EventReportService { + + /** + *获取Disdip表格(监测点报表专用) + * @param info influxdb查询结果(pqs_eventdetail表) + * @return + */ + List eventDisdip(List info); + + /** + * 获取IEC411数据 + * @param info influxdb查询结果(pqs_eventdetail表) + * @return + */ + List IEC411(List info); + + /** + * 获取IEC28数据 + * @param info influxdb查询结果(pqs_eventdetail表) + * @return + */ + List IEC28(List info); + + /** + *暂降幅值概率分布 + * @param info2 influxdb查询结果(pqs_eventdetail表) + * @return + */ + ProbabilityVO getProbabilityDistribution(List info2); + + /** + * 获取时间列表(月份统计) + * @param info influxdb查询结果(pqs_eventdetail表) + * @return + */ + List getReasonTypeTime(StatisticsParam statisticsParam,List info) throws ParseException; + + /** + * 获取点状表格数据2.1 + * @param info 结果集 + * @param reasonData 暂降原因 + * @param typeData 暂降类型 + * @return + */ + List getPlot(List info, List reasonData, List typeData); + + /** + * 获取详细数据对象 + * @param info + * @param reasonData + * @param typeData + * @return + */ + StatisticVO getStatistic(List info,List reasonData,ListtypeData); + +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/EventReportServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/EventReportServiceImpl.java new file mode 100644 index 000000000..d16a23922 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/EventReportServiceImpl.java @@ -0,0 +1,1022 @@ +package com.njcn.event.service.majornetwork.Impl; +import com.google.common.collect.Lists; + +import cn.hutool.core.date.DateUtil; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.event.pojo.constant.Param; +import com.njcn.event.pojo.param.StatisticsParam; +import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.pojo.po.EventDetailNew; +import com.njcn.event.pojo.vo.*; +import com.njcn.event.service.majornetwork.EventReportService; +import com.njcn.event.service.majornetwork.ReportService; +import com.njcn.influxdb.utils.InfluxDbUtils; +import com.njcn.system.enums.DicDataTypeEnum; +import com.njcn.system.pojo.po.DictData; +import lombok.RequiredArgsConstructor; +import org.influxdb.dto.QueryResult; +import org.influxdb.impl.InfluxDBResultMapper; +import org.springframework.stereotype.Service; + +import java.text.ParseException; +import java.time.LocalDate; +import java.time.temporal.ChronoUnit; +import java.util.*; +import java.util.stream.Collectors; + +/** + * <功能描述> + * + * @author wr + * @createTime: 2023-02-10 + */ +@Service +@RequiredArgsConstructor +public class EventReportServiceImpl implements EventReportService { + + private final InfluxDbUtils influxDbUtils; + + @Override + public List eventDisdip(List info) { + List result = new ArrayList<>(); + int[][] arr = new int[5][8]; + for (int i = 0; i < 5; i++) { + for (int j = 0; j < 8; j++) { + arr[i][j] = 0; + } + } + for (int i = 0; i < info.size(); i++) { + Double eventvalue = info.get(i).getEventValue(); + double persisttime = info.get(i).getPersistTime(); + if (eventvalue * 100 < 10) { + if (persisttime < 20) { + arr[4][0]++; + } else if (persisttime < 100) { + arr[4][1]++; + } else if (persisttime < 500) { + arr[4][2]++; + } else if (persisttime < 1000) { + arr[4][3]++; + } else if (persisttime < 3000) { + arr[4][4]++; + } else if (persisttime < 20000) { + arr[4][5]++; + } else if (persisttime < 60000) { + arr[4][6]++; + } else if (persisttime < 180000) { + arr[4][7]++; + } + } else if (eventvalue * 100 < 40) { + if (persisttime < 20) { + arr[3][0]++; + } else if (persisttime < 100) { + arr[3][1]++; + } else if (persisttime < 500) { + arr[3][2]++; + } else if (persisttime < 1000) { + arr[3][3]++; + } else if (persisttime < 3000) { + arr[3][4]++; + } else if (persisttime < 20000) { + arr[3][5]++; + } else if (persisttime < 60000) { + arr[3][6]++; + } else if (persisttime < 180000) { + arr[3][7]++; + } + } else if (eventvalue * 100 < 70) { + if (persisttime < 20) { + arr[2][0]++; + } else if (persisttime < 100) { + arr[2][1]++; + } else if (persisttime < 500) { + arr[2][2]++; + } else if (persisttime < 1000) { + arr[2][3]++; + } else if (persisttime < 3000) { + arr[2][4]++; + } else if (persisttime < 20000) { + arr[2][5]++; + } else if (persisttime < 60000) { + arr[2][6]++; + } else if (persisttime < 180000) { + arr[2][7]++; + } + } else if (eventvalue * 100 < 85) { + if (persisttime < 20) { + arr[1][0]++; + } else if (persisttime < 100) { + arr[1][1]++; + } else if (persisttime < 500) { + arr[1][2]++; + } else if (persisttime < 1000) { + arr[1][3]++; + } else if (persisttime < 3000) { + arr[1][4]++; + } else if (persisttime < 20000) { + arr[1][5]++; + } else if (persisttime < 60000) { + arr[1][6]++; + } else if (persisttime < 180000) { + arr[1][7]++; + } + } else if (eventvalue * 100 <= 90) { + if (persisttime < 20) { + arr[0][0]++; + } else if (persisttime < 100) { + arr[0][1]++; + } else if (persisttime < 500) { + arr[0][2]++; + } else if (persisttime < 1000) { + arr[0][3]++; + } else if (persisttime < 3000) { + arr[0][4]++; + } else if (persisttime < 20000) { + arr[0][5]++; + } else if (persisttime < 60000) { + arr[0][6]++; + } else if (persisttime < 180000) { + arr[0][7]++; + } + } + } + result.add(new DISDIPVO("90%", String.valueOf(arr[0][0]), String.valueOf(arr[0][1]), String.valueOf(arr[0][2]), String.valueOf(arr[0][3]), String.valueOf(arr[0][4]), String.valueOf(arr[0][5]), String.valueOf(arr[0][6]), String.valueOf(arr[0][7]))); + result.add(new DISDIPVO("85%", String.valueOf(arr[1][0]), String.valueOf(arr[1][1]), String.valueOf(arr[1][2]), String.valueOf(arr[1][3]), String.valueOf(arr[1][4]), String.valueOf(arr[1][5]), String.valueOf(arr[1][6]), String.valueOf(arr[1][7]))); + result.add(new DISDIPVO("70%", String.valueOf(arr[2][0]), String.valueOf(arr[2][1]), String.valueOf(arr[2][2]), String.valueOf(arr[2][3]), String.valueOf(arr[2][4]), String.valueOf(arr[2][5]), String.valueOf(arr[2][6]), String.valueOf(arr[2][7]))); + result.add(new DISDIPVO("40%", String.valueOf(arr[3][0]), String.valueOf(arr[3][1]), String.valueOf(arr[3][2]), String.valueOf(arr[3][3]), String.valueOf(arr[3][4]), String.valueOf(arr[3][5]), String.valueOf(arr[3][6]), String.valueOf(arr[3][7]))); + result.add(new DISDIPVO("10%", String.valueOf(arr[4][0]), String.valueOf(arr[4][1]), String.valueOf(arr[4][2]), String.valueOf(arr[4][3]), String.valueOf(arr[4][4]), String.valueOf(arr[4][5]), String.valueOf(arr[4][6]), String.valueOf(arr[4][7]))); + return result; + } + + @Override + public List IEC411(List info) { + List result = new ArrayList<>(); + int[][] arr = new int[3][6]; + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 6; j++) { + arr[i][j] = 0; + } + } + for (int i = 0; i < info.size(); i++) { + Double eventvalue = info.get(i).getEventValue(); + double persisttime = info.get(i).getPersistTime(); + if (eventvalue * 100 < 1) { + if (persisttime < 20 && persisttime >= 10) { + arr[2][0]++; + } else if (persisttime < 100) { + arr[2][1]++; + } else if (persisttime < 200) { + arr[2][2]++; + } else if (persisttime < 400) { + arr[2][3]++; + } else if (persisttime < 1000) { + arr[2][4]++; + } else { + arr[2][5]++; + } + } else if (eventvalue * 100 < 40) { + if (persisttime < 20 && persisttime >= 10) { + arr[1][0]++; + } else if (persisttime < 100) { + arr[1][1]++; + } else if (persisttime < 200) { + arr[1][2]++; + } else if (persisttime < 400) { + arr[1][3]++; + } else if (persisttime < 1000) { + arr[1][4]++; + } else { + arr[1][5]++; + } + } else if (eventvalue * 100 <= 70) { + if (persisttime < 20 && persisttime >= 10) { + arr[0][0]++; + } else if (persisttime < 100) { + arr[0][1]++; + } else if (persisttime < 200) { + arr[0][2]++; + } else if (persisttime < 400) { + arr[0][3]++; + } else if (persisttime < 1000) { + arr[0][4]++; + } else { + arr[0][5]++; + } + } + } + result.add(new IEC411VO("40~70%", String.valueOf(arr[0][0]), String.valueOf(arr[0][1]), String.valueOf(arr[0][2]), String.valueOf(arr[0][3]), String.valueOf(arr[0][4]), String.valueOf(arr[0][5]))); + result.add(new IEC411VO("1~40%", String.valueOf(arr[1][0]), String.valueOf(arr[1][1]), String.valueOf(arr[1][2]), String.valueOf(arr[1][3]), String.valueOf(arr[1][4]), String.valueOf(arr[1][5]))); + result.add(new IEC411VO("<1%", String.valueOf(arr[2][0]), String.valueOf(arr[2][1]), String.valueOf(arr[2][2]), String.valueOf(arr[2][3]), String.valueOf(arr[2][4]), String.valueOf(arr[2][5]))); + return result; + } + + @Override + public List IEC28(List info) { + List result = new ArrayList<>(); + int[][] arr = new int[17][8]; + for (int i = 0; i < 17; i++) { + for (int j = 0; j < 8; j++) { + arr[i][j] = 0; + } + } + for (int i = 0; i < info.size(); i++) { + Double eventvalue = info.get(i).getEventValue(); + double persisttime = info.get(i).getPersistTime(); + if (eventvalue * 100 < 1 && eventvalue * 100 >= 0) { + if (persisttime > 10 && persisttime <= 100) { + arr[16][0]++; + } else if (persisttime <= 250) { + arr[16][1]++; + } else if (persisttime <= 500) { + arr[16][2]++; + } else if (persisttime <= 1000) { + arr[16][3]++; + } else if (persisttime <= 3000) { + arr[16][4]++; + } else if (persisttime <= 20000) { + arr[16][5]++; + } else if (persisttime <= 60000) { + arr[16][6]++; + } else if (persisttime <= 180000) { + arr[16][7]++; + } + } else if (eventvalue * 100 < 10) { + if (persisttime > 10 && persisttime <= 100) { + arr[15][0]++; + } else if (persisttime <= 250) { + arr[15][1]++; + } else if (persisttime <= 500) { + arr[15][2]++; + } else if (persisttime <= 1000) { + arr[15][3]++; + } else if (persisttime <= 3000) { + arr[15][4]++; + } else if (persisttime <= 20000) { + arr[15][5]++; + } else if (persisttime <= 60000) { + arr[15][6]++; + } else if (persisttime <= 180000) { + arr[15][7]++; + } + } else if (eventvalue * 100 < 20) { + if (persisttime > 10 && persisttime <= 100) { + arr[14][0]++; + } else if (persisttime <= 250) { + arr[14][1]++; + } else if (persisttime <= 500) { + arr[14][2]++; + } else if (persisttime <= 1000) { + arr[14][3]++; + } else if (persisttime <= 3000) { + arr[14][4]++; + } else if (persisttime <= 20000) { + arr[14][5]++; + } else if (persisttime <= 60000) { + arr[14][6]++; + } else if (persisttime <= 180000) { + arr[14][7]++; + } + } else if (eventvalue * 100 < 30) { + if (persisttime > 10 && persisttime <= 100) { + arr[13][0]++; + } else if (persisttime <= 250) { + arr[13][1]++; + } else if (persisttime <= 500) { + arr[13][2]++; + } else if (persisttime <= 1000) { + arr[13][3]++; + } else if (persisttime <= 3000) { + arr[13][4]++; + } else if (persisttime <= 20000) { + arr[13][5]++; + } else if (persisttime <= 60000) { + arr[13][6]++; + } else if (persisttime <= 180000) { + arr[13][7]++; + } + } else if (eventvalue * 100 < 40) { + if (persisttime > 10 && persisttime <= 100) { + arr[12][0]++; + } else if (persisttime <= 250) { + arr[12][1]++; + } else if (persisttime <= 500) { + arr[12][2]++; + } else if (persisttime <= 1000) { + arr[12][3]++; + } else if (persisttime <= 3000) { + arr[12][4]++; + } else if (persisttime <= 20000) { + arr[12][5]++; + } else if (persisttime <= 60000) { + arr[12][6]++; + } else if (persisttime <= 180000) { + arr[12][7]++; + } + } else if (eventvalue * 100 < 50) { + if (persisttime > 10 && persisttime <= 100) { + arr[11][0]++; + } else if (persisttime <= 250) { + arr[11][1]++; + } else if (persisttime <= 500) { + arr[11][2]++; + } else if (persisttime <= 1000) { + arr[11][3]++; + } else if (persisttime <= 3000) { + arr[11][4]++; + } else if (persisttime <= 20000) { + arr[11][5]++; + } else if (persisttime <= 60000) { + arr[11][6]++; + } else if (persisttime <= 180000) { + arr[11][7]++; + } + } else if (eventvalue * 100 < 60) { + if (persisttime > 10 && persisttime <= 100) { + arr[10][0]++; + } else if (persisttime <= 250) { + arr[10][1]++; + } else if (persisttime <= 500) { + arr[10][2]++; + } else if (persisttime <= 1000) { + arr[10][3]++; + } else if (persisttime <= 3000) { + arr[10][4]++; + } else if (persisttime <= 20000) { + arr[10][5]++; + } else if (persisttime <= 60000) { + arr[10][6]++; + } else if (persisttime <= 180000) { + arr[10][7]++; + } + } else if (eventvalue * 100 < 70) { + if (persisttime > 10 && persisttime <= 100) { + arr[9][0]++; + } else if (persisttime <= 250) { + arr[9][1]++; + } else if (persisttime <= 500) { + arr[9][2]++; + } else if (persisttime <= 1000) { + arr[9][3]++; + } else if (persisttime <= 3000) { + arr[9][4]++; + } else if (persisttime <= 20000) { + arr[9][5]++; + } else if (persisttime <= 60000) { + arr[9][6]++; + } else if (persisttime <= 180000) { + arr[9][7]++; + } + } else if (eventvalue * 100 < 80) { + if (persisttime > 10 && persisttime <= 100) { + arr[8][0]++; + } else if (persisttime <= 250) { + arr[8][1]++; + } else if (persisttime <= 500) { + arr[8][2]++; + } else if (persisttime <= 1000) { + arr[8][3]++; + } else if (persisttime <= 3000) { + arr[8][4]++; + } else if (persisttime <= 20000) { + arr[8][5]++; + } else if (persisttime <= 60000) { + arr[8][6]++; + } else if (persisttime <= 180000) { + arr[8][7]++; + } + } else if (eventvalue * 100 <= 90) { + if (persisttime > 10 && persisttime <= 100) { + arr[7][0]++; + } else if (persisttime <= 250) { + arr[7][1]++; + } else if (persisttime <= 500) { + arr[7][2]++; + } else if (persisttime <= 1000) { + arr[7][3]++; + } else if (persisttime <= 3000) { + arr[7][4]++; + } else if (persisttime <= 20000) { + arr[7][5]++; + } else if (persisttime <= 60000) { + arr[7][6]++; + } else if (persisttime <= 180000) { + arr[7][7]++; + } + } else if (eventvalue * 100 < 120 && eventvalue * 100 >= 110) { + if (persisttime > 10 && persisttime <= 100) { + arr[6][0]++; + } else if (persisttime <= 250) { + arr[6][1]++; + } else if (persisttime <= 500) { + arr[6][2]++; + } else if (persisttime <= 1000) { + arr[6][3]++; + } else if (persisttime <= 3000) { + arr[6][4]++; + } else if (persisttime <= 20000) { + arr[6][5]++; + } else if (persisttime <= 60000) { + arr[6][6]++; + } else if (persisttime <= 180000) { + arr[6][7]++; + } + } else if (eventvalue * 100 < 130) { + if (persisttime > 10 && persisttime <= 100) { + arr[5][0]++; + } else if (persisttime <= 250) { + arr[5][1]++; + } else if (persisttime <= 500) { + arr[5][2]++; + } else if (persisttime <= 1000) { + arr[5][3]++; + } else if (persisttime <= 3000) { + arr[5][4]++; + } else if (persisttime <= 20000) { + arr[5][5]++; + } else if (persisttime <= 60000) { + arr[5][6]++; + } else if (persisttime <= 180000) { + arr[5][7]++; + } + } else if (eventvalue * 100 < 140) { + if (persisttime > 10 && persisttime <= 100) { + arr[4][0]++; + } else if (persisttime <= 250) { + arr[4][1]++; + } else if (persisttime <= 500) { + arr[4][2]++; + } else if (persisttime <= 1000) { + arr[4][3]++; + } else if (persisttime <= 3000) { + arr[4][4]++; + } else if (persisttime <= 20000) { + arr[4][5]++; + } else if (persisttime <= 60000) { + arr[4][6]++; + } else if (persisttime <= 180000) { + arr[4][7]++; + } + } else if (eventvalue * 100 < 150) { + if (persisttime > 10 && persisttime <= 100) { + arr[3][0]++; + } else if (persisttime <= 250) { + arr[3][1]++; + } else if (persisttime <= 500) { + arr[3][2]++; + } else if (persisttime <= 1000) { + arr[3][3]++; + } else if (persisttime <= 3000) { + arr[3][4]++; + } else if (persisttime <= 20000) { + arr[3][5]++; + } else if (persisttime <= 60000) { + arr[3][6]++; + } else if (persisttime <= 180000) { + arr[3][7]++; + } + } else if (eventvalue * 100 < 160) { + if (persisttime > 10 && persisttime <= 100) { + arr[2][0]++; + } else if (persisttime <= 250) { + arr[2][1]++; + } else if (persisttime <= 500) { + arr[2][2]++; + } else if (persisttime <= 1000) { + arr[2][3]++; + } else if (persisttime <= 3000) { + arr[2][4]++; + } else if (persisttime <= 20000) { + arr[2][5]++; + } else if (persisttime <= 60000) { + arr[2][6]++; + } else if (persisttime <= 180000) { + arr[2][7]++; + } + } else if (eventvalue * 100 < 170) { + if (persisttime > 10 && persisttime <= 100) { + arr[1][0]++; + } else if (persisttime <= 250) { + arr[1][1]++; + } else if (persisttime <= 500) { + arr[1][2]++; + } else if (persisttime <= 1000) { + arr[1][3]++; + } else if (persisttime <= 3000) { + arr[1][4]++; + } else if (persisttime <= 20000) { + arr[1][5]++; + } else if (persisttime <= 60000) { + arr[1][6]++; + } else if (persisttime <= 180000) { + arr[1][7]++; + } + } else if (eventvalue * 100 <= 180) { + if (persisttime > 10 && persisttime <= 100) { + arr[0][0]++; + } else if (persisttime <= 250) { + arr[0][1]++; + } else if (persisttime <= 500) { + arr[0][2]++; + } else if (persisttime <= 1000) { + arr[0][3]++; + } else if (persisttime <= 3000) { + arr[0][4]++; + } else if (persisttime <= 20000) { + arr[0][5]++; + } else if (persisttime <= 60000) { + arr[0][6]++; + } else if (persisttime <= 180000) { + arr[0][7]++; + } + } + } + result.add(new IEC28VO("180>U>=170", String.valueOf(arr[0][0]), String.valueOf(arr[0][1]), String.valueOf(arr[0][2]), String.valueOf(arr[0][3]), String.valueOf(arr[0][4]), String.valueOf(arr[0][5]), String.valueOf(arr[0][6]), String.valueOf(arr[0][7]))); + result.add(new IEC28VO("170>U>=160", String.valueOf(arr[1][0]), String.valueOf(arr[1][1]), String.valueOf(arr[1][2]), String.valueOf(arr[1][3]), String.valueOf(arr[1][4]), String.valueOf(arr[1][5]), String.valueOf(arr[1][6]), String.valueOf(arr[1][7]))); + result.add(new IEC28VO("160>U>=150", String.valueOf(arr[2][0]), String.valueOf(arr[2][1]), String.valueOf(arr[2][2]), String.valueOf(arr[2][3]), String.valueOf(arr[2][4]), String.valueOf(arr[2][5]), String.valueOf(arr[2][6]), String.valueOf(arr[2][7]))); + result.add(new IEC28VO("150>U>=140", String.valueOf(arr[3][0]), String.valueOf(arr[3][1]), String.valueOf(arr[3][2]), String.valueOf(arr[3][3]), String.valueOf(arr[3][4]), String.valueOf(arr[3][5]), String.valueOf(arr[3][6]), String.valueOf(arr[3][7]))); + result.add(new IEC28VO("140>U>=130", String.valueOf(arr[4][0]), String.valueOf(arr[4][1]), String.valueOf(arr[4][2]), String.valueOf(arr[4][3]), String.valueOf(arr[4][4]), String.valueOf(arr[4][5]), String.valueOf(arr[4][6]), String.valueOf(arr[4][7]))); + result.add(new IEC28VO("130>U>=120", String.valueOf(arr[5][0]), String.valueOf(arr[5][1]), String.valueOf(arr[5][2]), String.valueOf(arr[5][3]), String.valueOf(arr[5][4]), String.valueOf(arr[5][5]), String.valueOf(arr[5][6]), String.valueOf(arr[5][7]))); + result.add(new IEC28VO("120>U>=110", String.valueOf(arr[6][0]), String.valueOf(arr[6][1]), String.valueOf(arr[6][2]), String.valueOf(arr[6][3]), String.valueOf(arr[6][4]), String.valueOf(arr[6][5]), String.valueOf(arr[6][6]), String.valueOf(arr[6][7]))); + result.add(new IEC28VO("90>U>=80", String.valueOf(arr[7][0]), String.valueOf(arr[7][1]), String.valueOf(arr[7][2]), String.valueOf(arr[7][3]), String.valueOf(arr[7][4]), String.valueOf(arr[7][5]), String.valueOf(arr[7][6]), String.valueOf(arr[7][7]))); + result.add(new IEC28VO("80>U>=70", String.valueOf(arr[8][0]), String.valueOf(arr[8][1]), String.valueOf(arr[8][2]), String.valueOf(arr[8][3]), String.valueOf(arr[8][4]), String.valueOf(arr[8][5]), String.valueOf(arr[8][6]), String.valueOf(arr[8][7]))); + result.add(new IEC28VO("70>U>=60", String.valueOf(arr[9][0]), String.valueOf(arr[9][1]), String.valueOf(arr[9][2]), String.valueOf(arr[9][3]), String.valueOf(arr[9][4]), String.valueOf(arr[9][5]), String.valueOf(arr[9][6]), String.valueOf(arr[9][7]))); + result.add(new IEC28VO("60>U>=50", String.valueOf(arr[10][0]), String.valueOf(arr[10][1]), String.valueOf(arr[10][2]), String.valueOf(arr[10][3]), String.valueOf(arr[10][4]), String.valueOf(arr[10][5]), String.valueOf(arr[10][6]), String.valueOf(arr[10][7]))); + result.add(new IEC28VO("50>U>=40", String.valueOf(arr[11][0]), String.valueOf(arr[11][1]), String.valueOf(arr[11][2]), String.valueOf(arr[11][3]), String.valueOf(arr[11][4]), String.valueOf(arr[11][5]), String.valueOf(arr[11][6]), String.valueOf(arr[11][7]))); + result.add(new IEC28VO("40>U>=30", String.valueOf(arr[12][0]), String.valueOf(arr[12][1]), String.valueOf(arr[12][2]), String.valueOf(arr[12][3]), String.valueOf(arr[12][4]), String.valueOf(arr[12][5]), String.valueOf(arr[12][6]), String.valueOf(arr[12][7]))); + result.add(new IEC28VO("30>U>=20", String.valueOf(arr[13][0]), String.valueOf(arr[13][1]), String.valueOf(arr[13][2]), String.valueOf(arr[13][3]), String.valueOf(arr[13][4]), String.valueOf(arr[13][5]), String.valueOf(arr[13][6]), String.valueOf(arr[13][7]))); + result.add(new IEC28VO("20>U>=10", String.valueOf(arr[14][0]), String.valueOf(arr[14][1]), String.valueOf(arr[14][2]), String.valueOf(arr[14][3]), String.valueOf(arr[14][4]), String.valueOf(arr[14][5]), String.valueOf(arr[14][6]), String.valueOf(arr[14][7]))); + result.add(new IEC28VO("10>U>=1", String.valueOf(arr[15][0]), String.valueOf(arr[15][1]), String.valueOf(arr[15][2]), String.valueOf(arr[15][3]), String.valueOf(arr[15][4]), String.valueOf(arr[15][5]), String.valueOf(arr[15][6]), String.valueOf(arr[15][7]))); + result.add(new IEC28VO("1>U>=0", String.valueOf(arr[16][0]), String.valueOf(arr[16][1]), String.valueOf(arr[16][2]), String.valueOf(arr[16][3]), String.valueOf(arr[16][4]), String.valueOf(arr[16][5]), String.valueOf(arr[16][6]), String.valueOf(arr[16][7]))); + return result; + } + + @Override + public ProbabilityVO getProbabilityDistribution(List info2) { + ProbabilityVO result = new ProbabilityVO(); + List info = new ArrayList<>(); + + //总数 + Integer count = 0; + for (EventDetail eventDetail : info2) { + //过滤掉大于0.9的数据 + if (eventDetail.getEventValue() <= 0.9) { + count++; + info.add(eventDetail); + } + } + //计数map + HashMap countMap = new HashMap<>(); + countMap.put("<10", 0); + countMap.put("<20", 0); + countMap.put("<30", 0); + countMap.put("<40", 0); + countMap.put("<50", 0); + countMap.put("<60", 0); + countMap.put("<70", 0); + countMap.put("<80", 0); + countMap.put("<90", 0); + //分段计数 + HashMap subsectionMap = new HashMap<>(); + subsectionMap.put("0~10", 0); + subsectionMap.put("10~20", 0); + subsectionMap.put("20~30", 0); + subsectionMap.put("30~40", 0); + subsectionMap.put("40~50", 0); + subsectionMap.put("50~60", 0); + subsectionMap.put("60~70", 0); + subsectionMap.put("70~80", 0); + subsectionMap.put("80~90", 0); + //求数量 + for (EventDetail eventDetail : info) { + if (eventDetail.getEventValue() < 0.1) { + countMap.put("<10", (countMap.get("<10") + 1)); + } + if (eventDetail.getEventValue() < 0.2) { + countMap.put("<20", (countMap.get("<20") + 1)); + } + if (eventDetail.getEventValue() < 0.3) { + countMap.put("<30", (countMap.get("<30") + 1)); + } + if (eventDetail.getEventValue() < 0.4) { + countMap.put("<40", (countMap.get("<40") + 1)); + } + if (eventDetail.getEventValue() < 0.5) { + countMap.put("<50", (countMap.get("<50") + 1)); + } + if (eventDetail.getEventValue() < 0.6) { + countMap.put("<60", (countMap.get("<60") + 1)); + } + if (eventDetail.getEventValue() < 0.7) { + countMap.put("<70", (countMap.get("<70") + 1)); + } + if (eventDetail.getEventValue() < 0.8) { + countMap.put("<80", (countMap.get("<80") + 1)); + } + if (eventDetail.getEventValue() < 0.9) { + countMap.put("<90", (countMap.get("<90") + 1)); + } + } + //求每段数量 + for (EventDetail eventDetail : info) { + if (eventDetail.getEventValue() < 0.1) { + subsectionMap.put("0~10", (subsectionMap.get("0~10") + 1)); + } else if (eventDetail.getEventValue() > 0.1 && eventDetail.getEventValue() < 0.2) { + subsectionMap.put("10~20", (subsectionMap.get("10~20") + 1)); + } else if (eventDetail.getEventValue() > 0.2 && eventDetail.getEventValue() < 0.3) { + subsectionMap.put("20~30", (subsectionMap.get("20~30") + 1)); + } else if (eventDetail.getEventValue() > 0.3 && eventDetail.getEventValue() < 0.4) { + subsectionMap.put("30~40", (subsectionMap.get("30~40") + 1)); + } else if (eventDetail.getEventValue() > 0.4 && eventDetail.getEventValue() < 0.5) { + subsectionMap.put("40~50", (subsectionMap.get("40~50") + 1)); + } else if (eventDetail.getEventValue() > 0.5 && eventDetail.getEventValue() < 0.6) { + subsectionMap.put("50~60", (subsectionMap.get("50~60") + 1)); + } else if (eventDetail.getEventValue() > 0.6 && eventDetail.getEventValue() < 0.7) { + subsectionMap.put("60~70", (subsectionMap.get("60~70") + 1)); + } else if (eventDetail.getEventValue() > 0.7 && eventDetail.getEventValue() < 0.8) { + subsectionMap.put("70~80", (subsectionMap.get("70~80") + 1)); + } else if (eventDetail.getEventValue() > 0.8 && eventDetail.getEventValue() < 0.9) { + subsectionMap.put("80~90", (subsectionMap.get("80~90") + 1)); + } + } + //求概率并求pereventvalue + List pereventvalue = new ArrayList<>(); + Set subsectionSet = subsectionMap.keySet(); + List strings1 = new ArrayList<>(); + strings1.add("0~10"); + strings1.add("10~20"); + strings1.add("20~30"); + strings1.add("30~40"); + strings1.add("40~50"); + strings1.add("50~60"); + strings1.add("60~70"); + strings1.add("70~80"); + strings1.add("80~90"); + for (int i = 0; i < strings1.size(); i++) { + for (String s : subsectionSet) { + if (strings1.get(i).equals(s)) { + if (subsectionMap.get(s) == 0) { + pereventvalue.add(".00"); + break; + } + if (subsectionMap.get(s) / count.doubleValue() == 1.0) { + pereventvalue.add("100.00"); + } else { + String s1 = String.format("%.4f", (subsectionMap.get(s) / count.doubleValue())); + pereventvalue.add(s1.substring(2, 4) + "." + s1.substring(4, 6)); + } + } + } + } + result.setPereventvalue(pereventvalue); + //求eventvalue + List eventvalue = new ArrayList<>(); + List strings = new ArrayList<>(); + strings.add("<10"); + strings.add("<20"); + strings.add("<30"); + strings.add("<40"); + strings.add("<50"); + strings.add("<60"); + strings.add("<70"); + strings.add("<80"); + strings.add("<90"); + Set countSet = countMap.keySet(); + //保证顺序 + for (int i = 0; i < strings.size(); i++) { + for (String s : countSet) { + if (strings.get(i).equals(s)) { + if (countMap.get(s) == 0) { + eventvalue.add(".00"); + break; + } + if (countMap.get(s) / count.floatValue() == 1.0) { + eventvalue.add("100.00"); + } else { + String s1 = String.format("%.4f", (countMap.get(s) / count.doubleValue())); + eventvalue.add(s1.substring(2, 4) + "." + s1.substring(4, 6)); + } + } + } + } + eventvalue.add("100.00"); + result.setEventvalue(eventvalue); + //时间 + HashMap timeMap = new HashMap<>(); + timeMap.put("<0.1", 0); + timeMap.put("<0.25", 0); + timeMap.put("<0.5", 0); + timeMap.put("<1", 0); + timeMap.put("<3", 0); + timeMap.put("<20", 0); + timeMap.put("<60", 0); + timeMap.put("<180", 0); + //求不同时间段的总数 + for (EventDetail eventDetail : info) { + Double persistTime = eventDetail.getPersistTime(); + if (persistTime / 1000 < 0.1) { + timeMap.put("<0.1", timeMap.get("<0.1") + 1); + } else if (persistTime / 1000 > 0.1 && persistTime / 1000 < 0.25) { + timeMap.put("<0.25", timeMap.get("<0.25") + 1); + } else if (persistTime / 1000 > 0.25 && persistTime / 1000 < 0.5) { + timeMap.put("<0.5", timeMap.get("<0.5") + 1); + } else if (persistTime / 1000 > 0.5 && persistTime / 1000 < 1) { + timeMap.put("<1", timeMap.get("<1") + 1); + } else if (persistTime / 1000 > 1 && persistTime / 1000 < 3) { + timeMap.put("<3", timeMap.get("<3") + 1); + } else if (persistTime / 1000 > 3 && persistTime / 1000 < 20) { + timeMap.put("<20", timeMap.get("<20") + 1); + } else if (persistTime / 1000 > 20 && persistTime / 1000 < 60) { + timeMap.put("<60", timeMap.get("<60") + 1); + } else if (persistTime / 1000 > 60 && persistTime / 1000 < 180) { + timeMap.put("<180", timeMap.get("<180") + 1); + } + } + List strings2 = new ArrayList<>(); + strings2.add("<0.1"); + strings2.add("<0.25"); + strings2.add("<0.5"); + strings2.add("<1"); + strings2.add("<3"); + strings2.add("<20"); + strings2.add("<60"); + strings2.add("<180"); + //求persisttime + List persisttime = new ArrayList<>(); + Set timeSet = timeMap.keySet(); + for (int i = 0; i < strings2.size(); i++) { + for (String s : timeSet) { + if (strings2.get(i).equals(s)) { + if (timeMap.get(s) == 0) { + persisttime.add(".00"); + break; + } + if (timeMap.get(s) / count.floatValue() == 1.0) { + persisttime.add("100.00"); + } else { + String s1 = String.format("%.4f", (timeMap.get(s) / count.doubleValue())); + persisttime.add(s1.substring(2, 4) + "." + s1.substring(4, 6)); + } + } + } + } + result.setPersisttime(persisttime); + + HashMap timeMap2 = new HashMap<>(); + timeMap2.put("<0.1", 0); + timeMap2.put("<0.25", 0); + timeMap2.put("<0.5", 0); + timeMap2.put("<1", 0); + timeMap2.put("<3", 0); + timeMap2.put("<20", 0); + timeMap2.put("<60", 0); + timeMap2.put("<180", 0); + //求sisttime + List sisttime = new ArrayList<>(); + for (EventDetail eventDetail : info) { + Double persistTime = eventDetail.getPersistTime(); + if (persistTime / 1000 < 0.1) { + timeMap2.put("<0.1", timeMap2.get("<0.1") + 1); + } + if (persistTime / 1000 < 0.25) { + timeMap2.put("<0.25", timeMap2.get("<0.25") + 1); + } + if (persistTime / 1000 < 0.5) { + timeMap2.put("<0.5", timeMap2.get("<0.5") + 1); + } + if (persistTime / 1000 < 1) { + timeMap2.put("<1", timeMap2.get("<1") + 1); + } + if (persistTime / 1000 < 3) { + timeMap2.put("<3", timeMap2.get("<3") + 1); + } + if (persistTime / 1000 < 20) { + timeMap2.put("<20", timeMap2.get("<20") + 1); + } + if (persistTime / 1000 < 60) { + timeMap2.put("<60", timeMap2.get("<60") + 1); + } + if (persistTime / 1000 < 180) { + timeMap2.put("<180", timeMap2.get("<180") + 1); + } + } + Set time2Set = timeMap2.keySet(); + for (int i = 0; i < strings2.size(); i++) { + for (String s : time2Set) { + if (strings2.get(i).equals(s)) { + if (timeMap2.get(s) == 0) { + sisttime.add(".00"); + break; + } + if (timeMap2.get(s) / count.floatValue() == 1.0) { + sisttime.add("100.00"); + } else { + String s1 = String.format("%.4f", (timeMap2.get(s) / count.doubleValue())); + sisttime.add(s1.substring(2, 4) + "." + s1.substring(4, 6)); + } + } + } + } + sisttime.add("100.00"); + result.setSisttime(sisttime); + return result; + } + + @Override + public List getReasonTypeTime(StatisticsParam statisticsParam,List info) throws ParseException { + List list = new ArrayList<>(); + //参数 + StringBuilder builder1 = new StringBuilder(); + StringBuilder builder2 = new StringBuilder(); + QueryResult query = null; + //获取时间字符串 + String startTime = statisticsParam.getStartTime(); + String endTime = statisticsParam.getEndTime(); + Integer startDays = Integer.parseInt(startTime.substring(8, 10)); + Integer endDays = Integer.parseInt(endTime.substring(8, 10)); + Integer startMonth = Integer.parseInt(startTime.substring(5, 7)); + 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){ + while (!startYear.equals(endYear) && !startMonth.equals(endMonth)) { + builder1.delete(0, builder1.length()); + builder2.delete(0, builder2.length()); + builder1.append(startYear).append("-").append(startMonth).append("-").append(startDays); + if (startMonth + 1 == 13) { + builder2.append(startYear + 1).append("-").append(1).append("-").append(startDays); + } else { + builder2.append(startYear).append("-").append(startMonth + 1).append("-").append(startDays); + } + query = MonitorQuery(new StatisticsParam(statisticsParam.getLineIndex(),builder1.toString(), builder2.toString(), statisticsParam.getFlag())); + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + List eventDetailList = influxDBResultMapper.toPOJO(query, EventDetail.class); + long count = eventDetailList.stream().filter(x -> x.getWaveType() == 1).count(); + if (startMonth < 10) { + 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())); + } + startMonth++; + if (startMonth == 13) { + startYear++; + startMonth = 1; + } + } + builder1.delete(0, builder1.length()); + 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())); + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + List eventDetailList = influxDBResultMapper.toPOJO(query, EventDetail.class); + long count1 = eventDetailList.stream().filter(x -> x.getWaveType() == 1).count(); + if (startMonth < 10) { + 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())); + } + return list; + } + else { + QueryResult monitorQuery = MonitorQuery(statisticsParam); + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + List eventDetailList = influxDBResultMapper.toPOJO(monitorQuery, EventDetailNew.class); + + Map> map = eventDetailList.stream().filter(x -> x.getWaveType()==1).collect(Collectors.groupingBy(s -> s.getTimeId().substring(0, 10))); + Set 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())){ + List 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.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 { + TimeVO timeVO = new TimeVO(); + timeVO.setTimes("0"); + 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.setFulltime(parse1.toString()); + list.add(timeVO); + } + parse1=parse1.plus(1, ChronoUnit.DAYS); + } + return list; + } + } + + + /** + * 暂降事件点图 + * @author wr + */ + @Override + public List getPlot(List info,List reasonData,List typeData) { + //添加detail + for (EventDetail detail : info) { + for (DictData data : reasonData) { + if (detail.getEventReason().equals(data.getId())) { + detail.setEventReason(data.getName()); + } + } + for (DictData data : typeData) { + if (detail.getEventType().equals(data.getId())) { + detail.setEventType(data.getName()); + } + } + } + return info; + } + + @Override + public StatisticVO getStatistic(List info,List reasonData,ListtypeData) { + StatisticVO result = new StatisticVO(); + List list = new ArrayList<>(); + List reasonsVOS = new ArrayList<>(); + List typesVOS = new ArrayList<>(); + + HashMap reasonMap = new HashMap<>(); + HashMap typeMap = new HashMap<>(); + //添加detail + for (EventDetail detail : info) { + for (DictData data : reasonData) { + reasonMap.put(data.getName(),0); + if (detail.getEventReason().equals(data.getId())) { + detail.setEventReason(data.getName()); + } + } + for (DictData data : typeData) { + typeMap.put(data.getName(),0); + if (detail.getEventType().equals(data.getId())) { + detail.setEventType(data.getName()); + } + } + list.add(detail); + } + + //添加reason到map + for (EventDetail data : list) { + if (reasonMap.get(data.getEventReason()) != null) { + reasonMap.put(data.getEventReason(), reasonMap.get(data.getEventReason()) + 1); + } + } + //添加type到map + for (EventDetail data : list) { + if (typeMap.get(data.getEventType()) != null) { + typeMap.put(data.getEventType(), typeMap.get(data.getEventType()) + 1); + } + } + Set reasonKeyset = reasonMap.keySet(); + Set typeKeyset = typeMap.keySet(); + for (String s : reasonKeyset) { + reasonsVOS.add(new ReasonsVO(s, reasonMap.get(s), null)); + } + for (String s : typeKeyset) { + typesVOS.add(new TypesVO(s, typeMap.get(s))); + } + result.setTypes(typesVOS); + result.setReason(reasonsVOS); + return result; + } + + /** + * @return + * @author xxy + * 时间区间查询监测点抽取 + */ + public QueryResult MonitorQuery(StatisticsParam statisticsParam) { + //构建sql语句 + String stringResult = Param.SELECT + Param.EVENT_DETAIL + Param.WHERE + "" + "time >= '" + + DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getStartTime().toString())) + + "' and " + "time <= '" + + DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getEndTime().toString())) + + "' and " + "line_id= '" + + statisticsParam.getLineIndex() + "' " + + Param.TZ_ASIA_SHANGHAI; + //结果集映射到对象中 + return influxDbUtils.query(stringResult); + } +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/ReportServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/ReportServiceImpl.java index 5ef5013c0..caaaf118e 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/ReportServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/ReportServiceImpl.java @@ -1057,62 +1057,62 @@ public class ReportServiceImpl implements ReportService { //记录数 int i = 1; //1.监测点信息 - if (exportParam.isXq()){ - createTitle(doc,"4."+i+" 监测点信息","标题 2",200,15); + if (exportParam.isXq()) { + createTitle(doc, "4." + i + " 监测点信息", "标题 2", 200, 15); XWPFTable table = createTable(doc); XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc); HttpResult lineDetailData = lineFeignClient.getLineDetailData(exportParam.getLineId()); - if (ObjectUtil.isNull(lineDetailData)){ + if (ObjectUtil.isNull(lineDetailData)) { throw new BusinessException(EventResponseEnum.NOT_FOUND); } - insertRow(doc,table,centerParagraph,true,"项目","描述"); - insertRow(doc,table,centerParagraph,false,"监测点名称",lineDetailData.getData().getLineName()); - insertRow(doc,table,centerParagraph,false,"电压等级",lineDetailData.getData().getScale()); - insertRow(doc,table,centerParagraph,false,"PT变比",lineDetailData.getData().getPt()); - insertRow(doc,table,centerParagraph,false,"CT变比",lineDetailData.getData().getCt()); - insertRow(doc,table,centerParagraph,false,"协议容量",lineDetailData.getData().getDealCapacity()+""); - insertRow(doc,table,centerParagraph,false,"基准容量",lineDetailData.getData().getStandardCapacity()+""); - insertRow(doc,table,centerParagraph,false,"设备容量",lineDetailData.getData().getDevCapacity()+""); - insertRow(doc,table,centerParagraph,false,"最小短路容量",lineDetailData.getData().getShortCapacity()+""); - insertRow(doc,table,centerParagraph,false,"接线方式",lineDetailData.getData().getPtType()); + insertRow(doc, table, centerParagraph, true, "项目", "描述"); + insertRow(doc, table, centerParagraph, false, "监测点名称", lineDetailData.getData().getLineName()); + insertRow(doc, table, centerParagraph, false, "电压等级", lineDetailData.getData().getScale()); + insertRow(doc, table, centerParagraph, false, "PT变比", lineDetailData.getData().getPt()); + insertRow(doc, table, centerParagraph, false, "CT变比", lineDetailData.getData().getCt()); + insertRow(doc, table, centerParagraph, false, "协议容量", lineDetailData.getData().getDealCapacity() + ""); + insertRow(doc, table, centerParagraph, false, "基准容量", lineDetailData.getData().getStandardCapacity() + ""); + insertRow(doc, table, centerParagraph, false, "设备容量", lineDetailData.getData().getDevCapacity() + ""); + insertRow(doc, table, centerParagraph, false, "最小短路容量", lineDetailData.getData().getShortCapacity() + ""); + insertRow(doc, table, centerParagraph, false, "接线方式", lineDetailData.getData().getPtType()); i++; } //2.暂降事件暂降事件列表和暂降点图 //2.1.判断列表和点图是否是要导出 - if(exportParam.isLb()||exportParam.isSjdF47() || exportParam.isSjdITIC()){ + if (exportParam.isLb() || exportParam.isSjdF47() || exportParam.isSjdITIC()) { // List plot = eventAnalysisService.getPlot(param); - List plot = eventReportService.getPlot(info,reasonData,typeData); + List plot = eventReportService.getPlot(info, reasonData, typeData); //暂降事件列表 - if (exportParam.isLb()){ - createTitle(doc,"4."+i+" 暂降事件列表","标题 2",200,15); + if (exportParam.isLb()) { + createTitle(doc, "4." + i + " 暂降事件列表", "标题 2", 200, 15); XWPFTable table = createTable(doc); XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc); - insertRow(doc,table,centerParagraph,true,"序号","暂降发生时刻","暂降赋值(%)","持续时间(s)","暂降类型","暂降原因","严重度"); + insertRow(doc, table, centerParagraph, true, "序号", "暂降发生时刻", "暂降赋值(%)", "持续时间(s)", "暂降类型", "暂降原因", "严重度"); for (int j = 0; j < plot.size(); j++) { EventDetail eventDetail = plot.get(j); long l = eventDetail.getTimeId().toEpochMilli(); Date date1 = new Date(l); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); String s = simpleDateFormat.format(date1); - insertRow(doc,table,centerParagraph,false,j+1+"",s,eventDetail.getEventValue()+"",eventDetail.getPersistTime()/1000.0+"",eventDetail.getEventType(),eventDetail.getEventReason(),eventDetail.getSeverity()+""); + insertRow(doc, table, centerParagraph, false, j + 1 + "", s, eventDetail.getEventValue() + "", eventDetail.getPersistTime() / 1000.0 + "", eventDetail.getEventType(), eventDetail.getEventReason(), eventDetail.getSeverity() + ""); } i++; } //暂降事件点图 - if (exportParam.isSjdF47() || exportParam.isSjdITIC()){ + if (exportParam.isSjdF47() || exportParam.isSjdITIC()) { ArrayList> ass = getAss(plot); - createTitle(doc,"4."+i+" 暂降事件点图","标题 2",200,15); + createTitle(doc, "4." + i + " 暂降事件点图", "标题 2", 200, 15); int two = 1; - if (exportParam.isSjdITIC()){ - createTitle(doc,"4."+i+"."+two+" ITIC 曲线","标题 3",400,15); + if (exportParam.isSjdITIC()) { + createTitle(doc, "4." + i + "." + two + " ITIC 曲线", "标题 3", 400, 15); String itic = getITIC(ass); - createPic(doc,itic,"ITIC曲线"); + createPic(doc, itic, "ITIC曲线"); two++; } - if (exportParam.isSjdF47()){ - createTitle(doc,"4."+i+"."+two+" F47 曲线","标题 3",400,15); + if (exportParam.isSjdF47()) { + createTitle(doc, "4." + i + "." + two + " F47 曲线", "标题 3", 400, 15); String f47 = getF47(ass); - createPic(doc,f47,"SEMI F47曲线"); + createPic(doc, f47, "SEMI F47曲线"); two++; } i++; @@ -1121,69 +1121,69 @@ public class ReportServiceImpl implements ReportService { //3.暂降密度 - if (exportParam.isMdbg() || exportParam.isMdtx()){ - createTitle(doc,"4."+i+" 暂降密度","标题 2",200,15); + if (exportParam.isMdbg() || exportParam.isMdtx()) { + createTitle(doc, "4." + i + " 暂降密度", "标题 2", 200, 15); int two = 1; - if (exportParam.isMdtx()){ - createTitle(doc,"4."+i+"."+two+" 暂降密度点图","标题 3",400,15); + if (exportParam.isMdtx()) { + createTitle(doc, "4." + i + "." + two + " 暂降密度点图", "标题 3", 400, 15); two++; } - if (exportParam.isMdbg()){ + if (exportParam.isMdbg()) { XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc); - createTitle(doc,"4."+i+"."+two+" DISDIP 表格:国际发配电联盟(UNIPEDE)","标题 3",400,15); + createTitle(doc, "4." + i + "." + two + " DISDIP 表格:国际发配电联盟(UNIPEDE)", "标题 3", 400, 15); // List eventDisdip = eventAnalysisService.eventDisdip(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag())); - List eventDisdip = eventReportService.eventDisdip(info); + List eventDisdip = eventReportService.eventDisdip(info); XWPFTable table1 = createTable(doc); - insertRow(doc,table1,centerParagraph,true,"剩余电压","20ms","100ms","500ms","1s","3s","20s","60s","180s"); + insertRow(doc, table1, centerParagraph, true, "剩余电压", "20ms", "100ms", "500ms", "1s", "3s", "20s", "60s", "180s"); for (int j = 0; j < eventDisdip.size(); j++) { DISDIPVO disdipvo = eventDisdip.get(j); - insertRow(doc,table1,centerParagraph,false,disdipvo.getName(),disdipvo.getTwentyMs(),disdipvo.getOneHundredMs(),disdipvo.getFiveHundredMs(),disdipvo.getOneS(),disdipvo.getThreeS(),disdipvo.getTwentyS(),disdipvo.getSixtyS(),disdipvo.getOneEightyS()); + insertRow(doc, table1, centerParagraph, false, disdipvo.getName(), disdipvo.getTwentyMs(), disdipvo.getOneHundredMs(), disdipvo.getFiveHundredMs(), disdipvo.getOneS(), disdipvo.getThreeS(), disdipvo.getTwentyS(), disdipvo.getSixtyS(), disdipvo.getOneEightyS()); } two++; - createTitle(doc,"4."+i+"."+two+" IEC 61000-4-11:(用电终端的电压暂降抗度)","标题 3",400,15); + createTitle(doc, "4." + i + "." + two + " IEC 61000-4-11:(用电终端的电压暂降抗度)", "标题 3", 400, 15); // List iec411VOS = eventAnalysisService.IEC411(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag())); List iec411VOS = eventReportService.IEC411(info); XWPFTable table2 = createTable(doc); - insertRow(doc,table2,centerParagraph,true,"剩余电压","10~20ms","20~100ms","0.1~0.2s","0.2~0.5s","0.5~1s",">1s"); + insertRow(doc, table2, centerParagraph, true, "剩余电压", "10~20ms", "20~100ms", "0.1~0.2s", "0.2~0.5s", "0.5~1s", ">1s"); for (int j = 0; j < iec411VOS.size(); j++) { IEC411VO iec411VO = iec411VOS.get(j); - insertRow(doc,table2,centerParagraph,false,iec411VO.getName(),iec411VO.getTenTwentyMs(),iec411VO.getTwentyOneHundredMs(),iec411VO.getZeroPiontOneTwoS(),iec411VO.getZeroPiontTwoFiveS(),iec411VO.getZeroPiontFive1S(),iec411VO.getGreater1S()); + insertRow(doc, table2, centerParagraph, false, iec411VO.getName(), iec411VO.getTenTwentyMs(), iec411VO.getTwentyOneHundredMs(), iec411VO.getZeroPiontOneTwoS(), iec411VO.getZeroPiontTwoFiveS(), iec411VO.getZeroPiontFive1S(), iec411VO.getGreater1S()); } two++; - createTitle(doc,"4."+i+"."+two+" IEC 61000-2-8:(公共电网电压暂降测量统计)","标题 3",400,15); + createTitle(doc, "4." + i + "." + two + " IEC 61000-2-8:(公共电网电压暂降测量统计)", "标题 3", 400, 15); // List iec28VOS = eventAnalysisService.IEC28(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag())); List iec28VOS = eventReportService.IEC28(info); XWPFTable table3 = createTable(doc); - insertRow(doc,table3,centerParagraph,true,"剩余电压","0.02~0.1s","0.1~0.25s","0.25~0.5s","0.5s~1s","1~3s","3~20s","20~60s","60~180s"); + insertRow(doc, table3, centerParagraph, true, "剩余电压", "0.02~0.1s", "0.1~0.25s", "0.25~0.5s", "0.5s~1s", "1~3s", "3~20s", "20~60s", "60~180s"); for (int j = 0; j < iec28VOS.size(); j++) { IEC28VO iec28VO = iec28VOS.get(j); - insertRow(doc,table3,centerParagraph,false,iec28VO.getName(),iec28VO.getQ(),iec28VO.getW(),iec28VO.getE(),iec28VO.getR(),iec28VO.getT(),iec28VO.getY(),iec28VO.getU(),iec28VO.getI()); + insertRow(doc, table3, centerParagraph, false, iec28VO.getName(), iec28VO.getQ(), iec28VO.getW(), iec28VO.getE(), iec28VO.getR(), iec28VO.getT(), iec28VO.getY(), iec28VO.getU(), iec28VO.getI()); } two++; } i++; } //4.暂降幅值概率分布 - if (exportParam.isGlfbfz() || exportParam.isGlfbsj()){ - createTitle(doc,"4."+i+" 暂降幅值概率分布图","标题 2",200,15); + if (exportParam.isGlfbfz() || exportParam.isGlfbsj()) { + createTitle(doc, "4." + i + " 暂降幅值概率分布图", "标题 2", 200, 15); // ProbabilityVO probabilityVO = eventAnalysisService.getProbabilityDistribution(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag())); ProbabilityVO probabilityVO = eventReportService.getProbabilityDistribution(info); int two = 1; - if (exportParam.isGlfbfz()){ - createTitle(doc,"4."+i+"."+two+" 暂降幅值的概率分函数","标题 3",400,15); + if (exportParam.isGlfbfz()) { + createTitle(doc, "4." + i + "." + two + " 暂降幅值的概率分函数", "标题 3", 400, 15); List ybardata = probabilityVO.getPereventvalue(); List ylinedata = probabilityVO.getEventvalue(); String fz = getFZ(ylinedata, ybardata); - createPic(doc,fz,"暂降幅值的概率分布函数"); + createPic(doc, fz, "暂降幅值的概率分布函数"); two++; } - if (exportParam.isGlfbsj()){ - createTitle(doc,"4."+i+"."+two+" 持续时间的概率分函数","标题 3",400,15); + if (exportParam.isGlfbsj()) { + createTitle(doc, "4." + i + "." + two + " 持续时间的概率分函数", "标题 3", 400, 15); List ybardata = probabilityVO.getPersisttime(); List ylinedata = probabilityVO.getSisttime(); String sj = getSJ(ylinedata, ybardata); - createPic(doc,sj,"持续时间的概率分布函数"); + createPic(doc, sj, "持续时间的概率分布函数"); two++; } i++; @@ -1191,50 +1191,50 @@ public class ReportServiceImpl implements ReportService { //5.月份统计 - if (exportParam.isTjbg() || exportParam.isTjtx()){ - createTitle(doc,"4."+i+" 月份统计","标题 2",200,15); + if (exportParam.isTjbg() || exportParam.isTjtx()) { + createTitle(doc, "4." + i + " 月份统计", "标题 2", 200, 15); int two = 1; List reasonTypeTime = eventAnalysisService.getReasonTypeTime(param); //暂时时间端按月查询不能查询 // List reasonTypeTime = eventReportService.getReasonTypeTime(param,null); - if (exportParam.isTjtx()){ - createTitle(doc,"4."+i+"."+two+" 月份统计图","标题 3",400,15); + if (exportParam.isTjtx()) { + createTitle(doc, "4." + i + "." + two + " 月份统计图", "标题 3", 400, 15); List count = new ArrayList<>(); List name = new ArrayList<>(); - if (exportParam.getFlag()==0){ + if (exportParam.getFlag() == 0) { for (TimeVO timeVO : reasonTypeTime) { - name.add(timeVO.getMonth()+""); + name.add(timeVO.getMonth() + ""); count.add(Integer.parseInt(timeVO.getTimes())); } - }else { + } else { for (TimeVO timeVO : reasonTypeTime) { - name.add(timeVO.getDay()+""); + name.add(timeVO.getDay() + ""); count.add(Integer.parseInt(timeVO.getTimes())); } } - String yftj = getYFTJ(name, count, reasonTypeTime.get(0).getYear(),exportParam.getFlag()); - createPic(doc,yftj,"月份统计图"); + String yftj = getYFTJ(name, count, reasonTypeTime.get(0).getYear(), exportParam.getFlag()); + createPic(doc, yftj, "月份统计图"); two++; } - if (exportParam.isTjbg()){ + if (exportParam.isTjbg()) { XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc); - createTitle(doc,"4."+i+"."+two+" 时间统计表格","标题 3",400,15); + createTitle(doc, "4." + i + "." + two + " 时间统计表格", "标题 3", 400, 15); XWPFTable table1 = createTable(doc); - if (exportParam.getFlag() == 0){ - insertRow(doc,table1,centerParagraph,true,"时间(月)","电压暂降次数"); - }else { - insertRow(doc,table1,centerParagraph,true,"时间(天)","电压暂降次数"); + if (exportParam.getFlag() == 0) { + insertRow(doc, table1, centerParagraph, true, "时间(月)", "电压暂降次数"); + } else { + insertRow(doc, table1, centerParagraph, true, "时间(天)", "电压暂降次数"); } - if (exportParam.getFlag()==0){ + if (exportParam.getFlag() == 0) { for (int j = 0; j < reasonTypeTime.size(); j++) { TimeVO timeVO = reasonTypeTime.get(j); - insertRow(doc,table1,centerParagraph,false,timeVO.getMonth(),timeVO.getTimes()); + insertRow(doc, table1, centerParagraph, false, timeVO.getMonth(), timeVO.getTimes()); } - }else { + } else { for (int j = 0; j < reasonTypeTime.size(); j++) { TimeVO timeVO = reasonTypeTime.get(j); - insertRow(doc,table1,centerParagraph,false,timeVO.getDay(),timeVO.getTimes()); + insertRow(doc, table1, centerParagraph, false, timeVO.getDay(), timeVO.getTimes()); } } two++; @@ -1245,65 +1245,65 @@ public class ReportServiceImpl implements ReportService { //6.原因统计 //6.1整合提出查询语句 - Boolean fly=exportParam.isYybg() || exportParam.isYytx()||exportParam.isLxbg() || exportParam.isLxtx(); - if(fly){ - StatisticVO statistic = eventReportService.getStatistic(info,reasonData,typeData); - if (exportParam.isYybg() || exportParam.isYytx()){ - createTitle(doc,"4."+i+" 原因统计","标题 2",200,15); + Boolean fly = exportParam.isYybg() || exportParam.isYytx() || exportParam.isLxbg() || exportParam.isLxtx(); + if (fly) { + StatisticVO statistic = eventReportService.getStatistic(info, reasonData, typeData); + if (exportParam.isYybg() || exportParam.isYytx()) { + createTitle(doc, "4." + i + " 原因统计", "标题 2", 200, 15); // StatisticVO statistic = eventAnalysisService.getStatistic(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag())); int two = 1; - if (exportParam.isYytx()){ - createTitle(doc,"4."+i+"."+two+" 原因统计图","标题 3",400,15); + if (exportParam.isYytx()) { + createTitle(doc, "4." + i + "." + two + " 原因统计图", "标题 3", 400, 15); List xdata = new ArrayList<>(); List reason = statistic.getReason(); for (ReasonsVO reasonsVO : reason) { xdata.add(reasonsVO.getReason()); } - String tr = getR(xdata, reason,"bar9.ftl"); - createPic(doc,tr,"暂降原因图"); + String tr = getR(xdata, reason, "bar9.ftl"); + createPic(doc, tr, "暂降原因图"); two++; } - if (exportParam.isYybg()){ + if (exportParam.isYybg()) { XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc); - createTitle(doc,"4."+i+"."+two+" 原因统计表格","标题 3",400,15); + createTitle(doc, "4." + i + "." + two + " 原因统计表格", "标题 3", 400, 15); XWPFTable table1 = createTable(doc); - insertRow(doc,table1,centerParagraph,true,"暂降原因","电压暂降次数"); + insertRow(doc, table1, centerParagraph, true, "暂降原因", "电压暂降次数"); List reason = statistic.getReason(); for (int j = 0; j < reason.size(); j++) { ReasonsVO reasonsVO = reason.get(j); - insertRow(doc,table1,centerParagraph,false,reasonsVO.getReason(),reasonsVO.getTimes()+""); + insertRow(doc, table1, centerParagraph, false, reasonsVO.getReason(), reasonsVO.getTimes() + ""); } two++; } i++; } //7.类型统计 - if (exportParam.isLxbg() || exportParam.isLxtx()){ - createTitle(doc,"4."+i+" 类型统计","标题 2",200,15); + if (exportParam.isLxbg() || exportParam.isLxtx()) { + createTitle(doc, "4." + i + " 类型统计", "标题 2", 200, 15); // StatisticVO statistic = eventAnalysisService.getStatistic(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag())); int two = 1; - if (exportParam.isLxtx()){ - createTitle(doc,"4."+i+"."+two+" 类型统计图","标题 3",400,15); + if (exportParam.isLxtx()) { + createTitle(doc, "4." + i + "." + two + " 类型统计图", "标题 3", 400, 15); List xdata = new ArrayList<>(); List types = statistic.getTypes(); for (TypesVO type : types) { - if (type.getTimes()>0){ + if (type.getTimes() > 0) { xdata.add(type.getType()); } } String tr = getT(xdata, types, "bar8.ftl"); - createPic(doc,tr,"暂降类型图"); + createPic(doc, tr, "暂降类型图"); two++; } - if (exportParam.isLxbg()){ - createTitle(doc,"4."+i+"."+two+" 类型统计表格","标题 3",400,15); + if (exportParam.isLxbg()) { + createTitle(doc, "4." + i + "." + two + " 类型统计表格", "标题 3", 400, 15); XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc); XWPFTable table1 = createTable(doc); - insertRow(doc,table1,centerParagraph,true,"暂降原因","电压暂降次数"); + insertRow(doc, table1, centerParagraph, true, "暂降原因", "电压暂降次数"); List types = statistic.getTypes(); for (int j = 0; j < types.size(); j++) { TypesVO typesVO = types.get(j); - insertRow(doc,table1,centerParagraph,false,typesVO.getType(),typesVO.getTimes()+""); + insertRow(doc, table1, centerParagraph, false, typesVO.getType(), typesVO.getTimes() + ""); } two++; } @@ -1322,15 +1322,16 @@ public class ReportServiceImpl implements ReportService { /** * 监测点暂降事件点图赋值 + * * @param plot * @return */ - private ArrayList> getAss(List plot){ + private ArrayList> getAss(List plot) { ArrayList> list = new ArrayList<>(); for (EventDetail eventDetail : plot) { ArrayList doubles = new ArrayList<>(); - doubles.add(Double.parseDouble(eventDetail.getPersistTime()/1000+"")); - doubles.add(Double.parseDouble(String.valueOf(eventDetail.getEventValue()*100))); + doubles.add(Double.parseDouble(eventDetail.getPersistTime() / 1000 + "")); + doubles.add(Double.parseDouble(String.valueOf(eventDetail.getEventValue() * 100))); list.add(doubles); } return list; @@ -1338,28 +1339,26 @@ public class ReportServiceImpl implements ReportService { /** * influxdb查询结果集 + * * @param statisticsParam * @return */ - private List info (StatisticsParam statisticsParam){ + private List info(StatisticsParam statisticsParam) { //构建sql语句 - StringBuffer stringResult=new StringBuffer(); + StringBuffer stringResult = new StringBuffer(); stringResult.append(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE) - .append("time >= '").append( DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getStartTime()))+"'") - .append(" and time <= '").append(DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getEndTime()))+"'") - .append(" and line_id = '").append(statisticsParam.getLineIndex()+"'") - .append(" and wave_type = 5 ").append(Param.TZ_ASIA_SHANGHAI); + .append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getStartTime())) + "'") + .append(" and time <= '").append(DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getEndTime())) + "'") + .append(" and line_id = '").append(statisticsParam.getLineIndex() + "'") + .append(" and (wave_type = 1 or wave_type = 3)").append(Param.TZ_ASIA_SHANGHAI); //结果集映射到对象中 - System.out.println(stringResult); QueryResult query = influxDbUtils.query(stringResult.toString()); InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); return influxDBResultMapper.toPOJO(query, EventDetail.class); } - - - public String getStr(String barName,Map map) throws TemplateException, IOException { + public String getStr(String barName, Map map) throws TemplateException, IOException { String s = FreemarkerUtil.generateString(barName, "com/njcn/event/template", map); return EchartsUtil.generateEchartsBase64(s, "8910"); } @@ -2440,11 +2439,14 @@ public class ReportServiceImpl implements ReportService { //设置类型变量名为暂态 String typeName = "暂态"; - //事件统计表格 + //事件统计表格(部门查询) List generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(areaReportParam).getData(); + //测试id监测点id + //generalDeviceDTOList.get(9).getLineIndexes().add("97ec50b62c84d39d1e15d83e61e06844"); //这是总的监测点id List lineIds = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList()); + //创建部门参数数据 AreaReportParam areaParam = new AreaReportParam(); areaParam.setDeptIndex(areaReportParam.getDeptIndex()); @@ -2465,8 +2467,11 @@ public class ReportServiceImpl implements ReportService { InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); - //提前创建,不然获取不到 - List eventDetailList = new ArrayList<>(); + //提前创建,不然获取不到(初始化数据) + List eventDetailList = getEventDetailListInfo(areaReportParam,lineIds); + //电压集合(统计类型:电压) + List voltageParamList = generalDeviceInfoClient.getPracticalAllDeviceInfo(areaParam).getData(); +// List eventDetailList=new ArrayList<>(); //创建幅值计数器 @@ -2492,30 +2497,12 @@ public class ReportServiceImpl implements ReportService { int oneCount7 = 0; int twoCount4 = 0; - //提前创建计数 + //提前创建计数(累计监测点数量) Integer eventCount = 0; //如果集合中有id将id进行拼接 if (CollectionUtil.isNotEmpty(lineIds)) { - StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds); - - //查询sql语句总条数 - StringBuilder stringTotal = new StringBuilder("SELECT COUNT(num) as aa FROM ").append(Param.EVENT_DETAIL).append(" WHERE ").append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(areaReportParam.getSearchBeginTime()))).append("' and ") - .append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(areaReportParam.getSearchEndTime()))).append("' and "); - stringTotal.append(stringBuilder).append(" and ").append("(wave_type = 0 or wave_type = 1 or wave_type = 2 or wave_type = 3 or wave_type = 4)").append(" tz('Asia/Shanghai')"); - - //总条数 - QueryResult resultTotal = influxDbUtils.query(stringTotal.toString()); - - if (ObjectUtil.isNull(resultTotal.getResults().get(0).getSeries())) { - eventCount = 0; - - } else { - double aDouble = Double.valueOf(resultTotal.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()); - - eventCount = Integer.valueOf((int) aDouble); - } - - + //获取累计监测点数量 + eventCount = eventDetailList.size(); } @@ -2548,7 +2535,7 @@ public class ReportServiceImpl implements ReportService { r.addBreak(); r.addBreak(); r.addBreak(); - r.setText("中国供电公司"); + r.setText(deptName+"供电公司"); r.setBold(true);//设置为粗体 r.setFontSize(14);//字体大小 r.addBreak(); @@ -2557,7 +2544,7 @@ public class ReportServiceImpl implements ReportService { p = doc.createParagraph();// 新建一个段落 p.setAlignment(ParagraphAlignment.CENTER); XWPFRun r1 = p.createRun();//创建段落文本 - r1.setText("电压"+typeName+"事件区域报告"); + r1.setText("电压" + typeName + "事件区域报告"); r1.setBold(true);//设置为粗体 r1.setFontSize(36);//字体大小 r1.addBreak(); @@ -2589,7 +2576,7 @@ public class ReportServiceImpl implements ReportService { p = doc.createParagraph();// 新建一个段落 p.setAlignment(ParagraphAlignment.CENTER); XWPFRun r3 = p.createRun();//创建段落文本 - r3.setText("电压"+typeName+"事件区域报告"); + r3.setText("电压" + typeName + "事件区域报告"); r3.setFontSize(24);//字体大小 @@ -2599,8 +2586,8 @@ public class ReportServiceImpl implements ReportService { p = doc.createParagraph();// 新建一个段落 p.setAlignment(ParagraphAlignment.BOTH); XWPFRun r5 = p.createRun();//创建段落文本 - r5.setText(" 中国电网总共有" + size + "个监测点。中国电网在所选择时间段" + areaReportParam.getSearchBeginTime() + " 至 " + areaReportParam.getSearchEndTime() + - "累计监测到"+typeName+"事件" + eventCount + "条,本报告按照监测点分布,"+typeName+"事件统计,"+typeName+"事件点图,"+typeName+"热力图,"+typeName+"密度图,"+typeName+"概率分布图,事件关联统计,"+typeName+"类型统计,"+typeName+"原因统计等方面进行数据分析。"); + r5.setText(" "+deptName+"电网总共有" + size + "个监测点。"+deptName+"电网在所选择时间段" + areaReportParam.getSearchBeginTime() + " 至 " + areaReportParam.getSearchEndTime() + + "累计监测到" + typeName + "事件" + eventCount + "条,本报告按照监测点分布," + typeName + "事件统计," + typeName + "事件点图," + typeName + "热力图," + typeName + "密度图," + typeName + "概率分布图,事件关联统计," + typeName + "类型统计," + typeName + "原因统计等方面进行数据分析。"); r5.setFontSize(11);//字体大小 @@ -2626,13 +2613,17 @@ public class ReportServiceImpl implements ReportService { createTitle(doc, "4. 汇总信息", "标题 1", 0, 15); - + //1.监测网分布 if (areaReportParam.isMonitorDistributeChart()) { //监测网分布 //在线监测点数 - Integer onLineIdCount = lineFeignClient.getOnLineCount(lineIds).getData(); + Integer onLineIdCount=0; + if(CollectionUtil.isNotEmpty(lineIds)){ + onLineIdCount = lineFeignClient.getOnLineCount(lineIds).getData(); + } + //离线总监测点数 Integer unLineCount = Integer.valueOf(lineIds.size()) - onLineIdCount; //在线率 @@ -2647,25 +2638,6 @@ public class ReportServiceImpl implements ReportService { String onlineRateResult = nf.format(onlineRate); - List resultList = new ArrayList<>(); - //所有子部门的监测点在线离线情况 - for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) { - //创建对象存储结果 - AreaOnlineOrUnlinetParam areaOnlineOrUnlinetParam = new AreaOnlineOrUnlinetParam(); - if (CollectionUtil.isNotEmpty(generalDeviceDTO.getLineIndexes())) { - int sumSize = generalDeviceDTO.getLineIndexes().size(); - Integer onLineIds = lineFeignClient.getOnLineCount(generalDeviceDTO.getLineIndexes()).getData(); - Integer unLinIds = sumSize - onLineIds; - areaOnlineOrUnlinetParam.setName(generalDeviceDTO.getName()); - areaOnlineOrUnlinetParam.setSumCont(sumSize); - areaOnlineOrUnlinetParam.setOnlineCount(onLineIds); - areaOnlineOrUnlinetParam.setUnlineCount(unLinIds); - resultList.add(areaOnlineOrUnlinetParam); - } else { - continue; - } - } - System.out.println(resultList); /** * =========================续写word文档============================================== */ @@ -2676,12 +2648,12 @@ public class ReportServiceImpl implements ReportService { p = doc.createParagraph();// 新建一个段落 p.setAlignment(ParagraphAlignment.BOTH); XWPFRun r12 = p.createRun();//创建段落文本 - r12.setText(" 中国电网总共有监测点" + size + "个。监测点在线率达到" + onlineRateResult + "%(通讯正常为:" + onLineIdCount + "个,通讯异常为:" + unLineCount + "个)" + + r12.setText(" "+deptName+"电网总共有监测点" + size + "个。监测点在线率达到" + onlineRateResult + "%(通讯正常为:" + onLineIdCount + "个,通讯异常为:" + unLineCount + "个)" + "[通讯正常/总监测点数(统计时候排除检修和热备用监测点)],具体见下图:"); r12.setFontSize(11);//字体大小 - //代码 + //todo 分布地图代码未实现 //序号计数进行++ oneCount++; @@ -2690,8 +2662,9 @@ public class ReportServiceImpl implements ReportService { * =======================================word结束========================================= */ } - if (areaReportParam.isEventCountTable()) { - //暂降事件三表 + + //2.暂降事件三表季图像判断 + if (areaReportParam.isEventCountTable()||areaReportParam.isEventCountChart()) { //所有的表结果装入集合 Map areaCount = new HashMap<>(); @@ -2699,29 +2672,17 @@ public class ReportServiceImpl implements ReportService { //暂降事件最多的两个电压 Set topVoltage = new HashSet<>(); - - //传入参数 + //1.部门信息。传入参数(判断统计类型) if (Objects.nonNull(areaReportParam.getStatisticalType().getCode()) && areaReportParam.getStatisticalType().getCode().equals("Power_Network")) { //进行遍历集合获得子区域名及其所有监测点id for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) { //当前子部门下所有id List lineIndexes = generalDeviceDTO.getLineIndexes(); - - //如果集合中有id将id进行拼接 if (CollectionUtil.isNotEmpty(lineIndexes)) { - StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIndexes); - - - //查询sql语句总条数 - StringBuilder stringTotal = new StringBuilder("SELECT COUNT(num) as aa FROM ").append(Param.EVENT_DETAIL).append(" WHERE ").append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(areaReportParam.getSearchBeginTime()))).append("' and ") - .append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(areaReportParam.getSearchEndTime()))).append("' and "); - stringTotal.append(stringBuilder).append(" and ").append("(wave_type = 0 or wave_type = 1 or wave_type = 2 or wave_type = 3 or wave_type = 4)").append(" tz('Asia/Shanghai')"); - //总条数 - QueryResult resultTotal = influxDbUtils.query(stringTotal.toString()); - + QueryResult resultTotal = getEventDetailListInfoNum(areaReportParam,lineIndexes); if (ObjectUtil.isNull(resultTotal.getResults().get(0).getSeries())) { areaCount.put(generalDeviceDTO.getName(), 0); @@ -2738,14 +2699,8 @@ public class ReportServiceImpl implements ReportService { } } - /** - * ============================================================================================== - */ - - - //电压集合 - List areaParamList = generalDeviceInfoClient.getPracticalAllDeviceInfo(areaParam).getData(); - + //2.电压集合(统计类型:电压) + List areaParamList = voltageParamList; //进行遍历集合获得子区域名及其所有监测点id for (GeneralDeviceDTO generalDeviceDTO : areaParamList) { @@ -2754,16 +2709,9 @@ public class ReportServiceImpl implements ReportService { //如果集合中有id将id进行拼接 if (CollectionUtil.isNotEmpty(lineIndexes)) { - StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIndexes); - - - //查询sql语句总条数 - StringBuilder stringTotal = new StringBuilder("SELECT COUNT(num) as aa FROM ").append(Param.EVENT_DETAIL).append(" WHERE ").append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(areaReportParam.getSearchBeginTime()))).append("' and ") - .append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(areaReportParam.getSearchEndTime()))).append("' and "); - stringTotal.append(stringBuilder).append(" and ").append("(wave_type = 0 or wave_type = 1 or wave_type = 2 or wave_type = 3 or wave_type = 4)").append(" tz('Asia/Shanghai')"); //总条数 - QueryResult resultTotal = influxDbUtils.query(stringTotal.toString()); + QueryResult resultTotal = getEventDetailListInfoNum(areaReportParam,lineIndexes); if (ObjectUtil.isNull(resultTotal.getResults().get(0).getSeries())) { voltageCount.put(generalDeviceDTO.getName(), 0); @@ -2779,63 +2727,16 @@ public class ReportServiceImpl implements ReportService { voltageCount.put(generalDeviceDTO.getName(), 0); } } - - //还要对集合中哪个电压暂降次数最多进行计算,挑选出前两位 - //获取entrySet - Set> mapEntries = voltageCount.entrySet(); - - //使用链表来对集合进行排序,使用LinkedList,利于插入元素 - List> result = new LinkedList<>(mapEntries); - //自定义比较器来比较链表中的元素 - Collections.sort(result, new Comparator>() { - //基于entry的值(Entry.getValue()),来排序链表 - @Override - public int compare(Map.Entry o1, Map.Entry o2) { - return o2.getValue().compareTo(o1.getValue()); - } - }); - - //将排好序的存入到LinkedHashMap(可保持顺序)中,需要存储键和值信息对到新的映射中。 - Integer sort = 1; - Map linkMap = new LinkedHashMap<>(); - for (Map.Entry newEntry : result) { - // 取出排名前2的值 - if (sort <= 2) { - linkMap.put(newEntry.getKey(), newEntry.getValue()); - ++sort; - } - } + //数据排序 + Map linkMap = getSort(voltageCount); //最多暂降事件的两个电压名称 topVoltage = linkMap.keySet(); } + + + //根据月份来进行查看暂降 - - - //如果集合中有id将id进行拼接 - if (CollectionUtil.isNotEmpty(lineIds)) { - - List lineIds1 = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList()); - StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds1); - - StringBuilder stringResult = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE). - append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(areaReportParam.getSearchBeginTime()))).append("' and ").append("time <= '") - .append(DateUtil.endOfDay(DateUtil.parse(areaReportParam.getSearchEndTime()))) - .append("' and ").append(stringBuilder).append(" and ").append("(wave_type = 0 or wave_type = 1 or wave_type = 2 or wave_type = 3 or wave_type = 4)") - .append(" tz('Asia/Shanghai')"); - - // 结果集 - QueryResult result = influxDbUtils.query(stringResult.toString()); - - //结果集映射到对象中 - eventDetailList = influxDBResultMapper.toPOJO(result, EventDetailNew.class); - - } else { - //ids为空 - eventDetailList = null; - } - - //提前创建对象 int dayOfMonth = 0; //最后集合 @@ -2843,12 +2744,10 @@ public class ReportServiceImpl implements ReportService { //表格参数 String table = ""; - //月 if ("0".equals(areaReportParam.getInterval())) { table = "月份"; - List dayCount = new ArrayList<>(); List timeList = new ArrayList<>(); DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM"); @@ -2951,7 +2850,9 @@ public class ReportServiceImpl implements ReportService { timeVO.setTimes(countSize.toString()); timeVO.setYear(String.valueOf(beginTime.getYear())); - if (beginTime.getDayOfMonth() < 10) { + //todo 不知道代码是否是写错了,时间判断有问题 +// if (beginTime.getDayOfMonth() < 10) { + if (beginTime.getMonthValue() < 10) { timeVO.setMonth("0" + beginTime.getMonthValue() + ""); } else { timeVO.setMonth(beginTime.getMonthValue() + ""); @@ -2970,7 +2871,9 @@ public class ReportServiceImpl implements ReportService { TimeSVO timeVO = new TimeSVO(); timeVO.setTimes("0"); timeVO.setYear(String.valueOf(beginTime.getYear())); - if (beginTime.getDayOfMonth() < 10) { + + //todo 未知问题:是否是代码错误 + if (beginTime.getMonthValue() < 10) { timeVO.setMonth("0" + beginTime.getMonthValue() + ""); } else { timeVO.setMonth(beginTime.getMonthValue() + ""); @@ -2982,42 +2885,12 @@ public class ReportServiceImpl implements ReportService { beginTime = beginTime.plus(1, ChronoUnit.MONTHS); } - //还要对集合中哪个电压暂降次数最多进行计算,挑选出前两位 - //获取entrySet - Set> mapEntries = resultMap.entrySet(); - - //使用链表来对集合进行排序,使用LinkedList,利于插入元素 - List> result = new LinkedList<>(mapEntries); - //自定义比较器来比较链表中的元素 - Collections.sort(result, new Comparator>() { - //基于entry的值(Entry.getValue()),来排序链表 - @Override - public int compare(Map.Entry o1, Map.Entry o2) { - return o2.getValue().compareTo(o1.getValue()); - } - }); - - //将排好序的存入到LinkedHashMap(可保持顺序)中,需要存储键和值信息对到新的映射中。 - Integer sort = 1; - Map linkMap = new LinkedHashMap<>(); - for (Map.Entry newEntry : result) { - // 取出排名前2的值 - if (sort <= 1) { - linkMap.put(newEntry.getKey(), newEntry.getValue()); - ++sort; - } - } + //数据排序 + Map linkMap = getSort(resultMap); //暂降次数最多 List collect = linkMap.keySet().stream().collect(Collectors.toList()); - //赋值 dayOfMonth = Integer.parseInt(collect.get(0).substring(5, 7)); - - - System.out.println(timeSVoList); - System.out.println(dayOfMonth); - - } else { table = "天数"; @@ -3112,6 +2985,8 @@ public class ReportServiceImpl implements ReportService { while (!beginTime.equals(endTime.plus(1, ChronoUnit.DAYS))) { if (keySet.contains(beginTime.toString())) { + + //获取暂降次数 Integer countSize = resultMap.get(beginTime.toString()); TimeSVO timeVO = new TimeSVO(); timeVO.setTimes(countSize.toString()); @@ -3123,8 +2998,8 @@ public class ReportServiceImpl implements ReportService { } timeVO.setYear(String.valueOf(beginTime.getYear())); - - if (beginTime.getDayOfMonth() < 10) { + //todo 不知道代码是否是写错了,时间判断有问题 + if (beginTime.getMonthValue() < 10) { timeVO.setMonth("0" + beginTime.getMonthValue() + ""); } else { timeVO.setMonth(beginTime.getMonthValue() + ""); @@ -3147,7 +3022,9 @@ public class ReportServiceImpl implements ReportService { timeVO.setDay(beginTime.getDayOfMonth() + ""); } timeVO.setYear(String.valueOf(beginTime.getYear())); - if (beginTime.getDayOfMonth() < 10) { + + //todo 未知问题:是否是代码错误 + if (beginTime.getMonthValue() < 10) { timeVO.setMonth("0" + beginTime.getMonthValue() + ""); } else { timeVO.setMonth(beginTime.getMonthValue() + ""); @@ -3159,858 +3036,79 @@ public class ReportServiceImpl implements ReportService { beginTime = beginTime.plus(1, ChronoUnit.DAYS); } - //还要对集合中哪个电压暂降次数最多进行计算,挑选出前两位 - //获取entrySet - Set> mapEntries = resultMap.entrySet(); - - //使用链表来对集合进行排序,使用LinkedList,利于插入元素 - List> result = new LinkedList<>(mapEntries); - //自定义比较器来比较链表中的元素 - Collections.sort(result, new Comparator>() { - //基于entry的值(Entry.getValue()),来排序链表 - @Override - public int compare(Map.Entry o1, Map.Entry o2) { - return o2.getValue().compareTo(o1.getValue()); - } - }); - - //将排好序的存入到LinkedHashMap(可保持顺序)中,需要存储键和值信息对到新的映射中。 - Integer sort = 1; - Map linkMap = new LinkedHashMap<>(); - for (Map.Entry newEntry : result) { - // 取出排名前2的值 - if (sort <= 1) { - linkMap.put(newEntry.getKey(), newEntry.getValue()); - ++sort; - } - } + //数据排序 + Map linkMap = getSort(resultMap); //暂降次数最多 List collect = linkMap.keySet().stream().collect(Collectors.toList()); //赋值 dayOfMonth = LocalDate.parse(collect.get(0)).getDayOfMonth(); - - System.out.println(timeSVoList); - System.out.println(dayOfMonth); - - } - - //当前部门子部门分别有多少暂降事件 - System.out.println(areaCount); - //转为List对象集合 - List areaCountList = new ArrayList<>(); - for (String s : areaCount.keySet()) { - ReportCountParam reportCountParam = new ReportCountParam(); - reportCountParam.setName(s); - reportCountParam.setCount(areaCount.get(s).toString()); - areaCountList.add(reportCountParam); - } - //当前电压等级分别发生了多少次暂降事件 - System.out.println(voltageCount); - //转为List对象集合 - List voltageCountList = new ArrayList<>(); - for (String s : voltageCount.keySet()) { - ReportCountParam reportCountParam = new ReportCountParam(); - reportCountParam.setName(s); - reportCountParam.setCount(voltageCount.get(s).toString()); - voltageCountList.add(reportCountParam); - } - - //最高暂降事件的两个电压值 - System.out.println(topVoltage); +// System.out.println(topVoltage); //转为List List topVoltageList = new ArrayList<>(); for (String s : topVoltage) { topVoltageList.add(s); } - -/** - * =========================续写word文档============================================== - */ - - //创建表题计数 - int twoCount = 1; - - //与暂降事件图形共享序号 - oneCount5 = oneCount; - - - createTitle(doc, "4." + oneCount + " "+typeName+"事件列表", "标题 2", 200, 11); - - p = doc.createParagraph();// 新建一个段落 - p.setAlignment(ParagraphAlignment.BOTH); - XWPFRun r12 = p.createRun();//创建段落文本 - r12.setText(" 中国电网在所选择的分析时间段内累计监测"+typeName+"记录" + eventCount + "条," + topVoltageList.get(0) + "、" + topVoltageList.get(1) + ""+typeName+"事件居多," + - "第" + dayOfMonth + "" + table + ""+typeName+"事件居多,具体见下表(图):"); - r12.setFontSize(11);//字体大小 - - - createTitle(doc, "4." + oneCount + "." + twoCount + " "+typeName+"事件表格", "标题 3", 400, 11); - - twoCount2 = twoCount; - - //第一张表 - XWPFTable monitorInfo = createTable(doc); - XWPFParagraph monitorInfoExcelParagraph = WordUtils.getCenterParagraph(doc); - - // 表格第一行 - insertRow(doc, monitorInfo, monitorInfoExcelParagraph, true, "区域", "电压"+typeName+"次数"); - - - //塞入数据 - for (int i = 0; i < areaCountList.size(); i++) { - insertRow(doc, monitorInfo, monitorInfoExcelParagraph, false, areaCountList.get(i).getName(), areaCountList.get(i).getCount().toString()); - } - - //第二张表 - XWPFTable monitorInfo1 = createTable(doc); - XWPFParagraph monitorInfoExcelParagraph1 = WordUtils.getCenterParagraph(doc); - - // 表格第一行 - insertRow(doc, monitorInfo1, monitorInfoExcelParagraph1, true, "电压等级", "电压"+typeName+"次数"); - - - //塞入数据 - for (int i = 0; i < voltageCountList.size(); i++) { - insertRow(doc, monitorInfo1, monitorInfoExcelParagraph1, false, voltageCountList.get(i).getName(), voltageCountList.get(i).getCount().toString()); - } - - //第三张表 - XWPFTable monitorInfo2 = createTable(doc); - XWPFParagraph monitorInfoExcelParagraph2 = WordUtils.getCenterParagraph(doc); - - // 表格第一行 - insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, true, "" + table + "", "电压"+typeName+"次数"); - - - //塞入数据 - for (int i = 0; i < timeSVoList.size(); i++) { - insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, false, timeSVoList.get(i).getFulltime(), timeSVoList.get(i).getTimes()); - } - - //序号计数进行++ - oneCount++; - - /** - * =======================================word结束========================================= - */ - - } - if (areaReportParam.isEventCountChart()) { - //暂降事件三图 - - //所有的表结果装入集合 - Map areaCount = new HashMap<>(); - Map voltageCount = new HashMap<>(); - //暂降事件最多的两个电压 - Set topVoltage = new HashSet<>(); - - - //传入参数 - if (Objects.nonNull(areaReportParam.getStatisticalType().getCode()) && areaReportParam.getStatisticalType().getCode().equals("Power_Network")) { - //进行遍历集合获得子区域名及其所有监测点id - for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) { - - //当前子部门下所有id - List lineIndexes = generalDeviceDTO.getLineIndexes(); - - - //如果集合中有id将id进行拼接 - if (CollectionUtil.isNotEmpty(lineIndexes)) { - StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIndexes); - - - //查询sql语句总条数 - StringBuilder stringTotal = new StringBuilder("SELECT COUNT(num) as aa FROM ").append(Param.EVENT_DETAIL).append(" WHERE ").append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(areaReportParam.getSearchBeginTime()))).append("' and ") - .append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(areaReportParam.getSearchEndTime()))).append("' and "); - stringTotal.append(stringBuilder).append(" and ").append("(wave_type = 0 or wave_type = 1 or wave_type = 2 or wave_type = 3 or wave_type = 4)").append(" tz('Asia/Shanghai')"); - - //总条数 - QueryResult resultTotal = influxDbUtils.query(stringTotal.toString()); - - - if (ObjectUtil.isNull(resultTotal.getResults().get(0).getSeries())) { - areaCount.put(generalDeviceDTO.getName(), 0); - - } else { - double count = Double.valueOf(resultTotal.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()); - - areaCount.put(generalDeviceDTO.getName(), Integer.valueOf((int) count)); - } - - } else { - //为空put 0 - areaCount.put(generalDeviceDTO.getName(), 0); - } - } - - /** - * ============================================================================================== - */ - - - //电压集合 - List areaParamList = generalDeviceInfoClient.getPracticalAllDeviceInfo(areaParam).getData(); - - //进行遍历集合获得子区域名及其所有监测点id - for (GeneralDeviceDTO generalDeviceDTO : areaParamList) { - - //当前子部门下所有id - List lineIndexes = generalDeviceDTO.getLineIndexes(); - - //如果集合中有id将id进行拼接 - if (CollectionUtil.isNotEmpty(lineIndexes)) { - StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIndexes); - - - //查询sql语句总条数 - StringBuilder stringTotal = new StringBuilder("SELECT COUNT(num) as aa FROM ").append(Param.EVENT_DETAIL).append(" WHERE ").append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(areaReportParam.getSearchBeginTime()))).append("' and ") - .append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(areaReportParam.getSearchEndTime()))).append("' and "); - stringTotal.append(stringBuilder).append(" and ").append("(wave_type = 0 or wave_type = 1 or wave_type = 2 or wave_type = 3 or wave_type = 4)").append(" tz('Asia/Shanghai')"); - - //总条数 - QueryResult resultTotal = influxDbUtils.query(stringTotal.toString()); - - if (ObjectUtil.isNull(resultTotal.getResults().get(0).getSeries())) { - voltageCount.put(generalDeviceDTO.getName(), 0); - - } else { - double count = Double.valueOf(resultTotal.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()); - - voltageCount.put(generalDeviceDTO.getName(), Integer.valueOf((int) count)); - } - - } else { - //为空put 0 - voltageCount.put(generalDeviceDTO.getName(), 0); - } - } - - //还要对集合中哪个电压暂降次数最多进行计算,挑选出前两位 - //获取entrySet - Set> mapEntries = voltageCount.entrySet(); - - //使用链表来对集合进行排序,使用LinkedList,利于插入元素 - List> result = new LinkedList<>(mapEntries); - //自定义比较器来比较链表中的元素 - Collections.sort(result, new Comparator>() { - //基于entry的值(Entry.getValue()),来排序链表 - @Override - public int compare(Map.Entry o1, Map.Entry o2) { - return o2.getValue().compareTo(o1.getValue()); - } - }); - - //将排好序的存入到LinkedHashMap(可保持顺序)中,需要存储键和值信息对到新的映射中。 - Integer sort = 1; - Map linkMap = new LinkedHashMap<>(); - for (Map.Entry newEntry : result) { - // 取出排名前2的值 - if (sort <= 2) { - linkMap.put(newEntry.getKey(), newEntry.getValue()); - ++sort; - } - } - //最多暂降事件的两个电压名称 - topVoltage = linkMap.keySet(); - - } - //根据月份来进行查看暂降 - - - //如果集合中有id将id进行拼接 - if (CollectionUtil.isNotEmpty(lineIds)) { - - List lineIds1 = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList()); - StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds1); - - StringBuilder stringResult = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE). - append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(areaReportParam.getSearchBeginTime()))).append("' and ").append("time <= '") - .append(DateUtil.endOfDay(DateUtil.parse(areaReportParam.getSearchEndTime()))) - .append("' and ").append(stringBuilder).append(" and ").append("(wave_type = 0 or wave_type = 1 or wave_type = 2 or wave_type = 3 or wave_type = 4)") - .append(" tz('Asia/Shanghai')"); - - // 结果集 - QueryResult result = influxDbUtils.query(stringResult.toString()); - - //结果集映射到对象中 - eventDetailList = influxDBResultMapper.toPOJO(result, EventDetailNew.class); - - } else { - //ids为空 - eventDetailList = null; - } - - - //提前创建对象 - int dayOfMonth = 0; - //最后集合 - List timeSVoList = new ArrayList<>(); - //表格参数 - String table = ""; - - - //月 - if ("1".equals(areaReportParam.getInterval()) || "2".equals(areaReportParam.getInterval())) { - table = "月份"; - - - List dayCount = new ArrayList<>(); - List timeList = new ArrayList<>(); - DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM"); - //进行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.getTimeId()), fmt)); - - //创建对象 - AreaEventMonthParam timeParam = new AreaEventMonthParam(); - timeParam.setDayOrMonth(DateUtil.format(DateUtil.parse(eventDetail.getTimeId()), fmt)); - timeParam.setEventAssIndex(eventDetail.getEventassIndex()); - timeList.add(timeParam); - } - - //Map集和 - Map> relevanceMap = new HashMap<>(); - List list = new ArrayList<>(); - - for (AreaEventMonthParam areaEventMonthParam : timeList) { - //如果存在 - if (relevanceMap.containsKey(areaEventMonthParam.getDayOrMonth())) { - list = relevanceMap.get(areaEventMonthParam.getDayOrMonth()); - list.add(areaEventMonthParam.getEventAssIndex()); - relevanceMap.put(areaEventMonthParam.getDayOrMonth(), (list)); - } else { - List list1 = new ArrayList<>(); - list1.add(areaEventMonthParam.getEventAssIndex()); - relevanceMap.put(areaEventMonthParam.getDayOrMonth(), (list1)); - } - } - //创建map集和装当天和次数 - Map resultMap = new HashMap<>(); - for (String day : dayCount) { - if (resultMap.containsKey(day)) { - resultMap.put(day, resultMap.get(day) + 1); - } else { - resultMap.put(day, 1); - } - } - - Map relevanceCountMap = new HashMap<>(); - - for (String key : relevanceMap.keySet()) { - List 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()); - //因为是比较月份,将起始时间的天数加给结束时间,不然while一直不能结束循环 - - String substring1 = end.toString().substring(0, 8); - String substring2 = beginTime.toString().substring(8, 10); - - String s1 = substring1 + substring2; - LocalDate endTime = LocalDate.parse(s1); - Set keySet = resultMap.keySet(); - - while (!beginTime.equals(endTime.plus(1, ChronoUnit.MONTHS))) { - if (keySet.contains(beginTime.toString().substring(0, 7))) { - Integer countSize = resultMap.get(beginTime.toString().substring(0, 7)); - TimeSVO timeVO = new TimeSVO(); - timeVO.setTimes(countSize.toString()); - timeVO.setYear(String.valueOf(beginTime.getYear())); - - if (beginTime.getDayOfMonth() < 10) { - timeVO.setMonth("0" + beginTime.getMonthValue() + ""); - } else { - timeVO.setMonth(beginTime.getMonthValue() + ""); - } - - 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)); - } - } - timeSVoList.add(timeVO); - } else { - TimeSVO timeVO = new TimeSVO(); - timeVO.setTimes("0"); - timeVO.setYear(String.valueOf(beginTime.getYear())); - if (beginTime.getDayOfMonth() < 10) { - timeVO.setMonth("0" + beginTime.getMonthValue() + ""); - } else { - timeVO.setMonth(beginTime.getMonthValue() + ""); - } - timeVO.setFulltime(beginTime.toString().substring(0, 7)); - timeSVoList.add(timeVO); - } - - beginTime = beginTime.plus(1, ChronoUnit.MONTHS); - } - - //还要对集合中哪个电压暂降次数最多进行计算,挑选出前两位 - //获取entrySet - Set> mapEntries = resultMap.entrySet(); - - //使用链表来对集合进行排序,使用LinkedList,利于插入元素 - List> result = new LinkedList<>(mapEntries); - //自定义比较器来比较链表中的元素 - Collections.sort(result, new Comparator>() { - //基于entry的值(Entry.getValue()),来排序链表 - @Override - public int compare(Map.Entry o1, Map.Entry o2) { - return o2.getValue().compareTo(o1.getValue()); - } - }); - - //将排好序的存入到LinkedHashMap(可保持顺序)中,需要存储键和值信息对到新的映射中。 - Integer sort = 1; - Map linkMap = new LinkedHashMap<>(); - for (Map.Entry newEntry : result) { - // 取出排名前2的值 - if (sort <= 1) { - linkMap.put(newEntry.getKey(), newEntry.getValue()); - ++sort; - } - } - //暂降次数最多 - List collect = linkMap.keySet().stream().collect(Collectors.toList()); - - //赋值 - dayOfMonth = Integer.parseInt(collect.get(0).substring(5, 7)); - - - System.out.println(timeSVoList); - System.out.println(dayOfMonth); - - - } else { - table = "天数"; - - List dayCount = new ArrayList<>(); - List timeList = new ArrayList<>(); - - //进行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.formatDate(DateUtil.parse(eventDetail.getTimeId()))); - - //创建对象 - AreaEventMonthParam timeParam = new AreaEventMonthParam(); - timeParam.setDayOrMonth(DateUtil.formatDate(DateUtil.parse(eventDetail.getTimeId()))); - timeParam.setEventAssIndex(eventDetail.getEventassIndex()); - timeList.add(timeParam); - } - - //Map集和 - Map> relevanceMap = new HashMap<>(); - List list = new ArrayList<>(); - - for (AreaEventMonthParam areaEventMonthParam : timeList) { - //如果存在 - if (relevanceMap.containsKey(areaEventMonthParam.getDayOrMonth())) { - list = relevanceMap.get(areaEventMonthParam.getDayOrMonth()); - list.add(areaEventMonthParam.getEventAssIndex()); - relevanceMap.put(areaEventMonthParam.getDayOrMonth(), (list)); - } else { - List list1 = new ArrayList<>(); - list1.add(areaEventMonthParam.getEventAssIndex()); - relevanceMap.put(areaEventMonthParam.getDayOrMonth(), (list1)); - } - } - //创建map集和装当天和次数 - Map resultMap = new HashMap<>(); - for (String day : dayCount) { - if (resultMap.containsKey(day)) { - resultMap.put(day, resultMap.get(day) + 1); - } else { - resultMap.put(day, 1); - } - } - - Map relevanceCountMap = new HashMap<>(); - - for (String key : relevanceMap.keySet()) { - List 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); - LocalDate endTime = LocalDate.parse(areaReportParam.getSearchEndTime(), fmt); - - Set keySet = resultMap.keySet(); - - while (!beginTime.equals(endTime.plus(1, ChronoUnit.DAYS))) { - if (keySet.contains(beginTime.toString())) { - Integer countSize = resultMap.get(beginTime.toString()); - TimeSVO timeVO = new TimeSVO(); - timeVO.setTimes(countSize.toString()); - - if (beginTime.getDayOfMonth() < 10) { - timeVO.setDay("0" + beginTime.getDayOfMonth() + ""); - } else { - timeVO.setDay(beginTime.getDayOfMonth() + ""); - } - - timeVO.setYear(String.valueOf(beginTime.getYear())); - - if (beginTime.getDayOfMonth() < 10) { - timeVO.setMonth("0" + beginTime.getMonthValue() + ""); - } else { - timeVO.setMonth(beginTime.getMonthValue() + ""); - } - timeVO.setFulltime(beginTime.toString()); - - //遍历 如果时间相同,将所有关联处理事件次数赋值上去 - for (String s : relevanceCountMap.keySet()) { - if (beginTime.toString().equals(s)) { - timeVO.setEventAssIndex(relevanceCountMap.get(s)); - } - } - timeSVoList.add(timeVO); - } else { - TimeSVO timeVO = new TimeSVO(); - timeVO.setTimes("0"); - if (beginTime.getDayOfMonth() < 10) { - timeVO.setDay("0" + beginTime.getDayOfMonth() + ""); - } else { - timeVO.setDay(beginTime.getDayOfMonth() + ""); - } - timeVO.setYear(String.valueOf(beginTime.getYear())); - if (beginTime.getDayOfMonth() < 10) { - timeVO.setMonth("0" + beginTime.getMonthValue() + ""); - } else { - timeVO.setMonth(beginTime.getMonthValue() + ""); - } - timeVO.setFulltime(beginTime.toString()); - timeSVoList.add(timeVO); - } - - beginTime = beginTime.plus(1, ChronoUnit.DAYS); - } - - //还要对集合中哪个电压暂降次数最多进行计算,挑选出前两位 - //获取entrySet - Set> mapEntries = resultMap.entrySet(); - - //使用链表来对集合进行排序,使用LinkedList,利于插入元素 - List> result = new LinkedList<>(mapEntries); - //自定义比较器来比较链表中的元素 - Collections.sort(result, new Comparator>() { - //基于entry的值(Entry.getValue()),来排序链表 - @Override - public int compare(Map.Entry o1, Map.Entry o2) { - return o2.getValue().compareTo(o1.getValue()); - } - }); - - //将排好序的存入到LinkedHashMap(可保持顺序)中,需要存储键和值信息对到新的映射中。 - Integer sort = 1; - Map linkMap = new LinkedHashMap<>(); - for (Map.Entry newEntry : result) { - // 取出排名前2的值 - if (sort <= 1) { - linkMap.put(newEntry.getKey(), newEntry.getValue()); - ++sort; - } - } - //暂降次数最多 - List collect = linkMap.keySet().stream().collect(Collectors.toList()); - - //赋值 - dayOfMonth = LocalDate.parse(collect.get(0)).getDayOfMonth(); - - - System.out.println(timeSVoList); - System.out.println(dayOfMonth); - - - } - - - //当前部门子部门分别有多少暂降事件 - System.out.println(areaCount); - //转为List对象集合 - List areaCountList = new ArrayList<>(); - for (String s : areaCount.keySet()) { - ReportCountParam reportCountParam = new ReportCountParam(); - reportCountParam.setName(s); - reportCountParam.setCount(areaCount.get(s).toString()); - areaCountList.add(reportCountParam); - } - //当前电压等级分别发生了多少次暂降事件 - System.out.println(voltageCount); - //转为List对象集合 - List voltageCountList = new ArrayList<>(); - for (String s : voltageCount.keySet()) { - ReportCountParam reportCountParam = new ReportCountParam(); - reportCountParam.setName(s); - reportCountParam.setCount(voltageCount.get(s).toString()); - voltageCountList.add(reportCountParam); - } - - - //最高暂降事件的两个电压值 - System.out.println(topVoltage); - //转为List - List topVoltageList = new ArrayList<>(); - for (String s : topVoltage) { - topVoltageList.add(s); - } - -/** - * =========================续写word文档============================================== - */ + //表格 if (areaReportParam.isEventCountTable()) { - twoCount2++; - createTitle(doc, "4." + oneCount5 + "." + twoCount2 + " "+typeName+"事件图形", "标题 3", 400, 11); - - - //创建部门与监测点次数的map集合 - Map lineCount = new HashMap<>(); - for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) { - lineCount.put(generalDeviceDTO.getName(), generalDeviceDTO.getLineIndexes().size()); - } - System.out.println(lineCount); - //创建x,y参数 - List xdata = new ArrayList<>(); - List ydata = new ArrayList<>(); - for (ReportCountParam reportCountParam : areaCountList) { - - //将监测点的数量拼接在部门下面 - for (String s : lineCount.keySet()) { - if (s.equals(reportCountParam.getName())) { - xdata.add(reportCountParam.getName() + "\n" + "(" + lineCount.get(s) + ")"); - } - } - - ydata.add(Integer.parseInt(reportCountParam.getCount())); - } - - String qytj = getQYTJ(xdata, ydata); - createPic(doc, qytj, ""+typeName+"事件图形"); - - - //月份统计 - //创建x,y参数 - List xdata1 = new ArrayList<>(); - List ydata1 = new ArrayList<>(); - List ydata2 = new ArrayList<>(); - for (TimeSVO timeSVO : timeSVoList) { - xdata1.add(timeSVO.getFulltime()); - ydata1.add(Integer.parseInt(timeSVO.getTimes())); - ydata2.add(timeSVO.getEventAssIndex()); - - } - - - String year = areaReportParam.getSearchBeginTime().substring(0, 4); - List tableList = new ArrayList<>(); - tableList.add(table); - - String yftj = getYFTJ1(xdata1, ydata1, ydata2, year, tableList); - createPic(doc, yftj, ""+typeName+"事件图形"); - - - - //创建部门与监测点次数的map集合 - List areaParamList = generalDeviceInfoClient.getPracticalAllDeviceInfo(areaParam).getData(); - Map lineCount1 = new HashMap<>(); - for (GeneralDeviceDTO generalDeviceDTO : areaParamList) { - lineCount1.put(generalDeviceDTO.getName(), generalDeviceDTO.getLineIndexes().size()); - } - //创建x,y参数 - List xdata3 = new ArrayList<>(); - List ydata3 = new ArrayList<>(); - for (ReportCountParam reportCountParam : voltageCountList) { - - //将监测点的数量拼接在部门下面 - for (String s : lineCount1.keySet()) { - if (s.equals(reportCountParam.getName())) { - xdata3.add(reportCountParam.getName() + "\n" + "(" + lineCount1.get(s) + ")"); - } - } - - ydata3.add(Integer.parseInt(reportCountParam.getCount())); - } - String dydj = getDYDJ(xdata3, ydata3); - createPic(doc, dydj, ""+typeName+"事件图形"); - - - /** - * =======================================word结束========================================= - */ - } else { //创建表题计数 int twoCount = 1; + //与暂降事件图形共享序号 + oneCount5 = oneCount; - createTitle(doc, "4." + oneCount + " "+typeName+"事件列表", "标题 2", 200, 11); + createTitle(doc, "4." + oneCount + " " + typeName + "事件列表", "标题 2", 200, 11); p = doc.createParagraph();// 新建一个段落 p.setAlignment(ParagraphAlignment.BOTH); XWPFRun r12 = p.createRun();//创建段落文本 - r12.setText(" 中国电网在所选择的分析时间段内累计监测"+typeName+"记录" + eventCount + "条," + topVoltageList.get(0) + "、" + topVoltageList.get(1) + ""+typeName+"事件居多," + - "第" + dayOfMonth + "" + table + ""+typeName+"事件居多,具体见下表(图):"); + r12.setText(" "+deptName+"电网在所选择的分析时间段内累计监测" + typeName + "记录" + eventCount + "条," + topVoltageList.get(0) + "、" + topVoltageList.get(1) + "" + typeName + "事件居多," + + "第" + dayOfMonth + "" + table + "" + typeName + "事件居多,具体见下表(图):"); r12.setFontSize(11);//字体大小 - createTitle(doc, "4." + oneCount + "." + twoCount + " "+typeName+"事件图形", "标题 3", 400, 11); + createTitle(doc, "4." + oneCount + "." + twoCount + " " + typeName + "事件表格", "标题 3", 400, 11); + twoCount2 = twoCount; - //创建部门与监测点次数的map集合 - Map lineCount = new HashMap<>(); - for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) { - lineCount.put(generalDeviceDTO.getName(), generalDeviceDTO.getLineIndexes().size()); - } - System.out.println(lineCount); - //创建x,y参数 - List xdata = new ArrayList<>(); - List ydata = new ArrayList<>(); - for (ReportCountParam reportCountParam : areaCountList) { - - //将监测点的数量拼接在部门下面 - for (String s : lineCount.keySet()) { - if (s.equals(reportCountParam.getName())) { - xdata.add(reportCountParam.getName() + "\n" + "(" + lineCount.get(s) + ")"); - } - } - - ydata.add(Integer.parseInt(reportCountParam.getCount())); - } - - String qytj = getQYTJ(xdata, ydata); - createPic(doc, qytj, ""+typeName+"事件图形"); - - - //月份统计 - //创建x,y参数 - List xdata1 = new ArrayList<>(); - List ydata1 = new ArrayList<>(); - List ydata2 = new ArrayList<>(); - for (TimeSVO timeSVO : timeSVoList) { - xdata1.add(timeSVO.getFulltime()); - ydata1.add(Integer.parseInt(timeSVO.getTimes())); - ydata2.add(timeSVO.getEventAssIndex()); - + //第一张表 + XWPFTable monitorInfo = createTable(doc); + XWPFParagraph monitorInfoExcelParagraph = WordUtils.getCenterParagraph(doc); + // 表格第一行 + insertRow(doc, monitorInfo, monitorInfoExcelParagraph, true, "区域", "电压" + typeName + "次数"); + //塞入数据 + for (String s : areaCount.keySet()) { + insertRow(doc, monitorInfo, monitorInfoExcelParagraph, false, s, areaCount.get(s).toString()); } - String year = areaReportParam.getSearchBeginTime().substring(0, 4); - List tableList = new ArrayList<>(); - tableList.add(table); - String yftj = getYFTJ1(xdata1, ydata1, ydata2, year, tableList); - createPic(doc, yftj, ""+typeName+"事件图形"); - - - - //创建部门与监测点次数的map集合 - Map lineCount1 = new HashMap<>(); - List areaParamList = generalDeviceInfoClient.getPracticalAllDeviceInfo(areaParam).getData(); - for (GeneralDeviceDTO generalDeviceDTO : areaParamList) { - lineCount1.put(generalDeviceDTO.getName(), generalDeviceDTO.getLineIndexes().size()); - } - //创建x,y参数 - List xdata3 = new ArrayList<>(); - List ydata3 = new ArrayList<>(); - for (ReportCountParam reportCountParam : voltageCountList) { - - //将监测点的数量拼接在部门下面 - for (String s : lineCount1.keySet()) { - if (s.equals(reportCountParam.getName())) { - xdata3.add(reportCountParam.getName() + "\n" + "(" + lineCount1.get(s) + ")"); - } - } - - ydata3.add(Integer.parseInt(reportCountParam.getCount())); + //第二张表 + XWPFTable monitorInfo1 = createTable(doc); + XWPFParagraph monitorInfoExcelParagraph1 = WordUtils.getCenterParagraph(doc); + // 表格第一行 + insertRow(doc, monitorInfo1, monitorInfoExcelParagraph1, true, "电压等级", "电压" + typeName + "次数"); + //塞入数据 + for (String s : voltageCount.keySet()) { + insertRow(doc, monitorInfo1, monitorInfoExcelParagraph1, false, s, voltageCount.get(s).toString()); } - String dydj = getDYDJ(xdata3, ydata3); - createPic(doc, dydj, ""+typeName+"事件图形"); + //第三张表 + XWPFTable monitorInfo2 = createTable(doc); + XWPFParagraph monitorInfoExcelParagraph2 = WordUtils.getCenterParagraph(doc); + // 表格第一行 + insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, true, "" + table + "", "电压" + typeName + "次数"); + //塞入数据 + for (int i = 0; i < timeSVoList.size(); i++) { + insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, false, timeSVoList.get(i).getFulltime(), timeSVoList.get(i).getTimes()); + } //序号计数进行++ oneCount++; @@ -4021,1460 +3119,93 @@ public class ReportServiceImpl implements ReportService { } - } - if (areaReportParam.isDensityTable()) { - //暂降密度表格 - - AreaTableParam areaTableParam = new AreaTableParam(); - - //监测点id拼接 - StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds); - areaTableParam.setStartTime(areaReportParam.getSearchBeginTime()); - areaTableParam.setEndTime(areaReportParam.getSearchEndTime()); - areaTableParam.setStringBuilder(stringBuilder); - - - //创建结果集合 - List info = TableInfo(areaTableParam); - - //将sql结果集放入,共用一个sql,减少查询时间 - AreaTableParam areaTableParam1 = new AreaTableParam(); - areaTableParam1.setStartTime(areaReportParam.getSearchBeginTime()); - areaTableParam1.setEndTime(areaReportParam.getSearchEndTime()); - areaTableParam1.setStringBuilder(stringBuilder); - areaTableParam1.setInfo(info); - - - List iEC28VOResult = IEC28Area(areaTableParam1); - List iEC411VOResult = IEC411Area(areaTableParam1); - List dISDIPVOResult = eventDisdipArea(areaTableParam1); - - - //IEC411 <1% 总共集合 - List lessOneIEC411 = new ArrayList<>(); - //IEC411 1~40% 总共集合 - List lessFortyIEC411 = new ArrayList<>(); - //IEC411 40~70% 总共集合 - List lessSeventyIEC411 = new ArrayList<>(); - - - //IEC28 <1% 总共集合 - List lessOneIEC28 = new ArrayList<>(); - //IEC411 <10 总共集合 - List lessTenIEC28 = new ArrayList<>(); - //IEC411 <20 总共集合 - List lessTwentyIEC28 = new ArrayList<>(); - //IEC411 <30 总共集合 - List lessThirtyIEC28 = new ArrayList<>(); - //IEC411 <40 总共集合 - List lessFortyIEC28 = new ArrayList<>(); - //IEC411 <50 总共集合 - List lessFiftyIEC28 = new ArrayList<>(); - //IEC411 <60 总共集合 - List lessSixtyIEC28 = new ArrayList<>(); - //IEC411 <70 总共集合 - List lessSeventyIEC28 = new ArrayList<>(); - //IEC411 <80 总共集合 - List lessEightyIEC28 = new ArrayList<>(); - //IEC411 <90 总共集合 - List lessNinetyIEC28 = new ArrayList<>(); - //IEC411 <120 总共集合 - List lessHundredTwentyIEC28 = new ArrayList<>(); - //IEC411 <130 总共集合 - List lessHundredThirtyIEC28 = new ArrayList<>(); - //IEC411 <140 总共集合 - List lessHundredFortyIEC28 = new ArrayList<>(); - //IEC411 <150 总共集合 - List lessHundredFiftyIEC28 = new ArrayList<>(); - //IEC411 <160 总共集合 - List lessHundredSixtyIEC28 = new ArrayList<>(); - //IEC411 <170 总共集合 - List lessHundredSeventyIEC28 = new ArrayList<>(); - //IEC411 <180 总共集合 - List lessHundredEightyIEC28 = new ArrayList<>(); - - - //DISDIP = 10% - List equalTenDISDIP = new ArrayList<>(); - //DISDIP = 40% - List equalFortyDISDIP = new ArrayList<>(); - //DISDIP = 70% - List equalSeventyDISDIP = new ArrayList<>(); - //DISDIP = 85% - List equalEightyFiveDISDIP = new ArrayList<>(); - //DISDIP = 90% - List equalNinetyDISDIP = new ArrayList<>(); - - - //遍历将集合按名称分开 - for (int i1 = 0; i1 < iEC411VOResult.size(); i1++) { - if ("<1%".equals(iEC411VOResult.get(i1).getName())) { - //放入集合 - lessOneIEC411.add(iEC411VOResult.get(i1)); - } else if ("1~40%".equals(iEC411VOResult.get(i1).getName())) { - //放入集合 - lessFortyIEC411.add(iEC411VOResult.get(i1)); - } else { - //放入集合 - lessSeventyIEC411.add(iEC411VOResult.get(i1)); - } - } - - - //遍历将集合按名称分开 - for (int i1 = 0; i1 < iEC28VOResult.size(); i1++) { - if ("1>U>=0".equals(iEC28VOResult.get(i1).getName())) { - //放入集合 - lessOneIEC28.add(iEC28VOResult.get(i1)); - } else if ("10>U>=1".equals(iEC28VOResult.get(i1).getName())) { - //放入集合 - lessTenIEC28.add(iEC28VOResult.get(i1)); - } else if ("20>U>=10".equals(iEC28VOResult.get(i1).getName())) { - //放入集合 - lessTwentyIEC28.add(iEC28VOResult.get(i1)); - } else if ("30>U>=20".equals(iEC28VOResult.get(i1).getName())) { - //放入集合 - lessThirtyIEC28.add(iEC28VOResult.get(i1)); - } else if ("40>U>=30".equals(iEC28VOResult.get(i1).getName())) { - //放入集合 - lessFortyIEC28.add(iEC28VOResult.get(i1)); - } else if ("50>U>=40".equals(iEC28VOResult.get(i1).getName())) { - //放入集合 - lessFiftyIEC28.add(iEC28VOResult.get(i1)); - } else if ("60>U>=50".equals(iEC28VOResult.get(i1).getName())) { - //放入集合 - lessSixtyIEC28.add(iEC28VOResult.get(i1)); - } else if ("70>U>=60".equals(iEC28VOResult.get(i1).getName())) { - //放入集合 - lessSeventyIEC28.add(iEC28VOResult.get(i1)); - } else if ("80>U>=70".equals(iEC28VOResult.get(i1).getName())) { - //放入集合 - lessEightyIEC28.add(iEC28VOResult.get(i1)); - } else if ("90>U>=80".equals(iEC28VOResult.get(i1).getName())) { - //放入集合 - lessNinetyIEC28.add(iEC28VOResult.get(i1)); - } else if ("120>U>=110".equals(iEC28VOResult.get(i1).getName())) { - //放入集合 - lessHundredTwentyIEC28.add(iEC28VOResult.get(i1)); - } else if ("130>U>=120".equals(iEC28VOResult.get(i1).getName())) { - //放入集合 - lessHundredThirtyIEC28.add(iEC28VOResult.get(i1)); - } else if ("140>U>=130".equals(iEC28VOResult.get(i1).getName())) { - //放入集合 - lessHundredFortyIEC28.add(iEC28VOResult.get(i1)); - } else if ("150>U>=140".equals(iEC28VOResult.get(i1).getName())) { - //放入集合 - lessHundredFiftyIEC28.add(iEC28VOResult.get(i1)); - } else if ("160>U>=150".equals(iEC28VOResult.get(i1).getName())) { - //放入集合 - lessHundredSixtyIEC28.add(iEC28VOResult.get(i1)); - } else if ("170>U>=160".equals(iEC28VOResult.get(i1).getName())) { - //放入集合 - lessHundredSeventyIEC28.add(iEC28VOResult.get(i1)); - } else { - //放入集合 - lessHundredEightyIEC28.add(iEC28VOResult.get(i1)); - - } - } - - //遍历将集合按名称分开 - for (int i1 = 0; i1 < dISDIPVOResult.size(); i1++) { - if ("10%".equals(dISDIPVOResult.get(i1).getName())) { - //放入集合 - equalTenDISDIP.add(dISDIPVOResult.get(i1)); - } else if ("40%".equals(dISDIPVOResult.get(i1).getName())) { - //放入集合 - equalFortyDISDIP.add(dISDIPVOResult.get(i1)); - } else if ("70%".equals(dISDIPVOResult.get(i1).getName())) { - //放入集合 - equalSeventyDISDIP.add(dISDIPVOResult.get(i1)); - } else if ("85%".equals(dISDIPVOResult.get(i1).getName())) { - //放入集合 - equalEightyFiveDISDIP.add(dISDIPVOResult.get(i1)); - } else { - //放入集合 - equalNinetyDISDIP.add(dISDIPVOResult.get(i1)); - } - } - - - //遍历集合中的参数 - IEC411CountParam iec411LessOne = new IEC411CountParam(); - - for (IEC411VO iec411VO : lessOneIEC411) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(iec411LessOne.getName())) { - iec411LessOne.setName(iec411VO.getName()); - } - - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(iec411VO.getTenTwentyMs())) { - int tenToTwenty = iec411LessOne.getTenToTwenty(); - iec411LessOne.setTenToTwenty(tenToTwenty++); - } - if (!"0".equals(iec411VO.getTwentyOneHundredMs())) { - int twentyToHundred = iec411LessOne.getTwentyToHundred(); - iec411LessOne.setTenToTwenty(twentyToHundred++); - } - if (!"0".equals(iec411VO.getZeroPiontOneTwoS())) { - int zeroOneToZeroTwo = iec411LessOne.getZeroOneToZeroTwo(); - iec411LessOne.setTenToTwenty(zeroOneToZeroTwo++); - } - if (!"0".equals(iec411VO.getZeroPiontTwoFiveS())) { - int zeroTwoToZeroFive = iec411LessOne.getZeroTwoToZeroFive(); - iec411LessOne.setTenToTwenty(zeroTwoToZeroFive++); - } - if (!"0".equals(iec411VO.getZeroPiontFive1S())) { - int zeroFiveToOne = iec411LessOne.getZeroFiveToOne(); - iec411LessOne.setTenToTwenty(zeroFiveToOne++); - } - if (!"0".equals(iec411VO.getGreater1S())) { - int lessOne = iec411LessOne.getLessOne(); - iec411LessOne.setTenToTwenty(lessOne++); - } - } - - //遍历集合中的参数 - IEC411CountParam iec411LessForty = new IEC411CountParam(); - - for (IEC411VO iec411VO : lessFortyIEC411) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(iec411LessForty.getName())) { - iec411LessForty.setName(iec411VO.getName()); - } - - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(iec411VO.getTenTwentyMs())) { - int tenToTwenty = iec411LessForty.getTenToTwenty(); - iec411LessForty.setTenToTwenty(tenToTwenty++); - } - if (!"0".equals(iec411VO.getTwentyOneHundredMs())) { - int twentyToHundred = iec411LessForty.getTwentyToHundred(); - iec411LessForty.setTenToTwenty(twentyToHundred++); - } - if (!"0".equals(iec411VO.getZeroPiontOneTwoS())) { - int zeroOneToZeroTwo = iec411LessForty.getZeroOneToZeroTwo(); - iec411LessForty.setTenToTwenty(zeroOneToZeroTwo++); - } - if (!"0".equals(iec411VO.getZeroPiontTwoFiveS())) { - int zeroTwoToZeroFive = iec411LessForty.getZeroTwoToZeroFive(); - iec411LessForty.setTenToTwenty(zeroTwoToZeroFive++); - } - if (!"0".equals(iec411VO.getZeroPiontFive1S())) { - int zeroFiveToOne = iec411LessForty.getZeroFiveToOne(); - iec411LessForty.setTenToTwenty(zeroFiveToOne++); - } - if (!"0".equals(iec411VO.getGreater1S())) { - int lessOne = iec411LessForty.getLessOne(); - iec411LessForty.setTenToTwenty(lessOne++); - } - } - - //遍历集合中的参数 - IEC411CountParam iec411LessSeventy = new IEC411CountParam(); - - for (IEC411VO iec411VO : lessSeventyIEC411) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(iec411LessSeventy.getName())) { - iec411LessSeventy.setName(iec411VO.getName()); - } - - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(iec411VO.getTenTwentyMs())) { - int tenToTwenty = iec411LessSeventy.getTenToTwenty(); - iec411LessSeventy.setTenToTwenty(tenToTwenty++); - } - if (!"0".equals(iec411VO.getTwentyOneHundredMs())) { - int twentyToHundred = iec411LessSeventy.getTwentyToHundred(); - iec411LessSeventy.setTenToTwenty(twentyToHundred++); - } - if (!"0".equals(iec411VO.getZeroPiontOneTwoS())) { - int zeroOneToZeroTwo = iec411LessSeventy.getZeroOneToZeroTwo(); - iec411LessSeventy.setTenToTwenty(zeroOneToZeroTwo++); - } - if (!"0".equals(iec411VO.getZeroPiontTwoFiveS())) { - int zeroTwoToZeroFive = iec411LessSeventy.getZeroTwoToZeroFive(); - iec411LessSeventy.setTenToTwenty(zeroTwoToZeroFive++); - } - if (!"0".equals(iec411VO.getZeroPiontFive1S())) { - int zeroFiveToOne = iec411LessSeventy.getZeroFiveToOne(); - iec411LessSeventy.setTenToTwenty(zeroFiveToOne++); - } - if (!"0".equals(iec411VO.getGreater1S())) { - int lessOne = iec411LessSeventy.getLessOne(); - iec411LessSeventy.setTenToTwenty(lessOne++); - } - } - - /** - * ================第一张表结束====================== - */ - - DISDIPCountParam disdipEqualTen = new DISDIPCountParam(); - - for (DISDIPVO disdipvo : equalTenDISDIP) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(disdipEqualTen.getName())) { - disdipEqualTen.setName(disdipvo.getName()); - } - - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(disdipvo.getTwentyMs())) { - int twenty = disdipEqualTen.getTwenty(); - disdipEqualTen.setTwenty(twenty++); - } - if (!"0".equals(disdipvo.getOneHundredMs())) { - int oneHundredMS = disdipEqualTen.getOneHundredMS(); - disdipEqualTen.setOneHundredMS(oneHundredMS++); - } - if (!"0".equals(disdipvo.getFiveHundredMs())) { - int fiveHundredMS = disdipEqualTen.getFiveHundredMS(); - disdipEqualTen.setOneHundredMS(fiveHundredMS++); - } - if (!"0".equals(disdipvo.getOneS())) { - int one = disdipEqualTen.getOne(); - disdipEqualTen.setOne(one++); - } - if (!"0".equals(disdipvo.getThreeS())) { - int three = disdipEqualTen.getThree(); - disdipEqualTen.setOne(three++); - } - if (!"0".equals(disdipvo.getTwentyS())) { - int twenty = disdipEqualTen.getTwenty(); - disdipEqualTen.setTwenty(twenty++); - } - if (!"0".equals(disdipvo.getSixtyS())) { - int sixty = disdipEqualTen.getSixty(); - disdipEqualTen.setSixty(sixty++); - } - if (!"0".equals(disdipvo.getOneEightyS())) { - int oneHundredAndEighty = disdipEqualTen.getOneHundredAndEighty(); - disdipEqualTen.setOneHundredAndEighty(oneHundredAndEighty++); - } - } - - DISDIPCountParam disdipEqualForty = new DISDIPCountParam(); - - for (DISDIPVO disdipvo : equalFortyDISDIP) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(disdipEqualForty.getName())) { - disdipEqualForty.setName(disdipvo.getName()); - } - - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(disdipvo.getTwentyMs())) { - int twenty = disdipEqualForty.getTwenty(); - disdipEqualForty.setTwenty(twenty++); - } - if (!"0".equals(disdipvo.getOneHundredMs())) { - int oneHundredMS = disdipEqualForty.getOneHundredMS(); - disdipEqualForty.setOneHundredMS(oneHundredMS++); - } - if (!"0".equals(disdipvo.getFiveHundredMs())) { - int fiveHundredMS = disdipEqualForty.getFiveHundredMS(); - disdipEqualForty.setOneHundredMS(fiveHundredMS++); - } - if (!"0".equals(disdipvo.getOneS())) { - int one = disdipEqualForty.getOne(); - disdipEqualForty.setOne(one++); - } - if (!"0".equals(disdipvo.getThreeS())) { - int three = disdipEqualForty.getThree(); - disdipEqualForty.setOne(three++); - } - if (!"0".equals(disdipvo.getTwentyS())) { - int twenty = disdipEqualForty.getTwenty(); - disdipEqualForty.setTwenty(twenty++); - } - if (!"0".equals(disdipvo.getSixtyS())) { - int sixty = disdipEqualForty.getSixty(); - disdipEqualForty.setSixty(sixty++); - } - if (!"0".equals(disdipvo.getOneEightyS())) { - int oneHundredAndEighty = disdipEqualForty.getOneHundredAndEighty(); - disdipEqualForty.setOneHundredAndEighty(oneHundredAndEighty++); - } - } - - DISDIPCountParam disdipEqualSeventy = new DISDIPCountParam(); - - for (DISDIPVO disdipvo : equalSeventyDISDIP) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(disdipEqualSeventy.getName())) { - disdipEqualSeventy.setName(disdipvo.getName()); - } - - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(disdipvo.getTwentyMs())) { - int twenty = disdipEqualSeventy.getTwenty(); - disdipEqualSeventy.setTwenty(twenty++); - } - if (!"0".equals(disdipvo.getOneHundredMs())) { - int oneHundredMS = disdipEqualSeventy.getOneHundredMS(); - disdipEqualSeventy.setOneHundredMS(oneHundredMS++); - } - if (!"0".equals(disdipvo.getFiveHundredMs())) { - int fiveHundredMS = disdipEqualSeventy.getFiveHundredMS(); - disdipEqualSeventy.setOneHundredMS(fiveHundredMS++); - } - if (!"0".equals(disdipvo.getOneS())) { - int one = disdipEqualSeventy.getOne(); - disdipEqualSeventy.setOne(one++); - } - if (!"0".equals(disdipvo.getThreeS())) { - int three = disdipEqualSeventy.getThree(); - disdipEqualSeventy.setOne(three++); - } - if (!"0".equals(disdipvo.getTwentyS())) { - int twenty = disdipEqualSeventy.getTwenty(); - disdipEqualSeventy.setTwenty(twenty++); - } - if (!"0".equals(disdipvo.getSixtyS())) { - int sixty = disdipEqualSeventy.getSixty(); - disdipEqualSeventy.setSixty(sixty++); - } - if (!"0".equals(disdipvo.getOneEightyS())) { - int oneHundredAndEighty = disdipEqualSeventy.getOneHundredAndEighty(); - disdipEqualSeventy.setOneHundredAndEighty(oneHundredAndEighty++); - } - } - - DISDIPCountParam disdipEqualEighty = new DISDIPCountParam(); - - for (DISDIPVO disdipvo : equalEightyFiveDISDIP) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(disdipEqualEighty.getName())) { - disdipEqualEighty.setName(disdipvo.getName()); - } - - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(disdipvo.getTwentyMs())) { - int twenty = disdipEqualEighty.getTwenty(); - disdipEqualEighty.setTwenty(twenty++); - } - if (!"0".equals(disdipvo.getOneHundredMs())) { - int oneHundredMS = disdipEqualEighty.getOneHundredMS(); - disdipEqualEighty.setOneHundredMS(oneHundredMS++); - } - if (!"0".equals(disdipvo.getFiveHundredMs())) { - int fiveHundredMS = disdipEqualEighty.getFiveHundredMS(); - disdipEqualEighty.setOneHundredMS(fiveHundredMS++); - } - if (!"0".equals(disdipvo.getOneS())) { - int one = disdipEqualEighty.getOne(); - disdipEqualEighty.setOne(one++); - } - if (!"0".equals(disdipvo.getThreeS())) { - int three = disdipEqualEighty.getThree(); - disdipEqualEighty.setOne(three++); - } - if (!"0".equals(disdipvo.getTwentyS())) { - int twenty = disdipEqualEighty.getTwenty(); - disdipEqualEighty.setTwenty(twenty++); - } - if (!"0".equals(disdipvo.getSixtyS())) { - int sixty = disdipEqualEighty.getSixty(); - disdipEqualEighty.setSixty(sixty++); - } - if (!"0".equals(disdipvo.getOneEightyS())) { - int oneHundredAndEighty = disdipEqualEighty.getOneHundredAndEighty(); - disdipEqualEighty.setOneHundredAndEighty(oneHundredAndEighty++); - } - } - DISDIPCountParam disdipEqualNinety = new DISDIPCountParam(); - - for (DISDIPVO disdipvo : equalNinetyDISDIP) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(disdipEqualNinety.getName())) { - disdipEqualNinety.setName(disdipvo.getName()); - } - - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(disdipvo.getTwentyMs())) { - int twenty = disdipEqualNinety.getTwenty(); - disdipEqualNinety.setTwenty(twenty++); - } - if (!"0".equals(disdipvo.getOneHundredMs())) { - int oneHundredMS = disdipEqualNinety.getOneHundredMS(); - disdipEqualNinety.setOneHundredMS(oneHundredMS++); - } - if (!"0".equals(disdipvo.getFiveHundredMs())) { - int fiveHundredMS = disdipEqualNinety.getFiveHundredMS(); - disdipEqualNinety.setOneHundredMS(fiveHundredMS++); - } - if (!"0".equals(disdipvo.getOneS())) { - int one = disdipEqualNinety.getOne(); - disdipEqualNinety.setOne(one++); - } - if (!"0".equals(disdipvo.getThreeS())) { - int three = disdipEqualNinety.getThree(); - disdipEqualNinety.setOne(three++); - } - if (!"0".equals(disdipvo.getTwentyS())) { - int twenty = disdipEqualNinety.getTwenty(); - disdipEqualNinety.setTwenty(twenty++); - } - if (!"0".equals(disdipvo.getSixtyS())) { - int sixty = disdipEqualNinety.getSixty(); - disdipEqualNinety.setSixty(sixty++); - } - if (!"0".equals(disdipvo.getOneEightyS())) { - int oneHundredAndEighty = disdipEqualNinety.getOneHundredAndEighty(); - disdipEqualNinety.setOneHundredAndEighty(oneHundredAndEighty++); - } - } - - /** - * ======================第二张表结束============================== - */ - - //创建计数对象 - IEC28CountParam iec28CountLessOne = new IEC28CountParam(); - - for (IEC28VO iec28VO : lessOneIEC28) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(iec28CountLessOne.getName())) { - iec28CountLessOne.setName(iec28VO.getName()); - } - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(iec28VO.getQ())) { - int zeroZeroTwoToZeroOne = iec28CountLessOne.getZeroZeroTwoToZeroOne(); - iec28CountLessOne.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++); - } - if (!"0".equals(iec28VO.getW())) { - int zeroOneToZeroTwentyFive = iec28CountLessOne.getZeroOneToZeroTwentyFive(); - iec28CountLessOne.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++); - } - if (!"0".equals(iec28VO.getE())) { - int zeroTwentyFiveToZeroFive = iec28CountLessOne.getZeroTwentyFiveToZeroFive(); - iec28CountLessOne.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++); - } - if (!"0".equals(iec28VO.getR())) { - int zeroFiveToOne = iec28CountLessOne.getZeroFiveToOne(); - iec28CountLessOne.setZeroFiveToOne(zeroFiveToOne++); - } - if (!"0".equals(iec28VO.getT())) { - int oneToThree = iec28CountLessOne.getOneToThree(); - iec28CountLessOne.setOneToThree(oneToThree++); - } - if (!"0".equals(iec28VO.getY())) { - int threeToTwenty = iec28CountLessOne.getThreeToTwenty(); - iec28CountLessOne.setThreeToTwenty(threeToTwenty++); - } - if (!"0".equals(iec28VO.getU())) { - int twentyToSixty = iec28CountLessOne.getTwentyToSixty(); - iec28CountLessOne.setTwentyToSixty(twentyToSixty++); - } - if (!"0".equals(iec28VO.getI())) { - int sixtyToOneHundredAndEighty = iec28CountLessOne.getSixtyToOneHundredAndEighty(); - iec28CountLessOne.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++); - } - } - - - //创建计数对象 - IEC28CountParam iec28CountLessTen = new IEC28CountParam(); - - for (IEC28VO iec28VO : lessTenIEC28) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(iec28CountLessTen.getName())) { - iec28CountLessTen.setName(iec28VO.getName()); - } - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(iec28VO.getQ())) { - int zeroZeroTwoToZeroOne = iec28CountLessTen.getZeroZeroTwoToZeroOne(); - iec28CountLessTen.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++); - } - if (!"0".equals(iec28VO.getW())) { - int zeroOneToZeroTwentyFive = iec28CountLessTen.getZeroOneToZeroTwentyFive(); - iec28CountLessTen.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++); - } - if (!"0".equals(iec28VO.getE())) { - int zeroTwentyFiveToZeroFive = iec28CountLessTen.getZeroTwentyFiveToZeroFive(); - iec28CountLessTen.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++); - } - if (!"0".equals(iec28VO.getR())) { - int zeroFiveToOne = iec28CountLessTen.getZeroFiveToOne(); - iec28CountLessTen.setZeroFiveToOne(zeroFiveToOne++); - } - if (!"0".equals(iec28VO.getT())) { - int oneToThree = iec28CountLessTen.getOneToThree(); - iec28CountLessTen.setOneToThree(oneToThree++); - } - if (!"0".equals(iec28VO.getY())) { - int threeToTwenty = iec28CountLessTen.getThreeToTwenty(); - iec28CountLessTen.setThreeToTwenty(threeToTwenty++); - } - if (!"0".equals(iec28VO.getU())) { - int twentyToSixty = iec28CountLessTen.getTwentyToSixty(); - iec28CountLessTen.setTwentyToSixty(twentyToSixty++); - } - if (!"0".equals(iec28VO.getI())) { - int sixtyToOneHundredAndEighty = iec28CountLessTen.getSixtyToOneHundredAndEighty(); - iec28CountLessTen.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++); - } - } - - - //创建计数对象 - IEC28CountParam iec28CountLessTwenty = new IEC28CountParam(); - - for (IEC28VO iec28VO : lessTwentyIEC28) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(iec28CountLessTwenty.getName())) { - iec28CountLessTwenty.setName(iec28VO.getName()); - } - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(iec28VO.getQ())) { - int zeroZeroTwoToZeroOne = iec28CountLessTwenty.getZeroZeroTwoToZeroOne(); - iec28CountLessTwenty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++); - } - if (!"0".equals(iec28VO.getW())) { - int zeroOneToZeroTwentyFive = iec28CountLessTwenty.getZeroOneToZeroTwentyFive(); - iec28CountLessTwenty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++); - } - if (!"0".equals(iec28VO.getE())) { - int zeroTwentyFiveToZeroFive = iec28CountLessTwenty.getZeroTwentyFiveToZeroFive(); - iec28CountLessTwenty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++); - } - if (!"0".equals(iec28VO.getR())) { - int zeroFiveToOne = iec28CountLessTwenty.getZeroFiveToOne(); - iec28CountLessTwenty.setZeroFiveToOne(zeroFiveToOne++); - } - if (!"0".equals(iec28VO.getT())) { - int oneToThree = iec28CountLessTwenty.getOneToThree(); - iec28CountLessTwenty.setOneToThree(oneToThree++); - } - if (!"0".equals(iec28VO.getY())) { - int threeToTwenty = iec28CountLessTwenty.getThreeToTwenty(); - iec28CountLessTwenty.setThreeToTwenty(threeToTwenty++); - } - if (!"0".equals(iec28VO.getU())) { - int twentyToSixty = iec28CountLessTwenty.getTwentyToSixty(); - iec28CountLessTwenty.setTwentyToSixty(twentyToSixty++); - } - if (!"0".equals(iec28VO.getI())) { - int sixtyToOneHundredAndEighty = iec28CountLessTwenty.getSixtyToOneHundredAndEighty(); - iec28CountLessTwenty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++); - } - } - - - //创建计数对象 - IEC28CountParam iec28CountLessThirty = new IEC28CountParam(); - - for (IEC28VO iec28VO : lessThirtyIEC28) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(iec28CountLessThirty.getName())) { - iec28CountLessThirty.setName(iec28VO.getName()); - } - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(iec28VO.getQ())) { - int zeroZeroTwoToZeroOne = iec28CountLessThirty.getZeroZeroTwoToZeroOne(); - iec28CountLessThirty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++); - } - if (!"0".equals(iec28VO.getW())) { - int zeroOneToZeroTwentyFive = iec28CountLessThirty.getZeroOneToZeroTwentyFive(); - iec28CountLessThirty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++); - } - if (!"0".equals(iec28VO.getE())) { - int zeroTwentyFiveToZeroFive = iec28CountLessThirty.getZeroTwentyFiveToZeroFive(); - iec28CountLessThirty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++); - } - if (!"0".equals(iec28VO.getR())) { - int zeroFiveToOne = iec28CountLessThirty.getZeroFiveToOne(); - iec28CountLessThirty.setZeroFiveToOne(zeroFiveToOne++); - } - if (!"0".equals(iec28VO.getT())) { - int oneToThree = iec28CountLessThirty.getOneToThree(); - iec28CountLessThirty.setOneToThree(oneToThree++); - } - if (!"0".equals(iec28VO.getY())) { - int threeToTwenty = iec28CountLessThirty.getThreeToTwenty(); - iec28CountLessThirty.setThreeToTwenty(threeToTwenty++); - } - if (!"0".equals(iec28VO.getU())) { - int twentyToSixty = iec28CountLessThirty.getTwentyToSixty(); - iec28CountLessThirty.setTwentyToSixty(twentyToSixty++); - } - if (!"0".equals(iec28VO.getI())) { - int sixtyToOneHundredAndEighty = iec28CountLessThirty.getSixtyToOneHundredAndEighty(); - iec28CountLessThirty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++); - } - } - - - //创建计数对象 - IEC28CountParam iec28CountLessForty = new IEC28CountParam(); - - for (IEC28VO iec28VO : lessFortyIEC28) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(iec28CountLessForty.getName())) { - iec28CountLessForty.setName(iec28VO.getName()); - } - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(iec28VO.getQ())) { - int zeroZeroTwoToZeroOne = iec28CountLessForty.getZeroZeroTwoToZeroOne(); - iec28CountLessForty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++); - } - if (!"0".equals(iec28VO.getW())) { - int zeroOneToZeroTwentyFive = iec28CountLessForty.getZeroOneToZeroTwentyFive(); - iec28CountLessForty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++); - } - if (!"0".equals(iec28VO.getE())) { - int zeroTwentyFiveToZeroFive = iec28CountLessForty.getZeroTwentyFiveToZeroFive(); - iec28CountLessForty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++); - } - if (!"0".equals(iec28VO.getR())) { - int zeroFiveToOne = iec28CountLessForty.getZeroFiveToOne(); - iec28CountLessForty.setZeroFiveToOne(zeroFiveToOne++); - } - if (!"0".equals(iec28VO.getT())) { - int oneToThree = iec28CountLessForty.getOneToThree(); - iec28CountLessForty.setOneToThree(oneToThree++); - } - if (!"0".equals(iec28VO.getY())) { - int threeToTwenty = iec28CountLessForty.getThreeToTwenty(); - iec28CountLessForty.setThreeToTwenty(threeToTwenty++); - } - if (!"0".equals(iec28VO.getU())) { - int twentyToSixty = iec28CountLessForty.getTwentyToSixty(); - iec28CountLessForty.setTwentyToSixty(twentyToSixty++); - } - if (!"0".equals(iec28VO.getI())) { - int sixtyToOneHundredAndEighty = iec28CountLessForty.getSixtyToOneHundredAndEighty(); - iec28CountLessForty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++); - } - } - - - //创建计数对象 - IEC28CountParam iec28CountLessFifty = new IEC28CountParam(); - - for (IEC28VO iec28VO : lessFiftyIEC28) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(iec28CountLessFifty.getName())) { - iec28CountLessFifty.setName(iec28VO.getName()); - } - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(iec28VO.getQ())) { - int zeroZeroTwoToZeroOne = iec28CountLessFifty.getZeroZeroTwoToZeroOne(); - iec28CountLessFifty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++); - } - if (!"0".equals(iec28VO.getW())) { - int zeroOneToZeroTwentyFive = iec28CountLessFifty.getZeroOneToZeroTwentyFive(); - iec28CountLessFifty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++); - } - if (!"0".equals(iec28VO.getE())) { - int zeroTwentyFiveToZeroFive = iec28CountLessFifty.getZeroTwentyFiveToZeroFive(); - iec28CountLessFifty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++); - } - if (!"0".equals(iec28VO.getR())) { - int zeroFiveToOne = iec28CountLessFifty.getZeroFiveToOne(); - iec28CountLessFifty.setZeroFiveToOne(zeroFiveToOne++); - } - if (!"0".equals(iec28VO.getT())) { - int oneToThree = iec28CountLessFifty.getOneToThree(); - iec28CountLessFifty.setOneToThree(oneToThree++); - } - if (!"0".equals(iec28VO.getY())) { - int threeToTwenty = iec28CountLessFifty.getThreeToTwenty(); - iec28CountLessFifty.setThreeToTwenty(threeToTwenty++); - } - if (!"0".equals(iec28VO.getU())) { - int twentyToSixty = iec28CountLessFifty.getTwentyToSixty(); - iec28CountLessFifty.setTwentyToSixty(twentyToSixty++); - } - if (!"0".equals(iec28VO.getI())) { - int sixtyToOneHundredAndEighty = iec28CountLessFifty.getSixtyToOneHundredAndEighty(); - iec28CountLessFifty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++); - } - } - - - //创建计数对象 - IEC28CountParam iec28CountLessSixty = new IEC28CountParam(); - - for (IEC28VO iec28VO : lessSixtyIEC28) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(iec28CountLessSixty.getName())) { - iec28CountLessSixty.setName(iec28VO.getName()); - } - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(iec28VO.getQ())) { - int zeroZeroTwoToZeroOne = iec28CountLessSixty.getZeroZeroTwoToZeroOne(); - iec28CountLessSixty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++); - } - if (!"0".equals(iec28VO.getW())) { - int zeroOneToZeroTwentyFive = iec28CountLessSixty.getZeroOneToZeroTwentyFive(); - iec28CountLessSixty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++); - } - if (!"0".equals(iec28VO.getE())) { - int zeroTwentyFiveToZeroFive = iec28CountLessSixty.getZeroTwentyFiveToZeroFive(); - iec28CountLessSixty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++); - } - if (!"0".equals(iec28VO.getR())) { - int zeroFiveToOne = iec28CountLessSixty.getZeroFiveToOne(); - iec28CountLessSixty.setZeroFiveToOne(zeroFiveToOne++); - } - if (!"0".equals(iec28VO.getT())) { - int oneToThree = iec28CountLessSixty.getOneToThree(); - iec28CountLessSixty.setOneToThree(oneToThree++); - } - if (!"0".equals(iec28VO.getY())) { - int threeToTwenty = iec28CountLessSixty.getThreeToTwenty(); - iec28CountLessSixty.setThreeToTwenty(threeToTwenty++); - } - if (!"0".equals(iec28VO.getU())) { - int twentyToSixty = iec28CountLessSixty.getTwentyToSixty(); - iec28CountLessSixty.setTwentyToSixty(twentyToSixty++); - } - if (!"0".equals(iec28VO.getI())) { - int sixtyToOneHundredAndEighty = iec28CountLessSixty.getSixtyToOneHundredAndEighty(); - iec28CountLessSixty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++); - } - } - - - //创建计数对象 - IEC28CountParam iec28CountLessSeventy = new IEC28CountParam(); - - for (IEC28VO iec28VO : lessSeventyIEC28) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(iec28CountLessSeventy.getName())) { - iec28CountLessSeventy.setName(iec28VO.getName()); - } - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(iec28VO.getQ())) { - int zeroZeroTwoToZeroOne = iec28CountLessSeventy.getZeroZeroTwoToZeroOne(); - iec28CountLessSeventy.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++); - } - if (!"0".equals(iec28VO.getW())) { - int zeroOneToZeroTwentyFive = iec28CountLessSeventy.getZeroOneToZeroTwentyFive(); - iec28CountLessSeventy.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++); - } - if (!"0".equals(iec28VO.getE())) { - int zeroTwentyFiveToZeroFive = iec28CountLessSeventy.getZeroTwentyFiveToZeroFive(); - iec28CountLessSeventy.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++); - } - if (!"0".equals(iec28VO.getR())) { - int zeroFiveToOne = iec28CountLessSeventy.getZeroFiveToOne(); - iec28CountLessSeventy.setZeroFiveToOne(zeroFiveToOne++); - } - if (!"0".equals(iec28VO.getT())) { - int oneToThree = iec28CountLessSeventy.getOneToThree(); - iec28CountLessSeventy.setOneToThree(oneToThree++); - } - if (!"0".equals(iec28VO.getY())) { - int threeToTwenty = iec28CountLessSeventy.getThreeToTwenty(); - iec28CountLessSeventy.setThreeToTwenty(threeToTwenty++); - } - if (!"0".equals(iec28VO.getU())) { - int twentyToSixty = iec28CountLessSeventy.getTwentyToSixty(); - iec28CountLessSeventy.setTwentyToSixty(twentyToSixty++); - } - if (!"0".equals(iec28VO.getI())) { - int sixtyToOneHundredAndEighty = iec28CountLessSeventy.getSixtyToOneHundredAndEighty(); - iec28CountLessSeventy.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++); - } - } - - - //创建计数对象 - IEC28CountParam iec28CountLessEighty = new IEC28CountParam(); - - for (IEC28VO iec28VO : lessEightyIEC28) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(iec28CountLessEighty.getName())) { - iec28CountLessEighty.setName(iec28VO.getName()); - } - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(iec28VO.getQ())) { - int zeroZeroTwoToZeroOne = iec28CountLessEighty.getZeroZeroTwoToZeroOne(); - iec28CountLessEighty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++); - } - if (!"0".equals(iec28VO.getW())) { - int zeroOneToZeroTwentyFive = iec28CountLessEighty.getZeroOneToZeroTwentyFive(); - iec28CountLessEighty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++); - } - if (!"0".equals(iec28VO.getE())) { - int zeroTwentyFiveToZeroFive = iec28CountLessEighty.getZeroTwentyFiveToZeroFive(); - iec28CountLessEighty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++); - } - if (!"0".equals(iec28VO.getR())) { - int zeroFiveToOne = iec28CountLessEighty.getZeroFiveToOne(); - iec28CountLessEighty.setZeroFiveToOne(zeroFiveToOne++); - } - if (!"0".equals(iec28VO.getT())) { - int oneToThree = iec28CountLessEighty.getOneToThree(); - iec28CountLessEighty.setOneToThree(oneToThree++); - } - if (!"0".equals(iec28VO.getY())) { - int threeToTwenty = iec28CountLessEighty.getThreeToTwenty(); - iec28CountLessEighty.setThreeToTwenty(threeToTwenty++); - } - if (!"0".equals(iec28VO.getU())) { - int twentyToSixty = iec28CountLessEighty.getTwentyToSixty(); - iec28CountLessEighty.setTwentyToSixty(twentyToSixty++); - } - if (!"0".equals(iec28VO.getI())) { - int sixtyToOneHundredAndEighty = iec28CountLessEighty.getSixtyToOneHundredAndEighty(); - iec28CountLessEighty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++); - } - } - - //创建计数对象 - IEC28CountParam iec28CountLessNinety = new IEC28CountParam(); - - for (IEC28VO iec28VO : lessNinetyIEC28) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(iec28CountLessNinety.getName())) { - iec28CountLessNinety.setName(iec28VO.getName()); - } - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(iec28VO.getQ())) { - int zeroZeroTwoToZeroOne = iec28CountLessNinety.getZeroZeroTwoToZeroOne(); - iec28CountLessNinety.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++); - } - if (!"0".equals(iec28VO.getW())) { - int zeroOneToZeroTwentyFive = iec28CountLessNinety.getZeroOneToZeroTwentyFive(); - iec28CountLessNinety.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++); - } - if (!"0".equals(iec28VO.getE())) { - int zeroTwentyFiveToZeroFive = iec28CountLessNinety.getZeroTwentyFiveToZeroFive(); - iec28CountLessNinety.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++); - } - if (!"0".equals(iec28VO.getR())) { - int zeroFiveToOne = iec28CountLessNinety.getZeroFiveToOne(); - iec28CountLessNinety.setZeroFiveToOne(zeroFiveToOne++); - } - if (!"0".equals(iec28VO.getT())) { - int oneToThree = iec28CountLessNinety.getOneToThree(); - iec28CountLessNinety.setOneToThree(oneToThree++); - } - if (!"0".equals(iec28VO.getY())) { - int threeToTwenty = iec28CountLessNinety.getThreeToTwenty(); - iec28CountLessNinety.setThreeToTwenty(threeToTwenty++); - } - if (!"0".equals(iec28VO.getU())) { - int twentyToSixty = iec28CountLessNinety.getTwentyToSixty(); - iec28CountLessNinety.setTwentyToSixty(twentyToSixty++); - } - if (!"0".equals(iec28VO.getI())) { - int sixtyToOneHundredAndEighty = iec28CountLessNinety.getSixtyToOneHundredAndEighty(); - iec28CountLessNinety.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++); - } - } - - //创建计数对象 - IEC28CountParam iec28CountLessHundredTwenty = new IEC28CountParam(); - - for (IEC28VO iec28VO : lessHundredTwentyIEC28) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(iec28CountLessHundredTwenty.getName())) { - iec28CountLessHundredTwenty.setName(iec28VO.getName()); - } - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(iec28VO.getQ())) { - int zeroZeroTwoToZeroOne = iec28CountLessHundredTwenty.getZeroZeroTwoToZeroOne(); - iec28CountLessHundredTwenty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++); - } - if (!"0".equals(iec28VO.getW())) { - int zeroOneToZeroTwentyFive = iec28CountLessHundredTwenty.getZeroOneToZeroTwentyFive(); - iec28CountLessHundredTwenty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++); - } - if (!"0".equals(iec28VO.getE())) { - int zeroTwentyFiveToZeroFive = iec28CountLessHundredTwenty.getZeroTwentyFiveToZeroFive(); - iec28CountLessHundredTwenty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++); - } - if (!"0".equals(iec28VO.getR())) { - int zeroFiveToOne = iec28CountLessHundredTwenty.getZeroFiveToOne(); - iec28CountLessHundredTwenty.setZeroFiveToOne(zeroFiveToOne++); - } - if (!"0".equals(iec28VO.getT())) { - int oneToThree = iec28CountLessHundredTwenty.getOneToThree(); - iec28CountLessHundredTwenty.setOneToThree(oneToThree++); - } - if (!"0".equals(iec28VO.getY())) { - int threeToTwenty = iec28CountLessHundredTwenty.getThreeToTwenty(); - iec28CountLessHundredTwenty.setThreeToTwenty(threeToTwenty++); - } - if (!"0".equals(iec28VO.getU())) { - int twentyToSixty = iec28CountLessHundredTwenty.getTwentyToSixty(); - iec28CountLessHundredTwenty.setTwentyToSixty(twentyToSixty++); - } - if (!"0".equals(iec28VO.getI())) { - int sixtyToOneHundredAndEighty = iec28CountLessHundredTwenty.getSixtyToOneHundredAndEighty(); - iec28CountLessHundredTwenty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++); - } - } - - - //创建计数对象 - IEC28CountParam iec28CountLessHundredThirty = new IEC28CountParam(); - - for (IEC28VO iec28VO : lessHundredThirtyIEC28) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(iec28CountLessHundredThirty.getName())) { - iec28CountLessHundredThirty.setName(iec28VO.getName()); - } - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(iec28VO.getQ())) { - int zeroZeroTwoToZeroOne = iec28CountLessHundredThirty.getZeroZeroTwoToZeroOne(); - iec28CountLessHundredThirty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++); - } - if (!"0".equals(iec28VO.getW())) { - int zeroOneToZeroTwentyFive = iec28CountLessHundredThirty.getZeroOneToZeroTwentyFive(); - iec28CountLessHundredThirty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++); - } - if (!"0".equals(iec28VO.getE())) { - int zeroTwentyFiveToZeroFive = iec28CountLessHundredThirty.getZeroTwentyFiveToZeroFive(); - iec28CountLessHundredThirty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++); - } - if (!"0".equals(iec28VO.getR())) { - int zeroFiveToOne = iec28CountLessHundredThirty.getZeroFiveToOne(); - iec28CountLessHundredThirty.setZeroFiveToOne(zeroFiveToOne++); - } - if (!"0".equals(iec28VO.getT())) { - int oneToThree = iec28CountLessHundredThirty.getOneToThree(); - iec28CountLessHundredThirty.setOneToThree(oneToThree++); - } - if (!"0".equals(iec28VO.getY())) { - int threeToTwenty = iec28CountLessHundredThirty.getThreeToTwenty(); - iec28CountLessHundredThirty.setThreeToTwenty(threeToTwenty++); - } - if (!"0".equals(iec28VO.getU())) { - int twentyToSixty = iec28CountLessHundredThirty.getTwentyToSixty(); - iec28CountLessHundredThirty.setTwentyToSixty(twentyToSixty++); - } - if (!"0".equals(iec28VO.getI())) { - int sixtyToOneHundredAndEighty = iec28CountLessHundredThirty.getSixtyToOneHundredAndEighty(); - iec28CountLessHundredThirty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++); - } - } - - //创建计数对象 - IEC28CountParam iec28CountLessHundredForty = new IEC28CountParam(); - - for (IEC28VO iec28VO : lessHundredFortyIEC28) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(iec28CountLessHundredForty.getName())) { - iec28CountLessHundredForty.setName(iec28VO.getName()); - } - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(iec28VO.getQ())) { - int zeroZeroTwoToZeroOne = iec28CountLessHundredForty.getZeroZeroTwoToZeroOne(); - iec28CountLessHundredForty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++); - } - if (!"0".equals(iec28VO.getW())) { - int zeroOneToZeroTwentyFive = iec28CountLessHundredForty.getZeroOneToZeroTwentyFive(); - iec28CountLessHundredForty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++); - } - if (!"0".equals(iec28VO.getE())) { - int zeroTwentyFiveToZeroFive = iec28CountLessHundredForty.getZeroTwentyFiveToZeroFive(); - iec28CountLessHundredForty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++); - } - if (!"0".equals(iec28VO.getR())) { - int zeroFiveToOne = iec28CountLessHundredForty.getZeroFiveToOne(); - iec28CountLessHundredForty.setZeroFiveToOne(zeroFiveToOne++); - } - if (!"0".equals(iec28VO.getT())) { - int oneToThree = iec28CountLessHundredForty.getOneToThree(); - iec28CountLessHundredForty.setOneToThree(oneToThree++); - } - if (!"0".equals(iec28VO.getY())) { - int threeToTwenty = iec28CountLessHundredForty.getThreeToTwenty(); - iec28CountLessHundredForty.setThreeToTwenty(threeToTwenty++); - } - if (!"0".equals(iec28VO.getU())) { - int twentyToSixty = iec28CountLessHundredForty.getTwentyToSixty(); - iec28CountLessHundredForty.setTwentyToSixty(twentyToSixty++); - } - if (!"0".equals(iec28VO.getI())) { - int sixtyToOneHundredAndEighty = iec28CountLessHundredForty.getSixtyToOneHundredAndEighty(); - iec28CountLessHundredForty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++); - } - } - - - //创建计数对象 - IEC28CountParam iec28CountLessHundredFifty = new IEC28CountParam(); - - for (IEC28VO iec28VO : lessHundredFiftyIEC28) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(iec28CountLessHundredFifty.getName())) { - iec28CountLessHundredFifty.setName(iec28VO.getName()); - } - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(iec28VO.getQ())) { - int zeroZeroTwoToZeroOne = iec28CountLessHundredFifty.getZeroZeroTwoToZeroOne(); - iec28CountLessHundredFifty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++); - } - if (!"0".equals(iec28VO.getW())) { - int zeroOneToZeroTwentyFive = iec28CountLessHundredFifty.getZeroOneToZeroTwentyFive(); - iec28CountLessHundredFifty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++); - } - if (!"0".equals(iec28VO.getE())) { - int zeroTwentyFiveToZeroFive = iec28CountLessHundredFifty.getZeroTwentyFiveToZeroFive(); - iec28CountLessHundredFifty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++); - } - if (!"0".equals(iec28VO.getR())) { - int zeroFiveToOne = iec28CountLessHundredFifty.getZeroFiveToOne(); - iec28CountLessHundredFifty.setZeroFiveToOne(zeroFiveToOne++); - } - if (!"0".equals(iec28VO.getT())) { - int oneToThree = iec28CountLessHundredFifty.getOneToThree(); - iec28CountLessHundredFifty.setOneToThree(oneToThree++); - } - if (!"0".equals(iec28VO.getY())) { - int threeToTwenty = iec28CountLessHundredFifty.getThreeToTwenty(); - iec28CountLessHundredFifty.setThreeToTwenty(threeToTwenty++); - } - if (!"0".equals(iec28VO.getU())) { - int twentyToSixty = iec28CountLessHundredFifty.getTwentyToSixty(); - iec28CountLessHundredFifty.setTwentyToSixty(twentyToSixty++); - } - if (!"0".equals(iec28VO.getI())) { - int sixtyToOneHundredAndEighty = iec28CountLessHundredFifty.getSixtyToOneHundredAndEighty(); - iec28CountLessHundredFifty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++); - } - } - - - //创建计数对象 - IEC28CountParam iec28CountLessHundredSixty = new IEC28CountParam(); - - for (IEC28VO iec28VO : lessHundredSixtyIEC28) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(iec28CountLessHundredSixty.getName())) { - iec28CountLessHundredSixty.setName(iec28VO.getName()); - } - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(iec28VO.getQ())) { - int zeroZeroTwoToZeroOne = iec28CountLessHundredSixty.getZeroZeroTwoToZeroOne(); - iec28CountLessHundredSixty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++); - } - if (!"0".equals(iec28VO.getW())) { - int zeroOneToZeroTwentyFive = iec28CountLessHundredSixty.getZeroOneToZeroTwentyFive(); - iec28CountLessHundredSixty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++); - } - if (!"0".equals(iec28VO.getE())) { - int zeroTwentyFiveToZeroFive = iec28CountLessHundredSixty.getZeroTwentyFiveToZeroFive(); - iec28CountLessHundredSixty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++); - } - if (!"0".equals(iec28VO.getR())) { - int zeroFiveToOne = iec28CountLessHundredSixty.getZeroFiveToOne(); - iec28CountLessHundredSixty.setZeroFiveToOne(zeroFiveToOne++); - } - if (!"0".equals(iec28VO.getT())) { - int oneToThree = iec28CountLessHundredSixty.getOneToThree(); - iec28CountLessHundredSixty.setOneToThree(oneToThree++); - } - if (!"0".equals(iec28VO.getY())) { - int threeToTwenty = iec28CountLessHundredSixty.getThreeToTwenty(); - iec28CountLessHundredSixty.setThreeToTwenty(threeToTwenty++); - } - if (!"0".equals(iec28VO.getU())) { - int twentyToSixty = iec28CountLessHundredSixty.getTwentyToSixty(); - iec28CountLessHundredSixty.setTwentyToSixty(twentyToSixty++); - } - if (!"0".equals(iec28VO.getI())) { - int sixtyToOneHundredAndEighty = iec28CountLessHundredSixty.getSixtyToOneHundredAndEighty(); - iec28CountLessHundredSixty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++); - } - } - - - //创建计数对象 - IEC28CountParam iec28CountLessHundredSeventy = new IEC28CountParam(); - - for (IEC28VO iec28VO : lessHundredSeventyIEC28) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(iec28CountLessHundredSeventy.getName())) { - iec28CountLessHundredSeventy.setName(iec28VO.getName()); - } - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(iec28VO.getQ())) { - int zeroZeroTwoToZeroOne = iec28CountLessHundredSeventy.getZeroZeroTwoToZeroOne(); - iec28CountLessHundredSeventy.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++); - } - if (!"0".equals(iec28VO.getW())) { - int zeroOneToZeroTwentyFive = iec28CountLessHundredSeventy.getZeroOneToZeroTwentyFive(); - iec28CountLessHundredSeventy.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++); - } - if (!"0".equals(iec28VO.getE())) { - int zeroTwentyFiveToZeroFive = iec28CountLessHundredSeventy.getZeroTwentyFiveToZeroFive(); - iec28CountLessHundredSeventy.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++); - } - if (!"0".equals(iec28VO.getR())) { - int zeroFiveToOne = iec28CountLessHundredSeventy.getZeroFiveToOne(); - iec28CountLessHundredSeventy.setZeroFiveToOne(zeroFiveToOne++); - } - if (!"0".equals(iec28VO.getT())) { - int oneToThree = iec28CountLessHundredSeventy.getOneToThree(); - iec28CountLessHundredSeventy.setOneToThree(oneToThree++); - } - if (!"0".equals(iec28VO.getY())) { - int threeToTwenty = iec28CountLessHundredSeventy.getThreeToTwenty(); - iec28CountLessHundredSeventy.setThreeToTwenty(threeToTwenty++); - } - if (!"0".equals(iec28VO.getU())) { - int twentyToSixty = iec28CountLessHundredSeventy.getTwentyToSixty(); - iec28CountLessHundredSeventy.setTwentyToSixty(twentyToSixty++); - } - if (!"0".equals(iec28VO.getI())) { - int sixtyToOneHundredAndEighty = iec28CountLessHundredSeventy.getSixtyToOneHundredAndEighty(); - iec28CountLessHundredSeventy.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++); - } - } - - - //创建计数对象 - IEC28CountParam iec28CountLessHundredEighty = new IEC28CountParam(); - - for (IEC28VO iec28VO : lessHundredEightyIEC28) { - //获取当前剩余电压名称,不为空就进行添加 - if (Objects.isNull(iec28CountLessHundredEighty.getName())) { - iec28CountLessHundredEighty.setName(iec28VO.getName()); - } - //如果参数不等于0对对象中的参数进行++ - if (!"0".equals(iec28VO.getQ())) { - int zeroZeroTwoToZeroOne = iec28CountLessHundredEighty.getZeroZeroTwoToZeroOne(); - iec28CountLessHundredEighty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++); - } - if (!"0".equals(iec28VO.getW())) { - int zeroOneToZeroTwentyFive = iec28CountLessHundredEighty.getZeroOneToZeroTwentyFive(); - iec28CountLessHundredEighty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++); - } - if (!"0".equals(iec28VO.getE())) { - int zeroTwentyFiveToZeroFive = iec28CountLessHundredEighty.getZeroTwentyFiveToZeroFive(); - iec28CountLessHundredEighty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++); - } - if (!"0".equals(iec28VO.getR())) { - int zeroFiveToOne = iec28CountLessHundredEighty.getZeroFiveToOne(); - iec28CountLessHundredEighty.setZeroFiveToOne(zeroFiveToOne++); - } - if (!"0".equals(iec28VO.getT())) { - int oneToThree = iec28CountLessHundredEighty.getOneToThree(); - iec28CountLessHundredEighty.setOneToThree(oneToThree++); - } - if (!"0".equals(iec28VO.getY())) { - int threeToTwenty = iec28CountLessHundredEighty.getThreeToTwenty(); - iec28CountLessHundredEighty.setThreeToTwenty(threeToTwenty++); - } - if (!"0".equals(iec28VO.getU())) { - int twentyToSixty = iec28CountLessHundredEighty.getTwentyToSixty(); - iec28CountLessHundredEighty.setTwentyToSixty(twentyToSixty++); - } - if (!"0".equals(iec28VO.getI())) { - int sixtyToOneHundredAndEighty = iec28CountLessHundredEighty.getSixtyToOneHundredAndEighty(); - iec28CountLessHundredEighty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++); - } - } - - /** - * =========================第三张表结束=============================== - */ - - - //汇总放入集合 - List iec411Result = new ArrayList<>(); - iec411Result.add(iec411LessOne); - iec411Result.add(iec411LessForty); - iec411Result.add(iec411LessSeventy); - - List disdipResult = new ArrayList<>(); - disdipResult.add(disdipEqualTen); - disdipResult.add(disdipEqualForty); - disdipResult.add(disdipEqualSeventy); - disdipResult.add(disdipEqualEighty); - disdipResult.add(disdipEqualNinety); - - List iec28Result = new ArrayList<>(); - iec28Result.add(iec28CountLessOne); - iec28Result.add(iec28CountLessTen); - iec28Result.add(iec28CountLessTwenty); - iec28Result.add(iec28CountLessThirty); - iec28Result.add(iec28CountLessForty); - iec28Result.add(iec28CountLessFifty); - iec28Result.add(iec28CountLessSixty); - iec28Result.add(iec28CountLessSeventy); - iec28Result.add(iec28CountLessEighty); - iec28Result.add(iec28CountLessNinety); - iec28Result.add(iec28CountLessHundredTwenty); - iec28Result.add(iec28CountLessHundredThirty); - iec28Result.add(iec28CountLessHundredForty); - iec28Result.add(iec28CountLessHundredFifty); - iec28Result.add(iec28CountLessHundredSixty); - iec28Result.add(iec28CountLessHundredSeventy); - iec28Result.add(iec28CountLessHundredEighty); - - - Map resultMap = new HashMap<>(); - - for (int i = 0; i < iec28Result.size(); i++) { - - resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getSixtyToOneHundredAndEighty()); - resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getOneToThree()); - resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getZeroFiveToOne()); - resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getZeroOneToZeroTwentyFive()); - resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getZeroTwentyFiveToZeroFive()); - resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getThreeToTwenty()); - resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getTwentyToSixty()); - resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getZeroZeroTwoToZeroOne()); - } - - //还要对集合中哪个次数最多挑出第一位 - //获取entrySet - Set> entries = resultMap.entrySet(); - - //使用链表来对集合进行排序,使用LinkedList,利于插入元素 - List> result = new LinkedList<>(entries); - //自定义比较器来比较链表中的元素 - Collections.sort(result, new Comparator>() { - //基于entry的值(Entry.getValue()),来排序链表 - @Override - public int compare(Map.Entry o1, Map.Entry o2) { - return o2.getValue().compareTo(o1.getValue()); - } - }); - - //将排好序的存入到LinkedHashMap(可保持顺序)中,需要存储键和值信息对到新的映射中。 - Integer sort = 1; - Map linkMap = new LinkedHashMap<>(); - for (Map.Entry newEntry : result) { - // 取出排名第一的值 - if (sort <= 1) { - linkMap.put(newEntry.getKey(), newEntry.getValue()); - ++sort; - } - } - - - //存放结果的集合 - List resultList = new ArrayList(); - - for (String s : linkMap.keySet()) { - resultList.add(s); - resultList.add(linkMap.get(s).toString()); - } - - //最多暂降事件名称 - for (int i = 0; i < iec28Result.size(); i++) { - if (iec28Result.get(i).getName().equals(resultList.get(0))) { - if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getZeroZeroTwoToZeroOne()))) { - resultList.add("0.02~0.1"); - break; - } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getZeroOneToZeroTwentyFive()))) { - resultList.add("0.1~0.25"); - break; - } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getZeroTwentyFiveToZeroFive()))) { - resultList.add("0.25~0.5"); - break; - } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getZeroFiveToOne()))) { - resultList.add("0.5~1"); - break; - } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getOneToThree()))) { - resultList.add("1~3"); - break; - } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getThreeToTwenty()))) { - resultList.add("3~20"); - break; - } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getTwentyToSixty()))) { - resultList.add("20~60"); - break; - } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getSixtyToOneHundredAndEighty()))) { - resultList.add("60~180"); - break; + //图形 + if (areaReportParam.isEventCountChart()) { + twoCount2++; + createTitle(doc, "4." + oneCount5 + "." + twoCount2 + " " + typeName + "事件图形", "标题 3", 400, 11); + + + //创建部门与监测点次数的map集合 + Map lineCount = new HashMap<>(); + for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) { + lineCount.put(generalDeviceDTO.getName(), generalDeviceDTO.getLineIndexes().size()); + } + + //创建x,y参数 + List xdata = new ArrayList<>(); + List ydata = new ArrayList<>(); + //根据区域名称进行匹配 + for (String name: areaCount.keySet()) { + //将监测点的数量拼接在部门下面 + for (String s : lineCount.keySet()) { + if (s.equals(name)) { + xdata.add(name + "\n" + "(" + lineCount.get(s) + ")"); + } } + + ydata.add(areaCount.get(name)); } - } - System.out.println(resultList); - /** - * =========================续写word文档============================================== - */ - //创建表题计数 - int twoCount = 1; - //同步给暂降密度图 - oneCount4 = oneCount; - - createTitle(doc, "4." + oneCount + " "+typeName+"密度", "标题 2", 200, 11); - - p = doc.createParagraph();// 新建一个段落 - p.setAlignment(ParagraphAlignment.BOTH); - XWPFRun r12 = p.createRun();//创建段落文本 - r12.setText(" "+typeName+"密度统计可以从幅值和持续时间两个维度直接地反映"+typeName+"事件发生情况,主要反应事件的发生次数," + - "中国电网在所选择的分析时间内"+typeName+"事件主要集中在幅值为" + resultList.get(0) + ",持续时间为" + resultList.get(2) + "[根据 IEC 61000-2-8:(公共电网电压"+typeName+"测量统计)算出"+typeName+"事件发生最多的区间],具体见表(图):"); - r12.setFontSize(11);//字体大小 + String qytj = getQYTJ(xdata, ydata); + createPic(doc, qytj, "" + typeName + "事件图形"); - createTitle(doc, "4." + oneCount + "." + twoCount + " DISDIP表格:国际发配电联盟(UNIPEDE)", "标题 3", 400, 11); + //月份统计 + //创建x,y参数 + List xdata1 = new ArrayList<>(); + List ydata1 = new ArrayList<>(); + List ydata2 = new ArrayList<>(); + for (TimeSVO timeSVO : timeSVoList) { + xdata1.add(timeSVO.getFulltime()); + ydata1.add(Integer.parseInt(timeSVO.getTimes())); + ydata2.add(timeSVO.getEventAssIndex()); - //第一张表 - XWPFTable monitorInfo = createTable(doc); - XWPFParagraph monitorInfoExcelParagraph = WordUtils.getCenterParagraph(doc); - - // 表格第一行 - insertRow(doc, monitorInfo, monitorInfoExcelParagraph, true, "剩余电压", "20ms", "100ms", "500ms", "1s", "3s", "20s", "60s", "180s"); + } - //塞入数据 - for (int i = 0; i < disdipResult.size(); i++) { - insertRow(doc, monitorInfo, monitorInfoExcelParagraph, false, disdipResult.get(i).getName(), String.valueOf(disdipResult.get(i).getTwentyMS()), - String.valueOf(disdipResult.get(i).getOneHundredMS()), String.valueOf(disdipResult.get(i).getFiveHundredMS()), String.valueOf(disdipResult.get(i).getOne()), String.valueOf(disdipResult.get(i).getThree()), - String.valueOf(disdipResult.get(i).getTwenty()), String.valueOf(disdipResult.get(i).getSixty()), String.valueOf(disdipResult.get(i).getOneHundredAndEighty())); + String year = areaReportParam.getSearchBeginTime().substring(0, 4); + List tableList = new ArrayList<>(); + tableList.add(table); + + String yftj = getYFTJ1(xdata1, ydata1, ydata2, year, tableList); + createPic(doc, yftj, "" + typeName + "事件图形"); + + + //创建电压uiiiuuuu与监测点次数的map集合 + List areaParamList = voltageParamList; + Map lineCount1 = new HashMap<>(); + for (GeneralDeviceDTO generalDeviceDTO : areaParamList) { + lineCount1.put(generalDeviceDTO.getName(), generalDeviceDTO.getLineIndexes().size()); + } + //创建x,y参数 + List xdata3 = new ArrayList<>(); + List ydata3 = new ArrayList<>(); + //根据电压名称进行匹配 + for (String name: voltageCount.keySet()) { + //将监测点的数量拼接在部门下面 + for (String s : lineCount1.keySet()) { + if (s.equals(name)) { + xdata3.add(name + "\n" + "(" + lineCount1.get(s) + ")"); + } + } + ydata3.add(voltageCount.get(name)); + } + + String dydj = getDYDJ(xdata3, ydata3); + createPic(doc, dydj, "" + typeName + "事件图形"); + + + /** + * =======================================word结束========================================= + */ } - twoCount++; - - createTitle(doc, "4." + oneCount + "." + twoCount + " IEC 61000-4-11:(用电终端的电压"+typeName+"抗度)", "标题 3", 400, 11); - - //第二张表 - XWPFTable monitorInfo1 = createTable(doc); - XWPFParagraph monitorInfoExcelParagraph1 = WordUtils.getCenterParagraph(doc); - - // 表格第一行 - insertRow(doc, monitorInfo1, monitorInfoExcelParagraph1, true, "剩余电压", "10~20ms", "20~100ms", "0.1~0.2s", "0.2~0.5s", "0.5~1s", ">1s"); - - - //塞入数据 - for (int i = 0; i < iec411Result.size(); i++) { - insertRow(doc, monitorInfo1, monitorInfoExcelParagraph1, false, iec411Result.get(i).getName(), String.valueOf(iec411Result.get(i).getTenToTwenty()), String.valueOf(iec411Result.get(i).getTwentyToHundred()), - String.valueOf(iec411Result.get(i).getZeroOneToZeroTwo()), String.valueOf(iec411Result.get(i).getZeroTwoToZeroFive()), String.valueOf(iec411Result.get(i).getZeroFiveToOne()), String.valueOf(iec411Result.get(i).getLessOne())); - } - - twoCount++; - - - createTitle(doc, "4." + oneCount + "." + twoCount + " IEC 61000-2-8:(公共电网电压"+typeName+"测量统计)", "标题 3", 400, 11); - - //第二张表 - XWPFTable monitorInfo2 = createTable(doc); - XWPFParagraph monitorInfoExcelParagraph2 = WordUtils.getCenterParagraph(doc); - - // 表格第一行 - insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, true, "剩余电压", "0.02~0.1s", "0.1~0.25s", "0.25~0.5s", "0.5~1s", "1~3s", "3~20s", "20~60s", "60~180s"); - - - //塞入数据 - for (int i = 0; i < iec28Result.size(); i++) { - insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, false, iec28Result.get(i).getName(), String.valueOf(iec28Result.get(i).getZeroZeroTwoToZeroOne()), String.valueOf(iec28Result.get(i).getZeroOneToZeroTwentyFive()), - String.valueOf(iec28Result.get(i).getZeroTwentyFiveToZeroFive()), String.valueOf(iec28Result.get(i).getZeroFiveToOne()), String.valueOf(iec28Result.get(i).getOneToThree()), String.valueOf(iec28Result.get(i).getThreeToTwenty()), - String.valueOf(iec28Result.get(i).getTwentyToSixty()), String.valueOf(iec28Result.get(i).getSixtyToOneHundredAndEighty())); - } - - //同步给暂降密度表格 - twoCount1 = twoCount; - //序号计数进行++ - oneCount++; - /** - * =======================================word结束========================================= - */ } - if (areaReportParam.isDensityChart()) { + + //3.密度图 + if(areaReportParam.isDensityTable()||areaReportParam.isDensityChart()){ + //暂降密度图形 AreaTableParam areaTableParam = new AreaTableParam(); @@ -5487,7 +3218,8 @@ public class ReportServiceImpl implements ReportService { //创建结果集合 - List info = TableInfo(areaTableParam); +// List info = TableInfo(areaTableParam); + List info = eventDetailList; //将sql结果集放入,共用一个sql,减少查询时间 AreaTableParam areaTableParam1 = new AreaTableParam(); @@ -6777,32 +4509,8 @@ public class ReportServiceImpl implements ReportService { resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getZeroZeroTwoToZeroOne()); } - //还要对集合中哪个次数最多挑出第一位 - //获取entrySet - Set> entries = resultMap.entrySet(); - - //使用链表来对集合进行排序,使用LinkedList,利于插入元素 - List> result = new LinkedList<>(entries); - //自定义比较器来比较链表中的元素 - Collections.sort(result, new Comparator>() { - //基于entry的值(Entry.getValue()),来排序链表 - @Override - public int compare(Map.Entry o1, Map.Entry o2) { - return o2.getValue().compareTo(o1.getValue()); - } - }); - - //将排好序的存入到LinkedHashMap(可保持顺序)中,需要存储键和值信息对到新的映射中。 - Integer sort = 1; - Map linkMap = new LinkedHashMap<>(); - for (Map.Entry newEntry : result) { - // 取出排名第一的值 - if (sort <= 1) { - linkMap.put(newEntry.getKey(), newEntry.getValue()); - ++sort; - } - } - + //todo 还要对集合中哪个次数最多挑出第一位 + Map linkMap = getSort(resultMap); //存放结果的集合 List resultList = new ArrayList(); @@ -6842,49 +4550,129 @@ public class ReportServiceImpl implements ReportService { } } } - System.out.println(resultList); - /** - * =========================续写word文档============================================== - */ + //System.out.println(resultList); - //如果暂降幅值被勾选,就不需要进行写段落 + + //3.1密度密度表格 if (areaReportParam.isDensityTable()) { - twoCount1++; - - //如果幅值图存在与幅值的序号保持同步 - createTitle(doc, "4." + oneCount4 + "." + twoCount1 + " "+typeName+"密度图", "标题 3", 400, 11); - - - //代码 - - } else { + //创建表题计数 int twoCount = 1; - createTitle(doc, "4." + oneCount + " "+typeName+"密度", "标题 2", 200, 11); + + //同步给暂降密度图 + oneCount4 = oneCount; + + createTitle(doc, "4." + oneCount + " " + typeName + "密度", "标题 2", 200, 11); p = doc.createParagraph();// 新建一个段落 p.setAlignment(ParagraphAlignment.BOTH); XWPFRun r12 = p.createRun();//创建段落文本 - r12.setText(" "+typeName+"密度统计可以从幅值和持续时间两个维度直接地反映"+typeName+"事件发生情况,主要反应事件的发生次数," + - "中国电网在所选择的分析时间内"+typeName+"事件主要集中在幅值为" + resultList.get(0) + ",持续时间为" + resultList.get(2) + "[根据 IEC 61000-2-8:(公共电网电压"+typeName+"测量统计)算出"+typeName+"事件发生最多的区间],具体见表(图):"); + r12.setText(" " + typeName + "密度统计可以从幅值和持续时间两个维度直接地反映" + typeName + "事件发生情况,主要反应事件的发生次数," + + "中国电网在所选择的分析时间内" + typeName + "事件主要集中在幅值为" + resultList.get(0) + ",持续时间为" + resultList.get(2) + "[根据 IEC 61000-2-8:(公共电网电压" + typeName + "测量统计)算出" + typeName + "事件发生最多的区间],具体见表(图):"); r12.setFontSize(11);//字体大小 - createTitle(doc, "4." + oneCount + "." + twoCount + " "+typeName+"密度图", "标题 3", 400, 11); + createTitle(doc, "4." + oneCount + "." + twoCount + " DISDIP表格:国际发配电联盟(UNIPEDE)", "标题 3", 400, 11); + + //第一张表 + XWPFTable monitorInfo = createTable(doc); + XWPFParagraph monitorInfoExcelParagraph = WordUtils.getCenterParagraph(doc); + + // 表格第一行 + insertRow(doc, monitorInfo, monitorInfoExcelParagraph, true, "剩余电压", "20ms", "100ms", "500ms", "1s", "3s", "20s", "60s", "180s"); - //代码 + //塞入数据 + for (int i = 0; i < disdipResult.size(); i++) { + insertRow(doc, monitorInfo, monitorInfoExcelParagraph, false, disdipResult.get(i).getName(), String.valueOf(disdipResult.get(i).getTwentyMS()), + String.valueOf(disdipResult.get(i).getOneHundredMS()), String.valueOf(disdipResult.get(i).getFiveHundredMS()), String.valueOf(disdipResult.get(i).getOne()), String.valueOf(disdipResult.get(i).getThree()), + String.valueOf(disdipResult.get(i).getTwenty()), String.valueOf(disdipResult.get(i).getSixty()), String.valueOf(disdipResult.get(i).getOneHundredAndEighty())); + } + + twoCount++; + createTitle(doc, "4." + oneCount + "." + twoCount + " IEC 61000-4-11:(用电终端的电压" + typeName + "抗度)", "标题 3", 400, 11); + + //第二张表 + XWPFTable monitorInfo1 = createTable(doc); + XWPFParagraph monitorInfoExcelParagraph1 = WordUtils.getCenterParagraph(doc); + + // 表格第一行 + insertRow(doc, monitorInfo1, monitorInfoExcelParagraph1, true, "剩余电压", "10~20ms", "20~100ms", "0.1~0.2s", "0.2~0.5s", "0.5~1s", ">1s"); + + + //塞入数据 + for (int i = 0; i < iec411Result.size(); i++) { + insertRow(doc, monitorInfo1, monitorInfoExcelParagraph1, false, iec411Result.get(i).getName(), String.valueOf(iec411Result.get(i).getTenToTwenty()), String.valueOf(iec411Result.get(i).getTwentyToHundred()), + String.valueOf(iec411Result.get(i).getZeroOneToZeroTwo()), String.valueOf(iec411Result.get(i).getZeroTwoToZeroFive()), String.valueOf(iec411Result.get(i).getZeroFiveToOne()), String.valueOf(iec411Result.get(i).getLessOne())); + } + + twoCount++; + + + createTitle(doc, "4." + oneCount + "." + twoCount + " IEC 61000-2-8:(公共电网电压" + typeName + "测量统计)", "标题 3", 400, 11); + + //第二张表 + XWPFTable monitorInfo2 = createTable(doc); + XWPFParagraph monitorInfoExcelParagraph2 = WordUtils.getCenterParagraph(doc); + + // 表格第一行 + insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, true, "剩余电压", "0.02~0.1s", "0.1~0.25s", "0.25~0.5s", "0.5~1s", "1~3s", "3~20s", "20~60s", "60~180s"); + + + //塞入数据 + for (int i = 0; i < iec28Result.size(); i++) { + insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, false, iec28Result.get(i).getName(), String.valueOf(iec28Result.get(i).getZeroZeroTwoToZeroOne()), String.valueOf(iec28Result.get(i).getZeroOneToZeroTwentyFive()), + String.valueOf(iec28Result.get(i).getZeroTwentyFiveToZeroFive()), String.valueOf(iec28Result.get(i).getZeroFiveToOne()), String.valueOf(iec28Result.get(i).getOneToThree()), String.valueOf(iec28Result.get(i).getThreeToTwenty()), + String.valueOf(iec28Result.get(i).getTwentyToSixty()), String.valueOf(iec28Result.get(i).getSixtyToOneHundredAndEighty())); + } + + //同步给暂降密度表格 + twoCount1 = twoCount; //序号计数进行++ oneCount++; } - /** - * =======================================word结束========================================= - */ + + //3.2暂降密度图表 + if (areaReportParam.isDensityChart()) { + + //如果暂降幅值被勾选,就不需要进行写段落 + if (areaReportParam.isDensityTable()) { + twoCount1++; + + //如果幅值图存在与幅值的序号保持同步 + createTitle(doc, "4." + oneCount4 + "." + twoCount1 + " " + typeName + "密度图", "标题 3", 400, 11); + + //代码 + + } else { + int twoCount = 1; + createTitle(doc, "4." + oneCount + " " + typeName + "密度", "标题 2", 200, 11); + + p = doc.createParagraph();// 新建一个段落 + p.setAlignment(ParagraphAlignment.BOTH); + XWPFRun r12 = p.createRun();//创建段落文本 + r12.setText(" " + typeName + "密度统计可以从幅值和持续时间两个维度直接地反映" + typeName + "事件发生情况,主要反应事件的发生次数," + + "中国电网在所选择的分析时间内" + typeName + "事件主要集中在幅值为" + resultList.get(0) + ",持续时间为" + resultList.get(2) + "[根据 IEC 61000-2-8:(公共电网电压" + typeName + "测量统计)算出" + typeName + "事件发生最多的区间],具体见表(图):"); + r12.setFontSize(11);//字体大小 + + + createTitle(doc, "4." + oneCount + "." + twoCount + " " + typeName + "密度图", "标题 3", 400, 11); + + + //代码 + + + //序号计数进行++ + oneCount++; + } + } } + + //4.itic图 if (areaReportParam.isItic()) { //itic图 - + /* AreaTableParam areaTableParam = new AreaTableParam(); //监测点id拼接 @@ -6895,7 +4683,8 @@ public class ReportServiceImpl implements ReportService { //创建结果集合 - List info = TableInfo(areaTableParam); +// List info = TableInfo(areaTableParam); + List info = eventDetailList; //将sql结果集放入,共用一个sql,减少查询时间 AreaTableParam areaTableParam1 = new AreaTableParam(); @@ -6903,9 +4692,10 @@ public class ReportServiceImpl implements ReportService { areaTableParam1.setEndTime(areaReportParam.getSearchEndTime()); areaTableParam1.setStringBuilder(stringBuilder); areaTableParam1.setInfo(info); + */ - - List detailList = getPlotArea(areaTableParam1); +// List detailList = getPlotArea(areaTableParam1); + List detailList = eventDetailList; List obs = new ArrayList<>(); ArrayList> list = new ArrayList<>(); @@ -6929,12 +4719,12 @@ public class ReportServiceImpl implements ReportService { oneCount3 = oneCount; - createTitle(doc, "4." + oneCount3 + " "+typeName+"事件点图", "标题 2", 200, 11); + createTitle(doc, "4." + oneCount3 + " " + typeName + "事件点图", "标题 2", 200, 11); p = doc.createParagraph();// 新建一个段落 p.setAlignment(ParagraphAlignment.BOTH); XWPFRun r12 = p.createRun();//创建段落文本 - r12.setText(" "+typeName+"事件点图统计分成ITIC曲线和F47曲线展示。"); + r12.setText(" " + typeName + "事件点图统计分成ITIC曲线和F47曲线展示。"); r12.setFontSize(11);//字体大小 @@ -6943,7 +4733,7 @@ public class ReportServiceImpl implements ReportService { p = doc.createParagraph();// 新建一个段落 p.setAlignment(ParagraphAlignment.BOTH); XWPFRun r13 = p.createRun();//创建段落文本 - r13.setText(" ITIC曲线中可容忍"+typeName+"记录为:" + result.get(0) + "条;不可容忍"+typeName+"记录为:" + result.get(1) + "条,具体见下表(图):"); + r13.setText(" ITIC曲线中可容忍" + typeName + "记录为:" + result.get(0) + "条;不可容忍" + typeName + "记录为:" + result.get(1) + "条,具体见下表(图):"); r13.setFontSize(11);//字体大小 @@ -6961,9 +4751,11 @@ public class ReportServiceImpl implements ReportService { } + + //5.f47图 if (areaReportParam.isF47()) { //f47图 - + /* AreaTableParam areaTableParam = new AreaTableParam(); //监测点id拼接 @@ -6974,7 +4766,8 @@ public class ReportServiceImpl implements ReportService { //创建结果集合 - List info = TableInfo(areaTableParam); +// List info = TableInfo(areaTableParam); + List info = eventDetailList; //将sql结果集放入,共用一个sql,减少查询时间 AreaTableParam areaTableParam1 = new AreaTableParam(); @@ -6985,6 +4778,8 @@ public class ReportServiceImpl implements ReportService { List detailList = getPlotArea(areaTableParam1); + */ + List detailList = eventDetailList; List obs = new ArrayList<>(); @@ -7013,7 +4808,7 @@ public class ReportServiceImpl implements ReportService { p = doc.createParagraph();// 新建一个段落 p.setAlignment(ParagraphAlignment.BOTH); XWPFRun r13 = p.createRun();//创建段落文本 - r13.setText(" F47曲线中可容忍"+typeName+"记录为:" + result.get(0) + "条;不可容忍"+typeName+"记录为:" + result.get(1) + "条,具体见下表(图):"); + r13.setText(" F47曲线中可容忍" + typeName + "记录为:" + result.get(0) + "条;不可容忍" + typeName + "记录为:" + result.get(1) + "条,具体见下表(图):"); r13.setFontSize(11);//字体大小 @@ -7029,12 +4824,12 @@ public class ReportServiceImpl implements ReportService { oneCount3 = oneCount; - createTitle(doc, "4." + oneCount + " "+typeName+"事件点图", "标题 2", 200, 11); + createTitle(doc, "4." + oneCount + " " + typeName + "事件点图", "标题 2", 200, 11); p = doc.createParagraph();// 新建一个段落 p.setAlignment(ParagraphAlignment.BOTH); XWPFRun r12 = p.createRun();//创建段落文本 - r12.setText(" "+typeName+"事件点图统计分成ITIC曲线和F47曲线展示。"); + r12.setText(" " + typeName + "事件点图统计分成ITIC曲线和F47曲线展示。"); r12.setFontSize(11);//字体大小 @@ -7043,7 +4838,7 @@ public class ReportServiceImpl implements ReportService { p = doc.createParagraph();// 新建一个段落 p.setAlignment(ParagraphAlignment.BOTH); XWPFRun r13 = p.createRun();//创建段落文本 - r13.setText(" F47曲线中可容忍"+typeName+"降记录为:" + result.get(0) + "条;不可容忍"+typeName+"记录为:" + result.get(1) + "条,具体见下表(图):"); + r13.setText(" F47曲线中可容忍" + typeName + "降记录为:" + result.get(0) + "条;不可容忍" + typeName + "记录为:" + result.get(1) + "条,具体见下表(图):"); r13.setFontSize(11);//字体大小 @@ -7061,8 +4856,11 @@ public class ReportServiceImpl implements ReportService { } + + //6.暂降增幅 if (areaReportParam.isSagAmplitude()) { //暂降分布幅值 + /* AreaTableParam areaTableParam = new AreaTableParam(); //监测点id拼接 @@ -7071,15 +4869,16 @@ public class ReportServiceImpl implements ReportService { areaTableParam.setEndTime(areaReportParam.getSearchEndTime()); areaTableParam.setStringBuilder(stringBuilder); - + */ //创建结果集合 - List info = TableInfo(areaTableParam); +// List info = TableInfo(areaTableParam); + List info = eventDetailList; //将sql结果集放入,共用一个sql,减少查询时间 AreaTableParam areaTableParam1 = new AreaTableParam(); areaTableParam1.setStartTime(areaReportParam.getSearchBeginTime()); areaTableParam1.setEndTime(areaReportParam.getSearchEndTime()); - areaTableParam1.setStringBuilder(stringBuilder); +// areaTableParam1.setStringBuilder(stringBuilder); areaTableParam1.setInfo(info); ProbabilityVO probabilityDistributionArea = getProbabilityDistributionArea(areaTableParam1); @@ -7165,23 +4964,23 @@ public class ReportServiceImpl implements ReportService { oneCount2 = oneCount; - createTitle(doc, "4." + oneCount2 + " "+typeName+"幅值概率分布图", "标题 2", 200, 11); + createTitle(doc, "4." + oneCount2 + " " + typeName + "幅值概率分布图", "标题 2", 200, 11); p = doc.createParagraph();// 新建一个段落 p.setAlignment(ParagraphAlignment.BOTH); XWPFRun r12 = p.createRun();//创建段落文本 - r12.setText(" "+typeName+"概率分布图分成"+typeName+"幅值概率分布和持续时间概率分布图,中国电网在所选择的分析时间内"+typeName+"事件从幅值概率分布统计主要集中在幅值为" + amplitudeResult.get(0) + "~" + amplitudeResult.get(1) + "之间," + - "从持续时间统计主要集中在持续时间为" + amplitudeResult1.get(0) + "~" + amplitudeResult1.get(1) + "[持续时间排序,选择"+typeName+"记录发生最多的区域],如下表(图):"); + r12.setText(" " + typeName + "概率分布图分成" + typeName + "幅值概率分布和持续时间概率分布图,中国电网在所选择的分析时间内" + typeName + "事件从幅值概率分布统计主要集中在幅值为" + amplitudeResult.get(0) + "~" + amplitudeResult.get(1) + "之间," + + "从持续时间统计主要集中在持续时间为" + amplitudeResult1.get(0) + "~" + amplitudeResult1.get(1) + "[持续时间排序,选择" + typeName + "记录发生最多的区域],如下表(图):"); r12.setFontSize(11);//字体大小 - createTitle(doc, "4." + oneCount + "." + twoCount + " "+typeName+"幅值的概率分布函数", "标题 3", 400, 11); + createTitle(doc, "4." + oneCount + "." + twoCount + " " + typeName + "幅值的概率分布函数", "标题 3", 400, 11); List ybardata = probabilityDistributionArea.getPereventvalue(); List ylinedata = probabilityDistributionArea.getEventvalue(); String fz = getFZ(ylinedata, ybardata); - createPic(doc, fz, ""+typeName+"幅值的概率分布函数"); + createPic(doc, fz, "" + typeName + "幅值的概率分布函数"); //序号计数进行++ @@ -7192,6 +4991,8 @@ public class ReportServiceImpl implements ReportService { */ } + + //7.暂降持续时间 if (areaReportParam.isDuration()) { //持续时间概率分布 @@ -7206,7 +5007,8 @@ public class ReportServiceImpl implements ReportService { //创建结果集合 - List info = TableInfo(areaTableParam); +// List info = TableInfo(areaTableParam); + List info = eventDetailList; //将sql结果集放入,共用一个sql,减少查询时间 AreaTableParam areaTableParam1 = new AreaTableParam(); @@ -7216,7 +5018,7 @@ public class ReportServiceImpl implements ReportService { areaTableParam1.setInfo(info); ProbabilityVO probabilityDistributionArea = getProbabilityDistributionArea(areaTableParam1); - System.out.println(probabilityDistributionArea); +// System.out.println(probabilityDistributionArea); List eventvalue = probabilityDistributionArea.getEventvalue(); @@ -7311,13 +5113,13 @@ public class ReportServiceImpl implements ReportService { } else { - createTitle(doc, "4." + oneCount2 + " "+typeName+"幅值概率分布图", "标题 2", 200, 11); + createTitle(doc, "4." + oneCount2 + " " + typeName + "幅值概率分布图", "标题 2", 200, 11); p = doc.createParagraph();// 新建一个段落 p.setAlignment(ParagraphAlignment.BOTH); XWPFRun r12 = p.createRun();//创建段落文本 - r12.setText(" "+typeName+"概率分布图分成"+typeName+"幅值概率分布和持续时间概率分布图,中国电网在所选择的分析时间内"+typeName+"事件从幅值概率分布统计主要集中在幅值为" + amplitudeResult.get(0) + "~" + amplitudeResult.get(1) + "之间," + - "从持续时间统计主要集中在持续时间为" + amplitudeResult1.get(0) + "~" + amplitudeResult1.get(1) + "[持续时间排序,选择"+typeName+"记录发生最多的区域],如下表(图):"); + r12.setText(" " + typeName + "概率分布图分成" + typeName + "幅值概率分布和持续时间概率分布图,中国电网在所选择的分析时间内" + typeName + "事件从幅值概率分布统计主要集中在幅值为" + amplitudeResult.get(0) + "~" + amplitudeResult.get(1) + "之间," + + "从持续时间统计主要集中在持续时间为" + amplitudeResult1.get(0) + "~" + amplitudeResult1.get(1) + "[持续时间排序,选择" + typeName + "记录发生最多的区域],如下表(图):"); r12.setFontSize(11);//字体大小 @@ -7334,18 +5136,20 @@ public class ReportServiceImpl implements ReportService { * =======================================word结束========================================= */ } + + //8.事件关联统计表格 if (areaReportParam.isEventRelevanceCountTable()) { //事件关联统计表格 //创建存储总次数的集合 - Map resultCount = new HashMap<>(); + Map resultCount = new HashMap<>(); //创建存储time的集合 Map timeCount = new HashMap<>(); - + /* //提前创建line_id拼接工具,如:where id = '1' or id = '2' - StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds); + StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParamAndName(lineIds); StringBuilder stringResult = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE). append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(areaReportParam.getSearchBeginTime()))).append("' and ").append("time <= '") @@ -7359,17 +5163,14 @@ public class ReportServiceImpl implements ReportService { .append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(areaReportParam.getSearchEndTime()))).append("' and "); stringTotal.append(stringBuilder).append(" and ").append("(wave_type = 0 or wave_type = 1 or wave_type = 2 or wave_type = 3 or wave_type = 4)").append(" and ").append("eventass_index != '' ").append(" tz('Asia/Shanghai')"); - //总条数 QueryResult resultTotal = influxDbUtils.query(stringTotal.toString()); //结果集 QueryResult result = influxDbUtils.query(stringResult.toString()); - //结果集映射到对象中 eventDetailList = influxDBResultMapper.toPOJO(result, EventDetailNew.class); - //如果返回的结果不为null,将count重新赋值 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(); @@ -7380,19 +5181,51 @@ public class ReportServiceImpl implements ReportService { //count有默认值为0,不用进行非空判断,将结果集装入准备好的集合中 resultCount.put("count", count); } + */ + int resultCount1 = 0; + List resultList = new ArrayList<>(); - //将时间数存入集合Map集合 - for (EventDetailNew detail : eventDetailList) { - timeCount.put(detail.getEventassIndex(), detail.getTimeId()); - } + List eventList = eventDetailList.stream().filter(e -> e.getEventassIndex() != "").collect(Collectors.toList()); + if(CollectionUtil.isNotEmpty(eventList)){ + //记录条数 + resultCount.put("count", eventList.size()); - int resultCount1 = 0; - List resultList = new ArrayList<>(); + //将时间数存入集合Map集合(主数据) + for (EventDetailNew detail : eventList) { + timeCount.put(detail.getEventassIndex(), detail.getTimeId()); + } + + //时间拼接 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 eventassList = influxDBResultMapper.toPOJO(result1, Eventass.class); + + for (Eventass eventass : eventassList) { + EventassCountParam eventassCountParam = new EventassCountParam(); + eventassCountParam.setAssTime(eventass.getTimeId().toString()); + //获取时间 + String eventTime = timeCount.get(eventass.getEventTime()); + eventassCountParam.setEventTime(eventTime); + eventassCountParam.setDescribe(eventass.getDescribe()); + resultList.add(eventassCountParam); + } + }else{ + resultCount.put("count", 0); + } + + + /* for (String s : timeCount.keySet()) { StringBuilder stringResult1 = new StringBuilder(Param.SELECT).append("pqs_eventass").append(Param.WHERE). - append("event_time = '").append(s).append("' "); + append("event_time = '").append(stringBuilder).append("' "); //结果集 QueryResult result1 = influxDbUtils.query(stringResult1.toString()); @@ -7424,7 +5257,7 @@ public class ReportServiceImpl implements ReportService { p.setAlignment(ParagraphAlignment.BOTH); XWPFRun r12 = p.createRun();//创建段落文本 //归一化需要高级算法,先字符串代替 - r12.setText(" 中国电网在所选择的分析时间段内累计监测"+typeName+"记录" + resultCount.get("count") + "条,归一化统计后共" + resultCount1 + "[此为归一化后的暂态事件结果]条,,具体如下图所示:"); + r12.setText(" "+deptName+"电网在所选择的分析时间段内累计监测" + typeName + "记录" + resultCount.get("count") + "条,归一化统计后共" + resultCount1 + "[此为归一化后的暂态事件结果]条,,具体如下图所示:"); r12.setFontSize(11);//字体大小 @@ -7448,686 +5281,290 @@ public class ReportServiceImpl implements ReportService { */ } - if (areaReportParam.isEventReasonTable()) { + + //9.暂降原因表和暂降原因图形生成 + if(areaReportParam.isEventReasonTable()||areaReportParam.isEventReasonChart()){ + //查询字典表 + List reasonList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()).getData(); + + //新建map集合装入参数 + Map reasonMap = reasonList.stream().collect(Collectors.toMap(DictData::getId, DictData::getName)); + + //获得所有值 + Set typeSet = reasonMap.keySet(); + List listReason = new ArrayList<>(typeSet); + + //创建Map结果集合 + Map resultMap = new HashMap<>(); + + //优化数据(根据暂降原因,进行分组统计有多少条数据,key:暂降原因id,value:次数) + Map reasonMapCount = eventDetailList.stream().collect(Collectors.groupingBy(EventDetailNew::getEventReason, Collectors.counting())); + //将数据重新整合为(key:暂降原因的名称,value:暂降原因测次数) + reasonMap.forEach((key,value)->{ + if(reasonMapCount.containsKey(key)){ + resultMap.put(value, Math.toIntExact(reasonMapCount.get(key))); + }else{ + resultMap.put(value, 0); + } + }); + + //todo 还要对集合中哪个次数最多挑出第一位 + //获取entrySet + Map linkMap = getSort(resultMap); + //最多暂降事件名称 + Set topSet = linkMap.keySet(); + List topList = new ArrayList<>(topSet); + //暂降原因表格 - - //查询字典表 - List reasonList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()).getData(); - - - //提前创建line_id拼接工具,如:where id = '1' or id = '2' - StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds); - - - //新建map集合装入参数 - Map reasonMap = new HashMap<>(); - - for (DictData dictData : reasonList) { - reasonMap.put(dictData.getId(), dictData.getName()); - } - - - //获得所有值 - Set typeSet = reasonMap.keySet(); - List listReason = new ArrayList<>(typeSet); - - - //创建装次数结果的Map集合 - Map reasonCount = new HashMap<>(); - - - //创建Map结果集合 - Map resultMap = new HashMap<>(); - - - //进行fori遍历所有key - for (int i = 0; i < listReason.size(); i++) { - - - //拼接sql查询满足条件数据的次数 - StringBuilder stringResult = new StringBuilder("SELECT ").append("count(event_reason)").append(" FROM pqs_eventdetail ").append(Param.WHERE). - append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(areaReportParam.getSearchBeginTime()))).append("' and ").append("time <= '") - .append(DateUtil.endOfDay(DateUtil.parse(areaReportParam.getSearchEndTime()))) - .append("' and ").append(stringBuilder).append(" and ").append("(wave_type = 0 or wave_type = 1 or wave_type = 2 or wave_type = 3 or wave_type = 4)").append(" and ").append("event_reason = '").append(listReason.get(i)).append("' tz('Asia/Shanghai')"); - - - //结果集 - QueryResult result = influxDbUtils.query(stringResult.toString()); - - //如果返回的结果不为null,将count重新赋值 - if (Objects.nonNull(result.getResults().get(0).getSeries())) { - long count = new BigDecimal(result.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).longValue(); - //count有默认值为0,不用进行非空判断,将结果集装入准备好的集合中 - reasonCount.put(listReason.get(i), count); - } else { - long count = 0; - //count有默认值为0,不用进行非空判断,将结果集装入准备好的集合中 - reasonCount.put(listReason.get(i), count); - } - - - } - - //遍历 - for (String keyCount : reasonCount.keySet()) { - - for (String keyType : reasonMap.keySet()) { - if (keyCount.equals(keyType)) { - resultMap.put(reasonMap.get(keyType), reasonCount.get(keyCount)); - - } - } - } - - //Map结果 - System.out.println(resultMap); - - //还要对集合中哪个次数最多挑出第一位 - //获取entrySet - Set> entries = resultMap.entrySet(); - - //使用链表来对集合进行排序,使用LinkedList,利于插入元素 - List> result = new LinkedList<>(entries); - //自定义比较器来比较链表中的元素 - Collections.sort(result, new Comparator>() { - //基于entry的值(Entry.getValue()),来排序链表 - @Override - public int compare(Map.Entry o1, Map.Entry o2) { - return o2.getValue().compareTo(o1.getValue()); - } - }); - - //将排好序的存入到LinkedHashMap(可保持顺序)中,需要存储键和值信息对到新的映射中。 - Integer sort = 1; - Map linkMap = new LinkedHashMap<>(); - for (Map.Entry newEntry : result) { - // 取出排名前2的值 - if (sort <= 1) { - linkMap.put(newEntry.getKey(), newEntry.getValue()); - ++sort; - } - } - //最多暂降事件名称 - Set topSet = linkMap.keySet(); - List topList = new ArrayList<>(topSet); - //转为List对象集合 - List resultList = new ArrayList<>(); - for (String s : resultMap.keySet()) { - ReportCountParam reportCountParam = new ReportCountParam(); - reportCountParam.setName(s); - reportCountParam.setCount(resultMap.get(s).toString()); - resultList.add(reportCountParam); - } - -/** - * =========================续写word文档============================================== - */ - //创建表题计数 - int twoCount = 1; - - oneCount7 = oneCount; - createTitle(doc, "4." + oneCount + " 原因统计", "标题 2", 200, 11); - - p = doc.createParagraph();// 新建一个段落 - p.setAlignment(ParagraphAlignment.BOTH); - XWPFRun r12 = p.createRun();//创建段落文本 - r12.setText(" 中国电网在所选择的分析时间内暂态事件主要的暂态原因为" + topList.get(0) + "[根据表格中的次数来进行分析],见下表(图):"); - r12.setFontSize(11);//字体大小 - - - createTitle(doc, "4." + oneCount + "." + twoCount + " 原因统计表格", "标题 3", 400, 11); - - //第一张表 - XWPFTable monitorInfo = createTable(doc); - XWPFParagraph monitorInfoExcelParagraph = WordUtils.getCenterParagraph(doc); - - // 表格第一行 - insertRow(doc, monitorInfo, monitorInfoExcelParagraph, true, "暂态类型", "电压"+typeName+"次数"); - - - //塞入数据 - for (int i = 0; i < resultList.size(); i++) { - insertRow(doc, monitorInfo, monitorInfoExcelParagraph, false, resultList.get(i).getName(), resultList.get(i).getCount().toString()); - } - - twoCount4 = twoCount; - //序号计数进行++ - oneCount++; - - /** - * =======================================word结束========================================= - */ - } - if (areaReportParam.isEventReasonChart()) { - //暂降原因图形 - - //查询字典表 - List reasonList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()).getData(); - - - //提前创建line_id拼接工具,如:where id = '1' or id = '2' - StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds); - - - //新建map集合装入参数 - Map reasonMap = new HashMap<>(); - - for (DictData dictData : reasonList) { - reasonMap.put(dictData.getId(), dictData.getName()); - } - - - //获得所有值 - Set typeSet = reasonMap.keySet(); - List listReason = new ArrayList<>(typeSet); - - - //创建装次数结果的Map集合 - Map reasonCount = new HashMap<>(); - - - //创建Map结果集合 - Map resultMap = new HashMap<>(); - - - //进行fori遍历所有key - for (int i = 0; i < listReason.size(); i++) { - - - //拼接sql查询满足条件数据的次数 - StringBuilder stringResult = new StringBuilder("SELECT ").append("count(event_reason)").append(" FROM pqs_eventdetail ").append(Param.WHERE). - append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(areaReportParam.getSearchBeginTime()))).append("' and ").append("time <= '") - .append(DateUtil.endOfDay(DateUtil.parse(areaReportParam.getSearchEndTime()))) - .append("' and ").append(stringBuilder).append(" and ").append("(wave_type = 0 or wave_type = 1 or wave_type = 2 or wave_type = 3 or wave_type = 4)").append(" and ").append("event_reason = '").append(listReason.get(i)).append("' tz('Asia/Shanghai')"); - - - //结果集 - QueryResult result = influxDbUtils.query(stringResult.toString()); - - //如果返回的结果不为null,将count重新赋值 - if (Objects.nonNull(result.getResults().get(0).getSeries())) { - long count = new BigDecimal(result.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).longValue(); - //count有默认值为0,不用进行非空判断,将结果集装入准备好的集合中 - reasonCount.put(listReason.get(i), count); - } else { - long count = 0; - //count有默认值为0,不用进行非空判断,将结果集装入准备好的集合中 - reasonCount.put(listReason.get(i), count); - } - - - } - - //遍历 - for (String keyCount : reasonCount.keySet()) { - - for (String keyType : reasonMap.keySet()) { - if (keyCount.equals(keyType)) { - resultMap.put(reasonMap.get(keyType), reasonCount.get(keyCount)); - - } - } - } - - //Map结果 - System.out.println(resultMap); - - //还要对集合中哪个次数最多挑出第一位 - //获取entrySet - Set> entries = resultMap.entrySet(); - - //使用链表来对集合进行排序,使用LinkedList,利于插入元素 - List> result = new LinkedList<>(entries); - //自定义比较器来比较链表中的元素 - Collections.sort(result, new Comparator>() { - //基于entry的值(Entry.getValue()),来排序链表 - @Override - public int compare(Map.Entry o1, Map.Entry o2) { - return o2.getValue().compareTo(o1.getValue()); - } - }); - - //将排好序的存入到LinkedHashMap(可保持顺序)中,需要存储键和值信息对到新的映射中。 - Integer sort = 1; - Map linkMap = new LinkedHashMap<>(); - for (Map.Entry newEntry : result) { - // 取出排名前2的值 - if (sort <= 1) { - linkMap.put(newEntry.getKey(), newEntry.getValue()); - ++sort; - } - } - //最多暂降事件名称 - Set topSet = linkMap.keySet(); - List topList = new ArrayList<>(topSet); - //转为List对象集合 - List resultList = new ArrayList<>(); - for (String s : resultMap.keySet()) { - ReportCountParam reportCountParam = new ReportCountParam(); - reportCountParam.setName(s); - reportCountParam.setCount(resultMap.get(s).toString()); - resultList.add(reportCountParam); - } - -/** - * =========================续写word文档============================================== - */ - if (areaReportParam.isEventReasonTable()) { - - createTitle(doc, "4." + oneCount7 + "." + twoCount4 + " 原因统计图", "标题 3", 400, 11); - - //创建x,y参数 - List xdata = new ArrayList<>(); - List ydata = new ArrayList<>(); - - List reason = new ArrayList<>(); - for (ReportCountParam reportCountParam : resultList) { - xdata.add(reportCountParam.getName()); - ydata.add(Integer.parseInt(reportCountParam.getCount())); - - ReasonsVO reasonsVO = new ReasonsVO(); - reasonsVO.setReason(reportCountParam.getName()); - reasonsVO.setTimes(Integer.parseInt(reportCountParam.getCount())); - reason.add(reasonsVO); - - } - - - String tr = getR(xdata, reason, "bar9.ftl"); - createPic(doc, tr, ""+typeName+"原因图"); - - - } else { + //暂降原因表格 //创建表题计数 int twoCount = 1; - + oneCount7 = oneCount; createTitle(doc, "4." + oneCount + " 原因统计", "标题 2", 200, 11); p = doc.createParagraph();// 新建一个段落 p.setAlignment(ParagraphAlignment.BOTH); XWPFRun r12 = p.createRun();//创建段落文本 - r12.setText(" 中国电网在所选择的分析时间内暂态事件主要的暂态原因为" + topList.get(0) + "[根据表格中的次数来进行分析],见下表(图):"); + r12.setText(" "+deptName+"电网在所选择的分析时间内暂态事件主要的暂态原因为" + topList.get(0) + "[根据表格中的次数来进行分析],见下表(图):"); r12.setFontSize(11);//字体大小 - createTitle(doc, "4." + oneCount + "." + twoCount + " 原因统计图", "标题 3", 400, 11); + createTitle(doc, "4." + oneCount + "." + twoCount + " 原因统计表格", "标题 3", 400, 11); - //创建x,y参数 - List xdata = new ArrayList<>(); - List ydata = new ArrayList<>(); + //第一张表 + XWPFTable monitorInfo = createTable(doc); + XWPFParagraph monitorInfoExcelParagraph = WordUtils.getCenterParagraph(doc); + // 表格第一行 + insertRow(doc, monitorInfo, monitorInfoExcelParagraph, true, "暂态类型", "电压" + typeName + "次数"); - List reason = new ArrayList<>(); - - for (ReportCountParam reportCountParam : resultList) { - xdata.add(reportCountParam.getName()); - ydata.add(Integer.parseInt(reportCountParam.getCount())); - - ReasonsVO reasonsVO = new ReasonsVO(); - reasonsVO.setReason(reportCountParam.getName()); - reasonsVO.setTimes(Integer.parseInt(reportCountParam.getCount())); - reason.add(reasonsVO); + //塞入数据 + for (String name : resultMap.keySet()) { + insertRow(doc, monitorInfo, monitorInfoExcelParagraph, false, name, resultMap.get(name).toString()); } - - String tr = getR(xdata, reason, "bar9.ftl"); - createPic(doc, tr, ""+typeName+"原因图"); - + twoCount4 = twoCount; //序号计数进行++ oneCount++; + + } + + //暂降原因图表 + if (areaReportParam.isEventReasonChart()) { + if (areaReportParam.isEventReasonTable()) { + + createTitle(doc, "4." + oneCount7 + "." + twoCount4 + " 原因统计图", "标题 3", 400, 11); + + //创建x,y参数 + List xdata = new ArrayList<>(); + List ydata = new ArrayList<>(); + + List reason = new ArrayList<>(); + for (String name : resultMap.keySet()) { + xdata.add(name); + ydata.add(resultMap.get(name)); + + ReasonsVO reasonsVO = new ReasonsVO(); + reasonsVO.setReason(name); + reasonsVO.setTimes(resultMap.get(name)); + reason.add(reasonsVO); + } + + String tr = getR(xdata, reason, "bar9.ftl"); + createPic(doc, tr, "" + typeName + "原因图"); + } else { + //创建表题计数 + int twoCount = 1; + + createTitle(doc, "4." + oneCount + " 原因统计", "标题 2", 200, 11); + + p = doc.createParagraph();// 新建一个段落 + p.setAlignment(ParagraphAlignment.BOTH); + XWPFRun r12 = p.createRun();//创建段落文本 + r12.setText(" "+deptName+"电网在所选择的分析时间内暂态事件主要的暂态原因为" + topList.get(0) + "[根据表格中的次数来进行分析],见下表(图):"); + r12.setFontSize(11);//字体大小 + + + createTitle(doc, "4." + oneCount + "." + twoCount + " 原因统计图", "标题 3", 400, 11); + + //创建x,y参数 + List xdata = new ArrayList<>(); + List ydata = new ArrayList<>(); + + List reason = new ArrayList<>(); + + for (String name : resultMap.keySet()) { + xdata.add(name); + ydata.add(resultMap.get(name)); + + ReasonsVO reasonsVO = new ReasonsVO(); + reasonsVO.setReason(name); + reasonsVO.setTimes(resultMap.get(name)); + reason.add(reasonsVO); + } + + String tr = getR(xdata, reason, "bar9.ftl"); + createPic(doc, tr, "" + typeName + "原因图"); + + //序号计数进行++ + oneCount++; + } } - /** - * =======================================word结束========================================= - */ } - if (areaReportParam.isEventTypeTable()) { + + //10.暂降类型表格 和 暂降类型图表 + if(areaReportParam.isEventTypeTable()||areaReportParam.isEventTypeChart()){ + + //查询字典表(暂降类型) + List typeList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()).getData(); + //新建map集合装入参数 + Map typeMap = typeList.stream().collect(Collectors.toMap(DictData::getId, DictData::getName)); + + //获得所有值 + Set typeSet = typeMap.keySet(); + List listReason = new ArrayList<>(typeSet); + + //创建Map结果集合 + Map resultMap = new HashMap<>(); + + //优化数据(根据暂降类型,进行分组统计有多少条数据,key:暂降类型id,value:次数) + Map typeMapCount = eventDetailList.stream().collect(Collectors.groupingBy(EventDetailNew::getEventType, Collectors.counting())); + //将数据重新整合为(key:暂降类型的名称,value:暂降类型次数) + typeMap.forEach((key,value)->{ + if(typeMapCount.containsKey(key)){ + resultMap.put(value, Math.toIntExact(typeMapCount.get(key))); + }else{ + resultMap.put(value, 0); + } + }); + + //todo 还要对集合中哪个次数最多挑出第一位 + //获取entrySet + Map linkMap = getSort(resultMap); + //最多暂降事件名称 + Set topSet = linkMap.keySet(); + List topList = new ArrayList<>(topSet); + + //暂降类型表格 - - //查询字典表 - List typeList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()).getData(); - - - //提前创建line_id拼接工具,如:where id = '1' or id = '2' - StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds); - - - //新建map集合装入参数 - Map typeMap = new HashMap<>(); - - for (DictData dictData : typeList) { - typeMap.put(dictData.getId(), dictData.getName()); - } - - - //获得所有值 - Set typeSet = typeMap.keySet(); - List listType = new ArrayList<>(typeSet); - - - //创建装次数结果的Map集合 - Map typeCount = new HashMap<>(); - - - //创建Map结果集合 - Map resultMap = new HashMap<>(); - - - //进行fori遍历所有key - for (int i = 0; i < listType.size(); i++) { - - - //拼接sql查询满足条件数据的次数,成功!!明早测试下表中存在的暂态事件类型,把sql语局固定死,进行测试看返回值 - StringBuilder stringResult = new StringBuilder("SELECT ").append("count(event_type)").append(" FROM pqs_eventdetail ").append(Param.WHERE). - append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(areaReportParam.getSearchBeginTime()))).append("' and ").append("time <= '") - .append(DateUtil.endOfDay(DateUtil.parse(areaReportParam.getSearchEndTime()))) - .append("' and ").append(stringBuilder).append(" and ").append("(wave_type = 0 or wave_type = 1 or wave_type = 2 or wave_type = 3 or wave_type = 4)").append(" and ").append("event_type = '").append(listType.get(i)).append("' tz('Asia/Shanghai')"); - - //TODO - // 结果集 - QueryResult result = influxDbUtils.query(stringResult.toString()); - - //如果返回的结果不为null,将count重新赋值 - if (Objects.nonNull(result.getResults().get(0).getSeries())) { - long count = new BigDecimal(result.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).longValue(); - //count有默认值为0,不用进行非空判断,将结果集装入准备好的集合中 - typeCount.put(listType.get(i), count); - } else { - long count = 0; - //count有默认值为0,不用进行非空判断,将结果集装入准备好的集合中 - typeCount.put(listType.get(i), count); - } - - - } - - //遍历 - for (String keyCount : typeCount.keySet()) { - - for (String keyType : typeMap.keySet()) { - if (keyCount.equals(keyType)) { - resultMap.put(typeMap.get(keyType), typeCount.get(keyCount)); - - } - } - } - - //Map结果 - System.out.println(resultMap); - //还要对集合中哪个次数最多挑出第一位 - //获取entrySet - Set> entries = resultMap.entrySet(); - - //使用链表来对集合进行排序,使用LinkedList,利于插入元素 - List> result = new LinkedList<>(entries); - //自定义比较器来比较链表中的元素 - Collections.sort(result, new Comparator>() { - //基于entry的值(Entry.getValue()),来排序链表 - @Override - public int compare(Map.Entry o1, Map.Entry o2) { - return o2.getValue().compareTo(o1.getValue()); - } - }); - - //将排好序的存入到LinkedHashMap(可保持顺序)中,需要存储键和值信息对到新的映射中。 - Integer sort = 1; - Map linkMap = new LinkedHashMap<>(); - for (Map.Entry newEntry : result) { - // 取出排名前2的值 - if (sort <= 1) { - linkMap.put(newEntry.getKey(), newEntry.getValue()); - ++sort; - } - } - //最多暂降事件名称 - Set topSet = linkMap.keySet(); - List topList = new ArrayList<>(topSet); - //转为List对象集合 - List resultList = new ArrayList<>(); - for (String s : resultMap.keySet()) { - ReportCountParam reportCountParam = new ReportCountParam(); - reportCountParam.setName(s); - reportCountParam.setCount(resultMap.get(s).toString()); - resultList.add(reportCountParam); - } -/** - * =========================续写word文档============================================== - */ - //创建表题计数 - int twoCount = 1; - oneCount6 = oneCount; - - createTitle(doc, "4." + oneCount + " 类型统计", "标题 2", 200, 11); - - p = doc.createParagraph();// 新建一个段落 - p.setAlignment(ParagraphAlignment.BOTH); - XWPFRun r12 = p.createRun();//创建段落文本 - r12.setText(" 中国电网在所选择的分析时间内暂态事件主要的暂态类型为" + topList.get(0) + "[根据表格中的次数来进行分析],见下表(图):"); - r12.setFontSize(11);//字体大小 - - - createTitle(doc, "4." + oneCount + "." + twoCount + " 类型统计表格", "标题 3", 400, 11); - - //第一张表 - XWPFTable monitorInfo = createTable(doc); - XWPFParagraph monitorInfoExcelParagraph = WordUtils.getCenterParagraph(doc); - - // 表格第一行 - insertRow(doc, monitorInfo, monitorInfoExcelParagraph, true, "暂态类型", "电压"+typeName+"次数"); - - - //塞入数据 - for (int i = 0; i < resultList.size(); i++) { - insertRow(doc, monitorInfo, monitorInfoExcelParagraph, false, resultList.get(i).getName(), resultList.get(i).getCount().toString()); - } - - twoCount3 = twoCount; - //序号计数进行++ - oneCount++; - - /** - * =======================================word结束========================================= - */ - - } - if (areaReportParam.isEventTypeChart()) { - //暂降类型图形 - - //查询字典表 - List typeList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()).getData(); - - - //提前创建line_id拼接工具,如:where id = '1' or id = '2' - StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds); - - - //新建map集合装入参数 - Map typeMap = new HashMap<>(); - - for (DictData dictData : typeList) { - typeMap.put(dictData.getId(), dictData.getName()); - } - - - //获得所有值 - Set typeSet = typeMap.keySet(); - List listType = new ArrayList<>(typeSet); - - - //创建装次数结果的Map集合 - Map typeCount = new HashMap<>(); - - - //创建Map结果集合 - Map resultMap = new HashMap<>(); - - - //进行fori遍历所有key - for (int i = 0; i < listType.size(); i++) { - - - //拼接sql查询满足条件数据的次数,成功!!明早测试下表中存在的暂态事件类型,把sql语局固定死,进行测试看返回值 - StringBuilder stringResult = new StringBuilder("SELECT ").append("count(event_type)").append(" FROM pqs_eventdetail ").append(Param.WHERE). - append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(areaReportParam.getSearchBeginTime()))).append("' and ").append("time <= '") - .append(DateUtil.endOfDay(DateUtil.parse(areaReportParam.getSearchEndTime()))) - .append("' and ").append(stringBuilder).append(" and ").append("(wave_type = 0 or wave_type = 1 or wave_type = 2 or wave_type = 3 or wave_type = 4)").append(" and ").append("event_type = '").append(listType.get(i)).append("' tz('Asia/Shanghai')"); - - //TODO - // 结果集 - QueryResult result = influxDbUtils.query(stringResult.toString()); - - //如果返回的结果不为null,将count重新赋值 - if (Objects.nonNull(result.getResults().get(0).getSeries())) { - long count = new BigDecimal(result.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).longValue(); - //count有默认值为0,不用进行非空判断,将结果集装入准备好的集合中 - typeCount.put(listType.get(i), count); - } else { - long count = 0; - //count有默认值为0,不用进行非空判断,将结果集装入准备好的集合中 - typeCount.put(listType.get(i), count); - } - - - } - - //遍历 - for (String keyCount : typeCount.keySet()) { - - for (String keyType : typeMap.keySet()) { - if (keyCount.equals(keyType)) { - resultMap.put(typeMap.get(keyType), typeCount.get(keyCount)); - - } - } - } - - //Map结果 - System.out.println(resultMap); - //还要对集合中哪个次数最多挑出第一位 - //获取entrySet - Set> entries = resultMap.entrySet(); - - //使用链表来对集合进行排序,使用LinkedList,利于插入元素 - List> result = new LinkedList<>(entries); - //自定义比较器来比较链表中的元素 - Collections.sort(result, new Comparator>() { - //基于entry的值(Entry.getValue()),来排序链表 - @Override - public int compare(Map.Entry o1, Map.Entry o2) { - return o2.getValue().compareTo(o1.getValue()); - } - }); - - //将排好序的存入到LinkedHashMap(可保持顺序)中,需要存储键和值信息对到新的映射中。 - Integer sort = 1; - Map linkMap = new LinkedHashMap<>(); - for (Map.Entry newEntry : result) { - // 取出排名前2的值 - if (sort <= 1) { - linkMap.put(newEntry.getKey(), newEntry.getValue()); - ++sort; - } - } - //最多暂降事件名称 - Set topSet = linkMap.keySet(); - List topList = new ArrayList<>(topSet); - //转为List对象集合 - List resultList = new ArrayList<>(); - for (String s : resultMap.keySet()) { - ReportCountParam reportCountParam = new ReportCountParam(); - reportCountParam.setName(s); - reportCountParam.setCount(resultMap.get(s).toString()); - resultList.add(reportCountParam); - } -/** - * =========================续写word文档============================================== - */ if (areaReportParam.isEventTypeTable()) { - twoCount3++; - createTitle(doc, "4." + oneCount6 + "." + twoCount3 + " 类型统计图", "标题 3", 400, 11); - - - //创建x,y参数 - List xdata = new ArrayList<>(); - List ydata = new ArrayList<>(); - - List types = new ArrayList<>(); - for (ReportCountParam reportCountParam : resultList) { - xdata.add(reportCountParam.getName()); - ydata.add(Integer.parseInt(reportCountParam.getCount())); - - TypesVO typesVO = new TypesVO(); - typesVO.setType(reportCountParam.getName()); - typesVO.setTimes(Integer.parseInt(reportCountParam.getCount())); - types.add(typesVO); - } - - String tr = getT(xdata, types, "bar8.ftl"); - createPic(doc, tr, ""+typeName+"类型图"); - - } else { //创建表题计数 int twoCount = 1; - + oneCount6 = oneCount; createTitle(doc, "4." + oneCount + " 类型统计", "标题 2", 200, 11); p = doc.createParagraph();// 新建一个段落 p.setAlignment(ParagraphAlignment.BOTH); XWPFRun r12 = p.createRun();//创建段落文本 - r12.setText(" 中国电网在所选择的分析时间内暂态事件主要的暂态类型为" + topList.get(0) + "[根据表格中的次数来进行分析],见下表(图):"); + r12.setText(" "+deptName+"电网在所选择的分析时间内暂态事件主要的暂态类型为" + topList.get(0) + "[根据表格中的次数来进行分析],见下表(图):"); r12.setFontSize(11);//字体大小 - createTitle(doc, "4." + oneCount + "." + twoCount + " 类型统计图", "标题 3", 400, 11); + createTitle(doc, "4." + oneCount + "." + twoCount + " 类型统计表格", "标题 3", 400, 11); + + //第一张表 + XWPFTable monitorInfo = createTable(doc); + XWPFParagraph monitorInfoExcelParagraph = WordUtils.getCenterParagraph(doc); + + // 表格第一行 + insertRow(doc, monitorInfo, monitorInfoExcelParagraph, true, "暂态类型", "电压" + typeName + "次数"); - //创建x,y参数 - List xdata = new ArrayList<>(); - List ydata = new ArrayList<>(); - - List types = new ArrayList<>(); - for (ReportCountParam reportCountParam : resultList) { - xdata.add(reportCountParam.getName()); - ydata.add(Integer.parseInt(reportCountParam.getCount())); - - TypesVO typesVO = new TypesVO(); - typesVO.setType(reportCountParam.getName()); - typesVO.setTimes(Integer.parseInt(reportCountParam.getCount())); - types.add(typesVO); + //塞入数据 + for (String name : resultMap.keySet()) { + insertRow(doc, monitorInfo, monitorInfoExcelParagraph, false, name, resultMap.get(name).toString()); } - String tr = getT(xdata, types, "bar8.ftl"); - createPic(doc, tr, ""+typeName+"类型图"); - + twoCount3 = twoCount; //序号计数进行++ oneCount++; } - /** - * =======================================word结束========================================= - */ + //暂降类型图形 + if (areaReportParam.isEventTypeChart()) { + if (areaReportParam.isEventTypeTable()) { + twoCount3++; + createTitle(doc, "4." + oneCount6 + "." + twoCount3 + " 类型统计图", "标题 3", 400, 11); + + + //创建x,y参数 + List xdata = new ArrayList<>(); + List ydata = new ArrayList<>(); + + List types = new ArrayList<>(); + for (String name : resultMap.keySet()) { + xdata.add(name); + ydata.add(resultMap.get(name)); + + TypesVO typesVO = new TypesVO(); + typesVO.setType(name); + typesVO.setTimes(resultMap.get(name)); + types.add(typesVO); + } + + String tr = getT(xdata, types, "bar8.ftl"); + createPic(doc, tr, "" + typeName + "类型图"); + + } else { + //创建表题计数 + int twoCount = 1; + + + createTitle(doc, "4." + oneCount + " 类型统计", "标题 2", 200, 11); + + p = doc.createParagraph();// 新建一个段落 + p.setAlignment(ParagraphAlignment.BOTH); + XWPFRun r12 = p.createRun();//创建段落文本 + r12.setText(" "+deptName+"电网在所选择的分析时间内暂态事件主要的暂态类型为" + topList.get(0) + "[根据表格中的次数来进行分析],见下表(图):"); + r12.setFontSize(11);//字体大小 + + createTitle(doc, "4." + oneCount + "." + twoCount + " 类型统计图", "标题 3", 400, 11); + + //创建x,y参数 + List xdata = new ArrayList<>(); + List ydata = new ArrayList<>(); + + List types = new ArrayList<>(); + for (String name : resultMap.keySet()) { + xdata.add(name); + ydata.add(resultMap.get(name)); + + TypesVO typesVO = new TypesVO(); + typesVO.setType(name); + typesVO.setTimes(resultMap.get(name)); + types.add(typesVO); + } + + String tr = getT(xdata, types, "bar8.ftl"); + createPic(doc, tr, "" + typeName + "类型图"); + + //序号计数进行++ + oneCount++; + } + } + } + + //11.暂降热力图 if (areaReportParam.isThermodynamicChart()) { //暂降热力图 - /** - * =========================续写word文档============================================== - */ - createTitle(doc, "4." + oneCount + " " + typeName + "热力图", "标题 2", 200, 11); p = doc.createParagraph();// 新建一个段落 p.setAlignment(ParagraphAlignment.BOTH); XWPFRun r12 = p.createRun();//创建段落文本 - r12.setText(" 中国网在所选择的分析时间段内累计监测" + typeName + "记录" + eventCount + "条,使用颜色将地图上按照" + typeName + "记录发生频率进行描绘,所形成的热力具体见下图:"); + r12.setText(" "+deptName+"电网在所选择的分析时间段内累计监测" + typeName + "记录" + eventCount + "条,使用颜色将地图上按照" + typeName + "记录发生频率进行描绘,所形成的热力具体见下图:"); r12.setFontSize(11);//字体大小 //所有的表结果装入集合 Map areaCount1 = new HashMap<>(); //进行遍历集合获得子区域名及其所有监测点id + //根据省级获取部门下面的信息图 for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) { //当前子部门下所有id @@ -8164,7 +5601,7 @@ public class ReportServiceImpl implements ReportService { } - System.out.println(areaCount1); +// System.out.println(areaCount1); //转为List对象集合 List areaCountList1 = new ArrayList<>(); for (String s : areaCount1.keySet()) { @@ -8174,15 +5611,10 @@ public class ReportServiceImpl implements ReportService { areaCountList1.add(reportCountParam); } - System.out.println(areaCountList1); +// System.out.println(areaCountList1); //序号计数进行++ oneCount++; - - /** - * =======================================word结束========================================= - */ - } @@ -8192,12 +5624,11 @@ public class ReportServiceImpl implements ReportService { out.close();*/ //文件下载 ServletOutputStream outputStream = response.getOutputStream(); - String fileName = URLEncoder.encode("中国热力图.docx", "UTF-8"); + String fileName = URLEncoder.encode(deptName+"热力图.docx", "UTF-8"); response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); response.setContentType("application/octet-stream;charset=UTF-8"); doc.write(outputStream); outputStream.close(); - //暂降事件 } else { @@ -9240,5 +6671,74 @@ public class ReportServiceImpl implements ReportService { return str; } + /** + * wr(初始化数据) + * @param lineIds 监测点集合 + * @return + */ + private List getEventDetailListInfo(AreaReportParam areaReportParam,List lineIds){ + StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds); + + //查询sql语句总条数 + StringBuilder stringResult = new StringBuilder("SELECT * FROM ").append(Param.EVENT_DETAIL).append(" WHERE ").append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(areaReportParam.getSearchBeginTime()))).append("' and ") + .append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(areaReportParam.getSearchEndTime()))).append("' and "); + stringResult.append(stringBuilder).append(" and ").append("(wave_type = 0 or wave_type = 1 or wave_type = 2 or wave_type = 3 or wave_type = 4)").append(" tz('Asia/Shanghai')"); + // 结果集 + QueryResult result = influxDbUtils.query(stringResult.toString()); + //结果集映射到对象中 + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + return influxDBResultMapper.toPOJO(result, EventDetailNew.class); + } + + /** + * wr(公共查询条数) + * @param lineIds 监测点集合 + * @return + */ + private QueryResult getEventDetailListInfoNum(AreaReportParam areaReportParam,List lineIds){ + StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds); + //查询sql语句总条数 + StringBuilder stringTotal = new StringBuilder("SELECT COUNT(num) as aa FROM ").append(Param.EVENT_DETAIL).append(" WHERE ").append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(areaReportParam.getSearchBeginTime()))).append("' and ") + .append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(areaReportParam.getSearchEndTime()))).append("' and "); + stringTotal.append(stringBuilder).append(" and ").append("(wave_type = 0 or wave_type = 1 or wave_type = 2 or wave_type = 3 or wave_type = 4)").append(" tz('Asia/Shanghai')"); + + //总条数 + return influxDbUtils.query(stringTotal.toString()); + } + + /** + * 报表结果排序提取 + * @param voltageCount + * @return + */ + private Map getSort(Map voltageCount){ + //还要对集合中哪个电压暂降次数最多进行计算,挑选出前两位 + //获取entrySet + Set> mapEntries = voltageCount.entrySet(); + + //使用链表来对集合进行排序,使用LinkedList,利于插入元素 + List> result = new LinkedList<>(mapEntries); + //自定义比较器来比较链表中的元素 + Collections.sort(result, new Comparator>() { + //基于entry的值(Entry.getValue()),来排序链表 + @Override + public int compare(Map.Entry o1, Map.Entry o2) { + return o2.getValue().compareTo(o1.getValue()); + } + }); + + //将排好序的存入到LinkedHashMap(可保持顺序)中,需要存储键和值信息对到新的映射中。 + Integer sort = 1; + Map linkMap = new LinkedHashMap<>(); + for (Map.Entry newEntry : result) { + // 取出排名前2的值 (注意有的是需要1个值) + if (sort <= 2) { + linkMap.put(newEntry.getKey(), newEntry.getValue()); + ++sort; + } + } + return linkMap; + } + } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/ReportService.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/ReportService.java index 14d432897..41d8b2012 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/ReportService.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/ReportService.java @@ -3,14 +3,11 @@ package com.njcn.event.service.majornetwork; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.device.pq.pojo.param.DeviceInfoParam; import com.njcn.event.pojo.param.*; -import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.pojo.vo.*; import freemarker.template.TemplateException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; -import org.influxdb.dto.QueryResult; import javax.servlet.http.HttpServletResponse; -import java.io.FileNotFoundException; import java.io.IOException; import java.text.ParseException; import java.util.List; @@ -43,19 +40,20 @@ public interface ReportService { void getLineExport(ExportParam exportParam, HttpServletResponse response) throws InvalidFormatException, IOException, TemplateException, ParseException; /** - *获取事件报告 + * 获取事件报告 + * * @author zbj * @date 2022/7/29 */ Page getEventReport(WaveTypeParam deviceInfoParam); /** - *获取区域报告 + * 获取区域报告 + * * @author zbj * @date 2022/8/4 */ void getAreaReport(AreaReportParam areaReportParam, HttpServletResponse response) throws Exception; - }