Browse Source

fix 考试安排

he2802 3 years ago
parent
commit
430caff3ca

+ 14 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/order/OrderGoodsController.java

@@ -9,7 +9,10 @@ import com.zhongzheng.modules.order.bo.OrderGoodsEditBo;
 import com.zhongzheng.modules.order.bo.OrderGoodsQueryBo;
 import com.zhongzheng.modules.order.service.IOrderGoodsService;
 import com.zhongzheng.modules.order.vo.OrderGoodsVo;
+import com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo;
 import com.zhongzheng.modules.user.entity.ClientLoginUser;
+import com.zhongzheng.modules.user.service.IUserStudyRecordService;
+import com.zhongzheng.modules.user.vo.SectionStudyRecordVo;
 import lombok.RequiredArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -44,6 +47,8 @@ public class OrderGoodsController extends BaseController {
 
     private final IOrderGoodsService iOrderGoodsService;
 
+    private final IUserStudyRecordService iUserStudyRecordService;
+
     /**
      * 查询订单商品列表
      */
@@ -153,4 +158,13 @@ public class OrderGoodsController extends BaseController {
         List<OrderGoodsVo> list = iOrderGoodsService.listLiveGoodsList(bo);
         return getDataTable(list);
     }
+
+    @ApiOperation("直播商品的用户学习列表")
+    @PreAuthorize("@ss.hasPermi('system:invoice:list')")
+    @GetMapping("/userSectionLiveList")
+    public TableDataInfo<SectionStudyRecordVo> userSectionLiveList(UserStudyRecordQueryBo bo) {
+        startPage();
+        List<SectionStudyRecordVo> list = iUserStudyRecordService.userSectionLiveList(bo);
+        return getDataTable(list);
+    }
 }

+ 2 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/user/UserStudyRecordController.java

@@ -142,4 +142,6 @@ public class UserStudyRecordController extends BaseController {
         bo.setUserId(loginUser.getUser().getUserId());
         return AjaxResult.success(iUserStudyRecordService.getLastLive(bo));
     }
+
+
 }

+ 9 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/impl/ExamBeforeApplyServiceImpl.java

@@ -1,7 +1,9 @@
 package com.zhongzheng.modules.exam.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
+import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.modules.course.domain.CourseChapterBusiness;
 import com.zhongzheng.modules.course.domain.CourseChapterSection;
@@ -17,6 +19,7 @@ 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 org.springframework.transaction.annotation.Transactional;
 
 import java.util.Collection;
 import java.util.Collections;
