Browse Source

HBPO EDI发运数据定时任我对比

master
mahao 1 year ago
parent
commit
a6973084ea
  1. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_SA_DTO.cs
  2. 35
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs
  3. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs
  4. 78
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs

2
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_SA_DTO.cs

@ -79,7 +79,7 @@ public class BBAC_SA_DETAIL_IMPORT_DTO
[Display(Name = "Material")]
[Required(ErrorMessage = "{0}不能为空")]
[ImporterHeader(Name = "Material")]
public string LU { get; set; }
public string PartCode { get; set; }
/// <summary>
/// 数量

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

@ -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 入库数据赋值

4
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs

@ -328,8 +328,8 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
if (partCodes.Count > 1)
{
partCodes.RemoveAt(0);
var luAssemble = partCodes.Select(t => t.Replace(" ", ""));
hbpoSaDetail.PartCode += luAssemble.Aggregate(" ", (current, index) => current + index);
var partCodeAssemble = partCodes.Select(t => t.Replace(" ", ""));
hbpoSaDetail.PartCode += partCodeAssemble.Aggregate(" ", (current, index) => current + index);
}
hbpoSaDetail.BillNum = hbpoSaBillNum;

78
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs

@ -1,17 +1,15 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Coravel.Invocable;
using LinqToDB;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using SettleAccount.Domain.BQ;
using Volo.Abp.Application.Services;
using Win.Sfs.Shared.RepositoryBase;
using System.Linq;
using DocumentFormat.OpenXml.Office2010.ExcelAc;
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Application;
using System.Runtime.Intrinsics.X86;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
@ -47,56 +45,38 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable
/// </summary>
public async Task Invoke()
{
await Task.CompletedTask;
Debug.WriteLine($"执行了 {this.GetType()}");
Debug.WriteLine($"执行了:{this.GetType()}");
using var serviceScope = _serviceProvider.CreateScope();
var db = serviceScope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
//List<HBPO_SE_DETAIL> hbpoSeDetails = await _hbpoSeDetailRepository.GetListAsync(t => t.IsHaveEdiData == false);
//var hbpoSeDetails = db.Set<HBPO_SE_DETAIL>().Where(t => t.IsHaveEdiData == false).OrderBy(t => t.BillTime);
//var hbpoSeEdis = db.Set<HBPO_SE_EDI>().Where(t => t.IsHaveSeData == false && hbpoSeDetails.Any(w => w.PN.Equals(t.PN) && w.LU.Equals(t.LU) && w.Qty.Equals(t.Qty)));
var query = from se in db.Set<HBPO_SE_DETAIL>()
join edi in db.Set<HBPO_SE_EDI>() on new
{
se.LU,
se.PN,
se.Qty
} equals new
{
edi.LU,
edi.PN,
edi.Qty
}
where se.IsHaveEdiData == false && edi.IsHaveSeData == false
//select new
//var query = from se in db.Set<HBPO_SE_DETAIL>()
// join edi in db.Set<HBPO_SE_EDI>() on new
// {
// SeID = se.Id,
// se.PN,
// se.LU,
// se.Qty,
// EdiID = edi.Id
// se.PN,
// se.Qty
// } equals new
// {
// edi.LU,
// edi.PN,
// edi.Qty
// }
// where se.IsHaveEdiData == false && edi.IsHaveSeData == false
// select new
// {
// se,
// edi
// };
select new
{
se,
edi
};
var query = db.Set<HBPO_SE_DETAIL>().Join(db.Set<HBPO_SE_EDI>(), a => new { a.PN, a.LU, a.Qty }, b => new { b.PN, b.LU, b.Qty }, (se, edi) => new { se, edi }).Where(t => t.se.IsHaveEdiData == false && t.edi.IsHaveSeData == false);
var ses = query.Select(t => t.se);
var edis = query.Select(t => t.edi);
query.ForEach(item =>
{
Debug.WriteLine($"{Newtonsoft.Json.JsonConvert.SerializeObject(item)}");
});
//var ses = query.SelectMany(t => t.se);
//var edis = query.SelectMany(t => t.edi);
ses.ForEach(t => t.IsHaveEdiData = true);
edis.ForEach(t => t.IsHaveSeData = true);
//hbpoSeEdis.ForEach(hbpoSeEdi =>
//{
// Debug.WriteLine($"{hbpoSeEdi.Id}");
//});
db.Set<HBPO_SE_DETAIL>().UpdateRange(ses);
db.Set<HBPO_SE_EDI>().UpdateRange(edis);
await db.SaveChangesAsync().ConfigureAwait(false);
Debug.WriteLine($"处理数量:{query.Count()}");
}
}

Loading…
Cancel
Save