|
@@ -18,6 +18,8 @@ import java.util.regex.Pattern;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.io.FileUtils;
|
|
import org.apache.commons.io.FileUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -42,10 +44,12 @@ import cn.com.qmth.am.service.QuestionService;
|
|
@Service
|
|
@Service
|
|
public class QuestionServiceImpl extends ServiceImpl<QuestionDao, QuestionEntity> implements QuestionService {
|
|
public class QuestionServiceImpl extends ServiceImpl<QuestionDao, QuestionEntity> implements QuestionService {
|
|
|
|
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(QuestionService.class);
|
|
|
|
+
|
|
private Pattern scoreRex = Pattern.compile("\\[\\[([0-9][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", "科目代码", "科目名称", "大题号", "小题号", "满分", "试题内容",
|
|
|
|
- "试题答案", "作答坐标" };
|
|
|
|
|
|
+ private static final String[] EXCEL_HEADER = new String[] { "考试ID", "科目代码", "科目名称", "题目名称", "大题号", "小题号", "满分",
|
|
|
|
+ "试题内容", "试题答案", "作答坐标" };
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private SysProperty sysProperty;
|
|
private SysProperty sysProperty;
|
|
@@ -75,6 +79,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionDao, QuestionEntity
|
|
errMsg = "未找到文件:" + file.getAbsolutePath();
|
|
errMsg = "未找到文件:" + file.getAbsolutePath();
|
|
} else {
|
|
} else {
|
|
errMsg = "系统错误:" + e.getMessage();
|
|
errMsg = "系统错误:" + e.getMessage();
|
|
|
|
+ log.error("系统错误", e);
|
|
}
|
|
}
|
|
ret = new ImportResult(errMsg);
|
|
ret = new ImportResult(errMsg);
|
|
} finally {
|
|
} finally {
|
|
@@ -204,7 +209,15 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionDao, QuestionEntity
|
|
}
|
|
}
|
|
imp.setSubjectName(subjectName);
|
|
imp.setSubjectName(subjectName);
|
|
|
|
|
|
- String mainNum = trimAndNullIfBlank(line.get(EXCEL_HEADER[3]));
|
|
|
|
|
|
+ String title = trimAndNullIfBlank(line.get(EXCEL_HEADER[3]));
|
|
|
|
+ if (StringUtils.isBlank(title)) {
|
|
|
|
+ msg.append(" 题目名称不能为空");
|
|
|
|
+ } else if (title.length() > 100) {
|
|
|
|
+ msg.append(" 题目名称不能超过100个字符");
|
|
|
|
+ }
|
|
|
|
+ imp.setTitle(title);
|
|
|
|
+
|
|
|
|
+ String mainNum = trimAndNullIfBlank(line.get(EXCEL_HEADER[4]));
|
|
if (StringUtils.isBlank(mainNum)) {
|
|
if (StringUtils.isBlank(mainNum)) {
|
|
msg.append(" 大题号不能为空");
|
|
msg.append(" 大题号不能为空");
|
|
} else if (mainNum.length() > 10) {
|
|
} else if (mainNum.length() > 10) {
|
|
@@ -221,7 +234,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionDao, QuestionEntity
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- String subNum = trimAndNullIfBlank(line.get(EXCEL_HEADER[4]));
|
|
|
|
|
|
+ String subNum = trimAndNullIfBlank(line.get(EXCEL_HEADER[5]));
|
|
if (StringUtils.isBlank(subNum)) {
|
|
if (StringUtils.isBlank(subNum)) {
|
|
msg.append(" 小题号不能为空");
|
|
msg.append(" 小题号不能为空");
|
|
} else if (subNum.length() > 10) {
|
|
} else if (subNum.length() > 10) {
|
|
@@ -229,7 +242,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionDao, QuestionEntity
|
|
}
|
|
}
|
|
imp.setSubNumber(subNum);
|
|
imp.setSubNumber(subNum);
|
|
|
|
|
|
- String fullScore = trimAndNullIfBlank(line.get(EXCEL_HEADER[5]));
|
|
|
|
|
|
+ String fullScore = trimAndNullIfBlank(line.get(EXCEL_HEADER[6]));
|
|
if (StringUtils.isBlank(fullScore)) {
|
|
if (StringUtils.isBlank(fullScore)) {
|
|
msg.append(" 满分不能为空");
|
|
msg.append(" 满分不能为空");
|
|
} else if (fullScore.length() > 10) {
|
|
} else if (fullScore.length() > 10) {
|
|
@@ -246,19 +259,19 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionDao, QuestionEntity
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- String content = trimAndNullIfBlank(line.get(EXCEL_HEADER[6]));
|
|
|
|
|
|
+ String content = trimAndNullIfBlank(line.get(EXCEL_HEADER[7]));
|
|
if (StringUtils.isBlank(content)) {
|
|
if (StringUtils.isBlank(content)) {
|
|
msg.append(" 试题内容不能为空");
|
|
msg.append(" 试题内容不能为空");
|
|
}
|
|
}
|
|
imp.setContent(content);
|
|
imp.setContent(content);
|
|
|
|
|
|
- String answer = trimAndNullIfBlank(line.get(EXCEL_HEADER[7]));
|
|
|
|
|
|
+ String answer = trimAndNullIfBlank(line.get(EXCEL_HEADER[8]));
|
|
// if (StringUtils.isBlank(answer)) {
|
|
// if (StringUtils.isBlank(answer)) {
|
|
// msg.append(" 试题答案不能为空");
|
|
// msg.append(" 试题答案不能为空");
|
|
// }
|
|
// }
|
|
imp.setAnswer(getStandardAnswer(answer));
|
|
imp.setAnswer(getStandardAnswer(answer));
|
|
|
|
|
|
- String imageSlice = trimAndNullIfBlank(line.get(EXCEL_HEADER[8]));
|
|
|
|
|
|
+ String imageSlice = trimAndNullIfBlank(line.get(EXCEL_HEADER[9]));
|
|
if (StringUtils.isBlank(imageSlice)) {
|
|
if (StringUtils.isBlank(imageSlice)) {
|
|
msg.append(" 作答坐标不能为空");
|
|
msg.append(" 作答坐标不能为空");
|
|
} else if (imageSlice.length() > 1000) {
|
|
} else if (imageSlice.length() > 1000) {
|