diff --git a/backend/pensioner/controller/DepartmentMainController.java b/backend/pensioner/controller/DepartmentMainController.java index a5b1686..63d8c57 100644 --- a/backend/pensioner/controller/DepartmentMainController.java +++ b/backend/pensioner/controller/DepartmentMainController.java @@ -1,6 +1,7 @@ package in.gov.chennaicorporation.gccoffice.pensioner.controller; import java.util.List; + import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; diff --git a/backend/pensioner/controller/FileClosingApiController.java b/backend/pensioner/controller/FileClosingApiController.java index 8242115..e6b2c8a 100644 --- a/backend/pensioner/controller/FileClosingApiController.java +++ b/backend/pensioner/controller/FileClosingApiController.java @@ -1,6 +1,7 @@ package in.gov.chennaicorporation.gccoffice.pensioner.controller; import java.util.List; + import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; diff --git a/backend/pensioner/controller/FileClosingMainController.java b/backend/pensioner/controller/FileClosingMainController.java index d61bfff..70cd4ee 100644 --- a/backend/pensioner/controller/FileClosingMainController.java +++ b/backend/pensioner/controller/FileClosingMainController.java @@ -1,6 +1,7 @@ package in.gov.chennaicorporation.gccoffice.pensioner.controller; import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; diff --git a/backend/pensioner/controller/NewEntryAPIController.java b/backend/pensioner/controller/NewEntryAPIController.java index fc8bb3b..24ed3f9 100644 --- a/backend/pensioner/controller/NewEntryAPIController.java +++ b/backend/pensioner/controller/NewEntryAPIController.java @@ -1,6 +1,7 @@ package in.gov.chennaicorporation.gccoffice.pensioner.controller; import java.time.LocalDate; + import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.util.HashMap; @@ -109,7 +110,7 @@ public class NewEntryAPIController { Map datalist = newEntryService.fetchEmplyeeDetails(formattedFromDate, formattedToDate, deptId); System.out.println("datalist="+datalist); - List> emps= newEntryService.getRegisteredEmps(deptId,file_category); + List emps= newEntryService.getRegisteredEmps(deptId,file_category); // Format the dates for frontend in "yyyy-MM-dd" DateTimeFormatter frontendFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); @@ -119,9 +120,7 @@ public class NewEntryAPIController { response.put("toDate", frontendToDate); // Extract emp_no values from emps - Set empNos = emps.stream() - .map(emp -> (String) emp.get("emp_no")) - .collect(Collectors.toSet()); + // Set empNos = emps.stream().map(emp -> (String) emp.get("emp_no")).collect(Collectors.toSet()); //System.out.println("rrrrrrrrrrrr"); if (datalist.containsKey("list") && datalist.get("list") instanceof List) { @@ -135,7 +134,7 @@ public class NewEntryAPIController { //System.out.println("ttttttttttttt"); // Filter the datalist "list" to exclude matching EMPLOYEE_CODE values List> filteredList = ((List>) datalist.get("list")).stream() - .filter(employee -> !empNos.contains(employee.get("EMPLOYEE_CODE"))) + .filter(employee -> !emps.contains(employee.get("EMPLOYEE_CODE"))) .collect(Collectors.toList()); if (filteredList.isEmpty()) { diff --git a/backend/pensioner/controller/PendencyAutoConversionApiController.java b/backend/pensioner/controller/PendencyAutoConversionApiController.java index 1e7a39f..f1c7559 100644 --- a/backend/pensioner/controller/PendencyAutoConversionApiController.java +++ b/backend/pensioner/controller/PendencyAutoConversionApiController.java @@ -1,6 +1,8 @@ package in.gov.chennaicorporation.gccoffice.pensioner.controller; import java.time.LocalDate; + + import java.time.Period; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; diff --git a/backend/pensioner/controller/PensionerMainController.java b/backend/pensioner/controller/PensionerMainController.java index 2b03c34..60a5553 100644 --- a/backend/pensioner/controller/PensionerMainController.java +++ b/backend/pensioner/controller/PensionerMainController.java @@ -1,6 +1,7 @@ package in.gov.chennaicorporation.gccoffice.pensioner.controller; import java.util.List; + import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; diff --git a/backend/pensioner/scheduler/PendencyAutoConversionScheduler.java b/backend/pensioner/scheduler/PendencyAutoConversionScheduler.java index d7114f2..5218b36 100644 --- a/backend/pensioner/scheduler/PendencyAutoConversionScheduler.java +++ b/backend/pensioner/scheduler/PendencyAutoConversionScheduler.java @@ -13,176 +13,216 @@ import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import in.gov.chennaicorporation.gccoffice.pensioner.service.PendencyAutoConversionService; +import in.gov.chennaicorporation.gccoffice.pensioner.service.ReceivedDeptProvisionalService; @Component public class PendencyAutoConversionScheduler { - @Autowired - private PendencyAutoConversionService pendencyAutoConversionService; - - /** - * Scheduled method that runs every 60 seconds to process auto-conversion tasks. - */ - @Scheduled(cron = "*/20 * * * * ?") // Runs every 60 seconds - public void executeAutoConversion() { - try { - System.out.println(" Running scheduled auto-conversion task..."); - - // Step 1: Fetch temp IDs that need processing - List> tempIds = pendencyAutoConversionService.getConvertingTempIds(); - - if (tempIds == null || tempIds.isEmpty()) { - System.out.println(" No records found for auto-conversion."); - return; - } - - System.out.println(" Found " + tempIds.size() + " records for processing."); - - // Step 2: Process each tempId - for (Map tempIdMap : tempIds) { - String tempId = tempIdMap.get("temp_id") != null ? tempIdMap.get("temp_id").toString() : null; - - if (tempId == null || tempId.trim().isEmpty()) { - System.out.println(" Skipping empty temp_id."); - continue; - } - - System.out.println(" Processing tempId: " + tempId); - - // Step 3: Call service method to process auto-conversion - boolean success = pendencyAutoConversionService.processAutoConversionForTempId(tempId); - - if (success) { - System.out.println(" Auto-conversion completed for tempId: " + tempId); - } else { - System.out.println(" Auto-conversion failed for tempId: " + tempId); - } - } - } catch (Exception e) { - System.err.println(" Error during auto-conversion task: " + e.getMessage()); - e.printStackTrace(); - } - } - - - @Scheduled(cron = "*/40 * * * * ?") // Runs every 40 seconds - public void scheduledPendencyUpdate() { - System.out.println("Scheduled Task Started: Updating Pensioner Pending Duration 30"); - - Map result = GetRecordsUpdatePendencyDuration(); - - System.out.println("Scheduled Task Completed: " + result); - - // Fetch the pending pensioners count after the update - int pendingCount = pendencyAutoConversionService.getPendingPensionersCount(); - System.out.println("Total pending pensioners after update: " + pendingCount); - } - - public Map GetRecordsUpdatePendencyDuration() { - Map response = new HashMap<>(); - - // Lists to store tempIds based on update success or failure - List successfulUpdates = new ArrayList<>(); - List failedUpdates = new ArrayList<>(); - - List> details = pendencyAutoConversionService.getPendencyUpdatingDuration(); - - if(!details.isEmpty()) { - - for (Map tempIdMap : details) { - String tempId = tempIdMap.get("temp_id") != null ? String.valueOf(tempIdMap.get("temp_id")) : null; - String retirementDateStr = tempIdMap.get("retirement_date") != null ? String.valueOf(tempIdMap.get("retirement_date")) : null; - String serviceDeathDate = tempIdMap.get("service_death") != null ? String.valueOf(tempIdMap.get("service_death")) : null; - // Corrected parsing for file_category - int fileCat = tempIdMap.get("file_category") != null ? Integer.parseInt(tempIdMap.get("file_category").toString()) : null; - - if(fileCat==3) { - - if (retirementDateStr != null && !retirementDateStr.trim().isEmpty()) { - try { - // Convert retirement_date to LocalDate - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - LocalDate startDate = LocalDate.parse(retirementDateStr, formatter); - LocalDate endDate = LocalDate.now(); // Current date - - System.out.printf("Processing Temp ID: %s | Start Date: %s | End Date: %s%n", tempId, startDate, endDate); - - // Calculate duration - String updateDuration = pendencyAutoConversionService.calculatePendingDuration(startDate, endDate); - System.out.println("Updated Duration: " + updateDuration); - - // Update the record in the database - boolean isUpdated = pendencyAutoConversionService.updatePendingDuration(updateDuration, tempId); - - // Add tempId to the respective list - if (isUpdated) { - successfulUpdates.add(tempId); - } else { - failedUpdates.add(tempId); - } - - } catch (Exception e) { - System.err.println("Error parsing retirement_date for tempId " + tempId + ": " + e.getMessage()); - } - } else { - System.out.println("Skipping: Retirement date is null or empty for tempId: " + tempId); - } - } - - - if(fileCat==2) { - - if (serviceDeathDate != null && !serviceDeathDate.trim().isEmpty()) { - try { - // Convert retirement_date to LocalDate - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - LocalDate startDate = LocalDate.parse(serviceDeathDate, formatter); - LocalDate endDate = LocalDate.now(); // Current date - - System.out.printf("Processing Temp ID: %s | Start Date: %s | End Date: %s%n", tempId, startDate, endDate); - - // Calculate duration - String updateDuration = pendencyAutoConversionService.calculatePendingDuration(startDate, endDate); - System.out.println("Updated Duration: " + updateDuration); - - // Update the record in the database - boolean isUpdated = pendencyAutoConversionService.updatePendingDuration(updateDuration, tempId); - - // Add tempId to the respective list - if (isUpdated) { - successfulUpdates.add(tempId); - } else { - failedUpdates.add(tempId); - } - - } catch (Exception e) { - System.err.println("Error parsing service death date for tempId " + tempId + ": " + e.getMessage()); - } - } else { - System.out.println("Skipping: service death date is null or empty for tempId: " + tempId); - } - } - - - - - } - response.put("status", "Success"); - response.put("message", "Pendency duration updated"); - response.put("total_records_processed", details.size()); - response.put("successful_updates_count", successfulUpdates.size()); - response.put("failed_updates_count", failedUpdates.size()); - response.put("successful_updates", successfulUpdates); - response.put("failed_updates", failedUpdates); - - } - - response.put("status", "No Data"); - response.put("message", "No Updation in Pending Duration"); - - return response; - } + @Autowired + private PendencyAutoConversionService pendencyAutoConversionService; + + @Autowired + public ReceivedDeptProvisionalService ReceivedDeptProvisionalservice; + + /** + * Scheduled method that runs every 60 seconds to process auto-conversion tasks. + */ + @Scheduled(cron = "*/20 * * * * ?") // Runs every 60 seconds + public void executeAutoConversion() { + try { + System.out.println(" Running scheduled auto-conversion task..."); + + // Step 1: Fetch temp IDs that need processing + List> tempIds = pendencyAutoConversionService.getConvertingTempIds(); + + if (tempIds == null || tempIds.isEmpty()) { + System.out.println(" No records found for auto-conversion."); + return; + } + + System.out.println(" Found " + tempIds.size() + " records for processing."); + + // Step 2: Process each tempId + for (Map tempIdMap : tempIds) { + String tempId = tempIdMap.get("temp_id") != null ? tempIdMap.get("temp_id").toString() : null; + + if (tempId == null || tempId.trim().isEmpty()) { + System.out.println(" Skipping empty temp_id."); + continue; + } + + System.out.println(" Processing tempId: " + tempId); + + // Step 3: Call service method to process auto-conversion + boolean success = pendencyAutoConversionService.processAutoConversionForTempId(tempId); + + if (success) { + System.out.println(" Auto-conversion completed for tempId: " + tempId); + } else { + System.out.println(" Auto-conversion failed for tempId: " + tempId); + } + } + } catch (Exception e) { + System.err.println(" Error during auto-conversion task: " + e.getMessage()); + e.printStackTrace(); + } + } + + + @Scheduled(cron = "*/40 * * * * ?") // Runs every 40 seconds + public void scheduledPendencyUpdate() { + System.out.println("Scheduled Task Started: Updating Pensioner Pending Duration 30"); + + Map result = GetRecordsUpdatePendencyDuration(); + + System.out.println("Scheduled Task Completed: " + result); + + // Fetch the pending pensioners count after the update + int pendingCount = pendencyAutoConversionService.getPendingPensionersCount(); + System.out.println("Total pending pensioners after update: " + pendingCount); + } + + public Map GetRecordsUpdatePendencyDuration() { + Map response = new HashMap<>(); + + // Lists to store tempIds based on update success or failure + List successfulUpdates = new ArrayList<>(); + List failedUpdates = new ArrayList<>(); + + List> details = pendencyAutoConversionService.getPendencyUpdatingDuration(); + + List> prdetails = pendencyAutoConversionService.getProvisionalNoPendingDuration(); + if(!prdetails.isEmpty()) { + + for (Map prdetail : prdetails) { + String tempId1 = prdetail.get("temp_id") != null ? String.valueOf(prdetail.get("temp_id")) : null; + String retirementDateStr1 = prdetail.get("retirement_date") != null ? String.valueOf(prdetail.get("retirement_date")) : null; + + try { + // Convert retirement_date to LocalDate + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate startDate1 = LocalDate.parse(retirementDateStr1, formatter); + LocalDate endDate1 = LocalDate.now(); + + System.out.printf("Processing Temp ID: %s | Start Date: %s | End Date: %s%n", tempId1, startDate1, endDate1); + + String updateDuration1 = pendencyAutoConversionService.calculatePendingDuration(startDate1, endDate1); + System.out.println("Updated Duration: " + updateDuration1); + + boolean isUpdated1 = pendencyAutoConversionService.updatePendingDurationforPR(updateDuration1, tempId1); + + if (isUpdated1) { + successfulUpdates.add(tempId1); + String filemovedby=pendencyAutoConversionService.getFileMovedByTempId(tempId1); + List> empDetails=pendencyAutoConversionService.fetchEmployeeDetails(tempId1); + boolean historySaved = ReceivedDeptProvisionalservice.savehistory(empDetails, filemovedby); + if (!historySaved) { + System.out.println("Failed to save prno history for tempId: " + tempId1); + } + } else { + failedUpdates.add(tempId1); + } + + } + catch (Exception e) { + System.err.println("Error parsing retirement_date for tempId " + tempId1 + ": " + e.getMessage()); + } + } + + } + if(!details.isEmpty()) { + + for (Map tempIdMap : details) { + String tempId = tempIdMap.get("temp_id") != null ? String.valueOf(tempIdMap.get("temp_id")) : null; + String retirementDateStr = tempIdMap.get("retirement_date") != null ? String.valueOf(tempIdMap.get("retirement_date")) : null; + String serviceDeathDate = tempIdMap.get("service_death") != null ? String.valueOf(tempIdMap.get("service_death")) : null; + // Corrected parsing for file_category + int fileCat = tempIdMap.get("file_category") != null ? Integer.parseInt(tempIdMap.get("file_category").toString()) : null; + + if(fileCat==3 || fileCat==5) { + + if (retirementDateStr != null && !retirementDateStr.trim().isEmpty()) { + try { + // Convert retirement_date to LocalDate + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate startDate = LocalDate.parse(retirementDateStr, formatter); + LocalDate endDate = LocalDate.now(); // Current date + + System.out.printf("Processing Temp ID: %s | Start Date: %s | End Date: %s%n", tempId, startDate, endDate); + + // Calculate duration + String updateDuration = pendencyAutoConversionService.calculatePendingDuration(startDate, endDate); + System.out.println("Updated Duration: " + updateDuration); + + // Update the record in the database + boolean isUpdated = pendencyAutoConversionService.updatePendingDuration(updateDuration, tempId); + + // Add tempId to the respective list + if (isUpdated) { + successfulUpdates.add(tempId); + } else { + failedUpdates.add(tempId); + } + + } catch (Exception e) { + System.err.println("Error parsing retirement_date for tempId " + tempId + ": " + e.getMessage()); + } + } else { + System.out.println("Skipping: Retirement date is null or empty for tempId: " + tempId); + } + } + + + if(fileCat==2) { + + if (serviceDeathDate != null && !serviceDeathDate.trim().isEmpty()) { + try { + // Convert retirement_date to LocalDate + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate startDate = LocalDate.parse(serviceDeathDate, formatter); + LocalDate endDate = LocalDate.now(); // Current date + + System.out.printf("Processing Temp ID: %s | Start Date: %s | End Date: %s%n", tempId, startDate, endDate); + + // Calculate duration + String updateDuration = pendencyAutoConversionService.calculatePendingDuration(startDate, endDate); + System.out.println("Updated Duration: " + updateDuration); + + // Update the record in the database + boolean isUpdated = pendencyAutoConversionService.updatePendingDuration(updateDuration, tempId); + + // Add tempId to the respective list + if (isUpdated) { + successfulUpdates.add(tempId); + } else { + failedUpdates.add(tempId); + } + + } catch (Exception e) { + System.err.println("Error parsing service death date for tempId " + tempId + ": " + e.getMessage()); + } + } else { + System.out.println("Skipping: service death date is null or empty for tempId: " + tempId); + } + } + + } + response.put("status", "Success"); + response.put("message", "Pendency duration updated"); + response.put("total_records_processed", details.size()); + response.put("successful_updates_count", successfulUpdates.size()); + response.put("failed_updates_count", failedUpdates.size()); + response.put("successful_updates", successfulUpdates); + response.put("failed_updates", failedUpdates); + + } + + response.put("status", "No Data"); + response.put("message", "No Updation in Pending Duration"); + + return response; + } } diff --git a/backend/pensioner/service/DepartmentReceivedService.java b/backend/pensioner/service/DepartmentReceivedService.java index a7418f2..facfca4 100644 --- a/backend/pensioner/service/DepartmentReceivedService.java +++ b/backend/pensioner/service/DepartmentReceivedService.java @@ -158,11 +158,11 @@ public class DepartmentReceivedService { private boolean CheckFieldsInDept(String tempId) { // Define the SQL query - String sql = "SELECT CASE " + - "WHEN gpf = 'yes' AND spfgs = 'yes' AND private_affairs = 'yes' AND dcrg = 'yes' THEN true " + - "ELSE false END AS allYes " + - "FROM zone_benefits " + - "WHERE temp_id = ?"; + String sql = "SELECT CASE " + + "WHEN (gpf = 'yes' OR gpf = '90') AND spfgs = 'yes' AND private_affairs = 'yes' AND dcrg = 'yes' THEN true " + + "ELSE false END AS allYes " + + "FROM zone_benefits " + + "WHERE temp_id = ?"; try { diff --git a/backend/pensioner/service/DeptPartiallyCompService.java b/backend/pensioner/service/DeptPartiallyCompService.java index 108a375..8141b4d 100644 --- a/backend/pensioner/service/DeptPartiallyCompService.java +++ b/backend/pensioner/service/DeptPartiallyCompService.java @@ -315,7 +315,7 @@ public class DeptPartiallyCompService { // Define the SQL query String sql = "SELECT \r\n" + " CASE \r\n" - + " WHEN zb.gpf = 'yes' AND zb.spfgs = 'yes' AND zb.private_affairs = 'yes' AND zb.dcrg = 'yes' \r\n" + + " WHEN (zb.gpf = 'yes' OR zb.gpf = '90') AND zb.spfgs = 'yes' AND zb.private_affairs = 'yes' AND zb.dcrg = 'yes' \r\n" + " AND pb.benefit_pension = 'yes' AND pb.benefit_dcrg = 'yes' THEN 1 ELSE 0 \r\n" + " END AS allYes \r\n" + "FROM zone_benefits AS zb\r\n" @@ -342,7 +342,7 @@ public class DeptPartiallyCompService { // Define the SQL query String sql = "SELECT \r\n" + " CASE \r\n" - + " WHEN zb.gpf = 'yes' AND zb.spfgs = 'yes' AND zb.private_affairs = 'yes' AND zb.dcrg = 'yes' \r\n" + + " WHEN (zb.gpf = 'yes' OR zb.gpf = '90') AND zb.spfgs = 'yes' AND zb.private_affairs = 'yes' AND zb.dcrg = 'yes' \r\n" + " THEN 1 ELSE 0 \r\n" + " END AS allYes\r\n" + "FROM zone_benefits AS zb\r\n" diff --git a/backend/pensioner/service/FileClosingService.java b/backend/pensioner/service/FileClosingService.java index 59fc41f..ef1f270 100644 --- a/backend/pensioner/service/FileClosingService.java +++ b/backend/pensioner/service/FileClosingService.java @@ -23,6 +23,8 @@ public class FileClosingService { @Autowired private JdbcTemplate jdbcTemplate; + + private RestTemplate restTemplate; private ObjectMapper objectMapper; @Autowired @@ -48,7 +50,7 @@ public class FileClosingService { String sql = "SELECT * " + "FROM pensioner_details pd " + - "where pd.file_category=1 and pd.file_status < 11 and pd.temp_id = ? and pd.is_closed=0 " ; + "where pd.file_category=1 and pd.file_status <= 8 and pd.temp_id = ? and pd.is_closed=0 " ; System.out.println("outside"); @@ -104,11 +106,14 @@ public class FileClosingService { int deptId = Integer.parseInt(dept_Id); - int filestatus=12; - + int filestatus=getFileStatus.getFileStatus12Id(); + if (filestatus == 0) { + System.out.println("File status not found. Aborting insertion."); + return false; + } // Update file_status in pensioner_details - String updateQuery = "update pensioner_details set service_death=?,file_moved_date=?,remarks=?,updated_date= CURRENT_TIMESTAMP,is_closed=1 WHERE temp_id = ? LIMIT 1"; - int rowsUpdated = jdbcTemplate.update(updateQuery,serviceDeath,dateToAudit, remarks,tempId); + String updateQuery = "update pensioner_details set file_status=?,service_death=?,file_moved_date=?,remarks=?,updated_date= CURRENT_TIMESTAMP,is_closed=1 WHERE temp_id = ? LIMIT 1"; + int rowsUpdated = jdbcTemplate.update(updateQuery,filestatus,serviceDeath,dateToAudit, remarks,tempId); System.out.println("Rows inserted in pd:"+rowsUpdated); @@ -175,13 +180,11 @@ public class FileClosingService { //closed list - public List> fetchClosingEmployee() { - - System.out.println("inside"); + public List> fetchClosingEmployee() { String sql = "SELECT * " + "FROM pensioner_details pd " + - "where pd.file_category=1 and pd.file_status < 11 and pd.is_closed=1 "; + "where pd.file_category=1 and pd.is_closed=1 "; return jdbcTemplate.queryForList(sql); diff --git a/backend/pensioner/service/NewEntryService.java b/backend/pensioner/service/NewEntryService.java index 64fff29..07f4103 100644 --- a/backend/pensioner/service/NewEntryService.java +++ b/backend/pensioner/service/NewEntryService.java @@ -1,6 +1,7 @@ package in.gov.chennaicorporation.gccoffice.pensioner.service; import java.text.ParseException; + import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.LocalDateTime; @@ -427,21 +428,16 @@ public class NewEntryService { } - public List> getRegisteredEmps(Integer deptId,Integer file_category) { - String query="select distinct emp_no from pensioner_details where dept_id=?"; - - List>emps= jdbcTemplate.queryForList(query,deptId); - System.out.println("emps===="+emps); - if(emps.isEmpty()) - { - return Collections.emptyList(); - } - else - { - return emps; - } - - } + public List getRegisteredEmps(Integer deptId, Integer file_category) { + String query = "SELECT DISTINCT emp_no FROM pensioner_details WHERE dept_id=? " + + "UNION ALL " + + "SELECT DISTINCT emp_no FROM cps_pensioner_details WHERE dept_id=?"; + + List emps = jdbcTemplate.queryForList(query, String.class, deptId, deptId); + System.out.println("emps====" + emps); + + return emps; + } public Integer getRetirementFileCategoryId() { String query = "SELECT id FROM file_category_master WHERE file_name = 'Retirement'"; @@ -841,7 +837,7 @@ public class NewEntryService { public boolean doesEmployeeExistRPR(String empCode) { String sql = "SELECT COUNT(*) FROM ( " + - " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1,2,3,4,5,6) " + + " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1,2,3,4,5) " + " UNION ALL " + " SELECT emp_no FROM cps_pensioner_details WHERE emp_no = ? AND file_category IN (6) " + ") AS combined"; @@ -851,15 +847,59 @@ public class NewEntryService { } - public boolean doesEmployeeExist(String empCode) { +// public boolean doesEmployeeExist(String empCode) { +// +// String sql = "SELECT COUNT(*) FROM ( " + +// " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1,3,5) "+ +// " UNION ALL " + +// " SELECT emp_no FROM cps_pensioner_details WHERE emp_no = ? AND file_category IN (6) " + +// ") AS combined"; +// // Note: Pass empCode twice since there are two placeholders. +// Integer count = jdbcTemplate.queryForObject(sql,Integer.class,empCode,empCode); +// System.out.println("count<<<<<<<<<<<"+count); +// return count != null && count > 0; +// } +// +// +// public boolean doesEmployeeExistgis(String empCode) { +// String sql = "SELECT COUNT(*) FROM ( " + +// " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1,2,3,5,6) " + +// " UNION ALL " + +// " SELECT emp_no FROM cps_pensioner_details WHERE emp_no = ? AND file_category IN (6) " + +// ") AS combined"; +// // Note: Pass empCode twice since there are two placeholders. +// Integer count = jdbcTemplate.queryForObject(sql, Integer.class,empCode,empCode); +// return count != null && count > 0; +// } +// +// +// public boolean doesEmployeeExistfp(String empCode) { +// +// String sql = "SELECT COUNT(*) FROM ( " + +// +// " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1,2,3,5) AND is_closed IN (0)" + +// " UNION ALL " + +// +// " SELECT emp_no FROM cps_pensioner_details WHERE emp_no = ? AND file_category IN (6) " + +// ") AS combined"; +// +// // Note: Pass empCode twice since there are two placeholders. +// Integer count = jdbcTemplate.queryForObject(sql, Integer.class,empCode,empCode); +// return count != null && count > 0; +// } + + + public boolean doesEmployeeExist(String empCode) { String sql = "SELECT COUNT(*) FROM ( " + - " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1,3,5) "+ + " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (3,4,5) "+ + " UNION ALL " + + " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1) AND is_closed=0 "+ " UNION ALL " + " SELECT emp_no FROM cps_pensioner_details WHERE emp_no = ? AND file_category IN (6) " + ") AS combined"; // Note: Pass empCode twice since there are two placeholders. - Integer count = jdbcTemplate.queryForObject(sql,Integer.class,empCode,empCode); + Integer count = jdbcTemplate.queryForObject(sql,Integer.class,empCode,empCode,empCode); System.out.println("count<<<<<<<<<<<"+count); return count != null && count > 0; } @@ -867,7 +907,7 @@ public class NewEntryService { public boolean doesEmployeeExistgis(String empCode) { String sql = "SELECT COUNT(*) FROM ( " + - " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1,2,3,5,6) " + + " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1,2,3,5) " + " UNION ALL " + " SELECT emp_no FROM cps_pensioner_details WHERE emp_no = ? AND file_category IN (6) " + ") AS combined"; @@ -877,13 +917,13 @@ public class NewEntryService { } - public boolean doesEmployeeExistfp(String empCode) { + public boolean doesEmployeeExistfp(String empCode) { String sql = "SELECT COUNT(*) FROM ( " + " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1,2,3,5) AND is_closed IN (0)" + " UNION ALL " + - + " SELECT emp_no FROM cps_pensioner_details WHERE emp_no = ? AND file_category IN (6) " + ") AS combined"; @@ -891,6 +931,5 @@ public class NewEntryService { Integer count = jdbcTemplate.queryForObject(sql, Integer.class,empCode,empCode); return count != null && count > 0; } - } \ No newline at end of file diff --git a/backend/pensioner/service/PendencyAutoConversionService.java b/backend/pensioner/service/PendencyAutoConversionService.java index 16875c0..04900d0 100644 --- a/backend/pensioner/service/PendencyAutoConversionService.java +++ b/backend/pensioner/service/PendencyAutoConversionService.java @@ -21,244 +21,260 @@ import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; @Transactional public class PendencyAutoConversionService { - @Autowired - private JdbcTemplate jdbcTemplate; - - @Autowired - private AppConfig appConfig; - - @Autowired - public void setDataSource(@Qualifier("mysqlPensionerDataSource") DataSource dataSource) { - this.jdbcTemplate = new JdbcTemplate(dataSource); - } - - /** - * Main method to process auto-conversion logic. - * - Fetch records where retirement date has crossed. - * - Update pensioner details. - * - Fetch employee details. - * - Save data into pensioner_details_history and file_movement_history. - */ - @Transactional - public boolean processAutoConversion() { - try { - // Step 1: Fetch temp IDs that need processing - List> tempList = getConvertingTempIds(); - if (tempList.isEmpty()) { - System.out.println("No records found for auto-conversion."); - return false; - } - - for (Map tempIdMap : tempList) { - String tempId = tempIdMap.get("temp_id") != null ? String.valueOf(tempIdMap.get("temp_id")) : null; - if (tempId == null || tempId.trim().isEmpty()) { - System.out.println("Skipping null/empty temp_id."); - continue; - } - - System.out.println("Processing tempId: " + tempId); - - // Step 2: Get file_moved_by value - String fileMovedBy = getFileMovedByTempId(tempId); - if (fileMovedBy == null) { - System.out.println("Skipping tempId " + tempId + " as fileMovedBy is NULL."); - continue; - } - - // Step 3: Update pensioner_details table - boolean updated = updateEntryDetails(tempId); - if (!updated) { - System.out.println("Failed to update pensioner_details for tempId: " + tempId); - continue; - } - - // Step 4: Fetch employee details - List> empDetails = fetchEmployeeDetails(tempId); - if (empDetails.isEmpty()) { - System.out.println("No employee details found for tempId: " + tempId); - continue; - } - - // Step 5: Save history data - boolean historySaved = saveHistory(empDetails, fileMovedBy); - if (!historySaved) { - System.out.println("Failed to save history for tempId: " + tempId); - } - } - - System.out.println("Auto-conversion process completed."); - return true; - } catch (Exception e) { - System.err.println("Exception in processAutoConversion: " + e.getMessage()); - e.printStackTrace(); - return false; - } - } - - public List> getConvertingTempIds() { - String sql = "SELECT temp_id FROM pensioner_details WHERE file_category=1 AND file_status <=8 AND retirement_date <= CURDATE() - 1"; - return jdbcTemplate.queryForList(sql); - } - - private boolean updateEntryDetails(String tempId) { - try { - LocalDate datefield = LocalDate.now(); - String formattedDate = datefield.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); - String remarks = "Auto_Conversion"; - int fileCategory = 3; - String pendingDuration = "yes"; - String reasonForPending = "Retirement Date Crossed while file in Auditing"; - - String updateQuery = "UPDATE pensioner_details SET reason_for_pending=?, pending_duration=?, file_category=?, file_moved_date=?, remarks=?, updated_date=CURRENT_TIMESTAMP WHERE temp_id=?"; - int rowsUpdated = jdbcTemplate.update(updateQuery, reasonForPending, pendingDuration, fileCategory, formattedDate, remarks, tempId); - - System.out.println("Updated pensioner_details for tempId: " + tempId + " - Rows affected: " + rowsUpdated); - return rowsUpdated > 0; - } catch (Exception e) { - System.err.println("Exception in updateEntryDetails: " + e.getMessage()); - return false; - } - } - - private List> fetchEmployeeDetails(String tempId) { - String sql = "SELECT * FROM pensioner_details WHERE temp_id=?"; - return jdbcTemplate.queryForList(sql, tempId); - } - - - @Transactional - private boolean saveHistory(List> empDetails, String fileMovedBy) { - try { - String empInsertQuery = "INSERT INTO pensioner_details_history (emp_no, emp_name, dept_name, designation, type_of_retirement, " + - "retirement_date, retirement_class, file_moved_date, remarks, file_category, file_status, " + - "file_entry_type, file_moved_by, dept_id, file_category_name, temp_id, pending_duration, reason_for_pending) " + - "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; - - jdbcTemplate.batchUpdate(empInsertQuery, empDetails, empDetails.size(), (ps, emp) -> { - ps.setString(1, emp.get("emp_no").toString()); - ps.setString(2, emp.get("emp_name").toString()); - ps.setString(3, emp.get("dept_name").toString()); - ps.setString(4, emp.get("designation").toString()); - ps.setString(5, emp.get("type_of_retirement").toString()); - ps.setString(6, emp.get("retirement_date").toString()); - ps.setString(7, emp.get("retirement_class").toString()); - ps.setString(8, emp.get("file_moved_date").toString()); - ps.setString(9, emp.get("remarks").toString()); - ps.setInt(10, Integer.parseInt(emp.get("file_category").toString())); - ps.setInt(11, Integer.parseInt(emp.get("file_status").toString())); - ps.setString(12, emp.get("file_entry_type").toString()); - ps.setString(13, fileMovedBy != null ? fileMovedBy : ""); - ps.setInt(14, Integer.parseInt(emp.get("dept_id").toString())); - ps.setString(15, emp.get("file_category_name").toString()); - ps.setString(16, emp.get("temp_id").toString()); - ps.setString(17, emp.get("pending_duration") != null ? emp.get("pending_duration").toString() : null); - ps.setString(18, emp.get("reason_for_pending") != null ? emp.get("reason_for_pending").toString() : null); - }); - - String historyQuery = "INSERT INTO file_movement_history (emp_no, file_moved_date, file_status, file_moved_by, remarks, temp_id) VALUES (?, ?, ?, ?, ?, ?)"; - - jdbcTemplate.batchUpdate(historyQuery, empDetails, empDetails.size(), (ps, his) -> { - ps.setString(1, his.get("emp_no").toString()); - ps.setString(2, his.get("file_moved_date").toString()); - ps.setString(3, his.get("file_status").toString()); - ps.setString(4, fileMovedBy != null ? fileMovedBy : ""); - ps.setString(5, his.get("remarks").toString()); - ps.setString(6, his.get("temp_id").toString()); - }); - - System.out.println("Successfully saved history for " + empDetails.size() + " records."); - return true; - } catch (Exception e) { - System.err.println("Exception in saveHistory: " + e.getMessage()); - return false; - } - } - - private String getFileMovedByTempId(String tempId) { - String sql = "SELECT file_moved_by FROM pensioner_details_history WHERE temp_id=? ORDER BY created_date ASC LIMIT 1"; - return jdbcTemplate.queryForObject(sql, String.class, tempId); - } - - - public boolean processAutoConversionForTempId(String tempId) { - try { - System.out.println("Running auto-conversion for tempId: " + tempId); - - // Step 1: Get fileMovedBy - String fileMovedBy = getFileMovedByTempId(tempId); - if (fileMovedBy == null) { - System.out.println("Skipping tempId " + tempId + " as fileMovedBy is NULL."); - return false; - } - - // Step 2: Update pensioner details - boolean updated = updateEntryDetails(tempId); - if (!updated) { - System.out.println("Failed to update pensioner_details for tempId: " + tempId); - return false; - } - - // Step 3: Fetch employee details - List> empDetails = fetchEmployeeDetails(tempId); - if (empDetails.isEmpty()) { - System.out.println("No employee details found for tempId: " + tempId); - return false; - } - - // Step 4: Save history - boolean historySaved = saveHistory(empDetails, fileMovedBy); - if (!historySaved) { - System.out.println("Failed to save history for tempId: " + tempId); - return false; - } - - System.out.println("Successfully processed tempId: " + tempId); - return true; - } catch (Exception e) { - System.err.println("Error processing tempId: " + tempId + " - " + e.getMessage()); - e.printStackTrace(); - return false; - } -} - - public List> getPendencyUpdatingDuration(){ - - String sqlQuery = "SELECT * FROM pensioner_details WHERE file_category IN (2,3) AND pending_duration='yes' AND file_status < 11"; - List> details = jdbcTemplate.queryForList(sqlQuery); + @Autowired + private JdbcTemplate jdbcTemplate; + + @Autowired + private AppConfig appConfig; + + @Autowired + public void setDataSource(@Qualifier("mysqlPensionerDataSource") DataSource dataSource) { + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + /** + * Main method to process auto-conversion logic. + * - Fetch records where retirement date has crossed. + * - Update pensioner details. + * - Fetch employee details. + * - Save data into pensioner_details_history and file_movement_history. + */ + @Transactional + public boolean processAutoConversion() { + try { + // Step 1: Fetch temp IDs that need processing + List> tempList = getConvertingTempIds(); + if (tempList.isEmpty()) { + System.out.println("No records found for auto-conversion."); + return false; + } + + for (Map tempIdMap : tempList) { + String tempId = tempIdMap.get("temp_id") != null ? String.valueOf(tempIdMap.get("temp_id")) : null; + if (tempId == null || tempId.trim().isEmpty()) { + System.out.println("Skipping null/empty temp_id."); + continue; + } + + System.out.println("Processing tempId: " + tempId); + + // Step 2: Get file_moved_by value + String fileMovedBy = getFileMovedByTempId(tempId); + if (fileMovedBy == null) { + System.out.println("Skipping tempId " + tempId + " as fileMovedBy is NULL."); + continue; + } + + // Step 3: Update pensioner_details table + boolean updated = updateEntryDetails(tempId); + if (!updated) { + System.out.println("Failed to update pensioner_details for tempId: " + tempId); + continue; + } + + // Step 4: Fetch employee details + List> empDetails = fetchEmployeeDetails(tempId); + if (empDetails.isEmpty()) { + System.out.println("No employee details found for tempId: " + tempId); + continue; + } + + // Step 5: Save history data + boolean historySaved = saveHistory(empDetails, fileMovedBy); + if (!historySaved) { + System.out.println("Failed to save history for tempId: " + tempId); + } + } + + System.out.println("Auto-conversion process completed."); + return true; + } catch (Exception e) { + System.err.println("Exception in processAutoConversion: " + e.getMessage()); + e.printStackTrace(); + return false; + } + } + + public List> getConvertingTempIds() { + String sql = "SELECT temp_id FROM pensioner_details WHERE file_category=1 AND file_status <=8 AND retirement_date <= CURDATE() - 1"; + return jdbcTemplate.queryForList(sql); + } + + private boolean updateEntryDetails(String tempId) { + try { + LocalDate datefield = LocalDate.now(); + String formattedDate = datefield.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); + String remarks = "Auto_Conversion"; + int fileCategory = 3; + String pendingDuration = "yes"; + String reasonForPending = "Retirement Date Crossed while file in Processing"; + + String updateQuery = "UPDATE pensioner_details SET reason_for_pending=?, pending_duration=?, file_category=?, file_moved_date=?, remarks=?, updated_date=CURRENT_TIMESTAMP WHERE temp_id=?"; + int rowsUpdated = jdbcTemplate.update(updateQuery, reasonForPending, pendingDuration, fileCategory, formattedDate, remarks, tempId); + + System.out.println("Updated pensioner_details for tempId: " + tempId + " - Rows affected: " + rowsUpdated); + return rowsUpdated > 0; + } catch (Exception e) { + System.err.println("Exception in updateEntryDetails: " + e.getMessage()); + return false; + } + } + + public List> fetchEmployeeDetails(String tempId) { + String sql = "SELECT * FROM pensioner_details WHERE temp_id=?"; + return jdbcTemplate.queryForList(sql, tempId); + } + - return details; - + @Transactional + public boolean saveHistory(List> empDetails, String fileMovedBy) { + try { + String empInsertQuery = "INSERT INTO pensioner_details_history (emp_no, emp_name, dept_name, designation, type_of_retirement, " + + "retirement_date, retirement_class, file_moved_date, remarks, file_category, file_status, " + + "file_entry_type, file_moved_by, dept_id, file_category_name, temp_id, pending_duration, reason_for_pending) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + + jdbcTemplate.batchUpdate(empInsertQuery, empDetails, empDetails.size(), (ps, emp) -> { + ps.setString(1, emp.get("emp_no").toString()); + ps.setString(2, emp.get("emp_name").toString()); + ps.setString(3, emp.get("dept_name").toString()); + ps.setString(4, emp.get("designation").toString()); + ps.setString(5, emp.get("type_of_retirement").toString()); + ps.setString(6, emp.get("retirement_date").toString()); + ps.setString(7, emp.get("retirement_class").toString()); + ps.setString(8, emp.get("file_moved_date").toString()); + ps.setString(9, emp.get("remarks").toString()); + ps.setInt(10, Integer.parseInt(emp.get("file_category").toString())); + ps.setInt(11, Integer.parseInt(emp.get("file_status").toString())); + ps.setString(12, emp.get("file_entry_type").toString()); + ps.setString(13, fileMovedBy != null ? fileMovedBy : ""); + ps.setInt(14, Integer.parseInt(emp.get("dept_id").toString())); + ps.setString(15, emp.get("file_category_name").toString()); + ps.setString(16, emp.get("temp_id").toString()); + ps.setString(17, emp.get("pending_duration") != null ? emp.get("pending_duration").toString() : null); + ps.setString(18, emp.get("reason_for_pending") != null ? emp.get("reason_for_pending").toString() : null); + }); + + String historyQuery = "INSERT INTO file_movement_history (emp_no, file_moved_date, file_status, file_moved_by, remarks, temp_id) VALUES (?, ?, ?, ?, ?, ?)"; + + jdbcTemplate.batchUpdate(historyQuery, empDetails, empDetails.size(), (ps, his) -> { + ps.setString(1, his.get("emp_no").toString()); + ps.setString(2, his.get("file_moved_date").toString()); + ps.setString(3, his.get("file_status").toString()); + ps.setString(4, fileMovedBy != null ? fileMovedBy : ""); + ps.setString(5, his.get("remarks").toString()); + ps.setString(6, his.get("temp_id").toString()); + }); + + System.out.println("Successfully saved history for " + empDetails.size() + " records."); + return true; + } catch (Exception e) { + System.err.println("Exception in saveHistory: " + e.getMessage()); + return false; + } + } + + public String getFileMovedByTempId(String tempId) { + String sql = "SELECT file_moved_by FROM pensioner_details_history WHERE temp_id=? ORDER BY created_date DESC LIMIT 1"; + return jdbcTemplate.queryForObject(sql, String.class, tempId); + } + + + public boolean processAutoConversionForTempId(String tempId) { + try { + System.out.println("Running auto-conversion for tempId: " + tempId); + + // Step 1: Get fileMovedBy + String fileMovedBy = getFileMovedByTempId(tempId); + if (fileMovedBy == null) { + System.out.println("Skipping tempId " + tempId + " as fileMovedBy is NULL."); + return false; + } + + // Step 2: Update pensioner details + boolean updated = updateEntryDetails(tempId); + if (!updated) { + System.out.println("Failed to update pensioner_details for tempId: " + tempId); + return false; + } + + // Step 3: Fetch employee details + List> empDetails = fetchEmployeeDetails(tempId); + if (empDetails.isEmpty()) { + System.out.println("No employee details found for tempId: " + tempId); + return false; + } + + // Step 4: Save history + boolean historySaved = saveHistory(empDetails, fileMovedBy); + if (!historySaved) { + System.out.println("Failed to save history for tempId: " + tempId); + return false; + } + + System.out.println("Successfully processed tempId: " + tempId); + return true; + } catch (Exception e) { + System.err.println("Error processing tempId: " + tempId + " - " + e.getMessage()); + e.printStackTrace(); + return false; + } } - - public String calculatePendingDuration(LocalDate startDate, LocalDate endDate) { - Period period = Period.between(startDate, endDate); - - int years = period.getYears(); - int months = period.getMonths(); - int days = period.getDays(); - - if (years == 0 && months == 0 && days == 0) { - return "0 days"; // or "Same day" - } - - return (years > 0 ? years + " year " : "") + - (months > 0 ? months + " month " : "") + - (days > 0 ? days + " day" : ""); - } - - public boolean updatePendingDuration(String updateDuration, String tempId) { - String sqlQuery = "UPDATE pensioner_details SET reason_for_pending=? WHERE temp_id=?"; - int rowsUpdated = jdbcTemplate.update(sqlQuery, updateDuration, tempId); - System.out.println("Temp ID: " + tempId + " | Rows Updated: " + rowsUpdated); - return rowsUpdated > 0; - } - - // New method to get the count of pending pensioners - public int getPendingPensionersCount() { - String sqlQuery = "SELECT COUNT(*) FROM pensioner_details WHERE file_category=3 AND pending_duration='yes' AND file_status < 11"; - Integer count = jdbcTemplate.queryForObject(sqlQuery, Integer.class); - return count != null ? count : 0; - } + + public List> getPendencyUpdatingDuration(){ + + String sqlQuery = "SELECT * FROM pensioner_details WHERE file_category IN (2,3,5) AND (pending_duration = 'yes' OR pending_duration = 'Yes') AND file_status < 11"; + List> details = jdbcTemplate.queryForList(sqlQuery); + + return details; + + } + + public List> getProvisionalNoPendingDuration(){ + + String sqlQuery = "SELECT * FROM pensioner_details WHERE file_category IN (5) AND (pending_duration = 'no' OR pending_duration = 'No') AND file_status < 11 AND retirement_date < curdate()"; + List> prdetails = jdbcTemplate.queryForList(sqlQuery); + + return prdetails; + + } + + public String calculatePendingDuration(LocalDate startDate, LocalDate endDate) { + Period period = Period.between(startDate, endDate); + + int years = period.getYears(); + int months = period.getMonths(); + int days = period.getDays(); + + if (years == 0 && months == 0 && days == 0) { + return "0 days"; // or "Same day" + } + + return (years > 0 ? years + " year " : "") + + (months > 0 ? months + " month " : "") + + (days > 0 ? days + " day" : ""); + } + + public boolean updatePendingDuration(String updateDuration, String tempId) { + String sqlQuery = "UPDATE pensioner_details SET reason_for_pending=? WHERE temp_id=?"; + int rowsUpdated = jdbcTemplate.update(sqlQuery, updateDuration, tempId); + System.out.println("Temp ID: " + tempId + " | Rows Updated: " + rowsUpdated); + return rowsUpdated > 0; + } + + public boolean updatePendingDurationforPR(String updateDuration1, String tempId1) { + String sqlQuery = "UPDATE pensioner_details SET pending_duration='Yes',reason_for_pending=? WHERE temp_id=?"; + int rowsUpdated = jdbcTemplate.update(sqlQuery, updateDuration1, tempId1); + System.out.println("Updating for PR No Temp ID: " + tempId1 + " | Rows Updated: " + rowsUpdated); + return rowsUpdated > 0; + } + + // New method to get the count of pending pensioners + public int getPendingPensionersCount() { + String sqlQuery = "SELECT COUNT(*) FROM pensioner_details WHERE file_category=3 AND pending_duration='yes' AND file_status < 11"; + Integer count = jdbcTemplate.queryForObject(sqlQuery, Integer.class); + return count != null ? count : 0; + } } diff --git a/backend/pensioner/service/ReportApiService.java b/backend/pensioner/service/ReportApiService.java index b260691..b159596 100644 --- a/backend/pensioner/service/ReportApiService.java +++ b/backend/pensioner/service/ReportApiService.java @@ -230,35 +230,131 @@ public class ReportApiService { +// public List> getReportDatapension(String startDate, String endDate, String fileCategoryId) { +// String sql = "SELECT dm.dept_id, " + +// " dm.dept_name AS dept_name, " + +// +// // Audit Pending Count +// " (SELECT COUNT(*) FROM pensioner_details pd " + +// " WHERE pd.file_status IN (1,3) AND pd.dept_id = dm.dept_id " + +// " AND pd.is_closed = 0 " + // Added condition +// " AND ( ? IS NULL OR pd.file_category = ? ) " + +// " AND DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?)) AS audit_pending, " + +// +// // Department Pending Count +// " (SELECT COUNT(*) FROM pensioner_details pd " + +// " WHERE pd.file_status IN (2,5,6,9) AND pd.dept_id = dm.dept_id " + +// " AND pd.is_closed = 0 " + // Added condition +// " AND ( ? IS NULL OR pd.file_category = ? ) " + +// " AND DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?)) AS department_pending, " + +// +// // Pension Pending Count +// " (SELECT COUNT(*) FROM pensioner_details pd " + +// " WHERE pd.file_status IN (4,7,8,10) AND pd.dept_id = dm.dept_id " + +// " AND pd.is_closed = 0 " + // Added condition +// " AND ( ? IS NULL OR pd.file_category = ? ) " + +// " AND DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?)) AS pension_pending, " + +// +// // Completed Count +// " (SELECT COUNT(*) FROM pensioner_details pd " + +// " WHERE pd.file_status = 11 AND pd.dept_id = dm.dept_id " + +// " AND pd.is_closed = 0 " + // Added condition +// " AND ( ? IS NULL OR pd.file_category = ? ) " + +// " AND DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?)) " + +// " + " + +// " (SELECT COUNT(*) FROM cps_pensioner_details cps " + +// " WHERE cps.file_status = 11 AND cps.dept_id = dm.dept_id " + +// " AND ( ? IS NULL OR cps.file_category = ? ) " + +// " AND DATE(cps.created_date) BETWEEN DATE(?) AND DATE(?)) AS completed, " + +// +// // Total Files Count +// " (SELECT COUNT(*) pensioner_details pd " + +// " WHERE pd.dept_id = dm.dept_id " + +// " AND pd.is_closed = 0 " + // Added condition +// " AND ( ? IS NULL OR pd.file_category = ? ) " + +// " AND DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?)) " + +// " + " + +// " (SELECT COUNT(*) FROM cps_pensioner_details cps " + +// " WHERE cps.dept_id = dm.dept_id " + +// " AND ( ? IS NULL OR cps.file_category = ? ) " + +// " AND DATE(cps.created_date) BETWEEN DATE(?) AND DATE(?)) AS total_files " + +// +// "FROM department_master dm " + +// "ORDER BY dm.dept_id"; +// +// System.out.println("Executing SQL: " + sql); +// +// List params = new ArrayList<>(); +// +// // Adding parameters explicitly without a loop +// params.add(fileCategoryId != null && !fileCategoryId.isEmpty() ? fileCategoryId : null); +// params.add(fileCategoryId); +// params.add(startDate); +// params.add(endDate); +// +// params.add(fileCategoryId != null && !fileCategoryId.isEmpty() ? fileCategoryId : null); +// params.add(fileCategoryId); +// params.add(startDate); +// params.add(endDate); +// +// params.add(fileCategoryId != null && !fileCategoryId.isEmpty() ? fileCategoryId : null); +// params.add(fileCategoryId); +// params.add(startDate); +// params.add(endDate); +// +// params.add(fileCategoryId != null && !fileCategoryId.isEmpty() ? fileCategoryId : null); +// params.add(fileCategoryId); +// params.add(startDate); +// params.add(endDate); +// +// params.add(fileCategoryId != null && !fileCategoryId.isEmpty() ? fileCategoryId : null); +// params.add(fileCategoryId); +// params.add(startDate); +// params.add(endDate); +// +// params.add(fileCategoryId != null && !fileCategoryId.isEmpty() ? fileCategoryId : null); +// params.add(fileCategoryId); +// params.add(startDate); +// params.add(endDate); +// +// params.add(fileCategoryId != null && !fileCategoryId.isEmpty() ? fileCategoryId : null); +// params.add(fileCategoryId); +// params.add(startDate); +// params.add(endDate); +// +// return jdbcTemplate.queryForList(sql, params.toArray()); +// } + + public List> getReportDatapension(String startDate, String endDate, String fileCategoryId) { String sql = "SELECT dm.dept_id, " + - " dm.dept_name AS dept_name, " + + " dm.dept_name AS dept_name, " + // Audit Pending Count " (SELECT COUNT(*) FROM pensioner_details pd " + " WHERE pd.file_status IN (1,3) AND pd.dept_id = dm.dept_id " + - " AND pd.is_closed = 0 " + // Added condition + " AND pd.is_closed = 0 " + " AND ( ? IS NULL OR pd.file_category = ? ) " + " AND DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?)) AS audit_pending, " + // Department Pending Count " (SELECT COUNT(*) FROM pensioner_details pd " + " WHERE pd.file_status IN (2,5,6,9) AND pd.dept_id = dm.dept_id " + - " AND pd.is_closed = 0 " + // Added condition + " AND pd.is_closed = 0 " + " AND ( ? IS NULL OR pd.file_category = ? ) " + " AND DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?)) AS department_pending, " + // Pension Pending Count " (SELECT COUNT(*) FROM pensioner_details pd " + " WHERE pd.file_status IN (4,7,8,10) AND pd.dept_id = dm.dept_id " + - " AND pd.is_closed = 0 " + // Added condition + " AND pd.is_closed = 0 " + " AND ( ? IS NULL OR pd.file_category = ? ) " + " AND DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?)) AS pension_pending, " + // Completed Count " (SELECT COUNT(*) FROM pensioner_details pd " + " WHERE pd.file_status = 11 AND pd.dept_id = dm.dept_id " + - " AND pd.is_closed = 0 " + // Added condition + " AND pd.is_closed = 0 " + " AND ( ? IS NULL OR pd.file_category = ? ) " + " AND DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?)) " + " + " + @@ -268,9 +364,9 @@ public class ReportApiService { " AND DATE(cps.created_date) BETWEEN DATE(?) AND DATE(?)) AS completed, " + // Total Files Count - " (SELECT COUNT(*) pensioner_details pd " + + " (SELECT COUNT(*) FROM pensioner_details pd " + // Fixed Syntax " WHERE pd.dept_id = dm.dept_id " + - " AND pd.is_closed = 0 " + // Added condition + " AND pd.is_closed = 0 " + " AND ( ? IS NULL OR pd.file_category = ? ) " + " AND DATE(pd.created_date) BETWEEN DATE(?) AND DATE(?)) " + " + " + @@ -286,45 +382,17 @@ public class ReportApiService { List params = new ArrayList<>(); - // Adding parameters explicitly without a loop - params.add(fileCategoryId != null && !fileCategoryId.isEmpty() ? fileCategoryId : null); - params.add(fileCategoryId); - params.add(startDate); - params.add(endDate); - - params.add(fileCategoryId != null && !fileCategoryId.isEmpty() ? fileCategoryId : null); - params.add(fileCategoryId); - params.add(startDate); - params.add(endDate); - - params.add(fileCategoryId != null && !fileCategoryId.isEmpty() ? fileCategoryId : null); - params.add(fileCategoryId); - params.add(startDate); - params.add(endDate); - - params.add(fileCategoryId != null && !fileCategoryId.isEmpty() ? fileCategoryId : null); - params.add(fileCategoryId); - params.add(startDate); - params.add(endDate); - - params.add(fileCategoryId != null && !fileCategoryId.isEmpty() ? fileCategoryId : null); - params.add(fileCategoryId); - params.add(startDate); - params.add(endDate); - - params.add(fileCategoryId != null && !fileCategoryId.isEmpty() ? fileCategoryId : null); - params.add(fileCategoryId); - params.add(startDate); - params.add(endDate); - - params.add(fileCategoryId != null && !fileCategoryId.isEmpty() ? fileCategoryId : null); - params.add(fileCategoryId); - params.add(startDate); - params.add(endDate); + for (int i = 0; i < 7; i++) { + params.add(fileCategoryId != null && !fileCategoryId.isEmpty() ? fileCategoryId : null); + params.add(fileCategoryId); + params.add(startDate); + params.add(endDate); + } return jdbcTemplate.queryForList(sql, params.toArray()); } + // public List> getReportDetailspension(String startDate, String endDate, List deptIds, Integer fileCatId, List fileStatus) { // String sql = ""; diff --git a/frontend/pensioner/department/audit/familypension.html b/frontend/pensioner/department/audit/familypension.html index 7641014..95d6160 100644 --- a/frontend/pensioner/department/audit/familypension.html +++ b/frontend/pensioner/department/audit/familypension.html @@ -93,7 +93,7 @@ cursor: pointer; /* Change cursor to hand symbol */ } -#returnretrieddetailsModal .modal-body{ +#returnfamilypensiondetailsModal .modal-body{ max-height:80vh; overflow-y:auto; } @@ -275,7 +275,7 @@ margin-top: 10px; + --> @@ -817,7 +819,8 @@ margin-top: 10px; console.log("retirementdate",retirementdate); - + let status=employeeDetails.file_status; + console.log("status=:"+status); // Update the modal title with the employee code @@ -828,7 +831,10 @@ margin-top: 10px; //zone benefits fields - + if (status >= 6 && status <= 8) { + + + $('#showZoneBenefit').show(); if (employeeDetails.gpf === 'yes') { $('#gpfYes').prop('checked', true); // Disable radio @@ -907,8 +913,14 @@ margin-top: 10px; $('#dcrgYes').prop('disabled', true); } + + } + else if(status <=5) + { + $('#showZoneBenefit').hide(); + } - $('#pensionNumber').val(employeeDetails.pension_number).prop('readonly',true); + /* $('#pensionNumber').val(employeeDetails.pension_number).prop('readonly',true); $('#ledgerNumber').val(employeeDetails.ledger_number).prop('readonly',true); $('input[name="benefit_pension"][value="' + employeeDetails.benefit_pension + '"]').prop('checked', true); @@ -962,7 +974,7 @@ margin-top: 10px; $('#CommutationAmountDiv').hide(); $('#commutationNo').prop('disabled', true); $('#commutationYes').prop('disabled', true); - } + } */ //$('#datefile').val(''); $('#remarks').val(''); @@ -1077,7 +1089,7 @@ margin-top: 10px; - document.querySelectorAll('input[name="benefit_pension"]').forEach(radio => { + /* document.querySelectorAll('input[name="benefit_pension"]').forEach(radio => { radio.addEventListener('change', function () { const PbAmountDiv = document.getElementById('PbAmountDiv'); if (this.value === 'yes') { @@ -1113,7 +1125,7 @@ margin-top: 10px; document.getElementById('benefit_commutation_amount').value = ''; // Clear the input field } }); - }); + }); */ }); diff --git a/frontend/pensioner/department/newentry/contributorypensionscheme.html b/frontend/pensioner/department/newentry/contributorypensionscheme.html index e7088c0..0c3ed7c 100644 --- a/frontend/pensioner/department/newentry/contributorypensionscheme.html +++ b/frontend/pensioner/department/newentry/contributorypensionscheme.html @@ -159,7 +159,7 @@ padding-top: 2%;
-
New Entry - Contributory Pension
+
 Department
New Entry - Contributory Pension
diff --git a/frontend/pensioner/department/newentry/familypension.html b/frontend/pensioner/department/newentry/familypension.html index db300cc..8dfbfe1 100644 --- a/frontend/pensioner/department/newentry/familypension.html +++ b/frontend/pensioner/department/newentry/familypension.html @@ -532,7 +532,7 @@ padding-top: 2%; const currentDate = $('#filesentdate').val().trim(); - if(employeeDetails.RETIREMENT_DATE <= currentDate){ + /* if(employeeDetails.RETIREMENT_DATE <= currentDate){ Swal.fire({ icon: "warning", @@ -544,7 +544,7 @@ padding-top: 2%; } }); return; - } + } */ // Populate the form fields with the employee details $('#employeeno').val(employeeDetails.EMPLOYEE_CODE); diff --git a/frontend/pensioner/department/partial/familypension.html b/frontend/pensioner/department/partial/familypension.html index b72069e..cd40d2b 100644 --- a/frontend/pensioner/department/partial/familypension.html +++ b/frontend/pensioner/department/partial/familypension.html @@ -266,7 +266,7 @@ margin-top: 10px; -
+