Explorar o código

[bug-606] 操作日志不应该看到其他医院的log
[bug-607] 修改cscript.findPositionId()只能放在过滤列表最后的bug

Li Yuan %!s(int64=2) %!d(string=hai) anos
pai
achega
45a995256a

+ 2 - 2
ibps-common-root/modules/org-biz/src/main/java/com/lc/ibps/org/party/repository/PartyEmployeeRepository.java

@@ -31,7 +31,7 @@ public interface PartyEmployeeRepository extends IRepository<String, PartyEmploy
 	 * @return
 	 */
 	public List<PartyEmployeePo> getEmployeeByPosition(QueryFilter queryFilter,String position);
-	
+	public List<PartyEmployeePo> getEmployeeIdsByPosition(String position);
 	/**
 	 * 获取员工信息附带组织名称
 	 *
@@ -98,7 +98,7 @@ public interface PartyEmployeeRepository extends IRepository<String, PartyEmploy
 	/**
 	 * 获取未分配组织员工信息
 	 *
-	 * @param queryFilter
+	 * @param
 	 * @return 
 	 */
 	public List<PartyEmployeePo> findWoutOrg();

+ 5 - 0
ibps-common-root/modules/org-biz/src/main/java/com/lc/ibps/org/party/repository/impl/PartyEmployeeRepositoryImpl.java

@@ -219,6 +219,11 @@ public class PartyEmployeeRepositoryImpl extends AbstractRepository<String, Part
 		return queryByKey("findByPosition", "findIdsByPositionId", queryFilter);
 	}
 
+	@Override
+	public List<PartyEmployeePo> getEmployeeIdsByPosition(String position) {
+		return findByKey("findIdsByPositionId", "", b().a("position", "%" + position + "%").p());
+	}
+
     @Override
     public List<PartyEmployeeVo> loadEmployees(String sourceTenantId, List<String> accounts) {
     	List<PartyEmployeeVo> employees = new ArrayList<>();

+ 3 - 1
ibps-component-root/modules/comp-querybuilder/src/main/java/com/lc/ibps/components/querybuilder/support/parser/sql/FindInSetRuleParser.java

@@ -35,6 +35,8 @@ public class FindInSetRuleParser extends AbstractSqlRuleParser {
         }else{
             operate.append("("+rule.getField() + " like '%%' )");
         }
-        return new Operation(operate, rule.getValue());
+        Operation operation = new Operation(operate, rule.getValue());
+        operation.setHasValue(false);
+        return operation;
     }
 }

+ 38 - 31
ibps-excessive-root/modules/platform-excessive/src/main/java/com/lc/ibps/platform/script/script/CommonScript.java

@@ -1,17 +1,14 @@
 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.Stream;
 
 import javax.annotation.Resource;
 
+import com.lc.ibps.org.party.persistence.entity.*;
 import com.lc.ibps.org.vo.PartyEntityAttrVo;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 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.cloud.entity.APIResult;
 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.PartyUtil;
 
