学 赵
1 year ago
6 changed files with 518 additions and 857 deletions
@ -0,0 +1,46 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using EFCore.BulkExtensions; |
||||
|
using NPOI.OpenXmlFormats.Spreadsheet; |
||||
|
using SettleAccount.Bases; |
||||
|
using SettleAccount.Domain.BQ; |
||||
|
using TaskJob.EventArgs; |
||||
|
using TaskJob.Interfaces; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Emailing; |
||||
|
using Volo.Abp.Uow; |
||||
|
using Win.Sfs.SettleAccount.Entities.BQ.Vmi; |
||||
|
using Win.Sfs.SettleAccount.Entities.CodeSettings; |
||||
|
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
||||
|
{ |
||||
|
public class BalanceSumService : ApplicationService, ITransientDependency, IExportJob |
||||
|
{ |
||||
|
|
||||
|
//protected readonly SettleAccountDbContext _dbcontext;
|
||||
|
protected readonly BalanceSumDapperRepository _dapper; |
||||
|
|
||||
|
public BalanceSumService( |
||||
|
BalanceSumDapperRepository dapper |
||||
|
) |
||||
|
{ |
||||
|
_dapper = dapper; |
||||
|
|
||||
|
//_dbcontext = dbcontext;
|
||||
|
|
||||
|
} |
||||
|
[UnitOfWork(false)] |
||||
|
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property) |
||||
|
{ |
||||
|
var year = property.Where(p => p.Name == "Year").FirstOrDefault().Value; |
||||
|
var list=_dapper.GetBalanceSum(year); |
||||
|
|
||||
|
return id.ToString(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,373 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using Dapper; |
||||
|
using Magicodes.ExporterAndImporter.Core; |
||||
|
using SettleAccount.Domain.BQ; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Domain.Repositories.Dapper; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Volo.Abp.Uow; |
||||
|
using Win.Sfs.SettleAccount.Entities.BQ.Temp; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report |
||||
|
{ |
||||
|
public class Meta |
||||
|
{ |
||||
|
public class SettleInvoiceDiff |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
[ExporterHeader(DisplayName = "零件号", IsBold = true)] |
||||
|
public string MaterialCode { set; get; } |
||||
|
[ExporterHeader(DisplayName = "零件名称", IsBold = true)] |
||||
|
public string MaterialDesc { set; get; } |
||||
|
|
||||
|
|
||||
|
|
||||
|
[ExporterHeader(DisplayName = "全年发票合计", IsBold = true)] |
||||
|
public string SumInvoice { set; get; } |
||||
|
[ExporterHeader(DisplayName = "全年结算合计", IsBold = true)] |
||||
|
public string SumSettle { set; get; } |
||||
|
[ExporterHeader(DisplayName = "全年合计差异", IsBold = true)] |
||||
|
public string SumDiff { set; get; } |
||||
|
|
||||
|
|
||||
|
|
||||
|
[ExporterHeader(DisplayName = "1月发票", IsBold = true)] |
||||
|
public string January { set; get; } |
||||
|
[ExporterHeader(DisplayName = "1月结算", IsBold = true)] |
||||
|
public string SettleJanuary { set; get; } |
||||
|
|
||||
|
[ExporterHeader(DisplayName = "2月发票", IsBold = true)] |
||||
|
public string InvoiceFebruary { set; get; } |
||||
|
|
||||
|
[ExporterHeader(DisplayName = "2月结算", IsBold = true)] |
||||
|
public string SettleFebruary { set; get; } |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
[ExporterHeader(DisplayName = "3月发票", IsBold = true)] |
||||
|
public string InvoiceMarch { set; get; } |
||||
|
|
||||
|
[ExporterHeader(DisplayName = "3月结算", IsBold = true)] |
||||
|
public string SettleMarch { set; get; } |
||||
|
|
||||
|
[ExporterHeader(DisplayName = "4月发票", IsBold = true)] |
||||
|
public string InvoiceApril { set; get; } |
||||
|
[ExporterHeader(DisplayName = "4月结算", IsBold = true)] |
||||
|
public string SettleApril { set; get; } |
||||
|
|
||||
|
[ExporterHeader(DisplayName = "5月发票", IsBold = true)] |
||||
|
public string InvoiceMay { set; get; } |
||||
|
|
||||
|
[ExporterHeader(DisplayName = "5月结算", IsBold = true)] |
||||
|
public string SettleMay { set; get; } |
||||
|
|
||||
|
[ExporterHeader(DisplayName = "6月发票", IsBold = true)] |
||||
|
public string InvoiceJune { set; get; } |
||||
|
[ExporterHeader(DisplayName = "6月结算", IsBold = true)] |
||||
|
public string SettleJune { set; get; } |
||||
|
|
||||
|
|
||||
|
[ExporterHeader(DisplayName = "7月发票", IsBold = true)] |
||||
|
public string InvoiceJuly { set; get; } |
||||
|
|
||||
|
[ExporterHeader(DisplayName = "7月结算", IsBold = true)] |
||||
|
public string SettleJuly { set; get; } |
||||
|
|
||||
|
|
||||
|
|
||||
|
[ExporterHeader(DisplayName = "8月发票", IsBold = true)] |
||||
|
public string InvoiceAugust { set; get; } |
||||
|
|
||||
|
[ExporterHeader(DisplayName = "8月结算", IsBold = true)] |
||||
|
public string SettleAugust { set; get; } |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
[ExporterHeader(DisplayName = "9月发票", IsBold = true)] |
||||
|
public string InvoiceSeptember { set; get; } |
||||
|
|
||||
|
[ExporterHeader(DisplayName = "9月结算", IsBold = true)] |
||||
|
public string SettleSeptember { set; get; } |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
[ExporterHeader(DisplayName = "10月发票", IsBold = true)] |
||||
|
public string InvoiceOctober { set; get; } |
||||
|
|
||||
|
|
||||
|
|
||||
|
[ExporterHeader(DisplayName = "10月结算", IsBold = true)] |
||||
|
public string SettleOctober { set; get; } |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
[ExporterHeader(DisplayName = "11月发票", IsBold = true)] |
||||
|
public string InvoiceNovember { set; get; } |
||||
|
|
||||
|
[ExporterHeader(DisplayName = "11月结算", IsBold = true)] |
||||
|
|
||||
|
public string DiffNovember { set; get; } |
||||
|
|
||||
|
[ExporterHeader(DisplayName = "12月发票", IsBold = true)] |
||||
|
public string InvoiceDecember { set; get; } |
||||
|
[ExporterHeader(DisplayName = "12月结算", IsBold = true)] |
||||
|
public string SettleDecember { set; get; } |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 2.大众发票与结算核对明细表-准时化
|
||||
|
/// </summary>
|
||||
|
public class BalanceSumDapperRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency |
||||
|
{ |
||||
|
public BalanceSumDapperRepository(IDbContextProvider<SettleAccountDbContext> dbContextProvider) |
||||
|
: base(dbContextProvider) |
||||
|
{ |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 获取库存余额汇总
|
||||
|
/// </summary>
|
||||
|
/// <param name="p_year"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public virtual object GetBalanceSum(string p_year) |
||||
|
{ |
||||
|
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 sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'01' version1 from (\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@BeforeYear+'-12-26 08:00:00' AND BillTime<=@lastyear+'-01-26 07:59:59' and (LogType>200 OR LogType<200)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"UNION ALL\n" + |
||||
|
"select sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'02' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-01-26 08:00:00' AND BillTime<=@lastyear+'-02-26 07:59:59' and (LogType>200 OR LogType<200)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"UNION ALL\n" + |
||||
|
"select sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'03' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-02-26 08:00:00' AND BillTime<=@lastyear+'-03-26 07:59:59' and (LogType>200 OR LogType<200)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"UNION ALL\n" + |
||||
|
"select sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'04' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-03-26 08:00:00' AND BillTime<=@lastyear+'-04-26 07:59:59' and (LogType>200 OR LogType<200)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"UNION ALL\n" + |
||||
|
"select sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'05' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-04-26 08:00:00' AND BillTime<=@lastyear+'-05-26 07:59:59' and (LogType>200 OR LogType<200)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"UNION ALL\n" + |
||||
|
"select sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'06' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-05-26 08:00:00' AND BillTime<=@lastyear+'-06-26 07:59:59' and (LogType>200 OR LogType<200)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"UNION ALL\n" + |
||||
|
"select sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'07' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-06-26 08:00:00' AND BillTime<=@lastyear+'-07-26 07:59:59' and (LogType>200 OR LogType<200)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"UNION ALL\n" + |
||||
|
"select sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'09' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-07-26 08:00:00' AND BillTime<=@lastyear+'-08-26 07:59:59' and (LogType>200 OR LogType<200)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"UNION ALL\n" + |
||||
|
"select sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'09' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-08-26 08:00:00' AND BillTime<=@lastyear+'-09-26 07:59:59' and (LogType>200 OR LogType<200)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"union all\n" + |
||||
|
"select sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'10' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-09-26 08:00:00' AND BillTime<=@lastyear+'-10-26 07:59:59' and (LogType>200 OR LogType<200)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"union all\n" + |
||||
|
"select sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'11' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-10-26 08:00:00' AND BillTime<=@lastyear+'-11-26 07:59:59' and (LogType>200 OR LogType<200)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"union all\n" + |
||||
|
"select sum(changedQty) changedqty,RealPartCode,ErpToLoc,@lastyear+'12' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-11-26 08:00:00' AND BillTime<=@lastyear+'-12-26 07:59:59' and (LogType>200 OR LogType<200)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"union all\n" + |
||||
|
"select sum(changedQty) changedqty,RealPartCode,ErpToLoc, version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc,FORMAT(BillTime,'yyyyMM') version1\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where LogType=200\n" + |
||||
|
") a group by RealPartCode,ErpToLoc,version1\n" + |
||||
|
") temp\n" + |
||||
|
"PIVOT ( SUM( changedqty )\n" + |
||||
|
"FOR VERSION1 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 sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'01' version1 from (\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@BeforeYear+'-12-26 08:00:00' AND BillTime<=@lastyear+'-01-26 07:59:59' and (LogType=500)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"UNION ALL\n" + |
||||
|
"select sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'02' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-01-26 08:00:00' AND BillTime<=@lastyear+'-02-26 07:59:59' and (LogType=500)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"UNION ALL\n" + |
||||
|
"select sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'03' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-02-26 08:00:00' AND BillTime<=@lastyear+'-03-26 07:59:59' and (LogType=500)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"UNION ALL\n" + |
||||
|
"select sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'04' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-03-26 08:00:00' AND BillTime<=@lastyear+'-04-26 07:59:59' and (LogType=500)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"UNION ALL\n" + |
||||
|
"select sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'05' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-04-26 08:00:00' AND BillTime<=@lastyear+'-05-26 07:59:59' and (LogType=500)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"UNION ALL\n" + |
||||
|
"select sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'06' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-05-26 08:00:00' AND BillTime<=@lastyear+'-06-26 07:59:59' and (LogType=500)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"UNION ALL\n" + |
||||
|
"select sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'07' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-06-26 08:00:00' AND BillTime<=@lastyear+'-07-26 07:59:59' and (LogType=500)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"UNION ALL\n" + |
||||
|
"select sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'08' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-07-26 08:00:00' AND BillTime<=@lastyear+'-08-26 07:59:59' and (LogType=500)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"UNION ALL\n" + |
||||
|
"select sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'09' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-08-26 08:00:00' AND BillTime<=@lastyear+'-09-26 07:59:59' and (LogType=500)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"union all\n" + |
||||
|
"select sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'10' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-09-26 08:00:00' AND BillTime<=@lastyear+'-10-26 07:59:59' and (LogType=500)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"union all\n" + |
||||
|
"select sum(changedQty) ChangedQty,RealPartCode,ErpToLoc,@lastyear+'11' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-10-26 08:00:00' AND BillTime<=@lastyear+'-11-26 07:59:59' and (LogType=500)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"union all\n" + |
||||
|
"select sum(changedQty) changedqty,RealPartCode,ErpToLoc,@lastyear+'12' version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where BillTime>=@lastyear+'-11-26 08:00:00' AND BillTime<=@lastyear+'-12-26 07:59:59' and (LogType=500)\n" + |
||||
|
") a group by RealPartCode,ErpToLoc\n" + |
||||
|
"union all\n" + |
||||
|
"select sum(changedQty) changedqty,RealPartCode,ErpToLoc, version1 from\n" + |
||||
|
"(\n" + |
||||
|
"SELECT ChangedQty,RealPartCode,ErpToLoc,FORMAT(BillTime,'yyyyMM') version1\n" + |
||||
|
"FROM [BQ_SA].[dbo].[Set_VmiLog] where LogType=200 and ReMark ='有结算无发运'\n" + |
||||
|
") a group by RealPartCode,ErpToLoc,version1\n" + |
||||
|
") temp\n" + |
||||
|
"\n" + |
||||
|
"PIVOT ( SUM( changedqty )\n" + |
||||
|
"FOR VERSION1 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) 库存余额数量,\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) 有结无发合计,\n" + |
||||
|
"isnull(a.[{0}01],0) [{0}01],isnull(b.[{0}01],0) [有结无发],\n" + |
||||
|
"isnull(a.[{0}02],0) [{0}02],isnull(b.[{0}02],0) [有结无发],\n" + |
||||
|
"isnull(a.[{0}03],0) [{0}03],isnull(b.[{0}03],0) [有结无发],\n" + |
||||
|
"isnull(a.[{0}04],0) [{0}04],isnull(b.[{0}04],0) [有结无发],\n" + |
||||
|
"isnull(a.[{0}05],0) [{0}05],isnull(b.[{0}05],0) [有结无发],\n" + |
||||
|
"isnull(a.[{0}06],0) [{0}06],isnull(b.[{0}06],0) [有结无发],\n" + |
||||
|
"isnull(a.[{0}07],0) [{0}07],isnull(b.[{0}07],0) [有结无发],\n" + |
||||
|
"isnull(a.[{0}08],0) [{0}08],isnull(b.[{0}08],0) [有结无发],\n" + |
||||
|
"isnull(a.[{0}09],0) [{0}09],isnull(b.[{0}09],0) [有结无发],\n" + |
||||
|
"isnull(a.[{0}10],0) [{0}10],isnull(b.[{0}10],0) [有结无发],\n" + |
||||
|
"isnull(a.[{0}11],0) [{0}11],isnull(b.[{0}11],0) [有结无发],\n" + |
||||
|
"isnull(a.[{0}12],0) [{0}12],isnull(b.[{0}12],0) [有结无发] \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); |
||||
|
|
||||
|
var list = DbConnection.Query(query,null,null,false,1200,null); |
||||
|
|
||||
|
|
||||
|
return ""; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
Loading…
Reference in new issue