yin 7 hónapja
szülő
commit
83c22abca3

+ 1 - 1
src/main/java/cn/com/qmth/scancentral/controller/scan/ScanBatchController.java

@@ -84,6 +84,6 @@ public class ScanBatchController extends BaseController {
     @ApiOperation(value = "答题卡扫描批次完成")
     @RequestMapping(value = "/finish", method = RequestMethod.POST)
     public BatchFinishVo batchFinish(@RequestParam Long id) {
-        return batchService.batchFinish(id);
+        return batchService.batchFinish(id,null,null);
     }
 }

+ 2 - 1
src/main/java/cn/com/qmth/scancentral/service/BatchService.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import cn.com.qmth.scancentral.bean.answersave.AnswerPackageDomain;
 import cn.com.qmth.scancentral.bean.answersave.AnswerPackageSave;
+import io.swagger.models.auth.In;
 import org.springframework.web.multipart.MultipartFile;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -47,7 +48,7 @@ public interface BatchService extends IService<BatchEntity> {
 
     BatchVerifyVo batchVerify(Long id);
 
-    BatchFinishVo batchFinish(Long id);
+    BatchFinishVo batchFinish(Long id, Integer scanCount,Integer assignedCount);
 
     void updateScanCount(Long id);
 

+ 17 - 8
src/main/java/cn/com/qmth/scancentral/service/impl/BatchServiceImpl.java

@@ -483,7 +483,7 @@ public class BatchServiceImpl extends ServiceImpl<BatchDao, BatchEntity> impleme
 
     @Transactional
     @Override
-    public BatchFinishVo batchFinish(Long id) {
+    public BatchFinishVo batchFinish(Long id, Integer scanCount,Integer assignedCount) {
         BatchEntity entity = this.getById(id);
         if (entity == null) {
             throw new ParameterException("批次不存在");
@@ -533,9 +533,14 @@ public class BatchServiceImpl extends ServiceImpl<BatchDao, BatchEntity> impleme
             entity.setCheckStatus(CheckStatus.WAITING);
         }
         entity.setStatus(BatchStatus.FINISH);
+        if(scanCount!=null && assignedCount!=null){
+            entity.setAssignedCount(assignedCount);
+            entity.setScanCount(scanCount);
+        }else{
+            updateAssignedCount(entity.getId());
+            updateScanCount(entity.getId());
+        }
         this.saveOrUpdate(entity);
-        updateAssignedCount(entity.getId());
-        updateScanCount(entity.getId());
         BatchFinishVo vo = new BatchFinishVo();
         vo.setStatus(entity.getStatus());
         vo.setUpdateTime(System.currentTimeMillis());
@@ -997,6 +1002,7 @@ public class BatchServiceImpl extends ServiceImpl<BatchDao, BatchEntity> impleme
 
         Map<String,AnswerPackageStudent> answerPackageStudentMap = new HashMap<>();
         Map<String,StudentEntity> studentMap = new HashMap<>();
+        Integer assignedCount = 0;
         for (AnswerPackageStudent packageStudent:domain.getStudents()) {
             String examNumber = packageStudent.getExamNumber();
             StudentEntity student = studentService.findByExamAndSubjectCodeAndExamNumber(batch.getExamId(),
@@ -1022,7 +1028,7 @@ public class BatchServiceImpl extends ServiceImpl<BatchDao, BatchEntity> impleme
         for (String examNumber:studentMap.keySet()) {
             AnswerPackageStudent answerPackageStudent = answerPackageStudentMap.get(examNumber);
             StudentEntity student = studentMap.get(examNumber);
-//            boolean studentAssigned = false;
+            boolean studentAssigned = false;
             List<StudentPaperEntity> studentPaperList = new ArrayList<>();
             for (AnswerPaper answerPaper : answerPackageStudent.getPapers()) {
                 // 验证page数量
@@ -1044,7 +1050,7 @@ public class BatchServiceImpl extends ServiceImpl<BatchDao, BatchEntity> impleme
                 batchPaperService.update(batch, paper, student.getId(), paperNumber, false);
                 // 创建student与paper的关联关系
                 studentPaperList.add(new StudentPaperEntity(student.getId(), paperNumber, paper.getId()));
-//                studentAssigned = studentAssigned || paper.getAssigned();
+                studentAssigned = studentAssigned || paper.getAssigned();
                 // 更新批次统计数量,改到finish的时候更新
                 // updateAssignedCount(batch.getId());
                 // updateScanCount(batch.getId());
@@ -1079,14 +1085,17 @@ public class BatchServiceImpl extends ServiceImpl<BatchDao, BatchEntity> impleme
                     }
 //                }
             }
+            if(studentAssigned){
+                assignedCount++;
+            }
         }
         for (OmrGroupEntity g : gs) {
-            concurrentService.getReadWriteLock(LockType.OMR_GROUP + "-" + g.getId()).readLock().lock();
+            concurrentService.getReadWriteLock(LockType.OMR_GROUP + "-" + g.getId()).writeLock().lock();
             omrGroupService.updateTotalCount(g.getId());
-            concurrentService.getReadWriteLock(LockType.OMR_GROUP + "-" + g.getId()).readLock().unlock();
+            concurrentService.getReadWriteLock(LockType.OMR_GROUP + "-" + g.getId()).writeLock().unlock();
         }
 
-        this.batchFinish(batch.getId());
+        this.batchFinish(batch.getId(),studentMap.size(),assignedCount);
 
         LambdaUpdateWrapper<BatchEntity> lw = new LambdaUpdateWrapper<>();
         lw.set(BatchEntity::getStatus, BatchStatus.DISCARD);