Browse Source

Merge remote-tracking branch 'origin/master'

xuzuoyun 5 years ago
parent
commit
17fbdc6cd5
61 changed files with 1094 additions and 464 deletions
  1. 0 1
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java
  2. 3 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AdvertiserController.java
  3. 58 62
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java
  4. 22 9
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java
  5. 2 4
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java
  6. 50 63
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  7. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TransferAccountController.java
  8. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  9. 81 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/KuaishouMatcostAccountMay.java
  10. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/AccountCpaBidJob.java
  11. 5 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouSuZaoLoadJob.java
  12. 17 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/KuaishouMatcostAccountMayMapper.java
  13. 0 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/MediaReportMapper.java
  14. 25 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/KuaishouMatcostAccountMayMapper.xml
  15. 0 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MediaReportMapper.xml
  16. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/ICpaBidWarningService.java
  17. 18 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IKuaishouMatcostAccountMayService.java
  18. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IProjectMemberService.java
  19. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BidWarningServiceImpl.java
  20. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CpaBidWarningServiceImpl.java
  21. 3 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/KuaiShouUploadServiceImpl.java
  22. 43 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/KuaishouMatcostAccountMayServiceImpl.java
  23. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectMemberServiceImpl.java
  24. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/impl/WpsFileServiceImpl.java
  25. 55 10
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  26. 30 0
      module-common/src/main/java/cn/com/ctop/common/module/annotation/AutoLog.java
  27. 42 0
      module-common/src/main/java/cn/com/ctop/common/module/annotation/Dict.java
  28. 25 0
      module-common/src/main/java/cn/com/ctop/common/module/annotation/PermissionData.java
  29. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/Project.java
  30. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/ProjectMapper.java
  31. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/BindAccountLoginMapper.xml
  32. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/ProjectMapper.xml
  33. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IProjectService.java
  34. 13 11
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/BindAccountLoginServiceImpl.java
  35. 4 4
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectServiceImpl.java
  36. 1 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/entity/PangolinReportAppHour.java
  37. 2 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/entity/PangolinReportBillMonth.java
  38. 1 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/entity/PangolinReportChannelDaily.java
  39. 13 13
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/xml/PangolinAppMapper.xml
  40. 19 19
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/xml/PangolinReportAppHourMapper.xml
  41. 4 4
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/xml/PangolinReportBillMonthMapper.xml
  42. 10 12
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/xml/PangolinReportChannelDailyMapper.xml
  43. 1 1
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinAppServiceImpl.java
  44. 22 11
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinCrawlerServiceImpl.java
  45. 0 1
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinReportAppHourServiceImpl.java
  46. 22 0
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceAccountBidJob.java
  47. 22 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAccountBidJob.java
  48. 7 1
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouSuZaoLoadJob.java
  49. 13 17
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  50. 0 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouVideoGet.java
  51. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoGetService.java
  52. 0 9
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoTimeService.java
  53. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  54. 3 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouMaterialUploadServiceImpl.java
  55. 49 67
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java
  56. 0 64
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoTimeServiceImpl.java
  57. 45 45
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  58. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/service/IKuaishouBidWarningService.java
  59. 161 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/service/impl/KuaishouBidWarningServiceImpl.java
  60. 5 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IBytedanceBidWarningService.java
  61. 168 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/BytedanceBidWarningServiceImpl.java

+ 0 - 1
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -32,7 +32,6 @@ public class DateUtils extends PropertyEditorSupport {
     private static final long SECOND_IN_MILLIS = 1000L;
 
 
-
     public static Date getNowDate() throws ParseException {
         SimpleDateFormat dsdf = new SimpleDateFormat("yyyy-MM-dd");
         String nowDate = getNowDate("yyyy-MM-dd");

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

@@ -1,7 +1,10 @@
 package org.jeecg.modules.ctop.controller;
 
 import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
+import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.ProjectMapper;
+import cn.com.ctop.common.module.service.IProjectService;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.*;
@@ -20,11 +23,8 @@ import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.ctop.entity.Advertiser;
-import org.jeecg.modules.ctop.entity.Project;
-import org.jeecg.modules.ctop.mapper.ProjectMapper;
 import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
 import org.jeecg.modules.ctop.service.IAdvertiserService;
-import org.jeecg.modules.ctop.service.IProjectService;
 import org.jeecg.modules.ctop.vo.SheetInfoVo;
 import org.jeecg.modules.excelutil.entity.KuaishouXxlEntity;
 import org.jeecg.modules.system.entity.SysCategory;

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

@@ -25,10 +25,8 @@ import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
-import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.service.IKuaiShouUploadService;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
-import org.jeecg.modules.ctop.service.IProjectService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -342,77 +340,75 @@ public class MaterialInfoController {
         Result<MaterialInfo> result = new Result<>();
         MaterialInfo materialInfoEntity = materialInfoService.getById(materialInfo.getId());
         if (materialInfoEntity == null) {
-            result.error500("未找到对应实体");
-        } else {
-            String url = materialInfo.getUrl();
-            if (!Check.isNull(url)) {
-                if (!url.contains(KuaishouInterfaceConstant.HTTPS_PREFIX)) {
-                    url = KuaishouInterfaceConstant.HTTPS_PREFIX + url;
-                }
-                materialInfo.setUrl(url);
+            return result.error500("未找到对应实体");
+        }
+        String url = materialInfo.getUrl();
+        if (!Check.isNull(url)) {
+            if (!url.contains(KuaishouInterfaceConstant.HTTPS_PREFIX)) {
+                url = KuaishouInterfaceConstant.HTTPS_PREFIX + url;
             }
+            materialInfo.setUrl(url);
+        }
 
-            //  修改素材库 相关联code
-            if (!Check.isNull(materialInfo.getCode())) {
-                String code = materialInfoEntity.getCode();
-                if (!Check.isNull(code)) {
-                    MaterialTag updateMaterialTag = new MaterialTag();
-                    updateMaterialTag.setMaterialId(materialInfo.getCode());
-                    QueryWrapper<MaterialTag> tagQueryWrapper = new QueryWrapper<>();
-                    tagQueryWrapper.eq("material_id", code);
-                    materialTagService.update(updateMaterialTag, tagQueryWrapper);
-                    MaterialParameter updateParameter = new MaterialParameter();
-                    updateParameter.setMaterialId(materialInfo.getCode());
-                    QueryWrapper<MaterialParameter> parameterQueryWrapper = new QueryWrapper<>();
-                    parameterQueryWrapper.eq("material_id", code);
-                    materialParameterService.update(updateParameter, parameterQueryWrapper);
-                    MaterialAscription updateMaterialAscription = new MaterialAscription();
-                    updateMaterialAscription.setMaterialId(materialInfo.getCode());
-                    QueryWrapper<MaterialAscription> ascriptionQueryWrapper = new QueryWrapper<>();
-                    ascriptionQueryWrapper.eq("material_id", code);
-                    materialAscriptionService.update(updateMaterialAscription, ascriptionQueryWrapper);
-                }
+        //  修改素材库 相关联code
+        if (!Check.isNull(materialInfo.getCode())) {
+            String code = materialInfoEntity.getCode();
+            if (!Check.isNull(code)) {
+                MaterialTag updateMaterialTag = new MaterialTag();
+                updateMaterialTag.setMaterialId(materialInfo.getCode());
+                QueryWrapper<MaterialTag> tagQueryWrapper = new QueryWrapper<>();
+                tagQueryWrapper.eq("material_id", code);
+                materialTagService.update(updateMaterialTag, tagQueryWrapper);
+                MaterialParameter updateParameter = new MaterialParameter();
+                updateParameter.setMaterialId(materialInfo.getCode());
+                QueryWrapper<MaterialParameter> parameterQueryWrapper = new QueryWrapper<>();
+                parameterQueryWrapper.eq("material_id", code);
+                materialParameterService.update(updateParameter, parameterQueryWrapper);
+                MaterialAscription updateMaterialAscription = new MaterialAscription();
+                updateMaterialAscription.setMaterialId(materialInfo.getCode());
+                QueryWrapper<MaterialAscription> ascriptionQueryWrapper = new QueryWrapper<>();
+                ascriptionQueryWrapper.eq("material_id", code);
+                materialAscriptionService.update(updateMaterialAscription, ascriptionQueryWrapper);
             }
+        }
 
-            //  审核通过自动同步到到媒体后台
-           /* Long projectId = materialInfoEntity.getProjectId();
-            Project project = projectService.getById(projectId);
-            if (!Check.isNull(projectId)) {
-                if ("2".equals(project.getMediaId())) {
-                    if (!Check.isNull(materialInfo.getStatus())) {
-                        Integer status = materialInfo.getStatus();
-                        if (status == 1) {
-                            Thread thread = new Thread() {
-                                @Override
-                                public void run() {
-                                    log.info("开始自动同步素材,code:{}", materialInfoEntity.getCode());
-                                    uploadService.upload(materialInfoEntity);
-                                }
-                            };
-                            thread.start();
-                        }
+        //  审核通过自动同步到到媒体后台
+       /* Long projectId = materialInfoEntity.getProjectId();
+        Project project = projectService.getById(projectId);
+        if (!Check.isNull(projectId)) {
+            if ("2".equals(project.getMediaId())) {
+                if (!Check.isNull(materialInfo.getStatus())) {
+                    Integer status = materialInfo.getStatus();
+                    if (status == 1) {
+                        Thread thread = new Thread() {
+                            @Override
+                            public void run() {
+                                log.info("开始自动同步素材,code:{}", materialInfoEntity.getCode());
+                                uploadService.upload(materialInfoEntity);
+                            }
+                        };
+                        thread.start();
                     }
                 }
-
-            }*/
-
-            boolean ok = materialInfoService.updateById(materialInfo);
-            if (ok) {
-                result.success("修改成功!");
             }
 
-            Integer status = materialInfo.getStatus();
-            // 如果状态为2 审核拒绝 给上传人发送消息
-            if (status == 2) {
-                Project project = projectService.getById(materialInfoEntity.getProjectId());
-                String text = messageTemplate.getMaterialRejectTemplate(project.getProjectName(), materialInfoEntity.getMaterialName(), materialInfo.getRefuseReason());
-                sendMessageService.sendMessage(materialInfoEntity.getUserId(), text);
+        }*/
 
-                String feishuText = messageTemplate.getFeishuMaterialRejectTemplate(project.getProjectName(), materialInfoEntity.getMaterialName(), materialInfo.getRefuseReason());
-                sendMessageService.sendFeishuMessage(materialInfoEntity.getUserId(), feishuText);
-            }
+        boolean ok = materialInfoService.updateById(materialInfo);
+        if (ok) {
+            result.success("修改成功!");
         }
 
+        Integer status = materialInfo.getStatus();
+        // 如果状态为2 审核拒绝 给上传人发送消息
+        if (status == 2) {
+            Project project = projectService.getById(materialInfoEntity.getProjectId());
+            String text = messageTemplate.getMaterialRejectTemplate(project.getProjectName(), materialInfoEntity.getMaterialName(), materialInfo.getRefuseReason());
+            sendMessageService.sendMessage(materialInfoEntity.getUserId(), text);
+
+            String feishuText = messageTemplate.getFeishuMaterialRejectTemplate(project.getProjectName(), materialInfoEntity.getMaterialName(), materialInfo.getRefuseReason());
+            sendMessageService.sendFeishuMessage(materialInfoEntity.getUserId(), feishuText);
+        }
         return result;
 
     }

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

@@ -1,7 +1,10 @@
 package org.jeecg.modules.ctop.controller;
 
 import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
+import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.ProjectMapper;
+import cn.com.ctop.common.module.service.IProjectService;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
@@ -17,14 +20,11 @@ import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.ctop.entity.Advertiser;
-import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.jeecg.modules.ctop.entity.TransferAccount;
-import org.jeecg.modules.ctop.mapper.ProjectMapper;
 import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
 import org.jeecg.modules.ctop.service.IAdvertiserService;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
-import org.jeecg.modules.ctop.service.IProjectService;
 import org.jeecg.modules.ctop.service.ITransferAccountService;
 import org.jeecg.modules.system.entity.SysCategory;
 import org.jeecg.modules.system.entity.SysUser;
@@ -173,6 +173,12 @@ public class ProjectController {
                                                 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                 HttpServletRequest req) {
         Result<IPage<Project>> result = new Result<>();
+        String advertiserName = project.getAdvertiserName();
+        project.setAdvertiserName(null);
+        String projectName = project.getProjectName();
+        project.setProjectName(null);
+
+
         String industryId = project.getIndustryId();
         project.setIndustryId(null);
         QueryWrapper<Project> queryWrapper = QueryGenerator.initQueryWrapper(project, req.getParameterMap());
@@ -183,12 +189,19 @@ public class ProjectController {
             queryWrapper.eq("user_id", sysUser.getId());
             queryWrapper.orderByDesc("create_time");
         }
-        if(null!=industryId&&!"".equals(industryId.trim())){
+        if (null != industryId && !"".equals(industryId.trim())) {
             SysCategory category = sysCategoryService.getById(industryId);
-            if(null!=category){
-                queryWrapper.likeRight("industry_code",category.getCode());
+            if (null != category) {
+                queryWrapper.likeRight("industry_code", category.getCode());
             }
         }
+        if (!Check.isNull(advertiserName)) {
+            queryWrapper.like("advertiser_name", advertiserName);
+
+        }
+        if (!Check.isNull(projectName)) {
+            queryWrapper.like("project_name", projectName);
+        }
         IPage<Project> pageList = projectService.page(page, queryWrapper);
         result.setSuccess(true);
         result.setResult(pageList);
@@ -217,7 +230,7 @@ public class ProjectController {
                 project.setCompanyId(advertiser.getCompanyId());
             }
             SysCategory category = sysCategoryService.getById(project.getIndustryId());
-            if(null!=category){
+            if (null != category) {
                 project.setIndustryCode(category.getCode());
                 project.setIndustryId(category.getId());
             }
@@ -283,7 +296,7 @@ public class ProjectController {
         }
 
         SysCategory category = sysCategoryService.getById(project.getIndustryId());
-        if(null!=category){
+        if (null != category) {
             project.setIndustryCode(category.getCode());
             project.setIndustryId(category.getId());
         }
@@ -308,7 +321,7 @@ public class ProjectController {
             userAllocationQueryWrapper.eq("project_id", project.getId());
             UserAllocation updateUserAllocation = new UserAllocation();
             updateUserAllocation.setProjectName(project.getProjectName());
-           // updateUserAllocation.setMediaId(project.getMediaId());
+            // updateUserAllocation.setMediaId(project.getMediaId());
             userAllocationService.update(updateUserAllocation, userAllocationQueryWrapper);
 
             if (ok) {

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

@@ -1,8 +1,9 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.common.module.entity.Project;
+import cn.com.ctop.common.module.service.IProjectService;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.utils.Check;
-import cn.com.ctop.common.module.utils.CtopAdConstant;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -16,15 +17,12 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
-import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
-import org.jeecg.modules.ctop.service.IProjectService;
 import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.annotation.Cacheable;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;

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

@@ -7,7 +7,6 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
-import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
@@ -97,72 +96,38 @@ public class TestController {
     private IMaterialCutFrameService cutFrameService;
     @Autowired
     IKuaiShouVideoGetService videoGetService;
-    @Autowired
-    private IKuaiShouVideoTimeService timeService;
-
 
-    @GetMapping(value = "/getVideoTime")
-    public void getVideoTime() throws InterruptedException {
-        Thread thread = new Thread() {
-            @Override
-            public void run() {
-                QueryWrapper<KuaiShouVideoGet> queryWrapper = new QueryWrapper<>();
-                queryWrapper.eq("channel_type", 0);
-                List<KuaiShouVideoGet> list = videoGetService.list(queryWrapper);
-                for (KuaiShouVideoGet video : list) {
-                    videoService.submit(new Runnable() {
-                        @Override
-                        public void run() {
-                            Date date = timeService.getVideoTime(video.getPhotoId(), video.getAccountId());
-                            if (!Check.isNull(date)) {
-                                video.setUploadDate(date);
-                                videoGetService.updateById(video);
-                            }
 
-                            try {
-                                Thread.sleep(1000);
-                            } catch (InterruptedException e) {
-                                e.printStackTrace();
-                            }
-                        }
-                    });
-                }
-            }
-        };
-        thread.start();
+    @GetMapping(value = "/getSuZhao")
+    public void getSuZhao() throws JobExecutionException {
 
-    }
+        try {
 
+            //1:查询当日数据
+            QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("media_id", 2);
+            queryWrapper.orderByDesc("create_time");
+            List<CtopOauthToken> tokens = tokenService.list(queryWrapper);
+            if (null == tokens || tokens.size() <= 0) {
+                log.info("定时获取快手数据异常:未获取到可用的token");
+                return;
+            }
 
-    @GetMapping(value = "/getSuZhao")
-    public void getSuZhao() throws InterruptedException {
-        Thread thread = new Thread() {
-            @Override
-            public void run() {
-                QueryWrapper<KuaiShouVideoGet> queryWrapper = new QueryWrapper<>();
-                queryWrapper.eq("channel_type", 1);
-                List<KuaiShouVideoGet> list = videoGetService.list(queryWrapper);
-                for (KuaiShouVideoGet video : list) {
-                    suzhaoService.submit(new Runnable() {
-                        @Override
-                        public void run() {
-                            Date date = timeService.getVideoTime(video.getPhotoId(), video.getAccountId());
-                            if (!Check.isNull(date)) {
-                                video.setUploadDate(date);
-                                videoGetService.updateById(video);
-                            }
+            executorService = Executors.newFixedThreadPool(8);
+            tokens.forEach(token -> {
+                executorService.submit(new Runnable() {
+                    @Override
+                    public void run() {
+                        //1: 获取广告主信息数据
+                        log.info("获取素造素材:accountId:{}", token.getAccountId());
+                        kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, null, null);
+                    }
+                });
+            });
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
 
-                            try {
-                                Thread.sleep(1000);
-                            } catch (InterruptedException e) {
-                                e.printStackTrace();
-                            }
-                        }
-                    });
-                }
-            }
-        };
-        thread.start();
 
     }
 
@@ -223,7 +188,7 @@ public class TestController {
                             @Override
                             public void run() {
                                 try {
-                                    kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1);
+                                    kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, null, null);
                                     String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
                                     String videoEndDate = DateUtils.addDay(nowDate, -180);
                                     SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
@@ -268,7 +233,7 @@ public class TestController {
                     tokenQueryWrapper.eq("account_id", accountId);
                     CtopOauthToken one = tokenService.getOne(tokenQueryWrapper);
                     try {
-                        kuaishouInterfaceService.getSuZaoList(one.getAccessToken(), one.getAccountId(), 1);
+                        kuaishouInterfaceService.getSuZaoList(one.getAccessToken(), one.getAccountId(), 1, null, null);
                         String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
                         String videoEndDate = DateUtils.addDay(nowDate, -180);
                         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
@@ -474,6 +439,28 @@ public class TestController {
     }
 
 
+    @GetMapping(value = "/getHistoryDataByAccountId")
+    public String getHistoryDataByAccountId(Long accountId) {
+        Result<String> result = new Result<>();
+        try {
+            String endDateStr = DateUtils.getDate("yyyy-MM-dd");
+            String startDate = DateUtils.addMonth(endDateStr, -6);
+            QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
+            tokenQueryWrapper.eq("media_id", 2);
+            tokenQueryWrapper.eq("account_id", accountId);
+            CtopOauthToken ctopOauthTokens = oauthTokenMapper.selectOne(tokenQueryWrapper);
+            if (!Check.isNull(ctopOauthTokens)) {
+                historyReportTaskService.createTask(ctopOauthTokens.getAccountId(), ctopOauthTokens.getAccessToken(), startDate, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
+
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return "success";
+    }
+
+
     @GetMapping(value = "/getTaskList")
     public String getTaskList() {
         Result<String> result = new Result<>();

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

@@ -1,8 +1,10 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.MailLogMapper;
 import cn.com.ctop.common.module.service.IMailLogService;
+import cn.com.ctop.common.module.service.IProjectService;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
@@ -13,11 +15,9 @@ import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
-import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.jeecg.modules.ctop.entity.TransferAccount;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
-import org.jeecg.modules.ctop.service.IProjectService;
 import org.jeecg.modules.ctop.service.ITransferAccountService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;

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

@@ -1,8 +1,10 @@
 package org.jeecg.modules.ctop.controller;
 
 import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
+import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
+import cn.com.ctop.common.module.service.IProjectService;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
@@ -18,11 +20,9 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
-import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
-import org.jeecg.modules.ctop.service.IProjectService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 

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

@@ -0,0 +1,81 @@
+package org.jeecg.modules.ctop.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import java.math.BigDecimal;
+
+@TableName("kuaishou_matcost_account_jun_12_18")
+public class KuaishouMatcostAccountMay {
+    private BigDecimal cost;
+    private Long accountId;
+    private String videoCode;
+    private String channelType;
+    private String url;
+    private String userName;
+    private String minDate;
+    private String endDate;
+
+    public BigDecimal getCost() {
+        return cost;
+    }
+
+    public void setCost(BigDecimal cost) {
+        this.cost = cost;
+    }
+
+    public Long getAccountId() {
+        return accountId;
+    }
+
+    public void setAccountId(Long accountId) {
+        this.accountId = accountId;
+    }
+
+    public String getVideoCode() {
+        return videoCode;
+    }
+
+    public void setVideoCode(String videoCode) {
+        this.videoCode = videoCode;
+    }
+
+    public String getChannelType() {
+        return channelType;
+    }
+
+    public void setChannelType(String channelType) {
+        this.channelType = channelType;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getMinDate() {
+        return minDate;
+    }
+
+    public void setMinDate(String minDate) {
+        this.minDate = minDate;
+    }
+
+    public String getEndDate() {
+        return endDate;
+    }
+
+    public void setEndDate(String endDate) {
+        this.endDate = endDate;
+    }
+}

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

@@ -1,11 +1,11 @@
 package org.jeecg.modules.ctop.job;
 
+import cn.com.ctop.common.module.entity.Project;
+import cn.com.ctop.common.module.service.IProjectService;
 import cn.com.ctop.common.module.utils.BigDecimalUtil;
 import cn.com.ctop.common.module.utils.Check;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.service.ICpaBidWarningService;
-import org.jeecg.modules.ctop.service.IProjectService;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;

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

@@ -2,9 +2,9 @@ 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;
@@ -35,7 +35,10 @@ public class KuaishouSuZaoLoadJob implements Job {
                         @Override
                         public void run() {
                             try {
-                                kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1);
+                                String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                                String endDate = DateUtils.getAnotherDay("yyyy-mm-dd", nowDate, 1);
+                                String startDate = DateUtils.getAnotherDay("yyyy-mm-dd", nowDate, -1);
+                                kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startDate, endDate);
                             } catch (Exception e) {
                                 e.printStackTrace();
                             } finally {

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

@@ -0,0 +1,17 @@
+package org.jeecg.modules.ctop.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.ctop.entity.KuaishouMatcostAccountMay;
+
+import java.math.BigDecimal;
+
+public interface KuaishouMatcostAccountMayMapper extends BaseMapper<KuaishouMatcostAccountMay> {
+    String getMinDateByCode(@Param(value = "code") String code);
+
+    void updateByCode(@Param(value = "code")String code, @Param(value = "minDate")String minDate);
+
+    void updateCostByCode(@Param(value = "code")String code, @Param(value = "cost")BigDecimal cost);
+
+    BigDecimal getCostByParams(@Param(value = "code")String videoCode, @Param(value = "startDate")String minDate, @Param(value = "endDate")String endDate);
+}

jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MediaReportMapper.java → jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/MediaReportMapper.java


+ 25 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/KuaishouMatcostAccountMayMapper.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.ctop.mapper.KuaishouMatcostAccountMayMapper">
+    <update id="updateByCode">
+        update kuaishou_matcost_account_jun_12_18 set min_date = #{minDate}
+        where video_code = #{code}
+    </update>
+    <update id="updateCostByCode">
+        update kuaishou_matcost_account_jun_12_18 set twcost = #{cost}
+        where video_code = #{code}
+    </update>
+    <select id="getMinDateByCode" resultType="java.lang.String">
+    select substr(min(tmp.stat_date),1,10) from kuaishou_video_new_v2 video
+        left join tmp_kuaishou_creative_statdate2 tmp on tmp.photo_id = video.photo_id
+        where video.video_code = #{code}
+    </select>
+    <select id="getCostByParams" resultType="java.math.BigDecimal">
+        SELECT
+            sum(report.charge)
+        FROM
+        tmp_kuaishou_creative_report report
+        WHERE
+        report.video_code =#{code} and report.state_date &gt;= #{startDate} and report.state_date &lt; #{endDate};
+    </select>
+</mapper>

jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/MediaReportMapper.xml → jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MediaReportMapper.xml


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

@@ -1,6 +1,6 @@
 package org.jeecg.modules.ctop.service;
 
-import org.jeecg.modules.ctop.entity.Project;
+import cn.com.ctop.common.module.entity.Project;
 
 public interface ICpaBidWarningService {
     void cpaBidWarning(Project project);

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

@@ -0,0 +1,18 @@
+package org.jeecg.modules.ctop.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.ctop.entity.KuaishouMatcostAccountMay;
+
+import java.math.BigDecimal;
+
+public interface IKuaishouMatcostAccountMayService extends IService<KuaishouMatcostAccountMay> {
+    KuaishouMatcostAccountMay getOne();
+
+    String getMinDate(String code);
+
+    void updateByCode(String code,String minDate);
+
+    void updateCostByCode(String code, BigDecimal cost);
+
+    BigDecimal getCostByParams(KuaishouMatcostAccountMay matcostAccountMay);
+}

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

@@ -1,7 +1,7 @@
 package org.jeecg.modules.ctop.service;
 
+import cn.com.ctop.common.module.entity.Project;
 import com.baomidou.mybatisplus.extension.service.IService;
-import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.jeecg.modules.system.entity.SysUser;
 

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

@@ -1,8 +1,10 @@
 package org.jeecg.modules.ctop.service.impl;
 
 import cn.com.ctop.common.module.entity.MailLog;
+import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.MailLogMapper;
+import cn.com.ctop.common.module.mapper.ProjectMapper;
 import cn.com.ctop.common.module.service.ICorpFeishuUserService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.BigDecimalUtil;
@@ -17,8 +19,6 @@ import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
-import org.jeecg.modules.ctop.entity.Project;
-import org.jeecg.modules.ctop.mapper.ProjectMapper;
 import org.jeecg.modules.ctop.service.IBidWarningService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;

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

@@ -1,6 +1,7 @@
 package org.jeecg.modules.ctop.service.impl;
 
 import cn.com.ctop.common.module.entity.MailLog;
+import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.MailLogMapper;
 import cn.com.ctop.common.module.service.ICorpFeishuUserService;
@@ -16,7 +17,6 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
-import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.service.ICpaBidWarningService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;

+ 3 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/KuaiShouUploadServiceImpl.java

@@ -18,6 +18,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.http.ParseException;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.ctop.service.IKuaiShouUploadService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -130,8 +131,8 @@ public class KuaiShouUploadServiceImpl implements IKuaiShouUploadService {
                                             videoGet.setAccountId(accountId);
                                             videoGet.setId(accountId + photoId);
                                             videoGet.setUrl(materialInfo.getUrl());
-
-
+                                            videoGet.setCoverUrl(materialInfo.getUrl()+ "?x-oss-process=video/snapshot,t_00000,m_fast");
+                                            videoGet.setStatDate(DateUtils.getNowDate());
                                             videoGet.setMaterialType(finalType);
                                             videoGet.setPhotoId(photoId);
                                             videoGet.setSignature(signature);

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

@@ -0,0 +1,43 @@
+package org.jeecg.modules.ctop.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.ctop.entity.KuaishouMatcostAccountMay;
+import org.jeecg.modules.ctop.mapper.KuaishouMatcostAccountMayMapper;
+import org.jeecg.modules.ctop.service.IKuaishouMatcostAccountMayService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+
+@Service
+public class KuaishouMatcostAccountMayServiceImpl extends ServiceImpl<KuaishouMatcostAccountMayMapper, KuaishouMatcostAccountMay> implements IKuaishouMatcostAccountMayService {
+    @Autowired
+    private KuaishouMatcostAccountMayMapper kuaishouMatcostAccountMayMapper;
+    @Override
+    public KuaishouMatcostAccountMay getOne() {
+        QueryWrapper<KuaishouMatcostAccountMay>queryWrapper = new QueryWrapper<>();
+        queryWrapper.isNull("twcost").isNotNull("end_date").last("limit 1");
+        return this.getOne(queryWrapper);
+    }
+
+    @Override
+    public String getMinDate(String code){
+        return kuaishouMatcostAccountMayMapper.getMinDateByCode(code);
+    }
+
+    @Override
+    public void updateByCode(String code,String minDate) {
+        kuaishouMatcostAccountMayMapper.updateByCode(code,minDate);
+    }
+
+    @Override
+    public void updateCostByCode(String code, BigDecimal cost) {
+        kuaishouMatcostAccountMayMapper.updateCostByCode(code,cost);
+    }
+
+    @Override
+    public BigDecimal getCostByParams(KuaishouMatcostAccountMay matcostAccountMay) {
+        return kuaishouMatcostAccountMayMapper.getCostByParams(matcostAccountMay.getVideoCode(),matcostAccountMay.getMinDate(),matcostAccountMay.getEndDate());
+    }
+}

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

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.service.impl;
 
+import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.ISysRoleService;
@@ -9,7 +10,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
-import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
 import org.jeecg.modules.ctop.service.IProjectMemberService;

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/impl/WpsFileServiceImpl.java

@@ -1,6 +1,8 @@
 package org.jeecg.modules.wps.service.impl;
 
+import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.file.FileUtil;
+import cn.com.ctop.common.module.service.IProjectService;
 import cn.com.ctop.common.module.utils.CosUtils;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
@@ -11,8 +13,6 @@ import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
-import org.jeecg.modules.ctop.entity.Project;
-import org.jeecg.modules.ctop.service.IProjectService;
 import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.jeecg.modules.wps.config.Context;

+ 55 - 10
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -5,20 +5,25 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
-import cn.com.ctop.crawler.modules.pangolin.entity.PangolinApp;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinAppService;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinCrawlerService;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinLoginService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
+import cn.com.ctop.toutiao.modules.report.service.IReportService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.ctop.entity.KuaishouMatcostAccountMay;
+import org.jeecg.modules.ctop.service.IKuaishouMatcostAccountMayService;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
+import java.math.BigDecimal;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
@@ -33,10 +38,23 @@ public class SampleTest {
     private ICtopOauthTokenService oauthTokenService;
     @Autowired
     private IByteDanceAdvertiserDataService advertiserDataService;
+    @Autowired
+    private IReportService reportService;
     @Test
     public void testOceanEngineJob() {
-        CtopOauthToken token = oauthTokenService.getTokenByAccountId(1629785592929294L);
-        advertiserDataService.getMaterialList(token);
+        CtopOauthToken token1 = oauthTokenService.getTokenByAccountId(1670725854459911L);
+        CtopOauthToken token2 = oauthTokenService.getTokenByAccountId(1670827164313607L);
+        CtopOauthToken token3 = oauthTokenService.getTokenByAccountId(1670801593147405L);
+        CtopOauthToken token4 = oauthTokenService.getTokenByAccountId(1670827163327501L);
+        CtopOauthToken token5 = oauthTokenService.getTokenByAccountId(1670827163853832L);
+        for(int i=0;i<100;i++){
+            Date startDate = DateUtils.addDay(new Date(),-i);
+            reportService.getAdvertiserReport(token1,startDate,startDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+            reportService.getAdvertiserReport(token2,startDate,startDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+            reportService.getAdvertiserReport(token3,startDate,startDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+            reportService.getAdvertiserReport(token4,startDate,startDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+            reportService.getAdvertiserReport(token5,startDate,startDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+        }
     }
 
     @Autowired
@@ -114,6 +132,33 @@ public class SampleTest {
         }
     }
 
+    @Autowired
+    private IKuaishouMatcostAccountMayService matcostAccountMayService;
+    @Test
+    public void testLoadMinDate(){
+        loadData();
+    }
+
+    private void loadData(){
+        KuaishouMatcostAccountMay matcostAccountMay = matcostAccountMayService.getOne();
+        if(null!=matcostAccountMay){
+            BigDecimal cost = matcostAccountMayService.getCostByParams(matcostAccountMay);
+            if(null!=cost&&!cost.toString().trim().equals("")){
+                matcostAccountMayService.updateCostByCode(matcostAccountMay.getVideoCode(),cost);
+            }else{
+                matcostAccountMayService.updateCostByCode(matcostAccountMay.getVideoCode(),BigDecimal.ZERO);
+            }
+//            String minDate = matcostAccountMayService.getMinDate(matcostAccountMay.getVideoCode());
+//            if(null == minDate||minDate.trim().equals("")){
+//                matcostAccountMayService.updateByCode(matcostAccountMay.getVideoCode(),"-");
+//            }else{
+//                matcostAccountMayService.updateByCode(matcostAccountMay.getVideoCode(),minDate);
+//            }
+
+            loadData();
+        }
+    }
+
     @Test
     public void testPangolinData() {
         QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
@@ -123,15 +168,15 @@ public class SampleTest {
         List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
         if (list != null && !list.isEmpty()) {
             for (BindAccountLogin bindAccountLogin : list) {
-//                pangolinCrawlerService.getChannelList(bindAccountLogin);
+                pangolinCrawlerService.getChannelList(bindAccountLogin);
 //                pangolinCrawlerService.getActivationList(bindAccountLogin, DateUtils.getNowDate("yyyy-MM-dd"), 1);
 //                pangolinCrawlerService.getCheckList(bindAccountLogin);
-                QueryWrapper<PangolinApp> queryWrapper1 = new QueryWrapper<>();
-                queryWrapper1.eq("account_name", bindAccountLogin.getAccountName());
-                List<PangolinApp> appList = pangolinAppService.list(queryWrapper1);
-                if (appList != null && !appList.isEmpty()) {
-                    appList.forEach(pangolinApp -> pangolinCrawlerService.getRealTimeList(bindAccountLogin, pangolinApp.getAppId()));
-                }
+//                QueryWrapper<PangolinApp> queryWrapper1 = new QueryWrapper<>();
+//                queryWrapper1.eq("account_name", bindAccountLogin.getAccountName());
+//                List<PangolinApp> appList = pangolinAppService.list(queryWrapper1);
+//                if (appList != null && !appList.isEmpty()) {
+//                    appList.forEach(pangolinApp -> pangolinCrawlerService.getRealTimeList(bindAccountLogin, pangolinApp.getAppId()));
+//                }
             }
         }
     }

+ 30 - 0
module-common/src/main/java/cn/com/ctop/common/module/annotation/AutoLog.java

@@ -0,0 +1,30 @@
+package cn.com.ctop.common.module.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * 系统日志注解
+ *
+ * @Author scott
+ * @email jeecgos@163.com
+ * @Date 2019年1月14日
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface AutoLog {
+
+	/**
+	 * 日志内容
+	 *
+	 * @return
+	 */
+	String value() default "";
+
+	/**
+	 * 日志类型
+	 *
+	 * @return 0:操作日志;1:登录日志;2:定时任务;
+	 */
+	int logType() default 2;
+}

+ 42 - 0
module-common/src/main/java/cn/com/ctop/common/module/annotation/Dict.java

@@ -0,0 +1,42 @@
+package cn.com.ctop.common.module.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ *  类描述:  字典注解
+ * 作    者: dangzhenghui
+ * 日    期: 2019年03月17日-下午9:37:16
+ */
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Dict {
+    /**
+     * 方法描述:  数据code
+     * 作    者: dangzhenghui
+     * 日    期: 2019年03月17日-下午9:37:16
+     *
+     * @return 返回类型: String
+     */
+    String dicCode();
+
+    /**
+     * 方法描述:  数据Text
+     * 作    者: dangzhenghui
+     * 日    期: 2019年03月17日-下午9:37:16
+     *
+     * @return 返回类型: String
+     */
+    String dicText() default "";
+
+    /**
+     * 方法描述: 数据字典表
+     * 作    者: dangzhenghui
+     * 日    期: 2019年03月17日-下午9:37:16
+     *
+     * @return 返回类型: String
+     */
+    String dictTable() default "";
+}

+ 25 - 0
module-common/src/main/java/cn/com/ctop/common/module/annotation/PermissionData.java

@@ -0,0 +1,25 @@
+package cn.com.ctop.common.module.annotation;
+
+import java.lang.annotation.*;
+
+/**
+  *  数据权限注解
+ * @Author taoyan
+ * @Date 2019年4月11日
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE,ElementType.METHOD})
+@Documented
+public @interface PermissionData {
+	/**
+	 * 暂时没用
+	 * @return
+	 */
+	String value() default "";
+
+
+	/**
+	 * 配置菜单的组件路径,用于数据权限
+	 */
+	String pageComponent() default "";
+}

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/Project.java

@@ -1,5 +1,6 @@
-package org.jeecg.modules.ctop.entity;
+package cn.com.ctop.common.module.entity;
 
+import cn.com.ctop.common.module.annotation.Dict;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
@@ -10,7 +11,6 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import org.jeecg.common.aspect.annotation.Dict;
 import org.jeecgframework.poi.excel.annotation.Excel;
 import org.springframework.format.annotation.DateTimeFormat;
 

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/ProjectMapper.java

@@ -1,7 +1,7 @@
-package org.jeecg.modules.ctop.mapper;
+package cn.com.ctop.common.module.mapper;
 
+import cn.com.ctop.common.module.entity.Project;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import org.jeecg.modules.ctop.entity.Project;
 
 /**
  * 项目

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

@@ -25,7 +25,7 @@
         from
         ctop_bind_account_login login
         left join ctop_project project on login.project_id = project.id
-        where 1=1
+        where login.status = 1
         <if test="userId!=null">
             and login.user_id = #{userId}
         </if>

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/ProjectMapper.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.jeecg.modules.ctop.mapper.ProjectMapper">
+<mapper namespace="cn.com.ctop.common.module.mapper.ProjectMapper">
 
-</mapper>
+</mapper>

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IProjectService.java

@@ -1,7 +1,7 @@
-package org.jeecg.modules.ctop.service;
+package cn.com.ctop.common.module.service;
 
+import cn.com.ctop.common.module.entity.Project;
 import com.baomidou.mybatisplus.extension.service.IService;
-import org.jeecg.modules.ctop.entity.Project;
 
 /**
  * 项目

+ 13 - 11
module-common/src/main/java/cn/com/ctop/common/module/service/impl/BindAccountLoginServiceImpl.java

@@ -34,6 +34,8 @@ import java.util.Map;
 @Slf4j
 @Service
 public class BindAccountLoginServiceImpl extends ServiceImpl<BindAccountLoginMapper, BindAccountLogin> implements IBindAccountLoginService {
+    @Autowired
+    private BindAccountLoginMapper bindAccountLoginMapper;
     @Override
     public boolean checkLogin(BindAccountLogin bindAccountLogin, String response) {
         if (response.contains("<html>")) {
@@ -43,6 +45,7 @@ public class BindAccountLoginServiceImpl extends ServiceImpl<BindAccountLoginMap
         }
         return true;
     }
+
     @Override
     public BindAccountLogin selectByAccountId(String accountId) {
         QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
@@ -68,21 +71,20 @@ public class BindAccountLoginServiceImpl extends ServiceImpl<BindAccountLoginMap
 
     @Override
     public List<PangolinProjectVO> getProjectByParams(String userId, String loginType) {
-        List<PangolinProjectVO> projectVOS =  bindAccountLoginMapper.getProjectByParams(userId,loginType,null);
-        List<PangolinProjectVO> setProjectVOS = new ArrayList<>();
-        if(null!=projectVOS&&!projectVOS.isEmpty()){
-            projectVOS.forEach(pangolinProjectVO -> {
-                List<PangolinAccountVO>accountVOS = bindAccountLoginMapper.getAccountByParams(userId,loginType,pangolinProjectVO.getProjectId());
-                pangolinProjectVO.setAccountVOList(accountVOS);
-                setProjectVOS.add(pangolinProjectVO);
+        List<PangolinProjectVO> projectVos =  bindAccountLoginMapper.getProjectByParams(userId,loginType,null);
+        List<PangolinProjectVO> setProjectVos = new ArrayList<>();
+        if(null!=projectVos&&!projectVos.isEmpty()){
+            projectVos.forEach(pangolinProjectVO -> {
+                List<PangolinAccountVO>accountVos = bindAccountLoginMapper.getAccountByParams(userId,loginType,pangolinProjectVO.getProjectId());
+                if(null!=accountVos&&!accountVos.isEmpty()){
+                    pangolinProjectVO.setAccountVOList(accountVos);
+                    setProjectVos.add(pangolinProjectVO);
+                }
             });
         }
-        return setProjectVOS;
+        return setProjectVos;
     }
 
-    @Autowired
-    private BindAccountLoginMapper bindAccountLoginMapper;
-
     @Override
     public Map<String, Object> getListByUserId(String userId) {
         Map<String,Object>result = new HashMap<>();

+ 4 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectServiceImpl.java

@@ -1,9 +1,9 @@
-package org.jeecg.modules.ctop.service.impl;
+package cn.com.ctop.common.module.service.impl;
 
+import cn.com.ctop.common.module.entity.Project;
+import cn.com.ctop.common.module.mapper.ProjectMapper;
+import cn.com.ctop.common.module.service.IProjectService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.jeecg.modules.ctop.entity.Project;
-import org.jeecg.modules.ctop.mapper.ProjectMapper;
-import org.jeecg.modules.ctop.service.IProjectService;
 import org.springframework.stereotype.Service;
 
 /**

+ 1 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/entity/PangolinReportAppHour.java

@@ -28,6 +28,7 @@ public class PangolinReportAppHour {
      * 类型
      */
     private String type;
+    private String accountName;
     /**
      * 数字
      */

+ 2 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/entity/PangolinReportBillMonth.java

@@ -44,4 +44,6 @@ public class PangolinReportBillMonth {
      * 账户质量分
      */
     private BigDecimal accountQualityScore;
+
+    private String accountName;
 }

+ 1 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/entity/PangolinReportChannelDaily.java

@@ -24,6 +24,7 @@ public class PangolinReportChannelDaily {
      * 应用名称
      */
     private String appName;
+    private String accountName;
     /**
      * 操作系统
      */

+ 13 - 13
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/xml/PangolinAppMapper.xml

@@ -2,28 +2,28 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.crawler.modules.pangolin.mapper.PangolinAppMapper">
     <select id="getListByParams" resultType="cn.com.ctop.crawler.modules.pangolin.entity.PangolinApp">
-        select app.*
+        select distinct app.app_id as 'id',name
             from ctop_pangolin_app app
         left join ctop_bind_account_login login on login.account_name = app.account_name
         where
-        1=1
+        login.status = 1
         <if test="userId!=null">
             and login.user_id = #{userId}
         </if>
         <if test="accountNames!=null or projectIds!=null">
             and  ( 1=0
-              <if test="accountNames!=null">
-                  or login.account_name in
-                  <foreach item="item" index="index" collection="accountNames" open="(" separator="," close=")">
+                <if test="accountNames!=null">
+                    or login.account_name in
+                    <foreach item="item" index="index" collection="accountNames" open="(" separator="," close=")">
                       #{item}
-                  </foreach>
-              </if>
-            <if test="projectIds!=null">
-                or login.project_id in
-                <foreach item="item" index="index" collection="projectIds" open="(" separator="," close=")">
-                    #{item}
-                </foreach>
-            </if>
+                    </foreach>
+                </if>
+                <if test="projectIds!=null">
+                    or login.project_id in
+                    <foreach item="item" index="index" collection="projectIds" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
               )
         </if>
     </select>

+ 19 - 19
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/xml/PangolinReportAppHourMapper.xml

@@ -15,12 +15,12 @@
             hour
        from (select num,date,hour
 from ctop_pangolin_report_app_hour appHourActive
-         left join ctop_pangolin_app app on app.id = appHourActive.app_id
-         left join ctop_bind_account_login login on login.account_name = app.account_name
+         left join ctop_pangolin_app app on app.app_id = appHourActive.app_id
+         left join ctop_bind_account_login login on login.account_name = appHourActive.account_name
 where appHourActive.type = #{type}
 and date =  #{today} and hour = #{hour}
 <if test="appId!=null">
-    and app.id = #{appId}
+    and app.app_id = #{appId}
 </if>
 <if test="userId!=null">
     and login.user_id = #{userId}
@@ -28,7 +28,7 @@ and date =  #{today} and hour = #{hour}
         <if test="accountNames!=null or projectIds!=null">
             and  ( 1=0
             <if test="accountNames!=null">
-                or login.account_name in
+                or appHourActive.account_name in
                 <foreach item="item" index="index" collection="accountNames" open="(" separator="," close=")">
                     #{item}
                 </foreach>
@@ -44,12 +44,12 @@ and date =  #{today} and hour = #{hour}
 group by appHourActive.date, appHourActive.hour
 union all select num,date,hour
 from ctop_pangolin_report_app_hour appHourActive
-         left join ctop_pangolin_app app on app.id = appHourActive.app_id
-         left join ctop_bind_account_login login on login.account_name = app.account_name
+         left join ctop_pangolin_app app on app.app_id = appHourActive.app_id
+         left join ctop_bind_account_login login on login.account_name = appHourActive.account_name
 where appHourActive.type = #{type}
         and date =  #{yesterday} and hour = #{hour}
         <if test="appId!=null">
-            and app.id = #{appId}
+            and app.app_id = #{appId}
         </if>
         <if test="userId!=null">
             and login.user_id = #{userId}
@@ -57,7 +57,7 @@ where appHourActive.type = #{type}
         <if test="accountNames!=null or projectIds!=null">
             and  ( 1=0
             <if test="accountNames!=null">
-                or login.account_name in
+                or appHourActive.account_name in
                 <foreach item="item" index="index" collection="accountNames" open="(" separator="," close=")">
                     #{item}
                 </foreach>
@@ -73,12 +73,12 @@ where appHourActive.type = #{type}
         group by appHourActive.date, appHourActive.hour
 union all select num,date,hour
 from ctop_pangolin_report_app_hour appHourActive
-         left join ctop_pangolin_app app on app.id = appHourActive.app_id
-         left join ctop_bind_account_login login on login.account_name = app.account_name
+         left join ctop_pangolin_app app on app.app_id = appHourActive.app_id
+         left join ctop_bind_account_login login on login.account_name = appHourActive.account_name
 where appHourActive.type = #{type}
         and date =  #{sevenDaysAgo} and hour = #{hour}
         <if test="appId!=null">
-            and app.id = #{appId}
+            and app.app_id = #{appId}
         </if>
         <if test="userId!=null">
             and login.user_id = #{userId}
@@ -86,7 +86,7 @@ where appHourActive.type = #{type}
         <if test="accountNames!=null or projectIds!=null">
             and  ( 1=0
             <if test="accountNames!=null">
-                or login.account_name in
+                or appHourActive.account_name in
                 <foreach item="item" index="index" collection="accountNames" open="(" separator="," close=")">
                     #{item}
                 </foreach>
@@ -104,8 +104,8 @@ where appHourActive.type = #{type}
     union all
     select num,date,hour
     from ctop_pangolin_report_app_hour appHourActive
-    left join ctop_pangolin_app app on app.id = appHourActive.app_id
-    left join ctop_bind_account_login login on login.account_name = app.account_name
+    left join ctop_pangolin_app app on app.app_id = appHourActive.app_id
+    left join ctop_bind_account_login login on login.account_name = appHourActive.account_name
     where appHourActive.type = #{type}
     and date =  #{compareTime1} and hour = #{hour}
     <if test="appId!=null">
@@ -117,7 +117,7 @@ where appHourActive.type = #{type}
     <if test="accountNames!=null or projectIds!=null">
         and  ( 1=0
         <if test="accountNames!=null">
-            or login.account_name in
+            or appHourActive.account_name in
             <foreach item="item" index="index" collection="accountNames" open="(" separator="," close=")">
                 #{item}
             </foreach>
@@ -136,12 +136,12 @@ where appHourActive.type = #{type}
             union all
             select num,date,hour
             from ctop_pangolin_report_app_hour appHourActive
-            left join ctop_pangolin_app app on app.id = appHourActive.app_id
-            left join ctop_bind_account_login login on login.account_name = app.account_name
+            left join ctop_pangolin_app app on app.app_id = appHourActive.app_id
+            left join ctop_bind_account_login login on login.account_name = appHourActive.account_name
             where appHourActive.type = #{type}
             and date =  #{compareTime2} and hour = #{hour}
             <if test="appId!=null">
-                and app.id = #{appId}
+                and app.app_id = #{appId}
             </if>
             <if test="userId!=null">
                 and login.user_id = #{userId}
@@ -149,7 +149,7 @@ where appHourActive.type = #{type}
             <if test="accountNames!=null or projectIds!=null">
                 and  ( 1=0
                 <if test="accountNames!=null">
-                    or login.account_name in
+                    or appHourActive.account_name in
                     <foreach item="item" index="index" collection="accountNames" open="(" separator="," close=")">
                         #{item}
                     </foreach>

+ 4 - 4
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/xml/PangolinReportBillMonthMapper.xml

@@ -16,14 +16,14 @@
        round(avg(bill.account_quality_score),2) as 'account_quality_score',
        sum(bill.actual_total_price) as 'actual_total_price'
     from ctop_pangolin_report_bill_month bill
-         left join ctop_pangolin_app app on app.id = bill.app_id
-         left join ctop_bind_account_login login on login.account_name = app.account_name
+         left join ctop_pangolin_app app on app.app_id = bill.app_id
+         left join ctop_bind_account_login login on login.account_name = bill.account_name
          where 1=1
          <if test="userId!=null">
              and login.user_id = #{userId}
          </if>
          <if test="appId!=null">
-             and app.id = #{appId}
+             and app.app_id = #{appId}
          </if>
         <if test="startDate!=null">
             and bill.date &gt;= #{startDate}
@@ -37,7 +37,7 @@
         <if test="accountNames!=null or projectIds!=null">
             and  ( 1=0
             <if test="accountNames!=null">
-                or login.account_name in
+                or bill.account_name in
                 <foreach item="item" index="index" collection="accountNames" open="(" separator="," close=")">
                     #{item}
                 </foreach>

+ 10 - 12
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/mapper/xml/PangolinReportChannelDailyMapper.xml

@@ -6,7 +6,8 @@
             resultType="cn.com.ctop.crawler.modules.pangolin.entity.PangolinReportChannelDaily">
         select
             daily.date,
-            channel.name as 'channel_name',
+--             daily.channel_name as 'channel_name',
+            '-' as 'channel_name',
             <if test="appId == null">
                 '-' as 'app_name',
             </if>
@@ -18,15 +19,14 @@
             sum(daily.total_price)as 'total_price'
         from
         ctop_pangolin_report_channel_daily daily
-        left join ctop_pangolin_channel channel on channel.name = daily.channel_name
-        left join ctop_bind_account_login login on login.account_name = channel.account_name
-        left join ctop_pangolin_app app on app.account_name = channel.account_name
+        left join ctop_bind_account_login login on login.account_name = daily.account_name
+        left join ctop_pangolin_app app on app.name = daily.app_name and app.account_name = daily.account_name
         where 1=1
         <if test="userId!=null">
             and login.user_id = #{userId}
         </if>
         <if test="appId!=null">
-            and app.id = #{appId}
+            and app.app_id = #{appId}
         </if>
         <if test="startDate!=null">
             and daily.date &gt;= #{startDate}
@@ -40,7 +40,7 @@
         <if test="accountNames!=null or projectIds!=null">
             and  ( 1=0
             <if test="accountNames!=null">
-                or login.account_name in
+                or daily.account_name in
                 <foreach item="item" index="index" collection="accountNames" open="(" separator="," close=")">
                     #{item}
                 </foreach>
@@ -60,15 +60,14 @@
             sum(daily.external_activation)
         from
         ctop_pangolin_report_channel_daily daily
-        left join ctop_pangolin_channel channel on channel.name = daily.channel_name
-        left join ctop_bind_account_login login on login.account_name = channel.account_name
-        left join ctop_pangolin_app app on app.account_name = channel.account_name
+        left join ctop_bind_account_login login on login.account_name = daily.account_name
+        left join ctop_pangolin_app app on app.account_name = daily.account_name and daily.app_name = app.name
         where 1=1
         <if test="userId!=null">
             and login.user_id = #{userId}
         </if>
         <if test="appId!=null">
-            and app.id = #{appId}
+            and app.app_id = #{appId}
         </if>
         <if test="startDate!=null">
             and daily.date &gt;= #{startDate}
@@ -82,7 +81,7 @@
         <if test="accountNames!=null or projectIds!=null">
             and  ( 1=0
             <if test="accountNames!=null">
-                or login.account_name in
+                or daily.account_name in
                 <foreach item="item" index="index" collection="accountNames" open="(" separator="," close=")">
                     #{item}
                 </foreach>
@@ -95,7 +94,6 @@
             </if>
             )
         </if>
-
     </select>
 
 </mapper>

+ 1 - 1
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinAppServiceImpl.java

@@ -71,7 +71,7 @@ public class PangolinAppServiceImpl extends ServiceImpl<PangolinAppMapper, Pango
         if(null == getApp){
             this.save(app);
         }else{
-            getApp.setName(app.getAccountName());
+            getApp.setName(app.getName());
             this.updateById(getApp);
         }
     }

+ 22 - 11
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinCrawlerServiceImpl.java

@@ -80,11 +80,13 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                     pangolinReportBillMonth.setYear(Integer.parseInt(date.split("-")[0]));
                     pangolinReportBillMonth.setMonth(Integer.parseInt(date.split("-")[1]));
                     pangolinReportBillMonth.setDate(date);
+                    pangolinReportBillMonth.setAccountName(bindAccountLogin.getAccountName());
                     QueryWrapper<PangolinReportBillMonth> queryWrapper = new QueryWrapper<>();
                     queryWrapper.eq("os", pangolinReportBillMonth.getOs());
                     queryWrapper.eq("app_id", pangolinReportBillMonth.getAppId());
                     queryWrapper.eq("month", pangolinReportBillMonth.getMonth());
                     queryWrapper.eq("year", pangolinReportBillMonth.getYear());
+                    queryWrapper.eq("account_name", pangolinReportBillMonth.getAccountName());
                     if (pangolinReportBillMonthService.getOne(queryWrapper) == null) {
                         pangolinReportBillMonthService.save(pangolinReportBillMonth);
                     } else {
@@ -135,17 +137,17 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                     app.setName(name);
                     pangolinAppService.saveOrUpdateApp(app);
                 }
-                Iterator<JsonNode> channelIterator = resultNode.get("data").get("ChannelNameList").elements();
-                while (channelIterator.hasNext()) {
-                    JsonNode channelNode = channelIterator.next();
-                    Long id = channelNode.get("Id").asLong();
-                    String name = channelNode.get("Name").asText();
-                    PangolinChannel channel = new PangolinChannel();
-                    channel.setAccountName(bindAccountLogin.getAccountName());
-                    channel.setId(id);
-                    channel.setName(name);
-                    pangolinChannelService.saveOrUpdate(channel);
-                }
+//                Iterator<JsonNode> channelIterator = resultNode.get("data").get("ChannelNameList").elements();
+//                while (channelIterator.hasNext()) {
+//                    JsonNode channelNode = channelIterator.next();
+//                    Long id = channelNode.get("Id").asLong();
+//                    String name = channelNode.get("Name").asText();
+//                    PangolinChannel channel = new PangolinChannel();
+//                    channel.setAccountName(bindAccountLogin.getAccountName());
+//                    channel.setId(id);
+//                    channel.setName(name);
+//                    pangolinChannelService.saveOrUpdate(channel);
+//                }
             }
         } catch (IOException e) {
             e.printStackTrace();
@@ -208,9 +210,12 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                     pangolinReportChannelDaily.setOprateSystem(os);
                     pangolinReportChannelDaily.setRetentionRatio(retentionRatio);
                     pangolinReportChannelDaily.setTotalPrice(totalPrice);
+                    pangolinReportChannelDaily.setAccountName(bindAccountLogin.getAccountName());
                     QueryWrapper<PangolinReportChannelDaily> queryWrapper = new QueryWrapper<>();
                     queryWrapper.eq("date", pangolinReportChannelDaily.getDate());
+                    queryWrapper.eq("app_name", pangolinReportChannelDaily.getAppName());
                     queryWrapper.eq("channel_name", pangolinReportChannelDaily.getChannelName());
+                    queryWrapper.eq("account_name", bindAccountLogin.getAccountName());
                     if (pangolinReportChannelDailyService.getOne(queryWrapper) == null) {
                         pangolinReportChannelDailyService.save(pangolinReportChannelDaily);
                     } else {
@@ -269,6 +274,7 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                     for (int i = 0; i < size; i++) {
                         BigDecimal clickNum = clickNode.get(i).decimalValue();
                         PangolinReportAppHour pangolinReportAppHour = new PangolinReportAppHour();
+                        pangolinReportAppHour.setAccountName(bindAccountLogin.getAccountName());
                         pangolinReportAppHour.setAppId(appId);
                         pangolinReportAppHour.setDate(DateUtils.parseDate(date, "yyyy-MM-dd"));
                         pangolinReportAppHour.setNum(clickNum);
@@ -279,6 +285,7 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                         queryWrapper.eq("app_id", pangolinReportAppHour.getAppId());
                         queryWrapper.eq("type", pangolinReportAppHour.getType());
                         queryWrapper.eq("hour", pangolinReportAppHour.getHour());
+                        queryWrapper.eq("account_name", pangolinReportAppHour.getAccountName());
                         if (pangolinReportAppHourService.getOne(queryWrapper) == null) {
                             pangolinReportAppHourService.save(pangolinReportAppHour);
                         } else {
@@ -294,6 +301,7 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                     for (int i = 0; i < size; i++) {
                         BigDecimal activeNum = activeNode.get(i).decimalValue();
                         PangolinReportAppHour pangolinReportAppHour = new PangolinReportAppHour();
+                        pangolinReportAppHour.setAccountName(bindAccountLogin.getAccountName());
                         pangolinReportAppHour.setAppId(appId);
                         pangolinReportAppHour.setDate(DateUtils.parseDate(date, "yyyy-MM-dd"));
                         pangolinReportAppHour.setNum(activeNum);
@@ -304,6 +312,7 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                         queryWrapper.eq("app_id", pangolinReportAppHour.getAppId());
                         queryWrapper.eq("type", pangolinReportAppHour.getType());
                         queryWrapper.eq("hour", pangolinReportAppHour.getHour());
+                        queryWrapper.eq("account_name", pangolinReportAppHour.getAccountName());
                         if (pangolinReportAppHourService.getOne(queryWrapper) == null) {
                             pangolinReportAppHourService.save(pangolinReportAppHour);
                         } else {
@@ -319,6 +328,7 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                     for (int i = 0; i < size; i++) {
                         BigDecimal clickNum = rateNode.get(i).decimalValue();
                         PangolinReportAppHour pangolinReportAppHour = new PangolinReportAppHour();
+                        pangolinReportAppHour.setAccountName(bindAccountLogin.getAccountName());
                         pangolinReportAppHour.setAppId(appId);
                         pangolinReportAppHour.setDate(DateUtils.parseDate(date, "yyyy-MM-dd"));
                         pangolinReportAppHour.setNum(clickNum);
@@ -329,6 +339,7 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
                         queryWrapper.eq("app_id", pangolinReportAppHour.getAppId());
                         queryWrapper.eq("type", pangolinReportAppHour.getType());
                         queryWrapper.eq("hour", pangolinReportAppHour.getHour());
+                        queryWrapper.eq("account_name", pangolinReportAppHour.getAccountName());
                         if (pangolinReportAppHourService.getOne(queryWrapper) == null) {
                             pangolinReportAppHourService.save(pangolinReportAppHour);
                         } else {

+ 0 - 1
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinReportAppHourServiceImpl.java

@@ -24,7 +24,6 @@ public class PangolinReportAppHourServiceImpl extends ServiceImpl<PangolinReport
 
     @Override
     public Map<String, Object> getRealTimeData(String userId, JSONObject data) {
-
         Map<String, Object> resultMap = new HashMap<>();
         String today = DateUtils.formatDate();
         String yesterday = DateUtils.addDay(today,-1);

+ 22 - 0
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceAccountBidJob.java

@@ -0,0 +1,22 @@
+package cn.com.ctop.job.bytedance.handler;
+
+import cn.com.ctop.toutiao.modules.material.service.IBytedanceBidWarningService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class BytedanceAccountBidJob {
+    @Autowired
+    private IBytedanceBidWarningService bidWarningService;
+
+    /**
+     * 出价预警
+     */
+    @XxlJob("bytedanceAccountBidJob")
+    public ReturnT<String> execute(String params) throws Exception {
+        bidWarningService.bidWarning();
+        return ReturnT.SUCCESS;
+    }
+}

+ 22 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAccountBidJob.java

@@ -0,0 +1,22 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.kuaishou.modules.material.service.IKuaishouBidWarningService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class KuaishouAccountBidJob {
+    @Autowired
+    private IKuaishouBidWarningService bidWarningService;
+
+    /**
+     * 出价预警
+     **/
+    @XxlJob("kuaishouAccountBidJob")
+    public ReturnT<String> execute(String param) {
+        bidWarningService.bidWarning();
+        return ReturnT.SUCCESS;
+    }
+}

+ 7 - 1
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouSuZaoLoadJob.java

@@ -6,6 +6,7 @@ import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import com.xxl.job.core.biz.model.ReturnT;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import com.xxl.job.core.log.XxlJobLogger;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -25,8 +26,13 @@ public class KuaishouSuZaoLoadJob {
     public ReturnT<String> execute(String param) throws Exception {
         List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
         executorService = Executors.newFixedThreadPool(8);
-        tokens.forEach(token -> executorService.submit(() -> kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1)));
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        String endDate = DateUtils.getAnotherDay("yyyy-mm-dd", nowDate, 1);
+        String startDate = DateUtils.getAnotherDay("yyyy-mm-dd", nowDate, -1);
+        tokens.forEach(token -> executorService.submit(() -> kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startDate, endDate)));
         XxlJobLogger.log("快手素造数据同步完成");
         return ReturnT.SUCCESS;
     }
+
+
 }

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

@@ -151,28 +151,25 @@ public class BatchController {
             };
             thread1.start();
 
-            for (int i = 0; i < dateList.size(); i++) {
-                String date = (String) dateList.get(i);
-                Thread thread2 = new Thread() {
-                    @Override
-                    public void run() {
+
+            Thread thread2 = new Thread() {
+                @Override
+                public void run() {
+                    for (int i = 0; i < dateList.size(); i++) {
+                        String date = (String) dateList.get(i);
                         iKuaishouInterfaceService.getVideoList(oauthToken, date);
                     }
-                };
-                thread2.start();
-
-
-
-
-            }
-
-
+                }
+            };
+            thread2.start();
 
             Thread thread3 = new Thread() {
                 @Override
                 public void run() {
-                    iKuaishouInterfaceService.getSuZaoList(oauthToken.getAccessToken(), oauthToken.getAccountId(), 1);
-                    videoGetService.getKeyFrame(oauthToken);
+                    String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                    String endDate = DateUtils.getAnotherDay("yyyy-mm-dd", nowDate, 1);
+                    String startDate = DateUtils.getAnotherDay("yyyy-mm-dd", nowDate, -1);
+                    iKuaishouInterfaceService.getSuZaoList(oauthToken.getAccessToken(), oauthToken.getAccountId(), 1, startDate, endDate);
                 }
             };
             thread3.start();
@@ -186,7 +183,6 @@ public class BatchController {
             };
             thread4.start();
 
-
         } catch (Exception e) {
             e.printStackTrace();
             result.setSuccess(false);

+ 0 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouVideoGet.java

@@ -75,8 +75,6 @@ public class KuaiShouVideoGet {
     private String signature;
 
     private Date statDate;
-    private Date  uploadDate;
-
 
     private Integer materialType;
     /**

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

@@ -17,5 +17,5 @@ import java.util.List;
 public interface IKuaiShouVideoGetService extends IService<KuaiShouVideoGet> {
     void replaceBatch(List<KuaiShouVideoGet> videoGets);
 
-    void getKeyFrame(CtopOauthToken token);
+    void getKeyFrame(String token,Long accountId, String md5, String photoId);
 }

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

@@ -1,9 +0,0 @@
-package cn.com.ctop.kuaishou.modules.batch.service;
-
-
-public interface IKuaiShouVideoTimeService {
-
-    java.util.Date getVideoTime(String photoId, Long accountId);
-
-
-}

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

@@ -458,7 +458,7 @@ public interface IKuaishouInterfaceService {
      * @param accountId
      * @param page
      */
-    void getSuZaoList(String token, Long accountId, int page);
+    void getSuZaoList(String token, Long accountId, int page, String startDate,String endDate);
 
     /**
      * 异步获取创意信息

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

@@ -12,6 +12,7 @@ import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.io.FileSystemResource;
@@ -85,12 +86,13 @@ public class KuaiShouMaterialUploadServiceImpl implements IKuaiShouMaterialUploa
                         videoGet.setMaterialType(type);
                         videoGet.setPhotoId(photoId);
                         videoGet.setSignature(signature);
+                        videoGet.setStatDate(DateUtils.getNowDate());
+                        videoGet.setCoverUrl(url + "?x-oss-process=video/snapshot,t_00000,m_fast");
                         kuaiShouVideoGetService.saveOrUpdate(videoGet);
                         returnJson.put("success", true);
                         returnJson.put("photoId", photoId);
                         returnJson.put("signature", signature);
                         returnJson.put("message", "上传成功");
-
                     }
                     LoadFileUtil.delFile(localUrl);
                     log.info("快手素材上传完成,accountId:{},code:{},返回信息:{}", accountId, signature, resultJson);
@@ -99,7 +101,6 @@ public class KuaiShouMaterialUploadServiceImpl implements IKuaiShouMaterialUploa
                     returnJson.put("success", false);
                     returnJson.put("signature", signature);
                     returnJson.put("message", resultJson.getString("message"));
-
                 }
             } else {
                 log.error("快手上传素材返回信息为空请求参数:{}", requestJson);

+ 49 - 67
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java

@@ -1,6 +1,5 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
-import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.MaterialCutFrame;
 import cn.com.ctop.common.module.service.IMaterialCutFrameService;
 import cn.com.ctop.common.module.utils.Check;
@@ -13,6 +12,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -27,10 +27,10 @@ import java.util.concurrent.Executors;
 /**
  * @Description: 快手-获取视频接口
  * @Author: jeecg-boot
- *
  * @Date: 2019-07-25
  * @Version: V1.0
  */
+@Slf4j
 @Service
 public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMapper, KuaiShouVideoGet> implements IKuaiShouVideoGetService {
     @Autowired
@@ -51,82 +51,64 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
     /**
      * 获取关键帧
      *
-     *
      * @param
      */
     @Override
-    public void getKeyFrame(CtopOauthToken token) {
+    public void getKeyFrame(String token, Long accountId, String videoMd5, String photoId) {
         try {
-            QueryWrapper<KuaiShouVideoGet> videoGetQueryWrapper = new QueryWrapper<>();
-            videoGetQueryWrapper.eq("account_id", token.getAccountId());
-            videoGetQueryWrapper.eq("channel_type", 1);
-            List<KuaiShouVideoGet> kuaiShouVideoGets = videoGetMapper.selectList(videoGetQueryWrapper);
-            if (Check.isNull(kuaiShouVideoGets)) {
+            log.info("开始素造抽帧,md5:{}", videoMd5);
+            QueryWrapper<MaterialCutFrame> cutFrameQueryWrapper = new QueryWrapper<>();
+            cutFrameQueryWrapper.eq("video_signature", videoMd5);
+            cutFrameQueryWrapper.last("limit 1");
+            MaterialCutFrame one = materialCutFrameService.getOne(cutFrameQueryWrapper);
+            if (!Check.isNull(one)) {
                 return;
             }
-            for (KuaiShouVideoGet videoGet : kuaiShouVideoGets) {
-                synchronized (this) {
-                    if (!Check.isNull(videoGet.getSignature())) {
-                        QueryWrapper<MaterialCutFrame> cutFrameQueryWrapper = new QueryWrapper<>();
-                        cutFrameQueryWrapper.eq("video_signature", videoGet.getSignature());
-                        cutFrameQueryWrapper.last("limit 1");
-                        MaterialCutFrame one = materialCutFrameService.getOne(cutFrameQueryWrapper);
-                        if (!Check.isNull(one)) {
-                            continue;
-                        }
-                    }
-
-                    executorService.submit(new Runnable() {
-                        @Override
-                        public void run() {
-                            String url = "https://ad.e.kuaishou.com/rest/openapi/v1/tool/key_frame";
-                            JSONArray photoArr = new JSONArray();
-                            photoArr.add(videoGet.getPhotoId());
-                            Map<String, String> headers = new HashMap<>();
-                            headers.put("Access-Token", token.getAccessToken());
-                            headers.put("Content-Type", "application/json");
-                            JSONObject requestJson = new JSONObject();
-                            requestJson.put("advertiser_id", token.getAccountId());
-                            requestJson.put("photo_ids", photoArr);
-                            String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
-                            JSONObject resultJson = JSONObject.parseObject(result);
-                            if (!Check.isNull(resultJson)) {
-                                Integer code = resultJson.getInteger("code");
-                                if (code == 0) {
-                                    JSONArray dataArr = resultJson.getJSONArray("data");
-                                    if (!Check.isNull(dataArr)) {
-                                        for (int i = 0; i < dataArr.size(); i++) {
-                                            String imageUrl = dataArr.getString(i);
-                                            String localPath = LoadFileUtil.downLoadFromUrl(imageUrl, downloadUrl);
-                                            String md5 = null;
-                                            try {
-                                                md5 = LoadFileUtil.getMD5(localPath);
-                                            } catch (IOException e) {
-                                                e.printStackTrace();
-                                                continue;
-                                            }
-                                            Map<String, Object> deleteMap = new HashMap<>();
-                                            deleteMap.put("video_signature", videoGet.getSignature());
-                                            deleteMap.put("signature", md5);
-                                            materialCutFrameService.removeByMap(deleteMap);
-
-                                            MaterialCutFrame materialCutFrame = new MaterialCutFrame();
-                                            materialCutFrame.setImageIndex(i);
-                                            materialCutFrame.setVideoSignature(videoGet.getSignature());
-                                            materialCutFrame.setUrl(imageUrl);
-                                            materialCutFrame.setSignature(md5);
-                                            materialCutFrameService.save(materialCutFrame);
-                                            LoadFileUtil.delFile(localPath);
-                                        }
-                                    }
-                                }
+            String url = "https://ad.e.kuaishou.com/rest/openapi/v1/tool/key_frame";
+            JSONArray photoArr = new JSONArray();
+            photoArr.add(photoId);
+            Map<String, String> headers = new HashMap<>();
+            headers.put("Access-Token", token);
+            headers.put("Content-Type", "application/json");
+            JSONObject requestJson = new JSONObject();
+            requestJson.put("advertiser_id", accountId);
+            requestJson.put("photo_ids", photoArr);
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    JSONArray dataArr = resultJson.getJSONArray("data");
+                    if (!Check.isNull(dataArr)) {
+                        for (int i = 0; i < dataArr.size(); i++) {
+                            String imageUrl = dataArr.getString(i);
+                            String localPath = LoadFileUtil.downLoadFromUrl(imageUrl, downloadUrl);
+                            String md5 = null;
+                            try {
+                                md5 = LoadFileUtil.getMD5(localPath);
+                            } catch (IOException e) {
+                                e.printStackTrace();
+                                continue;
                             }
+                            Map<String, Object> deleteMap = new HashMap<>();
+                            deleteMap.put("video_signature", videoMd5);
+                            deleteMap.put("signature", md5);
+                            materialCutFrameService.removeByMap(deleteMap);
+                            MaterialCutFrame materialCutFrame = new MaterialCutFrame();
+                            materialCutFrame.setImageIndex(i);
+                            materialCutFrame.setVideoSignature(videoMd5);
+                            materialCutFrame.setUrl(imageUrl);
+                            materialCutFrame.setSignature(md5);
+                            materialCutFrameService.save(materialCutFrame);
+                            LoadFileUtil.delFile(localPath);
                         }
-                    });
+                    }
                 }
-
             }
 
+
+            // }
+
         } catch (Exception e) {
             e.printStackTrace();
         }

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

@@ -1,64 +0,0 @@
-package cn.com.ctop.kuaishou.modules.batch.service.impl;
-
-import cn.com.ctop.common.module.utils.Check;
-import cn.com.ctop.common.module.utils.HttpUtils;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoTimeService;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAgentAccount;
-import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAgentAccountService;
-import com.alibaba.fastjson.JSONObject;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-
-@Slf4j
-@Service
-public class KuaiShouVideoTimeServiceImpl implements IKuaiShouVideoTimeService {
-    @Autowired
-    private IKuaishouAgentAccountService agentAccountService;
-
-    @Override
-    public java.util.Date getVideoTime(String photoId, Long accountId) {
-
-        KuaishouAgentAccount agentAccount = agentAccountService.getById(accountId);
-        if (Check.isNull(agentAccount)) {
-            log.info("未获取到userId:accountId:{}",accountId);
-            return null;
-        }
-
-        try {
-            String videoUrl = "http://yongzhou.s.gifshow.com/i/photo/lwx?userId=" + agentAccount.getUserId() + "&photoId=" + photoId;
-            String res = HttpUtils.getKuaishouShareUrl(videoUrl);
-            String path = res.split("\\?")[0];
-            String photoIdStr = path.substring(path.lastIndexOf("/") + 1, path.length());
-            path = path.substring(0, path.lastIndexOf("/"));
-            String uid = path.substring(path.lastIndexOf("/") + 1, path.length());
-            String result = HttpUtils.postKuaishouVideoUrl("https://live.kuaishou.com/m_graphql", uid, photoIdStr);
-            JSONObject resultJson = JSONObject.parseObject(result);
-            if (!Check.isNull(resultJson)) {
-                JSONObject dataJson = resultJson.getJSONObject("data");
-                if (!Check.isNull(dataJson)) {
-                    JSONObject feedById = dataJson.getJSONObject("feedById");
-                    if (!Check.isNull(feedById)) {
-                        JSONObject currentWork = feedById.getJSONObject("currentWork");
-                        if (!Check.isNull(currentWork)) {
-                            Long timestamp = currentWork.getLong("timestamp");
-                            return new java.util.Date(timestamp);
-
-                        }
-
-                    }
-
-                }
-
-            }
-
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error("获取时间错误");
-        }
-
-
-        return null;
-    }
-}

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

@@ -222,11 +222,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
                 kuaiShouVideoGet.setId(token.getAccountId() + kuaiShouVideoGet.getPhotoId());
 
-                Date videoTime = videoTimeService.getVideoTime(kuaiShouVideoGet.getPhotoId(), token.getAccountId());
-                if (!Check.isNull(videoTime)) {
-                    kuaiShouVideoGet.setUploadDate(videoTime);
-                }
-
                 kuaiShouVideoGet.setAccountId(token.getAccountId());
                 kuaiShouVideoGet.setStatDate(DateUtils.parseDate(statDate, "yyyy-MM-dd"));
                 kuaiShouVideoGet.setUpdateTime(new Date());
@@ -290,17 +285,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 detailJson.put("photo_comment", detailJson.getString("comment"));
                 detailJson.put("photo_like", detailJson.getString("like"));
                 detailJson.put("photo_show", detailJson.getString("show"));
-                detailJson.remove("share");
-                detailJson.remove("comment");
-                detailJson.remove("like");
-                detailJson.remove("show");
-                detailJson.remove("adScene");
-                detailJson.remove("stat_hour");
-                detailJson.remove("event_valid_clues");
-                detailJson.remove("event_valid_clues_cost");
-                KuaishouReportDailyAccount kuaishouReportDailyAccount = JsonUtil.jsonToObj(detailJson, KuaishouReportDailyAccount.class);
-                kuaishouReportDailyAccount.setAccountId(token.getAccountId());
-                dailyAccountMapper.insertSelective(kuaishouReportDailyAccount);
+                var KuaishouReportDailyAccount = JSONObject.toJavaObject(detailJson, KuaishouReportDailyAccount.class);
+                KuaishouReportDailyAccount.setAccountId(token.getAccountId());
+                dailyAccountMapper.insertSelective(KuaishouReportDailyAccount);
             }
         }
         getAccountDailyReportByPage(token, startDate, endDate, page + 1);
@@ -908,6 +895,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
         historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), startDate, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
 
+        getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, null, null);
         String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
         String videoEndDate = DateUtils.addDay(nowDate, -180);
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
@@ -2861,20 +2849,27 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
      * @param page
      */
     @Autowired
-    private IKuaiShouVideoTimeService videoTimeService;
+    private IKuaiShouVideoGetService videoGetService;
 
     @Override
-    public void getSuZaoList(String token, Long accountId, int page) {
-        String url = "https://ad.e.kuaishou.com/rest/openapi/v1/file/ad/video/su_zao/list";
+    public void getSuZaoList(String token, Long accountId, int page, String startDate, String endDate) {
+        String url = "https://ad.e.kuaishou.com/rest/openapi/v1/ad_creator/video/list";
         Map<String, String> headers = new HashMap<String, String>();
         headers.put("Content-Type", "application/json");
         headers.put("Access-Token", token);
         Map<String, Object> param = new HashMap<String, Object>();
         param.put("advertiser_id", accountId);
         param.put("page", page);
-        param.put("page_size", 500);
+        param.put("page_size", 200);
+        if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
+            param.put("start_date", startDate);
+            param.put("end_date", endDate);
+        }
+        System.err.println("入参:" + param);
+        System.err.println("headers:" + headers);
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
+        System.err.println(resultJson);
         Integer code = resultJson.getInteger("code");
         String message = resultJson.getString("message");
         if (null == code || code != 0) {
@@ -2883,40 +2878,45 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         }
         JSONObject dataJson = resultJson.getJSONObject("data");
         if (!Check.isNull(dataJson)) {
-            Integer total_count = dataJson.getInteger("total_count");
-           /* if (total_count > 2000) {
-                return;
-            }*/
             JSONArray details = dataJson.getJSONArray("details");
             if (Check.isNull(details)) {
                 return;
             }
             for (int i = 0; i < details.size(); i++) {
-                var detailJson = details.getJSONObject(i);
+                JSONObject jsonObject = details.getJSONObject(i);
+                if (!Check.isNull(jsonObject)) {
+                    KuaiShouVideoGet kuaiShouVideoGet = new KuaiShouVideoGet();
+                    Long photo_id = jsonObject.getLong("photo_id");
+                    kuaiShouVideoGet.setId(accountId + photo_id + "");
+                    kuaiShouVideoGet.setPhotoId(String.valueOf(photo_id));
+                    kuaiShouVideoGet.setUrl(jsonObject.getString("watermark_url"));
+                    kuaiShouVideoGet.setWidth(jsonObject.getInteger("width"));
+                    kuaiShouVideoGet.setHeight(jsonObject.getInteger("height"));
+                    kuaiShouVideoGet.setCoverUrl(jsonObject.getString("cover_url"));
+                    kuaiShouVideoGet.setAccountId(accountId);
+                    String md5 = jsonObject.getString("md5");
+                    kuaiShouVideoGet.setSignature(md5);
+                    kuaiShouVideoGet.setStatDate(jsonObject.getDate("sync_date"));
+                    kuaiShouVideoGet.setChannelType(1);
+                    Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
+                    if (!Check.isNull(type)) {
+                        kuaiShouVideoGet.setMaterialType(type);
+                    }
+                    kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
+
+                    Thread thread = new Thread() {
+                        @Override
+                        public void run() {
+                            videoGetService.getKeyFrame(token, accountId, md5, String.valueOf(photo_id));
+                        }
+                    };
+                    thread.start();
+
 
-                KuaiShouVideoGet byId = kuaiShouVideoGetService.getById(accountId + detailJson.getString("photo_id"));
-                if (!Check.isNull(byId)) {
-                    continue;
-                }
-                var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
-               /* Date videoTime = videoTimeService.getVideoTime(kuaiShouVideoGet.getPhotoId(), accountId);
-                if (!Check.isNull(videoTime)) {
-                    kuaiShouVideoGet.setUploadDate(videoTime);
-                }*/
-                kuaiShouVideoGet.setStatDate(new Date());
-                kuaiShouVideoGet.setAccountId(accountId);
-                kuaiShouVideoGet.setId(accountId + kuaiShouVideoGet.getPhotoId());
-                kuaiShouVideoGet.setCreateTime(new Date());
-                kuaiShouVideoGet.setUpdateTime(new Date());
-                Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
-                if (!Check.isNull(type)) {
-                    kuaiShouVideoGet.setMaterialType(type);
                 }
-                kuaiShouVideoGet.setChannelType(1);
-                kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
             }
         }
-        getSuZaoList(token, accountId, page + 1);
+        getSuZaoList(token, accountId, page + 1, startDate, endDate);
 
     }
 

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/service/IKuaishouBidWarningService.java

@@ -0,0 +1,5 @@
+package cn.com.ctop.kuaishou.modules.material.service;
+
+public interface IKuaishouBidWarningService {
+    void bidWarning();
+}

+ 161 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/service/impl/KuaishouBidWarningServiceImpl.java

@@ -0,0 +1,161 @@
+package cn.com.ctop.kuaishou.modules.material.service.impl;
+
+import cn.com.ctop.common.module.entity.MailLog;
+import cn.com.ctop.common.module.entity.Project;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.MailLogMapper;
+import cn.com.ctop.common.module.service.ICorpFeishuUserService;
+import cn.com.ctop.common.module.service.IProjectService;
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CorpWexinUtils;
+import cn.com.ctop.common.module.utils.SendMailUtil;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
+import cn.com.ctop.kuaishou.modules.material.service.IKuaishouBidWarningService;
+import cn.com.feishu.provider.MessageProvider;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.xxl.job.core.log.XxlJobLogger;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class KuaishouBidWarningServiceImpl implements IKuaishouBidWarningService {
+    @Autowired
+    private IProjectService projectService;
+    @Autowired
+    private IUserAllocationService userAllocationService;
+    @Autowired
+    private KuaiShouGroupMapper groupMapper;
+    @Autowired
+    private MailLogMapper mailLogMapper;
+
+
+    /**
+     * 预警
+     */
+
+    @Override
+    public void bidWarning() {
+        XxlJobLogger.log("快手出价预警定时任务开始");
+        long start = System.currentTimeMillis();
+        try {
+            List<Project> projects = projectService.list();
+            if (Check.isNull(projects)) {
+                return;
+            }
+            for (Project project : projects) {
+                if (Check.isNull(project)) {
+                    continue;
+                }
+                Long maxBid = project.getMaxBid();
+                Long projectId = project.getId();
+                List<UserAllocation> userAllocations = userAllocationService.getByParams(projectId,null,null);
+                if (!Check.isNull(userAllocations)) {
+                    for (UserAllocation userAllocation : userAllocations) {
+                        if (userAllocation.getAccountStatus() == 1) {
+                            continue;
+                        }
+                        Long accountId = userAllocation.getAccountId();
+                        List<String> unitWarning = new ArrayList<>();
+                        if ("2".equals(userAllocation.getMediaId())) {
+                            unitWarning = groupMapper.selectWarningGroup(accountId, maxBid);
+                            sendMessage(project.getMediaId(), accountId, projectId, project.getProjectName(), userAllocation.getAuthName(), unitWarning, maxBid);
+                            sendFeishumessage(project.getMediaId(), accountId, projectId, project.getProjectName(), userAllocation.getAuthName(), unitWarning, maxBid);
+                        }
+                    }
+                }
+            }
+            XxlJobLogger.log("出价预警定时任务执行完毕,共耗时:{} s", (System.currentTimeMillis() - start) / 1000);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+    private void sendFeishumessage(String mediaId, Long accountId, Long projectId, String projectName, String authName, List<String> unitWarning, Long maxBid) throws Exception {
+        String createTime = DateUtils.getNowDate("yyyy-MM-dd");
+        Integer count = mailLogMapper.selectCountByAccountIdAndDate(accountId, createTime, Integer.getInteger(mediaId));
+        StringBuilder text = new StringBuilder();
+        String s = "";
+        for (int i = 0; i < unitWarning.size(); i++) {
+            s += unitWarning.get(i) + "," + "\n\r";
+
+        }
+        text.append("项目出价预警").append("\n\r").append("您的项目:").append(projectName + ",").append("\n\r")
+                .append("授权名称为:" + authName + " 下的,").append("\n\r").append(s)
+                .append("大于项目设置的最高出价:").append(maxBid / 1000).append(" 元! 请您及时调整。");
+        if (count < 3) {
+            List<String> mailList = mailLogMapper.selectMailList(projectId);
+            String subject;
+            if ("1".equals(mediaId)) {
+                subject = "头条-广告计划出价预警";
+
+            } else {
+                subject = "快手-广告组出价预警";
+            }
+            try {
+                SendMailUtil.sendMail(mailList, subject, text.toString());
+                MailLog mailLog = new MailLog();
+                mailLog.setAccountId(accountId);
+                mailLog.setMailType(1);
+                mailLog.setContent(text.toString());
+                mailLog.setSendEmil(JSON.toJSONString(mailList));
+                mailLog.setSubject(subject);
+                mailLogMapper.insert(mailLog);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+        JSONArray openIds = corpFeishuUserService.getOpenIdByParams(projectId);
+        if(null == openIds||openIds.isEmpty()){
+            XxlJobLogger.log("该项目下运营飞书账号尚未绑定邮箱=>projectId:{}",projectId);
+            return;
+        }
+        MessageProvider.batchSend(null,openIds,null,text.toString());
+    }
+
+    @Autowired
+    private ICorpFeishuUserService corpFeishuUserService;
+
+    private void sendMessage(String mediaId, Long accountId, Long projectId, String projectName, String authName, List<String> unitWarning, Long maxBid) {
+        String createTime = DateUtils.getNowDate("yyyy-MM-dd");
+        Integer count = mailLogMapper.selectCountByAccountIdAndDate(accountId, createTime, 1);
+        StringBuilder text = new StringBuilder();
+        String s = "";
+        for (int i = 0; i < unitWarning.size(); i++) {
+            s += unitWarning.get(i) + "," + "<br/>";
+        }
+        text.append("项目出价预警").append("<br/>").append("您的项目:").append(projectName + ",").append("<br/>")
+                .append("授权名称为:" + authName + " 下的,").append("<br/>").append(s)
+                .append("大于项目设置的最高出价:").append(maxBid / 1000).append(" 元! 请您及时调整。");
+        if (count < 3) {
+            List<String> mailList = mailLogMapper.selectMailList(projectId);
+            String subject;
+            if ("1".equals(mediaId)) {
+                subject = "头条-广告计划出价预警";
+            } else {
+                subject = "快手-广告组出价预警";
+            }
+
+            try {
+                SendMailUtil.sendMail(mailList, subject, text.toString());
+                MailLog mailLog = new MailLog();
+                mailLog.setAccountId(accountId);
+                mailLog.setMailType(1);
+                mailLog.setContent(text.toString());
+                mailLog.setSendEmil(JSON.toJSONString(mailList));
+                mailLog.setSubject(subject);
+                mailLogMapper.insert(mailLog);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+        List<String> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
+        CorpWexinUtils.sendMessage(wexinIds, text.toString());
+    }
+}

+ 5 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IBytedanceBidWarningService.java

@@ -0,0 +1,5 @@
+package cn.com.ctop.toutiao.modules.material.service;
+
+public interface IBytedanceBidWarningService {
+    void bidWarning();
+}

+ 168 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/BytedanceBidWarningServiceImpl.java

@@ -0,0 +1,168 @@
+package cn.com.ctop.toutiao.modules.material.service.impl;
+
+import cn.com.ctop.common.module.entity.MailLog;
+import cn.com.ctop.common.module.entity.Project;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.MailLogMapper;
+import cn.com.ctop.common.module.service.ICorpFeishuUserService;
+import cn.com.ctop.common.module.service.IProjectService;
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.BigDecimalUtil;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CorpWexinUtils;
+import cn.com.ctop.common.module.utils.SendMailUtil;
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertisePlanService;
+import cn.com.ctop.toutiao.modules.material.service.IBytedanceBidWarningService;
+import cn.com.feishu.provider.MessageProvider;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.xxl.job.core.log.XxlJobLogger;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+@Slf4j
+public class BytedanceBidWarningServiceImpl implements IBytedanceBidWarningService {
+    @Autowired
+    private ICorpFeishuUserService corpFeishuUserService;
+    @Autowired
+    private IProjectService projectService;
+    @Autowired
+    private IUserAllocationService userAllocationService;
+    @Autowired
+    private MailLogMapper mailLogMapper;
+    @Autowired
+    private IByteDanceAdvertisePlanService byteDanceAdvertisePlanService;
+
+    @Override
+    public void bidWarning() {
+        XxlJobLogger.log("---------头条出价预警定时任务开始----------");
+        long start = System.currentTimeMillis();
+        try {
+            List<Project> projects = projectService.list();
+            if (Check.isNull(projects)) {
+                XxlJobLogger.log("查询所属项目为空");
+                return ;
+            }
+            for (Project project : projects) {
+                if (Check.isNull(project)) {
+                    continue;
+                }
+                Long maxBid = project.getMaxBid();
+                Long projectId = project.getId();
+                List<UserAllocation> userAllocations = userAllocationService.getByParams(projectId,null,null);
+                if (Check.isNull(userAllocations)) {
+                    continue;
+                }
+                for (UserAllocation userAllocation : userAllocations) {
+                    if (userAllocation.getAccountStatus() == 1) {
+                        continue;
+                    }
+                    Long accountId = userAllocation.getAccountId();
+                    List<String> unitWarning = new ArrayList<>();
+                    if ("1".equals(userAllocation.getMediaId())) {
+                        BigDecimal bid = new BigDecimal(maxBid);
+                        BigDecimal bigDecimal = BigDecimalUtil.divideBigDecimal(bid, new BigDecimal(1000));
+                        unitWarning = byteDanceAdvertisePlanService.selectWarningGroup(accountId, bigDecimal);
+                        if (!Check.isNull(unitWarning)) {
+                            sendMessage(project.getMediaId(), accountId, projectId, project.getProjectName(), userAllocation.getAuthName(), unitWarning, maxBid);
+                            sendFeishumessage(project.getMediaId(), accountId, projectId, project.getProjectName(), userAllocation.getAuthName(), unitWarning, maxBid);
+                        }
+                    }
+                }
+            }
+            XxlJobLogger.log("头条出价预警定时任务执行完毕,共耗时:{} s", (System.currentTimeMillis() - start) / 1000);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+
+    }
+
+    private void sendFeishumessage(String mediaId, Long accountId, Long projectId, String projectName, String authName, List<String> unitWarning, Long maxBid) throws Exception {
+        String createTime = DateUtils.getNowDate("yyyy-MM-dd");
+        Integer count = mailLogMapper.selectCountByAccountIdAndDate(accountId, createTime, Integer.getInteger(mediaId));
+        StringBuilder text = new StringBuilder();
+        String s = "";
+        for (int i = 0; i < unitWarning.size(); i++) {
+            s += unitWarning.get(i) + "," + "\n\r";
+
+        }
+        text.append("项目出价预警").append("\n\r").append("您的项目:").append(projectName + ",").append("\n\r")
+                .append("授权名称为:" + authName + " 下的,").append("\n\r").append(s)
+                .append("大于项目设置的最高出价:").append(maxBid / 1000).append(" 元! 请您及时调整。");
+        if (count < 3) {
+            List<String> mailList = mailLogMapper.selectMailList(projectId);
+            String subject;
+            if ("1".equals(mediaId)) {
+                subject = "头条-广告计划出价预警";
+
+            } else {
+                subject = "快手-广告组出价预警";
+            }
+            try {
+                SendMailUtil.sendMail(mailList, subject, text.toString());
+                MailLog mailLog = new MailLog();
+                mailLog.setAccountId(accountId);
+                mailLog.setMailType(1);
+                mailLog.setContent(text.toString());
+                mailLog.setSendEmil(JSON.toJSONString(mailList));
+                mailLog.setSubject(subject);
+                mailLogMapper.insert(mailLog);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+        JSONArray openIds = corpFeishuUserService.getOpenIdByParams(projectId);
+        if(null == openIds||openIds.isEmpty()){
+            log.error("该项目下运营飞书账号尚未绑定邮箱=>projectId:{}",projectId);
+            return;
+        }
+        MessageProvider.batchSend(null,openIds,null,text.toString());
+    }
+
+    private void sendMessage(String mediaId, Long accountId, Long projectId, String projectName, String authName, List<String> unitWarning, Long maxBid) {
+        String createTime = DateUtils.getNowDate("yyyy-MM-dd");
+        Integer count = mailLogMapper.selectCountByAccountIdAndDate(accountId, createTime, 1);
+        StringBuilder text = new StringBuilder();
+        String s = "";
+        for (int i = 0; i < unitWarning.size(); i++) {
+            s += unitWarning.get(i) + "," + "<br/>";
+        }
+        text.append("项目出价预警").append("<br/>").append("您的项目:").append(projectName + ",").append("<br/>")
+                .append("授权名称为:" + authName + " 下的,").append("<br/>").append(s)
+                .append("大于项目设置的最高出价:").append(maxBid / 1000).append(" 元! 请您及时调整。");
+        if (count < 3) {
+            List<String> mailList = mailLogMapper.selectMailList(projectId);
+            String subject;
+            if ("1".equals(mediaId)) {
+                subject = "头条-广告计划出价预警";
+            } else {
+                subject = "快手-广告组出价预警";
+            }
+
+            try {
+                SendMailUtil.sendMail(mailList, subject, text.toString());
+                MailLog mailLog = new MailLog();
+                mailLog.setAccountId(accountId);
+                mailLog.setMailType(1);
+                mailLog.setContent(text.toString());
+                mailLog.setSendEmil(JSON.toJSONString(mailList));
+                mailLog.setSubject(subject);
+                mailLogMapper.insert(mailLog);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+        List<String> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
+        CorpWexinUtils.sendMessage(wexinIds, text.toString());
+    }
+}