diff --git a/src/Shentun.Peis.Application.Contracts/ReportFormatTemplates/CopyCreateReportFormatTemplateDto.cs b/src/Shentun.Peis.Application.Contracts/ReportFormatTemplates/CopyCreateReportFormatTemplateDto.cs new file mode 100644 index 00000000..d964dad4 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/ReportFormatTemplates/CopyCreateReportFormatTemplateDto.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.ReportFormatTemplates +{ + public class CopyCreateReportFormatTemplateDto + { + public string Id { get; set; } + + public string NewId { get; set; } + } +} diff --git a/src/Shentun.Peis.Application.Contracts/ReportFormatTemplates/ReportFormatTemplateIdDto.cs b/src/Shentun.Peis.Application.Contracts/ReportFormatTemplates/ReportFormatTemplateIdDto.cs new file mode 100644 index 00000000..869d57bd --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/ReportFormatTemplates/ReportFormatTemplateIdDto.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.ReportFormatTemplates +{ + public class ReportFormatTemplateIdDto + { + public string Id { get; set; } + } +} diff --git a/src/Shentun.Peis.Application.Contracts/ReportFormatTemplates/UpdateReportFormatTemplateDto.cs b/src/Shentun.Peis.Application.Contracts/ReportFormatTemplates/UpdateReportFormatTemplateDto.cs index 33dfdc44..a67025a1 100644 --- a/src/Shentun.Peis.Application.Contracts/ReportFormatTemplates/UpdateReportFormatTemplateDto.cs +++ b/src/Shentun.Peis.Application.Contracts/ReportFormatTemplates/UpdateReportFormatTemplateDto.cs @@ -7,6 +7,7 @@ namespace Shentun.Peis.ReportFormatTemplates public class UpdateReportFormatTemplateDto { + public string Id { get; set; } public string ReportFormatId { get; set; } public string DisplayName { get; set; } diff --git a/src/Shentun.Peis.Application.Contracts/ReportFormats/ReportFormatIdInputDto.cs b/src/Shentun.Peis.Application.Contracts/ReportFormats/ReportFormatIdInputDto.cs new file mode 100644 index 00000000..3363315c --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/ReportFormats/ReportFormatIdInputDto.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.ReportFormats +{ + public class ReportFormatIdInputDto + { + public string Id { get; set; } + } +} diff --git a/src/Shentun.Peis.Application.Contracts/ReportPrinters/ReportPrinterIdDto.cs b/src/Shentun.Peis.Application.Contracts/ReportPrinters/ReportPrinterIdDto.cs new file mode 100644 index 00000000..e714e92d --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/ReportPrinters/ReportPrinterIdDto.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.ReportPrinters +{ + public class ReportPrinterIdDto + { + public string Id { get; set; } + } +} diff --git a/src/Shentun.Peis.Application.Contracts/Reports/ComputerNameInputDto.cs b/src/Shentun.Peis.Application.Contracts/Reports/ComputerNameInputDto.cs new file mode 100644 index 00000000..efe40e0d --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/Reports/ComputerNameInputDto.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.Reports +{ + public class ComputerNameInputDto + { + public string ReportId { get; set; } + + public string ComputerName { get; set; } + } +} diff --git a/src/Shentun.Peis.Application.Contracts/Reports/ReportIdInputDto.cs b/src/Shentun.Peis.Application.Contracts/Reports/ReportIdInputDto.cs new file mode 100644 index 00000000..095de534 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/Reports/ReportIdInputDto.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.Reports +{ + public class ReportIdInputDto + { + public string Id { get; set; } + } +} diff --git a/src/Shentun.Peis.Application.Contracts/Reports/UpdateReportDto.cs b/src/Shentun.Peis.Application.Contracts/Reports/UpdateReportDto.cs index e00f3d54..2558e6fb 100644 --- a/src/Shentun.Peis.Application.Contracts/Reports/UpdateReportDto.cs +++ b/src/Shentun.Peis.Application.Contracts/Reports/UpdateReportDto.cs @@ -6,6 +6,7 @@ namespace Shentun.Peis.Reports { public class UpdateReportDto { + public string Id { get; set; } public string DisplayName { get; set; } public char IsActive { get; set; } diff --git a/src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs b/src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs index d1589593..aa2c955d 100644 --- a/src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs +++ b/src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs @@ -410,17 +410,21 @@ public class PeisApplicationAutoMapperProfile : Profile CreateMap(); + CreateMap(); CreateMap(); CreateMap(); + CreateMap(); CreateMap(); CreateMap(); CreateMap(); + CreateMap(); CreateMap(); CreateMap(); CreateMap(); + CreateMap(); CreateMap(); CreateMap(); CreateMap(); diff --git a/src/Shentun.Peis.Application/ReportFormatTemplates/ReportFormatTemplateAppService.cs b/src/Shentun.Peis.Application/ReportFormatTemplates/ReportFormatTemplateAppService.cs index 70f94d07..d6517031 100644 --- a/src/Shentun.Peis.Application/ReportFormatTemplates/ReportFormatTemplateAppService.cs +++ b/src/Shentun.Peis.Application/ReportFormatTemplates/ReportFormatTemplateAppService.cs @@ -19,18 +19,12 @@ using static Org.BouncyCastle.Bcpg.Attr.ImageAttrib; namespace Shentun.Peis.ReportFormatTemplates { //[Authorize] - public class ReportFormatTemplateAppService : CrudAppService< - ReportFormatTemplate, //The Book entity - ReportFormatTemplateDto, //Used to show books - string, //Primary key of the book entity - PagedAndSortedResultRequestDto, //Used for paging/sorting - CreateReportFormatTemplateDto, - UpdateReportFormatTemplateDto> + public class ReportFormatTemplateAppService : ApplicationService { private readonly IRepository _userRepository; private readonly IRepository _reportRepository; private readonly IRepository _reportFormatRepository; - private readonly IRepository _reportFormatTemplateRepository; + private readonly IRepository _repository; private readonly ReportFormatTemplateManager _manager; public ReportFormatTemplateAppService( IRepository repository, @@ -38,20 +32,20 @@ namespace Shentun.Peis.ReportFormatTemplates IRepository reportRepository, IRepository reportFormatRepository, ReportFormatTemplateManager manager) - : base(repository) { + _repository = repository; _userRepository = userRepository; _manager = manager; - _reportFormatTemplateRepository = repository; _reportFormatRepository = reportFormatRepository; _reportRepository = reportRepository; } - public async Task> GetReportTemplateAsync() + [HttpPost("api/app/ReportFormatTemplate/GetDefalutReportTemplates")] + public async Task> GetDefalutReportTemplateAsync() { var query = from a in await _reportFormatRepository.GetQueryableAsync() join b in await _reportRepository.GetQueryableAsync() on a.ReportId equals b.Id into bb from ab in bb.DefaultIfEmpty() - join c in await _reportFormatTemplateRepository.GetQueryableAsync() on a.Id equals c.ReportFormatId into cc + join c in await _repository.GetQueryableAsync() on a.Id equals c.ReportFormatId into cc from ac in cc.DefaultIfEmpty() where (a.IsDefault=='Y' &&ab.IsActive=='Y'&&ac.IsDefault== 'Y') select new @@ -81,32 +75,34 @@ namespace Shentun.Peis.ReportFormatTemplates /// /// 获取通过主键 /// - /// + /// /// - public override async Task GetAsync(string id) + [HttpPost("api/app/ReportFormatTemplate/GetById")] + public async Task GetByIdAsync(ReportFormatTemplateIdDto input) { - var entity= await base.GetAsync(id); + var entity= await _repository.GetAsync(input.Id); + var aEntity = ObjectMapper.Map(entity); var userList = await _userRepository.GetListAsync(); - entity.IsDefaulted = entity.IsDefault.Equals('Y'); - entity.IsSystemed = entity.IsSystem.Equals('Y'); - entity.CreatorName = EntityHelper.GetSurnameNoSql(userList, entity.CreatorId); - entity.LastModifierName = EntityHelper.GetSurnameNoSql(userList, entity.LastModifierId); - return entity; + aEntity.IsDefaulted = entity.IsDefault.Equals('Y'); + aEntity.IsSystemed = entity.IsSystem.Equals('Y'); + aEntity.CreatorName = EntityHelper.GetSurnameNoSql(userList, entity.CreatorId); + aEntity.LastModifierName = EntityHelper.GetSurnameNoSql(userList, entity.LastModifierId); + return aEntity; } - - public async Task GetMaxByIdAsync() + [HttpPost("api/app/ReportFormatTemplate/GetMaxId")] + public async Task GetMaxIdAsync() { - var ent = (await Repository.GetListAsync()).Max(x => x.Id); + var ent = (await _repository.GetListAsync()).Max(x => x.Id); var entdto = new ReportFormatTemplateDto { Id = !string.IsNullOrEmpty(ent)?ent:"0001" }; return entdto; } - - public async Task GetDefaultAsync(string formatId) + [HttpPost("api/app/ReportFormatTemplate/GetDefault")] + public async Task GetDefaultAsync(ReportFormatIdInputDto input) { - var ent = await _manager.GetDefaultAsync(formatId); + var ent = await _manager.GetDefaultAsync(input.Id); if (ent != null) { @@ -144,21 +140,37 @@ namespace Shentun.Peis.ReportFormatTemplates /// 获取列表 项目 /// /// - /// - public override async Task> GetListAsync(PagedAndSortedResultRequestDto input) + [HttpPost("api/app/ReportFormatTemplate/GetList")] + public async Task> GetListAsync(PagedAndSortedResultRequestDto input) { - return await base.GetListAsync(input); + var reportList = await _repository.GetListAsync(); + + List templates = new List(); + + foreach (var template in reportList) + { + var aEntity = ObjectMapper.Map(template); + var userList = await _userRepository.GetListAsync(); + aEntity.IsDefaulted = template.IsDefault.Equals('Y'); + aEntity.IsSystemed = template.IsSystem.Equals('Y'); + aEntity.CreatorName = EntityHelper.GetSurnameNoSql(userList, template.CreatorId); + aEntity.LastModifierName = EntityHelper.GetSurnameNoSql(userList, template.LastModifierId); + templates.Add(aEntity); + } + + return templates; } /// /// 获取列表 项目 可以带格式ID搜索 /// - /// + /// /// - public async Task> GetListInReportFormatAsync(string reportFormatId) + [HttpPost("api/app/ReportFormatTemplate/GetListByReportFormatId")] + public async Task> GetListByReportFormatIdAsync(ReportFormatIdInputDto input) { int totalCount = 0; - var entlist = (await Repository.GetListAsync()).Where(m => m.ReportFormatId == reportFormatId); + var entlist = (await _repository.GetListAsync()).Where(m => m.ReportFormatId == input.Id); totalCount = entlist.Count(); var userList = await _userRepository.GetListAsync(); @@ -191,20 +203,20 @@ namespace Shentun.Peis.ReportFormatTemplates /// 创建 /// /// - /// - public override async Task CreateAsync(CreateReportFormatTemplateDto input) + [HttpPost("api/app/ReportFormatTemplate/Create")] + public async Task CreateAsync(CreateReportFormatTemplateDto input) { var createEntity = ObjectMapper.Map(input); var entity = await _manager.CreateAsync(createEntity); - entity = await Repository.InsertAsync(entity); + entity = await _repository.InsertAsync(entity); var dto = ObjectMapper.Map(entity); return dto; } - - public async Task CopyCreateAsync(string id,string newId) + [HttpPost("api/app/ReportFormatTemplate/CopyCreate")] + public async Task CopyCreateAsync(CopyCreateReportFormatTemplateDto input) { - var entity = await _manager.CopyCreateAsync(id,newId); - entity = await Repository.InsertAsync(entity); + var entity = await _manager.CopyCreateAsync(input.Id, input.NewId); + entity = await _repository.InsertAsync(entity); var dto = ObjectMapper.Map(entity); return dto; } @@ -216,13 +228,13 @@ namespace Shentun.Peis.ReportFormatTemplates /// /// [HttpPost("api/app/ReportFormatTemplate/Update")] - public override async Task UpdateAsync(string id, UpdateReportFormatTemplateDto input) + public async Task UpdateAsync(UpdateReportFormatTemplateDto input) { - var entity = await Repository.GetAsync(id); + var entity = await _repository.GetAsync(input.Id); var userList = await _userRepository.GetListAsync(); var sourceEntity = ObjectMapper.Map(input); await _manager.UpdateAsync(sourceEntity, entity); - entity = await Repository.UpdateAsync(entity); + entity = await _repository.UpdateAsync(entity); var dto= ObjectMapper.Map(entity); dto.IsDefaulted = entity.IsDefault.Equals('Y'); dto.IsSystemed= entity.IsSystem.Equals('Y'); @@ -233,17 +245,18 @@ namespace Shentun.Peis.ReportFormatTemplates /// /// 删除 /// - /// + /// /// - public override Task DeleteAsync(string id) + [HttpPost("api/app/ReportFormatTemplate/Delete")] + public Task DeleteAsync(ReportFormatIdInputDto input) { - return base.DeleteAsync(id); + return _repository.DeleteAsync(input.Id); } - [HttpPut("api/app/reportfomattemplate/updatedefault")] - public async Task UpdateDefaultAsync(string id) + [HttpPost("api/app/reportfomattemplate/UpdateDefault")] + public async Task UpdateDefaultAsync(ReportFormatIdInputDto input) { - await _manager.UpdateDefaultAsync(id); + await _manager.UpdateDefaultAsync(input.Id); } } } diff --git a/src/Shentun.Peis.Application/ReportFormats/ReportFormatAppService.cs b/src/Shentun.Peis.Application/ReportFormats/ReportFormatAppService.cs index 4b898e94..d5eeb536 100644 --- a/src/Shentun.Peis.Application/ReportFormats/ReportFormatAppService.cs +++ b/src/Shentun.Peis.Application/ReportFormats/ReportFormatAppService.cs @@ -17,22 +17,18 @@ using Volo.Abp.ObjectMapping; namespace Shentun.Peis.ReportFormats { //[Authorize] - public class ReportFormatAppService : CrudAppService< - ReportFormat, //The Book entity - ReportFormatDto, //Used to show books - string, //Primary key of the book entity - PagedAndSortedResultRequestDto, //Used for paging/sorting - CreateReportFormatDto, - UpdateReportFormatDto> + public class ReportFormatAppService : ApplicationService { private readonly IRepository _userRepository; + private readonly IRepository _repository; private readonly ReportFormatManager _manager; public ReportFormatAppService( IRepository repository, IRepository userRepository, ReportFormatManager manager) - : base(repository) + { + _repository = repository; _userRepository = userRepository; _manager = manager; } @@ -40,31 +36,34 @@ namespace Shentun.Peis.ReportFormats /// /// 获取通过主键 /// - /// + /// /// - public override async Task GetAsync(string id) + [HttpPost("api/app/ReportFormat/GetById")] + public async Task GeByIdtAsync(ReportFormatIdInputDto input) { - var entity = await base.GetAsync(id); + var entity = await _repository.GetAsync(input.Id); + var aEntity = ObjectMapper.Map(entity); var userList = await _userRepository.GetListAsync(); - entity.IsDefaulted = entity.IsDefault.Equals('Y'); - entity.CreatorName = EntityHelper.GetSurnameNoSql(userList, entity.CreatorId); - entity.LastModifierName = EntityHelper.GetSurnameNoSql(userList, entity.LastModifierId); - return entity; + aEntity.IsDefaulted = entity.IsDefault.Equals('Y'); + aEntity.CreatorName = EntityHelper.GetSurnameNoSql(userList, entity.CreatorId); + aEntity.LastModifierName = EntityHelper.GetSurnameNoSql(userList, entity.LastModifierId); + return aEntity; } + [HttpPost("api/app/ReportFormat/GetMaxId")] public async Task GetMaxByIdAsync() { - var ent = (await Repository.GetListAsync()).Max(x => x.Id); + var ent = (await _repository.GetListAsync()).Max(x => x.Id); var entdto = new ReportFormatDto { Id = !string.IsNullOrEmpty(ent) ? ent : "0001" }; return entdto; } - - public async Task GetDefaultAsync(string reportId) + [HttpPost("api/app/ReportFormat/GetDefault")] + public async Task GetDefaultAsync(ReportIdInputDto input) { - var ent = await _manager.GetDefaultAsync(reportId); + var ent = await _manager.GetDefaultAsync(input.Id); if (ent!=null) { @@ -97,21 +96,37 @@ namespace Shentun.Peis.ReportFormats /// /// /// - public override async Task> GetListAsync(PagedAndSortedResultRequestDto input) + [HttpPost("api/app/ReportFormat/GetList")] + public async Task> GetListAsync(PagedAndSortedResultRequestDto input) { - return await base.GetListAsync(input); + var reportList = await _repository.GetListAsync(); + + List formats = new List(); + + foreach (var format in reportList) + { + var aEntity = ObjectMapper.Map(format); + var userList = await _userRepository.GetListAsync(); + aEntity.IsDefaulted = format.IsDefault.Equals('Y'); + aEntity.CreatorName = EntityHelper.GetSurnameNoSql(userList, format.CreatorId); + aEntity.LastModifierName = EntityHelper.GetSurnameNoSql(userList, format.LastModifierId); + formats.Add(aEntity); + } + + return formats; } /// /// 获取列表 项目 可以带报表ID搜索 /// - /// + /// /// - public async Task> GetListInReportAsync(string reportId) + [HttpPost("api/app/ReportFormat/GetListByReportId")] + public async Task> GetListByReportIdAsync(ReportIdInputDto input) { int totalCount = 0; - var entlist = (await Repository.GetListAsync()).Where(m => m.ReportId == reportId); + var entlist = (await _repository.GetListAsync()).Where(m => m.ReportId == input.Id); totalCount = entlist.Count(); var userList = await _userRepository.GetListAsync(); @@ -140,11 +155,12 @@ namespace Shentun.Peis.ReportFormats /// /// /// - public override async Task CreateAsync(CreateReportFormatDto input) + [HttpPost("api/app/ReportFormat/Create")] + public async Task CreateAsync(CreateReportFormatDto input) { var createEntity = ObjectMapper.Map(input); var entity = await _manager.CreateAsync(createEntity); - entity = await Repository.InsertAsync(entity); + entity = await _repository.InsertAsync(entity); var dto = ObjectMapper.Map(entity); return dto; } @@ -155,13 +171,14 @@ namespace Shentun.Peis.ReportFormats /// /// /// - public override async Task UpdateAsync(string id, UpdateReportFormatDto input) + [HttpPost("api/app/ReportFormat/Update")] + public async Task UpdateAsync(string id, UpdateReportFormatDto input) { - var entity = await Repository.GetAsync(id); + var entity = await _repository.GetAsync(id); var userList = await _userRepository.GetListAsync(); var sourceEntity = ObjectMapper.Map(input); await _manager.UpdateAsync(sourceEntity, entity); - entity = await Repository.UpdateAsync(entity); + entity = await _repository.UpdateAsync(entity); var dto= ObjectMapper.Map(entity); dto.IsDefaulted= entity.IsDefault.Equals('Y'); dto.CreatorName = EntityHelper.GetSurnameNoSql(userList, entity.CreatorId); @@ -171,17 +188,18 @@ namespace Shentun.Peis.ReportFormats /// /// 删除 /// - /// + /// /// - public override Task DeleteAsync(string id) + [HttpPost("api/app/ReportFormat/Delete")] + public Task DeleteAsync(ReportFormatIdInputDto input) { - return base.DeleteAsync(id); + return _repository.DeleteAsync(input.Id); } - [HttpPut("api/app/reportfomat/updatedefault")] - public async Task UpdateDefaultAsync(string id) + [HttpPost("api/app/ReportFormat/UpdateDefault")] + public async Task UpdateDefaultAsync(ReportFormatIdInputDto input) { - await _manager.UpdateDefaultAsync(id); + await _manager.UpdateDefaultAsync(input.Id); } } } diff --git a/src/Shentun.Peis.Application/ReportPrinters/ReportPrinterAppService.cs b/src/Shentun.Peis.Application/ReportPrinters/ReportPrinterAppService.cs index d9b591cc..f902b886 100644 --- a/src/Shentun.Peis.Application/ReportPrinters/ReportPrinterAppService.cs +++ b/src/Shentun.Peis.Application/ReportPrinters/ReportPrinterAppService.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; using Shentun.Peis.Models; using Shentun.Peis.ReportFormats; using Shentun.Peis.ReportFormatTemplates; @@ -17,22 +18,17 @@ using Volo.Abp.ObjectMapping; namespace Shentun.Peis.ReportPrinters { //[Authorize] - public class ReportPrinterAppService : CrudAppService< - ReportPrinter, //The Book entity - ReportPrinterDto, //Used to show books - string, //Primary key of the book entity - PagedAndSortedResultRequestDto, //Used for paging/sorting - CreateReportPrinterDto, - UpdateReportPrinterDto> + public class ReportPrinterAppService : ApplicationService { + private readonly IRepository _repository; private readonly IRepository _userRepository; private readonly ReportPrinterManager _manager; public ReportPrinterAppService( IRepository repository, IRepository userRepository, ReportPrinterManager manager) - : base(repository) { + _repository = repository; _userRepository = userRepository; _manager = manager; } @@ -42,24 +38,30 @@ namespace Shentun.Peis.ReportPrinters /// /// /// - public override async Task GetAsync(string id) + [HttpPost("api/app/ReportPrinter/GetById")] + public async Task GetByIdAsync(ReportPrinterIdDto input) { - return await base.GetAsync(id); + var entity = await _repository.GetAsync(input.Id); + var aEntity = ObjectMapper.Map(entity); + var userList = await _userRepository.GetListAsync(); + aEntity.CreatorName = EntityHelper.GetSurnameNoSql(userList, entity.CreatorId); + aEntity.LastModifierName = EntityHelper.GetSurnameNoSql(userList, entity.LastModifierId); + return aEntity; } - - public async Task GetMaxByIdAsync() + [HttpPost("api/app/ReportPrinter/GetMaxId")] + public async Task GetMaxIdAsync() { - var ent = (await Repository.GetListAsync()).Max(x => x.Id); + var ent = (await _repository.GetListAsync()).Max(x => x.Id); var entdto = new ReportPrinterDto { Id = !string.IsNullOrEmpty(ent) ? ent : "0001" }; return entdto; } - - public async Task GetLocalPrinter(string reportId,string computerName) + [HttpPost("api/app/ReportPrinter/GetLocalPrinterByComputerName")] + public async Task GetLocalPrinter(ComputerNameInputDto input) { - var ent = (await Repository.GetListAsync()).Where(m => m.ReportId == reportId && m.ComputerName.Equals(computerName)).FirstOrDefault(); + var ent = (await _repository.GetListAsync()).Where(m => m.ReportId == input.ReportId && m.ComputerName.Equals(input.ComputerName)).FirstOrDefault(); if (ent != null) { var userList = await _userRepository.GetListAsync(); @@ -89,16 +91,30 @@ namespace Shentun.Peis.ReportPrinters /// /// /// - public override async Task> GetListAsync(PagedAndSortedResultRequestDto input) + [HttpPost("api/app/ReportPrinter/GetList")] + public async Task> GetListAsync(PagedAndSortedResultRequestDto input) { - return await base.GetListAsync(input); - } + var reportList = await _repository.GetListAsync(); + + List formats = new List(); - public async Task> GetListInReportAsync(string reportId) + foreach (var format in reportList) + { + var aEntity = ObjectMapper.Map(format); + var userList = await _userRepository.GetListAsync(); + aEntity.CreatorName = EntityHelper.GetSurnameNoSql(userList, format.CreatorId); + aEntity.LastModifierName = EntityHelper.GetSurnameNoSql(userList, format.LastModifierId); + formats.Add(aEntity); + } + + return formats; + } + [HttpPost("api/app/ReportPrinter/GetListByReportId")] + public async Task> GetListByReportIdAsync(ReportIdInputDto input) { int totalCount = 0; - var entlist = (await Repository.GetListAsync()).Where(m => m.ReportId == reportId); + var entlist = (await _repository.GetListAsync()).Where(m => m.ReportId == input.Id); totalCount = entlist.Count(); var userList = await _userRepository.GetListAsync(); @@ -126,11 +142,12 @@ namespace Shentun.Peis.ReportPrinters /// /// /// - public override async Task CreateAsync(CreateReportPrinterDto input) + [HttpPost("api/app/ReportPrinter/Create")] + public async Task CreateAsync(CreateReportPrinterDto input) { var createEntity = ObjectMapper.Map(input); var entity = await _manager.CreateAsync(createEntity); - entity = await Repository.InsertAsync(entity); + entity = await _repository.InsertAsync(entity); var dto = ObjectMapper.Map(entity); return dto; } @@ -141,13 +158,14 @@ namespace Shentun.Peis.ReportPrinters /// /// /// - public override async Task UpdateAsync(string id, UpdateReportPrinterDto input) + [HttpPost("api/app/ReportPrinter/Update")] + public async Task UpdateAsync(string id, UpdateReportPrinterDto input) { var userList = await _userRepository.GetListAsync(); - var entity = await Repository.GetAsync(id); + var entity = await _repository.GetAsync(id); var sourceEntity = ObjectMapper.Map< UpdateReportPrinterDto, ReportPrinter>(input); await _manager.UpdateAsync(sourceEntity, entity); - entity = await Repository.UpdateAsync(entity); + entity = await _repository.UpdateAsync(entity); var dto= ObjectMapper.Map(entity); dto.CreatorName = EntityHelper.GetSurnameNoSql(userList, entity.CreatorId); dto.LastModifierName = EntityHelper.GetSurnameNoSql(userList, entity.LastModifierId); @@ -158,9 +176,10 @@ namespace Shentun.Peis.ReportPrinters /// /// /// - public override Task DeleteAsync(string id) + [HttpPost("api/app/ReportPrinter/Delete")] + public Task DeleteAsync(ReportPrinterIdDto input) { - return base.DeleteAsync(id); + return _repository.DeleteAsync(input.Id); } } } diff --git a/src/Shentun.Peis.Application/Reports/ReportAppService.cs b/src/Shentun.Peis.Application/Reports/ReportAppService.cs index f0942bae..f606452a 100644 --- a/src/Shentun.Peis.Application/Reports/ReportAppService.cs +++ b/src/Shentun.Peis.Application/Reports/ReportAppService.cs @@ -22,33 +22,29 @@ using Microsoft.AspNetCore.Mvc; using Volo.Abp.ObjectMapping; using Shentun.Peis.ReportPrinters; using Microsoft.Extensions.Configuration; +using Volo.Abp.Domain.Entities; namespace Shentun.Peis.Reports { //[Authorize] - public class ReportAppService : CrudAppService< - Report, //The Book entity - ReportDto, //Used to show books - string, //Primary key of the book entity - PagedAndSortedResultRequestDto, //Used for paging/sorting - CreateReportDto, - UpdateReportDto> + public class ReportAppService : ApplicationService { + private readonly IRepository _repository; private readonly IRepository _userRepository; private readonly IRepository _reportFormatRepository; - private readonly IRepository _reportFormatTemplateRepository; + private readonly IRepository _reportFormatTemplateRepository; private readonly IRepository _reportPrinterRespository; private readonly IConfiguration _configuration; private readonly ReportManager _manager; public ReportAppService( - IRepository repository, + IRepository repository, IRepository userRepository, IRepository reportFormatRepository, IRepository reportFormatTemplateRepository, IRepository reportPrinterRespository, IConfiguration configuration, ReportManager manager) - : base(repository) + { _userRepository = userRepository; _reportFormatRepository = reportFormatRepository; @@ -56,22 +52,26 @@ namespace Shentun.Peis.Reports _reportPrinterRespository = reportPrinterRespository; _manager = manager; _configuration = configuration; + _repository = repository; } /// /// 获取通过主键 /// - /// + /// /// - public override async Task GetAsync(string id) + [HttpPost("api/app/Report/GetById")] + public async Task GetByIdAsync(ReportIdInputDto inputDto) { //return await base.GetAsync(id); - var entity= await base.GetAsync(id); + var entity = await _repository.GetAsync(inputDto.Id); + var aEntity = ObjectMapper.Map(entity); + var userList = await _userRepository.GetListAsync(); - entity.IsActived = entity.IsActive.Equals('Y'); - entity.CreatorName = EntityHelper.GetSurnameNoSql(userList, entity.CreatorId); - entity.LastModifierName = EntityHelper.GetSurnameNoSql(userList, entity.LastModifierId); - return entity; + aEntity.IsActived = entity.IsActive.Equals('Y'); + aEntity.CreatorName = EntityHelper.GetSurnameNoSql(userList, entity.CreatorId); + aEntity.LastModifierName = EntityHelper.GetSurnameNoSql(userList, entity.LastModifierId); + return aEntity; } /// @@ -79,26 +79,41 @@ namespace Shentun.Peis.Reports /// /// /// - public override async Task> GetListAsync(PagedAndSortedResultRequestDto input) + [HttpPost("api/app/Report/GetList")] + public async Task> GetListAsync(PagedAndSortedResultRequestDto input) { - return await base.GetListAsync(input); - } + var reportList = await _repository.GetListAsync(); + + List reports= new List(); + + foreach(var report in reportList) + { + var aEntity= ObjectMapper.Map(report); + var userList = await _userRepository.GetListAsync(); + aEntity.IsActived = report.IsActive.Equals('Y'); + aEntity.CreatorName = EntityHelper.GetSurnameNoSql(userList, report.CreatorId); + aEntity.LastModifierName = EntityHelper.GetSurnameNoSql(userList, report.LastModifierId); + reports.Add(aEntity); + } + return reports; + } + [HttpPost("api/app/Report/GetMaxId")] public async Task GetMaxByIdAsync() { - var ent = (await Repository.GetListAsync()).Max(x => x.Id); + var ent = (await _repository.GetListAsync()).Max(x => x.Id); var entdto = new ReportDto { Id = !string.IsNullOrEmpty(ent) ? ent : "0001" }; return entdto; } - - public async Task GetPrintReport(string reportId,string computerName) + [HttpPost("api/app/Report/GetPrintReport")] + public async Task GetPrintReport(ComputerNameInputDto input) { - + PrintReportDto printReportDto = new PrintReportDto(); - var entity = await base.GetEntityByIdAsync(reportId); + var entity = await _repository.GetAsync(input.ReportId); if (entity == null) return null; if (!entity.IsActive.Equals('Y')) throw new Volo.Abp.UserFriendlyException($"报表:【'{entity.DisplayName}'】未启用,请启用后再操作"); @@ -119,11 +134,11 @@ namespace Shentun.Peis.Reports var userList = await _userRepository.GetListAsync(); var dto = ObjectMapper.Map(dtotmp); dto.IsDefaulted = dtotmp.IsDefault.Equals('Y'); - dto.IsSystemed= dtotmp.IsSystem.Equals('Y'); + dto.IsSystemed = dtotmp.IsSystem.Equals('Y'); dto.CreatorName = EntityHelper.GetSurnameNoSql(userList, entity.CreatorId); dto.LastModifierName = EntityHelper.GetSurnameNoSql(userList, entity.LastModifierId); printReportDto.reportFormatTemplate = dto; - var printerEntity = await _reportPrinterRespository.FirstOrDefaultAsync(p => p.ReportId.Equals(reportId) && p.ComputerName.Equals(computerName)); + var printerEntity = await _reportPrinterRespository.FirstOrDefaultAsync(p => p.ReportId.Equals(input.ReportId) && p.ComputerName.Equals(input.ComputerName)); if (printerEntity != null) { var printer = ObjectMapper.Map(printerEntity); @@ -131,32 +146,33 @@ namespace Shentun.Peis.Reports printer.LastModifierName = EntityHelper.GetSurnameNoSql(userList, printerEntity.LastModifierId); printReportDto.reportPrinter = printer; } - + return printReportDto; } - + [HttpPost("api/app/Report/Upload")] public async Task Upload(UploadPdfDto upload) { - var PeisReportPdfPath = string.Format("{0}{1}\\{2}.pdf", _configuration.GetValue("PeisReportPdfPath"),upload.ReportId,upload.PatientId); + var PeisReportPdfPath = string.Format("{0}{1}\\{2}.pdf", _configuration.GetValue("PeisReportPdfPath"), upload.ReportId, upload.PatientId); await FileHelper.Base64StringConvertPDF(upload.File, PeisReportPdfPath); } - + /// /// 获取列表 项目 可以带名称搜索 /// /// /// + [HttpPost("api/app/Report/GetListInFilterNotOrder")] public async Task> GetListInFilterNotOrderAsync(GetListInFilterPageDto input) { int totalCount = 0; if (!string.IsNullOrEmpty(input.Filter)) - totalCount = (await Repository.GetListAsync()).Where(m => m.DisplayName.Contains(input.Filter)).Count(); + totalCount = (await _repository.GetListAsync()).Where(m => m.DisplayName.Contains(input.Filter)).Count(); else - totalCount = await Repository.CountAsync(); + totalCount = await _repository.CountAsync(); - var entlist = await PageHelper.GetPageListInFitlerNotOrder(Repository, _userRepository, input); + var entlist = await PageHelper.GetPageListInFitlerNotOrder(_repository, _userRepository, input); var userList = await _userRepository.GetListAsync(); var entdto = entlist.Select(s => new ReportDto { @@ -167,7 +183,7 @@ namespace Shentun.Peis.Reports LastModificationTime = s.LastModificationTime, LastModifierId = s.LastModifierId, IsActive = s.IsActive, - IsActived=s.IsActive.Equals('Y'), + IsActived = s.IsActive.Equals('Y'), CreatorName = EntityHelper.GetSurnameNoSql(userList, s.CreatorId), LastModifierName = EntityHelper.GetSurnameNoSql(userList, s.LastModifierId) }).ToList(); @@ -182,11 +198,12 @@ namespace Shentun.Peis.Reports /// /// /// - public override async Task CreateAsync(CreateReportDto input) + [HttpPost("api/app/Report/Create")] + public async Task CreateAsync(CreateReportDto input) { var createEntity = ObjectMapper.Map(input); var entity = await _manager.CreateAsync(createEntity); - entity = await Repository.InsertAsync(entity); + entity = await _repository.InsertAsync(entity); var dto = ObjectMapper.Map(entity); return dto; } @@ -194,16 +211,16 @@ namespace Shentun.Peis.Reports /// /// 更新 /// - /// /// /// - public override async Task UpdateAsync(string id, UpdateReportDto input) + [HttpPost("api/app/Report/Update")] + public async Task UpdateAsync(UpdateReportDto input) { - var entity = await Repository.GetAsync(id); + var entity = await _repository.GetAsync(input.Id); var userList = await _userRepository.GetListAsync(); var sourceEntity = ObjectMapper.Map(input); await _manager.UpdateAsync(sourceEntity, entity); - entity = await Repository.UpdateAsync(entity); + entity = await _repository.UpdateAsync(entity); var dto = ObjectMapper.Map(entity); dto.IsActived = entity.IsActive.Equals('Y'); dto.CreatorName = EntityHelper.GetSurnameNoSql(userList, entity.CreatorId); @@ -213,11 +230,11 @@ namespace Shentun.Peis.Reports /// /// 删除 /// - /// - /// - public override Task DeleteAsync(string id) + /// + [HttpPost("api/app/Report/Delete")] + public Task DeleteAsync(ReportIdInputDto input) { - return base.DeleteAsync(id); + return _repository.DeleteAsync(input.Id); } } }