@@ -861,7 +852,7 @@ public class CommonScript extends BaseScript {
 
 	/**
 	 * 脚本获取用户的岗位ID 只能用于in 或者 not in 在。。之内和 不在。。之内
-	 * cscript.findPositionId(true/false)
+	 * cscript.findPositionId()
 	 *
 	 * @param ,true:是/false:所有岗位
 	 * @return List<String>
@@ -870,28 +861,44 @@ public class CommonScript extends BaseScript {
 		List<String> result = new ArrayList<String>();
 		//或取当前的岗位
 		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;
 		}
-		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;
 	}
 
+	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()
 	 * 

+ 15 - 4
ibps-excessive-root/modules/platform-excessive/src/main/java/com/lc/ibps/platform/script/utils/PartyUtil.java

@@ -4,6 +4,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import com.lc.ibps.api.base.model.PartyEntity;
+import com.lc.ibps.api.org.constant.PartyType;
 import com.lc.ibps.base.core.exception.BaseException;
 import com.lc.ibps.base.core.util.AppUtil;
 import com.lc.ibps.cloud.entity.APIResult;
@@ -12,10 +13,7 @@ import com.lc.ibps.org.api.IPartyEntityService;
 import com.lc.ibps.org.api.IPartyPositionService;
 import com.lc.ibps.org.api.IPartyRelService;
 import com.lc.ibps.org.api.IPartyRoleService;
-import com.lc.ibps.org.party.persistence.entity.DefaultPartyRolePo;
-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.org.party.persistence.entity.*;
 import com.lc.ibps.org.vo.PartyEntityAttrVo;
 
 /**
@@ -233,5 +231,18 @@ public class PartyUtil {
 			throw new BaseException(result.getCause());
 		}
 	}
+
+	public static APIResult<List<PartyEntityTreePo>> findAllPositions(){
+		return  partyEntityService.findTreeByType(PartyType.POSITION.getValue());
+	}
+
+	public static List<String> queryIdsByPositionId(String posId){
+		APIResult<List<String>> result = partyEmployeeService.queryIdsByPositionId(posId);
+		if (result.isSuccess()) {
+			return result.getData();
+		} else {
+			throw new BaseException(result.getCause());
+		}
+	}
 	
 }

+ 12 - 1
ibps-provider-base-root/modules/provider-platform-api/src/main/java/com/lc/ibps/org/api/IPartyEmployeeService.java

@@ -83,7 +83,18 @@ public interface IPartyEmployeeService {
 	@RequestMapping(value = "/queryOrgUser", method = RequestMethod.POST)
 	public APIResult<APIPageList<PartyEmployeePo>> queryOrgUser(
 			@RequestBody(required = true) APIRequest request);
-	
+
+	/**
+	 * 根据岗位ID返回所有员工
+	 *
+	 * @param positionId
+	 * @return
+	 */
+	@RequestMapping(value = "/queryIdsByPositionId", method = RequestMethod.GET)
+	public APIResult<List<String>> queryIdsByPositionId(
+			@NotBlank(message = "{com.lc.ibps.org.provider.PartyEmployeeProvider.employeeId}")
+			@RequestParam(name = "positionId", required = true) String positionId);
+
 	/**
 	 * 
 	 * 根据岗位id和根据扩展属性筛选出来的员工ids查询员工列表

+ 21 - 0
ibps-provider-root/modules/provider-platform-default/src/main/java/com/lc/ibps/org/provider/PartyEmployeeProvider.java

@@ -47,6 +47,7 @@ import com.lc.ibps.org.party.repository.*;
 import com.lc.ibps.org.vo.IdKeyVo;
 import io.swagger.annotations.*;
 import org.apache.commons.lang3.StringUtils;
+import org.hibernate.validator.constraints.NotBlank;
 import org.slf4j.event.Level;
 import org.springframework.stereotype.Service;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -57,6 +58,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import javax.annotation.Resource;
 import java.util.*;
 import java.util.Map.Entry;
+import java.util.stream.Collectors;
 
 /**
  * 员工管理
@@ -161,6 +163,25 @@ public class PartyEmployeeProvider extends GenericProvider implements IPartyEmpl
 		return queryWithOrg(request, UserStatus.DELETED.getValue(), "queryOrgUser");
 	}
 
+	/**
+	 * 根据岗位ID返回所有员工
+	 *
+	 * @param positionId
+	 * @return
+	 */
+	@ApiOperation(value = "员工列表", notes = "根据岗位ID返回所有员工")
+	@Override
+	public APIResult<List<String>> queryIdsByPositionId(
+			@ApiParam(name = "positionId", value = "传入查询请求岗位名", required = true)
+			@NotBlank(message = "{com.lc.ibps.org.provider.PartyEmployeeProvider.employeeId}")
+			@RequestParam(name = "positionId", required = true) String positionId){
+		APIResult<List<String>> result = new APIResult<>();
+		List<PartyEmployeePo> positions = partyEmployeeRepository.getEmployeeIdsByPosition(positionId);
+
+		result.setData(positions.stream().map(PartyEmployeePo::getId).collect(Collectors.toList()));
+		return result;
+	}
+
 	/**
 	 * 
 	 * 根据岗位id和根据拓展属性筛选出来的员工ids查询员工列表