|
|
@ -135,7 +135,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
version = pubSaImportRequestDto.Version; |
|
|
|
businessType = pubSaImportRequestDto.BusinessType; |
|
|
|
site = pubSaImportRequestDto.Site; |
|
|
|
switch (pubSaImportRequestDto.BusinessType) |
|
|
|
switch (businessType) |
|
|
|
{ |
|
|
|
case EnumBusinessType.ZhiGongJianBBAC: |
|
|
|
result = await ImportZhiGongJianBBACAsync(pubSaImportRequestDto.Files).ConfigureAwait(false); |
|
|
@ -301,7 +301,29 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
importPubSaDetails = HandleSaDetails(importPubSaDetails); |
|
|
|
|
|
|
|
#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) |
|
|
|
{ |
|
|
|
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false); |
|
|
@ -404,23 +426,40 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
if (!checkList.Any()) |
|
|
|
{ |
|
|
|
//验证客户对应厂内零件号是否存在
|
|
|
|
//导入的零件号集合
|
|
|
|
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)); |
|
|
|
}); |
|
|
|
checkList.AddRange(await CheckMaterialRelationshipAsync(pubSaDetails).ConfigureAwait(false)); |
|
|
|
} |
|
|
|
|
|
|
|
return checkList; |
|
|
|
#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>
|
|
|
|