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.

110 lines
4.5 KiB

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.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.DeptPartiallyCompService;
  13. import in.gov.chennaicorporation.gccoffice.pensioner.service.PensionReceivedService;
  14. @RequestMapping("gcc/api/department/partial")
  15. @RestController
  16. public class DeptPartiallyCompApiController {
  17. @Autowired
  18. public DeptPartiallyCompService deptPartiallyCompleteService;
  19. @Autowired
  20. public DeptAuditService deptAuditService;
  21. @Autowired
  22. public PensionReceivedService pensionReceivedService;
  23. @PostMapping("/updateEmployeeDetails")
  24. public ResponseEntity<String> updateEmployeeDetails(@RequestBody Map<String, Object> requestData) {
  25. try {
  26. // Call service method to save
  27. String tempId = (String) requestData.get("tempId");
  28. String filemovedby =(String)requestData.get("filemovedby");
  29. int fs1=0;
  30. boolean isSaved = deptPartiallyCompleteService.updateEntryCompletedDetails(requestData);
  31. if (isSaved) {
  32. List<Map<String, Object>> emp_details=deptAuditService.fetchPartialCompleted(tempId);
  33. System.out.println("emp_details:==:"+emp_details);
  34. List<Map<String, Object>> zone_benefits=pensionReceivedService.fetchZonebenefitsById(tempId);
  35. System.out.println("zone_benefits:==:"+zone_benefits);
  36. List<Map<String, Object>> pension_benefits=pensionReceivedService.fetchPensionbenefitsById(tempId);
  37. System.out.println("pension_benefits:==:"+pension_benefits);
  38. boolean updated=deptPartiallyCompleteService.saveHistory(emp_details,zone_benefits,pension_benefits,filemovedby);
  39. if (!emp_details.isEmpty()) { // Ensure list is not empty
  40. Map<String, Object> empDetailMap = emp_details.get(0); // Get first map from the list
  41. // Ensure the key exists in the map
  42. if (empDetailMap.containsKey("file_status")) {
  43. Object fileStatusObj = empDetailMap.get("file_status");
  44. if (fileStatusObj != null) {
  45. String fs = fileStatusObj.toString(); // Convert to String safely
  46. fs1 = Integer.parseInt(fs); // Convert to integer if needed
  47. System.out.println("file_status: " + fs1);
  48. } else {
  49. System.out.println("file_status is null");
  50. }
  51. } else {
  52. System.out.println("Key 'file_status' not found in emp_details");
  53. }
  54. } else {
  55. System.out.println("emp_details list is empty");
  56. }
  57. if(updated)
  58. {
  59. if(fs1==11 && fs1!=0)
  60. {
  61. return ResponseEntity.ok("File Completed successfully!");
  62. }
  63. else if(fs1==9 && fs1!=0) {
  64. return ResponseEntity.ok("File Partially Completed!");
  65. }
  66. else if(fs1==10 && fs1!=0){
  67. return ResponseEntity.ok("File Moved to Pension Partially Completed!");
  68. }
  69. else {
  70. return ResponseEntity.ok("File Status is 0!");
  71. }
  72. }
  73. else {
  74. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details in history.");
  75. }
  76. } else {
  77. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to save details.");
  78. }
  79. } catch (Exception e) {
  80. e.printStackTrace();
  81. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error occurred while saving details.");
  82. }
  83. }
  84. }