Olá, pessoal.
Então quando eu tento gerar o pdf via endpoint gera um o relatorio em branco alguem poderia me ajudar ?
// Classe Repository
@Repository
@EnableJpaRepositories
public interface ConsultaNfseRepository extends JpaRepository<ConsultaNfse, Integer> {
@Query("select u from ConsultaNfse u where u.codigoVerificacao = ?1")
List<ConsultaNfse> findByCodigoVerificacao(String codigoVerificacao);
}
//Service
public String exportPdfRelatorioConsultaNfseCuritiba(String reportFormat, String codigoVerificacao)
throws FileNotFoundException, JRException {
List<ConsultaNfse> employees = consultanfserepository.findByCodigoVerificacao(codigoVerificacao);
//load file and compile it
File file = ResourceUtils.getFile("classpath:relatorioprefeituranfsecuritiba.jrxml");
JasperReport jasperReport = JasperCompileManager.compileReport(file.getAbsolutePath());
JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(employees);
Map<String, Object> parameters = new HashMap<>();
parameters.put("createdBy", "Java Techie");
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource);
if (reportFormat.equalsIgnoreCase("html")) {
JasperExportManager.exportReportToHtmlFile(jasperPrint, "C:\\stream" + "\\employees.html");
}
if (reportFormat.equalsIgnoreCase("pdf")) {
JasperExportManager.exportReportToPdfFile(jasperPrint, "C:\\stream" + "\\employees.pdf");
}
return "report generated in path : ";
}
Classe Resources
@RequestMapping(value="/exportPdf/{reportFormat}/{codigoVerificacao}", method=RequestMethod.GET)
public String generateReport(@PathVariable String reportFormat,String codigoVerificacao) throws FileNotFoundException, JRException {
return consultanfseservice.exportPdfRelatorioConsultaNfseCuritiba(reportFormat,codigoVerificacao);
}