From d73da8d371661d8d6c48a502bd7f0160fd7fc317 Mon Sep 17 00:00:00 2001 From: Administrator Date: Sat, 7 May 2022 16:42:58 +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 --- .../Services/Report/UnSettledSumService.cs | 78 ++++++++++++++++++- 1 file changed, 74 insertions(+), 4 deletions(-) diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs index 5be7b2f3..06017c11 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs @@ -1,4 +1,6 @@ using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Excel; +using Shouldly; using System; using System.Collections.Generic; using System.Linq; @@ -6,8 +8,10 @@ using System.Text; using System.Threading.Tasks; using TaskJob.EventArgs; using TaskJob.Interfaces; +using Volo.Abp.BlobStoring; using Volo.Abp.DependencyInjection; using Volo.Abp.Uow; +using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; namespace SettleAccount.Job.Services.Report @@ -52,6 +56,7 @@ namespace SettleAccount.Job.Services.Report private readonly OutputService _outputService; private readonly ErpPartDapperRepository _erpDapper; private readonly SettleSparePartDapperReportRepository _sparepartdapper; + private readonly IBlobContainer _fileContainer; public UnSettledSumService( HQHSettledDetailDapperRepository hqkanbanDapper, KanbanUnSettledDapperRepository kanbanDapper, @@ -59,7 +64,8 @@ namespace SettleAccount.Job.Services.Report OutputService outputService, ErpPartDapperRepository erpDapper, WmsDapperRepository wmsDapper, - SettleSparePartDapperReportRepository sparepartdapper + SettleSparePartDapperReportRepository sparepartdapper, + IBlobContainer fileContainer ) { _wmsDapper = wmsDapper; @@ -69,15 +75,33 @@ namespace SettleAccount.Job.Services.Report _outputService = outputService; _erpDapper = erpDapper; _sparepartdapper = sparepartdapper; + _fileContainer = fileContainer; } [UnitOfWork(false)] public string ExportFile(Guid id, List exportName, List p_list) { var _lsExport= GetReport(id,exportName,p_list); + var _lsleft = GetLeftReport(id, exportName, p_list); + + var _first = exportName.FirstOrDefault(); + + + ExcelExporter _exporter = new ExcelExporter();//导出Excel + var result = _exporter.Append(_lsExport, "汇总核对表1") + .SeparateBySheet() + .Append(_lsleft, "汇总核对表2") + .ExportAppendDataAsByteArray(); + result.ShouldNotBeNull(); + _fileContainer.SaveAsync("结算未结寄售核对表", result.Result, true); + + + + + + + - var _first = exportName.FirstOrDefault(); - _outputService.Export(id, _first, _lsExport); return id.ToString(); } @@ -378,7 +402,7 @@ namespace SettleAccount.Job.Services.Report var _lst = _wmsDapper.GetSalesStockSum(version); var query = from itm in _lst join itm1 in _ls - on new { Version = itm.Version, PartCode = itm.PartCode, LocCode= itm.LocCode.ToUpper()} equals new { Version = itm1.版本, PartCode = itm1.物料号, LocCode = itm1.库位} + on new { Version = itm.Version, PartCode = itm.PartCode.Trim(), LocCode= itm.LocCode.ToUpper()} equals new { Version = itm1.版本, PartCode = itm1.物料号.Trim(), LocCode = itm1.库位} into temp from tm in temp.DefaultIfEmpty() select new UnSettledSum @@ -401,5 +425,51 @@ into temp }; return query.ToList(); } + + + public List GetLeftReport(Guid id, List exportName, List p_list) + { + var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value; + List _ls = new List(); + _ls.AddRange(GetFisSum(id, exportName, p_list)); + _ls.AddRange(GetHQKanbanSum(id, exportName, p_list)); + _ls.AddRange(GetKanbanSum(id, exportName, p_list)); + _ls.AddRange(GetSparePartSum(id, exportName, p_list));//大众备件未结 + + + + var _lst = _wmsDapper.GetSalesStockSum(version); + var query = from itm in _ls + join itm1 in _lst + on new { Version = itm.版本, PartCode = itm.物料号.Trim(), LocCode = itm.库位 } equals + new { Version = itm1.Version, PartCode = itm1.PartCode.Trim(), LocCode = itm1.LocCode.ToUpper() } +into temp + from tm in temp.DefaultIfEmpty() + select new UnSettledSum + { + + 版本 = itm.版本, + 物料号 = itm.物料号, + 物料描述 = itm.物料号, + 物料组编码 = itm.物料组编码, + 物料组车型 = itm.物料组车型, + SAS未结明细汇总 = tm == null ? "0" : tm.EndQty.ToString(), + WMS期初库存 = tm == null ? "0" : tm.StartQty.ToString(), + WMS期末库存 = tm == null ? "0" : tm.EndQty.ToString(), + 库位 = itm.库位, + 本月减少 = tm == null ? "0" : tm.OutQty.ToString(), + 本月增加 = tm == null ? "0" : tm.InQty.ToString(), + 差异 = (tm.EndQty - decimal.Parse(tm == null ? "0" : itm.SAS未结明细汇总)).ToString() + + + }; + return query.ToList(); + } + + + + + + } }