Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/dev_v3.3.1' into dev_v3.3.1

wangliang 1 anno fa
parent
commit
db4bb7e1b6
26 ha cambiato i file con 484 aggiunte e 310 eliminazioni
  1. 2 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/BasicExamStudentDto.java
  2. 9 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamStudentPdfInfoDto.java
  3. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamStudent.java
  4. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/enums/RequiredFieldsEnum.java
  5. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/BasicExamStudentMapper.java
  6. 4 6
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/BasicExamStudentService.java
  7. 20 29
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicExamStudentServiceImpl.java
  8. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicTeachClazzServiceImpl.java
  9. 2 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java
  10. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TeachStudentServiceImpl.java
  11. 3 4
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/SyncBasicExamStudentImportService.java
  12. 2 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/TaskLogicService.java
  13. 86 138
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java
  14. 51 5
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/pdf/CreatePdfNewUtil.java
  15. 9 2
      distributed-print-business/src/main/resources/mapper/ExamStudentMapper.xml
  16. 1 3
      distributed-print/src/main/java/com/qmth/distributed/print/api/BasicExamStudentController.java
  17. 1 1
      distributed-print/src/main/java/com/qmth/distributed/print/api/SysController.java
  18. 13 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/annotation/ExcelError.java
  19. 35 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/result/ExcelResult.java
  20. 1 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/entity/BasicExamStudent.java
  21. 2 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/BasicCourseService.java
  22. 20 9
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/BasicCourseServiceImpl.java
  23. 100 40
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/util/ConvertUtil.java
  24. 7 0
      teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/MarkStudentService.java
  25. 110 63
      teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkStudentServiceImpl.java
  26. 1 1
      teachcloud-task/src/main/java/com/qmth/teachcloud/task/service/impl/PrintFinishServiceImpl.java

+ 2 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/BasicExamStudentDto.java

@@ -1,6 +1,7 @@
 package com.qmth.distributed.print.business.bean.dto;
 
 import com.qmth.boot.tools.excel.annotation.ExcelColumn;
+import com.qmth.teachcloud.common.annotation.ExcelError;
 import com.qmth.teachcloud.common.annotation.ExcelNote;
 import com.qmth.teachcloud.common.annotation.ExcelProperty;
 import io.swagger.annotations.ApiModelProperty;
