Browse Source

开单合理项做成并发

gaodm 4 years ago
parent
commit
19053defb6

+ 91 - 0
src/main/java/com/diagbot/aggregate/BillNeoAggregate.java

@@ -0,0 +1,91 @@
+package com.diagbot.aggregate;
+
+import com.diagbot.dto.BillNeoDTO;
+import com.diagbot.facade.NeoFacade;
+import com.diagbot.util.ListUtil;
+import com.diagbot.vo.BillNeoVO;
+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.ArrayList;
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/10/22 9:24
+ */
+@Component
+@Slf4j
+public class BillNeoAggregate {
+    @Autowired
+    private NeoFacade neoFacade;
+
+    @DataProvider("getBillNeo")
+    public List<BillNeoDTO> getBillNeo(
+            @InvokeParameter("billNeoVO") BillNeoVO billNeoVO,
+            @DataConsumer("getDrugBill") List<BillNeoDTO> drugBillList,
+            @DataConsumer("getPacsBill") List<BillNeoDTO> pacsBillList,
+            @DataConsumer("getLisDetailBill") List<BillNeoDTO> lisDetailBillList,
+            @DataConsumer("getLisBill") List<BillNeoDTO> lisBillList,
+            @DataConsumer("getOperationBill") List<BillNeoDTO> operationBillList,
+            @DataConsumer("getCombiOpBill") List<BillNeoDTO> combiOpBillList,
+            @DataConsumer("getTransfusionBill") List<BillNeoDTO> transfusionBillList) {
+        List<BillNeoDTO> billNeoDTOs = new ArrayList<>();
+
+        addbillNeoDTO(billNeoDTOs, drugBillList);
+        addbillNeoDTO(billNeoDTOs, pacsBillList);
+        addbillNeoDTO(billNeoDTOs, lisDetailBillList);
+        addbillNeoDTO(billNeoDTOs, lisBillList);
+        addbillNeoDTO(billNeoDTOs, operationBillList);
+        addbillNeoDTO(billNeoDTOs, combiOpBillList);
+        addbillNeoDTO(billNeoDTOs, transfusionBillList);
+
+        return billNeoDTOs;
+    }
+
+    private void addbillNeoDTO(List<BillNeoDTO> billNeoDTOs, List<BillNeoDTO> billNeoDTOList) {
+        if (ListUtil.isNotEmpty(billNeoDTOList)) {
+            billNeoDTOs.addAll(billNeoDTOList);
+        }
+    }
+
+    @DataProvider("getDrugBill")
+    public List<BillNeoDTO> getDrugBill(@InvokeParameter("billNeoVO") BillNeoVO billNeoVO) {
+        return neoFacade.getDrugBill(billNeoVO.getDrugList());
+    }
+
+    @DataProvider("getPacsBill")
+    public List<BillNeoDTO> getPacsBill(@InvokeParameter("billNeoVO") BillNeoVO billNeoVO) {
+        return neoFacade.getPacsBill(billNeoVO.getPacsList());
+    }
+
+    @DataProvider("getLisDetailBill")
+    public List<BillNeoDTO> getLisDetailBill(@InvokeParameter("billNeoVO") BillNeoVO billNeoVO) {
+        return neoFacade.getLisDetailBill(billNeoVO.getLisDetailList());
+    }
+
+    @DataProvider("getLisBill")
+    public List<BillNeoDTO> getLisBill(@InvokeParameter("billNeoVO") BillNeoVO billNeoVO) {
+        return neoFacade.getLisBill(billNeoVO.getLisList());
+    }
+
+    @DataProvider("getOperationBill")
+    public List<BillNeoDTO> getOperationBill(@InvokeParameter("billNeoVO") BillNeoVO billNeoVO) {
+        return neoFacade.getOperationBill(billNeoVO.getOperationList());
+    }
+
+    @DataProvider("getCombiOpBill")
+    public List<BillNeoDTO> getCombiOpBill(@InvokeParameter("billNeoVO") BillNeoVO billNeoVO) {
+        return neoFacade.getCombiOpBill(billNeoVO.getCombiopList());
+    }
+
+    @DataProvider("getTransfusionBill")
+    public List<BillNeoDTO> getTransfusionBill(@InvokeParameter("billNeoVO") BillNeoVO billNeoVO) {
+        return neoFacade.getTransfusionBill(billNeoVO.getTransfusionList());
+    }
+}

