update wtrj

This commit is contained in:
ridwan 2025-09-29 14:39:06 +07:00
parent 49514b08a7
commit b4316dbdb0
5 changed files with 65 additions and 1 deletions

View File

@ -83,6 +83,28 @@ public class DbConfig {
return null; 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 = {"jdbcTemplate"}) @Bean(name = {"jdbcTemplate"})
public JdbcTemplate jdbcTemplate1(@Qualifier("db") DataSource ds) { public JdbcTemplate jdbcTemplate1(@Qualifier("db") DataSource ds) {
return new JdbcTemplate(ds); return new JdbcTemplate(ds);
@ -97,4 +119,9 @@ public class DbConfig {
public JdbcTemplate jdbcTemplate3(@Qualifier("thirdDataSource") DataSource ds) { public JdbcTemplate jdbcTemplate3(@Qualifier("thirdDataSource") DataSource ds) {
return new JdbcTemplate(ds); return new JdbcTemplate(ds);
} }
@Bean(name = "fourJdbcTemplate")
public JdbcTemplate jdbcTemplate4(@Qualifier("fourDataSource") DataSource ds) {
return new JdbcTemplate(ds);
}
} }

View File

@ -1020,4 +1020,12 @@ public class ReportingController {
} }
} }
@RequestMapping(value = {"/smpk/{smpk}"}, method = {RequestMethod.GET})
public void exportPdfSMPK(@PathVariable("smpk") Integer smpk,
ModelAndView mv, HttpServletResponse response) throws Exception {
JasperPrint jasperPrint = this.reportingService.exportPdfSMPK(smpk);
response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
}
} }

View File

@ -45,6 +45,10 @@ public class ReportingDao {
@Autowired @Autowired
private JdbcTemplate jdbcTemplate3; private JdbcTemplate jdbcTemplate3;
@Qualifier("fourJdbcTemplate")
@Autowired
private JdbcTemplate jdbcTemplate4;
@Autowired @Autowired
private PostgresArrayService postgresArrayService; private PostgresArrayService postgresArrayService;
@ -1122,7 +1126,7 @@ public class ReportingDao {
} }
public JasperPrint exportWaktuRawatJalan(Date tglAwal, Date tglAkhir, Integer idDokter, Integer idRuangan, String printBy) { public JasperPrint exportWaktuRawatJalan(Date tglAwal, Date tglAkhir, Integer idDokter, Integer idRuangan, String printBy) {
try (Connection conn = this.jdbcTemplate3.getDataSource().getConnection()) { try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
String path = jaspersim2DirPath + "waktu_rawat_jalan.jrxml"; String path = jaspersim2DirPath + "waktu_rawat_jalan.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap<>(); Map<String, Object> parameters = new HashMap<>();
@ -1276,4 +1280,18 @@ public class ReportingDao {
return null; return null;
} }
public JasperPrint exportPdfSMPK(Integer smpk) {
try (Connection conn = this.jdbcTemplate4.getDataSource().getConnection()) {
String path = jasperDirPath + "SMPK_testing.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap<>();
parameters.put("smpk", smpk);
return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var15) {
LOG.error("Exception at exportPdfSMPK");
LOG.error(ReportingDao.class, var15);
}
return null;
}
} }

View File

@ -432,4 +432,8 @@ public class ReportingService {
} }
} }
public JasperPrint exportPdfSMPK(Integer smpk) {
return this.reportingDao.exportPdfSMPK(smpk);
}
} }

View File

@ -20,6 +20,13 @@ spring.datasource.third.url=jdbc:postgresql://172.16.88.22:5432/gen2-development
spring.datasource.third.username=simrs spring.datasource.third.username=simrs
spring.datasource.third.password=@S1mrs.3205@ spring.datasource.third.password=@S1mrs.3205@
# Konfigurasi untuk sumber data pertama
spring.datasource.four.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.four.driver-class-name=org.postgresql.Driver
spring.datasource.four.url=jdbc:postgresql://192.168.12.3:5432/rsab_hk_25_01_14
spring.datasource.four.username=postgres
spring.datasource.four.password=postgres
# Pengaturan lainnya # Pengaturan lainnya
spring.mvc.dispatch-trace-request=true spring.mvc.dispatch-trace-request=true
spring.main.banner-mode=off spring.main.banner-mode=off