|
|
@ -114,14 +114,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA> |
|
|
|
#region 导入数据转换、数据校验
|
|
|
|
ExportImporter _exportImporter = new ExportImporter(); |
|
|
|
var importDtos = await _exportImporter.UploadExcelImport<BBAC_SA_DETAIL_IMPORT_DTO>(files, _excelImportService); |
|
|
|
|
|
|
|
//JisBBAC
|
|
|
|
var importHBOPDtos = importDtos.FindAll(t => t.PN.Contains("R0") == false); |
|
|
|
//买单件BBAC
|
|
|
|
var importMaiDanJianHBOPDtos = importDtos.FindAll(t => t.PN.Contains("R0")); |
|
|
|
|
|
|
|
var importBBACSaDetails = ObjectMapper.Map<List<BBAC_SA_DETAIL_IMPORT_DTO>, List<BBAC_SA_DETAIL>>(importHBOPDtos); |
|
|
|
var importMaiDanJianBBACSaDetails = ObjectMapper.Map<List<BBAC_SA_DETAIL_IMPORT_DTO>, List<PUB_SA_DETAIL>>(importHBOPDtos); |
|
|
|
var importBBACSaDetails = ObjectMapper.Map<List<BBAC_SA_DETAIL_IMPORT_DTO>, List<BBAC_SA_DETAIL>>(importDtos); |
|
|
|
|
|
|
|
//数据校验
|
|
|
|
var checkList = new List<ErrorExportDto>(); |
|
|
@ -139,14 +132,14 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA> |
|
|
|
|
|
|
|
if (checkList.Count > 0) |
|
|
|
{ |
|
|
|
string fileName = await ExportErrorReportAsync(checkList); |
|
|
|
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false); |
|
|
|
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName }); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
if (importBBACSaDetails.Any()) |
|
|
|
{ |
|
|
|
await SaDataHandleAsync(importBBACSaDetails, importMaiDanJianBBACSaDetails); |
|
|
|
await SaDataHandleAsync(importBBACSaDetails).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
return new JsonResult(new { Code = 200, Message = "导入成功" }); |
|
|
@ -286,7 +279,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA> |
|
|
|
/// <summary>
|
|
|
|
/// 结算数据处理
|
|
|
|
/// </summary>
|
|
|
|
private async Task SaDataHandleAsync(List<BBAC_SA_DETAIL> bbacSaDetails, List<PUB_SA_DETAIL> maiDanJianBBACSaDetails) |
|
|
|
private async Task SaDataHandleAsync(List<BBAC_SA_DETAIL> bbacSaDetails) |
|
|
|
{ |
|
|
|
//结算单号
|
|
|
|
var bbacSaBillNum = OrderNumberGenerator.GenerateOrderNumber("SA"); |
|
|
@ -319,13 +312,13 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA> |
|
|
|
|
|
|
|
bbacSaDetails.ForEach(bbacSaDetail => |
|
|
|
{ |
|
|
|
List<string> luList = bbacSaDetail.LU.Split(" ").ToList(); |
|
|
|
bbacSaDetail.LU = luList[0].Replace(" ", ""); |
|
|
|
if (luList.Count > 1) |
|
|
|
List<string> partCodes = bbacSaDetail.PartCode.Split(" ").ToList(); |
|
|
|
bbacSaDetail.PartCode = partCodes[0].Replace(" ", ""); |
|
|
|
if (partCodes.Count > 1) |
|
|
|
{ |
|
|
|
luList.RemoveAt(0); |
|
|
|
var luAssemble = luList.Select(t => t.Replace(" ", "")); |
|
|
|
bbacSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index); |
|
|
|
partCodes.RemoveAt(0); |
|
|
|
var partCodeAssemble = partCodes.Select(t => t.Replace(" ", "")); |
|
|
|
bbacSaDetail.PartCode += partCodeAssemble.Aggregate(" ", (current, index) => current + index); |
|
|
|
} |
|
|
|
|
|
|
|
bbacSaDetail.BillNum = bbacSaBillNum; |
|
|
@ -334,6 +327,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA> |
|
|
|
//根据物料号、结算日期获取价格
|
|
|
|
var priceListEntity = priceListEntitys.Find(t => t.LU == bbacSaDetail.LU && bbacSaDetail.SettleDate > t.BeginTime && bbacSaDetail.SettleDate < t.EndTime); |
|
|
|
bbacSaDetail.Price = priceListEntity?.Price ?? default; |
|
|
|
bbacSaDetail.IsMaiDan = bbacSaDetail.PN.Contains("R0"); |
|
|
|
}); |
|
|
|
|
|
|
|
//导入的零件号集合
|
|
|
@ -353,6 +347,13 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA> |
|
|
|
var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t, _businessType.ToString()); |
|
|
|
materialRelationships.Add(materialRelationship); |
|
|
|
}); |
|
|
|
|
|
|
|
var seAllMaterialRelationships = materialRelationshipEntitys.Union(materialRelationships); |
|
|
|
bbacSaDetails.ForEach(bbacSaDetail => |
|
|
|
{ |
|
|
|
bbacSaDetail.LU = seAllMaterialRelationships.FirstOrDefault(t => t.SettleMaterialCode == bbacSaDetail.PartCode)?.ErpMaterialCode ?? bbacSaDetail.PartCode.Replace(" ", "-"); |
|
|
|
bbacSaDetail.KeyCode = bbacSaDetail.PN + bbacSaDetail.LU; |
|
|
|
}); |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 入库数据赋值
|
|
|
|