学 赵 1 year ago
parent
commit
66617746ad
  1. 10
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SE_EDI_Service.cs
  2. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs
  3. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs
  4. 24
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs
  5. 49
      code/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs

10
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SE_EDI_Service.cs

@ -48,14 +48,14 @@ public class BBAC_SE_EDI_SERVICE : ApplicationService
public async Task<string> ExportAsync(RequestDto input)
{
string fileName = $"BBAC的EDI数据_{Guid.NewGuid()}.xlsx";
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true);
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true).ConfigureAwait(false); ;
var dtos = ObjectMapper.Map<List<BBAC_SE_EDI>, List<BBAC_SE_EDI_EXPORT_DTO>>(entities);
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.ExcelExporter(dtos);
var result = await _exportImporter.ExcelExporter(dtos).ConfigureAwait(false); ;
result.ShouldNotBeNull();
await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result });
await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result }).ConfigureAwait(false); ;
return fileName;
}
#endregion
@ -67,8 +67,8 @@ public class BBAC_SE_EDI_SERVICE : ApplicationService
[HttpPost]
public async Task<PagedResultDto<BBAC_SE_EDI_DTO>> GetListAsync(RequestDto input)
{
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true);
var totalCount = await _repository.GetCountByFilterAsync(input.Filters);
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true).ConfigureAwait(false);
var totalCount = await _repository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
var dtos = ObjectMapper.Map<List<BBAC_SE_EDI>, List<BBAC_SE_EDI_DTO>>(entities);
return new PagedResultDto<BBAC_SE_EDI_DTO>(totalCount, dtos);
}

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs

@ -92,7 +92,7 @@ public class JisBBACSeEdiCompareAppService : ApplicationService, IInvocable
using var serviceScope = _serviceProvider.CreateScope();
var db = serviceScope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
//Edi 删除的数据(有发运数据)
var ediDelKeyCodes = db.Set<BBAC_SE_EDI>().Where(t => t.IsDeleted == true && t.IsHaveSeData == true).Select(t => new { t.PN, t.LU }).Distinct();
var ediDelKeyCodes = db.Set<BBAC_SE_EDI>().Where(t => t.IsDeleted == true && t.IsHaveSeData == true).Select(t => new { t.PN, t.LU }).Distinct().ToList();
if (ediDelKeyCodes.Any())
{

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

@ -109,7 +109,7 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable
using var serviceScope = _serviceProvider.CreateScope();
var db = serviceScope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
//Edi 删除的数据(有发运数据)
var ediDelKeyCodes = db.Set<HBPO_SE_EDI>().Where(t => t.IsDeleted == true && t.IsHaveSeData == true).Select(t => new { t.PN, t.LU }).Distinct();
var ediDelKeyCodes = db.Set<HBPO_SE_EDI>().Where(t => t.IsDeleted == true && t.IsHaveSeData == true).Select(t => new { t.PN, t.LU }).Distinct().ToList();
if (ediDelKeyCodes.Any())
{

24
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs

@ -85,7 +85,7 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable
return;
}
await SyncJitRecordAsync().ConfigureAwait(false);
//await SyncJisRecordAsync().ConfigureAwait(false);
await SyncJisRecordAsync().ConfigureAwait(false);
}
/// <summary>
@ -194,7 +194,7 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable
if (luRePartCodes.Any())
{
var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.FactoryPartCode, "", t.LU, businessType));
await this.AddNewMaterialRelationships(materialRelationships).ConfigureAwait(false);
await _syncExtendManager.AddNewMaterialRelationshipsAsync(materialRelationships).ConfigureAwait(false);
}
jisSeDetails.ForEach(t =>
@ -226,24 +226,4 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable
}
}
}
/// <summary>
/// 添加零件关系
/// </summary>
public async Task AddNewMaterialRelationships(IEnumerable<MaterialRelationship> materialRelationships)
{
//新客户零件号和厂内零件号
var noHaveLuRePartCodes = from item1 in materialRelationships
join item2 in _settleAccountDbContext.Set<MaterialRelationship>()
on new { item1.ErpMaterialCode, item1.SettleMaterialCode } equals new { item2.ErpMaterialCode, item2.SettleMaterialCode }
into temp
from item3 in temp.DefaultIfEmpty()
where item3 == null
select item1;
if (noHaveLuRePartCodes.Any())
{
await _settleAccountDbContext.BulkInsertAsync(noHaveLuRePartCodes.ToList()).ConfigureAwait(false);
}
}
}

