Browse Source

导出功能

dzx 4 months ago
parent
commit
6b2b27d0b8

+ 18 - 2
src/main/java/com/xjrsoft/module/banding/controller/BandingTaskClassController.java

@@ -3,6 +3,7 @@ package com.xjrsoft.module.banding.controller;
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.bean.BeanUtil;
 import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.support.ExcelTypeEnum;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.module.banding.dto.AddBandingTaskClassDto;
 import com.xjrsoft.module.banding.dto.AddBandingTaskClassDto;
@@ -14,7 +15,9 @@ import com.xjrsoft.module.banding.dto.UpdateBandingClassDto;
 import com.xjrsoft.module.banding.entity.BandingTaskClass;
 import com.xjrsoft.module.banding.entity.BandingTaskClass;
 import com.xjrsoft.module.banding.service.IBandingTaskClassService;
 import com.xjrsoft.module.banding.service.IBandingTaskClassService;
 import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService;
 import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService;
+import com.xjrsoft.module.banding.vo.BandingTaskClassExcelVo;
 import com.xjrsoft.module.banding.vo.BandingTaskClassPageVo;
 import com.xjrsoft.module.banding.vo.BandingTaskClassPageVo;
+import com.xjrsoft.module.banding.vo.BandingTaskClassStudentListVo;
 import com.xjrsoft.module.banding.vo.BandingTaskClassSureListVo;
 import com.xjrsoft.module.banding.vo.BandingTaskClassSureListVo;
 import com.xjrsoft.module.banding.vo.BandingTaskClassVo;
 import com.xjrsoft.module.banding.vo.BandingTaskClassVo;
 import com.xjrsoft.module.banding.vo.BandingTaskPageVo;
 import com.xjrsoft.module.banding.vo.BandingTaskPageVo;
@@ -22,6 +25,7 @@ import com.xjrsoft.module.student.dto.BaseNewStudentPageDto;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -33,6 +37,7 @@ import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
 
 
 import javax.validation.Valid;
 import javax.validation.Valid;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.IOException;
 import java.util.List;
 import java.util.List;
 
 
@@ -64,8 +69,8 @@ public class BandingTaskClassController {
     @GetMapping(value = "/class-student")
     @GetMapping(value = "/class-student")
     @ApiOperation(value="分班后的学生列表")
     @ApiOperation(value="分班后的学生列表")
     @SaCheckPermission("bandingtask:detail")
     @SaCheckPermission("bandingtask:detail")
-    public RT<List<BandingTaskClassPageVo>> classStudent(@Valid BandingTaskClassStudentPageDto dto){
-        List<BandingTaskClassPageVo> list = bandingTaskClassService.classStudent(dto);
+    public RT<List<BandingTaskClassStudentListVo>> classStudent(@Valid BandingTaskClassStudentPageDto dto){
+        List<BandingTaskClassStudentListVo> list = bandingTaskClassService.classStudent(dto);
         return RT.ok(list);
         return RT.ok(list);
     }
     }
 
 
@@ -142,6 +147,17 @@ public class BandingTaskClassController {
         return RT.ok(result);
         return RT.ok(result);
     }
     }
 
 
