Files
emsback/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml

172 lines
12 KiB
XML
Raw Normal View History

2025-06-24 01:18:07 +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.EmsBatteryClusterMapper">
<resultMap type="EmsBatteryCluster" id="EmsBatteryClusterResult">
<result property="id" column="id" />
<result property="workStatus" column="work_status" />
<result property="pcsCommunicationStatus" column="pcs_communication_status" />
<result property="emsCommunicationStatus" column="ems_communication_status" />
<result property="clusterVoltage" column="cluster_voltage" />
<result property="chargeableCapacity" column="chargeable_capacity" />
<result property="totalChargedCapacity" column="total_charged_capacity" />
<result property="clusterCurrent" column="cluster_current" />
<result property="dischargeableCapacity" column="dischargeable_capacity" />
<result property="totalDischargedCapacity" column="total_discharged_capacity" />
<result property="soh" column="soh" />
<result property="averageTemperature" column="average_temperature" />
<result property="insulationResistance" column="insulation_resistance" />
<result property="currentSoc" column="current_soc" />
<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" />
</resultMap>
<sql id="selectEmsBatteryClusterVo">
select id, work_status, pcs_communication_status, ems_communication_status, cluster_voltage, chargeable_capacity, total_charged_capacity, cluster_current, dischargeable_capacity, total_discharged_capacity, soh, average_temperature, insulation_resistance, current_soc, create_by, create_time, update_by, update_time, remark, site_id, device_id from ems_battery_cluster
</sql>
<select id="selectEmsBatteryClusterList" parameterType="EmsBatteryCluster" resultMap="EmsBatteryClusterResult">
<include refid="selectEmsBatteryClusterVo"/>
<where>
<if test="workStatus != null and workStatus != ''"> and work_status = #{workStatus}</if>
<if test="pcsCommunicationStatus != null and pcsCommunicationStatus != ''"> and pcs_communication_status = #{pcsCommunicationStatus}</if>
<if test="emsCommunicationStatus != null and emsCommunicationStatus != ''"> and ems_communication_status = #{emsCommunicationStatus}</if>
<if test="clusterVoltage != null "> and cluster_voltage = #{clusterVoltage}</if>
<if test="chargeableCapacity != null "> and chargeable_capacity = #{chargeableCapacity}</if>
<if test="totalChargedCapacity != null "> and total_charged_capacity = #{totalChargedCapacity}</if>
<if test="clusterCurrent != null "> and cluster_current = #{clusterCurrent}</if>
<if test="dischargeableCapacity != null "> and dischargeable_capacity = #{dischargeableCapacity}</if>
<if test="totalDischargedCapacity != null "> and total_discharged_capacity = #{totalDischargedCapacity}</if>
<if test="soh != null "> and soh = #{soh}</if>
<if test="averageTemperature != null "> and average_temperature = #{averageTemperature}</if>
<if test="insulationResistance != null "> and insulation_resistance = #{insulationResistance}</if>
<if test="currentSoc != null "> and current_soc = #{currentSoc}</if>
<if test="siteId != null "> and site_id = #{siteId}</if>
<if test="deviceId != null "> and device_id = #{deviceId}</if>
</where>
</select>
<select id="selectEmsBatteryClusterById" parameterType="Long" resultMap="EmsBatteryClusterResult">
<include refid="selectEmsBatteryClusterVo"/>
where id = #{id}
</select>
<insert id="insertEmsBatteryCluster" parameterType="EmsBatteryCluster" useGeneratedKeys="true" keyProperty="id">
insert into ems_battery_cluster
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="workStatus != null">work_status,</if>
<if test="pcsCommunicationStatus != null">pcs_communication_status,</if>
<if test="emsCommunicationStatus != null">ems_communication_status,</if>
<if test="clusterVoltage != null">cluster_voltage,</if>
<if test="chargeableCapacity != null">chargeable_capacity,</if>
<if test="totalChargedCapacity != null">total_charged_capacity,</if>
<if test="clusterCurrent != null">cluster_current,</if>
<if test="dischargeableCapacity != null">dischargeable_capacity,</if>
<if test="totalDischargedCapacity != null">total_discharged_capacity,</if>
<if test="soh != null">soh,</if>
<if test="averageTemperature != null">average_temperature,</if>
<if test="insulationResistance != null">insulation_resistance,</if>
<if test="currentSoc != null">current_soc,</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>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="workStatus != null">#{workStatus},</if>
<if test="pcsCommunicationStatus != null">#{pcsCommunicationStatus},</if>
<if test="emsCommunicationStatus != null">#{emsCommunicationStatus},</if>
<if test="clusterVoltage != null">#{clusterVoltage},</if>
<if test="chargeableCapacity != null">#{chargeableCapacity},</if>
<if test="totalChargedCapacity != null">#{totalChargedCapacity},</if>
<if test="clusterCurrent != null">#{clusterCurrent},</if>
<if test="dischargeableCapacity != null">#{dischargeableCapacity},</if>
<if test="totalDischargedCapacity != null">#{totalDischargedCapacity},</if>
<if test="soh != null">#{soh},</if>
<if test="averageTemperature != null">#{averageTemperature},</if>
<if test="insulationResistance != null">#{insulationResistance},</if>
<if test="currentSoc != null">#{currentSoc},</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>
</trim>
</insert>
<update id="updateEmsBatteryCluster" parameterType="EmsBatteryCluster">
update ems_battery_cluster
<trim prefix="SET" suffixOverrides=",">
<if test="workStatus != null">work_status = #{workStatus},</if>
<if test="pcsCommunicationStatus != null">pcs_communication_status = #{pcsCommunicationStatus},</if>
<if test="emsCommunicationStatus != null">ems_communication_status = #{emsCommunicationStatus},</if>
<if test="clusterVoltage != null">cluster_voltage = #{clusterVoltage},</if>
<if test="chargeableCapacity != null">chargeable_capacity = #{chargeableCapacity},</if>
<if test="totalChargedCapacity != null">total_charged_capacity = #{totalChargedCapacity},</if>
<if test="clusterCurrent != null">cluster_current = #{clusterCurrent},</if>
<if test="dischargeableCapacity != null">dischargeable_capacity = #{dischargeableCapacity},</if>
<if test="totalDischargedCapacity != null">total_discharged_capacity = #{totalDischargedCapacity},</if>
<if test="soh != null">soh = #{soh},</if>
<if test="averageTemperature != null">average_temperature = #{averageTemperature},</if>
<if test="insulationResistance != null">insulation_resistance = #{insulationResistance},</if>
<if test="currentSoc != null">current_soc = #{currentSoc},</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>
</trim>
where id = #{id}
</update>
<delete id="deleteEmsBatteryClusterById" parameterType="Long">
delete from ems_battery_cluster where id = #{id}
</delete>
<delete id="deleteEmsBatteryClusterByIds" parameterType="String">
delete from ems_battery_cluster where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
2025-06-25 11:27:53 +08:00
<select id="getBMSBatteryCluster" parameterType="Long" resultType="com.xzzn.ems.domain.vo.BMSBatteryClusterVo">
select td.device_name as deviceName, tmp.work_status as workStatus,
tmp.pcs_communication_status as pcsCommunicationStatus, tmp.ems_communication_status as emsCommunicationStatus,
tmp.cluster_voltage as clusterVoltage,tmp.chargeable_capacity as chargeableCapacity, tmp.total_charged_capacity as totalChargedCapacity,
tmp.cluster_current as clusterCurrent,tmp.dischargeable_capacity as dischargeableCapacity, tmp.total_discharged_capacity as totalDischargedCapacity,
tmp.soh as soh,tmp.average_temperature as averageTemperature,tmp.insulation_resistance as insulationResistance,
tmp.current_soc as currentSoc,tmp.site_id as siteId,tmp.device_id as deviceId
from ems_battery_cluster tmp left join ems_devices_setting td on tmp.device_id = td.id and tmp.site_id = td.site_id
where tmp.site_id = #{siteId}
and tmp.update_time = (select MAX(t.update_time) FROM ems_battery_cluster t where t.site_id = tmp.site_id
and t.device_id = tmp.device_id)
order by tmp.device_id
2025-06-24 01:18:07 +08:00
</select>
2025-06-27 10:14:15 +08:00
<select id="getBmsBatteryData" resultType="com.xzzn.ems.domain.vo.BMSBatteryDataList">
select t.cluster_voltage as clusterVoltage,t.cluster_current as clusterCurrent,
t.current_soc as currentSoc,MAX(tb.voltage) as maxVoltage,MIN(tb.voltage) as minVoltage,
MAX(tb.temperature) as maxTemperature,MIN(tb.temperature) as minTemperature,
tb.site_id as siteId,tb.cluster_device_id as clusterId,tb.device_id as stackDeviceId
from ems_battery_cluster t left join ems_battery_data tb on t.device_id = tb.cluster_device_id
where t.site_id = #{siteId} and t.stack_device_id = #{stackDeviceId}
and t.update_time = (select MAX(update_time) FROM ems_battery_cluster where site_id = t.site_id
and device_id = t.device_id and stack_device_id = t.stack_device_id)
group by t.cluster_voltage,t.cluster_current,t.current_soc,tb.site_id,tb.cluster_device_id,tb.device_id
</select>
2025-06-24 01:18:07 +08:00
</mapper>