xiatian 8 ماه پیش
والد
کامیت
b929370334

+ 1 - 5
src/main/java/cn/com/qmth/scancentral/controller/admin/AsyncTaskController.java

@@ -34,11 +34,7 @@ public class AsyncTaskController extends BaseController {
         if (vo == null) {
             throw new ParameterException("未找到导出任务");
         }
-        vo.setProgress(Calculator.percentageDouble(vo.getProgressCount(), vo.getTotalCount()));
-        // if (vo.getProgress() == 100 && vo.getProgressCount() !=
-        // vo.getTotalCount()) {
-        // vo.setProgress(99.99);
-        // }
+        vo.setProgress(Calculator.percentageDouble(vo.getProgressCount(), vo.getTotalCount(), 2));
         AsyncProgressVo ret = new AsyncProgressVo();
         ret.setErrMsg(vo.getErrMsg());
         ret.setProgress(vo.getProgress());

+ 21 - 10
src/main/java/cn/com/qmth/scancentral/service/impl/BatchServiceImpl.java

@@ -8,7 +8,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import cn.com.qmth.scancentral.service.*;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang.math.RandomUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -44,7 +43,6 @@ import cn.com.qmth.scancentral.entity.PaperPageEntity;
 import cn.com.qmth.scancentral.entity.ScannerEntity;
 import cn.com.qmth.scancentral.entity.StudentEntity;
 import cn.com.qmth.scancentral.entity.StudentPaperEntity;
-import cn.com.qmth.scancentral.entity.SubjectEntity;
 import cn.com.qmth.scancentral.enums.BatchStatus;
 import cn.com.qmth.scancentral.enums.CheckStatus;
 import cn.com.qmth.scancentral.enums.LockType;
@@ -52,6 +50,19 @@ import cn.com.qmth.scancentral.enums.Role;
 import cn.com.qmth.scancentral.enums.VerifyStatus;
 import cn.com.qmth.scancentral.exception.NotFoundExceptions;
 import cn.com.qmth.scancentral.exception.ParameterExceptions;
+import cn.com.qmth.scancentral.service.AnswerCardService;
+import cn.com.qmth.scancentral.service.AnswerCardSubjectService;
+import cn.com.qmth.scancentral.service.AssignedCheckHistoryService;
+import cn.com.qmth.scancentral.service.BatchPaperService;
+import cn.com.qmth.scancentral.service.BatchService;
+import cn.com.qmth.scancentral.service.ExamRoomService;
+import cn.com.qmth.scancentral.service.ExamService;
+import cn.com.qmth.scancentral.service.FilePropertyService;
+import cn.com.qmth.scancentral.service.FileService;
+import cn.com.qmth.scancentral.service.PaperPageService;
+import cn.com.qmth.scancentral.service.PaperService;
+import cn.com.qmth.scancentral.service.ScannerService;
+import cn.com.qmth.scancentral.service.StudentService;
 import cn.com.qmth.scancentral.support.TaskLock;
 import cn.com.qmth.scancentral.support.TaskLockUtil;
 import cn.com.qmth.scancentral.util.PageUtil;
@@ -118,9 +129,6 @@ public class BatchServiceImpl extends ServiceImpl<BatchDao, BatchEntity> impleme
     @Autowired
     private FilePropertyService filePropertyService;
 
-    @Autowired
-    private SubjectService subjectService;
-
     @Autowired
     private AssignedCheckHistoryService assignedCheckHistoryService;
 
@@ -334,10 +342,13 @@ public class BatchServiceImpl extends ServiceImpl<BatchDao, BatchEntity> impleme
         if (!exam.getAllowUnexistPaper() && domain.getPapers().size() != answerCard.getPaperCount()) {
             throw new ParameterException("卡格式张数不一致");
         }
-//        List<String> paperTypeBarcodeContents  = markSiteService.findPaperTypeBarcodeContentByExamAndSubjectCode(student.getExamId(), student.getSubjectCode());
-//        if (paperTypeBarcodeContents == null || paperTypeBarcodeContents.isEmpty()) {
-//            paperTypeBarcodeContents = exam.getPaperTypeBarcodeContent();
-//        }
+        // List<String> paperTypeBarcodeContents =
+        // markSiteService.findPaperTypeBarcodeContentByExamAndSubjectCode(student.getExamId(),
+        // student.getSubjectCode());
+        // if (paperTypeBarcodeContents == null ||
+        // paperTypeBarcodeContents.isEmpty()) {
+        // paperTypeBarcodeContents = exam.getPaperTypeBarcodeContent();
+        // }
 
         boolean studentAssigned = false;
         List<StudentPaperEntity> studentPaperList = new ArrayList<>();
@@ -357,7 +368,7 @@ public class BatchServiceImpl extends ServiceImpl<BatchDao, BatchEntity> impleme
             paper.setAssigned(answerPaper.getAssigned());
             // 保存paper与page到数据库
             paperService.savePaperAndPages(paper, answerPaper.buildPageList(null));
-                    // 记录paper与batch关联关系
+            // 记录paper与batch关联关系
             batchPaperService.update(batch, paper, student.getId(), paperNumber, false);
             // 创建student与paper的关联关系
             studentPaperList.add(new StudentPaperEntity(student.getId(), paperNumber, paper.getId()));

+ 2 - 13
src/main/java/cn/com/qmth/scancentral/util/Calculator.java

@@ -220,25 +220,14 @@ public class Calculator {
         return percentage(v1.doubleValue(), v2.doubleValue(), len);
     }
 
-    public static String percentage(Integer v1, Integer v2) {
-        if (v1 == null || v2 == null || v2 == 0) {
-            return "-";
-        }
-        return percentage(v1.doubleValue(), v2.doubleValue(), null);
-    }
-
-    public static String percentage(double v1, double v2) {
-        return percentage(v1, v2, null);
-    }
-
-    public static Double percentageDouble(Integer v1, Integer v2) {
+    public static Double percentageDouble(Integer v1, Integer v2, Integer len) {
         if (v1 == null || v2 == null || v2 == 0) {
             return null;
         }
         BigDecimal b1 = BigDecimal.valueOf(v1);
         BigDecimal b2 = BigDecimal.valueOf(v2);
         BigDecimal b3 = BigDecimal.valueOf(100);
-        return b1.multiply(b3).divide(b2, 2, BigDecimal.ROUND_HALF_UP).doubleValue();
+        return b1.multiply(b3).divide(b2, len, BigDecimal.ROUND_HALF_UP).doubleValue();
 
     }
 }