2 Commits

Author SHA1 Message Date
vaining01 0d6a7c3baa Merge branch 'master' of http://140.143.162.39:3000/shentun/peis 2 years ago
vaining01 1df9a933e3 00 2 years ago
  1. 13
      src/Shentun.Peis.Application.Contracts/ReportFormatTemplates/CopyCreateReportFormatTemplateDto.cs
  2. 11
      src/Shentun.Peis.Application.Contracts/ReportFormatTemplates/ReportFormatTemplateIdDto.cs
  3. 11
      src/Shentun.Peis.Application.Contracts/ReportFormats/ReportFormatIdInputDto.cs
  4. 11
      src/Shentun.Peis.Application.Contracts/ReportPrinters/ReportPrinterIdDto.cs
  5. 13
      src/Shentun.Peis.Application.Contracts/Reports/ComputerNameInputDto.cs
  6. 11
      src/Shentun.Peis.Application.Contracts/Reports/ReportIdInputDto.cs
  7. 1
      src/Shentun.Peis.Application.Contracts/Reports/UpdateReportDto.cs
  8. 4
      src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs
  9. 93
      src/Shentun.Peis.Application/ReportFormatTemplates/ReportFormatTemplateAppService.cs
  10. 84
      src/Shentun.Peis.Application/ReportFormats/ReportFormatAppService.cs
  11. 75
      src/Shentun.Peis.Application/ReportPrinters/ReportPrinterAppService.cs
  12. 101
      src/Shentun.Peis.Application/Reports/ReportAppService.cs

13
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; }
}
}

11
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; }
}
}

11
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; }
}
}

11
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; }
}
}

13
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; }
}
}

11
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; }
}
}

1
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; }

4
src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs

@ -410,17 +410,21 @@ public class PeisApplicationAutoMapperProfile : Profile
CreateMap<Report, ReportDto>();
CreateMap<ReportDto, Report>();
CreateMap<CreateReportDto, Report>();
CreateMap<UpdateReportDto, Report>();
CreateMap<ReportFormatDto, ReportFormat>();
CreateMap<ReportFormat, ReportFormatDto>();
CreateMap<CreateReportFormatDto, ReportFormat>();
CreateMap<UpdateReportFormatDto, ReportFormat>();
CreateMap<ReportFormatTemplateDto, ReportFormatTemplate>();
CreateMap<ReportFormatTemplate, ReportFormatTemplateDto>();
CreateMap<CreateReportFormatTemplateDto, ReportFormatTemplate>();
CreateMap<UpdateReportFormatTemplateDto, ReportFormatTemplate>();
CreateMap<ReportPrinterDto, ReportPrinter>();
CreateMap<ReportPrinter, ReportPrinterDto>();
CreateMap<CreateReportPrinterDto, ReportPrinter>();
CreateMap<UpdateReportPrinterDto, ReportPrinter>();

93
src/Shentun.Peis.Application/ReportFormatTemplates/ReportFormatTemplateAppService.cs

