暂降监测点报告抽取公共方法
This commit is contained in:
@@ -16,7 +16,7 @@ import com.njcn.event.pojo.param.EventCountParam;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.GeneralVO;
|
||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||
import com.njcn.event.common.service.EventDetailService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.event.pojo.param.EventMonitorReportParam;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
import com.njcn.event.service.majornetwork.EventMonitorReportService;
|
||||
import com.njcn.event.common.service.EventMonitorReportService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -51,7 +51,7 @@ public class EventMonitorReportController extends BaseController {
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
*
|
||||
* @author jianghaifei
|
||||
* @date 2022-10-29 14:08
|
||||
* @param eventMonitorReportParam
|
||||
@@ -67,7 +67,7 @@ public class EventMonitorReportController extends BaseController {
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
*
|
||||
* @author jianghaifei
|
||||
* @date 2022-10-29 14:08
|
||||
* @param eventMonitorReportParam
|
||||
|
||||
@@ -2,15 +2,13 @@ package com.njcn.event.controller.majornetwork;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.event.pojo.param.*;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
import com.njcn.event.service.majornetwork.EventAnalysisService;
|
||||
import com.njcn.event.common.service.EventAnalysisService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -18,7 +16,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,18 +1,29 @@
|
||||
package com.njcn.event.controller.majornetwork;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.device.pms.api.MonitorClient;
|
||||
import com.njcn.device.pms.pojo.po.Monitor;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
||||
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
|
||||
import com.njcn.event.common.service.CommMonitorEventReportService;
|
||||
import com.njcn.event.enums.EventResponseEnum;
|
||||
import com.njcn.event.pojo.param.*;
|
||||
import com.njcn.event.pojo.vo.DetailVO;
|
||||
import com.njcn.event.pojo.vo.GeneralVO;
|
||||
import com.njcn.event.pojo.vo.ReasonsVO;
|
||||
import com.njcn.event.pojo.vo.WaveTypeVO;
|
||||
import com.njcn.event.service.majornetwork.ReportService;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import freemarker.template.TemplateException;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -27,6 +38,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -44,6 +56,14 @@ public class ReportController extends BaseController {
|
||||
|
||||
private final ReportService reportService;
|
||||
|
||||
private final CommMonitorEventReportService commMonitorEventReportService;
|
||||
|
||||
private final LineFeignClient lineFeignClient;
|
||||
|
||||
private final MonitorClient monitorClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getGeneralSituation")
|
||||
@ApiOperation("暂态总体概况(区域)")
|
||||
@@ -149,7 +169,31 @@ public class ReportController extends BaseController {
|
||||
@ApiOperation("监测点报告导出")
|
||||
@ApiImplicitParam(name = "exportParam", value = "监测点报告导出参数", required = true)
|
||||
public void getLineExport(@RequestBody @Validated ExportParam exportParam, HttpServletResponse response) throws IOException, InvalidFormatException, TemplateException, ParseException {
|
||||
reportService.getLineExport(exportParam, response);
|
||||
|
||||
LineDetailDataCommDTO lineDetailDataCommDTO = new LineDetailDataCommDTO();
|
||||
if(exportParam.getType() == 0) {
|
||||
LineDetailDataVO lineDetailData = lineFeignClient.getLineDetailData(exportParam.getLineId()).getData();
|
||||
if (ObjectUtil.isNull(lineDetailData)) {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL, "查询监测点失败");
|
||||
}
|
||||
BeanUtil.copyProperties(lineDetailData,lineDetailDataCommDTO);
|
||||
}else {
|
||||
HttpResult<List<Monitor>> monitorList = monitorClient.getMonitorList(Arrays.asList(exportParam.getLineId()));
|
||||
if (ObjectUtil.isNull(monitorList)) {
|
||||
throw new BusinessException(EventResponseEnum.NOT_FOUND);
|
||||
}
|
||||
lineDetailDataCommDTO.setLineName(monitorList.getData().get(0).getName());
|
||||
lineDetailDataCommDTO.setScale(dicDataFeignClient.getDicDataById(monitorList.getData().get(0).getVoltageLevel()).getData().getName());
|
||||
lineDetailDataCommDTO.setPt(monitorList.getData().get(0).getPt1() + "/" + monitorList.getData().get(0).getPt2());
|
||||
lineDetailDataCommDTO.setPt(monitorList.getData().get(0).getCt1() + "/" + monitorList.getData().get(0).getCt2());
|
||||
lineDetailDataCommDTO.setDealCapacity(monitorList.getData().get(0).getUserAgreementCapacity());
|
||||
// insertRow(doc, table, centerParagraph, false, "基准容量", monitorList.getData().get(0).getMinShortCircuitCapacity() + "");
|
||||
lineDetailDataCommDTO.setDevCapacity(monitorList.getData().get(0).getPowerSupplyEqCapacity());
|
||||
lineDetailDataCommDTO.setShortCapacity(monitorList.getData().get(0).getMinShortCircuitCapacity());
|
||||
lineDetailDataCommDTO.setPtType(dicDataFeignClient.getDicDataById(monitorList.getData().get(0).getTerminalWiringMethod()).getData().getName());
|
||||
}
|
||||
|
||||
commMonitorEventReportService.getLineExport(exportParam, lineDetailDataCommDTO,response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
package com.njcn.event.mapper.majornetwork;
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package com.njcn.event.mapper.majornetwork;
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.event.mapper.majornetwork.EventDistributionStatisticsMapper">
|
||||
<mapper namespace="com.njcn.event.common.mapper.EventDistributionStatisticsMapper">
|
||||
|
||||
<!--获取暂态指标分布统计-->
|
||||
<select id="getEventDistributionStatistics"
|
||||
@@ -469,4 +469,4 @@
|
||||
)
|
||||
r
|
||||
</select>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.event.mapper.majornetwork.RmpEventDetailMapper">
|
||||
|
||||
<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>
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.njcn.event.service.majornetwork;
|
||||
|
||||
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) throws ParseException;
|
||||
|
||||
/**
|
||||
* 获取详细数据对象
|
||||
* @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;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.njcn.event.service.majornetwork;
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.njcn.event.service.majornetwork;
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,78 +1,78 @@
|
||||
package com.njcn.event.service.majornetwork;
|
||||
|
||||
import com.njcn.event.pojo.param.StatisticsParam;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <监测点报表>
|
||||
*
|
||||
* @author wr
|
||||
* @createTime: 2023-02-10
|
||||
*/
|
||||
public interface EventReportService {
|
||||
|
||||
/**
|
||||
*获取Disdip表格(监测点报表专用)
|
||||
* @param info influxdb查询结果(pqs_eventdetail表)
|
||||
* @return
|
||||
*/
|
||||
List<DISDIPVO> eventDisdip(List<EventDetail> info);
|
||||
|
||||
/**
|
||||
* 获取IEC411数据
|
||||
* @param info influxdb查询结果(pqs_eventdetail表)
|
||||
* @return
|
||||
*/
|
||||
List<IEC411VO> IEC411(List<EventDetail> info);
|
||||
|
||||
/**
|
||||
* 获取IEC28数据
|
||||
* @param info influxdb查询结果(pqs_eventdetail表)
|
||||
* @return
|
||||
*/
|
||||
List<IEC28VO> IEC28(List<EventDetail> info);
|
||||
|
||||
/**
|
||||
*暂降幅值概率分布
|
||||
* @param info2 influxdb查询结果(pqs_eventdetail表)
|
||||
* @return
|
||||
*/
|
||||
ProbabilityVO getProbabilityDistribution(List<EventDetail> info2);
|
||||
|
||||
/**
|
||||
* 获取时间列表(月份统计)
|
||||
* @param info influxdb查询结果(pqs_eventdetail表)
|
||||
* @return
|
||||
*/
|
||||
List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam,List<EventDetail> info) throws ParseException;
|
||||
|
||||
/**
|
||||
* 获取点状表格数据2.1
|
||||
* @param info 结果集
|
||||
* @param reasonData 暂降原因
|
||||
* @param typeData 暂降类型
|
||||
* @return
|
||||
*/
|
||||
List<EventDetail> getPlot(List<EventDetail> info, List<DictData> reasonData, List<DictData> typeData);
|
||||
|
||||
/**
|
||||
* 获取详细数据对象
|
||||
* @param info
|
||||
* @param reasonData
|
||||
* @param typeData
|
||||
* @return
|
||||
*/
|
||||
StatisticVO getStatistic(List<EventDetail> info,List<DictData> reasonData,List<DictData>typeData);
|
||||
|
||||
/**
|
||||
* 获取密度点图
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
Integer[][] getCoords(List<EventDetail> info);
|
||||
}
|
||||
//package com.njcn.event.service.majornetwork;
|
||||
//
|
||||
//import com.njcn.event.pojo.param.StatisticsParam;
|
||||
//import com.njcn.event.pojo.po.EventDetail;
|
||||
//import com.njcn.event.pojo.vo.*;
|
||||
//import com.njcn.system.pojo.po.DictData;
|
||||
//
|
||||
//import java.text.ParseException;
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * <监测点报表>
|
||||
// *
|
||||
// * @author wr
|
||||
// * @createTime: 2023-02-10
|
||||
// */
|
||||
//public interface EventReportService {
|
||||
//
|
||||
// /**
|
||||
// *获取Disdip表格(监测点报表专用)
|
||||
// * @param info influxdb查询结果(pqs_eventdetail表)
|
||||
// * @return
|
||||
// */
|
||||
// List<DISDIPVO> eventDisdip(List<EventDetail> info);
|
||||
//
|
||||
// /**
|
||||
// * 获取IEC411数据
|
||||
// * @param info influxdb查询结果(pqs_eventdetail表)
|
||||
// * @return
|
||||
// */
|
||||
// List<IEC411VO> IEC411(List<EventDetail> info);
|
||||
//
|
||||
// /**
|
||||
// * 获取IEC28数据
|
||||
// * @param info influxdb查询结果(pqs_eventdetail表)
|
||||
// * @return
|
||||
// */
|
||||
// List<IEC28VO> IEC28(List<EventDetail> info);
|
||||
//
|
||||
// /**
|
||||
// *暂降幅值概率分布
|
||||
// * @param info2 influxdb查询结果(pqs_eventdetail表)
|
||||
// * @return
|
||||
// */
|
||||
// ProbabilityVO getProbabilityDistribution(List<EventDetail> info2);
|
||||
//
|
||||
// /**
|
||||
// * 获取时间列表(月份统计)
|
||||
// * @param info influxdb查询结果(pqs_eventdetail表)
|
||||
// * @return
|
||||
// */
|
||||
// List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam,List<EventDetail> info) throws ParseException;
|
||||
//
|
||||
// /**
|
||||
// * 获取点状表格数据2.1
|
||||
// * @param info 结果集
|
||||
// * @param reasonData 暂降原因
|
||||
// * @param typeData 暂降类型
|
||||
// * @return
|
||||
// */
|
||||
// List<EventDetail> getPlot(List<EventDetail> info, List<DictData> reasonData, List<DictData> typeData);
|
||||
//
|
||||
// /**
|
||||
// * 获取详细数据对象
|
||||
// * @param info
|
||||
// * @param reasonData
|
||||
// * @param typeData
|
||||
// * @return
|
||||
// */
|
||||
// StatisticVO getStatistic(List<EventDetail> info,List<DictData> reasonData,List<DictData>typeData);
|
||||
//
|
||||
// /**
|
||||
// * 获取密度点图
|
||||
// * @param info
|
||||
// * @return
|
||||
// */
|
||||
// Integer[][] getCoords(List<EventDetail> info);
|
||||
//}
|
||||
|
||||
@@ -20,19 +20,17 @@ import com.njcn.event.pojo.vo.AreaAnalysisVO;
|
||||
import com.njcn.event.pojo.vo.VoltageToleranceCurveVO;
|
||||
import com.njcn.event.pojo.vo.VoltageToleranceCurveVO.VoltageToleranceCurveDataList;
|
||||
import com.njcn.event.service.majornetwork.AreaAnalysisService;
|
||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||
import com.njcn.event.common.service.EventDetailService;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.njcn.event.pojo.po.EventDetailNew;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.AreaSubLineVO;
|
||||
import com.njcn.event.service.majornetwork.AreaInfoService;
|
||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||
import com.njcn.event.common.service.EventDetailService;
|
||||
import com.njcn.harmonic.api.PollutionSubstationClient;
|
||||
import com.njcn.harmonic.pojo.excel.pollution.UserLinePollution;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.njcn.event.pojo.vo.*;
|
||||
import com.njcn.event.pojo.vo.TerminalRunningStatisticsVO.TerminalRunningInfoVO;
|
||||
import com.njcn.event.pojo.vo.TerminalRunningStatisticsVO.TerminalRunningVO;
|
||||
import com.njcn.event.service.majornetwork.AreaLineService;
|
||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||
import com.njcn.event.common.service.EventDetailService;
|
||||
import com.njcn.event.service.majornetwork.LargeScreenService;
|
||||
import com.njcn.harmonic.pojo.dto.ComAssessDTO;
|
||||
import com.njcn.harmonic.pojo.po.PQSComAssesPO;
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.njcn.event.pojo.vo.AreaStatisticalVO.VoltageStatisticsVO;
|
||||
import com.njcn.event.pojo.vo.MonthCalculationVO;
|
||||
import com.njcn.event.pojo.vo.VoltageLevelCalculationVO;
|
||||
import com.njcn.event.service.majornetwork.AreaStatisticalService;
|
||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||
import com.njcn.event.common.service.EventDetailService;
|
||||
import com.njcn.event.pojo.vo.NodeVO;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,339 +0,0 @@
|
||||
package com.njcn.event.service.majornetwork.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.pojo.vo.SendEventVO;
|
||||
import com.njcn.event.utils.EventUtil;
|
||||
import com.njcn.event.mapper.majornetwork.EventDetailMapper;
|
||||
import com.njcn.event.pojo.dto.EventDeatilDTO;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||
import com.njcn.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<EventDetailMapper, 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import com.njcn.common.pojo.param.StatisticsBizBaseParam;
|
||||
import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient;
|
||||
import com.njcn.device.pms.pojo.dto.PmsGeneralDeviceDTO;
|
||||
import com.njcn.device.pms.pojo.param.PmsDeviceInfoParam;
|
||||
import com.njcn.event.mapper.majornetwork.EventDistributionStatisticsMapper;
|
||||
import com.njcn.event.common.mapper.EventDistributionStatisticsMapper;
|
||||
import com.njcn.event.pojo.po.EventDistributionStatisticsPO;
|
||||
import com.njcn.event.pojo.po.EventDurationLineChartPO;
|
||||
import com.njcn.event.pojo.po.EventFeatureAmplitudeLineChartPO;
|
||||
@@ -21,8 +21,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,427 +0,0 @@
|
||||
package com.njcn.event.service.majornetwork.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.mapper.majornetwork.EventDistributionStatisticsMapper;
|
||||
import com.njcn.event.mapper.majornetwork.RmpEventDetailMapper;
|
||||
import com.njcn.event.pojo.param.EventMonitorReportParam;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
import com.njcn.event.service.majornetwork.EventMonitorReportService;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
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
@@ -35,6 +35,7 @@ import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.echarts.pojo.constant.PicCommonData;
|
||||
import com.njcn.echarts.util.DrawPicUtil;
|
||||
import com.njcn.event.common.service.EventReportService;
|
||||
import com.njcn.event.enums.EventResponseEnum;
|
||||
import com.njcn.event.mapper.majornetwork.EventDetailMapper;
|
||||
import com.njcn.event.mapper.majornetwork.ReportMapper;
|
||||
@@ -44,11 +45,10 @@ import com.njcn.event.pojo.po.EventDetailNew;
|
||||
import com.njcn.event.pojo.po.Eventass;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
import com.njcn.event.service.majornetwork.EventAnalysisService;
|
||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||
import com.njcn.event.service.majornetwork.EventReportService;
|
||||
import com.njcn.event.common.service.EventAnalysisService;
|
||||
import com.njcn.event.common.service.EventDetailService;
|
||||
import com.njcn.event.service.majornetwork.ReportService;
|
||||
import com.njcn.event.utils.WordUtils;
|
||||
import com.njcn.event.common.utils.WordUtils;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.poi.util.PoiUtil;
|
||||
@@ -89,10 +89,8 @@ import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.util.Units;
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import sun.misc.BASE64Decoder;
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ import com.njcn.device.pq.pojo.vo.GridDiagramVO;
|
||||
import com.njcn.device.pq.pojo.vo.LineDetailVO;
|
||||
import com.njcn.event.enums.EventResponseEnum;
|
||||
import com.njcn.event.mapper.majornetwork.RMpEventDetailMMapper;
|
||||
import com.njcn.event.mapper.majornetwork.RmpEventDetailMapper;
|
||||
import com.njcn.event.common.mapper.RmpEventDetailMapper;
|
||||
import com.njcn.event.pojo.dto.EventCount;
|
||||
import com.njcn.event.pojo.param.EventBaseParam;
|
||||
import com.njcn.event.pojo.param.UniversalFrontEndParam;
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.njcn.event.file.component.WaveFileComponent;
|
||||
import com.njcn.event.file.pojo.dto.WaveDataDTO;
|
||||
import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
|
||||
import com.njcn.event.mapper.distribution.PwRmpEventDetailMapper;
|
||||
import com.njcn.event.mapper.majornetwork.RmpEventDetailMapper;
|
||||
import com.njcn.event.common.mapper.RmpEventDetailMapper;
|
||||
import com.njcn.event.mapper.majornetwork.TransientMapper;
|
||||
import com.njcn.event.pojo.param.EventVerifyReasonParam;
|
||||
import com.njcn.event.pojo.param.TransientParam;
|
||||
@@ -33,7 +33,7 @@ import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.po.EventDetailNew;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.TransientVO;
|
||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||
import com.njcn.event.common.service.EventDetailService;
|
||||
import com.njcn.event.service.majornetwork.TransientService;
|
||||
import com.njcn.minioss.config.MinIossProperties;
|
||||
import com.njcn.minioss.util.MinIoUtils;
|
||||
@@ -56,7 +56,6 @@ import java.text.DecimalFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.njcn.event.pojo.param.VoltageRideThroughQueryParam;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.vo.EventNewStationVo;
|
||||
import com.njcn.event.pojo.vo.VoltageRideThroughVo;
|
||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||
import com.njcn.event.common.service.EventDetailService;
|
||||
import com.njcn.event.service.majornetwork.SpThroughService;
|
||||
import com.njcn.event.service.majornetwork.VoltageRideThroughEventService;
|
||||
import com.njcn.event.pojo.param.SpThroughParam;
|
||||
|
||||
@@ -1,368 +0,0 @@
|
||||
package com.njcn.event.utils;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy;
|
||||
import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
|
||||
import org.apache.poi.xwpf.usermodel.TextAlignment;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFStyle;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFStyles;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFTable;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFTableRow;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDecimalNumber;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyle;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STStyleType;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth;
|
||||
|
||||
public class WordUtils {
|
||||
|
||||
|
||||
public static void main(String[] args)throws Exception {
|
||||
|
||||
// 空白文档
|
||||
XWPFDocument document= new XWPFDocument();
|
||||
//把文档写进本地系统
|
||||
FileOutputStream out = new FileOutputStream(new File("create_table.docx"));
|
||||
//设定标题格式
|
||||
setHeadingStyle(document);
|
||||
//添加标题
|
||||
XWPFParagraph titleParagraph = document.createParagraph();
|
||||
setParagraphStyle(titleParagraph);
|
||||
addLine(titleParagraph,11);
|
||||
//设置段落居中
|
||||
titleParagraph.setAlignment(ParagraphAlignment.CENTER);
|
||||
XWPFRun titleParagraphRun = titleParagraph.createRun();
|
||||
addParagraph(titleParagraphRun,"宋体",15,"000000","四川省供电公司",true);
|
||||
|
||||
addLine(titleParagraph,3);
|
||||
XWPFRun titleParagraphBigRun = titleParagraph.createRun();
|
||||
addParagraph(titleParagraphBigRun,"宋体",36,"000000","电压暂降事件分析报告",true);
|
||||
addLine(titleParagraph,19);
|
||||
|
||||
XWPFRun titleParagraphDateRun = titleParagraph.createRun();
|
||||
addParagraph(titleParagraphDateRun,"宋体",14,"000000","日期: 2018年1月3号",true);
|
||||
titleParagraph.setPageBreak(true);
|
||||
|
||||
|
||||
//段落
|
||||
XWPFParagraph statisticsParagraph = document.createParagraph();
|
||||
setParagraphStyle(statisticsParagraph);
|
||||
//段前分页
|
||||
statisticsParagraph.setPageBreak(true);
|
||||
statisticsParagraph.setAlignment(ParagraphAlignment.CENTER);
|
||||
XWPFRun statisticsRun = statisticsParagraph.createRun();
|
||||
addParagraph(statisticsRun,"宋体",24,"000000","电压暂降事件分析报告",false);
|
||||
|
||||
|
||||
|
||||
XWPFParagraph introductionParagraph= document.createParagraph();
|
||||
setParagraphStyle(introductionParagraph);
|
||||
introductionParagraph.setStyle("标题 1");
|
||||
introductionParagraph.setAlignment(ParagraphAlignment.LEFT);
|
||||
XWPFRun introductionRun = introductionParagraph.createRun();
|
||||
addParagraph(introductionRun,"宋体",15,"000000","1. 引言",true);
|
||||
|
||||
XWPFParagraph introductionContentParagraph = document.createParagraph();
|
||||
// 首行缩进---段落
|
||||
setParagraphStyle(introductionContentParagraph);
|
||||
introductionContentParagraph.setAlignment(ParagraphAlignment.LEFT);
|
||||
introductionContentParagraph.setIndentationFirstLine(200);
|
||||
XWPFRun introductionContentRun=introductionContentParagraph.createRun();
|
||||
addParagraph(introductionContentRun,"宋体",11,"000000","对所选中区间内电压暂降事件进行分析,能够直观清晰查看相应的暂降事件信息。",false);
|
||||
|
||||
XWPFParagraph objectParagraph=document.createParagraph();
|
||||
setParagraphStyle(objectParagraph);
|
||||
objectParagraph.setStyle("标题 1");
|
||||
objectParagraph.setAlignment(ParagraphAlignment.LEFT);
|
||||
XWPFRun objectRun= objectParagraph.createRun();
|
||||
addParagraph(objectRun,"宋体",15,"000000","2. 报告分析对象:",true);
|
||||
|
||||
XWPFParagraph objectContentParagraph = document.createParagraph();
|
||||
setParagraphStyle(objectContentParagraph);
|
||||
objectContentParagraph.setAlignment(ParagraphAlignment.LEFT);
|
||||
objectContentParagraph.setIndentationFirstLine(200);
|
||||
XWPFRun objectContentRun = objectContentParagraph.createRun();
|
||||
addParagraph(objectContentRun,"宋体",11,"000000","成都供电公司—>锦江区变电站—>锦江2号。",false);
|
||||
|
||||
XWPFParagraph timeParagraph = document.createParagraph();
|
||||
timeParagraph.setStyle("标题 1");
|
||||
timeParagraph.setAlignment(ParagraphAlignment.LEFT);
|
||||
setParagraphStyle(timeParagraph);
|
||||
XWPFRun timeRun = timeParagraph.createRun();
|
||||
addParagraph(timeRun,"宋体",15,"000000","3. 报告分析时间:",true);
|
||||
|
||||
XWPFParagraph timeContentParagraph = document.createParagraph();
|
||||
setParagraphStyle(timeContentParagraph);
|
||||
timeContentParagraph.setAlignment(ParagraphAlignment.LEFT);
|
||||
timeContentParagraph.setIndentationFirstLine(200);
|
||||
XWPFRun timeContentRun = timeContentParagraph.createRun();
|
||||
addParagraph(timeContentRun,"宋体",11,"000000","2017年12月21日至2017年12月30日。",false);
|
||||
|
||||
|
||||
XWPFParagraph summaeParagraph = document.createParagraph();
|
||||
setParagraphStyle(summaeParagraph);
|
||||
summaeParagraph.setStyle("标题 1");
|
||||
summaeParagraph.setAlignment(ParagraphAlignment.LEFT);
|
||||
XWPFRun summaeRun = summaeParagraph.createRun();
|
||||
addParagraph(summaeRun,"宋体",15,"000000","4. 汇总信息:",true);
|
||||
|
||||
|
||||
XWPFParagraph summaeTableParagraph = document.createParagraph();
|
||||
setParagraphStyle(summaeTableParagraph);
|
||||
summaeTableParagraph.setStyle("标题 2");
|
||||
summaeTableParagraph.setAlignment(ParagraphAlignment.LEFT);
|
||||
summaeTableParagraph.setIndentationFirstLine(200);
|
||||
XWPFRun summaeTableRun = summaeTableParagraph.createRun();
|
||||
addParagraph(summaeTableRun,"宋体",11,"000000","4.1 表格",false);
|
||||
|
||||
|
||||
//工作经历表格
|
||||
XWPFTable summaTable = document.createTable();
|
||||
|
||||
//列宽自动分割
|
||||
CTTblWidth summaTableWidth = summaTable.getCTTbl().addNewTblPr().addNewTblW();
|
||||
summaTableWidth.setType(STTblWidth.DXA);
|
||||
summaTableWidth.setW(BigInteger.valueOf(9072));
|
||||
|
||||
//表格第一行
|
||||
XWPFTableRow summaTableRowOne = summaTable.getRow(0);
|
||||
XWPFParagraph excelParagraph= document.createParagraph();
|
||||
setParagraphStyle(excelParagraph);
|
||||
excelParagraph.setAlignment(ParagraphAlignment.CENTER);
|
||||
excelParagraph.setVerticalAlignment(TextAlignment.CENTER);
|
||||
setExcelHeadContent(excelParagraph,summaTableRowOne,"序号","暂降发生时刻","暂降幅值(%)","持续时间(ms)","暂降类型","暂降原因","严重度");
|
||||
|
||||
//表格第二行
|
||||
XWPFTableRow summaTableRowTwo = summaTable.createRow();
|
||||
setExcelContent(excelParagraph,summaTableRowTwo,"1","2017-11-24 14:26:56.490","9","20","未识别","未明","0.91");
|
||||
|
||||
//表格第三行
|
||||
XWPFTableRow summaTableRowThree = summaTable.createRow();
|
||||
setExcelContent(excelParagraph,summaTableRowThree,"2","2017-11-24 14:25:46.472","15","19","未识别","未明","0.85");
|
||||
|
||||
XWPFParagraph summaePicParagraph = document.createParagraph();
|
||||
summaePicParagraph.setStyle("标题 2");
|
||||
summaePicParagraph.setAlignment(ParagraphAlignment.LEFT);
|
||||
summaePicParagraph.setIndentationFirstLine(200);
|
||||
XWPFRun summaePicRun = summaePicParagraph.createRun();
|
||||
addParagraph(summaePicRun,"宋体",11,"000000","4.2 ITIC曲线",false);
|
||||
|
||||
|
||||
CTSectPr sectPr = document.getDocument().getBody().addNewSectPr();
|
||||
XWPFHeaderFooterPolicy policy = new XWPFHeaderFooterPolicy(document, sectPr);
|
||||
|
||||
//添加页眉
|
||||
CTP ctpHeader = CTP.Factory.newInstance();
|
||||
CTR ctrHeader = ctpHeader.addNewR();
|
||||
CTText ctHeader = ctrHeader.addNewT();
|
||||
String headerText = "Java POI create MS word file.";
|
||||
ctHeader.setStringValue(headerText);
|
||||
XWPFParagraph headerParagraph = new XWPFParagraph(ctpHeader, document);
|
||||
//设置为右对齐
|
||||
headerParagraph.setAlignment(ParagraphAlignment.RIGHT);
|
||||
XWPFParagraph[] parsHeader = new XWPFParagraph[1];
|
||||
parsHeader[0] = headerParagraph;
|
||||
policy.createHeader(XWPFHeaderFooterPolicy.DEFAULT, parsHeader);
|
||||
|
||||
|
||||
//添加页脚
|
||||
CTP ctpFooter = CTP.Factory.newInstance();
|
||||
CTR ctrFooter = ctpFooter.addNewR();
|
||||
CTText ctFooter = ctrFooter.addNewT();
|
||||
String footerText = "http://blog.csdn.net/zhouseawater";
|
||||
ctFooter.setStringValue(footerText);
|
||||
XWPFParagraph footerParagraph = new XWPFParagraph(ctpFooter, document);
|
||||
headerParagraph.setAlignment(ParagraphAlignment.CENTER);
|
||||
XWPFParagraph[] parsFooter = new XWPFParagraph[1];
|
||||
parsFooter[0] = footerParagraph;
|
||||
policy.createFooter(XWPFHeaderFooterPolicy.DEFAULT, parsFooter);
|
||||
|
||||
document.write(out);
|
||||
out.close();
|
||||
|
||||
}
|
||||
|
||||
public static void setParagraphStyle(XWPFParagraph paragraph){
|
||||
paragraph.setSpacingBefore(100);
|
||||
paragraph.setSpacingAfter(100);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回指定格式的段落 居中型
|
||||
* @param document 文档对象
|
||||
*/
|
||||
public static XWPFParagraph getCenterParagraph(XWPFDocument document){
|
||||
XWPFParagraph paragraph = document.createParagraph();
|
||||
setParagraphStyle(paragraph);
|
||||
paragraph.setAlignment(ParagraphAlignment.CENTER);
|
||||
paragraph.setVerticalAlignment(TextAlignment.CENTER);
|
||||
return paragraph;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回指定格式的段落 居左型
|
||||
* @param document 文档对象
|
||||
*/
|
||||
public static XWPFParagraph getLeftParagraph(XWPFDocument document){
|
||||
XWPFParagraph paragraph = document.createParagraph();
|
||||
setParagraphStyle(paragraph);
|
||||
paragraph.setAlignment(ParagraphAlignment.LEFT);
|
||||
return paragraph;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 添加换行符
|
||||
* @param paragraph 指定段落
|
||||
* @param amount 行数
|
||||
* */
|
||||
public static void addLine(XWPFParagraph paragraph,Integer amount){
|
||||
XWPFRun run = paragraph.createRun();
|
||||
run.setFontSize(11);
|
||||
for(int i=0;i<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