202 lines
10 KiB
XML
202 lines
10 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">
|
||
|
|
<mapper namespace="com.xzzn.ems.mapper.EmsBatteryDataDayMapper">
|
||
|
|
|
||
|
|
<resultMap type="EmsBatteryDataDay" id="EmsBatteryDataDayResult">
|
||
|
|
<result property="id" column="id" />
|
||
|
|
<result property="batteryPack" column="battery_pack" />
|
||
|
|
<result property="batteryCluster" column="battery_cluster" />
|
||
|
|
<result property="batteryCellId" column="battery_cell_id" />
|
||
|
|
<result property="voltage" column="voltage" />
|
||
|
|
<result property="temperature" column="temperature" />
|
||
|
|
<result property="soc" column="soc" />
|
||
|
|
<result property="soh" column="soh" />
|
||
|
|
<result property="dataTimestamp" column="data_timestamp" />
|
||
|
|
<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" />
|
||
|
|
<result property="siteId" column="site_id" />
|
||
|
|
<result property="deviceId" column="device_id" />
|
||
|
|
<result property="clusterDeviceId" column="cluster_device_id" />
|
||
|
|
<result property="interResistance" column="inter_resistance" />
|
||
|
|
<result property="dayTime" column="day_time" />
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
<sql id="selectEmsBatteryDataDayVo">
|
||
|
|
select id, battery_pack, battery_cluster, battery_cell_id, voltage, temperature, soc, soh, data_timestamp, create_by, create_time, update_by, update_time, remark, site_id, device_id, cluster_device_id, inter_resistance, day_time from ems_battery_data_day
|
||
|
|
</sql>
|
||
|
|
|
||
|
|
<select id="selectEmsBatteryDataDayList" parameterType="EmsBatteryDataDay" resultMap="EmsBatteryDataDayResult">
|
||
|
|
<include refid="selectEmsBatteryDataDayVo"/>
|
||
|
|
<where>
|
||
|
|
<if test="batteryPack != null and batteryPack != ''"> and battery_pack = #{batteryPack}</if>
|
||
|
|
<if test="batteryCluster != null and batteryCluster != ''"> and battery_cluster = #{batteryCluster}</if>
|
||
|
|
<if test="batteryCellId != null and batteryCellId != ''"> and battery_cell_id = #{batteryCellId}</if>
|
||
|
|
<if test="voltage != null "> and voltage = #{voltage}</if>
|
||
|
|
<if test="temperature != null "> and temperature = #{temperature}</if>
|
||
|
|
<if test="soc != null "> and soc = #{soc}</if>
|
||
|
|
<if test="soh != null "> and soh = #{soh}</if>
|
||
|
|
<if test="dataTimestamp != null "> and data_timestamp = #{dataTimestamp}</if>
|
||
|
|
<if test="siteId != null and siteId != ''"> and site_id = #{siteId}</if>
|
||
|
|
<if test="deviceId != null and deviceId != ''"> and device_id = #{deviceId}</if>
|
||
|
|
<if test="clusterDeviceId != null and clusterDeviceId != ''"> and cluster_device_id = #{clusterDeviceId}</if>
|
||
|
|
<if test="interResistance != null "> and inter_resistance = #{interResistance}</if>
|
||
|
|
<if test="dayTime != null "> and day_time = #{dayTime}</if>
|
||
|
|
</where>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="selectEmsBatteryDataDayById" parameterType="Long" resultMap="EmsBatteryDataDayResult">
|
||
|
|
<include refid="selectEmsBatteryDataDayVo"/>
|
||
|
|
where id = #{id}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<insert id="insertEmsBatteryDataDay" parameterType="EmsBatteryDataDay" useGeneratedKeys="true" keyProperty="id">
|
||
|
|
insert into ems_battery_data_day
|
||
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||
|
|
<if test="batteryPack != null">battery_pack,</if>
|
||
|
|
<if test="batteryCluster != null">battery_cluster,</if>
|
||
|
|
<if test="batteryCellId != null">battery_cell_id,</if>
|
||
|
|
<if test="voltage != null">voltage,</if>
|
||
|
|
<if test="temperature != null">temperature,</if>
|
||
|
|
<if test="soc != null">soc,</if>
|
||
|
|
<if test="soh != null">soh,</if>
|
||
|
|
<if test="dataTimestamp != null">data_timestamp,</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>
|
||
|
|
<if test="siteId != null">site_id,</if>
|
||
|
|
<if test="deviceId != null">device_id,</if>
|
||
|
|
<if test="clusterDeviceId != null">cluster_device_id,</if>
|
||
|
|
<if test="interResistance != null">inter_resistance,</if>
|
||
|
|
<if test="dayTime != null">day_time,</if>
|
||
|
|
</trim>
|
||
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||
|
|
<if test="batteryPack != null">#{batteryPack},</if>
|
||
|
|
<if test="batteryCluster != null">#{batteryCluster},</if>
|
||
|
|
<if test="batteryCellId != null">#{batteryCellId},</if>
|
||
|
|
<if test="voltage != null">#{voltage},</if>
|
||
|
|
<if test="temperature != null">#{temperature},</if>
|
||
|
|
<if test="soc != null">#{soc},</if>
|
||
|
|
<if test="soh != null">#{soh},</if>
|
||
|
|
<if test="dataTimestamp != null">#{dataTimestamp},</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>
|
||
|
|
<if test="siteId != null">#{siteId},</if>
|
||
|
|
<if test="deviceId != null">#{deviceId},</if>
|
||
|
|
<if test="clusterDeviceId != null">#{clusterDeviceId},</if>
|
||
|
|
<if test="interResistance != null">#{interResistance},</if>
|
||
|
|
<if test="dayTime != null">#{dayTime},</if>
|
||
|
|
</trim>
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<update id="updateEmsBatteryDataDay" parameterType="EmsBatteryDataDay">
|
||
|
|
update ems_battery_data_day
|
||
|
|
<trim prefix="SET" suffixOverrides=",">
|
||
|
|
<if test="batteryPack != null">battery_pack = #{batteryPack},</if>
|
||
|
|
<if test="batteryCluster != null">battery_cluster = #{batteryCluster},</if>
|
||
|
|
<if test="batteryCellId != null">battery_cell_id = #{batteryCellId},</if>
|
||
|
|
<if test="voltage != null">voltage = #{voltage},</if>
|
||
|
|
<if test="temperature != null">temperature = #{temperature},</if>
|
||
|
|
<if test="soc != null">soc = #{soc},</if>
|
||
|
|
<if test="soh != null">soh = #{soh},</if>
|
||
|
|
<if test="dataTimestamp != null">data_timestamp = #{dataTimestamp},</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>
|
||
|
|
<if test="siteId != null">site_id = #{siteId},</if>
|
||
|
|
<if test="deviceId != null">device_id = #{deviceId},</if>
|
||
|
|
<if test="clusterDeviceId != null">cluster_device_id = #{clusterDeviceId},</if>
|
||
|
|
<if test="interResistance != null">inter_resistance = #{interResistance},</if>
|
||
|
|
<if test="dayTime != null">day_time = #{dayTime},</if>
|
||
|
|
</trim>
|
||
|
|
where id = #{id}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<delete id="deleteEmsBatteryDataDayById" parameterType="Long">
|
||
|
|
delete from ems_battery_data_day where id = #{id}
|
||
|
|
</delete>
|
||
|
|
|
||
|
|
<delete id="deleteEmsBatteryDataDayByIds" parameterType="String">
|
||
|
|
delete from ems_battery_data_day where id in
|
||
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||
|
|
#{id}
|
||
|
|
</foreach>
|
||
|
|
</delete>
|
||
|
|
|
||
|
|
<select id="findDayMaxTemp" resultMap="EmsBatteryDataDayResult">
|
||
|
|
<include refid="selectEmsBatteryDataDayVo"/>
|
||
|
|
WHERE site_id = #{siteId}
|
||
|
|
AND battery_pack = #{stackId}
|
||
|
|
AND cluster_device_id = #{clusterId}
|
||
|
|
AND device_id = #{batteryId}
|
||
|
|
AND day_time = #{dayStart}
|
||
|
|
LIMIT 1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!-- 批量插入或更新-->
|
||
|
|
<insert id="batchInsertOrUpdate">
|
||
|
|
INSERT INTO ems_battery_data_day (
|
||
|
|
battery_pack,
|
||
|
|
battery_cluster,
|
||
|
|
battery_cell_id,
|
||
|
|
voltage,
|
||
|
|
temperature,
|
||
|
|
soc,
|
||
|
|
soh,
|
||
|
|
data_timestamp,
|
||
|
|
create_by,
|
||
|
|
create_time,
|
||
|
|
update_by,
|
||
|
|
update_time,
|
||
|
|
remark,
|
||
|
|
site_id,
|
||
|
|
device_id,
|
||
|
|
cluster_device_id,
|
||
|
|
inter_resistance,
|
||
|
|
day_time
|
||
|
|
) VALUES
|
||
|
|
<foreach collection="list" item="item" separator=",">
|
||
|
|
(
|
||
|
|
#{item.batteryPack},
|
||
|
|
#{item.batteryCluster},
|
||
|
|
#{item.batteryCellId},
|
||
|
|
#{item.voltage},
|
||
|
|
#{item.temperature},
|
||
|
|
#{item.soc},
|
||
|
|
#{item.soh},
|
||
|
|
#{item.dataTimestamp},
|
||
|
|
#{item.createBy},
|
||
|
|
#{item.createTime}, #{item.updateBy},
|
||
|
|
#{item.updateTime},
|
||
|
|
#{item.remark},
|
||
|
|
#{item.siteId},
|
||
|
|
#{item.deviceId},
|
||
|
|
#{item.clusterDeviceId},
|
||
|
|
#{item.interResistance},
|
||
|
|
#{item.dayTime}
|
||
|
|
)
|
||
|
|
</foreach>
|
||
|
|
ON DUPLICATE KEY UPDATE
|
||
|
|
-- 仅当新温度高于现有温度时,才更新温度和相关字段
|
||
|
|
update_time = IF(VALUES(temperature) > temperature, NOW(), update_time),
|
||
|
|
data_timestamp = IF(VALUES(temperature) > temperature, VALUES(data_timestamp), data_timestamp),
|
||
|
|
voltage = IF(VALUES(temperature) > temperature, VALUES(voltage), voltage),
|
||
|
|
soc = IF(VALUES(temperature) > temperature, VALUES(soc), soc),
|
||
|
|
soh = IF(VALUES(temperature) > temperature, VALUES(soh), soh),
|
||
|
|
inter_resistance = IF(VALUES(temperature) > temperature, VALUES(inter_resistance), inter_resistance),
|
||
|
|
update_by = IF(VALUES(temperature) > temperature, VALUES(update_by), update_by)
|
||
|
|
temperature = IF(VALUES(temperature) > temperature, VALUES(temperature), temperature)
|
||
|
|
</insert>
|
||
|
|
</mapper>
|