Browse Source

fix 用户管理相关功能

master
niohe·erbao 1 year ago
parent
commit
65537a242d
4 changed files with 70 additions and 17 deletions
  1. +5
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/organization/model/entity/DingEmployeeInfo.java
  2. +10
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/organization/service/IDingOrganizationService.java
  3. +15
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/organization/service/impl/DingOrganizationServiceImpl.java
  4. +40
    -17
      pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java

+ 5
- 0
pmapi/src/main/java/com/ningdatech/pmapi/organization/model/entity/DingEmployeeInfo.java View File

@@ -70,4 +70,9 @@ public class DingEmployeeInfo implements Serializable {

private Long accountId;

/**
* 绑定系统用户手机号
*/
private String bindUserMobile;

}

+ 10
- 0
pmapi/src/main/java/com/ningdatech/pmapi/organization/service/IDingOrganizationService.java View File

@@ -5,6 +5,7 @@ import com.ningdatech.pmapi.organization.model.entity.DingOrganization;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
* <p>
@@ -50,4 +51,13 @@ public interface IDingOrganizationService extends IService<DingOrganization> {
**/
List<String> listNameByCodes(Collection<String> codes);


/**
* 根据orgCodeList 获取 code 和 名称 Map
* @param orgCodeList
* @return
*/
Map<String, String> getOrgCodeAndNameMap(List<String> orgCodeList);


}

+ 15
- 0
pmapi/src/main/java/com/ningdatech/pmapi/organization/service/impl/DingOrganizationServiceImpl.java View File

@@ -1,5 +1,6 @@
package com.ningdatech.pmapi.organization.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -10,8 +11,11 @@ import com.ningdatech.pmapi.organization.model.entity.DingOrganization;
import com.ningdatech.pmapi.organization.service.IDingOrganizationService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* <p>
@@ -45,6 +49,9 @@ public class DingOrganizationServiceImpl extends ServiceImpl<DingOrganizationMap

@Override
public List<DingOrganization> listByCodes(Collection<String> codes) {
if (CollectionUtil.isEmpty(codes)) {
return new ArrayList<>();
}
LambdaQueryWrapper<DingOrganization> query = Wrappers.lambdaQuery(DingOrganization.class)
.eq(DingOrganization::getOrganizationCode, codes);
return list(query);
@@ -58,4 +65,12 @@ public class DingOrganizationServiceImpl extends ServiceImpl<DingOrganizationMap
return CollUtils.fieldList(list(query), DingOrganization::getOrganizationName);
}

@Override
public Map<String, String> getOrgCodeAndNameMap(List<String> orgCodeList) {
orgCodeList = orgCodeList.stream().distinct().collect(Collectors.toList());
List<DingOrganization> dingOrganizationList = listByCodes(orgCodeList);
return dingOrganizationList.stream()
.filter(r -> StringUtils.isNotBlank(r.getOrganizationCode()) && StringUtils.isNotBlank(r.getOrganizationName()))
.collect(Collectors.toMap(DingOrganization::getOrganizationCode, DingOrganization::getOrganizationName));
}
}

+ 40
- 17
pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java View File

