Parcourir la source

Merge remote-tracking branch 'origin/test' into test

yumeng il y a 5 ans
Parent
commit
e24547d28e

+ 0 - 35
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedancePlanHourlyReportLoadJob.java

@@ -1,14 +1,11 @@
 package org.jeecg.modules.ctop.job;
 
-import cn.com.ctop.bytedance.entity.BytedancePlanHourlyReport;
 import cn.com.ctop.bytedance.service.IBytedancePlanHourlyReportService;
 import cn.com.ctop.bytedance.service.IReportService;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.quartz.Job;
@@ -73,39 +70,7 @@ public class BytedancePlanHourlyReportLoadJob implements Job {
         } catch (InterruptedException e) {
             e.printStackTrace();
         }
-        //清洗关于缘多多数据
-        formatData(113,finalGetDate);
-        //清洗关于交友数据
-        formatData(112,finalGetDate);
-        //清洗关于附近约会数据
-        formatData(222,finalGetDate);
         log.info("头条计划时报数据获取完成");
         executorService.shutdown();
     }
-
-    private void formatData(Integer projectId, Date finalGetDate){
-        QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("project_id", projectId);
-        List<UserAllocation> fjyhAllocations = userAllocationService.list(queryWrapper);
-        if (null != fjyhAllocations && fjyhAllocations.size() > 0) {
-            fjyhAllocations.forEach(allocation -> {
-                //根据accountId和时间,查询相关的时报报表信息
-                QueryWrapper<BytedancePlanHourlyReport> accountWrapper = new QueryWrapper<>();
-                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-                String dateString = dateFormat.format(finalGetDate);
-                accountWrapper.eq("advertiser_id", allocation.getAccountId())
-                        .eq("stat_datetime",dateString)
-                ;
-                List<BytedancePlanHourlyReport> bytedancePlanHourlyReports = planHourlyReportService.list(accountWrapper);
-                if (null != bytedancePlanHourlyReports && bytedancePlanHourlyReports.size() > 0) {
-                    bytedancePlanHourlyReports.forEach(report -> {
-                        String adName = report.getAdName();
-                        String[] tags = adName.split("-");
-                        report.setChannelCode(tags[0]);
-                        planHourlyReportService.updateById(report);
-                    });
-                }
-            });
-        }
-    }
 }

+ 55 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaishouReportDailyAgentSumController.java

@@ -8,6 +8,9 @@ import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+
+import cn.com.ctop.kuaishou.modules.report.entity.ParamsDTO;
+import org.apache.commons.lang.StringUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.aspect.annotation.AutoLog;
@@ -48,7 +51,7 @@ import io.swagger.annotations.ApiOperation;
 public class KuaishouReportDailyAgentSumController {
 	@Autowired
 	private IKuaishouReportDailyAgentSumService kuaishouReportDailyAgentSumService;
-	
+
 	/**
 	  * 分页列表查询
 	 * @param kuaishouReportDailyAgentSum
@@ -72,7 +75,7 @@ public class KuaishouReportDailyAgentSumController {
 		result.setResult(pageList);
 		return result;
 	}
-	
+
 	/**
 	  *   添加
 	 * @param kuaishouReportDailyAgentSum
@@ -92,7 +95,7 @@ public class KuaishouReportDailyAgentSumController {
 		}
 		return result;
 	}
-	
+
 	/**
 	  *  批量删除
 	 * @param ids
@@ -111,7 +114,7 @@ public class KuaishouReportDailyAgentSumController {
 		}
 		return result;
 	}
-	
+
 	/**
 	  * 通过id查询
 	 * @param id
@@ -199,4 +202,52 @@ public class KuaishouReportDailyAgentSumController {
       return Result.ok("文件导入失败!");
   }
 
+	 /**
+	  * @param dto
+	  * @return Result<List<KuaishouReportDailyAgentSum>>
+	  */
+	 @AutoLog(value = "公司报表")
+	 @ApiOperation(value="公司报表", notes="公司报表")
+	 @PostMapping(value = "/companyReport")
+	 public Result<List<KuaishouReportDailyAgentSum>> companyReport(@RequestBody ParamsDTO dto) {
+		Result<List<KuaishouReportDailyAgentSum>> result = new Result<>();
+	 	String startDate = dto.getStartDate();
+	 	String endDate = dto.getEndDate();
+	 	if(StringUtils.isBlank(startDate) || StringUtils.isBlank(endDate)){
+			result.setSuccess(false);
+			result.setMessage("时间不能为空");
+	 	}
+
+		List<KuaishouReportDailyAgentSum> kuaishouReportDailyAgentSumList = kuaishouReportDailyAgentSumService.companyReport(startDate,endDate);
+	 	result.setResult(kuaishouReportDailyAgentSumList);
+	 	result.setSuccess(true);
+	 	result.setMessage("success");
+
+	 	return result;
+	 }
+
+	 /**
+	  * @param dto
+	  * @return Result<KuaishouReportDailyAgentSum>
+	  */
+	 @AutoLog(value = "公司报表按时间汇总")
+	 @ApiOperation(value="公司报表按时间汇总", notes="公司报表按时间汇总")
+	 @PostMapping(value = "/companyReportSum")
+	 public Result<KuaishouReportDailyAgentSum> companyReportSum(@RequestBody ParamsDTO dto) {
+		 Result<KuaishouReportDailyAgentSum> result = new Result<>();
+		 String startDate = dto.getStartDate();
+		 String endDate = dto.getEndDate();
+		 if(StringUtils.isBlank(startDate) || StringUtils.isBlank(endDate)){
+			 result.setSuccess(false);
+			 result.setMessage("时间不能为空");
+		 }
+
+		 KuaishouReportDailyAgentSum kuaishouReportDailyAgentSum = kuaishouReportDailyAgentSumService.companyReportSum(startDate,endDate);
+		 result.setResult(kuaishouReportDailyAgentSum);
+		 result.setSuccess(true);
+		 result.setMessage("success");
+
+		 return result;
+	 }
+
 }

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyAgentSum.java

