he2802 2 years ago
parent
commit
4112e25631

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/IQuestionService.java

@@ -103,4 +103,6 @@ public interface IQuestionService extends IService<Question> {
 
 
     Question getQuestionByTenant(String code, Long newTenantId);
+
+	String insertByAddBoImport(QuestionAddBo bo, Integer no);
 }

+ 0 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/ExamServiceImpl.java

@@ -361,7 +361,6 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
     //    JSONObject param = JSONObject.parseObject(JSONObject.toJSONString(map));
         String respone = "";
         String url = OLD_SYS_HOST+"/system/BussinessApi/InitQdyQuiz";
-        System.out.println(url);
         try {
             respone = HttpUtils.postFormBody(url, map);
             QuestionOtherAddBo addBo = new QuestionOtherAddBo();

+ 149 - 3
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionOtherServiceImpl.java

@@ -6,20 +6,25 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
-import com.zhongzheng.modules.bank.bo.QuestionOtherAddBo;
-import com.zhongzheng.modules.bank.bo.QuestionOtherEditBo;
-import com.zhongzheng.modules.bank.bo.QuestionOtherQueryBo;
+import com.zhongzheng.common.utils.ServletUtils;
+import com.zhongzheng.modules.bank.bo.*;
 import com.zhongzheng.modules.bank.domain.QuestionOld;
+import com.zhongzheng.modules.bank.domain.QuestionOldChild;
+import com.zhongzheng.modules.bank.domain.QuestionOldOptions;
 import com.zhongzheng.modules.bank.domain.QuestionOther;
 import com.zhongzheng.modules.bank.mapper.QuestionOtherMapper;
 import com.zhongzheng.modules.bank.service.IQuestionOtherService;
+import com.zhongzheng.modules.bank.service.IQuestionService;
 import com.zhongzheng.modules.bank.vo.QuestionOtherVo;
+import com.zhongzheng.modules.course.service.ICourseMenuExamService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.pagehelper.Page;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -34,6 +39,9 @@ import java.util.stream.Collectors;
 @Service
 public class QuestionOtherServiceImpl extends ServiceImpl<QuestionOtherMapper, QuestionOther> implements IQuestionOtherService {
 
+    @Autowired
+    private IQuestionService iQuestionService;
+
     @Override
     public QuestionOtherVo queryById(Long id){
         QuestionOther db = this.baseMapper.selectById(id);
@@ -43,9 +51,147 @@ public class QuestionOtherServiceImpl extends ServiceImpl<QuestionOtherMapper, Q
         if (!db.getJsonStr().contains("\"msg\":\"获取成功\"")) {
             throw new CustomException("同步请求错误");
         }
+        int i = 100;
+        for(QuestionOld old : qList){
+            QuestionAddBo childAddBo = new QuestionAddBo();
+            String importNo = ServletUtils.getEncoded("IMPORT");
+            childAddBo.setStatus(1);
+            childAddBo.setContent(old.getTitle());
+            childAddBo.setSdQid(old.getSdQid());
+            childAddBo.setImportNo(importNo);
+            childAddBo.setCreateTime(DateUtils.getNowTime());
+            childAddBo.setCreateBy("admin");
+            childAddBo.setPublishStatus(1);
+            if(old.getQuiztype()==1){
+                childAddBo.setType(1);
+            }
+            else if(old.getQuiztype()==2){
+                childAddBo.setType(2);
+            }
+            else if(old.getQuiztype()==4){
+                childAddBo.setType(3);
+            }
+            else if(old.getQuiztype()==5){
+                childAddBo.setType(4);
+            }
+
+            if(old.getQuiztype()<3){
+                childAddBo.setAnalysisContent(old.getAnalysis());
+                String answerQuestion="";
+                List<QuestionChildAddBo> optionsList = new ArrayList<>();
+                for(QuestionOldOptions options : old.getOptions()){
+                    QuestionChildAddBo addBo = new QuestionChildAddBo();
+                    addBo.setContent(options.getOptiontitle());
+                    addBo.setOptionsId(dealOptions(options.getSerialnum()));
+                    if(options.getIsanswer()){
+                        answerQuestion+=options.getSerialnum();
+                    }
+                    optionsList.add(addBo);
+                }
+                childAddBo.setOptionsList(optionsList);
+                childAddBo.setAnswerQuestion(dealImportAnswer(answerQuestion));
+            }
+            else if(old.getQuiztype()==4){
+                childAddBo.setAnalysisContent(old.getAnalysis());
+                String answerQuestion="";
+                for(QuestionOldOptions options : old.getOptions()){
+                    if(options.getOptiontitle().equals("是")&&options.getIsanswer()){
+                        answerQuestion = "1";
+                    }else{
+                        answerQuestion = "0";
+                    }
+                }
+                childAddBo.setAnswerQuestion(answerQuestion);
+            }
+            else if(old.getQuiztype()==5){
+                List<QuestionChildAddBo> optionsList = new ArrayList<>();
+                for(QuestionOldChild oldChild :old.getChildlist()){
+                    QuestionChildAddBo addBo = new QuestionChildAddBo();
+                    addBo.setContent(oldChild.getTitle());
+                    if(oldChild.getQuiztype()==1){
+                        addBo.setType(1);
+                    }
+                    else if(oldChild.getQuiztype()==2){
+                        addBo.setType(2);
+                    }
+                    else if(oldChild.getQuiztype()==4){
+                        addBo.setType(3);
+                    }
+                    addBo.setAnalysisContent(oldChild.getAnalysis());
+                    if(oldChild.getQuiztype()<3){
+                        String answerQuestion="";
+                        List<QuestionOptionsAddBo> optionsItemList = new ArrayList<>();
+                        for(QuestionOldOptions options : oldChild.getOptions()){
+                            QuestionOptionsAddBo addChildBo = new QuestionOptionsAddBo();
+                            addChildBo.setContent(options.getOptiontitle());
+                            addChildBo.setOptionsId(dealOptions(options.getSerialnum()));
+                            if(options.getIsanswer()){
+                                answerQuestion+=options.getSerialnum();
+                            }
+                            optionsItemList.add(addChildBo);
+                        }
+                        addBo.setOptionsList(optionsItemList);
+                        addBo.setAnswerQuestion(dealImportAnswer(answerQuestion));
+                    }
+                    else if(oldChild.getQuiztype()==4){
+                        String answerQuestion="";
+                        for(QuestionOldOptions options : oldChild.getOptions()){
+                            if(options.getOptiontitle().equals("是")&&options.getIsanswer()){
+                                answerQuestion = "1";
+                            }else{
+                                answerQuestion = "0";
+                            }
+                        }
+                        addBo.setAnswerQuestion(answerQuestion);
+                    }
+                    optionsList.add(addBo);
+                }
+                childAddBo.setOptionsList(optionsList);
+            }
+            iQuestionService.insertByAddBoImport(childAddBo,i);
+            i++;
+        }
         return BeanUtil.toBean(db, QuestionOtherVo.class);
     }
 
+    private Long dealOptions(String v) {
+        if ("A".equals(v)) {
+           return 1L;
+        } else if ("B".equals(v)) {
+            return 2L;
+        } else if ("C".equals(v)) {
+            return 3L;
+        } else if ("D".equals(v)) {
+            return 4L;
+        } else if ("E".equals(v)) {
+            return 5L;
+        } else if ("F".equals(v)) {
+            return 6L;
+        }
+        return 99L;
+    }
+
+    private String dealImportAnswer(String Answer) {
+        String[] itemArray = Answer.split("");
+        List<String> list = new ArrayList<>();
+        for (String v : itemArray) {
+            if ("A".equals(v)) {
+                list.add("1");
+            } else if ("B".equals(v)) {
+                list.add("2");
+            } else if ("C".equals(v)) {
+                list.add("3");
+            } else if ("D".equals(v)) {
+                list.add("4");
+            } else if ("E".equals(v)) {
+                list.add("5");
+            } else if ("F".equals(v)) {
+                list.add("6");
+            }
+        }
+        return String.join(",", list);
+    }
+
     @Override
     public List<QuestionOtherVo> queryList(QuestionOtherQueryBo bo) {
         LambdaQueryWrapper<QuestionOther> lqw = Wrappers.lambdaQuery();

+ 1 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java

@@ -3015,8 +3015,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
         return false;
     }
 
-
-    @Transactional(rollbackFor = Exception.class)
+    @Override
     public String insertByAddBoImport(QuestionAddBo bo, Integer no) {
         String errorLog = null;
         Question add = BeanUtil.toBean(bo, Question.class);

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/QuestionVo.java

@@ -130,4 +130,5 @@ public class QuestionVo {
 	@Excel(name = "多选 每项部分分,默认0分则不开启")
 	@ApiModelProperty("多选 每项部分分,默认0分则不开启")
 	private BigDecimal partScore;
+	private Long sdQid;
 }