浏览代码

代码优化

xdd 2 月之前
父节点
当前提交
e39d46ad39

+ 20 - 10
fs-company/src/main/java/com/fs/course/controller/FsCourseWatchLogController.java

@@ -1,6 +1,7 @@
 package com.fs.course.controller;
 
 import com.fs.common.annotation.Log;
+import com.fs.common.constant.HttpStatus;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.page.TableDataInfo;
@@ -26,6 +27,7 @@ import com.fs.qw.service.IQwWatchLogService;
 import com.fs.qw.vo.QwWatchLogAllStatisticsListVO;
 import com.fs.qw.vo.QwWatchLogStatisticsListVO;
 import com.fs.sop.mapper.SopUserLogsMapper;
+import com.github.pagehelper.PageInfo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -58,18 +60,21 @@ public class FsCourseWatchLogController extends BaseController
     @GetMapping("/list")
     public TableDataInfo list(FsCourseWatchLogListParam param)
     {
-        startPage();
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         param.setCompanyId( loginUser.getCompany().getCompanyId());
         List<FsCourseWatchLogListVO> list = fsCourseWatchLogService.selectFsCourseWatchLogListVO(param);
-        return getDataTable(list);
+        TableDataInfo rspData = new TableDataInfo();
+        rspData.setCode(HttpStatus.SUCCESS);
+        rspData.setMsg("查询成功");
+        rspData.setRows(list);
+        rspData.setTotal(fsCourseWatchLogService.selectFsCourseWatchLogListVOCount(param));
+        return rspData;
     }
 
     @PreAuthorize("@ss.hasPermi('course:courseWatchLog:statisticsList')")
     @GetMapping("/statisticsList")
     public TableDataInfo statisticsList(FsCourseWatchLogStatisticsListParam param)
     {
-        startPage();
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         param.setCompanyId( loginUser.getCompany().getCompanyId());
         if (param.getSTime()==null||param.getETime()==null){
@@ -88,7 +93,7 @@ public class FsCourseWatchLogController extends BaseController
         if (param.getSTime()==null||param.getETime()==null){
             return getDataTable(new ArrayList<>());
         }
-        List<QwWatchLogStatisticsListVO> list = qwWatchLogService.selectQwWatchLogStatisticsListVONew(param);
+        List<QwWatchLogStatisticsListVO> list = qwWatchLogService.selectQwWatchLogStatisticsListVO(param);
         return getDataTable(list);
     }
     @GetMapping("/myQwWatchLogStatisticsList")
@@ -101,7 +106,7 @@ public class FsCourseWatchLogController extends BaseController
         if (param.getSTime()==null||param.getETime()==null){
             return getDataTable(new ArrayList<>());
         }
-        List<QwWatchLogStatisticsListVO> list = qwWatchLogService.selectQwWatchLogStatisticsListVONew(param);
+        List<QwWatchLogStatisticsListVO> list = qwWatchLogService.selectQwWatchLogStatisticsListVO(param);
         return getDataTable(list);
     }
 
@@ -115,7 +120,7 @@ public class FsCourseWatchLogController extends BaseController
         if (param.getSTime()==null||param.getETime()==null){
             return getDataTable(new ArrayList<>());
         }
-        List<QwWatchLogAllStatisticsListVO> list = qwWatchLogService.selectQwWatchLogAllStatisticsListVONew(param);
+        List<QwWatchLogAllStatisticsListVO> list = qwWatchLogService.selectQwWatchLogAllStatisticsListVO(param);
         return getDataTable(list);
     }
     @GetMapping("/myQwWatchLogAllStatisticsList")
@@ -128,7 +133,7 @@ public class FsCourseWatchLogController extends BaseController
         if (param.getSTime()==null||param.getETime()==null){
             return getDataTable(new ArrayList<>());
         }
-        List<QwWatchLogAllStatisticsListVO> list = qwWatchLogService.selectQwWatchLogAllStatisticsListVONew(param);
+        List<QwWatchLogAllStatisticsListVO> list = qwWatchLogService.selectQwWatchLogAllStatisticsListVO(param);
         return getDataTable(list);
     }
     @GetMapping("/watchLogStatistics")
