Clean code

This commit is contained in:
Salman Manoe 2023-07-13 09:46:59 +07:00
parent ed22248b75
commit 439eb26c34
19 changed files with 571 additions and 1365 deletions

24
pom.xml
View File

@ -6,7 +6,6 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version> <version>1.5.9.RELEASE</version>
<!-- <version>2.0.3.RELEASE</version> -->
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
<groupId>com.rsabhk</groupId> <groupId>com.rsabhk</groupId>
@ -19,7 +18,6 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- <mainClass>com.rsabhk.ReportingServiceApplication</mainClass> -->
<java.version>1.8</java.version> <java.version>1.8</java.version>
</properties> </properties>
@ -37,27 +35,16 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId> <artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<!-- dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency> -->
<dependency> <dependency>
<groupId>org.postgresql</groupId> <groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId> <artifactId>postgresql</artifactId>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency> -->
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId> <artifactId>jstl</artifactId>
@ -72,11 +59,6 @@
<artifactId>tomcat-embed-jasper</artifactId> <artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- <dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.46</version>
</dependency> -->
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId> <artifactId>groovy-all</artifactId>
@ -134,26 +116,21 @@
<artifactId>spring-boot-configuration-processor</artifactId> <artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/net.sourceforge.barbecue/barbecue -->
<dependency> <dependency>
<groupId>net.sourceforge.barbecue</groupId> <groupId>net.sourceforge.barbecue</groupId>
<artifactId>barbecue</artifactId> <artifactId>barbecue</artifactId>
<version>1.5-beta1</version> <version>1.5-beta1</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.google.zxing/core -->
<dependency> <dependency>
<groupId>com.google.zxing</groupId> <groupId>com.google.zxing</groupId>
<artifactId>core</artifactId> <artifactId>core</artifactId>
<version>2.2</version> <version>2.2</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.google.zxing/javase -->
<dependency> <dependency>
<groupId>com.google.zxing</groupId> <groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId> <artifactId>javase</artifactId>
<version>2.2</version> <version>2.2</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
@ -164,5 +141,4 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@ -6,9 +6,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication
public class ReportingApp { public class ReportingApp {
public ReportingApp() {
}
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(ReportingApp.class, args); SpringApplication.run(ReportingApp.class, args);
} }

View File

