Browse Source

首页考试统计

Administrator 1 year ago
parent
commit
6246cad9f5

+ 53 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/socre/ScoreDataController.java

@@ -1,10 +1,12 @@
 package com.ruoyi.web.controller.socre;
 package com.ruoyi.web.controller.socre;
 
 
 import java.util.List;
 import java.util.List;
+import java.util.Map;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
 
 
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.system.domain.score.ScoreData;
 import com.ruoyi.system.domain.score.ScoreData;
 import com.ruoyi.system.domain.score.ScoreDataDetails;
 import com.ruoyi.system.domain.score.ScoreDataDetails;
@@ -46,7 +48,6 @@ public class ScoreDataController extends BaseController
     @GetMapping("/list")
     @GetMapping("/list")
     public TableDataInfo list(ScoreData scoreData)
     public TableDataInfo list(ScoreData scoreData)
     {
     {
-        startPage();
         List<ScoreData> list = scoreDataService.selectScoreDataList(scoreData);
         List<ScoreData> list = scoreDataService.selectScoreDataList(scoreData);
         return getDataTable(list);
         return getDataTable(list);
     }
     }
@@ -86,10 +87,30 @@ public class ScoreDataController extends BaseController
         if (file != null){
         if (file != null){
             ExcelUtil<ScoreDataDetails> util = new ExcelUtil<ScoreDataDetails>(ScoreDataDetails.class);
             ExcelUtil<ScoreDataDetails> util = new ExcelUtil<ScoreDataDetails>(ScoreDataDetails.class);
             List<ScoreDataDetails> scoreDataDetailsList = util.importExcel(file.getInputStream());
             List<ScoreDataDetails> scoreDataDetailsList = util.importExcel(file.getInputStream());
+            if (scoreDataDetailsList == null || scoreDataDetailsList.size() < 1){
+                return AjaxResult.error("不能导入空数据");
+            }
+            for (ScoreDataDetails scoreDataDetails : scoreDataDetailsList) {
+                int zongfen = scoreDataDetails.getZongfen();
+                if (zongfen < 0){
+                    return AjaxResult.error("总成绩不能有小于0的数据");
+                }
+            }
             scoreData.setScoreDataDetailsList(scoreDataDetailsList);
             scoreData.setScoreDataDetailsList(scoreDataDetailsList);
         }
         }
         return toAjax(scoreDataService.insertScoreData(scoreData));
         return toAjax(scoreDataService.insertScoreData(scoreData));
     }
     }
+    /**
+     * 新增成绩
+     */
+    @PreAuthorize("@ss.hasPermi('score:data:add')")
+    @Log(title = "成绩", businessType = BusinessType.INSERT)
+    @PostMapping("/add")
+    public AjaxResult add(@RequestBody ScoreData scoreData)
+    {
+
+        return toAjax(scoreDataService.insertScoreData(scoreData));
+    }
 
 
     /**
     /**
      * 修改成绩
      * 修改成绩
@@ -112,4 +133,35 @@ public class ScoreDataController extends BaseController
     {
     {
         return toAjax(scoreDataService.deleteScoreDataByScoreIds(scoreIds));
         return toAjax(scoreDataService.deleteScoreDataByScoreIds(scoreIds));
     }
     }
+
+    /**
+     * 后台首页成绩统计排名
+     */
+    @PostMapping("/indexPaiMing")
+    public AjaxResult indexPaiMing(@RequestBody ScoreData scoreData)
+    {
+        List<ScoreDataDetails> scoreDataDetails = scoreDataService.indexPaiMing(scoreData);
+        return AjaxResult.success(scoreDataDetails);
+    }
+
+    /**
+     * 后台首页成绩统计分段人数饼图
+     */
+    @PostMapping("/indexBingTu")
+    public AjaxResult indexBingTu(@RequestBody ScoreData scoreData)
+    {
+        Map<String, Object> map = scoreDataService.indexBingTu(scoreData);
+        return AjaxResult.success(map);
+    }
+
+    /**
+     * 后台首页成绩统计分段人数折线图
+     */
+    @PostMapping("/indexZheXian")
+    public AjaxResult indexZheXian(@RequestBody ScoreData scoreData)
+    {
+        Map<String, Object> map = scoreDataService.indexZheXian(scoreData);
+        return AjaxResult.success(map);
+    }
+
 }
 }

+ 12 - 0
ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java

