diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs index 511fdf03..c1b64e09 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs @@ -152,7 +152,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase var luAssemble = lus.Select(t => t.Replace(" ", "")); importBBACSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index); } - + importBBACSaDetail.CustomerPartCodeNoSpace = importBBACSaDetail.LU.Replace(" ", ""); importBBACSaDetail.Version = Version; importBBACSaDetail.Site = Site; }); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs index 59ba3ea9..e7bde6c2 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs @@ -436,6 +436,7 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase var luAssemble = lus.Select(t => t.Replace(" ", "")); hbpoSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index); } + hbpoSaDetail.CustomerPartCodeNoSpace = hbpoSaDetail.LU.Replace(" ", ""); hbpoSaDetail.Version = Version; }); } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs index 33eea91f..9c09ef72 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs @@ -239,6 +239,8 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase return new JsonResult(new { Code = 200, Message = "导入成功" }); } + HandleSaDetailLU(importPubSaDetails); + #region 数据校验 var checkList = await CheckAsync(importPubSaDetails).ConfigureAwait(false); if (checkList.Count > 0) @@ -274,6 +276,8 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase return new JsonResult(new { Code = 200, Message = "导入成功" }); } + HandleSaDetailLU(importPubSaDetails); + #region 数据校验 var checkList = await CheckAsync(importPubSaDetails); if (checkList.Count > 0) @@ -302,6 +306,8 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase return new JsonResult(new { Code = 200, Message = "导入成功" }); } + HandleSaDetailLU(importPubSaDetails); + #region 数据校验 var checkList = await CheckAsync(importPubSaDetails).ConfigureAwait(false); if (checkList.Count > 0) @@ -331,6 +337,8 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase return new JsonResult(new { Code = 200, Message = "导入成功" }); } + HandleSaDetailLU(importPubSaDetails); + #region 数据校验 var checkList = await CheckAsync(importPubSaDetails).ConfigureAwait(false); if (checkList.Count > 0) @@ -368,19 +376,6 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase //验证客户对应厂内零件号是否存在 //导入的零件号集合 var importPubSaLUs = pubSaDetails.Select(t => t.LU).Distinct(); - - importPubSaLUs.ForEach(importPubSaLU => - { - List lus = importPubSaLU.Split(" ").ToList(); - importPubSaLU = lus[0].Replace(" ", ""); - if (lus.Count > 1) - { - lus.RemoveAt(0); - var luAssemble = lus.Select(t => t.Replace(" ", "")); - importPubSaLU += luAssemble.Aggregate(" ", (current, index) => current + index); - } - }); - var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false); var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct(); @@ -396,6 +391,25 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase #endregion } + /// + /// 处理结算数据LU + /// + /// + private void HandleSaDetailLU(List pubSaDetails) + { + pubSaDetails.ForEach(pubSaDetail => + { + var lus = pubSaDetail.LU.Split(" ").ToList(); + pubSaDetail.LU = lus[0].Replace(" ", ""); + if (lus.Count > 1) + { + lus.RemoveAt(0); + var luAssemble = lus.Select(t => t.Replace(" ", "")); + pubSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index); + } + }); + } + /// /// 结算数据处理 /// @@ -408,15 +422,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase pubSaDetails.ForEach(importPubSaDetail => { importPubSaDetail.SetId(GuidGenerator.Create()); - List lus = importPubSaDetail.LU.Split(" ").ToList(); - importPubSaDetail.LU = lus[0].Replace(" ", ""); - if (lus.Count > 1) - { - lus.RemoveAt(0); - var luAssemble = lus.Select(t => t.Replace(" ", "")); - importPubSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index); - } - + importPubSaDetail.CustomerPartCodeNoSpace = importPubSaDetail.LU.Replace(" ", ""); importPubSaDetail.KeyCode = importPubSaDetail.PN + importPubSaDetail.LU; importPubSaDetail.Version = _version; importPubSaDetail.BusinessType = businessType; @@ -449,20 +455,6 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase //导入的零件号集合 var importPubSaLUs = pubSaDetails.Select(t => t.LU).Distinct(); var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false); - //var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct(); - - ///* - // * (不存在的客户零件号)差集 - // * 转换为厂内零件号 - // * 转换规则6个空格替换成“-” - // */ - //var noExistSettleMaterialCodes = importPubSaLUs.Except(materialRelationshipEntitySettleMaterialCodes); - - //noExistSettleMaterialCodes.ForEach(t => - //{ - // var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t, businessType); - // materialRelationships.Add(materialRelationship); - //}); var seAllMaterialRelationships = materialRelationshipEntitys.Union(materialRelationships); pubSaDetails.ForEach(pubSaDetail => diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs index 06272d11..1837942f 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Coravel.Invocable; +using EFCore.BulkExtensions; using LinqToDB; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; @@ -38,25 +39,61 @@ public class JisBBACSeEdiCompareAppService : ApplicationService, IInvocable await HandDelEdiDataAsync().ConfigureAwait(false); lock (_lockObj) { - var seDetailGroup = db.Set().Where(t => t.IsHaveEdiData == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU }); - var ediDetailGroup = db.Set().Where(t => t.IsDeleted == false && t.IsHaveSeData == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU }); - var keyCodes = seDetailGroup.Join(ediDetailGroup, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (se, edi) => new { se.PN, se.LU }).Take(10000).ToList(); - if (keyCodes.Any()) + var seDetailGroup = db.Set().Where(t => t.IsHaveEdiData == false).GroupBy(t => new { t.PN, t.CustomerPartCodeNoSpace }).Select(t => new { t.Key.PN, LU = t.Key.CustomerPartCodeNoSpace }); + var ediDetailGroup = db.Set().Where(t => t.IsDeleted == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU }); + + var keyCodes = from se in seDetailGroup + from edi in ediDetailGroup + where se.PN == edi.PN && se.LU == edi.LU + select new { se.PN, se.LU }; + var seDetailsQuery = from se in db.Set() + from keyCode in keyCodes + where se.PN == keyCode.PN && se.CustomerPartCodeNoSpace == keyCode.LU && se.IsHaveEdiData == false + select se; + var ediDetailsQuery = from edi in db.Set() + from keyCode in keyCodes + where edi.PN == keyCode.PN && edi.LU == keyCode.LU && edi.IsDeleted == false && edi.IsHaveSeData == false + select edi; + + var seDetails = seDetailsQuery.Take(5000).ToList(); + var ediDetails = ediDetailsQuery.Take(5000).ToList(); + + if (seDetails.Any()) { - var seDetails = db.Set().Join(keyCodes, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (a, b) => a); - var ediDetails = db.Set().Join(keyCodes, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (a, b) => a); - if (seDetails.Any()) - { - seDetails.ForEach(t => t.IsHaveEdiData = true); - db.Set().UpdateRange(seDetails); - } - if (ediDetails.Any()) - { - ediDetails.ForEach(t => t.IsHaveSeData = true); - db.Set().UpdateRange(ediDetails); - } - db.SaveChanges(); + seDetails.ForEach(t => t.IsHaveEdiData = true); + db.BulkUpdate(seDetails); } + if (ediDetails.Any()) + { + ediDetails.ForEach(t => t.IsHaveSeData = true); + db.BulkUpdate(ediDetails); + } + db.SaveChanges(); + + //var keyCodes = seDetailGroup.Join(ediDetailGroup, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (se, edi) => new { se.PN, se.LU }).Take(1000).ToList(); + //if (keyCodes.Any()) + //{ + // var pnLus = keyCodes.GroupBy(t => t.PN).Select(t => new { t.Key, Lus = t.Where(p => p.PN == t.Key).Select(t => t.LU) }); + + // pnLus.ForEach(pnLu => + // { + // var pn = pnLu.Key; + // var lus = pnLu.Lus; + // var seDetails = db.Set().Where(t => t.PN == pn && lus.Contains(t.CustomerPartCodeNoSpace)); + // var ediDetails = db.Set().Where(t => t.PN == pn && lus.Contains(t.LU)); + // if (seDetails.Any()) + // { + // seDetails.ForEach(t => t.IsHaveEdiData = true); + // db.Set().UpdateRange(seDetails); + // } + // if (ediDetails.Any()) + // { + // ediDetails.ForEach(t => t.IsHaveSeData = true); + // db.Set().UpdateRange(ediDetails); + // } + // }); + // db.SaveChanges(); + //} } } catch (Exception) @@ -83,7 +120,7 @@ public class JisBBACSeEdiCompareAppService : ApplicationService, IInvocable if (ediDelKeyCodes.Any()) { - var seDetails = db.Set().Join(ediDelKeyCodes, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (a, b) => a); + var seDetails = db.Set().Join(ediDelKeyCodes, a => new { a.PN, LU = a.CustomerPartCodeNoSpace }, b => new { b.PN, b.LU }, (a, b) => a); var ediDetails = db.Set().Join(ediDelKeyCodes, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (a, b) => a); if (seDetails.Any()) { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs index 5891d4a9..65fa1450 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs @@ -122,6 +122,7 @@ public class JisBBACSeSyncBaseAppService : ApplicationService, IInvocable { t.SetId(GuidGenerator.Create()); t.BusinessType = businessType; + t.CustomerPartCodeNoSpace = t.LU.Replace(" ", ""); t.KeyCode = t.PN + t.LU; if (t.BillTime != null) { @@ -185,6 +186,7 @@ public class JisBBACSeSyncBaseAppService : ApplicationService, IInvocable { t.SetId(GuidGenerator.Create()); t.BusinessType = businessType; + t.CustomerPartCodeNoSpace = t.LU.Replace(" ", ""); t.KeyCode = t.PN + t.LU; if (t.BillTime != null) { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs index edda83f5..20da8e47 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Linq.Dynamic.Core; using System.Threading.Tasks; using Coravel.Invocable; +using EFCore.BulkExtensions; using LinqToDB; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; @@ -55,25 +56,36 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable await HandDelEdiDataAsync().ConfigureAwait(false); lock (_lockObj) { - var seDetailGroup = db.Set().Where(t => t.IsHaveEdiData == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU }); + var seDetailGroup = db.Set().Where(t => t.IsHaveEdiData == false).GroupBy(t => new { t.PN, t.CustomerPartCodeNoSpace }).Select(t => new { t.Key.PN, LU = t.Key.CustomerPartCodeNoSpace }); var ediDetailGroup = db.Set().Where(t => t.IsDeleted == false && t.IsHaveSeData == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU }); - var keyCodes = seDetailGroup.Join(ediDetailGroup, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (se, edi) => new { se.PN, se.LU }).Take(10000).ToList(); - if (keyCodes.Any()) + + var keyCodes = from se in seDetailGroup + from edi in ediDetailGroup + where se.PN == edi.PN && se.LU == edi.LU + select new { se.PN, se.LU }; + var seDetailsQuery = from se in db.Set() + from keyCode in keyCodes + where se.PN == keyCode.PN && se.CustomerPartCodeNoSpace == keyCode.LU && se.IsHaveEdiData == false + select se; + var ediDetailsQuery = from edi in db.Set() + from keyCode in keyCodes + where edi.PN == keyCode.PN && edi.LU == keyCode.LU && edi.IsDeleted == false && edi.IsHaveSeData == false + select edi; + + var seDetails = seDetailsQuery.Take(5000).ToList(); + var ediDetails = ediDetailsQuery.Take(5000).ToList(); + + if (seDetails.Any()) + { + seDetails.ForEach(t => t.IsHaveEdiData = true); + db.BulkUpdate(seDetails); + } + if (ediDetails.Any()) { - var seDetails = db.Set().Join(keyCodes, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (a, b) => a); - var ediDetails = db.Set().Join(keyCodes, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (a, b) => a); - if (seDetails.Any()) - { - seDetails.ForEach(t => t.IsHaveEdiData = true); - db.Set().UpdateRange(seDetails); - } - if (ediDetails.Any()) - { - ediDetails.ForEach(t => t.IsHaveSeData = true); - db.Set().UpdateRange(ediDetails); - } - db.SaveChanges(); + ediDetails.ForEach(t => t.IsHaveSeData = true); + db.BulkUpdate(ediDetails); } + db.SaveChanges(); } } catch (Exception) @@ -94,7 +106,7 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable if (ediDelKeyCodes.Any()) { - var seDetails = db.Set().Join(ediDelKeyCodes, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (a, b) => a); + var seDetails = db.Set().Join(ediDelKeyCodes, a => new { a.PN, LU = a.CustomerPartCodeNoSpace }, b => new { b.PN, b.LU }, (a, b) => a); var ediDetails = db.Set().Join(ediDelKeyCodes, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (a, b) => a); if (seDetails.Any()) { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs index e2e3c19a..fbb0d80e 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs @@ -122,6 +122,7 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable { t.SetId(GuidGenerator.Create()); t.BusinessType = businessType; + t.CustomerPartCodeNoSpace = t.LU.Replace(" ", ""); t.KeyCode = t.PN + t.LU; if (t.BillTime != null) { @@ -185,6 +186,7 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable { t.SetId(GuidGenerator.Create()); t.BusinessType = businessType; + t.CustomerPartCodeNoSpace = t.LU.Replace(" ", ""); t.KeyCode = t.PN + t.LU; if (t.BillTime != null) { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs index 6302dc9d..35ed7c72 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs @@ -119,6 +119,7 @@ public class JitSeSyncAppService : ApplicationService, IInvocable { t.SetId(GuidGenerator.Create()); t.BusinessType = businessType; + t.CustomerPartCodeNoSpace = t.LU.Replace(" ", ""); t.KeyCode = t.PN + t.LU; if (t.BillTime != null) { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs index 535125ae..272ea75f 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs @@ -57,6 +57,11 @@ public class PubSaSeCompareDiff [Display(Name = "生产号")] public string PN { set; get; } /// + /// 客户物料号 + /// + [Display(Name = "客户物料号")] + public string LU { set; get; } + /// /// WMS目标库位 /// [Display(Name = "WMS目标库位")] @@ -111,10 +116,6 @@ public class PubSaSeCompareDiff /// 是否已经移除 /// public bool IsRemove { get; set; } - /// - /// 是否替换了厂内零件号 - /// - public bool IsReplace { get; set; } } /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanBBACSaSeCompareExportService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanBBACSaSeCompareExportService.cs index c6cfb081..9e5134ee 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanBBACSaSeCompareExportService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanBBACSaSeCompareExportService.cs @@ -121,12 +121,13 @@ namespace SettleAccount.Job.Services.Report //结算 var saGroup = from sa in _settleAccountDbContext.Set() where sa.BusinessType == businessType && sa.Version == version - group sa by new { sa.PN, sa.LU } into groupItem + group sa by new { sa.PN, sa.CustomerPartCodeNoSpace } into groupItem select new { groupItem.Key.PN, - groupItem.Key.LU, + groupItem.Key.CustomerPartCodeNoSpace, Qty = groupItem.Sum(t => t.Qty), + LU = groupItem.Max(t => t.LU), Price = groupItem.Max(t => t.Price), SettleDate = groupItem.Max(t => t.SettleDate), PartCode = groupItem.Max(t => t.PartCode), @@ -134,12 +135,13 @@ namespace SettleAccount.Job.Services.Report //发运 var seGroup = from se in _settleAccountDbContext.Set() where se.BusinessType == businessType && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime - group se by new { se.PN, se.LU } into groupItem + group se by new { se.PN, se.CustomerPartCodeNoSpace } into groupItem select new { groupItem.Key.PN, - groupItem.Key.LU, + groupItem.Key.CustomerPartCodeNoSpace, Qty = groupItem.Sum(t => t.Qty), + LU = groupItem.Max(t => t.LU), WmsBillNum = groupItem.Max(t => t.WmsBillNum), ShippingDate = groupItem.Max(t => t.ShippingDate), FactoryPartCode = groupItem.Max(t => t.FactoryPartCode), @@ -148,7 +150,7 @@ namespace SettleAccount.Job.Services.Report }; var saSeCompareLeft = from sa in saGroup join se in seGroup - on new { sa.PN, sa.LU } equals new { se.PN, se.LU } + on new { sa.PN, sa.CustomerPartCodeNoSpace } equals new { se.PN, se.CustomerPartCodeNoSpace } into temp from se in temp.DefaultIfEmpty() select new PubSaSeCompareDiff() @@ -162,14 +164,15 @@ namespace SettleAccount.Job.Services.Report FixPrice = sa.Price, ToLocCode = se.ToLoc, ToErpLocCode = se.ErpToLoc, - SeCustomerPartCode = se.LU, + SeCustomerPartCode = se.CustomerPartCodeNoSpace, SeFactoryPartCode = se.FactoryPartCode, - SaCustomerPartCode = sa.LU, - SaFactoryPartCode = sa.PartCode + SaCustomerPartCode = sa.CustomerPartCodeNoSpace, + SaFactoryPartCode = sa.PartCode, + CustomerPartCode = sa.LU, }; var saSeCompareRight = from se in seGroup join sa in saGroup - on new { se.PN, se.LU } equals new { sa.PN, sa.LU } + on new { se.PN, se.CustomerPartCodeNoSpace } equals new { sa.PN, sa.CustomerPartCodeNoSpace } into temp from sa in temp.DefaultIfEmpty() select new PubSaSeCompareDiff() @@ -183,10 +186,11 @@ namespace SettleAccount.Job.Services.Report FixPrice = sa.Price, ToLocCode = se.ToLoc, ToErpLocCode = se.ErpToLoc, - SeCustomerPartCode = se.LU, + SeCustomerPartCode = se.CustomerPartCodeNoSpace, SeFactoryPartCode = se.FactoryPartCode, - SaCustomerPartCode = sa.LU, - SaFactoryPartCode = sa.PartCode + SaCustomerPartCode = sa.CustomerPartCodeNoSpace, + SaFactoryPartCode = sa.PartCode, + CustomerPartCode = sa.LU ?? se.LU }; var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList(); return saSeCompareFullJoin; diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanHBPOSaSeCompareExportService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanHBPOSaSeCompareExportService.cs index 52f12e15..8b5180ed 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanHBPOSaSeCompareExportService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanHBPOSaSeCompareExportService.cs @@ -121,12 +121,13 @@ namespace SettleAccount.Job.Services.Report //结算 var saGroup = from sa in _settleAccountDbContext.Set() where sa.BusinessType == businessType && sa.Version == version - group sa by new { sa.PN, sa.LU } into groupItem + group sa by new { sa.PN, sa.CustomerPartCodeNoSpace } into groupItem select new { groupItem.Key.PN, - groupItem.Key.LU, + groupItem.Key.CustomerPartCodeNoSpace, Qty = groupItem.Sum(t => t.Qty), + LU = groupItem.Max(t => t.LU), Price = groupItem.Max(t => t.Price), SettleDate = groupItem.Max(t => t.SettleDate), PartCode = groupItem.Max(t => t.PartCode), @@ -134,12 +135,13 @@ namespace SettleAccount.Job.Services.Report //发运 var seGroup = from se in _settleAccountDbContext.Set() where se.BusinessType == businessType && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime - group se by new { se.PN, se.LU } into groupItem + group se by new { se.PN, se.CustomerPartCodeNoSpace } into groupItem select new { groupItem.Key.PN, - groupItem.Key.LU, + groupItem.Key.CustomerPartCodeNoSpace, Qty = groupItem.Sum(t => t.Qty), + LU = groupItem.Max(t => t.LU), WmsBillNum = groupItem.Max(t => t.WmsBillNum), ShippingDate = groupItem.Max(t => t.ShippingDate), FactoryPartCode = groupItem.Max(t => t.FactoryPartCode), @@ -148,7 +150,7 @@ namespace SettleAccount.Job.Services.Report }; var saSeCompareLeft = from sa in saGroup join se in seGroup - on new { sa.PN, sa.LU } equals new { se.PN, se.LU } + on new { sa.PN, sa.CustomerPartCodeNoSpace } equals new { se.PN, se.CustomerPartCodeNoSpace } into temp from se in temp.DefaultIfEmpty() select new PubSaSeCompareDiff() @@ -162,10 +164,11 @@ namespace SettleAccount.Job.Services.Report FixPrice = sa.Price, ToLocCode = se.ToLoc, ToErpLocCode = se.ErpToLoc, - SeCustomerPartCode = se.LU, + SeCustomerPartCode = se.CustomerPartCodeNoSpace, SeFactoryPartCode = se.FactoryPartCode, - SaCustomerPartCode = sa.LU, - SaFactoryPartCode = sa.PartCode + SaCustomerPartCode = sa.CustomerPartCodeNoSpace, + SaFactoryPartCode = sa.PartCode, + CustomerPartCode = sa.LU }; var saSeCompareRight = from se in seGroup join sa in saGroup @@ -183,10 +186,11 @@ namespace SettleAccount.Job.Services.Report FixPrice = sa.Price, ToLocCode = se.ToLoc, ToErpLocCode = se.ErpToLoc, - SeCustomerPartCode = se.LU, + SeCustomerPartCode = se.CustomerPartCodeNoSpace, SeFactoryPartCode = se.FactoryPartCode, - SaCustomerPartCode = sa.LU, - SaFactoryPartCode = sa.PartCode + SaCustomerPartCode = sa.CustomerPartCodeNoSpace, + SaFactoryPartCode = sa.PartCode, + CustomerPartCode = sa.LU ?? se.LU }; var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList(); return saSeCompareFullJoin; diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs index b726c63c..38ab4539 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs @@ -226,12 +226,13 @@ namespace SettleAccount.Job.Services.Report //结算 var saGroup = from sa in _settleAccountDbContext.Set() where sa.BusinessType == businessType && sa.Version == version - group sa by new { sa.PN, sa.LU } into groupItem + group sa by new { sa.PN, sa.CustomerPartCodeNoSpace } into groupItem select new { groupItem.Key.PN, - groupItem.Key.LU, + groupItem.Key.CustomerPartCodeNoSpace, Qty = groupItem.Sum(t => t.Qty), + LU = groupItem.Max(t => t.LU), Price = groupItem.Max(t => t.Price), SettleDate = groupItem.Max(t => t.SettleDate), PartCode = groupItem.Max(t => t.PartCode), @@ -239,12 +240,13 @@ namespace SettleAccount.Job.Services.Report //发运 var seGroup = from se in _settleAccountDbContext.Set() where se.BusinessType == businessType && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime - group se by new { se.PN, se.LU } into groupItem + group se by new { se.PN, se.CustomerPartCodeNoSpace } into groupItem select new { groupItem.Key.PN, - groupItem.Key.LU, + groupItem.Key.CustomerPartCodeNoSpace, Qty = groupItem.Sum(t => t.Qty), + LU = groupItem.Max(t => t.LU), WmsBillNum = groupItem.Max(t => t.WmsBillNum), ShippingDate = groupItem.Max(t => t.ShippingDate), FactoryPartCode = groupItem.Max(t => t.FactoryPartCode), @@ -253,7 +255,7 @@ namespace SettleAccount.Job.Services.Report }; var saSeCompareLeft = from sa in saGroup join se in seGroup - on new { sa.PN, sa.LU } equals new { se.PN, se.LU } + on new { sa.PN, sa.CustomerPartCodeNoSpace } equals new { se.PN, se.CustomerPartCodeNoSpace } into temp from se in temp.DefaultIfEmpty() select new PubSaSeCompareDiff() @@ -267,14 +269,15 @@ namespace SettleAccount.Job.Services.Report FixPrice = sa.Price, ToLocCode = se.ToLocCode, ToErpLocCode = se.ToErpLocCode, - SeCustomerPartCode = se.LU, + SeCustomerPartCode = se.CustomerPartCodeNoSpace, SeFactoryPartCode = se.FactoryPartCode, - SaCustomerPartCode = sa.LU, - SaFactoryPartCode = sa.PartCode + SaCustomerPartCode = sa.CustomerPartCodeNoSpace, + SaFactoryPartCode = sa.PartCode, + CustomerPartCode = sa.LU }; var saSeCompareRight = from se in seGroup join sa in saGroup - on new { se.PN, se.LU } equals new { sa.PN, sa.LU } + on new { se.PN, se.CustomerPartCodeNoSpace } equals new { sa.PN, sa.CustomerPartCodeNoSpace } into temp from sa in temp.DefaultIfEmpty() select new PubSaSeCompareDiff() @@ -288,10 +291,11 @@ namespace SettleAccount.Job.Services.Report FixPrice = sa.Price, ToLocCode = se.ToLocCode, ToErpLocCode = se.ToErpLocCode, - SeCustomerPartCode = se.LU, + SeCustomerPartCode = se.CustomerPartCodeNoSpace, SeFactoryPartCode = se.FactoryPartCode, - SaCustomerPartCode = sa.LU, - SaFactoryPartCode = sa.PartCode + SaCustomerPartCode = sa.CustomerPartCodeNoSpace, + SaFactoryPartCode = sa.PartCode, + CustomerPartCode = sa.LU ?? se.LU }; var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList(); @@ -305,22 +309,24 @@ namespace SettleAccount.Job.Services.Report { var saGroup = from sa in _settleAccountDbContext.Set() where sa.BusinessType == EnumBusinessType.YinDuJian && sa.Version == version - group sa by new { sa.LU } into groupItem + group sa by new { sa.CustomerPartCodeNoSpace } into groupItem select new { - groupItem.Key.LU, + groupItem.Key.CustomerPartCodeNoSpace, Qty = groupItem.Sum(t => t.Qty), + LU = groupItem.Max(t => t.LU), Price = groupItem.Max(t => t.Price), SettleDate = groupItem.Max(t => t.SettleDate), PartCode = groupItem.Max(t => t.PartCode), }; var seGroup = from se in _settleAccountDbContext.Set() where se.BusinessType == EnumBusinessType.YinDuJian && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime - group se by new { se.LU } into groupItem + group se by new { se.CustomerPartCodeNoSpace } into groupItem select new { - groupItem.Key.LU, + groupItem.Key.CustomerPartCodeNoSpace, Qty = groupItem.Sum(t => t.Qty), + LU = groupItem.Max(t => t.LU), WmsBillNum = groupItem.Max(t => t.WmsBillNum), ShippingDate = groupItem.Max(t => t.ShippingDate), FactoryPartCode = groupItem.Max(t => t.FactoryPartCode), @@ -330,7 +336,7 @@ namespace SettleAccount.Job.Services.Report var saSeCompareLeft = from sa in saGroup join se in seGroup - on sa.LU equals se.LU + on sa.CustomerPartCodeNoSpace equals se.CustomerPartCodeNoSpace into temp from se in temp.DefaultIfEmpty() select new PubSaSeCompareDiff() @@ -343,14 +349,15 @@ namespace SettleAccount.Job.Services.Report FixPrice = sa.Price, ToLocCode = se.ToLocCode, ToErpLocCode = se.ToErpLocCode, - SeCustomerPartCode = se.LU, + SeCustomerPartCode = se.CustomerPartCodeNoSpace, SeFactoryPartCode = se.FactoryPartCode, - SaCustomerPartCode = sa.LU, - SaFactoryPartCode = sa.PartCode + SaCustomerPartCode = sa.CustomerPartCodeNoSpace, + SaFactoryPartCode = sa.PartCode, + CustomerPartCode = sa.LU }; var saSeCompareRight = from se in seGroup join sa in saGroup - on se.LU equals sa.LU + on se.CustomerPartCodeNoSpace equals sa.CustomerPartCodeNoSpace into temp from sa in temp.DefaultIfEmpty() select new PubSaSeCompareDiff() @@ -363,10 +370,11 @@ namespace SettleAccount.Job.Services.Report FixPrice = sa.Price, ToLocCode = se.ToLocCode, ToErpLocCode = se.ToErpLocCode, - SeCustomerPartCode = se.LU, + SeCustomerPartCode = se.CustomerPartCodeNoSpace, SeFactoryPartCode = se.FactoryPartCode, - SaCustomerPartCode = sa.LU, - SaFactoryPartCode = sa.PartCode + SaCustomerPartCode = sa.CustomerPartCodeNoSpace, + SaFactoryPartCode = sa.PartCode, + CustomerPartCode = sa.LU ?? se.LU }; var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList(); return saSeCompareFullJoin; diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs index 29601a0e..e6b21b93 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs @@ -47,21 +47,18 @@ namespace SettleAccount.Job.Services.Report break; case EnumPubSaSeCompareCategory.HaveSaHaveSe: { - p.CustomerPartCode = p.SaCustomerPartCode; p.FactoryPartCode = p.SaFactoryPartCode; p.ReplaceFactoryPartCode = p.SaFactoryPartCode; } break; case EnumPubSaSeCompareCategory.HaveSaNotHaveSe: { - p.CustomerPartCode = p.SaCustomerPartCode; p.FactoryPartCode = p.SaFactoryPartCode; p.ReplaceFactoryPartCode = p.SaFactoryPartCode; } break; case EnumPubSaSeCompareCategory.NotHaveSaHaveSe: { - p.CustomerPartCode = p.SeCustomerPartCode; p.FactoryPartCode = p.SeFactoryPartCode; p.ReplaceFactoryPartCode = p.SeFactoryPartCode; } @@ -79,8 +76,6 @@ namespace SettleAccount.Job.Services.Report { //二次匹配上的记录 var secondMatchHaveSaHaveSes = new List(); - //有结算有发运 - var haveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe); //有结算无发运 var haveSaNotHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe); //无结算有发运 @@ -95,7 +90,6 @@ namespace SettleAccount.Job.Services.Report notHaveSaHaveSes.FindAll(t => t.FactoryPartCode == tbRePartsRelationship.LU).ForEach(t => { t.ReplaceFactoryPartCode = tbRePartsRelationship.RepLU; - t.IsReplace = true; }); }); @@ -103,7 +97,6 @@ namespace SettleAccount.Job.Services.Report secondMatchHaveSaHaveSes = (from notHaveSaHaveSe in notHaveSaHaveSes join haveSaNotHaveSe in haveSaNotHaveSes on new { notHaveSaHaveSe.PN, notHaveSaHaveSe.ReplaceFactoryPartCode } equals new { haveSaNotHaveSe.PN, haveSaNotHaveSe.ReplaceFactoryPartCode } - where notHaveSaHaveSe.IsReplace == true select new PubSaSeCompareDiff() { WmsBillNum = notHaveSaHaveSe.WmsBillNum,