人员修改组织,同步修改考勤组组织
This commit is contained in:
parent
7714717268
commit
01a9f56eb8
|
|
@ -59,8 +59,11 @@ public class SysUserController extends BaseController {
|
|||
@Log(title = "系统管理->人员信息->查询人员列表", businessType = BusinessType.QUERY)
|
||||
public TableDataInfo list(SysUser bean) {
|
||||
try{
|
||||
// List<SysUser> list = userService.selectUserList(bean);
|
||||
// return endPage(list);
|
||||
startPage();
|
||||
List<SysUser> list = userService.selectUserList(bean);
|
||||
return endPage(list);
|
||||
return getDataTable(list);
|
||||
}catch (Exception e){
|
||||
logger.error(e.toString(),e);
|
||||
}
|
||||
|
|
@ -72,8 +75,11 @@ public class SysUserController extends BaseController {
|
|||
@Log(title = "系统管理->分公司项目部管理->权限分配->查询人员列表", businessType = BusinessType.QUERY)
|
||||
public TableDataInfo listPro(SysUser bean) {
|
||||
try{
|
||||
// List<SysUser> list = userService.selectUserList(bean);
|
||||
// return endPage(list);
|
||||
startPage();
|
||||
List<SysUser> list = userService.selectUserList(bean);
|
||||
return endPage(list);
|
||||
return getDataTable(list);
|
||||
}catch (Exception e){
|
||||
logger.error(e.toString(),e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.bonus.common.core.web.domain.AjaxResult;
|
|||
import com.bonus.system.api.domain.MapVo;
|
||||
import com.bonus.system.api.domain.SysDictData;
|
||||
import com.bonus.system.api.domain.SysRole;
|
||||
import com.bonus.system.att.entity.OrgChangeBean;
|
||||
import com.bonus.system.basic.domain.SysUserOrg;
|
||||
import com.bonus.system.basic.domain.SysUserPost;
|
||||
import com.bonus.system.basic.domain.SysUserRole;
|
||||
|
|
@ -221,4 +222,8 @@ public interface SysUserMapper
|
|||
int updateIsFace(SysUser user);
|
||||
|
||||
int checkPersonAssignment(SysUser bean);
|
||||
|
||||
Long getUserAttGroupByUserId(Long userId);
|
||||
|
||||
void updateAttOrgByUserId(OrgChangeBean item);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ import com.bonus.system.api.domain.MapVo;
|
|||
import com.bonus.system.api.domain.SysDictData;
|
||||
import com.bonus.system.api.domain.SysRole;
|
||||
import com.bonus.system.api.model.LoginUser;
|
||||
import com.bonus.system.att.entity.OrgChangeBean;
|
||||
import com.bonus.system.att.service.OrgChangeService;
|
||||
import com.bonus.system.basic.domain.SysUserOrg;
|
||||
import com.bonus.system.basic.domain.SysUserPost;
|
||||
import com.bonus.system.basic.domain.SysUserRole;
|
||||
|
|
@ -57,6 +59,9 @@ public class SysUserServiceImpl implements SysUserService
|
|||
@Resource(name = "SubOrgService")
|
||||
private SubOrgServiceImpl subOrgServiceImpl;
|
||||
|
||||
@Resource(name = "OrgChangeService")
|
||||
private OrgChangeService orgChangeService;
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
|
|
@ -100,7 +105,7 @@ public class SysUserServiceImpl implements SysUserService
|
|||
@Override
|
||||
public List<SysUser> selectUserList(SysUser bean) {
|
||||
List<SysUser> list = userMapper.selectUserList(bean);
|
||||
if (list.size()>0){
|
||||
if (!list.isEmpty()){
|
||||
for (SysUser sysUser : list) {
|
||||
//角色集合
|
||||
Long[] roleIds = userMapper.getRoleIdsByUserId(sysUser.getUserId());
|
||||
|
|
@ -292,6 +297,24 @@ public class SysUserServiceImpl implements SysUserService
|
|||
userMapper.deleteUserRoleByUserId(userId);
|
||||
insertUserRole(user);
|
||||
//删除用户与组织关联
|
||||
//旧组织
|
||||
Long[] orgIdsByUserId = userMapper.getOrgIdsByUserId(userId);
|
||||
//新组织
|
||||
Long[] orgIds = user.getOrgIds();
|
||||
//绑定考勤组组织
|
||||
Long orgId = userMapper.getUserAttGroupByUserId(userId);
|
||||
if (orgId == null || containsOrgId(orgIds,orgId)) {
|
||||
//没有考勤组或新变换的组织包含考勤组组织,不变
|
||||
}else{
|
||||
List<Long> uniqueInOrgIds = findUniqueInOrgIds(orgIds, orgIdsByUserId);
|
||||
if(!uniqueInOrgIds.isEmpty()){
|
||||
OrgChangeBean item = new OrgChangeBean();
|
||||
item.setOldOrgId(orgId);
|
||||
item.setNewOrgId(uniqueInOrgIds.get(0));
|
||||
item.setUserId(userId);
|
||||
userMapper.updateAttOrgByUserId(item);
|
||||
}
|
||||
}
|
||||
userMapper.deleteUserOrgByUserId(userId);
|
||||
insertUserOrg(user);
|
||||
return userMapper.updateUser(user);
|
||||
|
|
@ -301,6 +324,21 @@ public class SysUserServiceImpl implements SysUserService
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean containsOrgId(Long[] orgIds, Long orgId) {
|
||||
// 将数组转换为 List
|
||||
return Arrays.asList(orgIds).contains(orgId);
|
||||
}
|
||||
|
||||
public static List<Long> findUniqueInOrgIds(Long[] orgIds, Long[] orgIdsByUserId) {
|
||||
// 将两个数组转换为 Set
|
||||
Set<Long> orgIdSet = new HashSet<>(Arrays.asList(orgIds));
|
||||
Set<Long> orgIdByUserSet = new HashSet<>(Arrays.asList(orgIdsByUserId));
|
||||
// 计算差集:只保留在 orgIds 中的元素
|
||||
orgIdSet.removeAll(orgIdByUserSet);
|
||||
// 将结果转换回数组
|
||||
return new ArrayList<>(orgIdSet);
|
||||
}
|
||||
|
||||
@Resource(name = "ValidatorsUtils")
|
||||
private ValidatorsUtils validatorsUtils;
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
|
|
|||
|
|
@ -119,7 +119,8 @@
|
|||
where id = #{id}
|
||||
</update>
|
||||
<update id="updateOrgByUserId">
|
||||
update sys_user_org set org_id = #{newOrgId} where user_id = #{userId} and org_id = #{oldOrgId}
|
||||
update sys_user_org set org_id = #{newOrgId} where user_id = #{userId} and org_id = #{oldOrgId} and is_active = 1;
|
||||
update att_group_person_relation set org_id = #{newOrgId} where user_id = #{userId} and org_id = #{oldOrgId};
|
||||
</update>
|
||||
<update id="updateAttGroupByUserId">
|
||||
update att_group_person_relation set group_id = #{newAttGroup},org_id = #{newOrgId} where user_id = #{userId} and group_id = #{oldAttGroup}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,9 @@
|
|||
update sys_user set is_face = 0 where user_id = #{userId};
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateAttOrgByUserId">
|
||||
update att_group_person_relation set org_id = #{newOrgId} where user_id = #{userId} and org_id = #{oldOrgId};
|
||||
</update>
|
||||
|
||||
<select id="selectUserByUserName" resultType="com.bonus.system.api.domain.SysUser">
|
||||
select * from sys_user su
|
||||
|
|
@ -293,4 +296,8 @@
|
|||
agpr.user_id = #{userId} and agpr.is_active = '1' and ag.id is not null
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="getUserAttGroupByUserId" resultType="java.lang.Long">
|
||||
select org_id from att_group_person_relation where user_id=#{userId} and is_active = 1 limit 1
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue