Browse Source

changes in service class

master
yoganandhan 8 months ago
parent
commit
e3754159b8
  1. 89
      src/main/java/com/gcc/flagpoles_services/flagpoles/service/RdoService.java

89
src/main/java/com/gcc/flagpoles_services/flagpoles/service/RdoService.java

@ -518,7 +518,7 @@ public class RdoService {
FROM user_request_details urd FROM user_request_details urd
LEFT JOIN street_details sd
JOIN street_details sd
ON urd.refid = sd.refid ON urd.refid = sd.refid
AND sd.is_active = 1 AND sd.is_active = 1
AND sd.is_delete = 0 AND sd.is_delete = 0
@ -1418,21 +1418,10 @@ public class RdoService {
pdm.statue_pedestal_type AS pedestal_material, pdm.statue_pedestal_type AS pedestal_material,
urd.total_cost, urd.total_cost,
et.event_name,
dl.department_name,
DATE_FORMAT(ofb.cdate, '%d-%m-%Y %h:%i %p') AS action_date,
ofb.status AS officer_status,
ofb.remarks AS officer_remarks
et.event_name
FROM user_request_details urd FROM user_request_details urd
LEFT JOIN officer_feedback ofb
ON urd.refid = ofb.refid
AND ofb.is_active = 1
AND ofb.is_delete = 0
LEFT JOIN department_login dl
ON ofb.dept_id = dl.dpid
LEFT JOIN street_details sd
JOIN street_details sd
ON urd.refid = sd.refid ON urd.refid = sd.refid
AND sd.is_active = 1 AND sd.is_active = 1
AND sd.is_delete = 0 AND sd.is_delete = 0
@ -1455,18 +1444,6 @@ public class RdoService {
} }
final boolean canViewLandDocs = (documentsView != null && documentsView == 1); 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 Integer unitOff = (Integer) officerDetails.get("dlc_members"); // No, unit officer is via unit mapping
Long appUserId = getAppUserIdByGccUserId(gccUserId); Long appUserId = getAppUserIdByGccUserId(gccUserId);
List<Map<String, Object>> access = getUserAccess(appUserId); List<Map<String, Object>> access = getUserAccess(appUserId);
@ -1494,7 +1471,16 @@ public class RdoService {
params.add(fileBaseUrlImages); params.add(fileBaseUrlImages);
if (hasValue(status)) { if (hasValue(status)) {
sql.append(" AND ofb.status = ? ");
// Check if ANY officer feedback has this status
sql.append("""
AND EXISTS (
SELECT 1 FROM officer_feedback ofb
WHERE ofb.refid = urd.refid
AND ofb.status = ?
AND ofb.is_active = 1
AND ofb.is_delete = 0
)
""");
params.add(status); params.add(status);
} }
@ -1584,21 +1570,44 @@ public class RdoService {
streets.add(sObj); streets.add(sObj);
} }
} }
}
// History
List<Map<String, Object>> history = (List<Map<String, Object>>) request.get("history");
String deptName = (String) row.get("department_name");
String actionDate = (String) row.get("action_date");
if (deptName != null && actionDate != null) {
boolean exists = history.stream().anyMatch(
h -> deptName.equals(h.get("department_name")) && actionDate.equals(h.get("action_date")));
if (!exists) {
/* Fetch History for all refIds */
if (!resultMap.isEmpty()) {
String ids = resultMap.keySet().stream()
.map(id -> "'" + id + "'")
.collect(Collectors.joining(","));
String historySql = """
SELECT
ofb.refid,
dl.department_name,
ofb.status,
ofb.remarks,
DATE_FORMAT(ofb.cdate, '%%d-%%m-%%Y %%h:%%i %%p') AS action_date
FROM officer_feedback ofb
LEFT JOIN department_login dl ON ofb.dept_id = dl.dpid
WHERE ofb.refid IN (%s)
AND ofb.is_active=1
AND ofb.is_delete=0
ORDER BY ofb.cdate ASC
""".formatted(ids);
List<Map<String, Object>> historyRows = mysqlFlagPoleJdbcTemplate.queryForList(historySql);
for (Map<String, Object> hRow : historyRows) {
String ref = (String) hRow.get("refid");
Map<String, Object> req = resultMap.get(ref);
if (req != null) {
List<Map<String, Object>> hist = (List<Map<String, Object>>) req.get("history");
if (hist != null) {
Map<String, Object> hObj = new LinkedHashMap<>(); Map<String, Object> hObj = new LinkedHashMap<>();
hObj.put("department_name", deptName);
hObj.put("status", row.get("officer_status"));
hObj.put("remarks", row.get("officer_remarks"));
hObj.put("action_date", actionDate);
history.add(hObj);
hObj.put("department_name", hRow.get("department_name"));
hObj.put("status", hRow.get("status"));
hObj.put("remarks", hRow.get("remarks"));
hObj.put("action_date", hRow.get("action_date"));
hist.add(hObj);
}
} }
} }
} }

Loading…
Cancel
Save