Browse Source

区长书记、区领导的秘书可以看对应领导的批示留言数据

wanyuan 8 months ago
parent
commit
ec8c69a7c7
1 changed files with 56 additions and 3 deletions
  1. 56 3
      tip-front/src/main/java/com/minto/app/task/util/TaskKaizhouUtil.java

+ 56 - 3
tip-front/src/main/java/com/minto/app/task/util/TaskKaizhouUtil.java

@@ -29,6 +29,8 @@ import com.minto.tip.common.exceptions.BusinessException;
 import com.minto.tip.common.util.ApplicationContextHolder;
 import com.minto.tip.organization.enums.RelationValueName;
 import org.apache.commons.lang.ObjectUtils;
+import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.Restrictions;
 import org.jbpm.JbpmContext;
 import org.jbpm.taskmgmt.exe.TaskInstance;
 import org.slf4j.LoggerFactory;
@@ -112,7 +114,16 @@ public final class TaskKaizhouUtil{
                 showIds.addAll(list.stream().filter(e -> userId.equals(e.getBelongToResId())).map(BehSummaryBean::getId)
                                    .toList());
             }
-            //优先级2:根据公布范围设置可以看的区长书记、区领导发布的批示Id
+            //优先级2:区长书记、区领导的秘书可以看对应领导的批示留言数据
+            List<Long> leaderPersonIdsBySecretary = TaskKaizhouUtil.findLeaderPersonIds(null, List.of(userId));
+            List<Long> leaderPersonIds = TaskKaizhouUtil.findShuJiQuZhangQuLingDaoPersonIds();
+            if(CollectionUtil.isNotEmpty(leaderPersonIdsBySecretary)){
+                List<Long> list1 = leaderPersonIdsBySecretary.stream().filter(leaderPersonIds::contains).toList();
+                showIds.addAll(
+                        list.stream().filter(e -> list1.contains(e.getBelongToResId())).map(BehSummaryBean::getId)
+                            .toList());
+            }
+            //优先级3:根据公布范围设置可以看的区长书记、区领导发布的批示Id
             ITaskManager taskManager = AppContext.getBean(ITaskManager.class);
             List<Long> processIds = taskManager.findTaskProcessVisibilityRunTime(taskId, userId);
             if(CollectionUtil.isNotEmpty(processIds)){
@@ -120,9 +131,8 @@ public final class TaskKaizhouUtil{
                 showIds.addAll(
                         list.stream().filter(e -> ext1Strs.contains(e.getExt1())).map(BehSummaryBean::getId).toList());
             }
-            //优先级3:流程参与人员不能看区长书记、区领导批示留言数据
+            //优先级4:流程参与人员不能看区长书记、区领导批示留言数据
             if(TaskKaizhouUtil.isNodeManager(taskMemberBeans, currentMemberBeans, userId)){
-                List<Long> leaderPersonIds = TaskKaizhouUtil.findShuJiQuZhangQuLingDaoPersonIds();
                 showIds.addAll(list.stream().filter(e -> !(
                                            ResourceEnum.ResourceTypeEnum.OrgPerson.getKey() == e.getBelongToResType()
                                                    && leaderPersonIds.contains(e.getBelongToResId()))).map(BehSummaryBean::getId)
@@ -250,4 +260,47 @@ public final class TaskKaizhouUtil{
 
         return nodeBO;
     }
+    /**
+     * 获取某人的秘书
+     *
+     * @param cid
+     * @param pids
+     * @return
+     */
+    public static 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", OrgEnum.OrgRelationCategoryEnum.Secretary.getKey()));
+        IOrgManager orgManager = AppContext.getBean(IOrgManager.class);
+        List<OrgRelationBean> relationBeanList = orgManager.findOrgRelation(criterion, cid);
+        return relationBeanList.stream().map(OrgRelationBean::getTargetId).toList();
+    }
+
+    /**
+     * 获取某人作为哪些领导的秘书
+     * @param cid
+     * @param pids
+     * @return
+     */
+    public static List<Long> findLeaderPersonIds(Long cid, List<Long> pids){
+        if(CollectionUtil.isEmpty(pids)){
+            return new ArrayList<>();
+        }
+        Criterion criterion =
+                pids.size() > 1 ? Restrictions.in("targetId", pids) : Restrictions.eq("targetId", pids.get(0));
+
+        criterion = Restrictions.and(criterion,
+                Restrictions.eq("targetCategory", ResourceEnum.ResourceTypeEnum.OrgPerson.getKey()));
+        criterion = Restrictions.and(criterion,
+                Restrictions.eq("relationCategory", OrgEnum.OrgRelationCategoryEnum.Secretary.getKey()));
+        IOrgManager orgManager = AppContext.getBean(IOrgManager.class);
+        List<OrgRelationBean> relationBeanList = orgManager.findOrgRelation(criterion, cid);
+        return relationBeanList.stream().map(OrgRelationBean::getSourceId).toList();
+    }
 }