|
@@ -1061,11 +1061,55 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ private boolean isXueJianQuestionStart(String content,Integer type,List<String> alKeyList) {
|
|
|
+ content = dealTxt(content);
|
|
|
+ if (Validator.isNotEmpty(content)) {
|
|
|
+ if(type==5){
|
|
|
+ if(alKeyList.contains(content)){
|
|
|
+ return true;
|
|
|
+ }else{
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ String[] strArr = content.split("\\.");
|
|
|
+ if(strArr.length>1){
|
|
|
+ if(isNumeric1(strArr[0])){
|
|
|
+ int qIndex = content.indexOf(".");
|
|
|
+ if (qIndex > 0 && qIndex < 5) { //序号支持千位数
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean isNumeric1(String str) {
|
|
|
+ try {
|
|
|
+ Double.parseDouble(str);
|
|
|
+ return true;
|
|
|
+ } catch(Exception e){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private boolean isLineStart(String content) {
|
|
|
if (Validator.isNotEmpty(content)) {
|
|
|
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("多选题题模板")){
|
|
|
+ ||content.startsWith("单选题模板")||content.startsWith("判读题模板")||content.startsWith("问答题模板")||content.startsWith("多选题题模板")||content.startsWith("【参考答案】")||content.startsWith("【老师解析】")){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isXueJianLineStart(String content,Integer type,List<String> alKeyList) {
|
|
|
+ if (Validator.isNotEmpty(content)) {
|
|
|
+ if(isXueJianQuestionStart(content,type,alKeyList)||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("多选题题模板")||content.startsWith("【参考答案】")||content.startsWith("【老师解析】")){
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
@@ -1898,6 +1942,17 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
if(Validator.isEmpty(file)){
|
|
|
throw new CustomException("请选择文件");
|
|
|
}
|
|
|
+ List<String> alKeyList = new ArrayList<>();
|
|
|
+ alKeyList.add("案例(一)");
|
|
|
+ alKeyList.add("案例(二)");
|
|
|
+ alKeyList.add("案例(三)");
|
|
|
+ alKeyList.add("案例(四)");
|
|
|
+ alKeyList.add("案例(五)");
|
|
|
+ alKeyList.add("案例(六)");
|
|
|
+ alKeyList.add("案例(七)");
|
|
|
+ alKeyList.add("案例(八)");
|
|
|
+ alKeyList.add("案例(九)");
|
|
|
+ alKeyList.add("案例(十)");
|
|
|
try {
|
|
|
Long nowTime = DateUtils.getNowTime();
|
|
|
String path = file.getOriginalFilename();
|
|
@@ -1981,14 +2036,15 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ System.out.println(content);
|
|
|
content = dealTxt(content);
|
|
|
- if (content.startsWith("#")||isQuestionStart(content)) {
|
|
|
+ if (content.startsWith("#")||isXueJianQuestionStart(content,type,alKeyList)) {
|
|
|
if(hasQuestion){
|
|
|
index++;
|
|
|
hasQuestion = false;
|
|
|
//插入上一条
|
|
|
QuestionAddBo addBo = new QuestionAddBo();
|
|
|
- qContent = removeNo(qContent);
|
|
|
+ qContent = removeXueJianNo(qContent,type);
|
|
|
if (Validator.isEmpty(qContent)) {
|
|
|
hasError = true;
|
|
|
errorLog += "第" + index + "条题目内容错误\n";
|
|
@@ -2040,7 +2096,6 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
hasError = false;
|
|
|
//清空数据
|
|
|
isOption = false;
|
|
|
- type = -1;
|
|
|
qContent = "";
|
|
|
answerQuestion = null;
|
|
|
analysisContent = "";
|
|
@@ -2049,7 +2104,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
hasRightTag= false;
|
|
|
}
|
|
|
}
|
|
|
- if (content.startsWith("正确答案:")){
|
|
|
+ if (content.startsWith("【参考答案】")){
|
|
|
if(!hasRightTag){
|
|
|
hasRightTag = true;
|
|
|
}else{
|
|
@@ -2064,17 +2119,35 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
if(Validator.isEmpty(content)||content.equals("")){
|
|
|
continue;
|
|
|
}
|
|
|
- if (isQuestionStart(content)||(nowPart==0&&!isLineStart(content))) {
|
|
|
+ if (content.startsWith("一、单项选择题")) {
|
|
|
+ System.out.println("我的单选");
|
|
|
+ type = 1;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (content.startsWith("二、多项选择题")) {
|
|
|
+ System.out.println("我的多项选择题");
|
|
|
+ type = 2;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (content.startsWith("三、实务操作和案例分析题")) {
|
|
|
+ System.out.println("实务操作和案例分析题");
|
|
|
+ type = 5;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (isXueJianQuestionStart(content,type,alKeyList)||(nowPart==0&&!isXueJianLineStart(content,type,alKeyList))) {
|
|
|
hasQuestion = true;
|
|
|
if(nowPart!=0){
|
|
|
qContent = "";
|
|
|
}
|
|
|
nowPart = 0;
|
|
|
//新题开头
|
|
|
- qContent = qContent + content +"<br />";
|
|
|
+ if(!alKeyList.contains(content)){
|
|
|
+ qContent = qContent + content +"<br />";
|
|
|
+ }
|
|
|
+ continue;
|
|
|
}
|
|
|
//第一个选项
|
|
|
- if(content.startsWith("А.")||content.startsWith("A.")||(nowPart==1&&!isLineStart(content))) {
|
|
|
+ if(content.startsWith("А.")||content.startsWith("A.")||(nowPart==1&&!isXueJianLineStart(content,type,alKeyList))) {
|
|
|
hasQuestion = true;
|
|
|
if(nowPart!=1){
|
|
|
strContent = "";
|
|
@@ -2094,9 +2167,10 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("A.", "").replace("А.", ""));
|
|
|
}
|
|
|
+ continue;
|
|
|
}
|
|
|
//第二个选项
|
|
|
- if (content.startsWith("B.")||(nowPart==2&&!isLineStart(content))) {
|
|
|
+ if (content.startsWith("B.")||(nowPart==2&&!isXueJianLineStart(content,type,alKeyList))) {
|
|
|
if (optionsList.size()<1) {
|
|
|
errorLog += "第" + index + "条题目选项A错误\n";
|
|
|
continue;
|
|
@@ -2118,9 +2192,10 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("B.", ""));
|
|
|
}
|
|
|
+ continue;
|
|
|
}
|
|
|
//第三个选项
|
|
|
- if (content.startsWith("C.")||(nowPart==3&&!isLineStart(content))) {
|
|
|
+ if (content.startsWith("C.")||(nowPart==3&&!isXueJianLineStart(content,type,alKeyList))) {
|
|
|
if(nowPart!=3){
|
|
|
strContent = "";
|
|
|
}
|
|
@@ -2138,9 +2213,10 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("C.", ""));
|
|
|
}
|
|
|
+ continue;
|
|
|
}
|
|
|
//第四个选项
|
|
|
- if (content.startsWith("D.")||(nowPart==4&&!isLineStart(content))) {
|
|
|
+ if (content.startsWith("D.")||(nowPart==4&&!isXueJianLineStart(content,type,alKeyList))) {
|
|
|
if(nowPart!=4){
|
|
|
strContent = "";
|
|
|
}
|
|
@@ -2158,9 +2234,10 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("D.", ""));
|
|
|
}
|
|
|
+ continue;
|
|
|
}
|
|
|
//第五个选项
|
|
|
- if (content.startsWith("E.")||(nowPart==5&&!isLineStart(content))) {
|
|
|
+ if (content.startsWith("E.")||(nowPart==5&&!isXueJianLineStart(content,type,alKeyList))) {
|
|
|
if(nowPart!=5){
|
|
|
strContent = "";
|
|
|
}
|
|
@@ -2178,9 +2255,10 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("E.", ""));
|
|
|
}
|
|
|
+ continue;
|
|
|
}
|
|
|
//第六个选项
|
|
|
- if (content.startsWith("F.")||(nowPart==6&&!isLineStart(content))) {
|
|
|
+ if (content.startsWith("F.")||(nowPart==6&&!isXueJianLineStart(content,type,alKeyList))) {
|
|
|
if(nowPart!=6){
|
|
|
strContent = "";
|
|
|
}
|
|
@@ -2198,9 +2276,10 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("F.", ""));
|
|
|
}
|
|
|
+ continue;
|
|
|
}
|
|
|
//答案和题型
|
|
|
- if (content.startsWith("正确答案:")||(nowPart==7&&!isLineStart(content))) {
|
|
|
+ if (content.startsWith("【参考答案】")||(nowPart==7&&!isXueJianLineStart(content,type,alKeyList))) {
|
|
|
if(nowPart!=7){
|
|
|
strContent = "";
|
|
|
}
|
|
@@ -2210,39 +2289,41 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
if(Validator.isNotEmpty(answerQuestion)){
|
|
|
answerQuestion = answerQuestion + "<br />" + content ;
|
|
|
}else{
|
|
|
- answerQuestion = content.replace("正确答案:", "");
|
|
|
+ answerQuestion = content.replace("【参考答案】", "");
|
|
|
}
|
|
|
if (isOption) {
|
|
|
//选择题
|
|
|
answerQuestion = dealImportAnswer(answerQuestion);
|
|
|
if (answerQuestion.length() > 1) {
|
|
|
- type = 2; //多选
|
|
|
+ // type = 2; //多选
|
|
|
} else {
|
|
|
- type = 1; //单选
|
|
|
+ // type = 1; //单选
|
|
|
}
|
|
|
} else {
|
|
|
if ("正确".equals(answerQuestion)) {
|
|
|
answerQuestion = "1";
|
|
|
- type = 3; //判断
|
|
|
+ // type = 3; //判断
|
|
|
} else if ("错误".equals(answerQuestion)) {
|
|
|
answerQuestion = "0";
|
|
|
- type = 3;
|
|
|
+ // type = 3;
|
|
|
} else {
|
|
|
analysisContent = answerQuestion; //简答题把正确答案填充到解析文本
|
|
|
- type = 5; //简答题
|
|
|
+ // type = 5; //简答题
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ continue;
|
|
|
}
|
|
|
- else if (content.startsWith("解题思路")||(nowPart==8&&!isLineStart(content))) {
|
|
|
+ else if (content.startsWith("解题思路")||(nowPart==8&&!isXueJianLineStart(content,type,alKeyList))) {
|
|
|
nowPart = 8;
|
|
|
analysisContent = analysisContent + content +"<br />";
|
|
|
+ continue;
|
|
|
}
|
|
|
- else if (content.startsWith("考查考点")||(nowPart==9&&!isLineStart(content))) {
|
|
|
+ else if (content.startsWith("考查考点")||(nowPart==9&&!isXueJianLineStart(content,type,alKeyList))) {
|
|
|
nowPart = 9;
|
|
|
analysisContent = analysisContent + content +"<br />";
|
|
|
+ continue;
|
|
|
}
|
|
|
- else if (content.startsWith("老师解答")||(nowPart==10&&!isLineStart(content))) {
|
|
|
+ else if (content.startsWith("【老师解析】")||(nowPart==10&&!isXueJianLineStart(content,type,alKeyList))) {
|
|
|
nowPart = 10;
|
|
|
analysisContent = analysisContent + content +"<br />";
|
|
|
}
|
|
@@ -2898,6 +2979,18 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
return format.format(d1 / d2);
|
|
|
}
|
|
|
|
|
|
+ private String removeXueJianNo(String txt,Integer type) {
|
|
|
+ if(type!=5){
|
|
|
+ int intIndex = txt.indexOf(".");
|
|
|
+ if (intIndex != -1) {
|
|
|
+ txt = txt.substring(intIndex + 1);
|
|
|
+ }
|
|
|
+ return txt;
|
|
|
+ }else{
|
|
|
+ return txt;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
|
|
|
private String removeNo(String txt) {
|