diff --git a/backend/AgriculturalPlatform.Api/Controllers/ReportsController.cs b/backend/AgriculturalPlatform.Api/Controllers/ReportsController.cs index a827125..14bec29 100644 --- a/backend/AgriculturalPlatform.Api/Controllers/ReportsController.cs +++ b/backend/AgriculturalPlatform.Api/Controllers/ReportsController.cs @@ -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( diff --git a/backend/AgriculturalPlatform.Api/Properties/launchSettings.json b/backend/AgriculturalPlatform.Api/Properties/launchSettings.json index 09fb82b..00250cb 100644 --- a/backend/AgriculturalPlatform.Api/Properties/launchSettings.json +++ b/backend/AgriculturalPlatform.Api/Properties/launchSettings.json @@ -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" } diff --git a/backend/AgriculturalPlatform.Api/appsettings.json b/backend/AgriculturalPlatform.Api/appsettings.json index d661fd6..8c370c0 100644 --- a/backend/AgriculturalPlatform.Api/appsettings.json +++ b/backend/AgriculturalPlatform.Api/appsettings.json @@ -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 diff --git a/frontend/src/views/weighing/WeighingList.vue b/frontend/src/views/weighing/WeighingList.vue index 6d8fb88..ac517eb 100644 --- a/frontend/src/views/weighing/WeighingList.vue +++ b/frontend/src/views/weighing/WeighingList.vue @@ -5,7 +5,7 @@ {{ summary.orderCount }}收购单数(单) {{ summary.totalNetWeight.toLocaleString() }}重量合计({{ unitLabel }}) {{ fmtMoney(summary.avgPrice) }}均价(元/{{ unitLabel }}) - ¥ {{ fmtMoney(summary.totalAmount) }}金额合计(元) + {{ fmtSummaryMoney(summary.totalAmount) }}金额合计({{ summary.totalAmount >= 1000000 ? '万元' : '元' }}) {{ summary.farmerCount }}合作农户(户) {{ summary.todayOrderCount }}今日单数(单) @@ -858,6 +858,12 @@ const onTransfer = async () => { // ---------- 工具 ---------- const fmtMoney = (v?: number) => (v ?? 0).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) +// 金额合计:超过 100 万显示为万元,否则保留原样 +const fmtSummaryMoney = (v?: number) => { + const n = v ?? 0 + if (n >= 1000000) return '¥ ' + (n / 10000).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) + ' 万' + return '¥ ' + n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) +} onMounted(async () => { products.value = await getProducts() diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index b0882af..3d8e41a 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -11,18 +11,18 @@ export default defineConfig({ }, server: { host: '0.0.0.0', - port: 5173, + port: 9000, proxy: { '/api': { - target: 'http://localhost:5246', + target: 'http://localhost:9002', changeOrigin: true }, '/uploads': { - target: 'http://localhost:5246', + target: 'http://localhost:9002', changeOrigin: true }, '/mobile-upload.html': { - target: 'http://localhost:5246', + target: 'http://localhost:9002', changeOrigin: true } } diff --git a/scripts/start-backend.ps1 b/scripts/start-backend.ps1 index 225b0b1..6e19421 100644 --- a/scripts/start-backend.ps1 +++ b/scripts/start-backend.ps1 @@ -7,4 +7,4 @@ Start-Process -FilePath "dotnet" ` -RedirectStandardError "$root/backend-run.err.log" ` -WindowStyle Hidden Start-Sleep -Seconds 6 -Get-NetTCPConnection -LocalPort 5246 -ErrorAction SilentlyContinue | Where-Object State -eq Listen | Select-Object LocalPort, State, OwningProcess +Get-NetTCPConnection -LocalPort 9002 -ErrorAction SilentlyContinue | Where-Object State -eq Listen | Select-Object LocalPort, State, OwningProcess