暂降监测点报告抽取公共方法

This commit is contained in:
cdf
2026-01-17 20:25:03 +08:00
parent b27f049c9f
commit 7ca23b9431
40 changed files with 1021 additions and 174 deletions

View File

@@ -94,6 +94,11 @@
<artifactId>advance-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>event-common</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>

View File

@@ -16,7 +16,7 @@ import com.njcn.event.pojo.param.EventCountParam;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.GeneralVO;
import com.njcn.event.service.majornetwork.EventDetailService;
import com.njcn.event.common.service.EventDetailService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;

View File

@@ -7,7 +7,7 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.event.pojo.param.EventMonitorReportParam;
import com.njcn.event.pojo.vo.*;
import com.njcn.event.service.majornetwork.EventMonitorReportService;
import com.njcn.event.common.service.EventMonitorReportService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -51,7 +51,7 @@ public class EventMonitorReportController extends BaseController {
}
/***
*
*
* @author jianghaifei
* @date 2022-10-29 14:08
* @param eventMonitorReportParam
@@ -67,7 +67,7 @@ public class EventMonitorReportController extends BaseController {
}
/***
*
*
* @author jianghaifei
* @date 2022-10-29 14:08
* @param eventMonitorReportParam

View File

@@ -2,15 +2,13 @@ package com.njcn.event.controller.majornetwork;
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.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.*;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.vo.*;
import com.njcn.event.service.majornetwork.EventAnalysisService;
import com.njcn.event.common.service.EventAnalysisService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
@@ -18,7 +16,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.List;

View File

@@ -1,18 +1,29 @@
package com.njcn.event.controller.majornetwork;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
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.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pms.api.MonitorClient;
import com.njcn.device.pms.pojo.po.Monitor;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
import com.njcn.event.common.service.CommMonitorEventReportService;
import com.njcn.event.enums.EventResponseEnum;
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.majornetwork.ReportService;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.web.controller.BaseController;
import freemarker.template.TemplateException;
import io.swagger.annotations.Api;
@@ -27,6 +38,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.ParseException;
import java.util.Arrays;
import java.util.List;
/**
@@ -44,6 +56,14 @@ public class ReportController extends BaseController {
private final ReportService reportService;
private final CommMonitorEventReportService commMonitorEventReportService;
private final LineFeignClient lineFeignClient;
private final MonitorClient monitorClient;
private final DicDataFeignClient dicDataFeignClient;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getGeneralSituation")
@ApiOperation("暂态总体概况(区域)")
@@ -149,7 +169,31 @@ public class ReportController extends BaseController {
@ApiOperation("监测点报告导出")
@ApiImplicitParam(name = "exportParam", value = "监测点报告导出参数", required = true)
public void getLineExport(@RequestBody @Validated ExportParam exportParam, HttpServletResponse response) throws IOException, InvalidFormatException, TemplateException, ParseException {
reportService.getLineExport(exportParam, response);
LineDetailDataCommDTO lineDetailDataCommDTO = new LineDetailDataCommDTO();
if(exportParam.getType() == 0) {
LineDetailDataVO lineDetailData = lineFeignClient.getLineDetailData(exportParam.getLineId()).getData();
if (ObjectUtil.isNull(lineDetailData)) {
throw new BusinessException(CommonResponseEnum.FAIL, "查询监测点失败");
}
BeanUtil.copyProperties(lineDetailData,lineDetailDataCommDTO);
}else {
HttpResult<List<Monitor>> monitorList = monitorClient.getMonitorList(Arrays.asList(exportParam.getLineId()));
if (ObjectUtil.isNull(monitorList)) {
throw new BusinessException(EventResponseEnum.NOT_FOUND);
}
lineDetailDataCommDTO.setLineName(monitorList.getData().get(0).getName());
lineDetailDataCommDTO.setScale(dicDataFeignClient.getDicDataById(monitorList.getData().get(0).getVoltageLevel()).getData().getName());
lineDetailDataCommDTO.setPt(monitorList.getData().get(0).getPt1() + "/" + monitorList.getData().get(0).getPt2());
lineDetailDataCommDTO.setPt(monitorList.getData().get(0).getCt1() + "/" + monitorList.getData().get(0).getCt2());
lineDetailDataCommDTO.setDealCapacity(monitorList.getData().get(0).getUserAgreementCapacity());
// insertRow(doc, table, centerParagraph, false, "基准容量", monitorList.getData().get(0).getMinShortCircuitCapacity() + "");
lineDetailDataCommDTO.setDevCapacity(monitorList.getData().get(0).getPowerSupplyEqCapacity());
lineDetailDataCommDTO.setShortCapacity(monitorList.getData().get(0).getMinShortCircuitCapacity());
lineDetailDataCommDTO.setPtType(dicDataFeignClient.getDicDataById(monitorList.getData().get(0).getTerminalWiringMethod()).getData().getName());
}
commMonitorEventReportService.getLineExport(exportParam, lineDetailDataCommDTO,response);
}
/**

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.event.mapper.majornetwork.EventDistributionStatisticsMapper">
<mapper namespace="com.njcn.event.common.mapper.EventDistributionStatisticsMapper">
<!--获取暂态指标分布统计-->
<select id="getEventDistributionStatistics"
@@ -469,4 +469,4 @@
)
r
</select>
</mapper>
</mapper>

View File

@@ -1,78 +1,78 @@
package com.njcn.event.service.majornetwork;
import com.njcn.event.pojo.param.StatisticsParam;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.vo.*;
import com.njcn.system.pojo.po.DictData;
import java.text.ParseException;
import java.util.List;
/**
* <监测点报表>
*
* @author wr
* @createTime: 2023-02-10
*/
public interface EventReportService {
/**
*获取Disdip表格监测点报表专用
* @param info influxdb查询结果pqs_eventdetail表
* @return
*/
List<DISDIPVO> eventDisdip(List<EventDetail> info);
/**
* 获取IEC411数据
* @param info influxdb查询结果pqs_eventdetail表
* @return
*/
List<IEC411VO> IEC411(List<EventDetail> info);
/**
* 获取IEC28数据
* @param info influxdb查询结果pqs_eventdetail表
* @return
*/
List<IEC28VO> IEC28(List<EventDetail> info);
/**
*暂降幅值概率分布
* @param info2 influxdb查询结果pqs_eventdetail表
* @return
*/
ProbabilityVO getProbabilityDistribution(List<EventDetail> info2);
/**
* 获取时间列表(月份统计)
* @param info influxdb查询结果pqs_eventdetail表
* @return
*/
List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam,List<EventDetail> info) throws ParseException;
/**
* 获取点状表格数据2.1
* @param info 结果集
* @param reasonData 暂降原因
* @param typeData 暂降类型
* @return
*/
List<EventDetail> getPlot(List<EventDetail> info, List<DictData> reasonData, List<DictData> typeData);
/**
* 获取详细数据对象
* @param info
* @param reasonData
* @param typeData
* @return
*/
StatisticVO getStatistic(List<EventDetail> info,List<DictData> reasonData,List<DictData>typeData);
/**
* 获取密度点图
* @param info
* @return
*/
Integer[][] getCoords(List<EventDetail> info);
}
//package com.njcn.event.service.majornetwork;
//
//import com.njcn.event.pojo.param.StatisticsParam;
//import com.njcn.event.pojo.po.EventDetail;
//import com.njcn.event.pojo.vo.*;
//import com.njcn.system.pojo.po.DictData;
//
//import java.text.ParseException;
//import java.util.List;
//
///**
// * <监测点报表>
// *
// * @author wr
// * @createTime: 2023-02-10
// */
//public interface EventReportService {
//
// /**
// *获取Disdip表格监测点报表专用
// * @param info influxdb查询结果pqs_eventdetail表
// * @return
// */
// List<DISDIPVO> eventDisdip(List<EventDetail> info);
//
// /**
// * 获取IEC411数据
// * @param info influxdb查询结果pqs_eventdetail表
// * @return
// */
// List<IEC411VO> IEC411(List<EventDetail> info);
//
// /**
// * 获取IEC28数据
// * @param info influxdb查询结果pqs_eventdetail表
// * @return
// */
// List<IEC28VO> IEC28(List<EventDetail> info);
//
// /**
// *暂降幅值概率分布
// * @param info2 influxdb查询结果pqs_eventdetail表
// * @return
// */
// ProbabilityVO getProbabilityDistribution(List<EventDetail> info2);
//
// /**
// * 获取时间列表(月份统计)
// * @param info influxdb查询结果pqs_eventdetail表
// * @return
// */
// List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam,List<EventDetail> info) throws ParseException;
//
// /**
// * 获取点状表格数据2.1
// * @param info 结果集
// * @param reasonData 暂降原因
// * @param typeData 暂降类型
// * @return
// */
// List<EventDetail> getPlot(List<EventDetail> info, List<DictData> reasonData, List<DictData> typeData);
//
// /**
// * 获取详细数据对象
// * @param info
// * @param reasonData
// * @param typeData
// * @return
// */
// StatisticVO getStatistic(List<EventDetail> info,List<DictData> reasonData,List<DictData>typeData);
//
// /**
// * 获取密度点图
// * @param info
// * @return
// */
// Integer[][] getCoords(List<EventDetail> info);
//}

