parent
92ea9462b0
commit
43121285a1
@ -1,20 +1,20 @@
|
||||
package com.example.PersonalCenter;
|
||||
|
||||
public class Register {
|
||||
String phonenumber;
|
||||
String username;
|
||||
String password;
|
||||
public Register(String phonenumber, String username, String password){
|
||||
this.phonenumber = phonenumber;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
public boolean regist(){
|
||||
String regRet = WebServicePost.execuHttpPost(username, phonenumber, password,"/Register");
|
||||
if(regRet.equals("true")){
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.example.PersonalCenter;
|
||||
//
|
||||
//public class Register {
|
||||
// String phonenumber;
|
||||
// String username;
|
||||
// String password;
|
||||
// public Register(String phonenumber, String username, String password){
|
||||
// this.phonenumber = phonenumber;
|
||||
// this.username = username;
|
||||
// this.password = password;
|
||||
// }
|
||||
// public boolean regist(){
|
||||
// String regRet = WebServicePost.execuHttpPost(username, phonenumber, password,"/Register");
|
||||
// if(regRet.equals("true")){
|
||||
// return true;
|
||||
// }else {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,47 +1,47 @@
|
||||
package com.example.PersonalCenter;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.hankcs.hanlp.HanLP;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class Search {
|
||||
public String sickname;
|
||||
public Search(String sickname){
|
||||
this.sickname = sickname;
|
||||
}
|
||||
|
||||
public List<Set<String>> search(){
|
||||
Log.i("search","sick执行了");
|
||||
//找出对应的8个关键字
|
||||
List<String> keywordList = HanLP.extractKeyword(sickname,8);
|
||||
|
||||
//针对每一个sickname来查找一下能不能够找到相应的名字
|
||||
Set<String> mediciesSet = new HashSet<String>();
|
||||
Set<String> reasonsSet = new HashSet<String>();
|
||||
for(String i: keywordList){
|
||||
Log.i("关键词提取",i+"ha");
|
||||
//package com.example.PersonalCenter;
|
||||
//
|
||||
//import android.util.Log;
|
||||
//
|
||||
//import com.hankcs.hanlp.HanLP;
|
||||
//
|
||||
//import java.lang.reflect.Array;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.HashSet;
|
||||
//import java.util.List;
|
||||
//import java.util.Set;
|
||||
//
|
||||
//public class Search {
|
||||
// public String sickname;
|
||||
// public Search(String sickname){
|
||||
// this.sickname = sickname;
|
||||
// }
|
||||
//
|
||||
// public List<Set<String>> search(){
|
||||
// Log.i("search","sick执行了");
|
||||
// //找出对应的8个关键字
|
||||
// List<String> keywordList = HanLP.extractKeyword(sickname,8);
|
||||
//
|
||||
// //针对每一个sickname来查找一下能不能够找到相应的名字
|
||||
// Set<String> mediciesSet = new HashSet<String>();
|
||||
// Set<String> reasonsSet = new HashSet<String>();
|
||||
// for(String i: keywordList){
|
||||
// Log.i("关键词提取",i+"ha");
|
||||
// String resq = SearchServiceGet.executeSearchGet(i,"/Search");
|
||||
String resq="dd";
|
||||
if(!resq.equals("fail")) {
|
||||
String[] me_rea = resq.split("-");
|
||||
String[] medicines = me_rea[0].split("\\|");
|
||||
for(String j: medicines) mediciesSet.add(j);
|
||||
String[] reasons = me_rea[1].split("\\|");
|
||||
for(String j: reasons) reasonsSet.add(j);
|
||||
|
||||
}
|
||||
}
|
||||
List<Set<String>> a = new ArrayList<Set<String>>();
|
||||
a.add(mediciesSet);
|
||||
a.add(reasonsSet);
|
||||
return a;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
// String resq="dd";
|
||||
// if(!resq.equals("fail")) {
|
||||
// String[] me_rea = resq.split("-");
|
||||
// String[] medicines = me_rea[0].split("\\|");
|
||||
// for(String j: medicines) mediciesSet.add(j);
|
||||
// String[] reasons = me_rea[1].split("\\|");
|
||||
// for(String j: reasons) reasonsSet.add(j);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// List<Set<String>> a = new ArrayList<Set<String>>();
|
||||
// a.add(mediciesSet);
|
||||
// a.add(reasonsSet);
|
||||
// return a;
|
||||
//
|
||||
//
|
||||
// }
|
||||
//}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.example.cmknowledgegraph;
|
||||
package com.example.SearchCenter;
|
||||
|
||||
public class ContentData {
|
||||
|
@ -0,0 +1,34 @@
|
||||
//package com.example.SearchCenter;
|
||||
//
|
||||
//import android.os.Bundle;
|
||||
//import android.util.Log;
|
||||
//import android.view.View;
|
||||
//import android.widget.Button;
|
||||
//import android.widget.EditText;
|
||||
//import android.widget.ImageButton;
|
||||
//
|
||||
//import androidx.appcompat.app.AppCompatActivity;
|
||||
//
|
||||
//import com.example.PersonalCenter.Search;
|
||||
//import com.example.cmknowledgegraph.R;
|
||||
////
|
||||
//public class SearchActivity extends AppCompatActivity {
|
||||
//
|
||||
// @Override
|
||||
// protected void onCreate(Bundle savedInstanceState) {
|
||||
// super.onCreate(savedInstanceState);
|
||||
// setContentView(R.layout.activity_search);
|
||||
// EditText search_edit_frame = findViewById(R.id.search_edit);
|
||||
// ImageButton search_btn = findViewById(R.id.search_btn);
|
||||
// String sickname = search_edit_frame.getText().toString();
|
||||
//
|
||||
// search_btn.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
//
|
||||
//// Search search = new Search(sickname);
|
||||
//// search.search();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//}
|
@ -1,4 +1,4 @@
|
||||
package com.example.cmknowledgegraph;
|
||||
package com.example.Util;
|
||||
|
||||
public interface ConditionCode {
|
||||
|
@ -0,0 +1,41 @@
|
||||
package com.example.Util;
|
||||
|
||||
import org.json.JSONArray;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ReturnData implements Serializable {
|
||||
private Integer code;
|
||||
private String msg;
|
||||
private Object data;
|
||||
|
||||
public ReturnData(Integer code, String msg, Object data) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.example.PersonalCenter;
|
||||
package com.example.Util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
@ -1,4 +1,4 @@
|
||||
package com.example.PersonalCenter;
|
||||
package com.example.Util;
|
||||
|
||||
import android.util.Log;
|
||||
|
@ -0,0 +1,114 @@
|
||||
package com.example.Util;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
/*
|
||||
* 发给tomcat服务器的网络请求类
|
||||
* @han
|
||||
* @ongbo
|
||||
* */
|
||||
public class cmkgWebServiceGet {
|
||||
public static ReturnData executeHttpGet(String args,String address){
|
||||
HttpURLConnection connection = null;
|
||||
InputStream in = null;
|
||||
|
||||
String path = publicStringUtil.cmkgTomcatURL+address+args;
|
||||
URL url = null;
|
||||
try {
|
||||
url = new URL(path);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
//打开连接
|
||||
connection = (HttpURLConnection)url.openConnection();
|
||||
//设置请求方式
|
||||
connection.setRequestMethod("GET");//
|
||||
//建立连接超时
|
||||
connection.setConnectTimeout(100000);
|
||||
//传输数据超时
|
||||
connection.setReadTimeout(80000);
|
||||
//获取返回结果json数据
|
||||
in = connection.getInputStream();
|
||||
return parseInfo(in);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(connection != null){
|
||||
connection.disconnect();
|
||||
}
|
||||
if(in != null){
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//将字节流转换成String
|
||||
public static ReturnData parseInfo(InputStream inputStream){
|
||||
BufferedReader reader = null;
|
||||
String line = "";
|
||||
StringBuilder response = new StringBuilder();
|
||||
try {
|
||||
reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
while((line = reader.readLine()) != null) {
|
||||
response.append(line);
|
||||
}
|
||||
|
||||
JSONObject jsonObject = null;
|
||||
try {
|
||||
jsonObject = new JSONObject(response.toString());
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
int code = 0;
|
||||
try {
|
||||
code = jsonObject.getInt("code");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Log.i("code:",""+code);
|
||||
String message = null;
|
||||
try {
|
||||
message = jsonObject.getString("msg");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Object data = null;
|
||||
try {
|
||||
data = jsonObject.getString("data");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Log.i("data:",""+data);
|
||||
ReturnData returnData = new ReturnData(code,message,data);
|
||||
return returnData;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(reader!=null){
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package com.example.cmknowledgegraph;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.example.PersonalCenter.Search;
|
||||
|
||||
public class SearchActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_search);
|
||||
EditText search_edit_frame = findViewById(R.id.search_edit);
|
||||
ImageButton search_btn = findViewById(R.id.search_btn);
|
||||
String sickname = search_edit_frame.getText().toString();
|
||||
|
||||
search_btn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
// Search search = new Search(sickname);
|
||||
// search.search();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in new issue