From 4e811ec71dba161e13592828a6035e9316b1548e Mon Sep 17 00:00:00 2001
From: wangting <675591594@qq.com>
Date: 星期五, 30 八月 2024 17:15:29 +0800
Subject: [PATCH] 链接类型查询模板
---
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java | 576 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 547 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 3f73e92..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
@@ -1,35 +1,42 @@
package com.vci.frameworkcore.compatibility.impl;
+import com.vci.dto.OrgDepartmentDTO;
import com.vci.corba.common.PLException;
+import com.vci.corba.common.data.UserEntityInfo;
+import com.vci.corba.framework.data.DeptInfo;
import com.vci.corba.omd.data.BusinessObject;
import com.vci.frameworkcore.compatibility.OrgDeptQueryServiceI;
import com.vci.frameworkcore.lcstatuspck.FrameworkDataLCStatus;
-import com.vci.frameworkcore.model.OrgDeptForPlatform1;
-import com.vci.frameworkcore.model.SmRoleForPlatform1;
-import com.vci.frameworkcore.pagemodel.OrgDepartmentVO;
-import com.vci.frameworkcore.pagemodel.SmRoleVO;
+import com.vci.model.OrgDeptForPlatform1;
+import com.vci.po.OrgDeptPO;
+import com.vci.pagemodel.OrgDepartmentVO;
import com.vci.omd.utils.ObjectTool;
+import com.vci.starter.poi.bo.ReadExcelOption;
+import com.vci.starter.poi.bo.WriteExcelData;
+import com.vci.starter.poi.bo.WriteExcelOption;
+import com.vci.starter.poi.constant.ExcelLangCodeConstant;
+import com.vci.starter.poi.util.ExcelUtil;
import com.vci.starter.revision.bo.TreeWrapperOptions;
import com.vci.starter.revision.service.RevisionModelUtil;
import com.vci.starter.web.constant.QueryOptionConstant;
import com.vci.starter.web.exception.VciBaseException;
-import com.vci.starter.web.pagemodel.DataGrid;
-import com.vci.starter.web.pagemodel.PageHelper;
-import com.vci.starter.web.pagemodel.Tree;
-import com.vci.starter.web.pagemodel.TreeQueryObject;
-import com.vci.starter.web.util.BeanUtil;
-import com.vci.starter.web.util.VciBaseUtil;
+import com.vci.starter.web.pagemodel.*;
+import com.vci.starter.web.util.*;
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.apache.poi.hssf.util.HSSFColor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
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.io.File;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -61,19 +68,96 @@
private RevisionModelUtil revisionModelUtil;
/**
+ * 蹇呭~鍒�
+ */
+ private List<Integer> ColumnNameisRed = new ArrayList<Integer>();
+
+ /**
+ * 鏃ュ織
+ */
+ private Logger logger = LoggerFactory.getLogger(getClass());
+
+ /**
* 鏍规嵁閮ㄩ棬涓婚敭鑾峰彇閮ㄩ棬鐨勪俊鎭�
* @param deptOid 閮ㄩ棬涓婚敭
* @return 閮ㄩ棬鐨勬樉绀哄璞★紝濡傛灉閮ㄩ棬涓嶅瓨鍦ㄥ垯杩斿洖null锛屼笉浼氭姏鍑哄紓甯�
* @throws VciBaseException 鍙傛暟涓虹┖鎴栬�呮暟鎹簱瀛樺湪闂鐨勬椂鍊欎細鎶涘嚭寮傚父
*/
@Override
- public OrgDepartmentVO getDeptByDeptOid(String deptOid)
- throws VciBaseException {
+ public OrgDepartmentVO getDeptByDeptOid(String deptOid) throws VciBaseException {
if(StringUtils.isBlank(deptOid)){
return null;
}
- OrgDeptForPlatform1 deptForPlatform1 = boService.selectByOid(deptOid, OrgDeptForPlatform1.class);
- return deptDO2VO(deptForPlatform1);
+ Map<String, String> conditionMap = new HashMap<>();
+ conditionMap.put("pluid",deptOid);
+ VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(conditionMap, OrgDeptForPlatform1.class);
+ List<OrgDeptForPlatform1> deptForPlatform1s = boService.selectByQueryWrapper(queryWrapper, OrgDeptForPlatform1.class);
+ if(Func.isEmpty(deptForPlatform1s)){
+ return null;
+ }
+ return deptDO2VO(deptForPlatform1s.get(0));
+ }
+
+ /**
+ * 鏍规嵁鐖堕儴闂ㄤ富閿幏鍙栭儴闂ㄥ悕绉伴儴闂ㄧ殑淇℃伅
+ * @param parentDeptOid 鐖堕儴闂ㄤ富閿�
+ * @param conditionMap 閮ㄩ棬鍚嶇О
+ * @return 閮ㄩ棬鐨勬樉绀哄璞★紝濡傛灉閮ㄩ棬涓嶅瓨鍦ㄥ垯杩斿洖null锛屼笉浼氭姏鍑哄紓甯�
+ * @throws VciBaseException 鍙傛暟涓虹┖鎴栬�呮暟鎹簱瀛樺湪闂鐨勬椂鍊欎細鎶涘嚭寮傚父
+ */
+ @Override
+ public List<OrgDepartmentVO> getDeptByDeptpOidAndCondition(String parentDeptOid,Map<String,String> conditionMap) throws VciBaseException {
+ if(Func.isEmpty(conditionMap)){
+ conditionMap = new HashMap();
+ }
+ VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(conditionMap,OrgDeptForPlatform1.class);
+ //鐖朵富閿负绌烘煡椤跺眰
+ if(Func.isBlank(parentDeptOid)){
+ queryWrapper.isNull("plparentuid");
+ }else{
+ queryWrapper.eq("plparentuid",parentDeptOid);
+ }
+ List<OrgDeptForPlatform1> roleForPlatform1s = boService.selectByQueryWrapper(queryWrapper, OrgDeptForPlatform1.class);
+ if(Func.isEmpty(roleForPlatform1s)){
+ 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;
}
/**
@@ -98,18 +182,23 @@
OrgDepartmentVO departmentVO = new OrgDepartmentVO();
if(deptForPlatform1!=null){
departmentVO.setOid(deptForPlatform1.getPluid());
+ // 闄ら儴闂ㄤ富閿鐨勫敮涓�鏍囪瘑锛岄暱搴︿负Dept:+8浣嶅彲閫氳繃璇ュ弬鏁板弽鎺ㄥ洖閮ㄩ棬涓婚敭鐨刪ash缂栫爜
+ //departmentVO.setUniqueId("Dept:"+Func.oidEnHash(deptForPlatform1.getPluid()));
departmentVO.setId(deptForPlatform1.getPlnum());
departmentVO.setName(deptForPlatform1.getPlname());
+ departmentVO.setStatus(deptForPlatform1.getPlstatus());
if(0 == deptForPlatform1.getPlstatus()){
- departmentVO.setLcStatus(FrameworkDataLCStatus.ENABLED.getValue());
+ departmentVO.setStatusText(FrameworkDataLCStatus.ENABLED.getValue());
}else{
- departmentVO.setLcStatus(FrameworkDataLCStatus.DISABLED.getValue());
+ departmentVO.setStatusText(FrameworkDataLCStatus.DISABLED.getValue());
}
+ departmentVO.setSpecialties(deptForPlatform1.getPlspecialties());
+ departmentVO.setCode(deptForPlatform1.getPlcode());
departmentVO.setPkFatherDepartment(deptForPlatform1.getPlparentuid());
departmentVO.setDescription(deptForPlatform1.getPldesc());
- departmentVO.setCheckInTime(deptForPlatform1.getPlcreatetime());
+ departmentVO.setCreateTime(new Date(deptForPlatform1.getPlcreatetime()));
departmentVO.setCreator(deptForPlatform1.getPlcreateuser());
- departmentVO.setLastModifyTime(deptForPlatform1.getPlupdatetime());
+ departmentVO.setLastModifyTime(new Date(deptForPlatform1.getPlupdatetime()));
departmentVO.setLastModifier(deptForPlatform1.getPlupdateuser());
}
return departmentVO;
@@ -137,7 +226,7 @@
depts.addAll(roleForPlatform1s);
}
});
- return deptDO2VOs(depts);
+ return deptDO2VOs(depts);
}
/**
@@ -153,6 +242,7 @@
if(pageHelper == null){
pageHelper = new PageHelper(-1);
}
+ //鏍规嵁閮ㄩ棬缂栧彿鎺掑簭
pageHelper.addDefaultAsc("plnum");
VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(queryMap,OrgDeptForPlatform1.class,pageHelper);
List<OrgDeptForPlatform1> deptForPlatform1s = boService.selectByQueryWrapper(queryWrapper, OrgDeptForPlatform1.class);
@@ -288,7 +378,7 @@
* 鎵归噺鏍规嵁鐢ㄦ埛鐨勪富閿潵鑾峰彇閮ㄩ棬
* @param userOidCollection 鐢ㄦ埛涓婚敭闆嗗悎
* @param queryMap 鏌ヨ鏉′欢锛屽鏋滈渶瑕佷娇鐢ㄧ敤鎴风殑灞炴�ф潵鏌ヨ鍙互浣跨敤pkUser.xxxx
- * @return 閮ㄩ棬鐨勬樉绀哄璞★紝key鏄敤鎴蜂富閿�,value鏄繖涓敤鎴峰叧鑱旂殑閮ㄩ棬
+ * @return 閮ㄩ棬鐨勬樉绀哄璞★紝key鏄敤鎴蜂富閿�,value鏄叧鑱旂殑閮ㄩ棬
*/
@Override
public Map<String, List<OrgDepartmentVO>> batchListDeptByUserOids(
@@ -318,7 +408,6 @@
//杩欏効搴旇瀵筪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<>();
@@ -334,7 +423,63 @@
return new HashMap<>();
}
- /**
+ /**
+ * 鎵归噺鏍规嵁鐢ㄦ埛鐨勪富閿潵鑾峰彇閮ㄩ棬鍚嶇О锛�/闂撮殧鏂瑰紡锛�
+ * @param userOidCollection 鐢ㄦ埛涓婚敭闆嗗悎
+ * @param queryMap 鏌ヨ鏉′欢锛屽鏋滈渶瑕佷娇鐢ㄧ敤鎴风殑灞炴�ф潵鏌ヨ鍙互浣跨敤pkUser.xxxx
+ * @return 閮ㄩ棬鐨勬樉绀哄璞★紝key鏄敤鎴蜂富閿�,value鏄叧鑱旂殑閮ㄩ棬锛堝寘鍚埗鑺傜偣濡傚綋鍓嶉儴闂ㄤ负浜哄姏璧勬簮閮ㄥ垯鍊间负锛�550/浜哄姏璧勬簮閮級
+ */
+ @Override
+ public Map<String,Map<String,String>> batchMapDeptNameByUserOids(Collection<String> userOidCollection, Map<String, String> queryMap) {
+ if(CollectionUtils.isEmpty(userOidCollection)){
+ return new HashMap<>();
+ }
+ Map<String,Map<String,String>> deptOidNameMap = new HashMap<>();
+ Map<String,Map<String,String>> userDeptOidMap = new HashMap<>();
+ WebUtil.switchCollectionForOracleIn(userOidCollection).stream().forEach(userOids->{
+ //1銆佽鍏堟牴鎹敤鎴蜂富閿幏鍙栧埌鍏宠仈鐨勯儴闂ㄤ富閿�
+ String sql = "select pluseruid,pldeptuid from pluserdept where pluseruid in (" + WebUtil.toInSql(userOids.toArray(new String[0])) + ")";
+ List<BusinessObject> cbos = boService.queryBySql(sql, null);
+ if(!CollectionUtils.isEmpty(cbos)){
+ cbos.stream().forEach(cbo->{
+ //瑙掕壊涓婚敭
+ String userOid = ObjectTool.getNewBOAttributeValue(cbo,"pluseruid");
+ //閮ㄩ棬涓婚敭
+ String deptUid = ObjectTool.getNewBOAttributeValue(cbo, "pldeptuid");
+ //2銆佺劧鍚庢牴鎹儴闂ㄤ富閿幏鍙栧埌鐢遍儴闂ㄥ悕绉�/缁勬垚鐨勫��
+ //閬垮厤澶氭鏌ヨ锛屾垨鑰呭惊鐜煡璇�
+ if(deptOidNameMap.containsKey(deptUid)){
+ userDeptOidMap.put(userOid,deptOidNameMap.get(deptUid));
+ }else {
+ if(Func.isNotEmpty(deptUid)){
+ //2.1銆佹煡璇㈤儴闂╫id锛屽綋鍓嶉儴闂ㄥ寘鍚埗閮ㄩ棬
+ String queryDeptSql = "select pluid,plname from pldept START with pluid = '" +
+ deptUid + "' connect by prior plparentuid = pluid";
+ List<BusinessObject> cboDepts = boService.queryBySql(queryDeptSql, null);
+ if(!CollectionUtils.isEmpty(cboDepts)){
+ StringBuilder sb = new StringBuilder();
+ for (int i = cboDepts.size()-1; i >=0; i--) {
+ String deptName = ObjectTool.getNewBOAttributeValue(cboDepts.get(i),"plname");
+ sb.append(deptName);
+ sb.append("/");
+ }
+ //2.2銆侀伩鍏嶅悓涓�閮ㄩ棬澶氭鏌ヨ锛岃繖閲屽瓨鍌ㄥ湪涓�涓叕鍏遍泦鍚堜腑锛屼究浜庨噸澶嶄娇鐢�
+ //鍒犻櫎鏈�鍚庝竴涓枩鏉�
+ sb.deleteCharAt(sb.length() - 1);
+ Map<String,String> tempMap = new HashMap<>();
+ tempMap.put(deptUid,sb.toString());
+ deptOidNameMap.put(deptUid,tempMap);
+ userDeptOidMap.put(userOid,tempMap);
+ }
+ }
+ }
+ });
+ }
+ });
+ return userDeptOidMap;
+ }
+
+ /**
* 鑾峰彇鏌愪釜閮ㄩ棬鐨勭洿灞炰笅绾ч儴闂�
* @param pkFatherDepartmment 閮ㄩ棬鐨勪富閿�
* @param queryMap 鏌ヨ鏉′欢
@@ -376,6 +521,7 @@
public List<Tree> refTreeDept(TreeQueryObject treeQueryObject) {
String pkFatherDepartmment=treeQueryObject.getParentOid();
Map<String, String> conditionMap = treeQueryObject.getConditionMap();
+ Map<String, String> extandParamsMap = treeQueryObject.getExtandParamsMap();
if(conditionMap==null){
conditionMap=new HashMap<String, String>();
}
@@ -390,9 +536,27 @@
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())?"銆愬仠鐢ㄣ��":"");
+ List<Tree> trees = revisionModelUtil.doList2Trees(orgDepartmentVOList, treeWrapperOptions, dept -> {
+ return dept.getId() + " " + dept.getName() + (FrameworkDataLCStatus.DISABLED.getValue().equals(dept.getLcStatus()) ? "銆愬仠鐢ㄣ��" : "");
});
+ //extandParamsMap涓坊鍔�"showAllDepartmentNode"涓�"true"鏃�,骞朵笖parentOid涓虹┖锛岃繑鍥炵粨鏋滀腑浼氬寘鍚�滄墍鏈夐儴闂ㄢ�濊繖涓妭鐐�
+ if(Func.isBlank(pkFatherDepartmment) && (Func.isNotEmpty(extandParamsMap) && Boolean.parseBoolean(extandParamsMap.getOrDefault("showAllDepartmentNode","false")))){
+ List<Tree> treeList = new ArrayList<>();
+ Tree tree = new Tree();
+ tree.setLeaf(false);
+ tree.setParentId(null);
+ //娌℃湁瀹為檯浣滅敤鍙槸鐣岄潰涓婃覆鏌撲娇鐢�
+ tree.setOid(UUID.randomUUID().toString());
+ tree.setParentName(null);
+ Map<String, String> map = new HashMap<>();
+ map.put("name","鎵�鏈夐儴闂�");
+ map.put("ALLDept","ALLDept");
+ tree.setAttributes(map);
+ tree.setChildren(trees);
+ treeList.add(tree);
+ return treeList;
+ }
+ return trees;
}
/**
@@ -424,7 +588,7 @@
}
/**
- * 淇濆瓨閮ㄩ棬瑙掕壊鍏宠仈淇℃伅锛屽甫鏌ラ噸鍔熻兘
+ * 淇濆瓨閮ㄩ棬鐢ㄦ埛鍏宠仈淇℃伅锛屽甫鏌ラ噸鍔熻兘
* @param userOIds 鐢ㄦ埛id
* @param deptId 閮ㄩ棬id
* @return
@@ -432,9 +596,6 @@
@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
@@ -455,9 +616,366 @@
tempList.removeAll(repeatUserOidList);
userOIds = tempList.toArray(new String[tempList.size()]);
if(Func.isNotEmpty(userOIds)){
- platformClientUtil.getFrameworkService().saveUserDept(userOIds, deptId,null);
+ platformClientUtil.getFrameworkService().saveUserDept(userOIds, deptId,new UserEntityInfo(WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(),null));
}
return true;
}
+ /**
+ * 澧炲姞閮ㄩ棬淇℃伅
+ * @param orgDepartmentDTO
+ * @return
+ */
+ @Override
+ public boolean addDept(OrgDepartmentDTO orgDepartmentDTO) throws PLException {
+ //鍒ょ┖
+ VciBaseUtil.alertNotNull(
+ orgDepartmentDTO,"娣诲姞鐨勯儴闂ㄥ璞�",
+ orgDepartmentDTO.getName(),"閮ㄩ棬鍚�");
+ //閮ㄩ棬鍚嶅拰缂栧彿鍒ら噸
+ Map<String, String> conditionMap = new HashMap<>();
+ conditionMap.put("plname",QueryOptionConstant.OR + orgDepartmentDTO.getName());
+ if(Func.isNotBlank(orgDepartmentDTO.getId())){
+ conditionMap.put("plnum",QueryOptionConstant.OR + orgDepartmentDTO.getId());
+ }
+ List<OrgDepartmentVO> departmentVOS = getDeptByDeptpOidAndCondition(orgDepartmentDTO.getPkFatherDepartment(), conditionMap);
+ if(Func.isNotEmpty(departmentVOS)){
+ throw new VciBaseException("鍚屼竴鐖惰妭鐐逛笅璇ラ儴闂ㄥ悕绉版垨缂栧彿宸茬粡瀛樺湪,璇蜂慨鏀�!");
+ }
+ SessionInfo loginUser = WebThreadLocalUtil.getCurrentUserSessionInfoInThread();
+ String userId = loginUser.getUserId();
+
+ //鐢熸垚瀛樺偍鐨刢orba瀵硅薄
+ orgDepartmentDTO.setCreateTime(new Date());
+ orgDepartmentDTO.setCreator(userId);
+ orgDepartmentDTO.setLastModifier(userId);
+ orgDepartmentDTO.setStatus((short) 0);
+ DeptInfo deptInfo = changeOrgDeptDTOToDeptInfo(orgDepartmentDTO);
+ UserEntityInfo userEntityInfo = new UserEntityInfo(userId, "");
+ String oid = platformClientUtil.getFrameworkService().saveDepartment(deptInfo, userEntityInfo);
+ if (Func.isEmpty(oid)) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * 淇敼閮ㄩ棬淇℃伅
+ * @param orgDepartmentDTO
+ * @return
+ */
+ @Override
+ public boolean updateDept(OrgDepartmentDTO orgDepartmentDTO) throws PLException {
+ //鍒ょ┖
+ VciBaseUtil.alertNotNull(
+ orgDepartmentDTO,"淇敼鐨勯儴闂ㄥ璞�",
+ orgDepartmentDTO.getOid(),"鐢ㄦ埛涓婚敭",
+ orgDepartmentDTO.getId(),"鐢ㄦ埛鍚�"
+ );
+ //鎸塷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())){
+ conditionMap.put("plnum",QueryOptionConstant.OR + orgDepartmentDTO.getId());
+ }
+ 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())){
+ return true;
+ }
+ return false;
+ }).collect(Collectors.toList());
+ if(Func.isNotEmpty(repeatDepartmentVOS) ){
+ throw new VciBaseException("鍚屼竴鐖惰妭鐐逛笅璇ラ儴闂ㄥ悕绉版垨缂栧彿宸茬粡瀛樺湪,璇蜂慨鏀�!");
+ }
+ OrgDepartmentDTO departmentDTO = new OrgDepartmentDTO();
+ BeanUtil.convert(dbDepartmentVO,departmentDTO);
+ departmentDTO.setCode(orgDepartmentDTO.getCode());
+ departmentDTO.setId(orgDepartmentDTO.getId());
+ departmentDTO.setSpecialties(orgDepartmentDTO.getSpecialties());
+ departmentDTO.setDescription(orgDepartmentDTO.getDescription());
+ departmentDTO.setName(orgDepartmentDTO.getName());
+ String loginUserId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
+ orgDepartmentDTO.setLastModifier(loginUserId);
+ DeptInfo deptInfo = changeOrgDeptDTOToDeptInfo(departmentDTO);
+ boolean updateBoolean = platformClientUtil.getFrameworkService().updateDepartment(deptInfo, new UserEntityInfo(loginUserId, null));
+ return updateBoolean;
+ }
+
+ /**
+ * Dto瀵硅薄杞琧orb瀵硅薄
+ * @param orgDepartmentDTO
+ * @return
+ */
+ public DeptInfo changeOrgDeptDTOToDeptInfo(OrgDepartmentDTO orgDepartmentDTO) {
+ DeptInfo departmentInfo = new DeptInfo();
+ departmentInfo.id = orgDepartmentDTO.getOid() == null ? "" : orgDepartmentDTO.getOid();
+ departmentInfo.name = orgDepartmentDTO.getName() == null ? "" : orgDepartmentDTO.getName();
+ departmentInfo.num = orgDepartmentDTO.getId() == null ? "" : orgDepartmentDTO.getId();
+ departmentInfo.code = orgDepartmentDTO.getCode() == null ? "" : orgDepartmentDTO.getCode();
+ departmentInfo.specialties = orgDepartmentDTO.getSpecialties() == null ? "" : orgDepartmentDTO.getSpecialties();
+ departmentInfo.status = orgDepartmentDTO.getStatus() == 0 ? 0 : orgDepartmentDTO.getStatus();
+ departmentInfo.description = orgDepartmentDTO.getDescription() == null ? "" : orgDepartmentDTO.getDescription();
+ departmentInfo.parentId = orgDepartmentDTO.getPkFatherDepartment() == null ? "" : orgDepartmentDTO.getPkFatherDepartment();
+ departmentInfo.createUser = orgDepartmentDTO.getCreator() == null ? "" : orgDepartmentDTO.getCreator();
+ departmentInfo.createTime = orgDepartmentDTO.getCreateTime().getTime();
+ departmentInfo.updateTime = System.currentTimeMillis();
+ departmentInfo.updateUser = orgDepartmentDTO.getLastModifier() == null ? "" : orgDepartmentDTO.getLastModifier();
+ //departmentInfo.grantor = orgDepartmentDTO.getGrantor() == null ? "" : orgDepartmentDTO.getGrantor();
+ return departmentInfo;
+ }
+
+ /**
+ * 鍒犻櫎閮ㄩ棬
+ * @param ids
+ * @return
+ */
+ @Override
+ public boolean deleteDept(String[] ids) throws PLException {
+ VciBaseUtil.alertNotNull(ids,"瑕佸垹闄ょ殑閮ㄩ棬涓婚敭");
+ //TODO:鑰冭檻鏄惁闇�瑕佹坊鍔犲垹闄ゅ墠鍒ゆ柇閮ㄩ棬涓嬫槸鍚﹂厤缃湁鐢ㄦ埛锛岃繖绉嶆儏鍐靛簲璇ヤ笉鍏佽鍒犻櫎
+ //TODO: 搴旇鏄笉鍏峰杩炲甫鍒犻櫎鐨勫姛鑳斤紝閮ㄩ棬鍒犻櫎鍚庣敤鎴峰叧鑱旂殑鏃犵敤閮ㄩ棬杩樺湪,鑰冭檻鍚庢湡鏄惁闇�瑕佸仛锛屾暟鎹噺涓嶅ぇ鍙互涓嶅仛杩炲甫鍒犻櫎
+ return platformClientUtil.getFrameworkService().deleteDepartment(
+ ids,
+ new UserEntityInfo(WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(), null)
+ );
+ }
+
+ /**
+ * 涓嬭浇瀵煎叆閮ㄩ棬鐨別xcel妯℃澘銆�
+ * @param downloadFileName
+ * @return
+ */
+ @Override
+ public String downloadImportTemplate(String downloadFileName) {
+ //鐣岄潰娌′紶鍚嶇О锛屼娇鐢ㄩ粯璁ゅ悕绉�
+ downloadFileName = Func.isBlank(downloadFileName) ? "閮ㄩ棬瀵煎叆妯℃澘_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss"):downloadFileName;
+ // 璁剧疆琛ㄥ崟鍒楀悕
+ List<String> columns = new ArrayList<>(Arrays.asList("鍚嶇О", "缂栧彿", "浠e彿", "涓撲笟", "鐖堕儴闂ㄥ悕绉板叏璺緞锛�/闂撮殧锛�", "鎻忚堪"));
+ //璁剧疆蹇呭~鍒�
+ ColumnNameisRed.clear();
+ ColumnNameisRed.add(0);
+ ColumnNameisRed.add(1);
+ //鍐檈xcel
+ String excelPath = LocalFileUtil.getDefaultTempFolder() + File.separator + downloadFileName + ".xls";
+ try {
+ new File(excelPath).createNewFile();
+ } catch (Throwable e) {
+ throw new VciBaseException(LangBaseUtil.getErrorMsg(e), new String[]{excelPath}, e);
+ }
+ //璁剧疆鍒�
+ List<WriteExcelData> excelDataList = new ArrayList<>();
+ for (int index = 0; index < columns.size(); index++) {
+ //鍒ゆ柇鏄惁涓哄繀濉垪锛岀粰蹇呭~鍒楄缃鑹�
+ if(ColumnNameisRed.contains(index)){
+ WriteExcelData excelData = new WriteExcelData(0, index, columns.get(index));
+ excelData.setFontColor(String.valueOf(HSSFColor.HSSFColorPredefined.RED.getIndex()));
+ excelDataList.add(excelData);
+ }else{
+ excelDataList.add(new WriteExcelData(0,index, columns.get(index)));
+ }
+ }
+ WriteExcelOption excelOption = new WriteExcelOption(excelDataList);
+ ExcelUtil.writeDataToFile(excelPath, excelOption);
+ return excelPath;
+ }
+
+ /**
+ * 瀵煎叆閮ㄩ棬
+ * @param file
+ * @return
+ * @throws VciBaseException
+ */
+ @Override
+ public BaseResult importDept(File file) throws Exception {
+ VciBaseUtil.alertNotNull(file,"excel鏂囦欢");
+ if(!file.exists()){
+ throw new VciBaseException("瀵煎叆鐨別xcel鏂囦欢涓嶅瓨鍦�,{0}",new String[]{file.getPath()});
+ }
+ try{
+ //1銆佽鍙杄xcel涓殑鏁版嵁锛岀粍鎴愬璞�
+ ReadExcelOption excelOption = new ReadExcelOption();
+ //褰撳墠鐧诲綍鐨勭敤鎴疯处鍙�
+ //String loginUserId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
+ String loginUserId = "developer";
+ UserEntityInfo userEntityInfo = new UserEntityInfo(loginUserId,null);
+ List<OrgDeptPO> poList = ExcelUtil.readDataObjectFromExcel(file, OrgDeptPO.class,excelOption,(value, po, fieldName)->{});
+ //鍘婚櫎閮芥槸绌虹殑鎯呭喌
+ if(CollectionUtils.isEmpty(poList)){
+ return BaseResult.fail(ExcelLangCodeConstant.IMPORT_CONTENT_NULL,new String[]{});
+ }
+
+ //2銆佸繀濉垽绌恒�佸垽閲嶏紙鏁版嵁搴撳垽閲嶅拰excel涓垽閲嶏級锛岀粍瑁呮垚淇濆瓨鐢ㄧ殑鏁版嵁瀵硅薄
+ List<DeptInfo> deptInfoList = 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 parentFullNamePath = Func.isBlank(po.getParentFullNamePath()) ? "":po.getParentFullNamePath();
+ //閮ㄩ棬鍚嶇О鍒ょ┖锛岄�氬父閫氳繃po涓殑娉ㄨВ灏卞彲瀹炵幇
+ if(Func.isBlank(po.getName())){
+ throw new VciBaseException("绗��"+po.getRowIndex()+"銆戣锛宒epterror,Reason:Name cannot be empty");
+ }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.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锛夛紝姣旇緝楹荤儲闇�瑕佹牴鎹甈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(),parentFullNamePath);
+ if(Func.isNotBlank(po.getNum())){
+ repeatNumMap.put(po.getNum(),parentFullNamePath);
+ }
+ indexMap.put(po.getName(),po.getRowIndex());
+ //鏍¢獙鏁版嵁灏辫缁勮鎴怐TO鏁版嵁瀵硅薄浜�
+ OrgDepartmentDTO dto = new OrgDepartmentDTO();
+ BeanUtil.convert(po,dto);
+ dto.setOid(po.getId());
+ dto.setId(po.getNum());
+ dto.setDescription(po.getDesc());
+ dto.setSpecialties(po.getSpecialties());
+ dto.setCreateTime(new Date());
+ dto.setCreator(loginUserId);
+ dto.setLastModifier(loginUserId);
+ dto.setStatus((short) 0);
+ //缁欏鍏ョ殑鏁版嵁璁剧疆鐨勪富閿�
+ 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()) + "銆戣锛岀埗閮ㄩ棬璁剧疆瀛樺湪闂锛�");
+ }
+ //鎯呭喌2鍜�3闇�瑕侀�氳繃鏄犲皠鍏崇郴璁剧疆parentoid锛屾墍浠ヨ繖閲屽厛鏍囪鍚庣画鍐嶅仛澶勭悊銆�
+ dto.setPkFatherDepartment("Pending:" + parentFullNamePath);
+ }
+ //瀛樺偍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銆佸鐞唎id鍜宲arentOid鐨勬槧灏勫叧绯�:閽堝鏂板姞鐨勬暟鎹槸鐖堕儴闂�
+ deptInfoList.stream().forEach(info -> {
+ try {
+ //parentId涓嶄负绌哄苟涓旀病鏈塒ending:鐩稿叧鐨勫瓧绗︿覆,璇存槑鏄渶瑕佸鐞唎id鏄犲皠parentOid鐨�
+ if (info.parentId.contains("Pending:")){
+ //绯荤粺涓凡瀛樺湪鐨勭埗閮ㄩ棬OID锛岄渶瑕佺Щ闄ゆ帀Dept:鏍囪瘑
+ String key = info.parentId.replace("Pending:","");
+ String parentId = oidMap.get(key);
+ info.parentId = parentId;
+ }
+ //4銆佷繚瀛樻搷浣�
+ platformClientUtil.getFrameworkService().saveDepartment(
+ info,
+ userEntityInfo
+ );
+ } catch (PLException e) {
+ e.printStackTrace();
+ throw new VciBaseException("淇濆瓨鏃跺嚭鐜伴敊璇紒锛屽師鍥狅細"+VciBaseUtil.getExceptionMessage(e));
+ }
+ });
+ }catch (Exception e){
+ if(logger.isErrorEnabled()){
+ logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨閮ㄩ棬鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",e.getMessage());
+ }
+ e.printStackTrace();
+ return BaseResult.fail(LangBaseUtil.getErrorMsg(e),new String[]{},e);
+ }
+ return BaseResult.success("閮ㄩ棬瀵煎叆鎴愬姛锛�");
+ }
+
+ /**
+ * 鑾峰彇鎵�鏈夐儴闂ㄧ殑淇℃伅
+ * @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);
+ map.put(key, orgDepartmentVO);
+ }
+ return map;
+ }
+
+ private String buildKey(OrgDepartmentVO orgDepartmentVO, List<OrgDepartmentVO> orgDepartmentVOList) {
+ StringBuilder keyBuilder = new StringBuilder();
+ OrgDepartmentVO current = orgDepartmentVO;
+ while (current != null) {
+ keyBuilder.insert(0, current.getName());
+ keyBuilder.insert(0, "/");
+ current = getParentDepartment(current.getPkFatherDepartment(), orgDepartmentVOList);
+ }
+ keyBuilder.deleteCharAt(0);
+ return keyBuilder.toString();
+ }
+
+ private OrgDepartmentVO getParentDepartment(String pkFatherDepartment, List<OrgDepartmentVO> orgDepartmentVOList) {
+ for (OrgDepartmentVO orgDepartmentVO : orgDepartmentVOList) {
+ if (pkFatherDepartment != null && pkFatherDepartment.equals(orgDepartmentVO.getOid())) {
+ return orgDepartmentVO;
+ }
+ }
+ return null;
+ }
+
}
--
Gitblit v1.9.3