Browse Source

PUB结算与发运比对

master
mahao 1 year ago
parent
commit
aaa6795327
  1. 88
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/EdiSeCompareService.cs
  2. 15
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs
  3. 3
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/PubSaSeCompareDapperRepository.cs
  4. 46
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/BBACEdiSeCompareExportService.cs
  5. 46
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HBPOEdiSeCompareExportService.cs
  6. 84
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs
  7. 12
      code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs

88
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/EdiSeCompareService.cs

@ -0,0 +1,88 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.OpenApi.Extensions;
using SettleAccount.Job.Services.Report;
using TaskJob.EventArgs;
using Volo.Abp.Application.Services;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.TaskJobs;
namespace Win.Sfs.SettleAccount.Entities.BQ;
/// <summary>
/// Edi与发运对比服务
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class EdiSeCompareService : ApplicationService
{
/// <summary>
/// 任务服务
/// </summary>
private readonly TaskJobService _taskJobService;
public EdiSeCompareService(TaskJobService taskJobService)
{
_taskJobService = taskJobService;
}
#region 对比
/// <summary>
/// BBACEdi与发运比对
/// </summary>
[HttpPost]
public async Task<string> BBACEdiSeCompare(PubSaSeCompareRequestDto pubSaSeCompareRequestDto)
{
var businessTypeDisplayName = pubSaSeCompareRequestDto.BusinessType.ToString();
DisplayAttribute attributeOfType = pubSaSeCompareRequestDto.BusinessType.GetAttributeOfType<DisplayAttribute>();
if (attributeOfType != null)
{
businessTypeDisplayName = attributeOfType.Name;
}
var projectName = $"{businessTypeDisplayName}结算与发运数据对比";
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "Version", Value = pubSaSeCompareRequestDto.Version });
customConditionList.Add(new CustomCondition() { Name = "BusinessType", Value = ((int)pubSaSeCompareRequestDto.BusinessType).ToString() });
customConditionList.Add(new CustomCondition() { Name = "LU", Value = pubSaSeCompareRequestDto.LU });
customConditionList.Add(new CustomCondition() { Name = "PN", Value = pubSaSeCompareRequestDto.PN });
customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = projectName });
var _taskid = await _taskJobService.ExportEnqueueAsync(projectName, ExportExtentsion.Excel, pubSaSeCompareRequestDto.Version, string.Empty, CurrentUser, typeof(BBACEdiSeCompareExportService), customConditionList, (rs) =>
{
});
return _taskid;
}
/// <summary>
/// HBPOEdi与发运比对
/// </summary>
[HttpPost]
public async Task<string> HBPOEdiSeCompare(PubSaSeCompareRequestDto pubSaSeCompareRequestDto)
{
var businessTypeDisplayName = pubSaSeCompareRequestDto.BusinessType.ToString();
DisplayAttribute attributeOfType = pubSaSeCompareRequestDto.BusinessType.GetAttributeOfType<DisplayAttribute>();
if (attributeOfType != null)
{
businessTypeDisplayName = attributeOfType.Name;
}
var projectName = $"{businessTypeDisplayName}结算与发运数据对比";
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "Version", Value = pubSaSeCompareRequestDto.Version });
customConditionList.Add(new CustomCondition() { Name = "BusinessType", Value = ((int)pubSaSeCompareRequestDto.BusinessType).ToString() });
customConditionList.Add(new CustomCondition() { Name = "LU", Value = pubSaSeCompareRequestDto.LU });
customConditionList.Add(new CustomCondition() { Name = "PN", Value = pubSaSeCompareRequestDto.PN });
customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = projectName });
var _taskid = await _taskJobService.ExportEnqueueAsync(projectName, ExportExtentsion.Excel, pubSaSeCompareRequestDto.Version, string.Empty, CurrentUser, typeof(HBPOEdiSeCompareExportService), customConditionList, (rs) =>
{
});
return _taskid;
}
#endregion
}

15
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs

@ -68,9 +68,12 @@ public class PubSaSeCompareDiff
/// <summary>
/// 差异数量
/// </summary>
[ExporterHeader(DisplayName = "差异数量")]
public decimal DiffQty { set; get; }
[Display(Name = "差异数量")]
public decimal DiffQty => SAQty - SEQty;
/// <summary>
/// 匹配类型
/// </summary>
[Display(Name = "匹配类型")]
public string MateType { get; set; }
@ -98,12 +101,6 @@ public class PubSaSeCompareDiff
[Display(Name = "零件号")]
public string SeLU { set; get; }
/// <summary>
/// 生产号
/// </summary>
[Display(Name = "生产号")]
public string SePN { set; get; }
/// <summary>
/// 零件号
/// </summary>
@ -114,7 +111,7 @@ public class PubSaSeCompareDiff
/// 生产号
/// </summary>
[Display(Name = "生产号")]
public string SaPN { set; get; }
public string PN { set; get; }
/// <summary>
/// 类型

