diff --git a/src/main/java/com/gcc/publicgrievance/Service/ComplaintService.java b/src/main/java/com/gcc/publicgrievance/Service/ComplaintService.java index 6e69f94..6d9791c 100644 --- a/src/main/java/com/gcc/publicgrievance/Service/ComplaintService.java +++ b/src/main/java/com/gcc/publicgrievance/Service/ComplaintService.java @@ -1,4 +1,7 @@ package com.gcc.publicgrievance.Service; + +import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -13,41 +16,52 @@ import org.springframework.web.client.RestTemplate; @Service public class ComplaintService { - private final String baseUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice"; - - public String fetchComplaintCategories() { - RestTemplate restTemplate = new RestTemplate(); - String url = baseUrl + "?serviceId=getComplCategory&ComplaintGroupId=null"; - return restTemplate.getForObject(url, String.class); - } - - public String fetchComplaintSubTypes(String groupId) { - RestTemplate restTemplate = new RestTemplate(); - String url = baseUrl + "?serviceId=getComplCategory&ComplaintGroupId=" + groupId; - return restTemplate.getForObject(url, String.class); - } - -// public String fetchComplaintdetailsbyId(String complaintid) { -// RestTemplate restTemplate = new RestTemplate(); -// String url = baseUrl + "?serviceId=getComplaintByID&ComplaintId=" + complaintid; -// return restTemplate.getForObject(url, String.class); -// } - - public List> fetchComplaintDetailsById(String complaintId) { - RestTemplate restTemplate = new RestTemplate(); - String url = baseUrl + "?serviceId=getComplaintByID&ComplaintId=" + complaintId; - String response = restTemplate.getForObject(url, String.class); - - try { - ObjectMapper objectMapper = new ObjectMapper(); - return objectMapper.readValue(response, new TypeReference>>() {}); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - - - + private final String baseUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice"; + + public String fetchComplaintCategories() { + RestTemplate restTemplate = new RestTemplate(); + String url = baseUrl + "?serviceId=getComplCategory&ComplaintGroupId=null"; + return restTemplate.getForObject(url, String.class); + } + + public String fetchComplaintSubTypes(String groupId) { + RestTemplate restTemplate = new RestTemplate(); + String url = baseUrl + "?serviceId=getComplCategory&ComplaintGroupId=" + groupId; + return restTemplate.getForObject(url, String.class); + } + + public List> fetchComplaintDetailsById(String complaintId) { + RestTemplate restTemplate = new RestTemplate(); + String url = baseUrl + "?serviceId=getComplaintByID&ComplaintId=" + complaintId; + String response = restTemplate.getForObject(url, String.class); + + try { + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(response, new TypeReference>>() { + }); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public List> fetchComplaintDetailsByMobile(String mobileNo) { + RestTemplate restTemplate = new RestTemplate(); + String url = baseUrl + + "?serviceId=getComplaintListWithImg&From_date=01/01/2024&To_date=20/08/2024&jsonResp=Yes&UserType=Public&MobileNo=" + + mobileNo + "&PageIndex=null&Status=null&repYear=2024"; + String response = restTemplate.getForObject(url, String.class); + + try { + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(response, new TypeReference>>() { + }); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + + } diff --git a/src/main/java/com/gcc/publicgrievance/controller/ComplaintController.java b/src/main/java/com/gcc/publicgrievance/controller/ComplaintController.java index 0ecd90c..50034ea 100644 --- a/src/main/java/com/gcc/publicgrievance/controller/ComplaintController.java +++ b/src/main/java/com/gcc/publicgrievance/controller/ComplaintController.java @@ -57,182 +57,11 @@ public class ComplaintController { public List> getComplaintDetailsById(@RequestParam String complaintid) { return complaintService.fetchComplaintDetailsById(complaintid); } - // save api - /*@PostMapping("/register") - public ResponseEntity registerComplaint( - - @RequestParam("ComplainantName") String complainantName, - - @RequestParam("ComplainantAddr") String complainantAddr, - - @RequestParam("MobileNo") String mobileNo, - - @RequestParam("Email") String email, - - @RequestParam("ComplaintType") String complaintType, - - @RequestParam("ComplaintTitle") String complaintTitle, - - @RequestParam("ComplaintDetails") String complaintDetails, - - @RequestParam("StreetId") String streetId, - - @RequestParam("Comp_Image") String compImage, - - @RequestParam("latitude") String latitude, - - @RequestParam("longtitude") String longtitude, - - @RequestParam("Landmark") String landmark, - - @RequestParam("gender") String gender) { - - String externalUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice"; // // // - // Build the URI with parameters - UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromHttpUrl(externalUrl) - .queryParam("serviceId", "RegComplaint").queryParam("ComplainantName", complainantName) - .queryParam("ComplainantAddr", complainantAddr).queryParam("MobileNo", mobileNo) - .queryParam("Email", email).queryParam("ComplaintType", complaintType) - .queryParam("ComplaintTitle", complaintTitle).queryParam("ComplaintDetails", complaintDetails) - .queryParam("StreetId", streetId).queryParam("Comp_Image", compImage).queryParam("latitude", latitude) - .queryParam("longtitude", longtitude).queryParam("Landmark", landmark).queryParam("gender", gender); // // - // the - // external API - ResponseEntity response = restTemplate.postForEntity(uriBuilder.toUriString(), null, String.class); // - // // Return the response from the external API - return ResponseEntity.status(response.getStatusCode()).body(response.getBody()); - }*/ - - /* - * @PostMapping("/register") public ResponseEntity - * registerComplaint(@RequestParam("ComplainantName") String complainantName, - * - * @RequestParam("ComplainantAddr") String - * complainantAddr, @RequestParam("MobileNo") String mobileNo, - * - * @RequestParam("Email") String email, @RequestParam("ComplaintType") String - * complaintType, - * - * @RequestParam("ComplaintTitle") String complaintTitle, - * - * @RequestParam("ComplaintDetails") String - * complaintDetails, @RequestParam("StreetId") String streetId, - * - * @RequestParam("Comp_Image") MultipartFile - * compImage, @RequestParam("latitude") String latitude, - * - * @RequestParam("longtitude") String longtitude, @RequestParam("Landmark") - * String landmark, - * - * @RequestParam("gender") String gender) { - * - * String externalUrl = - * "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice"; - * - * // Convert the image to a Base64 string String base64Image = ""; if - * (!compImage.isEmpty()) { try { byte[] imageBytes = compImage.getBytes(); - * base64Image = Base64.getEncoder().encodeToString(imageBytes); } catch - * (IOException e) { return - * ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR). - * body("Error encoding image."); } } - * - * // Build the URI with parameters UriComponentsBuilder uriBuilder = - * UriComponentsBuilder.fromHttpUrl(externalUrl) .queryParam("serviceId", - * "RegComplaint").queryParam("ComplainantName", complainantName) - * .queryParam("ComplainantAddr", complainantAddr).queryParam("MobileNo", - * mobileNo) .queryParam("Email", email).queryParam("ComplaintType", - * complaintType) .queryParam("ComplaintTitle", - * complaintTitle).queryParam("ComplaintDetails", complaintDetails) - * .queryParam("StreetId", streetId).queryParam("Comp_Image", base64Image) // - * Use base64 image here .queryParam("latitude", - * latitude).queryParam("longtitude", longtitude).queryParam("Landmark", - * landmark) .queryParam("gender", gender); - * - * // Make a POST request to the external API ResponseEntity response = - * restTemplate.postForEntity(uriBuilder.toUriString(), null, String.class); - * - * // Return the response from the external API return - * ResponseEntity.status(response.getStatusCode()).body(response.getBody()); - * - * } - */ - /*@PostMapping("/register") - public ResponseEntity registerComplaint( - @RequestParam("ComplainantName") String complainantName, - @RequestParam("ComplainantAddr") String complainantAddr, - @RequestParam("MobileNo") String mobileNo, - @RequestParam("Email") String email, - @RequestParam("ComplaintType") String complaintType, - @RequestParam("ComplaintTitle") String complaintTitle, - @RequestParam("ComplaintDetails") String complaintDetails, - @RequestParam("StreetId") String streetId, - @RequestParam("Comp_Image") String compImage, - @RequestParam("latitude") String latitude, - @RequestParam("longtitude") String longtitude, - @RequestParam("Landmark") String landmark, - @RequestParam("gender") String gender) { - - String externalUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice"; - - try { - // Create the URL object - URL url = new URL(externalUrl); - - // Create the HttpURLConnection object - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); - conn.setDoOutput(true); - - // Create the parameters string - String params = "serviceId=RegComplaint" + - "&ComplainantName=" + URLEncoder.encode(complainantName, "UTF-8") + - "&ComplainantAddr=" + URLEncoder.encode(complainantAddr, "UTF-8") + - "&MobileNo=" + URLEncoder.encode(mobileNo, "UTF-8") + - "&Email=" + URLEncoder.encode(email, "UTF-8") + - "&ComplaintType=" + URLEncoder.encode(complaintType, "UTF-8") + - "&ComplaintTitle=" + URLEncoder.encode(complaintTitle, "UTF-8") + - "&ComplaintDetails=" + URLEncoder.encode(complaintDetails, "UTF-8") + - "&StreetId=" + URLEncoder.encode(streetId, "UTF-8") + - "&Comp_Image=" + URLEncoder.encode(compImage, "UTF-8") + - "&latitude=" + URLEncoder.encode(latitude, "UTF-8") + - "&longtitude=" + URLEncoder.encode(longtitude, "UTF-8") + - "&Landmark=" + URLEncoder.encode(landmark, "UTF-8") + - "&gender=" + URLEncoder.encode(gender, "UTF-8"); - - // Write parameters to request body - try (OutputStream os = conn.getOutputStream()) { - byte[] input = params.getBytes("UTF-8"); - os.write(input, 0, input.length); - } - - // Read the response - int responseCode = conn.getResponseCode(); - BufferedReader reader; - if (responseCode == HttpURLConnection.HTTP_OK) { - reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); - } else { - reader = new BufferedReader(new InputStreamReader(conn.getErrorStream())); - } - - StringBuilder response = new StringBuilder(); - String line; - while ((line = reader.readLine()) != null) { - response.append(line); - } - reader.close(); - - // Return the response from the external API - return ResponseEntity.status(responseCode).body(response.toString()); - - } catch (IOException e) { - e.printStackTrace(); - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("An error occurred while processing the request."); - } + @GetMapping("/api/getComplaintDetailsByMobile") + public List> getComplaintDetailsByMobile(@RequestParam String mobileNo) { + return complaintService.fetchComplaintDetailsByMobile(mobileNo); } - -*/ @PostMapping("/register") public ResponseEntity registerComplaint( @RequestParam(value = "ComplainantName", required = false) String complainantName, @@ -307,5 +136,70 @@ public class ComplaintController { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("An error occurred while processing the request."); } } + + + @PostMapping("/updateComplaint") + public ResponseEntity updateComplaint( + @RequestParam("ComplaintId") String complaintId, + @RequestParam(value = "Message", required = false) String message, + @RequestParam(value = "UserType", required = false) String userType, + @RequestParam(value = "Status", required = false) String status, + @RequestParam(value = "Comp_Image", required = false) String compImage) { + + String externalUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice"; + + try { + // Create the URL object + URL url = new URL(externalUrl); + + // Create the HttpURLConnection object + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("POST"); + conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + conn.setDoOutput(true); + + // Create the parameters string, handling null values + String params = "serviceId=UpdateComplaint"+ + "&ComplaintId=" + URLEncoder.encode(complaintId != null ? complaintId : "", "UTF-8") + + "&Message=" + URLEncoder.encode(message != null ? message : "", "UTF-8") + + "&UserType=" + URLEncoder.encode(userType != null ? userType : "", "UTF-8") + + "&Status=" + URLEncoder.encode(status != null ? status : "", "UTF-8") + + "&Comp_Image=" + URLEncoder.encode(compImage != null ? compImage : "", "UTF-8") + + "&Token=718333469976265947044293"; + + // Write parameters to request body + try (OutputStream os = conn.getOutputStream()) { + byte[] input = params.getBytes("UTF-8"); + os.write(input, 0, input.length); + } + + // Read the response + int responseCode = conn.getResponseCode(); + BufferedReader reader; + if (responseCode == HttpURLConnection.HTTP_OK) { + reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); + } else { + reader = new BufferedReader(new InputStreamReader(conn.getErrorStream())); + } + + StringBuilder response = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + response.append(line); + } + reader.close(); + + // Return the response from the external API + return ResponseEntity.status(responseCode).body(response.toString()); + + } catch (IOException e) { + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("An error occurred while processing the request."); + } + } + + + + } diff --git a/src/main/resources/templates/User/home.html b/src/main/resources/templates/User/home.html index 30e4cd2..e82d8a4 100644 --- a/src/main/resources/templates/User/home.html +++ b/src/main/resources/templates/User/home.html @@ -6,6 +6,9 @@ Main Page + @@ -172,15 +175,41 @@ font-size: 14px; cursor: pointer; } + + /*for radio button style*/ + .radio-group { + display: flex; + align-items: center; + /* Ensures all items are aligned to the center */ + } + + .radio-item { + display: flex; + align-items: center; + margin-right: 20px; + /* Adds space between each radio item */ + } + + .radio-item input[type="radio"] { + margin-right: 10px; + /* Adds space between the radio button and its label */ + vertical-align: middle; + /* Ensures vertical alignment */ + } + + .radio-item label { + margin: 0; + /* Removes any default margins that might affect alignment */ + }
- - -
= +
+
@@ -252,51 +284,147 @@
- + -
-
+ + +
+
+
+ Status +
+
Check Your Complaint Status
+
+ + + + + +
+ + +
+ +
+ + + +
+
+ + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + - - + + + + + + diff --git a/src/main/resources/templates/checklistofficer/checklistofficer.html b/src/main/resources/templates/checklistofficer/checklistofficer.html index 64b31df..8d3bcba 100644 --- a/src/main/resources/templates/checklistofficer/checklistofficer.html +++ b/src/main/resources/templates/checklistofficer/checklistofficer.html @@ -3,11 +3,12 @@ - CheckList Officer + CheckList User + @@ -43,6 +44,29 @@ font-size: medium; transition: font-size 0.3s ease; } + + + .comment-table { + width: 100%; + border-collapse: collapse; + } + + .comment-table td { + padding: 0.5rem; + border: 1px solid #ddd; + /* Light border color */ + } + + .comment-table td:first-child { + width: 25%; + /* Adjust as needed for label column width */ + font-weight: bold; + } + + .comment-table td:nth-child(2) { + width: 75%; + /* Adjust as needed for value column width */ + } @@ -53,9 +77,6 @@
- -
-
-
- Complainant Number: -
-
- Date: -
-
-
-
- Complainant Mode: -
-
- Expiry: -
-
-
1. Complaining Person's Details
+
+ Complainant ID: + +
Complainant Mobile Number: @@ -100,19 +108,16 @@ Complainant Name:
-
- Complainant Email: - -
-
+ +
@@ -155,17 +160,17 @@
-
+
Complainant Description: - +
@@ -179,52 +184,61 @@
+ Complaint Closed Date:
+ Official Name:
- + Status:
+ +
+ + + +
+
Complaint Action History
+
+
+ +
Update Complaint
Change Complaint Status: - + + + +
-
- -
- - - - - -
+ +
- Complainant Locality: + Details of Complaint: + placeholder="Enter complaint details" maxlength="400" required>
@@ -251,14 +265,11 @@