Browse Source

Merge branch 'master' of http://dev.ccwin-in.com:3000/BoXu.Zheng/BeiJinSettleAccount

master
学 赵 1 year ago
parent
commit
3d0d383fae
  1. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs
  2. 41
      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; }
} }

41
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
{ {
@ -117,12 +118,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// 提交到QAD /// 提交到QAD
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// 已扣减发票提交到QAD /// * 已扣减发票提交到QAD
/// 查询状态为已扣减的数据 /// * 查询状态为已扣减的数据
/// 判断ParentInvbillNum是否有数据 /// * 判断ParentInvbillNum是否有数据
/// 有数据查询出对应发票数据状态为已提交QAD(置换成负数据)需要提交到QAD /// * 有数据查询出对应发票数据状态为已提交QAD(置换成负数据)需要提交到QAD
/// 已扣减的数据提交到QAD /// * 已扣减的数据提交到QAD
/// 成功提交后修改状态为已提交QAD /// * 成功提交后修改状态为已提交QAD
/// </remarks> /// </remarks>
[HttpPost] [HttpPost]
public virtual async Task<IActionResult> SubmitToQad(List<string> invbillNums) public virtual async Task<IActionResult> SubmitToQad(List<string> invbillNums)
@ -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);
@ -576,11 +587,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
.GroupBy(p => new { p.LU, p.SettleGroupNum }) .GroupBy(p => new { p.LU, p.SettleGroupNum })
.Select(p => new JIT_UNSETTLED_DETAIL_DTO { LU = p.Key.LU, GroupNum = p.Key.SettleGroupNum, Qty = p.Sum(itm => itm.Qty.Value) }); .Select(p => new JIT_UNSETTLED_DETAIL_DTO { LU = p.Key.LU, GroupNum = p.Key.SettleGroupNum, Qty = p.Sum(itm => itm.Qty.Value) });
entity.JIT_UNSETTLED_DETAIL = unsettledList.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList(); entity.JIT_UNSETTLED_DETAIL = unsettledList.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList();
entity.INVOICE_MAP_GROUP =mdtos;
} }
if (first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO) if (first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO)
{ {
@ -744,13 +750,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
_excel.Append(jitunsettle, "未结零件汇总"); _excel.Append(jitunsettle, "未结零件汇总");
} }
if (m != null)
{
_excel.Append(m, "发票结算分组对应");
}
} }
//jis业务,发票分组对应关系,未结数据,调整数据 //jis业务,发票分组对应关系,未结数据,调整数据
if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO) if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO)

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