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

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<Map<String, Object>> getRegionCounts() {
return worksservice.getRegionCounts();
}
@GetMapping(value="/getZoneCounts")
public List<Map<String, Object>> getZoneCounts() {
return worksservice.getZoneCounts();
}
@GetMapping(value="/getImageUrl")
public List<Map<String, Object>> getImageUrl() {
return worksservice.getImageUrl();
}
@GetMapping("/all-list/{id}")
public Map<String, Object> 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<String> response = null;
RestTemplate restTemplate = new RestTemplate();
String bodyMessage = "";
HttpHeaders headers = new HttpHeaders();
try {
HttpEntity<String> postData = new HttpEntity<String>(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<String> response = null;
RestTemplate restTemplate = new RestTemplate();
String bodyMessage = "";
HttpHeaders headers = new HttpHeaders();
try {
HttpEntity<String> postData = new HttpEntity<String>(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;
}
}