yunfeng.liu
3 years ago
28 changed files with 598 additions and 69 deletions
@ -0,0 +1,161 @@ |
|||
using EFCore.BulkExtensions; |
|||
using Magicodes.ExporterAndImporter.Core; |
|||
using Magicodes.ExporterAndImporter.Excel; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Shouldly; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.Domain.Repositories; |
|||
using Volo.Abp.Uow; |
|||
using Win.Abp.Snowflakes; |
|||
using Win.Sfs.BaseData.ImportExcelCommon; |
|||
using Win.Sfs.SettleAccount.CommonManagers; |
|||
using Win.Sfs.SettleAccount.Constant; |
|||
using Win.Sfs.SettleAccount.Entities.Wms.WmsSumOutput; |
|||
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; |
|||
using Win.Sfs.Shared.Filter; |
|||
|
|||
namespace Win.Sfs.SettleAccount.Entities.WMS |
|||
{ |
|||
[Route("api/settleaccount/WMSOutputDetailWithCodeReport")] |
|||
public class WMSOutputDetailWithCodeReportAppService : |
|||
SettleAccountApplicationBase<WmsDetailWithCodeReport> |
|||
{ |
|||
private readonly ISettleAccountBranchEfCoreRepository<WmsDetailWithCodeReport, Guid> _wmsRepository; |
|||
private readonly WmsOutputSumDapperRepository _dapper; |
|||
private readonly IExcelImportAppService _excelImportService; |
|||
|
|||
private readonly ErpSumOutputDapperRepository _erpDapper; |
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
/// <param name="wmsRepository"></param>
|
|||
/// <param name="job"></param>
|
|||
|
|||
public WMSOutputDetailWithCodeReportAppService( |
|||
WmsOutputSumDapperRepository dapper, |
|||
ISettleAccountBranchEfCoreRepository<WmsDetailWithCodeReport, Guid> wmsRepository, |
|||
ISettleAccountBranchEfCoreRepository<TaskJob, Guid> job, |
|||
IExcelImportAppService excelImportService, |
|||
IDistributedCache<WmsDetailWithCodeReport> cache, |
|||
ISnowflakeIdGenerator snowflakeIdGenerator, |
|||
ICommonManager commonManager, |
|||
ErpSumOutputDapperRepository erpDapper |
|||
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) |
|||
{ |
|||
_erpDapper = erpDapper; |
|||
_wmsRepository = wmsRepository; |
|||
_dapper = dapper; |
|||
_excelImportService = excelImportService; |
|||
|
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("Make")] |
|||
[UnitOfWork(false)] |
|||
public async Task<string> ReportMake(string version, DateTime accountDate) |
|||
{ |
|||
//有条码的业务(可根据条码/K号/底盘号,查询是否结算过,结算期间)
|
|||
var _ls = _dapper.GetWmsSearchWithCodeReportList(version, "0"); |
|||
|
|||
var _count = _wmsRepository.Count(p => p.Version == version && p.State > 0); |
|||
if (_count > 0) |
|||
{ |
|||
throw new BusinessException("8899", "不能重新生成此版本!"); |
|||
} |
|||
else |
|||
{ |
|||
var query = _wmsRepository.Where(p => p.Version == version); |
|||
await query.BatchDeleteAsync(); |
|||
} |
|||
List<WmsDetailWithCodeReport> _lst = new List<WmsDetailWithCodeReport>(); |
|||
if (_ls != null && _ls.Count() > 0) |
|||
{ |
|||
foreach (var itm in _ls) |
|||
{ |
|||
_lst.Add(new WmsDetailWithCodeReport( |
|||
Guid.NewGuid(), |
|||
itm.客户, |
|||
itm.出库类型, |
|||
version, |
|||
itm.结算单, |
|||
itm.通用代码号, |
|||
itm.物料号, |
|||
itm.结算数量, |
|||
itm.实际出库数量, |
|||
itm.差异数量, |
|||
itm.物料组编码, |
|||
itm.物料组车型, |
|||
itm.物料描述, |
|||
itm.备注, |
|||
0)); |
|||
} |
|||
} |
|||
await _wmsRepository.GetDbContext().BulkInsertAsync(_lst); |
|||
return ApplicationConsts.SuccessStr; |
|||
} |
|||
/// <summary>
|
|||
/// Wms汇总合计明细
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
/// <returns></returns>
|
|||
[HttpPost] |
|||
[Route("WmsDetailReport")] |
|||
|
|||
virtual public async Task<PagedResultDto<WmsDetailWithCodeReport>> GetListAsync(WmsRequestDetailReportDto input) |
|||
{ |
|||
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version }); |
|||
var entities = await _wmsRepository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, input.MaxResultCount, |
|||
input.SkipCount, true); |
|||
var totalCount = await GetCountAsync(input); |
|||
return new PagedResultDto<WmsDetailWithCodeReport>(totalCount, entities); |
|||
} |
|||
|
|||
|
|||
private async Task<long> GetCountAsync(WmsRequestDetailReportDto input) |
|||
{ |
|||
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version }); |
|||
return await _wmsRepository.GetCountByFilterAsync(GuidGenerator.Create(), input.Filters); |
|||
} |
|||
[HttpPost] |
|||
[Route("ModifyTaskState")] |
|||
|
|||
public virtual async Task<bool> SyncInterface() |
|||
{ |
|||
//_wmsRepository.Where(p => p.BillNum ==)
|
|||
return true; |
|||
} |
|||
|
|||
[HttpPost] |
|||
[Route("Export")] |
|||
virtual public async Task<string> ExportAsync(WmsRequestDetailReportDto input) |
|||
{ |
|||
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version }); |
|||
var entities = await _wmsRepository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, int.MaxValue, |
|||
0, true); |
|||
var dtoDetails = ObjectMapper.Map<List<WmsDetailWithCodeReport>, List<WmsDetailWithCodeReportDto>>(entities); |
|||
IExporter _excel = new ExcelExporter(); |
|||
byte[] result = null; |
|||
var _fileName = string.Format("差异清单(有条码)报表_{0}.xlsx", Guid.NewGuid().ToString()); |
|||
result = await _excel.ExportAsByteArray(dtoDetails); |
|||
result.ShouldNotBeNull(); |
|||
//保存导出文件到服务器存成二进制
|
|||
await _excelImportService.SaveBlobAsync( |
|||
new SaveExcelImportInputDto |
|||
{ |
|||
Name = _fileName, |
|||
Content = result |
|||
} |
|||
); |
|||
return _fileName; |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
Loading…
Reference in new issue