1
0
Эх сурвалжийг харах

增加统分时显示进度

ting.yin 6 жил өмнө
parent
commit
3cdae8d4e7

+ 5 - 0
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/dao/ExamDao.java

@@ -30,4 +30,9 @@ public interface ExamDao extends PagingAndSortingRepository<Exam, Integer>, JpaS
     @Modifying
     @Modifying
     @Query("update Exam e set e.sliceConfig=?2 where e.id=?1")
     @Query("update Exam e set e.sliceConfig=?2 where e.id=?1")
     public void updateSliceConfig(Integer examId, String configString);
     public void updateSliceConfig(Integer examId, String configString);
+
+    @Modifying
+    @Query("update Exam e set e.process=?2 where e.id=?1")
+    public void updateProcess(Integer id, Double process);
+
 }
 }

+ 15 - 0
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/model/Exam.java

@@ -95,6 +95,12 @@ public class Exam implements Serializable {
     @Column(name = "slice_config", nullable = true)
     @Column(name = "slice_config", nullable = true)
     private String sliceConfig;
     private String sliceConfig;
 
 
+    /**
+     * 统分进度
+     */
+    @Column(name = "process")
+    private Double process;
+
     public Integer getId() {
     public Integer getId() {
         return id;
         return id;
     }
     }
@@ -218,4 +224,13 @@ public class Exam implements Serializable {
     public List<PictureConfigItem> getSliceConfigList() {
     public List<PictureConfigItem> getSliceConfigList() {
         return PictureConfigItem.parse(sliceConfig);
         return PictureConfigItem.parse(sliceConfig);
     }
     }
+
+    public Double getProcess() {
+        return process;
+    }
+
+    public void setProcess(Double process) {
+        this.process = process;
+    }
+
 }
 }

+ 4 - 1
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/service/ExamService.java

@@ -25,7 +25,10 @@ public interface ExamService {
 
 
     List<Exam> findByCreatorAndStatus(Integer id, ExamStatus status);
     List<Exam> findByCreatorAndStatus(Integer id, ExamStatus status);
 
 
-	List<Exam> findBySchoolId(Integer schoolId);
+    List<Exam> findBySchoolId(Integer schoolId);
 
 
     void updateSliceConfig(Integer examId, List<PictureConfigItem> asList);
     void updateSliceConfig(Integer examId, List<PictureConfigItem> asList);
+
+    void updateProcess(Integer examId, Double process);
+
 }
 }

+ 6 - 0
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/service/impl/ExamServiceImpl.java

@@ -146,4 +146,10 @@ public class ExamServiceImpl extends BaseQueryService<Exam> implements ExamServi
                 configList != null ? StringUtils.join(configList, PictureConfigItem.DB_ITEM_JOINER) : "");
                 configList != null ? StringUtils.join(configList, PictureConfigItem.DB_ITEM_JOINER) : "");
     }
     }
 
 
+    @Transactional
+    @Override
+    public void updateProcess(Integer id, Double process) {
+        examDao.updateProcess(id, process);
+    }
+
 }
 }

+ 20 - 3
stmms-web/src/main/java/cn/com/qmth/stmms/admin/exam/ScoreController.java

@@ -1,11 +1,14 @@
 package cn.com.qmth.stmms.admin.exam;
 package cn.com.qmth.stmms.admin.exam;
 
 
+import java.text.DecimalFormat;
 import java.util.LinkedList;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.List;
 
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
 
 
+import net.sf.json.JSONObject;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
@@ -51,7 +54,6 @@ import cn.com.qmth.stmms.common.utils.ExportExcel;
 import cn.com.qmth.stmms.common.utils.ExportExcel2;
 import cn.com.qmth.stmms.common.utils.ExportExcel2;
 import cn.com.qmth.stmms.common.utils.PictureUrlBuilder;
 import cn.com.qmth.stmms.common.utils.PictureUrlBuilder;
 import cn.com.qmth.stmms.common.utils.RequestUtils;
 import cn.com.qmth.stmms.common.utils.RequestUtils;
-import net.sf.json.JSONObject;
 
 
 @Controller
 @Controller
 @RequestMapping("/admin/exam/score")
 @RequestMapping("/admin/exam/score")
@@ -133,8 +135,7 @@ public class ScoreController extends BaseParameterController {
                 buildSheetUrl(student);
                 buildSheetUrl(student);
                 buildPackageUrl(student);
                 buildPackageUrl(student);
                 buildAnswerUrl(student);
                 buildAnswerUrl(student);
-                student.setSubjectRemark(
-                        subjectService.find(student.getExamId(), student.getSubjectCode()).getRemark());
+                student.setSubjectRemark(subjectService.find(student.getExamId(), student.getSubjectCode()).getRemark());
                 student.setMarked(isMarked(student));
                 student.setMarked(isMarked(student));
                 Marker marker = markerService.findByStudentId(student.getId());
                 Marker marker = markerService.findByStudentId(student.getId());
                 if (marker != null) {
                 if (marker != null) {
@@ -288,6 +289,22 @@ public class ScoreController extends BaseParameterController {
         }
         }
     }
     }
 
 
