소스 검색

成绩管理1对多

wangliang 8 달 전
부모
커밋
53a182266f

+ 18 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/excel/ExcelField.java

@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
+import java.util.Objects;
 
 /**
  * @Description: excel 动态字段
@@ -103,4 +104,21 @@ public class ExcelField implements Serializable {
     public void setComment(Boolean comment) {
         this.comment = comment;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        ExcelField that = (ExcelField) o;
+        return Objects.equals(code, that.code) && Objects.equals(name, that.name) && Objects.equals(value, that.value) && Objects.equals(comment, that.comment);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(code, name, value, comment);
+    }
 }

+ 3 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/PrintCommonService.java

@@ -21,6 +21,7 @@ import java.io.File;
 import java.io.IOException;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * @Description: 公共服务service
@@ -188,8 +189,8 @@ public interface PrintCommonService {
      * @param describe
      * @param sheetName
      * @param fileName
-     * @param excelFieldRowList
+     * @param excelFieldRowSet
      * @throws IOException
      */
-    public void scoreDownLoadExaminationTemplate(String describe, String sheetName, String fileName, List<List<ExcelField>> excelFieldRowList) throws IOException;
+    public void scoreDownLoadExaminationTemplate(String describe, String sheetName, String fileName, List<Set<ExcelField>> excelFieldRowList) throws IOException;
 }

+ 9 - 7
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/PrintCommonServiceImpl.java