View File

@@ -20,19 +20,17 @@ import com.njcn.event.pojo.vo.AreaAnalysisVO;
import com.njcn.event.pojo.vo.VoltageToleranceCurveVO;
import com.njcn.event.pojo.vo.VoltageToleranceCurveVO.VoltageToleranceCurveDataList;
import com.njcn.event.service.majornetwork.AreaAnalysisService;
import com.njcn.event.service.majornetwork.EventDetailService;
import com.njcn.event.common.service.EventDetailService;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import io.swagger.models.auth.In;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**

View File

@@ -14,7 +14,7 @@ import com.njcn.event.pojo.po.EventDetailNew;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.AreaSubLineVO;
import com.njcn.event.service.majornetwork.AreaInfoService;
import com.njcn.event.service.majornetwork.EventDetailService;
import com.njcn.event.common.service.EventDetailService;
import com.njcn.harmonic.api.PollutionSubstationClient;
import com.njcn.harmonic.pojo.excel.pollution.UserLinePollution;
import lombok.RequiredArgsConstructor;

View File

@@ -24,7 +24,7 @@ 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.majornetwork.AreaLineService;
import com.njcn.event.service.majornetwork.EventDetailService;
import com.njcn.event.common.service.EventDetailService;
import com.njcn.event.service.majornetwork.LargeScreenService;
import com.njcn.harmonic.pojo.dto.ComAssessDTO;
import com.njcn.harmonic.pojo.po.PQSComAssesPO;

