|
@ -18,109 +18,108 @@ using Win.Sfs.SettleAccount.ExcelImporter; |
|
|
using Win.Sfs.SettleAccount.ExportReports; |
|
|
using Win.Sfs.SettleAccount.ExportReports; |
|
|
using Win.Sfs.Shared.RepositoryBase; |
|
|
using Win.Sfs.Shared.RepositoryBase; |
|
|
|
|
|
|
|
|
namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
namespace Win.Sfs.SettleAccount.Entities.BQ; |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 客户替换件关系
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[AllowAnonymous] |
|
|
|
|
|
[Route("api/settleaccount/[controller]/[action]")]
|
|
|
|
|
|
public class TB_RePartsRelationship_SERVICE : SettleAccountApplicationBase<TB_RePartsRelationship> |
|
|
{ |
|
|
{ |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 客户替换件关系
|
|
|
/// 客户替换件关系仓储
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
[AllowAnonymous] |
|
|
private readonly INormalEfCoreRepository<TB_RePartsRelationship, Guid> _repository; |
|
|
[Route("api/settleaccount/[controller]/[action]")]
|
|
|
|
|
|
public class TB_RePartsRelationship_SERVICE : SettleAccountApplicationBase<TB_RePartsRelationship> |
|
|
public TB_RePartsRelationship_SERVICE( |
|
|
|
|
|
INormalEfCoreRepository<TB_RePartsRelationship, Guid> repository, |
|
|
|
|
|
IDistributedCache<TB_RePartsRelationship> cache, |
|
|
|
|
|
IExcelImportAppService excelImportService, |
|
|
|
|
|
ISnowflakeIdGenerator snowflakeIdGenerator, |
|
|
|
|
|
ICommonManager commonManager |
|
|
|
|
|
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) |
|
|
{ |
|
|
{ |
|
|
/// <summary>
|
|
|
_repository = repository; |
|
|
/// 客户替换件关系仓储
|
|
|
} |
|
|
/// </summary>
|
|
|
|
|
|
private readonly INormalEfCoreRepository<TB_RePartsRelationship, Guid> _repository; |
|
|
|
|
|
|
|
|
|
|
|
public TB_RePartsRelationship_SERVICE( |
|
|
#region 导入、导出
|
|
|
INormalEfCoreRepository<TB_RePartsRelationship, Guid> repository, |
|
|
/// <summary>
|
|
|
IDistributedCache<TB_RePartsRelationship> cache, |
|
|
/// 导入
|
|
|
IExcelImportAppService excelImportService, |
|
|
/// </summary>
|
|
|
ISnowflakeIdGenerator snowflakeIdGenerator, |
|
|
[HttpPost] |
|
|
ICommonManager commonManager |
|
|
public async Task<string> ImportAsync([FromForm] IFormFileCollection files) |
|
|
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) |
|
|
{ |
|
|
{ |
|
|
ExportImporter _exportImporter = new ExportImporter(); |
|
|
_repository = repository; |
|
|
var result = await _exportImporter.UploadExcelImport<TB_RePartsRelationship_IMPORT_DTO>(files, _excelImportService); |
|
|
} |
|
|
var _ls = ObjectMapper.Map<List<TB_RePartsRelationship_IMPORT_DTO>, List<TB_RePartsRelationship>>(result); |
|
|
|
|
|
List<string> _errorList = new List<string>(); |
|
|
|
|
|
var checkList = new List<ErrorExportDto>(); |
|
|
|
|
|
|
|
|
#region 导入、导出
|
|
|
if (_ls.Count > 0) |
|
|
/// <summary>
|
|
|
|
|
|
/// 导入
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[HttpPost] |
|
|
|
|
|
public async Task<string> ImportAsync([FromForm] IFormFileCollection files) |
|
|
|
|
|
{ |
|
|
{ |
|
|
ExportImporter _exportImporter = new ExportImporter(); |
|
|
var query = from arc in _ls |
|
|
var result = await _exportImporter.UploadExcelImport<TB_RePartsRelationship_IMPORT_DTO>(files, _excelImportService); |
|
|
group arc by new { arc.LU } |
|
|
var _ls = ObjectMapper.Map<List<TB_RePartsRelationship_IMPORT_DTO>, List<TB_RePartsRelationship>>(result); |
|
|
into g |
|
|
List<string> _errorList = new List<string>(); |
|
|
where g.Count() > 1 |
|
|
var checkList = new List<ErrorExportDto>(); |
|
|
|
|
|
|
|
|
|
|
|
if (_ls.Count > 0) |
|
|
select g; |
|
|
|
|
|
foreach (var itm in query) |
|
|
{ |
|
|
{ |
|
|
var query = from arc in _ls |
|
|
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("客户物料号{0}有重复", itm.Key.LU), string.Empty)); |
|
|
group arc by new { arc.LU } |
|
|
|
|
|
into g |
|
|
|
|
|
where g.Count() > 1 |
|
|
|
|
|
|
|
|
|
|
|
select g; |
|
|
|
|
|
foreach (var itm in query) |
|
|
|
|
|
{ |
|
|
|
|
|
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("客户物料号{0}有重复", itm.Key.LU), string.Empty)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
if (checkList.Count > 0) |
|
|
} |
|
|
|
|
|
if (checkList.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
return await ExportErrorReportAsync(checkList); |
|
|
|
|
|
} |
|
|
|
|
|
foreach (var itm in _ls) |
|
|
|
|
|
{ |
|
|
|
|
|
var _first = _repository.FirstOrDefault(p => p.LU == itm.LU); |
|
|
|
|
|
if (_first != null) |
|
|
{ |
|
|
{ |
|
|
return await ExportErrorReportAsync(checkList); |
|
|
_first.Update(itm.LU, itm.RepLU, itm.ClientCode, itm.BusinessType); |
|
|
|
|
|
await _repository.UpdateAsync(_first); |
|
|
} |
|
|
} |
|
|
foreach (var itm in _ls) |
|
|
else |
|
|
{ |
|
|
{ |
|
|
var _first = _repository.FirstOrDefault(p => p.LU == itm.LU); |
|
|
await _repository.InsertAsync(itm); |
|
|
if (_first != null) |
|
|
|
|
|
{ |
|
|
|
|
|
_first.Update(itm.LU, itm.RepLU, itm.ClientCode, itm.BusinessType); |
|
|
|
|
|
await _repository.UpdateAsync(_first); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
await _repository.InsertAsync(itm); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
return ApplicationConsts.SuccessStr; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
return ApplicationConsts.SuccessStr; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 导出
|
|
|
/// 导出
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
[HttpPost] |
|
|
[HttpPost] |
|
|
public async Task<string> ExportAsync(RequestDto input) |
|
|
public async Task<string> ExportAsync(RequestDto input) |
|
|
{ |
|
|
{ |
|
|
string fileName = $"客户替换件关系_{Guid.NewGuid()}.xlsx"; |
|
|
string fileName = $"客户替换件关系_{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); |
|
|
var dtos = ObjectMapper.Map<List<TB_RePartsRelationship>, List<TB_RePartsRelationship_EXPORT_DTO>>(entities); |
|
|
var dtos = ObjectMapper.Map<List<TB_RePartsRelationship>, List<TB_RePartsRelationship_EXPORT_DTO>>(entities); |
|
|
|
|
|
|
|
|
ExportImporter _exportImporter = new ExportImporter(); |
|
|
|
|
|
var result = await _exportImporter.ExcelExporter(dtos); |
|
|
|
|
|
result.ShouldNotBeNull(); |
|
|
|
|
|
|
|
|
|
|
|
await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result }); |
|
|
ExportImporter _exportImporter = new ExportImporter(); |
|
|
return fileName; |
|
|
var result = await _exportImporter.ExcelExporter(dtos); |
|
|
} |
|
|
result.ShouldNotBeNull(); |
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region CURD
|
|
|
await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result }); |
|
|
/// <summary>
|
|
|
return fileName; |
|
|
/// 获取列表
|
|
|
} |
|
|
/// </summary>
|
|
|
#endregion
|
|
|
[HttpPost] |
|
|
|
|
|
public async Task<PagedResultDto<TB_RePartsRelationship_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 dtos = ObjectMapper.Map<List<TB_RePartsRelationship>, List<TB_RePartsRelationship_DTO>>(entities); |
|
|
|
|
|
return new PagedResultDto<TB_RePartsRelationship_DTO>(totalCount, dtos); |
|
|
|
|
|
} |
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region CURD
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[HttpPost] |
|
|
|
|
|
public async Task<PagedResultDto<TB_RePartsRelationship_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 dtos = ObjectMapper.Map<List<TB_RePartsRelationship>, List<TB_RePartsRelationship_DTO>>(entities); |
|
|
|
|
|
return new PagedResultDto<TB_RePartsRelationship_DTO>(totalCount, dtos); |
|
|
} |
|
|
} |
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|