From e3d77c23a89626e486b6d29e6c64bc646e0a418f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=E6=9C=A8c?= <857448963@qq.com> Date: Thu, 15 Sep 2022 10:56:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E9=99=8D=E6=A8=A1=E5=9D=97=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=90=88=E5=B9=B6=20=E7=BB=88=E7=AB=AF=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E7=AE=A1=E7=90=86=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enums/response/CommonResponseEnum.java | 6 +- .../java/com/njcn/common/utils/PubUtils.java | 20 + .../controller/RunManageController.java | 10 +- .../com/njcn/device/mapper/DeviceMapper.java | 3 +- .../njcn/device/service/RunManageService.java | 2 +- .../service/impl/RunManageServiceImpl.java | 42 +- .../njcn/event/enums/EventResponseEnum.java | 13 +- .../event/pojo/param/AmplitudeCountParam.java | 17 + .../event/pojo/param/AreaEventMonthParam.java | 31 + .../pojo/param/AreaOnlineOrUnlinetParam.java | 20 + .../event/pojo/param/AreaReportParam.java | 76 + .../njcn/event/pojo/param/AreaTableParam.java | 42 + .../event/pojo/param/DISDIPCountParam.java | 41 + .../event/pojo/param/EventassCountParam.java | 37 + .../njcn/event/pojo/param/ExportParam.java | 75 + .../event/pojo/param/IEC28CountParam.java | 41 + .../event/pojo/param/IEC411CountParam.java | 36 + .../event/pojo/param/ReportCountParam.java | 19 + .../njcn/event/pojo/param/ReportParam.java | 26 + .../event/pojo/param/StatisticsParam.java | 38 + .../njcn/event/pojo/param/TransientParam.java | 28 + .../njcn/event/pojo/param/WaveTypeParam.java | 43 + .../com/njcn/event/pojo/po/BalanceInfo.java | 41 - .../com/njcn/event/pojo/po/EventDetail.java | 13 + .../njcn/event/pojo/po/EventDetailNew.java | 21 +- .../java/com/njcn/event/pojo/po/Eventass.java | 44 + .../java/com/njcn/event/pojo/po/QtIdx.java | 50 - .../java/com/njcn/event/pojo/po/Sarifi.java | 18 - .../java/com/njcn/event/pojo/vo/BaseVO.java | 19 + .../java/com/njcn/event/pojo/vo/BitMapVO.java | 104 + .../java/com/njcn/event/pojo/vo/ChanceVO.java | 33 + .../java/com/njcn/event/pojo/vo/CoordsVO.java | 30 + .../java/com/njcn/event/pojo/vo/DISDIPVO.java | 48 + .../java/com/njcn/event/pojo/vo/DetailVO.java | 37 + .../njcn/event/pojo/vo/EventHeatMapVO.java | 4 +- .../com/njcn/event/pojo/vo/GeneralVO.java | 46 + .../java/com/njcn/event/pojo/vo/IEC28VO.java | 47 + .../java/com/njcn/event/pojo/vo/IEC411VO.java | 42 + .../main/java/com/njcn/event/pojo/vo/OB.java | 23 + .../java/com/njcn/event/pojo/vo/PointVO.java | 89 + .../com/njcn/event/pojo/vo/ProbabilityVO.java | 33 + .../com/njcn/event/pojo/vo/ReasonsVO.java | 32 + .../com/njcn/event/pojo/vo/StatisticVO.java | 43 + .../pojo/vo/TerminalRunningStatisticsVO.java | 26 +- .../java/com/njcn/event/pojo/vo/TimeSVO.java | 25 + .../java/com/njcn/event/pojo/vo/TimeVO.java | 42 + .../java/com/njcn/event/pojo/vo/TypesVO.java | 27 + .../pojo/vo/VoltageToleranceCurveVO.java | 35 +- .../com/njcn/event/pojo/vo/WaveTypeVO.java | 194 + pqs-event/event-boot/pom.xml | 34 +- .../njcn/event/config/EventBaseConfig.java | 18 - .../controller/AreaAnalysisController.java | 2 +- .../njcn/event/controller/AreaController.java | 20 - .../controller/EventDetailController.java | 1 + .../controller/MonitorPointController.java | 203 +- .../event/controller/ReportController.java | 218 + .../event/controller/TransientController.java | 15 +- .../controller/area/AreaInfoController.java | 28 +- .../event/influxdb/PqsEventDetailQuery.java | 29 +- .../com/njcn/event/influxdb/QueryBuilder.java | 19 +- .../njcn/event/service/AreaInfoService.java | 10 +- .../njcn/event/service/AreaLineService.java | 8 - .../event/service/EventAnalysisService.java | 82 +- .../service/Impl/AreaAnalysisServiceImpl.java | 95 +- .../service/Impl/AreaInfoServiceImpl.java | 67 +- .../service/Impl/AreaLineServiceImpl.java | 181 +- .../Impl/AreaStatisticalServiceImpl.java | 117 +- .../Impl/EventAnalysisServiceImpl.java | 1916 +++- .../service/Impl/EventDetailServiceImpl.java | 5 +- .../event/service/Impl/ReportController.java | 1939 ++++ .../event/service/Impl/ReportServiceImpl.java | 9184 +++++++++++++++++ .../service/Impl/TransientServiceImpl.java | 206 +- .../com/njcn/event/service/ReportService.java | 61 + .../njcn/event/service/TransientService.java | 10 +- .../main/java/com/njcn/event/template/bar.ftl | 86 + .../java/com/njcn/event/template/bar2.ftl | 103 + .../java/com/njcn/event/template/bar3.ftl | 85 + .../java/com/njcn/event/template/bar4.ftl | 61 + .../java/com/njcn/event/template/bar5.ftl | 93 + .../java/com/njcn/event/template/bar6.ftl | 71 + .../java/com/njcn/event/template/bar7.ftl | 58 + .../java/com/njcn/event/template/bar8.ftl | 49 + .../java/com/njcn/event/template/bar9.ftl | 49 + .../java/com/njcn/event/template/dydj.ftl | 66 + .../java/com/njcn/event/template/qytj.ftl | 68 + .../java/com/njcn/event/template/test.ftl | 12 + .../java/com/njcn/event/template/yftj.ftl | 76 + .../com/njcn/event/utils/EchartsUtil.java | 52 + .../com/njcn/event/utils/FreemarkerUtil.java | 41 + .../java/com/njcn/event/utils/HttpUtil.java | 63 + .../com/njcn/event/utils/TestTemplate.java | 61 + .../java/com/njcn/event/utils/WordUtils.java | 368 + 92 files changed, 17262 insertions(+), 500 deletions(-) create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AmplitudeCountParam.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AreaEventMonthParam.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AreaOnlineOrUnlinetParam.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AreaReportParam.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AreaTableParam.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/DISDIPCountParam.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/EventassCountParam.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/ExportParam.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/IEC28CountParam.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/IEC411CountParam.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/ReportCountParam.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/ReportParam.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/StatisticsParam.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/WaveTypeParam.java delete mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/BalanceInfo.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/Eventass.java delete mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/QtIdx.java delete mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/Sarifi.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/BaseVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/BitMapVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/ChanceVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/CoordsVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/DISDIPVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/DetailVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/GeneralVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/IEC28VO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/IEC411VO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/OB.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/PointVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/ProbabilityVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/ReasonsVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/StatisticVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TimeSVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TimeVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TypesVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/WaveTypeVO.java delete mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/config/EventBaseConfig.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/controller/ReportController.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/ReportController.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/ReportServiceImpl.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/service/ReportService.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/template/bar.ftl create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/template/bar2.ftl create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/template/bar3.ftl create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/template/bar4.ftl create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/template/bar5.ftl create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/template/bar6.ftl create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/template/bar7.ftl create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/template/bar8.ftl create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/template/bar9.ftl create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/template/dydj.ftl create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/template/qytj.ftl create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/template/test.ftl create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/template/yftj.ftl create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/utils/EchartsUtil.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/utils/FreemarkerUtil.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/utils/HttpUtil.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/utils/TestTemplate.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/utils/WordUtils.java diff --git a/pqs-common/common-core/src/main/java/com/njcn/common/pojo/enums/response/CommonResponseEnum.java b/pqs-common/common-core/src/main/java/com/njcn/common/pojo/enums/response/CommonResponseEnum.java index 99c2727c3..65e744d85 100644 --- a/pqs-common/common-core/src/main/java/com/njcn/common/pojo/enums/response/CommonResponseEnum.java +++ b/pqs-common/common-core/src/main/java/com/njcn/common/pojo/enums/response/CommonResponseEnum.java @@ -88,7 +88,11 @@ public enum CommonResponseEnum { DEPT_BINDED("A0099", "部门id已绑定"), - ID_NOT_EXIST("A0099", "id不存在"), + ID_NOT_EXIST("A0100", "id不存在"), + + TIME_ERROR("A0101","时间格式有误"), + + ; private final String code; diff --git a/pqs-common/common-core/src/main/java/com/njcn/common/utils/PubUtils.java b/pqs-common/common-core/src/main/java/com/njcn/common/utils/PubUtils.java index 4cf248a46..262e6b253 100644 --- a/pqs-common/common-core/src/main/java/com/njcn/common/utils/PubUtils.java +++ b/pqs-common/common-core/src/main/java/com/njcn/common/utils/PubUtils.java @@ -178,6 +178,26 @@ public class PubUtils { return LocalDateTime.parse(time, dateTimeFormatter); } + /** + * 校验时间格式 + */ + public static boolean checkDateTime(String time) { + if(StrUtil.isBlank(time)){ + throw new BusinessException(CommonResponseEnum.TIME_ERROR); + } + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_TIME); + + try { + simpleDateFormat.parse(time); + } catch (Exception e) { + throw new BusinessException(CommonResponseEnum.TIME_ERROR); + } + + return true; + } + + + /** * 用于获取对象中,前缀一样,后缀为2~50的属性值 * diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/controller/RunManageController.java b/pqs-device/device-boot/src/main/java/com/njcn/device/controller/RunManageController.java index 7475c7633..263792000 100644 --- a/pqs-device/device-boot/src/main/java/com/njcn/device/controller/RunManageController.java +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/controller/RunManageController.java @@ -1,11 +1,14 @@ package com.njcn.device.controller; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.date.format.DatePrinter; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.HttpResultUtil; +import com.njcn.common.utils.PubUtils; import com.njcn.device.pojo.param.DeviceInfoParam; import com.njcn.device.pojo.param.RunManageParam; import com.njcn.device.pojo.param.TerminalLedgerParam; @@ -23,6 +26,9 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; /** @@ -45,9 +51,9 @@ public class RunManageController extends BaseController { @PostMapping("/getLineLedger") @ApiOperation("监测点台账信息") @ApiImplicitParam(name = "runManageParam", value = "监测点台账参数", required = true) - public HttpResult> getLineLedger(@RequestBody @Validated RunManageParam runManageParam) { + public HttpResult> getLineLedger(@RequestBody @Validated RunManageParam runManageParam) { String methodDescribe = getMethodDescribe("getLineLedger"); - Page res = runManageService.getLineLedger(runManageParam); + List res = runManageService.getLineLedger(runManageParam); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe); } diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/DeviceMapper.java b/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/DeviceMapper.java index fe57e24e7..72f000c57 100644 --- a/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/DeviceMapper.java +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/DeviceMapper.java @@ -25,7 +25,6 @@ public interface DeviceMapper extends BaseMapper { * @author cdf * @date 2022/5/11 */ - //TODO List getDeviceList(@Param("list") List list); /** @@ -35,7 +34,7 @@ public interface DeviceMapper extends BaseMapper { * @param runFlag 状态 * @return 结果 */ - Page getRunManageList(@Param("page") Page page, @Param("list") List list, @Param("comFlag")List comFlag, @Param("runFlag")List runFlag); + List getRunManageList(@Param("list") List list, @Param("comFlag")List comFlag, @Param("runFlag")List runFlag); /** * 获取监测点台账信息 diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/service/RunManageService.java b/pqs-device/device-boot/src/main/java/com/njcn/device/service/RunManageService.java index be3889a7f..d77ab60a7 100644 --- a/pqs-device/device-boot/src/main/java/com/njcn/device/service/RunManageService.java +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/service/RunManageService.java @@ -21,7 +21,7 @@ public interface RunManageService { * @param runManageParam 参数 * @return 结果 */ - Page getLineLedger(RunManageParam runManageParam); + List getLineLedger(RunManageParam runManageParam); /** * 获取终端台账信息 diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/RunManageServiceImpl.java b/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/RunManageServiceImpl.java index 2bd1b8da5..85d01ea39 100644 --- a/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/RunManageServiceImpl.java +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/RunManageServiceImpl.java @@ -3,6 +3,7 @@ package com.njcn.device.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.date.LocalDateTimeUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.common.pojo.dto.SimpleDTO; @@ -43,6 +44,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.math.BigDecimal; +import java.text.DateFormat; import java.text.SimpleDateFormat; import java.time.format.DateTimeFormatter; import java.util.*; @@ -77,14 +79,13 @@ public class RunManageServiceImpl implements RunManageService { private final InfluxDbUtils influxDbUtils; @Override - public Page getLineLedger(RunManageParam runManageParam) { + public List getLineLedger(RunManageParam runManageParam) { DeviceInfoParam deviceInfoParam = new DeviceInfoParam(); BeanUtil.copyProperties(runManageParam, deviceInfoParam); List generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, runManageParam.getRunFlag(), Stream.of(1).collect(Collectors.toList())); List lineIndexes = generalDeviceDTOList.stream().flatMap(list->list.getLineIndexes().stream()).collect(Collectors.toList()); if (!CollectionUtils.isEmpty(lineIndexes)) { - Page page = new Page<>(PageFactory.getPageNum(runManageParam),PageFactory.getPageSize(runManageParam)); - return deviceMapper.getRunManageList(page,lineIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag()); + return deviceMapper.getRunManageList(lineIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag()); }else { throw new BusinessException(CommonResponseEnum.FAIL); } @@ -99,14 +100,16 @@ public class RunManageServiceImpl implements RunManageService { if (!CollectionUtils.isEmpty(generalDeviceDTOList)) { List devIndexes = generalDeviceDTOList.stream().flatMap(list->list.getDeviceIndexes().stream()).collect(Collectors.toList()); - + DateFormat bf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + runManageParam.setSearchBeginTime(DateUtil.beginOfMonth(new Date()).toString(bf)); + runManageParam.setSearchEndTime(DateUtil.endOfMonth(new Date()).toString(bf)); if(CollectionUtil.isNotEmpty(devIndexes)){ runManageDevList = deviceMapper.getRunManageDevList(devIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag()); StringBuilder devSql = InfluxDBCommUtils.assToInfluxParamDev(devIndexes); String stringBuilder = "time >= '" + runManageParam.getSearchBeginTime() + "' and " + "time <= '" + runManageParam.getSearchEndTime()+"' and "+devSql+" group by dev_id"; //sql语句 - String sql = "SELECT MEAN(online_rate) AS online_rate FROM " + PQS_ONLINERATE + " WHERE " + stringBuilder + TIME_ZONE+")"; + String sql = "SELECT MEAN(online_rate) AS online_rate FROM " + PQS_ONLINERATE + " WHERE " + stringBuilder + TIME_ZONE; QueryResult queryResult = influxDbUtils.query(sql); InfluxDBResultMapper inCn = new InfluxDBResultMapper(); @@ -117,38 +120,11 @@ public class RunManageServiceImpl implements RunManageService { return runManageDevList; } - /* private Float getCondition(String startTime, String endTime, String lineId) { - final Float[] floatList = {0.0f}; - QueryResult queryResult; - if (!lineId.isEmpty()) { - //组装sql语句 - String stringBuilder = "time >= '" + startTime + "' and " + "time <= '" + endTime + "' and (" + DEV_INDEX + " ='" + lineId + "') "; - //sql语句 - String sql = "SELECT SUM(" + ONLINE_MIN + ")/(SUM(" + OFFLINE_MIN + ")+SUM(" + ONLINE_MIN + ")) AS onlineRate FROM " + PQS_ONLINERATE + " WHERE " + stringBuilder + TIME_ZONE; - queryResult = influxDbUtils.query(sql); - //处理结果集 - List list = queryResult.getResults().get(0).getSeries(); - if (!CollectionUtils.isEmpty(list)) { - list.forEach(po -> { - List> valueList = po.getValues(); - if (!CollectionUtils.isEmpty(valueList)) { - for (List value : valueList) { - //数据完整性 保留四位小数 - floatList[0] = value.get(1) == null ? null : BigDecimal.valueOf(Float.parseFloat(value.get(1).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue(); - } - } - }); - } - return floatList[0]; - } - - return floatList[0]; - }*/ @Override public List getTerminalLedger(DeviceInfoParam deviceInfoParam) { //定义待返回终端信息 - List generalDeviceDTOList = generalDeviceService.getDeviceInfoAsDept(deviceInfoParam, Stream.of(0).collect(Collectors.toList()), Stream.of(1).collect(Collectors.toList())); + List generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, Stream.of(0).collect(Collectors.toList()), Stream.of(1).collect(Collectors.toList())); List terminalLedgerVOList = new ArrayList<>(); if (CollectionUtil.isNotEmpty(generalDeviceDTOList)) { diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/enums/EventResponseEnum.java b/pqs-event/event-api/src/main/java/com/njcn/event/enums/EventResponseEnum.java index b7cb7720b..a4e1dda2e 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/enums/EventResponseEnum.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/enums/EventResponseEnum.java @@ -16,7 +16,18 @@ public enum EventResponseEnum { */ EVENT_COMMON_ERROR("A00650","暂降模块异常"), EVENT_NOT_FOUND("A00651","暂降事件或监测点不存在"), - ANALYSEWAVE_NOT_FOUND("A00652","波形文件找不到") + ANALYSEWAVE_NOT_FOUND("A00652","波形文件找不到"), + + + /** + * zbj + * 2022/8/4 + */ + EVENT_REASON_NOT_FOUND("A00653","暂态原因不存在"), + EVENT_TYPE_NOT_FOUND("A00654","暂态类型不存在"), + INDEX_OUT_OF_BOUNDS("A00655","集合索引越界异常"), + + NOT_FOUND("A00656","没有查到数据"), ; private final String code; diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AmplitudeCountParam.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AmplitudeCountParam.java new file mode 100644 index 000000000..2a1f4062c --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AmplitudeCountParam.java @@ -0,0 +1,17 @@ +package com.njcn.event.pojo.param; + +import lombok.Data; + +/** + * @author zbj + * @version 1.0.0 + * @date 2022年08月23日 + */ +@Data +public class AmplitudeCountParam { + + private String xName; + + private String yValue; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AreaEventMonthParam.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AreaEventMonthParam.java new file mode 100644 index 000000000..45492c447 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AreaEventMonthParam.java @@ -0,0 +1,31 @@ +package com.njcn.event.pojo.param; + +import com.njcn.event.pojo.po.EventDetail; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.time.Instant; +import java.util.List; + +/** + * @author zbj + * @version 1.0.0 + * @date 2022年08月18日 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class AreaEventMonthParam implements Serializable { + + @ApiModelProperty(name = "time", value = "对应月份或者时间") + private String dayOrMonth; + + + @ApiModelProperty(name = "eventAssIndex", value = "关联处理事件时间") + private String eventAssIndex; + + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AreaOnlineOrUnlinetParam.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AreaOnlineOrUnlinetParam.java new file mode 100644 index 000000000..2b779c9e4 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AreaOnlineOrUnlinetParam.java @@ -0,0 +1,20 @@ +package com.njcn.event.pojo.param; + +import lombok.Data; + +/** + * @author zbj + * @version 1.0.0 + * @date 2022年08月25日 + */ +@Data +public class AreaOnlineOrUnlinetParam { + + private String name; + + private Integer sumCont; + + private Integer onlineCount; + + private Integer unlineCount; +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AreaReportParam.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AreaReportParam.java new file mode 100644 index 000000000..5d74efdda --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AreaReportParam.java @@ -0,0 +1,76 @@ +package com.njcn.event.pojo.param; + + +import com.njcn.device.pojo.param.DeviceInfoParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.hibernate.validator.constraints.Range; + +import javax.validation.constraints.NotNull; +import java.util.List; + + +/** + * @version 1.0.0 + * @author: zbj + * @date: 2022/08/04 + */ +@Data +@ApiModel +@EqualsAndHashCode(callSuper = true) +public class AreaReportParam extends DeviceInfoParam.BusinessParam { + + @ApiModelProperty("监测网分布图形") + private boolean monitorDistributeChart = false; + + @ApiModelProperty("暂降事件统计表格") + private boolean eventCountTable = false; + + @ApiModelProperty("暂降事件统计图形") + private boolean eventCountChart = false; + + @ApiModelProperty("暂降密度表格") + private boolean densityTable = false; + + @ApiModelProperty("暂降密度图形") + private boolean densityChart = false; + + @ApiModelProperty("暂降事件点ITIC") + private boolean itic = false; + + @ApiModelProperty("暂降事件点F47") + private boolean f47 = false; + + @ApiModelProperty("概率分布暂降幅值") + private boolean sagAmplitude = false; + + @ApiModelProperty("概率分布持续时间") + private boolean duration = false; + + @ApiModelProperty("事件关联统计表格") + private boolean eventRelevanceCountTable = false; + + @ApiModelProperty("暂降原因表格") + private boolean eventReasonTable = false; + + @ApiModelProperty("暂降原因图形") + private boolean eventReasonChart = false; + + @ApiModelProperty("暂降类型表格") + private boolean eventTypeTable = false; + + @ApiModelProperty("暂降类型图形") + private boolean eventTypeChart = false; + + @ApiModelProperty("暂降热力图") + private boolean thermodynamicChart = false; + + @ApiModelProperty("触发类型") + private Integer waveType; + + @NotNull + @ApiModelProperty("日期下拉框 0:月 , 1:天") + private String interval; +} 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 new file mode 100644 index 000000000..8dcd75aa5 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/AreaTableParam.java @@ -0,0 +1,42 @@ +package com.njcn.event.pojo.param; + +import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.pojo.po.EventDetailNew; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zbj + * @version 1.0.0 + * @date 2022年08月18日 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +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; + + @ApiModelProperty(name = "info", value = "sql结果集") + private List info; + + @ApiModelProperty(name = "waveType", value = "暂态类型") + private Integer waveType; +} + + diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/DISDIPCountParam.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/DISDIPCountParam.java new file mode 100644 index 000000000..db84a78dc --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/DISDIPCountParam.java @@ -0,0 +1,41 @@ +package com.njcn.event.pojo.param; + +import lombok.Data; + +/** + * pqs-event + * + * @author zbj + * @date 2022/8/15 + */ +@Data +public class DISDIPCountParam { + + //剩余电压名称 + private String name; + + //20ms + private int twentyMS = 0; + + //100 + private int oneHundredMS = 0; + + //500 + private int fiveHundredMS = 0; + + //1 + private int one = 0; + + //3 + private int three = 0; + + //20 + private int twenty = 0; + + //60 + private int sixty = 0; + + //180 + private int oneHundredAndEighty = 0; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/EventassCountParam.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/EventassCountParam.java new file mode 100644 index 000000000..d04e95ce9 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/EventassCountParam.java @@ -0,0 +1,37 @@ +package com.njcn.event.pojo.param; + +import com.njcn.event.pojo.po.EventDetail; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zbj + * @version 1.0.0 + * @date 2022年08月24日 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class EventassCountParam implements Serializable { + + + @ApiModelProperty(name = "assTime", value = "ass时间") + private String assTime; + + + @ApiModelProperty(name = "eventTime", value = "event时间") + private String eventTime; + + + @ApiModelProperty(name = "describe", value = "事件关联描述") + private String describe; + + +} + + diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/ExportParam.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/ExportParam.java new file mode 100644 index 000000000..c4b3ef4bc --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/ExportParam.java @@ -0,0 +1,75 @@ +package com.njcn.event.pojo.param; + +import com.njcn.device.pojo.param.DeviceInfoParam; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.Getter; + +import java.io.Serializable; + +/** + * @author xxy + * @version 1.0.0 + * @date 2022年08月16日 19:37 + */ +@Data +public class ExportParam implements Serializable { + + @ApiModelProperty(name = "lineId",value = "监测点ID") + private String lineId; + + @ApiModelProperty(name = "searchBeginTime",value = "开始时间") + private String searchBeginTime; + + @ApiModelProperty(name = "searchEndTime",value = "结束时间") + private String searchEndTime; + + @ApiModelProperty(name = "lineName",value = "监测点名称") + private String lineName; + + @ApiModelProperty(name = "xq",value = "监测点详情") + private boolean xq; + + @ApiModelProperty(name = "lb",value = "暂降事件列表") + private boolean lb; + + @ApiModelProperty(name = "mdbg",value = "暂降密度表格") + private boolean mdbg; + + @ApiModelProperty(name = "mdtx",value = "暂降密度图形") + private boolean mdtx; + + @ApiModelProperty(name = "sjdITIC",value = "暂降时间点ITIC") + private boolean sjdITIC; + + @ApiModelProperty(name = "sjdF47",value = "暂降时间点F47") + private boolean sjdF47; + + @ApiModelProperty(name = "glfbfz",value = "概率分布暂降赋值") + private boolean glfbfz; + + @ApiModelProperty(name = "glfbsj",value = "概率分布持续时间") + private boolean glfbsj; + + @ApiModelProperty(name = "tjbg",value = "月份统计表格") + private boolean tjbg; + + @ApiModelProperty(name = "tjtx",value = "月份统计图形") + private boolean tjtx; + + @ApiModelProperty(name = "yybg",value = "暂降原因表格") + private boolean yybg; + + @ApiModelProperty(name = "yytx",value = "暂降原因图形") + private boolean yytx; + + @ApiModelProperty(name = "lxbg",value = "暂降类型表格") + private boolean lxbg; + + @ApiModelProperty(name = "lxtx",value = "暂降类型图形") + private boolean lxtx; + + @ApiModelProperty(name = "flag",value = "标识") + private Integer flag; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/IEC28CountParam.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/IEC28CountParam.java new file mode 100644 index 000000000..9826eeeda --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/IEC28CountParam.java @@ -0,0 +1,41 @@ +package com.njcn.event.pojo.param; + +import lombok.Data; + +/** + * pqs-event + * + * @author zbj + * @date 2022/8/15 + */ +@Data +public class IEC28CountParam { + + //剩余电压名称 + private String name; + + //0.02~0.1 + private int zeroZeroTwoToZeroOne = 0; + + //0.1~0.25 + private int zeroOneToZeroTwentyFive = 0; + + //0.25~0.5 + private int zeroTwentyFiveToZeroFive = 0; + + //0.5~1 + private int zeroFiveToOne = 0; + + //1~3 + private int oneToThree = 0; + + //3~20 + private int threeToTwenty = 0; + + //20~60 + private int twentyToSixty = 0; + + //60~180 + private int sixtyToOneHundredAndEighty = 0; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/IEC411CountParam.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/IEC411CountParam.java new file mode 100644 index 000000000..497f11ea4 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/IEC411CountParam.java @@ -0,0 +1,36 @@ +package com.njcn.event.pojo.param; + +import lombok.Data; + +/** + * pqs-event + * + * @author zbj + * @date 2022/8/15 + */ +@Data +public class IEC411CountParam { + + //剩余电压名称 + private String name; + + //10~20 + private int tenToTwenty = 0; + + //20~100 + private int twentyToHundred = 0; + + //0.1~0.2 + private int zeroOneToZeroTwo = 0; + + //0.2~0.5 + private int zeroTwoToZeroFive = 0; + + //0.5~1 + private int zeroFiveToOne = 0; + + //>1 + private int lessOne = 0; + + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/ReportCountParam.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/ReportCountParam.java new file mode 100644 index 000000000..f883fd572 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/ReportCountParam.java @@ -0,0 +1,19 @@ +package com.njcn.event.pojo.param; + +import lombok.Data; +/** + * @author zbj + * @version 1.0.0 + * @date 2022年08月17日 + */ +@Data +public class ReportCountParam { + + private String name; + + private String count; + + private String relevanceCount; + + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/ReportParam.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/ReportParam.java new file mode 100644 index 000000000..27e7d686e --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/ReportParam.java @@ -0,0 +1,26 @@ +package com.njcn.event.pojo.param; + +import com.njcn.web.pojo.param.BaseParam; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author xxy + * @version 1.0.0 + * @date 2022年08月09日 08:45 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class ReportParam extends BaseParam implements Serializable { + + @ApiModelProperty(name = "staFlag") + private boolean staFalg; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/StatisticsParam.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/StatisticsParam.java new file mode 100644 index 000000000..3a916cdeb --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/StatisticsParam.java @@ -0,0 +1,38 @@ +package com.njcn.event.pojo.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.Date; + +/** + * @author xxy + * @version 1.0.0 + * @date 2022年08月01日 15:35 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class StatisticsParam implements Serializable { + + @NotBlank(message = "没有监测点ID") + @ApiModelProperty(name = "lineIndex",value = "监测点ID") + private String lineIndex; + + @NotBlank(message = "没有开始时间") + @ApiModelProperty(name = "startTime",value = "开始时间") + private String startTime; + + @NotBlank(message = "没有结束时间") + @ApiModelProperty(name = "endTime",value = "结束时间") + private String endTime; + + @ApiModelProperty(name = "flag",value = "标识") + private Integer flag; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/TransientParam.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/TransientParam.java index 7fc1da0bd..d2a9933af 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/TransientParam.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/TransientParam.java @@ -7,6 +7,8 @@ import lombok.EqualsAndHashCode; import org.hibernate.validator.constraints.Range; import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.util.List; /** * @version 1.0.0 @@ -27,5 +29,31 @@ public class TransientParam extends DeviceInfoParam.BusinessParam { @Range(min = 1,message = "条数必须大于0") private Integer pageSize; + @ApiModelProperty("暂态幅值最大值") + private BigDecimal eventValueMax; + @ApiModelProperty("暂态幅值最小值") + private BigDecimal eventValueMin; + + @ApiModelProperty("持续时间最大值") + private Integer persistMax; + @ApiModelProperty("持续时间最小值") + private Integer persistMin; + + @ApiModelProperty("严重度最大值") + private BigDecimal severityMax; + @ApiModelProperty("严重度最小值") + private BigDecimal severityMin; + + @ApiModelProperty("触发类型") + private List waveType; + + @ApiModelProperty("暂降原因") + private List eventReason; + + @ApiModelProperty("暂降类型") + private List eventType; + + @ApiModelProperty("波形文件") + private Integer fileFlag; } diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/WaveTypeParam.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/WaveTypeParam.java new file mode 100644 index 000000000..7d6b31b33 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/WaveTypeParam.java @@ -0,0 +1,43 @@ +package com.njcn.event.pojo.param; + +import com.njcn.device.pojo.param.DeviceInfoParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.hibernate.validator.constraints.Range; + +import javax.validation.constraints.NotNull; + + +/** + * @version 1.0.0 + * @author: zbj + * @date: 2022/07/29 + */ +@Data +@ApiModel +public class WaveTypeParam extends DeviceInfoParam.BusinessParam { + @ApiModelProperty("搜索值") + private String searchValue; + @ApiModelProperty("触发类型") + private String waveType; + + @ApiModelProperty("页码") + @NotNull(message = "页码不可为空") + @Range(min = 1, message = "页码必须大于0") + private Integer pageNum; + + @ApiModelProperty("条数") + @NotNull(message = "条数不可为空") + @Range(min = 1, message = "条数必须大于0") + private Integer pageSize; + + @NotNull( + message = "通讯状态 0.离线 1.在线" + ) + @ApiModelProperty( + name = "comFlag", + value = "通讯状态 0.离线 1.在线" + ) + private Integer comFlag = 1; +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/BalanceInfo.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/BalanceInfo.java deleted file mode 100644 index f0c6ec0c6..000000000 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/BalanceInfo.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.njcn.event.pojo.po; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.util.List; - -/** - * @author denghuajun - * @version 1.0.0 - * @date 2022年08月18日 13:42 - * 电压区域综合评估基本类 - */ - -@Data -public class BalanceInfo implements Serializable { - @Data - public class PointInfo { - private Integer pointId; - private String pointName; - private QtIdx qtIdx; - private float civ; - private int l; - - public PointInfo() { - super(); - qtIdx = new QtIdx(); - } - } - @ApiModelProperty("区域的index") - private String areaIndex; - @ApiModelProperty("区域名称") - private String areaName; - @ApiModelProperty("系统最终的评估分") - private float ci; - @ApiModelProperty("监测点的详细信息") - private List list; - @ApiModelProperty("标识是否经过计算,默认为0-未计算,1-计算") - private int isCount; -} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/EventDetail.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/EventDetail.java index c13c35e8e..a2e825388 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/EventDetail.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/EventDetail.java @@ -1,9 +1,11 @@ package com.njcn.event.pojo.po; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.influxdb.annotation.Column; import org.influxdb.annotation.Measurement; +import java.math.BigDecimal; import java.time.Instant; /** @@ -82,4 +84,15 @@ public class EventDetail { @Column(name = "create_time") private String createTime; + private String lineName; + + private BigDecimal lat; + + private BigDecimal lng; + + private String gdName; + + private String subName; + + } diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/EventDetailNew.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/EventDetailNew.java index 7f427ddc9..a88310bff 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/EventDetailNew.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/EventDetailNew.java @@ -3,10 +3,8 @@ package com.njcn.event.pojo.po; import lombok.Data; import org.influxdb.annotation.Column; import org.influxdb.annotation.Measurement; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.Instant; -import java.time.LocalDateTime; +import java.math.BigDecimal; /** * @author cdf @@ -22,8 +20,7 @@ public class EventDetailNew { private String lineId; @Column(name = "time") - @DateTimeFormat(pattern = "yyyy-mm-dd") - private LocalDateTime timeId; + private String timeId; @Column(name = "event_describe") private String eventDescribe; @@ -85,4 +82,18 @@ public class EventDetailNew { @Column(name = "create_time") private String createTime; + private String lineName; + + private BigDecimal lat; + + private BigDecimal lng; + + private String gdName; + + private String subName; + + private String ip; + + private String scale; + } diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/Eventass.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/Eventass.java new file mode 100644 index 000000000..6bc644f4c --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/Eventass.java @@ -0,0 +1,44 @@ +package com.njcn.event.pojo.po; + +import lombok.Data; +import org.influxdb.annotation.Column; +import org.influxdb.annotation.Measurement; + +import java.math.BigDecimal; +import java.time.Instant; + +/** + * @author zbj + * @version 1.0.0 + * @date 2022年08月24日 + */ + +@Data +@Measurement(name = "pqs_eventass") +public class Eventass { + + @Column(name = "time") + private Instant timeId; + + @Column(name = "event_time") + private String eventTime; + + @Column(name = "line_id") + private String lineId; + + @Column(name = "host") + private String host; + + @Column(name = "describe") + private String describe; + + @Column(name = "range") + private Integer range; + + @Column(name = "user_index") + private String userIndex; + + @Column(name = "user_name") + private String userName; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/QtIdx.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/QtIdx.java deleted file mode 100644 index efc10e332..000000000 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/QtIdx.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.njcn.event.pojo.po; - -import com.sun.jna.Structure; -import io.swagger.annotations.ApiModelProperty; - -import java.util.List; - -/** - * @author denghuajun - * @version 1.0.0 - * @date 2022年08月18日 13:45 - * //单个监测点的暂降事件计算评价指标 - */ -public class QtIdx extends Structure { - @ApiModelProperty("暂降幅值") - public float r_esm; - @ApiModelProperty("sarifi-90") - public int sarfi_90; - @ApiModelProperty("sarifi-50") - public int sarifi_50; - @ApiModelProperty("暂降能量") - public float r_asei; - @ApiModelProperty("严重程度") - public float r_assi; - - public static class ByReference extends QtIdx implements Structure.ByReference { - - } - - public static class ByValue extends QtIdx implements Structure.ByValue { - - } - - @Override - protected List getFieldOrder() { - return null; - } - - @Override - public boolean equals(Object obj) { - if (obj == null || !(obj instanceof QtIdx)) - return false; - if (this == obj) - return true; - - QtIdx instance = (QtIdx) obj; - - return (r_esm == instance.r_esm) && (sarfi_90 == instance.sarfi_90) && (sarifi_50 == instance.sarifi_50) && (r_asei == instance.r_asei) && (r_assi == instance.r_assi); - } -} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/Sarifi.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/Sarifi.java deleted file mode 100644 index ec6e31371..000000000 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/Sarifi.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.njcn.event.pojo.po; - -import lombok.Data; - -import java.io.Serializable; - -/** - * @author denghuajun - * @version 1.0.0 - * @date 2022年08月19日 11:10 - */ -@Data -public class Sarifi implements Serializable { - private Float sarifiValue; - private Float time; - private Float pt1; - private Float pt2; -} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/BaseVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/BaseVO.java new file mode 100644 index 000000000..17e2d3b54 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/BaseVO.java @@ -0,0 +1,19 @@ +package com.njcn.event.pojo.vo; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * pqs-event + * + * @author cdf + * @date 2022/9/2 + */ +@Data +public class BaseVO { + + private String name; + + private BigDecimal value; +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/BitMapVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/BitMapVO.java new file mode 100644 index 000000000..a823aa458 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/BitMapVO.java @@ -0,0 +1,104 @@ +package com.njcn.event.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author xxy + * @version 1.0.0 + * @date 2022年08月02日 08:44 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class BitMapVO implements Serializable { + + @ApiModelProperty(name = "describe",value = "描述") + private String describe; + + @ApiModelProperty(name = "eventDetailIndex") + private String eventDetailIndex; + + @ApiModelProperty(name = "eventName") + private String eventName; + + @ApiModelProperty(name = "eventReason") + private String eventReason; + + @ApiModelProperty(name = "eventType") + private String eventType; + + @ApiModelProperty(name = "eventassIndex") + private String eventassIndex; + + @ApiModelProperty(name = "eventvalue") + private Integer eventvalue; + + @ApiModelProperty(name = "eventvaluea") + private Integer eventvaluea; + + @ApiModelProperty(name = "eventvalueb") + private Integer eventvalueb; + + @ApiModelProperty(name = "eventvaluec") + private Integer eventvaluec; + + @ApiModelProperty(name = "fileFlag") + private String fileFlag; + + @ApiModelProperty(name = "gdName",value = "供电名称") + private String gdName; + + @ApiModelProperty(name = "lineId",value = "监测点ID") + private String lineId; + + @ApiModelProperty(name = "lineName",value = "监测点名称") + private String lineName; + + @ApiModelProperty(name = "loadType") + private String loadType; + + @ApiModelProperty(name = "ms") + private Integer ms; + + @ApiModelProperty(name = "persisttime") + private String persisttime; + + @ApiModelProperty(name = "persisttimea") + private String persisttimea; + + @ApiModelProperty(name = "persisttimeb") + private String persisttimeb; + + @ApiModelProperty(name = "persisttimec") + private String persisttimec; + + @ApiModelProperty(name = "scale") + private String scale; + + @ApiModelProperty(name = "serverity") + private String serverity; + + @ApiModelProperty(name = "state") + private String state; + + @ApiModelProperty(name = "subName") + private String subName; + + @ApiModelProperty(name = "time") + private String time; + + @ApiModelProperty(name = "timeid") + private String timeid; + + @ApiModelProperty(name = "type") + private String type; + + @ApiModelProperty(name = "wavetype") + private String wavetype; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/ChanceVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/ChanceVO.java new file mode 100644 index 000000000..296bfcba4 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/ChanceVO.java @@ -0,0 +1,33 @@ +package com.njcn.event.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author xxy + * @version 1.0.0 + * @date 2022年08月02日 10:50 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ChanceVO implements Serializable { + + @ApiModelProperty(name = "eventvalue") + private List eventvalue; + + @ApiModelProperty(name = "pereventvalue") + private List pereventvalue; + + @ApiModelProperty(name = "persisttime") + private List persisttime; + + @ApiModelProperty(name = "sisttime") + private List sisttime; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/CoordsVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/CoordsVO.java new file mode 100644 index 000000000..5f6f87d6c --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/CoordsVO.java @@ -0,0 +1,30 @@ +package com.njcn.event.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 坐标轴 + * @author xxy + * @version 1.0.0 + * @date 2022年08月01日 15:28 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class CoordsVO implements Serializable { + + @ApiModelProperty(name = "x",value = "x轴") + private Integer x; + + @ApiModelProperty(name = "y",value = "y轴") + private Integer y; + + @ApiModelProperty(name = "z",value = "z轴") + private Integer z; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/DISDIPVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/DISDIPVO.java new file mode 100644 index 000000000..971ca6102 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/DISDIPVO.java @@ -0,0 +1,48 @@ +package com.njcn.event.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * DISDIP表格 + * @author xxy + * @version 1.0.0 + * @date 2022年08月01日 15:46 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class DISDIPVO implements Serializable { + + @ApiModelProperty(name = "name",value = "剩余电压/持续时间") + private String name; + + @ApiModelProperty(name = "twentyMs",value = "20ms") + private String twentyMs; + + @ApiModelProperty(name = "oneHundredMs",value = "100ms") + private String oneHundredMs; + + @ApiModelProperty(name = "fiveHundredMs",value = "500ms") + private String fiveHundredMs; + + @ApiModelProperty(name = "oneS",value = "1s") + private String oneS; + + @ApiModelProperty(name = "threeS",value = "3s") + private String threeS; + + @ApiModelProperty(name = "twentyS",value = "20s") + private String twentyS; + + @ApiModelProperty(name = "sixtyS",value = "60s") + private String sixtyS; + + @ApiModelProperty(name = "oneEightyS",value = "180s") + private String oneEightyS; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/DetailVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/DetailVO.java new file mode 100644 index 000000000..3b0ead4db --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/DetailVO.java @@ -0,0 +1,37 @@ +package com.njcn.event.pojo.vo; + +import com.njcn.device.pojo.vo.AreaLineInfoVO; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.checkerframework.checker.units.qual.A; + +import java.io.Serializable; + +/** + * @author xxy + * @version 1.0.0 + * @date 2022年08月02日 16:03 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class DetailVO extends AreaLineInfoVO implements Serializable { + + @ApiModelProperty(name = "persistTime",value = "持续时间") + private Double persistTime; + + @ApiModelProperty(name = "eventType",value = "暂态类型") + private String eventType; + + @ApiModelProperty(name = "eventValue",value = "特征幅值") + private Double eventValue; + + @ApiModelProperty(name = "time",value = "发生时间") + private String timeId; + + @ApiModelProperty(name = "times",value = "次数") + private Integer times; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/EventHeatMapVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/EventHeatMapVO.java index 1a64ce915..04146e7d3 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/EventHeatMapVO.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/EventHeatMapVO.java @@ -15,8 +15,8 @@ import java.util.List; public class EventHeatMapVO implements Serializable { @ApiModelProperty(name = "areaValue",value = "数值") - private List> areaValue; + private List areaValue; @ApiModelProperty(name = "eventHeatMapValue",value = "热力图数值") - private List eventHeatMapValue; + private List> eventHeatMapValue; } diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/GeneralVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/GeneralVO.java new file mode 100644 index 000000000..662be62b8 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/GeneralVO.java @@ -0,0 +1,46 @@ +package com.njcn.event.pojo.vo; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author xxy + * @version 1.0.0 + * @date 2022年08月01日 09:34 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class GeneralVO implements Serializable { + + @Excel(name = "区域") + @ApiModelProperty(name = "name",value = "监测点名称/电压等级") + private String name; + + @Excel(name = "在线") + @ApiModelProperty(name = "onLine",value = "在线数量") + private Integer onLine; + + @Excel(name = "离线") + @ApiModelProperty(name = "offLine",value = "离线数量") + private Integer offLine; + + @Excel(name = "暂降次数") + @ApiModelProperty(name = "sagsCount",value = "暂降次数") + private Integer sagsCount; + + @Excel(name = "中断次数") + @ApiModelProperty(name = "breakCount",value = "中断次数") + private Integer breakCount; + + @Excel(name = "暂升次数") + @ApiModelProperty(name = "upCount",value = "暂升次数") + private Integer upCount; + + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/IEC28VO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/IEC28VO.java new file mode 100644 index 000000000..157978806 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/IEC28VO.java @@ -0,0 +1,47 @@ +package com.njcn.event.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author xxy + * @version 1.0.0 + * @date 2022年08月01日 16:09 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class IEC28VO implements Serializable { + + @ApiModelProperty(name = "name",value = "剩余电压/持续时间") + private String name; + + @ApiModelProperty(name = "q",value = "0.01~0.1s") + private String q; + + @ApiModelProperty(name = "w",value = "0.1~0.25s") + private String w; + + @ApiModelProperty(name = "e",value = "0.25~0.5s") + private String e; + + @ApiModelProperty(name = "r",value = "0.5~1s") + private String r; + + @ApiModelProperty(name = "t",value = "1~3s") + private String t; + + @ApiModelProperty(name = "y",value = "3~20s") + private String y; + + @ApiModelProperty(name = "u",value = "20~60s") + private String u; + + @ApiModelProperty(name = "i",value = "60~180s") + private String i; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/IEC411VO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/IEC411VO.java new file mode 100644 index 000000000..aa74a2a48 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/IEC411VO.java @@ -0,0 +1,42 @@ +package com.njcn.event.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * IEC411 + * @author xxy + * @version 1.0.0 + * @date 2022年08月01日 16:00 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class IEC411VO implements Serializable { + + @ApiModelProperty(name = "name",value = "剩余电压/持续时间") + private String name; + + @ApiModelProperty(name = "tenTwentyMs",value = "10~20ms") + private String tenTwentyMs; + + @ApiModelProperty(name = "twentyOneHundredMs",value = "20~100ms") + private String twentyOneHundredMs; + + @ApiModelProperty(name = "zeroPiontOneTwoS",value = "0.1~0.2s") + private String zeroPiontOneTwoS; + + @ApiModelProperty(name = "zeroPiontTwoFiveS",value = "0.2~0.5s") + private String zeroPiontTwoFiveS; + + @ApiModelProperty(name = "zeroPiontFive1S",value = "0.5~1s") + private String zeroPiontFive1S; + + @ApiModelProperty(name = "greater1S",value = ">1s") + private String greater1S; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/OB.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/OB.java new file mode 100644 index 000000000..9521bb193 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/OB.java @@ -0,0 +1,23 @@ +package com.njcn.event.pojo.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author xxy + * @version 1.0.0 + * @date 2022年08月22日 15:03 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class OB implements Serializable { + + private double a; + + private double b; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/PointVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/PointVO.java new file mode 100644 index 000000000..d13ed04f9 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/PointVO.java @@ -0,0 +1,89 @@ +package com.njcn.event.pojo.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.influxdb.annotation.Column; +import org.influxdb.annotation.Measurement; + +import java.time.Instant; + +/** + * @author xxy + * @version 1.0.0 + * @date 2022年08月08日 10:52 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Measurement(name = "pqs_eventdetail") +public class PointVO { + + @Column(name = "line_id") + private String lineId; + + @Column(name = "time") + private String timeId; + + @Column(name = "event_describe") + private String eventDescribe; + + @Column(name = "wave_type") + private Integer waveType; + + @Column(name = "persist_time") + private Double persistTime; + + @Column(name = "event_value") + private Double eventValue; + + @Column(name = "event_reason") + private String eventReason; + + @Column(name = "event_type") + private String eventType; + + @Column(name = "eventass_index") + private String eventassIndex; + + @Column(name = "dq_time") + private Integer dqTime; + + @Column(name = "deal_time") + private String dealTime; + + @Column(name = "deal_flag") + private Integer dealFlag; + + @Column(name = "num") + private Integer num; + + @Column(name = "file_flag") + private Integer fileFlag; + + @Column(name = "first_time") + private String firstTime; + + @Column(name = "first_type") + private String firstType; + + @Column(name = "first_ms") + private Integer firstMs; + + @Column(name = "wave_name") + private String waveName; + + @Column(name = "energy") + private Double energy; + + @Column(name = "severity") + private Double severity; + + @Column(name = "sagsource") + private String sagSource; + + @Column(name = "create_time") + private String createTime; + + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/ProbabilityVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/ProbabilityVO.java new file mode 100644 index 000000000..ae9ac76de --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/ProbabilityVO.java @@ -0,0 +1,33 @@ +package com.njcn.event.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author xxy + * @version 1.0.0 + * @date 2022年08月03日 15:31 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ProbabilityVO implements Serializable { + + @ApiModelProperty(name = "eventvalue") + private List eventvalue; + + @ApiModelProperty(name = "pereventvalue") + private List pereventvalue; + + @ApiModelProperty(name = "persisttime") + private List persisttime; + + @ApiModelProperty(name = "sisttime") + private List sisttime; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/ReasonsVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/ReasonsVO.java new file mode 100644 index 000000000..c0114b5cc --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/ReasonsVO.java @@ -0,0 +1,32 @@ +package com.njcn.event.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.Objects; + +/** + * @author xxy + * @version 1.0.0 + * @date 2022年08月03日 09:03 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ReasonsVO implements Serializable { + + @ApiModelProperty(name = "reason",value = "原因") + private String reason; + + @ApiModelProperty(name = "times",value = "次数") + private Integer times; + + @ApiModelProperty(name = "rate",value = "占比") + private String rate; + + + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/StatisticVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/StatisticVO.java new file mode 100644 index 000000000..dfed26f12 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/StatisticVO.java @@ -0,0 +1,43 @@ +package com.njcn.event.pojo.vo; + +import com.njcn.event.pojo.po.EventDetail; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author xxy + * @version 1.0.0 + * @date 2022年08月02日 16:01 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class StatisticVO implements Serializable { + + @ApiModelProperty(name = "cityName",value = "城市名称") + private String cityName; + + @ApiModelProperty(name = "detail") + private List detail; + + @ApiModelProperty(name = "f47") + private String f47; + + @ApiModelProperty(name = "itic") + private String itic; + + @ApiModelProperty(name = "reason") + private List reason; + + @ApiModelProperty(name = "totalTimes") + private Integer totalTimes; + + @ApiModelProperty(name = "types") + private List types; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TerminalRunningStatisticsVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TerminalRunningStatisticsVO.java index d3c7bbfd0..2951d8973 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TerminalRunningStatisticsVO.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TerminalRunningStatisticsVO.java @@ -42,22 +42,22 @@ public class TerminalRunningStatisticsVO implements Serializable { @ApiModelProperty("区域名称") private String areaName; - + @ApiModelProperty("终端个数") private Integer numberOfTerminals; - + @ApiModelProperty("投运") private Long normal; @ApiModelProperty("投运率") private Double normalRate; - + @ApiModelProperty("热备用") private Long breaks; @ApiModelProperty("热备用率") private Double breaksRate; - + @ApiModelProperty("停运") private Long shutdown; @@ -75,41 +75,41 @@ public class TerminalRunningStatisticsVO implements Serializable { }; } } - + @Data @Builder public static class TerminalRunningVO implements Serializable { private static final long serialVersionUID = 8990224131248734699L; - + @ApiModelProperty("总计-终端个数") private Integer numberOfTerminals; - + @ApiModelProperty("总计-投运") private Long normal; @ApiModelProperty("总计-投运率") private Double normalRate; - + @ApiModelProperty("总计-热备用") private Long breaks; @ApiModelProperty("总计-热备用率") private Double breaksRate; - + @ApiModelProperty("总计-停运") private Long shutdown; @ApiModelProperty("总计-停运率") private Double shutdownRate; - + @ApiModelProperty("总计-在线率") private Double onlineRate; - + @ApiModelProperty("列表数据") private List areaInfo; - + public static TerminalRunningVO empty() { - return TerminalRunningVO.buildVO(0, 0L, 0.00D, 0L, 0.00D, 0L, 0.00D, 0.00D, Collections.emptyList()); + return TerminalRunningVO.buildVO(0, 0L, 3.14159D, 0L, 3.14159D, 0L, 3.14159D, 3.14159D, Collections.emptyList()); } public static TerminalRunningVO buildVO(Integer numberOfTerminals, Long normal, Double normalRate, Long breaks, Double breaksRate, Long shutdown, Double shutdownRate, Double onlineRate, List areaInfo) { diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TimeSVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TimeSVO.java new file mode 100644 index 000000000..c76402d56 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TimeSVO.java @@ -0,0 +1,25 @@ +package com.njcn.event.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zbj + * @version 1.0.0 + * @date 2022年08月29日 10:45 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class TimeSVO extends TimeVO { + + + @ApiModelProperty(name = "eventAssIndex", value = "关联处理事件时间") + private int eventAssIndex; + + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TimeVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TimeVO.java new file mode 100644 index 000000000..0c54baa0d --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TimeVO.java @@ -0,0 +1,42 @@ +package com.njcn.event.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.checkerframework.checker.units.qual.A; + +import java.io.Serializable; + +/** + * @author xxy + * @version 1.0.0 + * @date 2022年08月02日 10:45 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class TimeVO implements Serializable { + + @ApiModelProperty(name = "amounts") + private String amounts; + + @ApiModelProperty(name = "handledTimes") + private String handledTimes; + + @ApiModelProperty(name = "days",value = "天数") + private String day; + + @ApiModelProperty(name = "month",value = "月份") + private String month; + + @ApiModelProperty(name = "times") + private String times; + + @ApiModelProperty(name = "year",value = "年份") + private String year; + + @ApiModelProperty(name = "fulltime",value = "时间全称") + private String fulltime; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TypesVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TypesVO.java new file mode 100644 index 000000000..983e2ecc4 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TypesVO.java @@ -0,0 +1,27 @@ +package com.njcn.event.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author xxy + * @version 1.0.0 + * @date 2022年08月03日 09:07 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class TypesVO implements Serializable { + + @ApiModelProperty(name = "type",value = "类型") + private String type; + + @ApiModelProperty(name = "times",value = "次数") + private Integer times; + + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/VoltageToleranceCurveVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/VoltageToleranceCurveVO.java index f61f25aae..ec940b40e 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/VoltageToleranceCurveVO.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/VoltageToleranceCurveVO.java @@ -7,6 +7,7 @@ import lombok.Builder; import lombok.Data; import java.io.Serializable; +import java.time.LocalDateTime; import java.util.Collections; import java.util.Comparator; import java.util.List; @@ -22,13 +23,13 @@ import java.util.List; @Builder public class VoltageToleranceCurveVO implements Serializable { private static final long serialVersionUID = -2659670722467310785L; - + @ApiModelProperty(name = "totalNumberOfEvents", value = "事件总数") private Integer totalNumberOfEvents; - + @ApiModelProperty(name = "VoltageToleranceCurveDataList", value = "图表数据") private List voltageToleranceCurveDataList; - + /** * 构建默认对象 * @@ -37,7 +38,7 @@ public class VoltageToleranceCurveVO implements Serializable { public static VoltageToleranceCurveVO empty() { return VoltageToleranceCurveVO.buildVO(0, Collections.emptyList()); } - + /** * 构建默认对象 * @@ -47,37 +48,33 @@ public class VoltageToleranceCurveVO implements Serializable { */ public static VoltageToleranceCurveVO buildVO(int numberEvents, List dataList) { return VoltageToleranceCurveVO.builder().totalNumberOfEvents(numberEvents).voltageToleranceCurveDataList(dataList).build(); - + } - + @Data public static class VoltageToleranceCurveDataList implements Serializable { private static final long serialVersionUID = 2693688079727369565L; - + @ApiModelProperty(name = "lineId", value = "LineId") private String lineId; - + @ApiModelProperty(name = "persistTime", value = "持续时间(ms)") private Double persistTime; - + @ApiModelProperty(name = "eventValue", value = "特征幅值") private Double eventValue; - + @ApiModelProperty(name = "subName", value = "变电站名称") private String subName; - + @ApiModelProperty(name = "gdName", value = "供电公司名称") private String gdName; - + @ApiModelProperty(name = "time", value = "发生时刻") - private String time; - + private LocalDateTime time; + public static Comparator sortAscTime() { - return (o1, o2) -> { - DateTime time1 = DateUtil.parseDateTime(o1.getTime()); - DateTime time2 = DateUtil.parseDateTime(o2.getTime()); - return time1.compareTo(time2); - }; + return Comparator.comparing(VoltageToleranceCurveDataList::getTime); } } } diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/WaveTypeVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/WaveTypeVO.java new file mode 100644 index 000000000..f1609160e --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/WaveTypeVO.java @@ -0,0 +1,194 @@ +package com.njcn.event.pojo.vo; + +import com.njcn.device.pojo.vo.AreaLineInfoVO; +import com.njcn.event.pojo.po.EventDetail; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.influxdb.annotation.Column; +import org.influxdb.annotation.Measurement; + + +import java.math.BigDecimal; +import java.time.Instant; +/** + *获取事件报告 + * @author zbj + * @date 2022/8/1 + */ + +@Data +@Measurement(name = "pqs_eventdetail") +public class WaveTypeVO{ + + + @ApiModelProperty( + name = "lineName", + value = "监测点名称" + ) + private String lineName; + @ApiModelProperty( + name = "subId", + value = "变电站id" + ) + private String subId; + @ApiModelProperty( + name = "subName", + value = "变电站名称" + ) + private String subName; + @ApiModelProperty( + name = "gdId", + value = "供电公司id" + ) + private String gdId; + @ApiModelProperty( + name = "gdName", + value = "供电公司名称" + ) + private String gdName; + @ApiModelProperty( + name = "voltageId", + value = "母线id" + ) + private String voltageId; + @ApiModelProperty( + name = "voltageName", + value = "母线名称" + ) + private String voltageName; + @ApiModelProperty( + name = "voltageScale", + value = "监测点电压等级" + ) + private String voltageScale; + @ApiModelProperty( + name = "noDealCount", + value = "未处理暂降事件" + ) + private Integer noDealCount; + @ApiModelProperty( + name = "ct1", + value = "ct1" + ) + private Integer ct1; + @ApiModelProperty( + name = "ct2", + value = "ct2" + ) + private Integer ct2; + @ApiModelProperty( + name = "pt1", + value = "pt1" + ) + private Integer pt1; + @ApiModelProperty( + name = "pt2", + value = "pt2" + ) + private Integer pt2; + @ApiModelProperty( + name = "runFlag", + value = "运行状态" + ) + private Integer runFlag; + @ApiModelProperty( + name = "comFlag", + value = "通讯状态" + ) + private Integer comFlag; + @ApiModelProperty( + name = "ip", + value = "装置ip" + ) + private String ip; + @ApiModelProperty( + name = "lat", + value = "维度" + ) + private BigDecimal lat; + @ApiModelProperty( + name = "lng", + value = "经度" + ) + private BigDecimal lng; + @ApiModelProperty( + name = "manufacturer", + value = "供应商名称" + ) + private String manufacturer; + @ApiModelProperty( + name = "loadType", + value = "干扰源类型" + ) + private String loadType; + + + @Column(name = "line_id") + private String lineId; + + @Column(name = "time") + private String timeId; + + @Column(name = "event_describe") + private String eventDescribe; + + @Column(name = "wave_type") + private Integer waveType; + + @Column(name = "persist_time") + private Double persistTime; + + @Column(name = "event_value") + private Double eventValue; + + @Column(name = "event_reason") + private String eventReason; + + @Column(name = "event_type") + private String eventType; + + @Column(name = "eventass_index") + private String eventassIndex; + + @Column(name = "dq_time") + private Integer dqTime; + + @Column(name = "deal_time") + private String dealTime; + + @Column(name = "deal_flag") + private Integer dealFlag; + + @Column(name = "num") + private Integer num; + + @Column(name = "file_flag") + private Integer fileFlag; + + @Column(name = "first_time") + private String firstTime; + + @Column(name = "first_type") + private String firstType; + + @Column(name = "first_ms") + private Integer firstMs; + + @Column(name = "wave_name") + private String waveName; + + @Column(name = "energy") + private Double energy; + + @Column(name = "severity") + private Double severity; + + @Column(name = "sagsource") + private String sagSource; + + @Column(name = "create_time") + private String createTime; + + +} diff --git a/pqs-event/event-boot/pom.xml b/pqs-event/event-boot/pom.xml index 64228567a..20fec422b 100644 --- a/pqs-event/event-boot/pom.xml +++ b/pqs-event/event-boot/pom.xml @@ -54,10 +54,41 @@ 1.0.0 compile + + org.freemarker + freemarker + 2.3.28 + + + + com.njcn + common-echarts + 1.0.0 + eventboot + + + org.apache.maven.plugins @@ -70,6 +101,7 @@ org.springframework.boot spring-boot-maven-plugin + 2.2.2.RELEASE package @@ -115,4 +147,4 @@ - \ No newline at end of file + diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/config/EventBaseConfig.java b/pqs-event/event-boot/src/main/java/com/njcn/event/config/EventBaseConfig.java deleted file mode 100644 index ca5c48d0b..000000000 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/config/EventBaseConfig.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.njcn.event.config; - -import lombok.Data; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -/** - * @version 1.0.0 - * @author: chenchao - * @date: 2022/06/30 20:02 - */ -@Data -@Component -public class EventBaseConfig { - - @Value("${business.wavePath}") - private String wavePath; -} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AreaAnalysisController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AreaAnalysisController.java index 5e1b4ad5c..11dd4754a 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AreaAnalysisController.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AreaAnalysisController.java @@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.RestController; @Slf4j @RestController @RequestMapping("/areaAnalysis") -@Api(tags = "区域分析") +@Api(tags = "区域统计") @RequiredArgsConstructor public class AreaAnalysisController extends BaseController { diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AreaController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AreaController.java index 7421efc3f..68dd80caa 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AreaController.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AreaController.java @@ -7,7 +7,6 @@ import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.LogUtil; import com.njcn.device.pojo.param.DeviceInfoParam; -import com.njcn.event.pojo.po.BalanceInfo; import com.njcn.event.pojo.vo.AreaLineVO; import com.njcn.event.pojo.vo.EventHeatMapVO; import com.njcn.event.pojo.vo.EventSeverityVO; @@ -25,8 +24,6 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.List; - /** * @author denghuajun * @version 1.0.0 @@ -109,22 +106,5 @@ public class AreaController extends BaseController { TerminalRunningStatisticsVO result = areaLineService.getTerminalRunningStatistics(deviceInfoParam); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } - - /** - * 获取暂降严重度 - * - * @param deviceInfoParam 参数 - * @return 结果 - */ - @OperateInfo(info = LogEnum.BUSINESS_COMMON) - @PostMapping("/getBalanceInfo") - @ApiOperation("获取区域暂降综合评估") - @ApiImplicitParam(name = "deviceInfoParam", value = "参数", required = true) - public HttpResult> getBalanceInfo(@RequestBody @Validated DeviceInfoParam.BusinessParam deviceInfoParam) { - String methodDescribe = getMethodDescribe("getBalanceInfo"); - LogUtil.njcnDebug(log, "{},参数为:{}", methodDescribe, deviceInfoParam); - List result = areaLineService.getBalanceInfo(deviceInfoParam); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); - } } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/EventDetailController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/EventDetailController.java index 6c0cd77e7..508e9cfb8 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/EventDetailController.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/EventDetailController.java @@ -124,4 +124,5 @@ public class EventDetailController extends BaseController { } + } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/MonitorPointController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/MonitorPointController.java index 6edde2d37..ec2192049 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/MonitorPointController.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/MonitorPointController.java @@ -2,25 +2,27 @@ package com.njcn.event.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.common.pojo.annotation.OperateInfo; +import com.njcn.common.pojo.constant.OperateType; +import com.njcn.common.pojo.dto.wave.WaveDataDTO; import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.HttpResultUtil; -import com.njcn.event.pojo.param.EventBaseParam; +import com.njcn.event.pojo.param.*; import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.pojo.vo.*; import com.njcn.event.service.EventAnalysisService; import com.njcn.web.controller.BaseController; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.*; import lombok.AllArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.text.ParseException; +import java.util.List; /** * pqs-event @@ -38,12 +40,6 @@ public class MonitorPointController extends BaseController { private final EventAnalysisService eventAnalysisService; - /** - * 获取暂降幅值/持续时间分布函数 - * @author cdf - * @date 2022/6/23 - */ - /** @@ -61,4 +57,183 @@ public class MonitorPointController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe); } + /** + * 获取电压暂态表及密度图 + * @author xxy + * @param statisticsParam + * @return + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getCoords") + @ApiOperation("获取电压暂态表及密度坐标图") + @ApiImplicitParam(name = "statisticsParam", value = "电压暂态表及密度图坐标参数", required = true) + public HttpResult> getCoords(@RequestBody @Validated StatisticsParam statisticsParam){ + String methodDescribe = getMethodDescribe("getCoords"); + List list = eventAnalysisService.getCoords(statisticsParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe); + } + + /** + * 获取Disdip表格 + * @param statisticsParam + * @return + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/eventDisdip") + @ApiOperation("获取Disdip表格") + @ApiImplicitParam(name = "statisticsParam", value = "Disdip表格参数", required = true) + public HttpResult> eventDisdip(@RequestBody @Validated StatisticsParam statisticsParam){ + String methodDescribe = getMethodDescribe("eventDisdip"); + List list = eventAnalysisService.eventDisdip(statisticsParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe); + } + + /** + * 获取IEC411数据 + * @param statisticsParam + * @return + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/IEC411") + @ApiOperation("获取IEC411数据") + @ApiImplicitParam(name = "statisticsParam", value = "IEC411参数", required = true) + public HttpResult> IEC411(@RequestBody @Validated StatisticsParam statisticsParam){ + String methodDescribe = getMethodDescribe("IEC411"); + List list = eventAnalysisService.IEC411(statisticsParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe); + } + + /** + * 获取IEC28数据 + * @param statisticsParam + * @return + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/IEC28") + @ApiOperation("获取IEC28数据") + @ApiImplicitParam(name = "statisticsParam", value = "IEC28参数", required = true) + public HttpResult> IEC28(@RequestBody @Validated StatisticsParam statisticsParam){ + String methodDescribe = getMethodDescribe("IEC28"); + List list = eventAnalysisService.IEC28(statisticsParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe); + } + + /** + * 暂降原因类型和时间 + * @author xxy + * @param statisticsParam + * @return + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getReasonTypeTime") + @ApiOperation("暂降原因类型和时间") + @ApiImplicitParam(name = "statisticsParam", value = "暂降原因类型和时间参数", required = true) + public HttpResult> getReasonTypeTime(@RequestBody @Validated StatisticsParam statisticsParam) throws ParseException { + String methodDescribe = getMethodDescribe("getReasonTypeTime"); + List page = eventAnalysisService.getReasonTypeTime(statisticsParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,page,methodDescribe); + } + + /** + * 暂降原因类型和时间分布统计 + * @author xxy + * @param statisticsParam + * @return + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getStatistic") + @ApiOperation("暂降原因类型和时间分布统计") + @ApiImplicitParam(name = "statisticsParam", value = "暂降原因类型和时间分布统计参数", required = true) + public HttpResult getStatistic(@RequestBody @Validated StatisticsParam statisticsParam){ + String methodDescribe = getMethodDescribe("getStatistic"); + StatisticVO page = eventAnalysisService.getStatistic(statisticsParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,page,methodDescribe); + } + + /** + * 暂降幅值的概率分布函数 + * @author xxy + * @param statisticsParam + * @return + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getProbabilityDistribution") + @ApiOperation("暂降幅值的概率分布函数") + @ApiImplicitParam(name = "statisticsParam", value = "暂降幅值的概率分布函数参数", required = true) + public HttpResult getProbabilityDistribution(@RequestBody @Validated StatisticsParam statisticsParam){ + String methodDescribe = getMethodDescribe("getProbabilityDistribution"); + ProbabilityVO page = eventAnalysisService.getProbabilityDistribution(statisticsParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,page,methodDescribe); + } + + /** + * 暂降事件点图 + * @author xxy + * @param statisticsParam + * @return + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getPlot") + @ApiOperation("暂降事件点图") + @ApiImplicitParam(name = "statisticsParam", value = "暂降事件点图参数", required = true) + public HttpResult> getPlot(@RequestBody @Validated StatisticsParam statisticsParam){ + String methodDescribe = getMethodDescribe("getPlot"); + List page = eventAnalysisService.getPlot(statisticsParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,page,methodDescribe); + } + + + + + + /** + *监测点暂降事件分析查询 + * @author zbj + * @date 2022/7/25 + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getMonitorEventAnalyseQuery") + @ApiOperation("监测点暂降事件分析查询") + @ApiImplicitParam(name = "eventBaseParam", value = "暂降事件分析参数", required = true) + public HttpResult> getMonitorEventAnalyseQuery (@RequestBody @Validated EventBaseParam eventBaseParam){ + String methodDescribe = getMethodDescribe("getMonitorEventAnalyseQuery"); + Page result = eventAnalysisService.getMonitorEventAnalyseQuery(eventBaseParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } + + + + /** + *监测点事件波形分析 + * @author zbj + * @date 2022/7/27 + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getMonitorEventAnalyseWave") + @ApiOperation("监测点事件波形分析") + @ApiImplicitParams({ + @ApiImplicitParam(name = "timeId", value = "时间Id", required = true), + @ApiImplicitParam(name = "lineId", value = "监测点Id", required = true) + }) + public HttpResult getMonitorEventAnalyseWave(@RequestParam("timeId") String timeId, @RequestParam("lineId") String lineId){ + String methodDescribe = getMethodDescribe("getMonitorEventAnalyseWave"); + WaveDataDTO wave = eventAnalysisService.getMonitorEventAnalyseWave(timeId, lineId); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, wave, methodDescribe); + } + + /** + *监测点事件波形下载 + * @author zbj + * @date 2022/7/28 + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD) + @PostMapping("/downloadMonitorEventWaveFile") + @ApiOperation("监测点事件波形下载") + @ApiImplicitParam(name = "waveFileParam", value = "波形下载参数", required = true) + public HttpResult downloadMonitorEventWaveFile(@RequestBody @Validated WaveFileParam waveFileParam, HttpServletResponse response) throws Exception { + String methodDescribe = getMethodDescribe("downloadMonitorEventWaveFile"); + HttpServletResponse resp = eventAnalysisService.downloadMonitorEventWaveFile(waveFileParam, response); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, resp, methodDescribe); + } + } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/ReportController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/ReportController.java new file mode 100644 index 000000000..05e3ba182 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/ReportController.java @@ -0,0 +1,218 @@ +package com.njcn.event.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.njcn.common.pojo.annotation.OperateInfo; +import com.njcn.common.pojo.dto.SimpleDTO; +import com.njcn.common.pojo.enums.common.LogEnum; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.common.utils.HttpResultUtil; +import com.njcn.device.api.GeneralDeviceInfoClient; +import com.njcn.device.pojo.param.DeviceInfoParam; +import com.njcn.event.pojo.param.*; +import com.njcn.event.pojo.vo.DetailVO; +import com.njcn.event.pojo.vo.GeneralVO; +import com.njcn.event.pojo.vo.ReasonsVO; +import com.njcn.event.pojo.vo.WaveTypeVO; +import com.njcn.event.service.ReportService; +import com.njcn.poi.util.PoiUtil; +import com.njcn.web.controller.BaseController; +import freemarker.template.TemplateException; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.openxml4j.exceptions.InvalidFormatException; +import org.apache.poi.ss.usermodel.ClientAnchor; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.ss.util.CellRangeAddress; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.awt.*; +import java.io.ByteArrayOutputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.ParseException; +import java.util.*; +import java.util.List; + +/** + * @author xxy + * @version 1.0.0 + * @date 2022年07月28日 11:36 + */ +@Validated +@Slf4j +@Api(tags = "暂态报告") +@RestController +@RequestMapping("/report") +@RequiredArgsConstructor +public class ReportController extends BaseController { + + private final ReportService reportService; + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getGeneralSituation") + @ApiOperation("暂态总体概况(区域)") + @ApiImplicitParam(name = "businessParam", value = "暂态总体概况区域参数", required = true) + public HttpResult> getGeneralSituation(@RequestBody @Validated DeviceInfoParam.BusinessParam businessParam){ + String methodDescribe = getMethodDescribe("getGeneralSituation"); + List page = reportService.getGeneralSituation(businessParam); + 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){ + String methodDescribe = getMethodDescribe("getVoltage"); + List page = reportService.getVoltage(businessParam); + 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){ + String methodDescribe = getMethodDescribe("getSeverity"); + List page = reportService.getSeverity(businessParam); + 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){ + String methodDescribe = getMethodDescribe("getSeverity"); + List page = reportService.getReason(businessParam); + 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){ + String methodDescribe = getMethodDescribe("getContinueTime"); + Page page = reportService.getContinueTime(businessParam); + 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){ + String methodDescribe = getMethodDescribe("getSagTimes"); + Page page = reportService.getSagTimes(waveTypeParam); + 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){ + String methodDescribe = getMethodDescribe("getUpTimes"); + Page page = reportService.getUpTimes(waveTypeParam); + 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){ + String methodDescribe = getMethodDescribe("getBreakTimes"); + Page page = reportService.getBreakTimes(waveTypeParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,page,methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getExport") + @ApiOperation("周报导出") + @ApiImplicitParam(name = "businessParam", value = "周报导出参数", required = true) + public void getExport(@RequestBody @Validated DeviceInfoParam.BusinessParam businessParam, HttpServletResponse response) throws TemplateException, IOException { + reportService.getExport(businessParam,response); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getLineExport") + @ApiOperation("监测点报告导出") + @ApiImplicitParam(name = "exportParam", value = "监测点报告导出参数", required = true) + public void getLineExport(@RequestBody @Validated ExportParam exportParam, HttpServletResponse response) throws IOException, InvalidFormatException, TemplateException, ParseException { +// @RequestParam(name = "lineIndex") String lineIndex,@RequestParam(name = "startTime") String startTime,@RequestParam(name = "endTime") String endTime,@RequestParam("flag")Integer flag +// ExportParam exportParam = new ExportParam(); +// exportParam.setFlag(flag); +// exportParam.setXq(true); +// exportParam.setLb(true); +// exportParam.setMdbg(true); +// exportParam.setMdtx(true); +// exportParam.setSjdF47(true); +// exportParam.setSjdITIC(true); +// exportParam.setGlfbfz(true); +// exportParam.setGlfbsj(true); +// exportParam.setTjbg(true); +// exportParam.setTjtx(true); +// exportParam.setYybg(true); +// exportParam.setYytx(true); +// exportParam.setLxbg(true); +// exportParam.setLxtx(true); +// +// exportParam.setLineName("江苏省->常熟市->常熟森泉印染厂_6600087524->10kV I母_电源总进线1"); +// exportParam.setSearchBeginTime(startTime); +// exportParam.setSearchEndTime(endTime); +// exportParam.setDeptIndex("5699e5916a18a6381e1ac92da5bd2628"); +// exportParam.setMonitorFlag(0); +// exportParam.setLineId(lineIndex); +// exportParam.setStatFlag(false); +// exportParam.setServerName("event-boot"); +// exportParam.setPowerFlag(1); +// SimpleDTO simpleDTO = new SimpleDTO(); +// simpleDTO.setName("电网拓扑"); +// simpleDTO.setSort(0); +// simpleDTO.setCode("Power_Network"); +// exportParam.setStatisticalType(simpleDTO); + reportService.getLineExport(exportParam,response); + } + + /** + *获取事件报告 + * @author zbj + * @date 2022/7/29 + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getEventReport") + @ApiOperation("获取事件报告") + @ApiImplicitParam(name = "deviceInfoParam", value = "参数体", required = true) + public HttpResult> getEventReport(@RequestBody @Validated WaveTypeParam deviceInfoParam) { + String methodDescribe = getMethodDescribe("getEventReport"); + Page res = reportService.getEventReport(deviceInfoParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe); + } + + /** + *获取区域报告 + * @author zbj + * @date 2022/8/4 + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getAreaReport") + @ApiOperation("获取区域报告") + @ApiImplicitParam(name = "areaReportParam", value = "参数体", required = true) + public void getAreaReport(@RequestBody @Validated AreaReportParam areaReportParam, HttpServletResponse response) throws Exception { + reportService.getAreaReport(areaReportParam,response); + + } + + + +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/TransientController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/TransientController.java index f4e56909f..b5a30ba69 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/TransientController.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/TransientController.java @@ -2,6 +2,7 @@ package com.njcn.event.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.common.pojo.annotation.OperateInfo; +import com.njcn.common.pojo.constant.OperateType; import com.njcn.common.pojo.dto.wave.WaveDataDTO; import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum; @@ -9,6 +10,7 @@ import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.HttpResultUtil; import com.njcn.event.pojo.param.TransientParam; import com.njcn.event.pojo.param.WaveFileParam; +import com.njcn.event.pojo.po.EventDetailNew; import com.njcn.event.pojo.vo.TransientVO; import com.njcn.event.service.TransientService; import com.njcn.web.controller.BaseController; @@ -48,6 +50,8 @@ public class TransientController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); } + + //TODO 111 @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/getTransientAnalyseWave") @ApiOperation("暂态事件波形分析") @@ -61,7 +65,7 @@ public class TransientController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, wave, methodDescribe); } - @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD) @PostMapping("/downloadWaveFile") @ApiOperation("暂态波形下载") @ApiImplicitParam(name = "waveFileParam", value = "波形下载参数", required = true) @@ -71,5 +75,14 @@ public class TransientController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, resp, methodDescribe); } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getTransientValue") + @ApiOperation("根据条件查询暂态事件") + @ApiImplicitParam(name = "transientParam", value = "暂态列表参数", required = true) + public HttpResult> getTransientValue(@RequestBody @Validated TransientParam transientParam){ + String methodDescribe = getMethodDescribe("getTransientValue"); + Page list = transientService.getTransientValue(transientParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); + } } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/area/AreaInfoController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/area/AreaInfoController.java index 91ceed511..f8c9fb11c 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/area/AreaInfoController.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/area/AreaInfoController.java @@ -8,6 +8,7 @@ import com.njcn.common.utils.HttpResultUtil; import com.njcn.device.pojo.param.DeviceInfoParam; import com.njcn.device.pojo.vo.TerminalBaseVO; import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.pojo.po.EventDetailNew; import com.njcn.event.pojo.vo.AreaSubLineVO; import com.njcn.event.service.AreaInfoService; import com.njcn.web.controller.BaseController; @@ -17,11 +18,9 @@ import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import javax.validation.constraints.NotBlank; import java.util.List; /** @@ -75,9 +74,26 @@ public class AreaInfoController extends BaseController { @PostMapping("/getNoDealEvents") @ApiOperation("获取区域未处理暂态事件") @ApiImplicitParam(name = "deviceInfoParam", value = "参数体", required = true) - public HttpResult> getNoDealEvents(@RequestBody @Validated DeviceInfoParam.BusinessParam deviceInfoParam) { + public HttpResult> getNoDealEvents(@RequestBody @Validated DeviceInfoParam deviceInfoParam) { String methodDescribe = getMethodDescribe("getNoDealEvents"); - List res = areaInfoService.getNoDealEvents(deviceInfoParam); + List res = areaInfoService.getNoDealEvents(deviceInfoParam); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe); } + + + /** + * 获取监测点下未处理的暂降事件 + * @author cdf + * @date 2022/8/23 + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @GetMapping("/getNoDealEventsByLineId") + @ApiOperation("获取监测点下未处理的暂降事件") + @ApiImplicitParam(name = "id", value = "监测点id", required = true) + public HttpResult> getNoDealEventsByLineId(@RequestParam("id") @NotBlank(message = "监测点id不可为空") String id) { + String methodDescribe = getMethodDescribe("getNoDealEventsByLineId"); + List res = areaInfoService.getNoDealEventsByLineId(id); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe); + } + } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/influxdb/PqsEventDetailQuery.java b/pqs-event/event-boot/src/main/java/com/njcn/event/influxdb/PqsEventDetailQuery.java index f24090e7c..832108304 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/influxdb/PqsEventDetailQuery.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/influxdb/PqsEventDetailQuery.java @@ -35,7 +35,7 @@ public class PqsEventDetailQuery extends QueryBuilder { protected PqsEventDetailQuery(InfluxDbUtils influxDbUtils) { super(influxDbUtils); } - + /** * line_id or条件 * @@ -50,7 +50,7 @@ public class PqsEventDetailQuery extends QueryBuilder { } return lineIdOr; } - + /** * 指定查询数据库和表 * @@ -60,7 +60,7 @@ public class PqsEventDetailQuery extends QueryBuilder { private SelectQueryImpl fromTable(SelectionQueryImpl column) { return column.from(DATABASE, PQS_EVENT_DETAIL); } - + /** * 查询方法 * SELECT在包括一个tag时,必须至少指定一个field @@ -76,7 +76,7 @@ public class PqsEventDetailQuery extends QueryBuilder { QueryResult query = getQueryResult(or, and, selectAppendTable); return toPOJO(query, EventDetail.class); } - + /** * Count方法 * @@ -95,7 +95,18 @@ public class PqsEventDetailQuery extends QueryBuilder { } return eventDetailCounts.get(0).getCount(); } - + + public Integer selectCountUp(List columnNames, List> or, List and) { + SelectionQueryImpl selectAppendColumnNames = countAppendColumnNames(columnNames); + SelectQueryImpl selectAppendTable = fromTable(selectAppendColumnNames); + QueryResult query = getQueryResultUp(or, and, selectAppendTable); + List eventDetailCounts = toPOJO(query, EventDetailCount.class); + if (CollUtil.isEmpty(eventDetailCounts)) { + return 0; + } + return eventDetailCounts.get(0).getCount(); + } + /** * where条件 时间和reason_type * @@ -110,7 +121,7 @@ public class PqsEventDetailQuery extends QueryBuilder { clauses.add(eq(type, reasonId)); return clauses; } - + /** * 统计lineIndex的数据 * @@ -120,7 +131,7 @@ public class PqsEventDetailQuery extends QueryBuilder { public static Function, Long> countLineIndexes(List eventDetailList) { return lineIndexes -> eventDetailList.stream().filter(t -> lineIndexes.contains(t.getLineId())).count(); } - + /** * 统计eventass_index字段非空的个数 * @@ -129,7 +140,7 @@ public class PqsEventDetailQuery extends QueryBuilder { public static Function, Long> countEventassIndexIsNoEmpty() { return eventDetails -> eventDetails.stream().filter(t -> StringUtils.isNotEmpty(t.getEventassIndex())).count(); } - + /** * 时间段内的数据 * @@ -142,5 +153,5 @@ public class PqsEventDetailQuery extends QueryBuilder { return timeId.isAfter(beginTime.toInstant()) && timeId.isBefore(endTime.toInstant()); }).collect(Collectors.toList()); } - + } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/influxdb/QueryBuilder.java b/pqs-event/event-boot/src/main/java/com/njcn/event/influxdb/QueryBuilder.java index 12844dec4..6fddef7a2 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/influxdb/QueryBuilder.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/influxdb/QueryBuilder.java @@ -101,6 +101,23 @@ public abstract class QueryBuilder { return query(selectQuery.getCommand()); } + /** + * 组装sql语句,包括or语句和and语句添加对多个or语句支持 + * + * @param or or条件 + * @param and and条件 + * @return 查询结果 + * @see SelectionQueryImpl + */ + public QueryResult getQueryResultUp(List> or, List and, SelectQueryImpl selectQuery) { + WhereQueryImpl where = selectQuery.where(); + for(List item: or){ + whereAndNested(where, item); + } + appendWhereOther(where, and); + return query(selectQuery.getCommand()); + } + /** * 拼接or条件 * @@ -131,7 +148,7 @@ public abstract class QueryBuilder { } where.tz("Asia/Shanghai"); } - + /** * time and条件 * diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaInfoService.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaInfoService.java index 1cbe7f4c6..34b800f47 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaInfoService.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaInfoService.java @@ -3,6 +3,7 @@ package com.njcn.event.service; import com.njcn.device.pojo.param.DeviceInfoParam; import com.njcn.device.pojo.vo.TerminalBaseVO; import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.pojo.po.EventDetailNew; import com.njcn.event.pojo.vo.AreaSubLineVO; import java.util.List; @@ -35,5 +36,12 @@ public interface AreaInfoService { * @author cdf * @date 2022/6/29 */ - List getNoDealEvents(DeviceInfoParam.BusinessParam deviceInfoParam); + List getNoDealEvents(DeviceInfoParam deviceInfoParam); + + /** + * 获取监测点下未处理的暂降事件 + * @author cdf + * @date 2022/6/29 + */ + List getNoDealEventsByLineId(String id); } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaLineService.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaLineService.java index 5c6a34028..53f70e889 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaLineService.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaLineService.java @@ -2,7 +2,6 @@ package com.njcn.event.service; import com.njcn.device.pojo.param.DeviceInfoParam; -import com.njcn.event.pojo.po.BalanceInfo; import com.njcn.event.pojo.vo.*; import java.util.List; @@ -43,11 +42,4 @@ public interface AreaLineService { */ TerminalRunningStatisticsVO getTerminalRunningStatistics(DeviceInfoParam.BusinessParam deviceInfoParam); - /** - * 获取区域暂降综合评估 - * @param deviceInfoParam 参数 - * @return 结果 - */ - List getBalanceInfo(DeviceInfoParam.BusinessParam deviceInfoParam); - } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/EventAnalysisService.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/EventAnalysisService.java index 8dd3e2b13..5af05f56e 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/EventAnalysisService.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/EventAnalysisService.java @@ -1,8 +1,14 @@ package com.njcn.event.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.njcn.event.pojo.param.EventBaseParam; +import com.njcn.common.pojo.dto.wave.WaveDataDTO; +import com.njcn.event.pojo.param.*; import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.pojo.vo.*; + +import javax.servlet.http.HttpServletResponse; +import java.text.ParseException; +import java.util.List; /** * pqs-event @@ -18,4 +24,78 @@ public interface EventAnalysisService { * @date 2022/6/23 */ Page getEventAnalyse(EventBaseParam eventBaseParam); + + /** + * 获取坐标 + * @param statisticsParam + * @return + */ + List getCoords(StatisticsParam statisticsParam); + + /** + *获取Disdip表格 + * @param statisticsParam + * @return + */ + List eventDisdip(StatisticsParam statisticsParam); + + /** + * 获取IEC411数据 + * @param statisticsParam + * @return + */ + List IEC411(StatisticsParam statisticsParam); + + /** + * 获取IEC28数据 + * @param statisticsParam + * @return + */ + List IEC28(StatisticsParam statisticsParam); + + /** + * 获取时间列表 + * @param statisticsParam + * @return + */ + List getReasonTypeTime(StatisticsParam statisticsParam) throws ParseException; + + /** + * 获取详细数据对象 + * @param statisticsParam + * @return + */ + StatisticVO getStatistic(StatisticsParam statisticsParam); + + ProbabilityVO getProbabilityDistribution(StatisticsParam statisticsParam); + /** + * 获取点状表格数据 + * @param statisticsParam + * @return + */ + List getPlot(StatisticsParam statisticsParam); + + /** + *监测点暂降事件分析查询 + * @author zbj + * @date 2022/7/25 + */ + Page getMonitorEventAnalyseQuery(EventBaseParam eventBaseParam); + + /** + *监测点事件波形分析 + * @author zbj + * @date 2022/7/27 + */ + WaveDataDTO getMonitorEventAnalyseWave(String timeId, String lineId); + + /** + *监测点事件波形下载 + * @author zbj + * @date 2022/7/28 + */ + HttpServletResponse downloadMonitorEventWaveFile(WaveFileParam waveFileParam, HttpServletResponse response) throws Exception; + + + } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaAnalysisServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaAnalysisServiceImpl.java index 468b34948..74c6f01fd 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaAnalysisServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaAnalysisServiceImpl.java @@ -15,9 +15,14 @@ import com.njcn.event.service.AreaAnalysisService; import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.enums.DicDataTypeEnum; import com.njcn.system.pojo.po.DictData; +import io.swagger.models.auth.In; import lombok.RequiredArgsConstructor; +import org.checkerframework.checker.units.qual.A; +import org.influxdb.querybuilder.clauses.Clause; import org.springframework.stereotype.Service; +import java.time.LocalDateTime; +import java.time.ZoneId; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -25,6 +30,7 @@ import java.util.stream.Collectors; import static com.njcn.event.influxdb.PqsEventDetailQuery.lineIdOr; import static com.njcn.event.influxdb.PqsEventDetailQuery.timeAndType; import static com.njcn.event.influxdb.QueryBuilder.*; +import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq; /** * pqs-event @@ -36,12 +42,12 @@ import static com.njcn.event.influxdb.QueryBuilder.*; @RequiredArgsConstructor public class AreaAnalysisServiceImpl implements AreaAnalysisService { private final GeneralDeviceInfoClient generalDeviceInfoClient; - + private final DicDataFeignClient dicDataFeignClient; - + private final LineFeignClient lineFeignClient; private final PqsEventDetailQuery pqsEventDetailQuery; - + @Override public AreaAnalysisVO getEventReason(DeviceInfoParam.BusinessParam deviceInfoParam) { AreaAnalysisVO areaAnalysisVO = new AreaAnalysisVO(); @@ -50,14 +56,31 @@ public class AreaAnalysisServiceImpl implements AreaAnalysisService { // 获取指定部门下的监测点集合 List generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData(); List lineIds = getAllLineIdList(generalDeviceDTOList); - + List reasonList = assData(dicReasonList, lineIds, deviceInfoParam.getSearchBeginTime(), deviceInfoParam.getSearchEndTime(), "event_reason"); - List typeList = assData(dicTypeList, lineIds, deviceInfoParam.getSearchBeginTime(), deviceInfoParam.getSearchEndTime(), "event_type"); + + //暂降类型特殊处理 + DictData dictData = dicReasonList.stream().filter(item->"短路故障".equals(item.getName())).findFirst().get(); + + List dicIdsXi = dicTypeList.stream().filter(item->item.getName().contains("相间")).map(DictData::getId).collect(Collectors.toList()); + List dicIdsOne = dicTypeList.stream().filter(item->"A相".equals(item.getName())||"B相".equals(item.getName())||"C相".equals(item.getName())).map(DictData::getId).collect(Collectors.toList()); + List dicIdsThree = dicTypeList.stream().filter(item->item.getName().contains("三相接地")).map(DictData::getId).collect(Collectors.toList()); + List dicIdsOther = dicTypeList.stream().filter(item->item.getName().contains("其他")).map(DictData::getId).collect(Collectors.toList()); + List dicIdsDouble = dicTypeList.stream().filter(item->item.getName().contains("双相接地")).map(DictData::getId).collect(Collectors.toList()); + Map> stringListMap = new HashMap<>(); + stringListMap.put("单相接地",dicIdsOne); + stringListMap.put("双相接地",dicIdsDouble); + stringListMap.put("三相短路",dicIdsThree); + stringListMap.put("相间故障",dicIdsXi); + stringListMap.put("未知",dicIdsOther); + + List typeList = assReason(stringListMap,lineIds,deviceInfoParam.getSearchBeginTime(), deviceInfoParam.getSearchEndTime(),dictData.getId()); + areaAnalysisVO.setReason(reasonList); areaAnalysisVO.setType(typeList); return areaAnalysisVO; } - + /** * 获取电压容忍度曲线兼容性统计 * @@ -71,47 +94,47 @@ public class AreaAnalysisServiceImpl implements AreaAnalysisService { if (CollUtil.isEmpty(generalDeviceDTOList)) { return VoltageToleranceCurveVO.empty(); } - + List lineIds = getAllLineIdList(generalDeviceDTOList); if (CollUtil.isEmpty(lineIds)) { return VoltageToleranceCurveVO.empty(); } - + List getBaseLineAreaInfo = lineFeignClient.getBaseLineAreaInfo(lineIds).getData(); if (CollUtil.isEmpty(getBaseLineAreaInfo)) { return VoltageToleranceCurveVO.empty(); } - + Map areaLineInfoVOMap = getBaseLineAreaInfo.parallelStream().collect(Collectors.toConcurrentMap(AreaLineInfoVO::getLineId, Function.identity())); - - List eventDetailList = pqsEventDetailQuery.selectList(Arrays.asList("line_id", "persist_time", "event_value", "create_time"), + + List eventDetailList = pqsEventDetailQuery.selectList(Arrays.asList("time","line_id", "persist_time", "event_value"), lineIdOr(lineIds), timeAnd(beginOfDay(deviceInfoParam.getSearchBeginTime()), endOfDay(deviceInfoParam.getSearchEndTime()))); if (CollUtil.isEmpty(eventDetailList)) { return VoltageToleranceCurveVO.empty(); } - + List curveDataList = eventDetailList.parallelStream() .map(dto -> { AreaLineInfoVO info = areaLineInfoVOMap.get(dto.getLineId()); - + VoltageToleranceCurveDataList voltageToleranceCurve = new VoltageToleranceCurveDataList(); voltageToleranceCurve.setLineId(dto.getLineId()); voltageToleranceCurve.setPersistTime(dto.getPersistTime()); voltageToleranceCurve.setEventValue(dto.getEventValue()); - voltageToleranceCurve.setTime(dto.getCreateTime()); + voltageToleranceCurve.setTime(LocalDateTime.ofInstant(dto.getTimeId(), ZoneId.systemDefault())); voltageToleranceCurve.setGdName(info.getGdName()); voltageToleranceCurve.setSubName(info.getSubName()); return voltageToleranceCurve; }) - .sorted(VoltageToleranceCurveDataList.sortAscTime()) + //.sorted(VoltageToleranceCurveDataList.sortAscTime()) .collect(Collectors.toCollection(() -> Collections.synchronizedList(new ArrayList<>()))); - + return VoltageToleranceCurveVO.buildVO(eventDetailList.size(), curveDataList); } - + /** * 获取全部的LineID * @@ -121,8 +144,8 @@ public class AreaAnalysisServiceImpl implements AreaAnalysisService { private List getAllLineIdList(List generalDeviceDTOList) { return generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList()); } - - + + private List assData(List dicList, List lineIds, String startTime, String endTime, String type) { List reasonList = new ArrayList<>(); Integer allCount = 0; @@ -131,7 +154,7 @@ public class AreaAnalysisServiceImpl implements AreaAnalysisService { Integer count = pqsEventDetailQuery.selectCount(Collections.singletonList(type), lineIdOr(lineIds), timeAndType(beginOfDay(startTime), endOfDay(endTime), type, reason.getId())); - + AreaAnalysisVO.Children children = new AreaAnalysisVO.Children(); children.setName(reason.getName()); children.setValue(count); @@ -144,4 +167,36 @@ public class AreaAnalysisServiceImpl implements AreaAnalysisService { reasonList.add(allType); return reasonList; } + + private List assReason(Map> stringListMap, List lineIds, String startTime, String endTime, String typeId){ + List reasonList = new ArrayList<>(); + Integer allCount = 0; + for (Map.Entry> stringListEntry : stringListMap.entrySet()) { + // 暂降原因类型次数 + List> clauseList = new ArrayList<>(); + List clauses = new ArrayList<>(); + for (String id : stringListEntry.getValue()) { + clauses.add(eq("event_reason", id)); + } + clauseList.add(lineIdOr(lineIds)); + clauseList.add(clauses); + + Integer count = pqsEventDetailQuery.selectCountUp(Collections.singletonList("event_type"), clauseList + , timeAndType(beginOfDay(startTime), + endOfDay(endTime), "event_reason", typeId)); + + AreaAnalysisVO.Children children = new AreaAnalysisVO.Children(); + children.setName(stringListEntry.getKey()); + children.setValue(count); + allCount += count; + reasonList.add(children); + + } + + AreaAnalysisVO.Children allType = new AreaAnalysisVO.Children(); + allType.setName("总计"); + allType.setValue(allCount); + reasonList.add(allType); + return reasonList; + } } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaInfoServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaInfoServiceImpl.java index 17929147d..109be5c7d 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaInfoServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaInfoServiceImpl.java @@ -11,10 +11,14 @@ import com.njcn.device.pojo.vo.AreaLineInfoVO; import com.njcn.device.pojo.vo.TerminalBaseVO; import com.njcn.event.pojo.constant.Param; import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.pojo.po.EventDetailNew; +import com.njcn.event.pojo.vo.AreaLineVO; import com.njcn.event.pojo.vo.AreaSubLineVO; import com.njcn.event.service.AreaInfoService; import com.njcn.event.utils.CommUtil; +import com.njcn.influxdb.mapper.InfluxDBResultMapperCn; import com.njcn.influxdb.param.InfluxDBPublicParam; +import com.njcn.influxdb.utils.InfluxDBCommUtils; import com.njcn.influxdb.utils.InfluxDbUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -26,6 +30,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * pqs-event @@ -56,21 +61,24 @@ public class AreaInfoServiceImpl implements AreaInfoService { if (CollectionUtil.isNotEmpty(lineIds)) { List resList = lineFeignClient.getBaseLineAreaInfo(lineIds).getData(); //查询监测点未处理暂态事件 - StringBuilder lineIdsStr = CommUtil.assToInfluxParam(lineIds); + StringBuilder lineIdsStr = InfluxDBCommUtils.assToInfluxParam(lineIds); String stringResult = "SELECT count(eventass_index) FROM " + Param.EVENT_DETAIL + Param.WHERE + "time >= '" + deviceInfoParam.getSearchBeginTime() + InfluxDBPublicParam.START_TIME + "' and " + "time <= '" + deviceInfoParam.getSearchEndTime() + InfluxDBPublicParam.END_TIME + "' and " + lineIdsStr + " and eventass_index = '' group by line_id" + InfluxDBPublicParam.TIME_ZONE; // 结果集 QueryResult result = influxDbUtils.query(stringResult); if (!result.hasError()) { List list = result.getResults().get(0).getSeries(); + for (AreaLineInfoVO areaLineInfoVO : resList) { boolean flag = false; - for (QueryResult.Series tem : list) { - String lineId = tem.getTags().get("line_id"); - if (areaLineInfoVO.getLineId().equals(lineId)) { - areaLineInfoVO.setNoDealCount(Double.valueOf(tem.getValues().get(0).get(1).toString()).intValue()); - flag = true; - break; + if(CollectionUtil.isNotEmpty(list)) { + for (QueryResult.Series tem : list) { + String lineId = tem.getTags().get("line_id"); + if (areaLineInfoVO.getLineId().equals(lineId)) { + areaLineInfoVO.setNoDealCount(Double.valueOf(tem.getValues().get(0).get(1).toString()).intValue()); + flag = true; + break; + } } } if (!flag) { @@ -107,28 +115,30 @@ public class AreaInfoServiceImpl implements AreaInfoService { } @Override - public List getNoDealEvents(DeviceInfoParam.BusinessParam deviceInfoParam) { - List resList = new ArrayList<>(); + public List getNoDealEvents(DeviceInfoParam deviceInfoParam) { + List resList = new ArrayList<>(); List generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData(); List lineIds = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList()); if (CollectionUtil.isNotEmpty(lineIds)) { - List lineList = lineFeignClient.getBaseLineList(lineIds).getData(); + List lineList = lineFeignClient.getBaseLineAreaInfo(lineIds).getData(); //查询监测点未处理暂态事件 - StringBuilder lineIdsStr = CommUtil.assToInfluxParam(lineIds); + StringBuilder lineIdsStr = InfluxDBCommUtils.assToInfluxParam(lineIds); - String stringResult = "SELECT * FROM " + Param.EVENT_DETAIL + Param.WHERE + "time >= '" + deviceInfoParam.getSearchBeginTime() + Param.BEGIN + "' and " + "time <= '" + deviceInfoParam.getSearchEndTime() + Param.END + "' and " + lineIdsStr + "and eventass_index = '' " + InfluxDBPublicParam.TIME_ZONE; + String stringResult = "SELECT * FROM " + Param.EVENT_DETAIL + Param.WHERE + lineIdsStr + "and eventass_index = '' order by time desc limit 100" + InfluxDBPublicParam.TIME_ZONE; // 结果集 QueryResult result = influxDbUtils.query(stringResult); // 结果集映射到对象中 - InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); - resList = influxDBResultMapper.toPOJO(result, EventDetail.class); + InfluxDBResultMapperCn influxDBResultMapper = new InfluxDBResultMapperCn(); + resList = influxDBResultMapper.toPOJO(result, EventDetailNew.class); //对未处理暂降事件的监测点替换成中文名称 if (CollectionUtil.isNotEmpty(resList)) { - for (EventDetail eventDetail : resList) { - for (Line tem : lineList) { - if (eventDetail.getLineId().equals(tem.getId())) { - eventDetail.setLineId(tem.getName()); + for (EventDetailNew eventDetail : resList) { + for (AreaLineInfoVO tem : lineList) { + if (eventDetail.getLineId().equals(tem.getLineId())) { + eventDetail.setLineName(tem.getLineName()); + eventDetail.setLng(tem.getLng()); + eventDetail.setLat(tem.getLat()); break; } } @@ -138,5 +148,26 @@ public class AreaInfoServiceImpl implements AreaInfoService { return resList; } + @Override + public List getNoDealEventsByLineId(String id) { + + String stringResult = "SELECT * FROM " + Param.EVENT_DETAIL + Param.WHERE + "line_id = '"+id+"' and eventass_index = '' order by time desc limit 100" + InfluxDBPublicParam.TIME_ZONE; + // 结果集 + QueryResult result = influxDbUtils.query(stringResult); + // 结果集映射到对象中 + InfluxDBResultMapperCn influxDBResultMapper = new InfluxDBResultMapperCn(); + List resList = influxDBResultMapper.toPOJO(result, EventDetailNew.class); + + List lineList = lineFeignClient.getBaseLineAreaInfo(Stream.of(id).collect(Collectors.toList())).getData(); + if(CollectionUtil.isNotEmpty(lineList)){ + resList = resList.stream().peek(item->{ + item.setGdName(lineList.get(0).getGdName()); + item.setSubName(lineList.get(0).getSubName()); + item.setLineName(lineList.get(0).getLineName()); + }).collect(Collectors.toList()); + } + return resList; + } + } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaLineServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaLineServiceImpl.java index 89b312cd2..8b18efa10 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaLineServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaLineServiceImpl.java @@ -3,23 +3,24 @@ package com.njcn.event.service.Impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ArrayUtil; import com.njcn.common.pojo.enums.common.ServerEnum; import com.njcn.device.api.GeneralDeviceInfoClient; import com.njcn.device.api.LineFeignClient; import com.njcn.device.pojo.dto.GeneralDeviceDTO; import com.njcn.device.pojo.param.DeviceInfoParam; -import com.njcn.device.pojo.vo.LineDetailDataVO; +import com.njcn.device.pojo.vo.AreaLineInfoVO; import com.njcn.device.pojo.vo.LineDetailVO; import com.njcn.device.pojo.vo.LineDeviceStateVO; import com.njcn.device.pojo.vo.SubstationDetailVO; import com.njcn.event.influxdb.PqsOnlinerateQuery; import com.njcn.event.mapper.PqDeviceMapper; -import com.njcn.event.pojo.po.*; +import com.njcn.event.pojo.po.PqDevice; +import com.njcn.event.pojo.po.PqsOnlinerate; import com.njcn.event.pojo.vo.*; import com.njcn.event.pojo.vo.TerminalRunningStatisticsVO.TerminalRunningInfoVO; import com.njcn.event.pojo.vo.TerminalRunningStatisticsVO.TerminalRunningVO; import com.njcn.event.service.AreaLineService; -import com.njcn.event.service.EventDetailService; import com.njcn.influxdb.param.InfluxDBPublicParam; import com.njcn.influxdb.utils.InfluxDbUtils; import com.njcn.system.pojo.enums.StatisticsEnum; @@ -39,8 +40,6 @@ import java.util.stream.Collectors; import static com.njcn.event.influxdb.PqsOnlinerateQuery.devIdOr; import static com.njcn.event.influxdb.QueryBuilder.*; -import com.njcn.event.pojo.po.BalanceInfo.PointInfo; - /** * @author denghuajun * @version 1.0.0 @@ -61,8 +60,6 @@ public class AreaLineServiceImpl implements AreaLineService { private final PqDeviceMapper pqDeviceMapper; - private final EventDetailService eventDetailService; - @Override public AreaLineVO getAreaLineVO(DeviceInfoParam deviceInfoParam) { AreaLineVO areaLineVO = new AreaLineVO(); @@ -154,15 +151,14 @@ public class AreaLineServiceImpl implements AreaLineService { @Override public EventHeatMapVO getEventHeatMap(DeviceInfoParam.BusinessParam deviceInfoParam) { EventHeatMapVO eventHeatMapVO = new EventHeatMapVO(); - List eventHeatMapDetailList = new ArrayList<>(); + List> eventHeatMapDetailList = new ArrayList<>(); deviceInfoParam.setServerName(ServerEnum.EVENT.getName()); - List> listObject = new ArrayList<>(); + List listObject = new ArrayList<>(); // 获取暂降监测点 List generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData(); List lineIndexs; int i = 0, generalDeviceListSize = generalDeviceDTOList.size(); while (i < generalDeviceListSize) { - List objectList = new ArrayList<>(); GeneralDeviceDTO generalDeviceDTO = generalDeviceDTOList.get(i); lineIndexs = generalDeviceDTO.getLineIndexes(); // 获取暂降数据 @@ -170,18 +166,33 @@ public class AreaLineServiceImpl implements AreaLineService { int tail = 0; List eventdetailList = getContion(deviceInfoParam, lineIndexs); if (eventdetailList.size() > 0) { - for (int eventNum = 0; eventNum < eventdetailList.size(); eventNum++) { - EventHeatMapDetailVO eventHeatMapDetailVO = new EventHeatMapDetailVO(); - LineDetailVO lineDetailVO = lineFeignClient.getLineSubGdDetail(eventdetailList.get(eventNum).getLineId()).getData(); - BeanUtil.copyProperties(lineDetailVO, eventHeatMapDetailVO); - eventHeatMapDetailVO.setEventNum(eventdetailList.get(eventNum).getCount()); - tail += eventdetailList.get(eventNum).getCount(); - eventHeatMapDetailList.add(eventHeatMapDetailVO); + List lineIds = eventdetailList.stream().map(EventHeatDeatilVO::getLineId).collect(Collectors.toList()); + List areaAnalysisVOList = lineFeignClient.getBaseLineAreaInfo(lineIds).getData(); + + for (EventHeatDeatilVO eventHeat : eventdetailList) { + for(AreaLineInfoVO areaLineInfoVO : areaAnalysisVOList){ + if(eventHeat.getLineId().equals(areaLineInfoVO.getLineId())){ + List ev = new ArrayList<>(); + tail += eventHeat.getCount(); + ev.add(areaLineInfoVO.getLng()); + ev.add(areaLineInfoVO.getLat()); + ev.add(tail); + eventHeatMapDetailList.add(ev); + + break; + } + } } - objectList.add(generalDeviceDTO.getName() + "\n(" + lineIndexs.size() + ")"); - objectList.add(tail); - listObject.add(objectList); + BaseVO baseVO = new BaseVO(); + baseVO.setName(generalDeviceDTO.getName()); + baseVO.setValue(BigDecimal.valueOf(lineIndexs.size())); + listObject.add(baseVO); } + } else { + BaseVO baseVO = new BaseVO(); + baseVO.setName(generalDeviceDTO.getName()); + baseVO.setValue(BigDecimal.valueOf(3.141592)); + listObject.add(baseVO); } i++; } @@ -247,62 +258,17 @@ public class AreaLineServiceImpl implements AreaLineService { return TerminalRunningStatisticsVO.buildVO(area, factory); } - @Override - public List getBalanceInfo(DeviceInfoParam.BusinessParam deviceInfoParam) { - List balanceInfos = new ArrayList<>(); - //获取符合条件的监测点 - List generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData(); - if (CollUtil.isEmpty(generalDeviceDTOList)) { - return balanceInfos; - } - for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) { - BalanceInfo balanceInfo = new BalanceInfo(); - balanceInfo.setAreaName(generalDeviceDTO.getName()); - balanceInfo.setAreaIndex(generalDeviceDTO.getIndex()); - //监测点 - List lineList = generalDeviceDTO.getLineIndexes(); - List list = new ArrayList<>(); - for (String lineIndex : lineList) { - PointInfo pointInfo = balanceInfo.new PointInfo(); - Float value = getSarfiValue(deviceInfoParam.getSearchBeginTime(), deviceInfoParam.getSearchEndTime(), 0.9f, lineIndex); - pointInfo.getQtIdx().r_esm = (value == null ? 0f : value); - pointInfo.getQtIdx().sarfi_90 = getSarfiCount(deviceInfoParam.getSearchBeginTime(), deviceInfoParam.getSearchEndTime(), 0.9f, lineIndex); // 统计小于0.9的总数 - pointInfo.getQtIdx().sarifi_50 = getSarfiCount(deviceInfoParam.getSearchBeginTime(), deviceInfoParam.getSearchEndTime(), 0.5f, lineIndex); // 统计小于0.9的总数 // 统计小于0.5的总数 - //获取当前监测点的暂降信息 - List eventDetailList = getEventDetailInfo(lineIndex, 0.9f, deviceInfoParam.getSearchBeginTime(), deviceInfoParam.getSearchEndTime()); - if(eventDetailList.size()>0) { - //获取监测点信息 - LineDetailDataVO lineDetailVO = lineFeignClient.getLineDetailData(lineIndex).getData(); - List sarifis = new ArrayList<>(); - for (EventDetail eventDetail:eventDetailList){ - Sarifi sarifi = new Sarifi(); - sarifi.setTime(eventDetail.getPersistTime().floatValue()); - - } - } - - } - } - return balanceInfos; - } - private TerminalRunningVO analyzeTerminalRun(DeviceInfoParam.BusinessParam deviceInfoParam) { List generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData(); - - if (CollUtil.isEmpty(generalDeviceDTOList)) { - return TerminalRunningVO.empty(); - } - List deviceIndexList = - generalDeviceDTOList.stream().flatMap(dto -> dto.getDeviceIndexes().stream()).collect(Collectors.toList()); + List deviceIndexList = generalDeviceDTOList.stream().flatMap(dto -> dto.getDeviceIndexes().stream()).collect(Collectors.toList()); if (CollUtil.isEmpty(deviceIndexList)) { return TerminalRunningVO.empty(); } - List pqsOnlinerateList = - pqsOnlinerateQuery.selectList(Arrays.asList("dev_id", "offlinemin", "onlinemin"), - devIdOr(deviceIndexList), - timeAnd(beginOfDay(deviceInfoParam.getSearchBeginTime()), endOfDay(deviceInfoParam.getSearchEndTime()))); + List pqsOnlinerateList = pqsOnlinerateQuery.selectList(Arrays.asList("dev_id", "offlinemin", "onlinemin"), + devIdOr(deviceIndexList), + timeAnd(beginOfDay(deviceInfoParam.getSearchBeginTime()), endOfDay(deviceInfoParam.getSearchEndTime()))); List pqDeviceList = pqDeviceMapper.queryRunFlagByDeviceIndexs(deviceIndexList); @@ -316,9 +282,9 @@ public class AreaLineServiceImpl implements AreaLineService { terminalRunningInfoVO.setBreaks(countDeviceRunStatus(pqDeviceList).apply(1, deviceIndexes)); terminalRunningInfoVO.setShutdown(countDeviceRunStatus(pqDeviceList).apply(2, deviceIndexes)); if (deviceIndexes.size() == 0) { - terminalRunningInfoVO.setNormalRate(0.0); - terminalRunningInfoVO.setBreaksRate(0.0); - terminalRunningInfoVO.setShutdownRate(0.0); + terminalRunningInfoVO.setNormalRate(3.14159); + terminalRunningInfoVO.setBreaksRate(3.14159); + terminalRunningInfoVO.setShutdownRate(3.14159); } else { double normalRate = terminalRunningInfoVO.getNormal().doubleValue() / terminalRunningInfoVO.getNumberOfTerminals() * 100; terminalRunningInfoVO.setNormalRate(new BigDecimal(normalRate).setScale(2, RoundingMode.HALF_UP).doubleValue()); @@ -340,7 +306,7 @@ public class AreaLineServiceImpl implements AreaLineService { .sum(); Long shutdownSum = terminalRun.stream().mapToLong(TerminalRunningInfoVO::getShutdown) .sum(); - Double normalRateSum = 0.0, breaksRateSum = 0.0, shutdownRateSum = 0.0; + Double normalRateSum = 3.14159, breaksRateSum = 3.14159, shutdownRateSum = 3.14159; if (terminalSum != 0) { normalRateSum = new BigDecimal(normalSum.doubleValue() / terminalSum * 100).setScale(2, RoundingMode.HALF_UP).doubleValue(); breaksRateSum = new BigDecimal(breaksSum.doubleValue() / terminalSum * 100).setScale(2, RoundingMode.HALF_UP).doubleValue(); @@ -370,7 +336,7 @@ public class AreaLineServiceImpl implements AreaLineService { BigDecimal b2 = new BigDecimal(offlineSum); BigDecimal c = new BigDecimal(100); if (b1.compareTo(BigDecimal.ZERO) == 0) { - return 0.00D; + return 3.14159D; } return b1.divide(b1.add(b2), 4, RoundingMode.HALF_UP).multiply(c).doubleValue(); }; @@ -403,7 +369,7 @@ public class AreaLineServiceImpl implements AreaLineService { } j++; } - stringBuilder.append(" group by line_id"); + stringBuilder.append(" group by line_id").append(InfluxDBPublicParam.TIME_ZONE); // 获取暂降事件 String sql = "select count(file_flag) from pqs_eventdetail where " + stringBuilder.toString(); QueryResult result = influxDbUtils.query(sql); @@ -411,69 +377,4 @@ public class AreaLineServiceImpl implements AreaLineService { List eventdetailList = influxDBResultMapper.toPOJO(result, EventHeatDeatilVO.class); return eventdetailList; } - - public Float getSarfiValue(String startTime, String endTime, Float fvalue, String id) { - Float retList = 0f; - //组装sql语句 - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(startTime))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(endTime))).append("' and "); - stringBuilder.append("line_id = '").append(id).append("'").append(" and event_value <=").append(fvalue).append(InfluxDBPublicParam.TIME_ZONE); - String sql = "select mean(event_value) from " + InfluxDBPublicParam.PQS_EVENT_DETAIL + " where " + stringBuilder.toString(); - QueryResult queryResult = influxDbUtils.query(sql); - List results = queryResult.getResults(); - if (results == null || results.isEmpty()) { - return retList; - } - QueryResult.Result result = results.get(0); - List seriess = result.getSeries(); - if (seriess == null || seriess.isEmpty()) { - return retList; - } - QueryResult.Series series = seriess.get(0); - List> values = series.getValues(); - for (List columnValue : values) { - retList = BigDecimal.valueOf(Float.parseFloat(columnValue.get(1).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue(); - } - return retList; - } - - public Integer getSarfiCount(String startTime, String endTime, Float fvalue, String id) { - Integer retList = 0; - //组装sql语句 - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(startTime))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(endTime))).append("' and "); - stringBuilder.append("line_id = '").append(id).append("'").append(" and event_value <=").append(fvalue).append(" and persist_time<6000").append(InfluxDBPublicParam.TIME_ZONE); - String sql = "select count(*) from " + InfluxDBPublicParam.PQS_EVENT_DETAIL + " where " + stringBuilder.toString(); - QueryResult queryResult = influxDbUtils.query(sql); - List results = queryResult.getResults(); - if (results == null || results.isEmpty()) { - return retList; - } - QueryResult.Result result = results.get(0); - List seriess = result.getSeries(); - if (seriess == null || seriess.isEmpty()) { - return retList; - } - QueryResult.Series series = seriess.get(0); - List> values = series.getValues(); - for (List columnValue : values) { - retList = (Integer) columnValue.get(1); - } - return retList; - } - - public List getEventDetailInfo(String id, Float fvalue, String startTime, String endTime) { - //组装sql语句 - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(startTime))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(endTime))).append("' and "); - //sql语句 - stringBuilder.append("line_id ='").append(id).append("'").append(" and event_value <=").append(fvalue).append(" and persist_time < 60000").append(" tz('Asia/Shanghai')"); - - String sql = "select * from pqs_eventdetail where " + stringBuilder; - //获取暂降事件 - QueryResult result = influxDbUtils.query(sql); - InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); - List eventDetailList = influxDBResultMapper.toPOJO(result, EventDetail.class); - return eventDetailList; - } } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaStatisticalServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaStatisticalServiceImpl.java index 17020ecdc..8ea4c2cca 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaStatisticalServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaStatisticalServiceImpl.java @@ -20,6 +20,7 @@ import com.njcn.event.pojo.vo.VoltageLevelCalculationVO; import com.njcn.event.service.AreaStatisticalService; import com.njcn.system.pojo.enums.StatisticsEnum; import lombok.RequiredArgsConstructor; +import org.influxdb.querybuilder.clauses.Clause; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -30,6 +31,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import static com.njcn.event.influxdb.PqsEventDetailQuery.*; +import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.ne; /** * 区域统计 @@ -42,9 +44,9 @@ import static com.njcn.event.influxdb.PqsEventDetailQuery.*; @RequiredArgsConstructor public class AreaStatisticalServiceImpl implements AreaStatisticalService { private final GeneralDeviceInfoClient generalDeviceInfoClient; - + private final PqsEventDetailQuery pqsEventDetailQuery; - + /** * 获取暂降区域 电压等级 月份统计 * @@ -62,26 +64,27 @@ public class AreaStatisticalServiceImpl implements AreaStatisticalService { if (CollUtil.isEmpty(lineIds)) { return AreaStatisticalVO.empty(); } - + + List clauseList = new ArrayList<>(timeAnd(beginOfDay(deviceInfoParam.getSearchBeginTime()), endOfDay(deviceInfoParam.getSearchEndTime()))); + clauseList.add(ne("wave_type",5)); List eventDetailList = pqsEventDetailQuery.selectList(Arrays.asList("line_id", "eventass_index"), - lineIdOr(lineIds), - timeAnd(beginOfDay(deviceInfoParam.getSearchBeginTime()), endOfDay(deviceInfoParam.getSearchEndTime()))); + lineIdOr(lineIds),clauseList); if (CollUtil.isEmpty(eventDetailList)) { return AreaStatisticalVO.empty(); } - + AreaStatisticsVO areaStatisticsVO = statisticsAreaInfo(generalDeviceDTOList, eventDetailList); - + MonthlyStatisticsVO monthCalculationVOS = statisticsMonthInfo(deviceInfoParam, eventDetailList); - - + + deviceInfoParam.getStatisticalType().setCode(StatisticsEnum.VOLTAGE_LEVEL.getCode()); List voltageLevelList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData(); VoltageStatisticsVO voltageStatisticsVO = statisticalVoltageLevelInfo(voltageLevelList, eventDetailList); - + return AreaStatisticalVO.buildVO(areaStatisticsVO, voltageStatisticsVO, monthCalculationVOS); } - + /** * 统计月份信息 * @@ -91,34 +94,49 @@ public class AreaStatisticalServiceImpl implements AreaStatisticalService { */ private MonthlyStatisticsVO statisticsMonthInfo(DeviceInfoParam.BusinessParam deviceInfoParam, List eventDetailList) { List timeLimit = calculateTheTimePeriodRange(deviceInfoParam); - List monthStartAndEnd = calculateMonthStartAndEnd(timeLimit); - + List monthStartAndEnd = new ArrayList<>(); + if(deviceInfoParam.getTimeFlag()==0){ + //月 + monthStartAndEnd = calculateMonthStartAndEnd(timeLimit,0); + }else { + //天 + monthStartAndEnd = calculateMonthStartAndEnd(timeLimit,1); + } + + List monthCalculationVOList = new ArrayList<>(monthStartAndEnd.size()); MonthCalculationVO monthCalculationVO; for (int i = 0; i < monthStartAndEnd.size(); i += 2) { DateTime beginMon = monthStartAndEnd.get(i); DateTime endMon = monthStartAndEnd.get(i + 1); - + List eventDetails = getBetweenTimeEventDetailList(eventDetailList).apply(beginMon, endMon); - + // 时间段内总记录数 Long count = (long) eventDetails.size(); - + // 时间段内非空记录数,剔除等于空的 Long linkedCount = countEventassIndexIsNoEmpty().apply(eventDetails); - + + monthCalculationVO = new MonthCalculationVO(); - monthCalculationVO.setMonth(beginMon.toDateStr().substring(0, 7)); + if(deviceInfoParam.getTimeFlag()==0){ + //月 + monthCalculationVO.setMonth(beginMon.toDateStr().substring(0, 7)); + }else { + //日 + monthCalculationVO.setMonth(beginMon.toDateStr()); + } monthCalculationVO.setNotAssociated(count - linkedCount); monthCalculationVO.setLinked(linkedCount); - + monthCalculationVOList.add(monthCalculationVO); } Long notAssociatedSum = monthCalculationVOList.stream().mapToLong(MonthCalculationVO::getNotAssociated).sum(); - + return MonthlyStatisticsVO.buildVO(notAssociatedSum, monthCalculationVOList); } - + /** * 统计电压等级信息 * @@ -134,14 +152,14 @@ public class AreaStatisticalServiceImpl implements AreaStatisticalService { voltageLevelCalculationVO.setFrequency(countLineIndexes(eventDetailList).apply(t.getLineIndexes())); return voltageLevelCalculationVO; }).collect(Collectors.toCollection(() -> Collections.synchronizedList(new ArrayList<>()))); - + // 求和暂降次数 Long frequencySum = voltageLevelCalculation.stream().mapToLong(VoltageLevelCalculationVO::getFrequency).sum(); // 求装置数量 Integer monitoringPointSum = voltageLevelCalculation.stream().mapToInt(VoltageLevelCalculationVO::getMonitoringPoints).sum(); return VoltageStatisticsVO.buildVO(frequencySum, monitoringPointSum, voltageLevelCalculation); } - + /** * 统计区域信息 * @@ -154,35 +172,47 @@ public class AreaStatisticalServiceImpl implements AreaStatisticalService { AreaCalculationVO calculationVO = new AreaCalculationVO(); calculationVO.setAreaName(t.getName()); calculationVO.setMonitoringPoints(t.getLineIndexes().size()); - + calculationVO.setFrequency(countLineIndexes(eventDetailList).apply(t.getLineIndexes())); - + calculationVO.computeSarfi90(); return calculationVO; }).sorted(AreaCalculationVO.sortAscAreaName()).collect(Collectors.toCollection(() -> Collections.synchronizedList(new ArrayList<>()))); - + // 求和暂降次数 Long frequencySum = areaCalculation.stream().mapToLong(AreaCalculationVO::getFrequency).sum(); // 求装置数量 Integer monitoringPointSum = areaCalculation.stream().mapToInt(AreaCalculationVO::getMonitoringPoints).sum(); - + return AreaStatisticsVO.buildVO(frequencySum, monitoringPointSum, areaCalculation); } - + /** * 计算出月的开始时间和结束时间 * * @param timeLimit 查询参数 + * @param timeFlag 0.月 1.天 * @return 月的开始时间和结束时间 */ - private List calculateMonthStartAndEnd(List timeLimit) { - return timeLimit.stream().flatMap(dateTime -> { - DateTime dateTime1 = DateUtil.beginOfMonth(dateTime); - DateTime dateTime2 = DateUtil.endOfMonth(dateTime); - return Stream.of(dateTime1, dateTime2); - }).collect(Collectors.toList()); + private List calculateMonthStartAndEnd(List timeLimit,Integer timeFlag) { + + if(timeFlag == 0){ + return timeLimit.stream().flatMap(dateTime -> { + DateTime dateTime1 = DateUtil.beginOfMonth(dateTime); + DateTime dateTime2 = DateUtil.endOfMonth(dateTime); + return Stream.of(dateTime1, dateTime2); + }).collect(Collectors.toList()); + }else { + return timeLimit.stream().flatMap(dateTime -> { + DateTime dateTime1 = DateUtil.beginOfDay(dateTime); + DateTime dateTime2 = DateUtil.endOfDay(dateTime); + return Stream.of(dateTime1, dateTime2); + }).collect(Collectors.toList()); + + } + } - + /** * 根据开始时间结束时间, 获取时间年月范围 * @@ -190,9 +220,18 @@ public class AreaStatisticalServiceImpl implements AreaStatisticalService { * @return 获取时间年月范围 */ private List calculateTheTimePeriodRange(DeviceInfoParam.BusinessParam deviceInfoParam) { - DateTime beginTime = DateUtil.parse(deviceInfoParam.getSearchBeginTime(), DatePattern.NORM_DATE_PATTERN); - DateTime endTime = DateUtil.parse(deviceInfoParam.getSearchEndTime(), DatePattern.NORM_DATE_PATTERN); - return DateUtil.rangeToList(beginTime, endTime, DateField.MONTH); + if(deviceInfoParam.getTimeFlag() == 0){ + //月 + DateTime beginTime = DateUtil.parse(deviceInfoParam.getSearchBeginTime(), DatePattern.NORM_DATE_PATTERN); + DateTime endTime = DateUtil.parse(deviceInfoParam.getSearchEndTime(), DatePattern.NORM_DATE_PATTERN); + return DateUtil.rangeToList(beginTime, endTime, DateField.MONTH); + }else { + DateTime beginTime = DateUtil.parse(deviceInfoParam.getSearchBeginTime(), DatePattern.NORM_DATE_PATTERN); + DateTime endTime = DateUtil.parse(deviceInfoParam.getSearchEndTime(), DatePattern.NORM_DATE_PATTERN); + return DateUtil.rangeToList(beginTime, endTime, DateField.DAY_OF_MONTH); + + } + } - + } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/EventAnalysisServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/EventAnalysisServiceImpl.java index 9556cec01..c3417ccfe 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/EventAnalysisServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/EventAnalysisServiceImpl.java @@ -2,21 +2,49 @@ package com.njcn.event.service.Impl; import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.njcn.common.config.GeneralInfo; +import com.njcn.common.pojo.dto.wave.WaveDataDTO; +import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.PubUtils; +import com.njcn.common.utils.wave.AnalyWave; +import com.njcn.device.api.LineFeignClient; +import com.njcn.device.pojo.vo.AreaLineInfoVO; +import com.njcn.device.pojo.vo.LineDetailDataVO; +import com.njcn.event.enums.EventResponseEnum; import com.njcn.event.pojo.constant.Param; -import com.njcn.event.pojo.param.EventBaseParam; +import com.njcn.event.pojo.param.*; 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.EventAnalysisService; +import com.njcn.event.service.EventDetailService; import com.njcn.influxdb.utils.InfluxDbUtils; +import com.njcn.system.api.DicDataFeignClient; +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 javax.servlet.http.HttpServletResponse; +import java.io.*; import java.math.BigDecimal; -import java.util.List; -import java.util.Map; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.temporal.ChronoUnit; +import java.util.*; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +import static cn.hutool.poi.excel.sax.ElementName.v; + /** * pqs-event @@ -30,28 +58,35 @@ public class EventAnalysisServiceImpl implements EventAnalysisService { private final InfluxDbUtils influxDbUtils; + private final LineFeignClient lineFeignClient; + + private final EventDetailService eventDetailService; + + private final GeneralInfo generalInfo; + + private final DicDataFeignClient dicDataFeignClient; @Override public Page getEventAnalyse(EventBaseParam eventBaseParam) { //查询sql语句 StringBuilder stringResult = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE). - append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(eventBaseParam.getSearchBeginTime()))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(eventBaseParam.getSearchEndTime()))).append("' and ") - .append("line_id= '").append(eventBaseParam.getLineId()).append("'"); + append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(eventBaseParam.getSearchBeginTime()))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(eventBaseParam.getSearchEndTime()))).append("' and ") + .append("line_id= '").append(eventBaseParam.getLineId()).append("'"); - int i = (eventBaseParam.getPageNum() - 1)*eventBaseParam.getPageSize(); + int i = (eventBaseParam.getPageNum() - 1) * eventBaseParam.getPageSize(); stringResult.append("LIMIT ").append(eventBaseParam.getPageSize()).append(" OFFSET ").append(i).append(" tz('Asia/Shanghai')"); //查询sql语句总条数 - StringBuilder stringTotal = new StringBuilder("SELECT COUNT(num) as aa FROM ").append(Param.EVENT_DETAIL).append(" WHERE ") .append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(eventBaseParam.getSearchBeginTime()))).append("' and ") + StringBuilder stringTotal = new StringBuilder("SELECT COUNT(num) as aa FROM ").append(Param.EVENT_DETAIL).append(" WHERE ").append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(eventBaseParam.getSearchBeginTime()))).append("' and ") .append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(eventBaseParam.getSearchEndTime()))).append("' and "); - stringTotal.append("line_id= '").append(eventBaseParam.getLineId()).append("' tz('Asia/Shanghai')"); + stringTotal.append("line_id= '").append(eventBaseParam.getLineId()).append("' tz('Asia/Shanghai')"); //结果集 QueryResult result = influxDbUtils.query(stringResult.toString()); //总条数 - QueryResult resultTotal = influxDbUtils.query(stringTotal.toString()); + QueryResult resultTotal = influxDbUtils.query(stringTotal.toString()); //结果集映射到对象中 InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); List eventDetailList = influxDBResultMapper.toPOJO(result, EventDetail.class); @@ -64,4 +99,1867 @@ public class EventAnalysisServiceImpl implements EventAnalysisService { page.setSize(eventBaseParam.getPageSize()); return page; } + + /** + * 时间无ID全查询 + * + * @param startTime + * @param endTime + * @return + * @author xxy + */ + public QueryResult TimeQuery(String startTime, String endTime) { + //构建sql语句 + String stringResult = Param.SELECT + Param.EVENT_DETAIL + Param.WHERE + "time >= '" + + DateUtil.beginOfDay(DateUtil.parse(startTime)) + + "' and " + "time <= '" + + DateUtil.endOfDay(DateUtil.parse(endTime)) + "'" + Param.TZ_ASIA_SHANGHAI; + //结果集映射到对象中 + return influxDbUtils.query(stringResult); + } + + /** + * @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); + } + + /** + * 获取电压暂态表及密度坐标图 + * + * @param statisticsParam + * @return + * @author xxy + */ + @Override + public List getCoords(StatisticsParam statisticsParam) { + QueryResult query = MonitorQuery(statisticsParam); + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + List result = new ArrayList<>(); + List info = influxDBResultMapper.toPOJO(query, EventDetail.class); + + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 9; j++) { + result.add(new CoordsVO(i, j, 0)); + } + } + for (int i = 0; i < info.size(); i++) { + Integer index = null; + CoordsVO dto = new CoordsVO(); + if (info.get(i).getEventValue() >= 0 && info.get(i).getEventValue() <= 0.1) { + if (info.get(i).getPersistTime()/1000 > 0 && info.get(i).getPersistTime()/1000 <= 0.020) { + index = 0; + } else if (info.get(i).getPersistTime()/1000 <= 0.040 && info.get(i).getPersistTime()/1000 > 0.020) { + index = 1; + } else if (info.get(i).getPersistTime()/1000 <= 0.060 && info.get(i).getPersistTime()/1000 > 0.040) { + index = 2; + } else if (info.get(i).getPersistTime()/1000 <= 0.080 && info.get(i).getPersistTime()/1000 > 0.060) { + index = 3; + } else if (info.get(i).getPersistTime()/1000 <= 0.120 && info.get(i).getPersistTime()/1000 > 0.080) { + index = 4; + } else if (info.get(i).getPersistTime()/1000 > 0.120 && info.get(i).getPersistTime()/1000 < 0.200) { + index = 5; + } else if (info.get(i).getPersistTime()/1000 >= 0.200 && info.get(i).getPersistTime()/1000 < 0.400) { + index = 6; + } else if (info.get(i).getPersistTime()/1000 >= 0.400 && info.get(i).getPersistTime()/1000 < 0.600) { + index = 7; + } else if (info.get(i).getPersistTime()/1000 >= 0.600 && info.get(i).getPersistTime()/1000 <= 1.200) { + index = 8; + } + } else if (info.get(i).getEventValue() > 0.1 && info.get(i).getEventValue() <= 0.2) { + if (info.get(i).getPersistTime()/1000 > 0 && info.get(i).getPersistTime()/1000 <= 0.020) { + index = 9; + } else if (info.get(i).getPersistTime()/1000 <= 0.040 && info.get(i).getPersistTime()/1000 > 0.020) { + index = 10; + } else if (info.get(i).getPersistTime()/1000 <= 0.060 && info.get(i).getPersistTime()/1000 > 0.040) { + index = 11; + } else if (info.get(i).getPersistTime()/1000 <= 0.080 && info.get(i).getPersistTime()/1000 > 0.060) { + index = 12; + } else if (info.get(i).getPersistTime()/1000 <= 0.120 && info.get(i).getPersistTime()/1000 > 0.080) { + index = 13; + } else if (info.get(i).getPersistTime()/1000 > 0.120 && info.get(i).getPersistTime()/1000 < 0.200) { + index = 14; + } else if (info.get(i).getPersistTime()/1000 >= 0.200 && info.get(i).getPersistTime()/1000 < 0.400) { + index = 15; + } else if (info.get(i).getPersistTime()/1000 >= 0.400 && info.get(i).getPersistTime()/1000 < 0.600) { + index = 16; + } else if (info.get(i).getPersistTime()/1000 >= 0.600 && info.get(i).getPersistTime()/1000 <= 1.200) { + index = 17; + } + } else if (info.get(i).getEventValue() > 0.2 && info.get(i).getEventValue() <= 0.3) { + if (info.get(i).getPersistTime()/1000 > 0 && info.get(i).getPersistTime()/1000 <= 0.020) { + index = 18; + } else if (info.get(i).getPersistTime()/1000 <= 0.040 && info.get(i).getPersistTime()/1000 > 0.020) { + index = 19; + } else if (info.get(i).getPersistTime()/1000 <= 0.060 && info.get(i).getPersistTime()/1000 > 0.040) { + index = 20; + } else if (info.get(i).getPersistTime()/1000 <= 0.080 && info.get(i).getPersistTime()/1000 > 0.060) { + index = 21; + } else if (info.get(i).getPersistTime()/1000 <= 0.120 && info.get(i).getPersistTime()/1000 > 0.080) { + index = 22; + } else if (info.get(i).getPersistTime()/1000 > 0.120 && info.get(i).getPersistTime()/1000 < 0.200) { + index = 23; + } else if (info.get(i).getPersistTime()/1000 >= 0.200 && info.get(i).getPersistTime()/1000 < 0.400) { + index = 24; + } else if (info.get(i).getPersistTime()/1000 >= 0.400 && info.get(i).getPersistTime()/1000 < 0.600) { + index = 25; + } else if (info.get(i).getPersistTime()/1000 >= 0.600 && info.get(i).getPersistTime()/1000 <= 1.200) { + index = 26; + } + } else if (info.get(i).getEventValue() > 0.3 && info.get(i).getEventValue() <= 0.4) { + if (info.get(i).getPersistTime()/1000 > 0 && info.get(i).getPersistTime()/1000 <= 0.020) { + index = 27; + } else if (info.get(i).getPersistTime()/1000 <= 0.040 && info.get(i).getPersistTime()/1000 > 0.020) { + index = 28; + } else if (info.get(i).getPersistTime()/1000 <= 0.060 && info.get(i).getPersistTime()/1000 > 0.040) { + index = 29; + } else if (info.get(i).getPersistTime()/1000 <= 0.080 && info.get(i).getPersistTime()/1000 > 0.060) { + index = 30; + } else if (info.get(i).getPersistTime()/1000 <= 0.120 && info.get(i).getPersistTime()/1000 > 0.080) { + index = 31; + } else if (info.get(i).getPersistTime()/1000 > 0.120 && info.get(i).getPersistTime()/1000 < 0.200) { + index = 32; + } else if (info.get(i).getPersistTime()/1000 >= 0.200 && info.get(i).getPersistTime()/1000 < 0.400) { + index = 33; + } else if (info.get(i).getPersistTime()/1000 >= 0.400 && info.get(i).getPersistTime()/1000 < 0.600) { + index = 34; + } else if (info.get(i).getPersistTime()/1000 >= 0.600 && info.get(i).getPersistTime()/1000 <= 1.200) { + index = 35; + } + } else if (info.get(i).getEventValue() > 0.4 && info.get(i).getEventValue() <= 0.5) { + if (info.get(i).getPersistTime()/1000 > 0 && info.get(i).getPersistTime()/1000 <= 0.020) { + index = 36; + } else if (info.get(i).getPersistTime()/1000 <= 0.040 && info.get(i).getPersistTime()/1000 > 0.020) { + index = 37; + } else if (info.get(i).getPersistTime()/1000 <= 0.060 && info.get(i).getPersistTime()/1000 > 0.040) { + index = 38; + } else if (info.get(i).getPersistTime()/1000 <= 0.080 && info.get(i).getPersistTime()/1000 > 0.060) { + index = 39; + } else if (info.get(i).getPersistTime()/1000 <= 0.120 && info.get(i).getPersistTime()/1000 > 0.080) { + index = 40; + } else if (info.get(i).getPersistTime()/1000 > 0.120 && info.get(i).getPersistTime()/1000 < 0.200) { + index = 41; + } else if (info.get(i).getPersistTime()/1000 >= 0.200 && info.get(i).getPersistTime()/1000 < 0.400) { + index = 42; + } else if (info.get(i).getPersistTime()/1000 >= 0.400 && info.get(i).getPersistTime()/1000 < 0.600) { + index = 43; + } else if (info.get(i).getPersistTime()/1000 >= 0.600 && info.get(i).getPersistTime()/1000 <= 1.200) { + index = 44; + } + } else if (info.get(i).getEventValue() > 0.5 && info.get(i).getEventValue() <= 0.6) { + if (info.get(i).getPersistTime()/1000 > 0 && info.get(i).getPersistTime()/1000 <= 0.020) { + index = 45; + } else if (info.get(i).getPersistTime()/1000 <= 0.040 && info.get(i).getPersistTime()/1000 > 0.020) { + index = 46; + } else if (info.get(i).getPersistTime()/1000 <= 0.060 && info.get(i).getPersistTime()/1000 > 0.040) { + index = 47; + } else if (info.get(i).getPersistTime()/1000 <= 0.080 && info.get(i).getPersistTime()/1000 > 0.060) { + index = 48; + } else if (info.get(i).getPersistTime()/1000 <= 0.120 && info.get(i).getPersistTime()/1000 > 0.080) { + index = 49; + } else if (info.get(i).getPersistTime()/1000 > 0.120 && info.get(i).getPersistTime()/1000 < 0.200) { + index = 50; + } else if (info.get(i).getPersistTime()/1000 >= 0.200 && info.get(i).getPersistTime()/1000 < 0.400) { + index = 51; + } else if (info.get(i).getPersistTime()/1000 >= 0.400 && info.get(i).getPersistTime()/1000 < 0.600) { + index = 52; + } else if (info.get(i).getPersistTime()/1000 >= 0.600 && info.get(i).getPersistTime()/1000 <= 1.200) { + index = 53; + } + } else if (info.get(i).getEventValue() > 0.6 && info.get(i).getEventValue() <= 0.7) { + if (info.get(i).getPersistTime()/1000 > 0 && info.get(i).getPersistTime()/1000 <= 0.020) { + index = 54; + } else if (info.get(i).getPersistTime()/1000 <= 0.040 && info.get(i).getPersistTime()/1000 > 0.020) { + index = 55; + } else if (info.get(i).getPersistTime()/1000 <= 0.060 && info.get(i).getPersistTime()/1000 > 0.040) { + index = 56; + } else if (info.get(i).getPersistTime()/1000 <= 0.080 && info.get(i).getPersistTime()/1000 > 0.060) { + index = 57; + } else if (info.get(i).getPersistTime()/1000 <= 0.120 && info.get(i).getPersistTime()/1000 > 0.080) { + index = 58; + } else if (info.get(i).getPersistTime()/1000 > 0.120 && info.get(i).getPersistTime()/1000 < 0.200) { + index = 59; + } else if (info.get(i).getPersistTime()/1000 >= 0.200 && info.get(i).getPersistTime()/1000 < 0.400) { + index = 60; + } else if (info.get(i).getPersistTime()/1000 >= 0.400 && info.get(i).getPersistTime()/1000 < 0.600) { + index = 61; + } else if (info.get(i).getPersistTime()/1000 >= 0.600 && info.get(i).getPersistTime()/1000 <= 1.200) { + index = 62; + } + } else if (info.get(i).getEventValue() > 0.7 && info.get(i).getEventValue() <= 0.8) { + if (info.get(i).getPersistTime()/1000 > 0 && info.get(i).getPersistTime()/1000 <= 0.020) { + index = 63; + } else if (info.get(i).getPersistTime()/1000 <= 0.040 && info.get(i).getPersistTime()/1000 > 0.020) { + index = 64; + } else if (info.get(i).getPersistTime()/1000 <= 0.060 && info.get(i).getPersistTime()/1000 > 0.040) { + index = 65; + } else if (info.get(i).getPersistTime()/1000 <= 0.080 && info.get(i).getPersistTime()/1000 > 0.060) { + index = 66; + } else if (info.get(i).getPersistTime()/1000 <= 0.120 && info.get(i).getPersistTime()/1000 > 0.080) { + index = 67; + } else if (info.get(i).getPersistTime()/1000 > 0.120 && info.get(i).getPersistTime()/1000 < 0.200) { + index = 68; + } else if (info.get(i).getPersistTime()/1000 >= 0.200 && info.get(i).getPersistTime()/1000 < 0.400) { + index = 69; + } else if (info.get(i).getPersistTime()/1000 >= 0.400 && info.get(i).getPersistTime()/1000 < 0.600) { + index = 70; + } else if (info.get(i).getPersistTime()/1000 >= 0.600 && info.get(i).getPersistTime()/1000 <= 1.200) { + index = 71; + } + } else if (info.get(i).getEventValue() > 0.8 && info.get(i).getEventValue() <= 0.9) { + if (info.get(i).getPersistTime()/1000 > 0 && info.get(i).getPersistTime()/1000 <= 0.020) { + index = 72; + } else if (info.get(i).getPersistTime()/1000 <= 0.040 && info.get(i).getPersistTime()/1000 > 0.020) { + index = 73; + } else if (info.get(i).getPersistTime()/1000 <= 0.060 && info.get(i).getPersistTime()/1000 > 0.040) { + index = 74; + } else if (info.get(i).getPersistTime()/1000 <= 0.080 && info.get(i).getPersistTime()/1000 > 0.060) { + index = 75; + } else if (info.get(i).getPersistTime()/1000 <= 0.120 && info.get(i).getPersistTime()/1000 > 0.080) { + index = 76; + } else if (info.get(i).getPersistTime()/1000 > 0.120 && info.get(i).getPersistTime()/1000 < 0.200) { + index = 77; + } else if (info.get(i).getPersistTime()/1000 >= 0.200 && info.get(i).getPersistTime()/1000 < 0.400) { + index = 78; + } else if (info.get(i).getPersistTime()/1000 >= 0.400 && info.get(i).getPersistTime()/1000 < 0.600) { + index = 79; + } else if (info.get(i).getPersistTime()/1000 >= 0.600 && info.get(i).getPersistTime()/1000 <= 1.200) { + index = 80; + } + } else { + if (info.get(i).getPersistTime()/1000 > 0 && info.get(i).getPersistTime()/1000 <= 0.020) { + index = 81; + } else if (info.get(i).getPersistTime()/1000 <= 0.040 && info.get(i).getPersistTime()/1000 > 0.020) { + index = 82; + } else if (info.get(i).getPersistTime()/1000 <= 0.060 && info.get(i).getPersistTime()/1000 > 0.040) { + index = 83; + } else if (info.get(i).getPersistTime()/1000 <= 0.080 && info.get(i).getPersistTime()/1000 > 0.060) { + index = 84; + } else if (info.get(i).getPersistTime()/1000 <= 0.120 && info.get(i).getPersistTime()/1000 > 0.080) { + index = 85; + } else if (info.get(i).getPersistTime()/1000 > 0.120 && info.get(i).getPersistTime()/1000 < 0.200) { + index = 86; + } else if (info.get(i).getPersistTime()/1000 >= 0.200 && info.get(i).getPersistTime()/1000 < 0.400) { + index = 87; + } else if (info.get(i).getPersistTime()/1000 >= 0.400 && info.get(i).getPersistTime()/1000 < 0.600) { + index = 88; + } else if (info.get(i).getPersistTime()/1000 >= 0.600 && info.get(i).getPersistTime()/1000 <= 1.200) { + index = 89; + } + } + if (Objects.nonNull(index)) { + CoordsVO coordsVO = result.get(index); + coordsVO.setZ(coordsVO.getZ() + 1); + } + } + return result; + } + + @Override + public List eventDisdip(StatisticsParam statisticsParam) { + List result = new ArrayList<>(); + List info = new ArrayList<>(); + QueryResult query = MonitorQuery(statisticsParam); + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + info = influxDBResultMapper.toPOJO(query, EventDetail.class); + 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(StatisticsParam statisticsParam) { + List result = new ArrayList<>(); + List info = new ArrayList<>(); + QueryResult query = MonitorQuery(statisticsParam); + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + info = influxDBResultMapper.toPOJO(query, EventDetail.class); + 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(StatisticsParam statisticsParam) { + List result = new ArrayList<>(); + QueryResult query = MonitorQuery(statisticsParam); + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + List info = influxDBResultMapper.toPOJO(query, EventDetail.class); + 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; + } + + /** + * 暂降原因类型和时间 + * + * @param statisticsParam + * @return + * @author xxy + */ + @Override + public List getReasonTypeTime(StatisticsParam statisticsParam) 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 != endYear && startMonth != 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; + } + } + + @Override + public StatisticVO getStatistic(StatisticsParam statisticsParam) { + StatisticVO result = new StatisticVO(); + List list = new ArrayList<>(); + List reasonsVOS = new ArrayList<>(); + List typesVOS = new ArrayList<>(); + List info = new ArrayList<>(); + QueryResult query = MonitorQuery(statisticsParam); + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + info = influxDBResultMapper.toPOJO(query, EventDetail.class); + HttpResult> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()); + HttpResult> type = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()); + List reasonData = reason.getData(); + List typeData = type.getData(); + + HashMap reasonMap = new HashMap<>(); + HashMap typeMap = new HashMap<>(); + //添加detail + for (EventDetail detail : info) { + if (detail.getWaveType() == 1) { + 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); + //result.setDetail(list); + return result; + } + + /** + * 暂降幅值的概率分布函数 + * + * @param statisticsParam + * @return + * @author xxy + */ + @Override + public ProbabilityVO getProbabilityDistribution(StatisticsParam statisticsParam) { + ProbabilityVO result = new ProbabilityVO(); + List info = new ArrayList<>(); + QueryResult query = MonitorQuery(statisticsParam); + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + List info2 = influxDBResultMapper.toPOJO(query, EventDetail.class); + //总数 + 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; + } + + /** + * 暂降事件点图 + * + * @param statisticsParam + * @return + * @author xxy + */ + @Override + public List getPlot(StatisticsParam statisticsParam) { + List result = new ArrayList<>(); + QueryResult query = MonitorQuery(statisticsParam); + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + result = influxDBResultMapper.toPOJO(query, EventDetail.class); + HttpResult> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()); + HttpResult> type = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()); + List reasonData = reason.getData(); + List typeData = type.getData(); + //添加detail + for (EventDetail detail : result) { + if (detail.getWaveType() == 1) { + 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 result; + } + + /** + * 监测点暂降事件分析查询 + * + * @author zbj + * @date 2022/7/25 + */ + @Override + public Page getMonitorEventAnalyseQuery(EventBaseParam eventBaseParam) { + + //提前创建结果集合 + List eventDetailList = new ArrayList<>(); + + //创建line_id集合,将入参line_id塞进去 + List lineIds = new ArrayList<>(); + lineIds.add(eventBaseParam.getLineId()); + + //提前创建total + StringBuilder stringTotal = new StringBuilder(); + + + //查询参数不为空,进行条件填充 + if (ObjectUtil.isNotNull(eventBaseParam.getSearchValue())) { + //查询sql语句 + StringBuilder stringResult = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE). + append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(eventBaseParam.getSearchBeginTime()))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(eventBaseParam.getSearchEndTime()))).append("' and ") + .append("line_id= '").append(eventBaseParam.getLineId()).append("'"); + + //套用公式(page-1)*pageSize + int i = (eventBaseParam.getPageNum() - 1) * eventBaseParam.getPageSize(); + //拼接分页sql + stringResult.append("LIMIT ").append(eventBaseParam.getPageSize()).append(" OFFSET ").append(i).append(" tz('Asia/Shanghai')"); + + + //查询sql语句总条数 + stringTotal = new StringBuilder("SELECT COUNT(num) as aa FROM ").append(Param.EVENT_DETAIL).append(" WHERE ").append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(eventBaseParam.getSearchBeginTime()))).append("' and ") + .append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(eventBaseParam.getSearchEndTime()))).append("' and "); + stringTotal.append("line_id= '").append(eventBaseParam.getLineId()).append("' tz('Asia/Shanghai')"); + + //结果集 + QueryResult result = influxDbUtils.query(stringResult.toString()); + //总条数 + QueryResult resultTotal = influxDbUtils.query(stringTotal.toString()); + + //结果集映射到对象中 + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + eventDetailList = influxDBResultMapper.toPOJO(result, WaveTypeVO.class); + + + //获取关于监测点发电站相关信息 + HttpResult> baseLineAreaInfo = lineFeignClient.getBaseLineAreaInfo(lineIds); + System.out.println(baseLineAreaInfo); + //将返回的封装好的结果集进行还原成集合 + List areaLineList = baseLineAreaInfo.getData(); + + + //将监测点发电机相关信息copy到准备好的VO对象中 + for (WaveTypeVO waveTypeVO : eventDetailList) { + if (waveTypeVO.getLineId() != null) { + for (AreaLineInfoVO lineInfoVO : areaLineList) { + if (waveTypeVO.getLineId().equals(lineInfoVO.getLineId())) { + waveTypeVO.setSubName(lineInfoVO.getSubName()); + waveTypeVO.setLineId(lineInfoVO.getLineId()); + waveTypeVO.setLineName(lineInfoVO.getLineName()); + waveTypeVO.setGdId(lineInfoVO.getGdId()); + waveTypeVO.setGdName(lineInfoVO.getGdName()); + waveTypeVO.setVoltageId(lineInfoVO.getVoltageId()); + waveTypeVO.setNoDealCount(lineInfoVO.getNoDealCount()); + waveTypeVO.setCt1(lineInfoVO.getCt1()); + waveTypeVO.setCt2(lineInfoVO.getCt2()); + waveTypeVO.setPt1(lineInfoVO.getPt1()); + waveTypeVO.setPt2(lineInfoVO.getPt2()); + waveTypeVO.setRunFlag(lineInfoVO.getRunFlag()); + waveTypeVO.setComFlag(lineInfoVO.getComFlag()); + waveTypeVO.setIp(lineInfoVO.getIp()); + waveTypeVO.setLat(lineInfoVO.getLat()); + waveTypeVO.setLng(lineInfoVO.getLng()); + waveTypeVO.setManufacturer(lineInfoVO.getManufacturer()); + waveTypeVO.setVoltageScale(lineInfoVO.getVoltageScale()); + } + } + } else { + //抛出异常,当前监测点id为空 + throw new BusinessException(EventResponseEnum.EVENT_NOT_FOUND); + } + } + + //使用字典表对暂态类型和暂态原因进行转换 + HttpResult> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()); + HttpResult> type = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()); + //获取字典数据暂态原因集合 + List eventReasonList = reason.getData(); + //System.out.println(eventReasonList); + //获取字典数据暂态类型集合 + List eventTypeList = type.getData(); + //System.out.println(eventTypeList); + + + //查询字典表替换事件原因与事件类型的字符串 + for (WaveTypeVO eventDetail : eventDetailList) { + if (eventDetail.getEventReason() != null) { + for (DictData dictData : eventReasonList) { + //将字典数据id与VO中属性eventReason对应的字符串进行比较 + if (eventDetail.getEventReason().equals(dictData.getId())) { + eventDetail.setEventReason(dictData.getName()); + } + } + } else { + //抛出异常,当前暂态原因为空 + throw new BusinessException(EventResponseEnum.EVENT_REASON_NOT_FOUND); + } + } + + for (WaveTypeVO eventDetail : eventDetailList) { + if (eventDetail.getEventType() != null) { + for (DictData dictData : eventTypeList) { + //将字典数据id与VO中属性eventType对应的字符串进行比较 + if (eventDetail.getEventType().equals(dictData.getId())) { + eventDetail.setEventType(dictData.getName()); + } + } + } else { + //抛出异常,当前暂态类型为空 + throw new BusinessException(EventResponseEnum.EVENT_TYPE_NOT_FOUND); + } + } + Page page = new Page<>(); + long total = new BigDecimal(resultTotal.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).longValue(); + page.setTotal(total); + page.setRecords(eventDetailList); + page.setCurrent(eventBaseParam.getPageNum()); + page.setSize(eventBaseParam.getPageSize()); + return page; + + + } else { + StringBuilder stringResult = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE). + append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(eventBaseParam.getSearchBeginTime()))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(eventBaseParam.getSearchEndTime()))).append("' and ") + .append("line_id= '").append(eventBaseParam.getLineId()).append("'"); + + + int i = (eventBaseParam.getPageNum() - 1) * eventBaseParam.getPageSize(); + + stringResult.append("LIMIT ").append(eventBaseParam.getPageSize()).append(" OFFSET ").append(i).append(" tz('Asia/Shanghai')"); + + //查询sql语句总条数 + stringTotal = new StringBuilder("SELECT COUNT(num) as aa FROM ").append(Param.EVENT_DETAIL).append(" WHERE ").append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(eventBaseParam.getSearchBeginTime()))).append("' and ") + .append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(eventBaseParam.getSearchEndTime()))).append("' and "); + stringTotal.append("line_id= '").append(eventBaseParam.getLineId()).append("' tz('Asia/Shanghai')"); + + + //结果集 + QueryResult result = influxDbUtils.query(stringResult.toString()); + //总条数 + QueryResult resultTotal = influxDbUtils.query(stringTotal.toString()); + + //结果集映射到对象中 + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + eventDetailList = influxDBResultMapper.toPOJO(result, WaveTypeVO.class); + + + //获取关于监测点发电站相关信息 + HttpResult> baseLineAreaInfo = lineFeignClient.getBaseLineAreaInfo(lineIds); + System.out.println(baseLineAreaInfo); + //将返回的封装好的结果集进行还原成集合 + List areaLineList = baseLineAreaInfo.getData(); + + + //将监测点发电机相关信息copy到准备好的VO对象中 + for (WaveTypeVO waveTypeVO : eventDetailList) { + if (waveTypeVO.getLineId() != null) { + for (AreaLineInfoVO lineInfoVO : areaLineList) { + if (waveTypeVO.getLineId().equals(lineInfoVO.getLineId())) { + waveTypeVO.setSubName(lineInfoVO.getSubName()); + waveTypeVO.setLineId(lineInfoVO.getLineId()); + waveTypeVO.setLineName(lineInfoVO.getLineName()); + waveTypeVO.setGdId(lineInfoVO.getGdId()); + waveTypeVO.setGdName(lineInfoVO.getGdName()); + waveTypeVO.setVoltageId(lineInfoVO.getVoltageId()); + waveTypeVO.setNoDealCount(lineInfoVO.getNoDealCount()); + waveTypeVO.setCt1(lineInfoVO.getCt1()); + waveTypeVO.setCt2(lineInfoVO.getCt2()); + waveTypeVO.setPt1(lineInfoVO.getPt1()); + waveTypeVO.setPt2(lineInfoVO.getPt2()); + waveTypeVO.setRunFlag(lineInfoVO.getRunFlag()); + waveTypeVO.setComFlag(lineInfoVO.getComFlag()); + waveTypeVO.setIp(lineInfoVO.getIp()); + waveTypeVO.setLat(lineInfoVO.getLat()); + waveTypeVO.setLng(lineInfoVO.getLng()); + waveTypeVO.setManufacturer(lineInfoVO.getManufacturer()); + waveTypeVO.setVoltageScale(lineInfoVO.getVoltageScale()); + } + } + } else { + //抛出异常,当前监测点id为空 + throw new BusinessException(EventResponseEnum.EVENT_NOT_FOUND); + } + } + + + //使用字典表对暂态类型和暂态原因进行转换 + HttpResult> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()); + HttpResult> type = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()); + //获取字典数据暂态原因集合 + List eventReasonList = reason.getData(); + //System.out.println(eventReasonList); + //获取字典数据暂态类型集合 + List eventTypeList = type.getData(); + //System.out.println(eventTypeList); + + + //查询字典表替换事件原因与事件类型的字符串 + for (WaveTypeVO eventDetail : eventDetailList) { + if (eventDetail.getEventReason() != null) { + for (DictData dictData : eventReasonList) { + //将字典数据id与VO中属性eventReason对应的字符串进行比较 + if (eventDetail.getEventReason().equals(dictData.getId())) { + eventDetail.setEventReason(dictData.getName()); + break; + } + } + } else { + //抛出异常,当前暂态原因为空 + throw new BusinessException(EventResponseEnum.EVENT_REASON_NOT_FOUND); + } + } + + for (WaveTypeVO eventDetail : eventDetailList) { + if (eventDetail.getEventType() != null) { + for (DictData dictData : eventTypeList) { + //将字典数据id与VO中属性eventType对应的字符串进行比较 + if (eventDetail.getEventType().equals(dictData.getId())) { + eventDetail.setEventType(dictData.getName()); + break; + } + } + } else { + //抛出异常,当前暂态类型为空 + throw new BusinessException(EventResponseEnum.EVENT_TYPE_NOT_FOUND); + } + } + Page page = new Page<>(); + long total = new BigDecimal(resultTotal.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).longValue(); + page.setTotal(total); + page.setRecords(eventDetailList); + page.setCurrent(eventBaseParam.getPageNum()); + page.setSize(eventBaseParam.getPageSize()); + return page; + } + + } + + /** + * 监测点事件波形分析 + * + * @author zbj + * @date 2022/7/27 + */ + @Override + public WaveDataDTO getMonitorEventAnalyseWave(String timeId, String lineId) { + WaveDataDTO waveDataDTO = new WaveDataDTO(); + //根据监测点id获取监测点详情 + LineDetailDataVO lineDetailData = lineFeignClient.getLineDetailData(lineId).getData(); + EventDetail eventDetailByTime = eventDetailService.getEventDetailByTime(lineId, timeId); + + //暂时没有进行拼接 + String ip = lineDetailData.getIp(); + String waveName = eventDetailByTime.getWaveName(); + /* if(StrUtil.isBlank(waveName)){ + throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND); + }*/ + + + AnalyWave analyWave = new AnalyWave(); + + + /*WaveDataDTO comtrade = analyWave.getComtrade(generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + ".CFG", 1); + if (Objects.isNull(comtrade.getComtradeCfgDTO())) { + throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND); + }*/ + + + //测试用的本地路径 + WaveDataDTO comtrade = analyWave.getComtrade("C:\\Users\\CDF\\Desktop\\00-B7-8D-00-E7-15\\1_20220204_125513_383.cfg", 1); + + + waveDataDTO = analyWave.getValidData(comtrade); + + + waveDataDTO.setPtType(PubUtils.ptTypeName(lineDetailData.getPtType())); + double pt1 = Double.parseDouble(lineDetailData.getPt().split("/")[0]); + double pt2 = Double.parseDouble(lineDetailData.getPt().split("/")[1]); + double ct1 = Double.parseDouble(lineDetailData.getCt().split("/")[0]); + double ct2 = Double.parseDouble(lineDetailData.getCt().split("/")[1]); + + waveDataDTO.setPt(pt1 / pt2); + waveDataDTO.setCt(ct1 / ct2); + + + return waveDataDTO; + } + + + /** + * 监测点事件波形下载 + * + * @author zbj + * @date 2022/7/28 + */ + @Override + public HttpServletResponse downloadMonitorEventWaveFile(WaveFileParam waveFileParam, HttpServletResponse response) throws Exception { + List lineId = waveFileParam.getLineId(); + List timeId = waveFileParam.getTimeId(); + copyTempData(timeId, lineId); + + LineDetailDataVO lineDetailData = lineFeignClient.getLineDetailData(lineId.get(0)).getData(); + + + // TODO 1 + //压缩的文件夹名用检测点名进行命名 + zipCompress(new File(generalInfo.getBusinessTempPath() + File.separator + lineDetailData.getLineName())); + + + //使用自定义压缩文件名进行测试 + //zipCompress(new File("C:\\Users\\User\\Desktop\\" + lineDetailData.getLineName())); + + + // TODO 1 + //对压缩文件名进行字符串拼接 + String zipPath = generalInfo.getBusinessTempPath() + File.separator + lineDetailData.getLineName() + "波形文件" + ".zip"; + + + //使用自定义压缩文件名进行测试 + // String zipPath ="C:\\Users\\User\\Desktop\\"+lineDetailData.getLineName()+".zip"; + + + try { + // path是指欲下载的文件的路径。 + File file = new File(zipPath); + // 取得文件名。 + String filename = file.getName(); + // 取得文件的后缀名。 + String ext = filename.substring(filename.lastIndexOf(".") + 1).toUpperCase(); + // 以流的形式下载文件。 + InputStream fis = new BufferedInputStream(new FileInputStream(zipPath)); + byte[] buffer = new byte[fis.available()]; + fis.read(buffer); + fis.close(); + // 清空response + response.reset(); + // 设置response的Header + response.addHeader("Content-Disposition", "attachment;filename=" + new String(filename.getBytes())); + response.addHeader("Content-Length", "" + file.length()); + OutputStream toClient = new BufferedOutputStream(response.getOutputStream()); + response.setContentType("application/octet-stream"); + toClient.write(buffer); + toClient.flush(); + toClient.close(); + } catch (IOException ex) { + ex.printStackTrace(); + } + + //这里会删除压缩文件 + delFile(zipPath); + deleteDirectoryLegacyIO(new File(generalInfo.getBusinessTempPath() + File.separator + "comtrade")); + return response; + } + + /** + * 复制保存文件 + */ + public void copyTempData(List timeId, List lineId) throws IOException { + for (int i = 0; i < timeId.size(); i++) { + //根据监测点id获取监测点详情 + LineDetailDataVO lineDetailData = lineFeignClient.getLineDetailData(lineId.get(i)).getData(); + EventDetail eventDetailByTime = eventDetailService.getEventDetailByTime(lineId.get(i), timeId.get(i)); + if (Objects.isNull(lineDetailData.getIp()) && Objects.isNull(eventDetailByTime.getWaveName())) { + throw new BusinessException(EventResponseEnum.EVENT_NOT_FOUND); + } + String ip = lineDetailData.getIp(); + String waveName = eventDetailByTime.getWaveName(); + + // TODO 1 + File srcCFGFile = new File(generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + ".CFG"); + File srcDATFile = new File(generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + ".DAT"); + + + //使用本地的波形文件进行测试 +// File srcCFGFile = new File("C:\\Users\\User\\Desktop\\comtrade\\1\\PQMonitor_PQM1_002038_20220602_040510_117.CFG"); +// File srcDATFile = new File("C:\\Users\\User\\Desktop\\comtrade\\1\\PQMonitor_PQM1_002038_20220602_040510_117.DAT"); + + + // TODO 1 + if (!srcCFGFile.exists() && !srcDATFile.exists()) { + throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND); + } + + // TODO 1 + File temp = new File(generalInfo.getBusinessTempPath() + File.separator + lineDetailData.getLineName()); + temp.mkdirs(); + + + //使用本地创建的文件夹进行测试 +// File temp = new File("C:\\Users\\User\\Desktop\\" + lineDetailData.getLineName()); +// temp.mkdirs(); + + + //使用本地创建的文件夹进行测试 +// File cfg = new File("C:\\Users\\User\\Desktop\\" + lineDetailData.getLineName() + File.separator + srcCFGFile.getName()); +// File dat = new File("C:\\Users\\User\\Desktop\\" + lineDetailData.getLineName() + File.separator + srcDATFile.getName()); + + + // TODO 1 + File cfg = new File(generalInfo.getBusinessTempPath() + File.separator + lineDetailData.getLineName() + File.separator + srcCFGFile.getName()); + File dat = new File(generalInfo.getBusinessTempPath() + File.separator + lineDetailData.getLineName() + File.separator + srcDATFile.getName()); + + + writeFile(srcCFGFile, cfg); + writeFile(srcDATFile, dat); + } + } + + //读写文件 + public static void writeFile(File wave, File temp) throws IOException { + FileInputStream fis = new FileInputStream(wave); + FileOutputStream fos = new FileOutputStream(temp); + int len; + byte[] bys = new byte[1024]; + while ((len = fis.read(bys)) != -1) { + fos.write(bys, 0, len); + fos.flush(); + } + fos.close(); + fis.close(); + } + + + /** + * 将文件夹及文件夹包含的内容压缩成zip文件 + * (为了解决中文乱码的问题,ZipOutputStream用org.apache.tools.zip.*) + * + * @param inputFile 源文件(夹) + * @return File 压缩后的文件(路径在源文件的文件夹路径下) + */ + public static File zipCompress(File inputFile) throws Exception { + File zipFile = null; + ZipOutputStream zos = null; + if (inputFile != null && inputFile.exists()) { + try { + String path = inputFile.getCanonicalPath(); + String zipFileName = path + ".zip"; + zipFile = new File(zipFileName); + if (zipFile.exists()) { + zipFile.delete(); + } + zipFile.createNewFile();//创建文件 + zos = new ZipOutputStream(new FileOutputStream(zipFile)); + //压缩文件或文件夹 + compressFile(zos, inputFile, inputFile.getName()); + } catch (Exception e) { + System.out.println("文件压缩异常:" + e); + throw e; + } finally { + try { + if (zos != null) { + //先调用outputStream的flush()再关闭流; + //流如果未正常关闭,则会在解压的时候出现压缩文件损坏的现象 + zos.flush(); + zos.close(); + } + } catch (Exception ex) { + System.out.println("输出流关闭异常:" + ex); + } + } + } + return zipFile; + } + + /** + * 压缩文件或文件夹 (ZipEntry 使用org.apache.tools.zip.*,不要用 java.util.zip.*) + * + * @param zos zip输出流 + * @param sourceFile 源文件 + * @param baseName 父路径 + * @throws Exception 异常 + */ + public static void compressFile(ZipOutputStream zos, File sourceFile, String baseName) throws Exception { + if (!sourceFile.exists()) { + return; + } + //若路径为目录(文件夹) + if (sourceFile.isDirectory()) { + //取出文件夹中的文件(或子文件夹) + File[] fileList = sourceFile.listFiles(); + //若文件夹为空,则创建一个目录进入点 + if (fileList.length == 0) { + //文件名称后跟File.separator表示这是一个文件夹 + zos.putNextEntry(new ZipEntry(baseName + File.separator)); + + //若文件夹非空,则递归调用compressFile,对文件夹中的每个文件或每个文件夹进行压缩 + } else { + for (int i = 0; i < fileList.length; i++) { + compressFile(zos, fileList[i], + baseName + File.separator + fileList[i].getName()); + } + } + + //若为文件,则先创建目录进入点,再将文件写入zip文件中 + } else { + ZipEntry ze = new ZipEntry(baseName); + //设置ZipEntry的最后修改时间为源文件的最后修改时间 + ze.setTime(sourceFile.lastModified()); + zos.putNextEntry(ze); + + FileInputStream fis = new FileInputStream(sourceFile); + copyStream(fis, zos); + try { + if (fis != null) { + fis.close(); + } + } catch (Exception e) { + System.out.println("输入流关闭异常:" + e); + } + } + } + + /** + * 流拷贝 + * + * @param in 输入流 + * @param out 输出流 + * @throws IOException + */ + public static void copyStream(InputStream in, OutputStream out) throws IOException { + int bufferLength = 1024 * 100; + synchronized (in) { + synchronized (out) { + int count = 0; + byte[] buffer = new byte[bufferLength]; + while ((count = in.read(buffer, 0, bufferLength)) != -1) { + out.write(buffer, 0, count); + } + out.flush(); + } + } + } + + /** + * 删除文件(夹)和空文件夹 + */ + private void deleteDirectoryLegacyIO(File file) { + File[] list = file.listFiles(); //无法做到list多层文件夹数据 + if (list != null) { + for (File temp : list) { //先去递归删除子文件夹及子文件 + deleteDirectoryLegacyIO(temp); //注意这里是递归调用 + } + } + if (file.delete()) { //再删除自己本身的文件夹 + System.out.printf("删除成功 : %s%n", file); + } else { + System.err.printf("删除失败 : %s%n", file); + } + } + + /** + * 删除文件 + * + * @param filePathAndName 指定得路径 + */ + public static void delFile(String filePathAndName) { + try { + String filePath = filePathAndName; + filePath = filePath.toString(); + File myDelFile = new File(filePath); + myDelFile.delete(); + } catch (Exception e) { + System.out.println("删除文件操作出错"); + e.printStackTrace(); + } + } } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/EventDetailServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/EventDetailServiceImpl.java index 1ce21d501..28f0e136f 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/EventDetailServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/EventDetailServiceImpl.java @@ -1,8 +1,12 @@ package com.njcn.event.service.Impl; import cn.hutool.core.date.DateUtil; +import cn.hutool.db.Page; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.service.EventDetailService; +import com.njcn.influxdb.param.InfluxDBPublicParam; +import com.njcn.influxdb.utils.InfluxDBCommUtils; import com.njcn.influxdb.utils.InfluxDbUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -110,7 +114,6 @@ public class EventDetailServiceImpl implements EventDetailService { InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); List eventDetailList = influxDBResultMapper.toPOJO(result, EventDetail.class); - return eventDetailList; } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/ReportController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/ReportController.java new file mode 100644 index 000000000..a2b73ad75 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/ReportController.java @@ -0,0 +1,1939 @@ +package com.njcn.event.service.Impl;//package com.njcn.event.service.Impl; +// +//import java.io.ByteArrayInputStream; +//import java.io.File; +//import java.io.FileInputStream; +//import java.io.FileOutputStream; +//import java.io.IOException; +//import java.io.InputStream; +//import java.io.OutputStream; +//import java.io.UnsupportedEncodingException; +//import java.math.BigInteger; +//import java.net.URLEncoder; +//import java.text.DecimalFormat; +//import java.text.SimpleDateFormat; +//import java.util.ArrayList; +//import java.util.Collections; +//import java.util.Comparator; +//import java.util.Date; +//import java.util.List; +//import java.util.Properties; +// +//import javax.annotation.Resource; +//import javax.servlet.http.HttpServletRequest; +//import javax.servlet.http.HttpServletResponse; +//import javax.servlet.http.HttpSession; +// +//import com.njcn.pojo.data.WaveSvg; +//import org.apache.commons.lang3.StringUtils; +//import org.apache.poi.openxml4j.exceptions.InvalidFormatException; +//import org.apache.poi.util.Units; +//import org.apache.poi.xwpf.usermodel.XWPFDocument; +//import org.apache.poi.xwpf.usermodel.XWPFParagraph; +//import org.apache.poi.xwpf.usermodel.XWPFRun; +//import org.apache.poi.xwpf.usermodel.XWPFTable; +//import org.apache.poi.xwpf.usermodel.XWPFTableRow; +//import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth; +//import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Controller; +//import org.springframework.util.CollectionUtils; +//import org.springframework.web.bind.annotation.GetMapping; +//import org.springframework.web.bind.annotation.PostMapping; +//import org.springframework.web.bind.annotation.RequestMapping; +//import org.springframework.web.bind.annotation.RequestMethod; +//import org.springframework.web.bind.annotation.RequestParam; +//import org.springframework.web.bind.annotation.ResponseBody; +// +//import com.njcn.enums.LogTypeEnum; +//import com.njcn.mapper.advanced.RangeMapper; +//import com.njcn.mapper.configuration.RptAssMapper; +//import com.njcn.mapper.configuration.RptDataMapper; +//import com.njcn.mapper.configuration.RptPloyMapper; +//import com.njcn.pojo.advanced.EventAssObj; +//import com.njcn.pojo.commons.DatePojo; +//import com.njcn.pojo.commons.EventEigDetail; +//import com.njcn.pojo.commons.EventInfoDetail; +//import com.njcn.pojo.commons.HttpResult; +//import com.njcn.pojo.commons.RedisDB; +//import com.njcn.pojo.commons.ReportAreaPojo; +//import com.njcn.pojo.commons.ReportMonitorPojo; +//import com.njcn.pojo.commons.WaveData; +//import com.njcn.pojo.commons.area.Area; +//import com.njcn.pojo.commons.area.AreaGeneral; +//import com.njcn.pojo.commons.area.Iec28; +//import com.njcn.pojo.commons.area.Interval; +//import com.njcn.pojo.commons.area.Voltage; +//import com.njcn.pojo.commons.device.AnalyzeInfo; +//import com.njcn.pojo.commons.device.DeviceValue; +//import com.njcn.pojo.commons.device.EventCause; +//import com.njcn.pojo.commons.device.EventChance; +//import com.njcn.pojo.commons.device.EventDataList; +//import com.njcn.pojo.commons.device.EventDensity; +//import com.njcn.pojo.commons.device.EventTypeList; +//import com.njcn.pojo.commons.device.LineInfo; +//import com.njcn.pojo.configuration.RptPloy; +//import com.njcn.pojo.data.EventDetail; +//import com.njcn.pojo.data.LineMaps; +//import com.njcn.pojo.user.Depts; +//import com.njcn.pojo.wave.WaveDataDetail; +//import com.njcn.service.advanced.RangeService; +//import com.njcn.service.commons.IWaveService; +//import com.njcn.service.configuration.DeviceService; +//import com.njcn.service.configuration.ReportService; +//import com.njcn.service.data.EventDetailService; +//import com.njcn.service.log.UserLogDetailService; +//import com.njcn.shiro.token.TokenManager; +//import com.njcn.utils.AppConfig; +//import com.njcn.utils.ClearPathUtil; +//import com.njcn.utils.InstantiateUtil; +//import com.njcn.utils.PubUtils; +//import com.njcn.utils.UserUtil; +//import com.njcn.utils.redis.JedisManager; +//import com.pqs9200.pojo.commons.device.DevMapInfo; +//import com.pqs9200.service.area.IAreaService; +//import com.pqs9200.service.data.IOverviewServer; +//import com.pqs9200.utils.WordUtil; +//import com.pqs9200.utils.WordUtils; +// +//import net.sf.json.JSONArray; +//import net.sf.json.JSONObject; +//import sun.misc.BASE64Decoder; +// +//@Controller +//@RequestMapping("report") +//public class ReportController { +// @Resource +// private RptDataMapper rptDataMapper; +// +// @Resource +// private RptPloyMapper rptPloyMapper; +// +// @Resource +// private RptAssMapper rptAssMapper; +// +// @Resource +// private ReportService getreportInfo; +// +// @Autowired +// private ReportService reportService; +// +// @Autowired +// private IAreaService areaService; +// +// @Autowired +// private IOverviewServer iOverviewServer; +// +// @Resource +// UserLogDetailService userLog; +// +// @Autowired +// private RangeMapper rangeMapper; +// +// @Autowired +// private RangeService rangeService; +// +// @Autowired +// private EventDetailService eventDetailService; +// +// @Autowired +// private IWaveService waveService; +// @Autowired +// private AppConfig appConfig; +// // 日志记录 +// private static final Logger logger = LoggerFactory.getLogger(DeviceController.class); +// /** +// * 缓存每个方法查询的结果,缓存时间为半小时 +// *

+// * key:方法名+参数值(参数为对象时,约定某个属性值) +// */ +// @Autowired +// private JedisManager jedisManager; +// +// @Autowired +// private DeviceService deviceInfo; +// +// @Resource +// private UserUtil userUtil; +// +// @Autowired +// private UserLogDetailService userLogDetailService; +// +// private InstantiateUtil instantiateUtil; +// private InstantiateUtil jsonArrayInstantiateUtil; +// private InstantiateUtil stringInstantiateUtil; +// +// public ReportController() { +// instantiateUtil = new InstantiateUtil<>(); +// jsonArrayInstantiateUtil = new InstantiateUtil<>(); +// stringInstantiateUtil = new InstantiateUtil<>(); +// } +// +// /** +// * 获取模板引擎 +// * +// * @return +// */ +// @PostMapping("monitorTemplate") +// @ResponseBody +// public HttpResult monitorTemplate() { +// HttpResult result; +// List datas; +// datas = reportService.getTemplate(Integer.valueOf(0)); +// if (CollectionUtils.isEmpty(datas)) { +// result = PubUtils.assignmentResult(null, 500, "沒有对应的模板"); +// } else { +// result = PubUtils.assignmentResult(datas, 200, "获取模板成功"); +// } +// return result; +// } +// +// @PostMapping("monitor") +// @ResponseBody +// public HttpResult monitor(HttpServletRequest request, String startTime, String endTime, String lineIndex, String lineName, boolean jcdxq, +// boolean zjsjlb, boolean zjsjssbx, boolean zjmdbg, boolean zjmdtx, boolean zjsjditic, boolean zjsjdf47, boolean glfbzjfz, +// boolean glfbcxsj, boolean yftjbg, boolean yftjtx, boolean zjyybg, boolean zjyytx, boolean zjlxbg, boolean zjlxtx) throws Exception { +// HttpResult result; +// List reList = new ArrayList<>(); +// ReportMonitorPojo reportMonitorPojo = getMonitorChoose(request, startTime, endTime, lineIndex, lineName, jcdxq, zjsjlb, zjsjssbx, zjmdbg, zjmdtx, zjsjditic, zjsjdf47, glfbzjfz, glfbcxsj, yftjbg, yftjtx, zjyybg, zjyytx, zjlxbg, zjlxtx); +// DatePojo datePojo; +// datePojo = PubUtils.validateDate(reportMonitorPojo.getStartTime(), reportMonitorPojo.getEndTime(), "monitor"); +// String userIndex = TokenManager.getUserId(); +// if (!datePojo.getValidity()) { +// result = PubUtils.assignmentResult(null, 500, "解析前台传递的时间有误"); +// return result; +// } +// try { +// /* 监测点详情数据获取 */ +// LineInfo lineInfo; +// if (reportMonitorPojo.isJcdxq()) { +// lineInfo = deviceInfo.getDeviceInfo(Long.valueOf(reportMonitorPojo.getLineIndex())); +// JSONObject lineO = JSONObject.fromObject(lineInfo); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "lineInfo", instantiateUtil.stringInstantiate(lineO), RedisDB.SHORT_TIME); +// } +// /* 暂降事件列表 */ +// List analyzeInfos = null; +// if (reportMonitorPojo.isZjsjlb()) { +// analyzeInfos = deviceInfo.queryanalyzeinfo(datePojo.getStartTime(), datePojo.getEndTime(), +// reportMonitorPojo.getLineIndex()); +// JSONArray anArray = JSONArray.fromObject(analyzeInfos); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "analyzeInfos", jsonArrayInstantiateUtil.stringInstantiate(anArray), +// RedisDB.SHORT_TIME); +// } +// /* 暂降事件波形 */ +// List arry = new ArrayList<>(); +// int waveNum = 0; +// if (reportMonitorPojo.isZjsjssbx()) { +// List analyzeInfo = null; +// analyzeInfo = deviceInfo.queryanalyzeinfo(datePojo.getStartTime(), datePojo.getEndTime(), +// reportMonitorPojo.getLineIndex()); +// for (int i = 0; i < analyzeInfo.size(); i++) { +// if (Integer.parseInt(analyzeInfo.get(i).getFileFlag()) == 0) { +// analyzeInfo.remove(i); +// } +// } +// if (analyzeInfo.size() > 10) { +// waveNum = 10; +// } else { +// waveNum = analyzeInfo.size(); +// } +// for (int i = 0; i < waveNum; i++) { +// List shunS = new ArrayList<>(); +// WaveData waveData = waveService.getWavedata(analyzeInfo.get(i).getEventDetailIndex(), 1); +// if (waveData != null) { +// if (waveData.getiPhasic() > 0) { +// //数据筛选,如果是双路电压的话,会存在2个波形数据 +// List waveDataDetails = waveService.filteWaveData(waveData); +// if (waveData.getSunData().size() == 0) { +// +// } else { +// String time = waveData.getTime(); +// String title = "监测点名称:" + waveData.getLineName() + " 发生时刻:" + time + "特征幅值:" + waveData.getEventValue() + " 持续时间:" + waveData.getPersistTime() + "s"; +// if (waveDataDetails.size() == 1) { +// shunS.add(waveService.createShunSTitle(title, waveDataDetails.get(0))); +// } else { +// shunS.add(waveService.createShunSTitle(title, waveDataDetails.get(0))); +// for (int n = 1; n < waveDataDetails.size(); n++) { +// shunS.add(waveService.createShunS(waveDataDetails.get(n))); +// } +// } +// +// } +// arry.add(shunS); +// } +// } +// } +// } +// /* 暂降密度数据获取 */ +// List eventDensities = new ArrayList<>(); +// if (reportMonitorPojo.isZjmdtx()) { +// eventDensities = deviceInfo.getEventDensity(datePojo.getStartTime(), datePojo.getEndTime(), +// reportMonitorPojo.getLineIndex()); +// } +// List eventDisdip; +// List ec411; +// List ec28; +// if (reportMonitorPojo.isZjmdbg()) { +// eventDisdip = deviceInfo.getEventDisdip(datePojo.getStartTime(), datePojo.getEndTime(), +// reportMonitorPojo.getLineIndex()); +// ec411 = deviceInfo.getIEC411(datePojo.getStartTime(), datePojo.getEndTime(), +// reportMonitorPojo.getLineIndex()); +// ec28 = deviceInfo.getIEC28(datePojo.getStartTime(), datePojo.getEndTime(), +// reportMonitorPojo.getLineIndex()); +// JSONArray evArray = JSONArray.fromObject(eventDisdip); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "eventDisdip", jsonArrayInstantiateUtil.stringInstantiate(evArray), +// RedisDB.SHORT_TIME); +// JSONArray ec4Array = JSONArray.fromObject(ec411); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "ec411", jsonArrayInstantiateUtil.stringInstantiate(ec4Array), RedisDB.SHORT_TIME); +// JSONArray ec2Array = JSONArray.fromObject(ec28); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "ec28", jsonArrayInstantiateUtil.stringInstantiate(ec2Array), RedisDB.SHORT_TIME); +// } +// /* 暂降事件点图 */ +// List eventDataLists = new ArrayList<>(); +// if (reportMonitorPojo.isZjsjditic() || reportMonitorPojo.isZjsjdf47()) { +// eventDataLists = deviceInfo.getEventDataList(datePojo.getStartTime(), datePojo.getEndTime(), +// reportMonitorPojo.getLineIndex()); +// } +// /* 概率分布 */ +// EventChance eventChance = new EventChance(); +// if (reportMonitorPojo.isGlfbzjfz() || reportMonitorPojo.isGlfbcxsj()) { +// eventChance = deviceInfo.getEventChance(datePojo.getStartTime(), datePojo.getEndTime(), +// reportMonitorPojo.getLineIndex()); +// } +// /* 月份统计图 */ +// List intervals = new ArrayList<>(); +// if (reportMonitorPojo.isYftjbg() || reportMonitorPojo.isYftjtx()) { +// intervals = deviceInfo.getEventTime(datePojo.getStartTime(), datePojo.getEndTime(), +// reportMonitorPojo.getLineIndex()); +// JSONArray inArray = JSONArray.fromObject(intervals); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "intervals", jsonArrayInstantiateUtil.stringInstantiate(inArray), +// RedisDB.SHORT_TIME); +// } +// /* 暂降原因 */ +// List eventCauses = new ArrayList<>(); +// if (reportMonitorPojo.isZjyybg() || reportMonitorPojo.isZjyytx()) { +// eventCauses = deviceInfo.getEventCause(datePojo.getStartTime(), datePojo.getEndTime(), +// reportMonitorPojo.getLineIndex()); +// JSONArray caArray = JSONArray.fromObject(eventCauses); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "eventCauses", jsonArrayInstantiateUtil.stringInstantiate(caArray), +// RedisDB.SHORT_TIME); +// } +// /* 暂降类型 */ +// List eventTypeLists = new ArrayList<>(); +// if (reportMonitorPojo.isZjlxbg() || reportMonitorPojo.isZjlxtx()) { +// eventTypeLists = deviceInfo.getEventType(datePojo.getStartTime(), datePojo.getEndTime(), +// reportMonitorPojo.getLineIndex()); +// JSONArray tyArray = JSONArray.fromObject(eventTypeLists); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "eventTypeLists", jsonArrayInstantiateUtil.stringInstantiate(tyArray), +// RedisDB.SHORT_TIME); +// } +// JSONObject reportPojo = JSONObject.fromObject(reportMonitorPojo); +// String key = TokenManager.getUserId() + "reportPojo"; +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, key, instantiateUtil.stringInstantiate(reportPojo), RedisDB.SHORT_TIME); +// /* 将前台需要画图的数据返回 */ +// reList.add(eventDensities); +// reList.add(eventDataLists); +// reList.add(eventChance); +// reList.add(intervals); +// reList.add(eventCauses); +// reList.add(eventTypeLists); +// reList.add(arry); +// result = PubUtils.assignmentResult(reList, 200, "获取监测点图表数据成功"); +// } catch (Exception e) { +// logger.error("获取监测点图表数据异常,异常为:" + e.toString()); +// result = PubUtils.assignmentResult(null, 500, "获取监测点图表数据异常"); +// } +// +// return result; +// } +// +// /** +// * 根据用户页面的选择,指定我们需要查询的数据 +// * +// * @param request 请求 +// */ +// private ReportMonitorPojo getMonitorChoose(HttpServletRequest request, String startTime, String endTime, String lineIndex, String lineName, boolean jcdxq, +// boolean zjsjlb, boolean zjsjssbx, boolean zjmdbg, boolean zjmdtx, boolean zjsjditic, boolean zjsjdf47, boolean glfbzjfz, +// boolean glfbcxsj, boolean yftjbg, boolean yftjtx, boolean zjyybg, boolean zjyytx, boolean zjlxbg, boolean zjlxtx) { +// ReportMonitorPojo reportMonitorPojo = new ReportMonitorPojo(); +// reportMonitorPojo.setJcdxq(Boolean.valueOf(jcdxq)); +// reportMonitorPojo.setZjsjlb(Boolean.valueOf(zjsjlb)); +// reportMonitorPojo.setZjsjssbx(Boolean.valueOf(zjsjssbx)); +// reportMonitorPojo.setZjmdbg(Boolean.valueOf(zjmdbg)); +// reportMonitorPojo.setZjmdtx(Boolean.valueOf(zjmdtx)); +// reportMonitorPojo.setZjsjditic(Boolean.valueOf(zjsjditic)); +// reportMonitorPojo.setZjsjdf47(Boolean.valueOf(zjsjdf47)); +// reportMonitorPojo.setGlfbzjfz(Boolean.valueOf(glfbzjfz)); +// reportMonitorPojo.setGlfbcxsj(Boolean.valueOf(glfbcxsj)); +// reportMonitorPojo.setYftjbg(Boolean.valueOf(yftjbg)); +// reportMonitorPojo.setYftjtx(Boolean.valueOf(yftjtx)); +// reportMonitorPojo.setZjyybg(Boolean.valueOf(zjyybg)); +// reportMonitorPojo.setZjyytx(Boolean.valueOf(zjyytx)); +// reportMonitorPojo.setZjlxbg(Boolean.valueOf(zjlxbg)); +// reportMonitorPojo.setZjlxtx(Boolean.valueOf(zjlxtx)); +// reportMonitorPojo.setStartTime(startTime); +// reportMonitorPojo.setEndTime(endTime); +// reportMonitorPojo.setLineIndex(lineIndex); +// reportMonitorPojo.setLineName(lineName); +// return reportMonitorPojo; +// +// } +// +// @PostMapping("exportReport") +// @ResponseBody +// public String exportReport(HttpServletRequest request, String densityImage, String iticImage, String f47Image, String eventValueImage, +// String persisttimeImage, String shunSImg, String timeImage, String causeImage, String typeImage, String startTime, String endTime) throws Exception { +// String userIndex = TokenManager.getUserId(); +// JSONObject jsonObject = instantiateUtil.deInstantiate(instantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, +// TokenManager.getUserId() + "reportPojo"))); +// ReportMonitorPojo reportMonitorPojo = (ReportMonitorPojo) JSONObject.toBean(jsonObject, +// ReportMonitorPojo.class); +// // 需要展示的图 +// if (reportMonitorPojo.isZjmdtx()) { +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "densityImage", stringInstantiateUtil.stringInstantiate(densityImage), RedisDB.SHORT_TIME); +// } +// if (reportMonitorPojo.isZjsjssbx()) { +// if (!shunSImg.equals("[]")) { +// JSONArray jsonArray = JSONArray.fromObject(shunSImg); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "shunSImage", jsonArrayInstantiateUtil.stringInstantiate(jsonArray), RedisDB.SHORT_TIME); +// } else { +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "shunSImage", jsonArrayInstantiateUtil.stringInstantiate(null), RedisDB.SHORT_TIME); +// } +// } +// if (reportMonitorPojo.isZjsjditic()) { +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "iticImage", stringInstantiateUtil.stringInstantiate(iticImage), RedisDB.SHORT_TIME); +// } +// if (reportMonitorPojo.isZjsjdf47()) { +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "f47Image", stringInstantiateUtil.stringInstantiate(f47Image), RedisDB.SHORT_TIME); +// } +// if (reportMonitorPojo.isGlfbzjfz()) { +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "eventValueImage", stringInstantiateUtil.stringInstantiate(eventValueImage), +// RedisDB.SHORT_TIME); +// } +// if (reportMonitorPojo.isGlfbcxsj()) { +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "persisttimeImage", stringInstantiateUtil.stringInstantiate(persisttimeImage), +// RedisDB.SHORT_TIME); +// } +// if (reportMonitorPojo.isYftjtx()) { +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "timeImage", stringInstantiateUtil.stringInstantiate(timeImage), RedisDB.SHORT_TIME); +// } +// if (reportMonitorPojo.isZjyytx()) { +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "causeImage", stringInstantiateUtil.stringInstantiate(causeImage), RedisDB.SHORT_TIME); +// } +// if (reportMonitorPojo.isZjlxtx()) { +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "typeImage", stringInstantiateUtil.stringInstantiate(typeImage), RedisDB.SHORT_TIME); +// } +// userLogDetailService.saveUserLog(TokenManager.getToken().getUserIndex(), TokenManager.getToken().getLoginName(), +// "生成监测点报告", "成功", appConfig.getSystemFlag(), PubUtils.getIpAddr(request), +// LogTypeEnum.BUSSINESS.toString(), 0); +// return "success"; +// } +// +// @GetMapping("downMonitorReport") +// public void downMonitorReport(HttpServletResponse response, HttpServletRequest request, String name) throws Exception { +// String userIndex = TokenManager.getUserId(); +// JSONObject jsonObject = instantiateUtil.deInstantiate(instantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, +// TokenManager.getUserId() + "reportPojo"))); +// jedisManager.hdel(RedisDB.SHORT_TIME_QUERY, userIndex, TokenManager.getUserId() + "reportPojo"); +// ReportMonitorPojo reportMonitorPojo = (ReportMonitorPojo) JSONObject.toBean(jsonObject, +// ReportMonitorPojo.class); +// int one = 1; +// // 开始做文档 +// XWPFDocument document = new XWPFDocument(); +// // 设定标题格式 +// WordUtils.setHeadingStyle(document); +// // 添加标题 +// XWPFParagraph titleParagraph = WordUtils.getCenterParagraph(document); +// WordUtils.addLine(titleParagraph, 11); +// // 设置段落居中 +// XWPFRun titleParagraphRun = titleParagraph.createRun(); +// Depts deptTmp = userUtil.getCurrentDept(); +// String titlename = deptTmp.getDeptsName(); +// WordUtils.addParagraph(titleParagraphRun, "宋体", 15, "000000", titlename, true); +// WordUtils.addLine(titleParagraph, 3); +// XWPFRun titleParagraphBigRun = titleParagraph.createRun(); +// WordUtils.addParagraph(titleParagraphBigRun, "宋体", 36, "000000", "电压暂降事件分析报告", true); +// WordUtils.addLine(titleParagraph, 19); +// XWPFRun titleParagraphDateRun = titleParagraph.createRun(); +// WordUtils.addParagraph(titleParagraphDateRun, "宋体", 14, "000000", "日期:" + WordUtils.getRightNow(), true); +// titleParagraph.setPageBreak(true); +// // 段落 +// XWPFParagraph statisticsParagraph = WordUtils.getCenterParagraph(document); +// // 段前分页 +// statisticsParagraph.setPageBreak(true); +// XWPFRun statisticsRun = statisticsParagraph.createRun(); +// WordUtils.addParagraph(statisticsRun, "宋体", 24, "000000", "电压暂降事件分析报告", false); +// createTitle(document, "1. 引言", "标题 1", 0, 15); +// XWPFParagraph introductionContentParagraph = WordUtils.getLeftParagraph(document); +// // 首行缩进---段落 +// introductionContentParagraph.setIndentationFirstLine(200); +// XWPFRun introductionContentRun = introductionContentParagraph.createRun(); +// WordUtils.addParagraph(introductionContentRun, "宋体", 11, "000000", "对所选中区间内电压暂降事件进行分析,能够直观清晰查看相应的暂降事件信息。", +// false); +// createTitle(document, "2. 报告分析对象", "标题 1", 0, 15); +// XWPFParagraph objectContentParagraph = WordUtils.getLeftParagraph(document); +// objectContentParagraph.setIndentationFirstLine(200); +// XWPFRun objectContentRun = objectContentParagraph.createRun(); +// WordUtils.addParagraph(objectContentRun, "宋体", 11, "000000", reportMonitorPojo.getLineName(), false); +// createTitle(document, "3. 报告分析时间", "标题 1", 0, 15); +// XWPFParagraph timeContentParagraph = WordUtils.getLeftParagraph(document); +// timeContentParagraph.setIndentationFirstLine(200); +// XWPFRun timeContentRun = timeContentParagraph.createRun(); +// WordUtils.addParagraph(timeContentRun, "宋体", 11, "000000", +// reportMonitorPojo.getStartTime() + " 至 " + reportMonitorPojo.getEndTime(), false); +// createTitle(document, "4. 汇总信息", "标题 1", 0, 15); +// /* 填充监测点详情 */ +// if (reportMonitorPojo.isJcdxq()) { +// createTitle(document, "4." + one + " 监测点信息", "标题 2", 200, 11); +// // 监测点信息 +// XWPFTable monitorInfo = createTable(document); +// XWPFParagraph monitorInfoExcelParagraph = WordUtils.getCenterParagraph(document); +// LineInfo lineInfo; +// JSONObject jo = instantiateUtil.deInstantiate(instantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "lineInfo"))); +// lineInfo = (LineInfo) JSONObject.toBean(jo, LineInfo.class); +// // 表格第一行 +// insertRow(document, monitorInfo, monitorInfoExcelParagraph, true, "项目", "描述"); +// insertRow(document, monitorInfo, monitorInfoExcelParagraph, false, "监测点名称", lineInfo.getName()); +// insertRow(document, monitorInfo, monitorInfoExcelParagraph, false, "电压等级", lineInfo.getScale()); +// insertRow(document, monitorInfo, monitorInfoExcelParagraph, false, "PT变比", lineInfo.getPT()); +// insertRow(document, monitorInfo, monitorInfoExcelParagraph, false, "CT变比", lineInfo.getCT()); +// insertRow(document, monitorInfo, monitorInfoExcelParagraph, false, "协议容量", +// String.valueOf(lineInfo.getXYCMP())); +// insertRow(document, monitorInfo, monitorInfoExcelParagraph, false, "基准容量", +// String.valueOf(lineInfo.getJZCMP())); +// insertRow(document, monitorInfo, monitorInfoExcelParagraph, false, "设备容量", +// String.valueOf(lineInfo.getDEVCMP())); +// insertRow(document, monitorInfo, monitorInfoExcelParagraph, false, "最小短路容量", +// String.valueOf(lineInfo.getDLCMP())); +// insertRow(document, monitorInfo, monitorInfoExcelParagraph, false, "接线方式", lineInfo.getPttype()); +// one++; +// } +// /* 暂降事件列表 */ +// List analyzeInfos = null; +// if (reportMonitorPojo.isZjsjlb()) { +// createTitle(document, "4." + one + " 暂降事件列表", "标题 2", 200, 11); +// XWPFTable sum = createTable(document); +// XWPFParagraph sumExcelParagraph = WordUtils.getCenterParagraph(document); +// JSONArray ja = jsonArrayInstantiateUtil.deInstantiate(jsonArrayInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "analyzeInfos"))); +// analyzeInfos = (List) JSONArray.toCollection(ja, AnalyzeInfo.class); +// insertRow(document, sum, sumExcelParagraph, true, "序号", "暂降发生时刻", "暂降幅值(%)", "持续时间(s)", "暂降类型", "暂降原因", +// "严重度"); +// if (analyzeInfos.isEmpty()) { +// insertRow(document, sum, sumExcelParagraph, false, "", "", "", "", "", "", ""); +// } else { +// for (int i = 0; i < analyzeInfos.size(); i++) { +// insertRow(document, sum, sumExcelParagraph, false, String.valueOf(i + 1), +// analyzeInfos.get(i).getTime(), analyzeInfos.get(i).getEventvaule(), +// analyzeInfos.get(i).getPersisttime(), analyzeInfos.get(i).getType(), +// analyzeInfos.get(i).getReason(), String.valueOf(analyzeInfos.get(i).getYzd())); +// } +// } +// one++; +// } +// /* 暂降事件波形 */ +// if (reportMonitorPojo.isZjsjssbx()) { +// createTitle(document, "4." + one + " 暂降事件图形", "标题 2", 200, 11); +// int two = 1; +// if (reportMonitorPojo.isZjsjssbx()) { +// List analyzeInfo = null; +// JSONArray ja = jsonArrayInstantiateUtil.deInstantiate(jsonArrayInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "analyzeInfos"))); +// analyzeInfo = (List) JSONArray.toCollection(ja, AnalyzeInfo.class); +// for (int i = 0; i < analyzeInfo.size(); i++) { +// if (Integer.parseInt(analyzeInfo.get(i).getFileFlag()) == 0) { +// analyzeInfo.remove(i); +// } +// } +// JSONArray shunSImages = jsonArrayInstantiateUtil.deInstantiate(jsonArrayInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "shunSImage"))); +// if (shunSImages != null) { +// for (int i = 0; i < shunSImages.size(); i++) { +// if (Integer.parseInt(analyzeInfo.get(i).getFileFlag()) == 1) { +// createTitle(document, "事件" + (i + 1) + ":" + analyzeInfo.get(i).getTime(), "标题 3", 400, 11); +// List shunSImage; +// shunSImage = (List) JSONArray.toCollection((JSONArray) shunSImages.get(i)); +// for (int j = 0; j < shunSImage.size(); j++) { +// createPic(document, shunSImage.get(j), "暂降事件图形"); +// } +// } +// } +// +// } else { +// if (analyzeInfos.size() > 10) { +// two = 10; +// } else { +// two = analyzeInfos.size(); +// } +// for (int i = 0; i < two; i++) { +// if (Integer.parseInt(analyzeInfos.get(i).getFileFlag()) == 1) { +// createTitle(document, "事件" + (i + 1) + ":" + analyzeInfos.get(i).getTime() + "(未找到波形文件)", "标题 3", 400, 11); +// } +// } +// } +// +// } +// one++; +// } +// /* 暂降事件点图 */ +// if (reportMonitorPojo.isZjsjditic() || reportMonitorPojo.isZjsjdf47()) { +// createTitle(document, "4." + one + " 暂降事件点图", "标题 2", 200, 11); +// int two = 1; +// if (reportMonitorPojo.isZjsjditic()) { +// createTitle(document, "4." + one + "." + two + " ITIC曲线", "标题 3", 400, 11); +// String iticImage = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "iticImage"))); +// createPic(document, iticImage, "ITIC曲线"); +// two++; +// } +// if (reportMonitorPojo.isZjsjdf47()) { +// createTitle(document, "4." + one + "." + two + " F47曲线", "标题 3", 400, 11); +// String f47Image = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "f47Image"))); +// createPic(document, f47Image, "F47曲线"); +// } +// one++; +// } +// /* 暂降密度 */ +// if (reportMonitorPojo.isZjmdtx() || reportMonitorPojo.isZjmdbg()) { +// createTitle(document, "4." + one + " 暂降密度", "标题 2", 200, 11); +// int two = 1; +// if (reportMonitorPojo.isZjmdtx()) { +// createTitle(document, "4." + one + "." + two + " 暂降密度点图", "标题 3", 400, 11); +// String densityImage = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "densityImage"))); +// createPic(document, densityImage, "暂降密度点图"); +// two++; +// } +// if (reportMonitorPojo.isZjmdbg()) { +// createTitle(document, "4." + one + "." + two + " DISDIP表格:国际发配电联盟(UNIPEDE)", "标题 3", 400, 11); +// XWPFTable disdip = createTable(document); +// XWPFParagraph disdipExcelParagraph = WordUtils.getCenterParagraph(document); +// List eventDisdip; +// JSONArray arrayeventDisdip = jsonArrayInstantiateUtil.deInstantiate(jsonArrayInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "eventDisdip"))); +// eventDisdip = (List) JSONArray.toCollection(arrayeventDisdip, ArrayList.class); +// insertRow(document, disdip, disdipExcelParagraph, true, "剩余电压", "20ms", "100ms", "500ms", "1s", "3s", +// "20s", "60s", "180s"); +// if (eventDisdip.isEmpty()) { +// insertRow(document, disdip, disdipExcelParagraph, false, "", "", "", "", "", "", "", "", ""); +// } else { +// for (List list : eventDisdip) { +// insertRow(document, disdip, disdipExcelParagraph, false, list.get(0).toString(), +// list.get(1).toString(), list.get(2).toString(), list.get(3).toString(), +// list.get(4).toString(), list.get(5).toString(), list.get(6).toString(), +// list.get(7).toString(), list.get(8).toString()); +// } +// } +// two++; +// createTitle(document, "4." + one + "." + two + " IEC 61000-4-11:(用电终端的电压暂降抗度)", "标题 3", 400, 11); +// XWPFTable ec411Table = createTable(document); +// XWPFParagraph ec411TableExcelParagraph = WordUtils.getCenterParagraph(document); +// List ec411; +// JSONArray arrayec411 = jsonArrayInstantiateUtil.deInstantiate(jsonArrayInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "ec411"))); +// ec411 = (List) JSONArray.toCollection(arrayec411, ArrayList.class); +// insertRow(document, ec411Table, ec411TableExcelParagraph, true, "剩余电压", "10~20ms", "20~100ms", +// "0.1~0.2s", "0.2~0.5s", "0.5~1s", ">1s"); +// if (ec411.isEmpty()) { +// insertRow(document, ec411Table, ec411TableExcelParagraph, false, "", "", "", "", "", "", ""); +// } else { +// for (List list : ec411) { +// insertRow(document, ec411Table, ec411TableExcelParagraph, false, list.get(0).toString(), +// list.get(1).toString(), list.get(2).toString(), list.get(3).toString(), +// list.get(4).toString(), list.get(5).toString(), list.get(6).toString()); +// } +// } +// two++; +// createTitle(document, "4." + one + "." + two + " IEC 61000-2-8:(公共电网电压暂降测量统计)", "标题 3", 400, 11); +// XWPFTable ec28Table = createTable(document); +// XWPFParagraph ec28TableExcelParagraph = WordUtils.getCenterParagraph(document); +// List ec28; +// JSONArray arrayec28 = jsonArrayInstantiateUtil.deInstantiate(jsonArrayInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "ec28"))); +// ec28 = (List) JSONArray.toCollection(arrayec28, ArrayList.class); +// insertRow(document, ec28Table, ec28TableExcelParagraph, true, "剩余电压", "0.02~0.1s", "0.1~0.25s", +// "0.25~0.5s", "0.5~1s", "1~3s", "3~20s", "20~60s", "60~180s"); +// if (ec28.isEmpty()) { +// insertRow(document, ec28Table, ec28TableExcelParagraph, false, "", "", "", "", "", "", "", "", ""); +// } else { +// for (List list : ec28) { +// insertRow(document, ec28Table, ec28TableExcelParagraph, false, list.get(0).toString(), +// list.get(1).toString(), list.get(2).toString(), list.get(3).toString(), +// list.get(4).toString(), list.get(5).toString(), list.get(6).toString(), +// list.get(7).toString(), list.get(8).toString()); +// } +// } +// } +// one++; +// } +// /* 概率分布 */ +// if (reportMonitorPojo.isGlfbcxsj() || reportMonitorPojo.isGlfbzjfz()) { +// createTitle(document, "4." + one + " 暂降幅值概率分布图", "标题 2", 200, 11); +// int two = 1; +// if (reportMonitorPojo.isGlfbzjfz()) { +// createTitle(document, "4." + one + "." + two + " 暂降幅值的概率分函数", "标题 3", 400, 11); +// String eventValueImage = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "eventValueImage"))); +// createPic(document, eventValueImage, "暂降幅值的概率分布函数"); +// two++; +// } +// if (reportMonitorPojo.isGlfbcxsj()) { +// createTitle(document, "4." + one + "." + two + " 持续时间的概率分函数", "标题 3", 400, 11); +// String persisttimeImage = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "persisttimeImage"))); +// createPic(document, persisttimeImage, "持续时间的概率分函数"); +// } +// one++; +// } +// /* 月份统计 */ +// if (reportMonitorPojo.isYftjtx() || reportMonitorPojo.isYftjbg()) { +// createTitle(document, "4." + one + " 月份统计", "标题 2", 200, 11); +// int two = 1; +// if (reportMonitorPojo.isYftjtx()) { +// createTitle(document, "4." + one + "." + two + " 月份统计图", "标题 3", 400, 11); +// String timeImage = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "timeImage"))); +// createPic(document, timeImage, "月份统计图"); +// two++; +// } +// if (reportMonitorPojo.isYftjbg()) { +// createTitle(document, "4." + one + "." + two + " 月份统计表格", "标题 3", 400, 11); +// XWPFTable intervalsTable = createTable(document); +// XWPFParagraph intervalsTableExcelParagraph = WordUtils.getCenterParagraph(document); +// List intervals; +// JSONArray arrayintervals = jsonArrayInstantiateUtil.deInstantiate(jsonArrayInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "intervals"))); +// intervals = (List) JSONArray.toCollection(arrayintervals, Interval.class); +// insertRow(document, intervalsTable, intervalsTableExcelParagraph, true, "月份", "电压暂降次数"); +// if (intervals.isEmpty()) { +// insertRow(document, intervalsTable, intervalsTableExcelParagraph, false, "", ""); +// } else { +// for (Interval interval : intervals) { +// insertRow(document, intervalsTable, intervalsTableExcelParagraph, false, interval.getMonth(), +// String.valueOf(interval.getTimes())); +// } +// } +// } +// one++; +// } +// /* 原因统计 */ +// if (reportMonitorPojo.isZjyytx() || reportMonitorPojo.isZjyybg()) { +// createTitle(document, "4." + one + " 原因统计", "标题 2", 200, 11); +// int two = 1; +// if (reportMonitorPojo.isZjyytx()) { +// createTitle(document, "4." + one + "." + two + " 原因统计图", "标题 3", 400, 11); +// String causeImage = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "causeImage"))); +// createPic(document, causeImage, "原因统计图"); +// two++; +// } +// if (reportMonitorPojo.isZjyybg()) { +// createTitle(document, "4." + one + "." + two + " 原因统计表格", "标题 3", 400, 11); +// XWPFTable causeTable = createTable(document); +// XWPFParagraph causeTableExcelParagraph = WordUtils.getCenterParagraph(document); +// List eventCauses; +// JSONArray arrayeventCauses = jsonArrayInstantiateUtil.deInstantiate(jsonArrayInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "eventCauses"))); +// eventCauses = (List) JSONArray.toCollection(arrayeventCauses, EventCause.class); +// insertRow(document, causeTable, causeTableExcelParagraph, true, "暂降原因", "电压暂降次数"); +// if (eventCauses.isEmpty()) { +// insertRow(document, causeTable, causeTableExcelParagraph, false, "", ""); +// } else { +// for (EventCause eventCause : eventCauses) { +// insertRow(document, causeTable, causeTableExcelParagraph, false, eventCause.getCause(), +// String.valueOf(eventCause.getCount())); +// } +// } +// } +// one++; +// } +// /* 类型统计 */ +// if (reportMonitorPojo.isZjlxtx() || reportMonitorPojo.isZjlxbg()) { +// createTitle(document, "4." + one + " 类型统计", "标题 2", 200, 11); +// int two = 1; +// if (reportMonitorPojo.isZjlxtx()) { +// createTitle(document, "4." + one + "." + two + " 类型统计图", "标题 3", 400, 11); +// String typeImage = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "typeImage"))); +// createPic(document, typeImage, "类型统计图"); +// two++; +// } +// if (reportMonitorPojo.isZjlxbg()) { +// createTitle(document, "4." + one + "." + two + " 类型统计表格", "标题 3", 400, 11); +// XWPFTable typeTable = createTable(document); +// XWPFParagraph typeTableExcelParagraph = WordUtils.getCenterParagraph(document); +// List eventTypeLists = new ArrayList(); +// JSONArray arrayeventTypes = jsonArrayInstantiateUtil.deInstantiate(jsonArrayInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "eventTypeLists"))); +// eventTypeLists = (List) JSONArray.toCollection(arrayeventTypes, EventTypeList.class); +// insertRow(document, typeTable, typeTableExcelParagraph, true, "暂降类型", "电压暂降次数"); +// if (eventTypeLists.isEmpty()) { +// insertRow(document, typeTable, typeTableExcelParagraph, false, "", ""); +// } else { +// for (EventTypeList eventTypeList : eventTypeLists) { +// insertRow(document, typeTable, typeTableExcelParagraph, false, eventTypeList.getType(), +// String.valueOf(eventTypeList.getCount())); +// } +// } +// } +// } +// OutputStream out; +// try { +// response.setContentType("application/force-download");// 设置强制下载不打开 +// String agent = request.getHeader("User-Agent").toUpperCase(); // 获得浏览器信息并转换为大写 +// if (agent.indexOf("MSIE") > 0 || (agent.indexOf("GECKO") > 0 && agent.indexOf("RV:11") > 0)) { // IE浏览器和Edge浏览器 +// name = URLEncoder.encode(name, "UTF-8"); +// } else { // 其他浏览器 +//// name = new String(name.getBytes("UTF-8"), "iso-8859-1"); +// name = URLEncoder.encode(name, "UTF-8"); +// } +// response.addHeader("Content-Disposition", "attachment;fileName=" + name + ".docx");// 设置文件名 +// +// out = response.getOutputStream(); +// document.write(out); +// document.close(); +// out.close(); +// } catch (Exception e) { +// logger.error(e.getMessage()); +// } +// } +// +// /** +// * 创建标题 +// * +// * @param document 文档 +// * @param message 标题内容 +// * @param style 标题等级 +// * @param line 缩进 +// * @param fontSize 字体大小 +// */ +// public static void createTitle(XWPFDocument document, String message, String style, int line, int fontSize) { +// XWPFParagraph summaeTableParagraph = WordUtils.getLeftParagraph(document); +// summaeTableParagraph.setStyle(style); +// summaeTableParagraph.setIndentationFirstLine(line); +// XWPFRun summaeTableRun = summaeTableParagraph.createRun(); +// WordUtils.addParagraph(summaeTableRun, "宋体", fontSize, "000000", message, false); +// } +// +// /** +// * 创建图片在word中 +// * +// * @param document 文档 +// * @param image 图片base64 +// * @param name 图片名 +// * @throws IOException +// * @throws InvalidFormatException +// */ +// public void createPic(XWPFDocument document, String image, String name) throws IOException, InvalidFormatException { +// XWPFParagraph picParagraph = WordUtils.getCenterParagraph(document); +// XWPFRun createRun = picParagraph.createRun(); +// byte[] base64Info = decodeBase64(image); +// InputStream in = new ByteArrayInputStream(base64Info); +// createRun.addPicture(in, 5, name, Units.toEMU(410), Units.toEMU(170)); +// } +// +// /** +// * 创建地图 +// * +// * @param document 文档 +// * @param image 图片base64 +// * @param name 图片名 +// * @throws IOException +// * @throws InvalidFormatException +// */ +// public void createMap(XWPFDocument document, String image, String name) throws IOException, InvalidFormatException { +// XWPFParagraph picParagraph = WordUtils.getCenterParagraph(document); +// XWPFRun createRun = picParagraph.createRun(); +// byte[] base64Info = decodeBase64(image); +// InputStream in = new ByteArrayInputStream(base64Info); +// createRun.addPicture(in, 5, name, Units.toEMU(410), Units.toEMU(210)); +// } +// +// /** +// * 创建表格 +// * +// * @param document +// * @return +// */ +// public static XWPFTable createTable(XWPFDocument document) { +// XWPFTable summaTable = document.createTable(); +// // 列宽自动分割 +// CTTblWidth summaTableWidth = summaTable.getCTTbl().addNewTblPr().addNewTblW(); +// summaTableWidth.setType(STTblWidth.DXA); +// summaTableWidth.setW(BigInteger.valueOf(8160)); +// return summaTable; +// } +// +// /** +// * 表格插入行数据 +// * +// * @param document 文档 +// * @param table 表格 +// * @param head 是否是表头 +// * @param values 数据内容 +// */ +// public static void insertRow(XWPFDocument document, XWPFTable table, XWPFParagraph excelParagraph, boolean head, +// String... values) { +// if (head) { +// XWPFTableRow summaTableRowOne = table.getRow(0); +// WordUtils.setExcelHeadContent(excelParagraph, summaTableRowOne, values); +// } else { +// XWPFTableRow summaTableRowOne = table.createRow(); +// WordUtils.setExcelContent(excelParagraph, summaTableRowOne, values); +// } +// } +// +// /** +// * 解析base64,返回图片所在路径 +// * +// * @param base64Info +// * @return +// */ +// private byte[] decodeBase64(String base64Info) { +// if (StringUtils.isEmpty(base64Info)) { +// return null; +// } +// BASE64Decoder decoder = new BASE64Decoder(); +// if (!base64Info.contains("base64,")) +// return null; +// String[] arr = base64Info.split("base64,"); +// // 数据中:data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABI4AAAEsCAYAAAClh/jbAAA +// // ... 在"base64,"之后的才是图片信息 +// try { +// return decoder.decodeBuffer(arr[1]); +// } catch (IOException e) { +// return null; +// } +// } +// +// /** +// * 获取区域模板 +// * +// * @return +// */ +// @PostMapping("areaTemplate") +// @ResponseBody +// public HttpResult areaTemplate() { +// HttpResult result; +// List datas; +// datas = reportService.getTemplate(Integer.valueOf(1)); +// if (CollectionUtils.isEmpty(datas)) { +// result = PubUtils.assignmentResult(null, 500, "沒有对应的模板"); +// } else { +// result = PubUtils.assignmentResult(datas, 200, "获取模板成功"); +// } +// return result; +// } +// +// +// @PostMapping("area") +// @ResponseBody +// public HttpResult area(HttpServletRequest request, String startTime, String endTime, String area, String areaname, String jcwfb, String zjsjbg, +// String zjsjtx, String zjmdbg, String zjmdtx, String zjsjditic, String zjsjdf47, String glfbzjfz, String glfbcxsj, +// String sjglbg, String zjyybg, String zjyytx, String zjlxbg, String zjlxtx, String zjrlt) throws Exception { +// HttpResult result; +// List reList = new ArrayList<>(); +// ReportAreaPojo reportAreaPojo = getAreaChoose(request, startTime, endTime, area, areaname, jcwfb, zjsjbg, zjsjtx, zjmdbg, zjmdtx, +// zjsjditic, zjsjdf47, glfbzjfz, glfbcxsj, sjglbg, zjyybg, zjyytx, zjlxbg, zjlxtx, zjrlt); +// DatePojo datePojo; +// datePojo = PubUtils.validateDate(reportAreaPojo.getStartTime(), reportAreaPojo.getEndTime(), "monitor"); +// String userIndex = TokenManager.getUserId(); +// if (!datePojo.getValidity()) { +// result = PubUtils.assignmentResult(null, 500, "解析前台传递的时间有误"); +// return result; +// } +// try { +// DevMapInfo devMapInfo = new DevMapInfo(); +// devMapInfo = areaService.getDevMap(reportAreaPojo.getArea()); +// JSONArray devMapArray = JSONArray.fromObject(devMapInfo.getOnline()); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "linecount", +// stringInstantiateUtil.stringInstantiate(String.valueOf(devMapInfo.getMaps().size())), RedisDB.SHORT_TIME); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "devMapInfo", jsonArrayInstantiateUtil.stringInstantiate(devMapArray), +// RedisDB.SHORT_TIME); +// AreaGeneral eventcount = areaService.getGeneralDate(reportAreaPojo.getArea(), datePojo.getStartTime(), +// datePojo.getEndTime()); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "eventcount", stringInstantiateUtil.stringInstantiate(eventcount.getTotalTimes().toString()), +// RedisDB.SHORT_TIME); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "isPro", stringInstantiateUtil.stringInstantiate(eventcount.getPro()), RedisDB.SHORT_TIME); +// /* 监测网分布 */ +// List maps = new ArrayList<>(); +// if (reportAreaPojo.isJcwfb()) { +// maps = iOverviewServer.getLineMaps(); +// } +// /* 暂降事件列表 */ +// AreaGeneral analyzeInfos = new AreaGeneral(); +// if (reportAreaPojo.isZjsjbg() || reportAreaPojo.isZjsjtx()) { +// analyzeInfos = areaService.getGeneralDate(reportAreaPojo.getArea(), datePojo.getStartTime(), +// datePojo.getEndTime()); +// if (analyzeInfos == null) { +// result = PubUtils.assignmentResult(null, 500, "该区域暂无数据"); +// return result; +// } +// +// List areas = new ArrayList<>(); +// if (analyzeInfos.getPro() == "city") { +// for (int i = 0; i < analyzeInfos.getArea().size(); i++) { +// if (analyzeInfos.getArea().get(i).getCity().equals(analyzeInfos.getCityName())) { +// areas.add(analyzeInfos.getArea().get(i)); +// } +// } +// analyzeInfos.setArea(areas); +// } else { +// areas = analyzeInfos.getArea(); +// } +// List vol = analyzeInfos.getVol(); +// List interval = analyzeInfos.getInterval(); +// JSONArray areaArray = JSONArray.fromObject(areas); +// JSONArray volArray = JSONArray.fromObject(vol); +// JSONArray intervalArray = JSONArray.fromObject(interval); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "area", jsonArrayInstantiateUtil.stringInstantiate(areaArray), RedisDB.SHORT_TIME); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "vol", jsonArrayInstantiateUtil.stringInstantiate(volArray), RedisDB.SHORT_TIME); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "interval", jsonArrayInstantiateUtil.stringInstantiate(intervalArray), +// RedisDB.SHORT_TIME); +// } +// /* 暂降密度数据获取 */ +// List eventDensities = new ArrayList<>(); +// if (reportAreaPojo.isZjmdtx()) { +// eventDensities = areaService.getEventDensity(datePojo.getStartTime(), datePojo.getEndTime(), +// reportAreaPojo.getArea()); +// if (eventDensities == null) { +// result = PubUtils.assignmentResult(null, 500, "该区域暂无数据"); +// return result; +// } +// } +// List eventDisdip; +// List ec411; +// Iec28 iec28; +// if (reportAreaPojo.isZjmdbg()) { +// eventDisdip = areaService.getEventDisdip(datePojo.getStartTime(), datePojo.getEndTime(), +// reportAreaPojo.getArea()); +// ec411 = areaService.getIEC411(datePojo.getStartTime(), datePojo.getEndTime(), reportAreaPojo.getArea()); +// iec28 = areaService.getIEC28(datePojo.getStartTime(), datePojo.getEndTime(), reportAreaPojo.getArea()); +// if (eventDisdip == null || ec411 == null || iec28 == null) { +// result = PubUtils.assignmentResult(null, 500, "该区域暂无数据"); +// return result; +// } +// List ec28 = iec28.getData(); +// JSONArray evArray = JSONArray.fromObject(eventDisdip); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "eventDisdip", jsonArrayInstantiateUtil.stringInstantiate(evArray), +// RedisDB.SHORT_TIME); +// JSONArray ec4Array = JSONArray.fromObject(ec411); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "ec411", jsonArrayInstantiateUtil.stringInstantiate(ec4Array), RedisDB.SHORT_TIME); +// JSONArray ec2Array = JSONArray.fromObject(ec28); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "ec28", jsonArrayInstantiateUtil.stringInstantiate(ec2Array), RedisDB.SHORT_TIME); +// +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "pertime", stringInstantiateUtil.stringInstantiate(iec28.getPertime()), +// RedisDB.SHORT_TIME); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "eventvalue", stringInstantiateUtil.stringInstantiate(iec28.getEventvalue()), +// RedisDB.SHORT_TIME); +// } +// /* 暂降事件点图 */ +// List eventDataLists = new ArrayList<>(); +// if (reportAreaPojo.isZjsjditic() || reportAreaPojo.isZjsjdf47()) { +// eventDataLists = areaService.getEventDataList(datePojo.getStartTime(), datePojo.getEndTime(), +// reportAreaPojo.getArea()); +// if (eventDataLists == null) { +// result = PubUtils.assignmentResult(null, 500, "该区域暂无数据"); +// return result; +// } +// } +// /* 概率分布 */ +// EventChance eventChance = new EventChance(); +// if (reportAreaPojo.isGlfbzjfz() || reportAreaPojo.isGlfbcxsj()) { +// eventChance = areaService.getEventChance(datePojo.getStartTime(), datePojo.getEndTime(), +// reportAreaPojo.getArea()); +// if (eventChance == null) { +// result = PubUtils.assignmentResult(null, 500, "该区域暂无数据"); +// return result; +// } +// } +// /* 事件关联 */ +// List list = new ArrayList<>(); +// if (reportAreaPojo.isSjglbg()) { +// +// list = rangeService.queryEventsByTime(reportAreaPojo.getStartTime(), reportAreaPojo.getEndTime()); +// if (list == null) { +// result = PubUtils.assignmentResult(null, 500, "该区域暂无数据"); +// return result; +// } +// JSONArray inArray = JSONArray.fromObject(list); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "eventass", jsonArrayInstantiateUtil.stringInstantiate(inArray), +// RedisDB.SHORT_TIME); +// } +// /* 暂降原因 */ +// List eventCauses = new ArrayList<>(); +// if (reportAreaPojo.isZjyybg() || reportAreaPojo.isZjyytx()) { +// eventCauses = areaService.getEventCause(datePojo.getStartTime(), datePojo.getEndTime(), +// reportAreaPojo.getArea()); +// if (eventCauses == null) { +// result = PubUtils.assignmentResult(null, 500, "该区域暂无数据"); +// return result; +// } +// JSONArray caArray = JSONArray.fromObject(eventCauses); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "eventCauses", jsonArrayInstantiateUtil.stringInstantiate(caArray), +// RedisDB.SHORT_TIME); +// } +// /* 暂降类型 */ +// List eventTypeLists = new ArrayList<>(); +// if (reportAreaPojo.isZjlxbg() || reportAreaPojo.isZjlxtx()) { +// eventTypeLists = areaService.getEventType(datePojo.getStartTime(), datePojo.getEndTime(), +// reportAreaPojo.getArea()); +// if (eventTypeLists == null) { +// result = PubUtils.assignmentResult(null, 500, "该区域暂无数据"); +// return result; +// } +// JSONArray tyArray = JSONArray.fromObject(eventTypeLists); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "eventTypeLists", jsonArrayInstantiateUtil.stringInstantiate(tyArray), +// RedisDB.SHORT_TIME); +// } +// JSONObject reportPojo = JSONObject.fromObject(reportAreaPojo); +// String key = TokenManager.getUserId() + "reportPojo"; +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, key, instantiateUtil.stringInstantiate(reportPojo), RedisDB.SHORT_TIME); +// /* 暂降热力图 */ +// List eventMap = new ArrayList<>(); +// if (reportAreaPojo.isZjrlt()) { +// eventMap = areaService.getEventMaps(datePojo.getStartTime(), datePojo.getEndTime()); +// if (eventMap == null) { +// result = PubUtils.assignmentResult(null, 500, "该区域暂无数据"); +// return result; +// } +// } +// /* 将前台需要画图的数据返回 */ +// reList.add(analyzeInfos); +// reList.add(eventDensities); +// reList.add(eventDataLists); +// reList.add(eventChance); +// reList.add(eventCauses); +// reList.add(eventTypeLists); +// reList.add(maps); +// reList.add(eventMap); +// result = PubUtils.assignmentResult(reList, 200, "获取监测点图表数据成功"); +// userLog.getLog("查询区域报告", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0); +// } catch (Exception e) { +// // TODO: handle exception +// result = PubUtils.assignmentResult(null, 500, "获取监测点图表数据失败"); +// userLog.getLog("查询区域报告", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0); +// } +// return result; +// } +// +// /** +// * 根据用户页面的选择,指定我们需要查询的数据 +// * +// * @param request 请求 +// */ +// private ReportAreaPojo getAreaChoose(HttpServletRequest request, String startTime, String endTime, String area, String areaname, String jcwfb, String zjsjbg, +// String zjsjtx, String zjmdbg, String zjmdtx, String zjsjditic, String zjsjdf47, String glfbzjfz, String glfbcxsj, +// String sjglbg, String zjyybg, String zjyytx, String zjlxbg, String zjlxtx, String zjrlt) { +// ReportAreaPojo reportAreaPojo = new ReportAreaPojo(); +// reportAreaPojo.setJcwfb(Boolean.valueOf(jcwfb)); +// reportAreaPojo.setZjsjbg(Boolean.valueOf(zjsjbg)); +// reportAreaPojo.setZjsjtx(Boolean.valueOf(zjsjtx)); +// reportAreaPojo.setZjmdbg(Boolean.valueOf(zjmdbg)); +// reportAreaPojo.setZjmdtx(Boolean.valueOf(zjmdtx)); +// reportAreaPojo.setZjsjditic(Boolean.valueOf(zjsjditic)); +// reportAreaPojo.setZjsjdf47(Boolean.valueOf(zjsjdf47)); +// reportAreaPojo.setGlfbzjfz(Boolean.valueOf(glfbzjfz)); +// reportAreaPojo.setGlfbcxsj(Boolean.valueOf(glfbcxsj)); +// reportAreaPojo.setSjglbg(Boolean.valueOf(sjglbg)); +// reportAreaPojo.setZjyybg(Boolean.valueOf(zjyybg)); +// reportAreaPojo.setZjyytx(Boolean.valueOf(zjyytx)); +// reportAreaPojo.setZjlxbg(Boolean.valueOf(zjlxbg)); +// reportAreaPojo.setZjlxtx(Boolean.valueOf(zjlxtx)); +// reportAreaPojo.setZjrlt(Boolean.valueOf(zjrlt)); +// reportAreaPojo.setStartTime(startTime); +// reportAreaPojo.setEndTime(endTime); +// reportAreaPojo.setArea(area); +// reportAreaPojo.setAreaname(areaname); +// return reportAreaPojo; +// +// } +// +// +// @PostMapping("exportAreaReport") +// @ResponseBody +// public String exportAreaReport(HttpServletRequest request, String devmapImage, String intervalImage, String districtImage, String voltageImage, +// String densityImage, String iticImage, String f47Image, String eventValueImage, String persisttimeImage, +// String timeImage, String causeImage, String typeImage, String eventmapImage, String itictips, String f47tips, +// String startTime, String endTime) throws Exception { +// String userIndex = TokenManager.getUserId(); +// JSONObject jsonObject = instantiateUtil.deInstantiate(instantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, +// TokenManager.getUserId() + "reportPojo"))); +// ReportAreaPojo reportAreaPojo = (ReportAreaPojo) JSONObject.toBean(jsonObject, ReportAreaPojo.class); +// // 需要展示的图 +// if (reportAreaPojo.isJcwfb()) { +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "devmapImage", stringInstantiateUtil.stringInstantiate(devmapImage), RedisDB.SHORT_TIME); +// } +// if (reportAreaPojo.isZjsjtx()) { +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "intervalImage", stringInstantiateUtil.stringInstantiate(intervalImage), RedisDB.SHORT_TIME); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "districtImage", stringInstantiateUtil.stringInstantiate(districtImage), RedisDB.SHORT_TIME); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "voltageImage", stringInstantiateUtil.stringInstantiate(voltageImage), RedisDB.SHORT_TIME); +// } +// if (reportAreaPojo.isZjmdtx()) { +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "densityImage", stringInstantiateUtil.stringInstantiate(densityImage), RedisDB.SHORT_TIME); +// } +// if (reportAreaPojo.isZjsjditic()) { +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "iticImage", stringInstantiateUtil.stringInstantiate(iticImage), RedisDB.SHORT_TIME); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "itictips", stringInstantiateUtil.stringInstantiate(itictips), RedisDB.SHORT_TIME); +// } +// if (reportAreaPojo.isZjsjdf47()) { +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "f47Image", stringInstantiateUtil.stringInstantiate(f47Image), RedisDB.SHORT_TIME); +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "f47tips", stringInstantiateUtil.stringInstantiate(f47tips), RedisDB.SHORT_TIME); +// } +// if (reportAreaPojo.isGlfbzjfz()) { +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "eventValueImage", stringInstantiateUtil.stringInstantiate(eventValueImage), +// RedisDB.SHORT_TIME); +// } +// if (reportAreaPojo.isGlfbcxsj()) { +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "persisttimeImage", stringInstantiateUtil.stringInstantiate(persisttimeImage), +// RedisDB.SHORT_TIME); +// } +// if (reportAreaPojo.isZjyytx()) { +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "causeImage", stringInstantiateUtil.stringInstantiate(causeImage), RedisDB.SHORT_TIME); +// } +// if (reportAreaPojo.isZjlxtx()) { +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "typeImage", stringInstantiateUtil.stringInstantiate(typeImage), RedisDB.SHORT_TIME); +// } +// if (reportAreaPojo.isZjrlt()) { +// jedisManager.hset(RedisDB.SHORT_TIME_QUERY, userIndex, "eventmapImage", stringInstantiateUtil.stringInstantiate(eventmapImage), RedisDB.SHORT_TIME); +// } +// return "success"; +// } +// +// @GetMapping("downAreaReport") +// public void downAreaReport(HttpServletResponse response, HttpServletRequest request, String name) throws Exception { +// String userIndex = TokenManager.getUserId(); +// JSONObject jsonObject = instantiateUtil.deInstantiate(instantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, +// TokenManager.getUserId() + "reportPojo"))); +// jedisManager.hdel(RedisDB.SHORT_TIME_QUERY, userIndex, TokenManager.getUserId() + "reportPojo"); +// ReportAreaPojo reportAreaPojo = (ReportAreaPojo) JSONObject.toBean(jsonObject, ReportAreaPojo.class); +// int one = 1; +// // 开始做文档 +// XWPFDocument document = new XWPFDocument(); +// // 设定标题格式 +// WordUtils.setHeadingStyle(document); +// // 添加标题 +// XWPFParagraph titleParagraph = WordUtils.getCenterParagraph(document); +// WordUtils.addLine(titleParagraph, 11); +// // 设置段落居中 +// XWPFRun titleParagraphRun = titleParagraph.createRun(); +// WordUtils.addParagraph(titleParagraphRun, "宋体", 15, "000000", reportAreaPojo.getAreaname() + "供电公司", true); +// WordUtils.addLine(titleParagraph, 3); +// XWPFRun titleParagraphBigRun = titleParagraph.createRun(); +// WordUtils.addParagraph(titleParagraphBigRun, "宋体", 36, "000000", "电压暂降事件区域报告", true); +// WordUtils.addLine(titleParagraph, 19); +// XWPFRun titleParagraphDateRun = titleParagraph.createRun(); +// WordUtils.addParagraph(titleParagraphDateRun, "宋体", 14, "000000", "日期:" + WordUtils.getRightNow(), true); +// titleParagraph.setPageBreak(true); +// // 段落 +// XWPFParagraph statisticsParagraph = WordUtils.getCenterParagraph(document); +// // 段前分页 +// statisticsParagraph.setPageBreak(true); +// XWPFRun statisticsRun = statisticsParagraph.createRun(); +// WordUtils.addParagraph(statisticsRun, "宋体", 24, "000000", "电压暂降事件区域报告", false); +// createTitle(document, "1. 引言", "标题 1", 0, 15); +// XWPFParagraph introductionContentParagraph = WordUtils.getLeftParagraph(document); +// // 首行缩进---段落 +// introductionContentParagraph.setIndentationFirstLine(200); +// XWPFRun introductionContentRun = introductionContentParagraph.createRun(); +// +// List devmap; +// JSONArray dev = jsonArrayInstantiateUtil.deInstantiate(jsonArrayInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "devMapInfo"))); +// devmap = (List) JSONArray.toCollection(dev, DeviceValue.class); +// +// String pro = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "isPro"))); +// String yy; +// if (pro == "pro") { +// yy = reportAreaPojo.getAreaname() + "电网总共有" +// + stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "linecount") + "个监测点," +// + String.valueOf(devmap.size()))) + "个市(州)电压暂降监测点分布情况如下所示:"; +// for (int i = 0; i < devmap.size(); i++) { +// if (i != devmap.size() - 1) { +// yy = yy + devmap.get(i).getName() + ":" + devmap.get(i).getAmounts() + "个,"; +// } else { +// yy = yy + devmap.get(i).getName() + ":" + devmap.get(i).getAmounts() + "个。"; +// } +// } +// } else { +// yy = reportAreaPojo.getAreaname() + "电网总共有" +// + stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "linecount"))) + "个监测点。"; +// } +// WordUtils.addParagraph(introductionContentRun, "宋体", 11, "000000", yy, false); +// +// String eventcount = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "eventcount"))); +// WordUtils.addParagraph(introductionContentRun, "宋体", 11, "000000", +// reportAreaPojo.getAreaname() + "电网在所选择时间段" + reportAreaPojo.getStartTime() + " 至 " +// + reportAreaPojo.getEndTime() + "累计监测到暂降事件" + eventcount +// + "条,本报告按照监测点分布,暂降事件统计,暂降事件点图,暂降热力图,暂降密度图,暂降概率分布图,事件关联统计,暂降类型统计,暂降原因统计等方面进行数据分析。", +// false); +// createTitle(document, "2. 报告分析对象", "标题 1", 0, 15); +// XWPFParagraph objectContentParagraph = WordUtils.getLeftParagraph(document); +// objectContentParagraph.setIndentationFirstLine(200); +// XWPFRun objectContentRun = objectContentParagraph.createRun(); +// WordUtils.addParagraph(objectContentRun, "宋体", 11, "000000", reportAreaPojo.getAreaname() + "。", false); +// createTitle(document, "3. 报告分析时间", "标题 1", 0, 15); +// XWPFParagraph timeContentParagraph = WordUtils.getLeftParagraph(document); +// timeContentParagraph.setIndentationFirstLine(200); +// XWPFRun timeContentRun = timeContentParagraph.createRun(); +// WordUtils.addParagraph(timeContentRun, "宋体", 11, "000000", +// reportAreaPojo.getStartTime() + " 至 " + reportAreaPojo.getEndTime() + "。", false); +// createTitle(document, "4. 汇总信息", "标题 1", 0, 15); +// +// String tips; +// /* 监测网分布 */ +// if (reportAreaPojo.isJcwfb()) { +// createTitle(document, "4." + one + " 监测网分布", "标题 2", 200, 11); +// XWPFParagraph jcwfbtParagraph = WordUtils.getLeftParagraph(document); +// jcwfbtParagraph.setIndentationFirstLine(200); +// XWPFRun jcwfbContentRun = jcwfbtParagraph.createRun(); +// Integer oncount = 0; +// Integer offcount = 0; +// Integer totalcount = Integer.valueOf(stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "linecount")))); +// for (int i = 0; i < devmap.size(); i++) { +// oncount = oncount + devmap.get(i).getOncount(); +// offcount = offcount + devmap.get(i).getOffcount(); +// } +// float rate = (Float.valueOf(oncount) / Float.valueOf(totalcount)) * 100; +// DecimalFormat df = new DecimalFormat("0.00"); +// tips = new String(); +// if (pro == "pro") { +// tips = reportAreaPojo.getAreaname() + "电网总共有监测点" +// + stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "linecount"))) + "个,其中"; +// tips = tips + devmap.get(0).getName() + "、" + devmap.get(1).getName() + "监测点数量较多 ,监测点在线率达到" +// + df.format(rate) + "%(通讯正常为:" + String.valueOf(oncount) + "个,通讯异常为:" + String.valueOf(offcount) +// + "个)[在线率=通讯正常点数/总监测点数(统计时候排除检修和热备用监测点)],具体见下图"; +// } else { +// tips = reportAreaPojo.getAreaname() + "电网总共有监测点" +// + stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "linecount"))) + "个。"; +// tips = tips + "监测点在线率达到" + df.format(rate) + "%(通讯正常为:" + String.valueOf(oncount) + "个,通讯异常为:" +// + String.valueOf(offcount) + "个)[通讯正常/总监测点数(统计时候排除检修和热备用监测点)],具体见下图:"; +// } +// WordUtils.addParagraph(jcwfbContentRun, "宋体", 11, "000000", tips, false); +// String devmapImage = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "devmapImage"))); +// createMap(document, devmapImage, "监测网分布"); +// one++; +// } +// /* 暂降事件列表 */ +// if (reportAreaPojo.isZjsjbg() || reportAreaPojo.isZjsjtx()) { +// createTitle(document, "4." + one + " 暂降事件列表", "标题 2", 200, 11); +// XWPFParagraph zjsjlbParagraph = WordUtils.getLeftParagraph(document); +// zjsjlbParagraph.setIndentationFirstLine(200); +// XWPFRun zjsjlbContentRun = zjsjlbParagraph.createRun(); +// +// List area; +// List vol; +// List interval; +// JSONArray ar = jsonArrayInstantiateUtil.deInstantiate(jsonArrayInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "area"))); +// area = (List) JSONArray.toCollection(ar, Area.class); +// +// JSONArray vo = jsonArrayInstantiateUtil.deInstantiate(jsonArrayInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "vol"))); +// vol = (List) JSONArray.toCollection(vo, Voltage.class); +// +// JSONArray in = jsonArrayInstantiateUtil.deInstantiate(jsonArrayInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "interval"))); +// interval = (List) JSONArray.toCollection(in, Interval.class); +// +// List voldesc = (List) JSONArray.toCollection(vo, Voltage.class); +// List intervaldesc = (List) JSONArray.toCollection(in, Interval.class); +// Collections.sort(voldesc, new Comparator() { +// /* +// * 返回一个基本类型的整型, 返回负数表示:p1 小于p2, 返回0 表示:p1和p2相等, 返回正数表示:p1大于p2 +// */ +// public int compare(Voltage p1, Voltage p2) { +// if (p2.getTimes() > p1.getTimes()) { +// return 1; +// } +// if (p2.getTimes() == p1.getTimes()) { +// return 0; +// } +// return -1; +// } +// }); +// Collections.sort(intervaldesc, new Comparator() { +// /* +// * 返回一个基本类型的整型, 返回负数表示:p1 小于p2, 返回0 表示:p1和p2相等, 返回正数表示:p1大于p2 +// */ +// public int compare(Interval p1, Interval p2) { +// if (p2.getTimes() > p1.getTimes()) { +// return 1; +// } +// if (p2.getTimes() == p1.getTimes()) { +// return 0; +// } +// return -1; +// } +// }); +// tips = new String(); +// tips = reportAreaPojo.getAreaname() + "电网在所选择的分析时间段内累计监测暂降记录" + eventcount + "条"; +// if (pro == "pro") { +// if (area.size() > 0) { +// tips = tips + ",其中" + area.get(0).getCity(); +// if (area.size() > 1) { +// tips = tips + "、" + area.get(1).getCity(); +// } +// tips = tips + "暂降事件居多"; +// } +// } +// if (voldesc.size() > 0) { +// tips = tips + "," + voldesc.get(0).getVoltageValue(); +// if (vol.size() > 1) { +// tips = tips + "、" + voldesc.get(1).getVoltageValue(); +// } +// tips = tips + "暂降事件居多"; +// } +// if (interval.size() > 0) { +// tips = tips + "," + intervaldesc.get(0).getMonth(); +// if (interval.size() > 1) { +// tips = tips + "、" + intervaldesc.get(1).getMonth(); +// } +// tips = tips + "月暂降事件居多"; +// } +// tips = tips + ",具体见下表(图):"; +// WordUtils.addParagraph(zjsjlbContentRun, "宋体", 11, "000000", tips, false); +// +// int two = 1; +// if (reportAreaPojo.isZjsjtx()) { +// createTitle(document, "4." + one + "." + two + " 暂降事件图形", "标题 3", 400, 11); +// String districtImage = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "districtImage"))); +// createPic(document, districtImage, "按区域统计"); +// +// String intervalImage = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "intervalImage"))); +// createPic(document, intervalImage, "按月份统计"); +// +// String voltageImage = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "voltageImage"))); +// createPic(document, voltageImage, "按区域统计"); +// two++; +// } +// if (reportAreaPojo.isZjsjbg()) { +// createTitle(document, "4." + one + "." + two + " 暂降事件表格", "标题 3", 400, 11); +// +// XWPFTable sum = createTable(document); +// XWPFParagraph sumExcelParagraph = WordUtils.getCenterParagraph(document); +// insertRow(document, sum, sumExcelParagraph, true, "区域 ", "电压暂降次数"); +// if (area.isEmpty()) { +// insertRow(document, sum, sumExcelParagraph, false, "", ""); +// } else { +// for (int i = 0; i < area.size(); i++) { +// insertRow(document, sum, sumExcelParagraph, false, area.get(i).getCity(), +// String.valueOf(area.get(i).getTimes())); +// } +// } +// +// XWPFTable volsum = createTable(document); +// XWPFParagraph volsumExcelParagraph = WordUtils.getCenterParagraph(document); +// insertRow(document, volsum, volsumExcelParagraph, true, "电压等级 ", "电压暂降次数"); +// if (vol.isEmpty()) { +// insertRow(document, volsum, volsumExcelParagraph, false, "", ""); +// } else { +// for (int i = 0; i < vol.size(); i++) { +// insertRow(document, volsum, volsumExcelParagraph, false, vol.get(i).getVoltageValue(), +// String.valueOf(vol.get(i).getTimes())); +// } +// } +// +// XWPFTable intsum = createTable(document); +// XWPFParagraph intsumExcelParagraph = WordUtils.getCenterParagraph(document); +// insertRow(document, intsum, intsumExcelParagraph, true, "月份 ", "电压暂降次数"); +// if (interval.isEmpty()) { +// insertRow(document, intsum, intsumExcelParagraph, false, "", ""); +// } else { +// for (int i = 0; i < interval.size(); i++) { +// insertRow(document, intsum, intsumExcelParagraph, false, interval.get(i).getMonth(), +// String.valueOf(interval.get(i).getTimes())); +// } +// } +// } +// one++; +// } +// /* 暂降事件点图 */ +// if (reportAreaPojo.isZjsjditic() || reportAreaPojo.isZjsjdf47()) { +// createTitle(document, "4." + one + " 暂降事件点图", "标题 2", 200, 11); +// +// XWPFParagraph zjsjdParagraph = WordUtils.getLeftParagraph(document); +// zjsjdParagraph.setIndentationFirstLine(200); +// XWPFRun zjsjdContentRun = zjsjdParagraph.createRun(); +// +// tips = new String(); +// tips = "暂降事件点图统计分成ITIC曲线和F47曲线展示。"; +// WordUtils.addParagraph(zjsjdContentRun, "宋体", 11, "000000", tips, false); +// int two = 1; +// if (reportAreaPojo.isZjsjditic()) { +// createTitle(document, "4." + one + "." + two + " ITIC曲线", "标题 3", 400, 11); +// +// XWPFParagraph iticParagraph = WordUtils.getLeftParagraph(document); +// iticParagraph.setIndentationFirstLine(200); +// XWPFRun iticContentRun = iticParagraph.createRun(); +// +// tips = new String(); +// tips = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "itictips"))); +// WordUtils.addParagraph(iticContentRun, "宋体", 11, "000000", tips, false); +// String iticImage = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "iticImage"))); +// createPic(document, iticImage, "ITIC曲线"); +// two++; +// } +// if (reportAreaPojo.isZjsjdf47()) { +// createTitle(document, "4." + one + "." + two + " F47曲线", "标题 3", 400, 11); +// +// XWPFParagraph f47Paragraph = WordUtils.getLeftParagraph(document); +// f47Paragraph.setIndentationFirstLine(200); +// XWPFRun f47ContentRun = f47Paragraph.createRun(); +// +// tips = new String(); +// tips = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "f47tips"))); +// WordUtils.addParagraph(f47ContentRun, "宋体", 11, "000000", tips, false); +// String f47Image = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "f47Image"))); +// createPic(document, f47Image, "F47曲线"); +// } +// one++; +// } +// /* 暂降密度 */ +// if (reportAreaPojo.isZjmdtx() || reportAreaPojo.isZjmdbg()) { +// createTitle(document, "4." + one + " 暂降密度", "标题 2", 200, 11); +// +// XWPFParagraph zjmdParagraph = WordUtils.getLeftParagraph(document); +// zjmdParagraph.setIndentationFirstLine(200); +// XWPFRun zjmdContentRun = zjmdParagraph.createRun(); +// String pertime = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "pertime"))); +// String eventvalue = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "eventvalue"))); +// tips = new String(); +// tips = "暂降密度统计可以从幅值和持续时间两个维度直接地反映暂降事件发生情况,主要反应事件的发生次数,"; +// tips = tips + reportAreaPojo.getAreaname() + "电网在所选择的分析时间内暂降事件主要集中在幅值为" + eventvalue + ",持续时间为" + pertime +// + "[根据 IEC 61000-2-8:(公共电网电压暂降测量统计)算出暂降事件发生最多的区间],具体见表(图):"; +// WordUtils.addParagraph(zjmdContentRun, "宋体", 11, "000000", tips, false); +// int two = 1; +// if (reportAreaPojo.isZjmdtx()) { +// createTitle(document, "4." + one + "." + two + " 暂降密度图", "标题 3", 400, 11); +// String densityImage = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "densityImage"))); +// createPic(document, densityImage, "暂降密度图"); +// two++; +// } +// if (reportAreaPojo.isZjmdbg()) { +// createTitle(document, "4." + one + "." + two + " DISDIP表格:国际发配电联盟(UNIPEDE)", "标题 3", 400, 11); +// XWPFTable disdip = createTable(document); +// XWPFParagraph disdipExcelParagraph = WordUtils.getCenterParagraph(document); +// List eventDisdip; +// JSONArray arrayeventDisdip = jsonArrayInstantiateUtil.deInstantiate(jsonArrayInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "eventDisdip"))); +// eventDisdip = (List) JSONArray.toCollection(arrayeventDisdip, ArrayList.class); +// insertRow(document, disdip, disdipExcelParagraph, true, "剩余电压", "20ms", "100ms", "500ms", "1s", "3s", +// "20s", "60s", "180s"); +// if (eventDisdip.isEmpty()) { +// insertRow(document, disdip, disdipExcelParagraph, false, "", "", "", "", "", "", "", "", ""); +// } else { +// for (List list : eventDisdip) { +// insertRow(document, disdip, disdipExcelParagraph, false, list.get(0).toString(), +// list.get(1).toString(), list.get(2).toString(), list.get(3).toString(), +// list.get(4).toString(), list.get(5).toString(), list.get(6).toString(), +// list.get(7).toString(), list.get(8).toString()); +// } +// } +// two++; +// createTitle(document, "4." + one + "." + two + " IEC 61000-4-11:(用电终端的电压暂降抗度)", "标题 3", 400, 11); +// XWPFTable ec411Table = createTable(document); +// XWPFParagraph ec411TableExcelParagraph = WordUtils.getCenterParagraph(document); +// List ec411; +// JSONArray arrayec411 = jsonArrayInstantiateUtil.deInstantiate(jsonArrayInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "ec411"))); +// ec411 = (List) JSONArray.toCollection(arrayec411, ArrayList.class); +// insertRow(document, ec411Table, ec411TableExcelParagraph, true, "剩余电压", "10~20ms", "20~100ms", +// "0.1~0.2s", "0.2~0.5s", "0.5~1s", ">1s"); +// if (ec411.isEmpty()) { +// insertRow(document, ec411Table, ec411TableExcelParagraph, false, "", "", "", "", "", "", ""); +// } else { +// for (List list : ec411) { +// insertRow(document, ec411Table, ec411TableExcelParagraph, false, list.get(0).toString(), +// list.get(1).toString(), list.get(2).toString(), list.get(3).toString(), +// list.get(4).toString(), list.get(5).toString(), list.get(6).toString()); +// } +// } +// two++; +// createTitle(document, "4." + one + "." + two + " IEC 61000-2-8:(公共电网电压暂降测量统计)", "标题 3", 400, 11); +// XWPFTable ec28Table = createTable(document); +// XWPFParagraph ec28TableExcelParagraph = WordUtils.getCenterParagraph(document); +// List ec28; +// JSONArray arrayec28 = jsonArrayInstantiateUtil.deInstantiate(jsonArrayInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "ec28"))); +// ec28 = (List) JSONArray.toCollection(arrayec28, ArrayList.class); +// insertRow(document, ec28Table, ec28TableExcelParagraph, true, "剩余电压", "0.02~0.1s", "0.1~0.25s", +// "0.25~0.5s", "0.5~1s", "1~3s", "3~20s", "20~60s", "60~180s"); +// if (ec28.isEmpty()) { +// insertRow(document, ec28Table, ec28TableExcelParagraph, false, "", "", "", "", "", "", "", "", ""); +// } else { +// for (List list : ec28) { +// insertRow(document, ec28Table, ec28TableExcelParagraph, false, list.get(0).toString(), +// list.get(1).toString(), list.get(2).toString(), list.get(3).toString(), +// list.get(4).toString(), list.get(5).toString(), list.get(6).toString(), +// list.get(7).toString(), list.get(8).toString()); +// } +// } +// } +// one++; +// } +// /* 概率分布 */ +// if (reportAreaPojo.isGlfbcxsj() || reportAreaPojo.isGlfbzjfz()) { +// createTitle(document, "4." + one + " 暂降幅值概率分布图", "标题 2", 200, 11); +// +// XWPFParagraph glfbParagraph = WordUtils.getLeftParagraph(document); +// glfbParagraph.setIndentationFirstLine(200); +// XWPFRun glfbContentRun = glfbParagraph.createRun(); +// String pertime = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "pertime"))); +// String eventvalue = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "eventvalue"))); +// tips = new String(); +// tips = "暂降概率分布图分成暂降幅值概率分布和持续时间概率分布图,"; +// tips = tips + reportAreaPojo.getAreaname() + "电网在所选择的分析时间内暂降事件从幅值概率分布统计主要集中在幅值为" + eventvalue +// + "之间,从持续时间统计主要集中在持续时间为" + pertime + "[持续时间排序,选择暂降记录发生最多的区域],如下表(图):"; +// WordUtils.addParagraph(glfbContentRun, "宋体", 11, "000000", tips, false); +// int two = 1; +// if (reportAreaPojo.isGlfbzjfz()) { +// createTitle(document, "4." + one + "." + two + " 暂降幅值的概率分函数", "标题 3", 400, 11); +// String eventValueImage = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "eventValueImage"))); +// createPic(document, eventValueImage, "暂降幅值的概率分布函数"); +// two++; +// } +// if (reportAreaPojo.isGlfbcxsj()) { +// createTitle(document, "4." + one + "." + two + " 持续时间的概率分函数", "标题 3", 400, 11); +// String persisttimeImage = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "persisttimeImage"))); +// createPic(document, persisttimeImage, "持续时间的概率分函数"); +// } +// one++; +// } +// /* 事件关联分析 */ +// if (reportAreaPojo.isSjglbg()) { +// createTitle(document, "4." + one + " 事件关联分析", "标题 2", 200, 11); +// List eventass; +// JSONArray arrayeventass = jsonArrayInstantiateUtil.deInstantiate(jsonArrayInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "eventass"))); +// eventass = (List) JSONArray.toCollection(arrayeventass, EventAssObj.class); +// +// XWPFParagraph sjglParagraph = WordUtils.getLeftParagraph(document); +// sjglParagraph.setIndentationFirstLine(200); +// XWPFRun sjglContentRun = sjglParagraph.createRun(); +// tips = new String(); +// tips = reportAreaPojo.getAreaname() + "电网在所选择的分析时间段内累计监测暂降记录" + eventcount + "条,归一化统计后共" +// + String.valueOf(eventass.size()) + "[此为归一化后的暂态事件结果]条,,具体如下图所示:"; +// WordUtils.addParagraph(sjglContentRun, "宋体", 11, "000000", tips, false); +// XWPFTable intervalsTable = createTable(document); +// XWPFParagraph intervalsTableExcelParagraph = WordUtils.getCenterParagraph(document); +// insertRow(document, intervalsTable, intervalsTableExcelParagraph, true, "时间", "事件关联分析名称", "事件关联分析描述"); +// if (eventass.isEmpty()) { +// insertRow(document, intervalsTable, intervalsTableExcelParagraph, false, "", ""); +// } else { +// for (EventAssObj eventas : eventass) { +// insertRow(document, intervalsTable, intervalsTableExcelParagraph, false, +// PubUtils.date2String(eventas.getTime(), "yyyy-MM-dd HH:mm:ss"), eventas.getName(), +// eventas.getDescribe()); +// } +// } +// one++; +// } +// /* 原因统计 */ +// if (reportAreaPojo.isZjyytx() || reportAreaPojo.isZjyybg()) { +// createTitle(document, "4." + one + " 原因统计", "标题 2", 200, 11); +// List eventCauses; +// JSONArray arrayeventCauses = jsonArrayInstantiateUtil.deInstantiate(jsonArrayInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "eventCauses"))); +// eventCauses = (List) JSONArray.toCollection(arrayeventCauses, EventCause.class); +// +// Collections.sort(eventCauses, new Comparator() { +// /* +// * int compare(Person p1, Person p2) 返回一个基本类型的整型, 返回负数表示:p1 +// * 小于p2, 返回0 表示:p1和p2相等, 返回正数表示:p1大于p2 +// */ +// public int compare(EventCause p1, EventCause p2) { +// // 按照Person的年龄进行升序排列 +// if (p2.getCount() > p1.getCount()) { +// return 1; +// } +// if (p2.getCount() == p1.getCount()) { +// return 0; +// } +// return -1; +// } +// }); +// +// XWPFParagraph reasonParagraph = WordUtils.getLeftParagraph(document); +// reasonParagraph.setIndentationFirstLine(200); +// XWPFRun reasonContentRun = reasonParagraph.createRun(); +// tips = new String(); +// tips = reportAreaPojo.getAreaname() + "电网在所选择的分析时间内暂态事件主要的暂态原因为" + eventCauses.get(0).getCause() +// + "[根据表格中的次数来进行分析],见下表(图):"; +// WordUtils.addParagraph(reasonContentRun, "宋体", 11, "000000", tips, false); +// int two = 1; +// if (reportAreaPojo.isZjyytx()) { +// createTitle(document, "4." + one + "." + two + " 原因统计图", "标题 3", 400, 11); +// String causeImage = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "causeImage"))); +// createPic(document, causeImage, "原因统计图"); +// two++; +// } +// if (reportAreaPojo.isZjyybg()) { +// createTitle(document, "4." + one + "." + two + " 原因统计表格", "标题 3", 400, 11); +// XWPFTable causeTable = createTable(document); +// XWPFParagraph causeTableExcelParagraph = WordUtils.getCenterParagraph(document); +// insertRow(document, causeTable, causeTableExcelParagraph, true, "暂态原因", "电压暂降次数"); +// if (eventCauses.isEmpty()) { +// insertRow(document, causeTable, causeTableExcelParagraph, false, "", ""); +// } else { +// for (EventCause eventCause : eventCauses) { +// insertRow(document, causeTable, causeTableExcelParagraph, false, eventCause.getCause(), +// String.valueOf(eventCause.getCount())); +// } +// } +// } +// one++; +// } +// /* 类型统计 */ +// if (reportAreaPojo.isZjlxtx() || reportAreaPojo.isZjlxbg()) { +// createTitle(document, "4." + one + " 类型统计", "标题 2", 200, 11); +// List eventTypeLists = new ArrayList(); +// JSONArray arrayeventTypes = jsonArrayInstantiateUtil.deInstantiate(jsonArrayInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "eventTypeLists"))); +// eventTypeLists = (List) JSONArray.toCollection(arrayeventTypes, EventTypeList.class); +// +// Collections.sort(eventTypeLists, new Comparator() { +// /* +// * int compare(Person p1, Person p2) 返回一个基本类型的整型, 返回负数表示:p1 +// * 小于p2, 返回0 表示:p1和p2相等, 返回正数表示:p1大于p2 +// */ +// @Override +// public int compare(EventTypeList p1, EventTypeList p2) { +// // 按照Person的年龄进行升序排列 +// if (p2.getCount() > p1.getCount()) { +// return 1; +// } +// if (p2.getCount() == p1.getCount()) { +// return 0; +// } +// return -1; +// } +// }); +// +// XWPFParagraph typeParagraph = WordUtils.getLeftParagraph(document); +// typeParagraph.setIndentationFirstLine(200); +// XWPFRun typeContentRun = typeParagraph.createRun(); +// tips = new String(); +// tips = reportAreaPojo.getAreaname() + "电网在所选择的分析时间内暂态事件主要的暂态类型为" + eventTypeLists.get(0).getType() +// + "[根据表格中的次数来进行分析],见下表(图):"; +// WordUtils.addParagraph(typeContentRun, "宋体", 11, "000000", tips, false); +// int two = 1; +// if (reportAreaPojo.isZjlxtx()) { +// createTitle(document, "4." + one + "." + two + " 类型统计图", "标题 3", 400, 11); +// String typeImage = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "typeImage"))); +// createPic(document, typeImage, "类型统计图"); +// two++; +// } +// if (reportAreaPojo.isZjlxbg()) { +// createTitle(document, "4." + one + "." + two + " 类型统计表格", "标题 3", 400, 11); +// XWPFTable typeTable = createTable(document); +// XWPFParagraph typeTableExcelParagraph = WordUtils.getCenterParagraph(document); +// insertRow(document, typeTable, typeTableExcelParagraph, true, "暂态类型", "电压暂态次数"); +// if (eventTypeLists.isEmpty()) { +// insertRow(document, typeTable, typeTableExcelParagraph, false, "", ""); +// } else { +// for (EventTypeList eventTypeList : eventTypeLists) { +// insertRow(document, typeTable, typeTableExcelParagraph, false, eventTypeList.getType(), +// String.valueOf(eventTypeList.getCount())); +// } +// } +// } +// one++; +// } +// /* 暂降热力图 */ +// if (reportAreaPojo.isZjrlt()) { +// createTitle(document, "4." + one + " 暂降热力图", "标题 2", 200, 11); +// +// XWPFParagraph zjrltParagraph = WordUtils.getLeftParagraph(document); +// zjrltParagraph.setIndentationFirstLine(200); +// XWPFRun zjrltContentRun = zjrltParagraph.createRun(); +// tips = new String(); +// tips = reportAreaPojo.getAreaname() + "网在所选择的分析时间段内累计监测暂降记录" + eventcount +// + "条,使用颜色将地图上按照暂降记录发生频率进行描绘,所形成的热力具体见下图:"; +// WordUtils.addParagraph(zjrltContentRun, "宋体", 11, "000000", tips, false); +// String eventmapImage = stringInstantiateUtil.deInstantiate(stringInstantiateUtil.stringDeInstantiate(jedisManager.hget(RedisDB.SHORT_TIME_QUERY, userIndex, "eventmapImage"))); +// System.out.println(eventmapImage); +// createMap(document, eventmapImage, "暂降热力图"); +// one++; +// } +// OutputStream out; +// try { +// response.setContentType("application/force-download");// 设置强制下载不打开 +// // response.addHeader("Content-Disposition", +// // "attachment;fileName="+new +// // String(name.getBytes("GB2312"),"iso8859-1")+".docx" );// 设置文件名 +// String agent = request.getHeader("User-Agent").toUpperCase(); // 获得浏览器信息并转换为大写 +// if (agent.indexOf("MSIE") > 0 || (agent.indexOf("GECKO") > 0 && agent.indexOf("RV:11") > 0)) { // IE浏览器和Edge浏览器 +// name = URLEncoder.encode(name, "UTF-8"); +// } else { // 其他浏览器 +//// name = new String(name.getBytes("UTF-8"), "iso-8859-1"); +// name = URLEncoder.encode(name, "UTF-8"); +// } +// response.addHeader("Content-Disposition", "attachment;fileName=" + name + ".docx");// 设置文件名 +// out = response.getOutputStream(); +// document.write(out); +// document.close(); +// out.close(); +// } catch (Exception e) { +// logger.error(e.getMessage()); +// } +// } +// +// /** +// * 电压暂降列表,获取列表数据 +// * +// * @param startTime 起始时间 +// * @param endTime 结束事件 +// * @param area 区域名称 +// */ +// @RequestMapping(value = "getEventList", method = RequestMethod.POST) +// @ResponseBody +// public HttpResult getEventList(String startTime, String endTime, String area, String type, String waveType, HttpServletRequest request) { +// HttpResult result = PubUtils.initResult(TokenManager.getToken().getLoginName(), request, LogTypeEnum.BUSSINESS.toString(), 0); +// DatePojo datePojo; +// datePojo = PubUtils.validateDateTime(startTime, endTime, "getEventList"); +// if (!datePojo.getValidity()) { +// result = PubUtils.assignmentResult(null, 500, datePojo.getMsg()); +// return result; +// } +// // 统计时间段内的暂降原因次数、暂降类型次数 +// List voltageList; +// try { +// if (StringUtils.isEmpty(waveType) || waveType.equals("")) { +// voltageList = eventDetailService.getVolList(datePojo.getStartTime(), datePojo.getEndTime(), area, type, null, null, null, null, null, null, null, null, null, null); +// } else { +// voltageList = eventDetailService.getVolListByType(datePojo.getStartTime(), datePojo.getEndTime(), area, type, waveType, null, null, null, null, null, null, null, null, null, null); +// } +// if (null == voltageList) { +// result = PubUtils.assignmentResultLog(null, 500, "没有暂降列表的数据", "查询区域暂降列表", "成功", result); +// } else { +// result = PubUtils.assignmentResultLog(voltageList, 200, "获取暂降数据成功", "查询区域暂降列表", "成功", result); +// } +// } catch (Exception e) { +// logger.error("后台获取数据出错,方法名为:getEventList,异常为:" + e); +// result = PubUtils.assignmentResultLog(null, 500, "获取暂降数据失败", "查询区域暂降列表", "失败", result); +// } +// result.setResult(userUtil.getPro(area)); +// return result; +// } +// +// /** +// * 生成暂降事件报告 +// */ +// @PostMapping("createEventReport") +// @ResponseBody +// public HttpResult createEventReport(@RequestParam("index[]") List index, HttpSession session) { +// HttpResult result; +// if (CollectionUtils.isEmpty(index)) { +// result = PubUtils.assignmentResult(null, 500, "请选中需要下载的波形"); +// return result; +// } +// +// try { +// WordUtil wordUtil = new WordUtil(); +// for (int i = 0; i < index.size(); i++) { +// WaveData waveData = waveService.getWavedata(index.get(i), 1); +// //数据筛选,如果是双路电压的话,会存在2个波形数据 +// List waveDataDetails = waveService.filteWaveData(waveData); +// if (waveData.getSunData().size() == 0) { +// result = PubUtils.assignmentResult(null, 500, "没有波形数据"); +// } else { +// String time = waveData.getTime(); +// time = time.replace(" ", "%20"); +// String title = "监测点名称:" + waveData.getLineName() + "%20发生时刻:" + time + "%20特征幅值:" + waveData.getEventValue() + "%25%20持续时间:" + waveData.getPersistTime() + "s"; +// +// List shun = new ArrayList<>(); +// List rms = new ArrayList<>(); +// if (waveDataDetails.size() == 1) { +// shun.add(waveService.createShunTitle(title, waveDataDetails.get(0))); +// rms.add(waveService.createRMSTitle(title, waveDataDetails.get(0))); +// } else { +// shun.add(waveService.createShunTitle(title, waveDataDetails.get(0))); +// rms.add(waveService.createRMSTitle(title, waveDataDetails.get(0))); +// for (int n = 1; n < waveDataDetails.size(); n++) { +// shun.add(waveService.createShun(waveDataDetails.get(n))); +// rms.add(waveService.createRMS(waveDataDetails.get(n))); +// } +// } +// wordUtil.translateShun(i, shun); +// wordUtil.translateRms(i, rms); +// List eventDetailEigenvalue = eventDetailService.eventDetailEigenvalue(index.get(i)); +// wordUtil.setEventDetailEigenvalue(i, eventDetailEigenvalue); +// EventInfoDetail eventInfoList = eventDetailService.eventDetailBaseInfoByIndex(index.get(i)); +// wordUtil.setEventInfoList(i, eventInfoList); +// } +// } +// wordUtil.createReport(index.size()); +// result = PubUtils.assignmentResult(null, 200, "事件报告生成完毕"); +// +// SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmm");// 报告时分秒格式 +// String fileName = "暂降事件报告_" + formatter.format(new Date()) + ".docx"; +// //读取配置文件 +// Properties pros = PubUtils.readProperties(getClass().getClassLoader(), "java.properties"); +// String tmpPath = pros.get("TMP_PATH").toString() + File.separator + "eventreoprt"; +// tmpPath = ClearPathUtil.cleanString(tmpPath); +// OutputStream os = null; +// File tmpfile = new File(tmpPath); +// if (!tmpfile.exists()) { +// tmpfile.mkdir(); +// } +// tmpPath = tmpPath + File.separator + fileName; +// tmpPath = ClearPathUtil.cleanString(tmpPath); +// File tmp = new File(tmpPath); +// if (tmp.exists()) { +// tmp.delete(); +// } +// PubUtils.createFile(tmpPath); +// try { +// os = new FileOutputStream(tmpPath); +// if (null != wordUtil.getDocument()) { +// wordUtil.getDocument().write(os); +// session.setAttribute("eventFilePath", tmpPath); +// session.setAttribute("eventFileName", fileName); +// } +// } catch (Exception e) { +// session.setAttribute("eventFilePath", ""); +// session.setAttribute("eventFileName", ""); +// logger.error("输出暂态事件报告异常,原因为:" + e.toString()); +// } finally { +// try { +// if (os != null) { +// os.close(); +// } +// } catch (Exception e) { +// logger.error("关闭流异常,原因为:" + e.toString()); +// } +// } +// } catch (Exception e) { +// e.printStackTrace(); +// logger.error("生成事件报告失败,方法名为:getEventReport,异常为:" + e.toString()); +// result = PubUtils.assignmentResult(null, 500, "生成事件报告出错,请联系管理员"); +// } +// +// return result; +// } +// +// @GetMapping("downEventReport") +// public void downEventReport(HttpServletResponse response, HttpSession session) throws UnsupportedEncodingException { +// String tmpPath = (String) session.getAttribute("eventFilePath"); +// String filename = (String) session.getAttribute("eventFileName"); +// +// // 设置输出的格式 +// response.reset(); +// response.setContentType("application/docx"); +// response.addHeader("Content-Disposition", +// "attachment; filename=" + new String(filename.getBytes("gb2312"), "ISO8859-1")); +// // 循环取出流中的数据 +// byte[] b = new byte[100]; +// int len; +// if (StringUtils.isBlank(tmpPath)) { +// +// } else { +// if (!StringUtils.isBlank(tmpPath)) { +// tmpPath = ClearPathUtil.cleanString(tmpPath); +// // 读到流中 +// InputStream inStream = null; +// try { +// inStream = new FileInputStream(tmpPath); +// +// if (null != inStream) { +// while ((len = inStream.read(b)) > 0) +// response.getOutputStream().write(b, 0, len); +// } +// } catch (IOException e) { +// // TODO Auto-generated catch block +// logger.error("读取报告信息失败:" + e.getMessage()); +// } finally { +// if (inStream != null) { +// try { +// inStream.close(); +// } catch (Exception e) { +// logger.error("关闭输入流异常,异常为:" + e.toString()); +// } +// } +// } +// +// } +// // 清除session中的数据 +// session.removeAttribute("eventFilePath"); +// session.removeAttribute("eventFileName"); +// } +// +// } +//} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/ReportServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/ReportServiceImpl.java new file mode 100644 index 000000000..f8e226f2d --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/ReportServiceImpl.java @@ -0,0 +1,9184 @@ +package com.njcn.event.service.Impl; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.json.JSONObject; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; +import com.github.abel533.echarts.Label; +import com.github.abel533.echarts.Title; +import com.github.abel533.echarts.axis.AxisLabel; +import com.github.abel533.echarts.axis.CategoryAxis; +import com.github.abel533.echarts.axis.SplitLine; +import com.github.abel533.echarts.axis.ValueAxis; +import com.github.abel533.echarts.code.AxisType; +import com.github.abel533.echarts.code.SeriesType; +import com.github.abel533.echarts.json.GsonOption; +import com.github.abel533.echarts.series.Bar; +import com.github.abel533.echarts.style.ItemStyle; +import com.github.abel533.echarts.style.TextStyle; +import com.github.abel533.echarts.style.itemstyle.Normal; +import com.njcn.common.pojo.dto.SimpleDTO; +import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.device.api.GeneralDeviceInfoClient; +import com.njcn.device.api.LineFeignClient; +import com.njcn.device.pojo.dto.GeneralDeviceDTO; +import com.njcn.device.pojo.param.DeviceInfoParam; +import com.njcn.device.pojo.param.LineBaseQueryParam; +import com.njcn.device.pojo.vo.AreaLineInfoVO; +import com.njcn.device.pojo.vo.LineDetailDataVO; +import com.njcn.event.enums.EventResponseEnum; +import com.njcn.event.pojo.constant.Param; +import com.njcn.event.pojo.param.*; +import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.pojo.po.EventDetailNew; +import com.njcn.event.pojo.po.Eventass; +import com.njcn.event.pojo.vo.*; +import com.njcn.event.service.EventAnalysisService; +import com.njcn.event.service.ReportService; +import com.njcn.event.utils.EchartsUtil; +import com.njcn.event.utils.FreemarkerUtil; +import com.njcn.event.utils.WordUtils; +import com.njcn.influxdb.mapper.InfluxDBResultMapperCn; +import com.njcn.influxdb.utils.InfluxDBCommUtils; +import com.njcn.influxdb.utils.InfluxDbUtils; +import com.njcn.poi.util.PoiUtil; +import com.njcn.system.api.DicDataFeignClient; +import com.njcn.system.enums.DicDataTypeEnum; +import com.njcn.system.pojo.enums.StatisticsEnum; +import com.njcn.system.pojo.po.DictData; +import com.njcn.user.api.DeptFeignClient; +import freemarker.template.TemplateException; +import lombok.RequiredArgsConstructor; +import net.sf.json.JSONArray; +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.openxml4j.exceptions.InvalidFormatException; +import org.apache.poi.ss.usermodel.ClientAnchor; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.util.Units; +import org.apache.poi.xwpf.usermodel.*; +import org.influxdb.dto.QueryResult; +import org.influxdb.impl.InfluxDBResultMapper; + +import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; +import org.springframework.beans.BeanUtils; +import org.springframework.http.*; +import org.springframework.stereotype.Service; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; +import sun.misc.BASE64Decoder; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.math.RoundingMode; +import java.net.URLEncoder; +import java.text.NumberFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.Instant; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.util.*; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * @author xxy + * @version 1.0.0 + * @date 2022年07月28日 13:33 + */ +@Service +@RequiredArgsConstructor +public class ReportServiceImpl implements ReportService { + + private final GeneralDeviceInfoClient generalDeviceInfoClient; + + private final InfluxDbUtils influxDbUtils; + + private final LineFeignClient lineFeignClient; + + private final DicDataFeignClient dicDataFeignClient; + + private final DeptFeignClient deptFeignClient; + + private final RestTemplate restTemplate; + + //调用暂降密度接口 + private final EventAnalysisService eventAnalysisService; + + public List getED(DeviceInfoParam.BusinessParam businessParam){ + List info = new ArrayList<>(); + QueryResult queryResult = new QueryResult(); + List ids = new ArrayList<>(); + List deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData(); + List> collect = deviceDTOList.stream().map(x -> x.getLineIndexes()).collect(Collectors.toList()); + collect.stream().forEach(a -> a.forEach(x -> ids.add(x))); + StringBuilder stringBuilder = new StringBuilder(Param.SELECT+Param.EVENT_DETAIL); + stringBuilder.append(Param.WHERE); + for (String id : ids) { + stringBuilder.append("line_id = '").append(id + "' ").append("or "); + } + String substring = stringBuilder.substring(0, stringBuilder.length() - 3); + queryResult = influxDbUtils.query(substring.toString()); + //结果集映射到对象中 + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + List eventDetailList = influxDBResultMapper.toPOJO(queryResult, EventDetail.class); + eventDetailList.stream().forEach(a -> {info.add(a);}); + return info; + } + + public List getED2(DeviceInfoParam.BusinessParam businessParam){ + List info = new ArrayList<>(); + QueryResult queryResult = new QueryResult(); + List deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData(); + for (GeneralDeviceDTO dto : deviceDTOList) { + StringBuilder stringBuilder = new StringBuilder(Param.SELECT+Param.EVENT_DETAIL); + if (dto.getLineIndexes().size()>0){ + stringBuilder.append(Param.WHERE); + dto.getLineIndexes().stream().forEach(line -> { + stringBuilder.append("line_id = '").append(line + "' ").append("or "); + }); + String substring = stringBuilder.substring(0, stringBuilder.length() - 3); + queryResult = influxDbUtils.query(substring.toString()); + //结果集映射到对象中 + InfluxDBResultMapperCn influxDBResultMapper = new InfluxDBResultMapperCn(); + List eventDetailList = influxDBResultMapper.toPOJO(queryResult, EventDetailNew.class); + eventDetailList.stream().forEach(a -> {info.add(a);}); + } + } + return info; + } + + /** + * 暂态统计(区域) + * + * @param businessParam + * @return + */ + @Override + public List getGeneralSituation(DeviceInfoParam.BusinessParam businessParam) { + //查区域 + HttpResult> info = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam); + List data = info.getData(); + //所有根据line_id查询出来的数据 + HashMap> map = new HashMap<>(); + //循环查找所有数据 + QueryResult queryResult = new QueryResult(); + ArrayList list = new ArrayList<>(); + for (GeneralDeviceDTO dto : data) { + list.add(new GeneralVO(dto.getName(), 0, 0, 0, 0, 0)); + queryResult = null; + StringBuilder stringBuilder = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL); + List lineIndexes = dto.getLineIndexes(); + if (lineIndexes.size() > 0) { + stringBuilder.append(Param.WHERE); + lineIndexes.stream().forEach(line -> { + stringBuilder.append("line_id = '").append(line + "' ").append("or "); + }); + String substring = stringBuilder.substring(0, stringBuilder.length() - 3); + queryResult = influxDbUtils.query(substring.toString()); + //结果集映射到对象中 + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + List eventDetailList = influxDBResultMapper.toPOJO(queryResult, EventDetail.class); + map.put(dto.getName(), eventDetailList); + } else { + List eventDetailList = new ArrayList<>(); + map.put(dto.getName(), eventDetailList); + } + } + Set keySet = map.keySet(); + //获取状态 + for (int i = 0; i < keySet.size(); i++) { + for (String s : keySet) { + GeneralVO generalVO = list.get(i); + if (map.get(s).size() > 0 && generalVO.getName().equals(s)) { + map.get(s).stream().forEach(res -> { + Integer waveType = res.getWaveType(); + switch (waveType) { + case 1: { + generalVO.setSagsCount(generalVO.getSagsCount() + 1); + break; + } + case 2: { + generalVO.setUpCount(generalVO.getUpCount() + 1); + break; + } + case 3: { + generalVO.setBreakCount(generalVO.getBreakCount() + 1); + break; + } + } + }); + } + } + } + //是否在线 + for (int i = 0; i < data.size(); i++) { + GeneralVO generalVO = list.get(i); + GeneralDeviceDTO dto = data.get(i); + if (dto.getLineIndexes().size() > 0) { + HttpResult result = lineFeignClient.getOnLineCount(dto.getLineIndexes()); + generalVO.setOnLine(result.getData()); + generalVO.setOffLine(dto.getLineIndexes().size() - result.getData()); + } + } + return list; + } + + /** + * 暂态统计(电压) + * + * @param businessParam + * @return + */ + @Override + public List getVoltage(DeviceInfoParam.BusinessParam businessParam) { + //获取所有数据 + //查电压 + HttpResult> info = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam); + List data = info.getData(); + //所有根据line_id查询出来的数据 + HashMap> map = new HashMap<>(); + //循环查找所有数据 + QueryResult queryResult = new QueryResult(); + ArrayList list = new ArrayList<>(); + for (GeneralDeviceDTO dto : data) { + list.add(new GeneralVO(dto.getName(), 0, 0, 0, 0, 0)); + queryResult = null; + StringBuilder stringBuilder = new StringBuilder(Param.SELECT+Param.EVENT_DETAIL); + List lineIndexes = dto.getLineIndexes(); + if (lineIndexes.size() > 0) { + stringBuilder.append(Param.WHERE); + lineIndexes.stream().forEach(line -> { + stringBuilder.append("line_id = '").append(line + "' ").append("or "); + }); + String substring = stringBuilder.substring(0, stringBuilder.length() - 3); + queryResult = influxDbUtils.query(substring.toString()); + //结果集映射到对象中 + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + List eventDetailList = influxDBResultMapper.toPOJO(queryResult, EventDetail.class); + map.put(dto.getName(), eventDetailList); + } else { + List eventDetailList = new ArrayList<>(); + map.put(dto.getName(), eventDetailList); + } + } + Set keySet = map.keySet(); + //获取状态 + for (int i = 0; i < keySet.size(); i++) { + for (String s : keySet) { + GeneralVO generalVO = list.get(i); + if (map.get(s).size() > 0 && generalVO.getName().equals(s)) { + long count1 = map.get(s).stream().filter(x -> x.getWaveType() == 1).count(); + long count2 = map.get(s).stream().filter(x -> x.getWaveType() == 2).count(); + long count3 = map.get(s).stream().filter(x -> x.getWaveType() == 3).count(); + generalVO.setSagsCount((int) count1); + generalVO.setUpCount((int)count2); + generalVO.setBreakCount((int)count3); +// map.get(s).stream().forEach(res -> { +// Integer waveType = res.getWaveType(); +// switch (waveType) { +// case 1: { +// generalVO.setSagsCount(generalVO.getSagsCount() + 1); +// break; +// } +// case 2: { +// generalVO.setUpCount(generalVO.getUpCount() + 1); +// break; +// } +// case 3: { +// generalVO.setBreakCount(generalVO.getBreakCount() + 1); +// break; +// } +// } +// }); + } + } + } + //是否在线 + for (int i = 0; i < data.size(); i++) { + GeneralVO generalVO = list.get(i); + GeneralDeviceDTO dto = data.get(i); + if (dto.getLineIndexes().size() > 0) { + HttpResult result = lineFeignClient.getOnLineCount(dto.getLineIndexes()); + generalVO.setOnLine(result.getData()); + generalVO.setOffLine(dto.getLineIndexes().size() - result.getData()); + } + } + return list; + } + + /** + * 严重度前20 + * + * @param businessParam + * @return + */ + @Override + public List getSeverity(DeviceInfoParam.BusinessParam businessParam) { + List result = new ArrayList<>(); + List info = getED2(businessParam); + List idlist = new ArrayList<>(); + //根据严重度进行排序并取前二十个数据 + info.sort(((o1, o2) -> o1.getSeverity().compareTo(o2.getSeverity()))); + Collections.reverse(info); + List details = info.subList(0, 20); + //遍历集合得到id集合 + for (EventDetailNew detail : details) { + idlist.add(detail.getLineId()); + } + //得到对应的监测点信息 + HttpResult> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist); + List data = AreaInfo.getData(); + //遍历集合比较id得到最终数据 + for (EventDetailNew detail : details) { + WaveTypeVO waveTypeVO = new WaveTypeVO(); + for (AreaLineInfoVO vo : data) { + if (detail.getLineId().equals(vo.getLineId())) { + BeanUtils.copyProperties(detail, waveTypeVO); + BeanUtils.copyProperties(vo, waveTypeVO); + result.add(waveTypeVO); + } + } + } + return result; + } + + /** + * 获取暂降原因 + * + * @param businessParam + * @return + */ + @Override + public List getReason(DeviceInfoParam.BusinessParam businessParam) { + List result = new ArrayList<>(); + List info = getED(businessParam); + //获取字典表 + HttpResult> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()); + List data = reason.getData(); + //计数器初始化 + HashMap count = new HashMap<>(); + for (DictData datum : data) { + count.put(datum.getName(), 0); + } + //替值 + for (EventDetail eventDetail : info) { + if (eventDetail.getWaveType() == 1) { + for (DictData datum : data) { + if (datum.getId().equals(eventDetail.getEventReason())) { + eventDetail.setEventReason(datum.getName()); + } + } + } + } + //计数 + Set keySet = count.keySet(); + for (EventDetail eventDetail : info) { + for (String s : keySet) { + if (s.equals(eventDetail.getEventReason())) { + count.put(s, count.get(s) + 1); + } + } + } + for (String s : keySet) { + if (count.get(s) == 0) { + result.add(new ReasonsVO(s, 0, "0")); + } else { + if (count.get(s) == info.size()) { + result.add(new ReasonsVO(s, info.size(), "100")); + } else { + String s1 = String.format("%.4f", (count.get(s).doubleValue() / info.size())); + result.add(new ReasonsVO(s, count.get(s), s1.substring(2, 4) + "." + s1.substring(4, 6))); + } + } + } + return result; + } + + /** + * 获取详细时间列表 + * + * @param waveTypeParam + * @return + */ + @Override + public Page getContinueTime(WaveTypeParam waveTypeParam) { + List result = new ArrayList<>(); + List count = getED2(waveTypeParam); + StringBuilder stringBuilder = new StringBuilder(Param.SELECT+Param.EVENT_DETAIL+Param.WHERE+" 1=1 "); + List deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(waveTypeParam).getData(); + String substring = ""; + for (GeneralDeviceDTO dto : deviceDTOList) { + if (dto.getLineIndexes().size()>0){ + stringBuilder.append(" or "); + dto.getLineIndexes().stream().forEach(line -> { + stringBuilder.append("line_id = '").append(line + "' ").append("or "); + }); + stringBuilder.delete(stringBuilder.length()-3,stringBuilder.length()+1); + } + } + Integer s = (waveTypeParam.getPageNum() - 1) * waveTypeParam.getPageSize(); + substring = stringBuilder.toString() + "limit "+waveTypeParam.getPageSize()+" offset "+s+ Param.TZ_ASIA_SHANGHAI; + QueryResult query = influxDbUtils.query(substring); + InfluxDBResultMapperCn influxDBResultMapper = new InfluxDBResultMapperCn(); + List info = influxDBResultMapper.toPOJO(query, EventDetailNew.class); + //id集合 + ArrayList idlist = new ArrayList<>(); + for (EventDetailNew eventDetail : info) { + DetailVO vo = new DetailVO(); + BeanUtils.copyProperties(eventDetail, vo); + result.add(vo); + idlist.add(eventDetail.getLineId()); + } + HttpResult> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist); + List data = AreaInfo.getData(); + for (DetailVO detailVO : result) { + for (AreaLineInfoVO vo : data) { + if (vo.getLineId().equals(detailVO.getLineId())) { + BeanUtils.copyProperties(vo, detailVO); + } + } + } + HttpResult> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()); + List type = reason.getData(); + for (DetailVO detailVO : result) { + for (DictData dictData : type) { + if (dictData.getId().equals(detailVO.getEventType())) { + detailVO.setEventType(dictData.getName()); + } + } + } + Page page = new Page<>(); + page.setTotal(count.size()); + page.setRecords(result); + page.setCurrent(waveTypeParam.getPageNum()); + page.setSize(waveTypeParam.getPageSize()); + return page; + } + + /** + * 暂降次数统计 + * + * @param waveTypeParam + * @return + */ + @Override + public Page getSagTimes(WaveTypeParam waveTypeParam) { + List result = new ArrayList<>(); + List count = getED2(waveTypeParam); + StringBuilder stringBuilder = new StringBuilder(Param.SELECT+Param.EVENT_DETAIL+Param.WHERE+" 1=1 "); + List deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(waveTypeParam).getData(); + String substring = ""; + for (GeneralDeviceDTO dto : deviceDTOList) { + if (dto.getLineIndexes().size()>0){ + stringBuilder.append(" or "); + dto.getLineIndexes().stream().forEach(line -> { + stringBuilder.append("line_id = '").append(line + "' ").append("or "); + }); + stringBuilder.delete(stringBuilder.length()-3,stringBuilder.length()+1); + } + } + Integer i = (waveTypeParam.getPageNum() - 1) * waveTypeParam.getPageSize(); + substring = stringBuilder.toString() + "limit "+waveTypeParam.getPageSize()+" offset "+i+ Param.TZ_ASIA_SHANGHAI; + QueryResult query = influxDbUtils.query(substring); + InfluxDBResultMapperCn influxDBResultMapper = new InfluxDBResultMapperCn(); + List info = influxDBResultMapper.toPOJO(query, EventDetailNew.class); + HashMap countMap = new HashMap<>(); + for (EventDetailNew eventDetail : info) { + countMap.put(eventDetail.getLineId(), 0); + } + Set keySet = countMap.keySet(); + //id集合 + ArrayList idlist = new ArrayList<>(); + for (EventDetailNew eventDetail : info) { + for (String s : keySet) { + if (eventDetail.getLineId().equals(s) && eventDetail.getWaveType() == 1) { + countMap.put(s, countMap.get(s) + 1); + } + } + DetailVO vo = new DetailVO(); + BeanUtils.copyProperties(eventDetail, vo); + result.add(vo); + idlist.add(eventDetail.getLineId()); + } + HttpResult> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist); + List data = AreaInfo.getData(); + for (DetailVO detailVO : result) { + for (AreaLineInfoVO vo : data) { + if (vo.getLineId().equals(detailVO.getLineId())) { + BeanUtils.copyProperties(vo, detailVO); + } + } + for (String s : keySet) { + if (s.equals(detailVO.getLineId())) { + detailVO.setTimes(countMap.get(s)); + } + } + } + Page page = new Page<>(); + page.setTotal(count.size()); + page.setRecords(result); + page.setCurrent(waveTypeParam.getPageNum()); + page.setSize(waveTypeParam.getPageSize()); + return page; + } + + /** + * 暂升次数统计 + * + * @param waveTypeParam + * @return + */ + @Override + public Page getUpTimes(WaveTypeParam waveTypeParam) { + List result = new ArrayList<>(); + List count = getED2(waveTypeParam); + StringBuilder stringBuilder = new StringBuilder(Param.SELECT+Param.EVENT_DETAIL+Param.WHERE+" 1=1 "); + List deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(waveTypeParam).getData(); + String substring = ""; + for (GeneralDeviceDTO dto : deviceDTOList) { + if (dto.getLineIndexes().size()>0){ + stringBuilder.append(" or "); + dto.getLineIndexes().stream().forEach(line -> { + stringBuilder.append("line_id = '").append(line + "' ").append("or "); + }); + stringBuilder.delete(stringBuilder.length()-3,stringBuilder.length()+1); + } + } + Integer i = (waveTypeParam.getPageNum() - 1) * waveTypeParam.getPageSize(); + substring = stringBuilder.toString() + "limit "+waveTypeParam.getPageSize()+" offset "+i+ Param.TZ_ASIA_SHANGHAI; + QueryResult query = influxDbUtils.query(substring); + InfluxDBResultMapperCn influxDBResultMapper = new InfluxDBResultMapperCn(); + List info = influxDBResultMapper.toPOJO(query, EventDetailNew.class); + HashMap countMap = new HashMap<>(); + for (EventDetailNew eventDetail : info) { + countMap.put(eventDetail.getLineId(), 0); + } + Set keySet = countMap.keySet(); + //id集合 + ArrayList idlist = new ArrayList<>(); + for (EventDetailNew eventDetail : info) { + for (String s : keySet) { + if (eventDetail.getLineId().equals(s) && eventDetail.getWaveType() == 2) { + countMap.put(s, countMap.get(s) + 1); + } + } + DetailVO vo = new DetailVO(); + BeanUtils.copyProperties(eventDetail, vo); + result.add(vo); + idlist.add(eventDetail.getLineId()); + } + HttpResult> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist); + List data = AreaInfo.getData(); + for (DetailVO detailVO : result) { + for (AreaLineInfoVO vo : data) { + if (vo.getLineId().equals(detailVO.getLineId())) { + BeanUtils.copyProperties(vo, detailVO); + } + } + for (String s : keySet) { + if (s.equals(detailVO.getLineId())) { + detailVO.setTimes(countMap.get(s)); + } + } + } + Page page = new Page<>(); + page.setTotal(count.size()); + page.setRecords(result); + page.setCurrent(waveTypeParam.getPageNum()); + page.setSize(waveTypeParam.getPageSize()); + return page; + } + + /** + * 中断次数统计 + * + * @param waveTypeParam + * @return + */ + @Override + public Page getBreakTimes(WaveTypeParam waveTypeParam) { + List result = new ArrayList<>(); + List count = getED2(waveTypeParam); + StringBuilder stringBuilder = new StringBuilder(Param.SELECT+Param.EVENT_DETAIL+Param.WHERE+" 1=1 "); + List deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(waveTypeParam).getData(); + String substring = ""; + for (GeneralDeviceDTO dto : deviceDTOList) { + if (dto.getLineIndexes().size()>0){ + stringBuilder.append(" or "); + dto.getLineIndexes().stream().forEach(line -> { + stringBuilder.append("line_id = '").append(line + "' ").append("or "); + }); + stringBuilder.delete(stringBuilder.length()-3,stringBuilder.length()+1); + } + } + Integer i = (waveTypeParam.getPageNum() - 1) * waveTypeParam.getPageSize(); + substring = stringBuilder.toString() + "limit "+waveTypeParam.getPageSize()+" offset "+i+ Param.TZ_ASIA_SHANGHAI; + QueryResult query = influxDbUtils.query(substring); + InfluxDBResultMapperCn influxDBResultMapper = new InfluxDBResultMapperCn(); + List info = influxDBResultMapper.toPOJO(query, EventDetailNew.class); + HashMap countMap = new HashMap<>(); + for (EventDetailNew eventDetail : info) { + countMap.put(eventDetail.getLineId(), 0); + } + Set keySet = countMap.keySet(); + //id集合 + ArrayList idlist = new ArrayList<>(); + for (EventDetailNew eventDetail : info) { + for (String s : keySet) { + if (eventDetail.getLineId().equals(s) && eventDetail.getWaveType() == 3) { + countMap.put(s, countMap.get(s) + 1); + } + } + DetailVO vo = new DetailVO(); + BeanUtils.copyProperties(eventDetail, vo); + result.add(vo); + idlist.add(eventDetail.getLineId()); + } + HttpResult> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist); + List data = AreaInfo.getData(); + for (DetailVO detailVO : result) { + for (AreaLineInfoVO vo : data) { + if (vo.getLineId().equals(detailVO.getLineId())) { + BeanUtils.copyProperties(vo, detailVO); + } + } + for (String s : keySet) { + if (s.equals(detailVO.getLineId())) { + detailVO.setTimes(countMap.get(s)); + } + } + } + Page page = new Page<>(); + page.setTotal(count.size()); + page.setRecords(result); + page.setCurrent(waveTypeParam.getPageNum()); + page.setSize(waveTypeParam.getPageSize()); + return page; + } + + @Override + public void getExport(DeviceInfoParam.BusinessParam businessParam, HttpServletResponse response) throws IOException, TemplateException { + //区域暂态统计数据 + List GereralList = getGeneralSituation(businessParam); + //电压暂态统计数据 + SimpleDTO simpleDTOV = new SimpleDTO(); + simpleDTOV.setName("电压等级"); + simpleDTOV.setSort(1); + simpleDTOV.setCode("Voltage_Level"); + businessParam.setStatisticalType(simpleDTOV); + List VoltageList = getVoltage(businessParam); + + //表格操作 + HSSFWorkbook sheets = new HSSFWorkbook(); + sheets.createSheet("sheet1"); + HSSFSheet sheetAt = sheets.getSheetAt(0); + sheetAt.setColumnWidth(0,24*256); + sheetAt.setColumnWidth(1,9*256); + sheetAt.setColumnWidth(2,9*256); + sheetAt.setColumnWidth(3,9*256); + sheetAt.setColumnWidth(4,9*256); + sheetAt.setColumnWidth(5,9*256); + sheetAt.addMergedRegion(new CellRangeAddress(0,0,0,5)); + sheetAt.addMergedRegion(new CellRangeAddress(1,1,0,5)); + sheetAt.addMergedRegion(new CellRangeAddress(2,3,0,0)); + sheetAt.addMergedRegion(new CellRangeAddress(2,2,1,2)); + sheetAt.addMergedRegion(new CellRangeAddress(2,3,3,3)); + sheetAt.addMergedRegion(new CellRangeAddress(2,3,4,4)); + sheetAt.addMergedRegion(new CellRangeAddress(2,3,5,5)); + + HSSFRow title = sheetAt.createRow(0); + HSSFRow row1 = sheetAt.createRow(1); + HSSFRow row2 = sheetAt.createRow(2); + HSSFRow row3 = sheetAt.createRow(3); + + HSSFFont font = sheets.createFont(); + font.setFontName("微软雅黑"); + font.setBold(true); + HSSFCellStyle cellStyle = sheets.createCellStyle(); + cellStyle.setAlignment(HorizontalAlignment.CENTER); + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); + cellStyle.setFont(font); + + HSSFCellStyle cellStylearea = sheets.createCellStyle(); + cellStylearea.setAlignment(HorizontalAlignment.CENTER); + cellStylearea.setVerticalAlignment(VerticalAlignment.CENTER); + cellStylearea.setFont(font); + + HSSFCell titleCell = title.createCell(0); + setCellStyle(titleCell,"暂态统计",cellStyle); + HSSFCell r1Cell0 = row1.createCell(0); + setCellStyle(r1Cell0,"按区域统计",cellStyle); + HSSFCell r2Cell0 = row2.createCell(0); + setCellStyle(r2Cell0,"区域",cellStyle); + HSSFCell r2Cell1 = row2.createCell(1); + setCellStyle(r2Cell1,"监测点数量",cellStyle); + HSSFCell r2Cell3 = row2.createCell(3); + setCellStyle(r2Cell3,"暂降次数",cellStyle); + HSSFCell r2Cell4 = row2.createCell(4); + setCellStyle(r2Cell4,"中断次数",cellStyle); + HSSFCell r2Cell5 = row2.createCell(5); + setCellStyle(r2Cell5,"暂升次数",cellStyle); + HSSFCell r3Cell1 = row3.createCell(1); + setCellStyle(r3Cell1,"在线",cellStyle); + HSSFCell r3Cell2 = row3.createCell(2); + setCellStyle(r3Cell2,"离线",cellStyle); + int titleSize = 4; + HSSFCellStyle bodyStyle = sheets.createCellStyle(); + bodyStyle.setAlignment(HorizontalAlignment.CENTER); + bodyStyle.setVerticalAlignment(VerticalAlignment.CENTER); + HSSFFont bodyFont = sheets.createFont(); + bodyFont.setFontName("微软雅黑"); + bodyFont.setFontHeightInPoints((short) 9); + bodyStyle.setFont(bodyFont); + + ArrayList online = new ArrayList<>(); + ArrayList offline = new ArrayList<>(); + ArrayList xdata = new ArrayList<>(); + + ArrayList online2 = new ArrayList<>(); + ArrayList offline2 = new ArrayList<>(); + ArrayList xdata2 = new ArrayList<>(); + + List up1 = new ArrayList<>(); + List sag1 = new ArrayList<>(); + List break1 = new ArrayList<>(); + + List up2 = new ArrayList<>(); + List sag2 = new ArrayList<>(); + List break2 = new ArrayList<>(); + + for (int i = 0; i < GereralList.size(); i++) { + GeneralVO vo = GereralList.get(i); + + xdata.add(vo.getName()); + online.add(vo.getOnLine()); + offline.add(vo.getOffLine()); + + up1.add(vo.getUpCount()); + sag1.add(vo.getSagsCount()); + break1.add(vo.getBreakCount()); + + HSSFRow row = sheetAt.createRow(i + titleSize); + HSSFCell cell0 = row.createCell(0); + HSSFCell cell1 = row.createCell(1); + HSSFCell cell2 = row.createCell(2); + HSSFCell cell3 = row.createCell(3); + HSSFCell cell4 = row.createCell(4); + HSSFCell cell5 = row.createCell(5); + + cell0.setCellStyle(bodyStyle); + cell1.setCellStyle(bodyStyle); + cell2.setCellStyle(bodyStyle); + cell3.setCellStyle(bodyStyle); + cell4.setCellStyle(bodyStyle); + cell5.setCellStyle(bodyStyle); + + cell0.setCellValue(vo.getName()); + cell1.setCellValue(vo.getOnLine()); + cell2.setCellValue(vo.getOffLine()); + cell3.setCellValue(vo.getSagsCount()); + cell4.setCellValue(vo.getBreakCount()); + cell5.setCellValue(vo.getUpCount()); + } + titleSize = titleSize + GereralList.size(); + + sheetAt.addMergedRegion(new CellRangeAddress(titleSize,titleSize,0,5)); + sheetAt.addMergedRegion(new CellRangeAddress(titleSize+1,titleSize+2,0,0)); + sheetAt.addMergedRegion(new CellRangeAddress(titleSize+1,titleSize+1,1,2)); + sheetAt.addMergedRegion(new CellRangeAddress(titleSize+1,titleSize+2,3,3)); + sheetAt.addMergedRegion(new CellRangeAddress(titleSize+1,titleSize+2,4,4)); + sheetAt.addMergedRegion(new CellRangeAddress(titleSize+1,titleSize+2,5,5)); + + HSSFRow rown = sheetAt.createRow(titleSize); + HSSFRow row1v = sheetAt.createRow(titleSize + 1); + HSSFRow row2v = sheetAt.createRow(titleSize + 2); + + HSSFCell cellvt = rown.createCell(0); + setCellStyle(cellvt,"按电压等级统计",cellStyle); + HSSFCell v1cell0 = row1v.createCell(0); + setCellStyle(v1cell0,"电压等级",cellStyle); + HSSFCell v1cell1 = row1v.createCell(1); + setCellStyle(v1cell1,"监测点数量",cellStyle); + HSSFCell v2cell1 = row2v.createCell(1); + setCellStyle(v2cell1,"在线",cellStyle); + HSSFCell v2cell2 = row2v.createCell(2); + setCellStyle(v2cell2,"离线",cellStyle); + HSSFCell v1cell3 = row1v.createCell(3); + HSSFCell v1cell4 = row1v.createCell(4); + HSSFCell v1cell5 = row1v.createCell(5); + setCellStyle(v1cell3,"暂降次数",cellStyle); + setCellStyle(v1cell4,"中断次数",cellStyle); + setCellStyle(v1cell5,"暂升次数",cellStyle); + titleSize = titleSize + 3; + for (int i = 0; i < VoltageList.size(); i++) { + GeneralVO vo = VoltageList.get(i); + + xdata2.add(vo.getName()); + online2.add(vo.getOnLine()); + offline2.add(vo.getOffLine()); + + up2.add(vo.getUpCount()); + sag2.add(vo.getSagsCount()); + break2.add(vo.getBreakCount()); + + HSSFRow row = sheetAt.createRow(titleSize + i); + HSSFCell cell0 = row.createCell(0); + HSSFCell cell1 = row.createCell(1); + HSSFCell cell2 = row.createCell(2); + HSSFCell cell3 = row.createCell(3); + HSSFCell cell4 = row.createCell(4); + HSSFCell cell5 = row.createCell(5); + + cell0.setCellStyle(bodyStyle); + cell1.setCellStyle(bodyStyle); + cell2.setCellStyle(bodyStyle); + cell3.setCellStyle(bodyStyle); + cell4.setCellStyle(bodyStyle); + cell5.setCellStyle(bodyStyle); + + cell0.setCellValue(vo.getName()); + cell1.setCellValue(vo.getOnLine()); + cell2.setCellValue(vo.getOffLine()); + cell3.setCellValue(vo.getSagsCount()); + cell4.setCellValue(vo.getBreakCount()); + cell5.setCellValue(vo.getUpCount()); + } + + HashMap map1 = new HashMap<>(); + map1.put("onlineData",JSONArray.fromObject(online).toString()); + map1.put("offlineData",JSONArray.fromObject(offline).toString()); + map1.put("xname","(区域)"); + map1.put("subtext","区域统计"); + map1.put("area",JSONArray.fromObject(xdata).toString()); + String str1 = getStr("bar.ftl", map1); + + HashMap map2 = new HashMap<>(); + map2.put("onlineData",JSONArray.fromObject(online2).toString()); + map2.put("offlineData",JSONArray.fromObject(offline2).toString()); + map2.put("xname","(电压等级)"); + map2.put("subtext","电压等级统计"); + map2.put("area",JSONArray.fromObject(xdata2).toString()); + String str2 = getStr("bar.ftl", map2); + + HashMap map3 = new HashMap<>(); + map3.put("xname","(区域)"); + map3.put("subtext","区域等级"); + map3.put("area",JSONArray.fromObject(xdata).toString()); + map3.put("sag",JSONArray.fromObject(sag1).toString()); + map3.put("break",JSONArray.fromObject(break1).toString()); + map3.put("up",JSONArray.fromObject(up1).toString()); + String str3 = getStr("bar2.ftl", map3); + + HashMap map4 = new HashMap<>(); + map4.put("xname","(电压等级)"); + map4.put("subtext","电压等级统计"); + map4.put("area",JSONArray.fromObject(xdata2).toString()); + map4.put("sag",JSONArray.fromObject(sag2).toString()); + map4.put("break",JSONArray.fromObject(break2).toString()); + map4.put("up",JSONArray.fromObject(up2).toString()); + String str4 = getStr("bar2.ftl", map4); + + HSSFPatriarch drawingPatriarch = sheetAt.createDrawingPatriarch(); + //区域信息 + HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, (short) 6, (short) 0, (short) 15, (short) 14); + //电压信息 + HSSFClientAnchor anchor1 = new HSSFClientAnchor(0, 0, 0, 0, (short) 6, (short) 14, (short) 15, (short) 30); + //区域次数 + HSSFClientAnchor anchor2 = new HSSFClientAnchor(0, 0, 0, 0, (short) 6, (short) 31, (short) 15, (short) 45); + //电压等级次数 + HSSFClientAnchor anchor3 = new HSSFClientAnchor(0, 0, 0, 0, (short) 6, (short) 46, (short) 15, (short) 60); + + anchor.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE); + anchor1.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE); + anchor2.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE); + anchor3.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE); + + BASE64Decoder decoder = new BASE64Decoder(); + byte[] bytes1 = new byte[0]; + byte[] bytes2 = new byte[0]; + byte[] bytes3 = new byte[0]; + byte[] bytes4 = new byte[0]; + try { + bytes1 = decoder.decodeBuffer(str1); + bytes2 = decoder.decodeBuffer(str2); + bytes3 = decoder.decodeBuffer(str3); + bytes4 = decoder.decodeBuffer(str4); + } catch (IOException e) { + throw new RuntimeException(e); + } + + drawingPatriarch.createPicture(anchor,sheets.addPicture(bytes1,HSSFWorkbook.PICTURE_TYPE_JPEG)); + drawingPatriarch.createPicture(anchor1,sheets.addPicture(bytes2,HSSFWorkbook.PICTURE_TYPE_JPEG)); + drawingPatriarch.createPicture(anchor2,sheets.addPicture(bytes3,HSSFWorkbook.PICTURE_TYPE_JPEG)); + drawingPatriarch.createPicture(anchor3,sheets.addPicture(bytes4,HSSFWorkbook.PICTURE_TYPE_JPEG)); + + PoiUtil.exportFileByWorkbook(sheets,"电压暂降周报.xlsx",response); + } + + /** + * 创建标题 + * + * @param document 文档 + * @param message 标题内容 + * @param style 标题等级 + * @param line 缩进 + * @param fontSize 字体大小 + */ + public void createTitle(XWPFDocument document, String message, String style, int line, int fontSize) { + XWPFParagraph summaeTableParagraph = WordUtils.getLeftParagraph(document); + summaeTableParagraph.setStyle(style); + summaeTableParagraph.setIndentationFirstLine(line); + XWPFRun summaeTableRun = summaeTableParagraph.createRun(); + WordUtils.addParagraph(summaeTableRun, "宋体", fontSize, "000000", message, false); + } + + /** + * 监测点导出word + * + * @param exportParam . + * @param response . + * @throws InvalidFormatException . + * @throws IOException . + */ + @Override + public void getLineExport(ExportParam exportParam, HttpServletResponse response) throws IOException, InvalidFormatException, TemplateException, ParseException { + //创建word文档(poi生成word) + XWPFDocument doc = new XWPFDocument(); //创建Word文件 + //设置标题样式 + WordUtils.setHeadingStyle(doc); + XWPFParagraph p = doc.createParagraph(); //新建一个段落 + //设置对齐 + p.setAlignment(ParagraphAlignment.CENTER); + p.setVerticalAlignment(TextAlignment.CENTER); + XWPFRun r = p.createRun();//创建段落文本 + r.addBreak(); + r.addBreak(); + r.addBreak(); + r.addBreak(); + r.addBreak(); + r.addBreak(); + r.setText("中国"); + r.setBold(true);//设置为粗体 + r.setFontSize(14);//字体大小 + r.addBreak(); + + p = doc.createParagraph(); //新建一个段落 + p.setAlignment(ParagraphAlignment.CENTER); + XWPFRun r1 = p.createRun();//创建段落文本 + r1.setText("电压暂降事件分析报告"); + r1.setBold(true);//设置为粗体 + r1.setFontSize(36);//字体大小 + r1.addBreak(); + r1.addBreak(); + r1.addBreak(); + r1.addBreak(); + r1.addBreak(); + r1.addBreak(); + r1.addBreak(); + + p = doc.createParagraph(); //新建一个段落 + p.setAlignment(ParagraphAlignment.CENTER); + XWPFRun r2 = p.createRun();//创建段落文本 + //获取当前时间 + Date date = new Date(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy 年 MM 月 dd 日"); + String time = dateFormat.format(date); + + r2.setText("日期: " + time); + r2.setBold(true);//设置为粗体 + r2.setFontSize(14);//字体大小 + + r2.addBreak(); + r2.addBreak(); + r2.addBreak(); + + p = doc.createParagraph(); //新建一个段落 + p.setAlignment(ParagraphAlignment.CENTER); + XWPFRun r3 = p.createRun();//创建段落文本 + r3.setText("电压暂降事件区域报告"); + r3.setFontSize(24);//字体大小 + + p = doc.createParagraph(); //新建一个段落 + p.setAlignment(ParagraphAlignment.LEFT); + createTitle(doc,"1. 引言","标题 1",0,15); + + p = doc.createParagraph(); //新建一个段落 + p.setAlignment(ParagraphAlignment.BOTH); + XWPFRun r5 = p.createRun();//创建段落文本 + r5.setText("对所选中区间内电压暂降事件进行分析,能够直观清晰查看响应的暂降事件信息。"); + r5.setFontSize(11);//字体大小 + + p = doc.createParagraph(); //新建一个段落 + p.setAlignment(ParagraphAlignment.LEFT); + createTitle(doc,"2. 报告分析对象","标题 1",0,15); + + p = doc.createParagraph(); //新建一个段落 + p.setAlignment(ParagraphAlignment.BOTH); + XWPFRun r7 = p.createRun();//创建段落文本 + r7.setText(exportParam.getLineName()); + r7.setFontSize(11);//字体大小 + + p = doc.createParagraph(); //新建一个段落 + p.setAlignment(ParagraphAlignment.LEFT); + createTitle(doc,"3. 报告分析时间","标题 1",0,15); + + p = doc.createParagraph(); //新建一个段落 + p.setAlignment(ParagraphAlignment.BOTH); + XWPFRun r9 = p.createRun();//创建段落文本 + r9.setText(exportParam.getSearchBeginTime()+" 至 "+exportParam.getSearchEndTime()); + r9.setFontSize(11);//字体大小 + + p = doc.createParagraph(); //新建一个段落 + p.setAlignment(ParagraphAlignment.LEFT); + createTitle(doc,"4. 总汇信息","标题 1",0,15); + + //记录数 + int i = 1; + //监测点信息 + 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)){ + 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()); + i++; + } + //暂降事件列表 + if (exportParam.isLb()){ + createTitle(doc,"4."+i+" 暂降事件列表","标题 2",200,15); + XWPFTable table = createTable(doc); + XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc); + List plot = eventAnalysisService.getPlot(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag())); + 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()+""); + } + i++; + } + //暂降事件点图 + if (exportParam.isSjdF47() || exportParam.isSjdITIC()){ + List detailList = eventAnalysisService.getPlot(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag())); + createTitle(doc,"4."+i+" 暂降事件点图","标题 2",200,15); + int two = 1; + if (exportParam.isSjdITIC()){ + createTitle(doc,"4."+i+"."+two+" ITIC 曲线","标题 3",400,15); + ArrayList> list = new ArrayList<>(); + for (EventDetail eventDetail : detailList) { + ArrayList doubles = new ArrayList<>(); + doubles.add(Double.parseDouble(eventDetail.getPersistTime()/1000+"")); + doubles.add(Double.parseDouble(String.valueOf(eventDetail.getEventValue()*100))); + list.add(doubles); + } + String itic = getITIC(list); + createPic(doc,itic,"ITIC曲线"); + two++; + } + if (exportParam.isSjdF47()){ + createTitle(doc,"4."+i+"."+two+" F47 曲线","标题 3",400,15); + ArrayList> list = new ArrayList<>(); + for (EventDetail eventDetail : detailList) { + ArrayList doubles = new ArrayList<>(); + doubles.add(Double.parseDouble(eventDetail.getPersistTime()/1000+"")); + doubles.add(Double.parseDouble(String.valueOf(eventDetail.getEventValue()*100))); + list.add(doubles); + } + String f47 = getF47(list); + createPic(doc,f47,"SEMI F47曲线"); + two++; + } + i++; + } + //暂降密度 + 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); + two++; + } + if (exportParam.isMdbg()){ + XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc); + createTitle(doc,"4."+i+"."+two+" DISDIP 表格:国际发配电联盟(UNIPEDE)","标题 3",400,15); + List eventDisdip = eventAnalysisService.eventDisdip(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag())); + XWPFTable table1 = createTable(doc); + 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()); + } + two++; + 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())); + 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"); + 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()); + } + two++; + 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())); + 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"); + 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()); + } + two++; + } + i++; + } + //暂降幅值概率分布 + 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())); + int two = 1; + 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,"暂降幅值的概率分布函数"); + two++; + } + 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,"持续时间的概率分布函数"); + two++; + } + i++; + } + //月份统计 + if (exportParam.isTjbg() || exportParam.isTjtx()){ + createTitle(doc,"4."+i+" 月份统计","标题 2",200,15); + int two = 1; + List reasonTypeTime = eventAnalysisService.getReasonTypeTime(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag())); + if (exportParam.isTjtx()){ + createTitle(doc,"4."+i+"."+two+" 月份统计图","标题 3",400,15); + List count = new ArrayList<>(); + List name = new ArrayList<>(); + if (exportParam.getFlag()==0){ + for (TimeVO timeVO : reasonTypeTime) { + name.add(timeVO.getMonth()+""); + count.add(Integer.parseInt(timeVO.getTimes())); + } + }else { + for (TimeVO timeVO : reasonTypeTime) { + name.add(timeVO.getDay()+""); + count.add(Integer.parseInt(timeVO.getTimes())); + } + } + String yftj = getYFTJ(name, count, reasonTypeTime.get(0).getYear(),exportParam.getFlag()); + createPic(doc,yftj,"月份统计图"); + two++; + } + if (exportParam.isTjbg()){ + XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc); + 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){ + for (int j = 0; j < reasonTypeTime.size(); j++) { + TimeVO timeVO = reasonTypeTime.get(j); + insertRow(doc,table1,centerParagraph,false,timeVO.getMonth(),timeVO.getTimes()); + } + }else { + for (int j = 0; j < reasonTypeTime.size(); j++) { + TimeVO timeVO = reasonTypeTime.get(j); + insertRow(doc,table1,centerParagraph,false,timeVO.getDay(),timeVO.getTimes()); + } + } + two++; + } + i++; + } + //原因统计 + 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); + 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,"暂降原因图"); + two++; + } + if (exportParam.isYybg()){ + XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc); + createTitle(doc,"4."+i+"."+two+" 原因统计表格","标题 3",400,15); + XWPFTable table1 = createTable(doc); + 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()+""); + } + two++; + } + i++; + } + //类型统计 + 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); + List xdata = new ArrayList<>(); + List types = statistic.getTypes(); + for (TypesVO type : types) { + if (type.getTimes()>0){ + xdata.add(type.getType()); + } + } + String tr = getT(xdata, types, "bar8.ftl"); + createPic(doc,tr,"暂降类型图"); + two++; + } + 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,"暂降原因","电压暂降次数"); + 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()+""); + } + two++; + } + i++; + } + + ServletOutputStream outputStream = response.getOutputStream(); + String fileName = URLEncoder.encode(exportParam.getLineName()+".docx", "UTF-8"); + response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); + response.setContentType("application/octet-stream;charset=UTF-8"); + doc.write(outputStream); + outputStream.close(); + } + 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"); + } + + public String getPicName(JSONObject jsonObject){ + ResponseEntity forEntity = restTemplate.getForEntity("http://192.168.1.13:8910?opt={1}&width={2}&height={3}", HttpResult.class, jsonObject.toString(), 714, 300); + return forEntity.getBody().getData().toString(); + } + + public String getR(List xname,List map2,String barname) throws TemplateException, IOException { + HashMap map = new HashMap<>(); + map.put("typeArray",JSONArray.fromObject(xname).toString()); + map.put("valueArray",map2); + String str = getStr(barname, map); + return str; + } + + public String getT(List xname,List map2,String barname) throws TemplateException, IOException { + HashMap map = new HashMap<>(); + map.put("typeArray",JSONArray.fromObject(xname).toString()); + map.put("valueArray",map2); + String str = getStr(barname, map); + return str; + } + + public String getYFTJ(List xname, List times,String year,Integer flag) throws TemplateException, IOException { + HashMap map = new HashMap<>(); + xname.set(0,xname.get(0)+"\n"+"("+year+")"); + if (flag==0){ + map.put("text","月份统计"); + map.put("xname","月份"); + }else { + map.put("text","天数统计"); + map.put("xname","天数"); + } + map.put("months",JSONArray.fromObject(xname).toString()); + map.put("handle",JSONArray.fromObject(times).toString()); + String str = getStr("bar7.ftl", map); + return str; + } + + public String getFZ(List eventvalue,List pereventvalue) throws TemplateException, IOException { + HashMap map = new HashMap<>(); + map.put("eventValue",JSONArray.fromObject(eventvalue).toString()); + map.put("pereventValue",JSONArray.fromObject(pereventvalue).toString()); + String str = getStr("bar5.ftl", map); + return str; + } + + public String getSJ(List sisttime,List persisttime) throws TemplateException, IOException { + HashMap map = new HashMap<>(); + map.put("sisttime",JSONArray.fromObject(sisttime).toString()); + map.put("persisttime",JSONArray.fromObject(persisttime).toString()); + String str = getStr("bar6.ftl", map); + return str; + } + + public JSONObject getBar1(List xdata,List ydata,String tl,String title,String xname,String yname){ + //初始化option + GsonOption option = new GsonOption(); + //设置标头 + Title title1 = new Title(); + TextStyle textStyle1 = new TextStyle(); + + textStyle1.setFontWeight(700); + title1.text(title).x("center"); + title1.setTextStyle(textStyle1); + option.title(title1); + //图例 + option.legend().data(tl).x("left"); + option.color("#FF7E50"); + + CategoryAxis axis = new CategoryAxis(); + axis.data(xdata.toArray()); + axis.axisLabel(new AxisLabel().interval(0).show(true)); + // 起始和结束两端空白策略 + axis.boundaryGap(true); + axis.splitLine(new SplitLine().show(false)); + axis.name(xname); + option.xAxis(axis); + + Bar bar = new Bar(tl); + bar.setType(SeriesType.bar); + bar.data(ydata.toArray()); + bar.barMaxWidth(30); + setPosition(bar,"top","#FF7E50"); + option.series(bar); + + ValueAxis valueAxis = new ValueAxis(); + valueAxis.name(yname).type(AxisType.value); + option.yAxis(valueAxis); + + String replace = option.toString().replace(" ", ""); + + return new JSONObject(replace); + } + + public String getITIC(List> xbardata) throws TemplateException, IOException { + List> point = new ArrayList<>(); + List> pointno = new ArrayList<>(); + + for (int i = 0; i < xbardata.size(); i++) { + List list = xbardata.get(i); + //是否超过上限 + if (list.get(0)<=0.03){ + int line = 230 - 30000 * list.get(0).intValue(); + if (list.get(1)>line){ + pointno.add(list); + }else { + point.add(list); + } + }else if (list.get(0)<=0.02){ + if (list.get(1)>120){ + pointno.add(list); + }else { + point.add(list); + } + }else if (list.get(0)<=0.5){ + if (list.get(1)>120 || list.get(1)<70){ + pointno.add(list); + }else { + point.add(list); + } + }else if (list.get(0)<=10){ + if (list.get(1)>110 || list.get(1)<80){ + pointno.add(list); + }else { + point.add(list); + } + }else { + if (list.get(1)>110 || list.get(1)<90){ + pointno.add(list); + }else { + point.add(list); + } + } + } + + HashMap map = new HashMap<>(); + map.put("point",JSONArray.fromObject(point).toString()); + map.put("pointno",JSONArray.fromObject(pointno).toString()); + String str = getStr("bar3.ftl", map); + return str; + } + + public String getF47(List> xbardata) throws TemplateException, IOException { + List> point = new ArrayList<>(); + double[][] part = new double[8][2]; + part[0][0] = 0.05; + part[0][1] = 0; + part[1][0] = 0.05; + part[1][1] = 50; + part[2][0] = 0.2; + part[2][1] = 50; + part[3][0] = 0.2; + part[3][1] = 70; + part[4][0] = 0.5; + part[4][1] = 70; + part[5][0] = 0.5; + part[5][1] = 80; + part[6][0] = 10; + part[6][1] = 80; + part[7][0] = 1000; + part[7][1] = 80; + + double max = 0.0; + for (int i = 0; i < part.length; i++) { + if (part[i][1]>max){ + max = part[i][1]; + } + } + + List> pointno = new ArrayList<>(); + for (int i = 0; i < xbardata.size(); i++) { + List list = xbardata.get(i); + //是否超过上限 + if (list.get(0)<0.05){ + pointno.add(list); + }else if (list.get(0)<0.2){ + if (list.get(1)>50){ + point.add(list); + }else { + pointno.add(list); + } + }else if (list.get(0)<0.5){ + if (list.get(1)>70){ + point.add(list); + }else { + pointno.add(list); + } + }else { + if (list.get(1)>80){ + point.add(list); + }else { + pointno.add(list); + } + } + } + + HashMap map = new HashMap<>(); + map.put("zdz",max); + map.put("bjx",JSONArray.fromObject(part).toString()); + map.put("point",JSONArray.fromObject(point).toString()); + map.put("pointno",JSONArray.fromObject(pointno).toString()); + String str = getStr("bar4.ftl", map); + return str; + } + + /** + * + * @param bar + * @param position 位置 + * @param color 颜色 + */ + public void setPosition(Bar bar,String position,String color){ + //设置标签 + com.github.abel533.echarts.Label label = new Label(); + label.show(true); + label.position(position); + TextStyle textStyle = new TextStyle(); + textStyle.setColor(color); + ItemStyle itemStyle = new ItemStyle(); + label.setTextStyle(textStyle); + Normal normal = new Normal(); + normal.label(label); + itemStyle.setNormal(normal); + bar.setItemStyle(itemStyle); + } + + /** + * 表格插入行数据 + * + * @param document 文档 + * @param table 表格 + * @param head 是否是表头 + * @param values 数据内容 + */ + public static void insertRow(XWPFDocument document, XWPFTable table, XWPFParagraph excelParagraph, boolean head, + String... values) { + if (head) { + XWPFTableRow summaTableRowOne = table.getRow(0); + WordUtils.setExcelHeadContent(excelParagraph, summaTableRowOne, values); + } else { + XWPFTableRow summaTableRowOne = table.createRow(); + WordUtils.setExcelContent(excelParagraph, summaTableRowOne, values); + } + } + + /** + * 创建图片在word中 + * + * @param document 文档 + * @param image 图片base64 + * @param name 图片名 + * @throws IOException + * @throws InvalidFormatException + */ + public void createPic(XWPFDocument document, String image, String name) throws IOException, InvalidFormatException, InvalidFormatException { + XWPFParagraph picParagraph = WordUtils.getCenterParagraph(document); + XWPFRun createRun = picParagraph.createRun(); + BASE64Decoder decoder = new BASE64Decoder(); + byte[] bytes = decoder.decodeBuffer(image); + InputStream in = new ByteArrayInputStream(bytes); + createRun.addPicture(in, 5, name, Units.toEMU(410), Units.toEMU(170)); + } + + + /** + * 创建表格 + * + * @param document + * @return + */ + public XWPFTable createTable(XWPFDocument document) { + XWPFTable summaTable = document.createTable(); + // 列宽自动分割 + CTTblWidth summaTableWidth = summaTable.getCTTbl().addNewTblPr().addNewTblW(); + summaTableWidth.setType(STTblWidth.DXA); + summaTableWidth.setW(BigInteger.valueOf(8160)); + return summaTable; + } + + public void setCellStyle(HSSFCell cellname,String value,HSSFCellStyle style){ + cellname.setCellValue(value); + cellname.setCellStyle(style); + } + + + /** + * 获取事件报告 + * + * @author zbj + * @date 2022/7/29 + */ + @Override + public Page getEventReport(WaveTypeParam deviceInfoParam) { + List generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData(); + List lineIds = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList()); + //TODO 添加进去一个假的line_id + lineIds.add("6973ca7ea5dd4b0328496e4e1b871447"); + + + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + + //建立封装sql查询结果的集合 + List eventDetailList = new ArrayList<>(); + + //提前创建total + StringBuilder stringTotal = new StringBuilder(); + QueryResult resultTotal = new QueryResult(); + + //提前创建好统计在线离线的实体类,这样if和else都能访问到,并且只需要创建一个对象 + LineBaseQueryParam lineBaseQueryParam = new LineBaseQueryParam(); + + //提前创建查询框结果集合 + List resultList = new ArrayList<>(); + + //提前创建进行过查询过后的line_id集合 + List lineIdList = new ArrayList<>(); + + //TODO 在线,没有搜索框的值 + if (deviceInfoParam.getComFlag().equals(1) && Objects.isNull(deviceInfoParam.getSearchValue())) { + + lineBaseQueryParam.setLineIds(lineIds); + lineBaseQueryParam.setComFlag(deviceInfoParam.getComFlag()); + + //调用方法查看哪些在线 + List onOrUnLine = lineFeignClient.getOnOrUnLine(lineBaseQueryParam).getData(); + + + //调用创建好的line_id拼接工具 + StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(onOrUnLine); + + //判断当前检测点集合是否为空 + if (CollectionUtil.isNotEmpty(onOrUnLine)) { + + //触发类型为空 + if (Objects.isNull(deviceInfoParam.getWaveType())) { + + + StringBuilder stringResult = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE). + append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))).append("' and ").append("time <= '") + .append(DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))) + .append("' and ").append(stringBuilder); + + + //套用公式(page-1)*pageSize + int i1 = (deviceInfoParam.getPageNum() - 1) * deviceInfoParam.getPageSize(); + //拼接分页sql + stringResult.append(" LIMIT ").append(deviceInfoParam.getPageSize()).append(" OFFSET ").append(i1).append(" tz('Asia/Shanghai')"); + + //查询sql语句总条数 + stringTotal = new StringBuilder("SELECT COUNT(num) as aa FROM ").append(Param.EVENT_DETAIL).append(" WHERE ").append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))).append("' and ") + .append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))).append("' and "); + stringTotal.append(stringBuilder).append(" tz('Asia/Shanghai')"); + + //结果集 + QueryResult result = influxDbUtils.query(stringResult.toString()); + //总条数 + resultTotal = influxDbUtils.query(stringTotal.toString()); + + //结果集映射到对象中 + eventDetailList = influxDBResultMapper.toPOJO(result, WaveTypeVO.class); + + //如果集合中没有对象则返回空page + if (eventDetailList.size() == 0) { + return new Page<>(); + } + + + //触发类型不为空 + } else if (Objects.nonNull(deviceInfoParam.getWaveType())) { + + + StringBuilder stringResult = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE). + append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))).append("' and ").append("time <= '") + .append(DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))) + .append("' and ").append(stringBuilder).append(" and ").append("wave_type = ") + .append(deviceInfoParam.getWaveType()); + + + //套用公式(page-1)*pageSize + int i1 = (deviceInfoParam.getPageNum() - 1) * deviceInfoParam.getPageSize(); + //拼接分页sql + stringResult.append(" LIMIT ").append(deviceInfoParam.getPageSize()).append(" OFFSET ").append(i1).append(" tz('Asia/Shanghai')"); + + + //查询sql语句总条数 + stringTotal = new StringBuilder("SELECT COUNT(num) as aa FROM ").append(Param.EVENT_DETAIL).append(" WHERE ").append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))).append("' and ") + .append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))).append("' and "); + stringTotal.append(stringBuilder).append(" tz('Asia/Shanghai')"); + + //结果集 + QueryResult result = influxDbUtils.query(stringResult.toString()); + //总条数 + resultTotal = influxDbUtils.query(stringTotal.toString()); + + + //结果集映射到对象中 + eventDetailList = influxDBResultMapper.toPOJO(result, WaveTypeVO.class); + + + //如果集合中没有对象则返回空page + if (eventDetailList.size() == 0) { + return new Page<>(); + } + + + } + + + //获取关于监测点发电站相关信息 + HttpResult> baseLineAreaInfo = lineFeignClient.getBaseLineAreaInfo(lineIds); + System.out.println(baseLineAreaInfo); + //将返回的封装好的结果集进行还原成集合 + List areaLineList = baseLineAreaInfo.getData(); + + + //将监测点发电机相关信息copy到准备好的VO对象中 + for (WaveTypeVO waveTypeVO : eventDetailList) { + if (waveTypeVO.getLineId() != null) { + for (AreaLineInfoVO lineInfoVO : areaLineList) { + if (waveTypeVO.getLineId().equals(lineInfoVO.getLineId())) { + waveTypeVO.setSubName(lineInfoVO.getSubName()); + waveTypeVO.setLineId(lineInfoVO.getLineId()); + waveTypeVO.setLineName(lineInfoVO.getLineName()); + waveTypeVO.setGdId(lineInfoVO.getGdId()); + waveTypeVO.setGdName(lineInfoVO.getGdName()); + waveTypeVO.setVoltageId(lineInfoVO.getVoltageId()); + waveTypeVO.setNoDealCount(lineInfoVO.getNoDealCount()); + waveTypeVO.setCt1(lineInfoVO.getCt1()); + waveTypeVO.setCt2(lineInfoVO.getCt2()); + waveTypeVO.setPt1(lineInfoVO.getPt1()); + waveTypeVO.setPt2(lineInfoVO.getPt2()); + waveTypeVO.setRunFlag(lineInfoVO.getRunFlag()); + waveTypeVO.setComFlag(lineInfoVO.getComFlag()); + waveTypeVO.setIp(lineInfoVO.getIp()); + waveTypeVO.setLat(lineInfoVO.getLat()); + waveTypeVO.setLng(lineInfoVO.getLng()); + waveTypeVO.setManufacturer(lineInfoVO.getManufacturer()); + waveTypeVO.setVoltageScale(lineInfoVO.getVoltageScale()); + } + } + } + } + + + //使用字典表对暂态类型和暂态原因进行转换 + HttpResult> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()); + HttpResult> type = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()); + //获取字典数据暂态原因集合 + List eventReasonList = reason.getData(); + System.out.println(eventReasonList); + //获取字典数据暂态类型集合 + List eventTypeList = type.getData(); + System.out.println(eventTypeList); + + for (WaveTypeVO waveTypeVO : eventDetailList) { + if (waveTypeVO.getEventReason() != null) { + for (DictData dictData : eventReasonList) { + //将字典数据id与VO中属性eventReason对应的字符串进行比较 + if (waveTypeVO.getEventReason().equals(dictData.getId())) { + waveTypeVO.setEventReason(dictData.getName()); + } + } + } else { + //抛出异常,当前暂态原因为空 + throw new BusinessException(EventResponseEnum.EVENT_REASON_NOT_FOUND); + } + } + + for (WaveTypeVO waveTypeVO : eventDetailList) { + if (waveTypeVO.getEventType() != null) { + for (DictData dictData : eventTypeList) { + //将字典数据id与VO中属性eventType对应的字符串进行比较 + if (waveTypeVO.getEventType().equals(dictData.getId())) { + waveTypeVO.setEventType(dictData.getName()); + } + } + } else { + //抛出异常,当前暂态类型为空 + throw new BusinessException(EventResponseEnum.EVENT_TYPE_NOT_FOUND); + } + } + } else { + //返回空page对象 + return new Page<>(); + } + Page page = new Page<>(); + long total = new BigDecimal(resultTotal.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).longValue(); + page.setTotal(total); + page.setRecords(eventDetailList); + page.setCurrent(deviceInfoParam.getPageNum()); + page.setSize(deviceInfoParam.getPageSize()); + return page; + + + //TODO 在线,有搜索框的值 + } else if (deviceInfoParam.getComFlag().equals(1) && Objects.nonNull(deviceInfoParam.getSearchValue())) { + + //传入监测点集合和在线离线 + lineBaseQueryParam.setLineIds(lineIds); + lineBaseQueryParam.setComFlag(deviceInfoParam.getComFlag()); + //搜索框的值也传进去 + lineBaseQueryParam.setSearchValue(deviceInfoParam.getSearchValue()); + + //返回对象结果集合 + resultList = lineFeignClient.getRichLineInfo(lineBaseQueryParam).getData(); + + //进行循环遍历将line_id塞入集合 + for (AreaLineInfoVO areaLineInfoVO : resultList) { + lineIdList.add(areaLineInfoVO.getLineId()); + } + + //上面的方法已经将判断在线离线和搜索框结果一起返回了 + //调用方法查看哪些在线 + //List onOrUnLine = lineFeignClient.getOnOrUnLine(lineBaseQueryParam).getData(); + + //使用工具类替代fori循环,不然进行不了分页 + //调用创建好的line_id拼接工具,如:where id = '1' or id = '2' + StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIdList); + + //判断当前检测点集合是否为空 + if (CollectionUtil.isNotEmpty(lineIdList)) { + + //触发类型为空 + if (Objects.isNull(deviceInfoParam.getWaveType())) { + + + StringBuilder stringResult = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE). + append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))).append("' and ").append("time <= '") + .append(DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))) + .append("' and ").append(stringBuilder); + + + //套用公式(page-1)*pageSize + int i1 = (deviceInfoParam.getPageNum() - 1) * deviceInfoParam.getPageSize(); + //拼接分页sql + stringResult.append(" LIMIT ").append(deviceInfoParam.getPageSize()).append(" OFFSET ").append(i1).append(" tz('Asia/Shanghai')"); + + //查询sql语句总条数 + stringTotal = new StringBuilder("SELECT COUNT(num) as aa FROM ").append(Param.EVENT_DETAIL).append(" WHERE ").append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))).append("' and ") + .append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))).append("' and "); + stringTotal.append(stringBuilder).append(" tz('Asia/Shanghai')"); + + //结果集 + QueryResult result = influxDbUtils.query(stringResult.toString()); + //总条数 + resultTotal = influxDbUtils.query(stringTotal.toString()); + + //结果集映射到对象中 + eventDetailList = influxDBResultMapper.toPOJO(result, WaveTypeVO.class); + + + //如果集合中没有对象则返回空page + if (eventDetailList.size() == 0) { + return new Page<>(); + } + + + //触发类型不为空 + } else if (Objects.nonNull(deviceInfoParam.getWaveType())) { + + + StringBuilder stringResult = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE). + append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))).append("' and ").append("time <= '") + .append(DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))) + .append("' and ").append(stringBuilder).append(" and ").append("wave_type = ") + .append(deviceInfoParam.getWaveType()); + + + //套用公式(page-1)*pageSize + int i1 = (deviceInfoParam.getPageNum() - 1) * deviceInfoParam.getPageSize(); + //拼接分页sql + stringResult.append(" LIMIT ").append(deviceInfoParam.getPageSize()).append(" OFFSET ").append(i1).append(" tz('Asia/Shanghai')"); + + + //查询sql语句总条数 + stringTotal = new StringBuilder("SELECT COUNT(num) as aa FROM ").append(Param.EVENT_DETAIL).append(" WHERE ").append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))).append("' and ") + .append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))).append("' and "); + stringTotal.append(stringBuilder).append(" tz('Asia/Shanghai')"); + + //结果集 + QueryResult result = influxDbUtils.query(stringResult.toString()); + //总条数 + resultTotal = influxDbUtils.query(stringTotal.toString()); + + + //结果集映射到对象中 + eventDetailList = influxDBResultMapper.toPOJO(result, WaveTypeVO.class); + + + //如果集合中没有对象则返回空page + if (eventDetailList.size() == 0) { + return new Page<>(); + } + + } + + + //获取关于监测点发电站相关信息 + HttpResult> baseLineAreaInfo = lineFeignClient.getBaseLineAreaInfo(lineIds); + System.out.println(baseLineAreaInfo); + //将返回的封装好的结果集进行还原成集合 + List areaLineList = baseLineAreaInfo.getData(); + + + //将监测点发电机相关信息copy到准备好的VO对象中 + for (WaveTypeVO waveTypeVO : eventDetailList) { + if (waveTypeVO.getLineId() != null) { + for (AreaLineInfoVO lineInfoVO : areaLineList) { + if (waveTypeVO.getLineId().equals(lineInfoVO.getLineId())) { + waveTypeVO.setSubName(lineInfoVO.getSubName()); + waveTypeVO.setLineId(lineInfoVO.getLineId()); + waveTypeVO.setLineName(lineInfoVO.getLineName()); + waveTypeVO.setGdId(lineInfoVO.getGdId()); + waveTypeVO.setGdName(lineInfoVO.getGdName()); + waveTypeVO.setVoltageId(lineInfoVO.getVoltageId()); + waveTypeVO.setNoDealCount(lineInfoVO.getNoDealCount()); + waveTypeVO.setCt1(lineInfoVO.getCt1()); + waveTypeVO.setCt2(lineInfoVO.getCt2()); + waveTypeVO.setPt1(lineInfoVO.getPt1()); + waveTypeVO.setPt2(lineInfoVO.getPt2()); + waveTypeVO.setRunFlag(lineInfoVO.getRunFlag()); + waveTypeVO.setComFlag(lineInfoVO.getComFlag()); + waveTypeVO.setIp(lineInfoVO.getIp()); + waveTypeVO.setLat(lineInfoVO.getLat()); + waveTypeVO.setLng(lineInfoVO.getLng()); + waveTypeVO.setManufacturer(lineInfoVO.getManufacturer()); + waveTypeVO.setVoltageScale(lineInfoVO.getVoltageScale()); + } + } + } else { + //抛出异常,当前监测点id为空 + throw new BusinessException(EventResponseEnum.EVENT_NOT_FOUND); + } + } + + + //使用字典表对暂态类型和暂态原因进行转换 + HttpResult> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()); + HttpResult> type = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()); + //获取字典数据暂态原因集合 + List eventReasonList = reason.getData(); + System.out.println(eventReasonList); + //获取字典数据暂态类型集合 + List eventTypeList = type.getData(); + System.out.println(eventTypeList); + + for (WaveTypeVO waveTypeVO : eventDetailList) { + if (waveTypeVO.getEventReason() != null) { + for (DictData dictData : eventReasonList) { + //将字典数据id与VO中属性eventReason对应的字符串进行比较 + if (waveTypeVO.getEventReason().equals(dictData.getId())) { + waveTypeVO.setEventReason(dictData.getName()); + } + } + } else { + //抛出异常,当前暂态原因为空 + throw new BusinessException(EventResponseEnum.EVENT_REASON_NOT_FOUND); + } + } + + for (WaveTypeVO waveTypeVO : eventDetailList) { + if (waveTypeVO.getEventType() != null) { + for (DictData dictData : eventTypeList) { + //将字典数据id与VO中属性eventType对应的字符串进行比较 + if (waveTypeVO.getEventType().equals(dictData.getId())) { + waveTypeVO.setEventType(dictData.getName()); + } + } + } else { + //抛出异常,当前暂态类型为空 + throw new BusinessException(EventResponseEnum.EVENT_TYPE_NOT_FOUND); + } + } + } else { + //集合没有id,返回空对象 + return new Page<>(); + + } + Page page = new Page<>(); + long total = new BigDecimal(resultTotal.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).longValue(); + page.setTotal(total); + page.setRecords(eventDetailList); + page.setCurrent(deviceInfoParam.getPageNum()); + page.setSize(deviceInfoParam.getPageSize()); + return page; + + + //TODO 不在线,并且没有搜索框的值 + } else if (deviceInfoParam.getComFlag().equals(0) && Objects.isNull(deviceInfoParam.getSearchValue())) { + + //set参数,查询不在线人数 + lineBaseQueryParam.setLineIds(lineIds); + lineBaseQueryParam.setComFlag(deviceInfoParam.getComFlag()); + + //调用方法查看哪些离线 + List unLine = lineFeignClient.getOnOrUnLine(lineBaseQueryParam).getData(); + + + //使用工具类替代fori循环,不然进行不了分页 + //调用创建好的line_id拼接工具,如:where id = '1' or id = '2' + StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(unLine); + + //判断当前检测点集合是否为空 + if (CollectionUtil.isNotEmpty(unLine)) { + + //触发类型为空 + if (Objects.isNull(deviceInfoParam.getWaveType())) { + + + StringBuilder stringResult = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE). + append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))).append("' and ").append("time <= '") + .append(DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))) + .append("' and ").append(stringBuilder); + + + //套用公式(page-1)*pageSize + int i1 = (deviceInfoParam.getPageNum() - 1) * deviceInfoParam.getPageSize(); + //拼接分页sql + stringResult.append(" LIMIT ").append(deviceInfoParam.getPageSize()).append(" OFFSET ").append(i1).append(" tz('Asia/Shanghai')"); + + + //查询sql语句总条数 + stringTotal = new StringBuilder("SELECT COUNT(num) as aa FROM ").append(Param.EVENT_DETAIL).append(" WHERE ").append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))).append("' and ") + .append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))).append("' and "); + stringTotal.append(stringBuilder).append(" tz('Asia/Shanghai')"); + + //结果集 + QueryResult result = influxDbUtils.query(stringResult.toString()); + //总条数 + resultTotal = influxDbUtils.query(stringTotal.toString()); + + + //结果集映射到对象中 + eventDetailList = influxDBResultMapper.toPOJO(result, WaveTypeVO.class); + + + //如果集合中没有对象则返回空page + if (eventDetailList.size() == 0) { + return new Page<>(); + } + + //触发类型不为空 + } else if (Objects.nonNull(deviceInfoParam.getWaveType())) { + + + StringBuilder stringResult = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE). + append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))).append("' and ").append("time <= '") + .append(DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))) + .append("' and ").append(stringBuilder).append(" and ").append("wave_type = ") + .append(deviceInfoParam.getWaveType()); + + + //套用公式(page-1)*pageSize + int i1 = (deviceInfoParam.getPageNum() - 1) * deviceInfoParam.getPageSize(); + //拼接分页sql + stringResult.append(" LIMIT ").append(deviceInfoParam.getPageSize()).append(" OFFSET ").append(i1).append(" tz('Asia/Shanghai')"); + + + //查询sql语句总条数 + stringTotal = new StringBuilder("SELECT COUNT(num) as aa FROM ").append(Param.EVENT_DETAIL).append(" WHERE ").append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))).append("' and ") + .append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))).append("' and "); + stringTotal.append(stringBuilder).append(" tz('Asia/Shanghai')"); + + //结果集 + QueryResult result = influxDbUtils.query(stringResult.toString()); + //总条数 + resultTotal = influxDbUtils.query(stringTotal.toString()); + + + //结果集映射到对象中 + eventDetailList = influxDBResultMapper.toPOJO(result, WaveTypeVO.class); + + + //如果集合中没有对象则返回空page + if (eventDetailList.size() == 0) { + return new Page<>(); + } + + } + + + //获取关于监测点发电站相关信息 + HttpResult> baseLineAreaInfo = lineFeignClient.getBaseLineAreaInfo(lineIds); + System.out.println(baseLineAreaInfo); + //将返回的封装好的结果集进行还原成集合 + List areaLineList = baseLineAreaInfo.getData(); + + + //将监测点发电机相关信息copy到准备好的VO对象中 + for (WaveTypeVO waveTypeVO : eventDetailList) { + if (waveTypeVO.getLineId() != null) { + for (AreaLineInfoVO lineInfoVO : areaLineList) { + if (waveTypeVO.getLineId().equals(lineInfoVO.getLineId())) { + waveTypeVO.setSubName(lineInfoVO.getSubName()); + waveTypeVO.setLineId(lineInfoVO.getLineId()); + waveTypeVO.setLineName(lineInfoVO.getLineName()); + waveTypeVO.setGdId(lineInfoVO.getGdId()); + waveTypeVO.setGdName(lineInfoVO.getGdName()); + waveTypeVO.setVoltageId(lineInfoVO.getVoltageId()); + waveTypeVO.setNoDealCount(lineInfoVO.getNoDealCount()); + waveTypeVO.setCt1(lineInfoVO.getCt1()); + waveTypeVO.setCt2(lineInfoVO.getCt2()); + waveTypeVO.setPt1(lineInfoVO.getPt1()); + waveTypeVO.setPt2(lineInfoVO.getPt2()); + waveTypeVO.setRunFlag(lineInfoVO.getRunFlag()); + waveTypeVO.setComFlag(lineInfoVO.getComFlag()); + waveTypeVO.setIp(lineInfoVO.getIp()); + waveTypeVO.setLat(lineInfoVO.getLat()); + waveTypeVO.setLng(lineInfoVO.getLng()); + waveTypeVO.setManufacturer(lineInfoVO.getManufacturer()); + waveTypeVO.setVoltageScale(lineInfoVO.getVoltageScale()); + } + } + } + } + + + //使用字典表对暂态类型和暂态原因进行转换 + HttpResult> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()); + HttpResult> type = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()); + //获取字典数据暂态原因集合 + List eventReasonList = reason.getData(); + System.out.println(eventReasonList); + //获取字典数据暂态类型集合 + List eventTypeList = type.getData(); + System.out.println(eventTypeList); + + for (WaveTypeVO waveTypeVO : eventDetailList) { + if (waveTypeVO.getEventReason() != null) { + for (DictData dictData : eventReasonList) { + //将字典数据id与VO中属性eventReason对应的字符串进行比较 + if (waveTypeVO.getEventReason().equals(dictData.getId())) { + waveTypeVO.setEventReason(dictData.getName()); + break; + } + } + } else { + //抛出异常,当前暂态原因为空 + throw new BusinessException(EventResponseEnum.EVENT_REASON_NOT_FOUND); + } + } + + for (WaveTypeVO waveTypeVO : eventDetailList) { + if (waveTypeVO.getEventType() != null) { + for (DictData dictData : eventTypeList) { + //将字典数据id与VO中属性eventType对应的字符串进行比较 + if (waveTypeVO.getEventType().equals(dictData.getId())) { + waveTypeVO.setEventType(dictData.getName()); + break; + } + } + } else { + //抛出异常,当前暂态类型为空 + throw new BusinessException(EventResponseEnum.EVENT_TYPE_NOT_FOUND); + } + } + } else { + //当前id未查询到结果,new 空对象返回 + return new Page<>(); + + } + Page page = new Page<>(); + long total = new BigDecimal(resultTotal.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).longValue(); + page.setTotal(total); + page.setRecords(eventDetailList); + page.setCurrent(deviceInfoParam.getPageNum()); + page.setSize(deviceInfoParam.getPageSize()); + return page; + + + //TODO 不在线,并且有搜索框的值 + } else { + + //传入监测点集合和在线离线 + lineBaseQueryParam.setLineIds(lineIds); + lineBaseQueryParam.setComFlag(deviceInfoParam.getComFlag()); + //搜索框的值也传进去 + lineBaseQueryParam.setSearchValue(deviceInfoParam.getSearchValue()); + + //返回对象结果集合 + resultList = lineFeignClient.getRichLineInfo(lineBaseQueryParam).getData(); + + //进行循环遍历将line_id塞入集合 + for (AreaLineInfoVO areaLineInfoVO : resultList) { + lineIdList.add(areaLineInfoVO.getLineId()); + } + + //上面的方法已经将判断在线离线和搜索框结果一起返回了 + //调用方法查看哪些在线 + //List unLine = lineFeignClient.getOnOrUnLine(lineBaseQueryParam).getData(); + + //使用工具类替代fori循环,不然进行不了分页 + //调用创建好的line_id拼接工具,如:where id = '1' or id = '2' + StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIdList); + + //判断当前检测点集合是否为空 + if (CollectionUtil.isNotEmpty(lineIdList)) { + + //触发类型为空 + if (Objects.isNull(deviceInfoParam.getWaveType())) { + + + StringBuilder stringResult = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE). + append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))).append("' and ").append("time <= '") + .append(DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))) + .append("' and ").append(stringBuilder); + + + //套用公式(page-1)*pageSize + int i1 = (deviceInfoParam.getPageNum() - 1) * deviceInfoParam.getPageSize(); + //拼接分页sql + stringResult.append(" LIMIT ").append(deviceInfoParam.getPageSize()).append(" OFFSET ").append(i1).append(" tz('Asia/Shanghai')"); + + + //查询sql语句总条数 + stringTotal = new StringBuilder("SELECT COUNT(num) as aa FROM ").append(Param.EVENT_DETAIL).append(" WHERE ").append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))).append("' and ") + .append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))).append("' and "); + stringTotal.append(stringBuilder).append(" tz('Asia/Shanghai')"); + + //结果集 + QueryResult result = influxDbUtils.query(stringResult.toString()); + //总条数 + resultTotal = influxDbUtils.query(stringTotal.toString()); + + + //结果集映射到对象中 + eventDetailList = influxDBResultMapper.toPOJO(result, WaveTypeVO.class); + + + //如果集合中没有对象则返回空page + if (eventDetailList.size() == 0) { + return new Page<>(); + } + + //触发类型不为空 + } else if (Objects.nonNull(deviceInfoParam.getWaveType())) { + + + StringBuilder stringResult = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE). + append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))).append("' and ").append("time <= '") + .append(DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))) + .append("' and ").append(stringBuilder).append(" and ").append("wave_type = ") + .append(deviceInfoParam.getWaveType()); + + + //套用公式(page-1)*pageSize + int i1 = (deviceInfoParam.getPageNum() - 1) * deviceInfoParam.getPageSize(); + //拼接分页sql + stringResult.append(" LIMIT ").append(deviceInfoParam.getPageSize()).append(" OFFSET ").append(i1).append(" tz('Asia/Shanghai')"); + + + //查询sql语句总条数 + stringTotal = new StringBuilder("SELECT COUNT(num) as aa FROM ").append(Param.EVENT_DETAIL).append(" WHERE ").append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))).append("' and ") + .append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))).append("' and "); + stringTotal.append(stringBuilder).append(" tz('Asia/Shanghai')"); + + //结果集 + QueryResult result = influxDbUtils.query(stringResult.toString()); + //总条数 + resultTotal = influxDbUtils.query(stringTotal.toString()); + + + //结果集映射到对象中 + eventDetailList = influxDBResultMapper.toPOJO(result, WaveTypeVO.class); + + + //如果集合中没有对象则返回空page + if (eventDetailList.size() == 0) { + return new Page<>(); + } + + } + + + //获取关于监测点发电站相关信息 + HttpResult> baseLineAreaInfo = lineFeignClient.getBaseLineAreaInfo(lineIds); + System.out.println(baseLineAreaInfo); + //将返回的封装好的结果集进行还原成集合 + List areaLineList = baseLineAreaInfo.getData(); + + + //将监测点发电机相关信息copy到准备好的VO对象中 + for (WaveTypeVO waveTypeVO : eventDetailList) { + if (waveTypeVO.getLineId() != null) { + for (AreaLineInfoVO lineInfoVO : areaLineList) { + if (waveTypeVO.getLineId().equals(lineInfoVO.getLineId())) { + waveTypeVO.setSubName(lineInfoVO.getSubName()); + waveTypeVO.setLineId(lineInfoVO.getLineId()); + waveTypeVO.setLineName(lineInfoVO.getLineName()); + waveTypeVO.setGdId(lineInfoVO.getGdId()); + waveTypeVO.setGdName(lineInfoVO.getGdName()); + waveTypeVO.setVoltageId(lineInfoVO.getVoltageId()); + waveTypeVO.setNoDealCount(lineInfoVO.getNoDealCount()); + waveTypeVO.setCt1(lineInfoVO.getCt1()); + waveTypeVO.setCt2(lineInfoVO.getCt2()); + waveTypeVO.setPt1(lineInfoVO.getPt1()); + waveTypeVO.setPt2(lineInfoVO.getPt2()); + waveTypeVO.setRunFlag(lineInfoVO.getRunFlag()); + waveTypeVO.setComFlag(lineInfoVO.getComFlag()); + waveTypeVO.setIp(lineInfoVO.getIp()); + waveTypeVO.setLat(lineInfoVO.getLat()); + waveTypeVO.setLng(lineInfoVO.getLng()); + waveTypeVO.setManufacturer(lineInfoVO.getManufacturer()); + waveTypeVO.setVoltageScale(lineInfoVO.getVoltageScale()); + } + } + } + } + + + //使用字典表对暂态类型和暂态原因进行转换 + HttpResult> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()); + HttpResult> type = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()); + //获取字典数据暂态原因集合 + List eventReasonList = reason.getData(); + System.out.println(eventReasonList); + //获取字典数据暂态类型集合 + List eventTypeList = type.getData(); + System.out.println(eventTypeList); + + for (WaveTypeVO waveTypeVO : eventDetailList) { + if (waveTypeVO.getEventReason() != null) { + for (DictData dictData : eventReasonList) { + //将字典数据id与VO中属性eventReason对应的字符串进行比较 + if (waveTypeVO.getEventReason().equals(dictData.getId())) { + waveTypeVO.setEventReason(dictData.getName()); + break; + } + } + } else { + //抛出异常,当前暂态原因为空 + throw new BusinessException(EventResponseEnum.EVENT_REASON_NOT_FOUND); + } + } + + for (WaveTypeVO waveTypeVO : eventDetailList) { + if (waveTypeVO.getEventType() != null) { + for (DictData dictData : eventTypeList) { + //将字典数据id与VO中属性eventType对应的字符串进行比较 + if (waveTypeVO.getEventType().equals(dictData.getId())) { + waveTypeVO.setEventType(dictData.getName()); + break; + } + } + } else { + //抛出异常,当前暂态类型为空 + throw new BusinessException(EventResponseEnum.EVENT_TYPE_NOT_FOUND); + } + } + } else { + //如果集合中没有对象则返回空page + return new Page<>(); + } + Page page = new Page<>(); + long total = new BigDecimal(resultTotal.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).longValue(); + page.setTotal(total); + page.setRecords(eventDetailList); + page.setCurrent(deviceInfoParam.getPageNum()); + page.setSize(deviceInfoParam.getPageSize()); + return page; + } + + } + + /** + * 获取区域报告 + * + * @author zbj + * @date 2022/8/4 + */ + @Override + public void getAreaReport(AreaReportParam areaReportParam, HttpServletResponse response) throws Exception { + + //暂态事件 + if (areaReportParam.getWaveType().equals(0)) { + //设置类型变量名为暂态 + String typeName = "暂态"; + + //事件统计表格 + List generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(areaReportParam).getData(); + //这是总的监测点id + List lineIds = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList()); + + //创建部门参数数据 + AreaReportParam areaParam = new AreaReportParam(); + areaParam.setDeptIndex(areaReportParam.getDeptIndex()); + //创建Code对象 + SimpleDTO simpleDTO = new SimpleDTO(); + //电压等级 + simpleDTO.setCode(StatisticsEnum.VOLTAGE_LEVEL.getCode()); + simpleDTO.setName(StatisticsEnum.VOLTAGE_LEVEL.getName()); + + + areaParam.setStatisticalType(simpleDTO); + areaParam.setMonitorFlag(areaReportParam.getMonitorFlag()); + areaParam.setPowerFlag(areaReportParam.getPowerFlag()); + areaParam.setServerName(areaReportParam.getServerName()); + areaParam.setStatFlag(areaReportParam.getStatFlag()); + areaParam.setSearchBeginTime(areaReportParam.getSearchBeginTime()); + areaParam.setSearchEndTime(areaReportParam.getSearchEndTime()); + + + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + //提前创建,不然获取不到 + List eventDetailList = new ArrayList<>(); + + + //创建幅值计数器 + int oneCount2 = 0; + + //创建ITIC与F47计数器 + int oneCount3 = 0; + int twoCount5 = 0; + + //创建暂降密度表和密度图的计数器 + int oneCount4 = 0; + int twoCount1 = 0; + + //创建暂降事件表格和图的计数器 + int oneCount5 = 0; + int twoCount2 = 0; + + //创建暂态类型图和暂态类型表格计数器 + int oneCount6 = 0; + int twoCount3 = 0; + + //创建暂态原因图和暂态原因表格计数器 + 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); + } + + + } + + + //准备word表中参数 + //获取监测点总数量 + int size = lineIds.size(); + //还有当前传入的部门名称(例如:中国)需要等邓哥的公共方法 + String deptName = deptFeignClient.getDeptById(areaReportParam.getDeptIndex()).getData().getName(); + + + /** + * =====================生成word=========================== + */ + //设置序号初始值 + int oneCount = 1; + + //创建word文档(poi生成word) + XWPFDocument doc = new XWPFDocument();// 创建Word文件 + XWPFParagraph p = doc.createParagraph();// 新建一个段落 + + // 设定标题格式,可以生成可点击的序号 + WordUtils.setHeadingStyle(doc); + + //设置对齐 + p.setAlignment(ParagraphAlignment.CENTER); + XWPFRun r = p.createRun();//创建段落文本 + r.addBreak(); + r.addBreak(); + r.addBreak(); + r.addBreak(); + r.addBreak(); + r.addBreak(); + r.setText("中国供电公司"); + r.setBold(true);//设置为粗体 + r.setFontSize(14);//字体大小 + r.addBreak(); + + + p = doc.createParagraph();// 新建一个段落 + p.setAlignment(ParagraphAlignment.CENTER); + XWPFRun r1 = p.createRun();//创建段落文本 + r1.setText("电压"+typeName+"事件区域报告"); + r1.setBold(true);//设置为粗体 + r1.setFontSize(36);//字体大小 + r1.addBreak(); + r1.addBreak(); + r1.addBreak(); + r1.addBreak(); + r1.addBreak(); + r1.addBreak(); + r1.addBreak(); + + + p = doc.createParagraph();// 新建一个段落 + p.setAlignment(ParagraphAlignment.CENTER); + XWPFRun r2 = p.createRun();//创建段落文本 + //获取当前时间 + Date date = new Date(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy 年 MM 月 dd 日"); + String time = dateFormat.format(date); + + r2.setText("日期: " + time); + r2.setBold(true);//设置为粗体 + r2.setFontSize(14);//字体大小 + + r2.addBreak(); + r2.addBreak(); + r2.addBreak(); + + + p = doc.createParagraph();// 新建一个段落 + p.setAlignment(ParagraphAlignment.CENTER); + XWPFRun r3 = p.createRun();//创建段落文本 + r3.setText("电压"+typeName+"事件区域报告"); + r3.setFontSize(24);//字体大小 + + + createTitle(doc, "1. 引言", "标题 1", 0, 15); + + + 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.setFontSize(11);//字体大小 + + + createTitle(doc, "2. 报告分析对象", "标题 1", 0, 15); + + + p = doc.createParagraph();// 新建一个段落 + p.setAlignment(ParagraphAlignment.BOTH); + XWPFRun r7 = p.createRun();//创建段落文本 + r7.setText(" " + deptName + "。"); + r7.setFontSize(11);//字体大小 + + + createTitle(doc, "3. 报告分析时间", "标题 1", 0, 15); + + + p = doc.createParagraph();// 新建一个段落 + p.setAlignment(ParagraphAlignment.BOTH); + XWPFRun r9 = p.createRun();//创建段落文本 + r9.setText(" " + areaReportParam.getSearchBeginTime() + " 至 " + areaReportParam.getSearchEndTime() + "。"); + r9.setFontSize(11);//字体大小 + + + createTitle(doc, "4. 汇总信息", "标题 1", 0, 15); + + + if (areaReportParam.isMonitorDistributeChart()) { + //监测网分布 + + + //在线监测点数 + Integer onLineIdCount = lineFeignClient.getOnLineCount(lineIds).getData(); + //离线总监测点数 + Integer unLineCount = Integer.valueOf(lineIds.size()) - onLineIdCount; + //在线率 + Double onlineRate = (onLineIdCount.doubleValue()) / (Double.valueOf(String.valueOf(lineIds.size()))) * 100; + + NumberFormat nf = NumberFormat.getNumberInstance(); + // 保留两位小数 + nf.setMaximumFractionDigits(2); + // 如果不需要四舍五入 + nf.setRoundingMode(RoundingMode.UP); + + 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文档============================================== + */ + + + createTitle(doc, "4." + oneCount + " 监测网分布", "标题 2", 200, 11); + + p = doc.createParagraph();// 新建一个段落 + p.setAlignment(ParagraphAlignment.BOTH); + XWPFRun r12 = p.createRun();//创建段落文本 + r12.setText(" 中国电网总共有监测点" + size + "个。监测点在线率达到" + onlineRateResult + "%(通讯正常为:" + onLineIdCount + "个,通讯异常为:" + unLineCount + "个)" + + "[通讯正常/总监测点数(统计时候排除检修和热备用监测点)],具体见下图:"); + r12.setFontSize(11);//字体大小 + + + //代码 + + //序号计数进行++ + oneCount++; + + /** + * =======================================word结束========================================= + */ + } + if (areaReportParam.isEventCountTable()) { + //暂降事件三表 + + //所有的表结果装入集合 + 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 ("0".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文档============================================== + */ + + //创建表题计数 + 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; + + + 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); + + + //创建部门与监测点次数的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集合 + 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())); + } + + + String dydj = getDYDJ(xdata3, ydata3); + createPic(doc, dydj, ""+typeName+"事件图形"); + + + //序号计数进行++ + oneCount++; + + /** + * =======================================word结束========================================= + */ + + } + + } + 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; + } + } + } + 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);//字体大小 + + + 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结束========================================= + */ + } + if (areaReportParam.isDensityChart()) { + //暂降密度图形 + + 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; + } + } + } + System.out.println(resultList); + /** + * =========================续写word文档============================================== + */ + + //如果暂降幅值被勾选,就不需要进行写段落 + 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++; + } + /** + * =======================================word结束========================================= + */ + } + if (areaReportParam.isItic()) { + //itic图 + + AreaTableParam areaTableParam = new AreaTableParam(); + + //监测点id拼接 + StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds); + areaTableParam.setStartTime(areaReportParam.getSearchBeginTime()); + areaTableParam.setEndTime(areaReportParam.getSearchEndTime()); + areaTableParam.setStringBuilder(stringBuilder); + + + //创建结果集合 + List info = TableInfo(areaTableParam); + + //将sql结果集放入,共用一个sql,减少查询时间 + AreaTableParam areaTableParam1 = new AreaTableParam(); + areaTableParam1.setStartTime(areaReportParam.getSearchBeginTime()); + areaTableParam1.setEndTime(areaReportParam.getSearchEndTime()); + areaTableParam1.setStringBuilder(stringBuilder); + areaTableParam1.setInfo(info); + + + List detailList = getPlotArea(areaTableParam1); + + List obs = new ArrayList<>(); + ArrayList> list = new ArrayList<>(); + for (EventDetailNew eventDetail : detailList) { + obs.add(new OB(Double.parseDouble(eventDetail.getPersistTime() / 1000 + "") + , Double.parseDouble(eventDetail.getEventValue() * 100 + ""))); + + ArrayList doubles = new ArrayList<>(); + doubles.add(Double.parseDouble(eventDetail.getPersistTime() / 1000 + "")); + doubles.add(Double.parseDouble(String.valueOf(eventDetail.getEventValue() * 100))); + list.add(doubles); + } + + List result = getITICArea(obs); + + /** + * =========================续写word文档============================================== + */ + //创建表题计数 + int twoCount = 1; + + oneCount3 = oneCount; + + 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.setFontSize(11);//字体大小 + + + createTitle(doc, "4." + oneCount3 + "." + twoCount + " ITIC 曲线", "标题 3", 400, 11); + + p = doc.createParagraph();// 新建一个段落 + p.setAlignment(ParagraphAlignment.BOTH); + XWPFRun r13 = p.createRun();//创建段落文本 + r13.setText(" ITIC曲线中可容忍"+typeName+"记录为:" + result.get(0) + "条;不可容忍"+typeName+"记录为:" + result.get(1) + "条,具体见下表(图):"); + r13.setFontSize(11);//字体大小 + + + String itic = getITIC(list); + createPic(doc, itic, "ITIC曲线"); + + + twoCount5 = twoCount; + //序号计数进行++ + oneCount++; + + /** + * =======================================word结束========================================= + */ + + + } + if (areaReportParam.isF47()) { + //f47图 + + 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 detailList = getPlotArea(areaTableParam1); + + List obs = new ArrayList<>(); + + ArrayList> list = new ArrayList<>(); + for (EventDetailNew eventDetail : detailList) { + obs.add(new OB(Double.parseDouble(eventDetail.getPersistTime() / 1000 + ""), Double.parseDouble(eventDetail.getEventValue() * 100 + ""))); + + ArrayList doubles = new ArrayList<>(); + doubles.add(Double.parseDouble(eventDetail.getPersistTime() / 1000 + "")); + doubles.add(Double.parseDouble(String.valueOf(eventDetail.getEventValue() * 100))); + list.add(doubles); + } + + + List result = getF47Area(obs); + + /** + * =========================续写word文档============================================== + */ + + if (areaReportParam.isItic()) { + twoCount5++; + + createTitle(doc, "4." + oneCount3 + "." + twoCount5 + " F47 曲线", "标题 3", 400, 11); + + p = doc.createParagraph();// 新建一个段落 + p.setAlignment(ParagraphAlignment.BOTH); + XWPFRun r13 = p.createRun();//创建段落文本 + r13.setText(" F47曲线中可容忍"+typeName+"记录为:" + result.get(0) + "条;不可容忍"+typeName+"记录为:" + result.get(1) + "条,具体见下表(图):"); + r13.setFontSize(11);//字体大小 + + + String f47 = getF47(list); + createPic(doc, f47, "SEMI F47曲线"); + + /** + * =======================================word结束========================================= + */ + } else { + //创建表题计数 + int twoCount = 1; + + oneCount3 = oneCount; + + 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.setFontSize(11);//字体大小 + + + createTitle(doc, "4." + oneCount + "." + twoCount + " F47 曲线", "标题 3", 400, 11); + + p = doc.createParagraph();// 新建一个段落 + p.setAlignment(ParagraphAlignment.BOTH); + XWPFRun r13 = p.createRun();//创建段落文本 + r13.setText(" F47曲线中可容忍"+typeName+"降记录为:" + result.get(0) + "条;不可容忍"+typeName+"记录为:" + result.get(1) + "条,具体见下表(图):"); + r13.setFontSize(11);//字体大小 + + + String f47 = getF47(list); + createPic(doc, f47, "SEMI F47曲线"); + + + //序号计数进行++ + oneCount++; + + /** + * =======================================word结束========================================= + */ + } + + + } + if (areaReportParam.isSagAmplitude()) { + //暂降分布幅值 + 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); + ProbabilityVO probabilityDistributionArea = getProbabilityDistributionArea(areaTableParam1); + + + List eventvalue = probabilityDistributionArea.getEventvalue(); + + List amplitudeList = new ArrayList<>(); + + List xName = new ArrayList<>(); + xName.add("0"); + xName.add("10%"); + xName.add("20%"); + xName.add("30%"); + xName.add("40%"); + xName.add("50%"); + xName.add("60%"); + xName.add("70%"); + xName.add("80%"); + xName.add("90%"); + //将幅值绑定对应的x值,放入集合 + for (int i = 0; i < eventvalue.size(); i++) { + AmplitudeCountParam amplitudeCountParam = new AmplitudeCountParam(); + amplitudeCountParam.setXName(xName.get(i)); + amplitudeCountParam.setYValue(eventvalue.get(i)); + amplitudeList.add(amplitudeCountParam); + } + //存储幅值结果集合 + List amplitudeResult = new ArrayList<>(); + for (int i = 1; i < amplitudeList.size(); i++) { + if (!amplitudeList.get(i).getYValue().equals(amplitudeList.get(i - 1).getYValue())) { + amplitudeResult.add(amplitudeList.get(i - 1).getXName()); + amplitudeResult.add(amplitudeList.get(i).getXName()); + break; + } else if (amplitudeList.get(0).getYValue().equals(amplitudeList.get(amplitudeList.size() - 1).getYValue())) { + amplitudeResult.add(amplitudeList.get(0).getXName()); + amplitudeResult.add(amplitudeList.get(amplitudeList.size() - 1).getXName()); + break; + } + } + + + List eventvalue1 = probabilityDistributionArea.getSisttime(); + + List amplitudeList1 = new ArrayList<>(); + + List xName1 = new ArrayList<>(); + xName1.add("0.01"); + xName1.add("0.1"); + xName1.add("0.25"); + xName1.add("0.5"); + xName1.add("1"); + xName1.add("3"); + xName1.add("20"); + xName1.add("60"); + xName1.add("180"); + //将幅值绑定对应的x值,放入集合 + for (int i = 0; i < eventvalue1.size(); i++) { + AmplitudeCountParam amplitudeCountParam = new AmplitudeCountParam(); + amplitudeCountParam.setXName(xName1.get(i)); + amplitudeCountParam.setYValue(eventvalue1.get(i)); + amplitudeList1.add(amplitudeCountParam); + } + //存储幅值结果集合 + List amplitudeResult1 = new ArrayList<>(); + for (int i = 1; i < amplitudeList1.size(); i++) { + if (!amplitudeList1.get(i).getYValue().equals(amplitudeList1.get(i - 1).getYValue())) { + amplitudeResult1.add(amplitudeList1.get(i - 1).getXName()); + amplitudeResult1.add(amplitudeList1.get(i).getXName()); + break; + } else if (amplitudeList1.get(0).getYValue().equals(amplitudeList1.get(amplitudeList1.size() - 1).getYValue())) { + amplitudeResult1.add(amplitudeList1.get(0).getXName()); + amplitudeResult1.add(amplitudeList1.get(amplitudeList1.size() - 1).getXName()); + break; + } + } + + + /** + * =========================续写word文档============================================== + */ + //创建表题计数 + int twoCount = 1; + + oneCount2 = oneCount; + + 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.setFontSize(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+"幅值的概率分布函数"); + + + //序号计数进行++ + oneCount++; + + /** + * =======================================word结束========================================= + */ + + } + if (areaReportParam.isDuration()) { + //持续时间概率分布 + + + AreaTableParam areaTableParam = new AreaTableParam(); + + //监测点id拼接 + StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds); + areaTableParam.setStartTime(areaReportParam.getSearchBeginTime()); + areaTableParam.setEndTime(areaReportParam.getSearchEndTime()); + areaTableParam.setStringBuilder(stringBuilder); + + + //创建结果集合 + List info = TableInfo(areaTableParam); + + //将sql结果集放入,共用一个sql,减少查询时间 + AreaTableParam areaTableParam1 = new AreaTableParam(); + areaTableParam1.setStartTime(areaReportParam.getSearchBeginTime()); + areaTableParam1.setEndTime(areaReportParam.getSearchEndTime()); + areaTableParam1.setStringBuilder(stringBuilder); + areaTableParam1.setInfo(info); + ProbabilityVO probabilityDistributionArea = getProbabilityDistributionArea(areaTableParam1); + + System.out.println(probabilityDistributionArea); + + List eventvalue = probabilityDistributionArea.getEventvalue(); + + List amplitudeList = new ArrayList<>(); + + List xName = new ArrayList<>(); + xName.add("0"); + xName.add("10%"); + xName.add("20%"); + xName.add("30%"); + xName.add("40%"); + xName.add("50%"); + xName.add("60%"); + xName.add("70%"); + xName.add("80%"); + xName.add("90%"); + //将幅值绑定对应的x值,放入集合 + for (int i = 0; i < eventvalue.size(); i++) { + AmplitudeCountParam amplitudeCountParam = new AmplitudeCountParam(); + amplitudeCountParam.setXName(xName.get(i)); + amplitudeCountParam.setYValue(eventvalue.get(i)); + amplitudeList.add(amplitudeCountParam); + } + //存储幅值结果集合 + List amplitudeResult = new ArrayList<>(); + for (int i = 1; i < amplitudeList.size(); i++) { + if (!amplitudeList.get(i).getYValue().equals(amplitudeList.get(i - 1).getYValue())) { + amplitudeResult.add(amplitudeList.get(i - 1).getXName()); + amplitudeResult.add(amplitudeList.get(i).getXName()); + break; + } else if (amplitudeList.get(0).getYValue().equals(amplitudeList.get(amplitudeList.size() - 1).getYValue())) { + amplitudeResult.add(amplitudeList.get(0).getXName()); + amplitudeResult.add(amplitudeList.get(amplitudeList.size() - 1).getXName()); + break; + } + } + + + List eventvalue1 = probabilityDistributionArea.getSisttime(); + + List amplitudeList1 = new ArrayList<>(); + + List xName1 = new ArrayList<>(); + xName1.add("0.01"); + xName1.add("0.1"); + xName1.add("0.25"); + xName1.add("0.5"); + xName1.add("1"); + xName1.add("3"); + xName1.add("20"); + xName1.add("60"); + xName1.add("180"); + //将幅值绑定对应的x值,放入集合 + for (int i = 0; i < eventvalue1.size(); i++) { + AmplitudeCountParam amplitudeCountParam = new AmplitudeCountParam(); + amplitudeCountParam.setXName(xName1.get(i)); + amplitudeCountParam.setYValue(eventvalue1.get(i)); + amplitudeList1.add(amplitudeCountParam); + } + //存储幅值结果集合 + List amplitudeResult1 = new ArrayList<>(); + for (int i = 1; i < amplitudeList1.size(); i++) { + if (!amplitudeList1.get(i).getYValue().equals(amplitudeList1.get(i - 1).getYValue())) { + amplitudeResult1.add(amplitudeList1.get(i - 1).getXName()); + amplitudeResult1.add(amplitudeList1.get(i).getXName()); + break; + } else if (amplitudeList1.get(0).getYValue().equals(amplitudeList1.get(amplitudeList1.size() - 1).getYValue())) { + amplitudeResult1.add(amplitudeList1.get(0).getXName()); + amplitudeResult1.add(amplitudeList1.get(amplitudeList1.size() - 1).getXName()); + break; + } + } + /** + * =========================续写word文档============================================== + */ + + //创建表题计数 + int twoCount = 1; + + //如果暂降幅值被勾选,就不需要进行写段落 + if (areaReportParam.isSagAmplitude()) { + twoCount++; + + //如果幅值图存在与幅值的序号保持同步 + createTitle(doc, "4." + oneCount2 + "." + twoCount + " 时序时间的概率分函数", "标题 3", 400, 11); + + + List ybardata = probabilityDistributionArea.getPersisttime(); + List ylinedata = probabilityDistributionArea.getSisttime(); + String sj = getSJ(ylinedata, ybardata); + createPic(doc, sj, "持续时间的概率分布函数"); + + + } else { + 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.setFontSize(11);//字体大小 + + + createTitle(doc, "4." + oneCount + "." + twoCount + " 时序时间的概率分函数", "标题 3", 400, 11); + + + //代码 + + + //序号计数进行++ + oneCount++; + } + /** + * =======================================word结束========================================= + */ + } + if (areaReportParam.isEventRelevanceCountTable()) { + //事件关联统计表格 + + //创建存储总次数的集合 + Map resultCount = new HashMap<>(); + + //创建存储time的集合 + Map timeCount = new HashMap<>(); + + + //提前创建line_id拼接工具,如:where id = '1' or id = '2' + StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(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 <= '") + .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("eventass_index != '' ").append(" tz('Asia/Shanghai')"); + ; + + //查询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(" 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(); + //count有默认值为0,不用进行非空判断,将结果集装入准备好的集合中 + resultCount.put("count", count); + } else { + long count = 0; + //count有默认值为0,不用进行非空判断,将结果集装入准备好的集合中 + resultCount.put("count", count); + } + + //将时间数存入集合Map集合 + for (EventDetailNew detail : eventDetailList) { + timeCount.put(detail.getEventassIndex(), detail.getTimeId()); + } + + int resultCount1 = 0; + List resultList = new ArrayList<>(); + for (String s : timeCount.keySet()) { + + + StringBuilder stringResult1 = new StringBuilder(Param.SELECT).append("pqs_eventass").append(Param.WHERE). + append("event_time = '").append(s).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()); + eventassCountParam.setEventTime(timeCount.get(s).toString()); + eventassCountParam.setDescribe(eventass.getDescribe()); + resultList.add(eventassCountParam); + } + resultCount1 = eventassList.size() + resultCount1; + + } + + +/** + * =========================续写word文档============================================== + */ + + + createTitle(doc, "4." + oneCount + " 事件关联分析", "标题 2", 200, 11); + + p = doc.createParagraph();// 新建一个段落 + p.setAlignment(ParagraphAlignment.BOTH); + XWPFRun r12 = p.createRun();//创建段落文本 + //归一化需要高级算法,先字符串代替 + r12.setText(" 中国电网在所选择的分析时间段内累计监测"+typeName+"记录" + resultCount.get("count") + "条,归一化统计后共" + resultCount1 + "[此为归一化后的暂态事件结果]条,,具体如下图所示:"); + r12.setFontSize(11);//字体大小 + + + //第三张表 + XWPFTable monitorInfo2 = createTable(doc); + XWPFParagraph monitorInfoExcelParagraph2 = WordUtils.getCenterParagraph(doc); + + // 表格第一行 + insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, true, "时间", "事件关联分析名称", "事件关联分析表述"); + + + //塞入数据 + for (int i = 0; i < resultList.size(); i++) { + insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, false, resultList.get(i).getAssTime(), resultList.get(i).getEventTime(), resultList.get(i).getDescribe()); + } + //序号计数进行++ + oneCount++; + + /** + * =======================================word结束========================================= + */ + + } + if (areaReportParam.isEventReasonTable()) { + //暂降原因表格 + + //查询字典表 + 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; + + + 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); + + //创建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+"原因图"); + + //序号计数进行++ + oneCount++; + } + /** + * =======================================word结束========================================= + */ + } + if (areaReportParam.isEventTypeTable()) { + //暂降类型表格 + + //查询字典表 + 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; + + + 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); + + + //创建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+"类型图"); + + //序号计数进行++ + oneCount++; + } + /** + * =======================================word结束========================================= + */ + } + 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.setFontSize(11);//字体大小 + + //所有的表结果装入集合 + Map areaCount1 = new HashMap<>(); + + //进行遍历集合获得子区域名及其所有监测点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())) { + areaCount1.put(generalDeviceDTO.getName(), 0); + + } else { + double count = Double.valueOf(resultTotal.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()); + + areaCount1.put(generalDeviceDTO.getName(), Integer.valueOf((int) count)); + } + + } else { + //为空put 0 + areaCount1.put(generalDeviceDTO.getName(), 0); + } + } + + + System.out.println(areaCount1); + //转为List对象集合 + List areaCountList1 = new ArrayList<>(); + for (String s : areaCount1.keySet()) { + ReportCountParam reportCountParam = new ReportCountParam(); + reportCountParam.setName(s); + reportCountParam.setCount(areaCount1.get(s).toString()); + areaCountList1.add(reportCountParam); + } + + System.out.println(areaCountList1); + + //序号计数进行++ + oneCount++; + + /** + * =======================================word结束========================================= + */ + + } + + + //文件下载 + /* FileOutputStream out = new FileOutputStream("C:\\Users\\User\\Desktop\\中国热力图.docx"); + doc.write(out); + out.close();*/ + //文件下载 + ServletOutputStream outputStream = response.getOutputStream(); + String fileName = URLEncoder.encode("中国热力图.docx", "UTF-8"); + response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); + response.setContentType("application/octet-stream;charset=UTF-8"); + doc.write(outputStream); + outputStream.close(); + + //暂降事件 + } else { + + } + + } + + /** + * zbj + * + * @param areaTableParam + * @return + */ + //区域IEC28Area + public List IEC28Area(AreaTableParam areaTableParam) { + 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 < areaTableParam.getInfo().size(); i++) { + Double eventvalue = areaTableParam.getInfo().get(i).getEventValue(); + double persisttime = areaTableParam.getInfo().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; + } + + public List IEC411Area(AreaTableParam areaTableParam) { + 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 < areaTableParam.getInfo().size(); i++) { + Double eventvalue = areaTableParam.getInfo().get(i).getEventValue(); + double persisttime = areaTableParam.getInfo().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; + } + + public List eventDisdipArea(AreaTableParam areaTableParam) { + 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 < areaTableParam.getInfo().size(); i++) { + Double eventvalue = areaTableParam.getInfo().get(i).getEventValue(); + double persisttime = areaTableParam.getInfo().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; + } + + //区域sql结果集(暂态) + public List TableInfo(AreaTableParam areaTableParam) { + + StringBuilder stringResult = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE). + append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(areaTableParam.getStartTime()))).append("' and ").append("time <= '") + .append(DateUtil.endOfDay(DateUtil.parse(areaTableParam.getEndTime()))) + .append("' and ").append(areaTableParam.getStringBuilder()).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 query = influxDbUtils.query(stringResult.toString()); + + + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + List info = influxDBResultMapper.toPOJO(query, EventDetailNew.class); + + return info; + } + + //区域sql结果集(暂降) + public List TableInfo1(AreaTableParam areaTableParam) { + + StringBuilder stringResult = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE). + append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(areaTableParam.getStartTime()))).append("' and ").append("time <= '") + .append(DateUtil.endOfDay(DateUtil.parse(areaTableParam.getEndTime()))) + .append("' and ").append(areaTableParam.getStringBuilder()).append(" tz('Asia/Shanghai')"); + + + //结果集 + QueryResult query = influxDbUtils.query(stringResult.toString()); + + + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + List info = influxDBResultMapper.toPOJO(query, EventDetailNew.class); + + return info; + } + + //重写ITIC曲线图 + public List getPlotArea(AreaTableParam areaTableParam) { + + return areaTableParam.getInfo(); + } + + //获取区域幅值 + public ProbabilityVO getProbabilityDistributionArea(AreaTableParam areaTableParam) { + ProbabilityVO result = new ProbabilityVO(); + List info = new ArrayList<>(); + + //总数 + Integer count = 0; + for (EventDetailNew eventDetail : areaTableParam.getInfo()) { + //过滤掉大于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 (EventDetailNew 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 (EventDetailNew 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 (EventDetailNew 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 (EventDetailNew 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; + } + + + public List getITICArea(List xbardata) { + double[][] top = new double[7][2]; + top[0][0] = 0.001; + top[0][1] = 200; + top[1][0] = 0.003; + top[1][1] = 140; + top[2][0] = 0.003; + top[2][1] = 120; + top[3][0] = 0.5; + top[3][1] = 120; + top[4][0] = 0.5; + top[4][1] = 110; + top[5][0] = 10; + top[5][1] = 110; + top[6][0] = 1000; + top[6][1] = 110; + + double[][] bot = new double[7][2]; + bot[0][0] = 0.02; + bot[0][1] = 0; + bot[1][0] = 0.02; + bot[1][1] = 70; + bot[2][0] = 0.5; + bot[2][1] = 70; + bot[3][0] = 0.5; + bot[3][1] = 80; + bot[4][0] = 10; + bot[4][1] = 80; + bot[5][0] = 10; + bot[5][1] = 90; + bot[6][0] = 1000; + bot[6][1] = 90; + + double[][] point = new double[xbardata.size()][2]; + double[][] pointno = new double[xbardata.size()][2]; + int t = 0; + int n = 0; + for (int i = 0; i < xbardata.size(); i++) { + OB ob = xbardata.get(i); + //是否超过上限 + if (ob.getA() <= 0.03) { + int line = 230 - 30000 * (int) ob.getA(); + if (ob.getB() > line) { + pointno[i][0] = ob.getA(); + pointno[i][1] = ob.getB(); + n++; + } else { + point[i][0] = ob.getA(); + point[i][1] = ob.getB(); + t++; + } + } else if (ob.getA() <= 0.02) { + if (ob.getB() > 120) { + pointno[i][0] = ob.getA(); + pointno[i][1] = ob.getB(); + n++; + } else { + point[i][0] = ob.getA(); + point[i][1] = ob.getB(); + t++; + } + } else if (ob.getA() <= 0.5) { + if (ob.getB() > 120 || ob.getB() < 70) { + pointno[i][0] = ob.getA(); + pointno[i][1] = ob.getB(); + n++; + } else { + point[i][0] = ob.getA(); + point[i][1] = ob.getB(); + t++; + } + } else if (ob.getA() <= 10) { + if (ob.getB() > 110 || ob.getB() < 80) { + pointno[i][0] = ob.getA(); + pointno[i][1] = ob.getB(); + n++; + } else { + point[i][0] = ob.getA(); + point[i][1] = ob.getB(); + t++; + } + } else { + if (ob.getB() > 110 || ob.getB() < 90) { + pointno[i][0] = ob.getA(); + pointno[i][1] = ob.getB(); + n++; + } else { + point[i][0] = ob.getA(); + point[i][1] = ob.getB(); + t++; + } + } + } + + + ArrayList list = new ArrayList<>(); + list.add(t); + list.add(n); + return list; + } + + //重写了f47图形 + public List getF47Area(List xbardata) { + + double[][] part = new double[8][2]; + part[0][0] = 0.05; + part[0][1] = 0; + part[1][0] = 0.05; + part[1][1] = 50; + part[2][0] = 0.2; + part[2][1] = 50; + part[3][0] = 0.2; + part[3][1] = 70; + part[4][0] = 0.5; + part[4][1] = 70; + part[5][0] = 0.5; + part[5][1] = 80; + part[6][0] = 10; + part[6][1] = 80; + part[7][0] = 1000; + part[7][1] = 80; + + double[][] point = new double[xbardata.size()][2]; + double[][] pointno = new double[xbardata.size()][2]; + int t = 0; + int n = 0; + for (int i = 0; i < xbardata.size(); i++) { + OB ob = xbardata.get(i); + //是否超过上限 + if (ob.getA() < 0.05) { + point[i][0] = ob.getA(); + point[i][1] = ob.getB(); + t++; + } else if (ob.getA() < 0.2) { + if (ob.getB() > 50) { + point[i][0] = ob.getA(); + point[i][1] = ob.getB(); + t++; + } else { + pointno[i][0] = ob.getA(); + pointno[i][1] = ob.getB(); + n++; + } + } else if (ob.getA() < 0.5) { + if (ob.getB() > 70) { + point[i][0] = ob.getA(); + point[i][1] = ob.getB(); + t++; + } else { + pointno[i][0] = ob.getA(); + pointno[i][1] = ob.getB(); + n++; + } + } else { + if (ob.getB() > 80) { + point[i][0] = ob.getA(); + point[i][1] = ob.getB(); + t++; + } else { + pointno[i][0] = ob.getA(); + pointno[i][1] = ob.getB(); + n++; + } + } + } + ArrayList list = new ArrayList<>(); + list.add(t); + list.add(n); + return list; + } + + public String getDYDJ(List eventvalue, List pereventvalue) throws TemplateException, IOException { + HashMap map = new HashMap<>(); + map.put("xvalue", JSONArray.fromObject(eventvalue).toString()); + map.put("yvalue", JSONArray.fromObject(pereventvalue).toString()); + String str = getStr("dydj.ftl", map); + return str; + } + + public String getQYTJ(List eventvalue, List pereventvalue) throws TemplateException, IOException { + HashMap map = new HashMap<>(); + map.put("xvalue", JSONArray.fromObject(eventvalue).toString()); + map.put("yvalue", JSONArray.fromObject(pereventvalue).toString()); + String str = getStr("qytj.ftl", map); + return str; + } + + public String getYFTJ1(List eventvalue, List pereventvalue, List pereventvalue1, String year, List test) throws TemplateException, IOException { + HashMap map = new HashMap<>(); + eventvalue.set(0, eventvalue.get(0) + "\n" + "(" + year + ")"); + map.put("xvalue", JSONArray.fromObject(eventvalue).toString()); + map.put("yvalue1", JSONArray.fromObject(pereventvalue).toString()); + map.put("yvalue2", JSONArray.fromObject(pereventvalue1).toString()); + map.put("test", JSONArray.fromObject(test).toString()); + String str = getStr("yftj.ftl", map); + return str; + } + + +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/TransientServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/TransientServiceImpl.java index 8b932968b..913783210 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/TransientServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/TransientServiceImpl.java @@ -1,5 +1,8 @@ package com.njcn.event.service.Impl; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.common.config.GeneralInfo; import com.njcn.common.pojo.dto.wave.WaveDataDTO; @@ -10,17 +13,29 @@ import com.njcn.common.utils.wave.AnalyWave; import com.njcn.device.api.GeneralDeviceInfoClient; import com.njcn.device.api.LineFeignClient; import com.njcn.device.pojo.dto.GeneralDeviceDTO; +import com.njcn.device.pojo.vo.AreaLineInfoVO; import com.njcn.device.pojo.vo.LineDetailDataVO; -import com.njcn.event.config.EventBaseConfig; import com.njcn.event.enums.EventResponseEnum; import com.njcn.event.mapper.TransientMapper; import com.njcn.event.pojo.param.TransientParam; import com.njcn.event.pojo.param.WaveFileParam; import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.pojo.po.EventDetailNew; +import com.njcn.event.pojo.vo.AreaLineVO; import com.njcn.event.pojo.vo.TransientVO; import com.njcn.event.service.EventDetailService; import com.njcn.event.service.TransientService; +import com.njcn.influxdb.mapper.InfluxDBResultMapperCn; +import com.njcn.influxdb.param.InfluxDBPublicParam; +import com.njcn.influxdb.utils.InfluxDBCommUtils; +import com.njcn.influxdb.utils.InfluxDbUtils; +import com.njcn.system.api.DicDataFeignClient; +import com.njcn.system.enums.DicDataTypeEnum; +import com.njcn.system.pojo.po.DictData; +import io.swagger.models.auth.In; import lombok.AllArgsConstructor; +import org.influxdb.dto.QueryResult; +import org.influxdb.impl.InfluxDBResultMapper; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -52,12 +67,16 @@ public class TransientServiceImpl implements TransientService { private final LineFeignClient lineFeignClient; + private final DicDataFeignClient dicDataFeignClient; + private final TransientMapper transientMapper; private final EventDetailService eventDetailService; private final GeneralInfo generalInfo; + private final InfluxDbUtils influxDbUtils; + @Override public Page getTransientData(TransientParam transientParam) { Page page = new Page<>(); @@ -117,7 +136,7 @@ public class TransientServiceImpl implements TransientService { transientVO.setTrigType("暂降"); break; case 2: - transientVO.setTrigType("赞升"); + transientVO.setTrigType("暂升"); break; case 3: transientVO.setTrigType("中断"); @@ -231,6 +250,187 @@ public class TransientServiceImpl implements TransientService { return response; } + @Override + public Page getTransientValue(TransientParam transientParam){ + Page page = new Page<>(); + page.setSize(transientParam.getPageSize()); + page.setCurrent(transientParam.getPageNum()); + //List transientVos = new ArrayList<>(); + //transientParam.setServerName(ServerEnum.HARMONIC.getName()); + //按部门分类的实际运行终端综合信息 + List generalDeviceDTOList = generalDeviceInfoClient.getPracticalRunDeviceInfo(transientParam).getData(); + if (!CollectionUtils.isEmpty(generalDeviceDTOList)) { + //获取按终端分类的监测点索引集合 + List lineList = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList()); + + if (!CollectionUtils.isEmpty(lineList)) { + StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineList); + //influxDB查询待分页数据总量 + Long total = getTransientDetail(stringBuilder,transientParam); + page.setTotal(total); + //分页总页数 + int pages = (int) Math.ceil(transientParam.getPageNum() * 1.0 / transientParam.getPageSize()); + page.setPages(pages); + //influxDB分页查询 + List eventDetailData = getTransientDetailLimit(lineList, transientParam); + + if (CollUtil.isNotEmpty(eventDetailData)) { + List lineIds = eventDetailData.stream().map(EventDetailNew::getLineId).collect(Collectors.toList()); + lineIds = lineIds.stream().distinct().collect(Collectors.toList()); + + List r = lineFeignClient.getBaseLineAreaInfo(lineIds).getData(); + List reasonList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()).getData(); + List typeList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()).getData(); + + //List transientData = transientMapper.getTransientData(lineIds); + for (EventDetailNew eventDetail : eventDetailData) { + for(AreaLineInfoVO areaLineInfoVO : r){ + if(eventDetail.getLineId().equals(areaLineInfoVO.getLineId())){ + eventDetail.setLineId(areaLineInfoVO.getLineId()); + eventDetail.setLineName(areaLineInfoVO.getLineName()); + eventDetail.setGdName(areaLineInfoVO.getGdName()); + eventDetail.setSubName(areaLineInfoVO.getSubName()); + eventDetail.setIp(areaLineInfoVO.getIp()); + eventDetail.setScale(areaLineInfoVO.getVoltageScale()); + break; + } + } + + for (DictData dictData : reasonList) { + if (eventDetail.getEventReason().equals(dictData.getId())) { + eventDetail.setEventReason(dictData.getName()); + break; + } + } + + for (DictData dictData : typeList) { + if (eventDetail.getEventType().equals(dictData.getId())) { + eventDetail.setEventType(dictData.getName()); + break; + } + } + } + + + //当前页数据 + page.setRecords(eventDetailData); + } + + } + + } + return page; + } + + /** + * 查询数据库 + */ + private Long getTransientDetail(StringBuilder stringBuilder,TransientParam transientParam) { + Long total = 0L; + //组装sql语句 + stringBuilder.append(" and time >= '").append(DateUtil.beginOfDay(DateUtil.parse(transientParam.getSearchBeginTime()))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(transientParam.getSearchEndTime()))).append("'").append(InfluxDBPublicParam.TIME_ZONE); + //sql语句 + String sql = "SELECT count(wave_type) FROM pqs_eventdetail WHERE " + stringBuilder; + System.out.println("sql------------->>>"+sql); + //结果集 + QueryResult result = influxDbUtils.query(sql); + //结果集映射到对象中 + List series = result.getResults().get(0).getSeries(); + if(CollUtil.isNotEmpty(series)){ + Double tem =(Double)series.get(0).getValues().get(0).get(1); + total = tem.longValue(); + } + return total; + } + + /** + * 根据条件拼接sql语句 + */ + private List getTransientDetailLimit(List lineIndexes, TransientParam transientParam) { + //查询数据是否为空,不为空拼接sql语句 + StringBuilder querySql = new StringBuilder(); + if(Objects.nonNull(transientParam.getEventValueMin())){ + querySql.append(" and event_value >=").append(transientParam.getEventValueMin()); + } + if(Objects.nonNull(transientParam.getEventValueMax())){ + querySql.append(" and event_value <=").append(transientParam.getEventValueMax()); + } + + if(Objects.nonNull(transientParam.getPersistMin())){ + querySql.append(" and persist_time >=").append(transientParam.getPersistMin()); + } + if(Objects.nonNull(transientParam.getEventValueMax())){ + querySql.append(" and persist_time <=").append(transientParam.getPersistMax()); + } + + if(Objects.nonNull(transientParam.getSeverityMin())){ + querySql.append(" and severity >=").append(transientParam.getSeverityMin()); + } + if(Objects.nonNull(transientParam.getSeverityMax())){ + querySql.append(" and severity <=").append(transientParam.getSeverityMax()); + } + if(Objects.nonNull(transientParam.getFileFlag())){ + querySql.append(" and file_flag = ").append(transientParam.getFileFlag()); + } + + if(CollUtil.isNotEmpty(transientParam.getWaveType())) { + querySql.append(" and ( "); + for (int i = 0; i < transientParam.getWaveType().size(); i++) { + if (transientParam.getWaveType().size() - i != 1) { + querySql.append("wave_type =").append(transientParam.getWaveType().get(i)).append(" or "); + } else { + querySql.append("wave_type =").append(transientParam.getWaveType().get(i)).append(") "); + } + } + } + if(CollUtil.isNotEmpty(transientParam.getEventReason())) { + querySql.append(" and ( "); + for (int i = 0; i < transientParam.getEventReason().size(); i++) { + if (transientParam.getWaveType().size() - i != 1) { + querySql.append("event_reason =").append(transientParam.getEventReason().get(i)).append(" or "); + } else { + querySql.append("event_reason =").append(transientParam.getEventReason().get(i)).append(") "); + } + } + } + if(CollUtil.isNotEmpty(transientParam.getEventType())) { + querySql.append(" and ( "); + for (int i = 0; i < transientParam.getEventType().size(); i++) { + if (transientParam.getEventType().size() - i != 1) { + querySql.append("event_type =").append(transientParam.getEventType().get(i)).append(" or "); + } else { + querySql.append("event_type =").append(transientParam.getEventType().get(i)).append(") "); + } + } + } + + //组装sql语句 + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(transientParam.getSearchBeginTime()))) + .append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(transientParam.getSearchEndTime()))).append("'") + .append(querySql); + stringBuilder.append(" and ("); + for (int i = 0; i < lineIndexes.size(); i++) { + if (lineIndexes.size() - i != 1) { + stringBuilder.append("line_id ='").append(lineIndexes.get(i)).append("' or "); + } else { + stringBuilder.append("line_id ='").append(lineIndexes.get(i)).append("') "); + } + } + int i = (transientParam.getPageNum() - 1)*transientParam.getPageSize(); + stringBuilder.append("LIMIT ").append(transientParam.getPageSize()).append(" OFFSET ").append(i).append(" tz('Asia/Shanghai')"); + //sql语句 + String sql = "SELECT * FROM pqs_eventdetail WHERE " + stringBuilder; + System.out.println("sql====================="+sql); + //结果集 + QueryResult queryresult = influxDbUtils.query(sql); + //结果集映射到对象中 + InfluxDBResultMapperCn influxDBResultMapper = new InfluxDBResultMapperCn(); + List eventDetailList = influxDBResultMapper.toPOJO(queryresult, EventDetailNew.class); + + return eventDetailList; + } + /** * 复制保存文件 */ @@ -459,7 +659,7 @@ public class TransientServiceImpl implements TransientService { try { String filePath = filePathAndName; filePath = filePath.toString(); - java.io.File myDelFile = new java.io.File(filePath); + File myDelFile = new File(filePath); myDelFile.delete(); } catch (Exception e) { System.out.println("删除文件操作出错"); diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/ReportService.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/ReportService.java new file mode 100644 index 000000000..bdc0c6e4f --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/ReportService.java @@ -0,0 +1,61 @@ +package com.njcn.event.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.njcn.device.pojo.param.DeviceInfoParam; +import com.njcn.event.pojo.param.*; +import com.njcn.event.pojo.vo.DetailVO; +import com.njcn.event.pojo.vo.GeneralVO; +import com.njcn.event.pojo.vo.ReasonsVO; +import com.njcn.event.pojo.vo.WaveTypeVO; +import freemarker.template.TemplateException; +import org.apache.poi.openxml4j.exceptions.InvalidFormatException; + +import javax.servlet.http.HttpServletResponse; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.text.ParseException; +import java.util.List; + +/** + * @author xxy + * @version 1.0.0 + * @date 2022年07月28日 13:32 + */ +public interface ReportService { + + List getGeneralSituation(DeviceInfoParam.BusinessParam businessParam); + + List getVoltage(DeviceInfoParam.BusinessParam businessParam); + + List getSeverity(DeviceInfoParam.BusinessParam businessParam); + + List getReason(DeviceInfoParam.BusinessParam businessParam); + + Page getContinueTime(WaveTypeParam waveTypeParam); + + Page getSagTimes(WaveTypeParam waveTypeParam); + + Page getUpTimes(WaveTypeParam waveTypeParam); + + Page getBreakTimes(WaveTypeParam waveTypeParam); + + void getExport(DeviceInfoParam.BusinessParam businessParam, HttpServletResponse response) throws IOException, TemplateException; + + 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; + + +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/TransientService.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/TransientService.java index 345e56c8f..e78739de6 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/TransientService.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/TransientService.java @@ -4,9 +4,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.common.pojo.dto.wave.WaveDataDTO; import com.njcn.event.pojo.param.TransientParam; import com.njcn.event.pojo.param.WaveFileParam; +import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.pojo.po.EventDetailNew; import com.njcn.event.pojo.vo.TransientVO; import javax.servlet.http.HttpServletResponse; +import java.util.List; /** * @author: chenchao @@ -34,5 +37,10 @@ public interface TransientService { * @return */ HttpServletResponse downloadWaveFile(WaveFileParam waveFileParam, HttpServletResponse response) throws Exception; - + /** + * 功能描述: 根据条件查询暂态事件 + * @param transientParam + * @return + */ + Page getTransientValue(TransientParam transientParam); } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar.ftl b/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar.ftl new file mode 100644 index 000000000..4e61d097a --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar.ftl @@ -0,0 +1,86 @@ +<#--区域统计和电压等级共用模板--> +{ +title: { +text: '设备运行情况', +left:'center', +subtext:'${subtext}', +}, +tooltip: { +trigger: 'axis', +axisPointer: { +type: 'shadow' +} +}, +legend: { +data: ['在线', '离线',], +left: '10%', +top:'5%', +textStyle: { +color: "#666666" +}, +itemWidth: 15, +itemHeight: 10, +itemGap: 25 +}, +grid: { +left: '3%', +right: '8%', +bottom: '5%', +top: '20%', +containLabel: true +}, +xAxis: { +name: '${xname}', +nameTextStyle: { +color: '#666666', +}, +type: 'category', +data: ${area} +}, +yAxis: { +name: '(个)', +nameTextStyle: { +color: '#666666', +}, +type: 'value', +axisLine: { show: true, lineStyle: { color: '#666666' } }, +axisLabel: { color: '#666666' }, +splitLine: { lineStyle: { color: ['#ccc'], type: [5, 8], dashOffset: 3 } }, +}, +series: [ +{ +name: '在线', +type: 'bar', +stack: 'account', +barWidth: 20, +label: { +show: true, +color:'purple', +verticalAlign: 'middle', +rotate: 0, +fontSize: 12, +}, +color:'green', +itemStyle: { +}, +data: ${onlineData} +}, +{ +name: '离线', +type: 'bar', +stack: 'account', +barWidth: 20, +label: { +show: true, +color:'purple', +verticalAlign: 'middle', +rotate: 0, +fontSize: 12, +}, +color:'orange', +itemStyle: { +}, +data: ${offlineData} +} +] +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar2.ftl b/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar2.ftl new file mode 100644 index 000000000..a570e9bda --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar2.ftl @@ -0,0 +1,103 @@ +<#--区域和电压等级统计次数共用模板--> +{ +title: { +text: '暂态事件次数', +left:'center', +subtext:'${subtext}', +}, +tooltip: { +trigger: 'axis', +axisPointer: { +type: 'shadow' +} +}, +legend: { +data: ['暂降次数', '中断次数', '暂升次数'], +left: '7%', +top:'5%', +textStyle: { +color: "#666666" +}, +itemWidth: 10, +itemHeight: 10, +itemGap: 15 +}, +grid: { +left: '3%', +right: '8%', +bottom: '5%', +top: '20%', +containLabel: true +}, +xAxis: { +name: '${xname}', +nameTextStyle: { +color: '#666666', +}, +type: 'category', +data: ${area} +}, +yAxis: { +name: '(次)', +nameTextStyle: { +color: '#666666', +}, +type: 'value', +axisLine: { show: true, lineStyle: { color: '#666666' } }, +axisLabel: { color: '#666666' }, +splitLine: { lineStyle: { color: ['#ccc'], type: [5, 8], dashOffset: 3 } }, +}, +series: [ +{ +name: '暂降次数', +type: 'bar', +stack: 'account', +barWidth: 20, +label: { +show: true, +color:'purple', +verticalAlign: 'middle', +rotate: 0, +fontSize: 12, +}, +color:'#ff9966', +itemStyle: { +}, +data: ${sag} +}, +{ +name: '中断次数', +type: 'bar', +stack: 'account', +barWidth: 20, +label: { +show: true, +color:'purple', +verticalAlign: 'middle', +rotate: 0, +fontSize: 12, +}, +color:'#00dd00', +itemStyle: { +}, +data: ${break} +}, +{ +name: '暂升次数', +type: 'bar', +stack: 'account', +barWidth: 20, +label: { +show: true, +color:'purple', +verticalAlign: 'middle', +rotate: 0, +fontSize: 12, +}, +color:'#0066ff', +itemStyle: { +}, +data: ${up} +}, +] +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar3.ftl b/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar3.ftl new file mode 100644 index 000000000..98aed5a42 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar3.ftl @@ -0,0 +1,85 @@ +<#--ITIC曲线专用--> +{ +backgroundColor: "#FFF", +title: { +text: "ITIC曲线", +x: "center", +}, +grid: { +left: "4%", +right: "2%", +bottom: "10%", +}, +legend: { +data: ["上限", "下限", "可容忍事件", "不可容忍事件"], +x: "left", +}, +color: ["#FF8C00", "#00BFFF", "green", "red"], +xAxis: [ +{ +type: "log", +min: "0.001", +max: "1000", +splitLine: { +show: false, +}, +name: "s", +}, +], +yAxis: [ +{ +type: "value", +splitNumber: 10, +minInterval: 3, +name: "%" +}, +], +series: [ +{ +name: "上限", +type: "line", +data: [ +[0.001, 200], +[0.003, 140], +[0.003, 120], +[0.5, 120], +[0.5, 110], +[10, 110], +[1000, 110] +], +showSymbol: false, +tooltips: { +show: false +}, +}, +{ +name: "下限", +type: "line", +data: [ +[0.02, 0], +[0.02, 70], +[0.5, 70], +[0.5, 80], +[10, 80], +[10, 90], +[1000, 90] +], +showSymbol: false, +tooltips: { +show: false +}, +}, +{ +name: "可容忍事件", +type: "scatter", +symbol: "circle", +data: ${point} +}, +{ +name: "不可容忍事件", +type: "scatter", +symbol: "circle", +data: ${pointno} +} +] +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar4.ftl b/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar4.ftl new file mode 100644 index 000000000..2f5e51274 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar4.ftl @@ -0,0 +1,61 @@ +<#--F47曲线图专用模板--> +{ +backgroundColor: "#fff", +title: { +text: "SEMI F47曲线", +x: "center", +}, +grid: { +left: "4%", +right: "5%", +bottom: "10%", +}, +legend: { +data: ["边界线", "可容忍事件", "不可容忍事件"], +x: "left", +}, +color: ["yellow", "green", "red"], +xAxis: [ +{ +type: "log", +min: "0.001", +max: "1000", +splitLine: { +show: false, +}, +name: "s", +}, +], +yAxis: [ +{ +type: "value", +max: ${zdz} + 20, +splitNumber: 10, +minInterval: 0.1, +name: "%", +}, +], +series: [ +{ +name: "边界线", +type: "line", +data: ${bjx}, +showSymbol: false, +tooltips: { +show: false, +}, +}, +{ +name: "可容忍事件", +type: "scatter", +symbol: "circle", +data: ${point} +}, +{ +name: "不可容忍事件", +type: "scatter", +symbol: "circle", +data: ${pointno} +} +] +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar5.ftl b/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar5.ftl new file mode 100644 index 000000000..78085f1b7 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar5.ftl @@ -0,0 +1,93 @@ +<#--暂降幅值的概率分布函数专用模板--> +{ + backgroundColor: "#fff", + title: { + text: "暂降幅值的概率分布函数", + x: "center" + }, + grid: { + left: "10%", + right: "10%", + bottom: "15%" + }, + toolbox: { + show: true, + feature: { + restore: { show: true }, + saveAsImage: { show: true }, + }, + }, + tooltip: { + trigger: "axis", + formatter: "暂降幅值: {b0}
概率分布: {c0}%", + }, + legend: { + show: true, + left: 10, + data: ["概率分布", "占比"], + }, + calculable: true, + xAxis: [ + { + type: "category", + boundaryGap: false, + name: "暂降幅值", + nameLocation: "center", + nameGap: 20, + nameTextStyle: { + fontSize: 15, + }, + data: [ + "0", + "10%", + "20%", + "30%", + "40%", + "50%", + "60%", + "70%", + "80%", + "90%", + ], + }, + ], + yAxis: [ + { + type: "value", + name: "概率分布", + nameLocation: "center", + nameGap: 40, + nameTextStyle: { + fontSize: 15, + }, + axisLabel: { + formatter: "{value} %", + }, + }, + { + type: "value", + name: "占比", + nameLocation: "center", + nameGap: 40, + nameTextStyle: { + fontSize: 15, + }, + axisLabel: { + formatter: "{value} %", + }, + }, + ], + series: [ + { + name: "概率分布", + type: "line", + data: ${eventValue}, + }, + { + name: "占比", + type: "bar", + data: ${pereventValue}, + barWidth: 30 + } + ] +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar6.ftl b/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar6.ftl new file mode 100644 index 000000000..fb9f17d14 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar6.ftl @@ -0,0 +1,71 @@ +<#--持续时间的概率分布函数专用模板--> +{ +backgroundColor: "#fff", +title: { +text: "持续时间的概率分布函数", +x: "center", +}, +legend: { + show: true, + left: 10, + data: ["概率分布", "占比"], +}, +calculable: true, +grid: { +left: "10%", +right: "10%", +bottom: "15%" +}, +xAxis: [ +{ +type: "category", +boundaryGap: false, +name: "暂降持续时间(s)", +nameLocation: "center", +nameGap: 20, +nameTextStyle: { +fontSize: 15, +}, +data: ["0.01", "0.1", "0.25", "0.5", "1", "3", "20", "60", "180"], +}, +], +yAxis: [ +{ +type: "value", +name: "概率分布", +nameLocation: "center", +nameGap: 40, +nameTextStyle: { +fontSize: 15, +}, +axisLabel: { +formatter: "{value} %", +}, +}, +{ +type: "value", +name: "占比", +nameLocation: "center", +nameGap: 40, +nameTextStyle: { +fontSize: 15, +}, +axisLabel: { +formatter: "{value} %", +}, +}, +], +series: [ +{ +name: "概率分布", +type: "line", +data: ${sisttime}, +}, +{ +name: "占比", +type: "bar", +data: ${persisttime}, +barWidth: 30, +} +] +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar7.ftl b/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar7.ftl new file mode 100644 index 000000000..9673c0d7d --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar7.ftl @@ -0,0 +1,58 @@ +<#--月份统计专用模板--> +{ +backgroundColor: "#fff", +title: { +text: "${text}", +x: "center", +}, +color: ["#FF8C00"], +legend: { +data: ["暂降次数"], +x: "left", +}, +grid: { +left: "3%", +bottom: "3%", +right: "7%", +containLabel: true, +}, +xAxis: [ +{ +type: "category", +data: ${months}, +name: "${xname}", +splitLine: { +show: false, +}, +axisLabel: { +show: true, +interval: 0, +}, +}, +], +yAxis: [ +{ +type: "value", +name: "次", +}, +], +series: [ +{ +name: "暂降次数", +type: "bar", +barMaxWidth: 45, +itemStyle: { +normal: { +label: { +show: true, +textStyle: { +label: { show: true, position: "top" }, +color: "#8B008B", +}, +}, +}, +}, +data: ${handle}, +} +] +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar8.ftl b/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar8.ftl new file mode 100644 index 000000000..526cfef33 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar8.ftl @@ -0,0 +1,49 @@ +<#--类型专用模板--> +{ +backgroundColor: '#fff', +animation: false, +title: { +text: '暂降类型', +x: 'center', +}, +legend: { +orient: 'vertical', +left: 'left', +data: ${typeArray} +}, +series: [ +{ +name: '暂降类型', +type: 'pie', +radius: '70%', +center: ['50%', '60%'], +label: { +normal: { +show: false +}, +emphasis: { +show: true +} +}, +lableLine: { +normal: { +show: false +}, +emphasis: { +show: true +} +}, +data: [<#list valueArray as a> + {value:${a.times?c}, + name:'${a.type}'}, +], +itemStyle: { +emphasis: { +shadowBlur: 10, +shadowOffsetX: 0, +shadowColor: 'rgba(0, 0, 0, 0.5)' +} +} +} +] +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar9.ftl b/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar9.ftl new file mode 100644 index 000000000..d6dbb53cc --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/template/bar9.ftl @@ -0,0 +1,49 @@ +<#--暂降原因专用模板--> +{ +backgroundColor: '#fff', +animation: false, +title: { +text: '暂降原因', +x: 'center' +}, +legend: { +orient: 'vertical', +left: 'left', +data: ${typeArray} +}, +series: [ +{ +name: '暂降原因', +type: 'pie', +radius: '70%', +center: ['50%', '53%'], +label: { +normal: { +show: false +}, +emphasis: { +show: true +} +}, +lableLine: { +normal: { +show: false +}, +emphasis: { +show: true +} +}, +data: [<#list valueArray as a> + {value:${a.times?c}, + name:'${a.reason}'}, +], +itemStyle: { +emphasis: { +shadowBlur: 10, +shadowOffsetX: 0, +shadowColor: 'rgba(0, 0, 0, 0.5)' +} +} +} +] +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/template/dydj.ftl b/pqs-event/event-boot/src/main/java/com/njcn/event/template/dydj.ftl new file mode 100644 index 000000000..d8297f4b1 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/template/dydj.ftl @@ -0,0 +1,66 @@ + { +backgroundColor: "#FFF", +title: { +text: '电压等级', +x: 'center' +}, +tooltip: { +trigger: 'axis', +axisPointer: { +type: 'shadow' +}, +formatter: function (params) { +var tips = ""; +tips += params[0].name ; +for (var i = 0; i < params.length; i++) { +tips += params[i].seriesName + ":" + params[i].value ; +} +return tips; +} +}, +color: ['orange'], +legend: { +data: ['暂降次数'], +selectedMode: false, +x: 'left' +}, +grid: { +left: '3%', +right: '12%', +bottom: '6%', +containLabel: true +}, +xAxis: [{ +type: 'category', +data: ${xvalue}, +splitLine: { +show: false +}, +name: '电压等级\n(监测点数)', +axisLabel: { +interval: 0, +show: true, +fontSize:10 +} +}], +yAxis: [{ +type: 'value', +name: '(次)' +}], +series: [{ +name: '暂降次数', +type: 'bar', +itemStyle: { +normal: { +label: { +show: true, +textStyle: { +color: 'purple' +} +} +} +}, +data: ${yvalue}, +barMaxWidth: 45 +}] +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/template/qytj.ftl b/pqs-event/event-boot/src/main/java/com/njcn/event/template/qytj.ftl new file mode 100644 index 000000000..b9079cbca --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/template/qytj.ftl @@ -0,0 +1,68 @@ +{ +backgroundColor: '#FFF', +title: { +text: '区域统计', +x: 'center' +}, +tooltip: { +trigger: 'axis', +axisPointer: { +type: 'shadow' +}, +formatter: function (params) { +var tips = ""; +tips += params[0].name ; +for (var i = 0; i < params.length; i++) { +tips += params[i].seriesName + ":" + params[i].value ; +} +return tips; +} +}, +color: ['orange'], + +grid: { +left: '1%', +right: '7%', +bottom: '8%', +containLabel: true +}, +legend: { +data: ['暂降次数'], +selectedMode: false, +x: 'left' +}, +xAxis: [{ +type: 'category', +data: ${xvalue}, +splitLine: { +show: false +}, +name: '地区\n(监测点数)', +axisLabel: { +interval: 0, +show: true, +rotate:0, +fontSize:10 +} +}], +yAxis: [{ +type: 'value', +name: '(次)' +}], +series: [{ +name: '暂降次数', +type: 'bar', +itemStyle: { +normal: { +label: { +show: true, +textStyle: { +color: 'purple' +} +} +} +}, +data: ${yvalue}, +barMaxWidth: 45 +}], +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/template/test.ftl b/pqs-event/event-boot/src/main/java/com/njcn/event/template/test.ftl new file mode 100644 index 000000000..e2e8644d9 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/template/test.ftl @@ -0,0 +1,12 @@ +{ +animation:false, +xAxis: {}, +yAxis: {}, +series: [ +{ +symbolSize: 2, +data: ${bdata}, +type: 'scatter' +} +] +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/template/yftj.ftl b/pqs-event/event-boot/src/main/java/com/njcn/event/template/yftj.ftl new file mode 100644 index 000000000..bf46d0a35 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/template/yftj.ftl @@ -0,0 +1,76 @@ +{ +backgroundColor: "#FFF", +title: { +text: ${test}, +x: 'center' +}, +tooltip: { +trigger: 'axis', +axisPointer: { +type: 'shadow' +}, +formatter: function (params) { +var tips = ""; +tips += params[0].name ; +for (var i = 0; i < params.length; i++) { +tips += params[i].seriesName + ":" + params[i].value; +} +return tips; +} +}, +grid: { +left: '3%', +bottom: '6%', +containLabel: true +}, +legend: { +data: ['未关联暂降次数', '已关联处理事件'], +x: 'left' +}, +xAxis: [{ +type: 'category', +data:${xvalue}, +name: ${test}, +splitLine: { +show: false +}, +axisLabel: { +show: true, +interval: 0, +fontSize:10 +} +}], +yAxis: [{ +type: 'value', +name: '次' +}], +series: [{ +name: '未关联暂降次数', +type: 'bar', +stack: '事件总数', +barMaxWidth: 45, +itemStyle: { +normal: { +color: 'orange', +barBorderColor: 'orange', +barBorderWidth: 2, +barBorderRadius: 0 +} +}, +data: ${yvalue1} +}, { +name: '已关联处理事件', +type: 'bar', +stack: '事件总数', +barMaxWidth: 45, +itemStyle: { +normal: { +color: "#ccc", +barBorderColor: '#ccc', +barBorderWidth: 2, +barBorderRadius: 0 +} +}, +data: ${yvalue2} +}] +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/utils/EchartsUtil.java b/pqs-event/event-boot/src/main/java/com/njcn/event/utils/EchartsUtil.java new file mode 100644 index 000000000..7adc6cc03 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/utils/EchartsUtil.java @@ -0,0 +1,52 @@ +package com.njcn.event.utils; + +import net.sf.json.JSONObject; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +/** + * @author hongawen + * @version 1.0.0 + * @date 2022年08月23日 19:33 + */ +public class EchartsUtil { + private static final String SUCCESS_CODE = "1"; + + public static String generateEchartsBase64(String option, String port) throws IOException { + String url; + if (port.equals("8911")) { + url = "http://192.168.1.13:8911"; + } else { + url = "http://192.168.1.13:8910"; + } + + String base64 = ""; + if (option == null) { + return base64; + } + + option = option.replaceAll("\\s+", "").replaceAll("\"", "'"); + + // 将option字符串作为参数发送给echartsConvert服务器 + Map params = new HashMap<>(); + params.put("opt", option); + String response = HttpUtil.post(url, params, "utf-8"); + + // 解析echartsConvert响应 + JSONObject responseJson = JSONObject.fromObject(response); + String code = responseJson.getString("code"); + + // 如果echartsConvert正常返回 + if (SUCCESS_CODE.equals(code)) { + base64 = responseJson.getString("data"); + } + // 未正常返回 + else { + String string = responseJson.getString("msg"); + throw new RuntimeException(string); + } + return base64; + } +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/utils/FreemarkerUtil.java b/pqs-event/event-boot/src/main/java/com/njcn/event/utils/FreemarkerUtil.java new file mode 100644 index 000000000..145f9ba93 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/utils/FreemarkerUtil.java @@ -0,0 +1,41 @@ +package com.njcn.event.utils; + +import freemarker.template.Configuration; +import freemarker.template.Template; +import freemarker.template.TemplateException; + +import java.io.File; +import java.io.IOException; +import java.io.StringWriter; +import java.util.Map; + +/** + * @author hongawen + * @version 1.0.0 + * @date 2022年08月23日 19:32 + */ +public class FreemarkerUtil { + private static String path = FreemarkerUtil.class.getClassLoader().getResource("").getPath(); + + public static String generateString(String templateFileName, String templateDirectory, Map datas) + throws IOException, TemplateException { + Configuration configuration = new Configuration(Configuration.VERSION_2_3_0); + + // 设置默认编码 + configuration.setDefaultEncoding("UTF-8"); + + // 设置模板所在文件夹 + path = java.net.URLDecoder.decode(path,"utf-8"); + configuration.setDirectoryForTemplateLoading(new File(path + templateDirectory)); + + // 生成模板对象 + Template template = configuration.getTemplate(templateFileName); + + // 将datas写入模板并返回 + try (StringWriter stringWriter = new StringWriter()) { + template.process(datas, stringWriter); + stringWriter.flush(); + return stringWriter.getBuffer().toString(); + } + } +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/utils/HttpUtil.java b/pqs-event/event-boot/src/main/java/com/njcn/event/utils/HttpUtil.java new file mode 100644 index 000000000..2afb3bf99 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/utils/HttpUtil.java @@ -0,0 +1,63 @@ +package com.njcn.event.utils; + +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @author hongawen + * @version 1.0.0 + * @date 2022年08月23日 19:33 + */ +public class HttpUtil { + + public static String post(String url, Map params, String charset) + throws ClientProtocolException, IOException { + String responseEntity = ""; + + // 创建CloseableHttpClient对象 + CloseableHttpClient client = HttpClients.createDefault(); + + // 创建post方式请求对象 + HttpPost httpPost = new HttpPost(url); + + // 生成请求参数 + List nameValuePairs = new ArrayList<>(); + if (params != null) { + for (Map.Entry entry : params.entrySet()) { + nameValuePairs.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); + } + } + + // 将参数添加到post请求中 + httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, charset)); + + // 发送请求,获取结果(同步阻塞) + CloseableHttpResponse response = client.execute(httpPost); + + // 获取响应实体 + HttpEntity entity = response.getEntity(); + if (entity != null) { + // 按指定编码转换结果实体为String类型 + responseEntity = EntityUtils.toString(entity, charset); + } + + // 释放资源 + EntityUtils.consume(entity); + response.close(); + + return responseEntity; + } +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/utils/TestTemplate.java b/pqs-event/event-boot/src/main/java/com/njcn/event/utils/TestTemplate.java new file mode 100644 index 000000000..5c8936fe0 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/utils/TestTemplate.java @@ -0,0 +1,61 @@ +package com.njcn.event.utils; + +import cn.hutool.core.util.RandomUtil; +import freemarker.template.TemplateException; +import net.sf.json.JSONArray; + +import java.io.IOException; +import java.math.RoundingMode; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * @author hongawen + * @version 1.0.0 + * @date 2022年08月25日 08:59 + */ +public class TestTemplate { + public static void main(String[] args) throws IOException, TemplateException { + HashMap map = new HashMap<>(); + map.put("subtext","区域统计"); + map.put("xname","(区域)"); + List x = Stream.of("江苏省", "浙江省", "福建省").collect(Collectors.toList()); + map.put("area",JSONArray.fromObject(x).toString()); + List on = Stream.of(149, 15, 9).collect(Collectors.toList()); + List off = Stream.of(24, 2, 1).collect(Collectors.toList()); + map.put("onlineData",JSONArray.fromObject(on).toString()); + map.put("offlineData",JSONArray.fromObject(off).toString()); + + List> floatData = new ArrayList<>(); + for (int i = 0; i < 1500; i++) { + List sub = new ArrayList<>(); + sub.add( RandomUtil.randomDouble(100.0,3, RoundingMode.UP)); + sub.add( RandomUtil.randomDouble(200.0,3, RoundingMode.UP)); + floatData.add(sub); + } + map.put("point",JSONArray.fromObject(floatData).toString()); + + String s = FreemarkerUtil.generateString("bar.ftl", "com/njcn/event/template", map); + System.out.println(EchartsUtil.generateEchartsBase64(s,"8910")); + + + + +// HashMap datas = new HashMap<>(); +// List> floatData = new ArrayList<>(); +// for (int i = 0; i < 1500; i++) { +// List sub = new ArrayList<>(); +// sub.add( RandomUtil.randomDouble(100.0,3, RoundingMode.UP)); +// sub.add( RandomUtil.randomDouble(200.0,3, RoundingMode.UP)); +// floatData.add(sub); +// } +// datas.put("bdata", JSONArray.fromObject(floatData).toString()); +// String option = FreemarkerUtil.generateString("test.ftl", "com/njcn/event/template", datas); +// System.out.println(EchartsUtil.generateEchartsBase64(option, "8910")); + } + + +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/utils/WordUtils.java b/pqs-event/event-boot/src/main/java/com/njcn/event/utils/WordUtils.java new file mode 100644 index 000000000..90fab2184 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/utils/WordUtils.java @@ -0,0 +1,368 @@ +package com.njcn.event.utils; +import java.io.File; +import java.io.FileOutputStream; +import java.math.BigInteger; +import java.util.Calendar; + +import org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy; +import org.apache.poi.xwpf.usermodel.ParagraphAlignment; +import org.apache.poi.xwpf.usermodel.TextAlignment; +import org.apache.poi.xwpf.usermodel.XWPFDocument; +import org.apache.poi.xwpf.usermodel.XWPFParagraph; +import org.apache.poi.xwpf.usermodel.XWPFRun; +import org.apache.poi.xwpf.usermodel.XWPFStyle; +import org.apache.poi.xwpf.usermodel.XWPFStyles; +import org.apache.poi.xwpf.usermodel.XWPFTable; +import org.apache.poi.xwpf.usermodel.XWPFTableRow; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDecimalNumber; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyle; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.STStyleType; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth; + +public class WordUtils { + + + public static void main(String[] args)throws Exception { + + // 空白文档 + XWPFDocument document= new XWPFDocument(); + //把文档写进本地系统 + FileOutputStream out = new FileOutputStream(new File("create_table.docx")); + //设定标题格式 + setHeadingStyle(document); + //添加标题 + XWPFParagraph titleParagraph = document.createParagraph(); + setParagraphStyle(titleParagraph); + addLine(titleParagraph,11); + //设置段落居中 + titleParagraph.setAlignment(ParagraphAlignment.CENTER); + XWPFRun titleParagraphRun = titleParagraph.createRun(); + addParagraph(titleParagraphRun,"宋体",15,"000000","四川省供电公司",true); + + addLine(titleParagraph,3); + XWPFRun titleParagraphBigRun = titleParagraph.createRun(); + addParagraph(titleParagraphBigRun,"宋体",36,"000000","电压暂降事件分析报告",true); + addLine(titleParagraph,19); + + XWPFRun titleParagraphDateRun = titleParagraph.createRun(); + addParagraph(titleParagraphDateRun,"宋体",14,"000000","日期: 2018年1月3号",true); + titleParagraph.setPageBreak(true); + + + //段落 + XWPFParagraph statisticsParagraph = document.createParagraph(); + setParagraphStyle(statisticsParagraph); + //段前分页 + statisticsParagraph.setPageBreak(true); + statisticsParagraph.setAlignment(ParagraphAlignment.CENTER); + XWPFRun statisticsRun = statisticsParagraph.createRun(); + addParagraph(statisticsRun,"宋体",24,"000000","电压暂降事件分析报告",false); + + + + XWPFParagraph introductionParagraph= document.createParagraph(); + setParagraphStyle(introductionParagraph); + introductionParagraph.setStyle("标题 1"); + introductionParagraph.setAlignment(ParagraphAlignment.LEFT); + XWPFRun introductionRun = introductionParagraph.createRun(); + addParagraph(introductionRun,"宋体",15,"000000","1. 引言",true); + + XWPFParagraph introductionContentParagraph = document.createParagraph(); + // 首行缩进---段落 + setParagraphStyle(introductionContentParagraph); + introductionContentParagraph.setAlignment(ParagraphAlignment.LEFT); + introductionContentParagraph.setIndentationFirstLine(200); + XWPFRun introductionContentRun=introductionContentParagraph.createRun(); + addParagraph(introductionContentRun,"宋体",11,"000000","对所选中区间内电压暂降事件进行分析,能够直观清晰查看相应的暂降事件信息。",false); + + XWPFParagraph objectParagraph=document.createParagraph(); + setParagraphStyle(objectParagraph); + objectParagraph.setStyle("标题 1"); + objectParagraph.setAlignment(ParagraphAlignment.LEFT); + XWPFRun objectRun= objectParagraph.createRun(); + addParagraph(objectRun,"宋体",15,"000000","2. 报告分析对象:",true); + + XWPFParagraph objectContentParagraph = document.createParagraph(); + setParagraphStyle(objectContentParagraph); + objectContentParagraph.setAlignment(ParagraphAlignment.LEFT); + objectContentParagraph.setIndentationFirstLine(200); + XWPFRun objectContentRun = objectContentParagraph.createRun(); + addParagraph(objectContentRun,"宋体",11,"000000","成都供电公司—>锦江区变电站—>锦江2号。",false); + + XWPFParagraph timeParagraph = document.createParagraph(); + timeParagraph.setStyle("标题 1"); + timeParagraph.setAlignment(ParagraphAlignment.LEFT); + setParagraphStyle(timeParagraph); + XWPFRun timeRun = timeParagraph.createRun(); + addParagraph(timeRun,"宋体",15,"000000","3. 报告分析时间:",true); + + XWPFParagraph timeContentParagraph = document.createParagraph(); + setParagraphStyle(timeContentParagraph); + timeContentParagraph.setAlignment(ParagraphAlignment.LEFT); + timeContentParagraph.setIndentationFirstLine(200); + XWPFRun timeContentRun = timeContentParagraph.createRun(); + addParagraph(timeContentRun,"宋体",11,"000000","2017年12月21日至2017年12月30日。",false); + + + XWPFParagraph summaeParagraph = document.createParagraph(); + setParagraphStyle(summaeParagraph); + summaeParagraph.setStyle("标题 1"); + summaeParagraph.setAlignment(ParagraphAlignment.LEFT); + XWPFRun summaeRun = summaeParagraph.createRun(); + addParagraph(summaeRun,"宋体",15,"000000","4. 汇总信息:",true); + + + XWPFParagraph summaeTableParagraph = document.createParagraph(); + setParagraphStyle(summaeTableParagraph); + summaeTableParagraph.setStyle("标题 2"); + summaeTableParagraph.setAlignment(ParagraphAlignment.LEFT); + summaeTableParagraph.setIndentationFirstLine(200); + XWPFRun summaeTableRun = summaeTableParagraph.createRun(); + addParagraph(summaeTableRun,"宋体",11,"000000","4.1 表格",false); + + + //工作经历表格 + XWPFTable summaTable = document.createTable(); + + //列宽自动分割 + CTTblWidth summaTableWidth = summaTable.getCTTbl().addNewTblPr().addNewTblW(); + summaTableWidth.setType(STTblWidth.DXA); + summaTableWidth.setW(BigInteger.valueOf(9072)); + + //表格第一行 + XWPFTableRow summaTableRowOne = summaTable.getRow(0); + XWPFParagraph excelParagraph= document.createParagraph(); + setParagraphStyle(excelParagraph); + excelParagraph.setAlignment(ParagraphAlignment.CENTER); + excelParagraph.setVerticalAlignment(TextAlignment.CENTER); + setExcelHeadContent(excelParagraph,summaTableRowOne,"序号","暂降发生时刻","暂降幅值(%)","持续时间(ms)","暂降类型","暂降原因","严重度"); + + //表格第二行 + XWPFTableRow summaTableRowTwo = summaTable.createRow(); + setExcelContent(excelParagraph,summaTableRowTwo,"1","2017-11-24 14:26:56.490","9","20","未识别","未明","0.91"); + + //表格第三行 + XWPFTableRow summaTableRowThree = summaTable.createRow(); + setExcelContent(excelParagraph,summaTableRowThree,"2","2017-11-24 14:25:46.472","15","19","未识别","未明","0.85"); + + XWPFParagraph summaePicParagraph = document.createParagraph(); + summaePicParagraph.setStyle("标题 2"); + summaePicParagraph.setAlignment(ParagraphAlignment.LEFT); + summaePicParagraph.setIndentationFirstLine(200); + XWPFRun summaePicRun = summaePicParagraph.createRun(); + addParagraph(summaePicRun,"宋体",11,"000000","4.2 ITIC曲线",false); + + + CTSectPr sectPr = document.getDocument().getBody().addNewSectPr(); + XWPFHeaderFooterPolicy policy = new XWPFHeaderFooterPolicy(document, sectPr); + + //添加页眉 + CTP ctpHeader = CTP.Factory.newInstance(); + CTR ctrHeader = ctpHeader.addNewR(); + CTText ctHeader = ctrHeader.addNewT(); + String headerText = "Java POI create MS word file."; + ctHeader.setStringValue(headerText); + XWPFParagraph headerParagraph = new XWPFParagraph(ctpHeader, document); + //设置为右对齐 + headerParagraph.setAlignment(ParagraphAlignment.RIGHT); + XWPFParagraph[] parsHeader = new XWPFParagraph[1]; + parsHeader[0] = headerParagraph; + policy.createHeader(XWPFHeaderFooterPolicy.DEFAULT, parsHeader); + + + //添加页脚 + CTP ctpFooter = CTP.Factory.newInstance(); + CTR ctrFooter = ctpFooter.addNewR(); + CTText ctFooter = ctrFooter.addNewT(); + String footerText = "http://blog.csdn.net/zhouseawater"; + ctFooter.setStringValue(footerText); + XWPFParagraph footerParagraph = new XWPFParagraph(ctpFooter, document); + headerParagraph.setAlignment(ParagraphAlignment.CENTER); + XWPFParagraph[] parsFooter = new XWPFParagraph[1]; + parsFooter[0] = footerParagraph; + policy.createFooter(XWPFHeaderFooterPolicy.DEFAULT, parsFooter); + + document.write(out); + out.close(); + + } + + public static void setParagraphStyle(XWPFParagraph paragraph){ + paragraph.setSpacingBefore(100); + paragraph.setSpacingAfter(100); + } + + /** + * 返回指定格式的段落 居中型 + * @param document 文档对象 + */ + public static XWPFParagraph getCenterParagraph(XWPFDocument document){ + XWPFParagraph paragraph = document.createParagraph(); + setParagraphStyle(paragraph); + paragraph.setAlignment(ParagraphAlignment.CENTER); + paragraph.setVerticalAlignment(TextAlignment.CENTER); + return paragraph; + } + + /** + * 返回指定格式的段落 居左型 + * @param document 文档对象 + */ + public static XWPFParagraph getLeftParagraph(XWPFDocument document){ + XWPFParagraph paragraph = document.createParagraph(); + setParagraphStyle(paragraph); + paragraph.setAlignment(ParagraphAlignment.LEFT); + return paragraph; + } + + + + /** + * 添加换行符 + * @param paragraph 指定段落 + * @param amount 行数 + * */ + public static void addLine(XWPFParagraph paragraph,Integer amount){ + XWPFRun run = paragraph.createRun(); + run.setFontSize(11); + for(int i=0;i style is more prominent in the formats bar + ctStyle.setUiPriority(indentNumber); + + CTOnOff onoffnull = CTOnOff.Factory.newInstance(); + ctStyle.setUnhideWhenUsed(onoffnull); + + // style shows up in the formats bar + ctStyle.setQFormat(onoffnull); + + // style defines a heading of the given level + CTPPr ppr = CTPPr.Factory.newInstance(); + ppr.setOutlineLvl(indentNumber); + ctStyle.setPPr(ppr); + + XWPFStyle style = new XWPFStyle(ctStyle); + + // is a null op if already defined + XWPFStyles styles = docxDocument.createStyles(); + + style.setType(STStyleType.PARAGRAPH); + styles.addStyle(style); + + } + + /** + * 设置文档中标题格式 + * */ + public static void setHeadingStyle(XWPFDocument document){ + addCustomHeadingStyle(document, "标题 1", 1); + addCustomHeadingStyle(document, "标题 2", 2); + addCustomHeadingStyle(document, "标题 3", 3); + addCustomHeadingStyle(document, "标题 4", 4); + addCustomHeadingStyle(document, "标题 5", 5); + addCustomHeadingStyle(document, "标题 6", 6); + addCustomHeadingStyle(document, "标题 7", 7); + } + + /** + * 给表格添加一行数据 + * @param paragraph 段落对象 + * @param row 行对象 + * @param data 不定长度的数据 + */ + public static void setExcelContent(XWPFParagraph paragraph, XWPFTableRow row,String... data){ + for (int i=0;i