yumeng пре 5 година
родитељ
комит
3a19977f53

+ 65 - 41
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -13,6 +13,7 @@ import com.aliyuncs.mts.model.v20140618.QueryJobListResponse;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import it.sauronsoftware.jave.Encoder;
+import it.sauronsoftware.jave.EncoderException;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -20,6 +21,7 @@ import org.springframework.stereotype.Service;
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
@@ -329,46 +331,68 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         uploadExecutorService.submit(new Runnable() {
             @Override
             public void run() {
-                try {
-                    log.info("获取素材基本信息,code:{}", materialInfo.getCode());
-                    if (!Check.isNull(materialInfo)) {
-                        long l = System.currentTimeMillis();
-                        String url = materialInfo.getUrl().replace(replaceOldValue, replaceValue);
-                        log.info("replaceUrl:{}", url);
-                        String localUrl = LoadFileUtil.downLoadFromUrl(url, downloadUrl);
+                /*try {*/
+                log.info("获取素材基本信息,code:{}", materialInfo.getCode());
+                if (!Check.isNull(materialInfo)) {
+                    long l = System.currentTimeMillis();
+                    String url = materialInfo.getUrl().replace(replaceOldValue, replaceValue);
+                    log.info("replaceUrl:{}", url);
+                    String localUrl = null;
+                    it.sauronsoftware.jave.MultimediaInfo m = null;
+                    FileInputStream fis = null;
+                    try {
+                        localUrl = LoadFileUtil.downLoadFromUrl(url, downloadUrl);
+
                         File file = new File(localUrl);
                         it.sauronsoftware.jave.Encoder encoder = new Encoder();
-                        try {
-                            it.sauronsoftware.jave.MultimediaInfo m = encoder.getInfo(file);
-                            long duration = m.getDuration();
-                            long secondDuration = duration / 1000;
-                            MaterialParameter materialParameter = new MaterialParameter();
-                            materialParameter.setMaterialId(materialInfo.getCode());
-                            // 视频秒数
-                            materialParameter.setSecond(secondDuration);
-                            // 视频格式
-                            materialParameter.setFormat(m.getFormat());
-                            // 视频宽
-                            String width = String.valueOf(m.getVideo().getSize().getWidth());
-                            materialParameter.setWidth(width);
-                            // 视频高
-                            String height = String.valueOf(m.getVideo().getSize().getHeight());
-                            materialParameter.setHeight(height);
-                            FileInputStream fis = new FileInputStream(file);
-                            FileChannel fc = fis.getChannel();
-                            BigDecimal fileSize = new BigDecimal(fc.size());
-                            String size = fileSize.divide(new BigDecimal(1048576), 2, RoundingMode.HALF_UP) + "MB";
-                            materialParameter.setSize(size);
-                            materialParameter.setUpdateTime(new Date());
-
-                            Map<String, Object> deleteMap = new HashMap<>();
-                            deleteMap.put("material_id", materialInfo.getId());
-                            materialParameterMapper.deleteByMap(deleteMap);
-                            int insert = materialParameterMapper.insert(materialParameter);
-                            if (insert > 0) {
-                                log.info("素材基本信息入库完成,用时:{} s", (System.currentTimeMillis() - l) / 1000);
+                        /*try {*/
+                        m = encoder.getInfo(file);
+                        long duration = m.getDuration();
+                        long secondDuration = duration / 1000;
+                        MaterialParameter materialParameter = new MaterialParameter();
+                        materialParameter.setMaterialId(materialInfo.getCode());
+                        // 视频秒数
+                        materialParameter.setSecond(secondDuration);
+                        // 视频格式
+                        materialParameter.setFormat(m.getFormat());
+                        // 视频宽
+                        String width = String.valueOf(m.getVideo().getSize().getWidth());
+                        materialParameter.setWidth(width);
+                        // 视频高
+                        String height = String.valueOf(m.getVideo().getSize().getHeight());
+                        materialParameter.setHeight(height);
+                        fis = new FileInputStream(file);
+                        FileChannel fc = fis.getChannel();
+                        BigDecimal fileSize = new BigDecimal(fc.size());
+                        String size = fileSize.divide(new BigDecimal(1048576), 2, RoundingMode.HALF_UP) + "MB";
+                        materialParameter.setSize(size);
+                        materialParameter.setUpdateTime(new Date());
+
+                        Map<String, Object> deleteMap = new HashMap<>();
+                        deleteMap.put("material_id", materialInfo.getId());
+                        materialParameterMapper.deleteByMap(deleteMap);
+                        int insert = materialParameterMapper.insert(materialParameter);
+                        if (insert > 0) {
+                            log.info("素材基本信息入库完成,用时:{} s", (System.currentTimeMillis() - l) / 1000);
 
+                        }
+                    } catch (FileNotFoundException e) {
+                        e.printStackTrace();
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    } catch (EncoderException e) {
+                        e.printStackTrace();
+
+                    } finally {
+                        try {
+                            if (fis != null) {
+                                fis.close();
                             }
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                    }
+
                             /*Thread thread = new Thread() {
                                 @Override
                                 public void run() {
@@ -382,15 +406,15 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                             };
                             thread.start();*/
 
-                        } catch (Exception e) {
+                       /* } catch (Exception e) {
                             e.printStackTrace();
                         } finally {
                             file.delete();
-                        }
-                    }
-                } catch (Exception e) {
-                    e.printStackTrace();
+                        }*/
                 }
+                /*} catch (Exception e) {
+                    e.printStackTrace();
+                }*/
             }
 
 

+ 1 - 0
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadServiceImpl.java

@@ -170,6 +170,7 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                 JSONObject requestJson = new JSONObject();
                 requestJson.put("file", resource);
                 requestJson.put("signature", materialInfo.getCode());
+
                 QueryWrapper<MaterialParameter> parameterQueryWrapper = new QueryWrapper<>();
                 parameterQueryWrapper.eq("material_id", materialInfo.getCode());
                 parameterQueryWrapper.orderByDesc("create_time").last("limit 1");

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

@@ -24,14 +24,12 @@ 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;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClientBuilder;
-import org.bytedeco.javacpp.freenect2;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -43,9 +41,11 @@ import java.io.InputStreamReader;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.net.URI;
-import java.sql.Timestamp;
 import java.text.ParseException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 @Service
 @Slf4j
@@ -677,24 +677,24 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
 
     /////////////////////////////////////////////////////////////////////////////////////////////////
     //创建异步任务
-    public void bytedanceAsyncTaskCreate (String startDate, String endDate, CtopOauthToken token, Integer type) throws ParseException {
-        int diffMonths = DateUtils.calDiffMonth(DateUtils.parseDate(startDate,"yyyy-MM-dd"),DateUtils.parseDate(endDate,"yyyy-MM-dd"));
+    public void bytedanceAsyncTaskCreate(String startDate, String endDate, CtopOauthToken token, Integer type) throws ParseException {
+        int diffMonths = DateUtils.calDiffMonth(DateUtils.parseDate(startDate, "yyyy-MM-dd"), DateUtils.parseDate(endDate, "yyyy-MM-dd"));
         if (diffMonths == 0) {
             bytedanceAsyncTaskCreateByMonth(startDate, endDate, token, type);
-        }else{
-            for(int i=0; i<=diffMonths ; i++){
-                if (i == 0){
-                    Map<String,String> dateMap = DateUtils.getMaxMinDaysOfAddMonth(startDate,"yyyy-MM-dd", i);
+        } else {
+            for (int i = 0; i <= diffMonths; i++) {
+                if (i == 0) {
+                    Map<String, String> dateMap = DateUtils.getMaxMinDaysOfAddMonth(startDate, "yyyy-MM-dd", i);
                     String end = dateMap.get("endDate");
                     //System.out.println(startDate + " ----- " + end);
                     bytedanceAsyncTaskCreateByMonth(startDate, end, token, type);
-                }else if(i == diffMonths){
-                    Map<String,String> dateMap = DateUtils.getMaxMinDaysOfAddMonth(startDate,"yyyy-MM-dd", i);
+                } else if (i == diffMonths) {
+                    Map<String, String> dateMap = DateUtils.getMaxMinDaysOfAddMonth(startDate, "yyyy-MM-dd", i);
                     String start = dateMap.get("startDate");
                     //System.out.println(start + " ----- " + endDate);
                     bytedanceAsyncTaskCreateByMonth(start, endDate, token, type);
-                }else{
-                    Map<String,String> dateMap = DateUtils.getMaxMinDaysOfAddMonth(startDate,"yyyy-MM-dd", i);
+                } else {
+                    Map<String, String> dateMap = DateUtils.getMaxMinDaysOfAddMonth(startDate, "yyyy-MM-dd", i);
                     String start = dateMap.get("startDate");
                     String end = dateMap.get("endDate");
                     //System.out.println(start + " ----- " + end);
@@ -710,7 +710,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
      * @param endDate
      * @param token
      */
-    private void bytedanceAsyncTaskCreateByMonth(String startDate, String endDate, CtopOauthToken token, Integer type){
+    private void bytedanceAsyncTaskCreateByMonth(String startDate, String endDate, CtopOauthToken token, Integer type) {
         String access_token = token.getAccessToken();
         Long accountId = token.getAccountId();
 
@@ -724,14 +724,14 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
             {
                 put("start_date", startDate);
                 put("end_date", endDate);
-                if(type == 1){//创意
-                    put("group_by", new String[]{"STAT_GROUP_BY_CREATIVE_ID","STAT_GROUP_BY_TIME_DAY","STAT_GROUP_BY_CREATIVE_MATERIAL_MODE"});   //按照创意分组、天分组、创意类型分组查询
-                }else if(type == 2){//广告主
-                    put("group_by", new String[]{"STAT_GROUP_BY_ADVERTISER_ID","STAT_GROUP_BY_TIME_DAY","STAT_GROUP_BY_PRICING_CATEGORY"});   //按照广告主分组、天分组、广告类型类型分组查询
-                }else if(type == 3){//广告组
-                    put("group_by", new String[]{"STAT_GROUP_BY_CAMPAIGN_ID","STAT_GROUP_BY_TIME_DAY","STAT_GROUP_BY_CAMPAIGN_TYPE"});  //按照广告组、天、广告组类型分组
-                }else {//4广告计划
-                    put("group_by", new String[]{"STAT_GROUP_BY_AD_ID","STAT_GROUP_BY_TIME_DAY","STAT_GROUP_BY_LANDING_TYPE"});  //按照广告计划、天、推广类型分组
+                if (type == 1) {//创意
+                    put("group_by", new String[]{"STAT_GROUP_BY_CREATIVE_ID", "STAT_GROUP_BY_TIME_DAY", "STAT_GROUP_BY_CREATIVE_MATERIAL_MODE"});   //按照创意分组、天分组、创意类型分组查询
+                } else if (type == 2) {//广告主
+                    put("group_by", new String[]{"STAT_GROUP_BY_ADVERTISER_ID", "STAT_GROUP_BY_TIME_DAY", "STAT_GROUP_BY_PRICING_CATEGORY"});   //按照广告主分组、天分组、广告类型类型分组查询
+                } else if (type == 3) {//广告组
+                    put("group_by", new String[]{"STAT_GROUP_BY_CAMPAIGN_ID", "STAT_GROUP_BY_TIME_DAY", "STAT_GROUP_BY_CAMPAIGN_TYPE"});  //按照广告组、天、广告组类型分组
+                } else {//4广告计划
+                    put("group_by", new String[]{"STAT_GROUP_BY_AD_ID", "STAT_GROUP_BY_TIME_DAY", "STAT_GROUP_BY_LANDING_TYPE"});  //按照广告计划、天、推广类型分组
                 }
             }
         };
@@ -772,13 +772,13 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
                 }
                 bufferedReader.close();
 
-                JSONObject  json = JSONObject.parseObject(result.toString());
+                JSONObject json = JSONObject.parseObject(result.toString());
                 String jsonString = JSON.toJSONString(json);
 
-                if(!Check.isNull(json)){
+                if (!Check.isNull(json)) {
                     Integer code = json.getInteger("code");
-                    if(code != 0){
-                        log.info("返回信息错误,错误码为:" + code + ",头条accountId:" + accountId + ",message:"+ json.getString("message"));
+                    if (code != 0) {
+                        log.info("返回信息错误,错误码为:" + code + ",头条accountId:" + accountId + ",message:" + json.getString("message"));
                         return;
                     }
                     JSONObject dataJson = json.getJSONObject("data");
@@ -787,7 +787,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
                     BytedanceDailyReportTask task = new BytedanceDailyReportTask();
                     task.setAccountId(accountId);
                     task.setTaskCreateTime(dataJson.getDate("create_time") == null ? null : dataJson.getDate("create_time"));
-                    task.setTaskId(dataJson.getLong("task_id") ==  null ? null : dataJson.getLong("task_id") );
+                    task.setTaskId(dataJson.getLong("task_id") == null ? null : dataJson.getLong("task_id"));
                     task.setTaskName(dataJson.getString("task_name") == null ? null : dataJson.getString("task_name"));
                     task.setTaskParams(JSON.toJSONString(dataJson.getJSONObject("task_params")));
                     task.setJson(jsonString);
@@ -799,8 +799,8 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
                     bytedanceDailyReportTaskMapper.insert(task);
                 }
 
-            }else{
-                log.error("请求有误:" + response );
+            } else {
+                log.error("请求有误:" + response);
             }
         } catch (ClientProtocolException e) {
             e.printStackTrace();
@@ -819,10 +819,10 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
     }
 
     //获取任务列表
-    public void bytedanceAsyncTaskGet(){
+    public void bytedanceAsyncTaskGet() {
         QueryWrapper<BytedanceDailyReportTask> taskQueryWrapper = new QueryWrapper<>();
         //查询三种状态的信息--任务已创建、任务执行中、任务处理中
-        taskQueryWrapper.eq("is_download",0);
+        taskQueryWrapper.eq("is_download", 0);
         //taskQueryWrapper.in("task_status", "ASYNC_TASK_STATUS_CREATED","ASYNC_TASK_STATUS_EXECUTING","ASYNC_TASK_STATUS_EXECUTING_STAGE2");
         taskQueryWrapper.notIn("task_status", "ASYNC_TASK_STATUS_FAILED");
         taskQueryWrapper.orderByDesc("create_time");
@@ -844,11 +844,11 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
                     // 请求参数
                     final Map filtering = new HashMap() {
                         {
-                            put("task_ids",new Long[]{task.getTaskId()});
+                            put("task_ids", new Long[]{task.getTaskId()});
                             put("task_name", task.getTaskName());
                         }
                     };
-                    Map data = new HashMap(){
+                    Map data = new HashMap() {
                         {
                             put("advertiser_id", advertiser_id);
                             put("filtering", filtering);
@@ -863,7 +863,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
                         }
                     };
 
-                    httpEntity.setHeader("Access-Token",access_token);
+                    httpEntity.setHeader("Access-Token", access_token);
 
                     CloseableHttpResponse response = null;
                     CloseableHttpClient client = null;
@@ -874,29 +874,27 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
                         httpEntity.setEntity(new StringEntity(JSONObject.toJSONString(data), ContentType.APPLICATION_JSON));
 
                         response = client.execute(httpEntity);
-                        log.info("response为:" +  response);
                         if (response != null && response.getStatusLine().getStatusCode() == 200) {
-                            BufferedReader bufferedReader  = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+                            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
                             StringBuffer result = new StringBuffer();
                             String line = "";
-                            while((line = bufferedReader.readLine()) != null) {
+                            while ((line = bufferedReader.readLine()) != null) {
                                 result.append(line);
                             }
                             bufferedReader.close();
 
-                            JSONObject  json = JSONObject.parseObject(result.toString());
+                            JSONObject json = JSONObject.parseObject(result.toString());
                             String jsonString = JSON.toJSONString(json);
-                            log.info("返回json为" + jsonString);
 
-                            if(!Check.isNull(json)){
+                            if (!Check.isNull(json)) {
                                 Integer code = json.getInteger("code");
-                                if(code != 0){
+                                if (code != 0) {
                                     log.info("获取任务列表返回信息错误,错误码为:" + code + ",头条accountId:" + accountId + "taskId:" + task.getTaskId());
                                     return;
                                 }
 
                                 JSONObject jsonData = json.getJSONObject("data");
-                                if (Check.isNull(jsonData)){
+                                if (Check.isNull(jsonData)) {
                                     log.error("获取任务列表返回信息data内容为空");
                                 }
                                 JSONArray jsonArrayay = jsonData.getJSONArray("list");
@@ -906,17 +904,17 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
                                     if (!Check.isNull(detailJson)) {
                                         String taskStatus = detailJson.getString("task_status");
 
-                                        if (taskStatus .equals( "ASYNC_TASK_STATUS_COMPLETED")) {
-                                            bytedanceAsyncTaskDownload(task,token,task.getType());
+                                        if (taskStatus.equals("ASYNC_TASK_STATUS_COMPLETED")) {
+                                            bytedanceAsyncTaskDownload(task, token, task.getType());
                                             task.setIsDownload(1);
                                         }
-                                            task.setTaskStatus(taskStatus);
-                                            bytedanceDailyReportTaskMapper.updateById(task);
-                                        }
+                                        task.setTaskStatus(taskStatus);
+                                        bytedanceDailyReportTaskMapper.updateById(task);
                                     }
                                 }
+                            }
 
-                        }else{
+                        } else {
                             log.error("请求有误:" + response);
                         }
 
@@ -941,33 +939,33 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
     }
 
     //下载任务结果   type 1.creative 2.account 3.campaign 4.plan
-    private void bytedanceAsyncTaskDownload(BytedanceDailyReportTask task, CtopOauthToken token, Integer type){
+    private void bytedanceAsyncTaskDownload(BytedanceDailyReportTask task, CtopOauthToken token, Integer type) {
         // 请求地址
         String open_api_domain = "https://ad.toutiao.com";
         String path = "/open_api/2/async_task/download/";
 
         String url = open_api_domain + path;
-        String fileName = task.getAccountId() + "_" + "type" + type + "_" +System.currentTimeMillis() + ".csv";
+        String fileName = task.getAccountId() + "_" + "type" + type + "_" + System.currentTimeMillis() + ".csv";
         Map<String, Object> requestMap = new HashMap<>();
         requestMap.put("advertiser_id", task.getAccountId());
         requestMap.put("task_id", task.getTaskId());
         String localPath = DownloadUtils.downloadByUrl(requestMap, downloadPath, url, token.getAccessToken(), fileName);
-        if(task.getAccountId() !=1649961222605831L && task.getAccountId() != 1643726941045772L){
+        if (task.getAccountId() != 1649961222605831L && task.getAccountId() != 1643726941045772L) {
 
 
-            if(type == 1){
+            if (type == 1) {
                 //素材异步报表
                 bytedanceDailyReportTaskMapper.loadBytedanceDailyCreativeFileAsync(localPath);
-            }else if(type == 2){
+            } else if (type == 2) {
                 //账户异步报表
                 bytedanceDailyReportTaskMapper.loadBytedanceDailyAccountFileAsync(localPath);
-            }else if(type == 3){
+            } else if (type == 3) {
                 //campaign异步报表
                 bytedanceDailyReportTaskMapper.loadBytedanceDailyCampaignFileAsync(localPath);
-            }else if(type == 4){
+            } else if (type == 4) {
                 //plan异步报表
                 bytedanceDailyReportTaskMapper.loadBytedanceDailyPlanFileAsync(localPath);
-            }else{
+            } else {
                 log.error("异步报表类型传入错误,task_id:" + task.getTaskId() + ";类型:" + type);
             }
         }
@@ -975,7 +973,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
 
     /////////////////////////////////////////////////////////\
     //素材报表
-    public void bytedanceMaterialReportRetry(CtopOauthToken token, String startDate, String endDate){
+    public void bytedanceMaterialReportRetry(CtopOauthToken token, String startDate, String endDate) {
         Long accountId = token.getAccountId();
         log.info("头条素材报表当前accountId为:" + accountId);
         Integer page = 1;
@@ -987,22 +985,22 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
         retry.setStartDate(startDate);
         retry.setEndDate(endDate);
         retry.setStatusCode(code);
-        if (code != 200 && code != 1){
+        if (code != 200 && code != 1) {
             retry.setStatus(0);
             bytedanceReportMaterialDailyMapper.replaceMaterialRetry(retry);
-        }else{
+        } else {
             retry.setStatus(1);
             bytedanceReportMaterialDailyMapper.replaceMaterialRetry(retry);
         }
     }
 
-    public void bytedanceMaterialReport(CtopOauthToken token, String startDate, String endDate){
+    public void bytedanceMaterialReport(CtopOauthToken token, String startDate, String endDate) {
         Long accountId = token.getAccountId();
         log.info("头条素材报表当前accountId为:" + accountId);
         Integer page = 1;
         Integer pageSize = 100;
         int code = bytedanceMaterialReportByPage(page, pageSize, token, accountId, startDate, endDate);
-        if (code != 200 && code != 1){
+        if (code != 200 && code != 1) {
             BytedanceReportMaterialRetry retry = new BytedanceReportMaterialRetry();
             retry.setAccountId(accountId);
             retry.setStatus(0);
@@ -1013,7 +1011,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
         }
     }
 
-    private int bytedanceMaterialReportByPage(Integer page, Integer pageSize, CtopOauthToken token, Long accountId, String startDate, String endDate){
+    private int bytedanceMaterialReportByPage(Integer page, Integer pageSize, CtopOauthToken token, Long accountId, String startDate, String endDate) {
         //log.info("当前页数:"+ page);
         String access_token = token.getAccessToken();
 
@@ -1024,18 +1022,18 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
         // 请求参数
         final Map filtering = new HashMap() {
             {
-                put("image_mode",new String[]{"MATERIAL_IMAGE_MODE_TITLE"});
+                put("image_mode", new String[]{"MATERIAL_IMAGE_MODE_TITLE"});
             }
         };
 
-        Map data = new HashMap(){
+        Map data = new HashMap() {
             {
                 put("advertiser_id", accountId);
-                put("start_date",startDate);
-                put("end_date",endDate);
-                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("start_date", startDate);
+                put("end_date", endDate);
+                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"});
             }
         };
 
@@ -1047,7 +1045,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
             }
         };
 
-        httpEntity.setHeader("Access-Token",access_token);
+        httpEntity.setHeader("Access-Token", access_token);
 
         CloseableHttpResponse response = null;
         CloseableHttpClient client = null;
@@ -1071,28 +1069,28 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
             //log.info("头条获取素材报表数据任务获取服务器数据结束,执行耗时:{}秒", (connectEndTime - connectStartTime) / 1000);
             //System.out.println(response);
             if (response != null && response.getStatusLine().getStatusCode() == 200) {
-                BufferedReader bufferedReader  = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
                 StringBuffer result = new StringBuffer();
                 String line = "";
-                while((line = bufferedReader.readLine()) != null) {
+                while ((line = bufferedReader.readLine()) != null) {
                     result.append(line);
                 }
                 bufferedReader.close();
 
-                JSONObject  json = JSONObject.parseObject(result.toString());
+                JSONObject json = JSONObject.parseObject(result.toString());
                 String jsonString = JSON.toJSONString(json);
                 //log.info("返回值为:" + jsonString);
 
-                if(!Check.isNull(json)){
+                if (!Check.isNull(json)) {
                     Integer code = json.getInteger("code");
-                    if(code != 0){
+                    if (code != 0) {
                         log.info("获取任务列表返回信息错误,错误码为:" + code + ",头条accountId:" + accountId + ";返回json为:" + jsonString);
                         returnCode = -1;
                         return -1;
                     }
 
                     JSONObject jsonData = json.getJSONObject("data");
-                    if (Check.isNull(jsonData)){
+                    if (Check.isNull(jsonData)) {
                         log.error("获取任务列表返回信息data内容为空");
                     }
                     JSONObject pageInfo = jsonData.getJSONObject("page_info");
@@ -1100,8 +1098,8 @@ 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);
+                    if (jsonArrayay.size() == 0) {
+                        log.info("accountId:" + accountId + ";没有数据。总页数为:" + totalPage + "当前页数为:" + currentPage);
                         returnCode = 1;
                         return 1;
                     }
@@ -1116,7 +1114,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
                             daily.setImageMode(dimensions.getString("image_mode"));
                             daily.setMaterialId(dimensions.getLong("material_id"));
                             daily.setInventory(dimensions.getString("inventory"));
-                            daily.setStatDatetime(dimensions.getDate("stat_datetime")==null?null:DateUtils.formatDate(dimensions.getDate("stat_datetime"),"yyyy-MM-dd"));
+                            daily.setStatDatetime(dimensions.getDate("stat_datetime") == null ? null : DateUtils.formatDate(dimensions.getDate("stat_datetime"), "yyyy-MM-dd"));
 
                             JSONObject metrics = detailJson.getJSONObject("metrics");
                             daily.setActivePayAmount(metrics.getInteger("active_pay_amount"));
@@ -1219,20 +1217,20 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
                     bytedanceReportMaterialDailyMapper.replaceIntoBatch(bytedanceReportMaterialDailyList);
                     //Long insertEndTime = System.currentTimeMillis();
                     //log.info("头条获取素材报表插入数据结束,执行耗时:{}秒", (insertEndTime - insertStartTime) / 1000);
-                    if(currentPage >= totalPage){
-                        log.info("accountId:" + accountId + "数据同步完成,开始时间:" + startDate + ",结束时间:"+ endDate);
+                    if (currentPage >= totalPage) {
+                        log.info("accountId:" + accountId + "数据同步完成,开始时间:" + startDate + ",结束时间:" + endDate);
                         //returnCode = 1;
                         return 1;
-                    }else{
+                    } else {
                         bytedanceMaterialReportByPage(page + 1, pageSize, token, accountId, startDate, endDate);
                     }
-                }else{
+                } else {
                     returnCode = -1;
-                    log.error("服务器返回为空,json:"+jsonString);
+                    log.error("服务器返回为空,json:" + jsonString);
                     return -1;
                 }
-            }else{
-                log.error("头条素材报表请求有误:accountId:" + accountId + ",开始时间:" + startDate + "结束时间:" + endDate + "错误返回:" +response);
+            } else {
+                log.error("头条素材报表请求有误:accountId:" + accountId + ",开始时间:" + startDate + "结束时间:" + endDate + "错误返回:" + response);
                 returnCode = 0;  //504等状态0;-2连接服务器报错 ;-1对方服务器返回值为空;200正常;1没有数据(也属于正常)
                 return 0;
             }
@@ -1255,7 +1253,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
         return returnCode;
     }
 
-    public List<BytedanceReportMaterialRetry> getRetryList(){
+    public List<BytedanceReportMaterialRetry> getRetryList() {
         return bytedanceReportMaterialDailyMapper.getRetryList();
     }