yin 8 meses atrás
pai
commit
7c312fb0fa

+ 10 - 12
src/main/java/cn/com/qmth/scancentral/service/impl/ImageCheckServiceImpl.java

@@ -54,19 +54,17 @@ public class ImageCheckServiceImpl implements ImageCheckService {
             vo.setSubjectCode(subject.getCode());
             vo.setSubjectName(subject.getName());
             vo.setTotalCount(studentService.countByExamIdAndSubjectCode(examId,subject.getCode()));
-            if(vo.getTotalCount()!=null && vo.getTotalCount()>0){
-                List<ImageCheckStatus> imageCheckStatusList = new ArrayList<>();
-                List<UploadStatus> fileUploadStatusList = new ArrayList<>();
-                vo.setFailedCount(studentService.getImageCheckFailedCount(examId,subject.getCode()));
-                vo.setDisposedCount(studentService.getImageCheckDisposedCount(examId,subject.getCode()));
-                if (vo.getTotalCount() == null || vo.getTotalCount() == 0) {
-                    vo.setImageCheckProgress(null);
-                } else {
-                    double progress = MathUtil.percentage(vo.getTotalCount() - vo.getDisposedCount(), vo.getTotalCount());
-                    vo.setImageCheckProgress(progress);
-                }
-                result.add(vo);
+            List<ImageCheckStatus> imageCheckStatusList = new ArrayList<>();
+            List<UploadStatus> fileUploadStatusList = new ArrayList<>();
+            vo.setFailedCount(studentService.getImageCheckFailedCount(examId,subject.getCode()));
+            vo.setDisposedCount(studentService.getImageCheckDisposedCount(examId,subject.getCode()));
+            if (vo.getTotalCount() == null || vo.getTotalCount() == 0) {
+                vo.setImageCheckProgress(null);
+            } else {
+                double progress = MathUtil.percentage(vo.getTotalCount() - vo.getDisposedCount(), vo.getTotalCount());
+                vo.setImageCheckProgress(progress);
             }
+            result.add(vo);
         }
 
         return result;

+ 19 - 23
src/main/java/cn/com/qmth/scancentral/service/impl/SubjectServiceImpl.java

@@ -18,6 +18,7 @@ import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 
+import cn.com.qmth.scancentral.enums.ScanStatus;
 import cn.com.qmth.scancentral.vo.*;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.io.IOUtils;
@@ -231,41 +232,36 @@ public class SubjectServiceImpl extends MppServiceImpl<SubjectDao, SubjectEntity
         }
 
         ret.setSubjects(subjects);
-        ret.setTotal(new SubjectScanProgressVo());
+        Calendar now = Calendar.getInstance();
+        long endTime = now.getTimeInMillis();
+        now.add(Calendar.HOUR_OF_DAY, -1);
+        long startTime = now.getTimeInMillis();
+        Integer inTimeScannedCount = batchPaperService.getScanStudentCount(examId, null, startTime, endTime);
         if (CollectionUtils.isNotEmpty(subjects)) {
-            int totalScanned = 0;
-            int totalCount = 0;
-            double totalEstimation = 0.0;
-            Calendar now = Calendar.getInstance();
-            long endTime = now.getTimeInMillis();
-            now.add(Calendar.HOUR_OF_DAY, -1);
-            long startTime = now.getTimeInMillis();
-            Integer inTimeScannedCount = batchPaperService.getScanStudentCount(examId, null, startTime, endTime);
             for (SubjectScanProgressVo vo : subjects) {
-                totalCount = totalCount + vo.getStudentCount();
                 vo.setScannedCount(vo.getStudentCount() - vo.getUnexistCount());
-                totalScanned = totalScanned + vo.getScannedCount();
                 vo.setProgress(Calculator.percentage(vo.getScannedCount(), vo.getStudentCount(), 2));
                 if (inTimeScannedCount == null || inTimeScannedCount == 0) {
                     vo.setEstimation("-");
                 } else {
                     double speed = Calculator.divide(endTime - startTime, inTimeScannedCount, 6);
                     double es = Calculator.divide(Calculator.multiply(speed, vo.getUnexistCount()), 3600000, 2);
-                    totalEstimation = Calculator.add(totalEstimation, es);
                     vo.setEstimation(es + "h");
                 }
             }
-
-            ret.getTotal().setStudentCount(totalCount);
-            ret.getTotal().setScannedCount(totalScanned);
-            ret.getTotal().setUnexistCount(totalCount - totalScanned);
-            ret.getTotal().setProgress(
-                    Calculator.percentage(ret.getTotal().getScannedCount(), ret.getTotal().getStudentCount(), 2));
-            if (totalScanned == 0) {
-                ret.getTotal().setEstimation("-");
-            } else {
-                ret.getTotal().setEstimation(totalEstimation + "h");
-            }
+        }
+        ret.setTotal(new SubjectScanProgressVo());
+        ret.getTotal().setStudentCount(studentService.getCountByExam(examId));
+        ret.getTotal().setScannedCount(studentService.getCountByExamAndScanStatus(examId, ScanStatus.SCANNED));
+        ret.getTotal().setUnexistCount(ret.getTotal().getStudentCount() - ret.getTotal().getScannedCount());
+        ret.getTotal().setProgress(
+                Calculator.percentage(ret.getTotal().getScannedCount(), ret.getTotal().getStudentCount(), 2));
+        if (ret.getTotal().getStudentCount() == 0) {
+            ret.getTotal().setEstimation("-");
+        } else {
+            double speed = Calculator.divide(endTime - startTime, inTimeScannedCount, 6);
+            double es = Calculator.divide(Calculator.multiply(speed,   ret.getTotal().getUnexistCount()), 3600000, 2);
+            ret.getTotal().setEstimation(es + "h");
         }
         return ret;
     }