从redis取数

This commit is contained in:
2025-07-02 16:08:50 +08:00
parent 170bae19f8
commit 8415e2749e
14 changed files with 289 additions and 346 deletions

View File

@ -309,33 +309,6 @@
</foreach>
</delete>
<select id="getBMSBatteryCluster" parameterType="String" 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,
tmp.avg_cell_voltage as avgVoltage,tmp.avg_cell_temp as avgTemp,tmp.avg_cell_temp as avgSoc,
tmp.max_cell_voltage as maxVoltage,tmp.max_cell_voltage_id as maxVoltageId,
tmp.min_cell_voltage as minVolatage,tmp.min_cell_voltage_id as minVoltageId,
tmp.max_cell_temp as maxTem,tmp.max_cell_temp_id as maxTempId,
tmp.min_cell_temp as minTemp,tmp.min_cell_temp_id as minTempId,
tmp.max_cell_soc as maxSoc,tmp.max_cell_soc_id as maxSocId,
tmp.min_cell_soc as minSoc,tmp.min_cell_soc_id as minSocId
from ems_battery_cluster tmp left join ems_devices_setting td on tmp.device_id = td.device_id and tmp.site_id = td.site_id
INNER JOIN (
SELECT p.site_id, p.device_id, MAX(p.update_time) AS max_update_time
FROM ems_battery_cluster p
WHERE p.site_id = #{siteId}
GROUP BY p.site_id,p.device_id
) latest on tmp.device_id = latest.device_id and tmp.update_time = latest.max_update_time
where tmp.site_id = #{siteId}
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,t.site_id as siteId,t.device_id as clusterId,

View File

@ -25,10 +25,11 @@
<result property="communicationStatus" column="communication_status" />
<result property="deviceId" column="device_id" />
<result property="parentId" column="parent_id" />
<result property="deviceCategory" column="device_category" />
</resultMap>
<sql id="selectEmsDevicesSettingVo">
select id, device_name, device_type, slave_id, timeout_ms, retries, ip_address, ip_port, serial_port, baud_rate, data_bits, stop_bits, parity, description, created_at, updated_at, site_id, communication_status, device_id, parent_id from ems_devices_setting
select id, device_name, device_type, slave_id, timeout_ms, retries, ip_address, ip_port, serial_port, baud_rate, data_bits, stop_bits, parity, description, created_at, updated_at, site_id, communication_status, device_id, parent_id, device_category from ems_devices_setting
</sql>
<select id="selectEmsDevicesSettingList" parameterType="EmsDevicesSetting" resultMap="EmsDevicesSettingResult">
@ -53,6 +54,7 @@
<if test="communicationStatus != null and communicationStatus != ''"> and communication_status = #{communicationStatus}</if>
<if test="deviceId != null and deviceId != ''"> and device_id = #{deviceId}</if>
<if test="parentId != null and parentId != ''"> and parent_id = #{parentId}</if>
<if test="deviceCategory != null and deviceCategory != ''"> and device_category = #{deviceCategory}</if>
</where>
</select>
@ -83,6 +85,7 @@
<if test="communicationStatus != null">communication_status,</if>
<if test="deviceId != null and deviceId != ''">device_id,</if>
<if test="parentId != null">parent_id,</if>
<if test="deviceCategory != null">device_category,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
@ -104,6 +107,7 @@
<if test="communicationStatus != null">#{communicationStatus},</if>
<if test="deviceId != null and deviceId != ''">#{deviceId},</if>
<if test="parentId != null">#{parentId},</if>
<if test="deviceCategory != null">#{deviceCategory},</if>
</trim>
</insert>
@ -129,6 +133,7 @@
<if test="communicationStatus != null">communication_status = #{communicationStatus},</if>
<if test="deviceId != null and deviceId != ''">device_id = #{deviceId},</if>
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="deviceCategory != null">device_category = #{deviceCategory},</if>
</trim>
where id = #{id}
</update>
@ -150,8 +155,8 @@
select distinct eb.device_id from ems_battery_stack eb where eb.site_id = #{siteId})
</select>
<select id="getAllClusterInfoByStackId" parameterType="String" resultType="java.util.Map">
select distinct t.device_id as id,t.device_name as deviceName from ems_devices_setting t where t.parent_id = #{stackDeviceId}
<select id="getDeviceInfoByParentId" parameterType="String" resultType="java.util.Map">
select distinct t.device_id as id,t.device_name as deviceName from ems_devices_setting t where t.parent_id = #{parentId}
</select>
<select id="getAllBatteryDeviceBySiteId" parameterType="String" resultType="com.xzzn.ems.domain.EmsDevicesSetting">
@ -161,4 +166,17 @@
from ems_devices_setting t INNER JOIN ems_ammeter_data e on t.site_id = e.site_id and t.device_id = e.device_id
where t.site_id = #{siteId}
</select>
<select id="getAllClusterInfoBySiteId" parameterType="String" resultType="java.util.Map">
select device_id as id,device_name as deviceName from ems_devices_setting
where device_id in (
select distinct eb.device_id from ems_battery_cluster eb where eb.site_id = #{siteId})
</select>
<select id="getDeviceInfosBySiteIdAndCategory" resultType="java.util.Map">
select DISTINCT device_id as id,
device_name as deviceName,
communication_status as communicationStatus
from ems_devices_setting where site_id = #{siteId} and device_category = #{deviceCategory}
</select>
</mapper>