mahao 1 year ago
parent
commit
cd5c09d908
  1. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/TB_RePartsRelationship_DTO.cs
  2. 169
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs
  3. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs

6
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/TB_RePartsRelationship_DTO.cs

@ -27,6 +27,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// </summary>
[Display(Name = "业务类型")]
public EnumBusinessType BusinessType { get; set; }
/// <summary>
/// 业务类型
/// </summary>
[Display(Name = "业务类型")]
public string BusinessTypeDisplayName { get; set; }
}
/// <summary>

169
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs

@ -18,109 +18,108 @@ using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports;
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>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class TB_RePartsRelationship_SERVICE : SettleAccountApplicationBase<TB_RePartsRelationship>
private readonly INormalEfCoreRepository<TB_RePartsRelationship, Guid> _repository;
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>
/// 客户替换件关系仓储
/// </summary>
private readonly INormalEfCoreRepository<TB_RePartsRelationship, Guid> _repository;
_repository = repository;
}
public TB_RePartsRelationship_SERVICE(
INormalEfCoreRepository<TB_RePartsRelationship, Guid> repository,
IDistributedCache<TB_RePartsRelationship> cache,
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{
_repository = repository;
}
#region 导入、导出
/// <summary>
/// 导入
/// </summary>
[HttpPost]
public async Task<string> ImportAsync([FromForm] IFormFileCollection files)
{
ExportImporter _exportImporter = new ExportImporter();
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 导入、导出
/// <summary>
/// 导入
/// </summary>
[HttpPost]
public async Task<string> ImportAsync([FromForm] IFormFileCollection files)
if (_ls.Count > 0)
{
ExportImporter _exportImporter = new ExportImporter();
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>();
var query = from arc in _ls
group arc by new { arc.LU }
into g
where g.Count() > 1
if (_ls.Count > 0)
select g;
foreach (var itm in query)
{
var query = from arc in _ls
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));
}
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);
if (_first != null)
{
_first.Update(itm.LU, itm.RepLU, itm.ClientCode, itm.BusinessType);
await _repository.UpdateAsync(_first);
}
else
{
await _repository.InsertAsync(itm);
}
await _repository.InsertAsync(itm);
}
return ApplicationConsts.SuccessStr;
}
return ApplicationConsts.SuccessStr;
}
/// <summary>
/// 导出
/// </summary>
[HttpPost]
public async Task<string> ExportAsync(RequestDto input)
{
string fileName = $"客户替换件关系_{Guid.NewGuid()}.xlsx";
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);
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.ExcelExporter(dtos);
result.ShouldNotBeNull();
/// <summary>
/// 导出
/// </summary>
[HttpPost]
public async Task<string> ExportAsync(RequestDto input)
{
string fileName = $"客户替换件关系_{Guid.NewGuid()}.xlsx";
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);
await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result });
return fileName;
}
#endregion
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.ExcelExporter(dtos);
result.ShouldNotBeNull();
#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
await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result });
return fileName;
}
#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
}

5
code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs

@ -56,6 +56,8 @@ using Win.Sfs.SettleAccount.Errors;
using Win.Sfs.SettleAccount.Entities.Errors;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using SettleAccount.Domain.BQ;
using System.ComponentModel.DataAnnotations;
using System.Reflection;
namespace Win.Sfs.SettleAccount
{
@ -923,7 +925,8 @@ namespace Win.Sfs.SettleAccount
/// </summary>
private void CreateMapTB_RePartsRelationship()
{
CreateMap<TB_RePartsRelationship, TB_RePartsRelationship_DTO>();
CreateMap<TB_RePartsRelationship, TB_RePartsRelationship_DTO>()
.ForMember(x => x.BusinessTypeDisplayName, y => y.MapFrom(t => t.BusinessType.GetType().GetField(t.BusinessType.ToString()).GetCustomAttribute<DisplayAttribute>().Name));
CreateMap<TB_RePartsRelationship, TB_RePartsRelationship_EXPORT_DTO>();
CreateMap<TB_RePartsRelationship_IMPORT_DTO, TB_RePartsRelationship>();
}

Loading…
Cancel
Save