Prechádzať zdrojové kódy

pms 生产运营会议 项目部人员登录系统查询数据

zhangcl 3 dní pred
rodič
commit
5ebd21d842

+ 28 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotoperationmeeting/IotOperationMeetingServiceImpl.java

@@ -401,6 +401,30 @@ public class IotOperationMeetingServiceImpl implements IotOperationMeetingServic
         return projectNames;
     }
 
+    /**
+     * 从指定部门出发,向上查找类型为"1"(公司)的部门ID。
+     * 如果当前部门就是公司则直接返回;否则循环查找父级,直到找到公司或达到上限。
+     * 若始终找不到公司,则返回原部门的ID。
+     */
+    private Long findCompanyDeptId(DeptDO dept) {
+        if ("1".equals(dept.getType())) {
+            return dept.getId();
+        }
+
+        DeptDO current = dept;
+        int maxLevel = 10; // 防止意外的循环引用
+        while (current != null && !"1".equals(current.getType())
+                && current.getParentId() != null && maxLevel-- > 0) {
+            current = deptservice.getDept(current.getParentId());
+        }
+
+        if (current != null && "1".equals(current.getType())) {
+            return current.getId();
+        }
+        // 找不到公司时,保持与原逻辑一致,返回当前部门的ID
+        return dept.getId();
+    }
+
     @Override
     public IotOperationMeetingDetailRespVO previousWorkPlan(IotOperationMeetingDetailPageReqVO pageReqVO) {
         // 填报运营会议明细时查询上期填写的工作计划
@@ -1231,8 +1255,11 @@ public class IotOperationMeetingServiceImpl implements IotOperationMeetingServic
         if (ObjUtil.isEmpty(dept)) {
             throw exception(DEPT_NOT_FOUND);
         }
+        // 向上查找所属公司ID(类型为"1"的部门),找不到则保留当前部门ID
+        Long companyDeptId = findCompanyDeptId(dept);
+
         IotOperationMeetingAttrsPageReqVO reqVO = new IotOperationMeetingAttrsPageReqVO();
-        reqVO.setDeptId(dept.getId());
+        reqVO.setDeptId(companyDeptId);
         reqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
         PageResult<IotOperationMeetingAttrsDO> pageAttrs = iotOperationMeetingAttrsMapper.selectPage(reqVO);
         if (ObjUtil.isEmpty(pageAttrs)) {