Browse Source

代码优化

gaodm 6 years ago
parent
commit
a9adb39942

+ 2 - 1
aipt-service/src/main/java/com/diagbot/dto/ConceptIntroduceDTO.java

@@ -1,5 +1,6 @@
 package com.diagbot.dto;
 
+import com.diagbot.util.ListUtil;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -13,5 +14,5 @@ import java.util.List;
 @Getter
 @Setter
 public class ConceptIntroduceDTO extends ConceptBaseDTO{
-    private List<ConceptDetailDTO> details;
+    private List<ConceptDetailDTO> details = ListUtil.newArrayList();
 }

+ 32 - 32
aipt-service/src/main/java/com/diagbot/facade/ConceptDetailFacade.java

@@ -81,38 +81,38 @@ public class ConceptDetailFacade extends ConceptDetailServiceImpl {
         return conceptIntroduceDTO;
     }
 
-    /**
-     * 获取静态知识明细
-     *
-     * @param conceptIntroduceVO
-     * @return
-     */
-    public List<ConceptDetail> getConceptDetailList(ConceptIntroduceVO conceptIntroduceVO) {
-        conceptIntroduceVO.setLibType(ParamConvertUtil.conceptConvert2Lib(conceptIntroduceVO.getType()));
-        //验证存在并且获取概念基本信息
-        Concept concept = conceptFacade.exist(conceptIntroduceVO);
-
-        //获取概念提示信息
-        QueryWrapper<ConceptDetail> conceptDetailQueryWrapper = new QueryWrapper<>();
-        conceptDetailQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
-                .eq("concept_id", concept.getId())
-                .orderByAsc("order_no");
-        if (conceptIntroduceVO.getPosition() == null) {
-            if (conceptIntroduceVO.getLibType().equals(LexiconTypeEnum.DRUGS.getKey())) {
-                conceptIntroduceVO.setPosition(PositionTypeEnum.T5.getKey());
-            } else if (conceptIntroduceVO.getLibType().equals(LexiconTypeEnum.SIDE_EFFECTS.getKey())) {
-                conceptIntroduceVO.setPosition(PositionTypeEnum.T6.getKey());
-            } else {
-                conceptIntroduceVO.setPosition(PositionTypeEnum.T2.getKey());
-            }
-        }
-        conceptDetailQueryWrapper.apply("find_in_set({0},position)", conceptIntroduceVO.getPosition());
-        if (ListUtil.isNotEmpty(conceptIntroduceVO.getTitles())) {
-            conceptDetailQueryWrapper.in("title", conceptIntroduceVO.getTitles());
-        }
-        List<ConceptDetail> conceptDetailList = this.list(conceptDetailQueryWrapper);
-        return conceptDetailList;
-    }
+//    /**
+//     * 获取静态知识明细
+//     *
+//     * @param conceptIntroduceVO
+//     * @return
+//     */
+//    public List<ConceptDetail> getConceptDetailList(ConceptIntroduceVO conceptIntroduceVO) {
+//        conceptIntroduceVO.setLibType(ParamConvertUtil.conceptConvert2Lib(conceptIntroduceVO.getType()));
+//        //验证存在并且获取概念基本信息
+//        Concept concept = conceptFacade.exist(conceptIntroduceVO);
+//
+//        //获取概念提示信息
+//        QueryWrapper<ConceptDetail> conceptDetailQueryWrapper = new QueryWrapper<>();
+//        conceptDetailQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+//                .eq("concept_id", concept.getId())
+//                .orderByAsc("order_no");
+//        if (conceptIntroduceVO.getPosition() == null) {
+//            if (conceptIntroduceVO.getLibType().equals(LexiconTypeEnum.DRUGS.getKey())) {
+//                conceptIntroduceVO.setPosition(PositionTypeEnum.T5.getKey());
+//            } else if (conceptIntroduceVO.getLibType().equals(LexiconTypeEnum.SIDE_EFFECTS.getKey())) {
+//                conceptIntroduceVO.setPosition(PositionTypeEnum.T6.getKey());
+//            } else {
+//                conceptIntroduceVO.setPosition(PositionTypeEnum.T2.getKey());
+//            }
+//        }
+//        conceptDetailQueryWrapper.apply("find_in_set({0},position)", conceptIntroduceVO.getPosition());
+//        if (ListUtil.isNotEmpty(conceptIntroduceVO.getTitles())) {
+//            conceptDetailQueryWrapper.in("title", conceptIntroduceVO.getTitles());
+//        }
+//        List<ConceptDetail> conceptDetailList = this.list(conceptDetailQueryWrapper);
+//        return conceptDetailList;
+//    }
 
     /**
      * 是否存在提示信息

+ 48 - 33
aipt-service/src/main/java/com/diagbot/facade/TreatmentFacade.java

@@ -1,23 +1,20 @@
 package com.diagbot.facade;
 
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.client.bean.AdverseReaction;
 import com.diagbot.client.bean.Medicition;
 import com.diagbot.client.bean.MedicitionClass;
-import com.diagbot.dto.ConceptDetailDTO;
+import com.diagbot.dto.ConceptIntroduceDTO;
 import com.diagbot.dto.ConceptRes;
 import com.diagbot.entity.Concept;
-import com.diagbot.entity.ConceptDetail;
 import com.diagbot.entity.wrapper.ConceptWrapper;
 import com.diagbot.enums.ConceptTypeEnum;
 import com.diagbot.enums.DisTypeEnum;
-import com.diagbot.enums.PositionTypeEnum;
 import com.diagbot.enums.LexiconRSTypeEnum;
 import com.diagbot.enums.LexiconTypeEnum;
+import com.diagbot.enums.PositionTypeEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
-import com.diagbot.util.BeanUtil;
 import com.diagbot.util.EntityUtil;
 import com.diagbot.util.FastJsonUtils;
 import com.diagbot.util.ListUtil;
@@ -72,40 +69,47 @@ public class TreatmentFacade {
         conceptIntroduceVO.setLibType(LexiconTypeEnum.DIAGNOSIS.getKey());
         conceptIntroduceVO.setPosition(PositionTypeEnum.T3.getKey());
         conceptIntroduceVO.setType(ConceptTypeEnum.Disease.getKey());
-        List<ConceptDetail> commonTreatmentDetailList = conceptDetailFacade.getConceptDetailList(conceptIntroduceVO);
-        if (ListUtil.isNotEmpty(commonTreatmentDetailList)) {
-            ConceptDetailDTO commonDetailDTO = new ConceptDetailDTO();
-            BeanUtil.copyProperties(commonTreatmentDetailList.get(0), commonDetailDTO);
-            retMap.put("commonTreatment", commonDetailDTO);
+        ConceptIntroduceDTO commonTreatment
+                = conceptDetailFacade.getConceptDetail(conceptIntroduceVO);
+        if (ListUtil.isNotEmpty(commonTreatment.getDetails())) {
+            retMap.put("commonTreatment", commonTreatment.getDetails().get(0));
         } else {
             retMap.put("commonTreatment", null);
         }
 
         //手术治疗
         conceptIntroduceVO.setPosition(PositionTypeEnum.T4.getKey());
-        List<ConceptDetail> surgeryTreatmentDetailList = conceptDetailFacade.getConceptDetailList(conceptIntroduceVO);
-        if (ListUtil.isNotEmpty(surgeryTreatmentDetailList)) {
-            ConceptDetailDTO surgeryDetailDTO = new ConceptDetailDTO();
-            BeanUtil.copyProperties(surgeryTreatmentDetailList.get(0), surgeryDetailDTO);
-            retMap.put("surgeryTreatment", surgeryDetailDTO);
+        ConceptIntroduceDTO surgeryTreatment
+                = conceptDetailFacade.getConceptDetail(conceptIntroduceVO);
+        if (ListUtil.isNotEmpty(surgeryTreatment.getDetails())) {
+            retMap.put("surgeryTreatment", surgeryTreatment.getDetails().get(0));
         } else {
             retMap.put("surgeryTreatment", null);
         }
 
-
         //获取知识图谱治疗方案
         JSONObject treatmentJson = treatmentMap.get(diseaseName);
         if (treatmentJson == null || treatmentJson.isEmpty()) {
             return retMap;
         }
 
-        List<MedicitionClass> drugsList = FastJsonUtils.getJsonToListByKey(treatmentJson.toString(), "treatment", MedicitionClass.class);
-        List<String> cateBigNameList = drugsList.stream().map(drugs -> drugs.getBigdrugsName()).collect(Collectors.toList());
-        List<Concept> cateBigConceptList = conceptFacade.getListByNamesAndType(cateBigNameList, LexiconTypeEnum.DRUG_CATEGORY_BIG.getKey());
-        Map<String, Concept> cateBigConceptMap = EntityUtil.makeEntityMap(cateBigConceptList, "libName");
-        List<String> cateSmallNameList = drugsList.stream().map(drugs -> drugs.getSubdrugsName()).collect(Collectors.toList());
-        List<Concept> cateSmallConceptList = conceptFacade.getListByNamesAndType(cateSmallNameList, LexiconTypeEnum.DRUG_CATEGORY_SMALL.getKey());
-        Map<String, Concept> cateSmallConceptMap = EntityUtil.makeEntityMap(cateSmallConceptList, "libName");
+        List<MedicitionClass> drugsList
+                = FastJsonUtils.getJsonToListByKey(treatmentJson.toString(),
+                "treatment", MedicitionClass.class);
+        List<String> cateBigNameList
+                = drugsList.stream().map(drugs -> drugs.getBigdrugsName()).collect(Collectors.toList());
+        List<Concept> cateBigConceptList
+                = conceptFacade.getListByNamesAndType(cateBigNameList,
+                LexiconTypeEnum.DRUG_CATEGORY_BIG.getKey());
+        Map<String, Concept> cateBigConceptMap
+                = EntityUtil.makeEntityMap(cateBigConceptList, "libName");
+        List<String> cateSmallNameList
+                = drugsList.stream().map(drugs -> drugs.getSubdrugsName()).collect(Collectors.toList());
+        List<Concept> cateSmallConceptList
+                = conceptFacade.getListByNamesAndType(cateSmallNameList,
+                LexiconTypeEnum.DRUG_CATEGORY_SMALL.getKey());
+        Map<String, Concept> cateSmallConceptMap
+                = EntityUtil.makeEntityMap(cateSmallConceptList, "libName");
 
         for (MedicitionClass medicitionClass : drugsList) {
             Concept cateBigConcept = cateBigConceptMap.get(medicitionClass.getBigdrugsName());
@@ -130,17 +134,21 @@ public class TreatmentFacade {
                 }
             }
             LinkedList<Medicition> medicitionList = medicitionClass.getMedicitionsList();
-            List<String> drugNameList = medicitionList.stream().map(medicition -> medicition.getMedicitionName()).collect(Collectors.toList());
-            List<Concept> drugList = conceptFacade.getListByNamesAndType(drugNameList, LexiconTypeEnum.DRUGS.getKey());
+            List<String> drugNameList
+                    = medicitionList.stream().map(m -> m.getMedicitionName()).collect(Collectors.toList());
+            List<Concept> drugList
+                    = conceptFacade.getListByNamesAndType(drugNameList, LexiconTypeEnum.DRUGS.getKey());
             Map<String, Concept> drugMap = EntityUtil.makeEntityMap(drugList, "libName");
-            Map<String, Concept> drugDetailMap = conceptDetailFacade.existList(drugNameList, LexiconTypeEnum.DRUGS.getKey());
+            Map<String, Concept> drugDetailMap
+                    = conceptDetailFacade.existList(drugNameList, LexiconTypeEnum.DRUGS.getKey());
             for (Medicition medicition : medicitionList) {
                 Concept drugConcept = drugMap.get(medicition.getMedicitionName());
                 if (drugConcept != null) {
                     medicition.setConceptId(drugConcept.getId());
                 }
                 medicition.setLibType(ConceptTypeEnum.Drug.getKey());
-                if (drugDetailMap != null && drugDetailMap.containsKey(medicition.getMedicitionName())) {
+                if (drugDetailMap != null
+                        && drugDetailMap.containsKey(medicition.getMedicitionName())) {
                     medicition.setShowInfo("1");
                 } else {
                     medicition.setShowInfo("0");
@@ -172,18 +180,25 @@ public class TreatmentFacade {
                 //上次用药-icss层处理
                 retMap.put("drugHistory", null);
                 //不良反应
-                List<AdverseReaction> adverseReactionList = FastJsonUtils.getJsonToListByKey(treatmentJson.toString(), "adverseEvent", AdverseReaction.class);
-                List<String> adNameList = adverseReactionList.stream().map(adverseReaction -> adverseReaction.getName()).collect(Collectors.toList());
-                List<Concept> adConceptList = conceptFacade.getListByNamesAndType(adNameList, LexiconTypeEnum.SIDE_EFFECTS.getKey());
-                Map<String, Concept> adConceptMap = EntityUtil.makeEntityMap(adConceptList, "libName");
-                Map<String, Concept> adConceptDetailMap = conceptDetailFacade.existList(adNameList, LexiconTypeEnum.SIDE_EFFECTS.getKey());
+                List<AdverseReaction> adverseReactionList
+                        = FastJsonUtils.getJsonToListByKey(treatmentJson.toString(),
+                        "adverseEvent", AdverseReaction.class);
+                List<String> adNameList
+                        = adverseReactionList.stream().map(a -> a.getName()).collect(Collectors.toList());
+                List<Concept> adConceptList
+                        = conceptFacade.getListByNamesAndType(adNameList, LexiconTypeEnum.SIDE_EFFECTS.getKey());
+                Map<String, Concept> adConceptMap
+                        = EntityUtil.makeEntityMap(adConceptList, "libName");
+                Map<String, Concept> adConceptDetailMap
+                        = conceptDetailFacade.existList(adNameList, LexiconTypeEnum.SIDE_EFFECTS.getKey());
                 for (AdverseReaction adverseReaction : adverseReactionList) {
                     Concept adConcept = adConceptMap.get(adverseReaction.getName());
                     if (adConcept != null) {
                         adverseReaction.setConceptId(adConcept.getId());
                     }
                     adverseReaction.setLibType(ConceptTypeEnum.SIDE_EFFECTS.getKey());
-                    if (adConceptDetailMap != null && adConceptDetailMap.containsKey(adverseReaction.getName())) {
+                    if (adConceptDetailMap != null
+                            && adConceptDetailMap.containsKey(adverseReaction.getName())) {
                         adverseReaction.setShowInfo("1");
                     } else {
                         adverseReaction.setShowInfo("0");