Quellcode durchsuchen

电签角色去重/单独返回

lvy vor 2 Monaten
Ursprung
Commit
8fa8b72bbc

+ 16 - 16
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/SignConfigServiceImpl.java

@@ -324,8 +324,7 @@ public class SignConfigServiceImpl extends BaseServiceImpl<SignConfigMapper, Sig
             if (signConfigVOS == null || signConfigVOS.isEmpty()) {
                 return;
             }
-            List<Long> roleIds = new ArrayList<>();
-            List<String> roleNames = new ArrayList<>();
+            Map<Long, String> roleIdNameMap = new HashMap<>();
             signConfigVOS.forEach(signConfigVO -> {
                 List<SignConfigRelation> relations = signConfigVO.getRelations();
                 if (relations != null && !relations.isEmpty()) {
@@ -345,24 +344,25 @@ public class SignConfigServiceImpl extends BaseServiceImpl<SignConfigMapper, Sig
                     List<SignConfigRelation> roles = collect.get(1);
                     if (roles != null && !roles.isEmpty()) {
                         roles.forEach(role -> {
-                            roleIds.add(role.getRelationId());
-                            roleNames.add(role.getRelationName());
+                            roleIdNameMap.put(role.getRelationId(), role.getRelationName());
                         });
                     }
                 }
             });
-            if (!roleIds.isEmpty()) {
-                TextdictInfoVO textdictInfoVO = new TextdictInfoVO();
-                if (vo != null) {
-                    BeanUtil.copy(vo, textdictInfoVO);
-                }
-                textdictInfoVO.setId(null);
-                textdictInfoVO.setColKey(value);
-                textdictInfoVO.setColName(colName);
-                textdictInfoVO.setIsSystem(1);
-                textdictInfoVO.setSigRoleId(StringUtil.join(roleIds, ","));
-                textdictInfoVO.setSigRoleName(StringUtil.join(roleNames, ","));
-                textdictInfoVOS.add(textdictInfoVO);
+            if (!roleIdNameMap.isEmpty()) {
+                roleIdNameMap.forEach((roleId, roleName) -> {
+                    TextdictInfoVO textdictInfoVO = new TextdictInfoVO();
+                    if (vo != null) {
+                        BeanUtil.copy(vo, textdictInfoVO);
+                    }
+                    textdictInfoVO.setId(null);
+                    textdictInfoVO.setColKey(value);
+                    textdictInfoVO.setColName(colName);
+                    textdictInfoVO.setIsSystem(1);
+                    textdictInfoVO.setSigRoleId(roleId + "");
+                    textdictInfoVO.setSigRoleName(roleName);
+                    textdictInfoVOS.add(textdictInfoVO);
+                });
             }
         });
         return textdictInfoVOS;

+ 4 - 8
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/TextdictInfoServiceImpl.java

@@ -99,15 +99,11 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
                         if (textdict == null || textdict.isEmpty()) {
                             textdict = textdictList;
                         } else {
-                            Map<String, TextdictInfoVO> map = textdict.stream().collect(Collectors.toMap(TextdictInfoVO::getColKey, TextdictInfoVO -> TextdictInfoVO, (v1, v2) -> v1));
+                            Map<String, Map<String, TextdictInfoVO>> map = textdict.stream().collect(Collectors.groupingBy(TextdictInfoVO::getColKey, Collectors.toMap(TextdictInfoVO::getSigRoleId, v -> v, (v1, v2) -> v1)));
                             List<TextdictInfoVO> collect = textdictList.stream().filter(textdictInfoVO -> {
-                                TextdictInfoVO vo = map.get(textdictInfoVO.getColKey());
-                                if (vo != null && vo.getSigRoleId() != null && !vo.getSigRoleId().isEmpty()) {
-                                    List<String> projectRoleIds = Arrays.asList(vo.getSigRoleId().split(","));
-                                    List<String> systemRoleIds = new ArrayList<>(Arrays.asList(textdictInfoVO.getSigRoleId().split(",")));
-                                    // 如果 projectRoleIds 包含所有  systemRoleIds,则返回 false
-                                    systemRoleIds.removeAll(projectRoleIds);
-                                    return !systemRoleIds.isEmpty();
+                                Map<String, TextdictInfoVO> voMap = map.get(textdictInfoVO.getColKey());
+                                if (voMap != null && !voMap.isEmpty() ) {
+                                    return voMap.get(textdictInfoVO.getSigRoleId()) == null;
                                 }
                                 return true;
                             }).collect(Collectors.toList());