2026-03-25提交:查询接口调整,新增eventId

This commit is contained in:
junzhangfm 2026-03-25 23:32:04 +08:00
parent fd06ec8cf7
commit 1f8bca3de2
11 changed files with 49 additions and 21 deletions

View File

@ -60,8 +60,10 @@ public class DnerController {
@GetMapping("/intraday/query")
public Result<HourlyPowerOutageEventChartVO> queryIntradayData(@RequestParam String orgCode,
@RequestParam String startDate,
@RequestParam String endDate) {
return Result.success(dnerHourlyPowerOutageEventService.queryIntradayData(orgCode, startDate, endDate));
@RequestParam String endDate,
@RequestParam String eventId) {
return Result.success(dnerHourlyPowerOutageEventService.queryIntradayData(
orgCode, startDate, endDate, eventId));
}
@ -76,8 +78,10 @@ public class DnerController {
@GetMapping("/kline/query")
public Result<DailyPowerOutageEventVO> queryKlineData(@RequestParam String orgCode,
@RequestParam String startDate,
@RequestParam String endDate) {
return Result.success(dnerDailyPowerOutageEventService.queryKlineData(orgCode, startDate, endDate));
@RequestParam String endDate,
@RequestParam String eventId) {
return Result.success(dnerDailyPowerOutageEventService.queryKlineData(
orgCode, startDate, endDate, eventId));
}
/**

View File

@ -17,5 +17,6 @@ import java.util.List;
public interface DnerDailyPowerOutageEventMapper extends BaseMapper<DnerDailyPowerOutageEvent> {
List<DnerDailyPowerOutageEvent> selectListByConditions(@Param("orgCode") String orgCode,
@Param("startDate") String startDate,
@Param("endDate") String endDate);
@Param("endDate") String endDate,
@Param("eventId") String eventId);
}

View File

@ -19,7 +19,8 @@ import java.util.Map;
public interface DnerHourlyPowerOutageEventMapper extends BaseMapper<DnerHourlyPowerOutageEvent> {
List<DnerHourlyPowerOutageEvent> selectListByConditions(@Param("orgCode") String orgCode,
@Param("startDate") String startDate,
@Param("endDate") String endDate);
@Param("endDate") String endDate,
@Param("eventId") String eventId);
/**
* 批量插入事件记录

View File

@ -16,9 +16,12 @@ public class AreaTreeReq {
* DAILY-日K图
* HOURLY-分时图
*/
@NotBlank(message = "查询类型不能为空")
@NotBlank(message = "queryType can not be empty!")
String queryType;
@NotBlank(message = "eventId can not be empty!")
Long eventId;
// ================= 用于高级筛选的属性 ====================
/**
* 过去XX小时/

View File

@ -1,6 +1,5 @@
package com.southern.power.grid.service;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import com.southern.power.grid.entity.DailyPowerOutageEventVO;
import com.southern.power.grid.entity.DnerDailyPowerOutageEvent;
@ -18,7 +17,8 @@ public interface IDnerDailyPowerOutageEventService extends IService<DnerDailyPow
* @param orgCode 地区编码
* @param startDate 开始时间
* @param endDate 结束时间
* @param eventId 事件ID
* @return 返回结果
*/
DailyPowerOutageEventVO queryKlineData(String orgCode, String startDate, String endDate);
DailyPowerOutageEventVO queryKlineData(String orgCode, String startDate, String endDate, String eventId);
}

View File

@ -17,9 +17,10 @@ public interface IDnerHourlyPowerOutageEventService extends IService<DnerHourlyP
* @param orgCode 地区编码
* @param startDate 开始时间
* @param endDate 结束时间
* @param eventId 事件ID
* @return 返回结果
*/
HourlyPowerOutageEventChartVO queryIntradayData(String orgCode, String startDate, String endDate);
HourlyPowerOutageEventChartVO queryIntradayData(String orgCode, String startDate, String endDate, String eventId);
/**
* 停电开始时间超过7天自动归为已复电

View File

@ -30,11 +30,11 @@ public class DnerDailyPowerOutageEventServiceImpl
private DnerDailyPowerOutageEventMapper dnerDailyPowerOutageEventMapper;
@Override
public DailyPowerOutageEventVO queryKlineData(String orgCode, String startDate, String endDate) {
public DailyPowerOutageEventVO queryKlineData(String orgCode, String startDate, String endDate, String eventId) {
// 为了计算ma5/10/20/30查询起始日期往前推29天的记录
String beforeNumDays = TimeUtil.getBeforeNumDays(startDate, 29); // 获取前29天的日期
List<DnerDailyPowerOutageEvent> dataList = dnerDailyPowerOutageEventMapper.selectListByConditions(
orgCode, beforeNumDays, endDate);
orgCode, beforeNumDays, endDate, eventId);
Map<String, DnerDailyPowerOutageEvent> dateTimeAndEntityMap = dataList.stream().collect(Collectors.toMap(
DnerDailyPowerOutageEvent::getDataTime, Function.identity(), (k1, k2) -> k1));
DailyPowerOutageEventVO result = new DailyPowerOutageEventVO();

View File

@ -33,11 +33,11 @@ public class DnerHourlyPowerOutageEventServiceImpl
private DnerHourlyPowerOutageEventMapper dnerHourlyPowerOutageEventMapper;
@Override
public HourlyPowerOutageEventChartVO queryIntradayData(String orgCode, String startDate, String endDate) {
public HourlyPowerOutageEventChartVO queryIntradayData(String orgCode, String startDate, String endDate, String eventId) {
startDate = startDate.substring(0, 13) + ":00";
endDate = endDate.substring(0, 13) + ":00";
List<DnerHourlyPowerOutageEvent> dataList = dnerHourlyPowerOutageEventMapper.selectListByConditions(
orgCode, startDate, endDate);
orgCode, startDate, endDate, eventId);
Map<String, DnerHourlyPowerOutageEvent> dateTimeAndEntityMap = dataList.stream().collect(Collectors.toMap(
DnerHourlyPowerOutageEvent::getDataTime, Function.identity(), (k1, k2) -> k1));
HourlyPowerOutageEventChartVO result = new HourlyPowerOutageEventChartVO();

View File

@ -4,7 +4,7 @@
<!-- namespace 必须 = Mapper 接口全类名 -->
<mapper namespace="com.southern.power.grid.dao.DnerDailyPowerOutageEventMapper">
<select id="selectListByConditions">
<select id="selectListByConditions" resultType="com.southern.power.grid.entity.DnerDailyPowerOutageEvent">
select `id`, `org_code`, `data_time`, `hourly_precipitation`, `daily_precipitation`, `temperature`,
`hourly_max_temperature`, `hourly_min_temperature`, `extreme_wind_speed_hourly`, `user_count`,
`star_user_count`, `end_user_count`, `min_user_count`, `max_user_count`, `fault_star_user_count`,
@ -15,6 +15,7 @@
where org_code = #{orgCode}
and data_time >= #{startDate}
and data_time <![CDATA[ <= ]]> #{endDate}
and event_id = #{eventId}
order by data_time asc
</select>
</mapper>

View File

@ -13,6 +13,7 @@
where org_code = #{orgCode}
and data_time >= #{startDate}
and data_time <![CDATA[ <= ]]> #{endDate}
and event_id = #{eventId}
order by data_time asc
</select>

View File

@ -42,6 +42,7 @@
where t1.district_code = t2.org_code
and t2.data_time >= #{param.rainStartDateTime}
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
and t2.event_id = #{param.eventId}
having sum(t2.hourly_precipitation) > #{param.pastTimeRainCount})
</if>
<if test="param.avgTempPastTime != null and param.avgTempPastTime != 0">
@ -52,6 +53,7 @@
where t1.district_code = t2.org_code
and t2.data_time >= #{param.avgTempStartDateTime}
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
and t2.event_id = #{param.eventId}
having avg(t2.temperature) > #{param.pastTimeAvgTempCount})
</if>
<if test="param.maxWindPastTime != null and param.maxWindPastTime != 0">
@ -62,6 +64,7 @@
where t1.district_code = t2.org_code
and t2.data_time >= #{param.maxWindStartDateTime}
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
and t2.event_id = #{param.eventId}
having avg(t2.extreme_wind_speed_hourly) > #{param.pastTimeMaxWindCount})
</if>
<if test="param.powerOutageTimePastTime != null and param.powerOutageTimePastTime != 0">
@ -72,6 +75,7 @@
where t1.district_code = t2.org_code
and t2.data_time >= #{param.powerOutageTimeStartDateTime}
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
and t2.event_id = #{param.eventId}
having sum(t2.power_outage_duration) > #{param.pastTimePowerOutageTimeCount})
</if>
<if test="param.powerOutageUserPastTime != null and param.powerOutageUserPastTime != 0">
@ -82,6 +86,7 @@
where t1.district_code = t2.org_code
and t2.data_time >= #{param.powerOutageUserStartDateTime}
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
and t2.event_id = #{param.eventId}
having sum(t2.user_count) > #{param.pastTimePowerOutageUserCount})
</if>
<if test="param.powerOutageRatioPastTime != null and param.powerOutageRatioPastTime != 0">
@ -92,12 +97,15 @@
where t1.district_code = t2.org_code
and t2.data_time >= #{param.powerOutageRatioStartDateTime}
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
and t2.event_id = #{param.eventId}
having avg(t2.not_restored_user_count/(t2.restored_user_count + t2.not_restored_user_count)) > #{param.pastTimePowerOutageRatioCount})
</if>
</when>
<otherwise>
# 过滤得到已存在数据的分时图
AND EXISTS (select 1 from dner_hourly_power_outage_event t2 where t1.district_code = t2.org_code)
AND EXISTS (select 1
from dner_hourly_power_outage_event t2
where t1.district_code = t2.org_code and t2.event_id = #{param.eventId})
</otherwise>
</choose>
</select>
@ -118,6 +126,7 @@
where t1.district_code = t2.org_code
and t2.data_time >= #{param.rainStartDateTime}
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
and t2.event_id = #{param.eventId}
having sum(t2.daily_precipitation) > #{param.pastTimeRainCount})
</if>
<if test="param.avgTempPastTime != null and param.avgTempPastTime != 0">
@ -128,6 +137,7 @@
where t1.district_code = t2.org_code
and t2.data_time >= #{param.avgTempStartDateTime}
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
and t2.event_id = #{param.eventId}
having avg(t2.temperature) > #{param.pastTimeAvgTempCount})
</if>
<if test="param.maxWindPastTime != null and param.maxWindPastTime != 0">
@ -138,6 +148,7 @@
where t1.district_code = t2.org_code
and t2.data_time >= #{param.maxWindStartDateTime}
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
and t2.event_id = #{param.eventId}
having avg(t2.extreme_wind_speed_hourly) > #{param.pastTimeMaxWindCount})
</if>
<if test="param.powerOutageTimePastTime != null and param.powerOutageTimePastTime != 0">
@ -148,6 +159,7 @@
where t1.district_code = t2.org_code
and t2.data_time >= #{param.powerOutageTimeStartDateTime}
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
and t2.event_id = #{param.eventId}
having sum(t2.power_outage_duration) > #{param.pastTimePowerOutageTimeCount})
</if>
<if test="param.powerOutageUserPastTime != null and param.powerOutageUserPastTime != 0">
@ -158,6 +170,7 @@
where t1.district_code = t2.org_code
and t2.data_time >= #{param.powerOutageUserStartDateTime}
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
and t2.event_id = #{param.eventId}
having sum(t2.user_count) > #{param.pastTimePowerOutageUserCount})
</if>
<if test="param.powerOutageRatioPastTime != null and param.powerOutageRatioPastTime != 0">
@ -168,12 +181,15 @@
where t1.district_code = t2.org_code
and t2.data_time >= #{param.powerOutageRatioStartDateTime}
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
and t2.event_id = #{param.eventId}
having avg(t2.not_restored_user_count/(t2.restored_user_count + t2.not_restored_user_count)) > #{param.pastTimePowerOutageRatioCount})
</if>
</when>
<otherwise>
# 过滤得到已存在数据的K线图
AND EXISTS (select 1 from dner_daily_power_outage_event t2 where t1.district_code = t2.org_code)
AND EXISTS (select 1
from dner_daily_power_outage_event t2
where t1.district_code = t2.org_code and t2.event_id = #{param.eventId})
</otherwise>
</choose>
</select>