update reporting akbar dan fahmi
This commit is contained in:
parent
846eae51bb
commit
7536117c7a
@ -13,6 +13,7 @@ import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
public class DbConfig {
|
||||
|
||||
public DbConfig() {
|
||||
}
|
||||
|
||||
@ -34,7 +35,7 @@ public class DbConfig {
|
||||
config.setAutoCommit(ConnDb1.autoCommit);
|
||||
return new HikariDataSource(config);
|
||||
} catch (Exception var3) {
|
||||
System.out.println(var3.getMessage());
|
||||
System.out.println("Error DataSource 1: " + var3.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -56,7 +57,7 @@ public class DbConfig {
|
||||
config.setAutoCommit(ConnDb1.autoCommit);
|
||||
return new HikariDataSource(config);
|
||||
} catch (Exception var3) {
|
||||
System.out.println(var3.getMessage());
|
||||
System.out.println("Error DataSource 2: " + var3.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -78,32 +79,37 @@ public class DbConfig {
|
||||
config.setAutoCommit(ConnDb1.autoCommit);
|
||||
return new HikariDataSource(config);
|
||||
} catch (Exception var3) {
|
||||
System.out.println(var3.getMessage());
|
||||
System.out.println("Error DataSource 3: " + var3.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// @Bean(name = "fourDataSource")
|
||||
// public DataSource dataSource4() {
|
||||
// try {
|
||||
// HikariConfig config = new HikariConfig();
|
||||
// config.setPoolName("PoolReporting3");
|
||||
// config.setDriverClassName("org.postgresql.Driver");
|
||||
// config.setConnectionTestQuery("SELECT 1");
|
||||
// config.setJdbcUrl("jdbc:postgresql://192.168.12.3:5432/rsab_hk_25_01_14");
|
||||
// config.setUsername("postgres");
|
||||
// config.setPassword("postgres");
|
||||
// config.setMinimumIdle(5);
|
||||
// config.setIdleTimeout(300000L);
|
||||
// config.setMaximumPoolSize(20);
|
||||
// config.setConnectionTimeout(100000L);
|
||||
// config.setAutoCommit(ConnDb1.autoCommit);
|
||||
// return new HikariDataSource(config);
|
||||
// } catch (Exception var3) {
|
||||
// System.out.println(var3.getMessage());
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
@Bean(name = "fourDataSource")
|
||||
public DataSource dataSource4() {
|
||||
try {
|
||||
HikariConfig config = new HikariConfig();
|
||||
config.setPoolName("PoolReporting4"); // Perbaikan typo nama pool agar tidak bentrok dengan Pool 3
|
||||
config.setDriverClassName("org.postgresql.Driver");
|
||||
config.setConnectionTestQuery("SELECT 1");
|
||||
config.setJdbcUrl("jdbc:postgresql://192.168.12.3:5432/rsab_hk_25_01_14");
|
||||
config.setUsername("postgres");
|
||||
config.setPassword("postgres");
|
||||
config.setIdleTimeout(300000L);
|
||||
config.setMaximumPoolSize(20);
|
||||
config.setAutoCommit(ConnDb1.autoCommit);
|
||||
|
||||
/* PENGATURAN AGAR TIDAK MENGGANGGU RESTART/STARTUP APLIKASI SAAT MATI LAMPU:
|
||||
*/
|
||||
config.setMinimumIdle(0); // Jangan paksa alokasi koneksi di awal saat menyala
|
||||
config.setConnectionTimeout(3000L); // Jika database mati saat diakses, timeout cepat dalam 3 detik (tidak hang sampai 100 detik)
|
||||
config.setInitializationFailTimeout(-1L); // JANGAN GAGALKAN STARTUP jika database offline/mati
|
||||
|
||||
return new HikariDataSource(config);
|
||||
} catch (Exception var3) {
|
||||
System.out.println("Error DataSource 4 (Aplikasi tetap berjalan): " + var3.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Bean(name = {"jdbcTemplate"})
|
||||
public JdbcTemplate jdbcTemplate1(@Qualifier("db") DataSource ds) {
|
||||
@ -120,8 +126,8 @@ public class DbConfig {
|
||||
return new JdbcTemplate(ds);
|
||||
}
|
||||
|
||||
// @Bean(name = "fourJdbcTemplate")
|
||||
// public JdbcTemplate jdbcTemplate4(@Qualifier("fourDataSource") DataSource ds) {
|
||||
// return new JdbcTemplate(ds);
|
||||
// }
|
||||
}
|
||||
@Bean(name = "fourJdbcTemplate")
|
||||
public JdbcTemplate jdbcTemplate4(@Qualifier("fourDataSource") DataSource ds) {
|
||||
return new JdbcTemplate(ds);
|
||||
}
|
||||
}
|
||||
@ -2636,4 +2636,142 @@ public class ReportingController {
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/laporan-detail-ppra"}, method = {RequestMethod.GET})
|
||||
public void handleLpDetailPPRA(
|
||||
@RequestParam("tglAwal") Timestamp tglAwal,
|
||||
@RequestParam("tglAkhir") Timestamp tglAkhir,
|
||||
@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.exportLpDetailPPRA(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_Detail_PPRA.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_Detail_PPRA.pdf");
|
||||
|
||||
JRPdfExporter exporter = new JRPdfExporter();
|
||||
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
|
||||
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream()));
|
||||
exporter.exportReport();
|
||||
}
|
||||
} finally {
|
||||
jasperPrint = null;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/laporan-rekap-pasien-baru-pertahun"}, method = {RequestMethod.GET})
|
||||
public void handleLpRekapPasienBaru(
|
||||
@RequestParam("tglAwal") Timestamp tglAwal,
|
||||
@RequestParam("tglAkhir") Timestamp tglAkhir,
|
||||
@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.exportLpRekapPasienBaru(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_Rekap_Pasien_Baru.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_Rekap_Pasien_Baru.pdf");
|
||||
|
||||
JRPdfExporter exporter = new JRPdfExporter();
|
||||
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
|
||||
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream()));
|
||||
exporter.exportReport();
|
||||
}
|
||||
} finally {
|
||||
jasperPrint = null;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/laporan-log-radiologi"}, method = {RequestMethod.GET})
|
||||
public void handleLpLogRadiologi(
|
||||
@RequestParam("tglAwal") Timestamp tglAwal,
|
||||
@RequestParam("tglAkhir") Timestamp tglAkhir,
|
||||
@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.exportLpLogRadiologi(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_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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -46,9 +46,9 @@ public class ReportingDao {
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate3;
|
||||
|
||||
// @Qualifier("fourJdbcTemplate")
|
||||
// @Autowired
|
||||
// private JdbcTemplate jdbcTemplate4;
|
||||
@Qualifier("fourJdbcTemplate")
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate4;
|
||||
|
||||
@Autowired
|
||||
private PostgresArrayService postgresArrayService;
|
||||
@ -1573,7 +1573,7 @@ public class ReportingDao {
|
||||
}
|
||||
|
||||
public JasperPrint exportLpTreaseHasil(String norec) {
|
||||
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
|
||||
try (Connection conn = this.jdbcTemplate4.getDataSource().getConnection()) {
|
||||
String path = jasperDirPath + "trease_hasil.jrxml";
|
||||
JasperReport jasperReport = JasperCompileManager.compileReport(path);
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
@ -1762,4 +1762,52 @@ public class ReportingDao {
|
||||
return null;
|
||||
}
|
||||
|
||||
public JasperPrint exportLpDetailPPRA(Timestamp tglAwal, Timestamp tglAkhir, String printBy) {
|
||||
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
|
||||
String path = jasperDirPath + "laporan_detail_PPRA.jrxml";
|
||||
JasperReport jasperReport = JasperCompileManager.compileReport(path);
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
parameters.put("tglAwal", tglAwal);
|
||||
parameters.put("tglAkhir", tglAkhir);
|
||||
parameters.put("printBy", printBy);
|
||||
return JasperFillManager.fillReport(jasperReport, parameters, conn);
|
||||
} catch (Exception var15) {
|
||||
LOG.error("Exception at exportLpDetailPPRA");
|
||||
LOG.error(ReportingDao.class, var15);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public JasperPrint exportLpRekapPasienBaru(Timestamp tglAwal, Timestamp tglAkhir, String printBy) {
|
||||
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
|
||||
String path = jaspersim2DirPath + "pasien_baru.jrxml";
|
||||
JasperReport jasperReport = JasperCompileManager.compileReport(path);
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
parameters.put("tglAwal", tglAwal);
|
||||
parameters.put("tglAkhir", tglAkhir);
|
||||
parameters.put("printBy", printBy);
|
||||
return JasperFillManager.fillReport(jasperReport, parameters, conn);
|
||||
} catch (Exception var15) {
|
||||
LOG.error("Exception at exportLpRekapPasienBaru");
|
||||
LOG.error(ReportingDao.class, var15);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public JasperPrint exportLpLogRadiologi(Timestamp tglAwal, Timestamp tglAkhir, String printBy) {
|
||||
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
|
||||
String path = jaspersim2DirPath + "log_radiologi.jrxml";
|
||||
JasperReport jasperReport = JasperCompileManager.compileReport(path);
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
parameters.put("tglAwal", tglAwal);
|
||||
parameters.put("tglAkhir", tglAkhir);
|
||||
parameters.put("printBy", printBy);
|
||||
return JasperFillManager.fillReport(jasperReport, parameters, conn);
|
||||
} catch (Exception var15) {
|
||||
LOG.error("Exception at exportLpLogRadiologi");
|
||||
LOG.error(ReportingDao.class, var15);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -669,8 +669,23 @@ public class ReportingService {
|
||||
}
|
||||
|
||||
public JasperPrint exportLpRekapPasienLama(Timestamp tglAwal, Timestamp tglAkhir, String printBy) {
|
||||
log.info("Starting exportKunjunganPasienPerRuangan with tglAwal: {}, tglAkhir: {}, printBy: {}", tglAwal, tglAkhir, printBy);
|
||||
log.info("Starting exportLpRekapPasienLama with tglAwal: {}, tglAkhir: {}, printBy: {}", tglAwal, tglAkhir, printBy);
|
||||
return this.reportingDao.exportLpRekapPasienLama(tglAwal, tglAkhir, printBy);
|
||||
}
|
||||
|
||||
public JasperPrint exportLpDetailPPRA(Timestamp tglAwal, Timestamp tglAkhir, String printBy) {
|
||||
log.info("Starting exportLpDetailPPRA with tglAwal: {}, tglAkhir: {}, printBy: {}", tglAwal, tglAkhir, printBy);
|
||||
return this.reportingDao.exportLpDetailPPRA(tglAwal, tglAkhir, printBy);
|
||||
}
|
||||
|
||||
public JasperPrint exportLpRekapPasienBaru(Timestamp tglAwal, Timestamp tglAkhir, String printBy) {
|
||||
log.info("Starting exportLpRekapPasienBaru with tglAwal: {}, tglAkhir: {}, printBy: {}", tglAwal, tglAkhir, printBy);
|
||||
return this.reportingDao.exportLpRekapPasienBaru(tglAwal, tglAkhir, printBy);
|
||||
}
|
||||
|
||||
public JasperPrint exportLpLogRadiologi(Timestamp tglAwal, Timestamp tglAkhir, String printBy) {
|
||||
log.info("Starting exportLpLogRadiologi with tglAwal: {}, tglAkhir: {}, printBy: {}", tglAwal, tglAkhir, printBy);
|
||||
return this.reportingDao.exportLpLogRadiologi(tglAwal, tglAkhir, printBy);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user