浏览代码

解决导出数量少了的问题

dzx 1 年之前
父节点
当前提交
e8e1233f9f

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

@@ -17,6 +17,7 @@ import com.xjrsoft.module.room.entity.RoomBed;
 import com.xjrsoft.module.room.service.IRoomBedService;
 import com.xjrsoft.module.room.vo.DistributeClassPageVo;
 import com.xjrsoft.module.room.vo.DistributeRoomBedPageVo;
+import com.xjrsoft.module.room.vo.RoomBedExcelVo;
 import com.xjrsoft.module.room.vo.RoomBedPageVo;
 import com.xjrsoft.module.room.vo.RoomBedVo;
 import io.swagger.annotations.Api;
@@ -36,7 +37,6 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.validation.Valid;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -130,9 +130,9 @@ public class RoomBedController {
     @GetMapping("/export")
     @ApiOperation(value = "导出")
     public ResponseEntity<byte[]> exportData(@Valid RoomBedPageDto dto, @RequestParam(defaultValue = "false") Boolean isTemplate) {
-        List<RoomBedPageVo> customerList = isTemplate != null && isTemplate ? new ArrayList<>() : ((PageOutput<RoomBedPageVo>) page(dto).getData()).getList();
+        List<RoomBedExcelVo> customerList = roomBedService.getList(dto);
         ByteArrayOutputStream bot = new ByteArrayOutputStream();
-        EasyExcel.write(bot, RoomBedPageVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(customerList);
+        EasyExcel.write(bot, RoomBedExcelVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(customerList);
 
         return RT.fileStream(bot.toByteArray(), "RoomBed" + ExcelTypeEnum.XLSX.getValue());
     }

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

@@ -17,6 +17,7 @@ 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.RoomBedExcelVo;
 import com.xjrsoft.module.room.vo.RoomBedPageVo;
 import com.xjrsoft.module.room.vo.RoomBedVo;
 import org.apache.ibatis.annotations.Mapper;
@@ -46,6 +47,8 @@ public interface RoomBedMapper extends MPJBaseMapper<RoomBed> {
      */
     Page<RoomBedPageVo> getPage(Page<RoomBedPageVo> page, RoomBedPageDto dto);
 
+    List<RoomBedExcelVo> getList(@Param("dto") RoomBedPageDto dto);
+
     Page<DistributeClassPageVo> getDistributeClassInfo(Page<DistributeClassPageDto> page, DistributeClassPageDto dto);
 
     Page<DistributeRoomBedPageVo> getDistributeRoomBedInfo(Page<DistributeRoomBedPageDto> page, DistributeRoomBedPageDto dto);

+ 3 - 0
src/main/java/com/xjrsoft/module/room/service/IRoomBedService.java

@@ -16,6 +16,7 @@ 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.RoomBedExcelVo;
 import com.xjrsoft.module.room.vo.RoomBedPageVo;
 
 import java.util.List;
@@ -37,6 +38,8 @@ public interface IRoomBedService extends MPJBaseService<RoomBed> {
      */
     Page<RoomBedPageVo> getPage(Page<RoomBedPageVo> page, RoomBedPageDto dto);
 
+    List<RoomBedExcelVo> getList(RoomBedPageDto dto);
+
 
     Boolean clearStudentInfo(List<Long> ids);
 

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

@@ -37,6 +37,7 @@ 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.RoomBedExcelVo;
 import com.xjrsoft.module.room.vo.RoomBedPageVo;
 import com.xjrsoft.module.room.vo.RoomClassCountVo;
 import com.xjrsoft.module.student.entity.BaseStudent;
@@ -76,6 +77,11 @@ public class RoomBedServiceImpl extends MPJBaseServiceImpl<RoomBedMapper, RoomBe
         return result;
     }
 
+    @Override
+    public List<RoomBedExcelVo> getList(RoomBedPageDto dto) {
+        return roomBedMapper.getList(dto);
+    }
+
     @Override
     public Boolean clearStudentInfo(List<Long> ids) {
         for (Long id : ids) {

+ 103 - 0
src/main/java/com/xjrsoft/module/room/vo/RoomBedExcelVo.java

@@ -0,0 +1,103 @@
+package com.xjrsoft.module.room.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+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 RoomBedExcelVo {
+
+    /**
+     * 序号
+     */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("序号")
+    @ApiModelProperty("序号")
+    private Integer sortCode;
+
+    /**
+     * 楼栋名称
+     */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("楼栋名称")
+    @ApiModelProperty("楼栋名称")
+    private String buildName;
+
+    /**
+     * 楼层
+     */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("楼层")
+    @ApiModelProperty("楼层")
+    private Integer floorNumber;
+    /**
+     * 寝室名称
+     */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("寝室名称")
+    @ApiModelProperty("寝室名称")
+    private String roomName;
+
+    /**
+     * 床位号
+     */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("床位号")
+    @ApiModelProperty("床位号")
+    private Integer bedNumber;
+
+    /**
+     * 学生姓名
+     */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("学生姓名")
+    @ApiModelProperty("学生姓名")
+    private String studentName;
+
+    /**
+     * 学生学号
+     */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("学生学号")
+    @ApiModelProperty("学生学号")
+    private String studentId;
+
+    /**
+     * 手机号
+     */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("手机号")
+    @ApiModelProperty("手机号")
+    private String mobile;
+
+    /**
+     * 入住性别(xjr_dictionary_item[gender])
+     */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("入住性别")
+    @ApiModelProperty("入住性别")
+    private String genderCn;
+
+    /**
+     * 年级名称
+     */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("年级名称")
+    @ApiModelProperty("年级名称")
+    private String gradeName;
+
+    /**
+     * 班级名称
+     */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("班级名称")
+    @ApiModelProperty("班级名称")
+    private String className;
+}

+ 43 - 0
src/main/resources/mapper/room/RoomBedMapper.xml

@@ -44,6 +44,49 @@
         </if>
         ORDER BY t1.sort_code
     </select>
+
+    <select id="getList" 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,t9.name 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
+        LEFT JOIN xjr_dictionary_detail t9 ON t2.gender = t9.code AND t9.item_id = 2023000000000000004
+        where t1.delete_mark = 0 and t2.delete_mark = 0
+        <if test="dto.officeBuildId != null">
+            and t2.office_build_id = #{dto.officeBuildId}
+        </if>
+        <if test="dto.floorNumber != null">
+            and t2.floor_number = #{dto.floorNumber}
+        </if>
+        <if test="dto.roomId != null">
+            and t2.room_id = #{dto.roomId}
+        </if>
+        <if test="dto.gender != null and 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>
+        <if test="dto.identity != null and dto.identity != ''">
+            and t2.check_in_status like concat('%',#{dto.identity},'%')
+        </if>
+        ORDER BY t1.sort_code
+    </select>
+
     <select id="getMaxSortCode" resultType="java.lang.Integer">
         SELECT IFNULL(MAX(sort_code),0) FROM room_bed WHERE delete_mark = 0
     </select>