Browse Source

领导发布批示留言时,领导秘书收到领导批示消息

wanyuan 8 months ago
parent
commit
6b2661fed5

+ 28 - 2
tc-service/tap-task/src/main/java/com/minto/app/task/manager/TaskManagerImpl.java

@@ -1140,8 +1140,12 @@ public class TaskManagerImpl implements ITaskManager {
 						List<TaskMemberBean> list = mems.stream().filter(e -> Integer.valueOf(
 								TaskMemberRelTypeEnum.Supervise.getKey()).equals(e.getRelationType())).toList();
 						setPids.addAll(getMemberPersonIds(list));
-						//todo 领导秘书收到领导批示消息
-					}else{
+						//领导秘书收到领导批示消息
+						List<Long> secretaryPersonIds = findSecretaryPersonIds(null, List.of(process.getPersonId()));
+						if(CollectionUtil.isNotEmpty(secretaryPersonIds)){
+							setPids.addAll(secretaryPersonIds);
+						}
+					} else{
 						setPids.addAll(getMemberPersonIds(mems));
 					}
 					pids = new ArrayList<Long>();
@@ -1228,6 +1232,28 @@ public class TaskManagerImpl implements ITaskManager {
 		}
 	}
 
+	/**
+	 * 获取某人的秘书
+	 *
+	 * @param cid
+	 * @param pids
+	 * @return
+	 */
+	private List<Long> findSecretaryPersonIds(Long cid, List<Long> pids){
+		if(CollectionUtil.isEmpty(pids)){
+			return new ArrayList<>();
+		}
+		Criterion criterion =
+				pids.size() > 1 ? Restrictions.in("sourceId", pids) : Restrictions.eq("sourceId", pids.get(0));
+		criterion = Restrictions.and(criterion,
+				Restrictions.eq("targetCategory", ResourceEnum.ResourceTypeEnum.OrgPerson.getKey()));
+		criterion = Restrictions.and(criterion,
+				Restrictions.eq("relationCategory", com.minto.app.organization.OrgEnum.OrgRelationCategoryEnum.Secretary.getKey()));
+		IOrgManager orgManager = AppContext.getBean(IOrgManager.class);
+		List<OrgRelationBean> relationBeanList = orgManager.findOrgRelation(criterion, cid);
+		return relationBeanList.stream().map(OrgRelationBean::getTargetId).toList();
+	}
+
 	private Set<Long> getMemberPersonIds(List<TaskMemberBean> mems){
 		Set<Long> setPids = new HashSet<Long>();
 		// 查询扩展角色 Modifier: <Zhengyu.Hu> 2018/8/21 下午2:19 end.