@RequestMapping("/query")
public ResBean query(@RequestBody WareBean wareBean){
String url = yylm_api_url+"/ware/query_ware";
JSONObject jsonObject = new JSONObject();
jsonObject.put("session_id",wareBean.getSession_id());
JSONObject json = getJSONObject(url,jsonObject);
return null;
}
public JSONObject getJSONObject(String url, JSONObject jsonObject){
try {
String str = jsonObject.toString();
StringEntity stringEntity = new StringEntity(str,"UTF-8");
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(stringEntity);
httpPost.setHeader("Content-type","application/json;charset=UTF-8");
CloseableHttpClient httpClient = HttpTooler.acceptsUntrustedCertsHttpClient();
CloseableHttpResponse resp = httpClient.execute(httpPost);
HttpEntity entity = resp.getEntity();
InputStream content = entity.getContent();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
int len;
while ((len = content.read()) != -1){
outputStream.write(len);
}
String result = new String(outputStream.toByteArray(),"utf-8");
JSONObject json =JSONObject.parseObject(result);
Gson gson = new Gson();
Collection<Object> coll = json.values();
for (Object obj :coll){
if (obj!=null && obj!=""){
if(obj.toString().indexOf("\\u") != -1){
gson.fromJson(json.getString(obj.toString()),String.class);
}
}
}
outputStream.flush();
outputStream.close();
return json;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}