From d05b6e3e445b66fcb887d7448b88716160ee00f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Mon, 4 Dec 2023 17:03:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/BQ/VmiAppService.cs | 44 ++++++++----------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs index 18456b52..9f2c577c 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Data.SqlClient; @@ -77,9 +77,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ private readonly TaskJobService _service; private readonly Volo.Abp.ObjectMapping.IObjectMapper _maper; protected readonly IExcelImportAppService _excelImportService; - - - private readonly IConfiguration _config; public VmiAppService(IConfiguration cfg, IServiceProvider serviceProvider, IGuidGenerator guidGenerator, @@ -92,13 +89,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ ICurrentUser currentUser, ILogger logger, IExcelImportAppService excelImportService, - TaskJobService service, - IConfiguration config + TaskJobService service ) { - _config = config; + _maper = maper; this._codeRepository = codeRepository; this._cfg = cfg; this._guidGenerator = guidGenerator; @@ -109,13 +105,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ this._hubContext = hubContext; this._currentUser = currentUser; this._logger = logger; - _service = service; + _service = service; LinqToDBForEFTools.Initialize(); _excelImportService = excelImportService; - - string tax = config["Tax"]; - - } /// @@ -185,12 +177,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } } - - + + @@ -243,10 +235,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ query = query.Where(input.Filters.ToLambda()); } query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting); - var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode, o.VinCode }).Select(o => new VmiBalanceDto { VinCode = o.Key.VinCode, ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.ChangedQty), LastTime = o.Max(o => o.ChangedTime) }).Where(p=>p.Qty!=0); + var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode, o.VinCode }).Select(o => new VmiBalanceDto { VinCode = o.Key.VinCode, ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.ChangedQty), LastTime = o.Max(o => o.ChangedTime) }).Where(p => p.Qty != 0); var entities = query2.ToList(); - // var entities = await _balanceRepository.GetListByFilterAsync(input.Filters).ConfigureAwait(false); + // var entities = await _balanceRepository.GetListByFilterAsync(input.Filters).ConfigureAwait(false); var fileName = $"库存余额_{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.xlsx"; var content = this.GetContent(entities, "库存余额"); await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false); @@ -527,7 +519,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ if (entities.Count > 1000000) { - throw new UserFriendlyException("导出行数超过100W不能导出,请重新录入查询条件导出","400"); + throw new UserFriendlyException("导出行数超过100W不能导出,请重新录入查询条件导出", "400"); } var dtos = _maper.Map, List>(entities); @@ -550,7 +542,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ public async Task ReplenishedExportAsync(ARequestDto input) { RequestDto inputTemp = new RequestDto(); - var beginDate= DateTime.Parse(input.startBillTime).ToString("yyyy/MM/dd") + " 00:00:00 "; + var beginDate = DateTime.Parse(input.startBillTime).ToString("yyyy/MM/dd") + " 00:00:00 "; var endDate = DateTime.Parse(input.endBillTime).ToString("yyyy/MM/dd") + " 23:59:59 "; DateTimeFormatInfo dtFormat = new DateTimeFormatInfo(); dtFormat.ShortDatePattern = "yyyy/MM/dd HH:mm:ss"; @@ -616,8 +608,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ // where a.MinChangedTime < b.MinChangedTime && a.SumChangedQty <= b.SumChangedQty // select b); - var entities = result.Where(p => p.BillTime >= DateTime.Parse(beginDate) && p.BillTime <= DateTime.Parse(endDate) && p.LogType==VmiLogType.Type100).ToList(); - // IQueryable query = _logRepository.WhereIf(input.Filters?.Count != 0, input.Filters.ToLambda()); + var entities = result.Where(p => p.BillTime >= DateTime.Parse(beginDate) && p.BillTime <= DateTime.Parse(endDate) && p.LogType == VmiLogType.Type100).ToList(); + // IQueryable query = _logRepository.WhereIf(input.Filters?.Count != 0, input.Filters.ToLambda()); var fileName = $"补货数据_{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.xlsx"; var content = this.GetContent(entities, "补货数据_"); await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false); @@ -645,13 +637,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ //IQueryable query = _logRepository.WhereIf(input.Filters?.Count != 0, input.Filters.ToLambda()); IExporter _csv = new CsvExporter(); IExporter _excel = new ExcelExporter(); - - + + byte[] result = null; - + result = await _excel.ExportAsByteArray(entities).ConfigureAwait(false); - + result.ShouldNotBeNull(); string _fileName = $"导出文件_{Guid.NewGuid().ToString()}.xlsx"; @@ -863,7 +855,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ foreach (var itm in logList) { - itm.Version= GetVersionByBillTime(itm.BillTime.Value, value); + itm.Version = GetVersionByBillTime(itm.BillTime.Value, value); } @@ -1136,7 +1128,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } } var results = new List(); - Validator.TryValidateObject(model, new System.ComponentModel.DataAnnotations.ValidationContext (model, null, null), results); + Validator.TryValidateObject(model, new System.ComponentModel.DataAnnotations.ValidationContext(model, null, null), results); list.Add(new Tuple>(model, results)); } return list;