|
@@ -21,7 +21,26 @@ import org.dromara.xg.mapper.XgStudentMsgMapper;
|
|
|
import org.dromara.xg.service.IXgStudentMsgBatchService;
|
|
import org.dromara.xg.service.IXgStudentMsgBatchService;
|
|
|
import org.dromara.system.service.ISysUserService;
|
|
import org.dromara.system.service.ISysUserService;
|
|
|
import org.dromara.xg.service.IXgStudentMsgService;
|
|
import org.dromara.xg.service.IXgStudentMsgService;
|
|
|
-
|
|
|
|
|
|
|
+import org.dromara.xg.mapper.XgStudentManagerMapper;
|
|
|
|
|
+import org.dromara.xg.mapper.XgStudentManagerSourceMapper;
|
|
|
|
|
+import org.dromara.xg.mapper.XgClassTeacherCounselorRelMapper;
|
|
|
|
|
+import org.dromara.xg.mapper.XgClassMsgMapper;
|
|
|
|
|
+import org.dromara.xg.domain.XgStudentManager;
|
|
|
|
|
+import org.dromara.xg.domain.XgStudentManagerSource;
|
|
|
|
|
+import org.dromara.xg.domain.XgClassTeacherCounselorRel;
|
|
|
|
|
+import org.dromara.xg.domain.XgClassMsg;
|
|
|
|
|
+import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+import org.dromara.system.domain.SysDept;
|
|
|
|
|
+import org.dromara.system.mapper.SysDeptMapper;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.Collection;
|
|
|
|
|
+import java.util.Calendar;
|
|
|
|
|
+import java.util.Date;
|
|
|
|
|
+import java.util.Set;
|
|
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
@@ -45,6 +64,11 @@ public class XgStudentMsgBatchServiceImpl implements IXgStudentMsgBatchService {
|
|
|
private final XgStudentMsgMapper xgStudentMsgMapper;
|
|
private final XgStudentMsgMapper xgStudentMsgMapper;
|
|
|
private final ISysUserService sysUserService;
|
|
private final ISysUserService sysUserService;
|
|
|
private final IXgStudentMsgService xgStudentMsgService;
|
|
private final IXgStudentMsgService xgStudentMsgService;
|
|
|
|
|
+ private final XgStudentManagerMapper xgStudentManagerMapper;
|
|
|
|
|
+ private final XgStudentManagerSourceMapper xgStudentManagerSourceMapper;
|
|
|
|
|
+ private final XgClassTeacherCounselorRelMapper xgClassTeacherCounselorRelMapper;
|
|
|
|
|
+ private final XgClassMsgMapper xgClassMsgMapper;
|
|
|
|
|
+ private final SysDeptMapper sysDeptMapper;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询学生信息批次收集
|
|
* 查询学生信息批次收集
|
|
@@ -853,27 +877,176 @@ public class XgStudentMsgBatchServiceImpl implements IXgStudentMsgBatchService {
|
|
|
public TableDataInfo<XgStudentMsgBatchVo> queryPageListByDeptId(Long batchId, Long deptId, String name,
|
|
public TableDataInfo<XgStudentMsgBatchVo> queryPageListByDeptId(Long batchId, Long deptId, String name,
|
|
|
String studentNo, String phone, String infoStatus, PageQuery pageQuery) {
|
|
String studentNo, String phone, String infoStatus, PageQuery pageQuery) {
|
|
|
// 第一步:根据deptId查询所有子部门ID(包括自己)
|
|
// 第一步:根据deptId查询所有子部门ID(包括自己)
|
|
|
- List<Long> deptIds = baseMapper.selectChildDeptIds(deptId);
|
|
|
|
|
|
|
+ // List<Long> deptIds = baseMapper.selectChildDeptIds(deptId);
|
|
|
|
|
|
|
|
- if (deptIds == null || deptIds.isEmpty()) {
|
|
|
|
|
- log.warn("部门ID: {} 没有找到任何子部门或自身不存在", deptId);
|
|
|
|
|
- // 返回空的分页结果
|
|
|
|
|
- return TableDataInfo.build(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if (deptIds == null || deptIds.isEmpty()) {
|
|
|
|
|
+ // log.warn("部门ID: {} 没有找到任何子部门或自身不存在", deptId);
|
|
|
|
|
+ // // 返回空的分页结果
|
|
|
|
|
+ // return TableDataInfo.build(new
|
|
|
|
|
+ // com.baomidou.mybatisplus.extension.plugins.pagination.Page<>());
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // log.info("部门ID: {} 查询到的子部门列表: {}", deptId, deptIds);
|
|
|
|
|
+
|
|
|
|
|
+ // 调用权限过滤方法,获取过滤后的deptIds
|
|
|
|
|
+ List<Long> filteredDeptIds = filterDeptIdsByPermission(deptId);
|
|
|
|
|
|
|
|
- log.info("部门ID: {} 查询到的子部门列表: {}", deptId, deptIds);
|
|
|
|
|
|
|
+ log.info("权限过滤后的部门ID列表: {}", filteredDeptIds);
|
|
|
|
|
|
|
|
// 第二步:根据部门ID列表和条件分页查询学生信息批次数据
|
|
// 第二步:根据部门ID列表和条件分页查询学生信息批次数据
|
|
|
com.baomidou.mybatisplus.extension.plugins.pagination.Page<XgStudentMsgBatchVo> page = pageQuery
|
|
com.baomidou.mybatisplus.extension.plugins.pagination.Page<XgStudentMsgBatchVo> page = pageQuery
|
|
|
.build();
|
|
.build();
|
|
|
com.baomidou.mybatisplus.extension.plugins.pagination.Page<XgStudentMsgBatchVo> result = baseMapper
|
|
com.baomidou.mybatisplus.extension.plugins.pagination.Page<XgStudentMsgBatchVo> result = baseMapper
|
|
|
- .selectPageByDeptIds(page, batchId, deptIds, name, studentNo, phone, infoStatus);
|
|
|
|
|
|
|
+ .selectPageByDeptIds(page, batchId, filteredDeptIds, name, studentNo, phone, infoStatus);
|
|
|
|
|
|
|
|
log.info("根据部门ID: {} 和批次ID: {} 查询到 {} 条学生数据", deptId, batchId, result.getTotal());
|
|
log.info("根据部门ID: {} 和批次ID: {} 查询到 {} 条学生数据", deptId, batchId, result.getTotal());
|
|
|
|
|
|
|
|
return TableDataInfo.build(result);
|
|
return TableDataInfo.build(result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 权限过滤方法
|
|
|
|
|
+ * 根据当前用户的权限范围过滤部门ID列表
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param deptId 入参的部门ID
|
|
|
|
|
+ * @return 过滤后的部门ID列表
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<Long> filterDeptIdsByPermission(Long deptId) {
|
|
|
|
|
+ // 获取当前登录用户ID
|
|
|
|
|
+ Long currentUserId = LoginHelper.getUserId();
|
|
|
|
|
+ log.info("当前登录用户ID: {}", currentUserId);
|
|
|
|
|
+
|
|
|
|
|
+ // 第一步:判断当前用户是否为全校管理员
|
|
|
|
|
+ boolean isSchoolManager = checkIsSchoolManager(currentUserId);
|
|
|
|
|
+ if (isSchoolManager) {
|
|
|
|
|
+ log.info("用户 {} 是全校管理员,不进行权限过滤", currentUserId);
|
|
|
|
|
+ // 全校管理员不进行过滤,返回包含入参deptId及其子组织的列表
|
|
|
|
|
+ return getDeptIdsWithChildren(deptId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 第二步:获取用户的总权限集合
|
|
|
|
|
+ Set<Long> userAuthDeptIds = getUserAuthDeptIds(currentUserId);
|
|
|
|
|
+ log.info("用户 {} 的权限范围: {}", currentUserId, userAuthDeptIds);
|
|
|
|
|
+
|
|
|
|
|
+ // 第三步:判断入参deptId是否在用户权限范围内
|
|
|
|
|
+ if (deptId != null && userAuthDeptIds.contains(deptId)) {
|
|
|
|
|
+ log.info("入参deptId {} 在用户权限范围内,不进行过滤", deptId);
|
|
|
|
|
+ // 在权限范围内,返回包含入参deptId及其子组织的列表
|
|
|
|
|
+ return getDeptIdsWithChildren(deptId);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.info("入参deptId {} 不在用户权限范围内,进行权限过滤", deptId);
|
|
|
|
|
+ // 不在权限范围内,过滤deptIds,只保留在权限范围内的
|
|
|
|
|
+ List<Long> filteredDeptIds = new ArrayList<>();
|
|
|
|
|
+ if (deptId != null) {
|
|
|
|
|
+ // 如果入参deptId不为空,检查其子组织是否在权限范围内
|
|
|
|
|
+ List<Long> deptIdsWithChildren = getDeptIdsWithChildren(deptId);
|
|
|
|
|
+ for (Long deptIdWithChild : deptIdsWithChildren) {
|
|
|
|
|
+ if (userAuthDeptIds.contains(deptIdWithChild)) {
|
|
|
|
|
+ filteredDeptIds.add(deptIdWithChild);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 如果入参deptId为空,直接使用用户权限范围内的所有部门
|
|
|
|
|
+ filteredDeptIds.addAll(userAuthDeptIds);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 对过滤后的deptIds,查找所有子组织包括他们自己
|
|
|
|
|
+ Set<Long> finalDeptIds = new HashSet<>();
|
|
|
|
|
+ for (Long filteredDeptId : filteredDeptIds) {
|
|
|
|
|
+ List<Long> deptIdsWithChildren = getDeptIdsWithChildren(filteredDeptId);
|
|
|
|
|
+ finalDeptIds.addAll(deptIdsWithChildren);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return new ArrayList<>(finalDeptIds);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 检查用户是否为全校管理员
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param userId 用户ID
|
|
|
|
|
+ * @return 是否为全校管理员
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean checkIsSchoolManager(Long userId) {
|
|
|
|
|
+ LambdaQueryWrapper<XgStudentManager> lqw = Wrappers.lambdaQuery();
|
|
|
|
|
+ lqw.eq(XgStudentManager::getUserId, userId)
|
|
|
|
|
+ .eq(XgStudentManager::getDeleted, "0")
|
|
|
|
|
+ .eq(XgStudentManager::getStatus, "0")
|
|
|
|
|
+ .eq(XgStudentManager::getManagerType, "1");
|
|
|
|
|
+
|
|
|
|
|
+ return xgStudentManagerMapper.selectCount(lqw) > 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取用户的总权限集合
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param userId 用户ID
|
|
|
|
|
+ * @return 用户权限范围内的部门ID集合
|
|
|
|
|
+ */
|
|
|
|
|
+ private Set<Long> getUserAuthDeptIds(Long userId) {
|
|
|
|
|
+ Set<Long> authDeptIds = new HashSet<>();
|
|
|
|
|
+
|
|
|
|
|
+ // 第三步:通过xg_student_manager和xg_student_manager_source关联,获取用户的权限范围
|
|
|
|
|
+ LambdaQueryWrapper<XgStudentManager> managerWrapper = Wrappers.lambdaQuery();
|
|
|
|
|
+ managerWrapper.eq(XgStudentManager::getUserId, userId)
|
|
|
|
|
+ .eq(XgStudentManager::getDeleted, "0")
|
|
|
|
|
+ .eq(XgStudentManager::getStatus, "0");
|
|
|
|
|
+
|
|
|
|
|
+ List<XgStudentManager> managers = xgStudentManagerMapper.selectList(managerWrapper);
|
|
|
|
|
+
|
|
|
|
|
+ for (XgStudentManager manager : managers) {
|
|
|
|
|
+ LambdaQueryWrapper<XgStudentManagerSource> sourceWrapper = Wrappers.lambdaQuery();
|
|
|
|
|
+ sourceWrapper.eq(XgStudentManagerSource::getManagerId, manager.getId())
|
|
|
|
|
+ .eq(XgStudentManagerSource::getDeleted, "0")
|
|
|
|
|
+ .eq(XgStudentManagerSource::getStatus, "0");
|
|
|
|
|
+
|
|
|
|
|
+ List<XgStudentManagerSource> sources = xgStudentManagerSourceMapper.selectList(sourceWrapper);
|
|
|
|
|
+ for (XgStudentManagerSource source : sources) {
|
|
|
|
|
+ if (source.getAuthSource() != null) {
|
|
|
|
|
+ authDeptIds.add(source.getAuthSource());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 第四步:通过xg_class_msg表,class_teacher_id=当前登录人id,deleted='0',class_status='1',获取id
|
|
|
|
|
+ LambdaQueryWrapper<XgClassMsg> classWrapper = Wrappers.lambdaQuery();
|
|
|
|
|
+ classWrapper.eq(XgClassMsg::getClassTeacherId, userId)
|
|
|
|
|
+ .eq(XgClassMsg::getDeleted, 0L)
|
|
|
|
|
+ .eq(XgClassMsg::getClassStatus, "1");
|
|
|
|
|
+
|
|
|
|
|
+ List<XgClassMsg> classes = xgClassMsgMapper.selectList(classWrapper);
|
|
|
|
|
+ for (XgClassMsg classMsg : classes) {
|
|
|
|
|
+ if (classMsg.getId() != null) {
|
|
|
|
|
+ authDeptIds.add(classMsg.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return authDeptIds;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取部门ID及其所有子组织的ID列表
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param deptId 部门ID
|
|
|
|
|
+ * @return 包含部门ID及其子组织的ID列表
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<Long> getDeptIdsWithChildren(Long deptId) {
|
|
|
|
|
+ List<Long> deptIds = new ArrayList<>();
|
|
|
|
|
+ if (deptId != null) {
|
|
|
|
|
+ deptIds.add(deptId); // 包含自己
|
|
|
|
|
+
|
|
|
|
|
+ // 查找所有子组织
|
|
|
|
|
+ List<SysDept> childDepts = sysDeptMapper.selectListByParentId(deptId);
|
|
|
|
|
+ if (!childDepts.isEmpty()) {
|
|
|
|
|
+ List<Long> childDeptIds = childDepts.stream()
|
|
|
|
|
+ .map(SysDept::getDeptId)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ deptIds.addAll(childDeptIds);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return deptIds;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 驳回学生信息提交
|
|
* 驳回学生信息提交
|
|
|
*
|
|
*
|