package in.gov.chennaicorporation.gccoffice.pensioner.controller; import java.util.List; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import in.gov.chennaicorporation.gccoffice.pensioner.service.DashboardApiService; @RestController public class DashboardApiController { @Autowired private DashboardApiService dashboardApiService; @GetMapping("/dashboard") @ResponseBody public List> getDashboardData() { return dashboardApiService.fetchCategoryCounts(); } /*@GetMapping("/dashboardsearch") @ResponseBody public List> fetchDashboardData( @RequestParam(required = false) String startdate, @RequestParam(required = false) String enddate) { System.out.println("Endpoint hit with startdate: " + startdate + ", enddate: " + enddate); try { return dashboardApiService.fetchCategorysearchCounts(startdate, enddate); } catch (Exception e) { e.printStackTrace(); // Print fetchCategoryCounts stack trace to the logs throw e; // Rethrow the exception to propagate the 500 error } } @GetMapping("/categoryCounts") public List> getCategoryCounts() { return dashboardApiService.fetchCategoryCounts(); } @GetMapping("/getEmpNoByFileName") public List> getEmployeeDetails(@RequestParam("file_id") String FileId) { System.out.println("before fetch"); return dashboardApiService.getEmployeeDetails(FileId); } @GetMapping("/stageWiseCounts") public ResponseEntity>> getStageWiseCounts() { List> stageWiseCounts = dashboardApiService.getStageWiseCounts(); return ResponseEntity.ok(stageWiseCounts); }*/ @GetMapping("/getDepartments") @ResponseBody public List> getDepartment() { return dashboardApiService.getDepartment(); } @GetMapping("/getEmpNoByFileName") public List> getEmployeeDetails(@RequestParam("file_id") String FileId) { System.out.println("before fetch"); return dashboardApiService.getEmployeeDetails(FileId); } //department @GetMapping("/deparmentdashboard") @ResponseBody public List> getDepartmentDashboardData(@RequestParam(required = false) String deptId) { System.out.println("deptid"+ deptId); return dashboardApiService.DepartmenfetchCategoryCounts(deptId); } /* @GetMapping("/deparmentcategoryCounts") public List> getDepartmenCategoryCounts(@RequestParam(required = false) String deptId) { return dashboardApiService.DepartmenfetchCategoryCounts(deptId); } //DepartmentstageWiseCounts @GetMapping("/DepartmentstageWiseCounts") public ResponseEntity>> getDepartmentStageWiseCounts(@RequestParam(required = false) String deptId) { List> stageWiseCounts = dashboardApiService.getDepartmentStageWiseCounts(deptId); return ResponseEntity.ok(stageWiseCounts); }*/ @GetMapping("/stageWiseCounts") public ResponseEntity>> getDepartmentStageWiseCounts( @RequestParam(required = false) String deptId, @RequestParam(required = false) String startDate, @RequestParam(required = false) String endDate) { if(startDate.isEmpty()) { startDate=null; } if(endDate.isEmpty()) { endDate=null; } List> stageWiseCounts = dashboardApiService.getStageWiseCounts(deptId, startDate, endDate); return ResponseEntity.ok(stageWiseCounts); } @GetMapping("/categoryCounts") public List> getDepartmenCategoryCounts( @RequestParam(required = false) String deptId, @RequestParam(required = false) String startDate, @RequestParam(required = false) String endDate) { if(startDate.isEmpty()) { startDate=null; } if(endDate.isEmpty()) { endDate=null; } return dashboardApiService.fetchchartCategoryCounts(deptId, startDate, endDate); } @GetMapping("/dashboardsearch") @ResponseBody public List> fetchDeparmentDashboardData( @RequestParam(required = false) String startdate, @RequestParam(required = false) String enddate,@RequestParam(required = false) String deptId) { if(deptId.isEmpty()) { deptId=null; } System.out.println("Endpoint hit with startdate: " + startdate + ", enddate: " + enddate); try { return dashboardApiService.fetchCategorysearchCounts(startdate, enddate,deptId); } catch (Exception e) { e.printStackTrace(); // Print fetchCategoryCounts stack trace to the logs throw e; // Rethrow the exception to propagate the 500 error } } //pension @GetMapping("/pensiondashboard") @ResponseBody public List> getPensionDashboardData(@RequestParam(required = false) String deptId) { System.out.println("deptid"+ deptId); return dashboardApiService.DepartmenfetchCategoryCounts(deptId); } /* @GetMapping("/pensiondashboardsearch") @ResponseBody public List> fetchpensionDashboardData( @RequestParam(required = false) String startdate, @RequestParam(required = false) String enddate,@RequestParam(required = false) String deptId) { if(deptId.isEmpty()) { deptId=null; } System.out.println("Endpoint hit with startdate: " + startdate + ", enddate: " + enddate); try { return dashboardApiService.fetchDeparmentCategorysearchCounts(startdate, enddate,deptId); } catch (Exception e) { e.printStackTrace(); // Print fetchCategoryCounts stack trace to the logs throw e; // Rethrow the exception to propagate the 500 error } }*/ /* @GetMapping("/pensioncategoryCounts") public List> getpensionCategoryCounts( @RequestParam(required = false) String deptId, @RequestParam(required = false) String startDate, @RequestParam(required = false) String endDate) { if(startDate.isEmpty()) { startDate=null; } if(endDate.isEmpty()) { endDate=null; } return dashboardApiService.DepartmenfetchDepartmentCategoryCounts(deptId, startDate, endDate); }*/ /* @GetMapping("/pensionstageWiseCounts") public ResponseEntity>> getpensionStageWiseCounts( @RequestParam(required = false) String deptId, @RequestParam(required = false) String startDate, @RequestParam(required = false) String endDate) { if(startDate.isEmpty()) { startDate=null; } if(endDate.isEmpty()) { endDate=null; } List> stageWiseCounts = dashboardApiService.getDepartmentStageWiseCounts(deptId, startDate, endDate); return ResponseEntity.ok(stageWiseCounts); }*/ @GetMapping("/fetchEmpDetails") public List> getEmpDetails(@RequestParam(required = false) String Empcode) { System.out.println("checking"); System.out.println(Empcode); return dashboardApiService.getEmpDetails(Empcode); } @GetMapping("/fetchPensionEmpDetails") public List> getPensionEmpDetails(@RequestParam(required = false) String Empcode) { System.out.println("checking"); System.out.println(Empcode); return dashboardApiService.getPensionEmpDetails(Empcode); } @GetMapping("/fetchTempDetails") public List> getTempEmpDetails(@RequestParam(required = false) String tempId) { System.out.println("checking"); System.out.println(tempId); return dashboardApiService.getTempEmpDetails(tempId); } }