|
|
|
@ -378,7 +378,7 @@ public class ResourcesQuestionService extends CoreBaseService<ResourcesQuestion>
|
|
|
|
|
//获取最大列数
|
|
|
|
|
int colNum = firstRow.getPhysicalNumberOfCells();
|
|
|
|
|
|
|
|
|
|
String[] columns = {"归属课程", "理论课程分类", "归属章节", "题型", "分值", "题干", "选项A", "选项B", "选项C", "选项D", "选项E", "答案", "解析"};
|
|
|
|
|
String[] columns = {"归属课程", "归属章节", "题型", "分值", "题干", "选项A", "选项B", "选项C", "选项D", "选项E", "答案", "解析"};
|
|
|
|
|
|
|
|
|
|
Map<String, Integer> map = new HashMap<>();//获取需要的表头的列
|
|
|
|
|
|
|
|
|
@ -400,7 +400,7 @@ public class ResourcesQuestionService extends CoreBaseService<ResourcesQuestion>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (flag != columns.length) {
|
|
|
|
|
return JsonResult.failMessage("导入失败,表格表头应包含 \"归属课程\",\"理论课程分类\",\"归属章节\",\"题型\",\"分值\",\"题干\",\"选项A\",\"选项B\",\"选项C\",\"选项D\",\"选项E\",\"答案\",\"解析\"");
|
|
|
|
|
return JsonResult.failMessage("导入失败,表格表头应包含 \"归属课程\",\"归属章节\",\"题型\",\"分值\",\"题干\",\"选项A\",\"选项B\",\"选项C\",\"选项D\",\"选项E\",\"答案\",\"解析\"");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
@ -426,26 +426,26 @@ public class ResourcesQuestionService extends CoreBaseService<ResourcesQuestion>
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
String courseInfoName = getCellFormatValue(row.getCell(map.get(columns[0])));
|
|
|
|
|
String courseLabelName = getCellFormatValue(row.getCell(map.get(columns[1])));
|
|
|
|
|
String chapterName = getCellFormatValue(row.getCell(map.get(columns[2])));
|
|
|
|
|
String questionType = getCellFormatValue(row.getCell(map.get(columns[3])));
|
|
|
|
|
// String courseLabelName = getCellFormatValue(row.getCell(map.get(columns[1])));
|
|
|
|
|
String chapterName = getCellFormatValue(row.getCell(map.get(columns[1])));
|
|
|
|
|
String questionType = getCellFormatValue(row.getCell(map.get(columns[2])));
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(questionType)) {
|
|
|
|
|
questionType = questionType.replace("题", "").trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String questionScore = getCellFormatValue(row.getCell(map.get(columns[4])));
|
|
|
|
|
String questionStem = getCellFormatValue(row.getCell(map.get(columns[5])));
|
|
|
|
|
String questionScore = getCellFormatValue(row.getCell(map.get(columns[3])));
|
|
|
|
|
String questionStem = getCellFormatValue(row.getCell(map.get(columns[4])));
|
|
|
|
|
|
|
|
|
|
String questionOptionA = getCellFormatValue(row.getCell(map.get(columns[6])));
|
|
|
|
|
String questionOptionB = getCellFormatValue(row.getCell(map.get(columns[7])));
|
|
|
|
|
String questionOptionC = getCellFormatValue(row.getCell(map.get(columns[8])));
|
|
|
|
|
String questionOptionD = getCellFormatValue(row.getCell(map.get(columns[9])));
|
|
|
|
|
String questionOptionE = getCellFormatValue(row.getCell(map.get(columns[10])));
|
|
|
|
|
String questionOptionA = getCellFormatValue(row.getCell(map.get(columns[5])));
|
|
|
|
|
String questionOptionB = getCellFormatValue(row.getCell(map.get(columns[6])));
|
|
|
|
|
String questionOptionC = getCellFormatValue(row.getCell(map.get(columns[7])));
|
|
|
|
|
String questionOptionD = getCellFormatValue(row.getCell(map.get(columns[8])));
|
|
|
|
|
String questionOptionE = getCellFormatValue(row.getCell(map.get(columns[9])));
|
|
|
|
|
|
|
|
|
|
String questionAnswer = getCellFormatValue(row.getCell(map.get(columns[11])));
|
|
|
|
|
String questionAnswer = getCellFormatValue(row.getCell(map.get(columns[10])));
|
|
|
|
|
questionAnswer = answerFormat(questionType, questionAnswer);//格式化
|
|
|
|
|
String questionAnalysis = getCellFormatValue(row.getCell(map.get(columns[12])));
|
|
|
|
|
String questionAnalysis = getCellFormatValue(row.getCell(map.get(columns[11])));
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(questionScore)) {
|
|
|
|
|
questionScore = "1";//默认一分
|
|
|
|
@ -460,7 +460,7 @@ public class ResourcesQuestionService extends CoreBaseService<ResourcesQuestion>
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[0]) + 1) + "列,第" + (i + 1) + "行课程为空"});
|
|
|
|
|
continue;
|
|
|
|
|
} else if (StringUtils.isBlank(chapterName)) {
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[2]) + 1) + "列,第" + (i + 1) + "行归属章节为空"});
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[1]) + 1) + "列,第" + (i + 1) + "行归属章节为空"});
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//else if (courseInfoName.split("__ID").length != 2) {
|
|
|
|
@ -468,25 +468,25 @@ public class ResourcesQuestionService extends CoreBaseService<ResourcesQuestion>
|
|
|
|
|
// continue;
|
|
|
|
|
//}
|
|
|
|
|
else if (StringUtils.isBlank(questionType)) {
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[3]) + 1) + "列,第" + (i + 1) + "行题型为空"});
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[2]) + 1) + "列,第" + (i + 1) + "行题型为空"});
|
|
|
|
|
continue;
|
|
|
|
|
} else if (!ToolUtils.findInSet("单选,多选,判断", questionType)) {
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[3]) + 1) + "列,第" + (i + 1) + "行题型异常"});
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[2]) + 1) + "列,第" + (i + 1) + "行题型异常"});
|
|
|
|
|
continue;
|
|
|
|
|
} else if (StringUtils.isBlank(questionScore)) {
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[4]) + 1) + "列,第" + (i + 1) + "行分值为空"});
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[3]) + 1) + "列,第" + (i + 1) + "行分值为空"});
|
|
|
|
|
continue;
|
|
|
|
|
} else if (StringUtils.isBlank(questionStem)) {
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[5]) + 1) + "列,第" + (i + 1) + "行题干为空"});
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[4]) + 1) + "列,第" + (i + 1) + "行题干为空"});
|
|
|
|
|
continue;
|
|
|
|
|
} else if (StringUtils.isBlank(questionAnswer)) {
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[11]) + 1) + "列,第" + (i + 1) + "行答案为空"});
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[10]) + 1) + "列,第" + (i + 1) + "行答案为空"});
|
|
|
|
|
continue;
|
|
|
|
|
} else if (StringUtils.isNotBlank(m)) {
|
|
|
|
|
errMsg.add(new String[]{"第" + (i + 1) + "行" + m});
|
|
|
|
|
continue;
|
|
|
|
|
} else if (!NumberUtil.isNumber(questionScore)) {
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[4]) + 1) + "列,第" + (i + 1) + "行分值数值格式错误"});
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[3]) + 1) + "列,第" + (i + 1) + "行分值数值格式错误"});
|
|
|
|
|
continue;
|
|
|
|
|
} else {
|
|
|
|
|
questionAnswer = questionAnswer.trim();
|
|
|
|
@ -496,9 +496,9 @@ public class ResourcesQuestionService extends CoreBaseService<ResourcesQuestion>
|
|
|
|
|
questionScore = questionScore.trim();
|
|
|
|
|
questionStem = questionStem.trim();
|
|
|
|
|
questionAnswer = questionAnswer.trim();
|
|
|
|
|
if (!StringUtils.isBlank(courseLabelName)) {
|
|
|
|
|
courseLabelName = courseLabelName.trim();
|
|
|
|
|
}
|
|
|
|
|
// if (!StringUtils.isBlank(courseLabelName)) {
|
|
|
|
|
// courseLabelName = courseLabelName.trim();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//去掉最后一个逗号
|
|
|
|
@ -527,40 +527,42 @@ public class ResourcesQuestionService extends CoreBaseService<ResourcesQuestion>
|
|
|
|
|
|
|
|
|
|
//没有课程,添加课程
|
|
|
|
|
if (CollectionUtils.isEmpty(courseInfoList)) {
|
|
|
|
|
if (StringUtils.isBlank(courseLabelName)) {
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[1]) + 1) + "列,第" + (i + 1) + "行此课程不存在,并且理论课程分类栏目为空"});
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
CourseLabel courseLabel = new CourseLabel();
|
|
|
|
|
courseLabel.setCourseLabelType(THEORY.getType());
|
|
|
|
|
courseLabel.setCourseLabelName(courseLabelName.trim());
|
|
|
|
|
courseLabel.setCourseLabelStatus(1);
|
|
|
|
|
CourseLabel once = courseLabelService.getOnce(courseLabel);
|
|
|
|
|
if (once == null) {
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[1]) + 1) + "列,第" + (i + 1) + "行此课程不存在,并且理论课程分类栏目的数据在数据库中检索为空"});
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[0]) + 1) + "列,第" + (i + 1) + "行此课程不存在"});
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
CourseInfoQuery paras = new CourseInfoQuery();
|
|
|
|
|
paras.setCourseInfoType(1);
|
|
|
|
|
paras.setCourseLabelId(once.getCourseLabelId());
|
|
|
|
|
paras.setCourseInfoStatus(2);
|
|
|
|
|
paras.setCourseInfoName(courseInfoName);
|
|
|
|
|
paras.setOrgId(coreUser.getOrgId());
|
|
|
|
|
paras.setUserId(coreUser.getId());
|
|
|
|
|
paras.setAddTime(now);
|
|
|
|
|
paras.setCourseInfoType(1);
|
|
|
|
|
paras.setCourseInfoContent(courseInfoName);
|
|
|
|
|
|
|
|
|
|
CourseInfo addCourseInfo = courseInfoService.add(paras);
|
|
|
|
|
|
|
|
|
|
if (addCourseInfo == null || addCourseInfo.getCourseInfoId() == null) {
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[0]) + 1) + "列,第" + (i + 1) + "行添加课程到系统失败"});
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//移除缓存
|
|
|
|
|
courseInfoService.flushCache(addCourseInfo.getCourseInfoId());
|
|
|
|
|
corePlatformService.clearDictCache();
|
|
|
|
|
courseInfoCache.put(courseInfoName, addCourseInfo);
|
|
|
|
|
// if (StringUtils.isBlank(courseLabelName)) {
|
|
|
|
|
// errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[1]) + 1) + "列,第" + (i + 1) + "行此课程不存在,并且理论课程分类栏目为空"});
|
|
|
|
|
// continue;
|
|
|
|
|
// }
|
|
|
|
|
// CourseLabel courseLabel = new CourseLabel();
|
|
|
|
|
// courseLabel.setCourseLabelType(THEORY.getType());
|
|
|
|
|
// courseLabel.setCourseLabelName(courseLabelName.trim());
|
|
|
|
|
// courseLabel.setCourseLabelStatus(1);
|
|
|
|
|
// CourseLabel once = courseLabelService.getOnce(courseLabel);
|
|
|
|
|
// if (once == null) {
|
|
|
|
|
// errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[1]) + 1) + "列,第" + (i + 1) + "行此课程不存在,并且理论课程分类栏目的数据在数据库中检索为空"});
|
|
|
|
|
// continue;
|
|
|
|
|
// }
|
|
|
|
|
// CourseInfoQuery paras = new CourseInfoQuery();
|
|
|
|
|
// paras.setCourseInfoType(1);
|
|
|
|
|
// paras.setCourseLabelId(once.getCourseLabelId());
|
|
|
|
|
// paras.setCourseInfoStatus(2);
|
|
|
|
|
// paras.setCourseInfoName(courseInfoName);
|
|
|
|
|
// paras.setOrgId(coreUser.getOrgId());
|
|
|
|
|
// paras.setUserId(coreUser.getId());
|
|
|
|
|
// paras.setAddTime(now);
|
|
|
|
|
// paras.setCourseInfoType(1);
|
|
|
|
|
// paras.setCourseInfoContent(courseInfoName);
|
|
|
|
|
//
|
|
|
|
|
// CourseInfo addCourseInfo = courseInfoService.add(paras);
|
|
|
|
|
//
|
|
|
|
|
// if (addCourseInfo == null || addCourseInfo.getCourseInfoId() == null) {
|
|
|
|
|
// errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[0]) + 1) + "列,第" + (i + 1) + "行添加课程到系统失败"});
|
|
|
|
|
// continue;
|
|
|
|
|
// }
|
|
|
|
|
// //移除缓存
|
|
|
|
|
// courseInfoService.flushCache(addCourseInfo.getCourseInfoId());
|
|
|
|
|
// corePlatformService.clearDictCache();
|
|
|
|
|
// courseInfoCache.put(courseInfoName, addCourseInfo);
|
|
|
|
|
} else {
|
|
|
|
|
courseInfoCache.put(courseInfoName, courseInfoList.get(0));
|
|
|
|
|
List<CourseInfo> chapterList = new ArrayList<>();
|
|
|
|
@ -616,7 +618,7 @@ public class ResourcesQuestionService extends CoreBaseService<ResourcesQuestion>
|
|
|
|
|
CourseInfo addChild = courseInfoService.add(child);
|
|
|
|
|
|
|
|
|
|
if (addChild == null || addChild.getCourseInfoId() == null) {
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[2]) + 1) + "列,第" + (i + 1) + "行添加章节到系统失败"});
|
|
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[1]) + 1) + "列,第" + (i + 1) + "行添加章节到系统失败"});
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//移除缓存
|
|
|
|
|