|
@@ -889,6 +889,65 @@ public class CommonScript extends BaseScript {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据角色别名查询(会存在有多个角色的情况,英文逗号分隔)eg: gly,jyy
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param roleAlias
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public List<String> findPositionIdByRole(String roleAlias) {
|
|
|
|
|
+ String userId = currentContext.getCurrentUserId();
|
|
|
|
|
+ // 根据当前用户查询该用户所有角色信息
|
|
|
|
|
+ List<DefaultPartyRolePo> rolePos = PartyUtil.findRoleByUserId(userId);
|
|
|
|
|
+ List<String> roleParam = Arrays.asList(roleAlias.split(","));
|
|
|
|
|
+ // 判断 rolePos 是否都包含 roleAlias
|
|
|
|
|
+ boolean flag = true;
|
|
|
|
|
+ for (String param : roleParam) {
|
|
|
|
|
+ boolean exists = false;
|
|
|
|
|
+ for (DefaultPartyRolePo role : rolePos) {
|
|
|
|
|
+ if (param.equals(role.getRoleAlias())) {
|
|
|
|
|
+ exists = true;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!exists) {
|
|
|
|
|
+ flag = false;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ List<String> result = new ArrayList<String>();
|
|
|
|
|
+ if (flag){
|
|
|
|
|
+ // 如果有,那么function就返回该登录账号同地点下所有部门的id
|
|
|
|
|
+ result = findPositionId();
|
|
|
|
|
+ }else {
|
|
|
|
|
+ // 如果没有,那么function就返回该登录账号所属部门以及下属部门的id
|
|
|
|
|
+ result = findPositionChild();
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public List<String> findPositionChild() {
|
|
|
|
|
+ List<String> result = new ArrayList<String>();
|
|
|
|
|
+ //或取当前的岗位
|
|
|
|
|
+ List<String> ids = findCurrentUserPositionIds(false);
|
|
|
|
|
+
|
|
|
|
|
+ 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;
|
|
|
|
|
+ }
|
|
|
|
|
+ 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());
|
|
|
|
|
+ return posWithChild;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public List<String> findEmployees() {
|
|
public List<String> findEmployees() {
|
|
|
try {
|
|
try {
|
|
|
List<PartyPositionPo> posByUserId = PartyUtil.findPosByUserId(currentContext.getCurrentUserId());
|
|
List<PartyPositionPo> posByUserId = PartyUtil.findPosByUserId(currentContext.getCurrentUserId());
|