|
@@ -23,9 +23,7 @@ import com.zhongzheng.modules.bank.mapper.QuestionMapper;
|
|
|
import com.zhongzheng.modules.bank.service.IExamQuestionService;
|
|
|
import com.zhongzheng.modules.bank.service.IQuestionBusinessService;
|
|
|
import com.zhongzheng.modules.bank.service.IQuestionService;
|
|
|
-import com.zhongzheng.modules.bank.vo.QuestionBusinessImport;
|
|
|
-import com.zhongzheng.modules.bank.vo.QuestionImport;
|
|
|
-import com.zhongzheng.modules.bank.vo.QuestionVo;
|
|
|
+import com.zhongzheng.modules.bank.vo.*;
|
|
|
import com.zhongzheng.modules.base.domain.ApplyAreas;
|
|
|
import com.zhongzheng.modules.course.bo.CourseChapterSectionListAddBo;
|
|
|
import com.zhongzheng.modules.course.domain.*;
|
|
@@ -252,7 +250,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public List<QuestionImport> importQuestion(List<QuestionImport> questionList, Boolean isUpdateSupport, String operName) {
|
|
|
+ public List<QuestionImport> importExcelQuestion(List<QuestionImport> questionList, Boolean isUpdateSupport, String operName) {
|
|
|
if (Validator.isNull(questionList) || questionList.size() == 0) {
|
|
|
throw new CustomException("导入数据不能为空!");
|
|
|
}
|
|
@@ -369,22 +367,14 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
bo.setPublishStatus(1);
|
|
|
bo.setImportSort(nowTime + i); //导入时间从小到大排
|
|
|
bo.setCreateTime(nowTime); //从大到小排
|
|
|
- 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("案例题格式错误");
|
|
|
}
|
|
@@ -397,6 +387,378 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
return errorList;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<QuestionImportV2> importExcelQuestionV2(List<QuestionImportV2> questionList, Boolean isUpdateSupport, String operName) {
|
|
|
+ if (Validator.isNull(questionList) || questionList.size() == 0) {
|
|
|
+ throw new CustomException("导入数据不能为空!");
|
|
|
+ }
|
|
|
+ String errorLog = "";
|
|
|
+ String importNo = ServletUtils.getEncoded("IMPORT");
|
|
|
+ int i = 10;
|
|
|
+ Long nowTime = DateUtils.getNowTime();
|
|
|
+ List<QuestionImportV2> errorList = new ArrayList<>();
|
|
|
+ Collections.reverse(questionList);
|
|
|
+ //案例附属题数组
|
|
|
+ List<QuestionAddBo> attList = new ArrayList<>();
|
|
|
+ boolean isAnLi = false; // 是否案例题
|
|
|
+ for (QuestionImportV2 question : questionList) {
|
|
|
+ QuestionAddBo bo = new QuestionAddBo();
|
|
|
+ Integer type = null; //题目类型
|
|
|
+ boolean isFirst = true;
|
|
|
+ int startIndex = 0;
|
|
|
+ //业务层次,导入每条题目只有一条业务层次
|
|
|
+ List<QuestionBusinessAddBo> businessList = new ArrayList<>();
|
|
|
+ QuestionBusinessAddBo questionBusinessAddBo = new QuestionBusinessAddBo();
|
|
|
+ Long eduId = findEduId(question.getEducationType());
|
|
|
+ if (Validator.isNotEmpty(question.getEducationType())&&!Validator.isNotEmpty(eduId)) {
|
|
|
+ // errorLog+=question.getEducationType()+"-该教育类型不存在\n";
|
|
|
+ question.setCause("教育类型不存在");
|
|
|
+ errorList.add(question);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Long projectId = findProjectId(question.getProject(), eduId);
|
|
|
+ if (Validator.isNotEmpty(question.getProject())&&!Validator.isNotEmpty(projectId)) {
|
|
|
+ // errorLog+=question.getProject()+"-该项目类型不存在\n";
|
|
|
+ question.setCause("项目类型不存在");
|
|
|
+ errorList.add(question);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Long businessId = findBusinessId(question.getBusiness(), projectId);
|
|
|
+ if (Validator.isNotEmpty(question.getBusiness())&&!Validator.isNotEmpty(businessId)) {
|
|
|
+ // errorLog+=question.getBusiness()+"-该业务层次不存在\n";
|
|
|
+ question.setCause("业务层次不存在");
|
|
|
+ errorList.add(question);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Long subjectId = findSubjectId(question.getSubject());
|
|
|
+ if (Validator.isNotEmpty(question.getSubject())&&!Validator.isNotEmpty(subjectId)) {
|
|
|
+ // errorLog+=question.getSubject()+"-该科目不存在\n";
|
|
|
+ question.setCause("科目不存在");
|
|
|
+ errorList.add(question);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (Validator.isNotEmpty(question.getKnowledge())) {
|
|
|
+ List<String> knowledgeList = Arrays.asList(question.getKnowledge().split(","));
|
|
|
+ List<Long> kIdList = new ArrayList<>();
|
|
|
+ for (String knowledge : knowledgeList) {
|
|
|
+ Long knowledgeId = findKnowledgeId(knowledge);
|
|
|
+ if (!Validator.isNotEmpty(knowledgeId)) {
|
|
|
+ //知识点不存在则导入
|
|
|
+ ExamKnowledgeAddBo addBo = new ExamKnowledgeAddBo();
|
|
|
+ addBo.setName(knowledge);
|
|
|
+ List<ExamKnowledgeBusinessAddBo> bList = new ArrayList<>();
|
|
|
+ ExamKnowledgeBusinessAddBo bAddBo = new ExamKnowledgeBusinessAddBo();
|
|
|
+ bAddBo.setBusinessId(businessId);
|
|
|
+ bAddBo.setSubjectId(subjectId);
|
|
|
+ bList.add(bAddBo);
|
|
|
+ addBo.setExamKnowledgeBusinessAddBoList(bList);
|
|
|
+ addBo.setStatus(1);
|
|
|
+ knowledgeId = iExamKnowledgeService.insertByImportQuestionAddBo(addBo);
|
|
|
+ if (Validator.isEmpty(knowledgeId) || knowledgeId == 0) {
|
|
|
+ // errorLog+=knowledge+"-该知识点不存在\n";
|
|
|
+ question.setCause("该知识点不存在");
|
|
|
+ errorList.add(question);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //新增进入redis
|
|
|
+ String key = "KNO_" + knowledge;
|
|
|
+ redisCache.setCacheObject(key, knowledgeId, 3, TimeUnit.MINUTES);//3分钟
|
|
|
+ }
|
|
|
+ kIdList.add(knowledgeId);
|
|
|
+ }
|
|
|
+ //知识点ID拼接
|
|
|
+ bo.setKnowledgeIds(ToolsUtils.join(",", kIdList));
|
|
|
+ }
|
|
|
+ questionBusinessAddBo.setEducationTypeId(eduId);
|
|
|
+ questionBusinessAddBo.setProjectId(projectId);
|
|
|
+ questionBusinessAddBo.setBusinessId(businessId);
|
|
|
+ questionBusinessAddBo.setSubjectId(subjectId);
|
|
|
+ if(Validator.isNotEmpty(eduId)){
|
|
|
+ businessList.add(questionBusinessAddBo);
|
|
|
+ bo.setBusinessList(businessList);
|
|
|
+ }
|
|
|
+ if(Validator.isNotEmpty(question.getBusinessList())){
|
|
|
+ bo.setBusinessList(question.getBusinessList());
|
|
|
+ }
|
|
|
+ for(QuestionImportContent vo : question.getQuestionList()){
|
|
|
+ if(Validator.isNotEmpty(vo.getContent())){
|
|
|
+ type = findType(vo.getType());
|
|
|
+ if(isFirst){
|
|
|
+ isFirst = false;
|
|
|
+ //题目主体
|
|
|
+ bo.setType(type);
|
|
|
+ bo.setContent(vo.getContent());
|
|
|
+ bo.setAnalysisContent(vo.getAnalysisContent());
|
|
|
+ if(type==1||type==2){ //单选或多选
|
|
|
+ Map<String,Object> rs = getOptionsList(startIndex,question.getQuestionList());
|
|
|
+ bo.setOptionsList((List<QuestionChildAddBo>)rs.get("optionsList"));
|
|
|
+ bo.setAnswerQuestion((String) rs.get("answerStr"));
|
|
|
+ }
|
|
|
+ if(type==3){ //判断题
|
|
|
+ if(vo.getOption().equals("正确")&&vo.getAnswer().equals("是")){
|
|
|
+ bo.setAnswerQuestion("1");
|
|
|
+ }
|
|
|
+ else if(vo.getOption().equals("错误")&&vo.getAnswer().equals("否")){
|
|
|
+ bo.setAnswerQuestion("1");
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ bo.setAnswerQuestion("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(type==4){
|
|
|
+ isAnLi = true;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ //案例题附加题
|
|
|
+ QuestionAddBo childAddBo = new QuestionAddBo();
|
|
|
+ childAddBo.setType(type);
|
|
|
+ childAddBo.setContent(vo.getContent());
|
|
|
+ childAddBo.setAnalysisContent(vo.getAnalysisContent());
|
|
|
+ if(type==1||type==2){ //单选或多选
|
|
|
+ Map<String,Object> rs = getOptionsList(startIndex,question.getQuestionList());
|
|
|
+ childAddBo.setOptionsList((List<QuestionChildAddBo>)rs.get("optionsList"));
|
|
|
+ childAddBo.setAnswerQuestion((String) rs.get("answerStr"));
|
|
|
+ }
|
|
|
+ if(type==3){ //判断题
|
|
|
+ if(vo.getOption().equals("正确")&&vo.getAnswer().equals("是")){
|
|
|
+ childAddBo.setAnswerQuestion("1");
|
|
|
+ }
|
|
|
+ else if(vo.getOption().equals("错误")&&vo.getAnswer().equals("否")){
|
|
|
+ childAddBo.setAnswerQuestion("1");
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ childAddBo.setAnswerQuestion("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ attList.add(childAddBo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ startIndex++;
|
|
|
+ }
|
|
|
+ if(isAnLi){
|
|
|
+ bo.setJsonStr(JSON.toJSONString(attList));
|
|
|
+ }
|
|
|
+ bo.setStatus(1);
|
|
|
+ bo.setPrefixName(question.getPrefixName());
|
|
|
+ bo.setCreateBy(operName);
|
|
|
+ bo.setImportNo(importNo);
|
|
|
+ bo.setPublishStatus(1);
|
|
|
+ bo.setImportSort(nowTime + i); //导入时间从小到大排
|
|
|
+ bo.setCreateTime(nowTime); //从大到小排
|
|
|
+ errorLog = insertByAddBoImport(bo, i);
|
|
|
+ attList.clear();
|
|
|
+ isFirst = true;
|
|
|
+ isAnLi = false;
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ return errorList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> importExcelQuestionV2NotInBank(List<QuestionImportV2> questionList, Boolean isUpdateSupport, String operName) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ if (Validator.isNull(questionList) || questionList.size() == 0) {
|
|
|
+ throw new CustomException("导入数据不能为空!");
|
|
|
+ }
|
|
|
+ String errorLog = "";
|
|
|
+ String importNo = ServletUtils.getEncoded("IMPORT");
|
|
|
+ int i = 10;
|
|
|
+ Long nowTime = DateUtils.getNowTime();
|
|
|
+ List<QuestionImportV2> errorList = new ArrayList<>();
|
|
|
+ //案例附属题数组
|
|
|
+ List<QuestionAddBo> attList = new ArrayList<>();
|
|
|
+ List<QuestionAddBo> nqList = new ArrayList<>();
|
|
|
+ boolean isAnLi = false; // 是否案例题
|
|
|
+ for (QuestionImportV2 question : questionList) {
|
|
|
+ QuestionAddBo bo = new QuestionAddBo();
|
|
|
+ Integer type = null; //题目类型
|
|
|
+ boolean isFirst = true;
|
|
|
+ int startIndex = 0;
|
|
|
+ //业务层次,导入每条题目只有一条业务层次
|
|
|
+ List<QuestionBusinessAddBo> businessList = new ArrayList<>();
|
|
|
+ QuestionBusinessAddBo questionBusinessAddBo = new QuestionBusinessAddBo();
|
|
|
+ Long eduId = findEduId(question.getEducationType());
|
|
|
+ if (Validator.isNotEmpty(question.getEducationType())&&!Validator.isNotEmpty(eduId)) {
|
|
|
+ // errorLog+=question.getEducationType()+"-该教育类型不存在\n";
|
|
|
+ question.setCause("教育类型不存在");
|
|
|
+ errorList.add(question);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Long projectId = findProjectId(question.getProject(), eduId);
|
|
|
+ if (Validator.isNotEmpty(question.getProject())&&!Validator.isNotEmpty(projectId)) {
|
|
|
+ // errorLog+=question.getProject()+"-该项目类型不存在\n";
|
|
|
+ question.setCause("项目类型不存在");
|
|
|
+ errorList.add(question);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Long businessId = findBusinessId(question.getBusiness(), projectId);
|
|
|
+ if (Validator.isNotEmpty(question.getBusiness())&&!Validator.isNotEmpty(businessId)) {
|
|
|
+ // errorLog+=question.getBusiness()+"-该业务层次不存在\n";
|
|
|
+ question.setCause("业务层次不存在");
|
|
|
+ errorList.add(question);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Long subjectId = findSubjectId(question.getSubject());
|
|
|
+ if (Validator.isNotEmpty(question.getSubject())&&!Validator.isNotEmpty(subjectId)) {
|
|
|
+ // errorLog+=question.getSubject()+"-该科目不存在\n";
|
|
|
+ question.setCause("科目不存在");
|
|
|
+ errorList.add(question);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (Validator.isNotEmpty(question.getKnowledge())) {
|
|
|
+ List<String> knowledgeList = Arrays.asList(question.getKnowledge().split(","));
|
|
|
+ List<Long> kIdList = new ArrayList<>();
|
|
|
+ for (String knowledge : knowledgeList) {
|
|
|
+ Long knowledgeId = findKnowledgeId(knowledge);
|
|
|
+ if (!Validator.isNotEmpty(knowledgeId)) {
|
|
|
+ //知识点不存在则导入
|
|
|
+ ExamKnowledgeAddBo addBo = new ExamKnowledgeAddBo();
|
|
|
+ addBo.setName(knowledge);
|
|
|
+ List<ExamKnowledgeBusinessAddBo> bList = new ArrayList<>();
|
|
|
+ ExamKnowledgeBusinessAddBo bAddBo = new ExamKnowledgeBusinessAddBo();
|
|
|
+ bAddBo.setBusinessId(businessId);
|
|
|
+ bAddBo.setSubjectId(subjectId);
|
|
|
+ bList.add(bAddBo);
|
|
|
+ addBo.setExamKnowledgeBusinessAddBoList(bList);
|
|
|
+ addBo.setStatus(1);
|
|
|
+ knowledgeId = iExamKnowledgeService.insertByImportQuestionAddBo(addBo);
|
|
|
+ if (Validator.isEmpty(knowledgeId) || knowledgeId == 0) {
|
|
|
+ // errorLog+=knowledge+"-该知识点不存在\n";
|
|
|
+ question.setCause("该知识点不存在");
|
|
|
+ errorList.add(question);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //新增进入redis
|
|
|
+ String key = "KNO_" + knowledge;
|
|
|
+ redisCache.setCacheObject(key, knowledgeId, 3, TimeUnit.MINUTES);//3分钟
|
|
|
+ }
|
|
|
+ kIdList.add(knowledgeId);
|
|
|
+ }
|
|
|
+ //知识点ID拼接
|
|
|
+ bo.setKnowledgeIds(ToolsUtils.join(",", kIdList));
|
|
|
+ }
|
|
|
+ questionBusinessAddBo.setEducationTypeId(eduId);
|
|
|
+ questionBusinessAddBo.setProjectId(projectId);
|
|
|
+ questionBusinessAddBo.setBusinessId(businessId);
|
|
|
+ questionBusinessAddBo.setSubjectId(subjectId);
|
|
|
+ if(Validator.isNotEmpty(eduId)){
|
|
|
+ businessList.add(questionBusinessAddBo);
|
|
|
+ bo.setBusinessList(businessList);
|
|
|
+ }
|
|
|
+ if(Validator.isNotEmpty(question.getBusinessList())){
|
|
|
+ bo.setBusinessList(question.getBusinessList());
|
|
|
+ }
|
|
|
+ boolean hasError = false;
|
|
|
+ for(QuestionImportContent vo : question.getQuestionList()){
|
|
|
+ if(Validator.isNotEmpty(vo.getContent())){
|
|
|
+ type = findType(vo.getType());
|
|
|
+ if(isFirst){
|
|
|
+ isFirst = false;
|
|
|
+ //题目主体
|
|
|
+ bo.setType(type);
|
|
|
+ bo.setContent(vo.getContent());
|
|
|
+ bo.setAnalysisContent(vo.getAnalysisContent());
|
|
|
+ if(Validator.isEmpty(type)){
|
|
|
+ question.setCause("题目类型错误");
|
|
|
+ errorList.add(question);
|
|
|
+ hasError = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if(type==1||type==2){ //单选或多选
|
|
|
+ Map<String,Object> rs = getOptionsList(startIndex,question.getQuestionList());
|
|
|
+ bo.setOptionsList((List<QuestionChildAddBo>)rs.get("optionsList"));
|
|
|
+ bo.setAnswerQuestion((String) rs.get("answerStr"));
|
|
|
+ }
|
|
|
+ if(type==3){ //判断题
|
|
|
+ if(vo.getOption().equals("正确")&&vo.getAnswer().equals("是")){
|
|
|
+ bo.setAnswerQuestion("1");
|
|
|
+ }
|
|
|
+ else if(vo.getOption().equals("错误")&&vo.getAnswer().equals("否")){
|
|
|
+ bo.setAnswerQuestion("1");
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ bo.setAnswerQuestion("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(type==4){
|
|
|
+ isAnLi = true;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ //案例题附加题
|
|
|
+ QuestionAddBo childAddBo = new QuestionAddBo();
|
|
|
+ childAddBo.setType(type);
|
|
|
+ childAddBo.setContent(vo.getContent());
|
|
|
+ childAddBo.setAnalysisContent(vo.getAnalysisContent());
|
|
|
+ if(type==1||type==2){ //单选或多选
|
|
|
+ Map<String,Object> rs = getOptionsList(startIndex,question.getQuestionList());
|
|
|
+ childAddBo.setOptionsList((List<QuestionChildAddBo>)rs.get("optionsList"));
|
|
|
+ childAddBo.setAnswerQuestion((String) rs.get("answerStr"));
|
|
|
+ }
|
|
|
+ if(type==3){ //判断题
|
|
|
+ if(vo.getOption().equals("正确")&&vo.getAnswer().equals("是")){
|
|
|
+ childAddBo.setAnswerQuestion("1");
|
|
|
+ }
|
|
|
+ else if(vo.getOption().equals("错误")&&vo.getAnswer().equals("否")){
|
|
|
+ childAddBo.setAnswerQuestion("1");
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ childAddBo.setAnswerQuestion("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ attList.add(childAddBo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ startIndex++;
|
|
|
+ }
|
|
|
+ if(hasError){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(isAnLi){
|
|
|
+ bo.setJsonStr(JSON.toJSONString(attList));
|
|
|
+ }
|
|
|
+ bo.setStatus(1);
|
|
|
+ bo.setPrefixName(question.getPrefixName());
|
|
|
+ bo.setCreateBy(operName);
|
|
|
+ bo.setImportNo(importNo);
|
|
|
+ bo.setPublishStatus(1);
|
|
|
+ bo.setImportSort(nowTime + i); //导入时间从小到大排
|
|
|
+ bo.setCreateTime(nowTime); //从大到小排
|
|
|
+ nqList.add(bo);
|
|
|
+ attList.clear();
|
|
|
+ isFirst = true;
|
|
|
+ isAnLi = false;
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ map.put("errorList",errorList);
|
|
|
+ map.put("questionList",nqList);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String,Object> getOptionsList(int startIndex,List<QuestionImportContent> list){
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ String answerQuestion = "";
|
|
|
+ List<QuestionChildAddBo> optionsList = new ArrayList<>(); //题目选项
|
|
|
+ List<Long> answerList = new ArrayList<>(); //答案选项
|
|
|
+ Long j = 1L;
|
|
|
+ for(int i = startIndex;i<list.size();i++){
|
|
|
+ QuestionImportContent entity = list.get(i);
|
|
|
+ if(Validator.isNotEmpty(entity.getContent())&&i>startIndex){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ QuestionChildAddBo addBo = new QuestionChildAddBo();
|
|
|
+ addBo.setContent(entity.getOption());
|
|
|
+ addBo.setOptionsId(j);
|
|
|
+ optionsList.add(addBo);
|
|
|
+ if("是".equals(entity.getAnswer())){
|
|
|
+ answerList.add(j);
|
|
|
+ }
|
|
|
+ j++;
|
|
|
+ }
|
|
|
+ map.put("optionsList",optionsList);
|
|
|
+ map.put("answerStr",ToolsUtils.join(",", answerList));
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<GoodsUserQuestionVo> listGoodsUserQuestionVo(GoodsQueryBo bo) {
|
|
|
return baseMapper.listGoodsUserQuestionVo(bo);
|