提交代码

This commit is contained in:
zlwu committed 2025-09-09 00:09:23 +08:00
1 parent 21856615db
commit 8ddd3a0d09
2 files changed
+174 -15

No files matched your search

@@ -40,9 +40,11 @@ import org.dromara.xg.mapper.XgStudentManagerMapper;
import org.dromara.xg.mapper.XgStudentManagerSourceMapper;
import org.dromara.xg.mapper.XgClassMsgMapper;
import org.dromara.xg.mapper.XgDormBedStudentMapper;
import org.dromara.xg.service.IXgDormBedStudentService;
import org.dromara.xg.domain.XgStudentManager;
import org.dromara.xg.domain.XgStudentManagerSource;
import org.dromara.xg.domain.XgClassMsg;
import org.dromara.xg.domain.XgDormBedStudent;
import java.util.List;
import java.util.Map;
@@ -67,6 +69,7 @@ public class XgDormApplicationServiceImpl implements IXgDormApplicationService {
private final XgDormApplicationMapper baseMapper;
private final WorkflowService workflowService;
private final XgDormBedStudentMapper xgDormBedStudentMapper;
private final IXgDormBedStudentService xgDormBedStudentService;
// 添加权限过滤需要的依赖
private final SysDeptMapper sysDeptMapper;
private final SysUserMapper sysUserMapper;
@@ -427,32 +430,115 @@ public class XgDormApplicationServiceImpl implements IXgDormApplicationService {
private void executeApplicationOperation(XgDormApplication application) {
try {
if ("1".equals(application.getApplicationType())) {
// 调宿申请 - 调用宿舍调整接口
// 调宿申请 - 区分两种场景处理
log.info("执行调宿操作: 学生ID={}, 目标床位ID={}", application.getStudentId(), application.getTargetBedId());
// 构建调宿参数并调用接口
// 参考提示词中的接口:/dormBedStudent/dormBedStudent/classTeacherExchangeBeds
// TODO: 这里需要根据实际情况调用相应的宿舍管理接口
log.info("调宿操作参数: sourceStudentId={}, targetBedId={}, classId={}",
application.getStudentId(), application.getTargetBedId(), application.getClassId());
// 1. 根据目标床位ID查找当前占用该床位的学生ID
Long targetStudentId = findStudentByBedId(application.getTargetBedId());
Boolean operationResult = false;
if (targetStudentId != null) {
// 场景1:目标床位有学生 - 两个学生互换床位
log.info("目标床位已有学生,执行床位互换: 申请学生ID={}, 目标学生ID={}",
application.getStudentId(), targetStudentId);
operationResult = xgDormBedStudentService.classTeacherExchangeBeds(
application.getStudentId(), // 源学生ID(申请人)
targetStudentId, // 目标学生ID(目标床位当前占用者)
application.getClassId() // 班级ID
);
if (operationResult) {
log.info("床位互换操作执行成功: 申请学生ID={}, 目标学生ID={}, 班级ID={}",
application.getStudentId(), targetStudentId, application.getClassId());
} else {
log.error("床位互换操作执行失败: 申请学生ID={}, 目标学生ID={}, 班级ID={}",
application.getStudentId(), targetStudentId, application.getClassId());
throw new RuntimeException("床位互换操作执行失败");
}
} else {
// 场景2:目标床位为空 - 学生移动到新床位
log.info("目标床位为空,执行床位移动: 申请学生ID={}, 目标床位ID={}",
application.getStudentId(), application.getTargetBedId());
operationResult = xgDormBedStudentService.classTeacherMoveBed(
application.getStudentId(), // 源学生ID(申请人)
application.getTargetBedId(), // 目标床位ID
application.getClassId() // 班级ID
);
if (operationResult) {
log.info("床位移动操作执行成功: 申请学生ID={}, 目标床位ID={}, 班级ID={}",
application.getStudentId(), application.getTargetBedId(), application.getClassId());
} else {
log.error("床位移动操作执行失败: 申请学生ID={}, 目标床位ID={}, 班级ID={}",
application.getStudentId(), application.getTargetBedId(), application.getClassId());
throw new RuntimeException("床位移动操作执行失败");
}
}
} else if ("2".equals(application.getApplicationType())) {
// 退宿申请 - 调用退宿接口
log.info("执行退宿操作: 学生ID={}, 当前床位ID={}", application.getStudentId(), application.getCurrentBedId());
// 构建退宿参数并调用接口
// 参考提示词中的接口:/dormBedStudent/dormBedStudent/classTeacherStayawaySelectedBeds
// TODO: 这里需要根据实际情况调用相应的宿舍管理接口
List<Long> bedIds = List.of(application.getCurrentBedId());
log.info("退宿操作参数: studentId={}, bedIds={}, classId={}",
application.getStudentId(), bedIds, application.getClassId());
Boolean stayawayResult = xgDormBedStudentService.classTeacherStayawaySelectedBeds(
bedIds, // 床位ID列表
application.getClassId() // 班级ID
);
if (stayawayResult) {
log.info("退宿操作执行成功: 学生ID={}, 床位ID={}, 班级ID={}",
application.getStudentId(), application.getCurrentBedId(), application.getClassId());
} else {
log.error("退宿操作执行失败: 学生ID={}, 床位ID={}, 班级ID={}",
application.getStudentId(), application.getCurrentBedId(), application.getClassId());
throw new RuntimeException("退宿操作执行失败");
}
} else {
log.error("未知的申请类型: {}", application.getApplicationType());
throw new RuntimeException("未知的申请类型: " + application.getApplicationType());
}
log.info("宿舍申请操作执行成功,申请ID: {}", application.getId());
} catch (Exception e) {
log.error("宿舍申请操作执行失败,申请ID: {}, 错误信息: {}", application.getId(), e.getMessage(), e);
// 可以考虑设置申请状态为失败或者发送通知
// 抛出异常,让调用方处理
throw new RuntimeException("宿舍申请操作执行失败: " + e.getMessage(), e);
}
}
/**
* 根据床位ID查找当前占用该床位的学生ID
*
* @param bedId 床位ID
* @return 学生ID,如果没有找到则返回null
*/
private Long findStudentByBedId(Long bedId) {
if (bedId == null) {
return null;
}
try {
LambdaQueryWrapper<XgDormBedStudent> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(XgDormBedStudent::getBedId, bedId)
.eq(XgDormBedStudent::getStatus, "0") // 0-正常状态
.eq(XgDormBedStudent::getDeleted, 0L); // 未删除
XgDormBedStudent bedStudent = xgDormBedStudentMapper.selectOne(queryWrapper);
if (bedStudent != null) {
log.info("根据床位ID: {} 找到学生ID: {}", bedId, bedStudent.getStudentId());
return bedStudent.getStudentId();
} else {
log.warn("床位ID: {} 没有找到对应的学生", bedId);
return null;
}
} catch (Exception e) {
log.error("根据床位ID: {} 查找学生失败: {}", bedId, e.getMessage(), e);
return null;
}
}