浏览代码

Merge remote-tracking branch 'origin/master'

吴树波 1 月之前
父节点
当前提交
08c85945ce

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

@@ -81,5 +81,5 @@ public interface HyWatchLogMapper {
             "FROM hy_watch_log WHERE status = #{status}")
     List<HyWatchLog> selectByStatus(@Param("status") Integer status);
 
-    void insertHyWatchLogBatch(List<HyWatchLog> hyWatchLogs);
+    void insertHyWatchLogBatch(@Param("hyWatchLogs") List<HyWatchLog> hyWatchLogs);
 }

+ 3 - 1
fs-service-system/src/main/java/com/fs/course/service/impl/FsCourseWatchLogServiceImpl.java

@@ -709,7 +709,9 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
                         HyWatchLog qwWatchLog = new HyWatchLog();
                         qwWatchLog.setExtId(fsCourseWatchLog.getQwExternalContactId());
                         qwWatchLog.setLineTime(fsCourseWatchLog.getLineTime());
-                        qwWatchLog.setQwUserId(Long.parseLong(fsCourseWatchLog.getQwUserId()));
+                        if(fsCourseWatchLog.getQwUserId() != null) {
+                            qwWatchLog.setQwUserId(Long.parseLong(fsCourseWatchLog.getQwUserId()));
+                        }
                         qwWatchLog.setDay(day);
                         qwWatchLog.setStatus(fsCourseWatchLog.getLogType()==3?0:fsCourseWatchLog.getLogType()==2?2:1);
                         qwWatchLog.setProject(project);

+ 152 - 68
fs-service-system/src/main/java/com/fs/statis/service/impl/StatisticsServiceImpl.java

@@ -29,6 +29,7 @@ import java.math.RoundingMode;
 import java.time.DayOfWeek;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.time.LocalTime;
 import java.time.format.DateTimeFormatter;
 import java.time.temporal.TemporalAdjusters;
 import java.util.ArrayList;
