Browse Source

调整床位
3、未分配床位的学生信息
4、批量移出学生

dzx 1 year ago
parent
commit
4a54ec3236

+ 12 - 50
src/main/java/com/xjrsoft/module/room/controller/RoomBedAdjustController.java

@@ -1,34 +1,26 @@
 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 com.xjrsoft.module.room.vo.NoBedStudentPageVo;
 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: 调整床位
@@ -59,55 +51,25 @@ public class RoomBedAdjustController {
     @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);
+        Page<AdjustBedStudentPageVo> page = roomBedService.getBedStudetInfo(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);
+    @GetMapping(value = "/no-bed-student")
+    @ApiOperation(value="未分配床位的学生(分页)")
+    @SaCheckPermission("roomBedAdjust:detail")
+    public RT<PageOutput<NoBedStudentPageVo>> noBedStudent(@Valid AdjustBedPageDto dto){
+        Page<NoBedStudentPageVo> page = roomBedService.getNoBedStudent(new Page<>(dto.getLimit(), dto.getSize()), dto);
+        PageOutput<NoBedStudentPageVo> pageOutput = ConventPage.getPageOutput(page, NoBedStudentPageVo.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));
-
+    @ApiOperation(value = "批量移出学生")
+    @SaCheckPermission("roomBedAdjust:delete")
+    public RT<Boolean> delete(@Valid @RequestBody Long id){
+        return RT.ok(roomBedService.clearStudentInfoByRoomId(id));
     }
 }

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

@@ -14,6 +14,7 @@ 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;
+import com.xjrsoft.module.room.vo.NoBedStudentPageVo;
 import com.xjrsoft.module.room.vo.RoomBedPageVo;
 import com.xjrsoft.module.room.vo.RoomBedVo;
 import org.apache.ibatis.annotations.Mapper;
@@ -72,4 +73,13 @@ public interface RoomBedMapper extends MPJBaseMapper<RoomBed> {
      */
     Page<AdjustBedStudentPageVo> getBedStudentInfo(Page<AdjustBedStudentPageVo> page, @Param("dto") AdjustBedPageDto dto);
 
+
+    /**
+     * 未分配床位的学生信息
+     * @param page
+     * @param dto
+     * @return
+     */
+    Page<NoBedStudentPageVo> getNoBedStudent(Page<NoBedStudentPageVo> page, AdjustBedPageDto dto);
+
 }

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

@@ -14,6 +14,7 @@ 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.DistributeRoomBedPageVo;
+import com.xjrsoft.module.room.vo.NoBedStudentPageVo;
 import com.xjrsoft.module.room.vo.RoomBedPageVo;
 
 import java.util.List;
@@ -38,6 +39,8 @@ public interface IRoomBedService extends MPJBaseService<RoomBed> {
 
     Boolean clearStudentInfo(List<Long> ids);
 
+    Boolean clearStudentInfoByRoomId(Long id);
+
     /**
      * 分配床位,第一步查询班级
      * @param page
@@ -77,5 +80,13 @@ public interface IRoomBedService extends MPJBaseService<RoomBed> {
      * @param dto
      * @return
      */
-    Page<AdjustBedStudentPageVo> getBedStudetBed(Page<AdjustBedStudentPageVo> page, AdjustBedPageDto dto);
+    Page<AdjustBedStudentPageVo> getBedStudetInfo(Page<AdjustBedStudentPageVo> page, AdjustBedPageDto dto);
+
+    /**
+     * 未分配床位的学生信息
+     * @param page
+     * @param dto
+     * @return
+     */
+    Page<NoBedStudentPageVo> getNoBedStudent(Page<NoBedStudentPageVo> page, AdjustBedPageDto dto);
 }

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

@@ -29,6 +29,7 @@ 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.NoBedStudentPageVo;
 import com.xjrsoft.module.room.vo.RoomBedPageVo;
 import com.xjrsoft.module.room.vo.RoomBedVo;
 import com.xjrsoft.module.room.vo.RoomClassCountVo;
@@ -75,6 +76,18 @@ public class RoomBedServiceImpl extends MPJBaseServiceImpl<RoomBedMapper, RoomBe
         return true;
     }
 
+    @Override
+    public Boolean clearStudentInfoByRoomId(Long id) {
+        List<RoomBed> bedList = roomBedMapper.selectList(
+                MPJWrappers.<RoomBed>lambdaJoin().eq(RoomBed::getRoomId, id)
+        );
+        for (RoomBed roomBed : bedList) {
+            roomBed.setStudentUserId(null);
+            roomBedMapper.updateById(roomBed);
+        }
+        return true;
+    }
+
     @Override
     public Page<DistributeClassPageVo> getDistributeClassInfo(Page<DistributeClassPageVo> page, DistributeClassPageDto dto) {
         return roomBedMapper.getDistributeClassInfo(page, dto);
@@ -203,7 +216,12 @@ public class RoomBedServiceImpl extends MPJBaseServiceImpl<RoomBedMapper, RoomBe
     }
 
     @Override
-    public Page<AdjustBedStudentPageVo> getBedStudetBed(Page<AdjustBedStudentPageVo> page, AdjustBedPageDto dto) {
+    public Page<AdjustBedStudentPageVo> getBedStudetInfo(Page<AdjustBedStudentPageVo> page, AdjustBedPageDto dto) {
         return roomBedMapper.getBedStudentInfo(page, dto);
     }
+
+    @Override
+    public Page<NoBedStudentPageVo> getNoBedStudent(Page<NoBedStudentPageVo> page, AdjustBedPageDto dto) {
+        return roomBedMapper.getNoBedStudent(page, dto);
+    }
 }

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

@@ -46,4 +46,8 @@ public class AdjustBedStudentPageVo {
     @ApiModelProperty("是否是混合寝室【一个寝室有多个班级的学生】(1:是 0:否)")
     private Integer isMax;
 
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("寝室id")
+    private String roomId;
+
 }

+ 33 - 0
src/main/java/com/xjrsoft/module/room/vo/NoBedStudentPageVo.java

@@ -0,0 +1,33 @@
+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 NoBedStudentPageVo {
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("学生id")
+    private String userId;
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("入住性别")
+    private String genderCn;
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("班级名称")
+    private String className;
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("学生名称")
+    private String studentName;
+
+}

+ 13 - 1
src/main/resources/mapper/room/RoomBedMapper.xml

@@ -146,7 +146,7 @@
     </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
+        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,t2.id as room_id 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
@@ -156,4 +156,16 @@
         ORDER BY t2.sort_code,t1.sort_code
     </select>
 
+    <select id="getNoBedStudent" parameterType="com.xjrsoft.module.room.dto.AdjustBedPageDto" resultType="com.xjrsoft.module.room.vo.NoBedStudentPageVo">
+        SELECT t1.user_id, t2.name AS student_name,REPLACE(REPLACE(t2.gender,1,'男'),2,'女') as gender_cn,t4.name AS class_name FROM base_student t1
+        INNER 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
+        WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
+        AND t3.stduy_status = 'FB3001'
+        AND t1.user_id NOT IN (
+            SELECT student_user_id FROM room_bed WHERE delete_mark = 0 AND student_user_id IS NOT NULL
+        )
+    </select>
+
 </mapper>