diff --git a/src/main/java/com/reporting/controller/ReportingController.java b/src/main/java/com/reporting/controller/ReportingController.java index eb5ebaa..524737b 100644 --- a/src/main/java/com/reporting/controller/ReportingController.java +++ b/src/main/java/com/reporting/controller/ReportingController.java @@ -18,7 +18,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; import org.springframework.format.annotation.DateTimeFormat; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; @@ -63,9 +62,14 @@ public class ReportingController { public void exportLabelGiziTest(@PathVariable("noregistrasi") String noregistrasi, @RequestParam(value = "jnsdiet", required = false) String jnsdiet, ModelAndView mv, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.exportPdfLabelGizi(noregistrasi, jnsdiet); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.exportPdfLabelGizi(noregistrasi, jnsdiet); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + } finally { + jasperPrint = null; // Membebaskan memori setelah penggunaan + } } @RequestMapping(value = {"/permintaan-makanan"}, method = {RequestMethod.GET}) @@ -73,9 +77,14 @@ public class ReportingController { @RequestParam("tglAwal") String tglAwal, @RequestParam("tglAkhir") String tglAkhir, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.exportPdfPermintaanMakanan(idRu, tglAwal, tglAkhir); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.exportPdfPermintaanMakanan(idRu, tglAwal, tglAkhir); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + } finally { + jasperPrint = null; + } } @RequestMapping(value = {"/rekap-makanan"}, method = {RequestMethod.GET}) @@ -83,17 +92,27 @@ public class ReportingController { @RequestParam("tglAwal") String tglAwal, @RequestParam("tglAkhir") String tglAkhir, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.exportPdfRekapMakanan(idRu, tglAwal, tglAkhir); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.exportPdfRekapMakanan(idRu, tglAwal, tglAkhir); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/kartu-pasien/{nocm}"}, method = {RequestMethod.GET}) public void exportKartuPasien(@PathVariable("nocm") String nocm, ModelAndView mv, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.printReportKartuPasien(nocm); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.printReportKartuPasien(nocm); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/resep-dokter"}, method = {RequestMethod.GET}) @@ -111,25 +130,40 @@ public class ReportingController { @RequestMapping(value = {"/resep-pasien/{strukOrder}"}, method = {RequestMethod.GET}) public void exportResepPasien(@PathVariable("strukOrder") String strukOrder, ModelAndView mv, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.resepService.exportPdfResepPasien(strukOrder); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.resepService.exportPdfResepPasien(strukOrder); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/lap-bedah"}, method = {RequestMethod.GET}) public void exportLapBedahPasien(@RequestParam("noregis") String noregis, ModelAndView mv, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.printReportLapBedah(noregis); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.printReportLapBedah(noregis); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/lap-konsul/{noorder}"}, method = {RequestMethod.GET}) public void exportKonsulPasien(@PathVariable("noorder") String noorder, ModelAndView mv, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.printReportKonsul(noorder); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.printReportKonsul(noorder); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/lap-lab/{noorder}"}, method = {RequestMethod.GET}) @@ -163,28 +197,43 @@ public class ReportingController { @RequestMapping(value = {"/lap-upk/{nores}"}, method = {RequestMethod.GET}) public void exportUpk(@PathVariable("nores") String nores, ModelAndView mv, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.printReportUpk(nores); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.printReportUpk(nores); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/lap-verifikasi-tagihan-supplier/{noverifikasifk}"}, method = {RequestMethod.GET}) public void exportVerifikasiTagihanSupplier( @PathVariable("noverifikasifk") String noverifikasifk, ModelAndView mv, HttpServletResponse response, HttpServletRequest req) throws Exception { - JasperPrint jasperPrint = this.verifikasiTagihanSupplierServices.generateVerifikasiTagihanPdf(noverifikasifk); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.verifikasiTagihanSupplierServices.generateVerifikasiTagihanPdf(noverifikasifk); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/lap-verifikasi-pembayaran-umum/{noverifikasifk}"}, method = {RequestMethod.GET}) public void exportVerifikasiPembayaranUmum( @PathVariable("noverifikasifk") String noverifikasifk, ModelAndView mv, HttpServletResponse response, HttpServletRequest req) throws Exception { - JasperPrint jasperPrint = this.verifikasiTagihanSupplierServices - .generateVerifikasiPembayaranUmumPdf(noverifikasifk); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.verifikasiTagihanSupplierServices + .generateVerifikasiPembayaranUmumPdf(noverifikasifk); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/lap-rekap-harian-by-dept/{deptId}/{tglAwal}/{tglAkhir}"}, method = {RequestMethod.GET}) @@ -192,9 +241,14 @@ public class ReportingController { @PathVariable("tglAwal") String tglAwal, @PathVariable("tglAkhir") String tglAkhir, ModelAndView mv, HttpServletResponse response, HttpServletRequest req) throws Exception { - JasperPrint jasperPrint = this.reportingService.printPdfLapRekapHarianByDept(deptId, tglAwal, tglAkhir); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.printPdfLapRekapHarianByDept(deptId, tglAwal, tglAkhir); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/lap-rekap-harian-by-ruangan/{deptId}/{ruangId}/{tglAwal}/{tglAkhir}"}, @@ -204,18 +258,28 @@ public class ReportingController { @PathVariable("tglAwal") String tglAwal, @PathVariable("tglAkhir") String tglAkhir, ModelAndView mv, HttpServletResponse response, HttpServletRequest req) throws Exception { - JasperPrint jasperPrint = this.reportingService - .printPdfLapRekapHarianByRuanganId(deptId, ruangId, tglAwal, tglAkhir); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService + .printPdfLapRekapHarianByRuanganId(deptId, ruangId, tglAwal, tglAkhir); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/lap-pengkajian-awal-by-nores/{nores}"}, method = {RequestMethod.GET}) public void exportPengkajianAwalbyNoRes(@PathVariable("nores") String nores, ModelAndView mv, HttpServletRequest req, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.printPdfPengkajianAwalByNoRes(nores); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.printPdfPengkajianAwalByNoRes(nores); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/lap-rekap-penjamin"}, method = {RequestMethod.GET}) @@ -224,10 +288,15 @@ public class ReportingController { @RequestParam("idDept") int idDept, @RequestParam("kelompokPasien") int kelompokPasien, ModelAndView mv, HttpServletRequest req, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService - .printPdfRekapPenjamin(tglAwal, tglAkhir, idDept, kelompokPasien); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService + .printPdfRekapPenjamin(tglAwal, tglAkhir, idDept, kelompokPasien); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/lap-rekap-penjamin-by-institusi"}, method = {RequestMethod.GET}) @@ -236,10 +305,15 @@ public class ReportingController { @RequestParam("idDept") int idDept, @RequestParam("kelompokPasien") int kelompokPasien, @RequestParam("institusiPasien") int institusiPasien, ModelAndView mv, HttpServletRequest req, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService - .printPdfRekapPenjaminByInstitusiPasien(tglAwal, tglAkhir, idDept, kelompokPasien, institusiPasien); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService + .printPdfRekapPenjaminByInstitusiPasien(tglAwal, tglAkhir, idDept, kelompokPasien, institusiPasien); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/lap-rekap-penjamin-by-ranap"}, method = {RequestMethod.GET}) @@ -248,10 +322,15 @@ public class ReportingController { @RequestParam("idDept") int idDept, @RequestParam("kelompokPasien") int kelompokPasien, ModelAndView mv, HttpServletRequest req, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService - .printPdfRekapPenjaminByRanap(tglAwal, tglAkhir, idDept, kelompokPasien); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService + .printPdfRekapPenjaminByRanap(tglAwal, tglAkhir, idDept, kelompokPasien); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/lap-permintaan-makanan"}, method = {RequestMethod.GET}) @@ -261,9 +340,14 @@ public class ReportingController { @RequestParam("tglLayanan") String tglLayanan, @RequestParam(value = "jenisDiet", required = false, defaultValue = "") String jenisDiet, ModelAndView mv, HttpServletRequest req, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.printPdfPermintaanMakanan(idRu, tglAwal, tglAkhir, jenisDiet, tglLayanan); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.printPdfPermintaanMakanan(idRu, tglAwal, tglAkhir, jenisDiet, tglLayanan); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/lap-rekap-makanan"}, method = {RequestMethod.GET}) @@ -271,9 +355,14 @@ public class ReportingController { @RequestParam("tglAwal") String tglAwal, @RequestParam("tglAkhir") String tglAkhir, ModelAndView mv, HttpServletRequest req, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.printPdfRekapMakanan(idRu, tglAwal, tglAkhir); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.printPdfRekapMakanan(idRu, tglAwal, tglAkhir); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/gelang-pasien/{noregistrasi}"}, method = {RequestMethod.GET}) @@ -299,25 +388,33 @@ public class ReportingController { response.setContentType("application/pdf"); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); } -/* @RequestMapping(value = {"/summary-list/{nocm}"}, method = {RequestMethod.GET}) public void exportSummaryList(@PathVariable("nocm") String nocm, ModelAndView mv, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.exportPdfSummaryList(nocm); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.exportPdfSummaryList(nocm); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } -*/ @RequestMapping(value = {"/lap-amprahan-tindakan"}, method = {RequestMethod.GET}) public void exportAmprahanTindakan(@RequestParam("idRu") int idRu, @RequestParam("tglAwal") String tglAwal, @RequestParam("tglAkhir") String tglAkhir, ModelAndView mv, HttpServletRequest req, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.printPdfAmprahanTindakan(idRu, tglAwal, tglAkhir); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.printPdfAmprahanTindakan(idRu, tglAwal, tglAkhir); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/kwitansi/{noregistrasi}"}, method = {RequestMethod.GET}) @@ -326,51 +423,81 @@ public class ReportingController { @RequestParam(value = "nama_pt", required = false) String nama_pt, @RequestParam(value = "kasir", required = false) String kasir, ModelAndView mv, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.exportPdfKwitansi(noregistrasi, jeniskwitansi, nama_pt, kasir); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.exportPdfKwitansi(noregistrasi, jeniskwitansi, nama_pt, kasir); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/usulan/{norec}"}, method = {RequestMethod.GET}) public void exportMonitoringUsulan(@PathVariable("norec") String norec, ModelAndView mv, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.exportPdfMonitoringUsulan(norec); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.exportPdfMonitoringUsulan(norec); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/sppb/{norec}"}, method = {RequestMethod.GET}) public void exportSppb(@PathVariable("norec") String norec, @RequestParam(value = "jnsbrg", required = false) String jnsbrg, ModelAndView mv, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.exportPdfSppb(norec, jnsbrg); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.exportPdfSppb(norec, jnsbrg); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/bukti-layanan-farmasi/{norec}"}, method = {RequestMethod.GET}) public void exportPdfBuktiLayanan(@PathVariable("norec") String norec, @RequestParam(value = "user", required = false, defaultValue = "") String user, ModelAndView mv, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.exportPdfBuktiLayanan(norec, user); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.exportPdfBuktiLayanan(norec, user); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/bukti-nonlayanan-farmasi/{norec}"}, method = {RequestMethod.GET}) public void exportPdfBuktiNoLayanFarmasi(@PathVariable("norec") String norec, ModelAndView mv, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.exportPdfBuktiNoLayanFarmasi(norec); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.exportPdfBuktiNoLayanFarmasi(norec); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/label-farmasi/{norec}"}, method = {RequestMethod.GET}) public void exportPdfLabelFarmasi(@PathVariable("norec") String norec, ModelAndView mv, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.exportPdfLabelFarmasi(norec); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.exportPdfLabelFarmasi(norec); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/lap-tindakan"}, method = {RequestMethod.GET}) @@ -383,34 +510,52 @@ public class ReportingController { @RequestParam(value = "statusprodukid", required = false, defaultValue = "") Integer statusprodukid, ModelAndView mv, HttpServletRequest req, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService - .printPdfLaporanTindakan(ruanganid, instalasiid, kelasid, unitid, produkid, statusprodukid); - - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.printPdfLaporanTindakan(ruanganid, instalasiid, kelasid, unitid, produkid, statusprodukid); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/dashboard-kamar"}, method = {RequestMethod.GET}) public void exportPdfDKamar(ModelAndView mv, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.exportPdfDKamar(); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.exportPdfDKamar(); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/label-farmasi-nonlayanan/{norec}"}, method = {RequestMethod.GET}) public void exportPdfLabelFarmasiNo(@PathVariable("norec") String norec, ModelAndView mv, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.exportPdfLabelFarmasiNo(norec); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.exportPdfLabelFarmasiNo(norec); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/usulan-permintaan-barang-dan-jasa/{norec}"}, method = {RequestMethod.GET}) public void exportPdfUsulanPermintaanBdJ(@PathVariable("norec") String norec, ModelAndView mv, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.exportPdfUsulanPermintaanBdJ(norec); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.exportPdfUsulanPermintaanBdJ(norec); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/triase-igd/{norec}"}, method = {RequestMethod.GET}) @@ -488,9 +633,14 @@ public class ReportingController { public void exportPdfKwitansiCollectingPiutang(@PathVariable("noposting") String norec, @RequestParam(value = "PrintBy", required = false, defaultValue = "") String PrintBy, ModelAndView mv, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.exportPdfKwitansiCollectingPiutang(norec, PrintBy); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.exportPdfKwitansiCollectingPiutang(norec, PrintBy); response.setContentType("application/pdf"); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + }finally { + jasperPrint = null; + } } @RequestMapping(value = {"/lap-pasien-pulang"}, method = {RequestMethod.GET}) @@ -665,37 +815,42 @@ public class ReportingController { @RequestParam(value = "mode", required = false, defaultValue = "download") String mode, @RequestParam(value = "printBy", required = false, defaultValue = "") String printBy, ModelAndView mv, HttpServletResponse response) throws Exception { + JasperPrint jasperPrint = null; + try { + // Generate report (common for both PDF/Excel) + jasperPrint = this.reportingService.exportVisit(tglAwal, tglAkhir, idDokter, idRuangan, printBy); - // Generate report (common for both PDF/Excel) - JasperPrint jasperPrint = this.reportingService.exportVisit(tglAwal, tglAkhir, idDokter, idRuangan, printBy); + if ("excel".equalsIgnoreCase(format)) { + // Handle Excel export + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=Laporan_Ketepatan_Waktu_Visit.xlsx"); - if ("excel".equalsIgnoreCase(format)) { - // Handle Excel export - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - response.setHeader("Content-Disposition", "attachment; filename=Laporan_Ketepatan_Waktu_Visit.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(); - 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_Ketepatan_Waktu_Visit.pdf"); - } else { - // Handle PDF preview - response.setContentType("application/pdf"); - response.setHeader("Content-Disposition", "inline; filename=Laporan_Ketepatan_Waktu_Visit.pdf"); - - JRPdfExporter exporter = new JRPdfExporter(); - exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); - exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); - exporter.exportReport(); + JRPdfExporter exporter = new JRPdfExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + exporter.exportReport(); + } + } finally { + jasperPrint = null; } + } @RequestMapping(value = {"/waktu-rawat-jalan"}, method = {RequestMethod.GET}) @@ -708,36 +863,41 @@ public class ReportingController { @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 jasperPrint = this.reportingService.exportWaktuRawatJalan(tglAwal, tglAkhir, idDokter, idRuangan, printBy); + // Generate report (common for both PDF/Excel) + jasperPrint = this.reportingService.exportWaktuRawatJalan(tglAwal, tglAkhir, idDokter, idRuangan, printBy); - if ("excel".equalsIgnoreCase(format)) { - // Handle Excel export - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - response.setHeader("Content-Disposition", "attachment; filename=Laporan_Ketepatan_Waktu_Rawat_Jalan.xlsx"); + if ("excel".equalsIgnoreCase(format)) { + // Handle Excel export + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=Laporan_Ketepatan_Waktu_Rawat_Jalan.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(); + 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_Ketepatan_Waktu_Rawat_Jalan.pdf"); + } else { + // Handle PDF preview + response.setContentType("application/pdf"); + response.setHeader("Content-Disposition", "inline; filename=Laporan_Ketepatan_Waktu_Rawat_Jalan.pdf"); - JRPdfExporter exporter = new JRPdfExporter(); - exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); - exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); - exporter.exportReport(); + JRPdfExporter exporter = new JRPdfExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + exporter.exportReport(); + } + } finally { + jasperPrint = null; } } @@ -752,35 +912,41 @@ public class ReportingController { @RequestParam(value = "printBy", required = false, defaultValue = "") String printBy, HttpServletResponse response) throws Exception { - // Generate report (common for both PDF/Excel) - JasperPrint jasperPrint = this.reportingService.exportWaktuRawatJalanTRB(tglAwal, tglAkhir, idDokter, idRuangan, printBy); + JasperPrint jasperPrint = null; + try { - if ("excel".equalsIgnoreCase(format)) { - // Handle Excel export - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - response.setHeader("Content-Disposition", "attachment; filename=Laporan_Ketepatan_Waktu_Rawat_Jalan_TRB.xlsx"); + // Generate report (common for both PDF/Excel) + jasperPrint = this.reportingService.exportWaktuRawatJalanTRB(tglAwal, tglAkhir, idDokter, idRuangan, printBy); - 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(); + if ("excel".equalsIgnoreCase(format)) { + // Handle Excel export + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=Laporan_Ketepatan_Waktu_Rawat_Jalan_TRB.xlsx"); - } else { - // Handle PDF preview - response.setContentType("application/pdf"); - response.setHeader("Content-Disposition", "inline; filename=Laporan_Ketepatan_Waktu_Rawat_Jalan_TRB.pdf"); + 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(); - JRPdfExporter exporter = new JRPdfExporter(); - exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); - exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); - exporter.exportReport(); + } else { + // Handle PDF preview + response.setContentType("application/pdf"); + response.setHeader("Content-Disposition", "inline; filename=Laporan_Ketepatan_Waktu_Rawat_Jalan_TRB.pdf"); + + JRPdfExporter exporter = new JRPdfExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + exporter.exportReport(); + } + } finally { + jasperPrint = null; } } @@ -797,35 +963,40 @@ public class ReportingController { @RequestParam(value = "printBy", required = false, defaultValue = "") String printBy, HttpServletResponse response) throws Exception { - // Generate report (common for both PDF/Excel) - JasperPrint jasperPrint = this.reportingService.exportKunjunganPasien(tglAwal, tglAkhir, idInstalasi, idUnit, idRuangan, printBy); + JasperPrint jasperPrint = null; + try { + // Generate report (common for both PDF/Excel) + jasperPrint = this.reportingService.exportKunjunganPasien(tglAwal, tglAkhir, idInstalasi, idUnit, idRuangan, printBy); - if ("excel".equalsIgnoreCase(format)) { - // Handle Excel export - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - response.setHeader("Content-Disposition", "attachment; filename=Laporan_Kunjungan_Pasien.xlsx"); + if ("excel".equalsIgnoreCase(format)) { + // Handle Excel export + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=Laporan_Kunjungan_Pasien.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(); + 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_Kunjungan_Pasien.pdf"); + } else { + // Handle PDF preview + response.setContentType("application/pdf"); + response.setHeader("Content-Disposition", "inline; filename=Laporan_Kunjungan_Pasien.pdf"); - JRPdfExporter exporter = new JRPdfExporter(); - exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); - exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); - exporter.exportReport(); + JRPdfExporter exporter = new JRPdfExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + exporter.exportReport(); + } + } finally { + jasperPrint = null; } } @@ -840,35 +1011,40 @@ public class ReportingController { @RequestParam(value = "printBy", required = false, defaultValue = "") String printBy, HttpServletResponse response) throws Exception { - // Generate report (common for both PDF/Excel) - JasperPrint jasperPrint = this.reportingService.exportLpPendaftaranOnline(tglAwal, tglAkhir, idUnit, idRuangan, printBy); + JasperPrint jasperPrint = null; + try { + // Generate report (common for both PDF/Excel) + jasperPrint = this.reportingService.exportLpPendaftaranOnline(tglAwal, tglAkhir, idUnit, idRuangan, printBy); - if ("excel".equalsIgnoreCase(format)) { - // Handle Excel export - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - response.setHeader("Content-Disposition", "attachment; filename=Laporan_Pendaftaran_Online.xlsx"); + if ("excel".equalsIgnoreCase(format)) { + // Handle Excel export + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=Laporan_Pendaftaran_Online.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(); + 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_Pendaftaran_Online.pdf"); + } else { + // Handle PDF preview + response.setContentType("application/pdf"); + response.setHeader("Content-Disposition", "inline; filename=Laporan_Pendaftaran_Online.pdf"); - JRPdfExporter exporter = new JRPdfExporter(); - exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); - exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); - exporter.exportReport(); + JRPdfExporter exporter = new JRPdfExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + exporter.exportReport(); + } + } finally { + jasperPrint = null; } } @@ -887,35 +1063,40 @@ public class ReportingController { @RequestParam(value = "printBy", required = false, defaultValue = "") String printBy, HttpServletResponse response) throws Exception { - // Generate report (common for both PDF/Excel) - JasperPrint jasperPrint = this.reportingService.exportLpVolumeTindakan(tglAwal, tglAkhir, idInstalasi, idUnit, idRuangan, idProduk, idDokter, idKp, printBy); + JasperPrint jasperPrint = null; + try { + // Generate report (common for both PDF/Excel) + jasperPrint = this.reportingService.exportLpVolumeTindakan(tglAwal, tglAkhir, idInstalasi, idUnit, idRuangan, idProduk, idDokter, idKp, printBy); - if ("excel".equalsIgnoreCase(format)) { - // Handle Excel export - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - response.setHeader("Content-Disposition", "attachment; filename=Laporan_Volume_Tindakan.xlsx"); + if ("excel".equalsIgnoreCase(format)) { + // Handle Excel export + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=Laporan_Volume_Tindakan.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(); + 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_Volume_Tindakan.pdf"); + } else { + // Handle PDF preview + response.setContentType("application/pdf"); + response.setHeader("Content-Disposition", "inline; filename=Laporan_Volume_Tindakan.pdf"); - JRPdfExporter exporter = new JRPdfExporter(); - exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); - exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); - exporter.exportReport(); + JRPdfExporter exporter = new JRPdfExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + exporter.exportReport(); + } + } finally { + jasperPrint = null; } } @@ -932,35 +1113,40 @@ public class ReportingController { @RequestParam(value = "printBy", required = false, defaultValue = "") String printBy, HttpServletResponse response) throws Exception { - // Generate report (common for both PDF/Excel) - JasperPrint jasperPrint = this.reportingService.exportLpResumeMedis(tglAwal, tglAkhir, idInstalasi, idUnit, idRuangan, idDokter, printBy); + JasperPrint jasperPrint = null; + try { + // Generate report (common for both PDF/Excel) + jasperPrint = this.reportingService.exportLpResumeMedis(tglAwal, tglAkhir, idInstalasi, idUnit, idRuangan, idDokter, printBy); - if ("excel".equalsIgnoreCase(format)) { - // Handle Excel export - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - response.setHeader("Content-Disposition", "attachment; filename=Laporan_Resume_Medis.xlsx"); + if ("excel".equalsIgnoreCase(format)) { + // Handle Excel export + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=Laporan_Resume_Medis.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(); + 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_Resume_Medis.pdf"); + } else { + // Handle PDF preview + response.setContentType("application/pdf"); + response.setHeader("Content-Disposition", "inline; filename=Laporan_Resume_Medis.pdf"); - JRPdfExporter exporter = new JRPdfExporter(); - exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); - exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); - exporter.exportReport(); + JRPdfExporter exporter = new JRPdfExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + exporter.exportReport(); + } + } finally { + jasperPrint = null; } } @@ -977,35 +1163,40 @@ public class ReportingController { @RequestParam(value = "printBy", required = false, defaultValue = "") String printBy, HttpServletResponse response) throws Exception { - // Generate report (common for both PDF/Excel) - JasperPrint jasperPrint = this.reportingService.exportLpSatuSehat(tglAwal, tglAkhir, idInstalasi, idUnit, idRuangan, idDokter, printBy); + JasperPrint jasperPrint = null; + try { + // Generate report (common for both PDF/Excel) + jasperPrint = this.reportingService.exportLpSatuSehat(tglAwal, tglAkhir, idInstalasi, idUnit, idRuangan, idDokter, printBy); - if ("excel".equalsIgnoreCase(format)) { - // Handle Excel export - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - response.setHeader("Content-Disposition", "attachment; filename=Laporan_Pasien_SatuSehat.xlsx"); + if ("excel".equalsIgnoreCase(format)) { + // Handle Excel export + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=Laporan_Pasien_SatuSehat.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(); + 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_Pasien_SatuSehat.pdf"); + } else { + // Handle PDF preview + response.setContentType("application/pdf"); + response.setHeader("Content-Disposition", "inline; filename=Laporan_Pasien_SatuSehat.pdf"); - JRPdfExporter exporter = new JRPdfExporter(); - exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); - exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); - exporter.exportReport(); + JRPdfExporter exporter = new JRPdfExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + exporter.exportReport(); + } + } finally { + jasperPrint = null; } } @@ -1019,35 +1210,40 @@ public class ReportingController { @RequestParam(value = "printBy", required = false, defaultValue = "") String printBy, HttpServletResponse response) throws Exception { - // Generate report (common for both PDF/Excel) - JasperPrint jasperPrint = this.reportingService.exportLpTarif(idInstalasi, idProduk, idTarif, printBy); + JasperPrint jasperPrint = null; + try { + // Generate report (common for both PDF/Excel) + jasperPrint = this.reportingService.exportLpTarif(idInstalasi, idProduk, idTarif, printBy); - if ("excel".equalsIgnoreCase(format)) { - // Handle Excel export - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - response.setHeader("Content-Disposition", "attachment; filename=Daftar_Tarif_Ruangan.xlsx"); + if ("excel".equalsIgnoreCase(format)) { + // Handle Excel export + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=Daftar_Tarif_Ruangan.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(); + 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=Daftar_Tarif_Ruangan.pdf"); + } else { + // Handle PDF preview + response.setContentType("application/pdf"); + response.setHeader("Content-Disposition", "inline; filename=Daftar_Tarif_Ruangan.pdf"); - JRPdfExporter exporter = new JRPdfExporter(); - exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); - exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); - exporter.exportReport(); + JRPdfExporter exporter = new JRPdfExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + exporter.exportReport(); + } + } finally { + jasperPrint = null; } } @@ -1064,35 +1260,40 @@ public class ReportingController { @RequestParam(value = "printBy", required = false, defaultValue = "") String printBy, HttpServletResponse response) throws Exception { - // Generate report (common for both PDF/Excel) - JasperPrint jasperPrint = this.reportingService.exportLpRekapTidakan(tglAwal, tglAkhir, idUnit, idDokter, idKp, idProduk, printBy); + JasperPrint jasperPrint = null; + try { + // Generate report (common for both PDF/Excel) + jasperPrint = this.reportingService.exportLpRekapTidakan(tglAwal, tglAkhir, idUnit, idDokter, idKp, idProduk, printBy); - if ("excel".equalsIgnoreCase(format)) { - // Handle Excel export - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - response.setHeader("Content-Disposition", "attachment; filename=Laporan_Rekap_Tindakan.xlsx"); + if ("excel".equalsIgnoreCase(format)) { + // Handle Excel export + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=Laporan_Rekap_Tindakan.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(); + 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_Rekap_Tindakan.pdf"); + } else { + // Handle PDF preview + response.setContentType("application/pdf"); + response.setHeader("Content-Disposition", "inline; filename=Laporan_Rekap_Tindakan.pdf"); - JRPdfExporter exporter = new JRPdfExporter(); - exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); - exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); - exporter.exportReport(); + JRPdfExporter exporter = new JRPdfExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + exporter.exportReport(); + } + } finally { + jasperPrint = null; } } @@ -1100,9 +1301,14 @@ public class ReportingController { public void exportPdfSMPK(@PathVariable("smpk") Integer smpk, @RequestParam(value = "printBy", required = false, defaultValue = "") String printBy, ModelAndView mv, HttpServletResponse response) throws Exception { - JasperPrint jasperPrint = this.reportingService.exportPdfSMPK(smpk,printBy); - response.setContentType("application/pdf"); - JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + JasperPrint jasperPrint = null; + try { + jasperPrint = this.reportingService.exportPdfSMPK(smpk, printBy); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + } finally { + jasperPrint = null; + } } @RequestMapping(value = {"/rekap-logbook"}, method = {RequestMethod.GET}) @@ -1116,35 +1322,40 @@ public class ReportingController { @RequestParam(value = "printBy", required = false, defaultValue = "") String printBy, HttpServletResponse response) throws Exception { - // Generate report (common for both PDF/Excel) - JasperPrint jasperPrint = this.reportingService.exportPdfRekapLogbook(tahun, bulan, ksm_id, pegawai_id, printBy); + JasperPrint jasperPrint = null; + try { + // Generate report (common for both PDF/Excel) + jasperPrint = this.reportingService.exportPdfRekapLogbook(tahun, bulan, ksm_id, pegawai_id, printBy); - if ("excel".equalsIgnoreCase(format)) { - // Handle Excel export - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - response.setHeader("Content-Disposition", "attachment; filename=Rekap_Logbook.xlsx"); + if ("excel".equalsIgnoreCase(format)) { + // Handle Excel export + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=Rekap_Logbook.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(); + 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=Rekap_Logbook.pdf"); + } else { + // Handle PDF preview + response.setContentType("application/pdf"); + response.setHeader("Content-Disposition", "inline; filename=Rekap_Logbook.pdf"); - JRPdfExporter exporter = new JRPdfExporter(); - exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); - exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); - exporter.exportReport(); + JRPdfExporter exporter = new JRPdfExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + exporter.exportReport(); + } + } finally { + jasperPrint = null; } } @@ -1157,35 +1368,41 @@ public class ReportingController { @RequestParam(value = "printBy", required = false, defaultValue = "") String printBy, HttpServletResponse response) throws Exception { - // Generate report (common for both PDF/Excel) - JasperPrint jasperPrint = this.reportingService.exportDOrderRadiologi(tglAwal, tglAkhir, printBy); + JasperPrint jasperPrint = null; + try { + // Generate report (common for both PDF/Excel) + jasperPrint = this.reportingService.exportDOrderRadiologi(tglAwal, tglAkhir, printBy); - if ("excel".equalsIgnoreCase(format)) { - // Handle Excel export - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - response.setHeader("Content-Disposition", "attachment; filename=Laporan_Daftar_Order_Radiologi.xlsx"); + if ("excel".equalsIgnoreCase(format)) { + // Handle Excel export + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=Laporan_Daftar_Order_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(); + 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_Daftar_Order_Radiologi.pdf"); + } else { + // Handle PDF preview + response.setContentType("application/pdf"); + response.setHeader("Content-Disposition", "inline; filename=Laporan_Daftar_Order_Radiologi.pdf"); - JRPdfExporter exporter = new JRPdfExporter(); - exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); - exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); - exporter.exportReport(); + JRPdfExporter exporter = new JRPdfExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + exporter.exportReport(); + } + + } finally { + jasperPrint = null; } } @@ -1202,35 +1419,40 @@ public class ReportingController { @RequestParam(value = "printBy", required = false, defaultValue = "") String printBy, HttpServletResponse response) throws Exception { - // Generate report (common for both PDF/Excel) - JasperPrint jasperPrint = this.reportingService.exportLpPendapatanPoli(tglAwal, tglAkhir, IdDepartemen, IdRuangan, IdKelompokPasien, IdDokter, printBy); + JasperPrint jasperPrint = null; + try { + // Generate report (common for both PDF/Excel) + jasperPrint = this.reportingService.exportLpPendapatanPoli(tglAwal, tglAkhir, IdDepartemen, IdRuangan, IdKelompokPasien, IdDokter, printBy); - if ("excel".equalsIgnoreCase(format)) { - // Handle Excel export - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - response.setHeader("Content-Disposition", "attachment; filename=Laporan_Pendapatan_Poli.xlsx"); + if ("excel".equalsIgnoreCase(format)) { + // Handle Excel export + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=Laporan_Pendapatan_Poli.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(); + 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_Pendapatan_Poli.pdf"); + } else { + // Handle PDF preview + response.setContentType("application/pdf"); + response.setHeader("Content-Disposition", "inline; filename=Laporan_Pendapatan_Poli.pdf"); - JRPdfExporter exporter = new JRPdfExporter(); - exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); - exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); - exporter.exportReport(); + 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 783fbb7..16da17c 100644 --- a/src/main/java/com/reporting/dao/ReportingDao.java +++ b/src/main/java/com/reporting/dao/ReportingDao.java @@ -422,7 +422,6 @@ public class ReportingDao { } return null; } -/* public JasperPrint exportPdfSummaryList(String nocm) { try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) { @@ -437,7 +436,6 @@ public class ReportingDao { } return null; } -*/ public JasperPrint exportPdfAmprahanTindakan(int idRu, Date tglAwal, Date tglAkhir) { try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) { diff --git a/src/main/java/com/reporting/service/ReportingService.java b/src/main/java/com/reporting/service/ReportingService.java index d1dbd23..74fcda3 100644 --- a/src/main/java/com/reporting/service/ReportingService.java +++ b/src/main/java/com/reporting/service/ReportingService.java @@ -145,13 +145,11 @@ public class ReportingService { log.info("Starting exportPdfResumeMedis with norec: {}", norec); return this.reportingDao.exportPdfResumeMedis(norec); } -/* public JasperPrint exportPdfSummaryList(String nocm) { log.info("Starting exportPdfSummaryList with nocm: {}", nocm); return this.reportingDao.exportPdfSummaryList(nocm); } -*/ public JasperPrint printPdfAmprahanTindakan(int idRu, String tglAwal, String tglAkhir) { log.info("Starting printPdfAmprahanTindakan with idRu: {}, tglAwal: {}, tglAkhir: {}", idRu, tglAwal, tglAkhir);