@@ -110,30 +111,44 @@ public class StatisticsServiceImpl implements IStatisticsService {
         String startDate = "";
         String endDate = "";
 
-        LocalDate now = LocalDate.now();
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        LocalDateTime now = LocalDateTime.now();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 
+        LocalTime startOfDayTime = LocalTime.MIN;
+        LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
 
         if(0 == type){
-            startDate = now.format(formatter);
-            endDate = now.format(formatter);
+            LocalDateTime startOfDay = now.with(startOfDayTime);
+            LocalDateTime endOfDay = now.with(endOfDayTime);
+            startDate = startOfDay.format(formatter);
+            endDate = endOfDay.format(formatter);
         } else if(1 == type){
-            LocalDate yesterday = now.minusDays(1);
-            startDate = yesterday.format(formatter);
-            endDate = yesterday.format(formatter);
+            LocalDateTime yesterday = now.minusDays(1);
+            LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
+            LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
+            startDate = startOfYesterday.format(formatter);
+            endDate = endOfYesterday.format(formatter);
         } else if(2 == type) {
-            LocalDate startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
-            startDate = startOfWeek.format(formatter);
-            endDate = now.format(formatter);
+            LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
+            LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfWeek.format(formatter);
+            endDate = endOfToday.format(formatter);
         } else if(3 == type) {
-            LocalDate startOfMonth = now.withDayOfMonth(1);
-            startDate = startOfMonth.format(formatter);
-            endDate = now.format(formatter);
+            LocalDateTime startOfMonth = now.withDayOfMonth(1);
+            LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfMonth.format(formatter);
+            endDate = endOfToday.format(formatter);
         } else if(4 == type) {
-            LocalDate firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
-            LocalDate lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
-            startDate = firstDayOfPreviousMonth.format(formatter);
-            endDate = lastDayOfPreviousMonth.format(formatter);
+            LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
+            LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
+
+            LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
+            LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
+
+            startDate = startOfPrevMonthStart.format(formatter);
+            endDate = endOfPrevMonthEnd.format(formatter);
         }
 
         AnalysisPreviewQueryDTO param = new AnalysisPreviewQueryDTO();
@@ -174,27 +189,41 @@ public class StatisticsServiceImpl implements IStatisticsService {
         LocalDateTime now = LocalDateTime.now();
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 
+        LocalTime startOfDayTime = LocalTime.MIN;
+        LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
 
         if(0 == type){
-            startDate = now.format(formatter);
-            endDate = now.format(formatter);
+            LocalDateTime startOfDay = now.with(startOfDayTime);
+            LocalDateTime endOfDay = now.with(endOfDayTime);
+            startDate = startOfDay.format(formatter);
+            endDate = endOfDay.format(formatter);
         } else if(1 == type){
             LocalDateTime yesterday = now.minusDays(1);
-            startDate = yesterday.format(formatter);
-            endDate = yesterday.format(formatter);
+            LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
+            LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
+            startDate = startOfYesterday.format(formatter);
+            endDate = endOfYesterday.format(formatter);
         } else if(2 == type) {
             LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
-            startDate = startOfWeek.format(formatter);
-            endDate = now.format(formatter);
+            LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfWeek.format(formatter);
+            endDate = endOfToday.format(formatter);
         } else if(3 == type) {
             LocalDateTime startOfMonth = now.withDayOfMonth(1);
-            startDate = startOfMonth.format(formatter);
-            endDate = now.format(formatter);
+            LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfMonth.format(formatter);
+            endDate = endOfToday.format(formatter);
         } else if(4 == type) {
             LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
             LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
-            startDate = firstDayOfPreviousMonth.format(formatter);
-            endDate = lastDayOfPreviousMonth.format(formatter);
+
+            LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
+            LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
+
+            startDate = startOfPrevMonthStart.format(formatter);
+            endDate = endOfPrevMonthEnd.format(formatter);
         }
 
         AnalysisPreviewQueryDTO param = new AnalysisPreviewQueryDTO();
@@ -254,27 +283,41 @@ public class StatisticsServiceImpl implements IStatisticsService {
         LocalDateTime now = LocalDateTime.now();
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 
+        LocalTime startOfDayTime = LocalTime.MIN;
+        LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
 
         if(0 == type){
-            startDate = now.format(formatter);
-            endDate = now.format(formatter);
+            LocalDateTime startOfDay = now.with(startOfDayTime);
+            LocalDateTime endOfDay = now.with(endOfDayTime);
+            startDate = startOfDay.format(formatter);
+            endDate = endOfDay.format(formatter);
         } else if(1 == type){
             LocalDateTime yesterday = now.minusDays(1);
-            startDate = yesterday.format(formatter);
-            endDate = yesterday.format(formatter);
+            LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
+            LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
+            startDate = startOfYesterday.format(formatter);
+            endDate = endOfYesterday.format(formatter);
         } else if(2 == type) {
             LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
-            startDate = startOfWeek.format(formatter);
-            endDate = now.format(formatter);
+            LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfWeek.format(formatter);
+            endDate = endOfToday.format(formatter);
         } else if(3 == type) {
             LocalDateTime startOfMonth = now.withDayOfMonth(1);
-            startDate = startOfMonth.format(formatter);
-            endDate = now.format(formatter);
+            LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfMonth.format(formatter);
+            endDate = endOfToday.format(formatter);
         } else if(4 == type) {
             LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
             LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
-            startDate = firstDayOfPreviousMonth.format(formatter);
-            endDate = lastDayOfPreviousMonth.format(formatter);
+
+            LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
+            LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
+
+            startDate = startOfPrevMonthStart.format(formatter);
+            endDate = endOfPrevMonthEnd.format(formatter);
         }
 
         dto.setStartTime(startDate);
@@ -298,29 +341,42 @@ public class StatisticsServiceImpl implements IStatisticsService {
         LocalDateTime now = LocalDateTime.now();
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 
+        LocalTime startOfDayTime = LocalTime.MIN;
+        LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
 
         if(0 == type){
-            startDate = now.format(formatter);
-            endDate = now.format(formatter);
+            LocalDateTime startOfDay = now.with(startOfDayTime);
+            LocalDateTime endOfDay = now.with(endOfDayTime);
+            startDate = startOfDay.format(formatter);
+            endDate = endOfDay.format(formatter);
         } else if(1 == type){
             LocalDateTime yesterday = now.minusDays(1);
-            startDate = yesterday.format(formatter);
-            endDate = yesterday.format(formatter);
+            LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
+            LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
+            startDate = startOfYesterday.format(formatter);
+            endDate = endOfYesterday.format(formatter);
         } else if(2 == type) {
             LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
-            startDate = startOfWeek.format(formatter);
-            endDate = now.format(formatter);
+            LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfWeek.format(formatter);
+            endDate = endOfToday.format(formatter);
         } else if(3 == type) {
             LocalDateTime startOfMonth = now.withDayOfMonth(1);
-            startDate = startOfMonth.format(formatter);
-            endDate = now.format(formatter);
+            LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfMonth.format(formatter);
+            endDate = endOfToday.format(formatter);
         } else if(4 == type) {
             LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
             LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
-            startDate = firstDayOfPreviousMonth.format(formatter);
-            endDate = lastDayOfPreviousMonth.format(formatter);
-        }
 
+            LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
+            LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
+
+            startDate = startOfPrevMonthStart.format(formatter);
+            endDate = endOfPrevMonthEnd.format(formatter);
+        }
         dto.setStartTime(startDate);
         dto.setEndTime(endDate);
         dto.setUserType(userType);
@@ -508,27 +564,41 @@ public class StatisticsServiceImpl implements IStatisticsService {
         LocalDateTime now = LocalDateTime.now();
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 
+        LocalTime startOfDayTime = LocalTime.MIN;
+        LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
 
         if(0 == type){
-            startDate = now.format(formatter);
-            endDate = now.format(formatter);
+            LocalDateTime startOfDay = now.with(startOfDayTime);
+            LocalDateTime endOfDay = now.with(endOfDayTime);
+            startDate = startOfDay.format(formatter);
+            endDate = endOfDay.format(formatter);
         } else if(1 == type){
             LocalDateTime yesterday = now.minusDays(1);
-            startDate = yesterday.format(formatter);
-            endDate = yesterday.format(formatter);
+            LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
+            LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
+            startDate = startOfYesterday.format(formatter);
+            endDate = endOfYesterday.format(formatter);
         } else if(2 == type) {
             LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
-            startDate = startOfWeek.format(formatter);
-            endDate = now.format(formatter);
+            LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfWeek.format(formatter);
+            endDate = endOfToday.format(formatter);
         } else if(3 == type) {
             LocalDateTime startOfMonth = now.withDayOfMonth(1);
-            startDate = startOfMonth.format(formatter);
-            endDate = now.format(formatter);
+            LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfMonth.format(formatter);
+            endDate = endOfToday.format(formatter);
         } else if(4 == type) {
             LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
             LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
-            startDate = firstDayOfPreviousMonth.format(formatter);
-            endDate = lastDayOfPreviousMonth.format(formatter);
+
+            LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
+            LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
+
+            startDate = startOfPrevMonthStart.format(formatter);
+            endDate = endOfPrevMonthEnd.format(formatter);
         }
 
         dto.setStartTime(startDate);
@@ -552,27 +622,41 @@ public class StatisticsServiceImpl implements IStatisticsService {
         LocalDateTime now = LocalDateTime.now();
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 
+        LocalTime startOfDayTime = LocalTime.MIN;
+        LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
 
         if(0 == type){
-            startDate = now.format(formatter);
-            endDate = now.format(formatter);
+            LocalDateTime startOfDay = now.with(startOfDayTime);
+            LocalDateTime endOfDay = now.with(endOfDayTime);
+            startDate = startOfDay.format(formatter);
+            endDate = endOfDay.format(formatter);
         } else if(1 == type){
             LocalDateTime yesterday = now.minusDays(1);
-            startDate = yesterday.format(formatter);
-            endDate = yesterday.format(formatter);
+            LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
+            LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
+            startDate = startOfYesterday.format(formatter);
+            endDate = endOfYesterday.format(formatter);
         } else if(2 == type) {
             LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
-            startDate = startOfWeek.format(formatter);
-            endDate = now.format(formatter);
+            LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfWeek.format(formatter);
+            endDate = endOfToday.format(formatter);
         } else if(3 == type) {
             LocalDateTime startOfMonth = now.withDayOfMonth(1);
-            startDate = startOfMonth.format(formatter);
-            endDate = now.format(formatter);
+            LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfMonth.format(formatter);
+            endDate = endOfToday.format(formatter);
         } else if(4 == type) {
             LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
             LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
-            startDate = firstDayOfPreviousMonth.format(formatter);
-            endDate = lastDayOfPreviousMonth.format(formatter);
+
+            LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
+            LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
+
+            startDate = startOfPrevMonthStart.format(formatter);
+            endDate = endOfPrevMonthEnd.format(formatter);
         }
 
         dto.setStartTime(startDate);