You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
4.2 KiB

2 years ago
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. package in.gov.chennaicorporation.gccoffice.pensioner.controller;
  2. import java.util.List;
  3. import java.util.Map;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.http.HttpStatus;
  6. import org.springframework.http.ResponseEntity;
  7. import org.springframework.web.bind.annotation.GetMapping;
  8. import org.springframework.web.bind.annotation.PostMapping;
  9. import org.springframework.web.bind.annotation.RequestBody;
  10. import org.springframework.web.bind.annotation.RequestMapping;
  11. import org.springframework.web.bind.annotation.RequestParam;
  12. import org.springframework.web.bind.annotation.RestController;
  13. import in.gov.chennaicorporation.gccoffice.pensioner.service.DeptAuditService;
  14. import in.gov.chennaicorporation.gccoffice.pensioner.service.FileClosingService;
  15. import in.gov.chennaicorporation.gccoffice.pensioner.service.NewEntryService;
  16. @RequestMapping("gcc/api/fileclosing")
  17. @RestController
  18. public class FileClosingApiController {
  19. @Autowired
  20. private FileClosingService fileClosingService;
  21. @Autowired
  22. private NewEntryService newEntryService;
  23. @Autowired
  24. private DeptAuditService deptAuditService;
  25. @GetMapping("/getdetails")
  26. public List<Map<String, Object>> getEmployeedetailsbyCode( @RequestParam String empCode, @RequestParam String deptId){
  27. int dept_id=Integer.parseInt(deptId);
  28. int file_cat= newEntryService.getRetirementFileCategoryId();
  29. System.out.println("file_cat>>>>>>"+file_cat);
  30. String tempId=fileClosingService.getTempId(empCode,dept_id,file_cat);
  31. System.out.println("empCode>>>>>"+empCode);
  32. System.out.println("deptId>>>>>>"+dept_id);
  33. System.out.println("tempId>>>>>>"+tempId);
  34. List<Map<String, Object>> employeeDetails = fileClosingService.fetchEmployeeByTempId(tempId);
  35. System.out.println("employeeDetails==="+employeeDetails);
  36. return employeeDetails;
  37. }
  38. @GetMapping("/getemployeedetails")
  39. public List<Map<String, Object>> getEmployeedetailsbyCode(
  40. @RequestParam String tempId) {
  41. System.out.println("temporary==="+tempId);
  42. List<Map<String, Object>> employeeDetails = fileClosingService.fetchEmployeeById(tempId);
  43. System.out.println("employeeDetails==="+employeeDetails);
  44. return employeeDetails;
  45. }
  46. @PostMapping("/updateDetails")
  47. public ResponseEntity<String> updateDetails(@RequestBody Map<String, Object> requestData) {
  48. try {
  49. // Call service method to save
  50. String tempId = (String) requestData.get("tempId");
  51. String filemovedby =(String)requestData.get("filemovedby");
  52. System.out.println("data"+requestData);
  53. boolean isSaved = fileClosingService.updateEntryDetails(requestData);
  54. if (isSaved) {
  55. List<Map<String, Object>> emp_details=deptAuditService.fetchEmployeeById(tempId);
  56. System.out.println("emp_details:==:"+emp_details);
  57. boolean updated=fileClosingService.saveclosinghistory(emp_details,filemovedby);
  58. if(updated)
  59. {
  60. return ResponseEntity.ok("File Closed successfully!");
  61. }
  62. else {
  63. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details in history.");
  64. }
  65. } else {
  66. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details.");
  67. }
  68. } catch (Exception e) {
  69. e.printStackTrace();
  70. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error occurred while saving details.");
  71. }
  72. }
  73. //closed list api
  74. @GetMapping("/getcloseddetails")
  75. public List<Map<String, Object>> getClosedEmployeedetails(){
  76. List<Map<String, Object>> employeeDetails = fileClosingService.fetchClosingEmployee();
  77. System.out.println("employeeDetails==="+employeeDetails);
  78. return employeeDetails;
  79. }
  80. }