xiatian 11 månader sedan
förälder
incheckning
19c2125bc2

+ 1 - 1
pom.xml

@@ -3,7 +3,7 @@
 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>
-	<groupId>cn.com.qmth.scancloud</groupId>
+	<groupId>cn.com.qmth.am</groupId>
 	<artifactId>ai-marking</artifactId>
 	<version>1.0.0</version>
 	<packaging>jar</packaging>

+ 29 - 21
src/main/java/cn/com/qmth/am/service/impl/QuestionServiceImpl.java

@@ -41,7 +41,7 @@ import cn.com.qmth.am.service.QuestionService;
 
 @Service
 public class QuestionServiceImpl extends ServiceImpl<QuestionDao, QuestionEntity> implements QuestionService {
-	private Pattern scoreRex = Pattern.compile("\\[\\[([0-9](.[0-9]+){0,1})分\\]\\]");
+	private Pattern scoreRex = Pattern.compile("\\[\\[([0-9][0-9]*(.[0-9]+){0,1})分\\]\\]");
 	private static final String[] EXCEL_HEADER = new String[] { "考试ID", "科目代码", "科目名称", "大题号", "小题号", "满分", "试题内容",
 			"试题答案", "作答坐标" };
 	@Autowired
@@ -351,30 +351,38 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionDao, QuestionEntity
 		if (StringUtils.isBlank(s)) {
 			return null;
 		}
-		try {
-			List<StandardAnswer> list = new ArrayList<>();
-			Matcher matcher = scoreRex.matcher(s);
-			int start=0;
-			String score = null;
-			while (matcher.find()) {
-				if(start!=0) {
-					StandardAnswer a=new StandardAnswer();
-					list.add(a);
-					a.setScore(score);
-					a.setContent(s.substring(start,matcher.start()));
-				}
-				score=matcher.group(1);
-				start=matcher.end();
-	        }
-			if(start<s.length()) {
+		List<StandardAnswer> list = new ArrayList<>();
+		Matcher matcher = scoreRex.matcher(s);
+		int start=0;
+		Double score = null;
+		while (matcher.find()) {
+			if(start!=0) {
 				StandardAnswer a=new StandardAnswer();
 				list.add(a);
 				a.setScore(score);
-				a.setContent(s.substring(start,s.length()));
+				a.setContent(s.substring(start,matcher.start()));
 			}
-			return list;
-		} catch (Exception e) {
-			return null;
+			try {
+				score=Double.valueOf(matcher.group(1));
+			} catch (NumberFormatException e) {
+				throw new StatusException("分数格式有误");
+			}
+			checkScore(score);
+			start=matcher.end();
+        }
+		if(start<s.length()) {
+			StandardAnswer a=new StandardAnswer();
+			list.add(a);
+			a.setScore(score);
+			checkScore(score);
+			a.setContent(s.substring(start,s.length()));
+		}
+		return list;
+	}
+	
+	private void checkScore(Double score) {
+		if(score==null) {
+			throw new StatusException("分数不能为空");
 		}
 	}
 

+ 5 - 4
src/main/java/cn/com/qmth/am/service/impl/StudentScoreServiceImpl.java

@@ -495,8 +495,6 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
 
 	public static void main(String[] args) {
 //		Pattern pattern = Pattern.compile("\\[\\[([0-9](.[0-9]+){0,1})分\\]\\]");
-//		String code = "2022301052070";
-//		String s = "https://file.markingcloud.com/" + getMarkingCloudPath(1342, getSuffix(code), code, 1, "jpg");
 //		String d="[[1.1分]]中国共产党是中国特色社会主义事业的坚强领导核心。\n"
 //				+ "[[1.2分]]中国共产党的领导地位是在历史奋斗中形成的。\n"
 //				+ "[[1.3分]]中国共产党领导是人民当家作主的可靠保障。\n"
@@ -516,7 +514,9 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
 //			System.out.println(score+d.substring(start,d.length()));
 //		}
 //		String[] items = d.split("\\[\\[[0-9](.[0-9]+){0,1}分\\]\\]");
-//		System.out.println(s);
+		String code = "2020301021117";
+		String s = "https://file.markingcloud.com/" + getMarkingCloudPath(1342, getSuffix(code), code, 1, "jpg");
+		System.out.println(s);
 	}
 
 	@Override
@@ -612,7 +612,8 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
 			req.setStandardAnswer(q.getAnswer());
 			req.setStudentAnswer(score.getAnswer());
 			req.setSubjectName(q.getSubjectName());
-			req.setIntervalScore("0.5");
+			req.setTotalScore(q.getFullScore());
+			req.setIntervalScore(0.5);
 			AutoScoreResult ret = aiMarkingDispose(dto, org, req);
 			if (ret != null) {
 				updateScore(score.getId(), ret.getTotalScore(), null);