PCS+BMS总览+电池簇抽数逻辑

This commit is contained in:
2025-06-25 11:27:53 +08:00
parent 7b64e193fc
commit 46e0b94571
15 changed files with 643 additions and 67 deletions

View File

@ -144,8 +144,17 @@
</foreach>
</delete>
<select id="getBMSBatteryCluster" parameterType="Long" resultMap="EmsBatteryClusterResult">
<include refid="selectEmsBatteryClusterVo"/>
where site_id = #{siteId}
<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
</select>
</mapper>

View File

@ -144,8 +144,17 @@
</foreach>
</delete>
<select id="selectEmsBatteryStackBySiteId" parameterType="Long" resultMap="EmsBatteryStackResult">
<include refid="selectEmsBatteryStackVo"/>
where site_id = #{siteId} order by update_time desc limit 1
<select id="selectEmsBatteryStackBySiteId" parameterType="Long" resultType="com.xzzn.ems.domain.vo.BMSOverViewVo">
select td.device_name as deviceName,tmp.work_status as workStatus,
tmp.pcs_communication_status as pcsCommunicationStatus,tmp.ems_communication_status as emsCommunicationStatus,
tmp.total_voltage as totalVoltage,tmp.chargeable_capacity as chargeableCapacity,tmp.total_charged_capacity as totalChargedCapacity,
tmp.total_current as totalCurrent,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_stack 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_stack t where t.site_id = tmp.site_id
and t.device_id = tmp.device_id)
order by tmp.device_id
</select>
</mapper>

View File

