benbo 1 年之前
父节点
当前提交
a05a52f84f

+ 4 - 6
src/main/java/cn/com/qmth/am/controller/AdminController.java

@@ -32,8 +32,6 @@ import cn.com.qmth.am.enums.LockType;
 import cn.com.qmth.am.service.QuestionService;
 import cn.com.qmth.am.service.QuestionService;
 import cn.com.qmth.am.service.StudentScoreService;
 import cn.com.qmth.am.service.StudentScoreService;
 import cn.com.qmth.am.service.StudentService;
 import cn.com.qmth.am.service.StudentService;
-import cn.com.qmth.am.task.AiMarkingJob;
-import cn.com.qmth.am.task.BuildImageJob;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 
 
 @RestController
 @RestController
@@ -66,8 +64,8 @@ public class AdminController {
 			}
 			}
 			qsCourse = cset.size();
 			qsCourse = cset.size();
 		}
 		}
-		sb.append("ocr任务是否开启:" + (BuildImageJob.enable ? "是" : "否") + "\r\n");
-		sb.append("评分任务是否开启:" + (AiMarkingJob.enable ? "是" : "否") + "\r\n");
+		sb.append("ocr任务是否开启:" + (sysProperty.getOcrTaskEnable() ? "是" : "否") + "\r\n");
+		sb.append("评分任务是否开启:" + (sysProperty.getMarkingTaskEnable() ? "是" : "否") + "\r\n");
 		sb.append("试卷科目总数:" + qsCourse + "\r\n");
 		sb.append("试卷科目总数:" + qsCourse + "\r\n");
 		sb.append("试卷小题总数:" + qstotal + "\r\n");
 		sb.append("试卷小题总数:" + qstotal + "\r\n");
 		int total = studentService.countBy(examId, null);
 		int total = studentService.countBy(examId, null);
@@ -179,14 +177,14 @@ public class AdminController {
 	@ApiOperation(value = "机评开关")
 	@ApiOperation(value = "机评开关")
 	@RequestMapping(value = "marking/status", method = RequestMethod.GET)
 	@RequestMapping(value = "marking/status", method = RequestMethod.GET)
 	public String markingStatus(@RequestParam Boolean enable) {
 	public String markingStatus(@RequestParam Boolean enable) {
-		AiMarkingJob.enable = enable;
+		sysProperty.setMarkingTaskEnable(enable);
 		return "设置成功:" + enable;
 		return "设置成功:" + enable;
 	}
 	}
 	
 	
 	@ApiOperation(value = "ocr开关")
 	@ApiOperation(value = "ocr开关")
 	@RequestMapping(value = "ocr/status", method = RequestMethod.GET)
 	@RequestMapping(value = "ocr/status", method = RequestMethod.GET)
 	public String ocrStatus(@RequestParam Boolean enable) {
 	public String ocrStatus(@RequestParam Boolean enable) {
-		BuildImageJob.enable = enable;
+		sysProperty.setOcrTaskEnable(enable);
 		return "设置成功:" + enable;
 		return "设置成功:" + enable;
 	}
 	}
 
 

+ 2 - 0
src/main/java/cn/com/qmth/am/service/impl/StudentScoreServiceImpl.java

@@ -507,6 +507,8 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
 			String ret = ocrDispose(dto, org);
 			String ret = ocrDispose(dto, org);
 			if (ret != null) {
 			if (ret != null) {
 				updateAnswer(dto.getStudentScoreId(), ret);
 				updateAnswer(dto.getStudentScoreId(), ret);
+			}else{
+				ocrErr(dto, "ocr失败");
 			}
 			}
 		} catch (Exception e) {
 		} catch (Exception e) {
 			ocrErr(dto, e.getMessage());
 			ocrErr(dto, e.getMessage());

+ 2 - 6
src/main/java/cn/com/qmth/am/task/AiMarkingJob.java

@@ -16,7 +16,6 @@ import cn.com.qmth.am.service.StudentScoreService;
 
 
 @Service
 @Service
 public class AiMarkingJob {
 public class AiMarkingJob {
-	public static Boolean enable=null;
 	@Autowired
 	@Autowired
 	private StudentScoreService studentScoreService;
 	private StudentScoreService studentScoreService;
 	@Autowired
 	@Autowired
@@ -26,10 +25,7 @@ public class AiMarkingJob {
 
 
 	@Scheduled(fixedDelay = 5 * 1000, initialDelay = 20 * 1000)
 	@Scheduled(fixedDelay = 5 * 1000, initialDelay = 20 * 1000)
 	public void doJob() {
 	public void doJob() {
-		if(enable==null) {
-			enable=sysProperty.getMarkingTaskEnable();
-		}
-		if(!enable) {
+		if(!sysProperty.getMarkingTaskEnable()) {
 			return;
 			return;
 		}
 		}
 		List<StudentScoreEntity> scores = studentScoreService.findAllToAiMarking();
 		List<StudentScoreEntity> scores = studentScoreService.findAllToAiMarking();
@@ -51,7 +47,7 @@ public class AiMarkingJob {
 
 
 	private void dispose(List<StudentScoreEntity> scores) {
 	private void dispose(List<StudentScoreEntity> scores) {
 		for (StudentScoreEntity score : scores) {
 		for (StudentScoreEntity score : scores) {
-			if(!enable) {
+			if(!sysProperty.getMarkingTaskEnable()) {
 				return;
 				return;
 			}
 			}
 			studentScoreService.aiMarking(score);
 			studentScoreService.aiMarking(score);

+ 2 - 6
src/main/java/cn/com/qmth/am/task/BuildImageJob.java

@@ -26,7 +26,6 @@ import cn.com.qmth.am.utils.SpringContextHolder;
 
 
 @Service
 @Service
 public class BuildImageJob {
 public class BuildImageJob {
-	public static Boolean enable=null;
 	@Autowired
 	@Autowired
 	private StudentService studentService;
 	private StudentService studentService;
 	@Autowired
 	@Autowired
@@ -57,10 +56,7 @@ public class BuildImageJob {
 
 
 	@Scheduled(fixedDelay = 5 * 1000, initialDelay = 20 * 1000)
 	@Scheduled(fixedDelay = 5 * 1000, initialDelay = 20 * 1000)
 	public void doJob() {
 	public void doJob() {
-		if(enable==null) {
-			enable=sysProperty.getOcrTaskEnable();
-		}
-		if(!enable) {
+		if(!sysProperty.getOcrTaskEnable()) {
 			return;
 			return;
 		}
 		}
 		List<StudentEntity> stus = studentService.findToDispose();
 		List<StudentEntity> stus = studentService.findToDispose();
@@ -96,7 +92,7 @@ public class BuildImageJob {
 			tem.put(q.getId(),q);
 			tem.put(q.getId(),q);
 		}
 		}
 		for (StudentEntity stu : stus) {
 		for (StudentEntity stu : stus) {
-			if(!enable) {
+			if(!sysProperty.getOcrTaskEnable()) {
 				return;
 				return;
 			}
 			}
 			String key=stu.getExamId()+"-"+stu.getSubjectCode();
 			String key=stu.getExamId()+"-"+stu.getSubjectCode();