Browse Source

feat: userTree过滤测试用户

weijianghai 2 years ago
parent
commit
2195cca009

+ 20 - 6
src/main/java/com/nokia/service/FlowService.java

@@ -8,17 +8,15 @@ import com.nokia.pojo.User;
 import com.nokia.vo.flow.FlowRoleVo;
 import com.nokia.vo.flow.FlowUserVo;
 import com.nokia.vo.flow.UserTreeReq;
-
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.Map.Entry;
 
+@Slf4j
 @Service
 public class FlowService {
 
@@ -164,17 +162,33 @@ public class FlowService {
         // 把归类后的用户放入第三层
         for (Entry<Area, Object> entry : userMap.entrySet()) {
             if (entry.getKey().getTypeCode() < 3) {
+                if (entry.getKey().getAreaId() == null
+                        || top.get(entry.getKey().getAreaId()) == null
+                        || result.get(top.get(entry.getKey().getAreaId())) == null) {
+                    continue;
+                }
                 // 第一层的child
                 List<Map<String, Object>> list = (List<Map<String, Object>>) result
                         .get(top.get(entry.getKey().getAreaId())).get("child");
+                if (CollectionUtils.isEmpty(list)) {
+                    continue;
+                }
                 // 省级和地市级用户
                 list.get(0).put("child", entry.getValue());
             } else {
                 // 第一层的child
                 // System.out.println(entry);
                 // System.out.println(result);
+                if (entry.getKey().getParentId() == null
+                        || top.get(entry.getKey().getParentId()) == null
+                        || result.get(top.get(entry.getKey().getParentId())) == null) {
+                    continue;
+                }
                 List<Map<String, Object>> list = (List<Map<String, Object>>) result
                         .get(top.get(entry.getKey().getParentId())).get("child");
+                if (CollectionUtils.isEmpty(list) || second.get(entry.getKey().getAreaId()) == null) {
+                    continue;
+                }
                 // 区县级用户
                 list.get(second.get(entry.getKey().getAreaId())).put("child", entry.getValue());
             }

+ 1 - 1
src/main/resources/mapper/UserMapper.xml

@@ -79,7 +79,7 @@
             where
                 au.user_id = aurc.user_id and ar.role_id = aurc.role_id
                 and au.province_id = ac.area_id and au.city_id = ac2.area_id
-                and aurc.city_id = ac3.area_id and au.deleted = 0 ) tmp
+                and aurc.city_id = ac3.area_id and au.deleted = 0 and au.test_user = 0) tmp
             left join sqmdb_rpt.acl_area ac4
             on tmp.area_id = ac4.area_id
         where tmp.user_id != 1