From 7a171b5193feef1d201b7d273b64ba2aebaddcda Mon Sep 17 00:00:00 2001 From: ludc Date: 星期三, 26 六月 2024 18:22:01 +0800 Subject: [PATCH] 成员管理:分配角色、分配部门、分配部门界面查询、角色角色界面查询等接口添加 --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java | 83 ++++++++++++++++++++++++++++++++++++----- 1 files changed, 72 insertions(+), 11 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java index d652b0e..3d433a9 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java @@ -1,5 +1,6 @@ package com.vci.frameworkcore.compatibility.impl; +import com.vci.corba.common.PLException; import com.vci.corba.omd.data.BusinessObject; import com.vci.frameworkcore.compatibility.OrgDeptQueryServiceI; import com.vci.frameworkcore.lcstatuspck.FrameworkDataLCStatus; @@ -20,13 +21,17 @@ import com.vci.starter.web.util.VciBaseUtil; import com.vci.starter.web.wrapper.VciQueryWrapperForDO; import com.vci.web.service.WebBoServiceI; +import com.vci.web.util.Func; +import com.vci.web.util.PlatformClientUtil; import com.vci.web.util.WebUtil; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -42,6 +47,12 @@ */ @Autowired private WebBoServiceI boService; + + /** + * 骞冲彴璋冪敤瀹㈡埛绔� + */ + @Autowired + private PlatformClientUtil platformClientUtil; /** * 瀵硅薄鎿嶄綔宸ュ叿绫� @@ -103,6 +114,7 @@ } return departmentVO; } + /** * 鎵归噺鑾峰彇閮ㄩ棬鐨勪俊鎭� 锛堟牴鎹儴闂ㄤ富閿級 * @param deptOidCollections 閮ㄩ棬涓婚敭鐨勯泦鍚堬紝鍙互瓒呰繃1000涓� @@ -127,6 +139,7 @@ }); return deptDO2VOs(depts); } + /** * 鑾峰彇閮ㄩ棬鐨勫垪琛紝榛樿浼氫互閮ㄩ棬鍚嶇О鍗囧簭鎺掑垪锛岄儴闂ㄧ殑缂栬緫椤甸潰鍒楄〃涓嶈浣跨敤杩欎釜鎺ュ彛 * @param queryMap 鏌ヨ鏉′欢 @@ -150,6 +163,7 @@ } return dataGrid; } + /** * 鏍规嵁閮ㄩ棬涓婚敭鑾峰彇閮ㄩ棬鐨勫鍚� * @param deptOid 閮ㄩ棬涓婚敭 @@ -175,7 +189,7 @@ if(queryMap == null){ queryMap = new HashMap<>(); } - List<OrgDeptForPlatform1> roles = new ArrayList<>(); + List<OrgDeptForPlatform1> deptForPlatform1s = new ArrayList<>(); if(userOid.contains(",")){ Map<String, String> finalQueryMap = queryMap; WebUtil.switchCollectionForOracleIn(WebUtil.str2List(userOid)).stream().forEach(userOids->{ @@ -187,7 +201,7 @@ VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(conditionMap,OrgDeptForPlatform1.class); List<OrgDeptForPlatform1> roleForPlatform1s = boService.selectByQueryWrapper(queryWrapper, OrgDeptForPlatform1.class); if(!CollectionUtils.isEmpty(roleForPlatform1s)){ - roles.addAll(roleForPlatform1s); + deptForPlatform1s.addAll(roleForPlatform1s); } }); }else { @@ -196,25 +210,27 @@ VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(queryMap,OrgDeptForPlatform1.class); List<OrgDeptForPlatform1> roleForPlatform1s = boService.selectByQueryWrapper(queryWrapper, OrgDeptForPlatform1.class); if(!CollectionUtils.isEmpty(roleForPlatform1s)){ - roles.addAll(roleForPlatform1s); + deptForPlatform1s.addAll(roleForPlatform1s); } - return deptDO2VOs(roles); + return deptDO2VOs(deptForPlatform1s); } - /** + + /** * 鏍规嵁鐢ㄦ埛涓婚敭鑾峰彇鍏宠仈鐨勯儴闂� * @param userOid 鐢ㄦ埛涓婚敭 * @param queryMap 鏌ヨ鏉′欢锛屽鏋滈渶瑕佷娇鐢ㄧ敤鎴风殑灞炴�ф潵鏌ヨ鍙互浣跨敤pkUser.xxxx * @return 閮ㄩ棬鐨勬樉绀哄璞� */ @Override - public OrgDepartmentVO listDeptByUserOid(String userOid, + public List<OrgDepartmentVO> listDeptByUserOid(String userOid, Map<String, String> queryMap) { List<OrgDepartmentVO> departmentVOS = listDeptByUserOid(userOid, queryMap, false); if(CollectionUtils.isEmpty(departmentVOS)){ - return null; + return new ArrayList<>(); } - return departmentVOS.get(0); + return departmentVOS; } + /** * 鑾峰彇鏈叧鑱旀煇涓敤鎴风殑閮ㄩ棬 * @param userOid 鐢ㄦ埛涓婚敭 @@ -290,16 +306,19 @@ List<BusinessObject> cbos = boService.queryBySql(sql, null); if(!CollectionUtils.isEmpty(cbos)){ cbos.stream().forEach(cbo->{ - String userOid = ObjectTool.getBOAttributeValue(cbo,"pluseruid"); + String userOid = ObjectTool.getNewBOAttributeValue(cbo,"pluseruid"); List<String> deptOids = userDeptOidMap.getOrDefault(userOid,new ArrayList<>()); - deptOids.add(ObjectTool.getBOAttributeValue(cbo,"pldeptuid")); + deptOids.add(ObjectTool.getNewBOAttributeValue(cbo,"pldeptuid")); userDeptOidMap.put(userOid,deptOids); }); } } }); if(!CollectionUtils.isEmpty(deptVOList)){ - Map<String, OrgDepartmentVO> deptVOMap = deptVOList.stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); + //杩欏効搴旇瀵筪eptVOList鍋氫竴娆″幓閲嶅鐞嗭紝鍥犱负鑲畾浼氭湁閲嶅鐨勯儴闂ㄨ鏌ュ嚭鏉� + Map<String, OrgDepartmentVO> deptVOMap = deptVOList.stream() + .collect(Collectors.toMap(OrgDepartmentVO::getOid, Function.identity(), (existing, replacement) -> existing)); + //Map<String, OrgDepartmentVO> deptVOMap = deptVOList.stream().distinct().collect(Collectors.toMap(s -> s.getOid(), t -> t)); Map<String, List<OrgDepartmentVO>> userDeptVOMap = new HashMap<>(); userDeptOidMap.forEach((userOid,deptOids)->{ List<OrgDepartmentVO> deptVOS = new ArrayList<>(); @@ -314,6 +333,7 @@ } return new HashMap<>(); } + /** * 鑾峰彇鏌愪釜閮ㄩ棬鐨勭洿灞炰笅绾ч儴闂� * @param pkFatherDepartmment 閮ㄩ棬鐨勪富閿� @@ -332,6 +352,7 @@ List<OrgDeptForPlatform1> depts = boService.selectByQueryWrapper(queryWrapperForDO, OrgDeptForPlatform1.class); return deptDO2VOs(depts); } + /** * 鑾峰彇鏌愪釜閮ㄩ棬鐨勬墍鏈夊眰绾х殑涓嬬骇閮ㄩ棬 * @param pkFatherDepartmment 閮ㄩ棬鐨勪富閿� @@ -345,6 +366,7 @@ queryWrapperForDO.in("pluid","select pluid from pldept start with " + (StringUtils.isBlank(pkFatherDepartmment)?" (plparentuid is null or plparentuid = '') ":"plparentuid = '" + pkFatherDepartmment.trim() + "'") + "connect by PRIOR pluid=plparentuid"); return deptDO2VOs(boService.selectByQueryWrapper(queryWrapperForDO, OrgDeptForPlatform1.class)); } + /** * 鍙傜収鏍戝舰鏁版嵁鐨勯儴闂ㄤ俊鎭� * @param treeQueryObject 鏍戝舰鏌ヨ鐨勬潯浠� @@ -371,6 +393,7 @@ return dept.getId() + " " + dept.getName() + (FrameworkDataLCStatus.DISABLED.getValue().equals(dept.getLcStatus())?"銆愬仠鐢ㄣ��":""); }); } + /** * 鍙傜収鏍戝舰琛ㄦ牸鐨勯儴闂ㄤ俊鎭紝涓婄骇閮ㄩ棬鐨勬槸琛ㄦ牸涓殑鏍戝舰鍒� * @param treeQueryObject 鏍戝舰鏌ヨ鐨勬潯浠� @@ -399,4 +422,42 @@ return dataGrid; } + /** + * 淇濆瓨閮ㄩ棬瑙掕壊鍏宠仈淇℃伅锛屽甫鏌ラ噸鍔熻兘 + * @param userOIds 鐢ㄦ埛id + * @param deptId 閮ㄩ棬id + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public boolean saveUsersDept(String[] userOIds, String deptId) throws PLException { + if(Func.isEmpty(userOIds) || Func.isBlank(deptId)){ + return false; + } + //鍏堣繘鎬ф煡閲嶅鐞� + List<String> repeatUserOidList = new ArrayList<>(); + //寰幆杩涜鏌ラ噸锛岄伩鍏峣n澶т簬1000 + WebUtil.switchCollectionForOracleIn(Arrays.asList(userOIds)).stream().forEach(userOId->{ + String sql = "select pluseruid,pldeptuid from pluserdept where pldeptuid = '" + deptId + + "' and " + "pluseruid in ("+WebUtil.toInSql(userOId.toArray(new String[0]))+")"; + List<BusinessObject> cbos = boService.queryBySql(sql, null); + if(!CollectionUtils.isEmpty(cbos)){ + cbos.stream().forEach(cbo->{ + repeatUserOidList.add(ObjectTool.getNewBOAttributeValue(cbo,"pluseruid")); + }); + } + }); + + //浠庡嵆灏嗚鎵ц淇濆瓨鐨勭敤鎴穙id涓Щ闄ゅ綋鍓嶇敤鎴峰凡缁忓瓨鍦ㄥ叧鑱斿叧绯荤殑oid + //绉婚櫎閲嶅鐨� + List<String> tempList = new ArrayList<>(Arrays.asList(userOIds)); + tempList.removeAll(repeatUserOidList); + userOIds = tempList.toArray(new String[tempList.size()]); + if(Func.isNotEmpty(userOIds)){ + platformClientUtil.getFrameworkService().saveUserDept(userOIds, deptId,null); + } + return true; + } + + } -- Gitblit v1.9.3