From d45e6830c15541053b4d5be1c47afe14842e630a Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期四, 27 六月 2024 17:59:19 +0800
Subject: [PATCH] 用户管理界面,增加部门查询、角色下拉查询、分配密码策略接口,联调修改代码上传

---
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java |   85 ++++++++++++++++++++++++++++++++++++------
 1 files changed, 73 insertions(+), 12 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..3f73e92 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 鏍戝舰鏌ヨ鐨勬潯浠�
@@ -365,12 +387,14 @@
 			VciQueryWrapperForDO queryWrapperForDO = new VciQueryWrapperForDO(conditionMap,OrgDeptForPlatform1.class);
 			orgDepartmentVOList = deptDO2VOs(boService.selectByQueryWrapper(queryWrapperForDO,OrgDeptForPlatform1.class));
 		}
-		TreeWrapperOptions treeWrapperOptions = new TreeWrapperOptions("pkFatherDepartment");
+		TreeWrapperOptions treeWrapperOptions = new TreeWrapperOptions();
 		BeanUtil.convert(treeQueryObject,treeWrapperOptions);
+		treeWrapperOptions.setParentFieldName("pkFatherDepartment");
 		return revisionModelUtil.doList2Trees(orgDepartmentVOList,treeWrapperOptions,dept->{
 			return dept.getId() + " " + dept.getName() + (FrameworkDataLCStatus.DISABLED.getValue().equals(dept.getLcStatus())?"銆愬仠鐢ㄣ��":"");
 		});
 	}
+
 	  /**
      * 鍙傜収鏍戝舰琛ㄦ牸鐨勯儴闂ㄤ俊鎭紝涓婄骇閮ㄩ棬鐨勬槸琛ㄦ牸涓殑鏍戝舰鍒�
      * @param treeQueryObject 鏍戝舰鏌ヨ鐨勬潯浠�
@@ -399,4 +423,41 @@
 		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