whb 3 months ago
commit 16ec71a182

@ -38,6 +38,6 @@ public class Constant {
public static final String THEORY = "理论考试模块";
public static final String RESOURCE = "资源中心模块";
public static final String API_URL = "http://120.79.54.255:8889";
// public static final String API_URL = "http://192.168.2.44:8889";
// public static final String API_URL = "http://192.168.2.25:8889";
}

@ -48,10 +48,13 @@ public class ExerciseLearningEvaluation {
@AnonymousAccess
public ResultEntity commitObjectQuestionList(@RequestBody List<SysObjectiveQuestionDto> objectiveQuestionDtoList,
@RequestParam String userId,
@ApiParam("章节Id")@RequestParam String chapterId,@RequestParam String schoolId,@RequestParam String systemOwner){
@ApiParam("章节Id")@RequestParam String chapterId,
@RequestParam String schoolId,
@RequestParam String systemOwner,
@RequestParam String courseId){
Boolean flag= null;
try {
flag = exerciseService.commitObjectQuestionList(objectiveQuestionDtoList,userId,chapterId, schoolId, systemOwner);
flag = exerciseService.commitObjectQuestionList(objectiveQuestionDtoList,userId,chapterId, schoolId, systemOwner,courseId);
} catch (IOException e) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心客观题主键查询失败");
}

@ -132,8 +132,10 @@ public class StuIndexController {
List<StuClass> stuClassList = stuClassMapper.selectByExample(example);
StuClass stuClass = stuClassList.get(0);
stuUserDto.setClassName(stuClass.getClassName());
stuUserDto.setIpPlace(sysLoginLogs.get(0).getIpAddress());
stuUserDto.setLastIP(sysLoginLogs.get(0).getLoginIp());
if(!sysLoginLogs.isEmpty()){
stuUserDto.setIpPlace(sysLoginLogs.get(0).getIpAddress());
stuUserDto.setLastIP(sysLoginLogs.get(0).getLoginIp());
}
return new ResultEntity<StuUserDto>(stuUserDto);
}

@ -182,25 +182,27 @@ public class StuKnowledgeNote {
@RequestParam String systemOwner,
@RequestParam String trainingId) {
StuTrainingWithBLOBs stuTrainingWithBLOBs = stuTrainingMapper.selectByPrimaryKey(trainingId);
if (stuTrainingWithBLOBs.getKnowledgeSummaryCompleteStatus() != null) {
//不为空直接返回
return new ResultEntity<>(stuTrainingWithBLOBs.getKnowledgeSummaryScore());
}
//为空设置
SysWeight sysWeight = iTeaGradeManageService.getSysWeightResultEntity(courseId, schoolId, systemOwner);
BigDecimal knowledgeSummaryDefaultRule = sysWeight.getKnowledgeSummaryDefaultRule();
Integer knowledgeSummaryCompleteStatus = stuTrainingWithBLOBs.getKnowledgeSummaryCompleteStatus()==null?0:stuTrainingWithBLOBs.getKnowledgeSummaryCompleteStatus();
minutes=minutes+knowledgeSummaryCompleteStatus;
if (minutes < 1) {
stuTrainingWithBLOBs.setKnowledgeSummaryScore(BigDecimal.ZERO);
} else if (minutes == 1) {
stuTrainingWithBLOBs.setKnowledgeSummaryScore(knowledgeSummaryDefaultRule); //老师只能修改这个分值
} else {
int extraMinutes = minutes - 1;
int totalScore = 60 + extraMinutes * 10;
int totalScore = knowledgeSummaryDefaultRule.intValue() + extraMinutes * 10;
knowledgeSummaryDefaultRule = BigDecimal.valueOf(totalScore);
stuTrainingWithBLOBs.setKnowledgeSummaryScore(knowledgeSummaryDefaultRule);
if(knowledgeSummaryDefaultRule.compareTo(BigDecimal.valueOf(100))>0){
stuTrainingWithBLOBs.setKnowledgeSummaryScore(BigDecimal.valueOf(100));
}else {
stuTrainingWithBLOBs.setKnowledgeSummaryScore(knowledgeSummaryDefaultRule);
}
}
stuTrainingWithBLOBs.setResourceLearningCompleteStatus(minutes);
stuTrainingWithBLOBs.setKnowledgeSummaryCompleteStatus(minutes);
stuTrainingMapper.updateByPrimaryKey(stuTrainingWithBLOBs);
return new ResultEntity<>(knowledgeSummaryDefaultRule);
}

@ -78,6 +78,8 @@ public class TeaGradeManageController {
private StuTrainingMapper stuTrainingMapper;
@Autowired
StuScoreService stuScoreService;
@Value("${file.path}")
private String filePath;
@AnonymousAccess
@ -93,25 +95,32 @@ public class TeaGradeManageController {
return null;
}
List<TeaExamManageCountDto> teaExamManageCountDtos = new ArrayList<>();
Map<Integer, StuUser> userMap = new HashMap<>();
Map<String, StuUser> userMap = new HashMap<>();
List<Integer> userIds = new ArrayList<>();
List<String> userIds = new ArrayList<>();
for (TeaExamManage teaExamManage : teaExamManages) {
Integer zyUserId = Integer.parseInt(teaExamManage.getUserId()); //这里是智云 zyUserId
userIds.add(zyUserId);
userIds.add(teaExamManage.getUserId());
}
//存储用户信息
StuUserExample example = new StuUserExample();
example.createCriteria().andSystemOnwerEqualTo(systemOwner).andZyUseridIn(userIds);
example.createCriteria().andSystemOnwerEqualTo(systemOwner).andUseridIn(userIds);
List<StuUser> stuUsers = userMapper.selectByExample(example);
for (StuUser stuUser : stuUsers) {
userMap.put(stuUser.getZyUserid(), stuUser);
userMap.put(stuUser.getUserid(), stuUser);
}
for (TeaExamManage teaExamManage : teaExamManages) {
TeaExamManageCountDto copyexamManageWithBLOBs = new TeaExamManageCountDto();
String userId = teaExamManage.getUserId();
StuUser stuUser = userMap.get(userId);
if (stuUser == null) {
continue;
}
copyexamManageWithBLOBs.setName(stuUser.getName()); //发布人
teaExamManageCountDtos.add(copyexamManageWithBLOBs);
//获取班级和考试人数
TeaAndStudentExam teaAndStudentExam = teaAndStudentExamMapper.selectByExamMangeId(teaExamManage.getExamManageId());
@ -139,10 +148,6 @@ public class TeaGradeManageController {
String concatenatedTimeString = startTime + " -- " + endTime;
copyexamManageWithBLOBs.setExamTime(concatenatedTimeString); //考试时间
String userId = teaExamManage.getUserId();
StuUser stuUser = userMap.get(Integer.parseInt(userId));
copyexamManageWithBLOBs.setName(stuUser.getName()); //发布人
teaExamManageCountDtos.add(copyexamManageWithBLOBs);
}
PageInfo pageInfo = PageUtil.pageHelper(teaExamManageCountDtos, index, size);
return new ResultEntity<>(pageInfo);
@ -186,30 +191,6 @@ public class TeaGradeManageController {
}
// @GetMapping("/exportExam")
// @ApiOperation("考试模式--页面单个考试导出")
public void exportExam() {
//TODO 待写 页面单个考试导出
}
// @AnonymousAccess
// @GetMapping("/test")
// @ApiOperation("测试导出")
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
response.setHeader("Content-Disposition", "attachment; filename=exam_result.docx");
XWPFDocument document = new XWPFDocument();
XWPFParagraph paragraph = document.createParagraph();
XWPFRun run = paragraph.createRun();
run.setText("Python程序设计2022-2023学年度第一学期期末考试\n"
+ "答题人:沙志梅 学号21200780 课程Python程序设计 班级21金融科技华强2 提交时间2022-12-02 10:42 ip10.100.66.8 考试得分: 82 分\n"
+ "一. 单选题 (共15题,45分\n"
+ "1.赋值语句... (这里是你的题目内容)");
document.write(response.getOutputStream());
}
@AnonymousAccess
@PostMapping("/getCountChart")
@ -443,39 +424,54 @@ public class TeaGradeManageController {
return new ResultEntity<PageInfo<TeaTrainingInfoDTO>>(iTeaGradeManageService.getTrainingInfo(index, size, schoolId, keyWord, classId, systemOwner));
}
@AnonymousAccess
@GetMapping("/exportTrainingInfo")
@ApiOperation("***练习模式--页面导出")
public void exportTrainingInfo(HttpServletResponse response,
@RequestParam String schoolId,
@ApiParam("学号或姓名搜索框") @RequestParam(required = false) String keyWord,
@RequestParam(required = false) String classId,
@RequestParam String systemOwner) {
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
// @GetMapping("/exportTrainingInfo")
// @ApiOperation("***练习模式--页面导出")
// public void exportTrainingInfo(HttpServletResponse response,
// @RequestParam String schoolId,
// @ApiParam("学号或姓名搜索框") @RequestParam(required = false) String keyWord,
// @RequestParam(required = false) String classId,
// @RequestParam String systemOwner) {
// iTeaGradeManageService.exportTrainingInfo(response, schoolId, keyWord, classId, systemOwner);
// }
//
// @AnonymousAccess
// @PostMapping("/getTrainingDetailsInfo")
// @ApiOperation("练习模式--详情页面展示")
// public ResultEntity<List<StuTrainingDto>> 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();
}
}
//todo 新增的导出
@AnonymousAccess
@GetMapping("/exportAllStuTrainingInfo")
@ApiOperation("***练习模式--页面导出")
public void exportAllStuTrainingInfo(HttpServletResponse response,
@RequestParam String schoolId,
@RequestParam String systemOwner) throws IOException {
iTeaGradeManageService.exportAllStuTrainingInfo(response, schoolId, systemOwner);
}
@AnonymousAccess
@PostMapping("/getReportBySchoolID")
@ApiOperation("练习模式--实训报告展示")
@ -535,9 +531,6 @@ public class TeaGradeManageController {
}
@Value("${file.path}")
private String filePath;
@GetMapping("/getReportByReportId")
@ApiOperation("评阅--获取单个学生报告接口")
@AnonymousAccess
@ -639,8 +632,9 @@ public class TeaGradeManageController {
@ApiOperation("理论考试--导出理论考试信息")
public void exportTheoryExamInfo(HttpServletResponse response,
@ApiParam("不选择班级就是学习全部导出") @RequestParam(required = false) String classId,
@RequestParam String schoolId) {
iTeaGradeManageService.exportTheoryExamInfo(response, classId, schoolId);
@RequestParam String schoolId,
@RequestParam String systemOwner) {
iTeaGradeManageService.exportTheoryExamInfo(response, classId, schoolId, systemOwner);
}
@ -659,68 +653,48 @@ public class TeaGradeManageController {
return new ResultEntity<>(pageInfo);
}
//
// @AnonymousAccess
// @ApiOperation("老师端/练习模式得分详情展示")
// @PostMapping("getScoreInfo")
// public ResultEntity<List<StuTrainingDto>> getScoreInfo(@RequestParam String userId,
// @RequestParam String schoolId,
// @RequestParam String systemOwner) {
// List<StuTrainingDto> list = new ArrayList<>();
//
// StuTrainingExample stuTrainingExample = new StuTrainingExample();
// stuTrainingExample.createCriteria().andUserIdEqualTo(userId);
// List<StuTrainingWithBLOBs> stuTrainings = stuTrainingMapper.selectByExampleWithBLOBs(stuTrainingExample);
// //根据章节ID拿到课程ID 再去拿权重
// try {
// for (StuTrainingWithBLOBs stuTraining : stuTrainings) {
// StuTrainingDto stuTrainingDto = new StuTrainingDto();
// String chapterId = stuTraining.getChapterId();
// SysThreeCatalog sysCourseChapter = CourseAPI.selectChapterByChapterId(chapterId);
// stuTrainingDto.setTaskModule(sysCourseChapter.getThreeName());
// stuTrainingDto = stuScoreService.getScoreByChapterId(schoolId, systemOwner, stuTraining, stuTrainingDto, sysCourseChapter);
// list.add(stuTrainingDto);
// }
// } catch (IOException e) {
// return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心根据章节ID查询章节信息失败");
// }
// return new ResultEntity<>(list);
// }
@AnonymousAccess
@ApiOperation("老师端/练习模式得分详情展示")
@PostMapping("getScoreInfo")
public ResultEntity<List<StuTrainingDto>> getScoreInfo(@RequestParam String userId,
@RequestParam String schoolId,
@RequestParam String systemOwner) {
@RequestParam String systemOwner) throws IOException {
List<StuTrainingDto> list = new ArrayList<>();
List<SysTwoCatalog> sysTwoCatalogs = CourseAPI.selectCourseList(systemOwner,schoolId);
List<SysThreeCatalog>allChapterId =new ArrayList<>();
for (SysTwoCatalog sysTwoCatalog : sysTwoCatalogs) {
List<SysThreeCatalog> sysThreeCatalogs = CourseAPI.selectThreeCatalogListByTwoId(sysTwoCatalog.getTwoId(), schoolId);
allChapterId.addAll(sysThreeCatalogs);
}
StuTrainingExample stuTrainingExample = new StuTrainingExample();
stuTrainingExample.createCriteria().andUserIdEqualTo(userId);
List<StuTrainingWithBLOBs> stuTrainings = stuTrainingMapper.selectByExampleWithBLOBs(stuTrainingExample);
Map<String, SysThreeCatalog> chapterMap = new HashMap<>();
Map<String, SysThreeCatalog> chapterIds = allChapterId.stream().collect(Collectors.toMap(SysThreeCatalog::getThreeId, sysThreeCatalog -> sysThreeCatalog));
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);
SysThreeCatalog sysCourseChapter = chapterIds.get(chapterId);
if (sysCourseChapter==null){
continue;
}
StuTrainingDto stuTrainingDto = new StuTrainingDto();
stuTrainingDto.setTaskModule(sysCourseChapter.getThreeName());
list.add(stuScoreService.getScoreByChapterId(schoolId, systemOwner, stuTraining, stuTrainingDto, sysCourseChapter));
}
} catch (IOException e) {
} catch (Exception e) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心根据章节ID查询章节信息失败");
}
return new ResultEntity<>(list);
}
}

@ -80,28 +80,33 @@ public class TeaResourceCenterController {
@ApiOperation("学习资源-算分")
@PostMapping("getResourceScore") //观看资源1分钟得60分,1分钟以下不得分多1分钟加10分。
public ResultEntity<BigDecimal> getScore(@ApiParam("数字 单位分钟") @RequestParam Integer minutes,
@RequestParam String courseId,
@RequestParam String schoolId,
@RequestParam String systemOwner,
@RequestParam String trainingId) {
@RequestParam String courseId,
@RequestParam String schoolId,
@RequestParam String systemOwner,
@RequestParam String trainingId) {
StuTrainingWithBLOBs stuTrainingWithBLOBs = stuTrainingMapper.selectByPrimaryKey(trainingId);
if (stuTrainingWithBLOBs.getKnowledgeSummaryCompleteStatus() != null) {
//不为空直接返回
return new ResultEntity<>(stuTrainingWithBLOBs.getResourceLearningScore());
}
//为空设置
SysWeight sysWeight = iTeaGradeManageService.getSysWeightResultEntity(courseId, schoolId, systemOwner);
BigDecimal resourceLearningDefaultRule = sysWeight.getResourceLearningDefaultRule();
if (stuTrainingWithBLOBs.getResourceLearningCompleteStatus() != null) {
minutes = minutes + stuTrainingWithBLOBs.getResourceLearningCompleteStatus(); //累加时间
}
if (minutes < 1) {
stuTrainingWithBLOBs.setResourceLearningScore(BigDecimal.ZERO);
} else if (minutes == 1) {
stuTrainingWithBLOBs.setResourceLearningScore(resourceLearningDefaultRule); //老师只能修改这个分值
} else {
int extraMinutes = minutes - 1;
int totalScore = 60 + extraMinutes * 10;
int totalScore = resourceLearningDefaultRule.intValue() + extraMinutes * 10;
resourceLearningDefaultRule = BigDecimal.valueOf(totalScore);
stuTrainingWithBLOBs.setResourceLearningScore(resourceLearningDefaultRule);
if (resourceLearningDefaultRule.compareTo(BigDecimal.valueOf(100)) > 0) {
stuTrainingWithBLOBs.setResourceLearningScore(BigDecimal.valueOf(100));
}else {
stuTrainingWithBLOBs.setResourceLearningScore(resourceLearningDefaultRule);
}
}
stuTrainingWithBLOBs.setResourceLearningCompleteStatus(minutes);
stuTrainingMapper.updateByPrimaryKey(stuTrainingWithBLOBs);

@ -0,0 +1,37 @@
package com.sztzjy.financial_bigdata.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
* @Author xcj
* @Date 2024/12/10
*/
@Data
@NoArgsConstructor
public class ExcelDto {
@ApiModelProperty("排名")
private int rank;
@ApiModelProperty("姓名")
private String name;
@ApiModelProperty("学号")
private String studentId;
@ApiModelProperty("班级名称")
private String className;
@ApiModelProperty("综合得分")
private BigDecimal totalScore;
@ApiModelProperty("实训进度")
private BigDecimal progress;
private Map<String,BigDecimal>map;
}

@ -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;
}

@ -33,4 +33,9 @@ public interface StuTheoryRecordMapper {
int updateByPrimaryKey(StuTheoryRecord record);
StuTheoryIndexInfoDto selectTheoryInfo(@Param("userId") String userId);
List<StuTheoryRecord> selectConditions(@Param("schoolId") String schoolId,
@Param("classId") String classId,
@Param("keyWord") String keyWord,
@Param("systemOwner") String systemOwner);
}

@ -9,5 +9,5 @@ import java.util.List;
public interface IExerciseService {
List<SysObjectiveQuestionDto> selectObjectQuestionListByChapterId(String chapterId, String userId,String schoolId,String systemOwner) throws IOException;
Boolean commitObjectQuestionList(List<SysObjectiveQuestionDto> objectiveQuestionDtoList, String userId, String chapterId,String schoolId,String systemOwner) throws IOException;
Boolean commitObjectQuestionList(List<SysObjectiveQuestionDto> objectiveQuestionDtoList, String userId, String chapterId,String schoolId,String systemOwner,String courseId) throws IOException;
}

@ -1,13 +1,13 @@
package com.sztzjy.financial_bigdata.service.stu.impl;
import com.sztzjy.financial_bigdata.entity.StuTraining;
import com.sztzjy.financial_bigdata.entity.StuTrainingExample;
import com.sztzjy.financial_bigdata.entity.StuTrainingWithBLOBs;
import com.sztzjy.financial_bigdata.entity.SysObjectiveQuestion;
import cn.hutool.core.util.IdUtil;
import com.sztzjy.financial_bigdata.entity.*;
import com.sztzjy.financial_bigdata.entity.resource_entity.SysObjectiveQuestions;
import com.sztzjy.financial_bigdata.entity.stu_dto.StuTrainingDto;
import com.sztzjy.financial_bigdata.entity.sys_dto.SysObjectiveQuestionDto;
import com.sztzjy.financial_bigdata.mapper.StuTrainingMapper;
import com.sztzjy.financial_bigdata.mapper.SysObjectiveQuestionMapper;
import com.sztzjy.financial_bigdata.mapper.SysWeightMapper;
import com.sztzjy.financial_bigdata.resourceCenterAPI.ObjectiveApi;
import com.sztzjy.financial_bigdata.service.stu.IExerciseService;
import com.sztzjy.financial_bigdata.service.tea.ITeaObjectiveService;
@ -27,6 +27,8 @@ public class ExerciseServiceImpl implements IExerciseService {
ITeaObjectiveService objectiveService;
@Autowired
SysObjectiveQuestionMapper objectiveQuestionMapper;
@Autowired
SysWeightMapper sysWeightMapper;
@Override
public List<SysObjectiveQuestionDto> selectObjectQuestionListByChapterId(String chapterId, String userId,String schoolId,String systemOwner) throws IOException {
@ -111,12 +113,37 @@ public class ExerciseServiceImpl implements IExerciseService {
}
@Override
public Boolean commitObjectQuestionList(List<SysObjectiveQuestionDto> objectiveQuestionDtoList, String userId, String chapterId,String schoolId,String systemOwner) throws IOException {
public Boolean commitObjectQuestionList(List<SysObjectiveQuestionDto> objectiveQuestionDtoList, String userId, String chapterId,String schoolId,String systemOwner,String courseId) throws IOException {
StuTrainingExample example = new StuTrainingExample();
example.createCriteria().andUserIdEqualTo(userId).andChapterIdEqualTo(chapterId);
List<StuTrainingWithBLOBs> stuTrainingWithBLOBs = trainingMapper.selectByExampleWithBLOBs(example);
SysWeightExample sysWeightExample =new SysWeightExample();
sysWeightExample.createCriteria().andSchoolIdEqualTo(schoolId).andSystemOwnerEqualTo(systemOwner).andCourseIdEqualTo(courseId);
List<SysWeight> sysWeights = sysWeightMapper.selectByExample(sysWeightExample);
SysWeight sysWeight = new SysWeight();
if (sysWeights.isEmpty()){
//设置默认权重
sysWeight.setCourseId(courseId);
sysWeight.setWeightId(IdUtil.randomUUID());
sysWeight.setSchoolId(schoolId);
sysWeight.setSystemOwner(systemOwner);
sysWeight.setKnowledgeSummaryDefaultRule(BigDecimal.valueOf(60)); //知识概要默认计分规则 阅读1分钟得60分,1分钟以下不得分多1分钟加10分。
sysWeight.setResourceLearningDefaultRule(BigDecimal.valueOf(60)); //资源学习默认计分规则 观看资源1分钟得60分,1分钟以下不得分多1分钟加10分。
sysWeight.setLearningEvalDefaultRule(BigDecimal.valueOf(10)); //学习测评默认计分规则 客观题10分每道
sysWeight.setExpTrainingDefautRule(BigDecimal.valueOf(2));//实训题,输错/选错次数扣2分最低0分
sysWeight.setKnowledgeSummaryWeight(BigDecimal.valueOf(5));
sysWeight.setResourceLearningWeight(BigDecimal.valueOf(5));
sysWeight.setLearningEvalWeight(BigDecimal.valueOf(20));
sysWeight.setExpTrainingWeight(BigDecimal.valueOf(60));
sysWeight.setReportWeight(BigDecimal.valueOf(10));
sysWeightMapper.insert(sysWeight);
}else {
sysWeight = sysWeights.get(0);
}
// if (stuTrainingWithBLOBs.get(0).getLearningEvalAnswer()!=null){
// return false;
// }
@ -133,7 +160,7 @@ public class ExerciseServiceImpl implements IExerciseService {
String answer = objectiveQuestion.getAnswer();
stuAnswerList.add(stuAnswer);
if(answer.equals(stuAnswer)){
learning_eval_score= learning_eval_score.add(objectiveQuestion.getScore());
learning_eval_score= learning_eval_score.add(sysWeight.getLearningEvalDefaultRule());
}else {
errorCount++;
}

@ -135,14 +135,96 @@ public class StuScoreServiceImpl implements StuScoreService {
BeanUtils.copyProperties(stuTrainingWithBLOBs, stuTrainingDto); // 完成情况和得分
// 计算各模块得分
calculateModuleScores(stuTrainingWithBLOBs, stuTrainingDto);
//知识概要和学习资源得分已经乘过权重,直接返回
if (stuTrainingDto.getCaseStuScore() == null) {
stuTrainingDto.setCaseStuScore(BigDecimal.ZERO);
} else {
BigDecimal caseStuScore = stuTrainingDto.getCaseStuScore(); //实验实训得分
BigDecimal expTrainingWeight = stuTrainingDto.getExpTrainingWeight(); //实验实训权重
BigDecimal weightCaseScore = expTrainingWeight.multiply(caseStuScore).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
stuTrainingDto.setCaseStuScore(weightCaseScore); //返回乘过权重的
}
//学习测评
if (stuTrainingDto.getLearningEvalScore() == null) {
stuTrainingDto.setLearningEvalScore(BigDecimal.ZERO);
} else {
BigDecimal learningEvalScore = stuTrainingDto.getLearningEvalScore();
BigDecimal learningEvalWeight = stuTrainingDto.getLearningEvalWeight();
BigDecimal weightLearningEvalScore = learningEvalWeight.multiply(learningEvalScore).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
stuTrainingDto.setLearningEvalScore(weightLearningEvalScore);
}
//学习资源
if (stuTrainingDto.getResourceLearningScore()==null){
stuTrainingDto.setResourceLearningScore(BigDecimal.ZERO);
}else {
BigDecimal resourceLearningScore = stuTrainingDto.getResourceLearningScore();
BigDecimal resourceLearningWeight = stuTrainingDto.getResourceLearningWeight();
BigDecimal weightLearningEvalScore = resourceLearningWeight.multiply(resourceLearningScore).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
stuTrainingDto.setResourceLearningScore(weightLearningEvalScore);
}
//知识概要
if (stuTrainingDto.getKnowledgeSummaryScore() == null) {
stuTrainingDto.setKnowledgeSummaryScore(BigDecimal.ZERO);
} else {
BigDecimal knowledgeSummaryScore = stuTrainingDto.getKnowledgeSummaryScore();
BigDecimal knowledgeSummaryWeight = stuTrainingDto.getKnowledgeSummaryWeight();
BigDecimal weightKnowledgeSummaryScore = knowledgeSummaryWeight.multiply(knowledgeSummaryScore).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
stuTrainingDto.setKnowledgeSummaryScore(weightKnowledgeSummaryScore);
}
// 设置报告相关数据
setReportData(stuTrainingDto, stuTrainingWithBLOBs.getReportId());
TrainingReport trainingReport = trainingReportMapper.selectByPrimaryKey(stuTrainingWithBLOBs.getReportId());
if (trainingReport == null) {
stuTrainingDto.setReportCompleteStatus("未提交");
stuTrainingDto.setReportScore(BigDecimal.ZERO);
} else {
BigDecimal reportScore = trainingReport.getTeacherScore();
BigDecimal reportWeight = stuTrainingDto.getReportWeight();
BigDecimal weightReportScore = reportScore.multiply(reportWeight).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
stuTrainingDto.setReportScore(weightReportScore);
stuTrainingDto.setReportCompleteStatus("已提交");
}
//计算模块总得分
setTotalScore(stuTrainingDto);
return stuTrainingDto;
}
private void setTotalScore(StuTrainingDto stuTrainingDto) {
BigDecimal totalScore = BigDecimal.ZERO;
if (stuTrainingDto.getKnowledgeSummaryScore() != null) {
totalScore = totalScore.add(stuTrainingDto.getKnowledgeSummaryScore());
} else {
stuTrainingDto.setKnowledgeSummaryScore(BigDecimal.ZERO);
}
if (stuTrainingDto.getResourceLearningScore() != null) {
totalScore = totalScore.add(stuTrainingDto.getResourceLearningScore());
} else {
stuTrainingDto.setResourceLearningScore(BigDecimal.ZERO);
}
if (stuTrainingDto.getLearningEvalScore() != null) {
totalScore = totalScore.add(stuTrainingDto.getLearningEvalScore());
} else {
stuTrainingDto.setLearningEvalScore(BigDecimal.ZERO);
}
if (stuTrainingDto.getCaseStuScore() != null) {
totalScore = totalScore.add(stuTrainingDto.getCaseStuScore());
} else {
stuTrainingDto.setCaseStuScore(BigDecimal.ZERO);
}
if (stuTrainingDto.getReportScore() != null) {
totalScore = totalScore.add(stuTrainingDto.getReportScore());
} else {
stuTrainingDto.setReportScore(BigDecimal.ZERO);
}
stuTrainingDto.setModuleScore(totalScore);
}
private void setDefaultWeights(StuTrainingDto stuTrainingDto) {
stuTrainingDto.setKnowledgeSummaryDefaultRule(BigDecimal.valueOf(60));
stuTrainingDto.setResourceLearningDefaultRule(BigDecimal.valueOf(60));
@ -155,58 +237,4 @@ public class StuScoreServiceImpl implements StuScoreService {
stuTrainingDto.setReportWeight(BigDecimal.valueOf(10));
}
private void calculateModuleScores(StuTrainingWithBLOBs stuTrainingWithBLOBs, StuTrainingDto stuTrainingDto) {
stuTrainingDto.setKnowledgeSummaryScore(calculateScore(
stuTrainingDto.getKnowledgeSummaryDefaultRule(),
stuTrainingDto.getKnowledgeSummaryWeight(),
stuTrainingWithBLOBs.getKnowledgeSummaryCompleteStatus()
));
stuTrainingDto.setResourceLearningScore(calculateScore(
stuTrainingDto.getResourceLearningDefaultRule(),
stuTrainingDto.getResourceLearningWeight(),
stuTrainingWithBLOBs.getResourceLearningCompleteStatus()
));
stuTrainingDto.setLearningEvalScore(calculateEvaluationScore(
stuTrainingDto.getLearningEvalDefaultRule(),
stuTrainingDto.getLearningEvalWeight(),
stuTrainingWithBLOBs.getLearningEvalCompleteStatus()
));
stuTrainingDto.setCaseStuScore(calculateEvaluationScore(
stuTrainingDto.getExpTrainingDefautRule(),
stuTrainingDto.getExpTrainingWeight(),
stuTrainingWithBLOBs.getExpTrainingCompleteStatus()
));
}
private BigDecimal calculateScore(BigDecimal defaultRule, BigDecimal weight, Integer completeStatus) {
if (completeStatus != null && completeStatus > 0) {
BigDecimal score = defaultRule.add(BigDecimal.valueOf((completeStatus - 1) * 10));
score = score.min(BigDecimal.valueOf(100)); // 确保分数不超过100
return score.multiply(weight.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP));
}
return BigDecimal.ZERO;
}
private BigDecimal calculateEvaluationScore(BigDecimal defaultRule, BigDecimal weight, Integer completeStatus) {
if (completeStatus != null) {
BigDecimal score = BigDecimal.valueOf(100).subtract(defaultRule.multiply(BigDecimal.valueOf(completeStatus)));
return score.max(BigDecimal.ZERO).multiply(weight.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP));
}
return BigDecimal.ZERO;
}
private void setReportData(StuTrainingDto stuTrainingDto, String reportId) {
TrainingReport trainingReport = trainingReportMapper.selectByPrimaryKey(reportId);
if (trainingReport == null || trainingReport.getTeacherScore() == null) {
stuTrainingDto.setReportCompleteStatus("未提交");
stuTrainingDto.setReportScore(null);
} else {
stuTrainingDto.setReportCompleteStatus("已提交");
stuTrainingDto.setReportScore(trainingReport.getTeacherScore());
}
}
}

@ -3,11 +3,11 @@ 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 +18,23 @@ 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,String systemOwner);
SysWeight getSysWeightResultEntity(String courseId, String schoolId, String systemOwner);
void exportAllStuTrainingInfo(HttpServletResponse response, String schoolId, String systemOwner) throws IOException;
}

@ -148,7 +148,7 @@ public class TeaCaseStepServiceImpl implements ITeaCaseStepService {
StuTrainingStepRecord stepRecord = stuTrainingStepRecords.get(0);
stepRecord.setStuAnswer(commitCaseDto.getStuAnswer());
trainingStepRecordMapper.updateByPrimaryKeyWithBLOBs(stepRecord);
return false;
return true;
}
}
}

