Browse Source

比对后处理有发运的结算数据

master
mahao 1 year ago
parent
commit
96b02595e8
  1. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/JisBBACEidSeCompareReport.cs
  2. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSeEdiCompareExportService.cs
  3. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSeEdiCompareExportService.cs
  4. 48
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs
  5. 50
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs

2
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/JisBBACEidSeCompareReport.cs

@ -13,7 +13,7 @@ public class JisBBACEidSeCompareReport
}
/// <summary>
/// JisBBAC Edi发运对比导出
/// JisBBAC Edi发运对比导出
/// </summary>
[ExcelExporter(MaxRowNumberOnASheet = 900000)]
public class JisBBACEidSeCompareExport

4
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSeEdiCompareExportService.cs

@ -75,9 +75,11 @@ namespace SettleAccount.Job.Services.Report
LineStationcode = default,
SequenceNumber = t.Max(t => t.SeqNumber),
ParType = "01",
PN = t.Key.PN,
MaterialNumber = t.Key.LU,
EdiQty = t.Sum(t => t.Qty),
AssemblyDate = default,
MatchNumber = t.Key.LU,
MatchNumber = default,
MateType = "否",
DiffDesc = "WMS漏发货EDI有订单"
}).ToList();

6
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSeEdiCompareExportService.cs

@ -72,9 +72,11 @@ namespace SettleAccount.Job.Services.Report
LineStationcode = default,
SequenceNumber = t.Max(t => t.SeqNumber),
ParType = "01",
PN = t.Key.PN,
MaterialNumber = t.Key.LU,
EdiQty = t.Sum(t => t.Qty),
AssemblyDate = default,
MatchNumber = t.Key.LU,
MatchNumber = default,
MateType = "否",
DiffDesc = "WMS漏发货EDI有订单"
}).ToList();
@ -159,7 +161,9 @@ namespace SettleAccount.Job.Services.Report
}).ToList();
haveEdiNotHaveSeList.AddRange(haveEdiHaveSeList);
haveEdiNotHaveSeList.Reverse();
notHaveEdiHaveSeList.AddRange(haveEdiHaveSeList);
notHaveEdiHaveSeList.Reverse();
ExcelExporter excelExporter = new ExcelExporter();
excelExporter

