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.

134 lines
5.2 KiB

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.PostMapping;
  8. import org.springframework.web.bind.annotation.RequestBody;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.RestController;
  11. import in.gov.chennaicorporation.gccoffice.pensioner.service.DeptAuditService;
  12. import in.gov.chennaicorporation.gccoffice.pensioner.service.PensionAuditService;
  13. @RequestMapping("gcc/api/pensioner/audit")
  14. @RestController
  15. public class PensionAuditApiController {
  16. @Autowired
  17. private DeptAuditService deptAuditService;
  18. @Autowired
  19. private PensionAuditService pensionAuditService;
  20. @PostMapping("/updateEmployeeDetails")
  21. public ResponseEntity<String> updateEmployeeDetails(@RequestBody Map<String, Object> requestData) {
  22. try {
  23. // Call service method to save
  24. String tempId = (String) requestData.get("tempId");
  25. String filemovedby =(String)requestData.get("filemovedby");
  26. boolean isSaved = pensionAuditService.updateEntryDetails(requestData);
  27. if (isSaved) {
  28. List<Map<String, Object>> emp_details=deptAuditService.fetchEmployeeById(tempId);
  29. System.out.println("emp_details:==:"+emp_details);
  30. boolean updated=pensionAuditService.savehistory(emp_details,filemovedby);
  31. if(updated)
  32. {
  33. return ResponseEntity.ok("Audit Certificate Received successfully!");
  34. }
  35. else {
  36. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details in history.");
  37. }
  38. } else {
  39. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details.");
  40. }
  41. } catch (Exception e) {
  42. e.printStackTrace();
  43. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error occurred while saving details.");
  44. }
  45. }
  46. @PostMapping("/updateFamilyPensionDetails")
  47. public ResponseEntity<String> updateFamilyPensionDetails(@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. boolean isSaved = pensionAuditService.updateEntryDetails(requestData);
  53. if (isSaved) {
  54. List<Map<String, Object>> emp_details=deptAuditService.fetchEmployeeById(tempId);
  55. System.out.println("emp_details:==:"+emp_details);
  56. boolean updated=pensionAuditService.saveFamilyPensionHistory(emp_details,filemovedby);
  57. if(updated)
  58. {
  59. return ResponseEntity.ok("Audit Certificate Received successfully!");
  60. }
  61. else {
  62. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details in history.");
  63. }
  64. } else {
  65. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details.");
  66. }
  67. } catch (Exception e) {
  68. e.printStackTrace();
  69. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error occurred while saving details.");
  70. }
  71. }
  72. //pendency
  73. @PostMapping("/updatePendencyDetails")
  74. public ResponseEntity<String> updatePendencyDetails(@RequestBody Map<String, Object> requestData) {
  75. try {
  76. // Call service method to save
  77. String tempId = (String) requestData.get("tempId");
  78. String filemovedby =(String)requestData.get("filemovedby");
  79. boolean isSaved = pensionAuditService.updateEntryDetails(requestData);
  80. if (isSaved) {
  81. List<Map<String, Object>> emp_details=deptAuditService.fetchEmployeeById(tempId);
  82. System.out.println("emp_details:==:"+emp_details);
  83. boolean updated=pensionAuditService.savePendencyHistory(emp_details,filemovedby);
  84. if(updated)
  85. {
  86. return ResponseEntity.ok("Audit Certificate Received successfully!");
  87. }
  88. else {
  89. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details in history.");
  90. }
  91. } else {
  92. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details.");
  93. }
  94. } catch (Exception e) {
  95. e.printStackTrace();
  96. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error occurred while saving details.");
  97. }
  98. }
  99. }