|
@@ -47,6 +47,8 @@ import java.util.function.Function;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Stream;
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
+import static com.diagbot.util.StringUtil.permutationNoRepeat;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @Description: 图谱facade
|
|
* @Description: 图谱facade
|
|
* @author: Mark
|
|
* @author: Mark
|
|
@@ -181,6 +183,18 @@ public class NeoFacade {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void symptomMainCache() {
|
|
|
|
+ List<String> diseaseProperty = nodeRepository.getSymptomMain();
|
|
|
|
+ if (ListUtil.isNotEmpty(diseaseProperty)) {
|
|
|
|
+ Map map = diseaseProperty.stream().collect(Collectors.toMap(
|
|
|
|
+ k -> RedisEnum.symptomMainFeature.getName() + k,
|
|
|
|
+ v -> v,
|
|
|
|
+ (v1, v2) -> (v2)
|
|
|
|
+ ));
|
|
|
|
+ redisTemplate.opsForValue().multiSet(map);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
public void vitalCache() {
|
|
public void vitalCache() {
|
|
List<String> diseaseProperty = nodeRepository.getVitalClass();
|
|
List<String> diseaseProperty = nodeRepository.getVitalClass();
|
|
if (ListUtil.isNotEmpty(diseaseProperty)) {
|
|
if (ListUtil.isNotEmpty(diseaseProperty)) {
|
|
@@ -200,6 +214,7 @@ public class NeoFacade {
|
|
k -> RedisEnum.symptomFeature.getName() + k.getMinCombineElement(),
|
|
k -> RedisEnum.symptomFeature.getName() + k.getMinCombineElement(),
|
|
v -> {
|
|
v -> {
|
|
Map<String, String> desc = new HashMap<>();
|
|
Map<String, String> desc = new HashMap<>();
|
|
|
|
+ desc.put("minCombineElement",v.getMinCombineElement());
|
|
desc.put("bodyPart", v.getBodyPart());
|
|
desc.put("bodyPart", v.getBodyPart());
|
|
desc.put("change", v.getVariety());
|
|
desc.put("change", v.getVariety());
|
|
desc.put("color", v.getColor());
|
|
desc.put("color", v.getColor());
|
|
@@ -497,14 +512,86 @@ public class NeoFacade {
|
|
if(ListUtil.isNotEmpty(symptoms)){
|
|
if(ListUtil.isNotEmpty(symptoms)){
|
|
String s_m = symptoms.get(0);
|
|
String s_m = symptoms.get(0);
|
|
disBySymptom_main = nodeRepository.getDisBySymptom_main(s_m);
|
|
disBySymptom_main = nodeRepository.getDisBySymptom_main(s_m);
|
|
- if(ListUtil.isEmpty(disBySymptom_main) && ListUtil.isNotEmpty(pushVO.getSymptoms())){
|
|
|
|
|
|
+ /*if(ListUtil.isEmpty(disBySymptom_main) && ListUtil.isNotEmpty(pushVO.getSymptoms())){
|
|
String s_second = pushVO.getSymptoms().get(0);
|
|
String s_second = pushVO.getSymptoms().get(0);
|
|
disBySymptom_main = nodeRepository.getDisBySymptom_main(s_second);
|
|
disBySymptom_main = nodeRepository.getDisBySymptom_main(s_second);
|
|
|
|
+ }*/
|
|
|
|
+ if(ListUtil.isEmpty(disBySymptom_main)){
|
|
|
|
+ String name = RedisEnum.symptomFeature.getName();
|
|
|
|
+ Set<String> keys = redisUtil.keys(name + "*");
|
|
|
|
+ List<String> redis_key = keys.stream().map(x -> x.split(name)[1]).collect(Collectors.toList());
|
|
|
|
+ if(ListUtil.isNotEmpty(redis_key)){
|
|
|
|
+ List<String> filter_keys = redis_key.stream().filter(x -> s_m.contains(x)).collect(Collectors.toList());
|
|
|
|
+ List<Map<String,String>> redisDatas = redisUtil.getSf(filter_keys, RedisEnum.symptomFeature.getName());
|
|
|
|
+ Map<String,List<String>> min_filds = Maps.newHashMap();
|
|
|
|
+ if(ListUtil.isNotEmpty(redisDatas)){
|
|
|
|
+ redisDatas.forEach(x ->{
|
|
|
|
+ List<String> datas = Lists.newArrayList();
|
|
|
|
+ String minCombineElement = x.get("minCombineElement");
|
|
|
|
+ String radiationSituation = x.get("radiationSituation");
|
|
|
|
+ String color = x.get("color");
|
|
|
|
+ String change = x.get("change");
|
|
|
|
+ String degree = x.get("degree");
|
|
|
|
+ String shapePropety = x.get("shapePropety");
|
|
|
|
+ String position = x.get("position");
|
|
|
|
+ String bodyPart = x.get("bodyPart");
|
|
|
|
+ String frequency = x.get("frequency");
|
|
|
|
+ searchWord(radiationSituation,s_m,"、",datas);
|
|
|
|
+ searchWord(color,s_m,"、",datas);
|
|
|
|
+ searchWord(change,s_m,"、",datas);
|
|
|
|
+ searchWord(degree,s_m,"、",datas);
|
|
|
|
+ searchWord(shapePropety,s_m,"、",datas);
|
|
|
|
+ searchWord(position,s_m,"、",datas);
|
|
|
|
+ searchWord(bodyPart,s_m,"、",datas);
|
|
|
|
+ searchWord(frequency,s_m,"、",datas);
|
|
|
|
+ min_filds.put(minCombineElement,datas);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ if(MapUtils.isNotEmpty(min_filds)){
|
|
|
|
+ Map<Integer, List<String>> fild_pailie = Maps.newHashMap();
|
|
|
|
+ min_filds.forEach((k,v) ->{
|
|
|
|
+ v.add(k);
|
|
|
|
+ for(int i=v.size(); i>0; i--){
|
|
|
|
+ List<String> datad = permutationNoRepeat(v, i);
|
|
|
|
+ if(fild_pailie.containsKey(i)){
|
|
|
|
+ List<String> strings = fild_pailie.get(i);
|
|
|
|
+ datad.removeAll(strings);
|
|
|
|
+ strings.addAll(datad);
|
|
|
|
+ fild_pailie.put(i,strings);
|
|
|
|
+ }else {
|
|
|
|
+ fild_pailie.put(i,datad);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ if(MapUtils.isNotEmpty(fild_pailie)){
|
|
|
|
+ Map<Integer, List<String>> result = fild_pailie.entrySet().stream().sorted(Collections.reverseOrder(Map.Entry.comparingByKey()))
|
|
|
|
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e2, LinkedHashMap::new));
|
|
|
|
+ for (Map.Entry<Integer, List<String>> fd:result.entrySet()) {
|
|
|
|
+ List<String> sv = redisUtil.getSv(fd.getValue(), RedisEnum.symptomMainFeature.getName());
|
|
|
|
+ if(ListUtil.isNotEmpty(sv)){
|
|
|
|
+ disBySymptom_main = nodeRepository.getDisBySymptom_main(sv.get(0));
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return disBySymptom_main;
|
|
return disBySymptom_main;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void searchWord(String color,String regionWord,String patternFild,List<String> datas){
|
|
|
|
+ if(StringUtil.isNotEmpty(color)){
|
|
|
|
+ String[] splitsData = color.split(patternFild);
|
|
|
|
+ for (String fils:splitsData) {
|
|
|
|
+ if(regionWord.contains(fils)){
|
|
|
|
+ datas.add(fils);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
public List<String> getSymptoms(NeoPushVO pushVO){
|
|
public List<String> getSymptoms(NeoPushVO pushVO){
|
|
List<String> symptom_chief = Lists.newArrayList();
|
|
List<String> symptom_chief = Lists.newArrayList();
|
|
List<String> symptom_present = Lists.newArrayList();
|
|
List<String> symptom_present = Lists.newArrayList();
|