blueeye-3184 Cursor commited on
Commit
058a945
ยท
1 Parent(s): 5ea98bb

feat: add risky items top 5 card below overstock status (API + table UI)

Browse files
model-server/05.Inventory Optimization/Inventory Optimization.py CHANGED
@@ -40,6 +40,7 @@ UI: ๋ฉ”์ธ ๋Œ€์‹œ๋ณด๋“œ(3000) โ†’ "์•ˆ์ „์žฌ๊ณ " ์ง„์ž… ์‹œ ์˜ค๋ฒ„๋ ˆ์ด "Invent
40
  GET /api/safety-stock-kpi | get_kpi_summary() | [Action Center] KPI: ๋™๊ฒฐ์ž๊ธˆ, Danger/Overstock, ์˜ˆ์ƒ ๋งค์ถœ
41
  GET /api/safety-stock-inventory-list | get_inventory_list(status_filter) | [Action Center] ์žฌ๊ณ  ๋ฆฌ์ŠคํŠธ(๋งค์žฅยท์ œํ’ˆ๋ณ„, Frozen_Money ๋‚ด๋ฆผ์ฐจ์ˆœ)
42
  GET /api/safety-stock-overstock-status | get_overstock_status_by_region() | [Action Center] ๊ณผ์ž‰ ์žฌ๊ณ  ํ˜„ํ™ฉ ์นด๋“œ(๋Œ€๋ฅ™ยท๊ตญ๊ฐ€ยท์ƒ์  ๊ตฌ๋ถ„, ์นดํ…Œ๊ณ ๋ฆฌ๋ณ„ ์ˆœ)
 
43
  GET /api/inventory-critical-alerts | get_inventory_critical_alerts() | [3.4.4] ์‹ค์‹œ๊ฐ„ ์žฌ๊ณ ยท์˜ˆ์ธก ์‹ ๋ขฐ๋„ ๊ฒฝ๊ณ  (Health_Index < 70)
44
 
45
  ๋ฐ์ดํ„ฐ ์†Œ์Šค: SQL ์ „์šฉ โ€” load_sales_dataframe() (load_sales_data.py โ†’ 01.data/*.sql).
@@ -54,6 +55,7 @@ UI: ๋ฉ”์ธ ๋Œ€์‹œ๋ณด๋“œ(3000) โ†’ "์•ˆ์ „์žฌ๊ณ " ์ง„์ž… ์‹œ ์˜ค๋ฒ„๋ ˆ์ด "Invent
54
  - [Inventory Action Center] ์ „์šฉ ๋กœ์ง์€ ๋ณธ ํŒŒ์ผ์—๋งŒ ๋‘๊ณ , UIโ†”APIโ†”ํ•จ์ˆ˜ ๋งคํ•‘ ๋ฌธ์„œํ™”.
55
  - ๊ณผ์ž‰ ์žฌ๊ณ  ํ˜„ํ™ฉ ์นด๋“œ: get_overstock_status_by_region() ์ถ”๊ฐ€ (๋Œ€๋ฅ™ยท๊ตญ๊ฐ€ยท์ƒ์  ๊ตฌ๋ถ„, ์นดํ…Œ๊ณ ๋ฆฌ๋ณ„ ์ˆœ ์ •๋ ฌ).
56
  - ๊ณผ์ž‰ ์žฌ๊ณ  ํƒ€๊ฒŸ: ์ƒํ’ˆ๋ณ„ ๊ณผ์ž‰ ๋ฐฐ์ˆ˜ 100%~320% โ†’ 300%~450% (np.random.uniform 1.0~3.2 โ†’ 3.0~4.5).
 
57
  ----------------------------------------------------------------------
58
 
59
  [๋ชจ๋“ˆํ™”] ๋ณธ ํŒŒ์ผ์€ load_sales_data.py ์˜ load_sales_dataframe() ๋งŒ ์ฐธ์กฐํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ์Šต๋‹ˆ๋‹ค.
@@ -571,6 +573,63 @@ def get_overstock_top5_by_quantity():
571
  return out
572
 
573
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
574
  def get_inventory_critical_alerts(limit: int = 50):
575
  """
576
  [3.4.4 ์‹ค์‹œ๊ฐ„ ์žฌ๊ณ  ๋ฐ ์˜ˆ์ธก ์‹ ๋ขฐ๋„ ๊ฒฝ๊ณ ]
 
40
  GET /api/safety-stock-kpi | get_kpi_summary() | [Action Center] KPI: ๋™๊ฒฐ์ž๊ธˆ, Danger/Overstock, ์˜ˆ์ƒ ๋งค์ถœ
41
  GET /api/safety-stock-inventory-list | get_inventory_list(status_filter) | [Action Center] ์žฌ๊ณ  ๋ฆฌ์ŠคํŠธ(๋งค์žฅยท์ œํ’ˆ๋ณ„, Frozen_Money ๋‚ด๋ฆผ์ฐจ์ˆœ)
42
  GET /api/safety-stock-overstock-status | get_overstock_status_by_region() | [Action Center] ๊ณผ์ž‰ ์žฌ๊ณ  ํ˜„ํ™ฉ ์นด๋“œ(๋Œ€๋ฅ™ยท๊ตญ๊ฐ€ยท์ƒ์  ๊ตฌ๋ถ„, ์นดํ…Œ๊ณ ๋ฆฌ๋ณ„ ์ˆœ)
43
+ GET /api/safety-stock-risky-items-top5 | get_risky_items_top5() | [Action Center] ์œ„ํ—˜ ํ’ˆ๋ชฉ top 5 (๋ฐœ์ฃผ๋Ÿ‰ยท์ง€์ถœ ๊ธˆ์•ก ๊ธฐ์ค€)
44
  GET /api/inventory-critical-alerts | get_inventory_critical_alerts() | [3.4.4] ์‹ค์‹œ๊ฐ„ ์žฌ๊ณ ยท์˜ˆ์ธก ์‹ ๋ขฐ๋„ ๊ฒฝ๊ณ  (Health_Index < 70)
45
 
46
  ๋ฐ์ดํ„ฐ ์†Œ์Šค: SQL ์ „์šฉ โ€” load_sales_dataframe() (load_sales_data.py โ†’ 01.data/*.sql).
 
55
  - [Inventory Action Center] ์ „์šฉ ๋กœ์ง์€ ๋ณธ ํŒŒ์ผ์—๋งŒ ๋‘๊ณ , UIโ†”APIโ†”ํ•จ์ˆ˜ ๋งคํ•‘ ๋ฌธ์„œํ™”.
56
  - ๊ณผ์ž‰ ์žฌ๊ณ  ํ˜„ํ™ฉ ์นด๋“œ: get_overstock_status_by_region() ์ถ”๊ฐ€ (๋Œ€๋ฅ™ยท๊ตญ๊ฐ€ยท์ƒ์  ๊ตฌ๋ถ„, ์นดํ…Œ๊ณ ๋ฆฌ๋ณ„ ์ˆœ ์ •๋ ฌ).
57
  - ๊ณผ์ž‰ ์žฌ๊ณ  ํƒ€๊ฒŸ: ์ƒํ’ˆ๋ณ„ ๊ณผ์ž‰ ๋ฐฐ์ˆ˜ 100%~320% โ†’ 300%~450% (np.random.uniform 1.0~3.2 โ†’ 3.0~4.5).
58
+ - ์œ„ํ—˜ ํ’ˆ๋ชฉ top 5 ์นด๋“œ: get_risky_items_top5() ์ถ”๊ฐ€ (๋ฐœ์ฃผ๋Ÿ‰=๋ชฉํ‘œ์žฌ๊ณ โˆ’ํ˜„์žฌ์žฌ๊ณ , ์ง€์ถœ=๋ฐœ์ฃผ๋Ÿ‰ร—๊ฐ€๊ฒฉ, ์ง€์ถœ ๊ธฐ์ค€ ์ƒ์œ„ 5).
59
  ----------------------------------------------------------------------
60
 
61
  [๋ชจ๋“ˆํ™”] ๋ณธ ํŒŒ์ผ์€ load_sales_data.py ์˜ load_sales_dataframe() ๋งŒ ์ฐธ์กฐํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ์Šต๋‹ˆ๋‹ค.
 
573
  return out
574
 
575
 
576
+ def get_risky_items_top5():
577
+ """
578
+ [Inventory Action Center] ์œ„ํ—˜ ํ’ˆ๋ชฉ top 5 ์นด๋“œ์šฉ.
579
+ ํ˜„์žฌ ์žฌ๊ณ  < ๋ชฉํ‘œ ์žฌ๊ณ (์•ˆ์ „ ์žฌ๊ณ )์ธ ์ƒํ’ˆ๋ณ„๋กœ ๋ฐœ์ฃผ๋Ÿ‰ยท์ง€์ถœ ๊ธˆ์•ก์„ ์‚ฐ์ถœํ•˜์—ฌ ์ง€์ถœ ๊ธˆ์•ก ๊ธฐ์ค€ ์ƒ์œ„ 5๊ฐœ ๋ฐ˜ํ™˜.
580
+ - ๋ฐœ์ฃผ๋Ÿ‰ = max(0, ๋ชฉํ‘œ ์žฌ๊ณ  - ํ˜„์žฌ ์žฌ๊ณ )
581
+ - ์ง€์ถœ ๊ธˆ์•ก = ๋ฐœ์ฃผ๋Ÿ‰ ร— ํ•ด๋‹น ์ƒํ’ˆ ๋‹จ๊ฐ€(price)
582
+ ๋ฐ˜ํ™˜: [{"rank", "product_name", "current_inventory", "target_inventory", "order_quantity", "expenditure"}, ...]
583
+ """
584
+ df = load_sales_dataframe()
585
+ if df is None or df.empty:
586
+ return []
587
+ df = run_inventory_pipeline(df)
588
+ if df is None or df.empty or "Product_Name" not in df.columns:
589
+ return []
590
+ need = ["Product_Name", "Inventory", "Safety_Stock"]
591
+ if not all(c in df.columns for c in need):
592
+ return []
593
+
594
+ inv = pd.to_numeric(df["Inventory"], errors="coerce").fillna(0)
595
+ safety = pd.to_numeric(df["Safety_Stock"], errors="coerce").fillna(0)
596
+ df = df.copy()
597
+ df["_inv"] = inv
598
+ df["_safety"] = safety
599
+
600
+ agg = df.groupby("Product_Name", as_index=False).agg(
601
+ current_inventory=("_inv", "sum"),
602
+ target_inventory=("_safety", "sum"),
603
+ )
604
+ agg["current_inventory"] = agg["current_inventory"].round(0).astype(int)
605
+ agg["target_inventory"] = agg["target_inventory"].round(0).astype(int)
606
+ agg["order_quantity"] = (agg["target_inventory"] - agg["current_inventory"]).clip(lower=0)
607
+ agg = agg[agg["order_quantity"] > 0].copy()
608
+ if agg.empty:
609
+ return []
610
+
611
+ if "price" in df.columns:
612
+ price_map = df.groupby("Product_Name")["price"].first()
613
+ agg["price"] = agg["Product_Name"].map(price_map)
614
+ else:
615
+ agg["price"] = 0.0
616
+ agg["price"] = pd.to_numeric(agg["price"], errors="coerce").fillna(0)
617
+ agg["expenditure"] = (agg["order_quantity"] * agg["price"]).round(0)
618
+ agg = agg.sort_values(by="expenditure", ascending=False).head(5).reset_index(drop=True)
619
+
620
+ out = []
621
+ for i, (_, row) in enumerate(agg.iterrows(), start=1):
622
+ out.append({
623
+ "rank": i,
624
+ "product_name": str(row["Product_Name"]).strip() or "",
625
+ "current_inventory": int(row["current_inventory"]),
626
+ "target_inventory": int(row["target_inventory"]),
627
+ "order_quantity": int(row["order_quantity"]),
628
+ "expenditure": float(row["expenditure"]),
629
+ })
630
+ return out
631
+
632
+
633
  def get_inventory_critical_alerts(limit: int = 50):
634
  """
635
  [3.4.4 ์‹ค์‹œ๊ฐ„ ์žฌ๊ณ  ๋ฐ ์˜ˆ์ธก ์‹ ๋ขฐ๋„ ๊ฒฝ๊ณ ]
web-development/backend/main.py CHANGED
@@ -1006,9 +1006,10 @@ if _realtime_file.exists():
1006
  except Exception as e:
1007
  print(f"[Apple Retail API] Real-time execution and performance dashboard.py ๋กœ๋“œ ์‹คํŒจ: {e}")
1008
 
1009
- # Inventory Optimization ๋ชจ๋“ˆ: ๊ณผ์ž‰ ์žฌ๊ณ  ํ˜„ํ™ฉ(๋Œ€๋ฅ™ยท๊ตญ๊ฐ€ยท์ƒ์ ยท์นดํ…Œ๊ณ ๋ฆฌ ์ˆœ) ๋ฐ TOP5 ์ˆ˜๋Ÿ‰ ๊ธฐ์ค€
1010
  get_overstock_status_by_region = None
1011
  get_overstock_top5_by_quantity = None
 
1012
  _inv_opt_file = _model_path("05.Inventory Optimization", "Inventory Optimization") / "Inventory Optimization.py"
1013
  if _inv_opt_file.exists() and load_sales_dataframe is not None:
1014
  try:
@@ -1018,6 +1019,7 @@ if _inv_opt_file.exists() and load_sales_dataframe is not None:
1018
  _inv_opt_spec.loader.exec_module(_inv_opt_module)
1019
  get_overstock_status_by_region = getattr(_inv_opt_module, "get_overstock_status_by_region", None)
1020
  get_overstock_top5_by_quantity = getattr(_inv_opt_module, "get_overstock_top5_by_quantity", None)
 
1021
  except Exception as e:
1022
  print(f"[Apple Retail API] Inventory Optimization (get_overstock_status_by_region) ๋กœ๋“œ ์‹คํŒจ: {e}")
1023
 
@@ -1970,6 +1972,18 @@ def api_safety_stock_overstock_top5():
1970
  return []
1971
 
1972
 
 
 
 
 
 
 
 
 
 
 
 
 
1973
  @app.get("/api/inventory-frozen-money")
1974
  def api_inventory_frozen_money():
1975
  """
 
1006
  except Exception as e:
1007
  print(f"[Apple Retail API] Real-time execution and performance dashboard.py ๋กœ๋“œ ์‹คํŒจ: {e}")
1008
 
1009
+ # Inventory Optimization ๋ชจ๋“ˆ: ๊ณผ์ž‰ ์žฌ๊ณ  ํ˜„ํ™ฉ(๋Œ€๋ฅ™ยท๊ตญ๊ฐ€ยท์ƒ์ ยท์นดํ…Œ๊ณ ๋ฆฌ ์ˆœ), TOP5 ์ˆ˜๋Ÿ‰ ๊ธฐ์ค€, ์œ„ํ—˜ ํ’ˆ๋ชฉ top 5
1010
  get_overstock_status_by_region = None
1011
  get_overstock_top5_by_quantity = None
1012
+ get_risky_items_top5 = None
1013
  _inv_opt_file = _model_path("05.Inventory Optimization", "Inventory Optimization") / "Inventory Optimization.py"
1014
  if _inv_opt_file.exists() and load_sales_dataframe is not None:
1015
  try:
 
1019
  _inv_opt_spec.loader.exec_module(_inv_opt_module)
1020
  get_overstock_status_by_region = getattr(_inv_opt_module, "get_overstock_status_by_region", None)
1021
  get_overstock_top5_by_quantity = getattr(_inv_opt_module, "get_overstock_top5_by_quantity", None)
1022
+ get_risky_items_top5 = getattr(_inv_opt_module, "get_risky_items_top5", None)
1023
  except Exception as e:
1024
  print(f"[Apple Retail API] Inventory Optimization (get_overstock_status_by_region) ๋กœ๋“œ ์‹คํŒจ: {e}")
1025
 
 
1972
  return []
1973
 
1974
 
1975
+ @app.get("/api/safety-stock-risky-items-top5")
1976
+ def api_safety_stock_risky_items_top5():
1977
+ """Inventory Action Center: ์œ„ํ—˜ ํ’ˆ๋ชฉ top 5. ๋ฐœ์ฃผ๋Ÿ‰(๋ชฉํ‘œ์žฌ๊ณ โˆ’ํ˜„์žฌ์žฌ๊ณ )ยท์ง€์ถœ ๊ธˆ์•ก(๋ฐœ์ฃผ๋Ÿ‰ร—๊ฐ€๊ฒฉ) ๊ธฐ์ค€ ์ƒ์œ„ 5๊ฐœ."""
1978
+ if get_risky_items_top5 is None:
1979
+ return []
1980
+ try:
1981
+ return get_risky_items_top5()
1982
+ except Exception as e:
1983
+ print(f"[Apple Retail API] api_safety_stock_risky_items_top5 ์˜ค๋ฅ˜: {e}")
1984
+ return []
1985
+
1986
+
1987
  @app.get("/api/inventory-frozen-money")
1988
  def api_inventory_frozen_money():
1989
  """
web-development/frontend/app/page.tsx CHANGED
@@ -505,6 +505,10 @@ export default function Home() {
505
  const [overstockTop5ByQty, setOverstockTop5ByQty] = useState<
506
  { product_name: string; current_inventory: number; target_inventory: number; overstock_qty: number; overstock_pct: number; savings_amount: number }[]
507
  >([]);
 
 
 
 
508
  /** ์ƒํƒœ ํ•„ํ„ฐ: '' | '์œ„ํ—˜' | '๊ณผ์ž‰' (ํ•œ๊ธ€) */
509
  const [inventoryStatusFilter, setInventoryStatusFilter] = useState<string>('');
510
  /** ๊ด€๋ฆฌ์ž ์ฝ”๋ฉ˜ํŠธ: ์„ ํƒ๋œ ๋งค์žฅ๋ช… */
@@ -853,6 +857,13 @@ export default function Home() {
853
  if (Array.isArray(json)) setOverstockTop5ByQty(json);
854
  else setOverstockTop5ByQty([]);
855
  }).catch(() => setOverstockTop5ByQty([]));
 
 
 
 
 
 
 
