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, inter_resistance, current, day_time from ems_battery_data_day
insert into ems_battery_data_day
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,
inter_resistance,
current,
day_time,
#{batteryPack},
#{batteryCluster},
#{batteryCellId},
#{voltage},
#{temperature},
#{soc},
#{soh},
#{dataTimestamp},
#{createBy},
#{createTime},
#{updateBy},
#{updateTime},
#{remark},
#{siteId},
#{deviceId},
#{clusterDeviceId},
#{interResistance},
#{dayTime},
update ems_battery_data_day
battery_pack = #{batteryPack},
battery_cluster = #{batteryCluster},
battery_cell_id = #{batteryCellId},
voltage = #{voltage},
temperature = #{temperature},
soc = #{soc},
soh = #{soh},
data_timestamp = #{dataTimestamp},
create_by = #{createBy},
create_time = #{createTime},
update_by = #{updateBy},
update_time = #{updateTime},
remark = #{remark},
site_id = #{siteId},
device_id = #{deviceId},
cluster_device_id = #{clusterDeviceId},
inter_resistance = #{interResistance},
current = #{current},
day_time = #{dayTime},
where id = #{id}
delete from ems_battery_data_day where id = #{id}
delete from ems_battery_data_day where id in
#{id}
INSERT INTO ems_battery_data_day (
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,
inter_resistance,
current,
day_time
) VALUES
(
#{item.batteryPack},
#{item.batteryCluster},
#{item.batteryCellId},
#{item.voltage},
#{item.temperature},
#{item.soc},
#{item.soh},
#{item.dataTimestamp},
#{item.createBy},
#{item.createTime}, #{item.updateBy},
#{item.updateTime},
#{item.remark},
#{item.siteId},
#{item.deviceId},
#{item.clusterDeviceId},
#{item.interResistance},
#{item.current},
#{item.dayTime}
)
ON DUPLICATE KEY UPDATE
-- 仅当新温度高于现有温度时,才更新温度和相关字段
update_time = IF(VALUES(temperature) > temperature, NOW(), update_time),
data_timestamp = IF(VALUES(temperature) > temperature, VALUES(data_timestamp), data_timestamp),
voltage = IF(VALUES(temperature) > temperature, VALUES(voltage), voltage),
soc = IF(VALUES(temperature) > temperature, VALUES(soc), soc),
soh = IF(VALUES(temperature) > temperature, VALUES(soh), soh),
inter_resistance = IF(VALUES(temperature) > temperature, VALUES(inter_resistance), inter_resistance),
current = IF(VALUES(temperature) > temperature, VALUES(current), current),
update_by = IF(VALUES(temperature) > temperature, VALUES(update_by), update_by),
temperature = IF(VALUES(temperature) > temperature, VALUES(temperature), temperature)