| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547 |
- 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.alibaba.fastjson.JSONObject;
- 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.conditions.update.UpdateWrapper;
- 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.Pagination;
- import jnpf.base.UserInfo;
- import jnpf.base.entity.DictionaryDataEntity;
- import jnpf.base.entity.SuperBaseEntity;
- import jnpf.base.service.DictionaryDataService;
- import jnpf.base.service.SuperServiceImpl;
- import jnpf.base.service.SysconfigService;
- 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.message.util.OnlineUserModel;
- import jnpf.message.util.OnlineUserProvider;
- import jnpf.model.BaseSystemInfo;
- import jnpf.model.SystemParamModel;
- import jnpf.model.tenant.TenantVO;
- import jnpf.permission.entity.*;
- import jnpf.permission.mapper.UserMapper;
- 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.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.*;
- import jnpf.permission.service.*;
- import jnpf.util.*;
- import jnpf.util.context.RequestContext;
- 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.util.ObjectUtils;
- 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<UserMapper, UserEntity> implements UserService {
- @Autowired
- private UserRelationService userRelationService;
- @Autowired
- private RedisUtil redisUtil;
- @Autowired
- private OrganizeService organizeService;
- @Autowired
- private PositionService positionService;
- @Autowired
- private RoleService roleService;
- @Autowired
- private CacheKeyUtil cacheKeyUtil;
- @Autowired
- private DataSourceUtil dataSourceUtil;
- @Autowired
- private ConfigValueUtil configValueUtil;
- @Autowired
- private DictionaryDataService dictionaryDataService;
- @Autowired
- private RoleRelationService roleRelationService;
- @Autowired
- private UserMapper userMapper;
- @Autowired
- private SysconfigService sysconfigApi;
- @Autowired
- private OrganizeAdministratorService organizeAdministratorService;
- @Autowired
- private UserOldPasswordService userOldPasswordService;
- @Autowired
- private GroupService groupService;
- @Autowired
- private PermissionGroupService permissionGroupService;
- @Autowired
- private UserService userService;
- @Autowired
- private SocialsUserService socialsUserService;
- @Override
- public List<UserEntity> getList(UserPagination pagination) {
- QueryWrapper<UserEntity> 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) {
- 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<UserRelationEntity> listUser = userRelationService.getListByObjectId(pagination.getGroupId(), PermissionConst.GROUP);
- List<String> users = listUser.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList());
- if (CollectionUtil.isEmpty(users)) {
- return pagination.setData(Collections.EMPTY_LIST, 0);
- }
- List<List<String>> lists = Lists.partition(users, 1000);
- queryWrapper.lambda().and(t -> {
- for (List<String> userItem : lists) {
- t.in(UserEntity::getId, userItem).or();
- }
- });
- }
- //有岗位id
- if (StringUtil.isNotEmpty(pagination.getPositionId())) {
- List<UserRelationEntity> listUser = userRelationService.getListByObjectId(pagination.getPositionId(), PermissionConst.POSITION);
- List<String> users = listUser.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList());
- if (CollectionUtil.isEmpty(users)) {
- return pagination.setData(Collections.EMPTY_LIST, 0);
- }
- List<List<String>> lists = Lists.partition(users, 1000);
- queryWrapper.lambda().and(t -> {
- for (List<String> userItem : lists) {
- t.in(UserEntity::getId, userItem).or();
- }
- });
- } else if (StringUtil.isNotEmpty(pagination.getOrganizeId())) {
- //有组织id
- List<String> orgIds = new ArrayList<>();
- orgIds.add(pagination.getOrganizeId());
- if (Objects.equals(pagination.getShowSubOrganize(), 1)) {
- List<OrganizeEntity> allChild = organizeService.getAllChild(pagination.getOrganizeId());
- orgIds.addAll(allChild.stream().map(OrganizeEntity::getId).collect(Collectors.toList()));
- }
- List<PositionEntity> listPost = positionService.getListByOrgIds(orgIds);
- List<String> listPostId = listPost.stream().map(PositionEntity::getId).collect(Collectors.toList());
- List<UserRelationEntity> listUser = userRelationService.getListByObjectIdAll(listPostId);
- List<String> users = listUser.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList());
- if (CollectionUtil.isEmpty(users)) {
- return pagination.setData(Collections.EMPTY_LIST, 0);
- }
- List<List<String>> lists = Lists.partition(users, 1000);
- queryWrapper.lambda().and(t -> {
- for (List<String> userItem : lists) {
- t.in(UserEntity::getId, userItem).or();
- }
- });
- }
- //有角色id
- if (StringUtil.isNotEmpty(pagination.getRoleId())) {
- List<RoleRelationEntity> listUser = roleRelationService.getListByRoleId(pagination.getRoleId(), PermissionConst.USER);
- List<String> users = listUser.stream().map(RoleRelationEntity::getObjectId).collect(Collectors.toList());
- if (CollectionUtil.isEmpty(users)) {
- return pagination.setData(Collections.EMPTY_LIST, 0);
- }
- List<List<String>> lists = Lists.partition(users, 1000);
- queryWrapper.lambda().and(t -> {
- for (List<String> 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<UserEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize(), count, false);
- page.setOptimizeCountSql(false);
- IPage<UserEntity> iPage = this.page(page, queryWrapper);
- if (!iPage.getRecords().isEmpty()) {
- List<String> 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<UserEntity> getList(boolean filterEnabledMark) {
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- if (filterEnabledMark) {
- queryWrapper.lambda().eq(UserEntity::getEnabledMark, 1);
- }
- queryWrapper.lambda().ne(UserEntity::getAccount, ADMIN_KEY);
- queryWrapper.lambda().orderByAsc(UserEntity::getSortCode).orderByDesc(UserEntity::getCreatorTime);
- return this.list(queryWrapper);
- }
- @Override
- public List<UserEntity> getUserNameList(List<String> idList) {
- if (idList.size() > 0) {
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().select(UserEntity::getId, UserEntity::getRealName, UserEntity::getEnabledMark).in(UserEntity::getId, idList);
- return this.list(queryWrapper);
- }
- return new ArrayList<>();
- }
- @Override
- public List<UserEntity> getUserNameList(Set<String> idList) {
- if (idList.size() > 0) {
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().select(UserEntity::getId, UserEntity::getRealName, UserEntity::getAccount).in(UserEntity::getId, idList);
- return this.list(queryWrapper);
- }
- return new ArrayList<>();
- }
- @Override
- public Map<String, Object> getUserMap() {
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().select(UserEntity::getId, UserEntity::getRealName, UserEntity::getAccount);
- Map<String, Object> userMap = new HashMap<>();
- this.list(queryWrapper).stream().forEach(user -> userMap.put(user.getId(), user.getRealName() + "/" + user.getAccount()));
- return userMap;
- }
- @Override
- public Map<String, Object> getUserNameAndIdMap() {
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().select(UserEntity::getId, UserEntity::getRealName, UserEntity::getAccount);
- Map<String, Object> userMap = new HashMap<>();
- this.list(queryWrapper).stream().forEach(user -> userMap.put(user.getRealName() + "/" + user.getAccount(), user.getId()));
- return userMap;
- }
- @Override
- public Map<String, Object> getUserNameAndIdMap(boolean enabledMark) {
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- if (enabledMark) {
- queryWrapper.lambda().eq(UserEntity::getEnabledMark, 1);
- }
- queryWrapper.lambda().select(UserEntity::getId, UserEntity::getRealName, UserEntity::getAccount);
- Map<String, Object> userMap = new HashMap<>();
- this.list(queryWrapper).stream().forEach(user -> userMap.put(user.getRealName() + "/" + user.getAccount(), user.getId()));
- return userMap;
- }
- @Override
- public UserEntity getByRealName(String realName) {
- UserEntity userEntity = new UserEntity();
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().eq(UserEntity::getRealName, realName);
- queryWrapper.lambda().select(UserEntity::getId);
- List<UserEntity> list = this.list(queryWrapper);
- if (list.size() > 0) {
- userEntity = list.get(0);
- }
- return userEntity;
- }
- @Override
- public UserEntity getByRealName(String realName, String account) {
- UserEntity userEntity = new UserEntity();
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().eq(UserEntity::getRealName, realName);
- queryWrapper.lambda().eq(UserEntity::getAccount, account);
- queryWrapper.lambda().select(UserEntity::getId);
- List<UserEntity> list = this.list(queryWrapper);
- if (list.size() > 0) {
- userEntity = list.get(0);
- }
- return userEntity;
- }
- @Override
- public List<UserEntity> getAdminList() {
- QueryWrapper<UserEntity> query = new QueryWrapper<>();
- query.lambda().eq(UserEntity::getIsAdministrator, 1);
- query.lambda().orderByAsc(UserEntity::getSortCode).orderByDesc(UserEntity::getCreatorTime);
- return list(query);
- }
- @Override
- public List<UserEntity> getList(PaginationUser pagination, String organizeId, Boolean flag, Boolean filter, Integer enabledMark, String gender) {
- // 定义变量判断是否需要使用修改时间倒序
- boolean filterLastTime = false;
- String userId = UserProvider.getUser().getUserId();
- QueryWrapper<UserEntity> 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<String> orgIdList = organizeService.getUnderOrganizationss(organizeId);
- orgIdList.add(organizeId);
- PageHelper.startPage((int) pagination.getCurrentPage(), (int) pagination.getPageSize(), false);
- //组织数量很多时解析SQL很慢, COUNT不解析SQL不去除ORDERBY
- PageMethod.getLocalPage().keepOrderBy(true);
- // 用户id
- List<String> 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 = userMapper.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<UserEntity> queryWrapper1 = new QueryWrapper<>();
- List<List<String>> lists = Lists.partition(query, 1000);
- queryWrapper1.lambda().and(t -> {
- for (List<String> id : lists) {
- t.or().in(UserEntity::getId, id);
- }
- });
- queryWrapper1.lambda().orderByAsc(UserEntity::getSortCode).orderByDesc(UserEntity::getCreatorTime);
- List<UserEntity> entityList = getBaseMapper().selectList(queryWrapper1);
- return entityList;
- } else {
- return new ArrayList<>();
- }
- }
- if (!UserProvider.getUser().getIsAdministrator()) {
- // 通过权限转树
- List<OrganizeAdministratorEntity> listss = organizeAdministratorService.getOrganizeAdministratorEntity(UserProvider.getUser().getUserId());
- Set<String> orgIds = new HashSet<>(16);
- // 判断自己是哪些组织的管理员
- listss.stream().forEach(t -> {
- if (t != null) {
- if (t.getThisLayerSelect() != null && t.getThisLayerSelect() == 1) {
- orgIds.add(t.getOrganizeId());
- }
- if (t.getSubLayerSelect() != null && t.getSubLayerSelect() == 1) {
- List<String> underOrganizations = organizeService.getUnderOrganizations(t.getOrganizeId(), false);
- orgIds.addAll(underOrganizations);
- }
- }
- });
- List<String> list1 = new ArrayList<>(orgIds);
- // 得到所有有权限的组织
- List<OrganizeEntity> organizeName = new ArrayList<>(organizeService.getOrganizeName(list1, null, false, null).values());
- // 用户关系表得到所有的人
- List<String> collect = organizeName.stream().map(OrganizeEntity::getId).collect(Collectors.toList());
- List<UserRelationEntity> listByObjectIdAll = userRelationService.getListByOrgId(collect);
- List<String> collect1 = listByObjectIdAll.stream().map(UserRelationEntity::getUserId).distinct().collect(Collectors.toList());
- return getUserNames(collect1, pagination, false, ObjectUtil.equal(enabledMark, 1));
- }
- //关键字(账户、姓名、手机)
- 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) {
- queryWrapper.lambda().eq(UserEntity::getEnabledMark, enabledMark);
- }
- 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<UserEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize(), count, false);
- page.setOptimizeCountSql(false);
- IPage<UserEntity> iPage = this.page(page, queryWrapper);
- if (!iPage.getRecords().isEmpty()) {
- List<String> 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<UserEntity> getList(PageUser pagination, Boolean filterCurrentUser) {
- // 定义变量判断是否需要使用修改时间倒序
- boolean filterLastTime = false;
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- if (filterCurrentUser) {
- String userId = UserProvider.getUser().getUserId();
- queryWrapper.lambda().ne(UserEntity::getId, userId);
- }
- queryWrapper.lambda().ne(UserEntity::getEnabledMark, 0);
- //关键字(账户、姓名、手机)
- 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 (CollectionUtil.isNotEmpty(pagination.getIdList())) {
- List<List<String>> partition = Lists.partition(pagination.getIdList(), 1000);
- queryWrapper.lambda().and(t -> {
- for (List<String> list : partition) {
- t.in(UserEntity::getId, list).or();
- }
- });
- }
- //排序
- queryWrapper.lambda().orderByAsc(UserEntity::getSortCode).orderByDesc(UserEntity::getCreatorTime);
- if (filterLastTime) {
- queryWrapper.lambda().orderByDesc(UserEntity::getLastModifyTime);
- }
- Page<UserEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
- IPage<UserEntity> iPage = this.page(page, queryWrapper);
- return pagination.setData(iPage.getRecords(), iPage.getTotal());
- }
- @Override
- public List<UserEntity> getUserPage(Pagination pagination) {
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().ne(UserEntity::getEnabledMark, 0);
- if (StringUtil.isNotEmpty(pagination.getKeyword())) {
- //通过关键字查询
- queryWrapper.lambda().and(
- t -> t.like(UserEntity::getAccount, pagination.getKeyword())
- .or().like(UserEntity::getRealName, pagination.getKeyword())
- .or().like(UserEntity::getMobilePhone, pagination.getKeyword())
- );
- }
- queryWrapper.lambda().ne(UserEntity::getEnabledMark, 0);
- queryWrapper.lambda().select(UserEntity::getId, UserEntity::getAccount, UserEntity::getRealName, UserEntity::getGender, UserEntity::getEnabledMark);
- Page<UserEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
- IPage<UserEntity> iPage = this.page(page, queryWrapper);
- return iPage.getRecords();
- }
- @Override
- public List<UserEntity> getListByOrganizeId(String organizeId, String keyword) {
- List<String> userIds = userRelationService.getListByObjectId(organizeId, PermissionConst.ORGANIZE).stream()
- .map(UserRelationEntity::getUserId).collect(Collectors.toList());
- if (userIds.size() > 0) {
- QueryWrapper<UserEntity> 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<UserEntity> getListByManagerId(String managerId, String keyword) {
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().eq(UserEntity::getManagerId, managerId);
- // 通过关键字查询
- if (StringUtil.isNotEmpty(keyword)) {
- queryWrapper.lambda().and(
- t -> t.like(UserEntity::getAccount, keyword)
- .or().like(UserEntity::getRealName, keyword)
- );
- }
- // 只查询正常的用户
- queryWrapper.lambda().eq(UserEntity::getEnabledMark, 1);
- queryWrapper.lambda().orderByAsc(UserEntity::getSortCode).orderByDesc(UserEntity::getCreatorTime);
- return this.list(queryWrapper);
- }
- @Override
- public UserEntity getInfo(String id) {
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().eq(UserEntity::getId, String.valueOf(id));
- return this.getOne(queryWrapper);
- }
- @Override
- public UserEntity getUserByAccount(String account) {
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().eq(UserEntity::getAccount, account);
- return this.getOne(queryWrapper);
- }
- @Override
- public UserEntity getUserByMobile(String mobile) {
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().eq(UserEntity::getMobilePhone, mobile);
- List<UserEntity> list = this.list(queryWrapper);
- return CollectionUtil.isNotEmpty(list) ? list.get(0) : null;
- }
- @Override
- public Boolean setAdminListByIds(List<String> adminIds) {
- // 将所有的管理员取消
- QueryWrapper<UserEntity> query = new QueryWrapper<>();
- query.lambda().eq(UserEntity::getIsAdministrator, 1);
- // admin不允许移除管理员
- query.lambda().ne(UserEntity::getAccount, ADMIN_KEY);
- List<UserEntity> list1 = this.list(query);
- for (UserEntity entity : list1) {
- entity.setIsAdministrator(0);
- this.updateById(entity);
- }
- // 重新赋值管理员
- List<UserEntity> list = new ArrayList<>();
- adminIds.stream().forEach(adminId -> {
- UserEntity userEntity = new UserEntity();
- userEntity.setId(adminId);
- userEntity.setIsAdministrator(1);
- // admin无需添加
- if (!ADMIN_KEY.equals(userEntity.getAccount())) {
- list.add(userEntity);
- }
- });
- List<String> adminList = list1.stream().map(UserEntity::getId).collect(Collectors.toList());
- adminList.removeAll(list.stream().map(UserEntity::getId).collect(Collectors.toList()));
- delCurUser(MsgCode.PS010.get(), adminList);
- updateStand(adminList, 1);
- return this.updateBatchById(list);
- }
- @Override
- public boolean isExistByAccount(String account) {
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().eq(UserEntity::getAccount, account);
- List<UserEntity> list = this.list(queryWrapper);
- if (CollectionUtil.isNotEmpty(list)) {
- return true;
- }
- return false;
- }
- @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();
- 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());
- userRelationService.save(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());
- userRelationService.save(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());
- userRelationService.save(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());
- roleRelationService.save(posRelation);
- }
- } else {
- //创建没有角色的时候,默认使用者
- RoleEntity byEnCode = roleService.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());
- roleRelationService.save(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());
- //删除用户关联
- QueryWrapper<UserRelationEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().eq(UserRelationEntity::getUserId, entity.getId());
- userRelationService.remove(queryWrapper);
- //删除用户关联角色
- QueryWrapper<RoleRelationEntity> roleRelationQuery = new QueryWrapper<>();
- roleRelationQuery.lambda().eq(RoleRelationEntity::getObjectId, entity.getId());
- roleRelationService.remove(roleRelationQuery);
- //删除用户绑定关系
- QueryWrapper<SocialsUserEntity> socialsUserEntityQueryWrapper = new QueryWrapper<>();
- socialsUserEntityQueryWrapper.lambda().eq(SocialsUserEntity::getUserId, entity.getId());
- socialsUserService.remove(socialsUserEntityQueryWrapper);
- }
- @Override
- @DSTransactional
- public void batchDelete(List<String> userIdList) {
- if (userIdList == null || userIdList.isEmpty()) {
- return;
- }
- this.removeBatchByIds(userIdList);
- //删除用户关联
- QueryWrapper<UserRelationEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().in(UserRelationEntity::getUserId, userIdList);
- userRelationService.remove(queryWrapper);
- //删除用户关联角色
- QueryWrapper<RoleRelationEntity> roleRelationQuery = new QueryWrapper<>();
- roleRelationQuery.lambda().in(RoleRelationEntity::getObjectId, userIdList);
- roleRelationService.remove(roleRelationQuery);
- }
- @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());
- userOldPasswordService.create(userOldPasswordEntity);
- }
- @Override
- public List<UserEntity> getUserName(List<String> id) {
- return getUserName(id, false);
- }
- /**
- * 查询用户名称
- *
- * @param id 主键值
- * @return
- */
- @Override
- public List<UserEntity> getUserName(List<String> id, boolean filterEnabledMark) {
- List<UserEntity> list = new ArrayList<>();
- // 达梦数据库无法null值入参
- id.removeAll(Collections.singleton(null));
- if (id.size() > 0) {
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().in(UserEntity::getId, id);
- if (filterEnabledMark) {
- queryWrapper.lambda().ne(UserEntity::getEnabledMark, 0);
- }
- list = this.list(queryWrapper);
- }
- return list;
- }
- @Override
- public List<UserEntity> getListByUserIds(List<String> id) {
- List<UserEntity> list = new ArrayList<>();
- // 达梦数据库无法null值入参
- id.removeAll(Collections.singleton(null));
- if (id.size() > 0) {
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().in(UserEntity::getId, id);
- list = this.list(queryWrapper);
- }
- return list;
- }
- @Override
- public List<UserEntity> getUserList(List<String> id) {
- List<UserEntity> list = new ArrayList<>();
- // 达梦数据库无法null值入参
- id.removeAll(Collections.singleton(null));
- if (id.size() > 0) {
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().in(UserEntity::getId, id);
- queryWrapper.lambda().eq(UserEntity::getEnabledMark, 1);
- list = this.list(queryWrapper);
- }
- return list;
- }
- @Override
- public UserEntity getUserEntity(String account) {
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().eq(UserEntity::getAccount, account);
- return this.baseMapper.selectOne(queryWrapper);
- }
- @Override
- public List<String> getListId() {
- return this.baseMapper.getListId();
- }
- @Override
- public void update(UserEntity entity, String type) {
- UpdateWrapper<UserEntity> wrapper = new UpdateWrapper<>();
- if ("Position".equals(type)) {
- wrapper.lambda().set(UserEntity::getPositionId, entity.getPositionId());
- } else {
- wrapper.lambda().set(UserEntity::getRoleId, entity.getRoleId());
- }
- wrapper.lambda().eq(UserEntity::getId, entity.getId());
- this.update(wrapper);
- }
- @Override
- public void updateLastTime(UserEntity entity, String type) {
- UpdateWrapper<UserEntity> wrapper = new UpdateWrapper<>();
- if ("Position".equals(type)) {
- wrapper.lambda().set(UserEntity::getPositionId, entity.getPositionId());
- } else {
- wrapper.lambda().set(UserEntity::getRoleId, entity.getRoleId());
- }
- wrapper.lambda().set(UserEntity::getLastModifyTime, new Date());
- wrapper.lambda().set(UserEntity::getLastModifyUserId, entity.getLastModifyUserId());
- wrapper.lambda().eq(UserEntity::getId, entity.getId());
- this.update(wrapper);
- }
- @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<UserEntity> 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<UserExportVO> modeList = new ArrayList<>();
- Map<String, OrganizeEntity> orgMaps = null;
- // 长度超过300代表是全部数据
- if (entityList.size() > 300) {
- orgMaps = organizeService.getOrgMaps(null, true, null);
- }
- // 得到民族集合
- List<DictionaryDataEntity> dataServiceList = dictionaryDataService.getListByTypeDataCode("Nation");
- Map<String, String> dataServiceMap = dataServiceList.stream().filter(t -> ObjectUtil.equal(t.getEnabledMark(), 1)).collect(Collectors.toMap(DictionaryDataEntity::getId, DictionaryDataEntity::getFullName));
- // 得到证件类型
- List<DictionaryDataEntity> dataServiceList1 = dictionaryDataService.getListByTypeDataCode("certificateType");
- Map<String, String> dataServiceMap1 = dataServiceList1.stream().filter(t -> ObjectUtil.equal(t.getEnabledMark(), 1)).collect(Collectors.toMap(DictionaryDataEntity::getId, DictionaryDataEntity::getFullName));
- // 得到文化程度
- List<DictionaryDataEntity> dataServiceList2 = dictionaryDataService.getListByTypeDataCode("Education");
- Map<String, String> dataServiceMap2 = dataServiceList2.stream().filter(t -> ObjectUtil.equal(t.getEnabledMark(), 1)).collect(Collectors.toMap(DictionaryDataEntity::getId, DictionaryDataEntity::getFullName));
- // 得到职级
- List<DictionaryDataEntity> dataServiceList3 = dictionaryDataService.getListByTypeDataCode("Rank");
- Map<String, String> dataServiceMap3 = dataServiceList3.stream().filter(t -> ObjectUtil.equal(t.getEnabledMark(), 1)).collect(Collectors.toMap(DictionaryDataEntity::getId, DictionaryDataEntity::getFullName));
- // 得到性别
- List<DictionaryDataEntity> dataServiceList4 = dictionaryDataService.getListByTypeDataCode("sex");
- Map<String, String> 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<UserRelationEntity> allOrgRelationByUserId = userRelationService.getAllOrgRelationByUserId(entity.getId());
- Map<String, String> orgIdNameMaps = organizeService.getInfoList();
- for (UserRelationEntity userRelationEntity : allOrgRelationByUserId) {
- String id = userRelationEntity.getObjectId();
- OrganizeEntity organize = null;
- // 得到该组织信息
- if (orgMaps != null) {
- organize = orgMaps.get(id);
- } else {
- organize = organizeService.getInfo(id);
- }
- // 得到父级id树
- if (organize != null && ObjectUtil.equal(organize.getEnabledMark(), 1) && StringUtil.isNotEmpty(organize.getOrganizeIdTree())) {
- stringJoiner.add(organizeService.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<UserRelationEntity> listByObjectType = userRelationService.getListByObjectType(entity.getId(), PermissionConst.POSITION);
- StringBuffer positionName = new StringBuffer();
- for (UserRelationEntity userRelationEntity : listByObjectType) {
- if (StringUtil.isNotEmpty(userRelationEntity.getObjectId())) {
- PositionEntity positionEntity = positionService.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<UserRelationEntity> listByObjectType1 = userRelationService.getListByObjectType(entity.getId(), PermissionConst.ROLE);
- StringBuffer roleName = new StringBuffer();
- for (UserRelationEntity userRelationEntity : listByObjectType1) {
- if (StringUtil.isNotEmpty(userRelationEntity.getObjectId())) {
- RoleEntity roleEntity = roleService.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<ExcelExportEntity> 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<String, Object> importPreview(List<UserExportVO> personList) {
- List<Map<String, Object>> dataRow = new ArrayList<>();
- List<Map<String, Object>> columns = new ArrayList<>();
- for (int i = 0; i < personList.size(); i++) {
- Map<String, Object> 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<String, Object> 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<String, Object> map = new HashMap<>();
- map.put("dataRow", dataRow);
- map.put("columns", columns);
- return map;
- }
- @Override
- public UserImportVO importData(List<UserExportVO> dataList) {
- // List<UserImportModel> importModels = new ArrayList<>(16);
- List<UserExportExceptionVO> exceptionList = new ArrayList<>(16);
- // 得到民族集合
- List<DictionaryDataEntity> dataServiceList = dictionaryDataService.getListByTypeDataCode("Nation");
- BiMap<String, String> dataServiceMap = HashBiMap.create(dataServiceList.stream().collect(Collectors.toMap(DictionaryDataEntity::getId, DictionaryDataEntity::getFullName)));
- // 得到证件类型
- List<DictionaryDataEntity> dataServiceList1 = dictionaryDataService.getListByTypeDataCode("certificateType");
- BiMap<String, String> dataServiceMap1 = HashBiMap.create(dataServiceList1.stream().collect(Collectors.toMap(DictionaryDataEntity::getId, DictionaryDataEntity::getFullName)));
- // 得到文化程度
- List<DictionaryDataEntity> dataServiceList2 = dictionaryDataService.getListByTypeDataCode("Education");
- BiMap<String, String> dataServiceMap2 = HashBiMap.create(dataServiceList2.stream().collect(Collectors.toMap(DictionaryDataEntity::getId, DictionaryDataEntity::getFullName)));
- // 得到职级
- List<DictionaryDataEntity> dataServiceList3 = dictionaryDataService.getListByTypeDataCode("Rank");
- BiMap<String, String> dataServiceMap3 = HashBiMap.create(dataServiceList3.stream().collect(Collectors.toMap(DictionaryDataEntity::getId, DictionaryDataEntity::getFullName)));
- // 得到性别
- List<DictionaryDataEntity> dataServiceList4 = dictionaryDataService.getListByTypeDataCode("sex");
- BiMap<String, String> dataServiceMap4 = HashBiMap.create(dataServiceList4.stream().collect(Collectors.toMap(DictionaryDataEntity::getEnCode, DictionaryDataEntity::getFullName)));
- // // 去除重复的account
- // Map<String, Long> collect = dataList.stream().filter(t -> StringUtil.isNotBlank(t.getAccount())).collect(Collectors.groupingBy(t -> t.getAccount(), Collectors.counting()));
- // List<String> collect1 = collect.entrySet().stream().filter(entry -> entry.getValue() > 1).map(entry -> entry.getKey()).collect(Collectors.toList());
- // for (String account : collect1) {
- // List<UserExportVO> collect2 = dataList.stream().filter(t -> account.equals(t.getAccount())).collect(Collectors.toList());
- // dataList.removeAll(collect2);
- // exceptionList.addAll(collect2);
- // }
- // Map<String, UserExportVO> userExportVOMap = dataList.stream().collect(Collectors.toMap(UserExportVO::getAccount, Function.identity()));
- //记录成功了几条
- 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 = organizeService.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<PositionEntity> positionEntityList = positionService.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<PositionEntity> list = positionService.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 = organizeService.getInfo(organizeId);
- if (Objects.nonNull(entity) && StringUtil.isNotEmpty(entity.getParentId())) {
- // 记录id
- organizeParentIdList.append(organizeId + ",");
- getOrganizeIdTree(entity.getParentId(), organizeParentIdList);
- }
- }
- @Override
- public DownloadVO exportExceptionData(List<UserExportExceptionVO> 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<UserEntity> getUserName(List<String> id, Pagination pagination) {
- List<UserEntity> list = new ArrayList<>();
- id.removeAll(Collections.singleton(null));
- if (id.size() > 0) {
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- if (!StringUtil.isEmpty(pagination.getKeyword())) {
- queryWrapper.lambda().and(
- t -> t.like(UserEntity::getRealName, pagination.getKeyword())
- .or().like(UserEntity::getAccount, pagination.getKeyword())
- );
- }
- queryWrapper.lambda().in(UserEntity::getId, id);
- queryWrapper.lambda().ne(UserEntity::getEnabledMark, 0);
- queryWrapper.lambda().select(UserEntity::getId, UserEntity::getRealName, UserEntity::getAccount,
- UserEntity::getGender, UserEntity::getHeadIcon, UserEntity::getMobilePhone);
- Page<UserEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
- IPage<UserEntity> iPage = this.page(page, queryWrapper);
- return pagination.setData(iPage.getRecords(), iPage.getTotal());
- }
- return pagination.setData(list, list.size());
- }
- @Override
- public List<UserEntity> getUserNames(List<String> id, PaginationUser pagination, Boolean flag, Boolean enabledMark) {
- List<UserEntity> list = new ArrayList<>();
- id.removeAll(Collections.singleton(null));
- if (id.size() > 0) {
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- if (!StringUtil.isEmpty(pagination.getKeyword())) {
- queryWrapper.lambda().and(
- t -> t.like(UserEntity::getRealName, pagination.getKeyword())
- .or().like(UserEntity::getAccount, pagination.getKeyword())
- .or().like(UserEntity::getMobilePhone, pagination.getKeyword())
- );
- }
- List<List<String>> lists = Lists.partition(id, 1000);
- queryWrapper.lambda().and(t -> {
- for (List<String> userId : lists) {
- t.or().in(UserEntity::getId, userId);
- }
- });
- if (flag) {
- queryWrapper.lambda().ne(UserEntity::getId, UserProvider.getUser().getUserId());
- }
- if (enabledMark) {
- queryWrapper.lambda().ne(UserEntity::getEnabledMark, 0);
- }
- if (StringUtil.isNotEmpty(pagination.getGender())) {
- queryWrapper.lambda().eq(UserEntity::getGender, pagination.getGender());
- }
- queryWrapper.lambda().orderByDesc(UserEntity::getCreatorTime);
- // queryWrapper.lambda().select(UserEntity::getId, UserEntity::getRealName, UserEntity::getAccount,
- // UserEntity::getGender, UserEntity::getMobilePhone);
- if (ObjectUtil.isEmpty(pagination) || Objects.equals(pagination.getDataType(), 1)) {
- return this.list(queryWrapper);
- }
- Page<UserEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
- IPage<UserEntity> iPage = this.page(page, queryWrapper);
- return pagination.setData(iPage.getRecords(), iPage.getTotal());
- }
- return ObjectUtil.isEmpty(pagination) ? new ArrayList<>() : pagination.setData(list, list.size());
- }
- @Override
- public List<UserEntity> getListByRoleId(String roleId) {
- List<UserEntity> list = new ArrayList<>();
- // 根据roleId获取,用户与组织的关联对象集合
- userRelationService.getListByRoleId(roleId).forEach(u -> {
- list.add(this.getInfo(u.getUserId()));
- });
- return list;
- }
- @Override
- public List<UserEntity> getListByRoleIds(List<String> roleIds) {
- QueryWrapper<UserRelationEntity> query = new QueryWrapper<>();
- query.lambda().eq(UserRelationEntity::getObjectType, "role").in(UserRelationEntity::getObjectId, roleIds);
- List<UserRelationEntity> list = userRelationService.list(query);
- if (CollectionUtil.isNotEmpty(list)) {
- List<String> userIds = list.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList());
- return listByIds(userIds);
- }
- return new ArrayList<>();
- }
- @Override
- public List<String> getFullNameByIds(List<String> ids) {
- List<String> 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 = organizeService.getInfo(split[0]);
- if (organizeEntity != null) {
- list.add(organizeEntity.getFullName());
- }
- } else if (PermissionConst.ROLE.equalsIgnoreCase(type)) {
- RoleEntity roleEntity = roleService.getInfo(split[0]);
- if (roleEntity != null) {
- list.add(roleEntity.getFullName());
- }
- } else if (PermissionConst.POSITION.equalsIgnoreCase(type)) {
- PositionEntity positionEntity = positionService.getInfo(split[0]);
- if (positionEntity != null) {
- list.add(positionEntity.getFullName());
- }
- } else if (PermissionConst.GROUP.equalsIgnoreCase(type)) {
- GroupEntity groupEntity = groupService.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<BaseInfoVo> selectedByIds(List<String> ids) {
- List<BaseInfoVo> list = new ArrayList<>();
- List<OrganizeEntity> organizeEntityList = organizeService.list();
- Map<String, Object> allOrgsTreeName = organizeService.getAllOrgsTreeName();
- List<OrganizeSelectorVO> 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<String, String> orgIdNameMaps = organizeService.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 = organizeService.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(organizeService.getFullNameByOrgIdTree(orgIdNameMaps, organizeEntity.getOrganizeIdTree(), "/"));
- vo.setOrganizeIds(organizeService.getOrgIdTree(organizeEntity));
- vo.setType(organizeEntity.getCategory());
- list.add(vo);
- }
- } else if (PermissionConst.ROLE.equalsIgnoreCase(type)) {
- RoleEntity roleEntity = roleService.getInfo(split[0]);
- if (roleEntity != null) {
- BaseInfoVo vo = JsonUtil.getJsonToBean(roleEntity, BaseInfoVo.class);
- List<RoleRelationEntity> relationListByRoleId = roleRelationService.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 = positionService.getInfo(split[0]);
- if (positionEntity != null) {
- BaseInfoVo vo = JsonUtil.getJsonToBean(positionEntity, BaseInfoVo.class);
- vo.setId(selectedId);
- OrganizeEntity info = organizeService.getInfo(positionEntity.getOrganizeId());
- String orgName = "" ;
- if (info != null) {
- vo.setOrganize(organizeService.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 = groupService.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<UserRelationEntity> listByObjectType = userRelationService.getListByObjectType(userEntity.getId(), PermissionConst.ORGANIZE);
- StringJoiner orgName = new StringJoiner(",");
- listByObjectType.forEach(userRelationEntity -> {
- OrganizeEntity info = organizeService.getInfo(userRelationEntity.getObjectId());
- if (info != null) {
- String fullNameByOrgIdTree = organizeService.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<OrganizeSelectorVO> 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<String, String> orgIdNameMaps, List<BaseInfoVo> list, String userName) {
- BaseInfoVo vo = JsonUtil.getJsonToBean(userEntity, BaseInfoVo.class);
- List<UserRelationEntity> listByObjectType = userRelationService.getListByObjectType(userEntity.getId(), PermissionConst.ORGANIZE);
- StringJoiner orgName = new StringJoiner(",");
- listByObjectType.forEach(userRelationEntity -> {
- OrganizeEntity info = organizeService.getInfo(userRelationEntity.getObjectId());
- if (info != null) {
- String fullNameByOrgIdTree = organizeService.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<String> objectIdAll) {
- List<PermissionGroupEntity> list = permissionGroupService.list(objectIdAll).stream().filter(t -> Objects.equals(t.getEnabledMark(), 1)).collect(Collectors.toList());
- List<String> member = list.stream().filter(t -> StringUtil.isNotEmpty(t.getPermissionMember())).map(PermissionGroupEntity::getPermissionMember).collect(Collectors.toList());
- List<String> 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<UserEntity> getList(List<String> orgIdList, String keyword) {
- // 得到用户关系表
- List<UserRelationEntity> listByObjectId = userRelationService.getListByOrgId(orgIdList);
- if (listByObjectId.isEmpty()) {
- return new ArrayList<>();
- }
- QueryWrapper<UserEntity> 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<UserEntity> getListBySyn(List<String> orgIdList, String keyword) {
- // 得到用户关系表
- List<UserRelationEntity> listByObjectId = userRelationService.getListByOrgId(orgIdList);
- //根据userId分类
- Map<String, List<UserRelationEntity>> collect = listByObjectId.stream().collect(Collectors.groupingBy(UserRelationEntity::getUserId));
- if (listByObjectId.isEmpty()) {
- return new ArrayList<>();
- }
- QueryWrapper<UserEntity> 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<UserEntity> list = this.list(queryWrapper);
- ArrayList<UserEntity> userEntities = new ArrayList<>();
- for (UserEntity userEntity : list) {
- List<UserRelationEntity> 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<String> getUserIdList(List<String> idList) {
- Set<String> 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 = userService.getInfo(selectedId);
- if (BeanUtil.isNotEmpty(info)) {
- userIds.add(info.getId());
- }
- return;
- }
- if (selectedId.substring(selectedId.length() - 3).equalsIgnoreCase(SysParamEnum.ORG.getCode())) {
- ArrayList<String> strings = new ArrayList<>();
- if (selectedId.contains(SysParamEnum.SUBORG.getCode())) {
- List<OrganizeEntity> listByParentId = organizeService.getListByParentId(split[0]);
- if (listByParentId != null) {
- strings.addAll(listByParentId.stream().map(OrganizeEntity::getId).collect(Collectors.toList()));
- }
- }
- if (selectedId.contains(SysParamEnum.PROGENYORG.getCode())) {
- List<OrganizeEntity> grandSonList = organizeService.getAllChild(split[0]);
- if (grandSonList != null) {
- strings.addAll(grandSonList.stream().map(OrganizeEntity::getId).collect(Collectors.toList()));
- }
- }
- strings.add(split[0]);
- List<PositionEntity> listByOrgIds = positionService.getListByOrgIds(strings.stream()
- .filter(Objects::nonNull).collect(Collectors.toList()));
- List<String> positionIds = listByOrgIds.stream().map(PositionEntity::getId).collect(Collectors.toList());
- List<UserRelationEntity> listByObjectIdAll = userRelationService.getListByObjectIdAll(positionIds);
- userIds.addAll(listByObjectIdAll.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList()));
- } else if (selectedId.substring(selectedId.length() - 3).equalsIgnoreCase(SysParamEnum.POS.getCode())) {
- ArrayList<String> strings = new ArrayList<>();
- strings.add(split[0]);
- PositionEntity info = positionService.getInfo(split[0]);
- if (info != null && selectedId.contains(SysParamEnum.SUBPOS.getCode())) {
- List<PositionEntity> byParentId = positionService.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<PositionEntity> grandSonList = positionService.getAllChild(info.getId());
- if (null != grandSonList) {
- strings.addAll(grandSonList.stream().map(PositionEntity::getId).collect(Collectors.toList()));
- }
- }
- List<String> collect = userRelationService.getListByObjectIdAll(strings)
- .stream()
- .map(UserRelationEntity::getUserId)
- .collect(Collectors.toList());
- userIds.addAll(collect);
- } else if (selectedId.contains(SysParamEnum.GROUP.getCode())) {
- List<String> collect = userRelationService.getListByObjectId(split[0])
- .stream()
- .map(UserRelationEntity::getUserId)
- .collect(Collectors.toList());
- userIds.addAll(collect);
- } else if (selectedId.contains(SysParamEnum.ROLE.getCode())) {
- List<String> collect = roleRelationService.getListByRoleId(split[0], PermissionConst.USER)
- .stream()
- .map(RoleRelationEntity::getObjectId)
- .collect(Collectors.toList());
- userIds.addAll(collect);
- } else if (selectedId.contains(SysParamEnum.USER.getCode())) {
- UserEntity info = userService.getInfo(split[0]);
- if (BeanUtil.isNotEmpty(info)) {
- userIds.add(info.getId());
- }
- }
- }
- });
- return new ArrayList<>(userIds);
- }
- @Override
- public List<BaseInfoVo> getObjList(List<String> userIds, PaginationUser pagination) {
- // 得到所有的用户id关系
- Map<String, String> orgIdNameMaps = organizeService.getInfoList();
- List<UserEntity> userEntityList = getUserIdListByOrganize(userIds, pagination);
- if (userEntityList.isEmpty()) {
- return Collections.emptyList();
- }
- List<UserIdListVo> jsonToList = JsonUtil.getJsonToList(userEntityList, UserIdListVo.class);
- jsonToList.forEach(userIdListVo -> {
- List<UserRelationEntity> listByObjectType = userRelationService.getListByObjectType(userIdListVo.getId(), PermissionConst.ORGANIZE);
- StringJoiner orgName = new StringJoiner(",");
- listByObjectType.forEach(userRelationEntity -> {
- OrganizeEntity info = organizeService.getInfo(userRelationEntity.getObjectId());
- if (info != null) {
- String fullNameByOrgIdTree = organizeService.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<UserEntity> getUserIdListByOrganize(List<String> userIds, PaginationUser pagination) {
- List<String> userObjectIds = getUserIdList(userIds);
- if (userObjectIds.isEmpty()) {
- return Collections.emptyList();
- }
- LambdaQueryWrapper<UserEntity> wrapper = new LambdaQueryWrapper<>();
- wrapper.ne(UserEntity::getAccount, ADMIN_KEY);
- wrapper.ne(UserEntity::getEnabledMark, 0);
- //idList范围过滤
- if (userObjectIds.size() > 1000) {
- List<List<String>> lists = Lists.partition(userObjectIds, 1000);
- wrapper.and(t -> {
- for (List<String> 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())
- );
- }
- Page<UserEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
- IPage<UserEntity> iPage = userService.page(page, wrapper);
- return pagination.setData(iPage.getRecords(), iPage.getTotal());
- }
- @Override
- public List<UserByRoleVO> getListByAuthorize(String organizeId, jnpf.base.Page page) {
- List<UserByRoleVO> jsonToList = new ArrayList<>(16);
- List<String> collect0 = organizeAdministratorService.getListByAuthorize().stream().map(OrganizeEntity::getId).collect(Collectors.toList());
- // 有权限的组织
- Map<String, OrganizeEntity> orgMaps = organizeService.getOrganizeName(collect0, null, true, null);
- Map<String, String> orgIdNameMaps = organizeService.getInfoList();
- List<DictionaryDataEntity> dataServiceList4 = dictionaryDataService.getListByTypeDataCode("sex");
- Map<String, String> dataServiceMap4 = dataServiceList4.stream().filter(t -> ObjectUtil.equal(t.getEnabledMark(), 1)).collect(Collectors.toMap(DictionaryDataEntity::getEnCode, DictionaryDataEntity::getFullName));
- //判断是否搜索关键字
- if (StringUtil.isNotEmpty(page.getKeyword())) {
- //通过关键字查询
- List<UserEntity> list = getList(new ArrayList<>(orgMaps.keySet()), page.getKeyword());
- //遍历用户给要返回的值插入值
- for (UserEntity entity : list) {
- UserByRoleVO vo = new UserByRoleVO();
- vo.setHeadIcon(UploaderUtil.uploaderImg(entity.getHeadIcon()));
- vo.setId(entity.getId());
- vo.setFullName(entity.getRealName() + "/" + entity.getAccount());
- vo.setEnabledMark(entity.getEnabledMark());
- vo.setIsLeaf(true);
- vo.setHasChildren(false);
- vo.setIcon(PermissionConst.USER_ICON);
- vo.setType("user");
- vo.setGender(dataServiceMap4.get(entity.getGender()));
- List<UserRelationEntity> listByUserId = userRelationService.getListByUserId(entity.getId()).stream().filter(t -> t != null && PermissionConst.ORGANIZE.equals(t.getObjectType())).collect(Collectors.toList());
- StringBuilder stringBuilder = new StringBuilder();
- listByUserId.forEach(t -> {
- OrganizeEntity organizeEntity = orgMaps.get(t.getObjectId());
- if (organizeEntity != null) {
- String fullNameByOrgIdTree = organizeService.getFullNameByOrgIdTree(orgIdNameMaps, organizeEntity.getOrganizeIdTree(), "/");
- if (StringUtil.isNotEmpty(fullNameByOrgIdTree)) {
- stringBuilder.append("," + fullNameByOrgIdTree);
- }
- }
- });
- if (stringBuilder.length() > 0) {
- vo.setOrganize(stringBuilder.toString().replaceFirst(",", ""));
- }
- jsonToList.add(vo);
- }
- return jsonToList;
- }
- //获取所有组织
- List<OrganizeEntity> collect = new ArrayList<>(orgMaps.values());
- //判断时候传入组织id
- //如果传入组织id,则取出对应的子集
- if (!"0".equals(organizeId)) {
- //通过组织查询部门及人员
- OrganizeEntity organizeEntity = orgMaps.get(organizeId);
- if (organizeEntity != null) {
- // 取出子组织
- List<OrganizeEntity> collect1 = collect.stream().filter(t -> !t.getId().equals(organizeEntity.getId()) && t.getOrganizeIdTree().contains(organizeEntity.getId())).collect(Collectors.toList());
- // 判断组织关系中是否有子部门id
- List<OrganizeEntity> organizeEntities = new ArrayList<>();
- for (OrganizeEntity entity : collect1) {
- OrganizeEntity organizeEntity1 = orgMaps.get(entity.getId());
- if (organizeEntity1 != null) {
- organizeEntities.add(organizeEntity1);
- }
- }
- // 得到子集的子集
- List<OrganizeEntity> collect2 = collect.stream().filter(t -> t.getOrganizeIdTree().contains(organizeId)).collect(Collectors.toList());
- // 移除掉上级不是同一个的
- List<OrganizeEntity> collect3 = new ArrayList<>();
- collect2.forEach(t -> {
- organizeEntities.forEach(oe -> {
- if (!oe.getId().equals(t.getId()) && t.getOrganizeIdTree().contains(oe.getId())) {
- collect3.add(t);
- }
- });
- });
- organizeEntities.removeAll(collect3);
- //取出组织下的人员
- List<UserEntity> entityList = getListByOrganizeId(organizeId, null);
- for (UserEntity entity : entityList) {
- UserByRoleVO vo = new UserByRoleVO();
- vo.setId(entity.getId());
- vo.setHeadIcon(UploaderUtil.uploaderImg(entity.getHeadIcon()));
- vo.setFullName(entity.getRealName() + "/" + entity.getAccount());
- vo.setEnabledMark(entity.getEnabledMark());
- vo.setIsLeaf(true);
- vo.setHasChildren(false);
- vo.setIcon(PermissionConst.USER_ICON);
- vo.setType("user");
- vo.setGender(dataServiceMap4.get(entity.getGender()));
- List<UserRelationEntity> listByUserId = userRelationService.getListByUserId(entity.getId()).stream().filter(t -> t != null && PermissionConst.ORGANIZE.equals(t.getObjectType())).collect(Collectors.toList());
- StringJoiner stringJoiner = new StringJoiner(",");
- listByUserId.forEach(t -> {
- OrganizeEntity organizeEntity1 = orgMaps.get(t.getObjectId());
- if (organizeEntity1 != null) {
- String fullNameByOrgIdTree = organizeService.getFullNameByOrgIdTree(orgIdNameMaps, organizeEntity1.getOrganizeIdTree(), "/");
- if (StringUtil.isNotEmpty(fullNameByOrgIdTree)) {
- stringJoiner.add(fullNameByOrgIdTree);
- }
- }
- });
- vo.setOrganize(stringJoiner.toString());
- jsonToList.add(vo);
- }
- for (OrganizeEntity entitys : organizeEntities) {
- UserByRoleVO vo = new UserByRoleVO();
- vo.setId(entitys.getId());
- vo.setType(entitys.getCategory());
- vo.setFullName(entitys.getFullName());
- if ("department".equals(entitys.getCategory())) {
- vo.setIcon(PermissionConst.DEPARTMENT_ICON);
- } else {
- vo.setIcon(PermissionConst.COMPANY_ICON);
- }
- vo.setHasChildren(true);
- vo.setIsLeaf(false);
- vo.setEnabledMark(entitys.getEnabledMark());
- if (StringUtil.isNotEmpty(entitys.getOrganizeIdTree())) {
- String[] split = entitys.getOrganizeIdTree().split(organizeEntity.getId());
- if (split.length > 1) {
- vo.setFullName(organizeService.getFullNameByOrgIdTree(orgIdNameMaps, split[1], "/"));
- }
- }
- jsonToList.add(vo);
- }
- }
- return jsonToList;
- }
- List<String> list = new ArrayList<>(16);
- for (OrganizeEntity organizeEntity : collect) {
- if (organizeEntity != null && organizeEntity.getEnabledMark() == 1) {
- UserByRoleVO userByRoleVO = new UserByRoleVO();
- userByRoleVO.setId(organizeEntity.getId());
- userByRoleVO.setType(organizeEntity.getCategory());
- if ("department".equals(organizeEntity.getCategory())) {
- userByRoleVO.setIcon(PermissionConst.DEPARTMENT_ICON);
- } else {
- userByRoleVO.setIcon(PermissionConst.COMPANY_ICON);
- }
- userByRoleVO.setHasChildren(true);
- userByRoleVO.setIsLeaf(false);
- userByRoleVO.setEnabledMark(organizeEntity.getEnabledMark());
- // 处理断层
- if (StringUtil.isNotEmpty(organizeEntity.getOrganizeIdTree())) {
- List<String> list1 = new ArrayList<>();
- String[] split = organizeEntity.getOrganizeIdTree().split(",");
- list1 = Arrays.asList(split);
- Collections.reverse(list1);
- for (String orgId : list1) {
- OrganizeEntity organizeEntity1 = orgMaps.get(orgId);
- if (organizeEntity1 != null && !organizeEntity1.getId().equals(organizeEntity.getId())) {
- // 记录id
- list.add(organizeEntity.getId());
- break;
- }
- }
- }
- if (!list.contains(organizeEntity.getId())) {
- jsonToList.add(userByRoleVO);
- }
- }
- }
- jsonToList.forEach(t -> {
- OrganizeEntity entity = orgMaps.get(t.getId());
- if (entity != null) {
- t.setFullName(organizeService.getFullNameByOrgIdTree(orgIdNameMaps, entity.getOrganizeIdTree(), "/"));
- }
- t.setParentId(entity.getParentId());
- });
- return jsonToList;
- }
- private String getColumns(Integer key) {
- Map<Integer, String> 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<OrganizeEntity> orgList = organizeService.getOrgEntityList(userConditionModel.getDepartIds(), true);
- List<String> orgLIdList = orgList.stream().map(OrganizeEntity::getId).collect(Collectors.toList());
- if (orgLIdList != null && !orgLIdList.isEmpty()) {
- List<String> userIds = userRelationService.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<RoleEntity> roleList = roleService.getListByIds(userConditionModel.getRoleIds(), null, false);
- List<String> roleIdList = roleList.stream().filter(t -> t.getEnabledMark() == 1).map(RoleEntity::getId).collect(Collectors.toList());
- if (roleIdList != null && !roleIdList.isEmpty()) {
- List<String> userIds = userRelationService.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<PositionEntity> positionList = positionService.getPosList(userConditionModel.getPositionIds());
- List<String> positionIdList = positionList.stream().filter(t -> t.getEnabledMark() == 1).map(PositionEntity::getId).collect(Collectors.toList());
- if (positionIdList != null && !positionIdList.isEmpty()) {
- List<String> userIds = userRelationService.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<GroupEntity> groupList = groupService.getListByIds(userConditionModel.getGroupIds());
- List<String> groupIdList = groupList.stream().map(GroupEntity::getId).collect(Collectors.toList());
- if (groupIdList != null && !groupIdList.isEmpty()) {
- List<String> userIds = userRelationService.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<UserEntity> getUserAccount(List<String> ids) {
- List<UserEntity> list = new ArrayList<>();
- if (!ids.isEmpty()) {
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().in(UserEntity::getAccount, ids);
- list = this.list(queryWrapper);
- }
- return list;
- }
- @Override
- public void updateStand(List<String> ids, int standing) {
- List<UserEntity> userName = getUserName(new ArrayList<>(ids), false);
- for (UserEntity user : userName) {
- String positionId = user.getPositionId();
- String organizeId = user.getOrganizeId();
- String id = user.getId();
- UpdateWrapper<UserEntity> wrapper = new UpdateWrapper<>();
- wrapper.lambda().eq(UserEntity::getId, id);
- wrapper.lambda().set(UserEntity::getOrganizeId, organizeId);
- wrapper.lambda().set(UserEntity::getPositionId, positionId);
- update(wrapper);
- }
- if (!ids.isEmpty()) {
- UpdateWrapper<UserEntity> pcWrapper = new UpdateWrapper<>();
- pcWrapper.lambda().in(UserEntity::getId, ids);
- pcWrapper.lambda().eq(UserEntity::getStanding, standing);
- pcWrapper.lambda().set(UserEntity::getStanding, 3);
- update(pcWrapper);
- UpdateWrapper<UserEntity> appWrapper = new UpdateWrapper<>();
- appWrapper.lambda().in(UserEntity::getId, ids);
- appWrapper.lambda().eq(UserEntity::getAppStanding, standing);
- appWrapper.lambda().set(UserEntity::getAppStanding, 3);
- update(appWrapper);
- }
- }
- @Override
- public Boolean delCurUser(String message, List<String> userIds) {
- if (userIds.isEmpty()) {
- return true;
- }
- //用户不强制下线,websokit推送刷新即可
- List<OnlineUserModel> users = new ArrayList<>();
- List<OnlineUserModel> onlineUserList = OnlineUserProvider.getOnlineUserList();
- for (OnlineUserModel onlineUserModel : onlineUserList) {
- String userId = onlineUserModel.getUserId();
- if (userIds.contains(userId)) {
- users.add(onlineUserModel);
- }
- }
- if (!ObjectUtils.isEmpty(users)) {
- for (OnlineUserModel user : users) {
- JSONObject obj = new JSONObject();
- obj.put("method", "refresh");
- obj.put("msg", StringUtil.isEmpty(message) ? MsgCode.PS010.get() : message);
- if (user != null) {
- OnlineUserProvider.sendMessage(user, obj);
- }
- }
- }
- return true;
- }
- @Override
- public void majorStandFreshUser() {
- UserInfo userInfo = UserProvider.getUser();
- List<OnlineUserModel> onlineUserList = OnlineUserProvider.getOnlineUserList();
- for (OnlineUserModel onlineUserModel : onlineUserList) {
- String userId = onlineUserModel.getUserId();
- //当前用户,同平台的其他客户端需要强制刷新
- if (userInfo.getUserId().equals(userId)
- && Objects.equals(!RequestContext.isOrignPc(), onlineUserModel.getIsMobileDevice())) {
- JSONObject obj = new JSONObject();
- obj.put("method", "refresh");
- obj.put("msg", MsgCode.PS010.get());
- OnlineUserProvider.sendMessage(onlineUserModel, obj);
- }
- }
- }
- @Override
- public Boolean logoutUser(String message, List<String> userIds) {
- if (userIds.isEmpty()) {
- return true;
- }
- //用户不强制下线
- List<OnlineUserModel> users = new ArrayList<>();
- List<OnlineUserModel> onlineUserList = OnlineUserProvider.getOnlineUserList();
- for (OnlineUserModel onlineUserModel : onlineUserList) {
- String userId = onlineUserModel.getUserId();
- if (userIds.contains(userId) && !Objects.equals(UserProvider.getUser().getToken(), onlineUserModel.getToken())) {
- users.add(onlineUserModel);
- }
- }
- if (!ObjectUtils.isEmpty(users)) {
- for (OnlineUserModel user : users) {
- JSONObject obj = new JSONObject();
- obj.put("method", "logout");
- obj.put("msg", StringUtil.isEmpty(message) ? MsgCode.PS011.get() : message);
- if (user != null) {
- OnlineUserProvider.sendMessage(user, obj);
- }
- //先移除对象, 并推送下线信息, 避免网络原因导致就用户未断开 新用户连不上WebSocket
- OnlineUserProvider.removeModel(user);
- //通知所有在线,有用户离线
- //功能已删除
- // for (OnlineUserModel item : OnlineUserProvider.getOnlineUserList().stream().filter(t -> !Objects.equals(user.getUserId(), t.getUserId()) && Objects.equals(user.getTenantId(), t.getTenantId())).collect(Collectors.toList())) {
- // if (!item.getUserId().equals(user.getUserId())) {
- // JSONObject objs = new JSONObject();
- // objs.put("method", "Offline");
- // //推送给前端
- // OnlineUserProvider.sendMessage(item, objs);
- // }
- // }
- UserProvider.logoutByToken(user.getToken());
- }
- }
- return true;
- }
- @Override
- public List<UserEntity> getPageByIds(RoleRelationPage pagination) {
- QueryWrapper<UserEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().select(UserEntity::getId, UserEntity::getAccount, UserEntity::getRealName, UserEntity::getGender,
- UserEntity::getMobilePhone, UserEntity::getEnabledMark);
- boolean flag = false;
- //关键字(账户、姓名、手机)
- if (!StringUtil.isEmpty(pagination.getKeyword())) {
- flag = true;
- queryWrapper.lambda().and(
- t -> t.like(UserEntity::getAccount, pagination.getKeyword())
- .or().like(UserEntity::getRealName, pagination.getKeyword())
- .or().like(UserEntity::getMobilePhone, pagination.getKeyword())
- );
- }
- List<List<String>> lists = Lists.partition(pagination.getIdList(), 1000);
- queryWrapper.lambda().and(t -> {
- for (List<String> item : lists) {
- t.in(UserEntity::getId, item).or();
- }
- });
- queryWrapper.lambda().orderByAsc(UserEntity::getSortCode).orderByDesc(UserEntity::getCreatorTime);
- if (flag) {
- queryWrapper.lambda().orderByDesc(UserEntity::getLastModifyTime);
- return this.list(queryWrapper);
- }
- Page<UserEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
- IPage<UserEntity> iPage = this.page(page, queryWrapper);
- return pagination.setData(iPage.getRecords(), iPage.getTotal());
- }
- @Override
- public UserRelationIds getUserObjectIdList(String userId) {
- List<UserRelationEntity> listUser = userRelationService.getListByObjectType(userId, null);
- List<String> group = listUser.stream().filter(t -> PermissionConst.GROUP.equals(t.getObjectType())).map(UserRelationEntity::getObjectId).collect(Collectors.toList());
- List<String> organize = listUser.stream().filter(t -> PermissionConst.ORGANIZE.equals(t.getObjectType())).map(UserRelationEntity::getObjectId).collect(Collectors.toList());
- List<String> position = listUser.stream().filter(t -> PermissionConst.POSITION.equals(t.getObjectType())).map(UserRelationEntity::getObjectId).collect(Collectors.toList());
- List<String> 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<String> role = roleRelationService.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<String, String> getSystemFieldValue(SystemParamModel model) {
- Map<String, String> mapList = new HashMap<>();
- List<String> needList = model.getList();
- UserInfo userInfo = UserProvider.getUser();
- String userId = userInfo.getUserId();
- List<String> organizeIds = userInfo.getOrganizeIds();
- List<String> positionIds = userInfo.getPositionIds();
- for (String key : needList) {
- List<String> 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(userRelationService.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(userRelationService.getUserProgeny(positionIds, null).stream()
- .map(SuperBaseEntity.SuperIBaseEntity::getId).collect(Collectors.toList()));
- }
- values = JsonUtil.getObjectToString(dataValue);
- break;
- case DataInterfaceVarConst.ORGANDSUB:
- if (!organizeIds.isEmpty()) {
- List<OrganizeEntity> listByParentIds = organizeService.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<OrganizeEntity> allChild = organizeService.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<PositionEntity> listByParentIds = positionService.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<PositionEntity> allChild = positionService.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;
- }
- }
|