调宿审批模块-申请调宿权限修改,取消学生权限,由辅导员发起
This commit is contained in:
@@ -28,6 +28,8 @@ public interface DmsManageApplicationMapper extends BaseMapper<DmsManageApplicat
|
|||||||
*/
|
*/
|
||||||
public DmsManageApplication selectDmsManageApplicationById(Long id);
|
public DmsManageApplication selectDmsManageApplicationById(Long id);
|
||||||
|
|
||||||
|
public DmsManageApplication selectDmsManageApplicationByStuNO(String stuNO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询宿舍管理申请列表
|
* 查询宿舍管理申请列表
|
||||||
*
|
*
|
||||||
@@ -67,4 +69,12 @@ public interface DmsManageApplicationMapper extends BaseMapper<DmsManageApplicat
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
int deleteDmsManageApplicationByIds(Long[] ids);
|
int deleteDmsManageApplicationByIds(Long[] ids);
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* 根据学号查询学生宿舍完整信息
|
||||||
|
*
|
||||||
|
* @param stuNo 学号
|
||||||
|
* @return 学生宿舍完整信息
|
||||||
|
*/
|
||||||
|
DomInfo selectStudentDormitoryInfoByStuNo(String stuNo);
|
||||||
|
}
|
||||||
@@ -76,4 +76,11 @@ public interface IDmsManageApplicationService extends IService<DmsManageApplicat
|
|||||||
int deleteDmsManageApplicationById(Long id);
|
int deleteDmsManageApplicationById(Long id);
|
||||||
|
|
||||||
public AjaxResult stuDel(Long[] ids);
|
public AjaxResult stuDel(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取学生宿舍信息
|
||||||
|
* @param studentNo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult getStudentDormitoryInfo(String studentNo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,6 +145,44 @@ public class DmsManageApplicationServiceImpl extends ServiceImpl<DmsManageApplic
|
|||||||
return dmsManageApplicationMapper.selectDmsManageApplicationList(dmsManageApplication);
|
return dmsManageApplicationMapper.selectDmsManageApplicationList(dmsManageApplication);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据学号获取学生当前宿舍信息
|
||||||
|
*
|
||||||
|
* @param studentNo 学号
|
||||||
|
* @return 学生宿舍信息
|
||||||
|
*/
|
||||||
|
public AjaxResult getStudentDormitoryInfo(String studentNo) {
|
||||||
|
try {
|
||||||
|
// 参考现有逻辑中的查询方式
|
||||||
|
QueryWrapper<SrsDormitoryStudent> dormStuQuery = new QueryWrapper<>();
|
||||||
|
dormStuQuery.eq("stu_no", studentNo)
|
||||||
|
.last("limit 1");
|
||||||
|
|
||||||
|
SrsDormitoryStudent dormStu = _dormStuMapper.selectOne(dormStuQuery);
|
||||||
|
if (dormStu == null) {
|
||||||
|
return AjaxResult.error("该学生不在住宿记录表中,可能已退宿");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取宿舍详细信息
|
||||||
|
DmsDormitory dormitory = dormitoryMapper.selectById(dormStu.getDormitoryId());
|
||||||
|
if (dormitory == null) {
|
||||||
|
return AjaxResult.error("未找到学生宿舍信息");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用新添加的Mapper方法直接获取学生宿舍完整信息
|
||||||
|
DomInfo studentDormInfo = dmsManageApplicationMapper.selectStudentDormitoryInfoByStuNo(studentNo);
|
||||||
|
|
||||||
|
if (studentDormInfo == null) {
|
||||||
|
return AjaxResult.error("未找到该学生的宿舍信息");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回学生宿舍完整信息
|
||||||
|
return AjaxResult.success(studentDormInfo);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return AjaxResult.error("查询学生宿舍信息失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增宿舍管理申请
|
* 新增宿舍管理申请
|
||||||
*
|
*
|
||||||
@@ -152,6 +190,84 @@ public class DmsManageApplicationServiceImpl extends ServiceImpl<DmsManageApplic
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
public AjaxResult insertDmsManageApplication(DmsManageApplication dmsManageApplication) {
|
||||||
|
TransactionDefinition def = new DefaultTransactionDefinition();
|
||||||
|
TransactionStatus status = transactionManager.getTransaction(def);
|
||||||
|
try {
|
||||||
|
String username = getUsername();
|
||||||
|
String userType = dmsManageApplication.getGetBy(); // 获取当前用户类型
|
||||||
|
// 只允许辅导员发起申请
|
||||||
|
if (!"teacher".equals(userType)) {
|
||||||
|
throw new Exception("只有辅导员可以发起宿舍申请");
|
||||||
|
}
|
||||||
|
|
||||||
|
QueryWrapper<SrsDormitoryStudent> dormStuQuery = new QueryWrapper<>();
|
||||||
|
dormStuQuery.eq("stu_no", dmsManageApplication.getStuNo())
|
||||||
|
.last("limit 1");
|
||||||
|
|
||||||
|
SrsDormitoryStudent dormStu = _dormStuMapper.selectOne(dormStuQuery);
|
||||||
|
if (dormStu == null) {
|
||||||
|
throw new Exception("该学生已退宿(不在住宿记录表中)");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查该学生是否已存在未完成的申请
|
||||||
|
List<String> isExistStatus = new ArrayList<>();
|
||||||
|
isExistStatus.add("0");
|
||||||
|
isExistStatus.add("1");
|
||||||
|
isExistStatus.add("2");
|
||||||
|
|
||||||
|
QueryWrapper<DmsManageApplication> applyQuery = new QueryWrapper<>();
|
||||||
|
applyQuery.eq("stu_no", dmsManageApplication.getStuNo())
|
||||||
|
.in("status", isExistStatus);
|
||||||
|
|
||||||
|
List<DmsManageApplication> isExist = dmsManageApplicationMapper.selectList(applyQuery);
|
||||||
|
|
||||||
|
if (isExist.size() > 0) {
|
||||||
|
throw new RuntimeException("该学生当前存在未审核完成的流程");
|
||||||
|
}
|
||||||
|
|
||||||
|
QueryWrapper<DmsNewRecord> recordQueryWrapper = new QueryWrapper<>();
|
||||||
|
recordQueryWrapper.eq("stu_no", dmsManageApplication.getStuNo())
|
||||||
|
.orderByDesc("id");
|
||||||
|
List<DmsNewRecord> records = _newRecordMapper.selectList(recordQueryWrapper);
|
||||||
|
|
||||||
|
QueryWrapper<DmsNewTask> taskQuery = new QueryWrapper<>();
|
||||||
|
taskQuery.eq("stu_no", dmsManageApplication.getStuNo())
|
||||||
|
.eq("task_status", "2");
|
||||||
|
List<DmsNewTask> taskList = _taskMapper.selectList(taskQuery);
|
||||||
|
if (taskList.size() != 0) {
|
||||||
|
throw new Exception("该学生当前存在未执行的调宿计划任务,建议调宿任务执行后再申请");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (records.size() == 0) {
|
||||||
|
throw new RuntimeException("该学生没有住宿记录");
|
||||||
|
}
|
||||||
|
|
||||||
|
dmsManageApplication.setCurrentDormId(records.get(0).getRoomId());
|
||||||
|
dmsManageApplication.setCreateTime(getNowDate());
|
||||||
|
// 辅导员发起的申请直接进入下一审批环节(状态为1)
|
||||||
|
dmsManageApplication.setStatus(1L);
|
||||||
|
|
||||||
|
int i1 = dmsManageApplicationMapper.insertDmsManageApplication(dmsManageApplication);
|
||||||
|
DmsApprovalProcess approvalProcess = new DmsApprovalProcess();
|
||||||
|
approvalProcess.setApplyId(dmsManageApplication.getId());
|
||||||
|
approvalProcess.setCreateTime(getNowDate());
|
||||||
|
// 自动设置辅导员审批信息
|
||||||
|
approvalProcess.setFdyTime(getNowDate());
|
||||||
|
approvalProcess.setFdyNo(username);
|
||||||
|
approvalProcess.setFdyStatus("6"); // 辅导员审批通过
|
||||||
|
int i2 = approvalProcessMapper.insert(approvalProcess);
|
||||||
|
if (i1 + i2 != 2) {
|
||||||
|
throw new Exception("操作失败");
|
||||||
|
}
|
||||||
|
transactionManager.commit(status);
|
||||||
|
return AjaxResult.success("宿舍申请已成功发起并通过辅导员审批");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
transactionManager.rollback(status);
|
||||||
|
return AjaxResult.error(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*@Override
|
||||||
public AjaxResult insertDmsManageApplication(DmsManageApplication dmsManageApplication) {
|
public AjaxResult insertDmsManageApplication(DmsManageApplication dmsManageApplication) {
|
||||||
TransactionDefinition def = new DefaultTransactionDefinition();
|
TransactionDefinition def = new DefaultTransactionDefinition();
|
||||||
TransactionStatus status = transactionManager.getTransaction(def);
|
TransactionStatus status = transactionManager.getTransaction(def);
|
||||||
@@ -218,7 +334,7 @@ public class DmsManageApplicationServiceImpl extends ServiceImpl<DmsManageApplic
|
|||||||
return AjaxResult.error(ex.getMessage());
|
return AjaxResult.error(ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改宿舍管理申请
|
* 修改宿舍管理申请
|
||||||
|
|||||||
@@ -29,6 +29,15 @@
|
|||||||
<result property="currBuildingId" column="cBuildingId"/>
|
<result property="currBuildingId" column="cBuildingId"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
<resultMap type="DomInfo" id="StudentDormitoryInfoResult">
|
||||||
|
<result property="stuNo" column="stu_no"/>
|
||||||
|
<result property="stuName" column="stu_name"/>
|
||||||
|
<result property="gender" column="gender"/>
|
||||||
|
<result property="buildingName" column="building_name"/>
|
||||||
|
<result property="roomNo" column="room_no"/>
|
||||||
|
<result property="dormitoryId" column="dormitory_id"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectDmsManageApplicationVo">
|
<sql id="selectDmsManageApplicationVo">
|
||||||
select id, stu_no, time, current_dorm_id, target_dorm_id, reason, type, status, create_time, create_by, update_time, update_by, start_time, end_time, del_flag from dms_manage_application
|
select id, stu_no, time, current_dorm_id, target_dorm_id, reason, type, status, create_time, create_by, update_time, update_by, start_time, end_time, del_flag from dms_manage_application
|
||||||
</sql>
|
</sql>
|
||||||
@@ -102,6 +111,23 @@
|
|||||||
where a.id = #{id}
|
where a.id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectStudentDormitoryInfoByStuNo" parameterType="String" resultMap="StudentDormitoryInfoResult">
|
||||||
|
SELECT
|
||||||
|
s.stu_no,
|
||||||
|
s.name AS stu_name,
|
||||||
|
s.gender,
|
||||||
|
db.name AS building_name,
|
||||||
|
d.room_no,
|
||||||
|
d.id AS dormitory_id
|
||||||
|
FROM srs_student s
|
||||||
|
LEFT JOIN srs_dormitory_student ds ON s.stu_no = ds.stu_no
|
||||||
|
LEFT JOIN dms_dormitory d ON ds.dormitory_id = d.id
|
||||||
|
LEFT JOIN dms_dormitory_floor df ON d.floor_id = df.id
|
||||||
|
LEFT JOIN dms_dormitory_building db ON df.building_id = db.id
|
||||||
|
WHERE s.stu_no = #{stuNo}
|
||||||
|
LIMIT 1
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertDmsManageApplication" parameterType="DmsManageApplication"
|
<insert id="insertDmsManageApplication" parameterType="DmsManageApplication"
|
||||||
useGeneratedKeys="true" keyProperty="id">
|
useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into dms_manage_application
|
insert into dms_manage_application
|
||||||
@@ -199,7 +225,38 @@
|
|||||||
</where>
|
</where>
|
||||||
order by a.id desc
|
order by a.id desc
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectDmsManageApplicationByStuNO" resultType="com.srs.dormitory.domain.DmsManageApplication">
|
||||||
|
SELECT
|
||||||
|
a.*,
|
||||||
|
s.`name` stu_name,
|
||||||
|
p.fdy_no,
|
||||||
|
p.fdy_status,
|
||||||
|
p.fdy_time,
|
||||||
|
p.work_no,
|
||||||
|
p.work_status,
|
||||||
|
p.work_time,
|
||||||
|
p.final_no,
|
||||||
|
p.final_status,
|
||||||
|
p.final_time,
|
||||||
|
cdor.room_no cRoomNo,
|
||||||
|
cb.`name` cBuilding,
|
||||||
|
cb.id cBuildingId,
|
||||||
|
tdor.room_no tRoomNo,
|
||||||
|
tb.`name` tBuilding,
|
||||||
|
tb.id tBuildingId,
|
||||||
|
s.gender
|
||||||
|
FROM
|
||||||
|
dms_manage_application a
|
||||||
|
LEFT JOIN srs_student s ON a.stu_no = s.stu_no
|
||||||
|
LEFT JOIN dms_approval_process p ON p.apply_id = a.id
|
||||||
|
LEFT JOIN dms_dormitory cdor ON cdor.id = a.current_dorm_id
|
||||||
|
LEFT JOIN dms_dormitory_floor cf ON cf.id = cdor.floor_id
|
||||||
|
LEFT JOIN dms_dormitory_building cb ON cb.id = cf.building_id
|
||||||
|
LEFT JOIN dms_dormitory tdor ON tdor.id = a.target_dorm_id
|
||||||
|
LEFT JOIN dms_dormitory_floor tf ON tf.id = tdor.floor_id
|
||||||
|
LEFT JOIN dms_dormitory_building tb ON tb.id = tf.building_id
|
||||||
|
where s.stu_no = #{stuNo}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
</mapper>
|
|
||||||
@@ -11,12 +11,7 @@ import com.srs.system.service.ISysDeptMapService;
|
|||||||
import com.srs.system.service.ISysPostService;
|
import com.srs.system.service.ISysPostService;
|
||||||
import com.srs.web.controller.common.RoleBool;
|
import com.srs.web.controller.common.RoleBool;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
|
||||||
@@ -64,6 +59,8 @@ public class DmsManageApplicationController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/stuChange")
|
@PostMapping("/stuChange")
|
||||||
public AjaxResult stuChange(@RequestBody DmsManageApplication param) {
|
public AjaxResult stuChange(@RequestBody DmsManageApplication param) {
|
||||||
return dmsManageApplicationService.stuChange(param);
|
return dmsManageApplicationService.stuChange(param);
|
||||||
@@ -173,5 +170,15 @@ public class DmsManageApplicationController extends BaseController {
|
|||||||
return dmsManageApplicationService.stuDel(ids);
|
return dmsManageApplicationService.stuDel(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据学号获取学生当前宿舍信息
|
||||||
|
*/
|
||||||
|
@GetMapping("/studentDormitoryInfo")
|
||||||
|
@ApiOperation("根据学号获取学生当前宿舍信息")
|
||||||
|
public AjaxResult getStudentDormitoryInfo(@RequestParam String studentNo) {
|
||||||
|
// 调用service层方法获取学生宿舍信息
|
||||||
|
return dmsManageApplicationService.getStudentDormitoryInfo(studentNo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user