View File

@@ -22,7 +22,7 @@ import com.njcn.event.pojo.vo.AreaStatisticalVO.VoltageStatisticsVO;
import com.njcn.event.pojo.vo.MonthCalculationVO;
import com.njcn.event.pojo.vo.VoltageLevelCalculationVO;
import com.njcn.event.service.majornetwork.AreaStatisticalService;
import com.njcn.event.service.majornetwork.EventDetailService;
import com.njcn.event.common.service.EventDetailService;
import com.njcn.event.pojo.vo.NodeVO;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;

View File

@@ -8,7 +8,7 @@ import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient;
import com.njcn.device.pms.pojo.dto.PmsGeneralDeviceDTO;
import com.njcn.device.pms.pojo.param.PmsDeviceInfoParam;
import com.njcn.event.mapper.majornetwork.EventDistributionStatisticsMapper;
import com.njcn.event.common.mapper.EventDistributionStatisticsMapper;
import com.njcn.event.pojo.po.EventDistributionStatisticsPO;
import com.njcn.event.pojo.po.EventDurationLineChartPO;
import com.njcn.event.pojo.po.EventFeatureAmplitudeLineChartPO;
@@ -21,8 +21,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

View File

@@ -35,6 +35,7 @@ import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.echarts.pojo.constant.PicCommonData;
import com.njcn.echarts.util.DrawPicUtil;
import com.njcn.event.common.service.EventReportService;
import com.njcn.event.enums.EventResponseEnum;
import com.njcn.event.mapper.majornetwork.EventDetailMapper;
import com.njcn.event.mapper.majornetwork.ReportMapper;
@@ -44,11 +45,10 @@ import com.njcn.event.pojo.po.EventDetailNew;
import com.njcn.event.pojo.po.Eventass;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.*;
import com.njcn.event.service.majornetwork.EventAnalysisService;
import com.njcn.event.service.majornetwork.EventDetailService;
import com.njcn.event.service.majornetwork.EventReportService;
import com.njcn.event.common.service.EventAnalysisService;
import com.njcn.event.common.service.EventDetailService;
import com.njcn.event.service.majornetwork.ReportService;
import com.njcn.event.utils.WordUtils;
import com.njcn.event.common.utils.WordUtils;
import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.poi.util.PoiUtil;
@@ -89,10 +89,8 @@ 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.jetbrains.annotations.NotNull;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import org.springframework.beans.BeanUtils;
import org.springframework.core.io.InputStreamResource;
import org.springframework.stereotype.Service;
import sun.misc.BASE64Decoder;

View File

@@ -36,7 +36,7 @@ import com.njcn.device.pq.pojo.vo.GridDiagramVO;
import com.njcn.device.pq.pojo.vo.LineDetailVO;
import com.njcn.event.enums.EventResponseEnum;
import com.njcn.event.mapper.majornetwork.RMpEventDetailMMapper;
import com.njcn.event.mapper.majornetwork.RmpEventDetailMapper;
import com.njcn.event.common.mapper.RmpEventDetailMapper;
import com.njcn.event.pojo.dto.EventCount;
import com.njcn.event.pojo.param.EventBaseParam;
import com.njcn.event.pojo.param.UniversalFrontEndParam;

View File

@@ -25,7 +25,7 @@ import com.njcn.event.file.component.WaveFileComponent;
import com.njcn.event.file.pojo.dto.WaveDataDTO;
import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
import com.njcn.event.mapper.distribution.PwRmpEventDetailMapper;
import com.njcn.event.mapper.majornetwork.RmpEventDetailMapper;
import com.njcn.event.common.mapper.RmpEventDetailMapper;
import com.njcn.event.mapper.majornetwork.TransientMapper;
import com.njcn.event.pojo.param.EventVerifyReasonParam;
import com.njcn.event.pojo.param.TransientParam;
@@ -33,7 +33,7 @@ import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.EventDetailNew;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.TransientVO;
import com.njcn.event.service.majornetwork.EventDetailService;
import com.njcn.event.common.service.EventDetailService;
import com.njcn.event.service.majornetwork.TransientService;
import com.njcn.minioss.config.MinIossProperties;
import com.njcn.minioss.util.MinIoUtils;
@@ -56,7 +56,6 @@ import java.text.DecimalFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

View File

