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

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
syh 5 лет назад
Родитель
Сommit
0aaa6a7bf7
78 измененных файлов с 4064 добавлено и 2150 удалено
  1. 5 3
      jeecg-boot-module-system/src/main/java/org/jeecg/JeecgOneGui.java
  2. 9 9
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AdvertiserController.java
  3. 7 21
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ByteDanceAdvertiserPostController.java
  4. 248 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/KuaiShouDefectMaterialController.java
  5. 13 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialAscriptionController.java
  6. 47 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialImageInfoController.java
  7. 48 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java
  8. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java
  9. 1 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java
  10. 131 249
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  11. 92 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/KuaiShouDefectMaterial.java
  12. 6 6
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceAdvertiserHourlyReportLoadJob.java
  13. 6 6
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceCreativeHourlyReportLoadJob.java
  14. 5 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedancePlanHourlyReportLoadJob.java
  15. 0 40
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/DeleteCreativeStaticJob.java
  16. 0 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyAccountReportLoadJob.java
  17. 0 4
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyCampaignReportLoadJob.java
  18. 0 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyCreativeReportLoadJob.java
  19. 0 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyGroupReportLoadJob.java
  20. 0 4
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyCreativeReportLoadJob.java
  21. 59 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/ToutiaoMaterialsLoadJob.java
  22. 15 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/KuaiShouDefectMaterialMapper.java
  23. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/KuaiShouDefectMaterialMapper.xml
  24. 16 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IKuaiShouDefectMaterialService.java
  25. 0 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BidWarningServiceImpl.java
  26. 90 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/KuaiShouDefectMaterialServiceImpl.java
  27. 19 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/PerformanceController2.java
  28. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/IPerformanceService2.java
  29. 217 22
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/PerformanceServiceImpl2.java
  30. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/CtopOauthTokenMapper.java
  31. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/MaterialInfoMapper.java
  32. 12 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopOauthTokenMapper.xml
  33. 10 4
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MailLogMapper.xml
  34. 48 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialInfoMapper.xml
  35. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java
  36. 6 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialInfoService.java
  37. 12 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java
  38. 40 6
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java
  39. 3 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/CtopAdConstant.java
  40. 2 61
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouController.java
  41. 0 91
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouReportController.java
  42. 0 249
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouReportHourlyCreativeStatisticController.java
  43. 181 68
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  44. 2 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java
  45. 118 1009
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  46. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyCreativeMapper.java
  47. 0 18
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportHourlyCreativeStatisticMapper.java
  48. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyCreativeMapper.xml
  49. 0 157
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportHourlyCreativeStatisticMapper.xml
  50. 0 22
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportHourlyCreativeStatisticService.java
  51. 0 44
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportHourlyCreativeStatisticServiceImpl.java
  52. 243 0
      module-report/src/main/java/cn/com/ctop/bytedance/controller/BytedanceDailyReportTaskController.java
  53. 66 4
      module-report/src/main/java/cn/com/ctop/bytedance/controller/BytedanceReportController.java
  54. 243 0
      module-report/src/main/java/cn/com/ctop/bytedance/controller/BytedanceReportMaterialDailyController.java
  55. 73 0
      module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceDailyReportTask.java
  56. 448 0
      module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceReportMaterialDaily.java
  57. 17 0
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/BytedanceDailyReportTaskMapper.java
  58. 18 0
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/BytedanceReportMaterialDailyMapper.java
  59. 5 0
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/BytedanceDailyReportTaskMapper.xml
  60. 208 0
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/BytedanceReportMaterialDailyMapper.xml
  61. 4 5
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/MaterialReportMapper.xml
  62. 14 0
      module-report/src/main/java/cn/com/ctop/bytedance/service/IBytedanceDailyReportTaskService.java
  63. 14 0
      module-report/src/main/java/cn/com/ctop/bytedance/service/IBytedanceReportMaterialDailyService.java
  64. 9 0
      module-report/src/main/java/cn/com/ctop/bytedance/service/IBytedanceReportService.java
  65. 19 0
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/BytedanceDailyReportTaskServiceImpl.java
  66. 19 0
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/BytedanceReportMaterialDailyServiceImpl.java
  67. 580 4
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/BytedanceReportServiceImpl.java
  68. 0 1
      moudule-eureca/src/main/java/cn/com/ctop/eureca/server/ServerApplication.java
  69. 243 0
      performance-appraisal/src/main/java/cn/com/ctop/accountvideoquarterinfo/controller/AccountVideoQuarterInfoController.java
  70. 113 0
      performance-appraisal/src/main/java/cn/com/ctop/accountvideoquarterinfo/entity/AccountVideoQuarterInfo.java
  71. 17 0
      performance-appraisal/src/main/java/cn/com/ctop/accountvideoquarterinfo/mapper/AccountVideoQuarterInfoMapper.java
  72. 5 0
      performance-appraisal/src/main/java/cn/com/ctop/accountvideoquarterinfo/mapper/xml/AccountVideoQuarterInfoMapper.xml
  73. 14 0
      performance-appraisal/src/main/java/cn/com/ctop/accountvideoquarterinfo/service/IAccountVideoQuarterInfoService.java
  74. 19 0
      performance-appraisal/src/main/java/cn/com/ctop/accountvideoquarterinfo/service/impl/AccountVideoQuarterInfoServiceImpl.java
  75. 33 1
      performance-appraisal/src/main/java/cn/com/ctop/performanceappraisal/service/impl/PerformanceOptimizerServiceImpl.java
  76. 4 0
      performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/entity/VideoDTO.java
  77. 12 0
      performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/UserEfficientVideoMapMapper.java
  78. 118 15
      performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/xml/UserEfficientVideoMapMapper.xml

+ 5 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/JeecgOneGui.java

@@ -10,9 +10,11 @@ import org.jeecgframework.codegenerate.window.CodeWindow;
  */
 public class JeecgOneGui {
 
-	/** 详细使用手册: http://jeecg-boot.mydoc.io/?t=338140 */
+    /**
+     * 详细使用手册: http://jeecg-boot.mydoc.io/?t=338140
+     */
     public static void main(String[] args) {
-    	new CodeWindow().pack();
-	}
+        new CodeWindow().pack();
+    }
 
 }

+ 9 - 9
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AdvertiserController.java

