diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_SA_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_SA_DTO.cs
index d90ba01f..feee168f 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_SA_DTO.cs
+++ b/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; }
-
///
/// 结算分组号
///
@@ -139,7 +138,6 @@ public class BBAC_SA_DETAIL_IMPORT_DTO
[Required(ErrorMessage = "{0}不能为空")]
[ImporterHeader(Name = "Reference")]
public string GroupNum { get; set; }
-
///
/// 客户零件号
///
@@ -147,14 +145,12 @@ public class BBAC_SA_DETAIL_IMPORT_DTO
[Required(ErrorMessage = "{0}不能为空")]
[ImporterHeader(Name = "Material")]
public string LU { get; set; }
-
///
/// 数量
///
[Display(Name = "结算数量")]
[ImporterHeader(Name = "GR Quantity")]
public decimal Qty { get; set; }
-
///
/// 生产号
///
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs
index ad1c3659..0c034354 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs
@@ -134,17 +134,9 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase
var importBBACSaDetails = ObjectMapper.Map, List>(importDtos);
+ importBBACSaDetails = HandleSaDetails(importBBACSaDetails);
importBBACSaDetails.ForEach(importBBACSaDetail =>
{
- List 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
#endregion
#region 私有方法
+ ///
+ /// 处理结算数据
+ ///
+ private List HandleSaDetails(List 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);
+ }
+
+ ///
+ /// 结算数据分组Pn、Lu
+ ///
+ private List GroupPnLu(List 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();
+ }
+
///
/// 结算数据处理
///
@@ -365,17 +390,9 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase
bbacSaDetails.ForEach(bbacSaDetail =>
{
bbacSaDetail.SetId(GuidGenerator.Create());
- List 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;
});
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs
index e7bde6c2..3c1bff65 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs
@@ -219,7 +219,7 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase
var result = await _exportImporter.UploadExcelImport(files, _excelImportService).ConfigureAwait(false);
var importHBOPSaDetails = ObjectMapper.Map, List>(result);
- HandleSaDetails(importHBOPSaDetails);
+ importHBOPSaDetails = HandleSaDetails(importHBOPSaDetails);
//Site包含CN1 亦庄
//Site包含CN5 顺义
@@ -237,11 +237,11 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase
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
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
}
#endregion
- await SaDataHandleAsync(importMaiDanHBPOSaDetails, "").ConfigureAwait(false);
+ await InsertSaDataAsync(importMaiDanHBPOSaDetails, "").ConfigureAwait(false);
return new JsonResult(new { Code = 200, Message = "导入成功" });
}
///
- /// 结算数据处理
+ /// 处理结算数据
///
- private async Task SaDataHandleAsync(List hbpoSaDetails, string site)
+ private List HandleSaDetails(List 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);
+ }
+
+ ///
+ /// 结算数据分组Pn、Lu
+ ///
+ private List GroupPnLu(List 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();
+ }
+
+ ///
+ /// Insert结算数据
+ ///
+ private async Task InsertSaDataAsync(List hbpoSaDetails, string site)
{
//结算单号
var hbpoSaBillNum = OrderNumberGenerator.GenerateOrderNumber("SA");
@@ -420,27 +456,6 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase
return (hbpoSas, hbpoSaDetails, hbpoCanSas, hbpoCanSaDetails, hbpoNotSaDetails);
}
- ///
- /// 结算数据处理
- ///
- private void HandleSaDetails(List 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;
- });
- }
-
///
/// 数据校验
///
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
index 9c09ef72..592dbb43 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
@@ -239,7 +239,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase
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
}
#endregion
- return await SaDataHandleAsync(importPubSaDetails, EnumBusinessType.ZhiGongJianBBAC).ConfigureAwait(false);
+ return await InsertSaDataAsync(importPubSaDetails, EnumBusinessType.ZhiGongJianBBAC).ConfigureAwait(false);
}
///
@@ -276,7 +276,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase
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
}
#endregion
- return await SaDataHandleAsync(importPubSaDetails, EnumBusinessType.ZhiGongJianHBPO).ConfigureAwait(false);
+ return await InsertSaDataAsync(importPubSaDetails, EnumBusinessType.ZhiGongJianHBPO).ConfigureAwait(false);
}
///
@@ -306,7 +306,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase
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
}
#endregion
- return await SaDataHandleAsync(importPubSaDetails, EnumBusinessType.BeiJian).ConfigureAwait(false);
+ return await InsertSaDataAsync(importPubSaDetails, EnumBusinessType.BeiJian).ConfigureAwait(false);
}
///
@@ -337,7 +337,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase
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
}
#endregion
- return await SaDataHandleAsync(importPubSaDetails, EnumBusinessType.YinDuJian).ConfigureAwait(false);
+ return await InsertSaDataAsync(importPubSaDetails, EnumBusinessType.YinDuJian).ConfigureAwait(false);
}
///
@@ -392,10 +392,9 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase
}
///
- /// 处理结算数据LU
+ /// 处理结算数据
///
- ///
- private void HandleSaDetailLU(List pubSaDetails)
+ private List HandleSaDetails(List pubSaDetails)
{
pubSaDetails.ForEach(pubSaDetail =>
{
@@ -408,12 +407,27 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase
pubSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index);
}
});
+
+ return GroupPnLu(pubSaDetails);
+ }
+
+ ///
+ /// 结算数据分组Pn、Lu
+ ///
+ private List GroupPnLu(List 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();
}
///
- /// 结算数据处理
+ /// Insert结算数据
///
- private async Task SaDataHandleAsync(List pubSaDetails, EnumBusinessType businessType)
+ private async Task InsertSaDataAsync(List pubSaDetails, EnumBusinessType businessType)
{
//客户零件关系
var materialRelationships = new List();