完成定时修改计算平均成绩,折线图
parent
01d7ea1fc0
commit
dee7cf93e9
@ -0,0 +1,101 @@
|
||||
package com.sztzjy.digital_credit.controller.task;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.sztzjy.digital_credit.annotation.AnonymousAccess;
|
||||
import com.sztzjy.digital_credit.entity.*;
|
||||
import com.sztzjy.digital_credit.entity.dto.EducationAndBreachOfContractDTO;
|
||||
import com.sztzjy.digital_credit.mapper.StuBreachOfContractTrainingMapper;
|
||||
import com.sztzjy.digital_credit.mapper.StuScoreCenterMapper;
|
||||
import com.sztzjy.digital_credit.mapper.StuUserMapper;
|
||||
import com.sztzjy.digital_credit.mapper.TchClassAverageScoreMapper;
|
||||
import com.sztzjy.digital_credit.util.ResultEntity;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class StuTaskController {
|
||||
|
||||
@Autowired
|
||||
TchClassAverageScoreMapper tchClassAverageScoreMapper;
|
||||
|
||||
@Autowired
|
||||
private StuUserMapper userMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
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);
|
||||
|
||||
//该班级平均分
|
||||
BigDecimal divide = sum.divide(BigDecimal.valueOf(userListByClassName.size()), 2, BigDecimal.ROUND_HALF_UP);
|
||||
|
||||
TchClassAverageScore tchClassAverageScore= new TchClassAverageScore();
|
||||
tchClassAverageScore.setAveScore(divide.doubleValue());
|
||||
tchClassAverageScore.setClassName(className);
|
||||
tchClassAverageScore.setCreateTime(new Date());
|
||||
tchClassAverageScore.setId(String.valueOf(IdUtil.getSnowflakeNextId()));
|
||||
|
||||
tchClassAverageScoreMapper.insertSelective(tchClassAverageScore);
|
||||
}
|
||||
|
||||
|
||||
log.info("定时任务:==================执行结束======================");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,45 @@
|
||||
package com.sztzjy.digital_credit.controller.tch;
|
||||
|
||||
import com.sztzjy.digital_credit.annotation.AnonymousAccess;
|
||||
import com.sztzjy.digital_credit.entity.dto.TchAvgScoreByTimeDTO;
|
||||
import com.sztzjy.digital_credit.entity.dto.TchAvgScoreByTimeParentDTO;
|
||||
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 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.RestController;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 17803
|
||||
* @date 2024-04-30 11:41
|
||||
*/
|
||||
|
||||
@Api(tags = "教师端--首页")
|
||||
@RestController
|
||||
@RequestMapping("api/tch/home")
|
||||
public class TchHomePageController {
|
||||
|
||||
@Autowired
|
||||
private TchHomePageService tchHomePageService;
|
||||
|
||||
|
||||
@ApiOperation("班级平均成绩走势图")
|
||||
@GetMapping("avgScoreTrendChart")
|
||||
@AnonymousAccess
|
||||
public ResultEntity<List<TchAvgScoreByTimeParentDTO>> avgScoreTrendChart(String schoolId){
|
||||
|
||||
return tchHomePageService.avgScoreTrendChart(schoolId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.sztzjy.digital_credit.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author whb
|
||||
* tch_class_average_score
|
||||
*/
|
||||
public class TchClassAverageScore {
|
||||
@ApiModelProperty("id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("班级ID")
|
||||
private String classId;
|
||||
|
||||
@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;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id == null ? null : id.trim();
|
||||
}
|
||||
|
||||
public String getClassId() {
|
||||
return classId;
|
||||
}
|
||||
|
||||
public void setClassId(String classId) {
|
||||
this.classId = classId == null ? null : classId.trim();
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public void setClassName(String className) {
|
||||
this.className = className == null ? null : className.trim();
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Double getAveScore() {
|
||||
return aveScore;
|
||||
}
|
||||
|
||||
public void setAveScore(Double aveScore) {
|
||||
this.aveScore = aveScore;
|
||||
}
|
||||
}
|
@ -0,0 +1,530 @@
|
||||
package com.sztzjy.digital_credit.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class TchClassAverageScoreExample {
|
||||
protected String orderByClause;
|
||||
|
||||
protected boolean distinct;
|
||||
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
public TchClassAverageScoreExample() {
|
||||
oredCriteria = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void setOrderByClause(String orderByClause) {
|
||||
this.orderByClause = orderByClause;
|
||||
}
|
||||
|
||||
public String getOrderByClause() {
|
||||
return orderByClause;
|
||||
}
|
||||
|
||||
public void setDistinct(boolean distinct) {
|
||||
this.distinct = distinct;
|
||||
}
|
||||
|
||||
public boolean isDistinct() {
|
||||
return distinct;
|
||||
}
|
||||
|
||||
public List<Criteria> getOredCriteria() {
|
||||
return oredCriteria;
|
||||
}
|
||||
|
||||
public void or(Criteria criteria) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
|
||||
public Criteria or() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
oredCriteria.add(criteria);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public Criteria createCriteria() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
if (oredCriteria.size() == 0) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected Criteria createCriteriaInternal() {
|
||||
Criteria criteria = new Criteria();
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
oredCriteria.clear();
|
||||
orderByClause = null;
|
||||
distinct = false;
|
||||
}
|
||||
|
||||
protected abstract static class GeneratedCriteria {
|
||||
protected List<Criterion> criteria;
|
||||
|
||||
protected GeneratedCriteria() {
|
||||
super();
|
||||
criteria = new ArrayList<>();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return criteria.size() > 0;
|
||||
}
|
||||
|
||||
public List<Criterion> getAllCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public List<Criterion> getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition) {
|
||||
if (condition == null) {
|
||||
throw new RuntimeException("Value for condition cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value, String property) {
|
||||
if (value == null) {
|
||||
throw new RuntimeException("Value for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value1, Object value2, String property) {
|
||||
if (value1 == null || value2 == null) {
|
||||
throw new RuntimeException("Between values for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value1, value2));
|
||||
}
|
||||
|
||||
public Criteria andIdIsNull() {
|
||||
addCriterion("id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIsNotNull() {
|
||||
addCriterion("id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdEqualTo(String value) {
|
||||
addCriterion("id =", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotEqualTo(String value) {
|
||||
addCriterion("id <>", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThan(String value) {
|
||||
addCriterion("id >", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("id >=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThan(String value) {
|
||||
addCriterion("id <", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("id <=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLike(String value) {
|
||||
addCriterion("id like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotLike(String value) {
|
||||
addCriterion("id not like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIn(List<String> values) {
|
||||
addCriterion("id in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotIn(List<String> values) {
|
||||
addCriterion("id not in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdBetween(String value1, String value2) {
|
||||
addCriterion("id between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotBetween(String value1, String value2) {
|
||||
addCriterion("id not between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassIdIsNull() {
|
||||
addCriterion("class_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassIdIsNotNull() {
|
||||
addCriterion("class_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassIdEqualTo(String value) {
|
||||
addCriterion("class_id =", value, "classId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassIdNotEqualTo(String value) {
|
||||
addCriterion("class_id <>", value, "classId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassIdGreaterThan(String value) {
|
||||
addCriterion("class_id >", value, "classId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("class_id >=", value, "classId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassIdLessThan(String value) {
|
||||
addCriterion("class_id <", value, "classId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("class_id <=", value, "classId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassIdLike(String value) {
|
||||
addCriterion("class_id like", value, "classId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassIdNotLike(String value) {
|
||||
addCriterion("class_id not like", value, "classId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassIdIn(List<String> values) {
|
||||
addCriterion("class_id in", values, "classId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassIdNotIn(List<String> values) {
|
||||
addCriterion("class_id not in", values, "classId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassIdBetween(String value1, String value2) {
|
||||
addCriterion("class_id between", value1, value2, "classId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassIdNotBetween(String value1, String value2) {
|
||||
addCriterion("class_id not between", value1, value2, "classId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassNameIsNull() {
|
||||
addCriterion("class_name is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassNameIsNotNull() {
|
||||
addCriterion("class_name is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassNameEqualTo(String value) {
|
||||
addCriterion("class_name =", value, "className");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassNameNotEqualTo(String value) {
|
||||
addCriterion("class_name <>", value, "className");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassNameGreaterThan(String value) {
|
||||
addCriterion("class_name >", value, "className");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassNameGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("class_name >=", value, "className");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassNameLessThan(String value) {
|
||||
addCriterion("class_name <", value, "className");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassNameLessThanOrEqualTo(String value) {
|
||||
addCriterion("class_name <=", value, "className");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassNameLike(String value) {
|
||||
addCriterion("class_name like", value, "className");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassNameNotLike(String value) {
|
||||
addCriterion("class_name not like", value, "className");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassNameIn(List<String> values) {
|
||||
addCriterion("class_name in", values, "className");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassNameNotIn(List<String> values) {
|
||||
addCriterion("class_name not in", values, "className");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassNameBetween(String value1, String value2) {
|
||||
addCriterion("class_name between", value1, value2, "className");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andClassNameNotBetween(String value1, String value2) {
|
||||
addCriterion("class_name not between", value1, value2, "className");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNull() {
|
||||
addCriterion("create_time is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNotNull() {
|
||||
addCriterion("create_time is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeEqualTo(Date value) {
|
||||
addCriterion("create_time =", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotEqualTo(Date value) {
|
||||
addCriterion("create_time <>", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeGreaterThan(Date value) {
|
||||
addCriterion("create_time >", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
|
||||
addCriterion("create_time >=", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeLessThan(Date value) {
|
||||
addCriterion("create_time <", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
|
||||
addCriterion("create_time <=", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIn(List<Date> values) {
|
||||
addCriterion("create_time in", values, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotIn(List<Date> values) {
|
||||
addCriterion("create_time not in", values, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeBetween(Date value1, Date value2) {
|
||||
addCriterion("create_time between", value1, value2, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
|
||||
addCriterion("create_time not between", value1, value2, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAveScoreIsNull() {
|
||||
addCriterion("ave_score is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAveScoreIsNotNull() {
|
||||
addCriterion("ave_score is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAveScoreEqualTo(Double value) {
|
||||
addCriterion("ave_score =", value, "aveScore");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAveScoreNotEqualTo(Double value) {
|
||||
addCriterion("ave_score <>", value, "aveScore");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAveScoreGreaterThan(Double value) {
|
||||
addCriterion("ave_score >", value, "aveScore");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAveScoreGreaterThanOrEqualTo(Double value) {
|
||||
addCriterion("ave_score >=", value, "aveScore");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAveScoreLessThan(Double value) {
|
||||
addCriterion("ave_score <", value, "aveScore");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAveScoreLessThanOrEqualTo(Double value) {
|
||||
addCriterion("ave_score <=", value, "aveScore");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAveScoreIn(List<Double> values) {
|
||||
addCriterion("ave_score in", values, "aveScore");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAveScoreNotIn(List<Double> values) {
|
||||
addCriterion("ave_score not in", values, "aveScore");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAveScoreBetween(Double value1, Double value2) {
|
||||
addCriterion("ave_score between", value1, value2, "aveScore");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAveScoreNotBetween(Double value1, Double value2) {
|
||||
addCriterion("ave_score not between", value1, value2, "aveScore");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
protected Criteria() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criterion {
|
||||
private String condition;
|
||||
|
||||
private Object value;
|
||||
|
||||
private Object secondValue;
|
||||
|
||||
private boolean noValue;
|
||||
|
||||
private boolean singleValue;
|
||||
|
||||
private boolean betweenValue;
|
||||
|
||||
private boolean listValue;
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.typeHandler = null;
|
||||
this.noValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.typeHandler = typeHandler;
|
||||
if (value instanceof List<?>) {
|
||||
this.listValue = true;
|
||||
} else {
|
||||
this.singleValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value) {
|
||||
this(condition, value, null);
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.secondValue = secondValue;
|
||||
this.typeHandler = typeHandler;
|
||||
this.betweenValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.sztzjy.digital_credit.mapper;
|
||||
|
||||
import com.sztzjy.digital_credit.entity.TchClassAverageScore;
|
||||
import com.sztzjy.digital_credit.entity.TchClassAverageScoreExample;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
public interface TchClassAverageScoreMapper {
|
||||
long countByExample(TchClassAverageScoreExample example);
|
||||
|
||||
int deleteByExample(TchClassAverageScoreExample example);
|
||||
|
||||
int deleteByPrimaryKey(String id);
|
||||
|
||||
int insert(TchClassAverageScore record);
|
||||
|
||||
int insertSelective(TchClassAverageScore record);
|
||||
|
||||
List<TchClassAverageScore> selectByExample(TchClassAverageScoreExample example);
|
||||
|
||||
TchClassAverageScore selectByPrimaryKey(String id);
|
||||
|
||||
int updateByExampleSelective(@Param("record") TchClassAverageScore record, @Param("example") TchClassAverageScoreExample example);
|
||||
|
||||
int updateByExample(@Param("record") TchClassAverageScore record, @Param("example") TchClassAverageScoreExample example);
|
||||
|
||||
int updateByPrimaryKeySelective(TchClassAverageScore record);
|
||||
|
||||
int updateByPrimaryKey(TchClassAverageScore record);
|
||||
|
||||
//根据时间排序
|
||||
List<TchClassAverageScore> selectByTime(@Param("className") String className);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.sztzjy.digital_credit.service;
|
||||
|
||||
import com.sztzjy.digital_credit.entity.dto.TchAvgScoreByTimeParentDTO;
|
||||
import com.sztzjy.digital_credit.util.ResultEntity;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 17803
|
||||
* @date 2024-04-30 14:55
|
||||
*/
|
||||
public interface TchHomePageService {
|
||||
|
||||
ResultEntity<List<TchAvgScoreByTimeParentDTO>> avgScoreTrendChart(String schoolId);
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
package com.sztzjy.digital_credit.service.impl;/**
|
||||
* @author 17803
|
||||
* @date 2024-04-30 14:55
|
||||
*/
|
||||
|
||||
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.TchAvgScoreByTimeDTO;
|
||||
import com.sztzjy.digital_credit.entity.dto.TchAvgScoreByTimeParentDTO;
|
||||
import com.sztzjy.digital_credit.mapper.StuScoreCenterMapper;
|
||||
import com.sztzjy.digital_credit.mapper.StuUserMapper;
|
||||
import com.sztzjy.digital_credit.mapper.TchClassAverageScoreMapper;
|
||||
import com.sztzjy.digital_credit.mapper.TchModuleWeithMapper;
|
||||
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.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
|
||||
public class TchHomePageServiceImpl implements TchHomePageService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private StuUserMapper userMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
private StuScoreCenterMapper scoreCenterMapper;
|
||||
|
||||
@Autowired
|
||||
private TchClassAverageScoreMapper tchClassAverageScoreMapper;
|
||||
|
||||
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
@ -0,0 +1,229 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.sztzjy.digital_credit.mapper.TchClassAverageScoreMapper">
|
||||
<resultMap id="BaseResultMap" type="com.sztzjy.digital_credit.entity.TchClassAverageScore">
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="class_id" jdbcType="VARCHAR" property="classId" />
|
||||
<result column="class_name" jdbcType="VARCHAR" property="className" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="ave_score" jdbcType="DOUBLE" property="aveScore" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Update_By_Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="example.oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, class_id, class_name, create_time, ave_score
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="com.sztzjy.digital_credit.entity.TchClassAverageScoreExample" resultMap="BaseResultMap">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
from tch_class_average_score
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from tch_class_average_score
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
||||
delete from tch_class_average_score
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="com.sztzjy.digital_credit.entity.TchClassAverageScoreExample">
|
||||
delete from tch_class_average_score
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</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)
|
||||
values (#{id,jdbcType=VARCHAR}, #{classId,jdbcType=VARCHAR}, #{className,jdbcType=VARCHAR},
|
||||
#{createTime,jdbcType=TIMESTAMP}, #{aveScore,jdbcType=DOUBLE})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.sztzjy.digital_credit.entity.TchClassAverageScore">
|
||||
insert into tch_class_average_score
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="classId != null">
|
||||
class_id,
|
||||
</if>
|
||||
<if test="className != null">
|
||||
class_name,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="aveScore != null">
|
||||
ave_score,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="classId != null">
|
||||
#{classId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="className != null">
|
||||
#{className,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="aveScore != null">
|
||||
#{aveScore,jdbcType=DOUBLE},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="com.sztzjy.digital_credit.entity.TchClassAverageScoreExample" resultType="java.lang.Long">
|
||||
select count(*) from tch_class_average_score
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update tch_class_average_score
|
||||
<set>
|
||||
<if test="record.id != null">
|
||||
id = #{record.id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.classId != null">
|
||||
class_id = #{record.classId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.className != null">
|
||||
class_name = #{record.className,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="record.aveScore != null">
|
||||
ave_score = #{record.aveScore,jdbcType=DOUBLE},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update tch_class_average_score
|
||||
set id = #{record.id,jdbcType=VARCHAR},
|
||||
class_id = #{record.classId,jdbcType=VARCHAR},
|
||||
class_name = #{record.className,jdbcType=VARCHAR},
|
||||
create_time = #{record.createTime,jdbcType=TIMESTAMP},
|
||||
ave_score = #{record.aveScore,jdbcType=DOUBLE}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.sztzjy.digital_credit.entity.TchClassAverageScore">
|
||||
update tch_class_average_score
|
||||
<set>
|
||||
<if test="classId != null">
|
||||
class_id = #{classId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="className != null">
|
||||
class_name = #{className,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="aveScore != null">
|
||||
ave_score = #{aveScore,jdbcType=DOUBLE},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.sztzjy.digital_credit.entity.TchClassAverageScore">
|
||||
update tch_class_average_score
|
||||
set class_id = #{classId,jdbcType=VARCHAR},
|
||||
class_name = #{className,jdbcType=VARCHAR},
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
ave_score = #{aveScore,jdbcType=DOUBLE}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
|
||||
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue