Browse Source

Merge branch 'master' of ssh://192.168.8.213:10022/miaxis/jkt

Althars123 3 năm trước cách đây
mục cha
commit
80f291d2af

+ 0 - 4
jkt-admin/src/main/java/com/miaxis/app/controller/question/QuestionCollectionController.java

@@ -4,20 +4,16 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.miaxis.common.annotation.Log;
 import com.miaxis.common.constant.Constants;
 import com.miaxis.common.core.controller.BaseController;
-import com.miaxis.common.core.domain.BaseBusinessEntity;
 import com.miaxis.common.core.domain.Response;
 import com.miaxis.common.core.page.ResponsePageInfo;
 import com.miaxis.common.enums.BusinessTypeEnum;
 import com.miaxis.common.exception.CustomException;
 import com.miaxis.common.utils.SecurityUtils;
-import com.miaxis.common.utils.poi.ExcelUtil;
 import com.miaxis.question.domain.QuestionCollection;
 import com.miaxis.question.dto.QuestionCollectionDTO;
 import com.miaxis.question.dto.QuestionCollectionListDTO;
 import com.miaxis.question.service.IQuestionCollectionService;
-import com.miaxis.score.domain.ScoreInfo;
 import io.swagger.annotations.*;
-import org.aspectj.weaver.patterns.TypePatternQuestions;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;

+ 32 - 0
jkt-admin/src/main/java/com/miaxis/app/controller/score/ScoreInfoController.java

@@ -19,7 +19,9 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 【模拟考成绩】Controller
@@ -100,4 +102,34 @@ public class ScoreInfoController extends BaseController{
     ){
         return toResponse(scoreInfoService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
     }
+
+
+    /**
+     * 获取预测成功
+     */
+    @GetMapping(value = "/forecastScore")
+    @ApiOperation("获取预测成绩")
+    public Response<Integer> getInfo(){
+        ScoreInfo scoreInfo = new ScoreInfo();
+        scoreInfo.setUserId(SecurityUtils.getLoginUser().getStudent().getId());
+        int forecastScore = scoreInfoService.getForecastScore(scoreInfo);
+//        Map<String,Object> map = new HashMap<String,Object>();
+//        map.put("forecastScore",forecastScore);
+        return Response.success(forecastScore);
+    }
+
+
+    /**
+     * 获取预测成功
+     */
+    @GetMapping(value = "/avgScore")
+    @ApiOperation("获取平均成绩")
+    public Response<Integer> getAvgScore(){
+        ScoreInfo scoreInfo = new ScoreInfo();
+        scoreInfo.setUserId(SecurityUtils.getLoginUser().getStudent().getId());
+        int aveScore = scoreInfoService.getAveScore(scoreInfo);
+//        Map<String,Object> map = new HashMap<String,Object>();
+//        map.put("forecastScore",forecastScore);
+        return Response.success(aveScore);
+    }
 }

+ 12 - 1
jkt-admin/src/test/java/com/miaxis/test/NormalTest.java

@@ -1,8 +1,12 @@
 package com.miaxis.test;
 
 import com.miaxis.JktApplication;
+import com.miaxis.score.domain.ScoreInfo;
+import com.miaxis.score.dto.ScoreInfoDTO;
+import com.miaxis.score.service.IScoreInfoService;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
@@ -11,10 +15,17 @@ import org.springframework.test.context.junit4.SpringRunner;
 @RunWith(SpringRunner.class)
 public class NormalTest {
 
-
+    @Autowired
+    private IScoreInfoService iScoreInfoService;
     @Test
     public void test1() throws Exception {
 
+        ScoreInfo scoreInfo = new ScoreInfo();
+        scoreInfo.setUserId(4240l);
+
+//        int result = iScoreInfoService.getAveScore(scoreInfo);
+        iScoreInfoService.getForecastScore(scoreInfo);
+
     }
 
 

+ 11 - 31
jkt-service/src/main/java/com/miaxis/question/domain/QuestionCollection.java

@@ -41,36 +41,16 @@ public class QuestionCollection extends BaseBusinessEntity{
     @ApiModelProperty(value = "题目ID")
     private Long questionId;
 
-    public void setId(Long id){
-        this.id = id;
-    }
 
-    public Long getId(){
-        return id;
-    }
-    public void setUserId(Long userId){
-        this.userId = userId;
-    }
-
-    public Long getUserId(){
-        return userId;
-    }
-    public void setQuestionId(Long questionId){
-        this.questionId = questionId;
-    }
-
-    public Long getQuestionId(){
-        return questionId;
-    }
-
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("id", getId())
-            .append("userId", getUserId())
-            .append("questionId", getQuestionId())
-            .append("createTime", getCreateTime())
-            .append("updateTime", getUpdateTime())
-            .toString();
-    }
+    /** 科目 */
+    @Excel(name = "科目")
+    @TableField("km")
+    @ApiModelProperty(value = "考试科目(科目一、科目二、科目三、科目四)")
+    private String km;
+
+    /** 车型 */
+    @Excel(name = "车型")
+    @TableField("car_type")
+    @ApiModelProperty(value = "车型(小车 、客车、货车、摩托车)")
+    private String carType;
 }

