|
|
|
@ -2,7 +2,7 @@ package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.IPersonnelService;
|
|
|
|
|
import cn.estsh.i3plus.core.apiservice.util.HqlModelPack;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
@ -15,14 +15,18 @@ import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack;
|
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ImppRedis;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -67,6 +71,8 @@ public class PersonnelServiceService implements IPersonnelService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private SysPositionRepository positionRDao;
|
|
|
|
|
|
|
|
|
|
@Resource(name="redisCore")
|
|
|
|
|
protected ImppRedis redisCore;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public SysUser saveSysUser(SysUser user) {
|
|
|
|
@ -334,6 +340,67 @@ public class PersonnelServiceService implements IPersonnelService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@ApiOperation(value = "重置密码检查")
|
|
|
|
|
public Integer checkSysUserResetPassword(SysUser user) {
|
|
|
|
|
LOGGER.debug("平台用户岗位 SysUser user:{}", user);
|
|
|
|
|
Integer num = 0;
|
|
|
|
|
if(user != null){
|
|
|
|
|
String day = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.format(new Date());
|
|
|
|
|
String redisKey = CommonConstWords.REDIS_PREFIX_USER_RESET_PASSWORD + "-" + day + "-" + user.getId();
|
|
|
|
|
Object redisValue = redisCore.getObject(redisKey);
|
|
|
|
|
num = redisValue == null ? 1 : Integer.parseInt(redisValue.toString()) + 1;
|
|
|
|
|
|
|
|
|
|
if(num > CommonConstWords.LOCK_USER_RESET_PASSWORD){
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.USER_PERMISSION_RUN_OUT.getCode())
|
|
|
|
|
.setErrorDetail("重置密码次数已使用完毕")
|
|
|
|
|
.setErrorSolution("请明日再次使用")
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
redisCore.putObject(redisKey,num,CommonConstWords.REDIS_TIME_DAY_ONE);
|
|
|
|
|
}
|
|
|
|
|
return num;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void checkSysPositionRef(Long positionId) {
|
|
|
|
|
LOGGER.debug("平台岗位 SysPosition positionId:{}", positionId);
|
|
|
|
|
|
|
|
|
|
if(positionId != null){
|
|
|
|
|
long positionCount = positionRDao.findByPropertyCount("parentId",positionId);
|
|
|
|
|
if (positionCount >= 1) {
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
|
|
|
|
|
.setErrorDetail("存在相关岗位信息无法删除!")
|
|
|
|
|
.setErrorSolution("请先删除子集信息在操作")
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long refPositionCount = refUserPositionRDao.findByPropertyCount("positionId",positionId);
|
|
|
|
|
if (refPositionCount >= 1) {
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
|
|
|
|
|
.setErrorDetail("存在用户关系引用信息无法删除!")
|
|
|
|
|
.setErrorSolution("请先删除用户关系信息再操作")
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long refUserInfoCount = userInfoRDao.findByPropertyCount("positionId",positionId);
|
|
|
|
|
if (refUserInfoCount >= 1) {
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
|
|
|
|
|
.setErrorDetail("存在用户信息无法删除!")
|
|
|
|
|
.setErrorSolution("请先删除用户引用信息再操作")
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/************************************ 用户唯一检查 ****************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -630,6 +697,52 @@ public class PersonnelServiceService implements IPersonnelService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void refreshRefSysUserInfoPositionRdd(Long positionId) {
|
|
|
|
|
List<Long> result = new ArrayList<>(); // 需要更新的用户ID 集合
|
|
|
|
|
|
|
|
|
|
// 更新关系表中数据
|
|
|
|
|
if(positionId != null){
|
|
|
|
|
SysPosition position = positionRDao.getById(positionId);
|
|
|
|
|
if(position != null){
|
|
|
|
|
List<SysRefUserPosition> list = refUserPositionRDao.findByProperty("positionId", position.getId());
|
|
|
|
|
if(list != null && list.size() > 0){
|
|
|
|
|
|
|
|
|
|
// 更新关系表中的冗余信息
|
|
|
|
|
refUserPositionRDao.updateByProperties(
|
|
|
|
|
"positionId",position.getId(),
|
|
|
|
|
"positionNameRdd", position.getName());
|
|
|
|
|
|
|
|
|
|
// 更新父节点冗余信息
|
|
|
|
|
positionRDao.updateByProperties("parentId",position.getId(),
|
|
|
|
|
"parentNameRdd",position.getName());
|
|
|
|
|
|
|
|
|
|
for (SysRefUserPosition ref : list) {
|
|
|
|
|
result.add(ref.getUserId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 删除关系表中数据
|
|
|
|
|
refUserPositionRDao.deleteByProperty("positionId", positionId);
|
|
|
|
|
|
|
|
|
|
// 获取需要更新的用户
|
|
|
|
|
StringBuffer strWhere = new StringBuffer();
|
|
|
|
|
List<String> nameList = null;
|
|
|
|
|
HqlPack.getInPack(StringUtils.join(result, ","), "userId", strWhere);
|
|
|
|
|
List<SysUserInfo> infoList = userInfoRDao.findByHqlWhere(strWhere.toString());
|
|
|
|
|
|
|
|
|
|
// 更新用户的冗余信息
|
|
|
|
|
if(infoList != null && infoList.size() > 0){
|
|
|
|
|
for (SysUserInfo info : infoList) {
|
|
|
|
|
List<SysRefUserPosition> list = refUserPositionRDao.findByProperty("userId", info.getId());
|
|
|
|
|
if (list != null) {
|
|
|
|
|
for (SysRefUserPosition ref : list) {
|
|
|
|
|
nameList.add(ref.getPositionNameRdd());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
info.setPositionNamesRdd(StringUtils.join(nameList, ","));
|
|
|
|
|
userInfoRDao.save(info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|