This commit is contained in:
2026-01-27 21:37:57 +01:00
parent c6f2884759
commit ac653a4dd0

12
app.py
View File

@@ -538,7 +538,10 @@ def create_weight_report(payload: dict = Body(...)):
conn = get_db_connection() conn = get_db_connection()
cursor = conn.cursor() cursor = conn.cursor()
# 🔹 On déclare la variable OUTPUT @OUT_WEIGHT_REPORT_KEY
cursor.execute(""" cursor.execute("""
DECLARE @OUT_WEIGHT_REPORT_KEY INT;
EXEC dbo.sp_Singa_Automation_InsertWeightReport EXEC dbo.sp_Singa_Automation_InsertWeightReport
@CHUNK_KEY = ?, @CHUNK_KEY = ?,
@BAGS_SOUND_AND_FULL = ?, @BAGS_SOUND_AND_FULL = ?,
@@ -576,7 +579,10 @@ def create_weight_report(payload: dict = Body(...)):
@MOISTURE_VALUE = NULL, @MOISTURE_VALUE = NULL,
@REPORT_TYPE = 0, @REPORT_TYPE = 0,
@WET_WEIGHT = NULL, @WET_WEIGHT = NULL,
@WSMD_LOCATION = 0 @WSMD_LOCATION = 0,
@OUT_WEIGHT_REPORT_KEY = @OUT_WEIGHT_REPORT_KEY OUTPUT;
SELECT @OUT_WEIGHT_REPORT_KEY AS OUT_WEIGHT_REPORT_KEY;
""", """,
chunk_key, chunk_key,
bags, bags,
@@ -591,7 +597,7 @@ def create_weight_report(payload: dict = Body(...)):
report_date report_date
) )
# 🟢 On récupère le SELECT final de la SP # 🔹 Récupération de la variable OUTPUT
row = cursor.fetchone() row = cursor.fetchone()
conn.commit() conn.commit()
@@ -603,7 +609,7 @@ def create_weight_report(payload: dict = Body(...)):
return { return {
"success": True, "success": True,
"weight_report_key": row.WEIGHT_REPORT_KEY "weight_report_key": row.OUT_WEIGHT_REPORT_KEY
} }
except Exception as e: except Exception as e: