@ -17,7 +17,6 @@ import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse ;
import java.math.BigDecimal ;
import java.math.RoundingMode ;
import java.util.* ;
/ * *
@ -44,11 +43,14 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
private StuStudentExamMapper studentExamMapper ;
@Autowired
private StuTheoryRecordMapper stuTheoryRecordMapper ;
@Autowired
private StuTrainingMapper stuTrainingMapper ;
@Override
public PageInfo < TeaTrainingInfoDTO > getTrainingInfo ( Integer index , Integer size , String schoolId , String keyWord , String classId ) {
List < TeaTrainingInfoDTO > list = getTeaTrainingInfoDTOS ( schoolId , keyWord , classId );
public PageInfo < TeaTrainingInfoDTO > getTrainingInfo ( Integer index , Integer size , String schoolId , String keyWord , String classId ,String userId ) {
List < TeaTrainingInfoDTO > list = getTeaTrainingInfoDTOS ( schoolId , keyWord , classId ,userId );
list . sort ( new TotalScoreComparator ( ) ) ;
int i = 0 ;
for ( TeaTrainingInfoDTO teaTrainingInfoDTO : list ) {
@ -66,8 +68,8 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
* @Date 2024 / 3 / 19
* /
@Override
public void exportTrainingInfo ( HttpServletResponse response , String schoolId , String keyWord , String classId ) {
List < TeaTrainingInfoDTO > list = getTeaTrainingInfoDTOS ( schoolId , keyWord , classId );
public void exportTrainingInfo ( HttpServletResponse response , String schoolId , String keyWord , String classId ,String userId ) {
List < TeaTrainingInfoDTO > list = getTeaTrainingInfoDTOS ( schoolId , keyWord , classId ,userId );
//导出的表名
String title = IdUtil . simpleUUID ( ) ;
//表中第一行表头字段
@ -174,9 +176,11 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
TeaTrainingDto newData = new TeaTrainingDto ( ) ;
BeanUtils . copyProperties ( stuTrainingWithBLOBs , newData ) ;
newData . setTaskModule ( sysCourseChapter . getChapterName ( ) ) ;
String reportId = stuTrainingWithBLOB . getReportId ( ) ;
TrainingReport trainingReport = trainingReportMapper . selectByPrimaryKey ( reportId ) ;
newData . setReportScore ( trainingReport . getTeacherScore ( ) ) ;
if ( StringUtils . isNotBlank ( stuTrainingWithBLOB . getReportId ( ) ) ) {
String reportId = stuTrainingWithBLOB . getReportId ( ) ;
TrainingReport trainingReport = trainingReportMapper . selectByPrimaryKey ( reportId ) ;
newData . setReportScore ( trainingReport . getTeacherScore ( ) ) ;
}
newData . setModuleScore ( moduleScore ) ;
list . add ( newData ) ;
}
@ -258,7 +262,7 @@ 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 ) ;
int i = 0 ;
for ( StuTheoryRecordDto stuTheoryRecordDto : dtoList ) {
stuTheoryRecordDto . setRank ( i + + ) ;
@ -278,7 +282,7 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
}
private List < TeaTrainingInfoDTO > getTeaTrainingInfoDTOS ( String schoolId , String keyWord , String classId ) {
private List < TeaTrainingInfoDTO > getTeaTrainingInfoDTOS ( String schoolId , String keyWord , String classId ,String userId ) {
StuUserExample userExample = new StuUserExample ( ) ;
StuUserExample . Criteria criteria = userExample . createCriteria ( ) ;
criteria . andSchoolIdEqualTo ( schoolId ) ;
@ -289,59 +293,75 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
userExample . or ( ) . andSchoolIdEqualTo ( schoolId ) . andStudentIdEqualTo ( keyWord ) ;
userExample . or ( ) . andSchoolIdEqualTo ( schoolId ) . andNameEqualTo ( keyWord ) ;
}
SysWeight sysWeight = sysWeightMapper . selectByPrimaryKey ( schoolId ) ;
BigDecimal expTrainingWeight = sysWeight . getExpTrainingWeight ( ) ; //实验实训权重
BigDecimal knowledgeSummaryWeight = sysWeight . getKnowledgeSummaryWeight ( ) ; //知识概要权重
BigDecimal resourceLearningWeight = sysWeight . getResourceLearningWeight ( ) ; //资源学习权重
BigDecimal learningEvalWeight = sysWeight . getLearningEvalWeight ( ) ; //学习测评权重
BigDecimal reportWeight = sysWeight . getReportWeight ( ) ; //实验报告权重
List < TeaTrainingInfoDTO > list = new ArrayList < > ( ) ;
int chapterNum = sysCourseChapterMapper . selectChapterBySchoolId ( schoolId ) ;
List < StuUser > stuUsers = userMapper . selectByExample ( userExample ) ;
for ( StuUser stuUser : stuUsers ) {
TeaTrainingInfoDTO teaTrainingInfoDTO = new TeaTrainingInfoDTO ( ) ;
StuClass stuClass = classMapper . selectByPrimaryKey ( classId ) ;
teaTrainingInfoDTO . setClassName ( stuClass . getClassName ( ) ) ;
teaTrainingInfoDTO . setStudentId ( stuUser . getStudentId ( ) ) ;
teaTrainingInfoDTO . setName ( stuUser . getName ( ) ) ;
StuTrainingExample stuTrainingExample = new StuTrainingExample ( ) ;
stuTrainingExample . createCriteria ( ) . andUserIdEqualTo ( stuUser . getUserid ( ) ) ;
List < StuTrainingWithBLOBs > stuTrainingWithBLOBs = trainingMapper . selectByExampleWithBLOBs ( stuTrainingExample ) ;
for ( StuTrainingWithBLOBs stuTrainingWithBLOB : stuTrainingWithBLOBs ) {
if ( StringUtils . isNotBlank ( stuTrainingWithBLOB . getReportId ( ) ) ) { //之展示提交完报告的数据
List < TeaTrainingInfoDTO > list = new ArrayList < > ( ) ;
if ( stuUsers . isEmpty ( ) ) {
return null ;
} else {
for ( StuUser stuUser : stuUsers ) {
TeaTrainingInfoDTO teaTrainingInfoDTO = new TeaTrainingInfoDTO ( ) ;
StuClass stuClass = classMapper . selectByPrimaryKey ( stuUser . getClassId ( ) ) ;
//封装user表的数据
teaTrainingInfoDTO . setClassName ( stuClass . getClassName ( ) ) ;
teaTrainingInfoDTO . setStudentId ( stuUser . getStudentId ( ) ) ;
teaTrainingInfoDTO . setName ( stuUser . getName ( ) ) ;
teaTrainingInfoDTO . setUserId ( stuUser . getUserid ( ) ) ;
//求实训进度
StuTrainingExample stuTrainingExample = new StuTrainingExample ( ) ;
stuTrainingExample . createCriteria ( ) . andProgressEqualTo ( BigDecimal . valueOf ( 6 ) ) . andUserIdEqualTo ( stuUser . getUserid ( ) ) ; //进度为6代表这个章节完成了
List < StuTrainingWithBLOBs > stuTrainings = trainingMapper . selectByExampleWithBLOBs ( stuTrainingExample ) ;
int trainingSize = stuTrainingMapper . selectProgressFinish ( userId ) ; //已学任务数量
if ( stuTrainings . isEmpty ( ) ) {
teaTrainingInfoDTO . setProgress ( BigDecimal . ZERO ) ; //实训表为0设置为0
teaTrainingInfoDTO . setTotalScore ( BigDecimal . ZERO ) ;
list . add ( teaTrainingInfoDTO ) ;
}
if ( trainingSize ! = 0 & & chapterNum ! = 0 ) {
int i = chapterNum / trainingSize ; //综合进度
teaTrainingInfoDTO . setProgress ( BigDecimal . valueOf ( i ) ) ;
}
//求综合得分 拿到每个已完成的章节分数
BigDecimal totalScore = BigDecimal . valueOf ( 0 ) ;
if ( stuTrainings . isEmpty ( ) ) {
list . add ( teaTrainingInfoDTO ) ;
continue ;
}
for ( StuTrainingWithBLOBs stuTrainingWithBLOB : stuTrainings ) {
TrainingReport trainingReport = trainingReportMapper . selectByPrimaryKey ( stuTrainingWithBLOB . getReportId ( ) ) ;
BigDecimal reportScore = trainingReport . getTeacherScore ( ) ;
BigDecimal expTrainingScore = stuTrainingWithBLOB . getExpTrainingScore ( ) ;
BigDecimal knowledgeSummaryScore = stuTrainingWithBLOB . getKnowledgeSummaryScore ( ) ;
BigDecimal resourceLearningScore = stuTrainingWithBLOB . getResourceLearningScore ( ) ;
BigDecimal learningEvalScore = stuTrainingWithBLOB . getLearningEvalScore ( ) ;
teaTrainingInfoDTO . setProgress ( stuTrainingWithBLOB . getProgress ( ) ) ;
BigDecimal totalScore = BigDecimal . valueOf ( 0 ) ;
if ( reportScore ! = null & & BigDecimal . ZERO . compareTo ( reportScore ) = = 0 ) {
totalScore = totalScore . add ( reportScore . multiply ( reportWeight ) . setScale ( 2 , RoundingMode . HALF_UP ) ) ;
}
if ( expTrainingScore ! = null & & BigDecimal . ZERO . compareTo ( expTrainingScore ) = = 0 ) {
totalScore = totalScore . add ( expTrainingScore . multiply ( expTrainingWeight ) . setScale ( 2 , RoundingMode . HALF_UP ) ) ;
}
if ( knowledgeSummaryScore ! = null & & BigDecimal . ZERO . compareTo ( knowledgeSummaryScore ) = = 0 ) {
totalScore = totalScore . add ( knowledgeSummaryScore . multiply ( knowledgeSummaryWeight ) . setScale ( 2 , RoundingMode . HALF_UP ) ) ;
}
if ( resourceLearningScore ! = null & & BigDecimal . ZERO . compareTo ( resourceLearningScore ) = = 0 ) {
totalScore = totalScore . add ( resourceLearningScore . multiply ( resourceLearningWeight ) . setScale ( 2 , RoundingMode . HALF_UP ) ) ;
}
if ( learningEvalScore ! = null & & BigDecimal . ZERO . compareTo ( learningEvalScore ) = = 0 ) {
totalScore = totalScore . add ( learningEvalScore . multiply ( learningEvalWeight ) . setScale ( 2 , RoundingMode . HALF_UP ) ) ;
if ( reportScore ! = null & & BigDecimal . ZERO . compareTo ( reportScore ) = = 0 ) { //报告得分不等于0或null
totalScore = totalScore . add ( reportScore ) ;
if ( expTrainingScore ! = null & & BigDecimal . ZERO . compareTo ( expTrainingScore ) = = 0 ) {
totalScore = totalScore . add ( expTrainingScore ) ;
}
if ( knowledgeSummaryScore ! = null & & BigDecimal . ZERO . compareTo ( knowledgeSummaryScore ) = = 0 ) {
totalScore = totalScore . add ( knowledgeSummaryScore ) ;
}
if ( resourceLearningScore ! = null & & BigDecimal . ZERO . compareTo ( resourceLearningScore ) = = 0 ) {
totalScore = totalScore . add ( resourceLearningScore ) ;
}
if ( learningEvalScore ! = null & & BigDecimal . ZERO . compareTo ( learningEvalScore ) = = 0 ) {
totalScore = totalScore . add ( learningEvalScore ) ;
}
}
teaTrainingInfoDTO . setTotalScore ( totalScore ) ;
teaTrainingInfoDTO . setTrainingId ( stuTrainingWithBLOB . getTrainingId ( ) ) ;
list . add ( teaTrainingInfoDTO ) ;
}
int score = totalScore . intValue ( ) / chapterNum ; //已完成的模块分数/总模块数量
teaTrainingInfoDTO . setTotalScore ( BigDecimal . valueOf ( score ) ) ;
list . add ( teaTrainingInfoDTO ) ;
}
return list ;
}
return list ;
}
public class TotalScoreComparator implements Comparator < TeaTrainingInfoDTO > {
@Override
public int compare ( TeaTrainingInfoDTO o1 , TeaTrainingInfoDTO o2 ) {