|
|
|
@ -23,9 +23,10 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.logging.Handler;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/api/statisticsController")
|
|
|
|
@ -43,11 +44,12 @@ public class StatisticsController {
|
|
|
|
|
StuTheoryRecordMapper stuTheoryRecordMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
UserInfoMapper userInfoMapper;
|
|
|
|
|
|
|
|
|
|
//学生端 -我的成绩、有效时长、各模块用时
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@GetMapping("/selectStuStatistics")
|
|
|
|
|
@ApiOperation("学生端 -我的成绩、有效时长、各模块用时")
|
|
|
|
|
public ResultEntity<StuStatisticsDto> selectStuStatistics(@RequestParam String userId){
|
|
|
|
|
public ResultEntity<StuStatisticsDto> selectStuStatistics(@RequestParam String userId) {
|
|
|
|
|
ScoreRankExample scoreRankExample = new ScoreRankExample();
|
|
|
|
|
scoreRankExample.createCriteria().andUseridEqualTo(userId).andUpdateDateEqualTo(scoreRankService.getNowDate());
|
|
|
|
|
List<ScoreRank> scoreRankList = scoreRankMapper.selectByExample(scoreRankExample);
|
|
|
|
@ -59,43 +61,43 @@ public class StatisticsController {
|
|
|
|
|
stuStatisticsDto.setZhghTime(0);
|
|
|
|
|
stuStatisticsDto.setKszxTime(BigDecimal.valueOf(0));
|
|
|
|
|
stuStatisticsDto.setZyzxTime(0);
|
|
|
|
|
if(!scoreRankList.isEmpty()){
|
|
|
|
|
if (!scoreRankList.isEmpty()) {
|
|
|
|
|
ScoreRank scoreRank = scoreRankList.get(0);
|
|
|
|
|
stuStatisticsDto.setRank(scoreRank.getTotalRank());
|
|
|
|
|
stuStatisticsDto.setScore(scoreRank.getTotalScore());
|
|
|
|
|
//获取客户案例时长
|
|
|
|
|
Integer khanTime=stuTrainingMapper.selectTotalTrainingTimeByUserId(userId);
|
|
|
|
|
if (khanTime==null){
|
|
|
|
|
Integer khanTime = stuTrainingMapper.selectTotalTrainingTimeByUserId(userId);
|
|
|
|
|
if (khanTime == null) {
|
|
|
|
|
khanTime = 0;
|
|
|
|
|
}
|
|
|
|
|
stuStatisticsDto.setKhalTime(khanTime);
|
|
|
|
|
//获取综合规划时间
|
|
|
|
|
Integer zhghTime=synthesisPlanClientMapper.getTotalUseTime(userId);
|
|
|
|
|
if (zhghTime==null){
|
|
|
|
|
Integer zhghTime = synthesisPlanClientMapper.getTotalUseTime(userId);
|
|
|
|
|
if (zhghTime == null) {
|
|
|
|
|
zhghTime = 0;
|
|
|
|
|
}
|
|
|
|
|
stuStatisticsDto.setZhghTime(zhghTime);
|
|
|
|
|
//获取考试中心时间
|
|
|
|
|
StuTheoryRecord stuTheoryRecord = stuTheoryRecordMapper.selectByPrimaryKey(userId);
|
|
|
|
|
if(stuTheoryRecord!=null){
|
|
|
|
|
if (stuTheoryRecord != null) {
|
|
|
|
|
stuStatisticsDto.setKszxTime(stuTheoryRecord.getTotalDuration());
|
|
|
|
|
}
|
|
|
|
|
stuStatisticsDto.setTotalTime(BigDecimal.valueOf(khanTime+zhghTime).add(stuTheoryRecord==null?BigDecimal.ZERO:stuTheoryRecord.getTotalDuration()));
|
|
|
|
|
stuStatisticsDto.setTotalTime(BigDecimal.valueOf(khanTime + zhghTime).add(stuTheoryRecord == null ? BigDecimal.ZERO : stuTheoryRecord.getTotalDuration()));
|
|
|
|
|
}
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "我的成绩、有效时长、各模块用时返回成功!",stuStatisticsDto);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "我的成绩、有效时长、各模块用时返回成功!", stuStatisticsDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//学生端 -成绩走势
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@GetMapping("/getStuTrainingScoreTrend")
|
|
|
|
|
@ApiOperation("学生端 -成绩走势")
|
|
|
|
|
public ResultEntity<List<StuTrainingScoreTrendDto>> getStuTrainingScoreTrend(@RequestParam String userId,@RequestParam String classId,@RequestParam String schoolId){
|
|
|
|
|
public ResultEntity<List<StuTrainingScoreTrendDto>> getStuTrainingScoreTrend(@RequestParam String userId, @RequestParam String classId, @RequestParam String schoolId) {
|
|
|
|
|
//根据schoolID 查询score_rank表第一名和最后一名 并根据userId 查询本学生的成绩
|
|
|
|
|
ScoreRankExample scoreRankExample = new ScoreRankExample();
|
|
|
|
|
scoreRankExample.createCriteria().andClassIdEqualTo(classId).andUpdateDateEqualTo(scoreRankService.getNowDate().trim());
|
|
|
|
|
scoreRankExample.setOrderByClause("khal_score desc");
|
|
|
|
|
List<ScoreRank> scoreRankList = scoreRankMapper.selectByExample(scoreRankExample);
|
|
|
|
|
if(scoreRankList.isEmpty()){ //代表成绩还没更新
|
|
|
|
|
if (scoreRankList.isEmpty()) { //代表成绩还没更新
|
|
|
|
|
scoreRankService.doRankOne(schoolId);
|
|
|
|
|
scoreRankList = scoreRankMapper.selectByExample(scoreRankExample);
|
|
|
|
|
}
|
|
|
|
@ -103,7 +105,7 @@ public class StatisticsController {
|
|
|
|
|
String endUserId = scoreRankList.get(scoreRankList.size() - 1).getUserid();//最后一名UserId
|
|
|
|
|
|
|
|
|
|
//根据传递的userId 查询最近的五条成绩
|
|
|
|
|
List<StuTrainingScoreTrendDto> returnDtoList=new ArrayList<>();
|
|
|
|
|
List<StuTrainingScoreTrendDto> returnDtoList = new ArrayList<>();
|
|
|
|
|
//获取自己的成绩
|
|
|
|
|
StuTrainingScoreTrendDto selfDto = getTrendDto(userId, "我");
|
|
|
|
|
//获取第一名成绩
|
|
|
|
@ -113,16 +115,16 @@ public class StatisticsController {
|
|
|
|
|
returnDtoList.add(selfDto);
|
|
|
|
|
returnDtoList.add(firstDto);
|
|
|
|
|
returnDtoList.add(endDto);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "学生端 -成绩走势返回成功!",returnDtoList);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "学生端 -成绩走势返回成功!", returnDtoList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取成绩走势dto
|
|
|
|
|
private StuTrainingScoreTrendDto getTrendDto(String userId,String title){
|
|
|
|
|
List<ScoreRank> scoreList=scoreRankMapper.selectFiveScoreByUserId(userId);
|
|
|
|
|
private StuTrainingScoreTrendDto getTrendDto(String userId, String title) {
|
|
|
|
|
List<ScoreRank> scoreList = scoreRankMapper.selectFiveScoreByUserId(userId);
|
|
|
|
|
StuTrainingScoreTrendDto trendDto = new StuTrainingScoreTrendDto();
|
|
|
|
|
trendDto.setTitle(title);
|
|
|
|
|
List<BigDecimal> scores=new ArrayList<>();
|
|
|
|
|
List<String> dateList=new ArrayList<>();
|
|
|
|
|
List<BigDecimal> scores = new ArrayList<>();
|
|
|
|
|
List<String> dateList = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < scoreList.size(); i++) {
|
|
|
|
|
ScoreRank scoreRank = scoreList.get(i);
|
|
|
|
|
scores.add(scoreRank.getKhalScore());
|
|
|
|
@ -148,8 +150,8 @@ public class StatisticsController {
|
|
|
|
|
scoreRank.setClassName(className);
|
|
|
|
|
scoreRank.setSchoolId(schoolId);
|
|
|
|
|
List<TeaTrendVo> voList = scoreRankMapper.selectFiveAvgTotalScoreBySchoolIdAndClassName(scoreRank);
|
|
|
|
|
List<BigDecimal> classAverageScoreList=new ArrayList<>();
|
|
|
|
|
List<String> startTimeList=new ArrayList<>();
|
|
|
|
|
List<BigDecimal> classAverageScoreList = new ArrayList<>();
|
|
|
|
|
List<String> startTimeList = new ArrayList<>();
|
|
|
|
|
for (int j = 0; j < voList.size(); j++) {
|
|
|
|
|
TeaTrendVo teaTrendVo = voList.get(j);
|
|
|
|
|
classAverageScoreList.add(teaTrendVo.getAvgScore());
|
|
|
|
@ -182,52 +184,91 @@ public class StatisticsController {
|
|
|
|
|
formattedDate = sdf.format(time);
|
|
|
|
|
criteria.andClassIdEqualTo(classId).andUpdateDateEqualTo(formattedDate);
|
|
|
|
|
}
|
|
|
|
|
List<ScoreRank> scoreRankList = scoreRankMapper.selectByExample(scoreExample);
|
|
|
|
|
int excellentCount = 0;
|
|
|
|
|
int goodCount = 0;
|
|
|
|
|
int generalCount = 0;
|
|
|
|
|
int failCount = 0;
|
|
|
|
|
BigDecimal maxScore = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal minScore = BigDecimal.valueOf(1000);
|
|
|
|
|
BigDecimal avgScore = BigDecimal.ZERO;
|
|
|
|
|
for (int i = 0; i < scoreRankList.size(); i++) {
|
|
|
|
|
ScoreRank scoreRank = scoreRankList.get(i);
|
|
|
|
|
BigDecimal khalScore = scoreRank.getKhalScore();
|
|
|
|
|
if(khalScore==null){
|
|
|
|
|
khalScore=BigDecimal.ZERO;
|
|
|
|
|
}
|
|
|
|
|
if(khalScore.compareTo(maxScore)>0){ //设置最高分
|
|
|
|
|
maxScore=khalScore;
|
|
|
|
|
}
|
|
|
|
|
if(khalScore.compareTo(minScore)<0){ //设置最低分
|
|
|
|
|
minScore=khalScore;
|
|
|
|
|
}
|
|
|
|
|
avgScore=avgScore.add(khalScore);
|
|
|
|
|
if(khalScore.compareTo(BigDecimal.valueOf(90))>=0){ //设置优秀、良好、一般、不及格人数
|
|
|
|
|
excellentCount = excellentCount+1;
|
|
|
|
|
}else if(khalScore.compareTo(BigDecimal.valueOf(90))<0 && khalScore.compareTo(BigDecimal.valueOf(80))>=0){
|
|
|
|
|
goodCount= goodCount+1;
|
|
|
|
|
}else if(khalScore.compareTo(BigDecimal.valueOf(80))<0 && khalScore.compareTo(BigDecimal.valueOf(60))>=0){
|
|
|
|
|
generalCount=generalCount+1;
|
|
|
|
|
}else {
|
|
|
|
|
failCount = failCount +1;
|
|
|
|
|
}
|
|
|
|
|
List<ScoreRank> scoreRankList = scoreRankMapper.selectByExample(scoreExample);
|
|
|
|
|
int excellentCount = 0;
|
|
|
|
|
int goodCount = 0;
|
|
|
|
|
int generalCount = 0;
|
|
|
|
|
int failCount = 0;
|
|
|
|
|
BigDecimal maxScore = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal minScore = BigDecimal.valueOf(1000);
|
|
|
|
|
BigDecimal avgScore = BigDecimal.ZERO;
|
|
|
|
|
for (int i = 0; i < scoreRankList.size(); i++) {
|
|
|
|
|
ScoreRank scoreRank = scoreRankList.get(i);
|
|
|
|
|
BigDecimal khalScore = scoreRank.getKhalScore();
|
|
|
|
|
if (khalScore == null) {
|
|
|
|
|
khalScore = BigDecimal.ZERO;
|
|
|
|
|
}
|
|
|
|
|
if (khalScore.compareTo(maxScore) > 0) { //设置最高分
|
|
|
|
|
maxScore = khalScore;
|
|
|
|
|
}
|
|
|
|
|
if (khalScore.compareTo(minScore) < 0) { //设置最低分
|
|
|
|
|
minScore = khalScore;
|
|
|
|
|
}
|
|
|
|
|
avgScore = avgScore.add(khalScore);
|
|
|
|
|
if (khalScore.compareTo(BigDecimal.valueOf(90)) >= 0) { //设置优秀、良好、一般、不及格人数
|
|
|
|
|
excellentCount = excellentCount + 1;
|
|
|
|
|
} else if (khalScore.compareTo(BigDecimal.valueOf(90)) < 0 && khalScore.compareTo(BigDecimal.valueOf(80)) >= 0) {
|
|
|
|
|
goodCount = goodCount + 1;
|
|
|
|
|
} else if (khalScore.compareTo(BigDecimal.valueOf(80)) < 0 && khalScore.compareTo(BigDecimal.valueOf(60)) >= 0) {
|
|
|
|
|
generalCount = generalCount + 1;
|
|
|
|
|
} else {
|
|
|
|
|
failCount = failCount + 1;
|
|
|
|
|
}
|
|
|
|
|
if(!scoreRankList.isEmpty()){
|
|
|
|
|
avgScore = avgScore.divide(BigDecimal.valueOf(scoreRankList.size()), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
}
|
|
|
|
|
if (!scoreRankList.isEmpty()) {
|
|
|
|
|
avgScore = avgScore.divide(BigDecimal.valueOf(scoreRankList.size()), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
}
|
|
|
|
|
if (minScore.compareTo(BigDecimal.valueOf(1000)) == 0) {
|
|
|
|
|
minScore = BigDecimal.ZERO;
|
|
|
|
|
}
|
|
|
|
|
TeaClassScoreDto teaClassScoreDto = new TeaClassScoreDto();
|
|
|
|
|
teaClassScoreDto.setExcellentCount(excellentCount);
|
|
|
|
|
teaClassScoreDto.setGoodCount(goodCount);
|
|
|
|
|
teaClassScoreDto.setGeneralCount(generalCount);
|
|
|
|
|
teaClassScoreDto.setFailCount(failCount);
|
|
|
|
|
teaClassScoreDto.setMaxScore(maxScore);
|
|
|
|
|
teaClassScoreDto.setMinScore(minScore);
|
|
|
|
|
teaClassScoreDto.setAverageScore(avgScore);
|
|
|
|
|
teaClassScoreDto.setStartTime(formattedDate);
|
|
|
|
|
return teaClassScoreDto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@GetMapping("/getStuPieChart")
|
|
|
|
|
@ApiOperation("学生端 -我的成绩饼状图")
|
|
|
|
|
public Map<String,Integer> getStuPieChart(String schoolId) {
|
|
|
|
|
//根据schoolId查询当日scoreRank.totalScore 进行分类
|
|
|
|
|
Map<String,Integer> map=new HashMap<>();
|
|
|
|
|
map.put("great",0);
|
|
|
|
|
map.put("good",0);
|
|
|
|
|
map.put("poor",0);
|
|
|
|
|
ScoreRankExample scoreRankExample = new ScoreRankExample();
|
|
|
|
|
scoreRankExample.createCriteria().andSchoolIdEqualTo(schoolId).andUpdateDateEqualTo(getNowDate());
|
|
|
|
|
List<ScoreRank> scoreRankList = scoreRankMapper.selectByExample(scoreRankExample);
|
|
|
|
|
for (int i = 0; i < scoreRankList.size(); i++) {
|
|
|
|
|
if(scoreRankList.get(i).getTotalScore().compareTo(BigDecimal.valueOf(80))>=0){
|
|
|
|
|
Integer great = map.get("great");
|
|
|
|
|
map.put("great",great+1);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if(minScore.compareTo(BigDecimal.valueOf(1000))==0){
|
|
|
|
|
minScore=BigDecimal.ZERO;
|
|
|
|
|
if(scoreRankList.get(i).getTotalScore().compareTo(BigDecimal.valueOf(60))<0){
|
|
|
|
|
Integer poor = map.get("poor");
|
|
|
|
|
map.put("poor",poor+1);
|
|
|
|
|
continue;
|
|
|
|
|
}else {
|
|
|
|
|
Integer good = map.get("good");
|
|
|
|
|
map.put("good",good+1);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
TeaClassScoreDto teaClassScoreDto = new TeaClassScoreDto();
|
|
|
|
|
teaClassScoreDto.setExcellentCount(excellentCount);
|
|
|
|
|
teaClassScoreDto.setGoodCount(goodCount);
|
|
|
|
|
teaClassScoreDto.setGeneralCount(generalCount);
|
|
|
|
|
teaClassScoreDto.setFailCount(failCount);
|
|
|
|
|
teaClassScoreDto.setMaxScore(maxScore);
|
|
|
|
|
teaClassScoreDto.setMinScore(minScore);
|
|
|
|
|
teaClassScoreDto.setAverageScore(avgScore);
|
|
|
|
|
teaClassScoreDto.setStartTime(formattedDate);
|
|
|
|
|
return teaClassScoreDto;
|
|
|
|
|
}
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getNowDate() {
|
|
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
String nowDate = now.format(formatter);
|
|
|
|
|
return nowDate;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|