diff --git a/projects/sviyagino_2026q1.yaml b/projects/sviyagino_2026q1.yaml index a55676b..5479730 100644 --- a/projects/sviyagino_2026q1.yaml +++ b/projects/sviyagino_2026q1.yaml @@ -21,23 +21,31 @@ price_level: coefficients: definitions: + # К_движение: п.1.1 Прил.28.1 + # 91-108 п/сут, скорость до 140 км/ч → K=1.40 + # TODO: уточнить реальное число поездов/сутки на участке! - key: dvizhenie - code: "2022-13-ГЭСН-ПР-28-01-1.1.8-000" - name: "Выполнение работ в условиях движения поездов для участков с размерами движения 91-108 поездов/сут" - value: 1.60 + code: "2022-13-ГЭСН-ПР-28-01-1.1-000" + name: "Выполнение работ в условиях движения поездов 91-108 п/сут (п.1.1)" + value: 1.40 apply_zt: true apply_em: true apply_ztm: true + # К_ВЛ: п.1.2 Прил.28.1 — к ОБЕИМ колонкам (ЗТ и ЭМ) - key: vl code: "2022-13-ГЭСН-ПР-28-01-1.2-000" name: "Производство работ вблизи объектов, находящихся под высоким напряжением" value: 1.20 - apply_zt: false + apply_zt: true apply_em: true apply_ztm: true + # К_окно: п.1.3 Прил.28.1 — ТОЛЬКО к ЭМ/ЗТм + # Значение 1.81 — для ЩОМ/ВПО/ПРСМ (28-01-031, 041, 067-072, 074, 077, 105) + # Значение 1.51 — для замены рельсов/РШР (28-01-037-040, 046-049, 053-054, 058-063, 107) + # Автоматически определяется по коду нормы в calc/coefficients.py - key: okno - code: "2022-13-ГЭСН-ПР-28-01-1.3.1-000" - name: "Производство работ с прекращением движения поездов по перегону (в «окно»)" + code: "2022-13-ГЭСН-ПР-28-01-1.3-000" + name: "Производство работ в «окно» (п.1.3, К=1.81/1.51 по норме)" value: 1.81 apply_zt: false apply_em: true @@ -58,6 +66,13 @@ overhead: nr_label: "НР (Железные дороги)" sp_label: "СП (Железные дороги)" +limited_costs: + temp_buildings_pct: 3.4 # ГСН 81-05-01-2001, п.3.2 (ж/д новое строительство) + temp_buildings_repair_coeff: 0.8 # для капремонта + winter_zone: "IV" # Приморский край (южная часть) + winter_pct: 2.2 # ГСН 81-05-02-2007, зона IV, ж/д работы + contingency_pct: 3.0 # резерв на непредвиденные (производственные объекты) + fgis: xlsx_path: "../fgis_split_form.xlsx" cache_path: "../fgis_cache.pkl" diff --git a/src/smeta_railway/calc/coefficients.py b/src/smeta_railway/calc/coefficients.py index b845c1a..fdca637 100644 --- a/src/smeta_railway/calc/coefficients.py +++ b/src/smeta_railway/calc/coefficients.py @@ -1,23 +1,64 @@ """ Complication coefficients for railway capital repair. Technical part GESN-2022, Collection 28 "Zheleznye dorogi". +Verified against Приложение 28.1 (ГЭСН 81-02-28-2020, rccs.ru PDF). Parameterized via ProjectConfig — coefficient values and exclusion rules come from YAML, not hardcoded. + +Key rules from Приложение 28.1: + п.1.1: К_движение applies to BOTH ЗТ (col 4) AND ЭМ/ЗТм (col 5) + п.1.2: К_ВЛ applies to BOTH ЗТ (col 4) AND ЭМ/ЗТм (col 5) + п.1.3: К_окно applies ONLY to ЭМ/ЗТм (col 5), "-" in col 4 + Two sub-values: + 1.81 — for 28-01-031, 041, 067÷072, 074, 077, 105 + 1.51 — for 28-01-037÷040, 046÷049, 053, 054, 058÷063, 107 """ from smeta_railway.config import CoefficientConfig, CoefficientDef from smeta_railway.models import Coefficients +# Norms where К_окно = 1.81 (ЩОМ, ВПО, ПРСМ, балластировочные, вакуумные) +OKNO_181_NORMS = [ + "28-01-031-", # выправка ВПО + "28-01-041-", # сварка ПРСМ + "28-01-067-", "28-01-068-", "28-01-069-", # глубокая очистка ЩОМ + "28-01-070-", "28-01-071-", "28-01-072-", # глубокая очистка (продолж.) + "28-01-074-", # срезка балласта + "28-01-077-", # удаление балласта вакуумной машиной + "28-01-105-", # профильная шлифовка +] + +# Norms where К_окно = 1.51 (замена рельсов, РШР, стрелочные) +OKNO_151_NORMS = [ + "28-01-037-", "28-01-038-", "28-01-039-", "28-01-040-", # замена рельсов + "28-01-046-", "28-01-047-", "28-01-048-", "28-01-049-", # замена РШР + "28-01-053-", "28-01-054-", # замена бесстыкового пути + "28-01-058-", "28-01-059-", "28-01-060-", # замена стрелочных переводов + "28-01-061-", "28-01-062-", "28-01-063-", # замена стрелочных (продолж.) + "28-01-107-", # погрузка рельсовых плетей +] + +# Norms excluded from К_окно (manual work, no path machines) +OKNO_EXCLUDED_NORMS = [ + "28-01-155-", # замена скреплений (ручные работы) + "28-01-043-", # резка рельсов рельсорезным станком + "28-01-044-", # изолирующие стыки + "28-01-073-", # очистка балласта вручную + "28-01-075-", # уборка балласта (бульдозер, не путевая машина) + "28-01-076-", # очистка кюветов +] + + # Default coefficient definitions (can be overridden via YAML) DEFAULT_COEFFICIENTS: list[dict] = [ { "key": "dvizhenie", - "code": "2022-13-ГЭСН-ПР-28-01-1.1.8-000", + "code": "2022-13-ГЭСН-ПР-28-01-1.1-000", "name": ("Выполнение работ в условиях движения поездов " - "для участков с размерами движения 91-108 поездов/сут"), - "value": 1.60, + "(Приложение 28.1, п.1.1)"), + "value": 1.40, # 91-108 п/сут, скорость до 140 км/ч "apply_zt": True, "apply_em": True, "apply_ztm": True, @@ -28,28 +69,24 @@ DEFAULT_COEFFICIENTS: list[dict] = [ "name": ("Производство работ вблизи объектов, " "находящихся под высоким напряжением"), "value": 1.20, - "apply_zt": False, + "apply_zt": True, # п.1.2: col 4 = 1.2 (BOTH labor and machines) "apply_em": True, "apply_ztm": True, }, { "key": "okno", - "code": "2022-13-ГЭСН-ПР-28-01-1.3.1-000", + "code": "2022-13-ГЭСН-ПР-28-01-1.3-000", "name": ("Производство работ с прекращением движения " 'поездов по перегону (в «окно»)'), - "value": 1.81, - "apply_zt": False, + "value": 1.81, # default, overridden per-norm below + "apply_zt": False, # п.1.3: "-" in col 4 (labor) "apply_em": True, "apply_ztm": True, }, ] DEFAULT_EXCLUDE_NORMS: dict[str, list[str]] = { - "okno": [ - "28-01-155-", # replacement of fastenings (manual work) - "28-01-043-", # rail cutting (manual machine) - "28-01-044-", # insulating joints (manual) - ], + "okno": OKNO_EXCLUDED_NORMS, } @@ -62,6 +99,16 @@ def get_default_config() -> CoefficientConfig: ) +def _get_okno_value(code: str, base_value: float) -> float: + """Determine К_окно value based on norm code (1.81 or 1.51).""" + if any(code.startswith(p) for p in OKNO_181_NORMS): + return 1.81 + if any(code.startswith(p) for p in OKNO_151_NORMS): + return 1.51 + # For norms not in either list but not excluded, use base_value + return base_value + + def get_coefficients( gesn_code: str, config: CoefficientConfig | None = None, @@ -101,16 +148,21 @@ def get_coefficients( if any(code.startswith(p) for p in excluded_prefixes): continue + # Determine actual coefficient value (okno has per-norm values) + value = cdef.value + if cdef.key == "okno": + value = _get_okno_value(code, cdef.value) + # Apply coefficient if cdef.apply_zt: - zt *= cdef.value - parts_zt.append(f"{cdef.value:.2f}") + zt *= value + parts_zt.append(f"{value:.2f}") if cdef.apply_em: - em *= cdef.value - parts_em.append(f"{cdef.value:.2f}") + em *= value + parts_em.append(f"{value:.2f}") if cdef.apply_ztm: - ztm *= cdef.value - parts_ztm.append(f"{cdef.value:.2f}") + ztm *= value + parts_ztm.append(f"{value:.2f}") applied.append(cdef.key) def formula(parts: list[str], result: float) -> str: diff --git a/src/smeta_railway/calc/estimate.py b/src/smeta_railway/calc/estimate.py index d31a0c4..ce655fc 100644 --- a/src/smeta_railway/calc/estimate.py +++ b/src/smeta_railway/calc/estimate.py @@ -14,6 +14,7 @@ from smeta_railway.calc.coefficients import ( from smeta_railway.calc.overhead import calc_overhead, get_overhead_percents from smeta_railway.config import ( CoefficientConfig, + LimitedCostsConfig, OverheadConfig, ProjectConfig, Section, @@ -42,11 +43,13 @@ class EstimateCalculator: resources: dict[str, NormResources], coeff_config: CoefficientConfig | None = None, overhead_config: OverheadConfig | None = None, + limited_costs_config: LimitedCostsConfig | None = None, ): self.fgis = fgis self.resources = resources self.coeff_config = coeff_config self.overhead_config = overhead_config + self.limited_costs_config = limited_costs_config or LimitedCostsConfig() def calculate(self, sections: list[Section]) -> EstimateResult: """Calculate entire estimate from sections list.""" @@ -75,6 +78,32 @@ class EstimateCalculator: result.grand_total = round( result.grand_pz + result.grand_nr + result.grand_sp, 2 ) + + # Лимитированные затраты + lc = self.limited_costs_config + smr = result.grand_total # СМР = ПЗ + НР + СП + + # Временные здания: % от СМР × коэфф. капремонта + result.temp_buildings_pct = round( + lc.temp_buildings_pct * lc.temp_buildings_repair_coeff, 2 + ) + result.temp_buildings = round(smr * result.temp_buildings_pct / 100, 2) + + # Зимнее удорожание + result.winter_cost_pct = lc.winter_pct + result.winter_cost = round(smr * lc.winter_pct / 100, 2) + + # Резерв на непредвиденные (от итога СМР + лимитированные) + base_for_contingency = smr + result.temp_buildings + result.winter_cost + result.contingency_pct = lc.contingency_pct + result.contingency = round( + base_for_contingency * lc.contingency_pct / 100, 2 + ) + + result.grand_total_with_limits = round( + smr + result.temp_buildings + result.winter_cost + result.contingency, 2 + ) + return result def _calc_position(self, item: WorkItem) -> PositionResult | None: diff --git a/src/smeta_railway/cli.py b/src/smeta_railway/cli.py index d18e405..7b6b185 100644 --- a/src/smeta_railway/cli.py +++ b/src/smeta_railway/cli.py @@ -60,6 +60,7 @@ def generate( resources=resources, coeff_config=config.coefficients, overhead_config=config.overhead, + limited_costs_config=config.limited_costs, ) estimate = calculator.calculate(config.sections) @@ -79,8 +80,13 @@ def generate( typer.echo(f"ФОТ: {estimate.grand_fot:>15,.2f}") typer.echo(f"НР: {estimate.grand_nr:>15,.2f}") typer.echo(f"СП: {estimate.grand_sp:>15,.2f}") - typer.echo(f"ИТОГО: {estimate.grand_total:>15,.2f}") - typer.echo(f" = {estimate.grand_total / 1000:,.2f} тыс.руб.") + typer.echo(f"ИТОГО СМР:{estimate.grand_total:>14,.2f}") + typer.echo(f"") + typer.echo(f"Врем.зд. ({estimate.temp_buildings_pct}%):{estimate.temp_buildings:>10,.2f}") + typer.echo(f"Зимнее ({estimate.winter_cost_pct}%): {estimate.winter_cost:>10,.2f}") + typer.echo(f"Резерв ({estimate.contingency_pct}%): {estimate.contingency:>10,.2f}") + typer.echo(f"ВСЕГО: {estimate.grand_total_with_limits:>15,.2f}") + typer.echo(f" = {estimate.grand_total_with_limits / 1000:,.2f} тыс.руб.") @app.command() diff --git a/src/smeta_railway/config.py b/src/smeta_railway/config.py index 062de15..e400950 100644 --- a/src/smeta_railway/config.py +++ b/src/smeta_railway/config.py @@ -80,6 +80,15 @@ class TransportItem(BaseModel): note: str = "" +class LimitedCostsConfig(BaseModel): + """Лимитированные затраты.""" + temp_buildings_pct: float = 3.4 # % от СМР (ГСН 81-05-01-2001, п.3.2 ж/д) + temp_buildings_repair_coeff: float = 0.8 # для капремонта + winter_zone: str = "IV" # температурная зона (Приморский край) + winter_pct: float = 2.2 # % от СМР (ГСН 81-05-02-2007, зона IV, ж/д) + contingency_pct: float = 3.0 # резерв на непредвиденные (≤3% производственные) + + class OutputConfig(BaseModel): format: str = "se27" filename: str = "smeta.xlsx" @@ -97,6 +106,7 @@ class ProjectConfig(BaseModel): coefficients: CoefficientConfig = Field(default_factory=CoefficientConfig) overhead: OverheadConfig = Field(default_factory=OverheadConfig) sections: list[Section] = Field(default_factory=list) + limited_costs: LimitedCostsConfig = Field(default_factory=LimitedCostsConfig) transport_prices: dict[str, float] = Field(default_factory=dict) fgis: FGISConfig = Field(default_factory=FGISConfig) output: OutputConfig = Field(default_factory=OutputConfig) diff --git a/src/smeta_railway/models.py b/src/smeta_railway/models.py index 7fed836..74736fe 100644 --- a/src/smeta_railway/models.py +++ b/src/smeta_railway/models.py @@ -89,3 +89,11 @@ class EstimateResult: grand_total: float = 0.0 grand_zt_hours: float = 0.0 grand_ztm_hours: float = 0.0 + # Лимитированные затраты + temp_buildings: float = 0.0 # Временные здания и сооружения + temp_buildings_pct: float = 0.0 + winter_cost: float = 0.0 # Зимнее удорожание + winter_cost_pct: float = 0.0 + contingency: float = 0.0 # Резерв на непредвиденные + contingency_pct: float = 0.0 + grand_total_with_limits: float = 0.0 # Итого с лимитированными diff --git a/tests/test_coefficients.py b/tests/test_coefficients.py index bf8b545..802ca46 100644 --- a/tests/test_coefficients.py +++ b/tests/test_coefficients.py @@ -1,4 +1,7 @@ -"""Tests for coefficient calculation.""" +"""Tests for coefficient calculation. + +Verified against Приложение 28.1 к ГЭСН 81-02-28-2020 (rccs.ru PDF). +""" import pytest @@ -8,39 +11,46 @@ from smeta_railway.calc.coefficients import get_coefficients class TestCoefficients: """Test coefficient calculation for various norm codes.""" - def test_full_coefficients_037(self): - """28-01-037-02: all 3 coefficients applied.""" + def test_037_okno_151(self): + """28-01-037-02 (замена рельсов): К_окно = 1.51, not 1.81.""" c = get_coefficients("ГЭСН 28-01-037-02") - assert c.zt == 1.60 - assert c.em == pytest.approx(1.60 * 1.20 * 1.81, rel=1e-3) - assert c.ztm == pytest.approx(1.60 * 1.20 * 1.81, rel=1e-3) + # ЗТ = dvizhenie(1.40) * vl(1.20) = 1.68 + assert c.zt == pytest.approx(1.40 * 1.20, rel=1e-3) + # ЭМ = dvizhenie(1.40) * vl(1.20) * okno(1.51) = 2.5368 + assert c.em == pytest.approx(1.40 * 1.20 * 1.51, rel=1e-3) assert set(c.applied) == {"dvizhenie", "vl", "okno"} - def test_full_coefficients_068(self): - """28-01-068-07: all 3 coefficients (machine norm).""" + def test_068_okno_181(self): + """28-01-068-07 (глубокая очистка ЩОМ): К_окно = 1.81.""" c = get_coefficients("ГЭСН 28-01-068-07") - assert c.zt == 1.60 - assert c.em == pytest.approx(3.4752, rel=1e-3) + # ЗТ = dvizhenie(1.40) * vl(1.20) = 1.68 + assert c.zt == pytest.approx(1.40 * 1.20, rel=1e-3) + # ЭМ = dvizhenie(1.40) * vl(1.20) * okno(1.81) = 3.0408 + assert c.em == pytest.approx(1.40 * 1.20 * 1.81, rel=1e-3) assert len(c.applied) == 3 + def test_031_okno_181(self): + """28-01-031-01 (выправка ВПО): К_окно = 1.81.""" + c = get_coefficients("ГЭСН 28-01-031-01") + assert c.em == pytest.approx(1.40 * 1.20 * 1.81, rel=1e-3) + def test_no_okno_155(self): - """28-01-155-01: manual work, no okno coefficient.""" + """28-01-155-01: manual work, excluded from okno.""" c = get_coefficients("ГЭСН 28-01-155-01") - assert c.zt == 1.60 - assert c.em == pytest.approx(1.60 * 1.20, rel=1e-3) - assert c.ztm == pytest.approx(1.60 * 1.20, rel=1e-3) + # ЗТ = dvizhenie(1.40) * vl(1.20) = 1.68 + assert c.zt == pytest.approx(1.40 * 1.20, rel=1e-3) + # ЭМ = dvizhenie(1.40) * vl(1.20) = 1.68 (no okno) + assert c.em == pytest.approx(1.40 * 1.20, rel=1e-3) assert "okno" not in c.applied - assert "dvizhenie" in c.applied - assert "vl" in c.applied def test_no_okno_043(self): - """28-01-043-01: rail cutting, no okno.""" + """28-01-043-01: rail cutting, excluded from okno.""" c = get_coefficients("ГЭСН 28-01-043-01") assert "okno" not in c.applied - assert c.em == pytest.approx(1.92, rel=1e-3) + assert c.em == pytest.approx(1.40 * 1.20, rel=1e-3) def test_no_okno_044(self): - """28-01-044-01: insulating joints, no okno.""" + """28-01-044-01: insulating joints, excluded from okno.""" c = get_coefficients("ГЭСН 28-01-044-01") assert "okno" not in c.applied @@ -52,19 +62,22 @@ class TestCoefficients: assert c.ztm == 1.0 assert c.applied == [] + def test_vl_applies_to_zt(self): + """К_ВЛ (п.1.2) applies to BOTH ЗТ and ЭМ per Приложение 28.1.""" + c = get_coefficients("ГЭСН 28-01-155-01") # no okno + # ЗТ should include vl: 1.40 * 1.20 = 1.68 + assert c.zt == pytest.approx(1.68, rel=1e-3) + assert "vl" in c.applied + def test_formulas_display(self): """Check formula strings for display.""" c = get_coefficients("ГЭСН 28-01-037-02") - assert "1.60" in c.formulas["zt"] - assert "1.20" in c.formulas["em"] - assert "1.81" in c.formulas["em"] + assert "1.40" in c.formulas["zt"] + assert "1.20" in c.formulas["zt"] + assert "1.51" in c.formulas["em"] # okno = 1.51 for 037 - def test_zt_only_dvizhenie(self): - """ZT gets only dvizhenie (not vl, not okno).""" - c = get_coefficients("ГЭСН 28-01-037-02") - assert c.zt == 1.60 # only dvizhenie - - def test_em_value(self): - """EM = 1.60 * 1.20 * 1.81 = 3.4752.""" - c = get_coefficients("ГЭСН 28-01-037-02") - assert c.em == pytest.approx(3.4752, rel=1e-4) + def test_041_svarka_okno_181(self): + """28-01-041-01 (сварка ПРСМ): К_окно = 1.81.""" + c = get_coefficients("ГЭСН 28-01-041-01") + assert c.em == pytest.approx(1.40 * 1.20 * 1.81, rel=1e-3) + assert "okno" in c.applied