update rekapitulasi pendapatan ruangan

This commit is contained in:
ridwan 2026-02-18 09:54:12 +07:00
parent 683da47529
commit 43a2bb8443
3 changed files with 76 additions and 0 deletions

View File

@ -1759,4 +1759,51 @@ public class ReportingController {
}
}
@RequestMapping(value = {"/rekapitulasi-pendapatan-ruangan"}, method = {RequestMethod.GET})
public void handleLpPendapatanRuangan(
@RequestParam("tglAwal") String tglAwal,
@RequestParam("tglAkhir") String tglAkhir,
@RequestParam(value = "idUnit", required = false, defaultValue = "") Integer idUnit,
@RequestParam(value = "format", required = false, defaultValue = "pdf") String format,
@RequestParam(value = "mode", required = false, defaultValue = "download") String mode,
@RequestParam(value = "printBy", required = false, defaultValue = "") String printBy,
HttpServletResponse response) throws Exception {
JasperPrint jasperPrint = null;
try {
// Generate report (common for both PDF/Excel)
jasperPrint = this.reportingService.exportLpPendapatanRuangan(tglAwal, tglAkhir, idUnit, printBy);
if ("excel".equalsIgnoreCase(format)) {
// Handle Excel export
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "attachment; filename=Rekapitulasi_Pendapatan_Ruangan.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=Rekapitulasi_Pendapatan_Ruangan.pdf");
JRPdfExporter exporter = new JRPdfExporter();
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream()));
exporter.exportReport();
}
} finally {
jasperPrint = null;
}
}
}

View File

@ -1425,5 +1425,21 @@ public class ReportingDao {
return null;
}
public JasperPrint exportLpPendapatanRuangan(Timestamp tglAwal, Timestamp tglAkhir, Integer idUnit, String printBy) {
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
String path = jasperDirPath + "rpt_pendapatan_ruangan.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap<>();
parameters.put("tglAwal", tglAwal);
parameters.put("tglAkhir", tglAkhir);
parameters.put("idUnit", idUnit);
parameters.put("printBy", printBy);
return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var15) {
LOG.error("Exception at exportLpPendapatanRuangan");
LOG.error(ReportingDao.class, var15);
}
return null;
}
}

View File

@ -500,4 +500,17 @@ public class ReportingService {
}
}
public JasperPrint exportLpPendapatanRuangan(String tglAwal, String tglAkhir, Integer idUnit, String printBy) {
log.info("Starting exportLpPenjualanKaryawan with tglAwal: {}, tglAkhir: {}, idUnit: {}, printBy: {}", tglAwal, tglAkhir, idUnit, printBy);
try {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Timestamp parse = new Timestamp(formatter.parse(tglAwal).getTime());
Timestamp parse2 = new Timestamp(formatter.parse(tglAkhir).getTime());
return this.reportingDao.exportLpPendapatanRuangan(parse, parse2, idUnit, printBy);
} catch (ParseException e) {
log.error(e.getMessage());
return null;
}
}
}