Bläddra i källkod

Merge branch 'test' of http://git.tjyourong.com.cn/ctop/adsp-boot into test

jiequan.bi 4 år sedan
förälder
incheckning
9636f0b74c
34 ändrade filer med 1893 tillägg och 130 borttagningar
  1. 34 30
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  2. 20 4
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java
  3. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java
  4. 0 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  5. 0 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/ToutiaoMaterialsLoadJob.java
  6. 248 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/controller/ThirdConfigAdvertiserController.java
  7. 132 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/controller/ThirdConfigController.java
  8. 57 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/entity/ThirdConfig.java
  9. 57 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/entity/ThirdConfigAdvertiser.java
  10. 22 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/mapper/ThirdConfigAdvertiserMapper.java
  11. 15 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/mapper/ThirdConfigMapper.java
  12. 24 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/mapper/xml/ThirdConfigAdvertiserMapper.xml
  13. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/mapper/xml/ThirdConfigMapper.xml
  14. 20 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/server/IThirdConfigAdvertiserService.java
  15. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/server/IThirdConfigService.java
  16. 35 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/server/impl/ThirdConfigAdvertiserServiceImpl.java
  17. 19 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/server/impl/ThirdConfigServiceImpl.java
  18. 15 3
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  19. 51 0
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceOperationRecordJob.java
  20. 21 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/MaterialRefuseController.java
  21. 3 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCreativeServiceImpl.java
  22. 0 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl2.java
  23. 2 20
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/job/KuaishouReportAgentJob.java
  24. 2 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAgentServiceImpl.java
  25. 8 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/controller/ByteDanceCreativeController.java
  26. 2 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IByteDanceCreativeService.java
  27. 318 20
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceCreativeServiceImpl.java
  28. 82 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceInterfaceController.java
  29. 1 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/ByteDanceOperationRecord.java
  30. 527 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/entity/BytedanceReportPlayableDaily.java
  31. 1 4
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceOperationRecordMapper.java
  32. 35 29
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceOperationRecordMapper.xml
  33. 3 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceInterfaceService.java
  34. 119 6
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceInterfaceServiceImpl.java

+ 34 - 30
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -40,6 +40,7 @@ public class ShiroConfig {
 
     @Value("${spring.redis.password}")
     private String redisPassword;
+
     /**
      * Filter Chain定义说明
      * <p>
@@ -166,6 +167,8 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/ks/web/test", "anon");
         filterChainDefinitionMap.put("/ureport/**", "anon");
         filterChainDefinitionMap.put("/job/test/*", "anon");
+        filterChainDefinitionMap.put("/third/*", "anon");
+        //filterChainDefinitionMap.put("/kuaishou/**", "anon");
         filterChainDefinitionMap.put("/rest/script/*", "anon");
         filterChainDefinitionMap.put("/ctop/checkTaskList/*", "anon");
 
@@ -202,35 +205,36 @@ public class ShiroConfig {
         return securityManager;
     }
 
-	/**
-	 * 下面的代码是添加注解支持
-	 * @return
-	 */
-	@Bean
-	@DependsOn("lifecycleBeanPostProcessor")
-	public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
-		DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator();
-		defaultAdvisorAutoProxyCreator.setProxyTargetClass(true);
-		/**
-		* 解决重复代理问题 github#994
-		* 添加前缀判断 不匹配 任何Advisor
-		*/
-		defaultAdvisorAutoProxyCreator.setUsePrefix(true);
-		defaultAdvisorAutoProxyCreator.setAdvisorBeanNamePrefix("_no_advisor");
-		return defaultAdvisorAutoProxyCreator;
-	}
+    /**
+     * 下面的代码是添加注解支持
+     *
+     * @return
+     */
+    @Bean
+    @DependsOn("lifecycleBeanPostProcessor")
+    public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
+        DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator();
+        defaultAdvisorAutoProxyCreator.setProxyTargetClass(true);
+        /**
+         * 解决重复代理问题 github#994
+         * 添加前缀判断 不匹配 任何Advisor
+         */
+        defaultAdvisorAutoProxyCreator.setUsePrefix(true);
+        defaultAdvisorAutoProxyCreator.setAdvisorBeanNamePrefix("_no_advisor");
+        return defaultAdvisorAutoProxyCreator;
+    }
 
-	@Bean
-	public static LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
-		return new LifecycleBeanPostProcessor();
-	}
+    @Bean
+    public static LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
+        return new LifecycleBeanPostProcessor();
+    }
 
-	@Bean
-	public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(DefaultWebSecurityManager securityManager) {
-		AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor();
-		advisor.setSecurityManager(securityManager);
-		return advisor;
-	}
+    @Bean
+    public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(DefaultWebSecurityManager securityManager) {
+        AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor();
+        advisor.setSecurityManager(securityManager);
+        return advisor;
+    }
 
     /**
      * cacheManager 缓存 redis实现
@@ -257,9 +261,9 @@ public class ShiroConfig {
     @Bean
     public RedisManager redisManager() {
         RedisManager redisManager = new RedisManager();
-		redisManager.setHost(host);
-		redisManager.setPort(oConvertUtils.getInt(port));
-		redisManager.setTimeout(0);
+        redisManager.setHost(host);
+        redisManager.setPort(oConvertUtils.getInt(port));
+        redisManager.setTimeout(0);
         if (!StringUtils.isEmpty(redisPassword)) {
             redisManager.setPassword(redisPassword);
         }

+ 20 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java

@@ -35,10 +35,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.text.ParseException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @Slf4j
 @RestController
@@ -228,6 +225,11 @@ public class CallbackController {
         return "授权绑定失败!";
     }
 
+
+    public static void main(String[] args) {
+        System.err.println(UUID.randomUUID().toString().replace("-", ""));
+    }
+
     @RequestMapping("/bytedance")
     public String bytedance(HttpServletRequest request,
                             HttpServletResponse response,
@@ -431,5 +433,19 @@ public class CallbackController {
         return returnMap;
     }
 
+    @GetMapping("/kuaishou/agent")
+    public String kuaishouAgent(@RequestParam("auth_code") String authCode, @RequestParam("state") String state) {
+        if (StringUtils.isNotBlank(authCode)) {
+            Map<String, Object> map = this.getKuaishouAgentAccessToken(authCode, state);
+            log.info("返回信息:{}", map.toString());
+            return (String) map.get("desc");
+        }
+        return "代理商授权绑定失败";
+    }
+
+    private Map<String, Object> getKuaishouAgentAccessToken(String authCode, String state) {
+        return null;
+    }
+
 
 }

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java

@@ -219,7 +219,7 @@ public class MaterialInfoController {
         materialInfo.setCreateTime(null);
         if (!Check.isNull(materialInfo.getUserId())) {
             String roleCode = materialInfoService.getRoleCodeByUserId(materialInfo.getUserId());
-            if (CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode) || "operator".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "operationAssistant".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || "sale".equals(roleCode) || "saleDirector".equals(roleCode)) {
+            if (CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode) || "operator".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "operationAssistant".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || roleCode.contains("sale")) {
                 materialInfo.setUserId(null);
                 queryWrapper = QueryGenerator.initQueryWrapper(materialInfo, req.getParameterMap());
             } else if ("designTeamLeader".equals(roleCode) || "planeLeader".equals(roleCode) || "plane".equals(roleCode) || "plan".equals(roleCode) || "shot".equals(roleCode)) {

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

@@ -967,5 +967,4 @@ public class TestController {
         return result;
     }
 
-
 }

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

@@ -1,6 +1,5 @@
 package org.jeecg.modules.ctop.job;
 
-
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;

+ 248 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/controller/ThirdConfigAdvertiserController.java

@@ -0,0 +1,248 @@
+package org.jeecg.modules.third.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import com.alibaba.fastjson.JSON;
+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.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.third.entity.ThirdConfigAdvertiser;
+import org.jeecg.modules.third.server.IThirdConfigAdvertiserService;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 对外配置关联广告主
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-08-14
+ */
+@Slf4j
+@Api(tags = "对外配置关联广告主")
+@RestController
+@RequestMapping("/n/thirtConfigAdvertiser")
+public class ThirdConfigAdvertiserController {
+    @Autowired
+    private IThirdConfigAdvertiserService thirtConfigAdvertiserService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param thirtConfigAdvertiser
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "对外配置关联广告主-分页列表查询")
+    @ApiOperation(value = "对外配置关联广告主-分页列表查询", notes = "对外配置关联广告主-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<ThirdConfigAdvertiser>> queryPageList(ThirdConfigAdvertiser thirtConfigAdvertiser,
+                                                              @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                              @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                              HttpServletRequest req) {
+        Result<IPage<ThirdConfigAdvertiser>> result = new Result<>();
+        QueryWrapper<ThirdConfigAdvertiser> queryWrapper = QueryGenerator.initQueryWrapper(thirtConfigAdvertiser, req.getParameterMap());
+        Page<ThirdConfigAdvertiser> page = new Page<ThirdConfigAdvertiser>(pageNo, pageSize);
+        IPage<ThirdConfigAdvertiser> pageList = thirtConfigAdvertiserService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param thirtConfigAdvertiser
+     * @return
+     */
+    @AutoLog(value = "对外配置关联广告主-添加")
+    @ApiOperation(value = "对外配置关联广告主-添加", notes = "对外配置关联广告主-添加")
+    @PostMapping(value = "/add")
+    public Result<ThirdConfigAdvertiser> add(@RequestBody ThirdConfigAdvertiser thirtConfigAdvertiser) {
+        Result<ThirdConfigAdvertiser> result = new Result<>();
+        try {
+            thirtConfigAdvertiserService.save(thirtConfigAdvertiser);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param thirtConfigAdvertiser
+     * @return
+     */
+    @AutoLog(value = "对外配置关联广告主-编辑")
+    @ApiOperation(value = "对外配置关联广告主-编辑", notes = "对外配置关联广告主-编辑")
+    @PutMapping(value = "/edit")
+    public Result<ThirdConfigAdvertiser> edit(@RequestBody ThirdConfigAdvertiser thirtConfigAdvertiser) {
+        Result<ThirdConfigAdvertiser> result = new Result<ThirdConfigAdvertiser>();
+        ThirdConfigAdvertiser thirtConfigAdvertiserEntity = thirtConfigAdvertiserService.getById(thirtConfigAdvertiser.getId());
+        if (thirtConfigAdvertiserEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = thirtConfigAdvertiserService.updateById(thirtConfigAdvertiser);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "对外配置关联广告主-通过id删除")
+    @ApiOperation(value = "对外配置关联广告主-通过id删除", notes = "对外配置关联广告主-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            thirtConfigAdvertiserService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "对外配置关联广告主-批量删除")
+    @ApiOperation(value = "对外配置关联广告主-批量删除", notes = "对外配置关联广告主-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<ThirdConfigAdvertiser> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<ThirdConfigAdvertiser> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.thirtConfigAdvertiserService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "对外配置关联广告主-通过id查询")
+    @ApiOperation(value = "对外配置关联广告主-通过id查询", notes = "对外配置关联广告主-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<ThirdConfigAdvertiser> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<ThirdConfigAdvertiser> result = new Result<>();
+        ThirdConfigAdvertiser thirtConfigAdvertiser = thirtConfigAdvertiserService.getById(id);
+        if (thirtConfigAdvertiser == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(thirtConfigAdvertiser);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<ThirdConfigAdvertiser> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                ThirdConfigAdvertiser thirtConfigAdvertiser = JSON.parseObject(deString, ThirdConfigAdvertiser.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(thirtConfigAdvertiser, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<ThirdConfigAdvertiser> pageList = thirtConfigAdvertiserService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "对外配置关联广告主列表");
+        mv.addObject(NormalExcelConstants.CLASS, ThirdConfigAdvertiser.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("对外配置关联广告主列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<ThirdConfigAdvertiser> listThirtConfigAdvertisers = ExcelImportUtil.importExcel(file.getInputStream(), ThirdConfigAdvertiser.class, params);
+                thirtConfigAdvertiserService.saveBatch(listThirtConfigAdvertisers);
+                return Result.ok("文件导入成功!数据行数:" + listThirtConfigAdvertisers.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

+ 132 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/controller/ThirdConfigController.java

@@ -0,0 +1,132 @@
+package org.jeecg.modules.third.controller;
+
+import cn.com.ctop.common.module.utils.Check;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.third.entity.ThirdConfig;
+import org.jeecg.modules.third.entity.ThirdConfigAdvertiser;
+import org.jeecg.modules.third.server.IThirdConfigAdvertiserService;
+import org.jeecg.modules.third.server.IThirdConfigService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 对外配置
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-08-14
+ */
+@Slf4j
+@Api(tags = "对外配置")
+@RestController
+@RequestMapping("/third")
+public class ThirdConfigController {
+    @Autowired
+    private IThirdConfigService thirdConfigService;
+    @Autowired
+    private IThirdConfigAdvertiserService thirdConfigAdvertiserService;
+
+    @PostMapping(value = "/getAdvertiserList")
+    public Result<List<String>> getAdvertiserList(@RequestBody JSONObject requestJson) {
+
+        Result<List<String>> result = new Result<>();
+        try {
+            Long appId = requestJson.getLong("appId");
+            if (Check.isNull(appId)) {
+                throw new Exception("必传参数appId不能为空");
+            }
+            QueryWrapper<ThirdConfig> thirdConfigQueryWrapper = new QueryWrapper<>();
+            thirdConfigQueryWrapper.eq("app_id", appId);
+            ThirdConfig config = thirdConfigService.getOne(thirdConfigQueryWrapper);
+            if (Check.isNull(config)) {
+                throw new Exception("appId不正确");
+            }
+            String secret = requestJson.getString("secret");
+            if (Check.isNull(secret)) {
+                throw new Exception("secret不能为空");
+            }
+            if (!secret.equals(config.getSecret())) {
+                throw new Exception("secret不正确");
+            }
+
+            List<String> advertiserList = thirdConfigAdvertiserService.getAdvertiserListByAppId(appId);
+            result.setResult(advertiserList);
+
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+            result.setCode(-1);
+
+        }
+        return result;
+    }
+
+
+    @PostMapping(value = "/getAdvertiserCost")
+    public Result<List<JSONObject>> getAdvertiserCost(@RequestBody JSONObject requestJson) {
+        Result<List<JSONObject>> result = new Result<>();
+        try {
+
+            Long appId = requestJson.getLong("appId");
+            if (Check.isNull(appId)) {
+                throw new Exception("必传参数appId不能为空");
+            }
+            QueryWrapper<ThirdConfig> thirdConfigQueryWrapper = new QueryWrapper<>();
+            thirdConfigQueryWrapper.eq("app_id", appId);
+            ThirdConfig config = thirdConfigService.getOne(thirdConfigQueryWrapper);
+            if (Check.isNull(config)) {
+                throw new Exception("appId不正确");
+            }
+            String secret = requestJson.getString("secret");
+            if (Check.isNull(secret)) {
+                throw new Exception("secret不能为空");
+            }
+            if (!secret.equals(config.getSecret())) {
+                throw new Exception("secret不正确");
+            }
+
+            String advertiserName = requestJson.getString("advertiserName");
+            if (Check.isNull(advertiserName)) {
+                throw new Exception("请输入需要查询广告主名称");
+            }
+
+            QueryWrapper<ThirdConfigAdvertiser> thirtConfigAdvertiserQueryWrapper = new QueryWrapper<>();
+            thirtConfigAdvertiserQueryWrapper.eq("app_id", appId);
+            thirtConfigAdvertiserQueryWrapper.eq("advertiser_name", advertiserName);
+            thirtConfigAdvertiserQueryWrapper.last("limit 1");
+            ThirdConfigAdvertiser configAdvertiser = thirdConfigAdvertiserService.getOne(thirtConfigAdvertiserQueryWrapper);
+            if (Check.isNull(configAdvertiser)) {
+                throw new Exception("此appId下暂无此广告主信息");
+
+            }
+            String startDate = requestJson.getString("startDate");
+            if (Check.isNull(startDate)) {
+                throw new Exception("请输入查询开始时间");
+            }
+
+            String endDate = requestJson.getString("endDate");
+            if (Check.isNull(endDate)) {
+                throw new Exception("请输入查询结束时间");
+            }
+
+
+            List<JSONObject> costList = thirdConfigAdvertiserService.getAdvertiserCost(appId, advertiserName, startDate, endDate);
+            result.setResult(costList);
+        } catch (Exception e) {
+            result.setCode(-1);
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+}

+ 57 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/entity/ThirdConfig.java

@@ -0,0 +1,57 @@
+package org.jeecg.modules.third.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 对外配置
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-08-14
+ */
+@Data
+@TableName("ctop_thirt_config")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_thirt_config对象", description = "对外配置")
+public class ThirdConfig {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * appId
+     */
+    @Excel(name = "appId", width = 15)
+    @ApiModelProperty(value = "appId")
+    private Long appId;
+    /**
+     * secret
+     */
+    @Excel(name = "secret", width = 15)
+    @ApiModelProperty(value = "secret")
+    private String secret;
+    /**
+     * createTime
+     */
+    @ApiModelProperty(value = "createTime")
+    private Date createTime;
+    /**
+     * update
+     */
+    @ApiModelProperty(value = "update")
+    private Date updateTime;
+}

+ 57 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/entity/ThirdConfigAdvertiser.java

@@ -0,0 +1,57 @@
+package org.jeecg.modules.third.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 对外配置关联广告主
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-08-14
+ */
+@Data
+@TableName("ctop_thirt_config_advertiser")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_thirt_config_advertiser对象", description = "对外配置关联广告主")
+public class ThirdConfigAdvertiser {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * appId
+     */
+    @Excel(name = "appId", width = 15)
+    @ApiModelProperty(value = "appId")
+    private Integer appId;
+    /**
+     * advertsierName
+     */
+    @Excel(name = "advertsierName", width = 15)
+    @ApiModelProperty(value = "advertiserName")
+    private String advertiserName;
+    /**
+     * createTime
+     */
+    @ApiModelProperty(value = "createTime")
+    private Date createTime;
+    /**
+     * update
+     */
+    @ApiModelProperty(value = "update")
+    private Date updateTime;
+}

+ 22 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/mapper/ThirdConfigAdvertiserMapper.java

@@ -0,0 +1,22 @@
+package org.jeecg.modules.third.mapper;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.third.entity.ThirdConfigAdvertiser;
+
+import java.util.List;
+
+/**
+ * 对外配置关联广告主
+ *
+ * @author: jeecg-boot
+ * @date: 2020-08-14
+ * @cersion: V1.0
+ */
+public interface ThirdConfigAdvertiserMapper extends BaseMapper<ThirdConfigAdvertiser> {
+
+    List<JSONObject> getAdvertiserCost(@Param("appId") Long appId, @Param("advertiserName") String advertiserName, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    List<String> getAdvertiserListByAppId(@Param("appId") Long appId);
+}

+ 15 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/mapper/ThirdConfigMapper.java

@@ -0,0 +1,15 @@
+package org.jeecg.modules.third.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.third.entity.ThirdConfig;
+
+/**
+ * 对外配置
+ *
+ * @author: jeecg-boot
+ * @date: 2020-08-14
+ * @cersion: V1.0
+ */
+public interface ThirdConfigMapper extends BaseMapper<ThirdConfig> {
+
+}

+ 24 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/mapper/xml/ThirdConfigAdvertiserMapper.xml

@@ -0,0 +1,24 @@
+<?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="org.jeecg.modules.third.mapper.ThirdConfigAdvertiserMapper">
+
+    <select id="getAdvertiserListByAppId" resultType="java.lang.String">
+     select advertiser_name
+      from ctop_thirt_config_advertiser
+     where  app_id = #{appId}
+     group by advertiser_name
+    </select>
+
+    <select id="getAdvertiserCost" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT sum(t2.charge) as 'charge',
+        stat_date as 'statDate'
+        from ctop_kuaishou_advertiser_base_info t1
+        LEFT JOIN ctop_kuaishou_report_daily_account t2
+        ON t1.account_id = t2.account_id
+        WHERE t1.corporation_name = #{advertiserName}
+        and t2.stat_date &gt;= #{startDate}
+        AND t2.stat_date &lt;= #{endDate}
+        GROUP BY t2.stat_date
+    </select>
+
+</mapper>

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/mapper/xml/ThirdConfigMapper.xml

@@ -0,0 +1,5 @@
+<?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="org.jeecg.modules.third.mapper.ThirdConfigMapper">
+
+</mapper>

+ 20 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/server/IThirdConfigAdvertiserService.java

@@ -0,0 +1,20 @@
+package org.jeecg.modules.third.server;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.third.entity.ThirdConfigAdvertiser;
+
+import java.util.List;
+
+/**
+ * @Description: 对外配置关联广告主
+ * @Author: jeecg-boot
+ * @Date: 2020-08-14
+ * @Version: V1.0
+ */
+public interface IThirdConfigAdvertiserService extends IService<ThirdConfigAdvertiser> {
+
+    List<String> getAdvertiserListByAppId(Long appId);
+
+    List<JSONObject> getAdvertiserCost(Long appId, String advertiserName, String startDate, String endDate);
+}

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/server/IThirdConfigService.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.third.server;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.third.entity.ThirdConfig;
+
+/**
+ * @Description: 对外配置
+ * @Author: jeecg-boot
+ * @Date: 2020-08-14
+ * @Version: V1.0
+ */
+public interface IThirdConfigService extends IService<ThirdConfig> {
+
+}

+ 35 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/server/impl/ThirdConfigAdvertiserServiceImpl.java

@@ -0,0 +1,35 @@
+package org.jeecg.modules.third.server.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.third.entity.ThirdConfigAdvertiser;
+import org.jeecg.modules.third.mapper.ThirdConfigAdvertiserMapper;
+import org.jeecg.modules.third.server.IThirdConfigAdvertiserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 对外配置关联广告主
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-08-14
+ */
+@Service
+public class ThirdConfigAdvertiserServiceImpl extends ServiceImpl<ThirdConfigAdvertiserMapper, ThirdConfigAdvertiser> implements IThirdConfigAdvertiserService {
+    @Autowired
+    private ThirdConfigAdvertiserMapper thirdConfigAdvertiserMapper;
+
+
+    @Override
+    public List<String> getAdvertiserListByAppId(Long appId) {
+        return thirdConfigAdvertiserMapper.getAdvertiserListByAppId(appId);
+    }
+
+    @Override
+    public List<JSONObject> getAdvertiserCost(Long appId, String advertiserName, String startDate, String endDate) {
+        return thirdConfigAdvertiserMapper.getAdvertiserCost(appId, advertiserName, startDate, endDate);
+    }
+}

+ 19 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/third/server/impl/ThirdConfigServiceImpl.java

@@ -0,0 +1,19 @@
+package org.jeecg.modules.third.server.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.third.entity.ThirdConfig;
+import org.jeecg.modules.third.mapper.ThirdConfigMapper;
+import org.jeecg.modules.third.server.IThirdConfigService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 对外配置
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-08-14
+ */
+@Service
+public class ThirdConfigServiceImpl extends ServiceImpl<ThirdConfigMapper, ThirdConfig> implements IThirdConfigService {
+
+}

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

@@ -2,9 +2,10 @@ package org.jeecg;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceCampaignService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeService;
-import cn.com.ctop.toutiao.modules.report.service.IReportService;
+import org.jeecg.common.util.DateUtils;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -12,6 +13,8 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.context.junit4.SpringRunner;
 
+import java.util.Date;
+
 @RunWith(SpringRunner.class)
 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 @ActiveProfiles("wps")
@@ -19,11 +22,11 @@ public class SampleTest {
     @Autowired
     private ICtopOauthTokenService oauthTokenService;
     @Autowired
-    private IReportService reportService;
-	@Autowired
     private IByteDanceCreativeService creativeService;
 	@Autowired
     private IByteDanceCampaignService campaignService;
+    @Autowired
+    private IKuaishouReportDailyAgentService kuaishouReportDailyAgentService;
 
     @Test
     public void loadBytedanceCreativeData() {
@@ -36,4 +39,13 @@ public class SampleTest {
         CtopOauthToken token = oauthTokenService.getTokenByAccountId(1673731621920840L);
        campaignService.getAdvertiserCampaign(token,null,null);
     }
+
+    @Test
+    public void loadKuaishouAgentData(){
+        for(int i=0;i<30;i++){
+            String currentDate = DateUtils.formatDate(DateUtils.addDay(new Date(),-i));
+            kuaishouReportDailyAgentService.getReport(currentDate,DateUtils.getNowDate("yyyy-MM-dd"));
+
+        }
+    }
 }

+ 51 - 0
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceOperationRecordJob.java

@@ -0,0 +1,51 @@
+package cn.com.ctop.job.bytedance.handler;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.toutiao.modules.material.service.IBytedanceBidWarningService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceInterfaceService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import com.xxl.job.core.log.XxlJobLogger;
+import org.apache.commons.lang.StringUtils;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Component
+public class BytedanceOperationRecordJob {
+    @Autowired
+    private IBytedanceInterfaceService bytedanceInterfaceService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    static ExecutorService executorService = Executors.newFixedThreadPool(8);
+
+    @XxlJob("bytedanceOperationRecordJob")
+    public ReturnT<String> execute(String startDate, String endDate) throws Exception {
+        if(StringUtils.isBlank(startDate) || StringUtils.isBlank(endDate)){
+            return ReturnT.FAIL;
+        }
+
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        if (null == tokens || tokens.size() <= 0) {
+            XxlJobLogger.log("定时获取头条操作记录数据异常:未获取到可用的token");
+            return ReturnT.FAIL;
+        }
+        tokens.forEach(token -> {
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    XxlJobLogger.log("定时获取头条操作记录数据开始,accountId:" + token.getAccountId() + "操作目标为:" + 2 + "时间:" + startDate + "~" + endDate);
+                    bytedanceInterfaceService.searchLog(token.getAccountId(), token, 2, startDate, endDate);
+                    XxlJobLogger.log("定时获取头条操作记录数据结束,accountId:" + token.getAccountId() + "操作目标为:" + 2 + "时间:" + startDate + "~" + endDate);
+                }
+            });
+        });
+        return ReturnT.SUCCESS;
+    }
+}

+ 21 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/MaterialRefuseController.java

@@ -3,10 +3,11 @@ package cn.com.ctop.kuaishou.modules.batch.controller;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
 import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouActionBarText;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouActionBarTextService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
-import cn.com.ctop.kuaishou.modules.batch.service.IMaterialRefuseService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -19,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -28,13 +30,13 @@ import java.util.concurrent.Executors;
 @RequestMapping("/MaterialRefuse/")
 public class MaterialRefuseController {
     @Autowired
-    private IMaterialRefuseService materialRefuseService;
-    @Autowired
     private CtopOauthTokenMapper oauthTokenMapper;
     @Autowired
     private IKuaiShouUpdateService updateService;
     @Autowired
     private IKuaiShouCreativeService creativeService;
+    @Autowired
+    private IKuaiShouActionBarTextService actionBarTextService;
     static ExecutorService executorService = Executors.newFixedThreadPool(15);
 
 
@@ -61,6 +63,22 @@ public class MaterialRefuseController {
     }
 
 
+    @GetMapping(value = "getAllActionBarText")
+    public Result<List<KuaiShouActionBarText>> getAllActionBarText() {
+        Result<List<KuaiShouActionBarText>> result = new Result<>();
+        try {
+            //  QueryWrapper<KuaiShouActionBarText> actionBarTextQueryWrapper = new QueryWrapper<>();
+            List<KuaiShouActionBarText> list = actionBarTextService.list();
+            result.setResult(list);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+
     @GetMapping(value = "syncCreative")
     public Result<Boolean> syncCreative(Long accountId, Long campaignId) {
         Result<Boolean> result = new Result<>();

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

@@ -86,7 +86,9 @@ public class KuaiShouCreativeServiceImpl extends ServiceImpl<KuaiShouCreativeMap
         headers.put("Access-Token", accessToken);
         JSONObject param = new JSONObject();
         param.put("advertiser_id", accountId);
-        param.put("campaign_id", campaignId);
+        if (!Check.isNull(campaignId)) {
+            param.put("campaign_id", campaignId);
+        }
         param.put("page_size", 200);
         param.put("page", page);
 

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

@@ -10,7 +10,6 @@ import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService2;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections.ArrayStack;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;

+ 2 - 20
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/job/KuaishouReportAgentJob.java

@@ -1,28 +1,13 @@
 package cn.com.ctop.kuaishou.modules.report.job;
-import cn.com.ctop.common.module.utils.HttpUtils2;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgent;
+
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.http.client.CookieStore;
-import org.apache.http.impl.client.BasicCookieStore;
-import org.apache.http.impl.cookie.BasicClientCookie;
 import org.jeecg.common.util.DateUtils;
-import org.openqa.selenium.By;
-import org.openqa.selenium.Cookie;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.chrome.ChromeDriver;
-import org.openqa.selenium.chrome.ChromeOptions;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.Date;
 
 public class KuaishouReportAgentJob implements Job {
 
@@ -32,8 +17,5 @@ public class KuaishouReportAgentJob implements Job {
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
         String currentDate = DateUtils.formatDate(DateUtils.addDay(new Date(),-1));
         kuaishouReportDailyAgentService.getReport(currentDate,DateUtils.getNowDate("yyyy-MM-dd"));
-
-//        kuaishouReportDailyAgentService.getReport("2019-12-12","2020-03-05");
-
     }
 }

+ 2 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAgentServiceImpl.java

@@ -80,7 +80,7 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
             accountElement.sendKeys("17718376864");
             Thread.sleep(3000L);
             WebElement passwordElement = webDriver.findElement(By.xpath("//div[@class='password ']/input[@type='password']"));
-            passwordElement.sendKeys("hcstbaoliang567");
+            passwordElement.sendKeys("yehcbost85567");
             WebElement loginElement = webDriver.findElement(By.xpath("//div[@class='foot']"));
             Thread.sleep(3000L);
             //点击登录
@@ -191,6 +191,7 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
                 String listUrl = "https://agent.e.kuaishou.com/rest/dsp/agent/account/data/list";
                 String postData = "{\"agentId\":403756224,\"startDate\":\"" + currentDate + "\",\"endDate\":\"" + currentDate + "\",\"isAscending\":false,\"pageInfo\":{\"pageSize\":19,\"currentPage\":1,\"totalCount\":999999}}";
                 String result = HttpUtils2.httpPostRequestTest(listUrl, postData, headerMap);
+                System.out.println(result);
                 ObjectMapper mapper = new ObjectMapper();
                 JsonNode resultNode = mapper.readTree(result);
                 Integer code = resultNode.get("result").intValue();

+ 8 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/controller/ByteDanceCreativeController.java

@@ -6,6 +6,7 @@ import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.common.module.utils.StringUtils;
 import cn.com.ctop.toutiao.modules.material.entity.ByteDanceCreative;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeService;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -152,9 +153,9 @@ public class ByteDanceCreativeController {
     }
 
     @PostMapping("/detail")
-    public Map<String,Object>creativeDetail(@RequestParam(name = "adId",required = true,defaultValue = "0") Long adId,
+    public Map<String,Object>creativeDetail(@RequestParam(name = "planId",required = true,defaultValue = "0") Long planId,
                                             @RequestParam(name = "accountId",required = true,defaultValue = "0") Long accountId){
-        return byteDanceCreativeService.getCreativeDetail(accountId,adId);
+        return byteDanceCreativeService.getCreativeDetail(accountId,planId);
     }
 
     /**
@@ -216,4 +217,9 @@ public class ByteDanceCreativeController {
         }
         return result;
     }
+
+    @PostMapping("/updateCreative")
+    public Map<String,Object>updateCreative(@RequestBody JSONObject data){
+        return byteDanceCreativeService.updateCreative(data);
+    }
 }

+ 2 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IByteDanceCreativeService.java

@@ -24,9 +24,9 @@ public interface IByteDanceCreativeService extends IService<ByteDanceCreative> {
 
     void replaceBatch(List<ByteDanceCreative> creatives);
 
-    Map<String, Object> getCreativeDetail(Long accountId, Long adId);
+    Map<String, Object> getCreativeDetail(Long accountId, Long planId);
 
-    Map<String,Object> updateCreative(Long accountId, JSONObject data);
+    Map<String,Object> updateCreative(JSONObject data);
 
     Map<String,Object> getCreativeRejectReason(Long accountId, Long creativeId);
 

+ 318 - 20
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceCreativeServiceImpl.java

@@ -190,6 +190,9 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
             resultMap.put("message", "广告计划("+adId+"):"+message);
             return resultMap;
         }
+        Thread thread = new Thread(()->getAdvertiserCreative(token, null, null));
+        thread.start();
+
         resultMap.put("success", true);
         resultMap.put("code", 0);
         resultMap.put("message", "广告计划("+adId+"):"+"创意创建成功");
@@ -200,9 +203,9 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
      * @return
      */
     @Override
-    public Map<String, Object> getCreativeDetail(Long accountId, Long adId){
+    public Map<String, Object> getCreativeDetail(Long accountId, Long planId){
         Map<String,Object>resultMap = new HashMap<>();
-        if(null == adId||adId == 0||null == accountId||accountId == 0){
+        if(null == planId||planId == 0||null == accountId||accountId == 0){
             ResultMapUtils.setResultMap(resultMap,StatusCode.COMMON_PARAM_ERROR);
             return resultMap;
         }
@@ -211,7 +214,7 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
             ResultMapUtils.setResultMap(resultMap,StatusCode.BYTEDANCE_PLAN_DATA_NOT_EXIST);
             return resultMap;
         }
-        ByteDanceAdvertisePlan plan = byteDanceAdvertisePlanService.getById(adId);
+        ByteDanceAdvertisePlan plan = byteDanceAdvertisePlanService.getById(planId);
         if(null == plan||plan.getOptStatus().equals("AD_STATUS_DELETE")){
             ResultMapUtils.setResultMap(resultMap,StatusCode.BYTEDANCE_ACCOUNT_DATA_NOT_EXIST);
             return resultMap;
@@ -222,11 +225,27 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
         // 请求参数
         JSONObject data = new JSONObject();
         data.put("advertiser_id", token.getAccountId());
-        data.put("ad_id",adId);
+        data.put("ad_id",planId);
         JSONObject result = HttpUtils.bytedanceGetRequest(token.getAccessToken(),url,data);
+        System.out.println(result);
         Integer code = result.getInteger("code");
         String message = result.getString("message");
-        if (null == code || code != 0) {
+        if (null ==  code) {
+            log.info("广告创意获取详情失败,accountId:{},message:{}", accountId, message);
+            resultMap.put("success", false);
+            resultMap.put("code", -1);
+            resultMap.put("message", message);
+            return resultMap;
+        }
+        if(code == 40001){
+            //尚未创建创意
+            resultMap.put("success", true);
+            resultMap.put("code", 0);
+            result.put("data","");
+            resultMap.put("message", message);
+            return resultMap;
+        }
+        if(code!=0){
             log.info("广告创意获取详情失败,accountId:{},message:{}", accountId, message);
             resultMap.put("success", false);
             resultMap.put("code", -1);
@@ -241,34 +260,312 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
 
     private JSONObject formatData(JSONObject getData) {
         JSONObject data = new JSONObject();
+        Long advertiserId = getData.getLong("advertiser_id");
+        if(null!=advertiserId&&advertiserId!=0){
+            data.put("advertiserId",advertiserId);
+        }
+        Long adId = getData.getLong("ad_id");
+        if(null!=adId&&adId!=0){
+            data.put("adId",adId);
+        }
+        String modifyTime = getData.getString("modify_time");
+        if(null!=modifyTime&&!modifyTime.trim().equals("")){
+            data.put("modifyTime",modifyTime);
+        }
+        String trackUrl = getData.getString("track_url");
+        if(null!=trackUrl&&!trackUrl.trim().equals("")){
+            data.put("trackUrl",trackUrl);
+        }
+        String actionTrackUrl = getData.getString("action_track_url");
+        if(null!=actionTrackUrl&&!actionTrackUrl.trim().equals("")){
+            data.put("actionTrackUrl",actionTrackUrl);
+        }
+        String videoPlayEffectiveTrackUrl = getData.getString("video_play_effective_track_url");
+        if(null!=videoPlayEffectiveTrackUrl&&!videoPlayEffectiveTrackUrl.trim().equals("")){
+            data.put("video_play_effective_track_url",videoPlayEffectiveTrackUrl);
+        }
+        String videoPlayDoneTrackUrl = getData.getString("video_play_done_track_url");
+        if(null!=videoPlayDoneTrackUrl&&!videoPlayDoneTrackUrl.trim().equals("")){
+            data.put("video_play_done_track_url",videoPlayDoneTrackUrl);
+        }
+        String videoPlayTrackUrl = getData.getString("video_play_track_url");
+        if(null!=videoPlayTrackUrl&&!videoPlayTrackUrl.trim().equals("")){
+            data.put("videoPlayTrackUrl",videoPlayTrackUrl);
+        }
+        Integer isCommentDisable = getData.getInteger("is_comment_disable");
+        if(null!=isCommentDisable){
+            data.put("isCommentDisable",isCommentDisable);
+        }
+        Integer closeVideoDetail = getData.getInteger("close_video_detail");
+        if(null!=closeVideoDetail){
+            data.put("closeVideoDetail",closeVideoDetail);
+        }
+        String creativeDisplayMode = getData.getString("creative_display_mode");
+        if(null!=creativeDisplayMode&&!creativeDisplayMode.trim().equals("")){
+            data.put("creativeDisplayMode",creativeDisplayMode);
+        }
+        Long smartInventory = getData.getLong("smart_inventory");
+        if(null!=smartInventory&&smartInventory!=0){
+            data.put("smartInventory",smartInventory);
+        }
+        String sceneInventory = getData.getString("scene_inventory");
+        if(null!=sceneInventory&&!sceneInventory.trim().equals("")){
+            data.put("sceneInventory",sceneInventory);
+        }
+        Long generate_derived_ad = getData.getLong("generate_derived_ad");
+        if(null!=generate_derived_ad&&generate_derived_ad!=0){
+            data.put("generateDerivedAd",generate_derived_ad);
+        }
+        JSONArray inventory_type = getData.getJSONArray("inventory_type");
+        if(null!=inventory_type&&!inventory_type.isEmpty()){
+            data.put("inventoryType",inventory_type);
+        }
+        String source = getData.getString("source");
+        if(null!=source&&!source.trim().equals("")){
+            data.put("source",source);
+        }
+        String app_name = getData.getString("app_name");
+        if(null!=app_name&&!app_name.trim().equals("")){
+            data.put("appName",app_name);
+        }
+        String web_url = getData.getString("web_url");
+        if(null!=web_url&&!web_url.trim().equals("")){
+            data.put("webUrl",web_url);
+        }
+        JSONArray ad_keywords = getData.getJSONArray("ad_keywords");
+        if(null!=ad_keywords&&!ad_keywords.isEmpty()){
+            data.put("adKeywords",ad_keywords);
+        }
+        Long third_industry_id = getData.getLong("third_industry_id");
+        if(null!=third_industry_id&&third_industry_id!=0){
+            data.put("thirdIndustryId",third_industry_id);
+        }
+        String advanced_creative_type = getData.getString("advanced_creative_type");
+        if(null!=advanced_creative_type&&!advanced_creative_type.trim().equals("")){
+            data.put("advancedCreativeType",advanced_creative_type);
+        }
+        String advanced_creative_title = getData.getString("advanced_creative_title");
+        if(null!=advanced_creative_title&&!advanced_creative_title.trim().equals("")){
+            data.put("advancedCreativeTitle",advanced_creative_title);
+        }
+        String phone_number = getData.getString("phone_number");
+        if(null!=phone_number&&!phone_number.trim().equals("")){
+            data.put("phoneNumber",phone_number);
+        }
+        String button_text = getData.getString("button_text");
+        if(null!=button_text&&!button_text.trim().equals("")){
+            data.put("buttonText",button_text);
+        }
+        String action_text = getData.getString("action_text");
+        if(null!=action_text&&!action_text.trim().equals("")){
+            data.put("actionText",action_text);
+        }
+        String form_url = getData.getString("form_url");
+        if(null!=form_url&&!form_url.trim().equals("")){
+            data.put("formUrl",form_url);
+        }
+        String creative_material_mode = getData.getString("creative_material_mode");
+        if(null!=creative_material_mode&&!creative_material_mode.trim().equals("")){
+            data.put("creativeMaterialMode",creative_material_mode);
+        }
+        String ies_core_user_id = getData.getString("ies_core_user_id");
+        if(null!=ies_core_user_id&&!ies_core_user_id.trim().equals("")){
+            data.put("iesCoreUserId",ies_core_user_id);
+        }
+        Long is_feed_and_fav_see = getData.getLong("is_feed_and_fav_see");
+        if(null!=is_feed_and_fav_see){
+            data.put("isFeedAndFavSee",is_feed_and_fav_see);
+        }
+        JSONArray commerce_cards = getData.getJSONArray("commerce_cards");
+        if(null!=commerce_cards&&!commerce_cards.isEmpty()){
+            data.put("commerceCards",commerce_cards);
+        }
+        String playable_url = getData.getString("playable_url");
+        if(null!=playable_url&&!playable_url.trim().equals("")){
+            data.put("playableUrl",playable_url);
+        }
+        Long procedural_package_id = getData.getLong("procedural_package_id");
+        if(null!=procedural_package_id&&procedural_package_id!=0){
+            data.put("proceduralPackageId",procedural_package_id);
+        }
+        Long procedural_package_version = getData.getLong("procedural_package_version");
+        if(null!=procedural_package_version&&procedural_package_version!=0){
+            data.put("proceduralPackageVersion",procedural_package_version);
+        }
+        Long is_presented_video = getData.getLong("is_presented_video");
+        if(null!=is_presented_video){
+            data.put("isPresentedVideo",is_presented_video);
+        }
+        String sub_title = getData.getString("sub_title");
+        if(null!=sub_title&&!sub_title.trim().equals("")){
+            data.put("subTitle",sub_title);
+        }
+        Long creative_auto_generate_switch = getData.getLong("creative_auto_generate_switch");
+        if(null!=creative_auto_generate_switch){
+            data.put("creativeAutoGenerateSwitch",creative_auto_generate_switch);
+        }
+        String track_url_send_type = getData.getString("track_url_send_type");
+        if(null!=track_url_send_type&&!track_url_send_type.trim().equals("")){
+            data.put("trackUrlSendType",track_url_send_type);
+        }
+        JSONArray sub_link_id_list = getData.getJSONArray("track_url_send_type");
+        if(null!=sub_link_id_list&&!sub_link_id_list.isEmpty()){
+            data.put("subLinkIdList",sub_link_id_list);
+        }
+        JSONArray titleList = getData.getJSONArray("title_list");
+        if(null!=titleList&&!titleList.isEmpty()){
+            JSONArray titleArray = new JSONArray();
+            for (int i=0;i<titleList.size();i++){
+                JSONObject title = titleList.getJSONObject(i);
+                JSONArray creativeWordIds = title.getJSONArray("creative_word_ids");
+                JSONArray dpaDictIds = title.getJSONArray("dpa_dict_ids");
+                title.remove("creative_word_ids");
+                title.remove("dpa_dict_ids");
+                title.put("creativeWordIds",creativeWordIds);
+                title.put("dpaDictIds",dpaDictIds);
+                titleArray.add(title);
+            }
+            data.put("titleList",titleArray);
+        }
+        JSONArray imageList = getData.getJSONArray("image_list");
+        if(null!=imageList&&!imageList.isEmpty()){
+            JSONArray imageArray = new JSONArray();
+            for (int i=0;i<imageList.size();i++){
+                JSONObject getImage = imageList.getJSONObject(i);
+                JSONObject setImage = new JSONObject();
+                String imageMode = getImage.getString("image_mode");
+                setImage.put("imageMode",imageMode);
+                String imageId = getImage.getString("image_id");
+                if(null!=imageId&&!imageId.trim().equals("")){
+                    setImage.put("imageId",imageId);
+                }
+                String videoId = getImage.getString("video_id");
+                if(null!=videoId&&!videoId.trim().equals("")){
+                    setImage.put("videoId",videoId);
+                }
+                JSONArray imageIds = getImage.getJSONArray("image_ids");
+                if(null!=imageIds&&!imageIds.isEmpty()){
+                    setImage.put("imageIds",imageIds);
+                }
+                String templateId = getImage.getString("template_id");
+                if(null!=templateId&&!templateId.trim().equals("")){
+                    setImage.put("templateId",templateId);
+                }
+                imageArray.add(setImage);
+            }
+            data.put("imageList",imageArray);
+        }
+        JSONArray creativeList = getData.getJSONArray("creatives");
+        if(null!=creativeList&&!creativeList.isEmpty()){
+            JSONArray creativeArray = new JSONArray();
+            for (int i=0;i<creativeList.size();i++){
+                JSONObject getCreative = creativeList.getJSONObject(i);
+                JSONObject setCreative = new JSONObject();
+                String creative_id = getCreative.getString("creative_id");
+                if(null!=creative_id&&!creative_id.trim().equals("")){
+                    setCreative.put("creative_id",creative_id);
+                }
+                String title = getCreative.getString("title");
+                if(null!=title&&!title.trim().equals("")){
+                    setCreative.put("title",title);
+                }
+                JSONArray creativeWordIds = getCreative.getJSONArray("creative_word_ids");
+                if(null!=creativeWordIds&&!creativeWordIds.isEmpty()){
+                    setCreative.put("creativeWordIds",creativeWordIds);
+                }
+                JSONArray dpaDictIds = getCreative.getJSONArray("dpa_dict_ids");
+                if(null!=dpaDictIds&&!dpaDictIds.isEmpty()){
+                    setCreative.put("dpaDictIds",dpaDictIds);
+                }
+                String imageMode = getCreative.getString("image_mode");
+                if(null!=imageMode&&!imageMode.trim().equals("")){
+                    setCreative.put("imageMode",imageMode);
+                }
+                JSONArray imageIds = getCreative.getJSONArray("imageIds");
+                if(null!=imageIds&&!imageIds.isEmpty()){
+                    setCreative.put("imageIds",imageIds);
+                }
+                String imageId = getCreative.getString("image_id");
+                if(null!=imageId&&!imageId.trim().equals("")){
+                    setCreative.put("imageId",imageId);
+                }
+                String videoId = getCreative.getString("video_id");
+                if(null!=videoId&&!videoId.trim().equals("")){
+                    setCreative.put("videoId",videoId);
+                }
+                String thirdPartyId = getCreative.getString("third_party_id");
+                if(null!=thirdPartyId&&!thirdPartyId.trim().equals("")){
+                    setCreative.put("thirdPartyId",thirdPartyId);
+                }
+                Long derivePosterCid = getCreative.getLong("derive_poster_cid");
+                if(null!=derivePosterCid){
+                    setCreative.put("derivePosterCid",derivePosterCid);
+                }
+                Integer templateId = getCreative.getInteger("template_id");
+                if(null!=templateId){
+                    setCreative.put("templateId",templateId);
+                }
+                String templateImageId = getCreative.getString("template_image_id");
+                if(null!=templateImageId&&!templateImageId.trim().equals("")){
+                    setCreative.put("templateImageId",templateImageId);
+                }
+                Long dpaTemplate = getCreative.getLong("dpa_template");
+                if(null!=dpaTemplate){
+                    setCreative.put("dpaTemplate",dpaTemplate);
+                }
+                String dpaVideoTemplateType = getCreative.getString("dpa_video_template_type");
+                if(null!=dpaVideoTemplateType&&!dpaVideoTemplateType.trim().equals("")){
+                    setCreative.put("dpaVideoTemplateType",dpaVideoTemplateType);
+                }
+                JSONArray dpaVideoTaskIds = getCreative.getJSONArray("dpa_video_task_ids");
+                if(null!=dpaVideoTaskIds&&!dpaVideoTaskIds.isEmpty()){
+                    setCreative.put("dpaVideoTaskIds",dpaVideoTaskIds);
+                }
+                creativeArray.add(setCreative);
+            }
+            data.put("creatives",creativeArray);
+        }
+
         return data;
     }
 
     /**
-     * TODO 后续需要拼接参数
-     * @param accountId
      * @param data
      * @return
      */
     @Override
-    public Map<String,Object> updateCreative(Long accountId,JSONObject data){
-        Map<String,Object>resultMap = new HashMap<>();
+    public Map<String,Object> updateCreative(JSONObject data){
+        log.info(data.toJSONString());
+        Map<String,Object>result = new HashMap<>();
+        Long accountId = data.getLong("accountId");
         CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        if(null == token){
+            ResultMapUtils.setResultMap(result,StatusCode.COMMON_PARAM_ERROR);
+            return result;
+        }
+        Long planId = data.getLong("adId");
+        if(null == planId||planId==0){
+            ResultMapUtils.setResultMap(result,StatusCode.COMMON_PARAM_ERROR);
+            return result;
+        }
+        JSONObject params  = initParams(data);
         // 请求地址
         String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_creative_update");
-        JSONObject result = HttpUtils.bytedancePostRequest(token.getAccessToken(),url,data);
-        Integer code = result.getInteger("code");
-        String message = result.getString("message");
+        JSONObject dataObject = HttpUtils.bytedancePostRequest(token.getAccessToken(),url,data);
+        Integer code = dataObject.getInteger("code");
+        String message = dataObject.getString("message");
         if (null == code || code != 0) {
             log.info("广告创意更新失败,accountId:{},message:{}", accountId, message);
-            resultMap.put("success", false);
-            resultMap.put("code", -1);
-            resultMap.put("message", message);
-            return resultMap;
+            result.put("success", false);
+            result.put("code", -1);
+            result.put("message", message);
+            return result;
         }
-        resultMap.put("data",result.getJSONObject("data"));
-        ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS);
-        return resultMap;
+        Thread thread = new Thread(()->getAdvertiserCreative(token,null, DateUtils.formatDate()));
+        thread.start();
+        result.put("data",dataObject.getJSONObject("data"));
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+        return result;
     }
 
     @Override
@@ -320,7 +617,8 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
             Map<String,Object> getData = creativeCreate(accountId+"",planIds.getLong(i),params);
             array.add(getData);
         }
-        getAdvertiserCreative(token,null, DateUtils.formatDate());
+        Thread thread = new Thread(()->getAdvertiserCreative(token,null, DateUtils.formatDate()));
+        thread.start();
         result.put("data",array);
         ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
         return result;

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

@@ -0,0 +1,82 @@
+package cn.com.ctop.toutiao.modules.report.controller;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceAccountReportService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceInterfaceService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * Created by JQ.bi on 2020.6.5
+ */
+@Slf4j
+@RestController
+@RequestMapping("/ctop/bytedance/report")
+public class BytedanceInterfaceController {
+
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IByteDanceVideoReportDailyService byteDanceVideoReportDailyService;
+    @Autowired
+    private IBytedanceInterfaceService bytedanceInterfaceService;
+
+
+    /**
+     * 头条视频素材报表--此接口仅有视频素材,单个accountId拉取数据
+     * @param startDate
+     * @param endDate
+     * @return
+     */
+    @GetMapping("/bytedancePlayableReportByAccountId")
+    public Result bytedancePlayableReportByAccountId(@RequestParam(name = "startDate") String startDate,
+                                                          @RequestParam(name = "endDate") String endDate,
+                                                          @RequestParam(name = "accountId") Long accountId) {
+        Result result = new Result<>();
+        if (StringUtils.isBlank(startDate) || StringUtils.isBlank(endDate)||accountId==null){
+            result.error500("开始时间,结束时间和账户id不能为空");
+            return result;
+        }
+        try {
+            log.info("头条获取单个账户视频素材报表数据任务执行开始");
+            Long starttime = System.currentTimeMillis();
+            CtopOauthToken token = tokenService.getOauthTokenByAccountId(String.valueOf(accountId));
+            if (null == token ) {
+                log.info("头条获取单个账户视频素材报表数据任务执行失败:未获取到可用的token");
+                return result;
+            }
+
+            //间隔天数
+            Long days = DateUtils.getDiscrepantDays(startDate, endDate);
+            String start = null;
+            String end = null;
+            for (int i = 0; i <= days; i++) {
+                start = DateUtils.addDay(startDate, i);
+                end = start;
+                //获取头条素材报表数据
+                bytedanceInterfaceService.bytedancePlayableReport(token, start, end);
+            }
+
+            Long endtime = System.currentTimeMillis();
+            log.info("头条获取视频素材报表数据任务执行结束,执行耗时:{}秒", (endtime - starttime) / 1000);
+        } catch (Exception e) {
+            log.error("头条获取视频素材报表数据任务执行结失败");
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return result;
+    }
+
+}

+ 1 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/ByteDanceOperationRecord.java

@@ -1,4 +1,4 @@
-package cn.com.ctop.toutiao.modules.material.entity;
+package cn.com.ctop.toutiao.modules.report.entity;
 
 import lombok.Data;
 

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

@@ -0,0 +1,527 @@
+package cn.com.ctop.toutiao.modules.report.entity;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecg.common.util.DateUtils;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 头条视频素材日报表--仅包含视频素材
+ * @author sunzhen
+ */
+@Data
+@TableName("ctop_bytedance_report_playable_daily")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_bytedance_report_playable_daily", description="头条视频素材日报表--仅包含视频素材")
+public class BytedanceReportPlayableDaily {
+
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	@ApiModelProperty(value = "id")
+	private Long id;
+	/**广告主id*/
+	@Excel(name = "广告主id", width = 15)
+	@ApiModelProperty(value = "广告主id")
+	private Long accountId;
+	/**数据起始时间1*/
+	@Excel(name = "数据起始时间1", width = 15)
+	@ApiModelProperty(value = "数据起始时间1")
+	private String statDatetime;
+
+	/**点击量1*/
+	@Excel(name = "点击量1", width = 15)
+	@ApiModelProperty(value = "点击量1")
+	private Integer click;
+	/**总花费1*/
+	@Excel(name = "总花费1", width = 15)
+	@ApiModelProperty(value = "总花费1")
+	private BigDecimal cost;
+	/**应用下载-激活1*/
+	@Excel(name = "应用下载-激活1", width = 15)
+	@ApiModelProperty(value = "应用下载-激活1")
+	private Integer active;
+	/**应用下载-安卓下载完成1*/
+	@Excel(name = "应用下载-安卓下载完成1", width = 15)
+	@ApiModelProperty(value = "应用下载-安卓下载完成1")
+	private Integer downloadFinish;
+	/**应用下载-安卓下载开始1*/
+	@Excel(name = "应用下载-安卓下载开始1", width = 15)
+	@ApiModelProperty(value = "应用下载-安卓下载开始1")
+	private Integer downloadStart;
+	/**应用下载-安卓安装完成*/
+	@Excel(name = "应用下载-安卓安装完成", width = 15)
+	@ApiModelProperty(value = "应用下载-安卓安装完成")
+	private Integer installFinish;
+	/**应用下载-注册1*/
+	@Excel(name = "应用下载-注册1", width = 15)
+	@ApiModelProperty(value = "应用下载-注册1")
+	private Integer register;
+	/**应用下载-付费数1*/
+	@Excel(name = "应用下载-付费数1", width = 15)
+	@ApiModelProperty(value = "应用下载-付费数1")
+	private Integer payCount;
+	/**应用下载-到达uv1*/
+	@Excel(name = "应用下载-到达uv1", width = 15)
+	@ApiModelProperty(value = "应用下载-到达uv1")
+	private Integer inAppUv;
+	/**应用下载-详情页到站uv1*/
+	@Excel(name = "应用下载-详情页到站uv1", width = 15)
+	@ApiModelProperty(value = "应用下载-详情页到站uv1")
+	private Integer inAppDetailUv;
+	/**应用下载-加入购物车1*/
+	@Excel(name = "应用下载-加入购物车1", width = 15)
+	@ApiModelProperty(value = "应用下载-加入购物车1")
+	private Integer inAppCart;
+	/**应用下载-提交订单1*/
+	@Excel(name = "应用下载-提交订单1", width = 15)
+	@ApiModelProperty(value = "应用下载-提交订单1")
+	private Integer inAppOrder;
+	/**应用下载-付费1*/
+	@Excel(name = "应用下载-付费1", width = 15)
+	@ApiModelProperty(value = "应用下载-付费1")
+	private Integer inAppPay;
+	/**落地页-电话拨打数1*/
+	@Excel(name = "落地页-电话拨打数1", width = 15)
+	@ApiModelProperty(value = "落地页-电话拨打数1")
+	private Integer phone;
+	/**表单提交数1*/
+	@Excel(name = "表单提交数1", width = 15)
+	@ApiModelProperty(value = "表单提交数1")
+	private Integer form;
+	/**落地页-地图搜索1*/
+	@Excel(name = "落地页-地图搜索1", width = 15)
+	@ApiModelProperty(value = "落地页-地图搜索1")
+	private Integer mapSearch;
+	/**落地页-按钮button1*/
+	@Excel(name = "落地页-按钮button1", width = 15)
+	@ApiModelProperty(value = "落地页-按钮button1")
+	private Integer button;
+	/**落地页-关键页面浏览1*/
+	@Excel(name = "落地页-关键页面浏览1", width = 15)
+	@ApiModelProperty(value = "落地页-关键页面浏览1")
+	private Integer viewMaterial;
+	/**落地页-QQ咨询数1*/
+	@Excel(name = "落地页-QQ咨询数1", width = 15)
+	@ApiModelProperty(value = "落地页-QQ咨询数1")
+	private Integer qq;
+	/**落地页-抽奖数1*/
+	@Excel(name = "落地页-抽奖数1", width = 15)
+	@ApiModelProperty(value = "落地页-抽奖数1")
+	private Integer lottery;
+	/**落地页-投票1*/
+	@Excel(name = "落地页-投票1", width = 15)
+	@ApiModelProperty(value = "落地页-投票1")
+	private Integer vote;
+	/**落地页-页面跳转1*/
+	@Excel(name = "落地页-页面跳转1", width = 15)
+	@ApiModelProperty(value = "落地页-页面跳转1")
+	private Integer redirect;
+	/**落地页-商品购买1*/
+	@Excel(name = "落地页-商品购买1", width = 15)
+	@ApiModelProperty(value = "落地页-商品购买1")
+	private Integer shopping;
+	/**落地页-在线咨询1*/
+	@Excel(name = "落地页-在线咨询1", width = 15)
+	@ApiModelProperty(value = "落地页-在线咨询1")
+	private Integer consult;
+	/**落地页-微信1*/
+	@Excel(name = "落地页-微信1", width = 15)
+	@ApiModelProperty(value = "落地页-微信1")
+	private Integer wechat;
+	/**落地页-智能电话确认拨打1*/
+	@Excel(name = "落地页-智能电话确认拨打1", width = 15)
+	@ApiModelProperty(value = "落地页-智能电话确认拨打1")
+	private Integer phoneConfirm;
+	/**落地页-智能电话确认接通1*/
+	@Excel(name = "落地页-智能电话确认接通1", width = 15)
+	@ApiModelProperty(value = "落地页-智能电话确认接通1")
+	private Integer phoneConnect;
+	/**落地页-智能电话有效咨询1*/
+	@Excel(name = "落地页-智能电话有效咨询1", width = 15)
+	@ApiModelProperty(value = "落地页-智能电话有效咨询1")
+	private Integer consultEffective;
+	/**视频-总播放1*/
+	@Excel(name = "视频-总播放1", width = 15)
+	@ApiModelProperty(value = "视频-总播放1")
+	private Integer totalPlay;
+	/**视频-有效播放1*/
+	@Excel(name = "视频-有效播放1", width = 15)
+	@ApiModelProperty(value = "视频-有效播放1")
+	private Integer validPlay;
+	/**视频-wifi播放1*/
+	@Excel(name = "视频-wifi播放1", width = 15)
+	@ApiModelProperty(value = "视频-wifi播放1")
+	private Integer wifiPlay;
+	/**视频-播放时长,单位ms1*/
+	@Excel(name = "视频-播放时长,单位ms1", width = 15)
+	@ApiModelProperty(value = "视频-播放时长,单位ms1")
+	private Integer playDurationSum;
+	/**视频-播放25%进度总数1*/
+	@Excel(name = "视频-播放25%进度总数1", width = 15)
+	@ApiModelProperty(value = "视频-播放25%进度总数1")
+	private Integer play25FeedBreak;
+	/**视频-播放50%进度总数1*/
+	@Excel(name = "视频-播放50%进度总数1", width = 15)
+	@ApiModelProperty(value = "视频-播放50%进度总数1")
+	private Integer play50FeedBreak;
+	/**视频-播放75%进度总数*/
+	@Excel(name = "视频-播放75%进度总数", width = 15)
+	@ApiModelProperty(value = "视频-播放75%进度总数")
+	private Integer play75FeedBreak;
+	/**视频-播放100%进度总数1*/
+	@Excel(name = "视频-播放100%进度总数1", width = 15)
+	@ApiModelProperty(value = "视频-播放100%进度总数1")
+	private Integer play100FeedBreak;
+	/**附加创意-电话按钮1*/
+	@Excel(name = "附加创意-电话按钮1", width = 15)
+	@ApiModelProperty(value = "附加创意-电话按钮1")
+	private Integer advancedCreativePhoneClick;
+	/**附加创意-在线咨询1*/
+	@Excel(name = "附加创意-在线咨询1", width = 15)
+	@ApiModelProperty(value = "附加创意-在线咨询1")
+	private Integer advancedCreativeCounselClick;
+	/**附加创意-表单提交1*/
+	@Excel(name = "附加创意-表单提交1", width = 15)
+	@ApiModelProperty(value = "附加创意-表单提交1")
+	private Integer advancedCreativeFormClick;
+	/**互动数据-分享数1*/
+	@Excel(name = "互动数据-分享数1", width = 15)
+	@ApiModelProperty(value = "互动数据-分享数1")
+	private Integer shareMaterial;
+	/**互动数据-评论数1*/
+	@Excel(name = "互动数据-评论数1", width = 15)
+	@ApiModelProperty(value = "互动数据-评论数1")
+	private Integer commentMaterial;
+	/**互动数据-关注数1*/
+	@Excel(name = "互动数据-关注数1", width = 15)
+	@ApiModelProperty(value = "互动数据-关注数1")
+	private Integer follow;
+	/**互动数据-主页访问量1*/
+	@Excel(name = "互动数据-主页访问量1", width = 15)
+	@ApiModelProperty(value = "互动数据-主页访问量1")
+	private Integer homeVisited;
+	/**互动数据-挑战赛查看数1*/
+	@Excel(name = "互动数据-挑战赛查看数1", width = 15)
+	@ApiModelProperty(value = "互动数据-挑战赛查看数1")
+	private Integer iesChallengeClick;
+	/**互动数据-音乐查看数1*/
+	@Excel(name = "互动数据-音乐查看数1", width = 15)
+	@ApiModelProperty(value = "互动数据-音乐查看数1")
+	private Integer iesMusicClick;
+	/**次留数1*/
+	@Excel(name = "次留数1", width = 15)
+	@ApiModelProperty(value = "次留数1")
+	private Integer nextDayOpen;
+	/**次留率1*/
+	@Excel(name = "次留率1", width = 15)
+	@ApiModelProperty(value = "次留率1")
+	private BigDecimal nextDayOpenRate;
+	/**次留成本*/
+	@Excel(name = "次留成本", width = 15)
+	@ApiModelProperty(value = "次留成本")
+	private BigDecimal nextDayOpenCost;
+	/**素材类型*/
+	@Excel(name = "素材类型", width = 15)
+	@ApiModelProperty(value = "素材类型")
+	private String imageMode;
+	/**素材id*/
+	@Excel(name = "素材id", width = 15)
+	@ApiModelProperty(value = "素材id")
+	private Long materialId;
+	/**投放位置*/
+	@Excel(name = "投放位置", width = 15)
+	@ApiModelProperty(value = "投放位置")
+	private String inventory;
+	/**activePayAmount*/
+	@Excel(name = "activePayAmount", width = 15)
+	@ApiModelProperty(value = "activePayAmount")
+	private Integer activePayAmount;
+	/**validPlayCost*/
+	@Excel(name = "validPlayCost", width = 15)
+	@ApiModelProperty(value = "validPlayCost")
+	private BigDecimal validPlayCost;
+	/**advancedCreativeCouponAddition*/
+	@Excel(name = "advancedCreativeCouponAddition", width = 15)
+	@ApiModelProperty(value = "advancedCreativeCouponAddition")
+	private Integer advancedCreativeCouponAddition;
+	/**convert*/
+	@Excel(name = "convert", width = 15)
+	@ApiModelProperty(value = "convert")
+	private Integer convertMaterial;
+	/**activePayCost*/
+	@Excel(name = "activePayCost", width = 15)
+	@ApiModelProperty(value = "activePayCost")
+	private BigDecimal activePayCost;
+	/**download*/
+	@Excel(name = "download", width = 15)
+	@ApiModelProperty(value = "download")
+	private Integer download;
+	/**cpa*/
+	@Excel(name = "cpa", width = 15)
+	@ApiModelProperty(value = "cpa")
+	private BigDecimal cpa;
+	/**cpc*/
+	@Excel(name = "cpc", width = 15)
+	@ApiModelProperty(value = "cpc")
+	private BigDecimal cpc;
+	/**locationClick*/
+	@Excel(name = "locationClick", width = 15)
+	@ApiModelProperty(value = "locationClick")
+	private Integer locationClick;
+	/**playOverRate*/
+	@Excel(name = "playOverRate", width = 15)
+	@ApiModelProperty(value = "playOverRate")
+	private BigDecimal playOverRate;
+	/**ctr*/
+	@Excel(name = "ctr", width = 15)
+	@ApiModelProperty(value = "ctr")
+	private BigDecimal ctr;
+	/**cpm*/
+	@Excel(name = "cpm", width = 15)
+	@ApiModelProperty(value = "cpm")
+	private BigDecimal cpm;
+	/**wifiPlayRate*/
+	@Excel(name = "wifiPlayRate", width = 15)
+	@ApiModelProperty(value = "wifiPlayRate")
+	private BigDecimal wifiPlayRate;
+	/**like*/
+	@Excel(name = "like", width = 15)
+	@ApiModelProperty(value = "like")
+	private Integer likeMaterial;
+	/**activePayRate*/
+	@Excel(name = "activePayRate", width = 15)
+	@ApiModelProperty(value = "activePayRate")
+	private BigDecimal activePayRate;
+	/**activeCost*/
+	@Excel(name = "activeCost", width = 15)
+	@ApiModelProperty(value = "activeCost")
+	private BigDecimal activeCost;
+	/**gameAddictionCost*/
+	@Excel(name = "gameAddictionCost", width = 15)
+	@ApiModelProperty(value = "gameAddictionCost")
+	private BigDecimal gameAddictionCost;
+	/**gameAddiction*/
+	@Excel(name = "gameAddiction", width = 15)
+	@ApiModelProperty(value = "gameAddiction")
+	private Integer gameAddiction;
+	/**activeRate*/
+	@Excel(name = "activeRate", width = 15)
+	@ApiModelProperty(value = "activeRate")
+	private BigDecimal activeRate;
+	/**playDuration10s*/
+	@Excel(name = "playDuration10s", width = 15)
+	@ApiModelProperty(value = "playDuration10s")
+	private Integer playDuration_10s;
+	/**phoneEffective*/
+	@Excel(name = "phoneEffective", width = 15)
+	@ApiModelProperty(value = "phoneEffective")
+	private Integer phoneEffective;
+	/**gameAddictionRate*/
+	@Excel(name = "gameAddictionRate", width = 15)
+	@ApiModelProperty(value = "gameAddictionRate")
+	private BigDecimal gameAddictionRate;
+	/**activeRegisterRate*/
+	@Excel(name = "activeRegisterRate", width = 15)
+	@ApiModelProperty(value = "activeRegisterRate")
+	private BigDecimal activeRegisterRate;
+	/**averageVideoPlay*/
+	@Excel(name = "averageVideoPlay", width = 15)
+	@ApiModelProperty(value = "averageVideoPlay")
+	private BigDecimal averageVideoPlay;
+	/**downloadFinishCost*/
+	@Excel(name = "downloadFinishCost", width = 15)
+	@ApiModelProperty(value = "downloadFinishCost")
+	private BigDecimal downloadFinishCost;
+	/**playDuration3s*/
+	@Excel(name = "playDuration3s", width = 15)
+	@ApiModelProperty(value = "playDuration3s")
+	private Integer playDuration_3s;
+	/**activeRegisterCost*/
+	@Excel(name = "activeRegisterCost", width = 15)
+	@ApiModelProperty(value = "activeRegisterCost")
+	private BigDecimal activeRegisterCost;
+	/**show*/
+	@Excel(name = "show", width = 15)
+	@ApiModelProperty(value = "show")
+	private Integer showMaterial;
+	/**convertRate*/
+	@Excel(name = "convertRate", width = 15)
+	@ApiModelProperty(value = "convertRate")
+	private BigDecimal convertRate;
+	/**downloadFinishRate*/
+	@Excel(name = "downloadFinishRate", width = 15)
+	@ApiModelProperty(value = "downloadFinishRate")
+	private BigDecimal downloadFinishRate;
+	/**installFinishRate*/
+	@Excel(name = "installFinishRate", width = 15)
+	@ApiModelProperty(value = "installFinishRate")
+	private BigDecimal installFinishRate;
+	/**coupon*/
+	@Excel(name = "coupon", width = 15)
+	@ApiModelProperty(value = "coupon")
+	private Integer coupon;
+	/**couponSinglePage*/
+	@Excel(name = "couponSinglePage", width = 15)
+	@ApiModelProperty(value = "couponSinglePage")
+	private Integer couponSinglePage;
+	/**playOver*/
+	@Excel(name = "playOver", width = 15)
+	@ApiModelProperty(value = "playOver")
+	private Integer playOver;
+	/**downloadStartCost*/
+	@Excel(name = "downloadStartCost", width = 15)
+	@ApiModelProperty(value = "downloadStartCost")
+	private BigDecimal downloadStartCost;
+	/**message*/
+	@Excel(name = "message", width = 15)
+	@ApiModelProperty(value = "message")
+	private Integer message;
+	/**playDuration*/
+	@Excel(name = "playDuration", width = 15)
+	@ApiModelProperty(value = "playDuration")
+	private Integer playDuration;
+	/**validPlayRate*/
+	@Excel(name = "validPlayRate", width = 15)
+	@ApiModelProperty(value = "validPlayRate")
+	private BigDecimal validPlayRate;
+	/**averagePlayTimePerPlay*/
+	@Excel(name = "averagePlayTimePerPlay", width = 15)
+	@ApiModelProperty(value = "averagePlayTimePerPlay")
+	private BigDecimal averagePlayTimePerPlay;
+	/**convertCost*/
+	@Excel(name = "convertCost", width = 15)
+	@ApiModelProperty(value = "convertCost")
+	private BigDecimal convertCost;
+	/**convertShowRate*/
+	@Excel(name = "convertShowRate", width = 15)
+	@ApiModelProperty(value = "convertShowRate")
+	private BigDecimal convertShowRate;
+	/**installFinishCost*/
+	@Excel(name = "installFinishCost", width = 15)
+	@ApiModelProperty(value = "installFinishCost")
+	private BigDecimal installFinishCost;
+
+	private BigDecimal downloadStartRate;
+
+
+
+
+	public BytedanceReportPlayableDaily() {
+	}
+
+	public BytedanceReportPlayableDaily(JSONObject detailJson, Long accountId) {
+		JSONObject dimensions = detailJson.getJSONObject("dimensions");
+		this.accountId = accountId;
+		//this.setPlayableName(dimensions.getString("playable_name"));
+		//this.setPlayableUrl(dimensions.getString("playable_url"));
+		//this.setPlayableId(dimensions.getLong("playable_id"));
+		//this.setPlayablePreviewUrl(dimensions.getString("playable_preview_url"));
+		//this.setPlayableOrientation(dimensions.getString("playable_orientation"));
+		this.setStatDatetime(dimensions.getDate("stat_datetime") == null ? null : DateUtils.formatDate(dimensions.getDate("stat_datetime"), "yyyy-MM-dd"));
+
+		JSONObject metrics = detailJson.getJSONObject("metrics");
+		this.setActivePayAmount(metrics.getInteger("active_pay_amount"));
+		this.setValidPlayCost(metrics.getBigDecimal("valid_play_cost"));
+		this.setPlay75FeedBreak(metrics.getInteger("play_75_feed_break"));
+		this.setNextDayOpen(metrics.getInteger("next_day_open"));
+		this.setAdvancedCreativeCouponAddition(metrics.getInteger("advanced_creative_coupon_addition"));
+		this.setConvertMaterial(metrics.getInteger("convert"));
+		this.setActivePayCost(metrics.getBigDecimal("active_pay_cost"));
+		this.setInAppCart(metrics.getInteger("in_app_cart"));
+		this.setPlay25FeedBreak(metrics.getInteger("play_25_feed_break"));
+		this.setConsultEffective(metrics.getInteger("consult_effective"));
+		this.setViewMaterial(metrics.getInteger("view"));
+		this.setDownload(metrics.getInteger("download"));
+		this.setCpa(metrics.getBigDecimal("cpa"));
+		this.setCpc(metrics.getBigDecimal("cpc"));
+		this.setLocationClick(metrics.getInteger("location_click"));
+		this.setPhoneConfirm(metrics.getInteger("phone_confirm"));
+		this.setIesMusicClick(metrics.getInteger("ies_music_click"));
+		this.setPlayOverRate(metrics.getBigDecimal("play_over_rate"));
+		this.setWifiPlay(metrics.getInteger("wifi_play"));
+		this.setShopping(metrics.getInteger("shopping"));
+		this.setQq(metrics.getInteger("qq"));
+		this.setCtr(metrics.getBigDecimal("ctr"));
+		this.setCpm(metrics.getBigDecimal("cpm"));
+		this.setWifiPlayRate(metrics.getBigDecimal("wifi_play_rate"));
+		this.setLikeMaterial(metrics.getInteger("like"));
+		this.setPlay50FeedBreak(metrics.getInteger("play_50_feed_break"));
+		this.setActivePayRate(metrics.getBigDecimal("active_pay_rate"));
+		this.setActiveCost(metrics.getBigDecimal("active_cost"));
+		this.setActive(metrics.getInteger("active"));
+		this.setGameAddictionCost(metrics.getBigDecimal("game_addiction_cost"));
+		this.setGameAddiction(metrics.getInteger("game_addiction"));
+		this.setActiveRate(metrics.getBigDecimal("active_rate"));
+		this.setClick(metrics.getInteger("click"));
+		this.setPlayDuration_10s(metrics.getInteger("play_duration_10s"));
+		this.setAdvancedCreativePhoneClick(metrics.getInteger("advanced_creative_phone_click"));
+		this.setDownloadStart(metrics.getInteger("download_start"));
+		this.setHomeVisited(metrics.getInteger("home_visited"));
+		this.setPhone(metrics.getInteger("phone"));
+		this.setPhoneEffective(metrics.getInteger("phone_effective"));
+		this.setInAppPay(metrics.getInteger("in_app_pay"));
+		this.setGameAddictionRate(metrics.getBigDecimal("game_addiction_rate"));
+		this.setNextDayOpenCost(metrics.getBigDecimal("next_day_open_cost"));
+		this.setIesChallengeClick(metrics.getInteger("ies_challenge_click"));
+		this.setTotalPlay(metrics.getInteger("total_play"));
+		this.setActiveRegisterRate(metrics.getBigDecimal("active_register_rate"));
+		this.setAverageVideoPlay(metrics.getBigDecimal("average_video_play"));
+		this.setDownloadFinishCost(metrics.getBigDecimal("download_finish_cost"));
+		this.setPlayDuration_3s(metrics.getInteger("play_duration_3s"));
+		this.setActiveRegisterCost(metrics.getBigDecimal("active_register_cost"));
+		this.setShowMaterial(metrics.getInteger("show"));
+		this.setNextDayOpenRate(metrics.getBigDecimal("next_day_open_rate"));
+		this.setMapSearch(metrics.getInteger("map_search"));
+		this.setButton(metrics.getInteger("button"));
+		this.setPlayDurationSum(metrics.getInteger("play_duration_sum"));
+		this.setPlay100FeedBreak(metrics.getInteger("play_100_feed_break"));
+		this.setAdvancedCreativeCounselClick(metrics.getInteger("advanced_creative_counsel_click"));
+		this.setConvertRate(metrics.getBigDecimal("convert_rate"));
+		this.setDownloadFinishRate(metrics.getBigDecimal("download_finish_rate"));
+		this.setConsult(metrics.getInteger("consult"));
+		this.setShareMaterial(metrics.getInteger("share"));
+		this.setVote(metrics.getInteger("vote"));
+		this.setValidPlay(metrics.getInteger("valid_play"));
+		this.setInstallFinishRate(metrics.getBigDecimal("install_finish_rate"));
+		this.setRedirect(metrics.getInteger("redirect"));
+		this.setPayCount(metrics.getInteger("pay_count"));
+		this.setAdvancedCreativeFormClick(metrics.getInteger("advanced_creative_form_click"));
+		this.setCost(metrics.getBigDecimal("cost"));
+		this.setPhoneConnect(metrics.getInteger("phone_connect"));
+		this.setCoupon(metrics.getInteger("coupon"));
+		this.setDownloadStartRate(metrics.getBigDecimal("download_start_rate"));
+		this.setDownloadFinish(metrics.getInteger("download_finish"));
+		this.setWechat(metrics.getInteger("wechat"));
+		this.setCouponSinglePage(metrics.getInteger("coupon_single_page"));
+		this.setInstallFinish(metrics.getInteger("install_finish"));
+		this.setLottery(metrics.getInteger("lottery"));
+		this.setPlayOver(metrics.getInteger("play_over"));
+		this.setInAppOrder(metrics.getInteger("in_app_order"));
+		this.setDownloadStartCost(metrics.getBigDecimal("download_start_cost"));
+		this.setFollow(metrics.getInteger("follow"));
+		this.setMessage(metrics.getInteger("message"));
+		this.setInAppDetailUv(metrics.getInteger("in_app_detail_uv"));
+		this.setPlayDuration(metrics.getInteger("play_duration"));
+		this.setForm(metrics.getInteger("form"));
+		this.setValidPlayRate(metrics.getBigDecimal("valid_play_rate"));
+		this.setAveragePlayTimePerPlay(metrics.getBigDecimal("average_play_time_per_play"));
+		this.setConvertShowRate(metrics.getBigDecimal("convert_show_rate"));
+		this.setInstallFinishCost(metrics.getBigDecimal("install_finish_cost"));
+		this.setCommentMaterial(metrics.getInteger("comment"));
+		this.setInAppUv(metrics.getInteger("in_app_uv"));
+		this.setRegister(metrics.getInteger("register"));
+		this.setConvertCost(metrics.getBigDecimal("convert_cost"));
+	}
+
+}

+ 1 - 4
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceOperationRecordMapper.java

@@ -1,9 +1,6 @@
 package cn.com.ctop.toutiao.modules.report.mapper;
 
-import cn.com.ctop.toutiao.modules.material.entity.ByteDanceOperationRecord;
-import cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import cn.com.ctop.toutiao.modules.report.entity.ByteDanceOperationRecord;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;

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

@@ -3,24 +3,26 @@
 <mapper namespace="cn.com.ctop.toutiao.modules.report.mapper.BytedanceOperationRecordMapper">
 
     <select id="insertOperationRecordCampaign">
-        insert into
+        replace into
         ctop_bytedance_operation_record_campaign
         (
-            account_id,
-            object_id,
-            object_type,
-            content_title,
-            object_name,
-            operation_create_time,
-            content_log,
-            operator,
-            opt_ip,
-            operation_target
+        account_id,
+        stat_date,
+        object_id,
+        object_type,
+        content_title,
+        object_name,
+        operation_create_time,
+        content_log,
+        operator,
+        opt_ip,
+        operation_target
         )
         values
-        <foreach collection="records" item="report" separator=",">
+        <foreach collection="records" item="record" separator=",">
             (
             #{record.accountId},
+            #{record.statDate},
             #{record.objectId},
             #{record.objectType},
             #{record.contentTitle},
@@ -28,31 +30,33 @@
             #{record.operationCreateTime},
             #{record.contentLog},
             #{record.operator},
-            #{record.type},
+            #{record.optIp},
             #{record.operationTarget}
             )
         </foreach>
     </select>
 
     <select id="insertOperationRecordPlan">
-        insert into
+        replace into
         ctop_bytedance_operation_record_plan
         (
-            account_id,
-            object_id,
-            object_type,
-            content_title,
-            object_name,
-            operation_create_time,
-            content_log,
-            operator,
-            opt_ip,
-            operation_target
+        account_id,
+        stat_date,
+        object_id,
+        object_type,
+        content_title,
+        object_name,
+        operation_create_time,
+        content_log,
+        operator,
+        opt_ip,
+        operation_target
         )
         values
-        <foreach collection="records" item="report" separator=",">
+        <foreach collection="records" item="record" separator=",">
             (
             #{record.accountId},
+            #{record.statDate},
             #{record.objectId},
             #{record.objectType},
             #{record.contentTitle},
@@ -60,17 +64,18 @@
             #{record.operationCreateTime},
             #{record.contentLog},
             #{record.operator},
-            #{record.type},
+            #{record.optIp},
             #{record.operationTarget}
             )
         </foreach>
     </select>
 
     <select id="insertOperationRecordCreative">
-        insert into
+        replace into
         ctop_bytedance_operation_record_creative
         (
         account_id,
+        stat_date,
         object_id,
         object_type,
         content_title,
@@ -82,9 +87,10 @@
         operation_target
         )
         values
-        <foreach collection="records" item="report" separator=",">
+        <foreach collection="records" item="record" separator=",">
             (
             #{record.accountId},
+            #{record.statDate},
             #{record.objectId},
             #{record.objectType},
             #{record.contentTitle},
@@ -92,7 +98,7 @@
             #{record.operationCreateTime},
             #{record.contentLog},
             #{record.operator},
-            #{record.type},
+            #{record.optIp},
             #{record.operationTarget}
             )
         </foreach>

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

@@ -6,4 +6,7 @@ public interface IBytedanceInterfaceService {
 
     void searchLog(Long accountId, CtopOauthToken token, Integer operationType, String startDate, String endDate);
 
+    //头条试玩报表
+    int bytedancePlayableReport(CtopOauthToken token, String startDate, String endDate);
+
 }

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

@@ -1,16 +1,17 @@
 package cn.com.ctop.toutiao.modules.report.service.impl;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.entity.MaterialParameter;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.toutiao.modules.material.entity.ByteDanceAdvertisePlan;
 import cn.com.ctop.toutiao.modules.material.entity.ByteDanceCampaign;
 import cn.com.ctop.toutiao.modules.material.entity.ByteDanceCreative;
-import cn.com.ctop.toutiao.modules.material.entity.ByteDanceOperationRecord;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertisePlanService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceCampaignService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeService;
-import cn.com.ctop.toutiao.modules.report.entity.BytedancePlanDailyReport;
+import cn.com.ctop.toutiao.modules.report.entity.ByteDanceOperationRecord;
+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.mapper.BytedanceOperationRecordMapper;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceInterfaceService;
 import com.alibaba.fastjson.JSONArray;
@@ -114,7 +115,7 @@ public class BytedanceInterfaceServiceImpl implements IBytedanceInterfaceService
 
         JSONObject json = HttpUtils.bytedanceGetRequest(access_token, open_api_domain + path, JSONObject.parseObject(JSONObject.toJSONString(data)));
         if (json == null) {
-            log.error("头条日志查询返回为空,请求有误:" + JSONObject.toJSONString(data));
+            log.error("头条日志查询返回为空,请求有误:" + JSONObject.toJSONString(data) + ";;;返回值为:"+ json);
             return ;
         }
 
@@ -141,7 +142,7 @@ public class BytedanceInterfaceServiceImpl implements IBytedanceInterfaceService
                 record.setOperationCreateTime(logJson.getDate("create_time"));
                 record.setStatDate(DateUtils.formatDate(logJson.getDate("create_time")));
                 record.setOperator(logJson.getString("operator"));
-                record.setOptIp(logJson.getString("opt_id"));
+                record.setOptIp(logJson.getString("opt_ip"));
                 record.setOperationTarget(operationType);
 
                 records.add(record);
@@ -156,9 +157,10 @@ public class BytedanceInterfaceServiceImpl implements IBytedanceInterfaceService
                 logSearchByPage(page+1, pageSize, token, accountId, objectId, operationType, startTime, endTime);
             }
         }else{
-            log.error("头条日志查询返回为空,请求有误:" + JSONObject.toJSONString(data),";;;返回值为:"+ json);
+            log.error("头条日志查询返回为空,请求有误:" + JSONObject.toJSONString(data)+";;;返回值为:"+ json);
             return ;
         }
+        //return 200;
     }
 
     private void insertLog(Integer operationTarget, List<ByteDanceOperationRecord> records){
@@ -171,4 +173,115 @@ public class BytedanceInterfaceServiceImpl implements IBytedanceInterfaceService
         }
     }
 
+    //////////////////////////////////////////////////
+
+
+    /**
+     * 头条视频素材报表
+     * @param token
+     * @param startDate
+     * @param endDate
+     * @return
+     */
+    @Override
+    public int bytedancePlayableReport(CtopOauthToken token, String startDate, String endDate) {
+        Long accountId = token.getAccountId();
+        log.info("头条素材报表当前accountId为:{}  {}~{},开始" , accountId, startDate,endDate);
+        Integer page = 1;
+        Integer pageSize = 100;
+        int code = bytedancePlayableReportByPage(page, pageSize, token, accountId, startDate, endDate);
+        if (code != 200 && code != 1) {
+            BytedanceReportMaterialRetry retry = new BytedanceReportMaterialRetry();
+            retry.setAccountId(accountId);
+            retry.setStatus(0);
+            retry.setStartDate(startDate);
+            retry.setEndDate(endDate);
+            retry.setStatusCode(code);
+            retry.setType(2);  //1素材报表重试,2视频素材报表重试
+            //bytedanceReportMaterialDailyMapper.replaceMaterialRetry(retry);
+        }
+        log.info("头条素材报表当前accountId为:{}  {}~{},结束" , accountId, startDate,endDate);
+        return code;
+    }
+
+    private int bytedancePlayableReportByPage(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/integrated/get/";
+
+        // 请求参数
+        Map data = new HashMap();
+        data.put("advertiser_id", accountId);
+        data.put("start_date", startDate);
+        data.put("end_date", endDate);
+        data.put("page", page);
+        data.put("page_size", pageSize);
+        data.put("group_by", new String[]{"STAT_GROUP_BY_PLAYABLE_ID", "STAT_GROUP_BY_TIME_DAY"});  //, "STAT_GROUP_BY_TIME_DAY"
+
+        JSONObject json = HttpUtils.bytedanceGetRequest(access_token, open_api_domain + path, 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 bytedancePlayableReportByPage(page + 1, pageSize, token, accountId, startDate, endDate);
+                }
+            } else {
+                log.error("头条视频素材报表服务器返回为空,accountId:" + accountId + ",json:" + json + "请求为:" + JSONObject.toJSONString(data));
+                return -1;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("头条视频素材报表其他错误,accountId:" + accountId + ",json:" + json + "请求为:" + JSONObject.toJSONString(data));
+            returnCode = -3;
+        }
+        return returnCode;
+    }
+
+
+
+
+
+
+
 }