|
|
|
@ -445,14 +445,76 @@ public class ReportApiService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// public List<Map<String, Object>> getReportDetailspension(String startDate, String endDate, List<String> deptIds, Integer fileCatId, List<String> fileStatus) { |
|
|
|
// String sql = ""; |
|
|
|
// List<Object> params = new ArrayList<>(); |
|
|
|
// |
|
|
|
// boolean selectAll = deptIds.contains("ALL"); |
|
|
|
// |
|
|
|
// // ✅ If "ALL" is selected, remove department filtering |
|
|
|
// String deptCondition = selectAll ? "1=1" : "pd.dept_id IN (" + String.join(",", Collections.nCopies(deptIds.size(), "?")) + ")"; |
|
|
|
// |
|
|
|
// // ✅ Handle fileStatus as multiple values in IN clause |
|
|
|
// String fileStatusCondition = (fileStatus != null && !fileStatus.isEmpty()) |
|
|
|
// ? " AND pd.file_status IN (" + String.join(",", Collections.nCopies(fileStatus.size(), "?")) + ")" |
|
|
|
// : ""; // Skip condition if fileStatus is empty or null |
|
|
|
// |
|
|
|
// if (fileCatId == 6) { |
|
|
|
// sql = "SELECT pd.emp_no, pd.emp_name, pd.designation, pd.type_of_retirement, pd.reason_for_pending,pd.retirement_date, " + |
|
|
|
// "fm.file_status AS fst, pd.file_category_name, pd.remarks, DATE(pd.created_date) AS created_date " + |
|
|
|
// "FROM cps_pensioner_details pd " + |
|
|
|
// "INNER JOIN file_status_master fm ON pd.file_status = fm.id " + |
|
|
|
// "WHERE DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?) " + // First: Date filter |
|
|
|
// "AND pd.file_category = ? " + // Second: File category filter |
|
|
|
// "AND " + deptCondition + // Third: Department condition |
|
|
|
// fileStatusCondition; // Last: File status condition |
|
|
|
// |
|
|
|
// } else { |
|
|
|
// sql = "SELECT pd.*, fm.file_status as fst " + |
|
|
|
// "FROM pensioner_details pd " + |
|
|
|
// "INNER JOIN file_status_master fm ON pd.file_status = fm.id " + |
|
|
|
// "WHERE DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?) " + // First: Date filter |
|
|
|
// "AND pd.file_category = ? " + // Second: File category filter |
|
|
|
// "AND " + deptCondition + // Third: Department condition |
|
|
|
// fileStatusCondition; // Last: File status condition |
|
|
|
// } |
|
|
|
// |
|
|
|
// // Add date range parameters first |
|
|
|
// params.add(startDate); |
|
|
|
// params.add(endDate); |
|
|
|
// |
|
|
|
// // Add file category next |
|
|
|
// params.add(fileCatId); |
|
|
|
// |
|
|
|
// // Add department filter parameters if not "ALL" |
|
|
|
// if (!selectAll) { |
|
|
|
// params.addAll(deptIds); |
|
|
|
// } |
|
|
|
// |
|
|
|
// // Add fileStatus parameters if present |
|
|
|
// if (fileStatus != null && !fileStatus.isEmpty()) { |
|
|
|
// params.addAll(fileStatus); |
|
|
|
// } |
|
|
|
// |
|
|
|
// System.out.println("Executing SQL Query: " + sql); |
|
|
|
// System.out.println("Query Parameters: " + params); |
|
|
|
// |
|
|
|
// return jdbcTemplate.queryForList(sql, params.toArray()); |
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<Map<String, Object>> getReportDetailspension(String startDate, String endDate, List<String> deptIds, Integer fileCatId, List<String> fileStatus) { |
|
|
|
String sql = ""; |
|
|
|
List<Object> params = new ArrayList<>(); |
|
|
|
|
|
|
|
boolean selectAll = deptIds.contains("ALL"); |
|
|
|
// ✅ Ensure deptIds is never empty, otherwise fetch nothing |
|
|
|
if (deptIds == null || deptIds.isEmpty()) { |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
|
|
|
|
// ✅ If "ALL" is selected, remove department filtering |
|
|
|
String deptCondition = selectAll ? "1=1" : "pd.dept_id IN (" + String.join(",", Collections.nCopies(deptIds.size(), "?")) + ")"; |
|
|
|
// ✅ Construct IN clause for department filtering |
|
|
|
String deptCondition = "pd.dept_id IN (" + String.join(",", Collections.nCopies(deptIds.size(), "?")) + ")"; |
|
|
|
|
|
|
|
// ✅ Handle fileStatus as multiple values in IN clause |
|
|
|
String fileStatusCondition = (fileStatus != null && !fileStatus.isEmpty()) |
|
|
|
@ -460,23 +522,23 @@ public class ReportApiService { |
|
|
|
: ""; // Skip condition if fileStatus is empty or null |
|
|
|
|
|
|
|
if (fileCatId == 6) { |
|
|
|
sql = "SELECT pd.emp_no, pd.emp_name, pd.designation, pd.type_of_retirement, pd.reason_for_pending,pd.retirement_date, " + |
|
|
|
sql = "SELECT pd.emp_no, pd.emp_name, pd.designation, pd.type_of_retirement, pd.reason_for_pending, pd.retirement_date, " + |
|
|
|
"fm.file_status AS fst, pd.file_category_name, pd.remarks, DATE(pd.created_date) AS created_date " + |
|
|
|
"FROM cps_pensioner_details pd " + |
|
|
|
"INNER JOIN file_status_master fm ON pd.file_status = fm.id " + |
|
|
|
"WHERE DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?) " + // First: Date filter |
|
|
|
"AND pd.file_category = ? " + // Second: File category filter |
|
|
|
"AND " + deptCondition + // Third: Department condition |
|
|
|
fileStatusCondition; // Last: File status condition |
|
|
|
"WHERE DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?) " + |
|
|
|
"AND pd.file_category = ? " + |
|
|
|
"AND " + deptCondition + |
|
|
|
fileStatusCondition; |
|
|
|
|
|
|
|
} else { |
|
|
|
sql = "SELECT pd.*, fm.file_status as fst " + |
|
|
|
"FROM pensioner_details pd " + |
|
|
|
"INNER JOIN file_status_master fm ON pd.file_status = fm.id " + |
|
|
|
"WHERE DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?) " + // First: Date filter |
|
|
|
"AND pd.file_category = ? " + // Second: File category filter |
|
|
|
"AND " + deptCondition + // Third: Department condition |
|
|
|
fileStatusCondition; // Last: File status condition |
|
|
|
"WHERE DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?) " + |
|
|
|
"AND pd.file_category = ? " + |
|
|
|
"AND " + deptCondition + |
|
|
|
fileStatusCondition; |
|
|
|
} |
|
|
|
|
|
|
|
// Add date range parameters first |
|
|
|
@ -486,10 +548,8 @@ public class ReportApiService { |
|
|
|
// Add file category next |
|
|
|
params.add(fileCatId); |
|
|
|
|
|
|
|
// Add department filter parameters if not "ALL" |
|
|
|
if (!selectAll) { |
|
|
|
// Add department filter parameters |
|
|
|
params.addAll(deptIds); |
|
|
|
} |
|
|
|
|
|
|
|
// Add fileStatus parameters if present |
|
|
|
if (fileStatus != null && !fileStatus.isEmpty()) { |
|
|
|
@ -504,7 +564,6 @@ public class ReportApiService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<Map<String, Object>> getDepartmentpending(int file_category) { |
|
|
|
|
|
|
|
String sql = "SELECT dept_name, emp_name, emp_no, file_category_name, file_status, file_moved_date, remarks " + |
|
|
|
|