+ 89 - 52
src/main/java/com/diagbot/facade/NeoFacade.java

@@ -5,7 +5,17 @@ import com.diagbot.biz.push.entity.Item;
 import com.diagbot.biz.push.entity.Lis;
 import com.diagbot.client.ChiefPresentSimilarityServiceClient;
 import com.diagbot.client.StandConvertServiceClient;
-import com.diagbot.dto.*;
+import com.diagbot.dto.BillNeoDTO;
+import com.diagbot.dto.CriticalNeoDTO;
+import com.diagbot.dto.HighRiskNeoDTO;
+import com.diagbot.dto.NeoPushDTO;
+import com.diagbot.dto.NodeNeoDTO;
+import com.diagbot.dto.OtherTipNeoDTO;
+import com.diagbot.dto.OtherTipPacsNeoDTO;
+import com.diagbot.dto.OtherTipTransfusionNeoDTO;
+import com.diagbot.dto.StandConvertCrfBatchDTO;
+import com.diagbot.dto.StandConvertCrfDTO;
+import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.entity.DiseaseInfo;
 import com.diagbot.entity.DiseaseProperty;
 import com.diagbot.entity.node.LisRemind;
@@ -21,11 +31,20 @@ import com.diagbot.util.ListUtil;
 import com.diagbot.util.NeoUtil;
 import com.diagbot.util.RedisUtil;
 import com.diagbot.util.StringUtil;
+import com.diagbot.vo.BillNeoVO;
+import com.diagbot.vo.CriticalNeoVO;
 import com.diagbot.vo.Drug;
-import com.diagbot.vo.*;
-import com.diagbot.vo.neoPushEntity.*;
+import com.diagbot.vo.NeoPushVO;
+import com.diagbot.vo.StandConvert;
+import com.diagbot.vo.StandConvertCrfVO;
+import com.diagbot.vo.neoPushEntity.ChiefPushVo;
+import com.diagbot.vo.neoPushEntity.Diag;
+import com.diagbot.vo.neoPushEntity.LisPushVo;
+import com.diagbot.vo.neoPushEntity.PacsPushVo;
+import com.diagbot.vo.neoPushEntity.PresentPushVo;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
+import io.github.lvyahui8.spring.facade.DataFacade;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
@@ -36,7 +55,13 @@ import org.springframework.stereotype.Component;
 
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -228,7 +253,6 @@ public class NeoFacade {
     }
 
 
-
     /**
      * 图谱反推的数据
      *
@@ -258,15 +282,15 @@ public class NeoFacade {
         List<String> presentDiags = Lists.newArrayList();
         PresentPushVo presentPushVo = pushVO.getPresentPushVo();
         ChiefPushVo chiefPushVo = pushVO.getChiefPushVo();
-        if(presentPushVo != null){
+        if (presentPushVo != null) {
             List<Diag> diags = presentPushVo.getDiags();
-            if(ListUtil.isNotEmpty(diags)){
+            if (ListUtil.isNotEmpty(diags)) {
                 presentDiags = diags.stream().map(x -> x.getName()).collect(Collectors.toList());
             }
         }
-        if(chiefPushVo != null){
+        if (chiefPushVo != null) {
             List<Diag> diags = chiefPushVo.getDiags();
-            if(ListUtil.isNotEmpty(diags) ){
+            if (ListUtil.isNotEmpty(diags)) {
                 List<String> collect = diags.stream().map(x -> x.getName()).collect(Collectors.toList());
                 presentDiags.retainAll(collect);
                 presentDiags.addAll(collect);
@@ -274,7 +298,7 @@ public class NeoFacade {
         }
         List<PD> pds = pushVO.getChiefPushVo().getPds();
         PD pd = null;
-        if(ListUtil.isNotEmpty(pds)){
+        if (ListUtil.isNotEmpty(pds)) {
             pd = pds.get(0);
         }
         List<String> pushDis = new ArrayList<>();
@@ -286,8 +310,8 @@ public class NeoFacade {
             lises = lisPushVo.getLises();
         }
 
-        pushDis = pushDisBySpecialLis(age, sex, pd, lises,presentDiags);
-        if(ListUtil.isNotEmpty(pushDis)){
+        pushDis = pushDisBySpecialLis(age, sex, pd, lises, presentDiags);
+        if (ListUtil.isNotEmpty(pushDis)) {
             return pushDis;
         }
 
@@ -299,28 +323,29 @@ public class NeoFacade {
         //辅检推出的疾病
         pushDisByPacs(pushVO, allDis);
         filterAndSort(pushDis, allDis, sex, age, pd);
-        pushDis = addDiagFromPresent(pushDis,presentDiags);
+        pushDis = addDiagFromPresent(pushDis, presentDiags);
 
         return pushDis;
     }
 
     /**
      * 化验特异性推送疾病
+     *
      * @param age
      * @param sex
      * @param
      * @param lises
      * @return
      */
