zhoutg 4 anni fa
parent
commit
64f5b3b8d6

+ 120 - 0
src/main/java/com/diagbot/aggregate/PushNewAggregate.java

@@ -0,0 +1,120 @@
+package com.diagbot.aggregate;
+
+import com.diagbot.client.PushNewServiceClient;
+import com.diagbot.dto.PushBaseDTO;
+import com.diagbot.dto.PushDTO;
+import com.diagbot.dto.PushNewDTO;
+import com.diagbot.dto.WordCrfDTO;
+import com.diagbot.enums.DiseaseTypeEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.process.PushProcess;
+import com.diagbot.util.CoreUtil;
+import com.diagbot.util.ListUtil;
+import com.diagbot.vo.PushNewVO;
+import io.github.lvyahui8.spring.annotation.DataConsumer;
+import io.github.lvyahui8.spring.annotation.DataProvider;
+import io.github.lvyahui8.spring.annotation.InvokeParameter;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @Description: 提醒类聚合
+ * @author: zhoutg
+ * @time: 2019/10/16 13:37
+ */
+@Component
+@Slf4j
+public class PushNewAggregate {
+
+    @Autowired
+    PushProcess pushProcess;
+    @Autowired
+    PushNewServiceClient pushNewServiceClient;
+
+    @DataProvider("pushAll")
+    public PushDTO push(
+            @InvokeParameter("wordCrfDTO") WordCrfDTO wordCrfDTO,
+            @InvokeParameter("pushNewVO") PushNewVO pushNewVO,
+            @DataConsumer("pushBigData") PushDTO pushBigData,
+            @DataConsumer("pushDiagnose") PushDTO pushDiagnose) {
+
+        PushDTO res = new PushDTO();
+        Map<String, Object> debug = new LinkedHashMap<>();
+        Map<String, List<PushBaseDTO>> dis = new LinkedHashMap<>();
+        res.setDis(dis);
+        res.setDebug(debug);
+        if (pushDiagnose != null) {
+            if (pushDiagnose.getDis() != null) {
+                dis.putAll(pushDiagnose.getDis());
+            }
+            debug.putAll(pushDiagnose.getDebug());
+        }
+        if (pushBigData != null) {
+            if (pushBigData.getDis() != null) {
+                dis.putAll(pushBigData.getDis());
+            }
+            debug.putAll(pushBigData.getDebug());
+        }
+        return res;
+    }
+
+    /**
+     * 诊断依据推理
+     *
+     * @param wordCrfDTO
+     * @return
+     */
+    @DataProvider("pushDiagnose")
+    public PushDTO pushDiagnose(@InvokeParameter("wordCrfDTO") WordCrfDTO wordCrfDTO) {
+        long start = System.currentTimeMillis();
+        PushDTO pushDTO = null;
+        try {
+            pushDTO = pushProcess.pushDiagnose(wordCrfDTO);
+        } catch (Exception e) {
+            log.error("【诊断依据推理出错】", e);
+            CoreUtil.getDebugStr("【诊断依据推理出错】", e, pushDTO.getDebug());
+        }
+        CoreUtil.getDebugStr(start, "诊断依据推送诊断耗时", pushDTO.getDebug());
+        return pushDTO;
+    }
+
+    /**
+     * 大数据推理
+     *
+     * @param pushNewVO
+     * @return
+     */
+    @DataProvider("pushBigData")
+    public PushDTO bill(@InvokeParameter("pushNewVO") PushNewVO pushNewVO) {
+        PushDTO pushDTO = new PushDTO();
+        Map<String, List<PushBaseDTO>> dis = new LinkedHashMap<>();
+        pushDTO.setDis(dis);
+        long start = System.currentTimeMillis();
+        try {
+            PushNewDTO pushNewDTO = pushNewServiceClient.pushNew(pushNewVO);
+            if (pushNewDTO == null) {
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "大数据推理服务挂了");
+            }
+            if (pushNewDTO != null && ListUtil.isNotEmpty(pushNewDTO.getDisease())) {
+                List<PushBaseDTO> pushBaseDTOList = pushNewDTO.getDisease().stream().map(r -> {
+                    PushBaseDTO pushBaseDTO = new PushBaseDTO();
+                    pushBaseDTO.setName(r);
+                    return pushBaseDTO;
+                }).collect(Collectors.toList());
+                dis.put(DiseaseTypeEnum.possibleDis.getName(), pushBaseDTOList);
+            }
+        } catch (Exception e) {
+            log.error("【大数据推理出错】", e);
+            CoreUtil.getDebugStr("【大数据推理出错】", e, pushDTO.getDebug());
+        }
+        CoreUtil.getDebugStr(start, "大数据推送诊断耗时", pushDTO.getDebug());
+        return pushDTO;
+    }
+}

+ 23 - 0
src/main/java/com/diagbot/client/PushNewServiceClient.java

