Browse Source

代码优化

zhaops 5 years ago
parent
commit
206ccc8094

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

@@ -118,12 +118,16 @@ public class ConceptDetailFacade extends ConceptDetailServiceImpl {
         Map<String, Map<Long, List<ConceptDetail>>> retMap = new LinkedHashMap<>();
         Map<Long, List<ConceptDetail>> retSubMap = new LinkedHashMap<>();
         if (ListUtil.isNotEmpty(conceptList)) {
-            List<Long> conceptIds = conceptList.stream().map(concept -> concept.getId()).collect(Collectors.toList());
+            List<Long> conceptIds = conceptList
+                    .stream()
+                    .map(concept -> concept.getId()).collect(Collectors.toList());
             QueryWrapper<ConceptDetail> conceptDetailQueryWrapper = new QueryWrapper<>();
-            conceptDetailQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).in("concept_id", conceptIds);
+            conceptDetailQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .in("concept_id", conceptIds);
             List<ConceptDetail> conceptDetailList = this.list(conceptDetailQueryWrapper);
             if (ListUtil.isNotEmpty(conceptDetailList)) {
-                Map<Long, List<ConceptDetail>> conceptDetailMap = EntityUtil.makeEntityListMap(conceptDetailList, "conceptId");
+                Map<Long, List<ConceptDetail>> conceptDetailMap
+                        = EntityUtil.makeEntityListMap(conceptDetailList, "conceptId");
                 for (Concept concept : conceptList) {
                     if (retMap.containsKey(concept.getLibName())) {
                         retSubMap = retMap.get(concept.getLibName());
@@ -131,7 +135,8 @@ public class ConceptDetailFacade extends ConceptDetailServiceImpl {
                     if (retSubMap == null) {
                         retSubMap = new LinkedHashMap<>();
                     }
-                    if (conceptDetailMap.containsKey(concept.getId()) && ListUtil.isNotEmpty(conceptDetailMap.get(concept.getId()))) {
+                    if (conceptDetailMap.containsKey(concept.getId())
+                            && ListUtil.isNotEmpty(conceptDetailMap.get(concept.getId()))) {
                         retSubMap.put(concept.getLibType(), conceptDetailMap.get(concept.getId()));
                         retMap.put(concept.getLibName(), retSubMap);
                     }
@@ -153,10 +158,15 @@ public class ConceptDetailFacade extends ConceptDetailServiceImpl {
                 .in("concept_id", existListByConceptIdsVO.getConceptIds());
         List<ConceptDetail> conceptDetailList = this.list(conceptDetailQueryWrapper);
         if (ListUtil.isNotEmpty(conceptDetailList)) {
-            List<Long> retConceptIds = conceptDetailList.stream().map(conceptDetail -> conceptDetail.getConceptId()).distinct().collect(Collectors.toList());
+            List<Long> retConceptIds = conceptDetailList
+                    .stream()
+                    .map(conceptDetail -> conceptDetail.getConceptId()).distinct().collect(Collectors.toList());
             return retConceptIds;
         } else {
             return null;
+
+
+
         }
     }
 }

+ 8 - 5
aipt-service/src/main/java/com/diagbot/facade/FeatureFacade.java

@@ -7,8 +7,6 @@ import com.diagbot.exception.CommonException;
 import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.ParamConvertUtil;
-import com.diagbot.vo.ConceptBaseVO;
-import io.swagger.models.auth.In;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -41,11 +39,16 @@ public class FeatureFacade {
             throw new CommonException(CommonErrorCode.NOT_EXISTS, "未提取到特征词");
         }
 
-        Map<Integer, List<FeatureConceptDTO>> symptomMap = EntityUtil.makeEntityListMap(symptomFeatureList, "libType");
+        Map<Integer, List<FeatureConceptDTO>> symptomMap
+                = EntityUtil.makeEntityListMap(symptomFeatureList, "libType");
         Map<Integer, Map<String, Long>> map = new LinkedHashMap<>();
         for (Map.Entry<Integer, List<FeatureConceptDTO>> entry : symptomMap.entrySet()) {
-            List<Concept> concepts = conceptFacade.getListByNamesAndType(entry.getValue().stream().map(i -> i.getName()).collect(Collectors.toList()), entry.getKey());
-            Map<String, Long> conceptMap = EntityUtil.makeMapWithKeyValue(concepts, "libName", "id");
+            List<Concept> concepts
+                    = conceptFacade.getListByNamesAndType(entry.getValue()
+                    .stream()
+                    .map(i -> i.getName()).collect(Collectors.toList()), entry.getKey());
+            Map<String, Long> conceptMap
+                    = EntityUtil.makeMapWithKeyValue(concepts, "libName", "id");
             map.put(entry.getKey(), conceptMap);
         }
 

+ 4 - 6
aipt-service/src/main/java/com/diagbot/facade/LisMappingFacade.java

@@ -1,15 +1,11 @@
 package com.diagbot.facade;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.diagbot.entity.LisMapping;
 import com.diagbot.entity.wrapper.LisMappingWrapper;
-import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.service.impl.LisMappingServiceImpl;
 import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.StringUtil;
 import com.diagbot.vo.GetLisMappingVO;
-import com.google.common.collect.Lists;
 import org.springframework.stereotype.Component;
 
 import java.util.LinkedHashMap;
@@ -35,10 +31,12 @@ public class LisMappingFacade  extends LisMappingServiceImpl {
         lisMappingWrapper.setMealName(mealName);
         List<LisMappingWrapper> lisMappingWrapperList = this.getLisMappingByName(lisMappingWrapper);
 
-        Map<String, List<LisMappingWrapper>> lisMappingMap = EntityUtil.makeEntityListMap(lisMappingWrapperList, "mealName");
+        Map<String, List<LisMappingWrapper>> lisMappingMap
+                = EntityUtil.makeEntityListMap(lisMappingWrapperList, "mealName");
         for (Map.Entry<String, List<LisMappingWrapper>> entry : lisMappingMap.entrySet()) {
             if (entry.getValue().size() > 0) {
-                retMap.put(entry.getKey(), EntityUtil.makeMapWithKeyValue(entry.getValue(), "itemName", "uniqueName"));
+                retMap.put(entry.getKey(),
+                        EntityUtil.makeMapWithKeyValue(entry.getValue(), "itemName", "uniqueName"));
             } else {
                 retMap.put(entry.getKey(), null);
             }

+ 34 - 13
aipt-service/src/main/java/com/diagbot/facade/PushFacade.java

@@ -115,7 +115,9 @@ public class PushFacade {
         if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Feature_Type_Symptom.getKey()))) {
             List<FeatureRate> symptom = data.getSymptom();
             if (ListUtil.isNotEmpty(symptom)) {
-                List<String> nameList = symptom.stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
+                List<String> nameList = symptom
+                        .stream()
+                        .map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
                 if (ListUtil.isNotEmpty(nameList)) {
                     pushDTO.setSymptom(getConceptDTOList(nameList, LexiconTypeEnum.SYMPTOM.getKey()));
                 }
@@ -125,7 +127,9 @@ public class PushFacade {
         if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Feature_Type_Vital_Result.getKey()))) {
             List<FeatureRate> vital = data.getVitals();
             if (ListUtil.isNotEmpty(vital)) {
-                List<String> nameList = vital.stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
+                List<String> nameList = vital
+                        .stream()
+                        .map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
                 if (ListUtil.isNotEmpty(nameList)) {
                     pushDTO.setVital(getConceptDTOList(nameList, LexiconTypeEnum.VITAL_RESULT.getKey()));
                 }
@@ -135,7 +139,9 @@ public class PushFacade {
         if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Feature_Type_Vital_Index.getKey()))) {
             List<FeatureRate> vital = data.getVitals();
             if (ListUtil.isNotEmpty(vital)) {
-                List<String> nameList = vital.stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
+                List<String> nameList = vital
+                        .stream()
+                        .map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
                 if (ListUtil.isNotEmpty(nameList)) {
                     pushDTO.setVital(getConceptDTOList(nameList, LexiconTypeEnum.VITAL_INDEX.getKey()));
                 }
@@ -146,7 +152,9 @@ public class PushFacade {
         if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Feature_Type_Lis.getKey()))) {
             List<FeatureRate> lis = data.getLabs();
             if (ListUtil.isNotEmpty(lis)) {
-                List<String> nameList = lis.stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
+                List<String> nameList = lis
+                        .stream()
+                        .map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
                 if (ListUtil.isNotEmpty(nameList)) {
                     List<ConceptPushDTO> lisDTO = getConceptDTOList(nameList, LexiconTypeEnum.LIS_PACKAGE.getKey());
                     if (isConnect) {
@@ -161,7 +169,9 @@ public class PushFacade {
         if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Feature_Type_Pacs.getKey()))) {
             List<FeatureRate> pacs = data.getPacs();
             if (ListUtil.isNotEmpty(pacs)) {
-                List<String> nameList = pacs.stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
+                List<String> nameList = pacs
+                        .stream()
+                        .map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
                 if (ListUtil.isNotEmpty(nameList)) {
                     List<ConceptPushDTO> pacsDTO = getConceptDTOList(nameList, LexiconTypeEnum.PACS_ITEMS.getKey());
                     if (isConnect) {
@@ -192,9 +202,12 @@ public class PushFacade {
                     }
                 }
                 for (Map.Entry<String, List<FeatureRate>> entry : disFeatureMap.entrySet()) {
-                    List<String> nameListByDisClass = entry.getValue().stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
+                    List<String> nameListByDisClass = entry.getValue()
+                            .stream()
+                            .map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
                     if (ListUtil.isNotEmpty(nameListByDisClass)) {
-                        List<ConceptPushDTO> disDTO = getConceptDTOList(nameListByDisClass, LexiconTypeEnum.DIAGNOSIS.getKey());
+                        List<ConceptPushDTO> disDTO
+                                = getConceptDTOList(nameListByDisClass, LexiconTypeEnum.DIAGNOSIS.getKey());
                         if (isConnect) {
                             disDTO = addClientName(disDTO, searchVo.getHosCode(), ConceptTypeEnum.Disease.getKey());
                         }
@@ -290,7 +303,8 @@ public class PushFacade {
         if (StringUtil.isBlank(searchVo.getDiseaseName())) {
             throw new CommonException(CommonErrorCode.PARAM_ERROR, "请输入需获取治疗方案的诊断名称");
         }
-        Map<String, Object> treatmentMap = treatmentFacade.getTreatment(treat, searchVo.getDiseaseName(), searchVo.getDisType());
+        Map<String, Object> treatmentMap
+                = treatmentFacade.getTreatment(treat, searchVo.getDiseaseName(), searchVo.getDisType());
         return treatmentMap;
     }
 
@@ -367,11 +381,14 @@ public class PushFacade {
     public List<LisResult> addUniqueName(List<LisResult> lisResults, String hosCode) {
         //化验项转公表内容,参数处理
         if (ListUtil.isNotEmpty(lisResults)) {
-            List<String> mealNameList = lisResults.stream().map(lisResult -> lisResult.getName()).collect(Collectors.toList());
+            List<String> mealNameList = lisResults
+                    .stream()
+                    .map(lisResult -> lisResult.getName()).collect(Collectors.toList());
             LisConfigVO lisConfigVO = new LisConfigVO();
             lisConfigVO.setHosCode(hosCode);
             lisConfigVO.setMealNameList(mealNameList);
-            RespDTO<Map<String, Map<String, String>>> lisConfigRes = tranServiceClient.getLisConfigByMealNameAndHosCode(lisConfigVO);
+            RespDTO<Map<String, Map<String, String>>> lisConfigRes
+                    = tranServiceClient.getLisConfigByMealNameAndHosCode(lisConfigVO);
             Map<String, Map<String, String>> lisConfigMap = new LinkedHashMap<>();
             if (RespDTOUtil.respIsOK(lisConfigRes)) {
                 lisConfigMap = lisConfigRes.data;
@@ -404,10 +421,13 @@ public class PushFacade {
         hosCodeVO.setHosCode(hosCode);
         LisConfigVO lisConfigVO = new LisConfigVO();
         lisConfigVO.setHosCode(hosCode);
-        List<String> uniqueNameList = concepts.stream().map(concept -> concept.getName()).collect(Collectors.toList());
+        List<String> uniqueNameList = concepts
+                .stream()
+                .map(concept -> concept.getName()).collect(Collectors.toList());
         lisConfigVO.setUniqueNameList(uniqueNameList);
         if (type.equals(ConceptTypeEnum.Lis.getKey())) {
-            RespDTO<Map<String, List<String>>> lisRes = tranServiceClient.getLisConfigByUniqueNameAndHosCode(lisConfigVO);
+            RespDTO<Map<String, List<String>>> lisRes
+                    = tranServiceClient.getLisConfigByUniqueNameAndHosCode(lisConfigVO);
             if (RespDTOUtil.respIsOK(lisRes)) {
                 Map<String, List<String>> lisMappingByUniqueName = lisRes.data;
                 for (ConceptPushDTO concept : concepts) {
@@ -418,7 +438,8 @@ public class PushFacade {
                 }
             }
         } else if (type.equals(ConceptTypeEnum.Pacs.getKey())) {
-            RespDTO<Map<String, List<String>>> pacsRes = tranServiceClient.getPacsConfigByUniqueNameAndHosCode(hosCodeVO);
+            RespDTO<Map<String, List<String>>> pacsRes
+                    = tranServiceClient.getPacsConfigByUniqueNameAndHosCode(hosCodeVO);
             if (RespDTOUtil.respIsOK(pacsRes)) {
                 Map<String, List<String>> pacsConfigMapByUniqueName = pacsRes.data;
                 for (ConceptPushDTO concept : concepts) {

+ 67 - 21
aipt-service/src/main/java/com/diagbot/facade/TreatmentFacade.java

@@ -73,15 +73,21 @@ public class TreatmentFacade {
             return retMap;
         }
         //推荐药物
-        List<MedicitionClass> drugsList = FastJsonUtils.getJsonToListByKey(treatmentJson.toString(), "treatment", MedicitionClass.class);
+        List<MedicitionClass> drugsList
+                = FastJsonUtils.getJsonToListByKey(treatmentJson.toString(), "treatment", MedicitionClass.class);
         //不良反应
-        List<AdverseReaction> adverseReactionList = FastJsonUtils.getJsonToListByKey(treatmentJson.toString(), "adverseEvent", AdverseReaction.class);
+        List<AdverseReaction> adverseReactionList
+                = FastJsonUtils.getJsonToListByKey(treatmentJson.toString(), "adverseEvent", AdverseReaction.class);
         if (ListUtil.isNotEmpty(drugsList)) {
             //药品大类
-            List<String> cateBigNameList = drugsList.stream().map(drugs -> drugs.getBigdrugsName()).collect(Collectors.toList());
+            List<String> cateBigNameList = drugsList
+                    .stream()
+                    .map(drugs -> drugs.getBigdrugsName()).collect(Collectors.toList());
             conceptNameList.addAll(cateBigNameList);
             //药品小类
-            List<String> cateSmallNameList = drugsList.stream().map(drugs -> drugs.getSubdrugsName()).collect(Collectors.toList());
+            List<String> cateSmallNameList = drugsList
+                    .stream()
+                    .map(drugs -> drugs.getSubdrugsName()).collect(Collectors.toList());
             conceptNameList.addAll(cateSmallNameList);
             //药品
             List<Medicition> medicitionTotalList = Lists.newLinkedList();
@@ -90,11 +96,15 @@ public class TreatmentFacade {
                     medicitionTotalList.addAll(medicitionClass.getMedicitionsList());
                 }
             }
-            List<String> drugNameList = medicitionTotalList.stream().map(m -> m.getMedicitionName()).collect(Collectors.toList());
+            List<String> drugNameList = medicitionTotalList
+                    .stream()
+                    .map(m -> m.getMedicitionName()).collect(Collectors.toList());
             conceptNameList.addAll(drugNameList);
         }
         if (ListUtil.isNotEmpty(adverseReactionList)) {
-            List<String> adNameList = adverseReactionList.stream().map(a -> a.getName()).collect(Collectors.toList());
+            List<String> adNameList = adverseReactionList
+                    .stream()
+                    .map(a -> a.getName()).collect(Collectors.toList());
             conceptNameList.addAll(adNameList);
         }
         //概念
@@ -105,16 +115,22 @@ public class TreatmentFacade {
         Map<String, Map<Long, List<ConceptDetail>>> hasConDetailMap = conceptDetailFacade.hasConDetail(conceptList);
 
         //一般治疗&&手术治疗
-        if (hasConDetailMap != null && hasConDetailMap.get(diseaseName) != null && ListUtil.isNotEmpty(hasConDetailMap.get(diseaseName).get(Long.valueOf(LexiconTypeEnum.DIAGNOSIS.getKey())))) {
-            List<ConceptDetail> diseaseConDetailList = hasConDetailMap.get(diseaseName).get(Long.valueOf(LexiconTypeEnum.DIAGNOSIS.getKey()));
+        if (hasConDetailMap != null && hasConDetailMap.get(diseaseName) != null
+                && ListUtil.isNotEmpty(hasConDetailMap
+                .get(diseaseName)
+                .get(Long.valueOf(LexiconTypeEnum.DIAGNOSIS.getKey())))) {
+            List<ConceptDetail> diseaseConDetailList
+                    = hasConDetailMap.get(diseaseName).get(Long.valueOf(LexiconTypeEnum.DIAGNOSIS.getKey()));
             for (ConceptDetail conceptDetail : diseaseConDetailList) {
                 ConceptDetailDTO conceptDetailDTO = new ConceptDetailDTO();
                 List<String> positionList = Arrays.asList(conceptDetail.getPosition().split(",|,"));
-                if (positionList.contains(String.valueOf(PositionTypeEnum.T3.getKey())) && retMap.get("commonTreatment") == null) {
+                if (positionList.contains(String.valueOf(PositionTypeEnum.T3.getKey()))
+                        && retMap.get("commonTreatment") == null) {
                     BeanUtil.copyProperties(conceptDetail, conceptDetailDTO);
                     retMap.put("commonTreatment", conceptDetailDTO);
                 }
-                if (positionList.contains(String.valueOf(PositionTypeEnum.T4.getKey())) && retMap.get("surgeryTreatment") == null) {
+                if (positionList.contains(String.valueOf(PositionTypeEnum.T4.getKey()))
+                        && retMap.get("surgeryTreatment") == null) {
                     BeanUtil.copyProperties(conceptDetail, conceptDetailDTO);
                     retMap.put("surgeryTreatment", conceptDetailDTO);
                 }
@@ -126,11 +142,20 @@ public class TreatmentFacade {
 
         if (ListUtil.isNotEmpty(drugsList)) {
             for (MedicitionClass medicitionClass : drugsList) {
-                if (conceptMap != null && conceptMap.get(medicitionClass.getBigdrugsName()) != null && conceptMap.get(medicitionClass.getBigdrugsName()).containsKey(Long.valueOf(LexiconTypeEnum.DRUG_CATEGORY_BIG.getKey()))) {
-                    Concept cateBigConcept = conceptMap.get(medicitionClass.getBigdrugsName()).get(Long.valueOf(LexiconTypeEnum.DRUG_CATEGORY_BIG.getKey()));
+                if (conceptMap != null
+                        && conceptMap.get(medicitionClass.getBigdrugsName()) != null
+                        && conceptMap.get(medicitionClass
+                        .getBigdrugsName())
+                        .containsKey(Long.valueOf(LexiconTypeEnum.DRUG_CATEGORY_BIG.getKey()))) {
+                    Concept cateBigConcept = conceptMap
+                            .get(medicitionClass.getBigdrugsName())
+                            .get(Long.valueOf(LexiconTypeEnum.DRUG_CATEGORY_BIG.getKey()));
                     if (cateBigConcept != null) {
                         medicitionClass.setBigdrugsConceptId(cateBigConcept.getId());
-                        if (hasConDetailMap != null && hasConDetailMap.get(cateBigConcept.getLibName()) != null && hasConDetailMap.get(cateBigConcept.getLibName()).containsKey(Long.valueOf(LexiconTypeEnum.DRUG_CATEGORY_BIG.getKey()))) {
+                        if (hasConDetailMap != null
+                                && hasConDetailMap.get(cateBigConcept.getLibName()) != null
+                                && hasConDetailMap.get(cateBigConcept.getLibName())
+                                .containsKey(Long.valueOf(LexiconTypeEnum.DRUG_CATEGORY_BIG.getKey()))) {
                             medicitionClass.setShowInfo("1");
                         } else {
                             medicitionClass.setShowInfo("0");
@@ -139,8 +164,13 @@ public class TreatmentFacade {
                 }
                 medicitionClass.setBigdrgusLibType(LexiconTypeEnum.DRUG_CATEGORY_BIG.getKey());
                 medicitionClass.setBigdrugsType(ConceptTypeEnum.Drug_Category_Big.getKey());
-                if (conceptMap != null && conceptMap.get(medicitionClass.getSubdrugsName()) != null && conceptMap.get(medicitionClass.getSubdrugsName()).containsKey(Long.valueOf(LexiconTypeEnum.DRUG_CATEGORY_SMALL.getKey()))) {
-                    Concept cateSmallConcept = conceptMap.get(medicitionClass.getSubdrugsName()).get(Long.valueOf(LexiconTypeEnum.DRUG_CATEGORY_SMALL.getKey()));
+                if (conceptMap != null
+                        && conceptMap.get(medicitionClass.getSubdrugsName()) != null
+                        && conceptMap.get(medicitionClass.getSubdrugsName())
+                        .containsKey(Long.valueOf(LexiconTypeEnum.DRUG_CATEGORY_SMALL.getKey()))) {
+                    Concept cateSmallConcept = conceptMap
+                            .get(medicitionClass.getSubdrugsName())
+                            .get(Long.valueOf(LexiconTypeEnum.DRUG_CATEGORY_SMALL.getKey()));
                     if (cateSmallConcept != null) {
                         medicitionClass.setSubdrugsConceptId(cateSmallConcept.getId());
                     }
@@ -150,15 +180,23 @@ public class TreatmentFacade {
 
                 LinkedList<Medicition> medicitionList = medicitionClass.getMedicitionsList();
                 for (Medicition medicition : medicitionList) {
-                    if (conceptMap != null && conceptMap.get(medicition.getMedicitionName()) != null && conceptMap.get(medicition.getMedicitionName()).containsKey(Long.valueOf(LexiconTypeEnum.DRUGS.getKey()))) {
-                        Concept drugConcept = conceptMap.get(medicition.getMedicitionName()).get(Long.valueOf(LexiconTypeEnum.DRUGS.getKey()));
+                    if (conceptMap != null
+                            && conceptMap.get(medicition.getMedicitionName()) != null
+                            && conceptMap.get(medicition.getMedicitionName())
+                            .containsKey(Long.valueOf(LexiconTypeEnum.DRUGS.getKey()))) {
+                        Concept drugConcept = conceptMap
+                                .get(medicition.getMedicitionName())
+                                .get(Long.valueOf(LexiconTypeEnum.DRUGS.getKey()));
                         if (drugConcept != null) {
                             medicition.setConceptId(drugConcept.getId());
                         }
                     }
                     medicition.setLibType(LexiconTypeEnum.DRUGS.getKey());
                     medicition.setType(ConceptTypeEnum.Drug.getKey());
-                    if (hasConDetailMap != null && hasConDetailMap.get(medicition.getMedicitionName()) != null && hasConDetailMap.get(medicition.getMedicitionName()).containsKey(Long.valueOf(LexiconTypeEnum.DRUGS.getKey()))) {
+                    if (hasConDetailMap != null
+                            && hasConDetailMap.get(medicition.getMedicitionName()) != null
+                            && hasConDetailMap.get(medicition.getMedicitionName())
+                            .containsKey(Long.valueOf(LexiconTypeEnum.DRUGS.getKey()))) {
                         medicition.setShowInfo("1");
                     } else {
                         medicition.setShowInfo("0");
@@ -192,15 +230,23 @@ public class TreatmentFacade {
                 retMap.put("drugHistory", null);
                 //不良反应
                 for (AdverseReaction adverseReaction : adverseReactionList) {
-                    if (conceptMap != null && conceptMap.get(adverseReaction.getName()) != null && conceptMap.get(adverseReaction.getName()).containsKey(Long.valueOf(LexiconTypeEnum.SIDE_EFFECTS.getKey()))) {
-                        Concept adConcept = conceptMap.get(adverseReaction.getName()).get(Long.valueOf(LexiconTypeEnum.SIDE_EFFECTS.getKey()));
+                    if (conceptMap != null
+                            && conceptMap.get(adverseReaction.getName()) != null
+                            && conceptMap.get(adverseReaction.getName())
+                            .containsKey(Long.valueOf(LexiconTypeEnum.SIDE_EFFECTS.getKey()))) {
+                        Concept adConcept = conceptMap
+                                .get(adverseReaction.getName())
+                                .get(Long.valueOf(LexiconTypeEnum.SIDE_EFFECTS.getKey()));
                         if (adConcept != null) {
                             adverseReaction.setConceptId(adConcept.getId());
                         }
                     }
                     adverseReaction.setLibType(LexiconTypeEnum.SIDE_EFFECTS.getKey());
                     adverseReaction.setType(ConceptTypeEnum.SIDE_EFFECTS.getKey());
-                    if (hasConDetailMap != null && hasConDetailMap.get(adverseReaction.getName()) != null && hasConDetailMap.get(adverseReaction.getName()).containsKey(Long.valueOf(LexiconTypeEnum.SIDE_EFFECTS.getKey()))) {
+                    if (hasConDetailMap != null
+                            && hasConDetailMap.get(adverseReaction.getName()) != null
+                            && hasConDetailMap.get(adverseReaction.getName())
+                            .containsKey(Long.valueOf(LexiconTypeEnum.SIDE_EFFECTS.getKey()))) {
                         adverseReaction.setShowInfo("1");
                     } else {
                         adverseReaction.setShowInfo("0");

+ 23 - 19
diagbotman-service/src/main/java/com/diagbot/facade/ProductServiceFacade.java

@@ -191,26 +191,30 @@ public class ProductServiceFacade extends ProductServiceServiceImpl {
         queryWrapper.eq("product_id", productId).eq("is_deleted", IsDeleteEnum.N.getKey());
         List<ProductService> productServiceList = this.list(queryWrapper);
         Map<Long, ProductService> map = EntityUtil.makeEntityMap(productServiceList, "id");
-        //删除令牌
-        UpdateWrapper<ServiceToken> tokenUpdateWrapper = new UpdateWrapper<>();
-        tokenUpdateWrapper.in("product_service_id", map.keySet());
-        tokenUpdateWrapper.set("is_deleted", IsDeleteEnum.Y.getKey());
-        serviceTokenFacade.update(new ServiceToken(), tokenUpdateWrapper);
-
-        //删除产品服务端关联
-        UpdateWrapper<ProductService> productServiceUpdateWrapper = new UpdateWrapper<>();
-        productServiceUpdateWrapper.in("id", map.keySet());
-        productServiceUpdateWrapper.set("is_deleted", IsDeleteEnum.Y.getKey());
-        this.update(new ProductService(), productServiceUpdateWrapper);
-
+        if (map != null && map.size() > 0) {
+            //删除令牌
+            UpdateWrapper<ServiceToken> tokenUpdateWrapper = new UpdateWrapper<>();
+            tokenUpdateWrapper.in("product_service_id", map.keySet());
+            tokenUpdateWrapper.set("is_deleted", IsDeleteEnum.Y.getKey());
+            serviceTokenFacade.update(new ServiceToken(), tokenUpdateWrapper);
+
+            //删除产品服务端关联
+            UpdateWrapper<ProductService> productServiceUpdateWrapper = new UpdateWrapper<>();
+            productServiceUpdateWrapper.in("id", map.keySet());
+            productServiceUpdateWrapper.set("is_deleted", IsDeleteEnum.Y.getKey());
+            this.update(new ProductService(), productServiceUpdateWrapper);
+        }
         //删除系统自动生成的服务端
-        Map<Long, List<ProductService>> serviceMap = EntityUtil.makeEntityListMap(productServiceList, "serviceId");
-        UpdateWrapper<ServiceInfo> serviceInfoUpdateWrapper = new UpdateWrapper<>();
-        serviceInfoUpdateWrapper.in("id", serviceMap.keySet())
-                .eq("type", ServiceTypeEnum.Sys_Create.getKey())
-                .eq("is_deleted", IsDeleteEnum.N.getKey())
-                .set("is_deleted", IsDeleteEnum.Y.getKey());
-        serviceInfoFacade.update(new ServiceInfo(), serviceInfoUpdateWrapper);
+        Map<Long, List<ProductService>> serviceMap
+                = EntityUtil.makeEntityListMap(productServiceList, "serviceId");
+        if (serviceMap != null && serviceMap.size() > 0) {
+            UpdateWrapper<ServiceInfo> serviceInfoUpdateWrapper = new UpdateWrapper<>();
+            serviceInfoUpdateWrapper.in("id", serviceMap.keySet())
+                    .eq("type", ServiceTypeEnum.Sys_Create.getKey())
+                    .eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .set("is_deleted", IsDeleteEnum.Y.getKey());
+            serviceInfoFacade.update(new ServiceInfo(), serviceInfoUpdateWrapper);
+        }
         return true;
     }
 

+ 3 - 0
diagbotman-service/src/main/java/com/diagbot/facade/ServiceTokenFacade.java

@@ -169,6 +169,9 @@ public class ServiceTokenFacade extends ServiceTokenServiceImpl {
      * @return
      */
     public Boolean deleteByIds(Long[] ids) {
+        if (ids == null || ids.length == 0) {
+            return true;
+        }
         QueryWrapper<ServiceToken> queryWrapper = new QueryWrapper<>();
         queryWrapper.in("id", ids);
         List<ServiceToken> serviceTokenList = this.list(queryWrapper);

+ 5 - 2
icss-service/src/main/java/com/diagbot/facade/TreatmentFacade.java

@@ -110,14 +110,17 @@ public class TreatmentFacade {
                     continue;
                 }
                 QueryWrapper<InquiryDrug> inquiryDrugQueryWrapper = new QueryWrapper<>();
-                inquiryDrugQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).eq("inquiry_id", inquiryInfo.getId());
+                inquiryDrugQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                        .eq("inquiry_id", inquiryInfo.getId());
                 List<InquiryDrug> inquiryDrugList = inquiryDrugFacade.list(inquiryDrugQueryWrapper);
                 //当前病历没有开药
                 if (ListUtil.isEmpty(inquiryDrugList)) {
                     continue;
                 }
                 List<Medicition> medicitionList = Lists.newLinkedList();
-                List<Long> conceptIds = inquiryDrugList.stream().map(inquiryDrug -> inquiryDrug.getConceptId()).collect(Collectors.toList());
+                List<Long> conceptIds = inquiryDrugList
+                        .stream()
+                        .map(inquiryDrug -> inquiryDrug.getConceptId()).collect(Collectors.toList());
                 ExistListByConceptIdsVO existListByConceptIds = new ExistListByConceptIdsVO();
                 existListByConceptIds.setConceptIds(conceptIds);
                 RespDTO<List<Long>> res = aiptServiceClient.existListByConceptIds(existListByConceptIds);

+ 45 - 33
icssman-service/src/main/java/com/diagbot/facade/DeptVitalFacade.java

@@ -82,39 +82,43 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
             this.update(new DeptVital(), deptVitalUpdateWrapper);
         }
 
-        //查找标签是否存在
-        QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper<>();
-        List<Long> vitalIds = deptVitalVO.getDvDetailVOList().stream().map(deDetailVO -> deDetailVO.getVitalId()).collect(Collectors.toList());
-        questionInfoQueryWrapper.in("id", vitalIds).
-                eq("type", QuestionTypeEnum.Vital.getKey()).
-                eq("is_deleted", IsDeleteEnum.N.getKey());
-        List<QuestionInfo> questionInfoList = questionFacade.list(questionInfoQueryWrapper);
+        List<Long> vitalIds = deptVitalVO.getDvDetailVOList()
+                .stream()
+                .map(deDetailVO -> deDetailVO.getVitalId()).collect(Collectors.toList());
+        if (ListUtil.isNotEmpty(vitalIds)) {
+            //查找标签是否存在
+            QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper<>();
+            questionInfoQueryWrapper.in("id", vitalIds).
+                    eq("type", QuestionTypeEnum.Vital.getKey()).
+                    eq("is_deleted", IsDeleteEnum.N.getKey());
+            List<QuestionInfo> questionInfoList = questionFacade.list(questionInfoQueryWrapper);
 
-        Map<Long, QuestionInfo> questionInfoMap = EntityUtil.makeEntityMap(questionInfoList, "id");
-        for (Long vital : vitalIds) {
-            if (questionInfoMap.get(vital) == null) {
-                throw new CommonException(CommonErrorCode.NOT_EXISTS, "id=" + vital + "的查体标签不存在");
+            Map<Long, QuestionInfo> questionInfoMap = EntityUtil.makeEntityMap(questionInfoList, "id");
+            for (Long vital : vitalIds) {
+                if (questionInfoMap.get(vital) == null) {
+                    throw new CommonException(CommonErrorCode.NOT_EXISTS, "id=" + vital + "的查体标签不存在");
+                }
             }
-        }
 
-        //插入新模板
-        List<DeptVital> deptVitalList = Lists.newArrayList();
-        Date now = DateUtil.now();
-        String userId = UserUtils.getCurrentPrincipleID();
-        for (DVDetailVO dvDetailVO : deptVitalVO.getDvDetailVOList()) {
-            DeptVital deptVital = new DeptVital();
-            deptVital.setDeptId(deptVitalVO.getDeptId());
-            deptVital.setVitalId(dvDetailVO.getVitalId());
-            deptVital.setRemark(dvDetailVO.getRemark());
-            deptVital.setOrderNo(dvDetailVO.getOrderNo());
-            deptVital.setCreator(userId);
-            deptVital.setGmtCreate(now);
-            deptVital.setModifier(userId);
-            deptVital.setGmtModified(now);
-            deptVitalList.add(deptVital);
-        }
+            //插入新模板
+            List<DeptVital> deptVitalList = Lists.newArrayList();
+            Date now = DateUtil.now();
+            String userId = UserUtils.getCurrentPrincipleID();
+            for (DVDetailVO dvDetailVO : deptVitalVO.getDvDetailVOList()) {
+                DeptVital deptVital = new DeptVital();
+                deptVital.setDeptId(deptVitalVO.getDeptId());
+                deptVital.setVitalId(dvDetailVO.getVitalId());
+                deptVital.setRemark(dvDetailVO.getRemark());
+                deptVital.setOrderNo(dvDetailVO.getOrderNo());
+                deptVital.setCreator(userId);
+                deptVital.setGmtCreate(now);
+                deptVital.setModifier(userId);
+                deptVital.setGmtModified(now);
+                deptVitalList.add(deptVital);
+            }
 
-        deptVitalService.saveBatch(deptVitalList);
+            deptVitalService.saveBatch(deptVitalList);
+        }
         return true;
     }
 
@@ -194,11 +198,15 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
         IPage<DeptVitalDTO> page = this.getDeptVitalPage(deptVitalPageVO);
         List<DeptVitalDTO> deptVitalDTOList = page.getRecords();
         //操作人信息
-        List<String> userIds = deptVitalDTOList.stream().map(deptVitalDTO -> deptVitalDTO.getOperator()).collect(Collectors.toList());
+        List<String> userIds = deptVitalDTOList
+                .stream()
+                .map(deptVitalDTO -> deptVitalDTO.getOperator()).collect(Collectors.toList());
         RespDTO<Map<String, String>> data = userServiceClient.getUserInfoByIds(userIds);
         Map<String, String> userInfos = data.data;
         //科室信息
-        List<Long> deptIds = deptVitalDTOList.stream().map(deptVitalDTO -> deptVitalDTO.getDeptId()).collect(Collectors.toList());
+        List<Long> deptIds = deptVitalDTOList
+                .stream()
+                .map(deptVitalDTO -> deptVitalDTO.getDeptId()).collect(Collectors.toList());
         ConceptSearchVO conceptSearchVO = new ConceptSearchVO();
         conceptSearchVO.setConceptIds(deptIds);
         RespDTO<Map<Long, String>> deptMap = klmServiceClient.getConceptMap(conceptSearchVO);
@@ -253,7 +261,9 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
                 select("dept_id").
                 groupBy("dept_id");
         List<DeptVital> deptVitalList = this.list(deptVitalQueryWrapper);
-        List<Long> deptIds = deptVitalList.stream().map(deptVital -> deptVital.getDeptId()).collect(Collectors.toList());
+        List<Long> deptIds = deptVitalList
+                .stream()
+                .map(deptVital -> deptVital.getDeptId()).collect(Collectors.toList());
         return getDeptShortList(deptIds);
     }
 
@@ -307,7 +317,9 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
                 select("dept_id").
                 groupBy("dept_id");
         List<DeptVital> deptVitalList = this.list(deptVitalQueryWrapper);
-        List<Long> deptIds = deptVitalList.stream().map(deptVital -> deptVital.getDeptId()).collect(Collectors.toList());
+        List<Long> deptIds = deptVitalList
+                .stream()
+                .map(deptVital -> deptVital.getDeptId()).collect(Collectors.toList());
         return deptIds;
     }
 

+ 23 - 16
prec-service/src/main/java/com/diagbot/facade/PushFacade.java

@@ -78,22 +78,29 @@ public class PushFacade {
      * @return
      */
     public List<ConceptPushDTO> addQuestionId(List<ConceptPushDTO> concepts, Integer type) {
-        QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper<>();
-        List<String> nameList = concepts.stream().map(concept -> concept.getTagName()).collect(Collectors.toList());
-        questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).in("tag_name", nameList).eq("type", type);
-        List<QuestionInfo> questionInfoList = questionFacade.list(questionInfoQueryWrapper);
-        if (ListUtil.isNotEmpty(questionInfoList)) {
-            Map<String, QuestionInfo> questionInfoMap = EntityUtil.makeEntityMap(questionInfoList, "tagName");
-            for (ConceptPushDTO concept : concepts) {
-                concept.setType(1);
-                if (questionInfoMap.containsKey(concept.getName())) {
-                    QuestionInfo questionInfo = questionInfoMap.get(concept.getTagName());
-                    concept.setId(questionInfo.getId());
-                    concept.setName(questionInfo.getName());
-                    concept.setDescription(questionInfo.getDescription());
-                    if (StringUtil.isNotBlank(questionInfo.getExplains())) {
-                        concept.setHasExplain(1);
-                        concept.setExplains(questionInfo.getExplains());
+        List<String> nameList = concepts
+                .stream()
+                .map(concept -> concept.getTagName()).collect(Collectors.toList());
+        if (ListUtil.isNotEmpty(nameList)) {
+            QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper<>();
+            questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .in("tag_name", nameList)
+                    .eq("type", type);
+            List<QuestionInfo> questionInfoList = questionFacade.list(questionInfoQueryWrapper);
+            if (ListUtil.isNotEmpty(questionInfoList)) {
+                Map<String, QuestionInfo> questionInfoMap
+                        = EntityUtil.makeEntityMap(questionInfoList, "tagName");
+                for (ConceptPushDTO concept : concepts) {
+                    concept.setType(1);
+                    if (questionInfoMap.containsKey(concept.getName())) {
+                        QuestionInfo questionInfo = questionInfoMap.get(concept.getTagName());
+                        concept.setId(questionInfo.getId());
+                        concept.setName(questionInfo.getName());
+                        concept.setDescription(questionInfo.getDescription());
+                        if (StringUtil.isNotBlank(questionInfo.getExplains())) {
+                            concept.setHasExplain(1);
+                            concept.setExplains(questionInfo.getExplains());
+                        }
                     }
                 }
             }