From 21046b69a83e5ed3da2aa86f14c9c0d631a9c98e Mon Sep 17 00:00:00 2001
From: xiaoCJ <406612557@qq.com>
Date: Fri, 11 Aug 2023 16:47:21 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9USER.XML=EF=BC=8C=E6=96=B0?=
 =?UTF-8?q?=E5=A2=9E=E9=83=A8=E5=88=86=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../src/main/resources/application.yml        |  27 ++-
 .../controller/TrainingScoreController.java   |  92 ++++++++--
 .../common/core/domain/entity/SysUser.java    |   2 +-
 .../com/ruoyi/system/domain/vo/ReportDto.java |   9 +
 .../ruoyi/system/mapper/SysUserMapper.java    |  40 +++--
 .../service/ISysTrainingScoreService.java     |  14 +-
 .../impl/SysTrainingScoreServiceImpl.java     | 157 +++++++++++-------
 .../resources/mapper/system/SysUserMapper.xml |  18 ++
 8 files changed, 253 insertions(+), 106 deletions(-)

diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml
index 386e3a7..e80942f 100644
--- a/ruoyi-admin/src/main/resources/application.yml
+++ b/ruoyi-admin/src/main/resources/application.yml
@@ -9,7 +9,7 @@ ruoyi:
   # 实例演示开关
   demoEnabled: true
   # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
-  profile: D:/ruoyi/uploadPath
+  profile: /usr/local/textjar/upload/uploadIMG
   # 获取ip地址开关
   addressEnabled: false
   # 验证码类型 math 数组计算 char 字符验证
@@ -18,7 +18,7 @@ ruoyi:
 # 开发环境配置
 server:
   # 服务器的HTTP端口,默认为8080
-  port: 8888
+  port: 7777
   servlet:
     # 应用的访问路径
     context-path: /
@@ -62,16 +62,16 @@ spring:
   # redis 配置
   redis:
     # 地址
-    host: 39.108.144.227
 #    host: 39.108.144.227
-#    host: localhost
+#    host: 39.108.144.227
+    host: localhost
     # 端口,默认为6379
-    port: 1135
-#    port: 6379
+#    port: 1135
+    port: 6379
     # 数据库索引
-    database: 0
+#    database: 0
     # 密码
-    password: 123@Biemo.com
+#    password: 123@Biemo.com
 #    password: ''
     # 连接超时时间
     timeout: 10s
@@ -125,3 +125,14 @@ xss:
   excludes: /system/notice
   # 匹配链接
   urlPatterns: /system/*,/monitor/*,/tool/*
+
+## 文件存储
+#file:
+#  type: local
+#  path: /usr/local/tianzeProject/foreignExchange/uploadFile
+
+
+# 文件存储
+file:
+  type: local
+  path: /usr/local/textjar/upload/uploadReport
\ No newline at end of file
diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/controller/TrainingScoreController.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/controller/TrainingScoreController.java
index 7f49921..ebcef56 100644
--- a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/controller/TrainingScoreController.java
+++ b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/controller/TrainingScoreController.java
@@ -3,7 +3,12 @@ package com.ruoyi.biemo.business.controller;
 import com.alibaba.fastjson.JSONObject;
 
 import com.github.pagehelper.PageInfo;
+import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.system.domain.SysGradeWeight;
 import com.ruoyi.system.domain.SysTrainingScore;
 import com.ruoyi.system.domain.SysTrainingScoreExample;
@@ -11,11 +16,16 @@ import com.ruoyi.system.domain.vo.ReportDto;
 import com.ruoyi.system.domain.vo.TrainingScoreVo;
 import com.ruoyi.system.mapper.SysGradeWeightMapper;
 import com.ruoyi.system.mapper.SysTrainingScoreMapper;
+import com.ruoyi.system.mapper.SysUserMapper;
 import com.ruoyi.system.service.ISysTrainingScoreService;
+import com.ruoyi.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
 import java.util.List;
 
 @RestController
@@ -27,14 +37,17 @@ public class TrainingScoreController {
     SysTrainingScoreMapper trainingScoreMapper;
     @Autowired
     SysGradeWeightMapper gradeWeightMapper;
+    @Autowired
+    SysUserMapper sysUserMapper;
+
 
     @PostMapping("/addScore")
-    private void addScore(@RequestBody JSONObject jsonObject){
+    private void addScore(@RequestBody JSONObject jsonObject) {
         String controlsName = jsonObject.getString("controlsName");
         Long userId = jsonObject.getLong("userId");
         //检查状态是否提交且变更的值是否有数据 如果返回值为false 则执行更新操作
         SysTrainingScore sysTrainingScore = trainingScoreService.checkStatusAndControlsName(userId, controlsName);
-        if(sysTrainingScore!=null){
+        if (sysTrainingScore != null) {
             //更新userid的进度和分数
             sysTrainingScore.calculateDataScore();
             trainingScoreService.updateByPrimaryKeySelective(sysTrainingScore);
@@ -42,24 +55,24 @@ public class TrainingScoreController {
     }
 
     @PostMapping("/selectScore")
-    private TrainingScoreVo selectScore(@RequestBody JSONObject jsonObject){
+    private TrainingScoreVo selectScore(@RequestBody JSONObject jsonObject) {
         Long userId = jsonObject.getLong("userId");
         SysTrainingScore sysTrainingScore = trainingScoreService.selectByUserId(userId);
-        TrainingScoreVo trainingScoreVo=new TrainingScoreVo(sysTrainingScore);
+        TrainingScoreVo trainingScoreVo = new TrainingScoreVo(sysTrainingScore);
         return trainingScoreVo;
     }
 
     //一键审批
     @PostMapping("/approvalAll")
-    private String approvalAll(){
-        List<SysTrainingScore> trainingScoreList=trainingScoreService.selectAllReportContent();
-        if (trainingScoreList.isEmpty()){
+    private String approvalAll() {
+        List<SysTrainingScore> trainingScoreList = trainingScoreService.selectAllReportContent();
+        if (trainingScoreList.isEmpty()) {
             return "没有可审批的数据";
         }
         for (int i = 0; i < trainingScoreList.size(); i++) {
             SysTrainingScore sysTrainingScore = trainingScoreList.get(i);
             String reportContent = sysTrainingScore.getReportContent();
-            int wordCount = reportContent.replace(" ","").length(); // 获取文本的字数
+            int wordCount = reportContent.replace(" ", "").length(); // 获取文本的字数
 
             int score;
             if (wordCount <= 50) {
@@ -71,7 +84,7 @@ public class TrainingScoreController {
             } else {
                 score = 100; // 超过350字直接满分
             }
-            SysTrainingScore trainingScore=new SysTrainingScore();
+            SysTrainingScore trainingScore = new SysTrainingScore();
             trainingScore.setId(sysTrainingScore.getId());
             trainingScore.setTrainingReportScore(score);
             trainingScoreService.updateByPrimaryKeySelective(trainingScore);
@@ -79,7 +92,7 @@ public class TrainingScoreController {
         return "审批完毕";
     }
 
-    //实训报告上传
+    //学生端实训报告上传
     @PostMapping("/uploadReport")
     private AjaxResult uploadReport(@RequestParam("file") @RequestPart(name = "file") MultipartFile file,
                                     @RequestParam Long id,
@@ -87,24 +100,69 @@ public class TrainingScoreController {
         return trainingScoreService.uploadReport(file, fileName, id);
     }
 
-    //实训报告提交
+    //学生端实训报告提交
     @PostMapping("/submitReport")
     public AjaxResult submitReport(@RequestParam String content,
                                    @RequestParam Long userId) {
         return trainingScoreService.submitReport(content, userId);
     }
 
+    //    老师端文件下载
+    @GetMapping("/downloadReport")
+    public AjaxResult downloadReport(@RequestParam HttpServletResponse response, @RequestParam Long id) {
+        return trainingScoreService.downloadReport(response, id);
+    }
+
+
+    //    老师端按班级导出
+    @PostMapping("/exportByClass")
+    public void exportByClass(HttpServletResponse response, String className) {
+        // 根据班级名称查询对应的用户列表
+        List<SysUser> userList = sysUserMapper.selectClassStuNumberNameByClass(className);
+        SysTrainingScoreExample trainingScoreExample = new SysTrainingScoreExample();
+        List<SysTrainingScore> sysTrainingScores = trainingScoreMapper.selectByExample(trainingScoreExample);
+        List<ReportDto> reportDtoList = new ArrayList<>();
+        if (!userList.isEmpty()) {
+            for (SysUser sysUser : userList) {
+                if (!sysTrainingScores.isEmpty()) {
+                    for (SysTrainingScore sysTrainingScore : sysTrainingScores) {
+                        ReportDto reportDto = new ReportDto();
+                        reportDto.setFileName(sysTrainingScore.getReportFilename());
+                        if (sysTrainingScore.getReportSubmissionScore() == null) {
+                            reportDto.setReportSubmissionScore(0);
+                        }
+                        if (sysTrainingScore.getTrainingOperationScore() == null) {
+                            reportDto.setTrainingOperationScore(0);
+                        }
+                        reportDto.setReportSubmissionScore(sysTrainingScore.getReportSubmissionScore());
+                        reportDto.setTrainingOperationScore(sysTrainingScore.getTrainingOperationScore());
+                        reportDto.setScoreTotal(sysTrainingScore.getTotalscore());
+                        reportDto.setName(sysUser.getUserName());
+                        reportDto.setStuClass(sysUser.getStuClass());
+                        reportDto.setStuNumber(sysUser.getStudentNumber());
+                        reportDtoList.add(reportDto);
+                    }
+                }
+            }
+        }
+        // 创建Excel工具类实例,指定Excel中需要导出的字段与对应的实体类属性
+        ExcelUtil<ReportDto> util = new ExcelUtil<>(ReportDto.class);
+        // 导出Excel文件
+        util.exportExcel(response, reportDtoList, "班级数据");
+    }
+
+
     //   老师端报告提交页面查询
     @GetMapping("/teacherGetReport")
     public PageInfo<ReportDto> getReport(@RequestParam Integer index, @RequestParam Integer size,
                                          @RequestParam(required = false) Double operatorWeight,
                                          @RequestParam(required = false) Double reportWeight,
                                          @RequestParam(required = false) String keyWord,
-                                         @RequestParam(required = false) String stuClass
-    ) {
+                                         @RequestParam(required = false) String stuClass) {
         return trainingScoreService.teacherGetReport(index, size, reportWeight, operatorWeight, keyWord, stuClass);
     }
 
+
     //   老师端下拉查询班级
     @GetMapping("/selectClass")
     public List<String> selectClass() {
@@ -114,7 +172,9 @@ public class TrainingScoreController {
 
     //   老师端报告评分
     @PostMapping("/reportGrade")
-    public void reportGrade(@RequestParam int reportScore, @RequestParam Long userId) {
+    public void reportGrade(@RequestBody JSONObject jsonObject) {
+        Integer reportScore = jsonObject.getInteger("reportScore");
+        Long userId = jsonObject.getLong("userId");
         SysTrainingScoreExample trainingScoreExample = new SysTrainingScoreExample();
         trainingScoreExample.createCriteria().andUseridEqualTo(userId);
         List<SysTrainingScore> sysTrainingScores = trainingScoreMapper.selectByExample(trainingScoreExample);
@@ -140,4 +200,6 @@ public class TrainingScoreController {
     public SysGradeWeight getWeight() {
         return gradeWeightMapper.selectByPrimaryKey(1L);
     }
-}
+
+
+}
\ No newline at end of file
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
index 139de80..d49f95c 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
@@ -72,7 +72,7 @@ public class SysUser extends BaseEntity {
     /**
      * 学号
      */