@ -1,9 +1,9 @@
package com.reporting.Utility; package com.reporting.Utility;
public class Age { public class Age {
private int days; private final int days;
private int months; private final int months;
private int years; private final int years;
public Age(int days, int months, int years) { public Age(int days, int months, int years) {
this.days = days; this.days = days;

View File

@ -3,7 +3,6 @@ package com.reporting.Utility;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.Period; import java.time.Period;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
public final class AgeCalculator { public final class AgeCalculator {
@ -11,56 +10,10 @@ public final class AgeCalculator {
} }
public static Age calculateAge(Date birthDate) { public static Age calculateAge(Date birthDate) {
Age age = null;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
LocalDate today = LocalDate.now(); LocalDate today = LocalDate.now();
LocalDate birthday = LocalDate.parse(format.format(birthDate)); LocalDate birthday = LocalDate.parse(format.format(birthDate));
Period period = Period.between(birthday, today); Period period = Period.between(birthday, today);
age = new Age(period.getDays(), period.getMonths(), period.getYears()); return new Age(period.getDays(), period.getMonths(), period.getYears());
return age;
}
public static Age calculateAge2(Date tglRegistrasi, Date birthDate) {
int years = 0;
int months = 0;
int days = 0;
try {
Calendar birthDay = Calendar.getInstance();
birthDay.setTimeInMillis(birthDate.getTime());
Calendar regDay = Calendar.getInstance();
regDay.setTimeInMillis(tglRegistrasi.getTime());
years = regDay.get(1) - birthDay.get(1);
int currMonth = regDay.get(2) + 1;
int birthMonth = birthDay.get(2) + 1;
months = currMonth - birthMonth;
if (months < 0) {
--years;
months = 12 - birthMonth + currMonth;
if (regDay.get(5) < birthDay.get(5)) {
--months;
}
} else if (months == 0 && regDay.get(5) < birthDay.get(5)) {
--years;
months = 11;
}
if (regDay.get(5) > birthDay.get(5)) {
days = regDay.get(5) - birthDay.get(5);
} else if (regDay.get(5) < birthDay.get(5)) {
int today = regDay.get(5);
regDay.add(2, -1);
days = regDay.getActualMaximum(5) - birthDay.get(5) + today;
} else {
days = 0;
if (months == 12) {
++years;
months = 0;
}
}
} catch (Exception var10) {
}
return new Age(days, months, years);
} }
} }

View File

@ -1,42 +1,10 @@
package com.reporting.Utility; package com.reporting.Utility;
public class Constants { public class Constants {
public static final long ACCESS_TOKEN_VALIDITY_SECONDS = 18000L;
public static final String SIGNING_KEY = "x1y2z399";
public static final String TOKEN_PREFIX = "";
public static final String HEADER_STRING = "Authorization";
public static final boolean _TRUE = true;
public static final boolean _FALSE = false;
public Constants() { public Constants() {
} }
public static final class ConnDb1 { public static final class ConnDb1 {
public static final String poolName = "PoolReporting1";
public static final String typeDriver = "com.zaxxer.hikari.HikariDataSource";
public static final String driverClassName = "org.postgresql.Driver";
public static final String urlDriver = "jdbc:postgresql://172.16.88.8:5432/rsab_hk_production";
public static final String userName = "postgres";
public static final String password = "root";
public static final String testQuery = "SELECT 1";
public static final int maxTimeOut = 100000;
public static final int maxLifetime = 60000;
public static final int minIdle = 5;
public static final int idleTimeout = 300000;
public static final int maximumPoolSize = 20;
public static final Boolean autoCommit = true; public static final Boolean autoCommit = true;
public ConnDb1() {
}
}
public static final class MessageInfo {
public static final String INFO_MESSAGE = "INFO_MESSAGE";
public static final String WARNING_MESSAGE = "WARNING_MESSAGE";
public static final String ERROR_MESSAGE = "ERROR_MESSAGE";
public static final String EXCEPTION_MESSAGE = "EXCEPTION_MESSAGE";
public MessageInfo() {
}
} }
} }

View File

@ -1,91 +0,0 @@
package com.reporting.Utility;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class DatabaseUtility {
static final Log LOG = LogFactory.getLog(DatabaseUtility.class);
public DatabaseUtility() {
}
public static void clear(Connection conn, PreparedStatement pstmt, ResultSet rs) throws Exception {
try {
if (pstmt != null) {
if (rs != null) {
rs.close();
rs = null;
}
pstmt.close();
pstmt = null;
}
if (conn != null) {
conn.close();
conn = null;
}
} catch (Exception var4) {
LOG.error("Exception at clear(conn, pstmt, rs)");
LOG.error(DatabaseUtility.class, var4);
throw var4;
}
}
public static void clear(Connection conn, PreparedStatement pstmt) throws Exception {
try {
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
if (conn != null) {
conn.close();
conn = null;
}
} catch (Exception var3) {
LOG.error("Exception at clear(conn, pstmt)");
LOG.error(DatabaseUtility.class, var3);
throw var3;
}
}
public static void clear(PreparedStatement pstmt, ResultSet rs) throws Exception {
try {
if (pstmt != null) {
if (rs != null) {
rs.close();
rs = null;
}
pstmt.close();
pstmt = null;
}
} catch (Exception var3) {
LOG.error("Exception at clear(pstmt, rs)");
LOG.error(DatabaseUtility.class, var3);
throw var3;
}
}
public static void clear(PreparedStatement pstmt) throws Exception {
try {
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
} catch (Exception var2) {
LOG.error("Exception at clear(pstmt)");
LOG.error(DatabaseUtility.class, var2);
throw var2;
}
}
}

View File

@ -3,33 +3,24 @@ package com.reporting.config;
import com.reporting.Utility.Constants.ConnDb1; import com.reporting.Utility.Constants.ConnDb1;
import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource; import com.zaxxer.hikari.HikariDataSource;
import javax.sql.DataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import javax.sql.DataSource;
@Configuration @Configuration
public class DbConfig { public class DbConfig {
static final Log LOG = LogFactory.getLog(DbConfig.class);
public DbConfig() { public DbConfig() {
} }
@Primary @Primary
@Bean( @Bean(name = {"db"})
name = {"db"}
)
public DataSource dataSource1() { public DataSource dataSource1() {
HikariConfig config = null;
try { try {
config = new HikariConfig(); HikariConfig config = new HikariConfig();
config.setPoolName("PoolReporting1"); config.setPoolName("PoolReporting1");
config.setDriverClassName("org.postgresql.Driver"); config.setDriverClassName("org.postgresql.Driver");
config.setConnectionTestQuery("SELECT 1"); config.setConnectionTestQuery("SELECT 1");
@ -41,16 +32,14 @@ public class DbConfig {
config.setMaximumPoolSize(20); config.setMaximumPoolSize(20);
config.setConnectionTimeout(100000L); config.setConnectionTimeout(100000L);
config.setAutoCommit(ConnDb1.autoCommit); config.setAutoCommit(ConnDb1.autoCommit);
return new HikariDataSource(config);
} catch (Exception var3) { } catch (Exception var3) {
System.out.println(var3.getMessage()); System.out.println(var3.getMessage());
} }
return null;
return new HikariDataSource(config);
} }
@Bean( @Bean(name = {"jdbcTemplate"})
name = {"jdbcTemplate"}
)
public JdbcTemplate jdbcTemplate1(@Qualifier("db") DataSource ds) { public JdbcTemplate jdbcTemplate1(@Qualifier("db") DataSource ds) {
return new JdbcTemplate(ds); return new JdbcTemplate(ds);
} }

View File

@ -4,330 +4,259 @@ import com.reporting.model.Pasien;
import com.reporting.service.ReportingService; import com.reporting.service.ReportingService;
import com.reporting.service.ResepService; import com.reporting.service.ResepService;
import com.reporting.service.VerifikasiTagihanSupplierServices; import com.reporting.service.VerifikasiTagihanSupplierServices;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.jasperreports.engine.JasperExportManager; import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JasperPrint;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.HashMap;
import java.util.Map;
@RestController @RestController
@RequestMapping({"/service-reporting"}) @RequestMapping({"/service-reporting"})
public class ReportingController { public class ReportingController {
static final Log LOG = LogFactory.getLog(ReportingController.class);
@Autowired @Autowired
private ReportingService reportingService; private ReportingService reportingService;
@Autowired @Autowired
private ResepService resepService; private ResepService resepService;
@Autowired @Autowired
private VerifikasiTagihanSupplierServices verifikasiTagihanSupplierServices; private VerifikasiTagihanSupplierServices verifikasiTagihanSupplierServices;
public ReportingController() { public ReportingController() {
} }
@RequestMapping( @RequestMapping(value = {"/label-gizi/{noregistrasi}"}, method = {RequestMethod.GET})
value = {"/label-gizi/{noregistrasi}"}, public void exportLabelGiziTest(@PathVariable("noregistrasi") String noregistrasi,
method = {RequestMethod.GET} ModelAndView mv, HttpServletResponse response) throws Exception {
) JasperPrint jasperPrint = this.reportingService.exportPdfLabelGizi(noregistrasi);
public void exportLabelGiziTest(ModelAndView mv, @PathVariable("noregistrasi") String noregistrasi, HttpServletResponse response) throws Exception {
JasperPrint jasperPrint = null;
jasperPrint = this.reportingService.exportPdfLabelGizi(noregistrasi);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
} }
@RequestMapping( @RequestMapping(value = {"/permintaan-makanan"}, method = {RequestMethod.GET})
value = {"/permintaan-makanan"}, public void exportPermintaanMakanan(@RequestParam("idRu") Integer idRu,
method = {RequestMethod.GET} @RequestParam("tglAwal") String tglAwal,
) @RequestParam("tglAkhir") String tglAkhir,
public void exportPermintaanMakanan(@RequestParam("idRu") Integer idRu, @RequestParam("tglAwal") String tglAwal, @RequestParam("tglAkhir") String tglAkhir, HttpServletResponse response) throws Exception { HttpServletResponse response) throws Exception {
JasperPrint jasperPrint = null; JasperPrint jasperPrint = this.reportingService.exportPdfPermintaanMakanan(idRu, tglAwal, tglAkhir);
jasperPrint = this.reportingService.exportPdfPermintaanMakanan(idRu, tglAwal, tglAkhir);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
} }
@RequestMapping( @RequestMapping(value = {"/rekap-makanan"}, method = {RequestMethod.GET})
value = {"/rekap-makanan"}, public void exportRekapMakanan(@RequestParam("idRu") Integer idRu,
method = {RequestMethod.GET} @RequestParam("tglAwal") String tglAwal,
) @RequestParam("tglAkhir") String tglAkhir,
public void exportRekapMakanan(@RequestParam("idRu") Integer idRu, @RequestParam("tglAwal") String tglAwal, @RequestParam("tglAkhir") String tglAkhir, HttpServletResponse response) throws Exception { HttpServletResponse response) throws Exception {
JasperPrint jasperPrint = null; JasperPrint jasperPrint = this.reportingService.exportPdfRekapMakanan(idRu, tglAwal, tglAkhir);
jasperPrint = this.reportingService.exportPdfRekapMakanan(idRu, tglAwal, tglAkhir);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
} }
@RequestMapping( @RequestMapping(value = {"/kartu-pasien/{nocm}"}, method = {RequestMethod.GET})
value = {"/kartu-pasien/{nocm}"}, public void exportKartuPasien(@PathVariable("nocm") String nocm,
method = {RequestMethod.GET} ModelAndView mv, HttpServletResponse response) throws Exception {
) JasperPrint jasperPrint = this.reportingService.printReportKartuPasien(nocm);
public void exportKartuPasien(ModelAndView mv, @PathVariable("nocm") String nocm, HttpServletResponse response) throws Exception {
JasperPrint jasperPrint = null;
jasperPrint = this.reportingService.printReportKartuPasien(nocm);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
} }
@RequestMapping( @RequestMapping(value = {"/resep-dokter"}, method = {RequestMethod.GET})
value = {"/resep-dokter"},
method = {RequestMethod.GET}
)
public Map<String, Object> getResepDokter(@RequestParam("strukOrder") String strukOrder) { public Map<String, Object> getResepDokter(@RequestParam("strukOrder") String strukOrder) {
Map<String, Object> map = new HashMap(); Map<String, Object> map = new HashMap<>();
try { try {
Pasien pasien = this.resepService.getPasien(strukOrder); Pasien pasien = this.resepService.getPasien(strukOrder);
map.put("data", pasien); map.put("data", pasien);
} catch (Exception var4) { } catch (Exception var4) {
var4.printStackTrace(); var4.printStackTrace();
} }
return map; return map;
} }
@RequestMapping( @RequestMapping(value = {"/resep-pasien/{strukOrder}"}, method = {RequestMethod.GET})
value = {"/resep-pasien/{strukOrder}"}, public void exportResepPasien(@PathVariable("strukOrder") String strukOrder,
method = {RequestMethod.GET} ModelAndView mv, HttpServletResponse response) throws Exception {
) JasperPrint jasperPrint = this.resepService.exportPdfResepPasien(strukOrder);
public void exportResepPasien(ModelAndView mv, @PathVariable("strukOrder") String strukOrder, HttpServletResponse response) throws Exception {
JasperPrint jasperPrint = null;
jasperPrint = this.resepService.exportPdfResepPasien(strukOrder);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
} }
@RequestMapping( @RequestMapping(value = {"/lap-bedah/{noregis}"}, method = {RequestMethod.GET})
value = {"/lap-bedah/{noregis}"}, public void exportLapBedahPasien(@PathVariable("noregis") String noregis,
method = {RequestMethod.GET} ModelAndView mv, HttpServletResponse response) throws Exception {
) JasperPrint jasperPrint = this.reportingService.printReportLapBedah(noregis);
public void exportLapBedahPasien(ModelAndView mv, @PathVariable("noregis") String noregis, HttpServletResponse response) throws Exception {
JasperPrint jasperPrint = null;
jasperPrint = this.reportingService.printReportLapBedah(noregis);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
} }
@RequestMapping( @RequestMapping(value = {"/lap-konsul/{noorder}"}, method = {RequestMethod.GET})
value = {"/lap-konsul/{noorder}"}, public void exportKonsulPasien(@PathVariable("noorder") String noorder,
method = {RequestMethod.GET} ModelAndView mv, HttpServletResponse response) throws Exception {
) JasperPrint jasperPrint = this.reportingService.printReportKonsul(noorder);
public void exportKonsulPasien(ModelAndView mv, @PathVariable("noorder") String noorder, HttpServletResponse response) throws Exception {
JasperPrint jasperPrint = null;
jasperPrint = this.reportingService.printReportKonsul(noorder);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
} }
@RequestMapping( @RequestMapping(value = {"/lap-lab/{noorder}"}, method = {RequestMethod.GET})
value = {"/lap-lab/{noorder}"},
method = {RequestMethod.GET}
)
public void showPDF(@PathVariable("noorder") String noorder, HttpServletResponse response) { public void showPDF(@PathVariable("noorder") String noorder, HttpServletResponse response) {
InputStream inputStream = null; try (InputStream inputStream = Files.newInputStream(
new File("/mnt/lis/" + noorder + ".pdf").toPath())) {
try {
String path = "/mnt/lis/" + noorder + ".pdf";
File file = new File(path);
inputStream = new FileInputStream(file);
int nRead; int nRead;
while ((nRead = inputStream.read()) != -1) { while ((nRead = inputStream.read()) != -1) {
response.getWriter().write(nRead); response.getWriter().write(nRead);
} }
} catch (Exception var15) { } catch (Exception var15) {
System.out.println(var15.getMessage()); System.out.println(var15.getMessage());
} finally { }
try {
inputStream.close();
} catch (Exception var14) {
} }
} @RequestMapping(value = {"/cetak-sep/{norec_pd}"}, method = {RequestMethod.GET})
}
@RequestMapping(
value = {"/cetak-sep/{norec_pd}"},
method = {RequestMethod.GET}
)
public void showPDFSEP(@PathVariable("norec_pd") String norec_pd, HttpServletResponse response) { public void showPDFSEP(@PathVariable("norec_pd") String norec_pd, HttpServletResponse response) {
InputStream inputStream = null; try (InputStream inputStream = Files.newInputStream(
new File("/home/admindev/reporting/" + norec_pd + ".pdf").toPath())) {
try {
String path = "/home/admindev/reporting/" + norec_pd + ".pdf";
File file = new File(path);
inputStream = new FileInputStream(file);
int nRead; int nRead;
while ((nRead = inputStream.read()) != -1) { while ((nRead = inputStream.read()) != -1) {
response.getWriter().write(nRead); response.getWriter().write(nRead);
} }
} catch (Exception var15) { } catch (Exception var15) {
System.out.println(var15.getMessage()); System.out.println(var15.getMessage());
} finally { }
try {
inputStream.close();
} catch (Exception var14) {
} }
} @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);
@RequestMapping(
value = {"/lap-upk/{nores}"},
method = {RequestMethod.GET}
)
public void exportUpk(ModelAndView mv, @PathVariable("nores") String nores, HttpServletResponse response) throws Exception {
JasperPrint jasperPrint = null;
jasperPrint = this.reportingService.printReportUpk(nores);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
} }
@RequestMapping( @RequestMapping(value = {"/lap-verifikasi-tagihan-supplier/{noverifikasifk}"}, method = {RequestMethod.GET})
value = {"/lap-verifikasi-tagihan-supplier/{noverifikasifk}"}, public void exportVerifikasiTagihanSupplier(
method = {RequestMethod.GET} @PathVariable("noverifikasifk") String noverifikasifk, ModelAndView mv,
) HttpServletResponse response, HttpServletRequest req) throws Exception {
public void exportVerifikasiTagihanSupplier(ModelAndView mv, @PathVariable("noverifikasifk") String noverifikasifk, HttpServletResponse response, HttpServletRequest req) throws Exception { JasperPrint jasperPrint = this.verifikasiTagihanSupplierServices.generateVerifikasiTagihanPdf(noverifikasifk);
JasperPrint jasperPrint = null;
jasperPrint = this.verifikasiTagihanSupplierServices.generateVerifikasiTagihanPdf(noverifikasifk);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
} }
@RequestMapping( @RequestMapping(value = {"/lap-verifikasi-pembayaran-umum/{noverifikasifk}"}, method = {RequestMethod.GET})
value = {"/lap-verifikasi-pembayaran-umum/{noverifikasifk}"}, public void exportVerifikasiPembayaranUmum(
method = {RequestMethod.GET} @PathVariable("noverifikasifk") String noverifikasifk, ModelAndView mv,
) HttpServletResponse response, HttpServletRequest req) throws Exception {
public void exportVerifikasiPembayaranUmum(ModelAndView mv, @PathVariable("noverifikasifk") String noverifikasifk, HttpServletResponse response, HttpServletRequest req) throws Exception { JasperPrint jasperPrint = this.verifikasiTagihanSupplierServices
JasperPrint jasperPrint = null; .generateVerifikasiPembayaranUmumPdf(noverifikasifk);
jasperPrint = this.verifikasiTagihanSupplierServices.generateVerifikasiPembayaranUmumPdf(noverifikasifk);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
} }
@RequestMapping( @RequestMapping(value = {"/lap-rekap-harian-by-dept/{deptId}/{tglAwal}/{tglAkhir}"}, method = {RequestMethod.GET})
value = {"/lap-rekap-harian-by-dept/{deptId}/{tglAwal}/{tglAkhir}"}, public void exportRekapPHarian(@PathVariable("deptId") int deptId,
method = {RequestMethod.GET} @PathVariable("tglAwal") String tglAwal,
) @PathVariable("tglAkhir") String tglAkhir, ModelAndView mv,
public void exportRekapPHarian(ModelAndView mv, @PathVariable("deptId") int deptId, @PathVariable("tglAwal") String tglAwal, @PathVariable("tglAkhir") String tglAkhir, HttpServletResponse response, HttpServletRequest req) throws Exception { HttpServletResponse response, HttpServletRequest req) throws Exception {
JasperPrint jasperPrint = null; JasperPrint jasperPrint = this.reportingService.printPdfLapRekapHarianByDept(deptId, tglAwal, tglAkhir);
jasperPrint = this.reportingService.printPdfLapRekapHarianByDept(deptId, tglAwal, tglAkhir);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
} }
@RequestMapping( @RequestMapping(value = {"/lap-rekap-harian-by-ruangan/{deptId}/{ruangId}/{tglAwal}/{tglAkhir}"},
value = {"/lap-rekap-harian-by-ruangan/{deptId}/{ruangId}/{tglAwal}/{tglAkhir}"}, method = {RequestMethod.GET})
method = {RequestMethod.GET} public void exportRekapPHarian(@PathVariable("deptId") int deptId,
) @PathVariable("ruangId") int ruangId,
public void exportRekapPHarian(ModelAndView mv, @PathVariable("deptId") int deptId, @PathVariable("ruangId") int ruangId, @PathVariable("tglAwal") String tglAwal, @PathVariable("tglAkhir") String tglAkhir, HttpServletResponse response, HttpServletRequest req) throws Exception { @PathVariable("tglAwal") String tglAwal,
JasperPrint jasperPrint = null; @PathVariable("tglAkhir") String tglAkhir, ModelAndView mv,
jasperPrint = this.reportingService.printPdfLapRekapHarianByRuanganId(deptId, ruangId, tglAwal, tglAkhir); HttpServletResponse response, HttpServletRequest req) throws Exception {
JasperPrint jasperPrint = this.reportingService
.printPdfLapRekapHarianByRuanganId(deptId, ruangId, tglAwal, tglAkhir);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
} }
@RequestMapping( @RequestMapping(value = {"/lap-pengkajian-awal-by-nores/{nores}"}, method = {RequestMethod.GET})
value = {"/lap-pengkajian-awal-by-nores/{nores}"}, public void exportPengkajianAwalbyNoRes(@PathVariable("nores") String nores, ModelAndView mv,
method = {RequestMethod.GET} HttpServletRequest req, HttpServletResponse response) throws Exception {
) JasperPrint jasperPrint = this.reportingService.printPdfPengkajianAwalByNoRes(nores);
public void exportPengkajianAwalbyNoRes(ModelAndView mv, @PathVariable("nores") String nores, HttpServletRequest req, HttpServletResponse response) throws Exception {
JasperPrint jasperPrint = null;
jasperPrint = this.reportingService.printPdfPengkajianAwalByNoRes(nores);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
} }
@RequestMapping( @RequestMapping(value = {"/lap-rekap-penjamin"}, method = {RequestMethod.GET})
value = {"/lap-rekap-penjamin"}, public void exportRekapPenjamin(@RequestParam("tglAwal") String tglAwal,
method = {RequestMethod.GET} @RequestParam("tglAkhir") String tglAkhir,
) @RequestParam("idDept") int idDept,
public void exportRekapPenjamin(ModelAndView mv, @RequestParam("tglAwal") String tglAwal, @RequestParam("tglAkhir") String tglAkhir, @RequestParam("idDept") int idDept, @RequestParam("kelompokPasien") int kelompokPasien, HttpServletRequest req, HttpServletResponse response) throws Exception { @RequestParam("kelompokPasien") int kelompokPasien, ModelAndView mv,
JasperPrint jasperPrint = null; HttpServletRequest req, HttpServletResponse response) throws Exception {
jasperPrint = this.reportingService.printPdfRekapPenjamin(tglAwal, tglAkhir, idDept, kelompokPasien); JasperPrint jasperPrint = this.reportingService
.printPdfRekapPenjamin(tglAwal, tglAkhir, idDept, kelompokPasien);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
} }
@RequestMapping( @RequestMapping(value = {"/lap-rekap-penjamin-by-institusi"}, method = {RequestMethod.GET})
value = {"/lap-rekap-penjamin-by-institusi"}, public void exportRekapPenjaminByInstitusiPasien(
method = {RequestMethod.GET} @RequestParam("tglAwal") String tglAwal, @RequestParam("tglAkhir") String tglAkhir,
) @RequestParam("idDept") int idDept, @RequestParam("kelompokPasien") int kelompokPasien,
public void exportRekapPenjaminByInstitusiPasien(ModelAndView mv, @RequestParam("tglAwal") String tglAwal, @RequestParam("tglAkhir") String tglAkhir, @RequestParam("idDept") int idDept, @RequestParam("kelompokPasien") int kelompokPasien, @RequestParam("institusiPasien") int institusiPasien, HttpServletRequest req, HttpServletResponse response) throws Exception { @RequestParam("institusiPasien") int institusiPasien, ModelAndView mv,
JasperPrint jasperPrint = null; HttpServletRequest req, HttpServletResponse response) throws Exception {
jasperPrint = this.reportingService.printPdfRekapPenjaminByInstitusiPasien(tglAwal, tglAkhir, idDept, kelompokPasien, institusiPasien); JasperPrint jasperPrint = this.reportingService
.printPdfRekapPenjaminByInstitusiPasien(tglAwal, tglAkhir, idDept, kelompokPasien, institusiPasien);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
} }
@RequestMapping( @RequestMapping(value = {"/lap-rekap-penjamin-by-ranap"}, method = {RequestMethod.GET})
value = {"/lap-rekap-penjamin-by-ranap"}, public void exportRekapPenjaminByRanap(@RequestParam("tglAwal") String tglAwal,
method = {RequestMethod.GET} @RequestParam("tglAkhir") String tglAkhir,
) @RequestParam("idDept") int idDept,
public void exportRekapPenjaminByRanap(ModelAndView mv, @RequestParam("tglAwal") String tglAwal, @RequestParam("tglAkhir") String tglAkhir, @RequestParam("idDept") int idDept, @RequestParam("kelompokPasien") int kelompokPasien, HttpServletRequest req, HttpServletResponse response) throws Exception { @RequestParam("kelompokPasien") int kelompokPasien, ModelAndView mv,
JasperPrint jasperPrint = null; HttpServletRequest req, HttpServletResponse response) throws Exception {
jasperPrint = this.reportingService.printPdfRekapPenjaminByRanap(tglAwal, tglAkhir, idDept, kelompokPasien); JasperPrint jasperPrint = this.reportingService
.printPdfRekapPenjaminByRanap(tglAwal, tglAkhir, idDept, kelompokPasien);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
} }
@RequestMapping( @RequestMapping(value = {"/lap-permintaan-makanan"}, method = {RequestMethod.GET})
value = {"/lap-permintaan-makanan"}, public void exportPermintaanMakanan(@RequestParam("idRu") int idRu,
method = {RequestMethod.GET} @RequestParam("tglAwal") String tglAwal,
) @RequestParam("tglAkhir") String tglAkhir, ModelAndView mv,
public void exportPermintaanMakanan(ModelAndView mv, @RequestParam("idRu") int idRu, @RequestParam("tglAwal") String tglAwal, @RequestParam("tglAkhir") String tglAkhir, HttpServletRequest req, HttpServletResponse response) throws Exception { HttpServletRequest req, HttpServletResponse response) throws Exception {
JasperPrint jasperPrint = null; JasperPrint jasperPrint = this.reportingService.printPdfPermintaanMakanan(idRu, tglAwal, tglAkhir);
jasperPrint = this.reportingService.printPdfPermintaanMakanan(idRu, tglAwal, tglAkhir);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
} }
@RequestMapping( @RequestMapping(value = {"/lap-rekap-makanan"}, method = {RequestMethod.GET})
value = {"/lap-rekap-makanan"}, public void exportRekapMakanan(@RequestParam("idRu") int idRu,
method = {RequestMethod.GET} @RequestParam("tglAwal") String tglAwal,
) @RequestParam("tglAkhir") String tglAkhir, ModelAndView mv,
public void exportRekapMakanan(ModelAndView mv, @RequestParam("idRu") int idRu, @RequestParam("tglAwal") String tglAwal, @RequestParam("tglAkhir") String tglAkhir, HttpServletRequest req, HttpServletResponse response) throws Exception { HttpServletRequest req, HttpServletResponse response) throws Exception {
JasperPrint jasperPrint = null; JasperPrint jasperPrint = this.reportingService.printPdfRekapMakanan(idRu, tglAwal, tglAkhir);
jasperPrint = this.reportingService.printPdfRekapMakanan(idRu, tglAwal, tglAkhir);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
} }
@RequestMapping( @RequestMapping(value = {"/gelang-pasien/{noregistrasi}"}, method = {RequestMethod.GET})
value = {"/gelang-pasien/{noregistrasi}"}, public void exportLabelGelangPasien(@PathVariable("noregistrasi") String noregistrasi,
method = {RequestMethod.GET} ModelAndView mv, HttpServletResponse response) throws Exception {
) JasperPrint jasperPrint = this.reportingService.exportPdfGelangPasien(noregistrasi);
public void exportLabelGelangPasien(ModelAndView mv, @PathVariable("noregistrasi") String noregistrasi, HttpServletResponse response) throws Exception {
JasperPrint jasperPrint = null;
jasperPrint = this.reportingService.exportPdfGelangPasien(noregistrasi);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
} }
@RequestMapping( @RequestMapping(value = {"/lap-resume-medis/{norec}"}, method = {RequestMethod.GET})
value = {"/lap-resume-medis/{norec}"}, public void printLapResumeMedis(@PathVariable("norec") String norec,
method = {RequestMethod.GET} ModelAndView mv, HttpServletResponse response) throws Exception {
) JasperPrint jasperPrint = this.reportingService.exportPdfResumeMedis(norec);
public void printLapResumeMedis(ModelAndView mv, @PathVariable("norec") String norec, HttpServletResponse response) throws Exception {
JasperPrint jasperPrint = null;
jasperPrint = this.reportingService.exportPdfResumeMedis(norec);
response.setContentType("application/pdf"); response.setContentType("application/pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream()); JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
} }

View File

@ -1,26 +1,8 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package com.reporting.controller; package com.reporting.controller;
import com.reporting.model.InfoResponse;
import com.reporting.model.Printer; import com.reporting.model.Printer;
import com.reporting.model.PrinterForm; import com.reporting.model.PrinterForm;
import com.reporting.service.UserService; import com.reporting.service.UserService;
import java.io.IOException;
import java.io.OutputStream;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.print.DocFlavor;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.attribute.AttributeSet;
import javax.servlet.http.HttpServletResponse;
import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperExportManager; import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JasperPrint;
@ -31,6 +13,15 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
@Controller @Controller
@RequestMapping({"/"}) @RequestMapping({"/"})
public class UserController { public class UserController {
@ -40,65 +31,46 @@ public class UserController {
public UserController() { public UserController() {
} }
@RequestMapping( @RequestMapping(value = {"/", ""}, method = {RequestMethod.GET})
value = {"/", ""},
method = {RequestMethod.GET}
)
public ModelAndView home() { public ModelAndView home() {
ModelAndView model = new ModelAndView(); ModelAndView model = new ModelAndView();
PrinterForm printerForm = new PrinterForm(); PrinterForm printerForm = new PrinterForm();
PrintService[] services = PrintServiceLookup.lookupPrintServices((DocFlavor) null, (AttributeSet) null); PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
List<Printer> printers = new ArrayList(); List<Printer> printers = new ArrayList<>();
PrintService[] var5 = services;
int var6 = services.length; int var6 = services.length;
for (PrintService service : services) {
for (int var7 = 0; var7 < var6; ++var7) {
PrintService service = var5[var7];
Printer printer = new Printer(); Printer printer = new Printer();
printer.setPrinterName(service.getName()); printer.setPrinterName(service.getName());
printers.add(printer); printers.add(printer);
} }
model.addObject("listPrinters", printers); model.addObject("listPrinters", printers);
model.addObject("printerForm", printerForm); model.addObject("printerForm", printerForm);
model.setViewName("home"); model.setViewName("home");
return model; return model;
} }
@RequestMapping( @RequestMapping(value = {"/export"}, method = {RequestMethod.POST})
value = {"/export"}, public void export(ModelAndView model,
method = {RequestMethod.POST} HttpServletResponse response) throws IOException, JRException, SQLException {
)
public void export(ModelAndView model, HttpServletResponse response) throws IOException, JRException, SQLException {
JasperPrint jasperPrint = null;
response.setContentType("application/x-download"); response.setContentType("application/x-download");
response.setHeader("Content-Disposition", String.format("attachment; filename=\"users.pdf\"")); response.setHeader("Content-Disposition", "attachment; filename=\"users.pdf\"");
OutputStream out = response.getOutputStream(); OutputStream out = response.getOutputStream();
jasperPrint = this.userService.exportPdfFile(); JasperPrint jasperPrint = this.userService.exportPdfFile();
JasperExportManager.exportReportToPdfStream(jasperPrint, out); JasperExportManager.exportReportToPdfStream(jasperPrint, out);
} }
@RequestMapping( @RequestMapping(value = {"/printDirect"}, method = {RequestMethod.POST})
value = {"/printDirect"}, public void printDirect(@ModelAttribute("printerForm") PrinterForm printerForm,
method = {RequestMethod.POST} ModelAndView model) throws IOException, JRException, SQLException {
) JasperPrint jasperPrint = this.userService.exportPdfFile();
public void printDirect(@ModelAttribute("printerForm") PrinterForm printerForm, ModelAndView model) throws IOException, JRException, SQLException {
JasperPrint jasperPrint = null;
jasperPrint = this.userService.exportPdfFile();
this.userService.printReport(jasperPrint, printerForm.getPrinterName()); this.userService.printReport(jasperPrint, printerForm.getPrinterName());
} }
@RequestMapping( @RequestMapping(value = {"/printDirectDefault"}, method = {RequestMethod.POST})
value = {"/printDirectDefault"},
method = {RequestMethod.POST}
)
public void printDirectDefaultPrinter() throws SQLException, JRException, IOException { public void printDirectDefaultPrinter() throws SQLException, JRException, IOException {
JasperPrint jasperPrint = null;
InfoResponse infoResponse = new InfoResponse();
PrintService service = PrintServiceLookup.lookupDefaultPrintService(); PrintService service = PrintServiceLookup.lookupDefaultPrintService();
String printServiceName = service.getName(); String printServiceName = service.getName();
jasperPrint = this.userService.exportPdfFile(); JasperPrint jasperPrint = this.userService.exportPdfFile();
this.userService.printReport(jasperPrint, printServiceName); this.userService.printReport(jasperPrint, printServiceName);
infoResponse.setInfo("Cetak Data Berhasil");
} }
} }

View File

@ -1,43 +0,0 @@
package com.reporting.dao;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.io.ResourceLoader;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@Transactional
@Repository
public class LabelGizi {
@Autowired
@Qualifier("jdbcTemplate")
private JdbcTemplate jdbcTemplate;
@Autowired
private ResourceLoader resourceLoader;
public LabelGizi() {
}
public JasperPrint exportPdfFile() throws SQLException, JRException, IOException {
Connection conn = this.jdbcTemplate.getDataSource().getConnection();
String path = this.resourceLoader.getResource("classpath:rpt_labelgizi.jrxml").getURI().getPath();
JasperReport jasperReport = JasperCompileManager.compileReport(path);
String noregistrasi = "22fa0dd0-43c1-11e9-961f-8d877e74";
Map<String, Object> parameters = new HashMap();
parameters.put("noregistrasi", noregistrasi);
JasperPrint print = JasperFillManager.fillReport(jasperReport, parameters, conn);
return print;
}
}

View File

@ -1,27 +1,6 @@
package com.reporting.dao; package com.reporting.dao;
import java.sql.Connection; import net.sf.jasperreports.engine.*;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import javax.print.DocFlavor;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.attribute.AttributeSet;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.HashPrintServiceAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.PrintServiceAttributeSet;
import javax.print.attribute.standard.MediaSizeName;
import javax.print.attribute.standard.OrientationRequested;
import javax.print.attribute.standard.PrinterName;
import javax.sql.DataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.export.JRPrintServiceExporter; import net.sf.jasperreports.engine.export.JRPrintServiceExporter;
import net.sf.jasperreports.engine.type.OrientationEnum; import net.sf.jasperreports.engine.type.OrientationEnum;
import net.sf.jasperreports.export.SimpleExporterInput; import net.sf.jasperreports.export.SimpleExporterInput;
@ -34,13 +13,21 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.attribute.*;
import javax.print.attribute.standard.MediaSizeName;
import javax.print.attribute.standard.OrientationRequested;
import javax.print.attribute.standard.PrinterName;
import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;
@Transactional @Transactional
@Repository @Repository
public class ReportingDao { public class ReportingDao {
private static final Log LOG = LogFactory.getLog(ReportingDao.class); private static final Log LOG = LogFactory.getLog(ReportingDao.class);
@Autowired
@Qualifier("db")
private DataSource ds1;
@Qualifier("jdbcTemplate") @Qualifier("jdbcTemplate")
@Autowired @Autowired
private JdbcTemplate jdbcTemplate1; private JdbcTemplate jdbcTemplate1;
@ -51,14 +38,11 @@ public class ReportingDao {
public void printReport(JasperPrint jasperPrint, String selectedPrinter) throws JRException { public void printReport(JasperPrint jasperPrint, String selectedPrinter) throws JRException {
PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet(); PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
printRequestAttributeSet.add(MediaSizeName.ISO_A4); printRequestAttributeSet.add(MediaSizeName.ISO_A4);
if (jasperPrint.getOrientationValue() == OrientationEnum.LANDSCAPE) {
printRequestAttributeSet.add(OrientationRequested.LANDSCAPE);
} else {
printRequestAttributeSet.add(OrientationRequested.PORTRAIT); printRequestAttributeSet.add(OrientationRequested.PORTRAIT);
} if (jasperPrint.getOrientationValue() == OrientationEnum.LANDSCAPE)
printRequestAttributeSet.add(OrientationRequested.LANDSCAPE);
PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet(); PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
printServiceAttributeSet.add(new PrinterName(selectedPrinter, (Locale) null)); printServiceAttributeSet.add(new PrinterName(selectedPrinter, null));
JRPrintServiceExporter exporter = new JRPrintServiceExporter(); JRPrintServiceExporter exporter = new JRPrintServiceExporter();
SimplePrintServiceExporterConfiguration configuration = new SimplePrintServiceExporterConfiguration(); SimplePrintServiceExporterConfiguration configuration = new SimplePrintServiceExporterConfiguration();
configuration.setPrintRequestAttributeSet(printRequestAttributeSet); configuration.setPrintRequestAttributeSet(printRequestAttributeSet);
@ -67,500 +51,296 @@ public class ReportingDao {
configuration.setDisplayPrintDialog(false); configuration.setDisplayPrintDialog(false);
exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
exporter.setConfiguration(configuration); exporter.setConfiguration(configuration);
PrintService[] services = PrintServiceLookup.lookupPrintServices((DocFlavor) null, (AttributeSet) null); PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
PrintService selectedService = null; PrintService selectedService = null;
if (services.length != 0 || services != null) {
PrintService[] var9 = services;
int var10 = services.length; int var10 = services.length;
for (PrintService service : services) {
for (int var11 = 0; var11 < var10; ++var11) {
PrintService service = var9[var11];
String existingPrinter = service.getName(); String existingPrinter = service.getName();
if (existingPrinter.equals(selectedPrinter)) { if (existingPrinter.equals(selectedPrinter)) {
selectedService = service; selectedService = service;
break; break;
} }
} }
}
if (selectedService != null) { if (selectedService != null) {
exporter.exportReport(); exporter.exportReport();
} else { } else {
System.out.println("You did not set the printer!"); System.out.println("You did not set the printer!");
} }
} }
public JasperPrint exportPdfLabelGizi(String noregistrasi) throws Exception { public JasperPrint exportPdfLabelGizi(String noregistrasi) {
JasperPrint print = null; try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
Connection conn = null;
try {
conn = this.jdbcTemplate1.getDataSource().getConnection();
String path = "/usr/share/app/reporting/rpt_labelgizi.jrxml"; String path = "/usr/share/app/reporting/rpt_labelgizi.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("noregistrasi", noregistrasi); parameters.put("noregistrasi", noregistrasi);
print = JasperFillManager.fillReport(jasperReport, parameters, conn); return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var15) { } catch (Exception var15) {
LOG.error("Exception at exportPdfLabelGizi"); LOG.error("Exception at exportPdfLabelGizi");
LOG.error(ReportingDao.class, var15); LOG.error(ReportingDao.class, var15);
} finally { }
try { return null;
conn.close();
} catch (Exception var14) {
} }
} public JasperPrint exportPdfPermintaanMakanan(Integer idRu, String tglAwal, String tglAkhir) {
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
return print;
}
public JasperPrint exportPdfPermintaanMakanan(Integer idRu, String tglAwal, String tglAkhir) throws Exception {
JasperPrint print = null;
Connection conn = null;
try {
conn = this.jdbcTemplate1.getDataSource().getConnection();
String path = "/usr/share/app/reporting/pl_permintaan_makan.jrxml"; String path = "/usr/share/app/reporting/pl_permintaan_makan.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("idRu", idRu); parameters.put("idRu", idRu);
parameters.put("tglAwal", tglAwal); parameters.put("tglAwal", tglAwal);
parameters.put("tglAkhir", tglAkhir); parameters.put("tglAkhir", tglAkhir);
print = JasperFillManager.fillReport(jasperReport, parameters, conn); return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var17) { } catch (Exception var17) {
LOG.error("Exception at exportPdfPermintaanMakanan"); LOG.error("Exception at exportPdfPermintaanMakanan");
LOG.error(ReportingDao.class, var17); LOG.error(ReportingDao.class, var17);
} finally { }
try { return null;
conn.close();
} catch (Exception var16) {
} }
} public JasperPrint exportPdfRekapMakanan(Integer idRu, String tglAwal, String tglAkhir) {
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
return print;
}
public JasperPrint exportPdfRekapMakanan(Integer idRu, String tglAwal, String tglAkhir) throws Exception {
JasperPrint print = null;
Connection conn = null;
try {
conn = this.jdbcTemplate1.getDataSource().getConnection();
String path = "/usr/share/app/reporting/pl_rekap_makan.jrxml"; String path = "/usr/share/app/reporting/pl_rekap_makan.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("idRu", idRu); parameters.put("idRu", idRu);
parameters.put("tglAwal", tglAwal); parameters.put("tglAwal", tglAwal);
parameters.put("tglAkhir", tglAkhir); parameters.put("tglAkhir", tglAkhir);
print = JasperFillManager.fillReport(jasperReport, parameters, conn); return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var17) { } catch (Exception var17) {
LOG.error("Exception at exportPdfRekapMakanan"); LOG.error("Exception at exportPdfRekapMakanan");
LOG.error(ReportingDao.class, var17); LOG.error(ReportingDao.class, var17);
} finally { }
try { return null;
conn.close();
} catch (Exception var16) {
} }
} public JasperPrint exportPdfKartuPasien(String nocm) {
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
return print;
}
public JasperPrint exportPdfKartuPasien(String nocm) throws Exception {
JasperPrint print = null;
Connection conn = null;
try {
conn = this.jdbcTemplate1.getDataSource().getConnection();
String path = "/usr/share/app/reporting/rpt_kartupasien.jrxml"; String path = "/usr/share/app/reporting/rpt_kartupasien.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("nocm", nocm); parameters.put("nocm", nocm);
print = JasperFillManager.fillReport(jasperReport, parameters, conn); return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var15) { } catch (Exception var15) {
LOG.error("Exception at exportPdfLabelGizi"); LOG.error("Exception at exportPdfLabelGizi");
LOG.error(ReportingDao.class, var15); LOG.error(ReportingDao.class, var15);
} finally { }
try { return null;
conn.close();
} catch (Exception var14) {
} }
} public JasperPrint exportPdfLapBedah(String noregis) {
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
return print;
}
public JasperPrint exportPdfLapBedah(String noregis) throws Exception {
JasperPrint print = null;
Connection conn = null;
try {
conn = this.jdbcTemplate1.getDataSource().getConnection();
String path = "/usr/share/app/reporting/rpt_lapbedah.jrxml"; String path = "/usr/share/app/reporting/rpt_lapbedah.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("noregis", noregis); parameters.put("noregis", noregis);
print = JasperFillManager.fillReport(jasperReport, parameters, conn); return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var15) { } catch (Exception var15) {
LOG.error("Exception at exportPdfResepPasien"); LOG.error("Exception at exportPdfResepPasien");
LOG.error(ReportingDao.class, var15); LOG.error(ReportingDao.class, var15);
} finally { }
try { return null;
conn.close();
} catch (Exception var14) {
} }
} public JasperPrint exportPdfKonsul(String noorder) {
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
return print;
}
public JasperPrint exportPdfKonsul(String noorder) throws Exception {
JasperPrint print = null;
Connection conn = null;
try {
conn = this.jdbcTemplate1.getDataSource().getConnection();
String path = "/usr/share/app/reporting/rpt_konsul.jrxml"; String path = "/usr/share/app/reporting/rpt_konsul.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("noorder", noorder); parameters.put("noorder", noorder);
print = JasperFillManager.fillReport(jasperReport, parameters, conn); return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var15) { } catch (Exception var15) {
LOG.error("Exception at exportPdfResepPasien"); LOG.error("Exception at exportPdfResepPasien");
LOG.error(ReportingDao.class, var15); LOG.error(ReportingDao.class, var15);
} finally { }
try { return null;
conn.close();
} catch (Exception var14) {
} }
} public JasperPrint exportPdfUpk(String nores) {
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
return print;
}
public JasperPrint exportPdfUpk(String nores) throws Exception {
JasperPrint print = null;
Connection conn = null;
try {
conn = this.jdbcTemplate1.getDataSource().getConnection();
String path = "/usr/share/app/reporting/rpt_upk.jrxml"; String path = "/usr/share/app/reporting/rpt_upk.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("nores", nores); parameters.put("nores", nores);
print = JasperFillManager.fillReport(jasperReport, parameters, conn); return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var15) { } catch (Exception var15) {
LOG.error("Exception at exportPdfUpk"); LOG.error("Exception at exportPdfUpk");
LOG.error(ReportingDao.class, var15); LOG.error(ReportingDao.class, var15);
} finally { }
try { return null;
conn.close();
} catch (Exception var14) {
} }
} public JasperPrint exportPdfVerifikasiTagihan(String noverifikasifk) {
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
return print;
}
public JasperPrint exportPdfVerifikasiTagihan(String noverifikasifk) throws Exception {
JasperPrint print = null;
Connection conn = null;
try {
conn = this.jdbcTemplate1.getDataSource().getConnection();
String path = "/usr/share/app/reporting/BuktiKas.jrxml"; String path = "/usr/share/app/reporting/BuktiKas.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("noverifikasifk", noverifikasifk); parameters.put("noverifikasifk", noverifikasifk);
print = JasperFillManager.fillReport(jasperReport, parameters, conn); return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var15) { } catch (Exception var15) {
LOG.error("Exception at exportPdfVerifikasiTagihan"); LOG.error("Exception at exportPdfVerifikasiTagihan");
LOG.error(ReportingDao.class, var15); LOG.error(ReportingDao.class, var15);
} finally { }
try { return null;
conn.close();
} catch (Exception var14) {
} }
} public JasperPrint exportPdfLapRekapHarianByDept(int deptId, String tglAwal, String tglAkhir) {
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
return print;
}
public JasperPrint exportPdfLapRekapHarianByDept(int deptId, String tglAwal, String tglAkhir) throws Exception {
JasperPrint print = null;
Connection conn = null;
try {
conn = this.jdbcTemplate1.getDataSource().getConnection();
String path = "/usr/share/app/reporting/PL_LapRekapPHarian.jrxml"; String path = "/usr/share/app/reporting/PL_LapRekapPHarian.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("deptId", deptId); parameters.put("deptId", deptId);
parameters.put("tglAwal", tglAwal); parameters.put("tglAwal", tglAwal);
parameters.put("tglAkhir", tglAkhir); parameters.put("tglAkhir", tglAkhir);
print = JasperFillManager.fillReport(jasperReport, parameters, conn); return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var17) { } catch (Exception var17) {
LOG.error("Exception at exportPdfLapRekapHarianByDept"); LOG.error("Exception at exportPdfLapRekapHarianByDept");
LOG.error(ReportingDao.class, var17); LOG.error(ReportingDao.class, var17);
} finally { }
try { return null;
conn.close();
} catch (Exception var16) {
} }
} public JasperPrint exportPdfLapRekapHarianByRuanganId(int deptId, int ruangId, String tglAwal, String tglAkhir) {
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
return print;
}
public JasperPrint exportPdfLapRekapHarianByRuanganId(int deptId, int ruangId, String tglAwal, String tglAkhir) throws Exception {
JasperPrint print = null;
Connection conn = null;
try {
conn = this.jdbcTemplate1.getDataSource().getConnection();
String path = "/usr/share/app/reporting/PL_LapRekapPHarianV2.jrxml"; String path = "/usr/share/app/reporting/PL_LapRekapPHarianV2.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("deptId", deptId); parameters.put("deptId", deptId);
parameters.put("ruangId", ruangId); parameters.put("ruangId", ruangId);
parameters.put("tglAwal", tglAwal); parameters.put("tglAwal", tglAwal);
parameters.put("tglAkhir", tglAkhir); parameters.put("tglAkhir", tglAkhir);
print = JasperFillManager.fillReport(jasperReport, parameters, conn); return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var18) { } catch (Exception var18) {
LOG.error("Exception at exportPdfLapRekapHarianByRuanganId"); LOG.error("Exception at exportPdfLapRekapHarianByRuanganId");
LOG.error(ReportingDao.class, var18); LOG.error(ReportingDao.class, var18);
} finally { }
try { return null;
conn.close();
} catch (Exception var17) {
} }
} public JasperPrint exportPdfPengkajianAwalByNoRes(String nores) {
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
return print;
}
public JasperPrint exportPdfPengkajianAwalByNoRes(String nores) throws Exception {
JasperPrint print = null;
Connection conn = null;
try {
conn = this.jdbcTemplate1.getDataSource().getConnection();
String path = "/usr/share/app/reporting/PL_PengkajianAwal.jrxml"; String path = "/usr/share/app/reporting/PL_PengkajianAwal.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("nores", nores); parameters.put("nores", nores);
print = JasperFillManager.fillReport(jasperReport, parameters, conn); return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var15) { } catch (Exception var15) {
LOG.error("Exception at exportPdfPengkajianAwalByNoRes"); LOG.error("Exception at exportPdfPengkajianAwalByNoRes");
LOG.error(ReportingDao.class, var15); LOG.error(ReportingDao.class, var15);
} finally { }
try { return null;
conn.close();
} catch (Exception var14) {
} }
} public JasperPrint exportPdfRekapPenjamin(String tglAwal, String tglAkhir, int idDept, int kelompokPasien) {
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
return print;
}
public JasperPrint exportPdfRekapPenjamin(String tglAwal, String tglAkhir, int idDept, int kelompokPasien) throws Exception {
JasperPrint print = null;
Connection conn = null;
try {
conn = this.jdbcTemplate1.getDataSource().getConnection();
String path = "/usr/share/app/reporting/PL_rekap_penjamin.jrxml"; String path = "/usr/share/app/reporting/PL_rekap_penjamin.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("tglAwal", tglAwal); parameters.put("tglAwal", tglAwal);
parameters.put("tglAkhir", tglAkhir); parameters.put("tglAkhir", tglAkhir);
parameters.put("idDept", idDept); parameters.put("idDept", idDept);
parameters.put("kelompokPasien", kelompokPasien); parameters.put("kelompokPasien", kelompokPasien);
print = JasperFillManager.fillReport(jasperReport, parameters, conn); return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var18) { } catch (Exception var18) {
LOG.error("Exception at exportPdfPengkajianAwalRekapPenjamin"); LOG.error("Exception at exportPdfPengkajianAwalRekapPenjamin");
LOG.error(ReportingDao.class, var18); LOG.error(ReportingDao.class, var18);
} finally { }
try { return null;
conn.close();
} catch (Exception var17) {
} }
} public JasperPrint exportPdfRekapPenjaminByInstitusiPasien(
String tglAwal, String tglAkhir, int idDept, int kelompokPasien, int institusiPasien) {
return print; try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
}
public JasperPrint exportPdfRekapPenjaminByInstitusiPasien(String tglAwal, String tglAkhir, int idDept, int kelompokPasien, int institusiPasien) throws Exception {
JasperPrint print = null;
Connection conn = null;
try {
conn = this.jdbcTemplate1.getDataSource().getConnection();
String path = "/usr/share/app/reporting/PL_rekap_penjamin.jrxml"; String path = "/usr/share/app/reporting/PL_rekap_penjamin.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("tglAwal", tglAwal); parameters.put("tglAwal", tglAwal);
parameters.put("tglAkhir", tglAkhir); parameters.put("tglAkhir", tglAkhir);
parameters.put("idDept", idDept); parameters.put("idDept", idDept);
parameters.put("kelompokPasien", kelompokPasien); parameters.put("kelompokPasien", kelompokPasien);
parameters.put("institusiPasien", institusiPasien); parameters.put("institusiPasien", institusiPasien);
print = JasperFillManager.fillReport(jasperReport, parameters, conn); return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var19) { } catch (Exception var19) {
LOG.error("Exception at exportPdfPengkajianAwalRekapPenjaminByInstitusiPasien"); LOG.error("Exception at exportPdfPengkajianAwalRekapPenjaminByInstitusiPasien");
LOG.error(ReportingDao.class, var19); LOG.error(ReportingDao.class, var19);
} finally { }
try { return null;
conn.close();
} catch (Exception var18) {
} }
} public JasperPrint exportPdfRekapPenjaminByRanap(String tglAwal, String tglAkhir, int idDept, int kelompokPasien) {
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
return print;
}
public JasperPrint exportPdfRekapPenjaminByRanap(String tglAwal, String tglAkhir, int idDept, int kelompokPasien) throws Exception {
JasperPrint print = null;
Connection conn = null;
try {
conn = this.jdbcTemplate1.getDataSource().getConnection();
String path = "/usr/share/app/reporting/PL_rekap_penjaminRanap.jrxml"; String path = "/usr/share/app/reporting/PL_rekap_penjaminRanap.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("tglAwal", tglAwal); parameters.put("tglAwal", tglAwal);
parameters.put("tglAkhir", tglAkhir); parameters.put("tglAkhir", tglAkhir);
parameters.put("idDept", idDept); parameters.put("idDept", idDept);
parameters.put("kelompokPasien", kelompokPasien); parameters.put("kelompokPasien", kelompokPasien);
print = JasperFillManager.fillReport(jasperReport, parameters, conn); return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var18) { } catch (Exception var18) {
LOG.error("Exception at exportPdfRekapPenjaminByRanap"); LOG.error("Exception at exportPdfRekapPenjaminByRanap");
LOG.error(ReportingDao.class, var18); LOG.error(ReportingDao.class, var18);
} finally { }
try { return null;
conn.close();
} catch (Exception var17) {
} }
} public JasperPrint exportPdfPermintaanMakanan(int idRu, String tglAwal, String tglAkhir) {
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
return print;
}
public JasperPrint exportPdfPermintaanMakanan(int idRu, String tglAwal, String tglAkhir) throws Exception {
JasperPrint print = null;
Connection conn = null;
try {
conn = this.jdbcTemplate1.getDataSource().getConnection();
String path = "/usr/share/app/reporting/pl_permintaan_makan.jrxml"; String path = "/usr/share/app/reporting/pl_permintaan_makan.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("idRu", idRu); parameters.put("idRu", idRu);
parameters.put("tglAwal", tglAwal); parameters.put("tglAwal", tglAwal);
parameters.put("tglAkhir", tglAkhir); parameters.put("tglAkhir", tglAkhir);
print = JasperFillManager.fillReport(jasperReport, parameters, conn); return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var17) { } catch (Exception var17) {
LOG.error("Exception at exportPdfPermintaanMakanan"); LOG.error("Exception at exportPdfPermintaanMakanan");
LOG.error(ReportingDao.class, var17); LOG.error(ReportingDao.class, var17);
} finally { }
try { return null;
conn.close();
} catch (Exception var16) {
} }
} public JasperPrint exportPdfRekapMakanan(int idRu, String tglAwal, String tglAkhir) {
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
return print;
}
public JasperPrint exportPdfRekapMakanan(int idRu, String tglAwal, String tglAkhir) throws Exception {
JasperPrint print = null;
Connection conn = null;
try {
conn = this.jdbcTemplate1.getDataSource().getConnection();
String path = "/usr/share/app/reporting/pl_rekap_makan.jrxml"; String path = "/usr/share/app/reporting/pl_rekap_makan.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("idRu", idRu); parameters.put("idRu", idRu);
parameters.put("tglAwal", tglAwal); parameters.put("tglAwal", tglAwal);
parameters.put("tglAkhir", tglAkhir); parameters.put("tglAkhir", tglAkhir);
print = JasperFillManager.fillReport(jasperReport, parameters, conn); return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var17) { } catch (Exception var17) {
LOG.error("Exception at exportPdfRekapMakanan"); LOG.error("Exception at exportPdfRekapMakanan");
LOG.error(ReportingDao.class, var17); LOG.error(ReportingDao.class, var17);
} finally { }
try { return null;
conn.close();
} catch (Exception var16) {
} }
} public JasperPrint exportPdfGelangPasien(String noregistrasi) {
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
return print;
}
public JasperPrint exportPdfGelangPasien(String noregistrasi) throws Exception {
JasperPrint print = null;
Connection conn = null;
try {
conn = this.jdbcTemplate1.getDataSource().getConnection();
String path = "/usr/share/app/reporting/gelang_pasien.jrxml"; String path = "/usr/share/app/reporting/gelang_pasien.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("noregistrasi", noregistrasi); parameters.put("noregistrasi", noregistrasi);
print = JasperFillManager.fillReport(jasperReport, parameters, conn); return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var15) { } catch (Exception var15) {
LOG.error("Exception at exportPdfGelangPasien"); LOG.error("Exception at exportPdfGelangPasien");
LOG.error(ReportingDao.class, var15); LOG.error(ReportingDao.class, var15);
} finally { }
try { return null;
conn.close();
} catch (Exception var14) {
} }
} public JasperPrint exportPdfResumeMedis(String norec) {
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
return print;
}
public JasperPrint exportPdfResumeMedis(String norec) throws Exception {
JasperPrint print = null;
Connection conn = null;
try {
conn = this.jdbcTemplate1.getDataSource().getConnection();
String path = "/usr/share/app/reporting/ResumeMedis.jrxml"; String path = "/usr/share/app/reporting/ResumeMedis.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("norec", norec); parameters.put("norec", norec);
print = JasperFillManager.fillReport(jasperReport, parameters, conn); return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var15) { } catch (Exception var15) {
LOG.error("Exception at exportPdfResumeMedis"); LOG.error("Exception at exportPdfResumeMedis");
LOG.error(ReportingDao.class, var15); LOG.error(ReportingDao.class, var15);
} finally {
try {
conn.close();
} catch (Exception var14) {
} }
return null;
}
return print;
} }
} }

