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.

145 lines
5.5 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.ReceivedDeptProvisionalService;
  13. @RestController
  14. @RequestMapping("gcc/api/pensioner/received/provisional")
  15. public class ReceivedDeptProvisionalApiController {
  16. @Autowired
  17. private ReceivedDeptProvisionalService receivedDeptProvisionalService;
  18. @Autowired
  19. private DeptAuditService deptAuditService;
  20. @Autowired
  21. public ReceivedDeptProvisionalApiController(ReceivedDeptProvisionalService receivedDeptProvisionalService) {
  22. this.receivedDeptProvisionalService = receivedDeptProvisionalService;
  23. }
  24. //sent to completed list
  25. @PostMapping("/updateEmployeeDetailsCompleted")
  26. public ResponseEntity<String> updateEmployeeDetailsCompleted(@RequestBody Map<String, Object> requestData) {
  27. try {
  28. // Call service method to save
  29. String tempId = (String) requestData.get("tempId");
  30. String filemovedby =(String)requestData.get("filemovedby");
  31. boolean isSaved = receivedDeptProvisionalService.updateEntryDetailsCompleted(requestData);
  32. if (isSaved) {
  33. List<Map<String, Object>> emp_details=deptAuditService.fetchEmployeeById(tempId);
  34. System.out.println("emp_details:==:"+emp_details);
  35. boolean updated=receivedDeptProvisionalService.savehistory(emp_details,filemovedby);
  36. if(updated)
  37. {
  38. return ResponseEntity.ok("File Completed successfully!");
  39. }
  40. else {
  41. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details in history.");
  42. }
  43. } else {
  44. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details.");
  45. }
  46. } catch (Exception e) {
  47. e.printStackTrace();
  48. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error occurred while saving details.");
  49. }
  50. }
  51. // returned from pension to department
  52. @PostMapping("/updateEmployeeDetailsReturn")
  53. public ResponseEntity<String> updateEmployeeDetailsReturn(@RequestBody Map<String, Object> requestData) {
  54. try {
  55. // Call service method to save
  56. String tempId = (String) requestData.get("tempId");
  57. String filemovedby =(String)requestData.get("filemovedby");
  58. boolean isSaved = receivedDeptProvisionalService.updateEntryDetailsReturntoDepartment(requestData);
  59. if (isSaved) {
  60. List<Map<String, Object>> emp_details=deptAuditService.fetchEmployeeById(tempId);
  61. System.out.println("emp_details:==:"+emp_details);
  62. boolean updated=receivedDeptProvisionalService.savehistory(emp_details,filemovedby);
  63. if(updated)
  64. {
  65. return ResponseEntity.ok("File moved to Department successfully!");
  66. }
  67. else {
  68. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details in history.");
  69. }
  70. } else {
  71. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details.");
  72. }
  73. } catch (Exception e) {
  74. e.printStackTrace();
  75. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error occurred while saving details.");
  76. }
  77. }
  78. //sent again to pension from department
  79. @PostMapping("/updateEmployeeDetailsSentToPension")
  80. public ResponseEntity<String> updateEntryDetailsSenttoPension(@RequestBody Map<String, Object> requestData) {
  81. try {
  82. // Call service method to save
  83. String tempId = (String) requestData.get("tempId");
  84. String filemovedby =(String)requestData.get("filemovedby");
  85. boolean isSaved = receivedDeptProvisionalService.updateEntryDetailsSenttoPension(requestData);
  86. if (isSaved) {
  87. List<Map<String, Object>> emp_details=deptAuditService.fetchEmployeeById(tempId);
  88. System.out.println("emp_details:==:"+emp_details);
  89. boolean updated=receivedDeptProvisionalService.savehistory(emp_details,filemovedby);
  90. if(updated)
  91. {
  92. return ResponseEntity.ok("File moved to Pension successfully!");
  93. }
  94. else {
  95. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details in history.");
  96. }
  97. } else {
  98. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details.");
  99. }
  100. } catch (Exception e) {
  101. e.printStackTrace();
  102. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error occurred while saving details.");
  103. }
  104. }
  105. }