Procházet zdrojové kódy

看课流量统计改成按时间范围

xdd před 1 měsícem
rodič
revize
a78827eec2

+ 0 - 12
fs-admin/src/main/java/com/fs/course/controller/FsCourseTrafficLogController.java

@@ -51,18 +51,6 @@ public class FsCourseTrafficLogController extends BaseController
     public TableDataInfo list(FsCourseTrafficLogParam param)
     {
         startPage();
-        if(ObjectUtils.isNotNull(param.getTime())){
-
-            YearMonth yearMonth = param.getTime();
-            LocalDateTime startOfMonth = yearMonth.atDay(1).atStartOfDay();
-
-            LocalDateTime startOfNextMonth = yearMonth.plusMonths(1).atDay(1).atStartOfDay()
-                    .minusDays(1).withHour(23).withMinute(59).withSecond(59);
-            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-
-            param.setStartDate(startOfMonth.format(formatter));
-            param.setEndDate(startOfNextMonth.format(formatter));
-        }
         List<FsCourseTrafficLogListVO> list = fsCourseTrafficLogService.selectTrafficNew(param);
         return getDataTable(list);
     }

+ 0 - 4
fs-admin/src/main/java/com/fs/course/controller/FsCourseWatchLogController.java

@@ -60,7 +60,6 @@ public class FsCourseWatchLogController extends BaseController
     @GetMapping("/list")
     public TableDataInfo list(FsCourseWatchLogListParam param)
     {
-        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         List<FsCourseWatchLogListVO> list = fsCourseWatchLogService.selectFsCourseWatchLogListVONew(param);
         TableDataInfo rspData = new TableDataInfo();
         rspData.setCode(HttpStatus.SUCCESS);
@@ -164,7 +163,6 @@ public class FsCourseWatchLogController extends BaseController
     public TableDataInfo userStatisticsList(FsCourseUserStatisticsListParam param)
     {
         startPage();
-        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         if (param.getSTime()==null||param.getETime()==null){
             return getDataTable(new ArrayList<>());
         }
@@ -181,7 +179,6 @@ public class FsCourseWatchLogController extends BaseController
     @GetMapping("/myList")
     public TableDataInfo myList(FsCourseWatchLogListParam param)
     {
-        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         List<FsCourseWatchLogListVO> list = fsCourseWatchLogService.selectFsCourseWatchLogListVONew(param);
         TableDataInfo rspData = new TableDataInfo();
         rspData.setCode(HttpStatus.SUCCESS);
@@ -212,7 +209,6 @@ public class FsCourseWatchLogController extends BaseController
     @GetMapping("/myExport")
     public AjaxResult myExport(FsCourseWatchLogListParam param)
     {
-        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         List<FsCourseWatchLogListVO> list = fsCourseWatchLogService.selectFsCourseWatchLogListVO(param);
         ExcelUtil<FsCourseWatchLogListVO> util = new ExcelUtil<FsCourseWatchLogListVO>(FsCourseWatchLogListVO.class);
         return util.exportExcel(list, "短链课程看课记录数据");

+ 0 - 15
fs-company/src/main/java/com/fs/course/controller/FsCourseTrafficLogController.java

@@ -54,21 +54,6 @@ public class FsCourseTrafficLogController extends BaseController
     public TableDataInfo list(FsCourseTrafficLogParam param)
     {
         startPage();
-        if(ObjectUtils.isNotNull(param.getTime())){
-
-            YearMonth yearMonth = param.getTime();
-            LocalDateTime startOfMonth = yearMonth.atDay(1).atStartOfDay();
-
-            LocalDateTime startOfNextMonth = yearMonth.plusMonths(1).atDay(1).atStartOfDay()
-                    .minusDays(1).withHour(23).withMinute(59).withSecond(59);
-            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-
-            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
-            param.setCompanyId( loginUser.getCompany().getCompanyId());
-
-            param.setStartDate(startOfMonth.format(formatter));
-            param.setEndDate(startOfNextMonth.format(formatter));
-        }
         List<FsCourseTrafficLogListVO> list = fsCourseTrafficLogService.selectTrafficNew(param);
         return getDataTable(list);
     }

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

@@ -201,7 +201,7 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
             "LEFT JOIN qw_user qu on qu.id=o.qw_user_id\n" +
             "LEFT JOIN fs_user_course_video v on v.video_id=o.video_id \n" +
             "LEFT JOIN fs_user_course uc on uc.course_id=v.course_id\n" +
-            "where o.company_id=#{companyId}  " +
+            "where o.company_id=#{companyId} AND send_type=2 " +
             "<if test= 'sTime != null '> " +
             "       and DATE(o.create_time) &gt;= DATE(#{sTime})\n" +
             "</if>\n" +

+ 4 - 0
fs-service-system/src/main/java/com/fs/course/service/impl/FsCourseTrafficLogServiceImpl.java

@@ -4,6 +4,7 @@ import java.util.Collections;
 import java.util.List;
 
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.fs.common.exception.CustomException;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.DictUtils;
 import com.fs.company.cache.ICompanyCacheService;
@@ -138,6 +139,9 @@ public class FsCourseTrafficLogServiceImpl implements IFsCourseTrafficLogService
 
     @Override
     public List<FsCourseTrafficLogListVO> selectTrafficNew(FsCourseTrafficLogParam param) {
+        if(StringUtils.isBlank(param.getStartDate()) && StringUtils.isBlank(param.getEndDate())){
+            throw new CustomException("搜索必须要一个时间范围!");
+        }
         List<FsCourseTrafficLogListVO> fsCourseTrafficLogListVOS = fsCourseTrafficLogMapper.selectTrafficNew(param);
         for (FsCourseTrafficLogListVO log : fsCourseTrafficLogListVOS) {
             if (ObjectUtils.isNotNull(log.getProject())) {

+ 12 - 5
fs-service-system/src/main/java/com/fs/qw/service/impl/QwWatchLogServiceImpl.java

@@ -166,13 +166,20 @@ public class QwWatchLogServiceImpl extends ServiceImpl<QwWatchLogMapper, QwWatch
 
     @Override
     public TableDataInfo selectQwWatchLogStatisticsListVONew(QwWatchLogStatisticsListParam param) {
+        List<Long> userIds = null;
         // 获取当前公司下的所有销售
-        List<CompanyUser> companyUsers = companyUserMapper.selectCompanyUserByCompanyId(param.getCompanyId());
+        if(param.getCompanyUserId()  == null){
+            List<CompanyUser> companyUsers = companyUserMapper.selectCompanyUserByCompanyId(param.getCompanyId());
+
+            userIds = companyUsers.stream()
+                    .map(CompanyUser::getUserId)
+                    .filter(Objects::nonNull)
+                    .collect(Collectors.toList());
+        } else {
+            userIds = new ArrayList<>();
+            userIds.add(param.getCompanyUserId());
+        }
 
-        List<Long> userIds = companyUsers.stream()
-                .map(CompanyUser::getUserId)
-                .filter(Objects::nonNull)
-                .collect(Collectors.toList());
 
         List<QwWatchLogStatisticsListVO> list = new ArrayList<>();
 

+ 2 - 2
fs-service-system/src/main/resources/mapper/course/FsCourseTrafficLogMapper.xml

@@ -59,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
     <select id="selectTrafficNew" resultType="com.fs.course.vo.FsCourseTrafficLogListVO">
         select company_id,project,course_id,SUM(internet_traffic) AS total_internet_traffic
-        ,DATE_FORMAT(create_time, '%Y-%m') AS `month`  from fs_course_traffic_log
+        ,DATE_FORMAT(create_time, '%Y-%m-%d') AS `month`  from fs_course_traffic_log
         <where>
             <if test="startDate != null and endDate != null">
                 and create_time between #{startDate} AND #{endDate}
@@ -70,7 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="courseId != null">
                 and course_id = ${courseId}
             </if>
-            <if test="project">
+            <if test="project != null">
                 and project = ${project}
             </if>
         </where>

+ 4 - 2
fs-service-system/src/main/resources/mapper/course/FsCourseWatchLogMapper.xml

@@ -460,8 +460,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         o.video_id as video_id
         FROM fs_course_watch_log o
         <where>
+            send_type=1
             <if test="companyId != null">
-                o.company_id=#{companyId}
+               and o.company_id=#{companyId}
             </if>
             <if test= 'sTime != null '>
                 and o.create_time &gt;= #{sTime}
@@ -683,8 +684,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT 1
         FROM fs_course_watch_log o
         <where>
+            send_type=2
             <if test="companyId != null">
-                o.company_id=#{companyId}
+                and o.company_id=#{companyId}
             </if>
             <if test= 'sTime != null '>
                 and o.create_time &gt;= #{sTime}