From fa8f28cf848d2c3aeaa548a7ac65f93b690392c3 Mon Sep 17 00:00:00 2001
From: yuxc <yuxc@vci-tech.com>
Date: 星期五, 23 八月 2024 10:19:35 +0800
Subject: [PATCH] 1、配置文件上传
---
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java | 205 +++++++++++++++++++++++++++++++-------------------
1 files changed, 126 insertions(+), 79 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 6393e9f..e0aedfc 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
@@ -70,7 +70,7 @@
/**
* 蹇呭~鍒�
*/
- private ArrayList<Integer> ColumnNameisRed = new ArrayList<Integer>();
+ private List<Integer> ColumnNameisRed = new ArrayList<Integer>();
/**
* 鏃ュ織
@@ -99,14 +99,14 @@
}
/**
- * 鏍规嵁鐖堕儴闂ㄤ富閿幏鍙栧拰閮ㄩ棬鍚嶇О閮ㄩ棬鐨勪俊鎭�
+ * 鏍规嵁鐖堕儴闂ㄤ富閿幏鍙栭儴闂ㄥ悕绉伴儴闂ㄧ殑淇℃伅
* @param parentDeptOid 鐖堕儴闂ㄤ富閿�
* @param conditionMap 閮ㄩ棬鍚嶇О
* @return 閮ㄩ棬鐨勬樉绀哄璞★紝濡傛灉閮ㄩ棬涓嶅瓨鍦ㄥ垯杩斿洖null锛屼笉浼氭姏鍑哄紓甯�
* @throws VciBaseException 鍙傛暟涓虹┖鎴栬�呮暟鎹簱瀛樺湪闂鐨勬椂鍊欎細鎶涘嚭寮傚父
*/
@Override
- public List<OrgDepartmentVO> getDeptByDeptPOidAndCondition(String parentDeptOid,Map<String,String> conditionMap) throws VciBaseException {
+ public List<OrgDepartmentVO> getDeptByDeptpOidAndCondition(String parentDeptOid,Map<String,String> conditionMap) throws VciBaseException {
if(Func.isEmpty(conditionMap)){
conditionMap = new HashMap();
}
@@ -122,6 +122,42 @@
return null;
}
return deptDO2VOs(roleForPlatform1s);
+ }
+
+ /**
+ * 鏍规嵁鐖堕儴闂ㄥ悕绉拌矾寰勮幏鍙栧拰閮ㄩ棬鍚嶇О閮ㄩ棬鐨勪俊鎭紙涓昏鐢ㄤ簬瀵煎叆鏃舵牴鎹儴闂ㄥ懡浠ゅ叏璺緞鍜屽悕绉版垨缂栧彿鏌ラ噸锛�
+ * @return 閮ㄩ棬鐨勬樉绀哄璞★紝濡傛灉閮ㄩ棬涓嶅瓨鍦ㄥ垯杩斿洖null锛屼笉浼氭姏鍑哄紓甯�
+ * @throws VciBaseException 鍙傛暟涓虹┖鎴栬�呮暟鎹簱瀛樺湪闂鐨勬椂鍊欎細鎶涘嚭寮傚父
+ */
+ @Override
+ public List<OrgDepartmentVO> getDeptAllFullName() throws VciBaseException {
+ //鏌ヨ閮ㄩ棬淇℃伅锛屼富瑕佹煡璇㈤儴闂ㄥ悕绉扮粍鎴愬叏璺緞
+ String sql = "SELECT PLUID, PLNAME, PLNUM, PLSTATUS, level, substr(sys_connect_by_path(PLNAME, '/'), 2) AS FULL_NAME_PATH " +
+ "FROM PLDEPT " +
+ "START WITH PLPARENTUID IS NULL " +
+ "CONNECT BY PRIOR PLUID = PLPARENTUID";
+ List<BusinessObject> cbos = boService.queryByOnlySql(sql);
+ List<OrgDepartmentVO> departmentVOList = new ArrayList<>();
+ if(!CollectionUtils.isEmpty(cbos)){
+ cbos.stream().forEach(cbo->{
+ //閮ㄩ棬涓婚敭
+ String deptOid = ObjectTool.getNewBOAttributeValue(cbo,"PLUID");
+ //閮ㄩ棬鍚嶇О
+ String deptName = ObjectTool.getNewBOAttributeValue(cbo, "PLNAME");
+ //閮ㄩ棬缂栧彿
+ String deptNum = ObjectTool.getNewBOAttributeValue(cbo, "PLNUM");
+ //閮ㄩ棬灞傜骇
+ String deptLevel = ObjectTool.getNewBOAttributeValue(cbo, "level");
+ //閮ㄩ棬鍚嶇О鍏ㄨ矾寰�
+ String fullDeptNamePath = ObjectTool.getNewBOAttributeValue(cbo, "FULL_NAME_PATH");
+ //閮ㄩ棬鐘舵��
+ String deptStatus = ObjectTool.getNewBOAttributeValue(cbo, "PLSTATUS");
+ OrgDepartmentVO orgDepartmentVO = new OrgDepartmentVO(deptNum,deptName,Short.valueOf(deptStatus),fullDeptNamePath,Integer.valueOf(deptLevel));
+ orgDepartmentVO.setOid(deptOid);
+ departmentVOList.add(orgDepartmentVO);
+ });
+ }
+ return departmentVOList;
}
/**
@@ -147,7 +183,7 @@
if(deptForPlatform1!=null){
departmentVO.setOid(deptForPlatform1.getPluid());
// 闄ら儴闂ㄤ富閿鐨勫敮涓�鏍囪瘑锛岄暱搴︿负Dept:+8浣嶅彲閫氳繃璇ュ弬鏁板弽鎺ㄥ洖閮ㄩ棬涓婚敭鐨刪ash缂栫爜
- departmentVO.setUniqueId("Dept:"+Func.oidEnHash(deptForPlatform1.getPluid()));
+ //departmentVO.setUniqueId("Dept:"+Func.oidEnHash(deptForPlatform1.getPluid()));
departmentVO.setId(deptForPlatform1.getPlnum());
departmentVO.setName(deptForPlatform1.getPlname());
departmentVO.setStatus(deptForPlatform1.getPlstatus());
@@ -552,7 +588,7 @@
}
/**
- * 淇濆瓨閮ㄩ棬瑙掕壊鍏宠仈淇℃伅锛屽甫鏌ラ噸鍔熻兘
+ * 淇濆瓨閮ㄩ棬鐢ㄦ埛鍏宠仈淇℃伅锛屽甫鏌ラ噸鍔熻兘
* @param userOIds 鐢ㄦ埛id
* @param deptId 閮ㄩ棬id
* @return
@@ -602,7 +638,7 @@
if(Func.isNotBlank(orgDepartmentDTO.getId())){
conditionMap.put("plnum",QueryOptionConstant.OR + orgDepartmentDTO.getId());
}
- List<OrgDepartmentVO> departmentVOS = getDeptByDeptPOidAndCondition(orgDepartmentDTO.getPkFatherDepartment(), conditionMap);
+ List<OrgDepartmentVO> departmentVOS = getDeptByDeptpOidAndCondition(orgDepartmentDTO.getPkFatherDepartment(), conditionMap);
if(Func.isNotEmpty(departmentVOS)){
throw new VciBaseException("鍚屼竴鐖惰妭鐐逛笅璇ラ儴闂ㄥ悕绉版垨缂栧彿宸茬粡瀛樺湪,璇蜂慨鏀�!");
}
@@ -647,7 +683,7 @@
if(Func.isNotBlank(orgDepartmentDTO.getId())){
conditionMap.put("plnum",QueryOptionConstant.OR + orgDepartmentDTO.getId());
}
- List<OrgDepartmentVO> repeatDepartmentVOS = getDeptByDeptPOidAndCondition(orgDepartmentDTO.getPkFatherDepartment(), conditionMap);
+ List<OrgDepartmentVO> repeatDepartmentVOS = getDeptByDeptpOidAndCondition(orgDepartmentDTO.getPkFatherDepartment(), conditionMap);
repeatDepartmentVOS = repeatDepartmentVOS.stream().filter(item -> {
if((item.getName().equals(orgDepartmentDTO.getName()) || item.getId().equals(orgDepartmentDTO.getId())) &&
!item.getOid().equals(orgDepartmentDTO.getOid())){
@@ -707,19 +743,8 @@
//TODO: 搴旇鏄笉鍏峰杩炲甫鍒犻櫎鐨勫姛鑳斤紝閮ㄩ棬鍒犻櫎鍚庣敤鎴峰叧鑱旂殑鏃犵敤閮ㄩ棬杩樺湪,鑰冭檻鍚庢湡鏄惁闇�瑕佸仛锛屾暟鎹噺涓嶅ぇ鍙互涓嶅仛杩炲甫鍒犻櫎
return platformClientUtil.getFrameworkService().deleteDepartment(
ids,
- new UserEntityInfo("developer"/*WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId()*/, null)
+ new UserEntityInfo(WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(), null)
);
- }
-
- /**
- * 鑾峰彇鎵�鏈夐儴闂ㄧ殑淇℃伅
- * @return key锛氶儴闂ㄧ敱鍚嶇О缁勬垚鐨勮矾寰勶紙/闂撮殧锛夛紝value瀵瑰簲鏈�灏忓眰绾х殑閮ㄩ棬淇℃伅
- */
- @Override
- public Map<String, OrgDepartmentVO> getDeptAllTreeMap() {
- List<OrgDepartmentVO> orgDepartmentVOList = listAllLevelChildrenDeptByParentOid(null, null);
- Map<String, OrgDepartmentVO> stringOrgDepartmentVOMap = convertToMap(orgDepartmentVOList);
- return stringOrgDepartmentVOMap;
}
/**
@@ -732,10 +757,10 @@
//鐣岄潰娌′紶鍚嶇О锛屼娇鐢ㄩ粯璁ゅ悕绉�
downloadFileName = Func.isBlank(downloadFileName) ? "閮ㄩ棬瀵煎叆妯℃澘_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss"):downloadFileName;
// 璁剧疆琛ㄥ崟鍒楀悕
- List<String> columns = new ArrayList<>(Arrays.asList("ID", "鍚嶇О", "缂栧彿", "浠e彿", "涓撲笟", "鐖禝D锛堥儴闂ㄥ敮涓�鏍囪瘑ID锛�", "鎻忚堪"));
+ List<String> columns = new ArrayList<>(Arrays.asList("鍚嶇О", "缂栧彿", "浠e彿", "涓撲笟", "鐖堕儴闂ㄥ悕绉板叏璺緞锛�/闂撮殧锛�", "鎻忚堪"));
//璁剧疆蹇呭~鍒�
ColumnNameisRed.clear();
- //ColumnNameisRed.add(0);
+ ColumnNameisRed.add(0);
ColumnNameisRed.add(1);
//鍐檈xcel
String excelPath = LocalFileUtil.getDefaultTempFolder() + File.separator + downloadFileName + ".xls";
@@ -785,53 +810,56 @@
if(CollectionUtils.isEmpty(poList)){
return BaseResult.fail(ExcelLangCodeConstant.IMPORT_CONTENT_NULL,new String[]{});
}
- /*閮ㄩ棬瀵煎叆鍑犱釜姣旇緝閲嶈鐨勬儏鏅細
- 1銆佸綋鍓嶅鍏ョ殑鏁版嵁鏄竴涓儴闂ㄦ爲缁撴瀯(瑕佸垽鏂敤鎴锋墜杈撶殑ID鏄惁瀛樺湪閲嶅锛岃緭浜嗗氨瑕佸垽鏂槸鍚﹀湪褰撳墠琛ㄦ牸涓噸澶嶏紝
- 骞朵笖淇濆瓨鏃朵笉鑳戒娇鐢ㄧ敤鎴锋墜杈撶殑ID锛岃鏍规嵁鎵嬭緭ID鍜屽疄闄呭瓨鍌∣ID鍋氬搴旀槧灏勶紝
- 骞朵笖涓嶇牬鍧忚〃鏍间腑閮ㄩ棬鏍戠粨鏋勶紝濡傛灉娌℃墜杈揑D灏卞彧闇�瑕佸叧娉╬arentId杩欎釜灞炴�э紝
- 骞朵笖闇�瑕佹敞鎰忓鏋滄湁鐨処D鏈夛紝鏈夌殑娌℃湁閭e氨闇�瑕佹敞鎰忥紝鏃㈠瓨鍦ㄥ拰绯荤粺涓紝
- 鍏宠仈鐨勯儴闂ㄦ爲锛屽張瀛樺湪鍜屽綋鍓嶈〃鏍间腑鍏宠仈鐨勯儴闂ㄦ爲)銆�
- 2銆佸綋鍓嶅鍏ョ殑鏁版嵁鐖秈d鍏宠仈浜嗗凡瀛樺湪鐨勯儴闂╫id(瑕佹煡璇㈢埗id杩欎釜閮ㄩ棬鏄惁瀛樺湪锛�)
- 瑙e喅鎬濊矾锛氭渶濂芥槸灏嗚〃鏍间腑鍙兘鏄儴闂ㄦ爲鐨勭粰閬嶅巻鎴愭爲锛岀劧鍚庡啀鍋氭煡閲嶅暐鐨勫鐞�
- */
+
//2銆佸繀濉垽绌恒�佸垽閲嶏紙鏁版嵁搴撳垽閲嶅拰excel涓垽閲嶏級锛岀粍瑁呮垚淇濆瓨鐢ㄧ殑鏁版嵁瀵硅薄
List<DeptInfo> deptInfoList = new ArrayList<>();
- //2.1銆佺敤浠ュ瓨鍌╡xcel涓噸澶嶇殑鏁版嵁锛屼笁涓笉鍙噸澶嶇殑瀛楁锛夛紙Name涓嶈兘涓虹┖锛孨ame銆丆ode鍚屼竴鐖堕儴闂ㄤ笅鍞竴锛�
- List<String> repeatIdList = new ArrayList<>();
+ //2.1銆佺敤浠ュ瓨鍌╡xcel涓噸澶嶇殑鏁版嵁锛屼袱涓笉鍙噸澶嶇殑瀛楁锛夛紙Name涓嶈兘涓虹┖锛孨ame銆丆ode鍚屼竴鐖堕儴闂ㄤ笅鍞竴锛�
Map<String,String> repeatNameMap = new HashMap<>();
Map<String,String> repeatNumMap = new HashMap<>();
Map<String,String> indexMap = new HashMap<>();
//2.2銆佸瓨鍌ㄧ敤鎴锋墜杈撶殑oid鍜屽疄闄呭瓨鍌╫id鐨勬槧灏勫叧绯�
Map<String, String> oidMap = new HashMap<>();
+ //鏌ヨ绯荤粺涓儴闂紝鍏朵腑鍖呭惈浜嗛儴闂ㄥ悕绉版爲灞炴��
+ List<OrgDepartmentVO> dbOrgDepartmentVOList = this.getDeptAllFullName();
+ //閬嶅巻鎴恗ap瀵硅薄锛歬ey涓篋eptName鐨勫叏璺緞锛歷alue涓篋ept瀵硅薄(鐢ㄦ埛澶勭悊閮ㄩ棬鐖剁粍浠�)
+ Map<String, String> dbOrgDepartFullNameOidMap = dbOrgDepartmentVOList.stream().collect(Collectors.toMap(OrgDepartmentVO::getFullDeptNamePath, OrgDepartmentVO::getOid));
+ //鐢ㄦ潵鍒ゆ柇澶刾arentName鏃笉鍦ㄥ簱涓瓨鍦紝鍙堜笉鍦╬oNames瀛樺湪鐨勬儏鍐�
+ List<String> poNames = poList.stream().map(OrgDeptPO::getName).collect(Collectors.toList());
poList.stream().forEach(po->{
- String parentId = Func.isBlank(po.getParentId()) ? "":po.getParentId();
+ String parentFullNamePath = Func.isBlank(po.getParentFullNamePath()) ? "":po.getParentFullNamePath();
//閮ㄩ棬鍚嶇О鍒ょ┖锛岄�氬父閫氳繃po涓殑娉ㄨВ灏卞彲瀹炵幇
- if(Func.isEmpty(po.getName())){
+ if(Func.isBlank(po.getName())){
throw new VciBaseException("绗��"+po.getRowIndex()+"銆戣锛宒epterror,Reason:Name cannot be empty");
- }else if(parentId.equals(repeatNameMap.getOrDefault(po.getName(), null))/*excel涓悓涓�閮ㄩ棬涓婲ame鐩哥瓑*/){
+ }else if(parentFullNamePath.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()) && parentId.equals(repeatNumMap.getOrDefault(po.getNum(),null))/*excel涓悓涓�閮ㄩ棬涓嬬紪鍙峰瓨鍦� */){
+ }else if(Func.isNotBlank(po.getNum()) && parentFullNamePath.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",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);
+ //2.2銆佹煡璇㈡暟鎹簱涓殑鏁版嵁锛堟煡閲岻D鍜孨UM锛夛紝姣旇緝楹荤儲闇�瑕佹牴鎹甈arentName鍏ㄨ矾寰勬煡璇紙鎵�鏈夊彧鑳藉崟鏉℃煡璇㈣繘琛屽垽閲嶏級
+ //鍚屼竴閮ㄩ棬涓�(parentName鐩哥瓑)锛宯ame鎴栬�卬um鐩哥瓑
+ List<OrgDepartmentVO> repeatOrgDept = dbOrgDepartmentVOList.stream().filter(item -> {
+ //鍚屼竴閮ㄩ棬鍚嶇О鍏ㄨ矾寰勪笅锛岄儴闂ㄥ悕绉扮浉绛夈�侀儴闂ㄧ紪鍙蜂笉涓虹┖骞朵笖鍜岀郴缁熶腑瀛樺湪鐩哥瓑鐨勭紪鍙�
+ boolean isNameOrNumRepeat = po.getName().equals(item.getName()) || (Func.isNotBlank(po.getNum()) && po.getNum().equals(item.getId()));
+ /*褰損arentFullNamePath涓�""鏃秈tem.getFullDeptNamePath().contains(parentFullNamePath)姘歌繙涓簍rue锛�
+ 鎵�浠ラ渶瑕佺壒娈婂鐞嗙洿鎺ュ垽鏂《灞傜殑閮ㄩ棬鏄惁瀛樺湪閲嶅*/
+ if(((Func.isBlank(parentFullNamePath) && item.getTreelevel() == 1)
+ || (Func.isNotBlank(parentFullNamePath) && item.getFullDeptNamePath().contains(parentFullNamePath)))
+ && isNameOrNumRepeat) {
+ return true;
+ }
+ return false;
+ }).collect(Collectors.toList());
//鍙涓嶄负绌哄氨璇存槑褰撳墠琛屾暟鎹湪绯荤粺涓噸澶�
if(Func.isNotEmpty(repeatOrgDept)){
throw new VciBaseException("绗��"+po.getRowIndex()+"銆戣锛宒eptname or deptnum error,Reason: The name or number already exists in the system");
}
}
//瀛樺偍鏍¢獙閫氳繃鐨勬暟鎹紝浠ヤ究鍚庣画excel鏌ラ噸
- repeatNameMap.put(po.getName(),Func.isBlank(po.getParentId()) ? "":po.getParentId());
- repeatIdList.add(po.getId());
- repeatNumMap.put(po.getNum(),po.getParentId());
+ repeatNameMap.put(po.getName(),parentFullNamePath);
+ if(Func.isNotBlank(po.getNum())){
+ repeatNumMap.put(po.getNum(),parentFullNamePath);
+ }
indexMap.put(po.getName(),po.getRowIndex());
//鏍¢獙鏁版嵁灏辫缁勮鎴怐TO鏁版嵁瀵硅薄浜�
OrgDepartmentDTO dto = new OrgDepartmentDTO();
@@ -840,48 +868,51 @@
dto.setId(po.getNum());
dto.setDescription(po.getDesc());
dto.setSpecialties(po.getSpecialties());
- dto.setPkFatherDepartment(po.getParentId());
dto.setCreateTime(new Date());
dto.setCreator(loginUserId);
dto.setLastModifier(loginUserId);
dto.setStatus((short) 0);
- //2.2銆佽繃绋嬩腑澶勭悊涓婚敭杞崲闂鏈�濂芥槸涓�鏉′竴鏉$殑澶勭悊ID鏄惁瀛樺湪杩樻湁ParentID鏄惁瀛樺湪鐨勯棶棰�
- //鍏堝垽鏂槸宸插瓨鍦ㄧ殑閮ㄩ棬ID锛岃繕鏄笉瀛樺湪鐨勯儴闂↖D锛屽凡瀛樺湪绯荤粺涓殑ID灏辨槸涓篋ept:寮�澶寸殑
- String pId = Func.isBlank(dto.getPkFatherDepartment()) ? "":dto.getPkFatherDepartment();
- //鏄凡瀛樺湪绯荤粺涓殑閮ㄩ棬id
- if(pId.contains("Dept:")){
- //瑙f瀽鍑虹湡瀹炵殑oid
- String deParentId = Func.oidDeHash(pId.replace("Dept:", "").trim());
- //瑙f瀽鍑烘潵鐨刣eParentId蹇呴』寰楀湪搴撲腑瀛樺湪
- 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");
+ //缁欏鍏ョ殑鏁版嵁璁剧疆鐨勪富閿�
+ String oid = VciBaseUtil.getPk().toUpperCase(Locale.ROOT);
+ dto.setOid(oid);
+ /*澶勭悊閮ㄩ棬鍚嶇О鍏ㄨ矾寰勮浆鎹负PkFatherDepartment锛堥儴闂ㄤ富閿級锛�
+ 鎯呭喌1銆佺洿灞炵埗閮ㄩ棬鏄郴缁熶腑宸插瓨鍦紙鍒ゆ柇鏂瑰紡锛氶儴闂ㄥ悕绉板叏璺緞鍦╠bOrgDepartmentVOList涓瓨鍦紝fullDeptNamePath鍏ㄧ瓑浜巔arentFullNamePath锛夈��
+ 鎯呭喌2銆佺洿灞炵埗閮ㄩ棬涓嶆槸绯荤粺涓凡瀛樺湪鐨�,浣嗘槸鐩村睘鐖堕儴闂ㄧ殑鐨勪笂绾ч儴闂ㄦ槸绯荤粺涓凡瀛樺湪鐨�(娑夊強鍒皁id鍜宲arentoid瀵瑰簲鍏崇郴澶勭悊姣旇緝楹荤儲)銆�
+ 鎯呭喌3銆佺洿灞炵埗閮ㄩ棬鍜屽叾涓婄骇閮ㄩ棬閮芥槸excel涓柊鏋勫缓鐨勩��(娑夊強鍒皁id鍜宲arentoid瀵瑰簲鍏崇郴澶勭悊姣旇緝楹荤儲)*/
+ String dbDeptoid = dbOrgDepartFullNameOidMap.getOrDefault(parentFullNamePath, null);
+ //鎯呭喌1鍙互鐩存帴璁剧疆parentOid銆�
+ if(Func.isNotEmpty(dbDeptoid) || "".equals(parentFullNamePath)){
+ //璁剧疆鐖堕儴闂ㄤ富閿�
+ dto.setPkFatherDepartment(dbDeptoid);
+ }else{
+ //澶勭悊鐖惰矾寰勫悕鏃笉瀛樺湪浜庢暟鎹簱鍙堜笉瀛樺湪浜庡綋鍓峞xcel
+ String lastParentFullName = parentFullNamePath.substring(parentFullNamePath.lastIndexOf("/") + 1);//鐖惰矾寰勫悕鐨勬渶鍚庝竴涓儴闂ㄥ悕绉�
+ if(Func.isBlank(dbOrgDepartFullNameOidMap.getOrDefault(parentFullNamePath,null))
+ && !poNames.contains(lastParentFullName)
+ ){
+ throw new VciBaseException("褰撳墠瀵煎叆鐨勯儴闂ㄦ暟鎹腑锛岀銆�" + indexMap.get(po.getName()) + "銆戣锛岀埗閮ㄩ棬璁剧疆瀛樺湪闂锛�");
}
- //鏇挎崲鎺変复鏃朵娇鐢ㄧ殑閮ㄩ棬鍞竴鏍囪瘑锛屼絾鏄负浜嗘柟渚垮悗缁垽鏂紝杩樻槸闇�瑕佸姞涓奃ept:鏍囪瘑
- dto.setPkFatherDepartment("Dept:"+deParentId);
+ //鎯呭喌2鍜�3闇�瑕侀�氳繃鏄犲皠鍏崇郴璁剧疆parentoid锛屾墍浠ヨ繖閲屽厛鏍囪鍚庣画鍐嶅仛澶勭悊銆�
+ dto.setPkFatherDepartment("Pending:" + parentFullNamePath);
}
- //鐢ㄦ埛鎵嬭緭浜嗛儴闂╫id锛屼絾鏄伩鍏峯id涓嶈鑼冮渶瑕侊紝鐢ㄨ鑼僶id杩涜鏇挎崲锛屽鏋滄病杈撳叆淇濆瓨鏃朵細鑷姩鐢熸垚oid
- String excelOid = dto.getOid();
- if(Func.isNotBlank(excelOid)){
- String pkOid = VciBaseUtil.getPk().toUpperCase(Locale.ROOT);
- dto.setOid(pkOid);
- //oid鏄犲皠鍏崇郴锛屽悗缁敤鏉ユ洿鏂皃arentId
- oidMap.put(excelOid,pkOid);
- }
+ //瀛樺偍parentOid:oid鏄犲皠鍏崇郴
+ String key = Func.isBlank(parentFullNamePath) ? po.getName():parentFullNamePath + "/"+po.getName();
+ oidMap.put(key,oid);
+
DeptInfo deptInfo = this.changeOrgDeptDTOToDeptInfo(dto);
deptInfoList.add(deptInfo);
});
- //3銆佸鐞唅d鍜宲arentId鐨勬槧灏勫叧绯�:灏嗙敤鎴锋墜杈撶殑鐖禝D杞崲鎴愬疄闄呭瓨鍌ㄧ殑ID骞朵繚瀛樿繘搴�
+ //3銆佸鐞唎id鍜宲arentOid鐨勬槧灏勫叧绯�:閽堝鏂板姞鐨勬暟鎹槸鐖堕儴闂�
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:")){
+ //parentId涓嶄负绌哄苟涓旀病鏈塒ending:鐩稿叧鐨勫瓧绗︿覆,璇存槑鏄渶瑕佸鐞唎id鏄犲皠parentOid鐨�
+ if (info.parentId.contains("Pending:")){
//绯荤粺涓凡瀛樺湪鐨勭埗閮ㄩ棬OID锛岄渶瑕佺Щ闄ゆ帀Dept:鏍囪瘑
- info.parentId = info.parentId.replace("Dept:","");
+ String key = info.parentId.replace("Pending:","");
+ String parentId = oidMap.get(key);
+ info.parentId = parentId;
}
+ //4銆佷繚瀛樻搷浣�
platformClientUtil.getFrameworkService().saveDepartment(
info,
userEntityInfo
@@ -893,7 +924,7 @@
});
}catch (Exception e){
if(logger.isErrorEnabled()){
- logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨鐢ㄦ埛淇℃伅鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",e.getMessage());
+ logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨閮ㄩ棬鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",e.getMessage());
}
e.printStackTrace();
return BaseResult.fail(LangBaseUtil.getErrorMsg(e),new String[]{},e);
@@ -901,7 +932,23 @@
return BaseResult.success("閮ㄩ棬瀵煎叆鎴愬姛锛�");
}
- public Map<String, OrgDepartmentVO> convertToMap(List<OrgDepartmentVO> orgDepartmentVOList) {
+ /**
+ * 鑾峰彇鎵�鏈夐儴闂ㄧ殑淇℃伅
+ * @return key锛氶儴闂ㄧ敱鍚嶇О缁勬垚鐨勮矾寰勶紙/闂撮殧锛夛紝value瀵瑰簲鏈�灏忓眰绾х殑閮ㄩ棬淇℃伅
+ */
+ @Override
+ public Map<String, OrgDepartmentVO> getDeptAllTreeMap() {
+ List<OrgDepartmentVO> orgDepartmentVOList = listAllLevelChildrenDeptByParentOid(null, null);
+ Map<String, OrgDepartmentVO> stringOrgDepartmentVOMap = convertToMap(orgDepartmentVOList);
+ return stringOrgDepartmentVOMap;
+ }
+
+ /**
+ * 鑾峰彇閮ㄩ棬鐢卞悕绉扮粍鎴愮殑璺緞锛�/闂撮殧锛夛紝value瀵瑰簲鏈�灏忓眰绾х殑閮ㄩ棬淇℃伅
+ * @param orgDepartmentVOList
+ * @return
+ */
+ private Map<String, OrgDepartmentVO> convertToMap(List<OrgDepartmentVO> orgDepartmentVOList) {
Map<String, OrgDepartmentVO> map = new HashMap<>();
for (OrgDepartmentVO orgDepartmentVO : orgDepartmentVOList) {
String key = buildKey(orgDepartmentVO, orgDepartmentVOList);
--
Gitblit v1.9.3