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 a3d4a496..8c52fef0 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
@@ -122,6 +122,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
///
/// 导入
///
+ ///
+ /// JisBBAC结算数据导入(导入文件中包含买单件BBAC的数据)
+ /// 导入文件规则
+ /// * MovementType = 967,代表退货需要标记为负数
+ /// * MovementType = 966,代表正常发货标记正数
+ /// * PN中存在RO的数据为买单件BBAC的数据
+ /// 买单价PN特殊处理
+ /// * 获取导入PN后2位为生产码类型
+ /// * 获取导入PN前7位为PN
+ /// 验证结算分组号是否已存在
+ ///
[HttpPost]
public async Task ImportAsync([FromForm] BBACSaImportRequestDto bbacSaImportRequestDto)
{
@@ -158,7 +169,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
*/
maiDanSaDetails.ForEach(maiDanSaDetail =>
{
- maiDanSaDetail.PartCode = maiDanSaDetail.PN[^2..];
+ maiDanSaDetail.ProductionCodeType = maiDanSaDetail.PN[^2..];
maiDanSaDetail.PN = maiDanSaDetail.PN[..7];
});
@@ -247,63 +258,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
///
/// 删除
///
- [HttpPost]
- public async Task DeleteAsync(Guid id)
- {
- //结算主表
- BBAC_SA bbacSaDelEntity;
- //结算明细
- List bbacSaDetailDelEntitys;
- //可结算主表
- List bbacCanSaDelEntitys;
- //可结算明细
- List bbacCanSaDetailDelEntitys;
- //不可结算
- List bbacNotSaDetailDelEntitys;
-
- bbacSaDelEntity = await _bbacSaRepository.FindAsync(id).ConfigureAwait(false);
- if (bbacSaDelEntity == null)
- {
- throw new UserFriendlyException($"未获取到结算单!", "400");
- }
- //结算单据
- string bbacSaBillNum = bbacSaDelEntity.BillNum;
-
- bbacCanSaDelEntitys = await _bbacCanSaRepository.GetListAsync(t => t.SettleBillNum == bbacSaBillNum).ConfigureAwait(false);
- //验证可结算主表状态
- if (bbacCanSaDelEntitys.Any(t => t.State != SettleBillState.未结状态))
- {
- throw new UserFriendlyException($"该单据可结算单状态无法删除!", "400");
- }
-
- bbacSaDetailDelEntitys = await _bbacSaDetailRepository.GetListAsync(t => t.BillNum == bbacSaBillNum).ConfigureAwait(false);
- bbacCanSaDetailDelEntitys = await _bbacCanSaDetailRepository.GetListAsync(t => t.SettleBillNum == bbacSaBillNum).ConfigureAwait(false);
- bbacNotSaDetailDelEntitys = await _bbacNotSaDetailRepository.GetListAsync(t => t.SettleBillNum == bbacSaBillNum).ConfigureAwait(false);
-
- //删除
- await _bbacSaRepository.DeleteAsync(bbacSaDelEntity).ConfigureAwait(false);
- if (bbacSaDetailDelEntitys.Any())
- {
- await _bbacSaDetailRepository.DeleteManyAsync(bbacSaDetailDelEntitys).ConfigureAwait(false);
- }
- if (bbacCanSaDelEntitys.Any())
- {
- await _bbacCanSaRepository.DeleteManyAsync(bbacCanSaDelEntitys).ConfigureAwait(false);
- }
- if (bbacCanSaDetailDelEntitys.Any())
- {
- await _bbacCanSaDetailRepository.DeleteManyAsync(bbacCanSaDetailDelEntitys).ConfigureAwait(false);
- }
- if (bbacNotSaDetailDelEntitys.Any())
- {
- await _bbacNotSaDetailRepository.DeleteManyAsync(bbacNotSaDetailDelEntitys).ConfigureAwait(false);
- }
-
- }
-
- ///
- /// 删除
- ///
+ ///
+ /// 同时删除
+ /// 结算主表、明细表
+ /// 可结算主表、明细表
+ /// 不可结算明细表(不可结算没主表)
+ ///
[HttpPost]
public async Task DeleteListAsync(List ids)
{
@@ -364,6 +324,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
///
/// 处理结算数据
///
+ ///
+ /// 零件号(Lu)格式处理
+ /// 零件号可能存在颜色码 颜色码和塑件码中间统一用6个空格替换
+ /// PN有0开头的数据过滤 '‘’符号
+ ///
private List HandleSaDetails(List bbacSaDetails)
{
bbacSaDetails.ForEach(bbacSaDetail =>
@@ -378,15 +343,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
bbacSaDetail.PN = Regex.Replace(bbacSaDetail.PN, "['‘’]", "");
});
- return GroupPnLu(bbacSaDetails);
+ return bbacSaDetails;
}
///
- /// 结算数据分组Pn、Lu
+ /// 结算数据分组
///
- private List GroupPnLu(List bbacSaDetails)
+ ///
+ /// 根据PN、客户零件号、结算分组、结算日期分组合计数量
+ ///
+ private List GroupSaDetails(List bbacSaDetails)
{
- return bbacSaDetails.GroupBy(t => new { t.PN, t.LU }).Select(t =>
+ return bbacSaDetails.GroupBy(t => new { t.PN, t.LU, t.GroupNum, t.SettleDate }).Select(t =>
{
var bbacSaDetail = t.First();
bbacSaDetail.Qty = t.Sum(t => t.Qty);
@@ -397,8 +365,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
///
/// 结算数据处理
///
+ ///
+ /// 匹配价格
+ /// * 根据客户编码、业务、零件号、时间匹配价格
+ /// 匹配对应的厂内零件号
+ /// 结算数据入库
+ /// * 入库 结算主表、结算明细表、可结算主表、可结算明细表、不可结算明细表
+ ///
private async Task SaDataHandleAsync(List bbacSaDetails)
{
+ bbacSaDetails = GroupSaDetails(bbacSaDetails);
//结算单号
var bbacSaBillNum = OrderNumberGenerator.GenerateOrderNumber("SA");
//结算主表
@@ -442,7 +418,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//导入的零件号集合
var importPubSaLUs = bbacSaDetails.Select(t => t.LU).Distinct();
//销售价格
-
var priceListEntitys = GetPriceListEntitys(importPubSaLUs);
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => new List { EnumBusinessType.JisBBAC, EnumBusinessType.MaiDanJianBBAC }.Contains(t.BusinessType) && importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false);
bbacSaDetails.ForEach(bbacSaDetail =>
@@ -517,6 +492,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
///
/// 获取结算关联项
///
+ ///
+ /// 根据结算主表Id获取关联的结算主表、结算明细表、可结算主表、可结算明细表、不可结算明细表要删除的数据
+ /// 验证可结算主表状态
+ /// 只有可结算主表状态为未结状态时才可以删除结算数据
+ ///
private async Task<(List bbacSas, List bbacSaDetails, List bbacCanSas, List bbacCanSaDetails, List bbacNotSaDetails)> GetBBACSaDelItemsAsync(Guid id)
{
//结算主表
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/CompareService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/CompareService.cs
index 78cd4e95..74dbde82 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/CompareService.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/CompareService.cs
@@ -34,6 +34,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
///
/// Edi与发运比对
///
+ ///
+ /// JisBBAC、JisHBPO业务的Edi与发运比对
+ ///
[HttpPost]
public async Task EdiSeCompare(EdiSeCompareRequestDto ediSeCompareRequestDto)
{
@@ -72,6 +75,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
///
/// 结算与发运比对
///
+ ///
+ /// 所有业务的结算与发运比对
+ /// JisBBAC
+ /// JisHBPO
+ /// 直供件BBAC
+ /// 直供件HBPO
+ /// 买单件BBAC
+ /// 买单件HBPO
+ /// 备件
+ /// 印度件
+ ///
[HttpPost]
public async Task SaSeCompare(SaSeCompareRequestDto saSeCompareRequestDto)
{
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 3df5c8b0..d77c8aa2 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
@@ -145,7 +145,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[HttpPost]
public async Task> GetListAsync(RequestDto input)
{
- input.Filters.RemoveAll(t => t.Column.ToLower() == "site");
var entities = await _hbpoSaRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true).ConfigureAwait(false);
var totalCount = await _hbpoSaRepository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
var dtos = ObjectMapper.Map, List>(entities);
@@ -247,6 +246,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
///
/// 处理结算数据
///
+ ///
+ /// 零件号(Lu)格式处理
+ /// 零件号可能存在颜色码 颜色码和塑件码中间统一用6个空格替换
+ /// PN有0开头的数据过滤 '‘’符号
+ ///
private List HandleSaDetails(List hbpoSaDetails)
{
hbpoSaDetails.ForEach(hbpoSaDetail =>
@@ -264,15 +268,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
hbpoSaDetail.CustomerPartCodeNoSpace = hbpoSaDetail.LU.Replace(" ", "");
hbpoSaDetail.Version = Version;
});
- return GroupPnLu(hbpoSaDetails);
+ return hbpoSaDetails;
}
///
- /// 结算数据分组Pn、Lu
+ /// 结算数据分组
///
- private List GroupPnLu(List hbpoSaDetails)
+ ///
+ /// 根据PN、客户零件号、结算分组、结算日期分组合计数量
+ ///
+ private List GroupSaDetails(List hbpoSaDetails)
{
- return hbpoSaDetails.GroupBy(t => new { t.PN, t.LU }).Select(t =>
+ return hbpoSaDetails.GroupBy(t => new { t.PN, t.LU, t.GroupNum, t.SettleDate }).Select(t =>
{
var hbpoSaDetail = t.First();
hbpoSaDetail.Qty = t.Sum(t => t.Qty);
@@ -283,8 +290,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
///
/// 结算数据 Place 分组保存
///
- ///
- ///
+ ///
+ /// JisHBPO根据地点是否存在CN1\CN5分组保存结算数据
+ ///
private async Task SaDataGroupByPlaceAsync(List hbpoSaDetails)
{
if (!hbpoSaDetails.Any())
@@ -329,6 +337,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
///
private async Task InsertSaDataAsync(List hbpoSaDetails, string place)
{
+ hbpoSaDetails = GroupSaDetails(hbpoSaDetails);
var site = "104T";
//结算单号
var hbpoSaBillNum = OrderNumberGenerator.GenerateOrderNumber("SA");
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 8897d78b..98f1236d 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
@@ -429,7 +429,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
///
///
/// 零件号(Lu)格式处理
- /// 零件号可能存在颜色码 颜色码和塑件码中间用同一用6个空格替换
+ /// 零件号可能存在颜色码 颜色码和塑件码中间统一用6个空格替换
/// PN有0开头的数据过滤 '‘’符号
///
private List HandleSaDetails(List pubSaDetails)
@@ -446,19 +446,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
pubSaDetail.PN = Regex.Replace(pubSaDetail.PN, "['‘’]", "");
});
- return GroupPnLu(pubSaDetails);
+ return pubSaDetails;
}
///
- /// 结算数据分组Pn、Lu
+ /// 结算数据分组
///
///
- /// 导入文件中可能存在PN+LU相同的数据
- /// 根据PN+LU分组合计数量后导入
+ /// 根据PN、客户零件号、结算分组、结算日期分组合计数量
///
- private List GroupPnLu(List pubSaDetails)
+ private List GroupSaDetails(List pubSaDetails)
{
- return pubSaDetails.GroupBy(t => new { t.PN, t.LU }).Select(t =>
+ return pubSaDetails.GroupBy(t => new { t.PN, t.LU, t.GroupNum, t.SettleDate }).Select(t =>
{
var pubSaDetail = t.First();
pubSaDetail.Qty = t.Sum(t => t.Qty);
@@ -470,12 +469,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// Insert结算数据
///
///
+ /// 结算数据分组
+ /// * 备件不需要分组
/// 匹配价格
/// * 根据客户编码、业务、零件号、时间匹配价格
/// 匹配对应的厂内零件号
///
private async Task InsertSaDataAsync(List pubSaDetails, EnumBusinessType businessType)
{
+ if (businessType != EnumBusinessType.BeiJian)
+ {
+ pubSaDetails = GroupSaDetails(pubSaDetails);
+ }
#region 处理结算数据
//导入的零件号集合
var lus = pubSaDetails.Select(t => t.LU).Distinct().ToList();