Browse Source

结算数据根据PN+LU分组导入

master
mahao 1 year ago
parent
commit
66f17fa2c7
  1. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_SA_DTO.cs
  2. 53
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs
  3. 71
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs
  4. 40
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs

4
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_SA_DTO.cs

@ -131,7 +131,6 @@ public class BBAC_SA_DETAIL_IMPORT_DTO
[Display(Name = "Posting Date")]
[ImporterHeader(Name = "Posting Date")]
public string SettleDate { set; get; }
/// <summary>
/// 结算分组号
/// </summary>
@ -139,7 +138,6 @@ public class BBAC_SA_DETAIL_IMPORT_DTO
[Required(ErrorMessage = "{0}不能为空")]
[ImporterHeader(Name = "Reference")]
public string GroupNum { get; set; }
/// <summary>
/// 客户零件号
/// </summary>
@ -147,14 +145,12 @@ public class BBAC_SA_DETAIL_IMPORT_DTO
[Required(ErrorMessage = "{0}不能为空")]
[ImporterHeader(Name = "Material")]
public string LU { get; set; }
/// <summary>
/// 数量
/// </summary>
[Display(Name = "结算数量")]
[ImporterHeader(Name = "GR Quantity")]
public decimal Qty { get; set; }
/// <summary>
/// 生产号
/// </summary>

53
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs

@ -134,17 +134,9 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
var importBBACSaDetails = ObjectMapper.Map<List<BBAC_SA_DETAIL_IMPORT_DTO>, List<BBAC_SA_DETAIL>>(importDtos);
importBBACSaDetails = HandleSaDetails(importBBACSaDetails);
importBBACSaDetails.ForEach(importBBACSaDetail =>
{
List<string> lus = importBBACSaDetail.LU.Split(" ").ToList();
importBBACSaDetail.LU = lus[0].Replace(" ", "");
if (lus.Count > 1)
{
lus.RemoveAt(0);
var luAssemble = lus.Select(t => t.Replace(" ", ""));
importBBACSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index);
}
importBBACSaDetail.CustomerPartCodeNoSpace = importBBACSaDetail.LU.Replace(" ", "");
importBBACSaDetail.Version = Version;
importBBACSaDetail.Site = Site;
});
@ -325,6 +317,39 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
#endregion
#region 私有方法
/// <summary>
/// 处理结算数据
/// </summary>
private List<BBAC_SA_DETAIL> HandleSaDetails(List<BBAC_SA_DETAIL> bbacSaDetails)
{
bbacSaDetails.ForEach(bbacSaDetail =>
{
var lus = bbacSaDetail.LU.Split(" ").ToList();
bbacSaDetail.LU = lus[0].Replace(" ", "");
if (lus.Count > 1)
{
lus.RemoveAt(0);
var luAssemble = lus.Select(t => t.Replace(" ", ""));
bbacSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index);
}
});
return GroupPnLu(bbacSaDetails);
}
/// <summary>
/// 结算数据分组Pn、Lu
/// </summary>
private List<BBAC_SA_DETAIL> GroupPnLu(List<BBAC_SA_DETAIL> bbacSaDetails)
{
return bbacSaDetails.GroupBy(t => new { t.PN, t.LU }).Select(t =>
{
var bbacSaDetail = t.First();
bbacSaDetail.Qty = t.Sum(t => t.Qty);
return bbacSaDetail;
}).ToList();
}
/// <summary>
/// 结算数据处理
/// </summary>
@ -365,17 +390,9 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
bbacSaDetails.ForEach(bbacSaDetail =>
{
bbacSaDetail.SetId(GuidGenerator.Create());
List<string> lus = bbacSaDetail.LU.Split(" ").ToList();
bbacSaDetail.LU = lus[0].Replace(" ", "");
if (lus.Count > 1)
{
lus.RemoveAt(0);
var luAssemble = lus.Select(t => t.Replace(" ", ""));
bbacSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index);
}
bbacSaDetail.BillNum = bbacSaBillNum;
bbacSaDetail.KeyCode = bbacSaDetail.PN + bbacSaDetail.LU;
bbacSaDetail.CustomerPartCodeNoSpace = bbacSaDetail.LU.Replace(" ", "");
bbacSaDetail.BusinessType = bbacSaDetail.PN.Contains("R0") ? EnumBusinessType.MaiDanJianBBAC : _businessType;
});

71
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs

@ -219,7 +219,7 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
var result = await _exportImporter.UploadExcelImport<HBPO_SA_DETAIL_IMPORT_DTO>(files, _excelImportService).ConfigureAwait(false);
var importHBOPSaDetails = ObjectMapper.Map<List<HBPO_SA_DETAIL_IMPORT_DTO>, List<HBPO_SA_DETAIL>>(result);
HandleSaDetails(importHBOPSaDetails);
importHBOPSaDetails = HandleSaDetails(importHBOPSaDetails);
//Site包含CN1 亦庄
//Site包含CN5 顺义
@ -237,11 +237,11 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
if (importCN1HBOPSaDetails.Any())
{
await SaDataHandleAsync(importCN1HBOPSaDetails, "CN1").ConfigureAwait(false);
await InsertSaDataAsync(importCN1HBOPSaDetails, "CN1").ConfigureAwait(false);
}
if (importCN5HBOPSaDetails.Any())
{
await SaDataHandleAsync(importCN5HBOPSaDetails, "CN5").ConfigureAwait(false);
await InsertSaDataAsync(importCN5HBOPSaDetails, "CN5").ConfigureAwait(false);
}
return new JsonResult(new { Code = 200, Message = "导入成功" });
@ -263,7 +263,7 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
return new JsonResult(new { Code = 200, Message = "导入成功" });
}
HandleSaDetails(importMaiDanHBPOSaDetails);
importMaiDanHBPOSaDetails = HandleSaDetails(importMaiDanHBPOSaDetails);
#region 数据校验
var checkList = await CheckAsync(importMaiDanHBPOSaDetails).ConfigureAwait(false);
@ -274,14 +274,50 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
}
#endregion
await SaDataHandleAsync(importMaiDanHBPOSaDetails, "").ConfigureAwait(false);
await InsertSaDataAsync(importMaiDanHBPOSaDetails, "").ConfigureAwait(false);
return new JsonResult(new { Code = 200, Message = "导入成功" });
}
/// <summary>
/// 结算数据处理
/// 处理结算数据
/// </summary>
private async Task SaDataHandleAsync(List<HBPO_SA_DETAIL> hbpoSaDetails, string site)
private List<HBPO_SA_DETAIL> HandleSaDetails(List<HBPO_SA_DETAIL> hbpoSaDetails)
{
hbpoSaDetails.ForEach(hbpoSaDetail =>
{
hbpoSaDetail.SetId(GuidGenerator.Create());
var lus = hbpoSaDetail.LU.Split(" ").ToList();
hbpoSaDetail.LU = lus[0].Replace(" ", "");
if (lus.Count > 1)
{
lus.RemoveAt(0);
var luAssemble = lus.Select(t => t.Replace(" ", ""));
hbpoSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index);
}
hbpoSaDetail.CustomerPartCodeNoSpace = hbpoSaDetail.LU.Replace(" ", "");
hbpoSaDetail.Version = Version;
});
return GroupPnLu(hbpoSaDetails);
}
/// <summary>
/// 结算数据分组Pn、Lu
/// </summary>
private List<HBPO_SA_DETAIL> GroupPnLu(List<HBPO_SA_DETAIL> hbpoSaDetails)
{
return hbpoSaDetails.GroupBy(t => new { t.PN, t.LU }).Select(t =>
{
var hbpoSaDetail = t.First();
hbpoSaDetail.Qty = t.Sum(t => t.Qty);
return hbpoSaDetail;
}).ToList();
}
/// <summary>
/// Insert结算数据
/// </summary>
private async Task InsertSaDataAsync(List<HBPO_SA_DETAIL> hbpoSaDetails, string site)
{
//结算单号
var hbpoSaBillNum = OrderNumberGenerator.GenerateOrderNumber("SA");
@ -420,27 +456,6 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
return (hbpoSas, hbpoSaDetails, hbpoCanSas, hbpoCanSaDetails, hbpoNotSaDetails);
}
/// <summary>
/// 结算数据处理
/// </summary>
private void HandleSaDetails(List<HBPO_SA_DETAIL> hbpoSaDetails)
{
hbpoSaDetails.ForEach(hbpoSaDetail =>
{
hbpoSaDetail.SetId(GuidGenerator.Create());
var lus = hbpoSaDetail.LU.Split(" ").ToList();
hbpoSaDetail.LU = lus[0].Replace(" ", "");
if (lus.Count > 1)
{
lus.RemoveAt(0);
var luAssemble = lus.Select(t => t.Replace(" ", ""));
hbpoSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index);
}
hbpoSaDetail.CustomerPartCodeNoSpace = hbpoSaDetail.LU.Replace(" ", "");
hbpoSaDetail.Version = Version;
});
}
/// <summary>
/// 数据校验
/// </summary>

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

