package jnpf.permission.service.impl; import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import com.baomidou.dynamic.datasource.annotation.DSTransactional; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.github.pagehelper.page.PageMethod; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.google.common.collect.Lists; import jnpf.base.DictionaryDataApi; import jnpf.base.Pagination; import jnpf.base.SysConfigApi; import jnpf.base.UserInfo; import jnpf.base.entity.DictionaryDataEntity; import jnpf.base.entity.SuperBaseEntity; import jnpf.base.service.SuperServiceImpl; import jnpf.base.vo.DownloadVO; import jnpf.config.ConfigValueUtil; import jnpf.constant.*; import jnpf.database.source.DbBase; import jnpf.database.util.DataSourceUtil; import jnpf.database.util.TenantDataSourceUtil; import jnpf.emnus.SysParamEnum; import jnpf.entity.FileParameter; import jnpf.exception.DataException; import jnpf.model.BaseSystemInfo; import jnpf.model.tenant.TenantVO; import jnpf.permission.entity.*; import jnpf.permission.mapper.*; import jnpf.permission.model.SystemParamModel; import jnpf.permission.model.organize.OrganizeSelectorVO; import jnpf.permission.model.rolerelaiton.RoleRelationPage; import jnpf.permission.model.user.UserIdListVo; import jnpf.permission.model.user.UserRelationIds; import jnpf.permission.model.user.UserSystemCountModel; import jnpf.permission.model.user.mod.UserConditionModel; import jnpf.permission.model.user.mod.UserImportModel; import jnpf.permission.model.user.page.PageUser; import jnpf.permission.model.user.page.PaginationUser; import jnpf.permission.model.user.page.UserPagination; import jnpf.permission.model.user.vo.BaseInfoVo; import jnpf.permission.model.user.vo.UserExportExceptionVO; import jnpf.permission.model.user.vo.UserExportVO; import jnpf.permission.model.user.vo.UserImportVO; import jnpf.permission.service.UserService; import jnpf.permission.util.UserUtil; import jnpf.util.*; import lombok.Cleanup; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Workbook; import org.dromara.x.file.storage.core.FileInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; import static jnpf.util.Constants.ADMIN_KEY; /** * 用户信息 * * @author JNPF开发平台组 * @version V3.1.0 * @copyright 引迈信息技术有限公司 * @date 2019年9月26日 上午9:18 */ @Service public class UserServiceImpl extends SuperServiceImpl implements UserService { @Autowired private RedisUtil redisUtil; @Autowired private CacheKeyUtil cacheKeyUtil; @Autowired private DataSourceUtil dataSourceUtil; @Autowired private ConfigValueUtil configValueUtil; @Autowired private SysConfigApi sysconfigApi; @Autowired private UserUtil userUtil; @Autowired private DictionaryDataApi dictionaryDataService; @Autowired private GroupMapper groupMapper; @Autowired private RoleMapper roleMapper; @Autowired private OrganizeMapper organizeMapper; @Autowired private PositionMapper positionMapper; @Autowired private SocialsUserMapper socialsUserMapper; @Autowired private UserRelationMapper userRelationMapper; @Autowired private RoleRelationMapper roleRelationMapper; @Autowired private UserOldPasswordMapper userOldPasswordMapper; @Autowired private PermissionGroupMapper permissionGroupMapper; @Override public List getList(UserPagination pagination) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.lambda().ne(UserEntity::getAccount, ADMIN_KEY); boolean filterLastTime = false; //关键字(账户、姓名、手机) if (!StringUtil.isEmpty(pagination.getKeyword())) { filterLastTime = true; queryWrapper.lambda().and( t -> t.like(UserEntity::getAccount, pagination.getKeyword()) .or().like(UserEntity::getRealName, pagination.getKeyword()) .or().like(UserEntity::getMobilePhone, pagination.getKeyword()) ); } if (pagination.getEnabledMark() != null) { if (Objects.equals(pagination.getEnabledMark(), 1)) { queryWrapper.lambda().ne(UserEntity::getEnabledMark, 0); } else { queryWrapper.lambda().eq(UserEntity::getEnabledMark, pagination.getEnabledMark()); } } if (StringUtil.isNotEmpty(pagination.getGender())) { queryWrapper.lambda().eq(UserEntity::getGender, pagination.getGender()); } //有分组id过滤 if (StringUtil.isNotEmpty(pagination.getGroupId())) { List listUser = userRelationMapper.getListByObjectId(pagination.getGroupId(), PermissionConst.GROUP); List users = listUser.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList()); if (CollectionUtil.isEmpty(users)) { return pagination.setData(Collections.EMPTY_LIST, 0); } List> lists = Lists.partition(users, 1000); queryWrapper.lambda().and(t -> { for (List userItem : lists) { t.in(UserEntity::getId, userItem).or(); } }); } //有岗位id if (StringUtil.isNotEmpty(pagination.getPositionId())) { List listUser = userRelationMapper.getListByObjectId(pagination.getPositionId(), PermissionConst.POSITION); List users = listUser.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList()); if (CollectionUtil.isEmpty(users)) { return pagination.setData(Collections.EMPTY_LIST, 0); } List> lists = Lists.partition(users, 1000); queryWrapper.lambda().and(t -> { for (List userItem : lists) { t.in(UserEntity::getId, userItem).or(); } }); } else if (StringUtil.isNotEmpty(pagination.getOrganizeId())) { //有组织id List orgIds = new ArrayList<>(); orgIds.add(pagination.getOrganizeId()); if (Objects.equals(pagination.getShowSubOrganize(), 1)) { List allChild = organizeMapper.getAllChild(pagination.getOrganizeId()); orgIds.addAll(allChild.stream().map(OrganizeEntity::getId).collect(Collectors.toList())); } List listPost = positionMapper.getListByOrgIds(orgIds); List listPostId = listPost.stream().map(PositionEntity::getId).collect(Collectors.toList()); List listUser = userRelationMapper.getListByObjectIdAll(listPostId); List users = listUser.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList()); if (CollectionUtil.isEmpty(users)) { return pagination.setData(Collections.EMPTY_LIST, 0); } List> lists = Lists.partition(users, 1000); queryWrapper.lambda().and(t -> { for (List userItem : lists) { t.in(UserEntity::getId, userItem).or(); } }); } //有角色id if (StringUtil.isNotEmpty(pagination.getRoleId())) { List listUser = roleRelationMapper.getListByRoleId(pagination.getRoleId(), PermissionConst.USER); List users = listUser.stream().map(RoleRelationEntity::getObjectId).collect(Collectors.toList()); if (CollectionUtil.isEmpty(users)) { return pagination.setData(Collections.EMPTY_LIST, 0); } List> lists = Lists.partition(users, 1000); queryWrapper.lambda().and(t -> { for (List userItem : lists) { t.in(UserEntity::getId, userItem).or(); } }); } long count = this.count(queryWrapper); queryWrapper.lambda().select(UserEntity::getId); queryWrapper.lambda().orderByAsc(UserEntity::getSortCode).orderByDesc(UserEntity::getCreatorTime); if (filterLastTime) { queryWrapper.lambda().orderByDesc(UserEntity::getLastModifyTime); } if (Objects.equals(pagination.getDataType(), 1)) { return this.list(queryWrapper); } Page page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize(), count, false); page.setOptimizeCountSql(false); IPage iPage = this.page(page, queryWrapper); if (!iPage.getRecords().isEmpty()) { List ids = iPage.getRecords().stream().map(m -> m.getId()).collect(Collectors.toList()); queryWrapper = new QueryWrapper<>(); queryWrapper.lambda().in(UserEntity::getId, ids); queryWrapper.lambda().orderByAsc(UserEntity::getSortCode).orderByDesc(UserEntity::getCreatorTime); if (filterLastTime) { queryWrapper.lambda().orderByDesc(UserEntity::getLastModifyTime); } iPage.setRecords(this.list(queryWrapper)); } return pagination.setData(iPage.getRecords(), iPage.getTotal()); } @Override public List getList(boolean filterEnabledMark) { return this.baseMapper.getList(filterEnabledMark); } @Override public List getUserNameList(List idList) { return this.baseMapper.getUserNameList(idList); } @Override public List getUserNameList(Set idList) { return this.baseMapper.getUserNameList(idList); } @Override public Map getUserMap() { return this.baseMapper.getUserMap(); } @Override public Map getUserNameAndIdMap() { return this.baseMapper.getUserNameAndIdMap(); } @Override public Map getUserNameAndIdMap(boolean enabledMark) { return this.baseMapper.getUserNameAndIdMap(enabledMark); } @Override public UserEntity getByRealName(String realName) { return this.baseMapper.getByRealName(realName); } @Override public UserEntity getByRealName(String realName, String account) { return this.baseMapper.getByRealName(realName, account); } @Override public List getAdminList() { return this.baseMapper.getAdminList(); } @Override public List getList(PaginationUser pagination, String organizeId, Boolean flag, Boolean filter, Integer enabledMark, String gender) { // 定义变量判断是否需要使用修改时间倒序 boolean filterLastTime = false; String userId = UserProvider.getUser().getUserId(); QueryWrapper queryWrapper = new QueryWrapper<>(); if (flag) { queryWrapper.lambda().ne(UserEntity::getId, userId); } if (filter) { queryWrapper.lambda().ne(UserEntity::getAccount, ADMIN_KEY); } //组织机构 if (!StringUtil.isEmpty(organizeId)) { List orgIdList = organizeMapper.getUnderOrganizationss(organizeId); orgIdList.add(organizeId); PageHelper.startPage((int) pagination.getCurrentPage(), (int) pagination.getPageSize(), false); //组织数量很多时解析SQL很慢, COUNT不解析SQL不去除ORDERBY PageMethod.getLocalPage().keepOrderBy(true); // 用户id List query = new ArrayList<>(16); String dbSchema = null; // 判断是否为多租户 if (configValueUtil.isMultiTenancy() && DbBase.DM.equalsIgnoreCase(dataSourceUtil.getDbType())) { dbSchema = dataSourceUtil.getDbSchema(); } String keyword = null; if (StringUtil.isNotEmpty(pagination.getKeyword())) { keyword = "%" + pagination.getKeyword() + "%"; } query = this.baseMapper.query(orgIdList, keyword, dbSchema, enabledMark, gender); Long count = this.baseMapper.count(orgIdList, keyword, dbSchema, enabledMark, gender); PageInfo pageInfo = new PageInfo(query); // 赋值分页参数 pagination.setTotal(count); pagination.setCurrentPage(pageInfo.getPageNum()); pagination.setPageSize(pageInfo.getPageSize()); if (pageInfo.getList().size() > 0) { // 存放返回结果 QueryWrapper queryWrapper1 = new QueryWrapper<>(); List> lists = Lists.partition(query, 1000); queryWrapper1.lambda().and(t -> { for (List id : lists) { t.or().in(UserEntity::getId, id); } }); queryWrapper1.lambda().orderByAsc(UserEntity::getSortCode).orderByDesc(UserEntity::getCreatorTime); List entityList = getBaseMapper().selectList(queryWrapper1); return entityList; } else { return new ArrayList<>(); } } //关键字(账户、姓名、手机) if (!StringUtil.isEmpty(pagination.getKeyword())) { filterLastTime = true; queryWrapper.lambda().and( t -> t.like(UserEntity::getAccount, pagination.getKeyword()) .or().like(UserEntity::getRealName, pagination.getKeyword()) .or().like(UserEntity::getMobilePhone, pagination.getKeyword()) ); } if (enabledMark != null) { if (Objects.equals(pagination.getEnabledMark(), 1)) { queryWrapper.lambda().ne(UserEntity::getEnabledMark, 0); } else { queryWrapper.lambda().eq(UserEntity::getEnabledMark, pagination.getEnabledMark()); } } if (StringUtil.isNotEmpty(gender)) { queryWrapper.lambda().eq(UserEntity::getGender, gender); } //不分页 if (Objects.equals(pagination.getDataType(), 1)) { queryWrapper.lambda().orderByAsc(UserEntity::getSortCode).orderByDesc(UserEntity::getCreatorTime); if (filterLastTime) { queryWrapper.lambda().orderByDesc(UserEntity::getLastModifyTime); } return this.list(queryWrapper); } //分页 //排序 long count = this.count(queryWrapper); queryWrapper.lambda().select(UserEntity::getId); queryWrapper.lambda().orderByAsc(UserEntity::getSortCode).orderByDesc(UserEntity::getCreatorTime); if (filterLastTime) { queryWrapper.lambda().orderByDesc(UserEntity::getLastModifyTime); } Page page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize(), count, false); page.setOptimizeCountSql(false); IPage iPage = this.page(page, queryWrapper); if (!iPage.getRecords().isEmpty()) { List ids = iPage.getRecords().stream().map(m -> m.getId()).collect(Collectors.toList()); queryWrapper = new QueryWrapper<>(); queryWrapper.lambda().in(UserEntity::getId, ids); queryWrapper.lambda().orderByAsc(UserEntity::getSortCode).orderByDesc(UserEntity::getCreatorTime); if (filterLastTime) { queryWrapper.lambda().orderByDesc(UserEntity::getLastModifyTime); } iPage.setRecords(this.list(queryWrapper)); } return pagination.setData(iPage.getRecords(), iPage.getTotal()); } @Override public List getList(PageUser pagination, Boolean filterCurrentUser) { return this.baseMapper.getList(pagination, filterCurrentUser); } @Override public List getUserPage(Pagination pagination) { return this.baseMapper.getUserPage(pagination); } @Override public List getListByOrganizeId(String organizeId, String keyword) { List userIds = userRelationMapper.getListByObjectId(organizeId, PermissionConst.ORGANIZE).stream() .map(UserRelationEntity::getUserId).collect(Collectors.toList()); if (userIds.size() > 0) { QueryWrapper query = new QueryWrapper<>(); if (userIds.size() > 0) { query.lambda().in(UserEntity::getId, userIds); } // 通过关键字查询 if (StringUtil.isNotEmpty(keyword)) { query.lambda().and( t -> t.like(UserEntity::getAccount, keyword) .or().like(UserEntity::getRealName, keyword) ); } // 只查询正常的用户 query.lambda().ne(UserEntity::getEnabledMark, 0); query.lambda().orderByAsc(UserEntity::getSortCode).orderByDesc(UserEntity::getCreatorTime); return this.list(query); } return new ArrayList<>(0); } @Override public List getListByManagerId(String managerId, String keyword) { return this.baseMapper.getListByManagerId(managerId, keyword); } @Override public UserEntity getInfo(String id) { return this.baseMapper.getInfo(id); } @Override public UserEntity getUserByAccount(String account) { return this.baseMapper.getUserByAccount(account); } @Override public UserEntity getUserByMobile(String mobile) { return this.baseMapper.getUserByMobile(mobile); } @Override public Boolean setAdminListByIds(List adminIds) { return this.setAdminListByIds(adminIds); } @Override public boolean isExistByAccount(String account) { return this.baseMapper.isExistByAccount(account); } @Override @DSTransactional public Boolean create(UserEntity entity) throws Exception { beforeCheck(); if (StringUtil.isNotEmpty(entity.getGroupId()) && entity.getGroupId().contains(",")) { entity.setGroupId(null); } //添加用户 初始化 String userId = RandomUtil.uuId(); if (StringUtil.isNotEmpty(entity.getId())) { userId = entity.getId(); } BaseSystemInfo sysInfo = sysconfigApi.getSysInfo(UserProvider.getUser().getTenantId()); entity.setPassword(Md5Util.getStringMd5(sysInfo.getNewUserDefaultPassword())); entity.setId(userId); if (StringUtil.isEmpty(entity.getAccount())) { throw new DataException(MsgCode.PS007.get()); } if (StringUtil.isEmpty(entity.getRealName())) { throw new DataException(MsgCode.PS008.get()); } //获取头像 String oldHeadIcon = entity.getHeadIcon(); if (StringUtil.isEmpty(oldHeadIcon)) { entity.setHeadIcon("001.png"); } else { //获取头像 String[] headIcon = oldHeadIcon.split("/"); if (headIcon.length > 0) { entity.setHeadIcon(headIcon[headIcon.length - 1]); } } entity.setSecretkey(RandomUtil.uuId()); entity.setPassword(Md5Util.getStringMd5(entity.getPassword().toLowerCase() + entity.getSecretkey().toLowerCase())); entity.setIsAdministrator(0); entity.setCreatorUserId(UserProvider.getUser().getUserId()); String groupId = entity.getGroupId(); if (StringUtil.isNotEmpty(groupId)) { UserRelationEntity groupRelation = new UserRelationEntity(); groupRelation.setId(RandomUtil.uuId()); groupRelation.setObjectType(PermissionConst.GROUP); groupRelation.setObjectId(groupId); groupRelation.setUserId(entity.getId()); groupRelation.setCreatorTime(entity.getCreatorTime()); groupRelation.setCreatorUserId(entity.getCreatorUserId()); userRelationMapper.insert(groupRelation); } //添加岗位关系 if (StringUtil.isNotEmpty(entity.getPositionId())) { String[] split = entity.getPositionId().split(","); for (String s : split) { UserRelationEntity posRelation = new UserRelationEntity(); posRelation.setId(RandomUtil.uuId()); posRelation.setObjectType(PermissionConst.POSITION); posRelation.setObjectId(s); posRelation.setUserId(entity.getId()); posRelation.setCreatorTime(entity.getCreatorTime()); posRelation.setCreatorUserId(entity.getCreatorUserId()); userRelationMapper.insert(posRelation); } } //添加组织关系 if (StringUtil.isNotEmpty(entity.getOrganizeId())) { String[] split = entity.getOrganizeId().split(","); for (String s : split) { UserRelationEntity posRelation = new UserRelationEntity(); posRelation.setId(RandomUtil.uuId()); posRelation.setObjectType(PermissionConst.ORGANIZE); posRelation.setObjectId(s); posRelation.setUserId(entity.getId()); posRelation.setCreatorTime(entity.getCreatorTime()); posRelation.setCreatorUserId(entity.getCreatorUserId()); userRelationMapper.insert(posRelation); } } //添加角色关系 if (StringUtil.isNotEmpty(entity.getRoleId())) { String[] split = entity.getRoleId().split(","); for (String s : split) { RoleRelationEntity posRelation = new RoleRelationEntity(); posRelation.setId(RandomUtil.uuId()); posRelation.setObjectType(PermissionConst.USER); posRelation.setObjectId(entity.getId()); posRelation.setRoleId(s); posRelation.setCreatorTime(entity.getCreatorTime()); posRelation.setCreatorUserId(entity.getCreatorUserId()); roleRelationMapper.insert(posRelation); } } else { //创建没有角色的时候,默认使用者 RoleEntity byEnCode = roleMapper.getByEnCode(PermissionConst.USER_CODE); RoleRelationEntity posRelation = new RoleRelationEntity(); posRelation.setId(RandomUtil.uuId()); posRelation.setObjectType(PermissionConst.USER); posRelation.setObjectId(entity.getId()); posRelation.setRoleId(byEnCode.getId()); posRelation.setCreatorTime(entity.getCreatorTime()); posRelation.setCreatorUserId(entity.getCreatorUserId()); roleRelationMapper.insert(posRelation); } //写入时清空 entity.setGroupId(""); entity.setPositionId(""); entity.setOrganizeId(""); entity.setRoleId(""); entity.setQuickQuery(PinYinUtil.getFirstSpell(entity.getRealName())); //清理获取所有用户的redis缓存 redisUtil.remove(cacheKeyUtil.getAllUser()); this.save(entity); return true; } /** * 验证是否还有额度 */ @Override public void beforeCheck() { String tenantId = UserProvider.getUser().getTenantId(); // 开启多租住的 if (StringUtil.isNotEmpty(tenantId)) { TenantVO cacheTenantInfo = TenantDataSourceUtil.getCacheTenantInfo(tenantId); long count = this.count(); if (cacheTenantInfo.getAccountNum() != 0 && cacheTenantInfo.getAccountNum() < count) { throw new DataException(MsgCode.PS009.get()); } } } @Override @DSTransactional public Boolean update(String userId, UserEntity entity) throws Exception { //更新用户 entity.setId(userId); if (StringUtil.isEmpty(entity.getAccount())) { throw new DataException(MsgCode.PS007.get()); } if (StringUtil.isEmpty(entity.getRealName())) { throw new DataException(MsgCode.PS008.get()); } //获取头像 String oldHeadIcon = entity.getHeadIcon(); if (StringUtil.isEmpty(oldHeadIcon)) { entity.setHeadIcon("001.png"); } entity.setLastModifyTime(DateUtil.getNowDate()); entity.setLastModifyUserId(UserProvider.getUser().getUserId()); //获取头像 String[] headIcon = entity.getHeadIcon().split("/"); if (headIcon.length > 0) { entity.setHeadIcon(headIcon[headIcon.length - 1]); } entity.setQuickQuery(PinYinUtil.getFirstSpell(entity.getRealName())); //清理获取所有用户的redis缓存 redisUtil.remove(cacheKeyUtil.getAllUser()); if (StringUtil.isNotEmpty(entity.getGroupId()) && entity.getGroupId().contains(",")) { entity.setGroupId(null); } this.updateById(entity); return true; } @Override @DSTransactional public void delete(UserEntity entity) { this.removeById(entity.getId()); //删除用户关联 userRelationMapper.deleteAllByUserId(Arrays.asList(entity.getId())); //删除用户关联角色 roleRelationMapper.deleteAllByObjId(Arrays.asList(entity.getId())); //删除用户绑定关系 socialsUserMapper.deleteAllByUserId(Arrays.asList(entity.getId())); } @Override @DSTransactional public void batchDelete(List userIdList) { if (userIdList == null || userIdList.isEmpty()) { return; } this.removeBatchByIds(userIdList); //删除用户关联 userRelationMapper.deleteAllByUserId(userIdList); //删除用户关联角色 roleRelationMapper.deleteAllByObjId(userIdList); //删除用户绑定关系 socialsUserMapper.deleteAllByUserId(userIdList); } @Override public void updatePassword(UserEntity entity) { entity.setSecretkey(RandomUtil.uuId()); entity.setPassword(Md5Util.getStringMd5(entity.getPassword().toLowerCase() + entity.getSecretkey().toLowerCase())); entity.setChangePasswordDate(DateUtil.getNowDate()); this.updateById(entity); //加入到旧密码记录表 UserOldPasswordEntity userOldPasswordEntity = new UserOldPasswordEntity(); userOldPasswordEntity.setOldPassword(entity.getPassword()); userOldPasswordEntity.setSecretkey(entity.getSecretkey()); userOldPasswordEntity.setUserId(entity.getId()); userOldPasswordEntity.setAccount(entity.getAccount()); userOldPasswordMapper.create(userOldPasswordEntity); } @Override public List getUserName(List id) { return this.baseMapper.getUserName(id); } /** * 查询用户名称 * * @param id 主键值 * @return */ @Override public List getUserName(List id, boolean filterEnabledMark) { return this.baseMapper.getUserName(id, filterEnabledMark); } @Override public List getListByUserIds(List id) { return this.baseMapper.getListByUserIds(id); } @Override public List getUserList(List id) { return this.baseMapper.getUserList(id); } @Override public UserEntity getUserEntity(String account) { return this.baseMapper.getUserEntity(account); } @Override public List getListId() { return this.baseMapper.getListId(); } @Override public void update(UserEntity entity, String type) { this.baseMapper.update(entity, type); } @Override public void updateLastTime(UserEntity entity, String type) { this.baseMapper.updateLastTime(entity, type); } @Override public boolean isSubordinate(String id, String managerId) { int num = 0; return recursionSubordinates(id, managerId, num); } @Override public DownloadVO exportExcel(String dataType, String selectKey, PaginationUser pagination) { List entityList = new ArrayList<>(); if ("0".equals(dataType)) { entityList = getList(pagination, pagination.getOrganizeId(), false, true, null, null); } else if ("1".equals(dataType)) { entityList = getList(false); } List modeList = new ArrayList<>(); Map orgMaps = null; // 长度超过300代表是全部数据 if (entityList.size() > 300) { orgMaps = organizeMapper.getOrgMaps(null, true, null); } // 得到民族集合 List dataServiceList = dictionaryDataService.getListByCode("Nation"); Map dataServiceMap = dataServiceList.stream().filter(t -> ObjectUtil.equal(t.getEnabledMark(), 1)).collect(Collectors.toMap(DictionaryDataEntity::getId, DictionaryDataEntity::getFullName)); // 得到证件类型 List dataServiceList1 = dictionaryDataService.getListByCode("certificateType"); Map dataServiceMap1 = dataServiceList1.stream().filter(t -> ObjectUtil.equal(t.getEnabledMark(), 1)).collect(Collectors.toMap(DictionaryDataEntity::getId, DictionaryDataEntity::getFullName)); // 得到文化程度 List dataServiceList2 = dictionaryDataService.getListByCode("Education"); Map dataServiceMap2 = dataServiceList2.stream().filter(t -> ObjectUtil.equal(t.getEnabledMark(), 1)).collect(Collectors.toMap(DictionaryDataEntity::getId, DictionaryDataEntity::getFullName)); // 得到职级 List dataServiceList3 = dictionaryDataService.getListByCode("Rank"); Map dataServiceMap3 = dataServiceList3.stream().filter(t -> ObjectUtil.equal(t.getEnabledMark(), 1)).collect(Collectors.toMap(DictionaryDataEntity::getId, DictionaryDataEntity::getFullName)); // 得到性别 List dataServiceList4 = dictionaryDataService.getListByCode("sex"); Map dataServiceMap4 = dataServiceList4.stream().filter(t -> ObjectUtil.equal(t.getEnabledMark(), 1)).collect(Collectors.toMap(DictionaryDataEntity::getEnCode, DictionaryDataEntity::getFullName)); for (UserEntity entity : entityList) { UserExportVO model = new UserExportVO(); model.setAccount(entity.getAccount()); model.setRealName(entity.getRealName()); // 组织 // 定义多组织集合 StringJoiner stringJoiner = new StringJoiner(";"); // 获取该用户的所有组织关系 List allOrgRelationByUserId = userRelationMapper.getAllOrgRelationByUserId(entity.getId()); Map orgIdNameMaps = organizeMapper.getInfoList(); for (UserRelationEntity userRelationEntity : allOrgRelationByUserId) { String id = userRelationEntity.getObjectId(); OrganizeEntity organize = null; // 得到该组织信息 if (orgMaps != null) { organize = orgMaps.get(id); } else { organize = organizeMapper.getInfo(id); } // 得到父级id树 if (organize != null && ObjectUtil.equal(organize.getEnabledMark(), 1) && StringUtil.isNotEmpty(organize.getOrganizeIdTree())) { stringJoiner.add(organizeMapper.getFullNameByOrgIdTree(orgIdNameMaps, organize.getOrganizeIdTree(), "/")); } } model.setOrganizeId(stringJoiner.toString()); // 主管 UserEntity info = getInfo(entity.getManagerId()); if (Objects.nonNull(info) && StringUtil.isNotEmpty(info.getRealName()) && StringUtil.isNotEmpty(info.getAccount())) { model.setManagerId(info.getRealName() + "/" + info.getAccount()); } // 岗位 List listByObjectType = userRelationMapper.getListByObjectType(entity.getId(), PermissionConst.POSITION); StringBuffer positionName = new StringBuffer(); for (UserRelationEntity userRelationEntity : listByObjectType) { if (StringUtil.isNotEmpty(userRelationEntity.getObjectId())) { PositionEntity positionEntity = positionMapper.getInfo(userRelationEntity.getObjectId()); if (Objects.nonNull(positionEntity) && ObjectUtil.equal(positionEntity.getEnabledMark(), 1)) { positionName.append("," + positionEntity.getFullName() + "/" + positionEntity.getEnCode()); } } } // 判断岗位是否需要导出 if (positionName.length() > 0) { model.setPositionId(positionName.toString().replaceFirst(",", "")); } // 角色 List listByObjectType1 = userRelationMapper.getListByObjectType(entity.getId(), PermissionConst.ROLE); StringBuffer roleName = new StringBuffer(); for (UserRelationEntity userRelationEntity : listByObjectType1) { if (StringUtil.isNotEmpty(userRelationEntity.getObjectId())) { RoleEntity roleEntity = roleMapper.getInfo(userRelationEntity.getObjectId()); if (Objects.nonNull(roleEntity) && ObjectUtil.equal(roleEntity.getEnabledMark(), 1)) { roleName.append("," + roleEntity.getFullName()); } } } if (roleName.length() > 0) { model.setRoleId(roleName.toString().replaceFirst(",", "")); } model.setDescription(entity.getDescription()); // 性别 if (dataServiceMap4.containsKey(entity.getGender())) { model.setGender(dataServiceMap4.get(entity.getGender())); } // 民族 if (dataServiceMap.containsKey(entity.getNation())) { model.setNation(dataServiceMap.get(entity.getNation())); } model.setNativePlace(entity.getNativePlace()); // 证件类型 if (dataServiceMap1.containsKey(entity.getCertificatesType())) { model.setCertificatesType(dataServiceMap1.get(entity.getCertificatesType())); } model.setCertificatesNumber(entity.getCertificatesNumber()); // 文化程度 if (dataServiceMap2.containsKey(entity.getEducation())) { model.setEducation(dataServiceMap2.get(entity.getEducation())); } // 生日 SimpleDateFormat sf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); if (entity.getBirthday() != null) { String birthday = sf1.format(entity.getBirthday()); model.setBirthday(birthday); } model.setTelePhone(entity.getTelePhone()); model.setLandline(entity.getLandline()); model.setMobilePhone(entity.getMobilePhone()); model.setEmail(entity.getEmail()); model.setUrgentContacts(entity.getUrgentContacts()); model.setUrgentTelePhone(entity.getUrgentTelePhone()); model.setPostalAddress(entity.getPostalAddress()); model.setSortCode(entity.getSortCode() == null ? 0 : entity.getSortCode()); // 设置状态 if (entity.getEnabledMark() == null) { model.setEnabledMark("禁用"); } else { if (entity.getEnabledMark() == 2) { model.setEnabledMark("锁定"); } else if (entity.getEnabledMark() == 1) { model.setEnabledMark("正常"); } else { model.setEnabledMark("禁用"); } } // 入职时间 if (entity.getEntryDate() != null) { String entryDate = sf1.format(entity.getEntryDate()); model.setEntryDate(entryDate); } // 职级 if (dataServiceMap3.containsKey(entity.getRanks())) { model.setRanks(dataServiceMap3.get(entity.getRanks())); } modeList.add(model); } return exportUtil(selectKey, "用户信息", modeList, 0); } private DownloadVO exportUtil(String selectKey, String explain, List modeList, int type) { List list = JsonUtil.listToJsonField(JsonUtil.getJsonToList(modeList, UserExportVO.class)); if (type == 1) { list = JsonUtil.listToJsonField(JsonUtil.getJsonToList(modeList, UserExportExceptionVO.class)); } List entitys = new ArrayList<>(); String[] splitData = selectKey.split(","); if (splitData.length > 0) { for (int i = 0; i < splitData.length; i++) { if (splitData[i].equals("account")) { entitys.add(new ExcelExportEntity("账号", "account")); } if (splitData[i].equals("realName")) { entitys.add(new ExcelExportEntity("姓名", "realName")); } if (splitData[i].equals("gender")) { entitys.add(new ExcelExportEntity("性别", "gender")); } if (splitData[i].equals("email")) { entitys.add(new ExcelExportEntity("电子邮箱", "email")); } if (splitData[i].equals("organizeId")) { entitys.add(new ExcelExportEntity("所属组织", "organizeId")); } if (splitData[i].equals("managerId")) { entitys.add(new ExcelExportEntity("直属主管", "managerId")); } if (splitData[i].equals("positionId")) { entitys.add(new ExcelExportEntity("岗位", "positionId")); } if (splitData[i].equals("ranks")) { entitys.add(new ExcelExportEntity("职级", "ranks")); } if (splitData[i].equals("roleId")) { entitys.add(new ExcelExportEntity("角色", "roleId")); } if (splitData[i].equals("sortCode")) { entitys.add(new ExcelExportEntity("排序", "sortCode")); } if (splitData[i].equals("enabledMark")) { entitys.add(new ExcelExportEntity("状态", "enabledMark")); } if (splitData[i].equals("description")) { entitys.add(new ExcelExportEntity("说明", "description", 25)); } if (splitData[i].equals("nation")) { entitys.add(new ExcelExportEntity("民族", "nation")); } if (splitData[i].equals("nativePlace")) { entitys.add(new ExcelExportEntity("籍贯", "nativePlace")); } if (splitData[i].equals("entryDate")) { entitys.add(new ExcelExportEntity("入职时间", "entryDate")); } if (splitData[i].equals("certificatesType")) { entitys.add(new ExcelExportEntity("证件类型", "certificatesType")); } if (splitData[i].equals("certificatesNumber")) { entitys.add(new ExcelExportEntity("证件号码", "certificatesNumber")); } if (splitData[i].equals("education")) { entitys.add(new ExcelExportEntity("文化程度", "education")); } if (splitData[i].equals("birthday")) { entitys.add(new ExcelExportEntity("出生年月", "birthday")); } if (splitData[i].equals("telePhone")) { entitys.add(new ExcelExportEntity("办公电话", "telePhone")); } if (splitData[i].equals("landline")) { entitys.add(new ExcelExportEntity("办公座机", "landline")); } if (splitData[i].equals("mobilePhone")) { entitys.add(new ExcelExportEntity("手机号码", "mobilePhone")); } if (splitData[i].equals("urgentContacts")) { entitys.add(new ExcelExportEntity("紧急联系", "urgentContacts")); } if (splitData[i].equals("urgentTelePhone")) { entitys.add(new ExcelExportEntity("紧急电话", "urgentTelePhone")); } if (splitData[i].equals("postalAddress")) { entitys.add(new ExcelExportEntity("通讯地址", "postalAddress", 25)); } if (splitData[i].equals("errorsInfo")) { entitys.add(new ExcelExportEntity("异常原因", "errorsInfo", 50)); } } } ExportParams exportParams = new ExportParams(null, "用户信息"); exportParams.setType(ExcelType.XSSF); DownloadVO vo = DownloadVO.builder().build(); try { @Cleanup Workbook workbook = new HSSFWorkbook(); if (entitys.size() > 0) { workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list); } String name = explain + DateUtil.dateFormatByPattern(new Date(), "yyyyMMddHHmmss") + ".xlsx"; MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, name); FileInfo fileInfo = FileUploadUtils.uploadFile(new FileParameter(FileTypeConstant.TEMPORARY, name), multipartFile); vo.setName(fileInfo.getFilename()); vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + name); } catch (Exception e) { log.error("用户信息导出Excel错误:" + e.getMessage()); } return vo; } @Override public Map importPreview(List personList) { List> dataRow = new ArrayList<>(); List> columns = new ArrayList<>(); for (int i = 0; i < personList.size(); i++) { Map dataRowMap = new HashMap<>(); UserExportVO model = personList.get(i); dataRowMap.put("account", model.getAccount()); dataRowMap.put("realName", model.getRealName()); dataRowMap.put("organizeId", model.getOrganizeId()); dataRowMap.put("managerId", model.getManagerId()); dataRowMap.put("positionId", model.getPositionId()); dataRowMap.put("roleId", model.getRoleId()); dataRowMap.put("description", model.getDescription()); dataRowMap.put("gender", model.getGender()); dataRowMap.put("nation", model.getNation()); dataRowMap.put("nativePlace", model.getNativePlace()); dataRowMap.put("certificatesType", model.getCertificatesType()); dataRowMap.put("certificatesNumber", model.getCertificatesNumber()); dataRowMap.put("education", model.getEducation()); dataRowMap.put("birthday", model.getBirthday()); dataRowMap.put("telePhone", model.getTelePhone()); dataRowMap.put("landline", model.getLandline()); dataRowMap.put("mobilePhone", model.getMobilePhone()); dataRowMap.put("email", model.getEmail()); dataRowMap.put("urgentContacts", model.getUrgentContacts()); dataRowMap.put("urgentTelePhone", model.getUrgentTelePhone()); dataRowMap.put("postalAddress", model.getPostalAddress()); dataRowMap.put("sortCode", model.getSortCode()); dataRowMap.put("enabledMark", model.getEnabledMark()); dataRowMap.put("entryDate", model.getEntryDate()); dataRowMap.put("ranks", model.getRanks()); dataRow.add(dataRowMap); } for (int i = 1; i <= personList.size(); i++) { Map columnsMap = new HashMap<>(); columnsMap.put("AllowDBNull", true); columnsMap.put("AutoIncrement", false); columnsMap.put("AutoIncrementSeed", 0); columnsMap.put("AutoIncrementStep", 1); columnsMap.put("Caption", this.getColumns(i)); columnsMap.put("ColumnMapping", 1); columnsMap.put("ColumnName", this.getColumns(i)); columnsMap.put("Container", null); columnsMap.put("DataType", "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); columnsMap.put("DateTimeMode", 3); columnsMap.put("DefaultValue", null); columnsMap.put("DesignMode", false); columnsMap.put("Expression", ""); columnsMap.put("ExtendedProperties", ""); columnsMap.put("MaxLength", -1); columnsMap.put("Namespace", ""); columnsMap.put("Ordinal", 0); columnsMap.put("Prefix", ""); columnsMap.put("ReadOnly", false); columnsMap.put("Site", null); columnsMap.put("Table", personList); columnsMap.put("Unique", false); columns.add(columnsMap); } Map map = new HashMap<>(); map.put("dataRow", dataRow); map.put("columns", columns); return map; } @Override public UserImportVO importData(List dataList) { // List importModels = new ArrayList<>(16); List exceptionList = new ArrayList<>(16); // 得到民族集合 List dataServiceList = dictionaryDataService.getListByCode("Nation"); BiMap dataServiceMap = HashBiMap.create(dataServiceList.stream().collect(Collectors.toMap(DictionaryDataEntity::getId, DictionaryDataEntity::getFullName))); // 得到证件类型 List dataServiceList1 = dictionaryDataService.getListByCode("certificateType"); BiMap dataServiceMap1 = HashBiMap.create(dataServiceList1.stream().collect(Collectors.toMap(DictionaryDataEntity::getId, DictionaryDataEntity::getFullName))); // 得到文化程度 List dataServiceList2 = dictionaryDataService.getListByCode("Education"); BiMap dataServiceMap2 = HashBiMap.create(dataServiceList2.stream().collect(Collectors.toMap(DictionaryDataEntity::getId, DictionaryDataEntity::getFullName))); // 得到职级 List dataServiceList3 = dictionaryDataService.getListByCode("Rank"); BiMap dataServiceMap3 = HashBiMap.create(dataServiceList3.stream().collect(Collectors.toMap(DictionaryDataEntity::getId, DictionaryDataEntity::getFullName))); // 得到性别 List dataServiceList4 = dictionaryDataService.getListByCode("sex"); BiMap dataServiceMap4 = HashBiMap.create(dataServiceList4.stream().collect(Collectors.toMap(DictionaryDataEntity::getEnCode, DictionaryDataEntity::getFullName))); //记录成功了几条 int sum = 0; //记录第几条失败 int num = 0; for (UserExportVO exportVO : dataList) { UserImportModel model = new UserImportModel(); UserExportExceptionVO exceptionVO = JsonUtil.getJsonToBean(exportVO, UserExportExceptionVO.class); StringJoiner exceptionMsg = new StringJoiner(";"); // 处理账号 if (StringUtil.isNotEmpty(exportVO.getAccount())) { UserEntity userByAccount = getUserByAccount(exportVO.getAccount()); if (Objects.nonNull(userByAccount)) { // 账号重复 exceptionMsg.add("账号已存在"); } String regex = "^[a-z0-9A-Z\u4e00-\u9fa5]+$"; if (!exportVO.getAccount().matches(regex)) { // 账号重复 exceptionMsg.add("账户值不能含有特殊符号"); } model.setAccount(exportVO.getAccount()); } else { // 账号为空 exceptionMsg.add("账号不能为空"); } // 处理姓名 if (StringUtil.isEmpty(exportVO.getRealName())) { // 姓名为空 exceptionMsg.add("姓名不能为空"); } model.setRealName(exportVO.getRealName()); // 处理组织id String organizeId = exportVO.getOrganizeId(); if (StringUtil.isEmpty(organizeId)) { // 判断如果所属组织为空,则为错误数据 exceptionMsg.add("所属组织不能为空"); } else { StringJoiner orgName = new StringJoiner("、"); // 处理多级组织 String[] organizeIds = organizeId.split(";"); // 储存字段 StringJoiner orgIds = new StringJoiner(","); // 处理单个组织 for (String id : organizeIds) { String[] split = id.split("/"); // 定义一个标志,当前部门如果不存在则存到错误集合中 if (split.length > 0) { for (int i = 0; i < split.length; i++) { String orgId = split[i]; OrganizeEntity organizeEntity = organizeMapper.getInfoByFullName(orgId); if (organizeEntity != null) { if (i == split.length - 1) { orgIds.add(organizeEntity.getId()); } } else { orgName.add(id); break; } } } } if (orgName.length() > 0) { exceptionMsg.add("找不到该所属组织(" + orgName.toString() + ")"); } else { model.setOrganizeId(orgIds.toString()); } } // 处理性别 if (StringUtil.isEmpty(exportVO.getGender())) { // 性别为必填项,不给默认为错误,不给默认值 exceptionMsg.add("性别不能为空"); } else { if (dataServiceMap4.containsValue(exportVO.getGender())) { model.setGender(dataServiceMap4.inverse().get(exportVO.getGender())); } else { exceptionMsg.add("找不到该性别"); } } // 处理主管id String managerId = exportVO.getManagerId(); if (StringUtil.isNotEmpty(managerId)) { String[] split1 = managerId.split("/"); if (split1.length > 0) { String account = split1[split1.length - 1]; UserEntity entity = getUserByAccount(account); if (Objects.nonNull(entity) && StringUtil.isNotEmpty(entity.getAccount())) { model.setManagerId(entity.getId()); } } } String tmpOrganizeId = StringUtil.isEmpty(model.getOrganizeId()) ? "" : model.getOrganizeId(); // 处理岗位id String positionId = exportVO.getPositionId(); if (StringUtil.isNotEmpty(positionId)) { StringBuilder positionIdBuffer = new StringBuilder(); String[] positionIds = positionId.split(","); for (String id : positionIds) { // 岗位名称+编码 String[] positionName = id.split("/"); // 无编码无名称代表是无用数据,不予保存 if (positionName.length > 1) { // 通过名称和编码获取岗位信息 List positionEntityList = positionMapper.getListByFullName(positionName[0], positionName[1]); if (positionEntityList != null && positionEntityList.size() > 0) { PositionEntity positionEntity = positionEntityList.get(0); String[] split = tmpOrganizeId.split(","); boolean flag = false; for (String orgId : split) { List list = positionMapper.getListByOrganizeId(Collections.singletonList(orgId), false); if (list.stream().anyMatch(t -> t.getId().equals(positionEntity.getId()))) { flag = true; break; } } if (flag) { positionIdBuffer.append("," + positionEntity.getId()); } } } } model.setPositionId(positionIdBuffer.toString().replaceFirst(",", "")); } model.setDescription(exportVO.getDescription()); // 处理民族 if (StringUtil.isNotEmpty(exportVO.getNation())) { if (dataServiceMap.containsValue(exportVO.getNation())) { model.setNation(dataServiceMap.inverse().get(exportVO.getNation())); } } model.setNativePlace(exportVO.getNativePlace()); // 处理证件类型 if (StringUtil.isNotEmpty(exportVO.getCertificatesType())) { if (dataServiceMap1.containsValue(exportVO.getCertificatesType())) { model.setCertificatesType(dataServiceMap1.inverse().get(exportVO.getCertificatesType())); } } model.setCertificatesNumber(exportVO.getCertificatesNumber()); // 处理文化程度 if (StringUtil.isNotEmpty(exportVO.getEducation())) { if (dataServiceMap2.containsValue(exportVO.getEducation())) { model.setEducation(dataServiceMap2.inverse().get(exportVO.getEducation())); } } // 处理生日 if (StringUtil.isNotEmpty(exportVO.getBirthday())) { Date date = DateUtil.stringToDate(exportVO.getBirthday()); model.setBirthday(date); } model.setTelePhone(exportVO.getTelePhone()); model.setMobilePhone(exportVO.getMobilePhone()); model.setLandline(exportVO.getLandline()); model.setEmail(exportVO.getEmail()); model.setUrgentContacts(exportVO.getUrgentContacts()); model.setUrgentTelePhone(exportVO.getUrgentTelePhone()); model.setPostalAddress(exportVO.getPostalAddress()); model.setSortCode(exportVO.getSortCode() == null ? 0 : exportVO.getSortCode()); // 入职时间 if (StringUtil.isNotEmpty(exportVO.getEntryDate())) { Date date = DateUtil.stringToDate(exportVO.getEntryDate()); model.setEntryDate(date); } // 设置状态 if ("锁定".equals(exportVO.getEnabledMark())) { model.setEnabledMark(2); } else if ("正常".equals(exportVO.getEnabledMark())) { model.setEnabledMark(1); } else { model.setEnabledMark(0); } // 处理证件类型 if (StringUtil.isNotEmpty(exportVO.getRanks())) { if (dataServiceMap3.containsValue(exportVO.getRanks())) { model.setRanks(dataServiceMap3.inverse().get(exportVO.getRanks())); } } if (exceptionMsg.length() > 0) { exceptionVO.setErrorsInfo(exceptionMsg.toString()); exceptionList.add(exceptionVO); continue; } UserEntity entitys = JsonUtil.getJsonToBean(model, UserEntity.class); entitys.setHeadIcon("001.png"); try { create(entitys); sum++; } catch (Exception e) { if (e instanceof DataException) { exceptionVO.setErrorsInfo(e.getMessage()); } else { exceptionVO.setErrorsInfo("数据有误"); } exceptionList.add(exceptionVO); log.error("导入第" + (num + 1) + "条数据失败"); } } UserImportVO vo = new UserImportVO(); vo.setSnum(sum); if (exceptionList.size() > 0) { vo.setResultType(1); vo.setFailResult(exceptionList); vo.setFnum(exceptionList.size()); return vo; } else { vo.setResultType(0); return vo; } } @Override public void getOrganizeIdTree(String organizeId, StringBuffer organizeParentIdList) { OrganizeEntity entity = organizeMapper.getInfo(organizeId); if (Objects.nonNull(entity) && StringUtil.isNotEmpty(entity.getParentId())) { // 记录id organizeParentIdList.append(organizeId + ","); getOrganizeIdTree(entity.getParentId(), organizeParentIdList); } } @Override public DownloadVO exportExceptionData(List dataList) { DownloadVO vo = exportUtil("account,realName,gender,email,organizeId,managerId,positionId,roleId,sortCode,enabledMark,description,nation," + "nativePlace,entryDate,certificatesType,certificatesNumber,education,birthday,telePhone,landline,mobilePhone,urgentContacts," + "urgentTelePhone,postalAddress,ranks,errorsInfo" , "错误报告", dataList, 1); return vo; } @Override public List getUserName(List id, Pagination pagination) { return this.baseMapper.getUserName(id, pagination); } @Override public List getUserNames(List id, PaginationUser pagination, Boolean flag, Boolean enabledMark) { return this.baseMapper.getUserNames(id, pagination, flag, enabledMark); } @Override public List getFullNameByIds(List ids) { List list = new ArrayList<>(); if (ids != null) { ids.forEach(selectedId -> { if (StringUtil.isNotEmpty(selectedId)) { String[] split = selectedId.split("--"); // 截取type后获取详情 if (split.length > 1) { String type = split[1]; if (PermissionConst.COMPANY.equalsIgnoreCase(type) || PermissionConst.DEPARTMENT.equalsIgnoreCase(type)) { OrganizeEntity organizeEntity = organizeMapper.getInfo(split[0]); if (organizeEntity != null) { list.add(organizeEntity.getFullName()); } } else if (PermissionConst.ROLE.equalsIgnoreCase(type)) { RoleEntity roleEntity = roleMapper.getInfo(split[0]); if (roleEntity != null) { list.add(roleEntity.getFullName()); } } else if (PermissionConst.POSITION.equalsIgnoreCase(type)) { PositionEntity positionEntity = positionMapper.getInfo(split[0]); if (positionEntity != null) { list.add(positionEntity.getFullName()); } } else if (PermissionConst.GROUP.equalsIgnoreCase(type)) { GroupEntity groupEntity = groupMapper.getInfo(split[0]); if (groupEntity != null) { list.add(groupEntity.getFullName()); } } else if ("user".equalsIgnoreCase(type)) { UserEntity userEntity = this.getInfo(split[0]); if (userEntity != null) { list.add(userEntity.getRealName()); } } } else { UserEntity userEntity = this.getInfo(split[0]); if (userEntity != null) { list.add(userEntity.getRealName()); } } } }); } return list; } @Override public List selectedByIds(List ids) { List list = new ArrayList<>(); List organizeEntityList = organizeMapper.getList(true); Map allOrgsTreeName = organizeMapper.getAllOrgsTreeName(); List organizeSelectorList = JsonUtil.getJsonToList(organizeEntityList, OrganizeSelectorVO.class); for (OrganizeSelectorVO item : organizeSelectorList) { if (PermissionConst.DEPARTMENT.equals(item.getCategory())) { item.setIcon(PermissionConst.DEPARTMENT_ICON); } else { item.setIcon(PermissionConst.COMPANY_ICON); } item.setFullName(item.getOrgNameTree()); if (StringUtil.isNotEmpty(item.getParentId()) && Objects.nonNull(allOrgsTreeName.get(item.getParentId()))) { item.setParentName(allOrgsTreeName.get(item.getParentId()).toString()); } String[] orgs = item.getOrganizeIdTree().split(","); item.setOrganizeIds(Arrays.asList(orgs)); } if (ids != null) { Map orgIdNameMaps = organizeMapper.getInfoList(); ids.forEach(selectedId -> { if (StringUtil.isNotEmpty(selectedId)) { // 判断是否为系统参数 if (JnpfConst.SYSTEM_PARAM.containsKey(selectedId)) { UserIdListVo vo = new UserIdListVo(); vo.setId(selectedId); vo.setFullName(JnpfConst.SYSTEM_PARAM.get(selectedId)); } //组织 String[] split = selectedId.split("--"); // 截取type后获取详情 if (split.length > 1) { String type = split[1]; if (PermissionConst.COMPANY.equalsIgnoreCase(type) || PermissionConst.DEPARTMENT.equalsIgnoreCase(type)) { OrganizeEntity organizeEntity = organizeMapper.getInfo(split[0]); if (organizeEntity != null) { BaseInfoVo vo = JsonUtil.getJsonToBean(organizeEntity, BaseInfoVo.class); if ("department".equals(organizeEntity.getCategory())) { vo.setIcon(PermissionConst.DEPARTMENT_ICON); } else if ("company".equals(organizeEntity.getCategory())) { vo.setIcon(PermissionConst.COMPANY_ICON); } vo.setOrganize(organizeMapper.getFullNameByOrgIdTree(orgIdNameMaps, organizeEntity.getOrganizeIdTree(), "/")); vo.setOrganizeIds(organizeMapper.getOrgIdTree(organizeEntity)); vo.setType(organizeEntity.getCategory()); list.add(vo); } } else if (PermissionConst.ROLE.equalsIgnoreCase(type)) { RoleEntity roleEntity = roleMapper.getInfo(split[0]); if (roleEntity != null) { BaseInfoVo vo = JsonUtil.getJsonToBean(roleEntity, BaseInfoVo.class); List relationListByRoleId = roleRelationMapper.getListByRoleId(vo.getId(), null); StringJoiner orgName = new StringJoiner(","); relationListByRoleId.forEach(item -> { orgName.add(item.getObjectId()); }); vo.setId(selectedId); vo.setOrganize(orgName.toString()); vo.setType(SysParamEnum.ROLE.getCode()); vo.setIcon(PermissionConst.ROLE_ICON); vo.setOrgNameTree(vo.getFullName()); list.add(vo); } } else if (SysParamEnum.POS.getCode().equalsIgnoreCase(type) || SysParamEnum.SUBPOS.getCode().equalsIgnoreCase(type) || SysParamEnum.PROGENYPOS.getCode().equalsIgnoreCase(type)) { PositionEntity positionEntity = positionMapper.getInfo(split[0]); if (positionEntity != null) { BaseInfoVo vo = JsonUtil.getJsonToBean(positionEntity, BaseInfoVo.class); vo.setId(selectedId); OrganizeEntity info = organizeMapper.getInfo(positionEntity.getOrganizeId()); String orgName = ""; if (info != null) { vo.setOrganize(organizeMapper.getFullNameByOrgIdTree(orgIdNameMaps, info.getOrganizeIdTree(), "/")); orgName = vo.getOrganize(); } vo.setType(SysParamEnum.get(type).getCode()); vo.setIcon(PermissionConst.POSITION_ICON); vo.setOrgNameTree(orgName + "/" + positionEntity.getFullName() + SysParamEnum.get(type).getSuffix()); list.add(vo); } } else if (SysParamEnum.GROUP.getCode().equalsIgnoreCase(type)) { GroupEntity groupEntity = groupMapper.getInfo(split[0]); if (groupEntity != null) { BaseInfoVo vo = JsonUtil.getJsonToBean(groupEntity, BaseInfoVo.class); vo.setIcon(PermissionConst.GROUP_ICON); vo.setId(selectedId); vo.setType(SysParamEnum.GROUP.getCode()); vo.setOrgNameTree(groupEntity.getFullName() + SysParamEnum.get(type).getSuffix()); list.add(vo); } } else if (SysParamEnum.USER.getCode().equalsIgnoreCase(type)) { UserEntity userEntity = this.getInfo(split[0]); if (userEntity != null) { BaseInfoVo vo = JsonUtil.getJsonToBean(userEntity, BaseInfoVo.class); List listByObjectType = userRelationMapper.getListByObjectType(userEntity.getId(), PermissionConst.ORGANIZE); StringJoiner orgName = new StringJoiner(","); listByObjectType.forEach(userRelationEntity -> { OrganizeEntity info = organizeMapper.getInfo(userRelationEntity.getObjectId()); if (info != null) { String fullNameByOrgIdTree = organizeMapper.getFullNameByOrgIdTree(orgIdNameMaps, info.getOrganizeIdTree(), "/"); orgName.add(fullNameByOrgIdTree); } }); vo.setId(selectedId); vo.setOrganize(orgName.toString()); vo.setType(SysParamEnum.USER.getCode()); vo.setHeadIcon(UploaderUtil.uploaderImg(vo.getHeadIcon())); vo.setFullName(vo.getRealName() + "/" + vo.getAccount()); vo.setOrgNameTree(vo.getFullName()); list.add(vo); } } else { BaseInfoVo vo = new BaseInfoVo(); List collect = organizeSelectorList.stream() .filter(it -> split[0].equals(it.getId())) .collect(Collectors.toList()); if (!collect.isEmpty()) { vo = BeanUtil.copyProperties(collect.get(0), BaseInfoVo.class); String id = split[0]; SysParamEnum sysParamEnum = SysParamEnum.get(type); String suffix = sysParamEnum != null ? sysParamEnum.getSuffix() : ""; vo.setId(selectedId); vo.setOrgNameTree(allOrgsTreeName.get(id) + suffix); } vo.setId(selectedId); vo.setFullName(SysParamEnum.get(split[1]).getName()); vo.setRealName(orgIdNameMaps.get(split[0]) + "\\" + vo.getFullName()); vo.setType(split[1]); list.add(vo); } } else { UserEntity userEntity = this.getInfo(split[0]); if (userEntity != null) { extracted(userEntity, orgIdNameMaps, list, userEntity.getRealName() + "/" + userEntity.getAccount()); } if (selectedId.equals("@userId")) { UserInfo user = UserProvider.getUser(); userEntity = this.getInfo(user.getUserId()); userEntity.setId("@userId"); String userName = "当前用户"; extracted(userEntity, orgIdNameMaps, list, userName); } } } }); } return list; } private void extracted(UserEntity userEntity, Map orgIdNameMaps, List list, String userName) { BaseInfoVo vo = JsonUtil.getJsonToBean(userEntity, BaseInfoVo.class); List listByObjectType = userRelationMapper.getListByObjectType(userEntity.getId(), PermissionConst.ORGANIZE); StringJoiner orgName = new StringJoiner(","); listByObjectType.forEach(userRelationEntity -> { OrganizeEntity info = organizeMapper.getInfo(userRelationEntity.getObjectId()); if (info != null) { String fullNameByOrgIdTree = organizeMapper.getFullNameByOrgIdTree(orgIdNameMaps, info.getOrganizeIdTree(), "/"); orgName.add(fullNameByOrgIdTree); } }); vo.setOrganize(orgName.toString()); vo.setType("user"); vo.setHeadIcon(UploaderUtil.uploaderImg(vo.getHeadIcon())); vo.setFullName(vo.getRealName() + "/" + vo.getAccount()); vo.setOrgNameTree(userName); list.add(vo); } @Override public Boolean delCurRoleUser(String message, List objectIdAll) { List list = permissionGroupMapper.list(objectIdAll).stream().filter(t -> Objects.equals(t.getEnabledMark(), 1)).collect(Collectors.toList()); List member = list.stream().filter(t -> StringUtil.isNotEmpty(t.getPermissionMember())).map(PermissionGroupEntity::getPermissionMember).collect(Collectors.toList()); List userIdList = new ArrayList<>(); if (list.stream().filter(t -> Objects.equals(t.getType(), 0)).count() > 0) { userIdList.addAll(getUserMap().keySet()); } else { // 判断角色下面的人 userIdList.addAll(this.getUserIdList(member)); } delCurUser(message, userIdList); return true; } @Override public List getList(List orgIdList, String keyword) { // 得到用户关系表 List listByObjectId = userRelationMapper.getListByOrgId(orgIdList); if (listByObjectId.isEmpty()) { return new ArrayList<>(); } QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.lambda().in(UserEntity::getId, listByObjectId.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList())).and( t -> t.like(UserEntity::getRealName, keyword) .or().like(UserEntity::getAccount, keyword) ); return this.list(queryWrapper); } @Override public List getListBySyn(List orgIdList, String keyword) { // 得到用户关系表 List listByObjectId = userRelationMapper.getListByOrgId(orgIdList); //根据userId分类 Map> collect = listByObjectId.stream().collect(Collectors.groupingBy(UserRelationEntity::getUserId)); if (listByObjectId.isEmpty()) { return new ArrayList<>(); } QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.lambda().in(UserEntity::getId, listByObjectId.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList())).and( t -> t.like(UserEntity::getRealName, keyword) .or().like(UserEntity::getAccount, keyword) ); List list = this.list(queryWrapper); ArrayList userEntities = new ArrayList<>(); for (UserEntity userEntity : list) { List userRelationEntities = collect.get(userEntity.getId()); for (UserRelationEntity userRelationEntity : userRelationEntities) { UserEntity entity = BeanUtil.copyProperties(userEntity, UserEntity.class); entity.setOrganizeId(userRelationEntity.getObjectId()); userEntities.add(entity); } } return userEntities; } @Override public List getUserIdList(List idList) { Set userIds = new LinkedHashSet<>(); idList.forEach(selectedId -> { if (StringUtil.isNotEmpty(selectedId)) { if (selectedId.equals("@userId")) { userIds.add(UserProvider.getUser().getUserId()); return; } String[] split = selectedId.split("--"); if (Arrays.stream(split).count() == 1) { UserEntity info = this.baseMapper.getInfo(selectedId); if (BeanUtil.isNotEmpty(info)) { userIds.add(info.getId()); } return; } if (selectedId.substring(selectedId.length() - 3).equalsIgnoreCase(SysParamEnum.ORG.getCode())) { ArrayList strings = new ArrayList<>(); if (selectedId.contains(SysParamEnum.SUBORG.getCode())) { List listByParentId = organizeMapper.getListByParentId(split[0]); if (listByParentId != null) { strings.addAll(listByParentId.stream().map(OrganizeEntity::getId).collect(Collectors.toList())); } } if (selectedId.contains(SysParamEnum.PROGENYORG.getCode())) { List grandSonList = organizeMapper.getAllChild(split[0]); if (grandSonList != null) { strings.addAll(grandSonList.stream().map(OrganizeEntity::getId).collect(Collectors.toList())); } } strings.add(split[0]); List listByOrgIds = positionMapper.getListByOrgIds(strings.stream() .filter(Objects::nonNull).collect(Collectors.toList())); List positionIds = listByOrgIds.stream().map(PositionEntity::getId).collect(Collectors.toList()); List listByObjectIdAll = userRelationMapper.getListByObjectIdAll(positionIds); userIds.addAll(listByObjectIdAll.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList())); } else if (selectedId.substring(selectedId.length() - 3).equalsIgnoreCase(SysParamEnum.POS.getCode())) { ArrayList strings = new ArrayList<>(); strings.add(split[0]); PositionEntity info = positionMapper.getInfo(split[0]); if (info != null && selectedId.contains(SysParamEnum.SUBPOS.getCode())) { List byParentId = positionMapper.getByParentId(info.getId()); if (null != byParentId && !byParentId.isEmpty()) { strings.addAll(byParentId.stream().map(PositionEntity::getId).collect(Collectors.toList())); } } if (info != null && selectedId.contains(SysParamEnum.PROGENYPOS.getCode())) { List grandSonList = positionMapper.getAllChild(info.getId()); if (null != grandSonList) { strings.addAll(grandSonList.stream().map(PositionEntity::getId).collect(Collectors.toList())); } } List collect = userRelationMapper.getListByObjectIdAll(strings) .stream() .map(UserRelationEntity::getUserId) .collect(Collectors.toList()); userIds.addAll(collect); } else if (selectedId.contains(SysParamEnum.GROUP.getCode())) { List collect = userRelationMapper.getListByObjectId(split[0]) .stream() .map(UserRelationEntity::getUserId) .collect(Collectors.toList()); userIds.addAll(collect); } else if (selectedId.contains(SysParamEnum.ROLE.getCode())) { List collect = roleRelationMapper.getListByRoleId(split[0], PermissionConst.USER) .stream() .map(RoleRelationEntity::getObjectId) .collect(Collectors.toList()); userIds.addAll(collect); } else if (selectedId.contains(SysParamEnum.USER.getCode())) { UserEntity info = this.baseMapper.getInfo(split[0]); if (BeanUtil.isNotEmpty(info)) { userIds.add(info.getId()); } } } }); return new ArrayList<>(userIds); } @Override public List getRelUserEnable(List idList) { List userIdList = this.getUserIdList(idList); List listByUserIds = this.getListByUserIds(userIdList); return listByUserIds.stream().filter(t -> !Objects.equals(t.getEnabledMark(), 0)).map(UserEntity::getId).collect(Collectors.toList()); } @Override public List getObjList(List userIds, PaginationUser pagination) { // 得到所有的用户id关系 Map orgIdNameMaps = organizeMapper.getInfoList(); List userEntityList = getUserIdListByOrganize(userIds, pagination); if (userEntityList.isEmpty()) { return Collections.emptyList(); } List jsonToList = JsonUtil.getJsonToList(userEntityList, UserIdListVo.class); jsonToList.forEach(userIdListVo -> { List listByObjectType = userRelationMapper.getListByObjectType(userIdListVo.getId(), PermissionConst.ORGANIZE); StringJoiner orgName = new StringJoiner(","); listByObjectType.forEach(userRelationEntity -> { OrganizeEntity info = organizeMapper.getInfo(userRelationEntity.getObjectId()); if (info != null) { String fullNameByOrgIdTree = organizeMapper.getFullNameByOrgIdTree(orgIdNameMaps, info.getOrganizeIdTree(), "/"); orgName.add(fullNameByOrgIdTree); } }); userIdListVo.setOrganize(orgName.toString()); userIdListVo.setType(SysParamEnum.USER.getCode()); userIdListVo.setFullName(userIdListVo.getRealName() + "/" + userIdListVo.getAccount()); userIdListVo.setHeadIcon(UploaderUtil.uploaderImg(userIdListVo.getHeadIcon())); }); return JsonUtil.getJsonToList(jsonToList, BaseInfoVo.class); } private List getUserIdListByOrganize(List userIds, PaginationUser pagination) { List userObjectIds = getUserIdList(userIds); if (userObjectIds.isEmpty()) { return Collections.emptyList(); } LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.ne(UserEntity::getAccount, ADMIN_KEY); wrapper.ne(UserEntity::getEnabledMark, 0); //idList范围过滤 if (userObjectIds.size() > 1000) { List> lists = Lists.partition(userObjectIds, 1000); wrapper.and(t -> { for (List item : lists) { t.in(UserEntity::getId, item).or(); } }); } else { wrapper.in(UserEntity::getId, userObjectIds); } //关键字 if (StringUtil.isNotEmpty(pagination.getKeyword())) { wrapper.and( t -> t.like(UserEntity::getRealName, pagination.getKeyword()) .or().like(UserEntity::getAccount, pagination.getKeyword()) .or().like(UserEntity::getMobilePhone, pagination.getKeyword()) ); } wrapper.orderByAsc(UserEntity::getId); Page page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize()); IPage iPage = this.baseMapper.selectPage(page, wrapper); return pagination.setData(iPage.getRecords(), iPage.getTotal()); } private String getColumns(Integer key) { Map map = new HashMap<>(); map.put(1, "账号"); map.put(2, "姓名"); map.put(3, "性别"); map.put(4, "手机"); map.put(5, "说明"); map.put(6, "状态"); map.put(7, "排序"); map.put(8, "是否管理员"); map.put(9, "锁定标志"); map.put(10, "添加时间"); map.put(11, "部门"); return map.get(key); } /** * 判断上级是否直属主管的值是否为我的下属 * * @param id * @param managerId * @param num */ private boolean recursionSubordinates(String id, String managerId, int num) { UserEntity entity = getInfo(managerId); num++; if (entity != null && entity.getId().equals(id)) { return true; } if (num < 10) { if (entity != null) { return recursionSubordinates(id, entity.getManagerId(), num); } return false; } else { return false; } } /** * 查询给定的条件是否有默认当前登录者的默认用户值 * * @param userConditionModel * @return */ @Override public String getDefaultCurrentValueUserId(UserConditionModel userConditionModel) { UserInfo userInfo = UserProvider.getUser(); int currentFinded = 0; if (userConditionModel.getUserIds() != null && !userConditionModel.getUserIds().isEmpty() && userConditionModel.getUserIds().contains(userInfo.getUserId())) { currentFinded = 1; } if (currentFinded == 0 && userConditionModel.getDepartIds() != null && !userConditionModel.getDepartIds().isEmpty()) { List orgList = organizeMapper.getOrgEntityList(userConditionModel.getDepartIds(), true); List orgLIdList = orgList.stream().map(OrganizeEntity::getId).collect(Collectors.toList()); if (orgLIdList != null && !orgLIdList.isEmpty()) { List userIds = userRelationMapper.getListByObjectIdAll(orgLIdList).stream().map(UserRelationEntity::getUserId).collect(Collectors.toList()); if (userIds != null && !userIds.isEmpty() && userIds.contains(userInfo.getUserId())) { currentFinded = 1; } } } if (currentFinded == 0 && userConditionModel.getRoleIds() != null && !userConditionModel.getRoleIds().isEmpty()) { List roleList = roleMapper.getListByIds(userConditionModel.getRoleIds(), null, false); List roleIdList = roleList.stream().filter(t -> t.getEnabledMark() == 1).map(RoleEntity::getId).collect(Collectors.toList()); if (roleIdList != null && !roleIdList.isEmpty()) { List userIds = userRelationMapper.getListByObjectIdAll(roleIdList).stream().map(UserRelationEntity::getUserId).collect(Collectors.toList()); if (userIds != null && !userIds.isEmpty() && userIds.contains(userInfo.getUserId())) { currentFinded = 1; } } } if (currentFinded == 0 && userConditionModel.getPositionIds() != null && !userConditionModel.getPositionIds().isEmpty()) { List positionList = positionMapper.getPosList(userConditionModel.getPositionIds()); List positionIdList = positionList.stream().filter(t -> t.getEnabledMark() == 1).map(PositionEntity::getId).collect(Collectors.toList()); if (positionIdList != null && !positionIdList.isEmpty()) { List userIds = userRelationMapper.getListByObjectIdAll(positionIdList).stream().map(UserRelationEntity::getUserId).collect(Collectors.toList()); if (userIds != null && !userIds.isEmpty() && userIds.contains(userInfo.getUserId())) { currentFinded = 1; } } } if (currentFinded == 0 && userConditionModel.getGroupIds() != null && !userConditionModel.getGroupIds().isEmpty()) { List groupList = groupMapper.getListByIds(userConditionModel.getGroupIds()); List groupIdList = groupList.stream().map(GroupEntity::getId).collect(Collectors.toList()); if (groupIdList != null && !groupIdList.isEmpty()) { List userIds = userRelationMapper.getListByObjectIdAll(groupIdList).stream().map(UserRelationEntity::getUserId).collect(Collectors.toList()); if (userIds != null && !userIds.isEmpty() && userIds.contains(userInfo.getUserId())) { currentFinded = 1; } } } return (currentFinded == 1) ? userInfo.getUserId() : ""; } @Override public List getUserAccount(List ids) { return this.baseMapper.getUserAccount(ids); } @Override public void updateStand(List ids, int standing) { this.baseMapper.updateStand(ids, standing); } @Override public Boolean delCurUser(String message, List userIds) { return userUtil.delCurUser(message, userIds); } @Override public void majorStandFreshUser() { userUtil.majorStandFreshUser(); } @Override public Boolean logoutUser(String message, List userIds) { return userUtil.logoutUser(message, userIds); } @Override public List getPageByIds(RoleRelationPage pagination) { return this.baseMapper.getPageByIds(pagination); } @Override public UserRelationIds getUserObjectIdList(String userId) { List listUser = userRelationMapper.getListByObjectType(userId, null); List group = listUser.stream().filter(t -> PermissionConst.GROUP.equals(t.getObjectType())).map(UserRelationEntity::getObjectId).collect(Collectors.toList()); List organize = listUser.stream().filter(t -> PermissionConst.ORGANIZE.equals(t.getObjectType())).map(UserRelationEntity::getObjectId).collect(Collectors.toList()); List position = listUser.stream().filter(t -> PermissionConst.POSITION.equals(t.getObjectType())).map(UserRelationEntity::getObjectId).collect(Collectors.toList()); List rogAndPos = listUser.stream().filter(t -> PermissionConst.ORGANIZE.equals(t.getObjectType()) || PermissionConst.POSITION.equals(t.getObjectType())) .map(UserRelationEntity::getObjectId).collect(Collectors.toList()); rogAndPos.add(userId); List role = roleRelationMapper.getListByObjectId(rogAndPos, null).stream().map(RoleRelationEntity::getRoleId).collect(Collectors.toList()); UserRelationIds userRelationIds = UserRelationIds.builder() .group(group) .organize(organize) .position(position) .role(role) .build(); return userRelationIds; } @Override public Map getSystemFieldValue(SystemParamModel model) { Map mapList = new HashMap<>(); List needList = model.getList(); UserInfo userInfo = UserProvider.getUser(); String userId = userInfo.getUserId(); List organizeIds = userInfo.getOrganizeIds() != null ? userInfo.getOrganizeIds() : new ArrayList<>(); List positionIds = userInfo.getPositionIds() != null ? userInfo.getPositionIds() : new ArrayList<>(); for (String key : needList) { List dataValue = new ArrayList<>(); String values = ""; switch (key) { case DataInterfaceVarConst.CURRENTTIME: values = String.valueOf(DateUtil.stringToDate(DateUtil.getNow()).getTime()); break; case DataInterfaceVarConst.USER: values = userId; break; case DataInterfaceVarConst.ORG: values = JsonUtil.getObjectToString(organizeIds); break; case DataInterfaceVarConst.POSITIONID: values = JsonUtil.getObjectToString(positionIds); break; case DataInterfaceVarConst.USERANDSUB: dataValue.add(userId); if (!positionIds.isEmpty()) { dataValue.addAll(userUtil.getUserAndSub(positionIds, null).stream() .map(SuperBaseEntity.SuperIBaseEntity::getId).collect(Collectors.toList())); } values = JsonUtil.getObjectToString(dataValue); break; case DataInterfaceVarConst.USERANDPROGENY: dataValue.add(userId); if (!positionIds.isEmpty()) { dataValue.addAll(userUtil.getUserProgeny(positionIds, null).stream() .map(SuperBaseEntity.SuperIBaseEntity::getId).collect(Collectors.toList())); } values = JsonUtil.getObjectToString(dataValue); break; case DataInterfaceVarConst.ORGANDSUB: if (!organizeIds.isEmpty()) { List listByParentIds = organizeMapper.getListByParentIds(organizeIds); dataValue.addAll(organizeIds); dataValue.addAll(listByParentIds.stream().map(OrganizeEntity::getId).collect(Collectors.toList())); } values = JsonUtil.getObjectToString(dataValue); break; case DataInterfaceVarConst.ORGANIZEANDPROGENY: if (!organizeIds.isEmpty()) { List allChild = organizeMapper.getProgeny(organizeIds, null); dataValue.addAll(allChild.stream().map(OrganizeEntity::getId).collect(Collectors.toList())); } values = JsonUtil.getObjectToString(dataValue); break; case DataInterfaceVarConst.POSITIONANDSUB: if (!positionIds.isEmpty()) { List listByParentIds = positionMapper.getListByParentIds(positionIds); dataValue.addAll(positionIds); dataValue.addAll(listByParentIds.stream().map(PositionEntity::getId).collect(Collectors.toList())); } values = JsonUtil.getObjectToString(dataValue); break; case DataInterfaceVarConst.POSITIONANDPROGENY: if (!positionIds.isEmpty()) { List allChild = positionMapper.getProgeny(positionIds, null); dataValue.addAll(allChild.stream().map(PositionEntity::getId).collect(Collectors.toList())); } values = JsonUtil.getObjectToString(dataValue); break; default: break; } mapList.put(key, values); } return mapList; } @Override public List pageUser(UserSystemCountModel userSystemCountModel) { return this.baseMapper.pageUser(userSystemCountModel); } }