@@ -0,0 +1,23 @@
+package com.diagbot.client;
+
+import com.diagbot.client.hystrix.PushNewServiceHystrix;
+import com.diagbot.dto.PushNewDTO;
+import com.diagbot.vo.PushNewVO;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+/**
+ * @description: CDSS新推送
+ * @author: zhoutg
+ * @date: 2021/3/24 15:24
+ */
+@FeignClient(value = "PushNew-service", url="${PushNew.url}", fallback = PushNewServiceHystrix.class)
+public interface PushNewServiceClient {
+
+    @PostMapping(value = "/api/disease")
+    PushNewDTO pushNew(@RequestBody PushNewVO pushNewVO);
+}
+
+
+

+ 18 - 0
src/main/java/com/diagbot/client/hystrix/PushNewServiceHystrix.java

@@ -0,0 +1,18 @@
+package com.diagbot.client.hystrix;
+
+import com.diagbot.client.PushNewServiceClient;
+import com.diagbot.dto.PushNewDTO;
+import com.diagbot.vo.PushNewVO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+@Component
+@Slf4j
+public class PushNewServiceHystrix implements PushNewServiceClient {
+
+    @Override
+    public PushNewDTO pushNew(PushNewVO pushNewVO) {
+        log.error("【hystrix】调用{}异常", "pushNew");
+        return null;
+    }
+}

+ 10 - 9
src/main/java/com/diagbot/dto/PushDTO.java

@@ -1,5 +1,6 @@
 package com.diagbot.dto;
 
