|
|
@ -1,11 +1,17 @@ |
|
|
package com.gcc.greencommitte.controller; |
|
|
package com.gcc.greencommitte.controller; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedReader; |
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
import java.io.InputStreamReader; |
|
|
|
|
|
import java.io.OutputStream; |
|
|
|
|
|
import java.net.HttpURLConnection; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.Collections; |
|
|
import java.util.Collections; |
|
|
import java.util.HashMap; |
|
|
import java.util.HashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
import java.util.Random; |
|
|
import java.util.Random; |
|
|
|
|
|
import org.springframework.http.*; |
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.http.HttpStatus; |
|
|
import org.springframework.http.HttpStatus; |
|
|
@ -17,6 +23,10 @@ import org.springframework.web.bind.annotation.RequestParam; |
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
import org.springframework.web.client.RestTemplate; |
|
|
import org.springframework.web.client.RestTemplate; |
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
import java.net.URL; |
|
|
|
|
|
import java.net.URLEncoder; |
|
|
|
|
|
import java.util.Base64; |
|
|
|
|
|
//import org.springframework.http.MediaType; |
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
import com.fasterxml.jackson.core.type.TypeReference; |
|
|
import com.fasterxml.jackson.core.type.TypeReference; |
|
|
@ -28,362 +38,470 @@ import com.gcc.greencommitte.service.Greencommitteeservice; |
|
|
import jakarta.servlet.http.HttpServletRequest; |
|
|
import jakarta.servlet.http.HttpServletRequest; |
|
|
import jakarta.servlet.http.HttpSession; |
|
|
import jakarta.servlet.http.HttpSession; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RestController |
|
|
@RestController |
|
|
@RequestMapping("/greencommittee/api") |
|
|
|
|
|
|
|
|
@RequestMapping("/greencommittee/api") |
|
|
public class Apicontroller { |
|
|
public class Apicontroller { |
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private AppConfig appConfig; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private AppConfig appConfig; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private Greencommitteeservice gcservice; |
|
|
private Greencommitteeservice gcservice; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/sendOTP") |
|
|
@GetMapping(value = "/sendOTP") |
|
|
public String sendOtp(HttpServletRequest request, @RequestParam String mobileNo) { |
|
|
|
|
|
|
|
|
public String sendOtp(HttpServletRequest request, @RequestParam String mobileNo) { |
|
|
|
|
|
|
|
|
// Generate OTP logic as before |
|
|
|
|
|
String MobileNo = mobileNo; |
|
|
|
|
|
Random rand = new Random(); |
|
|
|
|
|
int otp = rand.nextInt(90000) + 10000; |
|
|
|
|
|
|
|
|
// Generate OTP logic as before |
|
|
|
|
|
String MobileNo = mobileNo; |
|
|
|
|
|
Random rand = new Random(); |
|
|
|
|
|
int otp = rand.nextInt(90000) + 10000; |
|
|
|
|
|
|
|
|
String key = "pfTEYN6H"; |
|
|
|
|
|
|
|
|
String key = "pfTEYN6H"; |
|
|
String entityId = "1401572690000011081"; |
|
|
String entityId = "1401572690000011081"; |
|
|
String templateId = "1407175765770900925"; |
|
|
String templateId = "1407175765770900925"; |
|
|
String appName="Green Committe"; |
|
|
|
|
|
|
|
|
|
|
|
String generatedMessage = "Welcome to GCC! Your OTP for " + appName + " is " + otp + "."; |
|
|
|
|
|
String urlString = appConfig.getGetOtpUrl() + "from=GCCCRP" + "&key=" + key + "&sender=GCCCRP" + "&to=" + MobileNo + "&body=" |
|
|
|
|
|
+ generatedMessage + "&entityid=" + entityId + "&templateid=" + templateId; |
|
|
|
|
|
|
|
|
|
|
|
System.out.println("\n urlString---: " + urlString); |
|
|
|
|
|
|
|
|
|
|
|
String bodyMessage = ""; |
|
|
|
|
|
try { |
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate(); |
|
|
|
|
|
String Response = restTemplate.getForObject(urlString, String.class); |
|
|
|
|
|
bodyMessage = Response; |
|
|
|
|
|
System.out.println("\n bodyMessage" + bodyMessage); |
|
|
|
|
|
|
|
|
|
|
|
System.out.println("OTP sent successfully!"); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
System.out.print("ERROR---: " + e); |
|
|
|
|
|
bodyMessage = "Error"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HttpSession session = request.getSession(); |
|
|
|
|
|
session.setAttribute("otp", otp); |
|
|
|
|
|
session.setAttribute("mobileNo", mobileNo); |
|
|
|
|
|
return bodyMessage; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String appName = "Green Committe"; |
|
|
|
|
|
|
|
|
|
|
|
String generatedMessage = "Welcome to GCC! Your OTP for " + appName + " is " + otp + "."; |
|
|
|
|
|
String urlString = appConfig.getGetOtpUrl() + "from=GCCCRP" + "&key=" + key + "&sender=GCCCRP" + "&to=" |
|
|
|
|
|
+ MobileNo + "&body=" |
|
|
|
|
|
+ generatedMessage + "&entityid=" + entityId + "&templateid=" + templateId; |
|
|
|
|
|
|
|
|
|
|
|
System.out.println("\n urlString---: " + urlString); |
|
|
|
|
|
|
|
|
|
|
|
String bodyMessage = ""; |
|
|
|
|
|
try { |
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate(); |
|
|
|
|
|
String Response = restTemplate.getForObject(urlString, String.class); |
|
|
|
|
|
bodyMessage = Response; |
|
|
|
|
|
System.out.println("\n bodyMessage" + bodyMessage); |
|
|
|
|
|
|
|
|
|
|
|
System.out.println("OTP sent successfully!"); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
System.out.print("ERROR---: " + e); |
|
|
|
|
|
bodyMessage = "Error"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HttpSession session = request.getSession(); |
|
|
|
|
|
session.setAttribute("otp", otp); |
|
|
|
|
|
session.setAttribute("mobileNo", mobileNo); |
|
|
|
|
|
return bodyMessage; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@GetMapping(value = "/verifyOTP") |
|
|
@GetMapping(value = "/verifyOTP") |
|
|
public String verifyOtp(HttpServletRequest request, @RequestParam String otp) { |
|
|
|
|
|
HttpSession session = request.getSession(); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
Integer session_otp = (Integer) session.getAttribute("otp"); |
|
|
|
|
|
//System.out.println("session_otp---:" + session_otp); |
|
|
|
|
|
Integer entered_otp = Integer.parseInt(otp); |
|
|
|
|
|
|
|
|
|
|
|
if (session_otp != null && session_otp.equals(entered_otp)) { |
|
|
|
|
|
System.out.println("Entered OTP Correct"); |
|
|
|
|
|
session.setAttribute("verifiedotp", "success"); |
|
|
|
|
|
return "Success"; |
|
|
|
|
|
} else { |
|
|
|
|
|
System.out.println("Incorrect OTP. Please enter correct OTPs."); |
|
|
|
|
|
session.setAttribute("verifiedotp", "error"); |
|
|
|
|
|
return "Error"; |
|
|
|
|
|
} |
|
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
|
|
System.out.println("Invalid OTP format: " + otp); |
|
|
|
|
|
return "Error"; |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
System.out.println("Error verifying OTP: " + e.getMessage()); |
|
|
|
|
|
return "Error"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getcompnatureforpublic") |
|
|
|
|
|
public ResponseEntity<?> getCompNatureForPublic(){ |
|
|
|
|
|
try { |
|
|
|
|
|
List<Map<String, Object>> list = gcservice.getCompNatureForPublic(); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> response = new HashMap<>(); |
|
|
|
|
|
response.put("status", "success"); |
|
|
|
|
|
response.put("data", list); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(response); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
|
ex.printStackTrace(); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> error = new HashMap<>(); |
|
|
|
|
|
error.put("status", "error"); |
|
|
|
|
|
error.put("message", ex.getMessage()); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getcompnaturefordept") |
|
|
|
|
|
public ResponseEntity<?> getCompNatureForDept(){ |
|
|
|
|
|
try { |
|
|
|
|
|
List<Map<String, Object>> list = gcservice.getCompNatureForDept(); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> response = new HashMap<>(); |
|
|
|
|
|
response.put("status", "success"); |
|
|
|
|
|
response.put("data", list); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(response); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
|
ex.printStackTrace(); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> error = new HashMap<>(); |
|
|
|
|
|
error.put("status", "error"); |
|
|
|
|
|
error.put("message", ex.getMessage()); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getAllDepts") |
|
|
|
|
|
public ResponseEntity<?> getAllDepts(){ |
|
|
|
|
|
try { |
|
|
|
|
|
List<Map<String, Object>> list = gcservice.getAllDepts(); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> response = new HashMap<>(); |
|
|
|
|
|
response.put("status", "success"); |
|
|
|
|
|
response.put("data", list); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(response); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
|
ex.printStackTrace(); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> error = new HashMap<>(); |
|
|
|
|
|
error.put("status", "error"); |
|
|
|
|
|
error.put("message", ex.getMessage()); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/savepublicform") |
|
|
|
|
|
public ResponseEntity<?> savepublicform( |
|
|
|
|
|
@RequestParam String p_name, |
|
|
|
|
|
@RequestParam String ph_no, |
|
|
|
|
|
@RequestParam String gender, |
|
|
|
|
|
@RequestParam String address, |
|
|
|
|
|
@RequestParam String latitude, |
|
|
|
|
|
@RequestParam String longitude, |
|
|
|
|
|
@RequestParam String zone, |
|
|
|
|
|
@RequestParam String ward, |
|
|
|
|
|
@RequestParam String remarks, |
|
|
|
|
|
@RequestParam MultipartFile c1image, |
|
|
|
|
|
@RequestParam MultipartFile c2image, |
|
|
|
|
|
@RequestParam String comp_details, |
|
|
|
|
|
@RequestParam String source) throws JsonMappingException, JsonProcessingException{ |
|
|
|
|
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
|
|
List<Map<String, Object>> compList = mapper.readValue(comp_details, |
|
|
|
|
|
new TypeReference<List<Map<String, Object>>>() { |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
int totalTreeCount = compList.stream() |
|
|
|
|
|
.mapToInt(item -> Integer.parseInt(item.get("count").toString())) |
|
|
|
|
|
.sum(); |
|
|
|
|
|
|
|
|
|
|
|
String c1imagePath=null; |
|
|
|
|
|
String c2imagePath=null; |
|
|
|
|
|
c1imagePath=gcservice.fileUpload(c1image, "comp_image1"); |
|
|
|
|
|
c2imagePath=gcservice.fileUpload(c2image, "comp_image1"); |
|
|
|
|
|
|
|
|
|
|
|
//System.out.println("======="+latitude+","+longitude); |
|
|
|
|
|
|
|
|
|
|
|
String saveStatus = gcservice.savepublicform(p_name,ph_no,gender,address,latitude,longitude,zone,ward,remarks,c1imagePath,c2imagePath,compList,totalTreeCount,source); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (saveStatus == null || saveStatus.equals("error")) { |
|
|
|
|
|
return ResponseEntity.ok(Map.of( |
|
|
|
|
|
"status", false, |
|
|
|
|
|
"message", "failed", |
|
|
|
|
|
"description", "Failed to save the details" |
|
|
|
|
|
)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(Map.of( |
|
|
|
|
|
"status", true, |
|
|
|
|
|
"message", "success", |
|
|
|
|
|
"description", "Details saved successfully", |
|
|
|
|
|
"ref_id", saveStatus |
|
|
|
|
|
)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/savedeptform") |
|
|
|
|
|
public ResponseEntity<?> savedeptform( |
|
|
|
|
|
@RequestParam String dept_id, |
|
|
|
|
|
@RequestParam (required = false) String dept_name, |
|
|
|
|
|
@RequestParam String ph_no, |
|
|
|
|
|
@RequestParam String designation, |
|
|
|
|
|
@RequestParam String govt_type, |
|
|
|
|
|
@RequestParam String address, |
|
|
|
|
|
@RequestParam String latitude, |
|
|
|
|
|
@RequestParam String longitude, |
|
|
|
|
|
@RequestParam String zone, |
|
|
|
|
|
@RequestParam String ward, |
|
|
|
|
|
@RequestParam String remarks, |
|
|
|
|
|
@RequestParam MultipartFile c1image, |
|
|
|
|
|
@RequestParam MultipartFile c2image, |
|
|
|
|
|
@RequestParam String comp_details, |
|
|
|
|
|
@RequestParam String source) throws JsonMappingException, JsonProcessingException{ |
|
|
|
|
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
|
|
List<Map<String, Object>> compList = mapper.readValue(comp_details, |
|
|
|
|
|
new TypeReference<List<Map<String, Object>>>() { |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
int totalTreeCount = compList.stream() |
|
|
|
|
|
.mapToInt(item -> Integer.parseInt(item.get("count").toString())) |
|
|
|
|
|
.sum(); |
|
|
|
|
|
|
|
|
|
|
|
String c1imagePath=null; |
|
|
|
|
|
String c2imagePath=null; |
|
|
|
|
|
c1imagePath=gcservice.fileUpload(c1image, "comp_image1"); |
|
|
|
|
|
c2imagePath=gcservice.fileUpload(c2image, "comp_image1"); |
|
|
|
|
|
|
|
|
|
|
|
// System.out.println("======="+latitude+","+longitude); |
|
|
|
|
|
|
|
|
|
|
|
String saveStatus = gcservice.savedeptform(dept_id,dept_name,ph_no,designation,govt_type,address,latitude,longitude,zone,ward,remarks,c1imagePath,c2imagePath,compList,totalTreeCount,source); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (saveStatus == null || saveStatus.equals("error")) { |
|
|
|
|
|
return ResponseEntity.ok(Map.of( |
|
|
|
|
|
"status", false, |
|
|
|
|
|
"message", "failed", |
|
|
|
|
|
"description", "Failed to save the details" |
|
|
|
|
|
)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(Map.of( |
|
|
|
|
|
"status", true, |
|
|
|
|
|
"message", "success", |
|
|
|
|
|
"description", "Details saved successfully", |
|
|
|
|
|
"ref_id", saveStatus |
|
|
|
|
|
)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/sendOTPforwithdraw") |
|
|
|
|
|
public String sendOtpforwithdraw(HttpServletRequest request, @RequestParam String mobileNo) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<?> CompDetailsList = gcservice.findByMobileNo(mobileNo); |
|
|
|
|
|
System.out.println("CompDetailsList="+CompDetailsList); |
|
|
|
|
|
if (CompDetailsList == null || CompDetailsList.isEmpty()) { |
|
|
|
|
|
// If the mobile number is not registered, return an error message |
|
|
|
|
|
return "Error: This number is not registered."; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Generate OTP logic as before |
|
|
|
|
|
String MobileNo = mobileNo; |
|
|
|
|
|
Random rand = new Random(); |
|
|
|
|
|
int otp = rand.nextInt(90000) + 10000; |
|
|
|
|
|
|
|
|
|
|
|
String key = "pfTEYN6H"; |
|
|
|
|
|
String entityId = "1401572690000011081"; |
|
|
|
|
|
String templateId = "1407175765770900925"; |
|
|
|
|
|
String appName="Green Committe"; |
|
|
|
|
|
|
|
|
|
|
|
String generatedMessage = "Welcome to GCC! Your OTP for " + appName + " is " + otp + "."; |
|
|
|
|
|
String urlString = appConfig.getGetOtpUrl() + "from=GCCCRP" + "&key=" + key + "&sender=GCCCRP" + "&to=" + MobileNo + "&body=" |
|
|
|
|
|
+ generatedMessage + "&entityid=" + entityId + "&templateid=" + templateId; |
|
|
|
|
|
|
|
|
|
|
|
System.out.println("\n urlString---: " + urlString); |
|
|
|
|
|
|
|
|
|
|
|
String bodyMessage = ""; |
|
|
|
|
|
try { |
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate(); |
|
|
|
|
|
String Response = restTemplate.getForObject(urlString, String.class); |
|
|
|
|
|
bodyMessage = Response; |
|
|
|
|
|
System.out.println("\n bodyMessage" + bodyMessage); |
|
|
|
|
|
|
|
|
|
|
|
System.out.println("OTP sent successfully!"); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
System.out.print("ERROR---: " + e); |
|
|
|
|
|
bodyMessage = "Error"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HttpSession session = request.getSession(); |
|
|
|
|
|
session.setAttribute("otp", otp); |
|
|
|
|
|
session.setAttribute("mobileNo", mobileNo); |
|
|
|
|
|
return bodyMessage; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @GetMapping("/checkwithdraw") |
|
|
|
|
|
// public List<Map<String, Object>> checkWithdrawByMobileNumber(@RequestParam String mobile_num){ |
|
|
|
|
|
// |
|
|
|
|
|
// return gcservice.checkwithdraw(mobile_num); |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/checkwithdraw") |
|
|
|
|
|
public List<Map<String, Object>> checkWithdrawByMobileNumber(@RequestParam String mobile_num) { |
|
|
|
|
|
|
|
|
|
|
|
List<String> refnums = gcservice.getrefnums(mobile_num); |
|
|
|
|
|
System.out.println("refnums="+refnums); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> wrapper = new HashMap<>(); |
|
|
|
|
|
List<Map<String, Object>> finalList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
if (refnums.isEmpty()) { |
|
|
|
|
|
wrapper.put("message", "Empty List"); |
|
|
|
|
|
wrapper.put("status", "Success"); |
|
|
|
|
|
return Collections.singletonList(wrapper); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (String ref : refnums) { |
|
|
|
|
|
System.out.println("ref="+ref); |
|
|
|
|
|
Map<String, Object> data = gcservice.getfulldetailsdata(ref); |
|
|
|
|
|
if (data != null && !data.isEmpty()) { |
|
|
|
|
|
finalList.add(data); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
wrapper.put("data", finalList); |
|
|
|
|
|
wrapper.put("message", "Complaint List"); |
|
|
|
|
|
wrapper.put("status", "Success"); |
|
|
|
|
|
|
|
|
|
|
|
return Collections.singletonList(wrapper); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/withdraw") |
|
|
|
|
|
public ResponseEntity<?> withdraw(@RequestParam String id,@RequestParam String remarks) |
|
|
|
|
|
{ |
|
|
|
|
|
String saveStatus=gcservice.withdraw(id,remarks); |
|
|
|
|
|
|
|
|
|
|
|
if (saveStatus == null || saveStatus.equals("error")) { |
|
|
|
|
|
return ResponseEntity.ok(Map.of( |
|
|
|
|
|
"status", false, |
|
|
|
|
|
"message", "failed", |
|
|
|
|
|
"description", "Failed to withdraw the Complaint" |
|
|
|
|
|
)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(Map.of( |
|
|
|
|
|
"status", true, |
|
|
|
|
|
"message", "success", |
|
|
|
|
|
"description", "Application withdrawn successfully", |
|
|
|
|
|
"ref_id", saveStatus |
|
|
|
|
|
)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String verifyOtp(HttpServletRequest request, @RequestParam String otp) { |
|
|
|
|
|
HttpSession session = request.getSession(); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
Integer session_otp = (Integer) session.getAttribute("otp"); |
|
|
|
|
|
// System.out.println("session_otp---:" + session_otp); |
|
|
|
|
|
Integer entered_otp = Integer.parseInt(otp); |
|
|
|
|
|
|
|
|
|
|
|
if (session_otp != null && session_otp.equals(entered_otp)) { |
|
|
|
|
|
System.out.println("Entered OTP Correct"); |
|
|
|
|
|
session.setAttribute("verifiedotp", "success"); |
|
|
|
|
|
return "Success"; |
|
|
|
|
|
} else { |
|
|
|
|
|
System.out.println("Incorrect OTP. Please enter correct OTPs."); |
|
|
|
|
|
session.setAttribute("verifiedotp", "error"); |
|
|
|
|
|
return "Error"; |
|
|
|
|
|
} |
|
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
|
|
System.out.println("Invalid OTP format: " + otp); |
|
|
|
|
|
return "Error"; |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
System.out.println("Error verifying OTP: " + e.getMessage()); |
|
|
|
|
|
return "Error"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getcompnatureforpublic") |
|
|
|
|
|
public ResponseEntity<?> getCompNatureForPublic() { |
|
|
|
|
|
try { |
|
|
|
|
|
List<Map<String, Object>> list = gcservice.getCompNatureForPublic(); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> response = new HashMap<>(); |
|
|
|
|
|
response.put("status", "success"); |
|
|
|
|
|
response.put("data", list); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(response); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
|
ex.printStackTrace(); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> error = new HashMap<>(); |
|
|
|
|
|
error.put("status", "error"); |
|
|
|
|
|
error.put("message", ex.getMessage()); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getcompnaturefordept") |
|
|
|
|
|
public ResponseEntity<?> getCompNatureForDept() { |
|
|
|
|
|
try { |
|
|
|
|
|
List<Map<String, Object>> list = gcservice.getCompNatureForDept(); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> response = new HashMap<>(); |
|
|
|
|
|
response.put("status", "success"); |
|
|
|
|
|
response.put("data", list); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(response); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
|
ex.printStackTrace(); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> error = new HashMap<>(); |
|
|
|
|
|
error.put("status", "error"); |
|
|
|
|
|
error.put("message", ex.getMessage()); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getAllDepts") |
|
|
|
|
|
public ResponseEntity<?> getAllDepts() { |
|
|
|
|
|
try { |
|
|
|
|
|
List<Map<String, Object>> list = gcservice.getAllDepts(); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> response = new HashMap<>(); |
|
|
|
|
|
response.put("status", "success"); |
|
|
|
|
|
response.put("data", list); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(response); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
|
ex.printStackTrace(); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> error = new HashMap<>(); |
|
|
|
|
|
error.put("status", "error"); |
|
|
|
|
|
error.put("message", ex.getMessage()); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/savepublicform") |
|
|
|
|
|
public ResponseEntity<?> savepublicform( |
|
|
|
|
|
@RequestParam String p_name, |
|
|
|
|
|
@RequestParam String ph_no, |
|
|
|
|
|
@RequestParam String gender, |
|
|
|
|
|
@RequestParam String address, |
|
|
|
|
|
@RequestParam String latitude, |
|
|
|
|
|
@RequestParam String longitude, |
|
|
|
|
|
@RequestParam String zone, |
|
|
|
|
|
@RequestParam String ward, |
|
|
|
|
|
@RequestParam String remarks, |
|
|
|
|
|
@RequestParam MultipartFile c1image, |
|
|
|
|
|
@RequestParam MultipartFile c2image, |
|
|
|
|
|
@RequestParam String comp_details, |
|
|
|
|
|
@RequestParam String source) throws JsonMappingException, JsonProcessingException { |
|
|
|
|
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
|
|
List<Map<String, Object>> compList = mapper.readValue(comp_details, |
|
|
|
|
|
new TypeReference<List<Map<String, Object>>>() { |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
int totalTreeCount = compList.stream() |
|
|
|
|
|
.mapToInt(item -> Integer.parseInt(item.get("count").toString())) |
|
|
|
|
|
.sum(); |
|
|
|
|
|
|
|
|
|
|
|
String c1imagePath = null; |
|
|
|
|
|
String c2imagePath = null; |
|
|
|
|
|
c1imagePath = gcservice.fileUpload(c1image, "comp_image1"); |
|
|
|
|
|
c2imagePath = gcservice.fileUpload(c2image, "comp_image1"); |
|
|
|
|
|
|
|
|
|
|
|
// System.out.println("======="+latitude+","+longitude); |
|
|
|
|
|
|
|
|
|
|
|
String saveStatus = gcservice.savepublicform(p_name, ph_no, gender, address, latitude, longitude, zone, ward, |
|
|
|
|
|
remarks, c1imagePath, c2imagePath, compList, totalTreeCount, source); |
|
|
|
|
|
|
|
|
|
|
|
if (saveStatus == null || saveStatus.equals("error")) { |
|
|
|
|
|
return ResponseEntity.ok(Map.of( |
|
|
|
|
|
"status", false, |
|
|
|
|
|
"message", "failed", |
|
|
|
|
|
"description", "Failed to save the details")); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(Map.of( |
|
|
|
|
|
"status", true, |
|
|
|
|
|
"message", "success", |
|
|
|
|
|
"description", "Details saved successfully", |
|
|
|
|
|
"ref_id", saveStatus)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/savepruningform") |
|
|
|
|
|
public ResponseEntity<?> registerComplaint( |
|
|
|
|
|
@RequestParam(value = "p_name", required = false) String complainantName, |
|
|
|
|
|
@RequestParam(value = "address", required = false) String complainantAddr, |
|
|
|
|
|
@RequestParam(value = "ph_no", required = false) String mobileNo, |
|
|
|
|
|
@RequestParam(value = "Email", required = false) String email, |
|
|
|
|
|
@RequestParam(value = "ComplaintType", required = false) String complaintType, |
|
|
|
|
|
@RequestParam(value = "ComplaintTitle", required = false) String complaintTitle, |
|
|
|
|
|
@RequestParam(value = "remarks", required = false) String complaintDetails, |
|
|
|
|
|
@RequestParam(value = "StreetId", required = false) String streetId, |
|
|
|
|
|
@RequestParam(value = "c1image", required = false) MultipartFile compImage, |
|
|
|
|
|
@RequestParam(value = "latitude", required = false) String latitude, |
|
|
|
|
|
@RequestParam(value = "longitude", required = false) String longtitude, |
|
|
|
|
|
@RequestParam(value = "Landmark", required = false) String landmark, |
|
|
|
|
|
@RequestParam(value = "gender", required = false) String gender) { |
|
|
|
|
|
complaintType = "454"; |
|
|
|
|
|
complaintTitle = "Tree Pruning"; |
|
|
|
|
|
System.out.println("========== Incoming Request =========="); |
|
|
|
|
|
System.out.println("Complainant Name : " + complainantName); |
|
|
|
|
|
System.out.println("Address : " + complainantAddr); |
|
|
|
|
|
System.out.println("Mobile No : " + mobileNo); |
|
|
|
|
|
System.out.println("Email : " + email); |
|
|
|
|
|
System.out.println("Complaint Type : " + complaintType); |
|
|
|
|
|
System.out.println("Complaint Title : " + complaintTitle); |
|
|
|
|
|
System.out.println("Complaint Details: " + complaintDetails); |
|
|
|
|
|
System.out.println("Street ID : " + streetId); |
|
|
|
|
|
System.out.println("Latitude : " + latitude); |
|
|
|
|
|
System.out.println("Longitude : " + longtitude); |
|
|
|
|
|
System.out.println("Landmark : " + landmark); |
|
|
|
|
|
System.out.println("Gender : " + gender); |
|
|
|
|
|
|
|
|
|
|
|
String externalUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice"; |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
URL url = new URL(externalUrl); |
|
|
|
|
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); |
|
|
|
|
|
conn.setRequestMethod("POST"); |
|
|
|
|
|
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); |
|
|
|
|
|
conn.setDoOutput(true); |
|
|
|
|
|
|
|
|
|
|
|
// 1) Convert MultipartFile to Base64 string |
|
|
|
|
|
String compImageBase64 = ""; |
|
|
|
|
|
if (compImage != null && !compImage.isEmpty()) { |
|
|
|
|
|
byte[] bytes = compImage.getBytes(); |
|
|
|
|
|
compImageBase64 = Base64.getEncoder().encodeToString(bytes); |
|
|
|
|
|
} |
|
|
|
|
|
System.out.println("compImage.." + compImage); |
|
|
|
|
|
|
|
|
|
|
|
String params = "serviceId=RegComplaint" + |
|
|
|
|
|
"&ComplainantName=" + URLEncoder.encode(complainantName != null ? complainantName : "", "UTF-8") + |
|
|
|
|
|
"&ComplainantAddr=" + URLEncoder.encode(complainantAddr != null ? complainantAddr : "", "UTF-8") + |
|
|
|
|
|
"&MobileNo=" + URLEncoder.encode(mobileNo != null ? mobileNo : "", "UTF-8") + |
|
|
|
|
|
"&Email=" + URLEncoder.encode(email != null ? email : "", "UTF-8") + |
|
|
|
|
|
"&ComplaintType=" + URLEncoder.encode(complaintType != null ? complaintType : "", "UTF-8") + |
|
|
|
|
|
"&ComplaintTitle=" + URLEncoder.encode(complaintTitle != null ? complaintTitle : "", "UTF-8") + |
|
|
|
|
|
"&ComplaintDetails=" + URLEncoder.encode(complaintDetails != null ? complaintDetails : "", "UTF-8") |
|
|
|
|
|
+ |
|
|
|
|
|
"&StreetId=" + URLEncoder.encode(streetId != null ? streetId : "", "UTF-8") + |
|
|
|
|
|
"&Comp_Image=" + URLEncoder.encode(compImageBase64, "UTF-8") + |
|
|
|
|
|
"&latitude=" + URLEncoder.encode(latitude != null ? latitude : "", "UTF-8") + |
|
|
|
|
|
"&longtitude=" + URLEncoder.encode(longtitude != null ? longtitude : "", "UTF-8") + |
|
|
|
|
|
"&Landmark=" + URLEncoder.encode(landmark != null ? landmark : "", "UTF-8") + |
|
|
|
|
|
"&gender=" + URLEncoder.encode(gender != null ? gender : "", "UTF-8") + |
|
|
|
|
|
"&compmode=1"; |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* System.out.println("========================================"); |
|
|
|
|
|
* System.out.println("External URL : " + externalUrl); |
|
|
|
|
|
* |
|
|
|
|
|
* System.out.println("========================================"); |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
try (OutputStream os = conn.getOutputStream()) { |
|
|
|
|
|
byte[] input = params.getBytes("UTF-8"); |
|
|
|
|
|
os.write(input, 0, input.length); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int responseCode = conn.getResponseCode(); |
|
|
|
|
|
System.out.println("responseCode" + responseCode); |
|
|
|
|
|
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); |
|
|
|
|
|
System.out.println("response" + response); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
reader.close(); |
|
|
|
|
|
|
|
|
|
|
|
// ✅ Parse and return only the complaint number |
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
|
|
Map<String, String> responseMap = mapper.readValue(response.toString(), Map.class); |
|
|
|
|
|
System.out.println("responseMap" + responseMap); |
|
|
|
|
|
|
|
|
|
|
|
String complaintNo = responseMap.getOrDefault("Complaint Number", "N/A"); |
|
|
|
|
|
System.out.println("complaintNo====" + complaintNo); |
|
|
|
|
|
return ResponseEntity.ok( |
|
|
|
|
|
Map.of( |
|
|
|
|
|
"status", true, |
|
|
|
|
|
"complaintNumber", complaintNo)); |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* return ResponseEntity.ok() |
|
|
|
|
|
* .contentType(MediaType.APPLICATION_JSON).body(Map.of("complaintNumber", |
|
|
|
|
|
* complaintNo)); |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|
|
|
|
|
.body(Map.of("error", "An error occurred while processing the request.")); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/savedeptform") |
|
|
|
|
|
public ResponseEntity<?> savedeptform( |
|
|
|
|
|
@RequestParam String dept_id, |
|
|
|
|
|
@RequestParam(required = false) String dept_name, |
|
|
|
|
|
@RequestParam String ph_no, |
|
|
|
|
|
@RequestParam String designation, |
|
|
|
|
|
@RequestParam String govt_type, |
|
|
|
|
|
@RequestParam String address, |
|
|
|
|
|
@RequestParam String latitude, |
|
|
|
|
|
@RequestParam String longitude, |
|
|
|
|
|
@RequestParam String zone, |
|
|
|
|
|
@RequestParam String ward, |
|
|
|
|
|
@RequestParam String remarks, |
|
|
|
|
|
@RequestParam MultipartFile c1image, |
|
|
|
|
|
@RequestParam MultipartFile c2image, |
|
|
|
|
|
@RequestParam String comp_details, |
|
|
|
|
|
@RequestParam String source) throws JsonMappingException, JsonProcessingException { |
|
|
|
|
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
|
|
List<Map<String, Object>> compList = mapper.readValue(comp_details, |
|
|
|
|
|
new TypeReference<List<Map<String, Object>>>() { |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
int totalTreeCount = compList.stream() |
|
|
|
|
|
.mapToInt(item -> Integer.parseInt(item.get("count").toString())) |
|
|
|
|
|
.sum(); |
|
|
|
|
|
|
|
|
|
|
|
String c1imagePath = null; |
|
|
|
|
|
String c2imagePath = null; |
|
|
|
|
|
c1imagePath = gcservice.fileUpload(c1image, "comp_image1"); |
|
|
|
|
|
c2imagePath = gcservice.fileUpload(c2image, "comp_image1"); |
|
|
|
|
|
|
|
|
|
|
|
// System.out.println("======="+latitude+","+longitude); |
|
|
|
|
|
|
|
|
|
|
|
String saveStatus = gcservice.savedeptform(dept_id, dept_name, ph_no, designation, govt_type, address, latitude, |
|
|
|
|
|
longitude, zone, ward, remarks, c1imagePath, c2imagePath, compList, totalTreeCount, source); |
|
|
|
|
|
|
|
|
|
|
|
if (saveStatus == null || saveStatus.equals("error")) { |
|
|
|
|
|
return ResponseEntity.ok(Map.of( |
|
|
|
|
|
"status", false, |
|
|
|
|
|
"message", "failed", |
|
|
|
|
|
"description", "Failed to save the details")); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(Map.of( |
|
|
|
|
|
"status", true, |
|
|
|
|
|
"message", "success", |
|
|
|
|
|
"description", "Details saved successfully", |
|
|
|
|
|
"ref_id", saveStatus)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/sendOTPforwithdraw") |
|
|
|
|
|
public String sendOtpforwithdraw(HttpServletRequest request, @RequestParam String mobileNo) { |
|
|
|
|
|
|
|
|
|
|
|
List<?> CompDetailsList = gcservice.findByMobileNo(mobileNo); |
|
|
|
|
|
System.out.println("CompDetailsList=" + CompDetailsList); |
|
|
|
|
|
if (CompDetailsList == null || CompDetailsList.isEmpty()) { |
|
|
|
|
|
// If the mobile number is not registered, return an error message |
|
|
|
|
|
return "Error: This number is not registered."; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Generate OTP logic as before |
|
|
|
|
|
String MobileNo = mobileNo; |
|
|
|
|
|
Random rand = new Random(); |
|
|
|
|
|
int otp = rand.nextInt(90000) + 10000; |
|
|
|
|
|
|
|
|
|
|
|
String key = "pfTEYN6H"; |
|
|
|
|
|
String entityId = "1401572690000011081"; |
|
|
|
|
|
String templateId = "1407175765770900925"; |
|
|
|
|
|
String appName = "Green Committe"; |
|
|
|
|
|
|
|
|
|
|
|
String generatedMessage = "Welcome to GCC! Your OTP for " + appName + " is " + otp + "."; |
|
|
|
|
|
String urlString = appConfig.getGetOtpUrl() + "from=GCCCRP" + "&key=" + key + "&sender=GCCCRP" + "&to=" |
|
|
|
|
|
+ MobileNo + "&body=" |
|
|
|
|
|
+ generatedMessage + "&entityid=" + entityId + "&templateid=" + templateId; |
|
|
|
|
|
|
|
|
|
|
|
System.out.println("\n urlString---: " + urlString); |
|
|
|
|
|
|
|
|
|
|
|
String bodyMessage = ""; |
|
|
|
|
|
try { |
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate(); |
|
|
|
|
|
String Response = restTemplate.getForObject(urlString, String.class); |
|
|
|
|
|
bodyMessage = Response; |
|
|
|
|
|
System.out.println("\n bodyMessage" + bodyMessage); |
|
|
|
|
|
|
|
|
|
|
|
System.out.println("OTP sent successfully!"); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
System.out.print("ERROR---: " + e); |
|
|
|
|
|
bodyMessage = "Error"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HttpSession session = request.getSession(); |
|
|
|
|
|
session.setAttribute("otp", otp); |
|
|
|
|
|
session.setAttribute("mobileNo", mobileNo); |
|
|
|
|
|
return bodyMessage; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// @GetMapping("/checkwithdraw") |
|
|
|
|
|
// public List<Map<String, Object>> checkWithdrawByMobileNumber(@RequestParam |
|
|
|
|
|
// String mobile_num){ |
|
|
|
|
|
// |
|
|
|
|
|
// return gcservice.checkwithdraw(mobile_num); |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/checkwithdraw") |
|
|
|
|
|
public List<Map<String, Object>> checkWithdrawByMobileNumber(@RequestParam String mobile_num) { |
|
|
|
|
|
|
|
|
|
|
|
List<String> refnums = gcservice.getrefnums(mobile_num); |
|
|
|
|
|
System.out.println("refnums=" + refnums); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> wrapper = new HashMap<>(); |
|
|
|
|
|
List<Map<String, Object>> finalList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
if (refnums.isEmpty()) { |
|
|
|
|
|
wrapper.put("message", "Empty List"); |
|
|
|
|
|
wrapper.put("status", "Success"); |
|
|
|
|
|
return Collections.singletonList(wrapper); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (String ref : refnums) { |
|
|
|
|
|
System.out.println("ref=" + ref); |
|
|
|
|
|
Map<String, Object> data = gcservice.getfulldetailsdata(ref); |
|
|
|
|
|
if (data != null && !data.isEmpty()) { |
|
|
|
|
|
finalList.add(data); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
wrapper.put("data", finalList); |
|
|
|
|
|
wrapper.put("message", "Complaint List"); |
|
|
|
|
|
wrapper.put("status", "Success"); |
|
|
|
|
|
|
|
|
|
|
|
return Collections.singletonList(wrapper); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/withdraw") |
|
|
|
|
|
public ResponseEntity<?> withdraw(@RequestParam String id, @RequestParam String remarks) { |
|
|
|
|
|
String saveStatus = gcservice.withdraw(id, remarks); |
|
|
|
|
|
|
|
|
|
|
|
if (saveStatus == null || saveStatus.equals("error")) { |
|
|
|
|
|
return ResponseEntity.ok(Map.of( |
|
|
|
|
|
"status", false, |
|
|
|
|
|
"message", "failed", |
|
|
|
|
|
"description", "Failed to withdraw the Complaint")); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(Map.of( |
|
|
|
|
|
"status", true, |
|
|
|
|
|
"message", "success", |
|
|
|
|
|
"description", "Application withdrawn successfully", |
|
|
|
|
|
"ref_id", saveStatus)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |