Browse Source

调整床位
1、左边班级学生列表
2、右边床位学生列表

dzx 1 year ago
parent
commit
796969575e

+ 113 - 0
src/main/java/com/xjrsoft/module/room/controller/RoomBedAdjustController.java

@@ -0,0 +1,113 @@
+package com.xjrsoft.module.room.controller;
+
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.xjrsoft.common.model.result.RT;
+import com.xjrsoft.common.page.ConventPage;
+import com.xjrsoft.common.page.PageOutput;
+import com.xjrsoft.module.room.dto.AddRoomBedDto;
+import com.xjrsoft.module.room.dto.AdjustBedPageDto;
+import com.xjrsoft.module.room.dto.AdjustClassPageDto;
+import com.xjrsoft.module.room.dto.UpdateRoomBedDto;
+import com.xjrsoft.module.room.entity.RoomBed;
+import com.xjrsoft.module.room.service.IRoomBedService;
+import com.xjrsoft.module.room.vo.AdjustBedClassPageVo;
+import com.xjrsoft.module.room.vo.AdjustBedStudentPageVo;
+import com.xjrsoft.module.room.vo.RoomBedVo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+import java.util.List;
+
+/**
+* @title: 调整床位
+* @Author dzx
+* @Date: 2023-12-30
+* @Version 1.0
+*/
+@RestController
+@RequestMapping("/room" + "/roomBedAdjust")
+@Api(value = "/room"  + "/roomBedAdjust",tags = "调整床位代码")
+@AllArgsConstructor
+public class RoomBedAdjustController {
+
+
+    private final IRoomBedService roomBedService;
+
+    @GetMapping(value = "/class-student")
+    @ApiOperation(value="需要分配/调整床位的学生(分页)")
+    @SaCheckPermission("roomBedAdjust:detail")
+    public RT<PageOutput<AdjustBedClassPageVo>> classStudent(@Valid AdjustClassPageDto dto){
+
+        Page<AdjustBedClassPageVo> page = roomBedService.getClassStudetBed(new Page<>(dto.getLimit(), dto.getSize()), dto);
+        PageOutput<AdjustBedClassPageVo> pageOutput = ConventPage.getPageOutput(page, AdjustBedClassPageVo.class);
+        return RT.ok(pageOutput);
+    }
+
+    @GetMapping(value = "/bed-student")
+    @ApiOperation(value="床位学生列表(分页)")
+    @SaCheckPermission("roomBedAdjust:detail")
+    public RT<PageOutput<AdjustBedStudentPageVo>> distributeClassPage(@Valid AdjustBedPageDto dto){
+        Page<AdjustBedStudentPageVo> page = roomBedService.getBedStudetBed(new Page<>(dto.getLimit(), dto.getSize()), dto);
+        PageOutput<AdjustBedStudentPageVo> pageOutput = ConventPage.getPageOutput(page, AdjustBedStudentPageVo.class);
+        return RT.ok(pageOutput);
+    }
+
+    @GetMapping(value = "/distribute-roombed-page")
+    @ApiOperation(value="分配床位寝室床位列表(分页)")
+    @SaCheckPermission("roombed:detail")
+    public RT<PageOutput<AdjustBedStudentPageVo>> noBedStudent(@Valid AdjustBedPageDto dto){
+        Page<AdjustBedStudentPageVo> page = roomBedService.getBedStudetBed(new Page<>(dto.getLimit(), dto.getSize()), dto);
+        PageOutput<AdjustBedStudentPageVo> pageOutput = ConventPage.getPageOutput(page, AdjustBedStudentPageVo.class);
+        return RT.ok(pageOutput);
+    }
+
+    @GetMapping(value = "/info")
+    @ApiOperation(value="根据id查询寝室床位信息")
+    @SaCheckPermission("roombed:detail")
+    public RT<RoomBedVo> info(@RequestParam Long id){
+        RoomBed roomBed = roomBedService.getById(id);
+        if (roomBed == null) {
+           return RT.error("找不到此数据!");
+        }
+        return RT.ok(BeanUtil.toBean(roomBed, RoomBedVo.class));
+    }
+
+
+    @PostMapping
+    @ApiOperation(value = "新增寝室床位")
+    @SaCheckPermission("roombed:add")
+    public RT<Boolean> add(@Valid @RequestBody AddRoomBedDto dto){
+        RoomBed roomBed = BeanUtil.toBean(dto, RoomBed.class);
+        boolean isSuccess = roomBedService.save(roomBed);
+    return RT.ok(isSuccess);
+    }
+
+    @PutMapping
+    @ApiOperation(value = "修改寝室床位")
+    @SaCheckPermission("roombed:edit")
+    public RT<Boolean> update(@Valid @RequestBody UpdateRoomBedDto dto){
+
+        RoomBed roomBed = BeanUtil.toBean(dto, RoomBed.class);
+        return RT.ok(roomBedService.updateById(roomBed));
+
+    }
+    @DeleteMapping
+    @ApiOperation(value = "删除寝室床位")
+    @SaCheckPermission("roombed:delete")
+    public RT<Boolean> delete(@Valid @RequestBody List<Long> ids){
+        return RT.ok(roomBedService.clearStudentInfo(ids));
+
+    }
+}

+ 25 - 0
src/main/java/com/xjrsoft/module/room/dto/AdjustBedPageDto.java

@@ -0,0 +1,25 @@
+package com.xjrsoft.module.room.dto;
+
+import com.xjrsoft.common.page.PageInput;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+
+/**
+* @title: 寝室床位分页查询入参
+* @Author dzx
+* @Date: 2023-12-27
+* @Version 1.0
+*/
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class AdjustBedPageDto extends PageInput {
+
+    @ApiModelProperty("年级id")
+    public Long gradeId;
+
+    @ApiModelProperty("年级id")
+    public Long classId;
+
+}

+ 25 - 0
src/main/java/com/xjrsoft/module/room/dto/AdjustClassPageDto.java

@@ -0,0 +1,25 @@
+package com.xjrsoft.module.room.dto;
+
+import com.xjrsoft.common.page.PageInput;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+
+/**
+* @title: 寝室床位分页查询入参
+* @Author dzx
+* @Date: 2023-12-27
+* @Version 1.0
+*/
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class AdjustClassPageDto extends PageInput {
+
+    @ApiModelProperty("年级id")
+    public Long gradeId;
+
+    @ApiModelProperty("年级id")
+    public Long classId;
+
+}

+ 1 - 19
src/main/java/com/xjrsoft/module/room/dto/DistributeClassPageDto.java

@@ -16,28 +16,10 @@ import lombok.EqualsAndHashCode;
 @EqualsAndHashCode(callSuper = false)
 public class DistributeClassPageDto extends PageInput {
 
-    @ApiModelProperty("楼栋id")
-    public Long officeBuildId;
-
-    @ApiModelProperty("楼层")
-    public Integer floorNumber;
-
-
-    @ApiModelProperty("寝室id")
-    public Long roomId;
-
-    @ApiModelProperty("入住性别")
-    public String gender;
-
-    @ApiModelProperty("寝室id")
+    @ApiModelProperty("年级id")
     public Long gradeId;
 
     @ApiModelProperty("年级id")
     public Long classId;
 
-    @ApiModelProperty("寝室id")
-    public String studentName;
-
-    @ApiModelProperty("学号")
-    public String studentId;
 }

+ 20 - 0
src/main/java/com/xjrsoft/module/room/mapper/RoomBedMapper.java

@@ -2,11 +2,15 @@ package com.xjrsoft.module.room.mapper;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseMapper;
+import com.xjrsoft.module.room.dto.AdjustBedPageDto;
+import com.xjrsoft.module.room.dto.AdjustClassPageDto;
 import com.xjrsoft.module.room.dto.DistributeClassPageDto;
 import com.xjrsoft.module.room.dto.DistributeRoomBedDto;
 import com.xjrsoft.module.room.dto.DistributeRoomBedPageDto;
 import com.xjrsoft.module.room.dto.RoomBedPageDto;
 import com.xjrsoft.module.room.entity.RoomBed;
+import com.xjrsoft.module.room.vo.AdjustBedClassPageVo;
+import com.xjrsoft.module.room.vo.AdjustBedStudentPageVo;
 import com.xjrsoft.module.room.vo.DistributeClassPageVo;
 import com.xjrsoft.module.room.vo.DistributeResultListVo;
 import com.xjrsoft.module.room.vo.DistributeRoomBedPageVo;
