diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs
index 5792be1e..65e208ae 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs
@@ -23,14 +23,14 @@ using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ;
///
-/// 客户替换件关系
+/// 厂内物料替换件关系
///
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class TB_RePartsRelationship_SERVICE : SettleAccountApplicationBase
{
///
- /// 客户替换件关系仓储
+ /// 厂内物料替换件关系仓储
///
private readonly INormalEfCoreRepository _repository;
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
index 37704e7f..7b658514 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
@@ -1139,7 +1139,7 @@ namespace Win.Sfs.SettleAccount
.ForMember(x => x.WmsBillNum, y => y.MapFrom(d => d.BillNum))
.ForMember(x => x.LU, y => y.MapFrom(d => d.CustPartCode))
.ForMember(x => x.FactoryPartCode, y => y.MapFrom(d => d.RealPartCode))
- .ForMember(x => x.PN, y => y.MapFrom(d => d.OrderNum))
+ .ForMember(x => x.PN, y => y.MapFrom(d => d.VinCode))
.ForMember(x => x.Qty, y => y.MapFrom(d => d.Qty));
CreateMap()
.ForMember(x => x.SeqNumber, y => y.MapFrom(d => d.JISNum))
@@ -1150,16 +1150,8 @@ namespace Win.Sfs.SettleAccount
.ForMember(x => x.WmsBillNum, y => y.MapFrom(d => d.BillNum))
.ForMember(x => x.LU, y => y.MapFrom(d => d.CustPartCode))
.ForMember(x => x.FactoryPartCode, y => y.MapFrom(d => d.RealPartCode))
- .ForMember(x => x.PN, y => y.MapFrom(d => d.OrderNum))
+ .ForMember(x => x.PN, y => y.MapFrom(d => d.VinCode))
.ForMember(x => x.Qty, y => y.MapFrom(d => d.Qty));
- CreateMap()
- .ForMember(x => x.BeginDate, y => y.MapFrom(d => d.BillTime))
- .ForMember(x => x.ShippingDate, y => y.MapFrom(d => d.BillTime))
- .ForMember(x => x.WmsBillNum, y => y.MapFrom(d => d.BillNum))
- .ForMember(x => x.LU, y => y.MapFrom(d => d.CustPartCode))
- .ForMember(x => x.FactoryPartCode, y => y.MapFrom(d => d.RealPartCode))
- .ForMember(x => x.PN, y => y.MapFrom(d => d.OrderNum))
- .ForMember(x => x.Qty, y => y.MapFrom(d => d.Qty));
CreateMap()
.ForMember(x => x.SeqNumber, y => y.MapFrom(d => d.Seq))
@@ -1170,7 +1162,7 @@ namespace Win.Sfs.SettleAccount
.ForMember(x => x.WmsBillNum, y => y.MapFrom(d => d.BillNum))
.ForMember(x => x.LU, y => y.MapFrom(d => d.CustPartCode))
.ForMember(x => x.FactoryPartCode, y => y.MapFrom(d => d.RealPartCode))
- .ForMember(x => x.PN, y => y.MapFrom(d => d.JISNum))
+ .ForMember(x => x.PN, y => y.MapFrom(d => d.VinCode))
.ForMember(x => x.Qty, y => y.MapFrom(d => d.Qty));
CreateMap()
.ForMember(x => x.SeqNumber, y => y.MapFrom(d => d.Seq))
@@ -1181,16 +1173,8 @@ namespace Win.Sfs.SettleAccount
.ForMember(x => x.WmsBillNum, y => y.MapFrom(d => d.BillNum))
.ForMember(x => x.LU, y => y.MapFrom(d => d.CustPartCode))
.ForMember(x => x.FactoryPartCode, y => y.MapFrom(d => d.RealPartCode))
- .ForMember(x => x.PN, y => y.MapFrom(d => d.JISNum))
+ .ForMember(x => x.PN, y => y.MapFrom(d => d.VinCode))
.ForMember(x => x.Qty, y => y.MapFrom(d => d.Qty));
- CreateMap()
- .ForMember(x => x.BeginDate, y => y.MapFrom(d => d.AssembleData))
- .ForMember(x => x.ShippingDate, y => y.MapFrom(d => d.BillTime))
- .ForMember(x => x.WmsBillNum, y => y.MapFrom(d => d.BillNum))
- .ForMember(x => x.LU, y => y.MapFrom(d => d.CustPartCode))
- .ForMember(x => x.FactoryPartCode, y => y.MapFrom(d => d.RealPartCode))
- .ForMember(x => x.PN, y => y.MapFrom(d => d.JISNum))
- .ForMember(x => x.Qty, y => y.MapFrom(d => d.Qty));
CreateMap()
.ForMember(x => x.BeginDate, y => y.MapFrom(d => d.AssembleData))
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs
index 51cede28..c19e82a1 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs
@@ -94,7 +94,7 @@ namespace SettleAccount.Bases
[Display(Name = "关联结算单号")]
public virtual string SettleBillNum { get; set; } = null!;
-
+
///
/// 可结算单状态
///
@@ -170,7 +170,7 @@ namespace SettleAccount.Bases
/// 结算日期
///
public DateTime SettleDate { set; get; }
-
+
public string InvGroupNum { set; get; }
///
/// 结算分组号
@@ -195,7 +195,7 @@ namespace SettleAccount.Bases
///
/// 结算日期
///
- public DateTime SettleDate { set; get;}
+ public DateTime SettleDate { set; get; }
///
/// 结算分组号
///
@@ -220,7 +220,7 @@ namespace SettleAccount.Bases
}
- public class RE_BASE :FullAuditedAggregateRoot, IRE_BASE
+ public class RE_BASE : FullAuditedAggregateRoot, IRE_BASE
{
public RE_BASE()
{
@@ -240,18 +240,18 @@ namespace SettleAccount.Bases
///
/// 零件號
///
- public string LU { get; set ; }
+ public string LU { get; set; }
///
/// 發貨單號、
///
- public string PN { get; set ; }
+ public string PN { get; set; }
///
///
///
- public string KeyCode { get; set ; }
+ public string KeyCode { get; set; }
+
+
-
-
}
@@ -260,18 +260,18 @@ namespace SettleAccount.Bases
public interface ISE_BASE : ISBASE
{
- ///
- /// 期间
- ///
- public int Version { set; get; }
- ///
- /// 发货时间
- ///
- public DateTime ShippingDate { set; get; }
- ///
- /// 发运单号
- ///
- public string WmsBillNum { set; get; }
+ ///
+ /// 期间
+ ///
+ public int Version { set; get; }
+ ///
+ /// 发货时间
+ ///
+ public DateTime ShippingDate { set; get; }
+ ///
+ /// 发运单号
+ ///
+ public string WmsBillNum { set; get; }
}
public interface IPD_BASE : ISBASE
@@ -300,7 +300,7 @@ namespace SettleAccount.Bases
/// 結算分組號
///
public string GroupNum { set; get; }
-
+
}
///
/// 基类检查设置
@@ -318,9 +318,9 @@ namespace SettleAccount.Bases
///
/// 是否检查BOM
///
- public bool IsBom { set; get; }
+ public bool IsBom { set; get; }
- public bool IsPriceList { set; get; }
+ public bool IsPriceList { set; get; }
public BASE_CONF(bool isRelationShip, bool isMaterial, bool isBom)
@@ -335,12 +335,12 @@ namespace SettleAccount.Bases
}
}
-
+
public class SA_BASE : AuditedAggregateRoot, ISA_BASE
{
-
+
public SA_BASE() { }
public SA_BASE(Guid id) : base(id) { }
@@ -364,29 +364,34 @@ namespace SettleAccount.Bases
///
/// 客户物料号
///
- public virtual string LU { get ; set ; }
+ public virtual string LU { get; set; }
+ ///
+ /// 客户零件号(无空格)
+ ///
+ [MaxLength(100)]
+ public string CustomerPartCodeNoSpace { get; set; }
///
/// 生產號
///
- public virtual string PN { get; set ; }
+ public virtual string PN { get; set; }
///
/// 組合鍵值(LU+PN)
///
- public virtual string KeyCode { get ; set ; }
+ public virtual string KeyCode { get; set; }
///
/// 數量
///
- public virtual decimal Qty { get ; set ; }
+ public virtual decimal Qty { get; set; }
///
/// 結算分組號
///
- public virtual string GroupNum { get ; set ; }
+ public virtual string GroupNum { get; set; }
///
/// 厂内物料号
///
public virtual string PartCode { get; set; }
-
+
@@ -403,7 +408,7 @@ namespace SettleAccount.Bases
public SA_CAN_BASE(Guid id) : base(id) { Id = id; }
-
+
///
@@ -453,7 +458,7 @@ namespace SettleAccount.Bases
public string InvbillNum { get; set; }
- public string ErpLoc { get; set; }=string.Empty;
+ public string ErpLoc { get; set; } = string.Empty;
public string PartCode { get; set; }
public string RealPartCode { get; set; }
@@ -569,6 +574,11 @@ namespace SettleAccount.Bases
///
public string LU { get; set; }
///
+ /// 客户零件号(无空格)
+ ///
+ [MaxLength(100)]
+ public string CustomerPartCodeNoSpace { get; set; }
+ ///
/// 厂内零件号
///
public string FactoryPartCode { get; set; }
@@ -622,11 +632,11 @@ namespace SettleAccount.Bases
///
/// LU(零件号)
///
- public string LU { get ; set; }
+ public string LU { get; set; }
///
/// 生产号、发货单号、交付单号等
///
- public string PN { get ; set; }
+ public string PN { get; set; }
///
/// 替换LU
///
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSaSeEdiCompareExportService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSaSeEdiCompareExportService.cs
index d8fa343f..7de4df7a 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSaSeEdiCompareExportService.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSaSeEdiCompareExportService.cs
@@ -130,17 +130,38 @@ namespace SettleAccount.Job.Services.Report
ToLoc = groupItem.Max(t => t.ToLoc),
ErpToLoc = groupItem.Max(t => t.ErpToLoc)
};
- var saSeCompareLeft = (from sa in saGroup
- join se in seGroup
- on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
+ var saSeCompareLeft = from sa in saGroup
+ join se in seGroup
+ on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
+ into temp
+ from se in temp.DefaultIfEmpty()
+ select new SaSeEdiCompareDiff()
+ {
+ WmsBillNum = se.WmsBillNum,
+ ShippingDate = se.ShippingDate,
+ CustomerOfflineTime = sa.SettleDate,
+ PN = sa.PN,
+ SAQty = sa.Qty,
+ SEQty = se.Qty,
+ FixPrice = sa.Price,
+ ToLocCode = se.ToLoc,
+ ToErpLocCode = se.ErpToLoc,
+ SeCustomerPartCode = se.LU,
+ SeFactoryPartCode = se.FactoryPartCode,
+ SaCustomerPartCode = sa.LU,
+ SaFactoryPartCode = sa.PartCode
+ };
+ var saSeCompareRight = from se in seGroup
+ join sa in saGroup
+ on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
into temp
- from se in temp.DefaultIfEmpty()
+ from sa in temp.DefaultIfEmpty()
select new SaSeEdiCompareDiff()
{
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
- PN = sa.PN,
+ PN = se.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
FixPrice = sa.Price,
@@ -150,29 +171,8 @@ namespace SettleAccount.Job.Services.Report
SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode
- });
- var saSeCompareRight = (from se in seGroup
- join sa in saGroup
- on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
- into temp
- from sa in temp.DefaultIfEmpty()
- select new SaSeEdiCompareDiff()
- {
- WmsBillNum = se.WmsBillNum,
- ShippingDate = se.ShippingDate,
- CustomerOfflineTime = sa.SettleDate,
- PN = se.PN,
- SAQty = sa.Qty,
- SEQty = se.Qty,
- FixPrice = sa.Price,
- ToLocCode = se.ToLoc,
- ToErpLocCode = se.ErpToLoc,
- SeCustomerPartCode = se.LU,
- SeFactoryPartCode = se.FactoryPartCode,
- SaCustomerPartCode = sa.LU,
- SaFactoryPartCode = sa.PartCode
- });
- var saSeCompareFullJoin = saSeCompareLeft.Concat(saSeCompareRight).ToList();
+ };
+ var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList();
return saSeCompareFullJoin;
}
#endregion
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSaSeEdiCompareExportService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSaSeEdiCompareExportService.cs
index 50fde116..858955dc 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSaSeEdiCompareExportService.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSaSeEdiCompareExportService.cs
@@ -129,17 +129,38 @@ namespace SettleAccount.Job.Services.Report
ToLoc = groupItem.Max(t => t.ToLoc),
ErpToLoc = groupItem.Max(t => t.ErpToLoc)
};
- var saSeCompareLeft = (from sa in saGroup
- join se in seGroup
- on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
+ var saSeCompareLeft = from sa in saGroup
+ join se in seGroup
+ on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
+ into temp
+ from se in temp.DefaultIfEmpty()
+ select new SaSeEdiCompareDiff()
+ {
+ WmsBillNum = se.WmsBillNum,
+ ShippingDate = se.ShippingDate,
+ CustomerOfflineTime = sa.SettleDate,
+ PN = sa.PN,
+ SAQty = sa.Qty,
+ SEQty = se.Qty,
+ FixPrice = sa.Price,
+ ToLocCode = se.ToLoc,
+ ToErpLocCode = se.ErpToLoc,
+ SeCustomerPartCode = se.LU,
+ SeFactoryPartCode = se.FactoryPartCode,
+ SaCustomerPartCode = sa.LU,
+ SaFactoryPartCode = sa.PartCode
+ };
+ var saSeCompareRight = from se in seGroup
+ join sa in saGroup
+ on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
into temp
- from se in temp.DefaultIfEmpty()
+ from sa in temp.DefaultIfEmpty()
select new SaSeEdiCompareDiff()
{
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
- PN = sa.PN,
+ PN = se.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
FixPrice = sa.Price,
@@ -149,29 +170,8 @@ namespace SettleAccount.Job.Services.Report
SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode
- });
- var saSeCompareRight = (from se in seGroup
- join sa in saGroup
- on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
- into temp
- from sa in temp.DefaultIfEmpty()
- select new SaSeEdiCompareDiff()
- {
- WmsBillNum = se.WmsBillNum,
- ShippingDate = se.ShippingDate,
- CustomerOfflineTime = sa.SettleDate,
- PN = se.PN,
- SAQty = sa.Qty,
- SEQty = se.Qty,
- FixPrice = sa.Price,
- ToLocCode = se.ToLoc,
- ToErpLocCode = se.ErpToLoc,
- SeCustomerPartCode = se.LU,
- SeFactoryPartCode = se.FactoryPartCode,
- SaCustomerPartCode = sa.LU,
- SaFactoryPartCode = sa.PartCode
- });
- var saSeCompareFullJoin = saSeCompareLeft.Concat(saSeCompareRight).ToList();
+ };
+ var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList();
return saSeCompareFullJoin;
}
#endregion
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 e6576c67..c6cfb081 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
@@ -15,6 +15,7 @@ using Volo.Abp.DependencyInjection;
using Volo.Abp.ObjectMapping;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount;
+using Win.Sfs.SettleAccount.Entities.BQ;
using Win.Sfs.SettleAccount.Reports;
namespace SettleAccount.Job.Services.Report
@@ -48,7 +49,7 @@ namespace SettleAccount.Job.Services.Report
IHubContext hubContext,
IBlobContainer fileContainer,
IObjectMapper objectMapper,
- SettleAccountDbContext settleAccountDbContext) : base(hubContext)
+ SettleAccountDbContext settleAccountDbContext) : base(hubContext, settleAccountDbContext)
{
_fileContainer = fileContainer;
_objectMapper = objectMapper;
@@ -75,6 +76,21 @@ namespace SettleAccount.Job.Services.Report
HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs);
+ #region 二次对比
+ //二次匹配上的记录
+ var secondMatchHaveSaHaveSes = HandleSecondCompare(pubSaSeCompareDiffs, businessType);
+ if (secondMatchHaveSaHaveSes.Any())
+ {
+ //二次匹配 匹配上的厂内零件号、PN
+ var secondMatchFPartCodePNs = secondMatchHaveSaHaveSes.Select(t => new { t.ReplaceFactoryPartCode, t.PN });
+ pubSaSeCompareDiffs.RemoveAll(t => secondMatchFPartCodePNs.Contains(new { t.ReplaceFactoryPartCode, t.PN }));
+ pubSaSeCompareDiffs.AddRange(secondMatchHaveSaHaveSes);
+ //二次对比比对上的数据入库
+ var pubSeCDetailEntitys = _objectMapper.Map, List>(secondMatchHaveSaHaveSes);
+ _settleAccountDbContext.Set().AddRange(pubSeCDetailEntitys);
+ }
+ #endregion
+
if (string.IsNullOrEmpty(lu) == false)
{
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.CustomerPartCode == lu);
@@ -130,17 +146,38 @@ namespace SettleAccount.Job.Services.Report
ToLoc = groupItem.Max(t => t.ToLoc),
ErpToLoc = groupItem.Max(t => t.ErpToLoc)
};
- var saSeCompareLeft = (from sa in saGroup
- join se in seGroup
- on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
+ var saSeCompareLeft = from sa in saGroup
+ join se in seGroup
+ on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
+ into temp
+ from se in temp.DefaultIfEmpty()
+ select new PubSaSeCompareDiff()
+ {
+ WmsBillNum = se.WmsBillNum,
+ ShippingDate = se.ShippingDate,
+ CustomerOfflineTime = sa.SettleDate,
+ PN = sa.PN,
+ SAQty = sa.Qty,
+ SEQty = se.Qty,
+ FixPrice = sa.Price,
+ ToLocCode = se.ToLoc,
+ ToErpLocCode = se.ErpToLoc,
+ SeCustomerPartCode = se.LU,
+ SeFactoryPartCode = se.FactoryPartCode,
+ SaCustomerPartCode = sa.LU,
+ SaFactoryPartCode = sa.PartCode
+ };
+ var saSeCompareRight = from se in seGroup
+ join sa in saGroup
+ on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
into temp
- from se in temp.DefaultIfEmpty()
+ from sa in temp.DefaultIfEmpty()
select new PubSaSeCompareDiff()
{
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
- PN = sa.PN,
+ PN = se.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
FixPrice = sa.Price,
@@ -150,29 +187,8 @@ namespace SettleAccount.Job.Services.Report
SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode
- });
- var saSeCompareRight = (from se in seGroup
- join sa in saGroup
- on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
- into temp
- from sa in temp.DefaultIfEmpty()
- select new PubSaSeCompareDiff()
- {
- WmsBillNum = se.WmsBillNum,
- ShippingDate = se.ShippingDate,
- CustomerOfflineTime = sa.SettleDate,
- PN = se.PN,
- SAQty = sa.Qty,
- SEQty = se.Qty,
- FixPrice = sa.Price,
- ToLocCode = se.ToLoc,
- ToErpLocCode = se.ErpToLoc,
- SeCustomerPartCode = se.LU,
- SeFactoryPartCode = se.FactoryPartCode,
- SaCustomerPartCode = sa.LU,
- SaFactoryPartCode = sa.PartCode
- });
- var saSeCompareFullJoin = saSeCompareLeft.Concat(saSeCompareRight).ToList();
+ };
+ var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList();
return saSeCompareFullJoin;
}
#endregion
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 37e31f9c..52f12e15 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
@@ -15,6 +15,7 @@ using Volo.Abp.DependencyInjection;
using Volo.Abp.ObjectMapping;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount;
+using Win.Sfs.SettleAccount.Entities.BQ;
using Win.Sfs.SettleAccount.Reports;
namespace SettleAccount.Job.Services.Report
@@ -48,7 +49,7 @@ namespace SettleAccount.Job.Services.Report
IHubContext hubContext,
IBlobContainer fileContainer,
IObjectMapper objectMapper,
- SettleAccountDbContext settleAccountDbContext) : base(hubContext)
+ SettleAccountDbContext settleAccountDbContext) : base(hubContext, settleAccountDbContext)
{
_fileContainer = fileContainer;
_objectMapper = objectMapper;
@@ -75,6 +76,21 @@ namespace SettleAccount.Job.Services.Report
HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs);
+ #region 二次对比
+ //二次匹配上的记录
+ var secondMatchHaveSaHaveSes = HandleSecondCompare(pubSaSeCompareDiffs, businessType);
+ if (secondMatchHaveSaHaveSes.Any())
+ {
+ //二次匹配 匹配上的厂内零件号、PN
+ var secondMatchFPartCodePNs = secondMatchHaveSaHaveSes.Select(t => new { t.ReplaceFactoryPartCode, t.PN });
+ pubSaSeCompareDiffs.RemoveAll(t => secondMatchFPartCodePNs.Contains(new { t.ReplaceFactoryPartCode, t.PN }));
+ pubSaSeCompareDiffs.AddRange(secondMatchHaveSaHaveSes);
+ //二次对比比对上的数据入库
+ var pubSeCDetailEntitys = _objectMapper.Map, List>(secondMatchHaveSaHaveSes);
+ _settleAccountDbContext.Set().AddRange(pubSeCDetailEntitys);
+ }
+ #endregion
+
if (string.IsNullOrEmpty(lu) == false)
{
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.CustomerPartCode == lu);
@@ -130,17 +146,38 @@ namespace SettleAccount.Job.Services.Report
ToLoc = groupItem.Max(t => t.ToLoc),
ErpToLoc = groupItem.Max(t => t.ErpToLoc)
};
- var saSeCompareLeft = (from sa in saGroup
- join se in seGroup
- on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
+ var saSeCompareLeft = from sa in saGroup
+ join se in seGroup
+ on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
+ into temp
+ from se in temp.DefaultIfEmpty()
+ select new PubSaSeCompareDiff()
+ {
+ WmsBillNum = se.WmsBillNum,
+ ShippingDate = se.ShippingDate,
+ CustomerOfflineTime = sa.SettleDate,
+ PN = sa.PN,
+ SAQty = sa.Qty,
+ SEQty = se.Qty,
+ FixPrice = sa.Price,
+ ToLocCode = se.ToLoc,
+ ToErpLocCode = se.ErpToLoc,
+ SeCustomerPartCode = se.LU,
+ SeFactoryPartCode = se.FactoryPartCode,
+ SaCustomerPartCode = sa.LU,
+ SaFactoryPartCode = sa.PartCode
+ };
+ var saSeCompareRight = from se in seGroup
+ join sa in saGroup
+ on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
into temp
- from se in temp.DefaultIfEmpty()
+ from sa in temp.DefaultIfEmpty()
select new PubSaSeCompareDiff()
{
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
- PN = sa.PN,
+ PN = se.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
FixPrice = sa.Price,
@@ -150,29 +187,8 @@ namespace SettleAccount.Job.Services.Report
SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode
- });
- var saSeCompareRight = (from se in seGroup
- join sa in saGroup
- on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
- into temp
- from sa in temp.DefaultIfEmpty()
- select new PubSaSeCompareDiff()
- {
- WmsBillNum = se.WmsBillNum,
- ShippingDate = se.ShippingDate,
- CustomerOfflineTime = sa.SettleDate,
- PN = se.PN,
- SAQty = sa.Qty,
- SEQty = se.Qty,
- FixPrice = sa.Price,
- ToLocCode = se.ToLoc,
- ToErpLocCode = se.ErpToLoc,
- SeCustomerPartCode = se.LU,
- SeFactoryPartCode = se.FactoryPartCode,
- SaCustomerPartCode = sa.LU,
- SaFactoryPartCode = sa.PartCode
- });
- var saSeCompareFullJoin = saSeCompareLeft.Concat(saSeCompareRight).ToList();
+ };
+ var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList();
return saSeCompareFullJoin;
}
#endregion
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 abb9efdc..b726c63c 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
@@ -24,14 +24,10 @@ using Win.Sfs.Shared.RepositoryBase;
namespace SettleAccount.Job.Services.Report
{
///
- /// Pub结算发运对比导出服务
+ /// 结算、发运对比导出服务
///
public class PubSaSeCompareExportService : SaSeCompareExportBaseService, ITransientDependency, IExportJob
{
- ///
- /// HubContext
- ///
- private readonly IHubContext _hubContext;
///
/// DbContext
///
@@ -40,22 +36,18 @@ namespace SettleAccount.Job.Services.Report
/// 替换件关系仓储
///
private readonly INormalEfCoreRepository _tbRePartsRelationshipRepository;
-
///
/// PUB二次比对仓储
///
private readonly INormalEfCoreRepository _pubSeCDetailRepository;
-
///
/// Pub结算发运对比Dapper
///
private readonly PubSaSeCompareDapperRepository _pubSaSeCompareDapperRepository;
-
///
/// 文件容器
///
private readonly IBlobContainer _fileContainer;
-
///
/// AutoMapper
///
@@ -71,9 +63,8 @@ namespace SettleAccount.Job.Services.Report
INormalEfCoreRepository pubSeCDetailRepository,
PubSaSeCompareDapperRepository pubSaSeCompareDapperRepository,
IBlobContainer fileContainer,
- IObjectMapper objectMapper) : base(hubContext)
+ IObjectMapper objectMapper) : base(hubContext, settleAccountDbContext)
{
- _hubContext = hubContext;
_settleAccountDbContext = settleAccountDbContext;
_tbRePartsRelationshipRepository = tbRePartsRelationshipRepository;
_pubSeCDetailRepository = pubSeCDetailRepository;
@@ -114,59 +105,9 @@ namespace SettleAccount.Job.Services.Report
HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs);
- //有结算有发运
- var haveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe);
- //有结算无发运
- var haveSaNotHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe);
- //无结算有发运
- var notHaveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe);
- //二次匹配上的记录
- var secondMatchHaveSaHaveSes = new List();
-
#region 二次对比
- //二次对比(替换无结算有发运数据的厂内零件号)
- var repFactoryPartCodes = notHaveSaHaveSes.Select(t => t.FactoryPartCode).Distinct().ToList();
-
- var tbRePartsRelationships = _settleAccountDbContext.Set().Where(t => repFactoryPartCodes.Contains(t.LU) && t.BusinessType == businessType).ToList();
- //var tbRePartsRelationshipsOld = _tbRePartsRelationshipRepository.GetListAsync(t => repFactoryPartCodes.Contains(t.LU) && t.BusinessType == businessType).Result;
-
- tbRePartsRelationships.ForEach(tbRePartsRelationship =>
- {
- notHaveSaHaveSes.FindAll(t => t.FactoryPartCode == tbRePartsRelationship.LU).ForEach(t =>
- {
- t.ReplaceFactoryPartCode = tbRePartsRelationship.RepLU;
- t.IsReplace = true;
- });
- });
-
- //获取二次比对上的数据
- 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,
- ShippingDate = notHaveSaHaveSe.ShippingDate,
- SeqNumber = notHaveSaHaveSe.SeqNumber,
- PJISSeqNumber = notHaveSaHaveSe.PJISSeqNumber,
- CustomerOfflineTime = haveSaNotHaveSe.CustomerOfflineTime,
- SAQty = haveSaNotHaveSe.SAQty,
- SEQty = notHaveSaHaveSe.SEQty,
- FixPrice = haveSaNotHaveSe.FixPrice,
- PN = haveSaNotHaveSe.PN,
- ToLocCode = notHaveSaHaveSe.ToLocCode,
- ToErpLocCode = notHaveSaHaveSe.ToErpLocCode,
- Category = EnumPubSaSeCompareCategory.HaveSaHaveSe,
- SeCustomerPartCode = notHaveSaHaveSe.SeCustomerPartCode,
- SeFactoryPartCode = notHaveSaHaveSe.SeFactoryPartCode,
- SaCustomerPartCode = haveSaNotHaveSe.SaCustomerPartCode,
- SaFactoryPartCode = haveSaNotHaveSe.SaFactoryPartCode,
- CustomerPartCode = notHaveSaHaveSe.CustomerPartCode,
- PartCodeDesc = notHaveSaHaveSe.PartCodeDesc,
- FactoryPartCode = notHaveSaHaveSe.FactoryPartCode,
- ReplaceFactoryPartCode = notHaveSaHaveSe.ReplaceFactoryPartCode
- }).ToList();
+ //二次匹配上的记录
+ var secondMatchHaveSaHaveSes = HandleSecondCompare(pubSaSeCompareDiffs, businessType);
if (secondMatchHaveSaHaveSes.Any())
{
//二次匹配 匹配上的厂内零件号、PN
@@ -273,10 +214,15 @@ namespace SettleAccount.Job.Services.Report
#region 私有方法
///
- /// 获取结算与发运比对数据
+ /// 获取比对数据
///
public List GetSaSeCompareData(EnumBusinessType businessType, int version, DateTime seStartDateTime, DateTime seEndDateTime)
{
+ //印度件LU对比
+ if (businessType == EnumBusinessType.YinDuJian)
+ {
+ return GetSaSeCompareDataYinDu(version, seStartDateTime, seEndDateTime);
+ }
//结算
var saGroup = from sa in _settleAccountDbContext.Set()
where sa.BusinessType == businessType && sa.Version == version
@@ -305,17 +251,38 @@ namespace SettleAccount.Job.Services.Report
ToLocCode = groupItem.Max(t => t.ToLocCode),
ToErpLocCode = groupItem.Max(t => t.ToErpLocCode)
};
- var saSeCompareLeft = (from sa in saGroup
- join se in seGroup
- on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
+ var saSeCompareLeft = from sa in saGroup
+ join se in seGroup
+ on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
+ into temp
+ from se in temp.DefaultIfEmpty()
+ select new PubSaSeCompareDiff()
+ {
+ WmsBillNum = se.WmsBillNum,
+ ShippingDate = se.ShippingDate,
+ CustomerOfflineTime = sa.SettleDate,
+ PN = sa.PN,
+ SAQty = sa.Qty,
+ SEQty = se.Qty,
+ FixPrice = sa.Price,
+ ToLocCode = se.ToLocCode,
+ ToErpLocCode = se.ToErpLocCode,
+ SeCustomerPartCode = se.LU,
+ SeFactoryPartCode = se.FactoryPartCode,
+ SaCustomerPartCode = sa.LU,
+ SaFactoryPartCode = sa.PartCode
+ };
+ var saSeCompareRight = from se in seGroup
+ join sa in saGroup
+ on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
into temp
- from se in temp.DefaultIfEmpty()
+ from sa in temp.DefaultIfEmpty()
select new PubSaSeCompareDiff()
{
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
- PN = sa.LU,
+ PN = se.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
FixPrice = sa.Price,
@@ -325,49 +292,33 @@ namespace SettleAccount.Job.Services.Report
SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode
- });
- var saSeCompareRight = (from se in seGroup
- join sa in saGroup
- on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
- into temp
- from sa in temp.DefaultIfEmpty()
- select new PubSaSeCompareDiff()
- {
- WmsBillNum = se.WmsBillNum,
- ShippingDate = se.ShippingDate,
- CustomerOfflineTime = sa.SettleDate,
- PN = se.LU,
- SAQty = sa.Qty,
- SEQty = se.Qty,
- FixPrice = sa.Price,
- ToLocCode = se.ToLocCode,
- ToErpLocCode = se.ToErpLocCode,
- SeCustomerPartCode = se.LU,
- SeFactoryPartCode = se.FactoryPartCode,
- SaCustomerPartCode = sa.LU,
- SaFactoryPartCode = sa.PartCode
- });
- //印度件LU对比
- if (businessType == EnumBusinessType.YinDuJian && (1 + 1) == 3)
- {
- saGroup = from sa in _settleAccountDbContext.Set()
- where sa.BusinessType == businessType && sa.Version == version
+ };
+
+ var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList();
+ return saSeCompareFullJoin;
+ }
+
+ ///
+ /// 获取比对数据
+ ///
+ public List GetSaSeCompareDataYinDu(int version, DateTime seStartDateTime, DateTime seEndDateTime)
+ {
+ var saGroup = from sa in _settleAccountDbContext.Set()
+ where sa.BusinessType == EnumBusinessType.YinDuJian && sa.Version == version
group sa by new { sa.LU } into groupItem
select new
{
- PN = "",
groupItem.Key.LU,
Qty = groupItem.Sum(t => t.Qty),
Price = groupItem.Max(t => t.Price),
SettleDate = groupItem.Max(t => t.SettleDate),
PartCode = groupItem.Max(t => t.PartCode),
};
- seGroup = from se in _settleAccountDbContext.Set()
- where se.BusinessType == businessType && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime
+ 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
select new
{
- PN = "",
groupItem.Key.LU,
Qty = groupItem.Sum(t => t.Qty),
WmsBillNum = groupItem.Max(t => t.WmsBillNum),
@@ -376,9 +327,48 @@ namespace SettleAccount.Job.Services.Report
ToLocCode = groupItem.Max(t => t.ToLocCode),
ToErpLocCode = groupItem.Max(t => t.ToErpLocCode)
};
- }
- var saSeCompareFullJoin = saSeCompareLeft.Concat(saSeCompareRight).ToList();
+ var saSeCompareLeft = from sa in saGroup
+ join se in seGroup
+ on sa.LU equals se.LU
+ into temp
+ from se in temp.DefaultIfEmpty()
+ select new PubSaSeCompareDiff()
+ {
+ WmsBillNum = se.WmsBillNum,
+ ShippingDate = se.ShippingDate,
+ CustomerOfflineTime = sa.SettleDate,
+ SAQty = sa.Qty,
+ SEQty = se.Qty,
+ FixPrice = sa.Price,
+ ToLocCode = se.ToLocCode,
+ ToErpLocCode = se.ToErpLocCode,
+ SeCustomerPartCode = se.LU,
+ SeFactoryPartCode = se.FactoryPartCode,
+ SaCustomerPartCode = sa.LU,
+ SaFactoryPartCode = sa.PartCode
+ };
+ var saSeCompareRight = from se in seGroup
+ join sa in saGroup
+ on se.LU equals sa.LU
+ into temp
+ from sa in temp.DefaultIfEmpty()
+ select new PubSaSeCompareDiff()
+ {
+ WmsBillNum = se.WmsBillNum,
+ ShippingDate = se.ShippingDate,
+ CustomerOfflineTime = sa.SettleDate,
+ SAQty = sa.Qty,
+ SEQty = se.Qty,
+ FixPrice = sa.Price,
+ ToLocCode = se.ToLocCode,
+ ToErpLocCode = se.ToErpLocCode,
+ SeCustomerPartCode = se.LU,
+ SeFactoryPartCode = se.FactoryPartCode,
+ SaCustomerPartCode = sa.LU,
+ SaFactoryPartCode = sa.PartCode
+ };
+ var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList();
return saSeCompareFullJoin;
}
#endregion
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 8e0a4126..29601a0e 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
@@ -2,7 +2,9 @@ using System.Collections.Generic;
using System.Linq;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.SignalR;
+using SettleAccount.Domain.BQ;
using SettleAccount.Job.SignalR;
+using Win.Sfs.SettleAccount;
using Win.Sfs.SettleAccount.Enums;
using Win.Sfs.SettleAccount.Reports;
@@ -17,10 +19,15 @@ namespace SettleAccount.Job.Services.Report
/// HubContext
///
private readonly IHubContext _hubContext;
+ ///
+ /// DbContext
+ ///
+ private readonly SettleAccountDbContext _settleAccountDbContext;
- public SaSeCompareExportBaseService(IHubContext hubContext)
+ public SaSeCompareExportBaseService(IHubContext hubContext, SettleAccountDbContext settleAccountDbContext)
{
_hubContext = hubContext;
+ _settleAccountDbContext = settleAccountDbContext;
}
public virtual void HandlePubSaSeCompareDiffList(List pubSaSeCompareDiffs)
@@ -65,6 +72,64 @@ namespace SettleAccount.Job.Services.Report
});
}
+ ///
+ /// 二次比对
+ ///
+ public virtual List HandleSecondCompare(List pubSaSeCompareDiffs, EnumBusinessType businessType)
+ {
+ //二次匹配上的记录
+ var secondMatchHaveSaHaveSes = new List();
+ //有结算有发运
+ var haveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe);
+ //有结算无发运
+ var haveSaNotHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe);
+ //无结算有发运
+ var notHaveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe);
+
+ //二次对比(替换无结算有发运数据的厂内零件号)
+ var repFactoryPartCodes = notHaveSaHaveSes.Select(t => t.FactoryPartCode).Distinct().ToList();
+ var tbRePartsRelationships = _settleAccountDbContext.Set().Where(t => repFactoryPartCodes.Contains(t.LU) && t.BusinessType == businessType).ToList();
+
+ tbRePartsRelationships.ForEach(tbRePartsRelationship =>
+ {
+ notHaveSaHaveSes.FindAll(t => t.FactoryPartCode == tbRePartsRelationship.LU).ForEach(t =>
+ {
+ t.ReplaceFactoryPartCode = tbRePartsRelationship.RepLU;
+ t.IsReplace = true;
+ });
+ });
+
+ //获取二次比对上的数据
+ 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,
+ ShippingDate = notHaveSaHaveSe.ShippingDate,
+ SeqNumber = notHaveSaHaveSe.SeqNumber,
+ PJISSeqNumber = notHaveSaHaveSe.PJISSeqNumber,
+ CustomerOfflineTime = haveSaNotHaveSe.CustomerOfflineTime,
+ SAQty = haveSaNotHaveSe.SAQty,
+ SEQty = notHaveSaHaveSe.SEQty,
+ FixPrice = haveSaNotHaveSe.FixPrice,
+ PN = haveSaNotHaveSe.PN,
+ ToLocCode = notHaveSaHaveSe.ToLocCode,
+ ToErpLocCode = notHaveSaHaveSe.ToErpLocCode,
+ Category = EnumPubSaSeCompareCategory.HaveSaHaveSe,
+ SeCustomerPartCode = notHaveSaHaveSe.SeCustomerPartCode,
+ SeFactoryPartCode = notHaveSaHaveSe.SeFactoryPartCode,
+ SaCustomerPartCode = haveSaNotHaveSe.SaCustomerPartCode,
+ SaFactoryPartCode = haveSaNotHaveSe.SaFactoryPartCode,
+ CustomerPartCode = notHaveSaHaveSe.CustomerPartCode,
+ PartCodeDesc = notHaveSaHaveSe.PartCodeDesc,
+ FactoryPartCode = notHaveSaHaveSe.FactoryPartCode,
+ ReplaceFactoryPartCode = notHaveSaHaveSe.ReplaceFactoryPartCode
+ }).ToList();
+ return secondMatchHaveSaHaveSes;
+ }
+
///
/// 创建导出文件结构
///