|
@@ -180,27 +180,45 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean updateByEditBo(QuestionEditBo bo) {
|
|
|
- Question update = BeanUtil.toBean(bo, Question.class);
|
|
|
- if (bo.getOptionsList() != null) {
|
|
|
- update.setJsonStr(JSON.toJSONString(bo.getOptionsList()));
|
|
|
- }
|
|
|
- validEntityBeforeSave(update);
|
|
|
- update.setUpdateTime(DateUtils.getNowTime());
|
|
|
- if (bo.getBusinessList() != null) {
|
|
|
- iQuestionBusinessService.remove(new LambdaQueryWrapper<QuestionBusiness>()
|
|
|
- .eq(QuestionBusiness::getMajorId, bo.getQuestionId())
|
|
|
- .eq(QuestionBusiness::getType, QuestionBusiness.TYPE_QUESTION));
|
|
|
- Collection<QuestionBusiness> coll = new HashSet<>();
|
|
|
- for (int i = 0; i < bo.getBusinessList().size(); i++) {
|
|
|
- QuestionBusinessEditBo item = bo.getBusinessList().get(i);
|
|
|
- QuestionBusiness addItem = BeanUtil.toBean(item, QuestionBusiness.class);
|
|
|
- addItem.setMajorId(bo.getQuestionId());
|
|
|
- addItem.setType(QuestionBusiness.TYPE_QUESTION);
|
|
|
- coll.add(addItem);
|
|
|
+ if(bo.getStatus()==-1){
|
|
|
+ //删除
|
|
|
+ if(Validator.isNotEmpty(bo.getQuestionIds())&&bo.getQuestionIds().size()>0){
|
|
|
+ for(Long id : bo.getQuestionIds()){
|
|
|
+ Question update = new Question();
|
|
|
+ update.setQuestionId(id);
|
|
|
+ update.setStatus(-1);
|
|
|
+ }
|
|
|
}
|
|
|
- iQuestionBusinessService.saveBatch(coll);
|
|
|
+ if(Validator.isNotEmpty(bo.getQuestionId())){
|
|
|
+ Question update = new Question();
|
|
|
+ update.setQuestionId(bo.getQuestionId());
|
|
|
+ update.setStatus(-1);
|
|
|
+ return this.updateById(update);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ Question update = BeanUtil.toBean(bo, Question.class);
|
|
|
+ if (bo.getOptionsList() != null) {
|
|
|
+ update.setJsonStr(JSON.toJSONString(bo.getOptionsList()));
|
|
|
+ }
|
|
|
+ validEntityBeforeSave(update);
|
|
|
+ update.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ if (bo.getBusinessList() != null) {
|
|
|
+ iQuestionBusinessService.remove(new LambdaQueryWrapper<QuestionBusiness>()
|
|
|
+ .eq(QuestionBusiness::getMajorId, bo.getQuestionId())
|
|
|
+ .eq(QuestionBusiness::getType, QuestionBusiness.TYPE_QUESTION));
|
|
|
+ Collection<QuestionBusiness> coll = new HashSet<>();
|
|
|
+ for (int i = 0; i < bo.getBusinessList().size(); i++) {
|
|
|
+ QuestionBusinessEditBo item = bo.getBusinessList().get(i);
|
|
|
+ QuestionBusiness addItem = BeanUtil.toBean(item, QuestionBusiness.class);
|
|
|
+ addItem.setMajorId(bo.getQuestionId());
|
|
|
+ addItem.setType(QuestionBusiness.TYPE_QUESTION);
|
|
|
+ coll.add(addItem);
|
|
|
+ }
|
|
|
+ iQuestionBusinessService.saveBatch(coll);
|
|
|
+ }
|
|
|
+ return this.updateById(update);
|
|
|
}
|
|
|
- return this.updateById(update);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -228,7 +246,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
return this.removeByIds(ids);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public List<QuestionImport> importQuestion(List<QuestionImport> questionList, Boolean isUpdateSupport, String operName) {
|
|
|
if (Validator.isNull(questionList) || questionList.size() == 0) {
|
|
|
throw new CustomException("导入数据不能为空!");
|
|
@@ -238,6 +258,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
int i = 1;
|
|
|
Long nowTime = DateUtils.getNowTime();
|
|
|
List<QuestionImport> errorList = new ArrayList<>();
|
|
|
+ Collections.reverse(questionList);
|
|
|
+ //案例附属题数组
|
|
|
+ List<QuestionAddBo> attList = new ArrayList<>();
|
|
|
for (QuestionImport question : questionList) {
|
|
|
QuestionAddBo bo = new QuestionAddBo();
|
|
|
|
|
@@ -252,6 +275,11 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
errorList.add(question);
|
|
|
continue;
|
|
|
}
|
|
|
+ if(Validator.isEmpty(question.getAttached())){
|
|
|
+ question.setCause("是否案例小题错误");
|
|
|
+ errorList.add(question);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
/* if(!Validator.isNotEmpty(question.getPrefixName())){
|
|
|
errorLog+=question.getContent()+"-前缀名称空白\n";
|
|
|
continue;
|
|
@@ -266,28 +294,28 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
List<QuestionBusinessAddBo> businessList = new ArrayList<>();
|
|
|
QuestionBusinessAddBo questionBusinessAddBo = new QuestionBusinessAddBo();
|
|
|
Long eduId = findEduId(question.getEducationType());
|
|
|
- if (!Validator.isNotEmpty(eduId)) {
|
|
|
+ if (question.getAttached().equals("否")&&!Validator.isNotEmpty(eduId)) {
|
|
|
// errorLog+=question.getEducationType()+"-该教育类型不存在\n";
|
|
|
question.setCause("教育类型不存在");
|
|
|
errorList.add(question);
|
|
|
continue;
|
|
|
}
|
|
|
Long projectId = findProjectId(question.getProject(), eduId);
|
|
|
- if (!Validator.isNotEmpty(projectId)) {
|
|
|
+ if (question.getAttached().equals("否")&&!Validator.isNotEmpty(projectId)) {
|
|
|
// errorLog+=question.getProject()+"-该项目类型不存在\n";
|
|
|
question.setCause("项目类型不存在");
|
|
|
errorList.add(question);
|
|
|
continue;
|
|
|
}
|
|
|
Long businessId = findBusinessId(question.getBusiness(), projectId);
|
|
|
- if (!Validator.isNotEmpty(businessId)) {
|
|
|
+ if (question.getAttached().equals("否")&&!Validator.isNotEmpty(businessId)) {
|
|
|
// errorLog+=question.getBusiness()+"-该业务层次不存在\n";
|
|
|
question.setCause("业务层次不存在");
|
|
|
errorList.add(question);
|
|
|
continue;
|
|
|
}
|
|
|
Long subjectId = findSubjectId(question.getSubject());
|
|
|
- if (!Validator.isNotEmpty(subjectId)) {
|
|
|
+ if (question.getAttached().equals("否")&&!Validator.isNotEmpty(subjectId)) {
|
|
|
// errorLog+=question.getSubject()+"-该科目不存在\n";
|
|
|
question.setCause("科目不存在");
|
|
|
errorList.add(question);
|
|
@@ -338,9 +366,31 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
bo.setPublishStatus(1);
|
|
|
bo.setImportSort(nowTime + i); //导入时间从小到大排
|
|
|
bo.setCreateTime(nowTime); //从大到小排
|
|
|
- errorLog = insertByAddBoImport(bo, i);
|
|
|
+ System.out.println(question);
|
|
|
+ if (question.getAttached().equals("是")){
|
|
|
+ System.out.println("123");
|
|
|
+ attList.add(bo);
|
|
|
+ }else{
|
|
|
+ System.out.println(bo);
|
|
|
+ System.out.println("CCVF"+bo.getType());
|
|
|
+ if(bo.getType()==4){//案例题
|
|
|
+ Collections.reverse(attList);
|
|
|
+ System.out.println("777");
|
|
|
+ bo.setJsonStr(JSON.toJSONString(attList));
|
|
|
+ System.out.println("666");
|
|
|
+ attList.clear();
|
|
|
+ }else {
|
|
|
+
|
|
|
+ System.out.println(errorList);
|
|
|
+ if(attList.size()>0){
|
|
|
+ throw new CustomException("案例题格式错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ errorLog = insertByAddBoImport(bo, i);
|
|
|
+ }
|
|
|
i++;
|
|
|
}
|
|
|
+
|
|
|
return errorList;
|
|
|
}
|
|
|
|
|
@@ -448,6 +498,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
String strContent = "";
|
|
|
for (XWPFParagraph paragraph : paragraphList) {
|
|
|
content = paragraph.getText();
|
|
|
+ content = dealTxt(content);
|
|
|
List<XWPFRun> runs = paragraph.getRuns();
|
|
|
for (XWPFRun run : runs) {
|
|
|
Node node = run.getCTR().getDomNode();
|
|
@@ -486,10 +537,13 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
String imgUrl = ossHost + "/" + ossPath + "?x-oss-process=image/resize,w_" + wPx + ",h_" + HPx;
|
|
|
- content = "<p><img src=\"" + imgUrl + "\"></p>";
|
|
|
+ if(Validator.isNotEmpty(content)&&content!=""){
|
|
|
+ content = content +"<br />" +"<p><img src=\"" + imgUrl + "\"></p>";
|
|
|
+ }else{
|
|
|
+ content = "<p><img src=\"" + imgUrl + "\"></p>";
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- content = dealTxt(content);
|
|
|
if (content.startsWith("#")||isQuestionStart(content)) {
|
|
|
if(nowPart>0){
|
|
|
//插入上一条
|