开发班级下拉框

de'v
whb 11 months ago
parent ea666be9a8
commit 73ad74714a

@ -26,13 +26,17 @@ import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -51,47 +55,97 @@ public class StuTaskController {
private StuScoreCenterMapper scoreCenterMapper;
// @Scheduled(cron = "*/30 * * * * *")
@Scheduled(cron ="0 0 0 * * ?")
public void updateUserRank(){
log.info("定时任务:==================计算班级平均分======================");
//获取今天所有成绩
StuUserExample userExample = new StuUserExample();
userExample.createCriteria().getAllCriteria();
List<StuUser> stuUsersList = userMapper.selectByExample(userExample);
//根据学校ID查询所有的班级列表 class_name
List<String> classNameList = stuUsersList.stream().map(StuUser::getClassName).distinct().collect(Collectors.toList());
for (String className : classNameList) {
StuUserExample userExample1 = new StuUserExample();
userExample1.createCriteria().andClassNameEqualTo(className);
//获取该班所有学生
List<StuUser> userListByClassName = userMapper.selectByExample(userExample1);
//汇总总分
List<BigDecimal> totalScoreByClassName = userListByClassName.stream().map(StuUser::getTotalScore).collect(Collectors.toList());
//求和
BigDecimal sum = totalScoreByClassName.stream()
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 计算每天每个班级的平均成绩 每天00.00执行
@Scheduled(cron = "0 0 0 * * ?")
public void getClassScore() {
//该班级平均分
BigDecimal divide = sum.divide(BigDecimal.valueOf(userListByClassName.size()), 2, BigDecimal.ROUND_HALF_UP);
log.info("定时任务:==================计算班级平均分======================");
// 算平均值,存表
//查出所有数据
List<String> classIdList = userMapper.selectClassId();
for (String classId : classIdList) {
BigDecimal avgScore = BigDecimal.ZERO;
BigDecimal count = BigDecimal.ZERO;
StuUserExample userExample = new StuUserExample();
userExample.createCriteria().andClassIdEqualTo(classId);
List<StuUser> stuUsersList = userMapper.selectByExample(userExample);
// 创建存储等级人数的Map
Map<String, Integer> gradeCounts = new HashMap<>();
gradeCounts.put("excellent", 0);
gradeCounts.put("good", 0);
gradeCounts.put("general", 0);
gradeCounts.put("fail", 0);
BigDecimal classMaxScore = BigDecimal.ZERO; // 最高分默认为0
BigDecimal classMinScore = null; // 最低分默认为null
String schoolId = "";
for (StuUser score : stuUsersList) {
//第一个比较对象
BigDecimal totalScore = score.getTotalScore();
if (totalScore == null) {
totalScore = BigDecimal.ZERO;
}
schoolId = score.getSchoolId();
// 计算最高分
if (totalScore.compareTo(classMaxScore) >= 0) {
classMaxScore = totalScore;
}
// 计算最低分
if (classMinScore == null || totalScore.compareTo(classMinScore) <= 0) {
classMinScore = totalScore;
}
count = count.add(BigDecimal.ONE);
avgScore = avgScore.add(totalScore);
// 计算等级人数
if (totalScore.compareTo(BigDecimal.valueOf(90)) >= 0 && totalScore.compareTo(BigDecimal.valueOf(100)) <= 0) {
gradeCounts.put("excellent", gradeCounts.get("excellent") + 1);
} else if (totalScore.compareTo(BigDecimal.valueOf(80)) >= 0 && totalScore.compareTo(BigDecimal.valueOf(89)) <= 0) {
gradeCounts.put("good", gradeCounts.get("good") + 1);
} else if (totalScore.compareTo(BigDecimal.valueOf(60)) >= 0 && totalScore.compareTo(BigDecimal.valueOf(79)) <= 0) {
gradeCounts.put("general", gradeCounts.get("general") + 1);
} else if (totalScore.compareTo(BigDecimal.valueOf(0)) >= 0 && totalScore.compareTo(BigDecimal.valueOf(59)) <= 0) {
gradeCounts.put("fail", gradeCounts.get("fail") + 1);
}
}
TchClassAverageScore tchClassAverageScore= new TchClassAverageScore();
tchClassAverageScore.setAveScore(divide.doubleValue());
tchClassAverageScore.setClassName(className);
tchClassAverageScore.setCreateTime(new Date());
tchClassAverageScore.setId(String.valueOf(IdUtil.getSnowflakeNextId()));
tchClassAverageScoreMapper.insertSelective(tchClassAverageScore);
//时间为年月日
LocalDate currentDate = LocalDate.now();
Date date = Date.from(currentDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
tchClassAverageScore.setSchoolId(schoolId);
tchClassAverageScore.setCreateTime(date);
tchClassAverageScore.setId(IdUtil.simpleUUID());
tchClassAverageScore.setClassMaxScore(classMaxScore);
tchClassAverageScore.setClassMinScore(classMinScore);
tchClassAverageScore.setExcellentCount(gradeCounts.get("excellent"));
tchClassAverageScore.setGoodCount(gradeCounts.get("good"));
tchClassAverageScore.setGeneralCount(gradeCounts.get("general"));
tchClassAverageScore.setFailCount(gradeCounts.get("fail"));
tchClassAverageScore.setClassId(classId);
StuUserExample stuUserExample1 = new StuUserExample();
stuUserExample1.createCriteria().andSchoolIdEqualTo(schoolId).andClassIdEqualTo(classId);
List<StuUser> userTables = userMapper.selectByExample(stuUserExample1);
StuUser userTable = userTables.get(0);
tchClassAverageScore.setClassName(userTable.getClassName());
if (count.compareTo(BigDecimal.ZERO) == 0) {
tchClassAverageScore.setClassAverageScore(BigDecimal.ZERO);
} else {
BigDecimal divideScore = avgScore.divide(count, 2, RoundingMode.HALF_UP);
tchClassAverageScore.setClassAverageScore(divideScore);
}
tchClassAverageScoreMapper.insert(tchClassAverageScore);
}
log.info("定时任务:==================执行结束======================");
}

@ -1,20 +1,28 @@
package com.sztzjy.digital_credit.controller.tch;
import com.sztzjy.digital_credit.annotation.AnonymousAccess;
import com.sztzjy.digital_credit.entity.dto.ClassAVGScoreVo;
import com.sztzjy.digital_credit.entity.dto.TchAvgScoreByTimeDTO;
import com.sztzjy.digital_credit.entity.dto.TchAvgScoreByTimeParentDTO;
import com.sztzjy.digital_credit.entity.dto.TeaClassScoreDto;
import com.sztzjy.digital_credit.mapper.StuUserMapper;
import com.sztzjy.digital_credit.service.TchHomePageService;
import com.sztzjy.digital_credit.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.http.HttpStatus;
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 java.time.LocalDate;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @author 17803
@ -29,17 +37,42 @@ public class TchHomePageController {
@Autowired
private TchHomePageService tchHomePageService;
@Autowired
private StuUserMapper userMapper;
@ApiOperation("班级平均成绩走势图")
@GetMapping("avgScoreTrendChart")
@AnonymousAccess
public ResultEntity<List<TchAvgScoreByTimeParentDTO>> avgScoreTrendChart(String schoolId){
public ResultEntity<List<ClassAVGScoreVo>> avgScoreTrendChart(String schoolId){
List<ClassAVGScoreVo> info = tchHomePageService.avgScoreTrendChart(schoolId);
return new ResultEntity<>(info);
}
return tchHomePageService.avgScoreTrendChart(schoolId);
@AnonymousAccess
@GetMapping("/getClassScoreCount")
@ApiOperation("班级成绩统计分析饼状图")
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<>(tchHomePageService.getClassScoreCount(schoolId, classId, time));
}
@AnonymousAccess
@GetMapping("/getClassNameBySchoolId")
@ApiOperation("班级下拉框")
public ResultEntity<List<Map<String, String>>> getClassNameBySchoolId(@RequestParam String schoolId) {
List<Map<String, String>> nameAndId = userMapper.selectClassNameBySchoolId(schoolId);
return new ResultEntity<>(nameAndId);
}
}

@ -1,11 +1,9 @@
package com.sztzjy.digital_credit.entity;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.format.annotation.DateTimeFormat;
/**
*
* @author whb
@ -21,14 +19,36 @@ public class TchClassAverageScore {
@ApiModelProperty("班级名称")
private String className;
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("平均分")
private Double aveScore;
@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;
@ApiModelProperty("学校ID")
private String schoolId;
public String getId() {
return id;
}
@ -68,4 +88,68 @@ public class TchClassAverageScore {
public void setAveScore(Double aveScore) {
this.aveScore = aveScore;
}
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 String getSchoolId() {
return schoolId;
}
public void setSchoolId(String schoolId) {
this.schoolId = schoolId == null ? null : schoolId.trim();
}
}

@ -1,5 +1,6 @@
package com.sztzjy.digital_credit.entity;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -434,6 +435,496 @@ public class TchClassAverageScoreExample {
addCriterion("ave_score not between", value1, value2, "aveScore");
return (Criteria) this;
}
public Criteria andExcellentCountIsNull() {
addCriterion("excellent_count is null");
return (Criteria) this;
}
public Criteria andExcellentCountIsNotNull() {
addCriterion("excellent_count is not null");
return (Criteria) this;
}
public Criteria andExcellentCountEqualTo(Integer value) {
addCriterion("excellent_count =", value, "excellentCount");
return (Criteria) this;
}
public Criteria andExcellentCountNotEqualTo(Integer value) {
addCriterion("excellent_count <>", value, "excellentCount");
return (Criteria) this;
}
public Criteria andExcellentCountGreaterThan(Integer value) {
addCriterion("excellent_count >", value, "excellentCount");
return (Criteria) this;
}
public Criteria andExcellentCountGreaterThanOrEqualTo(Integer value) {
addCriterion("excellent_count >=", value, "excellentCount");
return (Criteria) this;
}
public Criteria andExcellentCountLessThan(Integer value) {
addCriterion("excellent_count <", value, "excellentCount");
return (Criteria) this;
}
public Criteria andExcellentCountLessThanOrEqualTo(Integer value) {
addCriterion("excellent_count <=", value, "excellentCount");
return (Criteria) this;
}
public Criteria andExcellentCountIn(List<Integer> values) {
addCriterion("excellent_count in", values, "excellentCount");
return (Criteria) this;
}
public Criteria andExcellentCountNotIn(List<Integer> values) {
addCriterion("excellent_count not in", values, "excellentCount");
return (Criteria) this;
}
public Criteria andExcellentCountBetween(Integer value1, Integer value2) {
addCriterion("excellent_count between", value1, value2, "excellentCount");
return (Criteria) this;
}
public Criteria andExcellentCountNotBetween(Integer value1, Integer value2) {
addCriterion("excellent_count not between", value1, value2, "excellentCount");
return (Criteria) this;
}
public Criteria andGoodCountIsNull() {
addCriterion("good_count is null");
return (Criteria) this;
}
public Criteria andGoodCountIsNotNull() {
addCriterion("good_count is not null");
return (Criteria) this;
}
public Criteria andGoodCountEqualTo(Integer value) {
addCriterion("good_count =", value, "goodCount");
return (Criteria) this;
}
public Criteria andGoodCountNotEqualTo(Integer value) {
addCriterion("good_count <>", value, "goodCount");
return (Criteria) this;
}
public Criteria andGoodCountGreaterThan(Integer value) {
addCriterion("good_count >", value, "goodCount");
return (Criteria) this;
}
public Criteria andGoodCountGreaterThanOrEqualTo(Integer value) {
addCriterion("good_count >=", value, "goodCount");
return (Criteria) this;
}
public Criteria andGoodCountLessThan(Integer value) {
addCriterion("good_count <", value, "goodCount");
return (Criteria) this;
}
public Criteria andGoodCountLessThanOrEqualTo(Integer value) {
addCriterion("good_count <=", value, "goodCount");
return (Criteria) this;
}
public Criteria andGoodCountIn(List<Integer> values) {
addCriterion("good_count in", values, "goodCount");
return (Criteria) this;
}
public Criteria andGoodCountNotIn(List<Integer> values) {
addCriterion("good_count not in", values, "goodCount");
return (Criteria) this;
}
public Criteria andGoodCountBetween(Integer value1, Integer value2) {
addCriterion("good_count between", value1, value2, "goodCount");
return (Criteria) this;
}
public Criteria andGoodCountNotBetween(Integer value1, Integer value2) {
addCriterion("good_count not between", value1, value2, "goodCount");
return (Criteria) this;
}
public Criteria andGeneralCountIsNull() {
addCriterion("general_count is null");
return (Criteria) this;
}
public Criteria andGeneralCountIsNotNull() {
addCriterion("general_count is not null");
return (Criteria) this;
}
public Criteria andGeneralCountEqualTo(Integer value) {
addCriterion("general_count =", value, "generalCount");
return (Criteria) this;
}
public Criteria andGeneralCountNotEqualTo(Integer value) {
addCriterion("general_count <>", value, "generalCount");
return (Criteria) this;
}
public Criteria andGeneralCountGreaterThan(Integer value) {
addCriterion("general_count >", value, "generalCount");
return (Criteria) this;
}
public Criteria andGeneralCountGreaterThanOrEqualTo(Integer value) {
addCriterion("general_count >=", value, "generalCount");
return (Criteria) this;
}
public Criteria andGeneralCountLessThan(Integer value) {
addCriterion("general_count <", value, "generalCount");
return (Criteria) this;
}
public Criteria andGeneralCountLessThanOrEqualTo(Integer value) {
addCriterion("general_count <=", value, "generalCount");
return (Criteria) this;
}
public Criteria andGeneralCountIn(List<Integer> values) {
addCriterion("general_count in", values, "generalCount");
return (Criteria) this;
}
public Criteria andGeneralCountNotIn(List<Integer> values) {
addCriterion("general_count not in", values, "generalCount");
return (Criteria) this;
}
public Criteria andGeneralCountBetween(Integer value1, Integer value2) {
addCriterion("general_count between", value1, value2, "generalCount");
return (Criteria) this;
}
public Criteria andGeneralCountNotBetween(Integer value1, Integer value2) {
addCriterion("general_count not between", value1, value2, "generalCount");
return (Criteria) this;
}
public Criteria andFailCountIsNull() {
addCriterion("fail_count is null");
return (Criteria) this;
}
public Criteria andFailCountIsNotNull() {
addCriterion("fail_count is not null");
return (Criteria) this;
}
public Criteria andFailCountEqualTo(Integer value) {
addCriterion("fail_count =", value, "failCount");
return (Criteria) this;
}
public Criteria andFailCountNotEqualTo(Integer value) {
addCriterion("fail_count <>", value, "failCount");
return (Criteria) this;
}
public Criteria andFailCountGreaterThan(Integer value) {
addCriterion("fail_count >", value, "failCount");
return (Criteria) this;
}
public Criteria andFailCountGreaterThanOrEqualTo(Integer value) {
addCriterion("fail_count >=", value, "failCount");
return (Criteria) this;
}
public Criteria andFailCountLessThan(Integer value) {
addCriterion("fail_count <", value, "failCount");
return (Criteria) this;
}
public Criteria andFailCountLessThanOrEqualTo(Integer value) {
addCriterion("fail_count <=", value, "failCount");
return (Criteria) this;
}
public Criteria andFailCountIn(List<Integer> values) {
addCriterion("fail_count in", values, "failCount");
return (Criteria) this;
}
public Criteria andFailCountNotIn(List<Integer> values) {
addCriterion("fail_count not in", values, "failCount");
return (Criteria) this;
}
public Criteria andFailCountBetween(Integer value1, Integer value2) {
addCriterion("fail_count between", value1, value2, "failCount");
return (Criteria) this;
}
public Criteria andFailCountNotBetween(Integer value1, Integer value2) {
addCriterion("fail_count not between", value1, value2, "failCount");
return (Criteria) this;
}
public Criteria andClassMaxScoreIsNull() {
addCriterion("class_max_score is null");
return (Criteria) this;
}
public Criteria andClassMaxScoreIsNotNull() {
addCriterion("class_max_score is not null");
return (Criteria) this;
}
public Criteria andClassMaxScoreEqualTo(BigDecimal value) {
addCriterion("class_max_score =", value, "classMaxScore");
return (Criteria) this;
}
public Criteria andClassMaxScoreNotEqualTo(BigDecimal value) {
addCriterion("class_max_score <>", value, "classMaxScore");
return (Criteria) this;
}
public Criteria andClassMaxScoreGreaterThan(BigDecimal value) {
addCriterion("class_max_score >", value, "classMaxScore");
return (Criteria) this;
}
public Criteria andClassMaxScoreGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("class_max_score >=", value, "classMaxScore");
return (Criteria) this;
}
public Criteria andClassMaxScoreLessThan(BigDecimal value) {
addCriterion("class_max_score <", value, "classMaxScore");
return (Criteria) this;
}
public Criteria andClassMaxScoreLessThanOrEqualTo(BigDecimal value) {
addCriterion("class_max_score <=", value, "classMaxScore");
return (Criteria) this;
}
public Criteria andClassMaxScoreIn(List<BigDecimal> values) {
addCriterion("class_max_score in", values, "classMaxScore");
return (Criteria) this;
}
public Criteria andClassMaxScoreNotIn(List<BigDecimal> values) {
addCriterion("class_max_score not in", values, "classMaxScore");
return (Criteria) this;
}
public Criteria andClassMaxScoreBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("class_max_score between", value1, value2, "classMaxScore");
return (Criteria) this;
}
public Criteria andClassMaxScoreNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("class_max_score not between", value1, value2, "classMaxScore");
return (Criteria) this;
}
public Criteria andClassMinScoreIsNull() {
addCriterion("class_min_score is null");
return (Criteria) this;
}
public Criteria andClassMinScoreIsNotNull() {
addCriterion("class_min_score is not null");
return (Criteria) this;
}
public Criteria andClassMinScoreEqualTo(BigDecimal value) {
addCriterion("class_min_score =", value, "classMinScore");
return (Criteria) this;
}
public Criteria andClassMinScoreNotEqualTo(BigDecimal value) {
addCriterion("class_min_score <>", value, "classMinScore");
return (Criteria) this;
}
public Criteria andClassMinScoreGreaterThan(BigDecimal value) {
addCriterion("class_min_score >", value, "classMinScore");
return (Criteria) this;
}
public Criteria andClassMinScoreGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("class_min_score >=", value, "classMinScore");
return (Criteria) this;
}
public Criteria andClassMinScoreLessThan(BigDecimal value) {
addCriterion("class_min_score <", value, "classMinScore");
return (Criteria) this;
}
public Criteria andClassMinScoreLessThanOrEqualTo(BigDecimal value) {
addCriterion("class_min_score <=", value, "classMinScore");
return (Criteria) this;
}
public Criteria andClassMinScoreIn(List<BigDecimal> values) {
addCriterion("class_min_score in", values, "classMinScore");
return (Criteria) this;
}
public Criteria andClassMinScoreNotIn(List<BigDecimal> values) {
addCriterion("class_min_score not in", values, "classMinScore");
return (Criteria) this;
}
public Criteria andClassMinScoreBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("class_min_score between", value1, value2, "classMinScore");
return (Criteria) this;
}
public Criteria andClassMinScoreNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("class_min_score not between", value1, value2, "classMinScore");
return (Criteria) this;
}
public Criteria andClassAverageScoreIsNull() {
addCriterion("class_average_score is null");
return (Criteria) this;
}
public Criteria andClassAverageScoreIsNotNull() {
addCriterion("class_average_score is not null");
return (Criteria) this;
}
public Criteria andClassAverageScoreEqualTo(BigDecimal value) {
addCriterion("class_average_score =", value, "classAverageScore");
return (Criteria) this;
}
public Criteria andClassAverageScoreNotEqualTo(BigDecimal value) {
addCriterion("class_average_score <>", value, "classAverageScore");
return (Criteria) this;
}
public Criteria andClassAverageScoreGreaterThan(BigDecimal value) {
addCriterion("class_average_score >", value, "classAverageScore");
return (Criteria) this;
}
public Criteria andClassAverageScoreGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("class_average_score >=", value, "classAverageScore");
return (Criteria) this;
}
public Criteria andClassAverageScoreLessThan(BigDecimal value) {
addCriterion("class_average_score <", value, "classAverageScore");
return (Criteria) this;
}
public Criteria andClassAverageScoreLessThanOrEqualTo(BigDecimal value) {
addCriterion("class_average_score <=", value, "classAverageScore");
return (Criteria) this;
}
public Criteria andClassAverageScoreIn(List<BigDecimal> values) {
addCriterion("class_average_score in", values, "classAverageScore");
return (Criteria) this;
}
public Criteria andClassAverageScoreNotIn(List<BigDecimal> values) {
addCriterion("class_average_score not in", values, "classAverageScore");
return (Criteria) this;
}
public Criteria andClassAverageScoreBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("class_average_score between", value1, value2, "classAverageScore");
return (Criteria) this;
}
public Criteria andClassAverageScoreNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("class_average_score not between", value1, value2, "classAverageScore");
return (Criteria) this;
}
public Criteria andSchoolIdIsNull() {
addCriterion("school_id is null");
return (Criteria) this;
}
public Criteria andSchoolIdIsNotNull() {
addCriterion("school_id is not null");
return (Criteria) this;
}
public Criteria andSchoolIdEqualTo(String value) {
addCriterion("school_id =", value, "schoolId");
return (Criteria) this;
}
public Criteria andSchoolIdNotEqualTo(String value) {
addCriterion("school_id <>", value, "schoolId");
return (Criteria) this;
}
public Criteria andSchoolIdGreaterThan(String value) {
addCriterion("school_id >", value, "schoolId");
return (Criteria) this;
}
public Criteria andSchoolIdGreaterThanOrEqualTo(String value) {
addCriterion("school_id >=", value, "schoolId");
return (Criteria) this;
}
public Criteria andSchoolIdLessThan(String value) {
addCriterion("school_id <", value, "schoolId");
return (Criteria) this;
}
public Criteria andSchoolIdLessThanOrEqualTo(String value) {
addCriterion("school_id <=", value, "schoolId");
return (Criteria) this;
}
public Criteria andSchoolIdLike(String value) {
addCriterion("school_id like", value, "schoolId");
return (Criteria) this;
}
public Criteria andSchoolIdNotLike(String value) {
addCriterion("school_id not like", value, "schoolId");
return (Criteria) this;
}
public Criteria andSchoolIdIn(List<String> values) {
addCriterion("school_id in", values, "schoolId");
return (Criteria) this;
}
public Criteria andSchoolIdNotIn(List<String> values) {
addCriterion("school_id not in", values, "schoolId");
return (Criteria) this;
}
public Criteria andSchoolIdBetween(String value1, String value2) {
addCriterion("school_id between", value1, value2, "schoolId");
return (Criteria) this;
}
public Criteria andSchoolIdNotBetween(String value1, String value2) {
addCriterion("school_id not between", value1, value2, "schoolId");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

@ -0,0 +1,25 @@
package com.sztzjy.digital_credit.entity.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@Data
public class ClassAVGScoreVo {
@ApiModelProperty("班级名称")
private String className;
@ApiModelProperty("班级平均分")
private List<BigDecimal> classAverageScore;
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ApiModelProperty("最早得分日期")
private List<Date> startTime;
}

@ -0,0 +1,217 @@
package com.sztzjy.digital_credit.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;
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;
}
}

@ -4,6 +4,7 @@ import com.sztzjy.digital_credit.entity.StuScoreCenter;
import com.sztzjy.digital_credit.entity.StuScoreCenterExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
public interface StuScoreCenterMapper {
long countByExample(StuScoreCenterExample example);

@ -3,7 +3,10 @@ package com.sztzjy.digital_credit.mapper;
import com.sztzjy.digital_credit.entity.StuUser;
import com.sztzjy.digital_credit.entity.StuUserExample;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
public interface StuUserMapper {
long countByExample(StuUserExample example);
@ -28,5 +31,9 @@ public interface StuUserMapper {
int updateByPrimaryKey(StuUser record);
@Select("select class_id from stu_user group By class_id")
List<String> selectClassId();
@Select("select distinct(class_id),class_name from stu_user where school_id = #{schoolId}")
List<Map<String,String>> selectClassNameBySchoolId(@Param("schoolId") String schoolId);
}

@ -30,5 +30,10 @@ public interface TchClassAverageScoreMapper {
int updateByPrimaryKey(TchClassAverageScore record);
//根据时间排序
List<TchClassAverageScore> selectByTime(@Param("className") String className);
// List<TchClassAverageScore> selectByTime(@Param("className") String className);
@Select("select class_name from tch_class_average_score where school_id = #{schoolId} group by class_name")
List<String> selectClassNameBySchool(@Param("schoolId")String schoolId);
List<TchClassAverageScore> selectAndOrderByTime(@Param("schoolId")String schoolId,@Param("className")String className);
}

@ -1,9 +1,12 @@
package com.sztzjy.digital_credit.service;
import com.sztzjy.digital_credit.entity.dto.ClassAVGScoreVo;
import com.sztzjy.digital_credit.entity.dto.TchAvgScoreByTimeParentDTO;
import com.sztzjy.digital_credit.entity.dto.TeaClassScoreDto;
import com.sztzjy.digital_credit.util.ResultEntity;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;
/**
@ -11,6 +14,16 @@ import java.util.List;
* @date 2024-04-30 14:55
*/
public interface TchHomePageService {
//班级平均成绩走势图
List<ClassAVGScoreVo> avgScoreTrendChart(String schoolId);
ResultEntity<List<TchAvgScoreByTimeParentDTO>> avgScoreTrendChart(String schoolId);
/**
*
* @param schoolId
* @param classId
* @param time
* @return
*/
TeaClassScoreDto getClassScoreCount(String schoolId, String classId, Date time);
}

@ -7,8 +7,10 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import com.sztzjy.digital_credit.entity.*;
import com.sztzjy.digital_credit.entity.dto.ClassAVGScoreVo;
import com.sztzjy.digital_credit.entity.dto.TchAvgScoreByTimeDTO;
import com.sztzjy.digital_credit.entity.dto.TchAvgScoreByTimeParentDTO;
import com.sztzjy.digital_credit.entity.dto.TeaClassScoreDto;
import com.sztzjy.digital_credit.mapper.StuScoreCenterMapper;
import com.sztzjy.digital_credit.mapper.StuUserMapper;
import com.sztzjy.digital_credit.mapper.TchClassAverageScoreMapper;
@ -17,11 +19,13 @@ import com.sztzjy.digital_credit.service.TchHomePageService;
import com.sztzjy.digital_credit.util.ResultEntity;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
@ -46,72 +50,173 @@ public class TchHomePageServiceImpl implements TchHomePageService {
// @Override
// public ResultEntity<List<TchAvgScoreByTimeParentDTO>> avgScoreTrendChart(String schoolId) {
//
// List<TchAvgScoreByTimeParentDTO> tchAvgScoreByTimeParentDTOS = new ArrayList<TchAvgScoreByTimeParentDTO>();
//
// //每天平均成绩集合
// List<Double> avgScoreListByDate = new ArrayList<>();
//
// //根据学校ID查询所有的班级列表 class_name
// StuUserExample userExample = new StuUserExample();
// userExample.createCriteria().andSchoolIdEqualTo(schoolId);
//
// //学校所有班级
// List<StuUser> userList = userMapper.selectByExample(userExample);
//
// if (userList.isEmpty())
// {
// return new ResultEntity<>(HttpStatus.OK,"schoolId不存在");
// }
//
// // 查询出所有班级名
// List<String> distinctClassNames = userList.stream()
// .map(item -> item.getClassName())
// .distinct()
// .collect(Collectors.toList());
//
// //遍历所有班级
// for (String className : distinctClassNames) {
// TchAvgScoreByTimeParentDTO tchAvgScoreByTimeParentDTO = new TchAvgScoreByTimeParentDTO();
//
// tchAvgScoreByTimeParentDTO.setClassList(className);
//
//
// List<TchClassAverageScore> tchClassAverageScores = tchClassAverageScoreMapper.selectByTime(className);
//
// //成绩列表
// List<Double> avgDoubleList = tchClassAverageScores.stream().map(TchClassAverageScore::getAveScore).collect(Collectors.toList());
// //时间列表
// List<Date> dateList = tchClassAverageScores.stream().map(TchClassAverageScore::getCreateTime).collect(Collectors.toList());
//
// ArrayList<String> stringArrayList = new ArrayList<>();
//
// dateList.forEach(item ->{
// SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd");
// String formattedDate = outputFormat.format(item);
// stringArrayList.add(formattedDate);
// });
//
// TchAvgScoreByTimeDTO tchAvgScoreByTimeDTO = new TchAvgScoreByTimeDTO();
// tchAvgScoreByTimeDTO.setAvgScoreList(StringUtils.join(avgDoubleList, ","));
// tchAvgScoreByTimeDTO.setDataList(StringUtils.join(stringArrayList, ","));
//
// tchAvgScoreByTimeParentDTO.setBaseInfo(tchAvgScoreByTimeDTO);
//
// tchAvgScoreByTimeParentDTOS.add(tchAvgScoreByTimeParentDTO);
// avgScoreListByDate.clear();
//
// }
//
// return new ResultEntity<>(HttpStatus.OK,"查询成功",tchAvgScoreByTimeParentDTOS);
// }
//
/**
*
* @param schoolId
* @return
*/
@Override
public ResultEntity<List<TchAvgScoreByTimeParentDTO>> avgScoreTrendChart( String schoolId) {
List<TchAvgScoreByTimeParentDTO> tchAvgScoreByTimeParentDTOS = new ArrayList<TchAvgScoreByTimeParentDTO>();
//每天平均成绩集合
List<Double> avgScoreListByDate = new ArrayList<>();
//根据学校ID查询所有的班级列表 class_name
StuUserExample userExample = new StuUserExample();
userExample.createCriteria().andSchoolIdEqualTo(schoolId);
//学校所有班级
List<StuUser> userList = userMapper.selectByExample(userExample);
if (userList.isEmpty())
{
return new ResultEntity<>(HttpStatus.OK,"schoolId不存在");
public List<ClassAVGScoreVo> avgScoreTrendChart(String schoolId) {
List<String> classNameList = tchClassAverageScoreMapper.selectClassNameBySchool(schoolId);
List<ClassAVGScoreVo> voList = new ArrayList<>();
for (String className : classNameList) {
ClassAVGScoreVo vo = new ClassAVGScoreVo();
vo.setClassName(className);
List<TchClassAverageScore> list = tchClassAverageScoreMapper.selectAndOrderByTime(schoolId, className);
if (list.isEmpty()) {
continue;
}
List<BigDecimal> scoreList = new ArrayList();
List<Date> dateList = new ArrayList<>();
for (TchClassAverageScore classScore : list) {
scoreList.add(classScore.getClassAverageScore());
dateList.add(classScore.getCreateTime());
}
vo.setClassAverageScore(scoreList);
vo.setStartTime(dateList);
voList.add(vo);
}
return voList;
}
// 查询出所有班级名
List<String> distinctClassNames = userList.stream()
.map(item -> item.getClassName())
.distinct()
.collect(Collectors.toList());
//遍历所有班级
for (String className : distinctClassNames) {
TchAvgScoreByTimeParentDTO tchAvgScoreByTimeParentDTO = new TchAvgScoreByTimeParentDTO();
tchAvgScoreByTimeParentDTO.setClassList(className);
List<TchClassAverageScore> tchClassAverageScores = tchClassAverageScoreMapper.selectByTime(className);
//成绩列表
List<Double> avgDoubleList = tchClassAverageScores.stream().map(TchClassAverageScore::getAveScore).collect(Collectors.toList());
//时间列表
List<Date> dateList = tchClassAverageScores.stream().map(TchClassAverageScore::getCreateTime).collect(Collectors.toList());
ArrayList<String> stringArrayList = new ArrayList<>();
dateList.forEach(item ->{
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd");
String formattedDate = outputFormat.format(item);
stringArrayList.add(formattedDate);
});
TchAvgScoreByTimeDTO tchAvgScoreByTimeDTO = new TchAvgScoreByTimeDTO();
tchAvgScoreByTimeDTO.setAvgScoreList(StringUtils.join(avgDoubleList, ","));
tchAvgScoreByTimeDTO.setDataList(StringUtils.join(stringArrayList, ","));
tchAvgScoreByTimeParentDTO.setBaseInfo(tchAvgScoreByTimeDTO);
tchAvgScoreByTimeParentDTOS.add(tchAvgScoreByTimeParentDTO);
avgScoreListByDate.clear();
/**
*
* @param schoolId
* @param classId
* @param time
* @return
*/
@Override
public TeaClassScoreDto getClassScoreCount(String schoolId, String classId, Date time) {
TchClassAverageScoreExample teaClassScoreExample = new TchClassAverageScoreExample();
TchClassAverageScoreExample.Criteria criteria = teaClassScoreExample.createCriteria();
Date startTime = null;
//班级框为空 统计学校下的所有数据返回
if (classId == null && schoolId != null) {
criteria.andSchoolIdEqualTo(schoolId).andCreateTimeEqualTo(time);
List<TchClassAverageScore> teaClassScores = tchClassAverageScoreMapper.selectByExample(teaClassScoreExample);
int schoolExcellentCount = 0;
int schoolGoodCount = 0;
int schoolGeneralCount = 0;
int schoolFailCount = 0;
BigDecimal maxScoreBySchoolId = BigDecimal.ZERO;
BigDecimal minScoreBySchoolId = BigDecimal.ZERO;
BigDecimal avgScoreBySchoolId = BigDecimal.ZERO;
for (TchClassAverageScore teaClassScore : teaClassScores) {
schoolExcellentCount = schoolExcellentCount + teaClassScore.getExcellentCount();
schoolGoodCount = schoolGoodCount + teaClassScore.getGoodCount();
schoolGeneralCount = schoolGeneralCount + teaClassScore.getGeneralCount();
schoolFailCount = schoolFailCount + teaClassScore.getFailCount();
BigDecimal maxScore = teaClassScore.getClassMaxScore();
if (maxScore == null) {
maxScore = BigDecimal.ZERO;
}
BigDecimal minScore = teaClassScore.getClassMinScore();
if (minScore == null) {
minScore = BigDecimal.ZERO;
}
// 计算最高分
if (maxScore.compareTo(maxScoreBySchoolId) >= 0) {
maxScoreBySchoolId = maxScore;
}
// 计算最低分
if (minScoreBySchoolId.compareTo(BigDecimal.ZERO) == 0 || minScore.compareTo(minScoreBySchoolId) <= 0) {
minScoreBySchoolId = minScore;
}
//所有班级平均分累加
avgScoreBySchoolId = avgScoreBySchoolId.add(teaClassScore.getClassAverageScore()).setScale(2, RoundingMode.HALF_UP);
startTime = teaClassScore.getCreateTime();
}
TeaClassScoreDto teaClassScoreDto = new TeaClassScoreDto();
teaClassScoreDto.setSchoolExcellentCount(schoolExcellentCount);
teaClassScoreDto.setSchoolGoodCount(schoolGoodCount);
teaClassScoreDto.setSchoolGeneralCount(schoolGeneralCount);
teaClassScoreDto.setSchoolFailCount(schoolFailCount);
teaClassScoreDto.setSchoolMaxScore(maxScoreBySchoolId);
teaClassScoreDto.setSchoolMinScore(minScoreBySchoolId);
teaClassScoreDto.setStartTime(startTime);
if (teaClassScores.size() > 0) {
BigDecimal finalAVGScore = avgScoreBySchoolId.divide(BigDecimal.valueOf(teaClassScores.size()), 2, RoundingMode.HALF_UP);
teaClassScoreDto.setSchoolAverageScore(finalAVGScore);
}
return teaClassScoreDto;
} else { //选中某个班级返回
criteria.andClassIdEqualTo(classId).andCreateTimeEqualTo(time);
List<TchClassAverageScore> teaClassScores = tchClassAverageScoreMapper.selectByExample(teaClassScoreExample);
if (teaClassScores.isEmpty()) {
return new TeaClassScoreDto();
}
TchClassAverageScore teaClassScore = teaClassScores.get(0);
TeaClassScoreDto teaClassScoreDto = new TeaClassScoreDto();
BeanUtils.copyProperties(teaClassScore, teaClassScoreDto);
return teaClassScoreDto;
}
return new ResultEntity<>(HttpStatus.OK,"查询成功",tchAvgScoreByTimeParentDTOS);
}
}

@ -7,6 +7,14 @@
<result column="class_name" jdbcType="VARCHAR" property="className" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="ave_score" jdbcType="DOUBLE" property="aveScore" />
<result column="excellent_count" jdbcType="INTEGER" property="excellentCount" />
<result column="good_count" jdbcType="INTEGER" property="goodCount" />
<result column="general_count" jdbcType="INTEGER" property="generalCount" />
<result column="fail_count" jdbcType="INTEGER" property="failCount" />
<result column="class_max_score" jdbcType="DECIMAL" property="classMaxScore" />
<result column="class_min_score" jdbcType="DECIMAL" property="classMinScore" />
<result column="class_average_score" jdbcType="DECIMAL" property="classAverageScore" />
<result column="school_id" jdbcType="VARCHAR" property="schoolId" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -67,7 +75,8 @@
</where>
</sql>
<sql id="Base_Column_List">
id, class_id, class_name, create_time, ave_score
id, class_id, class_name, create_time, ave_score, excellent_count, good_count, general_count,
fail_count, class_max_score, class_min_score, class_average_score, school_id
</sql>
<select id="selectByExample" parameterType="com.sztzjy.digital_credit.entity.TchClassAverageScoreExample" resultMap="BaseResultMap">
select
@ -101,9 +110,15 @@
</delete>
<insert id="insert" parameterType="com.sztzjy.digital_credit.entity.TchClassAverageScore">
insert into tch_class_average_score (id, class_id, class_name,
create_time, ave_score)
create_time, ave_score, excellent_count,
good_count, general_count, fail_count,
class_max_score, class_min_score, class_average_score,
school_id)
values (#{id,jdbcType=VARCHAR}, #{classId,jdbcType=VARCHAR}, #{className,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{aveScore,jdbcType=DOUBLE})
#{createTime,jdbcType=TIMESTAMP}, #{aveScore,jdbcType=DOUBLE}, #{excellentCount,jdbcType=INTEGER},
#{goodCount,jdbcType=INTEGER}, #{generalCount,jdbcType=INTEGER}, #{failCount,jdbcType=INTEGER},
#{classMaxScore,jdbcType=DECIMAL}, #{classMinScore,jdbcType=DECIMAL}, #{classAverageScore,jdbcType=DECIMAL},
#{schoolId,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.sztzjy.digital_credit.entity.TchClassAverageScore">
insert into tch_class_average_score
@ -123,6 +138,30 @@
<if test="aveScore != null">
ave_score,
</if>
<if test="excellentCount != null">
excellent_count,
</if>
<if test="goodCount != null">
good_count,
</if>
<if test="generalCount != null">
general_count,
</if>
<if test="failCount != null">
fail_count,
</if>
<if test="classMaxScore != null">
class_max_score,
</if>
<if test="classMinScore != null">
class_min_score,
</if>
<if test="classAverageScore != null">
class_average_score,
</if>
<if test="schoolId != null">
school_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -140,6 +179,30 @@
<if test="aveScore != null">
#{aveScore,jdbcType=DOUBLE},
</if>
<if test="excellentCount != null">
#{excellentCount,jdbcType=INTEGER},
</if>
<if test="goodCount != null">
#{goodCount,jdbcType=INTEGER},
</if>
<if test="generalCount != null">
#{generalCount,jdbcType=INTEGER},
</if>
<if test="failCount != null">
#{failCount,jdbcType=INTEGER},
</if>
<if test="classMaxScore != null">
#{classMaxScore,jdbcType=DECIMAL},
</if>
<if test="classMinScore != null">
#{classMinScore,jdbcType=DECIMAL},
</if>
<if test="classAverageScore != null">
#{classAverageScore,jdbcType=DECIMAL},
</if>
<if test="schoolId != null">
#{schoolId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.sztzjy.digital_credit.entity.TchClassAverageScoreExample" resultType="java.lang.Long">
@ -148,8 +211,7 @@
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
<update id="updateByExampleSelective" parameterType="map">
update tch_class_average_score
<set>
<if test="record.id != null">
@ -167,6 +229,30 @@
<if test="record.aveScore != null">
ave_score = #{record.aveScore,jdbcType=DOUBLE},
</if>
<if test="record.excellentCount != null">
excellent_count = #{record.excellentCount,jdbcType=INTEGER},
</if>
<if test="record.goodCount != null">
good_count = #{record.goodCount,jdbcType=INTEGER},
</if>
<if test="record.generalCount != null">
general_count = #{record.generalCount,jdbcType=INTEGER},
</if>
<if test="record.failCount != null">
fail_count = #{record.failCount,jdbcType=INTEGER},
</if>
<if test="record.classMaxScore != null">
class_max_score = #{record.classMaxScore,jdbcType=DECIMAL},
</if>
<if test="record.classMinScore != null">
class_min_score = #{record.classMinScore,jdbcType=DECIMAL},
</if>
<if test="record.classAverageScore != null">
class_average_score = #{record.classAverageScore,jdbcType=DECIMAL},
</if>
<if test="record.schoolId != null">
school_id = #{record.schoolId,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -178,7 +264,15 @@
class_id = #{record.classId,jdbcType=VARCHAR},
class_name = #{record.className,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
ave_score = #{record.aveScore,jdbcType=DOUBLE}
ave_score = #{record.aveScore,jdbcType=DOUBLE},
excellent_count = #{record.excellentCount,jdbcType=INTEGER},
good_count = #{record.goodCount,jdbcType=INTEGER},
general_count = #{record.generalCount,jdbcType=INTEGER},
fail_count = #{record.failCount,jdbcType=INTEGER},
class_max_score = #{record.classMaxScore,jdbcType=DECIMAL},
class_min_score = #{record.classMinScore,jdbcType=DECIMAL},
class_average_score = #{record.classAverageScore,jdbcType=DECIMAL},
school_id = #{record.schoolId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -198,6 +292,30 @@
<if test="aveScore != null">
ave_score = #{aveScore,jdbcType=DOUBLE},
</if>
<if test="excellentCount != null">
excellent_count = #{excellentCount,jdbcType=INTEGER},
</if>
<if test="goodCount != null">
good_count = #{goodCount,jdbcType=INTEGER},
</if>
<if test="generalCount != null">
general_count = #{generalCount,jdbcType=INTEGER},
</if>
<if test="failCount != null">
fail_count = #{failCount,jdbcType=INTEGER},
</if>
<if test="classMaxScore != null">
class_max_score = #{classMaxScore,jdbcType=DECIMAL},
</if>
<if test="classMinScore != null">
class_min_score = #{classMinScore,jdbcType=DECIMAL},
</if>
<if test="classAverageScore != null">
class_average_score = #{classAverageScore,jdbcType=DECIMAL},
</if>
<if test="schoolId != null">
school_id = #{schoolId,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -206,24 +324,37 @@
set class_id = #{classId,jdbcType=VARCHAR},
class_name = #{className,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
ave_score = #{aveScore,jdbcType=DOUBLE}
ave_score = #{aveScore,jdbcType=DOUBLE},
excellent_count = #{excellentCount,jdbcType=INTEGER},
good_count = #{goodCount,jdbcType=INTEGER},
general_count = #{generalCount,jdbcType=INTEGER},
fail_count = #{failCount,jdbcType=INTEGER},
class_max_score = #{classMaxScore,jdbcType=DECIMAL},
class_min_score = #{classMinScore,jdbcType=DECIMAL},
class_average_score = #{classAverageScore,jdbcType=DECIMAL},
school_id = #{schoolId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<select id="selectByTime" parameterType="java.lang.String" resultMap="BaseResultMap">
<!-- <select id="selectByTime" parameterType="java.lang.String" resultMap="BaseResultMap">-->
<!-- select-->
<!-- <include refid="Base_Column_List" />-->
<!-- from tch_class_average_score-->
<!-- where-->
<!-- <if test="className != null">-->
<!-- class_name = #{className,jdbcType=VARCHAR}-->
<!-- </if>-->
<!-- AND create_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH)-->
<!-- order by create_time asc-->
<!-- </select>-->
<select id="selectAndOrderByTime" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tch_class_average_score
where
<if test="className != null">
class_name = #{className,jdbcType=VARCHAR}
</if>
where school_id = #{schoolId,jdbcType=VARCHAR}
AND class_name = #{className}
AND create_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH)
order by create_time asc
order by create_time
</select>
</mapper>
Loading…
Cancel
Save