RoleRelationServiceImpl.java 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. package jnpf.permission.service.impl;
  2. import cn.hutool.core.collection.CollectionUtil;
  3. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4. import com.baomidou.mybatisplus.core.metadata.IPage;
  5. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  6. import com.github.yulichang.toolkit.JoinWrappers;
  7. import com.github.yulichang.wrapper.MPJLambdaWrapper;
  8. import com.google.common.collect.Lists;
  9. import jnpf.base.ActionResult;
  10. import jnpf.base.service.SuperServiceImpl;
  11. import jnpf.constant.MsgCode;
  12. import jnpf.constant.PermissionConst;
  13. import jnpf.permission.entity.*;
  14. import jnpf.permission.mapper.RoleRelationMapper;
  15. import jnpf.permission.model.position.PosConModel;
  16. import jnpf.permission.model.rolerelaiton.*;
  17. import jnpf.permission.service.*;
  18. import jnpf.util.JsonUtil;
  19. import jnpf.util.RandomUtil;
  20. import jnpf.util.StringUtil;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.stereotype.Service;
  23. import java.util.*;
  24. import java.util.stream.Collectors;
  25. /**
  26. * 用户关系
  27. *
  28. * @author JNPF开发平台组
  29. * @version V3.1.0
  30. * @copyright 引迈信息技术有限公司
  31. * @date 2019年9月26日 上午9:18
  32. */
  33. @Service
  34. public class RoleRelationServiceImpl extends SuperServiceImpl<RoleRelationMapper, RoleRelationEntity> implements RoleRelationService {
  35. @Autowired
  36. private UserService userService;
  37. @Autowired
  38. private OrganizeService organizeService;
  39. @Autowired
  40. private PositionService positionService;
  41. @Autowired
  42. private UserRelationService userRelationService;
  43. @Autowired
  44. private RoleService roleService;
  45. @Override
  46. public List<RoleRelationEntity> getListPage(RoleListPage pagination) {
  47. String objectType = StringUtil.isNotEmpty(pagination.getPositionId()) ? PermissionConst.POSITION : PermissionConst.ORGANIZE;
  48. String objectId = StringUtil.isNotEmpty(pagination.getPositionId()) ? pagination.getPositionId() : pagination.getOrganizeId();
  49. QueryWrapper<RoleRelationEntity> queryWrapper = new QueryWrapper<>();
  50. queryWrapper.lambda().eq(RoleRelationEntity::getObjectId, objectId);
  51. queryWrapper.lambda().eq(RoleRelationEntity::getObjectType, objectType);
  52. queryWrapper.lambda().orderByDesc(RoleRelationEntity::getCreatorTime).orderByDesc(RoleRelationEntity::getId);
  53. Page<RoleRelationEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
  54. IPage<RoleRelationEntity> iPage = this.page(page, queryWrapper);
  55. return pagination.setData(iPage.getRecords(), iPage.getTotal());
  56. }
  57. @Override
  58. public List<RoleRelationUserVo> getUserPage(RoleRelationPage pagination) {
  59. MPJLambdaWrapper<RoleRelationEntity> queryWrapper = JoinWrappers.lambda(RoleRelationEntity.class);
  60. queryWrapper.selectAs(UserEntity::getId, RoleRelationUserVo::getId);
  61. queryWrapper.selectAs(UserEntity::getAccount, RoleRelationUserVo::getAccount);
  62. queryWrapper.selectAs(UserEntity::getRealName, RoleRelationUserVo::getRealName);
  63. queryWrapper.selectAs(UserEntity::getGender, RoleRelationUserVo::getGender);
  64. queryWrapper.selectAs(UserEntity::getMobilePhone, RoleRelationUserVo::getMobilePhone);
  65. queryWrapper.selectAs(UserEntity::getEnabledMark, RoleRelationUserVo::getEnabledMark);
  66. queryWrapper.leftJoin(UserEntity.class, UserEntity::getId, RoleRelationEntity::getObjectId);
  67. if (!StringUtil.isEmpty(pagination.getKeyword())) {
  68. queryWrapper.and(
  69. t -> t.like(UserEntity::getAccount, pagination.getKeyword())
  70. .or().like(UserEntity::getRealName, pagination.getKeyword())
  71. .or().like(UserEntity::getMobilePhone, pagination.getKeyword())
  72. );
  73. }
  74. queryWrapper.eq(RoleRelationEntity::getRoleId, pagination.getRoleId());
  75. queryWrapper.eq(RoleRelationEntity::getObjectType, pagination.getType());
  76. queryWrapper.orderByDesc(RoleRelationEntity::getCreatorTime).orderByDesc(RoleRelationEntity::getId);
  77. Page<RoleRelationUserVo> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
  78. IPage<RoleRelationUserVo> data = this.selectJoinListPage(page, RoleRelationUserVo.class, queryWrapper);
  79. return pagination.setData(data.getRecords(), page.getTotal());
  80. }
  81. @Override
  82. public List<RoleRelationOrgVo> getOrgPage(RoleRelationPage pagination) {
  83. MPJLambdaWrapper<RoleRelationEntity> queryWrapper = JoinWrappers.lambda(RoleRelationEntity.class);
  84. queryWrapper.leftJoin(OrganizeEntity.class, OrganizeEntity::getId, RoleRelationEntity::getObjectId);
  85. queryWrapper.selectAs(OrganizeEntity::getId, RoleRelationOrgVo::getId);
  86. queryWrapper.selectAs(OrganizeEntity::getFullName, RoleRelationOrgVo::getFullName);
  87. queryWrapper.selectAs(OrganizeEntity::getEnCode, RoleRelationOrgVo::getEnCode);
  88. queryWrapper.selectAs(OrganizeEntity::getOrgNameTree, RoleRelationOrgVo::getOrgNameTree);
  89. queryWrapper.selectAs(OrganizeEntity::getDescription, RoleRelationOrgVo::getDescription);
  90. if (!StringUtil.isEmpty(pagination.getKeyword())) {
  91. queryWrapper.and(
  92. t -> t.like(OrganizeEntity::getEnCode, pagination.getKeyword())
  93. .or().like(OrganizeEntity::getFullName, pagination.getKeyword())
  94. );
  95. }
  96. queryWrapper.eq(RoleRelationEntity::getRoleId, pagination.getRoleId());
  97. queryWrapper.eq(RoleRelationEntity::getObjectType, pagination.getType());
  98. queryWrapper.isNotNull(OrganizeEntity::getId);
  99. queryWrapper.orderByDesc(RoleRelationEntity::getCreatorTime).orderByDesc(RoleRelationEntity::getId);
  100. Page<RoleRelationOrgVo> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
  101. IPage<RoleRelationOrgVo> data = this.selectJoinListPage(page, RoleRelationOrgVo.class, queryWrapper);
  102. return pagination.setData(data.getRecords(), page.getTotal());
  103. }
  104. @Override
  105. public List<RoleRelationOrgVo> getPosPage(RoleRelationPage pagination) {
  106. MPJLambdaWrapper<RoleRelationEntity> queryWrapper = JoinWrappers.lambda(RoleRelationEntity.class);
  107. queryWrapper.leftJoin(PositionEntity.class, PositionEntity::getId, RoleRelationEntity::getObjectId);
  108. queryWrapper.selectAs(PositionEntity::getId, RoleRelationOrgVo::getId);
  109. queryWrapper.selectAs(PositionEntity::getFullName, RoleRelationOrgVo::getFullName);
  110. queryWrapper.selectAs(PositionEntity::getEnCode, RoleRelationOrgVo::getEnCode);
  111. queryWrapper.selectAs(PositionEntity::getDescription, RoleRelationOrgVo::getDescription);
  112. queryWrapper.selectAs(PositionEntity::getOrganizeId, RoleRelationOrgVo::getOrganizeId);
  113. if (!StringUtil.isEmpty(pagination.getKeyword())) {
  114. queryWrapper.and(
  115. t -> t.like(PositionEntity::getEnCode, pagination.getKeyword())
  116. .or().like(PositionEntity::getFullName, pagination.getKeyword())
  117. );
  118. }
  119. queryWrapper.eq(RoleRelationEntity::getRoleId, pagination.getRoleId());
  120. queryWrapper.eq(RoleRelationEntity::getObjectType, pagination.getType());
  121. queryWrapper.isNotNull(PositionEntity::getId);
  122. queryWrapper.orderByDesc(RoleRelationEntity::getCreatorTime).orderByDesc(RoleRelationEntity::getId);
  123. Page<RoleRelationOrgVo> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
  124. IPage<RoleRelationOrgVo> data = this.selectJoinListPage(page, RoleRelationOrgVo.class, queryWrapper);
  125. return pagination.setData(data.getRecords(), page.getTotal());
  126. }
  127. @Override
  128. public List<RoleRelationEntity> getListByObjectId(String objectId, String objectType) {
  129. QueryWrapper<RoleRelationEntity> queryWrapper = new QueryWrapper<>();
  130. queryWrapper.lambda().eq(RoleRelationEntity::getObjectId, objectId);
  131. if (objectType != null) {
  132. queryWrapper.lambda().eq(RoleRelationEntity::getObjectType, objectType);
  133. }
  134. queryWrapper.lambda().orderByAsc(RoleRelationEntity::getSortCode).orderByDesc(RoleRelationEntity::getCreatorTime);
  135. return this.list(queryWrapper);
  136. }
  137. @Override
  138. public List<RoleRelationEntity> getListByObjectId(List<String> objectId, String objectType) {
  139. if (CollectionUtil.isEmpty(objectId)) return Collections.EMPTY_LIST;
  140. QueryWrapper<RoleRelationEntity> queryWrapper = new QueryWrapper<>();
  141. if (objectType != null) {
  142. queryWrapper.lambda().eq(RoleRelationEntity::getObjectType, objectType);
  143. }
  144. List<List<String>> lists = Lists.partition(objectId, 1000);
  145. queryWrapper.lambda().and(t -> {
  146. for (List<String> ids : lists) {
  147. t.in(RoleRelationEntity::getObjectId, ids).or();
  148. }
  149. });
  150. queryWrapper.lambda().orderByAsc(RoleRelationEntity::getSortCode).orderByDesc(RoleRelationEntity::getCreatorTime);
  151. return this.list(queryWrapper);
  152. }
  153. @Override
  154. public List<RoleRelationEntity> getListByRoleId(String roleId, String objectType) {
  155. QueryWrapper<RoleRelationEntity> query = new QueryWrapper<>();
  156. if (StringUtil.isNotEmpty(roleId)) {
  157. query.lambda().eq(RoleRelationEntity::getRoleId, roleId);
  158. }
  159. if (StringUtil.isNotEmpty(objectType)) {
  160. query.lambda().eq(RoleRelationEntity::getObjectType, objectType);
  161. }
  162. query.lambda().orderByAsc(RoleRelationEntity::getSortCode).orderByDesc(RoleRelationEntity::getCreatorTime);
  163. return this.list(query);
  164. }
  165. @Override
  166. public List<RoleRelationEntity> getListByRoleId(List<String> roleId, String objectType) {
  167. if (CollectionUtil.isEmpty(roleId)) return Collections.EMPTY_LIST;
  168. QueryWrapper<RoleRelationEntity> query = new QueryWrapper<>();
  169. if (StringUtil.isNotEmpty(objectType)) {
  170. query.lambda().eq(RoleRelationEntity::getObjectType, objectType);
  171. }
  172. List<List<String>> lists = Lists.partition(roleId, 1000);
  173. query.lambda().and(t -> {
  174. for (List<String> ids : lists) {
  175. t.in(RoleRelationEntity::getRoleId, ids).or();
  176. }
  177. });
  178. query.lambda().orderByAsc(RoleRelationEntity::getSortCode).orderByDesc(RoleRelationEntity::getCreatorTime);
  179. return this.list(query);
  180. }
  181. @Override
  182. public ActionResult roleAddObjectIds(RoleRelationForm form) {
  183. if (CollectionUtil.isEmpty(form.getIds())) {
  184. return ActionResult.fail(MsgCode.SYS134.get());
  185. }
  186. String roleId = form.getRoleId();
  187. RoleEntity info = roleService.getInfo(roleId);
  188. if (info == null) {
  189. return ActionResult.fail(MsgCode.FA001.get());
  190. }
  191. String type = form.getType();
  192. List<String> ids = new ArrayList<>(form.getIds());
  193. List<String> errList1 = new ArrayList<>();
  194. List<String> objectIds = new ArrayList<>();
  195. //角色-移除数据库已有数据。
  196. List<RoleRelationEntity> listByRoleId = this.getListByRoleId(roleId, type);
  197. Set<String> roleSet = listByRoleId.stream().map(RoleRelationEntity::getObjectId).collect(Collectors.toSet());
  198. Set<String> adminIds = userService.getAdminList().stream().map(UserEntity::getId).collect(Collectors.toSet());
  199. ids = ids.stream().filter(t -> !roleSet.contains(t)).collect(Collectors.toList());
  200. //用户角色约束判断
  201. PosConModel posConModel = new PosConModel();
  202. if (Objects.equals(info.getIsCondition(), 1)) {
  203. posConModel = JsonUtil.getJsonToBean(info.getConditionJson(), PosConModel.class);
  204. posConModel.init();
  205. }
  206. if (posConModel.getNumFlag()) {
  207. //用户基数限制
  208. if (ids.size() > 0 && posConModel.getUserNum() <= roleSet.size()) {
  209. return ActionResult.fail(MsgCode.SYS135.get(MsgCode.PS006.get()));
  210. }
  211. }
  212. for (String objectId : ids) {
  213. if (adminIds.contains(objectId)) {
  214. errList1.add("超管不能添加");
  215. continue;
  216. }
  217. List<String> errList2 = new ArrayList<>();
  218. RoleRelationEntity entity = new RoleRelationEntity();
  219. entity.setId(RandomUtil.uuId());
  220. entity.setObjectId(objectId);
  221. entity.setRoleId(roleId);
  222. entity.setObjectType(type);
  223. //角色约束判断
  224. if (PermissionConst.USER.equals(type)) {
  225. List<RoleRelationEntity> userRoleList = this.getListByObjectId(objectId, PermissionConst.USER);
  226. List<String> thisUserRole = userRoleList.stream().map(RoleRelationEntity::getRoleId).collect(Collectors.toList());
  227. List<RoleEntity> roleList = roleService.getListByIds(thisUserRole);
  228. //用户现有角色和当前互斥
  229. for (RoleEntity role : roleList) {
  230. if (Objects.equals(role.getIsCondition(), 1)) {
  231. PosConModel conModelP = JsonUtil.getJsonToBean(role.getConditionJson(), PosConModel.class);
  232. conModelP.init();
  233. if (conModelP.getMutualExclusionFlag() && conModelP.getMutualExclusion().contains(roleId)) {
  234. errList2.add(MsgCode.SYS137.get());
  235. }
  236. }
  237. }
  238. //互斥
  239. if (posConModel.getMutualExclusionFlag()) {
  240. if (posConModel.getMutualExclusion().stream().filter(t -> thisUserRole.contains(t)).collect(Collectors.toList()).size() > 0) {
  241. errList2.add(MsgCode.SYS137.get());
  242. }
  243. }
  244. //先决
  245. if (posConModel.getPrerequisiteFlag() && !thisUserRole.containsAll(posConModel.getPrerequisite())) {
  246. errList2.add(MsgCode.SYS138.get());
  247. }
  248. }
  249. if (errList2.size() == 0) {
  250. //达到用户基数限制跳出循环
  251. if (posConModel.getNumFlag() && posConModel.getUserNum() <= (objectIds.size() + roleSet.size())) {
  252. errList1.add(MsgCode.SYS135.get(MsgCode.PS006.get()));
  253. break;
  254. }
  255. objectIds.add(objectId);
  256. this.save(entity);
  257. } else {
  258. errList1.addAll(errList2);
  259. }
  260. }
  261. //修改关系-相关用户踢下线
  262. List<String> userIds = new ArrayList<>();
  263. if (PermissionConst.USER.equals(type)) {
  264. userIds.addAll(objectIds);
  265. }
  266. // if (PermissionConst.ORGANIZE.equals(type)) {
  267. // List<OrganizeEntity> listByIds = organizeService.getListByIds(objectIds);
  268. // List<PositionEntity> listByOrgIds = positionService.getListByOrgIds(listByIds.stream().map(OrganizeEntity::getId).collect(Collectors.toList()));
  269. // List<String> positionIds = listByOrgIds.stream().map(PositionEntity::getId).collect(Collectors.toList());
  270. // List<UserRelationEntity> listByObjectIdAll = userRelationService.getListByObjectIdAll(positionIds);
  271. // userIds.addAll(listByObjectIdAll.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList()));
  272. // }
  273. if (PermissionConst.POSITION.equals(type)) {
  274. List<PositionEntity> listByOrgIds = positionService.getListByIds(objectIds);
  275. List<String> positionIds = listByOrgIds.stream().map(PositionEntity::getId).collect(Collectors.toList());
  276. List<UserRelationEntity> listByObjectIdAll = userRelationService.getListByObjectIdAll(positionIds);
  277. userIds.addAll(listByObjectIdAll.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList()));
  278. }
  279. if (CollectionUtil.isNotEmpty(userIds)) {
  280. userService.delCurUser(MsgCode.PS010.get(), userIds);
  281. }
  282. if (CollectionUtil.isNotEmpty(errList1) && CollectionUtil.isNotEmpty(objectIds)) {
  283. return ActionResult.success(MsgCode.SYS139.get());
  284. } else if (CollectionUtil.isNotEmpty(errList1)) {
  285. return ActionResult.fail(MsgCode.DB019.get());
  286. }
  287. return ActionResult.success(MsgCode.SU018.get());
  288. }
  289. @Override
  290. public void delete(RoleRelationForm form) {
  291. String type = form.getType();
  292. QueryWrapper<RoleRelationEntity> queryWrapper = new QueryWrapper<>();
  293. queryWrapper.lambda().eq(RoleRelationEntity::getRoleId, form.getRoleId());
  294. queryWrapper.lambda().eq(RoleRelationEntity::getObjectType, form.getType());
  295. queryWrapper.lambda().in(RoleRelationEntity::getObjectId, form.getIds());
  296. List<RoleRelationEntity> list = this.list(queryWrapper);
  297. if (CollectionUtil.isEmpty(list)) {
  298. return;
  299. }
  300. for (RoleRelationEntity item : list) {
  301. this.removeById(item);
  302. }
  303. //一次移除只能是用类型数据
  304. List<String> objectIds = list.stream().map(RoleRelationEntity::getObjectId).collect(Collectors.toList());
  305. //修改关系-相关用户踢下线
  306. List<String> userIds = new ArrayList<>();
  307. if (PermissionConst.USER.equals(type)) {
  308. userIds.addAll(objectIds);
  309. }
  310. // if (PermissionConst.ORGANIZE.equals(type)) {
  311. // List<OrganizeEntity> listByIds = organizeService.getListByIds(objectIds);
  312. // List<PositionEntity> listByOrgIds = positionService.getListByOrgIds(listByIds.stream().map(OrganizeEntity::getId).collect(Collectors.toList()));
  313. // List<String> positionIds = listByOrgIds.stream().map(PositionEntity::getId).collect(Collectors.toList());
  314. // List<UserRelationEntity> listByObjectIdAll = userRelationService.getListByObjectIdAll(positionIds);
  315. // userIds.addAll(listByObjectIdAll.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList()));
  316. // }
  317. if (PermissionConst.POSITION.equals(type)) {
  318. List<PositionEntity> listByOrgIds = positionService.getListByIds(objectIds);
  319. List<String> positionIds = listByOrgIds.stream().map(PositionEntity::getId).collect(Collectors.toList());
  320. List<UserRelationEntity> listByObjectIdAll = userRelationService.getListByObjectIdAll(positionIds);
  321. userIds.addAll(listByObjectIdAll.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList()));
  322. }
  323. if (CollectionUtil.isNotEmpty(userIds)) {
  324. userService.delCurUser(MsgCode.PS010.get(), userIds);
  325. }
  326. }
  327. @Override
  328. public void objectAddRoles(AddRolesForm form) {
  329. String type = form.getType();
  330. List<String> roleIds = form.getIds();
  331. List<String> hasRRE = this.getListByObjectId(form.getObjectId(), type).stream().map(RoleRelationEntity::getRoleId).collect(Collectors.toList());
  332. for (String roleId : roleIds) {
  333. if (!hasRRE.contains(roleId)) {
  334. RoleRelationEntity entity = new RoleRelationEntity();
  335. entity.setId(RandomUtil.uuId());
  336. entity.setObjectId(form.getObjectId());
  337. entity.setRoleId(roleId);
  338. entity.setObjectType(type);
  339. this.save(entity);
  340. }
  341. }
  342. List<String> userObjectIds = new ArrayList<>();
  343. // if (PermissionConst.ORGANIZE.equals(type)) {
  344. // List<OrganizeEntity> listByIds = organizeService.getListByIds(Arrays.asList(form.getObjectId()));
  345. // List<PositionEntity> listByOrgIds = positionService.getListByOrgIds(listByIds.stream().map(OrganizeEntity::getId).collect(Collectors.toList()));
  346. // List<String> positionIds = listByOrgIds.stream().map(PositionEntity::getId).collect(Collectors.toList());
  347. // List<UserRelationEntity> listByObjectIdAll = userRelationService.getListByObjectIdAll(positionIds);
  348. // userObjectIds.addAll(listByObjectIdAll.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList()));
  349. // }
  350. if (PermissionConst.POSITION.equals(type)) {
  351. List<PositionEntity> listByOrgIds = positionService.getListByIds(Arrays.asList(form.getObjectId()));
  352. List<String> positionIds = listByOrgIds.stream().map(PositionEntity::getId).collect(Collectors.toList());
  353. List<UserRelationEntity> listByObjectIdAll = userRelationService.getListByObjectIdAll(positionIds);
  354. userObjectIds.addAll(listByObjectIdAll.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList()));
  355. }
  356. if (CollectionUtil.isNotEmpty(userObjectIds)) {
  357. userService.delCurUser(MsgCode.PS010.get(), userObjectIds);
  358. }
  359. }
  360. public void objectDeleteRoles(AddRolesForm form) {
  361. String type = form.getType();
  362. QueryWrapper<RoleRelationEntity> queryWrapper = new QueryWrapper<>();
  363. queryWrapper.lambda().eq(RoleRelationEntity::getObjectId, form.getObjectId());
  364. queryWrapper.lambda().eq(RoleRelationEntity::getObjectType, form.getType());
  365. queryWrapper.lambda().in(RoleRelationEntity::getRoleId, form.getIds());
  366. List<RoleRelationEntity> list = this.list(queryWrapper);
  367. if (CollectionUtil.isEmpty(list)) {
  368. return;
  369. }
  370. for (RoleRelationEntity item : list) {
  371. this.removeById(item);
  372. }
  373. List<String> userObjectIds = new ArrayList<>();
  374. // if (PermissionConst.ORGANIZE.equals(type)) {
  375. // List<OrganizeEntity> listByIds = organizeService.getListByIds(Arrays.asList(form.getObjectId()));
  376. // List<PositionEntity> listByOrgIds = positionService.getListByOrgIds(listByIds.stream().map(OrganizeEntity::getId).collect(Collectors.toList()));
  377. // List<String> positionIds = listByOrgIds.stream().map(PositionEntity::getId).collect(Collectors.toList());
  378. // List<UserRelationEntity> listByObjectIdAll = userRelationService.getListByObjectIdAll(positionIds);
  379. // userObjectIds.addAll(listByObjectIdAll.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList()));
  380. // }
  381. if (PermissionConst.POSITION.equals(type)) {
  382. List<PositionEntity> listByOrgIds = positionService.getListByIds(Arrays.asList(form.getObjectId()));
  383. List<String> positionIds = listByOrgIds.stream().map(PositionEntity::getId).collect(Collectors.toList());
  384. List<UserRelationEntity> listByObjectIdAll = userRelationService.getListByObjectIdAll(positionIds);
  385. userObjectIds.addAll(listByObjectIdAll.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList()));
  386. }
  387. if (CollectionUtil.isNotEmpty(userObjectIds)) {
  388. userService.delCurUser(MsgCode.PS010.get(), userObjectIds);
  389. }
  390. }
  391. }