3
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/PubSaSeCompareDapperRepository.cs

@ -38,9 +38,8 @@ public class PubSaSeCompareDapperRepository : DapperRepository<SettleAccountDbCo
'' AssemblyCode,
'' InjectionCode,
A.LU SeLU,
A.PN SePN,
B.LU SaLU,
B.PN SaPN,
ISNULL(A.PN,B.PN) PN,
A.SEQty,
B.SAQty,
(B.SAQty-A.SEQty) DiffQty,

46
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/BBACEdiSeCompareExportService.cs

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using TaskJob.EventArgs;
using TaskJob.Interfaces;
using Volo.Abp.BlobStoring;
using Volo.Abp.DependencyInjection;
using Volo.Abp.ObjectMapping;
using Win.Sfs.BaseData.ImportExcelCommon;
namespace SettleAccount.Job.Services.Report
{
/// <summary>
/// BBACEdi与发运对比导出服务
/// </summary>
public class BBACEdiSeCompareExportService : ITransientDependency, IExportJob
{
/// <summary>
/// 文件容器
/// </summary>
private readonly IBlobContainer<MyFileContainer> _fileContainer;
/// <summary>
/// AutoMapper
/// </summary>
private readonly IObjectMapper _objectMapper;
/// <summary>
/// 构造
/// </summary>
public BBACEdiSeCompareExportService(
IBlobContainer<MyFileContainer> fileContainer,
IObjectMapper objectMapper)
{
_fileContainer = fileContainer;
_objectMapper = objectMapper;
}
/// <summary>
/// 导出
/// </summary>
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property)
{
return "";
}
}
}

