|
|
@ -22,33 +22,29 @@ using Microsoft.AspNetCore.Mvc; |
|
|
using Volo.Abp.ObjectMapping; |
|
|
using Volo.Abp.ObjectMapping; |
|
|
using Shentun.Peis.ReportPrinters; |
|
|
using Shentun.Peis.ReportPrinters; |
|
|
using Microsoft.Extensions.Configuration; |
|
|
using Microsoft.Extensions.Configuration; |
|
|
|
|
|
using Volo.Abp.Domain.Entities; |
|
|
|
|
|
|
|
|
namespace Shentun.Peis.Reports |
|
|
namespace Shentun.Peis.Reports |
|
|
{ |
|
|
{ |
|
|
//[Authorize]
|
|
|
//[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<IdentityUser, Guid> _userRepository; |
|
|
private readonly IRepository<ReportFormat, string> _reportFormatRepository; |
|
|
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 IRepository<ReportPrinter, string> _reportPrinterRespository; |
|
|
private readonly IConfiguration _configuration; |
|
|
private readonly IConfiguration _configuration; |
|
|
private readonly ReportManager _manager; |
|
|
private readonly ReportManager _manager; |
|
|
public ReportAppService( |
|
|
public ReportAppService( |
|
|
IRepository<Report,string> repository, |
|
|
|
|
|
|
|
|
IRepository<Report, string> repository, |
|
|
IRepository<IdentityUser, Guid> userRepository, |
|
|
IRepository<IdentityUser, Guid> userRepository, |
|
|
IRepository<ReportFormat, string> reportFormatRepository, |
|
|
IRepository<ReportFormat, string> reportFormatRepository, |
|
|
IRepository<ReportFormatTemplate, string> reportFormatTemplateRepository, |
|
|
IRepository<ReportFormatTemplate, string> reportFormatTemplateRepository, |
|
|
IRepository<ReportPrinter, string> reportPrinterRespository, |
|
|
IRepository<ReportPrinter, string> reportPrinterRespository, |
|
|
IConfiguration configuration, |
|
|
IConfiguration configuration, |
|
|
ReportManager manager) |
|
|
ReportManager manager) |
|
|
: base(repository) |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
_userRepository = userRepository; |
|
|
_userRepository = userRepository; |
|
|
_reportFormatRepository = reportFormatRepository; |
|
|
_reportFormatRepository = reportFormatRepository; |
|
|
@ -56,22 +52,26 @@ namespace Shentun.Peis.Reports |
|
|
_reportPrinterRespository = reportPrinterRespository; |
|
|
_reportPrinterRespository = reportPrinterRespository; |
|
|
_manager = manager; |
|
|
_manager = manager; |
|
|
_configuration = configuration; |
|
|
_configuration = configuration; |
|
|
|
|
|
_repository = repository; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 获取通过主键
|
|
|
/// 获取通过主键
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="id"></param>
|
|
|
|
|
|
|
|
|
/// <param name="inputDto"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <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);
|
|
|
//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(); |
|
|
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>
|
|
|
/// <summary>
|
|
|
@ -79,26 +79,41 @@ namespace Shentun.Peis.Reports |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="input"></param>
|
|
|
/// <param name="input"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
public override async Task<PagedResultDto<ReportDto>> GetListAsync(PagedAndSortedResultRequestDto input) |
|
|
|
|
|
|
|
|
[HttpPost("api/app/Report/GetList")] |
|
|
|
|
|
public async Task<List<ReportDto>> GetListAsync(PagedAndSortedResultRequestDto input) |
|
|
|
|
|
{ |
|
|
|
|
|
var reportList = await _repository.GetListAsync(); |
|
|
|
|
|
|
|
|
|
|
|
List<ReportDto> reports= new List<ReportDto>(); |
|
|
|
|
|
|
|
|
|
|
|
foreach(var report in reportList) |
|
|
{ |
|
|
{ |
|
|
return await base.GetListAsync(input); |
|
|
|
|
|
|
|
|
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() |
|
|
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 |
|
|
var entdto = new ReportDto |
|
|
{ |
|
|
{ |
|
|
Id = !string.IsNullOrEmpty(ent) ? ent : "0001" |
|
|
Id = !string.IsNullOrEmpty(ent) ? ent : "0001" |
|
|
}; |
|
|
}; |
|
|
return entdto; |
|
|
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(); |
|
|
PrintReportDto printReportDto = new PrintReportDto(); |
|
|
var entity = await base.GetEntityByIdAsync(reportId); |
|
|
|
|
|
|
|
|
var entity = await _repository.GetAsync(input.ReportId); |
|
|
if (entity == null) return null; |
|
|
if (entity == null) return null; |
|
|
if (!entity.IsActive.Equals('Y')) |
|
|
if (!entity.IsActive.Equals('Y')) |
|
|
throw new Volo.Abp.UserFriendlyException($"报表:【'{entity.DisplayName}'】未启用,请启用后再操作"); |
|
|
throw new Volo.Abp.UserFriendlyException($"报表:【'{entity.DisplayName}'】未启用,请启用后再操作"); |
|
|
@ -119,11 +134,11 @@ namespace Shentun.Peis.Reports |
|
|
var userList = await _userRepository.GetListAsync(); |
|
|
var userList = await _userRepository.GetListAsync(); |
|
|
var dto = ObjectMapper.Map<ReportFormatTemplate, ReportFormatTemplateDto>(dtotmp); |
|
|
var dto = ObjectMapper.Map<ReportFormatTemplate, ReportFormatTemplateDto>(dtotmp); |
|
|
dto.IsDefaulted = dtotmp.IsDefault.Equals('Y'); |
|
|
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.CreatorName = EntityHelper.GetSurnameNoSql(userList, entity.CreatorId); |
|
|
dto.LastModifierName = EntityHelper.GetSurnameNoSql(userList, entity.LastModifierId); |
|
|
dto.LastModifierName = EntityHelper.GetSurnameNoSql(userList, entity.LastModifierId); |
|
|
printReportDto.reportFormatTemplate = dto; |
|
|
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) |
|
|
if (printerEntity != null) |
|
|
{ |
|
|
{ |
|
|
var printer = ObjectMapper.Map<ReportPrinter, ReportPrinterDto>(printerEntity); |
|
|
var printer = ObjectMapper.Map<ReportPrinter, ReportPrinterDto>(printerEntity); |
|
|
@ -134,10 +149,10 @@ namespace Shentun.Peis.Reports |
|
|
|
|
|
|
|
|
return printReportDto; |
|
|
return printReportDto; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpPost("api/app/Report/Upload")] |
|
|
public async Task Upload(UploadPdfDto 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); |
|
|
await FileHelper.Base64StringConvertPDF(upload.File, PeisReportPdfPath); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -146,17 +161,18 @@ namespace Shentun.Peis.Reports |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="input"></param>
|
|
|
/// <param name="input"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("api/app/Report/GetListInFilterNotOrder")] |
|
|
public async Task<PagedResultDto<ReportDto>> GetListInFilterNotOrderAsync(GetListInFilterPageDto input) |
|
|
public async Task<PagedResultDto<ReportDto>> GetListInFilterNotOrderAsync(GetListInFilterPageDto input) |
|
|
{ |
|
|
{ |
|
|
int totalCount = 0; |
|
|
int totalCount = 0; |
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(input.Filter)) |
|
|
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 |
|
|
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 userList = await _userRepository.GetListAsync(); |
|
|
var entdto = entlist.Select(s => new ReportDto |
|
|
var entdto = entlist.Select(s => new ReportDto |
|
|
{ |
|
|
{ |
|
|
@ -167,7 +183,7 @@ namespace Shentun.Peis.Reports |
|
|
LastModificationTime = s.LastModificationTime, |
|
|
LastModificationTime = s.LastModificationTime, |
|
|
LastModifierId = s.LastModifierId, |
|
|
LastModifierId = s.LastModifierId, |
|
|
IsActive = s.IsActive, |
|
|
IsActive = s.IsActive, |
|
|
IsActived=s.IsActive.Equals('Y'), |
|
|
|
|
|
|
|
|
IsActived = s.IsActive.Equals('Y'), |
|
|
CreatorName = EntityHelper.GetSurnameNoSql(userList, s.CreatorId), |
|
|
CreatorName = EntityHelper.GetSurnameNoSql(userList, s.CreatorId), |
|
|
LastModifierName = EntityHelper.GetSurnameNoSql(userList, s.LastModifierId) |
|
|
LastModifierName = EntityHelper.GetSurnameNoSql(userList, s.LastModifierId) |
|
|
}).ToList(); |
|
|
}).ToList(); |
|
|
@ -182,11 +198,12 @@ namespace Shentun.Peis.Reports |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="input"></param>
|
|
|
/// <param name="input"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <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 createEntity = ObjectMapper.Map<CreateReportDto, Report>(input); |
|
|
var entity = await _manager.CreateAsync(createEntity); |
|
|
var entity = await _manager.CreateAsync(createEntity); |
|
|
entity = await Repository.InsertAsync(entity); |
|
|
|
|
|
|
|
|
entity = await _repository.InsertAsync(entity); |
|
|
var dto = ObjectMapper.Map<Report, ReportDto>(entity); |
|
|
var dto = ObjectMapper.Map<Report, ReportDto>(entity); |
|
|
return dto; |
|
|
return dto; |
|
|
} |
|
|
} |
|
|
@ -194,16 +211,16 @@ namespace Shentun.Peis.Reports |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 更新
|
|
|
/// 更新
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="id"></param>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
/// <param name="input"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <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 userList = await _userRepository.GetListAsync(); |
|
|
var sourceEntity = ObjectMapper.Map<UpdateReportDto, Report>(input); |
|
|
var sourceEntity = ObjectMapper.Map<UpdateReportDto, Report>(input); |
|
|
await _manager.UpdateAsync(sourceEntity, entity); |
|
|
await _manager.UpdateAsync(sourceEntity, entity); |
|
|
entity = await Repository.UpdateAsync(entity); |
|
|
|
|
|
|
|
|
entity = await _repository.UpdateAsync(entity); |
|
|
var dto = ObjectMapper.Map<Report, ReportDto>(entity); |
|
|
var dto = ObjectMapper.Map<Report, ReportDto>(entity); |
|
|
dto.IsActived = entity.IsActive.Equals('Y'); |
|
|
dto.IsActived = entity.IsActive.Equals('Y'); |
|
|
dto.CreatorName = EntityHelper.GetSurnameNoSql(userList, entity.CreatorId); |
|
|
dto.CreatorName = EntityHelper.GetSurnameNoSql(userList, entity.CreatorId); |
|
|
@ -213,11 +230,11 @@ namespace Shentun.Peis.Reports |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 删除
|
|
|
/// 删除
|
|
|
/// </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); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |