Parcourir la source

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

 Conflicts:
	jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
songyh il y a 4 ans
Parent
commit
addc723e27
70 fichiers modifiés avec 3905 ajouts et 423 suppressions
  1. 40 4
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java
  2. 18 11
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AiKuaishouAdvertiserStrategyController.java
  3. 9 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java
  4. 277 30
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  5. 0 84
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyGroupReportLoadJob.java
  6. 102 20
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  7. 44 36
      module-common/src/main/java/cn/com/ctop/common/module/mapper/SysDepartMapper.java
  8. 1 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/SysRoleMapper.java
  9. 3 1
      module-common/src/main/java/cn/com/ctop/common/module/mapper/SysUserDepartMapper.java
  10. 33 13
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/SysDepartMapper.xml
  11. 18 14
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/SysRoleMapper.xml
  12. 16 7
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/SysUserDepartMapper.xml
  13. 1 2
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/SysUserMapper.xml
  14. 3 0
      module-job-bytedance/src/main/resources/application-dev.yml
  15. 3 0
      module-job-bytedance/src/main/resources/application-jiaoyang.yml
  16. 3 0
      module-job-bytedance/src/main/resources/application-prod.yml
  17. 3 0
      module-job-bytedance/src/main/resources/application-test.yml
  18. 2 2
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/CrowdListQueryJob.java
  19. 64 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouBudgetJob.java
  20. 48 19
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouHourlyGroupReportLoadJob.java
  21. 66 2
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouMatDailyReportJob.java
  22. 3 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/enums/KuaishouCreativeMatTypeEnum.java
  23. 127 56
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java
  24. 76 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/app/entity/KuaishouAccountBalanceBudget.java
  25. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/app/mapper/KuaishouAccountBalanceBudgetMapper.java
  26. 36 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/app/mapper/xml/KuaishouAccountBalanceBudgetMapper.xml
  27. 18 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/app/service/IKuaishouAccountBalanceBudgetService.java
  28. 32 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/app/service/impl/KuaishouAccountBalanceBudgetServiceImpl.java
  29. 2 20
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  30. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCampaignMapper.java
  31. 16 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCampaignMapper.xml
  32. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCampaignService.java
  33. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCreativeService.java
  34. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouReportDailyMaterialService.java
  35. 1 13
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  36. 5 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouActionBarTextServiceImpl.java
  37. 10 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCampaignServiceImpl.java
  38. 76 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCreativeServiceImpl.java
  39. 12 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouReportDailyMaterialServiceImpl.java
  40. 5 53
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  41. 0 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouPopulationServiceImpl.java
  42. 129 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/EtlKuaishouReportAccountHourlyController.java
  43. 248 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaiShouProjectDataController.java
  44. 248 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaiShouReportHourlyMaterialController.java
  45. 15 9
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/EtlKuaishouReportAccountHourly.java
  46. 71 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaiShouProjectData.java
  47. 2 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaiShouReportDailyMaterial.java
  48. 425 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaiShouReportHourlyMaterial.java
  49. 94 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/enums/CheckParametersCostEnum.java
  50. 23 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/EtlKuaishouReportAccountDailyMapper.java
  51. 19 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/EtlKuaishouReportAccountHourlyMapper.java
  52. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaiShouProjectDataMapper.java
  53. 20 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaiShouReportHourlyMaterialMapper.java
  54. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportHourlyAccountMapper.java
  55. 280 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouReportAccountDailyMapper.xml
  56. 412 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouReportAccountHourlyMapper.xml
  57. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaiShouProjectDataMapper.xml
  58. 139 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaiShouReportHourlyMaterialMapper.xml
  59. 38 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportHourlyAccountMapper.xml
  60. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IEtlKuaishouReportAccountHourlyService.java
  61. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaiShouProjectDataService.java
  62. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaiShouReportHourlyMaterialService.java
  63. 3 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportHourlyGroupService.java
  64. 365 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/EtlKuaishouReportAccountHourlyServiceImpl.java
  65. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaiShouProjectDataServiceImpl.java
  66. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaiShouReportHourlyMaterialServiceImpl.java
  67. 61 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportHourlyGroupServiceImpl.java
  68. 2 2
      module-kuaishou/src/main/resources/json_template/kuaishou_filed_mapping.json
  69. 1 1
      module-oa/src/main/java/cn/com/ctop/oa/modules/mapper/xml/WechatNoListMapper.xml
  70. 1 1
      module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatCheckinDataServiceImpl.java

