update rekap logbook
This commit is contained in:
parent
59ddf53b98
commit
a31ec6f40a
@ -1028,4 +1028,47 @@ public class ReportingController {
|
|||||||
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
|
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = {"/rekap-logbook"}, method = {RequestMethod.GET})
|
||||||
|
public void handleRekapLogbook(
|
||||||
|
@RequestParam("tahun") String tahun,
|
||||||
|
@RequestParam("bulan") String bulan,
|
||||||
|
@RequestParam(value = "ksm_id", required = false, defaultValue = "") Integer ksm_id,
|
||||||
|
@RequestParam(value = "pegawai_id", required = false, defaultValue = "") Integer pegawai_id,
|
||||||
|
@RequestParam(value = "format", required = false, defaultValue = "pdf") String format,
|
||||||
|
@RequestParam(value = "mode", required = false, defaultValue = "download") String mode,
|
||||||
|
@RequestParam(value = "printBy", required = false, defaultValue = "") String printBy,
|
||||||
|
HttpServletResponse response) throws Exception {
|
||||||
|
|
||||||
|
// Generate report (common for both PDF/Excel)
|
||||||
|
JasperPrint jasperPrint = this.reportingService.exportPdfRekapLogbook(tahun, bulan, ksm_id, pegawai_id, printBy);
|
||||||
|
|
||||||
|
if ("excel".equalsIgnoreCase(format)) {
|
||||||
|
// Handle Excel export
|
||||||
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||||
|
response.setHeader("Content-Disposition", "attachment; filename=Rekap_Logbook.xlsx");
|
||||||
|
|
||||||
|
JRXlsxExporter exporter = new JRXlsxExporter();
|
||||||
|
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
|
||||||
|
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream()));
|
||||||
|
SimpleXlsxReportConfiguration config = new SimpleXlsxReportConfiguration();
|
||||||
|
config.setOnePagePerSheet(false);
|
||||||
|
config.setDetectCellType(true);
|
||||||
|
config.setCollapseRowSpan(false);
|
||||||
|
config.setRemoveEmptySpaceBetweenRows(true);
|
||||||
|
config.setWhitePageBackground(false);
|
||||||
|
exporter.setConfiguration(config);
|
||||||
|
exporter.exportReport();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Handle PDF preview
|
||||||
|
response.setContentType("application/pdf");
|
||||||
|
response.setHeader("Content-Disposition", "inline; filename=Rekap_Logbook.pdf");
|
||||||
|
|
||||||
|
JRPdfExporter exporter = new JRPdfExporter();
|
||||||
|
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
|
||||||
|
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream()));
|
||||||
|
exporter.exportReport();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1294,4 +1294,22 @@ public class ReportingDao {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JasperPrint exportPdfRekapLogbook(String tahun, String bulan, Integer ksm_id, Integer pegawai_id , String printBy) {
|
||||||
|
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
|
||||||
|
String path = jasperDirPath + "rekap_logbook_dong.jrxml";
|
||||||
|
JasperReport jasperReport = JasperCompileManager.compileReport(path);
|
||||||
|
Map<String, Object> parameters = new HashMap<>();
|
||||||
|
parameters.put("tahun", tahun);
|
||||||
|
parameters.put("bulan", bulan);
|
||||||
|
parameters.put("ksm_id", ksm_id);
|
||||||
|
parameters.put("pegawai_id", pegawai_id);
|
||||||
|
parameters.put("printBy", printBy);
|
||||||
|
return JasperFillManager.fillReport(jasperReport, parameters, conn);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("Exception at exportPdfRekapLogbook");
|
||||||
|
LOG.error(ReportingDao.class, e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,12 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.YearMonth;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.format.DateTimeParseException;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -297,6 +303,7 @@ public class ReportingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Klinik Utama Bintaro
|
//Klinik Utama Bintaro
|
||||||
|
|
||||||
public JasperPrint exportPdfBuktiLayananBintaro(String norec, String user) {
|
public JasperPrint exportPdfBuktiLayananBintaro(String norec, String user) {
|
||||||
@ -446,4 +453,8 @@ public class ReportingService {
|
|||||||
return this.reportingDao.exportPdfSMPK(smpk);
|
return this.reportingDao.exportPdfSMPK(smpk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JasperPrint exportPdfRekapLogbook(String tahun, String bulan, Integer ksm_id, Integer pegawai_id , String printBy) {
|
||||||
|
return this.reportingDao.exportPdfRekapLogbook(tahun, bulan, ksm_id, pegawai_id, printBy);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user