oprava KV 1
Some checks failed
CI and deploy / migration-check (push) Failing after 13s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-05-26 14:57:52 +02:00
parent 96b16b9ff9
commit 19108002ca
4 changed files with 110 additions and 12 deletions

View File

@@ -71,6 +71,7 @@ declare
v_ref_buy_am_czk_kwh numeric;
v_ref_buy_pm_czk_kwh numeric;
v_purchase_pricing_mode text;
v_block_export_neg_sell boolean;
v_lookahead_slots int := 4;
v_grid_charge_cap_am int;
v_grid_charge_cap_pm int;
@@ -281,6 +282,13 @@ begin
v_purchase_pricing_mode := coalesce(v_purchase_pricing_mode, 'spot');
select coalesce(sgc.block_export_on_negative_sell, false)
into v_block_export_neg_sell
from ems.site_grid_connection sgc
where sgc.site_id = p_site_id;
v_block_export_neg_sell := coalesce(v_block_export_neg_sell, false);
v_per_slot_charge_wh := v_max_charge_w * v_charge_eff * 0.25;
v_per_slot_discharge_wh := v_max_discharge_w * v_discharge_eff * 0.25;
v_energy_to_fill := v_soc_max_wh - p_current_soc_wh;
@@ -853,15 +861,14 @@ begin
where (wk.interval_start at time zone 'Europe/Prague')::date = r_slot.plan_date
and extract(hour from wk.interval_start at time zone 'Europe/Prague')
>= v_evening_peak_start_hour
and wk.sell_price >= r_slot.evening_peak_sell - v_degrad_czk_kwh
and (
case
when v_purchase_pricing_mode = 'fixed' then
-- Večerní peak: vyvést i když sell < fixní buy (KV1), pokud je to denní maximum výkupu.
true
when v_purchase_pricing_mode = 'fixed'
and v_block_export_neg_sell then
-- KV1: fixní buy ~6,3; večerní sell často < buy — vývoz ve všech kladných sell slotech ≥17h.
wk.sell_price > 0
else
-- Spot (home-01): denní večerní maximum výkupu; sell často < buy v tomže slotu.
true
wk.sell_price >= r_slot.evening_peak_sell - v_degrad_czk_kwh
end
);
end if;