题库表和答题记录表新增选项字段
parent
8e18b9679d
commit
2d7aff5221
@ -0,0 +1,49 @@
|
||||
package com.sztzjy.fund_investment.controller.tea;
|
||||
|
||||
import com.sztzjy.fund_investment.annotation.AnonymousAccess;
|
||||
import com.sztzjy.fund_investment.entity.TeaClassScore;
|
||||
import com.sztzjy.fund_investment.entity.dto.TeaClassScoreDto;
|
||||
import com.sztzjy.fund_investment.service.tea.ClassScoreService;
|
||||
import com.sztzjy.fund_investment.util.ResultEntity;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.xml.crypto.Data;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author xcj
|
||||
* @Date 2023/11/24
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping
|
||||
@Api(tags = "老师端--成绩管理")
|
||||
public class ClassScoreController {
|
||||
|
||||
@Autowired
|
||||
private ClassScoreService classScoreService;
|
||||
|
||||
@ApiOperation("班级平均成绩折线图")
|
||||
@AnonymousAccess
|
||||
@GetMapping("/getClassAVGScore")
|
||||
public ResultEntity<List<TeaClassScore>> getClassAVGScore(@RequestParam String schoolId) {
|
||||
return new ResultEntity<>(classScoreService.getClassAVGScore(schoolId));
|
||||
}
|
||||
|
||||
@ApiOperation("班级成绩统计分析饼状图")
|
||||
@AnonymousAccess
|
||||
@GetMapping("/getClassScoreCount")
|
||||
public ResultEntity<TeaClassScoreDto> getClassAVGScore(@ApiParam("班级框为空时传") @RequestParam(required = false) String schoolId,
|
||||
@ApiParam("班级框不为空时传") @RequestParam(required = false) String classId,
|
||||
@ApiParam("年月日格式/yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd") @RequestParam Date time) {
|
||||
return new ResultEntity<>(classScoreService.getClassScoreCount(schoolId, classId, time));
|
||||
}
|
||||
}
|
@ -0,0 +1,220 @@
|
||||
package com.sztzjy.fund_investment.entity.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author xcj
|
||||
* tea_class_score
|
||||
*/
|
||||
public class TeaClassScoreDto {
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("学校ID")
|
||||
private String schoolId;
|
||||
|
||||
@ApiModelProperty("班级ID")
|
||||
private String classId;
|
||||
|
||||
@ApiModelProperty("班级名称")
|
||||
private String className;
|
||||
|
||||
@ApiModelProperty("优秀人数")
|
||||
private Integer excellentCount;
|
||||
|
||||
@ApiModelProperty("良好人数")
|
||||
private Integer goodCount;
|
||||
|
||||
@ApiModelProperty("一般人数")
|
||||
private Integer generalCount;
|
||||
|
||||
@ApiModelProperty("不及格人数")
|
||||
private Integer failCount;
|
||||
|
||||
@ApiModelProperty("班级最高分")
|
||||
private BigDecimal classMaxScore;
|
||||
|
||||
@ApiModelProperty("班级最低分")
|
||||
private BigDecimal classMinScore;
|
||||
|
||||
@ApiModelProperty("班级平均分")
|
||||
private BigDecimal classAverageScore;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
|
||||
@ApiModelProperty("得分日期")
|
||||
private Date startTime;
|
||||
|
||||
|
||||
@ApiModelProperty("学校优秀人数")
|
||||
private Integer schoolExcellentCount;
|
||||
@ApiModelProperty("学校良好人数")
|
||||
private Integer schoolGoodCount;
|
||||
@ApiModelProperty("学校一般人数")
|
||||
private Integer schoolGeneralCount;
|
||||
@ApiModelProperty("学校不及格人数")
|
||||
private Integer schoolFailCount;
|
||||
@ApiModelProperty("学校班级最高分")
|
||||
private BigDecimal schoolMaxScore;
|
||||
@ApiModelProperty("学校班级最低分")
|
||||
private BigDecimal schoolMinScore;
|
||||
@ApiModelProperty("学校班级平均分")
|
||||
private BigDecimal schoolAverageScore;
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSchoolId() {
|
||||
return schoolId;
|
||||
}
|
||||
|
||||
public void setSchoolId(String schoolId) {
|
||||
this.schoolId = schoolId;
|
||||
}
|
||||
|
||||
public String getClassId() {
|
||||
return classId;
|
||||
}
|
||||
|
||||
public void setClassId(String classId) {
|
||||
this.classId = classId;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public void setClassName(String className) {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
public Integer getExcellentCount() {
|
||||
return excellentCount;
|
||||
}
|
||||
|
||||
public void setExcellentCount(Integer excellentCount) {
|
||||
this.excellentCount = excellentCount;
|
||||
}
|
||||
|
||||
public Integer getGoodCount() {
|
||||
return goodCount;
|
||||
}
|
||||
|
||||
public void setGoodCount(Integer goodCount) {
|
||||
this.goodCount = goodCount;
|
||||
}
|
||||
|
||||
public Integer getGeneralCount() {
|
||||
return generalCount;
|
||||
}
|
||||
|
||||
public void setGeneralCount(Integer generalCount) {
|
||||
this.generalCount = generalCount;
|
||||
}
|
||||
|
||||
public Integer getFailCount() {
|
||||
return failCount;
|
||||
}
|
||||
|
||||
public void setFailCount(Integer failCount) {
|
||||
this.failCount = failCount;
|
||||
}
|
||||
|
||||
public BigDecimal getClassMaxScore() {
|
||||
return classMaxScore;
|
||||
}
|
||||
|
||||
public void setClassMaxScore(BigDecimal classMaxScore) {
|
||||
this.classMaxScore = classMaxScore;
|
||||
}
|
||||
|
||||
public BigDecimal getClassMinScore() {
|
||||
return classMinScore;
|
||||
}
|
||||
|
||||
public void setClassMinScore(BigDecimal classMinScore) {
|
||||
this.classMinScore = classMinScore;
|
||||
}
|
||||
|
||||
public BigDecimal getClassAverageScore() {
|
||||
return classAverageScore;
|
||||
}
|
||||
|
||||
public void setClassAverageScore(BigDecimal classAverageScore) {
|
||||
this.classAverageScore = classAverageScore;
|
||||
}
|
||||
|
||||
public Date getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Date startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Integer getSchoolExcellentCount() {
|
||||
return schoolExcellentCount;
|
||||
}
|
||||
|
||||
public void setSchoolExcellentCount(Integer schoolExcellentCount) {
|
||||
this.schoolExcellentCount = schoolExcellentCount;
|
||||
}
|
||||
|
||||
public Integer getSchoolGoodCount() {
|
||||
return schoolGoodCount;
|
||||
}
|
||||
|
||||
public void setSchoolGoodCount(Integer schoolGoodCount) {
|
||||
this.schoolGoodCount = schoolGoodCount;
|
||||
}
|
||||
|
||||
public Integer getSchoolGeneralCount() {
|
||||
return schoolGeneralCount;
|
||||
}
|
||||
|
||||
public void setSchoolGeneralCount(Integer schoolGeneralCount) {
|
||||
this.schoolGeneralCount = schoolGeneralCount;
|
||||
}
|
||||
|
||||
public Integer getSchoolFailCount() {
|
||||
return schoolFailCount;
|
||||
}
|
||||
|
||||
public void setSchoolFailCount(Integer schoolFailCount) {
|
||||
this.schoolFailCount = schoolFailCount;
|
||||
}
|
||||
|
||||
public BigDecimal getSchoolMaxScore() {
|
||||
return schoolMaxScore;
|
||||
}
|
||||
|
||||
public void setSchoolMaxScore(BigDecimal schoolMaxScore) {
|
||||
this.schoolMaxScore = schoolMaxScore;
|
||||
}
|
||||
|
||||
public BigDecimal getSchoolMinScore() {
|
||||
return schoolMinScore;
|
||||
}
|
||||
|
||||
public void setSchoolMinScore(BigDecimal schoolMinScore) {
|
||||
this.schoolMinScore = schoolMinScore;
|
||||
}
|
||||
|
||||
public BigDecimal getSchoolAverageScore() {
|
||||
return schoolAverageScore;
|
||||
}
|
||||
|
||||
public void setSchoolAverageScore(BigDecimal schoolAverageScore) {
|
||||
this.schoolAverageScore = schoolAverageScore;
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package com.sztzjy.fund_investment.service.serviceImpl.tea;
|
||||
|
||||
import com.sztzjy.fund_investment.entity.TeaClassScore;
|
||||
import com.sztzjy.fund_investment.entity.TeaClassScoreExample;
|
||||
import com.sztzjy.fund_investment.entity.dto.TeaClassScoreDto;
|
||||
import com.sztzjy.fund_investment.mapper.TeaClassScoreMapper;
|
||||
import com.sztzjy.fund_investment.service.tea.ClassScoreService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author xcj
|
||||
* @Date 2023/11/24
|
||||
*/
|
||||
@Service
|
||||
public class ClassScoreServiceImpl implements ClassScoreService {
|
||||
@Autowired
|
||||
private TeaClassScoreMapper teaClassScoreMapper;
|
||||
|
||||
/*
|
||||
* @author xcj
|
||||
* @Date 2023/11/24
|
||||
*/
|
||||
@Override
|
||||
public List<TeaClassScore> getClassAVGScore(String schoolId) {
|
||||
return teaClassScoreMapper.selectAndOrderByTime(schoolId);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @author xcj
|
||||
* @Date 2023/11/24
|
||||
*/
|
||||
@Override
|
||||
public TeaClassScoreDto getClassScoreCount(String schoolId, String classId, Date time) {
|
||||
TeaClassScoreExample teaClassScoreExample = new TeaClassScoreExample();
|
||||
TeaClassScoreExample.Criteria criteria = teaClassScoreExample.createCriteria();
|
||||
//班级框为空 统计学校下的所有数据返回
|
||||
if (classId == null && schoolId != null) {
|
||||
criteria.andSchoolIdEqualTo(schoolId).andStartTimeEqualTo(time);
|
||||
List<TeaClassScore> teaClassScores = teaClassScoreMapper.selectByExample(teaClassScoreExample);
|
||||
int schoolExcellentCount = 0;
|
||||
int schoolGoodCount = 0;
|
||||
int schoolGeneralCount = 0;
|
||||
int schoolFailCount = 0;
|
||||
BigDecimal maxScoreBySchoolId = BigDecimal.ZERO;
|
||||
BigDecimal minScoreBySchoolId = null;
|
||||
BigDecimal avgScoreBySchoolId = BigDecimal.ZERO;
|
||||
for (TeaClassScore teaClassScore : teaClassScores) {
|
||||
schoolExcellentCount = schoolExcellentCount + teaClassScore.getExcellentCount();
|
||||
schoolGoodCount = schoolGoodCount + teaClassScore.getGoodCount();
|
||||
schoolGeneralCount = schoolGeneralCount + teaClassScore.getGeneralCount();
|
||||
schoolFailCount = schoolFailCount + teaClassScore.getFailCount();
|
||||
|
||||
BigDecimal maxScore = teaClassScore.getClassMaxScore();
|
||||
BigDecimal minScore = teaClassScore.getClassMinScore();
|
||||
// 计算最高分
|
||||
if (maxScore.compareTo(maxScoreBySchoolId) >= 0) {
|
||||
maxScoreBySchoolId = maxScore;
|
||||
}
|
||||
// 计算最低分
|
||||
if (minScoreBySchoolId == null || minScore.compareTo(minScoreBySchoolId) <= 0) {
|
||||
minScoreBySchoolId = minScore;
|
||||
}
|
||||
//所有班级平均分累加
|
||||
avgScoreBySchoolId = avgScoreBySchoolId.add(teaClassScore.getClassAverageScore()).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
TeaClassScoreDto teaClassScoreDto = new TeaClassScoreDto();
|
||||
teaClassScoreDto.setSchoolExcellentCount(schoolExcellentCount);
|
||||
teaClassScoreDto.setSchoolGoodCount(schoolGoodCount);
|
||||
teaClassScoreDto.setSchoolGeneralCount(schoolGeneralCount);
|
||||
teaClassScoreDto.setSchoolFailCount(schoolFailCount);
|
||||
BigDecimal finalAVGScore = avgScoreBySchoolId.divide(BigDecimal.valueOf(teaClassScores.size()), 2, RoundingMode.HALF_UP);
|
||||
teaClassScoreDto.setClassAverageScore(finalAVGScore);
|
||||
return teaClassScoreDto;
|
||||
} else { //选中某个班级返回
|
||||
criteria.andClassIdEqualTo(classId).andStartTimeEqualTo(time);
|
||||
List<TeaClassScore> teaClassScores = teaClassScoreMapper.selectByExample(teaClassScoreExample);
|
||||
TeaClassScore teaClassScore = teaClassScores.get(0);
|
||||
TeaClassScoreDto teaClassScoreDto = new TeaClassScoreDto();
|
||||
BeanUtils.copyProperties(teaClassScore,teaClassScoreDto);
|
||||
return teaClassScoreDto;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.sztzjy.fund_investment.service.tea;
|
||||
|
||||
import com.sztzjy.fund_investment.entity.TeaClassScore;
|
||||
import com.sztzjy.fund_investment.entity.dto.TeaClassScoreDto;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author xcj
|
||||
* @Date 2023/11/24
|
||||
*/
|
||||
public interface ClassScoreService {
|
||||
List<TeaClassScore> getClassAVGScore(String schoolId);
|
||||
|
||||
TeaClassScoreDto getClassScoreCount(String schoolId, String classId, Date time);
|
||||
}
|
Loading…
Reference in New Issue