From e88de1d408c76c45a656df1515cce213716bac31 Mon Sep 17 00:00:00 2001 From: DXC Date: Tue, 12 May 2026 15:15:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(warning):=20=E5=BA=93=E5=AD=98=E9=A2=84?= =?UTF-8?q?=E8=AD=A6=E9=82=AE=E4=BB=B6=E8=A1=A8=E6=A0=BC=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=BC=BA=E5=B0=91=E6=95=B0=E9=87=8F=E5=88=97=EF=BC=88=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E5=BA=93=E5=AD=98=20|=20=E7=BC=BA=E5=B0=91=E6=95=B0?= =?UTF-8?q?=E9=87=8F=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inventory-backend/app/services/inventory_task.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/inventory-backend/app/services/inventory_task.py b/inventory-backend/app/services/inventory_task.py index ee9c400..9d3729a 100644 --- a/inventory-backend/app/services/inventory_task.py +++ b/inventory-backend/app/services/inventory_task.py @@ -51,20 +51,19 @@ class InventoryWarningService: 构建纯文本物料清单表格 Args: - rows: [{"name": ..., "spec": ..., "qty": ..., "threshold": ...}, ...] + rows: [{"name": ..., "spec": ..., "qty": ..., "threshold": ..., "shortfall": ...}, ...] level: "red" 或 "yellow",决定阈值列标题 """ - threshold_label = "红色阈值" if level == "red" else "黄色阈值" lines = [ - "名称 | 规格 | 当前库存 | " + threshold_label, - "-" * 60, + "名称 | 规格 | 当前库存 | 缺少数量", + "-" * 55, ] for r in rows: name = r.get('name', '-') or '-' spec = r.get('spec', '-') or '-' qty = r.get('qty', '-') - th = r.get('threshold', '-') - lines.append(f"{name} | {spec} | {qty} | {th}") + shortfall = r.get('shortfall', '-') + lines.append(f"{name} | {spec} | {qty} | 差{shortfall}个") return '\n'.join(lines) @staticmethod @@ -141,6 +140,7 @@ class InventoryWarningService: 'spec': spec, 'qty': round(inv, 2), 'threshold': round(red_th, 2), + 'shortfall': round(red_th - inv, 2), } if use_yellow_channel: for email in emails_to_use: @@ -176,6 +176,7 @@ class InventoryWarningService: 'spec': spec, 'qty': round(inv, 2), 'threshold': round(yellow_th, 2), + 'shortfall': round(yellow_th - inv, 2), } if use_red_channel: for email in emails_to_use: