Forráskód Böngészése

修改标签库接口逻辑

syh 4 éve
szülő
commit
d33e93e29a

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

@@ -0,0 +1,19 @@
+package org.jeecg.modules.ctop.controller;
+
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportMaterialDailyService;
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+@RestController
+@RequestMapping("image")
+public class ImageCostController {
+    @Autowired
+    private IBytedanceReportMaterialDailyService materialDailyService;
+    @PostMapping("bytedance/cost")
+    public Map<String,Object> bytedanceImageCost(@RequestBody JSONObject data){
+        return materialDailyService.bytedanceImageCost(data);
+    }
+}

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

@@ -3,18 +3,23 @@ package org.jeecg.modules.ctop.controller;
 import cn.com.ctop.common.module.entity.TagInfo;
 import cn.com.ctop.common.module.model.TagInfoTreeModel;
 import cn.com.ctop.common.module.service.ITagInfoService;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.system.model.TagInfoTree;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
@@ -32,6 +37,50 @@ public class TagInfoController {
 	@Autowired
 	private ITagInfoService tagInfoService;
 
+	 /**
+	  * 加载数据节点
+	  *
+	  * @return
+	  */
+	 @RequestMapping(value = "/treeList", method = RequestMethod.GET)
+	 public Result<List<TagInfoTree>> list() {
+		 long start = System.currentTimeMillis();
+		 Result<List<TagInfoTree>> result = new Result<>();
+		 try {
+			 LambdaQueryWrapper<TagInfo> query = new LambdaQueryWrapper<>();
+			 query.eq(TagInfo::getDelFlag, CommonConstant.DEL_FLAG_0);
+			 query.orderByAsc(TagInfo::getTagOrder);
+			 List<TagInfo> list = tagInfoService.list(query);
+			 List<TagInfoTree> treeList = new ArrayList<>();
+			 getTreeList(treeList, list, null);
+			 result.setResult(treeList);
+			 result.setSuccess(true);
+			 log.info("======获取全部菜单数据=====耗时:" + (System.currentTimeMillis() - start) + "毫秒");
+		 } catch (Exception e) {
+			 log.error(e.getMessage(), e);
+		 }
+		 return result;
+	 }
+
+	 private void getTreeList(List<TagInfoTree> treeList, List<TagInfo> metaList, TagInfoTree temp) {
+		 for (TagInfo tagInfo : metaList) {
+			 Long tempPid = tagInfo.getParentId();
+			 TagInfoTree tree = new TagInfoTree(tagInfo);
+			 if (temp == null && oConvertUtils.isEmpty(tempPid)) {
+				 treeList.add(tree);
+				 if (!tree.isLeaf()) {
+					 getTreeList(treeList, metaList, tree);
+				 }
+			 } else if (temp != null && tempPid != null && tempPid.equals(temp.getId())) {
+				 temp.getChildren().add(tree);
+				 if (!tree.isLeaf()) {
+					 getTreeList(treeList, metaList, tree);
+				 }
+			 }
+
+		 }
+	 }
+
 	/**
 	  * 分页列表查询
 	 * @param tagInfo

+ 105 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/model/TagInfoTree.java

@@ -0,0 +1,105 @@
+package org.jeecg.modules.system.model;
+
+import cn.com.ctop.common.module.entity.TagInfo;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+@Data
+public class TagInfoTree implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * id
+     */
+    private String id;
+
+    private String key;
+    private String title;
+
+    /**
+     * 父id
+     */
+    private String parentId;
+
+    /**
+     * 标签名称
+     */
+    private String tagName;
+
+    /**
+     * 编码
+     */
+    private String tagCode;
+    /**
+     * 排序
+     */
+    private Integer tagOrder;
+
+    /**
+     * 所属一级标签id
+     */
+    private Long firstTagId;
+
+    /**
+     * 所属二级标签id
+     */
+    private Long secendTagId;
+
+    /**
+     * 简介
+     */
+    private String description;
+
+    private String model;
+
+    private Integer status;
+
+    private Integer delFlag;
+
+    private Integer level;
+
+    private Long tagCategoryId;
+
+    private String userId;
+    /**
+     * 是否叶子节点: 1:是 0:不是
+     */
+    private boolean isLeaf;
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+
+    private List<TagInfoTree> children;
+
+    public TagInfoTree(TagInfo tagInfo) {
+        this.key = tagInfo.getId()+"";
+        this.id = tagInfo.getId()+"";
+        this.title = tagInfo.getTagName();
+        this.parentId = tagInfo.getParentId()+"";
+        this.tagName = tagInfo.getTagName();
+        this.tagCode = tagInfo.getTagCode();
+        this.tagOrder = tagInfo.getTagOrder();
+        this.delFlag = tagInfo.getDelFlag();
+        this.description = tagInfo.getDescription();
+        this.firstTagId = tagInfo.getFirstTagId();
+        this.secendTagId = tagInfo.getSecendTagId();
+        this.description = tagInfo.getDescription();
+        this.model = tagInfo.getModel();
+        this.status = tagInfo.getStatus();
+        this.delFlag = tagInfo.getDelFlag();
+        this.level = tagInfo.getLevel();
+        this.tagCategoryId = tagInfo.getTagCategoryId();
+        this.userId = tagInfo.getUserId();
+        this.createTime = tagInfo.getCreateTime();
+        this.updateTime = tagInfo.getUpdateTime();
+        this.isLeaf = tagInfo.isLeaf();
+    }
+}

+ 29 - 15
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -18,8 +18,8 @@ import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
 import cn.com.ctop.toutiao.modules.material.entity.ByteDanceAdvertisePlan;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertisePlanService;
-import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
 import cn.com.ctop.toutiao.modules.report.service.IReportService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -55,17 +55,25 @@ public class SampleTest {
     @Autowired
     private IUserAllocationService userAllocationService;
     @Autowired
-    private IByteDanceAdvertiserDataService advertiserDataService;
+    private IBytedanceReportService bytedanceReportService;
     @Test
-    public void loadBytedanceCreativeData() {
-//        List<UserAllocation>allocations = userAllocationService.getByParams(633L,null,0);
-//
-//        if(null!=allocations&&!allocations.isEmpty()){
-//            for (UserAllocation allocation:allocations) {
-//                CtopOauthToken token = oauthTokenService.getTokenByAccountId(allocation.getAccountId());
-//                advertiserDataService.getAdvertiserPlan(token, "", null, null);
+    public void loadBytedanceMatData(){
+        executorService = Executors.newFixedThreadPool(5);
+        List<CtopOauthToken> tokens = oauthTokenService.selectToutiaoToken();
+//        for(int i=14;i<45;i++){
+//            Date getDate2 = DateUtils.addDay(new Date(), -i);
+            String date2 = DateUtils.formatDate(new Date());
+            for (CtopOauthToken token:tokens) {
+                //获取头条素材报表两天前的数据
+//                XxlJobLogger.log("账户"+token.getAccountId() + "素材报表数据任务开始,任务时间:" + date2 + "~" + date2);
+                reportService.getAdvertiserPlanReport(token,new Date(),new Date(),CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+//                XxlJobLogger.log("账户"+token.getAccountId() + "素材报表数据任务完成,任务时间:" + date2 + "~" + date2);
 //            }
-//        }
+        }
+    }
+
+    @Test
+    public void loadBytedanceCreativeData() {
         UserAllocation allocation = userAllocationService.getByAccountId(1648083559613447L);
         CtopOauthToken token = oauthTokenService.getTokenByAccountId(1648083559613447L);
 //        advertiserDataService.getAdvertiserPlan(token, "", null, null);
@@ -219,11 +227,6 @@ public class SampleTest {
     @Test
     public void loadKuaishouAgentData() {
         kuaishouReportDailyAgentService.loginAgent();
-//        for(int i=0;i<20;i++){
-//            String currentDate = DateUtils.formatDate(DateUtils.addDay(new Date(),-i));
-//            kuaishouReportDailyAgentService.getReport(currentDate,DateUtils.getNowDate("yyyy-MM-dd"));
-//        }
-//
         try {
             for (int i = 1; i < 30; i++) {
                 kuaishouReportDailyAgentService.getAccount(i);
@@ -254,6 +257,17 @@ public class SampleTest {
         reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-09-01", "yy-MM-dd"), DateUtils.parseDate("2020-09-01", "yy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
     }
 
+    @Test
+    public void testBytedanceVideoReport(){
+        List<CtopOauthToken> tokens = oauthTokenService.selectToutiaoToken();
+        for(int i=2;i<100;i++){
+            String date = DateUtils.formatDate(DateUtils.addDay(new Date(),-i));
+            for (CtopOauthToken token:tokens) {
+                bytedanceReportService.bytedanceVideoMaterialReport(token, date, date);
+            }
+        }
+    }
+
     @Autowired
     IUReportExportService uReportExportService;
     @Autowired

+ 3 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/TagInfo.java

@@ -2,6 +2,7 @@ package cn.com.ctop.common.module.entity;
 
 import cn.com.ctop.common.module.annotation.Dict;
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
@@ -43,6 +44,8 @@ public class TagInfo {
 	private Integer level;
 	private Integer status;
 	private Integer delFlag;
+	@TableField(value="is_leaf")
+	private boolean leaf;
 	private Date createTime;
 	private Date updateTime;
 }

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

@@ -0,0 +1,18 @@
+package cn.com.ctop.toutiao.modules.report.DTO;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+public class ImageCostVO implements Serializable {
+    private String statDate;
+    private String signature;
+    private String projectName;
+    private String imageUrl;
+    private BigDecimal cost;
+    private Long click;
+    private Long showNum;
+    private Long convert;
+}

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

@@ -18,7 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
@@ -316,7 +315,6 @@ public class BytedanceReportController {
                 executorService.submit(new Runnable() {
                            @Override
                            public void run() {
-
                                try {
                                    //间隔天数
                                    Long days = DateUtils.getDiscrepantDays(startDate, endDate);
@@ -331,13 +329,10 @@ public class BytedanceReportController {
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
-
                            }
                        });
                     });
-            ////
             Long endtime = System.currentTimeMillis();
-            log.info("头条获取视频素材报表数据任务执行结束,执行耗时:{}秒", (endtime - starttime) / 1000);
         } catch (Exception e) {
             log.error("头条获取视频素材报表数据任务执行结失败");
             e.printStackTrace();

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

@@ -1,9 +1,11 @@
 package cn.com.ctop.toutiao.modules.report.mapper;
 
 import cn.com.ctop.toutiao.modules.material.vo.BytedanceVideoVo;
+import cn.com.ctop.toutiao.modules.report.DTO.ImageCostVO;
 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 com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -28,4 +30,11 @@ public interface BytedanceReportMaterialDailyMapper extends BaseMapper<Bytedance
     void updateRetry(@Param("retry") BytedanceReportMaterialRetry retry);
 
     List<BytedanceVideoVo> getVideoVoByDate(@Param("date")String date);
+
+    List<ImageCostVO> bytedanceImageCost(@Param("startDate")String startDate,
+                                         @Param("endDate")String endDate,
+                                         @Param("accountList")JSONArray accountList,
+                                         @Param("code")String code,
+                                         @Param("startIndex")Integer startIndex,
+                                         @Param("pageSize")Integer pageSize);
 }

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

@@ -238,6 +238,53 @@
         ctop_bytedance_report_material_retry
         where status = 0
     </select>
+    <select id="bytedanceImageCost" resultType="cn.com.ctop.toutiao.modules.report.DTO.ImageCostVO">
+        select
+            a.statDate,
+            a.signature,
+            group_concat(distinct a.projectName) as 'projectName',
+            a.imageUrl as 'imageUrl',
+            round(sum(a.cost), 2)       as 'cost',
+            sum(a.click)                as 'click',
+            sum(a.showNum)              as 'showNum',
+            sum(a.convert)            as 'convert'
+        from (select
+                report.cost as 'cost',
+                report.click as 'click',
+                report.show_material as 'showNum',
+                report.convert_material as 'convert',
+                (select image_url from ctop_bytedance_image_info where material_id = report.material_id limit 1)       as 'imageUrl',
+                (select signature from ctop_bytedance_image_info where material_id = report.material_id)               as 'signature',
+                allocation.project_name as 'projectName',
+                report.stat_datetime as 'statDate'
+            from ctop_bytedance_report_material_daily report
+            left join ctop_user_allocation allocation on allocation.account_id = report.account_id
+        where
+        1=1
+        <if test="startDate!=null">
+            and report.stat_datetime &gt;= #{startDate}
+        </if>
+        <if test="endDate!=null">
+            and report.stat_datetime &lt;= #{endDate}
+        </if>
+        <if test="accountList!=null">
+            and report.account_id in
+            <foreach item="accountId" collection="accountList" open="(" separator="," close=")">
+                #{accountId}
+            </foreach>
+        </if>
+        and image_mode not in (
+        'CREATIVE_IMAGE_MODE_VIDEO',
+        'CREATIVE_IMAGE_MODE_VIDEO_VERTICAL',
+        'MATERIAL_IMAGE_MODE_TITLE')
+        ) a
+        where 1=1
+        <if test="code!=null">
+            and a.signature = #{code}
+        </if>
+        group by a.signature
+        order by sum(a.cost) desc
+    </select>
     <select id="getVideoVoByDate" resultType="cn.com.ctop.toutiao.modules.material.vo.BytedanceVideoVo">
         select
             distinct video.signature as 'code',video.video_url as 'url',report.stat_datetime as 'initial_cost_date'

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

@@ -2,9 +2,11 @@ package cn.com.ctop.toutiao.modules.report.service;
 
 import cn.com.ctop.toutiao.modules.material.vo.BytedanceVideoVo;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialDaily;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 素材报表
@@ -16,4 +18,6 @@ public interface IBytedanceReportMaterialDailyService extends IService<Bytedance
 
     List<BytedanceReportMaterialDaily> getListByParams(String date);
     List<BytedanceVideoVo> getVideoVoByDate(String date);
+
+    Map<String,Object> bytedanceImageCost(JSONObject data);
 }

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

@@ -1,16 +1,25 @@
 package cn.com.ctop.toutiao.modules.report.service.impl;
 
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.toutiao.modules.material.vo.BytedanceVideoVo;
+import cn.com.ctop.toutiao.modules.report.DTO.ImageCostVO;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialDaily;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportMaterialDailyService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Primary;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 素材报表
@@ -38,4 +47,42 @@ public class BytedanceReportMaterialDailyServiceImpl extends ServiceImpl<Bytedan
     public List<BytedanceVideoVo> getVideoVoByDate(String date) {
         return bytedanceReportMaterialDailyMapper.getVideoVoByDate(date);
     }
+
+    @Override
+    public Map<String,Object> bytedanceImageCost(JSONObject data) {
+        Map<String,Object>result = new HashMap<>();
+        String startDate = data.getString("startDate");
+        if(null == startDate||startDate.trim().equals("")){
+            startDate = null;
+        }
+        String endDate = data.getString("endDate");
+        if(null == endDate||endDate.trim().equals("")){
+            endDate = null;
+        }
+        JSONArray accountList = data.getJSONArray("accountList");
+        if(null==accountList||accountList.isEmpty()){
+            accountList = null;
+        }
+        String code = data.getString("code");
+        if(null == code||code.trim().equals("")){
+            code = null;
+        }
+        Integer pageSize = data.getInteger("pageSize");
+        Integer pageNumber = data.getInteger("pageNumber");
+        if(null == pageNumber||pageNumber ==0){
+            pageNumber = 1;
+        }
+        if(null == pageSize||pageSize ==0){
+            pageSize = 10;
+        }
+        PageHelper.startPage(pageNumber,pageSize);
+        List<ImageCostVO>vos = bytedanceReportMaterialDailyMapper.bytedanceImageCost(startDate,endDate,accountList,code,(pageNumber-1)*pageSize,pageSize);
+        PageInfo<ImageCostVO> pageInfo = new PageInfo<>(vos);
+        result.put("data",pageInfo);
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+        return result;
+
+    }
+
+
 }

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

@@ -29,7 +29,6 @@ import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -764,7 +763,6 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
     }
 
     private int bytedanceMaterialReportByPage(Integer page, Integer pageSize, CtopOauthToken token, Long accountId, String startDate, String endDate) {
-        //log.info("当前页数:"+ page);
         String access_token = token.getAccessToken();
 
         // 请求地址
@@ -976,13 +974,8 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
     }
 
     private int bytedanceVideoMaterialReportByPage(Integer page, Integer pageSize, CtopOauthToken token, Long accountId, String startDate, String endDate) {
-        log.info("当前页数:"+ page);
-        String access_token = token.getAccessToken();
-
         // 请求地址
-        String open_api_domain = "https://ad.oceanengine.com";
-        String path = "/open_api/2/report/video/get/";
-
+        String url = "https://ad.oceanengine.com/open_api/2/report/video/get/";
         // 请求参数
         Map data = new HashMap();
         data.put("advertiser_id", accountId);
@@ -992,61 +985,51 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
         data.put("page_size", pageSize);
         data.put("group_by", new String[]{"STAT_GROUP_BY_MATERIAL_ID", "STAT_GROUP_BY_TIME_DAY"});
 
-        JSONObject json = HttpUtils.bytedanceGetRequest(access_token, open_api_domain + path, JSONObject.parseObject(JSONObject.toJSONString(data)));
+        JSONObject json = HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, JSONObject.parseObject(JSONObject.toJSONString(data)));
         if (json == null) {
             log.error("返回为空,请求有误:" + JSONObject.toJSONString(data));
             return -2;
         }
 
-        int returnCode = 200;
         try {
-            if (!Check.isNull(json)) {
-                Integer code = json.getInteger("code");
-                if (code != 0) {
-                    log.error("获取任务列表返回信息错误,错误码为:" + code + ",头条accountId:" + accountId + ";返回json为:" + json + "请求为:" + JSONObject.toJSONString(data));
-                    return -1;
-                }
-
-                JSONObject jsonData = json.getJSONObject("data");
-                if (Check.isNull(jsonData)) {
-                    log.error("获取任务列表返回信息data内容为空,头条accountId:" + accountId + ";返回json为:" + json + "请求为:" + JSONObject.toJSONString(data));
-                    return -1;
-                }
-                JSONObject pageInfo = jsonData.getJSONObject("page_info");
-                Integer totalPage = pageInfo.getInteger("total_page");
-                Integer currentPage = pageInfo.getInteger("page");
-
-                JSONArray jsonArrayay = jsonData.getJSONArray("list");
-                if (jsonArrayay.size() == 0) {
-                    log.info("accountId:" + accountId + ";没有数据。总页数为:" + totalPage + "当前页数为:" + currentPage);
-                    return 1;
-                }
-
-                List<BytedanceReportVideoMaterialDaily> bytedanceReportVideoMaterialDailyList = new ArrayList<>();
-                for (int i = 0; i < jsonArrayay.size(); i++) {
-                    JSONObject detailJson = jsonArrayay.getJSONObject(i);
-                    if (!Check.isNull(detailJson)) {
-                        BytedanceReportVideoMaterialDaily daily = new BytedanceReportVideoMaterialDaily(detailJson, accountId);
-                        bytedanceReportVideoMaterialDailyList.add(daily);
-                    }
-                }
-                bytedanceReportMaterialDailyMapper.replaceIntoVideoMaterialBatch(bytedanceReportVideoMaterialDailyList);
-                if (currentPage >= totalPage) {
-                    log.info("头条视频素材报表当前accountId为:{}  {}~{},接口数据拉取成功" , accountId, startDate,endDate);
-                    return 1;
-                } else {
-                    return bytedanceVideoMaterialReportByPage(page + 1, pageSize, token, accountId, startDate, endDate);
+            Integer code = json.getInteger("code");
+            if (code != 0) {
+                log.error("获取任务列表返回信息错误,错误码为:" + code + ",头条accountId:" + accountId + ";返回json为:" + json + "请求为:" + JSONObject.toJSONString(data));
+                return -1;
+            }
+            JSONObject jsonData = json.getJSONObject("data");
+            if (Check.isNull(jsonData)) {
+                log.error("获取任务列表返回信息data内容为空,头条accountId:" + accountId + ";返回json为:" + json + "请求为:" + JSONObject.toJSONString(data));
+                return -1;
+            }
+            JSONObject pageInfo = jsonData.getJSONObject("page_info");
+            Integer totalPage = pageInfo.getInteger("total_page");
+            Integer currentPage = pageInfo.getInteger("page");
+            JSONArray jsonArrayay = jsonData.getJSONArray("list");
+            if (jsonArrayay.size() == 0) {
+                log.info("accountId:" + accountId + ";没有数据。总页数为:" + totalPage + "当前页数为:" + currentPage);
+                return 1;
+            }
+            List<BytedanceReportVideoMaterialDaily> bytedanceReportVideoMaterialDailyList = new ArrayList<>();
+            for (int i = 0; i < jsonArrayay.size(); i++) {
+                JSONObject detailJson = jsonArrayay.getJSONObject(i);
+                if (!Check.isNull(detailJson)) {
+                    BytedanceReportVideoMaterialDaily daily = new BytedanceReportVideoMaterialDaily(detailJson, accountId);
+                    bytedanceReportVideoMaterialDailyList.add(daily);
                 }
+            }
+            bytedanceReportMaterialDailyMapper.replaceIntoVideoMaterialBatch(bytedanceReportVideoMaterialDailyList);
+            if (currentPage >= totalPage) {
+                log.info("头条视频素材报表当前accountId为:{}  {}~{},接口数据拉取成功" , accountId, startDate,endDate);
+                return 1;
             } else {
-                log.error("头条视频素材报表服务器返回为空,accountId:" + accountId + ",json:" + json + "请求为:" + JSONObject.toJSONString(data));
-                return -1;
+                return bytedanceVideoMaterialReportByPage(page + 1, pageSize, token, accountId, startDate, endDate);
             }
         } catch (Exception e) {
             e.printStackTrace();
             log.error("头条视频素材报表其他错误,accountId:" + accountId + ",json:" + json + "请求为:" + JSONObject.toJSONString(data));
-            returnCode = -3;
+            return  -3;
         }
-        return returnCode;
     }
 
 }