From 60671ae6c3895480ca9733b630c251b03145cee1 Mon Sep 17 00:00:00 2001 From: Administrator Date: Sat, 19 Feb 2022 15:18:25 +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 --- .vs/Win.Sfs.SmartSettlementSystem.PG/v16/.suo | Bin 79872 -> 79872 bytes .../appsettings.Development.json | 120 +- .../InternalGateway.Host/appsettings.json | 147 +- .../Logs/log-20220218.txt | 2493 +++++++++++++++ .../Logs/log-20220219.txt | 2697 +++++++++++++++++ .../appsettings.Development.json | 10 +- .../appsettings.json | 10 +- .../Report/UnSettledDetailDapperRepository.cs | 4 +- .../Report/WmsOutputSumDapperRepository.cs | 338 +++ ...UnInvoiceSettledDetailDiffExportService.cs | 103 +- .../Report/WmsOutputSumExportService.cs | 23 +- 11 files changed, 5887 insertions(+), 58 deletions(-) create mode 100644 src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Logs/log-20220218.txt create mode 100644 src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Logs/log-20220219.txt diff --git a/.vs/Win.Sfs.SmartSettlementSystem.PG/v16/.suo b/.vs/Win.Sfs.SmartSettlementSystem.PG/v16/.suo index 84ff170240337bbf06359ea25c8fa083f0d4bf83..e3209a30f23ac4d791eb31ca428c10d85fa7e0c6 100644 GIT binary patch delta 1763 zcmds%OH30{6o%&x6KSCpsLHcK!4W~I(spPO5CIVtQD}VxBB(qhN(??IkHi>?F)9z0 z_GlWTiM7VaMiZHZTZ}A-abY40RxV83V}c2Z5&f^W*aaFBqYH2H&AD^$x#!&Z&uKk# zl4njDt7j=sou3#>p-eGD8@O~GTDSHKMyenPi?A`U zu^=8q10PjLNx9sEj}2J)44VMU-`B#XgA8B-E4|LNf!mny&5f{mARm~)Ca@V401L1J z8&E(YumcAu0$V^aC;_ElD<}ioKsl%Ym7ognTsvT^!A|bB3zOZT2J8W~U@zDQoPZzT z!-e^NZ~z(TI@MTUjk2{SaEkx!E)67?Hi z>5Onni*$6a8ucZ*S+3fXIKq6&3q8|fTOa9Co-L^hiiS-jSFvTjJ*A%M65*c|d1gNK zHBIG}`i#4Nq&L=U`2F~RlsU9us9p9xRCz01O*b79`K_{WtL#awh~T{6TmAPHR^Xp4 zWS9K`g$?@TDP2}5aVW4%b!^`m=4~-ruHx`;D8LBp zD7Xf$gByT%TzC-P6TQwPwSDzn_BWFxhm!=Y;zZHV3c1DJqO{wULUWtdW-}{WIvnO! zTbs>%+|ll^9Peh7yOwh tJ#+bw+L`P(E3Et35jzVq{~Luhs*O2~>~{)67vFc1soV5yIG^>#eg)m%2Rr}( delta 1939 zcmds%Urbw79LLY^?lM}q7fM$d(6zAAP7=#j*jhoi*;=zKu7*~pf>Sr3WgDVYRyK5h zDCo=_MB95}2s#sOl=$K@xetp*W3%yK6eEdy@Y(q8OfW%>%Q*nVQG|h@}E(6^5G2=Wa1<@ z+J3*aT9(n&GRDe56{rTKJRomYo#^ET-Kt1O>T4Twh9FuO*aq$d)9J_{b)+LZO2YW6 zOh>Gvo#=FdC%_@_BzOuu4Gx1Npd0jnUJwN_&DBCI0Mdtb6^xCfhL7=V#VK`UQeu2PG#I^um*%!rT9l)4$%s+ z%sHC@t&r;uAjA}+7MK60d}Z_8R3@jRsjh$PsF(T2<*yqmp{P)kkEu?cP!^O17}O%8 zo=`jKKiEs#0B_sYTq|JSk(O8wM-?5&ZmZ>Nup_a9e+h?LEM!f4KL3+RoS`tgX*-ZTXr#^xoUi z%Tx9r+r{E*ts%DX3D5dx>O9QD0wBoRQSV#%1=&tKo_aD+L;UQ0O?vizKTSN+FNNRFCHH+rEZPyef'{0}' ", begin); + str += string.Format(" and beginTime>='{0}' ", begin); } if (!string.IsNullOrEmpty(end)) { - str += string.Format(" and beginTime<'{0}' ", end); + str += string.Format(" and beginTime<='{0}' ", end); } //if (!string.IsNullOrEmpty(materialCode)) //{ diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsOutputSumDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsOutputSumDapperRepository.cs index 78bb404f..54b9ef7d 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsOutputSumDapperRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/WmsOutputSumDapperRepository.cs @@ -33,6 +33,30 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report } + public class WmsOutPutSumExtend + { + [ExporterHeader(DisplayName = "客户 ")] + public string 客户 {set;get;} + [ExporterHeader(DisplayName = "出库类型")] + public string 出库类型 {set;get;} + [ExporterHeader(DisplayName = "出库单")] + public string 出库单 {set;get;} + [ExporterHeader(DisplayName = "物料号")] + public string 物料号 {set;get;} + [ExporterHeader(DisplayName = "物料描述")] + public string 物料描述 {set;get;} + [ExporterHeader(DisplayName = "出库单号")] + public string 出库单号 {set;get;} + [ExporterHeader(DisplayName = "物料组")] + public string 物料组 {set;get;} + [ExporterHeader(DisplayName = "待出库")] + public string 待出库 {set;get;} + [ExporterHeader(DisplayName = "已出库")] + public string 已出库 { set; get; } + + } + + public class WmsOutputSumDapperRepository: DapperRepository, ITransientDependency { @@ -40,6 +64,320 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report : base(dbContextProvider) { } + + public virtual List GetWmsSumExtendList(string version) + { + + var str = "SELECT\n" + + " Client 客户,\n" + + " [Type] 出库类型,\n" + + " BillNum 出库单,\n" + + " MaterialCode 物料号,\n" + + " MaterialDesc 物料描述,\n" + + " BillNum 出库单号,\n" + + " MaterialGroup 物料组,\n" + + " [1] 待出库,\n" + + " ISNULL([2], 0 ) 已出库 \n" + + "FROM\n" + + " (\n" + + " SELECT\n" + + " * \n" + + " FROM\n" + + " (\n" + + " SELECT\n" + + " temp.Client,\n" + + " temp.Type,\n" + + " temp.BillNum,\n" + + " temp.MaterialCode,\n" + + " temp2.MaterialDesc,\n" + + " temp.Qty,\n" + + " 1 STATE,\n" + + " EstimateTypeDesc MaterialGroup,\n" + + " EstimateType \n" + + " FROM\n" + + " (\n" + + " SELECT\n" + + " '大众准时化出库' AS Type,\n" + + " '大众' Client,\n" + + " BillNum,\n" + + " MaterialCode,\n" + + " SUM( Qty ) Qty \n" + + " FROM\n" + + " Set_WmsJitOutPutDetial \n" + + " WHERE\n" + + " State = 1 \n" + + " AND VERSION = '{0}' \n" + + " GROUP BY\n" + + " BillNum,\n" + + " MaterialCode UNION ALL\n" + + " SELECT\n" + + " '大众看板出库' AS Type,\n" + + " '大众' Client,\n" + + " BillNum,\n" + + " MaterialCode,\n" + + " SUM( Qty ) Qty \n" + + " FROM\n" + + " Set_WmsKanbanOutPutDetial \n" + + " WHERE\n" + + " State = 1 \n" + + " AND VERSION = '{0}' \n" + + " GROUP BY\n" + + " BillNum,\n" + + " MaterialCode UNION ALL\n" + + " SELECT\n" + + " '大众无看板出库' AS Type,\n" + + " '大众' Client,\n" + + " BillNum,\n" + + " SapMaterialCode MaterialCode,\n" + + " SUM( Qty ) Qty \n" + + " FROM\n" + + " Set_WmsWithOutKanbanOutPutDetial \n" + + " WHERE\n" + + " State = 1 \n" + + " AND VERSION = '{0}' \n" + + " GROUP BY\n" + + " BillNum,\n" + + " SapMaterialCode UNION ALL\n" + + " SELECT\n" + + " '大众备件汇总出库' AS Type,\n" + + " '大众' Client,\n" + + " BillNum,\n" + + " MaterialCode,\n" + + " SUM( Qty ) Qty \n" + + " FROM\n" + + " Set_WmsSharePartOutPutDetial \n" + + " WHERE\n" + + " State = 1 \n" + + " AND VERSION = '{0}' \n" + + " GROUP BY\n" + + " BillNum,\n" + + " MaterialCode UNION ALL\n" + + " SELECT\n" + + " '大众备件条码出库' AS Type,\n" + + " '大众' Client,\n" + + " BillNum,\n" + + " MaterialCode,\n" + + " SUM( Qty ) Qty \n" + + " FROM\n" + + " Set_WmsSharePart90OutPutDetial \n" + + " WHERE\n" + + " State = 1 \n" + + " AND VERSION = '{0}' \n" + + " GROUP BY\n" + + " BillNum,\n" + + " MaterialCode UNION ALL\n" + + " SELECT\n" + + " '红旗看板出库' AS Type,\n" + + " '红旗' Client,\n" + + " BillNum,\n" + + " MaterialCode,\n" + + " SUM( Qty ) Qty \n" + + " FROM\n" + + " Set_WmsHQHKanbanOutPutDetial \n" + + " WHERE\n" + + " State = 1 \n" + + " AND VERSION = '{0}' \n" + + " GROUP BY\n" + + " BillNum,\n" + + " MaterialCode UNION ALL\n" + + " SELECT\n" + + " '红旗看板出库' AS Type,\n" + + " '红旗' Client,\n" + + " BillNum,\n" + + " MaterialCode,\n" + + " SUM( Qty ) Qty \n" + + " FROM\n" + + " Set_WmsHQHKanbanOutPutDetial \n" + + " WHERE\n" + + " State = 1 \n" + + " AND VERSION = '{0}' \n" + + " GROUP BY\n" + + " BillNum,\n" + + " MaterialCode UNION ALL\n" + + " SELECT\n" + + " '红旗一轿手工出库' AS Type,\n" + + " '红旗' Client,\n" + + " BillNum,\n" + + " SapMaterialCode,\n" + + " SUM( Qty ) Qty \n" + + " FROM\n" + + " Set_WmsHQWithOutKanbanOutPutDetial \n" + + " WHERE\n" + + " State = 1 \n" + + " AND VERSION = '{0}' \n" + + " GROUP BY\n" + + " BillNum,\n" + + " SapMaterialCode UNION ALL\n" + + " SELECT\n" + + " '一汽奔腾轿车出库' AS Type,\n" + + " '奔腾' Client,\n" + + " BillNum,\n" + + " SapMaterialCode,\n" + + " SUM( Qty ) Qty \n" + + " FROM\n" + + " Set_WmsHQWithOutKanbanOutPutDetial \n" + + " WHERE\n" + + " State = 1 \n" + + " AND VERSION = '{0}' \n" + + " GROUP BY\n" + + " BillNum,\n" + + " SapMaterialCode \n" + + " ) temp\n" + + " LEFT JOIN ( SELECT max( Id ) Id, MaterialCode, MaterialDesc, EstimateType, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, EstimateType ) temp2 ON temp.MaterialCode = temp2.MaterialCode \n" + + " ) t1 UNION ALL\n" + + " SELECT\n" + + " * \n" + + " FROM\n" + + " (\n" + + " SELECT\n" + + " temp.Client ,\n" + + " temp.Type,\n" + + " temp.BillNum,\n" + + " temp.MaterialCode,\n" + + " temp2.MaterialDesc,\n" + + " temp.Qty,\n" + + " 2 STATE,\n" + + " EstimateTypeDesc MaterialGroup,\n" + + " EstimateType \n" + + " FROM\n" + + " (\n" + + " SELECT\n" + + " '大众准时化出库' AS Type,\n" + + " '大众' Client,\n" + + " BillNum,\n" + + " MaterialCode,\n" + + " SUM( Qty ) Qty \n" + + " FROM\n" + + " Set_WmsJitOutPutDetial \n" + + " WHERE\n" + + " State = 2 \n" + + " AND VERSION = '{0}' \n" + + " GROUP BY\n" + + " BillNum,\n" + + " MaterialCode UNION ALL\n" + + " SELECT\n" + + " '大众看板出库' AS Type,\n" + + " '大众' Client,\n" + + " BillNum,\n" + + " MaterialCode,\n" + + " SUM( Qty ) Qty \n" + + " FROM\n" + + " Set_WmsKanbanOutPutDetial \n" + + " WHERE\n" + + " State = 2 \n" + + " AND VERSION = '{0}' \n" + + " GROUP BY\n" + + " BillNum,\n" + + " MaterialCode UNION ALL\n" + + " SELECT\n" + + " '大众无看板出库' AS Type,\n" + + " '大众' Client,\n" + + " BillNum,\n" + + " SapMaterialCode MaterialCode,\n" + + " SUM( Qty ) Qty \n" + + " FROM\n" + + " Set_WmsWithOutKanbanOutPutDetial \n" + + " WHERE\n" + + " State = 2 \n" + + " AND VERSION = '{0}' \n" + + " GROUP BY\n" + + " BillNum,\n" + + " SapMaterialCode UNION ALL\n" + + " SELECT\n" + + " '大众备件汇总出库' AS Type,\n" + + " '大众' Client,\n" + + " BillNum,\n" + + " MaterialCode,\n" + + " SUM( Qty ) Qty \n" + + " FROM\n" + + " Set_WmsSharePartOutPutDetial \n" + + " WHERE\n" + + " State = 2 \n" + + " AND VERSION = '{0}' \n" + + " GROUP BY\n" + + " BillNum,\n" + + " MaterialCode UNION ALL\n" + + " SELECT\n" + + " '大众备件条码出库' AS Type,\n" + + " '大众' Client,\n" + + " BillNum,\n" + + " MaterialCode,\n" + + " SUM( Qty ) Qty \n" + + " FROM\n" + + " Set_WmsSharePart90OutPutDetial \n" + + " WHERE\n" + + " State = 2 \n" + + " AND VERSION = '{0}' \n" + + " GROUP BY\n" + + " BillNum,\n" + + " MaterialCode UNION ALL\n" + + " SELECT\n" + + " '红旗看板出库' AS Type,\n" + + " '红旗' Client,\n" + + " BillNum,\n" + + " MaterialCode,\n" + + " SUM( Qty ) Qty \n" + + " FROM\n" + + " Set_WmsHQHKanbanOutPutDetial \n" + + " WHERE\n" + + " State = 2 \n" + + " AND VERSION = '{0}' \n" + + " GROUP BY\n" + + " BillNum,\n" + + " MaterialCode UNION ALL\n" + + " SELECT\n" + + " '红旗看板出库' AS Type,\n" + + " '红旗' Client,\n" + + " BillNum,\n" + + " MaterialCode,\n" + + " SUM( Qty ) Qty \n" + + " FROM\n" + + " Set_WmsHQHKanbanOutPutDetial \n" + + " WHERE\n" + + " State = 2 \n" + + " AND VERSION = '{0}' \n" + + " GROUP BY\n" + + " BillNum,\n" + + " MaterialCode UNION ALL\n" + + " SELECT\n" + + " '红旗一轿手工出库' AS Type,\n" + + " '红旗' Client,\n" + + " BillNum,\n" + + " SapMaterialCode,\n" + + " SUM( Qty ) Qty \n" + + " FROM\n" + + " Set_WmsHQWithOutKanbanOutPutDetial \n" + + " WHERE\n" + + " State = 2 \n" + + " AND VERSION = '{0}' \n" + + " GROUP BY\n" + + " BillNum,\n" + + " SapMaterialCode UNION ALL\n" + + " SELECT\n" + + " '一汽奔腾轿车出库' AS Type,\n" + + " '奔腾' Client,\n" + + " BillNum,\n" + + " SapMaterialCode,\n" + + " SUM( Qty ) Qty \n" + + " FROM\n" + + " Set_WmsHQWithOutKanbanOutPutDetial \n" + + " WHERE\n" + + " State = 2 \n" + + " AND VERSION = '{0}' \n" + + " GROUP BY\n" + + " BillNum,\n" + + " SapMaterialCode \n" + + " ) temp\n" + + " LEFT JOIN ( SELECT max( Id ) Id, MaterialCode, MaterialDesc, EstimateType, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, EstimateType ) temp2 ON temp.MaterialCode = temp2.MaterialCode \n" + + " ) t2 \n" + + " ) TEMP PIVOT ( SUM( QTY ) FOR STATE IN ([1],[2]) ) A order by 客户,出库类型,出库单"; + + string _sql = string.Format(str, version); + var _query = DbConnection.Query(_sql, null, null, true, 1200, null); + return _query.ToList(); + + } + public virtual List GetWmsSumReportList(string version,string state) { diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnInvoiceSettledDetailDiffExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnInvoiceSettledDetailDiffExportService.cs index 1c03117d..5d3dffd2 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnInvoiceSettledDetailDiffExportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnInvoiceSettledDetailDiffExportService.cs @@ -46,6 +46,9 @@ namespace SettleAccount.Job.Services private readonly UnInvoiceSettledDetailDiffDapperRepository _dapperRepository; private readonly InvoiceSettledDetailDiffDapperRepository _dapperRepository1; + private readonly UnSettledDetailDapperRepository _dapperRepository2; + + private readonly ErpPartDapperRepository _erpdapperRepository; private readonly IBlobContainer _fileContainer; @@ -59,7 +62,8 @@ namespace SettleAccount.Job.Services UnInvoiceSettledDetailDiffDapperRepository dapperRepository, InvoiceSettledDetailDiffDapperRepository dapperRepository1, OutputService outputService, - InputService inputService + InputService inputService, + UnSettledDetailDapperRepository dapperRepository2 ) { _fileContainer = fileContainer; @@ -70,6 +74,7 @@ namespace SettleAccount.Job.Services //_versionRepository = versionRepository; _dapperRepository =dapperRepository; _dapperRepository1 = dapperRepository1; + _dapperRepository2 = dapperRepository2; } public string ExportFile(Guid id, List exportName, List p_list) @@ -174,11 +179,12 @@ namespace SettleAccount.Job.Services - var report2List = _ls1.Where(p => p.DiffPrice != 0).Select(p => new { p.MaterialGroup, DiffAmt = p.DiffPrice * p.Qty }).GroupBy(p => new { p.MaterialGroup }).Select(p => new SettleDoorPanelSumExport { MaterialGroup = p.Key.MaterialGroup, InvoiceDiffPrice = p.Sum(itm => itm.DiffAmt), Version = version }); ; - - + var report2List = _ls1.Where(p => p.DiffPrice != 0).Select(p => new { p.MaterialGroup, DiffAmt = p.DiffPrice * p.Qty }).GroupBy(p => new { p.MaterialGroup }).Select(p => new SettleDoorPanelSumExport { MaterialGroup = p.Key.MaterialGroup, InvoiceDiffPrice = p.Sum(itm => itm.DiffAmt), Version = version }); + var list1= LSettleSum(id, exportName, p_list); + var report1 = report2List.ToList(); + report1.AddRange(list1); ExcelExporter _exporter = new ExcelExporter();//导出Excel @@ -189,7 +195,7 @@ namespace SettleAccount.Job.Services .SeparateBySheet() .Append(report1List, "按物料价格差异明细表") .SeparateBySheet() - .Append(report2List.ToList(), "差异汇总验证表") + .Append(report1, "差异汇总验证表") .ExportAppendDataAsByteArray(); result.ShouldNotBeNull(); _fileContainer.SaveAsync(_filename, result.Result, true); @@ -319,20 +325,87 @@ namespace SettleAccount.Job.Services _ls = _ls.OrderBy(p => p.ChassisNumber).ThenBy(p => p.KENNCode).ThenBy(p => p.SapMaterialCode).ToList(); } - return _ls; - - //ExcelExporter _exporter = new ExcelExporter();//导出Excel - //var result = _exporter.Append(report1List.ToList(), "按物料价格差异明细表") - //.SeparateBySheet() - //.Append(report2List.ToList(), "差异汇总验证表") - //.ExportAppendDataAsByteArray(); - //result.ShouldNotBeNull(); - //_fileContainer.SaveAsync(_filename, result.Result, true); + } + public List LSettleSum(Guid id, List exportName, List p_list) + { + var _first = exportName.FirstOrDefault(); + var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value; + var customerCode = p_list.Where(p => p.Name == "CustomerCode").FirstOrDefault().Value; + var materailCode = p_list.Where(p => p.Name == "MaterialCode").FirstOrDefault().Value; + var materialGroup = p_list.Where(p => p.Name == "MaterialGroup").FirstOrDefault().Value; + var sapcode = p_list.Where(p => p.Name == "SapMaterialCode").FirstOrDefault().Value; + var begin = p_list.Where(p => p.Name == "Begin").FirstOrDefault().Value; + var end = p_list.Where(p => p.Name == "End").FirstOrDefault().Value; + var kenncode = p_list.Where(p => p.Name == "KennCode").FirstOrDefault().Value; + var chassisNumber = p_list.Where(p => p.Name == "ChassisNumber").FirstOrDefault().Value; + var sapCode = p_list.Where(p => p.Name == "SapCode").FirstOrDefault().Value; - // _outputService.Export(id, string.Format("大众准时化结算门板价格差异比对报表_{0}.xlsx", Guid.NewGuid().ToString()), _list); + //var cp7begin = p_list.Where(p => p.Name == "CP7Begin").FirstOrDefault().Value; + //var cp7end = p_list.Where(p => p.Name == "CP7End").FirstOrDefault().Value; + + begin = version.Substring(0, 4) + "-" + version.Substring(version.Length - 2) + "-01 00:00:00"; + var _beginstr = version.Substring(0, 4) + "-" + version.Substring(version.Length - 2) + "-01"; + var _end = DateTime.Parse(_beginstr).AddMonths(1).AddDays(-1); + end=_end.ToString("yyyy-MM-dd")+" 23:59:59"; + + var _list = _dapperRepository2.GetDiffReport(DateTime.Now.Year.ToString(), begin, end, customerCode, version, materailCode, materialGroup, sapcode); + var _ls = _list.Where(p => p.Flag == "L").Where(p => p.ParentSapMaterialCode != p.SapMaterialCode).GroupBy(p => new { p.KENNCode, p.ChassisNumber, p.ParentSapMaterialCode }).Select(p => p.FirstOrDefault()).ToList(); + //var _lst = _erpDapper.GetSapList(_ls, version, false); + //_lst.ForEach(p => + //{ + + // p.Qty = 1; + // p.DiffAMT = Math.Round(p.Qty * p.Price, 2); + // p.DiffQty = 1; + //} + //); + //_list.AddRange(_lst); + if (!string.IsNullOrEmpty(materialGroup)) + { + var _groupList = materialGroup.Split(new char[] { ',' }).Distinct().ToList(); + if (_groupList.Count() > 0) + { + _list = _list.Where(p => _groupList.Contains(p.MaterialGroup)).ToList(); + } + } + if (!string.IsNullOrEmpty(kenncode)) + { + var _groupList = kenncode.Split(new char[] { '\n' }).Distinct().ToList(); + if (_groupList.Count() > 0) + { + _list = _list.Where(p => _groupList.Contains(p.KENNCode)).ToList(); + } + } + if (!string.IsNullOrEmpty(chassisNumber)) + { + var _groupList = chassisNumber.Split(new char[] { '\n' }).Distinct().ToList(); + if (_groupList.Count() > 0) + { + _list = _list.Where(p => _groupList.Contains(p.ChassisNumber)).ToList(); + } + } + if (!string.IsNullOrEmpty(sapCode)) + { + var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList(); + if (_groupList.Count() > 0) + { + _list = _list.Where(p => _groupList.Contains(p.SapMaterialCode)).ToList(); + } + } + if (!string.IsNullOrEmpty(materailCode)) + { + var _groupList = materailCode.Split(new char[] { '\n' }).Distinct().ToList(); + if (_groupList.Count() > 0) + { + _list = _list.Where(p => _groupList.Contains(p.SapMaterialCode)).ToList(); + } + } + _list = _list.OrderBy(p => p.ChassisNumber).ThenBy(p => p.SapMaterialCode).ThenBy(p => p.Flag).ToList(); + var report2List = _list.Select(p => new { p.MaterialGroup, DiffAmt = p.Price * p.Qty }).GroupBy(p => new { p.MaterialGroup }).Select(p => new SettleDoorPanelSumExport { MaterialGroup = p.Key.MaterialGroup, InvoiceDiffPrice = p.Sum(itm => itm.DiffAmt), Version = version }); + return report2List.ToList(); } diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/WmsOutputSumExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/WmsOutputSumExportService.cs index 9e4d2160..b733e542 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/WmsOutputSumExportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/WmsOutputSumExportService.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,7 +8,9 @@ using System.Text; using System.Threading.Tasks; using TaskJob.EventArgs; using TaskJob.Interfaces; +using Volo.Abp.BlobStoring; using Volo.Abp.DependencyInjection; +using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.SettleAccount.Reports.InvoiceSettledDiffs; using Win.Sfs.SettleAccount.Repository.SettleAccount; using Win.Sfs.SettleAccount.Repository.SettleAccountJob; @@ -39,15 +43,19 @@ namespace SettleAccount.Job.Services.Report private readonly WmsOutputSumDapperRepository _dapperRepository; private readonly OutputService _outputService; private readonly InputService _inputService; + private readonly IBlobContainer _fileContainer; public WmsOutputSumExportService( WmsOutputSumDapperRepository dapperRepository, OutputService outputService, - InputService inputService + InputService inputService, + IBlobContainer fileContainer + ) { _inputService = inputService; _outputService = outputService; _dapperRepository = dapperRepository; + _fileContainer = fileContainer; } @@ -58,6 +66,9 @@ namespace SettleAccount.Job.Services.Report var materialGroup = p_list.Where(p => p.Name == "MaterialGroup").FirstOrDefault().Value; var state = p_list.Where(p => p.Name == "State").FirstOrDefault().Value; var _ls= _dapperRepository.GetWmsSumReportList(version, state); + + var _lst = _dapperRepository.GetWmsSumExtendList(version); + if (!string.IsNullOrEmpty(materialGroup)) { var _groupList = materialGroup.Split(new char[] { ',' }).Distinct().ToList(); @@ -74,8 +85,16 @@ namespace SettleAccount.Job.Services.Report _ls = _ls.Where(p => _groupList.Contains(p.MaterialCode)).ToList(); } } + var _first = exportName.FirstOrDefault(); - _outputService.Export(id,_first, _ls); + ExcelExporter _exporter = new ExcelExporter();//导出Excel + var result = _exporter.Append(_ls.ToList(), "汇总表") + .SeparateBySheet() + .Append(_lst.ToList(), "完成清单表") + .ExportAppendDataAsByteArray(); + result.ShouldNotBeNull(); + _fileContainer.SaveAsync(_first, result.Result, true); + return id.ToString(); ; }