mahao 1 year ago
parent
commit
e75a41e756
  1. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs
  2. 24
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
  3. 36
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs
  4. 10
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSaSeEdiCompareExportService.cs
  5. 10
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSaSeEdiCompareExportService.cs
  6. 28
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanBBACSaSeCompareExportService.cs
  7. 28
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanHBPOSaSeCompareExportService.cs
  8. 150
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs
  9. 67
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs

4
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; namespace Win.Sfs.SettleAccount.Entities.BQ;
/// <summary> /// <summary>
/// 客户替换件关系 /// 厂内物料替换件关系
/// </summary> /// </summary>
[AllowAnonymous] [AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")] [Route("api/settleaccount/[controller]/[action]")]
public class TB_RePartsRelationship_SERVICE : SettleAccountApplicationBase<TB_RePartsRelationship> public class TB_RePartsRelationship_SERVICE : SettleAccountApplicationBase<TB_RePartsRelationship>
{ {
/// <summary> /// <summary>
/// 客户替换件关系仓储 /// 厂内物料替换件关系仓储
/// </summary> /// </summary>
private readonly INormalEfCoreRepository<TB_RePartsRelationship, Guid> _repository; private readonly INormalEfCoreRepository<TB_RePartsRelationship, Guid> _repository;

24
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.WmsBillNum, y => y.MapFrom(d => d.BillNum))
.ForMember(x => x.LU, y => y.MapFrom(d => d.CustPartCode)) .ForMember(x => x.LU, y => y.MapFrom(d => d.CustPartCode))
.ForMember(x => x.FactoryPartCode, y => y.MapFrom(d => d.RealPartCode)) .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)); .ForMember(x => x.Qty, y => y.MapFrom(d => d.Qty));
CreateMap<TM_BJBMPT_JIS_RECORD, HBPO_SE_DETAIL>() CreateMap<TM_BJBMPT_JIS_RECORD, HBPO_SE_DETAIL>()
.ForMember(x => x.SeqNumber, y => y.MapFrom(d => d.JISNum)) .ForMember(x => x.SeqNumber, y => y.MapFrom(d => d.JISNum))
@ -1150,15 +1150,7 @@ namespace Win.Sfs.SettleAccount
.ForMember(x => x.WmsBillNum, y => y.MapFrom(d => d.BillNum)) .ForMember(x => x.WmsBillNum, y => y.MapFrom(d => d.BillNum))
.ForMember(x => x.LU, y => y.MapFrom(d => d.CustPartCode)) .ForMember(x => x.LU, y => y.MapFrom(d => d.CustPartCode))
.ForMember(x => x.FactoryPartCode, y => y.MapFrom(d => d.RealPartCode)) .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<TM_BJBMPT_JIS_RECORD, PUB_SE_DETAIL>()
.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)); .ForMember(x => x.Qty, y => y.MapFrom(d => d.Qty));
CreateMap<TM_BJBMPT_JIT_RECORD, BBAC_SE_DETAIL>() CreateMap<TM_BJBMPT_JIT_RECORD, BBAC_SE_DETAIL>()
@ -1170,7 +1162,7 @@ namespace Win.Sfs.SettleAccount
.ForMember(x => x.WmsBillNum, y => y.MapFrom(d => d.BillNum)) .ForMember(x => x.WmsBillNum, y => y.MapFrom(d => d.BillNum))
.ForMember(x => x.LU, y => y.MapFrom(d => d.CustPartCode)) .ForMember(x => x.LU, y => y.MapFrom(d => d.CustPartCode))
.ForMember(x => x.FactoryPartCode, y => y.MapFrom(d => d.RealPartCode)) .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)); .ForMember(x => x.Qty, y => y.MapFrom(d => d.Qty));
CreateMap<TM_BJBMPT_JIT_RECORD, HBPO_SE_DETAIL>() CreateMap<TM_BJBMPT_JIT_RECORD, HBPO_SE_DETAIL>()
.ForMember(x => x.SeqNumber, y => y.MapFrom(d => d.Seq)) .ForMember(x => x.SeqNumber, y => y.MapFrom(d => d.Seq))
@ -1181,15 +1173,7 @@ namespace Win.Sfs.SettleAccount
.ForMember(x => x.WmsBillNum, y => y.MapFrom(d => d.BillNum)) .ForMember(x => x.WmsBillNum, y => y.MapFrom(d => d.BillNum))
.ForMember(x => x.LU, y => y.MapFrom(d => d.CustPartCode)) .ForMember(x => x.LU, y => y.MapFrom(d => d.CustPartCode))
.ForMember(x => x.FactoryPartCode, y => y.MapFrom(d => d.RealPartCode)) .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<TM_BJBMPT_JIT_RECORD, PUB_SE_DETAIL>()
.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)); .ForMember(x => x.Qty, y => y.MapFrom(d => d.Qty));
CreateMap<TM_BJBMPT_OTHER_RECORD, PUB_SE_DETAIL>() CreateMap<TM_BJBMPT_OTHER_RECORD, PUB_SE_DETAIL>()

