提交修改

This commit is contained in:
zlwu committed 2025-08-14 19:01:23 +08:00
1 parent ae8cddff00
commit 3468e1c88a
5 files changed
+120 -14

No files matched your search

@@ -245,4 +245,16 @@ public class XgDormBedStudentController extends BaseController {
@RequestParam(required = false) Long classId) {
return toAjax(xgDormBedStudentService.classTeacherRecallBeds(buildingId, classId));
}
/**
* 班主任收回选中床位
*/
@SaCheckPermission("dormBedStudent:dormBedStudent:edit")
@Log(title = "班主任收回选中床位", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PostMapping("/classTeacherRecallSelectedBeds")
public R<Void> classTeacherRecallSelectedBeds(@RequestBody List<Long> bedIds,
@RequestParam(required = false) Long classId) {
return toAjax(xgDormBedStudentService.classTeacherRecallSelectedBeds(bedIds, classId));
}
}
@@ -174,4 +174,13 @@ public interface IXgDormBedStudentService {
* @return 是否收回成功
*/
Boolean classTeacherRecallBeds(Long buildingId, Long classId);
/**
* 班主任收回选中床位
*
* @param bedIds 床位ID列表
* @param classId 班级ID
* @return 是否收回成功
*/
Boolean classTeacherRecallSelectedBeds(List<Long> bedIds, Long classId);
}
@@ -1747,4 +1747,63 @@ public class XgDormBedStudentServiceImpl implements IXgDormBedStudentService {
throw new RuntimeException("收回床位失败:" + e.getMessage());
}
}
/**
* 班主任收回选中床位
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean classTeacherRecallSelectedBeds(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
// 将 student_id、assign_time、checkout_time 置空
LambdaUpdateWrapper<XgDormBedStudent> updateBedStudentWrapper = Wrappers.lambdaUpdate();
updateBedStudentWrapper.in(XgDormBedStudent::getBedId, bedIds)
.eq(XgDormBedStudent::getDeleted, "0")
.eq(XgDormBedStudent::getStatus, "0")
.set(XgDormBedStudent::getStudentId, null)
// .set(XgDormBedStudent::getAssignTime, null)
.set(XgDormBedStudent::getCheckoutTime, null)
.set(XgDormBedStudent::getUpdateTime, now)
.set(XgDormBedStudent::getUpdateBy, loginUserId);
int bedStudentUpdateCount = baseMapper.update(null, updateBedStudentWrapper);
log.info("更新床位学生分配表记录数: {}", bedStudentUpdateCount);
return true;
} catch (Exception e) {
log.error("班主任收回选中床位失败", e);
throw new RuntimeException("收回选中床位失败:" + e.getMessage());
}
}
}
@@ -113,10 +113,7 @@ export const getClassTeacherDormTree = (classId?: string | number): AxiosPromise
* 获取班主任管理班级的房间床位详情(带学生信息)
* @param buildingId 宿舍楼ID,为空则查询所有楼栋
*/
export const getClassTeacherBedDetails = (
buildingId?: string | number,
classId?: string | number
): AxiosPromise<any[]> => {
export const getClassTeacherBedDetails = (buildingId?: string | number, classId?: string | number): AxiosPromise<any[]> => {
return request({
url: '/dormBedStudent/dormBedStudent/getClassTeacherBedDetails',
method: 'get',
@@ -163,11 +160,14 @@ export const classTeacherStudentNoAllocation = (buildingId?: string | number, cl
* 班主任选择性分配床位(弹窗模式)
* @param allocationParams 分配参数 {bedIds: number[], studentIds: number[], allocationType: 'random' | 'studentNo'}
*/
export const classTeacherSelectiveAllocation = (allocationParams: {
bedIds: Array<string | number>;
studentIds: Array<string | number>;
allocationType: 'random' | 'studentNo';
}, classId?: string | number) => {
export const classTeacherSelectiveAllocation = (
allocationParams: {
bedIds: Array<string | number>;
studentIds: Array<string | number>;
allocationType: 'random' | 'studentNo';
},
classId?: string | number
) => {
return request({
url: '/dormBedStudent/dormBedStudent/classTeacherSelectiveAllocation',
method: 'post',
@@ -187,3 +187,17 @@ export const classTeacherRecallBeds = (buildingId?: string | number, classId?: s
params: { buildingId, classId }
});
};
/**
* 班主任收回选中床位
* @param bedIds 床位ID数组
* @param classId 班级ID,可为空
*/
export const classTeacherRecallSelectedBeds = (bedIds: number[], classId?: string | number) => {
return request({
url: '/dormBedStudent/dormBedStudent/classTeacherRecallSelectedBeds',
method: 'post',
data: bedIds,
params: { classId }
});
};
+17 -5
View File
@@ -98,7 +98,7 @@
<el-button type="primary" icon="UserFilled" size="small" @click="handleSelectiveAllocation">分配床位</el-button>
<!-- <el-button type="success" icon="UserFilled" size="small" @click="handleRandomAllocation">随机分配</el-button>
<el-button type="info" icon="Sort" size="small" @click="handleStudentNoAllocation">按学号分配</el-button> -->
<el-button type="warning" icon="RefreshLeft" size="small" @click="handleRecallBeds">收回床位</el-button>
<el-button type="warning" icon="RefreshLeft" size="small" @click="handleRecallBeds">收回选中床位</el-button>
</el-col>
<el-col :span="12" style="text-align: right">
<el-button
@@ -304,7 +304,7 @@ import {
getClassTeacherUnallocatedStudents,
classTeacherRandomAllocation,
classTeacherStudentNoAllocation,
classTeacherRecallBeds
classTeacherRecallSelectedBeds
} from '@/api/xg/xgss/dormBedStudent/dormBedStudent';
// 导入API方法
import { listDormRoomByClassId } from '@/api/xg/xgss/dormRoom/index';
@@ -719,15 +719,27 @@ const handleRecallBeds = async () => {
return;
}
// 获取选中的床位ID数组
const selectedBedIds = selectedRows.value
.filter((row) => row.isBed && row.studentId) // 只收回已分配的床位
.map((bed) => bed.id);
if (selectedBedIds.length === 0) {
ElMessage.warning('请先勾选要收回的床位!');
return;
}
try {
await ElMessageBox.confirm(`确认收回 ${selectedBuilding.value.label} 的所有床位分配吗?\n\n收回后,学生的床位信息将被清空。`, '确认收回床位', {
const confirmMessage = `确认收回选中的 ${selectedBedIds.length} 个床位分配吗?\n\n收回后,这些床位上学生的床位信息将被清空。`;
await ElMessageBox.confirm(confirmMessage, '确认收回选中床位', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
});
await classTeacherRecallBeds(selectedBuilding.value.id, activeClassId.value);
ElMessage.success('收回床位成功');
await classTeacherRecallSelectedBeds(selectedBedIds, activeClassId.value);
ElMessage.success('收回选中床位成功');
handleAllocationSuccess();
} catch (error: any) {
if (error !== 'cancel') {