Интегрирован wesp в сайт
CI / quality (push) Canceled after 0s

This commit is contained in:
влад
2026-07-17 12:57:18 +03:00
parent 5dfa06ddbe
commit 355c0ef9f1
883 changed files with 194576 additions and 177 deletions
@@ -0,0 +1,29 @@
from __future__ import annotations
from app.modules.zootech.lab.dto.ration import ExecutionLineSnapshot, ExecutionSnapshot
from app.modules.zootech.wesp_bridge_models import Ingredient, Recipe
def load_execution(recipe_id: str) -> ExecutionSnapshot:
recipe = Recipe.query.filter_by(id=recipe_id, is_deleted=False).first()
if recipe is None:
raise LookupError("Рецепт не найден")
heads = int(recipe.heads_per_trip or 1)
ingredients = (
Ingredient.query.filter_by(recipe_id=recipe_id, is_deleted=False)
.order_by(Ingredient.order)
.all()
)
lines = []
for ing in ingredients:
wph = float(ing.weight_per_head or 0)
lines.append(
ExecutionLineSnapshot(
ingredient_id=ing.id,
component_id=ing.component_id,
name=ing.name,
weight_per_head=wph,
daily_kg_total=wph * heads,
)
)
return ExecutionSnapshot(recipe_id=recipe_id, heads_per_trip=heads, lines=tuple(lines))