Rev 23653 | Rev 23945 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.common.services;import java.util.Collections;import java.util.HashMap;import java.util.Map;import org.apache.http.HttpResponse;import org.apache.http.conn.HttpHostConnectException;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Component;import com.spice.profitmandi.common.enumuration.ReporticoProject;import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;import com.spice.profitmandi.common.web.client.RestClient;@Componentpublic class ReporticoService {//private String reporticoUrl="http://192.168.134.118/reports/run.php";private String reporticoUrl="http://50.116.10.120/reports/run.php";@AutowiredRestClient restClient;public static final Map<ReporticoProject, Map<String, String>> projectAuthMap = Collections.unmodifiableMap(new HashMap<ReporticoProject, Map<String, String>>() {{put(ReporticoProject.FOCO, new HashMap<String, String>() {{put("project", ReporticoProject.FOCO.getValue());put("project_password", "foco");}});put(ReporticoProject.FOCOR, new HashMap<String, String>() {{put("project", ReporticoProject.FOCOR.getValue());put("project_password", "focor");}});}});public HttpResponse getReportFile(ReporticoProject projectName, String reportName) throws HttpHostConnectException, ProfitMandiBusinessException {Map<String, String> authMap = projectAuthMap.get(projectName);Map<String, String> params = new HashMap<>(authMap);params.put("xmlin", reportName);params.put("target_format", "CSV");params.put("execute_mode", "EXECUTE");return restClient.getResponse(reporticoUrl, params, new HashMap<>());}public HttpResponse getReportFile(int fofoId, ReporticoProject projectName, String reportName) throws HttpHostConnectException, ProfitMandiBusinessException {Map<String, String> authMap = projectAuthMap.get(projectName);Map<String, String> params = new HashMap<>(authMap);params.put("xmlin", reportName);params.put("target_format", "CSV");params.put("execute_mode", "EXECUTE");params.put("MANUAL_fofoId", String.valueOf(fofoId));return restClient.getResponse(reporticoUrl, params, new HashMap<>());}}