yin hace 7 meses
padre
commit
ef038fb226

+ 28 - 32
src/main/java/cn/com/qmth/scancentral/service/impl/StudentServiceImpl.java

@@ -5,14 +5,7 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ThreadPoolExecutor;
@@ -118,7 +111,6 @@ import cn.com.qmth.scancentral.support.SpringContextHolder;
 import cn.com.qmth.scancentral.support.TaskLock;
 import cn.com.qmth.scancentral.support.TaskLockUtil;
 import cn.com.qmth.scancentral.util.BatchGetDataUtil;
-import cn.com.qmth.scancentral.util.BatchSetDataUtil;
 import cn.com.qmth.scancentral.util.MD5Util;
 import cn.com.qmth.scancentral.util.PageUtil;
 import cn.com.qmth.scancentral.vo.AbsentInfoVo;
@@ -263,7 +255,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
         // 保存绑定关系
         studentPaperService.saveOrUpdateBatchByMultiId(studentPaperList);
         // 更新考生状态
-        updateStudentByPaper(user, id, true,true);
+        updateStudentByPaper(user, id, true, true);
     }
 
     /**
@@ -274,7 +266,8 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
     @Override
     @Transactional
     // @Lockable(name = LockType.STUDENT, key = "#id")
-    public StudentEntity updateStudentByPaper(@NotNull User user, @NotNull Long id, @NotNull boolean updateOmrTask, boolean updateAssignedCount) {
+    public StudentEntity updateStudentByPaper(@NotNull User user, @NotNull Long id, @NotNull boolean updateOmrTask,
+            boolean updateAssignedCount) {
         StudentEntity student = baseMapper.selectById(id);
         if (student == null) {
             throw new ParameterException("找不到对应的考生");
@@ -371,7 +364,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
             if (CollectionUtils.isNotEmpty(gs)) {
                 for (OmrGroupEntity g : gs) {
                     concurrentService.getReadWriteLock(LockType.OMR_GROUP + "-" + g.getId()).readLock().lock();
-                    omrTaskService.deleteByStudentIdAndGroupId(g.getId(), student.getId(),true);
+                    omrTaskService.deleteByStudentIdAndGroupId(g.getId(), student.getId(), true);
                     // 默认分组重新生成识别对照任务,其他任务不生成
                     if (g.getFixed()) {
                         omrTaskService.saveTask(g, student.getId());
@@ -380,7 +373,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
                 }
             }
         }
-        if(updateAssignedCount){
+        if (updateAssignedCount) {
             this.updateAssignedCheckCount(student.getId(), true);
         }
         return student;
@@ -1162,7 +1155,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
                 }
                 paperService.savePaperAndPages(paper, pages);
             }
-            updateStudentByPaper(user, student.getId(), true,false);
+            updateStudentByPaper(user, student.getId(), true, false);
             return AnswerRefixVo.create();
         } finally {
             concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock().unlock();
@@ -1197,7 +1190,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
                 }
                 paperService.savePaperAndPages(paperEntity, pages);
             }
-            updateStudentByPaper(user, student.getId(), false,false);
+            updateStudentByPaper(user, student.getId(), false, false);
             return UpdateTimeVo.create();
         } finally {
             concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock().unlock();
@@ -1253,7 +1246,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
                 throw new ParameterException("未找到page信息结果");
             }
             paperService.savePaperAndPages(paperEntity, pages);
-            updateStudentByPaper(user, student.getId(), false,false);
+            updateStudentByPaper(user, student.getId(), false, false);
             return UpdateTimeVo.create();
         } finally {
             concurrentService.getReadWriteLock(LockType.STUDENT + "-" + student.getId()).writeLock().unlock();
@@ -1308,8 +1301,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
         if (!ExamMode.CET.equals(exam.getMode())) {
             throw new StatusException("该考试不是CET");
         }
-        List<ExportCetVo> dataList = baseMapper
-                .listCetMarkingPage(query);
+        List<ExportCetVo> dataList = baseMapper.listCetMarkingPage(query);
         if (CollectionUtils.isNotEmpty(dataList)) {
             String imageTransferDir = sysProperty.getTransferDir();
             Map<String, List<QuestionEntity>> structs = new HashMap<>();
@@ -1317,27 +1309,31 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
             List<Long> ids = dataList.stream().map(e -> e.getId()).collect(Collectors.toList());
             List<PaperPageCetVo> totalpages = paperPageService.listByStudentIds(ids);
             List<PaperCetVo> totalpapers = paperService.findByStudentIds(ids);
-            for (ExportCetVo vo: dataList) {
+            for (ExportCetVo vo : dataList) {
                 Map<Long, List<PaperPageCetVo>> totalpagesmap = ofPage(totalpages);
                 Map<Long, List<PaperCetVo>> totalpapersmap = ofPaper(totalpapers);
                 disposeStudent(vo, paperTypeBarcodeContents, totalpagesmap.get(vo.getId()),
-                            totalpapersmap.get(vo.getId()), imageTransferDir, structs, cardMap);
-            }
-//            new BatchSetDataUtil<ExportCetVo>() {
-//
-//                @Override
-//                protected void setData(List<ExportCetVo> dataList) {
-//
-//
-//                }
-//            }.setDataForBatch(iPage, 200);
+                        totalpapersmap.get(vo.getId()), imageTransferDir, structs, cardMap);
+            }
+            // new BatchSetDataUtil<ExportCetVo>() {
+            //
+            // @Override
+            // protected void setData(List<ExportCetVo> dataList) {
+            //
+            //
+            // }
+            // }.setDataForBatch(iPage, 200);
         }
-        return iPage;
+        return dataList;
     }
 
     private void disposeStudent(ExportCetVo student, List<String> paperTypeBarcodeContents, List<PaperPageCetVo> pages,
             List<PaperCetVo> papers, String imageTransferDir, Map<String, List<QuestionEntity>> structs,
             Map<Integer, AnswerCardEntity> cardMap) {
+        pages = pages.stream().sorted(Comparator.comparingInt(PaperPageCetVo::getPaperNumber).thenComparingInt(PaperPageCetVo::getPageIndex))
+                .collect(Collectors.toList());
+        papers = papers.stream().sorted(Comparator.comparingInt(PaperCetVo::getPaperNumber))
+                .collect(Collectors.toList());
         int subjectCodeVal = Integer.valueOf(student.getSubjectCode());
         if (subjectCodeVal > 2) {
             if (student.getExamStatus().equals(ExamStatus.ABSENT)) {
@@ -2036,7 +2032,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
             Long pageSize, User user) {
         IPage<AnswerQueryVo> result = this.baseMapper.getAssignedCheckTaskHistory(new Page<>(pageNumber, pageSize),
                 examId, subjectCode, user.getId());
-        SubjectEntity subject = subjectService.findByExamIdAndCode(examId,subjectCode);
+        SubjectEntity subject = subjectService.findByExamIdAndCode(examId, subjectCode);
         for (AnswerQueryVo t : result.getRecords()) {
             t.setSubjectName(subject.getName());
             t = toTaskVo(t);
@@ -2058,7 +2054,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
         } else {
             checkCount = 1;
         }
-        SubjectEntity subject = subjectService.findByExamIdAndCode(examId,subjectCode);
+        SubjectEntity subject = subjectService.findByExamIdAndCode(examId, subjectCode);
         while (task == null) {
             IPage<AnswerQueryVo> list = this.findUnCheck(examId, subjectCode, checkCount, retry, 20);
             if (list.getRecords().isEmpty()) {

+ 2 - 4
src/main/java/cn/com/qmth/scancentral/service/impl/SubjectServiceImpl.java

@@ -376,8 +376,7 @@ public class SubjectServiceImpl extends MppServiceImpl<SubjectDao, SubjectEntity
                 if (CollectionUtils.isEmpty(temp)) {
                     break;
                 }
-                startId = temp.stream()
-                        .max(Comparator.comparingLong(ExportCetVo::getId)).map(ExportCetVo::getId).get();
+                startId = temp.get(temp.size()-1).getId();
                 list.addAll(temp);
                 log.warn("【DBF导出】查询考生数据,当前第{}页共{}条! taskId:{}",req.getPageNumber(), list.size(), vo.getTaskId());
             }
@@ -609,8 +608,7 @@ public class SubjectServiceImpl extends MppServiceImpl<SubjectDao, SubjectEntity
                 if (CollectionUtils.isEmpty(temp)) {
                     break;
                 }
-                startId = temp.stream()
-                        .max(Comparator.comparingLong(ExportCetVo::getId)).map(ExportCetVo::getId).get();
+                startId = temp.get(temp.size()-1).getId();
                 list.addAll(temp);
             }
             if (CollectionUtils.isEmpty(list)) {

+ 9 - 0
src/main/java/cn/com/qmth/scancentral/vo/paper/PaperCetVo.java

@@ -8,6 +8,8 @@ public class PaperCetVo {
 
     private Long studentId;
 
+    private Integer paperNumber;
+
     public Long getId() {
         return id;
     }
@@ -32,4 +34,11 @@ public class PaperCetVo {
         this.studentId = studentId;
     }
 
+    public Integer getPaperNumber() {
+        return paperNumber;
+    }
+
+    public void setPaperNumber(Integer paperNumber) {
+        this.paperNumber = paperNumber;
+    }
 }

+ 9 - 0
src/main/java/cn/com/qmth/scancentral/vo/paper/PaperPageCetVo.java

@@ -14,6 +14,8 @@ public class PaperPageCetVo {
 
     private Long paperId;
 
+    private Integer paperNumber;
+
     private Integer pageIndex;
 
     private BoolResult absent;
@@ -118,4 +120,11 @@ public class PaperPageCetVo {
         this.slicePath = slicePath;
     }
 
+    public Integer getPaperNumber() {
+        return paperNumber;
+    }
+
+    public void setPaperNumber(Integer paperNumber) {
+        this.paperNumber = paperNumber;
+    }
 }

+ 5 - 7
src/main/resources/application.properties

@@ -12,21 +12,19 @@ db.host=localhost
 db.port=3306
 db.database=scan_central
 com.qmth.datasource.username=root
-com.qmth.datasource.password=12345678
+com.qmth.datasource.password=123456
 com.qmth.datasource.url=jdbc:mysql://${db.host}:${db.port}/${db.database}?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=GMT%2b8&rewriteBatchedStatements=true
 #
 # ********** sys config **********
 #
 com.qmth.solar.app-version=@project.version@
 com.qmth.logging.root-level=info
-com.qmth.logging.file-path=/Users/yin/Downloads/log/scancentral.log
+com.qmth.logging.file-path=../log/scancentral.log
 com.qmth.auth.time-max-delay=3600s
 com.qmth.auth.time-max-ahead=3600s
-com.qmth.fss.config=/Users/yin/Downloads/static
-com.qmth.fss.server=http://192.168.11.168
-scancentral.image-transfer.dir=/Users/yin/Downloads/static
+com.qmth.fss.config=../static
+com.qmth.fss.server=http://192.168.11.118
+scancentral.image-transfer.dir=../imagetransfer
 scancentral.heartbeat-timeout=300
 scancentral.file-uri-prefix=file
 scancentral.swagger.enable=true
-
-com.qmth.auth.debugMode=true

+ 2 - 1
src/main/resources/mapper/PaperMapper.xml

@@ -4,6 +4,7 @@
     <select id="findByStudentIds"
             resultType="cn.com.qmth.scancentral.vo.paper.PaperCetVo">
         SELECT p.id,
+        t.paper_number,
         p.question_filled questionFilled,t.student_id
         FROM sc_student_paper t
         inner join sc_paper p on t.paper_id = p.id
@@ -12,7 +13,7 @@
                  index="index" separator="," open="(" close=")">
             #{item}
         </foreach>
-        ORDER BY t.paper_number
+--         ORDER BY t.paper_number
     </select>
     <select id="findStudentPaper"
             resultType="cn.com.qmth.scancentral.vo.paper.PaperVo">

+ 2 - 2
src/main/resources/mapper/PaperPageMapper.xml

@@ -17,7 +17,7 @@
 			typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" />
 	</resultMap>
 	<select id="listByStudentIds" resultMap="custMap">
-		SELECT pg.*,t.student_id
+		SELECT pg.*,t.student_id,t.paper_number
 		FROM sc_student_paper t
 		left join sc_paper_page pg on t.paper_id = pg.paper_id
 		WHERE t.student_id in
@@ -25,7 +25,7 @@
 			index="index" separator="," open="(" close=")">
 			#{item}
 		</foreach>
-		ORDER BY t.paper_number,pg.page_index
+-- 		ORDER BY t.paper_number,pg.page_index
 	</select>
 
 </mapper>