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.

129 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.DepartmentForwardService;
  12. import in.gov.chennaicorporation.gccoffice.pensioner.service.DeptAuditService;
  13. @RequestMapping("gcc/api/pension/forward")
  14. @RestController
  15. public class DepartmentForwardApiController {
  16. @Autowired
  17. private DeptAuditService deptAuditService;
  18. @Autowired
  19. private DepartmentForwardService departmentForwardService;
  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 = departmentForwardService.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=departmentForwardService.savehistory(emp_details,filemovedby);
  31. if(updated)
  32. {
  33. return ResponseEntity.ok("File Forward to Department 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. //family pension
  47. @PostMapping("/updateForwardFamilyPension")
  48. public ResponseEntity<String> updateForwardFamilyPension(@RequestBody Map<String, Object> requestData) {
  49. try {
  50. // Call service method to save
  51. String tempId = (String) requestData.get("tempId");
  52. String filemovedby =(String)requestData.get("filemovedby");
  53. boolean isSaved = departmentForwardService.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=departmentForwardService.saveFamilyPensionForwardHistory(emp_details,filemovedby);
  58. if(updated)
  59. {
  60. return ResponseEntity.ok("File Forward to Department 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. @PostMapping("/updateForwardPendency")
  74. public ResponseEntity<String> updateForwardPendency(@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 = departmentForwardService.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=departmentForwardService.savePendencyForwardHistory(emp_details,filemovedby);
  84. if(updated)
  85. {
  86. return ResponseEntity.ok("File Forward to Department 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. }