From b9b411438c49ec8c882de5d5889b6e232ac0ae9a Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期一, 30 三月 2026 11:36:31 +0800
Subject: [PATCH] docs: 修正实现计划中的问题
---
Code/WMS/docs/superpowers/plans/2026-03-30-dashboard-chart-plan.md | 63 ++++++++-----------------------
1 files changed, 17 insertions(+), 46 deletions(-)
diff --git a/Code/WMS/docs/superpowers/plans/2026-03-30-dashboard-chart-plan.md b/Code/WMS/docs/superpowers/plans/2026-03-30-dashboard-chart-plan.md
index 4620f1c..a4b92b6 100644
--- a/Code/WMS/docs/superpowers/plans/2026-03-30-dashboard-chart-plan.md
+++ b/Code/WMS/docs/superpowers/plans/2026-03-30-dashboard-chart-plan.md
@@ -219,10 +219,12 @@
private string GetWeekKey(DateTime date)
{
- // 鑾峰彇鍛ㄤ竴寮�濮嬬殑鍛�
+ // 鑾峰彇鍛ㄤ竴寮�濮嬬殑鍛� (ISO 8601)
var diff = (7 + (date.DayOfWeek - DayOfWeek.Monday)) % 7;
var monday = date.AddDays(-diff);
- return monday.ToString("yyyy-Www");
+ var weekNum = System.Globalization.CultureInfo.InvariantCulture
+ .Calendar.GetWeekOfYear(monday, System.Globalization.CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
+ return $"{monday.Year}-W{weekNum:D2}";
}
```
@@ -262,16 +264,14 @@
public async Task<WebResponseContent> StockAgeDistribution()
{
var now = DateTime.Now;
- var stocks = await _db.Queryable<Dt_StockInfo>()
- .Select(s => s.CreateDate)
- .ToListAsync();
+ // 浣跨敤 SQL 鐩存帴鍒嗙粍缁熻锛岄伩鍏嶅姞杞芥墍鏈夋暟鎹埌鍐呭瓨
var result = new[]
{
- new { Range = "7澶╁唴", Count = stocks.Count(s => (now - s).TotalDays <= 7) },
- new { Range = "7-30澶�", Count = stocks.Count(s => (now - s).TotalDays > 7 && (now - s).TotalDays <= 30) },
- new { Range = "30-90澶�", Count = stocks.Count(s => (now - s).TotalDays > 30 && (now - s).TotalDays <= 90) },
- new { Range = "90澶╀互涓�", Count = stocks.Count(s => (now - s).TotalDays > 90) }
+ new { Range = "7澶╁唴", Count = await _db.Queryable<Dt_StockInfo>().Where(s => EF.Functions.DateDiffDay(s.CreateDate, now) <= 7).CountAsync() },
+ new { Range = "7-30澶�", Count = await _db.Queryable<Dt_StockInfo>().Where(s => EF.Functions.DateDiffDay(s.CreateDate, now) > 7 && EF.Functions.DateDiffDay(s.CreateDate, now) <= 30).CountAsync() },
+ new { Range = "30-90澶�", Count = await _db.Queryable<Dt_StockInfo>().Where(s => EF.Functions.DateDiffDay(s.CreateDate, now) > 30 && EF.Functions.DateDiffDay(s.CreateDate, now) <= 90).CountAsync() },
+ new { Range = "90澶╀互涓�", Count = await _db.Queryable<Dt_StockInfo>().Where(s => EF.Functions.DateDiffDay(s.CreateDate, now) > 90).CountAsync() }
};
return WebResponseContent.Instance.OK(null, result);
@@ -402,7 +402,6 @@
MonthOutbound: 0,
TotalStock: 0
},
- dailyData: [],
weeklyData: [],
monthlyData: [],
stockAgeData: [],
@@ -412,10 +411,16 @@
mounted() {
this.initCharts();
this.loadData();
+ window.addEventListener("resize", this.handleResize);
},
beforeUnmount() {
+ window.removeEventListener("resize", this.handleResize);
Object.values(this.charts).forEach(chart => chart.dispose());
},
+ methods: {
+ handleResize() {
+ Object.values(this.charts).forEach(chart => chart.resize());
+ },
methods: {
initCharts() {
this.charts.monthlyTrend = echarts.init(document.getElementById("chart-monthly-trend"));
@@ -428,7 +433,6 @@
async loadData() {
await this.loadOverview();
- await this.loadDailyStats();
await this.loadWeeklyStats();
await this.loadMonthlyStats();
await this.loadStockAgeDistribution();
@@ -449,23 +453,12 @@
}
},
- async loadDailyStats() {
- try {
- const res = await this.http.get("/api/Dashboard/DailyStats", { days: 30 });
- if (res.Status && res.Data) {
- this.dailyData = res.Data;
- }
- } catch (e) {
- console.error("鍔犺浇姣忔棩缁熻澶辫触", e);
- }
- },
-
async loadWeeklyStats() {
try {
const res = await this.http.get("/api/Dashboard/WeeklyStats", { weeks: 12 });
if (res.Status && res.Data) {
this.weeklyData = res.Data;
- this.updateWeeklyTrendChart();
+ this.updateWeekChart();
}
} catch (e) {
console.error("鍔犺浇姣忓懆缁熻澶辫触", e);
@@ -597,7 +590,7 @@
this.charts.month.setOption(option, true);
},
- // 鏇存柊鏈堝害瓒嬪娍鍥捐〃锛堟姌绾�+鏌辩姸缁勫悎锛�
+ // 鏇存柊鏈堝害瓒嬪娍鍥捐〃锛堟姌绾垮浘锛�
updateMonthlyTrendChart() {
const option = {
tooltip: { trigger: "axis" },
@@ -617,28 +610,6 @@
series: [
{ name: "鍏ュ簱", type: "line", data: this.monthlyData.map(m => m.Inbound), itemStyle: { color: "#5470c6" } },
{ name: "鍑哄簱", type: "line", data: this.monthlyData.map(m => m.Outbound), itemStyle: { color: "#91cc75" } }
- ]
- };
- this.charts.monthlyTrend.setOption(option, true);
- },
-
- // 鏇存柊鍛ㄨ秼鍔垮浘琛�
- updateWeeklyTrendChart() {
- const option = {
- tooltip: { trigger: "axis" },
- legend: { data: ["鍏ュ簱", "鍑哄簱"], textStyle: { color: "#fff" } },
- xAxis: {
- type: "category",
- data: this.weeklyData.map(w => w.Week),
- axisLabel: { color: "#fff", rotate: 45 }
- },
- yAxis: {
- type: "value",
- axisLabel: { color: "#fff" }
- },
- series: [
- { name: "鍏ュ簱", type: "bar", data: this.weeklyData.map(w => w.Inbound), itemStyle: { color: "#5470c6" } },
- { name: "鍑哄簱", type: "bar", data: this.weeklyData.map(w => w.Outbound), itemStyle: { color: "#91cc75" } }
]
};
this.charts.monthlyTrend.setOption(option, true);
--
Gitblit v1.9.3