| | |
| | | using Microsoft.AspNetCore.Authorization; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using SqlSugar; |
| | | using WIDESEA_Core; |
| | |
| | | /// <summary> |
| | | /// 总览数据 |
| | | /// </summary> |
| | | [HttpGet("Overview")] |
| | | [HttpGet("Overview"), AllowAnonymous] |
| | | public async Task<WebResponseContent> Overview() |
| | | { |
| | | try |
| | |
| | | /// SqlSugar 的 GroupBy 不支持对 .Date 这样的计算列直接生成 SQL GROUP BY, |
| | | /// 因此采用此方式以确保跨数据库兼容性。 |
| | | /// </remarks> |
| | | [HttpGet("DailyStats")] |
| | | [HttpGet("DailyStats"), AllowAnonymous] |
| | | public async Task<WebResponseContent> DailyStats([FromQuery] int days = 30) |
| | | { |
| | | try |
| | |
| | | /// 注意:数据在 SQL 层过滤后,在应用层按 ISO 8601 周键分组。 |
| | | /// 周键为 "YYYY-Www" 格式,无法直接在 SQL 层用 GROUP BY 实现。 |
| | | /// </remarks> |
| | | [HttpGet("WeeklyStats")] |
| | | [HttpGet("WeeklyStats"), AllowAnonymous] |
| | | public async Task<WebResponseContent> WeeklyStats([FromQuery] int weeks = 12) |
| | | { |
| | | try |
| | |
| | | /// SqlSugar 的 GroupBy 不支持匿名对象 (Year, Month) 直接映射到 SQL GROUP BY, |
| | | /// 因此采用此方式以确保跨数据库兼容性。 |
| | | /// </remarks> |
| | | [HttpGet("MonthlyStats")] |
| | | [HttpGet("MonthlyStats"), AllowAnonymous] |
| | | public async Task<WebResponseContent> MonthlyStats([FromQuery] int months = 12) |
| | | { |
| | | try |
| | |
| | | /// <summary> |
| | | /// 库存库龄分布 |
| | | /// </summary> |
| | | [HttpGet("StockAgeDistribution")] |
| | | [HttpGet("StockAgeDistribution"), AllowAnonymous] |
| | | public async Task<WebResponseContent> StockAgeDistribution() |
| | | { |
| | | try |
| | |
| | | /// <remarks> |
| | | /// 使用 SQL GROUP BY 在数据库层面聚合,避免加载全部库存记录到内存。 |
| | | /// </remarks> |
| | | [HttpGet("StockByWarehouse")] |
| | | [HttpGet("StockByWarehouse"), AllowAnonymous] |
| | | public async Task<WebResponseContent> StockByWarehouse() |
| | | { |
| | | try |