180 lines
9.8 KiB
XML
180 lines
9.8 KiB
XML
<?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">
|
|
|
|
<!-- namespace 必须 = Mapper 接口全类名 -->
|
|
<mapper namespace="com.southern.power.grid.dao.DnerSiteAreaConfigurationMapper">
|
|
|
|
<resultMap id="BaseResultMap" type="com.southern.power.grid.entity.DnerSiteAreaConfiguration">
|
|
<id column="id" property="id"/>
|
|
<result column="province" property="province"/>
|
|
<result column="province_code" property="provinceCode"/>
|
|
<result column="city" property="city"/>
|
|
<result column="city_code" property="cityCode"/>
|
|
<result column="district" property="district"/>
|
|
<result column="district_code" property="districtCode"/>
|
|
<result column="create_by" property="createBy"/>
|
|
<result column="create_time" property="createTime"/>
|
|
<result column="update_by" property="updateBy"/>
|
|
<result column="update_time" property="updateTime"/>
|
|
</resultMap>
|
|
|
|
<select id="selectAll" resultMap="BaseResultMap">
|
|
SELECT
|
|
id, province, province_code, city, city_code, district, district_code,
|
|
create_by, create_time, update_by, update_time
|
|
FROM dner_site_area_configuration
|
|
</select>
|
|
|
|
<select id="selectHourlyChartAreaTree" resultMap="BaseResultMap">
|
|
SELECT
|
|
t1.id, t1.province, t1.province_code, t1.city, t1.city_code, t1.district, t1.district_code,
|
|
t1.create_by, t1.create_time, t1.update_by, t1.update_time
|
|
FROM dner_site_area_configuration t1
|
|
where 1=1
|
|
<choose>
|
|
<when test="param.advancedFilterFlag == 1">
|
|
<if test="param.rainPastTime != null and param.rainPastTime != 0">
|
|
# 过去 X 小时累计降雨量超过 Y mm
|
|
AND EXISTS (
|
|
select 1
|
|
from dner_hourly_power_outage_event t2
|
|
where t1.district_code = t2.org_code
|
|
and t2.data_time >= #{param.rainStartDateTime}
|
|
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
|
|
having sum(t2.hourly_precipitation) > #{param.pastTimeRainCount})
|
|
</if>
|
|
<if test="param.avgTempPastTime != null and param.avgTempPastTime != 0">
|
|
# 过去X小时/X天的平均气温超过 Y ℃
|
|
AND EXISTS (
|
|
select 1
|
|
from dner_hourly_power_outage_event t2
|
|
where t1.district_code = t2.org_code
|
|
and t2.data_time >= #{param.avgTempStartDateTime}
|
|
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
|
|
having avg(t2.temperature) > #{param.pastTimeAvgTempCount})
|
|
</if>
|
|
<if test="param.maxWindPastTime != null and param.maxWindPastTime != 0">
|
|
# 过去X分钟的平均风速超过Y m/s
|
|
AND EXISTS (
|
|
select 1
|
|
from dner_hourly_power_outage_event t2
|
|
where t1.district_code = t2.org_code
|
|
and t2.data_time >= #{param.maxWindStartDateTime}
|
|
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
|
|
having avg(t2.extreme_wind_speed_hourly) > #{param.pastTimeMaxWindCount})
|
|
</if>
|
|
<if test="param.powerOutageTimePastTime != null and param.powerOutageTimePastTime != 0">
|
|
# 过去X小时的停电时长超Y小时
|
|
AND EXISTS (
|
|
select 1
|
|
from dner_hourly_power_outage_event t2
|
|
where t1.district_code = t2.org_code
|
|
and t2.data_time >= #{param.powerOutageTimeStartDateTime}
|
|
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
|
|
having sum(t2.power_outage_duration) > #{param.pastTimePowerOutageTimeCount})
|
|
</if>
|
|
<if test="param.powerOutageUserPastTime != null and param.powerOutageUserPastTime != 0">
|
|
# 过去X小时的停电用户数超过Y户
|
|
AND EXISTS (
|
|
select 1
|
|
from dner_hourly_power_outage_event t2
|
|
where t1.district_code = t2.org_code
|
|
and t2.data_time >= #{param.powerOutageUserStartDateTime}
|
|
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
|
|
having sum(t2.user_count) > #{param.pastTimePowerOutageUserCount})
|
|
</if>
|
|
<if test="param.powerOutageRatioPastTime != null and param.powerOutageRatioPastTime != 0">
|
|
# 未复电用户数占总停电用户数的比例大于 X %
|
|
AND EXISTS (
|
|
select 1
|
|
from dner_hourly_power_outage_event t2
|
|
where t1.district_code = t2.org_code
|
|
and t2.data_time >= #{param.powerOutageRatioStartDateTime}
|
|
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
|
|
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)
|
|
</otherwise>
|
|
</choose>
|
|
</select>
|
|
|
|
<select id="selectDailyChartAreaTree" resultMap="BaseResultMap">
|
|
SELECT
|
|
t1.id, t1.province, t1.province_code, t1.city, t1.city_code, t1.district, t1.district_code,
|
|
t1.create_by, t1.create_time, t1.update_by, t1.update_time
|
|
FROM dner_site_area_configuration t1
|
|
where 1=1
|
|
<choose>
|
|
<when test="param.advancedFilterFlag == 1">
|
|
<if test="param.rainPastTime != null and param.rainPastTime != 0">
|
|
# 过去 X 天累计日降雨量超过 Y mm
|
|
AND EXISTS (
|
|
select 1
|
|
from dner_daily_power_outage_event t2
|
|
where t1.district_code = t2.org_code
|
|
and t2.data_time >= #{param.rainStartDateTime}
|
|
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
|
|
having sum(t2.daily_precipitation) > #{param.pastTimeRainCount})
|
|
</if>
|
|
<if test="param.avgTempPastTime != null and param.avgTempPastTime != 0">
|
|
# 过去X天的平均气温超过 Y ℃
|
|
AND EXISTS (
|
|
select 1
|
|
from dner_daily_power_outage_event t2
|
|
where t1.district_code = t2.org_code
|
|
and t2.data_time >= #{param.avgTempStartDateTime}
|
|
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
|
|
having avg(t2.temperature) > #{param.pastTimeAvgTempCount})
|
|
</if>
|
|
<if test="param.maxWindPastTime != null and param.maxWindPastTime != 0">
|
|
# 过去X天的平均风速超过Y m/s
|
|
AND EXISTS (
|
|
select 1
|
|
from dner_daily_power_outage_event t2
|
|
where t1.district_code = t2.org_code
|
|
and t2.data_time >= #{param.maxWindStartDateTime}
|
|
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
|
|
having avg(t2.extreme_wind_speed_hourly) > #{param.pastTimeMaxWindCount})
|
|
</if>
|
|
<if test="param.powerOutageTimePastTime != null and param.powerOutageTimePastTime != 0">
|
|
# 过去X小时的停电时长超Y小时
|
|
AND EXISTS (
|
|
select 1
|
|
from dner_daily_power_outage_event t2
|
|
where t1.district_code = t2.org_code
|
|
and t2.data_time >= #{param.powerOutageTimeStartDateTime}
|
|
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
|
|
having sum(t2.power_outage_duration) > #{param.pastTimePowerOutageTimeCount})
|
|
</if>
|
|
<if test="param.powerOutageUserPastTime != null and param.powerOutageUserPastTime != 0">
|
|
# 过去X天的停电用户数超过Y户
|
|
AND EXISTS (
|
|
select 1
|
|
from dner_daily_power_outage_event t2
|
|
where t1.district_code = t2.org_code
|
|
and t2.data_time >= #{param.powerOutageUserStartDateTime}
|
|
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
|
|
having sum(t2.user_count) > #{param.pastTimePowerOutageUserCount})
|
|
</if>
|
|
<if test="param.powerOutageRatioPastTime != null and param.powerOutageRatioPastTime != 0">
|
|
# 未复电用户数占总停电用户数的比例大于 X %
|
|
AND EXISTS (
|
|
select 1
|
|
from dner_daily_power_outage_event t2
|
|
where t1.district_code = t2.org_code
|
|
and t2.data_time >= #{param.powerOutageRatioStartDateTime}
|
|
and t2.data_time <![CDATA[ < ]]> #{param.currentDateTime}
|
|
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)
|
|
</otherwise>
|
|
</choose>
|
|
</select>
|
|
</mapper> |