|
|
|
@ -196,6 +196,7 @@ public class Apicontroller { |
|
|
|
@RequestParam MultipartFile c1image, |
|
|
|
@RequestParam MultipartFile c2image, |
|
|
|
@RequestParam String comp_details, |
|
|
|
@RequestParam String streetName, |
|
|
|
@RequestParam String source) throws JsonMappingException, JsonProcessingException { |
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
@ -215,7 +216,7 @@ public class Apicontroller { |
|
|
|
// 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); |
|
|
|
remarks, c1imagePath, c2imagePath, compList, totalTreeCount, source, streetName); |
|
|
|
|
|
|
|
if (saveStatus == null || saveStatus.equals("error")) { |
|
|
|
return ResponseEntity.ok(Map.of( |
|
|
|
@ -352,6 +353,127 @@ public class Apicontroller { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/savedeptpruningform") |
|
|
|
public ResponseEntity<?> deptregisterComplaint( |
|
|
|
@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("========== DEPT 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, |
|
|
|
@ -368,6 +490,8 @@ public class Apicontroller { |
|
|
|
@RequestParam MultipartFile c1image, |
|
|
|
@RequestParam MultipartFile c2image, |
|
|
|
@RequestParam String comp_details, |
|
|
|
@RequestParam String streetName, |
|
|
|
|
|
|
|
@RequestParam String source) throws JsonMappingException, JsonProcessingException { |
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
@ -387,7 +511,7 @@ public class Apicontroller { |
|
|
|
// 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); |
|
|
|
longitude, zone, ward, remarks, c1imagePath, c2imagePath, compList, totalTreeCount, streetName, source); |
|
|
|
|
|
|
|
if (saveStatus == null || saveStatus.equals("error")) { |
|
|
|
return ResponseEntity.ok(Map.of( |
|
|
|
@ -505,8 +629,7 @@ public class Apicontroller { |
|
|
|
"ref_id", saveStatus)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//getpurninglist |
|
|
|
// getpurninglist |
|
|
|
|
|
|
|
@GetMapping("/getpurninglist") |
|
|
|
public List<Map<String, Object>> getpurninglist() { |
|
|
|
@ -515,15 +638,11 @@ public class Apicontroller { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/generatepgrcomplaints") |
|
|
|
@ResponseBody |
|
|
|
public ResponseEntity<?> generatepgrcomplaints(String refid){ |
|
|
|
public ResponseEntity<?> generatepgrcomplaints(String refid) { |
|
|
|
|
|
|
|
return gcservice.generatepgrcomplaints(refid); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |