fxi ba81 maximum price sell
Some checks failed
CI and deploy / migration-check (push) Failing after 11s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-04-29 15:45:23 +02:00
parent efc6e54f0e
commit 03ebc6246d
2 changed files with 3 additions and 20 deletions

View File

@@ -309,6 +309,7 @@ begin
v_discharge_target_wh := v_exportable * v_discharge_buf;
-- Rozpočet na půl dne (Europe/Prague): 00:0012:00 vs 12:0024:00; chybějící segment dostane celý budget.
-- Nabíjecí rozpočet dál dělíme 50/50 (kvůli rozprostření v rámci dne), ale exportní vybíjení volíme globálně podle sell_price.
select
coalesce(
count(*) filter (
@@ -328,18 +329,12 @@ begin
if v_n_am <= 0 then
v_chg_am_wh := 0;
v_chg_pm_wh := v_grid_target_wh;
v_dis_am_wh := 0;
v_dis_pm_wh := v_discharge_target_wh;
elsif v_n_pm <= 0 then
v_chg_am_wh := v_grid_target_wh;
v_chg_pm_wh := 0;
v_dis_am_wh := v_discharge_target_wh;
v_dis_pm_wh := 0;
else
v_chg_am_wh := v_grid_target_wh / 2.0;
v_chg_pm_wh := v_grid_target_wh - v_chg_am_wh;
v_dis_am_wh := v_discharge_target_wh / 2.0;
v_dis_pm_wh := v_discharge_target_wh - v_dis_am_wh;
end if;
-- charge mask (sloupce temp tabulky kvalifikujeme: RETURNS TABLE dělá PL proměnné stejných jmen)
@@ -390,22 +385,9 @@ begin
for r_slot in
select wk.slot_ord
from _ems_plan_slot_wk wk
where extract(hour from wk.interval_start at time zone 'Europe/Prague') < 12
order by wk.sell_price desc, wk.slot_ord desc
loop
exit when v_cum >= v_dis_am_wh;
exit when v_per_slot_discharge_wh <= 0;
update _ems_plan_slot_wk wk set allow_discharge_export = true where wk.slot_ord = r_slot.slot_ord;
v_cum := v_cum + v_per_slot_discharge_wh;
end loop;
v_cum := 0;
for r_slot in
select wk.slot_ord
from _ems_plan_slot_wk wk
where extract(hour from wk.interval_start at time zone 'Europe/Prague') >= 12
order by wk.sell_price desc, wk.slot_ord desc
loop
exit when v_cum >= v_dis_pm_wh;
exit when v_cum >= v_discharge_target_wh;
exit when v_per_slot_discharge_wh <= 0;
update _ems_plan_slot_wk wk set allow_discharge_export = true where wk.slot_ord = r_slot.slot_ord;
v_cum := v_cum + v_per_slot_discharge_wh;