Ver Fonte

[task-1499]补充/position/findTreeData的数据返回

szjbdgzl há 2 anos atrás
pai
commit
5a4ef0ec44

+ 8 - 0
ibps-common-root/modules/org-biz/src/main/java/com/lc/ibps/org/party/repository/PartyEntityRepository.java

@@ -72,6 +72,14 @@ public interface PartyEntityRepository extends IRepository<String, PartyEntityPo
 	 * @return
 	 */
 	public List<PartyEntityTreePo> findTreeByTypePid(String type, String pid, boolean needRoot, boolean needParent, boolean needSub);
+
+	/**
+	 * 查询所有岗位信息
+	 * @param type
+	 * @param pid
+	 * @return
+	 */
+	public List<PartyEntityTreePo> findAllPosition(String type, String pid,String path);
 	
 	/**
 	 * 

+ 8 - 1
ibps-common-root/modules/org-biz/src/main/java/com/lc/ibps/org/party/repository/impl/PartyEntityRepositoryImpl.java

@@ -275,7 +275,14 @@ public class PartyEntityRepositoryImpl extends AbstractRepository<String, PartyE
 		
 		return groupTreeList;
 	}
-	
+
+	@Override
+	public List<PartyEntityTreePo> findAllPosition(String type, String pid,String path) {
+		List<PartyEntityPo> poList = findByKey("findAllPosition", "findAllPosition",
+				b().a("partyType", type).a("pid", pid).a("path",path).p());
+		return new ArrayList<>(PartyEntityTreeBuilder.build(poList));
+	}
+
 	@Override
 	public List<PartyEntityTreePo> getTreeByTypeAndPid(String type, String pid, boolean needRoot) {
 		List<PartyEntityTreePo> groupTreeList = new ArrayList<PartyEntityTreePo>();

+ 13 - 0
ibps-model-root/modules/org-model/src/main/resources/com/lc/ibps/org/party/persistence/mapping/PartyEntity.map.xml

@@ -230,6 +230,19 @@
 		order by e.SN_ ASC,e.CREATE_TIME_ asc
 	</select>
 
+	<select id="findAllPosition" parameterType="java.util.Map" resultMap="PartyEntity">
+		select e.*,o.NAME_ from IBPS_PARTY_ENTITY e
+		INNER JOIN IBPS_PARTY_POSITION o on e.ID_=o.ID_
+		and e.PARTY_TYPE_=#{partyType}
+		<if test="@o.Ognl@isNotEmpty(pid)">
+			and e.PARENT_ID_ = #{pid}
+		</if>
+		<if test="@o.Ognl@isNotEmpty(path)">
+			and e.PATH_ like #{path}
+		</if>
+		order by e.PATH_
+	</select>
+
 	<select id="findRootPosIdsByTypeAndPid" parameterType="java.util.Map" resultMap="PartyEntity">
 		select e.ID_,e.SN_,e.CREATE_TIME_ from IBPS_PARTY_ENTITY e 
 		INNER JOIN IBPS_PARTY_POSITION o on e.ID_=o.ID_

+ 8 - 0
ibps-provider-base-root/modules/provider-platform-api/src/main/java/com/lc/ibps/org/api/IPartyPositionService.java

@@ -346,4 +346,12 @@ public interface IPartyPositionService {
 	@RequestMapping(value = "/findTreeData", method = { RequestMethod.POST })
 	public APIResult<List<PartyEntityTreePo>> findTreeData(
 			@RequestBody(required = true) APIRequest request);
+
+	/**
+	 * 获取所有岗位
+	 * @return
+	 */
+	@RequestMapping(value = "/findAllPosition", method = { RequestMethod.POST })
+	public APIResult<List<PartyEntityTreePo>> findAllPosition(
+			@RequestBody(required = true) APIRequest request);
 }

+ 59 - 6
ibps-provider-root/modules/provider-platform-default/src/main/java/com/lc/ibps/org/provider/PartyPositionProvider.java

@@ -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));