Browse Source

[172]直供HBPO结算导入变更,需要按目标库位字段区分CN1与CN5,CC004=亦庄=CN1;CC172=顺义=CN5

master
mahao 1 year ago
parent
commit
3bc2db862f
  1. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs
  2. 17
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
  3. 65
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs

6
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs

@ -162,9 +162,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// <summary> /// <summary>
/// 地点 /// 地点
/// </summary> /// </summary>
[Display(Name = "地点")] [Display(Name = "目标库位")]
[ImporterHeader(Name = "地点")] [ImporterHeader(Name = "目标库位")]
[Required(ErrorMessage = "{0}不能为空")] [Required(ErrorMessage = "{0}不能为空")]
[ValueMapping("CC004", "CN1")]
[ValueMapping("CC172", "CN5")]
public string Place { get; set; } public string Place { get; set; }
} }

17
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs

@ -48,6 +48,7 @@ using Win.Sfs.Shared.RepositoryBase;
using static Dm.parser.LVal; using static Dm.parser.LVal;
using static LinqToDB.Sql; using static LinqToDB.Sql;
using Win.Sfs.Shared.Filter; using Win.Sfs.Shared.Filter;
using Polly;
namespace Win.Sfs.SettleAccount.Entities.BQ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
@ -208,7 +209,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
invoiceGrps.ForEach(t => t.State = SettleBillState.QAD); invoiceGrps.ForEach(t => t.State = SettleBillState.QAD);
await _exChangeCenterDbContext.SaveChangesAsync().ConfigureAwait(false); await _exChangeCenterDbContext.SaveChangesAsync().ConfigureAwait(false);
await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false);
var retryPolicyAsync = Policy.Handle<Exception>().WaitAndRetryAsync(new[] {
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(5),
TimeSpan.FromSeconds(5),
TimeSpan.FromSeconds(5)
}, (exception, timeSpan, retryCount, context) =>
{
Console.WriteLine($"执行失败,第 {retryCount} 次重试");
});
await retryPolicyAsync.ExecuteAsync(async () => await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false)).ConfigureAwait(false);
} }
await Task.CompletedTask.ConfigureAwait(false); await Task.CompletedTask.ConfigureAwait(false);
@ -355,9 +366,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
INVOICE_GRP_DETAIL_DTO entity = new INVOICE_GRP_DETAIL_DTO(); INVOICE_GRP_DETAIL_DTO entity = new INVOICE_GRP_DETAIL_DTO();
var condition = input.Filters.FirstOrDefault(p => p.Column == "invbillNum"); var condition = input.Filters.FirstOrDefault(p => p.Column == "invbillNum");
if( condition==null ) if (condition == null)
{ {
input.Filters.Add(new FilterCondition("InvoiceState", "1", EnumFilterAction.Equal, EnumFilterLogic.And)); input.Filters.Add(new FilterCondition("InvoiceState", "1", EnumFilterAction.Equal, EnumFilterLogic.And));
} }
var invs = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); var invs = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false);

65
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs

@ -135,7 +135,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
version = pubSaImportRequestDto.Version; version = pubSaImportRequestDto.Version;
businessType = pubSaImportRequestDto.BusinessType; businessType = pubSaImportRequestDto.BusinessType;
site = pubSaImportRequestDto.Site; site = pubSaImportRequestDto.Site;
switch (pubSaImportRequestDto.BusinessType) switch (businessType)
{ {
case EnumBusinessType.ZhiGongJianBBAC: case EnumBusinessType.ZhiGongJianBBAC:
result = await ImportZhiGongJianBBACAsync(pubSaImportRequestDto.Files).ConfigureAwait(false); result = await ImportZhiGongJianBBACAsync(pubSaImportRequestDto.Files).ConfigureAwait(false);
@ -301,7 +301,29 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
importPubSaDetails = HandleSaDetails(importPubSaDetails); importPubSaDetails = HandleSaDetails(importPubSaDetails);
#region 数据校验 #region 数据校验
var checkList = await CheckAsync(importPubSaDetails).ConfigureAwait(false); var place = importPubSaDetails.FirstOrDefault().Place;
if (place != "CN1" && place != "CN5")
{
return new JsonResult(new { Code = 400, Message = $"目标库位值【{place}】无效" });
}
//数据校验
var checkList = new List<ErrorExportDto>();
//结算分组号
var pubSaGroupNums = importPubSaDetails.Select(t => t.GroupNum).Distinct();
//已存在的结算分组号
var havPubSaGroupNums = (await _pubSaDetailRepository.GetListAsync(t => t.Place == place && pubSaGroupNums.Contains(t.GroupNum)).ConfigureAwait(false)).Select(t => t.GroupNum).Distinct();
if (havPubSaGroupNums.Any() == true)
{
foreach (var item in havPubSaGroupNums)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"结算分组号{item}已存在", string.Empty));
}
}
if (!checkList.Any())
{
checkList.AddRange(await CheckMaterialRelationshipAsync(importPubSaDetails).ConfigureAwait(false));
}
if (checkList.Count > 0) if (checkList.Count > 0)
{ {
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false); string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
@ -404,23 +426,40 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
if (!checkList.Any()) if (!checkList.Any())
{ {
//验证客户对应厂内零件号是否存在 //验证客户对应厂内零件号是否存在
//导入的零件号集合 checkList.AddRange(await CheckMaterialRelationshipAsync(pubSaDetails).ConfigureAwait(false));
var importPubSaLUs = pubSaDetails.Select(t => t.LU).Distinct();
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => t.BusinessType == businessType && importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false);
var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct();
//不存在的客户零件号(差集)
var noExistSettleMaterialCodes = importPubSaLUs.Except(materialRelationshipEntitySettleMaterialCodes);
noExistSettleMaterialCodes.ForEach(t =>
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"客户零件号【{t}】对应厂内零件号系统中不存在", string.Empty));
});
} }
return checkList; return checkList;
#endregion #endregion
} }
/// <summary>
/// 数据校验
/// </summary>
/// <remarks>
/// 验证客户-厂内零件号关系是否已存在
/// </remarks>
private async Task<List<ErrorExportDto>> CheckMaterialRelationshipAsync(List<PUB_SA_DETAIL> pubSaDetails)
{
#region 数据校验
//数据校验
var checkList = new List<ErrorExportDto>();
//验证客户对应厂内零件号是否存在
//导入的零件号集合
var importPubSaLUs = pubSaDetails.Select(t => t.LU).Distinct();
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => t.BusinessType == businessType && importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false);
var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct();
//不存在的客户零件号(差集)
var noExistSettleMaterialCodes = importPubSaLUs.Except(materialRelationshipEntitySettleMaterialCodes);
noExistSettleMaterialCodes.ForEach(t =>
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"客户零件号【{t}】对应厂内零件号系统中不存在", string.Empty));
});
return checkList;
#endregion
}
/// <summary> /// <summary>
/// 处理结算数据 /// 处理结算数据
/// </summary> /// </summary>

Loading…
Cancel
Save