新增用户调整
parent
5f45e6f2ba
commit
33b9a09667
|
|
@ -14,6 +14,7 @@ import com.jjb.saas.message.client.message.facede.MessageFacade;
|
|||
import com.jjb.saas.message.client.message.request.MessageSendCmd;
|
||||
import com.jjb.saas.message.client.message.request.MessageTargetCmd;
|
||||
import com.jjb.saas.system.client.user.facade.UserFacade;
|
||||
import com.jjb.saas.system.client.user.request.RoleDeptAddCmd;
|
||||
import com.jjb.saas.system.client.user.request.UserUpdateQuitCmd;
|
||||
import com.jjb.saas.system.client.user.response.UserDetailCO;
|
||||
import com.zcloud.basic.info.command.convertor.UserCoConvertor;
|
||||
|
|
@ -44,10 +45,11 @@ import java.util.stream.Collectors;
|
|||
|
||||
|
||||
/**
|
||||
* web-app
|
||||
* @Author zhangyue
|
||||
* @Date 2025-11-04 14:07:21
|
||||
*/
|
||||
* web-app
|
||||
*
|
||||
* @Author zhangyue
|
||||
* @Date 2025-11-04 14:07:21
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
@Slf4j
|
||||
|
|
@ -72,7 +74,7 @@ public class UserAddExe {
|
|||
private final UserCorpRecordRepository userCorpRecordRepository;
|
||||
@DubboReference(check = false)
|
||||
private UserFacade userFacade;
|
||||
// private final String sourceCode;
|
||||
// private final String sourceCode;
|
||||
// @Value("${seng.message:MS000087}")
|
||||
// public void setSourceCode(String sourceCode) {
|
||||
// this.sourceCode = sourceCode;
|
||||
|
|
@ -91,16 +93,16 @@ public class UserAddExe {
|
|||
BeanUtils.copyProperties(cmd, userE);
|
||||
userE.initAdd(tenantId, userE);
|
||||
//校验身份证是否存在
|
||||
List<UserDO> userDOList = userRepository.getByIdCard(userE.getUserIdCard(),null);
|
||||
if(CollUtil.isNotEmpty(userDOList)){
|
||||
List<UserDO> userDOList = userRepository.getByIdCard(userE.getUserIdCard(), null);
|
||||
if (CollUtil.isNotEmpty(userDOList)) {
|
||||
List<UserE> userEList = userCoConvertor.convertDOsToEs(userDOList);
|
||||
userE.checkIdCardExist(userEList);
|
||||
}
|
||||
//校验手机号
|
||||
List<Integer> employmentFlagList = Arrays.asList(UserEmploymentFlagEnum.ON.getCode(), UserEmploymentFlagEnum.ENTRY_AUDIT.getCode(), UserEmploymentFlagEnum.RESIGNATION_AUDIT.getCode());
|
||||
List<UserDO> userList = userRepository.getListByPhone( userE.getPhone(),employmentFlagList);
|
||||
List<UserDO> userList = userRepository.getListByPhone(userE.getPhone(), employmentFlagList);
|
||||
if (CollUtil.isNotEmpty(userList)) {
|
||||
List<UserE> userEList = userCoConvertor.convertDOsToEs(userList);
|
||||
List<UserE> userEList = userCoConvertor.convertDOsToEs(userList);
|
||||
userE.checkPhone(userEList);
|
||||
}
|
||||
|
||||
|
|
@ -109,9 +111,9 @@ public class UserAddExe {
|
|||
UserEmploymentLogE userEmploymentLogE = new UserEmploymentLogE();
|
||||
BeanUtils.copyProperties(userE, userEmploymentLogE);
|
||||
boolean res = false;
|
||||
if(ObjectUtils.isEmpty(userE.getRoleId())){
|
||||
if (ObjectUtils.isEmpty(userE.getRoleId())) {
|
||||
Long roleId = userRepository.getDefaultRoleId();
|
||||
if (roleId == null){
|
||||
if (roleId == null) {
|
||||
throw new BizException("未创建默认通用角色,请联系管理员");
|
||||
}
|
||||
userE.setRoleId(roleId);
|
||||
|
|
@ -119,7 +121,7 @@ public class UserAddExe {
|
|||
try {
|
||||
|
||||
res = userGateway.add(userE);
|
||||
if(corpInfoDO != null && !ObjectUtils.isEmpty(corpInfoDO.getCorpName())){
|
||||
if (corpInfoDO != null && !ObjectUtils.isEmpty(corpInfoDO.getCorpName())) {
|
||||
corpName = corpInfoDO.getCorpName();
|
||||
}
|
||||
userEmploymentLogE.initAdd(userEmploymentLogE, corpName, userE.getId());
|
||||
|
|
@ -140,11 +142,11 @@ public class UserAddExe {
|
|||
userE.checkPassword(cmd.getNewPassword(), cmd.getConfirmPassword());
|
||||
|
||||
// 获取redis验证码
|
||||
if(!"dev".equals(codeConfig.getProfile())){
|
||||
if (!"dev".equals(codeConfig.getProfile())) {
|
||||
|
||||
|
||||
Object phoneCodeObj = zcloudRedisUtil.get(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
|
||||
if(phoneCodeObj == null || !phoneCodeObj.toString().equals(cmd.getPhoneCode())){
|
||||
if (phoneCodeObj == null || !phoneCodeObj.toString().equals(cmd.getPhoneCode())) {
|
||||
throw new BizException("验证码已过期或错误");
|
||||
}
|
||||
zcloudRedisUtil.del(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
|
||||
|
|
@ -177,18 +179,18 @@ public class UserAddExe {
|
|||
// 3-相关方
|
||||
userE.setUserType(3);
|
||||
UserDO userDO = userRepository.getById(cmd.getId());
|
||||
if(userDO == null){
|
||||
if (userDO == null) {
|
||||
throw new BizException("用户不存在");
|
||||
}
|
||||
// 12.29 不校验身份证号
|
||||
// userRepository.checkUserIdCard(cmd.getId(),cmd.getUserIdCard());
|
||||
|
||||
if(userDO.getFlowFlag()!=null && !userDO.getFlowFlag().equals(cmd.getFlowFlag())){
|
||||
if(cmd.getFlowFlag() == UserFlowFlagEnum.FIXED.getCode()){
|
||||
if (userDO.getFlowFlag() != null && !userDO.getFlowFlag().equals(cmd.getFlowFlag())) {
|
||||
if (cmd.getFlowFlag() == UserFlowFlagEnum.FIXED.getCode()) {
|
||||
// 流动转固定
|
||||
List<UserDO> listByPhone = userRepository.getListByPhone(userDO.getPhone(), Arrays.asList(UserEmploymentFlagEnum.ON.getCode(), UserEmploymentFlagEnum.ENTRY_AUDIT.getCode(), UserEmploymentFlagEnum.RESIGNATION_AUDIT.getCode()));
|
||||
|
||||
if(CollUtil.isNotEmpty(listByPhone) && listByPhone.size() > 1){
|
||||
if (CollUtil.isNotEmpty(listByPhone) && listByPhone.size() > 1) {
|
||||
throw new BizException("该用户存在多家未离职信息,不能修改人员流动状态");
|
||||
}
|
||||
}
|
||||
|
|
@ -198,8 +200,8 @@ public class UserAddExe {
|
|||
userGateway.updateByPhone(userE);
|
||||
|
||||
// 底座同步修改姓名和邮箱
|
||||
if(StringUtils.isNotEmpty(userDO.getName())){
|
||||
if(!userDO.getName().equals(cmd.getName()) || !userDO.getEmail().equals(cmd.getEmail())){
|
||||
if (StringUtils.isNotEmpty(userDO.getName())) {
|
||||
if (!userDO.getName().equals(cmd.getName()) || !userDO.getEmail().equals(cmd.getEmail())) {
|
||||
UserE u = new UserE();
|
||||
u.setId(cmd.getId());
|
||||
u.setName(cmd.getName());
|
||||
|
|
@ -226,38 +228,38 @@ public class UserAddExe {
|
|||
* 3.2.2 如果有则将离职状态改为入职待审批,
|
||||
* 3.2.3 如果没有则创建一条新user数据
|
||||
* 3.3 如果是流动用户,
|
||||
* 3.3.1 如果在当前企业有账号,则判断有未离职信息则提示,如果已离职,则将离职状态改为入职待审批
|
||||
* 3.3.2 如果在当前企业没有账号,则创建一条新user数据
|
||||
* 3.3.3 新user数据的基础信息通过手机号查询该用户的其他全的信息获取过来(有身份证号信息的取第一个)
|
||||
* 3.3.1 如果在当前企业有账号,则判断有未离职信息则提示,如果已离职,则将离职状态改为入职待审批
|
||||
* 3.3.2 如果在当前企业没有账号,则创建一条新user数据
|
||||
* 3.3.3 新user数据的基础信息通过手机号查询该用户的其他全的信息获取过来(有身份证号信息的取第一个)
|
||||
*/
|
||||
|
||||
UserDO userDO = userRepository.getById(cmd.getId());
|
||||
|
||||
if(userDO == null){
|
||||
if (userDO == null) {
|
||||
throw new BizException("用户不存在");
|
||||
}
|
||||
|
||||
UserE userE = new UserE();
|
||||
|
||||
if(userDO.getCorpinfoId() == null){
|
||||
if (userDO.getCorpinfoId() == null) {
|
||||
BeanUtils.copyProperties(cmd, userE);
|
||||
|
||||
// user表状态变为入职待审核
|
||||
userE.setEmploymentFlag(UserEmploymentFlagEnum.ENTRY_AUDIT.getCode());
|
||||
userGateway.update(userE);
|
||||
}else {
|
||||
} else {
|
||||
// 用户有企业id
|
||||
Integer flowFlag = userDO.getFlowFlag();
|
||||
if(UserFlowFlagEnum.FIXED.getCode().equals(flowFlag)){
|
||||
if (UserFlowFlagEnum.FIXED.getCode().equals(flowFlag)) {
|
||||
// 固定用户
|
||||
String username = userDO.getUsername();
|
||||
List<UserDO> userDOS = userRepository.listByPhone(username);
|
||||
// 3.2
|
||||
if(CollUtil.isNotEmpty(userDOS)){
|
||||
if (CollUtil.isNotEmpty(userDOS)) {
|
||||
userDOS.forEach(u -> {
|
||||
if (UserEmploymentFlagEnum.ON.getCode().equals(u.getEmploymentFlag())
|
||||
|| UserEmploymentFlagEnum.ENTRY_AUDIT.getCode().equals(u.getEmploymentFlag())
|
||||
|| UserEmploymentFlagEnum.RESIGNATION_AUDIT.getCode().equals(u.getEmploymentFlag())){
|
||||
|| UserEmploymentFlagEnum.ENTRY_AUDIT.getCode().equals(u.getEmploymentFlag())
|
||||
|| UserEmploymentFlagEnum.RESIGNATION_AUDIT.getCode().equals(u.getEmploymentFlag())) {
|
||||
throw new BizException("该固定用户存在未离职信息,无法入职");
|
||||
}
|
||||
});
|
||||
|
|
@ -265,9 +267,9 @@ public class UserAddExe {
|
|||
// 3.2.1 3.2.2
|
||||
// 在当前企业是否有账号标识,false-没有,true-有
|
||||
boolean corpFlag = false;
|
||||
if(CollUtil.isNotEmpty(userDOS)){
|
||||
if (CollUtil.isNotEmpty(userDOS)) {
|
||||
for (UserDO u : userDOS) {
|
||||
if(cmd.getCorpinfoId().equals(u.getCorpinfoId())){
|
||||
if (cmd.getCorpinfoId().equals(u.getCorpinfoId())) {
|
||||
// 在当前企业有账号
|
||||
u.setEmploymentFlag(UserEmploymentFlagEnum.ENTRY_AUDIT.getCode());
|
||||
BeanUtils.copyProperties(u, userE);
|
||||
|
|
@ -279,7 +281,7 @@ public class UserAddExe {
|
|||
}
|
||||
}
|
||||
// 3.2.3
|
||||
if(!corpFlag){
|
||||
if (!corpFlag) {
|
||||
// 在当前企业没有账号
|
||||
// 找到第一个 userIdCard 有值(非空且非空字符串)的数据
|
||||
Optional<UserDO> firstUserWithIdCard = userDOS.stream()
|
||||
|
|
@ -297,16 +299,16 @@ public class UserAddExe {
|
|||
throw new BizException("当前用户不存在完整用户信息");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
// 流动用户
|
||||
String username = userDO.getUsername();
|
||||
List<UserDO> userDOS = userRepository.listByPhone(username);
|
||||
// 在当前企业是否有账号标识,false-没有,true-有
|
||||
boolean corpFlag = false;
|
||||
for (UserDO u : userDOS) {
|
||||
if(cmd.getCorpinfoId().equals(u.getCorpinfoId())){
|
||||
if (cmd.getCorpinfoId().equals(u.getCorpinfoId())) {
|
||||
// 在当前企业有账号
|
||||
if(!UserEmploymentFlagEnum.NOT_ON.getCode().equals(u.getEmploymentFlag()) && !UserEmploymentFlagEnum.RESIGNATION.getCode().equals(u.getEmploymentFlag())){
|
||||
if (!UserEmploymentFlagEnum.NOT_ON.getCode().equals(u.getEmploymentFlag()) && !UserEmploymentFlagEnum.RESIGNATION.getCode().equals(u.getEmploymentFlag())) {
|
||||
throw new BizException("该用户在当前企业存在未离职信息,无法重新入职");
|
||||
}
|
||||
// user表状态变为入职待审核
|
||||
|
|
@ -317,7 +319,7 @@ public class UserAddExe {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if(!corpFlag){
|
||||
if (!corpFlag) {
|
||||
// 在当前企业没有账号
|
||||
// 找到第一个 userIdCard 有值(非空且非空字符串)的数据
|
||||
Optional<UserDO> firstUserWithIdCard = userDOS.stream()
|
||||
|
|
@ -357,21 +359,21 @@ public class UserAddExe {
|
|||
// 生成6位验证码
|
||||
String phoneCode = RandomUtil.randomNumbers(6);
|
||||
Object phoneCodeCountObj = zcloudRedisUtil.get(RedisConstant.PHONE_CODE_COUNT + DateUtil.getDays() + ":" + cmd.getPhone());
|
||||
if(phoneCodeCountObj != null){
|
||||
if (phoneCodeCountObj != null) {
|
||||
Integer phoneCodeCount = (Integer) phoneCodeCountObj;
|
||||
if(phoneCodeCount >= 20){
|
||||
if (phoneCodeCount >= 20) {
|
||||
throw new BizException("今天验证码已发送次数已超过20次");
|
||||
}
|
||||
}
|
||||
|
||||
boolean sendFlag = sendMessage(cmd.getPhone(), phoneCode);
|
||||
if(sendFlag){
|
||||
if (sendFlag) {
|
||||
// 发送成功
|
||||
// 放入到redis里
|
||||
zcloudRedisUtil.set(RedisConstant.PHONE_CODE_KEY + cmd.getPhone(), phoneCode, 60 * 15);
|
||||
// 设置新的验证码发送次数
|
||||
zcloudRedisUtil.set(RedisConstant.PHONE_CODE_COUNT + DateUtil.getDays() + ":" + cmd.getPhone(),
|
||||
phoneCodeCountObj == null ? 1 : (Integer)phoneCodeCountObj + 1,
|
||||
phoneCodeCountObj == null ? 1 : (Integer) phoneCodeCountObj + 1,
|
||||
60 * 60 * 24);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -380,7 +382,7 @@ public class UserAddExe {
|
|||
}
|
||||
|
||||
// 组装发送短信
|
||||
public boolean sendMessage(String phone, String phoneCode){
|
||||
public boolean sendMessage(String phone, String phoneCode) {
|
||||
MessageSendCmd messageSendCmd = new MessageSendCmd();
|
||||
messageSendCmd.setBusinessId(UuidUtil.get32UUID());
|
||||
MessageTargetCmd messageTargetCmd = new MessageTargetCmd();
|
||||
|
|
@ -395,7 +397,6 @@ public class UserAddExe {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean executeXgf(UserXgfAddCmd cmd) {
|
||||
SSOUser ssoUser = AuthContext.getCurrentUser();
|
||||
|
|
@ -406,42 +407,44 @@ public class UserAddExe {
|
|||
CorpInfoDO corpInfoDO = corpInfoRepository.getById(userE.getCorpinfoId());
|
||||
|
||||
Long roleId = userRepository.getDefaultRoleId();
|
||||
if (roleId == null){
|
||||
if (roleId == null) {
|
||||
throw new BizException("未创建默认通用角色,请联系管理员");
|
||||
}
|
||||
userE.setRoleId(roleId);
|
||||
List<Integer> employmentFlagList = Arrays.asList(UserEmploymentFlagEnum.ON.getCode(), UserEmploymentFlagEnum.ENTRY_AUDIT.getCode(), UserEmploymentFlagEnum.RESIGNATION_AUDIT.getCode());
|
||||
|
||||
//校验身份证是否存在
|
||||
List<UserDO> userDOList = userRepository.getByIdCard(userE.getUserIdCard(),null);
|
||||
if(CollUtil.isNotEmpty(userDOList)){
|
||||
List<UserDO> userDOList = userRepository.getByIdCard(userE.getUserIdCard(), null);
|
||||
if (CollUtil.isNotEmpty(userDOList)) {
|
||||
List<UserE> userEList = userCoConvertor.convertDOsToEs(userDOList);
|
||||
userE.checkIdCardExist(userEList);
|
||||
}
|
||||
|
||||
//校验手机号
|
||||
List<UserDO> userList = userRepository.getListByPhone(userE.getPhone(),employmentFlagList);
|
||||
List<UserDO> userList = userRepository.getListByPhone(userE.getPhone(), null);
|
||||
Boolean addFlag = true;
|
||||
UserDO userDOUpdate = null;
|
||||
if(CollUtil.isNotEmpty(userList)){
|
||||
if(UserFlowFlagEnum.FIXED.getCode().equals(cmd.getFlowFlag())){
|
||||
if (CollUtil.isNotEmpty(userList)) {
|
||||
if (UserFlowFlagEnum.FIXED.getCode().equals(cmd.getFlowFlag())) {
|
||||
userList.forEach(u -> {
|
||||
if (UserEmploymentFlagEnum.ON.getCode().equals(u.getEmploymentFlag())
|
||||
|| UserEmploymentFlagEnum.ENTRY_AUDIT.getCode().equals(u.getEmploymentFlag())
|
||||
|| UserEmploymentFlagEnum.RESIGNATION_AUDIT.getCode().equals(u.getEmploymentFlag())){
|
||||
|| UserEmploymentFlagEnum.RESIGNATION_AUDIT.getCode().equals(u.getEmploymentFlag())) {
|
||||
throw new BizException("该固定用户存在未离职信息,无法入职");
|
||||
}
|
||||
});
|
||||
Optional<UserDO> optionalUserDO = userList.stream().filter(u -> u.getCorpinfoId().equals(AuthContext.getTenantId())).findFirst();
|
||||
if(optionalUserDO.isPresent()){
|
||||
Optional<UserDO> optionalUserDO = userList.stream().filter(u -> AuthContext.getTenantId().equals(u.getCorpinfoId()) || u.getCorpinfoId() == null).findFirst();
|
||||
if (optionalUserDO.isPresent()) {
|
||||
addFlag = false;
|
||||
userDOUpdate = optionalUserDO.get();
|
||||
}
|
||||
}else{
|
||||
List<UserE> userEList = userCoConvertor.convertDOsToEs(userList);
|
||||
} else {
|
||||
List<UserE> userEList = userCoConvertor.convertDOsToEs(userList);
|
||||
userE.checkXGfPhone(userEList);
|
||||
Optional<UserDO> optionalUserDO = userList.stream().filter(u -> u.getCorpinfoId().equals(AuthContext.getTenantId())).findFirst();
|
||||
if(optionalUserDO.isPresent()){
|
||||
Optional<UserDO> optionalUserDO = userList.stream()
|
||||
.filter(u -> AuthContext.getTenantId().equals(u.getCorpinfoId()) || u.getCorpinfoId() == null)
|
||||
.findFirst();
|
||||
if (optionalUserDO.isPresent()) {
|
||||
addFlag = false;
|
||||
userDOUpdate = optionalUserDO.get();
|
||||
}
|
||||
|
|
@ -449,7 +452,7 @@ public class UserAddExe {
|
|||
}
|
||||
|
||||
boolean res = false;
|
||||
if(addFlag){
|
||||
if (addFlag) {
|
||||
try {
|
||||
res = userGateway.addXgf(userE);
|
||||
} catch (Exception e) {
|
||||
|
|
@ -458,31 +461,10 @@ public class UserAddExe {
|
|||
if (!res) {
|
||||
throw new BizException("保存失败");
|
||||
}
|
||||
}else{
|
||||
//修改所有手机号的信息
|
||||
userE.resetPassword();
|
||||
userE.setEmploymentFlag(null);
|
||||
userE.setFlowFlag( null);
|
||||
userGateway.updateByPhone(userE);
|
||||
//修改.状态为在职
|
||||
userE.setId(userDOUpdate.getId());
|
||||
userE.setEmploymentFlag(UserEmploymentFlagEnum.ON.getCode());
|
||||
userE.setFlowFlag( cmd.getFlowFlag());
|
||||
userGateway.update(userE);
|
||||
} else {
|
||||
userGateway.updateXgf(userE, userDOUpdate.getId());
|
||||
|
||||
|
||||
//调用底座重新入职
|
||||
log.info("executeXgf,GBS获取用户信息{}",userDOUpdate.getId());
|
||||
SingleResponse<UserDetailCO> detail = userFacade.getDetail(userDOUpdate.getId());
|
||||
log.info("executeXgf,GBS获取用户信息返回: {}", JSONUtil.toJsonStr(detail));
|
||||
if(detail.isSuccess() && detail.getData() != null && !detail.getData().getJobStatusEnum()){
|
||||
UserUpdateQuitCmd userUpdateQuitCmd = new UserUpdateQuitCmd();
|
||||
userUpdateQuitCmd.setId(userDOUpdate.getId());
|
||||
log.info("executeXgf,GBS恢复用户入职请求: {}",JSONUtil.toJsonStr(userUpdateQuitCmd));
|
||||
Response response = userFacade.restoreJob(userUpdateQuitCmd);
|
||||
log.info("executeXgf,GBS恢复用户入职返回: {}",JSONUtil.toJsonStr(response));
|
||||
}else{
|
||||
log.info("executeXgf,GBS恢复用户入职不需要处理");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -496,13 +478,13 @@ public class UserAddExe {
|
|||
//增加用户入职企业
|
||||
UserCorpRecordE userCorpRecordE = new UserCorpRecordE();
|
||||
BeanUtils.copyProperties(cmd, userCorpRecordE);
|
||||
userCorpRecordE.initAdd(userE,corpInfoDO.getCorpName(),departmentDO.getName());
|
||||
userCorpRecordE.initAdd(userE, corpInfoDO.getCorpName(), departmentDO.getName());
|
||||
userCorpRecordGateway.add(userCorpRecordE);
|
||||
|
||||
// 增加用户变更记录
|
||||
UserChangeRecordE userChangeRecordE = new UserChangeRecordE();
|
||||
BeanUtils.copyProperties(cmd, userChangeRecordE);
|
||||
userChangeRecordE.initUserAdd( userE,corpInfoDO.getCorpName(),departmentDO.getName());
|
||||
userChangeRecordE.initUserAdd(userE, corpInfoDO.getCorpName(), departmentDO.getName());
|
||||
userChangeRecordGateway.add(userChangeRecordE);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -51,5 +51,7 @@ public interface UserGateway {
|
|||
|
||||
boolean addXgf(UserE userE);
|
||||
|
||||
void updateXgf(UserE userE, Long id);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ public class UserE extends BaseE {
|
|||
if (flag) {
|
||||
//需要修改,不是提示
|
||||
throw new BizException("当前手机号当前企业已存在,请联系管理员");
|
||||
}else{
|
||||
} else {
|
||||
throw new BizException("当前手机号已在其他企业存在,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
|
@ -359,24 +359,24 @@ public class UserE extends BaseE {
|
|||
|
||||
public void checkXGfPhone(List<UserE> userEList) {
|
||||
|
||||
if(UserFlowFlagEnum.FIXED.getCode().equals(this.getFlowFlag())){
|
||||
// this.checkPhone(userEList);
|
||||
|
||||
|
||||
}else{
|
||||
//判断在其他企业是否是固定人员
|
||||
List<UserE> userList = userEList.stream().filter(userE -> UserFlowFlagEnum.FIXED.getCode().equals(userE.getFlowFlag()))
|
||||
.filter(userE -> !userE.getCorpinfoId().equals(AuthContext.getTenantId())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(userList)) {
|
||||
throw new BizException("当前手机号已在其他企业属于固定人员");
|
||||
}
|
||||
//判断是否在当前企业存在
|
||||
//判断是否有当前企业
|
||||
boolean flag = userEList.stream().anyMatch(userE -> userE.getCorpinfoId().equals(AuthContext.getTenantId()));
|
||||
if (flag) {
|
||||
throw new BizException("当前手机号当前企业已存在");
|
||||
}
|
||||
//判断在其他企业是否是固定人员
|
||||
List<UserE> userList = userEList.stream().
|
||||
filter(userE -> UserFlowFlagEnum.FIXED.getCode().equals(userE.getFlowFlag()))
|
||||
.filter(userE -> !AuthContext.getTenantId().equals(userE.getCorpinfoId()))
|
||||
.filter(userE -> UserEmploymentFlagEnum.ON.getCode().equals(userE.getEmploymentFlag()))
|
||||
.filter(userE -> UserEmploymentFlagEnum.ENTRY_AUDIT.getCode().equals(userE.getEmploymentFlag()))
|
||||
.filter(userE -> UserEmploymentFlagEnum.RESIGNATION_AUDIT.getCode().equals(userE.getEmploymentFlag()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(userList)) {
|
||||
throw new BizException("当前手机号已在其他企业属于固定人员");
|
||||
}
|
||||
//判断是否在当前企业存在
|
||||
//判断是否有当前企业
|
||||
boolean flag = userEList.stream().anyMatch(userE -> AuthContext.getTenantId().equals(userE.getCorpinfoId()));
|
||||
if (flag) {
|
||||
throw new BizException("当前手机号当前企业已存在");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void checkIdCardExist(List<UserE> userEList) {
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ import com.zcloud.basic.info.domain.gateway.UserGateway;
|
|||
import com.zcloud.basic.info.domain.model.UserE;
|
||||
import com.zcloud.basic.info.persistence.dataobject.UserDO;
|
||||
import com.zcloud.basic.info.persistence.repository.UserRepository;
|
||||
import com.zcloud.gbscommon.utils.PageQueryHelper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
|
@ -190,5 +190,28 @@ public class UserGatewayImpl implements UserGateway {
|
|||
BeanUtils.copyProperties(userE, userDO);
|
||||
return userRepository.updatePassword(userDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateXgf(UserE userE, Long id) {
|
||||
if (StringUtils.isEmpty(userE.getUsername())) {
|
||||
userE.setUsername(userE.getPhone());
|
||||
}
|
||||
Integer flowFlag = userE.getFlowFlag();
|
||||
//修改所有手机号的信息
|
||||
userE.resetPassword();
|
||||
userE.setEmploymentFlag(null);
|
||||
userE.setFlowFlag(null);
|
||||
this.updateByPhone(userE);
|
||||
//修改.状态为在职
|
||||
if(id!= null){
|
||||
userE.setId(id);
|
||||
}
|
||||
|
||||
userE.setEmploymentFlag(UserEmploymentFlagEnum.ON.getCode());
|
||||
userE.setFlowFlag(flowFlag);
|
||||
this.update(userE);
|
||||
userRepository.updateXgf(userE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,5 +88,7 @@ public interface UserRepository extends BaseRepository<UserDO> {
|
|||
List<UserCorpInfoDO> getListByUserIds(List<Long> userIds);
|
||||
|
||||
List<UserDO> getByIdCard(String userIdCard, List<Integer> employmentFlagList);
|
||||
|
||||
void updateXgf(UserE userE);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,10 +22,8 @@ import com.jjb.saas.message.client.todotask.facade.BusTodoTaskFacade;
|
|||
import com.jjb.saas.system.client.role.facade.RoleFacade;
|
||||
import com.jjb.saas.system.client.role.response.RoleCO;
|
||||
import com.jjb.saas.system.client.user.facade.UserFacade;
|
||||
import com.jjb.saas.system.client.user.request.RoleDeptAddCmd;
|
||||
import com.jjb.saas.system.client.user.request.UserAddCmd;
|
||||
import com.jjb.saas.system.client.user.request.UserUpdateCmd;
|
||||
import com.jjb.saas.system.client.user.request.UserUpdatePasswordCmd;
|
||||
import com.jjb.saas.system.client.user.request.*;
|
||||
import com.jjb.saas.system.client.user.response.UserDetailCO;
|
||||
import com.zcloud.basic.info.domain.enums.MenuEnum;
|
||||
import com.zcloud.basic.info.domain.enums.UserEmploymentFlagEnum;
|
||||
import com.zcloud.basic.info.domain.enums.UserTypeEnum;
|
||||
|
|
@ -44,6 +42,7 @@ import org.apache.dubbo.config.annotation.DubboReference;
|
|||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
|
@ -570,5 +569,43 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
|
|||
public List<UserCorpInfoDO> getListByUserIds(List<Long> userIds) {
|
||||
return userMapper.getListByUserIds(userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateXgf(UserE userE) {
|
||||
SingleResponse<UserDetailCO> detail = null;
|
||||
//调用底座重新入职
|
||||
try {
|
||||
log.info("updateXgf,GBS获取用户信息{}", userE.getId());
|
||||
detail = userFacade.getDetail(userE.getId());
|
||||
log.info("updateXgf,GBS获取用户信息返回: {}", JSONUtil.toJsonStr(detail));
|
||||
} catch (Exception e) {
|
||||
log.error("updateXgf,GBS获取用户信息失败: {}", e.getMessage());
|
||||
}
|
||||
|
||||
if (detail != null && detail.isSuccess() && detail.getData() != null && !detail.getData().getJobStatusEnum()) {
|
||||
UserUpdateQuitCmd userUpdateQuitCmd = new UserUpdateQuitCmd();
|
||||
userUpdateQuitCmd.setId(userE.getId());
|
||||
log.info("updateXgf,GBS恢复用户入职请求: {}", JSONUtil.toJsonStr(userUpdateQuitCmd));
|
||||
Response response = userFacade.restoreJob(userUpdateQuitCmd);
|
||||
log.info("updateXgf,GBS恢复用户入职返回: {}", JSONUtil.toJsonStr(response));
|
||||
} else {
|
||||
com.jjb.saas.system.client.user.request.UserAddCmd userAddCmd = new com.jjb.saas.system.client.user.request.UserAddCmd();
|
||||
userAddCmd.setAccount(userE.getUsername());
|
||||
userAddCmd.setName(userE.getName());
|
||||
RoleDeptAddCmd roleDeptAddCmd = new RoleDeptAddCmd();
|
||||
roleDeptAddCmd.setRoleId(userE.getRoleId());
|
||||
roleDeptAddCmd.setDeptId(userE.getDepartmentId());
|
||||
List<RoleDeptAddCmd> roleDeptAddCmdList = Collections.singletonList(roleDeptAddCmd);
|
||||
userAddCmd.setRoleDepts(roleDeptAddCmdList);
|
||||
userAddCmd.setId(userE.getId());
|
||||
log.info("GBS新增用户开始,用户信息:{}", JSONUtil.toJsonStr(userAddCmd));
|
||||
SingleResponse<Long> gbsResult = userFacade.add(userAddCmd);
|
||||
log.info("GBS新增用户结束,用户id:{},结果:{}", gbsResult.getData(), JSONUtil.toJsonStr(gbsResult));
|
||||
if (!gbsResult.isSuccess()) {
|
||||
throw new RuntimeException("GBS新增用户失败,用户id:" + gbsResult.getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue