123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- using Hotline.Application.StatisticalReport;
- using Hotline.Share.Dtos;
- using Hotline.Share.Dtos.Order;
- using Hotline.Share.Dtos.StatisticalReport;
- using Hotline.Tools;
- using MapsterMapper;
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Mvc;
- using SqlSugar;
- using XF.Domain.Authentications;
- namespace Hotline.Api.Controllers
- {
- public class StatisticalReportController : BaseController
- {
- private readonly IMapper _mapper;
- private readonly ISessionContext _sessionContext;
- private readonly IOrderReportApplication _orderReportApplication;
- public StatisticalReportController(
- IMapper mapper,
- ISessionContext sessionContext,
- IOrderReportApplication orderReportApplication)
- {
- _mapper = mapper;
- _sessionContext = sessionContext;
- _orderReportApplication = orderReportApplication;
- }
- /// <summary>
- /// 坐席退件明细
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpGet("getseatreturnorderlist")]
- [AllowAnonymous]
- public async Task<PagedDto<SeatReturnOrderListDto>> GetSeatReturnOrderList([FromQuery] SeatReturnOrderListRequestDto dto)
- {
- RefAsync<int> total = 0;
- var dataList = await _orderReportApplication.GetSeatReturnOrderList(dto)
- //转分页数据
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- return new PagedDto<SeatReturnOrderListDto>(total.Value, _mapper.Map<IReadOnlyList<SeatReturnOrderListDto>>(dataList));
- }
- /// <summary>
- /// 坐席退件明细--导出
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost("getseatreturnorderlist_export")]
- public async Task<FileStreamResult> GetSeatReturnOrderListExport([FromBody] ExportExcelDto<SeatReturnOrderListRequestDto> dto)
- {
- var query = _orderReportApplication.GetSeatReturnOrderList(dto.QueryDto);
- List<SeatReturnOrderListDto> data;
- if (dto.IsExportAll)
- {
- data = await query.ToListAsync(HttpContext.RequestAborted);
- }
- else
- {
- RefAsync<int> total = 0;
- data = await query.ToPageListAsync(dto.QueryDto.PageIndex, dto.QueryDto.PageSize, total);
- }
- dynamic? dynamicClass = DynamicClassHelper.CreateDynamicClass(dto.ColumnInfos);
- var dtos = data
- .Select(stu => _mapper.Map(stu, typeof(SeatReturnOrderListDto), dynamicClass))
- .Cast<object>()
- .ToList();
- var stream = ExcelHelper.CreateStream(dtos);
- return ExcelStreamResult(stream, "坐席退件明细数据");
- }
- /// <summary>
- /// 中心退件明细
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpGet("getcenterreturnorderlist")]
- [AllowAnonymous]
- public async Task<PagedDto<SeatReturnOrderListDto>> GetCenterReturnOrderList([FromQuery] SeatReturnOrderListRequestDto dto)
- {
- RefAsync<int> total = 0;
- var dataList = await _orderReportApplication.GetCenterReturnOrderList(dto)
- //转分页数据
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- return new PagedDto<SeatReturnOrderListDto>(total.Value, _mapper.Map<IReadOnlyList<SeatReturnOrderListDto>>(dataList));
- }
- /// <summary>
- /// 中心退件明细--导出
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost("getcenterreturnorderlist_export")]
- public async Task<FileStreamResult> GetCenterReturnOrderListExport([FromBody] ExportExcelDto<SeatReturnOrderListRequestDto> dto)
- {
- var query = _orderReportApplication.GetCenterReturnOrderList(dto.QueryDto);
- List<SeatReturnOrderListDto> data;
- if (dto.IsExportAll)
- {
- data = await query.ToListAsync(HttpContext.RequestAborted);
- }
- else
- {
- RefAsync<int> total = 0;
- data = await query.ToPageListAsync(dto.QueryDto.PageIndex, dto.QueryDto.PageSize, total);
- }
- dynamic? dynamicClass = DynamicClassHelper.CreateDynamicClass(dto.ColumnInfos);
- var dtos = data
- .Select(stu => _mapper.Map(stu, typeof(SeatReturnOrderListDto), dynamicClass))
- .Cast<object>()
- .ToList();
- var stream = ExcelHelper.CreateStream(dtos);
- return ExcelStreamResult(stream, "中心退件明细数据");
- }
- }
- }
|