@ -1,8 +1,8 @@
package com.ibeetl.jlw.service ;
import cn.hutool.core.collection.CollectionUtil ;
import cn.hutool.core.date.DateUtil ;
import cn.hutool.core.util.NumberUtil ;
import cn.hutool.core.util.ObjectUtil ;
import cn.hutool.core.util.StrUtil ;
import cn.jlw.util.ToolUtils ;
import com.alibaba.fastjson.JSON ;
@ -14,6 +14,7 @@ import com.ibeetl.admin.core.util.PlatformException;
import com.ibeetl.admin.core.util.TimeTool ;
import com.ibeetl.admin.core.web.JsonResult ;
import com.ibeetl.admin.core.web.JsonReturnCode ;
import com.ibeetl.jlw.constants.TeacherOpenCourseScoreDashboardConstant ;
import com.ibeetl.jlw.dao.* ;
import com.ibeetl.jlw.entity.* ;
import com.ibeetl.jlw.enums.ChatLogSendTypeEnum ;
@ -23,6 +24,7 @@ import com.ibeetl.jlw.web.query.TeacherOpenCourseMergeStudentQuery;
import com.ibeetl.jlw.web.query.TeacherOpenCourseScoreDashboardQuery ;
import com.ibeetl.jlw.web.query.TeacherOpenCourseStudentSigninLogQuery ;
import lombok.extern.slf4j.Slf4j ;
import org.apache.commons.collections4.CollectionUtils ;
import org.apache.commons.lang3.StringUtils ;
import org.apache.poi.hssf.usermodel.HSSFWorkbook ;
import org.apache.poi.ss.usermodel.Cell ;
@ -33,6 +35,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.beetl.sql.core.SqlId ;
import org.beetl.sql.core.engine.PageQuery ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.context.annotation.Lazy ;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
@ -40,6 +43,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull ;
import java.io.* ;
import java.math.BigDecimal ;
import java.math.RoundingMode ;
import java.text.DateFormat ;
import java.text.DecimalFormat ;
import java.text.SimpleDateFormat ;
@ -72,28 +76,42 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService<Teac
private TeacherOpenCourseStudentSigninLogDao studentSigninLogDao ;
@Autowired
private TeacherOpenCourseScheduleSessionDao teacherOpenCourseScheduleSessionDao ;
@Autowired
private QuestionLogSummaryDao questionLogSummaryService ;
private QuestionLogSummaryDao questionLogSummaryDao ;
@Autowired
private TeacherOpenCourseQuestionSettingDao teacherOpenCourseQuestionSettingDao ;
@Autowired
private StudentHandsOnTaskVideoDao video Service ;
private StudentHandsOnTaskVideoDao video Dao ;
@Autowired
private StudentHandsOnTaskPptDao ppt Service ;
private StudentHandsOnTaskPptDao ppt Dao ;
@Autowired
private StudentHandsOnTaskStepDao step Service ;
private StudentHandsOnTaskStepDao step Dao ;
@Autowired
private StudentHandsOnTaskTheoryDao theory Service ;
private StudentHandsOnTaskTheoryDao theory Dao ;
@Autowired
private StudentHandsOnTaskReportDao report Service ;
private StudentHandsOnTaskReportDao report Dao ;
@Autowired
private TeacherOpenCourseChatLogDao courseChatLogDao ;
@Autowired
private StudentService studentService ;
@Autowired
private TeacherOpenCourseStudentSigninSettingService teacherOpenCourseStudentSigninSettingService ;
@Autowired
@Lazy
private TeacherOpenCourseHandsOnSimulationTasksService teacherOpenCourseHandsOnSimulationTasksService ;
@Autowired
@Lazy
private TeacherOpenCourseHandsOnService teacherOpenCourseHandsOnService ;
@Autowired
private HandsOnAchievementService handsOnAchievementService ;
@Autowired
private TeacherOpenCourseChatLogService teacherOpenCourseChatLogService ;
public PageQuery < TeacherOpenCourseScoreDashboard > queryByCondition ( PageQuery query ) {
PageQuery ret = teacherOpenCourseScoreDashboardDao . queryByCondition ( query ) ;
@ -437,250 +455,499 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService<Teac
* @return
* /
public boolean updateGrades ( Long teacherOpenCourseId ) {
if ( teacherOpenCourseId = = null ) {
return false ;
}
Date now = new Date ( ) ;
//获取该课程的所有讨论数据
TeacherOpenCourseChatLog teacherOpenCourseChatLog = new TeacherOpenCourseChatLog ( ) ;
teacherOpenCourseChatLog . setTeacherOpenCourseId ( teacherOpenCourseId ) ;
teacherOpenCourseChatLog . setTeacherOpenCourseChatLogStatus ( 1 ) ;
List < TeacherOpenCourseChatLog > teacherOpenCourseChatLogList = teacherOpenCourseChatLogService . queryObjectList ( teacherOpenCourseChatLog ) ;
//查询章节练习配置
List < TeacherOpenCourseQuestionSetting > chapterExerciseList = teacherOpenCourseQuestionSettingDao . createLambdaQuery ( )
. andEq ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseId , teacherOpenCourseId )
. andEq ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseQuestionSettingType , ResourcesQuestionSnapshotFromTypeEnum . CHAPTER_EXERCISE )
. andEq ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseQuestionSettingStatus , 1 ) . select ( ) ;
//查询本课程的所有实操任务
TeacherOpenCourseHandsOn param = new TeacherOpenCourseHandsOn ( ) ;
param . setTeacherOpenCourseId ( teacherOpenCourseId ) ;
List < TeacherOpenCourseHandsOn > handsOnList = teacherOpenCourseHandsOnService . queryObjectList ( param ) ;
//查询本课程的所有实操任务子项
List < TeacherOpenCourseHandsOnSimulationTasks > teacherOpenCourseHandsOnSimulationTasksList = null ;
List < Long > handOnIdList = null ;
if ( CollectionUtil . isNotEmpty ( handsOnList ) ) {
handOnIdList = handsOnList . stream ( ) . map ( TeacherOpenCourseHandsOn : : getHandsOnId ) . collect ( Collectors . toList ( ) ) ;
TeacherOpenCourseHandsOnSimulationTasks query = new TeacherOpenCourseHandsOnSimulationTasks ( ) ;
query . setTeacherOpenCourseId ( teacherOpenCourseId ) ;
teacherOpenCourseHandsOnSimulationTasksList = teacherOpenCourseHandsOnSimulationTasksService . queryObjectList ( query ) ;
}
if ( CollectionUtil . isEmpty ( teacherOpenCourseHandsOnSimulationTasksList ) ) {
teacherOpenCourseHandsOnSimulationTasksList = new ArrayList < > ( ) ;
}
if ( CollectionUtil . isEmpty ( handOnIdList ) ) {
handOnIdList = new ArrayList < > ( ) ;
}
//查该课程的所有作业
List < TeacherOpenCourseQuestionSetting > homeworkList = teacherOpenCourseQuestionSettingDao . createLambdaQuery ( )
. andEq ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseId , teacherOpenCourseId )
. andEq ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseQuestionSettingStatus , 1 )
. andIn ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseQuestionSettingType , Arrays . asList ( ResourcesQuestionSnapshotFromTypeEnum . HOMEWORK_QUESTION , ResourcesQuestionSnapshotFromTypeEnum . HOMEWORK_FILE ) )
. select ( ) ;
//查该课程的所有考试
List < TeacherOpenCourseQuestionSetting > examList = teacherOpenCourseQuestionSettingDao . createLambdaQuery ( )
. andEq ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseId , teacherOpenCourseId )
. andEq ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseQuestionSettingStatus , 1 )
. andEq ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseQuestionSettingType , ResourcesQuestionSnapshotFromTypeEnum . EXAM ) . select ( ) ;
//查询权重
TeacherOpenCourseScoreWeight weight = weightDao . single ( teacherOpenCourseId ) ;
TeacherOpenCourseMergeStudentQuery studentQuery = new TeacherOpenCourseMergeStudentQuery ( ) ;
studentQuery . setTeacherOpenCourseId ( teacherOpenCourseId ) ;
studentQuery . setTeacherOpenCourseSchoolClassMergeStudentStatus ( 1 ) ;
//查开课里面的学生
List < TeacherOpenCourseMergeStudent > students = mergeStudentDao . getValuesByQueryNotWithPermission ( studentQuery ) ;
//todo 章节练习成绩,课程实操成绩,作业成绩,考试成绩,互动成绩
List < TeacherOpenCourseScoreDashboard > studentScores = new ArrayList < > ( ) ;
//班次数
Double classNum = null ;
for ( TeacherOpenCourseMergeStudent student : students ) {
Long studentId = student . getStudentId ( ) ;
for ( TeacherOpenCourseMergeStudent teacherOpenCourseMergeStudent : students ) {
Long studentId = teacherOpenCourseMergeStudent . getStudentId ( ) ;
//通过id查询学生
Student student = studentService . queryById ( studentId ) ;
TeacherOpenCourseScoreDashboard teacherOpenCourseScoreDashboard = teacherOpenCourseScoreDashboardDao . createLambdaQuery ( )
. andEq ( TeacherOpenCourseScoreDashboard : : getTeacherOpenCourseId , teacherOpenCourseId )
. andEq ( TeacherOpenCourseScoreDashboard : : getStudentId , studentId )
. singleSimple ( ) ;
if ( teacherOpenCourseScoreDashboard = = null ) {
teacherOpenCourseScoreDashboard = new TeacherOpenCourseScoreDashboard ( ) ;
teacherOpenCourseScoreDashboard . setTeacherOpenCourseId ( teacherOpenCourseId ) ;
teacherOpenCourseScoreDashboard . setStudentId ( studentId ) ;
teacherOpenCourseScoreDashboard . setOrgId ( student . getOrgId ( ) ) ;
teacherOpenCourseScoreDashboard . setStudentSn ( student . getStudentSn ( ) ) ;
teacherOpenCourseScoreDashboard . setStudentName ( student . getStudentName ( ) ) ;
teacherOpenCourseScoreDashboard . setExamScore ( BigDecimal . ZERO ) ;
teacherOpenCourseScoreDashboard . setCourseScore ( BigDecimal . ZERO ) ;
teacherOpenCourseScoreDashboard . setChatScore ( BigDecimal . ZERO ) ;
teacherOpenCourseScoreDashboard . setSigninScore ( BigDecimal . ZERO ) ;
teacherOpenCourseScoreDashboard . setRealOperationScore ( BigDecimal . ZERO ) ;
teacherOpenCourseScoreDashboard . setQuestionHomeworkScore ( BigDecimal . ZERO ) ;
teacherOpenCourseScoreDashboard . setTotalScore ( BigDecimal . ZERO ) ;
teacherOpenCourseScoreDashboard . setManualScore ( BigDecimal . ZERO ) ;
teacherOpenCourseScoreDashboard . setUserId ( student . getUserId ( ) ) ;
teacherOpenCourseScoreDashboard . setCreateTime ( now ) ;
teacherOpenCourseScoreDashboardDao . insert ( teacherOpenCourseScoreDashboard ) ;
}
if ( teacherOpenCourseScoreDashboard . getTeacherOpenCourseScoreDashboardId ( ) = = null ) {
log . error ( "teacherOpenCourseScoreDashboard.getTeacherOpenCourseScoreDashboardId()为空, studentId:{},openCourseId:{}" , studentId , teacherOpenCourseId ) ;
continue ;
}
if ( student = = null ) {
log . error ( "学生不存在, studentId={}" , studentId ) ;
continue ;
}
TeacherOpenCourseScoreDashboard scoreDashboard = new TeacherOpenCourseScoreDashboard ( ) ;
scoreDashboard . setStudentId ( studentId ) ;
TeacherOpenCourseStudentSigninLogQuery logQuery = new TeacherOpenCourseStudentSigninLogQuery ( ) ;
logQuery . setTeacherOpenCourseId ( teacherOpenCourseId ) ;
logQuery . setStudentId ( studentId ) ;
logQuery . setTeacherOpenCourseStudentSigninLogTag ( SignInTypeEnum . SIGN_IN ) ;
List < TeacherOpenCourseStudentSigninLog > logs = studentSigninLogDao . getValuesByQueryNotWithPermission ( logQuery ) ;
if ( CollectionUtil . isNotEmpty ( logs ) ) {
//周次*开课星期的长度
if ( weight ! = null & & "2" . equals ( weight . getSignInResultSetting ( ) ) ) {
//查询班次
if ( classNum = = null ) {
TeacherOpenCourseScheduleSession teacherOpenCourseScheduleSession = teacherOpenCourseScheduleSessionDao . createLambdaQuery ( )
. andEq ( TeacherOpenCourseScheduleSession : : getTeacherOpenCourseId , teacherOpenCourseId ) . singleSimple ( ) ;
if ( teacherOpenCourseScheduleSession ! = null ) {
String teacherOpenCourseScheduleSessionStartDate = teacherOpenCourseScheduleSession . getTeacherOpenCourseScheduleSessionStartDate ( ) ;
String teacherOpenCourseScheduleSessionEndDate = teacherOpenCourseScheduleSession . getTeacherOpenCourseScheduleSessionEndDate ( ) ;
long l = DateUtil . betweenWeek ( DateUtil . parseDate ( teacherOpenCourseScheduleSessionStartDate ) ,
DateUtil . parseDate ( teacherOpenCourseScheduleSessionEndDate ) , true ) ;
classNum = NumberUtil . mul ( l , teacherOpenCourseScheduleSession . getTeacherOpenCourseScheduleSessionWeekNum ( ) . longValue ( ) ) ;
scoreDashboard . setTeacherOpenCourseScoreDashboardId ( teacherOpenCourseScoreDashboard . getTeacherOpenCourseScoreDashboardId ( ) ) ;
//签到成绩
{
//所有签到记录
TeacherOpenCourseStudentSigninLogQuery logQuery = new TeacherOpenCourseStudentSigninLogQuery ( ) ;
logQuery . setTeacherOpenCourseId ( teacherOpenCourseId ) ;
logQuery . setStudentId ( studentId ) ;
logQuery . setTeacherOpenCourseStudentSigninLogTag ( SignInTypeEnum . SIGN_IN ) ;
List < TeacherOpenCourseStudentSigninLog > logs = studentSigninLogDao . getValuesByQueryNotWithPermission ( logQuery ) ;
scoreDashboard . setSigninScore ( BigDecimal . ZERO ) ;
if ( CollectionUtil . isNotEmpty ( logs ) ) {
long studentAllSignCount = logs . stream ( ) . map ( TeacherOpenCourseStudentSigninLog : : getTeacherOpenCourseStudentSigninSettingId ) . distinct ( ) . count ( ) ;
//签到到课率
if ( weight ! = null & & "2" . equals ( weight . getSignInResultSetting ( ) ) ) {
//有关该班级的所有签到设置
List < TeacherOpenCourseStudentSigninSetting > teacherOpenCourseStudentSigninSettingList = teacherOpenCourseStudentSigninSettingService . getByClassId ( student . getClassId ( ) ) ;
if ( CollectionUtils . isNotEmpty ( teacherOpenCourseStudentSigninSettingList ) ) {
int baseSize = teacherOpenCourseStudentSigninSettingList . size ( ) ;
//0.xxx * 100 = xx.x 结果保留一位小数
BigDecimal signScore = BigDecimal . valueOf ( studentAllSignCount ) . divide ( BigDecimal . valueOf ( baseSize ) , 3 , RoundingMode . HALF_UP ) . multiply ( BigDecimal . valueOf ( 100 ) ) ;
scoreDashboard . setSigninScore ( signScore ) ;
} else {
classNum = 0D ;
//有签到记录,但是没有签到设置,不应该出现这种情况
log . error ( "有签到记录,但是没有签到设置,不应该出现这种情况,studentId={}" , studentId ) ;
scoreDashboard . setSigninScore ( BigDecimal . ZERO ) ;
}
}
//按签到次数乘以签到分数
else if ( weight ! = null & & "1" . equals ( weight . getSignInResultSetting ( ) ) ) {
if ( StringUtils . isNotBlank ( weight . getSignInScore ( ) ) ) {
BigDecimal signScore = BigDecimal . valueOf ( studentAllSignCount ) . multiply ( new BigDecimal ( weight . getSignInScore ( ) ) ) . setScale ( 1 , RoundingMode . HALF_UP ) ;
scoreDashboard . setSigninScore ( signScore ) ;
}
}
double div = NumberUtil . div ( logs . size ( ) , classNum . intValue ( ) ) ;
double score = NumberUtil . mul ( div , 100 ) ;
scoreDashboard . setSigninScore ( BigDecimal . valueOf ( score ) ) ;
} else if ( weight ! = null & & "1" . equals ( weight . getSignInResultSetting ( ) ) ) {
scoreDashboard . setSigninScore ( BigDecimal . valueOf ( NumberUtil . mul ( logs . size ( ) , Integer . parseInt ( weight . getSignInScore ( ) ) ) ) ) ;
} else {
scoreDashboard . setSigninScore ( BigDecimal . valueOf ( logs . size ( ) ) ) ;
}
} else {
scoreDashboard . setSigninScore ( BigDecimal . ZERO ) ;
}
//章节练习
List < TeacherOpenCourseQuestionSetting > select = teacherOpenCourseQuestionSettingDao . createLambdaQuery ( )
. andEq ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseId , teacherOpenCourseId )
. andEq ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseQuestionSettingType , ResourcesQuestionSnapshotFromTypeEnum . CHAPTER_EXERCISE ) . select ( ) ;
if ( CollectionUtil . isEmpty ( select ) ) {
//章节练习成绩
{
scoreDashboard . setCourseScore ( BigDecimal . ZERO ) ;
} else {
List < Long > collect = select . stream ( ) . map ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseQuestionSettingId ) . collect ( Collectors . toList ( ) ) ;
List < QuestionLogSummary > select1 = questionLogSummaryService . createLambdaQuery ( )
. andEq ( QuestionLogSummary : : getPersonId , studentId )
. andIn ( QuestionLogSummary : : getQuestionSettingId , collect ) . select ( ) ;
if ( weight = = null | | "1" . equals ( weight . getCoursePracticeResultSetting ( ) ) ) {
if ( CollectionUtil . isEmpty ( select1 ) ) {
scoreDashboard . setCourseScore ( BigDecimal . ZERO ) ;
} else {
BigDecimal b = BigDecimal . ZERO ;
for ( QuestionLogSummary questionLogSummary : select1 ) {
b = b . add ( questionLogSummary . getQuestionLogSummarySuccessRate ( ) ) ;
}
BigDecimal div = NumberUtil . div ( b , select1 . size ( ) ) ;
BigDecimal mul = NumberUtil . mul ( div , 100 ) ;
scoreDashboard . setCourseScore ( mul ) ;
if ( ! CollectionUtil . isEmpty ( chapterExerciseList ) ) {
List < Long > teacherOpenCourseQuestionSettingIdList = chapterExerciseList . stream ( ) . map ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseQuestionSettingId ) . collect ( Collectors . toList ( ) ) ;
//查询章节练习成绩
List < QuestionLogSummary > questionLogSummaryList = questionLogSummaryDao . createLambdaQuery ( )
. andEq ( QuestionLogSummary : : getPersonId , studentId )
. andEq ( QuestionLogSummary : : getQuestionLogSummaryStatus , 1 )
. andIn ( QuestionLogSummary : : getQuestionSettingId , teacherOpenCourseQuestionSettingIdList ) . select ( ) ;
if ( CollectionUtil . isEmpty ( questionLogSummaryList ) ) {
questionLogSummaryList = new ArrayList < > ( ) ;
}
} else {
BigDecimal b = BigDecimal . ZERO ;
for ( QuestionLogSummary questionLogSummary : select1 ) {
b = b . add ( questionLogSummary . getQuestionLogSummaryStudentTotalScore ( ) ) ;
Map < Long , List < QuestionLogSummary > > questionLogSummaryMap = questionLogSummaryList . stream ( ) . collect ( Collectors . groupingBy ( QuestionLogSummary : : getQuestionSettingId ) ) ;
//按正确率计算
if ( weight = = null | | "1" . equals ( weight . getCoursePracticeResultSetting ( ) ) ) {
//总章节练习数
int baseSize = teacherOpenCourseQuestionSettingIdList . size ( ) ;
//总正确率
BigDecimal allSuccessRate = BigDecimal . ZERO ;
for ( Long settingId : teacherOpenCourseQuestionSettingIdList ) {
List < QuestionLogSummary > list = questionLogSummaryMap . get ( settingId ) ;
if ( CollectionUtils . isEmpty ( list ) ) {
continue ;
}
list . sort ( Comparator . comparing ( QuestionLogSummary : : getQuestionLogSummaryAddTime ) . reversed ( ) ) ;
QuestionLogSummary questionLogSummary = list . get ( 0 ) ;
//这里的正确率默认就是百分比, 不需要再除以100
BigDecimal questionLogSummarySuccessRate = questionLogSummary . getQuestionLogSummarySuccessRate ( ) ;
if ( questionLogSummarySuccessRate ! = null ) {
allSuccessRate = allSuccessRate . add ( questionLogSummarySuccessRate ) ;
}
}
//平均正确率得出分数
BigDecimal avgSuccessRate = allSuccessRate . divide ( BigDecimal . valueOf ( baseSize ) , 1 , RoundingMode . HALF_UP ) ;
scoreDashboard . setCourseScore ( avgSuccessRate ) ;
} else if ( "2" . equals ( weight . getCoursePracticeResultSetting ( ) ) ) {
//按完成进度计分:完成进度*100
//总章节练习数
int baseSize = teacherOpenCourseQuestionSettingIdList . size ( ) ;
int successSize = questionLogSummaryList . size ( ) ;
BigDecimal avgSuccessCount = BigDecimal . valueOf ( successSize ) . divide ( BigDecimal . valueOf ( baseSize ) , 3 , RoundingMode . HALF_UP ) . multiply ( BigDecimal . valueOf ( 100 ) ) ;
scoreDashboard . setCourseScore ( avgSuccessCount ) ;
}
scoreDashboard . setCourseScore ( b ) ;
}
}
//实操成绩
List < StudentHandsOnTaskVideo > single = videoService . createLambdaQuery ( )
. andEq ( StudentHandsOnTaskVideo : : getTeacherOpenCourseId , teacherOpenCourseId )
. andEq ( StudentHandsOnTaskVideo : : getStudentId , studentId ) . select ( ) ;
List < StudentHandsOnTaskPpt > single2 = pptService . createLambdaQuery ( )
. andEq ( StudentHandsOnTaskPpt : : getTeacherOpenCourseId , teacherOpenCourseId )
. andEq ( StudentHandsOnTaskPpt : : getStudentId , studentId ) . select ( ) ;
List < StudentHandsOnTaskStep > single3 = stepService . createLambdaQuery ( )
. andEq ( StudentHandsOnTaskStep : : getTeacherOpenCourseId , teacherOpenCourseId )
. andEq ( StudentHandsOnTaskStep : : getStudentId , studentId ) . select ( ) ;
List < StudentHandsOnTaskReport > single4 = reportService . createLambdaQuery ( )
. andEq ( StudentHandsOnTaskReport : : getTeacherOpenCourseId , teacherOpenCourseId )
. andEq ( StudentHandsOnTaskReport : : getStudentId , studentId ) . select ( ) ;
List < StudentHandsOnTaskTheory > single5 = theoryService . createLambdaQuery ( )
. andEq ( StudentHandsOnTaskTheory : : getTeacherOpenCourseId , teacherOpenCourseId )
. andEq ( StudentHandsOnTaskTheory : : getStudentId , studentId ) . select ( ) ;
BigDecimal realOperationScore = BigDecimal . ZERO ;
if ( CollectionUtil . isNotEmpty ( single ) ) {
for ( StudentHandsOnTaskVideo studentHandsOnTaskVideo : single ) {
try {
realOperationScore = NumberUtil . add ( realOperationScore ,
NumberUtil . toBigDecimal ( studentHandsOnTaskVideo . getVideoScore ( ) ) ) ;
} catch ( Exception ee ) {
ee . printStackTrace ( ) ;
}
{
scoreDashboard . setRealOperationScore ( BigDecimal . ZERO ) ;
if ( CollectionUtil . isNotEmpty ( teacherOpenCourseHandsOnSimulationTasksList ) ) {
}
}
if ( CollectionUtil . isNotEmpty ( single2 ) ) {
for ( StudentHandsOnTaskPpt studentHandsOnTaskPpt : single2 ) {
try {
realOperationScore = NumberUtil . add ( realOperationScore ,
NumberUtil . toBigDecimal ( studentHandsOnTaskPpt . getPptScore ( ) ) ) ;
} catch ( Exception ee ) {
ee . printStackTrace ( ) ;
}
Map < Long , List < TeacherOpenCourseHandsOnSimulationTasks > > teacherOpenCourseHandsOnSimulationTasksMap = teacherOpenCourseHandsOnSimulationTasksList . stream ( ) . collect ( Collectors . groupingBy ( TeacherOpenCourseHandsOnSimulationTasks : : getHandsOnId ) ) ;
}
}
if ( CollectionUtil . isNotEmpty ( single3 ) ) {
for ( StudentHandsOnTaskStep studentHandsOnTaskStep : single3 ) {
try {
realOperationScore = NumberUtil . add ( realOperationScore ,
NumberUtil . toBigDecimal ( studentHandsOnTaskStep . getTheoryScore ( ) ) ) ;
} catch ( Exception ee ) {
ee . printStackTrace ( ) ;
}
List < StudentHandsOnTaskVideo > studentHandsOnTaskVideoList = videoDao . createLambdaQuery ( )
. andEq ( StudentHandsOnTaskVideo : : getTeacherOpenCourseId , teacherOpenCourseId )
. andEq ( StudentHandsOnTaskVideo : : getStudentId , studentId ) . select ( ) ;
}
}
if ( CollectionUtil . isNotEmpty ( single4 ) ) {
for ( StudentHandsOnTaskReport studentHandsOnTaskReport : single4 ) {
try {
realOperationScore = NumberUtil . add ( realOperationScore ,
NumberUtil . toBigDecimal ( studentHandsOnTaskReport . getReportScore ( ) ) ) ;
} catch ( Exception ee ) {
ee . printStackTrace ( ) ;
}
Map < Long , List < StudentHandsOnTaskVideo > > studentHandsOnTaskVideoMap = studentHandsOnTaskVideoList . stream ( ) . collect ( Collectors . groupingBy ( StudentHandsOnTaskVideo : : getHandsOnTaskId ) ) ;
}
}
if ( CollectionUtil . isNotEmpty ( single5 ) ) {
for ( StudentHandsOnTaskTheory studentHandsOnTaskTheory : single5 ) {
try {
realOperationScore = NumberUtil . add ( realOperationScore ,
NumberUtil . toBigDecimal ( studentHandsOnTaskTheory . getTheoryScore ( ) ) ) ;
} catch ( Exception ee ) {
ee . printStackTrace ( ) ;
}
List < StudentHandsOnTaskPpt > studentHandsOnTaskPptList = pptDao . createLambdaQuery ( )
. andEq ( StudentHandsOnTaskPpt : : getTeacherOpenCourseId , teacherOpenCourseId )
. andEq ( StudentHandsOnTaskPpt : : getStudentId , studentId ) . select ( ) ;
Map < Long , List < StudentHandsOnTaskPpt > > studentHandsOnTaskPptMap = studentHandsOnTaskPptList . stream ( ) . collect ( Collectors . groupingBy ( StudentHandsOnTaskPpt : : getHandsOnTaskId ) ) ;
List < StudentHandsOnTaskStep > studentHandsOnTaskStepList = stepDao . createLambdaQuery ( )
. andEq ( StudentHandsOnTaskStep : : getTeacherOpenCourseId , teacherOpenCourseId )
. andEq ( StudentHandsOnTaskStep : : getStudentId , studentId ) . select ( ) ;
Map < Long , List < StudentHandsOnTaskStep > > studentHandsOnTaskStepMap = studentHandsOnTaskStepList . stream ( ) . collect ( Collectors . groupingBy ( StudentHandsOnTaskStep : : getHandsOnTaskId ) ) ;
List < StudentHandsOnTaskReport > studentHandsOnTaskReportList = reportDao . createLambdaQuery ( )
. andEq ( StudentHandsOnTaskReport : : getTeacherOpenCourseId , teacherOpenCourseId )
. andEq ( StudentHandsOnTaskReport : : getStudentId , studentId ) . select ( ) ;
Map < Long , List < StudentHandsOnTaskReport > > studentHandsOnTaskReportMap = studentHandsOnTaskReportList . stream ( ) . collect ( Collectors . groupingBy ( StudentHandsOnTaskReport : : getHandsOnTaskId ) ) ;
List < StudentHandsOnTaskTheory > studentHandsOnTaskTheoryList = theoryDao . createLambdaQuery ( )
. andEq ( StudentHandsOnTaskTheory : : getTeacherOpenCourseId , teacherOpenCourseId )
. andEq ( StudentHandsOnTaskTheory : : getStudentId , studentId ) . select ( ) ;
Map < Long , List < StudentHandsOnTaskTheory > > studentHandsOnTaskTheoryMap = studentHandsOnTaskTheoryList . stream ( ) . collect ( Collectors . groupingBy ( StudentHandsOnTaskTheory : : getHandsOnTaskId ) ) ;
//1平均分2平均完成进度
if ( weight = = null | | "1" . equals ( weight . getCoursePracticeResultSetting ( ) ) ) {
BigDecimal allHandOnScore = BigDecimal . ZERO ;
for ( Long handOnId : handOnIdList ) {
//获取这个实操任务的所有子项,并算出总分
List < TeacherOpenCourseHandsOnSimulationTasks > list = teacherOpenCourseHandsOnSimulationTasksMap . get ( handOnId ) ;
if ( CollectionUtil . isEmpty ( list ) ) {
continue ;
}
BigDecimal handOnTaskScoreSum = BigDecimal . ZERO ;
for ( TeacherOpenCourseHandsOnSimulationTasks item : list ) {
BigDecimal taskScore = new BigDecimal ( ObjectUtil . defaultIfBlank ( item . getTaskScore ( ) , "0" ) ) ;
handOnTaskScoreSum = handOnTaskScoreSum . add ( taskScore ) ;
}
//得到这个学生的分数,一个学生一个实操任务只有一条记录
HandsOnAchievement handsOnAchievement = new HandsOnAchievement ( ) ;
handsOnAchievement . setHandOnId ( handOnId ) ;
handsOnAchievement . setStudentId ( studentId ) ;
handsOnAchievement . setHandOnAchievementStatus ( 1 ) ;
HandsOnAchievement handsOnAchievementRes = handsOnAchievementService . queryObject ( handsOnAchievement ) ;
if ( handsOnAchievementRes ! = null ) {
String totalScore = handsOnAchievementRes . getTotalScore ( ) ;
if ( StringUtils . isNotBlank ( totalScore ) ) {
//转换为百分制
BigDecimal formatScore = new BigDecimal ( totalScore ) . multiply ( new BigDecimal ( 100 ) ) . divide ( handOnTaskScoreSum , 1 , RoundingMode . HALF_UP ) ;
allHandOnScore = allHandOnScore . add ( formatScore ) ;
}
}
}
BigDecimal avgScore = allHandOnScore . divide ( new BigDecimal ( handOnIdList . size ( ) ) , 1 , RoundingMode . HALF_UP ) ;
scoreDashboard . setRealOperationScore ( avgScore ) ;
} else if ( "2" . equals ( weight . getCoursePracticeResultSetting ( ) ) ) {
BigDecimal allDoStepSuccessProportion = BigDecimal . ZERO ;
for ( Long handOnId : handOnIdList ) {
//获取这个实操任务的所有子项
List < TeacherOpenCourseHandsOnSimulationTasks > list = teacherOpenCourseHandsOnSimulationTasksMap . get ( handOnId ) ;
if ( CollectionUtil . isNotEmpty ( list ) ) {
//得出这个实操任务的完成率
int doStepTimes = 0 ;
for ( TeacherOpenCourseHandsOnSimulationTasks task : list ) {
if ( studentHandsOnTaskVideoMap . containsKey ( task . getTaskId ( ) )
| | studentHandsOnTaskPptMap . containsKey ( task . getTaskId ( ) )
| | studentHandsOnTaskStepMap . containsKey ( task . getTaskId ( ) )
| | studentHandsOnTaskReportMap . containsKey ( task . getTaskId ( ) )
| | studentHandsOnTaskTheoryMap . containsKey ( task . getTaskId ( ) ) ) {
doStepTimes + + ;
}
}
//计算完成率
BigDecimal divide = new BigDecimal ( doStepTimes ) . divide ( new BigDecimal ( list . size ( ) ) , 5 , RoundingMode . HALF_UP ) ;
if ( divide . compareTo ( BigDecimal . ONE ) > 0 ) {
divide = BigDecimal . ONE ;
}
allDoStepSuccessProportion = allDoStepSuccessProportion . add ( divide ) ;
}
}
//计算平均完成率并乘以100得出分数
BigDecimal avgScore = allDoStepSuccessProportion . multiply ( new BigDecimal ( 100 ) ) . divide ( new BigDecimal ( handOnIdList . size ( ) ) , 1 , RoundingMode . HALF_UP ) ;
scoreDashboard . setRealOperationScore ( avgScore ) ;
}
}
}
scoreDashboard . setRealOperationScore ( realOperationScore ) ;
//作业
List < TeacherOpenCourseQuestionSetting > select2 = teacherOpenCourseQuestionSettingDao . createLambdaQuery ( )
. andEq ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseId , teacherOpenCourseId )
. andEq ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseQuestionSettingType , ResourcesQuestionSnapshotFromTypeEnum . HOMEWORK_QUESTION ) . select ( ) ;
if ( CollectionUtil . isEmpty ( select2 ) ) {
{
//查询题目类型作业和文件类型作业
scoreDashboard . setQuestionHomeworkScore ( BigDecimal . ZERO ) ;
} else {
List < Long > collect = select2 . stream ( ) . map ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseQuestionSettingId ) . collect ( Collectors . toList ( ) ) ;
List < QuestionLogSummary > select1 = questionLogSummaryService . createLambdaQuery ( )
. andEq ( QuestionLogSummary : : getPersonId , studentId )
. andIn ( QuestionLogSummary : : getQuestionSettingId , collect ) . select ( ) ;
if ( CollectionUtil . isEmpty ( select1 ) ) {
scoreDashboard . setQuestionHomeworkScore ( BigDecimal . ZERO ) ;
} else {
BigDecimal b = BigDecimal . ZERO ;
for ( QuestionLogSummary questionLogSummary : select1 ) {
b = b . add ( questionLogSummary . getQuestionLogSummaryStudentTotalScore ( ) ) ;
if ( ! CollectionUtil . isEmpty ( homeworkList ) ) {
List < Long > settingIdList = homeworkList . stream ( ) . map ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseQuestionSettingId ) . collect ( Collectors . toList ( ) ) ;
List < QuestionLogSummary > questionLogSummaryList = questionLogSummaryDao . createLambdaQuery ( )
. andEq ( QuestionLogSummary : : getPersonId , studentId )
. andIn ( QuestionLogSummary : : getQuestionSettingId , settingIdList )
. andEq ( QuestionLogSummary : : getQuestionLogSummaryStatus , 1 ) . select ( ) ;
if ( ! CollectionUtil . isEmpty ( questionLogSummaryList ) ) {
Map < Long , List < QuestionLogSummary > > questionLogSummaryMap = questionLogSummaryList . stream ( ) . collect ( Collectors . groupingBy ( QuestionLogSummary : : getQuestionSettingId ) ) ;
BigDecimal b = BigDecimal . ZERO ;
for ( Map . Entry < Long , List < QuestionLogSummary > > entry : questionLogSummaryMap . entrySet ( ) ) {
List < QuestionLogSummary > value = entry . getValue ( ) ;
//以防万一有多条记录,取最近的一条
value . sort ( Comparator . comparing ( QuestionLogSummary : : getQuestionLogSummaryAddTime ) . reversed ( ) ) ;
QuestionLogSummary questionLogSummary = value . get ( 0 ) ;
if ( ResourcesQuestionSnapshotFromTypeEnum . HOMEWORK_FILE . equals ( questionLogSummary . getQuestionSettingType ( ) ) ) {
//文件作业类型 没有最大分数,直接取学生得分
b = b . add ( ObjectUtil . defaultIfNull ( questionLogSummary . getQuestionLogSummaryStudentTotalScore ( ) , BigDecimal . ZERO ) ) ;
} else {
//题目类型作业 有最大分数,需要转换为百分制
BigDecimal questionSettingTotalScore = ObjectUtil . defaultIfNull ( questionLogSummary . getQuestionSettingTotalScore ( ) , BigDecimal . valueOf ( 100 ) ) ;
BigDecimal questionLogSummaryStudentTotalScore = ObjectUtil . defaultIfNull ( questionLogSummary . getQuestionLogSummaryStudentTotalScore ( ) , BigDecimal . ZERO ) ;
//转为百分制
b = b . add ( questionLogSummaryStudentTotalScore . multiply ( new BigDecimal ( 100 ) ) . divide ( questionSettingTotalScore , 1 , RoundingMode . HALF_UP ) ) ;
}
}
//总分除以总作业数得出平均分
b = b . divide ( new BigDecimal ( homeworkList . size ( ) ) , 1 , RoundingMode . HALF_UP ) ;
scoreDashboard . setQuestionHomeworkScore ( b ) ;
}
scoreDashboard . setQuestionHomeworkScore ( b ) ;
}
}
//考试
List < TeacherOpenCourseQuestionSetting > select3 = teacherOpenCourseQuestionSettingDao . createLambdaQuery ( )
. andEq ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseId , teacherOpenCourseId )
. andEq ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseQuestionSettingType , ResourcesQuestionSnapshotFromTypeEnum . EXAM ) . select ( ) ;
if ( CollectionUtil . isEmpty ( select3 ) ) {
{
scoreDashboard . setExamScore ( BigDecimal . ZERO ) ;
} else {
if ( weight = = null | | "1" . equals ( weight . getCoursePracticeResultSetting ( ) ) ) {
List < Long > collect = select3 . stream ( ) . map ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseQuestionSettingId ) . collect ( Collectors . toList ( ) ) ;
List < QuestionLogSummary > select1 = questionLogSummaryService . createLambdaQuery ( )
. andEq ( QuestionLogSummary : : getPersonId , studentId )
. andIn ( QuestionLogSummary : : getQuestionSettingId , collect ) . select ( ) ;
if ( CollectionUtil . isEmpty ( select1 ) ) {
scoreDashboard . setExamScore ( BigDecimal . ZERO ) ;
} else {
BigDecimal b = BigDecimal . ZERO ;
for ( QuestionLogSummary questionLogSummary : select1 ) {
b = b . add ( questionLogSummary . getQuestionLogSummaryStudentTotalScore ( ) ) ;
if ( ! CollectionUtil . isEmpty ( examList ) ) {
if ( weight = = null | | "1" . equals ( weight . getExaminationResultSetting ( ) ) ) {
List < Long > settingIdList = examList . stream ( ) . map ( TeacherOpenCourseQuestionSetting : : getTeacherOpenCourseQuestionSettingId ) . collect ( Collectors . toList ( ) ) ;
//查询学生考试记录
List < QuestionLogSummary > questionLogSummaryList = questionLogSummaryDao . createLambdaQuery ( )
. andEq ( QuestionLogSummary : : getPersonId , studentId )
. andIn ( QuestionLogSummary : : getQuestionSettingId , settingIdList )
. andEq ( QuestionLogSummary : : getQuestionLogSummaryStatus , 1 )
. select ( ) ;
if ( ! CollectionUtil . isEmpty ( questionLogSummaryList ) ) {
Map < Long , List < QuestionLogSummary > > questionLogSummaryMap = questionLogSummaryList . stream ( ) . collect ( Collectors . groupingBy ( QuestionLogSummary : : getQuestionSettingId ) ) ;
BigDecimal b = BigDecimal . ZERO ;
for ( Map . Entry < Long , List < QuestionLogSummary > > entry : questionLogSummaryMap . entrySet ( ) ) {
List < QuestionLogSummary > value = entry . getValue ( ) ;
//以防万一有多条记录,取最近的一条
value . sort ( Comparator . comparing ( QuestionLogSummary : : getQuestionLogSummaryAddTime ) . reversed ( ) ) ;
QuestionLogSummary questionLogSummary = value . get ( 0 ) ;
BigDecimal questionSettingTotalScore = ObjectUtil . defaultIfNull ( questionLogSummary . getQuestionSettingTotalScore ( ) , BigDecimal . valueOf ( 100 ) ) ;
BigDecimal questionLogSummaryStudentTotalScore = ObjectUtil . defaultIfNull ( questionLogSummary . getQuestionLogSummaryStudentTotalScore ( ) , BigDecimal . ZERO ) ;
//转为百分制
b = b . add ( questionLogSummaryStudentTotalScore . multiply ( new BigDecimal ( 100 ) ) . divide ( questionSettingTotalScore , 1 , RoundingMode . HALF_UP ) ) ;
}
//总分除以总作业数得出平均分
b = b . divide ( new BigDecimal ( examList . size ( ) ) , 1 , RoundingMode . HALF_UP ) ;
scoreDashboard . setQuestionHomeworkScore ( b ) ;
}
scoreDashboard . setExamScore ( b ) ;
}
}
}
//互动
List < TeacherOpenCourseChatLog > chatLogList = courseChatLogDao . createLambdaQuery ( )
. andEq ( TeacherOpenCourseChatLog : : getStudentId , studentId )
. andEq ( TeacherOpenCourseChatLog : : getTeacherOpenCourseId , teacherOpenCourseId ) . select ( ) ;
//提问次数
long count = chatLogList . stream ( ) . filter ( v - > v . getChatLogSendType ( ) . equals ( ChatLogSendTypeEnum . student_ask )
| | v . getChatLogSendType ( ) . equals ( ChatLogSendTypeEnum . specify_ask ) ) . count ( ) ;
//回复次数
long count2 = chatLogList . stream ( ) . filter ( v - >
v . getChatLogSendType ( ) . equals ( ChatLogSendTypeEnum . normal ) ) . count ( ) ;
//答题次数
long count3 = chatLogList . stream ( ) . filter ( v - >
v . getChatLogSendType ( ) . equals ( ChatLogSendTypeEnum . normal )
& & v . getStudentScore ( ) ! = null
) . count ( ) ;
BigDecimal chatScore = BigDecimal . ZERO ;
if ( weight ! = null & & StringUtils . isNotEmpty ( weight . getInteractionResultSetting ( ) ) ) {
String interactionResultSetting = weight . getInteractionResultSetting ( ) ;
if ( interactionResultSetting . contains ( "1" ) ) {
chatScore = NumberUtil . mul ( count2 , NumberUtil . toBigDecimal ( weight . getInteractionResultMessageScore ( ) ) ) ;
}
if ( interactionResultSetting . contains ( "2" ) ) {
chatScore = NumberUtil . mul ( count , NumberUtil . toBigDecimal ( weight . getInteractionResultQuestionScore ( ) ) ) ;
}
if ( interactionResultSetting . contains ( "3" ) ) {
chatScore = NumberUtil . mul ( count3 , NumberUtil . toBigDecimal ( weight . getInteractionResultAnswerScore ( ) ) ) ;
//互动分数
{
scoreDashboard . setChatScore ( BigDecimal . ZERO ) ;
if ( CollectionUtil . isNotEmpty ( teacherOpenCourseChatLogList ) & & weight ! = null & & StringUtils . isNotBlank ( weight . getInteractionResultSetting ( ) ) ) {
BigDecimal totalChatScore = BigDecimal . ZERO ;
//1留言2提问3回答
String interactionResultSetting = weight . getInteractionResultSetting ( ) ;
//回答分数处理
{
if ( interactionResultSetting . contains ( "3" ) ) {
//老师提问该学生
List < Long > teacherAskIds = teacherOpenCourseChatLogList . stream ( ) . filter ( v - > {
return ( ChatLogSendTypeEnum . random_ask . equals ( v . getChatLogSendType ( ) ) | | ChatLogSendTypeEnum . specify_ask . equals ( v . getChatLogSendType ( ) ) )
& & ObjectUtil . equals ( studentId , v . getStudentId ( ) ) ;
} ) . map ( TeacherOpenCourseChatLog : : getTeacherOpenCourseChatLogId ) . collect ( Collectors . toList ( ) ) ;
if ( CollectionUtil . isNotEmpty ( teacherAskIds ) ) {
//学生回答的次数,回答多次也只算一次
long count = teacherOpenCourseChatLogList . stream ( ) . filter ( v - > {
return ObjectUtil . equals ( studentId , v . getStudentId ( ) )
& & teacherAskIds . contains ( v . getTeacherOpenCourseChatLogParentId ( ) ) ;
} ) . map ( TeacherOpenCourseChatLog : : getTeacherOpenCourseChatLogParentId ) . distinct ( ) . count ( ) ;
BigDecimal interactionResultAnswerScore = new BigDecimal ( ObjectUtil . defaultIfBlank ( weight . getInteractionResultAnswerScore ( ) , "0" ) ) ;
totalChatScore = totalChatScore . add ( interactionResultAnswerScore . multiply ( new BigDecimal ( count ) ) ) ;
}
}
}
//提问分数处理
{
if ( interactionResultSetting . contains ( "2" ) ) {
//学生提问老师
List < Long > studentAskIds = teacherOpenCourseChatLogList . stream ( ) . filter ( v - > {
return ChatLogSendTypeEnum . student_ask . equals ( v . getChatLogSendType ( ) )
& & ObjectUtil . equals ( studentId , v . getStudentId ( ) ) ;
} ) . map ( TeacherOpenCourseChatLog : : getTeacherOpenCourseChatLogId ) . collect ( Collectors . toList ( ) ) ;
long count = studentAskIds . size ( ) ;
BigDecimal interactionResultQuestionScore = new BigDecimal ( ObjectUtil . defaultIfBlank ( weight . getInteractionResultQuestionScore ( ) , "0" ) ) ;
BigDecimal multiply = interactionResultQuestionScore . multiply ( new BigDecimal ( count ) ) ;
if ( multiply . compareTo ( new BigDecimal ( TeacherOpenCourseScoreDashboardConstant . STUDENT_ASK_MAX_SCORE ) ) > 0 ) {
multiply = new BigDecimal ( TeacherOpenCourseScoreDashboardConstant . STUDENT_ASK_MAX_SCORE ) ;
}
totalChatScore = totalChatScore . add ( multiply ) ;
}
}
//留言分数处理
{
if ( interactionResultSetting . contains ( "1" ) ) {
//老师发起的讨论,学生的班级在讨论的班级中
List < Long > discussionIdList = teacherOpenCourseChatLogList . stream ( ) . filter ( v - > {
return ChatLogSendTypeEnum . discuss . equals ( v . getChatLogSendType ( ) )
& & (
StringUtils . isBlank ( v . getSchoolClassIds ( ) )
| | Arrays . asList ( v . getSchoolClassIds ( ) . split ( "," ) ) . contains ( student . getClassId ( ) . toString ( ) )
) ;
} ) . map ( TeacherOpenCourseChatLog : : getTeacherOpenCourseChatLogId ) . collect ( Collectors . toList ( ) ) ;
//学生回复的讨论的次数
long count = teacherOpenCourseChatLogList . stream ( ) . filter ( v - > {
return (
ObjectUtil . equals ( studentId , v . getStudentId ( ) )
& & ChatLogSendTypeEnum . normal . equals ( v . getChatLogSendType ( ) )
& & StringUtils . isNotBlank ( v . getChatLogFullId ( ) )
& & discussionIdList . contains ( Long . valueOf ( v . getChatLogFullId ( ) . split ( "_" ) [ 0 ] ) )
) ;
} ) . count ( ) ;
BigDecimal interactionResultMessageScore = new BigDecimal ( ObjectUtil . defaultIfBlank ( weight . getInteractionResultMessageScore ( ) , "0" ) ) ;
BigDecimal multiply = interactionResultMessageScore . multiply ( new BigDecimal ( count ) ) ;
if ( multiply . compareTo ( new BigDecimal ( TeacherOpenCourseScoreDashboardConstant . DISCUSS_MAX_SCORE ) ) > 0 ) {
multiply = new BigDecimal ( TeacherOpenCourseScoreDashboardConstant . DISCUSS_MAX_SCORE ) ;
}
totalChatScore = totalChatScore . add ( multiply ) ;
}
}
scoreDashboard . setChatScore ( totalChatScore ) ;
}
} else {
chatScore = BigDecimal . valueOf ( count2 ) ;
}
scoreDashboard . setChatScore ( chatScore ) ;
BigDecimal totalScore = scoreDashboard . getSigninScore ( )
. add ( scoreDashboard . getCourseScore ( ) )
. add ( scoreDashboard . getRealOperationScore ( ) )
. add ( scoreDashboard . getQuestionHomeworkScore ( ) )
. add ( scoreDashboard . getExamScore ( ) )
. add ( scoreDashboard . getChatScore ( ) ) ;
scoreDashboard . setTotalScore ( totalScore ) ;
if ( weight ! = null ) {
lastStatus ( weight , totalScore , scoreDashboard ) ;
//总分
{
scoreDashboard . setTotalScore ( BigDecimal . ZERO ) ;
if ( weight ! = null ) {
BigDecimal totalScore = BigDecimal . ZERO ;
BigDecimal formatSignScore = scoreDashboard . getSigninScore ( ) . multiply ( new BigDecimal ( ObjectUtil . defaultIfBlank ( weight . getSignInResult ( ) , "0" ) ) ) ;
BigDecimal formatCourseScore = scoreDashboard . getCourseScore ( ) . multiply ( new BigDecimal ( ObjectUtil . defaultIfBlank ( weight . getChapterContactResult ( ) , "0" ) ) ) ;
BigDecimal formatRealOperationScore = scoreDashboard . getRealOperationScore ( ) . multiply ( new BigDecimal ( ObjectUtil . defaultIfBlank ( weight . getCoursePracticeResult ( ) , "0" ) ) ) ;
BigDecimal formatQuestionHomeworkScore = scoreDashboard . getQuestionHomeworkScore ( ) . multiply ( new BigDecimal ( ObjectUtil . defaultIfBlank ( weight . getHomeworkResult ( ) , "0" ) ) ) ;
BigDecimal formatExamScore = scoreDashboard . getExamScore ( ) . multiply ( new BigDecimal ( ObjectUtil . defaultIfBlank ( weight . getExaminationResult ( ) , "0" ) ) ) ;
BigDecimal formatChatScore = scoreDashboard . getChatScore ( ) . multiply ( new BigDecimal ( ObjectUtil . defaultIfBlank ( weight . getInteractionResult ( ) , "0" ) ) ) ;
totalScore = totalScore . add ( formatSignScore ) . add ( formatCourseScore ) . add ( formatRealOperationScore ) . add ( formatQuestionHomeworkScore ) . add ( formatExamScore ) . add ( formatChatScore ) ;
//加上手动的分数
totalScore = totalScore . add ( ObjectUtil . defaultIfNull ( teacherOpenCourseScoreDashboard . getManualScore ( ) , BigDecimal . ZERO ) ) ;
totalScore = totalScore . setScale ( 1 , RoundingMode . HALF_UP ) ;
scoreDashboard . setTotalScore ( totalScore ) ;
//成绩状态
lastStatus ( weight , totalScore , scoreDashboard ) ;
}
}
scoreDashboard . setTeacherOpenCourseId ( teacherOpenCourseId ) ;
studentScores . add ( scoreDashboard ) ;
updateTemplate ( scoreDashboard ) ;
}
//通过课程id删除存量数据
teacherOpenCourseScoreDashboardDao . deleteByTeacherOpenCourseId ( teacherOpenCourseId ) ;
teacherOpenCourseScoreDashboardDao . insertBatch ( studentScores ) ;
return true ;
}
@ -779,4 +1046,70 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService<Teac
String filename = StrUtil . format ( "成绩-导出 {}.xlsx" , System . currentTimeMillis ( ) ) ;
write ( response , filename , "Sheet1" , header . values ( ) , convertData ( header . keySet ( ) , maps ) ) ;
}
public void updateManualScore ( Long teacherOpenCourseScoreDashboardId , Long studentId , Long teacherOpenCourseId , BigDecimal manualScore ) {
TeacherOpenCourseScoreDashboard teacherOpenCourseScoreDashboard = null ;
if ( teacherOpenCourseScoreDashboardId ! = null ) {
teacherOpenCourseScoreDashboard = this . queryById ( teacherOpenCourseScoreDashboardId ) ;
if ( teacherOpenCourseScoreDashboard = = null ) {
throw new PlatformException ( "参数错误!" ) ;
}
} else {
if ( studentId = = null | | teacherOpenCourseId = = null ) {
throw new PlatformException ( "参数错误!" ) ;
}
TeacherOpenCourseScoreDashboard param = new TeacherOpenCourseScoreDashboard ( ) ;
param . setStudentId ( studentId ) ;
param . setTeacherOpenCourseId ( teacherOpenCourseId ) ;
teacherOpenCourseScoreDashboard = this . queryObject ( param ) ;
if ( teacherOpenCourseScoreDashboard = = null ) {
Student student = studentService . queryById ( studentId ) ;
if ( student = = null ) {
throw new PlatformException ( "参数错误!" ) ;
}
teacherOpenCourseScoreDashboard = new TeacherOpenCourseScoreDashboard ( ) ;
teacherOpenCourseScoreDashboard . setTeacherOpenCourseId ( teacherOpenCourseId ) ;
teacherOpenCourseScoreDashboard . setStudentId ( studentId ) ;
teacherOpenCourseScoreDashboard . setOrgId ( student . getOrgId ( ) ) ;
teacherOpenCourseScoreDashboard . setStudentSn ( student . getStudentSn ( ) ) ;
teacherOpenCourseScoreDashboard . setStudentName ( student . getStudentName ( ) ) ;
teacherOpenCourseScoreDashboard . setExamScore ( BigDecimal . ZERO ) ;
teacherOpenCourseScoreDashboard . setCourseScore ( BigDecimal . ZERO ) ;
teacherOpenCourseScoreDashboard . setChatScore ( BigDecimal . ZERO ) ;
teacherOpenCourseScoreDashboard . setSigninScore ( BigDecimal . ZERO ) ;
teacherOpenCourseScoreDashboard . setRealOperationScore ( BigDecimal . ZERO ) ;
teacherOpenCourseScoreDashboard . setQuestionHomeworkScore ( BigDecimal . ZERO ) ;
teacherOpenCourseScoreDashboard . setTotalScore ( BigDecimal . ZERO ) ;
teacherOpenCourseScoreDashboard . setManualScore ( BigDecimal . ZERO ) ;
teacherOpenCourseScoreDashboard . setUserId ( student . getUserId ( ) ) ;
teacherOpenCourseScoreDashboard . setCreateTime ( new Date ( ) ) ;
teacherOpenCourseScoreDashboardDao . insert ( teacherOpenCourseScoreDashboard ) ;
}
}
teacherOpenCourseScoreDashboard . setManualScore ( ObjectUtil . defaultIfNull ( manualScore , BigDecimal . ZERO ) ) ;
teacherOpenCourseScoreDashboard . setTotalScore ( ObjectUtil . defaultIfNull ( teacherOpenCourseScoreDashboard . getTotalScore ( ) , BigDecimal . ZERO ) . add ( ObjectUtil . defaultIfNull ( manualScore , BigDecimal . ZERO ) ) . setScale ( 1 , RoundingMode . HALF_UP ) ) ;
updateTemplate ( teacherOpenCourseScoreDashboard ) ;
}
}