修改三个导出功能

master
xiaoCJ 3 months ago
parent aaa06da62a
commit 2421250ef0

@ -454,28 +454,33 @@ public class TeaGradeManageController {
iTeaGradeManageService.exportTrainingInfo(response, schoolId, keyWord, classId, systemOwner);
}
@AnonymousAccess
@PostMapping("/getTrainingDetailsInfo")
@ApiOperation("练习模式--详情页面展示")
public ResultEntity<List<TeaTrainingDto>> getTrainingDetailsInfo(@RequestParam String userId) {
try {
return new ResultEntity<>(iTeaGradeManageService.getTrainingDetailsInfo(userId));
} catch (IOException e) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心异常");
}
}
// @AnonymousAccess
// @PostMapping("/getTrainingDetailsInfo")
// @ApiOperation("练习模式--详情页面展示")
// public ResultEntity<List<TeaTrainingDto>> getTrainingDetailsInfo(@RequestParam String userId) {
// try {
// return new ResultEntity<>(iTeaGradeManageService.getTrainingDetailsInfo(userId));
// } catch (IOException e) {
// return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心异常");
// }
// }
@AnonymousAccess
@GetMapping("/exportTrainingDetailsInfo")
@ApiOperation("练习模式--详情页面导出")
public void exportTrainingDetailsInfo(HttpServletResponse response, @RequestParam String userId) {
public void exportTrainingDetailsInfo(HttpServletResponse response,
@RequestParam String userId,
@RequestParam String schoolId,
@RequestParam String systemOwner) {
try {
iTeaGradeManageService.exportTrainingDetailsInfo(response, userId);
iTeaGradeManageService.exportTrainingDetailsInfo(response, userId,schoolId,systemOwner);
} catch (IOException e) {
e.printStackTrace();
}
}
@AnonymousAccess
@PostMapping("/getReportBySchoolID")
@ApiOperation("练习模式--实训报告展示")
@ -720,7 +725,6 @@ public class TeaGradeManageController {
}
}

@ -72,4 +72,7 @@ public class StuTrainingDto {
@ApiModelProperty("模板名称")
private String taskModule;
@ApiModelProperty("模块得分")
private BigDecimal moduleScore;
}