@@ -73,10 +76,16 @@ public class ExamBeforeApplyServiceImpl extends ServiceImpl<ExamBeforeApplyMappe
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Boolean insertByAddBo(ExamBeforeApplyAddBo bo) {
         remove(new LambdaQueryWrapper<ExamBeforeApply>().eq(ExamBeforeApply::getBeforeId, bo.getBeforeId()));
         Collection<ExamBeforeApply> coll = new HashSet<>();
         for(Long applyId : bo.getApplyIds()){
+            //考试安排只能被一个前培绑定
+            ExamBeforeApply apply = getOne(new LambdaQueryWrapper<ExamBeforeApply>().eq(ExamBeforeApply::getApplyId, applyId));
+            if(Validator.isNotEmpty(apply)){
+                throw new CustomException("考试计划ID"+applyId+"已被绑定");
+            }
             ExamBeforeApply add = new ExamBeforeApply();
             add.setBeforeId(bo.getBeforeId());
             add.setApplyId(applyId);

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserStudyRecordMapper.java

@@ -82,4 +82,6 @@ public interface UserStudyRecordMapper extends BaseMapper<UserStudyRecord> {
     List<SectionStudyRecordVo> listUserRecord(UserStudyRecordQueryBo bo);
 
     SectionStudyRecordVo getLastLive(UserStudyRecordQueryBo bo);
+
+    List<SectionStudyRecordVo> userSectionLiveList(UserStudyRecordQueryBo bo);
 }

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserStudyRecordService.java

@@ -90,4 +90,5 @@ public interface IUserStudyRecordService extends IService<UserStudyRecord> {
 
 	SectionStudyRecordVo getLastLive(UserStudyRecordQueryBo bo) throws Exception;
 
+	List<SectionStudyRecordVo> userSectionLiveList(UserStudyRecordQueryBo bo);
 }

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserStudyRecordServiceImpl.java

@@ -535,6 +535,11 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
         return recordVo;
     }
 
+    @Override
+    public List<SectionStudyRecordVo> userSectionLiveList(UserStudyRecordQueryBo bo) {
+        return this.baseMapper.userSectionLiveList(bo);
+    }
+
 
     //判断当前未看完的节是否是点击播放的节
     private boolean compareSection(UserStudyRecordVo recordVo,UserStudyRecordQueryBo entity){

+ 21 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/SectionStudyRecordVo.java

@@ -1,5 +1,6 @@
 package com.zhongzheng.modules.user.vo;
 
+import com.zhongzheng.common.annotation.Excel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -86,4 +87,24 @@ public class SectionStudyRecordVo {
     private String liveUrl;
     @ApiModelProperty("频道的观看页状态,取值为:live(直播中)、end(直播结束)、playback(回放中)、waiting(等待直播)")
     private String watchStatus;
+    /** 用户ID */
+    @Excel(name = "用户ID ")
+    @ApiModelProperty("用户ID")
+    private Long userId;
+    @ApiModelProperty("身份证")
+    private String idCard;
+    @ApiModelProperty("姓名")
+    private String realname;
+    /** 保利威真实直播时长,单位秒 */
+    @Excel(name = "保利威真实直播时长,单位秒")
+    @ApiModelProperty("保利威真实直播时长,单位秒")
+    private Long realDuration;
+    /** 用户初次学习开始时间 */
+    @Excel(name = "用户初次学习开始时间")
+    @ApiModelProperty("用户初次学习开始时间")
+    private Long firstStartTime;
+    /** 学习时长 */
+    @Excel(name = "学习时长")
+    @ApiModelProperty("学习时长")
+    private Long studyDuration;
 }

+ 2 - 2
zhongzheng-system/src/main/resources/mapper/modules/exam/ExamBeforeMapper.xml

@@ -193,8 +193,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             b.before_id
         FROM
             user_subscribe us
-                LEFT JOIN exam_before_goods bg ON us.goods_id = bg.goods_id
-                LEFT JOIN exam_before b ON bg.before_id = b.before_id
+                LEFT JOIN exam_before_apply ba ON us.apply_id = ba.apply_id
+                LEFT JOIN exam_before b ON ba.before_id = b.before_id
                 AND b.`status` = 1
         WHERE
             us.subscribe_status = 1

+ 42 - 2
zhongzheng-system/src/main/resources/mapper/modules/user/UserStudyRecordMapper.xml

@@ -83,6 +83,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="gradeId" column="grade_id"/>
         <result property="orderGoodsId" column="order_goods_id"/>
         <result property="liveUrl" column="live_url"/>
+        <result property="userId" column="user_id"/>
+        <result property="realname" column="realname"/>
+        <result property="idCard" column="id_card"/>
+        <result property="realDuration" column="real_duration"/>
+        <result property="firstStartTime" column="first_start_time"/>
+        <result property="studyDuration" column="study_duration"/>
     </resultMap>
 
     <resultMap type="com.zhongzheng.modules.user.vo.ExamStudyRecordVo" id="ExamStudyRecordVoResult">
@@ -1250,12 +1256,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 LEFT JOIN course_section cs ON usr.section_id = cs.section_id
         WHERE
             cs.section_type = 2
-          AND usr.goods_id = #{goodsId}
           AND usr.user_id = #{userId}
-          AND usr.grade_id = #{gradeId}
+          AND usr.order_goods_id = #{orderGoodsId}
           AND usr.course_id = #{courseId}
         ORDER BY
             usr.update_time
             LIMIT 1
     </select>
+
+    <select id="userSectionLiveList" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo" resultMap="SectionStudyRecordVoResult">
+        SELECT
+            r.*,
+            cs.section_type,
+            cs.real_duration,
+            u.realname,
+            u.id_card,
+            cs.`name`,
+            cm.module_name,
+            cc.chapter_id
+        FROM
+            (
+                SELECT
+                    usr.module_id,
+                    usr.chapter_id,
+                    usr.section_id,
+                    usr.user_id,
+                    sum( usr.study_duration ) study_duration,
+                    MIN( usr.first_start_time ) first_start_time
+                FROM
+                    user_study_record usr
+                WHERE
+                    usr.order_goods_id = #{orderGoodsId}
+                GROUP BY
+                    usr.module_id,
+                    usr.chapter_id,
+                    usr.section_id,
+                    usr.user_id
+            ) r
+                LEFT JOIN course_section cs ON r.section_id = cs.section_id
+                LEFT JOIN `user` u ON r.user_id = u.user_id
+                LEFT JOIN course_module cm ON r.module_id = cm.module_id
+                LEFT JOIN course_chapter cc ON r.chapter_id = cc.chapter_id
+    </select>
 </mapper>