lyhzzz 2 年之前
父节点
当前提交
4da8935fad

+ 2 - 0
src/main/java/com/fdkankan/fusion/service/ITmDepartmentService.java

@@ -34,4 +34,6 @@ public interface ITmDepartmentService extends IService<TmDepartment> {
     List<TmDepartment> getSonByDeptId(String deptId);
 
     HashMap<String, TmDepartment> getMapByDeptIds(Set<String> deptIdSet);
+
+    List<String> getByZdDeptIds();
 }

+ 19 - 0
src/main/java/com/fdkankan/fusion/service/impl/TmDepartmentServiceImpl.java

@@ -152,6 +152,25 @@ public class TmDepartmentServiceImpl extends ServiceImpl<ITmDepartmentMapper, Tm
     }
 
     @Override
+    public List<String> getByZdDeptIds() {
+        String deptId = this.getDeptId();
+        String zdDeptId = this.getZdDeptId(deptId);
+        List<TmDepartment> deptList = this.getSonByDeptId(zdDeptId);
+        return deptList.stream().map(TmDepartment::getId).collect(Collectors.toList());
+    }
+
+    private String getZdDeptId(String deptId) {
+        TmDepartment tmDepartment = this.getById(deptId);
+        if(tmDepartment == null){
+            throw new BusinessException(ResultCode.NOT_DEPT.code,ResultCode.NOT_DEPT.msg +":"+deptId);
+        }
+        if(tmDepartment.getDeptType()==1 ){
+            return tmDepartment.getId();
+        }
+        return getZdDeptId(tmDepartment.getParentId());
+    }
+
+    @Override
     public List<String> getDeptIds() {
         List<String> Ids = new ArrayList<>();
         List<TmDepartment> deptList = this.getDeptList();

+ 8 - 9
src/main/java/com/fdkankan/fusion/service/impl/TmProjectServiceImpl.java

@@ -30,10 +30,7 @@ import org.springframework.util.CollectionUtils;
 
 import java.net.URLEncoder;
 import java.time.LocalDateTime;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -64,15 +61,17 @@ public class TmProjectServiceImpl extends ServiceImpl<ITmProjectMapper, TmProjec
     public Object pageList(ProjectRequestDto tmProject) {
         LambdaQueryWrapper<TmProject> wrapper = new LambdaQueryWrapper<>();
         //教学场景
+        List<String> deptIds;
         if(tmProject.getQueryType() == 2){
             wrapper.eq(TmProject::getIsTeached,1);
+            deptIds = tmDepartmentService.getByZdDeptIds();
         }else {
-            List<String> deptIds = tmDepartmentService.getDeptIds();
-            if(deptIds.size() <=0){
-                throw new BusinessException(ResultCode.NOT_DEPT);
-            }
-            wrapper.in(TmProject::getDeptId,deptIds);
+            deptIds = tmDepartmentService.getDeptIds();
+        }
+        if(deptIds.size() <=0){
+            throw new BusinessException(ResultCode.NOT_DEPT);
         }
+        wrapper.in(TmProject::getDeptId,deptIds);
         //起火项目对象
         if(StringUtils.isNotBlank(tmProject.getProjectSn())){
             wrapper.like(TmProject::getProjectSn , tmProject.getProjectSn());