@@ -10,7 +10,7 @@ import com.njcn.event.pojo.param.VoltageRideThroughQueryParam;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.vo.EventNewStationVo;
import com.njcn.event.pojo.vo.VoltageRideThroughVo;
import com.njcn.event.service.majornetwork.EventDetailService;
import com.njcn.event.common.service.EventDetailService;
import com.njcn.event.service.majornetwork.SpThroughService;
import com.njcn.event.service.majornetwork.VoltageRideThroughEventService;
import com.njcn.event.pojo.param.SpThroughParam;

View File

@@ -1,4 +1,4 @@
package com.njcn.event.mapper.majornetwork;
package com.njcn.event.common.mapper;
import com.njcn.event.pojo.po.EventDistributionStatisticsPO;
import com.njcn.event.pojo.po.EventDurationLineChartPO;

View File

@@ -1,4 +1,4 @@
package com.njcn.event.mapper.majornetwork;
package com.njcn.event.common.mapper;
import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

View File

@@ -1,5 +1,5 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.event.mapper.majornetwork.RmpEventDetailMapper">
<mapper namespace="com.njcn.event.common.mapper.RmpEventDetailMapper">
<select id="getDetailsOfTransientEvents" resultType="com.njcn.event.pojo.po.RmpEventDetailPO">
SELECT

View File

@@ -0,0 +1,133 @@
package com.njcn.event.common.pojo.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* pqs
*
* @author cdf
* @date 2026/1/17
*/
@Data
public class LineDetailDataCommDTO {
private String lineId;
@ApiModelProperty(name = "id",value = "监测点序号")
private Integer id;
@ApiModelProperty(name = "lineName",value = "监测点名称")
private String lineName;
@ApiModelProperty(name = "areaName",value = "工程名称")
private String areaName;
@ApiModelProperty(name = "gdName",value = "单位")
private String gdName;
@ApiModelProperty(name = "bdName",value = "部门")
private String bdName;
@ApiModelProperty(name = "scale",value = "电压等级")
private String scale;
@ApiModelProperty(name = "manufacturer",value = "厂家")
private String manufacturer;
@ApiModelProperty(name = "devId",value = "终端Id")
private String devId;
@ApiModelProperty(name = "devName",value = "终端名称")
private String devName;
@ApiModelProperty(name = "ip",value = "网络参数")
private String ip;
@ApiModelProperty(name = "runFlag",value = "终端运行状态")
private String runFlag;
@ApiModelProperty(name = "comFlag",value = "通讯状态")
private String comFlag;
@ApiModelProperty(name = "loadType",value = "干扰源类型")
private String loadType;
@ApiModelProperty(name = "businessType",value = "行业类型")
private String businessType;
@ApiModelProperty(name = "objName",value = "监测点对象名称")
private String objName;
@ApiModelProperty(name = "ptType",value = "接线方式")
private String ptType;
@ApiModelProperty(name = "pt",value = "PT变比")
private String pt;
@ApiModelProperty(name = "ct",value = "CT变比")
private String ct;
@ApiModelProperty(name = "standardCapacity",value = "基准容量MVA")
private Float standardCapacity;
@ApiModelProperty(name = "shortCapacity",value = "最小短路容量MVA")
private Float shortCapacity;
@ApiModelProperty(name = "devCapacity",value = "供电设备容量MVA")
private Float devCapacity;
@ApiModelProperty(name = "dealCapacity",value = "用户协议容量MVA")
private Float dealCapacity;
@ApiModelProperty(name = "powerFlag",value = "电网标志0-电网侧1-非电网侧)")
private Integer powerFlag;
/**
* 测量间隔1-10分钟
*/
@ApiModelProperty(name = "timeInterval",value = "测量间隔1-10分钟")
private Integer timeInterval;
/**
* 监测点拥有者
*/
@ApiModelProperty(name = "owner",value = "监测点拥有者")
private String owner;
/**
* 拥有者职务
*/
@ApiModelProperty(name = "ownerDuty",value = "拥有者职务")
private String ownerDuty;
/**
* 拥有者联系方式
*/
@ApiModelProperty(name = "ownerTel",value = "拥有者联系方式")
private String ownerTel;
/**
* 接线图
*/
@ApiModelProperty(name = "wiringDiagram",value = "接线图")
private String wiringDiagram;
@ApiModelProperty(name = "ptPhaseType",value = "监测点接线相别0单相,1三相默认三相")
private Integer ptPhaseType;
@ApiModelProperty(name = "投运日期")
private LocalDate loginTime;
@ApiModelProperty(name = "最新数据时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
@ApiModelProperty(name = "监测对象信息ID")
private String objId;
@ApiModelProperty(name = "对象类型大类")
private String bigObjType;
}

View File

@@ -0,0 +1,18 @@
package com.njcn.event.common.service;
import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
import com.njcn.event.pojo.param.ExportParam;
import javax.servlet.http.HttpServletResponse;
/**
* pqs
*
* @author cdf
* @date 2026/1/17
*/
public interface CommMonitorEventReportService {
void getLineExport(ExportParam exportParam, LineDetailDataCommDTO lineDetailDataCommDTO, HttpServletResponse response);
}

View File

@@ -1,4 +1,4 @@
package com.njcn.event.service.majornetwork;
package com.njcn.event.common.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.event.pojo.param.*;
@@ -55,7 +55,7 @@ public interface EventAnalysisService {
* @param statisticsParam
* @return
*/
List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam) throws ParseException;
List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam);
/**
* 获取详细数据对象

View File

@@ -1,4 +1,4 @@
package com.njcn.event.service.majornetwork;
package com.njcn.event.common.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.event.pojo.dto.EventDeatilDTO;
@@ -41,4 +41,4 @@ public interface EventDetailService extends IService<RmpEventDetailPO> {
List<EventDetail> getEventDetailLimit(List<String> lineIndexes, String startTime, String endTime, Integer pageSize, Integer pageNum, List<String> waveType);
Boolean addEventDetail(EventDeatilDTO deatilDTO);
}
}

View File

@@ -1,4 +1,4 @@
package com.njcn.event.service.majornetwork;
package com.njcn.event.common.service;
import com.njcn.event.pojo.param.EventMonitorReportParam;
import com.njcn.event.pojo.vo.*;

View File

@@ -0,0 +1,78 @@
package com.njcn.event.common.service;
import com.njcn.event.pojo.param.StatisticsParam;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.vo.*;
import com.njcn.system.pojo.po.DictData;
import java.text.ParseException;
import java.util.List;
/**
* <监测点报表>
*
* @author wr
* @createTime: 2023-02-10
*/
public interface EventReportService {
/**
*获取Disdip表格监测点报表专用
* @param info influxdb查询结果pqs_eventdetail表
* @return
*/
List<DISDIPVO> eventDisdip(List<EventDetail> info);
/**
* 获取IEC411数据
* @param info influxdb查询结果pqs_eventdetail表
* @return
*/
List<IEC411VO> IEC411(List<EventDetail> info);
/**
* 获取IEC28数据
* @param info influxdb查询结果pqs_eventdetail表
* @return
*/
List<IEC28VO> IEC28(List<EventDetail> info);
/**
*暂降幅值概率分布
* @param info2 influxdb查询结果pqs_eventdetail表
* @return
*/
ProbabilityVO getProbabilityDistribution(List<EventDetail> info2);
/**
* 获取时间列表(月份统计)
* @param info influxdb查询结果pqs_eventdetail表
* @return
*/
List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam,List<EventDetail> info) throws ParseException;
/**
* 获取点状表格数据2.1
* @param info 结果集
* @param reasonData 暂降原因
* @param typeData 暂降类型
* @return
*/
List<EventDetail> getPlot(List<EventDetail> info, List<DictData> reasonData, List<DictData> typeData);
/**
* 获取详细数据对象
* @param info
* @param reasonData
* @param typeData
* @return
*/
StatisticVO getStatistic(List<EventDetail> info,List<DictData> reasonData,List<DictData>typeData);
/**
* 获取密度点图
* @param info
* @return
*/
Integer[][] getCoords(List<EventDetail> info);
}