@@ -45,4 +45,16 @@ public class CacheConstants
      * 登录账户密码错误次数 redis key
      * 登录账户密码错误次数 redis key
      */
      */
     public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
     public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
+    /**
+     * 后台首页各分段学生人数 上一次考试数据
+     */
+    public static final String FEN_DUAN_LAST = "fen_duan_last:";
+    /**
+     * 后台首页各分段学生人数 最新考试数据
+     */
+    public static final String FEN_DUAN_NEW = "fen_duan_new:";
+    /**
+     * 最新考试id
+     */
+    public static final String SCORE_ID = "score_id:";
 }
 }

+ 8 - 8
ruoyi-system/src/main/java/com/ruoyi/system/domain/score/ScoreData.java

@@ -32,7 +32,7 @@ public class ScoreData extends BaseEntity
 
 
     /** 接收班级id */
     /** 接收班级id */
     @Excel(name = "接收班级id")
     @Excel(name = "接收班级id")
-    private Long scoreClassId;
+    private String scoreClassId;
 
 
     /** 接收班级名称 */
     /** 接收班级名称 */
     @Excel(name = "接收班级名称")
     @Excel(name = "接收班级名称")
@@ -72,16 +72,16 @@ public class ScoreData extends BaseEntity
     {
     {
         return scoreTime;
         return scoreTime;
     }
     }
-    public void setScoreClassId(Long scoreClassId) 
-    {
-        this.scoreClassId = scoreClassId;
-    }
 
 
-    public Long getScoreClassId() 
-    {
+    public String getScoreClassId() {
         return scoreClassId;
         return scoreClassId;
     }
     }
-    public void setScoreClassName(String scoreClassName) 
+
+    public void setScoreClassId(String scoreClassId) {
+        this.scoreClassId = scoreClassId;
+    }
+
+    public void setScoreClassName(String scoreClassName)
     {
     {
         this.scoreClassName = scoreClassName;
         this.scoreClassName = scoreClassName;
     }
     }

+ 24 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/score/ScoreDataDetails.java

@@ -83,6 +83,30 @@ public class ScoreDataDetails extends BaseEntity
     /** 政策分 */
     /** 政策分 */
     @Excel(name = "政策分")
     @Excel(name = "政策分")
     private String zhengcefen;
     private String zhengcefen;
