he2802 3 жил өмнө
parent
commit
f5ea8a4150

+ 13 - 20
zhongzheng-common/src/main/java/com/zhongzheng/common/utils/ToolsUtils.java

@@ -49,44 +49,37 @@ public class ToolsUtils {
     public static String getEncoding(String str) {
         String encode = "GB2312";
         try {
-            if (isEncoding(str, encode)) { // 判断是不是GB2312
-                return encode;
+            if (str.equals(new String(str.getBytes(encode), encode))) {
+                String s = encode;
+                return s;
             }
         } catch (Exception exception) {
         }
         encode = "ISO-8859-1";
         try {
-            if (isEncoding(str, encode)) { // 判断是不是ISO-8859-1
-                return encode;
+            if (str.equals(new String(str.getBytes(encode), encode))) {
+                String s1 = encode;
+                return s1;
             }
         } catch (Exception exception1) {
         }
         encode = "UTF-8";
         try {
-            if (isEncoding(str, encode)) { // 判断是不是UTF-8
-                return encode;
+            if (str.equals(new String(str.getBytes(encode), encode))) {
+                String s2 = encode;
+                return s2;
             }
         } catch (Exception exception2) {
         }
         encode = "GBK";
         try {
-            if (isEncoding(str, encode)) { // 判断是不是GBK
-                return encode;
+            if (str.equals(new String(str.getBytes(encode), encode))) {
+                String s3 = encode;
+                return s3;
             }
         } catch (Exception exception3) {
         }
-        return ""; // 如果都不是,说明输入的内容不属于常见的编码格式。
-    }
-
-    public static boolean isEncoding(String str, String encode) {
-        try {
-            if (str.equals(new String(str.getBytes(), encode))) {
-                return true;
-            }
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-        }
-        return false;
+        return "";
     }
 
     /**

+ 16 - 15
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java

@@ -852,7 +852,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
 
     private boolean isLineStart(String content) {
         if (Validator.isNotEmpty(content)) {
-            if(isQuestionStart(content)||content.startsWith("A.")||content.startsWith("B.")||content.startsWith("C.")||content.startsWith("D.")||content.startsWith("E.")
+            if(isQuestionStart(content)||content.startsWith("А.")||content.startsWith("A.")||content.startsWith("B.")||content.startsWith("C.")||content.startsWith("D.")||content.startsWith("E.")
                     ||content.startsWith("F.")||content.startsWith("正确答案")||content.startsWith("解题思路")||content.startsWith("考查考点")||content.startsWith("老师解答")
                     ||content.startsWith("单选题模板")||content.startsWith("判读题模板")||content.startsWith("问答题模板")||content.startsWith("多选题题模板")){
                 return true;
@@ -1050,15 +1050,8 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                         //新题开头
                         qContent = qContent +   content +"<br />";
                     }
-                    //第一个选项
-                    System.out.println(content);
-                    System.out.println(ToolsUtils.getEncoding(content));
-                   /* System.out.println("FFF");
-                    System.out.println(content.startsWith("A"));
-                    System.out.println(ToolsUtils.getEncoding("A"));
-                    System.out.println(content.startsWith("А"));
-                    System.out.println(ToolsUtils.getEncoding("А"));*/
-                    if(content.startsWith("A.")||(nowPart==1&&!isLineStart(content))) {
+                    //第一个选项(包含西里尔字母А)
+                    if(content.startsWith("А.")||content.startsWith("A.")||(nowPart==1&&!isLineStart(content))) {
                         if (Validator.isEmpty(qContent)) {
                             errorLog += "第" + index + "条题目内容错误\n";
                             continue;
@@ -1073,17 +1066,21 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                         if(optionsList.size()<1){
                             bo1 = new QuestionChildAddBo();
                             bo1.setOptionsId(1L);
-                            bo1.setContent(strContent.replace("A.", ""));
+                            bo1.setContent(strContent.replace("A.", "").replace("А.", ""));
                             bo1.setImgUrl(imgUrl);
                             optionsList.add(bo1);
                         }else{
                             bo1 = optionsList.get(0);
                             bo1.setImgUrl(imgUrl);
-                            bo1.setContent(strContent.replace("A.", ""));
+                            bo1.setContent(strContent.replace("A.", "").replace("А.", ""));
                         }
                     }
                     //第二个选项
                     if (content.startsWith("B.")||(nowPart==2&&!isLineStart(content))) {
+                        if (optionsList.size()<1) {
+                            errorLog += "第" + index + "条题目选项A错误\n";
+                            continue;
+                        }
                         if(nowPart!=2){
                             strContent = "";
                         }
@@ -1430,7 +1427,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                         qContent = qContent +   content +"<br />";
                     }
                     //第一个选项
-                    if(content.startsWith("A.")||(nowPart==1&&!isLineStart(content))) {
+                    if(content.startsWith("А.")||content.startsWith("A.")||(nowPart==1&&!isLineStart(content))) {
                         if (Validator.isEmpty(qContent)) {
                             errorLog += "第" + index + "条题目内容错误\n";
                             continue;
@@ -1446,16 +1443,20 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                             bo1 = new QuestionChildAddBo();
                             bo1.setOptionsId(1L);
                             bo1.setImgUrl(imgUrl);
-                            bo1.setContent(strContent.replace("A.", ""));
+                            bo1.setContent(strContent.replace("A.", "").replace("А.", ""));
                             optionsList.add(bo1);
                         }else{
                             bo1 = optionsList.get(0);
                             bo1.setImgUrl(imgUrl);
-                            bo1.setContent(strContent.replace("A.", ""));
+                            bo1.setContent(strContent.replace("A.", "").replace("А.", ""));
                         }
                     }
                     //第二个选项
                     if (content.startsWith("B.")||(nowPart==2&&!isLineStart(content))) {
+                        if (optionsList.size()<1) {
+                            errorLog += "第" + index + "条题目选项A错误\n";
+                            continue;
+                        }
                         if(nowPart!=2){
                             strContent = "";
                         }

+ 1 - 0
zhongzheng-system/src/main/resources/mapper/modules/bank/QuestionModuleChapterMapper.xml

@@ -35,6 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 LEFT JOIN question_chapter qc ON mc.chapter_exam_id = qc.chapter_exam_id
         WHERE
             mc.module_exam_id = #{moduleExamId}
+        ORDER BY mc.sort
 
     </select>