|
|
@ -1,11 +1,18 @@ |
|
|
|
using System; |
|
|
|
using System.Collections; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
using System.Diagnostics.CodeAnalysis; |
|
|
|
using System.Linq; |
|
|
|
using System.Linq.Dynamic.Core; |
|
|
|
using System.Runtime.CompilerServices; |
|
|
|
using EFCore.BulkExtensions; |
|
|
|
using Magicodes.ExporterAndImporter.Core; |
|
|
|
using Magicodes.ExporterAndImporter.Excel; |
|
|
|
using Microsoft.AspNetCore.SignalR; |
|
|
|
using Microsoft.OpenApi.Extensions; |
|
|
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; |
|
|
|
using SettleAccount.Bases; |
|
|
|
using SettleAccount.Domain.BQ; |
|
|
|
using SettleAccount.Job.SignalR; |
|
|
|
using Shouldly; |
|
|
@ -17,6 +24,7 @@ using Volo.Abp.ObjectMapping; |
|
|
|
using Win.Sfs.BaseData.ImportExcelCommon; |
|
|
|
using Win.Sfs.SettleAccount; |
|
|
|
using Win.Sfs.SettleAccount.Entities.BQ; |
|
|
|
using Win.Sfs.SettleAccount.Enums; |
|
|
|
using Win.Sfs.SettleAccount.Reports; |
|
|
|
|
|
|
|
namespace SettleAccount.Job.Services.Report |
|
|
@ -87,10 +95,14 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
pubSaSeCompareDiffs.AddRange(secondMatchHaveSaHaveSes); |
|
|
|
//二次对比比对上的数据入库
|
|
|
|
var pubSeCDetailEntitys = _objectMapper.Map<List<SaSeCompareDiff>, List<PUB_SEC_DETAIL>>(secondMatchHaveSaHaveSes); |
|
|
|
_settleAccountDbContext.Set<PUB_SEC_DETAIL>().AddRange(pubSeCDetailEntitys); |
|
|
|
//_settleAccountDbContext.Set<PUB_SEC_DETAIL>().AddRange(pubSeCDetailEntitys);
|
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 三次对比
|
|
|
|
//pubSaSeCompareDiffs = ThreeCompare(pubSaSeCompareDiffs);
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 结算数据处理
|
|
|
|
HandleSaDetails<BBAC_CAN_SA_DETAIL, BBAC_NOT_SA_DETAIL>(pubSaSeCompareDiffs, businessType, version); |
|
|
|
HandleSaDetailsMain<BBAC_SA_DETAIL>(pubSaSeCompareDiffs, businessType, version); |
|
|
@ -117,5 +129,61 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
Notify(); |
|
|
|
return id.ToString(); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 三次比对
|
|
|
|
/// </summary>
|
|
|
|
/// <remarks>
|
|
|
|
/// 不同PN下客户零件号、数量、相同为有结算有发运数据
|
|
|
|
/// 获取有结算无发运、无结算有发运同时存在的零件号
|
|
|
|
/// 遍历零件号
|
|
|
|
/// 判断结算无发运和无结算有发运数据 客户零件号、数量是否完全匹配
|
|
|
|
/// 完全匹配修改有结算无发运的数据类型为有结算有发运,去掉无结算有发运的数据
|
|
|
|
/// </remarks>
|
|
|
|
public List<SaSeCompareDiff> ThreeCompare(List<SaSeCompareDiff> saSeCompareDiffs) |
|
|
|
{ |
|
|
|
//有结算无发运
|
|
|
|
var haveSaNotHaveSes = saSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe); |
|
|
|
//无结算有发运
|
|
|
|
var notHaveSaHaveSes = saSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe); |
|
|
|
|
|
|
|
var haveSaNotHaveSeHashCodes = haveSaNotHaveSes.OrderBy(t => t.CustomerPartCode).GroupBy(t => t.PN).Select(t => new |
|
|
|
{ |
|
|
|
PN = t.Key, |
|
|
|
PartCodeHashCode = t.Select(t => t.CustomerPartCode).Aggregate((current, index) => $"{current};{index}").GetHashCode(), |
|
|
|
QtyHashCode = t.Select(t => t.SAQty.ToString()).Aggregate((current, index) => $"{current};{index}") |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
var notHaveSaHaveSeHashCodes = notHaveSaHaveSes.OrderBy(t => t.CustomerPartCode).GroupBy(t => t.PN).Select(t => new |
|
|
|
{ |
|
|
|
PN = t.Key, |
|
|
|
PartCodeHashCode = t.Select(t => t.CustomerPartCode).Aggregate((current, index) => $"{current};{index}").GetHashCode(), |
|
|
|
QtyHashCode = t.Select(t => t.SEQty.ToString()).Aggregate((current, index) => $"{current};{index}") |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
var matchPNs = new Dictionary<string, string>(); |
|
|
|
|
|
|
|
haveSaNotHaveSeHashCodes.ForEach(haveSaNotHaveSeHashCode => |
|
|
|
{ |
|
|
|
var matchPN = notHaveSaHaveSeHashCodes.FirstOrDefault(t => t.PartCodeHashCode == haveSaNotHaveSeHashCode.PartCodeHashCode && t.QtyHashCode == haveSaNotHaveSeHashCode.QtyHashCode && matchPNs.ContainsKey(t.PN) == false); |
|
|
|
|
|
|
|
if (matchPN != null) |
|
|
|
{ |
|
|
|
matchPNs.Add(matchPN.PN, haveSaNotHaveSeHashCode.PN); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
saSeCompareDiffs.RemoveAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe && matchPNs.ContainsKey(t.PN)); |
|
|
|
|
|
|
|
saSeCompareDiffs.Where(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe) |
|
|
|
.Where(t => matchPNs.ContainsValue(t.PN)).ToList() |
|
|
|
.ForEach(t => |
|
|
|
{ |
|
|
|
t.Category = EnumPubSaSeCompareCategory.HaveSaHaveSe; |
|
|
|
t.SEQty = t.SAQty; |
|
|
|
}); |
|
|
|
|
|
|
|
return saSeCompareDiffs; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|