@@ -52,4 +56,20 @@ public interface RoomBedMapper extends MPJBaseMapper<RoomBed> {
      */
     List<DistributeResultListVo> getDistributeResult(@Param("dto") DistributeRoomBedDto dto);
 
+    /**
+     * 调整床位,左边的班级学生信息
+     * @param page
+     * @param dto
+     * @return
+     */
+    Page<AdjustBedClassPageVo> getClassStudetBed(Page<AdjustBedClassPageVo> page, @Param("dto") AdjustClassPageDto dto);
+
+    /**
+     * 调整床位,右边的床位学生信息
+     * @param page
+     * @param dto
+     * @return
+     */
+    Page<AdjustBedStudentPageVo> getBedStudentInfo(Page<AdjustBedStudentPageVo> page, @Param("dto") AdjustBedPageDto dto);
+
 }

+ 1 - 1
src/main/java/com/xjrsoft/module/room/mapper/RoomBedRecordMapper.java

@@ -12,5 +12,5 @@ import org.apache.ibatis.annotations.Mapper;
 */
 @Mapper
 public interface RoomBedRecordMapper extends MPJBaseMapper<RoomBedRecord> {
-
+    Integer getMaxSortCode();
 }

+ 19 - 1
src/main/java/com/xjrsoft/module/room/service/IRoomBedService.java

@@ -2,14 +2,17 @@ package com.xjrsoft.module.room.service;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseService;
+import com.xjrsoft.module.room.dto.AdjustBedPageDto;
+import com.xjrsoft.module.room.dto.AdjustClassPageDto;
 import com.xjrsoft.module.room.dto.DistributeClassPageDto;
 import com.xjrsoft.module.room.dto.DistributeRoomBedDto;
 import com.xjrsoft.module.room.dto.DistributeRoomBedPageDto;
 import com.xjrsoft.module.room.dto.RoomBedPageDto;
 import com.xjrsoft.module.room.entity.RoomBed;
+import com.xjrsoft.module.room.vo.AdjustBedClassPageVo;
+import com.xjrsoft.module.room.vo.AdjustBedStudentPageVo;
 import com.xjrsoft.module.room.vo.DistributeClassPageVo;
 import com.xjrsoft.module.room.vo.DistributeResultClassVo;
-import com.xjrsoft.module.room.vo.DistributeResultListVo;
 import com.xjrsoft.module.room.vo.DistributeRoomBedPageVo;
 import com.xjrsoft.module.room.vo.RoomBedPageVo;
 
@@ -60,4 +63,19 @@ public interface IRoomBedService extends MPJBaseService<RoomBed> {
      */
     List<DistributeResultClassVo> getDistributeResult(DistributeRoomBedDto dto);
 
+    /**
+     * 调整床位,左边的班级学生信息
+     * @param page
+     * @param dto
+     * @return
+     */
+    Page<AdjustBedClassPageVo> getClassStudetBed(Page<AdjustBedClassPageVo> page, AdjustClassPageDto dto);
+
+    /**
+     * 调整床位,右边的床位学生信息
+     * @param page
+     * @param dto
+     * @return
+     */
+    Page<AdjustBedStudentPageVo> getBedStudetBed(Page<AdjustBedStudentPageVo> page, AdjustBedPageDto dto);
 }

+ 34 - 4
src/main/java/com/xjrsoft/module/room/service/impl/RoomBedServiceImpl.java

@@ -10,6 +10,8 @@ import com.xjrsoft.common.enums.DeleteMark;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.mapper.BaseClassMapper;
+import com.xjrsoft.module.room.dto.AdjustBedPageDto;
+import com.xjrsoft.module.room.dto.AdjustClassPageDto;
 import com.xjrsoft.module.room.dto.DistributeClassPageDto;
 import com.xjrsoft.module.room.dto.DistributeRoomBedDto;
 import com.xjrsoft.module.room.dto.DistributeRoomBedPageDto;
@@ -21,6 +23,8 @@ import com.xjrsoft.module.room.mapper.RoomBedMapper;
 import com.xjrsoft.module.room.mapper.RoomBedRecordMapper;
 import com.xjrsoft.module.room.mapper.RoomMapper;
 import com.xjrsoft.module.room.service.IRoomBedService;
+import com.xjrsoft.module.room.vo.AdjustBedClassPageVo;
+import com.xjrsoft.module.room.vo.AdjustBedStudentPageVo;
 import com.xjrsoft.module.room.vo.DistributeClassPageVo;
 import com.xjrsoft.module.room.vo.DistributeResultClassVo;
 import com.xjrsoft.module.room.vo.DistributeResultListVo;
