he2802 2 anni fa
parent
commit
79e6c8037a

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/QuestionOtherAddBo.java

@@ -42,4 +42,5 @@ public class QuestionOtherAddBo {
     /** 试卷ID */
     @ApiModelProperty("试卷ID")
     private Long examId;
+    private Long relExamId;
 }

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/domain/QuestionOther.java

@@ -44,4 +44,5 @@ private static final long serialVersionUID=1L;
     private Integer fromPlat;
     /** 试卷ID */
     private Long examId;
+    private Long relExamId;
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/IExamService.java

@@ -60,5 +60,5 @@ public interface IExamService extends IService<Exam> {
 
     Exam getExamByTenant(String code, Long newTenantId);
 
-	boolean getShanDongExam(Long userId,String majorname);
+	boolean getShanDongExam(Long userId,String majorname,Long relExamId);
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/IQuestionOtherService.java

@@ -24,7 +24,7 @@ public interface IQuestionOtherService extends IService<QuestionOther> {
 	 */
 	QuestionOtherVo queryById(Long id);
 
-	Long queryByUserMajor(Long userId,String majorname);
+	Long queryByUserMajor(Long userId,String majorname,Long relExamId);
 
 	/**
 	 * 查询列表

+ 14 - 7
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/ExamServiceImpl.java

@@ -21,10 +21,7 @@ import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.common.utils.ToolsUtils;
 import com.zhongzheng.common.utils.http.HttpUtils;
 import com.zhongzheng.modules.bank.bo.*;
-import com.zhongzheng.modules.bank.domain.Exam;
-import com.zhongzheng.modules.bank.domain.ExamQuestion;
-import com.zhongzheng.modules.bank.domain.QuestionBusiness;
-import com.zhongzheng.modules.bank.domain.QuestionChapterExam;
+import com.zhongzheng.modules.bank.domain.*;
 import com.zhongzheng.modules.bank.mapper.ExamMapper;
 import com.zhongzheng.modules.bank.service.*;
 import com.zhongzheng.modules.bank.vo.ExamVo;
@@ -353,7 +350,7 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
     }
 
     @Override
-    public boolean getShanDongExam(Long userId,String majorname) {
+    public boolean getShanDongExam(Long userId,String majorname,Long relExamId) {
         Boolean getNew = false;
         User user = iUserService.getOne(new LambdaQueryWrapper<User>()
                 .eq(User::getUserId, userId).last("limit 1"));
@@ -380,8 +377,9 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
                 QuestionOtherAddBo addBo = new QuestionOtherAddBo();
                 addBo.setJsonStr(respone);
                 addBo.setFromPlat(1);
-                addBo.setUserId(1L);
+                addBo.setUserId(userId);
                 addBo.setMajorname(majorname);
+                addBo.setRelExamId(relExamId);
                 Long id = iQuestionOtherService.insertByAddBo(addBo);
                 iQuestionOtherService.queryById(id);
         //        System.out.println(respone);
@@ -389,7 +387,16 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
                 throw new CustomException("同步请求错误" + e.getMessage());
             }
         }else{
-
+            QuestionOther add = iQuestionOtherService.getOne(new LambdaQueryWrapper<QuestionOther>()
+                    .eq(QuestionOther::getId, 3L).last("limit 1"));
+            if(Validator.isEmpty(add)){
+                throw new CustomException("模拟数据不存在");
+            }
+            add.setUserId(userId);
+            add.setMajorname(majorname);
+            add.setRelExamId(relExamId);
+            add.setId(null);
+            iQuestionOtherService.save(add);
         }
 
         return false;

+ 9 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionOtherServiceImpl.java

@@ -182,9 +182,16 @@ public class QuestionOtherServiceImpl extends ServiceImpl<QuestionOtherMapper, Q
     }
 
     @Override
-    public Long queryByUserMajor(Long userId, String majorname) {
+    public Long queryByUserMajor(Long userId, String majorname,Long relExamId) {
         QuestionOther questionOther = getOne(new LambdaQueryWrapper<QuestionOther>()
-                .eq(QuestionOther::getUserId, userId).eq(QuestionOther::getMajorname, majorname)
+                .eq(QuestionOther::getUserId, userId).eq(QuestionOther::getMajorname, majorname).eq(QuestionOther::getRelExamId, relExamId)
+                .eq(QuestionOther::getStatus, 1));
+        if(Validator.isNotEmpty(questionOther)){
+            return questionOther.getExamId();
+        }
+        iExamService.getShanDongExam(userId,majorname, relExamId);
+        questionOther = getOne(new LambdaQueryWrapper<QuestionOther>()
+                .eq(QuestionOther::getUserId, userId).eq(QuestionOther::getMajorname, majorname).eq(QuestionOther::getRelExamId, relExamId)
                 .eq(QuestionOther::getStatus, 1));
         if(Validator.isNotEmpty(questionOther)){
             return questionOther.getExamId();

+ 7 - 5
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsQuestionRelExamServiceImpl.java

@@ -158,18 +158,20 @@ public class GoodsQuestionRelExamServiceImpl extends ServiceImpl<GoodsQuestionRe
         }
         Major major = iMajorService.getOne(new LambdaQueryWrapper<Major>()
                 .eq(Major::getId, goods.getMajorId()));
-        Long examId = iQuestionOtherService.queryByUserMajor(bo.getUserId(),major.getCategoryName());
-        if(Validator.isEmpty(examId)){
-            throw new CustomException("试卷不存在");
-        }
         questionRel.setQuestionDoNum(questionRel.getQuestionDoNum()-1);
         questionRel.setUpdateTime(DateUtils.getNowTime());
         iGoodsQuestionRelService.updateById(questionRel);
         add.setExpTime(qsOrderGoods.getServiceEndTime());
-        add.setExamId(examId);
+    //    add.setExamId(examId);
         add.setStatus(1);
         add.setUserSubscribeId(userSubscribe.getSubscribeId());
         this.save(add);
+        Long examId = iQuestionOtherService.queryByUserMajor(bo.getUserId(),major.getCategoryName(),add.getId());
+        if(Validator.isEmpty(examId)){
+            throw new CustomException("试卷获取失败");
+        }
+        add.setExamId(examId);
+        updateById(add);
         return BeanUtil.toBean(add,GoodsQuestionRelExamVo.class);
     }