46
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/HBPOEdiSeCompareExportService.cs

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using TaskJob.EventArgs;
using TaskJob.Interfaces;
using Volo.Abp.BlobStoring;
using Volo.Abp.DependencyInjection;
using Volo.Abp.ObjectMapping;
using Win.Sfs.BaseData.ImportExcelCommon;
namespace SettleAccount.Job.Services.Report
{
/// <summary>
/// HBPOEdi与发运对比导出服务
/// </summary>
public class HBPOEdiSeCompareExportService : ITransientDependency, IExportJob
{
/// <summary>
/// 文件容器
/// </summary>
private readonly IBlobContainer<MyFileContainer> _fileContainer;
/// <summary>
/// AutoMapper
/// </summary>
private readonly IObjectMapper _objectMapper;
/// <summary>
/// 构造
/// </summary>
public HBPOEdiSeCompareExportService(
IBlobContainer<MyFileContainer> fileContainer,
IObjectMapper objectMapper)
{
_fileContainer = fileContainer;
_objectMapper = objectMapper;
}
/// <summary>
/// 导出
/// </summary>
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property)
{
return "";
}
}
}

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

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using EmptyFiles;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.OpenApi.Extensions;
using NetTopologySuite.Operation.Buffer;
@ -31,38 +32,34 @@ namespace SettleAccount.Job.Services.Report
public class PubSaSeCompareExportService : ITransientDependency, IExportJob
{
/// <summary>
/// Pub结算明细仓储
/// 替换件关系仓储
/// </summary>
private readonly INormalEfCoreRepository<PUB_SA_DETAIL, Guid> _pubSaDetailRepository;
private readonly INormalEfCoreRepository<TB_RePartsRelationship, Guid> _tbRePartsRelationshipRepository;
/// <summary>
/// Pub发运数据仓储
/// Pub结算发运对比Dapper
/// </summary>
private readonly INormalEfCoreRepository<PUB_SE_DETAIL, Guid> _pubSeDetailRepository;
private readonly PubSaSeCompareDapperRepository _pubSaSeCompareDapperRepository;
/// <summary>
/// 替换件关系仓储
/// 文件容器
/// </summary>
private readonly INormalEfCoreRepository<TB_RePartsRelationship, Guid> _tbRePartsRelationshipRepository;
private readonly PubSaSeCompareDapperRepository _pubSaSeCompareDapperRepository;
private readonly IBlobContainer<MyFileContainer> _fileContainer;
/// <summary>
/// AutoMapper
/// </summary>
private readonly IObjectMapper _objectMapper;
/// <summary>
/// 构造
/// </summary>
public PubSaSeCompareExportService(INormalEfCoreRepository<PUB_SA_DETAIL, Guid> pubSaDetailRepository,
INormalEfCoreRepository<PUB_SE_DETAIL, Guid> pubSeDetailRepository,
public PubSaSeCompareExportService(
INormalEfCoreRepository<TB_RePartsRelationship, Guid> tbRePartsRelationshipRepository,
PubSaSeCompareDapperRepository pubSaSeCompareDapperRepository,
IBlobContainer<MyFileContainer> fileContainer,
IObjectMapper objectMapper)
{
_pubSaDetailRepository = pubSaDetailRepository;
_pubSeDetailRepository = pubSeDetailRepository;
_tbRePartsRelationshipRepository = tbRePartsRelationshipRepository;
_pubSaSeCompareDapperRepository = pubSaSeCompareDapperRepository;
_fileContainer = fileContainer;
@ -107,39 +104,64 @@ namespace SettleAccount.Job.Services.Report
});
//有结算有发运
var haveSaHaveSe = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe);
var haveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe);
//有结算无发运
var haveSaNotHaveSe = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe);
var haveSaNotHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe);
//无结算有发运
var notHaveSaHaveSe = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe);
var notHaveSaHaveSes = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe);
haveSaHaveSe.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU);
haveSaNotHaveSe.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU);
notHaveSaHaveSe.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU);
haveSaHaveSes.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU);
haveSaNotHaveSes.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU);
notHaveSaHaveSes.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SeLU);
#region 二次对比
//二次对比(替换零件号)
var repLUs = notHaveSaHaveSe.Select(t => t.SeLU).Distinct().ToList();
var repLUs = notHaveSaHaveSes.Select(t => t.SeLU).Distinct().ToList();
var tbRePartsRelationships = _tbRePartsRelationshipRepository.GetListAsync(t => repLUs.Contains(t.RepLU) && ((int)t.BusinessType).ToString() == businessType).Result;
tbRePartsRelationships.ForEach(tbRePartsRelationship =>
{
notHaveSaHaveSe.FindAll(t => t.SeLU == tbRePartsRelationship.RepLU).ForEach(t =>
notHaveSaHaveSes.FindAll(t => t.SeLU == tbRePartsRelationship.RepLU).ForEach(t =>
{
t.ReplaceLU = tbRePartsRelationship.LU;
});
});
var haveSaNotHaveSeLUPNs = haveSaNotHaveSes.Select(t => new { t.ReplaceLU, t.PN });
var notHaveSaHaveSeLUPNs = notHaveSaHaveSes.Select(t => new { t.ReplaceLU, t.PN });
//二次匹配 匹配上的零件号
var secondMatchLUPNs = haveSaNotHaveSeLUPNs.Intersect(notHaveSaHaveSeLUPNs);
if (secondMatchLUPNs.Any() == true)
{
pubSaSeCompareDiffs.RemoveAll<PubSaSeCompareDiff>(t => secondMatchLUPNs.Contains(new { t.ReplaceLU, t.PN }));
var haveSaNotHaveSeReplaceLU = haveSaNotHaveSe.Select(t => t.ReplaceLU);
var notHaveSaHaveSeReplaceLU = notHaveSaHaveSe.Select(t => t.ReplaceLU);
//此次匹配上的零件号
var secondMatchReplaceLU = notHaveSaHaveSeReplaceLU.Intersect(notHaveSaHaveSeReplaceLU);
//if (secondMatchReplaceLU)
//{
//}
foreach (var secondMatchLUPN in secondMatchLUPNs)
{
var haveSaNotHaveSe = haveSaNotHaveSes.FirstOrDefault(t => t.ReplaceLU == secondMatchLUPN.ReplaceLU && t.PN == secondMatchLUPN.PN);
var notHaveSaHaveSe = notHaveSaHaveSes.FirstOrDefault(t => t.ReplaceLU == secondMatchLUPN.ReplaceLU && t.PN == secondMatchLUPN.PN);
pubSaSeCompareDiffs.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
});
}
}
#endregion
@ -149,7 +171,7 @@ namespace SettleAccount.Job.Services.Report
}
if (string.IsNullOrEmpty(pn) == false)
{
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.SaPN == pn || p.SePN == pn);
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.PN == pn);
}
//结算核对明细

12
code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs

@ -40,6 +40,9 @@ namespace Win.Sfs.SettleAccount
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute{ Attempts = 0});
context.Services.AddTransient<PubSaSeCompareExportService>();
context.Services.AddTransient<BBACEdiSeCompareExportService>();
context.Services.AddTransient<HBPOEdiSeCompareExportService>();
context.Services.AddTransient<SettleAccountImportService>();
context.Services.AddTransient<InvoiceImportService>();
@ -86,6 +89,15 @@ namespace Win.Sfs.SettleAccount
{
return implementationFactory.GetService<PubSaSeCompareExportService>();
}
if (key.Equals(typeof(BBACEdiSeCompareExportService).FullName))
{
return implementationFactory.GetService<BBACEdiSeCompareExportService>();
}
if (key.Equals(typeof(HBPOEdiSeCompareExportService).FullName))
{
return implementationFactory.GetService<HBPOEdiSeCompareExportService>();
}
if (key.Equals(typeof(InvoiceSettledDiffExportService).FullName))
{

Loading…
Cancel
Save