xiaofei 1 سال پیش
والد
کامیت
57ffd9c1f7
22فایلهای تغییر یافته به همراه252 افزوده شده و 171 حذف شده
  1. 9 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamStudentPdfInfoDto.java
  2. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamStudent.java
  3. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/enums/RequiredFieldsEnum.java
  4. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/BasicExamStudentMapper.java
  5. 4 6
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/BasicExamStudentService.java
  6. 20 29
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicExamStudentServiceImpl.java
  7. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicTeachClazzServiceImpl.java
  8. 2 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java
  9. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TeachStudentServiceImpl.java
  10. 2 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/SyncBasicExamStudentImportService.java
  11. 2 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/TaskLogicService.java
  12. 6 40
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java
  13. 51 5
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/pdf/CreatePdfNewUtil.java
  14. 9 2
      distributed-print-business/src/main/resources/mapper/ExamStudentMapper.xml
  15. 0 3
      distributed-print/src/main/java/com/qmth/distributed/print/api/BasicExamStudentController.java
  16. 1 1
      distributed-print/src/main/java/com/qmth/distributed/print/api/SysController.java
  17. 1 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/entity/BasicExamStudent.java
  18. 2 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/BasicCourseService.java
  19. 20 9
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/BasicCourseServiceImpl.java
  20. 7 0
      teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/MarkStudentService.java
  21. 110 63
      teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkStudentServiceImpl.java
  22. 1 1
      teachcloud-task/src/main/java/com/qmth/teachcloud/task/service/impl/PrintFinishServiceImpl.java

+ 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;

+ 2 - 3
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)) {
                 // 有异常数据

+ 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 );
 }

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

@@ -2308,7 +2308,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 +2316,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 +2329,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"

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

@@ -90,9 +90,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;

+ 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<>();

+ 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())