+ 10 - 28
jkt-service/src/main/java/com/miaxis/question/domain/QuestionWrong.java

@@ -41,36 +41,18 @@ public class QuestionWrong extends BaseBusinessEntity{
     @ApiModelProperty(value = "题目ID")
     private Long questionId;
 
-    public void setId(Long id){
-        this.id = id;
-    }
 
-    public Long getId(){
-        return id;
-    }
-    public void setUserId(Long userId){
-        this.userId = userId;
-    }
+    /** 科目 */
+    @Excel(name = "科目")
+    @TableField("km")
+    @ApiModelProperty(value = "考试科目(科目一、科目二、科目三、科目四)")
+    private String km;
 
-    public Long getUserId(){
-        return userId;
-    }
-    public void setQuestionId(Long questionId){
-        this.questionId = questionId;
-    }
+    /** 车型 */
+    @Excel(name = "车型")
+    @TableField("car_type")
+    @ApiModelProperty(value = "车型(小车 、客车、货车、摩托车)")
+    private String carType;
 
-    public Long getQuestionId(){
-        return questionId;
-    }
 
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("id", getId())
-            .append("userId", getUserId())
-            .append("questionId", getQuestionId())
-            .append("createTime", getCreateTime())
-            .append("updateTime", getUpdateTime())
-            .toString();
-    }
 }

+ 9 - 2
jkt-service/src/main/java/com/miaxis/question/dto/QuestionCollectionDTO.java

@@ -1,6 +1,8 @@
 package com.miaxis.question.dto;
 
 
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.miaxis.common.annotation.Excel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -17,11 +19,16 @@ public class QuestionCollectionDTO {
 
 
 
-
     /** 题目ID */
-
     @ApiModelProperty(value = "题目ID",required=true)
     private Long questionId;
 
+    /** 科目 */
+    @ApiModelProperty(value = "考试科目(科目一、科目二、科目三、科目四)")
+    private String km;
+
+    /** 车型 */
+    @ApiModelProperty(value = "车型(小车 、客车、货车、摩托车)")
+    private String carType;
 
 }

+ 7 - 0
jkt-service/src/main/java/com/miaxis/question/dto/QuestionCollectionListDTO.java

@@ -25,4 +25,11 @@ public class QuestionCollectionListDTO extends BaseBusinessEntity {
     @ApiModelProperty(value = "题目ID",hidden = true)
     private Long questionId;
 
+    /** 科目 */
+    @ApiModelProperty(value = "考试科目(科目一、科目二、科目三、科目四)")
+    private String km;
+
+    /** 车型 */
+    @ApiModelProperty(value = "车型(小车 、客车、货车、摩托车)")
+    private String carType;
 }

+ 8 - 0
jkt-service/src/main/java/com/miaxis/question/dto/QuestionWrongDTO.java

@@ -22,4 +22,12 @@ public class QuestionWrongDTO {
     @ApiModelProperty(value = "题目ID")
     private Long questionId;
 
+    /** 科目 */
+    @ApiModelProperty(value = "考试科目(科目一、科目二、科目三、科目四)")
+    private String km;
+
+    /** 车型 */
+    @ApiModelProperty(value = "车型(小车 、客车、货车、摩托车)")
+    private String carType;
+
 }

+ 7 - 0
jkt-service/src/main/java/com/miaxis/question/dto/QuestionWrongListDTO.java

