Browse Source

implemented department side and enhancement for public form

master
AJITHKUMAR12 2 months ago
parent
commit
ab8d7a9e0c
  1. BIN
      gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025124945_bird.jpg
  2. BIN
      gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025124945_duck-7406987.jpg
  3. BIN
      gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025130138_bird.jpg
  4. BIN
      gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025130138_joban-khangura-hG8B9pKiilw-unsplash.jpg
  5. BIN
      gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025130247_bird.jpg
  6. BIN
      gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025130247_duck-7406987.jpg
  7. BIN
      gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025160944_sc1.jpeg
  8. BIN
      gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025161152_sc1.jpeg
  9. BIN
      gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025161603_sc1.jpeg
  10. BIN
      gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025161755_sc1.jpeg
  11. BIN
      gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025162323_sc1.jpeg
  12. BIN
      gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025162414_sc1.jpeg
  13. BIN
      gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_29122025110136_sc1.jpeg
  14. BIN
      gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_29122025112848_sc1.jpeg
  15. BIN
      gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_29122025113046_sc1.jpeg
  16. BIN
      gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_02012026134533_sample1.jpg
  17. BIN
      gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_02012026134650_sample1.jpg
  18. BIN
      gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_02012026165041_newuser.jpg
  19. BIN
      gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_02012026165137_newuser.jpg
  20. BIN
      gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_02012026165232_newuser.jpg
  21. BIN
      gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_12012026113726_MacBookPro14_-1.jpg
  22. BIN
      gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_12012026113726_sample1.jpg
  23. BIN
      gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_12012026115813_MacBookPro14_-1.jpg
  24. BIN
      gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_12012026115813_sample1.jpg
  25. BIN
      gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_12012026132432_MacBookPro14_-1.jpg
  26. BIN
      gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_12012026132432_sample1.jpg
  27. BIN
      gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_22012026125708_newuser.jpg
  28. BIN
      gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_22012026125832_newuser.jpg
  29. 137
      src/main/java/com/gcc/greencommitte/controller/Apicontroller.java
  30. 630
      src/main/java/com/gcc/greencommitte/service/Greencommitteeservice.java
  31. 2
      src/main/resources/application.properties
  32. 762
      src/main/resources/templates/modules/department/form.html
  33. 116
      src/main/resources/templates/modules/public/form.html

BIN
gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025124945_bird.jpg

Before

Width: 1280  |  Height: 897  |  Size: 191 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025124945_duck-7406987.jpg

Before

Width: 5401  |  Height: 3601  |  Size: 3.2 MiB

BIN
gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025130138_bird.jpg

Before

Width: 1280  |  Height: 897  |  Size: 191 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025130138_joban-khangura-hG8B9pKiilw-unsplash.jpg

Before

Width: 2400  |  Height: 3001  |  Size: 2.5 MiB

BIN
gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025130247_bird.jpg

Before

Width: 1280  |  Height: 897  |  Size: 191 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025130247_duck-7406987.jpg

Before

Width: 5401  |  Height: 3601  |  Size: 3.2 MiB

BIN
gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025160944_sc1.jpeg

Before

Width: 781  |  Height: 218  |  Size: 32 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025161152_sc1.jpeg

Before

Width: 781  |  Height: 218  |  Size: 32 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025161603_sc1.jpeg

Before

Width: 781  |  Height: 218  |  Size: 32 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025161755_sc1.jpeg

Before

Width: 781  |  Height: 218  |  Size: 32 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025162323_sc1.jpeg

Before

Width: 781  |  Height: 218  |  Size: 32 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_27122025162414_sc1.jpeg

Before

Width: 781  |  Height: 218  |  Size: 32 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_29122025110136_sc1.jpeg

Before

Width: 781  |  Height: 218  |  Size: 32 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_29122025112848_sc1.jpeg

Before

Width: 781  |  Height: 218  |  Size: 32 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2025/12/comp_image1_29122025113046_sc1.jpeg

Before

Width: 781  |  Height: 218  |  Size: 32 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_02012026134533_sample1.jpg

Before

Width: 1181  |  Height: 781  |  Size: 278 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_02012026134650_sample1.jpg

Before

Width: 1181  |  Height: 781  |  Size: 278 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_02012026165041_newuser.jpg

Before

Width: 1440  |  Height: 1482  |  Size: 102 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_02012026165137_newuser.jpg

Before

Width: 1440  |  Height: 1482  |  Size: 102 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_02012026165232_newuser.jpg

Before

Width: 1440  |  Height: 1482  |  Size: 102 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_12012026113726_MacBookPro14_-1.jpg

Before

Width: 1512  |  Height: 982  |  Size: 515 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_12012026113726_sample1.jpg

Before

Width: 1181  |  Height: 781  |  Size: 278 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_12012026115813_MacBookPro14_-1.jpg

Before

Width: 1512  |  Height: 982  |  Size: 515 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_12012026115813_sample1.jpg

Before

Width: 1181  |  Height: 781  |  Size: 278 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_12012026132432_MacBookPro14_-1.jpg

Before

Width: 1512  |  Height: 982  |  Size: 515 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_12012026132432_sample1.jpg

Before

Width: 1181  |  Height: 781  |  Size: 278 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_22012026125708_newuser.jpg

Before

Width: 1440  |  Height: 1482  |  Size: 102 KiB

BIN
gcc_mobile_service_uploads/green_committee_files/2026/01/comp_image1_22012026125832_newuser.jpg

Before

Width: 1440  |  Height: 1482  |  Size: 102 KiB

137
src/main/java/com/gcc/greencommitte/controller/Apicontroller.java

@ -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);
}
}

630
src/main/java/com/gcc/greencommitte/service/Greencommitteeservice.java

