wfansh пре 5 месеци
родитељ
комит
44cd023aef

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

@@ -1,9 +1,9 @@
 package org.jeecg.modules.adweb.common.util;
 
-import com.google.common.collect.ImmutableMap;
-
 import lombok.extern.slf4j.Slf4j;
 
+import org.apache.commons.lang3.tuple.Pair;
+
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
@@ -47,7 +47,7 @@ public class DateUtil {
      *
      * @param dateType 日期类型
      */
-    public static Map<String, Date> getDateRangeByType(String dateType) {
+    public static Pair<Date, Date> getDateRangeByType(String dateType) {
         Date now = new Date();
         Date start = null;
         Date end = null;
@@ -71,7 +71,7 @@ public class DateUtil {
                 break;
         }
 
-        return ImmutableMap.of("start", start, "end", end);
+        return Pair.of(start, end);
     }
 
     /**

+ 14 - 17
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/dmp/controller/DMPDataController.java

@@ -7,6 +7,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.tuple.Pair;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.adweb.common.util.DateUtil;
 import org.jeecg.modules.adweb.dmp.service.IGACountryReportService;
@@ -18,7 +19,6 @@ import org.jeecg.modules.adweb.dmp.vo.report.PagePathStatsVO;
 import org.jeecg.modules.adweb.dmp.vo.report.SiteOverviewStatsVO;
 import org.jeecg.modules.adweb.dmp.vo.report.SourceMediumStatsVO;
 import org.jeecg.modules.adweb.enquiry.service.IAdwebEnquiryService;
-import org.jeecg.modules.adweb.site.service.IAdwebSiteService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -27,7 +27,6 @@ import org.springframework.web.bind.annotation.RestController;
 
 import java.util.Date;
 import java.util.List;
-import java.util.Map;
 
 /**
  * 数据分析 - GA网站流量,询盘数据等
@@ -40,8 +39,6 @@ import java.util.Map;
 @Slf4j
 public class DMPDataController {
 
-    @Autowired private IAdwebSiteService adwebSiteService;
-
     @Autowired private IGADailyReportService gaDailyReportService;
     @Autowired private IGASourceMediumReportService gaSourceMediumReportService;
     @Autowired private IGACountryReportService gaCountryReportService;
@@ -49,7 +46,7 @@ public class DMPDataController {
 
     @Autowired private IAdwebEnquiryService adwebEnquiryService;
 
-    /** 网站流量分析统计 */
+    /** 网站流量整体分析统计 */
     @GetMapping("/site-overview/stats")
     public Result<SiteOverviewStatsVO> getSiteOverviewStats(
             String siteCode,
@@ -58,9 +55,9 @@ public class DMPDataController {
             @DateTimeFormat(pattern = "yyyy-MM-dd") Date end) {
         // 1. 计算时间区间
         if (StringUtils.isNotBlank(dateType)) {
-            Map<String, Date> dateRange = DateUtil.getDateRangeByType(dateType);
-            start = dateRange.get("start");
-            end = dateRange.get("end");
+            Pair<Date, Date> dateRange = DateUtil.getDateRangeByType(dateType);
+            start = dateRange.getLeft();
+            end = dateRange.getRight();
         }
 
         // 2. 查询GA Daily Report和Enquiries
@@ -79,9 +76,9 @@ public class DMPDataController {
             @DateTimeFormat(pattern = "yyyy-MM-dd") Date end) {
         // 1. 计算时间区间
         if (StringUtils.isNotBlank(dateType)) {
-            Map<String, Date> dateRange = DateUtil.getDateRangeByType(dateType);
-            start = dateRange.get("start");
-            end = dateRange.get("end");
+            Pair<Date, Date> dateRange = DateUtil.getDateRangeByType(dateType);
+            start = dateRange.getLeft();
+            end = dateRange.getRight();
         }
 
         // 2. 查询并返回
@@ -96,9 +93,9 @@ public class DMPDataController {
             @DateTimeFormat(pattern = "yyyy-MM-dd") Date end) {
         // 1. 计算时间区间
         if (StringUtils.isNotBlank(dateType)) {
-            Map<String, Date> dateRange = DateUtil.getDateRangeByType(dateType);
-            start = dateRange.get("start");
-            end = dateRange.get("end");
+            Pair<Date, Date> dateRange = DateUtil.getDateRangeByType(dateType);
+            start = dateRange.getLeft();
+            end = dateRange.getRight();
         }
 
         // 2. 查询并返回
@@ -114,9 +111,9 @@ public class DMPDataController {
             int limit) {
         // 1. 计算时间区间
         if (StringUtils.isNotBlank(dateType)) {
-            Map<String, Date> dateRange = DateUtil.getDateRangeByType(dateType);
-            start = dateRange.get("start");
-            end = dateRange.get("end");
+            Pair<Date, Date> dateRange = DateUtil.getDateRangeByType(dateType);
+            start = dateRange.getLeft();
+            end = dateRange.getRight();
         }
 
         // 2. 查询并返回

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

@@ -18,6 +18,8 @@ public interface IGADailyReportService extends IService<GADailyReport> {
      * 查询指定时间区间内的{@DailyStatsVO}
      *
      * <p>如数据库中某天数据缺失,需填充空数据
+     *
+     * <p>填充每日询盘数据
      */
     List<DailyStatsVO> getDailyStatsWithinPeriod(String siteCode, Date start, Date end);
 }

+ 14 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/dmp/service/impl/GADailyReportServiceImpl.java

@@ -15,6 +15,7 @@ import org.jeecg.modules.adweb.dmp.entity.GADailyReport;
 import org.jeecg.modules.adweb.dmp.mapper.GADailyReportMapper;
 import org.jeecg.modules.adweb.dmp.service.IGADailyReportService;
 import org.jeecg.modules.adweb.enquiry.mapper.AdwebEnquiryMapper;
+import org.jeecg.modules.adweb.site.service.IAdwebSiteService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -28,16 +29,29 @@ import java.util.stream.Collectors;
 public class GADailyReportServiceImpl extends ServiceImpl<GADailyReportMapper, GADailyReport>
         implements IGADailyReportService {
 
+    @Autowired private IAdwebSiteService adwebSiteService;
+
     @Autowired private AdwebEnquiryMapper adwebEnquiryMapper;
 
     /**
      * 查询指定时间区间内的{@DailyStatsVO}
      *
      * <p>如数据库中某天数据缺失,需填充空数据
+     *
+     * <p>填充每日询盘数据
      */
     public List<DailyStatsVO> getDailyStatsWithinPeriod(String siteCode, Date start, Date end) {
         Map<String, DailyStatsVO> dailyStatsVOs = Maps.newHashMap();
 
+        // 0. 起止时间为空时,设置默认区间 - start = 网站发布日期 & end = 今天
+        if (start == null || end == null) {
+            start =
+                    DateUtil.getTodayZeroTime(
+                            adwebSiteService.getSiteByCode(siteCode).getIssueTime());
+            end = DateUtil.getTodayZeroTime(new Date());
+        }
+
+        // 1. VO数据填充
         List<GADailyReport> gaDailyReports =
                 this.list(
                         new LambdaQueryWrapper<GADailyReport>()
@@ -46,7 +60,6 @@ public class GADailyReportServiceImpl extends ServiceImpl<GADailyReportMapper, G
                                 .le(GADailyReport::getDate, end)
                                 .orderByAsc(GADailyReport::getDate));
 
-        // 1. VO数据填充
         for (GADailyReport gaDailyReport : gaDailyReports) {
             DailyStatsVO dailyStatsVO = new DailyStatsVO();
             String date = DateUtils.date2Str(gaDailyReport.getDate(), DateUtils.date_sdf.get());

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

@@ -5,14 +5,19 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
+
 import jakarta.annotation.Resource;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
+
 import lombok.extern.slf4j.Slf4j;
+
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.tuple.Pair;
 import org.apache.ibatis.annotations.Param;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
@@ -26,9 +31,9 @@ import org.jeecg.modules.adweb.common.constant.AdwebConstant;
 import org.jeecg.modules.adweb.common.util.AwsTranslateUtils;
 import org.jeecg.modules.adweb.common.util.DateUtil;
 import org.jeecg.modules.adweb.enquiry.constant.EnquirySendStatus;
-import org.jeecg.modules.adweb.enquiry.dto.param.EnquirySearchDto;
 import org.jeecg.modules.adweb.enquiry.dto.param.EffectiveEnquiryParamDto;
 import org.jeecg.modules.adweb.enquiry.dto.param.EnquiryListSearchDto;
+import org.jeecg.modules.adweb.enquiry.dto.param.EnquirySearchDto;
 import org.jeecg.modules.adweb.enquiry.dto.result.EnquiryListDto;
 import org.jeecg.modules.adweb.enquiry.dto.result.EnquirySpecialFields;
 import org.jeecg.modules.adweb.enquiry.entity.AdwebEnquiry;
@@ -157,9 +162,9 @@ public class AdwebEnquiryController extends JeecgController<AdwebEnquiry, IAdweb
 		Date start = searchDto.getStart();
 		Date end = searchDto.getEnd();
 		if (StringUtils.isNotBlank(dateType)) {
-			Map<String, Date> map = DateUtil.getDateRangeByType(dateType);
-			start = map.get("start");
-			end = map.get("end");
+			Pair<Date, Date> dateRange = DateUtil.getDateRangeByType(dateType);
+			start = dateRange.getLeft();
+			end = dateRange.getRight();
 		} else {
 			if (end != null) {
 				end = DateUtil.addDays(end, 1);

+ 1 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/mapper/xml/AdwebEnquiryMapper.xml

@@ -318,7 +318,7 @@
             AND record_ctime >= #{start}
         </if>
         <if test="end != null">
-            AND #{end} > record_ctime
+            AND record_ctime &lt; DATE_ADD(#{end}, INTERVAL 1 DAY)
         </if>
         GROUP BY date
     </select>