|
|
@ -2,6 +2,8 @@ package com.ccsens.tcm.service; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.lang.Snowflake; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.ccsens.tcm.bean.dto.CodeVo; |
|
|
|
import com.ccsens.tcm.bean.po.*; |
|
|
|
import com.ccsens.tcm.bean.vo.QuestionVo; |
|
|
|
import com.ccsens.tcm.persist.dao.QuestionDao; |
|
|
@ -82,6 +84,8 @@ public class ImportService implements IImportService { |
|
|
|
List<QuestionOption> optionList = new ArrayList<>(); |
|
|
|
|
|
|
|
//关联的选项的id
|
|
|
|
Long questionId = null; |
|
|
|
Long optionQuestionId = null; |
|
|
|
Long optionId = null; |
|
|
|
for(Object[] objs : questions) { |
|
|
|
if (objs == null || objs.length < 4 || StringUtils.isEmpty(objs[2])) { |
|
|
@ -94,13 +98,14 @@ public class ImportService implements IImportService { |
|
|
|
switch (type) { |
|
|
|
case "题目" : |
|
|
|
Question question = initQuestion(objs, code, sort,null); |
|
|
|
questionId = question.getId(); |
|
|
|
questionList.add(question); |
|
|
|
break; |
|
|
|
case "选项" : |
|
|
|
if (questionList.isEmpty()) { |
|
|
|
break; |
|
|
|
} |
|
|
|
QuestionOption option = initOption(objs, questionList.get(questionList.size()-1).getId(), sort); |
|
|
|
QuestionOption option = initOption(objs, questionId, sort); |
|
|
|
optionList.add(option); |
|
|
|
optionId = option.getId(); |
|
|
|
break; |
|
|
@ -110,12 +115,13 @@ public class ImportService implements IImportService { |
|
|
|
} |
|
|
|
Question relevanceQuestion = initQuestion(objs, code, sort, optionId); |
|
|
|
questionList.add(relevanceQuestion); |
|
|
|
optionQuestionId = relevanceQuestion.getId(); |
|
|
|
break; |
|
|
|
case "关联题目的选项" : |
|
|
|
if (questionList.isEmpty()) { |
|
|
|
break; |
|
|
|
} |
|
|
|
QuestionOption relevanceOption = initOption(objs, questionList.get(questionList.size()-1).getId(), sort); |
|
|
|
QuestionOption relevanceOption = initOption(objs, optionQuestionId, sort); |
|
|
|
optionList.add(relevanceOption); |
|
|
|
break; |
|
|
|
default: |
|
|
@ -231,29 +237,88 @@ public class ImportService implements IImportService { |
|
|
|
if(CollectionUtil.isNotEmpty(reportCodeVos)){ |
|
|
|
reportCodeVos.forEach(reportCodeVo -> { |
|
|
|
//查询类型下的题目
|
|
|
|
|
|
|
|
|
|
|
|
reportCodeVo.setQuestionVos(questionDao.queryQuestionByCode(reportCodeVo.getCode())); |
|
|
|
List<QuestionVo.CodeQuestionVo> questionVos = getQuestionByCode(reportCodeVo.getCode()); |
|
|
|
reportCodeVo.setQuestionVos(questionVos); |
|
|
|
//查询子类型下的题目
|
|
|
|
if(CollectionUtil.isNotEmpty(reportCodeVo.getSubReportCodes())){ |
|
|
|
reportCodeVo.getSubReportCodes().forEach(subReportCode -> { |
|
|
|
//查询子类型下的题目
|
|
|
|
subReportCode.setQuestionVos(questionDao.queryQuestionByCode(subReportCode.getCode())); |
|
|
|
List<QuestionVo.CodeQuestionVo> subCodeQuestionVos = getQuestionByCode(subReportCode.getCode()); |
|
|
|
subReportCode.setQuestionVos(subCodeQuestionVos); |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
//移除原有的试题
|
|
|
|
redisUtil.lRemoveLast(Constant.Redis.CODE_QUESTION); |
|
|
|
//添加最新的试题
|
|
|
|
redisUtil.lSet(Constant.Redis.CODE_QUESTION,reportCodeVos); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据code查找题目 |
|
|
|
*/ |
|
|
|
private List<QuestionVo.CodeQuestionVo> getQuestionByCode(String code) { |
|
|
|
List<QuestionVo.CodeQuestionVo> subCodeQuestionVos = questionDao.queryQuestionByCode(code); |
|
|
|
if(CollectionUtil.isNotEmpty(subCodeQuestionVos)){ |
|
|
|
subCodeQuestionVos.forEach(question -> { |
|
|
|
if(CollectionUtil.isNotEmpty(question.getOptionVos())){ |
|
|
|
question.getOptionVos().forEach(option -> { |
|
|
|
if(option.getAfterOperation() == Constant.AFTER_OPERATION){ |
|
|
|
option.setQuestionVos(queryOptionQuestion(option.getId())); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
return subCodeQuestionVos; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查看选项下关联的题目 |
|
|
|
*/ |
|
|
|
private List<QuestionVo.CodeQuestionVo> queryOptionQuestion(Long optionId){ |
|
|
|
List<QuestionVo.CodeQuestionVo> questionVos = questionDao.queryQuestionByOption(optionId); |
|
|
|
if(CollectionUtil.isNotEmpty(questionVos)){ |
|
|
|
questionVos.forEach(question -> { |
|
|
|
if(CollectionUtil.isNotEmpty(question.getOptionVos())){ |
|
|
|
question.getOptionVos().forEach(option -> { |
|
|
|
if(option.getAfterOperation() == Constant.AFTER_OPERATION){ |
|
|
|
option.setQuestionVos(queryOptionQuestion(option.getId())); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
//将试题信息更新进redis
|
|
|
|
redisUtil.lSet(Constant.Redis.CODE_QUESTION,reportCodeVos); |
|
|
|
return questionVos; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 查看类型下的试题信息 |
|
|
|
* @param param |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<QuestionVo.ReportCodeVo> getQuestion() { |
|
|
|
Object objects = redisUtil.lGet(Constant.Redis.CODE_QUESTION, 0, -1); |
|
|
|
List<QuestionVo.ReportCodeVo> reportCodeVos = (List<QuestionVo.ReportCodeVo>)objects; |
|
|
|
public List<QuestionVo.ReportCodeVo> getQuestion(CodeVo.QuestionCode param) { |
|
|
|
List<QuestionVo.ReportCodeVo> reportCode = new ArrayList<>(); |
|
|
|
|
|
|
|
return reportCodeVos; |
|
|
|
List<Object> objects = redisUtil.lGet(Constant.Redis.CODE_QUESTION, 0, -1); |
|
|
|
List<QuestionVo.ReportCodeVo> reportCodeVos = (List<QuestionVo.ReportCodeVo>)objects.get(0); |
|
|
|
if(CollectionUtil.isNotEmpty(reportCodeVos)){ |
|
|
|
if(StrUtil.isEmpty(param.getCode())){ |
|
|
|
return reportCodeVos; |
|
|
|
} |
|
|
|
reportCodeVos.forEach(reportCodeVo -> { |
|
|
|
if(reportCodeVo.getCode().equalsIgnoreCase(param.getCode())){ |
|
|
|
reportCode.add(reportCodeVo); |
|
|
|
}else if(CollectionUtil.isNotEmpty(reportCodeVo.getSubReportCodes())){ |
|
|
|
reportCodeVo.getSubReportCodes().forEach(subReport ->{ |
|
|
|
if(subReport.getCode().equalsIgnoreCase(param.getCode())){ |
|
|
|
reportCode.add(subReport); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
return reportCode; |
|
|
|
} |
|
|
|
} |
|
|
|