View File

@ -1,28 +1,6 @@
package com.reporting.dao; package com.reporting.dao;
import java.io.IOException; import net.sf.jasperreports.engine.*;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import javax.print.DocFlavor;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.attribute.AttributeSet;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.HashPrintServiceAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.PrintServiceAttributeSet;
import javax.print.attribute.standard.MediaSizeName;
import javax.print.attribute.standard.OrientationRequested;
import javax.print.attribute.standard.PrinterName;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.export.JRPrintServiceExporter; import net.sf.jasperreports.engine.export.JRPrintServiceExporter;
import net.sf.jasperreports.engine.type.OrientationEnum; import net.sf.jasperreports.engine.type.OrientationEnum;
import net.sf.jasperreports.export.SimpleExporterInput; import net.sf.jasperreports.export.SimpleExporterInput;
@ -34,12 +12,25 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.attribute.*;
import javax.print.attribute.standard.MediaSizeName;
import javax.print.attribute.standard.OrientationRequested;
import javax.print.attribute.standard.PrinterName;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
@Transactional @Transactional
@Repository @Repository
public class UserDaoImpl { public class UserDaoImpl {
@Autowired @Autowired
@Qualifier("jdbcTemplate") @Qualifier("jdbcTemplate")
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
@Autowired @Autowired
private ResourceLoader resourceLoader; private ResourceLoader resourceLoader;
@ -50,22 +41,18 @@ public class UserDaoImpl {
Connection conn = this.jdbcTemplate.getDataSource().getConnection(); Connection conn = this.jdbcTemplate.getDataSource().getConnection();
String path = this.resourceLoader.getResource("classpath:rpt_users.jrxml").getURI().getPath(); String path = this.resourceLoader.getResource("classpath:rpt_users.jrxml").getURI().getPath();
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
JasperPrint print = JasperFillManager.fillReport(jasperReport, parameters, conn); return JasperFillManager.fillReport(jasperReport, parameters, conn);
return print;
} }
public void printReport(JasperPrint jasperPrint, String selectedPrinter) throws JRException { public void printReport(JasperPrint jasperPrint, String selectedPrinter) throws JRException {
PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet(); PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
printRequestAttributeSet.add(MediaSizeName.ISO_A4); printRequestAttributeSet.add(MediaSizeName.ISO_A4);
if (jasperPrint.getOrientationValue() == OrientationEnum.LANDSCAPE) {
printRequestAttributeSet.add(OrientationRequested.LANDSCAPE);
} else {
printRequestAttributeSet.add(OrientationRequested.PORTRAIT); printRequestAttributeSet.add(OrientationRequested.PORTRAIT);
} if (jasperPrint.getOrientationValue() == OrientationEnum.LANDSCAPE)
printRequestAttributeSet.add(OrientationRequested.LANDSCAPE);
PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet(); PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
printServiceAttributeSet.add(new PrinterName(selectedPrinter, (Locale) null)); printServiceAttributeSet.add(new PrinterName(selectedPrinter, null));
JRPrintServiceExporter exporter = new JRPrintServiceExporter(); JRPrintServiceExporter exporter = new JRPrintServiceExporter();
SimplePrintServiceExporterConfiguration configuration = new SimplePrintServiceExporterConfiguration(); SimplePrintServiceExporterConfiguration configuration = new SimplePrintServiceExporterConfiguration();
configuration.setPrintRequestAttributeSet(printRequestAttributeSet); configuration.setPrintRequestAttributeSet(printRequestAttributeSet);
@ -74,27 +61,20 @@ public class UserDaoImpl {
configuration.setDisplayPrintDialog(false); configuration.setDisplayPrintDialog(false);
exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
exporter.setConfiguration(configuration); exporter.setConfiguration(configuration);
PrintService[] services = PrintServiceLookup.lookupPrintServices((DocFlavor) null, (AttributeSet) null); PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
PrintService selectedService = null; PrintService selectedService = null;
if (services.length != 0 || services != null) {
PrintService[] var9 = services;
int var10 = services.length; int var10 = services.length;
for (PrintService service : services) {
for (int var11 = 0; var11 < var10; ++var11) {
PrintService service = var9[var11];
String existingPrinter = service.getName(); String existingPrinter = service.getName();
if (existingPrinter.equals(selectedPrinter)) { if (existingPrinter.equals(selectedPrinter)) {
selectedService = service; selectedService = service;
break; break;
} }
} }
}
if (selectedService != null) { if (selectedService != null) {
exporter.exportReport(); exporter.exportReport();
} else { } else {
System.out.println("You did not set the printer!"); System.out.println("You did not set the printer!");
} }
} }
} }

