diff --git a/src/main/java/com/reporting/controller/ReportingController.java b/src/main/java/com/reporting/controller/ReportingController.java index 53dc84b..6c10f8d 100644 --- a/src/main/java/com/reporting/controller/ReportingController.java +++ b/src/main/java/com/reporting/controller/ReportingController.java @@ -1706,6 +1706,8 @@ public class ReportingController { @RequestMapping(value = {"/daftar-tarif-ruangan"}, method = {RequestMethod.GET}) public void handleLpTarif( @RequestParam(value = "idInstalasi", required = false, defaultValue = "") Integer idInstalasi, + @RequestParam(value = "idUkp", required = false, defaultValue = "") Integer idUkp, + @RequestParam(value = "idRuangan", required = false, defaultValue = "") Integer idRuangan, @RequestParam(value = "idProduk", required = false, defaultValue = "") Integer idProduk, @RequestParam(value = "idTarif", required = false, defaultValue = "") Integer idTarif, @RequestParam(value = "format", required = false, defaultValue = "pdf") String format, @@ -1716,7 +1718,7 @@ public class ReportingController { JasperPrint jasperPrint = null; try { // Generate report (common for both PDF/Excel) - jasperPrint = this.reportingService.exportLpTarif(idInstalasi, idProduk, idTarif, printBy); + jasperPrint = this.reportingService.exportLpTarif(idInstalasi, idUkp, idRuangan, idProduk, idTarif, printBy); if ("excel".equalsIgnoreCase(format)) { // Handle Excel export @@ -2774,4 +2776,49 @@ public class ReportingController { } } + @RequestMapping(value = {"/surat-pengiriman-jenazah"}, method = {RequestMethod.GET}) + public void handleSuratPengirimanJenazah( + @RequestParam("smpk") Integer smpk, + @RequestParam(value = "format", required = false, defaultValue = "pdf") String format, + @RequestParam(value = "mode", required = false, defaultValue = "download") String mode, + @RequestParam(value = "printBy", required = false, defaultValue = "") String printBy, + HttpServletResponse response) throws Exception { + + JasperPrint jasperPrint = null; + try { + // Generate report (common for both PDF/Excel) + jasperPrint = this.reportingService.exporSuratPengirimanJenazah(smpk, printBy); + + if ("excel".equalsIgnoreCase(format)) { + // Handle Excel export + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=Laporan_Log_Radiologi.xlsx"); + + JRXlsxExporter exporter = new JRXlsxExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + SimpleXlsxReportConfiguration config = new SimpleXlsxReportConfiguration(); + config.setOnePagePerSheet(false); + config.setDetectCellType(true); + config.setCollapseRowSpan(false); + config.setRemoveEmptySpaceBetweenRows(true); + config.setWhitePageBackground(false); + exporter.setConfiguration(config); + exporter.exportReport(); + + } else { + // Handle PDF preview + response.setContentType("application/pdf"); + response.setHeader("Content-Disposition", "inline; filename=Laporan_Log_Radiologi.pdf"); + + JRPdfExporter exporter = new JRPdfExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + exporter.exportReport(); + } + } finally { + jasperPrint = null; + } + } + } diff --git a/src/main/java/com/reporting/dao/ReportingDao.java b/src/main/java/com/reporting/dao/ReportingDao.java index 9001550..3a2a77a 100644 --- a/src/main/java/com/reporting/dao/ReportingDao.java +++ b/src/main/java/com/reporting/dao/ReportingDao.java @@ -1398,12 +1398,14 @@ public class ReportingDao { } return null; } - public JasperPrint exportLpTarif(Integer idInstalasi, Integer idProduk, Integer idTarif, String printBy) { + public JasperPrint exportLpTarif(Integer idInstalasi, Integer idUkp, Integer idRuangan, Integer idProduk, Integer idTarif, String printBy) { try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) { String path = jaspersim2DirPath + "tindakan_mba_ayu_putri.jrxml"; JasperReport jasperReport = JasperCompileManager.compileReport(path); Map parameters = new HashMap<>(); parameters.put("idInstalasi", idInstalasi); + parameters.put("idUkp", idUkp); + parameters.put("idRuangan", idRuangan); parameters.put("idProduk", idProduk); parameters.put("idTarif", idTarif); parameters.put("printBy", printBy); @@ -1810,4 +1812,19 @@ public class ReportingDao { return null; } + public JasperPrint exporSuratPengirimanJenazah(Integer smpk, String printBy) { + try (Connection conn = this.jdbcTemplate4.getDataSource().getConnection()) { + String path = jasperDirPath + "Surat_pengantar_jenazah.jrxml"; + JasperReport jasperReport = JasperCompileManager.compileReport(path); + Map parameters = new HashMap<>(); + parameters.put("smpk", smpk); + parameters.put("printBy", printBy); + return JasperFillManager.fillReport(jasperReport, parameters, conn); + } catch (Exception var15) { + LOG.error("Exception at exporSuratPengirimanJenazah"); + LOG.error(ReportingDao.class, var15); + } + return null; + } + } diff --git a/src/main/java/com/reporting/service/ReportingService.java b/src/main/java/com/reporting/service/ReportingService.java index 5021879..985a43f 100644 --- a/src/main/java/com/reporting/service/ReportingService.java +++ b/src/main/java/com/reporting/service/ReportingService.java @@ -455,9 +455,9 @@ public class ReportingService { return this.reportingDao.exportLpSatuSehat(tglAwal, tglAkhir, idInstalasi, idUnit, idRuangan, idPegawai, printBy); } - public JasperPrint exportLpTarif(Integer idInstalasi, Integer idProduk, Integer idTarif, String printBy) { - log.info("Starting exportLpTarif with idInstalasi: {}, idProduk: {}, idTarif: {}, printBy: {}", idInstalasi, idProduk, idTarif, printBy); - return this.reportingDao.exportLpTarif(idInstalasi, idProduk, idTarif, printBy); + public JasperPrint exportLpTarif(Integer idInstalasi, Integer idUkp, Integer idRuangan, Integer idProduk, Integer idTarif, String printBy) { + log.info("Starting exportLpTarif with idInstalasi: {}, idProduk: {}, idTarif: {}, printBy: {}", idInstalasi, idUkp, idRuangan, idProduk, idTarif, printBy); + return this.reportingDao.exportLpTarif(idInstalasi, idUkp, idRuangan, idProduk, idTarif, printBy); } public JasperPrint exportLpRekapTidakan(String tglAwal, String tglAkhir, Integer idUnit, Integer idDokter, Integer idKp, Integer idProduk, String printBy) { @@ -688,4 +688,9 @@ public class ReportingService { return this.reportingDao.exportLpLogRadiologi(tglAwal, tglAkhir, printBy); } + public JasperPrint exporSuratPengirimanJenazah(Integer smpk, String printBy) { + log.info("Starting exporSuratPengirimanJenazah with smpk: {}, printBy: {}", smpk, printBy); + return this.reportingDao.exporSuratPengirimanJenazah(smpk, printBy); + } + }