Browse Source

枚举类型换成字典表检索

wangyu 5 years ago
parent
commit
e4341dcd20

+ 0 - 51
precman-service/src/main/java/com/diagbot/enums/ModuleTypeEnum.java

@@ -1,51 +0,0 @@
-package com.diagbot.enums;
-
-import com.diagbot.core.KeyedNamed;
-import lombok.Setter;
-
-/**
- * @Description: 
- * @Author: wangyu
- * @Date: 13:41 2019/3/28
- */
-public enum ModuleTypeEnum implements KeyedNamed {
-    Symptoms(1, "症状情况"),
-    DiagnosisAndTreatment(2, "诊疗情况"),
-    OtherMedicalHistory(3, "其他病史"),
-    SupplementaryContents(4, "补充内容");
-
-    @Setter
-    private Integer key;
-
-    @Setter
-    private String name;
-
-    ModuleTypeEnum(Integer key, String name) {
-        this.key = key;
-        this.name = name;
-    }
-
-    public static ModuleTypeEnum getEnum(Integer key) {
-        for (ModuleTypeEnum item : ModuleTypeEnum.values()) {
-            if (item.key == key) {
-                return item;
-            }
-        }
-        return null;
-    }
-
-    public static String getName(Integer key) {
-        ModuleTypeEnum item = getEnum(key);
-        return item != null ? item.name : null;
-    }
-
-    @Override
-    public int getKey() {
-        return key;
-    }
-
-    @Override
-    public String getName() {
-        return name;
-    }
-}

+ 30 - 15
precman-service/src/main/java/com/diagbot/facade/ModuleInfoFacade.java

@@ -13,16 +13,15 @@ import com.diagbot.dto.GetModuleInfoOneDTO;
 import com.diagbot.dto.GetModuleTypeDTO;
 import com.diagbot.dto.ModuleInfoListDTO;
 import com.diagbot.dto.RespDTO;
+import com.diagbot.entity.DictionaryInfo;
 import com.diagbot.entity.ModuleDetail;
 import com.diagbot.entity.ModuleInfo;
 import com.diagbot.entity.QuestionInfo;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.enums.ModuleInfoTypeEnum;
-import com.diagbot.enums.ModuleTypeEnum;
 import com.diagbot.service.impl.ModuleInfoServiceImpl;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.DateUtil;
-import com.diagbot.util.EnumEntriesBuilder;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.RespDTOUtil;
 import com.diagbot.util.StringUtil;
