yangdamao 5 일 전
부모
커밋
de88bc70dd

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/mapper/QuestionMapper.java

@@ -3,6 +3,7 @@ package com.zhongzheng.modules.bank.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.modules.bank.bo.QuestionQueryBo;
 import com.zhongzheng.modules.bank.bo.QuestionWaiBuBo;
+import com.zhongzheng.modules.bank.domain.Exam;
 import com.zhongzheng.modules.bank.domain.Question;
 import com.zhongzheng.modules.bank.vo.QuestionVo;
 import com.zhongzheng.modules.course.bo.CourseQueryBo;
@@ -42,4 +43,6 @@ public interface QuestionMapper extends BaseMapper<Question> {
     Question getQuestionByTenant(@Param("code") String code,@Param("newTenantId") Long newTenantId);
 
     Question getQuestionByWaiBu(QuestionWaiBuBo bo);
+
+    Exam getExamByWaiBu(QuestionWaiBuBo bo);
 }

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

@@ -4648,6 +4648,8 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                 List<String> strings = extractPureText(markdown);
                 questionReset(strings,major,exam);
             }
+
+            Files.delete(Paths.get("result.json"));
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -4671,6 +4673,45 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
         CourseSubject courseSubject = iCourseSubjectService.getOne(new LambdaQueryWrapper<CourseSubject>().in(CourseSubject::getId, subIds).eq(CourseSubject::getSubjectName, majorName).last("limit 1"));
         Long subId = courseSubject.getId();
 
+        //添加试卷
+        Long examId = 0L;
+        QuestionWaiBuBo bo1 = new QuestionWaiBuBo();
+        bo1.setEduId(eduId);
+        bo1.setProId(proId);
+        bo1.setBusinessId(businessId);
+        bo1.setSubId(subId);
+        bo1.setContent(exam);
+        Exam examEntity = baseMapper.getExamByWaiBu(bo1);
+        if (ObjectUtils.isNull(examEntity)){
+            //新增
+            Exam exam2 = new Exam();
+            exam2.setExamName(exam);
+            exam2.setCode(ServletUtils.getEncoded("SJ"));
+            exam2.setCreateTime(DateUtils.getNowTime());
+            exam2.setUpdateTime(DateUtils.getNowTime());
+            exam2.setPrefixName(String.format("外部系统拉取试卷(%s)",DateUtils.getDate()));
+            exam2.setPublishStatus(1L);
+            exam2.setYear(2026L);
+            exam2.setStatus(1);
+            exam2.setDoType(1);
+            //试卷类型ID
+            ExamPaper paper = iExamPaperService.getOne(new LambdaUpdateWrapper<ExamPaper>().eq(ExamPaper::getStatus, 1).eq(ExamPaper::getPaperName, "普通练习").last("limit 1"));
+            exam2.setExamPaperId(paper.getPaperId());
+            iExamService.save(exam2);
+            //业务乘次
+            QuestionBusiness questionBusiness = new QuestionBusiness();
+            questionBusiness.setEducationTypeId(eduId);
+            questionBusiness.setProjectId(proId);
+            questionBusiness.setBusinessId(businessId);
+            questionBusiness.setSubjectId(subId);
+            questionBusiness.setType(2);
+            questionBusiness.setMajorId(exam2.getExamId());
+            iQuestionBusinessService.save(questionBusiness);
+            examId = exam2.getExamId();
+        }else {
+            examId = examEntity.getExamId();
+        }
+
         //题库ID
         Long questionId = 0L;
         //处理题库
@@ -4755,6 +4796,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                 questionBusiness.setType(1);
                 questionBusiness.setMajorId(question.getQuestionId());
                 iQuestionBusinessService.save(questionBusiness);
+                saveExamQuestion(question.getQuestionId(),examId);
             }
 
             //案例题小题
@@ -4875,6 +4917,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                 question.setJsonStr(JSONArray.toJSONString(infoVoList));
                 save(question);
                 questionId = question.getQuestionId();
+                saveExamQuestion(questionId,examId);
             }
 
         }else {
@@ -4907,6 +4950,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                 question.setAnswerQuestion(simpleConvert(answer));
                 save(question);
                 questionId = question.getQuestionId();
+                saveExamQuestion(questionId,examId);
             }
 
             if (bt.contains("多选题")){
@@ -4937,6 +4981,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                 question.setAnswerQuestion(simpleConvert(answer));
                 save(question);
                 questionId = question.getQuestionId();
+                saveExamQuestion(questionId,examId);
             }
 
             if (bt.contains("判断题")){
@@ -4958,6 +5003,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                 question.setAnswerQuestion(answer.contains("错") ? "0":"1");
                 save(question);
                 questionId = question.getQuestionId();
+                saveExamQuestion(questionId,examId);
             }
 
         }
@@ -4976,6 +5022,20 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
 
     }
 
+    private void saveExamQuestion(Long questionId,Long examId){
+        ExamQuestion examQuestion = new ExamQuestion();
+        examQuestion.setExamId(examId);
+        examQuestion.setQuestionId(questionId);
+        //获取最新排序
+        Integer sort = 0;
+        ExamQuestion one = iExamQuestionService.getOne(new LambdaUpdateWrapper<ExamQuestion>().eq(ExamQuestion::getExamId, examId).orderByDesc(ExamQuestion::getSort));
+        if (ObjectUtils.isNotNull(one)){
+            sort = one.getSort() +1;
+        }
+        examQuestion.setSort(sort);
+        iExamQuestionService.save(examQuestion);
+    }
+
     public static String simpleConvert(String letters) {
         String result = letters.toUpperCase()
                 .replaceAll("[^A-E]", "")  // 只保留A-E

+ 18 - 0
zhongzheng-system/src/main/resources/mapper/modules/bank/QuestionMapper.xml

@@ -759,4 +759,22 @@
               LIMIT 1
     </select>
 
+    <select id="getExamByWaiBu" parameterType="com.zhongzheng.modules.bank.bo.QuestionWaiBuBo" resultType="com.zhongzheng.modules.bank.domain.Exam">
+        SELECT
+            q.*
+        FROM
+            `exam` q
+                LEFT JOIN question_business qb ON q.exam_id = qb.major_id
+        WHERE
+            q.`status` = 1
+          AND qb.type = 2
+          AND qb.education_type_id = #{eduId}
+          AND qb.project_id = #{proId}
+          AND qb.business_id = #{businessId}
+          AND qb.subject_id = #{subId}
+          AND q.exam_name = #{content}
+            ORDER BY q.create_time DESC
+            LIMIT 1
+    </select>
+
 </mapper>