@@ -134,12 +138,27 @@ public class RoomBedServiceImpl extends MPJBaseServiceImpl<RoomBedMapper, RoomBe
             classDistributeBedNumber.put(classId, distributeBedNumber);
             classStudent.put(classId, studentList.size());
         }
+        Map<Long, Long> classGradeMap = new HashMap<>();
+        baseClassMapper.selectList(
+            MPJWrappers.<BaseClass>lambdaJoin().in(BaseClass::getId, dto.getClassIds())
+        ).forEach((baseClass)->{
+            classGradeMap.put(baseClass.getId(), baseClass.getGradeId());
+        });
         //插入记录表 room_bed_record
-        classStudent.forEach((classId, studentCount)->{
+        Integer maxSortCode = roomBedRecordMapper.getMaxSortCode();
+        for (Long classId : classGradeMap.keySet()) {
+            maxSortCode ++;
+            Integer studentCount = classStudent.get(classId);
             RoomBedRecord record = new RoomBedRecord();
-//            record.setClassId();
-//            roomBedRecordMapper.insert();
-        });
+            record.setClassId(classId);
+            record.setGradeId(classGradeMap.get(classId));
+            record.setCreateDate(modifyDate);
+            record.setSortCode(maxSortCode);
+            record.setNeedBedNumber(classStudent.get(classId));
+            record.setDistributeBedNumber(classDistributeBedNumber.get(classId));
+            record.setDeleteMark(DeleteMark.NODELETE.getCode());
+            roomBedRecordMapper.insert(record);
+        }
 
         //查询每个寝室住入的班级数量,大于2的设置为混合寝室
         List<RoomClassCountVo> classCountVoList = roomMapper.getRoomClassCount(dto.getRoomIds());
@@ -176,4 +195,15 @@ public class RoomBedServiceImpl extends MPJBaseServiceImpl<RoomBedMapper, RoomBe
         }
         return result;
     }
+
+    @Override
+    public Page<AdjustBedClassPageVo> getClassStudetBed(Page<AdjustBedClassPageVo> page, AdjustClassPageDto dto) {
+        Page<AdjustBedClassPageVo> result = roomBedMapper.getClassStudetBed(page, dto);
+        return result;
+    }
+
+    @Override
+    public Page<AdjustBedStudentPageVo> getBedStudetBed(Page<AdjustBedStudentPageVo> page, AdjustBedPageDto dto) {
+        return roomBedMapper.getBedStudentInfo(page, dto);
+    }
 }

+ 48 - 0
src/main/java/com/xjrsoft/module/room/vo/AdjustBedClassPageVo.java

@@ -0,0 +1,48 @@
+package com.xjrsoft.module.room.vo;
+
+import com.alibaba.excel.annotation.write.style.ContentStyle;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+/**
+* @title: 寝室床位分页列表出参
+* @Author dzx
+* @Date: 2023-12-27
+* @Version 1.0
+*/
+@Data
+public class AdjustBedClassPageVo {
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("学生id")
+    private String userId;
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("班级id")
+    private String classId;
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("班级名称")
+    private String className;
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("学生名称")
+    private String studentName;
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("入住性别")
+    private String genderCn;
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("楼栋名称")
+    private String buildName;
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("寝室名称")
+    private String roomName;
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("床位")
+    private String bedNumber;
+}

+ 49 - 0
src/main/java/com/xjrsoft/module/room/vo/AdjustBedStudentPageVo.java

@@ -0,0 +1,49 @@
+package com.xjrsoft.module.room.vo;
+
+import com.alibaba.excel.annotation.write.style.ContentStyle;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+/**
+* @title: 寝室床位分页列表出参
+* @Author dzx
+* @Date: 2023-12-27
+* @Version 1.0
+*/
+@Data
+public class AdjustBedStudentPageVo {
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("床位id")
+    private String id;
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("楼栋名称")
+    private String buildName;
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("寝室名称")
+    private String roomName;
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("入住性别")
+    private String genderCn;
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("床位")
+    private String bedNumber;
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("学生名称")
+    private String studentName;
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("寝室长id(null即为未设置寝室长,非空即为设置了寝室长)")
+    private String studentUserId;
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("是否是混合寝室【一个寝室有多个班级的学生】(1:是 0:否)")
+    private Integer isMax;
+
+}

+ 30 - 2
src/main/resources/mapper/room/RoomBedMapper.xml

