|
@@ -0,0 +1,59 @@
|
|
|
+package org.diagbot.graphWeb.work;
|
|
|
+
|
|
|
+import org.diagbot.graph.jdbc.DriverManager;
|
|
|
+import org.diagbot.graph.jdbc.Neo4jAPI;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description: 量表得分计算结果
|
|
|
+ * @Author: HUJING
|
|
|
+ * @Date: 2019/4/9 14:33
|
|
|
+ */
|
|
|
+public class ScaleCalculate {
|
|
|
+ public String scaleScoreCalc(String[] scaleItems,String scaleName){
|
|
|
+ Neo4jAPI neo4jAPI = null;
|
|
|
+ try {
|
|
|
+ neo4jAPI = new Neo4jAPI(DriverManager.newDrive("192.168.2.233","neo4j","root"));
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("Neo4j连接出错!");
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ int sum = 0;
|
|
|
+ String final_result = null;
|
|
|
+ Map<String, Object> scaleCalc = neo4jAPI.getScaleCalc(scaleName);
|
|
|
+ for (String scaleItem:scaleItems) {
|
|
|
+ Object details = scaleCalc.get("details");
|
|
|
+ //获取name
|
|
|
+ List<Map<String, Object>> content = (List<Map<String, Object>>) details;
|
|
|
+ for (Map<String, Object> map : content) {
|
|
|
+ String name = map.get("name").toString();
|
|
|
+ if (scaleItem.contains(name) || name.contains(scaleItem)) {
|
|
|
+ List<Map<String, Object>> sub_detail = (List<Map<String, Object>>) map.get("details");
|
|
|
+ for (Map<String, Object> sub_map : sub_detail) {
|
|
|
+ String detailName = sub_map.get("detailName").toString();
|
|
|
+ String score = sub_map.get("score").toString();
|
|
|
+ if(scaleItem.contains(detailName)){
|
|
|
+ sum += Double.valueOf(score);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println(sum);
|
|
|
+ List<Map<String, String>> result = (List<Map<String, String>>) scaleCalc.get("result");
|
|
|
+ for (Map<String, String> result_map:result) {
|
|
|
+ Integer min = Integer.valueOf(result_map.get("min"));
|
|
|
+ Integer max = Integer.valueOf(result_map.get("max"));
|
|
|
+ String text = result_map.get("text");
|
|
|
+ if (sum >= min && sum <= max){
|
|
|
+ final_result = text;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return final_result;
|
|
|
+ }
|
|
|
+}
|