0918优化-电表报表-尖峰平谷日差值显示
This commit is contained in:
@ -885,11 +885,23 @@
|
||||
</select>
|
||||
|
||||
<select id="getYestLatestDate" resultMap="EmsAmmeterDataResult">
|
||||
<include refid="selectEmsAmmeterDataVo"/>
|
||||
where site_id = #{siteId}
|
||||
SELECT
|
||||
t.current_forward_active_total,
|
||||
t.current_reverse_active_total,
|
||||
t.current_forward_active_peak,
|
||||
t.current_forward_active_high,
|
||||
t.current_forward_active_flat,
|
||||
t.current_forward_active_valley,
|
||||
t.current_reverse_active_peak,
|
||||
t.current_reverse_active_high,
|
||||
t.current_reverse_active_flat,
|
||||
t.current_reverse_active_valley
|
||||
FROM ems_ammeter_data t
|
||||
WHERE site_id = #{siteId}
|
||||
and device_id = #{deviceId}
|
||||
and DATE(data_update_time) = #{yestData}
|
||||
order by data_update_time desc limit 1
|
||||
AND data_update_time <= #{yestData}
|
||||
ORDER BY data_update_time DESC
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="getMonthlyTimeRanges" resultType="com.xzzn.ems.domain.vo.MonthlyTimeRange">
|
||||
|
||||
@ -0,0 +1,181 @@
|
||||
<?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.xzzn.ems.mapper.EmsDailyEnergyDataMapper">
|
||||
|
||||
<resultMap type="EmsDailyEnergyData" id="EmsDailyEnergyDataResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="siteId" column="site_id" />
|
||||
<result property="dataDate" column="data_date" />
|
||||
<result property="peakChargeDiff" column="peak_charge_diff" />
|
||||
<result property="peakDischargeDiff" column="peak_discharge_diff" />
|
||||
<result property="highChargeDiff" column="high_charge_diff" />
|
||||
<result property="highDischargeDiff" column="high_discharge_diff" />
|
||||
<result property="flatChargeDiff" column="flat_charge_diff" />
|
||||
<result property="flatDischargeDiff" column="flat_discharge_diff" />
|
||||
<result property="valleyChargeDiff" column="valley_charge_diff" />
|
||||
<result property="valleyDischargeDiff" column="valley_discharge_diff" />
|
||||
<result property="calcTime" column="calc_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEmsDailyEnergyDataVo">
|
||||
select id, site_id, data_date, 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">
|
||||
<include refid="selectEmsDailyEnergyDataVo"/>
|
||||
<where>
|
||||
<if test="siteId != null and siteId != ''"> and site_id = #{siteId}</if>
|
||||
<if test="dataDate != null "> and data_date = #{dataDate}</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>
|
||||
<if test="highDischargeDiff != null "> and high_discharge_diff = #{highDischargeDiff}</if>
|
||||
<if test="flatChargeDiff != null "> and flat_charge_diff = #{flatChargeDiff}</if>
|
||||
<if test="flatDischargeDiff != null "> and flat_discharge_diff = #{flatDischargeDiff}</if>
|
||||
<if test="valleyChargeDiff != null "> and valley_charge_diff = #{valleyChargeDiff}</if>
|
||||
<if test="valleyDischargeDiff != null "> and valley_discharge_diff = #{valleyDischargeDiff}</if>
|
||||
<if test="calcTime != null "> and calc_time = #{calcTime}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectEmsDailyEnergyDataById" parameterType="Long" resultMap="EmsDailyEnergyDataResult">
|
||||
<include refid="selectEmsDailyEnergyDataVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertEmsDailyEnergyData" parameterType="EmsDailyEnergyData" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into ems_daily_energy_data
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="siteId != null">site_id,</if>
|
||||
<if test="dataDate != null">data_date,</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>
|
||||
<if test="highDischargeDiff != null">high_discharge_diff,</if>
|
||||
<if test="flatChargeDiff != null">flat_charge_diff,</if>
|
||||
<if test="flatDischargeDiff != null">flat_discharge_diff,</if>
|
||||
<if test="valleyChargeDiff != null">valley_charge_diff,</if>
|
||||
<if test="valleyDischargeDiff != null">valley_discharge_diff,</if>
|
||||
<if test="calcTime != null">calc_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="siteId != null">#{siteId},</if>
|
||||
<if test="dataDate != null">#{dataDate},</if>
|
||||
<if test="peakChargeDiff != null">#{peakChargeDiff},</if>
|
||||
<if test="peakDischargeDiff != null">#{peakDischargeDiff},</if>
|
||||
<if test="highChargeDiff != null">#{highChargeDiff},</if>
|
||||
<if test="highDischargeDiff != null">#{highDischargeDiff},</if>
|
||||
<if test="flatChargeDiff != null">#{flatChargeDiff},</if>
|
||||
<if test="flatDischargeDiff != null">#{flatDischargeDiff},</if>
|
||||
<if test="valleyChargeDiff != null">#{valleyChargeDiff},</if>
|
||||
<if test="valleyDischargeDiff != null">#{valleyDischargeDiff},</if>
|
||||
<if test="calcTime != null">#{calcTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateEmsDailyEnergyData" parameterType="EmsDailyEnergyData">
|
||||
update ems_daily_energy_data
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="siteId != null">site_id = #{siteId},</if>
|
||||
<if test="dataDate != null">data_date = #{dataDate},</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>
|
||||
<if test="highDischargeDiff != null">high_discharge_diff = #{highDischargeDiff},</if>
|
||||
<if test="flatChargeDiff != null">flat_charge_diff = #{flatChargeDiff},</if>
|
||||
<if test="flatDischargeDiff != null">flat_discharge_diff = #{flatDischargeDiff},</if>
|
||||
<if test="valleyChargeDiff != null">valley_charge_diff = #{valleyChargeDiff},</if>
|
||||
<if test="valleyDischargeDiff != null">valley_discharge_diff = #{valleyDischargeDiff},</if>
|
||||
<if test="calcTime != null">calc_time = #{calcTime},</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>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteEmsDailyEnergyDataById" parameterType="Long">
|
||||
delete from ems_daily_energy_data where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteEmsDailyEnergyDataByIds" parameterType="String">
|
||||
delete from ems_daily_energy_data where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="getDataByDate" parameterType="String" resultMap="EmsDailyEnergyDataResult">
|
||||
<include refid="selectEmsDailyEnergyDataVo"/>
|
||||
where data_date = #{today}
|
||||
AND site_id = #{siteId}
|
||||
</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="peakChargeDiff != null">peak_charge_diff,</if>
|
||||
<if test="peakDischargeDiff != null">peak_discharge_diff,</if>
|
||||
<if test="highChargeDiff != null">high_charge_diff,</if>
|
||||
<if test="highDischargeDiff != null">high_discharge_diff,</if>
|
||||
<if test="flatChargeDiff != null">flat_charge_diff,</if>
|
||||
<if test="flatDischargeDiff != null">flat_discharge_diff,</if>
|
||||
<if test="valleyChargeDiff != null">valley_charge_diff,</if>
|
||||
<if test="valleyDischargeDiff != null">valley_discharge_diff,</if>
|
||||
calc_time,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
remark
|
||||
) VALUES (
|
||||
#{id},
|
||||
#{siteId},
|
||||
#{dataDate},
|
||||
<if test="peakChargeDiff != null">#{peakChargeDiff},</if>
|
||||
<if test="peakDischargeDiff != null">#{peakDischargeDiff},</if>
|
||||
<if test="highChargeDiff != null">#{highChargeDiff},</if>
|
||||
<if test="highDischargeDiff != null">#{highDischargeDiff},</if>
|
||||
<if test="flatChargeDiff != null">#{flatChargeDiff},</if>
|
||||
<if test="flatDischargeDiff != null">#{flatDischargeDiff},</if>
|
||||
<if test="valleyChargeDiff != null">#{valleyChargeDiff},</if>
|
||||
<if test="valleyDischargeDiff != null">#{valleyDischargeDiff},</if>
|
||||
#{calcTime},
|
||||
'system',
|
||||
NOW(),
|
||||
'system',
|
||||
NOW(),
|
||||
#{remark}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
<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>
|
||||
<if test="highDischargeDiff != null">high_discharge_diff = #{highDischargeDiff},</if>
|
||||
<if test="flatChargeDiff != null">flat_charge_diff = #{flatChargeDiff},</if>
|
||||
<if test="flatDischargeDiff != null">flat_discharge_diff = #{flatDischargeDiff},</if>
|
||||
<if test="valleyChargeDiff != null">valley_charge_diff = #{valleyChargeDiff},</if>
|
||||
<if test="valleyDischargeDiff != null">valley_discharge_diff = #{valleyDischargeDiff},</if>
|
||||
calc_time = #{calcTime},
|
||||
update_time = NOW();
|
||||
</insert>
|
||||
</mapper>
|
||||
@ -148,4 +148,14 @@
|
||||
where year = #{currentYear}
|
||||
and month = #{month}
|
||||
</select>
|
||||
|
||||
<select id="getTimeRangeByDate" resultType="com.xzzn.ems.domain.vo.EnergyPriceTimeRange">
|
||||
select t2.cost_type as costType,
|
||||
t2.start_time as startTime,
|
||||
t2.end_time as endTime
|
||||
from ems_energy_price_config t
|
||||
left join ems_price_time_config t2 on t.id = t2.price_id
|
||||
where t.`year` = #{currentYear}
|
||||
and t.`month` = #{currentMonth}
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user