View File

@@ -0,0 +1,589 @@
package com.njcn.event.common.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.pms.api.MonitorClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.echarts.pojo.constant.PicCommonData;
import com.njcn.echarts.util.DrawPicUtil;
import com.njcn.event.common.mapper.RmpEventDetailMapper;
import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
import com.njcn.event.common.service.EventAnalysisService;
import com.njcn.event.common.service.EventReportService;
import com.njcn.event.common.service.CommMonitorEventReportService;
import com.njcn.event.common.utils.WordUtils;
import com.njcn.event.pojo.param.ExportParam;
import com.njcn.event.pojo.param.StatisticsParam;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.*;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.util.Units;
import org.apache.poi.xwpf.usermodel.*;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth;
import org.springframework.stereotype.Service;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
/**
* pqs
*
* @author cdf
* @date 2026/1/17
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class CommMonitorEventReportServiceImpl implements CommMonitorEventReportService {
private final LineFeignClient lineFeignClient;
private final DicDataFeignClient dicDataFeignClient;
private final EventReportService eventReportService;
//调用暂降密度接口
private final EventAnalysisService eventAnalysisService;
private final MonitorClient monitorClient;
private final RmpEventDetailMapper rmpEventDetailMapper;
private final DrawPicUtil drawPicUtil;
/**
* 监测点导出word
*
* @param exportParam .
* @param response .
*/
@Override
public void getLineExport(ExportParam exportParam, LineDetailDataCommDTO lineDetailData, HttpServletResponse response) {
//创建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);
//查询参数
StatisticsParam param = new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(), exportParam.getFlag());
//获取暂降原因字典
List<DictData> reasonData = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()).getData();
//获取暂降类型字典
List<DictData> typeData = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()).getData();
//influxdb查询结果pqs_eventdetail表
List<EventDetail> info = info(param);
//记录数
int i = 1;
//1.监测点信息
if (exportParam.isXq()) {
createTitle(doc, "4." + i + " 监测点信息", "标题 2", 200, 15);
XWPFTable table = createTable(doc);
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
insertRow(doc, table, centerParagraph, true, "项目", "描述");
insertRow(doc, table, centerParagraph, false, "监测点名称", lineDetailData.getLineName());
insertRow(doc, table, centerParagraph, false, "电压等级", lineDetailData.getScale());
insertRow(doc, table, centerParagraph, false, "PT变比", lineDetailData.getPt());
insertRow(doc, table, centerParagraph, false, "CT变比", lineDetailData.getCt());
insertRow(doc, table, centerParagraph, false, "协议容量", lineDetailData.getDealCapacity() + "");
insertRow(doc, table, centerParagraph, false, "设备容量", lineDetailData.getDevCapacity() + "");
insertRow(doc, table, centerParagraph, false, "最小短路容量", lineDetailData.getShortCapacity() + "");
insertRow(doc, table, centerParagraph, false, "接线方式", lineDetailData.getPtType());
if (exportParam.getType() == 0) {
insertRow(doc, table, centerParagraph, false, "基准容量", lineDetailData.getStandardCapacity() + "");
}
i++;
}
//2.暂降事件暂降事件列表和暂降点图
//2.1.判断列表和点图是否是要导出
if (exportParam.isLb() || exportParam.isSjdF47() || exportParam.isSjdITIC()) {
// List<EventDetail> plot = eventAnalysisService.getPlot(param);
List<EventDetail> plot = eventReportService.getPlot(info, reasonData, typeData);
//暂降事件列表
if (exportParam.isLb()) {
createTitle(doc, "4." + i + " 暂降事件列表", "标题 2", 200, 15);
XWPFTable table = createTable(doc);
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
insertRow(doc, table, centerParagraph, true, "序号", "暂降发生时刻", "暂降幅值(%)", "持续时间(s)", "暂降类型", "暂降原因", "严重度");
for (int j = 0; j < plot.size(); j++) {
EventDetail eventDetail = plot.get(j);
String s = eventDetail.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
insertRow(doc, table, centerParagraph, false, j + 1 + "", s, BigDecimal.valueOf(eventDetail.getFeatureAmplitude() * 100).setScale(2, RoundingMode.HALF_UP).toString(), eventDetail.getDuration() + "", eventDetail.getAdvanceType(), eventDetail.getAdvanceReason(), eventDetail.getSeverity() + "");
}
i++;
}
//暂降事件点图
if (exportParam.isSjdF47() || exportParam.isSjdITIC()) {
ArrayList<List<Double>> ass = getAss(plot);
createTitle(doc, "4." + i + " 暂降事件点图", "标题 2", 200, 15);
int two = 1;
if (exportParam.isSjdITIC()) {
createTitle(doc, "4." + i + "." + two + " ITIC 曲线", "标题 3", 400, 15);
String itic = drawPicUtil.drawItic(ass);
createPic(doc, itic, "ITIC曲线");
two++;
}
if (exportParam.isSjdF47()) {
createTitle(doc, "4." + i + "." + two + " F47 曲线", "标题 3", 400, 15);
String f47 = drawPicUtil.drawF47(ass);
createPic(doc, f47, "SEMI F47曲线");
two++;
}
i++;
}
}
//3.暂降密度
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);
Integer[][] eventDensityData = eventReportService.getCoords(info);
String str = drawPicUtil.drawEventDensity(eventDensityData);
createPic(doc, str, "暂降密度图");
two++;
}
if (exportParam.isMdbg()) {
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
createTitle(doc, "4." + i + "." + two + " DISDIP 表格:国际发配电联盟(UNIPEDE)", "标题 3", 400, 15);
// List<DISDIPVO> eventDisdip = eventAnalysisService.eventDisdip(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
List<DISDIPVO> eventDisdip = eventReportService.eventDisdip(info);
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<IEC411VO> iec411VOS = eventAnalysisService.IEC411(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
List<IEC411VO> iec411VOS = eventReportService.IEC411(info);
XWPFTable table2 = createTable(doc);
insertRow(doc, table2, centerParagraph, true, "剩余电压", "10~20ms", "20~100ms", "0.1~0.2s", "0.2~0.5s", "0.5~1s", ">1s");
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<IEC28VO> iec28VOS = eventAnalysisService.IEC28(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
List<IEC28VO> iec28VOS = eventReportService.IEC28(info);
XWPFTable table3 = createTable(doc);
insertRow(doc, table3, centerParagraph, true, "剩余电压", "0.02~0.1s", "0.1~0.25s", "0.25~0.5s", "0.5s~1s", "1~3s", "3~20s", "20~60s", "60~180s");
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++;
}
//4.暂降幅值概率分布
if (exportParam.isGlfbfz() || exportParam.isGlfbsj()) {
createTitle(doc, "4." + i + " 暂降幅值概率分布图", "标题 2", 200, 15);
// ProbabilityVO probabilityVO = eventAnalysisService.getProbabilityDistribution(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
ProbabilityVO probabilityVO = eventReportService.getProbabilityDistribution(info);
int two = 1;
if (exportParam.isGlfbfz()) {
createTitle(doc, "4." + i + "." + two + " 暂降幅值的概率分函数", "标题 3", 400, 15);
List<String> ybardata = probabilityVO.getPereventvalue();
List<String> ylinedata = probabilityVO.getEventvalue();
String fz = drawPicUtil.drawEventAmplitude(ylinedata, ybardata);
createPic(doc, fz, "暂降幅值的概率分布函数");
two++;
}
if (exportParam.isGlfbsj()) {
createTitle(doc, "4." + i + "." + two + " 持续时间的概率分函数", "标题 3", 400, 15);
List<String> ybardata = probabilityVO.getPersisttime();
List<String> ylinedata = probabilityVO.getSisttime();
String sj = drawPicUtil.drawPersistentTime(ylinedata, ybardata);
createPic(doc, sj, "持续时间的概率分布函数");
two++;
}
i++;
}
//5.月份统计
if (exportParam.isTjbg() || exportParam.isTjtx()) {
createTitle(doc, "4." + i + " 月份统计", "标题 2", 200, 15);
int two = 1;
List<TimeVO> reasonTypeTime = eventAnalysisService.getReasonTypeTime(param);
//暂时时间端按月查询不能查询
// List<TimeVO> reasonTypeTime = eventReportService.getReasonTypeTime(param,null);
if (exportParam.isTjtx()) {
createTitle(doc, "4." + i + "." + two + " 月份统计图", "标题 3", 400, 15);
List<Integer> count = new ArrayList<>();
List<String> 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 = drawPicUtil.drawMonth(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.getFulltime(), timeVO.getTimes());
}
}
two++;
}
i++;
}
//6.原因统计
//6.1整合提出查询语句
Boolean fly = exportParam.isYybg() || exportParam.isYytx() || exportParam.isLxbg() || exportParam.isLxtx();
if (fly) {
StatisticVO statistic = eventReportService.getStatistic(info, reasonData, typeData);
if (exportParam.isYybg() || exportParam.isYytx()) {
createTitle(doc, "4." + i + " 原因统计", "标题 2", 200, 15);
// 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<String> xdata = new ArrayList<>();
List<Map<String, Object>> reasonList = new ArrayList<>();
List<ReasonsVO> reason = statistic.getReason();
for (ReasonsVO reasonsVO : reason) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("value", reasonsVO.getTimes());
map.put("name", reasonsVO.getReason());
reasonList.add(map);
xdata.add(reasonsVO.getReason());
}
String tr = drawPicUtil.drawReason(xdata, reasonList);
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<ReasonsVO> 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++;
}
//7.类型统计
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<String> xdata = new ArrayList<>();
List<TypesVO> types = statistic.getTypes();
List<Map<String, Object>> reasonList = new ArrayList<>();
for (TypesVO type : types) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("value", type.getTimes());
map.put("name", type.getType());
reasonList.add(map);
xdata.add(type.getType());
}
String tr = drawPicUtil.drawType(xdata, reasonList);
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<TypesVO> 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++;
}
}
try {
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();
}catch (Exception e){
throw new BusinessException(CommonResponseEnum.FAIL,"导出监测点暂降报告异常");
}
}
/**
* 创建标题
*
* @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);
}
/**
* 表格插入行数据
*
* @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);
}
}
/**
* 创建表格
*
* @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);
}
/**
*
*
* @param document 文档
* @param image 图片base64
* @param name 图片名
* @throws IOException
* @throws InvalidFormatException
*/
public void createPic(XWPFDocument document, String image, String name) {
try {
XWPFParagraph picParagraph = WordUtils.getCenterParagraph(document);
XWPFRun createRun = picParagraph.createRun();
if (image.contains(PicCommonData.PNG_PREFIX)) {
image = image.replace(PicCommonData.PNG_PREFIX, "");
}
byte[] bytes = Base64.getDecoder().decode(image);
InputStream in = new ByteArrayInputStream(bytes);
createRun.addPicture(in, 5, name, Units.toEMU(410), Units.toEMU(170));
}catch (Exception e){
log.error("在word中创建图片异常:",e);
}
}
/**
* 监测点暂降事件点图赋值
*
* @param plot
* @return
*/
private ArrayList<List<Double>> getAss(List<EventDetail> plot) {
ArrayList<List<Double>> list = new ArrayList<>();
for (EventDetail eventDetail : plot) {
ArrayList<Double> doubles = new ArrayList<>();
doubles.add(eventDetail.getDuration());
doubles.add(Double.parseDouble(String.valueOf(eventDetail.getFeatureAmplitude() * 100)));
list.add(doubles);
}
return list;
}
/**
* influxdb查询结果集
*
* @param statisticsParam
* @return
*/
private List<EventDetail> info(StatisticsParam statisticsParam) {
//获取事件类型
List<DictData> dictType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
List<String> typeIds = dictType.stream().filter(x -> DicDataEnum.VOLTAGE_DIP.getCode().equals(x.getCode()) || DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(x.getCode()))
.map(DictData::getId).collect(Collectors.toList());
//数据暂降查询
List<RmpEventDetailPO> info = rmpEventDetailMapper.selectList(new LambdaQueryWrapper<RmpEventDetailPO>()
.eq(RmpEventDetailPO::getMeasurementPointId, statisticsParam.getLineIndex())
.in(RmpEventDetailPO::getEventType, typeIds)
.ge(StrUtil.isNotBlank(statisticsParam.getStartTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getStartTime())))
.le(StrUtil.isNotBlank(statisticsParam.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(statisticsParam.getEndTime())))
);
return BeanUtil.copyToList(info, EventDetail.class);
}
}

