Prechádzať zdrojové kódy

修改智能投放账户配置逻辑

syh 4 rokov pred
rodič
commit
84d0fc4924
19 zmenil súbory, kde vykonal 374 pridanie a 45 odobranie
  1. 25 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  2. 8 8
      jeecg-boot-module-system/src/main/resources/application-wps.yml
  3. 6 3
      jeecg-boot-module-system/src/main/resources/jeecg/jeecg_database.properties
  4. 70 2
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  5. 9 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAdvertiserStrategyController.java
  6. 8 7
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouCreativeRefusalController.java
  7. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAdvertiserStrategy.java
  8. 0 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouVideoGet.java
  9. 0 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java
  10. 70 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/entity/BytedanceMatReportTaskCheckInfo.java
  11. 18 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceMatReportTaskCheckInfoMapper.java
  12. 29 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceMatReportTaskCheckInfoMapper.xml
  13. 5 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceInterfaceService.java
  14. 14 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceMatReportTaskCheckInfoService.java
  15. 3 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceReportService.java
  16. 61 14
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceInterfaceServiceImpl.java
  17. 18 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceMatReportTaskCheckInfoServiceImpl.java
  18. 12 4
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceReportServiceImpl.java
  19. 1 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ReportServiceImpl.java

+ 25 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java

@@ -1445,4 +1445,29 @@ public class TestController {
         ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
         return result;
     }
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+
+    @GetMapping("loadMatData")
+    public Map<String,Object>getData(String startDate,String endDate,Long accountId){
+        Map<String,Object>result = new HashMap<>();
+        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        Date start = DateUtils.parseDate(startDate,"yyyy-MM-dd");
+        int days = DateUtils.getdaysOfTwoDate(startDate,endDate)+1;
+        for (int i=0;i<days;i++){
+            String getDate = DateUtils.formatDate(DateUtils.addDay(start,i));
+            bytedanceReportService.bytedanceMaterialReport(token, getDate, getDate);
+        }
+        ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
+        return result;
+    }
+
+    @GetMapping("loadAccountData")
+    public Map<String,Object>getData(Long accountId){
+        Map<String,Object>result = new HashMap<>();
+        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        reportService.getAdvertiserReport(token, DateUtils.parseDate("2021-01-01","yyyy-MM-dd"), DateUtils.parseDate("2021-01-31","yyyy-MM-dd"),CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+        ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
+        return result;
+    }
 }

+ 8 - 8
jeecg-boot-module-system/src/main/resources/application-wps.yml

@@ -95,16 +95,16 @@ spring:
         # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
-#        master:
-#          url: jdbc:mysql://139.186.151.174:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true
-#          username: hcst
-#          password: hcst@2020
-#          driver-class-name: com.mysql.jdbc.Driver
         master:
-          url: jdbc:mysql://139.186.27.96:4000/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
-          username: data
-          password: hcst@2021
+          url: jdbc:mysql://139.186.151.174:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true
+          username: hcst
+          password: hcst@2020
           driver-class-name: com.mysql.jdbc.Driver
+#        master:
+#          url: jdbc:mysql://139.186.27.96:4000/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+#          username: data
+#          password: hcst@2021
+#          driver-class-name: com.mysql.jdbc.Driver
   #redis 配置
   redis:
     database: 0

+ 6 - 3
jeecg-boot-module-system/src/main/resources/jeecg/jeecg_database.properties

@@ -1,8 +1,11 @@
 #mysql
 diver_name=com.mysql.jdbc.Driver
-url=jdbc:mysql://139.186.151.174:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
-username=hcst
-password=hcst@2020
+#url=jdbc:mysql://139.186.151.174:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+#username=hcst
+#password=hcst@2020
+url=jdbc:mysql://139.186.27.96:4000/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+username=data
+password=hcst@2021
 database_name=jeecg-boot
 #oracle
 #diver_name=oracle.jdbc.driver.OracleDriver

+ 70 - 2
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -556,9 +556,77 @@ public class SampleTest {
         aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2, 250);
     }
 