49
code/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs

@ -164,6 +164,8 @@ namespace Win.Sfs.SettleAccount.ExcelImporter
public virtual async Task<List<T>> UploadExcelImportByHeadDesc<T>([FromForm] IFormFileCollection files, IExcelImportAppService _excelImportService)
where T : class, new()
{
using var fs = ServiceProvider.CreateScope();
var fc = fs.ServiceProvider.GetRequiredService<IBlobContainer<MyFileContainer>>();
Type type = typeof(T);
var ImportList = new List<T>();
ExcelImportResult returnResult = new ExcelImportResult();
@ -182,37 +184,36 @@ namespace Win.Sfs.SettleAccount.ExcelImporter
{
//保存成物理文件
await file.CopyToAsync(memoryStream);
await _excelImportService.SaveBlobAsync(
new SaveExcelImportInputDto
{
Name = Path.GetFileName(FileOriginName),
Content = memoryStream.ToArray()
}
);
//await _excelImportService.SaveBlobAsync(
// new SaveExcelImportInputDto
// {
// Name = Path.GetFileName(FileOriginName),
// Content = memoryStream.ToArray()
// }
// );
await fc.SaveAsync(FileOriginName, memoryStream.ToArray(), true).ConfigureAwait(false);
}
//读取文件保存的根目录
string fileSaveRootDir = ConfigDirHelper.GetAppSetting("App", "FileRootPath");
//读取WMS文件保存的模块的根目录
string fileSaveDir = ConfigDirHelper.GetAppSetting("App", "WMSFiles");
//文件保存的相对文件夹(保存到wwwroot目录下)
string absoluteFileDir = fileSaveRootDir + @"\" + fileSaveDir;
//文件保存的路径(应用的工作目录+文件夹相对路径);
string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container" + absoluteFileDir;
var filePath = fileSavePath + getFileName;//获取到导入的excel
////读取文件保存的根目录
//string fileSaveRootDir = ConfigDirHelper.GetAppSetting("App", "FileRootPath");
////读取WMS文件保存的模块的根目录
//string fileSaveDir = ConfigDirHelper.GetAppSetting("App", "WMSFiles");
////文件保存的相对文件夹(保存到wwwroot目录下)
//string absoluteFileDir = fileSaveRootDir + @"\" + fileSaveDir;
////文件保存的路径(应用的工作目录+文件夹相对路径);
//string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container" + absoluteFileDir;
//var filePath = fileSavePath + getFileName;//获取到导入的excel
//var import = await _importer.Import<T>(filePath);
var import = new ImportResult<T>();
using (var importer = new ImportHelper<T>(filePath, null))
{
import = await importer.Import(null);
Stream Stream = new FileStream(filePath, FileMode.Open);
using (Stream)
using (var stream = new MemoryStream())
{
IWorkbook wk = new XSSFWorkbook(Stream);
await file.CopyToAsync(stream).ConfigureAwait(false);
stream.Position = 0;
IWorkbook wk = new XSSFWorkbook(stream);
//读取当前表数据
ISheet sheet = wk.GetSheetAt(0);
import = await _importer.Import<T>(await fc.GetAsync(FileOriginName).ConfigureAwait(false)).ConfigureAwait(false);
var excelImporterHeadDescAttributeProperties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty)
.Where(o => o.GetCustomAttribute<ExcelImporterHeadDescAttribute>(true) != null);
@ -233,7 +234,6 @@ namespace Win.Sfs.SettleAccount.ExcelImporter
}
}
}
}
if (import.Exception != null)
{
@ -291,6 +291,7 @@ namespace Win.Sfs.SettleAccount.ExcelImporter
}
if (_errorList.Count > 0)
{
throw new UserFriendlyException(string.Join("\r\n", _errorList), "400");
throw new BusinessException("8989", string.Join("\r\n", _errorList));
}
return ImportList;//返回客户端

Loading…
Cancel
Save