using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Yh.Platform.Abstractions; using YhCore.Common; using YhCore.Model.Dto; using YhCore.Service.Interfaces; namespace YhCore.WebApi.Controllers.Api.DocPrint { /// /// 文印统计看板控制器(对应旧 Areas/DocPrint/DocPrintStatisticsController,路由 api/docprint/statistics)。 /// 旧类级 [NoAuth]:schId 由前端传入(非当前用户),新项目 SSO 关闭时匿名放行、开启时按配置保护, /// 语义一致。ExportRecord(Excel 导出,NPOI)延后迁移。 /// [ApiController] [Route(ApiRoutes.ApiPath + "/docprint/statistics")] public class DocPrintStatisticsController : ControllerBase { private readonly IDocPrintStatisticsService _statistics; public DocPrintStatisticsController(IDocPrintStatisticsService statistics) { _statistics = statistics; } /// 打印总数/消耗/最多类型统计(旧 GetDocPrintCount)。 [HttpGet("GetDocPrintCount")] public async Task> GetDocPrintCount( [FromQuery] int schId, [FromQuery] DateTime? startDate = null, [FromQuery] DateTime? endDate = null) => await _statistics.GetDocPrintCountAsync(schId, startDate, endDate); /// 饼图(按类型,消耗/数量,旧 GetPieChart)。 [HttpGet("GetPieChart")] public async Task> GetPieChart( [FromQuery] int schId, [FromQuery] DateTime? startDate = null, [FromQuery] DateTime? endDate = null) => await _statistics.GetPieChartAsync(schId, startDate, endDate); /// 打印类型列表(旧 GetDocPrintType)。 [HttpGet("GetDocPrintType")] public async Task> GetDocPrintType([FromQuery] int schId) => await _statistics.GetDocPrintTypeAsync(schId); /// 分页明细(旧 GetDocPrintList;旧 1 基 pageIndex 内部转 0 基)。 [HttpGet("GetDocPrintList")] public async Task GetDocPrintList( [FromQuery] int schId, [FromQuery] string docType = "ALL", [FromQuery] string likeName = null, [FromQuery] int pageIndex = 1, [FromQuery] int pageSize = 10, [FromQuery] DateTime? startDate = null, [FromQuery] DateTime? endDate = null) { if (pageSize <= 0) throw new DException("pageSize 必须大于 0"); return await _statistics.GetDocPrintListAsync(schId, docType, likeName, pageIndex, pageSize, startDate, endDate); } // 延后:ExportRecord(Excel 导出,NPOI) } }