-    @Autowired
-    private IBytedancePlanDailyReportService planDailyReportService;
+    @Test
+    public void testLoadBytedanceDataV2(){
+        String accountIds=
+                "1675440464386062," +
+                        "1688606248211533," +
+                        "1669181787105294," +
+                        "1687571097467912," +
+                        "1650079154438157," +
+                        "1680697900744711," +
+                        "1678156679964680," +
+                        "1670727177043982," +
+                        "1676160388944910," +
+                        "1687559760306190," +
+                        "1687382871519240," +
+                        "1680312075164686," +
+                        "1675440465991688," +
+                        "1664657972166663," +
+                        "1688193173408782," +
+                        "1675616147056647," +
+                        "1687308848716814," +
+                        "1686394621234247," +
+                        "1683594409340935," +
+                        "1683676478859341," +
+                        "1686384860112904," +
+                        "1668290872519693," +
+                        "1674063202781191," +
+                        "1685024266033160," +
+                        "1669714891201544," +
+                        "1687758256277512," +
+                        "1675434231118856," +
+                        "1686394621807687," +
+                        "1678411706704903," +
+                        "1686223489547271," +
+                        "1660120711467022," +
+                        "1686833795211278," +
+                        "1680697899143175," +
+                        "1661313994984462," +
+                        "1661313995480077," +
+                        "1636295780727820," +
+                        "1676540490482759," +
+                        "1675342904713223," +
+                        "1686771461984327," +
+                        "1685841129360391," +
+                        "1683676477736973," +
+                        "1661313994470413," +
+                        "1663465141771272," +
+                        "1687758256732174," +
+                        "1686223482927117," +
+                        "1686835166313479," +
+                        "1642648003678215," +
+                        "1639753233213454," +
+                        "1675239584963662," +
+                        "1674634579279885," +
+                        "1650263841162253," +
+                        "1672178052130888";
+        String [] accountArray = accountIds.split(",");
+        for (int i=0;i<accountArray.length;i++){
+            CtopOauthToken token = tokenService.getTokenByAccountId(Long.parseLong(accountArray[i]));
+
+            reportService.getAdvertiserReport(token, DateUtils.parseDate("2021-01-14","yyyy-MM-dd"), DateUtils.parseDate("2021-01-14","yyyy-MM-dd"),CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+        }
+    }
 
+
+    @Test
+    public void checkBytedanceReport(){
+        CtopOauthToken token = tokenService.getTokenByAccountId(1678959391271949L);
+        String startDate = "2021-01-01 00:00:00";
+        String endDate = "2021-01-31 00:00:00";
+        bytedanceReportService.checkoutData(token,startDate,endDate);
+    }
     @Test
     public void etlKuaishouProjectData() {
         CtopOauthToken token = tokenService.getTokenByAccountId(1660666858777607L);

+ 9 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAdvertiserStrategyController.java

@@ -4,10 +4,12 @@ import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAdvertiserStrategyService;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.annotations.ApiOperation;
+import io.swagger.models.auth.In;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
@@ -72,7 +74,7 @@ public class AiKuaishouAdvertiserStrategyController {
 	private IUserAllocationService allocationService;
 
 	/**
-	  *   添加
+	 *   添加
 	 * @param aiKuaishouAdvertiserStrategy
 	 * @return
 	 */
@@ -81,6 +83,11 @@ public class AiKuaishouAdvertiserStrategyController {
 	public Result<AiKuaishouAdvertiserStrategy> add(@RequestBody AiKuaishouAdvertiserStrategy aiKuaishouAdvertiserStrategy) {
 		Result<AiKuaishouAdvertiserStrategy> result = new Result<>();
 		try {
+			Integer singleAppId = aiKuaishouAdvertiserStrategy.getSingleAppid();
+			if(null!=singleAppId&&singleAppId==1){
+				Integer appId = Integer.parseInt(JSONArray.parseArray(aiKuaishouAdvertiserStrategy.getAppIdArray()).getString(0));
+				aiKuaishouAdvertiserStrategy.setAppId(appId);
+			}
 			aiKuaishouAdvertiserStrategyService.save(aiKuaishouAdvertiserStrategy);
 			result.success("添加成功!");
 		} catch (Exception e) {
@@ -95,8 +102,7 @@ public class AiKuaishouAdvertiserStrategyController {
 	 * @param aiKuaishouAdvertiserStrategy
 	 * @return
 	 */
-	@ApiOperation(value="快手账户策略设置信息表-编辑", notes="快手账户策略设置信息表-编辑")
-	@PutMapping(value = "/edit")
+	@PostMapping(value = "/edit")
 	public Result<AiKuaishouAdvertiserStrategy> edit(@RequestBody AiKuaishouAdvertiserStrategy aiKuaishouAdvertiserStrategy) {
 		Result<AiKuaishouAdvertiserStrategy> result = new Result<>();
 		AiKuaishouAdvertiserStrategy aiKuaishouAdvertiserStrategyEntity = aiKuaishouAdvertiserStrategyService.getById(aiKuaishouAdvertiserStrategy.getId());

+ 8 - 7
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouCreativeRefusalController.java

@@ -45,7 +45,7 @@ public class KuaiShouCreativeRefusalController {
     static ExecutorService executorService = Executors.newFixedThreadPool(100);
 
     /**
-     * 创意拒审重提
+     * 创意拒审重提
      *
      * @param requestJson
      * @return
@@ -65,7 +65,8 @@ public class KuaiShouCreativeRefusalController {
             if (Check.isNull(oauthToken)) {
                 throw new Exception("未获取到账户信息");
             }
-            Integer updateType = requestJson.getInteger("updateType"); //  0 更换封面 1 修改广告语
+            //  0 更换封面 1 修改广告语
+            Integer updateType = requestJson.getInteger("updateType");
             if (Check.isNull(updateType)) {
                 throw new Exception("请输入修改类型");
             }
@@ -90,7 +91,6 @@ public class KuaiShouCreativeRefusalController {
                                     String imageToken = getImageToken(signature, accountId, oauthToken.getAccessToken(), url);
                                     if (!Check.isNull(imageToken)) {
                                         updateJson.put("imageToken", imageToken);
-
                                     }
                                 }
                             } else if (updateType == 1) { // 修改广告语
@@ -109,13 +109,14 @@ public class KuaiShouCreativeRefusalController {
                 });
             }
             returnJson.put("code", 0);
-            returnJson.put("message", "异步提交中");
+            returnJson.put("message", "异步任务提交完成,请耐心等待");
+            return returnJson;
         } catch (Exception e) {
             e.printStackTrace();
-            returnJson.put("code", 0);
-            returnJson.put("message", e.getMessage());
+            returnJson.put("code", -1);
+            returnJson.put("message", "服务异常");
+            return returnJson;
         }
-        return returnJson;
     }
 
 

+ 17 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAdvertiserStrategy.java

@@ -168,6 +168,7 @@ public class AiKuaishouAdvertiserStrategy {
 	private String clickTrackUrl;
 	/**第三方开始播放监测链接*/
 	private String impressionUrl;
+	private Integer generalTrack;
 	/**第三方有效播放监测链接*/
 	private String adPhotoPlayedT3sUrl;
 	/**第三方点击按钮监测链接*/
@@ -184,6 +185,22 @@ public class AiKuaishouAdvertiserStrategy {
 	private Date effectiveTime;
 	/**失效时间*/
 	private Date expiryTime;
+	/**
+	 * 是否开启智能封面
+	 */
+	private Integer smartCover;
+	/**
+	 * 是否开启素材挖掘
+	 */
+	private Integer assetMining;
+	/**
+	 * 是否单应用
+	 */
+	private Integer singleAppid;
+	/**
+	 * 投放中的appId数组
+	 */
+	private String appIdArray;
 
 	@TableField(exist = false)
 	private String authName;

+ 0 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouVideoGet.java

@@ -96,5 +96,4 @@ public class KuaiShouVideoGet {
     private Integer channelType;
     private Integer status;
     private Long userId;
-    private Integer aiStatus;
 }

+ 0 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java

@@ -125,9 +125,6 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
         if (null != accountId && accountId != 0) {
             queryWrapper.eq("account_id", accountId);
         }
-        if (null != aiStatus && aiStatus != 0) {
-            queryWrapper.eq("ai_status", aiStatus);
-        }
         queryWrapper.orderByDesc("stat_date");
         return this.list(queryWrapper);
     }

+ 70 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/entity/BytedanceMatReportTaskCheckInfo.java

@@ -0,0 +1,70 @@
+package cn.com.ctop.toutiao.modules.report.entity;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 报表数据核验信息
+ * @author jeecg-boot
+ * @date   2021-02-02
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_bytedance_mat_report_task_check_info")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_bytedance_mat_report_task_check_info对象", description="报表数据核验信息")
+public class BytedanceMatReportTaskCheckInfo {
+
+	/**id*/
+	@TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+	private Long id;
+	/**accountId*/
+	@Excel(name = "accountId", width = 15)
+    @ApiModelProperty(value = "accountId")
+	private Long accountId;
+	/**stateDate*/
+	@Excel(name = "stateDate", width = 15)
+    @ApiModelProperty(value = "stateDate")
+	private String stateDate;
+	/**accountCost*/
+	@Excel(name = "accountCost", width = 15)
+    @ApiModelProperty(value = "accountCost")
+	private BigDecimal accountCost;
+	/**videoCost*/
+	@Excel(name = "videoCost", width = 15)
+    @ApiModelProperty(value = "videoCost")
+	private BigDecimal videoCost;
+	/**imageCost*/
+	@Excel(name = "imageCost", width = 15)
+    @ApiModelProperty(value = "imageCost")
+	private BigDecimal imageCost;
+	/**status*/
+	@Excel(name = "status", width = 15)
+    @ApiModelProperty(value = "status")
+	private Integer status;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+	/**czCost*/
+	@Excel(name = "czCost", width = 15)
+    @ApiModelProperty(value = "czCost")
+	private BigDecimal czCost;
+}

+ 18 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceMatReportTaskCheckInfoMapper.java

@@ -0,0 +1,18 @@
+package cn.com.ctop.toutiao.modules.report.mapper;
+
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceMatReportTaskCheckInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 报表数据核验信息
+ * @author: jeecg-boot
+ * @date:   2021-02-02
+ * @cersion: V1.0
+ */
+public interface BytedanceMatReportTaskCheckInfoMapper extends BaseMapper<BytedanceMatReportTaskCheckInfo> {
+
+    List<BytedanceMatReportTaskCheckInfo> getByParams(@Param(value = "accountId") Long accountId, @Param(value = "startDate")String startDate, @Param(value = "endDate") String endDate);
+}

+ 29 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceMatReportTaskCheckInfoMapper.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.toutiao.modules.report.mapper.BytedanceMatReportTaskCheckInfoMapper">
+
+    <select id="getByParams"
+            resultType="cn.com.ctop.toutiao.modules.report.entity.BytedanceMatReportTaskCheckInfo">
+        select a.*, a.accountCost - a.videoCost - a.imageCost as 'cc'
+        from (select account.stat_datetime,
+        account.advertiser_id,
+        sum(account.cost)                                as 'accountCost',
+        (select sum(video.cost)
+        from ctop_bytedance_report_material_daily video
+        where video.stat_datetime = left(account.stat_datetime, 10)
+        and video.account_id = account.advertiser_id) as 'videoCost',
+        (select (case
+        when sum(image.cost) is null
+        then 0
+        else sum(image.cost) end)
+        from ctop_bytedance_report_image_daily image
+        where image.stat_datetime = left(account.stat_datetime, 10)
+        and image.account_id = account.advertiser_id) as 'imageCost'
+        from ctop_bytedance_report_advertiser_daily account
+        where account.stat_datetime &gt;= #{startDate}
+        and account.stat_datetime &lt;= #{endDate}
+        AND account.advertiser_id = #{accountId}
+        group by account.stat_datetime
+        order by account.stat_datetime) a;
+    </select>
+</mapper>

+ 5 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceInterfaceService.java

@@ -2,6 +2,8 @@ package cn.com.ctop.toutiao.modules.report.service;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportPlayableRetry;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 
 import java.util.List;
 
@@ -16,4 +18,7 @@ public interface IBytedanceInterfaceService {
 
     int bytedancePlayableReportRetry(Integer type, CtopOauthToken token, String startDate, String endDate);
 
+    JSONObject createAsyncTask(CtopOauthToken token, String startDate, String endDate, JSONArray groupByArray);
+
+    JSONObject getAsyncTask(CtopOauthToken token, JSONArray taskIds);
 }

+ 14 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceMatReportTaskCheckInfoService.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.toutiao.modules.report.service;
+
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceMatReportTaskCheckInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 报表数据核验信息
+ * @Author: jeecg-boot
+ * @Date:   2021-02-02
+ * @Version: V1.0
+ */
+public interface IBytedanceMatReportTaskCheckInfoService extends IService<BytedanceMatReportTaskCheckInfo> {
+
+}

+ 3 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceReportService.java

@@ -41,4 +41,7 @@ public interface IBytedanceReportService {
     int bytedanceVideoMaterialReport(CtopOauthToken token, String startDate, String endDate);
 
     void bytedanceMaterialReportV2(BytedanceAccountReportTaskRecord record);
+
+    void checkoutData(CtopOauthToken token, String startDate, String endDate);
+
 }

+ 61 - 14
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceInterfaceServiceImpl.java

@@ -17,11 +17,22 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Primary;
 import org.springframework.stereotype.Service;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -44,19 +55,6 @@ public class BytedanceInterfaceServiceImpl implements IBytedanceInterfaceService
 
     @Override
     public void searchLog(Long accountId, CtopOauthToken token, Integer operationTarget, String startDate, String endDate){
-
-        //int campaignCount = byteDanceCampaignService.count(parameterQueryWrapper);
-        //int campaignPageSize = 20;
-        //int campaignPage = 1;
-        //
-        //Integer campaignTotalPage = (campaignCount - 1) / campaignPageSize + 1;
-        //if (campaignPage < campaignTotalPage) {
-        //    QueryWrapper<ByteDanceCampaign> parameterQueryWrapper2 = new QueryWrapper<>();
-        //    parameterQueryWrapper2.eq("account_id", accountId);
-        //    parameterQueryWrapper2.last("limit" +  (campaignPage-1) +  "," + campaignPageSize);
-        //    parameterQueryWrapper2.select("id");
-        //
-        //}
         int pageNum = 1;
         int pageSize = 20;
         String startTime = startDate + " 00:00:00";
@@ -163,7 +161,7 @@ public class BytedanceInterfaceServiceImpl implements IBytedanceInterfaceService
                 }
 
                 //按类型入库
-                if (records != null && records.size() != 0) {
+                if (records.size() != 0) {
                     insertLog(operationType, records);
                 }
 
@@ -332,6 +330,55 @@ public class BytedanceInterfaceServiceImpl implements IBytedanceInterfaceService
         return returnCode;
     }
 
+    @Override
+    public JSONObject createAsyncTask(CtopOauthToken token, String startDate, String endDate, JSONArray groupByArray) {
+        // 请求地址
+        String url = "https://ad.toutiao.com/open_api/2/async_task/create/";
+        // 请求参数
+        JSONObject filtering= new JSONObject();
+        filtering.put("start_date",startDate);
+        filtering.put("end_date",endDate);
+        filtering.put("group_by",groupByArray);
+        JSONObject params = new JSONObject();
+        params.put("advertiser_id", token.getAccountId());
+        params.put("task_name", "test");
+        params.put("task_type", "REPORT");
+        params.put("task_params", filtering);
+        return HttpUtils.bytedancePostRequest(token.getAccessToken(),url,params);
+    }
+
+    @Override
+    public JSONObject getAsyncTask(CtopOauthToken token, JSONArray taskIds) {
+        // 请求地址
+        String url = "https://ad.toutiao.com/open_api/2/async_task/get/";
+        // 请求参数
+        JSONObject filtering = new JSONObject();
+        filtering.put("task_ids",taskIds);
+
+        JSONObject params = new JSONObject();
+        params.put("advertiser_id", token.getAccountId());
+        params.put("filtering", filtering);
+        return HttpUtils.bytedanceGetRequest(token.getAccessToken(),url,params);
+    }
+
+    public JSONObject dowanloadAsyncTask(CtopOauthToken  token,Long taskId) {
+        // 请求地址
+        String url = "https://ad.toutiao.com/open_api/2/async_task/download/";
+        // 请求参数
+        JSONObject filtering = new JSONObject();
+        filtering.put("start_date", "2019-08-08");
+        filtering.put("end_date","2019-08-08");
+        filtering.put("group_by",new String[]{"STAT_GROUP_BY_CAMPAIGN_ID"});
+
+        JSONObject params = new JSONObject();
+        params.put("advertiser_id", token.getAccountId());
+        params.put("task_id", taskId);
+        return HttpUtils.bytedanceGetRequest(token.getAccessToken(),url,params);
+    }
+
+
+
+
 
 
 

+ 18 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceMatReportTaskCheckInfoServiceImpl.java

@@ -0,0 +1,18 @@
+package cn.com.ctop.toutiao.modules.report.service.impl;
+
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceMatReportTaskCheckInfo;
+import cn.com.ctop.toutiao.modules.report.mapper.BytedanceMatReportTaskCheckInfoMapper;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceMatReportTaskCheckInfoService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 报表数据核验信息
+ * @author jeecg-boot
+ * @date   2021-02-02
+ * @version V1.0
+ */
+@Service
+public class BytedanceMatReportTaskCheckInfoServiceImpl extends ServiceImpl<BytedanceMatReportTaskCheckInfoMapper, BytedanceMatReportTaskCheckInfo> implements IBytedanceMatReportTaskCheckInfoService {
+
+}

+ 12 - 4
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceReportServiceImpl.java

@@ -4,10 +4,8 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
-import cn.com.ctop.toutiao.modules.report.entity.BytedanceAccountReportTaskRecord;
-import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialDaily;
-import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialRetry;
-import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportVideoMaterialDaily;
+import cn.com.ctop.toutiao.modules.report.entity.*;
+import cn.com.ctop.toutiao.modules.report.mapper.BytedanceMatReportTaskCheckInfoMapper;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMapper;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceAccountReportTaskRecordService;
@@ -20,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.*;
@@ -551,6 +550,14 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
 //        bytedanceReportMaterialDailyMapper.updateImageReportPlaneName();
         log.info("头条素材报表结束 当前accountId为:{}  {}~{}" , accountId, record.getStartDate(),record.getEndDate());
     }
+    @Resource
+    private BytedanceMatReportTaskCheckInfoMapper checkInfoMapper;
+
+    @Override
+    public void checkoutData(CtopOauthToken token, String startDate, String endDate) {
+        //1:检查
+        List<BytedanceMatReportTaskCheckInfo>checkInfoList = checkInfoMapper.getByParams(token.getAccountId(),startDate,endDate);
+    }
 
     private int bytedanceMaterialReportByPage(Integer page, Integer pageSize, CtopOauthToken token, Long accountId, String startDate, String endDate) {
         // 请求地址
@@ -567,6 +574,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
             }
         };
         JSONObject json = HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, JSONObject.parseObject(JSONObject.toJSONString(data)));
+        System.out.println(json);
         if (json == null) {
             log.error("返回为空,请求有误:" + JSONObject.toJSONString(data));
             return -2;

+ 1 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ReportServiceImpl.java

@@ -86,6 +86,7 @@ public class ReportServiceImpl implements IReportService {
         config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
         JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(conditions, config));
         JSONObject getObject = getAdvertiserStat(token, jsonObject);
+        System.out.println(getObject);
         if(null == getObject){
             XxlJobHelper.log("头条广告主数据获取异常");
             return;