From 14748debba40ddda4cc6f27050d649334af81994 Mon Sep 17 00:00:00 2001
From: hanxueqing <1045352474@qq.com>
Date: Mon, 6 Jan 2020 00:08:22 +0800
Subject: [PATCH] Merge branch 'master' of
http://bdgit.educoder.net/p01643725/paz2s9bc5
# Conflicts:
# cmkg/pom.xml
# cmkg/src/main/java/com/cmkg/cmkg/CmkgApplication.java
# cmkg/src/main/java/com/cmkg/cmkg/Controller/QuestionController.java
# cmkg/src/main/java/com/cmkg/cmkg/database/ReturnData.java
# cmkg/src/main/java/com/cmkg/cmkg/node/medicine.java
# cmkg/src/main/java/com/cmkg/cmkg/process/ModelProcess.java
# cmkg/src/main/java/com/cmkg/cmkg/repository/MedicineRespository.java
# cmkg/src/main/java/com/cmkg/cmkg/repository/QuestionRespository.java
# cmkg/src/main/java/com/cmkg/cmkg/server/QuestionService.java
# cmkg/src/main/java/com/cmkg/cmkg/server/impl/QuestionServiceImpl.java
# cmkg/src/main/resources/application.properties
---
app/app.iml | 2 +-
app/build.gradle | 1 -
.../SearchCenter/CMKGStackAdapter.java | 6 --
.../SearchCenter/SearchEntryActivity.java | 63 ++++++++++---------
.../main/res/layout/activity_search_entry.xml | 1 +
5 files changed, 35 insertions(+), 38 deletions(-)
diff --git a/app/app.iml b/app/app.iml
index 9273a94..8b55513 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -19,7 +19,7 @@
-
+
diff --git a/app/build.gradle b/app/build.gradle
index e358269..1d71c55 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -35,7 +35,6 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
api 'com.hankcs:hanlp:portable-1.7.2'
implementation 'com.google.android.material:material:1.0.0'
-
implementation 'com.alibaba:fastjson:1.2.62'
implementation 'com.loopeer.library:cardstack:1.0.2'
implementation 'androidx.cardview:cardview:1.0.0'
diff --git a/app/src/main/java/com/example/SearchCenter/CMKGStackAdapter.java b/app/src/main/java/com/example/SearchCenter/CMKGStackAdapter.java
index 595c493..0dc4a84 100644
--- a/app/src/main/java/com/example/SearchCenter/CMKGStackAdapter.java
+++ b/app/src/main/java/com/example/SearchCenter/CMKGStackAdapter.java
@@ -12,16 +12,12 @@ import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
-
import com.example.Util.ConditionCode;
import com.example.Util.ReturnData;
import com.example.cmknowledgegraph.R;
import com.loopeer.cardstack.CardStackView;
import com.loopeer.cardstack.StackAdapter;
-import org.json.JSONArray;
-import org.json.JSONException;
-
import java.util.List;
public class CMKGStackAdapter extends StackAdapter implements ConditionCode {
@@ -118,8 +114,6 @@ public class CMKGStackAdapter extends StackAdapter implements Condition
titleText.setText(returnData.getMsg());
}else {
//对应治疗方法,那么标题就要有多个
-
-
titleText.setText(SearchEntryActivity.content.get(title_num));
title_num++;
}
diff --git a/app/src/main/java/com/example/SearchCenter/SearchEntryActivity.java b/app/src/main/java/com/example/SearchCenter/SearchEntryActivity.java
index ebfa967..de89ca8 100644
--- a/app/src/main/java/com/example/SearchCenter/SearchEntryActivity.java
+++ b/app/src/main/java/com/example/SearchCenter/SearchEntryActivity.java
@@ -11,6 +11,8 @@ import androidx.appcompat.app.AppCompatActivity;
import com.example.Util.ConditionCode;
import com.example.Util.ReturnData;
+import com.example.Util.cmkgWebServiceGet;
+import com.example.Util.publicStringUtil;
import com.example.cmknowledgegraph.R;
import com.loopeer.cardstack.AllMoveDownAnimatorAdapter;
import com.loopeer.cardstack.CardStackView;
@@ -19,6 +21,7 @@ import com.loopeer.cardstack.UpDownStackAnimatorAdapter;
import org.json.JSONArray;
import org.json.JSONException;
+import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Arrays;
@@ -114,13 +117,12 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
*/
Log.i("hah",""+(String)response.getData());
JSONArray jsonArray = new JSONArray((String)response.getData());
- List list=new LinkedList<>();
for(int i=0;i list=new LinkedList<>();
list.add(new ContentData("我是您的用法哦~请您看看我嘞\n我无比的期待您的光临嘞\n我们没有连数据呢,马上就有嘞!"));
- lists.add(list);
content.add((String) jsonArray.get(i));
+ lists.add(list);
}
-
new_color=new Integer[jsonArray.length()];
}else if(code==MedicineToOperation) {
/**
@@ -138,8 +140,8 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
new_color=new Integer[1];
}else{
/**
- * //返回的是药的主治症状
- * 标题是药的名字,内容是主治症状
+ * //返回的是药的主治症状和对应的
+ * 标题是药的名字和“可以治疗的疾病”,内容是症状,和十种药物
*/
// for(int i = 0; i< content.size(); i++){
// List list=new LinkedList<>();
@@ -147,8 +149,17 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
// lists.add(list);
// }
List list = new LinkedList<>();
- list.add(new ContentData((String)response.getData()));
+ JSONObject jo=(JSONObject)response.getData();
+ String medicine_symptom=jo.getString("symptom");
+ list.add(new ContentData(medicine_symptom));
lists.add(list);
+ String disease_names=new String(jo.getString("name"));
+ JSONArray ja=new JSONArray(disease_names);
+ for(int i=0;i list_1=new LinkedList<>();
+ list_1.add(new ContentData(content.get(i)));
+ lists.add(list);
+ }
new_color=new Integer[1];
}
@@ -177,11 +188,11 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
* 病-症状:标题是名字,内容是症状
* 病-治疗药品:标题是药的名字,内容是药的用法(暂时不做)
* 药-用法:标题是药的名字,内容是药的用法
- * 药-作用:标题是药的名字,内容是药的用法
+ * 药-作用:标题是药的名字和 “可以治疗的疾病”,内容是药的用法
*
* 每种不同的情况对应不同的状态码,用接口实现状态码
*/
- adapter.updateData(Arrays.asList(new_color),lists);
+
// adapter.updateData(Arrays.asList(color),lists);
mCardStack.setAnimatorAdapter(new AllMoveDownAnimatorAdapter(mCardStack));
@@ -205,7 +216,7 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
textView_1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
-
+ cmkgWebServiceGet.executeHttpGet(publicStringUtil.questionSearchURL,publicStringUtil.questionSearchURL+response.getMsg()+"吃什么药");
}
});
}else if(response.getCode()==DiseaseToMedicines){
@@ -221,47 +232,39 @@ public class SearchEntryActivity extends AppCompatActivity implements CardStackV
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
-
+ cmkgWebServiceGet.executeHttpGet(publicStringUtil.questionSearchURL,publicStringUtil.questionSearchURL+response.getMsg()+"作用");
}
});
}
}else if(response.getCode()==MedicineToOperation){
/**
* 药——操作方法
- * nhm能治什么病 ,nhm的证候,nhm的功能
+ * nhm能治什么病
*/
-
TextView textView_1=findViewById(R.id.asscoiate_entry);
- TextView textView_2=findViewById(R.id.asscoiate_entry);
- TextView textView_3=findViewById(R.id.asscoiate_entry);
textView_1.setText(response.getMsg()+"能治什么病");
- textView_2.setText(response.getMsg()+"的证候");
- textView_3.setText(response.getMsg()+"的功能");
textView_1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
-
+ cmkgWebServiceGet.executeHttpGet(publicStringUtil.questionSearchURL,publicStringUtil.questionSearchURL+response.getMsg()+"作用");
}
});
- textView_2.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
-
- }
- });
- textView_3.setOnClickListener(new View.OnClickListener() {
+ }else {
+ /**
+ *药——作用,能治什么病
+ * nhm 操作方法
+ */
+ TextView textView=findViewById(R.id.asscoiate_entry);
+ textView.setText(response.getMsg()+"的用法");
+ textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
-
+ cmkgWebServiceGet.executeHttpGet(publicStringUtil.questionSearchURL,publicStringUtil.questionSearchURL+response.getMsg()+"用法");
}
});
- }else if(response.getCode()==MedicineToSymptom){
- /**
- *药——作用
- * nhm能治什么病,nhm的证候,nhm的功能
- */
}
+ adapter.updateData(Arrays.asList(new_color),lists);
}
}
diff --git a/app/src/main/res/layout/activity_search_entry.xml b/app/src/main/res/layout/activity_search_entry.xml
index e5e46f1..0cc3c03 100644
--- a/app/src/main/res/layout/activity_search_entry.xml
+++ b/app/src/main/res/layout/activity_search_entry.xml
@@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:orientation="vertical"
tools:context=".SearchEntryActivity">