36
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs

@ -195,7 +195,7 @@ namespace SettleAccount.Bases
/// <summary> /// <summary>
/// 结算日期 /// 结算日期
/// </summary> /// </summary>
public DateTime SettleDate { set; get;} public DateTime SettleDate { set; get; }
/// <summary> /// <summary>
/// 结算分组号 /// 结算分组号
/// </summary> /// </summary>
@ -220,7 +220,7 @@ namespace SettleAccount.Bases
} }
public class RE_BASE :FullAuditedAggregateRoot<Guid>, IRE_BASE public class RE_BASE : FullAuditedAggregateRoot<Guid>, IRE_BASE
{ {
public RE_BASE() public RE_BASE()
{ {
@ -240,15 +240,15 @@ namespace SettleAccount.Bases
/// <summary> /// <summary>
/// 零件號 /// 零件號
/// </summary> /// </summary>
public string LU { get; set ; } public string LU { get; set; }
/// <summary> /// <summary>
/// 發貨單號、 /// 發貨單號、
/// </summary> /// </summary>
public string PN { get; set ; } public string PN { get; set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public string KeyCode { get; set ; } public string KeyCode { get; set; }
@ -364,23 +364,28 @@ namespace SettleAccount.Bases
/// <summary> /// <summary>
/// 客户物料号 /// 客户物料号
/// </summary> /// </summary>
public virtual string LU { get ; set ; } public virtual string LU { get; set; }
/// <summary>
/// 客户零件号(无空格)
/// </summary>
[MaxLength(100)]
public string CustomerPartCodeNoSpace { get; set; }
/// <summary> /// <summary>
/// 生產號 /// 生產號
/// </summary> /// </summary>
public virtual string PN { get; set ; } public virtual string PN { get; set; }
/// <summary> /// <summary>
/// 組合鍵值(LU+PN) /// 組合鍵值(LU+PN)
/// </summary> /// </summary>
public virtual string KeyCode { get ; set ; } public virtual string KeyCode { get; set; }
/// <summary> /// <summary>
/// 數量 /// 數量
/// </summary> /// </summary>
public virtual decimal Qty { get ; set ; } public virtual decimal Qty { get; set; }
/// <summary> /// <summary>
/// 結算分組號 /// 結算分組號
/// </summary> /// </summary>
public virtual string GroupNum { get ; set ; } public virtual string GroupNum { get; set; }
/// <summary> /// <summary>
/// 厂内物料号 /// 厂内物料号
/// </summary> /// </summary>
@ -453,7 +458,7 @@ namespace SettleAccount.Bases
public string InvbillNum { get; set; } 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 PartCode { get; set; }
public string RealPartCode { get; set; } public string RealPartCode { get; set; }
@ -569,6 +574,11 @@ namespace SettleAccount.Bases
/// </summary> /// </summary>
public string LU { get; set; } public string LU { get; set; }
/// <summary> /// <summary>
/// 客户零件号(无空格)
/// </summary>
[MaxLength(100)]
public string CustomerPartCodeNoSpace { get; set; }
/// <summary>
/// 厂内零件号 /// 厂内零件号
/// </summary> /// </summary>
public string FactoryPartCode { get; set; } public string FactoryPartCode { get; set; }
@ -622,11 +632,11 @@ namespace SettleAccount.Bases
/// <summary> /// <summary>
/// LU(零件号) /// LU(零件号)
/// </summary> /// </summary>
public string LU { get ; set; } public string LU { get; set; }
/// <summary> /// <summary>
/// 生产号、发货单号、交付单号等 /// 生产号、发货单号、交付单号等
/// </summary> /// </summary>
public string PN { get ; set; } public string PN { get; set; }
/// <summary> /// <summary>
/// 替换LU /// 替换LU
/// </summary> /// </summary>

10
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSaSeEdiCompareExportService.cs

@ -130,7 +130,7 @@ namespace SettleAccount.Job.Services.Report
ToLoc = groupItem.Max(t => t.ToLoc), ToLoc = groupItem.Max(t => t.ToLoc),
ErpToLoc = groupItem.Max(t => t.ErpToLoc) ErpToLoc = groupItem.Max(t => t.ErpToLoc)
}; };
var saSeCompareLeft = (from sa in saGroup var saSeCompareLeft = from sa in saGroup
join se in seGroup join se in seGroup
on new { sa.PN, sa.LU } equals new { se.PN, se.LU } on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
into temp into temp
@ -150,8 +150,8 @@ namespace SettleAccount.Job.Services.Report
SeFactoryPartCode = se.FactoryPartCode, SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU, SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode SaFactoryPartCode = sa.PartCode
}); };
var saSeCompareRight = (from se in seGroup var saSeCompareRight = from se in seGroup
join sa in saGroup join sa in saGroup
on new { se.PN, se.LU } equals new { sa.PN, sa.LU } on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
into temp into temp
@ -171,8 +171,8 @@ namespace SettleAccount.Job.Services.Report
SeFactoryPartCode = se.FactoryPartCode, SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU, SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode SaFactoryPartCode = sa.PartCode
}); };
var saSeCompareFullJoin = saSeCompareLeft.Concat(saSeCompareRight).ToList(); var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList();
return saSeCompareFullJoin; return saSeCompareFullJoin;
} }
#endregion #endregion