-    @Excel(name = "用户性别")
+    @Excel(name = "学号")
     private String studentNumber;
 
     /**
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/ReportDto.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/ReportDto.java
index cca5dd9..d9437da 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/ReportDto.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/ReportDto.java
@@ -9,6 +9,15 @@ public class ReportDto {
     private Integer trainingOperationScore; //实验操作成绩
     private Double scoreTotal; //总成绩
     private String fileName; //上传报告名称
+    private Long userId;
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
 
     @Override
     public String toString() {
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
index e50aa07..5c01798 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
@@ -1,19 +1,21 @@
 package com.ruoyi.system.mapper;
 
 import java.util.List;
+
+import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import com.ruoyi.common.core.domain.entity.SysUser;
 
 /**
  * 用户表 数据层
- * 
+ *
  * @author ruoyi
  */
-public interface SysUserMapper
-{
+@Mapper
+public interface SysUserMapper {
     /**
      * 根据条件分页查询用户列表
-     * 
+     *
      * @param sysUser 用户信息
      * @return 用户信息集合信息
      */
@@ -21,7 +23,7 @@ public interface SysUserMapper
 
     /**
      * 根据条件分页查询已配用户角色列表
-     * 
+     *
      * @param user 用户信息
      * @return 用户信息集合信息
      */
@@ -29,7 +31,7 @@ public interface SysUserMapper
 
     /**
      * 根据条件分页查询未分配用户角色列表
-     * 
+     *
      * @param user 用户信息
      * @return 用户信息集合信息
      */
@@ -37,7 +39,7 @@ public interface SysUserMapper
 
     /**
      * 通过用户名查询用户
-     * 
+     *
      * @param userName 用户名
      * @return 用户对象信息
      */
@@ -45,7 +47,7 @@ public interface SysUserMapper
 
     /**
      * 通过用户ID查询用户
-     * 
+     *
      * @param userId 用户ID
      * @return 用户对象信息
      */
@@ -53,7 +55,7 @@ public interface SysUserMapper
 
     /**
      * 新增用户信息
-     * 
+     *
      * @param user 用户信息
      * @return 结果
      */
@@ -61,7 +63,7 @@ public interface SysUserMapper
 
     /**
      * 修改用户信息
-     * 
+     *
      * @param user 用户信息
      * @return 结果
      */
@@ -69,16 +71,16 @@ public interface SysUserMapper
 
     /**
      * 修改用户头像
-     * 
+     *
      * @param userName 用户名
-     * @param avatar 头像地址
+     * @param avatar   头像地址
      * @return 结果
      */
     public int updateUserAvatar(@Param("userName") String userName, @Param("avatar") String avatar);
 
     /**
      * 重置用户密码
-     * 
+     *
      * @param userName 用户名
      * @param password 密码
      * @return 结果
@@ -87,7 +89,7 @@ public interface SysUserMapper
 
     /**
      * 通过用户ID删除用户
-     * 
+     *
      * @param userId 用户ID
      * @return 结果
      */
@@ -95,7 +97,7 @@ public interface SysUserMapper
 
     /**
      * 批量删除用户信息
-     * 
+     *
      * @param userIds 需要删除的用户ID
      * @return 结果
      */
@@ -103,7 +105,7 @@ public interface SysUserMapper
 
     /**
      * 校验用户名称是否唯一
-     * 
+     *
      * @param userName 用户名称
      * @return 结果
      */
@@ -129,7 +131,9 @@ public interface SysUserMapper
     List<SysUser> selectClassStuNumberName();
 
     //查询班级
-    List<String>selectClass();
+    List<String> selectClass();
+
+    List<SysUser> selectByNameStuNum(@Param("stuClass") String stuClass, @Param("keyWord") String keyWord);
 
-    List<SysUser> selectByNameStuNum(@Param("stuClass") String stuClass,@Param("keyWord") String keyWord);
+    List<SysUser> selectClassStuNumberNameByClass(@Param("stuClass") String stuClass);
 }
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysTrainingScoreService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysTrainingScoreService.java
index 2e34959..bded8ef 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysTrainingScoreService.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysTrainingScoreService.java
@@ -2,17 +2,16 @@ package com.ruoyi.system.service;
 
 import com.github.pagehelper.PageInfo;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.system.domain.SysTrainingScore;
 import com.ruoyi.system.domain.vo.ReportDto;
 import org.springframework.web.multipart.MultipartFile;
 
-import com.ruoyi.system.domain.SysTrainingScore;
-
-import java.math.BigInteger;
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 public interface ISysTrainingScoreService {
 
-    SysTrainingScore checkStatusAndControlsName(Long userId,String controlsName);
+    SysTrainingScore checkStatusAndControlsName(Long userId, String controlsName);
 
     AjaxResult uploadReport(MultipartFile file, String fileName, Long id);
 
@@ -23,7 +22,10 @@ public interface ISysTrainingScoreService {
     SysTrainingScore selectByUserId(Long userId);
 
     List<SysTrainingScore> selectAllReportContent();
-    PageInfo<ReportDto> teacherGetReport(Integer index, Integer size , Double reportWeight, Double operatorWeight, String keyWord, String stuClass);
 
-    List<String>selectClass();
+    PageInfo<ReportDto> teacherGetReport(Integer index, Integer size, Double reportWeight, Double operatorWeight, String keyWord, String stuClass);
+
+    List<String> selectClass();
+
+    AjaxResult downloadReport(HttpServletResponse response, Long id);
 }
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTrainingScoreServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTrainingScoreServiceImpl.java
index eb7f61c..20ee2f7 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTrainingScoreServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTrainingScoreServiceImpl.java
@@ -19,6 +19,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -44,11 +45,41 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService {
         return trainingScores.get(0);
     }
 
+
+    @Override
+    public SysTrainingScore checkStatusAndControlsName(Long userId, String controlsName) {
+        SysTrainingScoreExample example = new SysTrainingScoreExample();
+        SysTrainingScoreExample.Criteria criteria = example.createCriteria();
+        criteria.andUseridEqualTo(userId);
+        List<SysTrainingScore> trainingScores = trainingScoreMapper.selectByExample(example);
+        SysTrainingScore sysTrainingScore = trainingScores.get(0);
+        if (sysTrainingScore.getStatus() == 1) {
+            return null;
+        } else {
+            if (sysTrainingScore.get(controlsName) == null || ("").equals(sysTrainingScore.get(controlsName))) {
+                Map<String, Integer> trainingScoreConstantsMap = TrainingScoreConstants.getTrainingScoreConstantsMap();
+                Integer score = trainingScoreConstantsMap.get(controlsName);
+                SysTrainingScore trainingScore = new SysTrainingScore();
+                trainingScore.setId(sysTrainingScore.getId());
+                trainingScore.set(controlsName, String.valueOf(score));
+                trainingScoreMapper.updateByPrimaryKeySelective(trainingScore);
+                sysTrainingScore.set(controlsName, String.valueOf(score));
+                return sysTrainingScore;
+            }
+            return null;
+        }
+    }
+
+
+    public void updateByPrimaryKeySelective(SysTrainingScore trainingScore) {
+        trainingScoreMapper.updateByPrimaryKeySelective(trainingScore);
+    }
+
+
     @Override
     public PageInfo<ReportDto> teacherGetReport(Integer index, Integer size, Double reportWeight, Double operatorWeight, String keyWord, String stuClass) {
         PageHelper.startPage(index, size);
         List<ReportDto> reportDtoList = new ArrayList<>();
-        double total = 100;
         SysTrainingScoreExample trainingScoreExample = new SysTrainingScoreExample();
         if (stuClass != null || keyWord != null) {
             List<SysUser> users = sysUserMapper.selectByNameStuNum(stuClass, keyWord);
@@ -57,7 +88,7 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService {
                 List<SysTrainingScore> sysTrainingScores = trainingScoreMapper.selectByExample(trainingScoreExample);
                 if (!sysTrainingScores.isEmpty()) {
                     SysTrainingScore sysTrainingScore = sysTrainingScores.get(0);
-                    ReportDto reportDto = createReportDto(sysTrainingScore, user, total);
+                    ReportDto reportDto = createReportDto(sysTrainingScore, user, reportWeight, operatorWeight);
                     reportDtoList.add(reportDto);
                 }
             }
@@ -69,7 +100,7 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService {
             List<SysTrainingScore> sysTrainingScores = trainingScoreMapper.selectByExample(trainingScoreExample);
             if (!sysTrainingScores.isEmpty()) {
                 SysTrainingScore sysTrainingScore = sysTrainingScores.get(0);
-                ReportDto reportDto = createReportDto(sysTrainingScore, sysUser, total);
+                ReportDto reportDto = createReportDto(sysTrainingScore, sysUser, reportWeight, operatorWeight);
                 reportDtoList.add(reportDto);
             }
         }
@@ -82,34 +113,51 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService {
     }
 
 
-    @Override
-    public SysTrainingScore checkStatusAndControlsName(Long userId, String controlsName) {
-        SysTrainingScoreExample example = new SysTrainingScoreExample();
-        SysTrainingScoreExample.Criteria criteria = example.createCriteria();
-        criteria.andUseridEqualTo(userId);
-        List<SysTrainingScore> trainingScores = trainingScoreMapper.selectByExample(example);
-        SysTrainingScore sysTrainingScore = trainingScores.get(0);
-        if (sysTrainingScore.getStatus() == 1) {
-            return null;
-        } else {
-            if (sysTrainingScore.get(controlsName) == null || ("").equals(sysTrainingScore.get(controlsName))) {
-                Map<String, Integer> trainingScoreConstantsMap = TrainingScoreConstants.getTrainingScoreConstantsMap();
-                Integer score = trainingScoreConstantsMap.get(controlsName);
-                SysTrainingScore trainingScore = new SysTrainingScore();
-                trainingScore.setId(sysTrainingScore.getId());
-                trainingScore.set(controlsName, String.valueOf(score));
-                trainingScoreMapper.updateByPrimaryKeySelective(trainingScore);
-                sysTrainingScore.set(controlsName, String.valueOf(score));
-                return sysTrainingScore;
+    //    算分
+    private ReportDto createReportDto(SysTrainingScore sysTrainingScore, SysUser user, Double reportWeight, Double operatorWeight) {
+        ReportDto reportDto = new ReportDto();
+        reportDto.setFileName(sysTrainingScore.getReportFilename());
+        Integer reportSubmissionScore = sysTrainingScore.getReportSubmissionScore();   // 报告成绩
+        reportDto.setReportSubmissionScore(reportSubmissionScore);
+        Integer trainingOperationScore = sysTrainingScore.getTrainingOperationScore();  // 操作成绩
+        reportDto.setTrainingOperationScore(trainingOperationScore);
+        reportDto.setName(user.getUserName());
+        reportDto.setStuClass(user.getStuClass());
+        reportDto.setStuNumber(user.getStudentNumber());
+        reportDto.setUserId(user.getUserId());
+        if (reportSubmissionScore != null && trainingOperationScore != null) {
+            SysGradeWeight sysGradeWeight = gradeWeightMapper.selectByPrimaryKey(1L);
+            Double oldReportWeight = sysGradeWeight.getReportWeight();
+            Double oldOperatorWeight = sysGradeWeight.getOperatorWeight();
+            if (reportWeight != null) {
+                sysGradeWeight.setReportWeight(reportWeight);
+            } else if (oldReportWeight != null) {
+                reportWeight = oldReportWeight;
+            } else {
+                reportWeight = 0.1; // 设置默认权重
             }
-            return null;
+
+            if (operatorWeight != null) {
+                sysGradeWeight.setOperatorWeight(operatorWeight);
+            } else if (oldOperatorWeight != null) {
+                operatorWeight = oldOperatorWeight;
+            } else {
+                operatorWeight = 0.9; // 设置默认权重
+            }
+
+            Double totalScore = (reportSubmissionScore * reportWeight) + (trainingOperationScore * operatorWeight);
+            reportDto.setScoreTotal(totalScore);
+            sysTrainingScore.setTotalscore(totalScore);
+            trainingScoreMapper.updateByPrimaryKeySelective(sysTrainingScore);
+            gradeWeightMapper.updateByPrimaryKeySelective(sysGradeWeight);
+        } else {
+            reportDto.setScoreTotal(null);
         }
+        return reportDto;
     }
 
-    public void updateByPrimaryKeySelective(SysTrainingScore trainingScore) {
-        trainingScoreMapper.updateByPrimaryKeySelective(trainingScore);
-    }
 
+    //上传
     @Override
     public AjaxResult uploadReport(MultipartFile file, String fileName, Long id) {
         String filePath = fileUtil.upload(file);
@@ -139,6 +187,8 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService {
         return null;
     }
 
+
+    //提交
     @Override
     public AjaxResult submitReport(String content, Long userId) {
         SysTrainingScoreExample trainingScoreExample = new SysTrainingScoreExample();
@@ -156,40 +206,31 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService {
     }
 
 
-    private ReportDto createReportDto(SysTrainingScore sysTrainingScore, SysUser user, Double toatle) {
-        ReportDto reportDto = new ReportDto();
-        reportDto.setFileName(sysTrainingScore.getReportFilename());
-        Integer reportSubmissionScore = sysTrainingScore.getReportSubmissionScore();   // 报告成绩
-        reportDto.setReportSubmissionScore(reportSubmissionScore);
-        Integer trainingOperationScore = sysTrainingScore.getTrainingOperationScore();  // 操作成绩
-        reportDto.setTrainingOperationScore(trainingOperationScore);
-        SysGradeWeight sysGradeWeight = gradeWeightMapper.selectByPrimaryKey(1L);
-        Double reportWeight = sysGradeWeight.getReportWeight();
-        Double operatorWeight = sysGradeWeight.getOperatorWeight();
-        if (reportWeight == null) {
-            reportWeight = 0.1;
-        }
-        if (operatorWeight == null) {
-            operatorWeight = 0.9;
-        }
-        if (reportSubmissionScore != null && trainingOperationScore != null) {
-            Double totalScore = (reportSubmissionScore * reportWeight) + (trainingOperationScore * operatorWeight); // 总成绩=实训操作成绩*权重+实训报告成绩*权重
-            reportDto.setScoreTotal(totalScore);
-//            sysTrainingScore
-        } else {
-            reportDto.setScoreTotal(null);
-        }
-
-
-        reportDto.setName(user.getUserName());
-        reportDto.setStuClass(user.getStuClass());
-        reportDto.setStuNumber(user.getStudentNumber());
-
-        return reportDto;
-    }
-
     @Override
     public List<String> selectClass() {
         return sysUserMapper.selectClass();
     }
+
+    @Override
+    public AjaxResult downloadReport(HttpServletResponse response, Long id) {
+        // 根据id获取文件路径信息
+        SysTrainingScoreExample sysTrainingScoreExample = new SysTrainingScoreExample();
+        sysTrainingScoreExample.createCriteria().andUseridEqualTo(id);
+        List<SysTrainingScore> sysTrainingScores = trainingScoreMapper.selectByExample(sysTrainingScoreExample);
+
+        if (sysTrainingScores.isEmpty()) {
+            return AjaxResult.error(404,"报告不存在");
+        }
+        SysTrainingScore sysTrainingScore = sysTrainingScores.get(0);
+        String filePath = sysTrainingScore.getReportUploadPath();
+        String fileName = sysTrainingScore.getReportFilename();
+
+        try {
+            // 下载文件
+            fileUtil.download(response, fileName, filePath);
+        } catch (IllegalArgumentException e) {
+            return AjaxResult.error(400,"下载失败");
+        }
+        return AjaxResult.success("下载成功");
+    }
 }
diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
index d3d843f..9e90ecf 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
@@ -56,6 +56,8 @@
                u.email,
                u.avatar,
                u.phonenumber,
+               u.studentnumber,
+               u.stuclass,
                u.password,
                u.sex,
                u.status,
@@ -89,6 +91,16 @@
         FROM sys_user
     </select>
 
+    <select id="selectClassStuNumberNameByClass" resultMap="SysUserResult">
+        SELECT studentnumber, stuclass, user_name
+        FROM sys_user
+        <where>
+            <if test="stuClass != null and stuClass !=''">
+                AND stuclass = #{stuClass}
+            </if>
+        </where>
+    </select>
+
     <select id="selectClass" resultMap="SysUserResult">
         SELECT stuclass
         FROM sys_user
@@ -213,6 +225,8 @@
         <if test="email != null and email != ''">email,</if>
         <if test="avatar != null and avatar != ''">avatar,</if>
         <if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
+        <if test="studentNumber != null and studentNumber != ''">studentnumber,</if>
+        <if test="stuClass != null and stuClass != ''">stuclass,</if>
         <if test="sex != null and sex != ''">sex,</if>
         <if test="password != null and password != ''">password,</if>
         <if test="status != null and status != ''">status,</if>
@@ -227,6 +241,8 @@
         <if test="email != null and email != ''">#{email},</if>
         <if test="avatar != null and avatar != ''">#{avatar},</if>
         <if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
+        <if test="studentNumber != null and studentNumber != ''">#{studentNumber},</if>
+        <if test="stuClass != null and stuClass != ''">#{stuClass},</if>
         <if test="sex != null and sex != ''">#{sex},</if>
         <if test="password != null and password != ''">#{password},</if>
         <if test="status != null and status != ''">#{status},</if>
@@ -244,6 +260,8 @@
             <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
             <if test="email != null ">email = #{email},</if>
             <if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
+            <if test="studentNumber != null and studentNumber != ''">#{studentNumber},</if>
+            <if test="stuClass != null and stuClass != ''">#{stuClass},</if>
             <if test="sex != null and sex != ''">sex = #{sex},</if>
             <if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
             <if test="password != null and password != ''">password = #{password},</if>