调整导入模板顺序和参数值

master
xiaoCJ 7 months ago
parent 5e73d74399
commit bbd8c85bd0

@ -326,37 +326,54 @@ public class TopicResourceController {
Cell cell12 = row.getCell(12); Cell cell12 = row.getCell(12);
//判断题的BCDE选项和解析可能为空 //判断题的BCDE选项和解析可能为空
if (cell0 == null || cell1 == null || cell2 == null || cell6 == null || cell7 == null || cell9 == null) { if (cell0 == null || cell2 == null || cell3 == null || cell7 == null || cell8 == null || cell10 == null || cell11 == null || cell12 == null) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "必填项不能为空"); return new ResultEntity<>(HttpStatus.BAD_REQUEST, "必填项不能为空");
} }
String content = this.getCellValue(cell0);//题 String type = this.getCellValue(cell0);//题
String a = this.getCellValue(cell1); //选项A String content = this.getCellValue(cell1);//题干
String b = this.getCellValue(cell2);//选项B String a = this.getCellValue(cell2); //选项A
String type = this.getCellValue(cell6);//题型 String b = this.getCellValue(cell3);//选项B
String answer = this.getCellValue(cell7);//答案 String answer = this.getCellValue(cell7);//答案
String score = this.getCellValue(cell9);//分值 String score = this.getCellValue(cell8);//分值
String oneName = this.getCellValue(cell10);//一级目录名称 String oneName = this.getCellValue(cell10);//一级目录名称
String twoName = this.getCellValue(cell11);//二级目录名称 String twoName = this.getCellValue(cell11);//二级目录名称
String threeName = this.getCellValue(cell12);//三级目录名称 String threeName = this.getCellValue(cell12);//三级目录名称
String c = cell3 != null ? this.getCellValue(cell3) : null; String c = cell4 != null ? this.getCellValue(cell4) : null;
String d = cell4 != null ? this.getCellValue(cell4) : null; String d = cell5 != null ? this.getCellValue(cell5) : null;
String e = cell5 != null ? this.getCellValue(cell5) : null; String e = cell6 != null ? this.getCellValue(cell6) : null;
String analyze = cell8 != null ? this.getCellValue(cell8) : null; String analyze = cell9 != null ? this.getCellValue(cell9) : null; //答案解析
SysObjectiveQuestions obj = new SysObjectiveQuestions(); SysObjectiveQuestions obj = new SysObjectiveQuestions();
String topicId = IdUtil.randomUUID(); String topicId = IdUtil.randomUUID();
obj.setObjectiveId(topicId); obj.setObjectiveId(topicId);
obj.setContent(content); obj.setContent(content);
obj.setType(type); obj.setAnswer(answer);
if (type.equals("单选题") || type.equals("单选")) {
obj.setType("0");
}
if (type.equals("多选题") || type.equals("多选")) {
obj.setType("1");
}
if (type.equals("判断题") || type.equals("判断")) {
obj.setType("2");
if (answer.equals("A")) {
obj.setAnswer("对");
}
if (answer.equals("B")) {
obj.setAnswer("错");
}
}
obj.setSource(source); obj.setSource(source);
obj.setQuestionA(a); obj.setQuestionA(a);
obj.setQuestionB(b); obj.setQuestionB(b);
obj.setQuestionC(c); obj.setQuestionC(c);
obj.setQuestionD(d); obj.setQuestionD(d);
obj.setQuestionE(e); obj.setQuestionE(e);
obj.setAnswer(answer);
obj.setAnalysis(analyze); obj.setAnalysis(analyze);
obj.setScore(BigDecimal.valueOf(Integer.parseInt(score))); obj.setScore(BigDecimal.valueOf(Integer.parseInt(score)));
obj.setCreateTime(new Date()); obj.setCreateTime(new Date());
@ -385,7 +402,7 @@ public class TopicResourceController {
String threeId = threeIdMap.get(threeName); String threeId = threeIdMap.get(threeName);
if (threeId == null) { if (threeId == null) {
threeId = sysThreeCatalogMapper.getIdByName(twoName, threeName); threeId = sysThreeCatalogMapper.getIdByName(oneId, twoId, threeName);
if (threeId == null) { if (threeId == null) {
return new ResultEntity<HttpStatus>(HttpStatus.INTERNAL_SERVER_ERROR, "导入关联的章节不存在,请在添加后重新导入"); return new ResultEntity<HttpStatus>(HttpStatus.INTERNAL_SERVER_ERROR, "导入关联的章节不存在,请在添加后重新导入");
} }

@ -7,6 +7,7 @@ import com.sztzjy.resource_center.entity.*;
import com.sztzjy.resource_center.entity.dto.SysObjectiveQuestionsDto; import com.sztzjy.resource_center.entity.dto.SysObjectiveQuestionsDto;
import com.sztzjy.resource_center.mapper.*; import com.sztzjy.resource_center.mapper.*;
import com.sztzjy.resource_center.util.PageUtil; import com.sztzjy.resource_center.util.PageUtil;
import com.sztzjy.resource_center.util.ResultEntity;
import com.sztzjy.resource_center.util.file.IFileUtil; import com.sztzjy.resource_center.util.file.IFileUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -17,6 +18,7 @@ import org.apache.poi.ss.usermodel.*;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -298,60 +300,97 @@ public class ObjectiveApi {
Cell cell10 = row.getCell(10); Cell cell10 = row.getCell(10);
Cell cell11 = row.getCell(11); Cell cell11 = row.getCell(11);
Cell cell12 = row.getCell(12); Cell cell12 = row.getCell(12);
if (cell0 == null) {
return false;
}
String type = this.getCellValue(cell0);//题型
if (type.equals("0") || type.equals("1")) {
if (cell1 == null || cell2 == null) {
return false;
}
}
//判断题的BCDE选项和解析可能为空 //判断题的BCDE选项和解析可能为空
if (cell0 == null || cell1 == null || cell2 == null || cell6 == null || cell7 == null || cell9 == null) { if (cell7 == null || cell8 == null || cell10 == null || cell11 == null || cell12 == null) {
return false; return false;
} }
String content = this.getCellValue(cell0);//题干 String content = this.getCellValue(cell1);//题干
String a = this.getCellValue(cell1); //选项A String a = cell2 != null ? this.getCellValue(cell2) : null; //选项A
String b = this.getCellValue(cell2);//选项B String b = cell3 != null ? this.getCellValue(cell3) : null;//选项B
String type = this.getCellValue(cell6);//题型
String answer = this.getCellValue(cell7);//答案 String answer = this.getCellValue(cell7);//答案
String score = this.getCellValue(cell9);//分值 String score = this.getCellValue(cell8);//分值
String oneName = this.getCellValue(cell10);//一级目录名称 String oneName = this.getCellValue(cell10);//一级目录名称
String twoName = this.getCellValue(cell11);//二级目录名称 String twoName = this.getCellValue(cell11);//二级目录名称
String threeName = this.getCellValue(cell12);//三级目录名称 String threeName = this.getCellValue(cell12);//三级目录名称
String c = cell3 != null ? this.getCellValue(cell3) : null; String c = cell4 != null ? this.getCellValue(cell4) : null;
String d = cell4 != null ? this.getCellValue(cell4) : null; String d = cell5 != null ? this.getCellValue(cell5) : null;
String e = cell5 != null ? this.getCellValue(cell5) : null; String e = cell6 != null ? this.getCellValue(cell6) : null;
String analyze = cell8 != null ? this.getCellValue(cell8) : null; String analyze = cell9 != null ? this.getCellValue(cell9) : null; //答案解析
SysObjectiveQuestions obj = new SysObjectiveQuestions(); SysObjectiveQuestions obj = new SysObjectiveQuestions();
String topicId = IdUtil.randomUUID(); String topicId = IdUtil.randomUUID();
obj.setObjectiveId(topicId); obj.setObjectiveId(topicId);
obj.setContent(content); obj.setContent(content);
obj.setType(type); if (type.equals("单选题") || type.equals("单选")) {
obj.setType("0");
}
if (type.equals("多选题") || type.equals("多选")) {
obj.setType("1");
}
obj.setSource(schoolId); obj.setSource(schoolId);
obj.setQuestionA(a); obj.setQuestionA(a);
obj.setQuestionB(b); obj.setQuestionB(b);
obj.setQuestionC(c); obj.setQuestionC(c);
obj.setQuestionD(d); obj.setQuestionD(d);
obj.setQuestionE(e); obj.setQuestionE(e);
obj.setAnswer(answer); obj.setAnswer(answer);
if (type.equals("判断题") || type.equals("判断")) {
obj.setType("2");
if (answer.equals("A")){
obj.setAnswer("对");
}
if (answer.equals("B")){
obj.setAnswer("错");
}
}
obj.setAnalysis(analyze); obj.setAnalysis(analyze);
obj.setScore(BigDecimal.valueOf(Integer.parseInt(score))); obj.setScore(BigDecimal.valueOf(Integer.parseInt(score)));
obj.setCreateTime(new Date()); obj.setCreateTime(new Date());
obj.setIsDelete(false); obj.setIsDelete(false);
objectiveQuestionList.add(obj); objectiveQuestionList.add(obj);
//判断名称是否被查出来过 //判断名称是否被查出来过
String oneId = oneIdMap.get(oneName); String oneId = oneIdMap.get(oneName);
if (oneId == null) { if (oneId == null) {
oneId = oneCatalogMapper.getIdByName(oneName); oneId = oneCatalogMapper.getIdByName(oneName);
if (oneId == null) {
return false;
}
oneIdMap.put(oneName, oneId); oneIdMap.put(oneName, oneId);
} }
String twoId = twoIdMap.get(twoName); String twoId = twoIdMap.get(twoName);
if (twoId == null) { if (twoId == null) {
twoId = sysTwoCatalogMapper.getIdByName(twoName); twoId = sysTwoCatalogMapper.getIdByName(twoName);
if (twoId == null) {
return false;
}
twoIdMap.put(twoName, twoId); twoIdMap.put(twoName, twoId);
} }
String threeId = threeIdMap.get(threeName); String threeId = threeIdMap.get(threeName);
if (threeId == null) { if (threeId == null) {
threeId = sysThreeCatalogMapper.getIdByName(threeName,twoName); threeId = sysThreeCatalogMapper.getIdByName(oneId, twoId, threeName);
if (threeId == null) {
return false;
}
threeIdMap.put(threeName, threeId); threeIdMap.put(threeName, threeId);
} }

@ -49,7 +49,9 @@ public interface SysThreeCatalogMapper {
List<String> selectNameByCourseID(@Param("oneId") String oneId, List<String> selectNameByCourseID(@Param("oneId") String oneId,
@Param("source") String source); @Param("source") String source);
@Select("select three_id from sys_three_catalog where three_name =#{threeName} and two_name =#{twoName}") @Select("select three_id from sys_three_catalog where three_name =#{threeName} and two_id =#{twoId} and ont_id = #{oneID}")
String getIdByName(@Param("threeName") String threeName, String getIdByName(@Param("oneID") String oneID,
@Param("twoName") String twoName); @Param("twoId") String twoId,
@Param("threeName") String threeName
);
} }
Loading…
Cancel
Save