|
|
@@ -4,12 +4,14 @@ import cn.hutool.core.collection.CollUtil; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.ningdatech.basic.exception.BizException; |
|
|
|
import com.ningdatech.pmapi.common.helper.UserInfoHelper; |
|
|
|
import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; |
|
|
|
import com.ningdatech.pmapi.organization.model.entity.DingOrganization; |
|
|
|
import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService; |
|
|
|
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; |
|
|
|
import com.ningdatech.pmapi.user.entity.UserInfo; |
|
|
|
import com.ningdatech.pmapi.user.mapper.NdUserInfoMapper; |
|
|
|
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; |
|
|
|
import com.ningdatech.pmapi.user.service.IUserInfoService; |
|
|
|
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
@@ -30,35 +32,22 @@ import java.util.stream.Collectors; |
|
|
|
@Service |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class UserInfoServiceImpl extends ServiceImpl<NdUserInfoMapper, UserInfo> implements IUserInfoService { |
|
|
|
|
|
|
|
private final NdUserInfoMapper userInfoMapper; |
|
|
|
private final IDingEmployeeInfoService dingEmployeeInfoService; |
|
|
|
|
|
|
|
private final IDingOrganizationService dingOrganizationService; |
|
|
|
private final UserInfoHelper userInfoHelper; |
|
|
|
|
|
|
|
@Override |
|
|
|
public Map<String, ProcessInstanceUserDto> getUserMapByIds(Set<String> staterUsers) { |
|
|
|
List<UserInfo> userInfos = userInfoMapper.selectBatchIds(staterUsers); |
|
|
|
return userInfos.stream().map(u -> { |
|
|
|
ProcessInstanceUserDto userInfo = new ProcessInstanceUserDto(); |
|
|
|
userInfo.setUserId(String.valueOf(u.getId())); |
|
|
|
userInfo.setUserId(u.getEmployeeCode()); |
|
|
|
userInfo.setUserName(u.getRealName()); |
|
|
|
Long accountId = u.getAccountId(); |
|
|
|
if (Objects.isNull(accountId)) { |
|
|
|
throw new BizException("该用户没有录入浙政钉用户信息!"); |
|
|
|
} |
|
|
|
// 根据浙政钉用户ID获取单位code |
|
|
|
DingEmployeeInfo employeeInfo = dingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) |
|
|
|
.eq(DingEmployeeInfo::getAccountId, accountId) |
|
|
|
.eq(DingEmployeeInfo::getMainJob, String.valueOf(Boolean.TRUE)) |
|
|
|
.last("limit 1")); |
|
|
|
String organizationCode = employeeInfo.getOrganizationCode(); |
|
|
|
// 根据 单位code获取单位名称 |
|
|
|
DingOrganization dingOrganization = dingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) |
|
|
|
.eq(DingOrganization::getOrganizationCode, organizationCode).last("limit 1")); |
|
|
|
String organizationName = dingOrganization.getOrganizationName(); |
|
|
|
userInfo.setOrgCode(organizationCode); |
|
|
|
userInfo.setOrgName(organizationName); |
|
|
|
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(u.getId()); |
|
|
|
if(Objects.nonNull(userFullInfo)){ |
|
|
|
userInfo.setOrgCode(userFullInfo.getEmpPosUnitCode()); |
|
|
|
userInfo.setOrgName(userFullInfo.getEmpPosUnitName()); |
|
|
|
} |
|
|
|
return userInfo; |
|
|
|
}).collect(Collectors.toMap((ProcessInstanceUserDto::getUserId), v -> v)); |
|
|
|
} |
|
|
@@ -77,22 +66,12 @@ public class UserInfoServiceImpl extends ServiceImpl<NdUserInfoMapper, UserInfo> |
|
|
|
ProcessInstanceUserDto userInfo = new ProcessInstanceUserDto(); |
|
|
|
userInfo.setUserId(u.getEmployeeCode()); |
|
|
|
userInfo.setUserName(u.getRealName()); |
|
|
|
Long accountId = u.getAccountId(); |
|
|
|
if (Objects.isNull(accountId)) { |
|
|
|
throw new BizException("该用户没有录入浙政钉用户信息!"); |
|
|
|
} |
|
|
|
// 根据浙政钉用户ID获取单位code |
|
|
|
DingEmployeeInfo employeeInfo = dingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) |
|
|
|
.eq(DingEmployeeInfo::getAccountId, accountId) |
|
|
|
.eq(DingEmployeeInfo::getMainJob, String.valueOf(Boolean.TRUE)) |
|
|
|
.last("limit 1")); |
|
|
|
String organizationCode = employeeInfo.getOrganizationCode(); |
|
|
|
// 根据 单位code获取单位名称 |
|
|
|
DingOrganization dingOrganization = dingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) |
|
|
|
.eq(DingOrganization::getOrganizationCode, organizationCode).last("limit 1")); |
|
|
|
String organizationName = dingOrganization.getOrganizationName(); |
|
|
|
userInfo.setOrgCode(organizationCode); |
|
|
|
userInfo.setOrgName(organizationName); |
|
|
|
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(u.getId()); |
|
|
|
if(Objects.nonNull(userFullInfo)){ |
|
|
|
userInfo.setOrgCode(userFullInfo.getEmpPosUnitCode()); |
|
|
|
userInfo.setOrgName(userFullInfo.getEmpPosUnitName()); |
|
|
|
} |
|
|
|
return userInfo; |
|
|
|
}).collect(Collectors.toMap((ProcessInstanceUserDto::getUserId), v -> v)); |
|
|
|
} |
|
|
@@ -103,20 +82,12 @@ public class UserInfoServiceImpl extends ServiceImpl<NdUserInfoMapper, UserInfo> |
|
|
|
ProcessInstanceUserDto processInstanceUserDto = new ProcessInstanceUserDto(); |
|
|
|
processInstanceUserDto.setUserId(String.valueOf(userInfo.getId())); |
|
|
|
processInstanceUserDto.setUserName(userInfo.getRealName()); |
|
|
|
Long accountId = userInfo.getAccountId(); |
|
|
|
if (Objects.isNull(accountId)) { |
|
|
|
throw new BizException("该用户没有录入浙政钉用户信息!"); |
|
|
|
// 根据 单位code获取单位名称 |
|
|
|
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userInfo.getId()); |
|
|
|
if(Objects.nonNull(userFullInfo)){ |
|
|
|
processInstanceUserDto.setOrgCode(userFullInfo.getEmpPosUnitCode()); |
|
|
|
processInstanceUserDto.setOrgName(userFullInfo.getEmpPosUnitName()); |
|
|
|
} |
|
|
|
// 根据浙政钉用户ID获取部门code |
|
|
|
DingEmployeeInfo employeeInfo = dingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) |
|
|
|
.eq(DingEmployeeInfo::getId, accountId)); |
|
|
|
String organizationCode = employeeInfo.getOrganizationCode(); |
|
|
|
// 根据部门code获取部门名称 |
|
|
|
DingOrganization dingOrganization = dingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) |
|
|
|
.eq(DingOrganization::getOrganizationCode, organizationCode)); |
|
|
|
String organizationName = dingOrganization.getOrganizationName(); |
|
|
|
processInstanceUserDto.setOrgCode(organizationCode); |
|
|
|
processInstanceUserDto.setOrgName(organizationName); |
|
|
|
return processInstanceUserDto; |
|
|
|
} |
|
|
|
|
|
|
|