From 312bc7a1f0236dbaaab5ad76e36cc6acad3673ec Mon Sep 17 00:00:00 2001 From: Administrator Date: Sat, 22 Jan 2022 12:15:16 +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 --- .../Entities/Prices/PriceListAppService.cs | 5 +- .../Entities/Prices/PriceListAppServiceBJ.cs | 5 +- .../UnSettleAccountAppService.cs | 4 +- .../Entities/WMS/WMSKanbanAppService.cs | 132 ++++++++++-------- .../ReportServices/ReportMakeService.cs | 9 +- .../Entities/WMS/TaskList.cs | 126 +++++++++++++++++ ...AccountDbContextModelCreatingExtensions.cs | 47 +++++++ ...nvoiceSettledDetailDiffDapperRepository.cs | 77 +++++++++- .../InvoiceSettledDetailDiffExportService.cs | 30 +++- ...UnInvoiceSettledDetailDiffExportService.cs | 2 +- 10 files changed, 360 insertions(+), 77 deletions(-) diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs index c404cfa6..aaf7aef6 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs @@ -23,8 +23,9 @@ namespace Win.Sfs.SettleAccount.Entities.Prices /// /// 标准价格单-相关应用服务 /// - [Authorize(SettleAccountPermissions.PriceLists.Default)] + //[Authorize(SettleAccountPermissions.PriceLists.Default)] [Route("api/SettleAccount/PriceList")] + [AllowAnonymous] public class PriceListAppService : ApplicationService /*, IPriceListAppService*/ { @@ -156,7 +157,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices /// 是否导入成功 [HttpPost] [Route("ExcelImport-Map")] - [Authorize(SettleAccountPermissions.PriceLists.Create)] + //[Authorize(SettleAccountPermissions.PriceLists.Create)] virtual public async Task ImportAsync([FromForm] IFormFileCollection files,string version) { ExportImporter _exportImporter = new ExportImporter(); diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs index a6fdcf1d..20c14eae 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs @@ -23,7 +23,8 @@ namespace Win.Sfs.SettleAccount.Entities.Prices /// /// 标准价格单-相关应用服务 /// - [Authorize(SettleAccountPermissions.PriceLists.Default)] + //[Authorize(SettleAccountPermissions.PriceLists.Default)] + [AllowAnonymous] [Route("api/SettleAccount/PriceListBJ")] public class PriceListAppServiceBJ : ApplicationService /*, IPriceListAppService*/ @@ -156,7 +157,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices /// 是否导入成功 [HttpPost] [Route("ExcelImport-Map")] - [Authorize(SettleAccountPermissions.PriceLists.Create)] + //[Authorize(SettleAccountPermissions.PriceLists.Create)] virtual public async Task ImportAsync([FromForm] IFormFileCollection files,string version) { ExportImporter _exportImporter = new ExportImporter(); diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/UnSettleAccounts/UnSettleAccountAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/UnSettleAccounts/UnSettleAccountAppService.cs index 3e334c67..520caa57 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/UnSettleAccounts/UnSettleAccountAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/UnSettleAccounts/UnSettleAccountAppService.cs @@ -49,8 +49,8 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts /// ///大众FIS未结算明细导入功能 /// - [Authorize(SettleAccountPermissions.UnSettleAccount.Default)] - //[AllowAnonymous] + [Authorize(SettleAccountPermissions.UnSettleAccount.Default)] + //[AllowAnonymous] [Route("api/settleaccount/UnSettleAccount")] public class UnSettleAccountAppService : SettleAccountApplicationBase, IUnSettleAccountAppService { diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs index 60c48474..9694bd5c 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs @@ -64,6 +64,11 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts private readonly ISettleAccountBranchEfCoreRepository _wmsRepository; private readonly ISettleAccountBranchEfCoreRepository _wmsVersionRepository; + + private readonly ISettleAccountBranchEfCoreRepository _wmsRepository1; + private readonly ISettleAccountBranchEfCoreRepository _wmsVersionRepository1; + + private readonly WMSEfCoreRepository _wmsefRespository; private readonly WMSEfCoreRepository _wmstbRespository; @@ -184,13 +189,14 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts [Route("WmsWithOutKanbanOutPut")] public async Task WmsWithOutKanbanOutPut(WmsJitRequestDto input) { + var _billNum = "KA" + DateTime.Now.ToString("yyyyMMddhhmmss"); var _joblist = _job.Where(p => input.Guids.Contains(p.Id) && p.FileName == "已确认").ToList(); if (_joblist.Count() > 0) { var fileList = _joblist.Select(p => p.RealDownFileName).ToList(); - List _lst = new List(); + List _lst = new List(); foreach (var filename in fileList) { string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename; @@ -198,49 +204,61 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts var _list = _excelHelper.ExcelToList(); foreach (var itm in _list) { - - var _entity= new WmsKanbanOutPutDetial(GuidGenerator.Create(), string.Empty, string.Empty, itm.MaterialCode, itm.MaterialDesc - , itm.SapMaterialGroup, string.Empty, string.Empty, 0, string.Empty, string.Empty, itm.Version, itm.SapMaterialCode, - _billNum, Guid.Empty, string.Empty, itm.InvoiceQty + var _entity= new WmsWithOutKanbanOutPutDetial( + GuidGenerator.Create(), + string.Empty, + string.Empty, + itm.MaterialCode, + itm.MaterialDesc, + itm.SapMaterialGroup, + string.Empty, + string.Empty, + 0, + string.Empty, + string.Empty, + input.Version, + itm.SapMaterialCode, + _billNum, + Guid.Empty, + string.Empty, + itm.InvoiceQty ); - _lst.Add(_entity); - } - + } } - var outPutDetail = await _wmsRepository.Where(p => p.Version == input.Version && p.Kanban==string.Empty).ToListAsync(); - - //var error = from itm1 in outPutDetail - // join itm2 in _ls1 on - // new { itm1.MaterialCode, itm1.Kanban } - // equals - // new { itm2.MaterialCode, itm2.Kanban } - // select itm1; - //var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) }); - //if (errList.Count() == 0) - //{ - - // var query = from itm1 in _ls1 - // join itm2 in outPutDetail on - // new { itm1.MaterialCode, itm1.Kanban } - // equals - // new { itm2.MaterialCode, itm2.Kanban } into temp1 - // from tm1 in temp1.DefaultIfEmpty() - // where tm1 == null - // select itm1; - // var _wmslst = query.ToList(); - // foreach (var itm in _lst) - // { - // itm.BillNum = _billNum; - // } - await _wmsRepository.GetDbContext().BulkInsertAsync(_lst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); - int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNum); + var outPutDetail = await _wmsRepository1.Where(p => p.Version == input.Version && p.Kanban==string.Empty).ToListAsync(); + + var error = from itm1 in outPutDetail + join itm2 in _lst on + new { itm1.MaterialCode } + equals + new { itm2.MaterialCode } + select itm1; + var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) }); + if (errList.Count() == 0) + { + + var query = from itm1 in _lst + join itm2 in outPutDetail on + new { itm1.MaterialCode} + equals + new { itm2.MaterialCode } into temp1 + from tm1 in temp1.DefaultIfEmpty() + where tm1 == null + select itm1; + var _wmslst = query.ToList(); + foreach (var itm in _lst) + { + itm.BillNum = _billNum; + } + await _wmsRepository1.GetDbContext().BulkInsertAsync(_lst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); + int _count = _wmsVersionRepository1.Count(p => p.Version == input.Version && p.BillNum == _billNum); if (_count == 0) { - var _version = new WmsKanbanOutPut(GuidGenerator.Create(), input.Version, _billNum, CurrentUser.Email); + var _version = new WmsWithOutKanbanOutPut(GuidGenerator.Create(), input.Version, _billNum, CurrentUser.Email); - await _wmsVersionRepository.InsertAsync(_version, true); + await _wmsVersionRepository1.InsertAsync(_version, true); } foreach (var job in _joblist) @@ -249,26 +267,26 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts await _job.UpdateAsync(job); } } - //else - //{ - // StringBuilder _buffer = new StringBuilder(); - // foreach (var itm in errList) - // { - // _buffer.AppendFormat("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number); - // } - // var _errinfo = _buffer.ToString(); - - // foreach (var job in _joblist) - // { - // job.FileName = _errinfo; - // await _job.UpdateAsync(job); - // } - //} - //} - //else - //{ - // _billNum = string.Empty; - //} + else + { + StringBuilder _buffer = new StringBuilder(); + foreach (var itm in errList) + { + _buffer.AppendFormat("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number); + } + var _errinfo = _buffer.ToString(); + + foreach (var job in _joblist) + { + job.FileName = _errinfo; + await _job.UpdateAsync(job); + } + } + } + else + { + _billNum = string.Empty; + } return ApplicationConsts.SuccessStr; ; } diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs index 377cba79..ae60aaae 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs @@ -32,8 +32,8 @@ using Win.Sfs.SettleAccount.Reports.ReportRequestDto; namespace Win.Sfs.SettleAccount.Reports.ReportServices { - [Authorize(SettleAccountPermissions.Reports.Default)] - //[AllowAnonymous] + //[Authorize(SettleAccountPermissions.Reports.Default)] + [AllowAnonymous] [Route("api/settleaccount/ReportMakeService")] public class ReportService : ApplicationService { @@ -360,6 +360,11 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices customConditionList.Add(new CustomCondition() { Name = "ChassisNumber", Value = string.IsNullOrEmpty(request.ChassisNumber) ? string.Empty : request.ChassisNumber }); customConditionList.Add(new CustomCondition() { Name = "MaterialGroup", Value = string.IsNullOrEmpty(request.MaterialGroup) ? string.Empty : request.MaterialGroup }); customConditionList.Add(new CustomCondition() { Name = "SapCode", Value = string.IsNullOrEmpty(request.SapCode) ? string.Empty : request.SapCode }); + + + + + var _taskid = await _service.ExportEnqueueAsync("准时化结算核对明细", ExportExtentsion.Excel,request.Version, string.IsNullOrEmpty(request.MaterialGroup) ? string.Empty : request.MaterialGroup, CurrentUser, typeof(InvoiceSettledDetailDiffExportService), customConditionList, (rs) => { }); diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs index 232183c2..3999f98f 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs @@ -324,6 +324,132 @@ namespace Win.Sfs.SettleAccount.Entities.WMS } + + public class WmsWithOutKanbanOutPut : FullAuditedAggregateRootBase + { + public WmsWithOutKanbanOutPut() + { + } + + public WmsWithOutKanbanOutPut(Guid id, string version, string billNum, string creator) : base(id) + { + Id = id; + Version = version; + BillNum = billNum; + Creator = creator; + } + + public string Version { set; get; } + + public string BillNum { set; get; } + + public string Creator { set; get; } + + + + } + + + /// + /// 看板明细 + /// + public class WmsWithOutKanbanOutPutDetial : FullAuditedAggregateRootBase + { + public WmsWithOutKanbanOutPutDetial() + { + } + + public WmsWithOutKanbanOutPutDetial(Guid id, string wmsBillNum, string kanban, string materialCode, string materialDesc, string materialGroup, string outPut, string inPut, int state, string extend1, string extend2, string extend3, string parentMaterialCode, string billNum, Guid taskId, string remark, decimal qty) + { + Id = id; + WmsBillNum = wmsBillNum; + Kanban = kanban; + MaterialCode = materialCode; + MaterialDesc = materialDesc; + MaterialGroup = materialGroup; + OutPut = outPut; + InPut = inPut; + State = state; + Extend1 = extend1; + Extend2 = extend2; + Version = extend3; + ParentMaterialCode = parentMaterialCode; + BillNum = billNum; + TaskId = taskId; + Remark = remark; + Qty = qty; + + } + public void SetData(Guid id, string remark, string wmsbillnum, string version, Guid taskId) + { + Id = id; + Remark = remark; + WmsBillNum = wmsbillnum; + Version = version; + TaskId = taskId; + + + + } + // 交货单号 实际发货日期 KENN号 底盘号 物料号 物料描述 客户物料 组件组物料 组件组物料描述 物料组(车型) 定价 金额 结算平台未结数量 大众R3未结数量 差异金额 差异数量 漏结标识 漏结期间 说明 + [ImporterHeader(Name = "组件组物料", IsIgnore = true)] + public string ParentMaterialCode { set; get; } + [ImporterHeader(Name = "交货单号")] + public string WmsBillNum { set; get; } + [ImporterHeader(Name = "条码号")] + //KENN号 + public string Kanban { set; get; } + + [ImporterHeader(Name = "物料号")] + //物料号 + public string MaterialCode { set; get; } + [ImporterHeader(Name = "物料描述")] + //物料描述 + public string MaterialDesc { set; get; } + [ImporterHeader(Name = "物料组(车型)")] + //物料组(车型) + public string MaterialGroup { set; get; } + [ImporterHeader(Name = "出库库位", IsIgnore = true)] + //出库库位 + public string OutPut { set; get; } + [ImporterHeader(Name = "入库库位", IsIgnore = true)] + //入库库位 + public string InPut { set; get; } + [ImporterHeader(Name = "状态", IsIgnore = true)] + public int State { get; set; } + [ImporterHeader(Name = "客户物料")] + /// + /// 扩展字段1 + /// + public string Extend1 { set; get; } + /// + /// 扩展字段2 + /// + [ImporterHeader(Name = "订单日期")] + public string Extend2 { set; get; } + /// + /// 扩展字段3 + /// + [ImporterHeader(Name = "版本号", IsIgnore = true)] + public string Version { set; get; } + [ImporterHeader(Name = "结算数量")] + public decimal Qty { set; get; } + + [ImporterHeader(Name = "单据", IsIgnore = true)] + public string BillNum { set; get; } + + [ImporterHeader(Name = "任务", IsIgnore = true)] + public Guid TaskId { set; get; } + + + } + + + + + + + #region 红旗M平台出库 /// diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs index 49a17aaa..1556643c 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs @@ -331,6 +331,10 @@ namespace Win.Sfs.SettleAccount builder.ConfigureWmsJitOutPutVersion(options); builder.ConfigureWmsKanbanOutPutVersion(options); builder.ConfigureWmsKanbanOutPutDetail(options); + + + builder.ConfigureWmsWithOutKanbanOutPutVersion(options); + builder.ConfigureWmsWithOutKanbanOutPutDetail(options); builder.ConfigureWmsSharePartOutPutDetail(options); builder.ConfigureWmsSharePartOutPutVersion(options); @@ -1345,6 +1349,49 @@ namespace Win.Sfs.SettleAccount } + + private static void ConfigureWmsWithOutKanbanOutPutVersion(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options) + { + + builder.Entity(b => + { + b.ToTable($"{options.TablePrefix}_WmsKanbanOutPutExtend", options.Schema); + b.ConfigureByConvention(); + b.Property(x => x.BillNum).IsRequired().HasMaxLength(CommonConsts.MaxCodeLength); + b.Property(x => x.Version).IsRequired().HasMaxLength(CommonConsts.MaxCodeLength); + + b.HasIndex(x => new { x.BillNum }); + }); + + } + private static void ConfigureWmsWithOutKanbanOutPutDetail(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options) + { + + builder.Entity(b => + { + b.ToTable($"{options.TablePrefix}_WmsKanbanOutPutDetialExtend", options.Schema); + b.ConfigureByConvention(); + b.Property(x => x.BillNum).IsRequired().HasMaxLength(CommonConsts.MaxCodeLength); + b.Property(x => x.WmsBillNum).IsRequired().HasMaxLength(CommonConsts.MaxCodeLength); + b.Property(x => x.Version).IsRequired().HasMaxLength(CommonConsts.MaxCodeLength); + b.Property(x => x.OutPut).HasMaxLength(CommonConsts.MaxCodeLength); + b.Property(x => x.InPut).HasMaxLength(CommonConsts.MaxCodeLength); + b.Property(x => x.Kanban).HasMaxLength(CommonConsts.MaxCodeLength); + + b.Property(x => x.ParentMaterialCode).HasMaxLength(CommonConsts.MaxCodeLength); + b.Property(x => x.Extend1).HasMaxLength(CommonConsts.MaxCodeLength); + b.Property(x => x.Extend2).HasMaxLength(CommonConsts.MaxCodeLength); + b.Property(x => x.MaterialCode).HasMaxLength(CommonConsts.MaxCodeLength); + b.HasIndex(x => new { x.BillNum }); + }); + + } + + + + + + private static void ConfigureWmsSharePartOutPutVersion(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options) { diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/InvoiceSettledDetailDiffDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/InvoiceSettledDetailDiffDapperRepository.cs index 058f503b..f8fb6449 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/InvoiceSettledDetailDiffDapperRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/InvoiceSettledDetailDiffDapperRepository.cs @@ -13,7 +13,7 @@ using Win.Sfs.SettleAccount.Reports; namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report { - [ExcelExporter(MaxRowNumberOnASheet = 500000)] + [ExcelExporter(MaxRowNumberOnASheet = 900000)] public class InvoiceSettledDetailDiff : ReportDetailBase { @@ -100,11 +100,14 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report //单价差异 [ExporterHeader(DisplayName = "单价差异")] public decimal DiffPrice { set; get; } + + [ExporterHeader(DisplayName = "结算实际数量",IsIgnore =true)] + public decimal SettleReadyQty { set; get; } //总金额差异 //[ExporterHeader(DisplayName = "总金额差异")] //public decimal AmtDiffPrice { set; get; } - + @@ -159,6 +162,69 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report //{ // condition += string.Format(" B.chassisNumber='{0}' ", materialGroup); //} + + + +// string str= "SELECT\n" + +//" temp1.*,\n" + +//" TEMP2.Price,(\n" + +//" Isnull( temp2.Price, 0 ) * isnull( temp1.Qty, 0 )) Amt \n" + +//"FROM\n" + +//" (\n" + +//" SELECT\n" + +//" b.YEAR,\n" + +//" isnull( a.OrderBillNum, b.Kenncode ) kennocode,\n" + +//" b.MaterialCode,\n" + +//" b.Model,\n" + +//" isnull( a.ChassisNumber, b.ChassisNumber ) ChassisNumber,\n" + +//" isnull( a.Qty, 0 ) Qty,\n" + +//" isnull( a.BeginTime, b.CP5A ) CP5Time,\n" + +//" a.ChassisNumber2,\n" + +//" B.CP7 CP7Time,\n" + +//" isnull( a.QTY, b.Qty ) SettledQty,\n" + +//" a.ErpMaterialCode ParentSapMaterialCode,\n" + +//" isnull( a.WMSState, '' ) WMSState,\n" + +//" isnull( a.WMSBillNum, '' ) WMSBillNum,\n" + +//" d.MaterialCode SapMaterialCode,\n" + +//" d.MaterialDesc MaterialDesc,\n" + +//" d.EstimateTypeDesc MaterialGroup,\n" + +//" e.MaterialDesc ParentMaterialDesc,\n" + +//" c.InvoicePrice,\n" + +//" Round( c.InvoicePrice * isnull( a.QTY, b.Qty ), 2 ) InvoiceAmt,\n" + +//" Round( c.InvoicePrice * isnull( a.QTY, b.Qty ), 2 ) SettleAmt,\n" + +//" isnull( a.Qty, 0 ) - IsNull( B.Qty, 0 ) DiffSettleFisQty,\n" + +//" 0 DiffSettleInvQty,\n" + +//" isnull( a.QTY, b.Qty ) InvoiceQty \n" + +//" FROM\n" + +//" ( SELECT * FROM Set_Settle b WHERE b.Version = '{0}' ) b\n" + +//" LEFT JOIN Set_fis a ON b.ChassisNumber = a.ChassisNumber2 \n" + +//" AND b.KENNCode = a.KENNCode \n" + +//" AND b.MaterialCode = a.ItemCode\n" + +//" LEFT JOIN ( SELECT SUM( amt )/ SUM( Qty ) InvoicePrice, MaterialCode FROM set_invoice WHERE version = '{0}' GROUP BY materialcode ) c ON b.MaterialCode = c.MaterialCode\n" + +//" LEFT JOIN set_material d ON b.MaterialCode = d.CustomerPartCode\n" + +//" LEFT JOIN set_material e ON a.ErpMaterialCode = e.MaterialCode \n" + +//" ) TEMP1\n" + +//" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE version = ( SELECT Max( Version ) FROM Set_PriceList ) AND type = 10 ) TEMP2 ON TEMP1.SapMaterialCode = TEMP2.MaterialCode" + + + + + + + + + + + + + + + + + + + + string str = "SELECT\n" + " temp1.*,\n" + @@ -187,9 +253,10 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " c.InvoicePrice,\n" + " Round( c.InvoicePrice * a.qty,2 ) InvoiceAmt,\n" + " Round( c.InvoicePrice * a.Qty,2 ) SettleAmt,\n" + -" a.Qty - IsNull( B.Qty, 0 ) DiffSettleFisQty,\n" + +" 0 DiffSettleFisQty,\n" + " 0 DiffSettleInvQty, \n" + -" a.Qty InvoiceQty \n" + +" a.Qty InvoiceQty ,\n" + +" IsNull( B.Qty, 0 ) SettleReadyQty \n" + " FROM\n" + " ( SELECT * FROM Set_Settle b WHERE b.Version = '{0}' ) b\n" + " INNER JOIN Set_fis a ON b.ChassisNumber = a.ChassisNumber2 \n" + @@ -197,7 +264,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " AND b.MaterialCode = a.ItemCode\n" + " LEFT JOIN ( SELECT SUM( amt )/ SUM( Qty ) InvoicePrice, MaterialCode FROM set_invoice WHERE version = '{0}' GROUP BY materialcode ) c ON a.ItemCode = c.MaterialCode\n" + " LEFT JOIN set_material d ON a.ItemCode = d.CustomerPartCode\n" + -" LEFT JOIN set_material e ON a.ErpMaterialCode = e.MaterialCode {1} \n" + +" LEFT JOIN (select max(CreationTime) CreateTime,MaterialCode,MaterialDesc from Set_material group by MaterialCode,MaterialDesc) e ON a.ErpMaterialCode = e.MaterialCode {1} \n" + " ) TEMP1\n" + " LEFT JOIN (\n" + " SELECT\n" + diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDetailDiffExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDetailDiffExportService.cs index aa0d7a38..3d90e200 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDetailDiffExportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDetailDiffExportService.cs @@ -95,10 +95,10 @@ namespace SettleAccount.Job.Services DiffSettleFisQty = 0, DiffSettleInvQty = 0, InvoiceQty = 1, - InvoicePrice = tm1.Price, - InvocieAmt = tm1.Price, - SettleAmt = tm1.Price, - DiffPrice = tm1.Price-itm1.Price + InvoicePrice =itm1==null?0: tm1.Price, + InvocieAmt = itm1 == null ?0: tm1.Price, + SettleAmt = itm1 == null ?0: tm1.Price, + DiffPrice = itm1 == null ?0-itm1.Price: tm1.Price-itm1.Price }; rangeList = rangList.ToList(); @@ -106,8 +106,11 @@ namespace SettleAccount.Job.Services foreach (var itm in diffList) { var _first = _ls.FirstOrDefault(p => p.MaterialCode == itm.MaterialCode); - _first.InvoiceQty = _first.SettledQty + itm.DiffQty; - _first.DiffSettleInvQty = itm.DiffQty; + if (_first != null) + { + _first.InvoiceQty = _first.SettledQty + itm.DiffQty; + _first.DiffSettleInvQty = itm.DiffQty; + } } foreach (var itm in _ls) @@ -117,6 +120,17 @@ namespace SettleAccount.Job.Services } _ls.AddRange(rangeList); + //var list1 = _ls.GroupBy(p => new { p.ChassisNumber, p.MaterialCode, p.SettleReadyQty }).Select(p => new { SettleQty = p.Key.SettleReadyQty, MaterialCode = p.Key.MaterialCode, ChassisNumber = p.Key.ChassisNumber, Qty = p.Sum(itm => itm.Qty) }).Where(p => p.Qty > 1).ToList(); + //foreach (var itm in list1) + //{ + // var _first = _ls.FirstOrDefault(p => p.ChassisNumber == itm.ChassisNumber && p.MaterialCode == itm.MaterialCode && p.SettleReadyQty == itm.SettleQty); + // if (_first != null) + // { + // _first.DiffSettleFisQty = itm.Qty - itm.SettleQty; + // } + //} + + if (!string.IsNullOrEmpty(materialGroup)) { var _groupList= materialGroup.Split(new char[] { ',' }).Distinct().ToList(); @@ -157,6 +171,10 @@ namespace SettleAccount.Job.Services _ls = _ls.Where(p => _groupList.Contains(p.SapMaterialCode)).ToList(); } } + + + + //.Select(p => p.FirstOrDefault()); _ls = _ls.OrderBy(p => p.ChassisNumber).ThenBy(p => p.KENNCode).ThenBy(p => p.SapMaterialCode).ToList(); } 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 e443c5a3..cc473ae9 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnInvoiceSettledDetailDiffExportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnInvoiceSettledDetailDiffExportService.cs @@ -164,7 +164,7 @@ namespace SettleAccount.Job.Services - + var result = _exporter.Append(_ls, "差异明细表")