Преглед изворни кода

知识图谱推送算法测试页面

louhr пре 5 година
родитељ
комит
9b385fa31b

+ 2 - 2
push-web/src/main/java/org/diagbot/push/config/InterceptorConfig.java

@@ -23,7 +23,7 @@ public class InterceptorConfig implements WebMvcConfigurer {
         registration.addPathPatterns("/**");                    //所有路径都被拦截
         registration.addPathPatterns("/**");                    //所有路径都被拦截
 
 
         //生成数据文件
         //生成数据文件
-        CacheFileManager cacheFileManager = new CacheFileManager();
-        cacheFileManager.createCacheFile();
+//        CacheFileManager cacheFileManager = new CacheFileManager();
+//        cacheFileManager.createCacheFile();
     }
     }
 }
 }

+ 38 - 0
push-web/src/main/java/org/diagbot/push/controller/AlgorithmValidateController.java

@@ -1,14 +1,22 @@
 package org.diagbot.push.controller;
 package org.diagbot.push.controller;
 
 
+import org.diagbot.common.push.bean.FeatureRate;
 import org.diagbot.common.push.bean.ResponseData;
 import org.diagbot.common.push.bean.ResponseData;
 import org.diagbot.common.push.bean.SearchData;
 import org.diagbot.common.push.bean.SearchData;
 import org.diagbot.pub.api.Response;
 import org.diagbot.pub.api.Response;
+import org.diagbot.pub.utils.http.HttpApi;
 import org.diagbot.pub.web.BaseController;
 import org.diagbot.pub.web.BaseController;
+import org.diagbot.push.model.GraphDiseaseParamModel;
+import org.diagbot.push.model.GraphDiseaseResultModel;
 import org.springframework.stereotype.Controller;
 import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.ResponseBody;
 
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.List;
 
 
 /**
 /**
  * Created by louhr on 2020/2/25.
  * Created by louhr on 2020/2/25.
@@ -28,8 +36,38 @@ public class AlgorithmValidateController extends BaseController {
     @RequestMapping(value = "/page_neural")
     @RequestMapping(value = "/page_neural")
     @ResponseBody
     @ResponseBody
     public Response<ResponseData> neuralData(HttpServletRequest request, SearchData searchData) throws Exception {
     public Response<ResponseData> neuralData(HttpServletRequest request, SearchData searchData) throws Exception {
+        return combine(request, searchData);
+    }
+
+    @RequestMapping(value = "/neural", method = RequestMethod.POST)
+    @ResponseBody
+    public Response<ResponseData> bayesPageData(HttpServletRequest request, @RequestBody SearchData searchData) throws Exception {
+        return combine(request, searchData);
+    }
+
+    public Response<ResponseData> combine(HttpServletRequest request, @RequestBody SearchData searchData) throws Exception {
         Response<ResponseData> response = new Response();
         Response<ResponseData> response = new Response();
         ResponseData responseData = new ResponseData();
         ResponseData responseData = new ResponseData();
+
+        GraphDiseaseParamModel paramModel = new GraphDiseaseParamModel();
+        paramModel.setQuery(searchData.getSymptom());
+        HttpApi<GraphDiseaseResultModel> httpApi = new HttpApi<>();
+        GraphDiseaseResultModel resultModel = httpApi.doPost("http://192.168.3.150:2222/api/inference_disease_graph", paramModel, GraphDiseaseResultModel.class);
+        if (resultModel.getDiseases() != null && resultModel.getDiseases().length > 0) {
+            List<FeatureRate> dis = new ArrayList<>(10);
+            int num = 0;
+            for (String s : resultModel.getDiseases()) {
+                FeatureRate featureRate = new FeatureRate();
+                featureRate.setFeatureName(s);
+                dis.add(featureRate);
+                num++;
+                if (num > searchData.getLength()) {
+                    break;
+                }
+            }
+            responseData.setDis(dis);
+        }
+        response.setData(responseData);
         return response;
         return response;
     }
     }
 }
 }

+ 16 - 0
push-web/src/main/java/org/diagbot/push/model/GraphDiseaseParamModel.java

@@ -0,0 +1,16 @@
+package org.diagbot.push.model;
+
+/**
+ * Created by louhr on 2020/2/26.
+ */
+public class GraphDiseaseParamModel {
+    private String query;
+
+    public String getQuery() {
+        return query;
+    }
+
+    public void setQuery(String query) {
+        this.query = query;
+    }
+}

+ 25 - 0
push-web/src/main/java/org/diagbot/push/model/GraphDiseaseResultModel.java

@@ -0,0 +1,25 @@
+package org.diagbot.push.model;
+
+/**
+ * Created by louhr on 2020/2/26.
+ */
+public class GraphDiseaseResultModel {
+    private String error = "";
+    private String[] diseases;
+
+    public String getError() {
+        return error;
+    }
+
+    public void setError(String error) {
+        this.error = error;
+    }
+
+    public String[] getDiseases() {
+        return diseases;
+    }
+
+    public void setDiseases(String[] diseases) {
+        this.diseases = diseases;
+    }
+}

+ 1 - 1
push-web/src/main/resources/application.yml

@@ -1,5 +1,5 @@
 server:
 server:
-  port: 5008 # 端口号
+  port: 5009 # 端口号
   servlet:
   servlet:
     context-path: ${spring.application.name}  # 访问路径,如果不配置,访问IP:端口号,配置后访问IP:端口号/${context-path}
     context-path: ${spring.application.name}  # 访问路径,如果不配置,访问IP:端口号,配置后访问IP:端口号/${context-path}
 
 

+ 13 - 21
push-web/src/main/resources/static/pages/validate/list.html