@ -1,19 +1,25 @@
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.resource_entity.SysTwoCatalog;
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 +54,135 @@ 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;
}
private List<TeaTrainingInfoDTO> getTrainingInfoDTOSNew(String schoolId, String systemOwner) {
List<TeaTrainingInfoDTO> list = getTeaTrainingInfoDTOSNew(schoolId, systemOwner);
assert !Objects.requireNonNull(list).isEmpty();
list.sort(new TotalScoreComparator());
int i = 0;
for (TeaTrainingInfoDTO teaTrainingInfoDTO : list) {
i++;
teaTrainingInfoDTO.setRank(i);
}
return list;
}
private List<TeaTrainingInfoDTO> getTeaTrainingInfoDTOSNew(String schoolId, String systemOwner) {
StuUserExample example1 = new StuUserExample();
example1.createCriteria().andSchoolIdEqualTo(schoolId).andSystemOnwerEqualTo(systemOwner).andRoleIdEqualTo(4);
List<StuUser> stuUsers = userMapper.selectByExample(example1);
// 查询学生用户列表
if (stuUsers.isEmpty()) {
return Collections.emptyList();
}
// 批量获取班级信息
Set<String> classIds = stuUsers.stream().map(StuUser::getClassId).collect(Collectors.toSet());
StuClassExample example = new StuClassExample();
List<String> IDlist = new ArrayList<>(classIds);
example.createCriteria().andClassIdIn(IDlist).andSystemOwnerEqualTo(systemOwner);
List<StuClass> stuClasses = classMapper.selectByExample(example);
Map<String, String> classIdToNameMap = stuClasses.stream().collect(Collectors.toMap(StuClass::getClassId, StuClass::getClassName));
//拿到权重
SysWeightExample sysWeightExample = new SysWeightExample();
sysWeightExample.createCriteria().andSchoolIdEqualTo(schoolId);
List<SysWeight> sysWeights = sysWeightMapper.selectByExample(sysWeightExample);
SysWeight sysWeight = sysWeights.get(0);
// 批量获取实训记录
Set<String> userIds = stuUsers.stream().map(StuUser::getUserid).collect(Collectors.toSet());
StuTrainingExample stuTrainingExample = new StuTrainingExample();
stuTrainingExample.createCriteria().andUserIdIn(new ArrayList<>(userIds));
List<StuTrainingWithBLOBs> stuTrainingsWithBLOBs = trainingMapper.selectByExampleWithBLOBs(stuTrainingExample);
if (stuTrainingsWithBLOBs.isEmpty()) {
return Collections.emptyList();
}
// 实训记录按用户ID分组
Map<String, List<StuTrainingWithBLOBs>> userIdToTrainingsMap = stuTrainingsWithBLOBs.stream().collect(Collectors.groupingBy(StuTrainingWithBLOBs::getUserId));
// 批量获取报告分数
Set<String> reportIds = stuTrainingsWithBLOBs.stream().map(StuTrainingWithBLOBs::getReportId).collect(Collectors.toSet());
List<TrainingReport> trainingReports = trainingReportMapper.selectByPrimaryKeys(reportIds);
Map<String, BigDecimal> reportIdToScoreMap = trainingReports.stream().collect(Collectors.toMap(TrainingReport::getReportId, TrainingReport::getTeacherScore));
// 获取总模块数量
BigDecimal chapterNum = null;
try {
chapterNum = BigDecimal.valueOf(CourseAPI.getTotalChapterCount(systemOwner));
} catch (IOException e) {
return null;
}
// 遍历用户计算分数并封装DTO
List<TeaTrainingInfoDTO> list = new ArrayList<>();
for (StuUser stuUser : stuUsers) {
List<StuTrainingWithBLOBs> userTrainings = userIdToTrainingsMap.getOrDefault(stuUser.getUserid(), Collections.emptyList());
if (userTrainings.isEmpty()) {
continue;
}
TeaTrainingInfoDTO teaTrainingInfoDTO = new TeaTrainingInfoDTO();
teaTrainingInfoDTO.setClassName(classIdToNameMap.get(stuUser.getClassId()));
teaTrainingInfoDTO.setStudentId(stuUser.getStudentId());
teaTrainingInfoDTO.setName(stuUser.getName());
teaTrainingInfoDTO.setUserId(stuUser.getUserid());
BigDecimal allProgress = BigDecimal.ZERO;
BigDecimal totalScore = BigDecimal.ZERO;
for (StuTrainingWithBLOBs training : userTrainings) {
allProgress = allProgress.add(Optional.ofNullable(training.getProgress()).orElse(BigDecimal.ZERO));
String reportId = training.getReportId();
if (reportId != null) {
BigDecimal reportScore = reportIdToScoreMap.getOrDefault(reportId, BigDecimal.ZERO);
if (BigDecimal.ZERO.compareTo(reportScore) != 0) {
totalScore = totalScore.add(reportScore);
}
}
//其他模块算分
BigDecimal moduleScore = getModuleScore(training, sysWeight);
totalScore = moduleScore.add(totalScore).setScale(2, RoundingMode.HALF_UP);
}
//这个综合得分的公式为 各个页面得分*权重 = 单个模块得分 所有模块得分之和/系统章节数 = 综合得分
BigDecimal score = totalScore;
if (totalScore.compareTo(BigDecimal.ZERO) > 0) {
score = totalScore.divide(chapterNum, 2, RoundingMode.HALF_UP);
}
teaTrainingInfoDTO.setTotalScore(score);
BigDecimal progress = allProgress.divide(BigDecimal.valueOf(userTrainings.size()), 2, RoundingMode.HALF_UP);
teaTrainingInfoDTO.setProgress(progress);
list.add(teaTrainingInfoDTO);
}
return list;
}
@ -70,22 +192,23 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
* @author xcj
* @Date 2024/3/19
*/
@Override
public void exportTrainingInfo(HttpServletResponse response, String schoolId, String keyWord, String classId, String systemOwner) {
List<TeaTrainingInfoDTO> list = getTeaTrainingInfoDTOS(schoolId, keyWord, classId, systemOwner);
//导出的表名
String title = IdUtil.simpleUUID();
//表中第一行表头字段
String[] headers = {"排名", "姓名", "学号", "班级名称", "综合得分", "实训进度"};
//具体需要写入excel需要哪些字段这些字段取自UserReward类也就是上面的实际数据结果集的泛型
List<String> listColumn = Arrays.asList("rank", "name", "studentId", "className", "totalScore", "progress");
try {
FilePortUtil.exportExcel(response, title, headers, list, listColumn);
} catch (Exception e) {
e.printStackTrace();
}
}
// @Override
// public void exportTrainingInfo(HttpServletResponse response, String schoolId, String keyWord, String classId, String systemOwner) {
// List<TeaTrainingInfoDTO> list = getTrainingInfoDTOS(schoolId, keyWord, classId, systemOwner);
//
// //导出的表名
// String title = IdUtil.simpleUUID();
// //表中第一行表头字段
// String[] headers = {"排名", "姓名", "学号", "班级名称", "综合得分", "实训进度"};
//
// //具体需要写入excel需要哪些字段这些字段取自UserReward类也就是上面的实际数据结果集的泛型
// List<String> listColumn = Arrays.asList("rank", "name", "studentId", "className", "totalScore", "progress");
// try {
// FilePortUtil.exportExcel(response, title, headers, list, listColumn);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//饼形图
@Override
@ -168,50 +291,91 @@ 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;
}
//计算模块得分
private BigDecimal getModuleScore(StuTrainingWithBLOBs stuTrainingWithBLOB) {
private BigDecimal getModuleScore(StuTrainingWithBLOBs stuTrainingWithBLOB, SysWeight sysWeight) {
BigDecimal knowledgeSummaryWeight = sysWeight.getKnowledgeSummaryWeight();
BigDecimal resourceLearningWeight = sysWeight.getResourceLearningWeight();
BigDecimal learningEvalWeight = sysWeight.getLearningEvalWeight();
BigDecimal expTrainingWeight = sysWeight.getExpTrainingWeight();
//知识概要和学习资源乘过权重了
BigDecimal knowledgeSummaryScore = Optional.ofNullable(stuTrainingWithBLOB.getKnowledgeSummaryScore()).orElse(BigDecimal.ZERO);
BigDecimal resourceLearningScore = Optional.ofNullable(stuTrainingWithBLOB.getResourceLearningScore()).orElse(BigDecimal.ZERO);
BigDecimal learningEvalScore = Optional.ofNullable(stuTrainingWithBLOB.getLearningEvalScore()).orElse(BigDecimal.ZERO);
BigDecimal expTrainingScore = Optional.ofNullable(stuTrainingWithBLOB.getExpTrainingScore()).orElse(BigDecimal.ZERO);
knowledgeSummaryScore = knowledgeSummaryWeight.multiply(knowledgeSummaryScore);
resourceLearningScore = resourceLearningScore.multiply(resourceLearningWeight);
learningEvalScore = learningEvalScore.multiply(learningEvalWeight).divide(BigDecimal.valueOf(100).setScale(2,RoundingMode.HALF_UP));
expTrainingScore = expTrainingScore.multiply(expTrainingWeight).divide(BigDecimal.valueOf(100).setScale(2,RoundingMode.HALF_UP));
return knowledgeSummaryScore.add(resourceLearningScore).add(learningEvalScore).add(expTrainingScore);
}
@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) {
@ -231,44 +395,50 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
@Override
public PageInfo<StuTheoryRecord> getTheoryInfo(Integer index, Integer size, String schoolId, String classId, String keyWord, String systemOwner) {
PageHelper.startPage(index, size);
List<StuTheoryRecord> list = getStuTheoryRecordPageInfo(schoolId, classId, keyWord, systemOwner);
// List<StuTheoryRecord> list = getStuTheoryRecordPageInfo(schoolId, classId, keyWord, systemOwner);
List<StuTheoryRecord> list = stuTheoryRecordMapper.selectConditions(schoolId, classId, keyWord, systemOwner);
PageInfo<StuTheoryRecord> pageInfo = new PageInfo<>(list);
return pageInfo;
}
//查询方法
private List<StuTheoryRecord> getStuTheoryRecordPageInfo(String schoolId, String classId, String keyWord, String systemOwner) {
StuTheoryRecordExample s = new StuTheoryRecordExample();
StuTheoryRecordExample.Criteria criteria = s.createCriteria();
StuTheoryRecordExample.Criteria orCriteria = s.createCriteria();
criteria.andSchoolIdEqualTo(schoolId).andSystemOwnerEqualTo(systemOwner);
orCriteria.andSchoolIdEqualTo(schoolId).andSystemOwnerEqualTo(systemOwner);
if (StringUtils.isNotBlank(classId)) {
criteria.andClassIdEqualTo(classId);
orCriteria.andClassIdEqualTo(classId);
}
if (StringUtils.isNotBlank(keyWord)) {
criteria.andStudentIdEqualTo(keyWord);
orCriteria.andNameEqualTo(keyWord);
}
s.or(orCriteria);
s.setOrderByClause("average_score ASC");
return stuTheoryRecordMapper.selectByExample(s);
}
// //查询方法
// private List<StuTheoryRecord> getStuTheoryRecordPageInfo(String schoolId, String classId, String keyWord, String systemOwner) {
// StuTheoryRecordExample s = new StuTheoryRecordExample();
// StuTheoryRecordExample.Criteria criteria = s.createCriteria();
// StuTheoryRecordExample.Criteria orCriteria = s.createCriteria();
// criteria.andSchoolIdEqualTo(schoolId).andSystemOwnerEqualTo(systemOwner);
// orCriteria.andSchoolIdEqualTo(schoolId).andSystemOwnerEqualTo(systemOwner);
// if (StringUtils.isNotBlank(classId)) {
// criteria.andClassIdEqualTo(classId);
// orCriteria.andClassIdEqualTo(classId);
// }
// if (StringUtils.isNotBlank(keyWord)) {
// criteria.andStudentIdEqualTo(keyWord);
// orCriteria.andNameEqualTo(keyWord);
// }
// s.or(orCriteria);
// s.setOrderByClause("average_score ASC");
// return stuTheoryRecordMapper.selectByExample(s);
// }
@Override
public void exportTheoryExamInfo(HttpServletResponse response, String classId, String schoolId) {
public void exportTheoryExamInfo(HttpServletResponse response, String classId, String schoolId, String systemOwner) {
StuTheoryRecordExample s = new StuTheoryRecordExample();
StuTheoryRecordExample.Criteria criteria = s.createCriteria();
criteria.andSchoolIdEqualTo(schoolId);
criteria.andSchoolIdEqualTo(schoolId).andSystemOwnerEqualTo(systemOwner);
if (StringUtils.isNotBlank(classId)) {
criteria.andClassIdEqualTo(classId);
}
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 +449,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) {
@ -315,6 +485,79 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
}
//todo 新的导出
@Override
public void exportAllStuTrainingInfo(HttpServletResponse response, String schoolId, String systemOwner) throws IOException {
List<TeaTrainingInfoDTO> trainingInfoDTOSNew = getTrainingInfoDTOSNew(schoolId, systemOwner);
List<SysTwoCatalog> sysTwoCatalogs = CourseAPI.selectCourseList(systemOwner, schoolId);
List<SysThreeCatalog> allChapterId = new ArrayList<>();
for (SysTwoCatalog sysTwoCatalog : sysTwoCatalogs) {
List<SysThreeCatalog> sysThreeCatalogs = CourseAPI.selectThreeCatalogListByTwoId(sysTwoCatalog.getTwoId(), schoolId);
allChapterId.addAll(sysThreeCatalogs);
}
Map<String, SysThreeCatalog> chapterIds = allChapterId.stream().collect(Collectors.toMap(SysThreeCatalog::getThreeId, sysThreeCatalog -> sysThreeCatalog));
List<ExcelDto> excelDtos = new ArrayList<>();
for (TeaTrainingInfoDTO teaTrainingInfoDTO : trainingInfoDTOSNew) {
ExcelDto excelDto = new ExcelDto();
excelDto.setProgress(teaTrainingInfoDTO.getProgress());
excelDto.setName(teaTrainingInfoDTO.getName());
excelDto.setStudentId(teaTrainingInfoDTO.getStudentId());
excelDto.setRank(teaTrainingInfoDTO.getRank());
excelDto.setTotalScore(teaTrainingInfoDTO.getTotalScore());
String userId = teaTrainingInfoDTO.getUserId();
StuTrainingExample stuTrainingExample = new StuTrainingExample();
stuTrainingExample.createCriteria().andUserIdEqualTo(userId);
List<StuTrainingWithBLOBs> stuTrainings = stuTrainingMapper.selectByExampleWithBLOBs(stuTrainingExample);
LinkedHashMap<String, BigDecimal> map = new LinkedHashMap<>();
LinkedHashMap<String, SysThreeCatalog> chapterMap = new LinkedHashMap<>();
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());
StuTrainingDto scoreByChapterId = stuScoreService.getScoreByChapterId(schoolId, systemOwner, stuTraining, stuTrainingDto, sysCourseChapter);
BigDecimal moduleScore = scoreByChapterId.getModuleScore();
String taskModule = scoreByChapterId.getTaskModule();
map.put(taskModule, moduleScore);
}
excelDto.setMap(map);
excelDtos.add(excelDto);
}
//导出的表名
String title = IdUtil.simpleUUID();
//表中第一行表头字段
String[] headers = {"排名", "姓名", "学号", "班级名称", "综合得分", "实训进度"};
List<String> headerList = new ArrayList<>(Arrays.asList(headers)); // 将headers数组转换为List
for (Map.Entry<String, SysThreeCatalog> stringBigDecimalEntry : chapterIds.entrySet()) {
String name = stringBigDecimalEntry.getValue().getThreeName();
headerList.add(name);
}
headers = headerList.toArray(new String[0]); // 将List转回数组
//具体需要写入excel需要哪些字段这些字段取自UserReward类也就是上面的实际数据结果集的泛型
List<String> listColumn = Arrays.asList("rank", "name", "studentId", "className", "totalScore", "progress");
try {
FilePortUtil.exportExcelNew(response, title, headers, excelDtos, listColumn);
} catch (
Exception e) {
e.printStackTrace();
}
}
private List<TeaTrainingInfoDTO> getTeaTrainingInfoDTOS(String schoolId, String keyWord, String classId, String systemOwner) {
List<StuUser> stuUsers = userMapper.getByNameAndStudentID(schoolId, keyWord, classId, systemOwner);
@ -355,6 +598,11 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
} catch (IOException e) {
return null;
}
//拿到权重
SysWeightExample sysWeightExample = new SysWeightExample();
sysWeightExample.createCriteria().andSchoolIdEqualTo(schoolId);
List<SysWeight> sysWeights = sysWeightMapper.selectByExample(sysWeightExample);
SysWeight sysWeight = sysWeights.get(0);
// 遍历用户计算分数并封装DTO
List<TeaTrainingInfoDTO> list = new ArrayList<>();
@ -364,6 +612,7 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
continue;
}
TeaTrainingInfoDTO teaTrainingInfoDTO = new TeaTrainingInfoDTO();
teaTrainingInfoDTO.setClassName(classIdToNameMap.get(stuUser.getClassId()));
teaTrainingInfoDTO.setStudentId(stuUser.getStudentId());
@ -378,10 +627,12 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
if (reportId != null) {
BigDecimal reportScore = reportIdToScoreMap.getOrDefault(reportId, BigDecimal.ZERO);
if (BigDecimal.ZERO.compareTo(reportScore) != 0) {
reportScore = reportScore.multiply(sysWeight.getReportWeight().setScale(2, RoundingMode.HALF_UP));
totalScore = totalScore.add(reportScore);
}
}
// 省略其他分数加法代码
BigDecimal moduleScore = getModuleScore(training, sysWeight);
totalScore = moduleScore.add(totalScore).setScale(2, RoundingMode.HALF_UP);
}
BigDecimal score = totalScore;

