暂降监测点报告抽取公共方法
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
package com.njcn.event.common.mapper;
|
||||
|
||||
import com.njcn.event.pojo.po.EventDistributionStatisticsPO;
|
||||
import com.njcn.event.pojo.po.EventDurationLineChartPO;
|
||||
import com.njcn.event.pojo.po.EventFeatureAmplitudeLineChartPO;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.EventDipShortDistributionVO;
|
||||
import com.njcn.event.pojo.vo.EventRiseDistributionVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yzh
|
||||
* @date 2022/10/20
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
public interface EventDistributionStatisticsMapper {
|
||||
|
||||
/**
|
||||
* 获取暂态指标分布统计
|
||||
*
|
||||
* @param monitorIdList 监测点id
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return 暂态指标分布统计
|
||||
*/
|
||||
EventDistributionStatisticsPO getEventDistributionStatistics(@Param("monitorIdList") List<String> monitorIdList,
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
/**
|
||||
* 获取持续时间折线图
|
||||
*
|
||||
* @param monitorIdList 监测点id
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return 持续时间折线图
|
||||
*/
|
||||
EventDurationLineChartPO getEventDurationLineChart(@Param("monitorIdList") List<String> monitorIdList,
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
/**
|
||||
* 获取特征幅值折线图
|
||||
*
|
||||
* @param monitorIdList 监测点id
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return 特征幅值折线图
|
||||
*/
|
||||
EventFeatureAmplitudeLineChartPO getEventFeatureAmplitudeLineChart(@Param("monitorIdList") List<String> monitorIdList,
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
/**
|
||||
* 获取监测点暂态事件明细数据
|
||||
*
|
||||
* @param monitorIdList 监测点id
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return 监测点暂态事件明细数据
|
||||
*/
|
||||
List<RmpEventDetailPO> getRmpEventDetail(@Param("monitorIdList") List<String> monitorIdList,
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
|
||||
/***
|
||||
* 获取监测点电压暂降和短时中断分布情况
|
||||
* @author jianghaifei
|
||||
* @date 2022-10-27 10:46
|
||||
* @param map
|
||||
* @return com.njcn.event.pojo.vo.EventDipShortDistributionVO
|
||||
*/
|
||||
EventDipShortDistributionVO getEventDipShortDistributionByCond(Map<String, Object> map);
|
||||
|
||||
/***
|
||||
* 获取监测点电压暂升分布情况
|
||||
* @author jianghaifei
|
||||
* @date 2022-10-27 10:46
|
||||
* @param map
|
||||
* @return com.njcn.event.pojo.vo.EventRiseDistributionVO
|
||||
*/
|
||||
EventRiseDistributionVO getEventRiseDistributionByCond(Map<String, Object> map);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.njcn.event.common.mapper;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.event.pojo.dto.EventCount;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.RmpEventDetailVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 暂态事件明细
|
||||
*
|
||||
* @author yzh
|
||||
* @date 2022/10/12
|
||||
*/
|
||||
@Mapper
|
||||
public interface RmpEventDetailMapper extends BaseMapper<RmpEventDetailPO> {
|
||||
|
||||
/**
|
||||
* 获取暂态事件明细
|
||||
*
|
||||
* @param monitorIds 监测点id
|
||||
* @param eventType 暂态指标类型
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return 暂态事件明细
|
||||
*/
|
||||
List<RmpEventDetailPO> getDetailsOfTransientEvents(@Param("monitorIds") List<String> monitorIds,
|
||||
@Param("eventType") List<String> eventType,
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
/***
|
||||
* 与上面的方法区别是日期精确到月 yy-MM
|
||||
* @author jianghaifei
|
||||
* @date 2022-10-31 16:27
|
||||
* @param monitorIds
|
||||
* @param eventType
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return java.util.List<com.njcn.event.pojo.po.RmpEventDetailPO>
|
||||
*/
|
||||
List<RmpEventDetailPO> getDetailsOfTransientEventsByMonth(@Param("monitorIds") List<String> monitorIds,
|
||||
@Param("eventType") List<String> eventType,
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
|
||||
/**
|
||||
* 查询暂降信息
|
||||
* @param id 暂降事件的id
|
||||
* @return
|
||||
*/
|
||||
RmpEventDetailPO getByEventId(@Param("id") String id);
|
||||
|
||||
List<EventCount> getEventCount(@Param("startTime")String startTime,@Param("endTime")String endTime);
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.event.common.mapper.RmpEventDetailMapper">
|
||||
|
||||
<select id="getDetailsOfTransientEvents" resultType="com.njcn.event.pojo.po.RmpEventDetailPO">
|
||||
SELECT
|
||||
event_id as eventId,
|
||||
measurement_point_id as measurementPointId,
|
||||
Event_Type as eventType,
|
||||
start_time as startTime,
|
||||
Duration as duration,
|
||||
feature_amplitude as featureAmplitude,
|
||||
phase as phase,
|
||||
event_describe as eventDescribe,
|
||||
wave_path as wavePath
|
||||
FROM
|
||||
r_mp_event_detail
|
||||
WHERE
|
||||
measurement_point_id IN
|
||||
<foreach collection="monitorIds" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
<if test="eventType != null and eventType.size() >0">
|
||||
AND Event_Type IN
|
||||
<foreach collection="eventType" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
AND DATE_FORMAT(start_time, '%Y-%m-%d') >= DATE_FORMAT(#{startTime}, '%Y-%m-%d')
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND DATE_FORMAT(start_time, '%Y-%m-%d') <= DATE_FORMAT(#{endTime}, '%Y-%m-%d')
|
||||
</if>
|
||||
order by start_time desc
|
||||
</select>
|
||||
|
||||
<!-- 获取暂态事件明细 与上面的方法区别是日期精确到月 yy-MM -->
|
||||
<select id="getDetailsOfTransientEventsByMonth" resultType="com.njcn.event.pojo.po.RmpEventDetailPO">
|
||||
SELECT
|
||||
event_id as eventId,
|
||||
measurement_point_id as measurementPointId,
|
||||
Event_Type as eventType,
|
||||
start_time as startTime,
|
||||
Duration as duration,
|
||||
feature_amplitude as featureAmplitude,
|
||||
phase as phase,
|
||||
event_describe as eventDescribe,
|
||||
wave_path as wavePath
|
||||
FROM
|
||||
r_mp_event_detail
|
||||
WHERE
|
||||
measurement_point_id IN
|
||||
<foreach collection="monitorIds" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
<if test="eventType != null and eventType.size() >0">
|
||||
AND Event_Type IN
|
||||
<foreach collection="eventType" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
AND DATE_FORMAT(start_time, '%Y-%m') >= SUBSTRING(#{startTime}, 1, 7)
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND DATE_FORMAT(start_time, '%Y-%m') <= SUBSTRING(#{endTime}, 1, 7)
|
||||
</if>
|
||||
order by start_time desc
|
||||
</select>
|
||||
<select id="getByEventId" resultType="com.njcn.event.pojo.po.RmpEventDetailPO">
|
||||
SELECT
|
||||
*
|
||||
from
|
||||
r_mp_event_detail
|
||||
where event_id=#{id}
|
||||
</select>
|
||||
<select id="getEventCount" resultType="com.njcn.event.pojo.dto.EventCount">
|
||||
SELECT
|
||||
measurement_point_id lineId,
|
||||
SUM(CASE WHEN feature_amplitude >= 0 AND feature_amplitude < 0.1 THEN 1 ELSE 0 END) AS breakCounts,
|
||||
SUM(CASE WHEN feature_amplitude >= 0.1 AND feature_amplitude < 0.9 THEN 1 ELSE 0 END) AS downCounts,
|
||||
SUM(CASE WHEN feature_amplitude >= 1.1 THEN 1 ELSE 0 END) AS upCounts
|
||||
FROM
|
||||
r_mp_event_detail
|
||||
where start_time between #{startTime} and #{endTime}
|
||||
GROUP BY measurement_point_id
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.njcn.event.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.event.pojo.param.*;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* pqs-event
|
||||
* 暂降 监测点
|
||||
* @author cdf
|
||||
* @date 2022/6/23
|
||||
*/
|
||||
public interface EventAnalysisService {
|
||||
|
||||
/**
|
||||
* 获取暂降事件分析
|
||||
* @author cdf
|
||||
* @date 2022/6/23
|
||||
*/
|
||||
//Page<EventDetail> getEventAnalyse(EventBaseParam eventBaseParam);
|
||||
|
||||
/**
|
||||
* 获取坐标
|
||||
* @param statisticsParam
|
||||
* @return
|
||||
*/
|
||||
List<CoordsVO> getCoords(StatisticsParam statisticsParam);
|
||||
|
||||
/**
|
||||
*获取Disdip表格
|
||||
* @param statisticsParam
|
||||
* @return
|
||||
*/
|
||||
List<DISDIPVO> eventDisdip(StatisticsParam statisticsParam);
|
||||
|
||||
/**
|
||||
* 获取IEC411数据
|
||||
* @param statisticsParam
|
||||
* @return
|
||||
*/
|
||||
List<IEC411VO> IEC411(StatisticsParam statisticsParam);
|
||||
|
||||
/**
|
||||
* 获取IEC28数据
|
||||
* @param statisticsParam
|
||||
* @return
|
||||
*/
|
||||
List<IEC28VO> IEC28(StatisticsParam statisticsParam);
|
||||
|
||||
/**
|
||||
* 获取时间列表
|
||||
* @param statisticsParam
|
||||
* @return
|
||||
*/
|
||||
List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam);
|
||||
|
||||
/**
|
||||
* 获取详细数据对象
|
||||
* @param statisticsParam
|
||||
* @return
|
||||
*/
|
||||
StatisticVO getStatistic(StatisticsParam statisticsParam);
|
||||
|
||||
ProbabilityVO getProbabilityDistribution(StatisticsParam statisticsParam);
|
||||
/**
|
||||
* 获取点状表格数据
|
||||
* @param statisticsParam
|
||||
* @return
|
||||
*/
|
||||
VoltageToleranceCurveVO getPlot(StatisticsParam statisticsParam);
|
||||
|
||||
/**
|
||||
*监测点暂降事件分析查询
|
||||
* @author zbj
|
||||
* @date 2022/7/25
|
||||
*/
|
||||
Page<WaveTypeVO> getMonitorEventAnalyseQuery(EventBaseParam eventBaseParam);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*监测点事件波形下载
|
||||
* @author zbj
|
||||
* @date 2022/7/28
|
||||
*/
|
||||
//HttpServletResponse downloadMonitorEventWaveFile(WaveFileParam waveFileParam, HttpServletResponse response) throws Exception;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.njcn.event.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.event.pojo.dto.EventDeatilDTO;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.po.RStatEventOrgM;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022年04月07日 09:39
|
||||
*/
|
||||
public interface EventDetailService extends IService<RmpEventDetailPO> {
|
||||
/**
|
||||
* 根据监测点id获取暂降事件
|
||||
*
|
||||
* @param id 监测点id
|
||||
* @return 暂降事件详情
|
||||
*/
|
||||
List<EventDetail> getEventDetailData(String id, String startTime, String endTime);
|
||||
|
||||
/**
|
||||
* 根据监测点id和时区时间time获取暂降事件
|
||||
*
|
||||
* @param id 监测点id
|
||||
* @return 暂降事件详情
|
||||
*/
|
||||
EventDetail getEventDetailByTime(String id, String time);
|
||||
|
||||
/**
|
||||
* 根据监测点集合获取暂态列表
|
||||
*/
|
||||
List<EventDetail> getEventDetail(List<String> lineIndexes, String startTime, String endTime);
|
||||
|
||||
/**
|
||||
* 根据监测点集合以及分页信息获取暂降事件
|
||||
*/
|
||||
List<EventDetail> getEventDetailLimit(List<String> lineIndexes, String startTime, String endTime, Integer pageSize, Integer pageNum, List<String> waveType);
|
||||
|
||||
Boolean addEventDetail(EventDeatilDTO deatilDTO);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.njcn.event.common.service;
|
||||
|
||||
import com.njcn.event.pojo.param.EventMonitorReportParam;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Title EventMonitorDailyReportService
|
||||
* @Package com.njcn.event.service
|
||||
* @Author jianghaifei
|
||||
* @Date 2022-10-25 09:39
|
||||
* @Version V1.0
|
||||
*/
|
||||
public interface EventMonitorReportService {
|
||||
|
||||
//监测点暂态事件发生次数
|
||||
List<EventMonitorReportVO> getMonitorEventCount(EventMonitorReportParam eventMonitorReportParam);
|
||||
|
||||
//暂态指标监测点电压暂降和短时中断分布情况
|
||||
List<EventDipShortDistributionTableVO> getEventDipShortDistributionByCond(EventMonitorReportParam eventMonitorReportParam);
|
||||
|
||||
//暂态指标监测点电压暂升分布情况
|
||||
List<EventRiseDistributionTableVO> getEventRiseDistributionByCond(EventMonitorReportParam eventMonitorReportParam);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,339 @@
|
||||
package com.njcn.event.common.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.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.advance.api.EventCauseFeignClient;
|
||||
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||
import com.njcn.device.pq.api.DeptLineFeignClient;
|
||||
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.pojo.dto.EventDeatilDTO;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
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;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.po.Dept;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.influxdb.impl.InfluxDBResultMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022/3/16
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class EventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper, RmpEventDetailPO> implements EventDetailService {
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
private final MqttPublisher publisher;
|
||||
private final CommTerminalGeneralClient commTerminalGeneralClient;
|
||||
private final LineFeignClient lineFeignClient;
|
||||
private final DeptLineFeignClient deptLineFeignClient;
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
|
||||
private final EventCauseFeignClient eventCauseFeignClient;
|
||||
@Override
|
||||
public List<EventDetail> getEventDetailData(String id, String startTime, String endTime) {
|
||||
//数据暂降查询
|
||||
List<RmpEventDetailPO> info = this.list(new LambdaQueryWrapper<RmpEventDetailPO>()
|
||||
.eq(RmpEventDetailPO::getMeasurementPointId, id)
|
||||
.ge(StrUtil.isNotBlank(startTime), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(startTime)))
|
||||
.le(StrUtil.isNotBlank(endTime), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(endTime)))
|
||||
);
|
||||
return BeanUtil.copyToList(info, EventDetail.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventDetail getEventDetailByTime(String id, String time) {
|
||||
EventDetail eventDetail = new EventDetail();
|
||||
//组装sql语句
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("time = '").append(time).append("' and ").append("line_id ='").append(id).append("' limit 1 tz('Asia/Shanghai')");
|
||||
|
||||
String sql = "select * from pqs_eventdetail where " + stringBuilder;
|
||||
//获取暂降事件
|
||||
QueryResult result = influxDbUtils.query(sql);
|
||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
||||
if (!Objects.isNull(result)) {
|
||||
List<EventDetail> detailList = influxDBResultMapper.toPOJO(result, EventDetail.class);
|
||||
if (!CollectionUtils.isEmpty(detailList)) {
|
||||
eventDetail = detailList.get(0);
|
||||
}
|
||||
}
|
||||
return eventDetail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EventDetail> getEventDetail(List<String> lineIndexes, String startTime, String endTime) {
|
||||
List<RmpEventDetailPO> info = this.list(new LambdaQueryWrapper<RmpEventDetailPO>()
|
||||
.in(RmpEventDetailPO::getMeasurementPointId, lineIndexes)
|
||||
.ge(StrUtil.isNotBlank(startTime), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(startTime)))
|
||||
.le(StrUtil.isNotBlank(endTime), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(endTime)))
|
||||
.orderByDesc(RmpEventDetailPO::getStartTime)
|
||||
);
|
||||
return BeanUtil.copyToList(info, EventDetail.class);
|
||||
|
||||
// //组装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 (");
|
||||
// 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("' ");
|
||||
// }
|
||||
// }
|
||||
// stringBuilder.append(") and (");
|
||||
// for (int i = 0; i < waveType.size(); i++) {
|
||||
// if (waveType.size() - i != 1) {
|
||||
// stringBuilder.append("wave_type ='").append(waveType.get(i)).append("' or ");
|
||||
// } else {
|
||||
// stringBuilder.append("wave_type ='").append(waveType.get(i)).append("' ");
|
||||
// }
|
||||
// }
|
||||
// stringBuilder.append(") order by time desc tz('Asia/Shanghai");
|
||||
// //sql语句
|
||||
// String sql = "SELECT * FROM pqs_eventdetail WHERE " + stringBuilder;
|
||||
//
|
||||
// //结果集
|
||||
// QueryResult result = influxDbUtils.query(sql);
|
||||
// //结果集映射到对象中
|
||||
// InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
||||
// List<EventDetail> eventDetailList = influxDBResultMapper.toPOJO(result, EventDetail.class);
|
||||
// return eventDetailList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EventDetail> getEventDetailLimit(List<String> lineIndexes, String startTime, String endTime, Integer pageSize, Integer pageNum, List<String> waveType) {
|
||||
Page<RmpEventDetailPO> pageInfo = this.page(new Page<>(pageNum, pageSize), new LambdaQueryWrapper<RmpEventDetailPO>()
|
||||
.in(RmpEventDetailPO::getMeasurementPointId, lineIndexes)
|
||||
.ge(StrUtil.isNotBlank(startTime), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(startTime)))
|
||||
.le(StrUtil.isNotBlank(endTime), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(endTime)))
|
||||
);
|
||||
return BeanUtil.copyToList(pageInfo.getRecords(), EventDetail.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean addEventDetail(EventDeatilDTO deatilDTO) {
|
||||
RmpEventDetailPO rmpEventDetailPO = new RmpEventDetailPO();
|
||||
// rmpEventDetailPO.setMeasurementPointId(deatilDTO.getMonitorId());
|
||||
rmpEventDetailPO.setLineId(deatilDTO.getMonitorId());
|
||||
DictData data = dicDataFeignClient.getDicDataByCode(eventTypeReflection(deatilDTO.getEventType())).getData();
|
||||
rmpEventDetailPO.setEventType(data.getId());
|
||||
rmpEventDetailPO.setStartTime(deatilDTO.getStartTime());
|
||||
rmpEventDetailPO.setDuration(deatilDTO.getDuration()/1000);
|
||||
rmpEventDetailPO.setFeatureAmplitude(deatilDTO.getAmplitude()/100);
|
||||
rmpEventDetailPO.setPhase(deatilDTO.getPhase());
|
||||
rmpEventDetailPO.setWavePath(deatilDTO.getWavePath());
|
||||
if(StringUtils.isEmpty(deatilDTO.getWavePath())){
|
||||
rmpEventDetailPO.setFileFlag(0);
|
||||
}else {
|
||||
rmpEventDetailPO.setFileFlag(1);
|
||||
}
|
||||
|
||||
rmpEventDetailPO.setEventDescribe(" ");
|
||||
//如果不为空,说明是二次上传波形文件了;
|
||||
String reason,type;
|
||||
if(!StringUtils.isEmpty(rmpEventDetailPO.getWavePath())){
|
||||
LineDetailDataVO lineDetailData = lineFeignClient.getLineDetailData(rmpEventDetailPO.getLineId()).getData();
|
||||
String ip = lineDetailData.getIp();
|
||||
EventAnalysisDTO eventAnalysisDTO = new EventAnalysisDTO();
|
||||
eventAnalysisDTO.setIp(ip);
|
||||
eventAnalysisDTO.setWaveName(rmpEventDetailPO.getWavePath());
|
||||
|
||||
EventAnalysisDTO result = eventCauseFeignClient.analysisCauseAndType(eventAnalysisDTO).getData();
|
||||
if(Objects.isNull(result.getCause())){
|
||||
reason =reasonReflection(0);
|
||||
|
||||
}else {
|
||||
reason =reasonReflection(result.getCause());
|
||||
|
||||
}
|
||||
if(Objects.isNull(result.getType())){
|
||||
type =advanceTypeReflection(10);
|
||||
|
||||
}else {
|
||||
type =advanceTypeReflection(result.getType());
|
||||
|
||||
}
|
||||
DictData advancereason = dicDataFeignClient.getDicDataByCode(reason).getData();
|
||||
DictData advanceType = dicDataFeignClient.getDicDataByCode(type).getData();
|
||||
rmpEventDetailPO.setAdvanceReason(advancereason.getId());
|
||||
rmpEventDetailPO.setAdvanceType(advanceType.getId());
|
||||
|
||||
}
|
||||
//默认都是其他
|
||||
// DictData reason = dicDataFeignClient.getDicDataByCode(DicDataEnum.RESON_REST.getCode()).getData();
|
||||
// DictData advanceType = dicDataFeignClient.getDicDataByCode(DicDataEnum.TYPE_REST.getCode()).getData();
|
||||
//
|
||||
// rmpEventDetailPO.setAdvanceReason(reason.getId());
|
||||
// rmpEventDetailPO.setAdvanceType(advanceType.getId());
|
||||
|
||||
|
||||
String severity = EventUtil.getYzd(deatilDTO.getDuration().floatValue(),(deatilDTO.getAmplitude().floatValue()/100));
|
||||
rmpEventDetailPO.setSeverity(Double.valueOf(severity));
|
||||
rmpEventDetailPO.setCreateTime(LocalDateTime.now());
|
||||
|
||||
RmpEventDetailPO one = this.lambdaQuery().eq(RmpEventDetailPO::getLineId, rmpEventDetailPO.getLineId()).eq(RmpEventDetailPO::getStartTime, rmpEventDetailPO.getStartTime()).one();
|
||||
if(Objects.nonNull(one)){
|
||||
rmpEventDetailPO.setEventId(one.getEventId());
|
||||
|
||||
this.updateById(rmpEventDetailPO);
|
||||
} else {
|
||||
this.save(rmpEventDetailPO);
|
||||
//推送MQTT消息给前端,用于展示告警消息和弹窗
|
||||
//如果是补招数据,如果事件的时间跟当前时间相差1小时,则不出弹窗。
|
||||
Duration duration = Duration.between(rmpEventDetailPO.getStartTime(), LocalDateTime.now());
|
||||
if (duration.toHours() <= 1 && !duration.isNegative()) {
|
||||
pushEvent(rmpEventDetailPO);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private String advanceTypeReflection(Integer type) {
|
||||
String result = DicDataEnum.TYPE_REST.getCode();
|
||||
switch (type) {
|
||||
case 0:
|
||||
result = DicDataEnum.INTERPHASE_BC.getCode();
|
||||
break;
|
||||
case 1:
|
||||
result = DicDataEnum.PHASE_C.getCode();
|
||||
break;
|
||||
case 2:
|
||||
result = DicDataEnum.INTERPHASE_AC.getCode();
|
||||
break;
|
||||
case 3:
|
||||
result = DicDataEnum.PHASE_A.getCode();
|
||||
break;
|
||||
case 4:
|
||||
result = DicDataEnum.INTERPHASE_AB.getCode();
|
||||
break;
|
||||
case 5:
|
||||
result = DicDataEnum.PHASE_B.getCode();
|
||||
break;
|
||||
case 6:
|
||||
result = DicDataEnum.GROUND_BC.getCode();
|
||||
break;
|
||||
case 7:
|
||||
result = DicDataEnum.GROUND_AC.getCode();
|
||||
break;
|
||||
case 8:
|
||||
result = DicDataEnum.GROUND_AB.getCode();
|
||||
break;
|
||||
case 9:
|
||||
result = DicDataEnum.GROUND_ABC.getCode();
|
||||
break;
|
||||
case 10:
|
||||
result = DicDataEnum.TYPE_REST.getCode();
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private String reasonReflection(Integer cause) {
|
||||
String result =DicDataEnum.RESON_REST.getCode();
|
||||
switch (cause) {
|
||||
case 0:
|
||||
result = DicDataEnum.RESON_REST.getCode();
|
||||
break;
|
||||
case 1:
|
||||
result = DicDataEnum.SHORT_TROUBLE.getCode();
|
||||
break;
|
||||
case 2:
|
||||
result = DicDataEnum.TRANSFORMER_EXCITATION.getCode();
|
||||
break;
|
||||
case 3:
|
||||
result = DicDataEnum.LARGE_INDUCTION.getCode();
|
||||
break;
|
||||
case 4:
|
||||
result = DicDataEnum.VOLTAGE_DISTURBANCE.getCode();
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void pushEvent(RmpEventDetailPO po) {
|
||||
String id = po.getLineId();
|
||||
//根据监测点获取部门
|
||||
List<DeptLine> deptLineList = deptLineFeignClient.getDeptListByLineId(id).getData();
|
||||
if (CollUtil.isNotEmpty(deptLineList)) {
|
||||
Set<String> dept = new HashSet<>();
|
||||
deptLineList.forEach(item->{
|
||||
String deptLineId = item.getId();
|
||||
dept.add(deptLineId);
|
||||
//获取上级部门
|
||||
Dept deptInfo = deptFeignClient.getDeptById(deptLineId).getData();
|
||||
String[] idsArray = deptInfo.getPids().split(",");
|
||||
dept.addAll(Arrays.asList(idsArray));
|
||||
});
|
||||
SendEventVO vo = new SendEventVO();
|
||||
vo.setDeptList(dept);
|
||||
vo.setTime(po.getStartTime());
|
||||
vo.setEventValue(BigDecimal.valueOf(po.getFeatureAmplitude()).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
vo.setPersistTime(po.getDuration());
|
||||
vo.setEventType(po.getEventType());
|
||||
vo.setEventReason(po.getAdvanceReason());
|
||||
List<AreaLineInfoVO> lineInfoVOList = lineFeignClient.getBaseLineAreaInfo(Collections.singletonList(po.getLineId())).getData();
|
||||
vo.setLineName(lineInfoVOList.get(0).getLineName());
|
||||
vo.setPowerCompany(lineInfoVOList.get(0).getGdName());
|
||||
vo.setSubstation(lineInfoVOList.get(0).getSubName());
|
||||
publisher.send("/sendEvent", PubUtils.obj2json(vo), 1, false);
|
||||
}
|
||||
}
|
||||
|
||||
public String eventTypeReflection(Integer eventType){
|
||||
String result ="";
|
||||
switch (eventType) {
|
||||
case 1210001:
|
||||
result = DicDataEnum.VOLTAGE_RISE.getCode();
|
||||
break;
|
||||
case 1210002:
|
||||
result = DicDataEnum.VOLTAGE_DIP.getCode();
|
||||
break;
|
||||
case 1210003:
|
||||
result = DicDataEnum.OTHER.getCode();
|
||||
break;
|
||||
case 1210004:
|
||||
result = DicDataEnum.SHORT_INTERRUPTIONS.getCode();
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,427 @@
|
||||
package com.njcn.event.common.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.njcn.common.pojo.constant.BizParamConstant;
|
||||
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.pms.pojo.dto.PmsMonitorDTO;
|
||||
import com.njcn.device.pms.pojo.param.PmsMonitorParam;
|
||||
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.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.dto.DeptDTO;
|
||||
import com.njcn.web.utils.WebUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Title EventMonitorDailyReportServiceImpl
|
||||
* @Package com.njcn.event.service.Impl
|
||||
* @Author jianghaifei
|
||||
* @Date 2022-10-25 09:39
|
||||
* @Version V1.0
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class EventMonitorReportServiceImpl implements EventMonitorReportService {
|
||||
|
||||
private final MonitorClient monitorClient;
|
||||
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
|
||||
private final RmpEventDetailMapper rmpEventDetailMapper;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final EventDistributionStatisticsMapper eventDistributionStatisticsMapper;
|
||||
|
||||
|
||||
/***
|
||||
* 监测点暂态事件发生次数
|
||||
* @author jianghaifei
|
||||
* @date 2022-10-29 18:05
|
||||
* @param eventMonitorReportParam
|
||||
* @return java.util.List<com.njcn.event.pojo.vo.EventMonitorReportVO>
|
||||
*/
|
||||
@Override
|
||||
public List<EventMonitorReportVO> getMonitorEventCount(EventMonitorReportParam eventMonitorReportParam) {
|
||||
//提取查询参数
|
||||
// String monitorName = eventMonitorReportParam.getMonitorName(); //监测点名称
|
||||
// String id = eventMonitorReportParam.getId(); //单位id
|
||||
String startTime = eventMonitorReportParam.getStartTime(); //开始时间
|
||||
String endTime = eventMonitorReportParam.getEndTime(); //结束时间
|
||||
Integer type = eventMonitorReportParam.getType(); //时间类型(日/月)
|
||||
|
||||
/****** 获取监测点信息(version1.0) ******/
|
||||
//获取所有子部门信息
|
||||
// List<DeptDTO> deptDTOList = deptFeignClient.getDeptDescendantIndexes(id, WebUtil.filterDeptType()).getData();
|
||||
// if (CollUtil.isEmpty(deptDTOList)) {
|
||||
// throw new BusinessException(CommonResponseEnum.NO_DATA, "部门不存在");
|
||||
// }
|
||||
// //单位id集合
|
||||
// List<String> orgNoList = deptDTOList.stream().map(DeptDTO::getId).collect(Collectors.toList());
|
||||
// //查询监测点信息(version1.0)
|
||||
// PmsMonitorParam pmsMonitorParam = new PmsMonitorParam();
|
||||
// pmsMonitorParam.setMonitorName(monitorName); //监测点名称
|
||||
// pmsMonitorParam.setOrgIds(orgNoList); //单位ids
|
||||
// List<PmsMonitorDTO> monitorList = monitorClient.getMonitorInfoListByCond(pmsMonitorParam).getData(); //监测点信息
|
||||
//查询监测点信息 (version2.0)
|
||||
List<PmsMonitorDTO> monitorList = this.getMonitorList(eventMonitorReportParam);
|
||||
List<String> monitorIdList = monitorList.stream().map(PmsMonitorDTO::getId).collect(Collectors.toList()); //监测点id信息
|
||||
Map<String, PmsMonitorDTO> monitorMap = monitorList.stream().collect(Collectors.toMap(PmsMonitorDTO::getId, monitor -> monitor));
|
||||
|
||||
//获取电压等级的字典
|
||||
List<DictData> voltageLevelList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
|
||||
//将电压信息转成map,key:id value:name
|
||||
Map<String, String> voltageLevelMap = voltageLevelList.stream().collect(Collectors.toMap(DictData::getId, DictData::getName));
|
||||
//获取暂态指标的字典
|
||||
List<DictData> eventStatisList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
|
||||
//将暂态指标信息转成map,key:id value:实体
|
||||
Map<String, DictData> eventStatisMap = eventStatisList.stream().collect(Collectors.toMap(DictData::getId, data -> data));
|
||||
//将暂态指标信息转成map,key:code value:实体
|
||||
// Map<String, DictData> eventStatisMapByCode = eventStatisList.stream().collect(Collectors.toMap(DictData::getCode, data -> data));
|
||||
|
||||
//查询暂态事件明细
|
||||
List<RmpEventDetailPO> detailList;
|
||||
if (BizParamConstant.STAT_BIZ_MONTH.equals(type + "")) { //按月查
|
||||
detailList = rmpEventDetailMapper.getDetailsOfTransientEventsByMonth(monitorIdList, null, startTime, endTime);
|
||||
} else { //按日查
|
||||
detailList = rmpEventDetailMapper.getDetailsOfTransientEvents(monitorIdList, null, startTime, endTime);
|
||||
}
|
||||
|
||||
|
||||
Map<String, List<RmpEventDetailPO>> groupByMIdDetailMap = detailList.stream().collect(Collectors.groupingBy(RmpEventDetailPO::getMeasurementPointId, Collectors.toList()));
|
||||
List<EventMonitorReportVO> resultList = new ArrayList<>();
|
||||
groupByMIdDetailMap.forEach((key, monitorEventDetailList) -> {
|
||||
//封装返回需要返回的信息
|
||||
PmsMonitorDTO pmsMonitorDTO = monitorMap.get(key);
|
||||
|
||||
EventMonitorReportVO eventMonitorReportVO = new EventMonitorReportVO();
|
||||
eventMonitorReportVO.setDate(startTime); //查询时间
|
||||
//监测点基本信息
|
||||
eventMonitorReportVO.setMonitorId(pmsMonitorDTO.getId()); //监测点id
|
||||
eventMonitorReportVO.setMonitorName(pmsMonitorDTO.getName()); //监测点name
|
||||
eventMonitorReportVO.setOrgId(pmsMonitorDTO.getOrgId()); //单位id
|
||||
eventMonitorReportVO.setOrgName(pmsMonitorDTO.getOrgName()); //单位name
|
||||
eventMonitorReportVO.setVoltageLevel(pmsMonitorDTO.getVoltageLevel()); //监测点电压等级
|
||||
eventMonitorReportVO.setVoltageLevelName(voltageLevelMap.get(pmsMonitorDTO.getVoltageLevel())); //监测点电压等级名称
|
||||
//暂升、暂降、短时中断次数
|
||||
Map<String, List<RmpEventDetailPO>> countMap = monitorEventDetailList.stream().collect(Collectors.groupingBy(RmpEventDetailPO::getEventType, Collectors.toList()));
|
||||
countMap.forEach((countKey, value) -> {
|
||||
String code = eventStatisMap.get(countKey).getCode();
|
||||
//电压暂降次数
|
||||
if (DicDataEnum.VOLTAGE_DIP.getCode().equalsIgnoreCase(code)) {
|
||||
eventMonitorReportVO.setVoltageDipCount(CollUtil.isNotEmpty(value) ? value.size() : 0);
|
||||
}
|
||||
//电压暂升次数
|
||||
if (DicDataEnum.VOLTAGE_RISE.getCode().equalsIgnoreCase(code)) {
|
||||
eventMonitorReportVO.setVoltageRiseCount(CollUtil.isNotEmpty(value) ? value.size() : 0);
|
||||
}
|
||||
//短时中断
|
||||
if (DicDataEnum.SHORT_INTERRUPTIONS.getCode().equalsIgnoreCase(code)) {
|
||||
eventMonitorReportVO.setShortInterruptionCount(CollUtil.isNotEmpty(value) ? value.size() : 0);
|
||||
}
|
||||
|
||||
});
|
||||
//重新校验设置属性值,避免值是null
|
||||
eventMonitorReportVO.setVoltageDipCount(eventMonitorReportVO.getVoltageDipCount() == null ? 0 : eventMonitorReportVO.getVoltageDipCount());
|
||||
eventMonitorReportVO.setVoltageRiseCount(eventMonitorReportVO.getVoltageRiseCount() == null ? 0 : eventMonitorReportVO.getVoltageRiseCount());
|
||||
eventMonitorReportVO.setShortInterruptionCount(eventMonitorReportVO.getShortInterruptionCount() == null ? 0 : eventMonitorReportVO.getShortInterruptionCount());
|
||||
|
||||
// //短时中断、暂降分布情况
|
||||
// Map<String, Object> condMap = new HashMap<>();
|
||||
// condMap.put("monitorIdList", Arrays.asList(key.split(",")));
|
||||
// condMap.put("startTime", startTime);
|
||||
// condMap.put("endTime", endTime);
|
||||
// condMap.put("eventTypeList", Arrays.asList(eventStatisMapByCode.get("Voltage_Dip").getId(), eventStatisMapByCode.get("Short_Interruptions").getId()));
|
||||
// EventDipShortDistributionVO eventDipShortDistributionVO = eventDistributionStatisticsMapper.getEventDipShortDistributionByCond(condMap);
|
||||
// eventMonitorReportVO.setDipShortStatisticsVO(eventDipShortDistributionVO);
|
||||
|
||||
//暂升分布情况
|
||||
// Map<String, Object> riseCondMap = new HashMap<>();
|
||||
// riseCondMap.put("monitorIdList", Arrays.asList(key.split(",")));
|
||||
// riseCondMap.put("startTime", startTime);
|
||||
// riseCondMap.put("endTime", endTime);
|
||||
// riseCondMap.put("eventTypeList", Collections.singletonList(eventStatisMapByCode.get("Voltage_Rise").getId()));
|
||||
// EventRiseDistributionVO eventRiseDistributionVO = eventDistributionStatisticsMapper.getEventRiseDistributionByCond(riseCondMap);
|
||||
// eventMonitorReportVO.setRiseStatisticsVO(eventRiseDistributionVO);
|
||||
|
||||
resultList.add(eventMonitorReportVO);
|
||||
});
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/***
|
||||
* 暂态指标监测点电压暂降和短时中断分布情况
|
||||
* @author jianghaifei
|
||||
* @date 2022-10-28 14:56
|
||||
* @param eventMonitorReportParam
|
||||
* @return com.njcn.event.pojo.vo.EventDipShortDistributionVO
|
||||
*/
|
||||
@Override
|
||||
public List<EventDipShortDistributionTableVO> getEventDipShortDistributionByCond(EventMonitorReportParam eventMonitorReportParam) {
|
||||
//提取参数
|
||||
// String monitorName = eventMonitorReportParam.getMonitorName(); //监测点名称
|
||||
// String id = eventMonitorReportParam.getId(); //单位id
|
||||
String startTime = eventMonitorReportParam.getStartTime(); //开始时间
|
||||
String endTime = eventMonitorReportParam.getEndTime(); //结束时间
|
||||
Integer type = eventMonitorReportParam.getType(); //时间类型(日/月)
|
||||
|
||||
/****** 获取监测点信息(version1.0) ******/
|
||||
// //获取所有子部门信息
|
||||
// List<DeptDTO> deptDTOList = deptFeignClient.getDeptDescendantIndexes(id, WebUtil.filterDeptType()).getData();
|
||||
// if (CollUtil.isEmpty(deptDTOList)) {
|
||||
// throw new BusinessException(CommonResponseEnum.NO_DATA, "部门不存在");
|
||||
// }
|
||||
// //单位id集合
|
||||
// List<String> orgNoList = deptDTOList.stream().map(DeptDTO::getId).collect(Collectors.toList());
|
||||
// //查询监测点信息
|
||||
// PmsMonitorParam pmsMonitorParam = new PmsMonitorParam();
|
||||
// pmsMonitorParam.setMonitorName(monitorName); //监测点名称
|
||||
// pmsMonitorParam.setOrgIds(orgNoList); //单位ids
|
||||
// List<PmsMonitorDTO> monitorList = monitorClient.getMonitorInfoListByCond(pmsMonitorParam).getData(); //监测点信息
|
||||
//查询监测点信息(version2.0)
|
||||
List<PmsMonitorDTO> monitorList = this.getMonitorList(eventMonitorReportParam);
|
||||
List<String> monitorIdList = monitorList.stream().map(PmsMonitorDTO::getId).collect(Collectors.toList()); //监测点id集合
|
||||
|
||||
//获取暂态指标的字典
|
||||
List<DictData> eventStatisList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
|
||||
//将暂态指标信息转成map,key:code value:实体
|
||||
Map<String, DictData> eventStatisMapByCode = eventStatisList.stream().collect(Collectors.toMap(DictData::getCode, data -> data));
|
||||
|
||||
//短时中断、暂降分布情况
|
||||
Map<String, Object> condMap = new HashMap<>();
|
||||
condMap.put("monitorIdList", monitorIdList);
|
||||
condMap.put("startTime", startTime);
|
||||
condMap.put("endTime", endTime);
|
||||
condMap.put("eventTypeList", Arrays.asList(eventStatisMapByCode.get(DicDataEnum.VOLTAGE_DIP.getCode()).getId(), eventStatisMapByCode.get(DicDataEnum.SHORT_INTERRUPTIONS.getCode()).getId()));
|
||||
condMap.put("dateType", type);
|
||||
EventDipShortDistributionVO eventDipShortDistribution = eventDistributionStatisticsMapper.getEventDipShortDistributionByCond(condMap);
|
||||
|
||||
//设置返回数据
|
||||
List<EventDipShortDistributionTableVO> list = new ArrayList<>();
|
||||
//特征幅值[80,90]
|
||||
EventDipShortDistributionTableVO entity8090 = new EventDipShortDistributionTableVO();
|
||||
entity8090.setFeatureAmplitude("[80,90]");
|
||||
entity8090.setDuration100(eventDipShortDistribution.getFeatureAmp90with100ms()); //持续时间10ms-100ms
|
||||
entity8090.setDuration250(eventDipShortDistribution.getFeatureAmp90with250ms()); //持续时间100ms-250ms
|
||||
entity8090.setDuration500(eventDipShortDistribution.getFeatureAmp90with500ms()); //持续时间250ms-500ms
|
||||
entity8090.setDuration1000(eventDipShortDistribution.getFeatureAmp90with1000ms()); //持续时间500ms-1000ms
|
||||
entity8090.setDuration3000(eventDipShortDistribution.getFeatureAmp90with3000ms()); //持续时间1000ms-3000ms
|
||||
entity8090.setDuration10000(eventDipShortDistribution.getFeatureAmp90with10000ms()); //持续时间3000ms-10000ms
|
||||
entity8090.setDuration20000(eventDipShortDistribution.getFeatureAmp90with20000ms()); //持续时间10000ms-20000ms
|
||||
entity8090.setDuration60000(eventDipShortDistribution.getFeatureAmp90with60000ms()); //持续时间20000ms-60000ms
|
||||
list.add(entity8090);
|
||||
|
||||
//特征幅值[70,80)
|
||||
EventDipShortDistributionTableVO entity7080 = new EventDipShortDistributionTableVO();
|
||||
entity7080.setFeatureAmplitude("[70,80)");
|
||||
entity7080.setDuration100(eventDipShortDistribution.getFeatureAmp80with100ms()); //持续时间10ms-100ms
|
||||
entity7080.setDuration250(eventDipShortDistribution.getFeatureAmp80with250ms()); //持续时间100ms-250ms
|
||||
entity7080.setDuration500(eventDipShortDistribution.getFeatureAmp80with500ms()); //持续时间250ms-500ms
|
||||
entity7080.setDuration1000(eventDipShortDistribution.getFeatureAmp80with1000ms()); //持续时间500ms-1000ms
|
||||
entity7080.setDuration3000(eventDipShortDistribution.getFeatureAmp80with3000ms()); //持续时间1000ms-3000ms
|
||||
entity7080.setDuration10000(eventDipShortDistribution.getFeatureAmp80with10000ms()); //持续时间3000ms-10000ms
|
||||
entity7080.setDuration20000(eventDipShortDistribution.getFeatureAmp80with20000ms()); //持续时间10000ms-20000ms
|
||||
entity7080.setDuration60000(eventDipShortDistribution.getFeatureAmp80with60000ms()); //持续时间20000ms-60000ms
|
||||
list.add(entity7080);
|
||||
|
||||
//特征幅值[60,70)
|
||||
EventDipShortDistributionTableVO entity6070 = new EventDipShortDistributionTableVO();
|
||||
entity6070.setFeatureAmplitude("[60,70)");
|
||||
entity6070.setDuration100(eventDipShortDistribution.getFeatureAmp70with100ms()); //持续时间10ms-100ms
|
||||
entity6070.setDuration250(eventDipShortDistribution.getFeatureAmp70with250ms()); //持续时间100ms-250ms
|
||||
entity6070.setDuration500(eventDipShortDistribution.getFeatureAmp70with500ms()); //持续时间250ms-500ms
|
||||
entity6070.setDuration1000(eventDipShortDistribution.getFeatureAmp70with1000ms()); //持续时间500ms-1000ms
|
||||
entity6070.setDuration3000(eventDipShortDistribution.getFeatureAmp70with3000ms()); //持续时间1000ms-3000ms
|
||||
entity6070.setDuration10000(eventDipShortDistribution.getFeatureAmp70with10000ms()); //持续时间3000ms-10000ms
|
||||
entity6070.setDuration20000(eventDipShortDistribution.getFeatureAmp70with20000ms()); //持续时间10000ms-20000ms
|
||||
entity6070.setDuration60000(eventDipShortDistribution.getFeatureAmp70with60000ms()); //持续时间20000ms-60000ms
|
||||
list.add(entity6070);
|
||||
|
||||
//特征幅值[50,60)
|
||||
EventDipShortDistributionTableVO entity5060 = new EventDipShortDistributionTableVO();
|
||||
entity5060.setFeatureAmplitude("[50,60)");
|
||||
entity5060.setDuration100(eventDipShortDistribution.getFeatureAmp60with100ms()); //持续时间10ms-100ms
|
||||
entity5060.setDuration250(eventDipShortDistribution.getFeatureAmp60with250ms()); //持续时间100ms-250ms
|
||||
entity5060.setDuration500(eventDipShortDistribution.getFeatureAmp60with500ms()); //持续时间250ms-500ms
|
||||
entity5060.setDuration1000(eventDipShortDistribution.getFeatureAmp60with1000ms()); //持续时间500ms-1000ms
|
||||
entity5060.setDuration3000(eventDipShortDistribution.getFeatureAmp60with3000ms()); //持续时间1000ms-3000ms
|
||||
entity5060.setDuration10000(eventDipShortDistribution.getFeatureAmp60with10000ms()); //持续时间3000ms-10000ms
|
||||
entity5060.setDuration20000(eventDipShortDistribution.getFeatureAmp60with20000ms()); //持续时间10000ms-20000ms
|
||||
entity5060.setDuration60000(eventDipShortDistribution.getFeatureAmp60with60000ms()); //持续时间20000ms-60000ms
|
||||
list.add(entity5060);
|
||||
|
||||
//特征幅值[40,50)
|
||||
EventDipShortDistributionTableVO entity4050 = new EventDipShortDistributionTableVO();
|
||||
entity4050.setFeatureAmplitude("[40,50)");
|
||||
entity4050.setDuration100(eventDipShortDistribution.getFeatureAmp50with100ms()); //持续时间10ms-100ms
|
||||
entity4050.setDuration250(eventDipShortDistribution.getFeatureAmp50with250ms()); //持续时间100ms-250ms
|
||||
entity4050.setDuration500(eventDipShortDistribution.getFeatureAmp50with500ms()); //持续时间250ms-500ms
|
||||
entity4050.setDuration1000(eventDipShortDistribution.getFeatureAmp50with1000ms()); //持续时间500ms-1000ms
|
||||
entity4050.setDuration3000(eventDipShortDistribution.getFeatureAmp50with3000ms()); //持续时间1000ms-3000ms
|
||||
entity4050.setDuration10000(eventDipShortDistribution.getFeatureAmp50with10000ms()); //持续时间3000ms-10000ms
|
||||
entity4050.setDuration20000(eventDipShortDistribution.getFeatureAmp50with20000ms()); //持续时间10000ms-20000ms
|
||||
entity4050.setDuration60000(eventDipShortDistribution.getFeatureAmp50with60000ms()); //持续时间20000ms-60000ms
|
||||
list.add(entity4050);
|
||||
|
||||
//特征幅值[30,40)
|
||||
EventDipShortDistributionTableVO entity3040 = new EventDipShortDistributionTableVO();
|
||||
entity3040.setFeatureAmplitude("[30,40)");
|
||||
entity3040.setDuration100(eventDipShortDistribution.getFeatureAmp40with100ms()); //持续时间10ms-100ms
|
||||
entity3040.setDuration250(eventDipShortDistribution.getFeatureAmp40with250ms()); //持续时间100ms-250ms
|
||||
entity3040.setDuration500(eventDipShortDistribution.getFeatureAmp40with500ms()); //持续时间250ms-500ms
|
||||
entity3040.setDuration1000(eventDipShortDistribution.getFeatureAmp40with1000ms()); //持续时间500ms-1000ms
|
||||
entity3040.setDuration3000(eventDipShortDistribution.getFeatureAmp40with3000ms()); //持续时间1000ms-3000ms
|
||||
entity3040.setDuration10000(eventDipShortDistribution.getFeatureAmp40with10000ms()); //持续时间3000ms-10000ms
|
||||
entity3040.setDuration20000(eventDipShortDistribution.getFeatureAmp40with20000ms()); //持续时间10000ms-20000ms
|
||||
entity3040.setDuration60000(eventDipShortDistribution.getFeatureAmp40with60000ms()); //持续时间20000ms-60000ms
|
||||
list.add(entity3040);
|
||||
|
||||
//特征幅值[20,30)
|
||||
EventDipShortDistributionTableVO entity2030 = new EventDipShortDistributionTableVO();
|
||||
entity2030.setFeatureAmplitude("[20,30)");
|
||||
entity2030.setDuration100(eventDipShortDistribution.getFeatureAmp30with100ms()); //持续时间10ms-100ms
|
||||
entity2030.setDuration250(eventDipShortDistribution.getFeatureAmp30with250ms()); //持续时间100ms-250ms
|
||||
entity2030.setDuration500(eventDipShortDistribution.getFeatureAmp30with500ms()); //持续时间250ms-500ms
|
||||
entity2030.setDuration1000(eventDipShortDistribution.getFeatureAmp30with1000ms()); //持续时间500ms-1000ms
|
||||
entity2030.setDuration3000(eventDipShortDistribution.getFeatureAmp30with3000ms()); //持续时间1000ms-3000ms
|
||||
entity2030.setDuration10000(eventDipShortDistribution.getFeatureAmp30with10000ms()); //持续时间3000ms-10000ms
|
||||
entity2030.setDuration20000(eventDipShortDistribution.getFeatureAmp30with20000ms()); //持续时间10000ms-20000ms
|
||||
entity2030.setDuration60000(eventDipShortDistribution.getFeatureAmp30with60000ms()); //持续时间20000ms-60000ms
|
||||
list.add(entity2030);
|
||||
|
||||
//特征幅值[10,20)
|
||||
EventDipShortDistributionTableVO entity1020 = new EventDipShortDistributionTableVO();
|
||||
entity1020.setFeatureAmplitude("[10,20)");
|
||||
entity1020.setDuration100(eventDipShortDistribution.getFeatureAmp20with100ms()); //持续时间10ms-100ms
|
||||
entity1020.setDuration250(eventDipShortDistribution.getFeatureAmp20with250ms()); //持续时间100ms-250ms
|
||||
entity1020.setDuration500(eventDipShortDistribution.getFeatureAmp20with500ms()); //持续时间250ms-500ms
|
||||
entity1020.setDuration1000(eventDipShortDistribution.getFeatureAmp20with1000ms()); //持续时间500ms-1000ms
|
||||
entity1020.setDuration3000(eventDipShortDistribution.getFeatureAmp20with3000ms()); //持续时间1000ms-3000ms
|
||||
entity1020.setDuration10000(eventDipShortDistribution.getFeatureAmp20with10000ms()); //持续时间3000ms-10000ms
|
||||
entity1020.setDuration20000(eventDipShortDistribution.getFeatureAmp20with20000ms()); //持续时间10000ms-20000ms
|
||||
entity1020.setDuration60000(eventDipShortDistribution.getFeatureAmp20with60000ms()); //持续时间20000ms-60000ms
|
||||
list.add(entity1020);
|
||||
|
||||
//特征幅值[0,10)
|
||||
EventDipShortDistributionTableVO entity10 = new EventDipShortDistributionTableVO();
|
||||
entity10.setFeatureAmplitude("[0,10)");
|
||||
entity10.setDuration100(eventDipShortDistribution.getFeatureAmp10with100ms()); //持续时间10ms-100ms
|
||||
entity10.setDuration250(eventDipShortDistribution.getFeatureAmp10with250ms()); //持续时间100ms-250ms
|
||||
entity10.setDuration500(eventDipShortDistribution.getFeatureAmp10with500ms()); //持续时间250ms-500ms
|
||||
entity10.setDuration1000(eventDipShortDistribution.getFeatureAmp10with1000ms()); //持续时间500ms-1000ms
|
||||
entity10.setDuration3000(eventDipShortDistribution.getFeatureAmp10with3000ms()); //持续时间1000ms-3000ms
|
||||
entity10.setDuration10000(eventDipShortDistribution.getFeatureAmp10with10000ms()); //持续时间3000ms-10000ms
|
||||
entity10.setDuration20000(eventDipShortDistribution.getFeatureAmp10with20000ms()); //持续时间10000ms-20000ms
|
||||
entity10.setDuration60000(eventDipShortDistribution.getFeatureAmp10with60000ms()); //持续时间20000ms-60000ms
|
||||
list.add(entity10);
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
* 暂态指标监测点电压暂升分布情况
|
||||
* @author jianghaifei
|
||||
* @date 2022-10-29 14:08
|
||||
* @param eventMonitorReportParam
|
||||
* @return com.njcn.event.pojo.vo.EventRiseDistributionVO
|
||||
*/
|
||||
@Override
|
||||
public List<EventRiseDistributionTableVO> getEventRiseDistributionByCond(EventMonitorReportParam eventMonitorReportParam) {
|
||||
//提取参数
|
||||
// String monitorName = eventMonitorReportParam.getMonitorName(); //监测点名称
|
||||
// String id = eventMonitorReportParam.getId(); //单位id
|
||||
String startTime = eventMonitorReportParam.getStartTime(); //开始时间
|
||||
String endTime = eventMonitorReportParam.getEndTime(); //结束时间
|
||||
Integer type = eventMonitorReportParam.getType(); //时间类型(日/月)
|
||||
|
||||
/****** 获取监测点信息(version1.0) ******/
|
||||
// //获取所有子部门信息
|
||||
// List<DeptDTO> deptDTOList = deptFeignClient.getDeptDescendantIndexes(id, WebUtil.filterDeptType()).getData();
|
||||
// if (CollUtil.isEmpty(deptDTOList)) {
|
||||
// throw new BusinessException(CommonResponseEnum.NO_DATA, "部门不存在");
|
||||
// }
|
||||
// //单位id集合
|
||||
// List<String> orgNoList = deptDTOList.stream().map(DeptDTO::getId).collect(Collectors.toList());
|
||||
// //查询监测点信息
|
||||
// PmsMonitorParam pmsMonitorParam = new PmsMonitorParam();
|
||||
// pmsMonitorParam.setMonitorName(monitorName); //监测点名称
|
||||
// pmsMonitorParam.setOrgIds(orgNoList); //单位ids
|
||||
// List<PmsMonitorDTO> monitorList = monitorClient.getMonitorInfoListByCond(pmsMonitorParam).getData(); //监测点信息
|
||||
|
||||
//查询监测点信息(version2.0)
|
||||
List<PmsMonitorDTO> monitorList = this.getMonitorList(eventMonitorReportParam);
|
||||
List<String> monitorIdList = monitorList.stream().map(PmsMonitorDTO::getId).collect(Collectors.toList()); //监测点id集合
|
||||
|
||||
//获取暂态指标的字典
|
||||
List<DictData> eventStatisList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
|
||||
//将暂态指标信息转成map,key:code value:实体
|
||||
Map<String, DictData> eventStatisMapByCode = eventStatisList.stream().collect(Collectors.toMap(DictData::getCode, data -> data));
|
||||
//暂升分布情况
|
||||
Map<String, Object> riseCondMap = new HashMap<>();
|
||||
riseCondMap.put("monitorIdList", monitorIdList);
|
||||
riseCondMap.put("startTime", startTime);
|
||||
riseCondMap.put("endTime", endTime);
|
||||
riseCondMap.put("eventTypeList", Collections.singletonList(eventStatisMapByCode.get(DicDataEnum.VOLTAGE_RISE.getCode()).getId()));
|
||||
riseCondMap.put("dateType", type);
|
||||
EventRiseDistributionVO eventRiseDistribution = eventDistributionStatisticsMapper.getEventRiseDistributionByCond(riseCondMap);
|
||||
//设置返回数据
|
||||
List<EventRiseDistributionTableVO> list = new ArrayList<>();
|
||||
//特征幅值U1≥120
|
||||
EventRiseDistributionTableVO entity120 = new EventRiseDistributionTableVO();
|
||||
entity120.setFeatureAmplitude("≥120");
|
||||
entity120.setDuration500(eventRiseDistribution.getFeatureAmp120with500ms()); //持续时间100ms-500ms
|
||||
entity120.setDuration5000(eventRiseDistribution.getFeatureAmp120with5000ms()); //持续时间500ms-5000ms
|
||||
entity120.setDuration60000(eventRiseDistribution.getFeatureAmp120with60000ms()); //持续时间5000ms-60000ms
|
||||
list.add(entity120);
|
||||
|
||||
//特征幅值-120-110
|
||||
EventRiseDistributionTableVO entity110 = new EventRiseDistributionTableVO();
|
||||
entity110.setFeatureAmplitude("-120,110");
|
||||
entity110.setDuration500(eventRiseDistribution.getFeatureAmp110with500ms()); //持续时间100ms-500ms
|
||||
entity110.setDuration5000(eventRiseDistribution.getFeatureAmp110with5000ms()); //持续时间500ms-5000ms
|
||||
entity110.setDuration60000(eventRiseDistribution.getFeatureAmp110with60000ms()); //持续时间5000ms-60000ms
|
||||
list.add(entity110);
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取单位(及子孙单位)下的监测点信息(抽取的公共方法)
|
||||
* @author jianghaifei
|
||||
* @date 2022-10-29 17:37
|
||||
* @param eventMonitorReportParam
|
||||
* @return java.util.List<com.njcn.device.pms.pojo.dto.PmsMonitorDTO>
|
||||
*/
|
||||
private List<PmsMonitorDTO> getMonitorList(EventMonitorReportParam eventMonitorReportParam) {
|
||||
//提取参数
|
||||
String monitorName = eventMonitorReportParam.getMonitorName(); //监测点名称
|
||||
String id = eventMonitorReportParam.getId(); //单位id
|
||||
|
||||
//获取所有子部门信息
|
||||
List<DeptDTO> deptDTOList = deptFeignClient.getDeptDescendantIndexes(id, WebUtil.filterDeptType()).getData();
|
||||
if (CollUtil.isEmpty(deptDTOList)) {
|
||||
throw new BusinessException(CommonResponseEnum.NO_DATA, "部门不存在");
|
||||
}
|
||||
//单位code集合
|
||||
List<String> orgCodeList = deptDTOList.stream().map(DeptDTO::getCode).collect(Collectors.toList());
|
||||
//查询监测点信息
|
||||
PmsMonitorParam pmsMonitorParam = new PmsMonitorParam();
|
||||
pmsMonitorParam.setMonitorName(monitorName); //监测点名称
|
||||
pmsMonitorParam.setOrgIds(orgCodeList); //单位codes
|
||||
List<PmsMonitorDTO> monitorList = monitorClient.getMonitorInfoListByCond(pmsMonitorParam).getData(); //监测点信息
|
||||
return monitorList;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,368 @@
|
||||
package com.njcn.event.common.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<amount;i++){
|
||||
run.addCarriageReturn();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加段落文本
|
||||
* @param run 文本执行对象
|
||||
* @param fontFamily 字体类型
|
||||
* @param fontSize 字体大小
|
||||
* @param backgroundColor 字体颜色
|
||||
* @param bold 是否加粗
|
||||
*/
|
||||
public static void addParagraph(XWPFRun run,String fontFamily,Integer fontSize,String backgroundColor,String message,boolean bold){
|
||||
run.setText(message);
|
||||
run.setColor(backgroundColor);
|
||||
run.setFontSize(fontSize);
|
||||
run.setFontFamily(fontFamily);
|
||||
run.setBold(bold);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 增加自定义标题样式。这里用的是stackoverflow的源码
|
||||
*
|
||||
* @param docxDocument 目标文档
|
||||
* @param strStyleId 样式名称
|
||||
* @param headingLevel 样式级别
|
||||
*/
|
||||
public static void addCustomHeadingStyle(XWPFDocument docxDocument, String strStyleId, int headingLevel) {
|
||||
|
||||
CTStyle ctStyle = CTStyle.Factory.newInstance();
|
||||
ctStyle.setStyleId(strStyleId);
|
||||
|
||||
CTString styleName = CTString.Factory.newInstance();
|
||||
styleName.setVal(strStyleId);
|
||||
ctStyle.setName(styleName);
|
||||
|
||||
CTDecimalNumber indentNumber = CTDecimalNumber.Factory.newInstance();
|
||||
indentNumber.setVal(BigInteger.valueOf(headingLevel));
|
||||
|
||||
// lower number > 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<data.length;i++){
|
||||
XWPFRun run =paragraph.createRun();
|
||||
run.setFontFamily("宋体");
|
||||
run.setText(data[i]);
|
||||
row.getCell(i).setParagraph(paragraph);
|
||||
paragraph.removeRun(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 添加表头标题一行数据
|
||||
* @param paragraph 段落对象
|
||||
* @param row 行对象
|
||||
* @param data 不定长度的数据
|
||||
*/
|
||||
public static void setExcelHeadContent(XWPFParagraph paragraph, XWPFTableRow row,String... data){
|
||||
XWPFRun run= paragraph.createRun();
|
||||
run.setFontFamily("宋体");
|
||||
run.setBold(true);
|
||||
run.setText(data[0]);
|
||||
row.getCell(0).setParagraph(paragraph);
|
||||
paragraph.removeRun(0);
|
||||
for(int i=1;i<data.length;i++){
|
||||
XWPFRun run1 =paragraph.createRun();
|
||||
run1.setFontFamily("宋体");
|
||||
run1.setBold(true);
|
||||
run1.setText(data[i]);
|
||||
row.addNewTableCell().setParagraph(paragraph);
|
||||
paragraph.removeRun(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前的日期
|
||||
* @return
|
||||
*/
|
||||
public static String getRightNow(){
|
||||
Calendar rightNow = Calendar.getInstance();
|
||||
Integer year = rightNow.get(Calendar.YEAR);
|
||||
Integer month = rightNow.get(Calendar.MONTH)+1;
|
||||
Integer day = rightNow.get(rightNow.DAY_OF_MONTH);
|
||||
return year+"年"+month+"月"+day+"日";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user