48
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using EFCore.BulkExtensions;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.SignalR;
using Microsoft.OpenApi.Extensions;
@ -85,7 +86,7 @@ namespace SettleAccount.Job.Services.Report
/// </summary>
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property)
{
var version = property.Where(p => p.Name == "Version").FirstOrDefault().Value;
var version = int.Parse(property.Where(p => p.Name == "Version").FirstOrDefault().Value);
var strBusinessType = property.Where(t => t.Name == "BusinessType").FirstOrDefault().Value;
var lu = property.Where(p => p.Name == "LU").FirstOrDefault().Value;
var pn = property.Where(p => p.Name == "PN").FirstOrDefault().Value;
@ -101,7 +102,7 @@ namespace SettleAccount.Job.Services.Report
}
var filename = exportName.FirstOrDefault();
//var pubSaSeCompareDiffs = _pubSaSeCompareDapperRepository.GetDetailDiffReportList(strBusinessType, version, seStartDateTime, seEndDateTime);
var pubSaSeCompareDiffs = GetSaSeCompareData(businessType, int.Parse(version), DateTime.Parse(seStartDateTime), DateTime.Parse(seEndDateTime));
var pubSaSeCompareDiffs = GetSaSeCompareData(businessType, version, DateTime.Parse(seStartDateTime), DateTime.Parse(seEndDateTime));
HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs);
@ -117,48 +118,11 @@ namespace SettleAccount.Job.Services.Report
//二次对比比对上的数据入库
var pubSeCDetailEntitys = _objectMapper.Map<List<PubSaSeCompareDiff>, List<PUB_SEC_DETAIL>>(secondMatchHaveSaHaveSes);
_settleAccountDbContext.Set<PUB_SEC_DETAIL>().AddRange(pubSeCDetailEntitys);
//_pubSeCDetailRepository.InsertManyAsync(pubSeCDetailEntitys);
}
#endregion
//var haveSaNotHaveSeFPartCodePNs = haveSaNotHaveSes.Select(t => new { t.ReplaceFactoryPartCode, t.PN });
//var notHaveSaHaveSeFPartCodePNs = notHaveSaHaveSes.Select(t => new { t.ReplaceFactoryPartCode, t.PN });
////二次匹配 匹配上的厂内零件号、PN
//var secondMatchFPartCodePNs = haveSaNotHaveSeFPartCodePNs.Intersect(notHaveSaHaveSeFPartCodePNs);
//if (secondMatchFPartCodePNs.Any() == true)
//{
// pubSaSeCompareDiffs.RemoveAll<PubSaSeCompareDiff>(t => secondMatchFPartCodePNs.Contains(new { t.ReplaceFactoryPartCode, t.PN }));
// foreach (var secondMatchFPartCodePN in secondMatchFPartCodePNs)
// {
// var haveSaNotHaveSe = haveSaNotHaveSes.FirstOrDefault(t => t.ReplaceFactoryPartCode == secondMatchFPartCodePN.ReplaceFactoryPartCode && t.PN == secondMatchFPartCodePN.PN);
// var notHaveSaHaveSe = notHaveSaHaveSes.FirstOrDefault(t => t.ReplaceFactoryPartCode == secondMatchFPartCodePN.ReplaceFactoryPartCode && t.PN == secondMatchFPartCodePN.PN);
// if (haveSaNotHaveSe != null && notHaveSaHaveSe != null)
// {
// }
// secondMatchHaveSaHaveSes.Add(new PubSaSeCompareDiff()
// {
// WmsBillNum = notHaveSaHaveSe.WmsBillNum,
// ShippingDate = notHaveSaHaveSe.ShippingDate,
// SeqNumber = notHaveSaHaveSe.SeqNumber,
// PJISSeqNumber = notHaveSaHaveSe.PJISSeqNumber,
// MaterialNumber = haveSaNotHaveSe.MaterialNumber,
// MaterialDes = haveSaNotHaveSe.MaterialDes,
// CustomerOfflineTime = haveSaNotHaveSe.CustomerOfflineTime,
// SAQty = haveSaNotHaveSe.SAQty,
// SEQty = notHaveSaHaveSe.SEQty,
// MateType = haveSaNotHaveSe.MateType,
// FixPrice = haveSaNotHaveSe.FixPrice,
// PrimitiveLU = haveSaNotHaveSe.PrimitiveLU,
// ReplaceLU = haveSaNotHaveSe.ReplaceLU,
// SeLU = notHaveSaHaveSe.SeLU,
// SaLU = haveSaNotHaveSe.SaLU,
// PN = haveSaNotHaveSe.PN,
// Category = EnumPubSaSeCompareCategory.HaveSaHaveSe,
// IsRemove = false
// });
// }
//}
#region 结算数据处理
HandlSaDetails(pubSaSeCompareDiffs, businessType, version);
#endregion
if (string.IsNullOrEmpty(lu) == false)

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

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using EFCore.BulkExtensions;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.SignalR;
using SettleAccount.Domain.BQ;
@ -76,18 +77,20 @@ namespace SettleAccount.Job.Services.Report
{
//二次匹配上的记录
var secondMatchHaveSaHaveSes = new List<PubSaSeCompareDiff>();
//有结算无发运 和 无结算有发运
var haveSaNotHaveSeUnionNotHaveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe || t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe);
//有结算无发运
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();
//二次对比(替换发运数据的厂内零件号)
var repFactoryPartCodes = haveSaNotHaveSeUnionNotHaveSaHaveSes.Select(t => t.FactoryPartCode).Distinct().ToList();
var tbRePartsRelationships = _settleAccountDbContext.Set<TB_RePartsRelationship>().Where(t => repFactoryPartCodes.Contains(t.LU)).ToList();
tbRePartsRelationships.ForEach(tbRePartsRelationship =>
{
notHaveSaHaveSes.FindAll(t => t.FactoryPartCode == tbRePartsRelationship.LU).ForEach(t =>
haveSaNotHaveSeUnionNotHaveSaHaveSes.FindAll(t => t.FactoryPartCode == tbRePartsRelationship.LU).ForEach(t =>
{
t.ReplaceFactoryPartCode = tbRePartsRelationship.RepLU;
});
@ -123,6 +126,45 @@ namespace SettleAccount.Job.Services.Report
return secondMatchHaveSaHaveSes;
}
/// <summary>
/// 结算数据处理
/// 写入库位、替换零件号
/// </summary>
public virtual void HandlSaDetails(List<PubSaSeCompareDiff> pubSaSeCompareDiffs, EnumBusinessType businessType, int version)
{
//写入库位、替换零件号
var haveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe);
if (haveSaHaveSes.Any())
{
var canSaDetails = (from sa in _settleAccountDbContext.Set<PUB_CAN_SA_DETAIL>()
where sa.BusinessType == businessType && sa.Version == version
select sa).ToList();
if (canSaDetails.Any())
{
var canSaDetailsUpdate = canSaDetails.Join(haveSaHaveSes, o => new { o.PN, o.LU }, i => new { i.PN, LU = i.CustomerPartCode }, (o, i) =>
{
o.ErpLoc = i.ToErpLocCode;
o.RealPartCode = i.ReplaceFactoryPartCode;
return o;
}).ToList();
_settleAccountDbContext.BulkUpdate(canSaDetailsUpdate);
}
var notSaDetails = (from sa in _settleAccountDbContext.Set<PUB_NOT_SA_DETAIL>()
where sa.BusinessType == businessType && sa.Version == version
select sa).ToList();
if (notSaDetails.Any())
{
var notSaDetailsUpdate = notSaDetails.Join(haveSaHaveSes, o => new { o.PN, o.LU }, i => new { i.PN, LU = i.CustomerPartCode }, (o, i) =>
{
o.ErpLoc = i.ToErpLocCode;
o.RealPartCode = i.ReplaceFactoryPartCode;
return o;
}).ToList();
_settleAccountDbContext.BulkUpdate(notSaDetailsUpdate);
}
}
}
/// <summary>
/// 创建导出文件结构
/// </summary>

Loading…
Cancel
Save