|
|
@@ -1,11 +1,8 @@
|
|
|
package com.lc.ibps.org.provider;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.Map.Entry;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
@@ -818,7 +815,63 @@ public class PartyPositionProvider extends GenericProvider implements IPartyPosi
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取岗位树", notes = "获取岗位树,\n"
|
|
|
+ + "当type的value为0且posId没有值的时候,则返回系统内所有部门的信息\n"
|
|
|
+ + "当type的value为0且posId有值的时候,则返回posId本级及其下属所有的部门信息\n"
|
|
|
+ + "超级管理员可查看所有组织,普通用户默认查询本组织部门信息"
|
|
|
+ + "参数QA^key,Object,对应参与者属性"
|
|
|
+ )
|
|
|
+ @Override
|
|
|
+ public APIResult<List<PartyEntityTreePo>> findAllPosition(
|
|
|
+ @ApiParam(name = "request", value = "传入查询请求json字符串", required = true)
|
|
|
+ @RequestBody(required = true) APIRequest request) {
|
|
|
+ APIResult<List<PartyEntityTreePo>> result = new APIResult<>();
|
|
|
+ List<PartyEntityTreePo> groupTreeList = new ArrayList<>();
|
|
|
+ try{
|
|
|
+ String postId = RequestUtil.getString(request, "posId");
|
|
|
+ if(ContextUtil.isSuper()){
|
|
|
+ groupTreeList = partyEntityRepository.findAllPosition("position",postId,"");
|
|
|
+ }else {
|
|
|
+ // 查询本岗位数据
|
|
|
+ String userId = ContextUtil.getCurrentUserId();
|
|
|
+ PartyEmployeePo partyEmployee = partyEmployeeRepository.get(userId);
|
|
|
+ if (BeanUtils.isNotEmpty(partyEmployee) && StringUtil.isNotBlank(partyEmployee.getPositions())) {
|
|
|
+ String position = partyEmployee.getPositions().split(",")[0];
|
|
|
+ PartyEntityPo entityPo = partyEntityRepository.get(position);
|
|
|
+ String path3 = entityPo.getPath().split(StringPool.BACK_SLASH+StringPool.DOT)[2];
|
|
|
+ groupTreeList = partyEntityRepository.findAllPosition("position","","%"+path3+"%");
|
|
|
+ if (BeanUtils.isNotEmpty(groupTreeList)){
|
|
|
+ List<PartyEntityTreePo> entityTreeList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < groupTreeList.size(); i++) {
|
|
|
+ PartyEntityTreePo bean = groupTreeList.get(i);
|
|
|
+ if (bean.getDepth() ==3){
|
|
|
+ this.getPosition(bean.getParentId(),entityTreeList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ groupTreeList.addAll(entityTreeList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<PartyEntityTreePo> filteredList = groupTreeList.stream()
|
|
|
+ .filter(Objects::nonNull) // 使用Objects.nonNull方法过滤掉null
|
|
|
+ .collect(Collectors.toList()); // 收集过滤后的元素到新的List中
|
|
|
+ result.setData(PartyUtil.unique(filteredList));
|
|
|
+ }catch (Exception e){
|
|
|
+ setExceptionResult(result, StateEnum.ERROR_POSITION.getCode(), I18nUtil.getMessage(StateEnum.ERROR_POSITION.getCode()+""), e);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void getPosition(String parentId,List<PartyEntityTreePo> groupTreeList ){
|
|
|
+ PartyEntityPo entity = partyEntityRepository.get(parentId);
|
|
|
+ if (!"0".equals(parentId)){
|
|
|
+ getPosition(entity.getParentId(),groupTreeList);
|
|
|
+ }
|
|
|
+ groupTreeList.add(PartyEntityTreeBuilder.build(entity));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private List<String> findByAttrKeyValue(Map<String, Object> map, String partyType) {
|
|
|
PartyParamsValidator.paramValidateObject(map, "参数为空");
|
|
|
List<String> entitys = PartyUtil.getIds(partyEntityRepository.findByPartyType(partyType));
|