|
|
@@ -2,7 +2,10 @@ package com.xjrsoft.module.student.service.impl;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
+import com.alibaba.excel.ExcelWriter;
|
|
|
import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
+import com.alibaba.excel.write.metadata.WriteSheet;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
@@ -10,15 +13,17 @@ import com.github.yulichang.toolkit.MPJWrappers;
|
|
|
import com.xjrsoft.common.enums.ScoreTypeEnum;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
+import com.xjrsoft.common.utils.excel.ExcelMergeUtil;
|
|
|
import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
import com.xjrsoft.module.base.mapper.BaseClassMapper;
|
|
|
-import com.xjrsoft.module.evaluate.vo.ResultViewingExcelVo;
|
|
|
import com.xjrsoft.module.student.dto.BaseStudentAssessmentInspectionMobilePageDto;
|
|
|
import com.xjrsoft.module.student.dto.BaseStudentAssessmentInspectionPageDto;
|
|
|
import com.xjrsoft.module.student.dto.QuantitativeAssessmentExcelDto;
|
|
|
+import com.xjrsoft.module.student.entity.BaseStudentAssessmentCategory;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudentAssessmentClassRelation;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudentAssessmentInspection;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudentAssessmentStudentRelation;
|
|
|
+import com.xjrsoft.module.student.mapper.BaseStudentAssessmentCategoryMapper;
|
|
|
import com.xjrsoft.module.student.mapper.BaseStudentAssessmentClassRelationMapper;
|
|
|
import com.xjrsoft.module.student.mapper.BaseStudentAssessmentInspectionMapper;
|
|
|
import com.xjrsoft.module.student.mapper.BaseStudentAssessmentStudentRelationMapper;
|
|
|
@@ -32,8 +37,8 @@ import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -48,6 +53,8 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
|
|
|
|
|
|
private final BaseStudentAssessmentInspectionMapper assessmentInspectionMapper;
|
|
|
|
|
|
+ private final BaseStudentAssessmentCategoryMapper baseStudentAssessmentCategoryMapper;
|
|
|
+
|
|
|
private final BaseStudentAssessmentStudentRelationMapper assessmentStudentRelationMapper;
|
|
|
|
|
|
private final BaseStudentAssessmentClassRelationMapper assessmentClassRelationMapper;
|
|
|
@@ -154,26 +161,63 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
|
|
|
|
|
|
@Override
|
|
|
public ResponseEntity<byte[]> getQuantitativeAssessmentExcelByte(QuantitativeAssessmentExcelDto dto) {
|
|
|
+ //导出的文件名,字节流
|
|
|
String fileName = "StudentAssessmentInspection" + ExcelTypeEnum.XLSX.getValue();
|
|
|
ByteArrayOutputStream bot = new ByteArrayOutputStream();
|
|
|
- //TODO 学生个人行为原始数据
|
|
|
- //求所有的个人行为集合
|
|
|
- List<StudentIndividualBehaviorExcelVo> studentIndividualBehaviorExcelVoList = assessmentInspectionMapper.getStudentIndividualBehaviorExcelVoList(dto);
|
|
|
- Map<Long, List<StudentIndividualBehaviorExcelVo>> studentIndividualBehaviorExcelVoListMap = studentIndividualBehaviorExcelVoList.stream()
|
|
|
- .collect(Collectors.groupingBy(StudentIndividualBehaviorExcelVo::getStudentUserId));
|
|
|
|
|
|
- //未合并
|
|
|
- EasyExcel.write(bot, ResultViewingExcelVo.class)
|
|
|
- .automaticMergeHead(false)
|
|
|
- .excelType(ExcelTypeEnum.XLSX)
|
|
|
- .sheet("学生个人行为")
|
|
|
- .doWrite(studentIndividualBehaviorExcelVoList);
|
|
|
+ //获取需要导出的子表
|
|
|
+ List<Long> baseStudentAssessmentCategoryIdList = new ArrayList<>();
|
|
|
+ baseStudentAssessmentCategoryIdList.add(1727155216239882240L);
|
|
|
+ baseStudentAssessmentCategoryIdList.add(1727154864019009536L);
|
|
|
+
|
|
|
+ LambdaQueryWrapper<BaseStudentAssessmentCategory> baseStudentAssessmentCategoryLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ baseStudentAssessmentCategoryLambdaQueryWrapper
|
|
|
+ .in(BaseStudentAssessmentCategory::getId, baseStudentAssessmentCategoryIdList);
|
|
|
+ List<BaseStudentAssessmentCategory> baseStudentAssessmentCategorieList = baseStudentAssessmentCategoryMapper.selectList(baseStudentAssessmentCategoryLambdaQueryWrapper);
|
|
|
+
|
|
|
+ //导出子表
|
|
|
+ if(baseStudentAssessmentCategorieList.size() > 0){
|
|
|
+ //需要合并的列
|
|
|
+ int[] mergeColumeIndex = {0, 1, 2, 3, 4};
|
|
|
+ ExcelMergeUtil excelFillCellMergeStrategy = new ExcelMergeUtil(1, mergeColumeIndex);
|
|
|
+
|
|
|
+ //开始处理写入
|
|
|
+ try (ExcelWriter excelWriter = EasyExcel.write(bot, QuantitativeAssessmentSubTableExcelVo.class).registerWriteHandler(excelFillCellMergeStrategy).build()) {
|
|
|
+ int no = 0;
|
|
|
+ for (BaseStudentAssessmentCategory bsac : baseStudentAssessmentCategorieList) {
|
|
|
+ dto.setBaseStudentAssessmentCategoryId(bsac.getId());
|
|
|
+ //sheet名
|
|
|
+ String sheetName = bsac.getName();
|
|
|
|
|
|
- //TODO 班级常规管理原始数据
|
|
|
+ WriteSheet writeSheet = EasyExcel.writerSheet(no++, sheetName ).build();
|
|
|
|
|
|
- //TODO 获奖原始数据
|
|
|
+ //求所有的个人行为集合
|
|
|
+ List<QuantitativeAssessmentSubTableExcelVo> quantitativeAssessmentSubTableExcelVoList = assessmentInspectionMapper.getQuantitativeAssessmentSubTableExcelVoList(dto);
|
|
|
|
|
|
- //TODO 班级量化考核统计表总
|
|
|
+ excelWriter.write(quantitativeAssessmentSubTableExcelVoList, writeSheet);
|
|
|
+ }
|
|
|
+ //TODO 班级量化考核统计表总
|
|
|
+
|
|
|
+ }
|
|
|
+ /*for (BaseStudentAssessmentCategory bsac : baseStudentAssessmentCategorieList) {
|
|
|
+ dto.setBaseStudentAssessmentCategoryId(bsac.getId());
|
|
|
+ //sheet名
|
|
|
+ String sheetName = bsac.getName();
|
|
|
+
|
|
|
+ //求所有的个人行为集合
|
|
|
+ List<QuantitativeAssessmentSubTableExcelVo> quantitativeAssessmentSubTableExcelVoList = assessmentInspectionMapper.getQuantitativeAssessmentSubTableExcelVoList(dto);
|
|
|
+
|
|
|
+ //需要合并的列
|
|
|
+ int[] mergeColumeIndex = {0, 1, 2, 3, 4};
|
|
|
+
|
|
|
+ //写字节流
|
|
|
+ ExcelMergeUtil excelFillCellMergeStrategy = new ExcelMergeUtil(1, mergeColumeIndex);
|
|
|
+ EasyExcel.write(bot, QuantitativeAssessmentSubTableExcelVo.class)
|
|
|
+ .registerWriteHandler(excelFillCellMergeStrategy)
|
|
|
+ .sheet(sheetName)
|
|
|
+ .doWrite(quantitativeAssessmentSubTableExcelVoList);
|
|
|
+ }*/
|
|
|
+ }
|
|
|
|
|
|
return RT.fileStream(bot.toByteArray(), fileName);
|
|
|
}
|