From 2b062bff69df96da71e1c0d48236c8787e6d12ef Mon Sep 17 00:00:00 2001 From: Salman Manoe Date: Thu, 15 Aug 2024 09:42:40 +0700 Subject: [PATCH] Update service reporting Pembuatan endpoint API untuk cetakan kwitansi di SMART --- .../controller/ReportingController.java | 16 ++++++++++++---- .../java/com/reporting/dao/ReportingDao.java | 14 ++++++++++++++ .../com/reporting/service/ReportingService.java | 4 ++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/reporting/controller/ReportingController.java b/src/main/java/com/reporting/controller/ReportingController.java index 60f811e..1accc18 100644 --- a/src/main/java/com/reporting/controller/ReportingController.java +++ b/src/main/java/com/reporting/controller/ReportingController.java @@ -283,7 +283,7 @@ public class ReportingController { @RequestMapping(value = {"/summary-list/{nocm}"}, method = {RequestMethod.GET}) public void exportSummaryList(@PathVariable("nocm") String nocm, - ModelAndView mv, HttpServletResponse response) throws Exception { + ModelAndView mv, HttpServletResponse response) throws Exception { JasperPrint jasperPrint = this.reportingService.exportPdfSummaryList(nocm); response.setContentType("application/pdf"); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); @@ -291,11 +291,19 @@ public class ReportingController { @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 { + @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()); } + + @RequestMapping(value = {"/kwitansi/{noSbm}"}, method = {RequestMethod.GET}) + public void exportKwitansi(@PathVariable("noSbm") String noSbm, + ModelAndView mv, HttpServletResponse response) throws Exception { + JasperPrint jasperPrint = this.reportingService.exportPdfKwitansi(noSbm); + response.setContentType("application/pdf"); + JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); + } } diff --git a/src/main/java/com/reporting/dao/ReportingDao.java b/src/main/java/com/reporting/dao/ReportingDao.java index 46b8737..eed1e81 100644 --- a/src/main/java/com/reporting/dao/ReportingDao.java +++ b/src/main/java/com/reporting/dao/ReportingDao.java @@ -393,4 +393,18 @@ public class ReportingDao { } return null; } + + public JasperPrint exportPdfKwitansi(String noSbm) { + try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) { + String path = jasperDirPath + "kwitansi.jrxml"; + JasperReport jasperReport = JasperCompileManager.compileReport(path); + Map parameters = new HashMap<>(); + parameters.put("nosbm", noSbm); + return JasperFillManager.fillReport(jasperReport, parameters, conn); + } catch (Exception var17) { + LOG.error("Exception at exportPdfKwitansi"); + LOG.error(ReportingDao.class, var17); + } + return null; + } } diff --git a/src/main/java/com/reporting/service/ReportingService.java b/src/main/java/com/reporting/service/ReportingService.java index e65f322..67a065c 100644 --- a/src/main/java/com/reporting/service/ReportingService.java +++ b/src/main/java/com/reporting/service/ReportingService.java @@ -119,4 +119,8 @@ public class ReportingService { return null; } } + + public JasperPrint exportPdfKwitansi(String noSbm) { + return this.reportingDao.exportPdfKwitansi(noSbm); + } }