@@ -27,25 +27,27 @@ public class SchGroupController {
|
|||||||
private ISchInfoService schInfoService;
|
private ISchInfoService schInfoService;
|
||||||
|
|
||||||
@GetMapping("GetTeaTree")
|
@GetMapping("GetTeaTree")
|
||||||
@Operation(summary = "获取学校教师组树+教师(SchSerID 与 schId 二选一)")
|
@Operation(summary = "获取学校教师组树(toUser 默认 true 带教师,false 仅返回组骨架;SchSerID 与 schId 二选一)")
|
||||||
public List<TeaTreeVO> getTeaTree(@RequestParam(value = "SchSerID", required = false) String SchSerID,
|
public List<TeaTreeVO> getTeaTree(@RequestParam(value = "SchSerID", required = false) String SchSerID,
|
||||||
@RequestParam(value = "schId", required = false) Integer schId) {
|
@RequestParam(value = "schId", required = false) Integer schId,
|
||||||
|
@RequestParam(value = "toUser", required = false, defaultValue = "true") boolean toUser) {
|
||||||
Integer resolvedSchId = resolveSchId(schId, SchSerID);
|
Integer resolvedSchId = resolveSchId(schId, SchSerID);
|
||||||
if (resolvedSchId == null) {
|
if (resolvedSchId == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
return comSchTreeService.getSchTeaTree(resolvedSchId);
|
return comSchTreeService.getSchTeaTree(resolvedSchId, toUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("GetStuTree")
|
@GetMapping("GetStuTree")
|
||||||
@Operation(summary = "获取学校学生树:学校→学段→年级→班级→学生(SchSerID 与 schId 二选一)")
|
@Operation(summary = "获取学校学生树:学校→学段→年级→班级→学生(toUser 默认 true 带学生,false 仅返回组织骨架;SchSerID 与 schId 二选一)")
|
||||||
public List<TeaTreeVO> getStuTree(@RequestParam(value = "SchSerID", required = false) String SchSerID,
|
public List<TeaTreeVO> getStuTree(@RequestParam(value = "SchSerID", required = false) String SchSerID,
|
||||||
@RequestParam(value = "schId", required = false) Integer schId) {
|
@RequestParam(value = "schId", required = false) Integer schId,
|
||||||
|
@RequestParam(value = "toUser", required = false, defaultValue = "true") boolean toUser) {
|
||||||
Integer resolvedSchId = resolveSchId(schId, SchSerID);
|
Integer resolvedSchId = resolveSchId(schId, SchSerID);
|
||||||
if (resolvedSchId == null) {
|
if (resolvedSchId == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
return comSchTreeService.getSchStuTree(resolvedSchId);
|
return comSchTreeService.getSchStuTree(resolvedSchId, toUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ public interface IComSchTreeService {
|
|||||||
|
|
||||||
BoaGroup getTeacherTree(Integer schId);
|
BoaGroup getTeacherTree(Integer schId);
|
||||||
|
|
||||||
List<TeaTreeVO> getSchTeaTree(Integer schId);
|
List<TeaTreeVO> getSchTeaTree(Integer schId, boolean toUser);
|
||||||
|
|
||||||
List<TeaTreeVO> getSchStuTree(Integer schId);
|
List<TeaTreeVO> getSchStuTree(Integer schId, boolean toUser);
|
||||||
|
|
||||||
List<SelectIntVO> getSchoolList();
|
List<SelectIntVO> getSchoolList();
|
||||||
|
|
||||||
|
|||||||
@@ -446,9 +446,10 @@ public class ComSchTreeService implements IComSchTreeService {
|
|||||||
* 结构:学校根(type=1) → 教师组(type=1) → 子组递归 + 教师叶子(type=2)。
|
* 结构:学校根(type=1) → 教师组(type=1) → 子组递归 + 教师叶子(type=2)。
|
||||||
* 节点字段:pid=父节点id(根为0)、no=组取 BoaGroup.sort / 教师固定 0、
|
* 节点字段:pid=父节点id(根为0)、no=组取 BoaGroup.sort / 教师固定 0、
|
||||||
* isParent=组true/教师false、photo 固定空串(本库无头像数据)。
|
* isParent=组true/教师false、photo 固定空串(本库无头像数据)。
|
||||||
|
* toUser=false 时只返回组织骨架(不查询、不挂载教师叶子)。
|
||||||
* 返回单元素列表(学校根节点)。
|
* 返回单元素列表(学校根节点)。
|
||||||
*/
|
*/
|
||||||
public List<TeaTreeVO> getSchTeaTree(Integer schId) {
|
public List<TeaTreeVO> getSchTeaTree(Integer schId, boolean toUser) {
|
||||||
// 1. 学校根节点(远程组树的根即学校节点,取不到时用学校名兜底)
|
// 1. 学校根节点(远程组树的根即学校节点,取不到时用学校名兜底)
|
||||||
List<BoaGroup> schTree = getSchTree(schId);
|
List<BoaGroup> schTree = getSchTree(schId);
|
||||||
BoaGroup schRoot = (schTree == null || schTree.isEmpty()) ? null : schTree.get(0);
|
BoaGroup schRoot = (schTree == null || schTree.isEmpty()) ? null : schTree.get(0);
|
||||||
@@ -479,7 +480,8 @@ public class ComSchTreeService implements IComSchTreeService {
|
|||||||
groupVoMap.put(teaRootVo.getId(), teaRootVo);
|
groupVoMap.put(teaRootVo.getId(), teaRootVo);
|
||||||
rootVo.getChildren().add(teaRootVo);
|
rootVo.getChildren().add(teaRootVo);
|
||||||
|
|
||||||
// 3. 挂教师:多组各挂一份;无组或组不在树中的落到"未分组"
|
// 3. 挂教师:多组各挂一份;无组或组不在树中的落到"未分组"(toUser=false 时不带用户,跳过查询)
|
||||||
|
if (toUser) {
|
||||||
List<SchTeacher> teacherList = schTeacherService.getSchTeacherList(schId);
|
List<SchTeacher> teacherList = schTeacherService.getSchTeacherList(schId);
|
||||||
if (CollectionUtils.isNotEmpty(teacherList)) {
|
if (CollectionUtils.isNotEmpty(teacherList)) {
|
||||||
List<Integer> teaIds = teacherList.stream()
|
List<Integer> teaIds = teacherList.stream()
|
||||||
@@ -515,6 +517,7 @@ public class ComSchTreeService implements IComSchTreeService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 4. 每个节点 children 按 no 升序(nullsLast、稳定排序):教师 no=0 排在子组之前,
|
// 4. 每个节点 children 按 no 升序(nullsLast、稳定排序):教师 no=0 排在子组之前,
|
||||||
// 同 no 的教师保持 getSchTeacherList 的 sort 顺序
|
// 同 no 的教师保持 getSchTeacherList 的 sort 顺序
|
||||||
@@ -588,9 +591,10 @@ public class ComSchTreeService implements IComSchTreeService {
|
|||||||
* 班级=sch_class(id=group_class_id,名称 cname 优先,no=sort,不含毕业班),
|
* 班级=sch_class(id=group_class_id,名称 cname 优先,no=sort,不含毕业班),
|
||||||
* 学生仅取在读正常状态(复用按班缓存查询,已过滤休学/转出/禁用并按 sort 排序)。
|
* 学生仅取在读正常状态(复用按班缓存查询,已过滤休学/转出/禁用并按 sort 排序)。
|
||||||
* 节点契约与 getSchTeaTree 相同:组织节点 type=1、isParent=true;学生叶子 type=2、isParent=false、children=null。
|
* 节点契约与 getSchTeaTree 相同:组织节点 type=1、isParent=true;学生叶子 type=2、isParent=false、children=null。
|
||||||
|
* toUser=false 时只返回组织骨架(不查询、不挂载学生叶子)。
|
||||||
* 返回单元素列表(学校根节点)。
|
* 返回单元素列表(学校根节点)。
|
||||||
*/
|
*/
|
||||||
public List<TeaTreeVO> getSchStuTree(Integer schId) {
|
public List<TeaTreeVO> getSchStuTree(Integer schId, boolean toUser) {
|
||||||
TeaTreeVO rootVo = new TeaTreeVO();
|
TeaTreeVO rootVo = new TeaTreeVO();
|
||||||
rootVo.setId(schId);
|
rootVo.setId(schId);
|
||||||
rootVo.setName(getSchoolName(schId));
|
rootVo.setName(getSchoolName(schId));
|
||||||
@@ -637,6 +641,8 @@ public class ComSchTreeService implements IComSchTreeService {
|
|||||||
grade.getGradeId(), clazz.getSort());
|
grade.getGradeId(), clazz.getSort());
|
||||||
gradeVo.getChildren().add(classVo);
|
gradeVo.getChildren().add(classVo);
|
||||||
|
|
||||||
|
// toUser=false 时不带用户,跳过按班查询
|
||||||
|
if (toUser) {
|
||||||
List<SchStudent> students = schStudentService.getSchGradeClassStudentCacheList(schId, null, null, clazz.getClassId());
|
List<SchStudent> students = schStudentService.getSchGradeClassStudentCacheList(schId, null, null, clazz.getClassId());
|
||||||
for (SchStudent student : students) {
|
for (SchStudent student : students) {
|
||||||
if (student.getStuId() == null) {
|
if (student.getStuId() == null) {
|
||||||
@@ -647,6 +653,7 @@ public class ComSchTreeService implements IComSchTreeService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sortChildrenByNo(rootVo);
|
sortChildrenByNo(rootVo);
|
||||||
return Collections.singletonList(rootVo);
|
return Collections.singletonList(rootVo);
|
||||||
|
|||||||
Reference in New Issue
Block a user