CM works overall dashboard integrate with gcc_office_portal
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.

132 lines
4.3 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. package in.gov.chennaicorporation.gccoffice.cmworks.controller;
  2. import java.util.List;
  3. import java.util.Map;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.http.HttpEntity;
  6. import org.springframework.http.HttpHeaders;
  7. import org.springframework.http.HttpMethod;
  8. import org.springframework.http.ResponseEntity;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.PathVariable;
  11. import org.springframework.web.bind.annotation.RequestMapping;
  12. import org.springframework.web.bind.annotation.RequestParam;
  13. import org.springframework.web.bind.annotation.ResponseBody;
  14. import org.springframework.web.bind.annotation.RestController;
  15. import org.springframework.web.client.RestTemplate;
  16. import in.gov.chennaicorporation.gccoffice.cmworks.service.WorksService;
  17. import in.gov.chennaicorporation.gccoffice.configuration.AppConfig;
  18. @RequestMapping("/gcc/api/works")
  19. @RestController("worksRest")
  20. public class APIController {
  21. private WorksService worksservice;
  22. @Autowired
  23. private AppConfig appConfig;
  24. @Autowired
  25. public APIController(WorksService worksservice) {
  26. this.worksservice=worksservice;
  27. }
  28. @GetMapping(value="/getCmDashboardReports")
  29. public List getCombinedCmDashboardReports(@RequestParam ("zonename") String zonename) {
  30. return worksservice.getCombinedCmDashboardReports(zonename);
  31. }
  32. @GetMapping(value="/getCmDashboardAllReports")
  33. public List getCmDashboardAllReports() {
  34. return worksservice.getCmDashboardAllReports();
  35. }
  36. @GetMapping(value="/getRegionCounts")
  37. public List<Map<String, Object>> getRegionCounts() {
  38. return worksservice.getRegionCounts();
  39. }
  40. @GetMapping(value="/getZoneCounts")
  41. public List<Map<String, Object>> getZoneCounts() {
  42. return worksservice.getZoneCounts();
  43. }
  44. @GetMapping(value="/getImageUrl")
  45. public List<Map<String, Object>> getImageUrl() {
  46. return worksservice.getImageUrl();
  47. }
  48. @GetMapping("/all-list/{id}")
  49. public Map<String, Object> getCMDetails(@PathVariable int id) {
  50. return worksservice.getCMDetails(id);
  51. }
  52. @GetMapping(value="/getTradelicenseReports")
  53. public List getTradelicenseReports(@RequestParam("divisionName")String divisionName) {
  54. System.out.println("selected region:"+ divisionName);
  55. return worksservice.getTradelicenseReports(divisionName);
  56. }
  57. @GetMapping(value="/getTradelicenseReportsAll")
  58. public List getTradelicenseReportsAll() {
  59. return worksservice.getTradelicenseReportsAll();
  60. }
  61. // Rest Api From ERP
  62. @GetMapping(value = "/getZoneNo")
  63. public String getZoneNo() {
  64. String urlString = appConfig.getErpUrl()+"serviceId=getZones";
  65. ResponseEntity<String> response = null;
  66. RestTemplate restTemplate = new RestTemplate();
  67. String bodyMessage = "";
  68. HttpHeaders headers = new HttpHeaders();
  69. try {
  70. HttpEntity<String> postData = new HttpEntity<String>(headers);
  71. response = restTemplate.exchange(urlString, HttpMethod.POST, postData, String.class);
  72. bodyMessage = response.getBody();
  73. //System.out.println("BodyMessage" + bodyMessage);
  74. } catch (Exception e) {
  75. e.printStackTrace();
  76. //System.out.print("\n ERROR---: " + e);
  77. bodyMessage = "Error";
  78. }
  79. return bodyMessage;
  80. }
  81. @GetMapping(value = "/getDiv")
  82. public String getDiv(@RequestParam String zoneId) {
  83. String urlString = appConfig.getErpUrl()+"serviceId=getWards&Zoneid="+zoneId+"";
  84. ResponseEntity<String> response = null;
  85. RestTemplate restTemplate = new RestTemplate();
  86. String bodyMessage = "";
  87. HttpHeaders headers = new HttpHeaders();
  88. try {
  89. HttpEntity<String> postData = new HttpEntity<String>(headers);
  90. response = restTemplate.exchange(urlString, HttpMethod.POST, postData, String.class);
  91. bodyMessage = response.getBody();
  92. //System.out.println("bodyMessage" + bodyMessage);
  93. } catch (Exception e) {
  94. e.printStackTrace();
  95. //System.out.print("\n ERROR---: " + e);
  96. bodyMessage = "Error";
  97. }
  98. return bodyMessage;
  99. }
  100. }