View File

@ -1,37 +0,0 @@
package com.reporting.model;
public class ApiResponse<T> {
private int status;
private String message;
private Object result;
public ApiResponse(int status, String message, Object result) {
this.status = status;
this.message = message;
this.result = result;
}
public int getStatus() {
return this.status;
}
public void setStatus(int status) {
this.status = status;
}
public String getMessage() {
return this.message;
}
public void setMessage(String message) {
this.message = message;
}
public Object getResult() {
return this.result;
}
public void setResult(Object result) {
this.result = result;
}
}

View File

@ -1,16 +0,0 @@
package com.reporting.model;
public class InfoResponse {
private String info;
public InfoResponse() {
}
public String getInfo() {
return this.info;
}
public void setInfo(String info) {
this.info = info;
}
}

View File

@ -1,52 +0,0 @@
package com.reporting.service;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.parser.PdfTextExtractor;
import com.reporting.dao.ReportingDao;
import java.io.File;
import java.io.FileInputStream;
import javax.sql.DataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@Service("lapLabService")
public class LapLabService {
static final Log LOG = LogFactory.getLog(LapLabService.class);
@Autowired
@Qualifier("db")
private DataSource ds1;
@Qualifier("jdbcTemplate")
@Autowired
private JdbcTemplate jdbcTemplate1;
public LapLabService() {
}
public void getLapLab() {
new File("/home/iwankasan/Documents/lap_lab/19057181.pdf");
FileInputStream fis = null;
try {
String path = "/home/iwankasan/Documents/lap_lab/19057181.pdf";
PdfReader pdfReader = new PdfReader(path);
int pages = pdfReader.getNumberOfPages();
for (int i = 1; i <= pages; ++i) {
String pageContent = PdfTextExtractor.getTextFromPage(pdfReader, i);
System.out.println("Content on page " + i + ": " + pageContent);
}
pdfReader.close();
} catch (Exception var8) {
LOG.error("Exception at LapLabService");
LOG.error(ReportingDao.class, var8);
}
}
}