+import com.google.common.collect.Lists;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -16,23 +17,23 @@ import java.util.Map;
 @Setter
 public class PushDTO {
     //症状
-    private List<PushBaseDTO> symptom;
+    private List<PushBaseDTO> symptom = Lists.newArrayList();
     //体格检查
-    private List<PushBaseDTO> vital;
+    private List<PushBaseDTO> vital = Lists.newArrayList();
     //检验
-    private List<PushBaseDTO> lis;
+    private List<PushBaseDTO> lis = Lists.newArrayList();
     //检查
-    private List<PushBaseDTO> pacs;
+    private List<PushBaseDTO> pacs = Lists.newArrayList();
     // 手术
-    private List<PushBaseDTO> operations;
+    private List<PushBaseDTO> operations = Lists.newArrayList();
     // 药品
-    private List<PushBaseDTO> medicines;
+    private List<PushBaseDTO> medicines = Lists.newArrayList();
     // 并发症
-    private List<PushBaseDTO> complications;
+    private List<PushBaseDTO> complications = Lists.newArrayList();
     //诊断
-    private Map<String, List<PushBaseDTO>> dis;
+    private Map<String, List<PushBaseDTO>> dis = new LinkedHashMap<>();
     //一般治疗
-    private List<TreatDTO> treat;
+    private List<TreatDTO> treat = Lists.newArrayList();
 
     // 记录调试信息
     private Map<String, Object> debug = new LinkedHashMap<>();

+ 19 - 0
src/main/java/com/diagbot/dto/PushNewDTO.java

@@ -0,0 +1,19 @@
+package com.diagbot.dto;
+
+import com.google.common.collect.Lists;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @Description: 推理出参
+ * @author: zhoutg
+ * @time: 2020/8/6 9:54
+ */
+@Data
+public class PushNewDTO {
+    // 返回状态
+    private Boolean status;
+    // 返回疾病
+    private List<String> Disease = Lists.newArrayList();
+}

+ 1 - 1
src/main/java/com/diagbot/dto/ReverseDTO.java

@@ -12,5 +12,5 @@ public class ReverseDTO {
     private String libName; // 标准词名称
     private String sonName; // 子项名称
     private Long sonId; // 子项conceptId
-    private Long sonType; // 子项类型
+    private Integer sonType; // 子项类型
 }

+ 68 - 0
src/main/java/com/diagbot/enums/PushTypeEnum.java

@@ -0,0 +1,68 @@
+package com.diagbot.enums;
+
+import com.diagbot.core.KeyedNamed;
+import lombok.Setter;
+
+/**
+ * @author zhoutg
+ * @Description: 类型枚举
+ * @date 2018年10月11日 下午3:33:22
+ */
+
+public enum PushTypeEnum implements KeyedNamed {
+
+    symptom(1, "症状"),
+    vital(4, "查体结果"),
+    lis(5, "化验"),
+    pacs(6, "辅检"),
+    disease(7, "诊断"),
+    drug(8, "药品"),
+    operation(9, "手术"),
+    treat(10, "一般治疗");
+
+    @Setter
+    private int key;
+
+    @Setter
+    private String name;
+
+    PushTypeEnum(int key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public static PushTypeEnum getEnum(int key) {
+        for (PushTypeEnum item : PushTypeEnum.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static PushTypeEnum getEnum(String value) {
+        for (PushTypeEnum item : PushTypeEnum.values()) {
+            if (item.getName().equals(value)) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(int key) {
+        PushTypeEnum item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    @Override
+    public int getKey() {
+        return key;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+
+}

+ 66 - 0
src/main/java/com/diagbot/enums/RelationshipEnum.java

@@ -0,0 +1,66 @@
+package com.diagbot.enums;
+
+import com.diagbot.core.KeyedNamed;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2021/2/24 10:46
+ */
+public enum RelationshipEnum implements KeyedNamed {
+
+    R501(501, "疾病相关主症状"),
+    R502(502,"疾病相关次症状"),
+    R503(503,"疾病相关体格检查结果"),
+    R504(504,"疾病相关实验室检查套餐"),
+    R505(505,"疾病相关辅助检查项目"),
+    R506(506,"疾病相关药物治疗"),
+    R507(507,"疾病相关手术治疗"),
+    R508(508,"疾病相关鉴别诊断"),
+    R600(600,"相关子类");
+
+    @Setter
+    private int key;
+
+    @Setter
+    private String name;
+
+    RelationshipEnum(int key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public static RelationshipEnum getEnum(int key) {
+        for (RelationshipEnum item : RelationshipEnum.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static RelationshipEnum getEnum(String value) {
+        for (RelationshipEnum item : RelationshipEnum.values()) {
+            if (item.getName().equals(value)) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(int key) {
+        RelationshipEnum item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    @Override
+    public int getKey() {
+        return key;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+}

+ 50 - 4
src/main/java/com/diagbot/facade/PushFacade.java

@@ -1,18 +1,25 @@
 package com.diagbot.facade;
 
+import com.diagbot.client.PushNewServiceClient;
 import com.diagbot.dto.PushDTO;
+import com.diagbot.dto.PushNewDTO;
 import com.diagbot.dto.PushPlanDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.enums.DiseasePushTypeEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
 import com.diagbot.process.PushProcess;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ParamUtil;
+import com.diagbot.vo.PushNewVO;
 import com.diagbot.vo.PushPlanVO;
 import com.diagbot.vo.PushVO;
 import com.diagbot.vo.StandConvert;
+import io.github.lvyahui8.spring.facade.DataFacade;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
@@ -34,6 +41,8 @@ public class PushFacade {
     FollowupPlanInfoFacade followupPlanInfoFacade;
     @Autowired
     TranHospitalInfoFacade tranHospitalInfoFacade;
+    @Autowired
+    PushNewServiceClient pushNewServiceClient;
 
     public PushDTO processAggreate(PushVO pushVo) {
         // 年龄容错处理
@@ -92,10 +101,21 @@ public class PushFacade {
         CoreUtil.getDebugStr(standStart, "标准词转换耗时", debug);
         ParamUtil.dealLis(wordCrfDTO.getLis());
 
-        // 推送
-        long pushStart = System.currentTimeMillis();
-        PushDTO pushDTO = pushProcess.process(pushVo, standConvertMap, wordCrfDTO);
-        CoreUtil.getDebugStr(pushStart, "规则业务耗时", debug);
+        PushDTO pushDTO = null;
+        try {
+            Map<String, Object> invokeParams = new HashMap<>();
+            invokeParams.put("wordCrfDTO", wordCrfDTO);
+            invokeParams.put("pushNewVO", generatePushVo(wordCrfDTO));
+            pushDTO = DataFacade.get("pushAll", invokeParams, PushDTO.class);
+        } catch (Exception e) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "推送服务出错" + e.getMessage());
+        }
+
+        // 通过诊断反推
+        long reverseStart = System.currentTimeMillis();
+        // TODO 处理诊断信息
+        pushProcess.process(pushDTO, pushVo, wordCrfDTO);
+        CoreUtil.getDebugStr(reverseStart, "反推业务耗时", debug);
 
         CoreUtil.getDebugStr(start, "总计耗时", debug);
         CoreUtil.getDebugObject("数据", debug, wordCrfDTO);
@@ -103,6 +123,22 @@ public class PushFacade {
         return pushDTO;
     }
 
+    /**
+     * 生成新版推送入参
+     *
+     * @param wordCrfDTO
+     * @return
+     */
+    public PushNewVO generatePushVo(WordCrfDTO wordCrfDTO) {
+        // TODO 获取医院类型
+        PushNewVO pushNewVO = new PushNewVO();
+        pushNewVO.setChief(wordCrfDTO.getChief());
+        pushNewVO.setPresent(wordCrfDTO.getSymptom());
+        pushNewVO.setAge(wordCrfDTO.getAgeNum());
+        pushNewVO.setSex(wordCrfDTO.getSex());
+        return pushNewVO;
+    }
+
     /**
      * 手术随访计划(持续检验检查)推送
      *
@@ -133,4 +169,14 @@ public class PushFacade {
         return pushPlanDTO;
     }
 
+    /**
+     * 测试新版推送
+     *
+     * @param pushNewVO
+     * @return
+     */
+    public PushNewDTO testPushFac(PushNewVO pushNewVO) {
+        return pushNewServiceClient.pushNew(pushNewVO);
+    }
+
 }

+ 191 - 41
src/main/java/com/diagbot/process/PushProcess.java

@@ -24,6 +24,7 @@ import com.diagbot.enums.LexiconEnum;
 import com.diagbot.enums.MedicalAdviceEnum;
 import com.diagbot.enums.PushRelationTypeEnum;
 import com.diagbot.enums.RedisEnum;
+import com.diagbot.enums.RelationshipEnum;
 import com.diagbot.enums.StandConvertEnum;
 import com.diagbot.facade.CommonFacade;
 import com.diagbot.facade.ConceptInfoFacade;
@@ -38,14 +39,18 @@ import com.diagbot.rule.GroupRule;
 import com.diagbot.rule.LisRule;
 import com.diagbot.rule.VitalRule;
 import com.diagbot.util.BeanUtil;
+import com.diagbot.util.CoreUtil;
+import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.RedisUtil;
+import com.diagbot.util.StringUtil;
 import com.diagbot.vo.DiagnoseVO;
 import com.diagbot.vo.DiseaseItemVO;
 import com.diagbot.vo.IcssVo;
 import com.diagbot.vo.NeoPushVO;
 import com.diagbot.vo.PushVO;
 import com.diagbot.vo.ReverseVO;
+import com.diagbot.vo.StandConvert;
 import com.diagbot.vo.neoPushEntity.Diag;
 import com.diagbot.vo.neoPushEntity.DiagVo;
 import com.google.common.collect.Lists;
@@ -354,40 +359,21 @@ public class PushProcess {
     }
 
     /**
-     * 6.0推送业务
+     * 反推
      *
      * @param pushVo
      * @param standConvertMap
      * @param wordCrfDTO
      * @return
      */
-    public PushDTO process(PushVO pushVo, Map<String, Map<String, String>> standConvertMap, WordCrfDTO wordCrfDTO) {
+    public PushDTO process(PushDTO pushDTO, PushVO pushVo, WordCrfDTO wordCrfDTO) {
         int length = pushVo.getLength();
-        // TODO 聚合诊断依据推送的诊断和大数据推送的可能诊断
-        PushDTO pushDTO = pushDiagnose(wordCrfDTO);
+        // 需要获取的类型
         List<String> ruleTypeList = Arrays.asList(pushVo.getFeatureType().split(","));
-        Map<String, List<String>> typeWords = typeWords(standConvertMap);
-
+        // 界面过滤元素
+        Map<String, List<String>> typeWords = filterWords(wordCrfDTO);
         // 根据诊断反推(根据性别和年龄过滤,并根据界面已有信息过滤,根据长度截取)
         reversePushPackage(pushDTO, ruleTypeList, typeWords, wordCrfDTO, length);
-
-        // if (ListUtil.isNotEmpty(push)) {
-        //     //先把所有疾病推出来
-        //     if (ruleTypeList.contains("7")) {
-        //         List<PushBaseDTO> diseeases = push.stream().map(x -> {
-        //             PushBaseDTO pushBaseDTO = new PushBaseDTO();
-        //             pushBaseDTO.setName(x);
-        //             return pushBaseDTO;
-        //         }).collect(Collectors.toList());
-        //         diseeases = diseeases.subList(0, diseeases.size() >= length ? length : diseeases.size());
-        //         dis.put(DiseaseTypeEnum.possibleDis.getName(), diseeases);
-        //         pushDTO.setDis(dis);
-        //     }
-        //     //把第一个推送出来的诊断set到diagOrder中,再反推
-        //     setPushVo(pushVO, push);
-        //     //调用反推
-        //     reversePushPackage(length, pushDTO, ruleTypeList, typeWords, pushVO, dis);
-        // }
         return pushDTO;
     }
 
@@ -520,19 +506,26 @@ public class PushProcess {
         pushVO.setDiagVo(diagVo);
     }
 
-    public Map<String, List<String>> typeWords(Map<String, Map<String, String>> standConvertMap) {
+    /**
+     * 生成各个类型的界面过滤元素
+     *
+     * @param wordCrfDTO
+     * @return
+     */
+    public Map<String, List<String>> filterWords(WordCrfDTO wordCrfDTO) {
         Map<String, List<String>> typeWordsMap = new HashMap<>();
-        for (Map.Entry<String, Map<String, String>> s : standConvertMap.entrySet()) {
-            List<String> words = new ArrayList<>();
-            String type = s.getKey();
-            Map<String, String> value = s.getValue();
-            value.forEach((name, standName) -> {
-                words.add(name);
-                words.add(standName);
-            });
-            typeWordsMap.put(type, new ArrayList<>(new LinkedHashSet<>(words)));
-        }
-
+        // TODO 界面过滤元素
+        typeWordsMap.put(StandConvertEnum.lis.getName(), CoreUtil.getByPropertyName(wordCrfDTO.getLis(), "name", "uniqueName"));
+        // for (Map.Entry<String, Map<String, String>> s : standConvertMap.entrySet()) {
+        //     List<String> words = new ArrayList<>();
+        //     String type = s.getKey();
+        //     Map<String, String> value = s.getValue();
+        //     value.forEach((name, standName) -> {
+        //         words.add(name);
+        //         words.add(standName);
+        //     });
+        //     typeWordsMap.put(type, new ArrayList<>(new LinkedHashSet<>(words)));
+        // }
         return typeWordsMap;
     }
 
@@ -545,13 +538,170 @@ public class PushProcess {
      * @param length
      */
     private void reversePushPackage(PushDTO pushDTO, List<String> ruleTypeList, Map<String, List<String>> typeWords, WordCrfDTO wordCrfDTO, int length){
-        // TODO 拼接查询数据的入参
-        ReverseVO reverseVO = new ReverseVO();
-
-        // TODO 查询数据
+        Map<String, List<PushBaseDTO>> dis = pushDTO.getDis();
+        // 生成反推的入参
+        ReverseVO reverseVO = generateReverseVO(wordCrfDTO, ruleTypeList, dis);
+        if (StringUtil.isEmpty(reverseVO.getLibName())) {
+            return ;
+        }
+        pushDTO.getDebug().put("反推依据诊断", reverseVO.getLibName());
+        // 查询数据
         List<ReverseDTO> reverseDTOList = conceptInfoFacade.getReverseFac(reverseVO);
 
-        // TODO 放到对应位置
+        // 设置其他推送信息
+        setPushItem(pushDTO, ruleTypeList, typeWords, reverseDTOList, length);
+    }
+
+    /**
+     * 设置其他推送信息
+     *
+     * @param pushDTO
+     * @param ruleTypeList
+     * @param typeWords
+     * @param reverseDTOList
+     */
+    public void setPushItem(PushDTO pushDTO, List<String> ruleTypeList, Map<String, List<String>> typeWords, List<ReverseDTO> reverseDTOList, int length) {
+        Map<String, List<PushBaseDTO>> dis = pushDTO.getDis();
+        Map<Integer, List<ReverseDTO>> map = EntityUtil.makeEntityListMap(reverseDTOList, "sonType");
+        // 症状
+        if (ruleTypeList.contains("1")) {
+            if (map.get(LexiconEnum.Symptom.getKey()) != null) {
+                List<String> list = map.get(LexiconEnum.Symptom.getKey()).stream().map(r -> r.getSonName()).collect(Collectors.toList());
+                CoreUtil.removeRepeat(list, typeWords.get(StandConvertEnum.symptom.toString())); // 过滤界面已有
+                pushDTO.setSymptom(getPushBaseDTO(list, length)); // 放入对象返回
+            }
+        }
+        // 查体结果
+        if (ruleTypeList.contains("4")) {
+            if (map.get(LexiconEnum.VitalResult.getKey()) != null) {
+                List<String> list = map.get(LexiconEnum.VitalResult.getKey()).stream().map(r -> r.getSonName()).collect(Collectors.toList());
+                CoreUtil.removeRepeat(list, typeWords.get(StandConvertEnum.vital.toString())); // 过滤界面已有
+                pushDTO.setVital(getPushBaseDTO(list, length)); // 放入对象返回
+            }
+        }
+        // 化验套餐
+        if (ruleTypeList.contains("5")) {
+            if (map.get(LexiconEnum.LisName.getKey()) != null) {
+                List<String> list = map.get(LexiconEnum.LisName.getKey()).stream().map(r -> r.getSonName()).collect(Collectors.toList());
+                CoreUtil.removeRepeat(list, typeWords.get(StandConvertEnum.lis.toString())); // 过滤界面已有
+                pushDTO.setLis(getPushBaseDTO(list, length)); // 放入对象返回
+            }
+        }
+        // 辅检项目
+        if (ruleTypeList.contains("6")) {
+            if (map.get(LexiconEnum.PacsName.getKey()) != null) {
+                List<String> list = map.get(LexiconEnum.PacsName.getKey()).stream().map(r -> r.getSonName()).collect(Collectors.toList());
+                CoreUtil.removeRepeat(list, typeWords.get(StandConvertEnum.pacs.toString())); // 过滤界面已有
+                pushDTO.setPacs(getPushBaseDTO(list, length)); // 放入对象返回
+            }
+        }
+        // 鉴别诊断, 注意这个类型与其他类型不一样
+        if (ruleTypeList.contains("7")) {
+            if (map.get(LexiconEnum.Disease.getKey()) != null) {
+                List<String> list = map.get(LexiconEnum.Disease.getKey()).stream().map(r -> r.getSonName()).collect(Collectors.toList());
+                CoreUtil.removeRepeat(list, typeWords.get(StandConvertEnum.disease.toString())); // 过滤界面已有
+                List<PushBaseDTO> pushBaseDTO = getPushBaseDTO(list, length);
+                if (ListUtil.isNotEmpty(pushBaseDTO)) {
+                    dis.put(DiseaseTypeEnum.identify.getName(), pushBaseDTO);
+                }
+            }
+        }
+        // 药品
+        if (ruleTypeList.contains("8")) {
+            if (map.get(LexiconEnum.Medicine.getKey()) != null) {
+                List<String> list = map.get(LexiconEnum.Medicine.getKey()).stream().map(r -> r.getSonName()).collect(Collectors.toList());
+                CoreUtil.removeRepeat(list, typeWords.get(StandConvertEnum.drug.toString())); // 过滤界面已有
+                pushDTO.setMedicines(getPushBaseDTO(list, length)); // 放入对象返回
+            }
+        }
+        // 手术
+        if (ruleTypeList.contains("9")) {
+            if (map.get(LexiconEnum.Operation.getKey()) != null) {
+                List<String> list = map.get(LexiconEnum.Operation.getKey()).stream().map(r -> r.getSonName()).collect(Collectors.toList());
+                CoreUtil.removeRepeat(list, typeWords.get(StandConvertEnum.operation.toString())); // 过滤界面已有
+                pushDTO.setOperations(getPushBaseDTO(list, length)); // 放入对象返回
+            }
+        }
+    }
+
+    /**
+     * 将名称列表生成推送返回类型
+     *
+     * @param nameList
+     * @param length 最长个数
+     * @return
+     */
+    public List<PushBaseDTO> getPushBaseDTO(List<String> nameList, int length) {
+        List<PushBaseDTO> pushBaseDTOList = Lists.newArrayList();
+        if (ListUtil.isNotEmpty(nameList)) {
+            for (int i = 0; i < nameList.size(); i++) {
+                if (pushBaseDTOList.size() >= length) {
+                    break;
+                }
+                PushBaseDTO pushBaseDTO = new PushBaseDTO();
+                pushBaseDTO.setName(nameList.get(i));
+                pushBaseDTOList.add(pushBaseDTO);
+            }
+        }
+        return pushBaseDTOList;
+    }
+
+    /**
+     * 生成反推的入参
+     *
+     * @param wordCrfDTO
+     * @param ruleTypeList
+     * @param dis
+     * @return
+     */
+    public ReverseVO generateReverseVO(WordCrfDTO wordCrfDTO, List<String> ruleTypeList, Map<String, List<PushBaseDTO>> dis) {
+        ReverseVO reverseVO = new ReverseVO();
+        reverseVO.setAge(wordCrfDTO.getAgeNum());
+        reverseVO.setSexType(wordCrfDTO.getSex());
+        reverseVO.setLibType(LexiconEnum.Disease.getKey());
+        String disName = "";
+        // 按以下顺序获取一个诊断: 下的诊断->确诊->拟诊->警惕->可能
+        if (ListUtil.isNotEmpty(wordCrfDTO.getDiag())) {
+            disName = wordCrfDTO.getDiag().get(0).getUniqueName();
+        } else if (dis != null) {
+            if (dis.get(DiagnoseTypeEnum.definite.getName()) != null) { // 确诊
+                disName = dis.get(DiagnoseTypeEnum.definite.getName()).get(0).getName();
+            } else if (dis.get(DiagnoseTypeEnum.protocol.getName()) != null) { // 拟诊
+                disName = dis.get(DiagnoseTypeEnum.protocol.getName()).get(0).getName();
+            } else if (dis.get(DiagnoseTypeEnum.vigilant.getName()) != null) { // 警惕
+                disName = dis.get(DiagnoseTypeEnum.vigilant.getName()).get(0).getName();
+            } else if (dis.get(DiseaseTypeEnum.possibleDis.getName()) != null) { // 可能
+                disName = dis.get(DiseaseTypeEnum.possibleDis.getName()).get(0).getName();
+            }
+        }
+        reverseVO.setLibName(disName);
+
+        // 关联类型
+        List<Integer> relationType = new ArrayList<>();
+        if (ruleTypeList.contains("1")) {
+            relationType.add(RelationshipEnum.R501.getKey()); // 主症状
+            relationType.add(RelationshipEnum.R502.getKey()); // 次症状
+        }
+        if (ruleTypeList.contains("4")) {
+            relationType.add(RelationshipEnum.R503.getKey()); // 查体结果
+        }
+        if (ruleTypeList.contains("5")) {
+            relationType.add(RelationshipEnum.R504.getKey()); // 化验套餐
+        }
+        if (ruleTypeList.contains("6")) {
+            relationType.add(RelationshipEnum.R505.getKey()); // 辅助检查项目
+        }
+        if (ruleTypeList.contains("7")) {
+            relationType.add(RelationshipEnum.R508.getKey()); // 鉴别诊断
+        }
+        if (ruleTypeList.contains("8")) {
+            relationType.add(RelationshipEnum.R506.getKey()); // 药品
+        }
+        if (ruleTypeList.contains("9")) {
+            relationType.add(RelationshipEnum.R507.getKey()); // 手术
+        }
+        reverseVO.setRelationType(relationType);
+        return reverseVO;
     }
 
     private void reversePushPackage(int length, PushDTO pushDTO, List<String> ruleTypeList, Map<String, List<String>> typeWords, NeoPushVO pushVO, Map<String, List<PushBaseDTO>> dis) {

+ 0 - 2
src/main/java/com/diagbot/service/impl/ConceptInfoServiceImpl.java

@@ -1,6 +1,5 @@
 package com.diagbot.service.impl;
 
-import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.diagbot.dto.ReverseDTO;
 import com.diagbot.entity.ConceptInfo;
@@ -20,7 +19,6 @@ import java.util.List;
  * @since 2020-08-18
  */
 @Service
-@DS("cdss")
 public class ConceptInfoServiceImpl extends ServiceImpl<ConceptInfoMapper, ConceptInfo> implements ConceptInfoService {
     @Override
     public List<ReverseDTO> getReverse(ReverseVO reverseVO) {

+ 43 - 0
src/main/java/com/diagbot/util/CoreUtil.java

@@ -11,6 +11,7 @@ import com.diagbot.model.entity.PD;
 import com.diagbot.model.entity.Usual;
 import com.diagbot.model.entity.Vital;
 import com.diagbot.model.label.VitalLabel;
+import com.google.common.collect.Lists;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
@@ -20,6 +21,7 @@ import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -915,6 +917,47 @@ public class CoreUtil {
         list.addAll(Arrays.stream(s.split(",")).map(r -> Long.parseLong(r)).collect(Collectors.toList()));
     }
 
+    /**
+     * 在源列表中移除过滤的内容
+     *
+     * @param orginList
+     * @param splitList
+     */
+    public static void removeRepeat(List<String> orginList, List<String> splitList) {
+        if (ListUtil.isNotEmpty(orginList) || ListUtil.isEmpty(splitList)) {
+            return ;
+        }
+        Iterator<String> iterator = orginList.iterator();
+        while (iterator.hasNext()) {
+            String key = iterator.next();
+            if (splitList.contains(key)) {
+                iterator.remove();
+            }
+        }
+    }
+
+    /**
+     * 根据属性名获取内容
+     *
+     * @param tList
+     * @param propertyName
+     * @return
+     */
+    public  static <T> List<String> getByPropertyName(List<T> tList, String... propertyName) {
+        List<String> list = Lists.newArrayList();
+        if (ListUtil.isEmpty(tList)) {
+            return list;
+        }
+        for (T t : tList) {
+            for (String key : propertyName) {
+                String name = (String)getFieldValue(t, key);
+                if (StringUtil.isNotBlank(name)) {
+                    list.add(name);
+                }
+            }
+        }
+        return list;
+    }
 
     public static void main(String[] args) {
         List<Item> list = new ArrayList<>();

+ 30 - 30
src/main/java/com/diagbot/util/RedisUtil.java

@@ -30,26 +30,6 @@ public class RedisUtil {
     @Qualifier("redisTemplateForSimilar")
     RedisTemplate redisTemplate;
 
-    /**
-     * 更新指定类型下的数据
-     *
-     * @param map
-     * @param type
-     */
-    public void updateValue(Map<String, String> map, String type) {
-        redisTemplate.opsForValue().set(type, map);
-    }
-
-    /**
-     * 更新指定类型下的数据
-     *
-     * @param key
-     * @param list
-     */
-    public void updateValue(String key, List<String> list) {
-        redisTemplate.opsForValue().set(key, list);
-    }
-
     /**
      * 更新指定的数据
      *
@@ -82,6 +62,36 @@ public class RedisUtil {
         return (T) redisTemplate.opsForValue().get(key);
     }
 
+    /**
+     * 根据指定key设置obj
+     *
+     * @param key
+     * @param obj
+     */
+    public void set(String key, Object obj) {
+        redisTemplate.opsForValue().set(key, obj);
+    }
+
+    /**
+     * 批量获取
+     *
+     * @param keys
+     * @return
+     */
+    public <T> List<T> multiGet(Collection<String> keys) {
+        return redisTemplate.opsForValue().multiGet(keys);
+    }
+
+    /**
+     * 批量设置
+     *
+     * @param map
+     * @return
+     */
+    public void multiSet(Map<String, Object> map) {
+        redisTemplate.opsForValue().multiSet(map);
+    }
+
     /**
      * 根据正则key获取value列表
      *
@@ -263,16 +273,6 @@ public class RedisUtil {
         redisTemplate.opsForValue().set(key, value);
     }
 
-    /**
-     * 批量获取
-     *
-     * @param keys
-     * @return
-     */
-    public <T> List<T> multiGet(Collection<String> keys) {
-        return redisTemplate.opsForValue().multiGet(keys);
-    }
-
     /**
      * 将值 value 关联到 key ,并将 key 的过期时间设为 timeout
      *

+ 18 - 0
src/main/java/com/diagbot/vo/PushNewVO.java

@@ -0,0 +1,18 @@
+package com.diagbot.vo;
+
+import lombok.Data;
+
+/**
+ * @Description:基础推理入参
+ * @Author:zhoutg
+ * @time: 2020/7/29 15:34
+ */
+@Data
+public class PushNewVO {
+    private String hospitalType = "0"; // 医院类型, 0:全科,1:妇幼,2:精神
+    private Double age; // 年龄
+    private Integer sex; // 性别
+    private String chief; // 主诉
+    private String present; // 现病史
+    private Integer num = 10; // 疾病个数
+}

+ 2 - 2
src/main/java/com/diagbot/vo/ReverseVO.java

@@ -12,8 +12,8 @@ import java.util.List;
 @Data
 public class ReverseVO {
     private String libName; // 标准词名称
-    private String libType; // 标准词类型
-    private List<Long> relationType; // 关联类型
+    private Integer libType; // 标准词类型
+    private List<Integer> relationType; // 关联类型
     private Integer sexType;
     private Double age;
 }

+ 8 - 0
src/main/java/com/diagbot/web/TestController.java

@@ -2,6 +2,7 @@ package com.diagbot.web;
 
 import com.diagbot.dto.DiagnoseDTO;
 import com.diagbot.dto.PushDTO;
+import com.diagbot.dto.PushNewDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.StandConvertCrfBatchDTO;
 import com.diagbot.dto.StandConvertCrfDTO;
@@ -9,6 +10,7 @@ import com.diagbot.facade.KlDiagnoseFacade;
 import com.diagbot.facade.PushFacade;
 import com.diagbot.facade.TestFacade;
 import com.diagbot.vo.DiagnoseVO;
+import com.diagbot.vo.PushNewVO;
 import com.diagbot.vo.PushVO;
 import com.diagbot.vo.StandConvertCrfVO;
 import com.diagbot.vo.TestAllVO;
@@ -187,5 +189,11 @@ public class TestController {
     public RespDTO<PushDTO> testDiagnose(@RequestBody PushVO pushVO) {
         return RespDTO.onSuc(pushFacade.pushFac(pushVO));
     }
+
+    @ApiOperation(value = "大数据推送接口测试[zhoutg]", notes = "")
+    @PostMapping("/testPush")
+    public RespDTO<PushNewDTO> testPush(@RequestBody PushNewVO pushNewVO) {
+        return RespDTO.onSuc(pushFacade.testPushFac(pushNewVO));
+    }
 }
 

+ 4 - 0
src/main/resources/application-dev.yml

@@ -177,4 +177,8 @@ StandConvertNew:
 IcssPush:
   url: http://192.168.2.234:5008
 
+# 新版推送
+PushNew:
+  url: http://192.168.3.150:9210
+
 debugFlag: true

+ 3 - 3
src/main/resources/application-local.yml

@@ -177,8 +177,8 @@ StandConvertNew:
 IcssPush:
   url: http://192.168.2.234:5008
 
-Similarity:
-  url: http://192.168.2.234:12480
-
+# 新版推送
+PushNew:
+  url: http://192.168.3.150:9210
 
 debugFlag: true

+ 4 - 0
src/main/resources/application-pre.yml

@@ -177,4 +177,8 @@ StandConvertNew:
 IcssPush:
   url: http://192.168.2.186:5008
 
+# 新版推送
+PushNew:
+  url: http://192.168.3.150:9210
+
 debugFlag: true

+ 4 - 0
src/main/resources/application-pro.yml

@@ -177,4 +177,8 @@ StandConvertNew:
 IcssPush:
   url: http://192.168.2.123:5008
 
+# 新版推送
+PushNew:
+  url: http://192.168.3.150:9210
+
 debugFlag: true

+ 4 - 0
src/main/resources/application-test.yml

@@ -177,4 +177,8 @@ StandConvertNew:
 IcssPush:
   url: http://192.168.2.241:5008
 
+# 新版推送
+PushNew:
+  url: http://192.168.3.150:9210
+
 debugFlag: true

+ 4 - 3
src/main/resources/mapper/ConceptInfoMapper.xml

@@ -28,7 +28,8 @@
         d.id sonId,
         d.lib_type sonType,
         d.lib_name sonName,
-        c.order_no
+        c.order_no,
+        b.relation_id
         FROM
         kl_concept a,
         kl_relation b,
@@ -61,12 +62,12 @@
             and e.sex_type in (3, #{sexType})
         </if>
         <if test="age != null and age != ''">
-            <![CDATA[ and ((e.age_begin <= #{age} and e.age_end >= #{age})
+            <![CDATA[ and ((e.min_age <= #{age} and e.max_age >= #{age})
                       OR e.min_age IS NULL
                       OR e.max_age IS NULL)]]>
         </if>
         ORDER BY
-        t.sonType,
+        t.relation_id,
         t.order_no
     </select>