Browse Source

护理三基excel题目导入

yangfeng 1 year ago
parent
commit
138011b498

+ 4 - 4
web/src/main/java/com/ynfy/buss/exam/question/service/impl/QuestionServiceImpl.java

@@ -30,7 +30,6 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.multipart.MultipartFile;
 
-import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletResponse;
 import java.io.BufferedInputStream;
 import java.io.IOException;
@@ -628,7 +627,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                 List<Object> objectList = iterator.next();
                 String content = String.valueOf(objectList.get(0));
                 char c = content.charAt(0);
-                if (Character.isDigit(c)) {//字符串以数字开头
+                if (Character.isDigit(c)) {//字符串以数字开头(题目)
                     Question question = new Question();
                     String str = content.substring(content.indexOf(":") + 1, content.lastIndexOf(":")).replace("答案", "").trim();
                     question.setContent(str.startsWith(".") ? str.replace(".", "") : str);
@@ -638,10 +637,11 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                     question.setId(IdUtil.getSnowflake(1, 1).nextIdStr());
                     question.setAnswerList(new ArrayList<>());
                     questionList.add(question);
-                } else if (Character.isLetter(c)) {//字符串以字母开头
-                    QuestionAnswer answer = new QuestionAnswer();
+                } else if (Character.isLetter(c)) {//字符串以字母开头(答案)
                     Question relateQuestion = questionList.get(questionList.size() - 1);
                     List<QuestionAnswer> answerList = relateQuestion.getAnswerList();
+                    QuestionAnswer answer = new QuestionAnswer();
+                    answer.setId(IdUtil.getSnowflake(2, 2).nextIdStr());
                     answer.setQuestionId(relateQuestion.getId());
                     answer.setTag(String.valueOf(c));
                     answer.setContent(content.substring(content.indexOf(".") + 1).trim());

+ 1 - 0
web/src/main/resources/application-dev.yml

@@ -211,6 +211,7 @@ logging:
     org.jeecg.modules.system.mapper: info
     com.ynfy.buss.exam.paper.mapper: debug
     com.ynfy.buss.exam.question.mapper: debug
+    com.ynfy.buss.exam.questionanswer.mapper: debug
     com.ynfy.buss.exam.exam.mapper: debug
     com.ynfy.buss.exam.userexam.mapper: debug
     com.ynfy.buss.exam.userexamresult.mapper: debug