Unify ports to 9002/9000 and fix report grouping sort, weigh summary in wan

This commit is contained in:
2026-08-20 15:33:56 +08:00
parent 8099ebae0a
commit c7a902833c
6 changed files with 42 additions and 15 deletions
@@ -30,16 +30,26 @@ public class ReportsController(AppDbContext db, DataScopeService scope, CurrentU
var rows = dimension switch
{
"month" => await query
"month" => (await query
.GroupBy(p => new { p.CreatedAt.Year, p.CreatedAt.Month })
.Select(g => new
{
Key = $"{g.Key.Year}-{g.Key.Month:D2}",
Year = g.Key.Year,
Month = g.Key.Month,
Amount = g.Sum(p => p.Amount),
Weight = g.Sum(p => p.NetWeight),
Cnt = g.Count()
})
.OrderBy(g => g.Key).ToListAsync(),
.OrderBy(g => g.Year).ThenBy(g => g.Month)
.ToListAsync())
.Select(g => new
{
Key = $"{g.Year}-{g.Month:D2}",
g.Amount,
g.Weight,
g.Cnt
})
.ToList(),
"product" => await query
.GroupBy(p => p.Product!.Name)
.Select(g => new { Key = g.Key, Amount = g.Sum(p => p.Amount), Weight = g.Sum(p => p.NetWeight), Cnt = g.Count() })
@@ -52,16 +62,27 @@ public class ReportsController(AppDbContext db, DataScopeService scope, CurrentU
.GroupBy(p => p.PurchaserOrg!.Name)
.Select(g => new { Key = g.Key, Amount = g.Sum(p => p.Amount), Weight = g.Sum(p => p.NetWeight), Cnt = g.Count() })
.OrderByDescending(g => g.Amount).ToListAsync(),
_ => await query
_ => (await query
.GroupBy(p => new { p.CreatedAt.Year, p.CreatedAt.Month, p.CreatedAt.Day })
.Select(g => new
{
Key = $"{g.Key.Year}-{g.Key.Month:D2}-{g.Key.Day:D2}",
Year = g.Key.Year,
Month = g.Key.Month,
Day = g.Key.Day,
Amount = g.Sum(p => p.Amount),
Weight = g.Sum(p => p.NetWeight),
Cnt = g.Count()
})
.OrderBy(g => g.Key).ToListAsync()
.OrderBy(g => g.Year).ThenBy(g => g.Month).ThenBy(g => g.Day)
.ToListAsync())
.Select(g => new
{
Key = $"{g.Year}-{g.Month:D2}-{g.Day:D2}",
g.Amount,
g.Weight,
g.Cnt
})
.ToList()
};
return Ok(new PurchaseSummaryResult(
@@ -5,7 +5,7 @@
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://0.0.0.0:5246",
"applicationUrl": "http://0.0.0.0:9002",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
@@ -19,9 +19,9 @@
"Issuer": "AgriculturalPlatform",
"Audience": "AgriculturalPlatform.Client"
},
"FrontendUrl": "http://localhost:5173",
"FrontendUrl": "http://localhost:9000",
"Server": {
"LanPort": 5246
"LanPort": 9002
},
"Storage": {
"UseOss": true