package in.gov.chennaicorporation.gccoffice.cmdashboard.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.cmdashboard.service.CmDashboardService; import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; @RequestMapping("/gcc/api/cmdashboard") @RestController("cmdashboard") public class APIController { private CmDashboardService cmdashboards; @Autowired private AppConfig appConfig; @Autowired public APIController(CmDashboardService cmdashboards) { this.cmdashboards = cmdashboards; } @GetMapping(value = "/getCmDashboardReports") public List getCombinedCmDashboardReports(@RequestParam("zonename") String zonename) { return cmdashboards.getCombinedCmDashboardReports(zonename); } @GetMapping(value = "/getCmDashboardAllReports") public List getCmDashboardAllReports() { return cmdashboards.getCmDashboardAllReports(); } @GetMapping(value = "/getRegionCounts") public List> getRegionCounts() { return cmdashboards.getRegionCounts(); } @GetMapping(value = "/getZoneCounts") public List> getZoneCounts() { return cmdashboards.getZoneCounts(); } @GetMapping(value = "/getSchemeDetails") public Map getSchemeDetails(@RequestParam("schemename") String schemename, @RequestParam("zonename") String zonename) { return cmdashboards.getSchemeDetails(schemename, zonename); } @GetMapping(value="/getTypeOfWorkDetails") public Map getTypeOfWorkDetails(@RequestParam("typeofwork") String typeofwork, @RequestParam("zonename") String zonename){ return cmdashboards.getTypeOfWorkDetails(typeofwork, zonename); } @GetMapping(value="/getRegionzones") public Map getRegionsZonesDetails(@RequestParam("regionname") String regionname){ return cmdashboards.getRegionDetails(regionname); } @GetMapping("/all-list/{id}") public Map getCMDetails(@PathVariable int id) { return cmdashboards.getCMDetails(id); } // 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; // } }