10
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSaSeEdiCompareExportService.cs

@ -129,7 +129,7 @@ namespace SettleAccount.Job.Services.Report
ToLoc = groupItem.Max(t => t.ToLoc), ToLoc = groupItem.Max(t => t.ToLoc),
ErpToLoc = groupItem.Max(t => t.ErpToLoc) ErpToLoc = groupItem.Max(t => t.ErpToLoc)
}; };
var saSeCompareLeft = (from sa in saGroup var saSeCompareLeft = from sa in saGroup
join se in seGroup join se in seGroup
on new { sa.PN, sa.LU } equals new { se.PN, se.LU } on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
into temp into temp
@ -149,8 +149,8 @@ namespace SettleAccount.Job.Services.Report
SeFactoryPartCode = se.FactoryPartCode, SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU, SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode SaFactoryPartCode = sa.PartCode
}); };
var saSeCompareRight = (from se in seGroup var saSeCompareRight = from se in seGroup
join sa in saGroup join sa in saGroup
on new { se.PN, se.LU } equals new { sa.PN, sa.LU } on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
into temp into temp
@ -170,8 +170,8 @@ namespace SettleAccount.Job.Services.Report
SeFactoryPartCode = se.FactoryPartCode, SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU, SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode SaFactoryPartCode = sa.PartCode
}); };
var saSeCompareFullJoin = saSeCompareLeft.Concat(saSeCompareRight).ToList(); var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList();
return saSeCompareFullJoin; return saSeCompareFullJoin;
} }
#endregion #endregion

