|
|
|
@@ -79,6 +79,52 @@ class ReportController( |
|
|
|
|
|
|
|
return ResponseEntity(pdfBytes, headers, HttpStatus.OK) |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/print-stock-in-traceability") |
|
|
|
fun generateStockInTraceabilityReport( |
|
|
|
@RequestParam(required = false) stockCategory: String?, |
|
|
|
@RequestParam(required = false) stockSubCategory: String?, |
|
|
|
@RequestParam(required = false) itemCode: String?, |
|
|
|
@RequestParam(required = false) year: String?, |
|
|
|
@RequestParam(required = false) lastInDateStart: String?, |
|
|
|
@RequestParam(required = false) lastInDateEnd: String? |
|
|
|
): ResponseEntity<ByteArray> { |
|
|
|
val parameters = mutableMapOf<String, Any>() |
|
|
|
|
|
|
|
// Set report header parameters |
|
|
|
parameters["stockCategory"] = stockCategory ?: "All" |
|
|
|
parameters["stockSubCategory"] = stockSubCategory ?: "All" |
|
|
|
parameters["itemNo"] = itemCode ?: "All" |
|
|
|
parameters["year"] = year ?: LocalDate.now().year.toString() |
|
|
|
parameters["reportDate"] = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) |
|
|
|
parameters["reportTime"] = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")) |
|
|
|
parameters["lastInDateStart"] = lastInDateStart ?: "" |
|
|
|
parameters["lastInDateEnd"] = lastInDateEnd ?: "" |
|
|
|
|
|
|
|
// Query the DB to get a list of data |
|
|
|
val dbData = reportService.searchStockInTraceabilityReport( |
|
|
|
stockCategory, |
|
|
|
stockSubCategory, |
|
|
|
itemCode, |
|
|
|
year, |
|
|
|
lastInDateStart, |
|
|
|
lastInDateEnd |
|
|
|
) |
|
|
|
|
|
|
|
val pdfBytes = reportService.createPdfResponse( |
|
|
|
"/jasper/StockInTraceabilityReport.jrxml", |
|
|
|
parameters, |
|
|
|
dbData |
|
|
|
) |
|
|
|
|
|
|
|
val headers = HttpHeaders().apply { |
|
|
|
contentType = MediaType.APPLICATION_PDF |
|
|
|
setContentDispositionFormData("attachment", "StockInTraceabilityReport.pdf") |
|
|
|
set("filename", "StockInTraceabilityReport.pdf") |
|
|
|
} |
|
|
|
|
|
|
|
return ResponseEntity(pdfBytes, headers, HttpStatus.OK) |
|
|
|
} |
|
|
|
@GetMapping("/print-fg-delivery-report") |
|
|
|
fun generateFGDeliveryReport( |
|
|
|
@RequestParam(required = false) stockCategory: String?, |
|
|
|
|