@@ -50,7 +50,7 @@
         LEFT JOIN base_student_school_roll c2 ON c1.user_id = c2.user_id
         LEFT JOIN xjr_dictionary_detail c3 ON c2.stduy_status = c3.code AND c3.item_id = 2023000000000000030
         WHERE c1.delete_mark = 0 AND c2.delete_mark = 0
-        AND c3.code = 'FB3001' AND c2.class_id = t1.id) AS need_count,(
+        AND c3.code = 'FB3002' AND c2.class_id = t1.id) AS need_count,(
         SELECT COUNT(*) FROM room_bed a1
         LEFT JOIN base_student_school_roll a2 ON a1.student_user_id = a2.user_id
         WHERE a1.delete_mark = 0 AND a2.delete_mark = 0
@@ -64,7 +64,7 @@
         LEFT JOIN base_student_school_roll c2 ON c1.user_id = c2.user_id
         LEFT JOIN xjr_dictionary_detail c3 ON c2.stduy_status = c3.code AND c3.item_id = 2023000000000000030
         WHERE c1.delete_mark = 0 AND c2.delete_mark = 0
-        AND c3.code = 'FB3001' AND c2.class_id = t1.id
+        AND c3.code = 'FB3002' AND c2.class_id = t1.id
         ) >
         (
         SELECT COUNT(*) FROM room_bed a1
@@ -72,6 +72,12 @@
         WHERE a1.delete_mark = 0 AND a2.delete_mark = 0
         AND a2.class_id = t1.id
         )
+        <if test="dto.gradeId != null">
+            and t1.grade_id = #{dto.gradeId}
+        </if>
+        <if test="dto.classId != null">
+            and t1.class_id = #{dto.classId}
+        </if>
     </select>
     <select id="getDistributeRoomBedInfo" parameterType="com.xjrsoft.module.room.dto.DistributeRoomBedPageDto" resultType="com.xjrsoft.module.room.vo.DistributeRoomBedPageVo">
         SELECT t1.id,t1.sort_code,t2.name AS build_name,t1.floor_number,t1.room_name,t4.name AS gender_cn, t3.name AS check_in_status_cn,
@@ -128,4 +134,26 @@
         ORDER BY t2.sort_code,t1.sort_code
     </select>
 
+    <select id="getClassStudetBed" resultType="com.xjrsoft.module.room.vo.AdjustBedClassPageVo">
+        SELECT t1.user_id,t4.id AS class_id, t4.name AS class_name,t2.name AS student_name,REPLACE(REPLACE(t2.gender,1,'男'),2,'女') AS gender_cn,t7.name AS build_name,t6.room_name,t5.bed_number FROM base_student t1
+        LEFT JOIN xjr_user t2 ON t1.user_id = t2.id
+        LEFT JOIN base_student_school_roll t3 ON t1.user_id = t3.user_id
+        LEFT JOIN base_class t4 ON t3.class_id = t4.id
+        LEFT JOIN room_bed t5 ON t5.student_user_id = t1.user_id
+        LEFT JOIN room t6 ON t5.room_id = t6.id
+        LEFT JOIN base_office_build t7 ON t6.office_build_id = t7.id
+        WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
+    </select>
+
+    <select id="getBedStudentInfo" parameterType="com.xjrsoft.module.room.dto.AdjustBedPageDto" resultType="com.xjrsoft.module.room.vo.AdjustBedStudentPageVo">
+        SELECT t1.id,t3.name AS build_name,t2.room_name,t5.name AS gender_cn,t1.bed_number,t4.name AS student_name,t6.student_user_id,t2.is_max FROM room_bed t1
+        LEFT JOIN room t2 ON t1.room_id = t2.id
+        LEFT JOIN base_office_build t3 ON t2.office_build_id = t3.id
+        LEFT JOIN xjr_user t4 ON t1.student_user_id = t4.id
+        LEFT JOIN xjr_dictionary_detail t5 ON t2.gender = t5.code AND t5.item_id = 2023000000000000004
+        LEFT JOIN room_student_appoint t6 ON t6.room_bed_id = t1.id
+        WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
+        ORDER BY t2.sort_code,t1.sort_code
+    </select>
+
 </mapper>

+ 9 - 0
src/main/resources/mapper/room/RoomBedRecordMapper.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.xjrsoft.module.room.mapper.RoomBedRecordMapper">
+    <select id="getMaxSortCode" resultType="java.lang.Integer">
+        SELECT IFNULL(MAX(sort_code),0) FROM room_bed_record WHERE delete_mark = 0
+    </select>
+</mapper>