@ -0,0 +1,136 @@
<?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.EmsDevicesSettingMapper">
<resultMap type="EmsDevicesSetting" id="EmsDevicesSettingResult">
<result property="id" column="id" />
<result property="deviceName" column="device_name" />
<result property="deviceType" column="device_type" />
<result property="slaveId" column="slave_id" />
<result property="timeoutMs" column="timeout_ms" />
<result property="retries" column="retries" />
<result property="ipAddress" column="ip_address" />
<result property="ipPort" column="ip_port" />
<result property="serialPort" column="serial_port" />
<result property="baudRate" column="baud_rate" />
<result property="dataBits" column="data_bits" />
<result property="stopBits" column="stop_bits" />
<result property="parity" column="parity" />
<result property="description" column="description" />
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
<result property="siteId" column="site_id" />
<result property="communicationStatus" column="communication_status" />
</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 from ems_devices_setting
</sql>
<select id="selectEmsDevicesSettingList" parameterType="EmsDevicesSetting" resultMap="EmsDevicesSettingResult">
<include refid="selectEmsDevicesSettingVo"/>
<where>
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
<if test="deviceType != null and deviceType != ''"> and device_type = #{deviceType}</if>
<if test="slaveId != null "> and slave_id = #{slaveId}</if>
<if test="timeoutMs != null "> and timeout_ms = #{timeoutMs}</if>
<if test="retries != null "> and retries = #{retries}</if>
<if test="ipAddress != null and ipAddress != ''"> and ip_address = #{ipAddress}</if>
<if test="ipPort != null "> and ip_port = #{ipPort}</if>
<if test="serialPort != null and serialPort != ''"> and serial_port = #{serialPort}</if>
<if test="baudRate != null "> and baud_rate = #{baudRate}</if>
<if test="dataBits != null "> and data_bits = #{dataBits}</if>
<if test="stopBits != null "> and stop_bits = #{stopBits}</if>
<if test="parity != null and parity != ''"> and parity = #{parity}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
<if test="createdAt != null "> and created_at = #{createdAt}</if>
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
<if test="siteId != null "> and site_id = #{siteId}</if>
<if test="communicationStatus != null and communicationStatus != ''"> and communication_status = #{communicationStatus}</if>
</where>
</select>
<select id="selectEmsDevicesSettingById" parameterType="Long" resultMap="EmsDevicesSettingResult">
<include refid="selectEmsDevicesSettingVo"/>
where id = #{id}
</select>
<insert id="insertEmsDevicesSetting" parameterType="EmsDevicesSetting" useGeneratedKeys="true" keyProperty="id">
insert into ems_devices_setting
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceName != null and deviceName != ''">device_name,</if>
<if test="deviceType != null and deviceType != ''">device_type,</if>
<if test="slaveId != null">slave_id,</if>
<if test="timeoutMs != null">timeout_ms,</if>
<if test="retries != null">retries,</if>
<if test="ipAddress != null">ip_address,</if>
<if test="ipPort != null">ip_port,</if>
<if test="serialPort != null">serial_port,</if>
<if test="baudRate != null">baud_rate,</if>
<if test="dataBits != null">data_bits,</if>
<if test="stopBits != null">stop_bits,</if>
<if test="parity != null">parity,</if>
<if test="description != null">description,</if>
<if test="createdAt != null">created_at,</if>
<if test="updatedAt != null">updated_at,</if>
<if test="siteId != null">site_id,</if>
<if test="communicationStatus != null">communication_status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
<if test="deviceType != null and deviceType != ''">#{deviceType},</if>
<if test="slaveId != null">#{slaveId},</if>
<if test="timeoutMs != null">#{timeoutMs},</if>
<if test="retries != null">#{retries},</if>
<if test="ipAddress != null">#{ipAddress},</if>
<if test="ipPort != null">#{ipPort},</if>
<if test="serialPort != null">#{serialPort},</if>
<if test="baudRate != null">#{baudRate},</if>
<if test="dataBits != null">#{dataBits},</if>
<if test="stopBits != null">#{stopBits},</if>
<if test="parity != null">#{parity},</if>
<if test="description != null">#{description},</if>
<if test="createdAt != null">#{createdAt},</if>
<if test="updatedAt != null">#{updatedAt},</if>
<if test="siteId != null">#{siteId},</if>
<if test="communicationStatus != null">#{communicationStatus},</if>
</trim>
</insert>
<update id="updateEmsDevicesSetting" parameterType="EmsDevicesSetting">
update ems_devices_setting
<trim prefix="SET" suffixOverrides=",">
<if test="deviceName != null and deviceName != ''">device_name = #{deviceName},</if>
<if test="deviceType != null and deviceType != ''">device_type = #{deviceType},</if>
<if test="slaveId != null">slave_id = #{slaveId},</if>
<if test="timeoutMs != null">timeout_ms = #{timeoutMs},</if>
<if test="retries != null">retries = #{retries},</if>
<if test="ipAddress != null">ip_address = #{ipAddress},</if>
<if test="ipPort != null">ip_port = #{ipPort},</if>
<if test="serialPort != null">serial_port = #{serialPort},</if>
<if test="baudRate != null">baud_rate = #{baudRate},</if>
<if test="dataBits != null">data_bits = #{dataBits},</if>
<if test="stopBits != null">stop_bits = #{stopBits},</if>
<if test="parity != null">parity = #{parity},</if>
<if test="description != null">description = #{description},</if>
<if test="createdAt != null">created_at = #{createdAt},</if>
<if test="updatedAt != null">updated_at = #{updatedAt},</if>
<if test="siteId != null">site_id = #{siteId},</if>
<if test="communicationStatus != null">communication_status = #{communicationStatus},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEmsDevicesSettingById" parameterType="Long">
delete from ems_devices_setting where id = #{id}
</delete>
<delete id="deleteEmsDevicesSettingByIds" parameterType="String">
delete from ems_devices_setting where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -268,9 +268,20 @@
group by dateMonth
</select>
<select id="getPcsDetailInfoBySiteId" parameterType="Long" resultMap="EmsPcsDataResult">
select tmp.*
from ems_pcs_data tmp
<select id="getPcsDetailInfoBySiteId" parameterType="Long" resultType="com.xzzn.ems.domain.vo.PcsDetailInfoVo">
select td.device_name as deviceName,td.communication_status as communicationStatus,
tmp.site_id as siteId,tmp.device_id as deviceId,
tmp.data_update_time as dataUpdateTime,tmp.work_status as workStatus,
tmp.grid_status as gridStatus,tmp.device_status as deviceStatus,tmp.control_mode as controlMode,
tmp.total_active_power as totalActivePower,tmp.daily_ac_charge_energy as dailyAcChargeEnergy,
tmp.a_phase_voltage as aPhaseVoltage,tmp.a_phase_current as aPhaseCurrent,
tmp.total_reactive_power as totalReactivePower,tmp.daily_ac_discharge_energy as dailyAcDischargeEnergy,
tmp.b_phase_voltage as bPhaseVoltage,tmp.b_phase_current as bPhaseCurrent,
tmp.total_apparent_power as totalApparentPower,tmp.pcs_module_temperature as pcsModuleTemperature,
tmp.c_phase_current as cPhaseVoltage,tmp.c_phase_current as cPhaseCurrent,
tmp.total_power_factor as totalPowerFactor,
tmp.pcs_environment_temperature as pcsEnvironmentTemperature,tmp.ac_frequency as acFrequency
from ems_pcs_data 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.data_update_time = (select MAX(data_update_time) FROM ems_pcs_data where site_id = tmp.site_id
and device_id = tmp.device_id)