View File

@@ -1,10 +1,9 @@
package com.njcn.event.service.majornetwork.Impl;
package com.njcn.event.common.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.config.GeneralInfo;
@@ -13,6 +12,7 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.event.common.service.EventDetailService;
import com.njcn.event.enums.EventResponseEnum;
import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
import com.njcn.event.pojo.param.EventBaseParam;
@@ -20,8 +20,7 @@ import com.njcn.event.pojo.param.StatisticsParam;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.*;
import com.njcn.event.service.majornetwork.EventAnalysisService;
import com.njcn.event.service.majornetwork.EventDetailService;
import com.njcn.event.common.service.EventAnalysisService;
import com.njcn.influx.utils.InfluxDbUtils;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
@@ -792,7 +791,7 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
* @author xxy
*/
@Override
public List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam) throws ParseException {
public List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam) {
//获取暂降字典信息
List<DictData> data = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
List<String> typeList = data.stream().filter(it->it.getCode().equals(DicDataEnum.VOLTAGE_DIP.getCode()) || it.getCode().equals(DicDataEnum.SHORT_INTERRUPTIONS.getCode())).map(DictData::getId).collect(Collectors.toList()); List<TimeVO> list = new ArrayList<>();

View File

@@ -1,4 +1,4 @@
package com.njcn.event.service.majornetwork.Impl;
package com.njcn.event.common.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
@@ -17,13 +17,13 @@ import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.po.DeptLine;
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.event.common.mapper.RmpEventDetailMapper;
import com.njcn.event.pojo.vo.SendEventVO;
import com.njcn.event.utils.EventUtil;
import com.njcn.event.mapper.majornetwork.EventDetailMapper;
import com.njcn.event.pojo.dto.EventDeatilDTO;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.service.majornetwork.EventDetailService;
import com.njcn.event.common.service.EventDetailService;
import com.njcn.influx.utils.InfluxDbUtils;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
@@ -53,7 +53,7 @@ import java.util.*;
@Slf4j
@Service
@RequiredArgsConstructor
public class EventDetailServiceImpl extends ServiceImpl<EventDetailMapper, RmpEventDetailPO> implements EventDetailService {
public class EventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper, RmpEventDetailPO> implements EventDetailService {
private final InfluxDbUtils influxDbUtils;
private final DicDataFeignClient dicDataFeignClient;

View File

@@ -1,4 +1,4 @@
package com.njcn.event.service.majornetwork.Impl;
package com.njcn.event.common.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.njcn.common.pojo.constant.BizParamConstant;
@@ -7,12 +7,12 @@ import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.pms.api.MonitorClient;
import com.njcn.device.pms.pojo.dto.PmsMonitorDTO;
import com.njcn.device.pms.pojo.param.PmsMonitorParam;
import com.njcn.event.mapper.majornetwork.EventDistributionStatisticsMapper;
import com.njcn.event.mapper.majornetwork.RmpEventDetailMapper;
import com.njcn.event.common.mapper.EventDistributionStatisticsMapper;
import com.njcn.event.common.service.EventMonitorReportService;
import com.njcn.event.common.mapper.RmpEventDetailMapper;
import com.njcn.event.pojo.param.EventMonitorReportParam;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.*;
import com.njcn.event.service.majornetwork.EventMonitorReportService;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum;

View File

@@ -1,13 +1,13 @@
package com.njcn.event.service.majornetwork.Impl;
package com.njcn.event.common.service.impl;
import cn.hutool.core.date.DateUtil;
import com.njcn.event.common.service.EventReportService;
import com.njcn.event.pojo.constant.Param;
import com.njcn.event.pojo.param.StatisticsParam;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.EventDetailNew;
import com.njcn.event.pojo.vo.*;
import com.njcn.event.service.majornetwork.EventReportService;
import com.njcn.influx.utils.InfluxDbUtils;
import com.njcn.system.pojo.po.DictData;
import lombok.RequiredArgsConstructor;

View File

@@ -1,4 +1,4 @@
package com.njcn.event.utils;
package com.njcn.event.common.utils;
import java.io.File;
import java.io.FileOutputStream;
import java.math.BigInteger;
@@ -28,7 +28,7 @@ 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 {
@@ -200,7 +200,7 @@ public class WordUtils {
paragraph.setSpacingAfter(100);
}
/**
/**
* 返回指定格式的段落 居中型
* @param document 文档对象
*/
@@ -211,8 +211,8 @@ public class WordUtils {
paragraph.setVerticalAlignment(TextAlignment.CENTER);
return paragraph;
}
/**
/**
* 返回指定格式的段落 居左型
* @param document 文档对象
*/
@@ -223,7 +223,7 @@ public class WordUtils {
return paragraph;
}
/**
* 添加换行符

View File

@@ -13,10 +13,11 @@
<modules>
<module>event-api</module>
<module>event-boot</module>
<module>event-common</module>
</modules>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<packaging>pom</packaging>
</project>
</project>