|
@ -10,12 +10,15 @@ import io.swagger.annotations.ApiParam;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.net.URLDecoder;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
@ -30,6 +33,28 @@ public class TransforController {
|
|
|
private static Logger logger = LoggerFactory.getLogger(TransforController.class);
|
|
|
@Autowired
|
|
|
private AqgService aqgService;
|
|
|
private static final RestTemplate restTemplate = new RestTemplate();
|
|
|
|
|
|
@ApiOperation("请求转发")
|
|
|
@RequestMapping(value = "transfor", method = {RequestMethod.POST,RequestMethod.GET})
|
|
|
public String transfor(HttpServletRequest request,String baseUrl) {
|
|
|
try {
|
|
|
long startTime=System.currentTimeMillis();
|
|
|
String paraString = JSON.toJSONString(request.getParameterMap());
|
|
|
String url = RequestParamUtil.getParam(request);
|
|
|
url = url.replace("baseUrl="+baseUrl+"&","");
|
|
|
url = URLDecoder.decode(url,"UTF-8");
|
|
|
logger.info("请求转发url="+ baseUrl+url);
|
|
|
ResponseEntity<String> responseEntity = restTemplate.getForEntity(baseUrl+url, String.class);
|
|
|
String res = responseEntity.getBody();
|
|
|
long endTime=System.currentTimeMillis();
|
|
|
logger.info("请求转发,请求参数:"+paraString+" "+(endTime-startTime)+"ms; 响应:"+res);
|
|
|
return res;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return "error";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@ApiOperation("爱牵挂设备sos数据接收")
|
|
|
@RequestMapping(value = "aqgsos", method = {RequestMethod.POST,RequestMethod.GET})
|