UP Lp Penjualan Karyawan

This commit is contained in:
ridwan 2026-02-05 15:55:25 +07:00
parent b90d647edd
commit 683da47529
3 changed files with 79 additions and 0 deletions

View File

@ -1711,4 +1711,52 @@ public class ReportingController {
}
}
@RequestMapping(value = {"/laporan-penjualan-karyawan"}, method = {RequestMethod.GET})
public void handleLpPenjualanKaryawan(
@RequestParam("tglAwal") String tglAwal,
@RequestParam("tglAkhir") String tglAkhir,
@RequestParam(value = "dokter", required = false, defaultValue = "") Integer dokter,
@RequestParam(value = "ruangan", required = false, defaultValue = "") Integer ruangan,
@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.exportLpPenjualanKaryawan(tglAwal, tglAkhir, dokter, ruangan, printBy);
if ("excel".equalsIgnoreCase(format)) {
// Handle Excel export
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "attachment; filename=Laporan_Penjualan_Karyawan.xlsx");
JRXlsxExporter exporter = new JRXlsxExporter();
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream()));
SimpleXlsxReportConfiguration config = new SimpleXlsxReportConfiguration();
config.setOnePagePerSheet(false);
config.setDetectCellType(true);
config.setCollapseRowSpan(false);
config.setRemoveEmptySpaceBetweenRows(true);
config.setWhitePageBackground(false);
exporter.setConfiguration(config);
exporter.exportReport();
} else {
// Handle PDF preview
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "inline; filename=Laporan_Penjualan_Karyawan.pdf");
JRPdfExporter exporter = new JRPdfExporter();
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream()));
exporter.exportReport();
}
} finally {
jasperPrint = null;
}
}
}

View File

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

View File

@ -487,4 +487,17 @@ public class ReportingService {
}
}
public JasperPrint exportLpPenjualanKaryawan(String tglAwal, String tglAkhir, Integer dokter, Integer ruangan, String printBy) {
log.info("Starting exportLpPenjualanKaryawan with tglAwal: {}, tglAkhir: {}, dokter: {}, ruangan: {}, printBy: {}", tglAwal, tglAkhir, dokter, ruangan, 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.exportLpPenjualanKaryawan(parse, parse2, dokter, ruangan, printBy);
} catch (ParseException e) {
log.error(e.getMessage());
return null;
}
}
}