@@ -194,6 +193,14 @@ public class ModuleInfoFacade extends ModuleInfoServiceImpl {
         RespDTO<List<ConceptBaseDTO>> deptInfoList = knowledgemanServiceClient.getConceptListByType(conceptTypeVO);
         RespDTOUtil.respNGDeal(deptInfoList,"获取科室信息失败");
         Map<Long, ConceptBaseDTO> deptInfoMap = deptInfoList.data.stream().collect(Collectors.toMap(ConceptBaseDTO::getConceptId,conceptBaseDTO -> conceptBaseDTO));
+        //获取模板类型名称
+        QueryWrapper<DictionaryInfo> dictionaryInfoQueryWrapper = new QueryWrapper<>();
+        dictionaryInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("group_type", 1)
+                .eq("return_type", 1)
+                .orderByDesc("order_no");
+        List<DictionaryInfo> dictionaryInfoList = dictionaryFacade.list(dictionaryInfoQueryWrapper);
+        Map<String, DictionaryInfo> dictionaryInfoMap = dictionaryInfoList.stream().collect(Collectors.toMap(DictionaryInfo::getVal,dictionaryInfo -> dictionaryInfo));
         if(ListUtil.isNotEmpty(moduleInfoDTOIPage.getRecords())){
             //获取用户信息
             RespDTO<Map<String, String>> respDTO = userServiceClient.getUserInfoByIds(ids);
@@ -201,7 +208,7 @@ public class ModuleInfoFacade extends ModuleInfoServiceImpl {
             //将用户信息放入实体
             for (ModuleInfoListDTO moduleInfoListDTO : moduleInfoDTOIPage.getRecords()) {
                 moduleInfoListDTO.setUserName(respDTO.data.get(moduleInfoListDTO.getModifier()));
-                moduleInfoListDTO.setAscriptionName(ModuleTypeEnum.getName(Integer.parseInt(moduleInfoListDTO.getType())));
+                moduleInfoListDTO.setAscriptionName(dictionaryInfoMap.get(moduleInfoListDTO.getType()).getName());
                 if(moduleInfoListDTO.getModuleType().intValue() == 1){//根据科室
                     if(moduleInfoListDTO.getRelationId().intValue() != -1){//判断是不是科室通用子模板
                         if(null != deptInfoMap.get(moduleInfoListDTO.getRelationId())){
@@ -244,7 +251,15 @@ public class ModuleInfoFacade extends ModuleInfoServiceImpl {
             Map<Long, ConceptBaseDTO> deptInfoMap = deptInfoList.data.stream().collect(Collectors.toMap(ConceptBaseDTO::getConceptId,conceptBaseDTO -> conceptBaseDTO));
             //获取模板类型
             BeanUtil.copyProperties(moduleInfo, getModuleInfoOneDTO);
-            getModuleInfoOneDTO.setAscriptionName(ModuleTypeEnum.getName(Integer.parseInt(moduleInfo.getType())));
+            //获取模板类型名称
+            QueryWrapper<DictionaryInfo> dictionaryInfoQueryWrapper = new QueryWrapper<>();
+            dictionaryInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .eq("group_type", 1)
+                    .eq("return_type", 1)
+                    .orderByDesc("order_no");
+            List<DictionaryInfo> dictionaryInfoList = dictionaryFacade.list(dictionaryInfoQueryWrapper);
+            Map<String, DictionaryInfo> dictionaryInfoMap = dictionaryInfoList.stream().collect(Collectors.toMap(DictionaryInfo::getVal,dictionaryInfo -> dictionaryInfo));
+            getModuleInfoOneDTO.setAscriptionName(dictionaryInfoMap.get(getModuleInfoOneDTO.getType()).getName());
             getModuleInfoOneDTO.setModuleTypeName(ModuleInfoTypeEnum.getName(getModuleInfoOneDTO.getModuleType().intValue()));
             if(getModuleInfoOneDTO.getModuleType().intValue() == 1){
                 if(null != deptInfoMap.get(getModuleInfoOneDTO.getRelationId())){
@@ -306,19 +321,19 @@ public class ModuleInfoFacade extends ModuleInfoServiceImpl {
         List<ModuleInfo> moduleInfos = this.list(moduleInfoQueryWrapper);
         List<String> types = moduleInfos.stream().map(moduleInfo -> moduleInfo.getType()).collect(Collectors.toList());
         //获取模板类型
-        Map<String, List<EnumEntriesBuilder.Entry>> enumMap = new EnumEntriesBuilder()
-                .addEnums("moduleTypeEnum", ModuleTypeEnum.values()).build();
-        Iterator<EnumEntriesBuilder.Entry> iterator =  enumMap.get("moduleTypeEnum").iterator();
-        while (iterator.hasNext()){
-            if (types.contains(iterator.next().getKey())){//过滤掉添加过的模板类型
-                iterator.remove();
-            }
-        }
+        QueryWrapper<DictionaryInfo> dictionaryInfoQueryWrapper = new QueryWrapper<>();
+        dictionaryInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("group_type", 1)
+                .eq("return_type", 1)
+                .orderByDesc("order_no")
+                .notIn("val",types);
+        List<DictionaryInfo> dictionaryInfoList = dictionaryFacade.list(dictionaryInfoQueryWrapper);
+        Map<String, DictionaryInfo> dictionaryInfoMap = dictionaryInfoList.stream().collect(Collectors.toMap(DictionaryInfo::getVal,dictionaryInfo -> dictionaryInfo));
         List<GetModuleTypeDTO> getModuleTypeDTOS = new ArrayList<>();
-        for (EnumEntriesBuilder.Entry entry : enumMap.get("moduleTypeEnum")) {
+        for (DictionaryInfo dictionaryInfo : dictionaryInfoList) {
             GetModuleTypeDTO getModuleTypeDTO = new GetModuleTypeDTO();
-            getModuleTypeDTO.setName(entry.getName());
-            getModuleTypeDTO.setType(entry.getKey().toString());
+            getModuleTypeDTO.setName(dictionaryInfo.getName());
+            getModuleTypeDTO.setType(dictionaryInfo.getVal());
             getModuleTypeDTOS.add(getModuleTypeDTO);
         }
         return getModuleTypeDTOS;