@@ -103,6 +104,7 @@ public class BasicExamStudentDto {
     private String examRoom;
 
     @ApiModelProperty("异常信息")
+    @ExcelError
     private String errorMsg;
 
     public String getCourseName() {

+ 9 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamStudentPdfInfoDto.java

@@ -13,6 +13,7 @@ public class ExamStudentPdfInfoDto extends ExamStudent {
     private String paperNumber;
     private String examPlace;
     private String examRoom;
+    private String teacherName;
 
     public String getCourseCode() {
         return courseCode;
@@ -55,4 +56,12 @@ public class ExamStudentPdfInfoDto extends ExamStudent {
     public void setExamRoom(String examRoom) {
         this.examRoom = examRoom;
     }
+
+    public String getTeacherName() {
+        return teacherName;
+    }
+
+    public void setTeacherName(String teacherName) {
+        this.teacherName = teacherName;
+    }
 }

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamStudent.java

@@ -85,7 +85,7 @@ public class ExamStudent extends BaseEntity implements Serializable {
     private String clazzName;
 
     @ApiModelProperty(value = "教学班id")
-    @TableField("clazz_id")
+    @TableField("teach_clazz_id")
     @JsonSerialize(using = ToStringSerializer.class)
     private Long teachClazzId;
 

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/enums/RequiredFieldsEnum.java

@@ -26,7 +26,7 @@ public enum RequiredFieldsEnum {
     MAJOR_NAME("majorName","专业", false, false),
     TEACH_CLAZZ_NAME("teachClazzName","教学班", true, true),
     CLAZZ_NAME("clazzName","行政班", false, false),
-    TEACHER_NAME("teachName","任课老师", true, true);
+    TEACHER_NAME("teacherName","任课老师", true, true);
 
     private final String code;
     private final String name;

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

@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.distributed.print.business.bean.result.BasicExamStudentResult;
-import com.qmth.distributed.print.business.entity.BasicExamStudent;
+import com.qmth.teachcloud.common.entity.BasicExamStudent;
 import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
 import org.apache.ibatis.annotations.Param;
 

+ 4 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/BasicExamStudentService.java

@@ -4,9 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.distributed.print.business.bean.params.BasicExamStudentParam;
 import com.qmth.distributed.print.business.bean.result.BasicExamStudentResult;
-import com.qmth.distributed.print.business.entity.BasicExamStudent;
+import com.qmth.teachcloud.common.entity.BasicExamStudent;
 import com.qmth.teachcloud.common.entity.SysUser;
-import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
@@ -40,7 +39,7 @@ public interface BasicExamStudentService extends IService<BasicExamStudent> {
      * @return 查询结果
      */
     IPage<BasicExamStudentResult> page(SysUser requestUser, Long semesterId, Long examId, String courseCode, String teacher,
-            String college, String major, String teachClazz, String examStudentInfo, int pageNumber, int pageSize);
+                                       String college, String major, String teachClazz, String examStudentInfo, int pageNumber, int pageSize);
 
     /**
      * 列表查询
@@ -57,7 +56,7 @@ public interface BasicExamStudentService extends IService<BasicExamStudent> {
      * @return 查询结果
      */
     List<BasicExamStudentResult> list(SysUser requestUser, Long semesterId, Long examId, String courseCode, String teacher,
-            String college, String major, String teachClazz, String examStudentInfo);
+                                      String college, String major, String teachClazz, String examStudentInfo);
 
     /**
      * 新增编辑
@@ -89,7 +88,7 @@ public interface BasicExamStudentService extends IService<BasicExamStudent> {
      * @param examStudentInfo 考生信息(姓名/学号)
      */
     void exportLogic(HttpServletResponse response, Long semesterId, Long examId, String courseCode, String teacher,
-            String college, String major, String teachClazz, String examStudentInfo) throws Exception;
+                     String college, String major, String teachClazz, String examStudentInfo) throws Exception;
 
     /**
      * 批量删除
@@ -107,5 +106,4 @@ public interface BasicExamStudentService extends IService<BasicExamStudent> {
      */
     BasicExamStudent editEntityHelp(BasicExamStudentParam basicExamStudentParam, SysUser requestUser);
 
-    void testImport(MultipartFile file) throws Exception;
 }

+ 20 - 29
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicExamStudentServiceImpl.java

@@ -1,16 +1,12 @@
 package com.qmth.distributed.print.business.service.impl;
 
-import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.qmth.boot.tools.excel.ExcelReader;
-import com.qmth.boot.tools.excel.enums.ExcelType;
 import com.qmth.distributed.print.business.bean.dto.BasicExamStudentDto;
 import com.qmth.distributed.print.business.bean.params.BasicExamStudentParam;
 import com.qmth.distributed.print.business.bean.result.BasicExamStudentResult;
-import com.qmth.distributed.print.business.entity.BasicExamStudent;
 import com.qmth.distributed.print.business.entity.BasicTeachClazz;
 import com.qmth.distributed.print.business.mapper.BasicExamStudentMapper;
 import com.qmth.distributed.print.business.service.BasicExamStudentService;
@@ -18,6 +14,7 @@ import com.qmth.distributed.print.business.service.BasicTeachClazzService;
 import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicCourse;
+import com.qmth.teachcloud.common.entity.BasicExamStudent;
 import com.qmth.teachcloud.common.entity.BasicSchool;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
@@ -28,18 +25,17 @@ import com.qmth.teachcloud.common.service.SysUserService;
 import com.qmth.teachcloud.common.util.ConvertUtil;
 import com.qmth.teachcloud.common.util.ExcelUtil;
 import com.qmth.teachcloud.common.util.ServletUtil;
+import com.qmth.teachcloud.mark.entity.MarkStudent;
+import com.qmth.teachcloud.mark.service.MarkStudentService;
 import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -56,23 +52,21 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
 
     @Resource
     private BasicRoleDataPermissionService basicRoleDataPermissionService;
-
     @Resource
     private BasicCourseService basicCourseService;
-
     @Resource
     private BasicTeachClazzService basicTeachClazzService;
-
     @Resource
     private SysUserService sysUserService;
-
     @Resource
     private CommonCacheService commonCacheService;
+    @Resource
+    private MarkStudentService markStudentService;
 
     @Override
     public IPage<BasicExamStudentResult> page(SysUser requestUser, Long semesterId, Long examId, String courseCode,
-            String teacher, String college, String major, String teachClazz, String examStudentInfo, int pageNumber,
-            int pageSize) {
+                                              String teacher, String college, String major, String teachClazz, String examStudentInfo, int pageNumber,
+                                              int pageSize) {
         Long schoolId = requestUser.getSchoolId();
 
         courseCode = SystemConstant.translateSpecificSign(courseCode);
@@ -102,7 +96,7 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
 
     @Override
     public List<BasicExamStudentResult> list(SysUser requestUser, Long semesterId, Long examId, String courseCode,
-            String teacher, String college, String major, String teachClazz, String examStudentInfo) {
+                                             String teacher, String college, String major, String teachClazz, String examStudentInfo) {
         Long schoolId = requestUser.getSchoolId();
 
         courseCode = SystemConstant.translateSpecificSign(courseCode);
@@ -135,6 +129,10 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
     public Long save(BasicExamStudentParam basicExamStudentParam, SysUser requestUser) {
         BasicExamStudent basicExamStudent = this.editEntityHelp(basicExamStudentParam, requestUser);
         this.saveOrUpdate(basicExamStudent);
+        if (StringUtils.isNotBlank(basicExamStudent.getPaperNumber())) {
+            // 同步更新扫描阅卷考生表
+            markStudentService.updateByBasicExamStudent(basicExamStudent, new HashSet<>());
+        }
         return basicExamStudent.getId();
     }
 
@@ -165,14 +163,14 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
     public void deleteBatch(List<Long> idList) {
         if (CollectionUtils.isNotEmpty(idList)) {
             List<BasicExamStudent> basicExamStudentList = this.listByIds(idList);
-
-            List<String> boundStudentNameList = this.baseMapper.findBoundBasicExamStudentNames(idList);
-            if (CollectionUtils.isNotEmpty(boundStudentNameList)) {
-                throw ExceptionResultEnum.ERROR.exception(
-                        String.format("学生[%s]已经被绑定", String.join(",", boundStudentNameList)));
+            for (BasicExamStudent basicExamStudent : basicExamStudentList) {
+                MarkStudent markStudent = markStudentService.findByExamIdAndPaperNumberAndStudentCode(basicExamStudent.getExamId(), basicExamStudent.getPaperNumber(), basicExamStudent.getStudentCode());
+                if(markStudent!= null && !markStudent.getUpload()){
+                    markStudentService.deleteByExamIdAndPaperNumberAndStudentCode(basicExamStudent.getExamId(), basicExamStudent.getPaperNumber(), basicExamStudent.getStudentCode());
+                }
             }
+
             this.removeByIds(idList);
-            basicExamStudentList.stream().map(BasicExamStudent::getClazzId).distinct().forEach(e -> basicTeachClazzService.deleteFreeClazz(e));
         }
     }
 
@@ -321,11 +319,4 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
         return basicExamStudent;
     }
 
-    @Override
-    public void testImport(MultipartFile file) throws Exception {
-        ExcelReader excelReader = ExcelReader.create(ExcelType.XLSX, file.getInputStream(), 1);
-        List<String[]> list = excelReader.getDataArrayList();
-
-        System.out.println(JSON.toJSONString(list));
-    }
 }

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

@@ -3,7 +3,7 @@ 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.bean.result.BasicTeachClazzResult;
-import com.qmth.distributed.print.business.entity.BasicExamStudent;
+import com.qmth.teachcloud.common.entity.BasicExamStudent;
 import com.qmth.distributed.print.business.entity.BasicTeachClazz;
 import com.qmth.distributed.print.business.mapper.BasicTeachClazzMapper;
 import com.qmth.distributed.print.business.service.BasicExamStudentService;

+ 2 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java

@@ -1406,7 +1406,8 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                         examDetailCourseService.save(examDetailCourse);
 
                         if (!CollectionUtils.isEmpty(examStudents)) {
-                            examStudentService.insertBatch(examStudents);
+//                            examStudentService.insertBatch(examStudents);
+                            examStudentService.saveBatch(examStudents);
                         }
                         int studentCount = examStudents.size();
 

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

@@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.distributed.print.business.bean.params.TeachStudentBatchParam;
 import com.qmth.distributed.print.business.bean.result.TeachStudentResult;
-import com.qmth.distributed.print.business.entity.BasicExamStudent;
+import com.qmth.teachcloud.common.entity.BasicExamStudent;
 import com.qmth.distributed.print.business.entity.TeachClazz;
 import com.qmth.distributed.print.business.entity.TeachStudent;
 import com.qmth.distributed.print.business.mapper.TeachStudentMapper;

+ 3 - 4
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/SyncBasicExamStudentImportService.java

@@ -4,7 +4,7 @@ import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSON;
 import com.qmth.distributed.print.business.bean.dto.BasicExamStudentDto;
 import com.qmth.distributed.print.business.bean.dto.MarkStudentImportDto;
-import com.qmth.distributed.print.business.entity.BasicExamStudent;
+import com.qmth.teachcloud.common.entity.BasicExamStudent;
 import com.qmth.distributed.print.business.service.BasicExamService;
 import com.qmth.distributed.print.business.service.BasicExamStudentService;
 import com.qmth.distributed.print.business.templete.importData.SyncImportTaskTemplate;
@@ -95,8 +95,7 @@ public class SyncBasicExamStudentImportService extends SyncImportTaskTemplate {
                 // 模式4,直接进扫描阅卷库
                 BasicExam basicExam = basicExamService.getById(tbTask.getExamId());
                 if (ExamModelEnum.MODEL4.equals(basicExam.getExamModel())) {
-                    List<MarkStudentImportDto> markStudentImportDtoList = JSON.parseArray(JSON.toJSONString(result.get(SystemConstant.DATASOURCE)), MarkStudentImportDto.class);
-                    taskLogicService.saveMarkStudent(tbTask.getExamId(), markStudentImportDtoList);
+                    taskLogicService.saveMarkStudent(tbTask.getExamId(), basicExamStudentList);
                 }
             } else if (result.containsKey(SystemConstant.ERROR_DATA_LIST)) {
                 // 有异常数据
@@ -159,7 +158,7 @@ public class SyncBasicExamStudentImportService extends SyncImportTaskTemplate {
         String describe = SystemConstant.BASIC_EXAM_STUDENT_DESCRIBE;
         describe = describe.trim();
         XSSFRow rowDescribe = sheet.createRow(0);
-        rowDescribe.setHeightInPoints(195); //行高设置成195px
+        rowDescribe.setHeightInPoints(100); //行高设置成100px
         for (int i = 0; i < cellCount; i++) {
             XSSFCell cell = rowDescribe.createCell(i);
             if (i == 0) {

+ 2 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/TaskLogicService.java

@@ -1,6 +1,7 @@
 package com.qmth.distributed.print.business.templete.service;
 
 import com.qmth.distributed.print.business.bean.dto.MarkStudentImportDto;
+import com.qmth.teachcloud.common.entity.BasicExamStudent;
 
 import java.io.IOException;
 import java.util.List;
@@ -142,7 +143,6 @@ public interface TaskLogicService {
      * 保存阅卷数据
      *
      * @param examId                   考试id
-     * @param markStudentImportDtoList 阅卷数据
      */
-    void saveMarkStudent(Long examId, List<MarkStudentImportDto> markStudentImportDtoList);
+    void saveMarkStudent(Long examId, List<BasicExamStudent> basicExamStudentList );
 }

+ 86 - 138
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java

@@ -10,6 +10,7 @@ import com.google.common.reflect.TypeToken;
 import com.google.gson.Gson;
 import com.itextpdf.text.DocumentException;
 import com.qmth.boot.api.exception.ApiException;
+import com.qmth.teachcloud.common.bean.result.ExcelResult;
 import com.qmth.teachcloud.common.bean.vo.PrintPathVo;
 import com.qmth.distributed.print.business.bean.dto.*;
 import com.qmth.distributed.print.business.bean.examRule.CodeNameEnableValue;
@@ -2062,7 +2063,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
     @Transactional
     @Override
     public Map<String, Object> executeImportBasicExamStudentLogic(Map<String, Object> map) throws Exception {
-
         SysUser requestUser = (SysUser) map.get(SystemConstant.USER);
         InputStream inputStream = (InputStream) map.get("inputStream");
         Long examId = SystemConstant.convertIdToLong(String.valueOf(map.get("examId")));
@@ -2084,110 +2084,92 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 BaseEntity::getId));
         // excel中学生学号和学生字典对象关系
         Map<String, BasicExamStudent> studentCodeObjMap = new HashMap<>();
-        List<BasicExamStudentDto> errorDataList = new ArrayList<>();
         AtomicInteger successInteger = new AtomicInteger(0);
         AtomicInteger exceptionInteger = new AtomicInteger(0);
 
-        ExcelUtil.excelReader(inputStream, Lists.newArrayList(BasicExamStudentDto.class),
-                (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
+        ExcelResult<BasicExamStudentDto> excelResult = ConvertUtil.analyzeExcel(inputStream, BasicExamStudentDto.class,
+                true, 1);
+        List<BasicExamStudentDto> basicExamStudentDtoList = excelResult.getDatasource();
+        boolean success = excelResult.isSuccess();
+        for (BasicExamStudentDto basicExamStudentDto : basicExamStudentDtoList) {
+            List<String> errorMsgList = new ArrayList<>();
+            // 行索引
+            String courseName = basicExamStudentDto.getCourseName();
+            String courseCode = basicExamStudentDto.getCourseCode();
+            String studentName = basicExamStudentDto.getStudentName();
+            String studentCode = basicExamStudentDto.getStudentCode();
+            String college = basicExamStudentDto.getCollege();
+            String major = basicExamStudentDto.getMajor();
+            String teachClazz = basicExamStudentDto.getTeachClazz();
+            String paperNumber = basicExamStudentDto.getPaperNumber();
+            String teacherName = basicExamStudentDto.getTeacherName();
+            String teacherCode = basicExamStudentDto.getTeacherCode();
+            String examDate = basicExamStudentDto.getExamDate();
+            String examTime = basicExamStudentDto.getExamTime();
+            String examPlace = basicExamStudentDto.getExamPlace();
+            String examRoom = basicExamStudentDto.getExamRoom();
 
-                    for (int i = 0; i < finalExcelList.size(); i++) {
-                        LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
-                        List<Object> basicExamStudentDtoList = excelMap.get(i);
-                        // 无数据,跳过
-                        if (CollectionUtils.isEmpty(basicExamStudentDtoList)) {
-                            continue;
-                        }
-                        for (int y = 0; y < Objects.requireNonNull(basicExamStudentDtoList).size(); y++) {
-                            List<String> errorMsgList = new ArrayList<>();
-                            // 行索引
-                            BasicExamStudentDto basicExamStudentDto = (BasicExamStudentDto) basicExamStudentDtoList.get(
-                                    y);
-                            String courseName = StringUtils.trimToNull(basicExamStudentDto.getCourseName());
-                            String courseCode = StringUtils.trimToNull(basicExamStudentDto.getCourseCode());
-                            String studentName = StringUtils.trimToNull(basicExamStudentDto.getStudentName());
-                            String studentCode = StringUtils.trimToNull(basicExamStudentDto.getStudentCode());
-                            String college = StringUtils.trimToNull(basicExamStudentDto.getCollege());
-                            String major = StringUtils.trimToNull(basicExamStudentDto.getMajor());
-                            String teachClazz = StringUtils.trimToNull(basicExamStudentDto.getTeachClazz());
-                            String paperNumber = StringUtils.trimToNull(basicExamStudentDto.getPaperNumber());
-                            String teacherName = StringUtils.trimToNull(basicExamStudentDto.getTeacherName());
-                            String teacherCode = StringUtils.trimToNull(basicExamStudentDto.getTeacherCode());
-                            String examDate = StringUtils.trimToNull(basicExamStudentDto.getExamDate());
-                            String examTime = StringUtils.trimToNull(basicExamStudentDto.getExamTime());
-                            String examPlace = StringUtils.trimToNull(basicExamStudentDto.getExamPlace());
-                            String examRoom = StringUtils.trimToNull(basicExamStudentDto.getExamRoom());
-
-                            // 本行全部列为空,跳过
-                            if (StringUtils.isAllBlank(courseName, courseCode, studentName, studentCode, college, major,
-                                    teachClazz, paperNumber, teacherName, teacherCode, examDate, examTime, examPlace,
-                                    examRoom)) {
-                                continue;
-                            }
-                            Long examStartTime = null;
-                            Long examEndTime = null;
-                            try {
-                                if (SystemConstant.strNotNull(examDate) && SystemConstant.strNotNull(examTime)) {
-                                    Map<String, Object> timeMap = ConvertUtil.analyzeStartAndEndTime(examDate, examTime);
-                                    examStartTime = SystemConstant.convertIdToLong(String.valueOf(timeMap.get("startTime")));
-                                    examEndTime = SystemConstant.convertIdToLong(String.valueOf(timeMap.get("endTime")));
-                                }
-                            } catch (Exception e) {
-                                errorMsgList.add(e.getMessage());
-                            }
+            Long examStartTime = null;
+            Long examEndTime = null;
+            try {
+                if (SystemConstant.strNotNull(examDate) && SystemConstant.strNotNull(examTime)) {
+                    Map<String, Object> timeMap = ConvertUtil.analyzeStartAndEndTime(examDate, examTime);
+                    examStartTime = SystemConstant.convertIdToLong(String.valueOf(timeMap.get("startTime")));
+                    examEndTime = SystemConstant.convertIdToLong(String.valueOf(timeMap.get("endTime")));
+                }
+            } catch (Exception e) {
+                errorMsgList.add(e.getMessage());
+            }
+
+            String key = examId + SystemConstant.HYPHEN + courseCode + SystemConstant.HYPHEN + studentCode;
+            Long id = null;
+            if (studentCodeIdMap.containsKey(key)) {
+                id = studentCodeIdMap.get(key);
+            }
+            BasicExamStudentParam basicExamStudentParam = new BasicExamStudentParam();
+            basicExamStudentParam.setId(id);
+            basicExamStudentParam.setSemesterId(semesterId);
+            basicExamStudentParam.setExamId(examId);
+            basicExamStudentParam.setCourseCode(courseCode);
+            basicExamStudentParam.setStudentName(studentName);
+            basicExamStudentParam.setStudentCode(studentCode);
+            basicExamStudentParam.setCollege(college);
+            basicExamStudentParam.setMajor(major);
+            basicExamStudentParam.setTeachClazz(teachClazz);
+            basicExamStudentParam.setPaperNumber(paperNumber);
+            basicExamStudentParam.setTeacherName(teacherName);
+            basicExamStudentParam.setTeacherCode(teacherCode);
+            basicExamStudentParam.setExamStartTime(examStartTime);
+            basicExamStudentParam.setExamEndTime(examEndTime);
+            basicExamStudentParam.setExamPlace(examPlace);
+            basicExamStudentParam.setExamRoom(examRoom);
+            try {
+                BasicExamStudent basicExamStudent = basicExamStudentService.editEntityHelp(basicExamStudentParam,
+                        requestUser);
+                // 考试课程下学号重复 后面的替换前面的
+                studentCodeObjMap.put(key, basicExamStudent);
+            } catch (Exception e) {
+                errorMsgList.add(e.getMessage());
+            }
 
-                            String key = examId + SystemConstant.HYPHEN + courseCode + SystemConstant.HYPHEN + studentCode;
-                            Long id = null;
-                            if (studentCodeIdMap.containsKey(key)) {
-                                id = studentCodeIdMap.get(key);
-                            }
-                            BasicExamStudentParam basicExamStudentParam = new BasicExamStudentParam();
-                            basicExamStudentParam.setId(id);
-                            basicExamStudentParam.setSemesterId(semesterId);
-                            basicExamStudentParam.setExamId(examId);
-                            basicExamStudentParam.setCourseCode(courseCode);
-                            basicExamStudentParam.setStudentName(studentName);
-                            basicExamStudentParam.setStudentCode(studentCode);
-                            basicExamStudentParam.setCollege(college);
-                            basicExamStudentParam.setMajor(major);
-                            basicExamStudentParam.setTeachClazz(teachClazz);
-                            basicExamStudentParam.setPaperNumber(paperNumber);
-                            basicExamStudentParam.setTeacherName(teacherName);
-                            basicExamStudentParam.setTeacherCode(teacherCode);
-                            basicExamStudentParam.setExamStartTime(examStartTime);
-                            basicExamStudentParam.setExamEndTime(examEndTime);
-                            basicExamStudentParam.setExamPlace(examPlace);
-                            basicExamStudentParam.setExamRoom(examRoom);
-                            try {
-                                BasicExamStudent basicExamStudent = basicExamStudentService.editEntityHelp(
-                                        basicExamStudentParam, requestUser);
-                                // 考试课程下学号重复 后面的替换前面的
-                                studentCodeObjMap.put(key, basicExamStudent);
-                            } catch (Exception e) {
-                                errorMsgList.add(e.getMessage());
-                            }
+            if (CollectionUtils.isNotEmpty(errorMsgList)) {
+                basicExamStudentDto.setErrorMsg(basicExamStudentDto.getErrorMsg() + ";" + String.join(";", errorMsgList));
+                exceptionInteger.getAndIncrement();
+            } else {
+                successInteger.getAndIncrement();
+            }
 
-                            if (CollectionUtils.isNotEmpty(errorMsgList)) {
-                                basicExamStudentDto.setErrorMsg(String.join(";", errorMsgList));
-                                exceptionInteger.getAndIncrement();
-                            } else {
-                                successInteger.getAndIncrement();
-                            }
-                            errorDataList.add(basicExamStudentDto);
-                        }
-                    }
+        }
 
-                    if (errorDataList.stream().anyMatch(e -> SystemConstant.strNotNull(e.getErrorMsg()))) {
-                        map.put(SystemConstant.ERROR_DATA_LIST, errorDataList);
-                    } else {
-                        List<BasicExamStudent> basicExamStudentList = new ArrayList<>(studentCodeObjMap.values());
-                        map.put(SystemConstant.DATASOURCE, basicExamStudentList);
-                    }
-                    map.put(SystemConstant.DATA_COUNT, errorDataList.size());
-                    map.put(SystemConstant.SUCCESS_DATA_COUNT, successInteger.get());
-                    map.put(SystemConstant.ERROR_DATA_COUNT, exceptionInteger.get());
-                    return finalExcelList;
-                }, 2);
+        if (basicExamStudentDtoList.stream().anyMatch(e -> SystemConstant.strNotNull(e.getErrorMsg()))) {
+            map.put(SystemConstant.ERROR_DATA_LIST, basicExamStudentDtoList);
+        } else {
+            List<BasicExamStudent> basicExamStudentList = new ArrayList<>(studentCodeObjMap.values());
+            map.put(SystemConstant.DATASOURCE, basicExamStudentList);
+        }
+        map.put(SystemConstant.DATA_COUNT, basicExamStudentDtoList.size());
+        map.put(SystemConstant.SUCCESS_DATA_COUNT, successInteger.get());
+        map.put(SystemConstant.ERROR_DATA_COUNT, exceptionInteger.get());
         return map;
     }
 
@@ -2308,7 +2290,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
 
     @Transactional
     @Override
-    public void saveMarkStudent(Long examId, List<MarkStudentImportDto> markStudentImportDtoList) {
+    public void saveMarkStudent(Long examId, List<BasicExamStudent> basicExamStudentList) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         Long requestUserId = requestUser.getId();
         final String paperType = "A";
@@ -2316,10 +2298,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         markPaperService.remove(new QueryWrapper<MarkPaper>().lambda().eq(MarkPaper::getExamId, examId));
         markStudentService.remove(new QueryWrapper<MarkStudent>().lambda().eq(MarkStudent::getExamId, examId));
 
-        List<Map<String, String>> paperInfo = markStudentImportDtoList.stream().flatMap(e -> {
+        List<Map<String, String>> paperInfo = basicExamStudentList.stream().flatMap(e -> {
             Map<String, String> map = new HashMap<>();
             map.put("courseCode", e.getCourseCode());
-            map.put("courseName", e.getCourseName());
             map.put("paperNumber", e.getPaperNumber());
             return Stream.of(map);
         }).distinct().collect(Collectors.toList());
@@ -2330,48 +2311,15 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             String courseName = paperMap.get("courseName");
             String paperNumber = paperMap.get("paperNumber");
 
-            MarkPaper markPaper = new MarkPaper(examId, courseCode, courseName, paperNumber, null, requestUserId,
-                    paperType);
+            MarkPaper markPaper = new MarkPaper(examId, courseCode, courseName, paperNumber, null, requestUserId, paperType);
             markPaperService.save(markPaper);
         }
         // 新增mark_student信息
-        Map<String, Map<String, Object>> examTimeMap = new HashMap<>();
         Set<String> secretNumberSet = new HashSet<>();
-        List<MarkStudent> markStudentList = markStudentImportDtoList.stream().flatMap(e -> {
-            String examDate = e.getExamDate();
-            String examTime = e.getExamTime();
-            Long examStartTime = null;
-            Long examEndTime = null;
-            if (SystemConstant.strNotNull(examDate) && SystemConstant.strNotNull(examTime)) {
-                String key = examDate + SystemConstant.HYPHEN + examTime;
-                Map<String, Object> timeMap = new HashMap<>();
-                if (examTimeMap.containsKey(key)) {
-                    timeMap = examTimeMap.get(key);
-                } else {
-                    timeMap = ConvertUtil.analyzeStartAndEndTime(examDate, examTime);
-                    examTimeMap.put(key, timeMap);
-                }
-                examStartTime = SystemConstant.convertIdToLong(String.valueOf(timeMap.get("startTime")));
-                examEndTime = SystemConstant.convertIdToLong(String.valueOf(timeMap.get("endTime")));
-            }
-            MarkStudent markStudent = new MarkStudent(null, examId, e.getCourseCode(), e.getCourseName(), e.getPaperNumber(),
-                    null, paperType, e.getStudentCode(), e.getStudentName(), null, e.getExamPlace(), e.getExamRoom(), e.getCollege(),
-                    e.getMajor(), e.getClazz(), examStartTime, examEndTime, requestUserId);
-            if (markStudent.getSecretNumber() == null) {
-                markStudent.randomSecretNumber();
-                while (secretNumberSet.contains(markStudent.getSecretNumber())
-                        || markStudentService.countByExamIdAndSecretNumber(markStudent.getExamId(), markStudent.getSecretNumber()) > 0) {
-                    markStudent.randomSecretNumber();
-                }
-            }
-            return Stream.of(markStudent);
-        }).collect(Collectors.toList());
+        basicExamStudentList.stream().forEach(m -> markStudentService.updateByBasicExamStudent(m, secretNumberSet));
 
-        if (CollectionUtils.isNotEmpty(markStudentList)) {
-            markStudentService.saveBatch(markStudentList);
-            // 更新mark_paper表student_count字段
-            paperInfo.stream().map(e -> e.get("paperNumber")).forEach(e -> markPaperService.updateStudentCountByExamIdAndPaperNumberAndPaperType(examId, e, paperType));
-        }
+        // 更新mark_paper表student_count字段
+        paperInfo.stream().map(e -> e.get("paperNumber")).forEach(e -> markPaperService.updateStudentCountByExamIdAndPaperNumberAndPaperType(examId, e, paperType));
     }
 
     /**

+ 51 - 5
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/pdf/CreatePdfNewUtil.java

@@ -280,9 +280,9 @@ public class CreatePdfNewUtil {
                 basicMap.put("name", name);
                 basicMap.put("value", CollectionUtils.isEmpty(stringSet) ? "" : String.join(SystemConstant.COMMA_OF_CHINESE, stringSet));
                 basicPlate.add(basicMap);
-            } else if ("clazzName".equals(code)) {
+            } else if ("teachClazzName".equals(code)) {
                 Set<String> stringSet = new HashSet<>();
-                Set<String> teachClazzNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getTeachClazzName())).map(ExamStudent::getTeachClazzName).collect(Collectors.toSet());
+                Set<String> teachClazzNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getTeachClazzName())).map(ExamStudentCourseDto::getTeachClazzName).collect(Collectors.toSet());
                 if (!teachClazzNames.isEmpty()) {
                     stringSet.addAll(teachClazzNames);
                 }
@@ -291,6 +291,28 @@ public class CreatePdfNewUtil {
                 basicMap.put("name", name);
                 basicMap.put("value", CollectionUtils.isEmpty(stringSet) ? "" : String.join(SystemConstant.COMMA_OF_CHINESE, stringSet));
                 basicPlate.add(basicMap);
+            } else if ("clazzName".equals(code)) {
+                Set<String> stringSet = new HashSet<>();
+                Set<String> clazzNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getClazzName())).map(ExamStudentCourseDto::getClazzName).collect(Collectors.toSet());
+                if (!clazzNames.isEmpty()) {
+                    stringSet.addAll(clazzNames);
+                }
+                Map<String, String> basicMap = new HashMap<>();
+                basicMap.put("code", code);
+                basicMap.put("name", name);
+                basicMap.put("value", CollectionUtils.isEmpty(stringSet) ? "" : String.join(SystemConstant.COMMA_OF_CHINESE, stringSet));
+                basicPlate.add(basicMap);
+            } else if ("teacherName".equals(code)) {
+                Set<String> stringSet = new HashSet<>();
+                Set<String> teachNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getTeacherName())).map(ExamStudentCourseDto::getTeacherName).collect(Collectors.toSet());
+                if (!teachNames.isEmpty()) {
+                    stringSet.addAll(teachNames);
+                }
+                Map<String, String> basicMap = new HashMap<>();
+                basicMap.put("code", code);
+                basicMap.put("name", name);
+                basicMap.put("value", CollectionUtils.isEmpty(stringSet) ? "" : String.join(SystemConstant.COMMA_OF_CHINESE, stringSet));
+                basicPlate.add(basicMap);
             } else if ("paperCount".equals(code)) {
                 Map<String, String> basicMap = new HashMap<>();
                 basicMap.put("code", "paperCount");
@@ -488,19 +510,40 @@ public class CreatePdfNewUtil {
                 }
                 basicPlate.add(basicMap);
             } else if ("collegeName".equals(code)) {
-                Set<String> collegeNames = examStudentList.stream().map(ExamStudentCourseDto::getCollegeName).collect(Collectors.toSet());
+                Set<String> collegeNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getCollegeName())).map(ExamStudentCourseDto::getCollegeName).collect(Collectors.toSet());
                 Map<String, String> basicMap = new HashMap<>();
                 basicMap.put("code", code);
                 basicMap.put("name", name);
                 basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, collegeNames));
                 basicPlate.add(basicMap);
             } else if ("majorName".equals(code)) {
-                Set<String> majorNames = examStudentList.stream().map(ExamStudentCourseDto::getMajorName).collect(Collectors.toSet());
+                Set<String> majorNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getMajorName())).map(ExamStudentCourseDto::getMajorName).collect(Collectors.toSet());
                 Map<String, String> basicMap = new HashMap<>();
                 basicMap.put("code", code);
                 basicMap.put("name", name);
                 basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, majorNames));
                 basicPlate.add(basicMap);
+            } else if ("teachClazzName".equals(code)) {
+                Set<String> teachClazzNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getTeachClazzName())).map(ExamStudentCourseDto::getTeachClazzName).collect(Collectors.toSet());
+                Map<String, String> basicMap = new HashMap<>();
+                basicMap.put("code", code);
+                basicMap.put("name", name);
+                basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, teachClazzNames));
+                basicPlate.add(basicMap);
+            } else if ("clazzName".equals(code)) {
+                Set<String> clazzNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getClazzName())).map(ExamStudentCourseDto::getClazzName).collect(Collectors.toSet());
+                Map<String, String> basicMap = new HashMap<>();
+                basicMap.put("code", code);
+                basicMap.put("name", name);
+                basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, clazzNames));
+                basicPlate.add(basicMap);
+            } else if ("teacherName".equals(code)) {
+                Set<String> teacherNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getTeacherName())).map(ExamStudentCourseDto::getTeacherName).collect(Collectors.toSet());
+                Map<String, String> basicMap = new HashMap<>();
+                basicMap.put("code", code);
+                basicMap.put("name", name);
+                basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, teacherNames));
+                basicPlate.add(basicMap);
             } else if ("examCount".equals(code)) {
                 Map<String, String> basicMap = new HashMap<>();
                 basicMap.put("code", code);
@@ -556,8 +599,11 @@ public class CreatePdfNewUtil {
             if (studentHeadPlateMap.containsKey("courseName")) {
                 studentMap.put("courseName", examStudentCourseDto.getCourseName());
             }
+            if (studentHeadPlateMap.containsKey("teachClazzName")) {
+                studentMap.put("teachClazzName", examStudentCourseDto.getTeachClazzName());
+            }
             if (studentHeadPlateMap.containsKey("clazzName")) {
-                studentMap.put("clazzName", StringUtils.isBlank(examStudentCourseDto.getTeachClazzName()) ? examStudentCourseDto.getClazzName() : examStudentCourseDto.getTeachClazzName());
+                studentMap.put("clazzName", examStudentCourseDto.getClazzName());
             }
             if (studentHeadPlateMap.containsKey("ticketNumber")) {
                 studentMap.put("ticketNumber", examStudentCourseDto.getTicketNumber());

+ 9 - 2
distributed-print-business/src/main/resources/mapper/ExamStudentMapper.xml

@@ -89,11 +89,14 @@
         es.clazz_name clazzName,
         es.teach_clazz_name teachClazzName,
         es.college_name collegeName,
-        es.major_name majorName
+        es.major_name majorName,
+        es.teacher_id teacherId,
+        su.real_name teacherName
         from
         exam_student es
         left join exam_detail_course edc on
         edc.id = es.exam_detail_course_id
+            left join sys_user su on es.teacher_id = su.id
         <where>
             <if test="schoolId != null and schoolId != ''">
                 and es.school_id = #{schoolId}
@@ -163,18 +166,22 @@
                a.major_name    majorName,
                a.clazz_id      clazzId,
                a.clazz_name    clazzName,
+               a.teach_clazz_name teachClazzName,
                a.campus_name   campusName,
                a.attachment_id attachmentId,
                b.course_code   courseCode,
                b.course_name   courseName,
                b.paper_number  paperNumber,
                c.exam_place    examPlace,
-               c.exam_room     examRoom
+               c.exam_room     examRoom,
+               su.real_name teacherName
         FROM exam_student a
                  JOIN
              exam_detail_course b ON a.exam_detail_course_id = b.id
                  JOIN
              exam_detail c ON b.exam_detail_id = c.id
+                left join
+             sys_user su on a.teacher_id = su.id
         WHERE a.id = #{id}
     </select>
     <select id="listExamStudentByPaperNumberAndPaperType"

+ 1 - 3
distributed-print/src/main/java/com/qmth/distributed/print/api/BasicExamStudentController.java

@@ -1,6 +1,7 @@
 package com.qmth.distributed.print.api;
 
 import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.distributed.print.business.bean.dto.BasicExamStudentDto;
 import com.qmth.distributed.print.business.bean.params.BasicExamStudentParam;
 import com.qmth.distributed.print.business.bean.result.BasicExamStudentResult;
 import com.qmth.distributed.print.business.service.BasicExamStudentService;
@@ -90,9 +91,6 @@ public class BasicExamStudentController {
         Map<String, Object> map = printCommonService.saveTask(file, SystemConstant.convertIdToLong(examId), TaskTypeEnum.BASIC_EXAM_STUDENT_IMPORT);
         map.put("examId", SystemConstant.convertIdToLong(examId));
         return syncBasicExamStudentImportService.importTask(map);
-
-//        basicExamStudentService.testImport(file);
-//        return ResultUtil.ok();
     }
 
     @ApiOperation(value = "导出")

+ 1 - 1
distributed-print/src/main/java/com/qmth/distributed/print/api/SysController.java

@@ -7,7 +7,7 @@ import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.bean.params.LoginParam;
 import com.qmth.distributed.print.business.bean.result.DictionaryResult;
 import com.qmth.distributed.print.business.bean.result.EditResult;
-import com.qmth.distributed.print.business.entity.BasicExamStudent;
+import com.qmth.teachcloud.common.entity.BasicExamStudent;
 import com.qmth.distributed.print.business.entity.BasicTeachClazz;
 import com.qmth.distributed.print.business.entity.TBSyncTask;
 import com.qmth.distributed.print.business.enums.DictionaryEnum;

+ 13 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/annotation/ExcelError.java

@@ -0,0 +1,13 @@
+package com.qmth.teachcloud.common.annotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @Description: excel映射类记录错误信息的属性
+ * @Author: CaoZixuan
+ * @Date: 2024-03-25
+ */
+@Retention(RetentionPolicy.RUNTIME) //定义注解运行策略
+public @interface ExcelError {
+}

+ 35 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/result/ExcelResult.java

@@ -0,0 +1,35 @@
+package com.qmth.teachcloud.common.bean.result;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+/**
+ * @Description: excel结果
+ * @Author: CaoZixuan
+ * @Date: 2024-03-26
+ */
+public class ExcelResult<T> {
+
+    @ApiModelProperty("数据")
+    private List<T> datasource;
+
+    @ApiModelProperty("是否成功")
+    private boolean success;
+
+    public List<T> getDatasource() {
+        return datasource;
+    }
+
+    public void setDatasource(List<T> datasource) {
+        this.datasource = datasource;
+    }
+
+    public boolean isSuccess() {
+        return success;
+    }
+
+    public void setSuccess(boolean success) {
+        this.success = success;
+    }
+}

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/BasicExamStudent.java → teachcloud-common/src/main/java/com/qmth/teachcloud/common/entity/BasicExamStudent.java

@@ -1,4 +1,4 @@
-package com.qmth.distributed.print.business.entity;
+package com.qmth.teachcloud.common.entity;
 
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;

+ 2 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/BasicCourseService.java

@@ -112,4 +112,6 @@ public interface BasicCourseService extends IService<BasicCourse> {
      * @return 可选基础课程结果
      */
     List<TeachCourseSelectResult> listByOrgId(Long orgId, Long examId, SysUser requestUser);
+
+    BasicCourse getByCode(String courseCode);
 }

+ 20 - 9
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/BasicCourseServiceImpl.java

@@ -26,6 +26,7 @@ import com.qmth.teachcloud.common.util.ExcelUtil;
 import com.qmth.teachcloud.common.util.JdbcErrorUtil;
 import com.qmth.teachcloud.common.util.ResultUtil;
 import com.qmth.teachcloud.common.util.ServletUtil;
+import io.netty.util.collection.ShortObjectHashMap;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.dao.DataIntegrityViolationException;
 import org.springframework.jdbc.BadSqlGrammarException;
@@ -37,6 +38,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
+import javax.websocket.RemoteEndpoint;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.*;
@@ -349,7 +351,7 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
     @Transactional(rollbackFor = Exception.class)
     @Override
     public List<BasicCourseParams> executeBasicCourseImportLogic(List<LinkedMultiValueMap<Integer, Object>> finalList,
-            Map<Integer, List<String>> errorMap) {
+                                                                 Map<Integer, List<String>> errorMap) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         Long schoolId = sysUser.getSchoolId();
         List<BasicCourseParams> addBasicCourseParamsList = new ArrayList<>();
@@ -464,18 +466,27 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
             List<String> occupiedCourseCodeList = this.baseMapper.findOccupiedCourseCode(examId, requestUser.getId());
 
             result = this.list(new QueryWrapper<BasicCourse>().lambda().in(BasicCourse::getTeachingRoomId, orgIdSet)
-                            .orderByAsc(BasicCourse::getOrgId)).stream().filter(e -> !occupiedCourseCodeList.contains(e.getCode())).flatMap(e -> {
-                        TeachCourseSelectResult teachCourseSelectResult = new TeachCourseSelectResult();
-                        teachCourseSelectResult.setBasicCourseId(e.getId());
-                        teachCourseSelectResult.setCourseName(e.getName());
-                        teachCourseSelectResult.setCourseCode(e.getCode());
-                        teachCourseSelectResult.setTeachCollegeName(collegeMap.get(e.getTeachingRoomId()));
-                        return Stream.of(teachCourseSelectResult);
-                    }).collect(Collectors.toList());
+                    .orderByAsc(BasicCourse::getOrgId)).stream().filter(e -> !occupiedCourseCodeList.contains(e.getCode())).flatMap(e -> {
+                TeachCourseSelectResult teachCourseSelectResult = new TeachCourseSelectResult();
+                teachCourseSelectResult.setBasicCourseId(e.getId());
+                teachCourseSelectResult.setCourseName(e.getName());
+                teachCourseSelectResult.setCourseCode(e.getCode());
+                teachCourseSelectResult.setTeachCollegeName(collegeMap.get(e.getTeachingRoomId()));
+                return Stream.of(teachCourseSelectResult);
+            }).collect(Collectors.toList());
         }
         return result;
     }
 
+    @Override
+    public BasicCourse getByCode(String courseCode) {
+        Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
+        QueryWrapper<BasicCourse> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(BasicCourse::getSchoolId, schoolId)
+                .eq(BasicCourse::getCode, courseCode);
+        return this.getOne(queryWrapper);
+    }
+
     private List<BasicCourse> editEntityHelp(List<BasicCourseParams> basicCourseParamsList, SysUser sysUser) {
         Long schoolId = sysUser.getSchoolId();
         List<BasicCourse> basicCourseList = new ArrayList<>();

+ 100 - 40
teachcloud-common/src/main/java/com/qmth/teachcloud/common/util/ConvertUtil.java

@@ -1,24 +1,31 @@
 package com.qmth.teachcloud.common.util;
 
+import com.qmth.boot.tools.excel.ExcelReader;
+import com.qmth.boot.tools.excel.annotation.ExcelColumn;
+import com.qmth.boot.tools.excel.enums.ExcelType;
+import com.qmth.teachcloud.common.annotation.ExcelError;
+import com.qmth.teachcloud.common.bean.result.ExcelResult;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPageTree;
 import org.apache.pdfbox.rendering.PDFRenderer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
 
-import javax.annotation.Resource;
 import javax.imageio.ImageIO;
 import javax.servlet.http.HttpServletResponse;
 import java.awt.image.BufferedImage;
 import java.io.*;
+import java.lang.reflect.Field;
 import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @Description: 转换工具类
@@ -28,28 +35,8 @@ import java.util.*;
 
 @Component
 public class ConvertUtil {
-    private final static Logger log = LoggerFactory.getLogger(ConvertUtil.class);
-
-    @Resource
-    RedisTemplate<String, Object> redisTemplate;
-
-    // inputStream转outputStream
-    public static ByteArrayOutputStream parse(final InputStream in) throws Exception {
-        final ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
-//        int ch;
-//        while ((ch = in.read()) != -1) {
-//            swapStream.write(ch);
-//        }
-        IOUtils.copy(in, swapStream);
-        return swapStream;
-    }
 
-    // outputStream转inputStream
-    public static ByteArrayInputStream parse(final OutputStream out) {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        baos = (ByteArrayOutputStream) out;
-        return new ByteArrayInputStream(baos.toByteArray());
-    }
+    private final static Logger log = LoggerFactory.getLogger(ConvertUtil.class);
 
     /**
      * 转换,解析时间
@@ -68,7 +55,8 @@ public class ConvertUtil {
         String startTimeStr = date + " " + arr[0];
         String endTimeStr = date + " " + arr[1];
         if (Objects.isNull(DateDisposeUtils.parseDate(startTimeStr)) || Objects.isNull(DateDisposeUtils.parseDate(endTimeStr))) {
-            throw ExceptionResultEnum.ERROR.exception("提供的日期时间格式异常 \n考试日期[" + date + "]应该使用如下的格式(考试日期:2021-09-01 或 2021/09/01 或 2021.09.01)" + "\n考试时间[" + time + "]应该使用如下的格式(考试时间:18:00-20:00)");
+            throw ExceptionResultEnum.ERROR.exception(
+                    "提供的日期时间格式异常 \n考试日期[" + date + "]应该使用如下的格式(考试日期:2021-09-01 或 2021/09/01 或 2021.09.01)" + "\n考试时间[" + time + "]应该使用如下的格式(考试时间:18:00-20:00)");
         }
         long startTime = DateDisposeUtils.parseDate(startTimeStr).getTime();
         long endTime = DateDisposeUtils.parseDate(endTimeStr).getTime();
@@ -97,7 +85,6 @@ public class ConvertUtil {
         String date;
         String time;
 
-
         Map<String, Object> map = new HashMap<>();
 
         Calendar calendar = Calendar.getInstance();
@@ -121,7 +108,6 @@ public class ConvertUtil {
         return map;
     }
 
-
     /**
      * 根据开始时间和结束时间解析日期和时间
      *
@@ -148,6 +134,81 @@ public class ConvertUtil {
         }
     }
 
+    /**
+     * 解析excel
+     *
+     * @param inputStream   inputStream
+     * @param clazz         实体类映射对象
+     * @param fillError     是否为映射对象添加错误信息(如果要添加的话映射对象的属性必须有一个字段有@ExcelError注解)
+     * @param columnNameRow 从第几行开始
+     * @throws Exception 异常
+     */
+    public static <T> ExcelResult<T> analyzeExcel(InputStream inputStream, Class<T> clazz, boolean fillError, int columnNameRow)
+            throws Exception {
+        boolean analyzeResult = true;
+        ExcelReader excelReader = ExcelReader.create(ExcelType.XLSX, inputStream, columnNameRow);
+        List<String[]> excelDatasource = excelReader.getDataArrayList();
+        List<T> dtoList = new ArrayList<>();
+        if (CollectionUtils.isNotEmpty(excelDatasource)) {
+            List<String> columnNameList = Arrays.asList(excelReader.getColumnNames());
+            Field[] fields = clazz.getDeclaredFields();
+            Field errorField = null;
+            if (fillError) {
+                for (Field field : fields) {
+                    ExcelError annotation = field.getAnnotation(ExcelError.class);
+                    if (Objects.nonNull(annotation)) {
+                        errorField = field;
+                        break;
+                    }
+                }
+            }
+            // 要导入的字段
+            List<Field> fieldList = Arrays.stream(fields).filter(field -> {
+                ExcelColumn annotation = field.getAnnotation(ExcelColumn.class);
+                return Objects.nonNull(annotation);
+            }).collect(Collectors.toList());
+            List<String> fieldNameList = fieldList.stream().map(e -> e.getAnnotation(ExcelColumn.class).name()).collect(Collectors.toList());
+
+            if (columnNameList.size() != fieldNameList.size()) {
+                throw ExceptionResultEnum.ERROR.exception(String.format("表头错误,应为[%s]", String.join(";", fieldNameList)));
+            }
+            for (String[] cell : excelDatasource) {
+                T dto = clazz.newInstance();
+                boolean emptyCell = true;
+                List<String> excelErrorList = new ArrayList<>();
+                for (int i = 0; i < cell.length; i++) {
+                    String v = StringUtils.trimToNull(cell[i]);
+                    Field field = fieldList.get(i);
+                    ExcelColumn annotation = field.getAnnotation(ExcelColumn.class);
+                    if (SystemConstant.strNotNull(v)) {
+                        field.setAccessible(true);
+                        field.set(dto, v);
+                        emptyCell = false;
+                    } else if (annotation.nullable()) {
+                        excelErrorList.add(String.format("[%s]不能为空", annotation.name()));
+                    }
+                }
+                if (emptyCell) {
+                    // 舍弃全空行
+                    continue;
+                }
+                if (CollectionUtils.isNotEmpty(excelErrorList)) {
+                    // 有异常数据
+                    analyzeResult = false;
+                    if (fillError && Objects.nonNull(errorField)) {
+                        errorField.setAccessible(true);
+                        errorField.set(dto, String.join(",", excelErrorList));
+                    }
+                }
+                dtoList.add(dto);
+            }
+        }
+        ExcelResult<T> excelResult = new ExcelResult<>();
+        excelResult.setSuccess(analyzeResult);
+        excelResult.setDatasource(dtoList);
+        return excelResult;
+    }
+
     public static void delFolder(String folderPath) {
         try {
             delAllFile(folderPath); //删除完里面所有内容
@@ -190,8 +251,8 @@ public class ConvertUtil {
 
     public static void outputFile(HttpServletResponse response, InputStream inputStream, String fileName) {
         try {
-//            byte[] buf = new byte[1024];
-//            int len = 0;
+            //            byte[] buf = new byte[1024];
+            //            int len = 0;
 
             String fName = new String(fileName.getBytes(), "ISO-8859-1");
 
@@ -199,15 +260,15 @@ public class ConvertUtil {
             response.setContentType("application/x-msdownload");
             response.setHeader("Content-Disposition", "attachment; filename=" + fName);
 
-//            OutputStream outStream = response.getOutputStream();
+            //            OutputStream outStream = response.getOutputStream();
 
-//            while ((len = inputStream.read(buf)) > 0) {
-//                outStream.write(buf, 0, len);
-//            }
+            //            while ((len = inputStream.read(buf)) > 0) {
+            //                outStream.write(buf, 0, len);
+            //            }
 
             IOUtils.copy(inputStream, response.getOutputStream());
             inputStream.close();
-//            outStream.close();
+            //            outStream.close();
         } catch (IOException e) {
             log.error(SystemConstant.LOG_ERROR, e);
         }
@@ -221,9 +282,9 @@ public class ConvertUtil {
             response.setContentType("application/x-msdownload");
             response.setHeader("Content-Disposition", "attachment; filename=" + fName);
 
-//            OutputStream outStream = response.getOutputStream();
-//            baos.writeTo(outStream);
-//            outStream.close();
+            //            OutputStream outStream = response.getOutputStream();
+            //            baos.writeTo(outStream);
+            //            outStream.close();
             IOUtils.write(baos.toByteArray(), response.getOutputStream());
         } catch (IOException e) {
             throw new Exception("下载失败");
@@ -234,7 +295,7 @@ public class ConvertUtil {
         PDDocument doc = null;
         ByteArrayOutputStream os = null;
         InputStream stream = null;
-//        OutputStream out = null;
+        //        OutputStream out = null;
         List<File> fileList = new ArrayList<>();
         try {
             // pdf路径
@@ -255,9 +316,9 @@ public class ConvertUtil {
                     file.getParentFile().mkdirs();
                     file.createNewFile();
                 }
-//                out = new FileOutputStream(file);
+                //                out = new FileOutputStream(file);
                 IOUtils.write(os.toByteArray(), new FileOutputStream(file));
-//                out.write(dataList);
+                //                out.write(dataList);
                 fileList.add(file);
             }
         } catch (Exception e) {
@@ -320,5 +381,4 @@ public class ConvertUtil {
         }
         return fileList;
     }
-
 }

+ 7 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/MarkStudentService.java

@@ -1,6 +1,7 @@
 package com.qmth.teachcloud.mark.service;
 
 import java.util.List;
+import java.util.Set;
 
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.constraints.NotNull;
@@ -10,6 +11,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
 import com.qmth.teachcloud.common.entity.BasicExam;
+import com.qmth.teachcloud.common.entity.BasicExamStudent;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.ScanStatus;
 import com.qmth.teachcloud.common.enums.mark.MarkPaperStatus;
@@ -69,6 +71,7 @@ public interface MarkStudentService extends IService<MarkStudent> {
     void updateStudentByPaper(@NotNull Long userId, @NotNull Long studentId, @NotNull boolean updateOmrTask);
 
     MarkStudent findByExamIdAndCoursePaperIdAndStudentCode(Long examId, String coursePaperId, String studentCode);
+    MarkStudent findByExamIdAndPaperNumberAndStudentCode(Long examId, String paperNumber, String studentCode);
 
     StudentObjectiveDetailDto getObjectiveInspectedTask(Long studentId);
 
@@ -155,4 +158,8 @@ public interface MarkStudentService extends IService<MarkStudent> {
     void trackExport(Long examId, String paperNumber, HttpServletResponse response);
 
     void sheetExport(Long examId, String paperNumber, HttpServletResponse response);
+
+    void updateByBasicExamStudent(BasicExamStudent basicExamStudent, Set<String> secretNumberSet);
+
+    void deleteByExamIdAndPaperNumberAndStudentCode(Long examId, String paperNumber, String studentCode);
 }

+ 110 - 63
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkStudentServiceImpl.java

@@ -1,31 +1,5 @@
 package com.qmth.teachcloud.mark.service.impl;
 
-import java.awt.*;
-import java.awt.color.ColorSpace;
-import java.awt.image.BufferedImage;
-import java.awt.image.ColorConvertOp;
-import java.io.*;
-import java.math.BigDecimal;
-import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
-import java.util.*;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import javax.annotation.Resource;
-import javax.imageio.ImageIO;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletResponse;
-import javax.validation.constraints.NotNull;
-
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.FileCopyUtils;
-
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -48,17 +22,13 @@ import com.qmth.boot.tools.io.ZipWriter;
 import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
 import com.qmth.teachcloud.common.bean.vo.FilePathVo;
 import com.qmth.teachcloud.common.contant.SystemConstant;
-import com.qmth.teachcloud.common.entity.BasicExam;
-import com.qmth.teachcloud.common.entity.MarkQuestion;
-import com.qmth.teachcloud.common.entity.SysUser;
+import com.qmth.teachcloud.common.entity.*;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.PageSizeEnum;
 import com.qmth.teachcloud.common.enums.ScanStatus;
 import com.qmth.teachcloud.common.enums.mark.MarkPaperStatus;
 import com.qmth.teachcloud.common.enums.mark.SubjectiveStatus;
-import com.qmth.teachcloud.common.service.BasicRoleDataPermissionService;
-import com.qmth.teachcloud.common.service.FileUploadService;
-import com.qmth.teachcloud.common.service.TeachcloudCommonService;
+import com.qmth.teachcloud.common.service.*;
 import com.qmth.teachcloud.common.util.*;
 import com.qmth.teachcloud.mark.bean.UpdateTimeVo;
 import com.qmth.teachcloud.mark.bean.archivescore.*;
@@ -87,6 +57,30 @@ import com.qmth.teachcloud.mark.service.*;
 import com.qmth.teachcloud.mark.utils.BatchGetDataUtil;
 import com.qmth.teachcloud.mark.utils.Calculator;
 import com.qmth.teachcloud.mark.utils.ScoreCalculateUtil;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.FileCopyUtils;
+
+import javax.annotation.Resource;
+import javax.imageio.ImageIO;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.constraints.NotNull;
+import java.awt.*;
+import java.awt.color.ColorSpace;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorConvertOp;
+import java.io.*;
+import java.math.BigDecimal;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -99,21 +93,20 @@ import com.qmth.teachcloud.mark.utils.ScoreCalculateUtil;
 @Service
 public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkStudent> implements MarkStudentService {
 
+    @Resource
+    private BasicCourseService basicCourseService;
+    @Resource
+    private BasicClazzService basicClazzService;
     @Autowired
     private MarkPaperService markPaperService;
-
     @Resource
     private MarkPaperPackageService markPaperPackageService;
-
     @Autowired
     private ScanPackageService scanPackageService;
-
     @Autowired
     private ScanPaperService scanPaperService;
-
     @Autowired
     private ScanPaperPageService scanPaperPageService;
-
     @Autowired
     private ScanOmrTaskService scanOmrTaskService;
 
@@ -435,8 +428,7 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
     }
 
     @Override
-    public MarkStudent findByExamIdAndCoursePaperIdAndStudentCode(Long examId, String coursePaperId,
-                                                                  String studentCode) {
+    public MarkStudent findByExamIdAndCoursePaperIdAndStudentCode(Long examId, String coursePaperId, String studentCode) {
         QueryWrapper<MarkStudent> wrapper = new QueryWrapper<>();
         LambdaQueryWrapper<MarkStudent> lw = wrapper.lambda();
         lw.eq(MarkStudent::getExamId, examId);
@@ -445,6 +437,20 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
         return baseMapper.selectOne(wrapper);
     }
 
+    @Override
+    public MarkStudent findByExamIdAndPaperNumberAndStudentCode(Long examId, String paperNumber, String studentCode) {
+        QueryWrapper<MarkStudent> wrapper = new QueryWrapper<>();
+        LambdaQueryWrapper<MarkStudent> lw = wrapper.lambda();
+        lw.eq(MarkStudent::getExamId, examId);
+        lw.eq(MarkStudent::getPaperNumber, paperNumber);
+        if (StringUtils.isNotBlank(studentCode)) {
+            lw.eq(MarkStudent::getStudentCode, studentCode);
+        } else {
+            lw.last("limit 1");
+        }
+        return baseMapper.selectOne(wrapper);
+    }
+
     @Override
     public StudentObjectiveDetailDto getObjectiveInspectedTask(Long studentId) {
         MarkStudent markStudent = this.getById(studentId);
@@ -1404,34 +1410,34 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
     @Override
     public void trackExport(Long examId, String coursePaperId, HttpServletResponse response) {
         {
-            List<MarkStudent> list = this.listByExamIdAndCoursePaperId(examId,coursePaperId);
+            List<MarkStudent> list = this.listByExamIdAndCoursePaperId(examId, coursePaperId);
             if (CollectionUtils.isNotEmpty(list)) {
                 try {
-                    response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("轨迹图.zip","UTF-8"));
+                    response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("轨迹图.zip", "UTF-8"));
                     ZipWriter writer = ZipWriter.create(response.getOutputStream());
                     ByteArrayOutputStream os = new ByteArrayOutputStream();
-                    for (MarkStudent s:list) {
-                        if(!s.getUpload()){
+                    for (MarkStudent s : list) {
+                        if (!s.getUpload()) {
                             continue;
                         }
                         List<FilePathVo> vos = JSON.parseArray(s.getSheetPath(), FilePathVo.class);
                         List<MarkTrack> trackList = markTrackService.listByStudentId(s.getId());
-                        Document document = new Document(new Rectangle(PageSize.A3.getHeight(),PageSize.A3.getWidth()));
+                        Document document = new Document(new Rectangle(PageSize.A3.getHeight(), PageSize.A3.getWidth()));
                         // 本地保存目录
                         File tempFile = SystemConstant.getFileTempParentDirVar(SystemConstant.TEMP_PREFIX);
-                        File file =new File(tempFile.getPath()+File.separator + s.getStudentCode()+".pdf");
-                        PdfWriter pdfWriter = PdfWriter.getInstance(document,new FileOutputStream(file));
+                        File file = new File(tempFile.getPath() + File.separator + s.getStudentCode() + ".pdf");
+                        PdfWriter pdfWriter = PdfWriter.getInstance(document, new FileOutputStream(file));
                         document.open();
                         for (int i = 0; i < vos.size(); i++) {
                             FilePathVo vo = vos.get(i);
-                            File sheet =  fileUploadService.downloadFile(JSON.toJSONString(vo),vo.getPath());
-                            File track = new File(tempFile.getPath()+File.separator + s.getStudentCode()+"-"+(i+1)+".jpg");
-                            int offsetIndex = i+1;
-                            List<MarkTrack> tracks = trackList.stream().filter(t->t.getOffsetIndex().equals(offsetIndex)).collect(Collectors.toList());
-                            this.createTrack(sheet,track,tracks);
+                            File sheet = fileUploadService.downloadFile(JSON.toJSONString(vo), vo.getPath());
+                            File track = new File(tempFile.getPath() + File.separator + s.getStudentCode() + "-" + (i + 1) + ".jpg");
+                            int offsetIndex = i + 1;
+                            List<MarkTrack> tracks = trackList.stream().filter(t -> t.getOffsetIndex().equals(offsetIndex)).collect(Collectors.toList());
+                            this.createTrack(sheet, track, tracks);
                             Image image = Image.getInstance(track.getPath());
-                            image.scaleAbsolute(PageSize.A3.getHeight()-100,PageSize.A3.getWidth()-100);
-                            if(i!=0){
+                            image.scaleAbsolute(PageSize.A3.getHeight() - 100, PageSize.A3.getWidth() - 100);
+                            if (i != 0) {
                                 document.newPage();
                             }
                             document.add(image);
@@ -1440,10 +1446,10 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
                         }
                         document.close();
                         pdfWriter.close();
-                        writer.write(file,s.getStudentCode()+".pdf");
+                        writer.write(file, s.getStudentCode() + ".pdf");
                     }
                     writer.close();
-                }catch (Exception e){
+                } catch (Exception e) {
                     e.printStackTrace();
                     throw new ParameterException("文件下载失败", e);
                 }
@@ -1451,7 +1457,7 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
         }
     }
 
-    private void createTrack(File sheet, File track, List<MarkTrack> trackList)throws IOException {
+    private void createTrack(File sheet, File track, List<MarkTrack> trackList) throws IOException {
         {
             FileOutputStream output = null;
             try {
@@ -1487,30 +1493,71 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
 
     @Override
     public void sheetExport(Long examId, String coursePaperId, HttpServletResponse response) {
-        List<MarkStudent> list = this.listByExamIdAndCoursePaperId(examId,coursePaperId);
+        List<MarkStudent> list = this.listByExamIdAndCoursePaperId(examId, coursePaperId);
         if (CollectionUtils.isNotEmpty(list)) {
             try {
-                response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("原图.zip","UTF-8"));
+                response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("原图.zip", "UTF-8"));
                 ZipWriter writer = ZipWriter.create(response.getOutputStream());
                 ByteArrayOutputStream os = new ByteArrayOutputStream();
-                for (MarkStudent s:list) {
-                    if(!s.getUpload()){
+                for (MarkStudent s : list) {
+                    if (!s.getUpload()) {
                         continue;
                     }
                     List<FilePathVo> vos = JSON.parseArray(s.getSheetPath(), FilePathVo.class);
                     for (int i = 0; i < vos.size(); i++) {
                         FilePathVo vo = vos.get(i);
-                        File file =  fileUploadService.downloadFile(JSON.toJSONString(vo),vo.getPath());
+                        File file = fileUploadService.downloadFile(JSON.toJSONString(vo), vo.getPath());
                         String format = FilenameUtils.getExtension(file.getName());
-                        writer.write(file, s.getStudentCode()+"-"+(i+1)+"."+format);
+                        writer.write(file, s.getStudentCode() + "-" + (i + 1) + "." + format);
                         file.delete();
                     }
                 }
                 writer.close();
-            }catch (Exception e){
+            } catch (Exception e) {
                 e.printStackTrace();
                 throw new ParameterException("文件下载失败", e);
             }
         }
     }
+
+    @Override
+    public void updateByBasicExamStudent(BasicExamStudent basicExamStudent, Set<String> secretNumberSet) {
+        MarkStudent markStudent = this.findByExamIdAndPaperNumberAndStudentCode(basicExamStudent.getExamId(), basicExamStudent.getPaperNumber(), basicExamStudent.getStudentCode());
+        BasicCourse basicCourse = basicCourseService.getByCode(basicExamStudent.getCourseCode());
+        BasicClazz basicClazz = basicClazzService.getById(basicExamStudent.getClazzId());
+        if (markStudent == null) {
+            String coursePaperId = null;
+            MarkStudent markStudentPaperNumberLimit1 = this.findByExamIdAndPaperNumberAndStudentCode(basicExamStudent.getExamId(), basicExamStudent.getPaperNumber(), null);
+            if (markStudentPaperNumberLimit1 == null) {
+                coursePaperId = String.valueOf(System.currentTimeMillis());
+            } else {
+                coursePaperId = markStudentPaperNumberLimit1.getCoursePaperId();
+            }
+            markStudent = new MarkStudent(basicExamStudent.getId(), basicExamStudent.getExamId(), basicExamStudent.getCourseCode(), basicCourse.getName(), basicExamStudent.getPaperNumber(), coursePaperId, "A", basicExamStudent.getStudentCode(), basicExamStudent.getStudentName(), "", basicExamStudent.getExamPlace(), basicExamStudent.getExamRoom(), basicExamStudent.getCollege(), basicExamStudent.getMajor(), basicClazz.getClazzName(), basicExamStudent.getExamStartTime(), basicExamStudent.getExamEndTime(), basicExamStudent.getCreateId());
+            if (markStudent.getSecretNumber() == null) {
+                markStudent.randomSecretNumber();
+                while (secretNumberSet.contains(markStudent.getSecretNumber())
+                        || this.countByExamIdAndSecretNumber(markStudent.getExamId(), markStudent.getSecretNumber()) > 0) {
+                    markStudent.randomSecretNumber();
+                }
+            }
+        } else {
+            markStudent.setStudentName(basicExamStudent.getStudentName());
+            markStudent.setCollege(basicExamStudent.getCollege());
+            markStudent.setMajorName(basicExamStudent.getMajor());
+            markStudent.setClassName(basicClazz.getClazzName());
+            markStudent.setExamPlace(basicExamStudent.getExamPlace());
+            markStudent.setExamRoom(basicExamStudent.getExamRoom());
+        }
+        this.saveOrUpdate(markStudent);
+    }
+
+    @Override
+    public void deleteByExamIdAndPaperNumberAndStudentCode(Long examId, String paperNumber, String studentCode) {
+        UpdateWrapper<MarkStudent> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.lambda().eq(MarkStudent::getExamId, examId)
+                .eq(MarkStudent::getPaperNumber, paperNumber)
+                .eq(MarkStudent::getStudentCode, studentCode);
+        this.remove(updateWrapper);
+    }
 }

+ 1 - 1
teachcloud-task/src/main/java/com/qmth/teachcloud/task/service/impl/PrintFinishServiceImpl.java

@@ -128,7 +128,7 @@ public class PrintFinishServiceImpl implements PrintFinishService {
                     if (markStudent != null) {
                         continue;
                     }
-                    MarkStudent student = new MarkStudent(examStudent.getId(), dto.getExamId(), dto.getCourseCode(), dto.getCourseName(), dto.getPaperNumber(), dto.getCoursePaperId(), paperType, examStudent.getStudentCode(), examStudent.getStudentName(), examDetail.getPackageCode(), examDetail.getExamPlace(), examDetail.getExamRoom(), examStudent.getCollegeName(), examStudent.getMajorName(), examStudent.getClazzName(), dto.getExamStartTime(), dto.getExamEndTime(), dto.getCreateId());
+                    MarkStudent student = new MarkStudent(examStudent.getId(), dto.getExamId(), dto.getCourseCode(), dto.getCourseName(), dto.getPaperNumber(), dto.getCoursePaperId(), paperType, examStudent.getStudentCode(), examStudent.getStudentName(), examDetail.getPackageCode(), examDetail.getExamPlace(), examDetail.getExamRoom(), examStudent.getCollegeName(), examStudent.getMajorName(), examStudent.getTeachClazzName(), dto.getExamStartTime(), dto.getExamEndTime(), dto.getCreateId());
                     if (student.getSecretNumber() == null) {
                         student.randomSecretNumber();
                         while (secretNumberSet.contains(student.getSecretNumber())