wfansh před 5 měsíci
rodič
revize
614760c8ff

+ 4 - 10
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/dmp/controller/GADataController.java

@@ -9,7 +9,6 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.adweb.common.util.DateUtil;
 import org.jeecg.modules.adweb.dmp.service.IGAPagePathReportService;
 import org.jeecg.modules.adweb.dmp.vo.report.PagePathStatsVO;
-import org.jeecg.modules.adweb.site.entity.AdwebSite;
 import org.jeecg.modules.adweb.site.service.IAdwebSiteService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.format.annotation.DateTimeFormat;
@@ -20,7 +19,6 @@ import org.springframework.web.bind.annotation.RestController;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
-import java.util.Objects;
 
 /**
  * GA网站流量
@@ -57,15 +55,11 @@ public class GADataController {
 
     @GetMapping("/page-path/stats")
     public Result<List<PagePathStatsVO>> getPagePathStats(
-            Integer siteId,
+            String siteCode,
             String dateType,
             @DateTimeFormat(pattern = "yyyy-MM-dd") Date start,
-            @DateTimeFormat(pattern = "yyyy-MM-dd") Date end) {
-        AdwebSite adwebSite = adwebSiteService.getById(siteId);
-        if (Objects.isNull(adwebSite)) {
-            return Result.error("站点未找到" + siteId);
-        }
-
+            @DateTimeFormat(pattern = "yyyy-MM-dd") Date end,
+            int limit) {
         // 1. 计算时间区间
         if (StringUtils.isNotBlank(dateType)) {
             Map<String, Date> dateRange = DateUtil.getDateRangeByType(dateType);
@@ -76,6 +70,6 @@ public class GADataController {
         // 2. 查询并返回
         return Result.ok(
                 gaPagePathReportService.getPagePathStats(
-                        adwebSite.getCode(), adwebSite.getDomain(), start, end, 10));
+                        siteCode, start, end, limit >= 0 ? limit : 10));
     }
 }

+ 3 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/dmp/controller/GTMController.java

@@ -35,10 +35,10 @@ public class GTMController {
 
     @RequestMapping(value = "/add", method = RequestMethod.POST)
     @ResponseBody
-    public Result<Pair<String, String>> addContainer(Integer siteId) {
-        AdwebSite adwebSite = adwebSiteService.getById(siteId);
+    public Result<Pair<String, String>> addContainer(String siteCode) {
+        AdwebSite adwebSite = adwebSiteService.getSiteByCode(siteCode);
         if (Objects.isNull(adwebSite)) {
-            return Result.error("站点未找到" + siteId);
+            return Result.error("站点未找到" + siteCode);
         }
 
         // 如果GoogleGTM表中已存在,不再创建,返回现有记录

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

@@ -13,6 +13,5 @@ import java.util.List;
  */
 public interface IGAPagePathReportService extends IService<GAPagePathReport> {
 
-    List<PagePathStatsVO> getPagePathStats(
-            String siteCode, String siteUrl, Date start, Date end, int limit);
+    List<PagePathStatsVO> getPagePathStats(String siteCode, Date start, Date end, int limit);
 }

+ 8 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/dmp/service/impl/GAPagePathReportServiceImpl.java

@@ -12,6 +12,8 @@ import org.jeecg.modules.adweb.dmp.entity.GAPagePathReport;
 import org.jeecg.modules.adweb.dmp.mapper.GAPagePathReportMapper;
 import org.jeecg.modules.adweb.dmp.service.IGAPagePathReportService;
 import org.jeecg.modules.adweb.dmp.vo.report.PagePathStatsVO;
+import org.jeecg.modules.adweb.site.entity.AdwebSite;
+import org.jeecg.modules.adweb.site.service.IAdwebSiteService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -30,16 +32,19 @@ public class GAPagePathReportServiceImpl
 
     @Autowired private GAPagePathReportMapper gaPagePathReportMapper;
 
+    @Autowired private IAdwebSiteService adwebSiteService;
+
     public List<PagePathStatsVO> getPagePathStats(
-            String siteCode, String siteUrl, Date start, Date end, int limit) {
+            String siteCode, Date start, Date end, int limit) {
         List<PagePathStatsVO> pagePathStatsVOs =
                 gaPagePathReportMapper.getPagePathStats(siteCode, start, end, limit);
         if (CollectionUtils.isEmpty(pagePathStatsVOs)) {
             return Collections.EMPTY_LIST;
         }
 
-        // 1. 网站URL格式化
-        siteUrl = StringUtils.removeEnd(Strings.nullToEmpty(siteUrl), "/");
+        // 1. 网站URL及格式化
+        AdwebSite adwebSite = adwebSiteService.getSiteByCode(siteCode);
+        String siteUrl = StringUtils.removeEnd(Strings.nullToEmpty(adwebSite.getDomain()), "/");
 
         // 2. 时间区间内PV总数
         int totalPVs = gaPagePathReportMapper.countTotalPVs(siteCode, start, end);

+ 2 - 4
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/dmp/vo/report/PagePathStatsVO.java

@@ -5,10 +5,8 @@ import lombok.Data;
 import org.jeecg.modules.adweb.dmp.dto.google.analytics.report.data.PagePathViewData;
 import org.jeecg.modules.adweb.dmp.entity.GAPagePathReport;
 
-import java.math.BigDecimal;
-
 /**
- * GA页面访问数据VO,see {@link PagePathViewData} and {@link GAPagePathReport}
+ * GA页面访问统计数据VO,see {@link PagePathViewData} and {@link GAPagePathReport}
  *
  * @author wfansh
  */
@@ -19,7 +17,7 @@ public class PagePathStatsVO {
 
     private int pageViews;
 
-    private BigDecimal avgTimeOnPage;
+    private double avgTimeOnPage;
 
     private String pvProportion;
 }

+ 5 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/IAdwebSiteService.java

@@ -45,6 +45,11 @@ public interface IAdwebSiteService extends IService<AdwebSite> {
      */
     List<Integer> getAllSiteIdBySiteId(Integer siteId);
 
+    /**
+     * 根据siteCode返回站点信息
+     * @param siteCode
+     * @return
+     */
     AdwebSite getSiteByCode(String siteCode);
 
     /**

+ 5 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/site/service/impl/AdwebSiteServiceImpl.java

@@ -186,6 +186,11 @@ public class AdwebSiteServiceImpl extends ServiceImpl<AdwebSiteMapper, AdwebSite
         return siteIds;
     }
 
+    /**
+     * 根据siteCode返回站点信息
+     * @param siteCode
+     * @return
+     */
     @Override
     public AdwebSite getSiteByCode(String siteCode) {
         try {