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.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import in.gov.chennaicorporation.gccoffice.pensioner.service.DeptAuditService; @RequestMapping("gcc/api/department/audit") @RestController public class DeptAuditApiController { @Autowired private DeptAuditService deptAuditService; @GetMapping("/getemployeedetails") public List> getEmployeedetailsbyCode( @RequestParam String tempId) { List> employeeDetails = deptAuditService.fetchEmployeeById(tempId); System.out.println("employeeDetails==="+employeeDetails); return employeeDetails; } @GetMapping("/getemployeedetailscps") public List> getEmployeedetailsbyCodeCps( @RequestParam String tempId) { List> employeeDetails = deptAuditService.fetchEmployeeByIdCps(tempId); System.out.println("employeeDetails==="+employeeDetails); return employeeDetails; } @GetMapping("/getzonebenefitsdetails") public List> getdetailsWithZonebenefits( @RequestParam String tempId) { List> zoneBenefitDetails = deptAuditService.fetchDetailsWithZoneBenefitsById(tempId); System.out.println("zoneBenefitDetails==="+zoneBenefitDetails); return zoneBenefitDetails; } @GetMapping("/getfilependingbenefits") public List> getAllBenefitsDetails( @RequestParam String tempId) { List> allBenefitDetails = deptAuditService.fetchFilePendingBenefits(tempId); System.out.println("allBenefitDetails==="+allBenefitDetails); return allBenefitDetails; } @GetMapping("/getpartialdetails") public List> getAllPartialDetails( @RequestParam String tempId) { List> partialDetails = deptAuditService.fetchPartialCompleted(tempId); System.out.println("partialDetails==="+partialDetails); return partialDetails; } @GetMapping("/fileMovementhistory") public List> getFileMovementHistory(@RequestParam String tempId) { List> fileHistory = deptAuditService.fetchFileMovementHistory(tempId); return fileHistory; } @PostMapping("/updateEmployeeDetails") public ResponseEntity updateEmployeeDetails(@RequestBody Map requestData) { try { // Call service method to save String tempId = (String) requestData.get("tempId"); String filemovedby =(String)requestData.get("filemovedby"); boolean isSaved = deptAuditService.updateEntryDetails(requestData); if (isSaved) { List> emp_details=deptAuditService.fetchEmployeeById(tempId); System.out.println("emp_details:==:"+emp_details); boolean updated=deptAuditService.savehistory(emp_details,filemovedby); if(updated) { return ResponseEntity.ok("File moved to Return from Audit successfully!"); } else { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details in history."); } } else { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details."); } } catch (Exception e) { e.printStackTrace(); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error occurred while saving details."); } } //update the family pension details @PostMapping("/updateFamilyPensionDetails") public ResponseEntity updateFamilyPensionDetails(@RequestBody Map requestData) { try { // Call service method to save String tempId = (String) requestData.get("tempId"); String filemovedby =(String)requestData.get("filemovedby"); boolean isSaved = deptAuditService.updateEntryDetails(requestData); if (isSaved) { List> emp_details=deptAuditService.fetchEmployeeById(tempId); System.out.println("emp_details:==:"+emp_details); boolean updated=deptAuditService.saveFamilyPensionHistory(emp_details,filemovedby); if(updated) { return ResponseEntity.ok("File moved to Return from Audit successfully!"); } else { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details in history."); } } else { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details."); } } catch (Exception e) { e.printStackTrace(); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error occurred while saving details."); } } //pendency @PostMapping("/updatePendencyDetails") public ResponseEntity updatePendencyDetails(@RequestBody Map requestData) { try { // Call service method to save String tempId = (String) requestData.get("tempId"); String filemovedby =(String)requestData.get("filemovedby"); boolean isSaved = deptAuditService.updateEntryDetails(requestData); if (isSaved) { List> emp_details=deptAuditService.fetchEmployeeById(tempId); System.out.println("emp_details:==:"+emp_details); boolean updated=deptAuditService.savePendencyHistory(emp_details,filemovedby); if(updated) { return ResponseEntity.ok("File moved to Return from Audit successfully!"); } else { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details in history."); } } else { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details."); } } catch (Exception e) { e.printStackTrace(); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error occurred while saving details."); } } }