28
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanBBACSaSeCompareExportService.cs

@ -15,6 +15,7 @@ using Volo.Abp.DependencyInjection;
using Volo.Abp.ObjectMapping; using Volo.Abp.ObjectMapping;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount; using Win.Sfs.SettleAccount;
using Win.Sfs.SettleAccount.Entities.BQ;
using Win.Sfs.SettleAccount.Reports; using Win.Sfs.SettleAccount.Reports;
namespace SettleAccount.Job.Services.Report namespace SettleAccount.Job.Services.Report
@ -48,7 +49,7 @@ namespace SettleAccount.Job.Services.Report
IHubContext<PageHub> hubContext, IHubContext<PageHub> hubContext,
IBlobContainer<MyFileContainer> fileContainer, IBlobContainer<MyFileContainer> fileContainer,
IObjectMapper objectMapper, IObjectMapper objectMapper,
SettleAccountDbContext settleAccountDbContext) : base(hubContext) SettleAccountDbContext settleAccountDbContext) : base(hubContext, settleAccountDbContext)
{ {
_fileContainer = fileContainer; _fileContainer = fileContainer;
_objectMapper = objectMapper; _objectMapper = objectMapper;
@ -75,6 +76,21 @@ namespace SettleAccount.Job.Services.Report
HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs); HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs);
#region 二次对比
//二次匹配上的记录
var secondMatchHaveSaHaveSes = HandleSecondCompare(pubSaSeCompareDiffs, businessType);
if (secondMatchHaveSaHaveSes.Any())
{
//二次匹配 匹配上的厂内零件号、PN
var secondMatchFPartCodePNs = secondMatchHaveSaHaveSes.Select(t => new { t.ReplaceFactoryPartCode, t.PN });
pubSaSeCompareDiffs.RemoveAll<PubSaSeCompareDiff>(t => secondMatchFPartCodePNs.Contains(new { t.ReplaceFactoryPartCode, t.PN }));
pubSaSeCompareDiffs.AddRange(secondMatchHaveSaHaveSes);
//二次对比比对上的数据入库
var pubSeCDetailEntitys = _objectMapper.Map<List<PubSaSeCompareDiff>, List<PUB_SEC_DETAIL>>(secondMatchHaveSaHaveSes);
_settleAccountDbContext.Set<PUB_SEC_DETAIL>().AddRange(pubSeCDetailEntitys);
}
#endregion
if (string.IsNullOrEmpty(lu) == false) if (string.IsNullOrEmpty(lu) == false)
{ {
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.CustomerPartCode == lu); pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.CustomerPartCode == lu);
@ -130,7 +146,7 @@ namespace SettleAccount.Job.Services.Report
ToLoc = groupItem.Max(t => t.ToLoc), ToLoc = groupItem.Max(t => t.ToLoc),
ErpToLoc = groupItem.Max(t => t.ErpToLoc) ErpToLoc = groupItem.Max(t => t.ErpToLoc)
}; };
var saSeCompareLeft = (from sa in saGroup var saSeCompareLeft = from sa in saGroup
join se in seGroup join se in seGroup
on new { sa.PN, sa.LU } equals new { se.PN, se.LU } on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
into temp into temp
@ -150,8 +166,8 @@ namespace SettleAccount.Job.Services.Report
SeFactoryPartCode = se.FactoryPartCode, SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU, SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode SaFactoryPartCode = sa.PartCode
}); };
var saSeCompareRight = (from se in seGroup var saSeCompareRight = from se in seGroup
join sa in saGroup join sa in saGroup
on new { se.PN, se.LU } equals new { sa.PN, sa.LU } on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
into temp into temp
@ -171,8 +187,8 @@ namespace SettleAccount.Job.Services.Report
SeFactoryPartCode = se.FactoryPartCode, SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU, SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode SaFactoryPartCode = sa.PartCode
}); };
var saSeCompareFullJoin = saSeCompareLeft.Concat(saSeCompareRight).ToList(); var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList();
return saSeCompareFullJoin; return saSeCompareFullJoin;
} }
#endregion #endregion

