From 18e2c156de069eaee2f989e09fda061841aae605 Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期四, 11 七月 2024 11:35:33 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java |   67 +++++++++++++++++++--------------
 1 files changed, 38 insertions(+), 29 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 35748de..c45b79e 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
@@ -645,12 +645,12 @@
 				orgDepartmentDTO.getOid(),"鐢ㄦ埛涓婚敭",
 				orgDepartmentDTO.getId(),"鐢ㄦ埛鍚�"
 		);
-		//鎸塷id鏌ヨ鏁版嵁搴撲腑宸插瓨鍦ㄧ殑
+		//鎸塷id鏌ヨ鏁版嵁搴撲腑宸插瓨鍦ㄧ殑锛岀‘淇濅慨鏀圭殑閮ㄩ棬瀛樺湪
 		OrgDepartmentVO dbDepartmentVO = getDeptByDeptOid(orgDepartmentDTO.getOid());
 		if(Func.isEmpty(dbDepartmentVO)){
 			throw new VciBaseException("淇敼鐨勯儴闂ㄤ笉瀛樺湪锛�");
 		}
-		//閮ㄩ棬鍚嶅拰缂栧彿鍒ら噸
+		//閮ㄩ棬鍚嶅拰缂栧彿鍒ら噸锛岄伩鍏嶆柊瀹堕儴闂ㄩ噸澶�
 		Map<String, String> conditionMap = new HashMap<>();
 		conditionMap.put("plname",QueryOptionConstant.OR + orgDepartmentDTO.getName());
 		if(Func.isNotBlank(orgDepartmentDTO.getId())){
@@ -712,7 +712,7 @@
 	@Override
 	public boolean deleteDept(String[] ids) throws PLException {
 		VciBaseUtil.alertNotNull(ids,"瑕佸垹闄ょ殑閮ㄩ棬涓婚敭");
-		//鍏峰杩炲甫鍒犻櫎鐨勫姛鑳斤紝濡傝鑹茶彍鍗曟巿鏉冭〃閲岄潰鐨勬巿鏉冧俊鎭�
+		//TODO: 搴旇鏄笉鍏峰杩炲甫鍒犻櫎鐨勫姛鑳斤紝绛栫暐鍒犻櫎鍚庣敤鎴峰叧鑱旂殑鏃犵敤閮ㄩ棬杩樺湪,鑰冭檻鍚庢湡鏄惁闇�瑕佸仛锛屾暟鎹噺涓嶅ぇ鍙互涓嶅仛杩炲甫鍒犻櫎
 		return platformClientUtil.getFrameworkService().deleteDepartment(
 				ids,
 				new UserEntityInfo("developer"/*WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId()*/, null)
@@ -743,7 +743,7 @@
 		List<String> columns = new ArrayList<>(Arrays.asList("ID", "鍚嶇О", "缂栧彿", "浠e彿", "涓撲笟", "鐖禝D锛堥儴闂ㄥ敮涓�鏍囪瘑ID锛�", "鎻忚堪"));
 		//璁剧疆蹇呭~鍒�
 		ColumnNameisRed.clear();
-		ColumnNameisRed.add(0);
+		//ColumnNameisRed.add(0);
 		ColumnNameisRed.add(1);
 		//鍐檈xcel
 		String excelPath = LocalFileUtil.getDefaultTempFolder() + File.separator + downloadFileName +  ".xls";
@@ -776,7 +776,7 @@
 	 * @throws VciBaseException
 	 */
 	@Override
-	public BaseResult importDept(File file) throws VciBaseException {
+	public BaseResult importDept(File file) throws Exception {
 		VciBaseUtil.alertNotNull(file,"excel鏂囦欢");
 		if(!file.exists()){
 			throw new VciBaseException("瀵煎叆鐨別xcel鏂囦欢涓嶅瓨鍦�,{0}",new String[]{file.getPath()});
@@ -813,22 +813,21 @@
 			Map<String, String> oidMap = new HashMap<>();
 			poList.stream().forEach(po->{
 				String parentId = Func.isBlank(po.getParentId()) ? "":po.getParentId();
-				//琛ㄦ牸鍐呭垽閲�
-				//閮ㄩ棬鍚嶇О鍒ょ┖
+				//閮ㄩ棬鍚嶇О鍒ょ┖锛岄�氬父閫氳繃po涓殑娉ㄨВ灏卞彲瀹炵幇
 				if(Func.isEmpty(po.getName())){
 					throw new VciBaseException("绗��"+po.getRowIndex()+"銆戣锛宒epterror,Reason:Name cannot be empty");
-				}else if(repeatNameMap.getOrDefault(po.getName(), "").equals(parentId)/*excel涓悓涓�閮ㄩ棬涓婲ame鐩哥瓑*/){
+				}else if(parentId.equals(repeatNameMap.getOrDefault(po.getName(), null))/*excel涓悓涓�閮ㄩ棬涓婲ame鐩哥瓑*/){
 					//鍚屼竴閮ㄩ棬涓嬪悕绉板垽閲�
 					throw new VciBaseException("绗��"+po.getRowIndex()+"銆戣锛宒eptnameerror,Reason: Names under the same department cannot be duplicated");
 				}else if(Func.isNotEmpty(po.getId()) && repeatIdList.equals(po.getId())){
 					throw new VciBaseException("绗��"+po.getRowIndex()+"銆戣锛宒eptiderror,Reason: The primary key cannot be duplicated");
-				}else if(Func.isNotEmpty(po.getNum()) && repeatNumMap.getOrDefault(po.getNum(),"").equals(parentId)/*excel涓悓涓�閮ㄩ棬涓嬬紪鍙峰瓨鍦� */){
+				}else if(Func.isNotEmpty(po.getNum()) && parentId.equals(repeatNumMap.getOrDefault(po.getNum(),null))/*excel涓悓涓�閮ㄩ棬涓嬬紪鍙峰瓨鍦� */){
 					throw new VciBaseException("绗��"+po.getRowIndex()+"銆戣锛宒eptnumerror,Reason: The number cannot be duplicated");
 				}else{
 					//2.2銆佹煡璇㈡暟鎹簱涓殑鏁版嵁锛堟煡閲岻D鍜孨UM锛夛紝姣旇緝楹荤儲闇�瑕佹牴鎹甈arentID鏌ヨ锛堟墍鏈夊彧鑳藉崟鏉℃煡璇㈣繘琛屽垽閲嶏級
 					//缁勮鏌ラ噸鏉′欢:鍚屼竴閮ㄩ棬涓�(parentId鐩哥瓑)锛宯ame鎴栬�卬um鐩哥瓑
 					HashMap<String, String> conditionMap = new HashMap<>();
-					conditionMap.put("plname",po.getName());
+					conditionMap.put("plname",QueryOptionConstant.OR + po.getName());
 					conditionMap.put("plnum",QueryOptionConstant.OR + po.getNum());
 					String pId = Func.isBlank(po.getParentId()) ? null:po.getParentId();
 					List<OrgDepartmentVO> repeatOrgDept = this.getDeptByDeptPOidAndCondition(pId, conditionMap);
@@ -847,6 +846,8 @@
 				BeanUtil.convert(po,dto);
 				dto.setOid(po.getId());
 				dto.setId(po.getNum());
+				dto.setDescription(po.getDesc());
+				dto.setSpecialties(po.getSpecialties());
 				dto.setPkFatherDepartment(po.getParentId());
 				dto.setCreateTime(new Date());
 				dto.setCreator(loginUserId);
@@ -854,7 +855,7 @@
 				dto.setStatus((short) 0);
 				//2.2銆佽繃绋嬩腑澶勭悊涓婚敭杞崲闂鏈�濂芥槸涓�鏉′竴鏉$殑澶勭悊ID鏄惁瀛樺湪杩樻湁ParentID鏄惁瀛樺湪鐨勯棶棰�
 				//鍏堝垽鏂槸宸插瓨鍦ㄧ殑閮ㄩ棬ID锛岃繕鏄笉瀛樺湪鐨勯儴闂↖D锛屽凡瀛樺湪绯荤粺涓殑ID灏辨槸涓篋ept:寮�澶寸殑
-				String pId = dto.getPkFatherDepartment();
+				String pId = Func.isBlank(dto.getPkFatherDepartment()) ? "":dto.getPkFatherDepartment();
 				//鏄凡瀛樺湪绯荤粺涓殑閮ㄩ棬id
 				if(pId.contains("Dept:")){
 					//瑙f瀽鍑虹湡瀹炵殑oid
@@ -863,33 +864,41 @@
 					if(Func.isBlank(deParentId) || Func.isEmpty(this.getDeptByDeptOid(deParentId))){
 						throw new VciBaseException("绗��"+ po.getRowIndex() +"銆戣锛宒eptparentiderror,Reason:Parent ID resolution error or does not exist in the system");
 					}
-					//鏇挎崲鎺変复鏃朵娇鐢ㄧ殑閮ㄩ棬鍞竴鏍囪瘑
-					dto.setPkOrganizationName(deParentId);
+					//鏇挎崲鎺変复鏃朵娇鐢ㄧ殑閮ㄩ棬鍞竴鏍囪瘑锛屼絾鏄负浜嗘柟渚垮悗缁垽鏂紝杩樻槸闇�瑕佸姞涓奃ept:鏍囪瘑
+					dto.setPkFatherDepartment("Dept:"+deParentId);
 				}
 				//鐢ㄦ埛鎵嬭緭浜嗛儴闂╫id锛屼絾鏄伩鍏峯id涓嶈鑼冮渶瑕侊紝鐢ㄨ鑼僶id杩涜鏇挎崲锛屽鏋滄病杈撳叆淇濆瓨鏃朵細鑷姩鐢熸垚oid
-				if(Func.isNotBlank(dto.getOid())){
-					String pkOid = VciBaseUtil.getPk();
+				String excelOid = dto.getOid();
+				if(Func.isNotBlank(excelOid)){
+					String pkOid = VciBaseUtil.getPk().toUpperCase(Locale.ROOT);
 					dto.setOid(pkOid);
 					//oid鏄犲皠鍏崇郴锛屽悗缁敤鏉ユ洿鏂皃arentId
-					oidMap.put(dto.getOid(),pkOid);
+					oidMap.put(excelOid,pkOid);
 				}
 				DeptInfo deptInfo = this.changeOrgDeptDTOToDeptInfo(dto);
 				deptInfoList.add(deptInfo);
 			});
-			//3銆佸鐞唅d鍜宲arentId鐨勬槧灏勫叧绯�:灏嗙敤鎴锋墜杈撶殑鐖禝D杞崲鎴愬疄闄呭瓨鍌ㄧ殑ID
-			List<DeptInfo> lastDeptInfoList = deptInfoList.stream().map(info -> {
-				//parentId涓嶄负绌哄苟涓旀病鏈塂ept:鐩稿叧鐨勫瓧绗︿覆,璇存槑鏄敤鎴锋墜杈撶殑ParentId(瀵煎叆鐨勬暟鎹氨鏄竴涓爲缁撴瀯)
-				if (Func.isNotBlank(info.parentId) || info.parentId.contains("Dept:")) {
-					//杞崲ParentId涓哄疄闄呰瀛樺偍鐨勯儴闂↖D
-					info.parentId = oidMap.get(info.parentId);
+			//3銆佸鐞唅d鍜宲arentId鐨勬槧灏勫叧绯�:灏嗙敤鎴锋墜杈撶殑鐖禝D杞崲鎴愬疄闄呭瓨鍌ㄧ殑ID骞朵繚瀛樿繘搴�
+			deptInfoList.stream().forEach(info -> {
+				//3.1銆佸鏈�缁堝鐞嗗ソ鐨勯儴闂ㄦ暟鎹繚瀛�
+				try {
+					//parentId涓嶄负绌哄苟涓旀病鏈塂ept:鐩稿叧鐨勫瓧绗︿覆,璇存槑鏄敤鎴锋墜杈撶殑ParentId(瀵煎叆鐨勬暟鎹氨鏄竴涓爲缁撴瀯)
+					if (Func.isNotBlank(info.parentId) && !info.parentId.contains("Dept:")) {
+						//杞崲ParentId涓哄疄闄呰瀛樺偍鐨勯儴闂↖D
+						info.parentId = oidMap.get(info.parentId);
+					}else if(info.parentId.contains("Dept:")){
+						//绯荤粺涓凡瀛樺湪鐨勭埗閮ㄩ棬OID锛岄渶瑕佺Щ闄ゆ帀Dept:鏍囪瘑
+						info.parentId = info.parentId.replace("Dept:","");
+					}
+					platformClientUtil.getFrameworkService().saveDepartment(
+							info,
+							userEntityInfo
+					);
+				} catch (PLException e) {
+					e.printStackTrace();
+					throw new VciBaseException("淇濆瓨鏃跺嚭鐜伴敊璇紒锛屽師鍥狅細"+VciBaseUtil.getExceptionMessage(e));
 				}
-				return info;
-			}).collect(Collectors.toList());
-			//4銆佸鏈�缁堝鐞嗗ソ鐨勯儴闂ㄦ暟鎹繚瀛橈紝瀹炵幇鏈�缁堢粺涓�淇濆瓨锛岄伩鍏嶄簡涓�閮ㄥ垎鏁版嵁杩涗簡涓�閮ㄥ垎鏁版嵁鍥犱负鏍¢獙娌¤繃娌¤繘搴撶殑闂
-			platformClientUtil.getFrameworkService().batchSaveDepart(
-					lastDeptInfoList.toArray(new DeptInfo[lastDeptInfoList.size()]),
-					userEntityInfo
-			);
+			});
 		}catch (Exception e){
 			if(logger.isErrorEnabled()){
 				logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨鐢ㄦ埛淇℃伅鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",e.getMessage());

--
Gitblit v1.9.3