|
@@ -1,17 +1,14 @@
|
|
|
package com.lc.ibps.platform.script.script;
|
|
package com.lc.ibps.platform.script.script;
|
|
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.Date;
|
|
|
|
|
-import java.util.HashSet;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
-import java.util.Set;
|
|
|
|
|
-import java.util.UUID;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
+import com.lc.ibps.org.party.persistence.entity.*;
|
|
|
import com.lc.ibps.org.vo.PartyEntityAttrVo;
|
|
import com.lc.ibps.org.vo.PartyEntityAttrVo;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
@@ -33,12 +30,6 @@ import com.lc.ibps.base.web.json.PageJson;
|
|
|
import com.lc.ibps.bpmn.api.model.identity.BpmIdentity;
|
|
import com.lc.ibps.bpmn.api.model.identity.BpmIdentity;
|
|
|
import com.lc.ibps.cloud.entity.APIResult;
|
|
import com.lc.ibps.cloud.entity.APIResult;
|
|
|
import com.lc.ibps.org.api.IPartyAttrService;
|
|
import com.lc.ibps.org.api.IPartyAttrService;
|
|
|
-import com.lc.ibps.org.party.persistence.entity.DefaultPartyRolePo;
|
|
|
|
|
-import com.lc.ibps.org.party.persistence.entity.PartyAttrPo;
|
|
|
|
|
-import com.lc.ibps.org.party.persistence.entity.PartyAttrValuePo;
|
|
|
|
|
-import com.lc.ibps.org.party.persistence.entity.PartyEmployeePo;
|
|
|
|
|
-import com.lc.ibps.org.party.persistence.entity.PartyEntityPo;
|
|
|
|
|
-import com.lc.ibps.org.party.persistence.entity.PartyPositionPo;
|
|
|
|
|
import com.lc.ibps.platform.script.utils.BpmnUtil;
|
|
import com.lc.ibps.platform.script.utils.BpmnUtil;
|
|
|
import com.lc.ibps.platform.script.utils.PartyUtil;
|
|
import com.lc.ibps.platform.script.utils.PartyUtil;
|
|
|
|
|
|
|
@@ -861,7 +852,7 @@ public class CommonScript extends BaseScript {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 脚本获取用户的岗位ID 只能用于in 或者 not in 在。。之内和 不在。。之内
|
|
* 脚本获取用户的岗位ID 只能用于in 或者 not in 在。。之内和 不在。。之内
|
|
|
- * cscript.findPositionId(true/false)
|
|
|
|
|
|
|
+ * cscript.findPositionId()
|
|
|
*
|
|
*
|
|
|
* @param ,true:是/false:所有岗位
|
|
* @param ,true:是/false:所有岗位
|
|
|
* @return List<String>
|
|
* @return List<String>
|
|
@@ -870,28 +861,44 @@ public class CommonScript extends BaseScript {
|
|
|
List<String> result = new ArrayList<String>();
|
|
List<String> result = new ArrayList<String>();
|
|
|
//或取当前的岗位
|
|
//或取当前的岗位
|
|
|
List<String> ids = findCurrentUserPositionIds(false);
|
|
List<String> ids = findCurrentUserPositionIds(false);
|
|
|
- //依据当前的岗位查到entity表中所有的下级
|
|
|
|
|
- List<PartyEntityPo> list = PartyUtil.findPositionId(ids); //当前岗位下的所有下级
|
|
|
|
|
- //依据当前的岗位查到entity表中id=当前的岗位的一条数据
|
|
|
|
|
- //再切除这条数据的最后一个
|
|
|
|
|
- //将前面的所有id都查出来
|
|
|
|
|
- //查出当前岗位的所有上级
|
|
|
|
|
- List<PartyEntityPo> po = PartyUtil.findId(ids);
|
|
|
|
|
- for (PartyEntityPo partyEntitypo : po) {
|
|
|
|
|
- result.add(partyEntitypo.getId());
|
|
|
|
|
- }
|
|
|
|
|
- if (BeanUtils.isEmpty(list)) {
|
|
|
|
|
- result.add("0"); // 标识不存在数据
|
|
|
|
|
|
|
+
|
|
|
|
|
+ String[] pkArray = ids.toArray(new String[ids.size()]);
|
|
|
|
|
+ //find all position nodes
|
|
|
|
|
+ APIResult<List<PartyEntityTreePo>> tree = PartyUtil.findAllPositions();
|
|
|
|
|
+ if(!tree.isSuccess()) {
|
|
|
|
|
+ result.add("0");
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
- for (PartyEntityPo partyEntitypo : list) {
|
|
|
|
|
- result.add(partyEntitypo.getId());
|
|
|
|
|
- }
|
|
|
|
|
- //去除重复元素
|
|
|
|
|
- result.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
|
|
+ List<PartyEntityTreePo> treeData = tree.getData();
|
|
|
|
|
+ //remove root node
|
|
|
|
|
+ treeData = treeData.stream().filter(x -> !x.getId().equals(StringPool.ZERO)).collect(Collectors.toList());
|
|
|
|
|
+ //get child
|
|
|
|
|
+ List<String> posWithChild = treeData.stream().filter(x -> StringUtils.containsAny(x.getPath(), pkArray))
|
|
|
|
|
+ .map(PartyEntityTreePo::getId)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ //get parent nodes
|
|
|
|
|
+ List<String> posWithParent = treeData.stream().filter(x -> StringUtils.containsAny(x.getId(), pkArray))
|
|
|
|
|
+ .flatMap(y -> Arrays.stream(y.getPath().split("\\.",0)))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ //combine and distinct
|
|
|
|
|
+ result = Stream.of(posWithChild, posWithParent)
|
|
|
|
|
+ .flatMap(Collection::stream)
|
|
|
|
|
+ .distinct()
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public List<String> findEmployees() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ List<PartyPositionPo> posByUserId = PartyUtil.findPosByUserId(currentContext.getCurrentUserId());
|
|
|
|
|
+ String rootPos = posByUserId.get(0).getPath().split("\\.")[0];
|
|
|
|
|
+ return PartyUtil.queryIdsByPositionId(rootPos);
|
|
|
|
|
+ } catch (Exception ignore) {
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 脚本判断当前用户是否部门负责人 cscript.isOrgManager()
|
|
* 脚本判断当前用户是否部门负责人 cscript.isOrgManager()
|
|
|
*
|
|
*
|