@@ -52,9 +52,15 @@ public class UserInfoManage {
private final UserInfoHelper userInfoHelper;

public PageVo<ResUserInfoListVO> list(ReqUserInfoListPO reqUserInfoListPO) {

String phoneNo = reqUserInfoListPO.getPhoneNo();
String orgCode = reqUserInfoListPO.getOrgCode();
String name = reqUserInfoListPO.getName();
LambdaQueryWrapper<DingEmployeeInfo> wrapper = Wrappers.lambdaQuery(DingEmployeeInfo.class)
.eq(DingEmployeeInfo::getMainJob, "true")
.eq(StringUtils.isNotBlank(reqUserInfoListPO.getOrgCode()), DingEmployeeInfo::getOrganizationCode, reqUserInfoListPO.getOrgCode());
.eq(StringUtils.isNotBlank(orgCode), DingEmployeeInfo::getOrganizationCode, orgCode)
.like(StringUtils.isNotBlank(phoneNo), DingEmployeeInfo::getBindUserMobile, phoneNo)
.like(StringUtils.isNotBlank(name), DingEmployeeInfo::getEmployeeName, name);

Page<DingEmployeeInfo> page = iDingEmployeeInfoService.page(new Page<>(reqUserInfoListPO.getPageNumber(), reqUserInfoListPO.getPageSize()), wrapper);
List<DingEmployeeInfo> records = page.getRecords();
@@ -70,32 +76,28 @@ public class UserInfoManage {
.in(UserInfo::getEmployeeCode, employeeCodeList))
.stream().collect(Collectors.toMap(UserInfo::getEmployeeCode, Function.identity()));
}

List<String> orgCodeList = records.stream()
.filter(r -> StringUtils.isNotBlank(r.getOrganizationCode()))
.map(DingEmployeeInfo::getOrganizationCode).distinct()
.collect(Collectors.toList());
Map<String, String> orgCodeAndNameMap = iDingOrganizationService.getOrgCodeAndNameMap(orgCodeList);

Map<String, UserInfo> finalEmployeeCodeAvailableMap = employeeCodeAvailableMap;
resUserInfoListVOList = records.stream()
.map(r -> {
ResUserInfoListVO resListVO = new ResUserInfoListVO();
resListVO.setName(r.getEmployeeName());
resListVO.setOrgName(r.getOrganizationCode());
resListVO.setOrgCode(r.getOrganizationCode());
String organizationCode = r.getOrganizationCode();
if (StringUtils.isNotBlank(organizationCode)) {
resListVO.setOrgName(orgCodeAndNameMap.get(organizationCode));
resListVO.setOrgCode(organizationCode);
}
// TODO 从用户信息中获取
// 从所属组织中获取
// resListVO.setRegionId();

UserInfo userInfo = finalEmployeeCodeAvailableMap.get(r.getEmployeeCode());
if (Objects.nonNull(userInfo)) {
resListVO.setPhoneNo(userInfo.getMobile());
if (StringUtils.isNotBlank(userInfo.getAvailable())
&& UserAvailableEnum.ENABLE.name().equals(userInfo.getAvailable())) {
resListVO.setStatus(UserAvailableEnum.ENABLE.name());
} else {
resListVO.setStatus(UserAvailableEnum.DISABLE.name());
}
resListVO.setUserId(userInfo.getId());
} else {
resListVO.setStatus(UserAvailableEnum.DISABLE.name());
}
// 装配用户状态 及 userId
userStatusAssembler(resListVO, userInfo);
resListVO.setUpdateTime(r.getUpdateOn());
// 从用户信息中获取
resListVO.setEmployeeCode(r.getEmployeeCode());
@@ -110,6 +112,27 @@ public class UserInfoManage {
return pageVo;
}

/**
* 装配用户状态 及 userId
*
* @param resListVO
* @param userInfo
*/
private void userStatusAssembler(ResUserInfoListVO resListVO, UserInfo userInfo) {
if (Objects.nonNull(userInfo)) {
resListVO.setPhoneNo(userInfo.getMobile());
if (StringUtils.isNotBlank(userInfo.getAvailable())
&& UserAvailableEnum.ENABLE.name().equals(userInfo.getAvailable())) {
resListVO.setStatus(UserAvailableEnum.ENABLE.name());
} else {
resListVO.setStatus(UserAvailableEnum.DISABLE.name());
}
resListVO.setUserId(userInfo.getId());
} else {
resListVO.setStatus(UserAvailableEnum.DISABLE.name());
}
}


private List<UserRoleVO> getUserRoleVOList(Long userId) {
List<UserRoleVO> userRoleInfoList = new ArrayList<>();


Loading…
Cancel
Save