From dee7cf93e9d592e370014c83c4587afa884aaecb Mon Sep 17 00:00:00 2001 From: whb <17803890193@163.com> Date: Mon, 6 May 2024 17:11:00 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A1=E7=AE=97=E5=B9=B3=E5=9D=87=E6=88=90?= =?UTF-8?q?=E7=BB=A9=EF=BC=8C=E6=8A=98=E7=BA=BF=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FinancialBigDataApplication.java | 4 +- .../controller/task/StuTaskController.java | 101 ++++ .../controller/tch/TchHomePageController.java | 45 ++ .../digital_credit/entity/StuScoreCenter.java | 25 +- .../entity/StuScoreCenterExample.java | 131 +++++ .../entity/TchClassAverageScore.java | 71 +++ .../entity/TchClassAverageScoreExample.java | 530 ++++++++++++++++++ .../entity/dto/TchAvgScoreByTimeDTO.java | 23 + .../dto/TchAvgScoreByTimeParentDTO.java | 26 + .../mapper/StuScoreCenterMapper.java | 4 +- .../mapper/TchClassAverageScoreMapper.java | 34 ++ .../service/TchHomePageService.java | 16 + .../service/impl/StuRateServiceImpl.java | 4 +- .../service/impl/TchHomePageServiceImpl.java | 117 ++++ src/main/resources/generatorConfig.xml | 2 +- .../mappers/StuScoreCenterMapper.xml | 44 +- .../mappers/TchClassAverageScoreMapper.xml | 229 ++++++++ 17 files changed, 1391 insertions(+), 15 deletions(-) create mode 100644 src/main/java/com/sztzjy/digital_credit/controller/task/StuTaskController.java create mode 100644 src/main/java/com/sztzjy/digital_credit/controller/tch/TchHomePageController.java create mode 100644 src/main/java/com/sztzjy/digital_credit/entity/TchClassAverageScore.java create mode 100644 src/main/java/com/sztzjy/digital_credit/entity/TchClassAverageScoreExample.java create mode 100644 src/main/java/com/sztzjy/digital_credit/entity/dto/TchAvgScoreByTimeDTO.java create mode 100644 src/main/java/com/sztzjy/digital_credit/entity/dto/TchAvgScoreByTimeParentDTO.java create mode 100644 src/main/java/com/sztzjy/digital_credit/mapper/TchClassAverageScoreMapper.java create mode 100644 src/main/java/com/sztzjy/digital_credit/service/TchHomePageService.java create mode 100644 src/main/java/com/sztzjy/digital_credit/service/impl/TchHomePageServiceImpl.java create mode 100644 src/main/resources/mappers/TchClassAverageScoreMapper.xml diff --git a/src/main/java/com/sztzjy/digital_credit/FinancialBigDataApplication.java b/src/main/java/com/sztzjy/digital_credit/FinancialBigDataApplication.java index 2c18f3a..78305c5 100644 --- a/src/main/java/com/sztzjy/digital_credit/FinancialBigDataApplication.java +++ b/src/main/java/com/sztzjy/digital_credit/FinancialBigDataApplication.java @@ -1,5 +1,6 @@ package com.sztzjy.digital_credit; +import lombok.extern.slf4j.Slf4j; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -7,9 +8,10 @@ import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication -@EnableScheduling @Configuration @MapperScan(basePackages = "com.sztzjy.digital_credit.mapper") +@EnableScheduling +@Slf4j public class FinancialBigDataApplication { public static void main(String[] args) { diff --git a/src/main/java/com/sztzjy/digital_credit/controller/task/StuTaskController.java b/src/main/java/com/sztzjy/digital_credit/controller/task/StuTaskController.java new file mode 100644 index 0000000..b440ae0 --- /dev/null +++ b/src/main/java/com/sztzjy/digital_credit/controller/task/StuTaskController.java @@ -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 stuUsersList = userMapper.selectByExample(userExample); + //根据学校ID查询所有的班级列表 class_name + List classNameList = stuUsersList.stream().map(StuUser::getClassName).distinct().collect(Collectors.toList()); + + for (String className : classNameList) { + + StuUserExample userExample1 = new StuUserExample(); + userExample1.createCriteria().andClassNameEqualTo(className); + //获取该班所有学生 + List userListByClassName = userMapper.selectByExample(userExample1); + //汇总总分 + List 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("定时任务:==================执行结束======================"); + + } + + + +} + + diff --git a/src/main/java/com/sztzjy/digital_credit/controller/tch/TchHomePageController.java b/src/main/java/com/sztzjy/digital_credit/controller/tch/TchHomePageController.java new file mode 100644 index 0000000..2e92339 --- /dev/null +++ b/src/main/java/com/sztzjy/digital_credit/controller/tch/TchHomePageController.java @@ -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> avgScoreTrendChart(String schoolId){ + + return tchHomePageService.avgScoreTrendChart(schoolId); + + } + + + + +} diff --git a/src/main/java/com/sztzjy/digital_credit/entity/StuScoreCenter.java b/src/main/java/com/sztzjy/digital_credit/entity/StuScoreCenter.java index 3710bf7..be99d6e 100644 --- a/src/main/java/com/sztzjy/digital_credit/entity/StuScoreCenter.java +++ b/src/main/java/com/sztzjy/digital_credit/entity/StuScoreCenter.java @@ -1,11 +1,12 @@ package com.sztzjy.digital_credit.entity; import java.math.BigDecimal; +import java.util.Date; import io.swagger.annotations.ApiModelProperty; /** * - * @author tz + * @author whb * stu_score_center */ public class StuScoreCenter { @@ -54,6 +55,12 @@ public class StuScoreCenter { @ApiModelProperty("重新实训次数(最多两次)") private Integer numberOfTraining; + @ApiModelProperty("完成时间") + private Date completionTime; + + @ApiModelProperty("班级名称") + private String className; + public Integer getId() { return id; } @@ -173,4 +180,20 @@ public class StuScoreCenter { public void setNumberOfTraining(Integer numberOfTraining) { this.numberOfTraining = numberOfTraining; } + + public Date getCompletionTime() { + return completionTime; + } + + public void setCompletionTime(Date completionTime) { + this.completionTime = completionTime; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className == null ? null : className.trim(); + } } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/digital_credit/entity/StuScoreCenterExample.java b/src/main/java/com/sztzjy/digital_credit/entity/StuScoreCenterExample.java index 037a581..7c57bfb 100644 --- a/src/main/java/com/sztzjy/digital_credit/entity/StuScoreCenterExample.java +++ b/src/main/java/com/sztzjy/digital_credit/entity/StuScoreCenterExample.java @@ -2,6 +2,7 @@ package com.sztzjy.digital_credit.entity; import java.math.BigDecimal; import java.util.ArrayList; +import java.util.Date; import java.util.List; public class StuScoreCenterExample { @@ -1054,6 +1055,136 @@ public class StuScoreCenterExample { addCriterion("number_of_training not between", value1, value2, "numberOfTraining"); return (Criteria) this; } + + public Criteria andCompletionTimeIsNull() { + addCriterion("completion_time is null"); + return (Criteria) this; + } + + public Criteria andCompletionTimeIsNotNull() { + addCriterion("completion_time is not null"); + return (Criteria) this; + } + + public Criteria andCompletionTimeEqualTo(Date value) { + addCriterion("completion_time =", value, "completionTime"); + return (Criteria) this; + } + + public Criteria andCompletionTimeNotEqualTo(Date value) { + addCriterion("completion_time <>", value, "completionTime"); + return (Criteria) this; + } + + public Criteria andCompletionTimeGreaterThan(Date value) { + addCriterion("completion_time >", value, "completionTime"); + return (Criteria) this; + } + + public Criteria andCompletionTimeGreaterThanOrEqualTo(Date value) { + addCriterion("completion_time >=", value, "completionTime"); + return (Criteria) this; + } + + public Criteria andCompletionTimeLessThan(Date value) { + addCriterion("completion_time <", value, "completionTime"); + return (Criteria) this; + } + + public Criteria andCompletionTimeLessThanOrEqualTo(Date value) { + addCriterion("completion_time <=", value, "completionTime"); + return (Criteria) this; + } + + public Criteria andCompletionTimeIn(List values) { + addCriterion("completion_time in", values, "completionTime"); + return (Criteria) this; + } + + public Criteria andCompletionTimeNotIn(List values) { + addCriterion("completion_time not in", values, "completionTime"); + return (Criteria) this; + } + + public Criteria andCompletionTimeBetween(Date value1, Date value2) { + addCriterion("completion_time between", value1, value2, "completionTime"); + return (Criteria) this; + } + + public Criteria andCompletionTimeNotBetween(Date value1, Date value2) { + addCriterion("completion_time not between", value1, value2, "completionTime"); + 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 values) { + addCriterion("class_name in", values, "className"); + return (Criteria) this; + } + + public Criteria andClassNameNotIn(List 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 static class Criteria extends GeneratedCriteria { diff --git a/src/main/java/com/sztzjy/digital_credit/entity/TchClassAverageScore.java b/src/main/java/com/sztzjy/digital_credit/entity/TchClassAverageScore.java new file mode 100644 index 0000000..d35784d --- /dev/null +++ b/src/main/java/com/sztzjy/digital_credit/entity/TchClassAverageScore.java @@ -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; + } +} \ No newline at end of file diff --git a/src/main/java/com/sztzjy/digital_credit/entity/TchClassAverageScoreExample.java b/src/main/java/com/sztzjy/digital_credit/entity/TchClassAverageScoreExample.java new file mode 100644 index 0000000..5f17c39 --- /dev/null +++ b/src/main/java/com/sztzjy/digital_credit/entity/TchClassAverageScoreExample.java @@ -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 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 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 criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList<>(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List 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 values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List 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 values) { + addCriterion("class_id in", values, "classId"); + return (Criteria) this; + } + + public Criteria andClassIdNotIn(List 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 values) { + addCriterion("class_name in", values, "className"); + return (Criteria) this; + } + + public Criteria andClassNameNotIn(List 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 values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List 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 values) { + addCriterion("ave_score in", values, "aveScore"); + return (Criteria) this; + } + + public Criteria andAveScoreNotIn(List 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); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/sztzjy/digital_credit/entity/dto/TchAvgScoreByTimeDTO.java b/src/main/java/com/sztzjy/digital_credit/entity/dto/TchAvgScoreByTimeDTO.java new file mode 100644 index 0000000..f4da193 --- /dev/null +++ b/src/main/java/com/sztzjy/digital_credit/entity/dto/TchAvgScoreByTimeDTO.java @@ -0,0 +1,23 @@ +package com.sztzjy.digital_credit.entity.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author 17803 + * @date 2024-04-30 14:57 + */ + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TchAvgScoreByTimeDTO { + //得分,以逗号分隔,例如:2022-10-01,2022-10-02,2022-10-03 + private String avgScoreList; + + //日期列表,以逗号分隔,例如:20,21,10 + private String dataList; +} diff --git a/src/main/java/com/sztzjy/digital_credit/entity/dto/TchAvgScoreByTimeParentDTO.java b/src/main/java/com/sztzjy/digital_credit/entity/dto/TchAvgScoreByTimeParentDTO.java new file mode 100644 index 0000000..643138d --- /dev/null +++ b/src/main/java/com/sztzjy/digital_credit/entity/dto/TchAvgScoreByTimeParentDTO.java @@ -0,0 +1,26 @@ +package com.sztzjy.digital_credit.entity.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @author 17803 + * @date 2024-04-30 14:57 + */ + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TchAvgScoreByTimeParentDTO { + + private String classList; + + + //日期列表,以逗号分隔,例如:20,21,10 + private TchAvgScoreByTimeDTO baseInfo; +} diff --git a/src/main/java/com/sztzjy/digital_credit/mapper/StuScoreCenterMapper.java b/src/main/java/com/sztzjy/digital_credit/mapper/StuScoreCenterMapper.java index 11dd716..305272f 100644 --- a/src/main/java/com/sztzjy/digital_credit/mapper/StuScoreCenterMapper.java +++ b/src/main/java/com/sztzjy/digital_credit/mapper/StuScoreCenterMapper.java @@ -3,10 +3,8 @@ package com.sztzjy.digital_credit.mapper; import com.sztzjy.digital_credit.entity.StuScoreCenter; import com.sztzjy.digital_credit.entity.StuScoreCenterExample; import java.util.List; - -import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; -@Mapper + public interface StuScoreCenterMapper { long countByExample(StuScoreCenterExample example); diff --git a/src/main/java/com/sztzjy/digital_credit/mapper/TchClassAverageScoreMapper.java b/src/main/java/com/sztzjy/digital_credit/mapper/TchClassAverageScoreMapper.java new file mode 100644 index 0000000..f4e593d --- /dev/null +++ b/src/main/java/com/sztzjy/digital_credit/mapper/TchClassAverageScoreMapper.java @@ -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 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 selectByTime(@Param("className") String className); +} \ No newline at end of file diff --git a/src/main/java/com/sztzjy/digital_credit/service/TchHomePageService.java b/src/main/java/com/sztzjy/digital_credit/service/TchHomePageService.java new file mode 100644 index 0000000..c79eb56 --- /dev/null +++ b/src/main/java/com/sztzjy/digital_credit/service/TchHomePageService.java @@ -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> avgScoreTrendChart(String schoolId); +} diff --git a/src/main/java/com/sztzjy/digital_credit/service/impl/StuRateServiceImpl.java b/src/main/java/com/sztzjy/digital_credit/service/impl/StuRateServiceImpl.java index 4198e69..ee07d9f 100644 --- a/src/main/java/com/sztzjy/digital_credit/service/impl/StuRateServiceImpl.java +++ b/src/main/java/com/sztzjy/digital_credit/service/impl/StuRateServiceImpl.java @@ -870,7 +870,7 @@ public class StuRateServiceImpl implements StuRateService { StuUser user = userMapper.selectByPrimaryKey(userId); - //获取用户企业征信客观成绩 + //获取用户 企业征信 客观成绩 BigDecimal caseCorporateCreditObjScore = user.getCaseCorporateCreditObjScore(); if (user.getCaseCorporateCreditObjScore() == null){ caseCorporateCreditObjScore = BigDecimal.valueOf(0); @@ -884,7 +884,7 @@ public class StuRateServiceImpl implements StuRateService { if (caseCorporateCreditScore == null){ caseCorporateCreditScore = BigDecimal.valueOf(0); } - //赋值企业征信客观总的成绩 + //赋值 企业征信客观总的成绩 user.setCaseCorporateCreditScore(caseCorporateCreditScore.add(BigDecimal.valueOf(info))); userMapper.updateByPrimaryKeySelective(user); diff --git a/src/main/java/com/sztzjy/digital_credit/service/impl/TchHomePageServiceImpl.java b/src/main/java/com/sztzjy/digital_credit/service/impl/TchHomePageServiceImpl.java new file mode 100644 index 0000000..28de42d --- /dev/null +++ b/src/main/java/com/sztzjy/digital_credit/service/impl/TchHomePageServiceImpl.java @@ -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> avgScoreTrendChart( String schoolId) { + + List tchAvgScoreByTimeParentDTOS = new ArrayList(); + + + + //每天平均成绩集合 + List avgScoreListByDate = new ArrayList<>(); + + //根据学校ID查询所有的班级列表 class_name + StuUserExample userExample = new StuUserExample(); + userExample.createCriteria().andSchoolIdEqualTo(schoolId); + + //学校所有班级 + List userList = userMapper.selectByExample(userExample); + + if (userList.isEmpty()) + { + return new ResultEntity<>(HttpStatus.OK,"schoolId不存在"); + } + + // 查询出所有班级名 + List distinctClassNames = userList.stream() + .map(item -> item.getClassName()) + .distinct() + .collect(Collectors.toList()); + + //遍历所有班级 + for (String className : distinctClassNames) { + TchAvgScoreByTimeParentDTO tchAvgScoreByTimeParentDTO = new TchAvgScoreByTimeParentDTO(); + + tchAvgScoreByTimeParentDTO.setClassList(className); + + + List tchClassAverageScores = tchClassAverageScoreMapper.selectByTime(className); + + //成绩列表 + List avgDoubleList = tchClassAverageScores.stream().map(TchClassAverageScore::getAveScore).collect(Collectors.toList()); + //时间列表 + List dateList = tchClassAverageScores.stream().map(TchClassAverageScore::getCreateTime).collect(Collectors.toList()); + + ArrayList 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); + } +} diff --git a/src/main/resources/generatorConfig.xml b/src/main/resources/generatorConfig.xml index f71b4cb..89e9c6c 100644 --- a/src/main/resources/generatorConfig.xml +++ b/src/main/resources/generatorConfig.xml @@ -66,7 +66,7 @@ - +
diff --git a/src/main/resources/mappers/StuScoreCenterMapper.xml b/src/main/resources/mappers/StuScoreCenterMapper.xml index 20521ce..1f67c73 100644 --- a/src/main/resources/mappers/StuScoreCenterMapper.xml +++ b/src/main/resources/mappers/StuScoreCenterMapper.xml @@ -17,6 +17,8 @@ + + @@ -79,7 +81,7 @@ id, learning_projects, training_duration, training_total_score, score_weight, training_score, class_ranking, completion_status, user_id, module, ascription, training_score_one, - training_score_two, training_score_three, number_of_training + training_score_two, training_score_three, number_of_training, completion_time, class_name @@ -276,6 +290,12 @@ number_of_training = #{record.numberOfTraining,jdbcType=INTEGER}, + + completion_time = #{record.completionTime,jdbcType=TIMESTAMP}, + + + class_name = #{record.className,jdbcType=VARCHAR}, + @@ -297,7 +317,9 @@ training_score_one = #{record.trainingScoreOne,jdbcType=DECIMAL}, training_score_two = #{record.trainingScoreTwo,jdbcType=DECIMAL}, training_score_three = #{record.trainingScoreThree,jdbcType=DECIMAL}, - number_of_training = #{record.numberOfTraining,jdbcType=INTEGER} + number_of_training = #{record.numberOfTraining,jdbcType=INTEGER}, + completion_time = #{record.completionTime,jdbcType=TIMESTAMP}, + class_name = #{record.className,jdbcType=VARCHAR} @@ -347,6 +369,12 @@ number_of_training = #{numberOfTraining,jdbcType=INTEGER}, + + completion_time = #{completionTime,jdbcType=TIMESTAMP}, + + + class_name = #{className,jdbcType=VARCHAR}, + where id = #{id,jdbcType=INTEGER} @@ -365,7 +393,9 @@ training_score_one = #{trainingScoreOne,jdbcType=DECIMAL}, training_score_two = #{trainingScoreTwo,jdbcType=DECIMAL}, training_score_three = #{trainingScoreThree,jdbcType=DECIMAL}, - number_of_training = #{numberOfTraining,jdbcType=INTEGER} + number_of_training = #{numberOfTraining,jdbcType=INTEGER}, + completion_time = #{completionTime,jdbcType=TIMESTAMP}, + class_name = #{className,jdbcType=VARCHAR} where id = #{id,jdbcType=INTEGER} \ No newline at end of file diff --git a/src/main/resources/mappers/TchClassAverageScoreMapper.xml b/src/main/resources/mappers/TchClassAverageScoreMapper.xml new file mode 100644 index 0000000..8b5c9f9 --- /dev/null +++ b/src/main/resources/mappers/TchClassAverageScoreMapper.xml @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, class_id, class_name, create_time, ave_score + + + + + delete from tch_class_average_score + where id = #{id,jdbcType=VARCHAR} + + + delete from tch_class_average_score + + + + + + 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 into tch_class_average_score + + + id, + + + class_id, + + + class_name, + + + create_time, + + + ave_score, + + + + + #{id,jdbcType=VARCHAR}, + + + #{classId,jdbcType=VARCHAR}, + + + #{className,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{aveScore,jdbcType=DOUBLE}, + + + + + + + update tch_class_average_score + + + 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}, + + + + + + + + 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} + + + + + + update tch_class_average_score + + + 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 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} + + + + + + + + + \ No newline at end of file From 73ad74714a23a71bf43cd7bf55fb58e49b8853d3 Mon Sep 17 00:00:00 2001 From: whb <17803890193@163.com> Date: Tue, 7 May 2024 09:32:02 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=BC=80=E5=8F=91=E7=8F=AD=E7=BA=A7?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/task/StuTaskController.java | 122 +++-- .../controller/tch/TchHomePageController.java | 37 +- .../entity/TchClassAverageScore.java | 94 +++- .../entity/TchClassAverageScoreExample.java | 491 ++++++++++++++++++ .../entity/dto/ClassAVGScoreVo.java | 25 + .../entity/dto/TeaClassScoreDto.java | 217 ++++++++ .../mapper/StuScoreCenterMapper.java | 1 + .../digital_credit/mapper/StuUserMapper.java | 7 + .../mapper/TchClassAverageScoreMapper.java | 7 +- .../service/TchHomePageService.java | 15 +- .../service/impl/TchHomePageServiceImpl.java | 227 +++++--- .../mappers/TchClassAverageScoreMapper.xml | 165 +++++- 12 files changed, 1287 insertions(+), 121 deletions(-) create mode 100644 src/main/java/com/sztzjy/digital_credit/entity/dto/ClassAVGScoreVo.java create mode 100644 src/main/java/com/sztzjy/digital_credit/entity/dto/TeaClassScoreDto.java diff --git a/src/main/java/com/sztzjy/digital_credit/controller/task/StuTaskController.java b/src/main/java/com/sztzjy/digital_credit/controller/task/StuTaskController.java index b440ae0..a218408 100644 --- a/src/main/java/com/sztzjy/digital_credit/controller/task/StuTaskController.java +++ b/src/main/java/com/sztzjy/digital_credit/controller/task/StuTaskController.java @@ -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 stuUsersList = userMapper.selectByExample(userExample); - //根据学校ID查询所有的班级列表 class_name - List classNameList = stuUsersList.stream().map(StuUser::getClassName).distinct().collect(Collectors.toList()); - - for (String className : classNameList) { - - StuUserExample userExample1 = new StuUserExample(); - userExample1.createCriteria().andClassNameEqualTo(className); - //获取该班所有学生 - List userListByClassName = userMapper.selectByExample(userExample1); - //汇总总分 - List 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 classIdList = userMapper.selectClassId(); + for (String classId : classIdList) { + BigDecimal avgScore = BigDecimal.ZERO; + BigDecimal count = BigDecimal.ZERO; + + StuUserExample userExample = new StuUserExample(); + userExample.createCriteria().andClassIdEqualTo(classId); + List stuUsersList = userMapper.selectByExample(userExample); + + + // 创建存储等级人数的Map + Map 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 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("定时任务:==================执行结束======================"); - } diff --git a/src/main/java/com/sztzjy/digital_credit/controller/tch/TchHomePageController.java b/src/main/java/com/sztzjy/digital_credit/controller/tch/TchHomePageController.java index 2e92339..207f8d5 100644 --- a/src/main/java/com/sztzjy/digital_credit/controller/tch/TchHomePageController.java +++ b/src/main/java/com/sztzjy/digital_credit/controller/tch/TchHomePageController.java @@ -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> avgScoreTrendChart(String schoolId){ + public ResultEntity> avgScoreTrendChart(String schoolId){ + + List info = tchHomePageService.avgScoreTrendChart(schoolId); + return new ResultEntity<>(info); + + } + - return tchHomePageService.avgScoreTrendChart(schoolId); + + @AnonymousAccess + @GetMapping("/getClassScoreCount") + @ApiOperation("班级成绩统计分析饼状图") + public ResultEntity 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>> getClassNameBySchoolId(@RequestParam String schoolId) { + List> nameAndId = userMapper.selectClassNameBySchoolId(schoolId); + return new ResultEntity<>(nameAndId); + } + + } diff --git a/src/main/java/com/sztzjy/digital_credit/entity/TchClassAverageScore.java b/src/main/java/com/sztzjy/digital_credit/entity/TchClassAverageScore.java index d35784d..9b4a502 100644 --- a/src/main/java/com/sztzjy/digital_credit/entity/TchClassAverageScore.java +++ b/src/main/java/com/sztzjy/digital_credit/entity/TchClassAverageScore.java @@ -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(); + } } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/digital_credit/entity/TchClassAverageScoreExample.java b/src/main/java/com/sztzjy/digital_credit/entity/TchClassAverageScoreExample.java index 5f17c39..9ec6e8d 100644 --- a/src/main/java/com/sztzjy/digital_credit/entity/TchClassAverageScoreExample.java +++ b/src/main/java/com/sztzjy/digital_credit/entity/TchClassAverageScoreExample.java @@ -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 values) { + addCriterion("excellent_count in", values, "excellentCount"); + return (Criteria) this; + } + + public Criteria andExcellentCountNotIn(List 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 values) { + addCriterion("good_count in", values, "goodCount"); + return (Criteria) this; + } + + public Criteria andGoodCountNotIn(List 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 values) { + addCriterion("general_count in", values, "generalCount"); + return (Criteria) this; + } + + public Criteria andGeneralCountNotIn(List 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 values) { + addCriterion("fail_count in", values, "failCount"); + return (Criteria) this; + } + + public Criteria andFailCountNotIn(List 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 values) { + addCriterion("class_max_score in", values, "classMaxScore"); + return (Criteria) this; + } + + public Criteria andClassMaxScoreNotIn(List 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 values) { + addCriterion("class_min_score in", values, "classMinScore"); + return (Criteria) this; + } + + public Criteria andClassMinScoreNotIn(List 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 values) { + addCriterion("class_average_score in", values, "classAverageScore"); + return (Criteria) this; + } + + public Criteria andClassAverageScoreNotIn(List 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 values) { + addCriterion("school_id in", values, "schoolId"); + return (Criteria) this; + } + + public Criteria andSchoolIdNotIn(List 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 { diff --git a/src/main/java/com/sztzjy/digital_credit/entity/dto/ClassAVGScoreVo.java b/src/main/java/com/sztzjy/digital_credit/entity/dto/ClassAVGScoreVo.java new file mode 100644 index 0000000..d22bc55 --- /dev/null +++ b/src/main/java/com/sztzjy/digital_credit/entity/dto/ClassAVGScoreVo.java @@ -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 classAverageScore; + + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @ApiModelProperty("最早得分日期") + private List startTime; +} diff --git a/src/main/java/com/sztzjy/digital_credit/entity/dto/TeaClassScoreDto.java b/src/main/java/com/sztzjy/digital_credit/entity/dto/TeaClassScoreDto.java new file mode 100644 index 0000000..8b28d6e --- /dev/null +++ b/src/main/java/com/sztzjy/digital_credit/entity/dto/TeaClassScoreDto.java @@ -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; + } +} \ No newline at end of file diff --git a/src/main/java/com/sztzjy/digital_credit/mapper/StuScoreCenterMapper.java b/src/main/java/com/sztzjy/digital_credit/mapper/StuScoreCenterMapper.java index 305272f..eba6190 100644 --- a/src/main/java/com/sztzjy/digital_credit/mapper/StuScoreCenterMapper.java +++ b/src/main/java/com/sztzjy/digital_credit/mapper/StuScoreCenterMapper.java @@ -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); diff --git a/src/main/java/com/sztzjy/digital_credit/mapper/StuUserMapper.java b/src/main/java/com/sztzjy/digital_credit/mapper/StuUserMapper.java index d53056d..7e60592 100644 --- a/src/main/java/com/sztzjy/digital_credit/mapper/StuUserMapper.java +++ b/src/main/java/com/sztzjy/digital_credit/mapper/StuUserMapper.java @@ -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 selectClassId(); + @Select("select distinct(class_id),class_name from stu_user where school_id = #{schoolId}") + List> selectClassNameBySchoolId(@Param("schoolId") String schoolId); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/digital_credit/mapper/TchClassAverageScoreMapper.java b/src/main/java/com/sztzjy/digital_credit/mapper/TchClassAverageScoreMapper.java index f4e593d..c791900 100644 --- a/src/main/java/com/sztzjy/digital_credit/mapper/TchClassAverageScoreMapper.java +++ b/src/main/java/com/sztzjy/digital_credit/mapper/TchClassAverageScoreMapper.java @@ -30,5 +30,10 @@ public interface TchClassAverageScoreMapper { int updateByPrimaryKey(TchClassAverageScore record); //根据时间排序 - List selectByTime(@Param("className") String className); +// List selectByTime(@Param("className") String className); + + @Select("select class_name from tch_class_average_score where school_id = #{schoolId} group by class_name") + List selectClassNameBySchool(@Param("schoolId")String schoolId); + + List selectAndOrderByTime(@Param("schoolId")String schoolId,@Param("className")String className); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/digital_credit/service/TchHomePageService.java b/src/main/java/com/sztzjy/digital_credit/service/TchHomePageService.java index c79eb56..208cd4b 100644 --- a/src/main/java/com/sztzjy/digital_credit/service/TchHomePageService.java +++ b/src/main/java/com/sztzjy/digital_credit/service/TchHomePageService.java @@ -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 avgScoreTrendChart(String schoolId); - ResultEntity> avgScoreTrendChart(String schoolId); + /** + * 班级成绩统计分析饼状图 + * @param schoolId + * @param classId + * @param time + * @return + */ + + TeaClassScoreDto getClassScoreCount(String schoolId, String classId, Date time); } diff --git a/src/main/java/com/sztzjy/digital_credit/service/impl/TchHomePageServiceImpl.java b/src/main/java/com/sztzjy/digital_credit/service/impl/TchHomePageServiceImpl.java index 28de42d..34eb568 100644 --- a/src/main/java/com/sztzjy/digital_credit/service/impl/TchHomePageServiceImpl.java +++ b/src/main/java/com/sztzjy/digital_credit/service/impl/TchHomePageServiceImpl.java @@ -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> avgScoreTrendChart(String schoolId) { +// +// List tchAvgScoreByTimeParentDTOS = new ArrayList(); +// +// //每天平均成绩集合 +// List avgScoreListByDate = new ArrayList<>(); +// +// //根据学校ID查询所有的班级列表 class_name +// StuUserExample userExample = new StuUserExample(); +// userExample.createCriteria().andSchoolIdEqualTo(schoolId); +// +// //学校所有班级 +// List userList = userMapper.selectByExample(userExample); +// +// if (userList.isEmpty()) +// { +// return new ResultEntity<>(HttpStatus.OK,"schoolId不存在"); +// } +// +// // 查询出所有班级名 +// List distinctClassNames = userList.stream() +// .map(item -> item.getClassName()) +// .distinct() +// .collect(Collectors.toList()); +// +// //遍历所有班级 +// for (String className : distinctClassNames) { +// TchAvgScoreByTimeParentDTO tchAvgScoreByTimeParentDTO = new TchAvgScoreByTimeParentDTO(); +// +// tchAvgScoreByTimeParentDTO.setClassList(className); +// +// +// List tchClassAverageScores = tchClassAverageScoreMapper.selectByTime(className); +// +// //成绩列表 +// List avgDoubleList = tchClassAverageScores.stream().map(TchClassAverageScore::getAveScore).collect(Collectors.toList()); +// //时间列表 +// List dateList = tchClassAverageScores.stream().map(TchClassAverageScore::getCreateTime).collect(Collectors.toList()); +// +// ArrayList 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> avgScoreTrendChart( String schoolId) { - - List tchAvgScoreByTimeParentDTOS = new ArrayList(); - - - - //每天平均成绩集合 - List avgScoreListByDate = new ArrayList<>(); - - //根据学校ID查询所有的班级列表 class_name - StuUserExample userExample = new StuUserExample(); - userExample.createCriteria().andSchoolIdEqualTo(schoolId); - - //学校所有班级 - List userList = userMapper.selectByExample(userExample); - - if (userList.isEmpty()) - { - return new ResultEntity<>(HttpStatus.OK,"schoolId不存在"); + public List avgScoreTrendChart(String schoolId) { + List classNameList = tchClassAverageScoreMapper.selectClassNameBySchool(schoolId); + List voList = new ArrayList<>(); + for (String className : classNameList) { + ClassAVGScoreVo vo = new ClassAVGScoreVo(); + vo.setClassName(className); + List list = tchClassAverageScoreMapper.selectAndOrderByTime(schoolId, className); + if (list.isEmpty()) { + continue; + } + List scoreList = new ArrayList(); + List 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 distinctClassNames = userList.stream() - .map(item -> item.getClassName()) - .distinct() - .collect(Collectors.toList()); - - //遍历所有班级 - for (String className : distinctClassNames) { - TchAvgScoreByTimeParentDTO tchAvgScoreByTimeParentDTO = new TchAvgScoreByTimeParentDTO(); - - tchAvgScoreByTimeParentDTO.setClassList(className); - - - List tchClassAverageScores = tchClassAverageScoreMapper.selectByTime(className); - - //成绩列表 - List avgDoubleList = tchClassAverageScores.stream().map(TchClassAverageScore::getAveScore).collect(Collectors.toList()); - //时间列表 - List dateList = tchClassAverageScores.stream().map(TchClassAverageScore::getCreateTime).collect(Collectors.toList()); - - ArrayList 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 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 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); } + } diff --git a/src/main/resources/mappers/TchClassAverageScoreMapper.xml b/src/main/resources/mappers/TchClassAverageScoreMapper.xml index 8b5c9f9..29a2e6f 100644 --- a/src/main/resources/mappers/TchClassAverageScoreMapper.xml +++ b/src/main/resources/mappers/TchClassAverageScoreMapper.xml @@ -7,6 +7,14 @@ + + + + + + + + @@ -67,7 +75,8 @@ - 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 @@ -148,8 +211,7 @@ - - + update tch_class_average_score @@ -167,6 +229,30 @@ 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}, + @@ -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} @@ -198,6 +292,30 @@ 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} @@ -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} - - select from tch_class_average_score - where - - class_name = #{className,jdbcType=VARCHAR} - + 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 - - - \ No newline at end of file From b34a28edcf88f0d86faa93d9c6a8b5a0443faf15 Mon Sep 17 00:00:00 2001 From: whb <17803890193@163.com> Date: Wed, 8 May 2024 09:45:49 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=95=99=E5=B8=88?= =?UTF-8?q?=E7=AB=AF=E6=88=90=E7=BB=A9=E6=80=BB=E8=A7=88=E6=89=80=E6=9C=89?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StuExperimentTrainByCreditController.java | 2 - .../controller/task/StuTaskController.java | 5 - .../tch/TchGeneralViewController.java | 112 ++++++++ .../sztzjy/digital_credit/entity/StuUser.java | 26 ++ .../digital_credit/entity/TchModuleWeith.java | 48 +++- .../entity/TchModuleWeithExample.java | 240 ++++++++++++++++++ .../tchdto/ScoreOverviewParametesDTO.java | 28 ++ .../entity/tchdto/TchGeneralViewDTO.java | 161 ++++++++++++ .../tchdto/TchGeneralViewWeightDTO.java | 26 ++ .../digital_credit/mapper/StuUserMapper.java | 3 + .../mapper/TchModuleWeithMapper.java | 4 +- .../service/StuUserService.java | 30 +++ .../StuEnterPriseByInfoEntryServiceImpl.java | 2 - .../service/impl/StuRateServiceImpl.java | 5 - .../service/impl/StuUserServiceImpl.java | 158 ++++++++++++ src/main/resources/application-dev.yml | 4 +- src/main/resources/mappers/StuUserMapper.xml | 111 ++++++++ .../mappers/TchModuleWeithMapper.xml | 75 +++++- 18 files changed, 1015 insertions(+), 25 deletions(-) create mode 100644 src/main/java/com/sztzjy/digital_credit/controller/tch/TchGeneralViewController.java create mode 100644 src/main/java/com/sztzjy/digital_credit/entity/tchdto/ScoreOverviewParametesDTO.java create mode 100644 src/main/java/com/sztzjy/digital_credit/entity/tchdto/TchGeneralViewDTO.java create mode 100644 src/main/java/com/sztzjy/digital_credit/entity/tchdto/TchGeneralViewWeightDTO.java create mode 100644 src/main/java/com/sztzjy/digital_credit/service/StuUserService.java create mode 100644 src/main/java/com/sztzjy/digital_credit/service/impl/StuUserServiceImpl.java diff --git a/src/main/java/com/sztzjy/digital_credit/controller/StuExperimentTrainByCreditController.java b/src/main/java/com/sztzjy/digital_credit/controller/StuExperimentTrainByCreditController.java index 96398cf..2fb99cf 100644 --- a/src/main/java/com/sztzjy/digital_credit/controller/StuExperimentTrainByCreditController.java +++ b/src/main/java/com/sztzjy/digital_credit/controller/StuExperimentTrainByCreditController.java @@ -33,8 +33,6 @@ import java.util.List; @Api(tags = "数字征信实验实训") public class StuExperimentTrainByCreditController { - - @Autowired private StuExperimentTrainByCreditService experimentTrainByCreditService; diff --git a/src/main/java/com/sztzjy/digital_credit/controller/task/StuTaskController.java b/src/main/java/com/sztzjy/digital_credit/controller/task/StuTaskController.java index a218408..2f09769 100644 --- a/src/main/java/com/sztzjy/digital_credit/controller/task/StuTaskController.java +++ b/src/main/java/com/sztzjy/digital_credit/controller/task/StuTaskController.java @@ -51,11 +51,6 @@ public class StuTaskController { private StuUserMapper userMapper; - @Autowired - private StuScoreCenterMapper scoreCenterMapper; - - - // 计算每天每个班级的平均成绩 每天00.00执行 @Scheduled(cron = "0 0 0 * * ?") public void getClassScore() { diff --git a/src/main/java/com/sztzjy/digital_credit/controller/tch/TchGeneralViewController.java b/src/main/java/com/sztzjy/digital_credit/controller/tch/TchGeneralViewController.java new file mode 100644 index 0000000..811289e --- /dev/null +++ b/src/main/java/com/sztzjy/digital_credit/controller/tch/TchGeneralViewController.java @@ -0,0 +1,112 @@ +package com.sztzjy.digital_credit.controller.tch; + +import cn.hutool.core.util.IdUtil; +import com.github.pagehelper.PageInfo; + +import com.sztzjy.digital_credit.annotation.AnonymousAccess; +import com.sztzjy.digital_credit.entity.TchModuleWeith; +import com.sztzjy.digital_credit.entity.TchModuleWeithExample; +import com.sztzjy.digital_credit.entity.tchdto.ScoreOverviewParametesDTO; +import com.sztzjy.digital_credit.entity.tchdto.TchGeneralViewDTO; +import com.sztzjy.digital_credit.entity.tchdto.TchGeneralViewWeightDTO; +import com.sztzjy.digital_credit.mapper.TchModuleWeithMapper; +import com.sztzjy.digital_credit.service.StuUserService; +import com.sztzjy.digital_credit.util.ResultEntity; +import com.sztzjy.digital_credit.util.excel.FilePortUtil; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.Arrays; +import java.util.List; + + +//教师端成绩总览 +@RestController +@RequestMapping("/api/tch/generalView") +public class TchGeneralViewController { + @Autowired + StuUserService userService; + + @Autowired + private TchModuleWeithMapper tchModuleWeithMapper; + + + + +// @Autowired +// ISysTchResultsOverviewWeightService resultsOverviewWeightService; +// @Autowired +// private ISysTchRankService rankService; + + + + @PostMapping("/getGeneralViewList") + @AnonymousAccess + @ApiOperation("成绩总览展示(条件查询)") + public ResultEntity getGeneralViewList(@RequestBody ScoreOverviewParametesDTO parametes) { + + PageInfo pageInfo = userService.selectGeneralViewList(parametes); + return new ResultEntity(HttpStatus.OK, "成绩总览展示", pageInfo); + } + + + + + @AnonymousAccess + @GetMapping("/generalViewExport") + @ApiOperation("成绩总览导出") + public void generalViewExport(HttpServletResponse response, @RequestParam String schoolId) { + //导出的表名 + String title = IdUtil.simpleUUID(); + //表中第一行表头字段 + String[] headers = {"姓名", "学号", "班级","征信画像成绩","个人征信成绩","企业征信成绩","综合案例成绩","总成绩","排名"}; + + //实际数据结果集 + List tchGeneralViewDTOS = userService.selectAllGeneralViewList(schoolId); + //具体需要写入excel需要哪些字段,这些字段取自UserReward类,也就是上面的实际数据结果集的泛型 + List listColumn = Arrays.asList("name", "studentId" + , "className", "creditPortraitScore","personalCreditScore", + "corporateCreditScore","comprehensiveCaseScore","totalScore","totalRank"); + try { + FilePortUtil.exportExcel(response, title, headers, tchGeneralViewDTOS, listColumn); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + @ApiOperation("成绩总览权重回显") + @AnonymousAccess + @GetMapping("/getResultsOverviewWeight") + public ResultEntity getResultsOverviewWeight(@RequestParam String schoolId) { + //根据学校id 查询权重表中 学校成绩总览权重 + TchModuleWeithExample tchModuleWeithExample = new TchModuleWeithExample(); + tchModuleWeithExample.createCriteria().andSchoolIdEqualTo(schoolId); + List tchModuleWeithList = tchModuleWeithMapper.selectByExample(tchModuleWeithExample); + return new ResultEntity(HttpStatus.OK, "成绩总览权重回显", tchModuleWeithList.get(0)); + } + + + + + + + @AnonymousAccess + @PostMapping("/setResultsOverviewWeight") + @ApiOperation("成绩总览权重设置") + public ResultEntity setResultsOverviewWeight(@RequestBody TchGeneralViewWeightDTO generalViewWeightDTO){ + Boolean b = userService.updateWeight(generalViewWeightDTO); + userService.totalRank(generalViewWeightDTO.getSchoolId()); + if (b == true) { + return new ResultEntity(HttpStatus.OK, "成绩总览权重设置成功"); + } + return new ResultEntity(HttpStatus.BAD_REQUEST, "成绩总览权重设置失败"); + } + + + + +} diff --git a/src/main/java/com/sztzjy/digital_credit/entity/StuUser.java b/src/main/java/com/sztzjy/digital_credit/entity/StuUser.java index 0504c22..e894dd0 100644 --- a/src/main/java/com/sztzjy/digital_credit/entity/StuUser.java +++ b/src/main/java/com/sztzjy/digital_credit/entity/StuUser.java @@ -117,6 +117,32 @@ public class StuUser { @ApiModelProperty("综合得分(学校)(乘完权重后)") private BigDecimal totalScore; + + + public StuUser(StuUser stuUser, TchModuleWeith resultsOverviewWeight) { + this.userId=stuUser.getUserId(); + //征信画像 + BigDecimal creditPortraitScore =stuUser.getLoanCasesScore().add(stuUser.getPerSituationScore()).add(stuUser.getRepaymentBehaviorScore()).divide(BigDecimal.valueOf(3)).multiply(resultsOverviewWeight.getCreditPortraitWeith()).setScale(2,BigDecimal.ROUND_HALF_UP); + //个人征信 + BigDecimal personalCreditScore=stuUser.getPerInfluenceFactorScore().add(stuUser.getPerCreditOptimizationSocre()).add(stuUser.getPerCreditRatingSocre()).divide(BigDecimal.valueOf(3)).multiply(resultsOverviewWeight.getPersonalCreditWeith()).setScale(2,BigDecimal.ROUND_HALF_UP); + //企业征信 + BigDecimal corporateCreditScore=stuUser.getEntInfluenceFactorSocre().add(stuUser.getEntCreditOptimizationSocre()).add(stuUser.getEntCreditRatingSocre()).divide(BigDecimal.valueOf(3)).multiply(resultsOverviewWeight.getEnterpriseCreditWeith()).setScale(2,BigDecimal.ROUND_HALF_UP); + //综合案例 + BigDecimal comprehensiveCaseScore=stuUser.getCaseUserProfileSocre().add(stuUser.getCasePersonalCreditScore()).add(stuUser.getCaseCorporateCreditScore()).divide(BigDecimal.valueOf(3)).multiply(resultsOverviewWeight.getCaseStudyWeith()).setScale(2,BigDecimal.ROUND_HALF_UP); + + + this.totalScore= creditPortraitScore.add(personalCreditScore).add(corporateCreditScore) + .add(comprehensiveCaseScore).setScale(2,BigDecimal.ROUND_HALF_UP); + + } + + public StuUser() { + } + + + + + public String getUserId() { return userId; } diff --git a/src/main/java/com/sztzjy/digital_credit/entity/TchModuleWeith.java b/src/main/java/com/sztzjy/digital_credit/entity/TchModuleWeith.java index dc91c27..7c1a717 100644 --- a/src/main/java/com/sztzjy/digital_credit/entity/TchModuleWeith.java +++ b/src/main/java/com/sztzjy/digital_credit/entity/TchModuleWeith.java @@ -6,7 +6,7 @@ import java.util.UUID; import io.swagger.annotations.ApiModelProperty; /** * - * @author tz + * @author whb * tch_module_weith */ public class TchModuleWeith { @@ -52,6 +52,19 @@ public class TchModuleWeith { @ApiModelProperty("案例-企业征信权重") private BigDecimal caseCorporateCreditWeith; + @ApiModelProperty("征信画像成绩权重") + private BigDecimal creditPortraitWeith; + + @ApiModelProperty("个人征信成绩权重") + private BigDecimal personalCreditWeith; + + @ApiModelProperty("企业征信成绩权重") + private BigDecimal enterpriseCreditWeith; + + @ApiModelProperty("综合案例成绩权重") + private BigDecimal caseStudyWeith; + + public TchModuleWeith(){ } @@ -75,6 +88,7 @@ public class TchModuleWeith { this.caseCorporateCreditWeith=BigDecimal.valueOf(0.3); } + public Integer getId() { return id; } @@ -186,4 +200,36 @@ public class TchModuleWeith { public void setCaseCorporateCreditWeith(BigDecimal caseCorporateCreditWeith) { this.caseCorporateCreditWeith = caseCorporateCreditWeith; } + + public BigDecimal getCreditPortraitWeith() { + return creditPortraitWeith; + } + + public void setCreditPortraitWeith(BigDecimal creditPortraitWeith) { + this.creditPortraitWeith = creditPortraitWeith; + } + + public BigDecimal getPersonalCreditWeith() { + return personalCreditWeith; + } + + public void setPersonalCreditWeith(BigDecimal personalCreditWeith) { + this.personalCreditWeith = personalCreditWeith; + } + + public BigDecimal getEnterpriseCreditWeith() { + return enterpriseCreditWeith; + } + + public void setEnterpriseCreditWeith(BigDecimal enterpriseCreditWeith) { + this.enterpriseCreditWeith = enterpriseCreditWeith; + } + + public BigDecimal getCaseStudyWeith() { + return caseStudyWeith; + } + + public void setCaseStudyWeith(BigDecimal caseStudyWeith) { + this.caseStudyWeith = caseStudyWeith; + } } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/digital_credit/entity/TchModuleWeithExample.java b/src/main/java/com/sztzjy/digital_credit/entity/TchModuleWeithExample.java index 4201637..e665ad8 100644 --- a/src/main/java/com/sztzjy/digital_credit/entity/TchModuleWeithExample.java +++ b/src/main/java/com/sztzjy/digital_credit/entity/TchModuleWeithExample.java @@ -954,6 +954,246 @@ public class TchModuleWeithExample { addCriterion("case_corporate_credit_weith not between", value1, value2, "caseCorporateCreditWeith"); return (Criteria) this; } + + public Criteria andCreditPortraitWeithIsNull() { + addCriterion("credit_portrait_weith is null"); + return (Criteria) this; + } + + public Criteria andCreditPortraitWeithIsNotNull() { + addCriterion("credit_portrait_weith is not null"); + return (Criteria) this; + } + + public Criteria andCreditPortraitWeithEqualTo(BigDecimal value) { + addCriterion("credit_portrait_weith =", value, "creditPortraitWeith"); + return (Criteria) this; + } + + public Criteria andCreditPortraitWeithNotEqualTo(BigDecimal value) { + addCriterion("credit_portrait_weith <>", value, "creditPortraitWeith"); + return (Criteria) this; + } + + public Criteria andCreditPortraitWeithGreaterThan(BigDecimal value) { + addCriterion("credit_portrait_weith >", value, "creditPortraitWeith"); + return (Criteria) this; + } + + public Criteria andCreditPortraitWeithGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("credit_portrait_weith >=", value, "creditPortraitWeith"); + return (Criteria) this; + } + + public Criteria andCreditPortraitWeithLessThan(BigDecimal value) { + addCriterion("credit_portrait_weith <", value, "creditPortraitWeith"); + return (Criteria) this; + } + + public Criteria andCreditPortraitWeithLessThanOrEqualTo(BigDecimal value) { + addCriterion("credit_portrait_weith <=", value, "creditPortraitWeith"); + return (Criteria) this; + } + + public Criteria andCreditPortraitWeithIn(List values) { + addCriterion("credit_portrait_weith in", values, "creditPortraitWeith"); + return (Criteria) this; + } + + public Criteria andCreditPortraitWeithNotIn(List values) { + addCriterion("credit_portrait_weith not in", values, "creditPortraitWeith"); + return (Criteria) this; + } + + public Criteria andCreditPortraitWeithBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("credit_portrait_weith between", value1, value2, "creditPortraitWeith"); + return (Criteria) this; + } + + public Criteria andCreditPortraitWeithNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("credit_portrait_weith not between", value1, value2, "creditPortraitWeith"); + return (Criteria) this; + } + + public Criteria andPersonalCreditWeithIsNull() { + addCriterion("personal_credit_weith is null"); + return (Criteria) this; + } + + public Criteria andPersonalCreditWeithIsNotNull() { + addCriterion("personal_credit_weith is not null"); + return (Criteria) this; + } + + public Criteria andPersonalCreditWeithEqualTo(BigDecimal value) { + addCriterion("personal_credit_weith =", value, "personalCreditWeith"); + return (Criteria) this; + } + + public Criteria andPersonalCreditWeithNotEqualTo(BigDecimal value) { + addCriterion("personal_credit_weith <>", value, "personalCreditWeith"); + return (Criteria) this; + } + + public Criteria andPersonalCreditWeithGreaterThan(BigDecimal value) { + addCriterion("personal_credit_weith >", value, "personalCreditWeith"); + return (Criteria) this; + } + + public Criteria andPersonalCreditWeithGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("personal_credit_weith >=", value, "personalCreditWeith"); + return (Criteria) this; + } + + public Criteria andPersonalCreditWeithLessThan(BigDecimal value) { + addCriterion("personal_credit_weith <", value, "personalCreditWeith"); + return (Criteria) this; + } + + public Criteria andPersonalCreditWeithLessThanOrEqualTo(BigDecimal value) { + addCriterion("personal_credit_weith <=", value, "personalCreditWeith"); + return (Criteria) this; + } + + public Criteria andPersonalCreditWeithIn(List values) { + addCriterion("personal_credit_weith in", values, "personalCreditWeith"); + return (Criteria) this; + } + + public Criteria andPersonalCreditWeithNotIn(List values) { + addCriterion("personal_credit_weith not in", values, "personalCreditWeith"); + return (Criteria) this; + } + + public Criteria andPersonalCreditWeithBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("personal_credit_weith between", value1, value2, "personalCreditWeith"); + return (Criteria) this; + } + + public Criteria andPersonalCreditWeithNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("personal_credit_weith not between", value1, value2, "personalCreditWeith"); + return (Criteria) this; + } + + public Criteria andEnterpriseCreditWeithIsNull() { + addCriterion("enterprise_credit_weith is null"); + return (Criteria) this; + } + + public Criteria andEnterpriseCreditWeithIsNotNull() { + addCriterion("enterprise_credit_weith is not null"); + return (Criteria) this; + } + + public Criteria andEnterpriseCreditWeithEqualTo(BigDecimal value) { + addCriterion("enterprise_credit_weith =", value, "enterpriseCreditWeith"); + return (Criteria) this; + } + + public Criteria andEnterpriseCreditWeithNotEqualTo(BigDecimal value) { + addCriterion("enterprise_credit_weith <>", value, "enterpriseCreditWeith"); + return (Criteria) this; + } + + public Criteria andEnterpriseCreditWeithGreaterThan(BigDecimal value) { + addCriterion("enterprise_credit_weith >", value, "enterpriseCreditWeith"); + return (Criteria) this; + } + + public Criteria andEnterpriseCreditWeithGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("enterprise_credit_weith >=", value, "enterpriseCreditWeith"); + return (Criteria) this; + } + + public Criteria andEnterpriseCreditWeithLessThan(BigDecimal value) { + addCriterion("enterprise_credit_weith <", value, "enterpriseCreditWeith"); + return (Criteria) this; + } + + public Criteria andEnterpriseCreditWeithLessThanOrEqualTo(BigDecimal value) { + addCriterion("enterprise_credit_weith <=", value, "enterpriseCreditWeith"); + return (Criteria) this; + } + + public Criteria andEnterpriseCreditWeithIn(List values) { + addCriterion("enterprise_credit_weith in", values, "enterpriseCreditWeith"); + return (Criteria) this; + } + + public Criteria andEnterpriseCreditWeithNotIn(List values) { + addCriterion("enterprise_credit_weith not in", values, "enterpriseCreditWeith"); + return (Criteria) this; + } + + public Criteria andEnterpriseCreditWeithBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("enterprise_credit_weith between", value1, value2, "enterpriseCreditWeith"); + return (Criteria) this; + } + + public Criteria andEnterpriseCreditWeithNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("enterprise_credit_weith not between", value1, value2, "enterpriseCreditWeith"); + return (Criteria) this; + } + + public Criteria andCaseStudyWeithIsNull() { + addCriterion("case_study_weith is null"); + return (Criteria) this; + } + + public Criteria andCaseStudyWeithIsNotNull() { + addCriterion("case_study_weith is not null"); + return (Criteria) this; + } + + public Criteria andCaseStudyWeithEqualTo(BigDecimal value) { + addCriterion("case_study_weith =", value, "caseStudyWeith"); + return (Criteria) this; + } + + public Criteria andCaseStudyWeithNotEqualTo(BigDecimal value) { + addCriterion("case_study_weith <>", value, "caseStudyWeith"); + return (Criteria) this; + } + + public Criteria andCaseStudyWeithGreaterThan(BigDecimal value) { + addCriterion("case_study_weith >", value, "caseStudyWeith"); + return (Criteria) this; + } + + public Criteria andCaseStudyWeithGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("case_study_weith >=", value, "caseStudyWeith"); + return (Criteria) this; + } + + public Criteria andCaseStudyWeithLessThan(BigDecimal value) { + addCriterion("case_study_weith <", value, "caseStudyWeith"); + return (Criteria) this; + } + + public Criteria andCaseStudyWeithLessThanOrEqualTo(BigDecimal value) { + addCriterion("case_study_weith <=", value, "caseStudyWeith"); + return (Criteria) this; + } + + public Criteria andCaseStudyWeithIn(List values) { + addCriterion("case_study_weith in", values, "caseStudyWeith"); + return (Criteria) this; + } + + public Criteria andCaseStudyWeithNotIn(List values) { + addCriterion("case_study_weith not in", values, "caseStudyWeith"); + return (Criteria) this; + } + + public Criteria andCaseStudyWeithBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("case_study_weith between", value1, value2, "caseStudyWeith"); + return (Criteria) this; + } + + public Criteria andCaseStudyWeithNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("case_study_weith not between", value1, value2, "caseStudyWeith"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/src/main/java/com/sztzjy/digital_credit/entity/tchdto/ScoreOverviewParametesDTO.java b/src/main/java/com/sztzjy/digital_credit/entity/tchdto/ScoreOverviewParametesDTO.java new file mode 100644 index 0000000..5d8abcc --- /dev/null +++ b/src/main/java/com/sztzjy/digital_credit/entity/tchdto/ScoreOverviewParametesDTO.java @@ -0,0 +1,28 @@ +package com.sztzjy.digital_credit.entity.tchdto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author 17803 + * @date 2024-05-07 10:03 + */ + +@Data +public class ScoreOverviewParametesDTO { + + private String schoolId; + @ApiModelProperty("用户名") + private String name; + @ApiModelProperty("学号") + private String studentId; + private String className; + + private Integer size; + + private Integer index; + + + + +} diff --git a/src/main/java/com/sztzjy/digital_credit/entity/tchdto/TchGeneralViewDTO.java b/src/main/java/com/sztzjy/digital_credit/entity/tchdto/TchGeneralViewDTO.java new file mode 100644 index 0000000..74cb956 --- /dev/null +++ b/src/main/java/com/sztzjy/digital_credit/entity/tchdto/TchGeneralViewDTO.java @@ -0,0 +1,161 @@ +package com.sztzjy.digital_credit.entity.tchdto; + + + +import com.sztzjy.digital_credit.entity.StuUser; +import com.sztzjy.digital_credit.entity.TchModuleWeith; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class TchGeneralViewDTO { + + @ApiModelProperty("姓名") + private String name; + + @ApiModelProperty("学校ID") + private String schoolId; + + @ApiModelProperty("学号") + private String studentId; + + @ApiModelProperty("班级名称") + private String className; + + @ApiModelProperty("贷款案例成绩") + private BigDecimal loanCasesScore; + + @ApiModelProperty("个人情况与违约成绩") + private BigDecimal perSituationScore; + + @ApiModelProperty("还款行为与违约成绩") + private BigDecimal repaymentBehaviorScore; + + @ApiModelProperty("个人征信-影响因素与分析成绩") + private BigDecimal perInfluenceFactorScore; + + @ApiModelProperty("个人征信-征信优化与分析成绩") + private BigDecimal perCreditOptimizationSocre; + + @ApiModelProperty("个人征信-征信评级模型成绩") + private BigDecimal perCreditRatingSocre; + + @ApiModelProperty("企业征信-影响因素与分析成绩") + private BigDecimal entInfluenceFactorSocre; + + @ApiModelProperty("企业征信-征信优化与分析成绩") + private BigDecimal entCreditOptimizationSocre; + + @ApiModelProperty("企业征信-征信评级模型成绩") + private BigDecimal entCreditRatingSocre; + + @ApiModelProperty("案例-用户画像成绩") + private BigDecimal caseUserProfileSocre; + + @ApiModelProperty("案例-个人征信总成绩") + private BigDecimal casePersonalCreditScore; + + @ApiModelProperty("案例-企业征信总成绩") + private BigDecimal caseCorporateCreditScore; + + @ApiModelProperty("案例-企业征信主观成绩") + private BigDecimal caseCorporateCreditSubScore; + + @ApiModelProperty("案例-企业征信客观成绩") + private BigDecimal caseCorporateCreditObjScore; + + @ApiModelProperty("案例-个人征信主观成绩") + private BigDecimal casePersonalCreditSubScore; + + @ApiModelProperty("案例-个人征信客观成绩") + private BigDecimal casePersonalCreditObjScore; + + @ApiModelProperty("征信画像成绩") + private BigDecimal creditPortraitScore; + + @ApiModelProperty("征信画像排名") + private Integer creditPortraitRank; + + @ApiModelProperty("个人征信总成绩") + private BigDecimal personalCreditScore; + + @ApiModelProperty("个人征信排名") + private Integer personalCreditRank; + + @ApiModelProperty("企业征信总成绩") + private BigDecimal corporateCreditScore; + + @ApiModelProperty("企业征信排名") + private Integer corporateCreditRank; + + @ApiModelProperty("综合案例总成绩") + private BigDecimal comprehensiveCaseScore; + + @ApiModelProperty("综合案例排名") + private Integer comprehensiveCaseRank; + + @ApiModelProperty("总排名(学校)") + private Integer totalRank; + + @ApiModelProperty("综合得分(学校)(乘完权重后)") + private BigDecimal totalScore; + + + @ApiModelProperty("征信画像成绩权重") + private BigDecimal creditPortraitWeith; + + @ApiModelProperty("个人征信成绩权重") + private BigDecimal personalCreditWeith; + + @ApiModelProperty("企业征信成绩权重") + private BigDecimal enterpriseCreditWeith; + + @ApiModelProperty("综合案例成绩权重") + private BigDecimal caseStudyWeith; + + + public TchGeneralViewDTO() { + } + + public TchGeneralViewDTO(StuUser stuUser, TchModuleWeith resultsOverviewWeight) { + this.name=stuUser.getName(); + this.studentId=stuUser.getStudentId(); + this.className=stuUser.getClassName(); + + //征信画像 + this.creditPortraitScore=stuUser.getLoanCasesScore().add(stuUser.getPerSituationScore()).add(stuUser.getRepaymentBehaviorScore()).divide(BigDecimal.valueOf(3)).multiply(resultsOverviewWeight.getCreditPortraitWeith()).setScale(2,BigDecimal.ROUND_HALF_UP); + this.creditPortraitWeith=resultsOverviewWeight.getCreditPortraitWeith(); + if(stuUser.getCreditPortraitRank()!=null){ + this.creditPortraitRank=stuUser.getCreditPortraitRank(); + } + + //个人征信 + this.personalCreditScore=stuUser.getPerInfluenceFactorScore().add(stuUser.getPerCreditOptimizationSocre()).add(stuUser.getPerCreditRatingSocre()).divide(BigDecimal.valueOf(3)).multiply(resultsOverviewWeight.getPersonalCreditWeith()).setScale(2,BigDecimal.ROUND_HALF_UP); + this.personalCreditWeith=resultsOverviewWeight.getPersonalCreditWeith(); + if(stuUser.getPersonalCreditRank()!=null){ + this.personalCreditRank=stuUser.getPersonalCreditRank(); + } + + //企业征信 + this.corporateCreditScore=stuUser.getEntInfluenceFactorSocre().add(stuUser.getEntCreditOptimizationSocre()).add(stuUser.getEntCreditRatingSocre()).divide(BigDecimal.valueOf(3)).multiply(resultsOverviewWeight.getEnterpriseCreditWeith()).setScale(2,BigDecimal.ROUND_HALF_UP); + this.enterpriseCreditWeith=resultsOverviewWeight.getEnterpriseCreditWeith(); + if(stuUser.getCorporateCreditRank()!=null){ + this.corporateCreditRank=stuUser.getCorporateCreditRank(); + } + + //综合案例 + this.comprehensiveCaseScore=stuUser.getCaseUserProfileSocre().add(stuUser.getCasePersonalCreditScore()).add(stuUser.getCaseCorporateCreditScore()).divide(BigDecimal.valueOf(3)).multiply(resultsOverviewWeight.getCaseStudyWeith()).setScale(2,BigDecimal.ROUND_HALF_UP); + this.caseStudyWeith=resultsOverviewWeight.getCaseStudyWeith(); + if(stuUser.getComprehensiveCaseRank()!=null){ + this.comprehensiveCaseRank=stuUser.getComprehensiveCaseRank(); + } + + + this.totalScore=stuUser.getTotalScore(); + if(stuUser.getTotalRank()!=null){ + this.totalRank=stuUser.getTotalRank(); + } + } +} diff --git a/src/main/java/com/sztzjy/digital_credit/entity/tchdto/TchGeneralViewWeightDTO.java b/src/main/java/com/sztzjy/digital_credit/entity/tchdto/TchGeneralViewWeightDTO.java new file mode 100644 index 0000000..d22b770 --- /dev/null +++ b/src/main/java/com/sztzjy/digital_credit/entity/tchdto/TchGeneralViewWeightDTO.java @@ -0,0 +1,26 @@ +package com.sztzjy.digital_credit.entity.tchdto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class TchGeneralViewWeightDTO { + + private String schoolId; //学校ID + + @ApiModelProperty("征信画像成绩权重") + private BigDecimal creditPortraitWeith; + + @ApiModelProperty("个人征信成绩权重") + private BigDecimal personalCreditWeith; + + @ApiModelProperty("企业征信成绩权重") + private BigDecimal enterpriseCreditWeith; + + @ApiModelProperty("综合案例成绩权重") + private BigDecimal caseStudyWeith; + + +} diff --git a/src/main/java/com/sztzjy/digital_credit/mapper/StuUserMapper.java b/src/main/java/com/sztzjy/digital_credit/mapper/StuUserMapper.java index 7e60592..2164ca6 100644 --- a/src/main/java/com/sztzjy/digital_credit/mapper/StuUserMapper.java +++ b/src/main/java/com/sztzjy/digital_credit/mapper/StuUserMapper.java @@ -36,4 +36,7 @@ public interface StuUserMapper { @Select("select distinct(class_id),class_name from stu_user where school_id = #{schoolId}") List> selectClassNameBySchoolId(@Param("schoolId") String schoolId); + + //批量更新排名 + void updateBatch(List list); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/digital_credit/mapper/TchModuleWeithMapper.java b/src/main/java/com/sztzjy/digital_credit/mapper/TchModuleWeithMapper.java index 854ac44..5037ff7 100644 --- a/src/main/java/com/sztzjy/digital_credit/mapper/TchModuleWeithMapper.java +++ b/src/main/java/com/sztzjy/digital_credit/mapper/TchModuleWeithMapper.java @@ -3,10 +3,8 @@ package com.sztzjy.digital_credit.mapper; import com.sztzjy.digital_credit.entity.TchModuleWeith; import com.sztzjy.digital_credit.entity.TchModuleWeithExample; import java.util.List; - -import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; -@Mapper + public interface TchModuleWeithMapper { long countByExample(TchModuleWeithExample example); diff --git a/src/main/java/com/sztzjy/digital_credit/service/StuUserService.java b/src/main/java/com/sztzjy/digital_credit/service/StuUserService.java new file mode 100644 index 0000000..ffcd7de --- /dev/null +++ b/src/main/java/com/sztzjy/digital_credit/service/StuUserService.java @@ -0,0 +1,30 @@ +package com.sztzjy.digital_credit.service; + +import com.github.pagehelper.PageInfo; +import com.sztzjy.digital_credit.entity.tchdto.ScoreOverviewParametesDTO; +import com.sztzjy.digital_credit.entity.tchdto.TchGeneralViewDTO; +import com.sztzjy.digital_credit.entity.tchdto.TchGeneralViewWeightDTO; + +import java.util.List; + +/** + * @author 17803 + * @date 2024-05-07 9:57 + */ +public interface StuUserService { + + + /** + * 成绩总览展示(条件查询) + * @param parametes + * @return + */ + + PageInfo selectGeneralViewList(ScoreOverviewParametesDTO parametes); + + List selectAllGeneralViewList(String schoolId); + + Boolean updateWeight(TchGeneralViewWeightDTO generalViewWeightDTO); + + void totalRank(String schoolId); +} diff --git a/src/main/java/com/sztzjy/digital_credit/service/impl/StuEnterPriseByInfoEntryServiceImpl.java b/src/main/java/com/sztzjy/digital_credit/service/impl/StuEnterPriseByInfoEntryServiceImpl.java index f431a2e..1705a40 100644 --- a/src/main/java/com/sztzjy/digital_credit/service/impl/StuEnterPriseByInfoEntryServiceImpl.java +++ b/src/main/java/com/sztzjy/digital_credit/service/impl/StuEnterPriseByInfoEntryServiceImpl.java @@ -822,8 +822,6 @@ public class StuEnterPriseByInfoEntryServiceImpl implements StuEnterPriseByInfoE @Override public ResultEntity getFinancialDuPontAnalysisBySub(StuDuPontAnalysis duPontAnalysis) { - - //判断是否为第一次提交 StuDuPontAnalysisExample duPontAnalysisExample = new StuDuPontAnalysisExample(); duPontAnalysisExample.createCriteria().andUserIdEqualTo(duPontAnalysis.getUserId()); diff --git a/src/main/java/com/sztzjy/digital_credit/service/impl/StuRateServiceImpl.java b/src/main/java/com/sztzjy/digital_credit/service/impl/StuRateServiceImpl.java index ee07d9f..3ddf69b 100644 --- a/src/main/java/com/sztzjy/digital_credit/service/impl/StuRateServiceImpl.java +++ b/src/main/java/com/sztzjy/digital_credit/service/impl/StuRateServiceImpl.java @@ -818,7 +818,6 @@ public class StuRateServiceImpl implements StuRateService { //企业征信将成绩写入用户表,计算总成绩 public void enterScoreWriteUserByUserId(Object obj,String module,String userId) { - Class aClass = obj.getClass(); @@ -856,8 +855,6 @@ public class StuRateServiceImpl implements StuRateService { map.put("评级结果",6); - - Integer currentCount = map.get(module); //获取正确得分 @@ -867,8 +864,6 @@ public class StuRateServiceImpl implements StuRateService { info = 0; } - - StuUser user = userMapper.selectByPrimaryKey(userId); //获取用户 企业征信 客观成绩 BigDecimal caseCorporateCreditObjScore = user.getCaseCorporateCreditObjScore(); diff --git a/src/main/java/com/sztzjy/digital_credit/service/impl/StuUserServiceImpl.java b/src/main/java/com/sztzjy/digital_credit/service/impl/StuUserServiceImpl.java new file mode 100644 index 0000000..156b325 --- /dev/null +++ b/src/main/java/com/sztzjy/digital_credit/service/impl/StuUserServiceImpl.java @@ -0,0 +1,158 @@ +package com.sztzjy.digital_credit.service.impl;/** + * @author 17803 + * @date 2024-05-07 9:58 + */ + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.sztzjy.digital_credit.entity.StuUser; +import com.sztzjy.digital_credit.entity.StuUserExample; +import com.sztzjy.digital_credit.entity.TchModuleWeith; +import com.sztzjy.digital_credit.entity.TchModuleWeithExample; +import com.sztzjy.digital_credit.entity.tchdto.ScoreOverviewParametesDTO; +import com.sztzjy.digital_credit.entity.tchdto.TchGeneralViewDTO; +import com.sztzjy.digital_credit.entity.tchdto.TchGeneralViewWeightDTO; +import com.sztzjy.digital_credit.mapper.StuUserMapper; +import com.sztzjy.digital_credit.mapper.TchModuleWeithMapper; +import com.sztzjy.digital_credit.service.StuUserService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +@Service +public class StuUserServiceImpl implements StuUserService { + + + @Autowired + private TchModuleWeithMapper tchModuleWeithMapper; + + @Autowired + private StuUserMapper userMapper; + + + /** + * 成绩总览展示(条件查询) + * + * @param parametes + * @return + */ + @Override + public PageInfo selectGeneralViewList(ScoreOverviewParametesDTO parametes) { + + //根据学校id 查询tch_results_overview_weight表中 学校成绩总览权重 + + TchModuleWeithExample tchModuleWeithExample = new TchModuleWeithExample(); + tchModuleWeithExample.createCriteria().andSchoolIdEqualTo(parametes.getSchoolId()); + List tchModuleWeithList = tchModuleWeithMapper.selectByExample(tchModuleWeithExample); + if (tchModuleWeithList.isEmpty()) + { + //创建默认权重数据 + TchModuleWeith tchModuleWeith=new TchModuleWeith(parametes.getSchoolId()); + tchModuleWeithMapper.insert(tchModuleWeith); + } + + + PageHelper.startPage(parametes.getIndex(), parametes.getSize()); + + StuUserExample example = new StuUserExample(); + StuUserExample.Criteria criteria = example.createCriteria(); + criteria.andSchoolIdEqualTo(parametes.getSchoolId()); + if (StringUtils.isNotBlank(parametes.getName())) { +// criteria.andNameEqualTo(viewShowDTO.getName()); + criteria.andNameLike("%" + parametes.getName() + "%"); + } + if (StringUtils.isNotBlank(parametes.getStudentId())) { +// criteria.andStudentIdEqualTo(viewShowDTO.getStudentId()); + criteria.andStudentIdLike("%" + parametes.getStudentId() + "%"); + } + if (StringUtils.isNotBlank(parametes.getClassName())) { + + criteria.andClassNameLike("%" + parametes.getClassName() + "%"); + } + example.setOrderByClause("total_rank"); + List stuUsers = userMapper.selectByExample(example); + PageInfo pageInfoTotalList = new PageInfo<>(stuUsers); + List list = new ArrayList(); + for (int i = 0; i < stuUsers.size(); i++) { + TchGeneralViewDTO dto = new TchGeneralViewDTO(stuUsers.get(i), tchModuleWeithList.get(0)); + list.add(dto); + } + PageInfo pageInfo = new PageInfo<>(list); + pageInfo.setTotal(pageInfoTotalList.getTotal()); + return pageInfo; + } + + @Override + public List selectAllGeneralViewList(String schoolId) { + + //根据学校id 查询tch_results_overview_weight表中 学校成绩总览权重 + TchModuleWeithExample tchModuleWeithExample = new TchModuleWeithExample(); + tchModuleWeithExample.createCriteria().andSchoolIdEqualTo(schoolId); + List tchModuleWeithList = tchModuleWeithMapper.selectByExample(tchModuleWeithExample); + + StuUserExample example = new StuUserExample(); + StuUserExample.Criteria criteria = example.createCriteria(); + criteria.andSchoolIdEqualTo(schoolId); + example.setOrderByClause("total_rank ASC"); + List stuUsers = userMapper.selectByExample(example); + List list = new ArrayList(); + for (int i = 0; i < stuUsers.size(); i++) { + TchGeneralViewDTO dto = new TchGeneralViewDTO(stuUsers.get(i), tchModuleWeithList.get(0)); + list.add(dto); + } + return list; + } + + + @Override + public Boolean updateWeight(TchGeneralViewWeightDTO generalViewWeightDTO) { + TchModuleWeithExample tchModuleWeithExample = new TchModuleWeithExample(); + tchModuleWeithExample.createCriteria().andSchoolIdEqualTo(generalViewWeightDTO.getSchoolId()); + List tchModuleWeithList = tchModuleWeithMapper.selectByExample(tchModuleWeithExample); + TchModuleWeith tchModuleWeith = tchModuleWeithList.get(0); + tchModuleWeith.setCreditPortraitWeith(generalViewWeightDTO.getCreditPortraitWeith()); + tchModuleWeith.setPersonalCreditWeith(generalViewWeightDTO.getPersonalCreditWeith()); + tchModuleWeith.setEnterpriseCreditWeith(generalViewWeightDTO.getEnterpriseCreditWeith()); + tchModuleWeith.setCaseStudyWeith(generalViewWeightDTO.getCaseStudyWeith()); + int i = tchModuleWeithMapper.updateByPrimaryKeySelective(tchModuleWeith); + return i == 1 ? true : false; + } + + //总排名 先获取改学校的权重 再获取user对象 算出权重后的成绩 更新到totalscore中 再根据totalscore排名 + @Override + public void totalRank(String schoolId) { + TchModuleWeithExample tchModuleWeithExample = new TchModuleWeithExample(); + tchModuleWeithExample.createCriteria().andSchoolIdEqualTo(schoolId); + List tchModuleWeithList = tchModuleWeithMapper.selectByExample(tchModuleWeithExample); + + StuUserExample example = new StuUserExample(); + StuUserExample.Criteria criteria = example.createCriteria(); + criteria.andSchoolIdEqualTo(schoolId); + List stuUsers = userMapper.selectByExample(example); + List list = new ArrayList(); + for (int i = 0; i < stuUsers.size(); i++) { + StuUser stuUser=new StuUser(stuUsers.get(i),tchModuleWeithList.get(0)); + list.add(stuUser); + } + Collections.sort(list, new Comparator() { + @Override + public int compare(StuUser s1, StuUser s2) { + return s2.getTotalScore().compareTo(s1.getTotalScore()); + } + }); + // 更新totalRank值 + for (int i = 0; i < list.size(); i++) { + list.get(i).setTotalRank(i + 1); +// userMapper.updateByPrimaryKeySelective(list.get(i)); + } + userMapper.updateBatch(list); + + } + + +} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index c9d5893..969dd3c 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -2,7 +2,7 @@ spring: datasource: druid: db-type: mysql - url: jdbc:mysql://${DB_HOST:118.31.7.2}:${DB_PORT:3306}/${DB_NAME:tz_digital_credit}?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8&useSSL=false&useInformationSchema=true&allowPublicKeyRetrieval=true + url: jdbc:mysql://${DB_HOST:118.31.7.2}:${DB_PORT:3306}/${DB_NAME:tz_digital_credit}?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8&useSSL=false&useInformationSchema=true&allowPublicKeyRetrieval=true&allowMultiQueries=true username: ${DB_USER:root} password: ${DB_PWD:sztzjy2017} driver-class-name: com.mysql.cj.jdbc.Driver @@ -11,7 +11,7 @@ spring: # 文件存储 file: type: local - path: D:\home + path: D:\home\credit # path: D:\home # path: /usr/local/tianzeProject/blockFinance/uploadFile diff --git a/src/main/resources/mappers/StuUserMapper.xml b/src/main/resources/mappers/StuUserMapper.xml index 6dce317..df0a564 100644 --- a/src/main/resources/mappers/StuUserMapper.xml +++ b/src/main/resources/mappers/StuUserMapper.xml @@ -709,4 +709,115 @@ total_score = #{totalScore,jdbcType=DECIMAL} where user_id = #{userId,jdbcType=VARCHAR} + + + + + + update stu_user + + + name = #{item.name,jdbcType=VARCHAR}, + + + student_id = #{item.studentId,jdbcType=VARCHAR}, + + + major = #{item.major,jdbcType=VARCHAR}, + + + class_name = #{item.className,jdbcType=VARCHAR}, + + + class_id = #{item.classId,jdbcType=VARCHAR}, + + + school_id = #{item.schoolId,jdbcType=VARCHAR}, + + + school_name = #{item.schoolName,jdbcType=VARCHAR}, + + + loan_cases_score = #{loanCasesScore,jdbcType=DECIMAL}, + + + per_situation_score = #{perSituationScore,jdbcType=DECIMAL}, + + + repayment_behavior_score = #{repaymentBehaviorScore,jdbcType=DECIMAL}, + + + per_influence_factor_score = #{perInfluenceFactorScore,jdbcType=DECIMAL}, + + + per_credit_optimization_socre = #{perCreditOptimizationSocre,jdbcType=DECIMAL}, + + + per_credit_rating_socre = #{perCreditRatingSocre,jdbcType=DECIMAL}, + + + ent_influence_factor_socre = #{entInfluenceFactorSocre,jdbcType=DECIMAL}, + + + ent_credit_optimization_socre = #{entCreditOptimizationSocre,jdbcType=DECIMAL}, + + + ent_credit_rating_socre = #{entCreditRatingSocre,jdbcType=DECIMAL}, + + + case_user_profile_socre = #{caseUserProfileSocre,jdbcType=DECIMAL}, + + + case_personal_credit_score = #{casePersonalCreditScore,jdbcType=DECIMAL}, + + + case_corporate_credit_score = #{caseCorporateCreditScore,jdbcType=DECIMAL}, + + + case_corporate_credit_sub_score = #{caseCorporateCreditSubScore,jdbcType=DECIMAL}, + + + case_corporate_credit_obj_score = #{caseCorporateCreditObjScore,jdbcType=DECIMAL}, + + + case_personal_credit_sub_score = #{casePersonalCreditSubScore,jdbcType=DECIMAL}, + + + case_personal_credit_obj_score = #{casePersonalCreditObjScore,jdbcType=DECIMAL}, + + + credit_portrait_score = #{creditPortraitScore,jdbcType=DECIMAL}, + + + credit_portrait_rank = #{creditPortraitRank,jdbcType=INTEGER}, + + + personal_credit_score = #{personalCreditScore,jdbcType=DECIMAL}, + + + personal_credit_rank = #{personalCreditRank,jdbcType=INTEGER}, + + + corporate_credit_score = #{corporateCreditScore,jdbcType=DECIMAL}, + + + corporate_credit_rank = #{corporateCreditRank,jdbcType=INTEGER}, + + + comprehensive_case_score = #{comprehensiveCaseScore,jdbcType=DECIMAL}, + + + comprehensive_case_rank = #{comprehensiveCaseRank,jdbcType=INTEGER}, + + + total_rank = #{totalRank,jdbcType=INTEGER}, + + + total_score = #{totalScore,jdbcType=DECIMAL}, + + + where user_id = #{item.userId,jdbcType=VARCHAR} + + + \ No newline at end of file diff --git a/src/main/resources/mappers/TchModuleWeithMapper.xml b/src/main/resources/mappers/TchModuleWeithMapper.xml index 5287c0e..3f1cd47 100644 --- a/src/main/resources/mappers/TchModuleWeithMapper.xml +++ b/src/main/resources/mappers/TchModuleWeithMapper.xml @@ -16,6 +16,10 @@ + + + + @@ -79,7 +83,8 @@ id, school_id, loan_cases_weight, per_situation_weiht, repayment_behavior_weiht, per_influence_factor_weith, per_credit_optimization_weith, per_credit_rating_weith, ent_influence_factor_weith, ent_credit_optimization_weith, ent_credit_rating_weith, - case_user_profile_weith, case_personal_credit_weith, case_corporate_credit_weith + case_user_profile_weith, case_personal_credit_weith, case_corporate_credit_weith, + credit_portrait_weith, personal_credit_weith, enterprise_credit_weith, case_study_weith @@ -269,6 +302,18 @@ case_corporate_credit_weith = #{record.caseCorporateCreditWeith,jdbcType=DECIMAL}, + + credit_portrait_weith = #{record.creditPortraitWeith,jdbcType=DECIMAL}, + + + personal_credit_weith = #{record.personalCreditWeith,jdbcType=DECIMAL}, + + + enterprise_credit_weith = #{record.enterpriseCreditWeith,jdbcType=DECIMAL}, + + + case_study_weith = #{record.caseStudyWeith,jdbcType=DECIMAL}, + @@ -289,7 +334,11 @@ ent_credit_rating_weith = #{record.entCreditRatingWeith,jdbcType=DECIMAL}, case_user_profile_weith = #{record.caseUserProfileWeith,jdbcType=DECIMAL}, case_personal_credit_weith = #{record.casePersonalCreditWeith,jdbcType=DECIMAL}, - case_corporate_credit_weith = #{record.caseCorporateCreditWeith,jdbcType=DECIMAL} + case_corporate_credit_weith = #{record.caseCorporateCreditWeith,jdbcType=DECIMAL}, + credit_portrait_weith = #{record.creditPortraitWeith,jdbcType=DECIMAL}, + personal_credit_weith = #{record.personalCreditWeith,jdbcType=DECIMAL}, + enterprise_credit_weith = #{record.enterpriseCreditWeith,jdbcType=DECIMAL}, + case_study_weith = #{record.caseStudyWeith,jdbcType=DECIMAL} @@ -336,6 +385,18 @@ case_corporate_credit_weith = #{caseCorporateCreditWeith,jdbcType=DECIMAL}, + + credit_portrait_weith = #{creditPortraitWeith,jdbcType=DECIMAL}, + + + personal_credit_weith = #{personalCreditWeith,jdbcType=DECIMAL}, + + + enterprise_credit_weith = #{enterpriseCreditWeith,jdbcType=DECIMAL}, + + + case_study_weith = #{caseStudyWeith,jdbcType=DECIMAL}, + where id = #{id,jdbcType=INTEGER} @@ -353,7 +414,11 @@ ent_credit_rating_weith = #{entCreditRatingWeith,jdbcType=DECIMAL}, case_user_profile_weith = #{caseUserProfileWeith,jdbcType=DECIMAL}, case_personal_credit_weith = #{casePersonalCreditWeith,jdbcType=DECIMAL}, - case_corporate_credit_weith = #{caseCorporateCreditWeith,jdbcType=DECIMAL} + case_corporate_credit_weith = #{caseCorporateCreditWeith,jdbcType=DECIMAL}, + credit_portrait_weith = #{creditPortraitWeith,jdbcType=DECIMAL}, + personal_credit_weith = #{personalCreditWeith,jdbcType=DECIMAL}, + enterprise_credit_weith = #{enterpriseCreditWeith,jdbcType=DECIMAL}, + case_study_weith = #{caseStudyWeith,jdbcType=DECIMAL} where id = #{id,jdbcType=INTEGER} \ No newline at end of file From 8bf496d0f659926b3ff85c3b590ff56534990538 Mon Sep 17 00:00:00 2001 From: whb <17803890193@163.com> Date: Thu, 9 May 2024 08:33:52 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E6=95=B0?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/StuUserPortraitController.java | 15 ++- .../controller/task/StuTaskController.java | 13 +++ .../digital_credit/mapper/StuUserMapper.java | 3 + .../StuUserPortraitControllerService.java | 1 + .../StuEnterPriseByInfoEntryServiceImpl.java | 44 +++++--- .../StuFinancialEarlyWarningServiceImpl.java | 19 +++- .../service/impl/StuRateServiceImpl.java | 28 +++-- .../StuUserPortraitControllerServiceImpl.java | 38 ++++++- src/main/resources/mappers/StuUserMapper.xml | 104 +++++++++--------- 9 files changed, 181 insertions(+), 84 deletions(-) diff --git a/src/main/java/com/sztzjy/digital_credit/controller/StuUserPortraitController.java b/src/main/java/com/sztzjy/digital_credit/controller/StuUserPortraitController.java index 075f704..f50d600 100644 --- a/src/main/java/com/sztzjy/digital_credit/controller/StuUserPortraitController.java +++ b/src/main/java/com/sztzjy/digital_credit/controller/StuUserPortraitController.java @@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("api/stu/userPortrait") -@Api(tags = "用户画像:用户画像") +@Api(tags = "用户画像") public class StuUserPortraitController { @@ -37,6 +37,19 @@ public class StuUserPortraitController { } + @ApiOperation("用户画像:重新实训") + @AnonymousAccess + @GetMapping("/reTraining") + public ResultEntity reTraining(String userId){ + + return userPortraitControllerService.reTraining(userId); + + } + + + + + diff --git a/src/main/java/com/sztzjy/digital_credit/controller/task/StuTaskController.java b/src/main/java/com/sztzjy/digital_credit/controller/task/StuTaskController.java index 2f09769..94ab8cf 100644 --- a/src/main/java/com/sztzjy/digital_credit/controller/task/StuTaskController.java +++ b/src/main/java/com/sztzjy/digital_credit/controller/task/StuTaskController.java @@ -8,6 +8,7 @@ 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.service.StuUserService; import com.sztzjy.digital_credit.util.ResultEntity; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -49,6 +50,8 @@ public class StuTaskController { @Autowired private StuUserMapper userMapper; + @Autowired + StuUserService userService; // 计算每天每个班级的平均成绩 每天00.00执行 @@ -145,6 +148,16 @@ public class StuTaskController { + @Scheduled(fixedDelay = 3600000) + public void updateUserRank(){ + //先查询所有学校id + List schoolIds=userMapper.selectSchool(); + for (int i = 0; i < schoolIds.size(); i++) { + String schoolId = schoolIds.get(i); + userService.totalRank(schoolId); + } + } + } diff --git a/src/main/java/com/sztzjy/digital_credit/mapper/StuUserMapper.java b/src/main/java/com/sztzjy/digital_credit/mapper/StuUserMapper.java index 2164ca6..014cb85 100644 --- a/src/main/java/com/sztzjy/digital_credit/mapper/StuUserMapper.java +++ b/src/main/java/com/sztzjy/digital_credit/mapper/StuUserMapper.java @@ -39,4 +39,7 @@ public interface StuUserMapper { //批量更新排名 void updateBatch(List list); + + @Select("select school_id from stu_user group by school_id") + List selectSchool(); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/digital_credit/service/StuUserPortraitControllerService.java b/src/main/java/com/sztzjy/digital_credit/service/StuUserPortraitControllerService.java index ba7ff08..707a84f 100644 --- a/src/main/java/com/sztzjy/digital_credit/service/StuUserPortraitControllerService.java +++ b/src/main/java/com/sztzjy/digital_credit/service/StuUserPortraitControllerService.java @@ -25,4 +25,5 @@ public interface StuUserPortraitControllerService { Boolean userPortraitSubState(String userId); + ResultEntity reTraining(String userId); } diff --git a/src/main/java/com/sztzjy/digital_credit/service/impl/StuEnterPriseByInfoEntryServiceImpl.java b/src/main/java/com/sztzjy/digital_credit/service/impl/StuEnterPriseByInfoEntryServiceImpl.java index 1705a40..cfcb418 100644 --- a/src/main/java/com/sztzjy/digital_credit/service/impl/StuEnterPriseByInfoEntryServiceImpl.java +++ b/src/main/java/com/sztzjy/digital_credit/service/impl/StuEnterPriseByInfoEntryServiceImpl.java @@ -19,6 +19,7 @@ import com.sztzjy.digital_credit.entity.*; import com.sztzjy.digital_credit.entity.dto.StuFinancialIndexDTO; import com.sztzjy.digital_credit.mapper.*; import com.sztzjy.digital_credit.service.StuEnterPriseByInfoEntryService; +import com.sztzjy.digital_credit.service.StuPersonalCreditService; import com.sztzjy.digital_credit.service.StuRateService; import com.sztzjy.digital_credit.util.ConvertUtil; import com.sztzjy.digital_credit.util.MyExcelListener; @@ -65,6 +66,9 @@ public class StuEnterPriseByInfoEntryServiceImpl implements StuEnterPriseByInfoE @Autowired private StuOperatingCapacityMapper operatingCapacityMapper; + @Autowired + private StuPersonalCreditService stuPersonalCreditService; + @Autowired @@ -195,7 +199,7 @@ public class StuEnterPriseByInfoEntryServiceImpl implements StuEnterPriseByInfoE stuBaseInfoMapper.updateByPrimaryKeySelective(stuBaseInfo); //计算分数写入用户表 - stuRateService.enterScoreWriteUserByUserId(stuBaseInfo,"基本信息",stuBaseInfo.getUserId()); + stuPersonalCreditService.scoreEntry(stuBaseInfo.getUserId(),"基本信息", BigDecimal.valueOf(24-stuBaseInfo.getErrorNumber())); return new ResultEntity<>(HttpStatus.OK,"保存成功!",stuBaseInfo.getErrorNumber()); @@ -208,7 +212,7 @@ public class StuEnterPriseByInfoEntryServiceImpl implements StuEnterPriseByInfoE //插入数据库 stuBaseInfoMapper.insertSelective(stuBaseInfo); - stuRateService.enterScoreWriteUserByUserId(stuBaseInfo,"基本信息",stuBaseInfo.getUserId()); + stuPersonalCreditService.scoreEntry(stuBaseInfo.getUserId(),"基本信息", BigDecimal.valueOf(24-stuBaseInfo.getErrorNumber())); return new ResultEntity<>(HttpStatus.OK,"保存成功!",stuBaseInfo.getErrorNumber()); } @@ -312,8 +316,9 @@ public class StuEnterPriseByInfoEntryServiceImpl implements StuEnterPriseByInfoE creditRecords.setUpdateTime(new Date()); creditRecordsMapper.updateByPrimaryKeySelective(creditRecords); - //计算分数写入用户表 - stuRateService.enterScoreWriteUserByUserId(creditRecords,"信贷记录",creditRecords.getUserId()); + //计算分数写入用户表 + stuPersonalCreditService.scoreEntry(creditRecords.getUserId(),"信贷记录", BigDecimal.valueOf(16-creditRecords.getErrorNumber())); + return new ResultEntity<>(HttpStatus.OK,"保存成功!",creditRecords.getErrorNumber()); @@ -327,7 +332,8 @@ public class StuEnterPriseByInfoEntryServiceImpl implements StuEnterPriseByInfoE creditRecords.setCreateTime(new Date()); creditRecordsMapper.insertSelective(creditRecords); //计算分数写入用户表 - stuRateService.enterScoreWriteUserByUserId(creditRecords,"信贷记录",creditRecords.getUserId()); + stuPersonalCreditService.scoreEntry(creditRecords.getUserId(),"信贷记录", BigDecimal.valueOf(16-creditRecords.getErrorNumber())); + return new ResultEntity<>(HttpStatus.OK,"保存成功!",creditRecords.getErrorNumber()); } @@ -489,7 +495,9 @@ public class StuEnterPriseByInfoEntryServiceImpl implements StuEnterPriseByInfoE profitAbility.setId(profitAbilityList.get(0).getId()); profitAbilityMapper.updateByPrimaryKeySelective(profitAbility); //计算分数写入用户表 - stuRateService.enterScoreWriteUserByUserId(profitAbility,"盈利能力",profitAbility.getUserId()); + + stuPersonalCreditService.scoreEntry(profitAbility.getUserId(),"盈利能力", BigDecimal.valueOf(7-profitAbility.getErrorNumber())); + return new ResultEntity<>(HttpStatus.OK,"保存成功!",profitAbility.getErrorNumber()); @@ -502,7 +510,7 @@ public class StuEnterPriseByInfoEntryServiceImpl implements StuEnterPriseByInfoE //插入数据库 profitAbilityMapper.insertSelective(profitAbility); //计算分数写入用户表 - stuRateService.enterScoreWriteUserByUserId(profitAbility,"盈利能力",profitAbility.getUserId()); + stuPersonalCreditService.scoreEntry(profitAbility.getUserId(),"盈利能力", BigDecimal.valueOf(7-profitAbility.getErrorNumber())); return new ResultEntity<>(HttpStatus.OK,"保存成功!",profitAbility.getErrorNumber()); } @@ -577,8 +585,8 @@ public class StuEnterPriseByInfoEntryServiceImpl implements StuEnterPriseByInfoE solvencyMapper.updateByPrimaryKeySelective(solvency); //计算分数写入用户表 - stuRateService.enterScoreWriteUserByUserId(solvency,"偿债能力",solvency.getUserId()); + stuPersonalCreditService.scoreEntry(solvency.getUserId(),"偿债能力", BigDecimal.valueOf(7-solvency.getErrorNumber())); return new ResultEntity<>(HttpStatus.OK,"保存成功!",solvency.getErrorNumber()); }else { @@ -589,7 +597,7 @@ public class StuEnterPriseByInfoEntryServiceImpl implements StuEnterPriseByInfoE solvencyMapper.insertSelective(solvency); //计算分数写入用户表 - stuRateService.enterScoreWriteUserByUserId(solvency,"偿债能力",solvency.getUserId()); + stuPersonalCreditService.scoreEntry(solvency.getUserId(),"偿债能力", BigDecimal.valueOf(7-solvency.getErrorNumber())); return new ResultEntity<>(HttpStatus.OK,"保存成功!",solvency.getErrorNumber()); } @@ -663,7 +671,8 @@ public class StuEnterPriseByInfoEntryServiceImpl implements StuEnterPriseByInfoE operatingCapacity.setId(operatingCapacityList.get(0).getId()); operatingCapacityMapper.updateByPrimaryKeySelective(operatingCapacity); //计算分数写入用户表 - stuRateService.enterScoreWriteUserByUserId(operatingCapacity,"营运能力",operatingCapacity.getUserId()); + stuPersonalCreditService.scoreEntry(operatingCapacity.getUserId(),"营运能力", BigDecimal.valueOf(8-operatingCapacity.getErrorNumber())); + return new ResultEntity<>(HttpStatus.OK,"保存成功!",operatingCapacity.getErrorNumber()); @@ -675,7 +684,7 @@ public class StuEnterPriseByInfoEntryServiceImpl implements StuEnterPriseByInfoE //插入数据库 operatingCapacityMapper.insertSelective(operatingCapacity); //计算分数写入用户表 - stuRateService.enterScoreWriteUserByUserId(operatingCapacity,"营运能力",operatingCapacity.getUserId()); + stuPersonalCreditService.scoreEntry(operatingCapacity.getUserId(),"营运能力", BigDecimal.valueOf(8-operatingCapacity.getErrorNumber())); return new ResultEntity<>(HttpStatus.OK,"保存成功!",operatingCapacity.getErrorNumber()); } @@ -755,7 +764,9 @@ public class StuEnterPriseByInfoEntryServiceImpl implements StuEnterPriseByInfoE growthAbilityMapper.updateByPrimaryKeySelective(growthAbility); //计算分数写入用户表 - stuRateService.enterScoreWriteUserByUserId(growthAbility,"成长能力",growthAbility.getUserId()); + stuPersonalCreditService.scoreEntry(growthAbility.getUserId(),"成长能力", BigDecimal.valueOf(1-growthAbility.getErrorNumber())); + + return new ResultEntity<>(HttpStatus.OK,"保存成功!",growthAbility.getErrorNumber()); @@ -767,7 +778,7 @@ public class StuEnterPriseByInfoEntryServiceImpl implements StuEnterPriseByInfoE //插入数据库 growthAbilityMapper.insertSelective(growthAbility); //计算分数写入用户表 - stuRateService.enterScoreWriteUserByUserId(growthAbility,"成长能力",growthAbility.getUserId()); + stuPersonalCreditService.scoreEntry(growthAbility.getUserId(),"成长能力", BigDecimal.valueOf(1-growthAbility.getErrorNumber())); return new ResultEntity<>(HttpStatus.OK,"保存成功!",growthAbility.getErrorNumber()); } } @@ -842,7 +853,10 @@ public class StuEnterPriseByInfoEntryServiceImpl implements StuEnterPriseByInfoE duPontAnalysis.setId(duPontAnalysisList.get(0).getId()); duPontAnalysisMapper.updateByPrimaryKeySelective(duPontAnalysis); //计算分数写入用户表 - stuRateService.enterScoreWriteUserByUserId(duPontAnalysis,"杜邦分析",duPontAnalysis.getUserId()); + + stuPersonalCreditService.scoreEntry(duPontAnalysis.getUserId(),"杜邦分析", BigDecimal.valueOf(4-duPontAnalysis.getErrorNumber())); + + return new ResultEntity<>(HttpStatus.OK,"保存成功!",duPontAnalysis.getErrorNumber()); @@ -853,7 +867,7 @@ public class StuEnterPriseByInfoEntryServiceImpl implements StuEnterPriseByInfoE //插入数据库 duPontAnalysisMapper.insertSelective(duPontAnalysis); //计算分数写入用户表 - stuRateService.enterScoreWriteUserByUserId(duPontAnalysis,"杜邦分析",duPontAnalysis.getUserId()); + stuPersonalCreditService.scoreEntry(duPontAnalysis.getUserId(),"杜邦分析", BigDecimal.valueOf(4-duPontAnalysis.getErrorNumber())); return new ResultEntity<>(HttpStatus.OK,"保存成功!",duPontAnalysis.getErrorNumber()); } } diff --git a/src/main/java/com/sztzjy/digital_credit/service/impl/StuFinancialEarlyWarningServiceImpl.java b/src/main/java/com/sztzjy/digital_credit/service/impl/StuFinancialEarlyWarningServiceImpl.java index 7a4baf8..681fbc2 100644 --- a/src/main/java/com/sztzjy/digital_credit/service/impl/StuFinancialEarlyWarningServiceImpl.java +++ b/src/main/java/com/sztzjy/digital_credit/service/impl/StuFinancialEarlyWarningServiceImpl.java @@ -10,6 +10,7 @@ import com.sztzjy.digital_credit.entity.*; import com.sztzjy.digital_credit.mapper.StuOperationAssetAnalysisModuleMapper; import com.sztzjy.digital_credit.mapper.StuScoreModuleMapper; import com.sztzjy.digital_credit.service.StuFinancialEarlyWarningService; +import com.sztzjy.digital_credit.service.StuPersonalCreditService; import com.sztzjy.digital_credit.service.StuRateService; import com.sztzjy.digital_credit.util.ResultEntity; import org.springframework.beans.BeanUtils; @@ -17,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -34,6 +36,8 @@ public class StuFinancialEarlyWarningServiceImpl implements StuFinancialEarlyWar @Autowired private StuRateService stuRateService; + @Autowired + private StuPersonalCreditService stuPersonalCreditService; /** * Z计分模型 * @param userId @@ -147,7 +151,10 @@ public class StuFinancialEarlyWarningServiceImpl implements StuFinancialEarlyWar //计算分数写入用户表 - stuRateService.enterScoreWriteUserByUserId(scoreModule,"Z计分模型",scoreModule.getUserId()); + + stuPersonalCreditService.scoreEntry(scoreModule.getUserId(),"Z计分模型", BigDecimal.valueOf(12-scoreModule.getErrorNumber())); + + return new ResultEntity<>(HttpStatus.OK,"保存成功!",scoreModule.getErrorNumber()); @@ -161,7 +168,7 @@ public class StuFinancialEarlyWarningServiceImpl implements StuFinancialEarlyWar //插入数据库 scoreModuleMapper.insertSelective(scoreModule); //计算分数写入用户表 - stuRateService.enterScoreWriteUserByUserId(scoreModule,"Z计分模型",scoreModule.getUserId()); + stuPersonalCreditService.scoreEntry(scoreModule.getUserId(),"Z计分模型", BigDecimal.valueOf(12-scoreModule.getErrorNumber())); return new ResultEntity<>(HttpStatus.OK,"保存成功!",scoreModule.getErrorNumber()); @@ -275,7 +282,11 @@ public class StuFinancialEarlyWarningServiceImpl implements StuFinancialEarlyWar analysisModule.setId(moduleList.get(0).getId()); operationAssetAnalysisModuleMapper.updateByPrimaryKeySelective(analysisModule); //计算分数写入用户表 - stuRateService.enterScoreWriteUserByUserId(analysisModule,"营运资产分析模型",analysisModule.getUserId()); + + stuPersonalCreditService.scoreEntry(analysisModule.getUserId(),"营运资产分析模型", BigDecimal.valueOf(10-analysisModule.getErrorNumber())); + + + return new ResultEntity<>(HttpStatus.OK,"保存成功!",analysisModule.getErrorNumber()); @@ -288,7 +299,7 @@ public class StuFinancialEarlyWarningServiceImpl implements StuFinancialEarlyWar //插入数据库 operationAssetAnalysisModuleMapper.insertSelective(analysisModule); //计算分数写入用户表 - stuRateService.enterScoreWriteUserByUserId(analysisModule,"营运资产分析模型",analysisModule.getUserId()); + stuPersonalCreditService.scoreEntry(analysisModule.getUserId(),"营运资产分析模型", BigDecimal.valueOf(10-analysisModule.getErrorNumber())); return new ResultEntity<>(HttpStatus.OK,"保存成功!",analysisModule.getErrorNumber()); } diff --git a/src/main/java/com/sztzjy/digital_credit/service/impl/StuRateServiceImpl.java b/src/main/java/com/sztzjy/digital_credit/service/impl/StuRateServiceImpl.java index 3ddf69b..e88ffa2 100644 --- a/src/main/java/com/sztzjy/digital_credit/service/impl/StuRateServiceImpl.java +++ b/src/main/java/com/sztzjy/digital_credit/service/impl/StuRateServiceImpl.java @@ -7,6 +7,7 @@ import cn.hutool.core.convert.Convert; import cn.hutool.core.util.IdUtil; import com.sztzjy.digital_credit.entity.*; import com.sztzjy.digital_credit.mapper.*; +import com.sztzjy.digital_credit.service.StuPersonalCreditService; import com.sztzjy.digital_credit.service.StuRateService; import com.sztzjy.digital_credit.util.ResultEntity; import org.springframework.beans.BeanUtils; @@ -69,6 +70,9 @@ public class StuRateServiceImpl implements StuRateService { private StuScoreCenterMapper stuScoreCenterMapper; + @Autowired + private StuPersonalCreditService stuPersonalCreditService; + @@ -178,7 +182,10 @@ public class StuRateServiceImpl implements StuRateService { ratingModel.setId(stuRatingModelList.get(0).getId()); ratingModelMapper.updateByPrimaryKeySelective(ratingModel); //计算分数写入用户表 - enterScoreWriteUserByUserId(ratingModel,"评级模型",ratingModel.getUserId()); + + stuPersonalCreditService.scoreEntry(ratingModel.getUserId(),"评级模型", BigDecimal.valueOf(35-ratingModel.getErrorNumber())); + + return new ResultEntity<>(HttpStatus.OK,"保存成功!",ratingModel.getErrorNumber()); @@ -191,7 +198,7 @@ public class StuRateServiceImpl implements StuRateService { //插入数据库 ratingModelMapper.insertSelective(ratingModel); //计算分数写入用户表 - enterScoreWriteUserByUserId(ratingModel,"评级模型",ratingModel.getUserId()); + stuPersonalCreditService.scoreEntry(ratingModel.getUserId(),"评级模型", BigDecimal.valueOf(35-ratingModel.getErrorNumber())); return new ResultEntity<>(HttpStatus.OK,"保存成功!",ratingModel.getErrorNumber()); } @@ -305,7 +312,10 @@ public class StuRateServiceImpl implements StuRateService { ratingResult.setId(ratingResultList.get(0).getId()); resultMapper.updateByPrimaryKeySelective(ratingResult); //计算分数写入用户表 - enterScoreWriteUserByUserId(ratingResult,"评级结果",ratingResult.getUserId()); + + stuPersonalCreditService.scoreEntry(ratingResult.getUserId(),"评级结果", BigDecimal.valueOf(6-ratingResult.getErrorNumber())); + + return new ResultEntity<>(HttpStatus.OK,"保存成功!",ratingResult.getErrorNumber()); @@ -318,7 +328,7 @@ public class StuRateServiceImpl implements StuRateService { //插入数据库 resultMapper.insertSelective(ratingResult); //计算分数写入用户表 - enterScoreWriteUserByUserId(ratingResult,"评级结果",ratingResult.getUserId()); + stuPersonalCreditService.scoreEntry(ratingResult.getUserId(),"评级结果", BigDecimal.valueOf(6-ratingResult.getErrorNumber())); return new ResultEntity<>(HttpStatus.OK,"保存成功!",ratingResult.getErrorNumber()); } @@ -469,11 +479,11 @@ public class StuRateServiceImpl implements StuRateService { } - //获取用户画像总成绩 企业征信总成绩 个人征信总成绩 累加 写入实训案例总成绩 - - BigDecimal allScore = stuUser.getCasePersonalCreditScore().add(stuUser.getCaseCorporateCreditScore()).add(stuUser.getCaseUserProfileSocre()); - //综合案例总成绩 - stuUser.setComprehensiveCaseScore(allScore); +// //获取用户画像总成绩 企业征信总成绩 个人征信总成绩 累加 写入实训案例总成绩 +// +// BigDecimal allScore = stuUser.getCasePersonalCreditScore().add(stuUser.getCaseCorporateCreditScore()).add(stuUser.getCaseUserProfileSocre()); +// //综合案例总成绩 +// stuUser.setComprehensiveCaseScore(allScore); userMapper.updateByPrimaryKeySelective(stuUser); diff --git a/src/main/java/com/sztzjy/digital_credit/service/impl/StuUserPortraitControllerServiceImpl.java b/src/main/java/com/sztzjy/digital_credit/service/impl/StuUserPortraitControllerServiceImpl.java index d8af9b1..c932aeb 100644 --- a/src/main/java/com/sztzjy/digital_credit/service/impl/StuUserPortraitControllerServiceImpl.java +++ b/src/main/java/com/sztzjy/digital_credit/service/impl/StuUserPortraitControllerServiceImpl.java @@ -11,6 +11,7 @@ import com.sztzjy.digital_credit.entity.StuUserPortrait; import com.sztzjy.digital_credit.entity.StuUserPortraitExample; import com.sztzjy.digital_credit.mapper.StuUserMapper; import com.sztzjy.digital_credit.mapper.StuUserPortraitMapper; +import com.sztzjy.digital_credit.service.StuPersonalCreditService; import com.sztzjy.digital_credit.service.StuUserPortraitControllerService; import com.sztzjy.digital_credit.util.ResultEntity; import org.springframework.beans.BeanUtils; @@ -19,9 +20,9 @@ import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import java.math.BigDecimal; -import java.rmi.ServerException; import java.util.HashMap; import java.util.List; +import java.util.Map; @Service public class StuUserPortraitControllerServiceImpl implements StuUserPortraitControllerService { @@ -33,6 +34,11 @@ public class StuUserPortraitControllerServiceImpl implements StuUserPortraitCont @Autowired private StuUserMapper userMapper; + + @Autowired + private StuPersonalCreditService stuPersonalCreditService; + + /** * 自动保存接口(根据module分类) * @param userPortrait @@ -63,8 +69,10 @@ public class StuUserPortraitControllerServiceImpl implements StuUserPortraitCont //根据model算正确分数 portrait = correctScoreCalculationByModule(portrait); + stuPersonalCreditService.scoreEntry(portrait.getUserId(),portrait.getModule(), BigDecimal.valueOf(portrait.getCorrectNumber())); + //将分数保存到用户表,如果重新实训将用户表数据删除 - saveScoreToUser(portrait); + // saveScoreToUser(portrait); } userPortraitMapper.updateByPrimaryKeySelective(portrait); @@ -82,7 +90,8 @@ public class StuUserPortraitControllerServiceImpl implements StuUserPortraitCont userPortrait = correctScoreCalculationByModule(userPortrait); //将分数保存到用户表,如果重新实训将用户表数据删除 - saveScoreToUser(userPortrait); + // saveScoreToUser(userPortrait); + stuPersonalCreditService.scoreEntry(userPortrait.getUserId(),userPortrait.getModule(), BigDecimal.valueOf(userPortrait.getCorrectNumber())); } userPortraitMapper.insertSelective(userPortrait); @@ -92,6 +101,9 @@ public class StuUserPortraitControllerServiceImpl implements StuUserPortraitCont } + + + /** * 用户画像提交状态 * @param userId @@ -117,6 +129,26 @@ public class StuUserPortraitControllerServiceImpl implements StuUserPortraitCont return false; } + /** + * 用户画像重新实训 + * @param userId + * @return + */ + + @Override + public ResultEntity reTraining(String userId) { + //重新实训 查询这张表里所有的数据 然后删除 + + StuUserPortraitExample portraitExample = new StuUserPortraitExample(); + portraitExample.createCriteria().andUserIdEqualTo(userId); + + userPortraitMapper.deleteByExample(portraitExample); + + + + return new ResultEntity<>(HttpStatus.OK,"重新实训成功!"); + } + //将分数保存到用户表,如果重新实训将用户表数据删除 private void saveScoreToUser(StuUserPortrait portrait) { diff --git a/src/main/resources/mappers/StuUserMapper.xml b/src/main/resources/mappers/StuUserMapper.xml index df0a564..35a95d1 100644 --- a/src/main/resources/mappers/StuUserMapper.xml +++ b/src/main/resources/mappers/StuUserMapper.xml @@ -737,83 +737,83 @@ school_name = #{item.schoolName,jdbcType=VARCHAR}, - - loan_cases_score = #{loanCasesScore,jdbcType=DECIMAL}, + + loan_cases_score = #{item.loanCasesScore,jdbcType=DECIMAL}, - - per_situation_score = #{perSituationScore,jdbcType=DECIMAL}, + + per_situation_score = #{item.perSituationScore,jdbcType=DECIMAL}, - - repayment_behavior_score = #{repaymentBehaviorScore,jdbcType=DECIMAL}, + + repayment_behavior_score = #{item.repaymentBehaviorScore,jdbcType=DECIMAL}, - - per_influence_factor_score = #{perInfluenceFactorScore,jdbcType=DECIMAL}, + + per_influence_factor_score = #{item.perInfluenceFactorScore,jdbcType=DECIMAL}, - - per_credit_optimization_socre = #{perCreditOptimizationSocre,jdbcType=DECIMAL}, + + per_credit_optimization_socre = #{item.perCreditOptimizationSocre,jdbcType=DECIMAL}, - - per_credit_rating_socre = #{perCreditRatingSocre,jdbcType=DECIMAL}, + + per_credit_rating_socre = #{item.perCreditRatingSocre,jdbcType=DECIMAL}, - - ent_influence_factor_socre = #{entInfluenceFactorSocre,jdbcType=DECIMAL}, + + ent_influence_factor_socre = #{item.entInfluenceFactorSocre,jdbcType=DECIMAL}, - - ent_credit_optimization_socre = #{entCreditOptimizationSocre,jdbcType=DECIMAL}, + + ent_credit_optimization_socre = #{item.entCreditOptimizationSocre,jdbcType=DECIMAL}, - - ent_credit_rating_socre = #{entCreditRatingSocre,jdbcType=DECIMAL}, + + ent_credit_rating_socre = #{item.entCreditRatingSocre,jdbcType=DECIMAL}, - - case_user_profile_socre = #{caseUserProfileSocre,jdbcType=DECIMAL}, + + case_user_profile_socre = #{item.caseUserProfileSocre,jdbcType=DECIMAL}, - - case_personal_credit_score = #{casePersonalCreditScore,jdbcType=DECIMAL}, + + case_personal_credit_score = #{item.casePersonalCreditScore,jdbcType=DECIMAL}, - - case_corporate_credit_score = #{caseCorporateCreditScore,jdbcType=DECIMAL}, + + case_corporate_credit_score = #{item.caseCorporateCreditScore,jdbcType=DECIMAL}, - - case_corporate_credit_sub_score = #{caseCorporateCreditSubScore,jdbcType=DECIMAL}, + + case_corporate_credit_sub_score = #{item.caseCorporateCreditSubScore,jdbcType=DECIMAL}, - - case_corporate_credit_obj_score = #{caseCorporateCreditObjScore,jdbcType=DECIMAL}, + + case_corporate_credit_obj_score = #{item.caseCorporateCreditObjScore,jdbcType=DECIMAL}, - - case_personal_credit_sub_score = #{casePersonalCreditSubScore,jdbcType=DECIMAL}, + + case_personal_credit_sub_score = #{item.casePersonalCreditSubScore,jdbcType=DECIMAL}, - - case_personal_credit_obj_score = #{casePersonalCreditObjScore,jdbcType=DECIMAL}, + + case_personal_credit_obj_score = #{item.casePersonalCreditObjScore,jdbcType=DECIMAL}, - - credit_portrait_score = #{creditPortraitScore,jdbcType=DECIMAL}, + + credit_portrait_score = #{item.creditPortraitScore,jdbcType=DECIMAL}, - - credit_portrait_rank = #{creditPortraitRank,jdbcType=INTEGER}, + + credit_portrait_rank = #{item.creditPortraitRank,jdbcType=INTEGER}, - - personal_credit_score = #{personalCreditScore,jdbcType=DECIMAL}, + + personal_credit_score = #{item.personalCreditScore,jdbcType=DECIMAL}, - - personal_credit_rank = #{personalCreditRank,jdbcType=INTEGER}, + + personal_credit_rank = #{item.personalCreditRank,jdbcType=INTEGER}, - - corporate_credit_score = #{corporateCreditScore,jdbcType=DECIMAL}, + + corporate_credit_score = #{item.corporateCreditScore,jdbcType=DECIMAL}, - - corporate_credit_rank = #{corporateCreditRank,jdbcType=INTEGER}, + + corporate_credit_rank = #{item.corporateCreditRank,jdbcType=INTEGER}, - - comprehensive_case_score = #{comprehensiveCaseScore,jdbcType=DECIMAL}, + + comprehensive_case_score = #{item.comprehensiveCaseScore,jdbcType=DECIMAL}, - - comprehensive_case_rank = #{comprehensiveCaseRank,jdbcType=INTEGER}, + + comprehensive_case_rank = #{item.comprehensiveCaseRank,jdbcType=INTEGER}, - - total_rank = #{totalRank,jdbcType=INTEGER}, + + total_rank = #{item.totalRank,jdbcType=INTEGER}, - - total_score = #{totalScore,jdbcType=DECIMAL}, + + total_score = #{item.totalScore,jdbcType=DECIMAL}, where user_id = #{item.userId,jdbcType=VARCHAR}