Authored by 鲁尚清

Merge branch 'master' of http://192.168.1.136:82/monitor_v3/anji-plus-report int…

…o master-ajreport-lushangqing
@@ -296,14 +296,19 @@ public class DataSourceServiceImpl implements DataSourceService { @@ -296,14 +296,19 @@ public class DataSourceServiceImpl implements DataSourceService {
296 */ 296 */
297 public List<JSONObject> executeHttp(DataSourceDto dto) { 297 public List<JSONObject> executeHttp(DataSourceDto dto) {
298 analysisHttpConfig(dto); 298 analysisHttpConfig(dto);
  299 + String apiUrl = dto.getApiUrl();
299 HttpMethod httpMethod = HttpMethod.valueOf(dto.getMethod()); 300 HttpMethod httpMethod = HttpMethod.valueOf(dto.getMethod());
300 if(Objects.equals(HttpMethod.GET, httpMethod)){ 301 if(Objects.equals(HttpMethod.GET, httpMethod)){
301 Map<String, Object> contextData = dto.getContextData(); 302 Map<String, Object> contextData = dto.getContextData();
302 -  
303 - if(!contextData.isEmpty()){  
304 - JSONObject o = (JSONObject)JSONObject.toJSON(contextData);  
305 - dto.setDynSentence(o.toJSONString()); 303 + List<String> params = new ArrayList<>();
  304 + contextData.forEach((k,v)->{
  305 + params.add(String.format("%s=%s",k,String.valueOf(v)));
  306 + });
  307 + String element = "&";
  308 + if(apiUrl.indexOf('?') == -1){
  309 + element = "?";
306 } 310 }
  311 + apiUrl += element + String.join("&",params);
307 } 312 }
308 HttpHeaders headers = new HttpHeaders(); 313 HttpHeaders headers = new HttpHeaders();
309 headers.setAll(JSONObject.parseObject(dto.getHeader(), Map.class)); 314 headers.setAll(JSONObject.parseObject(dto.getHeader(), Map.class));
@@ -311,7 +316,7 @@ public class DataSourceServiceImpl implements DataSourceService { @@ -311,7 +316,7 @@ public class DataSourceServiceImpl implements DataSourceService {
311 ResponseEntity<Object> exchange; 316 ResponseEntity<Object> exchange;
312 List<JSONObject> result = new ArrayList<>(); 317 List<JSONObject> result = new ArrayList<>();
313 try { 318 try {
314 - exchange = restTemplate.exchange(dto.getApiUrl(),httpMethod , entity, Object.class); 319 + exchange = restTemplate.exchange(apiUrl,httpMethod , entity, Object.class);
315 } catch (HttpClientErrorException error){ 320 } catch (HttpClientErrorException error){
316 int rawStatusCode = error.getRawStatusCode(); 321 int rawStatusCode = error.getRawStatusCode();
317 // 401 接口请求无权限 322 // 401 接口请求无权限