|
|
|
@ -2,6 +2,10 @@ package com.example.PersonalCenter;
|
|
|
|
|
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
|
|
|
|
|
import net.sf.json.JSONObject;
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
@ -10,8 +14,14 @@ import java.net.HttpURLConnection;
|
|
|
|
|
import java.net.MalformedURLException;
|
|
|
|
|
import java.net.ProtocolException;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
public class SearchServiceGet {
|
|
|
|
|
|
|
|
|
|
public static ArrayList<String> label;//存储标签内容
|
|
|
|
|
public static ArrayList<String> content;//存储数据内容
|
|
|
|
|
|
|
|
|
|
public static String executeSearchGet(String name){
|
|
|
|
|
HttpURLConnection connection = null;
|
|
|
|
|
InputStream in = null;
|
|
|
|
@ -40,6 +50,39 @@ public class SearchServiceGet {
|
|
|
|
|
//这时候response就是一个连续字符串了吧
|
|
|
|
|
Log.i("response+++++",response+"返回值");
|
|
|
|
|
System.out.println(response.toString());
|
|
|
|
|
|
|
|
|
|
//开始解析返回的数据
|
|
|
|
|
JSONObject jo=JSONObject.fromObject(response.toString());
|
|
|
|
|
String message=jo.getString("message");
|
|
|
|
|
int code=jo.getInt("code");
|
|
|
|
|
if((message.equals("病症查询成功")||message.equals("药品查询成功"))&&code==200){
|
|
|
|
|
//查询成功,在开始解析数据
|
|
|
|
|
//把data里的数据转换为Map,遍历map,打印键值对
|
|
|
|
|
String data=jo.get("data").toString();
|
|
|
|
|
Map mapType = JSON.parseObject(data,Map.class);
|
|
|
|
|
for (Object obj : mapType.keySet()){
|
|
|
|
|
if(!obj.equals("teammates")){
|
|
|
|
|
//把键值对放入队列中
|
|
|
|
|
label.add(obj.toString());
|
|
|
|
|
content.add(mapType.get(obj).toString());
|
|
|
|
|
System.out.println("key为:"+obj+"值为:"+mapType.get(obj));
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
}else{
|
|
|
|
|
//查询失败什么都没有查到
|
|
|
|
|
//在页面显示什么都没有查到
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return response.toString();
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|