View File

@ -14,15 +14,15 @@ public class ReportingService {
public ReportingService() { public ReportingService() {
} }
public JasperPrint exportPdfLabelGizi(String noregistrasi) throws Exception { public JasperPrint exportPdfLabelGizi(String noregistrasi) {
return this.reportingDao.exportPdfLabelGizi(noregistrasi); return this.reportingDao.exportPdfLabelGizi(noregistrasi);
} }
public JasperPrint exportPdfPermintaanMakanan(Integer idRu, String tglAwal, String tglAkhir) throws Exception { public JasperPrint exportPdfPermintaanMakanan(Integer idRu, String tglAwal, String tglAkhir) {
return this.reportingDao.exportPdfPermintaanMakanan(idRu, tglAwal, tglAkhir); return this.reportingDao.exportPdfPermintaanMakanan(idRu, tglAwal, tglAkhir);
} }
public JasperPrint exportPdfRekapMakanan(Integer idRu, String tglAwal, String tglAkhir) throws Exception { public JasperPrint exportPdfRekapMakanan(Integer idRu, String tglAwal, String tglAkhir) {
return this.reportingDao.exportPdfRekapMakanan(idRu, tglAwal, tglAkhir); return this.reportingDao.exportPdfRekapMakanan(idRu, tglAwal, tglAkhir);
} }
@ -30,63 +30,65 @@ public class ReportingService {
this.reportingDao.printReport(jasperPrint, selectedPrinter); this.reportingDao.printReport(jasperPrint, selectedPrinter);
} }
public JasperPrint printReportKartuPasien(String nocm) throws Exception { public JasperPrint printReportKartuPasien(String nocm) {
return this.reportingDao.exportPdfKartuPasien(nocm); return this.reportingDao.exportPdfKartuPasien(nocm);
} }
public JasperPrint printReportLapBedah(String noregis) throws Exception { public JasperPrint printReportLapBedah(String noregis) {
return this.reportingDao.exportPdfLapBedah(noregis); return this.reportingDao.exportPdfLapBedah(noregis);
} }
public JasperPrint printReportKonsul(String noregis) throws Exception { public JasperPrint printReportKonsul(String noregis) {
return this.reportingDao.exportPdfKonsul(noregis); return this.reportingDao.exportPdfKonsul(noregis);
} }
public JasperPrint printReportUpk(String nores) throws Exception { public JasperPrint printReportUpk(String nores) {
return this.reportingDao.exportPdfUpk(nores); return this.reportingDao.exportPdfUpk(nores);
} }
public JasperPrint printReportVerifikasiTagihan(String noverifikasifk) throws Exception { public JasperPrint printReportVerifikasiTagihan(String noverifikasifk) {
return this.reportingDao.exportPdfVerifikasiTagihan(noverifikasifk); return this.reportingDao.exportPdfVerifikasiTagihan(noverifikasifk);
} }
public JasperPrint printPdfLapRekapHarianByDept(int deptId, String tglAwal, String tglAkhir) throws Exception { public JasperPrint printPdfLapRekapHarianByDept(int deptId, String tglAwal, String tglAkhir) {
return this.reportingDao.exportPdfLapRekapHarianByDept(deptId, tglAwal, tglAkhir); return this.reportingDao.exportPdfLapRekapHarianByDept(deptId, tglAwal, tglAkhir);
} }
public JasperPrint printPdfLapRekapHarianByRuanganId(int deptId, int ruangId, String tglAwal, String tglAkhir) throws Exception { public JasperPrint printPdfLapRekapHarianByRuanganId(int deptId, int ruangId, String tglAwal, String tglAkhir) {
return this.reportingDao.exportPdfLapRekapHarianByRuanganId(deptId, ruangId, tglAwal, tglAkhir); return this.reportingDao.exportPdfLapRekapHarianByRuanganId(deptId, ruangId, tglAwal, tglAkhir);
} }
public JasperPrint printPdfPengkajianAwalByNoRes(String nores) throws Exception { public JasperPrint printPdfPengkajianAwalByNoRes(String nores) {
return this.reportingDao.exportPdfPengkajianAwalByNoRes(nores); return this.reportingDao.exportPdfPengkajianAwalByNoRes(nores);
} }
public JasperPrint printPdfRekapPenjamin(String tglAwal, String tglAkhir, int idDept, int kelompokPasien) throws Exception { public JasperPrint printPdfRekapPenjamin(String tglAwal, String tglAkhir, int idDept, int kelompokPasien) {
return this.reportingDao.exportPdfRekapPenjamin(tglAwal, tglAkhir, idDept, kelompokPasien); return this.reportingDao.exportPdfRekapPenjamin(tglAwal, tglAkhir, idDept, kelompokPasien);
} }
public JasperPrint printPdfRekapPenjaminByInstitusiPasien(String tglAwal, String tglAkhir, int idDept, int kelompokPasien, int institusiPasien) throws Exception { public JasperPrint printPdfRekapPenjaminByInstitusiPasien(
return this.reportingDao.exportPdfRekapPenjaminByInstitusiPasien(tglAwal, tglAkhir, idDept, kelompokPasien, institusiPasien); String tglAwal, String tglAkhir, int idDept, int kelompokPasien, int institusiPasien) {
return this.reportingDao
.exportPdfRekapPenjaminByInstitusiPasien(tglAwal, tglAkhir, idDept, kelompokPasien, institusiPasien);
} }
public JasperPrint printPdfRekapPenjaminByRanap(String tglAwal, String tglAkhir, int idDept, int kelompokPasien) throws Exception { public JasperPrint printPdfRekapPenjaminByRanap(String tglAwal, String tglAkhir, int idDept, int kelompokPasien) {
return this.reportingDao.exportPdfRekapPenjaminByRanap(tglAwal, tglAkhir, idDept, kelompokPasien); return this.reportingDao.exportPdfRekapPenjaminByRanap(tglAwal, tglAkhir, idDept, kelompokPasien);
} }
public JasperPrint printPdfPermintaanMakanan(int idRu, String tglAwal, String tglAkhir) throws Exception { public JasperPrint printPdfPermintaanMakanan(int idRu, String tglAwal, String tglAkhir) {
return this.reportingDao.exportPdfPermintaanMakanan(idRu, tglAwal, tglAkhir); return this.reportingDao.exportPdfPermintaanMakanan(idRu, tglAwal, tglAkhir);
} }
public JasperPrint printPdfRekapMakanan(int idRu, String tglAwal, String tglAkhir) throws Exception { public JasperPrint printPdfRekapMakanan(int idRu, String tglAwal, String tglAkhir) {
return this.reportingDao.exportPdfRekapMakanan(idRu, tglAwal, tglAkhir); return this.reportingDao.exportPdfRekapMakanan(idRu, tglAwal, tglAkhir);
} }
public JasperPrint exportPdfGelangPasien(String noregistrasi) throws Exception { public JasperPrint exportPdfGelangPasien(String noregistrasi) {
return this.reportingDao.exportPdfGelangPasien(noregistrasi); return this.reportingDao.exportPdfGelangPasien(noregistrasi);
} }
public JasperPrint exportPdfResumeMedis(String norec) throws Exception { public JasperPrint exportPdfResumeMedis(String norec) {
return this.reportingDao.exportPdfResumeMedis(norec); return this.reportingDao.exportPdfResumeMedis(norec);
} }
} }

View File

