فهرست منبع

fix: my task page

Blizzard 1 سال پیش
والد
کامیت
158debe05c

+ 0 - 1
blade-service/wutong-okr/src/main/java/com/wtkj/controller/CommonController.java

@@ -58,5 +58,4 @@ public class CommonController {
 
 	}
 
-
 }

+ 57 - 5
blade-service/wutong-okr/src/main/java/com/wtkj/service/impl/CommonServiceImpl.java

@@ -262,20 +262,72 @@ public class CommonServiceImpl implements ICommonService {
 	@Override
 	public IPage<FileAndFolder> esSearch(SearchProjectFileDTO dto, IPage<FileAndFolder> page) {
 		IPage<FileAndFolder> res = new Page<>();
-		Long deptId = dto.getTopDeptId();
+		Long topDept = dto.getTopDeptId();
 		String text = dto.getText();
 		Long projectId = dto.getProjectId();
 		Long createUser = dto.getCreateUser();
 		Set<Long> projectIds = new HashSet<>();
+		Set<String> proIds = new HashSet<>();
 		if (projectId != null && projectId > 0L) {
 			projectIds.add(projectId);
+			proIds.add(String.valueOf(projectId));
 		} else {
 			//如果projectId为空 则查询机构下所有项目
 			//此机构下的项目
-			List<ProjectAuth> auths = projectAuthService.getByDeptAndUser(deptId, null, AuthUtil.getUserId());
+			/*List<ProjectAuth> auths = projectAuthService.getByDeptAndUser(topDept, Func.firstLong(AuthUtil.getDeptId()), null);
 			if (!CollectionUtils.isEmpty(auths)) {
 				Set<Long> ids = auths.stream().map(ProjectAuth::getProjectId).filter(Objects::nonNull).collect(Collectors.toSet());
 				projectIds.addAll(ids);
+			}*/
+
+			String role = AuthUtil.getUserRole();
+			Long deptId = Func.firstLong(AuthUtil.getDeptId());
+			Long userId = AuthUtil.getUserId();
+			//1.2 是服务机构
+			if (role != null) {
+				if (role.contains(STAFF_ADMIN)) {
+					// 1.2.1 机构管理员 ---> 项目权限表里 topDept 字段是自己的集合
+					List<ProjectAuth> auths = projectAuthService.getByDeptAndUser(topDept, null, null);
+					if (!CollectionUtils.isEmpty(auths)) {
+						Set<Long> ids = auths.stream().map(ProjectAuth::getProjectId).filter(Objects::nonNull).collect(Collectors.toSet());
+						projectIds.addAll(ids);
+
+						Set<String> collect = ids.stream().map(String::valueOf).collect(Collectors.toSet());
+						proIds.addAll(collect);
+					}
+				} else if (role.contains(STAFF_SECOND_ADMIN)) {
+					// 1.2.2 次级机构主管  ---> 项目权限表里 userDept 字段是自己的集合
+					List<ProjectAuth> auths = projectAuthService.getByDeptAndUser(topDept, deptId, null);
+					if (!CollectionUtils.isEmpty(auths)) {
+						Set<Long> ids = auths.stream().map(ProjectAuth::getProjectId).filter(Objects::nonNull).collect(Collectors.toSet());
+						projectIds.addAll(ids);
+
+						Set<String> collect = ids.stream().map(String::valueOf).collect(Collectors.toSet());
+						proIds.addAll(collect);
+					}
+				} else if (role.contains(STAFF_USER) || role.contains(STAFF_PROJECT_MANAGER)) {
+					//1.2.3 普通员工和项目经理   --->项目权限表里 userId 是自己的
+					List<ProjectAuth> auths = projectAuthService.getByDeptAndUser(null, null, userId);
+					if (!CollectionUtils.isEmpty(auths)) {
+						Set<Long> ids = auths.stream().map(ProjectAuth::getProjectId).filter(Objects::nonNull).collect(Collectors.toSet());
+						projectIds.addAll(ids);
+
+						Set<String> collect = ids.stream().map(String::valueOf).collect(Collectors.toSet());
+						proIds.addAll(collect);
+					}
+				} else {
+					//都不是以上角色 则只可能是业主
+					List<ProjectAuth> auths = projectAuthService.getByDeptAndUser(topDept, null, null);
+					if (!CollectionUtils.isEmpty(auths)) {
+						Set<Long> ids = auths.stream().map(ProjectAuth::getProjectId).filter(Objects::nonNull).collect(Collectors.toSet());
+						projectIds.addAll(ids);
+
+						Set<String> collect = ids.stream().map(String::valueOf).collect(Collectors.toSet());
+						proIds.addAll(collect);
+					}
+				}
+			} else {
+				throw new ServiceException("查询不到您的角色信息,无法搜索资料");
 			}
 		}
 
@@ -289,9 +341,9 @@ public class CommonServiceImpl implements ICommonService {
 		BoolQueryBuilder condition = QueryBuilders.boolQuery();
 
 		//2. 添加must子句
-		condition.must(QueryBuilders.termsQuery("projectId", projectIds));
+		condition.must(QueryBuilders.termsQuery("projectId", proIds));
 		if (createUser != null) {
-			condition.must(QueryBuilders.termQuery("createUser", createUser));
+			condition.must(QueryBuilders.termQuery("createUser", String.valueOf(createUser)));
 		}
 		if (StringUtil.isNotBlank(text)) {
 			// 3.添加should子句
@@ -321,7 +373,7 @@ public class CommonServiceImpl implements ICommonService {
 			Set<Long> fileIds = set.stream().map(Document::getFileId).collect(Collectors.toSet());
 			lqw.in(FileAndFolder::getBladeFileId, fileIds);
 			res = fileAndFolderService.page(page, lqw);
-		} else {
+		} else if (!CollectionUtils.isEmpty(projectIds)) {
 			LambdaQueryWrapper<FileAndFolder> lqw = new LambdaQueryWrapper<>();
 			lqw.eq(FileAndFolder::getType, 1);
 			lqw.in(FileAndFolder::getProjectId, projectIds);

+ 0 - 45
blade-service/wutong-okr/src/main/java/com/wtkj/service/impl/ProjectServiceImpl.java

@@ -94,51 +94,6 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectMapper, Project>
 	@Override
 	public IPage<Project> getPage(ProjectPageDTO dto, IPage<Project> page) {
 		IPage<Project> projectIPage = new Page<>();
-		/*LambdaQueryWrapper<Project> lqw = new LambdaQueryWrapper<>();
-		//判断当前登录用户的身份 是业主还是服务机构
-		String deptIdStr = AuthUtil.getDeptId();
-		Long deptId = Long.valueOf(deptIdStr);
-		R<Dept> rpc = sysClient.getDept(deptId);
-		if (rpc.isSuccess()) {
-			//项目名称
-			if (StringUtil.isNotBlank(dto.getName())) {
-				lqw.eq(Project::getName, dto.getName());
-			}
-			//区域
-			if (StringUtil.isNotBlank(dto.getAreaCode())) {
-				lqw.eq(Project::getAreaCode, dto.getAreaCode());
-			}
-			Integer deptCategory = rpc.getData().getDeptCategory();
-			//如果是业主 即查询主管单位是该deptId的项目
-			if (deptCategory != null && deptCategory.equals(3)) {
-				//主管单位 业主自己
-				lqw.eq(Project::getCompetentUnit, deptId);
-				//协作单位
-				lqw.like(StringUtil.isNotBlank(dto.getCooperationUint()), Project::getCooperationUint, dto.getCooperationUint());
-			} else {
-				//主管单位
-				if (dto.getCompetentUnit() != null) {
-					lqw.eq(Project::getCompetentUnit, dto.getCompetentUnit());
-				}
-				//如果不是业主 ---> 判断是否是服务商的管理员  服务商管理员可以查看所有的项目
-				String userRole = AuthUtil.getUserRole();
-				if (userRole != null && userRole.contains(STAFF_ADMIN)) {
-					List<ProjectAuth> auths = projectAuthService.getByTopDept(dto.getTopDept(), null);
-					if (!CollectionUtils.isEmpty(auths)) {
-						Set<Long> projectIds = auths.stream().map(ProjectAuth::getProjectId).collect(Collectors.toSet());
-						lqw.in(Project::getId, projectIds);
-					}
-				} else {
-					//不是服务机构管理员 则会是项目经理或者任务执行人  从项目权限表里取
-					List<ProjectAuth> auths = projectAuthService.getByDeptAndUser(deptId, AuthUtil.getUserId());
-					if (!CollectionUtils.isEmpty(auths)) {
-						Set<Long> projectIds = auths.stream().map(ProjectAuth::getProjectId).collect(Collectors.toSet());
-						lqw.in(Project::getId, projectIds);
-					}
-				}
-			}
-		}
-		return this.page(page, lqw);*/
 		//1.机构类型
 		Integer category = dto.getDeptCategory();
 		Long topDept = dto.getTopDept();

+ 2 - 0
blade-service/wutong-okr/src/main/java/com/wtkj/service/impl/TaskServiceImpl.java

@@ -284,6 +284,8 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
 						Set<Long> taskIds = list.stream().map(Task::getId).collect(Collectors.toSet());
 						lqw.in(Task::getId, taskIds);
 					}
+				} else {
+					lqw.eq(Task::getId, 0L);
 				}
 			}
 		}