+    @GetMapping("/export")
+    @ApiOperation(value = "导出学生列表")
+    public ResponseEntity<byte[]> exportData(@Valid BandingTaskClassStudentPageDto dto, @RequestParam(defaultValue = "false") Boolean isTemplate) {
+        List<BandingTaskClassStudentListVo> listVos = bandingTaskClassService.classStudent(dto);
+        List<BandingTaskClassExcelVo> list = BeanUtil.copyToList(listVos, BandingTaskClassExcelVo.class);
+        ByteArrayOutputStream bot = new ByteArrayOutputStream();
+        EasyExcel.write(bot, BandingTaskClassExcelVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(list);
+
+        return RT.fileStream(bot.toByteArray(), "学生分班情况" + ExcelTypeEnum.XLSX.getValue());
+    }
+
     @PostMapping("/reset")
     @PostMapping("/reset")
     @ApiOperation(value = "重置功能")
     @ApiOperation(value = "重置功能")
     @SaCheckPermission("bandingTaskClass:add")
     @SaCheckPermission("bandingTaskClass:add")

+ 2 - 1
src/main/java/com/xjrsoft/module/banding/mapper/BandingTaskClassMapper.java

@@ -5,6 +5,7 @@ import com.xjrsoft.module.banding.dto.BandingTaskClassPageDto;
 import com.xjrsoft.module.banding.dto.BandingTaskClassStudentPageDto;
 import com.xjrsoft.module.banding.dto.BandingTaskClassStudentPageDto;
 import com.xjrsoft.module.banding.entity.BandingTaskClass;
 import com.xjrsoft.module.banding.entity.BandingTaskClass;
 import com.xjrsoft.module.banding.vo.BandingTaskClassPageVo;
 import com.xjrsoft.module.banding.vo.BandingTaskClassPageVo;
+import com.xjrsoft.module.banding.vo.BandingTaskClassStudentListVo;
 import com.xjrsoft.module.banding.vo.BandingTaskClassSureListVo;
 import com.xjrsoft.module.banding.vo.BandingTaskClassSureListVo;
 import com.xjrsoft.module.outint.vo.IdCountVo;
 import com.xjrsoft.module.outint.vo.IdCountVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Mapper;
@@ -22,7 +23,7 @@ import java.util.List;
 public interface BandingTaskClassMapper extends MPJBaseMapper<BandingTaskClass> {
 public interface BandingTaskClassMapper extends MPJBaseMapper<BandingTaskClass> {
     List<BandingTaskClassPageVo> getList(@Param("dto")BandingTaskClassPageDto dto);
     List<BandingTaskClassPageVo> getList(@Param("dto")BandingTaskClassPageDto dto);
 
 
-    List<BandingTaskClassPageVo> getClassStudent(@Param("dto") BandingTaskClassStudentPageDto dto);
+    List<BandingTaskClassStudentListVo> getClassStudent(@Param("dto") BandingTaskClassStudentPageDto dto);
 
 
     List<IdCountVo> getMajorClassCount(@Param("id") Long bandingTaskId);
     List<IdCountVo> getMajorClassCount(@Param("id") Long bandingTaskId);
     List<IdCountVo> getMajorClassStudentCount(@Param("id") Long bandingTaskId);
     List<IdCountVo> getMajorClassStudentCount(@Param("id") Long bandingTaskId);

+ 2 - 1
src/main/java/com/xjrsoft/module/banding/service/IBandingTaskClassService.java

@@ -5,6 +5,7 @@ import com.xjrsoft.module.banding.dto.BandingTaskClassPageDto;
 import com.xjrsoft.module.banding.dto.BandingTaskClassStudentPageDto;
 import com.xjrsoft.module.banding.dto.BandingTaskClassStudentPageDto;
 import com.xjrsoft.module.banding.entity.BandingTaskClass;
 import com.xjrsoft.module.banding.entity.BandingTaskClass;
 import com.xjrsoft.module.banding.vo.BandingTaskClassPageVo;
 import com.xjrsoft.module.banding.vo.BandingTaskClassPageVo;
+import com.xjrsoft.module.banding.vo.BandingTaskClassStudentListVo;
 import com.xjrsoft.module.banding.vo.BandingTaskClassSureListVo;
 import com.xjrsoft.module.banding.vo.BandingTaskClassSureListVo;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 
 
@@ -47,7 +48,7 @@ public interface IBandingTaskClassService extends MPJBaseService<BandingTaskClas
 
 
     Boolean reset(Long bandingTaskId);
     Boolean reset(Long bandingTaskId);
 
 
-    List<BandingTaskClassPageVo> classStudent(BandingTaskClassStudentPageDto dto);
+    List<BandingTaskClassStudentListVo> classStudent(BandingTaskClassStudentPageDto dto);
 
 
     List<BandingTaskClassSureListVo> getClassSure(BandingTaskClassStudentPageDto dto);
     List<BandingTaskClassSureListVo> getClassSure(BandingTaskClassStudentPageDto dto);
 }
 }

+ 2 - 1
src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskClassServiceImpl.java

@@ -11,6 +11,7 @@ import com.xjrsoft.module.banding.mapper.BandingTaskClassStudentMapper;
 import com.xjrsoft.module.banding.mapper.BandingTaskMapper;
 import com.xjrsoft.module.banding.mapper.BandingTaskMapper;
 import com.xjrsoft.module.banding.service.IBandingTaskClassService;
 import com.xjrsoft.module.banding.service.IBandingTaskClassService;
 import com.xjrsoft.module.banding.vo.BandingTaskClassPageVo;
 import com.xjrsoft.module.banding.vo.BandingTaskClassPageVo;
+import com.xjrsoft.module.banding.vo.BandingTaskClassStudentListVo;
 import com.xjrsoft.module.banding.vo.BandingTaskClassSureListVo;
 import com.xjrsoft.module.banding.vo.BandingTaskClassSureListVo;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -83,7 +84,7 @@ public class BandingTaskClassServiceImpl extends MPJBaseServiceImpl<BandingTaskC
     }
     }
 
 
     @Override
     @Override
-    public List<BandingTaskClassPageVo> classStudent(BandingTaskClassStudentPageDto dto) {
+    public List<BandingTaskClassStudentListVo> classStudent(BandingTaskClassStudentPageDto dto) {
         return this.baseMapper.getClassStudent(dto);
         return this.baseMapper.getClassStudent(dto);
     }
     }
 
 

+ 84 - 0
src/main/java/com/xjrsoft/module/banding/vo/BandingTaskClassExcelVo.java

@@ -0,0 +1,84 @@
+package com.xjrsoft.module.banding.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ContentStyle;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+* @title: 分班后的学生导出
+* @Author dzx
+* @Date: 2024-07-01
+* @Version 1.0
+*/
+@Data
+public class BandingTaskClassExcelVo {
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("学号")
+    @ApiModelProperty("学号")
+    private String credentialNumber;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("学生姓名")
+    @ApiModelProperty("学生姓名")
+    private String name;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("性别")
+    @ApiModelProperty("性别")
+    private String genderCn;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("毕业学校")
+    @ApiModelProperty("毕业学校")
+    private String graduateSchool;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("毕业班级")
+    @ApiModelProperty("毕业班级")
+    private String graduateClass;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("第一志愿")
+    @ApiModelProperty("第一志愿")
+    private String firstAmbition;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("第二志愿")
+    @ApiModelProperty("第二志愿")
+    private String secondAmbition;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("班主人名称")
+    @ApiModelProperty("班主人名称")
+    private String teacherName;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("住宿类型")
+    @ApiModelProperty("住宿类型")
+    private String stduyStatusCn;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("班级名称")
+    @ApiModelProperty("班级名称")
+    private String className;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("身高")
+    @ApiModelProperty("身高")
+    private BigDecimal height;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("体重")
+    @ApiModelProperty("体重")
+    private BigDecimal weight;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("分数")
+    @ApiModelProperty("分数")
+    private BigDecimal score;
+
+}