wangliang před 1 rokem
rodič
revize
2646ece783
15 změnil soubory, kde provedl 273 přidání a 97 odebrání
  1. 37 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamStudentDto.java
  2. 16 5
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/report/ReportCourseEvaluationResultDto.java
  3. 11 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamStudentMapper.java
  4. 10 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamStudentService.java
  5. 10 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TCPaperStructService.java
  6. 10 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TRBasicInfoService.java
  7. 13 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamStudentServiceImpl.java
  8. 4 4
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TCFinalScoreServiceImpl.java
  9. 23 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TCPaperStructServiceImpl.java
  10. 3 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TCUsualScoreServiceImpl.java
  11. 38 17
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TRBasicInfoServiceImpl.java
  12. 18 0
      distributed-print-business/src/main/resources/mapper/ExamStudentMapper.xml
  13. 2 13
      distributed-print/src/main/java/com/qmth/distributed/print/api/TCUsualScoreController.java
  14. 78 52
      distributed-print/src/main/java/com/qmth/distributed/print/api/TRBasicInfoController.java
  15. binární
      distributed-print/src/main/resources/static/course_degree_report.docx

+ 37 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamStudentDto.java

@@ -0,0 +1,37 @@
+package com.qmth.distributed.print.business.bean.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * @Description: 考生 dto
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2024/3/14
+ */
+public class ExamStudentDto implements Serializable {
+
+    @ApiModelProperty(value = "班级名称")
+    private String clazzNames;
+
+    @ApiModelProperty(value = "老师名称")
+    private String teacherNames;
+
+    public String getClazzNames() {
+        return clazzNames;
+    }
+
+    public void setClazzNames(String clazzNames) {
+        this.clazzNames = clazzNames;
+    }
+
+    public String getTeacherNames() {
+        return teacherNames;
+    }
+
+    public void setTeacherNames(String teacherNames) {
+        this.teacherNames = teacherNames;
+    }
+}

+ 16 - 5
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/report/ReportCourseEvaluationResultDto.java

@@ -1,5 +1,7 @@
 package com.qmth.distributed.print.business.bean.dto.report;
 
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
@@ -15,6 +17,10 @@ import java.util.List;
  */
 public class ReportCourseEvaluationResultDto implements Serializable {
 
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "权重变化id")
+    private Long weightSettingSign;
+
     @ApiModelProperty(value = "课程目标总达成评价值")
     private BigDecimal targetEvaluationSumValue;
 
@@ -25,13 +31,10 @@ public class ReportCourseEvaluationResultDto implements Serializable {
 
     }
 
-    public ReportCourseEvaluationResultDto(BigDecimal targetEvaluationSumValue, List<CourseTargetWebDto> targetList) {
+    public ReportCourseEvaluationResultDto(BigDecimal targetEvaluationSumValue, List<CourseTargetWebDto> targetList, Long weightSettingSign) {
         this.targetEvaluationSumValue = targetEvaluationSumValue;
         this.targetList = targetList;
-    }
-
-    public ReportCourseEvaluationResultDto(List<CourseTargetWebDto> targetList) {
-        this.targetList = targetList;
+        this.weightSettingSign = weightSettingSign;
     }
 
     public BigDecimal getTargetEvaluationSumValue() {
@@ -49,4 +52,12 @@ public class ReportCourseEvaluationResultDto implements Serializable {
     public void setTargetList(List<CourseTargetWebDto> targetList) {
         this.targetList = targetList;
     }
+
+    public Long getWeightSettingSign() {
+        return weightSettingSign;
+    }
+
+    public void setWeightSettingSign(Long weightSettingSign) {
+        this.weightSettingSign = weightSettingSign;
+    }
 }

+ 11 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamStudentMapper.java

@@ -3,6 +3,7 @@ package com.qmth.distributed.print.business.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseClassDto;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto;
+import com.qmth.distributed.print.business.bean.dto.ExamStudentDto;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentPdfInfoDto;
 import com.qmth.distributed.print.business.entity.ExamStudent;
 import org.apache.ibatis.annotations.Param;
@@ -47,11 +48,20 @@ public interface ExamStudentMapper extends BaseMapper<ExamStudent> {
 
     @SuppressWarnings("MybatisXMapperMethodInspection")
     List<ExamStudentCourseClassDto> listExamStudentByPaperNumberAndPaperType(@Param("batchId") Long batchId, @Param("examId") Long examId, @Param("paperNumber") String paperNumber,
-            @Param("paperType") String paperType);
+                                                                             @Param("paperType") String paperType);
 
     List<String> listUserClass(@Param("schoolId") Long schoolId, @Param("examId") Long examId, @Param("paperNumber") String paperNumber);
 
     ExamStudent listByExamDetailCourseIdLimit1(@Param("schoolId") Long schoolId, @Param("examDetailCourseId") Long examDetailCourseId);
 
     List<ExamStudent> listByExamDetailCourseIdNotIntMarkStudent(@Param("examDetailCourseId") Long examDetailCourseId, @Param("paperType") String paperType);
+
+    /**
+     * 查询班级和老师信息
+     *
+     * @param examId
+     * @param paperNumber
+     * @return
+     */
+    ExamStudentDto queryByExamIdAndPaperNumber(@Param("examId") Long examId, @Param("paperNumber") String paperNumber);
 }

+ 10 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamStudentService.java

@@ -2,6 +2,7 @@ package com.qmth.distributed.print.business.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto;
+import com.qmth.distributed.print.business.bean.dto.ExamStudentDto;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentPdfInfoDto;
 import com.qmth.distributed.print.business.entity.ExamStudent;
 
@@ -46,4 +47,13 @@ public interface ExamStudentService extends IService<ExamStudent> {
     int countByExamDetailCourseIdAndStudentCode(Long examDetailCourseId, String studentCode);
 
     List<ExamStudent> listByExamDetailCourseId(Long examDetailCourseId);
+
+    /**
+     * 查询班级和老师信息
+     *
+     * @param examId
+     * @param paperNumber
+     * @return
+     */
+    ExamStudentDto queryByExamIdAndPaperNumber(Long examId, String paperNumber);
 }

+ 10 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TCPaperStructService.java

@@ -1,7 +1,7 @@
 package com.qmth.distributed.print.business.service;
 
-import com.qmth.distributed.print.business.entity.TCPaperStruct;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.distributed.print.business.entity.TCPaperStruct;
 
 /**
  * <p>
@@ -13,4 +13,13 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface TCPaperStructService extends IService<TCPaperStruct> {
 
+    /**
+     * 根据考试id/课程编码/试卷编码查询数据库数据
+     *
+     * @param examId
+     * @param courseCode
+     * @param paperNumber
+     * @return
+     */
+    public Boolean remove(Long examId, String courseCode, String paperNumber);
 }

+ 10 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TRBasicInfoService.java

@@ -6,6 +6,7 @@ import com.qmth.distributed.print.business.bean.dto.report.CourseTargetWebDto;
 import com.qmth.distributed.print.business.bean.dto.report.CourseTargetWordDto;
 import com.qmth.distributed.print.business.bean.dto.report.ReportCourseEvaluationResultDto;
 import com.qmth.distributed.print.business.bean.dto.report.ReportScoreViewDto;
+import com.qmth.distributed.print.business.bean.result.CourseWeightResult;
 import com.qmth.distributed.print.business.bean.result.report.PaperStructResult;
 import com.qmth.distributed.print.business.bean.result.report.word.CourseReportBean;
 import com.qmth.distributed.print.business.entity.TRBasicInfo;
@@ -121,4 +122,13 @@ public interface TRBasicInfoService extends IService<TRBasicInfo> {
      * @return
      */
     public Boolean remove(Long examId, String courseCode, String paperNumber);
+
+    /**
+     * 查找课程评价值
+     *
+     * @param examId
+     * @param courseCode
+     * @return
+     */
+    public CourseWeightResult findCourseWeightResultRmi(Long examId, String courseCode);
 }

+ 13 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamStudentServiceImpl.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto;
+import com.qmth.distributed.print.business.bean.dto.ExamStudentDto;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentPdfInfoDto;
 import com.qmth.distributed.print.business.entity.ExamDetailCourse;
 import com.qmth.distributed.print.business.entity.ExamStudent;
@@ -125,4 +126,16 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
                 .orderByAsc(ExamStudent::getId);
         return this.list(queryWrapper);
     }
+
+    /**
+     * 查询班级和老师信息
+     *
+     * @param examId
+     * @param paperNumber
+     * @return
+     */
+    @Override
+    public ExamStudentDto queryByExamIdAndPaperNumber(Long examId, String paperNumber) {
+        return this.baseMapper.queryByExamIdAndPaperNumber(examId, paperNumber);
+    }
 }

+ 4 - 4
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TCFinalScoreServiceImpl.java

