diff --git a/pom.xml b/pom.xml index 324f0a5..86e91db 100644 --- a/pom.xml +++ b/pom.xml @@ -81,6 +81,21 @@ test --> + + + + + net.sf.jasperreports + jasperreports + 6.21.0 + + + + net.sf.jasperreports + jasperreports-fonts + 6.21.0 + + diff --git a/src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java b/src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java index aec60c1..30c39fc 100644 --- a/src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java +++ b/src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java @@ -17,12 +17,11 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; @EnableTransactionManagement public class DataSourceConfig { - private static String host = "localhost:3306"; - private static String dbpassword = "root"; +// private static String host = "localhost:3306"; +// private static String dbpassword = "root"; - // private static String host = - // "gcc-facial-db-instance-1.cf48eqcciziq.ap-south-1.rds.amazonaws.com:3306"; - // private static String dbpassword = "gcc-facial-password"; + private static String host = "gcc-facial-db-instance-1.cf48eqcciziq.ap-south-1.rds.amazonaws.com:3306"; + private static String dbpassword = "gcc-facial-password"; public static class MyDataSourceConfig { @Primary @@ -180,4 +179,7 @@ public class DataSourceConfig { return dataSource; } + + + } diff --git a/src/main/java/com/gcc/commissionerreview/controller/BannerRemovalApiController.java b/src/main/java/com/gcc/commissionerreview/controller/BannerRemovalApiController.java new file mode 100644 index 0000000..738e9a6 --- /dev/null +++ b/src/main/java/com/gcc/commissionerreview/controller/BannerRemovalApiController.java @@ -0,0 +1,79 @@ +package com.gcc.commissionerreview.controller; + +import com.gcc.commissionerreview.service.BannerApiService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("/commissionerreview/api/bannerremoval") + +public class BannerRemovalApiController { + + @Autowired + private BannerApiService bannerApiService ; + + + @GetMapping("/zone-wise") + public ResponseEntity> getZoneData( + @RequestParam Integer assetTypeId, + @RequestParam String fromDate, + @RequestParam String toDate) { + + Map data = + bannerApiService.fetchZoneData(assetTypeId, fromDate, toDate); + + return ResponseEntity.ok(data); + } + + + + @GetMapping("/ward-wise") + public ResponseEntity> getWardData( + @RequestParam Integer assetTypeId, + @RequestParam String fromDate, + @RequestParam String toDate, + @RequestParam String zone) { + + Map data = + bannerApiService.fetchWardData(assetTypeId, fromDate, toDate,zone); + + return ResponseEntity.ok(data); + } + + @GetMapping("/street-wise") + public ResponseEntity> getStreetData( + @RequestParam Integer assetTypeId, + @RequestParam String fromDate, + @RequestParam String toDate, + @RequestParam String zone, + @RequestParam String ward) { + + Map data = + bannerApiService.fetchStreetData(assetTypeId, fromDate, toDate,zone,ward); + + return ResponseEntity.ok(data); + } + + @GetMapping("/street-details") + public ResponseEntity>> getStreetDetails( + @RequestParam Integer assetTypeId, + @RequestParam String fromDate, + @RequestParam String toDate, + @RequestParam String zone, + @RequestParam String ward, + @RequestParam String streetid) { + + List> data = + bannerApiService.fetchStreetDetails(assetTypeId, fromDate, toDate, zone, ward, streetid); + + return ResponseEntity.ok(data); + } + +} diff --git a/src/main/java/com/gcc/commissionerreview/controller/MainController.java b/src/main/java/com/gcc/commissionerreview/controller/MainController.java index bdbaece..4d8a4a9 100644 --- a/src/main/java/com/gcc/commissionerreview/controller/MainController.java +++ b/src/main/java/com/gcc/commissionerreview/controller/MainController.java @@ -311,4 +311,15 @@ public class MainController { return "modules/fooddistribution/fooddistributiondetailedreport"; } + + @GetMapping("/posterreport") + public String posterdetailedreport(Model model) { + return "modules/poster/posterReport"; + } + + @GetMapping("/bannerreport") + public String bannerdetailedreport(Model model) { + return "modules/poster/bannerReport"; + } + } diff --git a/src/main/java/com/gcc/commissionerreview/controller/PosterRemovalApiController.java b/src/main/java/com/gcc/commissionerreview/controller/PosterRemovalApiController.java new file mode 100644 index 0000000..a91c023 --- /dev/null +++ b/src/main/java/com/gcc/commissionerreview/controller/PosterRemovalApiController.java @@ -0,0 +1,128 @@ +package com.gcc.commissionerreview.controller; + +import com.gcc.commissionerreview.service.PosterReportService; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("/commissionerreview/api/posterremoval") + +public class PosterRemovalApiController { + + + @Autowired + private PosterReportService posterReportService; + + + @GetMapping("/zone-wise") + public ResponseEntity> getZoneData( + @RequestParam Integer assetTypeId, + @RequestParam String fromDate, + @RequestParam String toDate) { + + Map data = + posterReportService.fetchZoneData(assetTypeId, fromDate, toDate); + + return ResponseEntity.ok(data); + } + + + + @GetMapping("/ward-wise") + public ResponseEntity> getWardData( + @RequestParam Integer assetTypeId, + @RequestParam String fromDate, + @RequestParam String toDate, + @RequestParam String zone) { + + Map data = + posterReportService.fetchWardData(assetTypeId, fromDate, toDate,zone); + + return ResponseEntity.ok(data); + } + + @GetMapping("/street-wise") + public ResponseEntity> getStreetData( + @RequestParam Integer assetTypeId, + @RequestParam String fromDate, + @RequestParam String toDate, + @RequestParam String zone, + @RequestParam String ward) { + + Map data = + posterReportService.fetchStreetData(assetTypeId, fromDate, toDate,zone,ward); + + return ResponseEntity.ok(data); + } + + @GetMapping("/street-details") + public ResponseEntity>> getStreetDetails( + @RequestParam Integer assetTypeId, + @RequestParam String fromDate, + @RequestParam String toDate, + @RequestParam String zone, + @RequestParam String ward, + @RequestParam String streetid) { + + List> data = + posterReportService.fetchStreetDetails(assetTypeId, fromDate, toDate, zone, ward, streetid); + + return ResponseEntity.ok(data); + } + + + +// add using jrxml format + + @GetMapping("/download-street-report") + public void downloadStreetReport( + @RequestParam Integer assetTypeId, + @RequestParam String fromDate, + @RequestParam String toDate, + @RequestParam String zone, + @RequestParam String ward, + @RequestParam String streetid, + HttpServletResponse response) throws Exception { + + posterReportService.downloadStreetReport( + assetTypeId, + fromDate, + toDate, + zone, + ward, + streetid, + response); + } + + + + @GetMapping("/download-street-pdf-report") + public void downloadStreetPdfReport( + @RequestParam Integer assetTypeId, + @RequestParam String fromDate, + @RequestParam String toDate, + @RequestParam String zone, + @RequestParam String ward, + @RequestParam String streetid, + HttpServletResponse response) throws Exception { + + posterReportService.downloadStreetPdfReport( + assetTypeId, + fromDate, + toDate, + zone, + ward, + streetid, + response); + } + + +} diff --git a/src/main/java/com/gcc/commissionerreview/service/BannerApiService.java b/src/main/java/com/gcc/commissionerreview/service/BannerApiService.java new file mode 100644 index 0000000..7aa30dd --- /dev/null +++ b/src/main/java/com/gcc/commissionerreview/service/BannerApiService.java @@ -0,0 +1,164 @@ +package com.gcc.commissionerreview.service; + + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class BannerApiService { + + + @Autowired + private RestTemplate restTemplate; + + @Autowired + private ObjectMapper objectMapper; + + + public Map fetchZoneData(Integer assetTypeId, + String fromDate, + String toDate) { + + try { + + DateTimeFormatter inputFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter outputFormat = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + + String formattedFromDate = LocalDate.parse(fromDate, inputFormat).format(outputFormat); + String formattedToDate = LocalDate.parse(toDate, inputFormat).format(outputFormat); + + String url = "https://gccservices.in/gccofficialapp/api/asset/filterReports" + + "?assetTypeId=" + assetTypeId + + "&fromDate=" + formattedFromDate + + "&toDate=" + formattedToDate; + + String response = restTemplate.getForObject(url, String.class); + + return objectMapper.readValue(response, Map.class); + + } catch (Exception e) { + System.out.println("Error: " + e.getMessage()); + return new HashMap<>(); + } + } + + + public Map fetchWardData(Integer assetTypeId, + String fromDate, + String toDate,String zone) { + + try { + + DateTimeFormatter inputFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter outputFormat = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + + String formattedFromDate = LocalDate.parse(fromDate, inputFormat).format(outputFormat); + String formattedToDate = LocalDate.parse(toDate, inputFormat).format(outputFormat); + + String url = "https://gccservices.in/gccofficialapp/api/asset/filterReports?" + + "assetTypeId=" + assetTypeId + + "&fromDate=" + formattedFromDate + + "&toDate=" + formattedToDate + + "&zone=" + zone; + + String response = restTemplate.getForObject(url, String.class); + + return objectMapper.readValue(response, Map.class); + + } catch (Exception e) { + System.out.println("Error: " + e.getMessage()); + return new HashMap<>(); + } + } + + + public Map fetchStreetData(Integer assetTypeId, + String fromDate, + String toDate,String zone,String ward) { + + try { + + DateTimeFormatter inputFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter outputFormat = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + + String formattedFromDate = LocalDate.parse(fromDate, inputFormat).format(outputFormat); + String formattedToDate = LocalDate.parse(toDate, inputFormat).format(outputFormat); + + String url = "https://gccservices.in/gccofficialapp/api/asset/filterReports?" + + "assetTypeId=" + assetTypeId + + "&fromDate=" + formattedFromDate + + "&toDate=" + formattedToDate + + "&zone=" + zone + + "&ward=" + ward ; + + String response = restTemplate.getForObject(url, String.class); + + return objectMapper.readValue(response, Map.class); + + } catch (Exception e) { + System.out.println("Error: " + e.getMessage()); + return new HashMap<>(); + } + } + + + public List> fetchStreetDetails(Integer assetTypeId, + String fromDate, + String toDate, + String zone, + String ward, + String streetid) { + + try { + + DateTimeFormatter inputFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter outputFormat = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + + String formattedFromDate = LocalDate.parse(fromDate, inputFormat).format(outputFormat); + String formattedToDate = LocalDate.parse(toDate, inputFormat).format(outputFormat); + + String url = "https://gccservices.in/gccofficialapp/api/asset/filterReportsByDate?" + + "assetTypeId=" + assetTypeId + + "&fromDate=" + formattedFromDate + + "&toDate=" + formattedToDate + + "&zone=" + zone + + "&ward=" + ward + + "&streetid=" + streetid; + + String response = restTemplate.getForObject(url, String.class); + + Object parsed = objectMapper.readValue(response, Object.class); + + + if (parsed instanceof List) { + return (List>) parsed; + } + + Map result = (Map) parsed; + + if (result.containsKey("data")) { + return (List>) result.get("data"); + } + + if (result.containsKey("zoneWise")) { + return (List>) result.get("zoneWise"); + } + + // fallback + return new ArrayList<>(); + + } catch (Exception e) { + System.out.println("Error: " + e.getMessage()); + return new ArrayList<>(); + } + } +} diff --git a/src/main/java/com/gcc/commissionerreview/service/PosterReportService.java b/src/main/java/com/gcc/commissionerreview/service/PosterReportService.java new file mode 100644 index 0000000..ce980b2 --- /dev/null +++ b/src/main/java/com/gcc/commissionerreview/service/PosterReportService.java @@ -0,0 +1,511 @@ +package com.gcc.commissionerreview.service; + +import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.servlet.http.HttpServletResponse; +import net.sf.jasperreports.engine.*; +import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; +import net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter; +import net.sf.jasperreports.export.SimpleExporterInput; +import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput; +import net.sf.jasperreports.export.SimpleXlsxReportConfiguration; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +import java.io.InputStream; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class PosterReportService { + + + @Autowired + private RestTemplate restTemplate; + + @Autowired + private ObjectMapper objectMapper; + + + public Map fetchZoneData(Integer assetTypeId, + String fromDate, + String toDate) { + + try { + + DateTimeFormatter inputFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter outputFormat = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + + String formattedFromDate = LocalDate.parse(fromDate, inputFormat).format(outputFormat); + String formattedToDate = LocalDate.parse(toDate, inputFormat).format(outputFormat); + + String url = "https://gccservices.in/gccofficialapp/api/asset/filterReports" + + "?assetTypeId=" + assetTypeId + + "&fromDate=" + formattedFromDate + + "&toDate=" + formattedToDate; + + String response = restTemplate.getForObject(url, String.class); + + return objectMapper.readValue(response, Map.class); + + } catch (Exception e) { + System.out.println("Error: " + e.getMessage()); + return new HashMap<>(); + } + } + + + public Map fetchWardData(Integer assetTypeId, + String fromDate, + String toDate,String zone) { + + try { + + DateTimeFormatter inputFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter outputFormat = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + + String formattedFromDate = LocalDate.parse(fromDate, inputFormat).format(outputFormat); + String formattedToDate = LocalDate.parse(toDate, inputFormat).format(outputFormat); + + String url = "https://gccservices.in/gccofficialapp/api/asset/filterReports?" + + "assetTypeId=" + assetTypeId + + "&fromDate=" + formattedFromDate + + "&toDate=" + formattedToDate + + "&zone=" + zone; + + String response = restTemplate.getForObject(url, String.class); + + return objectMapper.readValue(response, Map.class); + + } catch (Exception e) { + System.out.println("Error: " + e.getMessage()); + return new HashMap<>(); + } + } + + + public Map fetchStreetData(Integer assetTypeId, + String fromDate, + String toDate,String zone,String ward) { + + try { + + DateTimeFormatter inputFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter outputFormat = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + + String formattedFromDate = LocalDate.parse(fromDate, inputFormat).format(outputFormat); + String formattedToDate = LocalDate.parse(toDate, inputFormat).format(outputFormat); + + String url = "https://gccservices.in/gccofficialapp/api/asset/filterReports?" + + "assetTypeId=" + assetTypeId + + "&fromDate=" + formattedFromDate + + "&toDate=" + formattedToDate + + "&zone=" + zone + + "&ward=" + ward ; + + String response = restTemplate.getForObject(url, String.class); + + return objectMapper.readValue(response, Map.class); + + } catch (Exception e) { + System.out.println("Error: " + e.getMessage()); + return new HashMap<>(); + } + } + + + public List> fetchStreetDetails(Integer assetTypeId, + String fromDate, + String toDate, + String zone, + String ward, + String streetid) { + + try { + + DateTimeFormatter inputFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter outputFormat = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + + String formattedFromDate = LocalDate.parse(fromDate, inputFormat).format(outputFormat); + String formattedToDate = LocalDate.parse(toDate, inputFormat).format(outputFormat); + + String url = "https://gccservices.in/gccofficialapp/api/asset/filterReportsByDate?" + + "assetTypeId=" + assetTypeId + + "&fromDate=" + formattedFromDate + + "&toDate=" + formattedToDate + + "&zone=" + zone + + "&ward=" + ward + + "&streetid=" + streetid; + + String response = restTemplate.getForObject(url, String.class); + + Object parsed = objectMapper.readValue(response, Object.class); + + + if (parsed instanceof List) { + return (List>) parsed; + } + + Map result = (Map) parsed; + + if (result.containsKey("data")) { + return (List>) result.get("data"); + } + + if (result.containsKey("zoneWise")) { + return (List>) result.get("zoneWise"); + } + + // fallback + return new ArrayList<>(); + + } catch (Exception e) { + System.out.println("Error: " + e.getMessage()); + return new ArrayList<>(); + } + } + + + public void downloadStreetReport( + Integer assetTypeId, + String fromDate, + String toDate, + String zone, + String ward, + String streetid, + HttpServletResponse response) throws Exception { + + // EXISTING METHOD CALL + List> data = + fetchStreetDetails( + assetTypeId, + fromDate, + toDate, + zone, + ward, + streetid); + + + + List> finalList = new ArrayList<>(); + + for (Map row : data) { + + String beforeImage = ""; + String afterImage = ""; + + Object feedbackObj = row.get("feedback_file"); + + if (feedbackObj instanceof List) { + + List feedbackFiles = (List) feedbackObj; + + for (Object obj : feedbackFiles) { + + if (obj instanceof Map fileMap) { + + String action = ""; + + if (fileMap.get("fileaction") != null) { + action = + String.valueOf( + fileMap.get("fileaction")); + } + + String imageUrl = ""; + + if (fileMap.get("imageUrl") != null) { + imageUrl = + String.valueOf( + fileMap.get("imageUrl")); + } + + // BEFORE IMAGE + if ("before".equalsIgnoreCase(action)) { + beforeImage = imageUrl; + } + + // AFTER IMAGE + if ("after".equalsIgnoreCase(action)) { + afterImage = imageUrl; + } + } + } + } + + + + Map jasperMap = + new HashMap<>(); + + jasperMap.put("zone", + row.get("zone")); + + jasperMap.put("ward", + row.get("ward")); + + jasperMap.put("streetname", + row.get("streetname")); + + jasperMap.put("beforeImage", + beforeImage); + + jasperMap.put("afterImage", + afterImage); + + finalList.add(jasperMap); + } + + + + JRBeanCollectionDataSource dataSource = + new JRBeanCollectionDataSource(finalList); + + InputStream inputStream = + getClass().getResourceAsStream( + "/templates/modules/poster/street_details.jrxml"); + + JasperReport jasperReport = + JasperCompileManager.compileReport(inputStream); + + Map params = new HashMap<>(); + + JasperPrint jasperPrint = + JasperFillManager.fillReport( + jasperReport, + params, + dataSource); + + response.setContentType( + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + + response.setHeader( + "Content-Disposition", + "attachment; filename=Street_Details_Report.xlsx"); + + JRXlsxExporter exporter = new JRXlsxExporter(); + + exporter.setExporterInput( + new SimpleExporterInput(jasperPrint)); + + exporter.setExporterOutput( + new SimpleOutputStreamExporterOutput( + response.getOutputStream())); + + SimpleXlsxReportConfiguration configuration = + new SimpleXlsxReportConfiguration(); + + configuration.setOnePagePerSheet(false); + configuration.setDetectCellType(true); + configuration.setCollapseRowSpan(false); + configuration.setRemoveEmptySpaceBetweenRows(true); + configuration.setWhitePageBackground(false); + + exporter.setConfiguration(configuration); + + exporter.exportReport(); + + response.flushBuffer(); + } + + + public void downloadStreetPdfReport( + Integer assetTypeId, + String fromDate, + String toDate, + String zone, + String ward, + String streetid, + HttpServletResponse response) throws Exception { + + List> data = + fetchStreetDetails( + assetTypeId, + fromDate, + toDate, + zone, + ward, + streetid); + + + + List> finalList = + new ArrayList<>(); + + for (Map row : data) { + + String beforeImage = ""; + String afterImage = ""; + String removalDate = ""; + + + String enumeratedDate = ""; + + if (row.get("cdate") != null) { + + String fullDate = String.valueOf(row.get("cdate")); + + if (fullDate.contains("T")) { + String datePart = fullDate.split("T")[0]; + String[] parts = datePart.split("-"); + enumeratedDate = parts[2] + "-" + parts[1] + "-" + parts[0]; + } else { + enumeratedDate = fullDate; + } + } + + // LATITUDE + String latitude = ""; + + if (row.get("latitude") != null) { + latitude = String.valueOf(row.get("latitude")); + } + + // LONGITUDE + String longitude = ""; + + if (row.get("longitude") != null) { + longitude = String.valueOf(row.get("longitude")); + } + + Object feedbackObj = row.get("feedback_file"); + + if (feedbackObj instanceof List) { + + List feedbackFiles = (List) feedbackObj; + + for (Object obj : feedbackFiles) { + + if (obj instanceof Map fileMap) { + + String action = ""; + + if (fileMap.get("fileaction") != null) { + action = + String.valueOf( + fileMap.get("fileaction")); + } + + String imageUrl = ""; + + if (fileMap.get("imageUrl") != null) { + imageUrl = + String.valueOf( + fileMap.get("imageUrl")); + } + + // BEFORE IMAGE + if ("before".equalsIgnoreCase(action)) { + beforeImage = imageUrl; + } + + // AFTER IMAGE + REMOVAL DATE + if ("after".equalsIgnoreCase(action)) { + + afterImage = imageUrl; + + if (fileMap.get("cdate") != null) { + + String removeDate = String.valueOf( + fileMap.get("cdate")); + + if (removeDate.contains("T")) { + String datePart = removeDate.split("T")[0]; + String[] parts = datePart.split("-"); + + removalDate = parts[2] + "-" + parts[1] + "-" + parts[0]; + } else { + removalDate = removeDate; + } + } + } + } + } + } + + + + Map jasperMap = + new HashMap<>(); + + jasperMap.put("zone", + row.get("zone")); + + jasperMap.put("ward", + row.get("ward")); + + jasperMap.put("latitude", + latitude); + + jasperMap.put("longitude", + longitude); + + jasperMap.put("streetname", + row.get("streetname")); + + jasperMap.put("enumeratedDate", + enumeratedDate); + + jasperMap.put("removalDate", + removalDate); + + jasperMap.put("beforeImage", + beforeImage); + + jasperMap.put("afterImage", + afterImage); + + finalList.add(jasperMap); + } + + + + + + JRBeanCollectionDataSource dataSource = + new JRBeanCollectionDataSource(finalList); + + InputStream inputStream = + getClass().getResourceAsStream( + "/templates/modules/poster/street_details.jrxml"); + + JasperReport jasperReport = + JasperCompileManager.compileReport(inputStream); + + Map params = new HashMap<>(); + + DateTimeFormatter inputFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter outputFormat = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + + String formattedFromDate = LocalDate.parse(fromDate, inputFormat).format(outputFormat); + String formattedToDate = LocalDate.parse(toDate, inputFormat).format(outputFormat); + + params.put("zone", zone); + params.put("ward", ward); + params.put("fromDate", formattedFromDate); + params.put("toDate", formattedToDate); + + JasperPrint jasperPrint = + JasperFillManager.fillReport( + jasperReport, + params, + dataSource); + + response.setContentType("application/pdf"); + + response.setHeader( + "Content-Disposition", + "attachment; filename=Street_Details_Report.pdf"); + + JasperExportManager.exportReportToPdfStream( + jasperPrint, + response.getOutputStream()); + + response.flushBuffer(); + } + +} diff --git a/src/main/resources/templates/modules/poster/bannerReport.html b/src/main/resources/templates/modules/poster/bannerReport.html new file mode 100644 index 0000000..926a0c8 --- /dev/null +++ b/src/main/resources/templates/modules/poster/bannerReport.html @@ -0,0 +1,887 @@ + + + + Banner Removal Report + + + + + + + + + + + + + + + + + +
+ +

Banner Removal Report

+ + +
+ + + +
+ + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/templates/modules/poster/posterReport.html b/src/main/resources/templates/modules/poster/posterReport.html new file mode 100644 index 0000000..b792e91 --- /dev/null +++ b/src/main/resources/templates/modules/poster/posterReport.html @@ -0,0 +1,917 @@ + + + + Poster Removal Report + + + + + + + + + + + + + + + + + +
+ +

Poster Removal Report

+ + +
+ + + +
+ + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/templates/modules/poster/street_details.jrxml b/src/main/resources/templates/modules/poster/street_details.jrxml new file mode 100644 index 0000000..e71422d --- /dev/null +++ b/src/main/resources/templates/modules/poster/street_details.jrxml @@ -0,0 +1,362 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="90"> + + <!-- REPORT TITLE --> + <textField> + <reportElement x="0" y="0" width="1180" height="25"/> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font size="18" isBold="true"/> + </textElement> + <textFieldExpression><![CDATA["Street Details Report"]]></textFieldExpression> + </textField> + + <!-- ZONE + WARD --> + <textField> + <reportElement x="0" y="30" width="1180" height="20"/> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font size="14" isBold="true"/> + </textElement> + <textFieldExpression><![CDATA[ + "Zone: " + $P{zone} + " Ward: " + $P{ward} + ]]></textFieldExpression> + </textField> + + <!-- FROM DATE + TO DATE --> + <textField> + <reportElement x="0" y="55" width="1180" height="20"/> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font size="12"/> + </textElement> + <textFieldExpression><![CDATA[ + "From Date: " + $P{fromDate} + " To Date: " + $P{toDate} + ]]></textFieldExpression> + </textField> + + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file