@@ -184,7 +189,12 @@ public class FsCourseWatchLogController extends BaseController
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         param.setCompanyId( loginUser.getCompany().getCompanyId());
         List<FsCourseWatchLogListVO> list = fsCourseWatchLogService.selectFsCourseWatchLogListVO(param);
-        return getDataTable(list);
+        TableDataInfo rspData = new TableDataInfo();
+        rspData.setCode(HttpStatus.SUCCESS);
+        rspData.setMsg("查询成功");
+        rspData.setRows(list);
+        rspData.setTotal(fsCourseWatchLogService.selectFsCourseWatchLogListVOCount(param));
+        return rspData;
     }
 
     /**
@@ -195,7 +205,7 @@ public class FsCourseWatchLogController extends BaseController
     @GetMapping("/export")
     public AjaxResult export(FsCourseWatchLogListParam param)
     {
-        List<FsCourseWatchLogListVO> list = fsCourseWatchLogService.selectFsCourseWatchLogListVOExport(param);
+        List<FsCourseWatchLogListVO> list = fsCourseWatchLogService.selectFsCourseWatchLogListVO(param);
         ExcelUtil<FsCourseWatchLogListVO> util = new ExcelUtil<FsCourseWatchLogListVO>(FsCourseWatchLogListVO.class);
         return util.exportExcel(list, "短链课程看课记录数据");
     }
@@ -210,7 +220,7 @@ public class FsCourseWatchLogController extends BaseController
     {
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         param.setCompanyId( loginUser.getCompany().getCompanyId());
-        List<FsCourseWatchLogListVO> list = fsCourseWatchLogService.selectFsCourseWatchLogListVOExport(param);
+        List<FsCourseWatchLogListVO> list = fsCourseWatchLogService.selectFsCourseWatchLogListVO(param);
         ExcelUtil<FsCourseWatchLogListVO> util = new ExcelUtil<FsCourseWatchLogListVO>(FsCourseWatchLogListVO.class);
         return util.exportExcel(list, "短链课程看课记录数据");
     }

+ 1 - 1
fs-service-system/src/main/java/com/fs/company/cache/impl/CompanyUserCacheServiceImpl.java

@@ -23,7 +23,7 @@ public class CompanyUserCacheServiceImpl implements ICompanyUserCacheService {
 
     private static final Cache<Long, CompanyUser> USER_CACHE = Caffeine.newBuilder()
             .maximumSize(1000)
-            .expireAfterWrite(10, TimeUnit.SECONDS)
+            .expireAfterWrite(3, TimeUnit.MINUTES)
             .build();
     @Override
     public CompanyUser selectCompanyUserById(Long userId) {

+ 1 - 1
fs-service-system/src/main/java/com/fs/company/cache/impl/ICompanyCacheServiceImpl.java

@@ -19,7 +19,7 @@ public class ICompanyCacheServiceImpl implements ICompanyCacheService {
 
     private static final Cache<Long, Company> COMPANY_CACHE = Caffeine.newBuilder()
             .maximumSize(1000)
-            .expireAfterWrite(10, TimeUnit.SECONDS)
+            .expireAfterWrite(3, TimeUnit.MINUTES)
             .build();
     @Override
     public Company selectCompanyById(Long companyId) {

+ 1 - 0
fs-service-system/src/main/java/com/fs/course/mapper/FsCourseWatchLogMapper.java

@@ -125,6 +125,7 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
 
     List<FsCourseWatchLogListVO> selectFsCourseWatchLogListVO(@Param("maps") FsCourseWatchLogListParam param);
     List<FsCourseWatchLogListVO> selectFsCourseWatchLogListVONew(@Param("maps") FsCourseWatchLogListParam param);
+    Long selectFsCourseWatchLogListVONewCount(@Param("maps") FsCourseWatchLogListParam param);
 
     List<FsCourseWatchLogListVO> selectFsCourseWatchLogListByParam(FsCourseWatchLogListParam param);
 

+ 2 - 0
fs-service-system/src/main/java/com/fs/course/param/FsCourseWatchLogListParam.java

@@ -49,4 +49,6 @@ public class FsCourseWatchLogListParam implements Serializable {
     private String scheduleEndTime;
 
     private List<String> sopIds;
+    private Long pageNum;
+    private Long pageSize;
 }

+ 1 - 0
fs-service-system/src/main/java/com/fs/course/service/IFsCourseWatchLogService.java

@@ -81,6 +81,7 @@ public interface IFsCourseWatchLogService extends IService<FsCourseWatchLog> {
 
 
     List<FsCourseWatchLogListVO> selectFsCourseWatchLogListVO(FsCourseWatchLogListParam param);
+    Long selectFsCourseWatchLogListVOCount(FsCourseWatchLogListParam param);
     List<FsCourseWatchLogListVO> selectFsCourseWatchLogListVOExport(FsCourseWatchLogListParam param);
 
     List<FsCourseWatchLogListVO> selectFsCourseWatchLogListByParam(FsCourseWatchLogListParam param);

+ 1 - 1
fs-service-system/src/main/java/com/fs/course/service/cache/impl/FsUserCourseVideoCacheServiceImpl.java

@@ -21,7 +21,7 @@ public class FsUserCourseVideoCacheServiceImpl implements IFsUserCourseVideoCach
     private final IFsUserCourseVideoService fsUserCourseVideoService;
     private static final Cache<Long, FsUserCourseVideo> VIDEO_CACHE = Caffeine.newBuilder()
             .maximumSize(1000)
-            .expireAfterWrite(10, TimeUnit.MINUTES)
+            .expireAfterWrite(3, TimeUnit.MINUTES)
             .build();
 
     @Override

+ 6 - 0
fs-service-system/src/main/java/com/fs/course/service/impl/FsCourseWatchLogServiceImpl.java

@@ -272,6 +272,12 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
         return list;
     }
 
+    @Override
+    public Long selectFsCourseWatchLogListVOCount(FsCourseWatchLogListParam param) {
+
+        return fsCourseWatchLogMapper.selectFsCourseWatchLogListVONewCount(param);
+    }
+
     @Override
     public List<FsCourseWatchLogListVO> selectFsCourseWatchLogListVOExport(FsCourseWatchLogListParam param) {
         return fsCourseWatchLogMapper.selectFsCourseWatchLogListVO(param);

+ 1 - 1
fs-service-system/src/main/java/com/fs/store/service/cache/impl/FsUserCourseCacheServiceImpl.java

@@ -19,7 +19,7 @@ public class FsUserCourseCacheServiceImpl implements IFsUserCourseCacheService {
     private final IFsUserCourseService fsUserCourseService;
     private static final Cache<Long, FsUserCourse> FS_USER_COURSE_CACHE = Caffeine.newBuilder()
             .maximumSize(1000)
-            .expireAfterWrite(3, TimeUnit.MINUTES)
+            .expireAfterWrite(1, TimeUnit.MINUTES)
             .build();
     @Override
     public FsUserCourse selectFsUserCourseByCourseId(Long courseId) {

+ 72 - 21
fs-service-system/src/main/resources/mapper/course/FsCourseWatchLogMapper.xml

@@ -489,11 +489,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ORDER BY o.video_id ,DATE(o.create_time)
     </select>
     <select id="selectFsCourseWatchLogListVONew" resultType="com.fs.course.vo.FsCourseWatchLogListVO">
-        select l.log_id,
-        l.project as project,
+        SELECT
+        l.log_id,
+        l.project AS project,
         l.user_id,
         l.log_type,
-        SEC_TO_TIME(l.duration) as duration,
+        SEC_TO_TIME(l.duration) AS duration,
         l.camp_period_time,
         l.finish_time,
         l.send_type,
@@ -504,31 +505,81 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         l.company_user_id,
         l.course_id,
         l.video_id
-        from fs_course_watch_log l
+        FROM
+        fs_course_watch_log l
+        INNER JOIN (
+        SELECT log_id
+        FROM fs_course_watch_log
         <where>
-            <if test ='maps.userId !=null'>
-                and l.user_id = #{maps.userId}
+            <if test='maps.userId != null'>
+                AND user_id = #{maps.userId}
             </if>
-            <if test ='maps.qwExternalContactId !=null'>
-                and l.qw_external_contact_id = #{maps.qwExternalContactId}
+            <if test='maps.courseId != null'>
+                AND course_id = #{maps.courseId}
             </if>
-            <if test ='maps.qwUserId !=null'>
-                and l.qw_user_id = #{maps.qwUserId}
+            <if test='maps.videoId != null'>
+                AND video_id = #{maps.videoId}
             </if>
-            <if test ='maps.courseId !=null'>
-                and l.course_id = #{maps.courseId}
+            <if test='maps.logType != null'>
+                AND log_type = #{maps.logType}
             </if>
-            <if test ='maps.videoId !=null'>
-                and l.video_id = #{maps.videoId}
+            <if test='maps.companyId != null'>
+                AND company_id = #{maps.companyId}
             </if>
-            <if test ='maps.logType !=null'>
-                and l.log_type = #{maps.logType}
+            <if test='maps.companyUserId != null'>
+                AND company_user_id = #{maps.companyUserId}
             </if>
-            <if test ='maps.companyId !=null'>
-                and l.company_id = #{maps.companyId}
+            <if test= 'maps.sTime != null '>
+                and DATE(l.create_time) &gt;= DATE(#{maps.sTime})
             </if>
-            <if test ='maps.companyUserId !=null'>
-                and l.company_user_id = #{maps.companyUserId}
+            <if test='maps.eTime != null '>
+                and DATE(l.create_time) &lt;= DATE(#{maps.eTime})
+            </if>
+            <if test= 'maps.scheduleStartTime != null '>
+                and DATE(l.camp_period_time) &gt;= DATE(#{maps.scheduleStartTime})
+            </if>
+            <if test='maps.scheduleEndTime != null '>
+                and DATE(l.camp_period_time) &lt;= DATE(#{maps.scheduleEndTime})
+            </if>
+            <if test= 'maps.upSTime != null '>
+                and DATE(l.update_time) &gt;= DATE(#{maps.upSTime})
+            </if>
+            <if test='maps.upETime != null '>
+                and DATE(l.update_time) &lt;= DATE(#{maps.upETime})
+            </if>
+            <if test="maps.sopIds != null and maps.sopIds.size() > 0">
+            and l.sop_id in
+                AND sop_id IN
+                <foreach item="sopId" index="index" collection="maps.sopIds" open="(" separator="," close=")">
+                    #{sopId}
+                </foreach>
+            </if>
+        </where>
+        ORDER BY log_id DESC
+        LIMIT ${(maps.pageNum-1)*maps.pageSize}, ${maps.pageSize}
+        ) AS page_ids ON l.log_id = page_ids.log_id
+    </select>
+    <select id="selectFsCourseWatchLogListVONewCount" resultType="java.lang.Long">
+        SELECT count(log_id)
+        FROM fs_course_watch_log
+        <where>
+            <if test='maps.userId != null'>
+                AND user_id = #{maps.userId}
+            </if>
+            <if test='maps.courseId != null'>
+                AND course_id = #{maps.courseId}
+            </if>
+            <if test='maps.videoId != null'>
+                AND video_id = #{maps.videoId}
+            </if>
+            <if test='maps.logType != null'>
+                AND log_type = #{maps.logType}
+            </if>
+            <if test='maps.companyId != null'>
+                AND company_id = #{maps.companyId}
+            </if>
+            <if test='maps.companyUserId != null'>
+                AND company_user_id = #{maps.companyUserId}
             </if>
             <if test= 'maps.sTime != null '>
                 and DATE(l.create_time) &gt;= DATE(#{maps.sTime})
@@ -550,11 +601,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             </if>
             <if test="maps.sopIds != null and maps.sopIds.size() > 0">
                 and l.sop_id in
+                AND sop_id IN
                 <foreach item="sopId" index="index" collection="maps.sopIds" open="(" separator="," close=")">
                     #{sopId}
                 </foreach>
             </if>
         </where>
-        order by l.log_id desc
     </select>
 </mapper>