+    /**
+     * 总分
+     */
+    private Integer zongfen;
+    /**
+     * 是否查看
+     */
+    private String detailsType;
+
+    public Integer getZongfen() {
+        return zongfen;
+    }
+
+    public void setZongfen(Integer zongfen) {
+        this.zongfen = zongfen;
+    }
+
+    public String getDetailsType() {
+        return detailsType;
+    }
+
+    public void setDetailsType(String detailsType) {
+        this.detailsType = detailsType;
+    }
 
 
     public String getScoreDataNameId() {
     public String getScoreDataNameId() {
         return scoreDataNameId;
         return scoreDataNameId;

+ 14 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/score/ScoreDataMapper.java

@@ -21,6 +21,20 @@ public interface ScoreDataMapper
      */
      */
     public ScoreData selectScoreDataByScoreId(Long scoreId);
     public ScoreData selectScoreDataByScoreId(Long scoreId);
 
 
+    /**
+     * 查询成绩排名
+     * @param scoreClassId
+     * @return
+     */
+    public List<ScoreDataDetails> selectScoreDataByScoreClassId(String scoreClassId);
+
+    /**
+     * 根据班级id查询最新一次考试id
+     * @param scoreClassId
+     * @return
+     */
+    public ScoreData selectScoreIdByScoreClassId(String scoreClassId);
+
     /**
     /**
      * 查询成绩列表
      * 查询成绩列表
      * 
      * 

+ 42 - 27
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/XiaoyuanNoticeServiceImpl.java

@@ -64,36 +64,50 @@ public class XiaoyuanNoticeServiceImpl implements IXiaoyuanNoticeService {
     @Override
     @Override
     public List<XiaoyuanNotice> selectXiaoyuanNoticeList(XiaoyuanNotice xiaoyuanNotice) {
     public List<XiaoyuanNotice> selectXiaoyuanNoticeList(XiaoyuanNotice xiaoyuanNotice) {
         SysUser user = SecurityUtils.getLoginUser().getUser();
         SysUser user = SecurityUtils.getLoginUser().getUser();
-        xiaoyuanNotice.setSenderId(user.getUserId().toString());
-        List<SysRole> roles = user.getRoles();
-        String classId = "0";
-        for (SysRole role : roles) {
-            if ("teacher".equals(role.getRoleKey())) {
-                FormalTeacherClass formalTeacherClass = new FormalTeacherClass();
-                formalTeacherClass.setTeacherId(user.getUserId());
-                List<FormalTeacherClass> formalTeacherClasses = formalTeacherClassMapper.selectFormalTeacherClassList(formalTeacherClass);
-                if (formalTeacherClasses != null && formalTeacherClasses.size() > 0) {
-                    for (FormalTeacherClass teacherClass : formalTeacherClasses) {
-                        classId = teacherClass.getClassId() + ",";
-                    }
+        Map<String, Object> params = xiaoyuanNotice.getParams();
+        String role = "admin";
+        if (params != null && params.size() > 0) {
+            role = (String) params.get("role");
+        }
+        StringBuilder classId = new StringBuilder("0,");
+        List<XiaoyuanNotice> xiaoyuanNotices = new ArrayList<>();
+        if ("teacher".equals(role)) {
+            FormalTeacherClass formalTeacherClass = new FormalTeacherClass();
+            formalTeacherClass.setTeacherId(user.getUserId());
+            List<FormalTeacherClass> formalTeacherClasses = formalTeacherClassMapper.selectFormalTeacherClassList(formalTeacherClass);
+            if (formalTeacherClasses != null && formalTeacherClasses.size() > 0) {
+                for (FormalTeacherClass teacherClass : formalTeacherClasses) {
+                    classId.append(teacherClass.getClassId()).append(",");
                 }
                 }
             }
             }
-            if ("parents".equals(role.getRoleKey())) {
-                FormalParentsStudent formalParentsStudent = new FormalParentsStudent();
-                formalParentsStudent.setParentsId(user.getUserId());
-                List<FormalParentsStudent> formalParentsStudents = formalParentsStudentMapper.selectFormalParentsStudentList(formalParentsStudent);
-                for (FormalParentsStudent parentsStudent : formalParentsStudents) {
-                    classId = parentsStudent.getClassId() + ",";
-                }
+            if (StringUtils.isNotBlank(classId.toString())) {
+                classId = new StringBuilder(classId.substring(0, classId.length() - 1));
             }
             }
+            //查询出所有班级id
+            xiaoyuanNotice.setSenderDept(classId.toString());
+            startPage();
+            xiaoyuanNotices = xiaoyuanNoticeMapper.selectXiaoyuanNoticeList(xiaoyuanNotice);
         }
         }
-        if (StringUtils.isNotBlank(classId)) {
-            classId = classId.substring(0, classId.length() - 1);
+       else if ("parents".equals(role)) {
+            FormalParentsStudent formalParentsStudent = new FormalParentsStudent();
+            formalParentsStudent.setParentsId(user.getUserId());
+            List<FormalParentsStudent> formalParentsStudents = formalParentsStudentMapper.selectFormalParentsStudentList(formalParentsStudent);
+            for (FormalParentsStudent parentsStudent : formalParentsStudents) {
+                classId.append(parentsStudent.getClassId()).append(",");
+            }
+            if (StringUtils.isNotBlank(classId.toString())) {
+                classId = new StringBuilder(classId.substring(0, classId.length() - 1));
+            }
+            //查询出所有班级id
+            xiaoyuanNotice.setSenderDept(classId.toString());
+            startPage();
+            xiaoyuanNotices = xiaoyuanNoticeMapper.selectXiaoyuanNoticeList(xiaoyuanNotice);
+        }
+        else if ("admin".equals(role)){
+            startPage();
+            xiaoyuanNotices = xiaoyuanNoticeMapper.selectXiaoyuanNoticeList(xiaoyuanNotice);
         }
         }
-        //查询出所有班级id
-        xiaoyuanNotice.setSenderDept(classId);
-        startPage();
-        return xiaoyuanNoticeMapper.selectXiaoyuanNoticeList(xiaoyuanNotice);
+        return xiaoyuanNotices;
     }
     }
 
 
     @Override
     @Override
@@ -105,6 +119,7 @@ public class XiaoyuanNoticeServiceImpl implements IXiaoyuanNoticeService {
 
 
     /**
     /**
      * 我的收藏
      * 我的收藏
+     *
      * @param xiaoyuanNotice
      * @param xiaoyuanNotice
      * @return
      * @return
      */
      */
@@ -112,8 +127,8 @@ public class XiaoyuanNoticeServiceImpl implements IXiaoyuanNoticeService {
     public List<XiaoyuanNotice> myCollect(XiaoyuanNotice xiaoyuanNotice) {
     public List<XiaoyuanNotice> myCollect(XiaoyuanNotice xiaoyuanNotice) {
         SysUser user = SecurityUtils.getLoginUser().getUser();
         SysUser user = SecurityUtils.getLoginUser().getUser();
         Long userId = user.getUserId();
         Long userId = user.getUserId();
-        xiaoyuanNotice.setCollect("\"userId\":"+userId);
-        return  xiaoyuanNoticeMapper.selectXiaoyuanNoticeByMyCollect(xiaoyuanNotice);
+        xiaoyuanNotice.setCollect("\"userId\":" + userId);
+        return xiaoyuanNoticeMapper.selectXiaoyuanNoticeByMyCollect(xiaoyuanNotice);
     }
     }
 
 
     /**
     /**

+ 181 - 7
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/score/ScoreDataServiceImpl.java

@@ -1,24 +1,30 @@
 package com.ruoyi.system.service.impl.score;
 package com.ruoyi.system.service.impl.score;
 
 
-import java.util.List;
+import java.util.*;
 
 
-import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.constant.CacheConstants;
+import com.ruoyi.common.core.domain.entity.FormalParentsStudent;
+import com.ruoyi.common.core.domain.entity.FormalTeacherClass;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.domain.entity.SysUser;
-import com.ruoyi.common.exception.CustomException;
+import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.system.domain.score.ScoreData;
 import com.ruoyi.system.domain.score.ScoreData;
 import com.ruoyi.system.domain.score.ScoreDataDetails;
 import com.ruoyi.system.domain.score.ScoreDataDetails;
+import com.ruoyi.system.mapper.FormalParentsStudentMapper;
+import com.ruoyi.system.mapper.FormalTeacherClassMapper;
 import com.ruoyi.system.mapper.score.ScoreDataMapper;
 import com.ruoyi.system.mapper.score.ScoreDataMapper;
 import com.ruoyi.system.service.score.IScoreDataService;
 import com.ruoyi.system.service.score.IScoreDataService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
-import java.util.ArrayList;
+import java.util.stream.Collectors;
 
 
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.StringUtils;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 
 
+import static com.ruoyi.common.utils.PageUtils.startPage;
+
 /**
 /**
  * 成绩Service业务层处理
  * 成绩Service业务层处理
  *
  *
@@ -30,6 +36,13 @@ public class ScoreDataServiceImpl implements IScoreDataService {
     @Autowired
     @Autowired
     private ScoreDataMapper scoreDataMapper;
     private ScoreDataMapper scoreDataMapper;
 
 
+    @Autowired
+    private FormalTeacherClassMapper formalTeacherClassMapper;
+    @Autowired
+    private FormalParentsStudentMapper formalParentsStudentMapper;
+    @Autowired
+    private RedisCache redisCache;
+
     /**
     /**
      * 查询成绩
      * 查询成绩
      *
      *
@@ -49,7 +62,47 @@ public class ScoreDataServiceImpl implements IScoreDataService {
      */
      */
     @Override
     @Override
     public List<ScoreData> selectScoreDataList(ScoreData scoreData) {
     public List<ScoreData> selectScoreDataList(ScoreData scoreData) {
-        return scoreDataMapper.selectScoreDataList(scoreData);
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        StringBuilder classId = new StringBuilder("0,");
+        Map<String, Object> params = scoreData.getParams();
+        String role = "admin";
+        if (params != null && params.size() > 0) {
+            role = (String) params.get("role");
+        }
+        List<ScoreData> scoreDataList = new ArrayList<>();
+        if ("teacher".equals(role)) {
+            FormalTeacherClass formalTeacherClass = new FormalTeacherClass();
+            formalTeacherClass.setTeacherId(user.getUserId());
+            List<FormalTeacherClass> formalTeacherClasses = formalTeacherClassMapper.selectFormalTeacherClassList(formalTeacherClass);
+            if (formalTeacherClasses != null && formalTeacherClasses.size() > 0) {
+                for (FormalTeacherClass teacherClass : formalTeacherClasses) {
+                    classId.append(teacherClass.getClassId()).append(",");
+                }
+            }
+            if (StringUtils.isNotBlank(classId.toString())) {
+                classId = new StringBuilder(classId.substring(0, classId.length() - 1));
+            }
+            startPage();
+            scoreData.setScoreClassId(classId.toString());
+            scoreDataList = scoreDataMapper.selectScoreDataList(scoreData);
+        } else if ("parents".equals(role)) {
+            FormalParentsStudent formalParentsStudent = new FormalParentsStudent();
+            formalParentsStudent.setParentsId(user.getUserId());
+            List<FormalParentsStudent> formalParentsStudents = formalParentsStudentMapper.selectFormalParentsStudentList(formalParentsStudent);
+            for (FormalParentsStudent parentsStudent : formalParentsStudents) {
+                classId.append(parentsStudent.getClassId()).append(",");
+            }
+            if (StringUtils.isNotBlank(classId.toString())) {
+                classId = new StringBuilder(classId.substring(0, classId.length() - 1));
+            }
+            startPage();
+            scoreData.setScoreClassId(classId.toString());
+            scoreDataList = scoreDataMapper.selectScoreDataList(scoreData);
+        } else if ("admin".equals(role)) {
+            startPage();
+            scoreDataList = scoreDataMapper.selectScoreDataList(scoreData);
+        }
+        return scoreDataList;
     }
     }
 
 
     /**
     /**
@@ -58,12 +111,19 @@ public class ScoreDataServiceImpl implements IScoreDataService {
      * @param scoreData 成绩
      * @param scoreData 成绩
      * @return 结果
      * @return 结果
      */
      */
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     @Override
     @Override
     public int insertScoreData(ScoreData scoreData) {
     public int insertScoreData(ScoreData scoreData) {
         scoreData.setCreateTime(DateUtils.getNowDate());
         scoreData.setCreateTime(DateUtils.getNowDate());
         int rows = scoreDataMapper.insertScoreData(scoreData);
         int rows = scoreDataMapper.insertScoreData(scoreData);
-        insertScoreDataDetails(scoreData);
+        List<ScoreDataDetails> scoreDataDetailsList = scoreData.getScoreDataDetailsList();
+        if (scoreDataDetailsList != null && scoreDataDetailsList.size() > 0) {
+            scoreDataDetailsList.stream().sorted(Comparator.comparing(ScoreDataDetails::getZongfen).reversed()).collect(Collectors.toList());
+            for (int i = 0; i < scoreDataDetailsList.size(); i++) {
+                scoreDataDetailsList.get(i).setScoreSort(i + 1 + "");
+            }
+            insertScoreDataDetails(scoreData);
+        }
         return rows;
         return rows;
     }
     }
 
 
@@ -108,6 +168,120 @@ public class ScoreDataServiceImpl implements IScoreDataService {
         return scoreDataMapper.deleteScoreDataByScoreId(scoreId);
         return scoreDataMapper.deleteScoreDataByScoreId(scoreId);
     }
     }
 
 
+    /**
+     * 后台首页成绩统计排名
+     */
+    @Override
+    public List<ScoreDataDetails> indexPaiMing(ScoreData scoreData) {
+        //最新一次考试
+        List<ScoreDataDetails> scoreDataDetails = scoreDataMapper.selectScoreDataByScoreClassId(scoreData.getScoreClassId());
+        if (scoreDataDetails != null && scoreDataDetails.size() > 0) {
+            scoreDataDetails = scoreDataDetails.subList(0, Math.min(scoreDataDetails.size(), 10));
+        }
+        return scoreDataDetails;
+    }
+
+    /**
+     * 后台首页成绩统计分段人数饼图最新一次考试
+     */
+    @Override
+    public Map<String, Object> indexBingTu(ScoreData scoreData) {
+        //获取缓存的数据
+        Map<String, Object> cacheMap = redisCache.getCacheMap(CacheConstants.FEN_DUAN_NEW);
+        //获取班级id对应的最新考试id
+        Long scoreDataId = (Long) redisCache.getCacheObject(CacheConstants.SCORE_ID + scoreData.getScoreClassId());
+        boolean flag = false;
+        if (cacheMap != null) {
+            //获取redis缓存的考试id
+            Long scoreId = (Long) cacheMap.get("scoreId");
+            //判断最新一次考试id和缓存id是否匹配
+            if (scoreDataId.equals(scoreId)) {
+                //说明缓存就是最新的
+                return cacheMap;
+            } else {
+                //说明缓存数据不是最新的需要放到对比数据key中去 成为对比数据
+                flag = true;
+            }
+        }
+        Map<String, Object> map = new HashMap<>(8);
+        int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0;
+        map.put("0", a);
+        map.put("100", b);
+        map.put("200", c);
+        map.put("300", d);
+        map.put("400", e);
+        map.put("500", f);
+        map.put("600", g);
+        map.put("700", h);
+        List<ScoreDataDetails> scoreDataDetails = scoreDataMapper.selectScoreDataByScoreClassId(scoreData.getScoreClassId());
+        if (scoreDataDetails != null && scoreDataDetails.size() > 0) {
+            //计算各个分数段有多少人
+            for (ScoreDataDetails scoreDataDetail : scoreDataDetails) {
+                int zongfen = scoreDataDetail.getZongfen();
+                if (zongfen >= 0 && zongfen <= 100) {
+                    a++;
+                } else if (zongfen > 100 && zongfen <= 200) {
+                    b++;
+                } else if (zongfen > 200 && zongfen <= 300) {
+                    c++;
+                } else if (zongfen > 300 && zongfen <= 400) {
+                    d++;
+                } else if (zongfen > 400 && zongfen <= 500) {
+                    e++;
+                } else if (zongfen > 500 && zongfen <= 600) {
+                    f++;
+                } else if (zongfen > 600 && zongfen <= 700) {
+                    g++;
+                } else if (zongfen > 700) {
+                    h++;
+                }
+            }
+            map.put("0", a);
+            map.put("100", b);
+            map.put("200", c);
+            map.put("300", d);
+            map.put("400", e);
+            map.put("500", f);
+            map.put("600", g);
+            map.put("700", h);
+            map.put("scoreId", scoreDataDetails.get(0).getScoreId());
+            //把最新数据放到最新缓存key中
+            redisCache.setCacheMap(CacheConstants.FEN_DUAN_NEW, map);
+            redisCache.setCacheObject(CacheConstants.SCORE_ID + scoreData.getScoreClassId(), scoreDataDetails.get(0).getScoreId());
+            if (flag) {
+                //放入对比数据
+                redisCache.setCacheMap(CacheConstants.FEN_DUAN_LAST, cacheMap);
+            }
+        }
+        return map;
+    }
+
+    /**
+     * 后台首页成绩统计分段人数折线图
+     */
+
+    @Override
+    public Map<String, Object> indexZheXian(ScoreData scoreData) {
+        Map<String, Object> map = new HashMap<>(8);
+        //分段
+        List<String> x = new ArrayList<>();
+        //本次
+        List<Integer> y1 = new ArrayList<>();
+        //上次
+        List<Integer> y2 = new ArrayList<>();
+        Map<String, Object> cacheMapNew = redisCache.getCacheMap(CacheConstants.FEN_DUAN_NEW);
+        Map<String, Object> cacheMapLast = redisCache.getCacheMap(CacheConstants.FEN_DUAN_LAST);
+        for (String key : cacheMapNew.keySet()) {
+            x.add(key);
+            y1.add(Integer.parseInt((String) cacheMapNew.get(key)));
+            y2.add(Integer.parseInt((String) cacheMapLast.get(key)));
+        }
+        map.put("x",x);
+        map.put("y1",y1);
+        map.put("y2",y2);
+        return map;
+    }
+
     /**
     /**
      * 新增成绩_子信息
      * 新增成绩_子信息
      *
      *

+ 14 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/score/IScoreDataService.java

@@ -6,6 +6,7 @@ import com.ruoyi.system.domain.score.ScoreData;
 import com.ruoyi.system.domain.score.ScoreDataDetails;
 import com.ruoyi.system.domain.score.ScoreDataDetails;
 
 
 import java.util.List;
 import java.util.List;
+import java.util.Map;
 
 
 /**
 /**
  * 成绩Service接口
  * 成绩Service接口
@@ -62,4 +63,17 @@ public interface IScoreDataService
      * @return 结果
      * @return 结果
      */
      */
     public int deleteScoreDataByScoreId(Long scoreId);
     public int deleteScoreDataByScoreId(Long scoreId);
+    /**
+     * 后台首页成绩统计排名
+     */
+    public List<ScoreDataDetails> indexPaiMing(ScoreData scoreData);
+    /**
+     * 后台首页成绩统计分段人数饼图
+     */
+    public Map<String,Object> indexBingTu(ScoreData scoreData);
+
+    /**
+     * 后台首页成绩统计分段人数折线图
+     */
+    public Map<String,Object> indexZheXian(ScoreData scoreData);
 }
 }

