Explorar o código

模板数据去除重复的“”

zhoutg %!s(int64=6) %!d(string=hai) anos
pai
achega
6d94d81bd2

+ 55 - 0
icss-service/src/main/java/com/diagbot/enums/TagTypeEnum.java

@@ -0,0 +1,55 @@
+package com.diagbot.enums;
+
+import com.diagbot.core.KeyedNamed;
+import lombok.Setter;
+
+/**
+ * @Description:标签显示类型
+ * @Author:zhoutg
+ * @time: 2018/11/21 11:39
+ */
+public enum TagTypeEnum implements KeyedNamed {
+    T1(1, "单项单列"),
+    T2(2, "单项多列"),
+    T3(3, "横铺单标签形式"),
+    T4(4, "横铺多标签形式"),
+    T5(5, "竖铺组合项"),
+    T6(6, "组合项多列"),
+    T7(7, "化验类型"),
+    T8(8, "模板专用文字");
+
+    @Setter
+    private Integer key;
+
+    @Setter
+    private String name;
+
+    TagTypeEnum(Integer key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public static TagTypeEnum getEnum(Integer key) {
+        for (TagTypeEnum item : TagTypeEnum.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(Integer key) {
+        TagTypeEnum item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    @Override
+    public int getKey() {
+        return key;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+}

+ 16 - 1
icss-service/src/main/java/com/diagbot/facade/ModuleFacade.java

@@ -7,6 +7,7 @@ import com.diagbot.dto.QuestionDTO;
 import com.diagbot.entity.ModuleDetail;
 import com.diagbot.entity.ModuleInfo;
 import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.enums.TagTypeEnum;
 import com.diagbot.service.impl.ModuleInfoServiceImpl;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.EntityUtil;
@@ -66,7 +67,6 @@ public class ModuleFacade extends ModuleInfoServiceImpl {
         for (ModuleInfoDTO bean : data) {
             if (moduleDetailMap.get(bean.getId()) != null) {
                 List<ModuleDetailDTO> moduleDetailDTOList = BeanUtil.listCopyTo(moduleDetailMap.get(bean.getId()), ModuleDetailDTO.class);
-                bean.setModuleDetailDTOList(moduleDetailDTOList);
                 for (ModuleDetailDTO detailDTO : moduleDetailDTOList) {
                     if (null != detailDTO.getQuestionId()) {
                         QuestionVO questionVO = new QuestionVO();
@@ -77,6 +77,21 @@ public class ModuleFacade extends ModuleInfoServiceImpl {
                         BeanUtil.copyProperties(questionDTO, detailDTO);
                     }
                 }
+                //因为性别和年龄会过滤标签,留下重复的标点符号,以下用来处理重复的“”
+                boolean previousIsEmpty = false;
+                for (int i = 0; i < moduleDetailDTOList.size(); i++) {
+                    if (moduleDetailDTOList.get(i).getTagType() != null
+                            && TagTypeEnum.T8.getKey() == Integer.valueOf(moduleDetailDTOList.get(i).getTagType())
+                            && "".equals(moduleDetailDTOList.get(i).getName())) {
+                        if (previousIsEmpty) {
+                            moduleDetailDTOList.remove(i--);
+                        }
+                        previousIsEmpty = true;
+                    } else {
+                        previousIsEmpty = false;
+                    }
+                }
+                bean.setModuleDetailDTOList(moduleDetailDTOList);
             }
         }
         return data;