@ -19,13 +19,7 @@ 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<IdentityUser, Guid> _userRepository;
private readonly IRepository<Report, string> _reportRepository;
@ -38,7 +32,6 @@ namespace Shentun.Peis.ReportFormatTemplates
IRepository<Report, string> reportRepository,
IRepository<ReportFormat, string> reportFormatRepository,
ReportFormatTemplateManager manager)
: base(repository)
{
_userRepository = userRepository;
_manager = manager;
@ -46,6 +39,7 @@ namespace Shentun.Peis.ReportFormatTemplates
_reportFormatRepository = reportFormatRepository;
_reportRepository = reportRepository;
}
[HttpPost("api/app/ReportFormatTemplate/GetReportTemplate")]
public async Task<List<ReportFormatTemplateDto>> GetReportTemplateAsync()
{
var query = from a in await _reportFormatRepository.GetQueryableAsync()
@ -83,27 +77,29 @@ namespace Shentun.Peis.ReportFormatTemplates
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public override async Task<ReportFormatTemplateDto> GetAsync(string id)
[HttpPost("api/app/ReportFormatTemplate/GetById")]
public async Task<ReportFormatTemplateDto> GetByIdAsync(ReportFormatTemplateIdDto input)
{
var entity= await base.GetAsync(id);
var entity= await _reportFormatTemplateRepository.GetAsync(input.Id);
var aEntity = ObjectMapper.Map<ReportFormatTemplate, ReportFormatTemplateDto>(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<ReportFormatTemplateDto> GetMaxByIdAsync()
[HttpPost("api/app/ReportFormatTemplate/GetMaxId")]
public async Task<ReportFormatTemplateDto> GetMaxIdAsync()
{
var ent = (await Repository.GetListAsync()).Max(x => x.Id);
var ent = (await _reportFormatTemplateRepository.GetListAsync()).Max(x => x.Id);
var entdto = new ReportFormatTemplateDto
{
Id = !string.IsNullOrEmpty(ent)?ent:"0001"
};
return entdto;
}
[HttpPost("api/app/ReportFormatTemplate/GetDefault")]
public async Task<ReportFormatTemplateDto> GetDefaultAsync(string formatId)
{
var ent = await _manager.GetDefaultAsync(formatId);
@ -144,21 +140,37 @@ namespace Shentun.Peis.ReportFormatTemplates
/// 获取列表 项目
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public override async Task<PagedResultDto<ReportFormatTemplateDto>> GetListAsync(PagedAndSortedResultRequestDto input)
[HttpPost("api/app/ReportFormatTemplate/GetList")]
public async Task<List<ReportFormatTemplateDto>> GetListAsync(PagedAndSortedResultRequestDto input)
{
return await base.GetListAsync(input);
var reportList = await _reportFormatTemplateRepository.GetListAsync();
List<ReportFormatTemplateDto> templates = new List<ReportFormatTemplateDto>();
foreach (var template in reportList)
{
var aEntity = ObjectMapper.Map<ReportFormatTemplate, ReportFormatTemplateDto>(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;
}
/// <summary>
/// 获取列表 项目 可以带格式ID搜索
/// </summary>
/// <param name="reportFormatId"></param>
/// <param name="input"></param>
/// <returns></returns>
public async Task<PagedResultDto<ReportFormatTemplateDto>> GetListInReportFormatAsync(string reportFormatId)
[HttpPost("api/app/ReportFormatTemplate/GetListByReportFormatId")]
public async Task<PagedResultDto<ReportFormatTemplateDto>> GetListByReportFormatIdAsync(ReportFormatIdInputDto input)
{
int totalCount = 0;
var entlist = (await Repository.GetListAsync()).Where(m => m.ReportFormatId == reportFormatId);
var entlist = (await _reportFormatTemplateRepository.GetListAsync()).Where(m => m.ReportFormatId == input.Id);
totalCount = entlist.Count();
var userList = await _userRepository.GetListAsync();
@ -191,20 +203,20 @@ namespace Shentun.Peis.ReportFormatTemplates
/// 创建
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public override async Task<ReportFormatTemplateDto> CreateAsync(CreateReportFormatTemplateDto input)
[HttpPost("api/app/ReportFormatTemplate/Create")]
public async Task<ReportFormatTemplateDto> CreateAsync(CreateReportFormatTemplateDto input)
{
var createEntity = ObjectMapper.Map<CreateReportFormatTemplateDto, ReportFormatTemplate>(input);
var entity = await _manager.CreateAsync(createEntity);
entity = await Repository.InsertAsync(entity);
entity = await _reportFormatTemplateRepository.InsertAsync(entity);
var dto = ObjectMapper.Map<ReportFormatTemplate, ReportFormatTemplateDto>(entity);
return dto;
}
public async Task<ReportFormatTemplateDto> CopyCreateAsync(string id,string newId)
[HttpPost("api/app/ReportFormatTemplate/CopyCreate")]
public async Task<ReportFormatTemplateDto> 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 _reportFormatTemplateRepository.InsertAsync(entity);
var dto = ObjectMapper.Map<ReportFormatTemplate, ReportFormatTemplateDto>(entity);
return dto;
}
@ -216,13 +228,13 @@ namespace Shentun.Peis.ReportFormatTemplates
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("api/app/ReportFormatTemplate/Update")]
public override async Task<ReportFormatTemplateDto> UpdateAsync(string id, UpdateReportFormatTemplateDto input)
public async Task<ReportFormatTemplateDto> UpdateAsync(string id, UpdateReportFormatTemplateDto input)
{
var entity = await Repository.GetAsync(id);
var entity = await _reportFormatTemplateRepository.GetAsync(id);
var userList = await _userRepository.GetListAsync();
var sourceEntity = ObjectMapper.Map<UpdateReportFormatTemplateDto, ReportFormatTemplate>(input);
await _manager.UpdateAsync(sourceEntity, entity);
entity = await Repository.UpdateAsync(entity);
entity = await _reportFormatTemplateRepository.UpdateAsync(entity);
var dto= ObjectMapper.Map<ReportFormatTemplate, ReportFormatTemplateDto>(entity);
dto.IsDefaulted = entity.IsDefault.Equals('Y');
dto.IsSystemed= entity.IsSystem.Equals('Y');
@ -233,17 +245,18 @@ namespace Shentun.Peis.ReportFormatTemplates
/// <summary>
/// 删除
/// </summary>
/// <param name="id"></param>
/// <param name="input"></param>
/// <returns></returns>
public override Task DeleteAsync(string id)
[HttpPost("api/app/ReportFormatTemplate/Delete")]
public Task DeleteAsync(ReportFormatIdInputDto input)
{
return base.DeleteAsync(id);
return _reportFormatTemplateRepository.DeleteAsync(input.Id);
}
[HttpPut("api/app/reportfomattemplate/updatedefault")]
public async Task UpdateDefaultAsync(string id)
public async Task UpdateDefaultAsync(ReportFormatIdInputDto input)
{
await _manager.UpdateDefaultAsync(id);
await _manager.UpdateDefaultAsync(input.Id);
}
}
}

84
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<IdentityUser, Guid> _userRepository;
private readonly IRepository<ReportFormat, string> _repository;
private readonly ReportFormatManager _manager;
public ReportFormatAppService(
IRepository<ReportFormat, string> repository,
IRepository<IdentityUser, Guid> userRepository,
ReportFormatManager manager)
: base(repository)
{
_repository = repository;
_userRepository = userRepository;
_manager = manager;
}
@ -40,28 +36,31 @@ namespace Shentun.Peis.ReportFormats
/// <summary>
/// 获取通过主键
/// </summary>
/// <param name="id"></param>
/// <param name="input"></param>
/// <returns></returns>
public override async Task<ReportFormatDto> GetAsync(string id)
[HttpPost("api/app/ReportFormat/GetById")]
public async Task<ReportFormatDto> GeByIdtAsync(ReportFormatIdInputDto input)
{
var entity = await base.GetAsync(id);
var entity = await _repository.GetAsync(input.Id);
var aEntity = ObjectMapper.Map<ReportFormat, ReportFormatDto>(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<ReportFormatDto> 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;
}
[HttpPost("api/app/ReportFormat/GetDefault")]
public async Task<ReportFormatDto> GetDefaultAsync(string reportId)
{
var ent = await _manager.GetDefaultAsync(reportId);
@ -97,21 +96,37 @@ namespace Shentun.Peis.ReportFormats
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public override async Task<PagedResultDto<ReportFormatDto>> GetListAsync(PagedAndSortedResultRequestDto input)
[HttpPost("api/app/ReportFormat/GetList")]
public async Task<List<ReportFormatDto>> GetListAsync(PagedAndSortedResultRequestDto input)
{
return await base.GetListAsync(input);
var reportList = await _repository.GetListAsync();
List<ReportFormatDto> formats = new List<ReportFormatDto>();
foreach (var format in reportList)
{
var aEntity = ObjectMapper.Map<ReportFormat, ReportFormatDto>(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;
}
/// <summary>
/// 获取列表 项目 可以带报表ID搜索
/// </summary>
/// <param name="reportId"></param>
/// <param name="input"></param>
/// <returns></returns>
public async Task<PagedResultDto<ReportFormatDto>> GetListInReportAsync(string reportId)
[HttpPost("api/app/ReportFormat/GetListByReportId")]
public async Task<PagedResultDto<ReportFormatDto>> 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
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public override async Task<ReportFormatDto> CreateAsync(CreateReportFormatDto input)
[HttpPost("api/app/ReportFormat/Create")]
public async Task<ReportFormatDto> CreateAsync(CreateReportFormatDto input)
{
var createEntity = ObjectMapper.Map<CreateReportFormatDto, ReportFormat>(input);
var entity = await _manager.CreateAsync(createEntity);
entity = await Repository.InsertAsync(entity);
entity = await _repository.InsertAsync(entity);
var dto = ObjectMapper.Map<ReportFormat, ReportFormatDto>(entity);
return dto;
}
@ -155,13 +171,14 @@ namespace Shentun.Peis.ReportFormats
/// <param name="id"></param>
/// <param name="input"></param>
/// <returns></returns>
public override async Task<ReportFormatDto> UpdateAsync(string id, UpdateReportFormatDto input)
[HttpPost("api/app/ReportFormat/Update")]
public async Task<ReportFormatDto> 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<UpdateReportFormatDto, ReportFormat>(input);
await _manager.UpdateAsync(sourceEntity, entity);
entity = await Repository.UpdateAsync(entity);
entity = await _repository.UpdateAsync(entity);
var dto= ObjectMapper.Map<ReportFormat, ReportFormatDto>(entity);
dto.IsDefaulted= entity.IsDefault.Equals('Y');
dto.CreatorName = EntityHelper.GetSurnameNoSql(userList, entity.CreatorId);
@ -171,17 +188,18 @@ namespace Shentun.Peis.ReportFormats
/// <summary>
/// 删除
/// </summary>
/// <param name="id"></param>
/// <param name="input"></param>
/// <returns></returns>
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)
[HttpPut("api/app/ReportFormat/UpdateDefault")]
public async Task UpdateDefaultAsync(ReportFormatIdInputDto input)
{
await _manager.UpdateDefaultAsync(id);
await _manager.UpdateDefaultAsync(input.Id);
}
}
}

75
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<ReportPrinter, string> _repository;
private readonly IRepository<IdentityUser, Guid> _userRepository;
private readonly ReportPrinterManager _manager;
public ReportPrinterAppService(
IRepository<ReportPrinter, string> repository,
IRepository<IdentityUser, Guid> userRepository,
ReportPrinterManager manager)
: base(repository)
{
_repository = repository;
_userRepository = userRepository;
_manager = manager;
}
@ -42,24 +38,30 @@ namespace Shentun.Peis.ReportPrinters
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public override async Task<ReportPrinterDto> GetAsync(string id)
[HttpPost("api/app/ReportPrinter/GetById")]
public async Task<ReportPrinterDto> GetByIdAsync(ReportPrinterIdDto input)
{
return await base.GetAsync(id);
var entity = await _repository.GetAsync(input.Id);
var aEntity = ObjectMapper.Map<ReportPrinter, ReportPrinterDto>(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<ReportPrinterDto> GetMaxByIdAsync()
[HttpPost("api/app/ReportPrinter/GetMaxId")]
public async Task<ReportPrinterDto> 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<ReportPrinterDto> GetLocalPrinter(string reportId,string computerName)
[HttpPost("api/app/ReportPrinter/GetLocalPrinterByComputerName")]
public async Task<ReportPrinterDto> 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
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public override async Task<PagedResultDto<ReportPrinterDto>> GetListAsync(PagedAndSortedResultRequestDto input)
[HttpPost("api/app/ReportPrinter/GetList")]
public async Task<List<ReportPrinterDto>> GetListAsync(PagedAndSortedResultRequestDto input)
{
return await base.GetListAsync(input);
}
var reportList = await _repository.GetListAsync();
List<ReportPrinterDto> formats = new List<ReportPrinterDto>();
public async Task<PagedResultDto<ReportPrinterDto>> GetListInReportAsync(string reportId)
foreach (var format in reportList)
{
var aEntity = ObjectMapper.Map<ReportPrinter, ReportPrinterDto>(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<PagedResultDto<ReportPrinterDto>> 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
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public override async Task<ReportPrinterDto> CreateAsync(CreateReportPrinterDto input)
[HttpPost("api/app/ReportPrinter/Create")]
public async Task<ReportPrinterDto> CreateAsync(CreateReportPrinterDto input)
{
var createEntity = ObjectMapper.Map<CreateReportPrinterDto, ReportPrinter>(input);
var entity = await _manager.CreateAsync(createEntity);
entity = await Repository.InsertAsync(entity);
entity = await _repository.InsertAsync(entity);
var dto = ObjectMapper.Map<ReportPrinter, ReportPrinterDto>(entity);
return dto;
}
@ -141,13 +158,14 @@ namespace Shentun.Peis.ReportPrinters
/// <param name="id"></param>
/// <param name="input"></param>
/// <returns></returns>
public override async Task<ReportPrinterDto> UpdateAsync(string id, UpdateReportPrinterDto input)
[HttpPost("api/app/ReportPrinter/Update")]
public async Task<ReportPrinterDto> 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<ReportPrinter, ReportPrinterDto>(entity);
dto.CreatorName = EntityHelper.GetSurnameNoSql(userList, entity.CreatorId);
dto.LastModifierName = EntityHelper.GetSurnameNoSql(userList, entity.LastModifierId);
@ -158,9 +176,10 @@ namespace Shentun.Peis.ReportPrinters
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
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);
}
}
}

101
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<Report, string> _repository;
private readonly IRepository<IdentityUser, Guid> _userRepository;
private readonly IRepository<ReportFormat, string> _reportFormatRepository;
private readonly IRepository<ReportFormatTemplate,string> _reportFormatTemplateRepository;
private readonly IRepository<ReportFormatTemplate, string> _reportFormatTemplateRepository;
private readonly IRepository<ReportPrinter, string> _reportPrinterRespository;
private readonly IConfiguration _configuration;
private readonly ReportManager _manager;
public ReportAppService(
IRepository<Report,string> repository,
IRepository<Report, string> repository,
IRepository<IdentityUser, Guid> userRepository,
IRepository<ReportFormat, string> reportFormatRepository,
IRepository<ReportFormatTemplate, string> reportFormatTemplateRepository,
IRepository<ReportPrinter, string> 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;
}
/// <summary>
/// 获取通过主键
/// </summary>
/// <param name="id"></param>
/// <param name="inputDto"></param>
/// <returns></returns>
public override async Task<ReportDto> GetAsync(string id)
[HttpPost("api/app/Report/GetById")]
public async Task<ReportDto> 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<Report, ReportDto>(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;
}
/// <summary>
@ -79,26 +79,41 @@ namespace Shentun.Peis.Reports
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public override async Task<PagedResultDto<ReportDto>> GetListAsync(PagedAndSortedResultRequestDto input)
[HttpPost("api/app/Report/GetList")]
public async Task<List<ReportDto>> GetListAsync(PagedAndSortedResultRequestDto input)
{
return await base.GetListAsync(input);
}
var reportList = await _repository.GetListAsync();
List<ReportDto> reports= new List<ReportDto>();
foreach(var report in reportList)
{
var aEntity= ObjectMapper.Map<Report, ReportDto>(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<ReportDto> 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<PrintReportDto> GetPrintReport(string reportId,string computerName)
[HttpPost("api/app/Report/GetPrintReport")]
public async Task<PrintReportDto> 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<ReportFormatTemplate, ReportFormatTemplateDto>(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<ReportPrinter, ReportPrinterDto>(printerEntity);
@ -134,10 +149,10 @@ namespace Shentun.Peis.Reports
return printReportDto;
}
[HttpPost("api/app/Report/Upload")]
public async Task Upload(UploadPdfDto upload)
{
var PeisReportPdfPath = string.Format("{0}{1}\\{2}.pdf", _configuration.GetValue<string>("PeisReportPdfPath"),upload.ReportId,upload.PatientId);
var PeisReportPdfPath = string.Format("{0}{1}\\{2}.pdf", _configuration.GetValue<string>("PeisReportPdfPath"), upload.ReportId, upload.PatientId);
await FileHelper.Base64StringConvertPDF(upload.File, PeisReportPdfPath);
}
@ -146,17 +161,18 @@ namespace Shentun.Peis.Reports
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("api/app/Report/GetListInFilterNotOrder")]
public async Task<PagedResultDto<ReportDto>> 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
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public override async Task<ReportDto> CreateAsync(CreateReportDto input)
[HttpPost("api/app/Report/Create")]
public async Task<ReportDto> CreateAsync(CreateReportDto input)
{
var createEntity = ObjectMapper.Map<CreateReportDto, Report>(input);
var entity = await _manager.CreateAsync(createEntity);
entity = await Repository.InsertAsync(entity);
entity = await _repository.InsertAsync(entity);
var dto = ObjectMapper.Map<Report, ReportDto>(entity);
return dto;
}
@ -194,16 +211,16 @@ namespace Shentun.Peis.Reports
/// <summary>
/// 更新
/// </summary>
/// <param name="id"></param>
/// <param name="input"></param>
/// <returns></returns>
public override async Task<ReportDto> UpdateAsync(string id, UpdateReportDto input)
[HttpPost("api/app/Report/Update")]
public async Task<ReportDto> 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<UpdateReportDto, Report>(input);
await _manager.UpdateAsync(sourceEntity, entity);
entity = await Repository.UpdateAsync(entity);
entity = await _repository.UpdateAsync(entity);
var dto = ObjectMapper.Map<Report, ReportDto>(entity);
dto.IsActived = entity.IsActive.Equals('Y');
dto.CreatorName = EntityHelper.GetSurnameNoSql(userList, entity.CreatorId);
@ -213,11 +230,11 @@ namespace Shentun.Peis.Reports
/// <summary>
/// 删除
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public override Task DeleteAsync(string id)
/// <param name="input"></param>
[HttpPost("api/app/Report/Delete")]
public Task DeleteAsync(ReportIdInputDto input)
{
return base.DeleteAsync(id);
return _repository.DeleteAsync(input.Id);
}
}
}
Loading…
Cancel
Save