diff --git a/src/main/java/com/reporting/controller/ReportingController.java b/src/main/java/com/reporting/controller/ReportingController.java index 39d4fda..3ac0e1e 100644 --- a/src/main/java/com/reporting/controller/ReportingController.java +++ b/src/main/java/com/reporting/controller/ReportingController.java @@ -2156,4 +2156,147 @@ public class ReportingController { } } + @RequestMapping(value = {"/lap-detail-resep-perdokter"}, method = {RequestMethod.GET}) + public void handleLpDetailResepPerDokter( + @RequestParam("tglAwal") String tglAwal, + @RequestParam("tglAkhir") String tglAkhir, + @RequestParam(value = "idInstalasi", required = false, defaultValue = "") Integer idInstalasi, + @RequestParam(value = "idUnit", required = false, defaultValue = "") Integer idUnit, + @RequestParam(value = "idRuangan", required = false, defaultValue = "") Integer idRuangan, + @RequestParam(value = "idDokter", required = false, defaultValue = "") Integer idDokter, + @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.exportLpDetailResepPerDokter(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=Lp_Detail_Resep_PerDokter.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=Lp_Detail_Resep_PerDokter.pdf"); + + JRPdfExporter exporter = new JRPdfExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + exporter.exportReport(); + } + } finally { + jasperPrint = null; + } + } + + @RequestMapping(value = {"/cetak-master-obat"}, method = {RequestMethod.GET}) + public void handleMasterObat( + @RequestParam(value = "format", required = false, defaultValue = "pdf") String format, + @RequestParam(value = "mode", required = false, defaultValue = "download") String mode, + HttpServletResponse response) throws Exception { + + JasperPrint jasperPrint = null; + try { + // Generate report (common for both PDF/Excel) + jasperPrint = this.reportingService.exportMasterObat(); + + if ("excel".equalsIgnoreCase(format)) { + // Handle Excel export + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=Master_Obat.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=Master_Obat.pdf"); + + JRPdfExporter exporter = new JRPdfExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + exporter.exportReport(); + } + } finally { + jasperPrint = null; + } + } + + @RequestMapping(value = {"/waktu-tunggu-farmasi"}, method = {RequestMethod.GET}) + public void handleWaktuTungguFarmasi( + @RequestParam("tglAwal") String tglAwal, + @RequestParam("tglAkhir") String tglAkhir, + @RequestParam(value = "idInstalasi", required = false, defaultValue = "") Integer idInstalasi, + @RequestParam(value = "idUnit", required = false, defaultValue = "") Integer idUnit, + @RequestParam(value = "idRuangan", required = false, defaultValue = "") Integer idRuangan, + @RequestParam(value = "idDokter", required = false, defaultValue = "") Integer idDokter, + @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.exportWaktuTungguFarmasi(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=Waktu_Tunggu_Farmasi.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=Waktu_Tunggu_Farmasi.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 0c87c05..438d257 100644 --- a/src/main/java/com/reporting/dao/ReportingDao.java +++ b/src/main/java/com/reporting/dao/ReportingDao.java @@ -1582,4 +1582,57 @@ public class ReportingDao { return null; } + public JasperPrint exportLpDetailResepPerDokter(Timestamp tglAwal, Timestamp tglAkhir, Integer idInstalasi, Integer idUnit, Integer idRuangan, Integer idDokter, String printBy) { + try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) { + String path = jasperDirPath + "Lap_detail_resep_perdokter.jrxml"; + JasperReport jasperReport = JasperCompileManager.compileReport(path); + Map parameters = new HashMap<>(); + parameters.put("tglAwal", tglAwal); + parameters.put("tglAkhir", tglAkhir); + parameters.put("idInstalasi", idInstalasi); + parameters.put("idUnit", idUnit); + parameters.put("idRuangan", idRuangan); + parameters.put("idDokter", idDokter); + parameters.put("printBy", printBy); + return JasperFillManager.fillReport(jasperReport, parameters, conn); + } catch (Exception var15) { + LOG.error("Exception at exportLpDetailResepPerDokter"); + LOG.error(ReportingDao.class, var15); + } + return null; + } + + public JasperPrint exportMasterObat() { + try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) { + String path = jasperDirPath + "Cetakan_master_obat.jrxml"; + JasperReport jasperReport = JasperCompileManager.compileReport(path); + Map parameters = new HashMap<>(); + return JasperFillManager.fillReport(jasperReport, parameters, conn); + } catch (Exception var15) { + LOG.error("Exception at exportMasterObat"); + LOG.error(ReportingDao.class, var15); + } + return null; + } + + public JasperPrint exportWaktuTungguFarmasi(Timestamp tglAwal, Timestamp tglAkhir, Integer idInstalasi, Integer idUnit, Integer idRuangan, Integer idDokter, String printBy) { + try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) { + String path = jasperDirPath + "waktu_tunggu_farmasi.jrxml"; + JasperReport jasperReport = JasperCompileManager.compileReport(path); + Map parameters = new HashMap<>(); + parameters.put("tglAwal", tglAwal); + parameters.put("tglAkhir", tglAkhir); + parameters.put("idInstalasi", idInstalasi); + parameters.put("idUnit", idUnit); + parameters.put("idRuangan", idRuangan); + parameters.put("idDokter", idDokter); + parameters.put("printBy", printBy); + return JasperFillManager.fillReport(jasperReport, parameters, conn); + } catch (Exception var15) { + LOG.error("Exception at exportWaktuTungguFarmasi"); + 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 2270c63..be1f39d 100644 --- a/src/main/java/com/reporting/service/ReportingService.java +++ b/src/main/java/com/reporting/service/ReportingService.java @@ -553,4 +553,35 @@ public class ReportingService { return this.reportingDao.exportLpTreaseHasil(norec); } + public JasperPrint exportLpDetailResepPerDokter(String tglAwal, String tglAkhir, Integer idInstalasi, Integer idUnit, Integer idRuangan, Integer idDokter, String printBy) { + log.info("Starting exportLpDetailResepPerDokter with tglAwal: {}, tglAkhir: {}, idInstalasi: {}, idUnit: {}, idRuangan: {}, IdDokter: {}, printBy: {}", tglAwal, tglAkhir, idInstalasi, idUnit, idRuangan, idDokter, printBy); + try { + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Timestamp parse = new Timestamp(formatter.parse(tglAwal).getTime()); + Timestamp parse2 = new Timestamp(formatter.parse(tglAkhir).getTime()); + return this.reportingDao.exportLpDetailResepPerDokter(parse, parse2, idInstalasi, idUnit, idRuangan, idDokter, printBy); + } catch (ParseException e) { + log.error(e.getMessage()); + return null; + } + } + + public JasperPrint exportMasterObat() { + log.info("Starting exportMasterObat "); + return this.reportingDao.exportMasterObat(); + } + + public JasperPrint exportWaktuTungguFarmasi(String tglAwal, String tglAkhir, Integer idInstalasi, Integer idUnit, Integer idRuangan, Integer idDokter, String printBy) { + log.info("Starting exportWaktuTungguFarmasi with tglAwal: {}, tglAkhir: {}, idInstalasi: {}, idUnit: {}, idRuangan: {}, IdDokter: {}, printBy: {}", tglAwal, tglAkhir, idInstalasi, idUnit, idRuangan, idDokter, printBy); + try { + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Timestamp parse = new Timestamp(formatter.parse(tglAwal).getTime()); + Timestamp parse2 = new Timestamp(formatter.parse(tglAkhir).getTime()); + return this.reportingDao.exportWaktuTungguFarmasi(parse, parse2, idInstalasi, idUnit, idRuangan, idDokter, printBy); + } catch (ParseException e) { + log.error(e.getMessage()); + return null; + } + } + }