@@ -92,7 +92,9 @@
                 </div>
                 </div>
                 <div class="form-group">
                 <div class="form-group">
                     <label for="diagString">疾病信息</label>&nbsp;
                     <label for="diagString">疾病信息</label>&nbsp;
-                    <input type="text" id="diagString" placeholder="" size="150">&nbsp;&nbsp;&nbsp;&nbsp;
+                    <input type="text" id="diagString" placeholder="" size="80">&nbsp;&nbsp;&nbsp;&nbsp;
+                    <label>记录数</label>&nbsp;
+                    <input type="text" id="length" placeholder="" value="20">
                 </div>
                 </div>
             </div>
             </div>
             <!-- /.box-body -->
             <!-- /.box-body -->
@@ -114,9 +116,7 @@
                             <table id="diag_list" class="table table-bordered table-striped">
                             <table id="diag_list" class="table table-bordered table-striped">
                                 <thead>
                                 <thead>
                                 <tr>
                                 <tr>
-                                    <th>diag</th>
-                                    <th>dept</th>
-                                    <th>rate</th>
+                                    <th>疾病</th>
                                 </tr>
                                 </tr>
                                 </thead>
                                 </thead>
                                 <tbody>
                                 <tbody>
@@ -139,9 +139,7 @@
                             <table id="before_combine_diag_list" class="table table-bordered table-striped">
                             <table id="before_combine_diag_list" class="table table-bordered table-striped">
                                 <thead>
                                 <thead>
                                 <tr>
                                 <tr>
-                                    <th>diag</th>
-                                    <th>dept</th>
-                                    <th>rate</th>
+                                    <th>检查</th>
                                 </tr>
                                 </tr>
                                 </thead>
                                 </thead>
                                 <tbody>
                                 <tbody>
@@ -164,8 +162,7 @@
                             <table id="symptom_list" class="table table-bordered table-striped">
                             <table id="symptom_list" class="table table-bordered table-striped">
                                 <thead>
                                 <thead>
                                 <tr>
                                 <tr>
-                                    <th>symptom</th>
-                                    <th>rate</th>
+                                    <th>用药</th>
                                 </tr>
                                 </tr>
                                 </thead>
                                 </thead>
                                 <tbody>
                                 <tbody>
@@ -213,7 +210,7 @@
     });
     });
 
 
     function bayesPage(resourceType) {
     function bayesPage(resourceType) {
-        startDiag('/algorithm_validate/page_neural', '#symptom_list', '1', resourceType, '111', '1');
+        startDiag('/algorithm_validate/page_neural', '#diag_list', '1', resourceType, '111', '1');
     }
     }
 
 
     function startDiag(url, obj, featureType, resourceType, algorithmClassify, tp) {
     function startDiag(url, obj, featureType, resourceType, algorithmClassify, tp) {
@@ -229,8 +226,7 @@
             "destroy": true,
             "destroy": true,
             "iDisplayLength": 25,
             "iDisplayLength": 25,
             "columns": [
             "columns": [
-                {"data": "featureName"},
-                {"data": "rate"}
+                {"data": "featureName"}
             ],
             ],
             "ajax": {
             "ajax": {
                 "url": push_web_url + url,
                 "url": push_web_url + url,
@@ -238,40 +234,36 @@
                     d.featureType = featureType;
                     d.featureType = featureType;
                     d.resourceType = resourceType;
                     d.resourceType = resourceType;
                     d.algorithmClassifyValue =  algorithmClassify;
                     d.algorithmClassifyValue =  algorithmClassify;
-                    var content = $("#content").val();
+                    var symptom = $("#content").val();
                     var diagString = $("#diagString").val();
                     var diagString = $("#diagString").val();
+                    var length = $("#length").val();
                     d.sysCode = "2";
                     d.sysCode = "2";
                     //添加额外的参数传给服务器
                     //添加额外的参数传给服务器
-                    if (content != null && content != undefined) {
-                        d.content = content;
+                    if (symptom != null && symptom != undefined) {
+                        d.symptom = symptom;
                     }
                     }
                     if (diagString != null && diagString != undefined) {
                     if (diagString != null && diagString != undefined) {
                         d.diagString = diagString;
                         d.diagString = diagString;
                     }
                     }
+                    d.length = length;
                 },
                 },
                 "dataSrc": function (json) {
                 "dataSrc": function (json) {
                     if (tp == '1') {
                     if (tp == '1') {
-                        $("#participle_diag").html(json.data.participleSymptom);
                         json.data = json.data.dis;
                         json.data = json.data.dis;
                     }
                     }
                     if (tp == '2') {
                     if (tp == '2') {
-                        $("#participle_diag").html(json.data.participleSymptom);
                         json.data = json.data.dis;
                         json.data = json.data.dis;
                     }
                     }
                     if (tp == '3') {
                     if (tp == '3') {
-                        $("#participle_vital").html(json.data.participleSymptom);
                         json.data = json.data.vitals;
                         json.data = json.data.vitals;
                     }
                     }
                     if (tp == '4') {
                     if (tp == '4') {
-                        $("#participle_lis").html(json.data.participleSymptom);
                         json.data = json.data.labs;
                         json.data = json.data.labs;
                     }
                     }
                     if (tp == '5') {
                     if (tp == '5') {
-                        $("#participle_pacs").html(json.data.participleSymptom);
                         json.data = json.data.pacs;
                         json.data = json.data.pacs;
                     }
                     }
                     if (tp == '6') {
                     if (tp == '6') {
-                        $("#before_combine_participle_diag").html(json.data.participleSymptom);
                         json.data = json.data.beforeCombineDis;
                         json.data = json.data.beforeCombineDis;
                     }
                     }
                     return json.data;
                     return json.data;