Przeglądaj źródła

部门用户筛选

liangpeile 1 rok temu
rodzic
commit
92b0831d4f

+ 31 - 26
crmeb-service/src/main/java/com/zbkj/service/service/impl/OrganizationDepartmentServiceImpl.java

@@ -91,33 +91,38 @@ public class OrganizationDepartmentServiceImpl extends ServiceImpl<OrganizationD
                 LambdaQueryWrapper<UserEnterprise> queryWrapper2 = new LambdaQueryWrapper<>();
                 queryWrapper2.eq(UserEnterprise::getOrganizationId, organizationId1);
                 UserEnterprise userEnterprise2 = userEnterpriseService.getOne(queryWrapper2);
-                Integer id2 = userEnterprise2.getId();
-
-                LambdaQueryWrapper<UserBypassAccount> queryWrapper3 = new LambdaQueryWrapper<>();
-                queryWrapper3.eq(UserBypassAccount::getEnterpriseId, id2);
-                queryWrapper3.eq(UserBypassAccount::getDepartment, name);
-                queryWrapper3.eq(UserBypassAccount::getIsDelete, 0);
-                List<UserBypassAccount> list1 = userBypassAccountService.list(queryWrapper3);
-                for (UserBypassAccount userBypassAccount : list1) {
-                    list.add(userBypassAccount);
-                }
-                if (null == list || list.size() == 0) {
-                    LambdaQueryWrapper<UserEnterprise> queryWrapper4 = new LambdaQueryWrapper<>();
-                    queryWrapper4.eq(UserEnterprise::getOrganizationId, organizationId);
-                    UserEnterprise userEnterprise4 = userEnterpriseService.getOne(queryWrapper4);
-                    UserBypassAccount userBypassAccount = new UserBypassAccount();
-                    userBypassAccount.setId(userEnterprise4.getId());
-                    userBypassAccount.setEnterpriseId(userEnterprise4.getId());
-                    userBypassAccount.setUserId(userEnterprise4.getUserId());
-                    userBypassAccount.setRealName(userEnterprise4.getRealName());
-                    userBypassAccount.setNickname(userEnterprise4.getNickname());
-                    userBypassAccount.setPhone(userEnterprise4.getPhone());
-                    userBypassAccount.setAvatar(userEnterprise4.getAvatar());
-                    userBypassAccount.setIsDelete(userEnterprise4.getIsDelete());
-                    userBypassAccount.setDepartment(userEnterprise4.getDepartment());
-                    userBypassAccount.setDepartmentId(departmentId);
-                    list.add(userBypassAccount);
+                if (null!=userEnterprise2){
+                    Integer id2 = userEnterprise2.getId();
+                    LambdaQueryWrapper<UserBypassAccount> queryWrapper3 = new LambdaQueryWrapper<>();
+                    queryWrapper3.eq(UserBypassAccount::getEnterpriseId, id2);
+                    queryWrapper3.eq(UserBypassAccount::getDepartment, name);
+                    queryWrapper3.eq(UserBypassAccount::getIsDelete, 0);
+                    List<UserBypassAccount> list1 = userBypassAccountService.list(queryWrapper3);
+                    for (UserBypassAccount userBypassAccount : list1) {
+                        list.add(userBypassAccount);
+                    }
+                    if (null == list1 || list1.size() == 0) {
+                        LambdaQueryWrapper<UserEnterprise> queryWrapper4 = new LambdaQueryWrapper<>();
+                        queryWrapper4.eq(UserEnterprise::getOrganizationId, organizationId);
+                        UserEnterprise userEnterprise4 = userEnterpriseService.getOne(queryWrapper4);
+                        if (null!=userEnterprise4){
+                            UserBypassAccount userBypassAccount = new UserBypassAccount();
+                            userBypassAccount.setId(userEnterprise4.getId());
+                            userBypassAccount.setEnterpriseId(userEnterprise4.getId());
+                            userBypassAccount.setUserId(userEnterprise4.getUserId());
+                            userBypassAccount.setRealName(userEnterprise4.getRealName());
+                            userBypassAccount.setNickname(userEnterprise4.getNickname());
+                            userBypassAccount.setPhone(userEnterprise4.getPhone());
+                            userBypassAccount.setAvatar(userEnterprise4.getAvatar());
+                            userBypassAccount.setIsDelete(userEnterprise4.getIsDelete());
+                            userBypassAccount.setDepartment(userEnterprise4.getDepartment());
+                            userBypassAccount.setDepartmentId(organizationDepartment.getId());
+                            list.add(userBypassAccount);
+                        }
+
+                    }
                 }
+
             }
             return CommonResult.success(list);
         } else if (StringUtils.isNotBlank(organizationId)) {