|
@@ -32,8 +32,10 @@ import com.zhongzheng.modules.bank.domain.*;
|
|
|
import com.zhongzheng.modules.bank.mapper.QuestionMapper;
|
|
|
import com.zhongzheng.modules.bank.service.*;
|
|
|
import com.zhongzheng.modules.bank.vo.*;
|
|
|
+import com.zhongzheng.modules.course.bo.CourseBusinessQueryBo;
|
|
|
import com.zhongzheng.modules.course.domain.*;
|
|
|
import com.zhongzheng.modules.course.service.*;
|
|
|
+import com.zhongzheng.modules.course.vo.CourseBusinessVo;
|
|
|
import com.zhongzheng.modules.exam.bo.ExamKnowledgeAddBo;
|
|
|
import com.zhongzheng.modules.exam.bo.ExamKnowledgeBusinessAddBo;
|
|
|
import com.zhongzheng.modules.exam.domain.ExamKnowledge;
|
|
@@ -73,8 +75,7 @@ import org.w3c.dom.NamedNodeMap;
|
|
|
import org.w3c.dom.Node;
|
|
|
import org.w3c.dom.NodeList;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStream;
|
|
|
+import java.io.*;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.NumberFormat;
|
|
|
import java.util.*;
|
|
@@ -1129,9 +1130,21 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
if (content.startsWith("二、多项选择题")) {
|
|
|
return true;
|
|
|
}
|
|
|
+ if (content.indexOf("多项选择题")>-1) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
if (content.startsWith("三、实务操作和案例分析题")) {
|
|
|
return true;
|
|
|
}
|
|
|
+ if (content.indexOf("案例分析题")>-1) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (content.indexOf("章标题:")>-1) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (content.startsWith("参考答案")) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
if (Validator.isNotEmpty(content)) {
|
|
|
if(type==5){
|
|
|
if(alKeyList.contains(content)){
|
|
@@ -1195,6 +1208,16 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ private boolean isNumStart(String content) {
|
|
|
+ for(int i=1;i<40;i++){
|
|
|
+ String num = i+".";
|
|
|
+ if(content.startsWith(num)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
private boolean isNotOptionStart(String content) {
|
|
|
if (Validator.isNotEmpty(content)) {
|
|
|
if(isQuestionStart(content)||content.startsWith("正确答案")||content.startsWith("解题思路")||content.startsWith("考查考点")||content.startsWith("老师解答")
|
|
@@ -2436,6 +2459,592 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Map<String, Object> importErJianWordQuestionList(MultipartFile file, Long eduId, Long projectId, Long businessId, Long subjectId) {
|
|
|
+ Map<String,Object> result = new HashMap<>();
|
|
|
+ List<QuestionAddBo> list = new ArrayList<>();
|
|
|
+ String errorLog = ""; //错误提示
|
|
|
+ String preExamName = "";
|
|
|
+ String examName = "";
|
|
|
+ String importNo = ServletUtils.getEncoded("IMPORT");
|
|
|
+ Long sort = 1L;
|
|
|
+ if(Validator.isEmpty(file)){
|
|
|
+ throw new CustomException("请选择文件");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ Long nowTime = DateUtils.getNowTime();
|
|
|
+ String path = file.getOriginalFilename();
|
|
|
+ if (path.endsWith(".doc")) {
|
|
|
+ throw new CustomException("不支持doc格式");
|
|
|
+ } else if (path.endsWith("docx")) {
|
|
|
+ CourseBusinessQueryBo queryBo = new CourseBusinessQueryBo();
|
|
|
+ queryBo.setEducationName("考前培训");
|
|
|
+ queryBo.setProjectName("建造师");
|
|
|
+ queryBo.setBusinessName("二级");
|
|
|
+ CourseBusinessVo businessVo = iCourseBusinessService.queryFullId(queryBo);
|
|
|
+ String subjectName = path.substring(1,3);
|
|
|
+ if(subjectName.equals("水利")){
|
|
|
+ subjectName = "水利水电";
|
|
|
+ }
|
|
|
+ CourseSubject subject = iCourseSubjectService.getOne(new LambdaQueryWrapper<CourseSubject>()
|
|
|
+ .eq(CourseSubject::getSubjectName,subjectName).eq(CourseSubject::getStatus,1).last("limit 1"));
|
|
|
+ String importCode = ServletUtils.getImportEncoded("TM");
|
|
|
+ String importExamCode = ServletUtils.getEncoded("SJ");
|
|
|
+ InputStream is = file.getInputStream();
|
|
|
+ XWPFDocument doc = new XWPFDocument(is);
|
|
|
+ List<XWPFParagraph> paragraphList = doc.getParagraphs();
|
|
|
+ int type = -1; //题目类型
|
|
|
+ int aType = -1; //答案题目类型
|
|
|
+ boolean isOption = false; //是否判断题
|
|
|
+ List<QuestionChildAddBo> optionsList = new ArrayList<>(); //题目选项
|
|
|
+ String content = ""; //每行正文
|
|
|
+ String qContent = ""; //题目正文
|
|
|
+ String answerQuestion = null; //答案
|
|
|
+ String analysisContent = ""; //解析文本
|
|
|
+ int index = 1; //题目序列号
|
|
|
+ List<QuestionBusinessAddBo> businessList = new ArrayList<>();
|
|
|
+ QuestionBusinessAddBo questionBusinessAddBo = new QuestionBusinessAddBo();
|
|
|
+ questionBusinessAddBo.setEducationTypeId(eduId);
|
|
|
+ questionBusinessAddBo.setProjectId(projectId);
|
|
|
+ questionBusinessAddBo.setBusinessId(businessId);
|
|
|
+ questionBusinessAddBo.setSubjectId(subjectId);
|
|
|
+ businessList.add(questionBusinessAddBo);
|
|
|
+
|
|
|
+ List<QuestionAddBo> list1 = new ArrayList<>(); //单选列表
|
|
|
+ List<QuestionAddBo> list2 = new ArrayList<>(); //多选列表
|
|
|
+ List<QuestionAddBo> list3 = new ArrayList<>(); //简答列表
|
|
|
+ List<QuestionAddBo> list4 = new ArrayList<>(); //判断列表
|
|
|
+ Map<String,QuestionAddBo> allQues = new LinkedHashMap<>();
|
|
|
+ Integer nowPart = -1;//0正文 1选项A 2选项B 3选项C 4选项D 5选项E 6选项F
|
|
|
+ String strContent = "";
|
|
|
+ String imgUrl = "";
|
|
|
+ boolean hasQuestion = false;
|
|
|
+ boolean hasRightTag = false;
|
|
|
+ boolean hasError = false;
|
|
|
+ boolean answerStatus = false;
|
|
|
+ int cIndex = 1;
|
|
|
+ int nIndex = 2;
|
|
|
+ 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("案例(十)");
|
|
|
+ alKeyList.add("案例(十一)");
|
|
|
+ alKeyList.add("案例(十二)");
|
|
|
+ alKeyList.add("案例(十三)");
|
|
|
+ alKeyList.add("案例(十四)");
|
|
|
+ alKeyList.add("案例(十五)");
|
|
|
+ alKeyList.add("案例(十六)");
|
|
|
+ alKeyList.add("案例(十七)");
|
|
|
+ int anLiNum = 0;
|
|
|
+ String indexKey = null;
|
|
|
+ for (XWPFParagraph paragraph : paragraphList) {
|
|
|
+ content = paragraph.getText();
|
|
|
+
|
|
|
+ List<XWPFRun> runs = paragraph.getRuns();
|
|
|
+ imgUrl = null;
|
|
|
+ // System.out.println(content);
|
|
|
+ for (XWPFRun run : runs) {
|
|
|
+ Node node = run.getCTR().getDomNode();
|
|
|
+
|
|
|
+ // drawing 一个绘画的图片
|
|
|
+ Node drawingNode = getChildNode(node, "w:drawing");
|
|
|
+ if (drawingNode == null && content == null) {
|
|
|
+ imgUrl = null;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //上传图片
|
|
|
+ if (Validator.isNotEmpty(drawingNode)) {
|
|
|
+ // 绘画图片的宽和高
|
|
|
+ Node extentNode = getChildNode(drawingNode, "wp:extent");
|
|
|
+ NamedNodeMap extentAttrs = extentNode.getAttributes();
|
|
|
+ int wPx = ToolsUtils.emuToPx(Double.valueOf(extentAttrs.getNamedItem("cx").getNodeValue()));
|
|
|
+ // System.out.println("宽:".concat(extentAttrs.getNamedItem("cx").getNodeValue()).concat("emu"));
|
|
|
+ // System.out.println("高:".concat(extentAttrs.getNamedItem("cy").getNodeValue()).concat("emu"));
|
|
|
+ int HPx = ToolsUtils.emuToPx(Double.valueOf(extentAttrs.getNamedItem("cy").getNodeValue()));
|
|
|
+
|
|
|
+ // 绘画图片具体引用
|
|
|
+ Node blipNode = getChildNode(drawingNode, "a:blip");
|
|
|
+ if(Validator.isNotEmpty(blipNode)){
|
|
|
+ NamedNodeMap blipAttrs = blipNode.getAttributes();
|
|
|
+ String rid = blipAttrs.getNamedItem("r:embed").getNodeValue();
|
|
|
+ // System.out.println("word中图片ID:".concat(rid));
|
|
|
+
|
|
|
+ // 获取图片信息
|
|
|
+ PackagePart part = doc.getPartById(rid);
|
|
|
+
|
|
|
+ String ossPath = null;
|
|
|
+ try {
|
|
|
+ ossPath = ossService.uploadInputStream(part.getInputStream(), 8);
|
|
|
+ System.out.println(part.getSize()+"图片大小");
|
|
|
+ System.out.println(ossPath);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ imgUrl = ossPath + "?x-oss-process=image/resize,w_" + wPx + ",h_" + HPx;
|
|
|
+ if(type==5||nowPart==9){
|
|
|
+ //正文图片
|
|
|
+ if(!answerStatus){
|
|
|
+ qContent = qContent+"<br />" +"<p><img src=\"" + ossHost + "/" + imgUrl + "\"></p>";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(answerStatus){
|
|
|
+ analysisContent=analysisContent+"<br />" +"<p><img src=\"" + ossHost + "/" + imgUrl + "\"></p>";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ content = dealTxt(content);
|
|
|
+ if(content.equals("")){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(content.indexOf("关于《建设工程工程量清单计价规范》")>-1){
|
|
|
+ System.out.println(content);
|
|
|
+ }
|
|
|
+ System.out.println(content);
|
|
|
+ if (content.startsWith("###")||isXueJianQuestionStart(content,type,alKeyList)) {
|
|
|
+
|
|
|
+ if(hasQuestion&&!answerStatus){
|
|
|
+ index++;
|
|
|
+ hasQuestion = false;
|
|
|
+ //插入上一条
|
|
|
+ QuestionAddBo addBo = new QuestionAddBo();
|
|
|
+ qContent = removeXueJianNo(qContent,type);
|
|
|
+ if (Validator.isEmpty(qContent)) {
|
|
|
+ hasError = true;
|
|
|
+ errorLog += "第" + index + "条题目内容错误\n";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ QuestionAddBo bo = new QuestionAddBo();
|
|
|
+ if (type == -1) {
|
|
|
+ hasError = true;
|
|
|
+ errorLog += "第" + index + "条题目选项错误\n";
|
|
|
+ throw new CustomException("第" + index + "条题目选项错误\n");
|
|
|
+
|
|
|
+ }
|
|
|
+ if(!hasError){
|
|
|
+ /* if (Validator.isEmpty(answerQuestion)) {
|
|
|
+ errorLog += "第" + index + "正确答案错误\n";
|
|
|
+ continue;
|
|
|
+
|
|
|
+ }*/
|
|
|
+ if(type==5){
|
|
|
+ answerQuestion = null;
|
|
|
+ }else{
|
|
|
+ if(optionsList.size()<4){
|
|
|
+ throw new CustomException("选项数量错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ bo.setType(type);
|
|
|
+ bo.setStatus(1);
|
|
|
+ bo.setContent(qContent);
|
|
|
+ bo.setAnswerQuestion(answerQuestion);
|
|
|
+ bo.setAnalysisContent(analysisContent);
|
|
|
+ bo.setOptionsList(copyList(optionsList));
|
|
|
+ bo.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ bo.setImportNo(importNo);
|
|
|
+ bo.setPublishStatus(1);
|
|
|
+ bo.setBusinessList(businessList);
|
|
|
+ bo.setCreateTime(nowTime);
|
|
|
+ if(type==1){
|
|
|
+ list1.add(bo);
|
|
|
+ }
|
|
|
+ if(type==2){
|
|
|
+ list2.add(bo);
|
|
|
+ }
|
|
|
+ if(type==3){
|
|
|
+ list4.add(bo);
|
|
|
+ }
|
|
|
+ if(type==5){
|
|
|
+ list3.add(bo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ sort++;
|
|
|
+ hasError = false;
|
|
|
+ //清空数据
|
|
|
+ isOption = false;
|
|
|
+ qContent = "";
|
|
|
+ analysisContent = "";
|
|
|
+ optionsList.clear();
|
|
|
+ nowPart = -1;
|
|
|
+ hasRightTag= false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(nowPart==8){
|
|
|
+ if(isNumStart((content))||content.indexOf("###")>-1||content.indexOf("章标题")>-1||content.indexOf("多项选择题")>-1){
|
|
|
+ if(Validator.isNotEmpty(qContent)&&!qContent.equals("")){
|
|
|
+ String[] sList = qContent.split("【解析】");
|
|
|
+ if (sList.length>1) {
|
|
|
+ String jiexi = sList[1];
|
|
|
+ String[] daList = sList[0].split("\\.");
|
|
|
+ int num = Integer.valueOf(daList[0]);
|
|
|
+ String daan = daList[1];
|
|
|
+ if(num>list1.size()){
|
|
|
+ System.out.println(num);
|
|
|
+ }
|
|
|
+ QuestionAddBo addBo = list1.get(num-1);
|
|
|
+ addBo.setAnalysisContent(jiexi);
|
|
|
+ addBo.setAnswerQuestion(dealImportAnswer(daan));
|
|
|
+ qContent = "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ qContent = qContent + content +"<br />";
|
|
|
+ }
|
|
|
+ if(nowPart==9){
|
|
|
+ if(isNumStart((content))||content.indexOf("###")>-1||content.indexOf("章标题")>-1||content.indexOf("案例分析题")>-1){
|
|
|
+ if(Validator.isNotEmpty(qContent)&&!qContent.equals("")){
|
|
|
+ String[] sList = qContent.split("【解析】");
|
|
|
+ if (sList.length>1) {
|
|
|
+ String jiexi = sList[1];
|
|
|
+ String[] daList = sList[0].split("\\.");
|
|
|
+ int num = Integer.valueOf(daList[0]);
|
|
|
+ String daan = daList[1];
|
|
|
+ if(num>list1.size()){
|
|
|
+ System.out.println(num);
|
|
|
+ }
|
|
|
+ QuestionAddBo addBo = list2.get(num-1);
|
|
|
+ addBo.setAnalysisContent(jiexi);
|
|
|
+ addBo.setAnswerQuestion(dealImportAnswer(daan));
|
|
|
+ qContent = "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ qContent = qContent + content +"<br />";
|
|
|
+ }
|
|
|
+ if(nowPart==10){
|
|
|
+ System.out.println(content);
|
|
|
+ if(alKeyList.contains(content)||content.indexOf("###")>-1||content.indexOf("章标题")>-1){
|
|
|
+ if(Validator.isNotEmpty(qContent)&&!qContent.equals("")){
|
|
|
+ if(anLiNum>=list3.size()){
|
|
|
+ System.out.println(anLiNum);
|
|
|
+ }
|
|
|
+ QuestionAddBo addBo = list3.get(anLiNum);
|
|
|
+ addBo.setAnalysisContent(qContent);
|
|
|
+ qContent = "";
|
|
|
+ anLiNum++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!alKeyList.contains(content)){
|
|
|
+ qContent = qContent + content +"<br />";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /* if (content.indexOf("-Reference")>0){
|
|
|
+ answerStatus = true;
|
|
|
+ }*/
|
|
|
+ // System.out.println(content);
|
|
|
+ if (content.indexOf("章标题:")>-1||content.startsWith("###")){
|
|
|
+ preExamName = examName;
|
|
|
+ if(content.indexOf("章标题:")>-1){
|
|
|
+ examName = content.substring(4);
|
|
|
+ }
|
|
|
+ answerStatus = false;
|
|
|
+ if(list1.size()>0||list2.size()>0||list3.size()>0){
|
|
|
+ List<ExamQuestionAddBo> questionList = new ArrayList<>();
|
|
|
+ list1.addAll(list2);
|
|
|
+ list1.addAll(list3);
|
|
|
+ int i= 1;
|
|
|
+
|
|
|
+
|
|
|
+ List<QuestionBusinessAddBo> businessItemList = new ArrayList<>();
|
|
|
+ QuestionBusinessAddBo businessAddBo = new QuestionBusinessAddBo();
|
|
|
+ businessAddBo.setSubjectId(subject.getId());
|
|
|
+ businessAddBo.setBusinessId(businessVo.getBusinessId().longValue());
|
|
|
+ businessAddBo.setProjectId(businessVo.getProjectId().longValue());
|
|
|
+ businessAddBo.setEducationTypeId(businessVo.getEducationId().longValue());
|
|
|
+ businessItemList.add(businessAddBo);
|
|
|
+
|
|
|
+ for(QuestionAddBo addBo : list1){
|
|
|
+ if(addBo.getType()==1||addBo.getType()==2){
|
|
|
+ if(Validator.isEmpty(addBo.getAnswerQuestion())){
|
|
|
+ throw new CustomException("答案错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ addBo.setCode(importCode);
|
|
|
+
|
|
|
+ addBo.setBusinessList(businessItemList);
|
|
|
+ Long qId = insertByAddBoImportBackId(addBo,0);
|
|
|
+
|
|
|
+ ExamQuestionAddBo questionAddBo = new ExamQuestionAddBo();
|
|
|
+ questionAddBo.setQuestionId(qId);
|
|
|
+ questionAddBo.setSort(i);
|
|
|
+ questionList.add(questionAddBo);
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ ExamAddBo examAddBo = new ExamAddBo();
|
|
|
+ examAddBo.setExamName(preExamName);
|
|
|
+ examAddBo.setCode(importExamCode);
|
|
|
+ examAddBo.setBusinessList(businessItemList);
|
|
|
+ examAddBo.setQuestionList(questionList);
|
|
|
+ examAddBo.setStatus(1);
|
|
|
+ iExamService.insertByAddBo(examAddBo);
|
|
|
+ }
|
|
|
+ list1.clear();
|
|
|
+ list2.clear();
|
|
|
+ list3.clear();
|
|
|
+ list4.clear();
|
|
|
+ type = -100;
|
|
|
+
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(content.indexOf("单项选择题")>-1&&!answerStatus){
|
|
|
+ type = 1;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(content.indexOf("多项选择题")>-1&&!answerStatus){
|
|
|
+ type = 2;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(content.indexOf("案例分析题")>-1&&!answerStatus){
|
|
|
+ type = 5;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //第一个选项
|
|
|
+ if(content.startsWith("А.")||content.startsWith("A.")||(nowPart==1&&!isXueJianLineStart(content,type,alKeyList))) {
|
|
|
+ hasQuestion = true;
|
|
|
+ if(nowPart!=1){
|
|
|
+ strContent = "";
|
|
|
+ }
|
|
|
+ isOption = true; //是选择题
|
|
|
+ nowPart = 1;
|
|
|
+ if(content.indexOf("B.")>-1){
|
|
|
+ //带B
|
|
|
+ int len = content.indexOf("B.");
|
|
|
+ strContent = content.substring(0,len) ;
|
|
|
+ System.out.println("A选项"+strContent);
|
|
|
+ }else{
|
|
|
+ strContent = strContent + content ;
|
|
|
+ }
|
|
|
+ QuestionChildAddBo bo1;
|
|
|
+ if(optionsList.size()<1){
|
|
|
+ bo1 = new QuestionChildAddBo();
|
|
|
+ bo1.setOptionsId(1L);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
+ bo1.setContent(strContent.replace("A.", "").replace("А.", "").trim());
|
|
|
+ optionsList.add(bo1);
|
|
|
+ }else{
|
|
|
+ bo1 = optionsList.get(0);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
+ bo1.setContent(strContent.replace("A.", "").replace("А.", "").trim());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ //第二个选项
|
|
|
+ if (content.indexOf("B.")>0||content.startsWith("B.")||(nowPart==2&&!isXueJianLineStart(content,type,alKeyList))) {
|
|
|
+ if (optionsList.size()<1) {
|
|
|
+ errorLog += "第" + index + "条题目选项A错误\n";
|
|
|
+ throw new CustomException("第" + index + "条题目选项A错误\n");
|
|
|
+ }
|
|
|
+ if(nowPart!=2){
|
|
|
+ strContent = "";
|
|
|
+ }
|
|
|
+ nowPart = 2;
|
|
|
+ if(content.indexOf("B.")>0){
|
|
|
+ //带B
|
|
|
+ int len = content.indexOf("B.");
|
|
|
+ strContent = content.substring(len,content.length()) ;
|
|
|
+ }else{
|
|
|
+ strContent = strContent + content ;
|
|
|
+ }
|
|
|
+
|
|
|
+ QuestionChildAddBo bo1;
|
|
|
+ if(optionsList.size()<2){
|
|
|
+ bo1 = new QuestionChildAddBo();
|
|
|
+ bo1.setOptionsId(2L);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
+ bo1.setContent(strContent.replace("B.", "").trim());
|
|
|
+ optionsList.add(bo1);
|
|
|
+ }else{
|
|
|
+ bo1 = optionsList.get(1);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
+ bo1.setContent(strContent.replace("B.", "").trim());
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //第三个选项
|
|
|
+ if (content.startsWith("C.")||(nowPart==3&&!isXueJianLineStart(content,type,alKeyList))) {
|
|
|
+ if(nowPart!=3){
|
|
|
+ strContent = "";
|
|
|
+ }
|
|
|
+ nowPart = 3;
|
|
|
+ if(content.indexOf("D.")>0){
|
|
|
+ //带B
|
|
|
+ int len = content.indexOf("D.");
|
|
|
+ strContent = content.substring(0,len) ;
|
|
|
+ System.out.println("C选项"+strContent);
|
|
|
+ }else{
|
|
|
+ strContent = strContent + content ;
|
|
|
+ }
|
|
|
+ QuestionChildAddBo bo1;
|
|
|
+ if(optionsList.size()<3){
|
|
|
+ bo1 = new QuestionChildAddBo();
|
|
|
+ bo1.setOptionsId(3L);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
+ bo1.setContent(strContent.replace("C.", "").trim());
|
|
|
+ optionsList.add(bo1);
|
|
|
+ }else{
|
|
|
+ bo1 = optionsList.get(2);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
+ bo1.setContent(strContent.replace("C.", "").trim());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //第四个选项
|
|
|
+ if (content.indexOf("D.")>-1||content.startsWith("D.")||(nowPart==4&&!isXueJianLineStart(content,type,alKeyList))) {
|
|
|
+ if(nowPart!=4){
|
|
|
+ strContent = "";
|
|
|
+ }
|
|
|
+ nowPart = 4;
|
|
|
+ if(content.indexOf("D.")>0){
|
|
|
+ //带B
|
|
|
+ int len = content.indexOf("D.");
|
|
|
+ strContent = content.substring(len,content.length()) ;
|
|
|
+ System.out.println("D选项"+strContent);
|
|
|
+ }else{
|
|
|
+ strContent = strContent + content ;
|
|
|
+ }
|
|
|
+ QuestionChildAddBo bo1;
|
|
|
+ if(optionsList.size()<4){
|
|
|
+ bo1 = new QuestionChildAddBo();
|
|
|
+ bo1.setOptionsId(4L);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
+ bo1.setContent(strContent.replace("D.", "").trim());
|
|
|
+ optionsList.add(bo1);
|
|
|
+ }else{
|
|
|
+ bo1 = optionsList.get(3);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
+ bo1.setContent(strContent.replace("D.", "").trim());
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //第五个选项
|
|
|
+ if (content.startsWith("E.")||(nowPart==5&&!isXueJianLineStart(content,type,alKeyList))) {
|
|
|
+ if(nowPart!=5){
|
|
|
+ strContent = "";
|
|
|
+ }
|
|
|
+ nowPart = 5;
|
|
|
+ if(content.indexOf("F.")>0){
|
|
|
+ //带B
|
|
|
+ int len = content.indexOf("F.");
|
|
|
+ strContent = content.substring(0,len) ;
|
|
|
+ System.out.println("E选项"+strContent);
|
|
|
+ }else{
|
|
|
+ strContent = strContent + content ;
|
|
|
+ }
|
|
|
+ QuestionChildAddBo bo1;
|
|
|
+ if(optionsList.size()<5){
|
|
|
+ bo1 = new QuestionChildAddBo();
|
|
|
+ bo1.setOptionsId(5L);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
+ bo1.setContent(strContent.replace("E.", "").trim());
|
|
|
+ optionsList.add(bo1);
|
|
|
+ }else{
|
|
|
+ bo1 = optionsList.get(4);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
+ bo1.setContent(strContent.replace("E.", "").trim());
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //第六个选项
|
|
|
+ if (content.indexOf("F.")>0||content.startsWith("F.")||(nowPart==6&&!isXueJianLineStart(content,type,alKeyList))) {
|
|
|
+ if(nowPart!=6){
|
|
|
+ strContent = "";
|
|
|
+ }
|
|
|
+ nowPart = 6;
|
|
|
+ if(content.indexOf("F.")>0){
|
|
|
+ //带B
|
|
|
+ int len = content.indexOf("F.");
|
|
|
+ strContent = content.substring(len,content.length()) ;
|
|
|
+ System.out.println("F选项"+strContent);
|
|
|
+ }else{
|
|
|
+ strContent = strContent + content ;
|
|
|
+ }
|
|
|
+ QuestionChildAddBo bo1;
|
|
|
+ if(optionsList.size()<6){
|
|
|
+ bo1 = new QuestionChildAddBo();
|
|
|
+ bo1.setOptionsId(6L);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
+ bo1.setContent(strContent.replace("F.", "").trim());
|
|
|
+ optionsList.add(bo1);
|
|
|
+ }else{
|
|
|
+ bo1 = optionsList.get(5);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
+ bo1.setContent(strContent.replace("F.", "").trim());
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //答案和题型
|
|
|
+ if (content.indexOf("参考答案")>-1) {
|
|
|
+ answerStatus = true;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(answerStatus&&content.indexOf("单项选择题")>0){
|
|
|
+ nowPart = 8;
|
|
|
+ qContent = "";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(answerStatus&&content.indexOf("多项选择题")>0){
|
|
|
+ nowPart = 9;
|
|
|
+ qContent = "";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(answerStatus&&content.indexOf("案例分析题")>0){
|
|
|
+ nowPart = 10;
|
|
|
+ qContent = "";
|
|
|
+ anLiNum=0;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isXueJianQuestionStart(content,type,alKeyList)||(nowPart==0&&!isXueJianLineStart(content,type,alKeyList))) {
|
|
|
+ if(!answerStatus){
|
|
|
+ hasQuestion = true;
|
|
|
+ if(nowPart!=0){
|
|
|
+ qContent = "";
|
|
|
+ }
|
|
|
+ nowPart = 0;
|
|
|
+ //新题开头
|
|
|
+ if(!alKeyList.contains(content)){
|
|
|
+ qContent = qContent + content +"<br />";
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //遍历正文
|
|
|
+ if(true){
|
|
|
+ System.out.println(list1);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+ throw new CustomException("请导入word文件!");
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ System.out.println("此文件不是word文件!" + e.getMessage() + e.toString() + e.getLocalizedMessage());
|
|
|
+ }
|
|
|
+ result.put("list",list);
|
|
|
+ result.put("errorLog",errorLog);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public Map<String, Object> importJJWordQuestionList(MultipartFile file, Long eduId, Long projectId, Long businessId, Long subjectId) {
|
|
|
Map<String,Object> result = new HashMap<>();
|
|
@@ -3079,7 +3688,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
public String insertByAddBoImport(QuestionAddBo bo, Integer no) {
|
|
|
String errorLog = null;
|
|
|
Question add = BeanUtil.toBean(bo, Question.class);
|
|
|
- add.setCode(ServletUtils.getImportEncoded("TM") + no);
|
|
|
+ if(Validator.isEmpty(bo.getCode())){
|
|
|
+ add.setCode(ServletUtils.getImportEncoded("TM") + no);
|
|
|
+ }
|
|
|
if (bo.getOptionsList() != null && bo.getOptionsList().size() > 0) {
|
|
|
add.setJsonStr(JSON.toJSONString(bo.getOptionsList()));
|
|
|
}
|
|
@@ -3107,7 +3718,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
@Override
|
|
|
public Long insertByAddBoImportBackId(QuestionAddBo bo, Integer no) {
|
|
|
Question add = BeanUtil.toBean(bo, Question.class);
|
|
|
- add.setCode(ServletUtils.getImportEncoded("TM") + no);
|
|
|
+ if(Validator.isEmpty(bo.getCode())){
|
|
|
+ add.setCode(ServletUtils.getImportEncoded("TM") + no);
|
|
|
+ }
|
|
|
if (bo.getOptionsList() != null && bo.getOptionsList().size() > 0) {
|
|
|
add.setJsonStr(JSON.toJSONString(bo.getOptionsList()));
|
|
|
}
|