package in.gov.chennaicorporation.gccoffice.cmworks.controller; import java.util.List; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; import in.gov.chennaicorporation.gccoffice.cmworks.service.WorksService; import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; @RequestMapping("/gcc/api/works") @RestController("worksRest") public class APIController { private WorksService worksservice; @Autowired private AppConfig appConfig; @Autowired public APIController(WorksService worksservice) { this.worksservice=worksservice; } @GetMapping(value="/getCmDashboardReports") public List getCombinedCmDashboardReports(@RequestParam ("zonename") String zonename) { return worksservice.getCombinedCmDashboardReports(zonename); } @GetMapping(value="/getCmDashboardAllReports") public List getCmDashboardAllReports() { return worksservice.getCmDashboardAllReports(); } @GetMapping(value="/getRegionCounts") public List> getRegionCounts() { return worksservice.getRegionCounts(); } @GetMapping(value="/getZoneCounts") public List> getZoneCounts() { return worksservice.getZoneCounts(); } @GetMapping(value="/getImageUrl") public List> getImageUrl() { return worksservice.getImageUrl(); } @GetMapping("/all-list/{id}") public Map getCMDetails(@PathVariable int id) { return worksservice.getCMDetails(id); } @GetMapping(value="/getTradelicenseReports") public List getTradelicenseReports(@RequestParam("divisionName")String divisionName) { System.out.println("selected region:"+ divisionName); return worksservice.getTradelicenseReports(divisionName); } @GetMapping(value="/getTradelicenseReportsAll") public List getTradelicenseReportsAll() { return worksservice.getTradelicenseReportsAll(); } // Rest Api From ERP @GetMapping(value = "/getZoneNo") public String getZoneNo() { String urlString = appConfig.getErpUrl()+"serviceId=getZones"; ResponseEntity response = null; RestTemplate restTemplate = new RestTemplate(); String bodyMessage = ""; HttpHeaders headers = new HttpHeaders(); try { HttpEntity postData = new HttpEntity(headers); response = restTemplate.exchange(urlString, HttpMethod.POST, postData, String.class); bodyMessage = response.getBody(); //System.out.println("BodyMessage" + bodyMessage); } catch (Exception e) { e.printStackTrace(); //System.out.print("\n ERROR---: " + e); bodyMessage = "Error"; } return bodyMessage; } @GetMapping(value = "/getDiv") public String getDiv(@RequestParam String zoneId) { String urlString = appConfig.getErpUrl()+"serviceId=getWards&Zoneid="+zoneId+""; ResponseEntity response = null; RestTemplate restTemplate = new RestTemplate(); String bodyMessage = ""; HttpHeaders headers = new HttpHeaders(); try { HttpEntity postData = new HttpEntity(headers); response = restTemplate.exchange(urlString, HttpMethod.POST, postData, String.class); bodyMessage = response.getBody(); //System.out.println("bodyMessage" + bodyMessage); } catch (Exception e) { e.printStackTrace(); //System.out.print("\n ERROR---: " + e); bodyMessage = "Error"; } return bodyMessage; } }