Jelajahi Sumber

看课统计公司维度优化

wangxy 2 minggu lalu
induk
melakukan
ef6dd9479b

+ 7 - 7
fs-service/src/main/java/com/fs/course/param/FsCourseWatchLogStatisticsListParam.java

@@ -29,13 +29,13 @@ public class FsCourseWatchLogStatisticsListParam extends BaseEntity {
     private String startDate;
     private String endDate;
 
-    public String getStartDate() {
-        return DateUtils.getStartOfDayString(sTime);
-    }
-
-    public String getEndDate() {
-        return DateUtils.getEndOfDayString(eTime);
-    }
+//    public String getStartDate() {
+//        return DateUtils.getStartOfDayString(sTime);
+//    }
+//
+//    public String getEndDate() {
+//        return DateUtils.getEndOfDayString(eTime);
+//    }
 
     private Long project;
 

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

@@ -1295,12 +1295,10 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
 
     @Override
     public List<FsCourseReportVO> selectFsCourseReportVO(FsCourseWatchLogStatisticsListParam param) {
-        //时间处理
-        if (param.getSTime() != null || param.getETime() != null) {
-            Date date = removeTime(param.getSTime());
-            param.setSTime(date);
-            Date endDate = removeTime(param.getETime());
-            param.setETime(endDate);
+        if(param.getSTime()!=null && param.getETime()!=null){
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            param.setStartDate(simpleDateFormat.format(param.getSTime()));
+            param.setEndDate(simpleDateFormat.format(param.getETime()));
         }
         // 基础信息
         List<FsCourseReportVO> companyList = new ArrayList<>();

+ 6 - 34
fs-service/src/main/resources/mapper/course/FsCourseWatchLogMapper.xml

@@ -1423,38 +1423,10 @@ FROM
         c.company_id AS companyId,
         c.company_name AS companyName
         FROM company c
-        <choose>
-            <!-- 当传了 trainingCampId 时 -->
-            <when test="trainingCampId != null">
-                INNER JOIN fs_course_watch_log w ON c.company_id = w.company_id
-                INNER JOIN fs_user_course_period p ON w.period_id = p.period_id AND p.training_camp_id = #{trainingCampId}
-            </when>
-            <!-- 当传了 periodId 时 -->
-            <when test="periodId != null">
-                INNER JOIN fs_course_watch_log w ON c.company_id = w.company_id AND w.period_id = #{periodId}
-            </when>
-            <!-- 当只传了时间范围时 -->
-            <when test="(trainingCampId == null and periodId == null) and (sTime != null and eTime != null)">
-                    INNER JOIN fs_course_watch_log w ON c.company_id = w.company_id
-            </when>
-<!--            &lt;!&ndash; 默认情况:必须有关联记录 &ndash;&gt;-->
-<!--            <otherwise>-->
-<!--                INNER JOIN fs_course_watch_log w ON c.company_id = w.company_id-->
-<!--            </otherwise>-->
-        </choose>
         <where>
             <if test="companyId != null and companyId != ''">
                 AND c.company_id = #{companyId}
             </if>
-            <if test="(trainingCampId == null and periodId == null) and (sTime != null and eTime != null)">
-                AND Date(w.create_time) BETWEEN #{sTime} AND #{eTime}
-            </if>
-            <if test="trainingCampId != null and (sTime != null and eTime != null)">
-                AND Date(w.create_time) BETWEEN #{sTime} AND #{eTime}
-            </if>
-            <if test="periodId != null and (sTime != null and eTime != null)">
-                AND Date(w.create_time) BETWEEN #{sTime} AND #{eTime}
-            </if>
         </where>
         GROUP BY c.company_id, c.company_name
         ORDER BY c.create_time DESC
@@ -1479,8 +1451,8 @@ FROM
         COUNT(DISTINCT user_id) AS accessCount
         FROM fs_course_watch_log
         <where>
-            <if test="sTime != null and eTime != null">
-                AND Date(create_time)  BETWEEN #{sTime} AND #{eTime}
+            <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
+                AND create_time &gt;= #{startDate} AND create_time &lt; DATE_ADD(#{endDate}, INTERVAL 1 DAY)
             </if>
             <choose>
                 <!-- 公司维度筛选 -->
@@ -1535,8 +1507,8 @@ FROM
         FROM fs_course_answer_logs a
         INNER JOIN fs_course_watch_log w ON a.watch_log_id = w.log_id
         <where>
-            <if test="sTime != null and eTime != null">
-                AND Date(w.create_time) BETWEEN #{sTime} AND #{eTime}
+            <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
+                AND w.create_time &gt;= #{startDate} AND w.create_time &lt; DATE_ADD(#{endDate}, INTERVAL 1 DAY)
             </if>
             <choose>
                 <!-- 公司维度筛选 -->
@@ -1593,8 +1565,8 @@ FROM
         INNER JOIN fs_course_watch_log w ON rpl.watch_log_id = w.log_id
         <where>
             rpl.status=1
-            <if test="sTime != null and eTime != null">
-                AND DATE(w.create_time)  BETWEEN #{sTime} AND #{eTime}
+            <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
+                AND w.create_time &gt;= #{startDate} AND w.create_time &lt; DATE_ADD(#{endDate}, INTERVAL 1 DAY)
             </if>
             <choose>
                 <!-- 公司维度筛选 -->