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.EmsBatteryStackMapper" >
<resultMap type= "EmsBatteryStack" id= "EmsBatteryStackResult" >
<result property= "id" column= "id" />
2025-12-05 18:16:50 +08:00
<result property= "dataUpdateTime" column= "data_update_time" />
2025-06-24 01:18:07 +08:00
<result property= "workStatus" column= "work_status" />
<result property= "pcsCommunicationStatus" column= "pcs_communication_status" />
<result property= "emsCommunicationStatus" column= "ems_communication_status" />
2025-07-02 11:40:23 +08:00
<result property= "operationStatus" column= "operation_status" />
<result property= "stackVoltage" column= "stack_voltage" />
<result property= "stackCurrent" column= "stack_current" />
<result property= "stackSoc" column= "stack_soc" />
<result property= "stackSoh" column= "stack_soh" />
2025-06-29 10:55:05 +08:00
<result property= "maxCellVoltage" column= "max_cell_voltage" />
2025-07-02 11:40:23 +08:00
<result property= "maxVoltageGroupId" column= "max_voltage_group_id" />
<result property= "maxVoltageCellId" column= "max_voltage_cell_id" />
2025-06-29 10:55:05 +08:00
<result property= "minCellVoltage" column= "min_cell_voltage" />
2025-07-02 11:40:23 +08:00
<result property= "minVoltageGroupId" column= "min_voltage_group_id" />
<result property= "minVoltageCellId" column= "min_voltage_cell_id" />
2025-06-29 10:55:05 +08:00
<result property= "maxCellTemp" column= "max_cell_temp" />
2025-07-02 11:40:23 +08:00
<result property= "maxTempGroupId" column= "max_temp_group_id" />
<result property= "maxTempCellId" column= "max_temp_cell_id" />
2025-06-29 10:55:05 +08:00
<result property= "minCellTemp" column= "min_cell_temp" />
2025-07-02 11:40:23 +08:00
<result property= "minTempGroupId" column= "min_temp_group_id" />
<result property= "minTempCellId" column= "min_temp_cell_id" />
<result property= "totalChargeCapacity" column= "total_charge_capacity" />
<result property= "totalDischargeCapacity" column= "total_discharge_capacity" />
<result property= "sessionChargeCapacity" column= "session_charge_capacity" />
<result property= "sessionDischargeCapacity" column= "session_discharge_capacity" />
<result property= "availableChargeCapacity" column= "available_charge_capacity" />
<result property= "availableDischargeCapacity" column= "available_discharge_capacity" />
<result property= "remainingDischargeTime" column= "remaining_discharge_time" />
<result property= "remainingChargeTime" column= "remaining_charge_time" />
<result property= "maxDischargePower" column= "max_discharge_power" />
<result property= "maxChargePower" column= "max_charge_power" />
<result property= "maxDischargeCurrent" column= "max_discharge_current" />
<result property= "maxChargeCurrent" column= "max_charge_current" />
<result property= "dailyDischargeCycles" column= "daily_discharge_cycles" />
<result property= "dailyChargeCycles" column= "daily_charge_cycles" />
<result property= "dailyDischargeCapacity" column= "daily_discharge_capacity" />
<result property= "dailyChargeCapacity" column= "daily_charge_capacity" />
<result property= "operatingTemp" column= "operating_temp" />
<result property= "bmsStatus" column= "bms_status" />
<result property= "bmsChargeStatus" column= "bms_charge_status" />
<result property= "stackInsulationResistance" column= "stack_insulation_resistance" />
<result property= "siteId" column= "site_id" />
<result property= "deviceId" column= "device_id" />
<result property= "createTime" column= "create_time" />
<result property= "createBy" column= "create_by" />
<result property= "updateTime" column= "update_time" />
<result property= "updateBy" column= "update_by" />
2025-07-27 17:34:38 +08:00
<result property= "batteryNumber" column= "battery_number" />
<result property= "batteryAvgVoltage" column= "battery_avg_voltage" />
<result property= "batteryDifferentPressure" column= "battery_different_pressure" />
<result property= "avgTemperature" column= "avg_temperature" />
<result property= "batteryDifferentTemperature" column= "battery_different_temperature" />
<result property= "maxInternalResistance" column= "max_internal_resistance" />
<result property= "minInternalResistance" column= "min_internal_resistance" />
<result property= "avgInternalResistance" column= "avg_internal_resistance" />
<result property= "batteryDefferentResistance" column= "battery_defferent_resistance" />
<result property= "maxResistanceCellId" column= "max_resistance_cell_id" />
<result property= "minResistanceCellId" column= "min_resistance_cell_id" />
<result property= "environmentTemperature" column= "environment_temperature" />
<result property= "environmentHumidity" column= "environment_humidity" />
<result property= "circuitBreakerStatus" column= "circuit_breaker_status" />
2025-06-24 01:18:07 +08:00
</resultMap>
<sql id= "selectEmsBatteryStackVo" >
2025-07-27 17:34:38 +08:00
select id, work_status, pcs_communication_status, ems_communication_status, operation_status, stack_voltage, stack_current, stack_soc, stack_soh, max_cell_voltage, max_voltage_group_id, max_voltage_cell_id, min_cell_voltage, min_voltage_group_id, min_voltage_cell_id, max_cell_temp, max_temp_group_id, max_temp_cell_id, min_cell_temp, min_temp_group_id, min_temp_cell_id, total_charge_capacity, total_discharge_capacity, session_charge_capacity, session_discharge_capacity, available_charge_capacity, available_discharge_capacity, remaining_discharge_time, remaining_charge_time, max_discharge_power, max_charge_power, max_discharge_current, max_charge_current, daily_discharge_cycles, daily_charge_cycles, daily_discharge_capacity, daily_charge_capacity, operating_temp, bms_status, bms_charge_status, stack_insulation_resistance, site_id, device_id, create_time, create_by, update_time, update_by, battery_number, battery_avg_voltage, battery_different_pressure, avg_temperature, battery_different_temperature, max_internal_resistance, min_internal_resistance, avg_internal_resistance, battery_defferent_resistance, max_resistance_cell_id, min_resistance_cell_id, environment_temperature, environment_humidity, circuit_breaker_status from ems_battery_stack
2025-06-24 01:18:07 +08:00
</sql>
<select id= "selectEmsBatteryStackList" parameterType= "EmsBatteryStack" resultMap= "EmsBatteryStackResult" >
<include refid= "selectEmsBatteryStackVo" />
<where >
2025-12-05 18:16:50 +08:00
<if test= "dataUpdateTime != null " > and data_update_time = #{dataUpdateTime}</if>
2025-06-24 01:18:07 +08:00
<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>
2025-07-02 11:40:23 +08:00
<if test= "operationStatus != null and operationStatus != ''" > and operation_status = #{operationStatus}</if>
<if test= "stackVoltage != null " > and stack_voltage = #{stackVoltage}</if>
<if test= "stackCurrent != null " > and stack_current = #{stackCurrent}</if>
<if test= "stackSoc != null " > and stack_soc = #{stackSoc}</if>
<if test= "stackSoh != null " > and stack_soh = #{stackSoh}</if>
2025-06-29 10:55:05 +08:00
<if test= "maxCellVoltage != null " > and max_cell_voltage = #{maxCellVoltage}</if>
2025-07-02 11:40:23 +08:00
<if test= "maxVoltageGroupId != null " > and max_voltage_group_id = #{maxVoltageGroupId}</if>
<if test= "maxVoltageCellId != null " > and max_voltage_cell_id = #{maxVoltageCellId}</if>
2025-06-29 10:55:05 +08:00
<if test= "minCellVoltage != null " > and min_cell_voltage = #{minCellVoltage}</if>
2025-07-02 11:40:23 +08:00
<if test= "minVoltageGroupId != null " > and min_voltage_group_id = #{minVoltageGroupId}</if>
<if test= "minVoltageCellId != null " > and min_voltage_cell_id = #{minVoltageCellId}</if>
2025-06-29 10:55:05 +08:00
<if test= "maxCellTemp != null " > and max_cell_temp = #{maxCellTemp}</if>
2025-07-02 11:40:23 +08:00
<if test= "maxTempGroupId != null " > and max_temp_group_id = #{maxTempGroupId}</if>
<if test= "maxTempCellId != null " > and max_temp_cell_id = #{maxTempCellId}</if>
2025-06-29 10:55:05 +08:00
<if test= "minCellTemp != null " > and min_cell_temp = #{minCellTemp}</if>
2025-07-02 11:40:23 +08:00
<if test= "minTempGroupId != null " > and min_temp_group_id = #{minTempGroupId}</if>
<if test= "minTempCellId != null " > and min_temp_cell_id = #{minTempCellId}</if>
<if test= "totalChargeCapacity != null " > and total_charge_capacity = #{totalChargeCapacity}</if>
<if test= "totalDischargeCapacity != null " > and total_discharge_capacity = #{totalDischargeCapacity}</if>
<if test= "sessionChargeCapacity != null " > and session_charge_capacity = #{sessionChargeCapacity}</if>
<if test= "sessionDischargeCapacity != null " > and session_discharge_capacity = #{sessionDischargeCapacity}</if>
<if test= "availableChargeCapacity != null " > and available_charge_capacity = #{availableChargeCapacity}</if>
<if test= "availableDischargeCapacity != null " > and available_discharge_capacity = #{availableDischargeCapacity}</if>
<if test= "remainingDischargeTime != null " > and remaining_discharge_time = #{remainingDischargeTime}</if>
<if test= "remainingChargeTime != null " > and remaining_charge_time = #{remainingChargeTime}</if>
<if test= "maxDischargePower != null " > and max_discharge_power = #{maxDischargePower}</if>
<if test= "maxChargePower != null " > and max_charge_power = #{maxChargePower}</if>
<if test= "maxDischargeCurrent != null " > and max_discharge_current = #{maxDischargeCurrent}</if>
<if test= "maxChargeCurrent != null " > and max_charge_current = #{maxChargeCurrent}</if>
<if test= "dailyDischargeCycles != null " > and daily_discharge_cycles = #{dailyDischargeCycles}</if>
<if test= "dailyChargeCycles != null " > and daily_charge_cycles = #{dailyChargeCycles}</if>
<if test= "dailyDischargeCapacity != null " > and daily_discharge_capacity = #{dailyDischargeCapacity}</if>
<if test= "dailyChargeCapacity != null " > and daily_charge_capacity = #{dailyChargeCapacity}</if>
<if test= "operatingTemp != null " > and operating_temp = #{operatingTemp}</if>
<if test= "bmsStatus != null and bmsStatus != ''" > and bms_status = #{bmsStatus}</if>
<if test= "bmsChargeStatus != null and bmsChargeStatus != ''" > and bms_charge_status = #{bmsChargeStatus}</if>
<if test= "stackInsulationResistance != null " > and stack_insulation_resistance = #{stackInsulationResistance}</if>
<if test= "siteId != null and siteId != ''" > and site_id = #{siteId}</if>
<if test= "deviceId != null and deviceId != ''" > and device_id = #{deviceId}</if>
2025-07-27 17:34:38 +08:00
<if test= "batteryNumber != null " > and battery_number = #{batteryNumber}</if>
<if test= "batteryAvgVoltage != null " > and battery_avg_voltage = #{batteryAvgVoltage}</if>
<if test= "batteryDifferentPressure != null " > and battery_different_pressure = #{batteryDifferentPressure}</if>
<if test= "avgTemperature != null " > and avg_temperature = #{avgTemperature}</if>
<if test= "batteryDifferentTemperature != null " > and battery_different_temperature = #{batteryDifferentTemperature}</if>
<if test= "maxInternalResistance != null " > and max_internal_resistance = #{maxInternalResistance}</if>
<if test= "minInternalResistance != null " > and min_internal_resistance = #{minInternalResistance}</if>
<if test= "avgInternalResistance != null " > and avg_internal_resistance = #{avgInternalResistance}</if>
<if test= "batteryDefferentResistance != null " > and battery_defferent_resistance = #{batteryDefferentResistance}</if>
<if test= "maxResistanceCellId != null " > and max_resistance_cell_id = #{maxResistanceCellId}</if>
<if test= "minResistanceCellId != null " > and min_resistance_cell_id = #{minResistanceCellId}</if>
<if test= "environmentTemperature != null " > and environment_temperature = #{environmentTemperature}</if>
<if test= "environmentHumidity != null " > and environment_humidity = #{environmentHumidity}</if>
<if test= "circuitBreakerStatus != null and circuitBreakerStatus != ''" > and circuit_breaker_status = #{circuitBreakerStatus}</if>
2025-06-24 01:18:07 +08:00
</where>
</select>
<select id= "selectEmsBatteryStackById" parameterType= "Long" resultMap= "EmsBatteryStackResult" >
<include refid= "selectEmsBatteryStackVo" />
where id = #{id}
</select>
<insert id= "insertEmsBatteryStack" parameterType= "EmsBatteryStack" useGeneratedKeys= "true" keyProperty= "id" >
insert into ems_battery_stack
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
2025-12-05 18:16:50 +08:00
<if test= "dataUpdateTime != null" > data_update_time,</if>
2025-06-24 01:18:07 +08:00
<if test= "workStatus != null" > work_status,</if>
<if test= "pcsCommunicationStatus != null" > pcs_communication_status,</if>
<if test= "emsCommunicationStatus != null" > ems_communication_status,</if>
2025-07-02 11:40:23 +08:00
<if test= "operationStatus != null" > operation_status,</if>
<if test= "stackVoltage != null" > stack_voltage,</if>
<if test= "stackCurrent != null" > stack_current,</if>
<if test= "stackSoc != null" > stack_soc,</if>
<if test= "stackSoh != null" > stack_soh,</if>
2025-06-29 10:55:05 +08:00
<if test= "maxCellVoltage != null" > max_cell_voltage,</if>
2025-07-02 11:40:23 +08:00
<if test= "maxVoltageGroupId != null" > max_voltage_group_id,</if>
<if test= "maxVoltageCellId != null" > max_voltage_cell_id,</if>
2025-06-29 10:55:05 +08:00
<if test= "minCellVoltage != null" > min_cell_voltage,</if>
2025-07-02 11:40:23 +08:00
<if test= "minVoltageGroupId != null" > min_voltage_group_id,</if>
<if test= "minVoltageCellId != null" > min_voltage_cell_id,</if>
2025-06-29 10:55:05 +08:00
<if test= "maxCellTemp != null" > max_cell_temp,</if>
2025-07-02 11:40:23 +08:00
<if test= "maxTempGroupId != null" > max_temp_group_id,</if>
<if test= "maxTempCellId != null" > max_temp_cell_id,</if>
2025-06-29 10:55:05 +08:00
<if test= "minCellTemp != null" > min_cell_temp,</if>
2025-07-02 11:40:23 +08:00
<if test= "minTempGroupId != null" > min_temp_group_id,</if>
<if test= "minTempCellId != null" > min_temp_cell_id,</if>
<if test= "totalChargeCapacity != null" > total_charge_capacity,</if>
<if test= "totalDischargeCapacity != null" > total_discharge_capacity,</if>
<if test= "sessionChargeCapacity != null" > session_charge_capacity,</if>
<if test= "sessionDischargeCapacity != null" > session_discharge_capacity,</if>
<if test= "availableChargeCapacity != null" > available_charge_capacity,</if>
<if test= "availableDischargeCapacity != null" > available_discharge_capacity,</if>
<if test= "remainingDischargeTime != null" > remaining_discharge_time,</if>
<if test= "remainingChargeTime != null" > remaining_charge_time,</if>
<if test= "maxDischargePower != null" > max_discharge_power,</if>
<if test= "maxChargePower != null" > max_charge_power,</if>
<if test= "maxDischargeCurrent != null" > max_discharge_current,</if>
<if test= "maxChargeCurrent != null" > max_charge_current,</if>
<if test= "dailyDischargeCycles != null" > daily_discharge_cycles,</if>
<if test= "dailyChargeCycles != null" > daily_charge_cycles,</if>
<if test= "dailyDischargeCapacity != null" > daily_discharge_capacity,</if>
<if test= "dailyChargeCapacity != null" > daily_charge_capacity,</if>
<if test= "operatingTemp != null" > operating_temp,</if>
<if test= "bmsStatus != null" > bms_status,</if>
<if test= "bmsChargeStatus != null" > bms_charge_status,</if>
<if test= "stackInsulationResistance != null" > stack_insulation_resistance,</if>
<if test= "siteId != null and siteId != ''" > site_id,</if>
<if test= "deviceId != null and deviceId != ''" > device_id,</if>
<if test= "createTime != null" > create_time,</if>
<if test= "createBy != null" > create_by,</if>
<if test= "updateTime != null" > update_time,</if>
<if test= "updateBy != null" > update_by,</if>
2025-07-27 17:34:38 +08:00
<if test= "batteryNumber != null" > battery_number,</if>
<if test= "batteryAvgVoltage != null" > battery_avg_voltage,</if>
<if test= "batteryDifferentPressure != null" > battery_different_pressure,</if>
<if test= "avgTemperature != null" > avg_temperature,</if>
<if test= "batteryDifferentTemperature != null" > battery_different_temperature,</if>
<if test= "maxInternalResistance != null" > max_internal_resistance,</if>
<if test= "minInternalResistance != null" > min_internal_resistance,</if>
<if test= "avgInternalResistance != null" > avg_internal_resistance,</if>
<if test= "batteryDefferentResistance != null" > battery_defferent_resistance,</if>
<if test= "maxResistanceCellId != null" > max_resistance_cell_id,</if>
<if test= "minResistanceCellId != null" > min_resistance_cell_id,</if>
<if test= "environmentTemperature != null" > environment_temperature,</if>
<if test= "environmentHumidity != null" > environment_humidity,</if>
<if test= "circuitBreakerStatus != null" > circuit_breaker_status,</if>
2025-06-24 01:18:07 +08:00
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
2025-12-05 18:16:50 +08:00
<if test= "dataUpdateTime != null" > #{dataUpdateTime},</if>
2025-06-24 01:18:07 +08:00
<if test= "workStatus != null" > #{workStatus},</if>
<if test= "pcsCommunicationStatus != null" > #{pcsCommunicationStatus},</if>
<if test= "emsCommunicationStatus != null" > #{emsCommunicationStatus},</if>
2025-07-02 11:40:23 +08:00
<if test= "operationStatus != null" > #{operationStatus},</if>
<if test= "stackVoltage != null" > #{stackVoltage},</if>
<if test= "stackCurrent != null" > #{stackCurrent},</if>
<if test= "stackSoc != null" > #{stackSoc},</if>
<if test= "stackSoh != null" > #{stackSoh},</if>
2025-06-29 10:55:05 +08:00
<if test= "maxCellVoltage != null" > #{maxCellVoltage},</if>
2025-07-02 11:40:23 +08:00
<if test= "maxVoltageGroupId != null" > #{maxVoltageGroupId},</if>
<if test= "maxVoltageCellId != null" > #{maxVoltageCellId},</if>
2025-06-29 10:55:05 +08:00
<if test= "minCellVoltage != null" > #{minCellVoltage},</if>
2025-07-02 11:40:23 +08:00
<if test= "minVoltageGroupId != null" > #{minVoltageGroupId},</if>
<if test= "minVoltageCellId != null" > #{minVoltageCellId},</if>
2025-06-29 10:55:05 +08:00
<if test= "maxCellTemp != null" > #{maxCellTemp},</if>
2025-07-02 11:40:23 +08:00
<if test= "maxTempGroupId != null" > #{maxTempGroupId},</if>
<if test= "maxTempCellId != null" > #{maxTempCellId},</if>
2025-06-29 10:55:05 +08:00
<if test= "minCellTemp != null" > #{minCellTemp},</if>
2025-07-02 11:40:23 +08:00
<if test= "minTempGroupId != null" > #{minTempGroupId},</if>
<if test= "minTempCellId != null" > #{minTempCellId},</if>
<if test= "totalChargeCapacity != null" > #{totalChargeCapacity},</if>
<if test= "totalDischargeCapacity != null" > #{totalDischargeCapacity},</if>
<if test= "sessionChargeCapacity != null" > #{sessionChargeCapacity},</if>
<if test= "sessionDischargeCapacity != null" > #{sessionDischargeCapacity},</if>
<if test= "availableChargeCapacity != null" > #{availableChargeCapacity},</if>
<if test= "availableDischargeCapacity != null" > #{availableDischargeCapacity},</if>
<if test= "remainingDischargeTime != null" > #{remainingDischargeTime},</if>
<if test= "remainingChargeTime != null" > #{remainingChargeTime},</if>
<if test= "maxDischargePower != null" > #{maxDischargePower},</if>
<if test= "maxChargePower != null" > #{maxChargePower},</if>
<if test= "maxDischargeCurrent != null" > #{maxDischargeCurrent},</if>
<if test= "maxChargeCurrent != null" > #{maxChargeCurrent},</if>
<if test= "dailyDischargeCycles != null" > #{dailyDischargeCycles},</if>
<if test= "dailyChargeCycles != null" > #{dailyChargeCycles},</if>
<if test= "dailyDischargeCapacity != null" > #{dailyDischargeCapacity},</if>
<if test= "dailyChargeCapacity != null" > #{dailyChargeCapacity},</if>
<if test= "operatingTemp != null" > #{operatingTemp},</if>
<if test= "bmsStatus != null" > #{bmsStatus},</if>
<if test= "bmsChargeStatus != null" > #{bmsChargeStatus},</if>
<if test= "stackInsulationResistance != null" > #{stackInsulationResistance},</if>
<if test= "siteId != null and siteId != ''" > #{siteId},</if>
<if test= "deviceId != null and deviceId != ''" > #{deviceId},</if>
<if test= "createTime != null" > #{createTime},</if>
<if test= "createBy != null" > #{createBy},</if>
<if test= "updateTime != null" > #{updateTime},</if>
<if test= "updateBy != null" > #{updateBy},</if>
2025-07-27 17:34:38 +08:00
<if test= "batteryNumber != null" > #{batteryNumber},</if>
<if test= "batteryAvgVoltage != null" > #{batteryAvgVoltage},</if>
<if test= "batteryDifferentPressure != null" > #{batteryDifferentPressure},</if>
<if test= "avgTemperature != null" > #{avgTemperature},</if>
<if test= "batteryDifferentTemperature != null" > #{batteryDifferentTemperature},</if>
<if test= "maxInternalResistance != null" > #{maxInternalResistance},</if>
<if test= "minInternalResistance != null" > #{minInternalResistance},</if>
<if test= "avgInternalResistance != null" > #{avgInternalResistance},</if>
<if test= "batteryDefferentResistance != null" > #{batteryDefferentResistance},</if>
<if test= "maxResistanceCellId != null" > #{maxResistanceCellId},</if>
<if test= "minResistanceCellId != null" > #{minResistanceCellId},</if>
<if test= "environmentTemperature != null" > #{environmentTemperature},</if>
<if test= "environmentHumidity != null" > #{environmentHumidity},</if>
<if test= "circuitBreakerStatus != null" > #{circuitBreakerStatus},</if>
2025-06-24 01:18:07 +08:00
</trim>
</insert>
<update id= "updateEmsBatteryStack" parameterType= "EmsBatteryStack" >
update ems_battery_stack
<trim prefix= "SET" suffixOverrides= "," >
2025-12-05 18:16:50 +08:00
<if test= "dataUpdateTime != null" > data_update_time = #{dataUpdateTime},</if>
2025-06-24 01:18:07 +08:00
<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>
2025-07-02 11:40:23 +08:00
<if test= "operationStatus != null" > operation_status = #{operationStatus},</if>
<if test= "stackVoltage != null" > stack_voltage = #{stackVoltage},</if>
<if test= "stackCurrent != null" > stack_current = #{stackCurrent},</if>
<if test= "stackSoc != null" > stack_soc = #{stackSoc},</if>
<if test= "stackSoh != null" > stack_soh = #{stackSoh},</if>
2025-06-29 10:55:05 +08:00
<if test= "maxCellVoltage != null" > max_cell_voltage = #{maxCellVoltage},</if>
2025-07-02 11:40:23 +08:00
<if test= "maxVoltageGroupId != null" > max_voltage_group_id = #{maxVoltageGroupId},</if>
<if test= "maxVoltageCellId != null" > max_voltage_cell_id = #{maxVoltageCellId},</if>
2025-06-29 10:55:05 +08:00
<if test= "minCellVoltage != null" > min_cell_voltage = #{minCellVoltage},</if>
2025-07-02 11:40:23 +08:00
<if test= "minVoltageGroupId != null" > min_voltage_group_id = #{minVoltageGroupId},</if>
<if test= "minVoltageCellId != null" > min_voltage_cell_id = #{minVoltageCellId},</if>
2025-06-29 10:55:05 +08:00
<if test= "maxCellTemp != null" > max_cell_temp = #{maxCellTemp},</if>
2025-07-02 11:40:23 +08:00
<if test= "maxTempGroupId != null" > max_temp_group_id = #{maxTempGroupId},</if>
<if test= "maxTempCellId != null" > max_temp_cell_id = #{maxTempCellId},</if>
2025-06-29 10:55:05 +08:00
<if test= "minCellTemp != null" > min_cell_temp = #{minCellTemp},</if>
2025-07-02 11:40:23 +08:00
<if test= "minTempGroupId != null" > min_temp_group_id = #{minTempGroupId},</if>
<if test= "minTempCellId != null" > min_temp_cell_id = #{minTempCellId},</if>
<if test= "totalChargeCapacity != null" > total_charge_capacity = #{totalChargeCapacity},</if>
<if test= "totalDischargeCapacity != null" > total_discharge_capacity = #{totalDischargeCapacity},</if>
<if test= "sessionChargeCapacity != null" > session_charge_capacity = #{sessionChargeCapacity},</if>
<if test= "sessionDischargeCapacity != null" > session_discharge_capacity = #{sessionDischargeCapacity},</if>
<if test= "availableChargeCapacity != null" > available_charge_capacity = #{availableChargeCapacity},</if>
<if test= "availableDischargeCapacity != null" > available_discharge_capacity = #{availableDischargeCapacity},</if>
<if test= "remainingDischargeTime != null" > remaining_discharge_time = #{remainingDischargeTime},</if>
<if test= "remainingChargeTime != null" > remaining_charge_time = #{remainingChargeTime},</if>
<if test= "maxDischargePower != null" > max_discharge_power = #{maxDischargePower},</if>
<if test= "maxChargePower != null" > max_charge_power = #{maxChargePower},</if>
<if test= "maxDischargeCurrent != null" > max_discharge_current = #{maxDischargeCurrent},</if>
<if test= "maxChargeCurrent != null" > max_charge_current = #{maxChargeCurrent},</if>
<if test= "dailyDischargeCycles != null" > daily_discharge_cycles = #{dailyDischargeCycles},</if>
<if test= "dailyChargeCycles != null" > daily_charge_cycles = #{dailyChargeCycles},</if>
<if test= "dailyDischargeCapacity != null" > daily_discharge_capacity = #{dailyDischargeCapacity},</if>
<if test= "dailyChargeCapacity != null" > daily_charge_capacity = #{dailyChargeCapacity},</if>
<if test= "operatingTemp != null" > operating_temp = #{operatingTemp},</if>
<if test= "bmsStatus != null" > bms_status = #{bmsStatus},</if>
<if test= "bmsChargeStatus != null" > bms_charge_status = #{bmsChargeStatus},</if>
<if test= "stackInsulationResistance != null" > stack_insulation_resistance = #{stackInsulationResistance},</if>
<if test= "siteId != null and siteId != ''" > site_id = #{siteId},</if>
<if test= "deviceId != null and deviceId != ''" > device_id = #{deviceId},</if>
<if test= "createTime != null" > create_time = #{createTime},</if>
<if test= "createBy != null" > create_by = #{createBy},</if>
<if test= "updateTime != null" > update_time = #{updateTime},</if>
<if test= "updateBy != null" > update_by = #{updateBy},</if>
2025-07-27 17:34:38 +08:00
<if test= "batteryNumber != null" > battery_number = #{batteryNumber},</if>
<if test= "batteryAvgVoltage != null" > battery_avg_voltage = #{batteryAvgVoltage},</if>
<if test= "batteryDifferentPressure != null" > battery_different_pressure = #{batteryDifferentPressure},</if>
<if test= "avgTemperature != null" > avg_temperature = #{avgTemperature},</if>
<if test= "batteryDifferentTemperature != null" > battery_different_temperature = #{batteryDifferentTemperature},</if>
<if test= "maxInternalResistance != null" > max_internal_resistance = #{maxInternalResistance},</if>
<if test= "minInternalResistance != null" > min_internal_resistance = #{minInternalResistance},</if>
<if test= "avgInternalResistance != null" > avg_internal_resistance = #{avgInternalResistance},</if>
<if test= "batteryDefferentResistance != null" > battery_defferent_resistance = #{batteryDefferentResistance},</if>
<if test= "maxResistanceCellId != null" > max_resistance_cell_id = #{maxResistanceCellId},</if>
<if test= "minResistanceCellId != null" > min_resistance_cell_id = #{minResistanceCellId},</if>
<if test= "environmentTemperature != null" > environment_temperature = #{environmentTemperature},</if>
<if test= "environmentHumidity != null" > environment_humidity = #{environmentHumidity},</if>
<if test= "circuitBreakerStatus != null" > circuit_breaker_status = #{circuitBreakerStatus},</if>
2025-06-24 01:18:07 +08:00
</trim>
where id = #{id}
</update>
<delete id= "deleteEmsBatteryStackById" parameterType= "Long" >
delete from ems_battery_stack where id = #{id}
</delete>
<delete id= "deleteEmsBatteryStackByIds" parameterType= "String" >
delete from ems_battery_stack where id in
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
2025-07-07 22:15:01 +08:00
2025-09-25 14:53:17 +08:00
<select id= "getBatteryAveTempList" resultType= "com.xzzn.ems.domain.vo.BatteryAveTempVo" >
2026-01-23 19:11:13 +08:00
WITH ranked AS (
SELECT
*,
date_format(create_time, '%Y-%m-%d %H:00:00') + INTERVAL FLOOR(MINUTE(create_time) / 5) * 5 MINUTE AS group_time,
ROW_NUMBER() OVER (PARTITION BY date_format(create_time, '%Y-%m-%d %H:00:00'), FLOOR(MINUTE(create_time) / 5) ORDER BY create_time) as rn
FROM
ems_battery_stack
where site_id = #{siteId}
and create_time > = #{startDate}
and create_time < DATE_ADD(#{endDate}, INTERVAL 1 DAY)
and avg_temperature is not null
)
SELECT
site_id,
round(avg(avg_temperature)) as batteryTemp,
DATE_FORMAT(group_time, '%Y-%m-%d') as dateDay,
DATE_FORMAT(group_time, '%H:%i:00') as createDate,
group_time as groupTime
FROM
ranked
GROUP BY site_id,groupTime
2025-07-07 22:15:01 +08:00
</select>
2025-07-08 14:46:42 +08:00
<sql id= "statisCommonFilter" >
WHERE p.site_id = #{siteId}
<if test= "startDate != null" >
2025-07-09 14:36:11 +08:00
AND p.update_time > = #{startDate}
2025-07-08 14:46:42 +08:00
</if>
<if test= "endDate != null" >
2025-07-09 14:36:11 +08:00
AND p.update_time < #{endDate}
2025-07-08 14:46:42 +08:00
</if>
</sql>
<sql id= "dataTypeChooseFilter" >
<choose >
2025-07-09 22:41:14 +08:00
<when test= 'dataType == "1"' >
2025-07-08 14:46:42 +08:00
t.operating_temp AS temp
</when>
2025-07-09 22:41:14 +08:00
<when test= 'dataType == "2"' >
2025-07-08 14:46:42 +08:00
t.stack_voltage as voltage
</when>
2025-07-09 22:41:14 +08:00
<when test= 'dataType == "3"' >
2025-07-08 14:46:42 +08:00
t.stack_current as current
</when>
2025-07-09 22:41:14 +08:00
<when test= 'dataType == "4"' >
2025-07-08 14:46:42 +08:00
t.stack_soc as soc
</when>
2025-07-09 22:41:14 +08:00
<otherwise >
0 AS temp
</otherwise>
2025-07-08 14:46:42 +08:00
</choose>
</sql>
<select id= "getStackDataByHour" parameterType= "com.xzzn.ems.domain.vo.DateSearchRequest" resultType= "com.xzzn.ems.domain.vo.StackStatisListVo" >
select latest.dateHour as statisDate,
2025-09-14 22:44:10 +08:00
t.device_id as deviceId,
2025-07-08 14:46:42 +08:00
<include refid= "dataTypeChooseFilter" />
2025-09-16 00:31:58 +08:00
from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.update_time, '%H:00') AS dateHour,MAX(p.update_time) as max_update_time
2025-07-08 14:46:42 +08:00
FROM ems_battery_stack p
<include refid= "statisCommonFilter" />
GROUP BY p.site_id,p.device_id,dateHour
) latest inner join ems_battery_stack t ON latest.site_id = t.site_id
AND latest.device_id = t.device_id
AND latest.max_update_time = t.update_time
order by statisDate desc
</select>
<select id= "getStackDataByDay" parameterType= "com.xzzn.ems.domain.vo.DateSearchRequest" resultType= "com.xzzn.ems.domain.vo.StackStatisListVo" >
select latest.dateDay as statisDate,
2025-09-14 22:44:10 +08:00
t.device_id as deviceId,
2025-07-08 14:46:42 +08:00
<include refid= "dataTypeChooseFilter" />
from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.update_time, '%Y-%m-%d') AS dateDay,MAX(p.update_time) as max_update_time
FROM ems_battery_stack p
<include refid= "statisCommonFilter" />
GROUP BY p.site_id,p.device_id,dateDay
) latest inner join ems_battery_stack t ON latest.site_id = t.site_id
AND latest.device_id = t.device_id
AND latest.max_update_time = t.update_time
order by statisDate desc
</select>
<select id= "getStackDataByMonth" parameterType= "com.xzzn.ems.domain.vo.DateSearchRequest" resultType= "com.xzzn.ems.domain.vo.StackStatisListVo" >
select latest.dateMonth as statisDate,
2025-09-14 22:44:10 +08:00
t.device_id as deviceId,
2025-07-08 14:46:42 +08:00
<include refid= "dataTypeChooseFilter" />
from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.update_time, '%Y-%m') AS dateMonth,MAX(p.update_time) as max_update_time
FROM ems_battery_stack p
<include refid= "statisCommonFilter" />
GROUP BY p.site_id,p.device_id,dateMonth
) latest inner join ems_battery_stack t ON latest.site_id = t.site_id
AND latest.device_id = t.device_id
AND latest.max_update_time = t.update_time
order by statisDate desc
</select>
2025-07-18 20:14:38 +08:00
<select id= "getSiteSumStackInfo" parameterType= "String" resultType= "com.xzzn.ems.domain.EmsBatteryStack" >
2025-09-12 04:40:47 +08:00
select AVG(t.stack_soc) as stackSoc,
AVG(t.stack_soh) as stackSoh
2025-07-18 20:14:38 +08:00
from ems_battery_stack t
INNER JOIN (
select p.site_id,p.device_id,MAX(p.create_time) as max_time
from ems_battery_stack p
where p.site_id = #{siteId}
group by p.site_id, p.device_id
) latest on t.site_id = latest.site_id
and t.device_id = latest.device_id
and t.create_time = latest.max_time
where t.site_id = #{siteId}
</select>
2025-09-16 00:31:58 +08:00
<select id= "getStackPointByHour" parameterType= "com.xzzn.ems.domain.vo.DateSearchRequest" resultType= "com.xzzn.ems.domain.vo.StackPointVo" >
select latest.dateHour as statisDate,
avg(t.stack_soc) as avgSoc,
avg(t.stack_soh) as avgSoh,
avg(t.avg_temperature) as avgTemp
2025-09-23 14:01:24 +08:00
from ( SELECT p.site_id, p.device_id, DATE_FORMAT(p.update_time, '%Y-%m-%d %H:00') AS dateHour,MAX(p.update_time) as max_update_time
2025-09-16 00:31:58 +08:00
FROM ems_battery_stack p
<include refid= "statisCommonFilter" />
GROUP BY p.site_id,p.device_id,dateHour
) latest inner join ems_battery_stack t ON latest.site_id = t.site_id
AND latest.device_id = t.device_id
AND latest.max_update_time = t.update_time
GROUP BY latest.dateHour
ORDER BY statisDate
</select>
<select id= "getStackPointByDay" parameterType= "com.xzzn.ems.domain.vo.DateSearchRequest" resultType= "com.xzzn.ems.domain.vo.StackPointVo" >
select latest.dateDay as statisDate,
avg(t.stack_soc) as avgSoc,
avg(t.stack_soh) as avgSoh,
avg(t.avg_temperature) as avgTemp
from ( SELECT p.site_id, p.device_id, DATE(p.update_time) AS dateDay,MAX(p.update_time) as max_update_time
FROM ems_battery_stack p
<include refid= "statisCommonFilter" />
GROUP BY p.site_id,p.device_id,dateDay
) latest inner join ems_battery_stack t ON latest.site_id = t.site_id
AND latest.device_id = t.device_id
AND latest.max_update_time = t.update_time
GROUP BY latest.dateDay
ORDER BY statisDate
</select>
<select id= "getStackPointByMonth" parameterType= "com.xzzn.ems.domain.vo.DateSearchRequest" resultType= "com.xzzn.ems.domain.vo.StackPointVo" >
select latest.dateMonth as statisDate,
avg(t.stack_soc) as avgSoc,
avg(t.stack_soh) as avgSoh,
avg(t.avg_temperature) as avgTemp
from ( SELECT p.site_id, p.device_id, DATE_FORMAT(p.update_time, '%Y-%m') AS dateMonth,MAX(p.update_time) as max_update_time
FROM ems_battery_stack p
<include refid= "statisCommonFilter" />
GROUP BY p.site_id,p.device_id,dateMonth
) latest inner join ems_battery_stack t ON latest.site_id = t.site_id
AND latest.device_id = t.device_id
AND latest.max_update_time = t.update_time
GROUP BY latest.dateMonth
ORDER BY statisDate
</select>
2025-09-25 14:53:17 +08:00
2026-01-27 16:47:48 +08:00
<select id= "getStackPointByMinute" parameterType= "com.xzzn.ems.domain.vo.DateSearchRequest" resultType= "com.xzzn.ems.domain.vo.StackPointVo" >
WITH ranked AS (
SELECT
*,
date_format(p.update_time, '%Y-%m-%d %H:00:00') + INTERVAL FLOOR(MINUTE(p.update_time) / 5) * 5 MINUTE AS group_time,
ROW_NUMBER() OVER (PARTITION BY p.device_id, date_format(p.update_time, '%Y-%m-%d %H:00:00'), FLOOR(MINUTE(p.update_time) / 5) ORDER BY p.update_time) as rn
FROM
ems_battery_stack p
<include refid= "statisCommonFilter" />
)
SELECT
t.site_id,
DATE_FORMAT(t.group_time, '%Y-%m-%d %H:%i:%s') as statisDate,
avg(t.stack_soc) as avgSoc,
avg(t.stack_soh) as avgSoh,
avg(t.avg_temperature) as avgTemp
FROM
ranked as t
GROUP BY t.site_id, t.group_time
</select>
2025-09-25 14:53:17 +08:00
<select id= "getAveSocList" resultType= "com.xzzn.ems.domain.vo.BatteryAveSOCVo" >
2026-01-23 19:11:13 +08:00
WITH ranked AS (
SELECT
*,
date_format(create_time, '%Y-%m-%d %H:00:00') + INTERVAL FLOOR(MINUTE(create_time) / 5) * 5 MINUTE AS group_time,
ROW_NUMBER() OVER (PARTITION BY date_format(create_time, '%Y-%m-%d %H:00:00'), FLOOR(MINUTE(create_time) / 5) ORDER BY create_time) as rn
FROM
ems_battery_stack
where site_id = #{siteId}
and create_time > = #{startDate}
and create_time < DATE_ADD(#{endDate}, INTERVAL 1 DAY)
)
SELECT
site_id,
round(avg(stack_soc)) as batterySOC,
DATE_FORMAT(group_time, '%Y-%m-%d') as dateDay,
DATE_FORMAT(group_time, '%H:%i:00') as createDate,
group_time as groupTime
FROM
ranked
GROUP BY site_id,groupTime
2025-09-25 14:53:17 +08:00
</select>
2025-06-24 01:18:07 +08:00
</mapper>