select id, data_update_time, current_comb_active_total, current_comb_active_peak, current_comb_active_high, current_comb_active_flat, current_comb_active_valley, current_forward_active_total, current_forward_active_peak, current_forward_active_high, current_forward_active_flat, current_forward_active_valley, current_reverse_active_total, current_reverse_active_peak, current_reverse_active_high, current_reverse_active_flat, current_reverse_active_valley, current_comb_reactive_total, current_comb_reactive_peak, current_comb_reactive_high, current_comb_reactive_flat, current_comb_reactive_valley, current_forward_reactive_total, current_forward_reactive_peak, current_forward_reactive_high, current_forward_reactive_flat, current_forward_reactive_valley, current_reverse_reactive_total, current_reverse_reactive_peak, current_reverse_reactive_high, current_reverse_reactive_flat, current_reverse_reactive_valley, phase_a_voltage, phase_b_voltage, phase_c_voltage, phase_a_current, phase_b_current, phase_c_current, frequency, ab_line_voltage, cb_line_voltage, ac_line_voltage, forward_ac_max_demand, reverse_ac_max_demand, phase_a_active_power, phase_b_active_power, phase_c_active_power, total_active_power, phase_a_reactive_power, phase_b_reactive_power, phase_c_reactive_power, total_reactive_power, phase_a_apparent_power, phase_b_apparent_power, phase_c_apparent_power, total_apparent_power, phase_a_power_factor, phase_b_power_factor, phase_c_power_factor, total_power_factor, daily_forward_max_demand, site_id, device_id, create_by, create_time, update_by, update_time, remark, secondary_ab_line_voltage, secondary_a_phase_current, secondary_a_phase_voltage, secondary_a_power_factor, secondary_a_apparent_power, secondary_a_reactive_power, secondary_a_active_power, secondary_bc_line_voltage, secondary_b_phase_current, secondary_b_phase_voltage, secondary_b_power_factor, secondary_b_apparent_power, secondary_b_reactive_power, secondary_b_active_power, secondary_ca_line_voltage, secondary_c_phase_current, secondary_c_phase_voltage, secondary_c_power_factor, secondary_c_apparent_power, secondary_c_reactive_power, secondary_c_active_power, secondary_grid_frequency, secondary_reverse_reactive_energy, secondary_negative_active_energy, secondary_total_power_factor, secondary_total_apparent_power, secondary_total_reactive_power, secondary_positive_reactive_energy, secondary_positive_active_energy, secondary_total_active_power, reverse_reactive_energy_eq_minus, reverse_active_energy_ep_minus, positive_reactive_energy_eq_plus, positive_active_energy_ep_plus, current_percent, voltage_percent, avg_current, total_forward_active_two, total_peak_forward_active, total_high_forward_active, total_flat_forward_active, total_valley_forward_active, total_reverse_active_two, total_peak_reverse_active, total_high_reverse_active, total_flat_reverse_active, total_valley_reverse_active, disconnect_detection_indication, rated_primary_current_value, switch_input_output_status, alarm_status, current_total_voltage_percent, voltage_content_percent, voltage_ac_percent, current_total_current_percent, current_content_percent, current_ac_percent, current_total_power_percent, power_content_percent, power_ac_percent, data_setting_year_month, data_setting_day_hour, data_setting_minutes_seconds, current_rate, version_number, voltage, current, power, internal_temp, total_forward_active_one, total_reverse_active_one, forward_reactive_max_demand, reverse_reactive_max_demand, a_forward_active_energy, b_forward_active_energy, c_forward_active_energy, dido_status, running_status, zero_seq_current, voltage_unbalance_degree, current_unbalance_degree, daily_reverse_ac_max_demand, daily_forward_reac_max_demand, daily_reverse_reac_max_demand, pre_day_forward_ac_max_demand, pre_day_reverse_ac_max_demand, pre_day_forward_reac_max_demand, pre_day_reverse_reac_max_demand, pre_2d_forward_ac_max_demand, pre_2d_reverse_ac_max_demand, pre_2d_forward_reac_max_demand, pre_2d_reverse_reac_max_demand, current_forward_ac_demand, current_reverse_ac_demand, current_forward_reac_demand, current_reverse_reac_demand from ems_ammeter_data
insert into ems_ammeter_data
data_update_time,
current_comb_active_total,
current_comb_active_peak,
current_comb_active_high,
current_comb_active_flat,
current_comb_active_valley,
current_forward_active_total,
current_forward_active_peak,
current_forward_active_high,
current_forward_active_flat,
current_forward_active_valley,
current_reverse_active_total,
current_reverse_active_peak,
current_reverse_active_high,
current_reverse_active_flat,
current_reverse_active_valley,
current_comb_reactive_total,
current_comb_reactive_peak,
current_comb_reactive_high,
current_comb_reactive_flat,
current_comb_reactive_valley,
current_forward_reactive_total,
current_forward_reactive_peak,
current_forward_reactive_high,
current_forward_reactive_flat,
current_forward_reactive_valley,
current_reverse_reactive_total,
current_reverse_reactive_peak,
current_reverse_reactive_high,
current_reverse_reactive_flat,
current_reverse_reactive_valley,
phase_a_voltage,
phase_b_voltage,
phase_c_voltage,
phase_a_current,
phase_b_current,
phase_c_current,
frequency,
ab_line_voltage,
cb_line_voltage,
ac_line_voltage,
forward_ac_max_demand,
reverse_ac_max_demand,
phase_a_active_power,
phase_b_active_power,
phase_c_active_power,
total_active_power,
phase_a_reactive_power,
phase_b_reactive_power,
phase_c_reactive_power,
total_reactive_power,
phase_a_apparent_power,
phase_b_apparent_power,
phase_c_apparent_power,
total_apparent_power,
phase_a_power_factor,
phase_b_power_factor,
phase_c_power_factor,
total_power_factor,
daily_forward_max_demand,
site_id,
device_id,
create_by,
create_time,
update_by,
update_time,
remark,
secondary_ab_line_voltage,
secondary_a_phase_current,
secondary_a_phase_voltage,
secondary_a_power_factor,
secondary_a_apparent_power,
secondary_a_reactive_power,
secondary_a_active_power,
secondary_bc_line_voltage,
secondary_b_phase_current,
secondary_b_phase_voltage,
secondary_b_power_factor,
secondary_b_apparent_power,
secondary_b_reactive_power,
secondary_b_active_power,
secondary_ca_line_voltage,
secondary_c_phase_current,
secondary_c_phase_voltage,
secondary_c_power_factor,
secondary_c_apparent_power,
secondary_c_reactive_power,
secondary_c_active_power,
secondary_grid_frequency,
secondary_reverse_reactive_energy,
secondary_negative_active_energy,
secondary_total_power_factor,
secondary_total_apparent_power,
secondary_total_reactive_power,
secondary_positive_reactive_energy,
secondary_positive_active_energy,
secondary_total_active_power,
reverse_reactive_energy_eq_minus,
reverse_active_energy_ep_minus,
positive_reactive_energy_eq_plus,
positive_active_energy_ep_plus,
current_percent,
voltage_percent,
avg_current,
total_forward_active_two,
total_peak_forward_active,
total_high_forward_active,
total_flat_forward_active,
total_valley_forward_active,
total_reverse_active_two,
total_peak_reverse_active,
total_high_reverse_active,
total_flat_reverse_active,
total_valley_reverse_active,
disconnect_detection_indication,
rated_primary_current_value,
switch_input_output_status,
alarm_status,
current_total_voltage_percent,
voltage_content_percent,
voltage_ac_percent,
current_total_current_percent,
current_content_percent,
current_ac_percent,
current_total_power_percent,
power_content_percent,
power_ac_percent,
data_setting_year_month,
data_setting_day_hour,
data_setting_minutes_seconds,
current_rate,
version_number,
voltage,
current,
power,
internal_temp,
total_forward_active_one,
total_reverse_active_one,
forward_reactive_max_demand,
reverse_reactive_max_demand,
a_forward_active_energy,
b_forward_active_energy,
c_forward_active_energy,
dido_status,
running_status,
zero_seq_current,
voltage_unbalance_degree,
current_unbalance_degree,
daily_reverse_ac_max_demand,
daily_forward_reac_max_demand,
daily_reverse_reac_max_demand,
pre_day_forward_ac_max_demand,
pre_day_reverse_ac_max_demand,
pre_day_forward_reac_max_demand,
pre_day_reverse_reac_max_demand,
pre_2d_forward_ac_max_demand,
pre_2d_reverse_ac_max_demand,
pre_2d_forward_reac_max_demand,
pre_2d_reverse_reac_max_demand,
current_forward_ac_demand,
current_reverse_ac_demand,
current_forward_reac_demand,
current_reverse_reac_demand,
#{dataUpdateTime},
#{currentCombActiveTotal},
#{currentCombActivePeak},
#{currentCombActiveHigh},
#{currentCombActiveFlat},
#{currentCombActiveValley},
#{currentForwardActiveTotal},
#{currentForwardActivePeak},
#{currentForwardActiveHigh},
#{currentForwardActiveFlat},
#{currentForwardActiveValley},
#{currentReverseActiveTotal},
#{currentReverseActivePeak},
#{currentReverseActiveHigh},
#{currentReverseActiveFlat},
#{currentReverseActiveValley},
#{currentCombReactiveTotal},
#{currentCombReactivePeak},
#{currentCombReactiveHigh},
#{currentCombReactiveFlat},
#{currentCombReactiveValley},
#{currentForwardReactiveTotal},
#{currentForwardReactivePeak},
#{currentForwardReactiveHigh},
#{currentForwardReactiveFlat},
#{currentForwardReactiveValley},
#{currentReverseReactiveTotal},
#{currentReverseReactivePeak},
#{currentReverseReactiveHigh},
#{currentReverseReactiveFlat},
#{currentReverseReactiveValley},
#{phaseAVoltage},
#{phaseBVoltage},
#{phaseCVoltage},
#{phaseACurrent},
#{phaseBCurrent},
#{phaseCCurrent},
#{frequency},
#{abLineVoltage},
#{cbLineVoltage},
#{acLineVoltage},
#{forwardAcMaxDemand},
#{reverseAcMaxDemand},
#{phaseAActivePower},
#{phaseBActivePower},
#{phaseCActivePower},
#{totalActivePower},
#{phaseAReactivePower},
#{phaseBReactivePower},
#{phaseCReactivePower},
#{totalReactivePower},
#{phaseAApparentPower},
#{phaseBApparentPower},
#{phaseCApparentPower},
#{totalApparentPower},
#{phaseAPowerFactor},
#{phaseBPowerFactor},
#{phaseCPowerFactor},
#{totalPowerFactor},
#{dailyForwardMaxDemand},
#{siteId},
#{deviceId},
#{createBy},
#{createTime},
#{updateBy},
#{updateTime},
#{remark},
#{secondaryAbLineVoltage},
#{secondaryAPhaseCurrent},
#{secondaryAPhaseVoltage},
#{secondaryAPowerFactor},
#{secondaryAApparentPower},
#{secondaryAReactivePower},
#{secondaryAActivePower},
#{secondaryBcLineVoltage},
#{secondaryBPhaseCurrent},
#{secondaryBPhaseVoltage},
#{secondaryBPowerFactor},
#{secondaryBApparentPower},
#{secondaryBReactivePower},
#{secondaryBActivePower},
#{secondaryCaLineVoltage},
#{secondaryCPhaseCurrent},
#{secondaryCPhaseVoltage},
#{secondaryCPowerFactor},
#{secondaryCApparentPower},
#{secondaryCReactivePower},
#{secondaryCActivePower},
#{secondaryGridFrequency},
#{secondaryReverseReactiveEnergy},
#{secondaryNegativeActiveEnergy},
#{secondaryTotalPowerFactor},
#{secondaryTotalApparentPower},
#{secondaryTotalReactivePower},
#{secondaryPositiveReactiveEnergy},
#{secondaryPositiveActiveEnergy},
#{secondaryTotalActivePower},
#{reverseReactiveEnergyEqMinus},
#{reverseActiveEnergyEpMinus},
#{positiveReactiveEnergyEqPlus},
#{positiveActiveEnergyEpPlus},
#{currentPercent},
#{voltagePercent},
#{avgCurrent},
#{totalForwardActiveTwo},
#{totalPeakForwardActive},
#{totalHighForwardActive},
#{totalFlatForwardActive},
#{totalValleyForwardActive},
#{totalReverseActiveTwo},
#{totalPeakReverseActive},
#{totalHighReverseActive},
#{totalFlatReverseActive},
#{totalValleyReverseActive},
#{disconnectDetectionIndication},
#{ratedPrimaryCurrentValue},
#{switchInputOutputStatus},
#{alarmStatus},
#{currentTotalVoltagePercent},
#{voltageContentPercent},
#{voltageAcPercent},
#{currentTotalCurrentPercent},
#{currentContentPercent},
#{currentAcPercent},
#{currentTotalPowerPercent},
#{powerContentPercent},
#{powerAcPercent},
#{dataSettingYearMonth},
#{dataSettingDayHour},
#{dataSettingMinutesSeconds},
#{currentRate},
#{versionNumber},
#{voltage},
#{current},
#{power},
#{internalTemp},
#{totalForwardActiveOne},
#{totalReverseActiveOne},
#{forwardReactiveMaxDemand},
#{reverseReactiveMaxDemand},
#{aForwardActiveEnergy},
#{bForwardActiveEnergy},
#{cForwardActiveEnergy},
#{didoStatus},
#{runningStatus},
#{zeroSeqCurrent},
#{voltageUnbalanceDegree},
#{currentUnbalanceDegree},
#{dailyReverseAcMaxDemand},
#{dailyForwardReacMaxDemand},
#{dailyReverseReacMaxDemand},
#{preDayForwardAcMaxDemand},
#{preDayReverseAcMaxDemand},
#{preDayForwardReacMaxDemand},
#{preDayReverseReacMaxDemand},
#{pre2dForwardAcMaxDemand},
#{pre2dReverseAcMaxDemand},
#{pre2dForwardReacMaxDemand},
#{pre2dReverseReacMaxDemand},
#{currentForwardAcDemand},
#{currentReverseAcDemand},
#{currentForwardReacDemand},
#{currentReverseReacDemand},
update ems_ammeter_data
data_update_time = #{dataUpdateTime},
current_comb_active_total = #{currentCombActiveTotal},
current_comb_active_peak = #{currentCombActivePeak},
current_comb_active_high = #{currentCombActiveHigh},
current_comb_active_flat = #{currentCombActiveFlat},
current_comb_active_valley = #{currentCombActiveValley},
current_forward_active_total = #{currentForwardActiveTotal},
current_forward_active_peak = #{currentForwardActivePeak},
current_forward_active_high = #{currentForwardActiveHigh},
current_forward_active_flat = #{currentForwardActiveFlat},
current_forward_active_valley = #{currentForwardActiveValley},
current_reverse_active_total = #{currentReverseActiveTotal},
current_reverse_active_peak = #{currentReverseActivePeak},
current_reverse_active_high = #{currentReverseActiveHigh},
current_reverse_active_flat = #{currentReverseActiveFlat},
current_reverse_active_valley = #{currentReverseActiveValley},
current_comb_reactive_total = #{currentCombReactiveTotal},
current_comb_reactive_peak = #{currentCombReactivePeak},
current_comb_reactive_high = #{currentCombReactiveHigh},
current_comb_reactive_flat = #{currentCombReactiveFlat},
current_comb_reactive_valley = #{currentCombReactiveValley},
current_forward_reactive_total = #{currentForwardReactiveTotal},
current_forward_reactive_peak = #{currentForwardReactivePeak},
current_forward_reactive_high = #{currentForwardReactiveHigh},
current_forward_reactive_flat = #{currentForwardReactiveFlat},
current_forward_reactive_valley = #{currentForwardReactiveValley},
current_reverse_reactive_total = #{currentReverseReactiveTotal},
current_reverse_reactive_peak = #{currentReverseReactivePeak},
current_reverse_reactive_high = #{currentReverseReactiveHigh},
current_reverse_reactive_flat = #{currentReverseReactiveFlat},
current_reverse_reactive_valley = #{currentReverseReactiveValley},
phase_a_voltage = #{phaseAVoltage},
phase_b_voltage = #{phaseBVoltage},
phase_c_voltage = #{phaseCVoltage},
phase_a_current = #{phaseACurrent},
phase_b_current = #{phaseBCurrent},
phase_c_current = #{phaseCCurrent},
frequency = #{frequency},
ab_line_voltage = #{abLineVoltage},
cb_line_voltage = #{cbLineVoltage},
ac_line_voltage = #{acLineVoltage},
forward_ac_max_demand = #{forwardAcMaxDemand},
reverse_ac_max_demand = #{reverseAcMaxDemand},
phase_a_active_power = #{phaseAActivePower},
phase_b_active_power = #{phaseBActivePower},
phase_c_active_power = #{phaseCActivePower},
total_active_power = #{totalActivePower},
phase_a_reactive_power = #{phaseAReactivePower},
phase_b_reactive_power = #{phaseBReactivePower},
phase_c_reactive_power = #{phaseCReactivePower},
total_reactive_power = #{totalReactivePower},
phase_a_apparent_power = #{phaseAApparentPower},
phase_b_apparent_power = #{phaseBApparentPower},
phase_c_apparent_power = #{phaseCApparentPower},
total_apparent_power = #{totalApparentPower},
phase_a_power_factor = #{phaseAPowerFactor},
phase_b_power_factor = #{phaseBPowerFactor},
phase_c_power_factor = #{phaseCPowerFactor},
total_power_factor = #{totalPowerFactor},
daily_forward_max_demand = #{dailyForwardMaxDemand},
site_id = #{siteId},
device_id = #{deviceId},
create_by = #{createBy},
create_time = #{createTime},
update_by = #{updateBy},
update_time = #{updateTime},
remark = #{remark},
secondary_ab_line_voltage = #{secondaryAbLineVoltage},
secondary_a_phase_current = #{secondaryAPhaseCurrent},
secondary_a_phase_voltage = #{secondaryAPhaseVoltage},
secondary_a_power_factor = #{secondaryAPowerFactor},
secondary_a_apparent_power = #{secondaryAApparentPower},
secondary_a_reactive_power = #{secondaryAReactivePower},
secondary_a_active_power = #{secondaryAActivePower},
secondary_bc_line_voltage = #{secondaryBcLineVoltage},
secondary_b_phase_current = #{secondaryBPhaseCurrent},
secondary_b_phase_voltage = #{secondaryBPhaseVoltage},
secondary_b_power_factor = #{secondaryBPowerFactor},
secondary_b_apparent_power = #{secondaryBApparentPower},
secondary_b_reactive_power = #{secondaryBReactivePower},
secondary_b_active_power = #{secondaryBActivePower},
secondary_ca_line_voltage = #{secondaryCaLineVoltage},
secondary_c_phase_current = #{secondaryCPhaseCurrent},
secondary_c_phase_voltage = #{secondaryCPhaseVoltage},
secondary_c_power_factor = #{secondaryCPowerFactor},
secondary_c_apparent_power = #{secondaryCApparentPower},
secondary_c_reactive_power = #{secondaryCReactivePower},
secondary_c_active_power = #{secondaryCActivePower},
secondary_grid_frequency = #{secondaryGridFrequency},
secondary_reverse_reactive_energy = #{secondaryReverseReactiveEnergy},
secondary_negative_active_energy = #{secondaryNegativeActiveEnergy},
secondary_total_power_factor = #{secondaryTotalPowerFactor},
secondary_total_apparent_power = #{secondaryTotalApparentPower},
secondary_total_reactive_power = #{secondaryTotalReactivePower},
secondary_positive_reactive_energy = #{secondaryPositiveReactiveEnergy},
secondary_positive_active_energy = #{secondaryPositiveActiveEnergy},
secondary_total_active_power = #{secondaryTotalActivePower},
reverse_reactive_energy_eq_minus = #{reverseReactiveEnergyEqMinus},
reverse_active_energy_ep_minus = #{reverseActiveEnergyEpMinus},
positive_reactive_energy_eq_plus = #{positiveReactiveEnergyEqPlus},
positive_active_energy_ep_plus = #{positiveActiveEnergyEpPlus},
current_percent = #{currentPercent},
voltage_percent = #{voltagePercent},
avg_current = #{avgCurrent},
total_forward_active_two = #{totalForwardActiveTwo},
total_peak_forward_active = #{totalPeakForwardActive},
total_high_forward_active = #{totalHighForwardActive},
total_flat_forward_active = #{totalFlatForwardActive},
total_valley_forward_active = #{totalValleyForwardActive},
total_reverse_active_two = #{totalReverseActiveTwo},
total_peak_reverse_active = #{totalPeakReverseActive},
total_high_reverse_active = #{totalHighReverseActive},
total_flat_reverse_active = #{totalFlatReverseActive},
total_valley_reverse_active = #{totalValleyReverseActive},
disconnect_detection_indication = #{disconnectDetectionIndication},
rated_primary_current_value = #{ratedPrimaryCurrentValue},
switch_input_output_status = #{switchInputOutputStatus},
alarm_status = #{alarmStatus},
current_total_voltage_percent = #{currentTotalVoltagePercent},
voltage_content_percent = #{voltageContentPercent},
voltage_ac_percent = #{voltageAcPercent},
current_total_current_percent = #{currentTotalCurrentPercent},
current_content_percent = #{currentContentPercent},
current_ac_percent = #{currentAcPercent},
current_total_power_percent = #{currentTotalPowerPercent},
power_content_percent = #{powerContentPercent},
power_ac_percent = #{powerAcPercent},
data_setting_year_month = #{dataSettingYearMonth},
data_setting_day_hour = #{dataSettingDayHour},
data_setting_minutes_seconds = #{dataSettingMinutesSeconds},
current_rate = #{currentRate},
version_number = #{versionNumber},
voltage = #{voltage},
current = #{current},
power = #{power},
internal_temp = #{internalTemp},
total_forward_active_one = #{totalForwardActiveOne},
total_reverse_active_one = #{totalReverseActiveOne},
forward_reactive_max_demand = #{forwardReactiveMaxDemand},
reverse_reactive_max_demand = #{reverseReactiveMaxDemand},
a_forward_active_energy = #{aForwardActiveEnergy},
b_forward_active_energy = #{bForwardActiveEnergy},
c_forward_active_energy = #{cForwardActiveEnergy},
dido_status = #{didoStatus},
running_status = #{runningStatus},
zero_seq_current = #{zeroSeqCurrent},
voltage_unbalance_degree = #{voltageUnbalanceDegree},
current_unbalance_degree = #{currentUnbalanceDegree},
daily_reverse_ac_max_demand = #{dailyReverseAcMaxDemand},
daily_forward_reac_max_demand = #{dailyForwardReacMaxDemand},
daily_reverse_reac_max_demand = #{dailyReverseReacMaxDemand},
pre_day_forward_ac_max_demand = #{preDayForwardAcMaxDemand},
pre_day_reverse_ac_max_demand = #{preDayReverseAcMaxDemand},
pre_day_forward_reac_max_demand = #{preDayForwardReacMaxDemand},
pre_day_reverse_reac_max_demand = #{preDayReverseReacMaxDemand},
pre_2d_forward_ac_max_demand = #{pre2dForwardAcMaxDemand},
pre_2d_reverse_ac_max_demand = #{pre2dReverseAcMaxDemand},
pre_2d_forward_reac_max_demand = #{pre2dForwardReacMaxDemand},
pre_2d_reverse_reac_max_demand = #{pre2dReverseReacMaxDemand},
current_forward_ac_demand = #{currentForwardAcDemand},
current_reverse_ac_demand = #{currentReverseAcDemand},
current_forward_reac_demand = #{currentForwardReacDemand},
current_reverse_reac_demand = #{currentReverseReacDemand},
where id = #{id}
delete from ems_ammeter_data where id = #{id}
delete from ems_ammeter_data where id in
#{id}
MAX(CASE WHEN t.device_id = 'METE' THEN t.total_active_power END) AS storagePower,
MAX(CASE WHEN t.device_id = 'LOAD' THEN t.total_active_power END) AS gridPower,
MAX(CASE WHEN t.device_id = 'METEGF' THEN t.total_active_power END) AS pvPower
WHERE p.device_id in ('METE','LOAD','METEGF')
and p.site_id = #{siteId}
AND p.data_update_time >= #{startDate}
AND p.data_update_time < #{endDate}