|
@ -1,8 +1,10 @@ |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
|
|
|
using System.Linq.Dynamic.Core; |
|
|
using System.Text; |
|
|
using System.Text; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
|
|
|
using DocumentFormat.OpenXml.Bibliography; |
|
|
using DocumentFormat.OpenXml.Office2010.Excel; |
|
|
using DocumentFormat.OpenXml.Office2010.Excel; |
|
|
using EFCore.BulkExtensions; |
|
|
using EFCore.BulkExtensions; |
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
using Microsoft.AspNetCore.Authorization; |
|
@ -19,6 +21,7 @@ using Win.Sfs.SettleAccount.CommonManagers; |
|
|
using Win.Sfs.SettleAccount.Constant; |
|
|
using Win.Sfs.SettleAccount.Constant; |
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; |
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; |
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Managers; |
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Managers; |
|
|
|
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Temp; |
|
|
using Win.Sfs.SettleAccount.ExcelImporter; |
|
|
using Win.Sfs.SettleAccount.ExcelImporter; |
|
|
using Win.Sfs.SettleAccount.ExportReports; |
|
|
using Win.Sfs.SettleAccount.ExportReports; |
|
|
using Win.Sfs.SettleAccount.MaterialRelationships; |
|
|
using Win.Sfs.SettleAccount.MaterialRelationships; |
|
@ -36,6 +39,10 @@ public class ADJ_SERVICE : BASE_SERVICE |
|
|
protected readonly BaseDomainService _baseDomainService; |
|
|
protected readonly BaseDomainService _baseDomainService; |
|
|
protected readonly INormalEfCoreRepository<INVOICE_GRP, Guid> _invRepository; |
|
|
protected readonly INormalEfCoreRepository<INVOICE_GRP, Guid> _invRepository; |
|
|
protected readonly INormalEfCoreRepository<MaterialRelationship, Guid> _relRepository; |
|
|
protected readonly INormalEfCoreRepository<MaterialRelationship, Guid> _relRepository; |
|
|
|
|
|
protected readonly INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> _bbacRepository; |
|
|
|
|
|
protected readonly INormalEfCoreRepository<PUB_NOT_SA_DETAIL, Guid> _pubRepository; |
|
|
|
|
|
protected readonly INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> _hbpoRepository; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ADJ_SERVICE( |
|
|
public ADJ_SERVICE( |
|
|
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> repository, |
|
|
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> repository, |
|
@ -44,7 +51,10 @@ public class ADJ_SERVICE : BASE_SERVICE |
|
|
ISnowflakeIdGenerator snowflakeIdGenerator, |
|
|
ISnowflakeIdGenerator snowflakeIdGenerator, |
|
|
ICommonManager commonManager, |
|
|
ICommonManager commonManager, |
|
|
INormalEfCoreRepository<INVOICE_GRP, Guid> invRepository, |
|
|
INormalEfCoreRepository<INVOICE_GRP, Guid> invRepository, |
|
|
INormalEfCoreRepository<MaterialRelationship, Guid> relRepository |
|
|
INormalEfCoreRepository<MaterialRelationship, Guid> relRepository, |
|
|
|
|
|
INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> bbacRepository, |
|
|
|
|
|
INormalEfCoreRepository<PUB_NOT_SA_DETAIL, Guid> pubRepository, |
|
|
|
|
|
INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> hbpoRepository |
|
|
|
|
|
|
|
|
) |
|
|
) |
|
|
: base(excelImportService, snowflakeIdGenerator, commonManager) |
|
|
: base(excelImportService, snowflakeIdGenerator, commonManager) |
|
@ -53,6 +63,9 @@ public class ADJ_SERVICE : BASE_SERVICE |
|
|
_invRepository = invRepository; |
|
|
_invRepository = invRepository; |
|
|
_repository = repository; |
|
|
_repository = repository; |
|
|
_baseDomainService = baseDomainService; |
|
|
_baseDomainService = baseDomainService; |
|
|
|
|
|
_bbacRepository = bbacRepository; |
|
|
|
|
|
_pubRepository = pubRepository; |
|
|
|
|
|
_hbpoRepository= hbpoRepository; |
|
|
} |
|
|
} |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
///查询明细
|
|
|
///查询明细
|
|
@ -171,7 +184,84 @@ public class ADJ_SERVICE : BASE_SERVICE |
|
|
[DisableRequestSizeLimit] |
|
|
[DisableRequestSizeLimit] |
|
|
public async Task<string> CheckImport(List<PUB_ADJ_DETAIL_DTO> p_list) |
|
|
public async Task<string> CheckImport(List<PUB_ADJ_DETAIL_DTO> p_list) |
|
|
{ |
|
|
{ |
|
|
|
|
|
if (p_list.Count == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
throw new UserFriendlyException($"导入数据为空"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach (var itm in p_list) |
|
|
|
|
|
{ |
|
|
|
|
|
itm.KeyCode = itm.PN + itm.LU.Replace(" ", "").Trim(); |
|
|
|
|
|
} |
|
|
|
|
|
var pnlist=p_list.Select(p => p.PN).Distinct(); |
|
|
|
|
|
|
|
|
|
|
|
var keylist = p_list.Select(p => p.KeyCode).Distinct(); |
|
|
List<ERR_EXP_DTO> errorList = new List<ERR_EXP_DTO>(); |
|
|
List<ERR_EXP_DTO> errorList = new List<ERR_EXP_DTO>(); |
|
|
|
|
|
var first=p_list.FirstOrDefault(); |
|
|
|
|
|
if (first != null) |
|
|
|
|
|
{ |
|
|
|
|
|
var inv = _invRepository.Where(p => p.InvbillNum == first.InvBillNum).FirstOrDefault(); |
|
|
|
|
|
string keyname = string.Empty; |
|
|
|
|
|
List<PUB_ADJ_DETAIL> adjlist = new List<PUB_ADJ_DETAIL>(); |
|
|
|
|
|
|
|
|
|
|
|
switch (inv.BusinessType) |
|
|
|
|
|
{ |
|
|
|
|
|
case EnumBusinessType.MaiDanJianHBPO: |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
case EnumBusinessType.MaiDanJianBBAC: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
case EnumBusinessType.ZhiGongJianBBAC: |
|
|
|
|
|
var errors1 = _pubRepository.Where(p => pnlist.Contains(p.PN)); |
|
|
|
|
|
foreach (var p in errors1) |
|
|
|
|
|
{ |
|
|
|
|
|
errorList.Add(new ERR_EXP_DTO() { Message = $"不能结算数据中存在{p.PN}数据,不能导入调整表" }); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case EnumBusinessType.ZhiGongJianHBPO: |
|
|
|
|
|
var errors2 = _pubRepository.Where(p => pnlist.Contains(p.PN)); |
|
|
|
|
|
foreach (var p in errors2) |
|
|
|
|
|
{ |
|
|
|
|
|
errorList.Add(new ERR_EXP_DTO() { Message = $"不能结算数据中存在发货单{p.PN}数据,不能导入调整表" }); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case EnumBusinessType.BeiJian: |
|
|
|
|
|
var errors3 = _pubRepository.Where(p => pnlist.Contains(p.PN)); |
|
|
|
|
|
foreach (var p in errors3) |
|
|
|
|
|
{ |
|
|
|
|
|
errorList.Add(new ERR_EXP_DTO() { Message = $"不能结算数据中存在交付识别号{p.PN}数据,不能导入调整表" }); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case EnumBusinessType.JisBBAC: |
|
|
|
|
|
var errors4 = _bbacRepository.Where(p => keylist.Contains(p.KeyCode)); |
|
|
|
|
|
foreach (var p in errors4) |
|
|
|
|
|
{ |
|
|
|
|
|
errorList.Add(new ERR_EXP_DTO() {Message=$"不能结算数据中存在生产码{p.PN}结算零件{p.PartCode},不能导入调整表" }); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case EnumBusinessType.JisHBPO: |
|
|
|
|
|
var errors5=_hbpoRepository.Where(p => keylist.Contains(p.KeyCode)); |
|
|
|
|
|
foreach (var p in errors5) |
|
|
|
|
|
{ |
|
|
|
|
|
errorList.Add(new ERR_EXP_DTO() { Message = $"不能结算数据中存在生产码{p.PN}结算零件{p.PartCode},不能导入调整表" }); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case EnumBusinessType.YinDuJian: |
|
|
|
|
|
var errors6=_pubRepository.Where(p => pnlist.Contains(p.PN)); |
|
|
|
|
|
foreach (var p in errors6) |
|
|
|
|
|
{ |
|
|
|
|
|
errorList.Add(new ERR_EXP_DTO() { Message = $"不能结算数据中存在发货单{p.PN}数据,不能导入调整表" }); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
//ExportImporter _exportImporter = new ExportImporter();
|
|
|
//ExportImporter _exportImporter = new ExportImporter();
|
|
|
//var result = await _exportImporter.UploadExcelImport<PUB_ADJ_DETAIL_IMP_DTO>(files, _excelImportService);
|
|
|
//var result = await _exportImporter.UploadExcelImport<PUB_ADJ_DETAIL_IMP_DTO>(files, _excelImportService);
|
|
|
//if (result.Count == 0)
|
|
|
//if (result.Count == 0)
|
|
|