@ -239,7 +239,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
return new JsonResult(new { Code = 200, Message = "导入成功" });
}
HandleSaDetailLU(importPubSaDetails);
importPubSaDetails = HandleSaDetails(importPubSaDetails);
#region 数据校验
var checkList = await CheckAsync(importPubSaDetails).ConfigureAwait(false);
@ -250,7 +250,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
}
#endregion
return await SaDataHandleAsync(importPubSaDetails, EnumBusinessType.ZhiGongJianBBAC).ConfigureAwait(false);
return await InsertSaDataAsync(importPubSaDetails, EnumBusinessType.ZhiGongJianBBAC).ConfigureAwait(false);
}
/// <summary>
@ -276,7 +276,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
return new JsonResult(new { Code = 200, Message = "导入成功" });
}
HandleSaDetailLU(importPubSaDetails);
importPubSaDetails = HandleSaDetails(importPubSaDetails);
#region 数据校验
var checkList = await CheckAsync(importPubSaDetails);
@ -287,7 +287,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
}
#endregion
return await SaDataHandleAsync(importPubSaDetails, EnumBusinessType.ZhiGongJianHBPO).ConfigureAwait(false);
return await InsertSaDataAsync(importPubSaDetails, EnumBusinessType.ZhiGongJianHBPO).ConfigureAwait(false);
}
/// <summary>
@ -306,7 +306,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
return new JsonResult(new { Code = 200, Message = "导入成功" });
}
HandleSaDetailLU(importPubSaDetails);
importPubSaDetails = HandleSaDetails(importPubSaDetails);
#region 数据校验
var checkList = await CheckAsync(importPubSaDetails).ConfigureAwait(false);
@ -317,7 +317,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
}
#endregion
return await SaDataHandleAsync(importPubSaDetails, EnumBusinessType.BeiJian).ConfigureAwait(false);
return await InsertSaDataAsync(importPubSaDetails, EnumBusinessType.BeiJian).ConfigureAwait(false);
}
/// <summary>
@ -337,7 +337,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
return new JsonResult(new { Code = 200, Message = "导入成功" });
}
HandleSaDetailLU(importPubSaDetails);
importPubSaDetails = HandleSaDetails(importPubSaDetails);
#region 数据校验
var checkList = await CheckAsync(importPubSaDetails).ConfigureAwait(false);
@ -348,7 +348,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
}
#endregion
return await SaDataHandleAsync(importPubSaDetails, EnumBusinessType.YinDuJian).ConfigureAwait(false);
return await InsertSaDataAsync(importPubSaDetails, EnumBusinessType.YinDuJian).ConfigureAwait(false);
}
/// <summary>
@ -392,10 +392,9 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
}
/// <summary>
/// 处理结算数据LU
/// 处理结算数据
/// </summary>
/// <param name="pubSaDetails"></param>
private void HandleSaDetailLU(List<PUB_SA_DETAIL> pubSaDetails)
private List<PUB_SA_DETAIL> HandleSaDetails(List<PUB_SA_DETAIL> pubSaDetails)
{
pubSaDetails.ForEach(pubSaDetail =>
{
@ -408,12 +407,27 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
pubSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index);
}
});
return GroupPnLu(pubSaDetails);
}
/// <summary>
/// 结算数据分组Pn、Lu
/// </summary>
private List<PUB_SA_DETAIL> GroupPnLu(List<PUB_SA_DETAIL> pubSaDetails)
{
return pubSaDetails.GroupBy(t => new { t.PN, t.LU }).Select(t =>
{
var pubSaDetail = t.First();
pubSaDetail.Qty = t.Sum(t => t.Qty);
return pubSaDetail;
}).ToList();
}
/// <summary>
/// 结算数据处理
/// Insert结算数据
/// </summary>
private async Task<IActionResult> SaDataHandleAsync(List<PUB_SA_DETAIL> pubSaDetails, EnumBusinessType businessType)
private async Task<IActionResult> InsertSaDataAsync(List<PUB_SA_DETAIL> pubSaDetails, EnumBusinessType businessType)
{
//客户零件关系
var materialRelationships = new List<MaterialRelationship>();

Loading…
Cancel
Save