28
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanHBPOSaSeCompareExportService.cs

@ -15,6 +15,7 @@ using Volo.Abp.DependencyInjection;
using Volo.Abp.ObjectMapping; using Volo.Abp.ObjectMapping;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount; using Win.Sfs.SettleAccount;
using Win.Sfs.SettleAccount.Entities.BQ;
using Win.Sfs.SettleAccount.Reports; using Win.Sfs.SettleAccount.Reports;
namespace SettleAccount.Job.Services.Report namespace SettleAccount.Job.Services.Report
@ -48,7 +49,7 @@ namespace SettleAccount.Job.Services.Report
IHubContext<PageHub> hubContext, IHubContext<PageHub> hubContext,
IBlobContainer<MyFileContainer> fileContainer, IBlobContainer<MyFileContainer> fileContainer,
IObjectMapper objectMapper, IObjectMapper objectMapper,
SettleAccountDbContext settleAccountDbContext) : base(hubContext) SettleAccountDbContext settleAccountDbContext) : base(hubContext, settleAccountDbContext)
{ {
_fileContainer = fileContainer; _fileContainer = fileContainer;
_objectMapper = objectMapper; _objectMapper = objectMapper;
@ -75,6 +76,21 @@ namespace SettleAccount.Job.Services.Report
HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs); HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs);
#region 二次对比
//二次匹配上的记录
var secondMatchHaveSaHaveSes = HandleSecondCompare(pubSaSeCompareDiffs, businessType);
if (secondMatchHaveSaHaveSes.Any())
{
//二次匹配 匹配上的厂内零件号、PN
var secondMatchFPartCodePNs = secondMatchHaveSaHaveSes.Select(t => new { t.ReplaceFactoryPartCode, t.PN });
pubSaSeCompareDiffs.RemoveAll<PubSaSeCompareDiff>(t => secondMatchFPartCodePNs.Contains(new { t.ReplaceFactoryPartCode, t.PN }));
pubSaSeCompareDiffs.AddRange(secondMatchHaveSaHaveSes);
//二次对比比对上的数据入库
var pubSeCDetailEntitys = _objectMapper.Map<List<PubSaSeCompareDiff>, List<PUB_SEC_DETAIL>>(secondMatchHaveSaHaveSes);
_settleAccountDbContext.Set<PUB_SEC_DETAIL>().AddRange(pubSeCDetailEntitys);
}
#endregion
if (string.IsNullOrEmpty(lu) == false) if (string.IsNullOrEmpty(lu) == false)
{ {
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.CustomerPartCode == lu); pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.CustomerPartCode == lu);
@ -130,7 +146,7 @@ namespace SettleAccount.Job.Services.Report
ToLoc = groupItem.Max(t => t.ToLoc), ToLoc = groupItem.Max(t => t.ToLoc),
ErpToLoc = groupItem.Max(t => t.ErpToLoc) ErpToLoc = groupItem.Max(t => t.ErpToLoc)
}; };
var saSeCompareLeft = (from sa in saGroup var saSeCompareLeft = from sa in saGroup
join se in seGroup join se in seGroup
on new { sa.PN, sa.LU } equals new { se.PN, se.LU } on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
into temp into temp
@ -150,8 +166,8 @@ namespace SettleAccount.Job.Services.Report
SeFactoryPartCode = se.FactoryPartCode, SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU, SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode SaFactoryPartCode = sa.PartCode
}); };
var saSeCompareRight = (from se in seGroup var saSeCompareRight = from se in seGroup
join sa in saGroup join sa in saGroup
on new { se.PN, se.LU } equals new { sa.PN, sa.LU } on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
into temp into temp
@ -171,8 +187,8 @@ namespace SettleAccount.Job.Services.Report
SeFactoryPartCode = se.FactoryPartCode, SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU, SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode SaFactoryPartCode = sa.PartCode
}); };
var saSeCompareFullJoin = saSeCompareLeft.Concat(saSeCompareRight).ToList(); var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList();
return saSeCompareFullJoin; return saSeCompareFullJoin;
} }
#endregion #endregion

