diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/TB_RePartsRelationship_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/TB_RePartsRelationship_DTO.cs index 82cabdb0..f7b551a7 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/TB_RePartsRelationship_DTO.cs +++ b/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 /// [Display(Name = "业务类型")] public EnumBusinessType BusinessType { get; set; } + + /// + /// 业务类型 + /// + [Display(Name = "业务类型")] + public string BusinessTypeDisplayName { get; set; } } /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs index cbb30494..9a0da679 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs +++ b/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; + +/// +/// 客户替换件关系 +/// +[AllowAnonymous] +[Route("api/settleaccount/[controller]/[action]")] +public class TB_RePartsRelationship_SERVICE : SettleAccountApplicationBase { /// - /// 客户替换件关系 + /// 客户替换件关系仓储 /// - [AllowAnonymous] - [Route("api/settleaccount/[controller]/[action]")] - public class TB_RePartsRelationship_SERVICE : SettleAccountApplicationBase + private readonly INormalEfCoreRepository _repository; + + public TB_RePartsRelationship_SERVICE( + INormalEfCoreRepository repository, + IDistributedCache cache, + IExcelImportAppService excelImportService, + ISnowflakeIdGenerator snowflakeIdGenerator, + ICommonManager commonManager + ) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) { - /// - /// 客户替换件关系仓储 - /// - private readonly INormalEfCoreRepository _repository; + _repository = repository; + } - public TB_RePartsRelationship_SERVICE( - INormalEfCoreRepository repository, - IDistributedCache cache, - IExcelImportAppService excelImportService, - ISnowflakeIdGenerator snowflakeIdGenerator, - ICommonManager commonManager - ) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) - { - _repository = repository; - } + #region 导入、导出 + /// + /// 导入 + /// + [HttpPost] + public async Task ImportAsync([FromForm] IFormFileCollection files) + { + ExportImporter _exportImporter = new ExportImporter(); + var result = await _exportImporter.UploadExcelImport(files, _excelImportService); + var _ls = ObjectMapper.Map, List>(result); + List _errorList = new List(); + var checkList = new List(); - #region 导入、导出 - /// - /// 导入 - /// - [HttpPost] - public async Task ImportAsync([FromForm] IFormFileCollection files) + if (_ls.Count > 0) { - ExportImporter _exportImporter = new ExportImporter(); - var result = await _exportImporter.UploadExcelImport(files, _excelImportService); - var _ls = ObjectMapper.Map, List>(result); - List _errorList = new List(); - var checkList = new List(); + 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; + } - /// - /// 导出 - /// - [HttpPost] - public async Task 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>(entities); - - ExportImporter _exportImporter = new ExportImporter(); - var result = await _exportImporter.ExcelExporter(dtos); - result.ShouldNotBeNull(); + /// + /// 导出 + /// + [HttpPost] + public async Task 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>(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 - /// - /// 获取列表 - /// - [HttpPost] - public async Task> 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>(entities); - return new PagedResultDto(totalCount, dtos); - } - #endregion + await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result }); + return fileName; + } + #endregion + #region CURD + /// + /// 获取列表 + /// + [HttpPost] + public async Task> 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>(entities); + return new PagedResultDto(totalCount, dtos); } + #endregion + } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs index 87625849..54eb5aae 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs +++ b/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 /// private void CreateMapTB_RePartsRelationship() { - CreateMap(); + CreateMap() + .ForMember(x => x.BusinessTypeDisplayName, y => y.MapFrom(t => t.BusinessType.GetType().GetField(t.BusinessType.ToString()).GetCustomAttribute().Name)); CreateMap(); CreateMap(); }