@@ -128,7 +128,7 @@ public class TCFinalScoreServiceImpl extends ServiceImpl<TCFinalScoreMapper, TCF
                         for (int j = 0; j < strs.length; j++) {
                             JSONObject jsonObject = new JSONObject();
                             if (Objects.isNull(strs[j]) || Objects.equals(strs[j].trim(), "")) {
-                                errorData.add("excel第" + (i + 1) + "行[").add(columnNames[j] + "]为空;").add("\r\n");
+                                errorData.add("excel第").add((i + 1) + "").add("行[").add(columnNames[j] + "]为空;").add("\r\n");
                                 error = true;
                             } else {
                                 if (Objects.equals(columnNames[j].trim(), "学号")) {
@@ -147,7 +147,7 @@ public class TCFinalScoreServiceImpl extends ServiceImpl<TCFinalScoreMapper, TCF
                         }
                         if (jsonArray.size() > 0) {
                             if (score.doubleValue() > totalScore.doubleValue()) {
-                                errorData.add("excel第" + (i + 1) + "行[总分大于试卷总分]").add("\r\n");
+                                errorData.add("excel第").add((i + 1) + "").add("行[总分大于试卷总分]").add("\r\n");
                                 error = true;
                             } else {
                                 score = score.setScale(2, BigDecimal.ROUND_HALF_UP);
@@ -161,7 +161,7 @@ public class TCFinalScoreServiceImpl extends ServiceImpl<TCFinalScoreMapper, TCF
                     }
                 }
                 if (!CollectionUtils.isEmpty(tcFinalScoreList)) {
-                    successData.add("共导入" + tcFinalScoreList.size() + "条数据");
+                    successData.add("共导入").add(tcFinalScoreList.size() + "").add("条数据");
                     List<TCFinalScore> tcFinalScoreDbSourceList = tcFinalScoreService.queryDbSourceList(examId, courseCode, paperNumber);
                     if (CollectionUtils.isEmpty(tcFinalScoreDbSourceList) || !CollectionUtils.isEqualCollection(tcFinalScoreDbSourceList, tcFinalScoreList)) {
                         tcFinalScoreService.removeByIds(tcFinalScoreDbSourceList.stream().map(s -> s.getId()).collect(Collectors.toList()));
@@ -283,7 +283,7 @@ public class TCFinalScoreServiceImpl extends ServiceImpl<TCFinalScoreMapper, TCF
                     }
                 }
                 if (!CollectionUtils.isEmpty(tcFinalScoreList)) {
-                    successData.add("共同步" + tcFinalScoreList.size() + "条数据");
+                    successData.add("共同步").add(tcFinalScoreList.size() + "").add("条数据");
                     List<TCFinalScore> tcFinalScoreDbSourceList = tcFinalScoreService.queryDbSourceList(examId, courseCode, paperNumber);
                     if (CollectionUtils.isEmpty(tcFinalScoreDbSourceList) || !CollectionUtils.isEqualCollection(tcFinalScoreDbSourceList, tcFinalScoreList)) {
                         tcFinalScoreService.removeByIds(tcFinalScoreDbSourceList.stream().map(s -> s.getId()).collect(Collectors.toList()));

+ 23 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TCPaperStructServiceImpl.java

@@ -1,10 +1,14 @@
 package com.qmth.distributed.print.business.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.distributed.print.business.entity.TCPaperStruct;
 import com.qmth.distributed.print.business.mapper.TCPaperStructMapper;
 import com.qmth.distributed.print.business.service.TCPaperStructService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
 
 /**
  * <p>
@@ -17,4 +21,22 @@ import org.springframework.stereotype.Service;
 @Service
 public class TCPaperStructServiceImpl extends ServiceImpl<TCPaperStructMapper, TCPaperStruct> implements TCPaperStructService {
 
+    @Resource
+    TCPaperStructService tcPaperStructService;
+
+    /**
+     * 根据考试id/课程编码/试卷编码查询数据库数据
+     *
+     * @param examId
+     * @param courseCode
+     * @param paperNumber
+     * @return
+     */
+    @Override
+    @Transactional
+    public Boolean remove(Long examId, String courseCode, String paperNumber) {
+        return tcPaperStructService.remove(new QueryWrapper<TCPaperStruct>().lambda().eq(TCPaperStruct::getExamId, examId)
+                .eq(TCPaperStruct::getCourseCode, courseCode)
+                .eq(TCPaperStruct::getPaperNumber, paperNumber));
+    }
 }

+ 3 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TCUsualScoreServiceImpl.java

@@ -110,7 +110,7 @@ public class TCUsualScoreServiceImpl extends ServiceImpl<TCUsualScoreMapper, TCU
                         for (int j = 0; j < strs.length; j++) {
                             JSONObject jsonObject = new JSONObject();
                             if (Objects.isNull(strs[j]) || Objects.equals(strs[j].trim(), "")) {
-                                errorData.add("excel第" + (i + 1) + "行[").add(columnNames[j] + "]为空;").add("\r\n");
+                                errorData.add("excel第").add((i + 1) + "").add("行[").add(columnNames[j] + "]为空;").add("\r\n");
                                 error = true;
                             } else {
                                 if (Objects.equals(columnNames[j].trim(), "学号")) {
@@ -120,7 +120,7 @@ public class TCUsualScoreServiceImpl extends ServiceImpl<TCUsualScoreMapper, TCU
                                 } else {
                                     Double score = Double.parseDouble(strs[j]);
                                     if (score.doubleValue() > totalScore.doubleValue()) {
-                                        errorData.add("excel第" + (i + 1) + "行[" + columnNames[j] + "总分大于试卷总分]").add("\r\n");
+                                        errorData.add("excel第").add((i + 1) + "").add("行[").add(columnNames[j]).add("总分大于试卷总分]").add("\r\n");
                                         error = true;
                                     } else {
                                         jsonObject.put("name", columnNames[j]);
@@ -140,7 +140,7 @@ public class TCUsualScoreServiceImpl extends ServiceImpl<TCUsualScoreMapper, TCU
                     }
                 }
                 if (!CollectionUtils.isEmpty(tcUsualScoreList)) {
-                    successData.add("共导入" + tcUsualScoreList.size() + "条数据");
+                    successData.add("共导入").add(tcUsualScoreList.size() + "").add("条数据");
                     List<TCUsualScore> tcUsualScoreDbSourceList = tcUsualScoreService.queryDbSourceList(examId, courseCode, paperNumber);
                     if (CollectionUtils.isEmpty(tcUsualScoreDbSourceList) || !CollectionUtils.isEqualCollection(tcUsualScoreDbSourceList, tcUsualScoreList)) {
                         tcUsualScoreService.removeByIds(tcUsualScoreDbSourceList.stream().map(s -> s.getId()).collect(Collectors.toList()));

+ 38 - 17
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TRBasicInfoServiceImpl.java

@@ -11,6 +11,7 @@ import com.deepoove.poi.data.style.RowStyle;
 import com.google.gson.reflect.TypeToken;
 import com.qmth.distributed.print.business.bean.dto.CourseWeightDetailDto;
 import com.qmth.distributed.print.business.bean.dto.CourseWeightDto;
+import com.qmth.distributed.print.business.bean.dto.ExamStudentDto;
 import com.qmth.distributed.print.business.bean.dto.FinalScoreDto;
 import com.qmth.distributed.print.business.bean.dto.report.*;
 import com.qmth.distributed.print.business.bean.result.CourseWeightResult;
@@ -19,7 +20,6 @@ import com.qmth.distributed.print.business.bean.result.report.PaperStructResult;
 import com.qmth.distributed.print.business.bean.result.report.word.CourseReportBean;
 import com.qmth.distributed.print.business.bean.result.report.word.CourseTargetTableBean3;
 import com.qmth.distributed.print.business.bean.result.report.word.CourseTargetTableBean4;
-import com.qmth.distributed.print.business.entity.ExamStudent;
 import com.qmth.distributed.print.business.entity.TCPaperStruct;
 import com.qmth.distributed.print.business.entity.TRBasicInfo;
 import com.qmth.distributed.print.business.entity.TRExamStudent;
@@ -120,10 +120,13 @@ public class TRBasicInfoServiceImpl extends ServiceImpl<TRBasicInfoMapper, TRBas
      */
     @Override
     public Map<String, Object> getReportCalculateParams(TRBasicInfo trBasicInfo, List<PaperStructResult> paperStructResultList) {
-        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         Map<String, Object> paramsMap = new HashMap<>();
         //查询考生数据
         List<FinalScoreResult> finalScoreResultList = tcFinalScoreService.examStudentOverview(trBasicInfo.getExamId(), trBasicInfo.getCourseCode(), trBasicInfo.getPaperNumber());//考生成绩
+        if (CollectionUtils.isEmpty(finalScoreResultList)) {
+            throw ExceptionResultEnum.ERROR.exception("考试数据为空");
+        }
+
         Map<String, Map<Long, Map<Long, DimensionDto>>> finalScoreExamStudentDimensionMap = new LinkedHashMap<>();//汇总考生课程目标-知识点卷面分(知识点得分用)
         Map<Long, Map<Long, DimensionDto>> targetDimensionMap = new LinkedHashMap<>();//课程目标-知识点-卷面分(word报表用)
 
@@ -133,19 +136,15 @@ public class TRBasicInfoServiceImpl extends ServiceImpl<TRBasicInfoMapper, TRBas
         Map<Long, CourseTargetWordDto> targetWordMap = null;//word目标集合
         Map<Long, CourseTargetWebDto> targetWebMap = null;//web目标集合
         Map<String, ReportEvaluationDto> usualScoreMap = null;//平时作业集合
+        Long weightSettingSign = null;//权重变化id
         if (!CollectionUtils.isEmpty(finalScoreResultList)) {
             targetWordMap = new LinkedHashMap<>();
             targetWebMap = new LinkedHashMap<>();
             usualScoreMap = new LinkedHashMap<>();
 
-            CourseWeightResult courseWeightResult = courseWeightService.findCourseWeight(trBasicInfo.getExamId(), trBasicInfo.getCourseCode(), sysUser.getId());
-            if (Objects.isNull(courseWeightResult)) {
-                throw ExceptionResultEnum.ERROR.exception("未设置课程目标数据");
-            }
+            CourseWeightResult courseWeightResult = trBasicInfoService.findCourseWeightResultRmi(trBasicInfo.getExamId(), trBasicInfo.getCourseCode());
             List<CourseWeightDto> courseWeightDtoList = courseWeightResult.getSubmitForm();
-            if (CollectionUtils.isEmpty(courseWeightDtoList)) {
-                throw ExceptionResultEnum.ERROR.exception("未设置课程目标评价方式");
-            }
+            weightSettingSign = courseWeightResult.getWeightSettingSign();
 
             BigDecimal bigDecimal = new BigDecimal(100);
             for (CourseWeightDto courseWeightDto : courseWeightDtoList) {
@@ -254,6 +253,7 @@ public class TRBasicInfoServiceImpl extends ServiceImpl<TRBasicInfoMapper, TRBas
         paramsMap.put("finalScoreResultMap", finalScoreResultMap);
         paramsMap.put("targetWordMap", targetWordMap);
         paramsMap.put("targetWebMap", targetWebMap);
+        paramsMap.put("weightSettingSign", weightSettingSign);
         return paramsMap;
     }
 
@@ -312,7 +312,7 @@ public class TRBasicInfoServiceImpl extends ServiceImpl<TRBasicInfoMapper, TRBas
                         courseTargetWordDto.setEvaluationValue(targetEvaluationValue);
                     }
                 }
-                reportCourseEvaluationResultDto = new ReportCourseEvaluationResultDto(targetEvaluationSumValue, new ArrayList<>(targetWebMap.values()));
+                reportCourseEvaluationResultDto = new ReportCourseEvaluationResultDto(targetEvaluationSumValue, new ArrayList<>(targetWebMap.values()), (Long) paramsMap.get("weightSettingSign"));
             }
             paramsMap.put("targetWebMap", targetWebMap);
         }
@@ -333,15 +333,14 @@ public class TRBasicInfoServiceImpl extends ServiceImpl<TRBasicInfoMapper, TRBas
         BasicSemester basicSemester = basicSemesterService.selectByExamId(markPaper.getExamId());
         Objects.requireNonNull(basicSemester, "未找到学期信息");
 
-        ExamStudent examStudent = examStudentService.getOne(new QueryWrapper<ExamStudent>().select(" GROUP_CONCAT(DISTINCT clazz_name) as clazzName ")
-                .eq("exam_id", markPaper.getExamId())
-                .eq("paper_number", markPaper.getPaperNumber()));
-        String teachingObject = Objects.nonNull(examStudent) ? examStudent.getClazzName() : null;
-        //TODO 有测试数据,待肖飞补充任课老师数据
+        ExamStudentDto examStudentDto = examStudentService.queryByExamIdAndPaperNumber(markPaper.getExamId(), markPaper.getPaperNumber());
+        String teachingObject = Objects.nonNull(examStudentDto) ? examStudentDto.getClazzNames() : null;
+        String teacher = Objects.nonNull(examStudentDto) ? examStudentDto.getTeacherNames() : null;
+
         if (Objects.isNull(trBasicInfo)) {
-            trBasicInfo = new TRBasicInfo(markPaper.getExamId(), markPaper.getCourseCode(), markPaper.getCourseName(), markPaper.getPaperNumber(), basicSemester.getName(), teachingObject, null, null, userId);
+            trBasicInfo = new TRBasicInfo(markPaper.getExamId(), markPaper.getCourseCode(), markPaper.getCourseName(), markPaper.getPaperNumber(), basicSemester.getName(), teachingObject, teacher, null, userId);
         } else {
-            trBasicInfo.setBasicInfo(markPaper.getExamId(), markPaper.getCourseCode(), markPaper.getCourseName(), markPaper.getPaperNumber(), basicSemester.getName(), teachingObject, "测试老师1", null);
+            trBasicInfo.setBasicInfo(markPaper.getExamId(), markPaper.getCourseCode(), markPaper.getCourseName(), markPaper.getPaperNumber(), basicSemester.getName(), teachingObject, teacher, null);
         }
         //课程基本情况
         ReportCourseBasicInfoDto reportCourseBasicInfoDto = new ReportCourseBasicInfoDto(trBasicInfo);
@@ -818,6 +817,28 @@ public class TRBasicInfoServiceImpl extends ServiceImpl<TRBasicInfoMapper, TRBas
                 .eq(TRBasicInfo::getPaperNumber, paperNumber));
     }
 
+    /**
+     * 查找课程评价值
+     *
+     * @param examId
+     * @param courseCode
+     * @return
+     */
+    @Override
+    public CourseWeightResult findCourseWeightResultRmi(Long examId, String courseCode) {
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        CourseWeightResult courseWeightResult = courseWeightService.findCourseWeight(examId, courseCode, sysUser.getId());
+        Objects.requireNonNull(courseWeightResult, "未设置课程目标数据");
+        Objects.requireNonNull(courseWeightResult.getCustomRate(), "未设置平时成绩权重");
+        Objects.requireNonNull(courseWeightResult.getDefaultRate(), "未设置期末考试权重");
+        Objects.requireNonNull(courseWeightResult.getWeightSettingSign(), "课程权重变化id为空");
+        List<CourseWeightDto> courseWeightDtoList = courseWeightResult.getSubmitForm();
+        if (CollectionUtils.isEmpty(courseWeightDtoList)) {
+            throw ExceptionResultEnum.ERROR.exception("未设置课程目标评价方式");
+        }
+        return courseWeightResult;
+    }
+
     /**
      * 获取行样式
      *

+ 18 - 0
distributed-print-business/src/main/resources/mapper/ExamStudentMapper.xml

@@ -230,6 +230,7 @@
         </where>
         limit 1
     </select>
+
     <select id="listByExamDetailCourseIdNotIntMarkStudent" resultMap="BaseResultMap">
         SELECT
             *
@@ -245,4 +246,21 @@
                           WHERE
                               es.id = ms.id)
     </select>
+
+    <select id="queryByExamIdAndPaperNumber" resultType="com.qmth.distributed.print.business.bean.dto.ExamStudentDto">
+        SELECT
+            GROUP_CONCAT(DISTINCT es.clazz_name) as clazzNames,
+            GROUP_CONCAT(DISTINCT su.real_name) as teacherNames
+        FROM
+            exam_student es
+            left join sys_user su on su.id = es.teacher_id
+        <where>
+            <if test="examId != null and examId != ''">
+                AND es.exam_id = #{examId}
+            </if>
+            <if test="paperNumber != null and paperNumber != ''">
+                AND es.paper_number = #{paperNumber}
+            </if>
+        </where>
+    </select>
 </mapper>

+ 2 - 13
distributed-print/src/main/java/com/qmth/distributed/print/api/TCUsualScoreController.java

@@ -13,7 +13,6 @@ import com.qmth.distributed.print.business.service.*;
 import com.qmth.teachcloud.common.annotation.OperationLogDetail;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.SysUser;
-import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.log.CustomizedOperationTypeEnum;
 import com.qmth.teachcloud.common.util.ResultUtil;
 import com.qmth.teachcloud.common.util.ServletUtil;
@@ -22,7 +21,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.CollectionUtils;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -58,9 +56,6 @@ public class TCUsualScoreController {
     @Resource
     PrintCommonService printCommonService;
 
-    @Resource
-    CourseWeightService courseWeightService;
-
     @Resource
     TRBasicInfoService trBasicInfoService;
 
@@ -85,15 +80,9 @@ public class TCUsualScoreController {
     public void usualScoreTemplateDownload(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
                                            @ApiParam(value = "科目编码", required = true) @RequestParam String courseCode,
                                            @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber) throws IOException {
-        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        CourseWeightResult courseWeightResult = courseWeightService.findCourseWeight(examId, courseCode, sysUser.getId());
-        if (Objects.isNull(courseWeightResult)) {
-            throw ExceptionResultEnum.ERROR.exception("未设置课程目标数据");
-        }
+        CourseWeightResult courseWeightResult = trBasicInfoService.findCourseWeightResultRmi(examId, courseCode);
         List<CourseWeightDto> courseWeightDtoList = courseWeightResult.getSubmitForm();
-        if (CollectionUtils.isEmpty(courseWeightDtoList)) {
-            throw ExceptionResultEnum.ERROR.exception("未设置课程目标评价方式");
-        }
+
         List<ExcelField> excelFieldList = new ArrayList<>();
         excelFieldList.addAll(new ArrayList<>(Arrays.asList(new ExcelField("studentCode", "学号", true), new ExcelField("name", "姓名", true))));
         courseWeightDtoList.stream().peek(e -> {

+ 78 - 52
distributed-print/src/main/java/com/qmth/distributed/print/api/TRBasicInfoController.java

@@ -9,6 +9,7 @@ import com.deepoove.poi.XWPFTemplate;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.bean.dto.report.*;
+import com.qmth.distributed.print.business.bean.result.CourseWeightResult;
 import com.qmth.distributed.print.business.bean.result.ScoreResult;
 import com.qmth.distributed.print.business.bean.result.report.ReportResult;
 import com.qmth.distributed.print.business.bean.result.report.word.CourseBasicBean;
@@ -48,6 +49,7 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -108,19 +110,26 @@ public class TRBasicInfoController {
         if (Objects.isNull(trBasicInfo)) {
             trBasicInfo = trBasicInfoService.getReportView(trBasicInfo, markPaper, sysUser.getId());
         } else {
-            ReportCourseBasicInfoDto reportCourseBasicInfoDto = new ReportCourseBasicInfoDto(trBasicInfo);
-            ReportCourseEvaluationSpreadDto reportCourseEvaluationSpreadDto = Objects.nonNull(trBasicInfo.getCourseEvaluationSpread()) ? JSONObject.parseObject(trBasicInfo.getCourseEvaluationSpread(), ReportCourseEvaluationSpreadDto.class) : null;
+            CourseWeightResult courseWeightResult = trBasicInfoService.findCourseWeightResultRmi(examId, courseCode);
             ReportCourseEvaluationResultDto reportCourseEvaluationResultDto = Objects.nonNull(trBasicInfo.getCourseEvaluationResult()) ? JSONObject.parseObject(trBasicInfo.getCourseEvaluationResult(), ReportCourseEvaluationResultDto.class) : null;
-            ReportCourseEvaluationResultDetailDto reportCourseEvaluationResultDetailDto = null;
-            List<TRExamStudent> trExamStudentList = trExamStudentService.list(new QueryWrapper<TRExamStudent>().lambda().eq(TRExamStudent::getrBasicInfoId, trBasicInfo.getId()));
-            if (!CollectionUtils.isEmpty(trExamStudentList)) {
-                List<ReportExamStudentDto> examStudentList = new ArrayList<>(trExamStudentList.size());
-                for (TRExamStudent trExamStudent : trExamStudentList) {
-                    examStudentList.add(new ReportExamStudentDto(trExamStudent));
+            if (Objects.nonNull(reportCourseEvaluationResultDto.getWeightSettingSign()) && reportCourseEvaluationResultDto.getWeightSettingSign().longValue() != courseWeightResult.getWeightSettingSign().longValue()) {
+                trExamStudentService.remove(examId, courseCode, paperNumber);
+                trBasicInfoService.remove(examId, courseCode, paperNumber);
+                trBasicInfo = trBasicInfoService.getReportView(trBasicInfo, markPaper, sysUser.getId());
+            } else {
+                ReportCourseBasicInfoDto reportCourseBasicInfoDto = new ReportCourseBasicInfoDto(trBasicInfo);
+                ReportCourseEvaluationSpreadDto reportCourseEvaluationSpreadDto = Objects.nonNull(trBasicInfo.getCourseEvaluationSpread()) ? JSONObject.parseObject(trBasicInfo.getCourseEvaluationSpread(), ReportCourseEvaluationSpreadDto.class) : null;
+                ReportCourseEvaluationResultDetailDto reportCourseEvaluationResultDetailDto = null;
+                List<TRExamStudent> trExamStudentList = trExamStudentService.list(new QueryWrapper<TRExamStudent>().lambda().eq(TRExamStudent::getrBasicInfoId, trBasicInfo.getId()));
+                if (!CollectionUtils.isEmpty(trExamStudentList)) {
+                    List<ReportExamStudentDto> examStudentList = new ArrayList<>(trExamStudentList.size());
+                    for (TRExamStudent trExamStudent : trExamStudentList) {
+                        examStudentList.add(new ReportExamStudentDto(trExamStudent));
+                    }
+                    reportCourseEvaluationResultDetailDto = new ReportCourseEvaluationResultDetailDto(examStudentList);
                 }
-                reportCourseEvaluationResultDetailDto = new ReportCourseEvaluationResultDetailDto(examStudentList);
+                trBasicInfo.setReportResult(new ReportResult(new ReportCommonDto(examId, courseCode, markPaper.getCourseName(), paperNumber), reportCourseBasicInfoDto, reportCourseEvaluationSpreadDto, reportCourseEvaluationResultDto, reportCourseEvaluationResultDetailDto));
             }
-            trBasicInfo.setReportResult(new ReportResult(new ReportCommonDto(examId, courseCode, markPaper.getCourseName(), paperNumber), reportCourseBasicInfoDto, reportCourseEvaluationSpreadDto, reportCourseEvaluationResultDto, reportCourseEvaluationResultDetailDto));
         }
 
         trBasicInfo.updateInfo(sysUser.getId());
@@ -161,6 +170,7 @@ public class TRBasicInfoController {
                              @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber) throws IOException {
         File txtFileTemp = null, fileTemp = null;
         try {
+            SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
             Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
             BasicSchool basicSchool = commonCacheService.schoolCache(schoolId);
 
@@ -169,60 +179,76 @@ public class TRBasicInfoController {
             Objects.requireNonNull(trBasicInfo.getCourseEvaluationResult(), "没有课程目标信息");
             Objects.requireNonNull(trBasicInfo.getCourseEvaluationResultDetail(), "没有课程考生信息");
 
-            //评价样本的基本信息
-            String period = Objects.nonNull(trBasicInfo.getPeriod()) ? trBasicInfo.getPeriod() : null;
-            String credit = Objects.nonNull(trBasicInfo.getCredit()) ? trBasicInfo.getCredit() : null;
-            period = Objects.nonNull(credit) ? period + "/" + credit : period;
-
+            CourseWeightResult courseWeightResult = trBasicInfoService.findCourseWeightResultRmi(examId, courseCode);
             ReportCourseEvaluationResultDto reportCourseEvaluationResultDto = JSONObject.parseObject(trBasicInfo.getCourseEvaluationResult(), ReportCourseEvaluationResultDto.class);
-            CourseBasicBean courseBasicBean = new CourseBasicBean(trBasicInfo.getCourseName(),
-                    trBasicInfo.getCourseCode(), null, trBasicInfo.getCourseType(),
-                    period, null, null, trBasicInfo.getDirector(),
-                    DateUtil.format(new Date(trBasicInfo.getCreateTime()), SystemConstant.DEFAULT_DATE_PATTERN),
-                    "测试:我们的目标是没有目标", reportCourseEvaluationResultDto.getTargetList().size());
+            if (Objects.nonNull(reportCourseEvaluationResultDto.getWeightSettingSign()) && reportCourseEvaluationResultDto.getWeightSettingSign().longValue() != courseWeightResult.getWeightSettingSign().longValue()) {
+                MarkPaper markPaper = markPaperService.getByExamIdAndPaperNumber(examId, paperNumber);
+                Objects.requireNonNull(markPaper, "未找到科目信息");
+                trExamStudentService.remove(examId, courseCode, paperNumber);
+                trBasicInfoService.remove(examId, courseCode, paperNumber);
+                trBasicInfoService.getReportView(trBasicInfo, markPaper, sysUser.getId());
+                this.reportExport(examId, courseCode, paperNumber);
+            } else {
+                //评价样本的基本信息
+                String period = Objects.nonNull(trBasicInfo.getPeriod()) ? trBasicInfo.getPeriod() : null;
+                String credit = Objects.nonNull(trBasicInfo.getCredit()) ? trBasicInfo.getCredit() : null;
+                period = Objects.nonNull(credit) ? period + "/" + credit : period;
 
-            CourseReportBean courseReportBean = new CourseReportBean(trBasicInfo.getOpenTime() + "《" + trBasicInfo.getCourseName() + "》", courseBasicBean);
+                JSONObject jsonObject = JSONObject.parseObject(trBasicInfo.getCourseEvaluationResultDetail());
+                List<CourseTargetWordDto> courseTargetWordDtoList = JSONArray.parseArray(jsonObject.get("targetWordMap").toString(), CourseTargetWordDto.class);
+                List<CourseTargetWebDto> courseTargetWebDtoList = JSONArray.parseArray(jsonObject.get("targetWebMap").toString(), CourseTargetWebDto.class);
 
-            JSONObject jsonObject = JSONObject.parseObject(trBasicInfo.getCourseEvaluationResultDetail());
-            List<CourseTargetWordDto> courseTargetWordDtoList = JSONArray.parseArray(jsonObject.get("targetWordMap").toString(), CourseTargetWordDto.class);
-            List<CourseTargetWebDto> courseTargetWebDtoList = JSONArray.parseArray(jsonObject.get("targetWebMap").toString(), CourseTargetWebDto.class);
+                StringJoiner courseTarget = new StringJoiner("");
+                courseTargetWordDtoList.stream().peek(s -> {
+                    courseTarget.add("      ").add(s.getTargetName()).add("——").add(s.getGraduationRequirementPoint()).add("\r\n");
+                }).collect(Collectors.toList());
 
-            //table1-课程目标目标与毕业要求指标点的对应关系
-            List<String> header2_1List = new ArrayList<>(Arrays.asList("课程目标", "支撑毕业要求")), header2_2List = new ArrayList<>();
-            header2_2List.addAll(header2_1List);
-            header2_1List.add("考核/评价环节及目标分值");
-            courseReportBean.setCourseTargetTable1(trBasicInfoService.buildWordTable1(courseTargetWordDtoList, header2_1List, header2_2List));
+                CourseBasicBean courseBasicBean = new CourseBasicBean(trBasicInfo.getCourseName(),
+                        trBasicInfo.getCourseCode(), null, trBasicInfo.getCourseType(),
+                        period, null, null, trBasicInfo.getDirector(),
+                        DateUtil.format(new Date(trBasicInfo.getCreateTime()), SystemConstant.DEFAULT_DATE_PATTERN),
+                        courseTarget.toString(), reportCourseEvaluationResultDto.getTargetList().size());
 
-            //table2-课程目标达成评价依据
-            courseReportBean.setCourseTargetTable2(trBasicInfoService.buildWordTable2(courseTargetWordDtoList, courseTargetWebDtoList, header2_1List, header2_2List));
+                CourseReportBean courseReportBean = new CourseReportBean(trBasicInfo.getOpenTime() + "《" + trBasicInfo.getCourseName() + "》", courseBasicBean);
 
-            //table3-课程课后作业考核/评价内容及目标分值
-            courseReportBean.setCourseTargetTable3(trBasicInfoService.buildWordTable3(courseTargetWordDtoList));
 
-            //table4-课程期末考试考核/评价内容及目标分值
-            courseReportBean.setCourseTargetTable4(trBasicInfoService.buildWordTable4(courseTargetWordDtoList));
+                //table1-课程目标目标与毕业要求指标点的对应关系
+                List<String> header2_1List = new ArrayList<>(Arrays.asList("课程目标", "支撑毕业要求")), header2_2List = new ArrayList<>();
+                header2_2List.addAll(header2_1List);
+                header2_1List.add("考核/评价环节及目标分值");
+                courseReportBean.setCourseTargetTable1(trBasicInfoService.buildWordTable1(courseTargetWordDtoList, header2_1List, header2_2List));
 
-            //examstudent-课程目标达成评价依据-考生
-            courseReportBean.setExamStudentTable1(trBasicInfoService.buildWordTable5(trBasicInfo, courseReportBean));
+                //table2-课程目标达成评价依据
+                courseReportBean.setCourseTargetTable2(trBasicInfoService.buildWordTable2(courseTargetWordDtoList, courseTargetWebDtoList, header2_1List, header2_2List));
 
-            InputStream inputStream = null;
-            txtFileTemp = SystemConstant.getFileTempVar(SystemConstant.WORD_PREFIX);
-            SysConfig sysConfig = commonCacheService.addSysConfigCache(schoolId, SystemConstant.SCHOOL_COURSE_DEGREE_TEMPLATE);
-            if (Objects.isNull(sysConfig)) {
-                inputStream = FileUtil.getStream("static/" + ImportTemplateEnum.STATIC_COURSE_DEGREE_REPORT.getTemplateName());
-            } else {
-                fileTemp = fileUploadService.downloadFile(Long.parseLong(sysConfig.getConfigValue()), fileTemp.getName());
-                inputStream = FileUtil.getStream(fileTemp.getPath());
-            }
-            FileUtils.copyInputStreamToFile(inputStream, txtFileTemp);
-            XWPFTemplate template = XWPFTemplate.compile(txtFileTemp.getAbsolutePath()).render(courseReportBean);
-            template.writeToFile(txtFileTemp.getAbsolutePath());
-            // 导出
-            String fileName = Objects.nonNull(basicSchool) ? basicSchool.getName() + "_" + courseReportBean.getTitle1() + "_" + ImportTemplateEnum.STATIC_COURSE_DEGREE_REPORT.getFileName() + SystemConstant.WORD_PREFIX : courseReportBean.getTitle1() + "_" + ImportTemplateEnum.STATIC_COURSE_DEGREE_REPORT.getFileName() + SystemConstant.WORD_PREFIX;
-            FileUtil.outputFile(ServletUtil.getResponse(), new FileInputStream(txtFileTemp), fileName);
+                //table3-课程课后作业考核/评价内容及目标分值
+                courseReportBean.setCourseTargetTable3(trBasicInfoService.buildWordTable3(courseTargetWordDtoList));
+
+                //table4-课程期末考试考核/评价内容及目标分值
+                courseReportBean.setCourseTargetTable4(trBasicInfoService.buildWordTable4(courseTargetWordDtoList));
+
+                //examstudent-课程目标达成评价依据-考生
+                courseReportBean.setExamStudentTable1(trBasicInfoService.buildWordTable5(trBasicInfo, courseReportBean));
+
+                InputStream inputStream = null;
+                txtFileTemp = SystemConstant.getFileTempVar(SystemConstant.WORD_PREFIX);
+                SysConfig sysConfig = commonCacheService.addSysConfigCache(schoolId, SystemConstant.SCHOOL_COURSE_DEGREE_TEMPLATE);
+                if (Objects.isNull(sysConfig)) {
+                    inputStream = FileUtil.getStream("static/" + ImportTemplateEnum.STATIC_COURSE_DEGREE_REPORT.getTemplateName());
+                } else {
+                    fileTemp = fileUploadService.downloadFile(Long.parseLong(sysConfig.getConfigValue()), fileTemp.getName());
+                    inputStream = FileUtil.getStream(fileTemp.getPath());
+                }
+                FileUtils.copyInputStreamToFile(inputStream, txtFileTemp);
+                XWPFTemplate template = XWPFTemplate.compile(txtFileTemp.getAbsolutePath()).render(courseReportBean);
+                template.writeToFile(txtFileTemp.getAbsolutePath());
+                // 导出
+                String fileName = Objects.nonNull(basicSchool) ? basicSchool.getName() + "_" + courseReportBean.getTitle1() + "_" + ImportTemplateEnum.STATIC_COURSE_DEGREE_REPORT.getFileName() + SystemConstant.WORD_PREFIX : courseReportBean.getTitle1() + "_" + ImportTemplateEnum.STATIC_COURSE_DEGREE_REPORT.getFileName() + SystemConstant.WORD_PREFIX;
+                FileUtil.outputFile(ServletUtil.getResponse(), new FileInputStream(txtFileTemp), fileName);
 
 //            XWPFTemplate template = XWPFTemplate.compile("/Users/king/git/teachcloud-server/distributed-print/src/main/resources/static/course_degree_report.docx").render(courseReportBean);
 //            template.writeToFile("/Users/king/Downloads/demo_course_degree_report.docx");
+            }
         } catch (Exception e) {
             if (e instanceof ApiException) {
                 ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());

binární
distributed-print/src/main/resources/static/course_degree_report.docx