Browse Source

功能:修改集团编码赋值逻辑

lijie 3 years ago
parent
commit
66596e7ce4

+ 20 - 42
dmp-comp/dmp-auth/src/main/java/com/persagy/dmp/auth/service/impl/EmsAuthServiceImpl.java

@@ -39,36 +39,26 @@ public class EmsAuthServiceImpl extends AbstractAuthServiceImpl {
             // 两者都为空时不做校验,例如def/class的接口,dic的接口
             return;
         }
-        JSONObject param = new JSONObject();
-//        if (StrUtil.isNotBlank(AppContext.getContext().getGroupCode())){
-//            param.put(CommonConstant.QUERY_GROUPCODE,AppContext.getContext().getGroupCode());
-//        }
-//        if (StrUtil.isNotBlank(AppContext.getContext().getProjectId())){
-//            param.put(CommonConstant.QUERY_PROJECTIDS, CollUtil.newArrayList(AppContext.getContext().getProjectId()));
-//        }
-        ResultReturn<Group> queryResult = emsSaasWebClient.queryGroupProjectList(param);
-        if (!CommonConstant.QUERY_SUCCESS.equals(queryResult.getResult())){
-            throw new BusinessException(queryResult.getResultMsg());
-        }
-        List<Group> content = queryResult.getContent();
-        if (CollUtil.isEmpty(content)){
-            throw new BusinessException(ResponseCode.A0402.getCode(),ResponseCode.A0402.getDesc());
-        }
-        Map<String, List<Project>> groupMap = content.stream()
-                .collect(Collectors.toMap(Group::getGroupCode, Group::getProjects, (k1, k2) -> k1));
-        // 1.没有集团编码时根据项目匹配集团
-        if (StrUtil.isBlank(AppContext.getContext().getGroupCode())){
-            // 如果集团编码为空则通过项目id查找
-            Set<Map.Entry<String, List<Project>>> entries = groupMap.entrySet();
-            flag:
-            for (Map.Entry<String, List<Project>> entry : entries) {
-                if (CollUtil.isEmpty(entry.getValue())){
-                    continue;
-                }
-                for (Project project : entry.getValue()) {
-                    if (AppContext.getContext().getProjectId().equals(project.getProjectId())){
-                        AppContext.getContext().setGroupCode(entry.getKey());
-                        break flag;
+        if (StrUtil.isNotBlank(AppContext.getContext().getProjectId())){
+            ResultReturn<Group> queryResult = emsSaasWebClient.queryGroupProjectList(new JSONObject());
+            if (CommonConstant.QUERY_SUCCESS.equals(queryResult.getResult())
+                    && CollUtil.isEmpty(queryResult.getContent())){
+                List<Group> content = queryResult.getContent();
+                Map<String, List<Project>> groupMap = content.stream()
+                        .collect(Collectors.toMap(Group::getGroupCode, Group::getProjects, (k1, k2) -> k1));
+                // 1.没有集团编码时根据项目匹配集团,有则重新赋值
+                // 如果集团编码为空则通过项目id查找
+                Set<Map.Entry<String, List<Project>>> entries = groupMap.entrySet();
+                flag:
+                for (Map.Entry<String, List<Project>> entry : entries) {
+                    if (CollUtil.isEmpty(entry.getValue())){
+                        continue;
+                    }
+                    for (Project project : entry.getValue()) {
+                        if (AppContext.getContext().getProjectId().equals(project.getProjectId())){
+                            AppContext.getContext().setGroupCode(entry.getKey());
+                            break flag;
+                        }
                     }
                 }
             }
@@ -77,17 +67,5 @@ public class EmsAuthServiceImpl extends AbstractAuthServiceImpl {
         if (StrUtil.isBlank(AppContext.getContext().getGroupCode())){
             throw new BusinessException(ResponseCode.A0402.getCode(),ResponseCode.A0402.getDesc());
         }
-//        if (StrUtil.isBlank(AppContext.getContext().getProjectId())){
-//            return;
-//        }
-        // 3.验证项目是否匹配集团
-//        List<Project> projects = groupMap
-//                .getOrDefault(AppContext.getContext().getGroupCode(), new ArrayList<>());
-//        if (!projects.stream()
-//                .map(Project::getProjectId)
-//                .collect(Collectors.toSet())
-//                .contains(AppContext.getContext().getProjectId())){
-//            throw new BusinessException(ResponseCode.A0402.getCode(),ResponseCode.A0402.getDesc());
-//        }
     }
 }