|
|
|
@ -256,7 +256,7 @@ public class RdoService { |
|
|
|
public List<Map<String, Object>> getUserAccess(Long appUserId) { |
|
|
|
|
|
|
|
String sql = """ |
|
|
|
SELECT lmu.zone,lmu.ward,lmu.zonearray, lmu.wardarray |
|
|
|
SELECT lmu.zone,lmu.ward,lmu.zonearray, lmu.wardarray, lmu.unit |
|
|
|
FROM login_mapping_user lmu |
|
|
|
WHERE lmu.appuser_id = ? |
|
|
|
"""; |
|
|
|
@ -323,7 +323,7 @@ public class RdoService { |
|
|
|
public Map<String, Object> getOfficerDetailsByUserId(String gccUserId) { |
|
|
|
|
|
|
|
String sql = """ |
|
|
|
SELECT dpid, zlsc_members, dlc_members, gcc_user_id, dro_member, final_authority_permanent |
|
|
|
SELECT dpid, zlsc_members, dlc_members, gcc_user_id, dro_member, final_authority_permanent, documents_view |
|
|
|
FROM department_login |
|
|
|
WHERE gcc_user_id = ? |
|
|
|
AND is_active = 1 |
|
|
|
@ -445,15 +445,22 @@ public class RdoService { |
|
|
|
/* Resolve access */ |
|
|
|
List<Map<String, Object>> access = getUserAccess(appUserId); |
|
|
|
|
|
|
|
String zone = null, zoneArray = null, wardArray = null; |
|
|
|
boolean isRdo = false, isZonalOfficer = false; |
|
|
|
/* 🔥 Documents View Permission */ |
|
|
|
Integer documentsView = (Integer) officerDetails.get("documents_view"); |
|
|
|
boolean canViewLandDocs = (documentsView != null && documentsView == 1); |
|
|
|
|
|
|
|
String zone = null, zoneArray = null, wardArray = null, unit = null; |
|
|
|
boolean isRdo = false, isZonalOfficer = false, isUnitOfficer = false; |
|
|
|
|
|
|
|
if (!access.isEmpty()) { |
|
|
|
zone = (String) access.get(0).get("zone"); |
|
|
|
zoneArray = (String) access.get(0).get("zonearray"); |
|
|
|
wardArray = (String) access.get(0).get("wardarray"); |
|
|
|
unit = (String) access.get(0).get("unit"); |
|
|
|
|
|
|
|
if (hasValue(zoneArray) && hasValue(wardArray)) { |
|
|
|
if (hasValue(unit) && hasValue(wardArray)) { |
|
|
|
isUnitOfficer = true; |
|
|
|
} else if (hasValue(zoneArray) && hasValue(wardArray)) { |
|
|
|
isRdo = true; |
|
|
|
} else if (hasValue(zone)) { |
|
|
|
isZonalOfficer = true; |
|
|
|
@ -581,8 +588,15 @@ public class RdoService { |
|
|
|
params.add(applicationType); |
|
|
|
} |
|
|
|
|
|
|
|
/* Unit Officer (AEE) */ |
|
|
|
if (isUnitOfficer) { |
|
|
|
/* Only Temporary Requests */ |
|
|
|
sql.append(" AND urd.application_type = 1 "); |
|
|
|
sql.append(" AND FIND_IN_SET(sd.ward, ?) "); |
|
|
|
params.add(wardArray); |
|
|
|
} |
|
|
|
/* RDO */ |
|
|
|
if (isRdo) { |
|
|
|
else if (isRdo) { |
|
|
|
sql.append(" AND FIND_IN_SET(sd.zone, ?) AND FIND_IN_SET(sd.ward, ?) "); |
|
|
|
params.add(zoneArray); |
|
|
|
params.add(wardArray); |
|
|
|
@ -678,6 +692,7 @@ public class RdoService { |
|
|
|
List<Map<String, Object>> rows = mysqlFlagPoleJdbcTemplate.queryForList(sql.toString(), params.toArray()); |
|
|
|
|
|
|
|
/* GROUP BY REFID */ |
|
|
|
final boolean isUnitOfficerFinal = isUnitOfficer; |
|
|
|
Map<String, Map<String, Object>> resultMap = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
for (Map<String, Object> row : rows) { |
|
|
|
@ -702,11 +717,21 @@ public class RdoService { |
|
|
|
map.put("event_name", row.get("event_name")); |
|
|
|
map.put("total_cost", row.get("total_cost")); |
|
|
|
|
|
|
|
map.put("patta_image_url", isFinalAuthorityPermanent ? null : row.get("patta_image_url")); |
|
|
|
map.put("affidavit_image_url", isFinalAuthorityPermanent ? null : row.get("affidavit_image_url")); |
|
|
|
map.put("ec_image_url", isFinalAuthorityPermanent ? null : row.get("ec_image_url")); |
|
|
|
map.put("fmb_sketch_url", isFinalAuthorityPermanent ? null : row.get("fmb_sketch_url")); |
|
|
|
map.put("aadhaar_image_url", isFinalAuthorityPermanent ? null : row.get("aadhaar_image_url")); |
|
|
|
map.put("patta_image_url", |
|
|
|
((isFinalAuthorityPermanent || isUnitOfficerFinal) && !canViewLandDocs) ? null |
|
|
|
: row.get("patta_image_url")); |
|
|
|
map.put("affidavit_image_url", |
|
|
|
((isFinalAuthorityPermanent || isUnitOfficerFinal) && !canViewLandDocs) ? null |
|
|
|
: row.get("affidavit_image_url")); |
|
|
|
map.put("ec_image_url", |
|
|
|
((isFinalAuthorityPermanent || isUnitOfficerFinal) && !canViewLandDocs) ? null |
|
|
|
: row.get("ec_image_url")); |
|
|
|
map.put("fmb_sketch_url", |
|
|
|
((isFinalAuthorityPermanent || isUnitOfficerFinal) && !canViewLandDocs) ? null |
|
|
|
: row.get("fmb_sketch_url")); |
|
|
|
map.put("aadhaar_image_url", |
|
|
|
((isFinalAuthorityPermanent || isUnitOfficerFinal) && !canViewLandDocs) ? null |
|
|
|
: row.get("aadhaar_image_url")); |
|
|
|
|
|
|
|
map.put("application_type_id", row.get("application_type_id")); |
|
|
|
map.put("application_type_name", row.get("application_type_name")); |
|
|
|
@ -718,12 +743,14 @@ public class RdoService { |
|
|
|
map.put("streets", new ArrayList<>()); |
|
|
|
map.put("history", new ArrayList<>()); |
|
|
|
|
|
|
|
if ((isZlscMember || isDlcMember || isDro) |
|
|
|
if (!isUnitOfficerFinal && (isZlscMember || isDlcMember || isDro) |
|
|
|
&& "PERMANENT".equalsIgnoreCase((String) row.get("application_type_name"))) { |
|
|
|
map.put("verification_questions", verificationQuestions); |
|
|
|
} |
|
|
|
|
|
|
|
map.put("is_final_authority_perm", isFinalAuthorityPermanent); |
|
|
|
map.put("is_unit_officer", isUnitOfficerFinal); |
|
|
|
map.put("can_view_land_docs", canViewLandDocs); |
|
|
|
|
|
|
|
return map; |
|
|
|
}); |
|
|
|
@ -1078,6 +1105,9 @@ public class RdoService { |
|
|
|
Integer droMember = (Integer) officerDetails.get("dro_member"); |
|
|
|
boolean isDro = (droMember != null && droMember == 1); |
|
|
|
|
|
|
|
Integer finalAuthPerm = (Integer) officerDetails.get("final_authority_permanent"); |
|
|
|
boolean isFinalAuthorityPermanent = (finalAuthPerm != null && finalAuthPerm == 1); |
|
|
|
|
|
|
|
Integer gccUserQuestionsView = (Integer) officerDetails.get("gcc_user_id"); |
|
|
|
|
|
|
|
// System.out.println("gccUserQuestionsView: " + gccUserQuestionsView); |
|
|
|
@ -1091,19 +1121,28 @@ public class RdoService { |
|
|
|
/* Resolve access */ |
|
|
|
List<Map<String, Object>> access = getUserAccess(appUserId); |
|
|
|
|
|
|
|
/* Documents View Permission */ |
|
|
|
Integer documentsView = (Integer) officerDetails.get("documents_view"); |
|
|
|
boolean canViewLandDocs = (documentsView != null && documentsView == 1); |
|
|
|
|
|
|
|
String zone = null; |
|
|
|
String zoneArray = null; |
|
|
|
String wardArray = null; |
|
|
|
String unit = null; |
|
|
|
|
|
|
|
boolean isRdo = false; |
|
|
|
boolean isZonalOfficer = false; |
|
|
|
boolean isUnitOfficer = false; |
|
|
|
|
|
|
|
if (!access.isEmpty()) { |
|
|
|
zone = (String) access.get(0).get("zone"); |
|
|
|
zoneArray = (String) access.get(0).get("zonearray"); |
|
|
|
wardArray = (String) access.get(0).get("wardarray"); |
|
|
|
unit = (String) access.get(0).get("unit"); |
|
|
|
|
|
|
|
if (hasValue(zoneArray) && hasValue(wardArray)) { |
|
|
|
if (hasValue(unit) && hasValue(wardArray)) { |
|
|
|
isUnitOfficer = true; |
|
|
|
} else if (hasValue(zoneArray) && hasValue(wardArray)) { |
|
|
|
isRdo = true; |
|
|
|
} else if (hasValue(zone)) { |
|
|
|
isZonalOfficer = true; |
|
|
|
@ -1140,6 +1179,17 @@ public class RdoService { |
|
|
|
sd.street_cost, |
|
|
|
sd.height, |
|
|
|
|
|
|
|
CASE WHEN urd.patta_image_path IS NOT NULL |
|
|
|
THEN CONCAT(?,'/gcc/files',urd.patta_image_path) END AS patta_image_url, |
|
|
|
CASE WHEN urd.affidavit_image_path IS NOT NULL |
|
|
|
THEN CONCAT(?,'/gcc/files',urd.affidavit_image_path) END AS affidavit_image_url, |
|
|
|
CASE WHEN urd.ec_image_path IS NOT NULL |
|
|
|
THEN CONCAT(?,'/gcc/files',urd.ec_image_path) END AS ec_image_url, |
|
|
|
CASE WHEN urd.fmb_sketch_path IS NOT NULL |
|
|
|
THEN CONCAT(?,'/gcc/files',urd.fmb_sketch_path) END AS fmb_sketch_url, |
|
|
|
CASE WHEN urd.aadhaar_image_path IS NOT NULL |
|
|
|
THEN CONCAT(?,'/gcc/files',urd.aadhaar_image_path) END AS aadhaar_image_url, |
|
|
|
|
|
|
|
fm.flag_material_name AS flag_material, |
|
|
|
pm.pole_material_name AS pole_material, |
|
|
|
sm.statue_material_type, |
|
|
|
@ -1173,6 +1223,14 @@ public class RdoService { |
|
|
|
"""); |
|
|
|
|
|
|
|
List<Object> params = new ArrayList<>(); |
|
|
|
|
|
|
|
/* Add base URL params for image paths */ |
|
|
|
params.add(fileBaseUrlImages); |
|
|
|
params.add(fileBaseUrlImages); |
|
|
|
params.add(fileBaseUrlImages); |
|
|
|
params.add(fileBaseUrlImages); |
|
|
|
params.add(fileBaseUrlImages); |
|
|
|
|
|
|
|
params.add(deptId); |
|
|
|
|
|
|
|
/* Optional status */ |
|
|
|
@ -1181,8 +1239,15 @@ public class RdoService { |
|
|
|
params.add(status); |
|
|
|
} |
|
|
|
|
|
|
|
/* Unit Officer (AEE) */ |
|
|
|
if (isUnitOfficer) { |
|
|
|
/* Only Temporary Requests */ |
|
|
|
sql.append(" AND urd.application_type = 1 "); |
|
|
|
sql.append(" AND FIND_IN_SET(sd.ward, ?) "); |
|
|
|
params.add(wardArray); |
|
|
|
} |
|
|
|
/* RDO → zone + ward */ |
|
|
|
if (isRdo) { |
|
|
|
else if (isRdo) { |
|
|
|
sql.append(" AND FIND_IN_SET(sd.zone, ?) "); |
|
|
|
sql.append(" AND FIND_IN_SET(sd.ward, ?) "); |
|
|
|
params.add(zoneArray); |
|
|
|
@ -1212,6 +1277,7 @@ public class RdoService { |
|
|
|
List<Map<String, Object>> rows = mysqlFlagPoleJdbcTemplate.queryForList(sql.toString(), params.toArray()); |
|
|
|
|
|
|
|
/* GROUP BY REFID */ |
|
|
|
final boolean isUnitOfficerFinal = isUnitOfficer; |
|
|
|
Map<String, Map<String, Object>> resultMap = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
for (Map<String, Object> row : rows) { |
|
|
|
@ -1235,21 +1301,41 @@ public class RdoService { |
|
|
|
map.put("total_cost", row.get("total_cost")); |
|
|
|
map.put("officer_status", row.get("officer_status")); |
|
|
|
map.put("officer_remarks", row.get("officer_remarks")); |
|
|
|
map.put("others_specify_statue_material", row.get("others_specify_statue_material")); |
|
|
|
map.put("place_of_erection", row.get("place_of_erection")); |
|
|
|
map.put("application_type_name", row.get("application_type_name")); |
|
|
|
map.put("application_type_id", row.get("application_type_id")); |
|
|
|
map.put("option_name", row.get("option_name")); |
|
|
|
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 |
|
|
|
// member |
|
|
|
if ((isZlscMember || isDlcMember || isDro) |
|
|
|
if (!isUnitOfficerFinal && (isZlscMember || isDlcMember || isDro) |
|
|
|
&& "PERMANENT".equalsIgnoreCase((String) row.get("application_type_name"))) { |
|
|
|
map.put("verification_questions", verificationQuestions); |
|
|
|
} |
|
|
|
|
|
|
|
boolean isTemporary = "TEMPORARY".equalsIgnoreCase((String) row.get("application_type_name")); |
|
|
|
|
|
|
|
map.put("patta_image_url", |
|
|
|
(((isFinalAuthorityPermanent || isUnitOfficerFinal) && !canViewLandDocs) || isTemporary) ? null |
|
|
|
: row.get("patta_image_url")); |
|
|
|
map.put("affidavit_image_url", |
|
|
|
(((isFinalAuthorityPermanent || isUnitOfficerFinal) && !canViewLandDocs) || isTemporary) ? null |
|
|
|
: row.get("affidavit_image_url")); |
|
|
|
map.put("ec_image_url", |
|
|
|
(((isFinalAuthorityPermanent || isUnitOfficerFinal) && !canViewLandDocs) || isTemporary) ? null |
|
|
|
: row.get("ec_image_url")); |
|
|
|
map.put("fmb_sketch_url", |
|
|
|
(((isFinalAuthorityPermanent || isUnitOfficerFinal) && !canViewLandDocs) || isTemporary) ? null |
|
|
|
: row.get("fmb_sketch_url")); |
|
|
|
map.put("aadhaar_image_url", |
|
|
|
((isFinalAuthorityPermanent || isUnitOfficerFinal) && !canViewLandDocs) ? null |
|
|
|
: row.get("aadhaar_image_url")); |
|
|
|
|
|
|
|
map.put("is_unit_officer", isUnitOfficerFinal); |
|
|
|
map.put("can_view_land_docs", canViewLandDocs); |
|
|
|
|
|
|
|
map.put("is_unit_officer", isUnitOfficerFinal); |
|
|
|
map.put("can_view_land_docs", canViewLandDocs); |
|
|
|
map.put("application_type_name", row.get("application_type_name")); |
|
|
|
|
|
|
|
return map; |
|
|
|
}); |
|
|
|
|
|
|
|
@ -1310,8 +1396,22 @@ public class RdoService { |
|
|
|
sd.no_of_poles, |
|
|
|
sd.no_of_statue, |
|
|
|
sd.street_cost, |
|
|
|
sd.street_cost, |
|
|
|
sd.height, |
|
|
|
|
|
|
|
sd.height, |
|
|
|
|
|
|
|
CASE WHEN urd.patta_image_path IS NOT NULL |
|
|
|
THEN CONCAT(?,'/gcc/files',urd.patta_image_path) END AS patta_image_url, |
|
|
|
CASE WHEN urd.affidavit_image_path IS NOT NULL |
|
|
|
THEN CONCAT(?,'/gcc/files',urd.affidavit_image_path) END AS affidavit_image_url, |
|
|
|
CASE WHEN urd.ec_image_path IS NOT NULL |
|
|
|
THEN CONCAT(?,'/gcc/files',urd.ec_image_path) END AS ec_image_url, |
|
|
|
CASE WHEN urd.fmb_sketch_path IS NOT NULL |
|
|
|
THEN CONCAT(?,'/gcc/files',urd.fmb_sketch_path) END AS fmb_sketch_url, |
|
|
|
CASE WHEN urd.aadhaar_image_path IS NOT NULL |
|
|
|
THEN CONCAT(?,'/gcc/files',urd.aadhaar_image_path) END AS aadhaar_image_url, |
|
|
|
|
|
|
|
fm.flag_material_name AS flag_material, |
|
|
|
pm.pole_material_name AS pole_material, |
|
|
|
sm.statue_material_type, |
|
|
|
@ -1347,8 +1447,52 @@ public class RdoService { |
|
|
|
WHERE 1 = 1 |
|
|
|
"""); |
|
|
|
|
|
|
|
/* Resolve department details for permissions */ |
|
|
|
Map<String, Object> officerDetails = getOfficerDetailsByUserId(gccUserId); |
|
|
|
Integer documentsView = 0; |
|
|
|
if (officerDetails != null && officerDetails.get("documents_view") != null) { |
|
|
|
documentsView = (Integer) officerDetails.get("documents_view"); |
|
|
|
} |
|
|
|
final boolean canViewLandDocs = (documentsView != null && documentsView == 1); |
|
|
|
|
|
|
|
// Similar login permissions logic (if needed for admin reports, usually admins |
|
|
|
// see all but following same pattern) |
|
|
|
// Assuming Admin Reports might be accessed by various officers |
|
|
|
// Determining if restrictions apply essentially like getRdoApproved... |
|
|
|
// For Admin Reports, let's stick to the documents_view restriction mainly if |
|
|
|
// implied? |
|
|
|
// "getAdminReportDetails this method also and adminreports.html page also" |
|
|
|
// Let's reuse the isUnitOfficer/FinalAuthority logic if possible, or just |
|
|
|
// strict documents_view? |
|
|
|
// User said: "like same logic want to implement" |
|
|
|
// So I'll infer flags from officerDetails. |
|
|
|
|
|
|
|
Integer unitOff = (Integer) officerDetails.get("dlc_members"); // No, unit officer is via unit mapping |
|
|
|
Long appUserId = getAppUserIdByGccUserId(gccUserId); |
|
|
|
List<Map<String, Object>> access = getUserAccess(appUserId); |
|
|
|
|
|
|
|
boolean isUnitOfficer = false; |
|
|
|
if (access != null && !access.isEmpty()) { |
|
|
|
String unit = (String) access.get(0).get("unit"); |
|
|
|
String wardArray = (String) access.get(0).get("wardarray"); |
|
|
|
if (hasValue(unit) && hasValue(wardArray)) { |
|
|
|
isUnitOfficer = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Integer finalAuthPerm = (Integer) officerDetails.get("final_authority_permanent"); |
|
|
|
final boolean isFinalAuthorityPermanent = (finalAuthPerm != null && finalAuthPerm == 1); |
|
|
|
final boolean isUnitOfficerFinal = isUnitOfficer; |
|
|
|
|
|
|
|
List<Object> params = new ArrayList<>(); |
|
|
|
|
|
|
|
/* Add base URL params for image paths */ |
|
|
|
params.add(fileBaseUrlImages); |
|
|
|
params.add(fileBaseUrlImages); |
|
|
|
params.add(fileBaseUrlImages); |
|
|
|
params.add(fileBaseUrlImages); |
|
|
|
params.add(fileBaseUrlImages); |
|
|
|
|
|
|
|
if (hasValue(status)) { |
|
|
|
sql.append(" AND ofb.status = ? "); |
|
|
|
params.add(status); |
|
|
|
@ -1388,6 +1532,27 @@ public class RdoService { |
|
|
|
map.put("event_name", row.get("event_name")); |
|
|
|
map.put("total_cost", row.get("total_cost")); |
|
|
|
map.put("others_specify_statue_material", row.get("others_specify_statue_material")); |
|
|
|
|
|
|
|
boolean isTemporary = "TEMPORARY".equalsIgnoreCase((String) row.get("application_type_name")); |
|
|
|
|
|
|
|
map.put("patta_image_url", |
|
|
|
(((isFinalAuthorityPermanent || isUnitOfficerFinal) && !canViewLandDocs) || isTemporary) ? null |
|
|
|
: row.get("patta_image_url")); |
|
|
|
map.put("affidavit_image_url", |
|
|
|
(((isFinalAuthorityPermanent || isUnitOfficerFinal) && !canViewLandDocs) || isTemporary) ? null |
|
|
|
: row.get("affidavit_image_url")); |
|
|
|
map.put("ec_image_url", |
|
|
|
(((isFinalAuthorityPermanent || isUnitOfficerFinal) && !canViewLandDocs) || isTemporary) ? null |
|
|
|
: row.get("ec_image_url")); |
|
|
|
map.put("fmb_sketch_url", |
|
|
|
(((isFinalAuthorityPermanent || isUnitOfficerFinal) && !canViewLandDocs) || isTemporary) ? null |
|
|
|
: row.get("fmb_sketch_url")); |
|
|
|
map.put("aadhaar_image_url", |
|
|
|
((isFinalAuthorityPermanent || isUnitOfficerFinal) && !canViewLandDocs) ? null |
|
|
|
: row.get("aadhaar_image_url")); |
|
|
|
|
|
|
|
map.put("can_view_land_docs", canViewLandDocs); |
|
|
|
|
|
|
|
map.put("place_of_erection", row.get("place_of_erection")); |
|
|
|
map.put("application_type_name", row.get("application_type_name")); |
|
|
|
map.put("application_type_id", row.get("application_type_id")); |
|
|
|
|