@@ -20,6 +20,13 @@ public class QuestionWrongListDTO extends BaseBusinessEntity {
     @ApiModelProperty(value = "题目ID",hidden = true)
     private Long questionId;
 
+    /** 科目 */
+    @ApiModelProperty(value = "考试科目(科目一、科目二、科目三、科目四)")
+    private String km;
+
+    /** 车型 */
+    @ApiModelProperty(value = "车型(小车 、客车、货车、摩托车)")
+    private String carType;
 
 
 

+ 15 - 0
jkt-service/src/main/java/com/miaxis/score/mapper/ScoreInfoMapper.java

@@ -19,4 +19,19 @@ public interface ScoreInfoMapper extends BaseMapper<ScoreInfo> {
      */
     public List<ScoreInfo> selectScoreInfoList(ScoreInfo scoreInfo);
 
+
+    /**
+     * 返回
+     * @param scoreInfo
+     * @return
+     */
+    public int getAvgScore(ScoreInfo scoreInfo);
+
+
+    /**
+     * 返回
+     * @param scoreInfo
+     * @return
+     */
+    public List getLast10Score(ScoreInfo scoreInfo);
 }

+ 14 - 0
jkt-service/src/main/java/com/miaxis/score/service/IScoreInfoService.java

@@ -18,4 +18,18 @@ public interface IScoreInfoService extends IService<ScoreInfo>{
      * @return 模拟考成绩集合
      */
     public List<ScoreInfo> selectScoreInfoList(ScoreInfo scoreInfo);
+
+    /**
+     * 查询模拟考试平均成绩
+     * @param scoreInfo
+     * @return
+     */
+    public int getAveScore(ScoreInfo scoreInfo);
+
+    /**
+     * 查询模拟考试预测成绩
+     * @param scoreInfo
+     * @return
+     */
+    public int getForecastScore(ScoreInfo scoreInfo);
 }

+ 23 - 0
jkt-service/src/main/java/com/miaxis/score/service/impl/ScoreInfoServiceImpl.java

@@ -33,4 +33,27 @@ public class ScoreInfoServiceImpl extends ServiceImpl<ScoreInfoMapper, ScoreInfo
     public List<ScoreInfo> selectScoreInfoList(ScoreInfo scoreInfo){
         return scoreInfoMapper.selectScoreInfoList(scoreInfo);
     }
+
+    @Override
+    public int getAveScore(ScoreInfo scoreInfo) {
+        int avgScore= scoreInfoMapper.getAvgScore(scoreInfo);
+        return avgScore;
+    }
+
+    @Override
+    public int getForecastScore(ScoreInfo scoreInfo) {
+        List<Integer> list = scoreInfoMapper.getLast10Score(scoreInfo);
+        if(list!=null && list.size()>=3) {
+            list.remove(0);
+            list.remove(list.size() - 1);
+        }
+        int total = 0;
+        for (int a: list) {
+            total +=a;
+        }
+        int forecastScore= total/list.size();
+        return forecastScore;
+    }
+
+
 }

+ 38 - 0
jkt-service/src/main/resources/mapper/score/ScoreInfoMapper.xml

@@ -28,4 +28,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
     </select>
 
+
+    <select id="getLast10Score" parameterType="ScoreInfo" resultType="int">
+        select score from
+        (select score from score_info s
+        <where>
+            <if test="userId != null "> and user_id = #{userId}</if>
+        </where>
+        order by id desc limit 0,10) x order by score
+    </select>
+
+    <select id="getAvgScore" parameterType="ScoreInfo" resultType="int">
+        select ROUND(avg(score),0) from score_info s
+        <where>
+            <if test="userId != null "> and user_id = #{userId}</if>
+        </where>
+    </select>
+
+
+
+    <select id="getMinScore" parameterType="ScoreInfo" resultType="int">
+        select min(score) from score_info s
+        <where>
+            <if test="userId != null "> and user_id = #{userId}</if>
+            <if test="type != null  and type != ''"> and type = #{type}</if>
+            <if test="kskm != null  and kskm != ''"> and kskm = #{kskm}</if>
+        </where>
+    </select>
+
+    <select id="getMaxScore" parameterType="ScoreInfo" resultType="int">
+        select max(score) from score_info s
+        <where>
+            <if test="userId != null "> and user_id = #{userId}</if>
+            <if test="type != null  and type != ''"> and type = #{type}</if>
+            <if test="kskm != null  and kskm != ''"> and kskm = #{kskm}</if>
+        </where>
+    </select>
+
+
 </mapper>