Просмотр исходного кода

Merge branch 'test_performance2'

hcst_sunzhen 5 лет назад
Родитель
Сommit
3a3eea318c

+ 2 - 1
module-report/src/main/java/cn/com/ctop/bytedance/controller/BytedanceReportController.java

@@ -143,13 +143,14 @@ public class BytedanceReportController {
                 return result;
             }
             for (CtopOauthToken token : tokens) {
-                //if(token.getAccountId() == 1662649623517198L){
+                //if(token.getAccountId() == 1647352267707396L){
                     bytedanceReportService.bytedanceMaterialReport(token,startDate,endDate);
                 //}
             }
             Long end = System.currentTimeMillis();
             log.info("头条获取素材报表数据任务执行结束,执行耗时:{}秒", (end - start) / 1000);
         } catch (Exception e) {
+            log.error("头条获取素材报表数据任务执行结失败");
             e.printStackTrace();
             result.setSuccess(false);
         }

+ 14 - 5
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/BytedanceReportServiceImpl.java

@@ -23,6 +23,7 @@ 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.config.RequestConfig;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
 import org.apache.http.entity.ContentType;
@@ -974,6 +975,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
     public void bytedanceMaterialReport(CtopOauthToken token, String startDate, String endDate){
         //CtopOauthToken token = ctopOauthTokenService.getTokenByAccountId(accountId);
         Long accountId = token.getAccountId();
+        log.info("头条素材报表当前accountId为:" + accountId);
         Integer page = 1;
         Integer pageSize = 500;
         bytedanceMaterialReportByPage(page, pageSize, token, accountId, startDate, endDate);
@@ -1002,10 +1004,6 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
                 put("page",page);
                 put("page_size",pageSize);
                 put("group_by", new String[]{"STAT_GROUP_BY_MATERIAL_ID","STAT_GROUP_BY_INVENTORY","STAT_GROUP_BY_IMAGE_MODE","STAT_GROUP_BY_TIME_DAY"});
-                //put("group_by", new String[]{"STAT_GROUP_BY_MATERIAL_ID"});
-                //put("filtering",filtering);
-                //put("order_field","stat_datetime");
-                //put("order_type","ASC");
             }
         };
 
@@ -1027,6 +1025,12 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
             httpEntity.setURI(URI.create(open_api_domain + path));
             httpEntity.setEntity(new StringEntity(JSONObject.toJSONString(data), ContentType.APPLICATION_JSON));
 
+            //RequestConfig requestConfig = RequestConfig.custom()
+            //        .setConnectTimeout(60000).setConnectionRequestTimeout(60000)
+            //        .setSocketTimeout(60000).build();
+
+            //httpEntity.setConfig(requestConfig);
+
             response = client.execute(httpEntity);
             //System.out.println(response);
             if (response != null && response.getStatusLine().getStatusCode() == 200) {
@@ -1045,7 +1049,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
                 if(!Check.isNull(json)){
                     Integer code = json.getInteger("code");
                     if(code != 0){
-                        log.info("获取任务列表返回信息错误,错误码为:" + code + ",头条accountId:" + accountId );
+                        log.info("获取任务列表返回信息错误,错误码为:" + code + ",头条accountId:" + accountId + ";返回json为:" + jsonString);
                         return;
                     }
 
@@ -1058,6 +1062,10 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
                     Integer currentPage = pageInfo.getInteger("page");
 
                     JSONArray jsonArrayay = jsonData.getJSONArray("list");
+                    if(jsonArrayay.size() == 0){
+                        log.info("accountId:" + accountId + ";没有数据。总页数为:" +  totalPage + "当前页数为:" + currentPage);
+                        return;
+                    }
                     List<BytedanceReportMaterialDaily> bytedanceReportMaterialDailyList = new ArrayList<>();
                     for (int i = 0; i < jsonArrayay.size(); i++) {
                         BytedanceReportMaterialDaily daily = new BytedanceReportMaterialDaily();
@@ -1170,6 +1178,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
 
                     bytedanceReportMaterialDailyMapper.replaceIntoBatch(bytedanceReportMaterialDailyList);
                     if(currentPage >= totalPage){
+                        log.info("accountId:" + accountId + "数据同步完成");
                         return;
                     }else{
                         bytedanceMaterialReportByPage(page + 1, pageSize, token, accountId, startDate, endDate);

+ 18 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceVideoInfo.java

@@ -101,6 +101,18 @@ public class ByteDanceVideoInfo {
     @ApiModelProperty(value = "updateTime")
     private Date updateTime;
 
+    private String url;
+
+    private String format;
+
+    private String posterUrl;
+
+    private Long bitRate;
+
+    private Long materialId;
+
+    private String source;
+
     public ByteDanceVideoInfo(JSONObject data, CtopOauthToken token) {
         this.id = data.getString("id");
         this.fileId = data.getString("video_id");
@@ -113,6 +125,12 @@ public class ByteDanceVideoInfo {
         this.videoUrl = "https://aweme.snssdk.com/aweme/v1/playwm/?video_id="+data.getString("id")+"&line=0";
         this.signature = data.getString("signature");
         this.status = 1;
+        this.source = data.getString("source");
+        this.materialId = data.getLong("material_id");
+        this.bitRate = data.getLong("bit_rate");
+        this.posterUrl = data.getString("poster_url");
+        this.format = data.getString("format");
+        this.url = data.getString("url");
         Date now = new Date();
         this.createTime = now;
         this.updateTime = now;

+ 12 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/mapper/xml/ByteDanceVideoInfoMapper.xml

@@ -6,6 +6,12 @@
         id,
         advertiser_id,
         account_id,
+        material_id,
+        url,
+        format,
+        poster_url,
+        bit_rate,
+        source,
         file_id,
         width,
         height,
@@ -22,6 +28,12 @@
             #{video.id},
             #{video.advertiserId},
             #{video.accountId},
+            #{video.materialId},
+            #{video.url},
+            #{video.format},
+            #{video.posterUrl},
+            #{video.bitRate},
+            #{video.source},
             #{video.fileId},
             #{video.width},
             #{video.height},

+ 1 - 1
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/xml/UserEfficientVideoMapMapper.xml

@@ -369,7 +369,7 @@
     <select id="getMaterialAccountInfoByMaterialId" resultType="cn.com.ctop.userefficientvideomap.entity.DesignMaterialInfo">
         select
         a.account_id as accountId,
-        a.account_name as accountName,
+        <!-- a.account_name as accountName, -->
         '快手' as platform,
         sum(charge) as totalCost
         from