Commit 3f796936 authored by huyuchen's avatar huyuchen

huyc 部门根节点数值修改

parent 42507a98
...@@ -207,9 +207,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl ...@@ -207,9 +207,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
userId = dn.substring(4, dn.indexOf(",", 1)); userId = dn.substring(4, dn.indexOf(",", 1));
dn = dn.substring(dn.indexOf(",", 1) + 1); dn = dn.substring(dn.indexOf(",", 1) + 1);
} }
List<String> list = Arrays.asList(dn.split(",")).stream().filter(e -> (e.contains("ou=") && !e.equals("ou=wanxin"))).collect(Collectors.toList()); List<String> saveDnList = Arrays.asList(dn.split(",")).stream().filter(e -> (e.contains("ou=") && !e.equals("ou=wanxin"))).collect(Collectors.toList());
String deptName = list.get(0).replace("ou=", ""); String deptName = saveDnList.get(0).replace("ou=", "");
int size = list.size(); int size = saveDnList.size();
if (size == 1) { if (size == 1) {
SysDept sysDept = this.getOne(Wrappers.<SysDept>query().lambda().eq(SysDept::getDeptDn, dn)); SysDept sysDept = this.getOne(Wrappers.<SysDept>query().lambda().eq(SysDept::getDeptDn, dn));
if (null == sysDept) { if (null == sysDept) {
......
...@@ -20,10 +20,12 @@ import cn.hutool.core.collection.CollUtil; ...@@ -20,10 +20,12 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.plugin.excel.vo.ErrorMessage; import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import com.unboundid.ldap.sdk.SearchResultEntry;
import com.yifu.cloud.plus.v1.yifu.admin.api.dto.UserDTO; import com.yifu.cloud.plus.v1.yifu.admin.api.dto.UserDTO;
import com.yifu.cloud.plus.v1.yifu.admin.api.dto.UserInfo; import com.yifu.cloud.plus.v1.yifu.admin.api.dto.UserInfo;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.*; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.*;
...@@ -31,6 +33,7 @@ import com.yifu.cloud.plus.v1.yifu.admin.api.util.ParamResolver; ...@@ -31,6 +33,7 @@ import com.yifu.cloud.plus.v1.yifu.admin.api.util.ParamResolver;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserExcelVO; import com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserExcelVO;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserVO; import com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserVO;
import com.yifu.cloud.plus.v1.yifu.admin.mapper.*; import com.yifu.cloud.plus.v1.yifu.admin.mapper.*;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysDeptService;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysMenuService; import com.yifu.cloud.plus.v1.yifu.admin.service.SysMenuService;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysUserService; import com.yifu.cloud.plus.v1.yifu.admin.service.SysUserService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
...@@ -83,6 +86,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl ...@@ -83,6 +86,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
private final SysUserMapper sysUserMapper; private final SysUserMapper sysUserMapper;
private final SysDeptService sysDeptService;
/** /**
* 保存用户信息 * 保存用户信息
* @param userDto DTO 对象 * @param userDto DTO 对象
...@@ -405,26 +410,32 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl ...@@ -405,26 +410,32 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
*/ */
@Override @Override
public R<Boolean> updateByLdap() { public R<Boolean> updateByLdap() {
List<PersonVo> list = ldapUtil.getAllPersons(); try {
if (null != list) { List<PersonVo> list = ldapUtil.getAllPersons();
List<SysUser> listUser = this.list(Wrappers.<SysUser>query().lambda().eq(SysUser::getDelFlag, CommonConstants.STATUS_NORMAL)); if (null != list) {
List<String> list1 = listUser.stream().map(SysUser::getUsername).collect(Collectors.toList()); List<SysUser> listUser = this.list(Wrappers.<SysUser>query().lambda().eq(SysUser::getDelFlag, CommonConstants.STATUS_NORMAL));
Map<String, String> map = listUser.stream().collect(HashMap::new, (m, v) -> m.put(v.getUsername(), v.getUserId()), HashMap::putAll); List<String> list1 = listUser.stream().map(SysUser::getUsername).collect(Collectors.toList());
List<PersonVo> updateList = new ArrayList<>(); Map<String, String> map = listUser.stream().collect(HashMap::new, (m, v) -> m.put(v.getUsername(), v.getUserId()), HashMap::putAll);
List<PersonVo> insertList = new ArrayList<>(); List<PersonVo> updateList = new ArrayList<>();
for (PersonVo personVo : list) { List<PersonVo> insertList = new ArrayList<>();
if (list1.stream().anyMatch(e -> e.equals(personVo.getUid()))) { for (PersonVo personVo : list) {
updateList.add(personVo); if (list1.stream().anyMatch(e -> e.equals(personVo.getUid()))) {
} else { updateList.add(personVo);
insertList.add(personVo); } else {
insertList.add(personVo);
}
}
if (updateList.size() > 0) {
sysUserMapper.batchUpdateUser(updateList);
}
if (insertList.size() > 0) {
sysUserMapper.batchInsertUser(insertList);
} }
} }
if (updateList.size()>0) { sysDeptService.updateDeptByLdap();
sysUserMapper.batchUpdateUser(updateList); }catch (Exception e) {
} log.info("用户部门信息同步异常:" + e.getMessage());
if (insertList.size()>0) { return R.failed("用户部门信息同步异常!");
sysUserMapper.batchInsertUser(insertList);
}
} }
return R.ok(); return R.ok();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment