教师转入
This commit is contained in:
+19
-18
@@ -206,31 +206,32 @@ public class SchStudentTransferService {
|
|||||||
cacheKeysToDelete.add(RedisConstants.SCHOOL_CLASS_STUDENT + "_"
|
cacheKeysToDelete.add(RedisConstants.SCHOOL_CLASS_STUDENT + "_"
|
||||||
+ targetSchId + "_" + targetClassId);
|
+ targetSchId + "_" + targetClassId);
|
||||||
|
|
||||||
// 执行批量更新(更新学校和班级,transferStatus 置为转入 0)
|
// 已在目标学校且已在目标班级的学生 转入
|
||||||
int updated = schStudentRepository.batchUpdateSchIdAndClassId(
|
if (student.getSchId().equals(targetSchId) && targetClassId.equals(student.getClassId())) {
|
||||||
Collections.singletonList(student.getId()),
|
sendUserBaseService.changeUserStatus(student.getStuId(),true);
|
||||||
targetSchId,
|
}else {
|
||||||
targetClassId,
|
// 执行批量更新(更新学校和班级,transferStatus 置为转入 0)
|
||||||
now,
|
int updated = schStudentRepository.batchUpdateSchIdAndClassId(
|
||||||
user.getUserId()
|
Collections.singletonList(student.getId()),
|
||||||
);
|
targetSchId,
|
||||||
if (updated != 1) {
|
targetClassId,
|
||||||
throw new DException("更新失败,可能学生已被删除或修改,请刷新后重试");
|
now,
|
||||||
|
user.getUserId()
|
||||||
|
);
|
||||||
|
if (updated != 1) {
|
||||||
|
throw new DException("更新失败,可能学生已被删除或修改,请刷新后重试");
|
||||||
|
}
|
||||||
|
// 平台同步:转入目标学校/班级(fromSchoolId 取转入前的原学校)
|
||||||
|
sendUserBaseService.transferUserToSchool(student.getStuId(), student.getSchId(), targetSchId, targetClassId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 清除缓存(直接按Key删除)
|
// 清除缓存(直接按Key删除)
|
||||||
for (String cacheKey : cacheKeysToDelete) {
|
for (String cacheKey : cacheKeysToDelete) {
|
||||||
redisUtil.del(cacheKey);
|
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);
|
logService.setTransferInLog(user, Collections.singletonList(student), targetSchId, targetClassId);
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-15
@@ -168,23 +168,23 @@ public class SchTeacherRelationService {
|
|||||||
boolean alreadyInTarget = oldRelations.stream()
|
boolean alreadyInTarget = oldRelations.stream()
|
||||||
.anyMatch(r -> targetSchId.equals(r.getSchId()) && targetGroupId.equals(r.getGroupId()));
|
.anyMatch(r -> targetSchId.equals(r.getSchId()) && targetGroupId.equals(r.getGroupId()));
|
||||||
if (alreadyInTarget) {
|
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 ->
|
schTeacherRepository.findByTeaId(teaId).ifPresent(teacher ->
|
||||||
logService.setTransferInLogs(user, Collections.singletonList(teacher), targetGroupId));
|
logService.setTransferInLogs(user, Collections.singletonList(teacher), targetGroupId));
|
||||||
|
|||||||
Reference in New Issue
Block a user