Quellcode durchsuchen

床位管理模块

dzx vor 1 Jahr
Ursprung
Commit
c153b77402

+ 21 - 28
src/main/java/com/xjrsoft/module/room/controller/RoomBedController.java

@@ -1,41 +1,38 @@
 package com.xjrsoft.module.room.controller;
 
+import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.xjrsoft.common.constant.GlobalConstant;
-import com.baomidou.mybatisplus.core.toolkit.StringPool;
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.support.ExcelTypeEnum;
+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.common.model.result.RT;
-import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.room.dto.AddRoomBedDto;
-import com.xjrsoft.module.room.dto.UpdateRoomBedDto;
-import cn.dev33.satoken.annotation.SaCheckPermission;
-import com.alibaba.excel.EasyExcel;
-import org.springframework.web.multipart.MultipartFile;
-import java.io.IOException;
-import com.alibaba.excel.support.ExcelTypeEnum;
-import org.springframework.http.ResponseEntity;
-import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
-
 import com.xjrsoft.module.room.dto.RoomBedPageDto;
+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.RoomBedPageVo;
-
 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.*;
+import org.springframework.http.ResponseEntity;
+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 org.springframework.web.multipart.MultipartFile;
 
 import javax.validation.Valid;
-import javax.validation.constraints.NotNull;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -58,11 +55,7 @@ public class RoomBedController {
     @SaCheckPermission("roombed:detail")
     public RT<PageOutput<RoomBedPageVo>> page(@Valid RoomBedPageDto dto){
 
-        LambdaQueryWrapper<RoomBed> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper
-                    .orderByDesc(RoomBed::getId)
-                .select(RoomBed.class,x -> VoToColumnUtil.fieldsToColumns(RoomBedPageVo.class).contains(x.getProperty()));
-        IPage<RoomBed> page = roomBedService.page(ConventPage.getPage(dto), queryWrapper);
+        Page<RoomBedPageVo> page = roomBedService.getPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
         PageOutput<RoomBedPageVo> pageOutput = ConventPage.getPageOutput(page, RoomBedPageVo.class);
         return RT.ok(pageOutput);
     }
@@ -102,7 +95,7 @@ public class RoomBedController {
     @ApiOperation(value = "删除寝室床位")
     @SaCheckPermission("roombed:delete")
     public RT<Boolean> delete(@Valid @RequestBody List<Long> ids){
-        return RT.ok(roomBedService.removeBatchByIds(ids));
+        return RT.ok(roomBedService.clearStudentInfo(ids));
 
     }
     @PostMapping("/import")

+ 23 - 0
src/main/java/com/xjrsoft/module/room/dto/RoomBedPageDto.java

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

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

@@ -1,10 +1,16 @@
 package com.xjrsoft.module.room.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseMapper;
+import com.xjrsoft.module.room.dto.RoomBedPageDto;
+import com.xjrsoft.module.room.dto.RoomPageDto;
 import com.xjrsoft.module.room.entity.RoomBed;
+import com.xjrsoft.module.room.vo.RoomBedPageVo;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+
 /**
 * @title: 寝室床位
 * @Author dzx
@@ -18,4 +24,14 @@ public interface RoomBedMapper extends MPJBaseMapper<RoomBed> {
      * @return
      */
     Integer getMaxSortCode();
+
+    /**
+     * 分页查询
+     * @param page
+     * @param dto
+     * @return
+     */
+    Page<RoomBedPageVo> getPage(Page<RoomBedPageVo> page, RoomBedPageDto dto);
+
+
 }

+ 15 - 2
src/main/java/com/xjrsoft/module/room/service/IRoomBedService.java

@@ -1,9 +1,11 @@
 package com.xjrsoft.module.room.service;
 
-import com.baomidou.mybatisplus.extension.service.IService;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseService;
+import com.xjrsoft.module.room.dto.RoomBedPageDto;
 import com.xjrsoft.module.room.entity.RoomBed;
-import lombok.Data;
+import com.xjrsoft.module.room.vo.RoomBedPageVo;
+
 import java.util.List;
 
 /**
@@ -14,4 +16,15 @@ import java.util.List;
 */
 
 public interface IRoomBedService extends MPJBaseService<RoomBed> {
+
+    /**
+     * 分页查询
+     * @param page
+     * @param dto
+     * @return
+     */
+    Page<RoomBedPageVo> getPage(Page<RoomBedPageVo> page, RoomBedPageDto dto);
+
+
+    Boolean clearStudentInfo(List<Long> ids);
 }

+ 22 - 0
src/main/java/com/xjrsoft/module/room/service/impl/RoomBedServiceImpl.java

@@ -1,12 +1,18 @@
 package com.xjrsoft.module.room.service.impl;
 
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseServiceImpl;
+import com.xjrsoft.module.room.dto.RoomBedPageDto;
 import com.xjrsoft.module.room.entity.RoomBed;
 import com.xjrsoft.module.room.mapper.RoomBedMapper;
 import com.xjrsoft.module.room.service.IRoomBedService;
+import com.xjrsoft.module.room.vo.RoomBedPageVo;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
 * @title: 寝室床位
 * @Author dzx
@@ -16,4 +22,20 @@ import org.springframework.stereotype.Service;
 @Service
 @AllArgsConstructor
 public class RoomBedServiceImpl extends MPJBaseServiceImpl<RoomBedMapper, RoomBed> implements IRoomBedService {
+    private final RoomBedMapper roomBedMapper;
+    @Override
+    public Page<RoomBedPageVo> getPage(Page<RoomBedPageVo> page, RoomBedPageDto dto) {
+        Page<RoomBedPageVo> result = roomBedMapper.getPage(page, dto);
+        return result;
+    }
+
+    @Override
+    public Boolean clearStudentInfo(List<Long> ids) {
+        for (Long id : ids) {
+            RoomBed roomBed = roomBedMapper.selectById(id);
+            roomBed.setStudentUserId(null);
+            roomBedMapper.updateById(roomBed);
+        }
+        return true;
+    }
 }

+ 64 - 72
src/main/java/com/xjrsoft/module/room/vo/RoomBedPageVo.java

@@ -1,19 +1,10 @@
 package com.xjrsoft.module.room.vo;
 
 import com.alibaba.excel.annotation.ExcelProperty;
-import com.alibaba.excel.annotation.ExcelIgnore;
 import com.alibaba.excel.annotation.write.style.ContentStyle;
-import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
-import com.xjrsoft.common.annotation.Trans;
-import com.xjrsoft.common.enums.TransType;
-import java.time.LocalTime;
-import java.time.LocalDateTime;
-import java.math.BigDecimal;
-import java.util.Date;
-
 /**
 * @title: 寝室床位分页列表出参
 * @Author dzx
@@ -31,88 +22,89 @@ public class RoomBedPageVo {
     @ApiModelProperty("主键编号")
     private String id;
     /**
-    * 创建人
-    */
+     * 序号
+     */
     @ContentStyle(dataFormat = 49)
-    @ExcelProperty("创建人")
-    @ApiModelProperty("创建人")
-    private Long createUserId;
+    @ExcelProperty("序号")
+    @ApiModelProperty("序号")
+    private Integer sortCode;
+
     /**
-    * 创建时间
-    */
+     * 楼栋名称
+     */
     @ContentStyle(dataFormat = 49)
-    @ExcelProperty("创建时间")
-    @ApiModelProperty("创建时间")
-    private Date createDate;
+    @ExcelProperty("楼栋名称")
+    @ApiModelProperty("楼栋名称")
+    private String buildName;
+
     /**
-    * 修改人
-    */
+     * 楼层
+     */
     @ContentStyle(dataFormat = 49)
-    @ExcelProperty("修改人")
-    @ApiModelProperty("修改人")
-    private Long modifyUserId;
+    @ExcelProperty("楼层")
+    @ApiModelProperty("楼层")
+    private Integer floorNumber;
     /**
-    * 修改时间
-    */
+     * 寝室名称
+     */
     @ContentStyle(dataFormat = 49)
-    @ExcelProperty("修改时间")
-    @ApiModelProperty("修改时间")
-    private Date modifyDate;
+    @ExcelProperty("寝室名称")
+    @ApiModelProperty("寝室名称")
+    private String roomName;
+
     /**
-    * 删除标记
-    */
+     * 床位号
+     */
     @ContentStyle(dataFormat = 49)
-    @ExcelProperty("删除标记")
-    @ApiModelProperty("删除标记")
-    private Integer deleteMark;
+    @ExcelProperty("床位号")
+    @ApiModelProperty("床位号")
+    private Integer bedNumber;
+
     /**
-    * 有效标志
-    */
+     * 学生姓名
+     */
     @ContentStyle(dataFormat = 49)
-    @ExcelProperty("有效标志")
-    @ApiModelProperty("有效标志")
-    private Integer enabledMark;
-    /**
-    * 序号
-    */
-    @ContentStyle(dataFormat = 49)
-    @ExcelProperty("序号")
-    @ApiModelProperty("序号")
-    private Integer sortCode;
+    @ExcelProperty("学生姓名")
+    @ApiModelProperty("学生姓名")
+    private String studentName;
+
     /**
-    * 寝室编号(room)
-    */
+     * 学生学号
+     */
     @ContentStyle(dataFormat = 49)
-    @ExcelProperty("寝室编号(room)")
-    @ApiModelProperty("寝室编号(room)")
-    private Long roomId;
+    @ExcelProperty("学生学号")
+    @ApiModelProperty("学生学号")
+    private String studentId;
+
     /**
-    * 床位
-    */
+     * 手机
+     */
     @ContentStyle(dataFormat = 49)
-    @ExcelProperty("床位号")
-    @ApiModelProperty("床位号")
-    private Integer bedNumber;
+    @ExcelProperty("手机号")
+    @ApiModelProperty("手机号")
+    private String mobile;
+
     /**
-    * 学生用户编号
-    */
+     * 入住性别(xjr_dictionary_item[gender])
+     */
     @ContentStyle(dataFormat = 49)
-    @ExcelProperty("学生用户编号")
-    @ApiModelProperty("学生用户编号")
-    private Long studentUserId;
+    @ExcelProperty("入住性别")
+    @ApiModelProperty("入住性别")
+    private String genderCn;
+
     /**
-    * 是否入住(1:是 0:否)
-    */
+     * 年级名称
+     */
     @ContentStyle(dataFormat = 49)
-    @ExcelProperty("是否入住(1:是 0:否)")
-    @ApiModelProperty("是否入住(1:是 0:否)")
-    private Integer isCheckIn;
+    @ExcelProperty("年级名称")
+    @ApiModelProperty("年级名称")
+    private String gradeName;
+
     /**
-    * 备注
-    */
+     * 班级名称
+     */
     @ContentStyle(dataFormat = 49)
-    @ExcelProperty("备注")
-    @ApiModelProperty("备注")
-    private String remark;
-
+    @ExcelProperty("班级名称")
+    @ApiModelProperty("班级名称")
+    private String className;
 }

