he2802 2 years ago
parent
commit
e9fb1c19f2

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

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

+ 19 - 10
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionOtherServiceImpl.java

@@ -47,11 +47,11 @@ public class QuestionOtherServiceImpl extends ServiceImpl<QuestionOtherMapper, Q
         QuestionOther db = this.baseMapper.selectById(id);
         JSONObject jsonObject = (JSONObject) JSONObject.parse(db.getJsonStr());
         List<QuestionOld> qList = JSONArray.parseArray(String.valueOf(jsonObject.get("data")),QuestionOld.class);
-        System.out.println(qList);
         if (!db.getJsonStr().contains("\"msg\":\"获取成功\"")) {
             throw new CustomException("同步请求错误");
         }
         int i = 100;
+        List<Long> qIdList = new ArrayList<>();
         for(QuestionOld old : qList){
             QuestionAddBo childAddBo = new QuestionAddBo();
             String importNo = ServletUtils.getEncoded("IMPORT");
@@ -95,10 +95,12 @@ public class QuestionOtherServiceImpl extends ServiceImpl<QuestionOtherMapper, Q
                 childAddBo.setAnalysisContent(old.getAnalysis());
                 String answerQuestion="";
                 for(QuestionOldOptions options : old.getOptions()){
-                    if(options.getOptiontitle().equals("是")&&options.getIsanswer()){
-                        answerQuestion = "1";
-                    }else{
-                        answerQuestion = "0";
+                    if(options.getIsanswer()){
+                        if(options.getSerialnum().equals("A")){
+                            answerQuestion = "1";
+                        }else{
+                            answerQuestion = "0";
+                        }
                     }
                 }
                 childAddBo.setAnswerQuestion(answerQuestion);
@@ -118,6 +120,9 @@ public class QuestionOtherServiceImpl extends ServiceImpl<QuestionOtherMapper, Q
                         addBo.setType(3);
                     }
                     addBo.setAnalysisContent(oldChild.getAnalysis());
+                    if(oldChild.getAnalysis().startsWith("检查各类面层")){
+                        System.out.println(oldChild.getAnalysis());
+                    }
                     if(oldChild.getQuiztype()<3){
                         String answerQuestion="";
                         List<QuestionOptionsAddBo> optionsItemList = new ArrayList<>();
@@ -136,10 +141,12 @@ public class QuestionOtherServiceImpl extends ServiceImpl<QuestionOtherMapper, Q
                     else if(oldChild.getQuiztype()==4){
                         String answerQuestion="";
                         for(QuestionOldOptions options : oldChild.getOptions()){
-                            if(options.getOptiontitle().equals("是")&&options.getIsanswer()){
-                                answerQuestion = "1";
-                            }else{
-                                answerQuestion = "0";
+                            if(options.getIsanswer()){
+                                if(options.getSerialnum().equals("A")){
+                                    answerQuestion = "1";
+                                }else{
+                                    answerQuestion = "0";
+                                }
                             }
                         }
                         addBo.setAnswerQuestion(answerQuestion);
@@ -148,8 +155,10 @@ public class QuestionOtherServiceImpl extends ServiceImpl<QuestionOtherMapper, Q
                 }
                 childAddBo.setOptionsList(optionsList);
             }
-            iQuestionService.insertByAddBoImport(childAddBo,i);
+            Long qId = iQuestionService.insertByAddBoImportBackId(childAddBo,i);
+            qIdList.add(qId);
             i++;
+            System.out.println(qIdList.size());
         }
         return BeanUtil.toBean(db, QuestionOtherVo.class);
     }

+ 28 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java

@@ -3044,6 +3044,34 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
         return errorLog;
     }
 
+    @Override
+    public Long insertByAddBoImportBackId(QuestionAddBo bo, Integer no) {
+        Question add = BeanUtil.toBean(bo, Question.class);
+        add.setCode(ServletUtils.getImportEncoded("TM") + no);
+        if (bo.getOptionsList() != null && bo.getOptionsList().size() > 0) {
+            add.setJsonStr(JSON.toJSONString(bo.getOptionsList()));
+        }
+        /*if(checkNameUnique(add)){
+            errorLog+=bo.getContent()+"-名称重复\n";
+           return errorLog;
+        }*/
+        //    add.setCreateTime(DateUtils.getNowTime());
+        add.setUpdateTime(DateUtils.getNowTime());
+        boolean result = this.save(add);
+        if (bo.getBusinessList() != null) {
+            Collection<QuestionBusiness> coll = new HashSet<>();
+            for (int i = 0; i < bo.getBusinessList().size(); i++) {
+                QuestionBusinessAddBo item = bo.getBusinessList().get(i);
+                QuestionBusiness addItem = BeanUtil.toBean(item, QuestionBusiness.class);
+                addItem.setMajorId(add.getQuestionId());
+                addItem.setType(QuestionBusiness.TYPE_QUESTION);
+                coll.add(addItem);
+            }
+            boolean result1 = iQuestionBusinessService.saveBatch(coll);
+        }
+        return add.getQuestionId();
+    }
+
     private boolean checkNameUnique(Question entity) {
         Question info = getOne(new LambdaQueryWrapper<Question>()
                 .eq(Question::getPrefixName, entity.getPrefixName()).eq(Question::getContent, entity.getContent()).ne(Question::getStatus, -1).last("limit 1"));