+ 40 - 4
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -10,7 +10,14 @@ import java.sql.Timestamp;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 
 /**
  * 类描述:时间操作定义类
@@ -146,8 +153,6 @@ public class DateUtils extends PropertyEditorSupport {
     }
 
 
-
-
     // 指定模式的时间格式
     private static SimpleDateFormat getSDFormat(String pattern) {
         return new SimpleDateFormat(pattern);
@@ -1579,11 +1584,42 @@ public class DateUtils extends PropertyEditorSupport {
     }
 
     /**
-     * 获取两个日期之间的所有日期集合
+     * 根据数字查询本周对应的日期
+     * 1-7对应周一~周天
+     *
+     * @param
+     * @return java.lang.String
+     * @throws
      * @author ZHAOXA
+     */
+    public static String getdateFromWeek(int number) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar c = Calendar.getInstance();
+        // 今天是一周中的第几天
+        int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
+
+        if (c.getFirstDayOfWeek() == Calendar.SUNDAY) {
+            c.add(Calendar.DAY_OF_MONTH, 1);
+        }
+        // 计算一周开始的日期
+        c.add(Calendar.DAY_OF_MONTH, -dayOfWeek);
+
+        for (int i = 1; i <= 7; i++) {
+            c.add(Calendar.DAY_OF_MONTH, 1);
+            if (number == i) {
+                return sdf.format(c.getTime());
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 获取两个日期之间的所有日期集合
+     *
      * @param
      * @return java.util.List<java.lang.String>
      * @throws
+     * @author ZHAOXA
      */
     public static List<String> getDays(String startTime, String endTime) {
         // 返回的日期集合

+ 18 - 11
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AiKuaishouAdvertiserStrategyController.java

@@ -62,7 +62,7 @@ public class AiKuaishouAdvertiserStrategyController {
         QueryWrapper<AiKuaishouAdvertiserStrategy> queryWrapper = QueryGenerator.initQueryWrapper(aiKuaishouAdvertiserStrategy, req.getParameterMap());
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String roleCode = sysRoleService.getRoleCodeByUserId(user.getId());
-        if(!CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode)){
+        if (!CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode)) {
             queryWrapper.eq("user_id", user.getId());
         }
         Page<AiKuaishouAdvertiserStrategy> page = new Page<>(pageNo, pageSize);
@@ -98,22 +98,25 @@ public class AiKuaishouAdvertiserStrategyController {
         try {
             Long accountId = aiKuaishouAdvertiserStrategy.getAccountId();
             AiKuaishouAdvertiserStrategy getEntity = aiKuaishouAdvertiserStrategyService.getByAccountId(accountId);
-            if(null!=getEntity){
+            if (null != getEntity) {
                 result.error500("该账户配置信息已经被创建");
                 return result;
             }
             UserAllocation allocation = allocationService.getByAccountId(accountId);
-            if(null!=allocation){
+            if (null != allocation) {
                 aiKuaishouAdvertiserStrategy.setUserId(allocation.getUserId());
             }
             aiKuaishouAdvertiserStrategy.setDescription(aiKuaishouAdvertiserStrategy.getDescription().trim());
             Integer singleAppId = aiKuaishouAdvertiserStrategy.getSingleAppid();
             if (null != singleAppId && singleAppId == 1) {
-                Integer appId = Integer.parseInt(JSONArray.parseArray(aiKuaishouAdvertiserStrategy.getAppIdArray()).getString(0));
-                aiKuaishouAdvertiserStrategy.setAppId(appId);
+                if (aiKuaishouAdvertiserStrategy.getCampaignType() == 2 || aiKuaishouAdvertiserStrategy.getCampaignType() == 7) {
+                    Integer appId = Integer.parseInt(JSONArray.parseArray(aiKuaishouAdvertiserStrategy.getAppIdArray()).getString(0));
+                    aiKuaishouAdvertiserStrategy.setAppId(appId);
+                }
+
             }
             aiKuaishouAdvertiserStrategyService.save(aiKuaishouAdvertiserStrategy);
-            Thread thread = new Thread(){
+            Thread thread = new Thread() {
                 @Override
                 public void run() {
                     kuaishouVideoRelateCreativesService.videoRelateCreatives(aiKuaishouAdvertiserStrategy.getAccountId());
@@ -127,6 +130,7 @@ public class AiKuaishouAdvertiserStrategyController {
         }
         return result;
     }
+
     /**
      * 编辑
      *
@@ -141,10 +145,13 @@ public class AiKuaishouAdvertiserStrategyController {
             result.error500("未找到对应实体");
         } else {
             Integer singleAppId = aiKuaishouAdvertiserStrategy.getSingleAppid();
-            if (null != singleAppId && singleAppId == 1) {
-                Integer appId = Integer.parseInt(JSONArray.parseArray(aiKuaishouAdvertiserStrategy.getAppIdArray()).getString(0));
-                aiKuaishouAdvertiserStrategy.setAppId(appId);
+            if (aiKuaishouAdvertiserStrategy.getCampaignType() == 2 || aiKuaishouAdvertiserStrategy.getCampaignType() == 7) {
+                if (null != singleAppId && singleAppId == 1) {
+                    Integer appId = Integer.parseInt(JSONArray.parseArray(aiKuaishouAdvertiserStrategy.getAppIdArray()).getString(0));
+                    aiKuaishouAdvertiserStrategy.setAppId(appId);
+                }
             }
+
             boolean ok = aiKuaishouAdvertiserStrategyService.updateById(aiKuaishouAdvertiserStrategy);
             if (ok) {
                 result.success("修改成功!");
@@ -261,12 +268,12 @@ public class AiKuaishouAdvertiserStrategyController {
     }
 
     @GetMapping(value = "testCreate")
-    public Map<String,Object> testCreate(Long accountId){
+    public Map<String, Object> testCreate(Long accountId) {
         return aiKuaishouAdvertiserStrategyService.testCreate(accountId);
     }
 
     @GetMapping(value = "aiHistoricalMissingMaterial")
-    public Map<String,Object> aiHistoricalMissingMaterial(Long accountId){
+    public Map<String, Object> aiHistoricalMissingMaterial(Long accountId) {
         return aiKuaishouAdvertiserStrategyService.aiHistoricalMissingMaterial(accountId);
     }
 }

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

@@ -149,6 +149,11 @@ public class ProjectMemberController {
     }
 
 
+    /**
+     * 获取项目以及账户信息
+     * @param requestJson
+     * @return
+     */
     @PostMapping(value = "/participateListByMediaId")
     public Result<List<JSONObject>> participateListByMediaId(@RequestBody JSONObject requestJson) {
         Result<List<JSONObject>> result = new Result<>();
@@ -168,13 +173,17 @@ public class ProjectMemberController {
                     mediaIds.add(3);
                 }
             }
+            //查询用户角色
             String roleCode = sysRoleService.getRoleCodeByUserId(userId);
+            //角色为 管理员 || 销售 || 媒介 查询全部
             if ("admin".equals(roleCode) || roleCode.contains("sale") || "meidaManager".equals(roleCode)) {
                 userId = null;
             }
+            //查询项目信息以及广告主
             List<JSONObject> projectList = projectMemberService.getProjectByUserIdAndMediaIds(userId, mediaIds);
             List<JSONObject> haveList = new ArrayList<>();
             if (!Check.isNull(projectList)) {
+                //项目id 查询账户人员信息
                 Map<Long, List<JSONObject>> accountMap = userAllocationService.getAccountListByProjectList(projectList);
                 for (int i = 0; i < projectList.size(); i++) {
                     JSONObject project = projectList.get(i);

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

@@ -12,13 +12,19 @@ import cn.com.ctop.crawler.modules.douyin.service.DouyinMusicService;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAdvertiserStrategyService;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCreateCreativeService;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplate;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouAccessToken;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouProjectData;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouDailyAgentService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouProjectDataService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyGroupService;
 import cn.com.ctop.toutiao.modules.link.service.IETLReportBytedanceVideoService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.material.service.IBytedanceEffectVideoInfoService;
@@ -92,7 +98,7 @@ public class TestController {
     @Autowired
     private IKuaiShouHistoryReportTaskService kuaiShouHistoryReportTaskService;
 
-    static ExecutorService executorService = Executors.newFixedThreadPool(15);
+    static ExecutorService executorService = Executors.newFixedThreadPool(5);
     static ExecutorService suzhaoService = Executors.newFixedThreadPool(5);
     @Autowired
     private IKuaiShouDailyAgentService dailyAgentService;
@@ -111,23 +117,264 @@ public class TestController {
     @Autowired
     private ICtopOauthTokenService tokenService;
 
+    @Autowired
+    private IKuaiShouProjectDataService kuaiShouProjectDataService;
+    @Autowired
+    private IKuaishouReportHourlyGroupService hourlyGroupService;
+    @Autowired
+    private IKuaiShouReportDailyMaterialService kuaiShouReportDailyMaterialService;
+
+    @Autowired
+    private IKuaiShouCreativeService creativeService;
+    @Autowired
+    private IKuaiShouGroupService groupService;
+
+    @Autowired
+    private IBatchService batchService;
+    static ExecutorService videoService = Executors.newFixedThreadPool(3);
+
+
+    @GetMapping(value = "/getProgramCreative")
+    public void getProgramCreative() {
+        List<Long> list = new ArrayList();
+        list.add(10045052L);
+        list.add(10045823L);
+        list.add(10045830L);
+        list.add(10045831L);
+
+        for (int i = 0; i < list.size(); i++) {
+            Long accountId = list.get(i);
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            creativeService.getProgramCreative(oauthToken, 1);
+        }
+
+
+    }
+
+
+    @GetMapping(value = "/campaignList")
+    public void campaignList() {
+        List<Long> list = new ArrayList();
+        list.add(10045052L);
+        list.add(10045823L);
+        list.add(10045830L);
+        list.add(10045831L);
+        for (int i = 0; i < list.size(); i++) {
+            Long accountId = list.get(i);
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            // kuaishouInterfaceService.getCampaignList(oauthToken, null, null);
+            videoService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        kuaishouInterfaceService.getCampaignList(oauthToken, null, null);
+                        //   kuaishouInterfaceService.getGroupList(oauthToken, null, null);
+                        //     kuaishouInterfaceService.getCreativeList(oauthToken, null, null);
+                        Thread.sleep(1500);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+            });
+
+        }
+
+    }
+
+
+    @GetMapping(value = "/creativeList")
+    public void creativeList() {
+        List<Long> list = new ArrayList();
+        list.add(10045052L);
+        list.add(10045823L);
+        list.add(10045830L);
+        list.add(10045831L);
+        for (int i = 0; i < list.size(); i++) {
+            Long accountId = list.get(i);
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            QueryWrapper<KuaiShouCampaign> campaignQueryWrapper = new QueryWrapper<>();
+            campaignQueryWrapper.eq("account_id", accountId);
+
+            List<KuaiShouCampaign> list1 = campaignService.list(campaignQueryWrapper);
+            for (KuaiShouCampaign campaign : list1) {
+                executorService.submit(new Runnable() {
+                    @Override
+                    public void run() {
+                        kuaishouInterfaceService.getCreativeList(oauthToken, null, null);
+                    }
+                });
+                try {
+                    Thread.sleep(400L);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+            }
+
+
+        }
+
+    }
+
+
+    @GetMapping(value = "/updateUnit")
+    public void updateUnit() throws Exception {
+        List<Long> list = new ArrayList();
+        list.add(9556344L);
+        list.add(9743738L);
+        list.add(9743727L);
+        list.add(9812671L);
+        list.add(9838554L);
+        list.add(9743746L);
+        list.add(9767055L);
+        list.add(9556274L);
+        list.add(9767096L);
+        list.add(9792538L);
+        list.add(9766952L);
+        list.add(9677440L);
+        list.add(9677334L);
+        list.add(9556465L);
+        list.add(9677236L);
+        list.add(9556227L);
+        list.add(9556188L);
+        list.add(9556431L);
+        list.add(9677408L);
+        list.add(9677284L);
+
+        for (int i = 0; i < list.size(); i++) {
+            Long accountId = list.get(i);
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            QueryWrapper<KuaiShouGroup> groupQueryWrapper = new QueryWrapper<>();
+            groupQueryWrapper.eq("account_id", accountId);
+            //      groupQueryWrapper.ne("schedule_time","000000111111111111111111000000111111111111111111000000111111111111111111000000111111111111111111000000111111111111111111000000111111111111111111000000111111111111111111");
+            //     groupQueryWrapper.eq("use_app_market", 1);
+            //    groupQueryWrapper.gt("cpa_bid", 19000);
+
+
+            List<KuaiShouGroup> list1 = groupService.list(groupQueryWrapper);
+          /*  for (KuaiShouGroup group : list1) {
+
+                JSONObject json = new JSONObject();
+                json.put("unitId", group.getUnitId());
+                json.put("useAppMarket", 0);
+                json.put("appStore", new JSONArray());
+                batchService.updateUnit(json, oauthToken);
+            }*/
+
+            for (KuaiShouGroup group : list1) {
+                executorService.submit(new Runnable() {
+                    @Override
+                    public void run() {
+                        try {
+                            JSONObject json = new JSONObject();
+                            json.put("unitId", group.getUnitId());
+                            json.put("cpaBid", 18 * 1000);
+                            //     json.put("gender", "2");
+                            batchService.updateUnit(json, oauthToken);
+                            Thread.sleep(1500);
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
+                });
+
+
+            }
+
+
+        }
+
+
+    }
+
+
+    @GetMapping(value = "/updateCreative")
+    public void updateCreative() {
+        List<Long> list = new ArrayList();
+        list.add(10045052L);
+        list.add(10045823L);
+        list.add(10045830L);
+        list.add(10045831L);
+
+        for (int i = 0; i < list.size(); i++) {
+            Long accountId = list.get(i);
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+
+
+            QueryWrapper<KuaiShouCreative> creativeQueryWrapper = new QueryWrapper<>();
+            creativeQueryWrapper.eq("account_id", accountId);
+
+
+            List<KuaiShouCreative> creativeList = creativeService.list(creativeQueryWrapper);
+            for (KuaiShouCreative creative : creativeList) {
+                executorService.submit(new Runnable() {
+                    @Override
+                    public void run() {
+                        try {
+                            JSONObject json = new JSONObject();
+                            json.put("creativeId", creative.getCreativeId());
+                            String url = "https://click-wailaxin.1sapp.com/vendor/feedback/reportClick?platform=kuaishou&feedback_type=android&account_id=19&plan_id=__DID__&adgroup_id=__AID__&creative_id=__CID__&imei=__IMEI2__&mac=__MAC__&androidid=__ANDROIDID2__&ts=__TS__&ip=__IP__&ua=__UA__&callback=__CALLBACK__&oaid=__OAID__&app=dxqlb";
+
+                            if (creative.getCreativeMaterialType() == 1) {
+                                json.put("clickTrackUrl", url);
+                            } else if (creative.getCreativeMaterialType() == 4) {
+                                json.put("impressionUrl", url);
+                                json.put("clickTrackUrl", url);
+
+                            }
+                            JSONObject jsonObject = batchService.updateCreative(json, oauthToken);
+                            log.info("修改创意返回信息:creative:{},结果:{}", creative.getCreativeId(), jsonObject);
+                            Thread.sleep(1000L);
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
+                });
+            }
+        }
+    }
+
 
     @GetMapping("/cleanNewlyData")
     public void cleanNewlyData(String startDate, String endDate) throws ParseException {
 
 
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-        Date parse1 = simpleDateFormat.parse(startDate);
-        Date parse2 = simpleDateFormat.parse(endDate);
-     /*   CtopOauthToken token = new CtopOauthToken();
-        token.setAccountId(9791267L);
-        token.setAccessToken("b8ab3b361cd30339ef7e18dcc1305123");*/
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+        //1:查询当日数据
+        QueryWrapper<KuaiShouProjectData> queryWrapper = new QueryWrapper();
+        queryWrapper.eq("project_status", 0);
+        List<KuaiShouProjectData> list = kuaiShouProjectDataService.list(queryWrapper);
+        if (Check.isNull(list)) {
+            return;
+        }
+        for (KuaiShouProjectData projectData : list) {
+            Long projectId = projectData.getProjectId();
+            if (Check.isNull(projectId)) {
+                continue;
+            }
+            QueryWrapper<UserAllocation> allocationQueryWrapper = new QueryWrapper<>();
+            allocationQueryWrapper.eq("project_id", projectId);
+            allocationQueryWrapper.eq("account_status", 0);
+            List<UserAllocation> accountIds = allocationService.list(allocationQueryWrapper);
+            if (Check.isNull(accountIds)) {
+                continue;
+            }
+            for (UserAllocation allocation : accountIds) {
+                CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
+                if (Check.isNull(token)) {
+                    continue;
+                }
 
-        List<CtopOauthToken> ctopOauthTokens = tokenService.selectKuaiShouToken();
-        // kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate, getDate, "adScene");
-        ctopOauthTokens.forEach(token -> executorService.submit(() -> {
-            kuaishouInterfaceService.getAdvertiserReportDaily(token, parse1, parse2, "adScene");
-        }));
+                executorService.submit(new Runnable() {
+                    @Override
+                    public void run() {
+                        kuaiShouReportDailyMaterialService.getMaterialReportByAccountIdAndStatDate(token.getAccountId(), token.getAccessToken(), yesterday, yesterday, "HOURLY", 1);
+
+                        //  hourlyGroupService.getAdvertiserGroupReportHourly(token.getAccountId(), token.getAccessToken(), yesterday, yesterday);
+                    }
+                });
+            }
+        }
 
 
     }
@@ -1255,41 +1502,41 @@ public class TestController {
     private IAiKuaishouCreateCreativeService createCreativeService;
 
     @GetMapping("testCreateCreative")
-    public Map<String,Object>testCreateCreative(Long accountId,Integer createType){
-        Map<String,Object>result = new HashMap<>();
+    public Map<String, Object> testCreateCreative(Long accountId, Integer createType) {
+        Map<String, Object> result = new HashMap<>();
         AiKuaishouAdvertiserStrategy strategy = strategyService.getByAccountId(accountId);
-        if(strategy == null){
-            ResultMapUtils.setResultMap(result,StatusCode.COMMON_PARAM_ERROR);
+        if (strategy == null) {
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
             return result;
         }
-        createCreativeService.autoCreateCreative(strategy,createType,150L);
-        ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
+        createCreativeService.autoCreateCreative(strategy, createType, 150L);
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
         return result;
     }
 
     @GetMapping("testProgramCreative")
-    public Map<String,Object>testProgramCreative(Long accountId,Integer createType){
-        Map<String,Object>result = new HashMap<>();
+    public Map<String, Object> testProgramCreative(Long accountId, Integer createType) {
+        Map<String, Object> result = new HashMap<>();
         AiKuaishouAdvertiserStrategy strategy = strategyService.getByAccountId(accountId);
-        if(strategy == null){
-            ResultMapUtils.setResultMap(result,StatusCode.COMMON_PARAM_ERROR);
+        if (strategy == null) {
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
             return result;
         }
-        createCreativeService.autoCreateProgramCreative(strategy, createType,150L);
-        ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
+        createCreativeService.autoCreateProgramCreative(strategy, createType, 150L);
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
         return result;
     }
 
     @GetMapping("testCreateCreativeLimit")
-    public Map<String,Object>testCreateCreativeLimit(Long accountId,Integer hour) throws ParseException {
-        Map<String,Object>result = new HashMap<>();
+    public Map<String, Object> testCreateCreativeLimit(Long accountId, Integer hour) throws ParseException {
+        Map<String, Object> result = new HashMap<>();
         AiKuaishouAdvertiserStrategy strategy = strategyService.getByAccountId(accountId);
-        if(strategy == null){
-            ResultMapUtils.setResultMap(result,StatusCode.COMMON_PARAM_ERROR);
+        if (strategy == null) {
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
             return result;
         }
-        createCreativeService.customCreativeSupplement(strategy,hour);
-        ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
+        createCreativeService.customCreativeSupplement(strategy, hour);
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
         return result;
     }
 }

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

@@ -1,84 +0,0 @@
-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;
-import org.quartz.Job;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-/**
- * 获取 广告组分时数据
- *
- * @author syh
- */
-@Slf4j
-public class KuaishouHourlyGroupReportLoadJob implements Job {
-    @Autowired
-    private ICtopOauthTokenService tokenService;
-    @Autowired
-    private IKuaishouInterfaceService kuaishouInterfaceService;
-
-    static ExecutorService executorService = null;
-    //线程计数器
-    static CountDownLatch countDownLatch = null;
-
-    @Override
-    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        Thread thread = new Thread() {
-            @Override
-            public void run() {
-                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.selectKuaiShouToken();
-                if (null == tokens || tokens.size() <= 0) {
-                    log.info("定时获取快手数据异常:未获取到可用的token");
-                    return;
-                }
-                executorService = Executors.newFixedThreadPool(5);
-                countDownLatch = new CountDownLatch(tokens.size());
-                Date finalGetDate = getDate;
-                tokens.forEach(token -> {
-                    executorService.submit(new Runnable() {
-                        @Override
-                        public void run() {
-                            try {
-                                //3:获取广告组信息数据
-                                kuaishouInterfaceService.getAdvertiserGroupReportHourly(token, finalGetDate, finalGetDate);
-                            } catch (Exception e) {
-                                e.printStackTrace();
-                            } finally {
-                                countDownLatch.countDown();
-                            }
-                        }
-                    });
-                });
-                try {
-                    countDownLatch.await();
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
-                }
-
-                executorService.shutdown();
-            }
-        };
-        thread.start();
-
-    }
-}

+ 102 - 20
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -54,23 +54,103 @@ public class SampleTest {
     @Autowired
     private ICtopOauthTokenService tokenService;
     @Autowired
+    private IKuaiShouVideoGetService videoGetService;
+    @Autowired
+    private IKuaishouVideoRelateCreativesService kuaishouVideoRelateCreativesService;
+    @Autowired
     private IBindAccountLoginService bindAccountLoginService;
     @Autowired
     private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
+    /*   @Autowired
+       private IByteDanceAdvertiserDataService advertiserDataService;
+
+   */
+    @Autowired
+    private IKuaishouReportDailyGroupService reportDailyGroupService;
+    @Autowired
+    private IEtlKuaiShouAccountMaterialOverviewService kuaiShouAccountMaterialOverviewService;
     @Autowired
     private IKuaiShouGroupService kuaiShouGroupService;
-
+    @Autowired
+    private IKuaishouReportHourlyGroupService groupService;
+    @Autowired
+    private IKuaiShouReportDailyMaterialService reportDailyMaterialService;
+    @Autowired
+    private IKuaiShouActionBarTextService actionBarTextService;
 
     @Test
     public void loadBytedanceCreativeData() throws ParseException {
-        Date getDate = DateUtils.addDay(new Date(), -1);
+
+        actionBarTextService.getActionBarText();
+
+        // groupService.getAdvertiserGroupReportHourly(9677284L, "b88c5f0d80c518fc80174a4dabbcd180", "2021-04-19", "2021-04-19");
+    //    reportDailyMaterialService.getMaterialReportByAccountIdAndStatDate(9677284L, "b88c5f0d80c518fc80174a4dabbcd180", "2021-04-19", "2021-04-19", "DAILY", 1);
+
+     /*   Date getDate = DateUtils.addDay(new Date(), -1);
         Date getDate2 = DateUtils.addDay(new Date(), -2);
 
         CtopOauthToken token = new CtopOauthToken();
         token.setAccountId(9901975L);
         token.setAccessToken("1c7cebebc3174c39fe941d136df65b1d");
 
-        kuaiShouGroupService.getGroupListByPage("90f31a01c2137aa11c8686e86064b630",9845316L,null,1);
+        kuaiShouGroupService.getGroupListByPage("90f31a01c2137aa11c8686e86064b630",9845316L,null,1);*/
+
+//        kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate2, getDate, "adScene");
+
+     /*   JSONObject materialOverview = kuaiShouAccountMaterialOverviewService.getMaterialOverview(5473041L, "2021-03-09");
+        System.err.println(materialOverview);*/
+
+      /*  CtopOauthToken token = new CtopOauthToken();
+        token.setAccountId(9901975L);
+        token.setAccessToken("e609f9d3f56f3d6b4653f32c98a6d119");
+        kuaiShouAccountMaterialOverviewService.cleanAccountMaterialOverview(9901975L, "2021-03-09");
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date parse = simpleDateFormat.parse("2021-03-09");
+        reportDailyGroupService.getAdvertiserGroupReportDaily(token, parse, parse);*/
+
+        //    1662234704806924
+       /* CtopOauthToken token = new CtopOauthToken();
+        token.setAccountId(9549277L);
+        token.setAccessToken("bc5327c8f2bd8a67513e51148c9206c8");
+
+
+
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date parse = simpleDateFormat.parse("2021-02-02");
+        kuaishouInterfaceService.getAdvertiserReportDaily(token, parse, parse);*/
+
+     /*   CtopOauthToken token = new CtopOauthToken();
+        token.setAccountId(9767055L);
+        token.setAccessToken("28e4e6b124e1443d6971ba4c699de6c9");
+
+        kuaishouInterfaceService.getVideoList(token, null, null);
+        kuaishouInterfaceService.getVideoInfo("28e4e6b124e1443d6971ba4c699de6c9", 9767055L, "5208131540349742192");*/
+
+     /*   CtopOauthToken tokenByAccountId = tokenService.getTokenByAccountId(1662234704806924L);
+        advertiserDataService.getMaterialList(tokenByAccountId);*/
+       /* getVideoByPage(token, "", 1);
+        List<KuaiShouVideoGet> KuaiShouVideoGets = videoGetService.selectPhotoIdsByAccountId(9743746L);
+        if (!Check.isNull(KuaiShouVideoGets)) {
+            JSONArray dateList = new JSONArray();
+            JSONArray photoIds = new JSONArray();
+            Map<String, Object> statdateMap = new HashMap<>();
+            int count = 0;
+            for (KuaiShouVideoGet video : KuaiShouVideoGets) {
+                count++;
+                if (count < 10) {
+                    photoIds.add(video.getPhotoId());
+                    statdateMap.put(video.getPhotoId(), video.getStatDate());
+                } else {
+                    photoIds.add(video.getPhotoId());
+                    statdateMap.put(video.getPhotoId(), video.getStatDate());
+                    dateList.add(photoIds);
+                    photoIds = new JSONArray();
+                    count = 0;
+                }
+            }
+            dateList.add(photoIds);
+            kuaishouVideoRelateCreativesService.videoRelateCreatives(9743746L, dateList, statdateMap);
+        }*/
     }
 
     @Test
@@ -88,14 +168,15 @@ public class SampleTest {
     }
 
     @Test
-    public void loadKuaishouCamgaignData(){
-        Date getDate = DateUtils.parseDate("2021-03-24","yyyy-MM-dd");
-        List<UserAllocation> list = allocationService.getByParams(50L,null,0);
+    public void loadKuaishouCamgaignData() {
+        Date getDate = DateUtils.parseDate("2021-03-24", "yyyy-MM-dd");
+        List<UserAllocation> list = allocationService.getByParams(50L, null, 0);
         list.forEach(userAllocation -> {
             CtopOauthToken token = tokenService.getOauthTokenByAccountId(userAllocation.getAccountId().toString());
             kuaishouInterfaceService.getAdvertiserCampaignReportDaily(token, getDate, getDate);
         });
     }
+
     static ExecutorService executorService = null;
     static CountDownLatch countDownLatch = null;
 
@@ -281,13 +362,18 @@ public class SampleTest {
         }
     }
 
-    @Autowired
-    private IKuaiShouReportDailyMaterialService kuaiShouReportDailyMaterialService;
     @Test
-    public void loadKuaishouMatReportData() {
-        CtopOauthToken token = tokenService.getTokenByAccountId(9677284L);
-        String getDate = "2021-03-15";
-        kuaiShouReportDailyMaterialService.getMaterialReportByAccountIdAndStatDate(token.getAccountId(),token.getAccessToken(), getDate, getDate,1);
+    public void loadKuaishouHourlyReportData() {
+        Date getDate = new Date();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
+        String hour = simpleDateFormat.format(getDate);
+        if ("00".equals(hour)) {
+            getDate = DateUtils.addDay(getDate, -1);
+        }
+        //1:查询当日数据
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        Date finalGetDate = getDate;
+        tokens.forEach(token -> kuaishouInterfaceService.getAdvertiserReportHourly(token, finalGetDate, finalGetDate));
     }
 
     @Autowired
@@ -389,17 +475,14 @@ public class SampleTest {
 
     @Test
     public void loadBDAccoutData() {
-        Date startDate = DateUtils.addDay(new Date(),-2000);
-        for(int i=0;i<=2000;i++){
-            Date getDate = DateUtils.addDay(startDate,i);
+        Date startDate = DateUtils.addDay(new Date(), -2000);
+        for (int i = 0; i <= 2000; i++) {
+            Date getDate = DateUtils.addDay(startDate, i);
             bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
         }
     }
 
 
-
-
-
     @Test
     public void etlKuaishouData() {
         String dateString = "2021-01-05";
@@ -430,7 +513,6 @@ public class SampleTest {
     }
 
 
-
     @Test
     public void testLoadBytedanceDataV2() {
         String accountIds = "1675440464386062";
@@ -477,11 +559,11 @@ public class SampleTest {
     private IEtlKuaishouVideoInfoService videoEtlInfoService;
     @Resource
     private EtlKuaishouAccountMaterialReportDailyMapper etlKuaishouAccountMaterialReportDailyMapper;
+
     @Test
     public void etlKuaishouVideoInfo() {
         etlKuaishouAccountMaterialReportDailyMapper.etlKuaishouAccountMaterialReportDailyData(DateUtils.formatDate());
     }
 
 
-
 }

+ 44 - 36
module-common/src/main/java/cn/com/ctop/common/module/mapper/SysDepartMapper.java

@@ -1,9 +1,10 @@
 package cn.com.ctop.common.module.mapper;
 
 import cn.com.ctop.common.module.entity.SysDepart;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
-import org.springframework.data.repository.query.Param;
 
 import java.util.List;
 
@@ -13,42 +14,49 @@ import java.util.List;
  * <p>
  *
  * @Author: Steve
- * @Since:   2019-01-22
+ * @Since: 2019-01-22
  */
 public interface SysDepartMapper extends BaseMapper<SysDepart> {
 
-	/**
-	 * 根据用户ID查询部门集合
-	 */
-	public List<SysDepart> queryUserDeparts(@Param("userId") String userId);
-
-	/**
-	 * 根据用户名查询部门
-	 *
-	 * @param username
-	 * @return
-	 */
-	public List<SysDepart> queryDepartsByUsername(@Param("username") String username);
-
-	@Select("select id from sys_depart where org_code=#{orgCode}")
-	public String queryDepartIdByOrgCode(@Param("orgCode") String orgCode);
-
-	@Select("select id,parent_id from sys_depart where id=#{departId}")
-	public SysDepart getParentDepartId(@Param("departId") String departId);
-
-	/**
-	 *  根据部门Id查询,当前和下级所有部门IDS
-	 * @param departId
-	 * @return
-	 */
-	List<String> getSubDepIdsByDepId(@Param("departId") String departId);
-
-	/**
-	 * 根据部门编码获取部门下所有IDS
-	 * @param orgCodes
-	 * @return
-	 */
-	List<String> getSubDepIdsByOrgCodes(@org.apache.ibatis.annotations.Param("orgCodes") String[] orgCodes);
-
-	SysDepart queryUserDepartsByDepartId(@Param("departId") String departId);
+    /**
+     * 根据用户ID查询部门集合
+     */
+    public List<SysDepart> queryUserDeparts(@Param("userId") String userId);
+
+    /**
+     * 根据用户名查询部门
+     *
+     * @param username
+     * @return
+     */
+    public List<SysDepart> queryDepartsByUsername(@Param("username") String username);
+
+    @Select("select id from sys_depart where org_code=#{orgCode}")
+    public String queryDepartIdByOrgCode(@Param("orgCode") String orgCode);
+
+    @Select("select id,parent_id from sys_depart where id=#{departId}")
+    public SysDepart getParentDepartId(@Param("departId") String departId);
+
+    /**
+     * 根据部门Id查询,当前和下级所有部门IDS
+     *
+     * @param departId
+     * @return
+     */
+    List<String> getSubDepIdsByDepId(@Param("departId") String departId);
+
+    /**
+     * 根据部门编码获取部门下所有IDS
+     *
+     * @param orgCodes
+     * @return
+     */
+    List<String> getSubDepIdsByOrgCodes(@org.apache.ibatis.annotations.Param("orgCodes") String[] orgCodes);
+
+    SysDepart queryUserDepartsByDepartId(@Param("departId") String departId);
+
+    List<JSONObject> getDepartmentIds(@Param("userId") String userId);
+
+    List<JSONObject> checkLowestLevelDepartment(@Param("departIds") List<JSONObject> departIds);
+
 }

+ 1 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/SysRoleMapper.java

@@ -34,4 +34,5 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
     @Delete("delete from sys_role_permission where role_id = #{roleId}")
     void deleteRolePermissionRelation(@Param("roleId") String roleId);
 
+    SysRole queryRoleByUserId(@Param("userId") String userId);
 }

+ 3 - 1
module-common/src/main/java/cn/com/ctop/common/module/mapper/SysUserDepartMapper.java

@@ -2,7 +2,7 @@ package cn.com.ctop.common.module.mapper;
 
 import cn.com.ctop.common.module.entity.SysUserDepart;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import io.lettuce.core.dynamic.annotation.Param;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -15,4 +15,6 @@ public interface SysUserDepartMapper extends BaseMapper<SysUserDepart>{
     List<SysUserDepart> getUserDepartByUid(@Param("userId") String userId);
 
 	SysUserDepart getUserDepartByUserId(@Param("userId") String userId);
+
+    List<String> getUserIds(@Param("ids") List<String> ids);
 }

+ 33 - 13
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/SysDepartMapper.xml

@@ -2,9 +2,11 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.common.module.mapper.SysDepartMapper">
 
-	<select id="queryUserDeparts" parameterType="String" resultType="cn.com.ctop.common.module.entity.SysDepart">
-	   select * from sys_depart where id IN ( select dep_id from sys_user_depart where user_id = #{userId} )
-	</select>
+    <select id="queryUserDeparts" parameterType="String" resultType="cn.com.ctop.common.module.entity.SysDepart">
+        select *
+        from sys_depart
+        where id IN (select dep_id from sys_user_depart where user_id = #{userId})
+    </select>
 
     <!-- 根据username查询所拥有的部门 -->
     <select id="queryDepartsByUsername" parameterType="String" resultType="cn.com.ctop.common.module.entity.SysDepart">
@@ -23,22 +25,40 @@
 
     <!-- 根据部门Id查询,当前和下级所有部门IDS -->
     <select id="getSubDepIdsByDepId" resultType="java.lang.String">
-		select id from sys_depart where del_flag = '0' and org_code like concat((select org_code from sys_depart where id=#{departId}),'%')
-	</select>
+        select id
+        from sys_depart
+        where del_flag = '0'
+          and org_code like concat((select org_code from sys_depart where id = #{departId}), '%')
+    </select>
 
     <!--根据部门编码获取我的部门下所有部门ids -->
     <select id="getSubDepIdsByOrgCodes" resultType="java.lang.String">
-		select id from sys_depart where del_flag = '0' and
-        <foreach collection="orgCodes" item="item" index="index"  open="(" separator="or" close=")">
+        select id from sys_depart where del_flag = '0' and
+        <foreach collection="orgCodes" item="item" index="index" open="(" separator="or" close=")">
             org_code LIKE CONCAT(#{item},'%')
         </foreach>
-	</select>
+    </select>
+
+    <select id="queryUserDepartsByDepartId" parameterType="String"
+            resultType="cn.com.ctop.common.module.entity.SysDepart">
+        select *
+        from sys_depart
+        where id = #{departId} limit 1
+    </select>
 
-    <select id="queryUserDepartsByDepartId" parameterType="String" resultType="cn.com.ctop.common.module.entity.SysDepart">
-		select * from sys_depart
-			where id = #{departId}
-			limit 1
-	</select>
+    <select id="getDepartmentIds" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT dep_id as 'id'
+        FROM sys_user_depart
+        WHERE user_id = #{userId}
+    </select>
+
+    <select id="checkLowestLevelDepartment" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT id,parent_id FROM sys_depart WHERE parent_id IN
+        <foreach item="item" index="index" collection="departIds"
+                 open="(" separator="," close=")">
+            #{item.id}
+        </foreach>
+    </select>
 
 
 </mapper>

+ 18 - 14
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/SysRoleMapper.xml

@@ -4,22 +4,26 @@
 
     <!-- 根据roleCode获取roleId -->
     <select id="getRoleIdByRoleCode" resultType="java.lang.String">
-		select
-		id
-		from sys_role
-		where role_code = #{roleCode}
-	</select>
+        select id
+        from sys_role
+        where role_code = #{roleCode}
+    </select>
 
     <!-- 根据userId获取角色code -->
     <select id="getRoleCodeByUserId" resultType="java.lang.String">
-		select
-		c.role_code
-		from
-		sys_user a
-		left join sys_user_role b on a.id = b.user_id
-		left join sys_role c on b.role_id = c.id
-        where
-        a.id = #{userId}
-	</select>
+        select c.role_code
+        from sys_user a
+                 left join sys_user_role b on a.id = b.user_id
+                 left join sys_role c on b.role_id = c.id
+        where a.id = #{userId}
+    </select>
+
+
+    <select id="queryRoleByUserId" resultType="cn.com.ctop.common.module.entity.SysRole">
+        SELECT t2.role_name,t2.role_code
+        FROM sys_user_role t1
+                 LEFT JOIN sys_role t2 ON t1.role_id = t2.id
+        WHERE t1.user_id = #{userId} LIMIT 1
+    </select>
 
 </mapper>

+ 16 - 7
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/SysUserDepartMapper.xml

@@ -2,17 +2,26 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.common.module.mapper.SysUserDepartMapper">
     <select id="getUserDepartByUid" parameterType="String" resultType="cn.com.ctop.common.module.entity.SysUserDepart">
-		SELECT *
-		FROM sys_user_depart
-		WHERE user_id = #{userId, jdbcType=VARCHAR}
+        SELECT *
+        FROM sys_user_depart
+        WHERE user_id = #{userId, jdbcType=VARCHAR}
     </select>
 
     <select id="getUserDepartByUserId" parameterType="String"
             resultType="cn.com.ctop.common.module.entity.SysUserDepart">
-		SELECT *
-		FROM sys_user_depart
-		WHERE user_id = #{userId, jdbcType=VARCHAR}
-		limit 1
+        SELECT *
+        FROM sys_user_depart
+        WHERE user_id = #{userId, jdbcType=VARCHAR} limit 1
+    </select>
+
+    <select id="getUserIds" resultType="java.lang.String">
+        SELECT user_id
+        FROM sys_user_depart
+        WHERE dep_id IN
+        <foreach item="id" index="index" collection="ids"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
     </select>
 
 </mapper>

+ 1 - 2
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/SysUserMapper.xml

@@ -313,8 +313,7 @@ SELECT
         <if test="sex != null and sex != ''">
             AND t1.sex =#{sex}
         </if>
-        ORDER BY updTime DESC
-        limit 99999
+
         ) t4
         GROUP BY t4.id
     </select>

+ 3 - 0
module-job-bytedance/src/main/resources/application-dev.yml

@@ -212,3 +212,6 @@ xxl:
       logretentiondays: 30
     admin:
       addresses: http://127.0.0.1:8090/xxl-job-admin
+zip:
+  local:
+    download-path: /data/unzip/

+ 3 - 0
module-job-bytedance/src/main/resources/application-jiaoyang.yml

@@ -227,3 +227,6 @@ xxl:
       logretentiondays: 30
     admin:
       addresses: http://129.28.150.229:8090/xxl-job-admin
+zip:
+  local:
+    download-path: /data/unzip/

+ 3 - 0
module-job-bytedance/src/main/resources/application-prod.yml

@@ -231,3 +231,6 @@ ai:
   callback:
     callback-unit-url: http://192.168.1.193:31012/ai_callback_add_group
     callback-creative-url: http://192.168.1.193:31012/ai_callback_add_creative
+zip:
+  local:
+    download-path: /data/unzip/

+ 3 - 0
module-job-bytedance/src/main/resources/application-test.yml

@@ -236,3 +236,6 @@ xxl:
       logretentiondays: 30
     admin:
       addresses: http://127.0.0.1:8090/xxl-job-admin
+zip:
+  local:
+    download-path: /data/unzip/

+ 2 - 2
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/CrowdListQueryJob.java

@@ -59,9 +59,9 @@ public class CrowdListQueryJob {
                                         crowdPackEntity.setStatDate(oldPack.getStatDate());
                                         crowdPackEntity.setUrl(oldPack.getUrl());
                                         crowdPackEntity.setSignature(oldPack.getSignature());
-                                        crowdPackEntity.setMessage("PUSH OK");
-                                        crowdPackEntity.setDataStatus(1);
                                     }
+                                    crowdPackEntity.setMessage("PUSH OK");
+                                    crowdPackEntity.setDataStatus(1);
                                     crowdPackService.save(crowdPackEntity);
                                 } else {
                                     crowdPackMapper.update(obj);

+ 64 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouBudgetJob.java

@@ -0,0 +1,64 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+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.kuaishou.modules.app.entity.KuaishouAccountBalanceBudget;
+import cn.com.ctop.kuaishou.modules.app.service.IKuaishouAccountBalanceBudgetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouAccountBudgetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import com.alibaba.fastjson.JSONObject;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Component
+public class KuaiShouBudgetJob {
+    @Autowired
+    private IKuaishouAccountBalanceBudgetService balanceBudgetService;
+    @Autowired
+    private IKuaishouInterfaceService iKuaishouInterfaceService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouAccountBudgetService accountBudgetService;
+
+    static ExecutorService executorService = Executors.newFixedThreadPool(8);
+
+    /**
+     * 定时更新快手账户余额和预算
+     *
+     * @throws
+     */
+    @XxlJob("kuaiShouBudgetJob")
+    public void execute() throws Exception {
+        if (DateUtils.getNowHour() == 2) {
+            //每日凌晨2点将预算全部置为无效,避免已关闭的账户留有僵尸数据。
+            balanceBudgetService.updateAllIsInvalidState();
+        }
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        tokens.forEach(token -> executorService.submit(() -> {
+            KuaishouAccountBalanceBudget budget = new KuaishouAccountBalanceBudget();
+            JSONObject fundJson = iKuaishouInterfaceService.fundGet(token);
+            JSONObject accountBudget = accountBudgetService.getAccountBudget(token);
+            if (!Check.isNull(accountBudget) && !Check.isNull(fundJson)) {
+                budget.setBalance(fundJson.getBigDecimal("balance"));
+                budget.setDayBudget(accountBudget.getBigDecimal("day_budget").divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_UP));
+                budget.setDayBudgetSchedule(accountBudget.getString("day_budget_schedule"));
+                budget.setAccountId(token.getAccountId());
+                budget.setState(1);
+                balanceBudgetService.replace(budget);
+            }
+        }));
+        XxlJobHelper.log("定时更新快手账户余额和预算完成");
+    }
+}
+

+ 48 - 19
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouHourlyGroupReportLoadJob.java

@@ -1,16 +1,19 @@
 package cn.com.ctop.job.kuaishou.handler;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
-import com.xxl.job.core.context.XxlJobHelper;
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouProjectData;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouProjectDataService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyGroupService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.text.SimpleDateFormat;
-import java.util.Date;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -24,26 +27,52 @@ import java.util.concurrent.Executors;
 public class KuaishouHourlyGroupReportLoadJob {
     @Autowired
     private ICtopOauthTokenService tokenService;
-    @Autowired
-    private IKuaishouInterfaceService kuaishouInterfaceService;
     static ExecutorService executorService = Executors.newFixedThreadPool(5);
+    @Autowired
+    private IKuaiShouProjectDataService kuaiShouProjectDataService;
+    @Autowired
+    private IUserAllocationService allocationService;
+    @Autowired
+    private IKuaishouReportHourlyGroupService hourlyGroupService;
+
 
     @XxlJob("kuaishouHourlyGroupReport")
     public void execute() throws Exception {
-        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);
-        }
+        //增加接口的开始和结束日期
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
         //1:查询当日数据
-        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
-        if (null == tokens || tokens.isEmpty()) {
-            XxlJobHelper.log("定时获取快手数据异常:未获取到可用的token");
-            XxlJobHelper.handleFail();
-            return ;
+        QueryWrapper<KuaiShouProjectData> queryWrapper = new QueryWrapper();
+        queryWrapper.eq("project_status", 0);
+        List<KuaiShouProjectData> list = kuaiShouProjectDataService.list(queryWrapper);
+        if (Check.isNull(list)) {
+            return;
+        }
+        for (KuaiShouProjectData projectData : list) {
+            Long projectId = projectData.getProjectId();
+            if (Check.isNull(projectId)) {
+                continue;
+            }
+            QueryWrapper<UserAllocation> allocationQueryWrapper = new QueryWrapper<>();
+            allocationQueryWrapper.eq("project_id", projectId);
+            allocationQueryWrapper.eq("account_status", 0);
+            List<UserAllocation> accountIds = allocationService.list(allocationQueryWrapper);
+            if (Check.isNull(accountIds)) {
+                continue;
+            }
+            for (UserAllocation allocation : accountIds) {
+                CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
+                if (Check.isNull(token)) {
+                    continue;
+                }
+
+                executorService.submit(new Runnable() {
+                    @Override
+                    public void run() {
+                        hourlyGroupService.getAdvertiserGroupReportHourly(token.getAccountId(), token.getAccessToken(), yesterday, yesterday);
+                    }
+                });
+            }
         }
-        Date finalGetDate = getDate;
-        tokens.forEach(token -> executorService.submit(() -> kuaishouInterfaceService.getAdvertiserGroupReportHourly(token, finalGetDate, finalGetDate)));
     }
 }

+ 66 - 2
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouMatDailyReportJob.java

@@ -1,8 +1,14 @@
 package cn.com.ctop.job.kuaishou.handler;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouReportDailyMaterialService;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouProjectData;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouProjectDataService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import org.jeecg.common.util.DateUtils;
@@ -19,20 +25,78 @@ public class KuaishouMatDailyReportJob {
     private ICtopOauthTokenService tokenService;
     @Autowired
     private IKuaiShouReportDailyMaterialService kuaiShouReportDailyMaterialService;
+    @Autowired
+    private IKuaiShouProjectDataService kuaiShouProjectDataService;
+    @Autowired
+    private IUserAllocationService allocationService;
+
     static ExecutorService executorService = Executors.newFixedThreadPool(10);
+    static ExecutorService hourExecutorService = Executors.newFixedThreadPool(5);
 
+    /**
+     * 素材日报
+     *
+     * @throws Exception
+     */
     @XxlJob("kuaishouMaterialReportByStateDate")
     public void execute() throws Exception {
         //增加接口的开始和结束日期
         String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-        String endDate =DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+        String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
         String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -2);
         //1:查询当日数据
         List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
         tokens.forEach(token -> executorService.submit(() -> {
-            kuaiShouReportDailyMaterialService.getMaterialReportByAccountIdAndStatDate(token.getAccountId(),token.getAccessToken(),startDate,endDate,1);
+            kuaiShouReportDailyMaterialService.getMaterialReportByAccountIdAndStatDate(token.getAccountId(), token.getAccessToken(), startDate, endDate, "DAILY", 1);
         }));
         XxlJobHelper.log("快手物料数据同步完成");
     }
 
+
+    /**
+     * 素材时报
+     *
+     * @throws Exception
+     */
+    @XxlJob("kuaishouMaterialHourReportByStateDate")
+    public void kuaishouMaterialHourReportByStateDate() throws Exception {
+        //增加接口的开始和结束日期
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+        //1:查询当日数据
+        QueryWrapper<KuaiShouProjectData> queryWrapper = new QueryWrapper();
+        queryWrapper.eq("project_status", 0);
+        List<KuaiShouProjectData> list = kuaiShouProjectDataService.list(queryWrapper);
+        if (Check.isNull(list)) {
+            return;
+        }
+
+        for (KuaiShouProjectData projectData : list) {
+            Long projectId = projectData.getProjectId();
+            if (Check.isNull(projectId)) {
+                continue;
+            }
+            QueryWrapper<UserAllocation> allocationQueryWrapper = new QueryWrapper<>();
+            allocationQueryWrapper.eq("project_id", projectId);
+            allocationQueryWrapper.eq("account_status", 0);
+            List<UserAllocation> accountIds = allocationService.list(allocationQueryWrapper);
+            if (Check.isNull(accountIds)) {
+                continue;
+            }
+            for (UserAllocation allocation : accountIds) {
+                CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
+                if (Check.isNull(token)) {
+                    continue;
+                }
+
+                hourExecutorService.submit(new Runnable() {
+                    @Override
+                    public void run() {
+                        kuaiShouReportDailyMaterialService.getMaterialReportByAccountIdAndStatDate(token.getAccountId(), token.getAccessToken(), yesterday, yesterday, "HOURLY", 1);
+                    }
+                });
+            }
+        }
+    }
+
 }

+ 3 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/enums/KuaishouCreativeMatTypeEnum.java

@@ -10,11 +10,11 @@ public enum KuaishouCreativeMatTypeEnum {
      * 快手创意素材获取类型
      */
     KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_NEW("41","自定义上新",-10L,-5L),
-    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_HIGH_quality("42","自定义高质量",-14*60*24L,-1*60*24L),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_HIGH_quality("42","自定义高质量",-28*60*24L,-1*60*24L),
     KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_MISSING("43","自定义上新",-60*60*24L,-1*60*24L),
     KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_HISTORY("44","自定义历史",-60*60*24L,-1*60*24L),
-    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_PROGRAM_NEW("71","程序化上新",-1*60*24L,-5L),
-    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_PROGRAM_HIGH_quality("72","程序化高质量",-14*60*24L,-1*60*24L),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_PROGRAM_NEW("71","程序化上新",-3*60*24L,-5L),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_PROGRAM_HIGH_quality("72","程序化高质量",-28*60*24L,-1*60*24L),
     KUAISHOU_CREATIVE_MAT_TYPE_ENUM_PROGRAM_MISSING("73","程序化上新",-60*60*24L,-1*60*24L),
     KUAISHOU_CREATIVE_MAT_TYPE_ENUM_PROGRAM_HISTORY("74","程序化历史",-60*60*24L,-1*60*24L),;
 

+ 127 - 56
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java

@@ -98,6 +98,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                         log.info("账户:{},appid({}) 数据不存在", accountId, appIdArray.getLong(i));
                         continue;
                     }
+
                     if (null != strategy.getGeneralTrack() && strategy.getGeneralTrack() == 0) {
                         strategy.setClickTrackUrl(appInfo.getTrackUrl());
                         strategy.setImpressionUrl(appInfo.getTrackUrl());
@@ -149,7 +150,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                         unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                         videoCnt--;
                         JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy);
-                        createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid);
+                        createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid, appInfo.getAppVersion());
                         if (videoCnt <= 0) {
                             return videoCnt;
                         }
@@ -185,7 +186,12 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 unitCnt++;
                 String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
                 String unitName = getName(strategy.getGroupName(), strategy, createType, null, timestamp, unitCnt);
-                Long appId = JSONArray.parseArray(strategy.getAppIdArray()).getLong(0);
+
+                Long appId = null;
+                if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
+                    appId = JSONArray.parseArray(strategy.getAppIdArray()).getLong(0);
+                }
+
                 JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
                 Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                 Integer unitCode = (Integer) unitCreateResult.get("code");
@@ -208,7 +214,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                 videoCnt--;
                 JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy);
-                createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid);
+                createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid, null);
                 if (videoCnt <= 0) {
                     return 0L;
                 }
@@ -235,14 +241,24 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         }
         //1:获取视频信息
         kuaishouInterfaceService.getVideoList(token, DateUtils.date2Str(), DateUtils.date2Str());
-        Long timeStart = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString() + createType.toString());
-        Long timeEnd = KuaishouCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString() + createType.toString());
+        //2:判定账户是否单一应用
+        Long timeStart = null;
+        Long timeEnd = null;
+
+        Integer singleAppid = strategy.getSingleAppid();
+        if (null != singleAppid && singleAppid == 0) {
+            timeStart = -7 * 60 * 24L;
+            timeEnd = -5L;
+        } else {
+            timeStart = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString() + createType.toString());
+            timeEnd = KuaishouCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString() + createType.toString());
+        }
+
         Long now = System.currentTimeMillis();
         String startTime = DateUtils.formatDateTime(now + timeStart * 60 * 1000L);
         String endTime = DateUtils.formatDateTime(now + timeEnd * 60 * 1000L);
 
-        //2:判定账户是否单一应用
-        Integer singleAppid = strategy.getSingleAppid();
+
         if (null != singleAppid && singleAppid == 0) {
             //多应用
             String appidString = strategy.getAppIdArray();
@@ -300,7 +316,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                         Long unitId = (Long) unitCreateResult.get("unitId");
                         unitLevelOperationRecord.setUnitId(unitId);
                         unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
-                        JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j);
+                        JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, appInfo.getAppVersion());
                         createProgramCreative(token, creativeParams, strategy);
                     }
                 }
@@ -317,7 +333,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             if (null == newCampaignId) {
                 return;
             }
-
             //创意
             List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
             for (int j = 1; j < splitVideos.size() + 1; j++) {
@@ -326,8 +341,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 String unitName = getName(strategy.getGroupName(), strategy, createType, null, timestamp, null);
                 String appIdString = strategy.getAppIdArray();
                 Long appId = null;
-                if (!Check.isNull(appIdString) && !Check.isNull(JSON.parseArray(appIdString))) {
-                    appId = JSON.parseArray(appIdString).getLong(0);
+                if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
+                    if (!Check.isNull(appIdString) && !Check.isNull(JSON.parseArray(appIdString))) {
+                        appId = JSON.parseArray(appIdString).getLong(0);
+                    }
                 }
                 JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId);
                 Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
@@ -349,7 +366,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 Long unitId = (Long) unitCreateResult.get("unitId");
                 unitLevelOperationRecord.setUnitId(unitId);
                 unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
-                JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j);
+                JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, null);
                 createProgramCreative(token, creativeParams, strategy);
             }
         }
@@ -436,11 +453,21 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         log.info("创建程序化创意成功");
     }
 
-    private JSONObject programCreativeParams(CtopOauthToken token, Long unitId, List<KuaiShouVideoGet> list, AiKuaishouAdvertiserStrategy strategy, Integer creativeCnt) {
+    private JSONObject programCreativeParams(CtopOauthToken token, Long unitId, List<KuaiShouVideoGet> list, AiKuaishouAdvertiserStrategy strategy, Integer creativeCnt, String appVersion) {
         JSONObject programJson = new JSONObject();
         programJson.put("advertiser_id", token.getAccountId());
         programJson.put("unit_id", unitId);
-        programJson.put("package_name", "程序化创意" + creativeCnt);
+        if (strategy.getSingleAppid() != null && strategy.getSingleAppid() == 0) {  // 多应用情况下 创意名称已app-versionMI命名
+            if (!Check.isNull(appVersion)) {
+                programJson.put("package_name", appVersion);
+            } else {
+                programJson.put("package_name", "程序化创意" + creativeCnt);
+            }
+
+        } else {
+            programJson.put("package_name", "程序化创意" + creativeCnt);
+        }
+
         JSONArray horizontalPhotoIds = new JSONArray();
         JSONArray verticalPhotoIds = new JSONArray();
         JSONArray coverImageTokens = new JSONArray();
@@ -571,6 +598,9 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
      * @param startTime  开始时间
      * @param endTime    结束时间
      */
+    @Autowired
+    private IKuaiShouCampaignService campaignService;
+
     private List<KuaiShouVideoGet> getVideosByParams(AiKuaishouAdvertiserStrategy strategy, String startTime, String endTime, AiKuaiShouAppInfo appInfo, Integer createType, Long videoCnt) {
         if (createType == 1) {
             return getNewVideoListByParams(strategy, startTime, endTime, appInfo);
@@ -584,23 +614,34 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
     }
 
     private Long getCampaignId(AiKuaishouAdvertiserStrategy strategy, CtopOauthToken token, String replaceString, String checkType, Integer createType, AiKuaiShouAppInfo appInfo, String uuid) {
-        JSONArray campaignList;
-        String timestamp = null;
-        if ("ALL_CAMPAIGN".equals(checkType)) {
+        //  JSONArray campaignList;
+        String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
+        /*if ("ALL_CAMPAIGN".equals(checkType)) {
             campaignList = kuaishouInterfaceService.getCampaignList(token, null, null, 1);
         } else {
             timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
             campaignList = kuaishouInterfaceService.getCampaignList(token, new Date(), new Date(), 1);
-        }
+        }*/
 
-        if (null != campaignList && !campaignList.isEmpty()) {
+       /* if (!Check.isNull(campaignList)){
             for (int i = 0; i < campaignList.size(); i++) {
                 JSONObject jsonObject = campaignList.getJSONObject(i);
                 if (jsonObject.getString("campaign_name").contains(replaceString)) {
                     return jsonObject.getLong("campaign_id");
                 }
             }
+        }*/
+        Long campaignId = null;
+        if ("ALL_CAMPAIGN".equals(checkType)) {
+            campaignId = campaignService.getCampaignIdByAccountAndName(strategy.getAccountId(), replaceString);
+        } else if ("TODAY".equals(checkType)) {
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd") + " 00:00:01";
+            campaignId = campaignService.getCampaignIdByAccountAndNameAndDate(strategy.getAccountId(), replaceString, nowDate);
+        }
+        if (!Check.isNull(campaignId)) {
+            return campaignId;
         }
+
         // 不存在“上新”计划,则创建一个计划
         JSONObject campaignParams = new JSONObject();
         campaignParams.put("advertiser_id", token.getAccountId());
@@ -622,7 +663,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             aiKuaishouCampaignLevelOperationRecordService.saveOrUpdate(record);
             return null;
         }
-        Long campaignId = (Long) campaignCreateResult.get("campaignId");
+        campaignId = (Long) campaignCreateResult.get("campaignId");
         record.setCampaignId(campaignId);
         aiKuaishouCampaignLevelOperationRecordService.saveOrUpdate(record);
         return campaignId;
@@ -633,6 +674,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         // 拼装创建组的入参 json
         JSONObject unitParams = new JSONObject();
         Integer unitType = strategy.getUnitType();
+
+
         //创意制作方式
         unitParams.put("unit_type", unitType);
         unitParams.put("advertiser_id", token.getAccountId());
@@ -640,10 +683,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         unitParams.put("unit_name", unitName);
         //出价类型
         unitParams.put("bid_type", strategy.getBidType());
-        // 优先从系统应用商店下载
-        if (null != strategy.getUseAppMarket()) {
-            unitParams.put("use_app_market", strategy.getUseAppMarket());
-        }
+
         //组单日预算
         if (null != strategy.getUnitDayBudget() && strategy.getUnitDayBudget() != 0) {
             unitParams.put("day_budget", strategy.getUnitDayBudget());
@@ -651,9 +691,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             unitParams.put("day_budget", 0);
         }
         //应用商店列表
-        if (null != strategy.getAppStore() && !"".equals(strategy.getAppStore())) {
-            unitParams.put("app_store", JSON.parseArray(strategy.getAppStore()));
-        }
+
         unitParams.put("ocpx_action_type", strategy.getOcpxActionType());
 
         //出价
@@ -686,17 +724,63 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 
         Integer sceneId = null;
         String scenceIdString = strategy.getSceneId();
+
         if (!Check.isNull(scenceIdString) && !Check.isNull(JSON.parseArray(scenceIdString))) {
             JSONArray scenceArray = JSON.parseArray(scenceIdString);
             sceneId = scenceArray.getInteger(0);
-            //资源位置
-            if (unitType == 7) {
-                //程序化
-                scenceArray = cleanPramgramErrorScence(scenceArray);
-            }
             unitParams.put("scene_id", scenceArray);
         }
 
+        Integer campaignType = strategy.getCampaignType();
+        if (campaignType == 2) { // 提升应用安装
+            //应用ID
+            if (!Check.isNull(appId)) {
+                unitParams.put("app_id", appId);
+            }
+            // 优先从系统应用商店下载
+            if (null != strategy.getUseAppMarket()) {
+                unitParams.put("use_app_market", strategy.getUseAppMarket());
+            }
+            if (null != strategy.getAppStore() && !"".equals(strategy.getAppStore())) {
+                unitParams.put("app_store", JSON.parseArray(strategy.getAppStore()));
+            }
+        } else if (campaignType == 3) { //  获取电商下单
+
+            //url类型
+            if (!Check.isNull(strategy.getUrlType())) {
+                unitParams.put("url_type", strategy.getUrlType());
+            }
+
+            if (!Check.isNull(strategy.getUrl())) {
+                unitParams.put("url", strategy.getUrl());
+            }
+
+        } else if (campaignType == 5) { //收集销售线索
+            //url类型
+            if (!Check.isNull(strategy.getWebUriType())) {
+                unitParams.put("web_uri_type", strategy.getWebUriType());
+            }
+            //url
+            if (!Check.isNull(strategy.getUrl())) {
+                unitParams.put("url", strategy.getUrl());
+            }
+
+        } else if (campaignType == 7) { //  提高应用活跃
+            //  appId
+            if (!Check.isNull(appId)) {
+                unitParams.put("app_id", appId);
+            }
+
+            //  url
+            if (!Check.isNull(strategy.getUrl())) {
+                unitParams.put("url", strategy.getUrl());
+            }
+            //调起链接
+            if (!Check.isNull(strategy.getSchemaUri())) {
+                unitParams.put("schema_uri", strategy.getSchemaUri());
+            }
+        }
+
         //投放开始时间
         if (!Check.isNull(strategy.getBeginTime())) {
             unitParams.put("begin_time", strategy.getBeginTime());
@@ -715,26 +799,8 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         if (!Check.isNull(strategy.getConvertId())) {
             unitParams.put("convert_id", strategy.getConvertId());
         }
-        //url类型
-        if (!Check.isNull(strategy.getUrlType())) {
-            unitParams.put("url_type", strategy.getUrlType());
-        }
-        //url类型
-        if (!Check.isNull(strategy.getWebUriType())) {
-            unitParams.put("web_uri_type", strategy.getWebUriType());
-        }
-        //url
-        if (!Check.isNull(strategy.getUrl())) {
-            unitParams.put("url", strategy.getUrl());
-        }
-        //调起链接
-        if (!Check.isNull(strategy.getSchemaUri())) {
-            unitParams.put("schema_uri", strategy.getSchemaUri());
-        }
-        //应用ID
-        if (!Check.isNull(appId)) {
-            unitParams.put("app_id", appId);
-        }
+
+
         //创意展现方式
         if (!Check.isNull(strategy.getShowMode())) {
             unitParams.put("show_mode", strategy.getShowMode());
@@ -1007,14 +1073,14 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 
     private void createCreativeByImage(List<MaterialCutFrame> cutFrameList, CtopOauthToken token, JSONObject creativeParams,
                                        Long campaignId, Long unitId, KuaiShouVideoGet videoItem,
-                                       int imageNumber, AiKuaishouAdvertiserStrategy strategy, String uuid) {
+                                       int imageNumber, AiKuaishouAdvertiserStrategy strategy, String uuid, String appVersion) {
         if ((null != cutFrameList && !cutFrameList.isEmpty())) {
             for (int i = 0; i < cutFrameList.size(); i++) {
                 String imageCode = cutFrameList.get(i).getSignature();
                 String imageUrl = cutFrameList.get(i).getUrl();
                 String imageToken = getImageToken(imageUrl, imageCode, token.getAccountId(), token.getAccessToken());
                 creativeParams.put("image_token", imageToken);
-                createCreative(token, creativeParams, campaignId, unitId, i + 1, videoItem, strategy, uuid);
+                createCreative(token, creativeParams, campaignId, unitId, i + 1, videoItem, strategy, uuid, appVersion);
                 imageNumber--;
                 if (imageNumber <= 0) {
                     break;
@@ -1088,8 +1154,13 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 
 
     private void createCreative(CtopOauthToken token, JSONObject creativeParams, Long campaignId, Long unitId,
-                                int creativeCnt, KuaiShouVideoGet videoGet, AiKuaishouAdvertiserStrategy strategy, String uuid) {
-        String creativeName = "自定义创意_" + creativeCnt;
+                                int creativeCnt, KuaiShouVideoGet videoGet, AiKuaishouAdvertiserStrategy strategy, String uuid, String appVersion) {
+        String creativeName = null;
+        if (!Check.isNull(appVersion)) {
+            creativeName = appVersion + "_" + creativeCnt;
+        } else {
+            creativeName = "自定义创意_" + creativeCnt;
+        }
         creativeParams.put("creative_name", creativeName);
         Map<String, Object> creativeCreateResult = kuaishouInterfaceService.creativeCreate(token.getAccessToken(), token.getAccountId(), creativeParams, 1);
         Integer creativeCode = (Integer) creativeCreateResult.get("code");

+ 76 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/app/entity/KuaishouAccountBalanceBudget.java

@@ -0,0 +1,76 @@
+package cn.com.ctop.kuaishou.modules.app.entity;
+
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 快手-账余额、预算
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-04-16
+ */
+@Data
+@TableName("ctop_kuaishou_account_balance_budget")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_account_balance_budget对象", description = "快手-账余额、预算")
+public class KuaishouAccountBalanceBudget {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 状态 0 失效,1有效
+     */
+    private Integer state;
+
+    /**
+     * 账户总余额
+     */
+    @Excel(name = "账户总余额", width = 15)
+    @ApiModelProperty(value = "账户总余额")
+    private BigDecimal balance;
+    /**
+     * 单日预算
+     */
+    @Excel(name = "单日预算", width = 15)
+    @ApiModelProperty(value = "单日预算")
+    private BigDecimal dayBudget;
+    /**
+     * 分日预算
+     */
+    @Excel(name = "分日预算", width = 15)
+    @ApiModelProperty(value = "分日预算")
+    private String dayBudgetSchedule;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+}

+ 19 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/app/mapper/KuaishouAccountBalanceBudgetMapper.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.app.mapper;
+
+
+import cn.com.ctop.kuaishou.modules.app.entity.KuaishouAccountBalanceBudget;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 快手-账余额、预算
+ *
+ * @author: jeecg-boot
+ * @date: 2021-04-16
+ * @cersion: V1.0
+ */
+public interface KuaishouAccountBalanceBudgetMapper extends BaseMapper<KuaishouAccountBalanceBudget> {
+
+    void replace(KuaishouAccountBalanceBudget budget);
+
+    void updateAllIsInvalidState();
+}

+ 36 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/app/mapper/xml/KuaishouAccountBalanceBudgetMapper.xml

@@ -0,0 +1,36 @@
+<?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.app.mapper.KuaishouAccountBalanceBudgetMapper">
+
+    <insert id="replace">
+        replace
+        into ctop_kuaishou_account_balance_budget
+        (
+        id,
+        account_id ,
+        balance ,
+        day_budget ,
+        day_budget_schedule ,
+        state,
+        create_time
+        )
+        values
+        (
+        #{id},
+        #{accountId},
+        #{balance},
+        #{dayBudget},
+        #{dayBudgetSchedule},
+        #{state},
+        #{createTime}
+        )
+    </insert>
+
+
+    <update id="updateAllIsInvalidState">
+        update ctop_kuaishou_account_balance_budget
+        set state =0
+        where 1 = 1
+    </update>
+
+</mapper>

+ 18 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/app/service/IKuaishouAccountBalanceBudgetService.java

@@ -0,0 +1,18 @@
+package cn.com.ctop.kuaishou.modules.app.service;
+
+
+import cn.com.ctop.kuaishou.modules.app.entity.KuaishouAccountBalanceBudget;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 快手-账余额、预算
+ * @Author: jeecg-boot
+ * @Date: 2021-04-16
+ * @Version: V1.0
+ */
+public interface IKuaishouAccountBalanceBudgetService extends IService<KuaishouAccountBalanceBudget> {
+
+    void replace(KuaishouAccountBalanceBudget budget);
+
+    void updateAllIsInvalidState();
+}

+ 32 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/app/service/impl/KuaishouAccountBalanceBudgetServiceImpl.java

@@ -0,0 +1,32 @@
+package cn.com.ctop.kuaishou.modules.app.service.impl;
+
+import cn.com.ctop.kuaishou.modules.app.entity.KuaishouAccountBalanceBudget;
+import cn.com.ctop.kuaishou.modules.app.mapper.KuaishouAccountBalanceBudgetMapper;
+import cn.com.ctop.kuaishou.modules.app.service.IKuaishouAccountBalanceBudgetService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * 快手-账余额、预算
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-04-16
+ */
+@Service
+public class KuaishouAccountBalanceBudgetServiceImpl extends ServiceImpl<KuaishouAccountBalanceBudgetMapper, KuaishouAccountBalanceBudget> implements IKuaishouAccountBalanceBudgetService {
+
+    @Autowired
+    private KuaishouAccountBalanceBudgetMapper budgetMapper;
+
+    @Override
+    public void replace(KuaishouAccountBalanceBudget budget) {
+        budgetMapper.replace(budget);
+    }
+
+    @Override
+    public void updateAllIsInvalidState() {
+        budgetMapper.updateAllIsInvalidState();
+    }
+}

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

@@ -109,7 +109,6 @@ public class BatchController {
             SpendVo spendVo = new SpendVo();
             JSONObject fundJson = iKuaishouInterfaceService.fundGet(oauthToken);
 
-
             if (!Check.isNull(fundJson)) {
                 spendVo.setBalance(fundJson.getBigDecimal("balance")); // 余额
             }
@@ -120,15 +119,7 @@ public class BatchController {
             spendVo.setBudget(budget);
             result.setSuccess(true);
             result.setResult(spendVo);
-
             String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-            String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
-            String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, 1);
-
-
-            iKuaishouInterfaceService.getCampaignList(oauthToken, new java.util.Date(), new java.util.Date());
-
-
             Thread thread = new Thread() {
                 @Override
                 public void run() {
@@ -149,21 +140,12 @@ public class BatchController {
             Thread thread2 = new Thread() {
                 @Override
                 public void run() {
-                    // syncPullMaterialService.getSyncVideoList(accountId, nowDate, nowDate);
                     iKuaishouInterfaceService.getVideoList(oauthToken, nowDate, nowDate);
 
                 }
             };
             thread2.start();
 
-          /*  Thread thread3 = new Thread() {
-                @Override
-                public void run() {
-                    iKuaishouInterfaceService.getSuZaoList(oauthToken.getAccessToken(), accountId, 1, nowDate, endDate);
-                }
-            };
-            thread3.start();*/
-
             Thread thread4 = new Thread() {
                 @Override
                 public void run() {
@@ -172,7 +154,6 @@ public class BatchController {
                 }
             };
             thread4.start();
-
         } catch (Exception e) {
             e.printStackTrace();
             result.setSuccess(false);
@@ -198,10 +179,11 @@ public class BatchController {
                                                            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                            HttpServletRequest req) {
         Result<IPage<KuaiShouCampaign>> result = new Result<>();
+        CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(kuaiShouCampaign.getAccountId());
+        iKuaishouInterfaceService.getCampaignList(oauthToken, new java.util.Date(), new java.util.Date());
         String campaignName = kuaiShouCampaign.getCampaignName();
         kuaiShouCampaign.setCampaignName(null);
         if (!Check.isNull(kuaiShouCampaign.getCampaignId())) {
-            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(kuaiShouCampaign.getAccountId());
             iKuaishouInterfaceService.getCampaign(oauthToken.getAccessToken(), kuaiShouCampaign.getAccountId(), kuaiShouCampaign.getCampaignId());
         }
         QueryWrapper<KuaiShouCampaign> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouCampaign, req.getParameterMap());

+ 4 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCampaignMapper.java

@@ -21,4 +21,8 @@ public interface KuaiShouCampaignMapper extends BaseMapper<KuaiShouCampaign> {
     List<Long> queryCampaignIdByAccountId(Long accountId);
 
     Integer getNewDataByAccountIdAndDate(@Param("accountId") Long accountId, @Param("statDate") String statDate);
+
+    Long getCampaignIdByAccountAndName(@Param("accountId") Long accountId, @Param("name") String replaceString);
+
+    Long getCampaignIdByAccountAndNameAndDate(@Param("accountId") Long accountId, @Param("name") String replaceString, @Param("nowDate") String nowDate);
 }

+ 16 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCampaignMapper.xml

@@ -54,4 +54,20 @@
      where account_id = #{accountId}
      and DATE_FORMAT(put_create_time,'%Y-%m-%d') = #{statDate}
     </select>
+    <select id="getCampaignIdByAccountAndName" resultType="java.lang.Long">
+        select campaign_id  from  ctop_kuaishou_campaign where  account_id = #{accountId}
+        and campaign_name like CONCAT('%',CONCAT(#{name},'%'))
+        order by put_create_time DESC
+        limit 1
+
+
+    </select>
+    <select id="getCampaignIdByAccountAndNameAndDate" resultType="java.lang.Long">
+          select campaign_id  from  ctop_kuaishou_campaign where  account_id = #{accountId}
+        and campaign_name like CONCAT('%',CONCAT(#{name},'%'))
+        and put_create_time &gt;= #{nowDate}
+        order by put_create_time DESC
+        limit 1
+
+    </select>
 </mapper>

+ 4 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCampaignService.java

@@ -23,4 +23,8 @@ public interface IKuaiShouCampaignService extends IService<KuaiShouCampaign> {
     KuaiShouCampaign getCampaignByAccountAndCampaign(Long accountId, Long campaignId);
 
     Integer getNewDataByAccountIdAndDate(Long accountId, String statDate);
+
+    Long getCampaignIdByAccountAndName(Long accountId, String replaceString);
+
+    Long getCampaignIdByAccountAndNameAndDate(Long accountId, String replaceString, String nowDate);
 }

+ 4 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCreativeService.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -70,4 +71,7 @@ public interface IKuaiShouCreativeService extends IService<KuaiShouCreative> {
     String getClickTrackUrl(Long accountId, Long unitId);
 
     List<KuaiShouCreative> getCreativeListByAccountIdAndUnitId(Long accountId, Long unitId);
+
+
+    void getProgramCreative(CtopOauthToken oauthToken, int page);
 }

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

@@ -17,7 +17,7 @@ public interface IKuaiShouReportDailyMaterialService extends IService<KuaiShouRe
 
     List<KuaiShouVideoGetVo> getVideoList(Map<String, Object> requestMap);
 
-    void getMaterialReportByAccountIdAndStatDate(Long accountId, String token, String startDate, String endDate, Integer page);
+    void getMaterialReportByAccountIdAndStatDate(Long accountId, String token, String startDate, String endDate,String temporalGranularity, Integer page);
 
     List<KuaiShouReportDailyMaterial> getSignatureByDate(String date);
 

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

@@ -5,11 +5,7 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.kuaishou.modules.batch.entity.vo.ConvertVo;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCampaign;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCreative;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCampaign;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCreative;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyGroup;
+import cn.com.ctop.kuaishou.modules.report.entity.*;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 
@@ -316,14 +312,6 @@ public interface IKuaishouInterfaceService {
      */
     void getAdvertiserCampaignReportHourly(CtopOauthToken token, Date startDate, Date endDate);
 
-    /**
-     * 获取组时报
-     *
-     * @param token
-     * @param startDate
-     * @param endDate
-     */
-    void getAdvertiserGroupReportHourly(CtopOauthToken token, Date startDate, Date endDate);
 
     /**
      * 获取创意时报 暂停使用

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

@@ -45,10 +45,11 @@ public class KuaiShouActionBarTextServiceImpl extends ServiceImpl<KuaiShouAction
         queryWrapper.last("limit 1");
         CtopOauthToken token = tokenService.getOne(queryWrapper);
         List list = new ArrayList();
-        list.add(2);
+     /*   list.add(2);
         list.add(3);
         list.add(4);
-        list.add(5);
+        list.add(5);*/
+        list.add(7);
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.ACTION_BAR_TEXT_LIST;
         Map<String, String> headers = new HashMap<>();
         headers.put("Access-Token", token.getAccessToken());
@@ -60,6 +61,7 @@ public class KuaiShouActionBarTextServiceImpl extends ServiceImpl<KuaiShouAction
             requestJson.put("campaign_type", list.get(i));
             String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
             JSONObject resultJson = JSONObject.parseObject(result);
+            System.err.println(resultJson);
             Integer code = resultJson.getInteger("code");
             if (code == 0) {
                 JSONObject data = resultJson.getJSONObject("data");
@@ -69,7 +71,7 @@ public class KuaiShouActionBarTextServiceImpl extends ServiceImpl<KuaiShouAction
                     if (!Check.isNull(action_bar_text)) {
                         Map<String, Object> deleteMap = new HashMap<>();
                         deleteMap.put("type", campaign_type);
-                        actionBarTextMapper.deleteByMap(deleteMap);
+                   //     actionBarTextMapper.deleteByMap(deleteMap);
                         for (int j = 0; j < action_bar_text.size(); j++) {
                             String actionBarText = action_bar_text.getString(j);
                             KuaiShouActionBarText kuaiShouActionBarText = new KuaiShouActionBarText();

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

@@ -81,4 +81,14 @@ public class KuaiShouCampaignServiceImpl extends ServiceImpl<KuaiShouCampaignMap
         return campaignMapper.getNewDataByAccountIdAndDate(accountId, statDate);
     }
 
+    @Override
+    public Long getCampaignIdByAccountAndName(Long accountId, String replaceString) {
+        return campaignMapper.getCampaignIdByAccountAndName(accountId, replaceString);
+    }
+
+    @Override
+    public Long getCampaignIdByAccountAndNameAndDate(Long accountId, String replaceString, String nowDate) {
+        return campaignMapper.getCampaignIdByAccountAndNameAndDate(accountId, replaceString, nowDate);
+    }
+
 }

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

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
@@ -304,4 +305,79 @@ public class KuaiShouCreativeServiceImpl extends ServiceImpl<KuaiShouCreativeMap
     }
 
 
+    @Override
+    public void getProgramCreative(CtopOauthToken token, int page) {
+
+        log.info("获取视频数据,accountId:{}", token.getAccountId());
+        String url1 = "https://ad.e.kuaishou.com/rest/openapi/v2/creative/advanced/program/list";
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token.getAccessToken());
+        Map<String, Object> param = new HashMap<>();
+        param.put("advertiser_id", token.getAccountId());
+        param.put("page_size", 500);
+        param.put("page", page);
+
+        String result = HttpUtils.httpPostRequest(url1, param, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取快手视频列表数据异常:{},accountId:{}", message, token.getAccountId());
+            return;
+        }
+        JSONObject dataJson = resultJson.getJSONObject("data");
+        if (Check.isNull(dataJson)) {
+            return;
+        }
+        JSONArray details = dataJson.getJSONArray("details");
+        if (Check.isNull(details)) {
+            return;
+        }
+
+        for (int i = 0; i < details.size(); i++) {
+            JSONObject jsonObject = details.getJSONObject(i);
+            if (Check.isNull(jsonObject)) {
+                continue;
+            }
+
+            String updateUrl = "https://ad.e.kuaishou.com/rest/openapi/v2/creative/advanced/program/update";
+
+            Map<String, String> headers1 = new HashMap<>();
+            headers1.put("Content-Type", "application/json");
+            headers1.put("Access-Token", token.getAccessToken());
+            Map<String, Object> param1 = new HashMap<>();
+            param1.put("advertiser_id", token.getAccountId());
+            param1.put("unit_id", jsonObject.getLong("unit_id"));
+
+          /*  String clickTrackUrl = jsonObject.getString("click_url").replace("&idfa_md5=__IDFA__", "").replace("&idfa_md5=__IDFA2__", "");
+            if (Check.isNull(clickTrackUrl)) {
+                continue;
+            }
+
+            if (clickTrackUrl.contains("&ad_name=__DNAME__")) {
+                continue;
+            }*/
+
+            String replaceUrll = "https://click-wailaxin.1sapp.com/vendor/feedback/reportClick?platform=kuaishou&feedback_type=android&account_id=19&plan_id=__DID__&adgroup_id=__AID__&creative_id=__CID__&imei=__IMEI2__&mac=__MAC__&androidid=__ANDROIDID2__&ts=__TS__&ip=__IP__&ua=__UA__&callback=__CALLBACK__&oaid=__OAID__&app=dxqlb";
+
+            param1.put("click_url", replaceUrll);
+            String result1 = HttpUtils.httpPostRequest(updateUrl, param1, headers1);
+            JSONObject resultJson1 = JSONObject.parseObject(result1);
+            Integer code1 = resultJson1.getInteger("code");
+            if (code1 == 0) {
+                log.info("修改成功,accountId:{},unitId:{}", token.getAccountId(), jsonObject.getLong("unit_id"));
+
+            } else {
+                log.info("修改失败,accountId:{},unitId:{},原因:{}", token.getAccountId(), jsonObject.getLong("unit_id"), resultJson1.getString("message"));
+            }
+
+
+        }
+
+        getProgramCreative(token, page + 1);
+
+    }
+
+
 }

+ 12 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouReportDailyMaterialServiceImpl.java

@@ -6,6 +6,7 @@ import cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouReportDailyMaterialMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouReportDailyMaterialService;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterial;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaiShouReportHourlyMaterialMapper;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -30,6 +31,8 @@ import java.util.Map;
 public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShouReportDailyMaterialMapper, KuaiShouReportDailyMaterial> implements IKuaiShouReportDailyMaterialService {
     @Autowired
     private KuaiShouReportDailyMaterialMapper dailyMaterialMapper;
+    @Autowired
+    private KuaiShouReportHourlyMaterialMapper hourlyMaterialMapper;
 
     @Override
     public List<KuaiShouVideoGetVo> getVideoList(Map<String, Object> requestMap) {
@@ -44,7 +47,7 @@ public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShou
      * @param endDate
      */
     @Override
-    public void getMaterialReportByAccountIdAndStatDate(Long accountId, String token, String startDate, String endDate, Integer page) {
+    public void getMaterialReportByAccountIdAndStatDate(Long accountId, String token, String startDate, String endDate, String temporalGranularity, Integer page) {
         String url = "https://ad.e.kuaishou.com/rest/openapi/v1/report/material_report";
         Map<String, String> headers = new HashMap<>();
         headers.put("Content-Type", "application/json");
@@ -53,7 +56,7 @@ public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShou
         param.put("start_date", startDate);
         param.put("end_date", endDate);
         param.put("advertiser_id", accountId);
-        param.put("temporal_granularity", "DAILY");
+        param.put("temporal_granularity", temporalGranularity);
         param.put("view_type", 5);
         param.put("page_size", 2000);
         param.put("page", page);
@@ -89,8 +92,13 @@ public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShou
             addList.add(material);
         }
         addList = this.getVideoInfoByList(addList, photoIdList);
-        dailyMaterialMapper.batchReplace(addList);
-        getMaterialReportByAccountIdAndStatDate(accountId, token, startDate, endDate, page + 1);
+        if ("DAILY".equals(temporalGranularity)) {
+            dailyMaterialMapper.batchReplace(addList);
+        } else if ("HOURLY".equals(temporalGranularity)) {
+            hourlyMaterialMapper.batchReplace(addList);
+        }
+
+        getMaterialReportByAccountIdAndStatDate(accountId, token, startDate, endDate, temporalGranularity, page + 1);
     }
 
     private List<KuaiShouReportDailyMaterial> getVideoInfoByList(List<KuaiShouReportDailyMaterial> addList, List<Long> photoIdList) {

+ 5 - 53
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -504,57 +504,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
 
     @Override
-    public void getAdvertiserGroupReportHourly(CtopOauthToken token, Date startDate, Date endDate) {
-        getGroupHourlyReportByPage(token, startDate, endDate, 1);
-    }
-
-    private void getGroupHourlyReportByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
-        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GTOUP_REPORT;
-        Map<String, String> headers = new HashMap<>();
-        headers.put("Content-Type", "application/json");
-        headers.put("Access-Token", token.getAccessToken());
-        Map<String, Object> param = new HashMap<>();
-        param.put("start_date", DateUtils.formatDate(startDate));
-        param.put("end_date", DateUtils.formatDate(endDate));
-        param.put("advertiser_id", token.getAccountId());
-        param.put("temporal_granularity", "HOURLY");
-        param.put("page_size", 2000);
-        param.put("page", page);
-
-        String result = HttpUtils.httpPostRequest(url, param, headers);
-        JSONObject resultJson = JSONObject.parseObject(result);
-        Integer code = resultJson.getInteger("code");
-        String message = resultJson.getString("message");
-        if (null == code || code != 0) {
-            log.error("获取快手广告组时报表异常:{},accountId:{}", message, token.getAccountId());
-            return;
-        }
-        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
-        if (null == details || details.size() <= 0) {
-            log.info("快手广告组时报表信息为空=》accountId:{}", token.getAccountId());
-            return;
-        }
-        List<KuaishouReportHourlyGroup> groups = new ArrayList<>();
-        for (int i = 0; i < details.size(); i++) {
-            JSONObject detailJson = details.getJSONObject(i);
-            var show = detailJson.getLong("show");
-            detailJson.put("photo_show", show);
-            var like = detailJson.getLong("like");
-            detailJson.put("photo_like", like);
-            var hourlyGroup = JSONObject.toJavaObject(detailJson, KuaishouReportHourlyGroup.class);
-            hourlyGroup.setAccountId(token.getAccountId());
-            hourlyGroup.setId("" + hourlyGroup.getAccountId() + hourlyGroup.getUnitId() + hourlyGroup.getStatDate() + hourlyGroup.getStatHour());
-            hourlyGroup.setCreateTime(new Date());
-            hourlyGroup.setUpdateTime(new Date());
-            groups.add(hourlyGroup);
-        }
-        hourlyGroupService.replaceBatch(groups);
-
-
-        getGroupHourlyReportByPage(token, startDate, endDate, page + 1);
-    }
-
-    @Override
     public KuaishouResult<KuaishouReportHourlyGroup> getGroupHourlyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GTOUP_REPORT;
         Map<String, String> headers = new HashMap<>();
@@ -1023,7 +972,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             param.put("end_date", DateUtils.formatDate(endDate));
         }
         param.put("page", page);
-        param.put("page_size", 200);
+        param.put("page_size", 500);
 
         String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
         JSONObject resultJson = JSONObject.parseObject(result);
@@ -1905,7 +1854,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         returnJson.put("isAppInvoked", dataJson.getInteger("is_app_invoked"));
                         returnJson.put("isMultiConversion", dataJson.getInteger("is_multi_conversion"));
                         returnJson.put("isAdWatchTimes", dataJson.getInteger("is_ad_watch_times"));
-
+                        returnJson.put("isAppInvoked", dataJson.getInteger("is_app_invoked"));
+                        returnJson.put("isMultiConversion", dataJson.getInteger("is_multi_conversion"));
+                        returnJson.put("isAdWatchTimes", dataJson.getInteger("is_ad_watch_times"));
+                        returnJson.put("isOrderPaied", dataJson.getInteger("is_order_paied"));
 
                         JSONArray deep_conversion_types = dataJson.getJSONArray("deep_conversion_types");
                         JSONArray deepConversionTypes = new JSONArray();

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

@@ -42,7 +42,6 @@ public class KuaishouPopulationServiceImpl extends ServiceImpl<KuaishouPopulatio
 
     @Override
     public JSONObject getPopulationList(Long accountId, String accessToken, Integer status) {
-        log.info("获取人群包列表,accountId:{}", accountId);
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.POPULATION_LIST;
         Map<String, String> headers = new HashMap<>();
         headers.put("Access-Token", accessToken);

+ 129 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/EtlKuaishouReportAccountHourlyController.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.report.controller;
 
 import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.QueryGenerator;
 import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountHourly;
 import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaishouReportAccountHourlyService;
@@ -96,6 +97,134 @@ public class EtlKuaishouReportAccountHourlyController {
 
 
     /**
+     * 盯盘——运营个人绩效
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/personalAchievements")
+    public Result<Object> personalAchievements(String userId) {
+        try {
+            if (Check.isNull(userId)) {
+                return Result.error("缺少参数");
+            }
+            return etlKuaishouReportAccountHourlyService.queryPersonalAchievements(userId);
+        } catch (Exception e) {
+            log.error("error:", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("error");
+    }
+
+    /**
+     * 判断角色
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/checkRole")
+    public Result<Object> checkRole(String userId) {
+        try {
+            if (Check.isNull(userId)) {
+                return Result.error("缺少参数");
+            }
+            return etlKuaishouReportAccountHourlyService.checkRole(userId);
+        } catch (Exception e) {
+            log.error("error:", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("error");
+    }
+
+    /**
+     * 个人账户列表
+     *
+     * @param request
+     * @return
+     */
+    @PostMapping(value = "/accountPageList")
+    public Result<Object> accountPageList(@RequestBody JSONObject request) {
+        try {
+            return etlKuaishouReportAccountHourlyService.accountPageList(request);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+    /**
+     * 经理账户列表
+     *
+     * @param request
+     * @return
+     */
+    @PostMapping(value = "/leaderAccountPageList")
+    public Result<Object> leaderAccountPageList(@RequestBody JSONObject request) {
+        try {
+            return etlKuaishouReportAccountHourlyService.leaderAccountPageList(request);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+     /**
+     * 趋势图
+     *
+     * @param request
+     * @return
+     */
+    @PostMapping(value = "/queryNewlyData")
+    public Result<Object> queryNewlyData(@RequestBody JSONObject request) {
+        try {
+            return etlKuaishouReportAccountHourlyService.queryNewlyData(request);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+     /**
+     * 运营人员当日数据列表
+     *
+     * @param request
+     * @return
+     */
+    @RequestMapping(value = "/operatingStaffDataList")
+    public Result<Object> operatingStaffDataList(@RequestBody JSONObject request) {
+        try {
+            return etlKuaishouReportAccountHourlyService.operatingStaffDataList(request);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+     /**
+     * 项目列表
+     *
+     * @param request
+     * @return
+     */
+    @RequestMapping(value = "/projectList")
+    public Result<Object> projectList(@RequestBody JSONObject request) {
+        try {
+            return etlKuaishouReportAccountHourlyService.projectList(request);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
      * 获取当日花费最大的账户
      *
      * @param

+ 248 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaiShouProjectDataController.java

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

+ 248 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaiShouReportHourlyMaterialController.java

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

+ 15 - 9
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/EtlKuaishouReportAccountHourly.java

@@ -1,21 +1,20 @@
 package cn.com.ctop.kuaishou.modules.report.entity;
 
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.util.Date;
-
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.TableField;
+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 com.fasterxml.jackson.annotation.JsonFormat;
-import org.springframework.format.annotation.DateTimeFormat;
 import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.math.BigDecimal;
+import java.util.Date;
 
 /**
  * 账户维度-每小时盯盘数据
@@ -223,7 +222,8 @@ public class EtlKuaishouReportAccountHourly {
     @Excel(name = "落地页数据-落地页授信数", width = 15)
     @ApiModelProperty(value = "落地页数据-落地页授信数")
     private Long eventCreditGrantLandingPage;
-    /**Save pv the next day
+    /**
+     * Save pv the next day
      * 应用下载数据-次留数(仅支持分日查询)
      */
     @Excel(name = "应用下载数据-次留数(仅支持分日查询)", width = 15)
@@ -259,6 +259,12 @@ public class EtlKuaishouReportAccountHourly {
     private Date updateTime;
 
     @TableField(exist = false)
+    private BigDecimal totalBalance;//余额
+    @TableField(exist = false)
+    private BigDecimal budget;//预算
+    @TableField(exist = false)
+    private String authName;//账户名称
+    @TableField(exist = false)
     private BigDecimal activationCost;//激活单价
     @TableField(exist = false)
     private BigDecimal impression1kCost;//平均千次素材曝光花费 = 花费/素材曝光数*1000
@@ -318,5 +324,5 @@ public class EtlKuaishouReportAccountHourly {
     private BigDecimal formActionRatio;//表单提交点击率 =当日回传表单数/当日行为数
     @TableField(exist = false)
     private BigDecimal submitRatio;//按钮点击率 =当日按钮点击数 / 当日行为数
-    private BigDecimal grew=new BigDecimal(0);//同比 = (今日实时花费-昨日截止到此时的花费)/昨日截止到此时的花费*100%;
+    private BigDecimal grew = new BigDecimal(0);//同比 = (今日实时花费-昨日截止到此时的花费)/昨日截止到此时的花费*100%;
 }

+ 71 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaiShouProjectData.java

@@ -0,0 +1,71 @@
+package cn.com.ctop.kuaishou.modules.report.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 2021-04-20
+ */
+@Data
+@TableName("ctop_kuaishou_project_data")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_project_data对象", description = "快手-配置项目拉取时报数据")
+public class KuaiShouProjectData {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long projectId;
+    /**
+     * 项目名称
+     */
+    @Excel(name = "项目名称", width = 15)
+    @ApiModelProperty(value = "项目名称")
+    private String projectName;
+    /**
+     * 0:拉取 1:暂停
+     */
+    @Excel(name = "0:拉取 1:暂停", width = 15)
+    @ApiModelProperty(value = "0:拉取 1:暂停")
+    private Integer projectStatus;
+    /**
+     * 创建时间
+     */
+    @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;
+}

+ 2 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaiShouReportDailyMaterial.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.report.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -11,7 +12,6 @@ import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 import org.jeecgframework.poi.excel.annotation.Excel;
 import org.springframework.format.annotation.DateTimeFormat;
-import com.baomidou.mybatisplus.annotation.TableField;
 
 import java.util.Date;
 
@@ -191,6 +191,7 @@ public class KuaiShouReportDailyMaterial {
     @Excel(name = "日期", width = 15)
     @ApiModelProperty(value = "日期")
     private String statDate;
+    private Integer statHour;
     /**
      * 封面点击数
      */

+ 425 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaiShouReportHourlyMaterial.java

@@ -0,0 +1,425 @@
+package cn.com.ctop.kuaishou.modules.report.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 2021-04-20
+ */
+@Data
+@TableName("ctop_kuaishou_report_hourly_material")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_report_hourly_material对象", description = "素材时报")
+public class KuaiShouReportHourlyMaterial {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 计划ID
+     */
+    @Excel(name = "计划ID", width = 15)
+    @ApiModelProperty(value = "计划ID")
+    private Long photoId;
+    /**
+     * channelType
+     */
+    @Excel(name = "channelType", width = 15)
+    @ApiModelProperty(value = "channelType")
+    private Integer channelType;
+    /**
+     * signature
+     */
+    @Excel(name = "signature", width = 15)
+    @ApiModelProperty(value = "signature")
+    private String signature;
+    /**
+     * 封面token
+     */
+    @Excel(name = "封面token", width = 15)
+    @ApiModelProperty(value = "封面token")
+    private String imageToken;
+    /**
+     * 封面url
+     */
+    @Excel(name = "封面url", width = 15)
+    @ApiModelProperty(value = "封面url")
+    private String coverUrl;
+    /**
+     * 视频uel
+     */
+    @Excel(name = "视频uel", width = 15)
+    @ApiModelProperty(value = "视频uel")
+    private String photoUrl;
+    /**
+     * 素材类型
+     */
+    @Excel(name = "素材类型", width = 15)
+    @ApiModelProperty(value = "素材类型")
+    private String creativeMaterialTypeString;
+    /**
+     * 场景
+     */
+    @Excel(name = "场景", width = 15)
+    @ApiModelProperty(value = "场景")
+    private String adScene;
+    /**
+     * 花费(元)
+     */
+    @Excel(name = "花费(元)", width = 15)
+    @ApiModelProperty(value = "花费(元)")
+    private java.math.BigDecimal charge;
+    /**
+     * 曝光数
+     */
+    @Excel(name = "曝光数", width = 15)
+    @ApiModelProperty(value = "曝光数")
+    private Integer photoShow;
+    /**
+     * 素材曝光数
+     */
+    @Excel(name = "素材曝光数", width = 15)
+    @ApiModelProperty(value = "素材曝光数")
+    private Integer aclick;
+    /**
+     * 行为数
+     */
+    @Excel(name = "行为数", width = 15)
+    @ApiModelProperty(value = "行为数")
+    private Integer bclick;
+    /**
+     * 分享数
+     */
+    @Excel(name = "分享数", width = 15)
+    @ApiModelProperty(value = "分享数")
+    private Integer photoShare;
+    /**
+     * 评论数
+     */
+    @Excel(name = "评论数", width = 15)
+    @ApiModelProperty(value = "评论数")
+    private Integer photoComment;
+    /**
+     * 点赞数
+     */
+    @Excel(name = "点赞数", width = 15)
+    @ApiModelProperty(value = "点赞数")
+    private Integer photoLike;
+    /**
+     * 新增关注数
+     */
+    @Excel(name = "新增关注数", width = 15)
+    @ApiModelProperty(value = "新增关注数")
+    private Integer follow;
+    /**
+     * 取消关注数
+     */
+    @Excel(name = "取消关注数", width = 15)
+    @ApiModelProperty(value = "取消关注数")
+    private Integer cancelFollow;
+    /**
+     * 举报数
+     */
+    @Excel(name = "举报数", width = 15)
+    @ApiModelProperty(value = "举报数")
+    private Integer report;
+    /**
+     * 拉黑数
+     */
+    @Excel(name = "拉黑数", width = 15)
+    @ApiModelProperty(value = "拉黑数")
+    private Integer block;
+    /**
+     * 减少此类作品数
+     */
+    @Excel(name = "减少此类作品数", width = 15)
+    @ApiModelProperty(value = "减少此类作品数")
+    private Integer negative;
+    /**
+     * 应用下载数据-安卓下载开始数
+     */
+    @Excel(name = "应用下载数据-安卓下载开始数", width = 15)
+    @ApiModelProperty(value = "应用下载数据-安卓下载开始数")
+    private Integer downloadStarted;
+    /**
+     * 应用下载数据-安卓下载完成数
+     */
+    @Excel(name = "应用下载数据-安卓下载完成数", width = 15)
+    @ApiModelProperty(value = "应用下载数据-安卓下载完成数")
+    private Integer downloadCompleted;
+    /**
+     * 应用下载数据-激活数
+     */
+    @Excel(name = "应用下载数据-激活数", width = 15)
+    @ApiModelProperty(value = "应用下载数据-激活数")
+    private Integer activation;
+    /**
+     * 提交按钮点击数
+     */
+    @Excel(name = "提交按钮点击数", width = 15)
+    @ApiModelProperty(value = "提交按钮点击数")
+    private Integer submit;
+    /**
+     * 日期
+     */
+    @Excel(name = "日期", width = 15)
+    @ApiModelProperty(value = "日期")
+    private String statDate;
+    /**
+     * 时段
+     */
+    @Excel(name = "时段", width = 15)
+    @ApiModelProperty(value = "时段")
+    private Integer statHour;
+    /**
+     * 封面点击数
+     */
+    @Excel(name = "封面点击数", width = 15)
+    @ApiModelProperty(value = "封面点击数")
+    private Integer photoClick;
+    /**
+     * 封面点击率
+     */
+    @Excel(name = "封面点击率", width = 15)
+    @ApiModelProperty(value = "封面点击率")
+    private Double photoClickRatio;
+    /**
+     * 行为率
+     */
+    @Excel(name = "行为率", width = 15)
+    @ApiModelProperty(value = "行为率")
+    private Double actionRatio;
+    /**
+     * 平均千次曝光花费(元)
+     */
+    @Excel(name = "平均千次曝光花费(元)", width = 15)
+    @ApiModelProperty(value = "平均千次曝光花费(元)")
+    private java.math.BigDecimal impression1kCost;
+    /**
+     * 平均点击单价(元)
+     */
+    @Excel(name = "平均点击单价(元)", width = 15)
+    @ApiModelProperty(value = "平均点击单价(元)")
+    private java.math.BigDecimal photoClickCost;
+    /**
+     * 平均行为单价(元)
+     */
+    @Excel(name = "平均行为单价(元)", width = 15)
+    @ApiModelProperty(value = "平均行为单价(元)")
+    private java.math.BigDecimal actionCost;
+    /**
+     * 应用下载数据-首日付费次数
+     */
+    @Excel(name = "应用下载数据-首日付费次数", width = 15)
+    @ApiModelProperty(value = "应用下载数据-首日付费次数")
+    private Integer eventPayFirstDay;
+    /**
+     * 应用下载数据-首日付费金额
+     */
+    @Excel(name = "应用下载数据-首日付费金额", width = 15)
+    @ApiModelProperty(value = "应用下载数据-首日付费金额")
+    private java.math.BigDecimal eventPayPurchaseAmountFirstDay;
+    /**
+     * 应用下载数据-首日ROI
+     */
+    @Excel(name = "应用下载数据-首日ROI", width = 15)
+    @ApiModelProperty(value = "应用下载数据-首日ROI")
+    private Double eventPayFirstDayRoi;
+    /**
+     * 应用下载数据-付费次数
+     */
+    @Excel(name = "应用下载数据-付费次数", width = 15)
+    @ApiModelProperty(value = "应用下载数据-付费次数")
+    private Integer eventPay;
+    /**
+     * 应用下载数据-付费金额
+     */
+    @Excel(name = "应用下载数据-付费金额", width = 15)
+    @ApiModelProperty(value = "应用下载数据-付费金额")
+    private java.math.BigDecimal eventPayPurchaseAmount;
+    /**
+     * 应用下载数据-ROI
+     */
+    @Excel(name = "应用下载数据-ROI", width = 15)
+    @ApiModelProperty(value = "应用下载数据-ROI")
+    private Double eventPayRoi;
+    /**
+     * 应用下载数据-注册数
+     */
+    @Excel(name = "应用下载数据-注册数", width = 15)
+    @ApiModelProperty(value = "应用下载数据-注册数")
+    private Integer eventRegister;
+    /**
+     * 应用下载数据-注册成本
+     */
+    @Excel(name = "应用下载数据-注册成本", width = 15)
+    @ApiModelProperty(value = "应用下载数据-注册成本")
+    private java.math.BigDecimal eventRegisterCost;
+    /**
+     * 应用下载数据-注册率
+     */
+    @Excel(name = "应用下载数据-注册率", width = 15)
+    @ApiModelProperty(value = "应用下载数据-注册率")
+    private Double eventRegisterRatio;
+    /**
+     * 应用下载数据-完件数
+     */
+    @Excel(name = "应用下载数据-完件数", width = 15)
+    @ApiModelProperty(value = "应用下载数据-完件数")
+    private Integer eventJinJianApp;
+    /**
+     * 应用下载数据-完件成本
+     */
+    @Excel(name = "应用下载数据-完件成本", width = 15)
+    @ApiModelProperty(value = "应用下载数据-完件成本")
+    private java.math.BigDecimal eventJinJianAppCost;
+    /**
+     * 应用下载数据-授信数
+     */
+    @Excel(name = "应用下载数据-授信数", width = 15)
+    @ApiModelProperty(value = "应用下载数据-授信数")
+    private Integer eventCreditGrantApp;
+    /**
+     * 应用下载数据-授信成本
+     */
+    @Excel(name = "应用下载数据-授信成本", width = 15)
+    @ApiModelProperty(value = "应用下载数据-授信成本")
+    private java.math.BigDecimal eventCreditGrantAppCost;
+    /**
+     * 应用下载数据-授信率
+     */
+    @Excel(name = "应用下载数据-授信率", width = 15)
+    @ApiModelProperty(value = "应用下载数据-授信率")
+    private Double eventCreditGrantAppRatio;
+    /**
+     * 应用下载数据-付款成功数
+     */
+    @Excel(name = "应用下载数据-付款成功数", width = 15)
+    @ApiModelProperty(value = "应用下载数据-付款成功数")
+    private Integer eventOrderPaid;
+    /**
+     * 应用下载数据-付款成功金额
+     */
+    @Excel(name = "应用下载数据-付款成功金额", width = 15)
+    @ApiModelProperty(value = "应用下载数据-付款成功金额")
+    private java.math.BigDecimal eventOrderPaidPurchaseAmount;
+    /**
+     * 落地页数据-落地页完件数
+     */
+    @Excel(name = "落地页数据-落地页完件数", width = 15)
+    @ApiModelProperty(value = "落地页数据-落地页完件数")
+    private Integer eventJinJianLandingPage;
+    /**
+     * 落地页数据-落地页完件成本
+     */
+    @Excel(name = "落地页数据-落地页完件成本", width = 15)
+    @ApiModelProperty(value = "落地页数据-落地页完件成本")
+    private java.math.BigDecimal eventJinJianLandingPageCost;
+    /**
+     * 落地页数据-落地页授信数
+     */
+    @Excel(name = "落地页数据-落地页授信数", width = 15)
+    @ApiModelProperty(value = "落地页数据-落地页授信数")
+    private Integer eventCreditGrantLandingPage;
+    /**
+     * 落地页数据-落地页授信成本
+     */
+    @Excel(name = "落地页数据-落地页授信成本", width = 15)
+    @ApiModelProperty(value = "落地页数据-落地页授信成本")
+    private java.math.BigDecimal eventCreditGrantLandingPageCost;
+    /**
+     * 落地页数据-落地页授信率
+     */
+    @Excel(name = "落地页数据-落地页授信率", width = 15)
+    @ApiModelProperty(value = "落地页数据-落地页授信率")
+    private Double eventCreditGrantLandingRatio;
+    /**
+     * 应用下载数据-次留成本(仅支持分日查询)
+     */
+    @Excel(name = "应用下载数据-次留成本(仅支持分日查询)", width = 15)
+    @ApiModelProperty(value = "应用下载数据-次留成本(仅支持分日查询)")
+    private java.math.BigDecimal eventNextDayStayCost;
+    /**
+     * 应用下载数据-次留率(仅支持分日查询)
+     */
+    @Excel(name = "应用下载数据-次留率(仅支持分日查询)", width = 15)
+    @ApiModelProperty(value = "应用下载数据-次留率(仅支持分日查询)")
+    private Integer eventNextDayStayRatio;
+    /**
+     * 落地页数据-表单提交点击率
+     */
+    @Excel(name = "落地页数据-表单提交点击率", width = 15)
+    @ApiModelProperty(value = "落地页数据-表单提交点击率")
+    private Double formActionRatio;
+    /**
+     * 应用下载数据-单次付款成本
+     */
+    @Excel(name = "应用下载数据-单次付款成本", width = 15)
+    @ApiModelProperty(value = "应用下载数据-单次付款成本")
+    private java.math.BigDecimal eventOrderPaidCost;
+    /**
+     * 应用下载数据-次留数(仅支持分日查询)
+     */
+    @Excel(name = "应用下载数据-次留数(仅支持分日查询)", width = 15)
+    @ApiModelProperty(value = "应用下载数据-次留数(仅支持分日查询)")
+    private Integer eventNextDayStay;
+    /**
+     * 落地页数据-表单提交单价
+     */
+    @Excel(name = "落地页数据-表单提交单价", width = 15)
+    @ApiModelProperty(value = "落地页数据-表单提交单价")
+    private java.math.BigDecimal formCost;
+    /**
+     * 落地页数据-表单提交数
+     */
+    @Excel(name = "落地页数据-表单提交数", width = 15)
+    @ApiModelProperty(value = "落地页数据-表单提交数")
+    private Integer formCount;
+    /**
+     * 3s播放率
+     */
+    @Excel(name = "3s播放率", width = 15)
+    @ApiModelProperty(value = "3s播放率")
+    private Double play3sRatio;
+    /**
+     * 创建时间
+     */
+    @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;
+}

+ 94 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/enums/CheckParametersCostEnum.java

@@ -0,0 +1,94 @@
+package cn.com.ctop.kuaishou.modules.report.enums;
+
+/**
+ * 运营盯盘 按字段排序枚举
+ *
+ * @param
+ * @author ZHAOXA
+ * @return
+ * @throws
+ */
+public enum CheckParametersCostEnum {
+    PARAMETER1("cost", "sum(t1.charge)"),
+    PARAMETER2("photoShow", "sum(t1.photo_show)"),
+    PARAMETER3("photoClick", "sum(t1.photo_click)"),
+    PARAMETER4("aClick", "sum(t1.aclick)"),
+    PARAMETER5("bClick", "sum(t1.bclick)"),
+    PARAMETER6("cpm", "sum(t1.charge) / sum(t1.photo_show)"),
+    PARAMETER7("cpc", "sum(t1.charge) / sum(t1.photo_click)"),
+    PARAMETER8("cpb", "sum(t1.charge) / sum(t1.bclick)"),
+    PARAMETER9("downloadStart", "sum(download_started)"),
+    PARAMETER10("downloadStartCost", "sum(t1.charge) / sum(t1.download_started)"),
+    PARAMETER11("downloadFinish", "sum(download_completed)"),
+    PARAMETER12("downloadFinishCost", "sum(t1.charge) / sum(t1.download_completed)"),
+    PARAMETER13("active", "sum(activation)"),
+    PARAMETER14("activeCost", "sum(t1.charge) / sum(t1.activation)"),
+    PARAMETER15("firstDayPay", "sum(t1.event_pay_first_day)"),
+    PARAMETER16("firstDayPayAmount", "sum(t1.event_pay_purchase_amount_first_day)"),
+    PARAMETER17("firstDayPayCost", "sum(t1.charge) / sum(t1.event_pay_first_day)"),
+    PARAMETER18("eventPay", "sum(t1.event_pay)"),
+    PARAMETER19("eventPayPurchaseAmount", "sum(t1.event_pay_purchase_amount)"),
+    PARAMETER20("eventPayCost", "sum(t1.charge) / sum(t1.event_pay)"),
+    PARAMETER21("register", "sum(t1.event_register)"),
+    PARAMETER22("activeRegisterCost", "sum(t1.charge)/sum(t1.event_register)"),
+    PARAMETER23("eventJinJianApp", "sum(event_jin_jian_app)"),
+    PARAMETER24("eventJinJianAppCost", "sum(t1.charge)/sum(t1.event_jin_jian_app)"),
+    PARAMETER25("eventCreditGrantApp", "sum(event_credit_grant_app)"),
+    PARAMETER26("eventCreditGrantAppCost", "sum(t1.charge)/sum(t1.event_credit_grant_app)"),
+    PARAMETER27("formCount", "sum(t1.form_count)"),
+    PARAMETER28("formCountCost", "sum(t1.charge)/sum(t1.form_count)"),
+    PARAMETER29("nextDayOpen", "sum(t1.event_next_day_stay)"),
+    PARAMETER30("nextDayOpenCost", "sum(t1.charge)/sum(t1.event_next_day_stay)"),
+    PARAMETER31("eventJinJianLandingPage", "sum(t1.event_jin_jian_landing_page)"),
+    PARAMETER32("eventJinJianLandingPageCost", "sum(t1.charge)/sum(t1.event_jin_jian_landing_page)"),
+    PARAMETER33("eventCreditGrantLandingPage", "sum(t1.event_credit_grant_landing_page)"),
+    PARAMETER34("eventCreditGrantLandingPageCost", "sum(t1.charge)/sum(t1.event_credit_grant_landing_page)"),
+    PARAMETER35("submit", "sum(t1.submit)"),
+    PARAMETER36("submitCost", "sum(t1.charge)/sum(t1.submit)"),
+    PARAMETER37("totalBalance", "balance"),
+    PARAMETER38("budget", "day_budget");
+
+    private String value;
+    private String formula;
+
+    CheckParametersCostEnum(String value, String formula) {
+        this.value = value;
+        this.formula = formula;
+    }
+
+    public static String getFormula(String value) {
+        for (CheckParametersCostEnum campaignType : CheckParametersCostEnum.values()) {
+            if (campaignType.getValue().equals(value)) {
+                return campaignType.getFormula();
+            }
+        }
+        return "";
+    }
+
+    public static boolean isInclude(String key) {
+        boolean include = false;
+        for (CheckParametersCostEnum e : CheckParametersCostEnum.values()) {
+            if (e.getValue().equals(key)) {
+                include = true;
+                break;
+            }
+        }
+        return include;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public String getFormula() {
+        return formula;
+    }
+
+    public void setFormula(String formula) {
+        this.formula = formula;
+    }
+}

+ 23 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/EtlKuaishouReportAccountDailyMapper.java

@@ -1,12 +1,13 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
-import java.util.List;
-
+import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountDaily;
 import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountHourly;
 import com.alibaba.fastjson.JSONObject;
-import org.apache.ibatis.annotations.Param;
-import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountDaily;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
 
 /**
  * 盯盘日数据
@@ -26,4 +27,22 @@ public interface EtlKuaishouReportAccountDailyMapper extends BaseMapper<EtlKuais
     JSONObject getMaxChargeAccountId(@Param("userId") String userId);
 
     String getNewlyUpdateTime();
+
+    JSONObject getMonthlyRank(Map<String, Object> paramsMap);
+
+    List<JSONObject> accountPageList(JSONObject request);
+
+    int accountPageListTotal(JSONObject request);
+
+    List<JSONObject> queryEveryDayCharge(JSONObject request);
+
+    List<JSONObject> queryEveryDayCount(JSONObject request);
+
+    List<JSONObject> projectPageList(JSONObject request);
+
+    int projectPageListTotal(JSONObject request);
+
+    List<JSONObject> leaderAccountPageList(JSONObject request);
+
+    int leaderAccountPageListTotal(JSONObject request);
 }

+ 19 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/EtlKuaishouReportAccountHourlyMapper.java

@@ -22,7 +22,25 @@ public interface EtlKuaishouReportAccountHourlyMapper extends BaseMapper<EtlKuai
 
     EtlKuaishouReportAccountHourly getOnedayAggregateByHour(@Param("startTime") String startTime, @Param("accountId") Long accountId);
 
-    List<JSONObject> getOnedayEtlReportList(@Param("startTime") String startTime, @Param("accountId") Long accountId,@Param("value") String value,@Param("type") String type);
+    List<JSONObject> getOnedayEtlReportList(@Param("startTime") String startTime, @Param("accountId") Long accountId, @Param("value") String value, @Param("type") String type);
 
     String getNewlyUpdateTime();
+
+    List<JSONObject> accountPageList(JSONObject request);
+
+    int accountPageListTotal(JSONObject request);
+
+    List<JSONObject> queryEveryHourlyCharge(JSONObject request);
+
+    List<JSONObject> operatingStaffDataList(JSONObject request);
+
+    Integer operatingStaffDataListTotal(JSONObject request);
+
+    List<JSONObject> projectPageList(JSONObject request);
+
+    int projectPageListTotal(JSONObject request);
+
+    List<JSONObject> leaderAccountPageList(JSONObject request);
+
+    int leaderAccountPageListTotal(JSONObject request);
 }

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.report.mapper;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouProjectData;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 快手-配置项目拉取时报数据
+ *
+ * @author: jeecg-boot
+ * @date: 2021-04-20
+ * @cersion: V1.0
+ */
+public interface KuaiShouProjectDataMapper extends BaseMapper<KuaiShouProjectData> {
+
+}

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

@@ -0,0 +1,20 @@
+package cn.com.ctop.kuaishou.modules.report.mapper;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterial;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportHourlyMaterial;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 素材时报
+ *
+ * @author: jeecg-boot
+ * @date: 2021-04-20
+ * @cersion: V1.0
+ */
+public interface KuaiShouReportHourlyMaterialMapper extends BaseMapper<KuaiShouReportHourlyMaterial> {
+
+    void batchReplace(@Param("addList") List<KuaiShouReportDailyMaterial> addList);
+}

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

@@ -2,11 +2,13 @@ package cn.com.ctop.kuaishou.modules.report.mapper;
 
 import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountHourly;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyAccount;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.Map;
 
 public interface KuaishouReportHourlyAccountMapper extends BaseMapper<KuaishouReportHourlyAccount> {
     Integer selectMaxHour(@Param("accountId") Long accountId, @Param("statDate") String statDate);
@@ -16,4 +18,6 @@ public interface KuaishouReportHourlyAccountMapper extends BaseMapper<KuaishouRe
     void replaceBatch(@Param("addList") List<KuaishouReportHourlyAccount> addList);
 
     List<EtlKuaishouReportAccountHourly> queryEveryhourlyDataForAccount();
+
+    JSONObject queryPersonalAchievements(Map<String, Object> paramsMap);
 }

+ 280 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouReportAccountDailyMapper.xml

@@ -269,9 +269,288 @@
     </select>
 
     <select id="getNewlyUpdateTime" resultType="java.lang.String">
-        select DATE_FORMAT(update_time,'%Y-%m-%d %H:%i:%s')
+        select DATE_FORMAT(update_time, '%Y-%m-%d %H:%i:%s')
         FROM ctop_etl_kuaishou_report_account_daily
         ORDER BY update_time desc LIMIT 1
     </select>
 
+    <select id="getMonthlyRank" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT *
+        FROM (
+                 SELECT @rownum:=@rownum+1 as id,t.*,
+        (SELECT COUNT(1) FROM(SELECT 1 FROM ctop_etl_kuaishou_report_account_daily t1
+        LEFT  JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        WHERE t1.stat_date &gt;= #{mStartDate}
+                     AND t1.stat_date &lt;= #{today}
+                     AND media_id =2
+                     GROUP BY user_id) t) as 'totle'
+                 FROM (
+                     SELECT sum(charge) as 'charge', t2.user_id 'userId' FROM ctop_etl_kuaishou_report_account_daily t1
+                     LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+                     WHERE t1.stat_date &gt;= #{mStartDate}
+                     AND t1.stat_date &lt;= #{today}
+                     AND media_id =2
+                     GROUP BY user_id
+                     ORDER BY SUM(charge) DESC
+                     ) t, (select @rownum := 0) a
+             ) tt
+        WHERE tt.userId = #{userId}
+    </select>
+
+    <select id="accountPageList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        ${filed},
+        '-' as 'grewRatio',
+        IFNULL(CONCAT(CAST(ROUND((SUM(charge)-t4.week_charge)/t4.week_charge*100,3)as CHAR),'%'),'0%') as
+        'weekGrewRatio',
+        t1.account_id 'accountId',
+        t2.auth_name as 'authName',
+        IFNULL(ROUND(play_3s_count / aclick * 100, 2), 0) as 'play3sRatio',
+        (select realname FROM sys_user where id = #{userId}) as 'realname',
+        IFNULL(t6.balance,0) as 'totalBalance',
+        IFNULL(t6.day_budget,0) as 'budget'
+        FROM ctop_etl_kuaishou_report_account_daily t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        LEFT JOIN(
+        SELECT i1.account_id,SUM(charge) as 'week_charge' FROM ctop_etl_kuaishou_report_account_daily i1
+        LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
+        where stat_date &gt;= DATE_SUB(#{startTime},INTERVAL 7 DAY)
+        AND stat_date &lt;= DATE_SUB(#{endTime},INTERVAL 7 DAY)
+        AND i2.user_id = #{userId}
+        GROUP BY i1.account_id
+        ) t4 ON t2.account_id = t4.account_id
+        LEFT JOIN (
+        select account_id,balance,day_budget from ctop_kuaishou_account_balance_budget
+        where state =1
+        ) t6 ON t6.account_id = t2.account_id
+        where stat_date &gt;= #{startTime}
+        AND stat_date &lt;= #{endTime}
+        AND t2.user_id = #{userId}
+        GROUP BY t2.account_id
+        <if test="sortCode != '' and sortCode != null ">
+            ORDER BY ${sortCode}
+        </if>
+        ${sortType}
+    </select>
+
+    <select id="accountPageListTotal" resultType="java.lang.Integer">
+        SELECT IFNULL(SUM(1), 0)
+        from (
+                 SELECT t2.account_id
+                 FROM ctop_etl_kuaishou_report_account_daily t1
+                          LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+                 where stat_date &gt;= #{startTime}
+                   AND stat_date &lt;= #{endTime}
+                   AND t2.user_id = #{userId}
+                 GROUP BY t2.account_id
+             ) t
+    </select>
+
+    <select id="leaderAccountPageList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        ${filed},
+        '-' as 'grewRatio',
+        IFNULL(CONCAT(CAST(ROUND((SUM(charge)-t4.week_charge)/t4.week_charge*100,3)as CHAR),'%'),'0%') as
+        'weekGrewRatio',
+        t1.account_id 'accountId',
+        t2.auth_name as 'authName',
+        IFNULL(ROUND(play_3s_count / aclick * 100, 2), 0) as 'play3sRatio',
+        t5.realname,
+        IFNULL(t6.balance,0) as 'totalBalance',
+        IFNULL(t6.day_budget,0) as 'budget'
+        FROM ctop_etl_kuaishou_report_account_daily t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        LEFT JOIN(
+        SELECT i1.account_id,SUM(charge) as 'week_charge' FROM ctop_etl_kuaishou_report_account_daily i1
+        LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
+        where stat_date &gt;= DATE_SUB(#{startTime},INTERVAL 7 DAY)
+        AND stat_date &lt;= DATE_SUB(#{endTime},INTERVAL 7 DAY)
+        <if test="userIds != null">
+            AND i2.user_id IN
+            <foreach item="id" index="index" collection="userIds"
+                     open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+        <if test="projectId != null">
+            AND i2.project_id = #{projectId}
+        </if>
+        GROUP BY i1.account_id
+        ) t4 ON t2.account_id = t4.account_id
+        LEFT JOIN (
+        SELECT
+        id,realname
+        FROM
+        sys_user
+        WHERE 1=1
+        <if test="userIds != null">
+            and id IN
+            <foreach item="id" index="index" collection="userIds"
+                     open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+        ) t5 ON t2.user_id = t5.id
+        LEFT JOIN (
+        select account_id,balance,day_budget from ctop_kuaishou_account_balance_budget
+        where state =1
+        ) t6 ON t6.account_id = t2.account_id
+        where stat_date &gt;= #{startTime}
+        AND stat_date &lt;= #{endTime}
+        and t2.account_status = 0
+        <if test="userIds != null">
+            AND t2.user_id IN
+            <foreach item="id" index="index" collection="userIds"
+                     open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+        <if test="projectId != null">
+            AND t2.project_id = #{projectId}
+        </if>
+        GROUP BY t2.account_id
+        <if test="sortCode != '' and sortCode != null ">
+            ORDER BY ${sortCode}
+        </if>
+        ${sortType}
+    </select>
+
+    <select id="leaderAccountPageListTotal" resultType="java.lang.Integer">
+        SELECT IFNULL(SUM(1), 0)
+        from (
+        SELECT t2.account_id
+        FROM ctop_etl_kuaishou_report_account_daily t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        where stat_date &gt;= #{startTime}
+        AND stat_date &lt;= #{endTime}
+        and t2.account_status = 0
+        <if test="userIds != null">
+            AND t2.user_id IN
+            <foreach item="id" index="index" collection="userIds"
+                     open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+        <if test="projectId != null">
+            AND t2.project_id = #{projectId}
+        </if>
+        GROUP BY t2.account_id
+        ) t
+    </select>
+
+    <select id="queryEveryDayCharge" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        IFNULL(stat_date,'') 'time',
+        IFNULL(SUM(charge),0) 'value'
+        FROM ctop_etl_kuaishou_report_account_daily t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        where stat_date &lt;=#{endTime}
+        and stat_date &gt;=#{startTime}
+        AND t2.user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY stat_date
+        ORDER BY stat_date
+    </select>
+
+    <select id="queryEveryDayCount" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        IFNULL(stat_date,'') 'time',
+        IFNULL(SUM(new_count),0) 'value'
+        FROM ctop_etl_kuaishou_newly t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        where stat_date &lt;=#{endTime}
+        and stat_date &gt;=#{startTime}
+        AND new_type = #{parameterCode}
+        AND t2.user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY stat_date
+        ORDER BY stat_date
+    </select>
+
+
+    <select id="projectPageList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        ${filed},
+        '-' as 'grewRatio',
+        IFNULL(CONCAT(CAST(ROUND((SUM(charge)-t6.week_charge)/t6.week_charge*100,3)as CHAR),'%'),'0%') as
+        'weekGrewRatio',
+        t2.project_id 'projectId',
+        t3.project_name as 'projectName',
+        IFNULL(ROUND(SUM(play_3s_count) / SUM(aclick) * 100, 2), 0) as 'play3sRatio',
+        t7.accountCount as 'accountCount',
+        IFNULL(t4.userCount,0) as 'userCount'
+        FROM ctop_etl_kuaishou_report_account_daily t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        LEFT JOIN ctop_project t3 ON t2.project_id = t3.id
+        LEFT JOIN (
+        SELECT project_id,COUNT(1) 'userCount'
+        FROM (
+        SELECT DISTINCT project_id,user_id
+        FROM ctop_user_allocation
+        where account_status = 0
+        ) t
+        GROUP BY project_id
+        ) t4 ON t4.project_id = t3.id
+        LEFT JOIN(
+        SELECT i1.account_id,SUM(charge) as 'week_charge' FROM ctop_etl_kuaishou_report_account_daily i1
+        LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
+        where i1.stat_date &gt;= DATE_SUB(#{startTime},INTERVAL 7 DAY)
+        AND i1.stat_date &lt;= DATE_SUB(#{endTime},INTERVAL 7 DAY)
+        AND i2.user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY i1.account_id
+        ) t6 ON t2.account_id = t6.account_id
+        LEFT JOIN (
+        SELECT project_id ,count(1) as 'accountCount' FROM (
+        SELECT i2.project_id,i2.account_id FROM ctop_etl_kuaishou_report_account_daily i1
+        LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
+        where account_status = 0
+        AND i1.stat_date &gt;= #{startTime}
+        AND i1.stat_date &lt;= #{endTime}
+        GROUP BY project_id,i1.account_id ) t GROUP BY t.project_id
+        ) t7 on t2.project_id = t7.project_id
+        where t1.stat_date &gt;= #{startTime}
+        AND t1.stat_date &lt;= #{endTime}
+        AND t2.user_id in
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY t3.id
+        <if test="sortCode != '' and sortCode != null ">
+            ORDER BY ${sortCode}
+        </if>
+        ${sortType}
+    </select>
+
+
+    <select id="projectPageListTotal" resultType="java.lang.Integer">
+        SELECT IFNULL(SUM(1),0) from
+        (
+        SELECT
+        t3.id
+        FROM ctop_etl_kuaishou_report_account_daily t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        LEFT JOIN ctop_project t3 ON t2.project_id = t3.id
+        where t1.stat_date &gt;= #{startTime}
+        AND t1.stat_date &lt;= #{endTime}
+        AND t2.user_id in
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY t3.id
+        ) t
+    </select>
+
+
 </mapper>

+ 412 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouReportAccountHourlyMapper.xml

@@ -221,9 +221,420 @@
     </select>
 
     <select id="getNewlyUpdateTime" resultType="java.lang.String">
-        select DATE_FORMAT(update_time,'%Y-%m-%d %H:%i:%s')
+        select DATE_FORMAT(update_time, '%Y-%m-%d %H:%i:%s')
         FROM ctop_etl_kuaishou_report_account_hourly
         ORDER BY update_time desc LIMIT 1
     </select>
 
+    <select id="accountPageListTotal" resultType="java.lang.Integer">
+        select IFNULL(SUM(1), 0)
+        from (
+                 SELECT t2.account_id
+                 FROM ctop_etl_kuaishou_report_account_hourly t1
+                          LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+                 where stat_date = #{startTime}
+                   AND t2.user_id = #{userId}
+                 GROUP BY t2.account_id
+             ) t
+    </select>
+
+    <select id="accountPageList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        ${filed},
+        IFNULL(CONCAT(CAST(ROUND((SUM(charge)-t3.y_charge)/t3.y_charge*100,3)as CHAR),'%'),'0%') as 'grewRatio',
+        IFNULL(CONCAT(CAST(ROUND((SUM(charge)-t4.week_charge)/t4.week_charge*100,3)as CHAR),'%'),'0%') as
+        'weekGrewRatio',
+        t1.account_id 'accountId',
+        t2.auth_name as 'authName',
+        IFNULL(ROUND(SUM(play_3s_count) / SUM(aclick) * 100, 2), 0) as 'play3sRatio',
+        (select realname FROM sys_user where id = #{userId}) as 'realname',
+        IFNULL(t6.balance,0) as 'totalBalance',
+        IFNULL(t6.day_budget,0) as 'budget'
+        FROM ctop_etl_kuaishou_report_account_hourly t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        LEFT JOIN(
+        SELECT i1.account_id,SUM(charge) as 'y_charge' FROM ctop_kuaishou_report_hourly_account i1
+        LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
+        where stat_date = DATE_SUB(#{startTime},INTERVAL 1 DAY)
+        AND stat_hour &lt;= #{hours}
+        AND i2.user_id = #{userId}
+        GROUP BY i1.account_id
+        ) t3 ON t2.account_id = t3.account_id
+        LEFT JOIN(
+        SELECT i1.account_id,SUM(charge) as 'week_charge' FROM ctop_kuaishou_report_hourly_account i1
+        LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
+        where stat_date = DATE_SUB(#{startTime},INTERVAL 7 DAY)
+        AND stat_hour &lt;= #{hours}
+        AND i2.user_id = #{userId}
+        GROUP BY i1.account_id
+        ) t4 ON t2.account_id = t4.account_id
+        LEFT JOIN (
+        select account_id,balance,day_budget from ctop_kuaishou_account_balance_budget
+        where state =1
+        ) t6 ON t6.account_id = t2.account_id
+        where stat_date = #{startTime}
+        AND t2.user_id = #{userId}
+        GROUP BY t2.account_id
+        <if test="sortCode != '' and sortCode != null ">
+            ORDER BY ${sortCode}
+        </if>
+        ${sortType}
+    </select>
+
+    <select id="leaderAccountPageListTotal" resultType="java.lang.Integer">
+        select IFNULL(SUM(1),0)
+        from (
+        SELECT
+        t2.account_id
+        FROM ctop_etl_kuaishou_report_account_hourly t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        where stat_date = #{startTime}
+        and t2.account_status = 0
+        <if test="userIds != null">
+            AND t2.user_id IN
+            <foreach item="id" index="index" collection="userIds"
+                     open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+        <if test="projectId != null">
+            AND t2.project_id = #{projectId}
+        </if>
+        GROUP BY t2.account_id
+        ) t
+    </select>
+
+    <select id="leaderAccountPageList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        ${filed},
+        IFNULL(CONCAT(CAST(ROUND((SUM(charge)-t3.y_charge)/t3.y_charge*100,3)as CHAR),'%'),'0%') as 'grewRatio',
+        IFNULL(CONCAT(CAST(ROUND((SUM(charge)-t4.week_charge)/t4.week_charge*100,3)as CHAR),'%'),'0%') as
+        'weekGrewRatio',
+        t1.account_id 'accountId',
+        t2.auth_name as 'authName',
+        IFNULL(ROUND(SUM(play_3s_count) / SUM(aclick) * 100, 2), 0) as 'play3sRatio',
+        t5.realname,
+        IFNULL(t6.balance,0) as 'totalBalance',
+        IFNULL(t6.day_budget,0) as 'budget'
+        FROM ctop_etl_kuaishou_report_account_hourly t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        LEFT JOIN(
+        SELECT i1.account_id,SUM(charge) as 'y_charge' FROM ctop_kuaishou_report_hourly_account i1
+        LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
+        where stat_date = DATE_SUB(#{startTime},INTERVAL 1 DAY)
+        AND stat_hour &lt;= #{hours}
+        <if test="userIds != null">
+            AND i2.user_id IN
+            <foreach item="id" index="index" collection="userIds"
+                     open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+        <if test="projectId != null">
+            AND i2.project_id = #{projectId}
+        </if>
+        GROUP BY i1.account_id
+        ) t3 ON t2.account_id = t3.account_id
+        LEFT JOIN(
+        SELECT i1.account_id,SUM(charge) as 'week_charge' FROM ctop_kuaishou_report_hourly_account i1
+        LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
+        where stat_date = DATE_SUB(#{startTime},INTERVAL 7 DAY)
+        AND stat_hour &lt;= #{hours}
+        <if test="userIds != null">
+            AND i2.user_id IN
+            <foreach item="id" index="index" collection="userIds"
+                     open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+        <if test="projectId != null">
+            AND i2.project_id = #{projectId}
+        </if>
+        GROUP BY i1.account_id
+        ) t4 ON t2.account_id = t4.account_id
+        LEFT JOIN (
+        SELECT
+        id,realname
+        FROM
+        sys_user
+        WHERE 1=1
+        <if test="userIds != null">
+            and id IN
+            <foreach item="id" index="index" collection="userIds"
+                     open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+        ) t5 ON t2.user_id = t5.id
+        LEFT JOIN (
+        select account_id,balance,day_budget from ctop_kuaishou_account_balance_budget
+        where state =1
+        ) t6 ON t6.account_id = t2.account_id
+        where stat_date = #{startTime}
+        and t2.account_status = 0
+        <if test="userIds != null">
+            AND t2.user_id IN
+            <foreach item="id" index="index" collection="userIds"
+                     open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+        <if test="projectId != null">
+            AND t2.project_id = #{projectId}
+        </if>
+        GROUP BY t2.account_id
+        <if test="sortCode != '' and sortCode != null ">
+            ORDER BY ${sortCode}
+        </if>
+        ${sortType}
+    </select>
+
+    <select id="queryEveryHourlyCharge" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        IFNULL(stat_hour,'') 'time',
+        IFNULL(SUM(charge),0) 'value'
+        FROM ctop_kuaishou_report_hourly_account t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        where stat_date = #{startTime}
+        AND t2.user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY stat_hour
+        ORDER BY stat_hour
+    </select>
+
+    <select id="operatingStaffDataListTotal" resultType="java.lang.Integer">
+        SELECT IFNULL(SUM(1),0)
+        FROM (
+        SELECT 1
+        FROM ctop_etl_kuaishou_report_account_hourly t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        WHERE stat_date = #{today}
+        AND t2.account_status = 0
+        AND t2.user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY t2.user_id
+        ) t
+    </select>
+
+    <select id="operatingStaffDataList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        IFNULL(t2.user_id,'') 'userId',
+        IFNULL(t9.realname,'') 'realName',
+        IFNULL(t3.accountCount,0) 'accountCount',
+        IFNULL(SUM(t1.charge),0) 'charge',
+        IFNULL(t4.weekCharge,0) 'weekCharge',
+        concat(CAST(IFNULL(ROUND((t4.weekCharge-t5.lweekCharge)/t5.lweekCharge*100,2), 0)as char),'%')as 'grew',
+        IFNULL(t6.effectiveCount,0) 'effectiveCount',
+        IFNULL(t7.campaignCount,0) 'campaignCount',
+        IFNULL(t8.unitCount,0) 'unitCount'
+        FROM
+        ctop_etl_kuaishou_report_account_hourly t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        LEFT JOIN(
+        SELECT user_id,COUNT(1) 'accountCount' FROM ctop_user_allocation i1
+        INNER JOIN ctop_etl_kuaishou_report_account_hourly  i2 ON i1.account_id = i2.account_id
+        AND i2.stat_date = #{today}
+        WHERE
+        account_status = 0 AND user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY user_id
+        ) t3 ON t2.user_id = t3.user_id
+        LEFT JOIN (
+        SELECT
+        SUM(charge) 'weekCharge',
+        tt2.user_id
+        FROM
+        ctop_etl_kuaishou_report_account_daily tt1
+        LEFT JOIN ctop_user_allocation tt2 ON tt1.account_id = tt2.account_id
+        WHERE tt1.stat_date &lt;=#{today}
+        and tt1.stat_date &gt;=#{weekStartTime}
+        AND tt2.user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY tt2.user_id
+        ) t4 ON t2.user_id = t4.user_id
+        LEFT JOIN (
+        SELECT
+        SUM(charge) 'lweekCharge',
+        tt2.user_id
+        FROM
+        ctop_etl_kuaishou_report_account_daily tt1
+        LEFT JOIN ctop_user_allocation tt2 ON tt1.account_id = tt2.account_id
+        WHERE tt1.stat_date &lt;=#{lweekEndTime}
+        and tt1.stat_date &gt;=#{lweekStartTime}
+        AND tt2.user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY tt2.user_id
+        ) t5 ON t2.user_id = t5.user_id
+        LEFT JOIN (
+        SELECT
+        SUM(effective_count) 'effectiveCount',
+        tt2.user_id
+        FROM
+        ctop_etl_kuaishou_account_material_overview tt1
+        LEFT JOIN ctop_user_allocation tt2 ON tt1.account_id = tt2.account_id
+        WHERE tt1.state_date = #{yesterday}
+        AND tt2.user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY tt2.user_id
+        ) t6 ON t2.user_id = t6.user_id
+        LEFT JOIN (
+        SELECT
+        SUM(new_count) 'campaignCount',
+        tt2.user_id
+        FROM
+        ctop_etl_kuaishou_newly tt1
+        LEFT JOIN ctop_user_allocation tt2 ON tt1.account_id = tt2.account_id
+        WHERE tt1.stat_date = #{yesterday}
+        AND tt1.new_type = 'campaign'
+        AND tt2.user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY tt2.user_id
+        ) t7 ON t2.user_id = t7.user_id
+        LEFT JOIN (
+        SELECT
+        SUM(new_count) 'unitCount',
+        tt2.user_id
+        FROM
+        ctop_etl_kuaishou_newly tt1
+        LEFT JOIN ctop_user_allocation tt2 ON tt1.account_id = tt2.account_id
+        WHERE tt1.stat_date = #{yesterday}
+        AND tt1.new_type = 'unit'
+        AND tt2.user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY tt2.user_id
+        ) t8 ON t2.user_id = t8.user_id
+        LEFT JOIN (
+        SELECT
+        id,realname
+        FROM
+        sys_user
+        WHERE id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        ) t9 ON t2.user_id = t9.id
+        WHERE t1.stat_date = #{today}
+        AND t2.account_status = 0
+        AND t2.user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY t2.user_id
+        <if test="sortCode != '' and sortCode != null ">
+            ORDER BY ${sortCode}
+        </if>
+        ${sortType}
+    </select>
+
+    <select id="projectPageList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        ${filed},
+        IFNULL(CONCAT(CAST(ROUND((SUM(charge)-t5.y_charge)/t5.y_charge*100,3)as CHAR),'%'),'0%') as 'grewRatio',
+        IFNULL(CONCAT(CAST(ROUND((SUM(charge)-t6.week_charge)/t6.week_charge*100,3)as CHAR),'%'),'0%') as
+        'weekGrewRatio',
+        t2.project_id 'projectId',
+        t3.project_name as 'projectName',
+        IFNULL(ROUND(SUM(play_3s_count) / SUM(aclick) * 100, 2), 0) as 'play3sRatio',
+        (
+        SELECT count(1) FROM ctop_etl_kuaishou_report_account_hourly i1
+        LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
+        where project_id = t3.id and account_status = 0
+        AND i1.stat_date = #{startTime}) as 'accountCount',
+        IFNULL(t4.userCount,0) as 'userCount'
+        FROM ctop_etl_kuaishou_report_account_hourly t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        LEFT JOIN ctop_project t3 ON t2.project_id = t3.id
+        LEFT JOIN (
+        SELECT project_id,COUNT(1) 'userCount'
+        FROM (
+        SELECT DISTINCT project_id,user_id
+        FROM ctop_user_allocation
+        where account_status = 0
+        ) t
+        GROUP BY project_id
+        ) t4 ON t4.project_id = t3.id
+        LEFT JOIN(
+        SELECT i1.account_id,SUM(charge) as 'y_charge' FROM ctop_kuaishou_report_hourly_account i1
+        LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
+        where stat_date = DATE_SUB(#{startTime},INTERVAL 1 DAY)
+        AND stat_hour &lt;= #{hours}
+        AND i2.user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY i1.account_id
+        ) t5 ON t2.account_id = t5.account_id
+        LEFT JOIN(
+        SELECT i1.account_id,SUM(charge) as 'week_charge' FROM ctop_kuaishou_report_hourly_account i1
+        LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
+        where stat_date = DATE_SUB(#{startTime},INTERVAL 7 DAY)
+        AND stat_hour &lt;= #{hours}
+        AND i2.user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY i1.account_id
+        ) t6 ON t2.account_id = t6.account_id
+        where stat_date = #{startTime}
+        and t2.account_status = 0
+        AND t2.user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY t3.id
+        <if test="sortCode != '' and sortCode != null ">
+            ORDER BY ${sortCode}
+        </if>
+        ${sortType}
+    </select>
+
+    <select id="projectPageListTotal" resultType="java.lang.Integer">
+        select IFNULL(SUM(1),0) from
+        (
+        SELECT
+        t3.id
+        FROM ctop_etl_kuaishou_report_account_hourly t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        LEFT JOIN ctop_project t3 ON t2.project_id = t3.id
+        where stat_date = #{startTime}
+        and t2.account_status = 0
+        AND t2.user_id in
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY t3.id
+        )t
+    </select>
+
+
 </mapper>

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

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

@@ -0,0 +1,139 @@
+<?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.KuaiShouReportHourlyMaterialMapper">
+
+    <insert id="batchReplace">
+        replace into `ctop_kuaishou_report_hourly_material` (
+        account_id,
+        photo_id,
+        channel_type,
+        signature,
+        image_token,
+        cover_url,
+        photo_url,
+        creative_material_type_string,
+        ad_scene,
+        charge,
+        photo_show,
+        aclick,
+        bclick,
+        photo_share,
+        photo_comment,
+        photo_like,
+        follow,
+        cancel_follow,
+        report,
+        block,
+        negative,
+        download_started,
+        download_completed,
+        activation,
+        submit,
+        stat_date,
+        stat_hour,
+        photo_click,
+        photo_click_ratio,
+        action_ratio,
+        impression_1k_cost,
+        photo_click_cost,
+        action_cost,
+        event_pay_first_day,
+        event_pay_purchase_amount_first_day,
+        event_pay_first_day_roi,
+        event_pay,
+        event_pay_purchase_amount,
+        event_pay_roi,
+        event_register,
+        event_register_cost,
+        event_register_ratio,
+        event_jin_jian_app,
+        event_jin_jian_app_cost,
+        event_credit_grant_app,
+        event_credit_grant_app_cost,
+        event_credit_grant_app_ratio,
+        event_order_paid,
+        event_order_paid_purchase_amount,
+        event_jin_jian_landing_page,
+        event_jin_jian_landing_page_cost,
+        event_credit_grant_landing_page,
+        event_credit_grant_landing_page_cost,
+        event_credit_grant_landing_ratio,
+        event_next_day_stay_cost,
+        event_next_day_stay_ratio,
+        form_action_ratio,
+        event_order_paid_cost,
+        event_next_day_stay,
+        form_cost,
+        form_count,
+        play_3s_ratio
+        )
+        values
+        <foreach collection="addList" item="material" separator=",">
+            (
+            #{material.accountId},
+            #{material.photoId},
+            #{material.channelType},
+            #{material.signature},
+            #{material.imageToken},
+            #{material.coverUrl},
+            #{material.photoUrl},
+            #{material.creativeMaterialTypeString},
+            #{material.adScene},
+            #{material.charge},
+            #{material.photoShow},
+            #{material.aclick},
+            #{material.bclick},
+            #{material.photoShare},
+            #{material.photoComment},
+            #{material.photoLike},
+            #{material.follow},
+            #{material.cancelFollow},
+            #{material.report},
+            #{material.block},
+            #{material.negative},
+            #{material.downloadStarted},
+            #{material.downloadCompleted},
+            #{material.activation},
+            #{material.submit},
+            #{material.statDate},
+            #{material.statHour},
+            #{material.photoClick},
+            #{material.photoClickRatio},
+            #{material.actionRatio},
+            #{material.impression1kCost},
+            #{material.photoClickCost},
+            #{material.actionCost},
+            #{material.eventPayFirstDay},
+            #{material.eventPayPurchaseAmountFirstDay},
+            #{material.eventPayFirstDayRoi},
+            #{material.eventPay},
+            #{material.eventPayPurchaseAmount},
+            #{material.eventPayRoi},
+            #{material.eventRegister},
+            #{material.eventRegisterCost},
+            #{material.eventRegisterRatio},
+            #{material.eventJinJianApp},
+            #{material.eventJinJianAppCost},
+            #{material.eventCreditGrantApp},
+            #{material.eventCreditGrantAppCost},
+            #{material.eventCreditGrantAppRatio},
+            #{material.eventOrderPaid},
+            #{material.eventOrderPaidPurchaseAmount},
+            #{material.eventJinJianLandingPage},
+            #{material.eventJinJianLandingPageCost},
+            #{material.eventCreditGrantLandingPage},
+            #{material.eventCreditGrantLandingPageCost},
+            #{material.eventCreditGrantLandingRatio},
+            #{material.eventNextDayStayCost},
+            #{material.eventNextDayStayRatio},
+            #{material.formActionRatio},
+            #{material.eventOrderPaidCost},
+            #{material.eventNextDayStay},
+            #{material.formCost},
+            #{material.formCount},
+            #{material.play3sRatio}
+            )
+        </foreach>
+
+    </insert>
+</mapper>

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

@@ -175,4 +175,42 @@
         GROUP BY account_id
     </select>
 
+
+    <select id="queryPersonalAchievements" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        IFNULL((SELECT realname from sys_user WHERE id = #{userId}),'') as 'realName',
+        IFNULL(SUM(charge),0) 'charge',
+        IFNULL(ROUND((SUM(charge)-t3.zcharge)/t3.zcharge*100,2),0) 'grew',
+        IFNULL(t4.weekCharge,0) 'weekCharge',
+        IFNULL(t5.lweekCharge,0) 'lweekCharge',
+        IFNULL(ROUND((t4.weekCharge-t5.lweekCharge)/t5.lweekCharge*100,2),0) 'weekGrew',
+        IFNULL((SELECT count(1) FROM ctop_user_allocation where user_id = #{userId} AND account_status = 0),0) 'accouuntCount'
+        FROM ctop_kuaishou_report_hourly_account t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        LEFT JOIN(
+        SELECT SUM(charge) 'zcharge' FROM ctop_kuaishou_report_hourly_account i1
+        LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
+        WHERE i2.user_id = #{userId}
+        AND i1.stat_date = DATE_SUB(#{today},INTERVAL 1 DAY)
+        AND i1.stat_hour  &lt;= DATE_FORMAT(now(), '%H')
+        ) t3 ON 1=1
+        LEFT JOIN(
+        SELECT SUM(charge) 'weekCharge' FROM ctop_etl_kuaishou_report_account_daily i1
+        LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
+        WHERE i2.user_id = #{userId}
+        AND i1.stat_date &gt;= #{startDate}
+        AND i1.stat_date  &lt;= #{today}
+        ) t4 ON 1=1
+        LEFT JOIN(
+        SELECT SUM(charge) 'lweekCharge' FROM ctop_etl_kuaishou_report_account_daily i1
+        LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
+        WHERE i2.user_id = #{userId}
+        AND i1.stat_date &gt;= #{lastStartDate}
+        AND i1.stat_date  &lt;= #{lastEndDate}
+        ) t5 ON 1=1
+        WHERE t2.user_id = #{userId}
+        AND t1.stat_date = #{today}
+        AND t1.stat_hour &lt;= DATE_FORMAT(now(), '%H')
+    </select>
+
 </mapper>

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

@@ -25,4 +25,18 @@ public interface IEtlKuaishouReportAccountHourlyService extends IService<EtlKuai
     Result<Object> getMaxChargeAccountId(Long accountId);
 
     Result<Object> getMaxChargeAccountIdByUser(String userId);
+
+    Result<Object> queryPersonalAchievements(String userId);
+
+    Result<Object> checkRole(String userId);
+
+    Result<Object> accountPageList(JSONObject request) throws Exception;
+
+    Result<Object> queryNewlyData(JSONObject request);
+
+    Result<Object> operatingStaffDataList(JSONObject request);
+
+    Result<Object> projectList(JSONObject request) throws Exception;
+
+    Result<Object> leaderAccountPageList(JSONObject request) throws Exception;
 }

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouProjectData;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 快手-配置项目拉取时报数据
+ * @Author: jeecg-boot
+ * @Date: 2021-04-20
+ * @Version: V1.0
+ */
+public interface IKuaiShouProjectDataService extends IService<KuaiShouProjectData> {
+
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportHourlyMaterial;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 素材时报
+ * @Author: jeecg-boot
+ * @Date: 2021-04-20
+ * @Version: V1.0
+ */
+public interface IKuaiShouReportHourlyMaterialService extends IService<KuaiShouReportHourlyMaterial> {
+
+}

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

@@ -6,5 +6,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import java.util.List;
 
 public interface IKuaishouReportHourlyGroupService extends IService<KuaishouReportHourlyGroup> {
+
+    void getAdvertiserGroupReportHourly(Long accountId, String accessToken, String startDate, String endDate);
+
     void replaceBatch(List<KuaishouReportHourlyGroup> groups);
 }

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

@@ -2,13 +2,18 @@ package cn.com.ctop.kuaishou.modules.report.service.impl;
 
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.SysRole;
 import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.SysDepartMapper;
+import cn.com.ctop.common.module.mapper.SysRoleMapper;
+import cn.com.ctop.common.module.mapper.SysUserDepartMapper;
 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.batch.mapper.KuaiShouCreativeMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountHourly;
+import cn.com.ctop.kuaishou.modules.report.enums.CheckParametersCostEnum;
 import cn.com.ctop.kuaishou.modules.report.enums.CheckParametersEnum;
 import cn.com.ctop.kuaishou.modules.report.mapper.EtlKuaishouReportAccountDailyMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.EtlKuaishouReportAccountHourlyMapper;
@@ -16,11 +21,16 @@ import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportHourlyAccountMap
 import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaishouReportAccountHourlyService;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.constant.AccountReportConstants;
 import org.jeecg.common.util.DateUtils;
+import org.jeecg.common.util.JsonResourceUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.text.ParseException;
@@ -29,7 +39,9 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 账户维度-每小时盯盘数据
@@ -57,6 +69,12 @@ public class EtlKuaishouReportAccountHourlyServiceImpl extends ServiceImpl<EtlKu
     private EtlKuaishouReportAccountDailyMapper etlDailyAccountMapper;
     @Autowired
     private ICtopOauthTokenService oauthTokenService;
+    @Resource
+    private SysDepartMapper departMapper;
+    @Resource
+    private SysUserDepartMapper sysUserDepartMapper;
+    @Resource
+    private SysRoleMapper roleMapper;
 
     @Override
     public void queryEveryhourlyDataForAccount() {
@@ -274,10 +292,355 @@ public class EtlKuaishouReportAccountHourlyServiceImpl extends ServiceImpl<EtlKu
             result.setMessage("未获取到账户信息");
             return result;
         }
+        obj.put("totalBalance", getBalance(oauthToken));
+        return Result.ok(obj);
+    }
+
+    private BigDecimal getBalance(CtopOauthToken oauthToken) {
         JSONObject fundJson = iKuaishouInterfaceService.fundGet(oauthToken);
         if (!Check.isNull(fundJson)) {
-            obj.put("totalBalance", fundJson.getBigDecimal("balance")); // 余额
+            return fundJson.getBigDecimal("balance"); // 余额
+        }
+        return new BigDecimal(0);
+    }
+
+    /**
+     * 运营盯盘,---------个人绩效
+     */
+    @Override
+    public Result<Object> queryPersonalAchievements(String userId) {
+        Map<String, Object> paramsMap = new HashMap<>();
+        //本周一
+        String monday = DateUtils.getdateFromWeek(1);
+        //当天日期
+        String today = DateUtils.formatDate(new Date());
+        //上周一日期
+        String lastStartDate = DateUtils.getLastDay(monday, 7);
+        //上周当天日期
+        String lastEndDate = DateUtils.getLastDay(today, 7);
+        paramsMap.put("lastStartDate", lastStartDate);
+        paramsMap.put("lastEndDate", lastEndDate);
+        paramsMap.put("startDate", monday);
+        paramsMap.put("today", today);
+        paramsMap.put("userId", userId);
+        JSONObject data = hourlyAccountMapper.queryPersonalAchievements(paramsMap);
+        if (!Check.isNull(data)) {
+            Integer totle = 0;
+            Integer rank = 0;
+            paramsMap.put("mStartDate", DateUtils.dateformat(DateUtils.initDateByMonth(), DateUtils.WEB_FORMAT));
+            JSONObject user = etlDailyAccountMapper.getMonthlyRank(paramsMap);
+            if (!Check.isNull(user)) {
+                totle = user.getInteger("totle");
+                rank = user.getInteger("id");
+                data.put("monthCharge", user.getBigDecimal("charge"));
+            }
+            data.put("total", totle);
+            data.put("rank", rank);
+        }
+        return Result.ok(data);
+    }
+
+    @Override
+    public Result<Object> checkRole(String userId) {
+        SysRole role = roleMapper.queryRoleByUserId(userId);
+        if (Check.isNull(role)) {
+            return Result.error("员工未划分角色");
+        }
+        boolean flag = false;
+        String roleCode = role.getRoleCode();
+        //TODO 后续去除 roleName相关的逻辑
+        String roleName = role.getRoleName();
+        if (roleName.contains("总监") || roleName.contains("经理") || roleName.contains("管理员")
+                || "genera_manager_of_operations".equals(roleCode)
+                || "kuaishou_operations_director".equals(roleCode)
+                || "kuaishou_operations_manager".equals(roleCode)) {
+            flag = true;
+        }
+        return Result.ok(flag);
+    }
+
+    @Override
+    public Result<Object> accountPageList(JSONObject request) throws Exception {
+        Integer pageNo = request.getInteger("pageNo");
+        Integer pageSize = request.getInteger("pageSize");
+        if (Check.isNull(pageNo)) {
+            pageNo = 1;
+        }
+        if (Check.isNull(pageSize)) {
+            pageSize = 10;
+        }
+        String startTime = request.getString("startTime");
+        String endTime = request.getString("endTime");
+        String userId = request.getString("userId");
+        if (Check.isNull(startTime) && Check.isNull(userId)) {
+            return Result.error("请选择时间和用户");
+        }
+        //参数处理
+        configParameter(request);
+        List<JSONObject> list = null;
+        int total = 0;
+        //单日数据
+        if (endTime.equals(startTime)) {
+            if (startTime.equals(DateUtils.formatDate(new Date()))) {
+                request.put("hours", DateUtils.getNowHour());
+            } else {
+                request.put("hours", 24);
+            }
+            total = etlHourlyAccountMapper.accountPageListTotal(request);
+            PageHelper.startPage(pageNo, pageSize, false);
+            list = etlHourlyAccountMapper.accountPageList(request);
+        } else {
+            //多日数据
+            total = etlDailyAccountMapper.accountPageListTotal(request);
+            PageHelper.startPage(pageNo, pageSize, false);
+            list = etlDailyAccountMapper.accountPageList(request);
+        }
+        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
+        if (!Check.isNull(pageInfo)) {
+            pageInfo.setTotal(total);
+        }
+        return Result.ok(pageInfo);
+    }
+
+    /**
+     * 配置参数
+     */
+    private void configParameter(JSONObject request) throws Exception {
+        Map<String, Map<String, Object>> parameter = AccountReportConstants.dicMapKs;
+        parameter.remove("play3sRate");
+        String filedAll = JsonResourceUtil.joinAllFiled(parameter);
+        if (Check.isNull(filedAll)) {
+            throw new Exception("初始化查询字段,结果为空");
+        }
+        request.put("filed", filedAll);
+        String sortCode = request.getString("sortCode");
+        if (Check.isNull(sortCode)) {
+            request.put("sortCode", "sum(charge)");
+        } else {
+            request.put("sortCode", CheckParametersCostEnum.getFormula(sortCode));
+        }
+        if (Check.isNull(request.getString("sortType"))) {
+            request.put("sortType", "DESC");
+        }
+    }
+
+
+    @Override
+    public Result<Object> queryNewlyData(JSONObject request) {
+        String userId = request.getString("userId");
+        String startTime = request.getString("startTime");
+        String endTime = request.getString("endTime");
+        String parameterCode = request.getString("parameterCode");
+        if (Check.isNull(userId) || Check.isNull(startTime) || Check.isNull(endTime) || Check.isNull(parameterCode)) {
+            return Result.error("缺失参数");
+        }
+        request.put("userIds", getUserIdList(userId));
+        List<JSONObject> data = null;
+        JSONObject result = new JSONObject();
+        //单日数据
+        String updateTime = "";
+        if (startTime.equals(endTime)) {
+            data = etlHourlyAccountMapper.queryEveryHourlyCharge(request);
+            updateTime = etlHourlyAccountMapper.getNewlyUpdateTime();
+        } else {
+            updateTime = etlDailyAccountMapper.getNewlyUpdateTime();
+            if (parameterCode.equals("campaign") || parameterCode.equals("unit")) {
+                data = etlDailyAccountMapper.queryEveryDayCount(request);
+            } else {
+                data = etlDailyAccountMapper.queryEveryDayCharge(request);
+            }
+        }
+        result.put("data", data);
+        result.put("updateTime", updateTime);
+        return Result.ok(result);
+    }
+
+    /**
+     * 通过经理或者总监userId,获取其部门的员工Id
+     */
+    private List<String> getUserIdList(String userId) {
+        SysRole role = roleMapper.queryRoleByUserId(userId);
+        String roleCode = role.getRoleCode();
+        List<String> ids = new ArrayList<>();
+        List<JSONObject> departIds = new ArrayList<>();
+        //管理员和运营总经理 可以查看所有快手的运营信息
+        if ("genera_manager_of_operations".equals(roleCode) || "admin".equals(roleCode)) {
+            JSONObject obj = new JSONObject();
+            //快手运营部 峰级部门 ID
+            obj.put("id", "024b0dc0840045afb048022a8c61253f");
+            departIds.add(obj);
+        } else {
+            departIds = departMapper.getDepartmentIds(userId);
+        }
+        if (!Check.isNull(departIds)) {
+            ids.add(departIds.get(0).getString("id"));
+            checkDepart(departIds, ids);
+        }
+        List<String> userIds = null;
+        if (!Check.isNull(ids)) {
+            userIds = sysUserDepartMapper.getUserIds(ids);
+        }
+        if (Check.isNull(userIds)) {
+            userIds = new ArrayList<>();
+            userIds.add(userId);
+        }
+        return userIds;
+    }
+
+    @Override
+    public Result<Object> operatingStaffDataList(JSONObject request) {
+        String userId = request.getString("userId");
+        if (Check.isNull(userId)) {
+            return Result.error("缺少账户入参");
+        }
+        String sortCode = request.getString("sortCode");
+        if (Check.isNull(sortCode)) {
+            request.put("sortCode", "SUM(t1.charge)");
+        } else {
+            if ("charge".equals(sortCode)) {
+                request.put("sortCode", "SUM(t1.charge)");
+            }
+        }
+        if (Check.isNull(request.getString("sortType"))) {
+            request.put("sortType", "DESC");
+        }
+        Integer pageNo = request.getInteger("pageNo");
+        Integer pageSize = request.getInteger("pageSize");
+        if (Check.isNull(pageNo)) {
+            pageNo = 1;
+        }
+        if (Check.isNull(pageSize)) {
+            pageSize = 10;
+        }
+        //本周一
+        String weekStartTime = DateUtils.getdateFromWeek(1);
+        //当天日期
+        String today = DateUtils.formatDate(new Date());
+        //上周一日期
+        String lweekStartTime = DateUtils.getLastDay(weekStartTime, 7);
+        //上周当天日期
+        String lweekEndTime = DateUtils.getLastDay(today, 7);
+        //昨天
+        String yesterday = DateUtils.getLastDay(today, 1);
+        request.put("today", today);
+        request.put("weekStartTime", weekStartTime);
+        request.put("lweekEndTime", lweekEndTime);
+        request.put("lweekStartTime", lweekStartTime);
+        request.put("yesterday", yesterday);
+        //获取人群集
+        request.put("userIds", getUserIdList(userId));
+        int totle = etlHourlyAccountMapper.operatingStaffDataListTotal(request);
+        PageHelper.startPage(pageNo, pageSize, false);
+        PageInfo pageInfo = new PageInfo(etlHourlyAccountMapper.operatingStaffDataList(request));
+        if (!Check.isNull(pageInfo)) {
+            pageInfo.setTotal(totle);
+        }
+        return Result.ok(pageInfo);
+    }
+
+    @Override
+    public Result<Object> projectList(JSONObject request) throws Exception {
+        Integer pageNo = request.getInteger("pageNo");
+        Integer pageSize = request.getInteger("pageSize");
+        if (Check.isNull(pageNo)) {
+            pageNo = 1;
+        }
+        if (Check.isNull(pageSize)) {
+            pageSize = 10;
+        }
+        String startTime = request.getString("startTime");
+        String endTime = request.getString("endTime");
+        String userId = request.getString("userId");
+        if (Check.isNull(startTime) && Check.isNull(userId)) {
+            return Result.error("请选择时间和用户");
+        }
+        //参数处理
+        configParameter(request);
+        //获取人群集
+        request.put("userIds", getUserIdList(userId));
+        List<JSONObject> list = null;
+        int total = 0;
+        //单日数据
+        if (endTime.equals(startTime)) {
+            if (startTime.equals(DateUtils.formatDate(new Date()))) {
+                request.put("hours", DateUtils.getNowHour());
+            } else {
+                request.put("hours", 24);
+            }
+            total = etlHourlyAccountMapper.projectPageListTotal(request);
+            PageHelper.startPage(pageNo, pageSize, false);
+            list = etlHourlyAccountMapper.projectPageList(request);
+        } else {
+            //多日数据
+            total = etlDailyAccountMapper.projectPageListTotal(request);
+            PageHelper.startPage(pageNo, pageSize, false);
+            list = etlDailyAccountMapper.projectPageList(request);
+        }
+
+        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
+        if (!Check.isNull(pageInfo)) {
+            pageInfo.setTotal(total);
+        }
+        return Result.ok(pageInfo);
+    }
+
+    @Override
+    public Result<Object> leaderAccountPageList(JSONObject request) throws Exception {
+        Integer pageNo = request.getInteger("pageNo");
+        Integer pageSize = request.getInteger("pageSize");
+        if (Check.isNull(pageNo)) {
+            pageNo = 1;
+        }
+        if (Check.isNull(pageSize)) {
+            pageSize = 10;
+        }
+        String startTime = request.getString("startTime");
+        String endTime = request.getString("endTime");
+        String userId = request.getString("userId");
+        if (Check.isNull(startTime) && Check.isNull(userId)) {
+            return Result.error("请选择时间和用户");
+        }
+        //参数处理
+        configParameter(request);
+        List<JSONObject> list = null;
+        int total = 0;
+        if (Check.isNull(request.getLong("projectId"))) {
+            //获取人群集
+            request.put("userIds", getUserIdList(userId));
+        }
+        //单日数据
+        if (endTime.equals(startTime)) {
+            if (startTime.equals(DateUtils.formatDate(new Date()))) {
+                request.put("hours", DateUtils.getNowHour());
+            } else {
+                request.put("hours", 24);
+            }
+            total = etlHourlyAccountMapper.leaderAccountPageListTotal(request);
+            PageHelper.startPage(pageNo, pageSize, false);
+            list = etlHourlyAccountMapper.leaderAccountPageList(request);
+        } else {
+            //多日数据
+            total = etlDailyAccountMapper.leaderAccountPageListTotal(request);
+            PageHelper.startPage(pageNo, pageSize, false);
+            list = etlDailyAccountMapper.leaderAccountPageList(request);
+        }
+        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
+        if (!Check.isNull(pageInfo)) {
+            pageInfo.setTotal(total);
+        }
+        return Result.ok(pageInfo);
+    }
+
+    /**
+     * 递归查询出所有部门
+     */
+    private void checkDepart(List<JSONObject> departIds, List<String> ids) {
+        for (JSONObject depart : departIds) {
+            ids.add(depart.getString("id"));
+        }
+        departIds = departMapper.checkLowestLevelDepartment(departIds);
+        if (!Check.isNull(departIds)) {
+            checkDepart(departIds, ids);
         }
-        return Result.ok(obj);
     }
 }

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

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouProjectData;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaiShouProjectDataMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouProjectDataService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 快手-配置项目拉取时报数据
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-04-20
+ */
+@Service
+public class KuaiShouProjectDataServiceImpl extends ServiceImpl<KuaiShouProjectDataMapper, KuaiShouProjectData> implements IKuaiShouProjectDataService {
+
+}

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

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportHourlyMaterial;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaiShouReportHourlyMaterialMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouReportHourlyMaterialService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 素材时报
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-04-20
+ */
+@Service
+public class KuaiShouReportHourlyMaterialServiceImpl extends ServiceImpl<KuaiShouReportHourlyMaterialMapper, KuaiShouReportHourlyMaterial> implements IKuaiShouReportHourlyMaterialService {
+
+}

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

@@ -1,19 +1,79 @@
 package cn.com.ctop.kuaishou.modules.report.service.impl;
 
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyGroup;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportHourlyGroupMapper;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyGroupService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import lombok.var;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.List;
+import java.util.*;
 
 @Service
+@Slf4j
 public class KuaishouReportHourlyGroupServiceImpl extends ServiceImpl<KuaishouReportHourlyGroupMapper, KuaishouReportHourlyGroup> implements IKuaishouReportHourlyGroupService {
     @Autowired
     private KuaishouReportHourlyGroupMapper groupMapper;
 
+
+    @Override
+    public void getAdvertiserGroupReportHourly(Long accountId, String accessToken, String startDate, String endDate) {
+        getGroupHourlyReportByPage(accountId, accessToken, startDate, endDate, 1);
+    }
+
+    private void getGroupHourlyReportByPage(Long accountId, String accessToken, String startDate, String endDate, int page) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GTOUP_REPORT;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", accessToken);
+        Map<String, Object> param = new HashMap<>();
+        param.put("start_date", startDate);
+        param.put("end_date", endDate);
+        param.put("advertiser_id", accountId);
+        param.put("temporal_granularity", "HOURLY");
+        param.put("page_size", 2000);
+        param.put("page", page);
+
+        String result = HttpUtils.httpPostRequest(url, param, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取快手广告组时报表异常:{},accountId:{}", message, accountId);
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (null == details || details.size() <= 0) {
+            log.info("快手广告组时报表信息为空=》accountId:{}", accountId);
+            return;
+        }
+        List<KuaishouReportHourlyGroup> groups = new ArrayList<>();
+        for (int i = 0; i < details.size(); i++) {
+            JSONObject detailJson = details.getJSONObject(i);
+            var show = detailJson.getLong("show");
+            detailJson.put("photo_show", show);
+            var like = detailJson.getLong("like");
+            detailJson.put("photo_like", like);
+            var hourlyGroup = JSONObject.toJavaObject(detailJson, KuaishouReportHourlyGroup.class);
+            hourlyGroup.setAccountId(accountId);
+            hourlyGroup.setId("" + hourlyGroup.getAccountId() + hourlyGroup.getUnitId() + hourlyGroup.getStatDate() + hourlyGroup.getStatHour());
+            hourlyGroup.setCreateTime(new Date());
+            hourlyGroup.setUpdateTime(new Date());
+            groups.add(hourlyGroup);
+        }
+        groupMapper.replaceBatch(groups);
+
+        getGroupHourlyReportByPage(accountId, accessToken, startDate, endDate, page + 1);
+    }
+
+
     @Override
     public void replaceBatch(List<KuaishouReportHourlyGroup> groups) {
         groupMapper.replaceBatch(groups);

+ 2 - 2
module-kuaishou/src/main/resources/json_template/kuaishou_filed_mapping.json

@@ -84,7 +84,7 @@
     "comment": "首日付费成本"
   },
   "firstDayPayROI": {
-    "filed": "CASE WHEN sum(t1.event_pay_purchase_amount_first_day) / sum(t1.charge) IS NULL THEN 0 ELSE sum(t1.event_pay_purchase_amount_first_day) / sum(t1.charge) end AS firstDayPayROI ",
+    "filed": "CASE WHEN sum(t1.event_pay_purchase_amount_first_day) / sum(t1.charge) IS NULL THEN '0%' ELSE concat(CAST(round(sum(t1.event_pay_purchase_amount_first_day) / sum(t1.charge)*100,2) AS CHAR) ,'%') end AS firstDayPayROI ",
     "comment": "首日ROI"
   },
   "eventPay": {
@@ -100,7 +100,7 @@
     "comment": "付费次数成本"
   },
   "ROI": {
-    "filed": "CASE WHEN sum(t1.event_pay_purchase_amount) / sum(t1.charge) IS NULL THEN 0 ELSE sum(t1.event_pay_purchase_amount) / sum(t1.charge) end AS ROI ",
+    "filed": "CASE WHEN sum(t1.event_pay_purchase_amount) / sum(t1.charge) IS NULL THEN '0%' ELSE concat(CAST(round(sum(t1.event_pay_purchase_amount) / sum(t1.charge)*100,2) AS CHAR) ,'%') end AS ROI ",
     "comment": "ROI"
   },
   "register": {

+ 1 - 1
module-oa/src/main/java/cn/com/ctop/oa/modules/mapper/xml/WechatNoListMapper.xml

@@ -19,7 +19,7 @@
         end AS type,
         case when nl.type!=''and nl.type !='补卡' then CONCAT(nl.new_duration,' h')
         when ck.checkin_type ='上班打卡'and ck.exception_type ='时间异常' then
-        CONCAT(TIMESTAMPDIFF(MINUTE,DATE_FORMAT(CONCAT(DATE_FORMAT(ck.checkin_time,'%Y-%m-%d '),'09:35:00'),'%Y-%m-%d %H:%i:%s'),ck.checkin_time),' min')
+        CONCAT(TIMESTAMPDIFF(MINUTE,DATE_FORMAT(CONCAT(DATE_FORMAT(ck.checkin_time,'%Y-%m-%d '),'09:36:00'),'%Y-%m-%d %H:%i:%s'),ck.checkin_time)+1,' min')
         when ck.checkin_type ='下班打卡'and ck.exception_type ='时间异常' then
         CONCAT(TIMESTAMPDIFF(MINUTE,ck.checkin_time,DATE_FORMAT(CONCAT(DATE_FORMAT(ck.checkin_time,'%Y-%m-%d '),'19:00:00'),'%Y-%m-%d %H:%i:%s')),' min')
         end AS stateDuration

+ 1 - 1
module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatCheckinDataServiceImpl.java

@@ -91,7 +91,7 @@ public class WechatCheckinDataServiceImpl extends ServiceImpl<WechatCheckinDataM
                                 String exceptionType = jsonObject.getString("exception_type");
                                 if (NoEn.NO1.valueStr().equals(checkinTypeCode)) {
                                     if ("星期一".equals(DateUtils.getWhatDay(checkinTimeStamp))) {
-                                        long toTime = DateUtils.timeToStamp(dateStr + " 09:35:00");
+                                        long toTime = DateUtils.timeToStamp(dateStr + " 09:36:00");
                                         if (checkinTimeStamp > toTime) {
                                             exceptionType = Check.isNull(exceptionType) ? "时间异常" : exceptionType;
                                         }