+    @RequestMapping("/getProcess")
+    @ResponseBody
+    public JSONObject getProcess(HttpServletRequest request) {
+        int examId = getSessionExamId(request);
+        Exam exam = examService.findById(examId);
+        JSONObject obj = new JSONObject();
+        obj.accumulate("running", exam.getStatus().equals(ExamStatus.CALCULATING)?true:false);
+        if (exam.getProcess() != null) {
+            DecimalFormat format = new DecimalFormat("##.##");
+            obj.accumulate("process", format.format(exam.getProcess() * 100));
+        } else {
+            obj.accumulate("process", 0);
+        }
+        return obj;
+    }
+
     private List<ScoreItem> buildScoreList(ExamStudent student) {
     private List<ScoreItem> buildScoreList(ExamStudent student) {
         List<ScoreItem> scoreList = new LinkedList<ScoreItem>();
         List<ScoreItem> scoreList = new LinkedList<ScoreItem>();
 
 

+ 6 - 0
stmms-web/src/main/java/cn/com/qmth/stmms/admin/thread/ScoreCalculateThread.java

@@ -83,11 +83,17 @@ public class ScoreCalculateThread implements Runnable {
         try {
         try {
             int pageNumber = 1;
             int pageNumber = 1;
             int pageSize = 1000;
             int pageSize = 1000;
+            long totalCount = studentService.countByExamId(exam.getId());
             List<ExamStudent> list = studentService.findByExamIdAndUpload(exam.getId(), true, pageNumber, pageSize);
             List<ExamStudent> list = studentService.findByExamIdAndUpload(exam.getId(), true, pageNumber, pageSize);
             while (list != null && list.size() > 0) {
             while (list != null && list.size() > 0) {
                 for (ExamStudent student : list) {
                 for (ExamStudent student : list) {
                     calculate(student);
                     calculate(student);
                 }
                 }
+                double process = pageSize * pageNumber * 1.0 / totalCount;
+                if (process >= 100) {
+                    process = 99;
+                }
+                examService.updateProcess(exam.getId(), process);
                 pageNumber++;
                 pageNumber++;
                 list = studentService.findByExamIdAndUpload(exam.getId(), true, pageNumber, pageSize);
                 list = studentService.findByExamIdAndUpload(exam.getId(), true, pageNumber, pageSize);
             }
             }

+ 22 - 1
stmms-web/src/main/webapp/WEB-INF/views/modules/exam/scoreList.jsp

@@ -97,7 +97,7 @@
                     <a href="${ctx}/admin/exam/score/calculate" class="btn">重新统分</a>
                     <a href="${ctx}/admin/exam/score/calculate" class="btn">重新统分</a>
                 </c:if>
                 </c:if>
                 <c:if test="${exam.status.value==1}">
                 <c:if test="${exam.status.value==1}">
-                    <a href="javascript:void(0)" class="btn" disabled>${exam.status.name}</a>
+                    <a href="javascript:void(0)" class="btn" disabled id="exam-process">${exam.status.name}</a>
                 </c:if>
                 </c:if>
             </div>
             </div>
 		</div>
 		</div>
@@ -274,6 +274,11 @@ $(document).ready(function() {
         });
         });
         }
         }
     });
     });
+
+	var examStatus = "${exam.status.value}";
+	if(examStatus==1){
+	    var timer = setInterval(function(){getExamProcess(timer)},5000);
+	}
 });
 });
 function page(n,s){
 function page(n,s){
 	$("#pageNumber").val(n);
 	$("#pageNumber").val(n);
@@ -311,6 +316,22 @@ function goExportScore(){
 	$("#searchForm").attr('action','${ctx}/admin/exam/score/exportScore');
 	$("#searchForm").attr('action','${ctx}/admin/exam/score/exportScore');
 	$("#searchForm").submit();
 	$("#searchForm").submit();
 }
 }
+function getExamProcess(timer){
+	var examStatus = "${exam.status.value}";
+	if(examStatus==1){
+		$.post('${ctx}/admin/exam/score/getProcess', function(result){
+			if(result.running){
+				$("#exam-process").html("正在统分: "+result.process+"%");
+			}else{
+				window.clearInterval(timer);
+				window.location.reload();
+			}
+	    });
+	}else{
+		window.clearInterval(timer);
+		window.location.reload();
+	}
+}
 </script>	
 </script>	
 </body>
 </body>
 </html>
 </html>