提交代码
This commit is contained in:
1 parent
c20df56dcd
commit
2c51e0ec3b
2 files changed
+143
-20
No files matched your search
+45
-14
@@ -1136,29 +1136,60 @@ public class XgStudentMsgServiceImpl implements IXgStudentMsgService {
|
||||
return;
|
||||
}
|
||||
|
||||
// 1. 批量更新学生信息表的is_boarder字段为0,同时清空宿舍楼栋和房间号
|
||||
// 1. 查询学生信息,检查哪些学生已经分配了宿舍
|
||||
List<XgStudentMsg> students = baseMapper.selectList(
|
||||
Wrappers.lambdaQuery(XgStudentMsg.class)
|
||||
.in(XgStudentMsg::getId, studentIds)
|
||||
.eq(XgStudentMsg::getDeleted, 0));
|
||||
|
||||
// 2. 过滤出可以取消床位申请的学生(宿舍楼栋、房间号、床位号都为空的学生)
|
||||
List<Long> allowedStudentIds = new ArrayList<>();
|
||||
List<Long> skippedStudentIds = new ArrayList<>();
|
||||
|
||||
for (XgStudentMsg student : students) {
|
||||
// 检查宿舍楼栋、房间号、床位号是否都不为空
|
||||
boolean hasAssignedBed = StringUtils.isNotBlank(student.getDormitoryBuilding()) ||
|
||||
StringUtils.isNotBlank(student.getDormitoryRoom()) ||
|
||||
StringUtils.isNotBlank(student.getExtField1()); // 床位号字段
|
||||
|
||||
if (hasAssignedBed) {
|
||||
skippedStudentIds.add(student.getId());
|
||||
log.warn("学生 {} (ID: {}) 已分配宿舍,跳过取消床位申请操作", student.getName(), student.getId());
|
||||
} else {
|
||||
allowedStudentIds.add(student.getId());
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 如果没有学生可以取消床位申请,直接返回
|
||||
if (allowedStudentIds.isEmpty()) {
|
||||
log.warn("所有学生都已分配宿舍,无法执行取消床位申请操作");
|
||||
return;
|
||||
}
|
||||
|
||||
// 4. 批量更新允许取消床位申请的学生信息
|
||||
LambdaQueryWrapper<XgStudentMsg> updateWrapper = Wrappers.lambdaQuery();
|
||||
updateWrapper.in(XgStudentMsg::getId, studentIds);
|
||||
updateWrapper.in(XgStudentMsg::getId, allowedStudentIds);
|
||||
|
||||
XgStudentMsg updateEntity = new XgStudentMsg();
|
||||
updateEntity.setIsBoarder(0L);
|
||||
updateEntity.setDormitoryBuilding(null); // 清空宿舍楼栋
|
||||
updateEntity.setDormitoryRoom(null); // 清空宿舍房间号
|
||||
|
||||
int updateCount = baseMapper.update(updateEntity, updateWrapper);
|
||||
log.info("批量取消床位 - 更新学生住宿状态并清空宿舍信息完成,共更新 {} 条学生记录", updateCount);
|
||||
log.info("批量取消床位 - 更新学生住宿状态完成,共更新 {} 条学生记录,跳过 {} 条已分配宿舍的学生记录",
|
||||
updateCount, skippedStudentIds.size());
|
||||
|
||||
// 2. 更新宿舍床位学生表,将状态改为1(已退宿),设置退宿时间为当前时间
|
||||
LambdaQueryWrapper<XgDormBedStudent> bedUpdateWrapper = Wrappers.lambdaQuery();
|
||||
bedUpdateWrapper.in(XgDormBedStudent::getStudentId, studentIds);
|
||||
bedUpdateWrapper.eq(XgDormBedStudent::getStatus, "0"); // 只更新状态为正常的记录
|
||||
// 5. 更新宿舍床位学生表,将状态改为1(已退宿),设置退宿时间为当前时间
|
||||
// LambdaQueryWrapper<XgDormBedStudent> bedUpdateWrapper =
|
||||
// Wrappers.lambdaQuery();
|
||||
// bedUpdateWrapper.in(XgDormBedStudent::getStudentId, studentIds);
|
||||
// bedUpdateWrapper.eq(XgDormBedStudent::getStatus, "0"); // 只更新状态为正常的记录
|
||||
|
||||
XgDormBedStudent bedUpdateEntity = new XgDormBedStudent();
|
||||
bedUpdateEntity.setStatus("1"); // 设置为已退宿
|
||||
bedUpdateEntity.setCheckoutTime(new Date()); // 设置退宿时间为当前时间
|
||||
// XgDormBedStudent bedUpdateEntity = new XgDormBedStudent();
|
||||
// bedUpdateEntity.setStatus("1"); // 设置为已退宿
|
||||
// bedUpdateEntity.setCheckoutTime(new Date()); // 设置退宿时间为当前时间
|
||||
|
||||
int bedUpdateCount = xgDormBedStudentMapper.update(bedUpdateEntity, bedUpdateWrapper);
|
||||
log.info("批量取消床位 - 更新宿舍床位状态完成,共更新 {} 条床位记录", bedUpdateCount);
|
||||
// int bedUpdateCount = xgDormBedStudentMapper.update(bedUpdateEntity,
|
||||
// bedUpdateWrapper);
|
||||
// log.info("批量取消床位 - 更新宿舍床位状态完成,共更新 {} 条床位记录", bedUpdateCount);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
<el-button type="primary" :disabled="multiple" @click="handleBatchApplyBed()"> 批量申请床位 </el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" :disabled="multiple" @click="handleBatchCancelBed()"> 批量取消床位 </el-button>
|
||||
<el-button type="danger" :disabled="multiple" @click="handleBatchCancelBed()"> 批量取消床位申请 </el-button>
|
||||
</el-col>
|
||||
<!-- <el-col :span="1.5">
|
||||
<el-button :disabled="multiple" icon="Delete" @click="handleDelete()"> 删除 </el-button>
|
||||
@@ -2285,7 +2285,7 @@ const resetQuery = () => {
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: StudentVO) => {
|
||||
const studentIds = row?.id || ids.value;
|
||||
const [err] = await to(ElMessageBox.confirm('是否确认删除学生编号为"' + row?.name + '"的数据项?', '提示'));
|
||||
const [err] = await to(ElMessageBox.confirm('是否确认删除学生姓名为"' + row?.name + '"的数据项?', '提示'));
|
||||
if (!err) {
|
||||
try {
|
||||
const res = await service.delete(`/studentMsg/studentMsg/${studentIds}`);
|
||||
@@ -2342,23 +2342,93 @@ const handleBatchCancelBed = async () => {
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取选中学生的详细信息
|
||||
const selectedStudents = studentList.value.filter((student) => ids.value.includes(student.id));
|
||||
|
||||
// 分类学生:可以取消和不可以取消的
|
||||
const canCancelStudents: any[] = [];
|
||||
const cannotCancelStudents: any[] = [];
|
||||
|
||||
selectedStudents.forEach((student) => {
|
||||
// 检查学生是否已分配宿舍(宿舍楼栋、房间号、床位号任一不为空)
|
||||
const studentAny = student as any;
|
||||
const hasAssignedBed = studentAny.dormitoryBuilding || studentAny.dormitoryRoom || studentAny.extField1; // 床位号字段
|
||||
|
||||
if (hasAssignedBed) {
|
||||
cannotCancelStudents.push(student);
|
||||
} else {
|
||||
canCancelStudents.push(student);
|
||||
}
|
||||
});
|
||||
|
||||
// 构建确认消息
|
||||
let confirmMessage = '';
|
||||
|
||||
if (canCancelStudents.length > 0) {
|
||||
confirmMessage += `<div style="margin-bottom: 15px;">
|
||||
<strong style="color: #67c23a;">✅ 可以取消床位申请的学生 (${canCancelStudents.length}人):</strong><br/>
|
||||
${canCancelStudents.map((student) => `• ${student.name} (${student.studentNo})`).join('<br/>')}
|
||||
</div>`;
|
||||
}
|
||||
|
||||
if (cannotCancelStudents.length > 0) {
|
||||
confirmMessage += `<div style="margin-bottom: 15px;">
|
||||
<strong style="color: #f56c6c;">❌ 无法取消床位申请的学生 (${cannotCancelStudents.length}人):</strong><br/>
|
||||
${cannotCancelStudents.map((student) => `• ${student.name} (${student.studentNo}) - 已分配宿舍`).join('<br/>')}
|
||||
</div>`;
|
||||
}
|
||||
|
||||
// 如果没有学生可以取消,直接提示
|
||||
if (canCancelStudents.length === 0) {
|
||||
ElMessage.warning('选中的学生都已分配宿舍,无法取消床位申请');
|
||||
return;
|
||||
}
|
||||
|
||||
// 显示确认对话框
|
||||
const [err] = await to(
|
||||
ElMessageBox.confirm('请确认是否取消,会将学生已有宿舍清除!!!', '批量取消床位', {
|
||||
ElMessageBox.confirm(
|
||||
`<div style="text-align: left; max-height: 400px; overflow-y: auto;">
|
||||
<div style="margin-bottom: 15px; font-size: 14px;">
|
||||
<strong>批量取消床位申请确认</strong><br/>
|
||||
系统将只对未分配宿舍的学生执行取消床位申请操作。
|
||||
</div>
|
||||
${confirmMessage}
|
||||
<div style="margin-top: 15px; padding: 10px; background-color: #f0f9ff; border-left: 4px solid #409eff; border-radius: 4px;">
|
||||
<strong>操作说明:</strong><br/>
|
||||
• 已分配宿舍的学生将被跳过<br/>
|
||||
• 仅对未分配宿舍的学生执行取消操作<br/>
|
||||
• 确认后将无法撤销此操作
|
||||
</div>
|
||||
</div>`,
|
||||
'批量取消床位申请',
|
||||
{
|
||||
confirmButtonText: '确认取消',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
dangerouslyUseHTMLString: true
|
||||
})
|
||||
dangerouslyUseHTMLString: true,
|
||||
customClass: 'batch-cancel-bed-dialog'
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
if (!err) {
|
||||
try {
|
||||
// 只对可以取消的学生执行操作
|
||||
const allowedStudentIds = canCancelStudents.map((student) => student.id);
|
||||
|
||||
const res = await service.post('/studentMsg/studentMsg/batchCancelBed', {
|
||||
studentIds: ids.value
|
||||
studentIds: allowedStudentIds
|
||||
});
|
||||
|
||||
if (res && res.code === 200) {
|
||||
await getList();
|
||||
|
||||
// 根据操作结果给出不同的提示
|
||||
if (cannotCancelStudents.length > 0) {
|
||||
ElMessage.success(`批量取消床位成功!成功取消 ${canCancelStudents.length} 名学生,跳过 ${cannotCancelStudents.length} 名已分配宿舍的学生`);
|
||||
} else {
|
||||
ElMessage.success('批量取消床位成功');
|
||||
}
|
||||
} else {
|
||||
ElMessage.error(res?.msg || '批量取消床位失败');
|
||||
}
|
||||
@@ -3154,4 +3224,26 @@ onMounted(() => {
|
||||
:deep(.el-message) {
|
||||
z-index: 4000 !important;
|
||||
}
|
||||
|
||||
/* 批量取消床位申请确认对话框样式 */
|
||||
:deep(.batch-cancel-bed-dialog) {
|
||||
max-width: 600px !important;
|
||||
}
|
||||
|
||||
:deep(.batch-cancel-bed-dialog .el-message-box__content) {
|
||||
max-height: 500px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
:deep(.batch-cancel-bed-dialog .el-message-box__message) {
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
:deep(.batch-cancel-bed-dialog .el-message-box__message div) {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
:deep(.batch-cancel-bed-dialog .el-message-box__message strong) {
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user