he2802 2 лет назад
Родитель
Сommit
115464d17e

+ 9 - 4
zhongzheng-api/src/main/java/com/zhongzheng/controller/goods/GoodsController.java

@@ -7,6 +7,7 @@ import com.zhongzheng.common.core.domain.AjaxResult;
 import com.zhongzheng.common.core.page.PageDomain;
 import com.zhongzheng.common.core.page.TableDataInfo;
 import com.zhongzheng.common.core.page.TableSupport;
+import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.framework.web.service.WxTokenService;
 import com.zhongzheng.modules.bank.bo.QuestionChapterExamQueryBo;
@@ -22,6 +23,8 @@ import com.zhongzheng.modules.course.bo.CourseQueryBo;
 import com.zhongzheng.modules.course.service.ICourseSectionService;
 import com.zhongzheng.modules.course.vo.CourseLiveVo;
 import com.zhongzheng.modules.course.vo.CourseSectionVo;
+import com.zhongzheng.modules.exam.domain.ExamPaper;
+import com.zhongzheng.modules.exam.service.IExamPaperService;
 import com.zhongzheng.modules.goods.bo.*;
 import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
@@ -87,7 +90,7 @@ public class GoodsController extends BaseController {
 
     private final IOrderGoodsFreeService iOrderGoodsFreeService;
 
-
+    private final IExamPaperService iExamPaperService;
 
     /**
      * 获取商品详细信息
@@ -165,8 +168,10 @@ public class GoodsController extends BaseController {
         ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
 
         Map<String,Object> numMap = new HashMap<>();
-
-
+        ExamPaper examPaper = iExamPaperService.getOne(new LambdaQueryWrapper<ExamPaper>().eq(ExamPaper::getStatus, 1).eq(ExamPaper::getPaperName,"随机练习").last("limit 1"));
+        if(Validator.isEmpty(examPaper)){
+            throw new CustomException("系统不存在随机练习试卷类型");
+        }
 
         UserExamRecordQueryBo userExamRecordQueryBo = new UserExamRecordQueryBo();
         userExamRecordQueryBo.setOrderGoodsId(orderGoodsId);
@@ -186,7 +191,7 @@ public class GoodsController extends BaseController {
                 .eq(OrderGoods::getOrderGoodsId, orderGoodsId));
         if(Validator.isNotEmpty(orderGoods)){
             Long goodsId = orderGoods.getGoodsId();
-            Long totalNum = iGoodsService.getQuestionNum(goodsId);
+            Long totalNum = iGoodsService.getRandomQuestionNum(goodsId,examPaper.getPaperId());
             numMap.put("totalNum",totalNum);
         }
 

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

@@ -114,6 +114,7 @@ public class ExamTempServiceImpl extends ServiceImpl<ExamTempMapper, ExamTemp> i
         queryBo.setGoodsId(bo.getGoodsId());
         queryBo.setOrderGoodsId(bo.getOrderGoodsId());
         queryBo.setNumber(bo.getNumber());
+        queryBo.setExamPaperId(examPaper.getPaperId());
         List<QuestionVo> questionlist = getQuestionList(queryBo);
 
         add.setExamName(ServletUtils.getEncoded("随机练习试卷-")+bo.getOrderGoodsId());

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/mapper/GoodsMapper.java

@@ -8,6 +8,7 @@ import com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo;
 import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
 import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -28,6 +29,8 @@ public interface GoodsMapper extends BaseMapper<Goods> {
 
     Long getQuestionNum(Long goodsId);
 
+    Long getRandomQuestionNum(@Param("gradeId")Long goodsId,@Param("examPaperId") Long examPaperId);
+
     int queryUpGoods();
 
     List<GoodsVo> selectListToInput(GoodsQueryBo bo);

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/IGoodsService.java

@@ -39,6 +39,8 @@ public interface IGoodsService extends IService<Goods> {
 
 	Long getQuestionNum(Long goodsId);
 
+	Long getRandomQuestionNum(Long goodsId,Long examPaperId);
+
 	Long getExamNum(Long goodsId);
 
 	/**

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java

@@ -253,6 +253,11 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         return baseMapper.getQuestionNum(goodsId);
     }
 
+    @Override
+    public Long getRandomQuestionNum(Long goodsId, Long examPaperId) {
+        return baseMapper.getRandomQuestionNum(goodsId,examPaperId);
+    }
+
     @Override
     public Long getExamNum(Long goodsId) {
         return baseMapper.getExamNum(goodsId);

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/schedule/service/IScheduleService.java

@@ -84,6 +84,12 @@ public interface IScheduleService extends IService<PolyvVideo> {
 
     void longNotReadToTeacher(UserQueryBo bo);
 
+    void noFinishExamToStudentThree(UserQueryBo bo);
+
+    void noFinishExamToStudentFive(UserQueryBo bo);
+
+    void noFinishExamToStudentSeven(UserQueryBo bo);
+
     void wisdomExamSite(UserQueryBo bo);
 
     void refreshToken(UserQueryBo bo);

+ 15 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/schedule/service/impl/ScheduleServiceImpl.java

@@ -2854,6 +2854,21 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
         }
     }
 
+    @Override
+    public void noFinishExamToStudentThree(UserQueryBo bo) {
+
+    }
+
+    @Override
+    public void noFinishExamToStudentFive(UserQueryBo bo) {
+
+    }
+
+    @Override
+    public void noFinishExamToStudentSeven(UserQueryBo bo) {
+
+    }
+
     @Override
     public void wisdomExamSite(UserQueryBo bo) {
         iWisdomService.SiteList(1);

+ 4 - 4
zhongzheng-system/src/main/resources/mapper/modules/bank/ExamTempMapper.xml

@@ -40,12 +40,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         WHERE
                 question_id IN (
                 SELECT
-                    question_id
+                    eq.question_id
                 FROM
-                    exam_question
+                    exam_question eq LEFT JOIN exam e on  eq.exam_id = e.exam_id
                 WHERE
                     find_in_set(
-                            exam_id,(
+                            eq.exam_id,(
                         SELECT
                             concat(
                                     IFNULL((
@@ -83,6 +83,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                                 user_exam_record uer
                             WHERE
                                 order_goods_id = #{orderGoodsId} and do_mode = 2
-                        ))  GROUP BY question_id ) ORDER BY RAND() LIMIT  #{number}
+                        )) and e.exam_paper_id = #{examPaperId}  GROUP BY question_id ) ORDER BY RAND() LIMIT  #{number}
     </select>
 </mapper>

+ 37 - 0
zhongzheng-system/src/main/resources/mapper/modules/goods/GoodsMapper.xml

@@ -566,6 +566,43 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                             IFNULL(( SELECT GROUP_CONCAT(  major_id ) FROM goods_attached WHERE goods_id = #{goodsId} AND type = 3 ), '' ))))
     </select>
 
+    <select id="getRandomQuestionNum" parameterType="map" resultType="Long">
+        SELECT
+            count(DISTINCT  eq.question_id ) question_num
+        FROM
+            exam_question eq LEFT JOIN exam e on  eq.exam_id = e.exam_id
+        WHERE
+            find_in_set(
+                    eq.exam_id,(
+                SELECT
+                    concat(
+                            IFNULL((
+                                       SELECT
+                                           GROUP_CONCAT(  exam_id )
+                                       FROM
+                                           question_chapter_exam
+                                       WHERE
+                                           FIND_IN_SET(chapter_exam_id,
+                                                       (SELECT
+                                                            concat(
+                                                                    IFNULL(( SELECT GROUP_CONCAT(  major_id ) eids FROM goods_attached WHERE goods_id = #{goodsId} AND type = 2 ), '' ),
+                                                                    ',',
+                                                                    IFNULL(
+                                                                            (
+                                                                                SELECT
+                                                                                    GROUP_CONCAT(  chapter_exam_id ) eids2
+                                                                                FROM
+                                                                                    question_module_chapter
+                                                                                WHERE
+                                                                                        module_exam_id IN ( SELECT major_id FROM goods_attached WHERE goods_id = #{goodsId} AND type = 1 )),
+                                                                            ''
+                                                                        ))))),
+                                   ''
+                                ),
+                            ',',
+                            IFNULL(( SELECT GROUP_CONCAT(  major_id ) FROM goods_attached WHERE goods_id = #{goodsId} AND type = 3 ), '' )))) and e.exam_paper_id = #{examPaperId}
+    </select>
+
     <update id="queryUpGoods">
         update goods g set g.goods_status=0 where unix_timestamp(now()) > g.validity_end_time and g.goods_status = 1
     </update>