dzx vor 9 Monaten
Ursprung
Commit
c8db906faa

+ 16 - 1
src/main/java/com/xjrsoft/module/student/controller/StudentReportRecordController.java

@@ -459,10 +459,25 @@ public class StudentReportRecordController {
     @ApiOperation(value="导出")
     @SaCheckPermission("studentreportrecord:detail")
     public ResponseEntity<byte[]> exportQuerty(@Valid @RequestBody StudentReportRecordPageDto dto){
+        List<StudentReportRecordExcelVo> dataList = new ArrayList<>();
+
+        List<String> roleList = StpUtil.getRoleList();
+        if(roleList.contains(RoleCodeEnum.TEACHER.getCode()) && roleList.contains(RoleCodeEnum.CLASSTE.getCode())){
+            Long classId = classService.getIdByTeacherId(StpUtil.getLoginIdAsLong());
+            if(ObjectUtil.isNull(classId) && dto.getClassId() == null){
+                ByteArrayOutputStream bot = new ByteArrayOutputStream();
+                EasyExcel.write(bot, StudentReportRecordExcelVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(dataList);
+                String fileName = "exportQuerty" + ExcelTypeEnum.XLSX.getValue();
+                return RT.fileStream(bot.toByteArray(), fileName);
+            }
+            if(dto.getClassId() == null){
+                dto.setClassId(classId);
+            }
+        }
         List<StudentReportRecordPlanPageVo> planPageList = studentReportRecordService.getPlanPageList(dto);
 
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        List<StudentReportRecordExcelVo> dataList = new ArrayList<>();
+
         for (StudentReportRecordPlanPageVo pageVo : planPageList) {
             StudentReportRecordExcelVo excelVo = BeanUtil.toBean(pageVo, StudentReportRecordExcelVo.class);
             if(pageVo.getReportTime() != null){