Files
DocprintService/src/YhCore.WebApi/Controllers/Api/DocPrint/DocPrintStatisticsController.cs
T
2026-09-02 10:23:24 +08:00

66 lines
2.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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
{
/// <summary>
/// 文印统计看板控制器(对应旧 Areas/DocPrint/DocPrintStatisticsController,路由 api/docprint/statistics)。
/// 旧类级 [NoAuth]:schId 由前端传入(非当前用户),新项目 SSO 关闭时匿名放行、开启时按配置保护,
/// 语义一致。ExportRecord(Excel 导出,NPOI)延后迁移。
/// </summary>
[ApiController]
[Route(ApiRoutes.ApiPath + "/docprint/statistics")]
public class DocPrintStatisticsController : ControllerBase
{
private readonly IDocPrintStatisticsService _statistics;
public DocPrintStatisticsController(IDocPrintStatisticsService statistics)
{
_statistics = statistics;
}
/// <summary>打印总数/消耗/最多类型统计(旧 GetDocPrintCount)。</summary>
[HttpGet("GetDocPrintCount")]
public async Task<System.Collections.Generic.List<DocPrintCountItem>> GetDocPrintCount(
[FromQuery] int schId,
[FromQuery] DateTime? startDate = null,
[FromQuery] DateTime? endDate = null)
=> await _statistics.GetDocPrintCountAsync(schId, startDate, endDate);
/// <summary>饼图(按类型,消耗/数量,旧 GetPieChart)。</summary>
[HttpGet("GetPieChart")]
public async Task<System.Collections.Generic.List<PieChartSeries>> GetPieChart(
[FromQuery] int schId,
[FromQuery] DateTime? startDate = null,
[FromQuery] DateTime? endDate = null)
=> await _statistics.GetPieChartAsync(schId, startDate, endDate);
/// <summary>打印类型列表(旧 GetDocPrintType)。</summary>
[HttpGet("GetDocPrintType")]
public async Task<System.Collections.Generic.List<DocPrintTypeItem>> GetDocPrintType([FromQuery] int schId)
=> await _statistics.GetDocPrintTypeAsync(schId);
/// <summary>分页明细(旧 GetDocPrintList;旧 1 基 pageIndex 内部转 0 基)。</summary>
[HttpGet("GetDocPrintList")]
public async Task<DocPrintListResult> 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)
}
}