教师转入

This commit is contained in:
2026-08-27 18:07:19 +08:00
parent ed056b73d4
commit 88cc1857c8
2 changed files with 34 additions and 33 deletions
@@ -206,31 +206,32 @@ public class SchStudentTransferService {
cacheKeysToDelete.add(RedisConstants.SCHOOL_CLASS_STUDENT + "_"
+ targetSchId + "_" + targetClassId);
// 执行批量更新(更新学校和班级,transferStatus 置为转入 0)
int updated = schStudentRepository.batchUpdateSchIdAndClassId(
Collections.singletonList(student.getId()),
targetSchId,
targetClassId,
now,
user.getUserId()
);
if (updated != 1) {
throw new DException("更新失败,可能学生已被删除或修改,请刷新后重试");
// 已在目标学校且已在目标班级的学生 转入
if (student.getSchId().equals(targetSchId) && targetClassId.equals(student.getClassId())) {
sendUserBaseService.changeUserStatus(student.getStuId(),true);
}else {
// 执行批量更新(更新学校和班级,transferStatus 置为转入 0)
int updated = schStudentRepository.batchUpdateSchIdAndClassId(
Collections.singletonList(student.getId()),
targetSchId,
targetClassId,
now,
user.getUserId()
);
if (updated != 1) {
throw new DException("更新失败,可能学生已被删除或修改,请刷新后重试");
}
// 平台同步:转入目标学校/班级(fromSchoolId 取转入前的原学校)
sendUserBaseService.transferUserToSchool(student.getStuId(), student.getSchId(), targetSchId, targetClassId);
}
// 清除缓存(直接按Key删除)
for (String cacheKey : cacheKeysToDelete) {
redisUtil.del(cacheKey);
}
// 已在目标学校且已在目标班级的学生 转入
if (student.getSchId().equals(targetSchId) && targetClassId.equals(student.getClassId())) {
sendUserBaseService.changeUserStatus(student.getStuId(),true);
}else {
// 平台同步:转入目标学校/班级(fromSchoolId 取转入前的原学校)
sendUserBaseService.transferUserToSchool(student.getStuId(), student.getSchId(), targetSchId, targetClassId);
}
// 异步记录操作日志
logService.setTransferInLog(user, Collections.singletonList(student), targetSchId, targetClassId);
}
@@ -168,23 +168,23 @@ public class SchTeacherRelationService {
boolean alreadyInTarget = oldRelations.stream()
.anyMatch(r -> targetSchId.equals(r.getSchId()) && targetGroupId.equals(r.getGroupId()));
if (alreadyInTarget) {
return;
sendUserBaseService.changeUserStatus(teaId, true);
}else {
// 删除原学校旧关联
schTeacherGroupRepository.deleteAll(oldRelations);
// 插入目标学校/目标组新关联(transferStatus 置为转入 0)
SchTeacherGroup newRel = new SchTeacherGroup();
newRel.setTeaId(teaId);
newRel.setGroupId(targetGroupId);
newRel.setSchId(targetSchId);
newRel.setTransferStatus(TransferStatus.IN.getId());
schTeacherGroupRepository.save(newRel);
// 平台同步:转入目标学校/目标组
sendUserBaseService.transferUserToSchool(teaId, fromSchId, targetSchId, targetGroupId);
}
// 删除原学校旧关联
schTeacherGroupRepository.deleteAll(oldRelations);
// 插入目标学校/目标组新关联(transferStatus 置为转入 0)
SchTeacherGroup newRel = new SchTeacherGroup();
newRel.setTeaId(teaId);
newRel.setGroupId(targetGroupId);
newRel.setSchId(targetSchId);
newRel.setTransferStatus(TransferStatus.IN.getId());
schTeacherGroupRepository.save(newRel);
// 平台同步:转入目标学校/目标组
sendUserBaseService.transferUserToSchool(teaId, fromSchId, targetSchId, targetGroupId);
// 异步记录操作日志
schTeacherRepository.findByTeaId(teaId).ifPresent(teacher ->
logService.setTransferInLogs(user, Collections.singletonList(teacher), targetGroupId));