From 578e66efd7c241c51eb3f91f23e183231e5375ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Tue, 5 Dec 2023 09:23:00 +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 --- .../BalanceSum/BalanceSumDapperRepository.cs | 128 +++++++++--------- 1 file changed, 64 insertions(+), 64 deletions(-) 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 e3e17bdd..ddedc658 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 @@ -327,70 +327,70 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report //"drop table #temp_js\n" + //"drop table #temp_bh\n"; var sql= -"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" + -"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\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" + -"drop table #temp_js\n" + -"drop table #temp_bh;\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" + + "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\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" + + "drop table #temp_js\n" + + "drop table #temp_bh;\n"; var query = string.Format(sql, p_year);