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.

189 lines
7.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.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. @RequestMapping("gcc/api/department/audit")
  15. @RestController
  16. public class DeptAuditApiController {
  17. @Autowired
  18. private DeptAuditService deptAuditService;
  19. @GetMapping("/getemployeedetails")
  20. public List<Map<String, Object>> getEmployeedetailsbyCode(
  21. @RequestParam String tempId) {
  22. List<Map<String, Object>> employeeDetails = deptAuditService.fetchEmployeeById(tempId);
  23. System.out.println("employeeDetails==="+employeeDetails);
  24. return employeeDetails;
  25. }
  26. @GetMapping("/getemployeedetailscps")
  27. public List<Map<String, Object>> getEmployeedetailsbyCodeCps(
  28. @RequestParam String tempId) {
  29. List<Map<String, Object>> employeeDetails = deptAuditService.fetchEmployeeByIdCps(tempId);
  30. System.out.println("employeeDetails==="+employeeDetails);
  31. return employeeDetails;
  32. }
  33. @GetMapping("/getzonebenefitsdetails")
  34. public List<Map<String, Object>> getdetailsWithZonebenefits(
  35. @RequestParam String tempId) {
  36. List<Map<String, Object>> zoneBenefitDetails = deptAuditService.fetchDetailsWithZoneBenefitsById(tempId);
  37. System.out.println("zoneBenefitDetails==="+zoneBenefitDetails);
  38. return zoneBenefitDetails;
  39. }
  40. @GetMapping("/getfilependingbenefits")
  41. public List<Map<String, Object>> getAllBenefitsDetails(
  42. @RequestParam String tempId) {
  43. List<Map<String, Object>> allBenefitDetails = deptAuditService.fetchFilePendingBenefits(tempId);
  44. System.out.println("allBenefitDetails==="+allBenefitDetails);
  45. return allBenefitDetails;
  46. }
  47. @GetMapping("/getpartialdetails")
  48. public List<Map<String, Object>> getAllPartialDetails(
  49. @RequestParam String tempId) {
  50. List<Map<String, Object>> partialDetails = deptAuditService.fetchPartialCompleted(tempId);
  51. System.out.println("partialDetails==="+partialDetails);
  52. return partialDetails;
  53. }
  54. @GetMapping("/fileMovementhistory")
  55. public List<Map<String, Object>> getFileMovementHistory(@RequestParam String tempId) {
  56. List<Map<String, Object>> fileHistory = deptAuditService.fetchFileMovementHistory(tempId);
  57. return fileHistory;
  58. }
  59. @PostMapping("/updateEmployeeDetails")
  60. public ResponseEntity<String> updateEmployeeDetails(@RequestBody Map<String, Object> requestData) {
  61. try {
  62. // Call service method to save
  63. String tempId = (String) requestData.get("tempId");
  64. String filemovedby =(String)requestData.get("filemovedby");
  65. boolean isSaved = deptAuditService.updateEntryDetails(requestData);
  66. if (isSaved) {
  67. List<Map<String, Object>> emp_details=deptAuditService.fetchEmployeeById(tempId);
  68. System.out.println("emp_details:==:"+emp_details);
  69. boolean updated=deptAuditService.savehistory(emp_details,filemovedby);
  70. if(updated)
  71. {
  72. return ResponseEntity.ok("File moved to Return from Audit successfully!");
  73. }
  74. else {
  75. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details in history.");
  76. }
  77. } else {
  78. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details.");
  79. }
  80. } catch (Exception e) {
  81. e.printStackTrace();
  82. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error occurred while saving details.");
  83. }
  84. }
  85. //update the family pension details
  86. @PostMapping("/updateFamilyPensionDetails")
  87. public ResponseEntity<String> updateFamilyPensionDetails(@RequestBody Map<String, Object> requestData) {
  88. try {
  89. // Call service method to save
  90. String tempId = (String) requestData.get("tempId");
  91. String filemovedby =(String)requestData.get("filemovedby");
  92. boolean isSaved = deptAuditService.updateEntryDetails(requestData);
  93. if (isSaved) {
  94. List<Map<String, Object>> emp_details=deptAuditService.fetchEmployeeById(tempId);
  95. System.out.println("emp_details:==:"+emp_details);
  96. boolean updated=deptAuditService.saveFamilyPensionHistory(emp_details,filemovedby);
  97. if(updated)
  98. {
  99. return ResponseEntity.ok("File moved to Return from Audit successfully!");
  100. }
  101. else {
  102. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details in history.");
  103. }
  104. } else {
  105. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details.");
  106. }
  107. } catch (Exception e) {
  108. e.printStackTrace();
  109. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error occurred while saving details.");
  110. }
  111. }
  112. //pendency
  113. @PostMapping("/updatePendencyDetails")
  114. public ResponseEntity<String> updatePendencyDetails(@RequestBody Map<String, Object> requestData) {
  115. try {
  116. // Call service method to save
  117. String tempId = (String) requestData.get("tempId");
  118. String filemovedby =(String)requestData.get("filemovedby");
  119. boolean isSaved = deptAuditService.updateEntryDetails(requestData);
  120. if (isSaved) {
  121. List<Map<String, Object>> emp_details=deptAuditService.fetchEmployeeById(tempId);
  122. System.out.println("emp_details:==:"+emp_details);
  123. boolean updated=deptAuditService.savePendencyHistory(emp_details,filemovedby);
  124. if(updated)
  125. {
  126. return ResponseEntity.ok("File moved to Return from Audit successfully!");
  127. }
  128. else {
  129. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details in history.");
  130. }
  131. } else {
  132. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details.");
  133. }
  134. } catch (Exception e) {
  135. e.printStackTrace();
  136. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error occurred while saving details.");
  137. }
  138. }
  139. }