mahao 1 year ago
parent
commit
fb8bb5fa75
  1. 26
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs

26
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs

@ -54,15 +54,15 @@ public class MaterialRelationshipAppService : SettleAccountApplicationBase<Mater
[HttpPost]
public async Task<IActionResult> ImportAsync([FromForm] MaterialRelationshipImportRequestDto materialRelationshipImportRequestDto)
{
var _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<MaterialRelationshipImportDto>(materialRelationshipImportRequestDto.Files, _excelImportService).ConfigureAwait(false);
var _ls = ObjectMapper.Map<List<MaterialRelationshipImportDto>, List<MaterialRelationship>>(result);
List<string> _errorList = new List<string>();
var exportImporter = new ExportImporter();
var inportDatas = await exportImporter.UploadExcelImport<MaterialRelationshipImportDto>(materialRelationshipImportRequestDto.Files, _excelImportService).ConfigureAwait(false);
var entitys = ObjectMapper.Map<List<MaterialRelationshipImportDto>, List<MaterialRelationship>>(inportDatas);
var errorList = new List<string>();
var checkList = new List<ErrorExportDto>();
if (_ls.Count > 0)
if (entitys.Count > 0)
{
var query = from arc in _ls
var query = from arc in entitys
group arc by new { arc.SettleMaterialCode }
into g
where g.Count() > 1
@ -77,18 +77,18 @@ public class MaterialRelationshipAppService : SettleAccountApplicationBase<Mater
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = fileName });
}
foreach (var itm in _ls)
foreach (var item in entitys)
{
var _first = _repository.FirstOrDefault(p => p.ErpMaterialCode == itm.ErpMaterialCode && p.BusinessType == EnumBusinessType.BeiJian);
if (_first != null)
var entity = _repository.FirstOrDefault(p => p.ErpMaterialCode == item.ErpMaterialCode && p.BusinessType == EnumBusinessType.BeiJian);
if (entity != null)
{
_first.Update(itm.MaterialDesc, itm.SettleMaterialCode);
await _repository.UpdateAsync(_first).ConfigureAwait(false);
entity.Update(item.MaterialDesc, item.SettleMaterialCode);
await _repository.UpdateAsync(entity).ConfigureAwait(false);
}
else
{
itm.BusinessType = EnumBusinessType.BeiJian;
await _repository.InsertAsync(itm).ConfigureAwait(false);
item.BusinessType = EnumBusinessType.BeiJian;
await _repository.InsertAsync(item).ConfigureAwait(false);
}
}
return new JsonResult(new { Code = 200, Message = "导入成功" });

Loading…
Cancel
Save