856
  }, [showSafetyStockDashboard, inventoryStatusFilter]);
857
 
858
  // ๋งค์žฅ๋ณ„ ์žฌ๊ณ  ๋ชฉ๋ก/ํ•„ํ„ฐ ๋ณ€๊ฒฝ ์‹œ, ์„ ํƒ ๋งค์žฅ์ด ๋ชฉ๋ก์— ์—†์œผ๋ฉด ์„ ํƒ ํ•ด์ œ (๋™๊ธฐํ™”)
@@ -1913,6 +1924,44 @@ export default function Home() {
1913
  </div>
1914
  )}
1915
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1916
  {/* ์œ„ํ—˜ ํ’ˆ๋ชฉ: ์ฐจํŠธ & ๊ด€๋ฆฌ์ž ์ฝ”๋ฉ˜ํŠธ */}
1917
  {dangerTop5.length > 0 && (
1918
  <div className="mb-6 grid grid-cols-1 lg:grid-cols-2 gap-6">
 
505
  const [overstockTop5ByQty, setOverstockTop5ByQty] = useState<
506
  { product_name: string; current_inventory: number; target_inventory: number; overstock_qty: number; overstock_pct: number; savings_amount: number }[]
507
  >([]);
508
+ /** ์œ„ํ—˜ ํ’ˆ๋ชฉ top 5: ์ˆœ์œ„ยท์ƒํ’ˆ๋ช…ยทํ˜„์žฌ์žฌ๊ณ ยท๋ชฉํ‘œ์žฌ๊ณ ยท๋ฐœ์ฃผ๋Ÿ‰ยท์ง€์ถœ ๊ธˆ์•ก (DB ๊ธฐ์ค€) */
509
+ const [riskyItemsTop5, setRiskyItemsTop5] = useState<
510
+ { rank: number; product_name: string; current_inventory: number; target_inventory: number; order_quantity: number; expenditure: number }[]
511
+ >([]);
512
  /** ์ƒํƒœ ํ•„ํ„ฐ: '' | '์œ„ํ—˜' | '๊ณผ์ž‰' (ํ•œ๊ธ€) */
513
  const [inventoryStatusFilter, setInventoryStatusFilter] = useState<string>('');
514
  /** ๊ด€๋ฆฌ์ž ์ฝ”๋ฉ˜ํŠธ: ์„ ํƒ๋œ ๋งค์žฅ๋ช… */
 
857
  if (Array.isArray(json)) setOverstockTop5ByQty(json);
858
  else setOverstockTop5ByQty([]);
859
  }).catch(() => setOverstockTop5ByQty([]));
860
+ // ์œ„ํ—˜ ํ’ˆ๋ชฉ top 5 (๋ฐœ์ฃผ๋Ÿ‰ยท์ง€์ถœ ๊ธˆ์•ก ๊ธฐ์ค€, DB)
861
+ apiGet<{ rank: number; product_name: string; current_inventory: number; target_inventory: number; order_quantity: number; expenditure: number }[]>(
862
+ '/api/safety-stock-risky-items-top5'
863
+ ).then((json) => {
864
+ if (Array.isArray(json)) setRiskyItemsTop5(json);
865
+ else setRiskyItemsTop5([]);
866
+ }).catch(() => setRiskyItemsTop5([]));
867
  }, [showSafetyStockDashboard, inventoryStatusFilter]);
868
 
869
  // ๋งค์žฅ๋ณ„ ์žฌ๊ณ  ๋ชฉ๋ก/ํ•„ํ„ฐ ๋ณ€๊ฒฝ ์‹œ, ์„ ํƒ ๋งค์žฅ์ด ๋ชฉ๋ก์— ์—†์œผ๋ฉด ์„ ํƒ ํ•ด์ œ (๋™๊ธฐํ™”)
 
1924
  </div>
1925
  )}
1926
 
1927
+ {/* ์œ„ํ—˜ ํ’ˆ๋ชฉ top 5: DB ๊ธฐ์ค€ ํ…Œ์ด๋ธ” (์ˆœ์œ„ยท์ƒํ’ˆ๋ช…ยทํ˜„์žฌ์žฌ๊ณ ยท๋ชฉํ‘œ์žฌ๊ณ ยท๋ฐœ์ฃผ๋Ÿ‰ยท์ง€์ถœ ๊ธˆ์•ก) */}
1928
+ {riskyItemsTop5.length > 0 && (
1929
+ <div className="mb-6">
1930
+ <div className="rounded-xl border border-gray-700 bg-[#2d2d2f] p-4">
1931
+ <h3 className="text-sm font-semibold text-white mb-1">์œ„ํ—˜ ํ’ˆ๋ชฉ top 5</h3>
1932
+ <p className="text-xs text-[#a1a1a6] mb-3">
1933
+ ํ˜„์žฌ ์žฌ๊ณ ๊ฐ€ ๋ชฉํ‘œ ์žฌ๊ณ (์•ˆ์ „ ์žฌ๊ณ )๋ณด๋‹ค ๋‚ฎ์€ ์ƒํ’ˆ ์ค‘, ๋ฐœ์ฃผ ํ•„์š”๋Ÿ‰ยท์˜ˆ์ƒ ์ง€์ถœ ๊ธˆ์•ก ๊ธฐ์ค€ ์ƒ์œ„ 5๊ฐœ์ž…๋‹ˆ๋‹ค.
1934
+ </p>
1935
+ <div className="overflow-x-auto">
1936
+ <table className="w-full text-left border-collapse">
1937
+ <thead>
1938
+ <tr className="border-b border-gray-600">
1939
+ <th className="text-xs font-medium text-[#a1a1a6] py-2 pr-3">์ˆœ์œ„</th>
1940
+ <th className="text-xs font-medium text-[#a1a1a6] py-2 pr-3">์ƒํ’ˆ๋ช…</th>
1941
+ <th className="text-xs font-medium text-[#a1a1a6] py-2 pr-3">ํ˜„์žฌ ์žฌ๊ณ </th>
1942
+ <th className="text-xs font-medium text-[#a1a1a6] py-2 pr-3">๋ชฉํ‘œ ์žฌ๊ณ </th>
1943
+ <th className="text-xs font-medium text-[#a1a1a6] py-2 pr-3">๋ฐœ์ฃผ๋Ÿ‰</th>
1944
+ <th className="text-xs font-medium text-[#a1a1a6] py-2 pr-3">์ง€์ถœ ๊ธˆ์•ก</th>
1945
+ </tr>
1946
+ </thead>
1947
+ <tbody>
1948
+ {riskyItemsTop5.map((row) => (
1949
+ <tr key={row.rank} className="border-b border-gray-600/80">
1950
+ <td className="text-sm text-white py-2 pr-3">{row.rank}</td>
1951
+ <td className="text-sm text-white py-2 pr-3">{row.product_name || 'โ€”'}</td>
1952
+ <td className="text-sm text-white py-2 pr-3">{(row.current_inventory ?? 0).toLocaleString()}๋Œ€</td>
1953
+ <td className="text-sm text-white py-2 pr-3">{(row.target_inventory ?? 0).toLocaleString()}๋Œ€</td>
1954
+ <td className="text-sm text-white py-2 pr-3">{(row.order_quantity ?? 0).toLocaleString()}๋Œ€</td>
1955
+ <td className="text-sm text-white py-2 pr-3">โ‚ฉ{(row.expenditure ?? 0).toLocaleString()}</td>
1956
+ </tr>
1957
+ ))}
1958
+ </tbody>
1959
+ </table>
1960
+ </div>
1961
+ </div>
1962
+ </div>
1963
+ )}
1964
+
1965
  {/* ์œ„ํ—˜ ํ’ˆ๋ชฉ: ์ฐจํŠธ & ๊ด€๋ฆฌ์ž ์ฝ”๋ฉ˜ํŠธ */}
1966
  {dangerTop5.length > 0 && (
1967
  <div className="mb-6 grid grid-cols-1 lg:grid-cols-2 gap-6">