+ 40 - 9
ruoyi-system/src/main/resources/mapper/score/ScoreDataMapper.xml

@@ -41,6 +41,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="wenzong"    column="sub_wenzong"    />
         <result property="wenzong"    column="sub_wenzong"    />
         <result property="lizong"    column="sub_lizong"    />
         <result property="lizong"    column="sub_lizong"    />
         <result property="zhengcefen"    column="sub_zhengcefen"    />
         <result property="zhengcefen"    column="sub_zhengcefen"    />
+        <result property="zongfen"    column="sub_zongfen"    />
+        <result property="detailsType"    column="sub_details_type"    />
         <result property="createBy"    column="sub_create_by"    />
         <result property="createBy"    column="sub_create_by"    />
         <result property="createTime"    column="sub_create_time"    />
         <result property="createTime"    column="sub_create_time"    />
         <result property="updateBy"    column="sub_update_by"    />
         <result property="updateBy"    column="sub_update_by"    />
@@ -53,23 +55,52 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </sql>
     </sql>
 
 
     <select id="selectScoreDataList" parameterType="ScoreData" resultMap="ScoreDataResult">
     <select id="selectScoreDataList" parameterType="ScoreData" resultMap="ScoreDataResult">
-        <include refid="selectScoreDataVo"/>
+        select a.score_id, a.score_title, a.score_time, a.score_class_id, a.score_class_name, a.privacy_type, a.create_by, a.create_time, a.update_by, a.update_time, a.remark
+
+        from score_data a
+
         <where>  
         <where>  
-            <if test="scoreTitle != null  and scoreTitle != ''"> and score_title = #{scoreTitle}</if>
-            <if test="scoreTime != null "> and score_time = #{scoreTime}</if>
-            <if test="scoreClassId != null "> and score_class_id = #{scoreClassId}</if>
-            <if test="scoreClassName != null  and scoreClassName != ''"> and score_class_name like concat('%', #{scoreClassName}, '%')</if>
-            <if test="privacyType != null  and privacyType != ''"> and privacy_type = #{privacyType}</if>
+            <if test="scoreTitle != null  and scoreTitle != ''"> and a.score_title = #{scoreTitle}</if>
+            <if test="scoreTime != null "> and a.score_time = #{scoreTime}</if>
+            <if test="scoreClassName != null  and scoreClassName != ''"> and a.score_class_name like concat('%', #{scoreClassName}, '%')</if>
+            <if test="privacyType != null  and privacyType != ''"> and a.privacy_type = #{privacyType}</if>
+            <if test="scoreClassId != null  and scoreClassId != ''"> and find_in_set(a.score_class_id,#{scoreClassId})</if>
         </where>
         </where>
     </select>
     </select>
     
     
     <select id="selectScoreDataByScoreId" parameterType="Long" resultMap="ScoreDataScoreDataDetailsResult">
     <select id="selectScoreDataByScoreId" parameterType="Long" resultMap="ScoreDataScoreDataDetailsResult">
         select a.score_id, a.score_title, a.score_time, a.score_class_id, a.score_class_name, a.privacy_type, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
         select a.score_id, a.score_title, a.score_time, a.score_class_id, a.score_class_name, a.privacy_type, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
- b.score_details_id as sub_score_details_id, b.score_id as sub_score_id, b.score_sort as sub_score_sort, b.score_data_name as sub_score_data_name, b.yuwen as sub_yuwen, b.shuxue as sub_shuxue, b.yingyu as sub_yingyu, b.wuli as sub_wuli, b.huaxue as sub_huaxue, b.shengwu as sub_shengwu, b.zhengzhi as sub_zhengzhi, b.lishi as sub_lishi, b.dili as sub_dili, b.tiyu as sub_tiyu, b.wenzong as sub_wenzong, b.lizong as sub_lizong, b.zhengcefen as sub_zhengcefen, b.create_by as sub_create_by, b.create_time as sub_create_time, b.update_by as sub_update_by, b.update_time as sub_update_time, b.remark as sub_remark
+ b.score_details_id as sub_score_details_id, b.score_id as sub_score_id,b.zongfen as sub_zongfen, b.score_sort as sub_score_sort, b.details_type as sub_details_type, b.score_data_name as sub_score_data_name, b.yuwen as sub_yuwen, b.shuxue as sub_shuxue, b.yingyu as sub_yingyu, b.wuli as sub_wuli, b.huaxue as sub_huaxue, b.shengwu as sub_shengwu, b.zhengzhi as sub_zhengzhi, b.lishi as sub_lishi, b.dili as sub_dili, b.tiyu as sub_tiyu, b.wenzong as sub_wenzong, b.lizong as sub_lizong, b.zhengcefen as sub_zhengcefen, b.create_by as sub_create_by, b.create_time as sub_create_time, b.update_by as sub_update_by, b.update_time as sub_update_time, b.remark as sub_remark
         from score_data a
         from score_data a
         left join score_data_details b on b.score_id = a.score_id
         left join score_data_details b on b.score_id = a.score_id
         where a.score_id = #{scoreId}
         where a.score_id = #{scoreId}
     </select>
     </select>
+
+    <select id="selectScoreIdByScoreClassId" parameterType="string" resultMap="ScoreDataResult">
+SELECT
+		score_id
+	FROM
+		score_data
+WHERE
+	score_class_id = #{scoreClassId} order by score_time DESC limit 1
+
+    </select>
+    <select id="selectScoreDataByScoreClassId" parameterType="string" resultMap="ScoreDataDetailsResult">
+        select
+ b.score_details_id as sub_score_details_id, b.score_id as sub_score_id,b.zongfen as sub_zongfen, b.score_sort as sub_score_sort, b.details_type as sub_details_type, b.score_data_name as sub_score_data_name, b.yuwen as sub_yuwen, b.shuxue as sub_shuxue, b.yingyu as sub_yingyu, b.wuli as sub_wuli, b.huaxue as sub_huaxue, b.shengwu as sub_shengwu, b.zhengzhi as sub_zhengzhi, b.lishi as sub_lishi, b.dili as sub_dili, b.tiyu as sub_tiyu, b.wenzong as sub_wenzong, b.lizong as sub_lizong, b.zhengcefen as sub_zhengcefen, b.create_by as sub_create_by, b.create_time as sub_create_time, b.update_by as sub_update_by, b.update_time as sub_update_time, b.remark as sub_remark
+        from
+         score_data_details b
+WHERE
+	b.score_id = (
+	SELECT
+		score_id
+	FROM
+		score_data
+WHERE
+	score_class_id = #{scoreClassId} order by score_time DESC limit 1)
+	order by b.score_sort
+
+    </select>
         
         
     <insert id="insertScoreData" parameterType="ScoreData" useGeneratedKeys="true" keyProperty="scoreId">
     <insert id="insertScoreData" parameterType="ScoreData" useGeneratedKeys="true" keyProperty="scoreId">
         insert into score_data
         insert into score_data
@@ -139,9 +170,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
     </delete>
 
 
     <insert id="batchScoreDataDetails">
     <insert id="batchScoreDataDetails">
-        insert into score_data_details( score_details_id, score_id, score_sort, score_data_name, yuwen, shuxue, yingyu, wuli, huaxue, shengwu, zhengzhi, lishi, dili, tiyu, wenzong, lizong, zhengcefen, create_by, create_time, update_by, update_time, remark) values
+        insert into score_data_details( score_details_id, score_id, score_sort, score_data_name, yuwen, shuxue, yingyu, wuli, huaxue, shengwu, zhengzhi, lishi, dili, tiyu, wenzong, lizong, zhengcefen,zongfen, create_by, create_time, update_by, update_time, remark) values
 		<foreach item="item" index="index" collection="list" separator=",">
 		<foreach item="item" index="index" collection="list" separator=",">
-            ( #{item.scoreDetailsId}, #{item.scoreId}, #{item.scoreSort}, #{item.scoreDataName}, #{item.yuwen}, #{item.shuxue}, #{item.yingyu}, #{item.wuli}, #{item.huaxue}, #{item.shengwu}, #{item.zhengzhi}, #{item.lishi}, #{item.dili}, #{item.tiyu}, #{item.wenzong}, #{item.lizong}, #{item.zhengcefen}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.remark})
+            ( #{item.scoreDetailsId}, #{item.scoreId}, #{item.scoreSort}, #{item.scoreDataName}, #{item.yuwen}, #{item.shuxue}, #{item.yingyu}, #{item.wuli}, #{item.huaxue}, #{item.shengwu}, #{item.zhengzhi}, #{item.lishi}, #{item.dili}, #{item.tiyu}, #{item.wenzong}, #{item.lizong}, #{item.zhengcefen},#{item.zongfen}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.remark})
         </foreach>
         </foreach>
     </insert>
     </insert>
 </mapper>
 </mapper>