单体电池-框架
This commit is contained in:
@ -157,4 +157,16 @@
|
||||
and t.device_id = tmp.device_id)
|
||||
order by tmp.device_id
|
||||
</select>
|
||||
|
||||
<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>
|
||||
</mapper>
|
@ -21,10 +21,11 @@
|
||||
<result property="remark" column="remark" />
|
||||
<result property="siteId" column="site_id" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="clusterDeviceId" column="cluster_device_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEmsBatteryDataVo">
|
||||
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 from ems_battery_data
|
||||
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 from ems_battery_data
|
||||
</sql>
|
||||
|
||||
<select id="selectEmsBatteryDataList" parameterType="EmsBatteryData" resultMap="EmsBatteryDataResult">
|
||||
@ -40,6 +41,7 @@
|
||||
<if test="dataTimestamp != null "> and data_timestamp = #{dataTimestamp}</if>
|
||||
<if test="siteId != null "> and site_id = #{siteId}</if>
|
||||
<if test="deviceId != null "> and device_id = #{deviceId}</if>
|
||||
<if test="clusterDeviceId != null "> and cluster_device_id = #{clusterDeviceId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@ -66,6 +68,7 @@
|
||||
<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>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="batteryPack != null">#{batteryPack},</if>
|
||||
@ -83,6 +86,7 @@
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="siteId != null">#{siteId},</if>
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="clusterDeviceId != null">#{clusterDeviceId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@ -104,6 +108,7 @@
|
||||
<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>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
@ -124,4 +129,51 @@
|
||||
where site_id = #{siteId}
|
||||
and DATE(data_timestamp) = DATE(NOW())
|
||||
</select>
|
||||
|
||||
<select id="getBatteryDataByClusterId" resultType="com.xzzn.ems.domain.vo.BatteryClusterDataDetailVo">
|
||||
select t.site_id as siteId,t.cluster_device_id as clusterId,
|
||||
AVG(t.voltage) as avgVoltage,MAX(t.voltage) as maxVoltage,MIN(t.voltage) as minVoltage,
|
||||
AVG(t.temperature) as avgTemp,MAX(t.temperature) as maxTemp,MIN(t.temperature) as minTemp,
|
||||
AVG(t.soc) as avgSoc,MAX(t.soc) as maxSoc,MIN(t.soc) as minSoc
|
||||
from ems_battery_data t
|
||||
where t.site_id = #{siteId}
|
||||
and t.cluster_device_id = #{clusterDeviceId}
|
||||
and t.update_time = (select MAX(update_time) FROM ems_battery_data where site_id = t.site_id
|
||||
and device_id = t.device_id and cluster_device_id = t.cluster_device_id)
|
||||
group by t.site_id,t.cluster_device_id
|
||||
</select>
|
||||
|
||||
<select id="getDataIdsMap" parameterType="com.xzzn.ems.domain.vo.BatteryClusterDataDetailVo" resultType="java.util.Map">
|
||||
<if test="maxVoltage != null">
|
||||
select 'maxVoltageId' as type, t.device_id from ems_battery_data t
|
||||
where t.site_id = #{siteId} and t.cluster_device_id = #{clusterId} and t.voltage = #{maxVoltage}
|
||||
union all
|
||||
</if>
|
||||
<if test="minVoltage != null">
|
||||
select 'minVoltageId' as type, t.device_id from ems_battery_data t
|
||||
where t.site_id = #{siteId} and t.cluster_device_id = #{clusterId} and t.voltage = #{minVoltage}
|
||||
union all
|
||||
</if>
|
||||
<if test="maxTemp != null">
|
||||
select 'maxTempId' as type, t.device_id from ems_battery_data t
|
||||
where t.site_id = #{siteId} and t.cluster_device_id = #{clusterId} and t.temperature = #{maxTemp}
|
||||
union all
|
||||
</if>
|
||||
<if test="minTemp != null">
|
||||
select 'minTempId' as type, t.device_id from ems_battery_data t
|
||||
where t.site_id = #{siteId} and t.cluster_device_id = #{clusterId} and t.temperature = #{minTemp}
|
||||
union all
|
||||
</if>
|
||||
<if test="maxSoc != null">
|
||||
select 'maxSocId' as type, t.device_id from ems_battery_data t
|
||||
where t.site_id = #{siteId} and t.cluster_device_id = #{clusterId} and t.soc = #{maxSoc}
|
||||
union all
|
||||
</if>
|
||||
<if test="minSoc != null">
|
||||
select 'minSocId' as type, t.device_id from ems_battery_data t
|
||||
where t.site_id = #{siteId} and t.cluster_device_id = #{clusterId} and t.soc = #{minSoc}
|
||||
union all
|
||||
</if>
|
||||
SELECT NULL AS type, NULL AS device_id FROM DUAL WHERE 1=0
|
||||
</select>
|
||||
</mapper>
|
@ -133,4 +133,16 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="getAllStackInfoBySiteId" parameterType="Long" resultType="java.util.Map">
|
||||
select id,device_name as deviceName from ems_devices_setting
|
||||
where id in (
|
||||
select distinct eb.device_id from ems_battery_stack eb where eb.site_id = #{siteId})
|
||||
</select>
|
||||
|
||||
<select id="getAllClusterInfoByStackId" parameterType="Long" resultType="java.util.Map">
|
||||
select id,device_name as deviceName
|
||||
from ems_devices_setting
|
||||
where id in (select distinct eb.device_id from ems_battery_cluster eb where eb.stack_device_id = #{stackDeviceId})
|
||||
</select>
|
||||
</mapper>
|
Reference in New Issue
Block a user