@@ -27,7 +27,7 @@ import org.jeecgframework.poi.excel.annotation.Excel;
 @Accessors(chain = true)
 @ApiModel(value="ctop_kuaishou_report_daily_agent对象", description="代理商日汇总表")
 public class KuaishouReportDailyAgentSum {
-    
+
 	/**日期*/
 	@Excel(name = "日期", width = 15, format = "yyyy-MM-dd")
 	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")

+ 12 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/ParamsDTO.java

@@ -0,0 +1,12 @@
+package cn.com.ctop.kuaishou.modules.report.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+@Data
+public class ParamsDTO implements Serializable {
+    private String startDate;
+    private String endDate;
+}

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyAgentSumMapper.java

@@ -13,5 +13,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @cersion: V1.0
  */
 public interface KuaishouReportDailyAgentSumMapper extends BaseMapper<KuaishouReportDailyAgentSum> {
+    List<KuaishouReportDailyAgentSum> companyReport(@Param("startDate")String startDate, @Param("endDate")String endDate);
 
+    KuaishouReportDailyAgentSum companyReportSum(@Param("startDate")String startDate, @Param("endDate")String endDate);
 }

+ 48 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyAgentSumMapper.xml

@@ -2,4 +2,51 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAgentSumMapper">
 
-</mapper>
+    <!-- 公司报表sql -->
+    <select id="companyReport" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgentSum">
+            select
+            date as date,  <!-- 日期 -->
+            cost_campaign_count as costCampaignCount,  <!-- 有消费计划数 -->
+            balance as balance,  <!-- 总余额 -->
+            cost as cost,  <!-- 总消耗 -->
+            xianjin_cost as xianjinCost,  <!-- 现金消耗 -->
+            fandian_cost as fandianCost,  <!-- 后返消耗 -->
+            kuangfan_cost as kuangfanCost,  <!-- 框返消耗 -->
+            jili_cost as jiliCost,  <!-- 激励账户消耗 -->
+            xinyong_cost as xinyongCost,  <!-- 信用账户消耗 -->
+            fengmian_show_count as fengmianShowCount,  <!-- 封面曝光数 -->
+            fengmian_click_count as fengmianClickCount,  <!-- 封面点击数 -->
+            sucai_show_count as sucaiShowCount,  <!-- 素材曝光数 -->
+            convert_count as convertCount,  <!-- 行为数 -->
+            fengmian_click_rate as fengmianClickRate,  <!-- 封面点击率 -->
+            convert_click_rate as convertClickRate  <!-- 转化点击率 -->
+        from
+        ctop_kuaishou_report_daily_agent_sum
+        where
+        date &lt;= #{endDate} and
+        date &gt;= #{startDate}
+    </select>
+
+    <select id="companyReportSum" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgentSum">
+        select
+        sum(cost_campaign_count) as costCampaignCount,  <!-- 有消费计划数 -->
+        sum(balance) as balance,  <!-- 总余额 -->
+        sum(cost) as cost,  <!-- 总消耗 -->
+        sum(xianjin_cost) as xianjinCost,  <!-- 现金消耗 -->
+        sum(fandian_cost) as fandianCost,  <!-- 后返消耗 -->
+        sum(kuangfan_cost) as kuangfanCost,  <!-- 框返消耗 -->
+        sum(jili_cost) as jiliCost,  <!-- 激励账户消耗 -->
+        sum(xinyong_cost) as xinyongCost,  <!-- 信用账户消耗 -->
+        sum(fengmian_show_count) as fengmianShowCount,  <!-- 封面曝光数 -->
+        sum(fengmian_click_count) as fengmianClickCount,  <!-- 封面点击数 -->
+        sum(sucai_show_count) as sucaiShowCount,  <!-- 素材曝光数 -->
+        sum(convert_count) as convertCount,  <!-- 行为数 -->
+        sum(fengmian_click_rate) as fengmianClickRate,  <!-- 封面点击率 -->
+        sum(convert_click_rate) as convertClickRate  <!-- 转化点击率 -->
+        from
+        ctop_kuaishou_report_daily_agent_sum
+        where
+        date &lt;= #{endDate} and
+        date &gt;= #{startDate}
+    </select>
+</mapper>

+ 4 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportDailyAgentSumService.java

@@ -3,6 +3,8 @@ package cn.com.ctop.kuaishou.modules.report.service;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgentSum;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * 代理商日汇总表
  * @author jeecg-boot
@@ -10,5 +12,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @version V1.0
  */
 public interface IKuaishouReportDailyAgentSumService extends IService<KuaishouReportDailyAgentSum> {
-
+    List<KuaishouReportDailyAgentSum> companyReport(String startDate, String endDate);
+    KuaishouReportDailyAgentSum companyReportSum(String startDate, String endDate);
 }

+ 16 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAgentSumServiceImpl.java

@@ -3,10 +3,13 @@ package cn.com.ctop.kuaishou.modules.report.service.impl;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgentSum;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAgentSumMapper;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentSumService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
+import java.util.List;
+
 /**
  * 代理商日汇总表
  * @author jeecg-boot
@@ -16,4 +19,17 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 @Service
 public class KuaishouReportDailyAgentSumServiceImpl extends ServiceImpl<KuaishouReportDailyAgentSumMapper, KuaishouReportDailyAgentSum> implements IKuaishouReportDailyAgentSumService {
 
+    @Autowired
+    private KuaishouReportDailyAgentSumMapper kuaishouReportDailyAgentSumMapper;
+
+    //公司报表
+    public List<KuaishouReportDailyAgentSum> companyReport(String startDate, String endDate){
+        return kuaishouReportDailyAgentSumMapper.companyReport(startDate,endDate);
+    }
+
+    //公司报表汇总
+    public KuaishouReportDailyAgentSum companyReportSum(String startDate, String endDate){
+        return kuaishouReportDailyAgentSumMapper.companyReportSum(startDate, endDate);
+    }
+
 }

+ 4 - 2
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/BytedancePlanHourlyReportMapper.xml

@@ -64,7 +64,8 @@
         ad_name ,
         campaign_id,
         create_time,
-        update_time)
+        update_time,
+        channel_code)
         values
         <foreach collection="reports" item="report" separator=",">
             (
@@ -129,7 +130,8 @@
             #{report.adName},
             #{report.campaignId},
             #{report.createTime},
-            #{report.updateTime}
+            #{report.updateTime},
+            #{report.channelCode}
             )
         </foreach>
     </insert>

+ 3 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/ReportServiceImpl.java

@@ -241,6 +241,9 @@ public class ReportServiceImpl implements IReportService {
             var data = dataArray.getJSONObject(i);
             if (null != conditions.getTimeGranularity() && CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY.equals(conditions.getTimeGranularity())) {
                 var hourlyReport = new BytedancePlanHourlyReport(data, token.getAccountId());
+                String adName = hourlyReport.getAdName();
+                String[] tags = adName.split("-");
+                hourlyReport.setChannelCode(tags[0]);
                 hourlyReports.add(hourlyReport);
             } else {
                 var dailyReport = new BytedancePlanDailyReport(data, token.getAccountId());