@ -3,6 +3,7 @@ package com.sztzjy.financial_bigdata.util.excel;
import com.github.xiaoymin.knife4j.core.util.CollectionUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.poi.hssf.usermodel.*;
import org.geolatte.geom.M;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -10,9 +11,8 @@ import javax.servlet.http.HttpServletResponse;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.math.BigDecimal;
import java.util.*;
/*
* @author xcj
@ -83,6 +83,79 @@ public class FilePortUtil {
}
}
public static <T> void exportExcelNew(HttpServletResponse response, String title, String[] headers, List<T> list, List<String> containBean) throws Exception {
HSSFWorkbook workbook = null;
try {
workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet(title);
HSSFRow row = sheet.createRow(0);
/*创建第一行表头*/
for (short i = 0; i < headers.length; i++) {
HSSFCell cell = row.createCell(i);
HSSFRichTextString text = new HSSFRichTextString(headers[i]);
cell.setCellValue(text);
}
Iterator<T> it = list.iterator();
int index = 0;
while (it.hasNext()) {
index++;
row = sheet.createRow(index);
T t = (T) it.next();
/*反射得到字段*/
Field[] fields = t.getClass().getDeclaredFields();
/*如果需要匹配*/
if (CollectionUtils.isNotEmpty(containBean)) {
for (int j = 0; j < containBean.size(); j++) {
for (int i = 0; i < fields.length; i++) {
Field field = fields[i];
if (!field.getName().equals(containBean.get(j)))
continue;
/*给每一列set值*/
setCellValue(t, field, row, j);
}
}
} else {
for (int i = 0; i < fields.length; i++) {
Field field = fields[i];
setCellValue(t, field, row, i);
}
}
Field mapField = t.getClass().getDeclaredField("map");
mapField.setAccessible(true);
List<String> list1 = Arrays.asList(headers);
LinkedHashMap<String, BigDecimal> map = (LinkedHashMap<String, BigDecimal>) mapField.get(t);
for (Map.Entry<String, BigDecimal> entry : map.entrySet()) {
BigDecimal moduleScore = entry.getValue();
String key = entry.getKey();
for (String header : list1) {
if (key.equals(header)){
// 处理 moduleScore例如将其写入Excel 中对应的单元格
int i = list1.indexOf(header);
HSSFCell cell = row.createCell(i);
if (moduleScore != null) {
cell.setCellValue(moduleScore.doubleValue());
}
}
}
}
headers = list1.toArray(new String[0]); // 将List转回数组
}
/*application/vnd.ms-excel告诉浏览器要下载的是个excel*/
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
/*请求头设置Content-Disposition为下载标识attachment标识以附件方式下载*/
response.addHeader("Content-Disposition", "attachment;filename=" + new String((title).getBytes(), "ISO8859-1") + ".xls");
workbook.write(response.getOutputStream());
} finally {
if (workbook != null) {
workbook.close();
}
}
}
/**
*
*

@ -1,340 +1,366 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sztzjy.financial_bigdata.mapper.StuTheoryRecordMapper">
<resultMap id="BaseResultMap" type="com.sztzjy.financial_bigdata.entity.StuTheoryRecord">
<id column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="school_id" jdbcType="VARCHAR" property="schoolId" />
<result column="class_id" jdbcType="VARCHAR" property="classId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="student_id" jdbcType="VARCHAR" property="studentId" />
<result column="exam_count" jdbcType="INTEGER" property="examCount" />
<result column="highest_score" jdbcType="DECIMAL" property="highestScore" />
<result column="lowest_score" jdbcType="DECIMAL" property="lowestScore" />
<result column="total_duration" jdbcType="INTEGER" property="totalDuration" />
<result column="average_score" jdbcType="DECIMAL" property="averageScore" />
<result column="system_owner" jdbcType="VARCHAR" property="systemOwner" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
<resultMap id="BaseResultMap" type="com.sztzjy.financial_bigdata.entity.StuTheoryRecord">
<id column="user_id" jdbcType="VARCHAR" property="userId"/>
<result column="school_id" jdbcType="VARCHAR" property="schoolId"/>
<result column="class_id" jdbcType="VARCHAR" property="classId"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="student_id" jdbcType="VARCHAR" property="studentId"/>
<result column="exam_count" jdbcType="INTEGER" property="examCount"/>
<result column="highest_score" jdbcType="DECIMAL" property="highestScore"/>
<result column="lowest_score" jdbcType="DECIMAL" property="lowestScore"/>
<result column="total_duration" jdbcType="INTEGER" property="totalDuration"/>
<result column="average_score" jdbcType="DECIMAL" property="averageScore"/>
<result column="system_owner" jdbcType="VARCHAR" property="systemOwner"/>
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
user_id, school_id, class_id, name, student_id, exam_count, highest_score, lowest_score,
</where>
</sql>
<sql id="Base_Column_List">
user_id
, school_id, class_id, name, student_id, exam_count, highest_score, lowest_score,
total_duration, average_score, system_owner
</sql>
<select id="selectByExample" parameterType="com.sztzjy.financial_bigdata.entity.StuTheoryRecordExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from stu_theory_record
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from stu_theory_record
where user_id = #{userId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from stu_theory_record
where user_id = #{userId,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.sztzjy.financial_bigdata.entity.StuTheoryRecordExample">
delete from stu_theory_record
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.sztzjy.financial_bigdata.entity.StuTheoryRecord">
insert into stu_theory_record (user_id, school_id, class_id,
name, student_id, exam_count,
highest_score, lowest_score, total_duration,
average_score, system_owner)
values (#{userId,jdbcType=VARCHAR}, #{schoolId,jdbcType=VARCHAR}, #{classId,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{studentId,jdbcType=VARCHAR}, #{examCount,jdbcType=INTEGER},
#{highestScore,jdbcType=DECIMAL}, #{lowestScore,jdbcType=DECIMAL}, #{totalDuration,jdbcType=INTEGER},
#{averageScore,jdbcType=DECIMAL}, #{systemOwner,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.sztzjy.financial_bigdata.entity.StuTheoryRecord">
insert into stu_theory_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">
user_id,
</if>
<if test="schoolId != null">
school_id,
</if>
<if test="classId != null">
class_id,
</if>
<if test="name != null">
name,
</if>
<if test="studentId != null">
student_id,
</if>
<if test="examCount != null">
exam_count,
</if>
<if test="highestScore != null">
highest_score,
</if>
<if test="lowestScore != null">
lowest_score,
</if>
<if test="totalDuration != null">
total_duration,
</if>
<if test="averageScore != null">
average_score,
</if>
<if test="systemOwner != null">
system_owner,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">
#{userId,jdbcType=VARCHAR},
</if>
<if test="schoolId != null">
#{schoolId,jdbcType=VARCHAR},
</if>
<if test="classId != null">
#{classId,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="studentId != null">
#{studentId,jdbcType=VARCHAR},
</if>
<if test="examCount != null">
#{examCount,jdbcType=INTEGER},
</if>
<if test="highestScore != null">
#{highestScore,jdbcType=DECIMAL},
</if>
<if test="lowestScore != null">
#{lowestScore,jdbcType=DECIMAL},
</if>
<if test="totalDuration != null">
#{totalDuration,jdbcType=INTEGER},
</if>
<if test="averageScore != null">
#{averageScore,jdbcType=DECIMAL},
</if>
<if test="systemOwner != null">
#{systemOwner,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.sztzjy.financial_bigdata.entity.StuTheoryRecordExample" resultType="java.lang.Long">
select count(*) from stu_theory_record
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update stu_theory_record
<set>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=VARCHAR},
</if>
<if test="record.schoolId != null">
</sql>
<select id="selectByExample" parameterType="com.sztzjy.financial_bigdata.entity.StuTheoryRecordExample"
resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List"/>
from stu_theory_record
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from stu_theory_record
where user_id = #{userId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete
from stu_theory_record
where user_id = #{userId,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.sztzjy.financial_bigdata.entity.StuTheoryRecordExample">
delete from stu_theory_record
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
</delete>
<insert id="insert" parameterType="com.sztzjy.financial_bigdata.entity.StuTheoryRecord">
insert into stu_theory_record (user_id, school_id, class_id,
name, student_id, exam_count,
highest_score, lowest_score, total_duration,
average_score, system_owner)
values (#{userId,jdbcType=VARCHAR}, #{schoolId,jdbcType=VARCHAR}, #{classId,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{studentId,jdbcType=VARCHAR}, #{examCount,jdbcType=INTEGER},
#{highestScore,jdbcType=DECIMAL}, #{lowestScore,jdbcType=DECIMAL}, #{totalDuration,jdbcType=INTEGER},
#{averageScore,jdbcType=DECIMAL}, #{systemOwner,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.sztzjy.financial_bigdata.entity.StuTheoryRecord">
insert into stu_theory_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">
user_id,
</if>
<if test="schoolId != null">
school_id,
</if>
<if test="classId != null">
class_id,
</if>
<if test="name != null">
name,
</if>
<if test="studentId != null">
student_id,
</if>
<if test="examCount != null">
exam_count,
</if>
<if test="highestScore != null">
highest_score,
</if>
<if test="lowestScore != null">
lowest_score,
</if>
<if test="totalDuration != null">
total_duration,
</if>
<if test="averageScore != null">
average_score,
</if>
<if test="systemOwner != null">
system_owner,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">
#{userId,jdbcType=VARCHAR},
</if>
<if test="schoolId != null">
#{schoolId,jdbcType=VARCHAR},
</if>
<if test="classId != null">
#{classId,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="studentId != null">
#{studentId,jdbcType=VARCHAR},
</if>
<if test="examCount != null">
#{examCount,jdbcType=INTEGER},
</if>
<if test="highestScore != null">
#{highestScore,jdbcType=DECIMAL},
</if>
<if test="lowestScore != null">
#{lowestScore,jdbcType=DECIMAL},
</if>
<if test="totalDuration != null">
#{totalDuration,jdbcType=INTEGER},
</if>
<if test="averageScore != null">
#{averageScore,jdbcType=DECIMAL},
</if>
<if test="systemOwner != null">
#{systemOwner,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.sztzjy.financial_bigdata.entity.StuTheoryRecordExample"
resultType="java.lang.Long">
select count(*) from stu_theory_record
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update stu_theory_record
<set>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=VARCHAR},
</if>
<if test="record.schoolId != null">
school_id = #{record.schoolId,jdbcType=VARCHAR},
</if>
<if test="record.classId != null">
class_id = #{record.classId,jdbcType=VARCHAR},
</if>
<if test="record.name != null">
name = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.studentId != null">
student_id = #{record.studentId,jdbcType=VARCHAR},
</if>
<if test="record.examCount != null">
exam_count = #{record.examCount,jdbcType=INTEGER},
</if>
<if test="record.highestScore != null">
highest_score = #{record.highestScore,jdbcType=DECIMAL},
</if>
<if test="record.lowestScore != null">
lowest_score = #{record.lowestScore,jdbcType=DECIMAL},
</if>
<if test="record.totalDuration != null">
total_duration = #{record.totalDuration,jdbcType=INTEGER},
</if>
<if test="record.averageScore != null">
average_score = #{record.averageScore,jdbcType=DECIMAL},
</if>
<if test="record.systemOwner != null">
system_owner = #{record.systemOwner,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByExample" parameterType="map">
update stu_theory_record
set user_id = #{record.userId,jdbcType=VARCHAR},
school_id = #{record.schoolId,jdbcType=VARCHAR},
</if>
<if test="record.classId != null">
class_id = #{record.classId,jdbcType=VARCHAR},
</if>
<if test="record.name != null">
name = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.studentId != null">
student_id = #{record.studentId,jdbcType=VARCHAR},
</if>
<if test="record.examCount != null">
exam_count = #{record.examCount,jdbcType=INTEGER},
</if>
<if test="record.highestScore != null">
highest_score = #{record.highestScore,jdbcType=DECIMAL},
</if>
<if test="record.lowestScore != null">
lowest_score = #{record.lowestScore,jdbcType=DECIMAL},
</if>
<if test="record.totalDuration != null">
total_duration = #{record.totalDuration,jdbcType=INTEGER},
</if>
<if test="record.averageScore != null">
average_score = #{record.averageScore,jdbcType=DECIMAL},
</if>
<if test="record.systemOwner != null">
system_owner = #{record.systemOwner,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update stu_theory_record
set user_id = #{record.userId,jdbcType=VARCHAR},
school_id = #{record.schoolId,jdbcType=VARCHAR},
class_id = #{record.classId,jdbcType=VARCHAR},
name = #{record.name,jdbcType=VARCHAR},
student_id = #{record.studentId,jdbcType=VARCHAR},
exam_count = #{record.examCount,jdbcType=INTEGER},
highest_score = #{record.highestScore,jdbcType=DECIMAL},
lowest_score = #{record.lowestScore,jdbcType=DECIMAL},
total_duration = #{record.totalDuration,jdbcType=INTEGER},
average_score = #{record.averageScore,jdbcType=DECIMAL},
system_owner = #{record.systemOwner,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.sztzjy.financial_bigdata.entity.StuTheoryRecord">
update stu_theory_record
<set>
<if test="schoolId != null">
school_id = #{schoolId,jdbcType=VARCHAR},
</if>
<if test="classId != null">
class_id = #{classId,jdbcType=VARCHAR},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="studentId != null">
student_id = #{studentId,jdbcType=VARCHAR},
</if>
<if test="examCount != null">
exam_count = #{examCount,jdbcType=INTEGER},
</if>
<if test="highestScore != null">
highest_score = #{highestScore,jdbcType=DECIMAL},
</if>
<if test="lowestScore != null">
lowest_score = #{lowestScore,jdbcType=DECIMAL},
</if>
<if test="totalDuration != null">
total_duration = #{totalDuration,jdbcType=INTEGER},
</if>
<if test="averageScore != null">
average_score = #{averageScore,jdbcType=DECIMAL},
</if>
<if test="systemOwner != null">
system_owner = #{systemOwner,jdbcType=VARCHAR},
</if>
</set>
where user_id = #{userId,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.sztzjy.financial_bigdata.entity.StuTheoryRecord">
update stu_theory_record
set school_id = #{schoolId,jdbcType=VARCHAR},
class_id = #{classId,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
student_id = #{studentId,jdbcType=VARCHAR},
exam_count = #{examCount,jdbcType=INTEGER},
highest_score = #{highestScore,jdbcType=DECIMAL},
lowest_score = #{lowestScore,jdbcType=DECIMAL},
total_duration = #{totalDuration,jdbcType=INTEGER},
average_score = #{averageScore,jdbcType=DECIMAL},
system_owner = #{systemOwner,jdbcType=VARCHAR}
where user_id = #{userId,jdbcType=VARCHAR}
</update>
system_owner = #{record.systemOwner,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.sztzjy.financial_bigdata.entity.StuTheoryRecord">
update stu_theory_record
<set>
<if test="schoolId != null">
school_id = #{schoolId,jdbcType=VARCHAR},
</if>
<if test="classId != null">
class_id = #{classId,jdbcType=VARCHAR},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="studentId != null">
student_id = #{studentId,jdbcType=VARCHAR},
</if>
<if test="examCount != null">
exam_count = #{examCount,jdbcType=INTEGER},
</if>
<if test="highestScore != null">
highest_score = #{highestScore,jdbcType=DECIMAL},
</if>
<if test="lowestScore != null">
lowest_score = #{lowestScore,jdbcType=DECIMAL},
</if>
<if test="totalDuration != null">
total_duration = #{totalDuration,jdbcType=INTEGER},
</if>
<if test="averageScore != null">
average_score = #{averageScore,jdbcType=DECIMAL},
</if>
<if test="systemOwner != null">
system_owner = #{systemOwner,jdbcType=VARCHAR},
</if>
</set>
where user_id = #{userId,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.sztzjy.financial_bigdata.entity.StuTheoryRecord">
update stu_theory_record
set school_id = #{schoolId,jdbcType=VARCHAR},
class_id = #{classId,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
student_id = #{studentId,jdbcType=VARCHAR},
exam_count = #{examCount,jdbcType=INTEGER},
highest_score = #{highestScore,jdbcType=DECIMAL},
lowest_score = #{lowestScore,jdbcType=DECIMAL},
total_duration = #{totalDuration,jdbcType=INTEGER},
average_score = #{averageScore,jdbcType=DECIMAL},
system_owner = #{systemOwner,jdbcType=VARCHAR}
where user_id = #{userId,jdbcType=VARCHAR}
</update>
<resultMap id="DtoMap" type="com.sztzjy.financial_bigdata.entity.stu_dto.StuTheoryIndexInfoDto">
<result column="score" jdbcType="DECIMAL" property="lastTaskScore" />
<result column="total_duration" jdbcType="INTEGER" property="theoryTotalDuration" />
<result column="exam_count" jdbcType="INTEGER" property="theoryNum" />
<result column="rank" jdbcType="INTEGER" property="theoryLastRank" />
</resultMap>
<resultMap id="DtoMap" type="com.sztzjy.financial_bigdata.entity.stu_dto.StuTheoryIndexInfoDto">
<result column="score" jdbcType="DECIMAL" property="lastTaskScore"/>
<result column="total_duration" jdbcType="INTEGER" property="theoryTotalDuration"/>
<result column="exam_count" jdbcType="INTEGER" property="theoryNum"/>
<result column="rank" jdbcType="INTEGER" property="theoryLastRank"/>
</resultMap>
<select id="selectTheoryInfo" parameterType="com.sztzjy.financial_bigdata.entity.stu_dto.StuTheoryIndexInfoDto" resultMap="DtoMap">
SELECT ste.score, str.total_duration,str.exam_count, (
SELECT COUNT(*) AS `rank`
FROM stu_theory_exam
WHERE accuracy &gt;= (
SELECT accuracy
FROM stu_theory_exam
WHERE user_id = 4
ORDER BY exam_time DESC
LIMIT 1
)
<select id="selectTheoryInfo" parameterType="com.sztzjy.financial_bigdata.entity.stu_dto.StuTheoryIndexInfoDto"
resultMap="DtoMap">
SELECT ste.score,
str.total_duration,
str.exam_count,
(
SELECT COUNT(*) AS `rank`
FROM stu_theory_exam
WHERE accuracy &gt;= (
SELECT accuracy
FROM stu_theory_exam
WHERE user_id = 4
ORDER BY exam_time DESC
LIMIT 1 )
) AS `rank`
FROM stu_theory_exam ste
JOIN stu_theory_record str ON ste.user_id = str.user_id
WHERE ste.user_id = 4
AND ste.answered = 1
AND ste.accuracy &gt;= (
SELECT accuracy
FROM stu_theory_exam
WHERE user_id = 4
ORDER BY exam_time DESC
LIMIT 1
)
ORDER BY ste.exam_time DESC
LIMIT 1;
</select>
FROM stu_theory_exam ste
JOIN stu_theory_record str
ON ste.user_id = str.user_id
WHERE ste.user_id = 4
AND ste.answered = 1
AND ste.accuracy &gt;= (
SELECT accuracy
FROM stu_theory_exam
WHERE user_id = 4
ORDER BY exam_time DESC
LIMIT 1
)
ORDER BY ste.exam_time DESC
LIMIT 1;
</select>
<select id="selectConditions" resultMap="BaseResultMap">
select *
from stu_theory_record
<where>
system_owner = #{systemOwner}
AND school_id = #{schoolId}
<if test="classId != null and classId != ''">
AND class_id = #{classId}
</if>
<if test="keyWord != null and keyWord != ''">
AND (student_id like CONCAT ('%',#{keyWord},'%') or name like CONCAT ('%',#{keyWord},'%'))
</if>
</where>
</select>
</mapper>

@ -456,7 +456,7 @@
AND u.role_id = 4
AND u.school_id = #{schoolId}
<if test="keyWord != null and keyWord!=''">
AND student_id like CONCAT ('%',#{keyWord},'%') or name like CONCAT ('%',#{keyWord},'%')
AND (student_id like CONCAT ('%',#{keyWord},'%') or name like CONCAT ('%',#{keyWord},'%'))
</if>
<if test="classId != null and classId !=''">
AND u.class_id = #{classId}
@ -491,7 +491,7 @@
AND school_id = #{schoolId}
</if>
<if test="keyWord != null and keyWord != ''">
AND student_id like CONCAT ('%',#{keyWord},'%') or name like CONCAT ('%',#{keyWord},'%')
AND (student_id like CONCAT ('%',#{keyWord},'%') or name like CONCAT ('%',#{keyWord},'%'))
</if>
</where>
</select>

Loading…
Cancel
Save