|
|
@@ -915,23 +915,22 @@ public class CommonScript extends BaseScript {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- List<String> result = new ArrayList<String>();
|
|
|
- if (flag){
|
|
|
- // 如果有,那么function就返回该登录账号同地点下所有部门的id
|
|
|
- result = findPositionId();
|
|
|
- }else {
|
|
|
- // 如果没有,那么function就返回该登录账号所属部门以及下属部门的id
|
|
|
- result = findPositionChild();
|
|
|
- }
|
|
|
- return result;
|
|
|
+ return findPositionChild(flag);
|
|
|
}
|
|
|
|
|
|
- public List<String> findPositionChild() {
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * 如果isAllPos = ture,那么function就返回该登录账号同地点下所有部门的id
|
|
|
+ * 如果isAllPos = false,那么function就返回该登录账号所属部门以及下属部门的id
|
|
|
+ * @param isAllPos
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<String> findPositionChild(boolean isAllPos) {
|
|
|
List<String> result = new ArrayList<String>();
|
|
|
//或取当前的岗位
|
|
|
List<String> ids = findCurrentUserPositionIds(false);
|
|
|
|
|
|
- String[] pkArray = ids.toArray(new String[ids.size()]);
|
|
|
+ List<String> pkList = new ArrayList<>();
|
|
|
//find all position nodes
|
|
|
APIResult<List<PartyEntityTreePo>> tree = PartyUtil.findAllPositions();
|
|
|
if(!tree.isSuccess()) {
|
|
|
@@ -941,6 +940,16 @@ public class CommonScript extends BaseScript {
|
|
|
List<PartyEntityTreePo> treeData = tree.getData();
|
|
|
//remove root node
|
|
|
treeData = treeData.stream().filter(x -> !x.getId().equals(StringPool.ZERO)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if(isAllPos){
|
|
|
+ PartyEntityTreePo treePo = treeData.stream().filter(x -> StringUtils.containsAny(x.getPath(), ids.toArray(new String[ids.size()])))
|
|
|
+ .findAny().orElse(null);
|
|
|
+ pkList.add(treePo.getPath().split("\\.")[0]);
|
|
|
+
|
|
|
+ }else{
|
|
|
+ pkList = ids;
|
|
|
+ }
|
|
|
+ String[] pkArray = pkList.toArray(new String[pkList.size()]);
|
|
|
//get child
|
|
|
List<String> posWithChild = treeData.stream().filter(x -> StringUtils.containsAny(x.getPath(), pkArray))
|
|
|
.map(PartyEntityTreePo::getId)
|