Add machine-aware maximum product length

This commit is contained in:
2026-09-26 12:25:04 +02:00
parent 3e13d24405
commit 90c28fb2f5
11 changed files with 765 additions and 5 deletions
+47 -1
View File
@@ -20,7 +20,10 @@ from flask_httpauth import HTTPBasicAuth
from werkzeug.security import check_password_hash
from core_presets import CORE_PRESETS
from machine_constraints import check_production_feasibility
from machine_constraints import (
calculate_machine_max_product_length,
check_production_feasibility,
)
from conversation_service import (
ConversationNotFoundError,
ConversationReportNotFoundError,
@@ -278,6 +281,49 @@ def create_production_feasibility_calculation():
return jsonify(result), 200
@app.route("/api/calculations/machine-max-product-length", methods=["POST"])
@auth.login_required
def create_machine_max_product_length_calculation():
"""Calculate machine-limited product length through the shared domain."""
payload = request.get_json(silent=True)
allowed = {
"machine",
"core_diameter_mm",
"thickness_mm",
"thickness_stddev_mm",
"product_width_m",
"area_weight_g_m2",
}
if not isinstance(payload, dict):
result = {
"status": "invalid_parameter",
"invalid": [{"field": "request", "message": "JSON object required"}],
}
else:
unknown = sorted(set(payload) - allowed)
if unknown:
result = {
"status": "invalid_parameter",
"invalid": [{
"field": "request",
"message": "unknown request fields: " + ", ".join(unknown),
}],
}
else:
result = calculate_machine_max_product_length(
machine=payload.get("machine"),
core_diameter_mm=payload.get("core_diameter_mm"),
thickness_mm=payload.get("thickness_mm"),
thickness_stddev_mm=payload.get("thickness_stddev_mm"),
product_width_m=payload.get("product_width_m"),
area_weight_g_m2=payload.get("area_weight_g_m2"),
)
log_access(
auth.current_user(), "/api/calculations/machine-max-product-length", "POST"
)
return jsonify(result), 200
def _create_pdf(calculation_request):
result = calculate_roll(calculation_request, build_info=BUILD_INFO)
report = report_from_calculation_result(result)