|
|
@@ -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;
|
|
|
@@ -2455,10 +2457,12 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
}
|
|
|
|
|
|
@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;
|
|
|
@@ -2471,6 +2475,15 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
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);
|
|
|
+ CourseSubject subject = iCourseSubjectService.getOne(new LambdaQueryWrapper<CourseSubject>()
|
|
|
+ .eq(CourseSubject::getSubjectName,subjectName).eq(CourseSubject::getStatus,1).last("limit 1"));
|
|
|
+ String importCode = ServletUtils.getImportEncoded("TM");
|
|
|
InputStream is = file.getInputStream();
|
|
|
XWPFDocument doc = new XWPFDocument(is);
|
|
|
List<XWPFParagraph> paragraphList = doc.getParagraphs();
|
|
|
@@ -2516,14 +2529,11 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
alKeyList.add("案例(八)");
|
|
|
alKeyList.add("案例(九)");
|
|
|
alKeyList.add("案例(十)");
|
|
|
+ int anLiNum = 0;
|
|
|
String indexKey = null;
|
|
|
for (XWPFParagraph paragraph : paragraphList) {
|
|
|
content = paragraph.getText();
|
|
|
- content = dealTxt(content);
|
|
|
- if(content.equals("")){
|
|
|
- continue;
|
|
|
- }
|
|
|
- System.out.println(content);
|
|
|
+
|
|
|
List<XWPFRun> runs = paragraph.getRuns();
|
|
|
imgUrl = null;
|
|
|
// System.out.println(content);
|
|
|
@@ -2559,23 +2569,23 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
|
|
|
String ossPath = null;
|
|
|
try {
|
|
|
- /* ossPath = ossService.uploadInputStream(part.getInputStream(), 8);
|
|
|
+ ossPath = ossService.uploadInputStream(part.getInputStream(), 8);
|
|
|
System.out.println(part.getSize()+"图片大小");
|
|
|
- System.out.println(ossPath);*/
|
|
|
+ System.out.println(ossPath);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- /* imgUrl = ossPath + "?x-oss-process=image/resize,w_" + wPx + ",h_" + HPx;
|
|
|
- if(type==5){
|
|
|
+ imgUrl = ossPath + "?x-oss-process=image/resize,w_" + wPx + ",h_" + HPx;
|
|
|
+ if(type==5||nowPart==9){
|
|
|
//正文图片
|
|
|
- QuestionAddBo cAddBo = allQues.get(indexKey);
|
|
|
- cAddBo.setContent(cAddBo.getContent()+"<br />" +"<p><img src=\"" + ossHost + "/" + imgUrl + "\"></p>");
|
|
|
- }*/
|
|
|
+ qContent = qContent+"<br />" +"<p><img src=\"" + ossHost + "/" + imgUrl + "\"></p>";
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if(content.indexOf("参考答案")>-1){
|
|
|
- System.out.println(content);
|
|
|
+ content = dealTxt(content);
|
|
|
+ if(content.equals("")){
|
|
|
+ continue;
|
|
|
}
|
|
|
if (content.startsWith("###")||isXueJianQuestionStart(content,type,alKeyList)) {
|
|
|
|
|
|
@@ -2644,7 +2654,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
}
|
|
|
|
|
|
if(nowPart==8){
|
|
|
- if(isNumStart((content))||content.indexOf("###")>-1||content.indexOf("章标题")>-1){
|
|
|
+ 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) {
|
|
|
@@ -2652,6 +2662,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
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));
|
|
|
@@ -2661,24 +2674,97 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
}
|
|
|
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){
|
|
|
- examName = content.substring(4);
|
|
|
-
|
|
|
+ if (content.indexOf("章标题:")>-1||content.startsWith("###")){
|
|
|
+ preExamName = examName;
|
|
|
+ if(content.indexOf("章标题:")>-1){
|
|
|
+ examName = content.substring(4);
|
|
|
+ }
|
|
|
answerStatus = false;
|
|
|
- // System.out.println("试卷名"+examName);
|
|
|
- }
|
|
|
- if (content.indexOf("章标题:")>-1||content.startsWith("###")) { //插入章
|
|
|
+ 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){
|
|
|
+ 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.setBusinessList(businessItemList);
|
|
|
+ examAddBo.setQuestionList(questionList);
|
|
|
+ examAddBo.setStatus(1);
|
|
|
+ iExamService.insertByAddBo(examAddBo);
|
|
|
+ }
|
|
|
list1.clear();
|
|
|
list2.clear();
|
|
|
list3.clear();
|
|
|
list4.clear();
|
|
|
+ type = -1;
|
|
|
|
|
|
continue;
|
|
|
}
|
|
|
+
|
|
|
if(content.indexOf("单项选择题")>-1&&!answerStatus){
|
|
|
type = 1;
|
|
|
continue;
|
|
|
@@ -2886,20 +2972,24 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
if(answerStatus&&content.indexOf("案例分析题")>0){
|
|
|
nowPart = 10;
|
|
|
qContent = "";
|
|
|
+ anLiNum=0;
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if (isXueJianQuestionStart(content,type,alKeyList)||(nowPart==0&&!isXueJianLineStart(content,type,alKeyList))) {
|
|
|
- hasQuestion = true;
|
|
|
- if(nowPart!=0){
|
|
|
- qContent = "";
|
|
|
- }
|
|
|
- nowPart = 0;
|
|
|
- //新题开头
|
|
|
- if(!alKeyList.contains(content)){
|
|
|
- qContent = qContent + content +"<br />";
|
|
|
+ if(!answerStatus){
|
|
|
+ hasQuestion = true;
|
|
|
+ if(nowPart!=0){
|
|
|
+ qContent = "";
|
|
|
+ }
|
|
|
+ nowPart = 0;
|
|
|
+ //新题开头
|
|
|
+ if(!alKeyList.contains(content)){
|
|
|
+ qContent = qContent + content +"<br />";
|
|
|
+ }
|
|
|
+ continue;
|
|
|
}
|
|
|
- continue;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -3564,7 +3654,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()));
|
|
|
}
|
|
|
@@ -3592,7 +3684,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()));
|
|
|
}
|