修改学生端实验概览

hehai
rong.liu 4 years ago
parent c398ef0472
commit cf83a5cc0e
  1. 1
      src/main/java/com/msdw/tms/entity/vo/ProjectRecordVo.java
  2. 43
      src/main/java/com/msdw/tms/service/impl/ProjectRecordServiceImpl.java

@ -5,6 +5,7 @@ import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
@Data

@ -24,6 +24,8 @@ import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.List;
@ -92,12 +94,53 @@ public class ProjectRecordServiceImpl extends ServiceImpl<ProjectRecordDao, Proj
//练习统计
List<GetByUserRecordResp> sumByPracticeNum = this.baseMapper.sumByPracticeNum(userId);
//练习总分
Integer practiceByScore = 0;
//练习总耗时
Integer practiceByTime = 0;
for (GetByUserRecordResp resp : sumByPracticeNum) {
//累计总分
practiceByScore += resp.getScore();
//累计时间
practiceByTime += resp.getTimeSum();
}
//考核统计
List<ProjectRecordVo> sumByAssessmentNum = this.baseMapper.sumByAssessmentNum(userId);
//练习总分
Integer assessmenteByScore = 0;
//练习总耗时
double assessmentByTime = 0;
for (ProjectRecordVo vo : sumByAssessmentNum) {
//累计总分
assessmenteByScore += vo.getScore();
//累计时间
assessmentByTime += vo.getTimeSum();
}
//设置实验次数
Integer numer = sumByPracticeNum.size() + sumByAssessmentNum.size();
projectRecordVo.setExperimentNumber(numer);
//取平均分
//BigDecimal getSumByScore = (new BigDecimal(practiceByScore).add(new BigDecimal(assessmenteByScore))).divide(new BigDecimal(numer)).setScale(2, RoundingMode.HALF_UP);
if (practiceByScore + assessmenteByScore != 0) {
double getSumByScore = (practiceByScore + assessmenteByScore) / numer;
projectRecordVo.setAvgScore(getSumByScore);
} else {
projectRecordVo.setAvgScore(0);
}
//获得总耗时
double getTime = practiceByTime + assessmentByTime;
projectRecordVo.setTotalTime(new Double(getTime));
Double totalTime = projectRecordVo.getTotalTime();
if (totalTime != null) {
DecimalFormat df = new DecimalFormat("0.00");

Loading…
Cancel
Save