From 4f4200189707a2240c9cd385c5ca8793dd52151d Mon Sep 17 00:00:00 2001 From: yoganandhan Date: Wed, 11 Feb 2026 16:13:15 +0530 Subject: [PATCH] for permanent flagpole or statue updated service, message content and pages --- .../controller/FlagPoleApiController.java | 12 +- .../flagpoles/service/FlagpoleSMSService.java | 144 ------------------ .../flagpoles/service/RdoService.java | 90 +++++------ 3 files changed, 43 insertions(+), 203 deletions(-) diff --git a/src/main/java/com/gcc/flagpoles_services/flagpoles/controller/FlagPoleApiController.java b/src/main/java/com/gcc/flagpoles_services/flagpoles/controller/FlagPoleApiController.java index 1ba1c9c..28459bb 100644 --- a/src/main/java/com/gcc/flagpoles_services/flagpoles/controller/FlagPoleApiController.java +++ b/src/main/java/com/gcc/flagpoles_services/flagpoles/controller/FlagPoleApiController.java @@ -172,11 +172,13 @@ public class FlagPoleApiController { return flagpoleSMSService.userrequestRejectedsms(mobileNo, refid); } - @GetMapping("/sendUnauthorizedMessage") - public String sendUnauthorizedMessage(@RequestParam String mobileNo, @RequestParam String location, - @RequestParam String fineAmount, @RequestParam String refid) { - return flagpoleSMSService.unauthorizedFlagPoleSms(mobileNo, location, fineAmount, refid); - } + // @GetMapping("/sendUnauthorizedMessage") + // public String sendUnauthorizedMessage(@RequestParam String mobileNo, + // @RequestParam String location, + // @RequestParam String fineAmount, @RequestParam String refid) { + // return flagpoleSMSService.unauthorizedFlagPoleSms(mobileNo, location, + // fineAmount, refid); + // } @GetMapping("/sendPermanentRequestApproved") public String sendPermanentRequestApproved(@RequestParam String mobileNo, @RequestParam String requestId) { diff --git a/src/main/java/com/gcc/flagpoles_services/flagpoles/service/FlagpoleSMSService.java b/src/main/java/com/gcc/flagpoles_services/flagpoles/service/FlagpoleSMSService.java index 0fbfbc0..2dcb790 100644 --- a/src/main/java/com/gcc/flagpoles_services/flagpoles/service/FlagpoleSMSService.java +++ b/src/main/java/com/gcc/flagpoles_services/flagpoles/service/FlagpoleSMSService.java @@ -24,33 +24,6 @@ public class FlagpoleSMSService { private final String key = "pfTEYN6H"; - public String sendBookingSuccesssms(String mobileNo, String requestId) { - - String message = "Your Flag Pole permission request has been submitted successfully. " - + "Request ID: " + requestId - + ". You will be notified once the status is updated. By GCC"; - - // Encode message and fix colon issue (gateway not decoding %3A) - String encodedMsg = URLEncoder.encode(message, StandardCharsets.UTF_8) - .replace("%3A", ":"); - - String urlString = appConfig.getOtpUrl() - + "from=GCCCRP" - + "&key=" + key - + "&sender=GCCCRP" - + "&to=" + mobileNo - + "&body=" + encodedMsg - + "&entityid=1401572690000011081" - + "&templateid=1407176959297472163"; - - System.out.println("SMS URL:- " + urlString); - - String response = messageUtility.sendSMS(urlString); - System.out.println("SMS RESPONSE:- " + response); - - return response; - } - public String userrequestApprovedsms(String mobileNo, String requestId) { String message = "Your Flag Pole permission request has been approved. " @@ -78,34 +51,6 @@ public class FlagpoleSMSService { return response; } - // public String userrequestRejectedsms(String mobileNo, String requestId) { - - // String message = "Your Flag Pole permission request has been rejected. " - // + "Request ID: " + requestId + ". " - // + "Review the details in the portal - // https://gccservices.in/flagpolesregistration/status\n" - // + "By GCC"; - - // // ONLY encode. Do NOT replace %3A - // String encodedMsg = URLEncoder.encode(message, StandardCharsets.UTF_8); - - // String urlString = appConfig.getOtpUrl() - // + "from=GCCCRP" - // + "&key=" + key - // + "&sender=GCCCRP" - // + "&to=" + mobileNo - // + "&body=" + encodedMsg - // + "&entityid=1401572690000011081" - // + "&templateid=1407176959315374790"; - - // System.out.println("SMS URL:- " + urlString); - - // String response = messageUtility.sendSMS(urlString); - // System.out.println("SMS RESPONSE:- " + response); - - // return response; - // } - public String userrequestRejectedsms(String mobileNo, String requestId) { try { @@ -156,95 +101,6 @@ public class FlagpoleSMSService { } } - // public String unauthorizedFlagPoleSms(String mobileNo, - // String location, - // String fineAmount, - // String requestId) { - - // String message = "An unauthorized flag pole installation was found at " + - // location + ". " - // + "Fine amount: Rs. " + fineAmount - // + " to be paid at - // https://gccservices.in/flagpolesregistration/paymentform?requestId=" - // + requestId + " to avoid further action.\n" - // + "By GCC"; - - // // Encode full message - // String encodedMsg = URLEncoder.encode(message, StandardCharsets.UTF_8); - - // String urlString = appConfig.getOtpUrl() - // + "from=GCCCRP" - // + "&key=" + key - // + "&sender=GCCCRP" - // + "&to=" + mobileNo - // + "&body=" + encodedMsg - // + "&entityid=1401572690000011081" - // + "&templateid=1407176959335259899"; // replace with actual template id - - // System.out.println("SMS URL:- " + urlString); - - // String response = messageUtility.sendSMS(urlString); - // System.out.println("SMS RESPONSE:- " + response); - - // return response; - // } - - public String unauthorizedFlagPoleSms(String mobileNo, - String location, - String fineAmount, - String requestId) { - - try { - - String paymentUrl = "https://gccservices.in/flagpolesregistration/paymentform?requestId=" - + requestId; - - String message = "An unauthorized flag pole installation was found at " + location + ". " - + "Fine amount: Rs. " + fineAmount - + " to be paid at " + paymentUrl - + " to avoid further action.\r\n" - + "By GCC"; - - String encodedMsg = URLEncoder.encode(message, StandardCharsets.UTF_8); - - String urlString = appConfig.getOtpUrl() - + "from=GCCCRP" - + "&key=" + key - + "&sender=GCCCRP" - + "&to=" + mobileNo - + "&body=" + encodedMsg - + "&entityid=1401572690000011081" - + "&templateid=1407176959335259899"; - - System.out.println("FINAL SMS URL:- " + urlString); - - URL apiUrl = new URL(urlString); - HttpURLConnection conn = (HttpURLConnection) apiUrl.openConnection(); - conn.setRequestMethod("GET"); - conn.setConnectTimeout(15000); - conn.setReadTimeout(15000); - - BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); - String inputLine; - StringBuilder content = new StringBuilder(); - - while ((inputLine = in.readLine()) != null) { - content.append(inputLine); - } - - in.close(); - conn.disconnect(); - - System.out.println("DIRECT SMS RESPONSE:- " + content.toString()); - - return content.toString(); - - } catch (Exception e) { - e.printStackTrace(); - return "FAILED"; - } - } - ///// permanent request approved and rejected sms public String sendPermanentRequestApproved(String mobileNo, String requestId) { diff --git a/src/main/java/com/gcc/flagpoles_services/flagpoles/service/RdoService.java b/src/main/java/com/gcc/flagpoles_services/flagpoles/service/RdoService.java index e277874..7b9d53b 100644 --- a/src/main/java/com/gcc/flagpoles_services/flagpoles/service/RdoService.java +++ b/src/main/java/com/gcc/flagpoles_services/flagpoles/service/RdoService.java @@ -126,19 +126,19 @@ public class RdoService { String refid, String gccUserId) { - /* 🔥 Resolve appuser_id from gccuserid (gcc_apps) */ + /* Resolve appuser_id from gccuserid (gcc_apps) */ Long appUserId = getAppUserIdByGccUserId(gccUserId); if (appUserId == null) { throw new RuntimeException("Invalid gccUserId: " + gccUserId); } - /* 🔥 Resolve department id (gcc_flag_pole) */ + /* Resolve department id (gcc_flag_pole) */ Integer deptId = getDepartmentIdByUserId(gccUserId); - /* 🔥 Resolve access (gcc_apps) */ + /* Resolve access (gcc_apps) */ List> access = getUserAccess(appUserId); - /* 🔥 Resolve officer details (for DRO check) */ + /* Resolve officer details (for DRO check) */ Map officerDetails = getOfficerDetailsByUserId(gccUserId); Integer droMember = (officerDetails != null) ? (Integer) officerDetails.get("dro_member") : null; boolean isDro = (droMember != null && droMember == 1); @@ -170,12 +170,12 @@ public class RdoService { // wardArray = row.get("wardarray") != null ? row.get("wardarray").toString() : // null; - /* ✅ RDO → zonearray + wardarray */ + /* RDO → zonearray + wardarray */ // if (hasValue(zoneArray) && hasValue(wardArray)) { // isRdo = true; // } - /* ✅ Zonal Officer → zone 01–15 */ + /* Zonal Officer → zone 01–15 */ if (hasValue(zone) && zone.matches("^(0[1-9]|1[0-5])$")) { isZonalOfficer = true; } @@ -201,7 +201,7 @@ public class RdoService { params.add(refid); /* - * 🔥 Only NON-RDO & NON-ZONAL & NON-DRO & NON-Zlsc & NON-DLC & + * Only NON-RDO & NON-ZONAL & NON-DRO & NON-Zlsc & NON-DLC & * NON-FINAL-AUTH-PERM are * restricted */ @@ -264,7 +264,7 @@ public class RdoService { return mysqlAppJdbcTemplate.queryForList(sql, appUserId); } - /* 🔥 Fetch all Zonal Officers (userids) for a given zone */ + /* Fetch all Zonal Officers (userids) for a given zone */ public List getZonalOfficerUserIdsByZone(String zone) { // We need 'userid' from appusers. login_mapping_user has appuser_id. // So we join login_mapping_user -> appusers @@ -407,13 +407,13 @@ public class RdoService { String applicationType // 1 = TEMP, 2 = PERM, null = ALL ) { - /* 🔥 Resolve appuser_id */ + /* Resolve appuser_id */ Long appUserId = getAppUserIdByGccUserId(gccUserId); if (appUserId == null) { throw new RuntimeException("Invalid gccUserId: " + gccUserId); } - /* 🔥 Resolve department & zlsC */ + /* Resolve department & zlsC */ Map officerDetails = getOfficerDetailsByUserId(gccUserId); if (officerDetails == null) { throw new RuntimeException("Department mapping missing for gccUserId: " + gccUserId); @@ -442,7 +442,7 @@ public class RdoService { // System.out.println("DEBUG: verificationQuestions is NULL"); } - /* 🔥 Resolve access */ + /* Resolve access */ List> access = getUserAccess(appUserId); String zone = null, zoneArray = null, wardArray = null; @@ -531,14 +531,14 @@ public class RdoService { List params = new ArrayList<>(); - /* 🔥 fileBaseUrl for all images */ + /* fileBaseUrl for all images */ params.add(fileBaseUrlImages); params.add(fileBaseUrlImages); params.add(fileBaseUrlImages); params.add(fileBaseUrlImages); params.add(fileBaseUrlImages); - /* 🔥 Only pending final */ + /* Only pending final */ sql.append(" AND (urd.final_status IS NULL OR urd.final_status = '') "); /* Zlsc → PERMANENT only & Processed by DRO */ @@ -548,7 +548,7 @@ public class RdoService { } else if (isZlscMember || isDlcMember) { sql.append(" AND urd.application_type = 2 "); - /* 🔥 Must be processed by DRO first */ + /* Must be processed by DRO first */ sql.append(""" AND urd.refid IN ( SELECT ofb.refid @@ -562,7 +562,7 @@ public class RdoService { """); } - /* 🔥 Exclude already decided by same dept */ + /* Exclude already decided by same dept */ sql.append(""" AND urd.refid NOT IN ( SELECT ofb.refid @@ -575,30 +575,30 @@ public class RdoService { """); params.add(deptId); - /* 🔥 TEMP / PERM filter */ + /* TEMP / PERM filter */ if (hasValue(applicationType)) { sql.append(" AND urd.application_type = ? "); params.add(applicationType); } - /* 🔥 RDO */ + /* RDO */ if (isRdo) { sql.append(" AND FIND_IN_SET(sd.zone, ?) AND FIND_IN_SET(sd.ward, ?) "); params.add(zoneArray); params.add(wardArray); } - /* 🔥 Zonal */ + /* Zonal */ else if (isZonalOfficer) { sql.append(" AND sd.zone = ? "); params.add(zone); } - /* 🔥 DRO Logic */ + /* DRO Logic */ else if (isDro) { - /* 🔥 DRO → PERMANENT only */ + /* DRO → PERMANENT only */ sql.append(" AND urd.application_type = 2 "); - /* 🔥 Fetch all Zonal Officers grouped by Zone */ + /* Fetch all Zonal Officers grouped by Zone */ Map> zoneOfficersMap = getMapOfZonalOfficersByZone(); if (zoneOfficersMap.isEmpty()) { @@ -651,14 +651,14 @@ public class RdoService { sql.append(" ) "); } - /* 🔥 If DRO is mapped to a specific Zone, restrict to that zone as well */ + /* If DRO is mapped to a specific Zone, restrict to that zone as well */ if (hasValue(zone)) { sql.append(" AND sd.zone = ? "); params.add(zone); } } - /* 🔹 Date filter */ + /* Date filter */ if (hasValue(startDate) && hasValue(endDate)) { sql.append(" AND DATE(urd.event_date) BETWEEN ? AND ? "); params.add(startDate); @@ -677,7 +677,7 @@ public class RdoService { List> rows = mysqlFlagPoleJdbcTemplate.queryForList(sql.toString(), params.toArray()); - /* 🔥 GROUP BY REFID */ + /* GROUP BY REFID */ Map> resultMap = new LinkedHashMap<>(); for (Map row : rows) { @@ -744,7 +744,7 @@ public class RdoService { ((List>) request.get("streets")).add(street); } - /* 🔥 Fetch History for all refIds */ + /* Fetch History for all refIds */ if (!resultMap.isEmpty()) { String ids = resultMap.keySet().stream() .map(id -> "'" + id + "'") @@ -864,23 +864,13 @@ public class RdoService { Integer applicationType = (appTypeNum != null) ? appTypeNum.intValue() : null; /* - * 🔥 Resolve officer details (for Permanent Final Authority) + * Resolve officer details (for Permanent Final Authority) */ Map officerDetails = getOfficerDetailsByUserId(gccUserId); Integer finalAuthPerm = (officerDetails != null) ? (Integer) officerDetails.get("final_authority_permanent") : null; boolean isFinalAuthorityPermanent = (finalAuthPerm != null && finalAuthPerm == 1); - /* - * 🔥 ZOs act as Final Authority ONLY if configured (1) and Application Type is - * TEMPORARY (1). - * If PERMANENT (2): - * - Normal ZOs should NOT update final_status. - * - Users with 'final_authority_permanent = 1' SHOULD update final_status. - * - * If Application Type is unknown (null), we assume it's NOT Final Authority to - * allow workflow flexibility. - */ if (applicationType != null && applicationType == 2) { if (isFinalAuthorityPermanent) { isFinalAuthority = true; @@ -903,9 +893,7 @@ public class RdoService { } /* - * ===================================================== * INSERT FEEDBACK (EXISTING) - * ===================================================== */ insertOfficerFeedback( @@ -917,9 +905,7 @@ public class RdoService { username); /* - * ===================================================== - * 🔥 NEW: get fid + save verification answers - * ===================================================== + * NEW: get fid + save verification answers */ Integer fid = mysqlFlagPoleJdbcTemplate.queryForObject( @@ -948,9 +934,7 @@ public class RdoService { } /* - * ===================================================== * FINAL AUTHORITY FLOW (UNCHANGED) - * ===================================================== */ if (isFinalAuthority) { @@ -1029,9 +1013,7 @@ public class RdoService { } /* - * ===================================================== * RDO FLOW (UNCHANGED) - * ===================================================== */ if (isRdo) { @@ -1077,13 +1059,13 @@ public class RdoService { String endDate, String status) { - /* 🔥 Resolve appuser_id */ + /* Resolve appuser_id */ Long appUserId = getAppUserIdByGccUserId(gccUserId); if (appUserId == null) { throw new RuntimeException("Invalid gccUserId: " + gccUserId); } - /* 🔥 Resolve department details and ZLSC status */ + /* Resolve department details and ZLSC status */ Map officerDetails = getOfficerDetailsByUserId(gccUserId); if (officerDetails == null) { throw new RuntimeException("Department mapping missing for gccUserId: " + gccUserId); @@ -1106,7 +1088,7 @@ public class RdoService { // System.out.println("verificationQuestions: " + verificationQuestions); - /* 🔥 Resolve access */ + /* Resolve access */ List> access = getUserAccess(appUserId); String zone = null; @@ -1193,26 +1175,26 @@ public class RdoService { List params = new ArrayList<>(); params.add(deptId); - /* 🔹 Optional status */ + /* Optional status */ if (hasValue(status)) { sql.append(" AND ofb.status = ? "); params.add(status); } - /* 🔹 RDO → zone + ward */ + /* RDO → zone + ward */ if (isRdo) { sql.append(" AND FIND_IN_SET(sd.zone, ?) "); sql.append(" AND FIND_IN_SET(sd.ward, ?) "); params.add(zoneArray); params.add(wardArray); } - /* 🔹 Zonal → only zone */ + /* Zonal → only zone */ else if (isZonalOfficer) { sql.append(" AND sd.zone = ? "); params.add(zone); } - /* 🔹 Date */ + /* Date */ if (hasValue(startDate) && hasValue(endDate)) { sql.append(" AND DATE(urd.event_date) BETWEEN ? AND ? "); @@ -1229,7 +1211,7 @@ public class RdoService { List> rows = mysqlFlagPoleJdbcTemplate.queryForList(sql.toString(), params.toArray()); - /* 🔥 GROUP BY REFID */ + /* GROUP BY REFID */ Map> resultMap = new LinkedHashMap<>(); for (Map row : rows) { @@ -1261,7 +1243,7 @@ public class RdoService { map.put("installation_name", row.get("installation_name")); map.put("streets", new ArrayList<>()); - // 🔥 Add verification questions for Permanent requests if user is ZLSC OR DRO + // Add verification questions for Permanent requests if user is ZLSC OR DRO // member if ((isZlscMember || isDlcMember || isDro) && "PERMANENT".equalsIgnoreCase((String) row.get("application_type_name"))) {