|
@ -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 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); |
|
|
var importHBOPSaDetails = ObjectMapper.Map<List<HBPO_SA_DETAIL_IMPORT_DTO>, List<HBPO_SA_DETAIL>>(result); |
|
|
|
|
|
|
|
|
HandleSaDetails(importHBOPSaDetails); |
|
|
importHBOPSaDetails = HandleSaDetails(importHBOPSaDetails); |
|
|
|
|
|
|
|
|
//Site包含CN1 亦庄
|
|
|
//Site包含CN1 亦庄
|
|
|
//Site包含CN5 顺义
|
|
|
//Site包含CN5 顺义
|
|
@ -237,11 +237,11 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA> |
|
|
|
|
|
|
|
|
if (importCN1HBOPSaDetails.Any()) |
|
|
if (importCN1HBOPSaDetails.Any()) |
|
|
{ |
|
|
{ |
|
|
await SaDataHandleAsync(importCN1HBOPSaDetails, "CN1").ConfigureAwait(false); |
|
|
await InsertSaDataAsync(importCN1HBOPSaDetails, "CN1").ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
if (importCN5HBOPSaDetails.Any()) |
|
|
if (importCN5HBOPSaDetails.Any()) |
|
|
{ |
|
|
{ |
|
|
await SaDataHandleAsync(importCN5HBOPSaDetails, "CN5").ConfigureAwait(false); |
|
|
await InsertSaDataAsync(importCN5HBOPSaDetails, "CN5").ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return new JsonResult(new { Code = 200, Message = "导入成功" }); |
|
|
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 = "导入成功" }); |
|
|
return new JsonResult(new { Code = 200, Message = "导入成功" }); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
HandleSaDetails(importMaiDanHBPOSaDetails); |
|
|
importMaiDanHBPOSaDetails = HandleSaDetails(importMaiDanHBPOSaDetails); |
|
|
|
|
|
|
|
|
#region 数据校验
|
|
|
#region 数据校验
|
|
|
var checkList = await CheckAsync(importMaiDanHBPOSaDetails).ConfigureAwait(false); |
|
|
var checkList = await CheckAsync(importMaiDanHBPOSaDetails).ConfigureAwait(false); |
|
@ -274,14 +274,50 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA> |
|
|
} |
|
|
} |
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
await SaDataHandleAsync(importMaiDanHBPOSaDetails, "").ConfigureAwait(false); |
|
|
await InsertSaDataAsync(importMaiDanHBPOSaDetails, "").ConfigureAwait(false); |
|
|
return new JsonResult(new { Code = 200, Message = "导入成功" }); |
|
|
return new JsonResult(new { Code = 200, Message = "导入成功" }); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 结算数据处理
|
|
|
/// 处理结算数据
|
|
|
/// </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"); |
|
|
var hbpoSaBillNum = OrderNumberGenerator.GenerateOrderNumber("SA"); |
|
@ -420,27 +456,6 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA> |
|
|
return (hbpoSas, hbpoSaDetails, hbpoCanSas, hbpoCanSaDetails, hbpoNotSaDetails); |
|
|
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>
|
|
|
/// 数据校验
|
|
|
/// 数据校验
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|