|
@@ -12,6 +12,7 @@ import org.diagbot.graph.jdbc.Neo4jAPI;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import org.diagbot.graphWeb.util.MapValueComparator;
|
|
|
|
|
|
public class GraphCalculate {
|
|
public class GraphCalculate {
|
|
public ResponseData calculate(HttpServletRequest request, SearchData searchData) throws Exception {
|
|
public ResponseData calculate(HttpServletRequest request, SearchData searchData) throws Exception {
|
|
@@ -64,6 +65,7 @@ public class GraphCalculate {
|
|
|
|
|
|
responseData.setGraphWords(graphWordfeatureRates);
|
|
responseData.setGraphWords(graphWordfeatureRates);
|
|
responseData.setDis(featureRates);
|
|
responseData.setDis(featureRates);
|
|
|
|
+
|
|
responseData.setInputs(searchData.getInputs());
|
|
responseData.setInputs(searchData.getInputs());
|
|
return responseData;
|
|
return responseData;
|
|
}
|
|
}
|
|
@@ -92,16 +94,80 @@ public class GraphCalculate {
|
|
//如果界面有诊断
|
|
//如果界面有诊断
|
|
if(webDiagList.size()>0){
|
|
if(webDiagList.size()>0){
|
|
lis = weblisPacs.get("LIS");
|
|
lis = weblisPacs.get("LIS");
|
|
|
|
+ lis = new HashSet<>(processResult(lis));
|
|
lis.addAll(biglisPacs.get("LIS"));
|
|
lis.addAll(biglisPacs.get("LIS"));
|
|
pacs = weblisPacs.get("PACS");
|
|
pacs = weblisPacs.get("PACS");
|
|
|
|
+ pacs = new HashSet<>(processResult(pacs));
|
|
pacs.addAll(biglisPacs.get("PACS"));
|
|
pacs.addAll(biglisPacs.get("PACS"));
|
|
|
|
|
|
}else {
|
|
}else {
|
|
lis=biglisPacs.get("LIS");
|
|
lis=biglisPacs.get("LIS");
|
|
pacs=biglisPacs.get("PACS");
|
|
pacs=biglisPacs.get("PACS");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ lis = new HashSet<>(processResult(lis));
|
|
|
|
+ pacs = new HashSet<>(processResult(pacs));
|
|
|
|
+
|
|
responseData.setLabs(new ArrayList<FeatureRate>(lis));
|
|
responseData.setLabs(new ArrayList<FeatureRate>(lis));
|
|
responseData.setPacs(new ArrayList<FeatureRate>(pacs));
|
|
responseData.setPacs(new ArrayList<FeatureRate>(pacs));
|
|
return responseData;
|
|
return responseData;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public List<FeatureRate> processResult(Set<FeatureRate> set) {
|
|
|
|
+ List<FeatureRate> frlist = new ArrayList<>();
|
|
|
|
+ Map<String, String> sortval = new HashMap<>();
|
|
|
|
+ Map<String, FeatureRate> items = new HashMap<>();
|
|
|
|
+ String name;
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ for (FeatureRate item:set) {
|
|
|
|
+ name = item.getFeatureName();
|
|
|
|
+ items.put(name, item);
|
|
|
|
+ if (sortval.get(name) == null) {
|
|
|
|
+ sortval.put(name, "1");
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ sortval.put(name, String.valueOf(Integer.parseInt(sortval.get(name))+1));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ sortval = sortMapByValue(sortval);
|
|
|
|
+
|
|
|
|
+ for (String key:sortval.keySet()) {
|
|
|
|
+ frlist.add(items.get(key));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex) {
|
|
|
|
+ ex.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ finally {
|
|
|
|
+ return frlist;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 使用 Map按value进行排序
|
|
|
|
+ * @param oriMap
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public static Map<String, String> sortMapByValue(Map<String, String> oriMap) {
|
|
|
|
+ if (oriMap == null || oriMap.isEmpty()) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ Map<String, String> sortedMap = new LinkedHashMap<String, String>();
|
|
|
|
+ List<Map.Entry<String, String>> entryList = new ArrayList<Map.Entry<String, String>>(
|
|
|
|
+ oriMap.entrySet());
|
|
|
|
+ Collections.sort(entryList, new MapValueComparator());
|
|
|
|
+
|
|
|
|
+ Iterator<Map.Entry<String, String>> iter = entryList.iterator();
|
|
|
|
+ Map.Entry<String, String> tmpEntry = null;
|
|
|
|
+ while (iter.hasNext()) {
|
|
|
|
+ tmpEntry = iter.next();
|
|
|
|
+ sortedMap.put(tmpEntry.getKey(), tmpEntry.getValue());
|
|
|
|
+ }
|
|
|
|
+ return sortedMap;
|
|
|
|
+ }
|
|
}
|
|
}
|