150
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 namespace SettleAccount.Job.Services.Report
{ {
/// <summary> /// <summary>
/// Pub结算发运对比导出服务 /// 结算发运对比导出服务
/// </summary> /// </summary>
public class PubSaSeCompareExportService : SaSeCompareExportBaseService, ITransientDependency, IExportJob public class PubSaSeCompareExportService : SaSeCompareExportBaseService, ITransientDependency, IExportJob
{ {
/// <summary>
/// HubContext
/// </summary>
private readonly IHubContext<PageHub> _hubContext;
/// <summary> /// <summary>
/// DbContext /// DbContext
/// </summary> /// </summary>
@ -40,22 +36,18 @@ namespace SettleAccount.Job.Services.Report
/// 替换件关系仓储 /// 替换件关系仓储
/// </summary> /// </summary>
private readonly INormalEfCoreRepository<TB_RePartsRelationship, Guid> _tbRePartsRelationshipRepository; private readonly INormalEfCoreRepository<TB_RePartsRelationship, Guid> _tbRePartsRelationshipRepository;
/// <summary> /// <summary>
/// PUB二次比对仓储 /// PUB二次比对仓储
/// </summary> /// </summary>
private readonly INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> _pubSeCDetailRepository; private readonly INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> _pubSeCDetailRepository;
/// <summary> /// <summary>
/// Pub结算发运对比Dapper /// Pub结算发运对比Dapper
/// </summary> /// </summary>
private readonly PubSaSeCompareDapperRepository _pubSaSeCompareDapperRepository; private readonly PubSaSeCompareDapperRepository _pubSaSeCompareDapperRepository;
/// <summary> /// <summary>
/// 文件容器 /// 文件容器
/// </summary> /// </summary>
private readonly IBlobContainer<MyFileContainer> _fileContainer; private readonly IBlobContainer<MyFileContainer> _fileContainer;
/// <summary> /// <summary>
/// AutoMapper /// AutoMapper
/// </summary> /// </summary>
@ -71,9 +63,8 @@ namespace SettleAccount.Job.Services.Report
INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSeCDetailRepository, INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSeCDetailRepository,
PubSaSeCompareDapperRepository pubSaSeCompareDapperRepository, PubSaSeCompareDapperRepository pubSaSeCompareDapperRepository,
IBlobContainer<MyFileContainer> fileContainer, IBlobContainer<MyFileContainer> fileContainer,
IObjectMapper objectMapper) : base(hubContext) IObjectMapper objectMapper) : base(hubContext, settleAccountDbContext)
{ {
_hubContext = hubContext;
_settleAccountDbContext = settleAccountDbContext; _settleAccountDbContext = settleAccountDbContext;
_tbRePartsRelationshipRepository = tbRePartsRelationshipRepository; _tbRePartsRelationshipRepository = tbRePartsRelationshipRepository;
_pubSeCDetailRepository = pubSeCDetailRepository; _pubSeCDetailRepository = pubSeCDetailRepository;
@ -114,59 +105,9 @@ namespace SettleAccount.Job.Services.Report
HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs); 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<PubSaSeCompareDiff>();
#region 二次对比 #region 二次对比
//二次对比(替换无结算有发运数据的厂内零件号) //二次匹配上的记录
var repFactoryPartCodes = notHaveSaHaveSes.Select(t => t.FactoryPartCode).Distinct().ToList(); var secondMatchHaveSaHaveSes = HandleSecondCompare(pubSaSeCompareDiffs, businessType);
var tbRePartsRelationships = _settleAccountDbContext.Set<TB_RePartsRelationship>().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();
if (secondMatchHaveSaHaveSes.Any()) if (secondMatchHaveSaHaveSes.Any())
{ {
//二次匹配 匹配上的厂内零件号、PN //二次匹配 匹配上的厂内零件号、PN
@ -273,10 +214,15 @@ namespace SettleAccount.Job.Services.Report
#region 私有方法 #region 私有方法
/// <summary> /// <summary>
/// 获取结算与发运比对数据 /// 获取比对数据
/// </summary> /// </summary>
public List<PubSaSeCompareDiff> GetSaSeCompareData(EnumBusinessType businessType, int version, DateTime seStartDateTime, DateTime seEndDateTime) public List<PubSaSeCompareDiff> 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<PUB_SA_DETAIL>() var saGroup = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>()
where sa.BusinessType == businessType && sa.Version == version where sa.BusinessType == businessType && sa.Version == version
@ -305,7 +251,7 @@ namespace SettleAccount.Job.Services.Report
ToLocCode = groupItem.Max(t => t.ToLocCode), ToLocCode = groupItem.Max(t => t.ToLocCode),
ToErpLocCode = groupItem.Max(t => t.ToErpLocCode) ToErpLocCode = groupItem.Max(t => t.ToErpLocCode)
}; };
var saSeCompareLeft = (from sa in saGroup var saSeCompareLeft = from sa in saGroup
join se in seGroup join se in seGroup
on new { sa.PN, sa.LU } equals new { se.PN, se.LU } on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
into temp into temp
@ -315,7 +261,7 @@ namespace SettleAccount.Job.Services.Report
WmsBillNum = se.WmsBillNum, WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate, ShippingDate = se.ShippingDate,
CustomerOfflineTime = sa.SettleDate, CustomerOfflineTime = sa.SettleDate,
PN = sa.LU, PN = sa.PN,
SAQty = sa.Qty, SAQty = sa.Qty,
SEQty = se.Qty, SEQty = se.Qty,
FixPrice = sa.Price, FixPrice = sa.Price,
@ -325,8 +271,8 @@ namespace SettleAccount.Job.Services.Report
SeFactoryPartCode = se.FactoryPartCode, SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU, SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode SaFactoryPartCode = sa.PartCode
}); };
var saSeCompareRight = (from se in seGroup var saSeCompareRight = from se in seGroup
join sa in saGroup join sa in saGroup
on new { se.PN, se.LU } equals new { sa.PN, sa.LU } on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
into temp into temp
@ -336,7 +282,7 @@ namespace SettleAccount.Job.Services.Report
WmsBillNum = se.WmsBillNum, WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate, ShippingDate = se.ShippingDate,
CustomerOfflineTime = sa.SettleDate, CustomerOfflineTime = sa.SettleDate,
PN = se.LU, PN = se.PN,
SAQty = sa.Qty, SAQty = sa.Qty,
SEQty = se.Qty, SEQty = se.Qty,
FixPrice = sa.Price, FixPrice = sa.Price,
@ -346,28 +292,33 @@ namespace SettleAccount.Job.Services.Report
SeFactoryPartCode = se.FactoryPartCode, SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU, SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode SaFactoryPartCode = sa.PartCode
}); };
//印度件LU对比
if (businessType == EnumBusinessType.YinDuJian && (1 + 1) == 3) var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList();
return saSeCompareFullJoin;
}
/// <summary>
/// 获取比对数据
/// </summary>
public List<PubSaSeCompareDiff> GetSaSeCompareDataYinDu(int version, DateTime seStartDateTime, DateTime seEndDateTime)
{ {
saGroup = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>() var saGroup = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>()
where sa.BusinessType == businessType && sa.Version == version where sa.BusinessType == EnumBusinessType.YinDuJian && sa.Version == version
group sa by new { sa.LU } into groupItem group sa by new { sa.LU } into groupItem
select new select new
{ {
PN = "",
groupItem.Key.LU, groupItem.Key.LU,
Qty = groupItem.Sum(t => t.Qty), Qty = groupItem.Sum(t => t.Qty),
Price = groupItem.Max(t => t.Price), Price = groupItem.Max(t => t.Price),
SettleDate = groupItem.Max(t => t.SettleDate), SettleDate = groupItem.Max(t => t.SettleDate),
PartCode = groupItem.Max(t => t.PartCode), PartCode = groupItem.Max(t => t.PartCode),
}; };
seGroup = from se in _settleAccountDbContext.Set<PUB_SE_DETAIL>() var seGroup = from se in _settleAccountDbContext.Set<PUB_SE_DETAIL>()
where se.BusinessType == businessType && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime where se.BusinessType == EnumBusinessType.YinDuJian && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime
group se by new { se.LU } into groupItem group se by new { se.LU } into groupItem
select new select new
{ {
PN = "",
groupItem.Key.LU, groupItem.Key.LU,
Qty = groupItem.Sum(t => t.Qty), Qty = groupItem.Sum(t => t.Qty),
WmsBillNum = groupItem.Max(t => t.WmsBillNum), WmsBillNum = groupItem.Max(t => t.WmsBillNum),
@ -376,9 +327,48 @@ namespace SettleAccount.Job.Services.Report
ToLocCode = groupItem.Max(t => t.ToLocCode), ToLocCode = groupItem.Max(t => t.ToLocCode),
ToErpLocCode = groupItem.Max(t => t.ToErpLocCode) 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; return saSeCompareFullJoin;
} }
#endregion #endregion

67
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs

@ -2,7 +2,9 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using Magicodes.ExporterAndImporter.Excel; using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;
using SettleAccount.Domain.BQ;
using SettleAccount.Job.SignalR; using SettleAccount.Job.SignalR;
using Win.Sfs.SettleAccount;
using Win.Sfs.SettleAccount.Enums; using Win.Sfs.SettleAccount.Enums;
using Win.Sfs.SettleAccount.Reports; using Win.Sfs.SettleAccount.Reports;
@ -17,10 +19,15 @@ namespace SettleAccount.Job.Services.Report
/// HubContext /// HubContext
/// </summary> /// </summary>
private readonly IHubContext<PageHub> _hubContext; private readonly IHubContext<PageHub> _hubContext;
/// <summary>
/// DbContext
/// </summary>
private readonly SettleAccountDbContext _settleAccountDbContext;
public SaSeCompareExportBaseService(IHubContext<PageHub> hubContext) public SaSeCompareExportBaseService(IHubContext<PageHub> hubContext, SettleAccountDbContext settleAccountDbContext)
{ {
_hubContext = hubContext; _hubContext = hubContext;
_settleAccountDbContext = settleAccountDbContext;
} }
public virtual void HandlePubSaSeCompareDiffList(List<PubSaSeCompareDiff> pubSaSeCompareDiffs) public virtual void HandlePubSaSeCompareDiffList(List<PubSaSeCompareDiff> pubSaSeCompareDiffs)
@ -65,6 +72,64 @@ namespace SettleAccount.Job.Services.Report
}); });
} }
/// <summary>
/// 二次比对
/// </summary>
public virtual List<PubSaSeCompareDiff> HandleSecondCompare(List<PubSaSeCompareDiff> pubSaSeCompareDiffs, EnumBusinessType businessType)
{
//二次匹配上的记录
var secondMatchHaveSaHaveSes = new List<PubSaSeCompareDiff>();
//有结算有发运
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<TB_RePartsRelationship>().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;
}
/// <summary> /// <summary>
/// 创建导出文件结构 /// 创建导出文件结构
/// </summary> /// </summary>

Loading…
Cancel
Save