@ -24,7 +24,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
@ -43,8 +42,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.gcc.greencommitte.config.AppConfig;
@Service
public class Greencommitteeservice {
@ -61,7 +58,7 @@ public class Greencommitteeservice {
}
public List<Map<String, Object>> getCompNatureForPublic() {
String sql="SELECT * FROM comp_nature WHERE category='public' AND is_active=1 AND is_delete=0";
String sql = "SELECT * FROM comp_nature WHERE category='public' AND is_active=1 AND is_delete=0";
try {
return jdbcTemplate.queryForList(sql);
} catch (Exception ex) {
@ -71,7 +68,7 @@ public class Greencommitteeservice {
}
public List<Map<String, Object>> getCompNatureForDept() {
String sql="SELECT * FROM comp_nature WHERE category='dept' AND is_active=1 AND is_delete=0";
String sql = "SELECT * FROM comp_nature WHERE category='dept' AND is_active=1 AND is_delete=0";
try {
return jdbcTemplate.queryForList(sql);
} catch (Exception ex) {
@ -81,7 +78,7 @@ public class Greencommitteeservice {
}
public List<Map<String, Object>> getAllDepts() {
String sql="SELECT * FROM dept_master WHERE is_active=1 AND is_delete=0";
String sql = "SELECT * FROM dept_master WHERE is_active=1 AND is_delete=0";
try {
return jdbcTemplate.queryForList(sql);
} catch (Exception ex) {
@ -126,7 +123,7 @@ public class Greencommitteeservice {
Files.write(path, bytes);
//System.out.println(filePath);
// System.out.println(filePath);
return filepath_txt;
} catch (IOException e) {
@ -136,16 +133,18 @@ public class Greencommitteeservice {
}
@Transactional
public String savepublicform(String p_name, String ph_no, String gender, String address,String latitude,String longitude, String zone, String ward,String remarks,
String c1imagePath, String c2imagePath, List<Map<String, Object>> compList,int totalTreeCount ,String source) {
public String savepublicform(String p_name, String ph_no, String gender, String address, String latitude,
String longitude, String zone, String ward, String remarks,
String c1imagePath, String c2imagePath, List<Map<String, Object>> compList, int totalTreeCount,
String source, String streetName) {
String cby="public";
String cby = "public";
String remarksVal = (remarks != null && !remarks.isEmpty()) ? remarks : null;
String sql = "INSERT INTO reg_details ("
+ "cby,p_name,ph_no,gender,address,zone,ward,total_trees,remarks,latitude,longitude,source "
+ ") VALUES (?,?, ?, ?, ?, ?, ?, ?,?,?,?,?)";
+ "cby,p_name,ph_no,gender,address,zone,ward,total_trees,remarks,latitude,longitude,source,street_name "
+ ") VALUES (?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?)";
KeyHolder keyHolder = new GeneratedKeyHolder();
@ -161,25 +160,26 @@ public class Greencommitteeservice {
ps.setString(7, ward);
ps.setInt(8, totalTreeCount);
ps.setString(9, remarksVal);
ps.setString(10,latitude );
ps.setString(11,longitude);
ps.setString(12,source);
ps.setString(10, latitude);
ps.setString(11, longitude);
ps.setString(12, source);
ps.setString(13, streetName);
return ps;
}, keyHolder);
//return keyHolder.getKey().intValue();
// return keyHolder.getKey().intValue();
if (result > 0) {
int generatedId = keyHolder.getKey().intValue();
String prefix = "GC"+LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
String prefix = "GC" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
String refId = prefix + generatedId;
String updateSql = "UPDATE reg_details SET ref_id = ? WHERE id = ? ";
jdbcTemplate.update(updateSql,refId, generatedId);
jdbcTemplate.update(updateSql, refId, generatedId);
String img1sql="INSERT INTO img_uploads (ref_id,img_path) VALUES (?,?)";
jdbcTemplate.update(img1sql,refId, c1imagePath);
String img1sql = "INSERT INTO img_uploads (ref_id,img_path) VALUES (?,?)";
jdbcTemplate.update(img1sql, refId, c1imagePath);
String img2sql="INSERT INTO img_uploads (ref_id,img_path) VALUES (?,?)";
jdbcTemplate.update(img2sql,refId, c2imagePath);
String img2sql = "INSERT INTO img_uploads (ref_id,img_path) VALUES (?,?)";
jdbcTemplate.update(img2sql, refId, c2imagePath);
String compSql = "INSERT INTO complaint_details (ref_id, comp_nature_id, no_of_trees) "
+ "VALUES (?, ?, ?)";
@ -193,7 +193,7 @@ public class Greencommitteeservice {
return refId;
}
//return "error";
// return "error";
} catch (Exception e) {
e.printStackTrace();
}
@ -203,18 +203,20 @@ public class Greencommitteeservice {
@Transactional
public String savedeptform(String dept_id, String dept_name, String ph_no, String designation, String govt_type,
String address,String latitude,String longitude, String zone, String ward, String remarks, String c1imagePath, String c2imagePath,
List<Map<String, Object>> compList, int totalTreeCount,String source) {
String address, String latitude, String longitude, String zone, String ward, String remarks,
String c1imagePath, String c2imagePath,
List<Map<String, Object>> compList, int totalTreeCount, String streetName, String source) {
String cby="department";
String cby = "department";
int deptIdInt = Integer.parseInt(dept_id);
System.out.println("address = " + address);
System.out.println("streetName = " + streetName);
String remarksVal = (remarks != null && !remarks.isEmpty()) ? remarks : null;
String sql = "INSERT INTO reg_details ("
+ "cby,dept_id,dept_name,govt_type,designation,ph_no,address,zone,ward,total_trees,remarks,latitude,longitude,source "
+ ") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+ "cby,dept_id,dept_name,govt_type,designation,ph_no,address,zone,ward,total_trees,remarks,latitude,longitude,street_name,source "
+ ") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
KeyHolder keyHolder = new GeneratedKeyHolder();
@ -232,25 +234,27 @@ public class Greencommitteeservice {
ps.setString(9, ward);
ps.setInt(10, totalTreeCount);
ps.setString(11, remarksVal);
ps.setString(12,latitude );
ps.setString(13,longitude);
ps.setString(14,source);
ps.setString(12, latitude);
ps.setString(13, longitude);
ps.setString(14, streetName);
ps.setString(15, source);
return ps;
}, keyHolder);
//return keyHolder.getKey().intValue();
// return keyHolder.getKey().intValue();
if (result > 0) {
int generatedId = keyHolder.getKey().intValue();
String prefix = "GC"+LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
String prefix = "GC" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
String refId = prefix + generatedId;
String updateSql = "UPDATE reg_details SET ref_id = ? WHERE id = ? ";
jdbcTemplate.update(updateSql,refId, generatedId);
jdbcTemplate.update(updateSql, refId, generatedId);
String img1sql="INSERT INTO img_uploads (ref_id,img_path) VALUES (?,?)";
jdbcTemplate.update(img1sql,refId, c1imagePath);
String img1sql = "INSERT INTO img_uploads (ref_id,img_path) VALUES (?,?)";
jdbcTemplate.update(img1sql, refId, c1imagePath);
String img2sql="INSERT INTO img_uploads (ref_id,img_path) VALUES (?,?)";
jdbcTemplate.update(img2sql,refId, c2imagePath);
String img2sql = "INSERT INTO img_uploads (ref_id,img_path) VALUES (?,?)";
jdbcTemplate.update(img2sql, refId, c2imagePath);
String compSql = "INSERT INTO complaint_details (ref_id, comp_nature_id, no_of_trees) "
+ "VALUES (?, ?, ?)";
@ -264,7 +268,7 @@ public class Greencommitteeservice {
return refId;
}
//return "error";
// return "error";
} catch (Exception e) {
e.printStackTrace();
}
@ -272,56 +276,57 @@ public class Greencommitteeservice {
}
@Transactional
public List<Map<String, Object>> findByMobileNo(String mobileNo){
public List<Map<String, Object>> findByMobileNo(String mobileNo) {
String sqlQuery = "select id from reg_details where ph_no =?";
System.out.println(sqlQuery);
return jdbcTemplate.queryForList(sqlQuery,mobileNo);
}
// public List<Map<String, Object>> checkwithdraw(String mobile_num) {
//
// String sql="SELECT rd.ref_id "
// + " FROM reg_details rd "
// + " WHERE rd.ph_no = ? AND is_active=1 "
// + " AND NOT EXISTS ( "
// + " SELECT 1 "
// + " FROM inspection_data id "
// + " WHERE id.ref_id = rd.ref_id AND id.isactive=1 "
// + " )";
//
// List<String> refIds=jdbcTemplate.query(sql,new Object[]{mobile_num},(rs, rowNum) -> rs.getString("ref_id"));
// Map<String, Object> wrapper = new HashMap<>();
// List<Map<String, Object>> dataList = new ArrayList<>();
//
// if(!refIds.isEmpty()) {
//
// for (String refId : refIds) {
//
// Map<String, Object> fullData = getfulldetailsdata(refId);
//
// if (fullData != null && !fullData.isEmpty()) {
// dataList.add((Map<String, Object>) fullData.get("data"));
// }
// }
//
// wrapper.put("data", dataList);
// wrapper.put("message", "Complaint List");
// wrapper.put("status", "Success");
//
// return Collections.singletonList(wrapper);
//
// }
// else {
//
//
// wrapper.put("message", "Empty List");
// wrapper.put("status", "Success");
//
// return Collections.singletonList(wrapper);
//
// }
//
// }
return jdbcTemplate.queryForList(sqlQuery, mobileNo);
}
// public List<Map<String, Object>> checkwithdraw(String mobile_num) {
//
// String sql="SELECT rd.ref_id "
// + " FROM reg_details rd "
// + " WHERE rd.ph_no = ? AND is_active=1 "
// + " AND NOT EXISTS ( "
// + " SELECT 1 "
// + " FROM inspection_data id "
// + " WHERE id.ref_id = rd.ref_id AND id.isactive=1 "
// + " )";
//
// List<String> refIds=jdbcTemplate.query(sql,new Object[]{mobile_num},(rs,
// rowNum) -> rs.getString("ref_id"));
// Map<String, Object> wrapper = new HashMap<>();
// List<Map<String, Object>> dataList = new ArrayList<>();
//
// if(!refIds.isEmpty()) {
//
// for (String refId : refIds) {
//
// Map<String, Object> fullData = getfulldetailsdata(refId);
//
// if (fullData != null && !fullData.isEmpty()) {
// dataList.add((Map<String, Object>) fullData.get("data"));
// }
// }
//
// wrapper.put("data", dataList);
// wrapper.put("message", "Complaint List");
// wrapper.put("status", "Success");
//
// return Collections.singletonList(wrapper);
//
// }
// else {
//
//
// wrapper.put("message", "Empty List");
// wrapper.put("status", "Success");
//
// return Collections.singletonList(wrapper);
//
// }
//
// }
public Map<String, Object> getfulldetailsdata(String refId) {
@ -330,32 +335,28 @@ public class Greencommitteeservice {
// 1 — Application details
Map<String, Object> app = jdbcTemplate.queryForMap(
"SELECT *,DATE_FORMAT(cdate, '%d-%m-%Y %l:%i %p') as r_Cdate,IFNULL(reinspection_id, '') AS com_reinspection_id FROM reg_details WHERE ref_id=?",
refId
);
refId);
// 2 — Complaint details (grouped)
List<Map<String, Object>> complaints = jdbcTemplate.queryForList(
"SELECT cn.name AS nature, SUM(cd.no_of_trees) AS count " +
"FROM complaint_details cd JOIN comp_nature cn ON cn.id=cd.comp_nature_id " +
"WHERE cd.ref_id=? GROUP BY cn.name", refId
);
"WHERE cd.ref_id=? GROUP BY cn.name",
refId);
String compDetails = complaints.stream()
.map(c -> c.get("nature") + "-" + c.get("count"))
.collect(Collectors.joining(","));
// 3 — Complaint images
List<Map<String, Object>> imagePaths =
jdbcTemplate.queryForList(
List<Map<String, Object>> imagePaths = jdbcTemplate.queryForList(
"SELECT img_path FROM img_uploads WHERE ref_id=? AND is_active=1",
new Object[]{refId}
).stream()
new Object[] { refId }).stream()
.map(row -> {
Map<String, Object> img = new HashMap<>();
img.put(
"img_path",
appconfig.getFilebaseurl() + "/gccofficialapp/files" + row.get("img_path").toString()
);
appconfig.getFilebaseurl() + "/gccofficialapp/files" + row.get("img_path").toString());
return img;
})
.collect(Collectors.toList());
@ -366,8 +367,7 @@ public class Greencommitteeservice {
List<Map<String, Object>> inspectionList = new ArrayList<>();
String sql =
"SELECT id.*, um.name AS inspector_name, " +
String sql = "SELECT id.*, um.name AS inspector_name, " +
" DATE_FORMAT(id.cdate, '%d-%m-%Y %l:%i %p') AS f_Cdate " +
"FROM inspection_data id " +
"LEFT JOIN user_maping um ON um.userid = id.cby " +
@ -382,9 +382,7 @@ public class Greencommitteeservice {
"ORDER BY FIELD(id.inspection_by, 'GCC', 'NGO', 'TNFD')";
List<Map<String, Object>> rows = jdbcTemplate.queryForList(
sql, refId, refId
);
sql, refId, refId);
for (Map<String, Object> row : rows) {
@ -396,8 +394,7 @@ public class Greencommitteeservice {
"FROM inspection_tree_data itd " +
"JOIN inspection_recommend_master rm ON rm.rid = itd.action " +
"WHERE itd.inspection_data_id=? AND itd.isactive=1",
inspId
);
inspId);
row.put("recommendations", recommend);
List<String> imgs = new ArrayList<>();
@ -418,9 +415,7 @@ public class Greencommitteeservice {
app.put("inspections", inspectionList);
String reSql =
"SELECT r.id AS reins_id, r.committee_action, r.remarks AS reins_remarks, " +
String reSql = "SELECT r.id AS reins_id, r.committee_action, r.remarks AS reins_remarks, " +
" DATE_FORMAT(r.cdate, '%d-%m-%Y %l:%i %p') AS reins_date, " +
" cm.event_name, DATE_FORMAT(cm.event_date, '%d-%m-%Y') AS event_date, crm.name as ins_name " +
"FROM reinspection r " +
@ -441,8 +436,7 @@ public class Greencommitteeservice {
"FROM committee_data cd " +
"LEFT JOIN create_meeting cm ON cm.id = cd.meeting_id " +
"WHERE cd.ref_id = ? AND cd.isactive = 1",
refId
);
refId);
if (!committeeList.isEmpty()) {
c1 = committeeList.get(0);
@ -453,8 +447,7 @@ public class Greencommitteeservice {
"JOIN committee_recommend_master crm ON crm.id = ctd.committee_action " +
"WHERE ctd.ref_id = ? " +
"GROUP BY crm.name",
refId
);
refId);
c1.put("com_complaints", com_complaints);
}
@ -462,23 +455,21 @@ public class Greencommitteeservice {
// IMPORTANT: always put committee key (even if null)
app.put("committee", c1);
//response.put("data", app);
// response.put("data", app);
return app;
}
public List<String> getrefnums(String mobile_num) {
try {
String sql="SELECT ref_id "
String sql = "SELECT ref_id "
+ " FROM reg_details "
+ " WHERE ph_no = ?";
System.out.println(sql);
return jdbcTemplate.query(sql,new Object[]{mobile_num},(rs, rowNum) -> rs.getString("ref_id"));
return jdbcTemplate.query(sql, new Object[] { mobile_num }, (rs, rowNum) -> rs.getString("ref_id"));
} catch (Exception e) {
System.err.println("Error in getrefnums(): " + e.getMessage());
@ -487,132 +478,133 @@ public class Greencommitteeservice {
}
}
// public Map<String, Object> getlistdata(String ref) {
//
// Map<String, Object> regDetails = getRegDetails(ref);
//
// List<Map<String, Object>> compDetails = getComplaintDetails(ref);
//
// regDetails.put("comp_details", compDetails);
//
//
//
// String linecompDetails = compDetails.stream()
// .map(c -> c.get("nature") + "-" + c.get("count"))
// .collect(Collectors.joining(","));
//
// List<Map<String, Object>> inspectionList = new ArrayList<>();
//
// String sql =
// "SELECT id.*, um.name AS inspector_name, " +
// " DATE_FORMAT(id.cdate, '%d-%m-%Y %l:%i %p') AS f_Cdate " +
// "FROM inspection_data id " +
// "LEFT JOIN user_maping um ON um.userid = id.cby " +
// "INNER JOIN ( " +
// " SELECT inspection_by, MAX(cdate) AS latest_date " +
// " FROM inspection_data " +
// " WHERE ref_id = ? AND isactive = 1 " +
// " GROUP BY inspection_by " +
// ") latest ON id.inspection_by = latest.inspection_by " +
// " AND id.cdate = latest.latest_date " +
// "WHERE id.ref_id = ? AND id.isactive = 1 " +
// "ORDER BY FIELD(id.inspection_by, 'GCC', 'NGO', 'TNFD')";
//
// List<Map<String, Object>> rows = jdbcTemplate.queryForList(
// sql, ref, ref
// );
//
//
// for (Map<String, Object> row : rows) {
//
// Integer inspId = (Integer) row.get("inspection_data_id");
//
// // 4a — Recommendation details
// List<Map<String, Object>> recommend = jdbcTemplate.queryForList(
// "SELECT rm.name, itd.nooftrees AS count " +
// "FROM inspection_tree_data itd " +
// "JOIN inspection_recommend_master rm ON rm.rid = itd.action " +
// "WHERE itd.inspection_data_id=? AND itd.isactive=1",
// inspId
// );
//
// row.put("recommendations", recommend);
//
// inspectionList.add(row);
// }
//
// regDetails.put("inspections", inspectionList);
//
//
// String reSql =
// "SELECT r.id AS reins_id, r.committee_action, r.remarks AS reins_remarks, " +
// " DATE_FORMAT(r.cdate, '%d-%m-%Y %l:%i %p') AS reins_date, " +
// " cm.event_name, DATE_FORMAT(cm.event_date, '%d-%m-%Y') AS event_date, crm.name as ins_name " +
// "FROM reinspection r " +
// "LEFT JOIN create_meeting cm ON cm.id = r.meeting_id " +
// " LEFT JOIN committee_recommend_master crm ON crm.id=r.committee_action " +
// "WHERE r.ref_id = ? AND r.isactive = 1 " +
// "ORDER BY r.id DESC";
//
// List<Map<String, Object>> reinspectionList = jdbcTemplate.queryForList(reSql, ref);
//
// regDetails.put("reinspections", reinspectionList);
//
// Map<String, Object> c1 = null;
//
// List<Map<String, Object>> committeeList = jdbcTemplate.queryForList(
// "SELECT cd.*, DATE_FORMAT(cd.cdate, '%d-%m-%Y %l:%i %p') AS c_Cdate, " +
// "cm.event_name AS meeting_name, cm.event_date AS meeting_date " +
// "FROM committee_data cd " +
// "LEFT JOIN create_meeting cm ON cm.id = cd.meeting_id " +
// "WHERE cd.ref_id = ? AND cd.isactive = 1",
// ref
// );
//
// if (!committeeList.isEmpty()) {
// c1 = committeeList.get(0);
//
// List<Map<String, Object>> com_complaints = jdbcTemplate.queryForList(
// "SELECT crm.name AS nature, SUM(ctd.nooftrees) AS count " +
// "FROM committee_tree_data ctd " +
// "JOIN committee_recommend_master crm ON crm.id = ctd.committee_action " +
// "WHERE ctd.ref_id = ? " +
// "GROUP BY crm.name",
// ref
// );
//
// c1.put("com_complaints", com_complaints);
// }
//
// // IMPORTANT: always put committee key (even if null)
// regDetails.put("committee", c1);
//
//
// return regDetails;
// }
//
// public Map<String, Object> getRegDetails(String ref) {
// String sql = "SELECT * FROM reg_details WHERE is_active = 1 AND ref_id = ?";
// return jdbcTemplate.queryForMap(sql, ref);
// }
//
// public List<Map<String, Object>> getComplaintDetails(String ref) {
//
// String sql = "SELECT cn.name AS nature, SUM(cd.no_of_trees) AS total_trees " +
// "FROM complaint_details cd " +
// "JOIN comp_nature cn ON cn.id = cd.comp_nature_id " +
// "WHERE cd.is_active = 1 AND cd.ref_id = ? " +
// "GROUP BY cn.name";
//
// return jdbcTemplate.queryForList(sql, ref);
// }
// public Map<String, Object> getlistdata(String ref) {
//
// Map<String, Object> regDetails = getRegDetails(ref);
//
// List<Map<String, Object>> compDetails = getComplaintDetails(ref);
//
// regDetails.put("comp_details", compDetails);
//
//
//
// String linecompDetails = compDetails.stream()
// .map(c -> c.get("nature") + "-" + c.get("count"))
// .collect(Collectors.joining(","));
//
// List<Map<String, Object>> inspectionList = new ArrayList<>();
//
// String sql =
// "SELECT id.*, um.name AS inspector_name, " +
// " DATE_FORMAT(id.cdate, '%d-%m-%Y %l:%i %p') AS f_Cdate " +
// "FROM inspection_data id " +
// "LEFT JOIN user_maping um ON um.userid = id.cby " +
// "INNER JOIN ( " +
// " SELECT inspection_by, MAX(cdate) AS latest_date " +
// " FROM inspection_data " +
// " WHERE ref_id = ? AND isactive = 1 " +
// " GROUP BY inspection_by " +
// ") latest ON id.inspection_by = latest.inspection_by " +
// " AND id.cdate = latest.latest_date " +
// "WHERE id.ref_id = ? AND id.isactive = 1 " +
// "ORDER BY FIELD(id.inspection_by, 'GCC', 'NGO', 'TNFD')";
//
// List<Map<String, Object>> rows = jdbcTemplate.queryForList(
// sql, ref, ref
// );
//
//
// for (Map<String, Object> row : rows) {
//
// Integer inspId = (Integer) row.get("inspection_data_id");
//
// // 4a — Recommendation details
// List<Map<String, Object>> recommend = jdbcTemplate.queryForList(
// "SELECT rm.name, itd.nooftrees AS count " +
// "FROM inspection_tree_data itd " +
// "JOIN inspection_recommend_master rm ON rm.rid = itd.action " +
// "WHERE itd.inspection_data_id=? AND itd.isactive=1",
// inspId
// );
//
// row.put("recommendations", recommend);
//
// inspectionList.add(row);
// }
//
// regDetails.put("inspections", inspectionList);
//
//
// String reSql =
// "SELECT r.id AS reins_id, r.committee_action, r.remarks AS reins_remarks, " +
// " DATE_FORMAT(r.cdate, '%d-%m-%Y %l:%i %p') AS reins_date, " +
// " cm.event_name, DATE_FORMAT(cm.event_date, '%d-%m-%Y') AS event_date,
// crm.name as ins_name " +
// "FROM reinspection r " +
// "LEFT JOIN create_meeting cm ON cm.id = r.meeting_id " +
// " LEFT JOIN committee_recommend_master crm ON crm.id=r.committee_action " +
// "WHERE r.ref_id = ? AND r.isactive = 1 " +
// "ORDER BY r.id DESC";
//
// List<Map<String, Object>> reinspectionList = jdbcTemplate.queryForList(reSql,
// ref);
//
// regDetails.put("reinspections", reinspectionList);
//
// Map<String, Object> c1 = null;
//
// List<Map<String, Object>> committeeList = jdbcTemplate.queryForList(
// "SELECT cd.*, DATE_FORMAT(cd.cdate, '%d-%m-%Y %l:%i %p') AS c_Cdate, " +
// "cm.event_name AS meeting_name, cm.event_date AS meeting_date " +
// "FROM committee_data cd " +
// "LEFT JOIN create_meeting cm ON cm.id = cd.meeting_id " +
// "WHERE cd.ref_id = ? AND cd.isactive = 1",
// ref
// );
//
// if (!committeeList.isEmpty()) {
// c1 = committeeList.get(0);
//
// List<Map<String, Object>> com_complaints = jdbcTemplate.queryForList(
// "SELECT crm.name AS nature, SUM(ctd.nooftrees) AS count " +
// "FROM committee_tree_data ctd " +
// "JOIN committee_recommend_master crm ON crm.id = ctd.committee_action " +
// "WHERE ctd.ref_id = ? " +
// "GROUP BY crm.name",
// ref
// );
//
// c1.put("com_complaints", com_complaints);
// }
//
// // IMPORTANT: always put committee key (even if null)
// regDetails.put("committee", c1);
//
//
// return regDetails;
// }
//
// public Map<String, Object> getRegDetails(String ref) {
// String sql = "SELECT * FROM reg_details WHERE is_active = 1 AND ref_id = ?";
// return jdbcTemplate.queryForMap(sql, ref);
// }
//
// public List<Map<String, Object>> getComplaintDetails(String ref) {
//
// String sql = "SELECT cn.name AS nature, SUM(cd.no_of_trees) AS total_trees "
// +
// "FROM complaint_details cd " +
// "JOIN comp_nature cn ON cn.id = cd.comp_nature_id " +
// "WHERE cd.is_active = 1 AND cd.ref_id = ? " +
// "GROUP BY cn.name";
//
// return jdbcTemplate.queryForList(sql, ref);
// }
@Transactional
public String withdraw(String id, String remarks) {
String sql="UPDATE reg_details SET is_active=0,is_delete=1,is_withdraw=1,withdraw_remarks=?,withdraw_date=NOW() WHERE id=?";
String sql = "UPDATE reg_details SET is_active=0,is_delete=1,is_withdraw=1,withdraw_remarks=?,withdraw_date=NOW() WHERE id=?";
try {
jdbcTemplate.update(sql, remarks, id);
@ -625,10 +617,9 @@ public class Greencommitteeservice {
}
public List<Map<String, Object>> getpurninglist() {
public List<Map<String, Object>> getpurninglist() {
String sql=" SELECT "
String sql = " SELECT "
+ " r.ref_id,r.cby, "
+ " r.p_name, dm.name as deptname,"
+ " r.dept_name,"
@ -683,13 +674,11 @@ public List<Map<String, Object>> getpurninglist() {
}
}
public ResponseEntity<?> generatepgrcomplaints(String refid) {
try {
String sql=" SELECT "
String sql = " SELECT "
+ " r.ref_id,r.cby, "
+ " r.p_name,dm.name as deptname, "
+ " r.dept_name,"
@ -728,57 +717,54 @@ public List<Map<String, Object>> getpurninglist() {
+ " AND cd.comp_nature_id IN (1,3) "
+ ") ";
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql,refid);
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, refid);
System.out.println("Total Generating Complaints : " + list.size());
if(list.isEmpty()) {
if (list.isEmpty()) {
return ResponseEntity.ok(Map.of(
"status", false,
"message", "No eligible complaint found for this Ref ID."
));
"message", "No eligible complaint found for this Ref ID."));
}
String complaintNumber="";
String complaintNumber = "";
for (Map<String, Object> row : list) {
try {
String refId = String.valueOf(row.get("ref_id"));
// String imageUrl = "";
//
// if(row.get("img_path") != null){
// imageUrl = "https://gccservices.in/gccofficialapp/files" + row.get("img_path");
// }
// String imageUrl = "";
//
// if(row.get("img_path") != null){
// imageUrl = "https://gccservices.in/gccofficialapp/files" +
// row.get("img_path");
// }
//String imageBase64 = convertUrlToBase64(imageUrl);
// String imageBase64 = convertUrlToBase64(imageUrl);
complaintNumber = sendComplaintToERP(row);
if(complaintNumber == null) {
if (complaintNumber == null) {
return ResponseEntity.ok(Map.of(
"status", false,
"message", "ERP complaint generation failed."
));
"message", "ERP complaint generation failed."));
}
if(complaintNumber != null && !complaintNumber.equals("N/A")){
if (complaintNumber != null && !complaintNumber.equals("N/A")) {
jdbcTemplate.update(
"UPDATE reg_details SET pgrticketno=? WHERE ref_id=?",
complaintNumber,
refId
);
refId);
jdbcTemplate.update(
"UPDATE complaint_details "
+ "SET is_active=0, is_delete=1 "
+ "WHERE ref_id=? "
+ "AND comp_nature_id IN (1,3)",
refId
);
refId);
System.out.println(refId + " -> " + complaintNumber);
@ -793,25 +779,20 @@ public List<Map<String, Object>> getpurninglist() {
return ResponseEntity.ok(Map.of(
"status", true,
"message", "PGR Complaint generation completed.",
"complaintNumber",complaintNumber,
"total", list.size()
));
"complaintNumber", complaintNumber,
"total", list.size()));
} catch (Exception e) {
e.printStackTrace();
return ResponseEntity.internalServerError().body(
Map.of(
"status", false,
"message", e.getMessage()
)
);
"message", e.getMessage()));
}
}
private String sendComplaintToERP(Map<String,Object> row) {
private String sendComplaintToERP(Map<String, Object> row) {
try {
@ -828,33 +809,32 @@ private String sendComplaintToERP(Map<String,Object> row) {
String complaintType = "454";
String complaintTitle = "Tree Pruning";
//System.out.println("Name : " + getString(row.get("p_name")));
// System.out.println("Name : " + getString(row.get("p_name")));
String complainantName = getComplainantName(row);
String params =
"serviceId=RegComplaint"
String params = "serviceId=RegComplaint"
+ "&ComplainantName=" + URLEncoder.encode(complainantName, "UTF-8")
+ "&ComplainantAddr=" + URLEncoder.encode(getString(row.get("address")), "UTF-8")
+ "&MobileNo=" + URLEncoder.encode(getString(row.get("ph_no")), "UTF-8")
+ "&Email="+ URLEncoder.encode( "", "UTF-8")
+ "&Email=" + URLEncoder.encode("", "UTF-8")
+ "&ComplaintType=" + URLEncoder.encode(complaintType, "UTF-8")
+ "&ComplaintTitle=" + URLEncoder.encode(complaintTitle, "UTF-8")
+ "&ComplaintDetails=" + URLEncoder.encode(getString(row.get("remarks")), "UTF-8")+ URLEncoder.encode(getString(row.get("ref_id")), "UTF-8")
+ "&ComplaintDetails=" + URLEncoder.encode(getString(row.get("remarks")), "UTF-8")
+ URLEncoder.encode(getString(row.get("ref_id")), "UTF-8")
+ "&StreetId=" + URLEncoder.encode(getString(row.get("streetid")), "UTF-8")
//+ "&Comp_Image=" + URLEncoder.encode(imageBase64 == null ? "" : imageBase64, "UTF-8")
+ "&Comp_Image="+ URLEncoder.encode( "", "UTF-8")
// + "&Comp_Image=" + URLEncoder.encode(imageBase64 == null ? "" : imageBase64,
// "UTF-8")
+ "&Comp_Image=" + URLEncoder.encode("", "UTF-8")
+ "&latitude=" + URLEncoder.encode(getString(row.get("latitude")), "UTF-8")
+ "&longtitude=" + URLEncoder.encode(getString(row.get("longitude")), "UTF-8")
+ "&Landmark="+ URLEncoder.encode( "", "UTF-8")
+ "&Landmark=" + URLEncoder.encode("", "UTF-8")
+ "&gender=" + URLEncoder.encode(getString(row.get("gender")), "UTF-8")
+ "&compmode=1";
System.out.println(params);
try(OutputStream os = conn.getOutputStream()){
try (OutputStream os = conn.getOutputStream()) {
os.write(params.getBytes("UTF-8"));
@ -864,12 +844,12 @@ private String sendComplaintToERP(Map<String,Object> row) {
System.out.println(conn.getResponseCode());
System.out.println(conn.getResponseMessage());
if(conn.getResponseCode()==200){
if (conn.getResponseCode() == 200) {
reader = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
}else{
} else {
reader = new BufferedReader(
new InputStreamReader(conn.getErrorStream()));
@ -879,7 +859,7 @@ private String sendComplaintToERP(Map<String,Object> row) {
String line;
while((line = reader.readLine()) != null){
while ((line = reader.readLine()) != null) {
response.append(line);
@ -887,7 +867,6 @@ private String sendComplaintToERP(Map<String,Object> row) {
reader.close();
String responseText = response.toString();
System.out.println("=================================");
@ -902,27 +881,25 @@ private String sendComplaintToERP(Map<String,Object> row) {
}
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> responseMap =
mapper.readValue(responseText, Map.class);
Map<String, Object> responseMap = mapper.readValue(responseText, Map.class);
return String.valueOf(responseMap.get("Complaint Number"));
}
catch(Exception e){
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
private String getString(Object obj){
private String getString(Object obj) {
return obj == null ? "" : obj.toString();
}
}
public String convertUrlToBase64(String urlString) {
public String convertUrlToBase64(String urlString) {
try {
URL url = new URL(urlString);
@ -946,9 +923,9 @@ public String convertUrlToBase64(String urlString) {
e.printStackTrace();
return null;
}
}
}
private String getComplainantName(Map<String, Object> row) {
private String getComplainantName(Map<String, Object> row) {
String name = getString(row.get("p_name")).trim();
@ -984,35 +961,34 @@ private String getComplainantName(Map<String, Object> row) {
System.out.println("Trimmed Length : " + temp.length());
return temp;
}
}
//private String getComplainantName(Map<String, Object> row) {
//
// String pName = getString(row.get("p_name")).trim();
// if (!pName.isEmpty()) {
// System.out.println("Using p_name : " + pName);
// System.out.println("Length : " + pName.length());
// return pName;
// }
//
// String deptName = getString(row.get("dept_name")).trim();
// if (!deptName.isEmpty()) {
// System.out.println("Using dept_name : " + deptName);
// System.out.println("Length : " + deptName.length());
// return deptName;
// }
//
// String deptMasterName = getString(row.get("deptname")).trim();
// if (!deptMasterName.isEmpty()) {
// System.out.println("Using deptname : " + deptMasterName);
// System.out.println("Length : " + deptMasterName.length());
// return deptMasterName;
// }
//
// System.out.println("No Complainant Name found.");
// System.out.println("Length : 0");
// return "";
//}
// private String getComplainantName(Map<String, Object> row) {
//
// String pName = getString(row.get("p_name")).trim();
// if (!pName.isEmpty()) {
// System.out.println("Using p_name : " + pName);
// System.out.println("Length : " + pName.length());
// return pName;
// }
//
// String deptName = getString(row.get("dept_name")).trim();
// if (!deptName.isEmpty()) {
// System.out.println("Using dept_name : " + deptName);
// System.out.println("Length : " + deptName.length());
// return deptName;
// }
//
// String deptMasterName = getString(row.get("deptname")).trim();
// if (!deptMasterName.isEmpty()) {
// System.out.println("Using deptname : " + deptMasterName);
// System.out.println("Length : " + deptMasterName.length());
// return deptMasterName;
// }
//
// System.out.println("No Complainant Name found.");
// System.out.println("Length : 0");
// return "";
// }
}

2
src/main/resources/application.properties

@ -1,3 +1,3 @@
spring.application.name=greencommitte
spring.profiles.active=prod
spring.profiles.active=dev

762
src/main/resources/templates/modules/department/form.html
File diff suppressed because it is too large
View File

116
src/main/resources/templates/modules/public/form.html

@ -479,10 +479,13 @@
<input type="text" class="form-control" id="ward" name="ward" readonly>
</div>
</div>
<div class="row mb-3">
<!-- Left Side -->
<div class="col-md-4">
<label class="form-label">
Details of Complaint<span class="text-danger">*</span>
Request Type<span class="text-danger">*</span>
</label>
<select id="complaintDropdown" class="form-control" required>
<option value="">Select Complaint</option>
@ -532,6 +535,15 @@
<!-- Dynamic input rows -->
<div id="naturecontainer"></div>
<div class="row mb-3">
<div class="col-md-6">
<label for="address">Location of Tree<span class="text-danger">*</span></label>
<!-- <input type="text" class="form-control" id="address" name="address" placeholder="Enter Address"
required>-->
<textarea class="form-control" id="address" name="address" placeholder="Type Tree Address Here"
required></textarea>
</div>
</div>
<div class="row mb-3">
<div class="col-md-12">
@ -748,13 +760,44 @@
let id = $(this).val();
let name = $("#complaintDropdown option:selected").data("name");
if (name && name.toLowerCase() === "pruning") {
if (!name) {
// Nothing selected
$("#c2image").closest(".col-md-6").show();
$("#c2image").prop("required", true);
$("#address").closest(".col-md-6").hide();
$("#address").prop("required", false).val("");
} else if (name.toLowerCase() === "pruning") {
// Pruning selected
$("#c2image").closest(".col-md-6").hide();
$("#c2image").prop("required", false).val("");
$("#address").closest(".col-md-6").hide();
$("#address").prop("required", false).val("");
} else {
// Any complaint other than pruning
$("#c2image").closest(".col-md-6").show();
$("#c2image").prop("required", true);
$("#address").closest(".col-md-6").show();
$("#address").prop("required", true);
}
/* if (name && name.toLowerCase() === "pruning") {
// Hide second image
$("#c2image").closest(".col-md-6").hide();
// Remove required validation
$("#c2image").prop("required", false).val("");
$("#address").closest(".col-md-6").hide();
$("#address").prop("required", false).val("");
} else {
@ -763,7 +806,9 @@
// Existing workflow
$("#c2image").prop("required", true);
}
$("#address").closest(".col-md-6").show();
$("#address").prop("required", true);
}*/
if (!id) {
return;
@ -862,6 +907,7 @@
// Apply to all file inputs inside the form
$("#publicform input[type='file']").on("change", function () {
const fileInput = this;
console.log(" cehcking");
if (fileInput.files.length > 0) {
let file = fileInput.files[0];
@ -1178,7 +1224,7 @@
const name = $('#pname').val();
const streetName = $('#streetName option:selected').text();
const street_id = $('#streetId').val();
console.log("cfefefef");
// console.log("cfefefef");
console.log(streetName);
console.log("Streetid");
console.log(street_id);
@ -1254,7 +1300,10 @@
formData.append("p_name", name);
formData.append("source", "1");
formData.append("address", streetName)
//formData.append("address", streetName)
formData.set("streetName", streetName);
let address = $("#address").val().trim();
formData.append("address", address)
formData.append("c1image", c1image);
@ -1264,6 +1313,61 @@
let apiUrl = "/greencommittee/api/savepublicform";
if (complaintName &&
complaintName.trim().toLowerCase() === "pruning") {
if (name.length > 31) {
$('#pageLoader').hide();
$('#submitBtn').prop('disabled', false).text('Submit');
Swal.fire({
icon: "warning",
title: "Invalid Petitioner Name",
text: "Petitioner name cannot exceed 31 characters."
});
return; // Stop form submission
}
const file = $("#c1image")[0].files[0];
if (!file) {
$('#pageLoader').hide();
$('#submitBtn').prop('disabled', false).text('Submit');
Swal.fire({
icon: "warning",
title: "Image Required",
text: "Please upload Image 1."
});
return;
}
// Allow only JPG, JPEG, PNG
const allowedTypes = ["image/jpeg", "image/jpg", "image/png"];
if (!allowedTypes.includes(file.type)) {
$('#pageLoader').hide();
$('#submitBtn').prop('disabled', false).text('Submit');
Swal.fire({
icon: "warning",
title: "Invalid File",
text: "Only JPG, JPEG and PNG images are allowed."
});
$("#c1image").val("");
return;
}
// Maximum size: 1 MB
if (file.size > (1 * 1024 * 1024)) {
$('#pageLoader').hide();
$('#submitBtn').prop('disabled', false).text('Submit');
Swal.fire({
icon: "warning",
title: "File Too Large",
text: "Image size should not exceed 1 MB."
});
$("#c1image").val("");
return;
}
apiUrl = "/greencommittee/api/savepruningform";
formData.append("StreetId", street_id);
@ -1502,6 +1606,8 @@
}
$(document).ready(function () {
$("#address").closest(".col-md-6").hide();
$("#address").prop("required", false);
$('#sendOtpButton').click(function () {
// Get the entered mobile number

Loading…
Cancel
Save