From dc1d067c566bbde1c7170186960a8bd27f210a47 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 09 九月 2026 13:45:58 +0800
Subject: [PATCH] feat(bi): 新增决策总览仪表盘并优化预测分析功能

---
 src/views/wls/sn/location-maps.ts |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/src/views/wls/sn/location-maps.ts b/src/views/wls/sn/location-maps.ts
new file mode 100644
index 0000000..762f3c4
--- /dev/null
+++ b/src/views/wls/sn/location-maps.ts
@@ -0,0 +1,51 @@
+import { getWarehouseAreaSimpleList } from '#/api/mes/wm/warehouse/area';
+import { getWarehouseSimpleList } from '#/api/mes/wm/warehouse';
+import { getWarehouseLocationSimpleList } from '#/api/mes/wm/warehouse/location';
+
+export interface WmLocationMaps {
+  warehouseNameMap: Record<number, string>;
+  locationNameMap: Record<number, string>;
+  areaNameMap: Record<number, string>;
+}
+
+let cached: WmLocationMaps | null = null;
+
+/** 鍔犺浇浠撳簱/搴撳尯/搴撲綅 ID -> 鍚嶇О鏄犲皠锛堟ā鍧楃骇缂撳瓨锛屼粎棣栨鍔犺浇锛� */
+export async function getWmLocationMaps(): Promise<WmLocationMaps> {
+  if (cached) {
+    return cached;
+  }
+  const [warehouses, locations, areas] = await Promise.all([
+    getWarehouseSimpleList(),
+    getWarehouseLocationSimpleList(),
+    getWarehouseAreaSimpleList(),
+  ]);
+  cached = {
+    warehouseNameMap: Object.fromEntries(
+      warehouses.map((w) => [w.id!, w.name || w.code || '']),
+    ),
+    locationNameMap: Object.fromEntries(
+      locations.map((l) => [l.id!, l.name || l.code || '']),
+    ),
+    areaNameMap: Object.fromEntries(
+      areas.map((a) => [a.id!, a.name || a.code || '']),
+    ),
+  };
+  return cached;
+}
+
+/** 鏍规嵁 ID 娓叉煋 浠撳簱/搴撳尯/搴撲綅 鏂囨湰锛圛D 缂哄け鏃惰繑鍥炵┖涓诧級 */
+export function formatWmLocation(
+  maps: WmLocationMaps,
+  warehouseId?: number,
+  locationId?: number,
+  areaId?: number,
+): string {
+  return [
+    warehouseId ? maps.warehouseNameMap[warehouseId] : '',
+    locationId ? maps.locationNameMap[locationId] : '',
+    areaId ? maps.areaNameMap[areaId] : '',
+  ]
+    .filter(Boolean)
+    .join(' / ');
+}
\ No newline at end of file

--
Gitblit v1.9.3