2025-09-01 16:10:17 +08:00
|
|
|
<?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.EmsDailyChargeDataMapper">
|
|
|
|
|
|
|
|
|
|
<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="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="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
|
|
|
|
|
</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>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectEmsDailyChargeDataById" parameterType="Long" resultMap="EmsDailyChargeDataResult">
|
|
|
|
|
<include refid="selectEmsDailyChargeDataVo"/>
|
|
|
|
|
where id = #{id}
|
|
|
|
|
</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="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="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="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="updateEmsDailyChargeData" parameterType="EmsDailyChargeData">
|
|
|
|
|
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="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="deleteEmsDailyChargeDataById" parameterType="Long">
|
|
|
|
|
delete from ems_daily_charge_data where id = #{id}
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteEmsDailyChargeDataByIds" parameterType="String">
|
|
|
|
|
delete from ems_daily_charge_data where id in
|
|
|
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<insert id="insertOrUpdateData" parameterType="EmsDailyChargeData">
|
|
|
|
|
INSERT into ems_daily_charge_data (
|
|
|
|
|
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
|
|
|
|
|
) values (
|
|
|
|
|
#{id},
|
|
|
|
|
#{siteId},
|
|
|
|
|
#{deviceId},
|
|
|
|
|
#{dateTime},
|
|
|
|
|
#{totalChargeData},
|
|
|
|
|
#{totalDischargeData},
|
|
|
|
|
#{chargeData},
|
|
|
|
|
#{dischargeData},
|
|
|
|
|
#{createBy},
|
|
|
|
|
#{createTime},
|
|
|
|
|
#{updateBy},
|
|
|
|
|
#{updateTime},
|
|
|
|
|
#{remark}
|
|
|
|
|
)
|
|
|
|
|
on duplicate key update
|
|
|
|
|
total_charge_Data = #{totalChargeData},
|
|
|
|
|
total_discharge_Data = #{totalDischargeData},
|
|
|
|
|
charge_data = #{chargeData},
|
|
|
|
|
discharge_data = #{dischargeData},
|
|
|
|
|
update_time = NOW()
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<select id="getAllSiteChargeData" resultType="map">
|
2025-09-12 04:40:47 +08:00
|
|
|
SELECT
|
|
|
|
|
SUM(t.total_charge_data) AS totalChargedCap,
|
|
|
|
|
SUM(t.total_discharge_data) AS totalDischargedCap
|
2025-09-01 16:10:17 +08:00
|
|
|
FROM ems_daily_charge_data t
|
2025-09-12 04:40:47 +08:00
|
|
|
LEFT JOIN ems_site_setting ss ON t.site_id = ss.site_id
|
|
|
|
|
INNER JOIN (
|
|
|
|
|
SELECT site_id,MAX(date_time) AS latest_date FROM ems_daily_charge_data
|
|
|
|
|
WHERE date_time <= #{nowData}
|
2025-09-01 16:10:17 +08:00
|
|
|
<if test="siteId != null">
|
2025-09-12 04:40:47 +08:00
|
|
|
and site_id = #{siteId}
|
2025-09-01 16:10:17 +08:00
|
|
|
</if>
|
2025-09-12 04:40:47 +08:00
|
|
|
AND total_charge_data IS NOT NULL
|
|
|
|
|
AND total_discharge_data IS NOT NULL
|
|
|
|
|
GROUP BY site_id
|
|
|
|
|
) AS latest ON t.date_time = latest.latest_date
|
|
|
|
|
and t.site_id = latest.site_id
|
|
|
|
|
<if test="siteId != null">
|
|
|
|
|
where t.site_id = #{siteId}
|
|
|
|
|
</if>
|
2025-09-01 16:10:17 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getSingleSiteChargeData" resultType="com.xzzn.ems.domain.vo.SiteMonitorDataVo">
|
2025-09-07 21:23:24 +08:00
|
|
|
SELECT SUM(t.charge_data) AS chargedCap,
|
|
|
|
|
SUM(t.discharge_data) AS disChargedCap,
|
|
|
|
|
t.date_time AS ammeterDate
|
2025-09-01 16:10:17 +08:00
|
|
|
FROM ems_daily_charge_data t
|
|
|
|
|
WHERE t.site_id = #{siteId}
|
|
|
|
|
AND t.date_time BETWEEN #{startDate} AND #{endDate}
|
2025-09-07 21:23:24 +08:00
|
|
|
group by ammeterDate
|
2025-09-01 16:10:17 +08:00
|
|
|
order by ammeterDate
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getTotalChargeDataByDay" resultType="com.xzzn.ems.domain.vo.SiteMonitorDataVo">
|
|
|
|
|
SELECT t.date_time AS ammeterDate,
|
2025-09-12 04:40:47 +08:00
|
|
|
SUM(t.charge_data) as chargedCap,
|
|
|
|
|
SUM(t.discharge_data) as disChargedCap
|
2025-09-01 16:10:17 +08:00
|
|
|
FROM ems_daily_charge_data t
|
|
|
|
|
WHERE t.site_id = #{siteId}
|
|
|
|
|
AND t.date_time BETWEEN #{startDate} AND #{endDate}
|
2025-09-12 04:40:47 +08:00
|
|
|
group BY ammeterDate
|
2025-09-01 16:10:17 +08:00
|
|
|
order by ammeterDate
|
|
|
|
|
</select>
|
2025-09-12 04:40:47 +08:00
|
|
|
|
|
|
|
|
<select id="getTotalChargeDataByMonth" resultType="com.xzzn.ems.domain.vo.SiteMonitorDataVo">
|
|
|
|
|
SELECT
|
|
|
|
|
DATE_FORMAT(t.date_time, '%Y-%m') AS ammeterMonth,
|
|
|
|
|
SUM(t.charge_data) AS chargedCap,
|
|
|
|
|
SUM(t.discharge_data) AS disChargedCap
|
|
|
|
|
FROM ems_daily_charge_data t
|
|
|
|
|
WHERE t.site_id = #{siteId}
|
|
|
|
|
AND t.date_time BETWEEN #{startDate} AND #{endDate}
|
|
|
|
|
GROUP BY ammeterMonth
|
|
|
|
|
ORDER BY ammeterMonth
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getAllSiteChargeDataByMonth" resultType="com.xzzn.ems.domain.vo.ElectricIndexList">
|
|
|
|
|
SELECT
|
|
|
|
|
DATE_FORMAT(t.date_time, '%Y-%m') AS dateMonth,
|
|
|
|
|
SUM(t.charge_data) AS chargeEnergy,
|
|
|
|
|
SUM(t.discharge_data) AS disChargeEnergy
|
|
|
|
|
FROM ems_daily_charge_data t
|
|
|
|
|
GROUP BY dateMonth
|
|
|
|
|
ORDER BY dateMonth
|
|
|
|
|
</select>
|
2025-09-01 16:10:17 +08:00
|
|
|
</mapper>
|