Browse Source

代码优化

gaodm 5 years ago
parent
commit
d05677b3a8

+ 64 - 32
knowledgeman-service/src/main/java/com/diagbot/facade/DiagnoseImportFacade.java

@@ -22,6 +22,7 @@ import com.diagbot.service.DiagnoseQuestionService;
 import com.diagbot.service.DiagnoseService;
 import com.diagbot.util.ExportBeanExcelUtil;
 import com.diagbot.util.GsonUtil;
+import com.diagbot.util.IntegerUtil;
 import com.diagbot.util.StringUtil;
 import com.diagbot.vo.DiagnosticAllExportVO;
 import com.diagbot.vo.DiagnosticBasisExportVO;
@@ -44,7 +45,9 @@ import java.io.InputStream;
 import java.text.DecimalFormat;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author wangfeng
@@ -54,6 +57,24 @@ import java.util.List;
 @Component
 public class DiagnoseImportFacade {
 
+    private static final Map<String, Integer> typeMap = new HashMap<String, Integer>() {
+        {
+            put(String.valueOf(DiagnoseFeatureTypeEnum.Dis.getKey()), 0);
+            put(String.valueOf(DiagnoseFeatureTypeEnum.Symptom.getKey()), 1);
+            put(String.valueOf(DiagnoseFeatureTypeEnum.Vital.getKey()), 2);
+            put(DiagnoseFeatureTypeEnum.Lis.getKey() + "_2", 3);
+            put(DiagnoseFeatureTypeEnum.Lis.getKey() + "_3", 4);
+            put(DiagnoseFeatureTypeEnum.Lis.getKey() + "_4", 5);
+            put(DiagnoseFeatureTypeEnum.Pacs.getKey() + "_2", 6);
+            put(DiagnoseFeatureTypeEnum.Pacs.getKey() + "_3", 7);
+            put(String.valueOf(DiagnoseFeatureTypeEnum.Antidiastole.getKey()), 8);
+            put(String.valueOf(DiagnoseFeatureTypeEnum.History.getKey()), 8);
+            put(String.valueOf(DiagnoseFeatureTypeEnum.Cause.getKey()), 9);
+            put(String.valueOf(DiagnoseFeatureTypeEnum.CourseOfDisease.getKey()), 10);
+            put(String.valueOf(DiagnoseFeatureTypeEnum.Other.getKey()), 10);
+        }
+    };
+
     @Autowired
     DiagnoseQuestionService diagnoseQuestionService;
     @Autowired
@@ -319,41 +340,52 @@ public class DiagnoseImportFacade {
      */
     public String getType(Integer type, Integer questionType) {
         String typeName = "";
-        if (type == DiagnoseFeatureTypeEnum.Dis.getKey()) {
-            typeName = TermEnum.getName(0);
-        } else if (type == DiagnoseFeatureTypeEnum.Symptom.getKey()) {
-            typeName = TermEnum.getName(1);
-        } else if (type == DiagnoseFeatureTypeEnum.Vital.getKey()) {
-            typeName = TermEnum.getName(2);
-        } else if (type == DiagnoseFeatureTypeEnum.Lis.getKey()) {
-            if (questionType == 2) {
-                typeName = TermEnum.getName(3);
-            }
-            if (questionType == 3) {
-                typeName = TermEnum.getName(4);
-            }
-            if (questionType == 4) {
-                typeName = TermEnum.getName(5);
+        Integer showType = null;
+        if (typeMap.containsKey(type.toString())) {
+            showType = typeMap.get(type.toString());
+        } else {
+            if (typeMap.containsKey(type + "_" + questionType)) {
+                showType = typeMap.get(type + "_" + questionType);
             }
-        } else if (type == DiagnoseFeatureTypeEnum.Pacs.getKey()) {
-            if (questionType == 2) {
-                typeName = TermEnum.getName(6);
-            }
-            if (questionType == 3) {
-                typeName = TermEnum.getName(7);
-            }
-        } else if (type == DiagnoseFeatureTypeEnum.Antidiastole.getKey()) {
-            typeName = TermEnum.getName(8);
-        } else if (type == DiagnoseFeatureTypeEnum.History.getKey()) {
-            typeName = TermEnum.getName(8);
-        } else if (type == DiagnoseFeatureTypeEnum.Cause.getKey()) {
-            typeName = TermEnum.getName(9);
-        } else if (type == DiagnoseFeatureTypeEnum.CourseOfDisease.getKey()) {
-            typeName = TermEnum.getName(10);
-        } else if (type == DiagnoseFeatureTypeEnum.Other.getKey()) {
-            typeName = TermEnum.getName(10);
+        }
+        if (!IntegerUtil.isNull(showType)) {
+            typeName = TermEnum.getName(showType);
         }
         return typeName;
+        //        if (type == DiagnoseFeatureTypeEnum.Dis.getKey()) {
+        //            typeName = TermEnum.getName(0);
+        //        } else if (type == DiagnoseFeatureTypeEnum.Symptom.getKey()) {
+        //            typeName = TermEnum.getName(1);
+        //        } else if (type == DiagnoseFeatureTypeEnum.Vital.getKey()) {
+        //            typeName = TermEnum.getName(2);
+        //        } else if (type == DiagnoseFeatureTypeEnum.Lis.getKey()) {
+        //            if (questionType == 2) {
+        //                typeName = TermEnum.getName(3);
+        //            }
+        //            if (questionType == 3) {
+        //                typeName = TermEnum.getName(4);
+        //            }
+        //            if (questionType == 4) {
+        //                typeName = TermEnum.getName(5);
+        //            }
+        //        } else if (type == DiagnoseFeatureTypeEnum.Pacs.getKey()) {
+        //            if (questionType == 2) {
+        //                typeName = TermEnum.getName(6);
+        //            }
+        //            if (questionType == 3) {
+        //                typeName = TermEnum.getName(7);
+        //            }
+        //        } else if (type == DiagnoseFeatureTypeEnum.Antidiastole.getKey()) {
+        //            typeName = TermEnum.getName(8);
+        //        } else if (type == DiagnoseFeatureTypeEnum.History.getKey()) {
+        //            typeName = TermEnum.getName(8);
+        //        } else if (type == DiagnoseFeatureTypeEnum.Cause.getKey()) {
+        //            typeName = TermEnum.getName(9);
+        //        } else if (type == DiagnoseFeatureTypeEnum.CourseOfDisease.getKey()) {
+        //            typeName = TermEnum.getName(10);
+        //        } else if (type == DiagnoseFeatureTypeEnum.Other.getKey()) {
+        //            typeName = TermEnum.getName(10);
+        //        }
     }
 
     /**