提交
This commit is contained in:
1 parent
7b53c004ab
commit
84016d2f1a
6 files changed
+99
-5
No files matched your search
+11
@@ -143,6 +143,17 @@ public class XgDormBedStudentController extends BaseController {
|
||||
return toAjax(xgDormBedStudentService.batchRecallBeds(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量回收班级分配床位(保留学院分配)
|
||||
*/
|
||||
@SaCheckPermission("dormBedStudent:dormBedStudent:edit")
|
||||
@Log(title = "批量回收班级分配床位", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/batchRecallClassAllocation")
|
||||
public R<Void> batchRecallClassAllocation(@Validated(AddGroup.class) @RequestBody XgDormBedBatchRecallBo bo) {
|
||||
return toAjax(xgDormBedStudentService.batchRecallClassAllocation(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户二级学院的宿舍楼树形结构
|
||||
* 校区-宿舍区-宿舍楼三级结构,校区和宿舍区不可选,只有宿舍楼可以选择
|
||||
|
||||
+8
@@ -96,6 +96,14 @@ public interface IXgDormBedStudentService {
|
||||
*/
|
||||
Boolean batchRecallBeds(XgDormBedBatchRecallBo bo);
|
||||
|
||||
/**
|
||||
* 批量回收班级分配床位(保留学院分配)
|
||||
*
|
||||
* @param bo 批量回收请求参数
|
||||
* @return 是否成功
|
||||
*/
|
||||
Boolean batchRecallClassAllocation(XgDormBedBatchRecallBo bo);
|
||||
|
||||
/**
|
||||
* 获取当前用户二级学院的宿舍楼树形结构
|
||||
* 校区-宿舍区-宿舍楼三级结构,校区和宿舍区不可选,只有宿舍楼可以选择
|
||||
|
||||
+61
-1
@@ -496,7 +496,67 @@ public class XgDormBedStudentServiceImpl implements IXgDormBedStudentService {
|
||||
LambdaUpdateWrapper<XgStudentMsg> updateStudent = Wrappers.lambdaUpdate();
|
||||
updateStudent.in(XgStudentMsg::getId, affectedStudentIds)
|
||||
.eq(XgStudentMsg::getDeleted, 0L)
|
||||
.set(XgStudentMsg::getStudentStatus, "1")
|
||||
.eq(XgStudentMsg::getStudentStatus, "1")
|
||||
.set(XgStudentMsg::getExtField1, null)
|
||||
.set(XgStudentMsg::getDormitoryRoom, null)
|
||||
.set(XgStudentMsg::getDormitoryBuilding, null)
|
||||
.set(XgStudentMsg::getUpdateTime, now)
|
||||
.set(XgStudentMsg::getUpdateBy, loginUserId);
|
||||
xgStudentMsgMapper.update(null, updateStudent);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量回收班级分配床位(保留学院分配)
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean batchRecallClassAllocation(XgDormBedBatchRecallBo bo) {
|
||||
Date now = new Date();
|
||||
Long loginUserId = LoginHelper.getUserId();
|
||||
|
||||
// 1) 查出这些床位当前有效的分配关系(status=0, deleted=0,并且已分配给班级)
|
||||
LambdaQueryWrapper<XgDormBedStudent> activeAssignQuery = Wrappers.lambdaQuery();
|
||||
activeAssignQuery.in(XgDormBedStudent::getBedId, bo.getBedIds())
|
||||
.eq(XgDormBedStudent::getStatus, "0")
|
||||
.eq(XgDormBedStudent::getDeleted, "0")
|
||||
.isNotNull(XgDormBedStudent::getClassId); // 只处理已分配给班级的记录
|
||||
List<XgDormBedStudent> activeAssignments = baseMapper.selectList(activeAssignQuery);
|
||||
|
||||
if (activeAssignments.isEmpty()) {
|
||||
return true; // 没有需要处理的数据
|
||||
}
|
||||
|
||||
// 2) 更新分配关系:清空班级相关字段,但保留学院分配信息
|
||||
LambdaUpdateWrapper<XgDormBedStudent> updateAssign = Wrappers.lambdaUpdate();
|
||||
updateAssign.in(XgDormBedStudent::getBedId, bo.getBedIds())
|
||||
.eq(XgDormBedStudent::getStatus, "0")
|
||||
.eq(XgDormBedStudent::getDeleted, "0")
|
||||
.isNotNull(XgDormBedStudent::getClassId)
|
||||
.set(XgDormBedStudent::getMajorId, null)
|
||||
.set(XgDormBedStudent::getClassId, null)
|
||||
.set(XgDormBedStudent::getStudentId, null)
|
||||
// .set(XgDormBedStudent::getAssignTime, null)
|
||||
.set(XgDormBedStudent::getCheckoutTime, null)
|
||||
.set(XgDormBedStudent::getUpdateTime, now)
|
||||
.set(XgDormBedStudent::getUpdateBy, loginUserId);
|
||||
baseMapper.update(null, updateAssign);
|
||||
|
||||
// 3) XgDormBed 状态保持不变(仍然是已分配给学院的状态)
|
||||
|
||||
// 4) 更新学生信息:找到受影响的studentId,设置 student_status=1,清空
|
||||
// ext_field1/dormitory_room/dormitory_building
|
||||
Set<Long> affectedStudentIds = activeAssignments.stream()
|
||||
.map(XgDormBedStudent::getStudentId)
|
||||
.filter(java.util.Objects::nonNull)
|
||||
.collect(java.util.stream.Collectors.toSet());
|
||||
if (!affectedStudentIds.isEmpty()) {
|
||||
LambdaUpdateWrapper<XgStudentMsg> updateStudent = Wrappers.lambdaUpdate();
|
||||
updateStudent.in(XgStudentMsg::getId, affectedStudentIds)
|
||||
.eq(XgStudentMsg::getDeleted, 0L)
|
||||
.eq(XgStudentMsg::getStudentStatus, "1")
|
||||
.set(XgStudentMsg::getExtField1, null)
|
||||
.set(XgStudentMsg::getDormitoryRoom, null)
|
||||
.set(XgStudentMsg::getDormitoryBuilding, null)
|
||||
|
||||
@@ -73,6 +73,17 @@ export const batchRecallDormBeds = (data: { bedIds: Array<string | number> }) =>
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 批量回收班级分配床位(保留学院分配)
|
||||
*/
|
||||
export const batchRecallClassAllocation = (data: { bedIds: Array<string | number> }) => {
|
||||
return request({
|
||||
url: '/dormBedStudent/dormBedStudent/batchRecallClassAllocation',
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取当前用户二级学院的宿舍楼树形结构
|
||||
* 校区-宿舍区-宿舍楼三级结构,校区和宿舍区不可选,只有宿舍楼可以选择
|
||||
|
||||
@@ -369,7 +369,7 @@ import ElMessageBox from 'element-plus/es/components/message-box/index';
|
||||
import RoomDialog from './components/RoomDialog.vue';
|
||||
import BedDialog from './components/BedDialog.vue';
|
||||
import ClassAllocationDialog from './components/ClassAllocationDialog.vue';
|
||||
import { batchRecallDormBeds } from '@/api/xg/xgss/dormBedStudent/dormBedStudent';
|
||||
import { batchRecallDormBeds, batchRecallClassAllocation } from '@/api/xg/xgss/dormBedStudent/dormBedStudent';
|
||||
|
||||
// const { proxy } = getCurrentInstance();
|
||||
|
||||
@@ -685,7 +685,7 @@ const handleBatchRecall = async () => {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const content = `确认收回选中的 ${selectedBeds.length} 个床位吗?\n\n重要提示:回收后,学生已分配的宿舍都会回收,无法恢复`;
|
||||
const content = `确认收回选中的 ${selectedBeds.length} 个床位的班级分配吗?\n\n重要提示:收回后,床位将从班级分配中移除,但仍保持分配给学院的状态。已分配给学生的宿舍信息将被清空。`;
|
||||
await ElMessageBox.confirm(content, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
@@ -695,8 +695,8 @@ const handleBatchRecall = async () => {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await batchRecallDormBeds({ bedIds: selectedBeds });
|
||||
ElMessage.success('批量收回成功');
|
||||
await batchRecallClassAllocation({ bedIds: selectedBeds });
|
||||
ElMessage.success('批量收回班级分配成功');
|
||||
// 刷新数据
|
||||
selectableRowsCache.value = [];
|
||||
loadRoomData();
|
||||
@@ -812,6 +812,8 @@ const handleCollegeAllocationSuccess = () => {
|
||||
selectableRowsCache.value = [];
|
||||
// 刷新房间和床位数据
|
||||
loadRoomData();
|
||||
// 刷新学生信息树数据
|
||||
getStudentTreeData();
|
||||
// 清空选择状态
|
||||
isUpdatingSelection.value = true;
|
||||
try {
|
||||
|
||||
@@ -813,6 +813,8 @@ const handleCollegeAllocationSuccess = () => {
|
||||
selectableRowsCache.value = [];
|
||||
// 刷新房间和床位数据
|
||||
loadRoomData();
|
||||
// 刷新学生信息树数据
|
||||
getStudentTreeData();
|
||||
// 清空选择状态
|
||||
isUpdatingSelection.value = true;
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user