|
@ -114,14 +114,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA> |
|
|
#region 导入数据转换、数据校验
|
|
|
#region 导入数据转换、数据校验
|
|
|
ExportImporter _exportImporter = new ExportImporter(); |
|
|
ExportImporter _exportImporter = new ExportImporter(); |
|
|
var importDtos = await _exportImporter.UploadExcelImport<BBAC_SA_DETAIL_IMPORT_DTO>(files, _excelImportService); |
|
|
var importDtos = await _exportImporter.UploadExcelImport<BBAC_SA_DETAIL_IMPORT_DTO>(files, _excelImportService); |
|
|
|
|
|
var importBBACSaDetails = ObjectMapper.Map<List<BBAC_SA_DETAIL_IMPORT_DTO>, List<BBAC_SA_DETAIL>>(importDtos); |
|
|
//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 checkList = new List<ErrorExportDto>(); |
|
|
var checkList = new List<ErrorExportDto>(); |
|
@ -139,14 +132,14 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA> |
|
|
|
|
|
|
|
|
if (checkList.Count > 0) |
|
|
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 }); |
|
|
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName }); |
|
|
} |
|
|
} |
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
if (importBBACSaDetails.Any()) |
|
|
if (importBBACSaDetails.Any()) |
|
|
{ |
|
|
{ |
|
|
await SaDataHandleAsync(importBBACSaDetails, importMaiDanJianBBACSaDetails); |
|
|
await SaDataHandleAsync(importBBACSaDetails).ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return new JsonResult(new { Code = 200, Message = "导入成功" }); |
|
|
return new JsonResult(new { Code = 200, Message = "导入成功" }); |
|
@ -286,7 +279,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA> |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 结算数据处理
|
|
|
/// 结算数据处理
|
|
|
/// </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"); |
|
|
var bbacSaBillNum = OrderNumberGenerator.GenerateOrderNumber("SA"); |
|
@ -319,13 +312,13 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA> |
|
|
|
|
|
|
|
|
bbacSaDetails.ForEach(bbacSaDetail => |
|
|
bbacSaDetails.ForEach(bbacSaDetail => |
|
|
{ |
|
|
{ |
|
|
List<string> luList = bbacSaDetail.LU.Split(" ").ToList(); |
|
|
List<string> partCodes = bbacSaDetail.PartCode.Split(" ").ToList(); |
|
|
bbacSaDetail.LU = luList[0].Replace(" ", ""); |
|
|
bbacSaDetail.PartCode = partCodes[0].Replace(" ", ""); |
|
|
if (luList.Count > 1) |
|
|
if (partCodes.Count > 1) |
|
|
{ |
|
|
{ |
|
|
luList.RemoveAt(0); |
|
|
partCodes.RemoveAt(0); |
|
|
var luAssemble = luList.Select(t => t.Replace(" ", "")); |
|
|
var partCodeAssemble = partCodes.Select(t => t.Replace(" ", "")); |
|
|
bbacSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index); |
|
|
bbacSaDetail.PartCode += partCodeAssemble.Aggregate(" ", (current, index) => current + index); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bbacSaDetail.BillNum = bbacSaBillNum; |
|
|
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); |
|
|
var priceListEntity = priceListEntitys.Find(t => t.LU == bbacSaDetail.LU && bbacSaDetail.SettleDate > t.BeginTime && bbacSaDetail.SettleDate < t.EndTime); |
|
|
bbacSaDetail.Price = priceListEntity?.Price ?? default; |
|
|
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()); |
|
|
var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t, _businessType.ToString()); |
|
|
materialRelationships.Add(materialRelationship); |
|
|
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
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 入库数据赋值
|
|
|
#region 入库数据赋值
|
|
|