diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncExtendManager.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncExtendManager.cs index b539558f..513c5275 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncExtendManager.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncExtendManager.cs @@ -225,20 +225,21 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs var before = p_billtime.Year; var last = before - 1; + var next = before + 1; DateTime lastYear = DateTime.ParseExact(string.Format("{0}-12-{1} 08:00:00", last, p_day), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);//上期时间 DateTime beforeYear = DateTime.ParseExact(string.Format("{0}-12-{1} 07:59:59", before, p_day), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);//这期时间 - //var result = seDetails - // .Select(log => - // { + string version = null; - if (p_billtime >= lastYear && p_billtime <= lastYear.AddMonths(1)) + if (p_billtime >= DateTime.ParseExact(string.Format("{0}-01-01 08:00:00", before), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture) && p_billtime <= lastYear.AddMonths(1)) { version = $"{before.ToString()}01"; } else if (p_billtime >= lastYear.AddMonths(1) && p_billtime <= lastYear.AddMonths(2)) - { version = $"{before.ToString()}02"; } + { + version = $"{before.ToString()}02"; + } else if (p_billtime >= lastYear.AddMonths(2) && p_billtime <= lastYear.AddMonths(3)) { version = $"{before.ToString()}03"; } else if (p_billtime >= lastYear.AddMonths(3) && p_billtime <= lastYear.AddMonths(4)) @@ -257,8 +258,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs { version = $"{before.ToString()}10"; } else if (p_billtime >= lastYear.AddMonths(10) && p_billtime <= lastYear.AddMonths(11)) { version = $"{before.ToString()}11"; } - else if (p_billtime >= lastYear.AddMonths(11) && p_billtime <= beforeYear) - { version = $"{before.ToString()}12"; } + else if (p_billtime >= lastYear.AddMonths(11) && p_billtime <= + DateTime.ParseExact(string.Format("{0}-01-{1} 07:59:59", next.ToString(), 01), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture) + ) + { + version = $"{before.ToString()}12"; + } if (string.IsNullOrEmpty(version)) 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 9f2c577c..76ccf160 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 @@ -225,6 +225,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ [HttpPost] public async Task BalanceExport(RequestDto input) { + + + var connectionString = this._serviceProvider.GetRequiredService().GetConnectionString("SettleAccountService"); var options = new DbContextOptionsBuilder().UseSqlServer(connectionString).Options; using var db = new SettleAccountDbContext(options); @@ -419,6 +422,24 @@ namespace Win.Sfs.SettleAccount.Entities.BQ [HttpPost] public async Task> Log(LogRequestDto input) { + //var accountday = _codeRepository.FirstOrDefault(p => p.Project == "库存账期").Value; + //var begin= input.Filters.FirstOrDefault(p => p.Column == "BillTime" && p.Action == EnumFilterAction.BiggerThanOrEqual); + //if(begin != null){ + // var begintime=DateTime.Parse(begin.Value); + // int version=GetVersionByBillTime(begintime, accountday); + // input.Filters.Add(new FilterCondition("Version",version.ToString(), EnumFilterAction.BiggerThanOrEqual,EnumFilterLogic.And)); + + + + //} + //var end = input.Filters.FirstOrDefault(p => p.Column == "BillTime" && p.Action == EnumFilterAction.SmallThan); + //if(end != null) { + // var endtime = DateTime.Parse(end.Value); + // int version = GetVersionByBillTime(endtime, accountday); + // input.Filters.Add(new FilterCondition("Version", version.ToString(), EnumFilterAction.SmallThan, EnumFilterLogic.And)); ; + + //} + //if (input.UseHistory) //{ // return await Log2(input).ConfigureAwait(false); @@ -581,35 +602,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ ) on new { temp1.VinCode, temp1.RealPartCode } equals new { temp2.VinCode, temp2.RealPartCode } where temp1.ChangedQty > 0 select temp1).ToList(); - //var temp2 = (from a in _logRepository - // where (int)a.LogType == 200 - // group a by new { a.VinCode, a.RealPartCode } into g - // let SumChangedQty = g.Sum(log => log.ChangedQty) - // let MinChangedTime = g.Min(log => log.ChangedTime) - // select new - // { - // VinCode = g.Key.VinCode, - // RealPartCode = g.Key.RealPartCode, - // SumChangedQty, - // MinChangedTime - // } into a - // join b in (from log in _logRepository - // where (int)log.LogType == 100 - // group log by new { log.VinCode, log.RealPartCode } into g - // let SumChangedQty = g.Sum(log => log.ChangedQty) - // let MinChangedTime = g.Min(log => log.ChangedTime) - // select new - // { - // VinCode = g.Key.VinCode, - // RealPartCode = g.Key.RealPartCode, - // SumChangedQty, - // MinChangedTime - // }) on new { a.VinCode, a.RealPartCode } equals new { b.VinCode, b.RealPartCode } - // 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 fileName = $"补货数据_{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.xlsx"; var content = this.GetContent(entities, "补货数据_"); await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false); @@ -754,26 +750,80 @@ namespace Win.Sfs.SettleAccount.Entities.BQ log.ChangedBy = this._currentUser.UserName; } + //private int GetVersionByTimeSpan(DateTime p_begintime,DateTime p_endtime, string p_day) + //{ + + // var before = p_billtime.Year; + // var last = before - 1; + // DateTime lastYear = DateTime.ParseExact(string.Format("{0}-12-{1} 08:00:00", last, p_day), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);//上期时间 + // DateTime beforeYear = DateTime.ParseExact(string.Format("{0}-12-{1} 07:59:59", before, p_day), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);//这期时间 + + // //var result = seDetails + // // .Select(log => + // // { + // string version = null; + + // if (p_billtime >= lastYear && p_billtime <= lastYear.AddMonths(1)) + // { + // version = $"{before.ToString()}01"; + // } + // else if (p_billtime >= lastYear.AddMonths(1) && p_billtime <= lastYear.AddMonths(2)) + // { version = $"{before.ToString()}02"; } + // else if (p_billtime >= lastYear.AddMonths(2) && p_billtime <= lastYear.AddMonths(3)) + // { version = $"{before.ToString()}03"; } + // else if (p_billtime >= lastYear.AddMonths(3) && p_billtime <= lastYear.AddMonths(4)) + // { version = $"{before.ToString()}04"; } + // else if (p_billtime >= lastYear.AddMonths(4) && p_billtime <= lastYear.AddMonths(5)) + // { version = $"{before.ToString()}05"; } + // else if (p_billtime >= lastYear.AddMonths(5) && p_billtime <= lastYear.AddMonths(6)) + // { version = $"{before.ToString()}06"; } + // else if (p_billtime >= lastYear.AddMonths(6) && p_billtime <= lastYear.AddMonths(7)) + // { version = $"{before.ToString()}07"; } + // else if (p_billtime >= lastYear.AddMonths(7) && p_billtime <= lastYear.AddMonths(8)) + // { version = $"{before.ToString()}08"; } + // else if (p_billtime >= lastYear.AddMonths(8) && p_billtime <= lastYear.AddMonths(9)) + // { version = $"{before.ToString()}09"; } + // else if (p_billtime >= lastYear.AddMonths(9) && p_billtime <= lastYear.AddMonths(10)) + // { version = $"{before.ToString()}10"; } + // else if (p_billtime >= lastYear.AddMonths(10) && p_billtime <= lastYear.AddMonths(11)) + // { version = $"{before.ToString()}11"; } + // else if (p_billtime >= lastYear.AddMonths(11) && p_billtime <= beforeYear) + // { version = $"{before.ToString()}12"; } + + + // if (string.IsNullOrEmpty(version)) + // { + // return 200802;//找不到的数据默认写到这个区间 + // } + // return int.Parse(version); + + + //} + + + + private int GetVersionByBillTime(DateTime p_billtime, string p_day) { var before = p_billtime.Year; var last = before - 1; + var next = before + 1; DateTime lastYear = DateTime.ParseExact(string.Format("{0}-12-{1} 08:00:00", last, p_day), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);//上期时间 DateTime beforeYear = DateTime.ParseExact(string.Format("{0}-12-{1} 07:59:59", before, p_day), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);//这期时间 - //var result = seDetails - // .Select(log => - // { + string version = null; - if (p_billtime >= lastYear && p_billtime <= lastYear.AddMonths(1)) + if (p_billtime >= DateTime.ParseExact(string.Format("{0}-12-{1} 08:00:00", last, p_day), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture) && p_billtime <= lastYear.AddMonths(1)) { version = $"{before.ToString()}01"; } else if (p_billtime >= lastYear.AddMonths(1) && p_billtime <= lastYear.AddMonths(2)) - { version = $"{before.ToString()}02"; } + { + version = $"{before.ToString()}02"; + } else if (p_billtime >= lastYear.AddMonths(2) && p_billtime <= lastYear.AddMonths(3)) { version = $"{before.ToString()}03"; } else if (p_billtime >= lastYear.AddMonths(3) && p_billtime <= lastYear.AddMonths(4)) @@ -792,8 +842,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { version = $"{before.ToString()}10"; } else if (p_billtime >= lastYear.AddMonths(10) && p_billtime <= lastYear.AddMonths(11)) { version = $"{before.ToString()}11"; } - else if (p_billtime >= lastYear.AddMonths(11) && p_billtime <= beforeYear) - { version = $"{before.ToString()}12"; } + else if (p_billtime >= lastYear.AddMonths(11) && p_billtime <= + DateTime.ParseExact(string.Format("{0}-01-{1} 07:59:59", next.ToString(), 01), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture) + ) + { + version = $"{before.ToString()}12"; + } if (string.IsNullOrEmpty(version)) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs index 84e3e4ac..81869fa2 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs @@ -232,7 +232,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers /// public virtual async Task SetBackwardState(List p_invs, SettleBillState p_State) { - List errors = new List(); var appls = _repository.Where(p => p_invs.Contains(p.InvbillNum)).ToList(); if (appls.Count > 0) @@ -256,7 +255,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers { if (inv.State == SettleBillState.财务已审核) { - inv.State = state; } else @@ -275,7 +273,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers { if (inv.State == SettleBillState.商务已审核) { - inv.State = state; } else @@ -499,7 +496,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers var bbacDetail = new List(); foreach (var itm in entityList) { - var detail = new BBAC_PD_DETAIL( guid: itm.Id, keyCode: itm.KeyCode, @@ -564,7 +560,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers var involdList = invList.Where(p => oldinvs.Contains(p.ParentInvbillNum)).ToList(); var involdname = involdList.Select(p => p.InvbillNum); var adjlist = _adjRepository.Where(p => involdname.Contains(p.InvBillNum)); - if (adjlist != null && adjlist.Any()) { foreach (var itm in adjlist) @@ -2455,16 +2450,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers case EnumBusinessType.YinDuJian: invlist = await JITInvoice(p_list, p_adjlist, dtos, new List(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType, false).ConfigureAwait(false);//重开可以变多张发票 break; - } - if (invlist.Count == 0) { return false; } - _repository.DbContext.BulkUpdate(new List { inv }); - //foreach (var adj in p_adjlist) //{ // adj.InvBillNum = string.Join(",", invlist); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/BalanceSum/BalanceSumDapperRepository.cs b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/BalanceSum/BalanceSumDapperRepository.cs index 09e15774..ad9d8c43 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/BalanceSum/BalanceSumDapperRepository.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/BalanceSum/BalanceSumDapperRepository.cs @@ -335,109 +335,109 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report //"drop table #temp_js\n" + //"drop table #temp_bh\n"; var sql= - "\n" + -"declare @lastyear as varchar(50)\n" + -"declare @lastTime as varchar(50)\n" + -"declare @BeforeYear as varchar(50)\n" + -"Set @lastyear='{0}'\n" + -"Set @BeforeYear=CAST(@lastyear as int)-1\n" + -"Set @lastTime=dateadd(ms,-3,DATEADD(yy,DATEDIFF(yy,0,@lastyear+'01'+'01')+1, 0))\n" + -"\n" + -"select * into #temp_history from\n" + -"(\n" + -"SELECT ErpToLoc,RealPartCode,SUM(Qty) Qty FROM Set_VmiLog WHERE VERSION <=cast(@BeforeYear as varchar(50))+'12' GROUP BY ErpToLoc,RealPartCode\n" + -") t3\n" + -"select * into #temp_js from (\n" + -"select\n" + -"version,ErpToLoc,realpartcode,changedQty from Set_VmiLog\n" + -") temp\n" + -"PIVOT ( SUM( changedqty )\n" + -"FOR VERSION IN ([{0}01],[{0}02],[{0}03],[{0}04],[{0}05],[{0}06],[{0}07],[{0}08],[{0}09],[{0}10],[{0}11],[{0}12]) ) b\n" + -"select * into #temp_bh from (\n" + -"select\n" + -"version,ErpToLoc,realpartcode,changedQty from Set_VmiLog where LogType=500\n" + -"union all\n" + -"select version,ErpToLoc,realpartcode,changedQty from Set_VmiLog where LogType=200 and ReMark ='有结算无发运'\n" + -"\n" + -") temp\n" + -"\n" + -"PIVOT ( SUM( changedqty )\n" + -"FOR VERSION IN ([{0}01],[{0}02],[{0}03],[{0}04],[{0}05],[{0}06],[{0}07],[{0}08],[{0}09],[{0}10],[{0}11],[{0}12]) ) b\n" + -"select isnull(tt1.ErpToLoc,tt2.ErpToLoc) ErpToLoc,isnull(tt1.RealPartCode,tt2.RealPartCode) RealPartCode\n" + -",ISNULL(tt2.Qty,0) HistoryQty\n" + -",isnull(tt1.BalanceQty,0) BalanceQty\n" + -",ISNULL(tt2.Qty,0) +\n" + -"isnull(tt1.BalanceQty,0) InventQty\n" + -",isnull(tt1.January ,0) January\n" + -",isnull(tt1.SettleJanuary ,0) SettleJanuary\n" + -",isnull(tt1.February ,0) February\n" + -",isnull(tt1.SettleFebruary ,0) SettleFebruary\n" + -",isnull(tt1.March ,0) March\n" + -",isnull(tt1.SettleMarch ,0) SettleMarch\n" + -",isnull(tt1.April ,0) April\n" + -",isnull(tt1.SettleApril ,0) SettleApril\n" + -",isnull(tt1.May ,0) May\n" + -",isnull(tt1.SettleMay ,0) SettleMay\n" + -",isnull(tt1.June ,0) June\n" + -",isnull(tt1.SettleJune ,0) SettleJune\n" + -",isnull(tt1.July ,0) July\n" + -",isnull(tt1.SettleJuly ,0) SettleJuly\n" + -",isnull(tt1.August ,0) August\n" + -",isnull(tt1.SettleAugust ,0) SettleAugust\n" + -",isnull(tt1.September ,0) September\n" + -",isnull(tt1.SettleSeptember ,0) SettleSeptember\n" + -",isnull(tt1.October ,0) October\n" + -",isnull(tt1.SettleOctober ,0) SettleOctober\n" + -",isnull(tt1.November ,0) November\n" + -",isnull(tt1.SettleNovember ,0) SettleNovember\n" + -",isnull(tt1.December ,0) December\n" + -",isnull(tt1.SettleDecember ,0) SettleDecember\n" + -"from\n" + -"(select\n" + -"isnull(a.ErpToLoc,b.ErpToLoc) ErpToLoc,\n" + -"Isnull(b.RealPartCode,a.RealPartCode) RealPartCode,\n" + -"isnull(a.[{0}01],0)+\n" + -"isnull(a.[{0}02],0)+\n" + -"isnull(a.[{0}03],0)+\n" + -"isnull(a.[{0}04],0)+\n" + -"isnull(a.[{0}05],0)+\n" + -"isnull(a.[{0}06],0)+\n" + -"isnull(a.[{0}07],0)+\n" + -"isnull(a.[{0}08],0)+\n" + -"isnull(a.[{0}09],0)+\n" + -"isnull(a.[{0}10],0)+\n" + -"isnull(a.[{0}11],0)+\n" + -"isnull(a.[{0}12],0) BalanceQty ,\n" + -"isnull(b.[{0}01],0) +\n" + -"isnull(b.[{0}02],0) +\n" + -"isnull(b.[{0}03],0) +\n" + -"isnull(b.[{0}04],0) +\n" + -"isnull(b.[{0}05],0) +\n" + -"isnull(b.[{0}06],0) +\n" + -"isnull(b.[{0}07],0) +\n" + -"isnull(b.[{0}08],0) +\n" + -"isnull(b.[{0}09],0) +\n" + -"isnull(b.[{0}10],0) +\n" + -"isnull(b.[{0}11],0) +\n" + -"isnull(b.[{0}12],0) SettleQty,\n" + -"isnull(a.[{0}01],0) January,isnull(b.[{0}01],0) SettleJanuary,\n" + -"isnull(a.[{0}02],0) February,isnull(b.[{0}02],0) SettleFebruary,\n" + -"isnull(a.[{0}03],0) March,isnull(b.[{0}03],0) SettleMarch,\n" + -"isnull(a.[{0}04],0) April,isnull(b.[{0}04],0) SettleApril,\n" + -"isnull(a.[{0}05],0) May,isnull(b.[{0}05],0) SettleMay,\n" + -"isnull(a.[{0}06],0) June,isnull(b.[{0}06],0) SettleJune,\n" + -"isnull(a.[{0}07],0) July,isnull(b.[{0}07],0) SettleJuly,\n" + -"isnull(a.[{0}08],0) August,isnull(b.[{0}08],0) SettleAugust,\n" + -"isnull(a.[{0}09],0) September,isnull(b.[{0}09],0) SettleSeptember,\n" + -"isnull(a.[{0}10],0) October,isnull(b.[{0}10],0) SettleOctober,\n" + -"isnull(a.[{0}11],0) November,isnull(b.[{0}11],0) SettleNovember,\n" + -"isnull(a.[{0}12],0) December,isnull(b.[{0}12],0) SettleDecember\n" + -"from #temp_js a full join #temp_bh b on a.ErpToLoc=b.ErpToLoc and a.RealPartCode=b.RealPartCode\n" + -") tt1\n" + -"full join #temp_history tt2 on tt1.RealPartCode=tt2.RealPartCode and tt1.ErpToLoc=tt2.ErpToLoc\n" + -"drop table #temp_js\n" + -"drop table #temp_bh\n" + -"drop table #temp_history\n"; + + "declare @lastyear as varchar(50)\n" + + "declare @lastTime as varchar(50)\n" + + "declare @BeforeYear as varchar(50)\n" + + "Set @lastyear='{0}'\n" + + "Set @BeforeYear=CAST(@lastyear as int)-1\n" + + "Set @lastTime=dateadd(ms,-3,DATEADD(yy,DATEDIFF(yy,0,@lastyear+'01'+'01')+1, 0))\n" + + "\n" + + "select * into #temp_history from\n" + + "(\n" + + "SELECT ErpToLoc,RealPartCode,SUM(Qty) Qty FROM Set_VmiLog WHERE VERSION <=cast(@BeforeYear as varchar(50))+'12' GROUP BY ErpToLoc,RealPartCode\n" + + ") t3\n" + + "select * into #temp_js from (\n" + + "select\n" + + "version,ErpToLoc,realpartcode,changedQty from Set_VmiLog\n" + + ") temp\n" + + "PIVOT ( SUM( changedqty )\n" + + "FOR VERSION IN ([{0}01],[{0}02],[{0}03],[{0}04],[{0}05],[{0}06],[{0}07],[{0}08],[{0}09],[{0}10],[{0}11],[{0}12]) ) b\n" + + "select * into #temp_bh from (\n" + + "select\n" + + "version,ErpToLoc,realpartcode,changedQty from Set_VmiLog where LogType=500\n" + + "union all\n" + + "select version,ErpToLoc,realpartcode,changedQty from Set_VmiLog where LogType=200 and ReMark ='有结算无发运'\n" + + "\n" + + ") temp\n" + + "\n" + + "PIVOT ( SUM( changedqty )\n" + + "FOR VERSION IN ([{0}01],[{0}02],[{0}03],[{0}04],[{0}05],[{0}06],[{0}07],[{0}08],[{0}09],[{0}10],[{0}11],[{0}12]) ) b\n" + + "select isnull(tt1.ErpToLoc,tt2.ErpToLoc) ErpToLoc,isnull(tt1.RealPartCode,tt2.RealPartCode) RealPartCode\n" + + ",ISNULL(tt2.Qty,0) HistoryQty\n" + + ",isnull(tt1.BalanceQty,0) BalanceQty\n" + + ",ISNULL(tt2.Qty,0) +\n" + + "isnull(tt1.BalanceQty,0) InventQty\n" + + ",isnull(tt1.January ,0) January\n" + + ",isnull(tt1.SettleJanuary ,0) SettleJanuary\n" + + ",isnull(tt1.February ,0) February\n" + + ",isnull(tt1.SettleFebruary ,0) SettleFebruary\n" + + ",isnull(tt1.March ,0) March\n" + + ",isnull(tt1.SettleMarch ,0) SettleMarch\n" + + ",isnull(tt1.April ,0) April\n" + + ",isnull(tt1.SettleApril ,0) SettleApril\n" + + ",isnull(tt1.May ,0) May\n" + + ",isnull(tt1.SettleMay ,0) SettleMay\n" + + ",isnull(tt1.June ,0) June\n" + + ",isnull(tt1.SettleJune ,0) SettleJune\n" + + ",isnull(tt1.July ,0) July\n" + + ",isnull(tt1.SettleJuly ,0) SettleJuly\n" + + ",isnull(tt1.August ,0) August\n" + + ",isnull(tt1.SettleAugust ,0) SettleAugust\n" + + ",isnull(tt1.September ,0) September\n" + + ",isnull(tt1.SettleSeptember ,0) SettleSeptember\n" + + ",isnull(tt1.October ,0) October\n" + + ",isnull(tt1.SettleOctober ,0) SettleOctober\n" + + ",isnull(tt1.November ,0) November\n" + + ",isnull(tt1.SettleNovember ,0) SettleNovember\n" + + ",isnull(tt1.December ,0) December\n" + + ",isnull(tt1.SettleDecember ,0) SettleDecember\n" + + "from\n" + + "(select\n" + + "isnull(a.ErpToLoc,b.ErpToLoc) ErpToLoc,\n" + + "Isnull(b.RealPartCode,a.RealPartCode) RealPartCode,\n" + + "isnull(a.[{0}01],0)+\n" + + "isnull(a.[{0}02],0)+\n" + + "isnull(a.[{0}03],0)+\n" + + "isnull(a.[{0}04],0)+\n" + + "isnull(a.[{0}05],0)+\n" + + "isnull(a.[{0}06],0)+\n" + + "isnull(a.[{0}07],0)+\n" + + "isnull(a.[{0}08],0)+\n" + + "isnull(a.[{0}09],0)+\n" + + "isnull(a.[{0}10],0)+\n" + + "isnull(a.[{0}11],0)+\n" + + "isnull(a.[{0}12],0) BalanceQty ,\n" + + "isnull(b.[{0}01],0) +\n" + + "isnull(b.[{0}02],0) +\n" + + "isnull(b.[{0}03],0) +\n" + + "isnull(b.[{0}04],0) +\n" + + "isnull(b.[{0}05],0) +\n" + + "isnull(b.[{0}06],0) +\n" + + "isnull(b.[{0}07],0) +\n" + + "isnull(b.[{0}08],0) +\n" + + "isnull(b.[{0}09],0) +\n" + + "isnull(b.[{0}10],0) +\n" + + "isnull(b.[{0}11],0) +\n" + + "isnull(b.[{0}12],0) SettleQty,\n" + + "isnull(a.[{0}01],0) January,isnull(b.[{0}01],0) SettleJanuary,\n" + + "isnull(a.[{0}02],0) February,isnull(b.[{0}02],0) SettleFebruary,\n" + + "isnull(a.[{0}03],0) March,isnull(b.[{0}03],0) SettleMarch,\n" + + "isnull(a.[{0}04],0) April,isnull(b.[{0}04],0) SettleApril,\n" + + "isnull(a.[{0}05],0) May,isnull(b.[{0}05],0) SettleMay,\n" + + "isnull(a.[{0}06],0) June,isnull(b.[{0}06],0) SettleJune,\n" + + "isnull(a.[{0}07],0) July,isnull(b.[{0}07],0) SettleJuly,\n" + + "isnull(a.[{0}08],0) August,isnull(b.[{0}08],0) SettleAugust,\n" + + "isnull(a.[{0}09],0) September,isnull(b.[{0}09],0) SettleSeptember,\n" + + "isnull(a.[{0}10],0) October,isnull(b.[{0}10],0) SettleOctober,\n" + + "isnull(a.[{0}11],0) November,isnull(b.[{0}11],0) SettleNovember,\n" + + "isnull(a.[{0}12],0) December,isnull(b.[{0}12],0) SettleDecember\n" + + "from #temp_js a full join #temp_bh b on a.ErpToLoc=b.ErpToLoc and a.RealPartCode=b.RealPartCode\n" + + ") tt1\n" + + "full join #temp_history tt2 on tt1.RealPartCode=tt2.RealPartCode and tt1.ErpToLoc=tt2.ErpToLoc\n" + + "drop table #temp_js\n" + + "drop table #temp_bh\n" + + "drop table #temp_history\n"; var query = string.Format(sql, p_year); @@ -458,10 +458,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report } } - - - - return entities.ToList(); }