@@ -122,7 +122,7 @@ public class AdvertiserController {
         Result<IPage<Advertiser>> result = new Result<IPage<Advertiser>>();
         String roleCode = materialReportMapper.getRoleCodeByUserId(advertiser.getUserId());
         String userId = advertiser.getUserId();
-        if ("admin".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "touTiaoOperationManager".equals(roleCode)) {
+        if ("admin".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || "sale".equals(roleCode) || "saleDirector".equals(roleCode)) {
             advertiser.setUserId(null);
         }
         QueryWrapper<Advertiser> queryWrapper = QueryGenerator.initQueryWrapper(advertiser, req.getParameterMap());
@@ -379,10 +379,10 @@ public class AdvertiserController {
         }
         SheetInfoVo totalSheetVo = advertiserService.getXxlStatisticInfo(projectId, systemType, null, "汇总表");
         sheets.add(totalSheetVo);
-        if(null == systemType){
-            List<SheetInfoVo>vos = advertiserService.getSystemTypeXxlStatisticInfo(projectId);
-            if(null!=vos&&vos.size()>0){
-                for(SheetInfoVo vo:vos){
+        if (null == systemType) {
+            List<SheetInfoVo> vos = advertiserService.getSystemTypeXxlStatisticInfo(projectId);
+            if (null != vos && vos.size() > 0) {
+                for (SheetInfoVo vo : vos) {
                     sheets.add(vo);
                 }
             }
@@ -414,10 +414,10 @@ public class AdvertiserController {
         //查询总的消耗信息
         SheetInfoVo totalSheetVo = advertiserService.getXxlStatisticInfo(projectId, systemType, null, "汇总表");
         sheets.add(totalSheetVo);
-        if(null == systemType){
-            List<SheetInfoVo>vos = advertiserService.getSystemTypeXxlStatisticInfo(projectId);
-            if(null!=vos&&vos.size()>0){
-                for(SheetInfoVo vo:vos){
+        if (null == systemType) {
+            List<SheetInfoVo> vos = advertiserService.getSystemTypeXxlStatisticInfo(projectId);
+            if (null != vos && vos.size() > 0) {
+                for (SheetInfoVo vo : vos) {
                     sheets.add(vo);
                 }
             }

+ 7 - 21
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ByteDanceAdvertiserPostController.java

@@ -28,7 +28,6 @@ import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
 import java.text.ParseException;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -53,6 +52,7 @@ public class ByteDanceAdvertiserPostController {
 
     /**
      * 1:获取广告主信息
+     *
      * @param accountId 本平台广告主id
      */
     @RequestMapping("/advertiser/info")
@@ -110,6 +110,7 @@ public class ByteDanceAdvertiserPostController {
 
     /**
      * 6:获取广告主广告预算信息
+     *
      * @param accountId 本平台广告主id
      */
     @RequestMapping("/advertiser/budget/get/")
@@ -119,6 +120,7 @@ public class ByteDanceAdvertiserPostController {
 
     /**
      * 7:获取广告主广告组信息
+     *
      * @param accountId 本平台广告主id
      */
     @RequestMapping("/advertiser/campaign/get")
@@ -138,6 +140,7 @@ public class ByteDanceAdvertiserPostController {
 
     /**
      * 8:获取广告主广告创意信息
+     *
      * @param accountId 本平台广告主id
      */
     @RequestMapping("/advertiser/creative/get")
@@ -147,6 +150,7 @@ public class ByteDanceAdvertiserPostController {
 
     /**
      * 9:修改广告创意信息状态
+     *
      * @param accountId 本平台广告主id
      */
     @RequestMapping("/advertiser/update/status/")
@@ -156,7 +160,8 @@ public class ByteDanceAdvertiserPostController {
 
     /**
      * 10:获取广告主广告创意素材信息
-     * @param accountId 本平台广告主id
+     *
+     * @param accountId   本平台广告主id
      * @param creativeIds 广告创意id
      */
     @RequestMapping("/advertiser/creative/material/read")
@@ -263,14 +268,6 @@ public class ByteDanceAdvertiserPostController {
         return result;
     }
 
-    @GetMapping("loadAllData")
-    public Map<String, Object> loadAllData() {
-        Map<String, Object> result = new HashMap<>();
-        List<CtopOauthToken> kuaishouTokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
-        kuaishouInterfaceService.loadAllKuaishouData(kuaishouTokens);
-        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS.getCode());
-        return result;
-    }
 
     @GetMapping("loadSingleData")
     public Map<String, Object> loadSingleData(Long accountId) {
@@ -289,17 +286,6 @@ public class ByteDanceAdvertiserPostController {
         return result;
     }
 
-    @GetMapping("loadData")
-    public Map<String, Object> loadData() {
-        Map<String, Object> result = new HashMap<>();
-        try {
-            kuaishouInterfaceService.loadData();
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS.getCode());
-        return result;
-    }
 
     @Autowired
     private ICtopOauthTokenService tokenService;

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

@@ -0,0 +1,248 @@
+package org.jeecg.modules.ctop.controller;
+
+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.aspect.annotation.AutoLog;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.ctop.entity.KuaiShouDefectMaterial;
+import org.jeecg.modules.ctop.service.IKuaiShouDefectMaterialService;
+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-04-15
+ */
+@Slf4j
+@Api(tags = "快手缺失素材")
+@RestController
+@RequestMapping("/ctop/kuaiShouDefectMaterial")
+public class KuaiShouDefectMaterialController {
+    @Autowired
+    private IKuaiShouDefectMaterialService kuaiShouDefectMaterialService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaiShouDefectMaterial
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "快手缺失素材-分页列表查询")
+    @ApiOperation(value = "快手缺失素材-分页列表查询", notes = "快手缺失素材-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaiShouDefectMaterial>> queryPageList(KuaiShouDefectMaterial kuaiShouDefectMaterial,
+                                                               @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                               @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                               HttpServletRequest req) {
+        Result<IPage<KuaiShouDefectMaterial>> result = new Result<IPage<KuaiShouDefectMaterial>>();
+        QueryWrapper<KuaiShouDefectMaterial> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouDefectMaterial, req.getParameterMap());
+        Page<KuaiShouDefectMaterial> page = new Page<KuaiShouDefectMaterial>(pageNo, pageSize);
+        IPage<KuaiShouDefectMaterial> pageList = kuaiShouDefectMaterialService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaiShouDefectMaterial
+     * @return
+     */
+    @AutoLog(value = "快手缺失素材-添加")
+    @ApiOperation(value = "快手缺失素材-添加", notes = "快手缺失素材-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaiShouDefectMaterial> add(@RequestBody KuaiShouDefectMaterial kuaiShouDefectMaterial) {
+        Result<KuaiShouDefectMaterial> result = new Result<KuaiShouDefectMaterial>();
+        try {
+            kuaiShouDefectMaterialService.save(kuaiShouDefectMaterial);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaiShouDefectMaterial
+     * @return
+     */
+    @AutoLog(value = "快手缺失素材-编辑")
+    @ApiOperation(value = "快手缺失素材-编辑", notes = "快手缺失素材-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaiShouDefectMaterial> edit(@RequestBody KuaiShouDefectMaterial kuaiShouDefectMaterial) {
+        Result<KuaiShouDefectMaterial> result = new Result<KuaiShouDefectMaterial>();
+        KuaiShouDefectMaterial kuaiShouDefectMaterialEntity = kuaiShouDefectMaterialService.getById(kuaiShouDefectMaterial.getId());
+        if (kuaiShouDefectMaterialEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaiShouDefectMaterialService.updateById(kuaiShouDefectMaterial);
+            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 {
+            kuaiShouDefectMaterialService.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<KuaiShouDefectMaterial> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaiShouDefectMaterial> result = new Result<KuaiShouDefectMaterial>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaiShouDefectMaterialService.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<KuaiShouDefectMaterial> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaiShouDefectMaterial> result = new Result<KuaiShouDefectMaterial>();
+        KuaiShouDefectMaterial kuaiShouDefectMaterial = kuaiShouDefectMaterialService.getById(id);
+        if (kuaiShouDefectMaterial == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaiShouDefectMaterial);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaiShouDefectMaterial> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaiShouDefectMaterial kuaiShouDefectMaterial = JSON.parseObject(deString, KuaiShouDefectMaterial.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouDefectMaterial, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaiShouDefectMaterial> pageList = kuaiShouDefectMaterialService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "快手缺失素材列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaiShouDefectMaterial.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<KuaiShouDefectMaterial> listKuaiShouDefectMaterials = ExcelImportUtil.importExcel(file.getInputStream(), KuaiShouDefectMaterial.class, params);
+                kuaiShouDefectMaterialService.saveBatch(listKuaiShouDefectMaterials);
+                return Result.ok("文件导入成功!数据行数:" + listKuaiShouDefectMaterials.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("文件导入失败!");
+    }
+
+}

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

@@ -118,6 +118,19 @@ public class MaterialAscriptionController {
         return result;
     }
 
+    @PutMapping(value = "/update")
+    public Result<MaterialAscription> update(@RequestBody MaterialAscription materialAscription) {
+        Result<MaterialAscription> result = new Result<>();
+        QueryWrapper<MaterialAscription> ascriptionQueryWrapper = new QueryWrapper<>();
+        ascriptionQueryWrapper.eq("material_id", materialAscription.getMaterialId());
+        boolean ok = materialAscriptionService.update(materialAscription, ascriptionQueryWrapper);
+        if (ok) {
+            result.success("修改成功!");
+        }
+        return result;
+    }
+
+
     /**
      * 通过id删除
      *

+ 47 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialImageInfoController.java

@@ -20,7 +20,9 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.ctop.service.IProjectMemberService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -37,6 +39,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
+import java.text.ParseException;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -59,6 +62,8 @@ public class MaterialImageInfoController {
     private IMaterialInfoService materialInfoService;
     @Autowired
     private MaterialInfoMapper materialInfoMapper;
+    @Autowired
+    private IProjectMemberService memberService;
 
 
     @ApiOperation(value = "截屏-分页列表查询", notes = "截屏-分页列表查询")
@@ -68,12 +73,52 @@ public class MaterialImageInfoController {
                                                      @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                      HttpServletRequest req) {
         Result<IPage<MaterialImageInfo>> result = new Result<IPage<MaterialImageInfo>>();
-        QueryWrapper<MaterialImageInfo> queryWrapper = QueryGenerator.initQueryWrapper(materialImageInfo, req.getParameterMap());
-        Page<MaterialImageInfo> page = new Page<MaterialImageInfo>(pageNo, pageSize);
+
+
+        QueryWrapper<MaterialImageInfo> queryWrapper = new QueryWrapper<>();
+        Object createTime = materialImageInfo.getCreateTime();
+        materialImageInfo.setCreateTime(null);
+        if (!Check.isNull(materialImageInfo.getUserId())) {
+            String roleCode = materialInfoService.getRoleCodeByUserId(materialImageInfo.getUserId());
+            if ("admin".equals(roleCode) || "operator".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "operationAssistant".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || "sale".equals(roleCode) || "saleDirector".equals(roleCode)) {
+                materialImageInfo.setUserId(null);
+                queryWrapper = QueryGenerator.initQueryWrapper(materialImageInfo, req.getParameterMap());
+            } else if ("designTeamLeader".equals(roleCode) || "planeLeader".equals(roleCode) || "plane".equals(roleCode) || "plan".equals(roleCode) || "shot".equals(roleCode)) {
+                String userId = materialImageInfo.getUserId();
+                materialImageInfo.setUserId(null);
+                queryWrapper = QueryGenerator.initQueryWrapper(materialImageInfo, req.getParameterMap());
+                if (Check.isNull(materialImageInfo.getProjectId())) {
+                    List<Long> projects = memberService.selectProjectsByUserId(userId);
+                    if (!Check.isNull(projects)) {
+                        queryWrapper.in("project_id", projects);
+                    } else {
+                        result.setSuccess(true);
+                        result.setResult(null);
+                        return result;
+                    }
+                }
+            } else {
+                queryWrapper = QueryGenerator.initQueryWrapper(materialImageInfo, req.getParameterMap());
+            }
+            if (!Check.isNull(createTime)) {
+                try {
+                    String dateString = DateUtils.getDateString(String.valueOf(createTime));
+                    Map<String, Object> map = DateUtils.getStartEndTime(dateString);
+                    queryWrapper.ge("create_time", map.get("start"));
+                    queryWrapper.lt("create_time", map.get("end"));
+                } catch (ParseException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        Page<MaterialImageInfo> page = new Page<>(pageNo, pageSize);
         IPage<MaterialImageInfo> pageList = MaterialImageInfoService.page(page, queryWrapper);
+
+
         result.setSuccess(true);
         result.setResult(pageList);
         return result;
+
     }
 
 

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

@@ -45,10 +45,7 @@ import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.text.ParseException;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 素材信息
@@ -180,7 +177,7 @@ public class MaterialInfoController {
         materialInfo.setCreateTime(null);
         if (!Check.isNull(materialInfo.getUserId())) {
             String roleCode = materialInfoService.getRoleCodeByUserId(materialInfo.getUserId());
-            if ("admin".equals(roleCode) || "operator".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "operationAssistant".equals(roleCode) || "touTiaoOperationManager".equals(roleCode)) {
+            if ("admin".equals(roleCode) || "operator".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "operationAssistant".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || "sale".equals(roleCode) || "saleDirector".equals(roleCode)) {
                 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)) {
@@ -496,4 +493,50 @@ public class MaterialInfoController {
         return Result.ok("文件导入失败!");
     }
 
+    @AutoLog(value = "获取有效素材")
+    @ApiOperation(value = "获取有效素材", notes = "获取有效素材")
+    @GetMapping(value = "/effiMaterialInfo")
+    public Result<IPage<MaterialInfo>> effiMaterialInfo(MaterialInfo materialInfo,
+                                                        @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                        HttpServletRequest req) {
+        Result<IPage<MaterialInfo>> result = new Result<>();
+        QueryWrapper<MaterialInfo> queryWrapper = new QueryWrapper<>();
+
+        List<String> effiList = materialInfoService.getEffiCode();
+        Object createTime = materialInfo.getCreateTime();
+        materialInfo.setCreateTime(null);
+        queryWrapper.in("code", effiList);
+        queryWrapper.groupBy("code");
+        //queryWrapper = QueryGenerator.initQueryWrapper(materialInfo, req.getParameterMap());
+
+        Page<MaterialInfo> page = new Page<>(pageNo, pageSize);
+        IPage<MaterialInfo> pageList = materialInfoService.page(page, queryWrapper);
+
+        List<MaterialInfo> materialInfoList = pageList.getRecords();
+        if (materialInfoList.size() != 0) {
+            for (MaterialInfo material : materialInfoList) {
+                //判断是否已经同步到快手平台
+                Integer kuaishouMaterialUpCount = materialInfoService.getKuaishouUpVideoCount(material.getCode());
+                if (kuaishouMaterialUpCount > 0) {
+                    material.setKuaishouVideoIsUp(1);
+                } else {
+                    material.setKuaishouVideoIsUp(0);
+                }
+                //判断是否已经同步到抖音平台
+                Integer toutiaoMaterialUpCount = materialInfoService.getToutiaoUpVideoCount(material.getCode());
+                if (toutiaoMaterialUpCount > 0) {
+                    material.setToutiaoVideoIsUp(1);
+                } else {
+                    material.setToutiaoVideoIsUp(0);
+                }
+            }
+        }
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+
+
 }

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java

@@ -118,7 +118,7 @@ public class ProjectController {
         String roleCode = materialReportMapper.getRoleCodeByUserId(userId);
         QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
         List<Project> projects = new ArrayList<>();
-        if (!"admin".equals(roleCode)) {
+        if (!"admin".equals(roleCode) && !"sale".equals(roleCode) && !"saleDirector".equals(roleCode)) {
             if ("designTeamLeader".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "planeLeader".equals(roleCode)) {
                 QueryWrapper<ProjectMember> memberQueryWrapper = new QueryWrapper<>();
                 memberQueryWrapper.eq("user_id", userId);
@@ -198,7 +198,7 @@ public class ProjectController {
         }
 
         String roleCode = materialReportMapper.getRoleCodeByUserId(sysUser.getId());
-        if (!"admin".equals(roleCode)) {
+        if (!"admin".equals(roleCode) && "sale".equals(roleCode) && "saleDirector".equals(roleCode)) {
             queryWrapper.eq("user_id", sysUser.getId());
             queryWrapper.orderByDesc("create_time");
         }

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

@@ -106,9 +106,8 @@ public class ProjectMemberController {
         try {
             QueryWrapper<ProjectMember> queryWrapper = new QueryWrapper<>();
             String roleCode = materialReportMapper.getRoleCodeByUserId(userId);
-            if (!"admin".equals(roleCode)) {
+            if (!"admin".equals(roleCode) && !"sale".equals(roleCode) && !"saleDirector".equals(roleCode)) {
                 queryWrapper.eq("user_id", userId);
-
             }
             queryWrapper.groupBy("project_id");
             queryWrapper.orderByDesc("create_time");

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

@@ -13,18 +13,14 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
-import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyReportTaskService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
-import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCreativeMapper;
-import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCreativeStatisticMapper;
 import cn.com.ctop.toutiao.service.IByteDanceAdvertiserDataService;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.util.DateUtils;
@@ -98,19 +94,13 @@ public class TestController {
             String startDate = DateUtils.addMonth(endDateStr, -6);
             QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
             tokenQueryWrapper.eq("media_id", 2);
-            System.err.println(startDate);
-            System.err.println(endDateStr);
-
-
-            //List<CtopOauthToken> ctopOauthTokens = oauthTokenMapper.selectList(tokenQueryWrapper);
-            //if (!Check.isNull(ctopOauthTokens)) {
-            //for (CtopOauthToken token : ctopOauthTokens) {
-            //if ("3768019".equals(token.getAccountId())) {
-            historyReportTaskService.createTask(3768019L, "0fb5f7dadd26b265979b1a8956950008", startDate, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
+            List<CtopOauthToken> ctopOauthTokens = oauthTokenMapper.selectList(tokenQueryWrapper);
+            if (!Check.isNull(ctopOauthTokens)) {
+                for (CtopOauthToken token : ctopOauthTokens) {
+                    historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), startDate, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
+                }
 
-            //}
-            //}
-            //}
+            }
         } catch (Exception e) {
             e.printStackTrace();
             result.setSuccess(false);
@@ -127,13 +117,8 @@ public class TestController {
             String startDate = DateUtils.addMonth(endDateStr, -6);
             QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
             tokenQueryWrapper.eq("media_id", 2);
-            System.err.println(startDate);
-            System.err.println(endDateStr);
-
-
             historyReportTaskService.getTaskList();
 
-
         } catch (Exception e) {
             e.printStackTrace();
             result.setSuccess(false);
@@ -174,26 +159,7 @@ public class TestController {
         return "Success";
     }
 
-    static ExecutorService executorService = Executors.newFixedThreadPool(5);
-
-    @GetMapping(value = "/getVideoAndImage")
-    public String getVideoAndImage() {
-        QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
-        tokenQueryWrapper.eq("media_id", 2);
-        List<CtopOauthToken> ctopOauthTokens = tokenMapper.selectList(tokenQueryWrapper);
-        for (CtopOauthToken token : ctopOauthTokens) {
-            executorService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    kuaishouInterfaceService.getVideoList2(token, null, null, 1);
-                    //kuaishouInterfaceService.getImageList2(token, null, null, 1);
-                    //   kuaishouInterfaceService.getCreativeList2(token, null, null, 1);
-                }
-            });
-
-        }
-        return "Success";
-    }
+    static ExecutorService executorService = Executors.newFixedThreadPool(10);
 
 
     @GetMapping(value = "/gerCreative")
@@ -206,7 +172,6 @@ public class TestController {
                 @Override
                 public void run() {
                     try {
-                        System.err.println("获取创意,accountId:" + token.getAccountId());
                         kuaishouInterfaceService.getCreativeList(token, null, null);
                         //  kuaishouInterfaceService.getVideoList2(token, null, null,1);
                         //3: 获取图片信息数据
@@ -246,118 +211,35 @@ public class TestController {
     @Autowired
     private IKuaiShouCampaignService campaignService;
 
-    @GetMapping(value = "/getCreativeReportByAccount")
-    public void gerCreativeReportByAccount(Long accountId, String startDateStr, String endDateStr) {
-        Thread thread = new Thread() {
-            @SneakyThrows
-            @Override
-            public void run() {
-                SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
-                Date startDate = sim.parse(startDateStr);
-                Date endDate = sim.parse(endDateStr);
-                //1:查询当日数据
-                //executorService = Executors.newFixedThreadPool(3);
-                QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
-                oauthTokenQueryWrapper.eq("media_id", 2);
-                oauthTokenQueryWrapper.eq("account_id", accountId);
-                CtopOauthToken ctopOauthToken = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
-
-                System.err.println("创意报表accountId:" + ctopOauthToken.getAccountId());
-                QueryWrapper<KuaiShouCampaign> campaignQueryWrapper = new QueryWrapper<>();
-                campaignQueryWrapper.eq("account_id", accountId);
-                List<KuaiShouCampaign> list = campaignService.list(campaignQueryWrapper);
-                if (!Check.isNull(list)) {
-                    for (KuaiShouCampaign campaign : list) {
-                        kuaishouInterfaceService.getAdvertiserCreativeReportDailyV2(campaign.getCampaignId(), ctopOauthToken, startDate, endDate);
 
+    @GetMapping("loadBytedanceHistoryData")
+    public Map<String, Object> loadBytedanceHistoryData() {
+        Map<String, Object> result = new HashMap<>();
+        //1:查询所有头条的token数据
+        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+        if (null != tokens && tokens.size() > 0) {
+            tokens.forEach(token -> {
+                //拉取往期数据
+                executorService.submit(new Runnable() {
+                    @Override
+                    public void run() {
+                        reportService.loadBytedanceHistoryData(token);
                     }
-
-                }
-
-
-            }
-        };
-        thread.start();
+                });
+            });
+        }
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+        return result;
     }
 
 
     @Autowired
     private IUserAllocationService userAllocationService;
-    @Autowired
-    private KuaishouReportDailyCreativeStatisticMapper reportDailyCreativeStatisticMapper;
-
-
-    @Autowired
-    private KuaishouReportDailyCreativeMapper reportDailyCreativeMapper;
-
-    @GetMapping(value = "/getCreativeReportByProjectId")
-    public void getCreativeReportByProjectId(Long projectId) {
 
-        try {
-            Map<String, Object> deleteMap = new HashMap<>();
-            String date = DateUtils.getDate("yyyy-MM-dd");
-            String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", date, -1);
-            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-            Date endDate = simpleDateFormat.parse(anotherDay);
-            QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
-            userAllocationQueryWrapper.eq("project_id", projectId);
-            List<UserAllocation> list = userAllocationService.list(userAllocationQueryWrapper);
-            if (!Check.isNull(list)) {
-                for (UserAllocation allocation : list) {
-                    executorService.submit(new Runnable() {
-                        @Override
-                        public void run() {
-                            if (!Check.isNull(allocation)) {
-                                log.info("账号id:{}", allocation.getAccountId());
-
-                                QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
-                                oauthTokenQueryWrapper.eq("media_id", 2);
-                                oauthTokenQueryWrapper.eq("account_id", allocation.getAccountId());
-                                CtopOauthToken ctopOauthToken = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
-                                if (!Check.isNull(ctopOauthToken)) {
-                                    deleteMap.put("account_id", allocation.getAccountId());
-                                    deleteMap.put("stat_date", anotherDay);
-                                    //   reportDailyCreativeStatisticMapper.deleteByMap(deleteMap);
-                                    //  reportDailyCreativeMapper.deleteByMap(deleteMap);
-
-                                    // 1.计划数据
-                                    log.info("获取计划,账号id:{}", allocation.getAccountId());
-                                    kuaishouInterfaceService.getCampaignList(ctopOauthToken, null, null);
-                                    // 2:广告组数据
-                                    log.info("获取广告组,账号id:{}", allocation.getAccountId());
-                                    kuaishouInterfaceService.getGroupList(ctopOauthToken, null, null);
-                                    // 3:创意数据
-                                    log.info("获取创意,账号id:{}", allocation.getAccountId());
-                                    kuaishouInterfaceService.getCreativeList(ctopOauthToken, null, null);
-
-                                    QueryWrapper<KuaiShouCampaign> campaignQueryWrapper = new QueryWrapper<>();
-                                    campaignQueryWrapper.eq("account_id", ctopOauthToken.getAccountId());
-                                    log.info("获取创意报表,账号id:{}", allocation.getAccountId());
-                                    List<KuaiShouCampaign> campaigns = campaignService.list(campaignQueryWrapper);
-                                    if (!Check.isNull(campaigns)) {
-                                        for (KuaiShouCampaign campaign : campaigns) {
-                                            kuaishouInterfaceService.getAdvertiserCreativeReportDailyV2(campaign.getCampaignId(), ctopOauthToken, endDate, endDate);
-                                        }
-                                    }
-                                }
-                            }
-
-                        }
-                    });
-
-
-                }
-            }
-        } catch (ParseException e) {
-            e.printStackTrace();
-        }
-
-    }
 
     public static void main(String[] args) throws ParseException {
         String date = DateUtils.getDate("yyyy-MM-dd");
         String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", date, -1);
-        System.err.println(anotherDay);
     }
 
 
@@ -369,11 +251,9 @@ public class TestController {
         oauthTokenQueryWrapper.last("limit 1");
         CtopOauthToken token = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
         try {
-            System.err.println("获取计划,广告组:" + accountId);
             kuaishouInterfaceService.getCampaignList(token, null, null);
             //1:获取全量广告组数据
             kuaishouInterfaceService.getGroupList(token, null, null);
-            System.err.println("获取计划,广告组:" + accountId);
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -391,29 +271,7 @@ public class TestController {
         CtopOauthToken token = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
 
         try {
-            System.err.println("获取创意,accountId:" + token.getAccountId());
             kuaishouInterfaceService.getCreativeList(token, null, null);
-            System.err.println("获取创意结束,accountId:" + token.getAccountId());
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-
-    }
-
-
-    @GetMapping(value = "/getVideo")
-    public void getVideo(Long accountId) {
-        QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
-        oauthTokenQueryWrapper.eq("media_id", 2);
-        oauthTokenQueryWrapper.eq("account_id", accountId);
-        oauthTokenQueryWrapper.last("limit 1");
-        CtopOauthToken token = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
-
-        try {
-            System.err.println("获取视频,accountId:" + token.getAccountId());
-            kuaishouInterfaceService.getVideoList(token, null, null);
-            System.err.println("获取视频结束,accountId:" + token.getAccountId());
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -422,40 +280,6 @@ public class TestController {
     }
 
 
-    @GetMapping(value = "/gerCreativeReportByAccount")
-    public void gerCreativeReportByAccount(Long accountId, String startDateStr, String endDateStr, QueryWrapper<CtopOauthToken> account_id) {
-        Thread thread = new Thread() {
-            @SneakyThrows
-            @Override
-            public void run() {
-                SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
-                Date startDate = sim.parse(startDateStr);
-                Date endDate = sim.parse(endDateStr);
-                //1:查询当日数据
-                //executorService = Executors.newFixedThreadPool(3);
-                QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
-                oauthTokenQueryWrapper.eq("media_id", 2);
-                oauthTokenQueryWrapper.eq("account_id", accountId);
-                CtopOauthToken ctopOauthToken = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
-                System.err.println("创意报表accountId:" + ctopOauthToken.getAccountId());
-
-
-                QueryWrapper<KuaiShouCampaign> campaignQueryWrapper = new QueryWrapper<>();
-                campaignQueryWrapper.eq("account_id", ctopOauthToken.getAccountId());
-
-                List<KuaiShouCampaign> campaigns = campaignService.list(campaignQueryWrapper);
-                if (!Check.isNull(campaigns)) {
-                    for (KuaiShouCampaign campaign : campaigns) {
-                        kuaishouInterfaceService.getAdvertiserCreativeReportDailyV2(campaign.getCampaignId(), ctopOauthToken, endDate, endDate);
-                    }
-                }
-
-            }
-        };
-        thread.start();
-    }
-
-
     @Autowired
     private IBytedancePlanDailyReportService planDailyReportService;
     @Autowired
@@ -472,61 +296,60 @@ public class TestController {
             e.printStackTrace();
         }
         //1:查询当日数据
-        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
-        if (null == tokens || tokens.size() <= 0) {
-            log.info("定时获取头条数据异常:为获取到可用的token");
+        QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("project_id", 215);
+        List<UserAllocation> allocations = userAllocationService.list(queryWrapper);
+        if (null == allocations || allocations.size() <= 0) {
+            log.info("定时获取头条数据异常:获取用户信息失败");
         }
         Date finalGetDate = getDate;
-        tokens.forEach(token -> {
+
+        allocations.forEach(allocation -> {
             //3:获取广告计划信息数据
+            CtopOauthToken token = oauthTokenMapper.selectByAccountId(allocation.getAccountId());
             reportService.getAdvertiserPlanReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
         });
 
         //清洗关于作业帮数据
         //1:查询作业帮相关的用户数据
-        QueryWrapper<UserAllocation> wrapper = new QueryWrapper<>();
-        wrapper.eq("project_id", 215);
-        List<UserAllocation> allocations = userAllocationService.list(wrapper);
-        if (null != allocations && allocations.size() > 0) {
-            allocations.forEach(allocation -> {
-                //根据accountId和时间,查询相关的日报表信息
-                QueryWrapper<BytedancePlanDailyReport> queryWrapper = new QueryWrapper<>();
-                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-                String dateString = dateFormat.format(finalGetDate) + " 00:00:00";
-                queryWrapper.eq("advertiser_id", allocation.getAccountId())
-                        .eq("stat_datetime", dateString)
-                ;
-                List<BytedancePlanDailyReport> bytedancePlanDailyReports = planDailyReportService.list(queryWrapper);
-                if (null != bytedancePlanDailyReports && bytedancePlanDailyReports.size() > 0) {
-                    bytedancePlanDailyReports.forEach(report -> {
-                        String adName = report.getAdName();
-                        String[] tags = adName.split("-");
-                        report.setAdsense(tags[1]);
-                        report.setPlanCode(tags[2]);
-                        String materialName = tags[3];
-                        report.setMaterialName(materialName);
-                        if (materialName.contains("其他")) {
-                            report.setMaterialType("其他");
-                        } else if (materialName.contains("图片轮播")) {
-                            report.setMaterialType("图片轮播");
-                        } else if (materialName.contains("大字报")) {
-                            report.setMaterialType("大字报");
-                        } else if (materialName.contains("文字动画")) {
-                            report.setMaterialType("文字动画");
-                        } else if (materialName.contains("采访形式")) {
-                            report.setMaterialType("采访形式");
-                        } else if (materialName.contains("剧情")) {
-                            report.setMaterialType("剧情");
-                        } else if (materialName.contains("口播")) {
-                            report.setMaterialType("口播");
-                        } else {
-                            report.setMaterialType("其他");
-                        }
-                        planDailyReportService.updateById(report);
-                    });
-                }
-            });
-        }
+        allocations.forEach(allocation -> {
+            //根据accountId和时间,查询相关的日报表信息
+            QueryWrapper<BytedancePlanDailyReport> reportQueryWrapper = new QueryWrapper<>();
+            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            String dateString = dateFormat.format(finalGetDate) + " 00:00:00";
+            queryWrapper.eq("advertiser_id", allocation.getAccountId())
+                    .eq("stat_datetime", dateString)
+            ;
+            List<BytedancePlanDailyReport> bytedancePlanDailyReports = planDailyReportService.list(reportQueryWrapper);
+            if (null != bytedancePlanDailyReports && bytedancePlanDailyReports.size() > 0) {
+                bytedancePlanDailyReports.forEach(report -> {
+                    String adName = report.getAdName();
+                    String[] tags = adName.split("-");
+                    report.setAdsense(tags[1]);
+                    report.setPlanCode(tags[2]);
+                    String materialName = tags[3];
+                    report.setMaterialName(materialName);
+                    if (materialName.contains("其他")) {
+                        report.setMaterialType("其他");
+                    } else if (materialName.contains("图片轮播")) {
+                        report.setMaterialType("图片轮播");
+                    } else if (materialName.contains("大字报")) {
+                        report.setMaterialType("大字报");
+                    } else if (materialName.contains("文字动画")) {
+                        report.setMaterialType("文字动画");
+                    } else if (materialName.contains("采访形式")) {
+                        report.setMaterialType("采访形式");
+                    } else if (materialName.contains("剧情")) {
+                        report.setMaterialType("剧情");
+                    } else if (materialName.contains("口播")) {
+                        report.setMaterialType("口播");
+                    } else {
+                        report.setMaterialType("其他");
+                    }
+                    planDailyReportService.updateById(report);
+                });
+            }
+        });
         ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
         return result;
     }
@@ -818,7 +641,6 @@ public class TestController {
             executorService.submit(new Runnable() {
                 @Override
                 public void run() {
-                    System.err.println(signature);
                     cleanMaterialService.calculationReport(signature);
                 }
             });
@@ -847,7 +669,6 @@ public class TestController {
                     } catch (ParseException e) {
                         e.printStackTrace();
                     }
-                    System.err.println("获取广告主报表,accountId:" + token.getAccountId());
                     kuaishouInterfaceService.getAdvertiserReportDaily(token, startDate, endDate);
 
                     Thread.sleep(1 * 200);
@@ -858,4 +679,65 @@ public class TestController {
             }
         });
     }
+
+
+    @GetMapping(value = "/getAllCreativeList")
+    public void getAllCreativeList() {
+
+        try {
+
+
+            QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
+            oauthTokenQueryWrapper.eq("media_id", 2);
+            List<CtopOauthToken> ctopOauthTokens = oauthTokenMapper.selectList(oauthTokenQueryWrapper);
+
+            if (!Check.isNull(ctopOauthTokens)) {
+                for (CtopOauthToken token : ctopOauthTokens) {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            if (!Check.isNull(token)) {
+                                log.info("获取创意,账号id:{}", token.getAccountId());
+                                kuaishouInterfaceService.getCreativeList(token, null, null);
+                            }
+                        }
+                    });
+
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+
+    @GetMapping(value = "/getAllGroupList")
+    public void getAllGroupList() {
+
+        try {
+
+            QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
+            oauthTokenQueryWrapper.eq("media_id", 2);
+            List<CtopOauthToken> ctopOauthTokens = oauthTokenMapper.selectList(oauthTokenQueryWrapper);
+            if (!Check.isNull(ctopOauthTokens)) {
+                for (CtopOauthToken token : ctopOauthTokens) {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            if (!Check.isNull(token)) {
+                                log.info("获取组,账号id:{}", token.getAccountId());
+                                kuaishouInterfaceService.getGroupList(token, null, null);
+                            }
+                        }
+                    });
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+
 }

+ 92 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/KuaiShouDefectMaterial.java

@@ -0,0 +1,92 @@
+package org.jeecg.modules.ctop.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+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 org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 快手缺失素材
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-04-15
+ */
+@Data
+@TableName("ctop_kuaishou_defect_material")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_defect_material对象", description = "快手缺失素材")
+public class KuaiShouDefectMaterial {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Integer id;
+    /**
+     * md5
+     */
+    @Excel(name = "md5", width = 15)
+    @ApiModelProperty(value = "md5")
+    private String signature;
+    /**
+     * 花费(元)
+     */
+    @Excel(name = "花费(元)", width = 15)
+    @ApiModelProperty(value = "花费(元)")
+    private java.math.BigDecimal charge;
+    /**
+     * url
+     */
+    @Excel(name = "url", width = 15)
+    @ApiModelProperty(value = "url")
+    private String url;
+    /**
+     * 项目
+     */
+    @Excel(name = "项目", width = 15)
+    @ApiModelProperty(value = "项目")
+    private Long projectId;
+    /**
+     * 开始时间
+     */
+    @Excel(name = "开始时间", width = 15)
+    @ApiModelProperty(value = "开始时间")
+    private String startDate;
+    /**
+     * 结束时间
+     */
+    @Excel(name = "结束时间", width = 15)
+    @ApiModelProperty(value = "结束时间")
+    private String endDate;
+
+    private String accountIds;
+
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

+ 6 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceAdvertiserHourlyReportLoadJob.java

@@ -35,9 +35,6 @@ public class BytedanceAdvertiserHourlyReportLoadJob implements Job {
         Date getDate = new Date();
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
         String hour = simpleDateFormat.format(getDate);
-        if (null != hour && "00".equals(hour)) {
-            getDate = DateUtils.addDay(getDate, -1);
-        }
         //1:查询当日数据
         List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
         if (null == tokens || tokens.size() <= 0) {
@@ -45,13 +42,16 @@ public class BytedanceAdvertiserHourlyReportLoadJob implements Job {
             return;
         }
         executorService = Executors.newFixedThreadPool(4);
-        Date finalGetDate = getDate;
         tokens.forEach(token -> {
             executorService.submit(new Runnable() {
                 @Override
                 public void run() {
-                    //获取广告主信息数据
-                    reportService.getAdvertiserReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+                    if (null != hour && "00".equals(hour)) {
+                        Date  finalGetDate = DateUtils.addDay(getDate, -1);
+                        //获取广告主信息数据
+                        reportService.getAdvertiserReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+                    }
+                    reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
                 }
 
             });

+ 6 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceCreativeHourlyReportLoadJob.java

@@ -35,9 +35,6 @@ public class BytedanceCreativeHourlyReportLoadJob implements Job {
         Date getDate = new Date();
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
         String hour = simpleDateFormat.format(getDate);
-        if (null != hour && "00".equals(hour)) {
-            getDate = DateUtils.addDay(getDate, -1);
-        }
         //1:查询当日数据
         List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
         if (null == tokens || tokens.size() <= 0) {
@@ -45,13 +42,16 @@ public class BytedanceCreativeHourlyReportLoadJob implements Job {
             return;
         }
         executorService = Executors.newFixedThreadPool(4);
-        Date finalGetDate = getDate;
         tokens.forEach(token -> {
             executorService.submit(new Runnable() {
                 @Override
                 public void run() {
-                    //获取广告创意信息数据
-                    reportService.getAdvertiserCreativeReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+                    if (null != hour && "00".equals(hour)) {
+                        Date  finalGetDate = DateUtils.addDay(getDate, -1);
+                        //获取广告创意信息数据
+                        reportService.getAdvertiserCreativeReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+                    }
+                    reportService.getAdvertiserCreativeReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
                 }
 
             });

+ 5 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedancePlanHourlyReportLoadJob.java

@@ -37,12 +37,8 @@ public class BytedancePlanHourlyReportLoadJob implements Job {
         Date getDate = new Date();
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
         String hour = simpleDateFormat.format(getDate);
-        if (null != hour && "00".equals(hour)) {
-            getDate = DateUtils.addDay(getDate, -1);
-        }
         //1:查询当日计划时报数据
         List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
-        Date finalGetDate = getDate;
         executorService = Executors.newFixedThreadPool(5);
         countDownLatch = new CountDownLatch(tokens.size());
         tokens.forEach(token -> {
@@ -50,7 +46,11 @@ public class BytedancePlanHourlyReportLoadJob implements Job {
                 @Override
                 public void run() {
                     try {
-                        reportService.getAdvertiserPlanReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+                        if (null != hour && "00".equals(hour)) {
+                            Date  finalGetDate = DateUtils.addDay(getDate, -1);
+                            reportService.getAdvertiserPlanReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+                        }
+                        reportService.getAdvertiserPlanReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
                     } catch (Exception e) {
                         e.printStackTrace();
                     } finally {

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

@@ -1,40 +0,0 @@
-package org.jeecg.modules.ctop.job;
-
-import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyCreativeStatisticService;
-import org.jeecg.common.util.DateUtils;
-import org.quartz.Job;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
-import org.springframework.beans.factory.annotation.Autowired;
-
-/**
- * 出价预警
- */
-public class DeleteCreativeStaticJob implements Job {
-    @Autowired
-    private IKuaishouReportHourlyCreativeStatisticService reportHourlyCreativeStatisticService;
-
-    /**
-     * 定时删除数据
-     *
-     * @param jobExecutionContext
-     * @throws JobExecutionException
-     */
-    @Override
-    public void execute(JobExecutionContext jobExecutionContext) {
-        Thread thread = new Thread() {
-            @Override
-            public void run() {
-                try {
-                    String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-                    String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -2);
-                    reportHourlyCreativeStatisticService.deleteHourlyReportByStatDate(anotherDay);
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
-            }
-        };
-        thread.start();
-    }
-
-}

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

@@ -33,8 +33,6 @@ public class KuaishouDailyAccountReportLoadJob implements Job {
         Thread thread = new Thread() {
             @Override
             public void run() {
-                Date deleteDate = DateUtils.addDay(new Date(), -2);
-                kuaishouInterfaceService.deleteHourlyReport(deleteDate);
                 Date getDate = DateUtils.addDay(new Date(), -1);
                 //1:查询当日数据
                 List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();

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

@@ -2,7 +2,6 @@ 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.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
@@ -34,8 +33,6 @@ public class KuaishouDailyCampaignReportLoadJob implements Job {
         Thread thread = new Thread() {
             @Override
             public void run() {
-                Date deleteDate = DateUtils.addDay(new Date(), -2);
-                kuaishouInterfaceService.deleteHourlyReport(deleteDate);
                 Date getDate = DateUtils.addDay(new Date(), -1);
                 //1:查询当日数据
                 List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
@@ -50,7 +47,6 @@ public class KuaishouDailyCampaignReportLoadJob implements Job {
                         public void run() {
                             //获取广告计划信息数据
                             kuaishouInterfaceService.getAdvertiserCampaignReportDaily(token, getDate, getDate);
-
                         }
                     });
                 });

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

@@ -3,7 +3,6 @@ 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.common.module.utils.Check;
-import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import com.alibaba.fastjson.JSONArray;
@@ -41,8 +40,6 @@ public class KuaishouDailyCreativeReportLoadJob implements Job {
         Thread thread = new Thread() {
             @Override
             public void run() {
-                Date deleteDate = DateUtils.addDay(new Date(), -2);
-                kuaishouInterfaceService.deleteHourlyReport(deleteDate);
                 Date getDate = DateUtils.addDay(new Date(), -1);
                 //1:查询当日数据
                 executorService = Executors.newFixedThreadPool(4);

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

@@ -2,7 +2,6 @@ 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.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
@@ -34,8 +33,6 @@ public class KuaishouDailyGroupReportLoadJob implements Job {
         Thread thread = new Thread() {
             @Override
             public void run() {
-                Date deleteDate = DateUtils.addDay(new Date(), -2);
-                kuaishouInterfaceService.deleteHourlyReport(deleteDate);
                 Date getDate = DateUtils.addDay(new Date(), -1);
                 //1:查询当日数据
                 List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();

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

@@ -2,7 +2,6 @@ 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.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
@@ -76,9 +75,6 @@ public class KuaishouHourlyCreativeReportLoadJob implements Job {
                     e.printStackTrace();
                 }
                 executorService.shutdown();
-                for (CtopOauthToken token : tokens) {
-                    kuaishouInterfaceService.updateCreativeReportHourlyStatistic(token, getDate);
-                }
             }
 
         };

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

@@ -0,0 +1,59 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.bytedance.service.IBytedanceReportService;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Slf4j
+public class ToutiaoMaterialsLoadJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+
+    static ExecutorService executorService = null;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                //增加接口的开始和结束日期
+                String startDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -1));
+                String endDate = startDate;
+                //获取头条token数据
+                List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
+                executorService = Executors.newFixedThreadPool(8);
+                tokens.forEach(token -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+                                //获取头条素材报表数据
+                                bytedanceReportService.bytedanceMaterialReport(token,startDate,endDate);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            } finally {
+                            }
+                        }
+                    });
+                });
+                log.info("头条素材数据同步完成,"+ "开始时间:" + startDate + ",结束时间:" + endDate);
+            }
+        };
+        thread.start();
+
+    }
+}

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

@@ -0,0 +1,15 @@
+package org.jeecg.modules.ctop.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.ctop.entity.KuaiShouDefectMaterial;
+
+/**
+ * 快手缺失素材
+ *
+ * @author: jeecg-boot
+ * @date: 2020-04-15
+ * @cersion: V1.0
+ */
+public interface KuaiShouDefectMaterialMapper extends BaseMapper<KuaiShouDefectMaterial> {
+
+}

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/KuaiShouDefectMaterialMapper.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.ctop.mapper.KuaiShouDefectMaterialMapper">
+
+</mapper>

+ 16 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IKuaiShouDefectMaterialService.java

@@ -0,0 +1,16 @@
+package org.jeecg.modules.ctop.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.ctop.entity.KuaiShouDefectMaterial;
+
+/**
+ * 快手缺失素材
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-04-15
+ */
+public interface IKuaiShouDefectMaterialService extends IService<KuaiShouDefectMaterial> {
+    void getDefectVideo(String startDate, String endDate);
+
+}

+ 0 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BidWarningServiceImpl.java

@@ -110,7 +110,6 @@ public class BidWarningServiceImpl implements IBidWarningService {
         String createTime = DateUtils.getNowDate("yyyy-MM-dd");
         Integer count = mailLogMapper.selectCountByAccountIdAndDate(accountId, createTime, 1);
         StringBuilder text = new StringBuilder();
-
         String s = "";
         for (int i = 0; i < unitWarning.size(); i++) {
             s += unitWarning.get(i) + "," + "<br/>";

+ 90 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/KuaiShouDefectMaterialServiceImpl.java

@@ -0,0 +1,90 @@
+package org.jeecg.modules.ctop.service.impl;
+
+import cn.com.ctop.common.module.entity.MaterialInfo;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.service.IMaterialInfoService;
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCreativeMapper;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.ctop.entity.KuaiShouDefectMaterial;
+import org.jeecg.modules.ctop.mapper.KuaiShouDefectMaterialMapper;
+import org.jeecg.modules.ctop.service.IKuaiShouDefectMaterialService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 快手缺失素材
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-04-15
+ */
+@Slf4j
+@Service
+public class KuaiShouDefectMaterialServiceImpl extends ServiceImpl<KuaiShouDefectMaterialMapper, KuaiShouDefectMaterial> implements IKuaiShouDefectMaterialService {
+    @Autowired
+    private KuaishouReportDailyCreativeMapper creativeMapper;
+    @Autowired
+    private IMaterialInfoService materialInfoService;
+    @Autowired
+    private IKuaiShouVideoGetService videoGetService;
+    @Autowired
+    private IUserAllocationService userAllocationService;
+
+
+    @Override
+    public void getDefectVideo(String startDate, String endDate) {
+
+        List<JSONObject> list = creativeMapper.selectCodeByDate(startDate, endDate);
+        if (!Check.isNull(list)) {
+            for (int i = 0; i < list.size(); i++) {
+
+                JSONObject codeJson = list.get(i);
+                // charge signature
+                String signature = codeJson.getString("signature");
+                if (!Check.isNull(signature)) {
+                    QueryWrapper<MaterialInfo> materialInfoQueryWrapper = new QueryWrapper<>();
+                    materialInfoQueryWrapper.eq("code", signature);
+                    materialInfoQueryWrapper.last("limit 1");
+                    MaterialInfo materialInfo = materialInfoService.getOne(materialInfoQueryWrapper);
+                    if (!Check.isNull(materialInfo)) {
+                        continue;
+                    }
+                    KuaiShouDefectMaterial defectMaterial = new KuaiShouDefectMaterial();
+                    defectMaterial.setCharge(codeJson.getBigDecimal("charge"));
+                    defectMaterial.setAccountIds(codeJson.getString("accountId"));
+                    defectMaterial.setSignature(signature);
+                    defectMaterial.setStartDate(startDate);
+                    defectMaterial.setEndDate(endDate);
+                    QueryWrapper<KuaiShouVideoGet> videoGetQueryWrapper = new QueryWrapper<>();
+                    videoGetQueryWrapper.eq("signature", signature);
+                    videoGetQueryWrapper.last("limit 1");
+                    KuaiShouVideoGet videoGet = videoGetService.getOne(videoGetQueryWrapper);
+                    if (Check.isNull(videoGet)) {
+                        continue;
+                    }
+                    defectMaterial.setUrl(videoGet.getUrl());
+                    QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
+                    userAllocationQueryWrapper.eq("account_id", videoGet.getAccountId());
+                    userAllocationQueryWrapper.last("limit 1");
+                    UserAllocation userAllocation = userAllocationService.getOne(userAllocationQueryWrapper);
+                    if (!Check.isNull(userAllocation)) {
+                        defectMaterial.setProjectId(userAllocation.getProjectId());
+                    }
+                    this.save(defectMaterial);
+
+                }
+            }
+
+        }
+
+    }
+}

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

@@ -758,4 +758,23 @@ public class PerformanceController2 {
         return result;
     }
 
+    @AutoLog(value = "绩效-获取快手、头条下各账户下视频的季度消耗")
+    @ApiOperation(value = "绩效-获取快手、头条下各账户下视频的季度消耗", notes = "绩效-获取快手、头条下各账户下视频的季度消耗")
+    @PostMapping(value = "/getQuarterVideoInfoByAccountId")
+    public Result getQuarterVideoInfoByAccountId(@RequestBody PerformanceTimeDTO dto,
+                                                          HttpServletRequest req) {
+        Result result = new Result<>();
+        Integer year = dto.getYear();
+        Integer quarter = dto.getQuarter();
+        if(year==null || quarter == null  ){
+            result.setSuccess(false);
+            result.setMessage("媒体类型均不能为空");
+        }
+        performanceService.getQuarterVideoInfoByAccountId(year, quarter);
+        result.setSuccess(true);
+        return result;
+    }
+
+
+
 }

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/IPerformanceService2.java

@@ -136,4 +136,6 @@ public interface IPerformanceService2 extends IService<Performance> {
     List<VideoDTO> getUserQuarterVideo(Integer year, Integer quarter, String userId);
 
     List<VideoDTO> getUserQuarterEffiVideo(Integer year, Integer quarter, String userId);
+
+    void getQuarterVideoInfoByAccountId(Integer year, Integer quarter);
 }

+ 217 - 22
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/PerformanceServiceImpl2.java

@@ -1,5 +1,7 @@
 package org.jeecg.modules.system.service.impl;
 
+import cn.com.ctop.accountvideoquarterinfo.entity.AccountVideoQuarterInfo;
+import cn.com.ctop.accountvideoquarterinfo.mapper.AccountVideoQuarterInfoMapper;
 import cn.com.ctop.common.module.entity.MaterialInfo;
 import cn.com.ctop.performanceaccount.entity.PerformanceAccount;
 import cn.com.ctop.performanceappraisal.entity.Performance;
@@ -49,6 +51,8 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
     private PlaneProjectCostMapper planeProjectCostMapper;
     @Autowired
     private UserVideoMapMapper userVideoMapMapper;
+    @Autowired
+    private AccountVideoQuarterInfoMapper accountVideoQuarterInfoMapper;
 
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //有效视频计算开始
@@ -704,7 +708,16 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         //循环前30%有绩效的人数并计算其绩效,并入库
         for (int i = 0; i <= top30 - 1; i++) {
             //总消耗--获取这个人的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"plan",planList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"plan",planList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "plan",planList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
+
             //总绩效=总消耗*提点比例(5‰)*提成比例(编导40%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -727,12 +740,20 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         }
 
         //去掉list中前30的数据
-        planList.subList(0, top30 - 1).clear();
+        planList.subList(0, top30).clear();
 
         //循环中间50%有绩效的人,计算绩效并入库
         for (int i = 0; i <= middle50 - 1; i++) {
             //总消耗--获取这个人所在项目的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"plan",planList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"plan",planList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "plan",planList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
             //总绩效=总消耗*提点比例(3‰)*提成比例(编导40%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null){
@@ -793,7 +814,15 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         //循环前30%有绩效的人数并计算其绩效,并入库
         for (int i = 0; i <= shotTop30 - 1; i++) {
             //总消耗--获取这个人所在项目的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"shot",shotList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"shot",shotList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "shot",shotList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
             //总绩效=总消耗*提点比例(5‰)*提成比例(拍摄10%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -816,12 +845,20 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         }
 
         //去掉list中前30的数据
-        shotList.subList(0, shotTop30 - 1).clear();
+        shotList.subList(0, shotTop30).clear();
 
         //循环中间50%有绩效的人,计算绩效并入库
         for (int i = 0; i <= shotMiddle50 - 1; i++) {
             //总消耗--获取这个人所在项目的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"shot",shotList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"shot",shotList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "shot",shotList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
             //总绩效=总消耗*提点比例(3‰)*提成比例(拍摄10%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -881,7 +918,15 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         //循环前30%有绩效的人数并计算其绩效,并入库
         for (int i = 0; i <= clipTop30 - 1; i++) {
             //总消耗--获取这个人所在项目的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"clip",clipList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"clip",clipList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "clip",clipList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
             //总绩效=总消耗*提点比例(5‰)*提成比例(剪辑30%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -904,12 +949,19 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         }
 
         //去掉list中前30的数据
-        clipList.subList(0, clipTop30 - 1).clear();
+        clipList.subList(0, clipTop30).clear();
 
         //循环中间50%有绩效的人,计算绩效并入库
         for (int i = 0; i <= clipMiddle50 - 1; i++) {
             //总消耗--获取这个人所在项目的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"clip",clipList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getQuarterTotalCostByRoleCode(thisYear, thisQuarter,startTime, endTime,"clip",clipList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "clip",clipList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
             //总绩效=总消耗*提点比例(3‰)*提成比例(剪辑30%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -1009,6 +1061,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
                 //增加平面人数、和项目单独的绩效
                 planeProjectCost.setProjectPlaneCount(planeList.size());
                 planeProjectCost.setProjectPerformance(averageQuarterCost.multiply(new BigDecimal("0.05")).multiply(new BigDecimal("0.003")).setScale(4,BigDecimal.ROUND_HALF_UP));
+                planeProjectCost.setType(1);
                 if (null == planeMap.get(plane.getUserId())) {
                     plane.setEffiRate(averageQuarterCost);
                     planeMap.put(plane.getUserId(), plane);
@@ -1029,7 +1082,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             planeProjectCost.setUserId(designLeader.getUserId());
             //增加平面人数、和项目单独的绩效
             planeProjectCost.setProjectPlaneCount(1);
-            planeProjectCost.setProjectPerformance(quarterCost.multiply(new BigDecimal("0.2")).multiply(new BigDecimal("0.003")));
+            planeProjectCost.setProjectPerformance(quarterCost.multiply(new BigDecimal("0.15")).multiply(new BigDecimal("0.003")).setScale(4,BigDecimal.ROUND_HALF_UP));
             planeProjectCost.setType(2);
 
             if (null == designLeaderMap.get(designLeader.getUserId())) {
@@ -1117,7 +1170,16 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         //循环前30%有绩效的人数并计算其绩效,并入库
         for (int i = 0; i <= top30 - 1; i++) {
             //头条编导总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "plan", planList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "plan", planList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "plan",planList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
+
             //总绩效=总消耗*提点比例(5‰)*提成比例(编导40%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -1140,12 +1202,21 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         }
 
         //去掉list中前30的数据
-        planList.subList(0, top30 - 1).clear();
+        planList.subList(0, top30).clear();
 
         //循环中间50%有绩效的人,计算绩效并入库
         for (int i = 0; i <= middle50 - 1; i++) {
             //这个编导的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "plan", planList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "plan", planList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "plan",planList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
+
             //总绩效=总消耗*提点比例(2‰)*提成比例(编导40%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -1202,7 +1273,15 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         //循环前30%有绩效的人数并计算其绩效,并入库
         for (int i = 0; i <= shotTop30 - 1; i++) {
             //总消耗--获取这个人所在项目的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "shot", shotList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "shot", shotList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "shot",shotList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
             //总绩效=总消耗*提点比例(5‰)*提成比例(拍摄10%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -1225,12 +1304,20 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         }
 
         //去掉list中前30的数据
-        shotList.subList(0, shotTop30 - 1).clear();
+        shotList.subList(0, shotTop30).clear();
 
         //循环中间50%有绩效的人,计算绩效并入库
         for (int i = 0; i <= shotMiddle50 - 1; i++) {
             //总消耗--获取这个人所在项目的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "shot", shotList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "shot", shotList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "shot",shotList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
             //总绩效=总消耗*提点比例(3‰)*提成比例(拍摄10%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -1265,7 +1352,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             //有效视频数量 //1头条 2快手
             int effiVideoCount = userEfficientVideoMapMapper.getEffiVideoCountByUserId(1, thisYear, thisQuarter, userDto.getUserId(), "clip");
             //总视频数量
-            int videoCount = userEfficientVideoMapMapper.getQuarterVideoCountByRoleCodeAndUserId(thisYear, thisQuarter, 2, userDto.getUserId(), "clip");
+            int videoCount = userEfficientVideoMapMapper.getQuarterVideoCountByRoleCodeAndUserId(thisYear, thisQuarter, 1, userDto.getUserId(), "clip");
             //视频有效率
             BigDecimal effiRate=BigDecimal.ZERO;
             if (videoCount != 0){
@@ -1287,7 +1374,15 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         //循环前30%有绩效的人数并计算其绩效,并入库
         for (int i = 0; i <= clipTop30 - 1; i++) {
             //总消耗--获取这个人所在项目的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "clip", clipList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "clip", clipList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "clip",clipList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
             //总绩效=总消耗*提点比例(5‰)*提成比例(剪辑30%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -1310,12 +1405,20 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         }
 
         //去掉list中前30的数据
-        clipList.subList(0, clipTop30 - 1).clear();
+        clipList.subList(0, clipTop30).clear();
 
         //循环中间50%有绩效的人,计算绩效并入库
         for (int i = 0; i <= clipMiddle50 - 1; i++) {
             //总消耗--获取这个人所在项目的总消耗
-            BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "clip", clipList.get(i).getUserId());
+            //BigDecimal totalCost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByRoleCode(thisYear, thisQuarter, startTime, endTime, "clip", clipList.get(i).getUserId());
+            BigDecimal totalCost = BigDecimal.ZERO;
+
+            List<String> codeList = userEfficientVideoMapMapper.getQuarterSignature(thisYear, thisQuarter, "clip",clipList.get(i).getUserId());
+            for(String code : codeList){
+                BigDecimal cost = userEfficientVideoMapMapper.getToutiaoQuarterTotalCostByCode(startTime, endTime,code);
+                totalCost = totalCost.add(cost==null?BigDecimal.ZERO:cost);
+            }
+
             //总绩效=总消耗*提点比例(3‰)*提成比例(剪辑30%)
             BigDecimal totalPerformance = BigDecimal.ZERO;
             if(totalCost != null) {
@@ -1364,7 +1467,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
 
             UserDto2 designLeader = userEfficientVideoMapMapper.getProjectDesignResponsibleInfo(projectDTO.getProjectId());
             List<UserDto2> planeList = userEfficientVideoMapMapper.getPlaneByProjectId(projectDTO.getProjectId());
-            BigDecimal quarterCost = userEfficientVideoMapMapper.getProjectQuarterCostById(startTime, endTime, projectDTO.getProjectId());
+            BigDecimal quarterCost = userEfficientVideoMapMapper.getToutiaoProjectQuarterCostById(startTime, endTime, projectDTO.getProjectId());
             quarterCost = quarterCost==null?BigDecimal.ZERO:quarterCost;
             //此项目当中平面数量,平面数量为0的时候说明此project当中没有平面设计师;项目没有平面的情况下,项目leader绩效提成为20%
             int size = planeList.size();
@@ -1415,7 +1518,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
                 planeProjectCost.setUserId(plane.getUserId());
                 //增加平面人数、和项目单独的绩效
                 planeProjectCost.setProjectPlaneCount(planeList.size());
-                planeProjectCost.setProjectPerformance(averageQuarterCost.multiply(new BigDecimal("0.05")));
+                planeProjectCost.setProjectPerformance(averageQuarterCost.multiply(new BigDecimal("0.05")).multiply(new BigDecimal("0.002")).setScale(4,BigDecimal.ROUND_HALF_UP));
                 planeProjectCost.setType(1);
 
                 if (null == planeMap.get(plane.getUserId())) {
@@ -2553,6 +2656,98 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         return userEfficientVideoMapMapper.getToutiaoQuarterVideoInfoByAccountId(startDate, endDate, accountId);
     }
 
+    //获取快手、头条下各账户下视频的季度消耗
+    public void getQuarterVideoInfoByAccountId(Integer year, Integer quarter){
+        Map<String,String> dateMap = DateUtils.quarterStartEndDate(year, quarter);
+        String startDate = dateMap.get("startDate");
+        String endDate = dateMap.get("endDate");
+
+        getToutiaoQuarterVideoInfoByAccountId2(startDate, endDate);
+        getKuaishouQuarterVideoInfoByAccountId2(startDate, endDate);
+    }
+
+    //TODO 根据accountId获取季度视频信息
+    public void getKuaishouQuarterVideoInfoByAccountId2(String startDate, String endDate){
+        Integer appType = 2;
+        List<AccountDTO> accountList = userEfficientVideoMapMapper.getAccountInfoByAppType(appType);
+        for (AccountDTO accountDTO:accountList){
+            List<VideoDTO> videoDTOList= userEfficientVideoMapMapper.getKuaishouQuarterVideoInfoByAccountId(startDate, endDate, Long.parseLong(accountDTO.getAccountId()));
+
+            for(VideoDTO video:videoDTOList){
+                AccountVideoQuarterInfo info = new AccountVideoQuarterInfo();
+                info.setAccountId(Long.parseLong(accountDTO.getAccountId()));
+                info.setProjectId(accountDTO.getProjectId());
+                info.setProjectName(accountDTO.getProjectName());
+                info.setSignature(video.getSignature());
+                info.setPlanId(video.getPlanId());
+                info.setPlanName(video.getPlan());
+                info.setClipId(video.getClipId());
+                info.setClipName(video.getClip());
+                info.setShotId(video.getShotId());
+                info.setShotName(video.getShot());
+                info.setPlaneId(video.getPlaneId());
+                info.setPlaneName(video.getPlane());
+                info.setVideoCost(video.getCharge());
+                info.setAppType(appType);
+                info.setYear(2020);
+                info.setQuarter(1);
+                if(video.getClipId() != null){
+                    SysUser user = userEfficientVideoMapMapper.getDesignLeaderInfoByDesignUserId(video.getClipId());
+                    info.setDesignResponsibleId(user==null?null:user.getId());
+                    info.setDesignResponsibleName(user==null?null:user.getRealname());
+                }else{
+                    SysUser user = userEfficientVideoMapMapper.getDesignLeaderInfoByDesignUserId(video.getPlaneId());
+                    info.setDesignResponsibleId(user==null?null:user.getId());
+                    info.setDesignResponsibleName(user==null?null:user.getRealname());
+                }
+                accountVideoQuarterInfoMapper.insert(info);
+            }
+
+        }
+
+
+    }
+
+    //TODO 根据accountId获取季度视频信息
+    public void getToutiaoQuarterVideoInfoByAccountId2(String startDate, String endDate){
+        Integer appType = 1;
+        List<AccountDTO> accountList = userEfficientVideoMapMapper.getAccountInfoByAppType(appType);
+        for (AccountDTO accountDTO:accountList){
+            List<VideoDTO> videoDTOList= userEfficientVideoMapMapper.getToutiaoQuarterVideoInfoByAccountId(startDate, endDate, Long.parseLong(accountDTO.getAccountId()));
+
+            for(VideoDTO video:videoDTOList){
+                AccountVideoQuarterInfo info = new AccountVideoQuarterInfo();
+                info.setAccountId(Long.parseLong(accountDTO.getAccountId()));
+                info.setProjectId(accountDTO.getProjectId());
+                info.setProjectName(accountDTO.getProjectName());
+                info.setSignature(video.getSignature());
+                info.setPlanId(video.getPlanId());
+                info.setPlanName(video.getPlan());
+                info.setClipId(video.getClipId());
+                info.setClipName(video.getClip());
+                info.setShotId(video.getShotId());
+                info.setShotName(video.getShot());
+                info.setPlaneId(video.getPlaneId());
+                info.setPlaneName(video.getPlane());
+                info.setVideoCost(video.getCharge());
+                info.setAppType(appType);
+                info.setYear(2020);
+                info.setQuarter(1);
+                if(video.getClipId() != null){
+                    SysUser user = userEfficientVideoMapMapper.getDesignLeaderInfoByDesignUserId(video.getClipId());
+                    info.setDesignResponsibleId(user==null?null:user.getId());
+                    info.setDesignResponsibleName(user==null?null:user.getRealname());
+                }else{
+                    SysUser user = userEfficientVideoMapMapper.getDesignLeaderInfoByDesignUserId(video.getPlaneId());
+                    info.setDesignResponsibleId(user==null?null:user.getId());
+                    info.setDesignResponsibleName(user==null?null:user.getRealname());
+                }
+                accountVideoQuarterInfoMapper.insert(info);
+            }
+
+        }
+    }
+
     public List<VideoDTO> getUserQuarterVideo(Integer year, Integer quarter, String userId){
         return userEfficientVideoMapMapper.getUserQuarterVideo(userId, year, quarter);
     }

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/CtopOauthTokenMapper.java

@@ -34,4 +34,6 @@ public interface CtopOauthTokenMapper extends BaseMapper<CtopOauthToken> {
     CtopOauthToken selectByAccountId(Long accountId);
 
     List<CtopOauthToken> selectKuaiShouToken();
+
+    List<CtopOauthToken> selectToutiaoToken();
 }

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/MaterialInfoMapper.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -27,4 +28,8 @@ public interface MaterialInfoMapper extends BaseMapper<MaterialInfo> {
     Integer getToutiaoUpVideoCount(@Param("code") String code);
 
     JSONObject getGeneralizationInfo(@Param("code") String code);
+
+    List<String> getEffiSignature();
+
+    MaterialInfo getMaterialInfoByCode(@Param("code")String code);
 }

+ 12 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopOauthTokenMapper.xml

@@ -85,4 +85,16 @@
         and t1.media_id = 2
 
     </select>
+
+    <select id="selectToutiaoToken" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
+        select  t1.*
+        from ctop_oauth_token t1
+        left join ctop_user_allocation t2
+        on t1.account_id = t2.account_id
+        where t2.account_status = 0
+        and t1.media_id = 1
+        and user_id != 'e9ca23d68d884d4ebb19d07889727dae' <!-- 去掉管理员 -->
+        group by account_id
+    </select>
+
 </mapper>

+ 10 - 4
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MailLogMapper.xml

@@ -4,7 +4,6 @@
 
 
     <select id="selectCountByAccountIdAndDate" resultType="java.lang.Integer">
-
         select
         count(1)
         from
@@ -23,6 +22,7 @@
      left join sys_user t2
      on t1.user_id = t2.id
      where t1.project_id = #{projectId}
+     and t2.`status` = 1
      and t2.email != ''
     </select>
 
@@ -34,14 +34,20 @@
      ctop_project_member t1
      left join ctop_corp_wexin_user t2
      on t1.user_id = t2.user_id
+     LEFT JOIN sys_user t3
+     on  t1.user_id = t3.id
      where t1.project_id = #{projectId}
+     and t3.`status` = 1
      and t2.wexin_id != ''
     </select>
 
     <select id="getWChatIdByUserId" resultType="java.lang.String">
-    select wexin_id
-    from ctop_corp_wexin_user
-    where  user_id = #{userId}
+    select t1.wexin_id
+    from ctop_corp_wexin_user t1
+    left join  sys_user t2
+    on  t1.user_id = t2.id
+    where  t1.user_id = #{userId}
+    and t2.`status` = 1
 
     </select>
 

+ 48 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialInfoMapper.xml

@@ -86,5 +86,53 @@
 	  )t
     </select>
 
+    <select id="getEffiSignature" resultType="string">
+        select
+        efficient_video_signature
+        from ctop_user_efficient_video_map
+        where company_id is not null
+        group by efficient_video_signature
+
+    </select>
+
+    <!--TODO -->
+    <select id="getEffiSignatureCount" resultType="integer">
+        select
+        count(1)
+        from
+            (
+            select
+            efficient_video_signature
+            from ctop_user_efficient_video_map
+            where company_id is not null
+            group by efficient_video_signature
+            ) a
+    </select>
+
+    <select id="getMaterialInfoByCode" resultType="cn.com.ctop.common.module.entity.MaterialInfo">
+            select
+            id,
+            code,
+            url,
+            watermark_code as watermarkCode,
+            material_name as materialName,
+            watermark_url as watermarkUrl,
+            watermark_material_name as watermarkMaterialName,
+            user_id as userId,
+            auditor_id as auditorId,
+            status as status,
+            material_describe as materialDescribe,
+            project_id as projectId,
+            refuse_reason as refuseReason,
+            creative_copywriter as creativeCopywriter,
+            refuse_file as refuseFile,
+            excellent,
+            type
+        from
+        ctop_material_info
+        where code = #{code}
+        limit 1
+    </select>
+
 
 </mapper>

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java

@@ -25,4 +25,6 @@ public interface ICtopOauthTokenService extends IService<CtopOauthToken> {
     List<CtopOauthToken> getTokenListByType(String platformTypeBytedance);
 
     List<CtopOauthToken> selectKuaiShouToken();
+
+    List<CtopOauthToken> selectToutiaoToken();
 }

+ 6 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialInfoService.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -57,4 +58,9 @@ public interface IMaterialInfoService extends IService<MaterialInfo> {
      * @return
      */
     Map<String, Object> insertImage(JSONObject json);
+
+
+    List<MaterialInfo> effiMaterialInfo();
+
+    List<String> getEffiCode();
 }

+ 12 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java

@@ -171,4 +171,16 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
     public List<CtopOauthToken> selectKuaiShouToken() {
         return cTopOauthTokenMapper.selectKuaiShouToken();
     }
+
+
+    /**
+     * 获取toutiao有效账户列表
+     *
+     * @return
+     */
+
+    @Override
+    public List<CtopOauthToken> selectToutiaoToken() {
+        return cTopOauthTokenMapper.selectToutiaoToken();
+    }
 }

+ 40 - 6
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -24,10 +24,7 @@ import java.io.IOException;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.nio.channels.FileChannel;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.regex.Pattern;
@@ -47,6 +44,8 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
     private IVideoWatermarkTemplateService videoWatermarkTemplateService;
     @Autowired
     private IVideoWatermarkTaskService videoWatermarkTaskService;
+    @Autowired
+    private MaterialInfoMapper materialInfoMapper;
     @Value("${oss.replace.replace-value}")
     private String replaceValue;
     @Value("${oss.replace.replace-old-value}")
@@ -244,8 +243,8 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
      * @return
      */
 
-    @Autowired
-    private MaterialInfoMapper materialInfoMapper;
+    //@Autowired
+    //private MaterialInfoMapper materialInfoMapper;
 
 
     @Override
@@ -546,4 +545,39 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
 
         return resultMap;
     }
+
+    public List<String> getEffiCode(){
+        return materialInfoMapper.getEffiSignature();
+    }
+
+    public List<MaterialInfo> effiMaterialInfo(){
+        List<MaterialInfo> materialInfoList = new ArrayList<>();
+        List<String> effiSignatureList = materialInfoMapper.getEffiSignature();
+        for(String code:effiSignatureList){
+            MaterialInfo materialInfo = materialInfoMapper.getMaterialInfoByCode(code);
+
+            if (materialInfo == null){
+                continue;
+            }
+            //判断是否已经同步到快手平台
+            Integer kuaishouMaterialUpCount = materialInfoMapper.getKuaishouUpVideoCount(code);
+            if (kuaishouMaterialUpCount > 0) {
+                materialInfo.setKuaishouVideoIsUp(1);
+            } else {
+                materialInfo.setKuaishouVideoIsUp(0);
+            }
+            //判断是否已经同步到抖音平台
+            Integer toutiaoMaterialUpCount = materialInfoMapper.getToutiaoUpVideoCount(code);
+            if (toutiaoMaterialUpCount > 0) {
+                materialInfo.setToutiaoVideoIsUp(1);
+            } else {
+                materialInfo.setToutiaoVideoIsUp(0);
+            }
+            materialInfoList.add(materialInfo);
+        }
+
+        return materialInfoList;
+    }
+
+
 }

+ 3 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/CtopAdConstant.java

@@ -24,6 +24,9 @@ public class CtopAdConstant {
     public static final String KUAISHOU_LOAD_JOB_TYPE_HISTORY = "history";
     public static final String KUAISHOU_LOAD_JOB_TYPE_DAILY = "daily";
 
+    public static final String BYTEDANCE_LOAD_JOB_TYPE_ASYNC = "async";
+    public static final String BYTEDANCE_LOAD_JOB_TYPE_DAILY = "daily";
+
     /**
      * 销售角色Id
      */

+ 2 - 61
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouController.java

@@ -3,18 +3,12 @@ package cn.com.ctop.kuaishou.modules.batch.controller;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
 
-import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -74,29 +68,6 @@ public class KuaiShouController {
     }
 
 
-    @RequestMapping("/getCampaignList")
-    public void getCampaignList() {
-        String accessToken = "18cf38d50da314dcbd9cb6db9c43bcbf";
-        Long advertiserId = 1595407L;
-        kuaishouInterfaceService.getCampaignList(accessToken, advertiserId, DateUtils.addDay(new Date(),-1), new Date(), 1);
-
-    }
-
-    @RequestMapping("/getGroupList")
-    public void getGroupList() {
-        String accessToken = "604d2f2ffe5573c3500ffee358ba9b3c";
-        Long advertiserId = 1595407L;
-        kuaishouInterfaceService.getGroupList(accessToken, advertiserId, DateUtils.addDay(new Date(),-1), new Date(), 1);
-
-    }
-
-    @RequestMapping("/getCreativeList")
-    public void getCreativeList() {
-        String accessToken = "604d2f2ffe5573c3500ffee358ba9b3c";
-        Long advertiserId = 1595407L;
-        kuaishouInterfaceService.getCreativeList(accessToken, advertiserId, DateUtils.addDay(new Date(),-1), new Date(), 1);
-    }
-
     @RequestMapping("/getDeepConversionInfos")
     public void getDeepConversionInfos() {
         String accessToken = "cbe9caeffcc2c5ccd97a05bf909896da";
@@ -105,11 +76,6 @@ public class KuaiShouController {
     }
 
 
-
-
-
-
-
     @RequestMapping("/image/get")
     public void imageGet() {
         String accessToken = "360d43b49553684a011d6607322582b1";
@@ -135,15 +101,7 @@ public class KuaiShouController {
         kuaishouInterfaceService.getAppList(advertiserId, accessToken);
 
     }
-
-    @RequestMapping(value = "/app/update", consumes = "multipart/form-data;charset=utf-8")
-    public void appUpdate(@RequestParam("multipartFile") MultipartFile multipartFile, HttpServletRequest request) throws IOException {
-        String accessToken = "360d43b49553684a011d6607322582b1";
-        Long advertiserId = 23212L;
-        JSONObject requestJson = new JSONObject();
-        kuaishouInterfaceService.appUpdate(advertiserId, accessToken, requestJson, multipartFile, request);
-    }
-
+    
 
     @Autowired
     private ICtopOauthTokenService tokenService;
@@ -161,11 +119,7 @@ public class KuaiShouController {
         if (null != type) {
             if (type == 1) {
                 //广告主
-                if (null != temporalGranularity && "hourly".equals(temporalGranularity)) {
-                    result.put("data", kuaishouInterfaceService.getAccountHourlyReport(token.getAccessToken(), token.getAccountId(), startDate, endDate, 500, 1));
-                } else {
-                    result.put("data", kuaishouInterfaceService.getAccountDailyReport(token.getAccessToken(), token.getAccountId(), startDate, endDate, 500, 1));
-                }
+
             } else if (type == 2) {
                 //广告组
                 if (null != temporalGranularity && "hourly".equals(temporalGranularity)) {
@@ -197,18 +151,5 @@ public class KuaiShouController {
         kuaishouInterfaceService.advertiserInfo(23212L, "10b6ad966b7e958d1510a78a5315ec5c");
     }
 
-    @RequestMapping("getImageList")
-    public void getImageList() {
-        String accessToken = "604d2f2ffe5573c3500ffee358ba9b3c";
-        Long advertiserId = 1595407L;
-        kuaishouInterfaceService.getImageList(accessToken, advertiserId, new Date(), new Date(), 1);
-    }
-
-    @RequestMapping("getVideoList")
-    public void getVideoList() {
-        String accessToken = "e8959cf08e59e78b91b22aa4ed593c00";
-        Long advertiserId = 1022694L;
-        kuaishouInterfaceService.getVideoList(accessToken, advertiserId, DateUtils.addDay(new Date(), -1), new Date(), 1);
-    }
 
 }

+ 0 - 91
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouReportController.java

@@ -1,91 +0,0 @@
-package cn.com.ctop.kuaishou.modules.batch.controller;
-
-import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.entity.UserAllocation;
-import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
-import cn.com.ctop.common.module.mapper.UserAllocationMapper;
-import cn.com.ctop.common.module.utils.Check;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.util.DateUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.text.ParseException;
-import java.util.List;
-
-/**
- * @Description: 快手-本地图片保存
- * @Author: jeecg-boot
- * @Date: 2019-08-14
- * @Version: V1.0
- */
-@Slf4j
-
-@RestController
-@RequestMapping("/kuaishou/getReport")
-public class KuaiShouReportController {
-    @Autowired
-    private UserAllocationMapper userAllocationMapper;
-    @Autowired
-    private CtopOauthTokenMapper ctopOauthTokenMapper;
-    @Autowired
-    private IKuaishouInterfaceService kuaishouInterfaceService;
-
-    @RequestMapping(value = "/historyData")
-    public String queryPageList() throws ParseException {
-        QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("media_id", 2);
-        queryWrapper.groupBy("account_id");
-        List<UserAllocation> userAllocations = userAllocationMapper.selectList(queryWrapper);
-        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-        String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
-        if (!Check.isNull(userAllocations)) {
-            for (UserAllocation allocation : userAllocations) {
-                String beginDate = null;
-                String hourDate = null;
-                Long accountId = allocation.getAccountId();
-                if (!Check.isNull(accountId)) {
-                    QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
-                    tokenQueryWrapper.eq("account_id", accountId);
-                    tokenQueryWrapper.eq("media_id", 2);
-                    tokenQueryWrapper.orderByDesc("create_time");
-                    tokenQueryWrapper.last("limit 1");
-                    CtopOauthToken ctopOauthToken = ctopOauthTokenMapper.selectOne(tokenQueryWrapper);
-                    if (!Check.isNull(ctopOauthToken)) {
-                        String accessToken = ctopOauthToken.getAccessToken();
-                        Long advertiserId = ctopOauthToken.getAccountId();
-                        for (int i = 0; i < 6; i++) {
-                            if (i == 0) {
-                                String monthBefore = DateUtils.getMonthBefore("yyyy-MM-dd", nowDate, -1);
-                                kuaishouInterfaceService.getAccountDailyReport(accessToken, advertiserId, monthBefore, anotherDay, 500, 1);
-                                beginDate = monthBefore;
-                            } else if (i > 0) {
-                                String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", beginDate, -1);
-                                String monthBefore = DateUtils.getMonthBefore("yyyy-MM-dd", beginDate, -1);
-                                if (i == 5) {
-                                    monthBefore = DateUtils.getAnotherDay("yyyy-MM-dd", monthBefore, 4);
-                                }
-                                kuaishouInterfaceService.getAccountDailyReport(accessToken, advertiserId, monthBefore, startDate, 500, 1);
-                                beginDate = monthBefore;
-                            }
-                        }
-                        for (int i = 0; i < 7; i++) {
-                            if (i == 0) {
-                                kuaishouInterfaceService.getAccountHourlyReport(accessToken, advertiserId, nowDate, nowDate, 500, 1);
-                                hourDate = nowDate;
-                            } else if (i > 0) {
-                                String hourAnotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", hourDate, -1);
-                                kuaishouInterfaceService.getAccountHourlyReport(accessToken, advertiserId, hourAnotherDay, hourAnotherDay, 500, 1);
-                                hourDate = hourAnotherDay;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        return null;
-    }
-}

+ 0 - 249
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouReportHourlyCreativeStatisticController.java

@@ -1,249 +0,0 @@
-package cn.com.ctop.kuaishou.modules.batch.controller;
-
-import cn.com.ctop.common.module.utils.StringUtils;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCreativeStatistic;
-import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyCreativeStatisticService;
-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.aspect.annotation.AutoLog;
-import org.jeecg.common.system.query.QueryGenerator;
-import org.jeecg.common.util.oConvertUtils;
-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 2019-11-01
- */
-@Slf4j
-@Api(tags = "时报清洗数据")
-@RestController
-@RequestMapping("/ctop/kuaishouReportHourlyCreativeStatistic")
-public class KuaishouReportHourlyCreativeStatisticController {
-    @Autowired
-    private IKuaishouReportHourlyCreativeStatisticService kuaishouReportHourlyCreativeStatisticService;
-
-    /**
-     * 分页列表查询
-     *
-     * @param kuaishouReportHourlyCreativeStatistic
-     * @param pageNo
-     * @param pageSize
-     * @param req
-     * @return
-     */
-    @AutoLog(value = "时报清洗数据-分页列表查询")
-    @ApiOperation(value = "时报清洗数据-分页列表查询", notes = "时报清洗数据-分页列表查询")
-    @GetMapping(value = "/list")
-    public Result<IPage<KuaishouReportHourlyCreativeStatistic>> queryPageList(KuaishouReportHourlyCreativeStatistic kuaishouReportHourlyCreativeStatistic,
-                                                                              @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                                                              @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
-                                                                              HttpServletRequest req) {
-        Result<IPage<KuaishouReportHourlyCreativeStatistic>> result = new Result<IPage<KuaishouReportHourlyCreativeStatistic>>();
-        QueryWrapper<KuaishouReportHourlyCreativeStatistic> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouReportHourlyCreativeStatistic, req.getParameterMap());
-        Page<KuaishouReportHourlyCreativeStatistic> page = new Page<KuaishouReportHourlyCreativeStatistic>(pageNo, pageSize);
-        IPage<KuaishouReportHourlyCreativeStatistic> pageList = kuaishouReportHourlyCreativeStatisticService.page(page, queryWrapper);
-        result.setSuccess(true);
-        result.setResult(pageList);
-        return result;
-    }
-
-    /**
-     * 添加
-     *
-     * @param kuaishouReportHourlyCreativeStatistic
-     * @return
-     */
-    @AutoLog(value = "时报清洗数据-添加")
-    @ApiOperation(value = "时报清洗数据-添加", notes = "时报清洗数据-添加")
-    @PostMapping(value = "/add")
-    public Result<KuaishouReportHourlyCreativeStatistic> add(@RequestBody KuaishouReportHourlyCreativeStatistic kuaishouReportHourlyCreativeStatistic) {
-        Result<KuaishouReportHourlyCreativeStatistic> result = new Result<KuaishouReportHourlyCreativeStatistic>();
-        try {
-            kuaishouReportHourlyCreativeStatisticService.save(kuaishouReportHourlyCreativeStatistic);
-            result.success("添加成功!");
-        } catch (Exception e) {
-            log.error(e.getMessage(), e);
-            result.error500("操作失败");
-        }
-        return result;
-    }
-
-    /**
-     * 编辑
-     *
-     * @param kuaishouReportHourlyCreativeStatistic
-     * @return
-     */
-    @AutoLog(value = "时报清洗数据-编辑")
-    @ApiOperation(value = "时报清洗数据-编辑", notes = "时报清洗数据-编辑")
-    @PutMapping(value = "/edit")
-    public Result<KuaishouReportHourlyCreativeStatistic> edit(@RequestBody KuaishouReportHourlyCreativeStatistic kuaishouReportHourlyCreativeStatistic) {
-        Result<KuaishouReportHourlyCreativeStatistic> result = new Result<KuaishouReportHourlyCreativeStatistic>();
-        KuaishouReportHourlyCreativeStatistic kuaishouReportHourlyCreativeStatisticEntity = kuaishouReportHourlyCreativeStatisticService.getById(kuaishouReportHourlyCreativeStatistic.getId());
-        if (kuaishouReportHourlyCreativeStatisticEntity == null) {
-            result.error500("未找到对应实体");
-        } else {
-            boolean ok = kuaishouReportHourlyCreativeStatisticService.updateById(kuaishouReportHourlyCreativeStatistic);
-            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 {
-            kuaishouReportHourlyCreativeStatisticService.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<KuaishouReportHourlyCreativeStatistic> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
-        Result<KuaishouReportHourlyCreativeStatistic> result = new Result<KuaishouReportHourlyCreativeStatistic>();
-        if (ids == null || "".equals(ids.trim())) {
-            result.error500("参数不识别!");
-        } else {
-            this.kuaishouReportHourlyCreativeStatisticService.removeByIds(Arrays.asList(ids.split(StringUtils.COMMA)));
-            result.success("删除成功!");
-        }
-        return result;
-    }
-
-    /**
-     * 通过id查询
-     *
-     * @param id
-     * @return
-     */
-    @AutoLog(value = "时报清洗数据-通过id查询")
-    @ApiOperation(value = "时报清洗数据-通过id查询", notes = "时报清洗数据-通过id查询")
-    @GetMapping(value = "/queryById")
-    public Result<KuaishouReportHourlyCreativeStatistic> queryById(@RequestParam(name = "id", required = true) String id) {
-        Result<KuaishouReportHourlyCreativeStatistic> result = new Result<KuaishouReportHourlyCreativeStatistic>();
-        KuaishouReportHourlyCreativeStatistic kuaishouReportHourlyCreativeStatistic = kuaishouReportHourlyCreativeStatisticService.getById(id);
-        if (kuaishouReportHourlyCreativeStatistic == null) {
-            result.error500("未找到对应实体");
-        } else {
-            result.setResult(kuaishouReportHourlyCreativeStatistic);
-            result.setSuccess(true);
-        }
-        return result;
-    }
-
-    /**
-     * 导出excel
-     *
-     * @param request
-     * @param response
-     */
-    @RequestMapping(value = "/exportXls")
-    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
-        // Step.1 组装查询条件
-        QueryWrapper<KuaishouReportHourlyCreativeStatistic> queryWrapper = null;
-        try {
-            String paramsStr = request.getParameter("paramsStr");
-            if (oConvertUtils.isNotEmpty(paramsStr)) {
-                String deString = URLDecoder.decode(paramsStr, "UTF-8");
-                KuaishouReportHourlyCreativeStatistic kuaishouReportHourlyCreativeStatistic = JSON.parseObject(deString, KuaishouReportHourlyCreativeStatistic.class);
-                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouReportHourlyCreativeStatistic, request.getParameterMap());
-            }
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-        }
-
-        //Step.2 AutoPoi 导出Excel
-        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
-        List<KuaishouReportHourlyCreativeStatistic> pageList = kuaishouReportHourlyCreativeStatisticService.list(queryWrapper);
-        //导出文件名称
-        mv.addObject(NormalExcelConstants.FILE_NAME, "时报清洗数据列表");
-        mv.addObject(NormalExcelConstants.CLASS, KuaishouReportHourlyCreativeStatistic.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<KuaishouReportHourlyCreativeStatistic> listKuaishouReportHourlyCreativeStatistics = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouReportHourlyCreativeStatistic.class, params);
-                kuaishouReportHourlyCreativeStatisticService.saveBatch(listKuaishouReportHourlyCreativeStatistics);
-                return Result.ok("文件导入成功!数据行数:" + listKuaishouReportHourlyCreativeStatistics.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("文件导入失败!");
-    }
-
-}

+ 181 - 68
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java

@@ -7,12 +7,9 @@ import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
 import cn.com.ctop.kuaishou.modules.report.entity.*;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import org.springframework.web.multipart.MultipartFile;
 
-import javax.servlet.http.HttpServletRequest;
 import java.text.ParseException;
 import java.util.Date;
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -20,24 +17,92 @@ import java.util.Map;
  * 2019年11月12日11:08:52
  */
 public interface IKuaishouInterfaceService {
-    KuaishouResult<KuaishouReportHourlyAccount> getAccountHourlyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum);
-
-    KuaishouResult<KuaishouReportDailyAccount> getAccountDailyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum);
 
+    /**
+     * 计划日报
+     *
+     * @param accessToken
+     * @param advertiserId
+     * @param startDate
+     * @param endDate
+     * @param pageSize
+     * @param pageNum
+     * @return
+     */
     KuaishouResult<KuaishouReportDailyCampaign> getCampaignDailyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum);
 
+    /**
+     * 计划时报
+     *
+     * @param accessToken
+     * @param advertiserId
+     * @param startDate
+     * @param endDate
+     * @param pageSize
+     * @param pageNum
+     * @return
+     */
     KuaishouResult<KuaishouReportHourlyCampaign> getCampaignHourlyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum);
 
+    /**
+     * 组日报
+     *
+     * @param accessToken
+     * @param advertiserId
+     * @param startDate
+     * @param endDate
+     * @param pageSize
+     * @param pageNum
+     * @return
+     */
     KuaishouResult<KuaishouReportDailyGroup> getGroupDailyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum);
 
+    /**
+     * 组时报
+     *
+     * @param accessToken
+     * @param advertiserId
+     * @param startDate
+     * @param endDate
+     * @param pageSize
+     * @param pageNum
+     * @return
+     */
     KuaishouResult<KuaishouReportHourlyGroup> getGroupHourlyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum);
 
+    /**
+     * 创意日报 暂停使用
+     *
+     * @param accessToken
+     * @param advertiserId
+     * @param startDate
+     * @param endDate
+     * @param pageSize
+     * @param pageNum
+     * @return
+     */
     KuaishouResult<KuaishouReportDailyCreative> getCreativeDailyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum);
 
+    /**
+     * 创意时报 暂停使用
+     *
+     * @param accessToken
+     * @param advertiserId
+     * @param startDate
+     * @param endDate
+     * @param pageSize
+     * @param pageNum
+     * @return
+     */
     KuaishouResult<KuaishouReportHourlyCreative> getCreativeHourlyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum);
 
-    void loadAllKuaishouData(List<CtopOauthToken> tokens);
 
+    /**
+     * 获取历史数据
+     *
+     * @param token
+     * @throws ParseException
+     */
     void loadKuaishouDataSingle(CtopOauthToken token) throws ParseException;
 
     /**
@@ -63,15 +128,6 @@ public interface IKuaishouInterfaceService {
 
 
     /**
-     * 获取广告计划信息  全量
-     *
-     * @param accessToken
-     * @param advertiserId
-     */
-    void getCampaignList(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page);
-
-
-    /**
      * 获取广告计划信息  单条
      *
      * @param accessToken
@@ -79,14 +135,6 @@ public interface IKuaishouInterfaceService {
      */
     void getCampaign(String accessToken, Long advertiserId, Long campaignId);
 
-    /**
-     * 获取广告组信息 全量
-     *
-     * @param accessToken
-     * @param advertiserId
-     * @param page
-     */
-    void getGroupList(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page);
 
     /**
      * 获取广告组信息 单条
@@ -98,17 +146,24 @@ public interface IKuaishouInterfaceService {
     void getGroup(String accessToken, Long advertiserId, Long unitId);
 
 
+    /**
+     * 获取创意列表
+     *
+     * @param token
+     * @param startDate
+     * @param endDate
+     */
     void getCreativeList(CtopOauthToken token, Date startDate, Date endDate);
 
-    void getVideoInfo(String accessToken, Long advertiserId, String photoId);
-
     /**
-     * 获取创意信息
+     * 获取视频信息
      *
      * @param accessToken
      * @param advertiserId
+     * @param photoId
      */
-    void getCreativeList(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page);
+    void getVideoInfo(String accessToken, Long advertiserId, String photoId);
+
 
     /**
      * 获取token
@@ -127,6 +182,13 @@ public interface IKuaishouInterfaceService {
      */
     Map<String, Object> getDeepConversionInfos(Long advertiserId, String accessToken);
 
+    /**
+     * 取可选的深度转化类型
+     *
+     * @param advertiserId
+     * @param accessToken
+     * @return
+     */
     JSONObject getDeepConversionInfosV2(Long advertiserId, String accessToken);
 
 
@@ -139,7 +201,14 @@ public interface IKuaishouInterfaceService {
      */
     Map<String, Object> creativeCreate(String accessToken, Long advertiserId, JSONObject requestJson);
 
-    void getCreativeByCreativeId(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page, Long creativeId);
+    /**
+     * 根据创意id 获取创意信息
+     *
+     * @param accessToken
+     * @param advertiserId
+     * @param creativeId
+     */
+    void getCreativeByCreativeId(String accessToken, Long advertiserId, Long creativeId);
 
     /**
      * 文件上传
@@ -216,17 +285,6 @@ public interface IKuaishouInterfaceService {
 
 
     /**
-     * 修改应用
-     *
-     * @param advertiserId
-     * @param accessToken
-     * @param requestJson
-     * @param multipartFile
-     * @param request
-     */
-    void appUpdate(Long advertiserId, String accessToken, JSONObject requestJson, MultipartFile multipartFile, HttpServletRequest request);
-
-    /**
      * 创建 url应用
      *
      * @param accountId
@@ -245,59 +303,117 @@ public interface IKuaishouInterfaceService {
      */
     Map<String, Object> advertiserInfo(Long accountId, String accessToken);
 
+    /**
+     * 获取视频列表
+     *
+     * @param token
+     * @param startDate
+     * @param endDate
+     */
     void getVideoList(CtopOauthToken token, Date startDate, Date endDate);
 
-    void getVideoList(String token, Long advertiserId, Date startDate, Date endDate, int page);
 
+    /**
+     * 获取广告主分天报表
+     *
+     * @param token
+     * @param startDate
+     * @param endDate
+     */
     void getAdvertiserReportDaily(CtopOauthToken token, Date startDate, Date endDate);
 
+    /**
+     * 获取计划分天报表
+     *
+     * @param token
+     * @param startDate
+     * @param endDate
+     */
     void getAdvertiserCampaignReportDaily(CtopOauthToken token, Date startDate, Date endDate);
 
+    /**
+     * 获取广告计划分天报表 暂停使用
+     *
+     * @param token
+     * @param startDate
+     * @param endDate
+     */
     void getAdvertiserGroupReportDaily(CtopOauthToken token, Date startDate, Date endDate);
 
+    /**
+     * 获取创意分天报表 暂停使用
+     *
+     * @param token
+     * @param startDate
+     * @param endDate
+     * @param campaignIds
+     */
     void getAdvertiserCreativeReportDaily(CtopOauthToken token, Date startDate, Date endDate, JSONArray campaignIds);
 
+    /**
+     * 获取广告主时报
+     *
+     * @param token
+     * @param startDate
+     * @param endDate
+     */
     void getAdvertiserReportHourly(CtopOauthToken token, Date startDate, Date endDate);
 
+    /**
+     * 获取计划时报
+     *
+     * @param token
+     * @param startDate
+     * @param endDate
+     */
     void getAdvertiserCampaignReportHourly(CtopOauthToken token, Date startDate, Date endDate);
 
+    /**
+     * 获取组时报
+     *
+     * @param token
+     * @param startDate
+     * @param endDate
+     */
     void getAdvertiserGroupReportHourly(CtopOauthToken token, Date startDate, Date endDate);
 
+    /**
+     * 获取创意时报 暂停使用
+     *
+     * @param token
+     * @param startDate
+     * @param endDate
+     */
     void getAdvertiserCreativeReportHourly(CtopOauthToken token, Date startDate, Date endDate);
 
+    /**
+     * 获取计划列表
+     *
+     * @param token
+     * @param startDate
+     * @param endDate
+     */
     void getCampaignList(CtopOauthToken token, Date startDate, Date endDate);
 
-    void getGroupList(CtopOauthToken token, Date startDate, Date endDate);
-
-    void loadData() throws InterruptedException;
-
-    void updateCreativeReportHourlyStatistic(CtopOauthToken token, Date getDate);
-
-    void deleteHourlyReport(Date deleteDate);
-
     /**
-     * 获取快手图片列表
+     * 获取组列表
      *
      * @param token
      * @param startDate
      * @param endDate
      */
-    void getImageList(CtopOauthToken token, Date startDate, Date endDate);
-
-
-    void getImageList2(CtopOauthToken token, Date startDate, Date endDate, Integer page);
+    void getGroupList(CtopOauthToken token, Date startDate, Date endDate);
 
 
     /**
-     * 获取快手图片列表--测试使用
+     * 获取快手图片列表
      *
      * @param token
-     * @param accountId
      * @param startDate
      * @param endDate
-     * @param page
      */
-    void getImageList(String token, Long accountId, Date startDate, Date endDate, int page);
+    void getImageList(CtopOauthToken token, Date startDate, Date endDate);
+
 
     /**
      * 获取账户余额
@@ -346,16 +462,13 @@ public interface IKuaishouInterfaceService {
     JSONArray getAppSearch(Long accountId, String accessToken, String appName);
 
 
-    void getVideoList2(CtopOauthToken token, Date startDate, Date endDate, Integer page);
-
-    void getCreativeList2(CtopOauthToken token, Date startDate, Date endDate, Integer page);
-
-    void getCreative(String token, Long advertiserId, Long creativeId);
-
-
-    void getAdvertiserCreativeReportDailyV2(Long campaignId, CtopOauthToken ctopOauthToken, Date startDate, Date endDate);
-
-
+    /**
+     * 获取素造素材列表
+     *
+     * @param token
+     * @param accountId
+     * @param page
+     */
     void getSuZaoList(String token, Long accountId, int page);
 
 

+ 2 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java

@@ -434,7 +434,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                         deleteMap.put("creative_id", creativeId);
                         creativeMapper.deleteByMap(deleteMap);
                     } else {
-                        interfaceService.getCreative(token, advertiserId, creativeId);
+                        interfaceService.getCreativeByCreativeId(token, advertiserId, creativeId);
                     }
 
                     returnMap.put("code", 0);
@@ -646,7 +646,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
 
                         try {
                             Thread.sleep(500);
-                            interfaceService.getCreative(accessToken, creativeJson.getLong("advertiser_id"), data.getLong("creative_id"));
+                            interfaceService.getCreativeByCreativeId(accessToken, creativeJson.getLong("advertiser_id"), data.getLong("creative_id"));
                         } catch (InterruptedException e) {
                             e.printStackTrace();
                         }

Разница между файлами не показана из-за своего большого размера
+ 118 - 1009
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java


+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyCreativeMapper.java

@@ -1,11 +1,16 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCreative;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 public interface KuaishouReportDailyCreativeMapper extends BaseMapper<KuaishouReportDailyCreative> {
     void loadCreativeDailyReport(@Param("accountId") Long accountId, @Param("localPath") String localPath);
 
     void formatCreativeDailyReportData(@Param("accountId") Long accountId, @Param("statDate") String statDate);
+
+    List<JSONObject> selectCodeByDate(@Param("startDate") String startDate, @Param("endDate") String endDate);
 }

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

@@ -1,18 +0,0 @@
-package cn.com.ctop.kuaishou.modules.report.mapper;
-
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCreativeStatistic;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import org.apache.ibatis.annotations.Param;
-
-/**
- * 时报清洗数据
- *
- * @author: jeecg-boot
- * @date: 2019-11-01
- * @cersion: V1.0
- */
-public interface KuaishouReportHourlyCreativeStatisticMapper extends BaseMapper<KuaishouReportHourlyCreativeStatistic> {
-    void updateCreativeReportHourlyStatistic(@Param(value = "accountId") Long accountId, @Param(value = "date") String dateString);
-
-    void deleteHourlyReport(@Param(value = "date") String dateString);
-}

+ 15 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyCreativeMapper.xml

@@ -97,4 +97,19 @@
         </if>
     </update>
 
+    <select id="selectCodeByDate" resultType="com.alibaba.fastjson.JSONObject">
+   select
+   GROUP_CONCAT(DISTINCT(account_id)) accountId,
+   sum(charge) charge,
+   signature signature
+   from
+   ctop_kuaishou_report_daily_creative
+   where stat_date &gt;= #{startDate}
+   and stat_date &lt;= #{endDate}
+   and signature is not null
+   group by signature
+
+
+    </select>
+
 </mapper>

+ 0 - 157
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportHourlyCreativeStatisticMapper.xml

@@ -1,157 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportHourlyCreativeStatisticMapper">
-	<insert id="updateCreativeReportHourlyStatistic">
-        REPLACE INTO `ctop_kuaishou_report_hourly_creative_statistic` (
-	`id`,
-	`account_id`,
-	`account_name`,
-	`unit_id`,
-	`unit_name`,
-	`campaign_id`,
-	`campaign_name`,
-	`creative_id`,
-	`creative_name`,
-	`stat_date`,
-	`stat_hour`,
-	`charge`,
-	`photo_click`,
-	`photo_show`,
-	`aclick`,
-	`bclick`,
-	`photo_click_ratio`,
-	`action_ratio`,
-	`impression_1k_cost`,
-	`event_credit_grant_landing_page_cost`,
-	`event_credit_grant_landing_page`,
-	`event_jin_jian_landing_page_cost`,
-	`event_jin_jian_landing_page`,
-	`form_action_ratio`,
-	`form_cost`,
-	`form_count`,
-	`event_order_paid_cost`,
-	`event_order_paid_purchase_amount`,
-	`event_order_paid`,
-	`event_credit_grant_app_ratio`,
-	`event_credit_grant_app_cost`,
-	`event_credit_grant_app`,
-	`event_pay_purchase_amount_first_day`,
-	`event_jin_jian_app_cost`,
-	`event_jin_jian_app`,
-	`event_register_cost`,
-	`event_register`,
-	`event_pay_roi`,
-	`event_pay_purchase_amount`,
-	`event_pay`,
-	`event_pay_first_day_roi`,
-	`event_pay_first_day`,
-	`photo_click_cost`,
-	`action_cost`,
-	`share`,
-	`comment`,
-	`photo_like`,
-	`follow`,
-	`report`,
-	`block`,
-	`negative`,
-	`activation`,
-	`submit`,
-	`cancel_follow`,
-	`download_started`,
-	`download_completed`,
-	`create_time`,
-	`update_time`,
-	`signature`,
-	`url`
-) SELECT
-	*
-FROM
-	(
-		SELECT
-			ckrhc.`id`,
-			ckrhc.`account_id`,
-			cua.account_name,
-			ckg.unit_id,
-			ckg.unit_name,
-			ckc.campaign_id,
-			ckc.campaign_name,
-			ckrhc.`creative_id`,
-			ckr.creative_name,
-			ckrhc.`stat_date`,
-			ckrhc.`stat_hour`,
-			ckrhc.`charge`,
-			ckrhc.`photo_click`,
-			ckrhc.`photo_show`,
-			ckrhc.`aclick`,
-			ckrhc.`bclick`,
-			ckrhc.`photo_click_ratio`,
-			ckrhc.`action_ratio`,
-			ckrhc.`impression_1k_cost`,
-			ckrhc.`event_credit_grant_landing_page_cost`,
-			ckrhc.`event_credit_grant_landing_page`,
-			ckrhc.`event_jin_jian_landing_page_cost`,
-			ckrhc.`event_jin_jian_landing_page`,
-			ckrhc.`form_action_ratio`,
-			ckrhc.`form_cost`,
-			ckrhc.`form_count`,
-			ckrhc.`event_order_paid_cost`,
-			ckrhc.`event_order_paid_purchase_amount`,
-			ckrhc.`event_order_paid`,
-			ckrhc.`event_credit_grant_app_ratio`,
-			ckrhc.`event_credit_grant_app_cost`,
-			ckrhc.`event_credit_grant_app`,
-			ckrhc.`event_pay_purchase_amount_first_day`,
-			ckrhc.`event_jin_jian_app_cost`,
-			ckrhc.`event_jin_jian_app`,
-			ckrhc.`event_register_cost`,
-			ckrhc.`event_register`,
-			ckrhc.`event_pay_roi`,
-			ckrhc.`event_pay_purchase_amount`,
-			ckrhc.`event_pay`,
-			ckrhc.`event_pay_first_day_roi`,
-			ckrhc.`event_pay_first_day`,
-			ckrhc.`photo_click_cost`,
-			ckrhc.`action_cost`,
-			ckrhc.`share`,
-			ckrhc.`comment`,
-			ckrhc.`photo_like`,
-			ckrhc.`follow`,
-			ckrhc.`report`,
-			ckrhc.`block`,
-			ckrhc.`negative`,
-			ckrhc.`activation`,
-			ckrhc.`submit`,
-			ckrhc.`cancel_follow`,
-			ckrhc.`download_started`,
-			ckrhc.`download_completed`,
-			ckrhc.`create_time`,
-			ckrhc.`update_time`,
-			ckvg.signature,
-			ckvg.url
-		FROM
-			(
-				SELECT
-					*
-				FROM
-					ctop_kuaishou_report_hourly_creative
-				WHERE
-					account_id = #{accountId} and stat_date = #{date}) ckrhc,
-					ctop_kuaishou_creative ckr,
-					ctop_user_allocation cua,
-					ctop_kuaishou_campaign ckc,
-					ctop_kuaishou_group ckg,
-					ctop_kuaishou_video_get ckvg
-				WHERE
-					ckrhc.creative_id = ckr.creative_id
-				AND ckr.account_id = cua.account_id
-				AND ckr.campaign_id = ckc.campaign_id
-				AND ckr.unit_id = ckg.unit_id
-				AND ckr.photo_id = ckvg.photo_id
-				AND ckr.account_id = ckvg.account_id
-			) t
-    </insert>
-
-	<delete id="deleteHourlyReport">
-		delete from ctop_kuaishou_report_hourly_creative where stat_date &lt;= #{date}
-	</delete>
-</mapper>

+ 0 - 22
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportHourlyCreativeStatisticService.java

@@ -1,22 +0,0 @@
-package cn.com.ctop.kuaishou.modules.report.service;
-
-import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCreativeStatistic;
-import com.baomidou.mybatisplus.extension.service.IService;
-
-import java.util.Date;
-
-/**
- * 时报清洗数据
- *
- * @author jeecg-boot
- * @version V1.0
- * @date 2019-11-01
- */
-public interface IKuaishouReportHourlyCreativeStatisticService extends IService<KuaishouReportHourlyCreativeStatistic> {
-
-    void updateCreativeReportHourlyStatistic(CtopOauthToken token, Date getDate);
-
-    void deleteHourlyReport(Date deleteDate);
-    void deleteHourlyReportByStatDate(String deleteDate);
-}

+ 0 - 44
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportHourlyCreativeStatisticServiceImpl.java

@@ -1,44 +0,0 @@
-package cn.com.ctop.kuaishou.modules.report.service.impl;
-
-import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCreativeStatistic;
-import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportHourlyCreativeStatisticMapper;
-import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyCreativeStatisticService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * 时报清洗数据
- *
- * @author jeecg-boot
- * @version V1.0
- * @date 2019-11-01
- */
-@Service
-public class KuaishouReportHourlyCreativeStatisticServiceImpl extends ServiceImpl<KuaishouReportHourlyCreativeStatisticMapper, KuaishouReportHourlyCreativeStatistic> implements IKuaishouReportHourlyCreativeStatisticService {
-    @Autowired
-    private KuaishouReportHourlyCreativeStatisticMapper statisticMapper;
-
-    @Override
-    public void updateCreativeReportHourlyStatistic(CtopOauthToken token, Date getDate) {
-        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
-        String dateString = format.format(getDate);
-        statisticMapper.updateCreativeReportHourlyStatistic(token.getAccountId(), dateString);
-    }
-
-    @Override
-    public void deleteHourlyReport(Date deleteDate) {
-        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
-        String dateString = format.format(deleteDate);
-        statisticMapper.deleteHourlyReport(dateString);
-    }
-
-    @Override
-    public void deleteHourlyReportByStatDate(String deleteDate) {
-        statisticMapper.deleteHourlyReport(deleteDate);
-    }
-}

+ 243 - 0
module-report/src/main/java/cn/com/ctop/bytedance/controller/BytedanceDailyReportTaskController.java

@@ -0,0 +1,243 @@
+package cn.com.ctop.bytedance.controller;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.util.oConvertUtils;
+import cn.com.ctop.bytedance.entity.BytedanceDailyReportTask;
+import cn.com.ctop.bytedance.service.IBytedanceDailyReportTaskService;
+import java.util.Date;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.extern.slf4j.Slf4j;
+
+import org.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 com.alibaba.fastjson.JSON;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+ /**
+ * 头条异步报表任务表
+ * @author jeecg-boot
+ * @date   2020-04-16
+ * @version V1.0
+ */
+@Slf4j
+@Api(tags="头条异步报表任务表")
+@RestController
+@RequestMapping("/bytedance/bytedanceDailyReportTask")
+public class BytedanceDailyReportTaskController {
+	@Autowired
+	private IBytedanceDailyReportTaskService bytedanceDailyReportTaskService;
+	
+	/**
+	  * 分页列表查询
+	 * @param bytedanceDailyReportTask
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@AutoLog(value = "头条异步报表任务表-分页列表查询")
+	@ApiOperation(value="头条异步报表任务表-分页列表查询", notes="头条异步报表任务表-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<BytedanceDailyReportTask>> queryPageList(BytedanceDailyReportTask bytedanceDailyReportTask,
+									  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+									  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+									  HttpServletRequest req) {
+		Result<IPage<BytedanceDailyReportTask>> result = new Result<IPage<BytedanceDailyReportTask>>();
+		QueryWrapper<BytedanceDailyReportTask> queryWrapper = QueryGenerator.initQueryWrapper(bytedanceDailyReportTask, req.getParameterMap());
+		Page<BytedanceDailyReportTask> page = new Page<BytedanceDailyReportTask>(pageNo, pageSize);
+		IPage<BytedanceDailyReportTask> pageList = bytedanceDailyReportTaskService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+	
+	/**
+	  *   添加
+	 * @param bytedanceDailyReportTask
+	 * @return
+	 */
+	@AutoLog(value = "头条异步报表任务表-添加")
+	@ApiOperation(value="头条异步报表任务表-添加", notes="头条异步报表任务表-添加")
+	@PostMapping(value = "/add")
+	public Result<BytedanceDailyReportTask> add(@RequestBody BytedanceDailyReportTask bytedanceDailyReportTask) {
+		Result<BytedanceDailyReportTask> result = new Result<BytedanceDailyReportTask>();
+		try {
+			bytedanceDailyReportTaskService.save(bytedanceDailyReportTask);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+	
+	/**
+	  *  编辑
+	 * @param bytedanceDailyReportTask
+	 * @return
+	 */
+	@AutoLog(value = "头条异步报表任务表-编辑")
+	@ApiOperation(value="头条异步报表任务表-编辑", notes="头条异步报表任务表-编辑")
+	@PutMapping(value = "/edit")
+	public Result<BytedanceDailyReportTask> edit(@RequestBody BytedanceDailyReportTask bytedanceDailyReportTask) {
+		Result<BytedanceDailyReportTask> result = new Result<BytedanceDailyReportTask>();
+		BytedanceDailyReportTask bytedanceDailyReportTaskEntity = bytedanceDailyReportTaskService.getById(bytedanceDailyReportTask.getId());
+		if(bytedanceDailyReportTaskEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = bytedanceDailyReportTaskService.updateById(bytedanceDailyReportTask);
+			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 {
+			bytedanceDailyReportTaskService.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<BytedanceDailyReportTask> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		Result<BytedanceDailyReportTask> result = new Result<BytedanceDailyReportTask>();
+		if(ids==null || "".equals(ids.trim())) {
+			result.error500("参数不识别!");
+		}else {
+			this.bytedanceDailyReportTaskService.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<BytedanceDailyReportTask> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<BytedanceDailyReportTask> result = new Result<BytedanceDailyReportTask>();
+		BytedanceDailyReportTask bytedanceDailyReportTask = bytedanceDailyReportTaskService.getById(id);
+		if(bytedanceDailyReportTask==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(bytedanceDailyReportTask);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+
+  /**
+      * 导出excel
+   *
+   * @param request
+   * @param response
+   */
+  @RequestMapping(value = "/exportXls")
+  public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+      // Step.1 组装查询条件
+      QueryWrapper<BytedanceDailyReportTask> queryWrapper = null;
+      try {
+          String paramsStr = request.getParameter("paramsStr");
+          if (oConvertUtils.isNotEmpty(paramsStr)) {
+              String deString = URLDecoder.decode(paramsStr, "UTF-8");
+              BytedanceDailyReportTask bytedanceDailyReportTask = JSON.parseObject(deString, BytedanceDailyReportTask.class);
+              queryWrapper = QueryGenerator.initQueryWrapper(bytedanceDailyReportTask, request.getParameterMap());
+          }
+      } catch (UnsupportedEncodingException e) {
+          e.printStackTrace();
+      }
+
+      //Step.2 AutoPoi 导出Excel
+      ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+      List<BytedanceDailyReportTask> pageList = bytedanceDailyReportTaskService.list(queryWrapper);
+      //导出文件名称
+      mv.addObject(NormalExcelConstants.FILE_NAME, "头条异步报表任务表列表");
+      mv.addObject(NormalExcelConstants.CLASS, BytedanceDailyReportTask.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<BytedanceDailyReportTask> listBytedanceDailyReportTasks = ExcelImportUtil.importExcel(file.getInputStream(), BytedanceDailyReportTask.class, params);
+              bytedanceDailyReportTaskService.saveBatch(listBytedanceDailyReportTasks);
+              return Result.ok("文件导入成功!数据行数:" + listBytedanceDailyReportTasks.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("文件导入失败!");
+  }
+
+}

+ 66 - 4
module-report/src/main/java/cn/com/ctop/bytedance/controller/BytedanceReportController.java

@@ -1,15 +1,18 @@
 package cn.com.ctop.bytedance.controller;
 
 import cn.com.ctop.bytedance.service.IBytedanceReportService;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
 import com.alibaba.fastjson.JSONObject;
 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.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
+import java.util.Date;
 import java.util.List;
 
 @Slf4j
@@ -18,6 +21,8 @@ import java.util.List;
 public class BytedanceReportController {
     @Autowired
     private IBytedanceReportService bytedanceReportService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
 
     /**
      * 昨日总花费
@@ -93,5 +98,62 @@ public class BytedanceReportController {
 
     }
 
+    @PostMapping("/bytedance/async")
+    public Result<List<JSONObject>> asyncTaskCreate(@RequestBody JSONObject requestJson) {
+
+        Result<List<JSONObject>> result = new Result<>();
+        try {
+            bytedanceReportService.bytedanceAsyncTaskCreate();
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return result;
+
+    }
+
+    @PostMapping("/bytedance/async/taskGet")
+    public Result<List<JSONObject>> bytedanceAsyncTaskGet(@RequestBody JSONObject requestJson) {
+        Result<List<JSONObject>> result = new Result<>();
+        try {
+            bytedanceReportService.bytedanceAsyncTaskGet();
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return result;
+    }
+
+    @GetMapping("/bytedance/bytedanceMaterialReport")
+    public Result bytedanceMaterialReport(@RequestParam(name = "startDate")String startDate,
+                                                            @RequestParam(name = "endDate")String endDate) {
+        Result result = new Result<>();
+        if (StringUtils.isBlank(startDate) || StringUtils.isBlank(endDate)){
+            result.error500("开始时间和结束时间不能为空");
+            return result;
+        }
+
+        try {
+            log.info("头条获取素材报表数据任务执行开始");
+            Long start = System.currentTimeMillis();
+            List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
+            if (null == tokens || tokens.size() <= 0) {
+                log.info("头条获取素材报表数据任务执行失败:未获取到可用的token");
+                return result;
+            }
+            for (CtopOauthToken token : tokens) {
+                //if(token.getAccountId() == 1662649623517198L){
+                    bytedanceReportService.bytedanceMaterialReport(token,startDate,endDate);
+                //}
+            }
+            Long end = System.currentTimeMillis();
+            log.info("头条获取素材报表数据任务执行结束,执行耗时:{}秒", (end - start) / 1000);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return result;
+    }
 
 }

+ 243 - 0
module-report/src/main/java/cn/com/ctop/bytedance/controller/BytedanceReportMaterialDailyController.java

@@ -0,0 +1,243 @@
+package cn.com.ctop.bytedance.controller;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.util.oConvertUtils;
+import cn.com.ctop.bytedance.entity.BytedanceReportMaterialDaily;
+import cn.com.ctop.bytedance.service.IBytedanceReportMaterialDailyService;
+import java.util.Date;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.extern.slf4j.Slf4j;
+
+import org.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 com.alibaba.fastjson.JSON;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+ /**
+ * 素材报表
+ * @author jeecg-boot
+ * @date   2020-04-16
+ * @version V1.0
+ */
+@Slf4j
+@Api(tags="素材报表")
+@RestController
+@RequestMapping("/bytedance/bytedanceReportMaterialDaily")
+public class BytedanceReportMaterialDailyController {
+	@Autowired
+	private IBytedanceReportMaterialDailyService bytedanceReportMaterialDailyService;
+	
+	/**
+	  * 分页列表查询
+	 * @param bytedanceReportMaterialDaily
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@AutoLog(value = "素材报表-分页列表查询")
+	@ApiOperation(value="素材报表-分页列表查询", notes="素材报表-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<BytedanceReportMaterialDaily>> queryPageList(BytedanceReportMaterialDaily bytedanceReportMaterialDaily,
+									  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+									  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+									  HttpServletRequest req) {
+		Result<IPage<BytedanceReportMaterialDaily>> result = new Result<IPage<BytedanceReportMaterialDaily>>();
+		QueryWrapper<BytedanceReportMaterialDaily> queryWrapper = QueryGenerator.initQueryWrapper(bytedanceReportMaterialDaily, req.getParameterMap());
+		Page<BytedanceReportMaterialDaily> page = new Page<BytedanceReportMaterialDaily>(pageNo, pageSize);
+		IPage<BytedanceReportMaterialDaily> pageList = bytedanceReportMaterialDailyService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+	
+	/**
+	  *   添加
+	 * @param bytedanceReportMaterialDaily
+	 * @return
+	 */
+	@AutoLog(value = "素材报表-添加")
+	@ApiOperation(value="素材报表-添加", notes="素材报表-添加")
+	@PostMapping(value = "/add")
+	public Result<BytedanceReportMaterialDaily> add(@RequestBody BytedanceReportMaterialDaily bytedanceReportMaterialDaily) {
+		Result<BytedanceReportMaterialDaily> result = new Result<BytedanceReportMaterialDaily>();
+		try {
+			bytedanceReportMaterialDailyService.save(bytedanceReportMaterialDaily);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+	
+	/**
+	  *  编辑
+	 * @param bytedanceReportMaterialDaily
+	 * @return
+	 */
+	@AutoLog(value = "素材报表-编辑")
+	@ApiOperation(value="素材报表-编辑", notes="素材报表-编辑")
+	@PutMapping(value = "/edit")
+	public Result<BytedanceReportMaterialDaily> edit(@RequestBody BytedanceReportMaterialDaily bytedanceReportMaterialDaily) {
+		Result<BytedanceReportMaterialDaily> result = new Result<BytedanceReportMaterialDaily>();
+		BytedanceReportMaterialDaily bytedanceReportMaterialDailyEntity = bytedanceReportMaterialDailyService.getById(bytedanceReportMaterialDaily.getId());
+		if(bytedanceReportMaterialDailyEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = bytedanceReportMaterialDailyService.updateById(bytedanceReportMaterialDaily);
+			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 {
+			bytedanceReportMaterialDailyService.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<BytedanceReportMaterialDaily> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		Result<BytedanceReportMaterialDaily> result = new Result<BytedanceReportMaterialDaily>();
+		if(ids==null || "".equals(ids.trim())) {
+			result.error500("参数不识别!");
+		}else {
+			this.bytedanceReportMaterialDailyService.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<BytedanceReportMaterialDaily> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<BytedanceReportMaterialDaily> result = new Result<BytedanceReportMaterialDaily>();
+		BytedanceReportMaterialDaily bytedanceReportMaterialDaily = bytedanceReportMaterialDailyService.getById(id);
+		if(bytedanceReportMaterialDaily==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(bytedanceReportMaterialDaily);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+
+  /**
+      * 导出excel
+   *
+   * @param request
+   * @param response
+   */
+  @RequestMapping(value = "/exportXls")
+  public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+      // Step.1 组装查询条件
+      QueryWrapper<BytedanceReportMaterialDaily> queryWrapper = null;
+      try {
+          String paramsStr = request.getParameter("paramsStr");
+          if (oConvertUtils.isNotEmpty(paramsStr)) {
+              String deString = URLDecoder.decode(paramsStr, "UTF-8");
+              BytedanceReportMaterialDaily bytedanceReportMaterialDaily = JSON.parseObject(deString, BytedanceReportMaterialDaily.class);
+              queryWrapper = QueryGenerator.initQueryWrapper(bytedanceReportMaterialDaily, request.getParameterMap());
+          }
+      } catch (UnsupportedEncodingException e) {
+          e.printStackTrace();
+      }
+
+      //Step.2 AutoPoi 导出Excel
+      ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+      List<BytedanceReportMaterialDaily> pageList = bytedanceReportMaterialDailyService.list(queryWrapper);
+      //导出文件名称
+      mv.addObject(NormalExcelConstants.FILE_NAME, "素材报表列表");
+      mv.addObject(NormalExcelConstants.CLASS, BytedanceReportMaterialDaily.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<BytedanceReportMaterialDaily> listBytedanceReportMaterialDailys = ExcelImportUtil.importExcel(file.getInputStream(), BytedanceReportMaterialDaily.class, params);
+              bytedanceReportMaterialDailyService.saveBatch(listBytedanceReportMaterialDailys);
+              return Result.ok("文件导入成功!数据行数:" + listBytedanceReportMaterialDailys.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("文件导入失败!");
+  }
+
+}

+ 73 - 0
module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceDailyReportTask.java

@@ -0,0 +1,73 @@
+package cn.com.ctop.bytedance.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 头条异步报表任务表
+ * @author jeecg-boot
+ * @date   2020-04-16
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_bytedance_daily_report_task")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_bytedance_daily_report_task对象", description="头条异步报表任务表")
+public class BytedanceDailyReportTask {
+
+	/**主键ID*/
+	@TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "主键ID")
+	private Integer id;
+	/**广告账户ID(相当于头条返回的access_token数据中的advertiser_id)*/
+	@Excel(name = "广告账户ID(相当于头条返回的access_token数据中的advertiser_id)", width = 15)
+    @ApiModelProperty(value = "广告账户ID(相当于头条返回的access_token数据中的advertiser_id)")
+	private Long accountId;
+	/**任务id*/
+	@Excel(name = "任务id", width = 15)
+    @ApiModelProperty(value = "任务id")
+	private Long taskId;
+	/**任务名称*/
+	@Excel(name = "任务名称", width = 15)
+    @ApiModelProperty(value = "任务名称")
+	private String taskName;
+	/**任务类型REPORT-普通报表;REPORT_DPA-DPA报表;REPORT_BIDWORD-关键词/搜索词报表*/
+	@Excel(name = "任务类型REPORT-普通报表;REPORT_DPA-DPA报表;REPORT_BIDWORD-关键词/搜索词报表", width = 15)
+    @ApiModelProperty(value = "任务类型REPORT-普通报表;REPORT_DPA-DPA报表;REPORT_BIDWORD-关键词/搜索词报表")
+	private String taskType;
+	/**任务创建时间*/
+	@Excel(name = "任务创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "任务创建时间")
+	private Date taskCreateTime;
+	/**任务参数*/
+	@Excel(name = "任务参数", width = 15)
+    @ApiModelProperty(value = "任务参数")
+	private Object taskParams;
+	/**返回参数*/
+	@Excel(name = "返回参数", width = 15)
+    @ApiModelProperty(value = "返回参数")
+	private Object json;
+	/**创建时间*/
+    @ApiModelProperty(value = "创建时间")
+	private Date createTime;
+	/**修改时间*/
+    @ApiModelProperty(value = "修改时间")
+	private Date updateTime;
+
+    private String taskStatus;
+}

+ 448 - 0
module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceReportMaterialDaily.java

@@ -0,0 +1,448 @@
+package cn.com.ctop.bytedance.entity;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 素材报表
+ * @author jeecg-boot
+ * @date   2020-04-16
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_bytedance_report_material_daily")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_bytedance_report_material_daily对象", description="素材报表")
+public class BytedanceReportMaterialDaily {
+
+	/**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;
+	///**展示量*/
+	//@Excel(name = "展示量", width = 15)
+    //@ApiModelProperty(value = "展示量")
+	//private Integer showNum;
+	/**点击量1*/
+	@Excel(name = "点击量1", width = 15)
+    @ApiModelProperty(value = "点击量1")
+	private Integer click;
+	///**转化量*/
+	//@Excel(name = "转化量", width = 15)
+    //@ApiModelProperty(value = "转化量")
+	//private Integer convertNum;
+	/**总花费1*/
+	@Excel(name = "总花费1", width = 15)
+    @ApiModelProperty(value = "总花费1")
+	private java.math.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 clickInstall;
+	/**应用下载-安卓安装完成*/
+	@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;
+	///**互动数据-点赞数*/
+	//@Excel(name = "互动数据-点赞数", width = 15)
+    //@ApiModelProperty(value = "互动数据-点赞数")
+	//private Integer likeNum;
+	/**互动数据-关注数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;
+	///**互动数据-单次互动成本*/
+	//@Excel(name = "互动数据-单次互动成本", width = 15)
+    //@ApiModelProperty(value = "互动数据-单次互动成本")
+	//private java.math.BigDecimal interactPerCost;
+	/**次留数1*/
+	@Excel(name = "次留数1", width = 15)
+    @ApiModelProperty(value = "次留数1")
+	private Integer nextDayOpen;
+	/**次留率1*/
+	@Excel(name = "次留率1", width = 15)
+    @ApiModelProperty(value = "次留率1")
+	private java.math.BigDecimal nextDayOpenRate;
+	/**次留成本*/
+	@Excel(name = "次留成本", width = 15)
+    @ApiModelProperty(value = "次留成本")
+	private java.math.BigDecimal nextDayOpenCost;
+	///**createTime*/
+    //@ApiModelProperty(value = "createTime")
+	//private Date createTime;
+	///**updateTime*/
+    //@ApiModelProperty(value = "updateTime")
+	//private Date updateTime;
+	/**素材类型*/
+	@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 java.math.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 java.math.BigDecimal activePayCost;
+	/**download*/
+	@Excel(name = "download", width = 15)
+    @ApiModelProperty(value = "download")
+	private Integer download;
+	/**cpa*/
+	@Excel(name = "cpa", width = 15)
+    @ApiModelProperty(value = "cpa")
+	private java.math.BigDecimal cpa;
+	/**cpc*/
+	@Excel(name = "cpc", width = 15)
+    @ApiModelProperty(value = "cpc")
+	private java.math.BigDecimal cpc;
+	/**locationClick*/
+	@Excel(name = "locationClick", width = 15)
+    @ApiModelProperty(value = "locationClick")
+	private Integer locationClick;
+	/**playOverRate*/
+	@Excel(name = "playOverRate", width = 15)
+    @ApiModelProperty(value = "playOverRate")
+	private java.math.BigDecimal playOverRate;
+	/**ctr*/
+	@Excel(name = "ctr", width = 15)
+    @ApiModelProperty(value = "ctr")
+	private java.math.BigDecimal ctr;
+	/**cpm*/
+	@Excel(name = "cpm", width = 15)
+    @ApiModelProperty(value = "cpm")
+	private java.math.BigDecimal cpm;
+	/**wifiPlayRate*/
+	@Excel(name = "wifiPlayRate", width = 15)
+    @ApiModelProperty(value = "wifiPlayRate")
+	private java.math.BigDecimal wifiPlayRate;
+	/**like*/
+	@Excel(name = "like", width = 15)
+    @ApiModelProperty(value = "like")
+	private Integer likeMaterial;
+	/**activePayRate*/
+	@Excel(name = "activePayRate", width = 15)
+    @ApiModelProperty(value = "activePayRate")
+	private java.math.BigDecimal activePayRate;
+	/**activeCost*/
+	@Excel(name = "activeCost", width = 15)
+    @ApiModelProperty(value = "activeCost")
+	private java.math.BigDecimal activeCost;
+	/**gameAddictionCost*/
+	@Excel(name = "gameAddictionCost", width = 15)
+    @ApiModelProperty(value = "gameAddictionCost")
+	private java.math.BigDecimal gameAddictionCost;
+	/**gameAddiction*/
+	@Excel(name = "gameAddiction", width = 15)
+    @ApiModelProperty(value = "gameAddiction")
+	private Integer gameAddiction;
+	/**activeRate*/
+	@Excel(name = "activeRate", width = 15)
+    @ApiModelProperty(value = "activeRate")
+	private java.math.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 java.math.BigDecimal gameAddictionRate;
+	/**activeRegisterRate*/
+	@Excel(name = "activeRegisterRate", width = 15)
+    @ApiModelProperty(value = "activeRegisterRate")
+	private java.math.BigDecimal activeRegisterRate;
+	/**averageVideoPlay*/
+	@Excel(name = "averageVideoPlay", width = 15)
+    @ApiModelProperty(value = "averageVideoPlay")
+	private java.math.BigDecimal averageVideoPlay;
+	/**downloadFinishCost*/
+	@Excel(name = "downloadFinishCost", width = 15)
+    @ApiModelProperty(value = "downloadFinishCost")
+	private java.math.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 java.math.BigDecimal activeRegisterCost;
+	/**show*/
+	@Excel(name = "show", width = 15)
+    @ApiModelProperty(value = "show")
+	private Integer showMaterial;
+	/**convertRate*/
+	@Excel(name = "convertRate", width = 15)
+    @ApiModelProperty(value = "convertRate")
+	private java.math.BigDecimal convertRate;
+	/**downloadFinishRate*/
+	@Excel(name = "downloadFinishRate", width = 15)
+    @ApiModelProperty(value = "downloadFinishRate")
+	private java.math.BigDecimal downloadFinishRate;
+	/**installFinishRate*/
+	@Excel(name = "installFinishRate", width = 15)
+    @ApiModelProperty(value = "installFinishRate")
+	private java.math.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;
+	///**installFinsih*/
+	//@Excel(name = "installFinsih", width = 15)
+    //@ApiModelProperty(value = "installFinsih")
+	//private Integer installFinsih;
+	/**playOver*/
+	@Excel(name = "playOver", width = 15)
+    @ApiModelProperty(value = "playOver")
+	private Integer playOver;
+	/**downloadStartCost*/
+	@Excel(name = "downloadStartCost", width = 15)
+    @ApiModelProperty(value = "downloadStartCost")
+	private java.math.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 java.math.BigDecimal validPlayRate;
+	/**averagePlayTimePerPlay*/
+	@Excel(name = "averagePlayTimePerPlay", width = 15)
+    @ApiModelProperty(value = "averagePlayTimePerPlay")
+	private java.math.BigDecimal averagePlayTimePerPlay;
+	/**convertCost*/
+	@Excel(name = "convertCost", width = 15)
+    @ApiModelProperty(value = "convertCost")
+	private java.math.BigDecimal convertCost;
+	/**convertShowRate*/
+	@Excel(name = "convertShowRate", width = 15)
+    @ApiModelProperty(value = "convertShowRate")
+	private java.math.BigDecimal convertShowRate;
+	/**installFinishCost*/
+	@Excel(name = "installFinishCost", width = 15)
+    @ApiModelProperty(value = "installFinishCost")
+	private java.math.BigDecimal installFinishCost;
+
+	private BigDecimal downloadStartRate;
+}

+ 17 - 0
module-report/src/main/java/cn/com/ctop/bytedance/mapper/BytedanceDailyReportTaskMapper.java

@@ -0,0 +1,17 @@
+package cn.com.ctop.bytedance.mapper;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+import cn.com.ctop.bytedance.entity.BytedanceDailyReportTask;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 头条异步报表任务表
+ * @author: jeecg-boot
+ * @date:   2020-04-16
+ * @cersion: V1.0
+ */
+public interface BytedanceDailyReportTaskMapper extends BaseMapper<BytedanceDailyReportTask> {
+
+}

+ 18 - 0
module-report/src/main/java/cn/com/ctop/bytedance/mapper/BytedanceReportMaterialDailyMapper.java

@@ -0,0 +1,18 @@
+package cn.com.ctop.bytedance.mapper;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+import cn.com.ctop.bytedance.entity.BytedanceReportMaterialDaily;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 素材报表
+ * @author: jeecg-boot
+ * @date:   2020-04-16
+ * @cersion: V1.0
+ */
+public interface BytedanceReportMaterialDailyMapper extends BaseMapper<BytedanceReportMaterialDaily> {
+
+    void replaceIntoBatch(@Param("infos") List<BytedanceReportMaterialDaily> infos);
+}

+ 5 - 0
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/BytedanceDailyReportTaskMapper.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="cn.com.ctop.bytedance.mapper.BytedanceDailyReportTaskMapper">
+
+</mapper>

+ 208 - 0
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/BytedanceReportMaterialDailyMapper.xml

@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.bytedance.mapper.BytedanceReportMaterialDailyMapper">
+
+    <insert id="replaceIntoBatch">
+        REPLACE INTO ctop_bytedance_report_material_daily
+        (
+        account_id,
+        stat_datetime,
+        click,
+        cost,
+        active,
+        download_finish,
+        download_start,
+        install_finish,
+        register,
+        pay_count,
+        in_app_uv,
+        in_app_detail_uv,
+        in_app_cart,
+        in_app_order,
+        in_app_pay,
+        phone,
+        form,
+        map_search,
+        button,
+        view_material,
+        qq,
+        lottery,
+        vote,
+        redirect,
+        shopping,
+        consult,
+        wechat,
+        phone_confirm,
+        phone_connect,
+        consult_effective,
+        total_play,
+        valid_play,
+        wifi_play,
+        play_duration_sum,
+        play25_feed_break,
+        play50_feed_break,
+        play75_feed_break,
+        play100_feed_break,
+        advanced_creative_phone_click,
+        advanced_creative_counsel_click,
+        advanced_creative_form_click,
+        share_material,
+        comment_material,
+        follow,
+        home_visited,
+        ies_challenge_click,
+        ies_music_click,
+        next_day_open,
+        next_day_open_rate,
+        next_day_open_cost,
+        image_mode,
+        material_id,
+        inventory,
+        active_pay_amount,
+        valid_play_cost,
+        advanced_creative_coupon_addition,
+        convert_material,
+        active_pay_cost,
+        download,
+        cpa,
+        cpc,
+        location_click,
+        play_over_rate,
+        ctr,
+        cpm,
+        wifi_play_rate,
+        like_material,
+        active_pay_rate,
+        active_cost,
+        game_addiction_cost,
+        game_addiction,
+        active_rate,
+        play_duration_10s,
+        phone_effective,
+        game_addiction_rate,
+        active_register_rate,
+        average_video_play,
+        download_finish_cost,
+        play_duration_3s,
+        active_register_cost,
+        show_material,
+        convert_rate,
+        download_finish_rate,
+        install_finish_rate,
+        coupon,
+        coupon_single_page,
+        play_over,
+        download_start_cost,
+        message,
+        play_duration,
+        valid_play_rate,
+        average_play_time_per_play,
+        convert_cost,
+        convert_show_rate,
+        install_finish_cost,
+        download_start_rate
+        )
+        VALUES
+        <foreach collection="infos" item="info" separator=",">
+      (
+        #{info.accountId},
+        #{info.statDatetime},
+        #{info.click},
+        #{info.cost},
+        #{info.active},
+        #{info.downloadFinish},
+        #{info.downloadStart},
+        #{info.installFinish},
+        #{info.register},
+        #{info.payCount},
+        #{info.inAppUv},
+        #{info.inAppDetailUv},
+        #{info.inAppCart},
+        #{info.inAppOrder},
+        #{info.inAppPay},
+        #{info.phone},
+        #{info.form},
+        #{info.mapSearch},
+        #{info.button},
+        #{info.viewMaterial},
+        #{info.qq},
+        #{info.lottery},
+        #{info.vote},
+        #{info.redirect},
+        #{info.shopping},
+        #{info.consult},
+        #{info.wechat},
+        #{info.phoneConfirm},
+        #{info.phoneConnect},
+        #{info.consultEffective},
+        #{info.totalPlay},
+        #{info.validPlay},
+        #{info.wifiPlay},
+        #{info.playDurationSum},
+        #{info.play25FeedBreak},
+        #{info.play50FeedBreak},
+        #{info.play75FeedBreak},
+        #{info.play100FeedBreak},
+        #{info.advancedCreativePhoneClick},
+        #{info.advancedCreativeCounselClick},
+        #{info.advancedCreativeFormClick},
+        #{info.shareMaterial},
+        #{info.commentMaterial},
+        #{info.follow},
+        #{info.homeVisited},
+        #{info.iesChallengeClick},
+        #{info.iesMusicClick},
+        #{info.nextDayOpen},
+        #{info.nextDayOpenRate},
+        #{info.nextDayOpenCost},
+        #{info.imageMode},
+        #{info.materialId},
+        #{info.inventory},
+        #{info.activePayAmount},
+        #{info.validPlayCost},
+        #{info.advancedCreativeCouponAddition},
+        #{info.convertMaterial},
+        #{info.activePayCost},
+        #{info.download},
+        #{info.cpa},
+        #{info.cpc},
+        #{info.locationClick},
+        #{info.playOverRate},
+        #{info.ctr},
+        #{info.cpm},
+        #{info.wifiPlayRate},
+        #{info.likeMaterial},
+        #{info.activePayRate},
+        #{info.activeCost},
+        #{info.gameAddictionCost},
+        #{info.gameAddiction},
+        #{info.activeRate},
+        #{info.playDuration_10s},
+        #{info.phoneEffective},
+        #{info.gameAddictionRate},
+        #{info.activeRegisterRate},
+        #{info.averageVideoPlay},
+        #{info.downloadFinishCost},
+        #{info.playDuration_3s},
+        #{info.activeRegisterCost},
+        #{info.showMaterial},
+        #{info.convertRate},
+        #{info.downloadFinishRate},
+        #{info.installFinishRate},
+        #{info.coupon},
+        #{info.couponSinglePage},
+        #{info.playOver},
+        #{info.downloadStartCost},
+        #{info.message},
+        #{info.playDuration},
+        #{info.validPlayRate},
+        #{info.averagePlayTimePerPlay},
+        #{info.convertCost},
+        #{info.convertShowRate},
+        #{info.installFinishCost},
+        #{info.downloadStartRate}
+         )
+        </foreach>
+    </insert>
+
+</mapper>

+ 4 - 5
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/MaterialReportMapper.xml

@@ -92,9 +92,9 @@
         END
         ) conversionPrice, -- 转化单价
 
-        --  t2.url url, -- 视频url
+        -- t2.url url, -- 视频url
 
-        (SELECT  url
+        (SELECT url
         FROM ctop_kuaishou_video_get
         WHERE signature = t2.signature
         LIMIT 1
@@ -121,7 +121,6 @@
         limit 100;
 
 
-
     </select>
 
 
@@ -477,6 +476,7 @@
         sum(t1.photo_click) photoClick, -- 封面点击数
         sum(t1.aclick) aclick, -- 素材曝光数
         sum(t1.bclick) bclick, -- 行为数
+        sum(t1.download_completed) downloadCompleted, -- 安卓下载完成 数
         (case
         when sum(t1.photo_show) != 0
         then (sum(t1.photo_click) / sum(t1.photo_show))
@@ -536,7 +536,7 @@
         t1.account_id accountId
         from
         ctop_kuaishou_report_daily_creative t1
-        where  t1.account_id in
+        where t1.account_id in
         <foreach item="item" index="index" collection="accountIds"
                  open="(" separator="," close=")">
             #{item}
@@ -551,7 +551,6 @@
         and t1.signature is not null
         GROUP BY t1.signature
         order by sum(t1.charge) desc
-        limit 100
     </select>
 
 

+ 14 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/IBytedanceDailyReportTaskService.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.bytedance.service;
+
+import cn.com.ctop.bytedance.entity.BytedanceDailyReportTask;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 头条异步报表任务表
+ * @author jeecg-boot
+ * @date   2020-04-16
+ * @version V1.0
+ */
+public interface IBytedanceDailyReportTaskService extends IService<BytedanceDailyReportTask> {
+
+}

+ 14 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/IBytedanceReportMaterialDailyService.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.bytedance.service;
+
+import cn.com.ctop.bytedance.entity.BytedanceReportMaterialDaily;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 素材报表
+ * @author jeecg-boot
+ * @date   2020-04-16
+ * @version V1.0
+ */
+public interface IBytedanceReportMaterialDailyService extends IService<BytedanceReportMaterialDaily> {
+
+}

+ 9 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/IBytedanceReportService.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.bytedance.service;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import com.alibaba.fastjson.JSONObject;
 
 import java.util.List;
@@ -32,4 +33,12 @@ public interface IBytedanceReportService {
      * @return
      */
     List<JSONObject> getReportList(JSONObject requestJson);
+
+
+
+    void bytedanceAsyncTaskCreate();
+
+    void bytedanceAsyncTaskGet();
+
+    void bytedanceMaterialReport(CtopOauthToken token, String startDate, String endDate);
 }

+ 19 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/BytedanceDailyReportTaskServiceImpl.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.bytedance.service.impl;
+
+import cn.com.ctop.bytedance.entity.BytedanceDailyReportTask;
+import cn.com.ctop.bytedance.mapper.BytedanceDailyReportTaskMapper;
+import cn.com.ctop.bytedance.service.IBytedanceDailyReportTaskService;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * 头条异步报表任务表
+ * @author jeecg-boot
+ * @date   2020-04-16
+ * @version V1.0
+ */
+@Service
+public class BytedanceDailyReportTaskServiceImpl extends ServiceImpl<BytedanceDailyReportTaskMapper, BytedanceDailyReportTask> implements IBytedanceDailyReportTaskService {
+
+}

+ 19 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/BytedanceReportMaterialDailyServiceImpl.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.bytedance.service.impl;
+
+import cn.com.ctop.bytedance.entity.BytedanceReportMaterialDaily;
+import cn.com.ctop.bytedance.mapper.BytedanceReportMaterialDailyMapper;
+import cn.com.ctop.bytedance.service.IBytedanceReportMaterialDailyService;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * 素材报表
+ * @author jeecg-boot
+ * @date   2020-04-16
+ * @version V1.0
+ */
+@Service
+public class BytedanceReportMaterialDailyServiceImpl extends ServiceImpl<BytedanceReportMaterialDailyMapper, BytedanceReportMaterialDaily> implements IBytedanceReportMaterialDailyService {
+
+}

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

@@ -1,30 +1,53 @@
 package cn.com.ctop.bytedance.service.impl;
 
 import cn.com.ctop.bytedance.entity.BytedanceAdvertiserDailyReport;
+import cn.com.ctop.bytedance.entity.BytedanceDailyReportTask;
+import cn.com.ctop.bytedance.entity.BytedanceReportMaterialDaily;
 import cn.com.ctop.bytedance.mapper.BytedanceAdvertiserDailyReportMapper;
+import cn.com.ctop.bytedance.mapper.BytedanceDailyReportTaskMapper;
 import cn.com.ctop.bytedance.mapper.BytedanceReportMapper;
+import cn.com.ctop.bytedance.mapper.BytedanceReportMaterialDailyMapper;
+import cn.com.ctop.bytedance.service.IBytedanceDailyReportTaskService;
 import cn.com.ctop.bytedance.service.IBytedanceReportService;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
+import cn.com.ctop.kuaishou.modules.utils.DownloadUtils;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.net.URI;
+import java.util.*;
 
 @Service
+@Slf4j
 public class BytedanceReportServiceImpl implements IBytedanceReportService {
+
+    @Value("${jeecg.path.report-history}")
+    private String downloadPath;
     @Autowired
     private UserAllocationMapper userAllocationMapper;
 
@@ -37,6 +60,18 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
     @Autowired
     private KuaishouReportDailyAccountMapper kuaishouReportDailyAccountMapper;
 
+    @Autowired
+    private BytedanceDailyReportTaskMapper bytedanceDailyReportTaskMapper;
+
+    @Autowired
+    private IBytedanceDailyReportTaskService bytedanceDailyReportTaskService;
+
+    @Autowired
+    private ICtopOauthTokenService ctopOauthTokenService;
+
+    @Autowired
+    private BytedanceReportMaterialDailyMapper bytedanceReportMaterialDailyMapper;
+
     /**
      * 媒体昨日总消耗
      *
@@ -634,4 +669,545 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
         }
         return reportList;
     }
+
+    /////////////////////////////////////////////////////////////////////////////////////////////////
+    //创建异步任务
+    public void bytedanceAsyncTaskCreate () {
+        String startDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -1));
+        String endDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -31));
+        String type = "BYTEDANCE_LOAD_JOB_TYPE_ASYNC";
+        Long accountId = 1662649623517198L;
+
+        CtopOauthToken token = ctopOauthTokenService.getTokenByAccountId(accountId);
+        String access_token = token.getAccessToken();
+        Long advertiser_id = accountId;
+        //final Long[] ad_ids = new Long[]{1L};
+        //List<String> fields_list = FIELDS;
+        //ist<String> fields_list = new ArrayList<>();
+
+        // 请求地址
+        String open_api_domain = "https://ad.toutiao.com";
+        String path = "/open_api/2/async_task/create/";
+
+        String taskName = System.currentTimeMillis() + "";
+        // 请求参数
+        final Map filtering = new HashMap() {
+            {
+                //put("start_date", startDate);
+                //put("end_date", endDate);
+                put("start_date", "2020-04-01");
+                put("end_date", "2020-04-15");
+                put("group_by", new String[]{"STAT_GROUP_BY_CREATIVE_ID","STAT_GROUP_BY_TIME_DAY","STAT_GROUP_BY_CREATIVE_MATERIAL_MODE"});   //按照创意分组、天分组、创意类型分组查询
+            }
+        };
+        Map data = new HashMap() {
+            {
+                put("advertiser_id", advertiser_id);
+                put("task_name", taskName);
+                put("task_type", "REPORT");
+                put("task_params", filtering);
+            }
+        };
+
+        // 构造请求
+        HttpEntityEnclosingRequestBase httpEntity = new HttpEntityEnclosingRequestBase() {
+            @Override
+            public String getMethod() {
+                return "POST";
+            }
+        };
+
+        httpEntity.setHeader("Access-Token", access_token);
+
+        CloseableHttpResponse response = null;
+        CloseableHttpClient client = null;
+
+        try {
+            client = HttpClientBuilder.create().build();
+            httpEntity.setURI(URI.create(open_api_domain + path));
+            httpEntity.setEntity(new StringEntity(JSONObject.toJSONString(data), ContentType.APPLICATION_JSON));
+
+            response = client.execute(httpEntity);
+            if (response != null && response.getStatusLine().getStatusCode() == 200) {
+                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+                StringBuffer result = new StringBuffer();
+                String line = "";
+                while ((line = bufferedReader.readLine()) != null) {
+                    result.append(line);
+                }
+                bufferedReader.close();
+
+                JSONObject  json = JSONObject.parseObject(result.toString());
+                String jsonString = JSON.toJSONString(json);
+
+                if(!Check.isNull(json)){
+                    Integer code = json.getInteger("code");
+                    if(code != 0){
+                        log.info("返回信息错误,错误码为:" + code + ",头条accountId:" + accountId + ",message:"+ json.getString("message"));
+                        return;
+                    }
+                    JSONObject dataJson = json.getJSONObject("data");
+
+                    //解析数据并入库
+                    BytedanceDailyReportTask task = new BytedanceDailyReportTask();
+                    task.setAccountId(accountId);
+                    task.setTaskCreateTime(dataJson.getDate("create_time") == null ? null : dataJson.getDate("create_time"));
+                    task.setTaskId(dataJson.getLong("task_id") ==  null ? null : dataJson.getLong("task_id") );
+                    task.setTaskName(dataJson.getString("task_name") == null ? null : dataJson.getString("task_name"));
+                    task.setTaskParams(JSON.toJSONString(dataJson.getJSONObject("task_params")));
+                    task.setJson(jsonString);
+                    task.setTaskStatus(dataJson.getString("task_status"));
+                    task.setTaskType(dataJson.getString("task_type"));
+                    bytedanceDailyReportTaskMapper.insert(task);
+                }
+
+            }else{
+                log.error("请求有误:" + response );
+            }
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (response != null) {
+                    response.close();
+                }
+                client.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    //获取任务列表
+    public void bytedanceAsyncTaskGet(){
+        QueryWrapper<BytedanceDailyReportTask> taskQueryWrapper = new QueryWrapper<>();
+        //查询三种状态的信息--任务已创建、任务执行中、任务处理中
+        taskQueryWrapper.in("task_status", "ASYNC_TASK_STATUS_CREATED","ASYNC_TASK_STATUS_EXECUTING","ASYNC_TASK_STATUS_EXECUTING_STAGE2");
+        taskQueryWrapper.orderByDesc("create_time");
+        List<BytedanceDailyReportTask> taskList = bytedanceDailyReportTaskService.list(taskQueryWrapper);
+
+        if (!Check.isNull(taskList)) {
+            for (BytedanceDailyReportTask task : taskList) {
+                CtopOauthToken token = ctopOauthTokenService.getTokenByAccountId(task.getAccountId());
+
+                if (!Check.isNull(token)) {
+                    // 请求地址
+                    String open_api_domain = "https://ad.toutiao.com";
+                    String path = "/open_api/2/async_task/get/";
+
+                    String access_token = token.getAccessToken();
+                    Long accountId = task.getAccountId();
+                    final Long advertiser_id = accountId;
+                    //Long taskId = 682327L;
+
+                    // 请求参数
+                    final Map filtering = new HashMap() {
+                        {
+                            put("task_ids",new Long[]{task.getTaskId()});
+                            put("task_name", task.getTaskName());
+                        }
+                    };
+                    Map data = new HashMap(){
+                        {
+                            put("advertiser_id", advertiser_id);
+                            put("filtering", filtering);
+                        }
+                    };
+
+                    // 构造请求
+                    HttpEntityEnclosingRequestBase httpEntity = new HttpEntityEnclosingRequestBase() {
+                        @Override
+                        public String getMethod() {
+                            return "GET";
+                        }
+                    };
+
+                    httpEntity.setHeader("Access-Token",access_token);
+
+                    CloseableHttpResponse response = null;
+                    CloseableHttpClient client = null;
+
+                    try {
+                        client = HttpClientBuilder.create().build();
+                        httpEntity.setURI(URI.create(open_api_domain + path));
+                        httpEntity.setEntity(new StringEntity(JSONObject.toJSONString(data), ContentType.APPLICATION_JSON));
+
+                        response = client.execute(httpEntity);
+                        log.info("response为:" +  response);
+                        if (response != null && response.getStatusLine().getStatusCode() == 200) {
+                            BufferedReader bufferedReader  = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+                            StringBuffer result = new StringBuffer();
+                            String line = "";
+                            while((line = bufferedReader.readLine()) != null) {
+                                result.append(line);
+                            }
+                            bufferedReader.close();
+
+                            JSONObject  json = JSONObject.parseObject(result.toString());
+                            String jsonString = JSON.toJSONString(json);
+                            log.info("返回json为" + jsonString);
+
+                            if(!Check.isNull(json)){
+                                Integer code = json.getInteger("code");
+                                if(code != 0){
+                                    log.info("获取任务列表返回信息错误,错误码为:" + code + ",头条accountId:" + accountId + "taskId:" + task.getTaskId());
+                                    return;
+                                }
+
+                                JSONObject jsonData = json.getJSONObject("data");
+                                if (Check.isNull(jsonData)){
+                                    log.error("获取任务列表返回信息data内容为空");
+                                }
+                                JSONArray jsonArrayay = jsonData.getJSONArray("list");
+
+                                for (int i = 0; i < jsonArrayay.size(); i++) {
+                                    JSONObject detailJson = jsonArrayay.getJSONObject(i);
+                                    if (!Check.isNull(detailJson)) {
+                                        String taskStatus = detailJson.getString("task_status");
+
+                                        if (taskStatus .equals( "ASYNC_TASK_STATUS_COMPLETED")) {
+                                            bytedanceAsyncTaskDownload(task,token);
+                                        }
+                                            task.setTaskStatus(taskStatus);
+                                            bytedanceDailyReportTaskMapper.updateById(task);
+                                        }
+                                    }
+                                }
+
+                        }else{
+                            log.error("请求有误:" + response);
+                        }
+
+                    } catch (ClientProtocolException e) {
+                        e.printStackTrace();
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    } finally {
+                        try {
+                            if (response != null) {
+                                response.close();
+                            }
+                            client.close();
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                    }
+
+                }
+            }
+        }
+    }
+
+    //下载任务结果
+    private void bytedanceAsyncTaskDownload(BytedanceDailyReportTask task, CtopOauthToken token){
+        // 请求地址
+        String open_api_domain = "https://ad.toutiao.com";
+        String path = "/open_api/2/async_task/download/";
+
+        Long accountId = task.getAccountId();
+        final Long advertiser_id = accountId;
+        String access_token = token.getAccessToken();
+        Long taskId = task.getTaskId();
+
+        //Map data = new HashMap(){
+        //    {
+        //        put("advertiser_id", advertiser_id);
+        //        put("task_id", taskId);
+        //    }
+        //};
+        //
+        //// 构造请求
+        //HttpEntityEnclosingRequestBase httpEntity = new HttpEntityEnclosingRequestBase() {
+        //    @Override
+        //    public String getMethod() {
+        //        return "GET";
+        //    }
+        //};
+        //
+        //httpEntity.setHeader("Access-Token",access_token);
+        //
+        //CloseableHttpResponse response = null;
+        //CloseableHttpClient client = null;
+
+
+
+        try {
+            //client = HttpClientBuilder.create().build();
+            //httpEntity.setURI(URI.create(open_api_domain + path));
+            //httpEntity.setEntity(new StringEntity(JSONObject.toJSONString(data), ContentType.APPLICATION_JSON));
+            //
+            //response = client.execute(httpEntity);
+            //log.info("response为:" +  response);
+            //if (response != null && response.getStatusLine().getStatusCode() == 200) {
+            //    BufferedReader bufferedReader  = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+            //    StringBuffer result = new StringBuffer();
+            //    String line = "";
+            //    while((line = bufferedReader.readLine()) != null) {
+            //        result.append(line);
+            //    }
+            //    bufferedReader.close();
+
+            String url = open_api_domain + path;
+            String fileName = task.getAccountId() + "_" +  ".csv";
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("advertiser_id", task.getAccountId());
+            requestMap.put("task_id", task.getTaskId());
+            String localPath = DownloadUtils.downloadByUrl(requestMap, downloadPath, url, token.getAccessToken(), fileName);
+
+
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            //task.setTaskStatus(5);
+        }
+
+        return;
+    }
+
+
+
+
+    /////////////////////////////////////////////////////////\
+    //素材报表
+    public void bytedanceMaterialReport(CtopOauthToken token, String startDate, String endDate){
+        //CtopOauthToken token = ctopOauthTokenService.getTokenByAccountId(accountId);
+        Long accountId = token.getAccountId();
+        Integer page = 1;
+        Integer pageSize = 500;
+        bytedanceMaterialReportByPage(page, pageSize, token, accountId, startDate, endDate);
+    }
+
+    private void bytedanceMaterialReportByPage(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/";
+
+        // 请求参数
+        final Map filtering = new HashMap() {
+            {
+                put("image_mode",new String[]{"MATERIAL_IMAGE_MODE_TITLE"});
+            }
+        };
+
+        Map data = new HashMap(){
+            {
+                put("advertiser_id", accountId);
+                put("start_date",startDate);
+                put("end_date",endDate);
+                put("page",page);
+                put("page_size",pageSize);
+                put("group_by", new String[]{"STAT_GROUP_BY_MATERIAL_ID","STAT_GROUP_BY_INVENTORY","STAT_GROUP_BY_IMAGE_MODE","STAT_GROUP_BY_TIME_DAY"});
+                //put("group_by", new String[]{"STAT_GROUP_BY_MATERIAL_ID"});
+                //put("filtering",filtering);
+                //put("order_field","stat_datetime");
+                //put("order_type","ASC");
+            }
+        };
+
+        // 构造请求
+        HttpEntityEnclosingRequestBase httpEntity = new HttpEntityEnclosingRequestBase() {
+            @Override
+            public String getMethod() {
+                return "GET";
+            }
+        };
+
+        httpEntity.setHeader("Access-Token",access_token);
+
+        CloseableHttpResponse response = null;
+        CloseableHttpClient client = null;
+
+        try {
+            client = HttpClientBuilder.create().build();
+            httpEntity.setURI(URI.create(open_api_domain + path));
+            httpEntity.setEntity(new StringEntity(JSONObject.toJSONString(data), ContentType.APPLICATION_JSON));
+
+            response = client.execute(httpEntity);
+            //System.out.println(response);
+            if (response != null && response.getStatusLine().getStatusCode() == 200) {
+                BufferedReader bufferedReader  = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+                StringBuffer result = new StringBuffer();
+                String line = "";
+                while((line = bufferedReader.readLine()) != null) {
+                    result.append(line);
+                }
+                bufferedReader.close();
+
+                JSONObject  json = JSONObject.parseObject(result.toString());
+                String jsonString = JSON.toJSONString(json);
+                //log.info("返回值为:" + jsonString);
+
+                if(!Check.isNull(json)){
+                    Integer code = json.getInteger("code");
+                    if(code != 0){
+                        log.info("获取任务列表返回信息错误,错误码为:" + code + ",头条accountId:" + accountId );
+                        return;
+                    }
+
+                    JSONObject jsonData = json.getJSONObject("data");
+                    if (Check.isNull(jsonData)){
+                        log.error("获取任务列表返回信息data内容为空");
+                    }
+                    JSONObject pageInfo = jsonData.getJSONObject("page_info");
+                    Integer totalPage = pageInfo.getInteger("total_page");
+                    Integer currentPage = pageInfo.getInteger("page");
+
+                    JSONArray jsonArrayay = jsonData.getJSONArray("list");
+                    List<BytedanceReportMaterialDaily> bytedanceReportMaterialDailyList = new ArrayList<>();
+                    for (int i = 0; i < jsonArrayay.size(); i++) {
+                        BytedanceReportMaterialDaily daily = new BytedanceReportMaterialDaily();
+                        daily.setAccountId(accountId);
+                        JSONObject detailJson = jsonArrayay.getJSONObject(i);
+                        if (!Check.isNull(detailJson)) {
+                            JSONObject dimensions = detailJson.getJSONObject("dimensions");
+                            daily.setImageMode(dimensions.getString("image_mode"));
+                            daily.setMaterialId(dimensions.getLong("material_id"));
+                            daily.setInventory(dimensions.getString("inventory"));
+                            daily.setStatDatetime(dimensions.getDate("stat_datetime")==null?null:DateUtils.formatDate(dimensions.getDate("stat_datetime"),"yyyy-MM-dd"));
+
+                            JSONObject metrics = detailJson.getJSONObject("metrics");
+                            daily.setActivePayAmount(metrics.getInteger("active_pay_amount"));
+                            daily.setValidPlayCost(metrics.getBigDecimal("valid_play_cost"));
+                            daily.setPlay75FeedBreak(metrics.getInteger("play_75_feed_break"));
+                            daily.setNextDayOpen(metrics.getInteger("next_day_open"));
+                            daily.setAdvancedCreativeCouponAddition(metrics.getInteger("advanced_creative_coupon_addition"));
+                            daily.setConvertMaterial(metrics.getInteger("convert"));
+                            daily.setActivePayCost(metrics.getBigDecimal("active_pay_cost"));
+                            daily.setInAppCart(metrics.getInteger("in_app_cart"));
+                            daily.setPlay25FeedBreak(metrics.getInteger("play_25_feed_break"));
+                            daily.setConsultEffective(metrics.getInteger("consult_effective"));
+                            daily.setViewMaterial(metrics.getInteger("view"));
+                            daily.setDownload(metrics.getInteger("download"));
+                            daily.setCpa(metrics.getBigDecimal("cpa"));
+                            daily.setCpc(metrics.getBigDecimal("cpc"));
+                            daily.setLocationClick(metrics.getInteger("location_click"));
+                            daily.setPhoneConfirm(metrics.getInteger("phone_confirm"));
+                            daily.setIesMusicClick(metrics.getInteger("ies_music_click"));
+                            daily.setPlayOverRate(metrics.getBigDecimal("play_over_rate"));
+                            daily.setWifiPlay(metrics.getInteger("wifi_play"));
+                            daily.setShopping(metrics.getInteger("shopping"));
+                            daily.setQq(metrics.getInteger("qq"));
+                            daily.setCtr(metrics.getBigDecimal("ctr"));
+                            daily.setCpm(metrics.getBigDecimal("cpm"));
+                            daily.setWifiPlayRate(metrics.getBigDecimal("wifi_play_rate"));
+                            daily.setLikeMaterial(metrics.getInteger("like"));
+                            daily.setPlay50FeedBreak(metrics.getInteger("play_50_feed_break"));
+                            daily.setActivePayRate(metrics.getBigDecimal("active_pay_rate"));
+                            daily.setActiveCost(metrics.getBigDecimal("active_cost"));
+                            daily.setActive(metrics.getInteger("active"));
+                            daily.setGameAddictionCost(metrics.getBigDecimal("game_addiction_cost"));
+                            daily.setGameAddiction(metrics.getInteger("game_addiction"));
+                            daily.setActiveRate(metrics.getBigDecimal("active_rate"));
+                            daily.setClick(metrics.getInteger("click"));
+                            daily.setPlayDuration_10s(metrics.getInteger("play_duration_10s"));
+                            daily.setAdvancedCreativePhoneClick(metrics.getInteger("advanced_creative_phone_click"));
+                            daily.setDownloadStart(metrics.getInteger("download_start"));
+                            daily.setHomeVisited(metrics.getInteger("home_visited"));
+                            daily.setPhone(metrics.getInteger("phone"));
+                            daily.setPhoneEffective(metrics.getInteger("phone_effective"));
+                            daily.setInAppPay(metrics.getInteger("in_app_pay"));
+                            daily.setGameAddictionRate(metrics.getBigDecimal("game_addiction_rate"));
+                            daily.setNextDayOpenCost(metrics.getBigDecimal("next_day_open_cost"));
+                            daily.setIesChallengeClick(metrics.getInteger("ies_challenge_click"));
+                            daily.setTotalPlay(metrics.getInteger("total_play"));
+                            daily.setActiveRegisterRate(metrics.getBigDecimal("active_register_rate"));
+                            daily.setAverageVideoPlay(metrics.getBigDecimal("average_video_play"));
+                            daily.setDownloadFinishCost(metrics.getBigDecimal("download_finish_cost"));
+                            daily.setPlayDuration_3s(metrics.getInteger("play_duration_3s"));
+                            daily.setActiveRegisterCost(metrics.getBigDecimal("active_register_cost"));
+                            daily.setShowMaterial(metrics.getInteger("show"));
+                            daily.setNextDayOpenRate(metrics.getBigDecimal("next_day_open_rate"));
+                            daily.setMapSearch(metrics.getInteger("map_search"));
+                            daily.setButton(metrics.getInteger("button"));
+                            daily.setPlayDurationSum(metrics.getInteger("play_duration_sum"));
+                            daily.setPlay100FeedBreak(metrics.getInteger("play_100_feed_break"));
+                            daily.setAdvancedCreativeCounselClick(metrics.getInteger("advanced_creative_counsel_click"));
+                            daily.setConvertRate(metrics.getBigDecimal("convert_rate"));
+                            daily.setDownloadFinishRate(metrics.getBigDecimal("download_finish_rate"));
+                            daily.setConsult(metrics.getInteger("consult"));
+                            daily.setShareMaterial(metrics.getInteger("share"));
+                            daily.setVote(metrics.getInteger("vote"));
+                            daily.setValidPlay(metrics.getInteger("valid_play"));
+                            daily.setInstallFinishRate(metrics.getBigDecimal("install_finish_rate"));
+                            daily.setRedirect(metrics.getInteger("redirect"));
+                            daily.setPayCount(metrics.getInteger("pay_count"));
+                            daily.setAdvancedCreativeFormClick(metrics.getInteger("advanced_creative_form_click"));
+                            daily.setCost(metrics.getBigDecimal("cost"));
+                            daily.setPhoneConnect(metrics.getInteger("phone_connect"));
+                            daily.setCoupon(metrics.getInteger("coupon"));
+                            daily.setDownloadStartRate(metrics.getBigDecimal("download_start_rate"));
+                            daily.setDownloadFinish(metrics.getInteger("download_finish"));
+                            daily.setWechat(metrics.getInteger("wechat"));
+                            daily.setCouponSinglePage(metrics.getInteger("coupon_single_page"));
+                            daily.setInstallFinish(metrics.getInteger("install_finish"));
+                            daily.setLottery(metrics.getInteger("lottery"));
+                            daily.setPlayOver(metrics.getInteger("play_over"));
+                            daily.setInAppOrder(metrics.getInteger("in_app_order"));
+                            daily.setDownloadStartCost(metrics.getBigDecimal("download_start_cost"));
+                            daily.setFollow(metrics.getInteger("follow"));
+                            daily.setMessage(metrics.getInteger("message"));
+                            daily.setInAppDetailUv(metrics.getInteger("in_app_detail_uv"));
+                            daily.setPlayDuration(metrics.getInteger("play_duration"));
+                            daily.setForm(metrics.getInteger("form"));
+                            daily.setValidPlayRate(metrics.getBigDecimal("valid_play_rate"));
+                            daily.setAveragePlayTimePerPlay(metrics.getBigDecimal("average_play_time_per_play"));
+                            daily.setConvertShowRate(metrics.getBigDecimal("convert_show_rate"));
+                            daily.setInstallFinishCost(metrics.getBigDecimal("install_finish_cost"));
+                            daily.setCommentMaterial(metrics.getInteger("comment"));
+                            daily.setInAppUv(metrics.getInteger("in_app_uv"));
+                            daily.setRegister(metrics.getInteger("register"));
+                            daily.setConvertCost(metrics.getBigDecimal("convert_cost"));
+
+                            bytedanceReportMaterialDailyList.add(daily);
+                            //bytedanceReportMaterialDailyMapper.insert(daily);
+                        }
+                    }
+
+                    bytedanceReportMaterialDailyMapper.replaceIntoBatch(bytedanceReportMaterialDailyList);
+                    if(currentPage >= totalPage){
+                        return;
+                    }else{
+                        bytedanceMaterialReportByPage(page + 1, pageSize, token, accountId, startDate, endDate);
+                    }
+                }
+            }else{
+                log.error("头条素材报表请求有误:accountId:" + accountId + ",开始时间:" + startDate + "结束时间:" + endDate + "错误返回:" +response);
+            }
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (response != null) {
+                    response.close();
+                }
+                client.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
 }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 0 - 1
moudule-eureca/src/main/java/cn/com/ctop/eureca/server/ServerApplication.java

@@ -11,5 +11,4 @@ public class ServerApplication {
     public static void main(String[] args) {
         SpringApplication.run(ServerApplication.class, args);
     }
-
 }

+ 243 - 0
performance-appraisal/src/main/java/cn/com/ctop/accountvideoquarterinfo/controller/AccountVideoQuarterInfoController.java

@@ -0,0 +1,243 @@
+package cn.com.ctop.accountvideoquarterinfo.controller;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.util.oConvertUtils;
+import cn.com.ctop.accountvideoquarterinfo.entity.AccountVideoQuarterInfo;
+import cn.com.ctop.accountvideoquarterinfo.service.IAccountVideoQuarterInfoService;
+import java.util.Date;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.extern.slf4j.Slf4j;
+
+import org.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 com.alibaba.fastjson.JSON;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+ /**
+ * 绩效明细_账户下所有视频的季度消耗数据
+ * @author jeecg-boot
+ * @date   2020-04-13
+ * @version V1.0
+ */
+@Slf4j
+@Api(tags="绩效明细_账户下所有视频的季度消耗数据")
+@RestController
+@RequestMapping("/accountvideoquarterinfo/accountVideoQuarterInfo")
+public class AccountVideoQuarterInfoController {
+	@Autowired
+	private IAccountVideoQuarterInfoService accountVideoQuarterInfoService;
+	
+	/**
+	  * 分页列表查询
+	 * @param accountVideoQuarterInfo
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@AutoLog(value = "绩效明细_账户下所有视频的季度消耗数据-分页列表查询")
+	@ApiOperation(value="绩效明细_账户下所有视频的季度消耗数据-分页列表查询", notes="绩效明细_账户下所有视频的季度消耗数据-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<AccountVideoQuarterInfo>> queryPageList(AccountVideoQuarterInfo accountVideoQuarterInfo,
+									  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+									  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+									  HttpServletRequest req) {
+		Result<IPage<AccountVideoQuarterInfo>> result = new Result<IPage<AccountVideoQuarterInfo>>();
+		QueryWrapper<AccountVideoQuarterInfo> queryWrapper = QueryGenerator.initQueryWrapper(accountVideoQuarterInfo, req.getParameterMap());
+		Page<AccountVideoQuarterInfo> page = new Page<AccountVideoQuarterInfo>(pageNo, pageSize);
+		IPage<AccountVideoQuarterInfo> pageList = accountVideoQuarterInfoService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+	
+	/**
+	  *   添加
+	 * @param accountVideoQuarterInfo
+	 * @return
+	 */
+	@AutoLog(value = "绩效明细_账户下所有视频的季度消耗数据-添加")
+	@ApiOperation(value="绩效明细_账户下所有视频的季度消耗数据-添加", notes="绩效明细_账户下所有视频的季度消耗数据-添加")
+	@PostMapping(value = "/add")
+	public Result<AccountVideoQuarterInfo> add(@RequestBody AccountVideoQuarterInfo accountVideoQuarterInfo) {
+		Result<AccountVideoQuarterInfo> result = new Result<AccountVideoQuarterInfo>();
+		try {
+			accountVideoQuarterInfoService.save(accountVideoQuarterInfo);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+	
+	/**
+	  *  编辑
+	 * @param accountVideoQuarterInfo
+	 * @return
+	 */
+	@AutoLog(value = "绩效明细_账户下所有视频的季度消耗数据-编辑")
+	@ApiOperation(value="绩效明细_账户下所有视频的季度消耗数据-编辑", notes="绩效明细_账户下所有视频的季度消耗数据-编辑")
+	@PutMapping(value = "/edit")
+	public Result<AccountVideoQuarterInfo> edit(@RequestBody AccountVideoQuarterInfo accountVideoQuarterInfo) {
+		Result<AccountVideoQuarterInfo> result = new Result<AccountVideoQuarterInfo>();
+		AccountVideoQuarterInfo accountVideoQuarterInfoEntity = accountVideoQuarterInfoService.getById(accountVideoQuarterInfo.getId());
+		if(accountVideoQuarterInfoEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = accountVideoQuarterInfoService.updateById(accountVideoQuarterInfo);
+			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 {
+			accountVideoQuarterInfoService.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<AccountVideoQuarterInfo> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		Result<AccountVideoQuarterInfo> result = new Result<AccountVideoQuarterInfo>();
+		if(ids==null || "".equals(ids.trim())) {
+			result.error500("参数不识别!");
+		}else {
+			this.accountVideoQuarterInfoService.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<AccountVideoQuarterInfo> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<AccountVideoQuarterInfo> result = new Result<AccountVideoQuarterInfo>();
+		AccountVideoQuarterInfo accountVideoQuarterInfo = accountVideoQuarterInfoService.getById(id);
+		if(accountVideoQuarterInfo==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(accountVideoQuarterInfo);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+
+  /**
+      * 导出excel
+   *
+   * @param request
+   * @param response
+   */
+  @RequestMapping(value = "/exportXls")
+  public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+      // Step.1 组装查询条件
+      QueryWrapper<AccountVideoQuarterInfo> queryWrapper = null;
+      try {
+          String paramsStr = request.getParameter("paramsStr");
+          if (oConvertUtils.isNotEmpty(paramsStr)) {
+              String deString = URLDecoder.decode(paramsStr, "UTF-8");
+              AccountVideoQuarterInfo accountVideoQuarterInfo = JSON.parseObject(deString, AccountVideoQuarterInfo.class);
+              queryWrapper = QueryGenerator.initQueryWrapper(accountVideoQuarterInfo, request.getParameterMap());
+          }
+      } catch (UnsupportedEncodingException e) {
+          e.printStackTrace();
+      }
+
+      //Step.2 AutoPoi 导出Excel
+      ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+      List<AccountVideoQuarterInfo> pageList = accountVideoQuarterInfoService.list(queryWrapper);
+      //导出文件名称
+      mv.addObject(NormalExcelConstants.FILE_NAME, "绩效明细_账户下所有视频的季度消耗数据列表");
+      mv.addObject(NormalExcelConstants.CLASS, AccountVideoQuarterInfo.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<AccountVideoQuarterInfo> listAccountVideoQuarterInfos = ExcelImportUtil.importExcel(file.getInputStream(), AccountVideoQuarterInfo.class, params);
+              accountVideoQuarterInfoService.saveBatch(listAccountVideoQuarterInfos);
+              return Result.ok("文件导入成功!数据行数:" + listAccountVideoQuarterInfos.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("文件导入失败!");
+  }
+
+}

+ 113 - 0
performance-appraisal/src/main/java/cn/com/ctop/accountvideoquarterinfo/entity/AccountVideoQuarterInfo.java

@@ -0,0 +1,113 @@
+package cn.com.ctop.accountvideoquarterinfo.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 绩效明细_账户下所有视频的季度消耗数据
+ * @author jeecg-boot
+ * @date   2020-04-13
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_performance_account_video_quarter_info")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_performance_account_video_quarter_info对象", description="绩效明细_账户下所有视频的季度消耗数据")
+public class AccountVideoQuarterInfo {
+
+	/**id*/
+	@TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+	private Integer id;
+	/**accountId*/
+	@Excel(name = "accountId", width = 15)
+    @ApiModelProperty(value = "accountId")
+	private Long accountId;
+	/**projectId*/
+	@Excel(name = "projectId", width = 15)
+    @ApiModelProperty(value = "projectId")
+	private Long projectId;
+	/**projectName*/
+	@Excel(name = "projectName", width = 15)
+    @ApiModelProperty(value = "projectName")
+	private String projectName;
+	/**signature*/
+	@Excel(name = "signature", width = 15)
+    @ApiModelProperty(value = "signature")
+	private String signature;
+	/**designResponsibleName*/
+	@Excel(name = "designResponsibleName", width = 15)
+    @ApiModelProperty(value = "designResponsibleName")
+	private String designResponsibleName;
+	/**designResponsibleId*/
+	@Excel(name = "designResponsibleId", width = 15)
+    @ApiModelProperty(value = "designResponsibleId")
+	private String designResponsibleId;
+	/**planId*/
+	@Excel(name = "planId", width = 15)
+    @ApiModelProperty(value = "planId")
+	private String planId;
+	/**planName*/
+	@Excel(name = "planName", width = 15)
+    @ApiModelProperty(value = "planName")
+	private String planName;
+	/**clipId*/
+	@Excel(name = "clipId", width = 15)
+    @ApiModelProperty(value = "clipId")
+	private String clipId;
+	/**clipName*/
+	@Excel(name = "clipName", width = 15)
+    @ApiModelProperty(value = "clipName")
+	private String clipName;
+	/**shotId*/
+	@Excel(name = "shotId", width = 15)
+    @ApiModelProperty(value = "shotId")
+	private String shotId;
+	/**shotName*/
+	@Excel(name = "shotName", width = 15)
+    @ApiModelProperty(value = "shotName")
+	private String shotName;
+	/**planeId*/
+	@Excel(name = "planeId", width = 15)
+    @ApiModelProperty(value = "planeId")
+	private String planeId;
+	/**planeName*/
+	@Excel(name = "planeName", width = 15)
+    @ApiModelProperty(value = "planeName")
+	private String planeName;
+	/**videoCost*/
+	@Excel(name = "videoCost", width = 15)
+    @ApiModelProperty(value = "videoCost")
+	private java.math.BigDecimal videoCost;
+	/**appType*/
+	@Excel(name = "appType", width = 15)
+    @ApiModelProperty(value = "appType")
+	private Integer appType;
+	/**year*/
+	@Excel(name = "year", width = 15)
+    @ApiModelProperty(value = "year")
+	private Integer year;
+	/**quarter*/
+	@Excel(name = "quarter", width = 15)
+    @ApiModelProperty(value = "quarter")
+	private Integer quarter;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+}

+ 17 - 0
performance-appraisal/src/main/java/cn/com/ctop/accountvideoquarterinfo/mapper/AccountVideoQuarterInfoMapper.java

@@ -0,0 +1,17 @@
+package cn.com.ctop.accountvideoquarterinfo.mapper;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+import cn.com.ctop.accountvideoquarterinfo.entity.AccountVideoQuarterInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 绩效明细_账户下所有视频的季度消耗数据
+ * @author: jeecg-boot
+ * @date:   2020-04-13
+ * @cersion: V1.0
+ */
+public interface AccountVideoQuarterInfoMapper extends BaseMapper<AccountVideoQuarterInfo> {
+
+}

+ 5 - 0
performance-appraisal/src/main/java/cn/com/ctop/accountvideoquarterinfo/mapper/xml/AccountVideoQuarterInfoMapper.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="cn.com.ctop.accountvideoquarterinfo.mapper.AccountVideoQuarterInfoMapper">
+
+</mapper>

+ 14 - 0
performance-appraisal/src/main/java/cn/com/ctop/accountvideoquarterinfo/service/IAccountVideoQuarterInfoService.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.accountvideoquarterinfo.service;
+
+import cn.com.ctop.accountvideoquarterinfo.entity.AccountVideoQuarterInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 绩效明细_账户下所有视频的季度消耗数据
+ * @author jeecg-boot
+ * @date   2020-04-13
+ * @version V1.0
+ */
+public interface IAccountVideoQuarterInfoService extends IService<AccountVideoQuarterInfo> {
+
+}

+ 19 - 0
performance-appraisal/src/main/java/cn/com/ctop/accountvideoquarterinfo/service/impl/AccountVideoQuarterInfoServiceImpl.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.accountvideoquarterinfo.service.impl;
+
+import cn.com.ctop.accountvideoquarterinfo.entity.AccountVideoQuarterInfo;
+import cn.com.ctop.accountvideoquarterinfo.mapper.AccountVideoQuarterInfoMapper;
+import cn.com.ctop.accountvideoquarterinfo.service.IAccountVideoQuarterInfoService;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * 绩效明细_账户下所有视频的季度消耗数据
+ * @author jeecg-boot
+ * @date   2020-04-13
+ * @version V1.0
+ */
+@Service
+public class AccountVideoQuarterInfoServiceImpl extends ServiceImpl<AccountVideoQuarterInfoMapper, AccountVideoQuarterInfo> implements IAccountVideoQuarterInfoService {
+
+}

+ 33 - 1
performance-appraisal/src/main/java/cn/com/ctop/performanceappraisal/service/impl/PerformanceOptimizerServiceImpl.java

@@ -467,6 +467,10 @@ public class PerformanceOptimizerServiceImpl extends ServiceImpl<PerformanceOpti
             List<UserDto2> userList = userEfficientVideoMapMapper.getYunyingLeaderMember(userDto2.getDepId());
 
             for (UserDto2 user:userList){
+                //增加判断:如果项目成员中包含自己的话,不将自己的消耗计算在内
+                if(user.getUserId().equals(userDto2.getUserId())){
+                    continue;
+                }
                 BigDecimal userRoality = userEfficientVideoMapMapper.getYunyingRoyalty(user.getUserId(), year, quarter);
                 if (userRoality == null){
                     userRoality= BigDecimal.ZERO;
@@ -487,8 +491,36 @@ public class PerformanceOptimizerServiceImpl extends ServiceImpl<PerformanceOpti
     }
 
     //TODO 头条运营leader绩效计算
-    public void toutiaoYunyingLeaderQuarterPerformance(){
+    public void toutiaoYunyingLeaderQuarterPerformance(Integer year, Integer quarter){
+        Integer mediaType = 1;
+        //获取快手组下所有运营组长信息列表
+        List<UserDto2> yunyingLeaderList = userEfficientVideoMapMapper.getToutiaoYunyingLeaderUserInfo();
+        for(UserDto2 userDto2:yunyingLeaderList){
+            BigDecimal royalty = BigDecimal.ZERO;
+            List<UserDto2> userList = userEfficientVideoMapMapper.getYunyingLeaderMember(userDto2.getDepId());
 
+            for (UserDto2 user:userList){
+                //增加判断:如果项目成员中包含自己的话,不将自己的消耗计算在内
+                if(user.getUserId().equals(userDto2.getUserId())){
+                    continue;
+                }
+                BigDecimal userRoality = userEfficientVideoMapMapper.getYunyingRoyalty(user.getUserId(), year, quarter);
+                if (userRoality == null){
+                    userRoality= BigDecimal.ZERO;
+                }
+                royalty =  royalty.add(userRoality);
+            }
+            //运营leader绩效数据入库
+            PerformanceOptimizer performanceOptimizer = new PerformanceOptimizer();
+            performanceOptimizer.setAppType(mediaType);
+            performanceOptimizer.setQuarter(quarter + "");
+            performanceOptimizer.setYear(year + "");
+            performanceOptimizer.setRealname(userDto2.getRealname());
+            performanceOptimizer.setTotalCost(royalty);
+            performanceOptimizer.setTotalRoyalty( royalty.multiply(new BigDecimal("0.2")) );
+            performanceOptimizer.setUserId(userDto2.getUserId());
+            performanceOptimizerMapper.insert(performanceOptimizer);
+        }
 
     }
 

+ 4 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/entity/VideoDTO.java

@@ -14,9 +14,13 @@ public class VideoDTO implements Serializable {
     private BigDecimal charge;
     private String creativeUrl;
     private String shot;
+    private String shotId;
     private String plan;
+    private String planId;
     private String plane;
+    private String planeId;
     private String clip;
+    private String clipId;
     private Integer appType;
     private String weekStart;
     private String weekEnd;

+ 12 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/UserEfficientVideoMapMapper.java

@@ -55,6 +55,8 @@ public interface UserEfficientVideoMapMapper extends BaseMapper<UserEfficientVid
 
     BigDecimal getProjectQuarterCostById(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projectId") Long projectId);
 
+    BigDecimal getToutiaoProjectQuarterCostById(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projectId") Long projectId);
+
     List<UserDto2> getPlaneByProjectId(@Param("projectId") Long projectId);
 
     List<UserDto2> getKuaishouDesignLeaderList();
@@ -236,12 +238,22 @@ public interface UserEfficientVideoMapMapper extends BaseMapper<UserEfficientVid
 
     List<VideoDTO> getToutiaoQuarterVideoInfoByAccountId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("accountId")Long accountId);
 
+    SysUser getDesignLeaderInfoByDesignUserId(@Param("userId")String userId);
+
     List<VideoDTO> getUserQuarterVideo(@Param("userId")String userId, @Param("year")Integer year, @Param("quarter")Integer quarter);
 
     List<VideoDTO> getUserQuarterEffiVideo(@Param("userId")String userId, @Param("year")Integer year, @Param("quarter")Integer quarter);
 
     BigDecimal getQuarterTotalCostByRoleCode(@Param("year")Integer year, @Param("quarter")Integer quarter,@Param("startDate")String startDate, @Param("endDate")String endDate,@Param("roleCode")String roleCode,@Param("userId")String userId);
 
+    List<String> getQuarterSignature(@Param("year")Integer year, @Param("quarter")Integer quarter,@Param("roleCode")String roleCode,@Param("userId")String userId);
+
+    BigDecimal getQuarterTotalCostByCode(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("signature")String signature);
+
+    BigDecimal getToutiaoQuarterTotalCostByCode(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("signature")String signature);
+
     BigDecimal getToutiaoQuarterTotalCostByRoleCode(@Param("year")Integer year, @Param("quarter")Integer quarter,@Param("startDate")String startDate, @Param("endDate")String endDate,@Param("roleCode")String roleCode,@Param("userId")String userId);
+
+    List<AccountDTO> getAccountInfoByAppType(@Param("appType")Integer appType);
 }
 

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

@@ -209,18 +209,46 @@
         and c.shot_id = #{userId}
     </select>
 
+    <select id="getQuarterSignature" resultType="string">
+        select
+            video_signature
+            from
+            ctop_user_video_map
+            where year = #{year} and quarter = #{quarter}
+            and user_id = #{userId} and role_id = #{roleCode}
+    </select>
+
+    <select id="getQuarterTotalCostByCode" resultType="java.math.BigDecimal">
+        select
+        sum(a.charge) as charge
+        from ctop_kuaishou_report_daily_creative a
+        where signature = #{signature}
+        and DATE_FORMAT(a.stat_date,'%Y-%m-%d') &gt;= #{startDate}
+        and DATE_FORMAT(a.stat_date,'%Y-%m-%d') &lt;= #{endDate}
+    </select>
+
+    <select id="getToutiaoQuarterTotalCostByCode" resultType="java.math.BigDecimal">
+        select
+        sum(a.cost) as charge
+        from ctop_bytedance_report_creative_daily a
+        where signature = #{signature}
+        and DATE_FORMAT(a.stat_datetime,'%Y-%m-%d') &gt;= #{startDate}
+        and DATE_FORMAT(a.stat_datetime,'%Y-%m-%d') &lt;= #{endDate}
+    </select>
+
     <!-- 根据userId和角色名获取其在本季度所有视频总消耗 -->
     <select id="getQuarterTotalCostByRoleCode" resultType="java.math.BigDecimal">
         select
         sum(a.charge) as charge
         from ctop_kuaishou_report_daily_creative a
-        where signature in (
+        left join  (
             select
-            efficient_video_signature
+            video_signature
             from
-            ctop_user_efficient_video_map
+            ctop_user_video_map
             where year = #{year} and quarter = #{quarter}
-            and user_id = #{userId} and role_id = #{roleCode})
+            and user_id = #{userId} and role_id = #{roleCode}) b on a.signature = b.video_signature
+        where b.video_signature is not null
         and DATE_FORMAT(a.stat_date,'%Y-%m-%d') &gt;= #{startDate}
         and DATE_FORMAT(a.stat_date,'%Y-%m-%d') &lt;= #{endDate}
     </select>
@@ -366,11 +394,27 @@
     </select>
 
     <!-- 根据projectId计算项目总消耗 -->
+    <select id="getToutiaoProjectQuarterCostById" resultType="java.math.BigDecimal">
+            select
+            sum(dailiAccount.cost) as charge
+            from
+            ctop_bytedance_report_advertiser_daily dailiAccount
+            left join
+            ctop_user_allocation allocation on dailiAccount.advertiser_id = allocation.account_id
+        where
+        allocation.project_id = #{projectId}
+        AND
+        date_format(dailiAccount.stat_datetime,'%Y-%m-%d') &gt;= #{startDate}
+        AND
+        date_format(dailiAccount.stat_datetime,'%Y-%m-%d') &lt; #{endDate}
+    </select>
+
+    <!-- 根据projectId计算项目总消耗 -->
     <select id="getProjectQuarterCostById" resultType="java.math.BigDecimal">
             select
             sum(dailiAccount.charge) as charge
             from
-            ctop_kuaishou_report_daily_account dailiAccount
+            ctop_kuaishou_report_daily_creative dailiAccount
             left join
             ctop_user_allocation allocation on dailiAccount.account_id = allocation.account_id
         where
@@ -617,7 +661,17 @@
     select
     sum(a.cost) as charge
     from ctop_bytedance_report_creative_daily a
-    where signature in (select efficient_video_signature from ctop_user_efficient_video_map where year =#{year} and quarter =#{quarter} and user_id = #{userId} and role_id = #{roleCode})
+    left join  (
+                select
+                video_signature
+                from
+                ctop_user_video_map
+                where year =#{year}
+                and quarter =#{quarter}
+                and user_id = #{userId}
+                and role_id = #{roleCode}
+                ) b on on a.signature = b.video_signature
+    where b.video_signature is not null
     and DATE_FORMAT(a.stat_datetime,'%Y-%m-%d') &gt;= #{startDate}
     and DATE_FORMAT(a.stat_datetime,'%Y-%m-%d') &lt;= #{endDate}
     </select>
@@ -934,7 +988,8 @@
         left join sys_user_role ur on u.id = ur.user_id
         left join sys_role r on ur.role_id = r.id
         WHERE b.parent_id = '024b0dc0840045afb048022a8c61253f'  <!-- 快手运营部 -->
-        and r.role_code = 'operator'
+        and (r.role_code in ('operator','kuaishouOperationManager','operationAssistant')
+				or realname = '郭浩')
     </select>
 
     <!-- 获取北京快手运营部所有人的信息 -->
@@ -954,6 +1009,19 @@
 
     <!-- 获取北京头条运营部所有优化师得信息 -->
     <select id="getToutiaoYunyingDepartUserInfo" resultType="cn.com.ctop.userefficientvideomap.entity.UserDto2">
+       <!-- select u.id as userId,
+        u.realname as realname,
+        r.role_name as roleName,
+        r.role_code as roleCode,
+        r.id as roleId
+        FROM sys_user_depart ud
+        left join sys_depart b on ud.dep_id = b.id
+        left join sys_user u on ud.user_id = u.id
+        left join sys_user_role ur on u.id = ur.user_id
+        left join sys_role r on ur.role_id = r.id
+        WHERE b.parent_id = 'c869de6bedc44a50803e45a4611df05e'
+        and r.role_code = 'operator' -->
+
         select u.id as userId,
         u.realname as realname,
         r.role_name as roleName,
@@ -965,7 +1033,7 @@
         left join sys_user_role ur on u.id = ur.user_id
         left join sys_role r on ur.role_id = r.id
         WHERE b.parent_id = 'c869de6bedc44a50803e45a4611df05e'  <!-- 头条运营部 -->
-        and r.role_code = 'operator'
+        and r.role_code in ('operator','kuaishouOperationManager','operationAssistant')
     </select>
 
     <!-- 获取北京头条运营部所有优化师得信息 -->
@@ -1433,7 +1501,7 @@
         and r.role_code = 'kuaishouOperationManager'
     </select>
 
-    <!-- 获取北京头条运营部所有优化师得信息 -->
+    <!-- 获取北京头条运营部所有运营经理的信息 -->
     <select id="getToutiaoYunyingLeaderUserInfo" resultType="cn.com.ctop.userefficientvideomap.entity.UserDto2">
         select u.id as userId,
         u.realname as realname,
@@ -1609,9 +1677,13 @@
             (select url from ctop_kuaishou_video_get where signature = a.signature limit 1) as url,
             b.url as creativeUrl,
             d1.realname as shot,
-            d2.realname as plan,
-            d3.realname as plane,
-            d4.realname as clip
+        d1.id as shotId,
+        d2.realname as plan,
+        d2.id as planId,
+        d3.realname as plane,
+        d3.id as planeid,
+        d4.realname as clip,
+        d4.id as clipId
         from
         (
         select signature, sum(charge) as charge from ctop_kuaishou_report_daily_creative where creative_id in  (
@@ -1619,12 +1691,13 @@
         )
         and stat_date &gt;= #{startDate} and stat_date &lt;= #{endDate} <!-- and signature is not null --> group by signature
         ) a
-        left join ctop_material_info b on a.signature = b.code
+        left join (select id,url,code from ctop_material_info group by code) b on a.signature = b.code
         left join ctop_material_ascription c on b.id = c.material_id
         left join sys_user d1 on d1.id = c.shot_id
         left join sys_user d2 on d2.id = c.plan_id
         left join sys_user d3 on d3.id = c.plane_id
         left join sys_user d4 on d4.id = c.clip_id
+        where b.url is not null <!-- TODO delete -->
     </select>
 
     <!-- 头条根据账户获取其下视频制作信息以及消耗 -->
@@ -1635,9 +1708,13 @@
         (select video_url from  ctop_bytedance_video_info where signature = a.signature limit 1) as creativeUrl,
         b.url,
         d1.realname as shot,
+        d1.id as shotId,
         d2.realname as plan,
+        d2.id as planId,
         d3.realname as plane,
-        d4.realname as clip
+        d3.id as planeid,
+        d4.realname as clip,
+        d4.id as clipId
         from
         (
             select creative_id,signature, sum(cost) as charge from ctop_bytedance_report_creative_daily where creative_id in  (
@@ -1647,12 +1724,25 @@
             and date_format(stat_datetime,'%Y-%m-%d') &lt;= #{endDate}
             <!--and  signature is not null --> group by signature
         ) a
-        left join ctop_material_info b on a.signature = b.code
+        left join (select id,url,code from ctop_material_info group by code) b on a.signature = b.code
         left join ctop_material_ascription c on b.id = c.material_id
         left join sys_user d1 on d1.id = c.shot_id
         left join sys_user d2 on d2.id = c.plan_id
         left join sys_user d3 on d3.id = c.plane_id
         left join sys_user d4 on d4.id = c.clip_id
+        where b.url is not null <!-- TODO delete -->
+    </select>
+
+    <!-- 根据设计师组员姓名获取组长姓名 -->
+    <select id="getDesignLeaderInfoByDesignUserId" resultType="cn.com.ctop.userefficientvideomap.entity.SysUser">
+            select
+            a.id,
+            a.realname
+        from sys_user a
+        left join sys_user_depart b on a.id = b.user_id
+        left join sys_user_role c on a.id = c.user_id
+        where b.dep_id = (select dep_id from sys_user_depart where user_id = #{userId})
+        and c.role_id = '8d3e2ed58bdedf17716f698ea674da27' <!-- 设计组长roleid -->
     </select>
 
     <select id="getUserQuarterVideo" resultType="cn.com.ctop.userefficientvideomap.entity.VideoDTO">
@@ -1703,4 +1793,17 @@
         group by signature
     </select>
 
+    <select id="getAccountInfoByAppType" resultType="cn.com.ctop.userefficientvideomap.entity.AccountDTO">
+            select
+            account_id as accountId,
+            auth_name as authName,
+            project_id as projectId,
+            project_name as projectName
+        from
+        ctop_user_allocation
+        where
+        media_id = #{appType}
+        order by project_id
+    </select>
+
 </mapper>