@ -1,15 +1,52 @@
package com.sztzjy.financial_bigdata.entity.tea_dto;
import com.sztzjy.financial_bigdata.entity.StuTheoryRecord;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* @Author xcj
* @Date 2024/4/10
*/
@Data
@NoArgsConstructor
public class StuTheoryRecordDto extends StuTheoryRecord {
@Data
public class StuTheoryRecordDto {
private int rank;
@ApiModelProperty("用户ID")
private String userId;
@ApiModelProperty("学校ID")
private String schoolId;
@ApiModelProperty("班级ID")
private String classId;
@ApiModelProperty("姓名")
private String name;
@ApiModelProperty("学号")
private String studentId;
@ApiModelProperty("考试次数")
private Integer examCount;
@ApiModelProperty("考试最高分")
private BigDecimal highestScore;
@ApiModelProperty("考试最低分")
private BigDecimal lowestScore;
@ApiModelProperty("考试合计时长")
private Integer totalDuration;
@ApiModelProperty("平均分")
private BigDecimal averageScore;
@ApiModelProperty("归属系统")
private String systemOwner;
}

@ -140,9 +140,31 @@ public class StuScoreServiceImpl implements StuScoreService {
// 设置报告相关数据
setReportData(stuTrainingDto, stuTrainingWithBLOBs.getReportId());
//计算模块总得分
setTotalScore(stuTrainingDto);
return stuTrainingDto;
}
private void setTotalScore(StuTrainingDto stuTrainingDto) {
BigDecimal totalScore = BigDecimal.ZERO;
if (stuTrainingDto.getKnowledgeSummaryScore() != null) {
totalScore = totalScore.add(stuTrainingDto.getKnowledgeSummaryScore());
}
if (stuTrainingDto.getResourceLearningScore() != null) {
totalScore = totalScore.add(stuTrainingDto.getResourceLearningScore());
}
if (stuTrainingDto.getLearningEvalScore() != null) {
totalScore = totalScore.add(stuTrainingDto.getLearningEvalScore());
}
if (stuTrainingDto.getCaseStuScore() != null) {
totalScore = totalScore.add(stuTrainingDto.getCaseStuScore());
}
if (stuTrainingDto.getReportScore() != null) {
totalScore = totalScore.add(stuTrainingDto.getReportScore());
}
stuTrainingDto.setModuleScore(totalScore);
}
private void setDefaultWeights(StuTrainingDto stuTrainingDto) {
stuTrainingDto.setKnowledgeSummaryDefaultRule(BigDecimal.valueOf(60));
stuTrainingDto.setResourceLearningDefaultRule(BigDecimal.valueOf(60));

@ -3,11 +3,10 @@ package com.sztzjy.financial_bigdata.service.tea;
import com.github.pagehelper.PageInfo;
import com.sztzjy.financial_bigdata.entity.StuTheoryRecord;
import com.sztzjy.financial_bigdata.entity.SysWeight;
import com.sztzjy.financial_bigdata.entity.stu_dto.StuTrainingDto;
import com.sztzjy.financial_bigdata.entity.stu_dto.StuUserDto;
import com.sztzjy.financial_bigdata.entity.tea_dto.TeaExaminationDetailsDto;
import com.sztzjy.financial_bigdata.entity.tea_dto.TeaTrainingDto;
import com.sztzjy.financial_bigdata.entity.tea_dto.TeaTrainingInfoDTO;
import com.sztzjy.financial_bigdata.util.ResultEntity;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@ -18,21 +17,21 @@ import java.util.List;
* @Date 2024/3/19
*/
public interface ITeaGradeManageService {
PageInfo<TeaTrainingInfoDTO> getTrainingInfo(Integer index, Integer size, String schoolId, String keyWord, String classId,String systemOwner);
PageInfo<TeaTrainingInfoDTO> getTrainingInfo(Integer index, Integer size, String schoolId, String keyWord, String classId, String systemOwner);
void exportTrainingInfo(HttpServletResponse response, String schoolId, String keyWord, String classId,String systemOwner);
void exportTrainingInfo(HttpServletResponse response, String schoolId, String keyWord, String classId, String systemOwner);
TeaExaminationDetailsDto getCountChart(String examManageId, String classId);
List<TeaTrainingDto> getTrainingDetailsInfo(String userId) throws IOException;
List<StuTrainingDto> getTrainingDetailsInfo(String userId, String schoolId, String systemOwner) throws IOException;
void exportTrainingDetailsInfo(HttpServletResponse response, String userId) throws IOException;
void exportTrainingDetailsInfo(HttpServletResponse response, String userId, String schoolId, String systemOwner) throws IOException;
PageInfo<StuUserDto> getReportCorrect(String schoolId, Integer index, Integer size, String module, String classId, String keyWord);
PageInfo<StuTheoryRecord> getTheoryInfo(Integer index, Integer size, String schoolId, String classId, String keyWord,String systemOwner);
PageInfo<StuTheoryRecord> getTheoryInfo(Integer index, Integer size, String schoolId, String classId, String keyWord, String systemOwner);
void exportTheoryExamInfo(HttpServletResponse response,String classId, String schoolId);
void exportTheoryExamInfo(HttpServletResponse response, String classId, String schoolId);
SysWeight getSysWeightResultEntity(String courseId, String schoolId, String systemOwner);
}

@ -1,19 +1,24 @@
package com.sztzjy.financial_bigdata.service.tea.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.IdUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sztzjy.financial_bigdata.entity.*;
import com.sztzjy.financial_bigdata.entity.resource_entity.SysThreeCatalog;
import com.sztzjy.financial_bigdata.entity.stu_dto.StuTrainingDto;
import com.sztzjy.financial_bigdata.entity.stu_dto.StuUserDto;
import com.sztzjy.financial_bigdata.entity.tea_dto.*;
import com.sztzjy.financial_bigdata.entity.tea_dto.StuTheoryRecordDto;
import com.sztzjy.financial_bigdata.entity.tea_dto.TeaExamAndUserDto;
import com.sztzjy.financial_bigdata.entity.tea_dto.TeaExaminationDetailsDto;
import com.sztzjy.financial_bigdata.entity.tea_dto.TeaTrainingInfoDTO;
import com.sztzjy.financial_bigdata.mapper.*;
import com.sztzjy.financial_bigdata.resourceCenterAPI.CourseAPI;
import com.sztzjy.financial_bigdata.service.stu.StuScoreService;
import com.sztzjy.financial_bigdata.service.tea.ITeaGradeManageService;
import com.sztzjy.financial_bigdata.util.PageUtil;
import com.sztzjy.financial_bigdata.util.excel.FilePortUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -48,19 +53,25 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
private StuTheoryRecordMapper stuTheoryRecordMapper;
@Autowired
private StuTrainingMapper stuTrainingMapper;
@Autowired
private StuScoreService stuScoreService;
@Override
public PageInfo<TeaTrainingInfoDTO> getTrainingInfo(Integer index, Integer size, String schoolId, String keyWord, String classId, String systemOwner) {
List<TeaTrainingInfoDTO> list = getTrainingInfoDTOS(schoolId, keyWord, classId, systemOwner);
return PageUtil.pageHelper(list, index, size);
}
private List<TeaTrainingInfoDTO> getTrainingInfoDTOS(String schoolId, String keyWord, String classId, String systemOwner) {
List<TeaTrainingInfoDTO> list = getTeaTrainingInfoDTOS(schoolId, keyWord, classId, systemOwner);
assert !list.isEmpty();
assert !Objects.requireNonNull(list).isEmpty();
list.sort(new TotalScoreComparator());
int i = 0;
for (TeaTrainingInfoDTO teaTrainingInfoDTO : list) {
i++;
teaTrainingInfoDTO.setRank(i);
}
return PageUtil.pageHelper(list, index, size);
return list;
}
@ -72,7 +83,8 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
*/
@Override
public void exportTrainingInfo(HttpServletResponse response, String schoolId, String keyWord, String classId, String systemOwner) {
List<TeaTrainingInfoDTO> list = getTeaTrainingInfoDTOS(schoolId, keyWord, classId, systemOwner);
List<TeaTrainingInfoDTO> list = getTrainingInfoDTOS(schoolId, keyWord, classId, systemOwner);
//导出的表名
String title = IdUtil.simpleUUID();
//表中第一行表头字段
@ -168,29 +180,58 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
}
// @Override
// public List<TeaTrainingDto> getTrainingDetailsInfo(String userId) throws IOException {
// StuTrainingExample trainingExample = new StuTrainingExample();
// trainingExample.createCriteria().andUserIdEqualTo(userId);
// List<StuTrainingWithBLOBs> stuTrainingWithBLOBs = trainingMapper.selectByExampleWithBLOBs(trainingExample);
// List<TeaTrainingDto> list = new ArrayList<>();
// for (StuTrainingWithBLOBs stuTrainingWithBLOB : stuTrainingWithBLOBs) {
// BigDecimal moduleScore = getModuleScore(stuTrainingWithBLOB);
// SysThreeCatalog sysCourseChapter = CourseAPI.selectChapterByChapterId(stuTrainingWithBLOB.getChapterId());
// TeaTrainingDto newData = new TeaTrainingDto();
// BeanUtils.copyProperties(stuTrainingWithBLOB, newData);
// if (sysCourseChapter != null) {
// newData.setTaskModule(sysCourseChapter.getThreeName());
// }
// if (StringUtils.isNotBlank(stuTrainingWithBLOB.getReportId())) {
// String reportId = stuTrainingWithBLOB.getReportId();
// TrainingReport trainingReport = trainingReportMapper.selectByPrimaryKey(reportId);
// newData.setReportScore(trainingReport.getTeacherScore());
// }
// newData.setModuleScore(moduleScore);
// list.add(newData);
// }
// return list;
// }
@Override
public List<TeaTrainingDto> getTrainingDetailsInfo(String userId) throws IOException {
StuTrainingExample trainingExample = new StuTrainingExample();
trainingExample.createCriteria().andUserIdEqualTo(userId);
List<StuTrainingWithBLOBs> stuTrainingWithBLOBs = trainingMapper.selectByExampleWithBLOBs(trainingExample);
List<TeaTrainingDto> list = new ArrayList<>();
for (StuTrainingWithBLOBs stuTrainingWithBLOB : stuTrainingWithBLOBs) {
BigDecimal moduleScore = getModuleScore(stuTrainingWithBLOB);
SysThreeCatalog sysCourseChapter = CourseAPI.selectChapterByChapterId(stuTrainingWithBLOB.getChapterId());
TeaTrainingDto newData = new TeaTrainingDto();
BeanUtils.copyProperties(stuTrainingWithBLOB, newData);
if (sysCourseChapter != null) {
newData.setTaskModule(sysCourseChapter.getThreeName());
}
if (StringUtils.isNotBlank(stuTrainingWithBLOB.getReportId())) {
String reportId = stuTrainingWithBLOB.getReportId();
TrainingReport trainingReport = trainingReportMapper.selectByPrimaryKey(reportId);
newData.setReportScore(trainingReport.getTeacherScore());
public List<StuTrainingDto> getTrainingDetailsInfo(String userId, String schoolId, String systemOwner) {
List<StuTrainingDto> list = new ArrayList<>();
StuTrainingExample stuTrainingExample = new StuTrainingExample();
stuTrainingExample.createCriteria().andUserIdEqualTo(userId);
List<StuTrainingWithBLOBs> stuTrainings = stuTrainingMapper.selectByExampleWithBLOBs(stuTrainingExample);
Map<String, SysThreeCatalog> chapterMap = new HashMap<>();
try {
for (StuTrainingWithBLOBs stuTraining : stuTrainings) {
String chapterId = stuTraining.getChapterId();
SysThreeCatalog sysCourseChapter = chapterMap.get(chapterId);
if (sysCourseChapter == null) {
sysCourseChapter = CourseAPI.selectChapterByChapterId(chapterId);
chapterMap.put(chapterId, sysCourseChapter);
}
StuTrainingDto stuTrainingDto = new StuTrainingDto();
stuTrainingDto.setTaskModule(sysCourseChapter.getThreeName());
list.add(stuScoreService.getScoreByChapterId(schoolId, systemOwner, stuTraining, stuTrainingDto, sysCourseChapter));
}
newData.setModuleScore(moduleScore);
list.add(newData);
return list;
} catch (Exception e) {
return null;
}
return list;
}
//计算模块得分
@ -203,15 +244,15 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
}
@Override
public void exportTrainingDetailsInfo(HttpServletResponse response, String userId) throws IOException {
List<TeaTrainingDto> list = getTrainingDetailsInfo(userId);
public void exportTrainingDetailsInfo(HttpServletResponse response, String userId, String schoolId, String systemOwner) throws IOException {
List<StuTrainingDto> list = getTrainingDetailsInfo(userId, schoolId, systemOwner);
//导出的表名
String title = IdUtil.simpleUUID();
//表中第一行表头字段
String[] headers = {"任务模块", "模块得分", "知识概要得分", "资源学习得分", "学习测评得分", "实验实训得分", "实验报告得分"};
//具体需要写入excel需要哪些字段这些字段取自UserReward类也就是上面的实际数据结果集的泛型
List<String> listColumn = Arrays.asList("taskModule", "moduleScore", "knowledgeSummaryScore", "resourceLearningScore", "learningEvalScore", "expTrainingScore", "reportScore");
List<String> listColumn = Arrays.asList("taskModule", "moduleScore", "knowledgeSummaryScore", "resourceLearningScore", "learningEvalScore", "caseStuScore", "reportScore");
try {
FilePortUtil.exportExcel(response, title, headers, list, listColumn);
} catch (Exception e) {
@ -268,7 +309,12 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
s.setOrderByClause("average_score ASC");
List<StuTheoryRecord> list = stuTheoryRecordMapper.selectByExample(s);
List<StuTheoryRecordDto> dtoList = new ArrayList<>();
BeanUtils.copyProperties(list, dtoList);
// BeanUtils.copyProperties(list, dtoList);
for (StuTheoryRecord stuTheoryRecord : list) {
StuTheoryRecordDto stuTheoryRecordDto = new StuTheoryRecordDto();
BeanUtil.copyProperties(stuTheoryRecord, stuTheoryRecordDto);
dtoList.add(stuTheoryRecordDto);
}
int i = 0;
for (StuTheoryRecordDto stuTheoryRecordDto : dtoList) {
stuTheoryRecordDto.setRank(i++);
@ -279,7 +325,7 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
String[] headers = {"排名", "姓名", "学号", "考试次数", "考试最高分", "考试最低分", "考试合计时长"};
//具体需要写入excel需要哪些字段这些字段取自UserReward类也就是上面的实际数据结果集的泛型
List<String> listColumn = Arrays.asList("rank", "name", "studentId", "examCount", "highestScore", "lowestScore", "averageScore");
List<String> listColumn = Arrays.asList("rank", "name", "studentId", "examCount", "highestScore", "lowestScore", "totalDuration");
try {
FilePortUtil.exportExcel(response, title, headers, dtoList, listColumn);
} catch (Exception e) {

Loading…
Cancel
Save