wangliang 1 год назад
Родитель
Сommit
d783e02299

+ 18 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TCFinalScore.java

@@ -10,6 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
 
 import javax.validation.constraints.NotNull;
 import java.io.Serializable;
+import java.util.Objects;
 
 /**
  * <p>
@@ -241,4 +242,21 @@ public class TCFinalScore implements Serializable {
     public void setUpdateTime(Long updateTime) {
         this.updateTime = updateTime;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        TCFinalScore that = (TCFinalScore) o;
+        return examId.equals(that.examId) && courseCode.equals(that.courseCode) && courseName.equals(that.courseName) && paperNumber.equals(that.paperNumber) && name.equals(that.name) && studentCode.equals(that.studentCode) && score.equals(that.score) && scoreDetail.equals(that.scoreDetail);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(examId, courseCode, courseName, paperNumber, name, studentCode, score, scoreDetail);
+    }
 }

+ 18 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TCUsualScore.java

@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
 
 import javax.validation.constraints.NotNull;
 import java.io.Serializable;
+import java.util.Objects;
 
 /**
  * <p>
@@ -199,4 +200,21 @@ public class TCUsualScore implements Serializable {
     public void setUpdateTime(Long updateTime) {
         this.updateTime = updateTime;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        TCUsualScore that = (TCUsualScore) o;
+        return examId.equals(that.examId) && courseCode.equals(that.courseCode) && courseName.equals(that.courseName) && paperNumber.equals(that.paperNumber) && name.equals(that.name) && studentCode.equals(that.studentCode) && score.equals(that.score);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(examId, courseCode, courseName, paperNumber, name, studentCode, score);
+    }
 }

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

@@ -39,6 +39,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.util.*;
 
 /**
@@ -119,6 +120,7 @@ public class TCFinalScoreServiceImpl extends ServiceImpl<TCFinalScoreMapper, TCF
                         boolean error = false;
                         JSONArray jsonArray = new JSONArray();
                         TCFinalScore tcFinalScore = new TCFinalScore(examId, courseCode, markPaper.getCourseName(), paperNumber, SourceEnum.EXCEL_IMPORT, sysUser.getId());
+                        BigDecimal score = new BigDecimal(0);
                         for (int j = 0; j < strs.length; j++) {
                             JSONObject jsonObject = new JSONObject();
                             if (Objects.isNull(strs[j]) || Objects.equals(strs[j].trim(), "")) {
@@ -132,6 +134,7 @@ public class TCFinalScoreServiceImpl extends ServiceImpl<TCFinalScoreMapper, TCF
                                 } else if (Objects.equals(columnNames[j].trim(), "成绩")) {
                                     tcFinalScore.setScore(Double.valueOf(strs[j]));
                                 } else {
+                                    score = score.add(new BigDecimal(strs[j]));
                                     jsonObject.put("name", columnNames[j]);
                                     jsonObject.put("score", strs[j]);
                                     jsonArray.add(jsonObject);
@@ -139,6 +142,8 @@ public class TCFinalScoreServiceImpl extends ServiceImpl<TCFinalScoreMapper, TCF
                             }
                         }
                         if (jsonArray.size() > 0) {
+                            score = score.setScale(2, BigDecimal.ROUND_HALF_UP);
+                            tcFinalScore.setScore(score.doubleValue());
                             tcFinalScore.setScoreDetail(jsonArray.toJSONString());
                         }
                         if (!error) {

+ 22 - 23
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TRBasicInfoServiceImpl.java

@@ -81,9 +81,8 @@ public class TRBasicInfoServiceImpl extends ServiceImpl<TRBasicInfoMapper, TRBas
     @Resource
     ExamStudentService examStudentService;
 
-    protected final static DecimalFormat df = new DecimalFormat("0.##");
-    protected final static String tbBgColor = "F2F2F2";
-    protected final static String tbPercentWidth = "100%";
+    protected static final String tbBgColor = "F2F2F2";
+    protected static final String tbPercentWidth = "100%";
 
     /**
      * 获取课程目标考核分布-分数图
@@ -460,13 +459,13 @@ public class TRBasicInfoServiceImpl extends ServiceImpl<TRBasicInfoMapper, TRBas
                 }
                 if (reportEvaluationDtoMap.containsKey(key)) {
                     BigDecimal targetScore = reportEvaluationDtoMap.get(key).getTargetScore();
-                    rowData.add(df.format(targetScore));
+                    rowData.add(SystemConstant.df.format(targetScore));
                     sumScore = sumScore.add(targetScore);
                 } else {
                     rowData.add("0");
                 }
             }
-            rowData.add(df.format(sumScore));
+            rowData.add(SystemConstant.df.format(sumScore));
             targetSum = targetSum.add(sumScore);
             rowRenderData2SumMap.put("目标分值统计", targetSum);
             rowRenderData2[i + 2] = Rows.of(rowData.toArray(new String[header2_2List.size()])).rowStyle(this.getRowStyle()).create();
@@ -478,7 +477,7 @@ public class TRBasicInfoServiceImpl extends ServiceImpl<TRBasicInfoMapper, TRBas
         header2FootList.add("合计");
         header2FootList.add("");
         for (int y = 2; y < header2_2List.size(); y++) {
-            header2FootList.add(df.format(rowRenderData2SumMap.get(header2_2List.get(y))));
+            header2FootList.add(SystemConstant.df.format(rowRenderData2SumMap.get(header2_2List.get(y))));
         }
 
         RowRenderData header2_foot = Rows.of(header2FootList.toArray(new String[header2_2List.size()])).rowStyle(this.getRowStyle()).create();
@@ -524,13 +523,13 @@ public class TRBasicInfoServiceImpl extends ServiceImpl<TRBasicInfoMapper, TRBas
             usualScoreTargetSumWeight3 = usualScoreTargetSumWeight3.add(usualScoreWordDto.getUsualScoreTargetSumWeight());
         }
         usualScoreTargetSumWeight3 = usualScoreTargetSumWeight3.divide(new BigDecimal(courseTargetWordDtoList.size()), 2, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
-        tableFootTitle3 = tableFootTitle3.replace("${usualScoreSum}", df.format(usualScoreSum3));
-        tableFootTitle3 = tableFootTitle3.replace("${usualScoreSumWeight}", df.format(usualScoreTargetSumWeight3));
+        tableFootTitle3 = tableFootTitle3.replace("${usualScoreSum}", SystemConstant.df.format(usualScoreSum3));
+        tableFootTitle3 = tableFootTitle3.replace("${usualScoreSumWeight}", SystemConstant.df.format(usualScoreTargetSumWeight3));
 
         RowRenderData[] rowRenderData3 = new RowRenderData[courseTargetTableBean3List.size() + 2];
         for (int i = 0; i < courseTargetTableBean3List.size(); i++) {
             CourseTargetTableBean3 courseTargetTableBean3 = courseTargetTableBean3List.get(i);
-            rowRenderData3[i + 1] = Rows.of(courseTargetTableBean3.getNum().toString(), courseTargetTableBean3.getProject(), courseTargetTableBean3.getContent(), df.format(courseTargetTableBean3.getTarget()), courseTargetTableBean3.getCourseTarget()).rowStyle(this.getRowStyle()).create();
+            rowRenderData3[i + 1] = Rows.of(courseTargetTableBean3.getNum().toString(), courseTargetTableBean3.getProject(), courseTargetTableBean3.getContent(), SystemConstant.df.format(courseTargetTableBean3.getTarget()), courseTargetTableBean3.getCourseTarget()).rowStyle(this.getRowStyle()).create();
         }
         rowRenderData3[0] = header3_1;
         RowRenderData header3_foot = Rows.of(tableFootTitle3, "", "", "", "").center().create();
@@ -572,13 +571,13 @@ public class TRBasicInfoServiceImpl extends ServiceImpl<TRBasicInfoMapper, TRBas
         }
         finalScoreTargetSumWeight4 = finalScoreTargetSumWeight4.divide(new BigDecimal(courseTargetWordDtoList.size()), 2, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
         String tableFootTitle4 = "合计${dimensionScoreSum}分,占课程总评成绩的${dimensionSumWeight}%";
-        tableFootTitle4 = tableFootTitle4.replace("${dimensionScoreSum}", df.format(finalScoreSum4));
-        tableFootTitle4 = tableFootTitle4.replace("${dimensionSumWeight}", df.format(finalScoreTargetSumWeight4));
+        tableFootTitle4 = tableFootTitle4.replace("${dimensionScoreSum}", SystemConstant.df.format(finalScoreSum4));
+        tableFootTitle4 = tableFootTitle4.replace("${dimensionSumWeight}", SystemConstant.df.format(finalScoreTargetSumWeight4));
 
         RowRenderData[] rowRenderData4 = new RowRenderData[courseTargetTableBean4List.size() + 2];
         for (int i = 0; i < courseTargetTableBean4List.size(); i++) {
             CourseTargetTableBean4 courseTargetTableBean4 = courseTargetTableBean4List.get(i);
-            rowRenderData4[i + 1] = Rows.of(courseTargetTableBean4.getNum().toString(), courseTargetTableBean4.getProject(), courseTargetTableBean4.getContent(), df.format(courseTargetTableBean4.getTargetScore()), courseTargetTableBean4.getCourseTarget()).rowStyle(this.getRowStyle()).create();
+            rowRenderData4[i + 1] = Rows.of(courseTargetTableBean4.getNum().toString(), courseTargetTableBean4.getProject(), courseTargetTableBean4.getContent(), SystemConstant.df.format(courseTargetTableBean4.getTargetScore()), courseTargetTableBean4.getCourseTarget()).rowStyle(this.getRowStyle()).create();
         }
         rowRenderData4[0] = header4_1;
         RowRenderData header4_foot = Rows.of(tableFootTitle4, "", "", "", "").center().create();
@@ -695,18 +694,18 @@ public class TRBasicInfoServiceImpl extends ServiceImpl<TRBasicInfoMapper, TRBas
                                 for (ReportExamStudentUsualScoreObjDto reportExamStudentUsualScoreObjDto : reportExamStudentUsualScoreObjDtoList) {
                                     switch (trExamStudent.getName()) {
                                         case "目标分":
-                                            examStudent_cells.add(Cells.of(df.format(reportExamStudentUsualScoreObjDto.getTargetScore())).create());
+                                            examStudent_cells.add(Cells.of(SystemConstant.df.format(reportExamStudentUsualScoreObjDto.getTargetScore())).create());
                                             targetSumScore = targetSumScore.add(reportExamStudentUsualScoreObjDto.getTargetScore());
                                             break;
                                         case "平均分":
-                                            examStudent_cells.add(Cells.of(df.format(reportExamStudentUsualScoreObjDto.getMatrixAvgScore())).create());
+                                            examStudent_cells.add(Cells.of(SystemConstant.df.format(reportExamStudentUsualScoreObjDto.getMatrixAvgScore())).create());
                                             targetAvgScore = targetAvgScore.add(new BigDecimal(reportExamStudentUsualScoreObjDto.getMatrixAvgScore()));
                                             break;
                                         case "各课程目标平均分":
-                                            examStudent_cells.add(Cells.of(df.format(reportExamStudentTargetDto.getTargetMatrixAvgScore())).create());
+                                            examStudent_cells.add(Cells.of(SystemConstant.df.format(reportExamStudentTargetDto.getTargetMatrixAvgScore())).create());
                                             break;
                                         default:
-                                            examStudent_cells.add(Cells.of(df.format(reportExamStudentUsualScoreObjDto.getScore())).create());
+                                            examStudent_cells.add(Cells.of(SystemConstant.df.format(reportExamStudentUsualScoreObjDto.getScore())).create());
                                             break;
                                     }
                                 }
@@ -717,18 +716,18 @@ public class TRBasicInfoServiceImpl extends ServiceImpl<TRBasicInfoMapper, TRBas
                                 courseReportBean.getCourseBasicBean().setFinalScoreWeight(reportExamStudentFinalScoreDto.getTargetWeight());
                                 switch (trExamStudent.getName()) {
                                     case "目标分":
-                                        examStudent_cells.add(Cells.of(df.format(reportExamStudentFinalScoreDto.getTargetScore())).create());
+                                        examStudent_cells.add(Cells.of(SystemConstant.df.format(reportExamStudentFinalScoreDto.getTargetScore())).create());
                                         targetSumScore = targetSumScore.add(reportExamStudentFinalScoreDto.getTargetScore());
                                         break;
                                     case "平均分":
-                                        examStudent_cells.add(Cells.of(df.format(reportExamStudentFinalScoreDto.getMatrixAvgScore())).create());
+                                        examStudent_cells.add(Cells.of(SystemConstant.df.format(reportExamStudentFinalScoreDto.getMatrixAvgScore())).create());
                                         targetAvgScore = targetAvgScore.add(new BigDecimal(reportExamStudentFinalScoreDto.getMatrixAvgScore()));
                                         break;
                                     case "各课程目标平均分":
-                                        examStudent_cells.add(Cells.of(df.format(reportExamStudentTargetDto.getTargetMatrixAvgScore())).create());
+                                        examStudent_cells.add(Cells.of(SystemConstant.df.format(reportExamStudentTargetDto.getTargetMatrixAvgScore())).create());
                                         break;
                                     default:
-                                        examStudent_cells.add(Cells.of(df.format(reportExamStudentFinalScoreDto.getTargetMatrixSumScore())).create());
+                                        examStudent_cells.add(Cells.of(SystemConstant.df.format(reportExamStudentFinalScoreDto.getTargetMatrixSumScore())).create());
                                         break;
                                 }
                             }
@@ -737,16 +736,16 @@ public class TRBasicInfoServiceImpl extends ServiceImpl<TRBasicInfoMapper, TRBas
                 }
                 switch (trExamStudent.getName()) {
                     case "目标分":
-                        examStudent_cells.add(Cells.of(df.format(targetSumScore.setScale(2, BigDecimal.ROUND_HALF_UP))).create());
+                        examStudent_cells.add(Cells.of(SystemConstant.df.format(targetSumScore.setScale(2, BigDecimal.ROUND_HALF_UP))).create());
                         break;
                     case "平均分":
-                        examStudent_cells.add(Cells.of(df.format(targetAvgScore.setScale(2, BigDecimal.ROUND_HALF_UP))).create());
+                        examStudent_cells.add(Cells.of(SystemConstant.df.format(targetAvgScore.setScale(2, BigDecimal.ROUND_HALF_UP))).create());
                         break;
                     case "各课程目标平均分":
                         examStudent_cells.add(Cells.of("").create());
                         break;
                     default:
-                        examStudent_cells.add(Cells.of(df.format(trExamStudent.getScore())).create());
+                        examStudent_cells.add(Cells.of(SystemConstant.df.format(trExamStudent.getScore())).create());
                         break;
                 }
                 examStudent_row.setCells(examStudent_cells);

+ 3 - 0
distributed-print-business/src/main/resources/mapper/TCFinalScoreMapper.xml

@@ -34,6 +34,7 @@
             <if test="paperNumber != null and paperNumber != ''">
                 and tcfs.paper_number = #{paperNumber}
             </if>
+                and tcfs.enable = true and tcus.enable = true
         </where>
     </select>
 
@@ -50,6 +51,7 @@
                 and tcfs.paper_number = #{paperNumber}
             </if>
                 and tcfs.score &gt;= #{start} and tcfs.score &lt;= #{end}
+                and tcfs.enable = true
         </where>
     </select>
 
@@ -74,6 +76,7 @@
             <if test="paperNumber != null and paperNumber != ''">
                 and tcfs.paper_number = #{paperNumber}
             </if>
+                and tcfs.enable = true and tcus.enable = true
         </where>
     </select>
 </mapper>

+ 11 - 3
distributed-print/src/main/java/com/qmth/distributed/print/api/TCFinalScoreController.java

@@ -25,6 +25,7 @@ import com.qmth.teachcloud.mark.service.MarkQuestionService;
 import io.swagger.annotations.*;
 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;
@@ -192,11 +193,17 @@ public class TCFinalScoreController {
         TCFinalScore tcFinalScoreDb = tcFinalScoreService.getById(tcFinalScore.getId());
         Objects.requireNonNull(tcFinalScoreDb, "未找到期末成绩信息");
 
+        TCFinalScore tcFinalScoreSource = new TCFinalScore();
+        BeanUtils.copyProperties(tcFinalScoreDb, tcFinalScoreSource);
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         tcFinalScoreDb.updateInfo(tcFinalScore, sysUser.getId());
-        trExamStudentService.remove(tcFinalScoreDb.getExamId(), tcFinalScoreDb.getCourseCode(), tcFinalScoreDb.getPaperNumber());
-        trBasicInfoService.remove(tcFinalScoreDb.getExamId(), tcFinalScoreDb.getCourseCode(), tcFinalScoreDb.getPaperNumber());
-        return ResultUtil.ok(tcFinalScoreService.updateById(tcFinalScoreDb));
+
+        if (!tcFinalScoreSource.equals(tcFinalScoreDb)) {
+            trExamStudentService.remove(tcFinalScoreDb.getExamId(), tcFinalScoreDb.getCourseCode(), tcFinalScoreDb.getPaperNumber());
+            trBasicInfoService.remove(tcFinalScoreDb.getExamId(), tcFinalScoreDb.getCourseCode(), tcFinalScoreDb.getPaperNumber());
+            tcFinalScoreService.updateById(tcFinalScoreDb);
+        }
+        return ResultUtil.ok(true);
     }
 
     @ApiOperation(value = "期末成绩启用/禁用")
@@ -257,6 +264,7 @@ public class TCFinalScoreController {
                                              @ApiParam(value = "科目编码", required = true) @RequestParam String courseCode,
                                              @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber) throws IOException {
         List<PaperStructResult> paperStructResultList = null;
+//        org.apache.commons.collections4.CollectionUtils.isEqualCollection()
         TCPaperStruct tcPaperStruct = tcPaperStructService.getOne(new QueryWrapper<TCPaperStruct>().lambda().eq(TCPaperStruct::getExamId, examId).eq(TCPaperStruct::getCourseCode, courseCode).eq(TCPaperStruct::getPaperNumber, paperNumber));
         if (Objects.isNull(tcPaperStruct)) {
             List<MarkQuestion> markQuestionList = markQuestionService.listQuestionByExamIdAndPaperNumberAndPaperType(examId, paperNumber, null);

+ 10 - 3
distributed-print/src/main/java/com/qmth/distributed/print/api/TCUsualScoreController.java

@@ -19,6 +19,7 @@ import com.qmth.teachcloud.common.util.ServletUtil;
 import io.swagger.annotations.*;
 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;
@@ -149,11 +150,17 @@ public class TCUsualScoreController {
         TCUsualScore tcUsualScoreDb = tcUsualScoreService.getById(tcUsualScore.getId());
         Objects.requireNonNull(tcUsualScoreDb, "未找到平时成绩信息");
 
+        TCUsualScore tcUsualScoreSource = new TCUsualScore();
+        BeanUtils.copyProperties(tcUsualScoreDb, tcUsualScoreSource);
+
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         tcUsualScoreDb.updateInfo(tcUsualScore, sysUser.getId());
-        trExamStudentService.remove(tcUsualScoreDb.getExamId(), tcUsualScoreDb.getCourseCode(), tcUsualScoreDb.getPaperNumber());
-        trBasicInfoService.remove(tcUsualScoreDb.getExamId(), tcUsualScoreDb.getCourseCode(), tcUsualScoreDb.getPaperNumber());
-        return ResultUtil.ok(tcUsualScoreService.updateById(tcUsualScoreDb));
+        if (!tcUsualScoreSource.equals(tcUsualScoreDb)) {
+            trExamStudentService.remove(tcUsualScoreDb.getExamId(), tcUsualScoreDb.getCourseCode(), tcUsualScoreDb.getPaperNumber());
+            trBasicInfoService.remove(tcUsualScoreDb.getExamId(), tcUsualScoreDb.getCourseCode(), tcUsualScoreDb.getPaperNumber());
+            tcUsualScoreService.updateById(tcUsualScoreDb);
+        }
+        return ResultUtil.ok(true);
     }
 
     @ApiOperation(value = "平时成绩启用/禁用")

+ 2 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/contant/SystemConstant.java

@@ -28,6 +28,7 @@ import java.math.RoundingMode;
 import java.net.URLEncoder;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
+import java.text.DecimalFormat;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -268,6 +269,7 @@ public class SystemConstant {
     public static final String ZIP_PREFIX = ".zip";
     public static final String TXT_PREFIX = ".txt";
     public static final String WINDOWS = "Windows";
+    public static final DecimalFormat df = new DecimalFormat("0.##");
 
     public static final String EXCEL_PREFIX = ".xlsx";
     public static final String WORD_PREFIX = ".docx";