|
@@ -1,9 +1,13 @@
|
|
|
package com.xjrsoft.module.teacher.controller;
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
+import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
+import com.xjrsoft.common.enums.DeleteMark;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
|
import com.xjrsoft.common.page.ConventPage;
|
|
|
import com.xjrsoft.common.page.PageOutput;
|
|
@@ -16,15 +20,22 @@ import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
|
import com.xjrsoft.module.teacher.service.ITeacherAwardItemService;
|
|
|
import com.xjrsoft.module.teacher.service.ITeacherAwardService;
|
|
|
import com.xjrsoft.module.teacher.vo.TeacherAwardDetailPageVo;
|
|
|
+import com.xjrsoft.module.teacher.vo.TeacherAwardStatisticsExcelVo;
|
|
|
import com.xjrsoft.module.teacher.vo.TeacherAwardStatisticsPageVo;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @title: 教师奖项
|
|
@@ -77,4 +88,25 @@ public class TeacherAwardController {
|
|
|
PageOutput<TeacherAwardDetailPageVo> pageOutput = ConventPage.getPageOutput(page, TeacherAwardDetailPageVo.class);
|
|
|
return RT.ok(pageOutput);
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping(value = "/export-query")
|
|
|
+ @ApiOperation(value="导出")
|
|
|
+ @SaCheckPermission("teacheraward:detail")
|
|
|
+ public ResponseEntity<byte[]> exportQuery(@Valid @RequestBody TeacherAwardStatisticsPageDto dto){
|
|
|
+ List<TeacherAwardStatisticsPageVo> list = teacherAwardItemService.getStatisticsList(dto);
|
|
|
+
|
|
|
+ List<Long> userIds = list.stream().map(TeacherAwardStatisticsPageVo::getId).collect(Collectors.toList());
|
|
|
+ List<TeacherAward> awardList = teacherAwardService.list(
|
|
|
+ new QueryWrapper<TeacherAward>().lambda()
|
|
|
+ .eq(TeacherAward::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ .in(TeacherAward::getApplicantUserId, userIds)
|
|
|
+ .orderByAsc(TeacherAward::getCreateDate)
|
|
|
+ );
|
|
|
+
|
|
|
+
|
|
|
+ ByteArrayOutputStream bot = new ByteArrayOutputStream();
|
|
|
+ EasyExcel.write(bot, TeacherAwardStatisticsExcelVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(list);
|
|
|
+
|
|
|
+ return RT.fileStream(bot.toByteArray(), "TeacherAward" + ExcelTypeEnum.XLSX.getValue());
|
|
|
+ }
|
|
|
}
|