+ 27 - 17
src/main/resources/mapper/room/RoomBedMapper.xml

@@ -3,29 +3,39 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.xjrsoft.module.room.mapper.RoomBedMapper">
-    <select id="getPage" parameterType="com.xjrsoft.module.room.dto.RoomPageDto" resultType="com.xjrsoft.module.room.vo.RoomPageVo">
-        SELECT t1.id,t1.sort_code,t2.name AS bulid_name,t1.floor_number,t1.room_name,t3.name AS check_in_status_cn,t4.name AS gender_cn,t1.bed_count,
-        (SELECT GROUP_CONCAT(c2.name) FROM room_student_appoint c1
-        LEFT JOIN xjr_user c2 ON c1.student_user_id = c2.id
-        WHERE c1.delete_mark = 0 AND c1.room_id = t1.id) AS student_appoint_names,
-        (SELECT GROUP_CONCAT(c2.name) FROM room_teacher_appoint c1
-        LEFT JOIN xjr_user c2 ON c1.user_id = c2.id
-        WHERE c1.delete_mark = 0 AND c1.room_id = t1.id) AS teacher_appoint_names,t1.is_max,t1.remark FROM room t1
-        LEFT JOIN base_office_build t2 ON t1.office_build_id = t2.id
-        LEFT JOIN xjr_dictionary_detail t3 ON t1.check_in_status = t3.code AND t3.item_id = 1739843696019435521
-        LEFT JOIN xjr_dictionary_detail t4 ON t1.gender = t4.code AND t4.item_id = 2023000000000000004
-        WHERE t1.delete_mark = 0
+    <select id="getPage" parameterType="com.xjrsoft.module.room.dto.RoomBedPageDto" resultType="com.xjrsoft.module.room.vo.RoomBedPageVo">
+        SELECT t1.id,t1.sort_code,t3.name AS build_name,t2.floor_number,t2.room_name,t1.bed_number,t4.name AS student_name,t5.student_id,
+        t4.mobile,t2.gender as gender_cn,t7.name AS grade_name,t8.name AS class_name 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 base_student t5 ON t1.student_user_id = t5.user_id
+        LEFT JOIN base_student_school_roll t6 ON t1.student_user_id = t6.user_id
+        LEFT JOIN base_grade t7 ON t6.grade_id = t7.id
+        LEFT JOIN base_class t8 ON t6.class_id = t8.id
         <if test="dto.officeBuildId != null">
-            and t1.office_build_id = #{dto.officeBuildId}
+            and t2.office_build_id = #{dto.officeBuildId}
         </if>
         <if test="dto.floorNumber != null">
-            and t1.floor_number = #{dto.floorNumber}
+            and t2.floor_number = #{dto.floorNumber}
         </if>
-        <if test="dto.checkInStatus != null and dto.checkInStatus != ''">
-            and t1.check_in_status = #{dto.checkInStatus}
+        <if test="dto.roomId != null">
+            and t2.room_id = #{dto.roomId}
         </if>
         <if test="dto.gender != null and dto.gender != ''">
-            and t1.gender = #{dto.gender}
+            and t2.gender = #{dto.gender}
+        </if>
+        <if test="dto.gradeId != null">
+            and t7.id = #{dto.gradeId}
+        </if>
+        <if test="dto.classId != null">
+            and t8.id = #{dto.classId}
+        </if>
+        <if test="dto.studentName != null">
+            and t4.name like concat('%',#{dto.studentName},'%')
+        </if>
+        <if test="dto.studentId != null">
+            and t5.student_id like concat('%',#{dto.studentId},'%')
         </if>
         ORDER BY t1.sort_code
     </select>