wfansh 5 месяцев назад
Родитель
Сommit
a175a34d5a

+ 11 - 23
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/util/DateUtil.java

@@ -1,11 +1,5 @@
 package org.jeecg.modules.adweb.common.util;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.util.StringUtils;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.time.ZoneId;
 import java.util.*;
 
@@ -20,14 +14,6 @@ public class DateUtil {
 
     public static final ZoneId DEFAULT_ZONE_ID = ZoneId.of("Asia/Shanghai");
 
-    public static Date plusDays(Date date, int daysToAdd) {
-        Calendar calendar = Calendar.getInstance();
-        calendar.setTime(date);
-
-        calendar.add(Calendar.DAY_OF_MONTH, daysToAdd);
-        return calendar.getTime();
-    }
-
     /**
      * 特殊时间数据处理
      *
@@ -38,20 +24,20 @@ public class DateUtil {
         Date start = null;
         Date end = null;
         if ("yesterday".equals(dateType)) {
-            start = getTodayZeroTime(DateUtil.addDay2(now, -1));
+            start = getTodayZeroTime(DateUtil.addDays(now, -1));
             end = getTodayZeroTime(now);
         }
         if ("today".equals(dateType)) {
             start = getTodayZeroTime(now);
-            end = getTomZeroTime(now);
+            end = getTmrZeroTime(now);
         }
         if ("sevenDay".equals(dateType)) {
-            end = getTomZeroTime(now);
-            start = addDay2(end, -7);
+            end = getTmrZeroTime(now);
+            start = addDays(end, -7);
         }
         if ("thirtyDay".equals(dateType)) {
-            end = getTomZeroTime(now);
-            start = addDay2(end, -30);
+            end = getTmrZeroTime(now);
+            start = addDays(end, -30);
         }
         Map<String, Date> map = new HashMap<>();
         map.put("start", start);
@@ -61,6 +47,7 @@ public class DateUtil {
 
     /**
      * 获取当日零点
+     *
      * @param date
      * @return
      */
@@ -76,10 +63,11 @@ public class DateUtil {
 
     /**
      * 获取明日零点
+     *
      * @param date
      * @return
      */
-    public static Date getTomZeroTime(Date date) {
+    public static Date getTmrZeroTime(Date date) {
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(date);
         calendar.set(Calendar.HOUR_OF_DAY, 0);
@@ -92,15 +80,15 @@ public class DateUtil {
 
     /**
      * 在当前日期上追加N天
+     *
      * @param date 当前日期
      * @param num 添加天数
      * @return 日期字符串形式
      */
-    public static Date addDay2(Date date, int num) {
+    public static Date addDays(Date date, int num) {
         Calendar c = Calendar.getInstance();
         c.setTime(date);
         c.add(Calendar.DAY_OF_MONTH, num);
         return c.getTime();
     }
 }
-

+ 2 - 2
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/dmp/service/google/GAReportService.java

@@ -329,10 +329,10 @@ public class GAReportService {
         Date maxDate = commonMapper.getMaxDate(tableName, "date", "site_id = " + siteId);
         if (Objects.isNull(maxDate)) {
             // 1. 一年前
-            return DateUtil.plusDays(new Date(), -365);
+            return DateUtil.addDays(new Date(), -365);
         }
         // 2. 最大时间减一天
-        return DateUtil.plusDays(maxDate, -1);
+        return DateUtil.addDays(maxDate, -1);
     }
 
     /** 生成{@link QueryWrapper}, 删除GA报表历史数据 */

+ 1 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/controller/AdwebEnquiryController.java

@@ -148,7 +148,7 @@ public class AdwebEnquiryController extends JeecgController<AdwebEnquiry, IAdweb
 			end = map.get("end");
 		} else {
 			if (end != null) {
-				end = DateUtil.addDay2(end, 1);
+				end = DateUtil.addDays(end, 1);
 			}
 		}
 		if(ListUtil.isEmpty(codeList)){