@@ -248,11 +248,11 @@ public class PrintCommonServiceImpl implements PrintCommonService {
      * @param describe
      * @param sheetName
      * @param fileName
-     * @param excelFieldRowList
+     * @param excelFieldRowSet
      * @throws IOException
      */
     @Override
-    public void scoreDownLoadExaminationTemplate(String describe, String sheetName, String fileName, List<List<ExcelField>> excelFieldRowList) throws IOException {
+    public void scoreDownLoadExaminationTemplate(String describe, String sheetName, String fileName, List<Set<ExcelField>> excelFieldRowSet) throws IOException {
         HttpServletResponse response = ServletUtil.getResponse();
         log.debug("导出Excel开始...");
         XSSFWorkbook wb = new XSSFWorkbook();
@@ -274,8 +274,8 @@ public class PrintCommonServiceImpl implements PrintCommonService {
         describeFont.setFontName("宋体");
         describeFont.setColor(IndexedColors.RED.getIndex());
 
-        List<ExcelField> excelFieldFirstList = excelFieldRowList.get(0);
-        int cellCount = excelFieldFirstList.size();
+        Set<ExcelField> excelFieldFirstSet = excelFieldRowSet.get(0);
+        int cellCount = excelFieldFirstSet.size();
         // 说明
         XSSFCellStyle describeStyle = wb.createCellStyle();
         describeStyle.setAlignment(HorizontalAlignment.LEFT);
@@ -300,6 +300,7 @@ public class PrintCommonServiceImpl implements PrintCommonService {
         headerStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
         headerStyle.setFont(headFont);
         XSSFRow rowHead = sheet.createRow(1);
+        List<ExcelField> excelFieldFirstList = new ArrayList<>(excelFieldFirstSet);
         for (int i = 0; i < excelFieldFirstList.size(); i++) {
             XSSFCell cell = rowHead.createCell(i);
             cell.setCellValue(excelFieldFirstList.get(i).getName());
@@ -318,10 +319,11 @@ public class PrintCommonServiceImpl implements PrintCommonService {
         XSSFCellStyle exampleStyle = wb.createCellStyle();
         exampleStyle.setAlignment(HorizontalAlignment.LEFT);
         exampleStyle.setFont(defaultFont);
-        for (int y = 0; y < excelFieldRowList.size(); y++) {
+        for (int y = 0; y < excelFieldRowSet.size(); y++) {
             XSSFRow rowExample = sheet.createRow(2 + y);
-            List<ExcelField> excelFieldList = excelFieldRowList.get(y);
-            for (int i = 0; i < excelFieldList.size(); i++) {
+            Set<ExcelField> excelFieldSet = excelFieldRowSet.get(y);
+            List<ExcelField> excelFieldList = new ArrayList<>(excelFieldSet);
+            for (int i = 0; i < excelFieldSet.size(); i++) {
                 XSSFCell cell = rowExample.createCell(i);
                 if (excelFieldList.get(i).getCode().startsWith("score")) {
                 } else if (excelFieldList.get(i).getCode().startsWith("key")) {

+ 12 - 12
distributed-print/src/main/java/com/qmth/distributed/print/api/obe/TCFinalScoreController.java

@@ -98,20 +98,20 @@ public class TCFinalScoreController {
                                            @ApiParam(value = "培养方案id", required = true) @RequestParam Long cultureProgramId) throws IOException {
         tcFinalScoreService.getLock(cultureProgramId, courseId, paperNumber, examId);
         TCPaperStruct tcPaperStruct = tcPaperStructService.queryPaperStruct(cultureProgramId, courseId, paperNumber, examId);
-        List<List<ExcelField>> excelFieldRowList = new ArrayList<>();
+        List<Set<ExcelField>> excelFieldRowSet = new ArrayList<>();
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         List<TCFinalScore> finalScoreList = tcFinalScoreService.queryFinalScore(cultureProgramId, courseId, paperNumber, examId, sysUser.getId());
         if (CollectionUtils.isNotEmpty(finalScoreList)) {
             finalScoreList.stream().peek(s -> {
-                        List<ExcelField> excelFieldList = new ArrayList<>();
+                        Set<ExcelField> excelFieldList = new LinkedHashSet<>();
                         excelFieldList.addAll(new ArrayList<>(Arrays.asList(new ExcelField("studentCode", "学号", s.getStudentCode(), true), new ExcelField("name", "姓名", s.getName(), true), new ExcelField("score", "成绩", Objects.nonNull(s.getScore()) ? s.getScore().toString() : null, true))));
-                        excelFieldRowList.add(excelFieldList);
+                        excelFieldRowSet.add(excelFieldList);
                     }
             ).collect(Collectors.toList());
         } else {
-            List<ExcelField> excelFieldList = new ArrayList<>();
+            Set<ExcelField> excelFieldList = new LinkedHashSet<>();
             excelFieldList.addAll(new ArrayList<>(Arrays.asList(new ExcelField("studentCode", "学号", true), new ExcelField("name", "姓名", true), new ExcelField("score", "成绩", true))));
-            excelFieldRowList.add(excelFieldList);
+            excelFieldRowSet.add(excelFieldList);
         }
         if (Objects.isNull(tcPaperStruct) || Objects.isNull(tcPaperStruct.getPaperStruct())) {
             List<MarkQuestion> markQuestionList = markQuestionService.listQuestionByExamIdAndPaperNumber(examId, paperNumber);
@@ -120,9 +120,9 @@ public class TCFinalScoreController {
             }
             for (int i = 0; i < markQuestionList.size(); i++) {
                 MarkQuestion markQuestion = markQuestionList.get(i);
-                for (int y = 0; y < excelFieldRowList.size(); y++) {
-                    List<ExcelField> excelFieldList = excelFieldRowList.get(y);
-                    excelFieldList.add(new ExcelField("key" + (i + 1), markQuestion.getMainNumber() + "-" + markQuestion.getSubNumber(), true));
+                for (int y = 0; y < excelFieldRowSet.size(); y++) {
+                    Set<ExcelField> excelFieldSet = excelFieldRowSet.get(y);
+                    excelFieldSet.add(new ExcelField("key" + (i + 1), markQuestion.getMainNumber() + "-" + markQuestion.getSubNumber(), true));
                 }
             }
         } else {
@@ -130,16 +130,16 @@ public class TCFinalScoreController {
             }.getType());
             for (int i = 0; i < paperStructDtoList.size(); i++) {
                 PaperStructDto paperStructDto = paperStructDtoList.get(i);
-                for (int y = 0; y < excelFieldRowList.size(); y++) {
-                    List<ExcelField> excelFieldList = excelFieldRowList.get(y);
-                    excelFieldList.add(new ExcelField("key" + (i + 1), paperStructDto.getMainNumber() + "-" + paperStructDto.getSubNumber(), true));
+                for (int y = 0; y < excelFieldRowSet.size(); y++) {
+                    Set<ExcelField> excelFieldSet = excelFieldRowSet.get(y);
+                    excelFieldSet.add(new ExcelField("key" + (i + 1), paperStructDto.getMainNumber() + "-" + paperStructDto.getSubNumber(), true));
                 }
             }
         }
         printCommonService.scoreDownLoadExaminationTemplate("1、所有字段均为必填字段;\n" +
                 "2、期末成绩按总分,和小题分录入,题号按大题号-小题号方式录入,如下,1-1表示第一大题第一小题,2-1表示第二大题第一小题;\n" +
                 "3、请不要删除此行,也不要删除模板中的任何列;\n" +
-                "4、使用前请先删除样例数据。", "sheet1", "期末成绩导入模版", excelFieldRowList);
+                "4、使用前请先删除样例数据。", "sheet1", "期末成绩导入模版", excelFieldRowSet);
     }
 
     @ApiOperation(value = "导入期末成绩")

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

@@ -40,10 +40,7 @@ import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
 import java.io.IOException;
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -96,19 +93,19 @@ public class TCUsualScoreController {
                                            @ApiParam(value = "试卷编号") @RequestParam(required = false) String paperNumber
     ) throws IOException {
         tcUsualScoreService.getUsualScoreImportLock(cultureProgramId, courseId, paperNumber, examId);
-        List<List<ExcelField>> excelFieldRowList = new ArrayList<>();
+        List<Set<ExcelField>> excelFieldRowList = new ArrayList<>();
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         List<TCUsualScore> tcUsualScoreList = tcUsualScoreService.queryUsualScore(cultureProgramId, courseId, paperNumber, examId, sysUser.getId());
         if (CollectionUtils.isNotEmpty(tcUsualScoreList)) {
             tcUsualScoreList.stream().peek(s -> {
-                        List<ExcelField> excelFieldList = new ArrayList<>();
-                        excelFieldList.addAll(new ArrayList<>(Arrays.asList(new ExcelField("studentCode", "学号", s.getStudentCode(), true), new ExcelField("name", "姓名", s.getName(), true))));
+                        Set<ExcelField> excelFieldList = new LinkedHashSet<>();
+                        excelFieldList.addAll(new LinkedHashSet<>(Arrays.asList(new ExcelField("studentCode", "学号", s.getStudentCode(), true), new ExcelField("name", "姓名", s.getName(), true))));
                         excelFieldRowList.add(excelFieldList);
                     }
             ).collect(Collectors.toList());
         } else {
-            List<ExcelField> excelFieldList = new ArrayList<>();
-            excelFieldList.addAll(new ArrayList<>(Arrays.asList(new ExcelField("studentCode", "学号", true), new ExcelField("name", "姓名", true))));
+            Set<ExcelField> excelFieldList = new LinkedHashSet<>();
+            excelFieldList.addAll(new LinkedHashSet<>(Arrays.asList(new ExcelField("studentCode", "学号", true), new ExcelField("name", "姓名", true))));
             excelFieldRowList.add(excelFieldList);
         }
 
@@ -124,7 +121,7 @@ public class TCUsualScoreController {
                 if (Objects.nonNull(s.getEnable()) && s.getEnable() && !Objects.equals(s.getEvaluationName(),
                         SystemConstant.FINAL_SCORE_STR)) {
                     for (int y = 0; y < excelFieldRowList.size(); y++) {
-                        List<ExcelField> excelFieldList = excelFieldRowList.get(y);
+                        Set<ExcelField> excelFieldList = excelFieldRowList.get(y);
                         excelFieldList.add(new ExcelField(s.getEvaluationName(), true));
                     }
                 }
@@ -144,8 +141,7 @@ public class TCUsualScoreController {
     @ApiResponses({@ApiResponse(code = 200, message = "作业集合信息", response = Object.class)})
     public Result usualScoreTemplateDownloadList(@ApiParam(value = "培养方案id", required = true) @RequestParam Long cultureProgramId,
                                                  @ApiParam(value = "课程id", required = true) @RequestParam Long courseId) {
-        List<ExcelField> excelFieldList = new ArrayList<>();
-        excelFieldList = this.getUsualScoreList(cultureProgramId, courseId, excelFieldList);
+        Set<ExcelField> excelFieldList = this.getUsualScoreList(cultureProgramId, courseId);
         excelFieldList.stream().peek(s -> s.setNull()).collect(Collectors.toList());
         return ResultUtil.ok(excelFieldList);
     }
@@ -249,15 +245,15 @@ public class TCUsualScoreController {
      *
      * @param cultureProgramId
      * @param courseId
-     * @param excelFieldList
      * @return
      */
-    protected List<ExcelField> getUsualScoreList(Long cultureProgramId, Long courseId, List<ExcelField> excelFieldList) {
+    protected Set<ExcelField> getUsualScoreList(Long cultureProgramId, Long courseId) {
         ObeCourseOutline obeCourseOutline = obeCourseOutlineService.findByCultureProgramIdAndCourseId(
                 cultureProgramId, courseId);
         ObeCourseWeightResult obeCourseWeightResult = trBasicInfoService.findCourseWeightResultRmi(obeCourseOutline.getId(), true);
         List<CourseWeightDto> courseWeightDtoList = obeCourseWeightResult.getSubmitForm();
 
+        Set<ExcelField> excelFieldList = new LinkedHashSet<>();
         courseWeightDtoList.stream().peek(e -> {
             List<CourseWeightDetailDto> courseWeightDetailDtoList = e.getEvaluationList();
             courseWeightDetailDtoList.stream().peek(s -> {