@ -2,21 +2,10 @@ package com.reporting.service;
import com.reporting.Utility.Age; import com.reporting.Utility.Age;
import com.reporting.Utility.AgeCalculator; import com.reporting.Utility.AgeCalculator;
import com.reporting.Utility.DatabaseUtility;
import com.reporting.dao.ReportingDao; import com.reporting.dao.ReportingDao;
import com.reporting.model.Pasien; import com.reporting.model.Pasien;
import com.reporting.model.Resep; import com.reporting.model.Resep;
import com.reporting.model.ResepDetail; import com.reporting.model.ResepDetail;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.sql.DataSource;
import net.sf.jasperreports.engine.JasperCompileManager; import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager; import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JasperPrint;
@ -28,12 +17,23 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service("resepService") @Service("resepService")
public class ResepService { public class ResepService {
static final Log LOG = LogFactory.getLog(ResepService.class); static final Log LOG = LogFactory.getLog(ResepService.class);
@Autowired @Autowired
@Qualifier("db") @Qualifier("db")
private DataSource ds1; private DataSource ds1;
@Qualifier("jdbcTemplate") @Qualifier("jdbcTemplate")
@Autowired @Autowired
private JdbcTemplate jdbcTemplate1; private JdbcTemplate jdbcTemplate1;
@ -42,20 +42,25 @@ public class ResepService {
} }
public Pasien getPasien(String strukOrder) throws Exception { public Pasien getPasien(String strukOrder) throws Exception {
Pasien pasien = null; String SQL = "select st.norec,st.objectpegawaiorderfk as dokter," +
Connection conn = null; "to_char(st.tglorder,'dd-MM-yyyy') as tglorder,st.noregistrasifk,pg.namalengkap,ru.namaruangan," +
PreparedStatement pstmt = null; "pd.noregistrasi,pd.tglregistrasi,ps.nocm,ps.namapasien," +
ResultSet rs = null; "to_char(ps.tgllahir,'dd-MM-yyyy') as tgllahir,st.noorder,date(ps.tgllahir) as umurPasien," +
String SQL = "select st.norec,st.objectpegawaiorderfk as dokter,to_char(st.tglorder,'dd-MM-yyyy') as tglorder,st.noregistrasifk, \tpg.namalengkap,ru.namaruangan,pd.noregistrasi,pd.tglregistrasi,ps.nocm,ps.namapasien, to_char(ps.tgllahir,'dd-MM-yyyy') as tgllahir,st.noorder,date(ps.tgllahir) as umurPasien, \tst.masalah as riwayatAlergi, st.diagnosis as beratBadan\tfrom strukorder_t st \tleft join pasien_m ps on st.nocmfk=ps.id \tleft join pasiendaftar_t pd on pd.norec=st.noregistrasifk \tleft join pegawai_m pg on pg.id=st.objectpegawaiorderfk \tleft join ruangan_m ru on ru.id=st.objectruanganfk \twhere st.statusenabled=true and st.keteranganorder='Order Farmasi' and st.norec='" + strukOrder + "'"; "st.masalah as riwayatAlergi, st.diagnosis as beratBadan " +
"from strukorder_t st " +
try { "left join pasien_m ps on st.nocmfk=ps.id " +
"left join pasiendaftar_t pd on pd.norec=st.noregistrasifk " +
"left join pegawai_m pg on pg.id=st.objectpegawaiorderfk " +
"left join ruangan_m ru on ru.id=st.objectruanganfk " +
"where st.statusenabled=true " +
"and st.keteranganorder='Order Farmasi' " +
"and st.norec='" + strukOrder + "'";
this.ds1 = this.jdbcTemplate1.getDataSource(); this.ds1 = this.jdbcTemplate1.getDataSource();
conn = this.ds1.getConnection(); try (Connection conn = this.ds1.getConnection();
pstmt = conn.prepareStatement(SQL); PreparedStatement pstmt = conn.prepareStatement(SQL);
rs = pstmt.executeQuery(); ResultSet rs = pstmt.executeQuery()) {
Pasien pasien = new Pasien();
while (rs.next()) { while (rs.next()) {
pasien = new Pasien();
pasien.setNoRegistrasi(rs.getString("noregistrasi")); pasien.setNoRegistrasi(rs.getString("noregistrasi"));
pasien.setNamaDokter(rs.getString("namalengkap")); pasien.setNamaDokter(rs.getString("namalengkap"));
pasien.setTglOrder(rs.getString("tglorder")); pasien.setTglOrder(rs.getString("tglorder"));
@ -64,7 +69,7 @@ public class ResepService {
pasien.setNamaRuangan(rs.getString("namaruangan")); pasien.setNamaRuangan(rs.getString("namaruangan"));
pasien.setNoCm(rs.getString("nocm")); pasien.setNoCm(rs.getString("nocm"));
Age age = AgeCalculator.calculateAge(rs.getDate("umurPasien")); Age age = AgeCalculator.calculateAge(rs.getDate("umurPasien"));
String umurPasien = Integer.toString(age.getYears()) + " tahun " + Integer.toString(age.getMonths()) + " bulan " + Integer.toString(age.getDays()) + " hari"; String umurPasien = age.getYears() + " tahun " + age.getMonths() + " bulan " + age.getDays() + " hari";
pasien.setUmurPasien(umurPasien); pasien.setUmurPasien(umurPasien);
if (rs.getString("riwayatAlergi") != null) { if (rs.getString("riwayatAlergi") != null) {
pasien.setRiwayatAlergi(rs.getString("riwayatAlergi")); pasien.setRiwayatAlergi(rs.getString("riwayatAlergi"));
@ -76,107 +81,66 @@ public class ResepService {
pasien.setUmurPasien(umurPasien); pasien.setUmurPasien(umurPasien);
pasien.setListResep(this.getResepHeader(strukOrder)); pasien.setListResep(this.getResepHeader(strukOrder));
} }
return pasien;
} catch (Exception var16) { } catch (Exception var16) {
LOG.error("Exception at getPasien()", var16); LOG.error("Exception at getPasien()", var16);
throw var16; throw var16;
} finally {
try {
DatabaseUtility.clear(conn, pstmt, rs);
} catch (Exception var15) {
} }
}
return pasien;
} }
public List<Resep> getResepHeader(String strukOrder) throws Exception { public List<Resep> getResepHeader(String strukOrder) throws Exception {
List<Resep> list = null; String SQL_HEADER = "select rd.racikanke as resep,rd.strukorderfk as strukorder " +
Resep resep = null; "from t_resep_dokter rd " +
Connection conn = null; "where rd.strukorderfk='" + strukOrder + "' " +
PreparedStatement pstmt = null; "and rd.statusenabled='true' " +
ResultSet rs = null; "group by rd.racikanke,rd.strukorderfk " +
String SQL_HEADER = "select rd.racikanke as resep,rd.strukorderfk as strukorder from \t t_resep_dokter rd where rd.strukorderfk='" + strukOrder + "' \t and rd.statusenabled='true' group by rd.racikanke,rd.strukorderfk order by rd.racikanke asc"; "order by rd.racikanke asc";
try {
list = new ArrayList();
this.ds1 = this.jdbcTemplate1.getDataSource(); this.ds1 = this.jdbcTemplate1.getDataSource();
conn = this.ds1.getConnection(); try (Connection conn = this.ds1.getConnection();
pstmt = conn.prepareStatement(SQL_HEADER); PreparedStatement pstmt = conn.prepareStatement(SQL_HEADER);
rs = pstmt.executeQuery(); ResultSet rs = pstmt.executeQuery()) {
List<Resep> list = new ArrayList<>();
while (rs.next()) { while (rs.next()) {
resep = new Resep(); Resep resep = new Resep();
resep.setResep(rs.getString("resep")); resep.setResep(rs.getString("resep"));
resep.setResepDetail(this.getResepDetail(strukOrder, rs.getString("resep"))); resep.setResepDetail(this.getResepDetail(strukOrder, rs.getString("resep")));
if (resep != null) {
list.add(resep); list.add(resep);
} }
} return list;
} catch (Exception var16) { } catch (Exception var16) {
LOG.error("Exception at getResepDetail()", var16); LOG.error("Exception at getResepDetail()", var16);
throw var16; throw var16;
} finally {
resep = null;
try {
DatabaseUtility.clear(conn, pstmt, rs);
} catch (Exception var15) {
} }
}
return list;
} }
private List<ResepDetail> getResepDetail(String strukOrder, String resepke) throws Exception { private List<ResepDetail> getResepDetail(String strukOrder, String resepke) throws Exception {
List<ResepDetail> list = null; String SQL_ITEM = "select rd.objectprodukfk,rd.qtyproduk,rd.satuanview,rd.keteranganpakai," +
ResepDetail detail = null; "rd.keteranganlainnya,rd.namaobat " +
Connection conn = null; "from t_resep_dokter rd " +
PreparedStatement pstmt = null; "where rd.strukorderfk='" + strukOrder + "' " +
ResultSet rs = null; "and rd.racikanke='" + resepke + "'";
String SQL_ITEM = "select rd.objectprodukfk,rd.qtyproduk,rd.satuanview, rd.keteranganpakai,rd.keteranganlainnya,rd.namaobat from t_resep_dokter rd where rd.strukorderfk='" + strukOrder + "' and rd.racikanke='" + resepke + "'";
try {
list = new ArrayList();
this.ds1 = this.jdbcTemplate1.getDataSource(); this.ds1 = this.jdbcTemplate1.getDataSource();
conn = this.ds1.getConnection(); try (Connection conn = this.ds1.getConnection();
pstmt = conn.prepareStatement(SQL_ITEM); PreparedStatement pstmt = conn.prepareStatement(SQL_ITEM);
rs = pstmt.executeQuery(); ResultSet rs = pstmt.executeQuery()) {
List<ResepDetail> list = new ArrayList<>();
while (rs.next()) { while (rs.next()) {
detail = new ResepDetail(); ResepDetail detail = new ResepDetail();
detail.setNamaObat(rs.getString("namaobat")); detail.setNamaObat(rs.getString("namaobat"));
detail.setKeteranganLainnya(rs.getString("keteranganlainnya")); detail.setKeteranganLainnya(rs.getString("keteranganlainnya"));
detail.setKeteranganPakai(rs.getString("keteranganpakai")); detail.setKeteranganPakai(rs.getString("keteranganpakai"));
detail.setQtyProduk(rs.getString("qtyproduk")); detail.setQtyProduk(rs.getString("qtyproduk"));
if (detail != null) {
list.add(detail); list.add(detail);
} }
} return list;
} catch (Exception var17) { } catch (Exception var17) {
LOG.error("Exception at getResepDetail()", var17); LOG.error("Exception at getResepDetail()", var17);
throw var17; throw var17;
} finally { }
detail = null;
try {
DatabaseUtility.clear(conn, pstmt, rs);
} catch (Exception var16) {
} }
} public JasperPrint exportPdfResepPasien(String strukOrder) {
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
return list;
}
public JasperPrint exportPdfResepPasien(String strukOrder) throws Exception {
JasperPrint print = null;
Connection conn = null;
Map<String, Object> parameters = null;
try {
conn = this.jdbcTemplate1.getDataSource().getConnection();
String path = "/usr/share/app/reporting/rpt_eresep1.jrxml"; String path = "/usr/share/app/reporting/rpt_eresep1.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
String namaPasien = this.getPasien(strukOrder).getNamaPasien(); String namaPasien = this.getPasien(strukOrder).getNamaPasien();
@ -189,7 +153,7 @@ public class ResepService {
String noCM = this.getPasien(strukOrder).getNoCm(); String noCM = this.getPasien(strukOrder).getNoCm();
String alergi = this.getPasien(strukOrder).getRiwayatAlergi(); String alergi = this.getPasien(strukOrder).getRiwayatAlergi();
String beratBadan = this.getPasien(strukOrder).getBeratBadan(); String beratBadan = this.getPasien(strukOrder).getBeratBadan();
parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("strukOrder", strukOrder); parameters.put("strukOrder", strukOrder);
parameters.put("noRegistrasi", noRegistrasi); parameters.put("noRegistrasi", noRegistrasi);
parameters.put("namaPasien", namaPasien); parameters.put("namaPasien", namaPasien);
@ -201,18 +165,11 @@ public class ResepService {
parameters.put("noCM", noCM); parameters.put("noCM", noCM);
parameters.put("alergi", alergi); parameters.put("alergi", alergi);
parameters.put("beratBadan", beratBadan); parameters.put("beratBadan", beratBadan);
print = JasperFillManager.fillReport(jasperReport, parameters, conn); return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var25) { } catch (Exception var25) {
LOG.error("Exception at exportPdfResepPasien"); LOG.error("Exception at exportPdfResepPasien");
LOG.error(ReportingDao.class, var25); LOG.error(ReportingDao.class, var25);
} finally {
try {
conn.close();
} catch (Exception var24) {
} }
return null;
}
return print;
} }
} }

View File

@ -1,18 +1,7 @@
package com.reporting.service; package com.reporting.service;
import com.reporting.Utility.DatabaseUtility;
import com.reporting.model.VerifikasiTagihanSupplier; import com.reporting.model.VerifikasiTagihanSupplier;
import com.reporting.model.VerifikasiTagihanSupplier2; import com.reporting.model.VerifikasiTagihanSupplier2;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
import javax.sql.DataSource;
import net.sf.jasperreports.engine.JasperCompileManager; import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager; import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JasperPrint;
@ -25,12 +14,24 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.sql.DataSource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
@Service("verifikasiTagihanSupplierServices") @Service("verifikasiTagihanSupplierServices")
public class VerifikasiTagihanSupplierServices { public class VerifikasiTagihanSupplierServices {
static final Log LOG = LogFactory.getLog(VerifikasiTagihanSupplierServices.class); static final Log LOG = LogFactory.getLog(VerifikasiTagihanSupplierServices.class);
@Autowired @Autowired
@Qualifier("db") @Qualifier("db")
private DataSource ds1; private DataSource ds1;
@Qualifier("jdbcTemplate") @Qualifier("jdbcTemplate")
@Autowired @Autowired
private JdbcTemplate jdbcTemplate1; private JdbcTemplate jdbcTemplate1;
@ -39,20 +40,19 @@ public class VerifikasiTagihanSupplierServices {
} }
public static String terbilang(BigDecimal value) { public static String terbilang(BigDecimal value) {
value = value.setScale(0, 6); value = value.setScale(0, RoundingMode.HALF_EVEN);
String strValue = value.toString(); String strValue = value.toString();
int lenValue = strValue.length(); int lenValue = strValue.length();
int x = 0; int x = 0;
int y = 0; int y = 0;
String bil1 = ""; String bil1 = "";
String bil2 = ""; String bil2;
String urai = ""; StringBuilder urai = new StringBuilder();
while (x < lenValue) { while (x < lenValue) {
int z; int z;
int strTot; int strTot;
++x; ++x;
strTot = Integer.valueOf(strValue.substring(x - 1, x)); strTot = Integer.parseInt(strValue.substring(x - 1, x));
y += strTot; y += strTot;
z = lenValue - x + 1; z = lenValue - x + 1;
label94: label94:
@ -67,16 +67,13 @@ public class VerifikasiTagihanSupplierServices {
} }
break; break;
} }
if (z != 2 && z != 5 && z != 8 && z != 11 && z != 14) { if (z != 2 && z != 5 && z != 8 && z != 11 && z != 14) {
bil1 = "Se"; bil1 = "Se";
break; break;
} }
++x; ++x;
int newStrTot = Integer.valueOf(strValue.substring(x - 1, x)); int newStrTot = Integer.parseInt(strValue.substring(x - 1, x));
z = lenValue - x + 1; z = lenValue - x + 1;
bil2 = "";
switch (newStrTot) { switch (newStrTot) {
case 0: case 0:
bil1 = "Sepuluh "; bil1 = "Sepuluh ";
@ -111,7 +108,6 @@ public class VerifikasiTagihanSupplierServices {
break label94; break label94;
} }
} }
bil1 = "Satu "; bil1 = "Satu ";
break; break;
case 2: case 2:
@ -141,7 +137,6 @@ public class VerifikasiTagihanSupplierServices {
default: default:
bil1 = ""; bil1 = "";
} }
if (strTot > 0) { if (strTot > 0) {
if (z != 2 && z != 5 && z != 8 && z != 11 && z != 14) { if (z != 2 && z != 5 && z != 8 && z != 11 && z != 14) {
if (z != 3 && z != 6 && z != 9 && z != 12 && z != 15) { if (z != 3 && z != 6 && z != 9 && z != 12 && z != 15) {
@ -155,7 +150,6 @@ public class VerifikasiTagihanSupplierServices {
} else { } else {
bil2 = ""; bil2 = "";
} }
if (y > 0) { if (y > 0) {
switch (z) { switch (z) {
case 4: case 4:
@ -182,20 +176,19 @@ public class VerifikasiTagihanSupplierServices {
y = 0; y = 0;
} }
} }
if (bil1.equals("Se")) { if (bil1.equals("Se")) {
String pre = bil2.substring(0, 1); String pre = bil2.substring(0, 1);
urai = urai + bil1 + bil2.replace(pre, pre.toLowerCase()); urai.append(bil1).append(bil2.replace(pre, pre.toLowerCase()));
} else { } else {
urai = urai + bil1 + bil2; urai.append(bil1).append(bil2);
} }
} }
return urai.toString();
return urai;
} }
public String bilangx(double angka) { public String bilangx(double angka) {
String[] nomina = new String[]{"", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas"}; String[] nomina = new String[]{"", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan",
"sembilan", "sepuluh", "sebelas"};
if (angka < 12.0) { if (angka < 12.0) {
return nomina[(int) angka]; return nomina[(int) angka];
} else if (angka >= 12.0 && angka <= 19.0) { } else if (angka >= 12.0 && angka <= 19.0) {
@ -209,27 +202,70 @@ public class VerifikasiTagihanSupplierServices {
} else if (angka >= 1000.0 && angka <= 1999.0) { } else if (angka >= 1000.0 && angka <= 1999.0) {
return "seribu " + this.bilangx(angka % 1000.0); return "seribu " + this.bilangx(angka % 1000.0);
} else if (angka >= 2000.0 && angka <= 999999.0) { } else if (angka >= 2000.0 && angka <= 999999.0) {
return this.bilangx((double) ((int) angka / 1000)) + " ribu " + this.bilangx(angka % 1000.0); return this.bilangx((double) (int) angka / 1000) + " ribu " + this.bilangx(angka % 1000.0);
} else { } else {
return angka >= 1000000.0 && angka <= 9.99999999E8 ? this.bilangx((double) ((int) angka / 1000000)) + " juta " + this.bilangx(angka % 1000000.0) : ""; return angka >= 1000000.0 && angka <= 9.99999999E8 ? this.bilangx((double) (int) angka / 1000000) +
" juta " + this.bilangx(angka % 1000000.0) : "";
} }
} }
public VerifikasiTagihanSupplier getVerifikasiTagihanSupplier(String noverifikasifk) throws Exception { public VerifikasiTagihanSupplier getVerifikasiTagihanSupplier(String noverifikasifk) throws Exception {
VerifikasiTagihanSupplier verif = null; String SQL = "select * from(" +
Connection conn = null; "select xx.norec,xx.noverifikasifk,xx.tglstruk,xx.tgldokumen,xx.tgljatuhtempo,xx.rknid," +
PreparedStatement pstmt = null; "xx.namarekanan,xx.asalproduk,xx.nostruk,xx.nodokumen,xx.nopo,xx.keperluan,xx.nosbk," +
ResultSet rs = null; "(CASE WHEN xx.noverifikasi is null THEN '-' ELSE xx.noverifikasi END) as noverifikasi," +
String SQL = "select * from(select xx.norec,xx.noverifikasifk,xx.tglstruk,xx.tgldokumen,xx.tgljatuhtempo,xx.rknid,xx.namarekanan,xx.asalproduk,xx.nostruk,xx.nodokumen,xx.nopo,xx.keperluan,xx.nosbk, \t\t\t\t(CASE WHEN xx.noverifikasi is null THEN '-' ELSE xx.noverifikasi END) as noverifikasi,xx.total,xx.totalppn,xx.totaldiskon,xx.subtotal,xx.sisautang, (CASE WHEN xx.noverifikasi is null THEN '-' ELSE xx.noverifikasi END) as noverifikasi, (case when xx.noorder is null then '-' else xx.noorder end) as nospk, (CASE WHEN xx.totalbayar = 0 THEN 'BELUM LUNAS' WHEN xx.totalbayar <> 0 and xx.totalbayar > 0 and xx.sisautang <> 0 THEN 'KREDIT' WHEN xx.totalbayar = xx.subtotal OR xx.sisautang = 0 THEN 'LUNAS' ELSE '' END) as statusbayar, (Case when xx.noverifikasi is null THEN 'BLM VERIFIKASI' WHEN xx.noverifikasi is not null THEN 'VERIFIKASI' ELSE '' END) as status, (Case when xx.confirmfk is null THEN 'BLM CONFIRM' ELSE 'CONFIRM' END) as statusconfirmkabag, (Case when xx.confirm1fk is null THEN 'BLM CONFIRM' ELSE 'CONFIRM' END) as statusconfirmanggaran, xx.noorderintern,xx.tglorder,xx.confirmfk,xx.confirm1fk,xx.keteranganlainnya as kodeanggaran,xx.kode_dana,xx.kode_dana,xx.ba,xx.sppb,xx.faktur,xx.pph FROM(SELECT x.norec,x.tglstruk,x.asalproduk,x.tgldokumen,x.tgljatuhtempo,x.rknid,x.namarekanan,x.nostruk,x.nodokumen,x.nopo, x.totalppn as totalppn, x.totaldiskon as totaldiskon, x.total as total, (x.total+x.totalppn-x.totaldiskon) as subtotal, x.totaldibayar as totalbayar, (case when x.totalsisahutang is null then (x.total+x.totalppn-x.totaldiskon) ELSE \t\t\t\t x.totalsisahutang end) as sisautang, x.nosbk,x.noverifikasi,x.noverifikasifk,x.confirmfk,x.confirm1fk,x.noorderintern,x.noorder,x.tglorder,x.keteranganlainnya,x.keperluan,x.kode_dana,x.ba,x.sppb,x.faktur,x.pph FROM (SELECT sp.norec,sp.tglstruk,sp.tglfaktur as tgldokumen,sp.nostruk,sp.nosppb as nopo,sp.nofaktur as nodokumen, SUM(spd.qtyproduk*spd.hargasatuan) as total, asp.asalproduk as asalproduk, SUM(spd.qtyproduk*spd.hargappn) as totalppn,SUM(spd.qtyproduk*spd.hargadiscount) as totaldiskon, CASE WHEN sbk.totaldibayar is null then 0 else sbk.totaldibayar end as totaldibayar, CASE WHEN sbk.totalsudahdibayar is null then 0 else sbk.totalsudahdibayar end as totalsudahdibayar,\t sbk.nosbk,sv.noverifikasi,sv.norec as noverifikasifk,sp.tgljatuhtempo,rkn.id as rknid,rkn.namarekanan,sbk.totalsisahutang, sv.confirmfk,sv.confirm1fk,so.noorderintern,so.noorder,so.tglorder,sv.keteranganlainnya,sv.keperluan,pg.kode_dana,sv.ba,sv.sppb,sv.faktur,sv.pph from strukpelayanan_t as sp left join strukorder_t as so on so.norec = sp.noorderfk inner join strukpelayanandetail_t as spd on spd.nostrukfk = sp.norec \t\t\t\t LEFT JOIN asalproduk_m as asp ON asp.id = spd.objectasalprodukfk left join rekanan_m as rkn on rkn.id = sp.objectrekananfk left join strukbuktipengeluaran_t as sbk on sbk.norec = sp.nosbklastfk left join strukverifikasi_t as sv on sv.norec = spd.noverifikasifk left join ruangan_m as ru on ru.id = sv.objectruanganfk \t\t\t\t left join penggunaan_anggaran_t as pg on pg.kode_anggaran=sv.keteranganlainnya\t where sp.objectkelompoktransaksifk=35 and sv.norec='" + noverifikasifk + "' GROUP BY sp.norec,sp.tglstruk,sp.tglfaktur,sp.nostruk,sp.nosppb,sp.nofaktur,sp.nosbklastfk,sbk.totaldibayar,pg.kode_dana, sbk.totalsudahdibayar,sp.tgljatuhtempo,rkn.id,rkn.namarekanan,sbk.nosbk,sv.noverifikasi,sv.norec,sbk.totalsisahutang,so.noorderintern,so.noorder,so.tglorder,asp.asalproduk) as x) as xx) as su"; "xx.total,xx.totalppn,xx.totaldiskon,xx.subtotal,xx.sisautang," +
"(CASE WHEN xx.noverifikasi is null THEN '-' ELSE xx.noverifikasi END) as noverifikasi," +
try { "(case when xx.noorder is null then '-' else xx.noorder end) as nospk," +
"(CASE WHEN xx.totalbayar = 0 THEN 'BELUM LUNAS' WHEN xx.totalbayar <> 0 and xx.totalbayar > 0 " +
"and xx.sisautang <> 0 THEN 'KREDIT' " +
"WHEN xx.totalbayar = xx.subtotal OR xx.sisautang = 0 THEN 'LUNAS' " +
"ELSE '' END) as statusbayar," +
"(Case when xx.noverifikasi is null THEN 'BLM VERIFIKASI' " +
"WHEN xx.noverifikasi is not null THEN 'VERIFIKASI' ELSE '' END) as status," +
"(Case when xx.confirmfk is null THEN 'BLM CONFIRM' ELSE 'CONFIRM' END) as statusconfirmkabag," +
"(Case when xx.confirm1fk is null THEN 'BLM CONFIRM' ELSE 'CONFIRM' END) as statusconfirmanggaran," +
"xx.noorderintern,xx.tglorder,xx.confirmfk,xx.confirm1fk,xx.keteranganlainnya as kodeanggaran," +
"xx.kode_dana,xx.kode_dana,xx.ba,xx.sppb,xx.faktur,xx.pph " +
"FROM(" +
"SELECT x.norec,x.tglstruk,x.asalproduk,x.tgldokumen,x.tgljatuhtempo,x.rknid,x.namarekanan,x.nostruk," +
"x.nodokumen,x.nopo,x.totalppn as totalppn,x.totaldiskon as totaldiskon,x.total as total," +
"(x.total+x.totalppn-x.totaldiskon) as subtotal,x.totaldibayar as totalbayar," +
"(case when x.totalsisahutang is null then (x.total+x.totalppn-x.totaldiskon) " +
"ELSE x.totalsisahutang end) as sisautang,x.nosbk,x.noverifikasi,x.noverifikasifk,x.confirmfk," +
"x.confirm1fk,x.noorderintern,x.noorder,x.tglorder,x.keteranganlainnya,x.keperluan,x.kode_dana," +
"x.ba,x.sppb,x.faktur,x.pph " +
"FROM (SELECT sp.norec,sp.tglstruk,sp.tglfaktur as tgldokumen,sp.nostruk,sp.nosppb as nopo," +
"sp.nofaktur as nodokumen,SUM(spd.qtyproduk*spd.hargasatuan) as total, asp.asalproduk as asalproduk," +
"SUM(spd.qtyproduk*spd.hargappn) as totalppn,SUM(spd.qtyproduk*spd.hargadiscount) as totaldiskon," +
"CASE WHEN sbk.totaldibayar is null then 0 else sbk.totaldibayar end as totaldibayar," +
"CASE WHEN sbk.totalsudahdibayar is null then 0 else sbk.totalsudahdibayar end as totalsudahdibayar," +
"sbk.nosbk,sv.noverifikasi,sv.norec as noverifikasifk,sp.tgljatuhtempo," +
"rkn.id as rknid,rkn.namarekanan,sbk.totalsisahutang,sv.confirmfk,sv.confirm1fk,so.noorderintern," +
"so.noorder,so.tglorder,sv.keteranganlainnya,sv.keperluan,pg.kode_dana,sv.ba,sv.sppb,sv.faktur,sv.pph" +
"from strukpelayanan_t as sp " +
"left join strukorder_t as so on so.norec = sp.noorderfk " +
"inner join strukpelayanandetail_t as spd on spd.nostrukfk = sp.norec " +
"LEFT JOIN asalproduk_m as asp ON asp.id = spd.objectasalprodukfk " +
"left join rekanan_m as rkn on rkn.id = sp.objectrekananfk " +
"left join strukbuktipengeluaran_t as sbk on sbk.norec = sp.nosbklastfk " +
"left join strukverifikasi_t as sv on sv.norec = spd.noverifikasifk " +
"left join ruangan_m as ru on ru.id = sv.objectruanganfk " +
"left join penggunaan_anggaran_t as pg on pg.kode_anggaran=sv.keteranganlainnya " +
"where sp.objectkelompoktransaksifk=35 and sv.norec='" + noverifikasifk + "' " +
"GROUP BY sp.norec,sp.tglstruk,sp.tglfaktur,sp.nostruk,sp.nosppb,sp.nofaktur,sp.nosbklastfk," +
"sbk.totaldibayar,pg.kode_dana,sbk.totalsudahdibayar,sp.tgljatuhtempo,rkn.id,rkn.namarekanan," +
"sbk.nosbk,sv.noverifikasi,sv.norec,sbk.totalsisahutang," +
"so.noorderintern,so.noorder,so.tglorder,asp.asalproduk) " +
"as x) " +
"as xx) " +
"as su";
this.ds1 = this.jdbcTemplate1.getDataSource(); this.ds1 = this.jdbcTemplate1.getDataSource();
conn = this.ds1.getConnection(); try (Connection conn = this.ds1.getConnection();
pstmt = conn.prepareStatement(SQL); PreparedStatement pstmt = conn.prepareStatement(SQL);
rs = pstmt.executeQuery(); ResultSet rs = pstmt.executeQuery()) {
VerifikasiTagihanSupplier verif = new VerifikasiTagihanSupplier();
if (rs.next()) { if (rs.next()) {
verif = null;
verif = new VerifikasiTagihanSupplier();
verif.setNoverifikasifk(rs.getString("noverifikasifk")); verif.setNoverifikasifk(rs.getString("noverifikasifk"));
verif.setNoSpk(rs.getString("nospk")); verif.setNoSpk(rs.getString("nospk"));
verif.setKodeAnggaran(rs.getString("kodeanggaran")); verif.setKodeAnggaran(rs.getString("kodeanggaran"));
@ -243,38 +279,32 @@ public class VerifikasiTagihanSupplierServices {
verif.setSppb(rs.getString("sppb")); verif.setSppb(rs.getString("sppb"));
verif.setFaktur(rs.getString("faktur")); verif.setFaktur(rs.getString("faktur"));
verif.setPph(rs.getDouble("pph")); verif.setPph(rs.getDouble("pph"));
verif.setTerbilang(terbilang(new BigDecimal(rs.getDouble("subtotal"))).toUpperCase() + "RUPIAH"); verif.setTerbilang(terbilang(BigDecimal.valueOf(rs.getDouble("subtotal")))
.toUpperCase() + "RUPIAH");
} }
return verif;
} catch (Exception var15) { } catch (Exception var15) {
LOG.error("Exception at getVerifikasiTagihanSupplier()"); LOG.error("Exception at getVerifikasiTagihanSupplier()");
LOG.error("VerifikasiTagihanSupplierServices.class", var15); LOG.error("VerifikasiTagihanSupplierServices.class", var15);
throw var15; throw var15;
} finally {
try {
DatabaseUtility.clear(conn, pstmt, rs);
} catch (Exception var14) {
} }
}
return verif;
} }
public VerifikasiTagihanSupplier getVerifikasiPembayaranUmum(String noverifikasifk) throws Exception { public VerifikasiTagihanSupplier getVerifikasiPembayaranUmum(String noverifikasifk) throws Exception {
VerifikasiTagihanSupplier verif = null; String SQL = "select spu.norec,to_char(spu.tgltransaksi,'dd-MM-yyyy') as tglSPK,spu.keperluan," +
Connection conn = null; "spu.totaltagihan,spu.totalbayar,sv.norec as noverifikasifk,sv.tglverifikasi,sv.noverifikasi," +
PreparedStatement pstmt = null; "sv.confirmfk,sv.confirm1fk,sv.keteranganlainnya as kodeanggaran,pg.kode_dana,spu.nospk," +
ResultSet rs = null; "spu.keperluan,spu.namarekanan,spu.dana as asalproduk,sv.ba,sv.sppb,sv.faktur,sv.pph " +
String SQL = "select spu.norec,to_char(spu.tgltransaksi,'dd-MM-yyyy') as tglSPK,spu.keperluan,spu.totaltagihan,spu.totalbayar,\t sv.norec as noverifikasifk,sv.tglverifikasi,sv.noverifikasi,sv.confirmfk,sv.confirm1fk,sv.keteranganlainnya as kodeanggaran,\t pg.kode_dana,spu.nospk,spu.keperluan,spu.namarekanan,spu.dana as asalproduk,sv.ba,sv.sppb,sv.faktur,sv.pph\t from strukpembayaranumum_t as spu \t left join strukverifikasi_t as sv on sv.norec=spu.noverifikasifk left join penggunaan_anggaran_t as pg on pg.kode_anggaran=sv.keteranganlainnya where sv.norec='" + noverifikasifk + "'"; "from strukpembayaranumum_t as spu " +
"left join strukverifikasi_t as sv on sv.norec=spu.noverifikasifk " +
try { "left join penggunaan_anggaran_t as pg on pg.kode_anggaran=sv.keteranganlainnya " +
"where sv.norec='" + noverifikasifk + "'";
this.ds1 = this.jdbcTemplate1.getDataSource(); this.ds1 = this.jdbcTemplate1.getDataSource();
conn = this.ds1.getConnection(); try (Connection conn = this.ds1.getConnection();
pstmt = conn.prepareStatement(SQL); PreparedStatement pstmt = conn.prepareStatement(SQL);
rs = pstmt.executeQuery(); ResultSet rs = pstmt.executeQuery()) {
VerifikasiTagihanSupplier verif = new VerifikasiTagihanSupplier();
if (rs.next()) { if (rs.next()) {
verif = null;
verif = new VerifikasiTagihanSupplier();
verif.setNoverifikasifk(rs.getString("noverifikasifk")); verif.setNoverifikasifk(rs.getString("noverifikasifk"));
verif.setNoSpk(rs.getString("nospk")); verif.setNoSpk(rs.getString("nospk"));
verif.setKodeAnggaran(rs.getString("kodeanggaran")); verif.setKodeAnggaran(rs.getString("kodeanggaran"));
@ -289,182 +319,106 @@ public class VerifikasiTagihanSupplierServices {
verif.setSppb(rs.getString("sppb")); verif.setSppb(rs.getString("sppb"));
verif.setFaktur(rs.getString("faktur")); verif.setFaktur(rs.getString("faktur"));
verif.setPph(rs.getDouble("pph")); verif.setPph(rs.getDouble("pph"));
verif.setTerbilang(terbilang(new BigDecimal(rs.getDouble("totaltagihan"))).toUpperCase() + "RUPIAH"); verif.setTerbilang(terbilang(BigDecimal.valueOf(rs.getDouble("totaltagihan")))
.toUpperCase() + "RUPIAH");
} }
return verif;
} catch (Exception var15) { } catch (Exception var15) {
LOG.error("Exception at getVerifikasiPembayaranUmum()"); LOG.error("Exception at getVerifikasiPembayaranUmum()");
LOG.error("VerifikasiTagihanSupplierServices.class", var15); LOG.error("VerifikasiTagihanSupplierServices.class", var15);
throw var15; throw var15;
} finally { }
}
public JasperPrint generateVerifikasiTagihanPdf(String noverifikasifk) {
try { try {
DatabaseUtility.clear(conn, pstmt, rs); if (noverifikasifk == null)
} catch (Exception var14) { throw new Exception("Cannot find verifikasi");
} Vector<VerifikasiTagihanSupplier2> collection = new Vector<>();
VerifikasiTagihanSupplier verif = this.getVerifikasiTagihanSupplier(noverifikasifk);
} VerifikasiTagihanSupplier2 verif2 = new VerifikasiTagihanSupplier2();
return verif;
}
public JasperPrint generateVerifikasiTagihanPdf(String noverifikasifk) throws Exception {
JasperPrint print = null;
Map<String, Object> parameters = null;
JRBeanCollectionDataSource jrbcds = null;
Vector<VerifikasiTagihanSupplier2> collection = null;
VerifikasiTagihanSupplier verif = null;
VerifikasiTagihanSupplier2 verif2 = null;
try {
try {
if (noverifikasifk == null) {
throw new Exception("Cannot find verifikasi = " + noverifikasifk + ".");
}
collection = null;
collection = new Vector();
verif = null;
verif = this.getVerifikasiTagihanSupplier(noverifikasifk);
verif2 = null;
verif2 = new VerifikasiTagihanSupplier2();
verif2.setNoSpk(verif.getNoSpk()); verif2.setNoSpk(verif.getNoSpk());
verif2.setKodeAnggaran(verif.getKodeAnggaran()); verif2.setKodeAnggaran(verif.getKodeAnggaran());
verif2.setKodeDana(verif.getKodeDana()); verif2.setKodeDana(verif.getKodeDana());
verif2.setNamaRekanan(verif.getNamaRekanan()); verif2.setNamaRekanan(verif.getNamaRekanan());
verif2.setTotalBayar(verif.getTotalBayar()); verif2.setTotalBayar(verif.getTotalBayar());
verif2.setKeperluan(verif.getKeperluan()); verif2.setKeperluan(verif.getKeperluan());
if (verif.getAsalproduk() != null) {
verif2.setAsalproduk(verif.getAsalproduk());
} else {
verif2.setAsalproduk("-"); verif2.setAsalproduk("-");
} if (verif.getAsalproduk() != null)
verif2.setAsalproduk(verif.getAsalproduk());
verif2.setNoVerifikasi(verif.getNoVerifikasi()); verif2.setNoVerifikasi(verif.getNoVerifikasi());
verif2.setTerbilang("#" + verif.getTerbilang() + "#"); verif2.setTerbilang("#" + verif.getTerbilang() + "#");
if (verif.getBa() != null) {
verif2.setBa(verif.getBa());
} else {
verif2.setBa("-"); verif2.setBa("-");
} if (verif.getBa() != null)
verif2.setBa(verif.getBa());
if (verif.getSppb() != null) {
verif2.setSppb(verif.getSppb());
} else {
verif2.setSppb("-"); verif2.setSppb("-");
} if (verif.getSppb() != null)
verif2.setSppb(verif.getSppb());
if (verif.getFaktur() != null) {
verif2.setFaktur(verif.getFaktur());
} else {
verif2.setFaktur("-"); verif2.setFaktur("-");
} if (verif.getFaktur() != null)
verif2.setFaktur(verif.getFaktur());
if (verif.getPph() != null) {
verif2.setPph(verif.getPph());
} else {
verif2.setPph(0.0); verif2.setPph(0.0);
} if (verif.getPph() != null)
verif2.setPph(verif.getPph());
collection.add(verif2); collection.add(verif2);
parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("noverifikasifk", noverifikasifk); parameters.put("noverifikasifk", noverifikasifk);
jrbcds = new JRBeanCollectionDataSource(collection); JRBeanCollectionDataSource jrbcds = new JRBeanCollectionDataSource(collection);
String path = "/usr/share/app/reporting/rpt_verifikasitagihansupplier.jrxml"; String path = "/usr/share/app/reporting/rpt_verifikasitagihansupplier.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
print = JasperFillManager.fillReport(jasperReport, parameters, jrbcds); return JasperFillManager.fillReport(jasperReport, parameters, jrbcds);
} catch (Exception var13) { } catch (Exception var13) {
LOG.error("Exception at generateVerifikasiTagihanPdf()"); LOG.error("Exception at generateVerifikasiTagihanPdf()");
LOG.error(VerifikasiTagihanSupplierServices.class, var13); LOG.error(VerifikasiTagihanSupplierServices.class, var13);
} }
return null;
return print;
} finally {
;
}
} }
public JasperPrint generateVerifikasiPembayaranUmumPdf(String noverifikasifk) throws Exception { public JasperPrint generateVerifikasiPembayaranUmumPdf(String noverifikasifk) {
JasperPrint print = null;
Map<String, Object> parameters = null;
JRBeanCollectionDataSource jrbcds = null;
Vector<VerifikasiTagihanSupplier2> collection = null;
VerifikasiTagihanSupplier verif = null;
VerifikasiTagihanSupplier2 verif2 = null;
try { try {
try { if (noverifikasifk == null)
if (noverifikasifk == null) { throw new Exception("Cannot find verifikasi");
throw new Exception("Cannot find verifikasi = " + noverifikasifk + "."); Vector<VerifikasiTagihanSupplier2> collection = new Vector<>();
} VerifikasiTagihanSupplier verif = this.getVerifikasiPembayaranUmum(noverifikasifk);
VerifikasiTagihanSupplier2 verif2 = new VerifikasiTagihanSupplier2();
collection = null;
collection = new Vector();
verif = null;
verif = this.getVerifikasiPembayaranUmum(noverifikasifk);
verif2 = null;
verif2 = new VerifikasiTagihanSupplier2();
if (verif.getNoSpk() != null) {
verif2.setNoSpk(verif.getNoSpk());
} else {
verif2.setNoSpk("-"); verif2.setNoSpk("-");
} if (verif.getNoSpk() != null)
verif2.setNoSpk(verif.getNoSpk());
verif2.setKodeAnggaran(verif.getKodeAnggaran()); verif2.setKodeAnggaran(verif.getKodeAnggaran());
verif2.setKodeDana(verif.getKodeDana()); verif2.setKodeDana(verif.getKodeDana());
if (verif.getNamaRekanan() != null) {
verif2.setNamaRekanan(verif.getNamaRekanan());
} else {
verif2.setNamaRekanan("-"); verif2.setNamaRekanan("-");
} if (verif.getNamaRekanan() != null)
verif2.setNamaRekanan(verif.getNamaRekanan());
verif2.setTotalBayar(verif.getTotalBayar()); verif2.setTotalBayar(verif.getTotalBayar());
verif2.setKeperluan(verif.getKeperluan()); verif2.setKeperluan(verif.getKeperluan());
if (verif.getAsalproduk() != null) {
verif2.setAsalproduk(verif.getAsalproduk());
} else {
verif2.setAsalproduk("-"); verif2.setAsalproduk("-");
} if (verif.getAsalproduk() != null)
verif2.setAsalproduk(verif.getAsalproduk());
verif2.setNoVerifikasi(verif.getNoVerifikasi()); verif2.setNoVerifikasi(verif.getNoVerifikasi());
verif2.setTerbilang("#" + verif.getTerbilang() + "#"); verif2.setTerbilang("#" + verif.getTerbilang() + "#");
if (verif.getBa() != null) {
verif2.setBa(verif.getBa());
} else {
verif2.setBa("-"); verif2.setBa("-");
} if (verif.getBa() != null)
verif2.setBa(verif.getBa());
if (verif.getSppb() != null) {
verif2.setSppb(verif.getSppb());
} else {
verif2.setSppb("-"); verif2.setSppb("-");
} if (verif.getSppb() != null)
verif2.setSppb(verif.getSppb());
if (verif.getFaktur() != null) {
verif2.setFaktur(verif.getFaktur());
} else {
verif2.setFaktur("-"); verif2.setFaktur("-");
} if (verif.getFaktur() != null)
verif2.setFaktur(verif.getFaktur());
if (verif.getPph() != null) {
verif2.setPph(verif.getPph());
} else {
verif2.setPph(0.0); verif2.setPph(0.0);
} if (verif.getPph() != null)
verif2.setPph(verif.getPph());
collection.add(verif2); collection.add(verif2);
parameters = new HashMap(); Map<String, Object> parameters = new HashMap<>();
parameters.put("noverifikasifk", noverifikasifk); parameters.put("noverifikasifk", noverifikasifk);
jrbcds = new JRBeanCollectionDataSource(collection); JRBeanCollectionDataSource jrbcds = new JRBeanCollectionDataSource(collection);
String path = "/usr/share/app/reporting/rpt_verifikasipembayaranumum.jrxml"; String path = "/usr/share/app/reporting/rpt_verifikasipembayaranumum.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path); JasperReport jasperReport = JasperCompileManager.compileReport(path);
print = JasperFillManager.fillReport(jasperReport, parameters, jrbcds); return JasperFillManager.fillReport(jasperReport, parameters, jrbcds);
} catch (Exception var13) { } catch (Exception var13) {
LOG.error("Exception at generateVerifikasiPembayaranUmumPdf()"); LOG.error("Exception at generateVerifikasiPembayaranUmumPdf()");
LOG.error(VerifikasiTagihanSupplierServices.class, var13); LOG.error(VerifikasiTagihanSupplierServices.class, var13);
} }
return null;
return print;
} finally {
;
}
} }
} }

View File

@ -1,20 +1,8 @@
server.port=7777 server.port=7777
#Datasource
spring.datasource.type=com.zaxxer.hikari.HikariDataSource spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.driver-class-name=org.postgresql.Driver spring.datasource.driver-class-name=org.postgresql.Driver
#spring.datasource.url=jdbc:postgresql://localhost:5432/simrs_db_new
spring.datasource.url=jdbc:postgresql://172.16.88.8:5432/rsab_hk_production spring.datasource.url=jdbc:postgresql://172.16.88.8:5432/rsab_hk_production
#spring.datasource.url=jdbc:postgresql://192.168.12.1:5432/rsab_hk_production
#spring.datasource.url=jdbc:postgresql://192.168.12.3:5432/rsabhk_db_17022020
spring.datasource.username=postgres spring.datasource.username=postgres
spring.datasource.password=root spring.datasource.password=root
#spring.datasource.hikari.pool-name=SpringBootHikariCP
#spring.datasource.hikari.connection-test-query=SELECT 1
#spring.datasource.hikari.minimum-idle=5
#spring.datasource.hikari.maximum-pool-size=50
#spring.datasource.hikari.connection-timeout=30000
#spring.datasource.hikari.idle-timeout=600000
#spring.datasource.hikari.max-lifetime=1800000
#spring.datasource.hikari.auto-commit=true
spring.mvc.dispatch-trace-request=true spring.mvc.dispatch-trace-request=true
spring.main.banner-mode=off spring.main.banner-mode=off