From 51922d7093b9c8f52417bfdd0fe9aa087d1fb5be Mon Sep 17 00:00:00 2001
From: xiazhengtongxue <133085197+xiazhengtongxue@users.noreply.github.com>
Date: 星期五, 01 五月 2026 18:31:01 +0800
Subject: [PATCH] feat: 优化仓库仪表盘界面并添加电池和空托盘统计功能
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Dashboard/DashboardController.cs | 83 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 83 insertions(+), 0 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Dashboard/DashboardController.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Dashboard/DashboardController.cs
index 191dd33..cffe42d 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Dashboard/DashboardController.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Dashboard/DashboardController.cs
@@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using WIDESEA_Common.LocationEnum;
+using WIDESEA_Common.StockEnum;
using WIDESEA_Core;
using WIDESEA_Model.Models;
@@ -415,5 +416,87 @@
return WebResponseContent.Instance.Error($"鍚勪粨搴撳簱瀛樺垎甯冭幏鍙栧け璐�: {ex.Message}");
}
}
+ /// <summary>
+ /// 鏌ヨ鍚勪粨搴撶數姹�/鏈夎揣鏁伴噺鍜岀┖鎵樼洏鏁伴噺
+ /// </summary>
+ /// <remarks>
+ /// 浠撳簱ID瑙勫垯锛�1=楂樻俯搴�, 2=甯告俯搴�, 3=鍖栨垚搴�, 6/7=鏋佸嵎搴�
+ /// <br/>
+ /// 缁熻瑙勫垯锛�
+ /// <br/>
+ /// - 楂樻俯/甯告俯/鍖栨垚搴擄細缁熻 鐢垫睜鏁伴噺(StockStatus=6) 鍜� 绌烘墭鐩樻暟閲�(StockStatus=22)
+ /// <br/>
+ /// - 鏋佸嵎搴�(6/7)锛氱粺璁� 鏈夎揣鏁伴噺(StockStatus鈮�22) 鍜� 绌烘墭鐩樻暟閲�(StockStatus=22)
+ /// <br/>
+ /// 閫氳繃杩斿洖鏁版嵁涓殑 StockStatus 鍜� Count 鍙互杩涗竴姝ユ煡璇㈡槑缁嗙數姹犮��
+ /// </remarks>
+ [HttpGet("StockAndTrayCount"), AllowAnonymous]
+ public async Task<WebResponseContent> StockAndTrayCount()
+ {
+ try
+ {
+ var warehouseIds = new[] { 1, 2, 3, 6, 7 };
+
+ var warehouseNames = new Dictionary<int, string>
+ {
+ { 1, "楂樻俯搴�" },
+ { 2, "甯告俯搴�" },
+ { 3, "鍖栨垚搴�" },
+ { 6, "鏋佸嵎搴�" },
+ { 7, "鏋佸嵎搴�" }
+ };
+
+ var result = new List<object>();
+
+ foreach (var warehouseId in warehouseIds)
+ {
+ var warehouseName = warehouseNames.GetValueOrDefault(warehouseId, $"浠撳簱{warehouseId}");
+
+ if (warehouseId == 6 || warehouseId == 7)
+ {
+ var totalCount = await _db.Queryable<Dt_StockInfo>()
+ .Where(s => s.WarehouseId == warehouseId)
+ .CountAsync();
+
+ var emptyTrayCount = await _db.Queryable<Dt_StockInfo>()
+ .Where(s => s.WarehouseId == warehouseId && s.StockStatus == (int)StockStatusEmun.绌烘墭鐩樺簱瀛�)
+ .CountAsync();
+
+ result.Add(new
+ {
+ WarehouseId = warehouseId,
+ WarehouseName = warehouseName,
+ HasGoodsCount = totalCount - emptyTrayCount,
+ EmptyTrayCount = emptyTrayCount,
+ });
+ }
+ else
+ {
+ var batteryCount = await _db.Queryable<Dt_StockInfo>()
+ .Where(s => s.WarehouseId == warehouseId && s.StockStatus == (int)StockStatusEmun.鍏ュ簱瀹屾垚)
+ .LeftJoin<Dt_StockInfoDetail>((s, d) => s.Id == d.StockId)
+ .CountAsync();
+
+ var emptyTrayCount = await _db.Queryable<Dt_StockInfo>()
+ .Where(s => s.WarehouseId == warehouseId && s.StockStatus == (int)StockStatusEmun.绌烘墭鐩樺簱瀛�)
+ .CountAsync();
+
+ result.Add(new
+ {
+ WarehouseId = warehouseId,
+ WarehouseName = warehouseName,
+ BatteryCount = batteryCount,
+ EmptyTrayCount = emptyTrayCount,
+ });
+ }
+ }
+
+ return WebResponseContent.Instance.OK(null, result);
+ }
+ catch (Exception ex)
+ {
+ return WebResponseContent.Instance.Error($"鐢垫睜鍜岀┖鎵樼洏鏁伴噺鏌ヨ澶辫触: {ex.Message}");
+ }
+ }
}
}
\ No newline at end of file
--
Gitblit v1.9.3