Ver código fonte

标签保存bug

zhoutg 5 anos atrás
pai
commit
4881aeb2c8

+ 32 - 29
icssman-service/src/main/java/com/diagbot/facade/QuestionFacade.java

@@ -302,38 +302,41 @@ public class QuestionFacade extends QuestionInfoServiceImpl {
      */
     public Map<String, Long> getNameMap(List<QuestionMappingWrapper> questionMappings, Date now,
                                         String person, Integer type) {
+        Map<String, Long> map = new HashMap<>();
         List<String> nameList = questionMappings.stream().filter(row -> StringUtil.isNotEmpty(row.getText()))
                 .map(row -> row.getText()).collect(Collectors.toList());
-        List<QuestionInfo> questionInfos = this.list(new QueryWrapper<QuestionInfo>()
-                .eq("type", type)
-                .eq("is_deleted", IsDeleteEnum.N.getKey())
-                .eq("tag_type", TagTypeEnum.T8.getKey())
-                .in("name", nameList)
-        );
-        Map<String, Long> map = questionInfos.stream()
-                .collect(Collectors.toMap(row -> row.getName(), row -> row.getId(), (k1, k2) -> k1));
-        List<QuestionInfo> addBatch = new ArrayList<>();
-        List<String> nameExist = new ArrayList<>();
-        for (String s : nameList) {
-            if (map.get(s) == null && !nameExist.contains(s)) {
-                nameExist.add(s);
-                QuestionInfo bean = new QuestionInfo();
-                bean.setModifier(person);
-                bean.setCreator(person);
-                bean.setGmtCreate(now);
-                bean.setGmtModified(now);
-                bean.setTagType(TagTypeEnum.T8.getKey());
-                bean.setTagName(s);
-                bean.setName(s);
-                bean.setType(type);
-                bean.setSubType(1); //描述类型
-                addBatch.add(bean);
+        if (ListUtil.isNotEmpty(nameList)) {
+            List<QuestionInfo> questionInfos = this.list(new QueryWrapper<QuestionInfo>()
+                    .eq("type", type)
+                    .eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .eq("tag_type", TagTypeEnum.T8.getKey())
+                    .in("name", nameList)
+            );
+            map = questionInfos.stream()
+                    .collect(Collectors.toMap(row -> row.getName(), row -> row.getId(), (k1, k2) -> k1));
+            List<QuestionInfo> addBatch = new ArrayList<>();
+            List<String> nameExist = new ArrayList<>();
+            for (String s : nameList) {
+                if (map.get(s) == null && !nameExist.contains(s)) {
+                    nameExist.add(s);
+                    QuestionInfo bean = new QuestionInfo();
+                    bean.setModifier(person);
+                    bean.setCreator(person);
+                    bean.setGmtCreate(now);
+                    bean.setGmtModified(now);
+                    bean.setTagType(TagTypeEnum.T8.getKey());
+                    bean.setTagName(s);
+                    bean.setName(s);
+                    bean.setType(type);
+                    bean.setSubType(1); //描述类型
+                    addBatch.add(bean);
+                }
             }
-        }
-        questionInfoService.saveBatch(addBatch); //批量插入question
-        for (QuestionInfo bean : addBatch) {
-            if (map.get(bean.getName()) == null) {
-                map.put(bean.getName(), bean.getId());
+            questionInfoService.saveBatch(addBatch); //批量插入question
+            for (QuestionInfo bean : addBatch) {
+                if (map.get(bean.getName()) == null) {
+                    map.put(bean.getName(), bean.getId());
+                }
             }
         }
         return map;