|
@@ -1,14 +1,19 @@
|
|
using Hotline.Api.Filter;
|
|
using Hotline.Api.Filter;
|
|
using Hotline.Application.Enterprise;
|
|
using Hotline.Application.Enterprise;
|
|
|
|
+using Hotline.Configurations;
|
|
using Hotline.Enterprise;
|
|
using Hotline.Enterprise;
|
|
|
|
+using Hotline.Orders;
|
|
using Hotline.Repository.SqlSugar.Extensions;
|
|
using Hotline.Repository.SqlSugar.Extensions;
|
|
using Hotline.Share.Dtos;
|
|
using Hotline.Share.Dtos;
|
|
using Hotline.Share.Dtos.Enterprise;
|
|
using Hotline.Share.Dtos.Enterprise;
|
|
using Hotline.Share.Dtos.Order;
|
|
using Hotline.Share.Dtos.Order;
|
|
using Hotline.Share.Dtos.Users;
|
|
using Hotline.Share.Dtos.Users;
|
|
using Hotline.Share.Requests;
|
|
using Hotline.Share.Requests;
|
|
|
|
+using Hotline.Tools;
|
|
using MapsterMapper;
|
|
using MapsterMapper;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
+using Microsoft.Extensions.Options;
|
|
|
|
+using XF.Domain.Authentications;
|
|
using XF.Domain.Repository;
|
|
using XF.Domain.Repository;
|
|
|
|
|
|
namespace Hotline.Api.Controllers
|
|
namespace Hotline.Api.Controllers
|
|
@@ -18,17 +23,23 @@ namespace Hotline.Api.Controllers
|
|
private readonly IEnterpriseService _enterpriseService;
|
|
private readonly IEnterpriseService _enterpriseService;
|
|
private readonly IRepository<EnterpriseSpecialist> _enterpriseSpecialistRepository;
|
|
private readonly IRepository<EnterpriseSpecialist> _enterpriseSpecialistRepository;
|
|
private readonly IEnterpriseApplication _enterpriseApplication;
|
|
private readonly IEnterpriseApplication _enterpriseApplication;
|
|
|
|
+ private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
|
|
|
|
+ private readonly ISessionContext _sessionContext;
|
|
private readonly IMapper _mapper;
|
|
private readonly IMapper _mapper;
|
|
|
|
|
|
public EnterprisesController(
|
|
public EnterprisesController(
|
|
IEnterpriseService enterpriseService,
|
|
IEnterpriseService enterpriseService,
|
|
IRepository<EnterpriseSpecialist> enterpriseSpecialistRepository,
|
|
IRepository<EnterpriseSpecialist> enterpriseSpecialistRepository,
|
|
IEnterpriseApplication enterpriseApplication,
|
|
IEnterpriseApplication enterpriseApplication,
|
|
|
|
+ IOptionsSnapshot<AppConfiguration> appOptions,
|
|
|
|
+ ISessionContext sessionContext,
|
|
IMapper mapper)
|
|
IMapper mapper)
|
|
{
|
|
{
|
|
_enterpriseService = enterpriseService;
|
|
_enterpriseService = enterpriseService;
|
|
_enterpriseSpecialistRepository = enterpriseSpecialistRepository;
|
|
_enterpriseSpecialistRepository = enterpriseSpecialistRepository;
|
|
_enterpriseApplication = enterpriseApplication;
|
|
_enterpriseApplication = enterpriseApplication;
|
|
|
|
+ _appOptions = appOptions;
|
|
|
|
+ _sessionContext = sessionContext;
|
|
_mapper = mapper;
|
|
_mapper = mapper;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -115,7 +126,40 @@ namespace Hotline.Api.Controllers
|
|
return await query.CountAsync(HttpContext.RequestAborted);
|
|
return await query.CountAsync(HttpContext.RequestAborted);
|
|
}
|
|
}
|
|
|
|
|
|
- //todo export
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 导出企业专员工单
|
|
|
|
+ /// </summary>
|
|
|
|
+ [HttpPost("specialist/orders/export")]
|
|
|
|
+ public async Task<FileStreamResult> ExportOrders([FromBody] ExportExcelDto<QueryOrderDto> dto)
|
|
|
|
+ {
|
|
|
|
+ var query = await _enterpriseApplication.QueryEnterpriseSpecialistOrdersAsync(dto, HttpContext.RequestAborted);
|
|
|
|
+ List<Order> orders;
|
|
|
|
+ if (dto.IsExportAll)
|
|
|
|
+ {
|
|
|
|
+ orders = await query.ToListAsync(HttpContext.RequestAborted);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ var (_, items) = await query.ToPagedListAsync(dto.QueryDto, HttpContext.RequestAborted);
|
|
|
|
+ orders = items;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var orderDtos = _mapper.Map<ICollection<OrderDto>>(orders);
|
|
|
|
+
|
|
|
|
+ if (_appOptions.Value.IsLuZhou && !_sessionContext.OrgIsCenter)
|
|
|
|
+ orderDtos = orderDtos.Select(p => p.DataMask()).ToList();
|
|
|
|
+
|
|
|
|
+ dynamic? dynamicClass = DynamicClassHelper.CreateDynamicClass(dto.ColumnInfos);
|
|
|
|
+
|
|
|
|
+ var dtos = orderDtos
|
|
|
|
+ .Select(stu => _mapper.Map(stu, typeof(OrderDto), dynamicClass))
|
|
|
|
+ .Cast<object>()
|
|
|
|
+ .ToList();
|
|
|
|
+
|
|
|
|
+ var stream = ExcelHelper.CreateStream(dtos);
|
|
|
|
+
|
|
|
|
+ return ExcelStreamResult(stream, "企业专员工单数据");
|
|
|
|
+ }
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
}
|
|
}
|