-    private List<String> pushDisBySpecialLis(Double age, Integer sex, PD pd, List<Lis> lises,List<String> presentDiags) {
+    private List<String> pushDisBySpecialLis(Double age, Integer sex, PD pd, List<Lis> lises, List<String> presentDiags) {
         List<String> neoPushDTOS = new ArrayList<>();
         if (ListUtil.isNotEmpty(lises)) {
             List<String> lis_dis = lises.parallelStream()
                     .map(x -> nodeRepository.getDisByLis_Special(x.getName(), x.getUniqueName() + x.getResult()))
                     .flatMap(List::stream).collect(Collectors.toList());
             if (ListUtil.isNotEmpty(lis_dis)) {
-                filterAndSort(neoPushDTOS, lis_dis, sex, age,pd);
-                neoPushDTOS = addDiagFromPresent(neoPushDTOS,presentDiags);
+                filterAndSort(neoPushDTOS, lis_dis, sex, age, pd);
+                neoPushDTOS = addDiagFromPresent(neoPushDTOS, presentDiags);
             }
         }
         return neoPushDTOS;
@@ -328,39 +353,41 @@ public class NeoFacade {
 
     /**
      * 把现病史中的诊断添加到推送诊断中
+     *
      * @param lis_dis
      * @param presentDiags
      */
-    private  List<String> addDiagFromPresent(List<String> lis_dis,List<String> presentDiags){
-        List<String> lis_dis_new  = Lists.newArrayList();
-        if(ListUtil.isNotEmpty(lis_dis) && ListUtil.isNotEmpty(presentDiags)){
-            if(lis_dis.size()>=10){
-                for(int i =0; i< lis_dis.size(); i++){
-                    if(i == 10 - presentDiags.size()){
-                        for (String dis: presentDiags) {
-                            if(!lis_dis_new.contains(dis)){
+    private List<String> addDiagFromPresent(List<String> lis_dis, List<String> presentDiags) {
+        List<String> lis_dis_new = Lists.newArrayList();
+        if (ListUtil.isNotEmpty(lis_dis) && ListUtil.isNotEmpty(presentDiags)) {
+            if (lis_dis.size() >= 10) {
+                for (int i = 0; i < lis_dis.size(); i++) {
+                    if (i == 10 - presentDiags.size()) {
+                        for (String dis : presentDiags) {
+                            if (!lis_dis_new.contains(dis)) {
                                 lis_dis_new.add(dis);
                             }
                         }
                         lis_dis_new.add(lis_dis.get(i));
-                    }else {
+                    } else {
                         lis_dis_new.add(lis_dis.get(i));
                     }
                 }
-            }else {
+            } else {
                 lis_dis_new.addAll(lis_dis);
                 lis_dis_new.addAll(presentDiags);
             }
             lis_dis_new = lis_dis_new.stream().distinct().collect(Collectors.toList());
-        }else {
+        } else {
             lis_dis.addAll(presentDiags);
-            lis_dis_new =lis_dis;
+            lis_dis_new = lis_dis;
         }
         return lis_dis_new;
     }
 
     /**
      * 辅检推送疾病
+     *
      * @param pushVO
      * @param allDis
      */
@@ -378,6 +405,7 @@ public class NeoFacade {
 
     /**
      * 化验推送疾病
+     *
      * @param allDis
      * @param lises
      */
@@ -392,6 +420,7 @@ public class NeoFacade {
 
     /**
      * 症状和体征推送疾病
+     *
      * @param pushVO
      * @param allDis
      */
@@ -422,17 +451,17 @@ public class NeoFacade {
         List<Map<String, String>> diseases = null;
         Map<String, Double> dis_fbl = new HashMap<>();
         if (ListUtil.isNotEmpty(allDis)) {
-//            diseases = redisUtil.get(allDis);
+            //            diseases = redisUtil.get(allDis);
             diseases = redisUtil.geth(allDis);
-            allDis = diseases.stream().filter(x -> NeoUtil.matchBasic(x, gender_code, age) && NeoUtil.matchPds(x.get("name"),pd))
-//            allDis = diseases.stream().filter(x -> NeoUtil.matchBasic(x, gender_code, age))
+            allDis = diseases.stream().filter(x -> NeoUtil.matchBasic(x, gender_code, age) && NeoUtil.matchPds(x.get("name"), pd))
+                    //            allDis = diseases.stream().filter(x -> NeoUtil.matchBasic(x, gender_code, age))
                     .map(x -> x.get("name")).collect(Collectors.toList());
             diseases.forEach(x -> dis_fbl.put(x.get("name"), Double.parseDouble(x.get("fbl"))));
         }
 
         Map<Long, List<String>> numberDiseasesMap = disCountSort(allDis);
         //根据发病率排序
-//        Map<String, Double> disdistributionCache = self.getDisdistributionCache();
+        //        Map<String, Double> disdistributionCache = self.getDisdistributionCache();
         Map<Long, Map<String, Double>> disPack = new LinkedHashMap<>();
         numberDiseasesMap.forEach((x, y) -> {
             Map<String, Double> collect = y.stream()
@@ -534,28 +563,29 @@ public class NeoFacade {
 
     /**
      * 反推信息
+     *
      * @param dis
      * @return
      */
-    public NeoPushDTO reverseInfo(String dis){
+    public NeoPushDTO reverseInfo(String dis) {
         NeoPushDTO neoPushDTO = new NeoPushDTO();
         List<DiseaseInfo> diseaseInfo = nodeRepository.getDiseaseInfo(dis);
-        if(ListUtil.isNotEmpty(diseaseInfo)){
-            diseaseInfo.forEach(disIf ->{
+        if (ListUtil.isNotEmpty(diseaseInfo)) {
+            diseaseInfo.forEach(disIf -> {
                 String tp = disIf.getTp();
                 List<String> col = disIf.getCol();
-                switch (tp){
+                switch (tp) {
                     case "医保疾病名称相关症状":
-                        neoPushDTO.setSymptoms(col.stream().map(x ->NeoUtil.updatePushInfo(x)).collect(Collectors.toList()));
+                        neoPushDTO.setSymptoms(col.stream().map(x -> NeoUtil.updatePushInfo(x)).collect(Collectors.toList()));
                         break;
                     case "医保疾病名称相关化验套餐名称":
-                        neoPushDTO.setLis(col.stream().map(x ->NeoUtil.updatePushInfo(x)).collect(Collectors.toList()));
+                        neoPushDTO.setLis(col.stream().map(x -> NeoUtil.updatePushInfo(x)).collect(Collectors.toList()));
                         break;
                     case "医保疾病名称相关辅助检查名称":
-                        neoPushDTO.setPacs(col.stream().map(x ->NeoUtil.updatePushInfo(x)).collect(Collectors.toList()));
+                        neoPushDTO.setPacs(col.stream().map(x -> NeoUtil.updatePushInfo(x)).collect(Collectors.toList()));
                         break;
                     case "医保疾病名称相关体征":
-                        neoPushDTO.setVitals(col.stream().map(x ->NeoUtil.updatePushInfo(x)).collect(Collectors.toList()));
+                        neoPushDTO.setVitals(col.stream().map(x -> NeoUtil.updatePushInfo(x)).collect(Collectors.toList()));
                         break;
                     default:
                         break;
@@ -567,6 +597,7 @@ public class NeoFacade {
 
         return neoPushDTO;
     }
+
     /**
      * 处理开单合理性图谱数据
      *
@@ -574,19 +605,25 @@ public class NeoFacade {
      * @return
      */
     public List<BillNeoDTO> getBillNeo(BillNeoVO billNeoVO) {
-
         List<BillNeoDTO> billNeoDTOs = new ArrayList<>();
+//                try {
+//                    billNeoDTOs.addAll(getDrugBill(billNeoVO.getDrugList()));
+//                    billNeoDTOs.addAll(getPacsBill(billNeoVO.getPacsList()));
+//                    billNeoDTOs.addAll(getLisDetailBill(billNeoVO.getLisDetailList()));
+//                    billNeoDTOs.addAll(getLisBill(billNeoVO.getLisList()));
+//                    billNeoDTOs.addAll(getOperationBill(billNeoVO.getOperationList()));
+//                    billNeoDTOs.addAll(getCombiOpBill(billNeoVO.getCombiopList()));
+//                    billNeoDTOs.addAll(getTransfusionBill(billNeoVO.getTransfusionList()));
+//                } catch (Exception ex) {
+//                    ex.printStackTrace();
+//                }
 
         try {
-            billNeoDTOs.addAll(getDrugBill(billNeoVO.getDrugList()));
-            billNeoDTOs.addAll(getPacsBill(billNeoVO.getPacsList()));
-            billNeoDTOs.addAll(getLisDetailBill(billNeoVO.getLisDetailList()));
-            billNeoDTOs.addAll(getLisBill(billNeoVO.getLisList()));
-            billNeoDTOs.addAll(getOperationBill(billNeoVO.getOperationList()));
-            billNeoDTOs.addAll(getCombiOpBill(billNeoVO.getCombiopList()));
-            billNeoDTOs.addAll(getTransfusionBill(billNeoVO.getTransfusionList()));
-        } catch (Exception ex) {
-            ex.printStackTrace();
+            Map<String, Object> invokeParams = new HashMap<>();
+            invokeParams.put("billNeoVO", billNeoVO);
+            billNeoDTOs = DataFacade.get("getBillNeo", invokeParams, List.class);
+        } catch (Exception e) {
+            e.printStackTrace();
         }
 
         return billNeoDTOs;
@@ -845,7 +882,7 @@ public class NeoFacade {
      */
     public NeoPushDTO getDiagInfo(NeoPushVO neoPushVO) {
         NeoPushDTO pushDTO = new NeoPushDTO();
-//        YiBaoDiseaseNode icdDiseaseNode = new YiBaoDiseaseNode();
+        //        YiBaoDiseaseNode icdDiseaseNode = new YiBaoDiseaseNode();
         String term = neoPushVO.getDiagVo().getDiags().get(0).getName();
         /*List<YiBaoDiseaseName> yiBaoName = yiBaoDiseaseRepository.findByNameIs(term);
 
@@ -944,7 +981,7 @@ public class NeoFacade {
      * 类型,疾病: disease,症状: symptom,手术和操作:operation,药品: drug,实验室检查:lis,辅助检查:pacs, 辅助检查:vital"
      *
      * @param standConvert
-     * @return Map<String, Map < String, String>> -->Map<类型, Map<原始词, 标准词>>
+     * @return Map<String ,   Map   <   String ,   String>> -->Map<类型, Map<原始词, 标准词>>
      */
     public Map<String, Map<String, String>> standConvertCrf(StandConvert standConvert) {
         Map<String, Map<String, String>> map = new LinkedHashMap<>();