提交代码
This commit is contained in:
1 parent
3468e1c88a
commit
bd5d4e57fc
7 files changed
+214
-5
No files matched your search
+13
@@ -257,4 +257,17 @@ public class XgDormBedStudentController extends BaseController {
|
||||
@RequestParam(required = false) Long classId) {
|
||||
return toAjax(xgDormBedStudentService.classTeacherRecallSelectedBeds(bedIds, classId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 班主任批量退宿
|
||||
*/
|
||||
@SaCheckPermission("dormBedStudent:dormBedStudent:edit")
|
||||
@Log(title = "班主任批量退宿", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/classTeacherStayawaySelectedBeds")
|
||||
public R<Void> classTeacherStayawaySelectedBeds(@RequestBody List<Long> bedIds,
|
||||
@RequestParam(required = false) Long classId) {
|
||||
return toAjax(xgDormBedStudentService.classTeacherStayawaySelectedBeds(bedIds, classId));
|
||||
}
|
||||
|
||||
}
|
||||
+9
@@ -183,4 +183,13 @@ public interface IXgDormBedStudentService {
|
||||
* @return 是否收回成功
|
||||
*/
|
||||
Boolean classTeacherRecallSelectedBeds(List<Long> bedIds, Long classId);
|
||||
|
||||
/**
|
||||
* 班主任批量退宿
|
||||
*
|
||||
* @param bedIds 床位ID列表
|
||||
* @param classId 班级ID
|
||||
* @return 是否退宿成功
|
||||
*/
|
||||
Boolean classTeacherStayawaySelectedBeds(List<Long> bedIds, Long classId);
|
||||
}
|
||||
+67
@@ -1806,4 +1806,71 @@ public class XgDormBedStudentServiceImpl implements IXgDormBedStudentService {
|
||||
throw new RuntimeException("收回选中床位失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 班主任退宿床位
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean classTeacherStayawaySelectedBeds(List<Long> bedIds, Long classId) {
|
||||
if (bedIds == null || bedIds.isEmpty()) {
|
||||
throw new IllegalArgumentException("床位ID列表不能为空");
|
||||
}
|
||||
|
||||
try {
|
||||
Long targetClassId = classId != null ? classId : getCurrentUserClassId();
|
||||
Date now = new Date();
|
||||
Long loginUserId = LoginHelper.getUserId();
|
||||
|
||||
log.info("班主任退宿选中床位,床位IDs: {},classId:{}", bedIds, targetClassId);
|
||||
|
||||
// 1. 更新 xg_student_msg 表:根据 ext_field1 = 床位id,deleted = 0,student_status = 1
|
||||
// 的数据
|
||||
// 将 dormitory_building、dormitory_room、ext_field1 置空
|
||||
if (!bedIds.isEmpty()) {
|
||||
LambdaUpdateWrapper<XgStudentMsg> updateStudentWrapper = Wrappers.lambdaUpdate();
|
||||
updateStudentWrapper
|
||||
.in(XgStudentMsg::getExtField1,
|
||||
bedIds.stream().map(String::valueOf).collect(java.util.stream.Collectors.toList()))
|
||||
.eq(XgStudentMsg::getDeleted, 0L)
|
||||
.eq(XgStudentMsg::getStudentStatus, "1")
|
||||
.set(XgStudentMsg::getDormitoryBuilding, null)
|
||||
.set(XgStudentMsg::getDormitoryRoom, null)
|
||||
.set(XgStudentMsg::getExtField1, null)
|
||||
.set(XgStudentMsg::getUpdateTime, now)
|
||||
.set(XgStudentMsg::getUpdateBy, loginUserId);
|
||||
|
||||
int studentUpdateCount = xgStudentMsgMapper.update(null, updateStudentWrapper);
|
||||
log.info("更新学生信息表记录数: {}", studentUpdateCount);
|
||||
}
|
||||
|
||||
// 2. 更新 xg_dorm_bed_student 表:根据 bed_id = 床位id,deleted = 0,status = 0
|
||||
// 将 status = 1 , checkout_time = 当前时间
|
||||
LambdaUpdateWrapper<XgDormBedStudent> updateBedStudentWrapper = Wrappers.lambdaUpdate();
|
||||
updateBedStudentWrapper.in(XgDormBedStudent::getBedId, bedIds)
|
||||
.eq(XgDormBedStudent::getDeleted, "0")
|
||||
.eq(XgDormBedStudent::getStatus, "0")
|
||||
.set(XgDormBedStudent::getStatus, "1")
|
||||
// .set(XgDormBedStudent::getAssignTime, null)
|
||||
.set(XgDormBedStudent::getCheckoutTime, now)
|
||||
.set(XgDormBedStudent::getUpdateTime, now)
|
||||
.set(XgDormBedStudent::getUpdateBy, loginUserId);
|
||||
|
||||
int bedStudentUpdateCount = baseMapper.update(null, updateBedStudentWrapper);
|
||||
log.info("更新床位学生分配表记录数: {}", bedStudentUpdateCount);
|
||||
|
||||
// 根据id跟床位id更新床位状态为空闲
|
||||
LambdaUpdateWrapper<XgDormBed> updateBedWrapper = Wrappers.lambdaUpdate();
|
||||
updateBedWrapper.in(XgDormBed::getId, bedIds)
|
||||
.eq(XgDormBed::getDeleted, "0")
|
||||
.set(XgDormBed::getBedStatus, "0");
|
||||
xgDormBedMapper.update(null, updateBedWrapper);
|
||||
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("班主任退宿选中床位失败", e);
|
||||
throw new RuntimeException("退宿选中床位失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user