|
@@ -35,8 +35,10 @@ import org.springframework.stereotype.Component; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
import java.time.LocalDateTime; |
|
|
import java.util.*; |
|
|
|
|
|
import java.util.function.Function; |
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.Objects; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@@ -63,70 +65,51 @@ public class UserInfoManage { |
|
|
String orgCode = req.getOrgCode(); |
|
|
String orgCode = req.getOrgCode(); |
|
|
String name = req.getName(); |
|
|
String name = req.getName(); |
|
|
|
|
|
|
|
|
List<String> roleCompliantEmployeeCodeList = getRoleCompliantEmployeeCodeList(req.getUserRoleList()); |
|
|
|
|
|
if (roleCompliantEmployeeCodeList != null && roleCompliantEmployeeCodeList.size() == 0) { |
|
|
|
|
|
|
|
|
List<Long> userIdList = getRoleCompliantUserIdList(req.getUserRoleList()); |
|
|
|
|
|
if (userIdList != null && userIdList.size() == 0) { |
|
|
return pageVo; |
|
|
return pageVo; |
|
|
} |
|
|
} |
|
|
List<String> orgNameCompliantOrgCodeList = getOrgNameCompliantOrgCodeList(req.getOrgName()); |
|
|
|
|
|
if (orgNameCompliantOrgCodeList != null && orgNameCompliantOrgCodeList.size() == 0) { |
|
|
|
|
|
|
|
|
List<String> compliantOrgEmpCodeList = getCompliantOrgEmpCodeList(req.getOrgName(), req.getOrgCode()); |
|
|
|
|
|
if (compliantOrgEmpCodeList != null && compliantOrgEmpCodeList.size() == 0) { |
|
|
return pageVo; |
|
|
return pageVo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
LambdaQueryWrapper<DingEmployeeInfo> wrapper = Wrappers.lambdaQuery(DingEmployeeInfo.class) |
|
|
|
|
|
.eq(DingEmployeeInfo::getMainJob, "true") |
|
|
|
|
|
.eq(DingEmployeeInfo::getStatus, "A") |
|
|
|
|
|
.eq(StringUtils.isNotBlank(orgCode), DingEmployeeInfo::getOrganizationCode, orgCode) |
|
|
|
|
|
.like(StringUtils.isNotBlank(phoneNo), DingEmployeeInfo::getBindUserMobile, phoneNo) |
|
|
|
|
|
.like(StringUtils.isNotBlank(name), DingEmployeeInfo::getEmployeeName, name) |
|
|
|
|
|
.in(Objects.nonNull(roleCompliantEmployeeCodeList), DingEmployeeInfo::getEmployeeCode, roleCompliantEmployeeCodeList) |
|
|
|
|
|
.in(Objects.nonNull(orgNameCompliantOrgCodeList), DingEmployeeInfo::getOrganizationCode, orgNameCompliantOrgCodeList); |
|
|
|
|
|
|
|
|
|
|
|
Page<DingEmployeeInfo> page = iDingEmployeeInfoService.page(new Page<>(req.getPageNumber(), req.getPageSize()), wrapper); |
|
|
|
|
|
List<DingEmployeeInfo> records = page.getRecords(); |
|
|
|
|
|
|
|
|
LambdaQueryWrapper<UserInfo> wrapper = Wrappers.lambdaQuery(UserInfo.class) |
|
|
|
|
|
.like(StringUtils.isNotBlank(phoneNo), UserInfo::getMobile, phoneNo) |
|
|
|
|
|
.like(StringUtils.isNotBlank(name), UserInfo::getRealName, name) |
|
|
|
|
|
.in(Objects.nonNull(userIdList), UserInfo::getId, userIdList) |
|
|
|
|
|
.in(Objects.nonNull(compliantOrgEmpCodeList), UserInfo::getEmployeeCode, compliantOrgEmpCodeList); |
|
|
|
|
|
|
|
|
|
|
|
Page<UserInfo> page = iUserInfoService.page(new Page<>(req.getPageNumber(), req.getPageSize()), wrapper); |
|
|
|
|
|
List<UserInfo> records = page.getRecords(); |
|
|
long total = page.getTotal(); |
|
|
long total = page.getTotal(); |
|
|
List<ResUserInfoListVO> result = new ArrayList<>(); |
|
|
List<ResUserInfoListVO> result = new ArrayList<>(); |
|
|
if (records != null && records.size() > 0) { |
|
|
if (records != null && records.size() > 0) { |
|
|
List<String> employeeCodeList = records.stream().map(DingEmployeeInfo::getEmployeeCode) |
|
|
|
|
|
|
|
|
List<String> employeeCodeList = records.stream().map(UserInfo::getEmployeeCode) |
|
|
.distinct().collect(Collectors.toList()); |
|
|
.distinct().collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
Map<String, UserInfo> employeeCodeAvailableMap = new HashMap<>(16); |
|
|
|
|
|
if (CollUtil.isNotEmpty(employeeCodeList)) { |
|
|
|
|
|
employeeCodeAvailableMap = iUserInfoService.list(Wrappers.lambdaQuery(UserInfo.class) |
|
|
|
|
|
.in(UserInfo::getEmployeeCode, employeeCodeList)) |
|
|
|
|
|
.stream().collect(Collectors.toMap(UserInfo::getEmployeeCode, Function.identity())); |
|
|
|
|
|
} |
|
|
|
|
|
List<String> orgCodeList = records.stream() |
|
|
|
|
|
.map(DingEmployeeInfo::getOrganizationCode) |
|
|
|
|
|
.filter(StringUtils::isNotBlank).distinct() |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
Map<String, DingOrganization> orgMap = iDingOrganizationService.getOrgMap(orgCodeList); |
|
|
|
|
|
|
|
|
List<DingEmployeeInfo> employeeInfoList = iDingEmployeeInfoService.getEmployeeList(employeeCodeList); |
|
|
|
|
|
Map<String, DingOrganization> empCodeOrgMap = iDingOrganizationService.getEmpCodeOrgMap(employeeInfoList); |
|
|
|
|
|
|
|
|
Map<String, UserInfo> finalEmployeeCodeAvailableMap = employeeCodeAvailableMap; |
|
|
|
|
|
records.forEach(r -> { |
|
|
records.forEach(r -> { |
|
|
ResUserInfoListVO item = new ResUserInfoListVO(); |
|
|
ResUserInfoListVO item = new ResUserInfoListVO(); |
|
|
item.setName(r.getEmployeeName()); |
|
|
|
|
|
String organizationCode = r.getOrganizationCode(); |
|
|
|
|
|
if (StringUtils.isNotBlank(organizationCode) && orgMap.containsKey(organizationCode)) { |
|
|
|
|
|
item.setOrgName(orgMap.get(organizationCode).getOrganizationName()); |
|
|
|
|
|
item.setOrgCode(organizationCode); |
|
|
|
|
|
String regionCode = orgMap.get(organizationCode).getDivisionCode(); |
|
|
|
|
|
item.setRegionCode(regionCode); |
|
|
|
|
|
if (Objects.nonNull(regionCode)) { |
|
|
|
|
|
item.setRegionName(regionCacheHelper.getDisplayName(regionCode, RegionConst.RL_COUNTY)); |
|
|
|
|
|
|
|
|
item.setName(r.getRealName()); |
|
|
|
|
|
String employeeCode = r.getEmployeeCode(); |
|
|
|
|
|
if (StringUtils.isNotBlank(employeeCode)) { |
|
|
|
|
|
DingOrganization dingOrganization = empCodeOrgMap.get(employeeCode); |
|
|
|
|
|
if (Objects.nonNull(dingOrganization)) { |
|
|
|
|
|
item.setOrgName(dingOrganization.getOrganizationName()); |
|
|
|
|
|
item.setOrgCode(dingOrganization.getOrganizationCode()); |
|
|
|
|
|
String regionCode = dingOrganization.getDivisionCode(); |
|
|
|
|
|
item.setRegionCode(regionCode); |
|
|
|
|
|
if (Objects.nonNull(regionCode)) { |
|
|
|
|
|
item.setRegionName(regionCacheHelper.getDisplayName(regionCode, RegionConst.RL_COUNTY)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
// TODO 从用户信息中获取 |
|
|
|
|
|
// 从所属组织中获取 |
|
|
|
|
|
// resListVO.setRegionId(); |
|
|
|
|
|
UserInfo userInfo = finalEmployeeCodeAvailableMap.get(r.getEmployeeCode()); |
|
|
|
|
|
// 装配用户状态 及 userId |
|
|
|
|
|
userStatusAssembler(item, userInfo); |
|
|
|
|
|
|
|
|
|
|
|
if (Objects.isNull(userInfo)) { |
|
|
|
|
|
item.setUpdateTime(r.getUpdateOn()); |
|
|
|
|
|
} else { |
|
|
|
|
|
item.setUpdateTime(userInfo.getUpdateOn()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
userStatusAssembler(item, r); |
|
|
|
|
|
item.setUpdateTime(r.getUpdateOn()); |
|
|
item.setEmployeeCode(r.getEmployeeCode()); |
|
|
item.setEmployeeCode(r.getEmployeeCode()); |
|
|
item.setUserRoleList(getUserRoleVOList(item.getUserId())); |
|
|
item.setUserRoleList(getUserRoleVOList(item.getUserId())); |
|
|
result.add(item); |
|
|
result.add(item); |
|
@@ -137,24 +120,50 @@ public class UserInfoManage { |
|
|
return pageVo; |
|
|
return pageVo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private List<String> getOrgNameCompliantOrgCodeList(String orgName) { |
|
|
|
|
|
if (StringUtils.isBlank(orgName)) { |
|
|
|
|
|
|
|
|
private List<String> getCompliantOrgEmpCodeList(String orgName, String orgCode) { |
|
|
|
|
|
if (StringUtils.isBlank(orgName) && StringUtils.isBlank(orgCode)) { |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
List<DingOrganization> dingOrganizationList = iDingOrganizationService.list(Wrappers.lambdaQuery(DingOrganization.class) |
|
|
|
|
|
.like(DingOrganization::getOrganizationName, orgName)); |
|
|
|
|
|
|
|
|
List<String> compliantOrgCodeList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
// 查重符合筛选条件的组织列表 |
|
|
|
|
|
if (StringUtils.isNotBlank(orgName)) { |
|
|
|
|
|
List<DingOrganization> dingOrganizationList = iDingOrganizationService.list(Wrappers.lambdaQuery(DingOrganization.class) |
|
|
|
|
|
.like(DingOrganization::getOrganizationName, orgName)); |
|
|
|
|
|
List<String> compliantOrgNameList = dingOrganizationList.stream() |
|
|
|
|
|
.map(DingOrganization::getOrganizationCode) |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
if (CollUtil.isEmpty(compliantOrgNameList)) { |
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
} |
|
|
|
|
|
compliantOrgCodeList.addAll(compliantOrgNameList); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return dingOrganizationList.stream() |
|
|
|
|
|
.map(DingOrganization::getOrganizationCode) |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(orgCode)) { |
|
|
|
|
|
compliantOrgCodeList.add(orgCode); |
|
|
|
|
|
} |
|
|
|
|
|
if (CollUtil.isEmpty(compliantOrgCodeList)) { |
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 查重符合筛选条件的用户code列表 |
|
|
|
|
|
List<DingEmployeeInfo> dingEmployeeInfoList = iDingEmployeeInfoService.list(Wrappers.lambdaQuery(DingEmployeeInfo.class) |
|
|
|
|
|
.in(DingEmployeeInfo::getOrganizationCode, compliantOrgCodeList)); |
|
|
|
|
|
|
|
|
|
|
|
List<String> compliantOrgEmpCodeList = dingEmployeeInfoList.stream() |
|
|
|
|
|
.map(DingEmployeeInfo::getEmployeeCode).distinct().collect(Collectors.toList()); |
|
|
|
|
|
if (compliantOrgEmpCodeList.size() > 500) { |
|
|
|
|
|
throw new BizException("搜索结果过多请缩小搜索范围"); |
|
|
|
|
|
} |
|
|
|
|
|
return compliantOrgEmpCodeList; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取符合查询条件的 用户 employeeCode |
|
|
|
|
|
|
|
|
* 获取符合查询条件的 用户 userId |
|
|
* |
|
|
* |
|
|
* @param userRoleList |
|
|
* @param userRoleList |
|
|
*/ |
|
|
*/ |
|
|
private List<String> getRoleCompliantEmployeeCodeList(List<UserRoleVO> userRoleList) { |
|
|
|
|
|
|
|
|
private List<Long> getRoleCompliantUserIdList(List<UserRoleVO> userRoleList) { |
|
|
userRoleList = userRoleList.stream().filter(r -> Objects.nonNull(r.getId())).collect(Collectors.toList()); |
|
|
userRoleList = userRoleList.stream().filter(r -> Objects.nonNull(r.getId())).collect(Collectors.toList()); |
|
|
if (CollUtil.isEmpty(userRoleList)) { |
|
|
if (CollUtil.isEmpty(userRoleList)) { |
|
|
return null; |
|
|
return null; |
|
@@ -166,12 +175,9 @@ public class UserInfoManage { |
|
|
if (CollUtil.isEmpty(compliantUserIdList)) { |
|
|
if (CollUtil.isEmpty(compliantUserIdList)) { |
|
|
return new ArrayList<>(); |
|
|
return new ArrayList<>(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// TODO 这里过滤的非浙政钉用户的专家 后续需要增加补充逻辑 |
|
|
|
|
|
return iUserInfoService.list(Wrappers.lambdaQuery(UserInfo.class) |
|
|
return iUserInfoService.list(Wrappers.lambdaQuery(UserInfo.class) |
|
|
.in(UserInfo::getId, compliantUserIdList)) |
|
|
.in(UserInfo::getId, compliantUserIdList)) |
|
|
.stream().map(UserInfo::getEmployeeCode) |
|
|
|
|
|
.filter(StringUtils::isNotBlank).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
.stream().map(UserInfo::getId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|