重构
This commit is contained in:
@ -7,12 +7,13 @@
|
||||
<resultMap type="EmsDailyChargeData" id="EmsDailyChargeDataResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="siteId" column="site_id" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="dateTime" column="date_time" />
|
||||
<result property="totalChargeData" column="total_charge_Data" />
|
||||
<result property="totalDischargeData" column="total_discharge_Data" />
|
||||
<result property="chargeData" column="charge_data" />
|
||||
<result property="dischargeData" column="discharge_data" />
|
||||
<result property="totalRevenue" column="total_revenue" />
|
||||
<result property="dayRevenue" column="day_revenue" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
@ -21,20 +22,22 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEmsDailyChargeDataVo">
|
||||
select id, site_id, device_id, date_time, total_charge_Data, total_discharge_Data, charge_data, discharge_data, create_by, create_time, update_by, update_time, remark from ems_daily_charge_data
|
||||
select id, site_id, date_time, total_charge_Data, total_discharge_Data, charge_data, discharge_data, total_revenue, day_revenue, create_by, create_time, update_by, update_time, remark from ems_daily_charge_data
|
||||
</sql>
|
||||
|
||||
<select id="selectEmsDailyChargeDataList" parameterType="EmsDailyChargeData" resultMap="EmsDailyChargeDataResult">
|
||||
<include refid="selectEmsDailyChargeDataVo"/>
|
||||
<where>
|
||||
<if test="siteId != null and siteId != ''"> and site_id = #{siteId}</if>
|
||||
<if test="deviceId != null and deviceId != ''"> and device_id = #{deviceId}</if>
|
||||
<if test="dateTime != null "> and date_time = #{dateTime}</if>
|
||||
<if test="totalChargeData != null "> and total_charge_Data = #{totalChargeData}</if>
|
||||
<if test="totalDischargeData != null "> and total_discharge_Data = #{totalDischargeData}</if>
|
||||
<if test="chargeData != null "> and charge_data = #{chargeData}</if>
|
||||
<if test="dischargeData != null "> and discharge_data = #{dischargeData}</if>
|
||||
<if test="totalRevenue != null "> and total_revenue = #{totalRevenue}</if>
|
||||
<if test="dayRevenue != null "> and day_revenue = #{dayRevenue}</if>
|
||||
</where>
|
||||
order by date_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectEmsDailyChargeDataById" parameterType="Long" resultMap="EmsDailyChargeDataResult">
|
||||
@ -42,16 +45,25 @@
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectBySiteIdAndDateTime" resultMap="EmsDailyChargeDataResult">
|
||||
<include refid="selectEmsDailyChargeDataVo"/>
|
||||
where site_id = #{siteId}
|
||||
and date(date_time) = date(#{dateTime})
|
||||
order by date_time desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertEmsDailyChargeData" parameterType="EmsDailyChargeData" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into ems_daily_charge_data
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="siteId != null">site_id,</if>
|
||||
<if test="deviceId != null and deviceId != ''">device_id,</if>
|
||||
<if test="dateTime != null">date_time,</if>
|
||||
<if test="totalChargeData != null">total_charge_Data,</if>
|
||||
<if test="totalDischargeData != null">total_discharge_Data,</if>
|
||||
<if test="chargeData != null">charge_data,</if>
|
||||
<if test="dischargeData != null">discharge_data,</if>
|
||||
<if test="totalRevenue != null">total_revenue,</if>
|
||||
<if test="dayRevenue != null">day_revenue,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
@ -60,12 +72,13 @@
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="siteId != null">#{siteId},</if>
|
||||
<if test="deviceId != null and deviceId != ''">#{deviceId},</if>
|
||||
<if test="dateTime != null">#{dateTime},</if>
|
||||
<if test="totalChargeData != null">#{totalChargeData},</if>
|
||||
<if test="totalDischargeData != null">#{totalDischargeData},</if>
|
||||
<if test="chargeData != null">#{chargeData},</if>
|
||||
<if test="dischargeData != null">#{dischargeData},</if>
|
||||
<if test="totalRevenue != null">#{totalRevenue},</if>
|
||||
<if test="dayRevenue != null">#{dayRevenue},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
@ -78,12 +91,13 @@
|
||||
update ems_daily_charge_data
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="siteId != null">site_id = #{siteId},</if>
|
||||
<if test="deviceId != null and deviceId != ''">device_id = #{deviceId},</if>
|
||||
<if test="dateTime != null">date_time = #{dateTime},</if>
|
||||
<if test="totalChargeData != null">total_charge_Data = #{totalChargeData},</if>
|
||||
<if test="totalDischargeData != null">total_discharge_Data = #{totalDischargeData},</if>
|
||||
<if test="chargeData != null">charge_data = #{chargeData},</if>
|
||||
<if test="dischargeData != null">discharge_data = #{dischargeData},</if>
|
||||
<if test="totalRevenue != null">total_revenue = #{totalRevenue},</if>
|
||||
<if test="dayRevenue != null">day_revenue = #{dayRevenue},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
@ -108,26 +122,28 @@
|
||||
INSERT into ems_daily_charge_data (
|
||||
id,
|
||||
site_id,
|
||||
device_id,
|
||||
date_time,
|
||||
total_charge_Data,
|
||||
total_discharge_Data,
|
||||
charge_data,
|
||||
discharge_data,
|
||||
total_revenue,
|
||||
day_revenue,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
remark
|
||||
) values (
|
||||
) values (
|
||||
#{id},
|
||||
#{siteId},
|
||||
#{deviceId},
|
||||
#{dateTime},
|
||||
#{totalChargeData},
|
||||
#{totalDischargeData},
|
||||
#{chargeData},
|
||||
#{dischargeData},
|
||||
#{totalRevenue},
|
||||
#{dayRevenue},
|
||||
#{createBy},
|
||||
#{createTime},
|
||||
#{updateBy},
|
||||
@ -139,9 +155,21 @@
|
||||
total_discharge_Data = #{totalDischargeData},
|
||||
charge_data = #{chargeData},
|
||||
discharge_data = #{dischargeData},
|
||||
total_revenue = IFNULL(#{totalRevenue}, total_revenue),
|
||||
day_revenue = IFNULL(#{dayRevenue}, day_revenue),
|
||||
update_time = NOW()
|
||||
</insert>
|
||||
|
||||
<update id="updateRevenueBySiteAndDate">
|
||||
update ems_daily_charge_data
|
||||
set total_revenue = #{totalRevenue},
|
||||
day_revenue = #{dayRevenue},
|
||||
update_by = #{updateBy},
|
||||
update_time = NOW()
|
||||
where site_id = #{siteId}
|
||||
and date(date_time) = date(#{dateTime})
|
||||
</update>
|
||||
|
||||
<select id="getAllSiteChargeData" resultType="map">
|
||||
SELECT
|
||||
SUM(t.total_charge_data) AS totalChargedCap,
|
||||
@ -207,4 +235,4 @@
|
||||
GROUP BY dateMonth
|
||||
ORDER BY dateMonth
|
||||
</select>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
||||
@ -8,8 +8,7 @@
|
||||
<result property="id" column="id" />
|
||||
<result property="siteId" column="site_id" />
|
||||
<result property="dataDate" column="data_date" />
|
||||
<result property="totalRevenue" column="total_revenue" />
|
||||
<result property="dayRevenue" column="day_revenue" />
|
||||
<result property="dataHour" column="data_hour" />
|
||||
<result property="peakChargeDiff" column="peak_charge_diff" />
|
||||
<result property="peakDischargeDiff" column="peak_discharge_diff" />
|
||||
<result property="highChargeDiff" column="high_charge_diff" />
|
||||
@ -27,7 +26,11 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEmsDailyEnergyDataVo">
|
||||
select id, site_id, data_date, total_revenue, day_revenue, peak_charge_diff, peak_discharge_diff, high_charge_diff, high_discharge_diff, flat_charge_diff, flat_discharge_diff, valley_charge_diff, valley_discharge_diff, calc_time, create_by, create_time, update_by, update_time, remark from ems_daily_energy_data
|
||||
select id, site_id, data_date, data_hour,
|
||||
peak_charge_diff, peak_discharge_diff, high_charge_diff, high_discharge_diff,
|
||||
flat_charge_diff, flat_discharge_diff, valley_charge_diff, valley_discharge_diff,
|
||||
calc_time, create_by, create_time, update_by, update_time, remark
|
||||
from ems_daily_energy_data
|
||||
</sql>
|
||||
|
||||
<select id="selectEmsDailyEnergyDataList" parameterType="EmsDailyEnergyData" resultMap="EmsDailyEnergyDataResult">
|
||||
@ -35,8 +38,7 @@
|
||||
<where>
|
||||
<if test="siteId != null and siteId != ''"> and site_id = #{siteId}</if>
|
||||
<if test="dataDate != null "> and data_date = #{dataDate}</if>
|
||||
<if test="totalRevenue != null "> and total_revenue = #{totalRevenue}</if>
|
||||
<if test="dayRevenue != null "> and day_revenue = #{dayRevenue}</if>
|
||||
<if test="dataHour != null "> and data_hour = #{dataHour}</if>
|
||||
<if test="peakChargeDiff != null "> and peak_charge_diff = #{peakChargeDiff}</if>
|
||||
<if test="peakDischargeDiff != null "> and peak_discharge_diff = #{peakDischargeDiff}</if>
|
||||
<if test="highChargeDiff != null "> and high_charge_diff = #{highChargeDiff}</if>
|
||||
@ -47,6 +49,7 @@
|
||||
<if test="valleyDischargeDiff != null "> and valley_discharge_diff = #{valleyDischargeDiff}</if>
|
||||
<if test="calcTime != null "> and calc_time = #{calcTime}</if>
|
||||
</where>
|
||||
order by data_date desc, calc_time desc, id desc
|
||||
</select>
|
||||
|
||||
<select id="selectEmsDailyEnergyDataById" parameterType="Long" resultMap="EmsDailyEnergyDataResult">
|
||||
@ -59,8 +62,7 @@
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="siteId != null">site_id,</if>
|
||||
<if test="dataDate != null">data_date,</if>
|
||||
<if test="totalRevenue != null">total_revenue,</if>
|
||||
<if test="dayRevenue != null">day_revenue,</if>
|
||||
<if test="dataHour != null">data_hour,</if>
|
||||
<if test="peakChargeDiff != null">peak_charge_diff,</if>
|
||||
<if test="peakDischargeDiff != null">peak_discharge_diff,</if>
|
||||
<if test="highChargeDiff != null">high_charge_diff,</if>
|
||||
@ -79,8 +81,7 @@
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="siteId != null">#{siteId},</if>
|
||||
<if test="dataDate != null">#{dataDate},</if>
|
||||
<if test="totalRevenue != null">#{totalRevenue},</if>
|
||||
<if test="dayRevenue != null">#{dayRevenue},</if>
|
||||
<if test="dataHour != null">#{dataHour},</if>
|
||||
<if test="peakChargeDiff != null">#{peakChargeDiff},</if>
|
||||
<if test="peakDischargeDiff != null">#{peakDischargeDiff},</if>
|
||||
<if test="highChargeDiff != null">#{highChargeDiff},</if>
|
||||
@ -103,8 +104,7 @@
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="siteId != null">site_id = #{siteId},</if>
|
||||
<if test="dataDate != null">data_date = #{dataDate},</if>
|
||||
<if test="totalRevenue != null">total_revenue = #{totalRevenue},</if>
|
||||
<if test="dayRevenue != null">day_revenue = #{dayRevenue},</if>
|
||||
<if test="dataHour != null">data_hour = #{dataHour},</if>
|
||||
<if test="peakChargeDiff != null">peak_charge_diff = #{peakChargeDiff},</if>
|
||||
<if test="peakDischargeDiff != null">peak_discharge_diff = #{peakDischargeDiff},</if>
|
||||
<if test="highChargeDiff != null">high_charge_diff = #{highChargeDiff},</if>
|
||||
@ -138,14 +138,22 @@
|
||||
<include refid="selectEmsDailyEnergyDataVo"/>
|
||||
where data_date = #{today}
|
||||
AND site_id = #{siteId}
|
||||
AND data_hour IS NULL
|
||||
</select>
|
||||
|
||||
<select id="selectBySiteIdAndDateHour" resultMap="EmsDailyEnergyDataResult">
|
||||
<include refid="selectEmsDailyEnergyDataVo"/>
|
||||
where site_id = #{siteId}
|
||||
and data_date = DATE(#{dataDate})
|
||||
and data_hour = #{dataHour}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertOrUpdateData" parameterType="com.xzzn.ems.domain.EmsDailyEnergyData"
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO ems_daily_energy_data (
|
||||
id, site_id, data_date,
|
||||
<if test="totalRevenue != null">total_revenue,</if>
|
||||
<if test="dayRevenue != null">day_revenue,</if>
|
||||
<if test="dataHour != null">data_hour,</if>
|
||||
<if test="peakChargeDiff != null">peak_charge_diff,</if>
|
||||
<if test="peakDischargeDiff != null">peak_discharge_diff,</if>
|
||||
<if test="highChargeDiff != null">high_charge_diff,</if>
|
||||
@ -164,8 +172,7 @@
|
||||
#{id},
|
||||
#{siteId},
|
||||
#{dataDate},
|
||||
<if test="totalRevenue != null">#{totalRevenue},</if>
|
||||
<if test="dayRevenue != null">#{dayRevenue},</if>
|
||||
<if test="dataHour != null">#{dataHour},</if>
|
||||
<if test="peakChargeDiff != null">#{peakChargeDiff},</if>
|
||||
<if test="peakDischargeDiff != null">#{peakDischargeDiff},</if>
|
||||
<if test="highChargeDiff != null">#{highChargeDiff},</if>
|
||||
@ -181,8 +188,7 @@
|
||||
NOW(),
|
||||
#{remark}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
<if test="totalRevenue != null">total_revenue = #{totalRevenue},</if>
|
||||
<if test="dayRevenue != null">day_revenue = #{dayRevenue},</if>
|
||||
<if test="dataHour != null">data_hour = #{dataHour},</if>
|
||||
<if test="peakChargeDiff != null">peak_charge_diff = #{peakChargeDiff},</if>
|
||||
<if test="peakDischargeDiff != null">peak_discharge_diff = #{peakDischargeDiff},</if>
|
||||
<if test="highChargeDiff != null">high_charge_diff = #{highChargeDiff},</if>
|
||||
@ -196,60 +202,116 @@
|
||||
</insert>
|
||||
|
||||
<select id="getDataBySiteId" resultType="com.xzzn.ems.domain.vo.AmmeterStatisListVo">
|
||||
select t.data_date as dataTime,
|
||||
t.peak_charge_diff as activePeakKwh,
|
||||
t.peak_discharge_diff as reActivePeakKwh,
|
||||
t.high_charge_diff as activeHighKwh,
|
||||
t.high_discharge_diff as reActiveHighKwh,
|
||||
t.flat_charge_diff as activeFlatKwh,
|
||||
t.flat_discharge_diff as reActiveFlatKwh,
|
||||
t.valley_charge_diff as activeValleyKwh,
|
||||
t.valley_discharge_diff as reActiveValleyKwh
|
||||
from ems_daily_energy_data t
|
||||
where 1=1
|
||||
<if test="siteId != null">
|
||||
and t.site_id = #{siteId}
|
||||
</if>
|
||||
<if test="startTime != null">
|
||||
and t.data_date >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
and t.data_date <= #{endTime}
|
||||
</if>
|
||||
select DATE_FORMAT(r.dataDate, '%Y-%m-%d') as dataTime,
|
||||
r.activePeakKwh,
|
||||
r.reActivePeakKwh,
|
||||
r.activeHighKwh,
|
||||
r.reActiveHighKwh,
|
||||
r.activeFlatKwh,
|
||||
r.reActiveFlatKwh,
|
||||
r.activeValleyKwh,
|
||||
r.reActiveValleyKwh
|
||||
from (
|
||||
-- 优先使用按天汇总记录(data_hour is null)
|
||||
select DATE(t.data_date) as dataDate,
|
||||
t.peak_charge_diff as activePeakKwh,
|
||||
t.peak_discharge_diff as reActivePeakKwh,
|
||||
t.high_charge_diff as activeHighKwh,
|
||||
t.high_discharge_diff as reActiveHighKwh,
|
||||
t.flat_charge_diff as activeFlatKwh,
|
||||
t.flat_discharge_diff as reActiveFlatKwh,
|
||||
t.valley_charge_diff as activeValleyKwh,
|
||||
t.valley_discharge_diff as reActiveValleyKwh
|
||||
from ems_daily_energy_data t
|
||||
where t.data_hour is null
|
||||
<if test="siteId != null and siteId != ''">
|
||||
and t.site_id = #{siteId}
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
and t.data_date >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
and t.data_date < DATE_ADD(#{endTime}, INTERVAL 1 DAY)
|
||||
</if>
|
||||
|
||||
union all
|
||||
|
||||
-- 若某天没有日汇总记录,则按小时数据汇总兜底
|
||||
select DATE(h.data_date) as dataDate,
|
||||
SUM(IFNULL(h.peak_charge_diff, 0)) as activePeakKwh,
|
||||
SUM(IFNULL(h.peak_discharge_diff, 0)) as reActivePeakKwh,
|
||||
SUM(IFNULL(h.high_charge_diff, 0)) as activeHighKwh,
|
||||
SUM(IFNULL(h.high_discharge_diff, 0)) as reActiveHighKwh,
|
||||
SUM(IFNULL(h.flat_charge_diff, 0)) as activeFlatKwh,
|
||||
SUM(IFNULL(h.flat_discharge_diff, 0)) as reActiveFlatKwh,
|
||||
SUM(IFNULL(h.valley_charge_diff, 0)) as activeValleyKwh,
|
||||
SUM(IFNULL(h.valley_discharge_diff, 0)) as reActiveValleyKwh
|
||||
from ems_daily_energy_data h
|
||||
where h.data_hour is not null
|
||||
<if test="siteId != null and siteId != ''">
|
||||
and h.site_id = #{siteId}
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
and h.data_date >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
and h.data_date < DATE_ADD(#{endTime}, INTERVAL 1 DAY)
|
||||
</if>
|
||||
and not exists (
|
||||
select 1
|
||||
from ems_daily_energy_data d
|
||||
where d.site_id = h.site_id
|
||||
and DATE(d.data_date) = DATE(h.data_date)
|
||||
and d.data_hour is null
|
||||
)
|
||||
group by h.site_id, DATE(h.data_date)
|
||||
) r
|
||||
order by r.dataDate desc
|
||||
</select>
|
||||
|
||||
<select id="getLastTotalRevenue" resultType="java.math.BigDecimal">
|
||||
select t.total_revenue
|
||||
from ems_daily_energy_data t
|
||||
where t.site_id = #{siteId}
|
||||
and t.data_date < CURDATE()
|
||||
order by t.data_date desc limit 1
|
||||
from ems_daily_charge_data t
|
||||
where t.site_id = #{siteId}
|
||||
and date(t.date_time) < CURDATE()
|
||||
order by t.date_time desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="getRealTimeRevenue" resultType="java.util.Map">
|
||||
select t.total_revenue as totalRevenue, t.day_revenue as dayRevenue
|
||||
from ems_daily_energy_data t
|
||||
where t.site_id = #{siteId}
|
||||
order by t.data_date desc limit 1
|
||||
from ems_daily_charge_data t
|
||||
where t.site_id = #{siteId}
|
||||
order by t.date_time desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="getRevenueDataBySiteId" resultType="com.xzzn.ems.domain.vo.AmmeterRevenueStatisListVo">
|
||||
select
|
||||
t.data_date as dataTime,
|
||||
DATE_FORMAT(t.data_date, '%Y-%m-%d') as dataTime,
|
||||
COALESCE(c.is_workday, CASE WHEN WEEKDAY(t.data_date) < 5 THEN 1 ELSE 0 END) as isWorkday,
|
||||
CASE
|
||||
WHEN COALESCE(c.is_workday, CASE WHEN WEEKDAY(t.data_date) < 5 THEN 1 ELSE 0 END) = 1 THEN '工作日'
|
||||
ELSE '节假日'
|
||||
END as dayType,
|
||||
COALESCE(NULLIF(TRIM(w.weather_desc), ''), '--') as weatherDesc,
|
||||
ROUND(IFNULL(t.peak_charge_diff, 0) * IFNULL(pc.peak, 0), 3) as activePeakPrice,
|
||||
ROUND(IFNULL(t.peak_discharge_diff, 0) * IFNULL(pc.peak, 0), 3) as reActivePeakPrice,
|
||||
ROUND(IFNULL(t.high_charge_diff, 0) * IFNULL(pc.high, 0), 3) as activeHighPrice,
|
||||
ROUND(IFNULL(t.high_discharge_diff, 0) * IFNULL(pc.high, 0), 3) as reActiveHighPrice,
|
||||
ROUND(IFNULL(t.flat_charge_diff, 0) * IFNULL(pc.flat, 0), 3) as activeFlatPrice,
|
||||
ROUND(IFNULL(t.flat_discharge_diff, 0) * IFNULL(pc.flat, 0), 3) as reActiveFlatPrice,
|
||||
ROUND(IFNULL(t.valley_charge_diff, 0) * IFNULL(pc.valley, 0), 3) as activeValleyPrice,
|
||||
ROUND(IFNULL(t.valley_discharge_diff, 0) * IFNULL(pc.valley, 0), 3) as reActiveValleyPrice
|
||||
ROUND(SUM(IFNULL(t.peak_charge_diff, 0) * IFNULL(pc.peak, 0)), 3) as activePeakPrice,
|
||||
ROUND(SUM(IFNULL(t.peak_discharge_diff, 0) * IFNULL(pc.peak, 0)), 3) as reActivePeakPrice,
|
||||
ROUND(SUM(IFNULL(t.high_charge_diff, 0) * IFNULL(pc.high, 0)), 3) as activeHighPrice,
|
||||
ROUND(SUM(IFNULL(t.high_discharge_diff, 0) * IFNULL(pc.high, 0)), 3) as reActiveHighPrice,
|
||||
ROUND(SUM(IFNULL(t.flat_charge_diff, 0) * IFNULL(pc.flat, 0)), 3) as activeFlatPrice,
|
||||
ROUND(SUM(IFNULL(t.flat_discharge_diff, 0) * IFNULL(pc.flat, 0)), 3) as reActiveFlatPrice,
|
||||
ROUND(SUM(IFNULL(t.valley_charge_diff, 0) * IFNULL(pc.valley, 0)), 3) as activeValleyPrice,
|
||||
ROUND(SUM(IFNULL(t.valley_discharge_diff, 0) * IFNULL(pc.valley, 0)), 3) as reActiveValleyPrice,
|
||||
ROUND(
|
||||
SUM(
|
||||
(IFNULL(t.peak_discharge_diff, 0) - IFNULL(t.peak_charge_diff, 0)) * IFNULL(pc.peak, 0)
|
||||
+ (IFNULL(t.high_discharge_diff, 0) - IFNULL(t.high_charge_diff, 0)) * IFNULL(pc.high, 0)
|
||||
+ (IFNULL(t.flat_discharge_diff, 0) - IFNULL(t.flat_charge_diff, 0)) * IFNULL(pc.flat, 0)
|
||||
+ (IFNULL(t.valley_discharge_diff, 0) - IFNULL(t.valley_charge_diff, 0)) * IFNULL(pc.valley, 0)
|
||||
),
|
||||
3
|
||||
) as actualRevenue
|
||||
from ems_daily_energy_data t
|
||||
left join ems_calendar_day c on c.calendar_date = t.data_date
|
||||
left join ems_site_weather_day w on w.site_id = t.site_id and w.calendar_date = t.data_date
|
||||
@ -271,6 +333,7 @@
|
||||
)
|
||||
)
|
||||
where 1=1
|
||||
and t.data_hour is not null
|
||||
<if test="siteId != null">
|
||||
and t.site_id = #{siteId}
|
||||
</if>
|
||||
@ -280,6 +343,9 @@
|
||||
<if test="endTime != null">
|
||||
and t.data_date <= #{endTime}
|
||||
</if>
|
||||
group by t.data_date,
|
||||
COALESCE(c.is_workday, CASE WHEN WEEKDAY(t.data_date) < 5 THEN 1 ELSE 0 END),
|
||||
COALESCE(NULLIF(TRIM(w.weather_desc), ''), '--')
|
||||
order by t.data_date desc
|
||||
|
||||
</select>
|
||||
|
||||
@ -52,7 +52,7 @@
|
||||
<include refid="selectEmsPointConfigVo"/>
|
||||
<where>
|
||||
<if test="siteId != null and siteId != ''">and site_id = #{siteId}</if>
|
||||
<if test="pointId != null and pointId != ''">and point_id = #{pointId}</if>
|
||||
<if test="pointId != null and pointId != ''">and point_id like concat('%', #{pointId}, '%')</if>
|
||||
<if test="deviceCategory != null and deviceCategory != ''">and device_category = #{deviceCategory}</if>
|
||||
<if test="deviceId != null and deviceId != ''">and device_id = #{deviceId}</if>
|
||||
<if test="dataKey != null and dataKey != ''">and data_key like concat('%', #{dataKey}, '%')</if>
|
||||
@ -202,6 +202,36 @@
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateEmsPointConfigForImport" parameterType="EmsPointConfig">
|
||||
update ems_point_config
|
||||
set point_id = #{pointId},
|
||||
site_id = #{siteId},
|
||||
device_category = #{deviceCategory},
|
||||
device_id = #{deviceId},
|
||||
point_name = #{pointName},
|
||||
data_key = #{dataKey},
|
||||
point_desc = #{pointDesc},
|
||||
register_address = #{registerAddress},
|
||||
data_unit = #{dataUnit},
|
||||
data_a = #{dataA},
|
||||
data_k = #{dataK},
|
||||
data_b = #{dataB},
|
||||
data_bit = #{dataBit},
|
||||
is_alarm = #{isAlarm},
|
||||
point_type = #{pointType},
|
||||
calc_expression = #{calcExpression},
|
||||
collect_enabled = #{collectEnabled},
|
||||
collect_source = #{collectSource},
|
||||
modbus_register_type = #{modbusRegisterType},
|
||||
modbus_data_type = #{modbusDataType},
|
||||
modbus_read_order = #{modbusReadOrder},
|
||||
modbus_group = #{modbusGroup},
|
||||
update_by = #{updateBy},
|
||||
update_time = now(),
|
||||
remark = #{remark}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteEmsPointConfigById" parameterType="Long">
|
||||
delete from ems_point_config where id = #{id}
|
||||
</delete>
|
||||
@ -329,11 +359,11 @@
|
||||
<include refid="selectEmsPointConfigVo"/>
|
||||
where collect_enabled = 1
|
||||
and collect_source = 'MODBUS'
|
||||
and (point_type is null or point_type <> 'calc')
|
||||
and (point_type is null or point_type <> 'calc')
|
||||
and (is_alarm is null or is_alarm = 0)
|
||||
and register_address is not null and register_address <> ''
|
||||
and modbus_register_type is not null and modbus_register_type <> ''
|
||||
and modbus_data_type is not null and modbus_data_type <> ''
|
||||
and register_address is not null and register_address <> ''
|
||||
and modbus_register_type is not null and modbus_register_type <> ''
|
||||
and modbus_data_type is not null and modbus_data_type <> ''
|
||||
<if test="siteId != null and siteId != ''">
|
||||
and site_id = #{siteId}
|
||||
</if>
|
||||
|
||||
@ -4,6 +4,14 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.xzzn.ems.mapper.EmsSiteMonitorPointMatchMapper">
|
||||
|
||||
<select id="selectDistinctSiteIds" resultType="java.lang.String">
|
||||
select distinct site_id
|
||||
from ems_site_monitor_point_match
|
||||
where site_id is not null
|
||||
and site_id != ''
|
||||
order by site_id asc
|
||||
</select>
|
||||
|
||||
<resultMap id="EmsSiteMonitorPointMatchResult" type="com.xzzn.ems.domain.EmsSiteMonitorPointMatch">
|
||||
<result property="id" column="id"/>
|
||||
<result property="siteId" column="site_id"/>
|
||||
|
||||
Reference in New Issue
Block a user