Browse Source

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

master
学 赵 1 year ago
parent
commit
396bb44109
  1. 106
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs
  2. 14
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/CompareService.cs
  3. 23
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs
  4. 19
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs

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

@ -122,6 +122,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// <summary>
/// 导入
/// </summary>
/// <remarks>
/// JisBBAC结算数据导入(导入文件中包含买单件BBAC的数据)
/// 导入文件规则
/// * MovementType = 967,代表退货需要标记为负数
/// * MovementType = 966,代表正常发货标记正数
/// * PN中存在RO的数据为买单件BBAC的数据
/// 买单价PN特殊处理
/// * 获取导入PN后2位为生产码类型
/// * 获取导入PN前7位为PN
/// 验证结算分组号是否已存在
/// </remarks>
[HttpPost]
public async Task<IActionResult> 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
/// <summary>
/// 删除
/// </summary>
[HttpPost]
public async Task DeleteAsync(Guid id)
{
//结算主表
BBAC_SA bbacSaDelEntity;
//结算明细
List<BBAC_SA_DETAIL> bbacSaDetailDelEntitys;
//可结算主表
List<BBAC_CAN_SA> bbacCanSaDelEntitys;
//可结算明细
List<BBAC_CAN_SA_DETAIL> bbacCanSaDetailDelEntitys;
//不可结算
List<BBAC_NOT_SA_DETAIL> 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);
}
}
/// <summary>
/// 删除
/// </summary>
/// <remarks>
/// 同时删除
/// 结算主表、明细表
/// 可结算主表、明细表
/// 不可结算明细表(不可结算没主表)
/// </remarks>
[HttpPost]
public async Task DeleteListAsync(List<Guid> ids)
{
@ -364,6 +324,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// <summary>
/// 处理结算数据
/// </summary>
/// <remarks>
/// 零件号(Lu)格式处理
/// 零件号可能存在颜色码 颜色码和塑件码中间统一用6个空格替换
/// PN有0开头的数据过滤 '‘’符号
/// </remarks>
private List<BBAC_SA_DETAIL> HandleSaDetails(List<BBAC_SA_DETAIL> 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;
}
/// <summary>
/// 结算数据分组Pn、Lu
/// 结算数据分组
/// </summary>
private List<BBAC_SA_DETAIL> GroupPnLu(List<BBAC_SA_DETAIL> bbacSaDetails)
/// <remarks>
/// 根据PN、客户零件号、结算分组、结算日期分组合计数量
/// </remarks>
private List<BBAC_SA_DETAIL> GroupSaDetails(List<BBAC_SA_DETAIL> 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
/// <summary>
/// 结算数据处理
/// </summary>
/// <remarks>
/// 匹配价格
/// * 根据客户编码、业务、零件号、时间匹配价格
/// 匹配对应的厂内零件号
/// 结算数据入库
/// * 入库 结算主表、结算明细表、可结算主表、可结算明细表、不可结算明细表
/// </remarks>
private async Task SaDataHandleAsync(List<BBAC_SA_DETAIL> 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> { 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
/// <summary>
/// 获取结算关联项
/// </summary>
/// <remarks>
/// 根据结算主表Id获取关联的结算主表、结算明细表、可结算主表、可结算明细表、不可结算明细表要删除的数据
/// 验证可结算主表状态
/// 只有可结算主表状态为未结状态时才可以删除结算数据
/// </remarks>
private async Task<(List<BBAC_SA> bbacSas, List<BBAC_SA_DETAIL> bbacSaDetails, List<BBAC_CAN_SA> bbacCanSas, List<BBAC_CAN_SA_DETAIL> bbacCanSaDetails, List<BBAC_NOT_SA_DETAIL> bbacNotSaDetails)> GetBBACSaDelItemsAsync(Guid id)
{
//结算主表

14
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/CompareService.cs

@ -34,6 +34,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// <summary>
/// Edi与发运比对
/// </summary>
/// <remarks>
/// JisBBAC、JisHBPO业务的Edi与发运比对
/// </remarks>
[HttpPost]
public async Task<string> EdiSeCompare(EdiSeCompareRequestDto ediSeCompareRequestDto)
{
@ -72,6 +75,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// <summary>
/// 结算与发运比对
/// </summary>
/// <remarks>
/// 所有业务的结算与发运比对
/// JisBBAC
/// JisHBPO
/// 直供件BBAC
/// 直供件HBPO
/// 买单件BBAC
/// 买单件HBPO
/// 备件
/// 印度件
/// </remarks>
[HttpPost]
public async Task<string> SaSeCompare(SaSeCompareRequestDto saSeCompareRequestDto)
{

23
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<PagedResultDto<HBPO_SA_DTO>> 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<HBPO_SA>, List<HBPO_SA_DTO>>(entities);
@ -247,6 +246,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// <summary>
/// 处理结算数据
/// </summary>
/// <remarks>
/// 零件号(Lu)格式处理
/// 零件号可能存在颜色码 颜色码和塑件码中间统一用6个空格替换
/// PN有0开头的数据过滤 '‘’符号
/// </remarks>
private List<HBPO_SA_DETAIL> HandleSaDetails(List<HBPO_SA_DETAIL> 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;
}
/// <summary>
/// 结算数据分组Pn、Lu
/// 结算数据分组
/// </summary>
private List<HBPO_SA_DETAIL> GroupPnLu(List<HBPO_SA_DETAIL> hbpoSaDetails)
/// <remarks>
/// 根据PN、客户零件号、结算分组、结算日期分组合计数量
/// </remarks>
private List<HBPO_SA_DETAIL> GroupSaDetails(List<HBPO_SA_DETAIL> 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
/// <summary>
/// 结算数据 Place 分组保存
/// </summary>
/// <param name="hbpoSaDetails"></param>
/// <returns></returns>
/// <remarks>
/// JisHBPO根据地点是否存在CN1\CN5分组保存结算数据
/// </remarks>
private async Task<IActionResult> SaDataGroupByPlaceAsync(List<HBPO_SA_DETAIL> hbpoSaDetails)
{
if (!hbpoSaDetails.Any())
@ -329,6 +337,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// </remarks>
private async Task InsertSaDataAsync(List<HBPO_SA_DETAIL> hbpoSaDetails, string place)
{
hbpoSaDetails = GroupSaDetails(hbpoSaDetails);
var site = "104T";
//结算单号
var hbpoSaBillNum = OrderNumberGenerator.GenerateOrderNumber("SA");

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

@ -429,7 +429,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// </summary>
/// <remarks>
/// 零件号(Lu)格式处理
/// 零件号可能存在颜色码 颜色码和塑件码中间用同一用6个空格替换
/// 零件号可能存在颜色码 颜色码和塑件码中间一用6个空格替换
/// PN有0开头的数据过滤 '‘’符号
/// </remarks>
private List<PUB_SA_DETAIL> HandleSaDetails(List<PUB_SA_DETAIL> pubSaDetails)
@ -446,19 +446,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
pubSaDetail.PN = Regex.Replace(pubSaDetail.PN, "['‘’]", "");
});
return GroupPnLu(pubSaDetails);
return pubSaDetails;
}
/// <summary>
/// 结算数据分组Pn、Lu
/// 结算数据分组
/// </summary>
/// <remarks>
/// 导入文件中可能存在PN+LU相同的数据
/// 根据PN+LU分组合计数量后导入
/// 根据PN、客户零件号、结算分组、结算日期分组合计数量
/// </remarks>
private List<PUB_SA_DETAIL> GroupPnLu(List<PUB_SA_DETAIL> pubSaDetails)
private List<PUB_SA_DETAIL> GroupSaDetails(List<PUB_SA_DETAIL> 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结算数据
/// </summary>
/// <remarks>
/// 结算数据分组
/// * 备件不需要分组
/// 匹配价格
/// * 根据客户编码、业务、零件号、时间匹配价格
/// 匹配对应的厂内零件号
/// </remarks>
private async Task<IActionResult> InsertSaDataAsync(List<PUB_SA_DETAIL> pubSaDetails, EnumBusinessType businessType)
{
if (businessType != EnumBusinessType.BeiJian)
{
pubSaDetails = GroupSaDetails(pubSaDetails);
}
#region 处理结算数据
//导入的零件号集合
var lus = pubSaDetails.Select(t => t.LU).Distinct().ToList();

Loading…
Cancel
Save