提交
This commit is contained in:
1 parent
66faebd8ac
commit
aba267170a
13 files changed
+269
-12
No files matched your search
+11
@@ -22,6 +22,7 @@ import org.dromara.xg.domain.bo.XgDormBedStudentBo;
|
||||
import org.dromara.xg.domain.bo.XgDormBedBatchAllocateBo;
|
||||
import org.dromara.xg.service.IXgDormBedStudentService;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.xg.domain.bo.XgDormBedBatchRecallBo;
|
||||
|
||||
/**
|
||||
* 床位学生分配关系
|
||||
@@ -115,4 +116,14 @@ public class XgDormBedStudentController extends BaseController {
|
||||
return toAjax(xgDormBedStudentService.batchAllocateBedsToCollege(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量收回宿舍床位
|
||||
*/
|
||||
@SaCheckPermission("dormBedStudent:dormBedStudent:edit")
|
||||
@Log(title = "批量收回宿舍床位", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/batchRecall")
|
||||
public R<Void> batchRecallBeds(@Validated(AddGroup.class) @RequestBody XgDormBedBatchRecallBo bo) {
|
||||
return toAjax(xgDormBedStudentService.batchRecallBeds(bo));
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -516,7 +516,7 @@ public class XgStudentMsg extends TenantEntity {
|
||||
private String dormitoryRoom;
|
||||
|
||||
/**
|
||||
* 扩展字段1
|
||||
* 扩展字段1 - 床位id
|
||||
*/
|
||||
private String extField1;
|
||||
|
||||
|
||||
+1
-1
@@ -516,7 +516,7 @@ public class XgStudentMsgBatch extends TenantEntity {
|
||||
private String dormitoryRoom;
|
||||
|
||||
/**
|
||||
* 扩展字段1
|
||||
* 扩展字段1 - 床位id
|
||||
*/
|
||||
private String extField1;
|
||||
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package org.dromara.xg.domain.bo;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 床位批量收回业务对象
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class XgDormBedBatchRecallBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 床位ID列表
|
||||
*/
|
||||
@NotEmpty(message = "床位ID列表不能为空", groups = { AddGroup.class })
|
||||
private List<Long> bedIds;
|
||||
}
|
||||
+1
-1
@@ -517,7 +517,7 @@ public class XgStudentMsgBatchBo extends BaseEntity {
|
||||
private String dormitoryRoom;
|
||||
|
||||
/**
|
||||
* 扩展字段1
|
||||
* 扩展字段1 扩展字段1 - 床位id
|
||||
*/
|
||||
private String extField1;
|
||||
|
||||
|
||||
+1
-1
@@ -517,7 +517,7 @@ public class XgStudentMsgBo extends BaseEntity {
|
||||
private String dormitoryRoom;
|
||||
|
||||
/**
|
||||
* 扩展字段1
|
||||
* 扩展字段1 扩展字段1 - 床位id
|
||||
*/
|
||||
private String extField1;
|
||||
|
||||
|
||||
+1
-1
@@ -623,7 +623,7 @@ public class XgStudentMsgBatchVo implements Serializable {
|
||||
private String dormitoryRoom;
|
||||
|
||||
/**
|
||||
* 扩展字段1
|
||||
* 扩展字段1 扩展字段1 - 床位id
|
||||
*/
|
||||
@ExcelProperty(value = "扩展字段1")
|
||||
private String extField1;
|
||||
|
||||
+1
-1
@@ -623,7 +623,7 @@ public class XgStudentMsgVo implements Serializable {
|
||||
private String dormitoryRoom;
|
||||
|
||||
/**
|
||||
* 扩展字段1
|
||||
* 扩展字段1 扩展字段1 - 床位id
|
||||
*/
|
||||
@ExcelProperty(value = "扩展字段1")
|
||||
private String extField1;
|
||||
|
||||
+10
@@ -9,6 +9,8 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.xg.domain.bo.XgDormBedBatchRecallBo;
|
||||
|
||||
/**
|
||||
* 床位学生分配关系Service接口
|
||||
*
|
||||
@@ -75,4 +77,12 @@ public interface IXgDormBedStudentService {
|
||||
*/
|
||||
Boolean batchAllocateBedsToCollege(
|
||||
XgDormBedBatchAllocateBo bo);
|
||||
|
||||
/**
|
||||
* 批量收回宿舍床位
|
||||
*
|
||||
* @param bo 批量收回请求参数
|
||||
* @return 是否成功
|
||||
*/
|
||||
Boolean batchRecallBeds(XgDormBedBatchRecallBo bo);
|
||||
}
|
||||
+70
@@ -31,6 +31,12 @@ import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.dromara.xg.domain.bo.XgDormBedBatchRecallBo;
|
||||
import org.dromara.xg.mapper.XgStudentMsgMapper;
|
||||
import org.dromara.xg.domain.XgStudentMsg;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
|
||||
/**
|
||||
* 床位学生分配关系Service业务层处理
|
||||
*
|
||||
@@ -46,6 +52,7 @@ public class XgDormBedStudentServiceImpl implements IXgDormBedStudentService {
|
||||
private final XgDormBedMapper xgDormBedMapper;
|
||||
private final XgDormBuildingMapper xgDormBuildingMapper;
|
||||
private final XgDormRoomMapper xgDormRoomMapper;
|
||||
private final XgStudentMsgMapper xgStudentMsgMapper;
|
||||
|
||||
/**
|
||||
* 查询床位学生分配关系
|
||||
@@ -421,4 +428,67 @@ public class XgDormBedStudentServiceImpl implements IXgDormBedStudentService {
|
||||
allocationRecords.add(allocation);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量收回宿舍床位
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean batchRecallBeds(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");
|
||||
List<XgDormBedStudent> activeAssignments = baseMapper.selectList(activeAssignQuery);
|
||||
|
||||
if (activeAssignments.isEmpty()) {
|
||||
return true; // 没有需要处理的数据
|
||||
}
|
||||
|
||||
// 2) 更新分配关系:status=1(已退宿), checkout_time=now, update_time=now,
|
||||
// update_by=loginUserId
|
||||
LambdaUpdateWrapper<XgDormBedStudent> updateAssign = Wrappers.lambdaUpdate();
|
||||
updateAssign.in(XgDormBedStudent::getBedId, bo.getBedIds())
|
||||
.eq(XgDormBedStudent::getStatus, "0")
|
||||
.eq(XgDormBedStudent::getDeleted, "0")
|
||||
.set(XgDormBedStudent::getStatus, "1")
|
||||
.set(XgDormBedStudent::getCheckoutTime, now)
|
||||
.set(XgDormBedStudent::getUpdateTime, now)
|
||||
.set(XgDormBedStudent::getUpdateBy, loginUserId);
|
||||
baseMapper.update(null, updateAssign);
|
||||
|
||||
// 3) 更新床位:bed_status=0(空闲), update_time=now, update_by=loginUserId
|
||||
LambdaUpdateWrapper<XgDormBed> updateBed = Wrappers.lambdaUpdate();
|
||||
updateBed.in(XgDormBed::getId, bo.getBedIds())
|
||||
.eq(XgDormBed::getDeleted, "0")
|
||||
.set(XgDormBed::getBedStatus, "0")
|
||||
.set(XgDormBed::getUpdateTime, now)
|
||||
.set(XgDormBed::getUpdateBy, loginUserId);
|
||||
xgDormBedMapper.update(null, updateBed);
|
||||
|
||||
// 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)
|
||||
.set(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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user