Explorar o código

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

zhaoxian %!s(int64=4) %!d(string=hai) anos
pai
achega
b3b60cb842
Modificáronse 38 ficheiros con 754 adicións e 248 borrados
  1. 22 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAdvertiserStrategyController.java
  2. 154 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/KuaishouAccountSpeedExploreLogController.java
  3. 4 24
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  4. 2 2
      jeecg-boot-module-system/src/main/resources/application-test.yml
  5. 5 0
      jeecg-boot-module-system/src/main/resources/application-wps.yml
  6. 6 12
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  7. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/StatusCode.java
  8. 11 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouEtlVideoJob.java
  9. 31 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouGroupExploreJob.java
  10. 3 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAdvertiserStrategy.java
  11. 48 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouAccountSpeedExploreLog.java
  12. 37 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouGroupSpeedExploreLog.java
  13. 23 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouAccountSpeedExploreLogMapper.java
  14. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouGroupSpeedExploreLogMapper.java
  15. 49 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouAccountSpeedExploreLogMapper.xml
  16. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouGroupSpeedExploreLogMapper.xml
  17. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAdvertiserStrategyService.java
  18. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouAccountSpeedExploreLogService.java
  19. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouGroupSpeedExploreLogService.java
  20. 9 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAdvertiserStrategyServiceImpl.java
  21. 103 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouAccountSpeedExploreLogServiceImpl.java
  22. 18 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouGroupSpeedExploreLogServiceImpl.java
  23. 18 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/vo/SpeedExploreGroupVO.java
  24. 6 53
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroup.java
  25. 4 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupMapper.xml
  26. 7 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  27. 4 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/service/impl/KuaishouWebInterfaceServiceImpl.java
  28. 4 108
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaishouGroupExploreController.java
  29. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KsVideoReportMapper.java
  30. 45 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KsVideoReportMapper.xml
  31. 11 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouGroupExploreService.java
  32. 7 11
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/AccountReportServiceImpl.java
  33. 5 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KsVideoReportServiceImpl.java
  34. 45 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouGroupExploreServiceImpl.java
  35. 3 3
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/xml/ByteDanceVideoInfoMapper.xml
  36. 3 3
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceReportMaterialDailyMapper.java
  37. 3 3
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceReportMaterialDailyMapper.xml
  38. 3 5
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceReportServiceImpl.java

+ 22 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAdvertiserStrategyController.java

@@ -1,5 +1,6 @@
-package cn.com.ctop.kuaishou.modules.ai.controller;
+package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.QueryGenerator;
@@ -13,7 +14,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.system.service.ISysRoleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -33,7 +37,8 @@ import java.util.*;
 public class AiKuaishouAdvertiserStrategyController {
     @Autowired
     private IAiKuaishouAdvertiserStrategyService aiKuaishouAdvertiserStrategyService;
-
+    @Autowired
+    private ISysRoleService sysRoleService;
     /**
      * 分页列表查询
      *
@@ -51,6 +56,11 @@ public class AiKuaishouAdvertiserStrategyController {
                                                                      HttpServletRequest req) {
         Result<IPage<AiKuaishouAdvertiserStrategy>> result = new Result<>();
         QueryWrapper<AiKuaishouAdvertiserStrategy> queryWrapper = QueryGenerator.initQueryWrapper(aiKuaishouAdvertiserStrategy, req.getParameterMap());
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String roleCode = sysRoleService.getRoleCodeByUserId(user.getId());
+        if(!CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode)){
+            queryWrapper.eq("user_id", user.getId());
+        }
         Page<AiKuaishouAdvertiserStrategy> page = new Page<>(pageNo, pageSize);
         queryWrapper.orderByDesc("id");
         IPage<AiKuaishouAdvertiserStrategy> pageList = aiKuaishouAdvertiserStrategyService.page(page, queryWrapper);
@@ -86,6 +96,16 @@ public class AiKuaishouAdvertiserStrategyController {
     public Result<AiKuaishouAdvertiserStrategy> add(@RequestBody AiKuaishouAdvertiserStrategy aiKuaishouAdvertiserStrategy) {
         Result<AiKuaishouAdvertiserStrategy> result = new Result<>();
         try {
+            Long accountId = aiKuaishouAdvertiserStrategy.getAccountId();
+            AiKuaishouAdvertiserStrategy getEntity = aiKuaishouAdvertiserStrategyService.getByAccountId(accountId);
+            if(null!=getEntity){
+                result.error500("该账户配置信息已经被创建");
+                return result;
+            }
+            UserAllocation allocation = allocationService.getByAccountId(accountId);
+            if(null!=allocation){
+                aiKuaishouAdvertiserStrategy.setUserId(allocation.getUserId());
+            }
             Integer singleAppId = aiKuaishouAdvertiserStrategy.getSingleAppid();
             if (null != singleAppId && singleAppId == 1) {
                 Integer appId = Integer.parseInt(JSONArray.parseArray(aiKuaishouAdvertiserStrategy.getAppIdArray()).getString(0));

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

@@ -0,0 +1,154 @@
+package org.jeecg.modules.ctop.controller;
+
+import cn.com.ctop.common.module.utils.QueryGenerator;
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAccountSpeedExploreLog;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAccountSpeedExploreLogService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.vo.LoginUser;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 快手账户加速探索触发记录信息
+ * @author jeecg-boot
+ * @date   2021-03-08
+ * @version V1.0
+ */
+@Slf4j
+@RestController
+@RequestMapping("/ctop/kuaishouAccountSpeedExploreLog")
+public class KuaishouAccountSpeedExploreLogController {
+	@Autowired
+	private IKuaishouAccountSpeedExploreLogService kuaishouAccountSpeedExploreLogService;
+
+	/**
+	  * 分页列表查询
+	 * @param kuaishouAccountSpeedExploreLog
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@GetMapping(value = "/list")
+	public Result<IPage<KuaishouAccountSpeedExploreLog>> queryPageList(KuaishouAccountSpeedExploreLog kuaishouAccountSpeedExploreLog,
+																	   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+																	   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+																	   HttpServletRequest req) {
+		Result<IPage<KuaishouAccountSpeedExploreLog>> result = new Result<>();
+		QueryWrapper<KuaishouAccountSpeedExploreLog> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouAccountSpeedExploreLog, req.getParameterMap());
+		Page<KuaishouAccountSpeedExploreLog> page = new Page<>(pageNo, pageSize);
+		IPage<KuaishouAccountSpeedExploreLog> pageList = kuaishouAccountSpeedExploreLogService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+
+	/**
+	  *   添加
+	 * @param kuaishouAccountSpeedExploreLog
+	 * @return
+	 */
+	@PostMapping(value = "/open")
+	public Map<String,Object> add(@RequestBody KuaishouAccountSpeedExploreLog kuaishouAccountSpeedExploreLog) {
+		Map<String,Object>result = new HashMap<>();
+		try {
+			LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+			kuaishouAccountSpeedExploreLog.setUserId(user.getId());
+			//1:查询此账户当前是否存在正在加速探索的账户
+			if(null!=kuaishouAccountSpeedExploreLog.getConvertType()&&(kuaishouAccountSpeedExploreLog.getConvertType()==2||kuaishouAccountSpeedExploreLog.getConvertType()==180||kuaishouAccountSpeedExploreLog.getConvertType()==53||kuaishouAccountSpeedExploreLog.getConvertType()==190)){
+				return kuaishouAccountSpeedExploreLogService.openSpeedExplore(kuaishouAccountSpeedExploreLog);
+			}else {
+				ResultMapUtils.setResultMap(result, StatusCode.KUAISHOU_SPEED_EXPLORE_ACTION_TYPE_NOT_CONFIG);
+				return result;
+			}
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			ResultMapUtils.setResultMap(result, StatusCode.COMMON_SERVER_ERROR);
+			return result;
+		}
+	}
+
+	/**
+	  *  编辑
+	 * @param kuaishouAccountSpeedExploreLog
+	 * @return
+	 */
+	@PutMapping(value = "/edit")
+	public Result<KuaishouAccountSpeedExploreLog> edit(@RequestBody KuaishouAccountSpeedExploreLog kuaishouAccountSpeedExploreLog) {
+		Result<KuaishouAccountSpeedExploreLog> result = new Result<>();
+		KuaishouAccountSpeedExploreLog kuaishouAccountSpeedExploreLogEntity = kuaishouAccountSpeedExploreLogService.getById(kuaishouAccountSpeedExploreLog.getId());
+		if(kuaishouAccountSpeedExploreLogEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = kuaishouAccountSpeedExploreLogService.updateById(kuaishouAccountSpeedExploreLog);
+			if(ok) {
+				result.success("修改成功!");
+			}
+		}
+
+		return result;
+	}
+
+	/**
+	  *   通过id删除
+	 * @param id
+	 * @return
+	 */
+	@DeleteMapping(value = "/delete")
+	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
+		try {
+			kuaishouAccountSpeedExploreLogService.removeById(id);
+		} catch (Exception e) {
+			log.error("删除失败",e.getMessage());
+			return Result.error("删除失败!");
+		}
+		return Result.ok("删除成功!");
+	}
+
+	/**
+	  *  批量删除
+	 * @param ids
+	 * @return
+	 */
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<KuaishouAccountSpeedExploreLog> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		Result<KuaishouAccountSpeedExploreLog> result = new Result<>();
+		if(ids==null || "".equals(ids.trim())) {
+			result.error500("参数不识别!");
+		}else {
+			this.kuaishouAccountSpeedExploreLogService.removeByIds(Arrays.asList(ids.split(",")));
+			result.success("删除成功!");
+		}
+		return result;
+	}
+
+	/**
+	  * 通过id查询
+	 * @param id
+	 * @return
+	 */
+	@GetMapping(value = "/queryById")
+	public Result<KuaishouAccountSpeedExploreLog> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<KuaishouAccountSpeedExploreLog> result = new Result<>();
+		KuaishouAccountSpeedExploreLog kuaishouAccountSpeedExploreLog = kuaishouAccountSpeedExploreLogService.getById(id);
+		if(kuaishouAccountSpeedExploreLog==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(kuaishouAccountSpeedExploreLog);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+}

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

@@ -23,7 +23,6 @@ import cn.com.ctop.toutiao.modules.report.service.*;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.xxl.job.core.context.XxlJobHelper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.ibatis.annotations.Param;
@@ -1367,35 +1366,16 @@ public class TestController {
         return result;
     }
 
-    private ExecutorService executor = Executors.newFixedThreadPool(10);
-    private CountDownLatch countDownLatch;
     @Autowired
     IBytedanceVideoReportService bytedanceVideoReportService;
     @Autowired
     IETLReportBytedanceVideoService etlReportBytedanceVideoService;
     @GetMapping("execute")
-    public Map<String,Object> execute(String date) throws Exception {
+    public Map<String,Object> execute(Long accountId) throws Exception {
         Map<String,Object>result = new HashMap<>();
-//        List<CtopOauthToken> tokens = oauthTokenService.selectToutiaoToken();
-//        countDownLatch = new CountDownLatch(tokens.size());
-//        tokens.forEach(token -> executor.submit(() -> {
-//            try {
-//                bytedanceVideoReportService.pullVideoReport(token,date,date,1);
-//            } catch (Exception e) {
-//                XxlJobHelper.log("头条视频报表基础数据拉取异常:{}",e.getMessage());
-//            } finally {
-//                countDownLatch.countDown();
-//            }
-//        }));
-//        try {
-//            countDownLatch.await();
-//        } catch (InterruptedException e) {
-//            e.printStackTrace();
-//        }
-        Map<String,Object> params = new HashMap<>();
-        params.put("stat_datetime",date);
-        etlReportBytedanceVideoService.removeByMap(params);
-        etlReportBytedanceVideoService.cleanETL(date);
+        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        kuaishouInterfaceService.getGroupList(token,new Date(),new Date());
+        kuaishouInterfaceService.getAdvertiserGroupReportDaily(token,new Date(),new Date());
         ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
         return result;
     }

+ 2 - 2
jeecg-boot-module-system/src/main/resources/application-test.yml

@@ -1,5 +1,5 @@
 server:
-  port: 8804
+  port: 8806
   servlet:
     context-path: /jeecg-boot
     compression:
@@ -97,7 +97,7 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
-          url: jdbc:mysql://139.186.151.174:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true
+          url: jdbc:mysql://139.186.165.84:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true
           username: hcst
           password: hcst@2020
           driver-class-name: com.mysql.jdbc.Driver

+ 5 - 0
jeecg-boot-module-system/src/main/resources/application-wps.yml

@@ -96,6 +96,11 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
 #        master:
+#          url: jdbc:mysql://139.186.27.96:4000/jiaoyang?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+#          username: data
+#          password: hcst@2021
+#          driver-class-name: com.mysql.jdbc.Driver
+#        master:
 #          url: jdbc:mysql://139.186.151.174:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true
 #          username: hcst
 #          password: hcst@2020

+ 6 - 12
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -387,7 +387,8 @@ public class SampleTest {
     private IByteDanceVideoReportDailyService videoReportDailyService;
 
     @Test
-    public void formatVideoReportData() {
+    synchronized public void formatVideoReportData() {
+
         for (int i = 1; i < 45; i++) {
             Date getDate = DateUtils.addDay(new Date(), -i);
             String date = DateUtils.formatDate(getDate);
@@ -418,11 +419,6 @@ public class SampleTest {
     public void loadBDAccoutData() {
         CtopOauthToken token2 = tokenService.getTokenByAccountId(1674206482908163L);
         bytedanceReportService.bytedanceMaterialReport(token2, "2020-10-14", "2020-10-14");
-        bytedanceReportMaterialDailyMapper.updateImageReportCode();
-        bytedanceReportMaterialDailyMapper.updateImageReportProjectId();
-        bytedanceReportMaterialDailyMapper.updateImageReportProjectName();
-        bytedanceReportMaterialDailyMapper.updateImageReportPlaneId();
-        bytedanceReportMaterialDailyMapper.updateImageReportPlaneName();
     }
 
     @Resource
@@ -587,11 +583,9 @@ public class SampleTest {
     private IEtlKuaishouVideoInfoService videoEtlInfoService;
     @Test
     public void etlKuaishouVideoInfo(){
-        Date startDate = DateUtils.parseDate("2020-09-11","yyyy-MM-dd");
-        for(int i=0;i<365;i++){
-//            dailyService.etlKuaishouAccountMaterialReportDailyData(DateUtils.formatDate(DateUtils.addDay(startDate,i)));
-            videoEtlInfoService.etlKuaishouVideoInfo(DateUtils.formatDate(DateUtils.addDay(startDate,i)));
-        }
+        String startDate = "2021-01-01";
+        String endDate = "2021-01-31";
+        CtopOauthToken token = tokenService.getTokenByAccountId(9556227L);
+        kuaishouInterfaceService.getAdvertiserReportDaily(token, DateUtils.parseDate(startDate,"yyyy-MM-dd"), DateUtils.parseDate(endDate,"yyyy-MM-dd"));
     }
-
 }

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/StatusCode.java

@@ -57,6 +57,11 @@ public enum StatusCode {
 
     BYTEDACNE_API_GROUP_CREATE_ERROR("头条API创建广告组异常",-4001,false),
 
+    KUAISHOU_API_ACCOUNT_SPEED_EXPLORING("此账户加速探索尚未完成",-5001,false),
+
+    KUAISHOU_SPEED_EXPLORE_ACTION_TYPE_NOT_CONFIG("加速探索尚不支持此类优化目标",-6001,false),
+    KUAISHOU_SPEED_EXPLORE_FAIL("加速探索失败",-6002,false),
+
     KUAISHOU_CRAWLER_APP_SUCCESS("爬虫运行正常", 0, true),
     KUAISHOU_CRAWLER_APP_TASK_END("爬虫任务运行结束", 1, true),
     KUAISHOU_CRAWLER_APP_JOB_StART("任务开始执行开始", 0, true),

+ 11 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouEtlVideoJob.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.job.kuaishou.handler;
 
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
+import cn.com.ctop.kuaishou.modules.material.service.IEtlKuaishouVideoInfoService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouVideoEtlInfoService;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import org.jeecg.common.util.DateUtils;
@@ -15,6 +16,9 @@ public class KuaishouEtlVideoJob {
     private IKuaishouVideoEtlInfoService kuaishouVideoEtlInfoService;
     @Autowired
     private IKuaiShouVideoGetService videoGetService;
+    @Autowired
+    private IEtlKuaishouVideoInfoService videoEtlInfoService;
+
 
     @XxlJob("kuaishouEtlVideoJob")
     public void execute() throws Exception {
@@ -40,5 +44,12 @@ public class KuaishouEtlVideoJob {
         videoGetService.etlVideoBaseInfoByStaDate(statDate);
     }
 
+    @XxlJob("etlFinalKuaishouVideoInfo")
+    public void etlKuaishouVideoInfo(){
+        Date startDate = DateUtils.addDay(new Date(), -2);
+        for(int i=0;i<=2;i++){
+            videoEtlInfoService.etlKuaishouVideoInfo(DateUtils.formatDate(DateUtils.addDay(startDate,i)));
+        }
+    }
 
 }

+ 31 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouGroupExploreJob.java

@@ -0,0 +1,31 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouGroupExploreService;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.text.ParseException;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Component
+public class KuaishouGroupExploreJob {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouGroupExploreService kuaishouGroupExploreService;
+    static ExecutorService executorService = Executors.newFixedThreadPool(5);
+    @XxlJob("kuaishouGroupExploreReportJob")
+    public void execute() throws ParseException {
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        tokens.forEach(token -> executorService.submit(() ->
+                kuaishouGroupExploreService.getReportByAccount(token))
+        );
+        XxlJobHelper.log("快手物料数据同步完成");
+    }
+}

+ 3 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAdvertiserStrategy.java

@@ -1,10 +1,6 @@
 package cn.com.ctop.kuaishou.modules.ai.entity;
 
-import cn.com.ctop.common.module.annotation.Dict;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.*;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
@@ -26,6 +22,8 @@ public class AiKuaishouAdvertiserStrategy {
 	private Long id;
 	/**账户ID*/
 	private Long accountId;
+	private String userId;
+	private Integer channelType;
 	/**策略状态 1-使用 0-停用*/
 	private Integer status;
 	/**客户要求的计划名称规范*/

+ 48 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouAccountSpeedExploreLog.java

@@ -0,0 +1,48 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 快手账户加速探索触发记录信息
+ * @author jeecg-boot
+ * @date   2021-03-08
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_kuaishou_account_speed_explore_log")
+@EqualsAndHashCode(callSuper = false)
+public class KuaishouAccountSpeedExploreLog {
+
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**accountId*/
+	private Long accountId;
+	/**groupAccount*/
+	private BigDecimal groupAccount;
+	/**groupCount*/
+	private Integer groupCount;
+	private Integer convertType;
+	/**convertCount*/
+	private Integer convertCount;
+	/**userId*/
+	private String userId;
+	/**
+	 * status
+	 * 0:默认
+	 * 1:探索中
+	 * 2:探索完成
+	 * */
+	private Integer status;
+	/**createTime*/
+	private Date createTime;
+	/**updateTime*/
+	private Date updateTime;
+}

+ 37 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouGroupSpeedExploreLog.java

@@ -0,0 +1,37 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 快手组级别加速探索执行记录
+ * @author jeecg-boot
+ * @date   2021-03-10
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_kuaishou_group_speed_explore_log")
+public class KuaishouGroupSpeedExploreLog {
+
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**accountId*/
+	private Long accountId;
+	/**accountExploreId*/
+	private Long accountExploreId;
+	/**unitId*/
+	private Long unitId;
+	/**status*/
+	private Integer status;
+	/**message*/
+	private String message;
+	/**createTime*/
+	private Date createTime;
+	/**updateTime*/
+	private Date updateTime;
+}

+ 23 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouAccountSpeedExploreLogMapper.java

@@ -0,0 +1,23 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAccountSpeedExploreLog;
+import cn.com.ctop.kuaishou.modules.ai.vo.SpeedExploreGroupVO;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 快手账户加速探索触发记录信息
+ * @author: jeecg-boot
+ * @date:   2021-03-08
+ * @cersion: V1.0
+ */
+public interface KuaishouAccountSpeedExploreLogMapper extends BaseMapper<KuaishouAccountSpeedExploreLog> {
+
+    List<SpeedExploreGroupVO> getSpeedExploreGroupVosByParams(@Param(value = "date") String date,
+                                                              @Param(value = "accountId")Long accountId,
+                                                              @Param(value = "convertType")Integer convertType,
+                                                              @Param(value = "convertCount")Integer convertCount,
+                                                              @Param(value = "groupCount")Integer groupCount);
+}

+ 14 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouGroupSpeedExploreLogMapper.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouGroupSpeedExploreLog;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 快手组级别加速探索执行记录
+ * @author: jeecg-boot
+ * @date:   2021-03-10
+ * @cersion: V1.0
+ */
+public interface KuaishouGroupSpeedExploreLogMapper extends BaseMapper<KuaishouGroupSpeedExploreLog> {
+
+}

+ 49 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouAccountSpeedExploreLogMapper.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouAccountSpeedExploreLogMapper">
+
+    <select id="getSpeedExploreGroupVosByParams"
+            resultType="cn.com.ctop.kuaishou.modules.ai.vo.SpeedExploreGroupVO">
+        select *from (select report.account_id,
+                report.unit_id,
+                report.campaign_id,
+                report.charge,
+                report.activation,
+                report.bclick,
+                report.form_count,
+                report.event_pay,
+        <if test="convertType=180">
+            (case when activation=0 then 0 else round(report.charge/report.activation,2) end)as account,
+        </if>
+        <if test="convertType=2">
+            (case when bclick=0 then 0 else round(report.charge/report.bclick,2) end)as account,
+        </if>
+        <if test="convertType=53">
+            (case when form_count=0 then 0 else round(report.charge/report.form_count,2) end)as account,
+        </if>
+        <if test="convertType=190">
+            (case when event_pay=0 then 0 else round(report.charge/report.event_pay,2) end)as account,
+        </if>
+        round(g.cpa_bid/1000,2) as cpaBid
+         from ctop_kuaishou_group g
+                  left join ctop_kuaishou_report_daily_group report
+                            on report.unit_id = g.unit_id and report.stat_date = #{date}
+         where g.study_status = 1
+           and g.group_create_time like '2021-03-10%'
+           and g.account_id = #{accountId}
+           and report.account_id is not null
+        <if test="convertType=180">
+            and report.activation >= #{convertCount}
+        </if>
+        <if test="convertType=2">
+            and report.bclick >= #{convertCount}
+        </if>
+        <if test="convertType=53">
+            and report.form_count >= #{convertCount}
+        </if>
+        <if test="convertType=190">
+            and report.event_pay >= #{convertCount}
+        </if>) a
+where a.cpaBid>a.activation_account order by a.account limit #{groupCount}
+    </select>
+</mapper>

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouGroupSpeedExploreLogMapper.xml

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

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAdvertiserStrategyService.java

@@ -11,4 +11,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IAiKuaishouAdvertiserStrategyService extends IService<AiKuaishouAdvertiserStrategy> {
 
+    AiKuaishouAdvertiserStrategy getByAccountId(Long accountId);
+
 }

+ 19 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouAccountSpeedExploreLogService.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAccountSpeedExploreLog;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.Map;
+
+/**
+ * @Description: 快手账户加速探索触发记录信息
+ * @Author: jeecg-boot
+ * @Date:   2021-03-08
+ * @Version: V1.0
+ */
+public interface IKuaishouAccountSpeedExploreLogService extends IService<KuaishouAccountSpeedExploreLog> {
+
+    Map<String, Object> openSpeedExplore(KuaishouAccountSpeedExploreLog kuaishouAccountSpeedExploreLog)throws Exception;
+
+    KuaishouAccountSpeedExploreLog getByParams(Long accountId, Integer status);
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouGroupSpeedExploreLog;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 快手组级别加速探索执行记录
+ * @Author: jeecg-boot
+ * @Date:   2021-03-10
+ * @Version: V1.0
+ */
+public interface IKuaishouGroupSpeedExploreLogService extends IService<KuaishouGroupSpeedExploreLog> {
+
+}

+ 9 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAdvertiserStrategyServiceImpl.java

@@ -3,6 +3,7 @@ package cn.com.ctop.kuaishou.modules.ai.service.impl;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
 import cn.com.ctop.kuaishou.modules.ai.mapper.AiKuaishouAdvertiserStrategyMapper;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAdvertiserStrategyService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
@@ -15,4 +16,12 @@ import org.springframework.stereotype.Service;
 @Service
 public class AiKuaishouAdvertiserStrategyServiceImpl extends ServiceImpl<AiKuaishouAdvertiserStrategyMapper, AiKuaishouAdvertiserStrategy> implements IAiKuaishouAdvertiserStrategyService {
 
+    @Override
+    public AiKuaishouAdvertiserStrategy getByAccountId(Long accountId) {
+        QueryWrapper<AiKuaishouAdvertiserStrategy>queryWrapper =new QueryWrapper<>();
+        queryWrapper.eq("account_id",accountId);
+        queryWrapper.orderByDesc("id");
+        queryWrapper.last("limit 1");
+        return this.getOne(queryWrapper);
+    }
 }

+ 103 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouAccountSpeedExploreLogServiceImpl.java

@@ -0,0 +1,103 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAccountSpeedExploreLog;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouAccountSpeedExploreLogMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAccountSpeedExploreLogService;
+import cn.com.ctop.kuaishou.modules.ai.vo.SpeedExploreGroupVO;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouGroupExploreService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 快手账户加速探索触发记录信息
+ * @author jeecg-boot
+ * @date   2021-03-08
+ * @version V1.0
+ */
+@Service
+public class KuaishouAccountSpeedExploreLogServiceImpl extends ServiceImpl<KuaishouAccountSpeedExploreLogMapper, KuaishouAccountSpeedExploreLog> implements IKuaishouAccountSpeedExploreLogService {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+    @Autowired
+    private IKuaishouGroupExploreService kuaishouGroupExploreService;
+    @Resource
+    private KuaishouAccountSpeedExploreLogMapper kuaishouAccountSpeedExploreLogMapper;
+    @Override
+    public Map<String, Object> openSpeedExplore(KuaishouAccountSpeedExploreLog kuaishouAccountSpeedExploreLog) throws Exception{
+        Map<String,Object> result = new HashMap<>();
+        //查询当前账户是否加速探索中
+        KuaishouAccountSpeedExploreLog getEntity = this.getByParams(kuaishouAccountSpeedExploreLog.getAccountId(),1);
+        if(null!=getEntity){
+            ResultMapUtils.setResultMap(result, StatusCode.KUAISHOU_API_ACCOUNT_SPEED_EXPLORING);
+            return result;
+        }
+        //创建加速探索记录
+        kuaishouAccountSpeedExploreLog.setStatus(1);
+        this.save(kuaishouAccountSpeedExploreLog);
+        //触发加速探索任务
+        this.startSpeedExplore(kuaishouAccountSpeedExploreLog);
+        return result;
+    }
+
+    private void startSpeedExplore(KuaishouAccountSpeedExploreLog kuaishouAccountSpeedExploreLog) throws Exception{
+        Date endDate = new Date();
+        String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.formatDate(endDate), -1);
+        SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
+        Date startDate = sim.parse(anotherDay);
+        CtopOauthToken token = tokenService.getTokenByAccountId(kuaishouAccountSpeedExploreLog.getAccountId());
+        //1: 拉取账户下所有的广告组信息
+        kuaishouInterfaceService.getGroupList(token, startDate, endDate);
+        //2: 查询处于学习期的广告组数据
+        kuaishouInterfaceService.getAdvertiserGroupReportDaily(token,startDate,endDate);
+        //3:根据转化目标查询相应的符合条件的广告组数据
+        //优化目标 2 行为数 180 激活数 53 表单数 190 付费 191 首日ROI
+        Integer convertType = kuaishouAccountSpeedExploreLog.getConvertType();
+        //查询相关符合条件的广告组数据
+        List<SpeedExploreGroupVO> speedExploreGroupVos = this.getSpeedExploreGroupVOSByParams(DateUtils.formatDate(endDate),kuaishouAccountSpeedExploreLog.getAccountId(),kuaishouAccountSpeedExploreLog.getConvertType(),kuaishouAccountSpeedExploreLog.getConvertCount(),kuaishouAccountSpeedExploreLog.getGroupCount());
+        if(null==speedExploreGroupVos||speedExploreGroupVos.isEmpty()){
+            speedExploreGroupVos.forEach(speedExploreGroupVO -> {
+                //触发加速探索逻辑
+                kuaishouGroupExploreService.unitOpenSpeedExplore(speedExploreGroupVO.getAccountId(),speedExploreGroupVO.getUnitId(),kuaishouAccountSpeedExploreLog.getGroupAccount(),kuaishouAccountSpeedExploreLog.getId());
+                //缺广告组加速探索记录数据表
+
+            });
+        }
+
+
+    }
+
+    private List<SpeedExploreGroupVO> getSpeedExploreGroupVOSByParams(String date, Long accountId, Integer convertType, Integer convertCount,Integer groupCount) {
+        return kuaishouAccountSpeedExploreLogMapper.getSpeedExploreGroupVosByParams(date,accountId,convertType,convertCount,groupCount);
+    }
+
+    @Override
+    public KuaishouAccountSpeedExploreLog getByParams(Long accountId, Integer status) {
+        QueryWrapper<KuaishouAccountSpeedExploreLog> queryWrapper = new QueryWrapper<>();
+        if(null!=accountId&&accountId!=0){
+            queryWrapper.eq("account_id",accountId);
+        }
+        if(null!=status){
+            queryWrapper.eq("status",accountId);
+        }
+        queryWrapper.orderByDesc("id");
+        queryWrapper.last("limit 1");
+        return this.getOne(queryWrapper);
+    }
+}

+ 18 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouGroupSpeedExploreLogServiceImpl.java

@@ -0,0 +1,18 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouGroupSpeedExploreLog;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouGroupSpeedExploreLogMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouGroupSpeedExploreLogService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 快手组级别加速探索执行记录
+ * @author jeecg-boot
+ * @date   2021-03-10
+ * @version V1.0
+ */
+@Service
+public class KuaishouGroupSpeedExploreLogServiceImpl extends ServiceImpl<KuaishouGroupSpeedExploreLogMapper, KuaishouGroupSpeedExploreLog> implements IKuaishouGroupSpeedExploreLogService {
+
+}

+ 18 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/vo/SpeedExploreGroupVO.java

@@ -0,0 +1,18 @@
+package cn.com.ctop.kuaishou.modules.ai.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class SpeedExploreGroupVO {
+    private Long accountId;
+    private Long unitId;
+    private Long campaignId;
+    private BigDecimal charge;
+    private Long activation;
+    private Long bclick;
+    private Long formCount;
+    private Long eventPay;
+    private BigDecimal account;
+}

+ 6 - 53
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroup.java

@@ -3,14 +3,10 @@ package cn.com.ctop.kuaishou.modules.batch.entity;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import org.jeecgframework.poi.excel.annotation.Excel;
-import org.springframework.format.annotation.DateTimeFormat;
 
 import java.util.Date;
 
@@ -31,19 +27,14 @@ public class KuaiShouGroup {
      * id
      */
     @TableId
-    @ApiModelProperty(value = "id")
     private String id;
     /**
      * 账户ID
      */
-    @Excel(name = "账户ID", width = 15)
-    @ApiModelProperty(value = "账户ID")
     private Long accountId;
     /**
      * 广告活动ID
      */
-    @Excel(name = "广告活动ID", width = 15)
-    @ApiModelProperty(value = "广告活动ID")
     private Long campaignId;
 
     @TableField(exist = false)
@@ -51,46 +42,33 @@ public class KuaiShouGroup {
     /**
      * 广告组ID
      */
-    @Excel(name = "广告组ID", width = 15)
-    @ApiModelProperty(value = "广告组ID")
     private Long unitId;
     /**
      * 广告组名称
      */
-    @Excel(name = "广告组名称", width = 15)
-    @ApiModelProperty(value = "广告组名称")
     private String unitName;
     /**
      * 广告组状态
      */
-    @Excel(name = "广告组状态", width = 15)
-    @ApiModelProperty(value = "广告组状态")
     private Integer status;
     private Integer putStatus;
+    private Integer studyStatus;
     private Integer createChannel;
     /**
      * 审核拒绝理由
      */
-    @Excel(name = "审核拒绝理由", width = 15)
-    @ApiModelProperty(value = "审核拒绝理由")
     private String reviewDetail;
     /**
      * 出价类型
      */
-    @Excel(name = "出价类型", width = 15)
-    @ApiModelProperty(value = "出价类型")
     private Integer bidType;
     /**
      * 出价
      */
-    @Excel(name = "出价", width = 15)
-    @ApiModelProperty(value = "出价")
     private Long bid;
     /**
      * OCPC出价
      */
-    @Excel(name = "OCPC出价", width = 15)
-    @ApiModelProperty(value = "OCPC出价")
     private Long cpaBid;
 
     private Integer deepConversionType;
@@ -99,32 +77,22 @@ public class KuaiShouGroup {
     /**
      * OCPX行为类型   1: CPM, 2: CPC,
      */
-    @Excel(name = "OCPX行为类型   1: CPM, 2: CPC,", width = 15)
-    @ApiModelProperty(value = "OCPX行为类型   1: CPM, 2: CPC,")
     private Integer ocpxActionType;
     /**
      * 单日预算
      */
-    @Excel(name = "单日预算", width = 15)
-    @ApiModelProperty(value = "单日预算")
     private Long dayBudget;
     /**
      * 投放方式  0:未知, 1:正常投
      */
-    @Excel(name = "投放方式  0:未知, 1:正常投", width = 15)
-    @ApiModelProperty(value = "投放方式  0:未知, 1:正常投")
     private Integer speed;
     /**
      * 投放开始时间
      */
-    @Excel(name = "投放开始时间", width = 15)
-    @ApiModelProperty(value = "投放开始时间")
     private String beginTime;
     /**
      * 投放结束时间
      */
-    @Excel(name = "投放结束时间", width = 15)
-    @ApiModelProperty(value = "投放结束时间")
     private String endTime;
     private String scheduleTime;
     private String sceneId;
@@ -132,38 +100,31 @@ public class KuaiShouGroup {
     /**
      * 创意展现方式  0:未知, 1:轮播,
      */
-    @Excel(name = "创意展现方式  0:未知, 1:轮播,", width = 15)
-    @ApiModelProperty(value = "创意展现方式  0:未知, 1:轮播,")
     private Integer showMode;
     private Integer unitType;
     /**
      * url类型
      */
-    @Excel(name = "url类型 ", width = 15)
-    @ApiModelProperty(value = "url类型 ")
     private Integer urlType;
     /**
      * 落地页链接
      */
-    @Excel(name = "落地页链接", width = 15)
-    @ApiModelProperty(value = "落地页链接")
     private Object url;
     /**
      * APP ID
      */
-    @Excel(name = "APP ID", width = 15)
-    @ApiModelProperty(value = "APP ID")
     private Long appId;
     /**
      * APP图标存储地址
      */
-    @Excel(name = "APP图标存储地址", width = 15)
-    @ApiModelProperty(value = "APP图标存储地址")
     private String appIconUrl;
 
 
-    private Long convertId; // 转化目标
-    private Integer useAppMarket; // 转化目标
+
+    // 转化目标
+    private Long convertId;
+    // 转化目标
+    private Integer useAppMarket;
     private String groupCreateTime;
     private String groupUpdateTime;
 
@@ -174,18 +135,10 @@ public class KuaiShouGroup {
     /**
      * 创建时间
      */
-    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
-    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
-    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @ApiModelProperty(value = "创建时间")
     private Date createTime;
     /**
      * 修改时间
      */
-    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
-    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
-    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @ApiModelProperty(value = "修改时间")
     private Date updateTime;
 
     @TableField(exist = false)

+ 4 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupMapper.xml

@@ -36,7 +36,8 @@
         group_create_time,
         group_update_time,
         create_time,
-        update_time)
+        update_time,
+        study_status)
         values
         <foreach collection="groups" item="getGroup" separator=",">
             (
@@ -73,7 +74,8 @@
             #{getGroup.groupCreateTime},
             #{getGroup.groupUpdateTime},
             #{getGroup.createTime},
-            #{getGroup.updateTime})
+            #{getGroup.updateTime},
+            #{getGroup.studyStatus})
         </foreach>
     </insert>
 

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

@@ -302,10 +302,12 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         param.put("temporal_granularity", "DAILY");
         param.put("page_size", 2000);
         param.put("page", page);
+        System.out.println(param);
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
         Integer code = resultJson.getInteger("code");
         String message = resultJson.getString("message");
+        System.out.println(resultJson.toJSONString());
         if (null == code || code != 0) {
             log.error("获取快手广告主报表异常:{},accountId:{}", message, token.getAccountId());
             return;
@@ -1131,6 +1133,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
 
+    @Override
     public JSONArray getCampaignList(CtopOauthToken token, Date startDate, Date endDate, int timeFilterType) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CAMPAIGN_LIST;
         Map<String, String> headers = new HashMap<>();
@@ -1229,6 +1232,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         kuaiShouCampaignService.replaceBatch(campaigns);
     }
 
+    @Override
     public JSONArray getGroupList(CtopOauthToken token, Long campaignId, Date startDate,
                                   Date endDate, int time_filter_type) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
@@ -1381,10 +1385,12 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     group.setUnitName(unit_name);
                     group.setStatus(status);
                     group.setPutStatus(put_status);
+                    group.setStudyStatus(detail.getInteger("study_status"));
                     group.setCreateChannel(detail.getInteger("create_channel"));
                     group.setReviewDetail(detail.getString("review_detail"));
                     group.setBidType(bid_type);
                     group.setBid(bid);
+                    group.setStudyStatus(detail.getInteger("study_status"));
                     group.setCpaBid(cpa_bid);
                     group.setOcpxActionType(ocpx_action_type);
                     group.setDeepConversionType(detail.getInteger("deep_conversion_type"));
@@ -1425,6 +1431,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
 
+    @Override
     public JSONArray getCreativeList(CtopOauthToken token, Long unitId, Date startDate, Date endDate, int timeFilterType) {
         Long advertiserId = token.getAccountId();
         String accessToken = token.getAccessToken();

+ 4 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/service/impl/KuaishouWebInterfaceServiceImpl.java

@@ -688,9 +688,10 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
             //设定网址
             webDriver.get(KUAISHOU_BE_DOMAIN_HTTPS);
             //显示等待控制对象
+            webDriver.findElement(By.className("login-now-btn")).click();
             WebDriverWait webDriverWait = new WebDriverWait(webDriver, 10);
-            webDriverWait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".phone input"))).sendKeys(login.getAccountName());
-            webDriverWait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".password input"))).sendKeys(login.getPassword());
+            webDriverWait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[contains(@type,'text')]"))).sendKeys(login.getAccountName());
+            webDriverWait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[contains(@type,'password')]"))).sendKeys(login.getPassword());
             //点击登录
             webDriver.findElement(By.className("foot")).click();
             //等待2秒用于页面加载,保证Cookie响应全部获取。
@@ -711,7 +712,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
                     }
                 }
                 webDriver.switchTo().frame(webDriver.findElement(By.tagName("iframe")));
-                webDriver.findElement(By.xpath("//div[@class='opArea']/span[@id='submit']")).click();
+                webDriver.findElement(By.xpath("//div[@class='ad-login-comp-btn']")).click();
             }
             Thread.sleep(3000L);
 

+ 4 - 108
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaishouGroupExploreController.java

@@ -1,38 +1,20 @@
 package cn.com.ctop.kuaishou.modules.report.controller;
 
-import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.utils.QueryGenerator;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouGroupExplore;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouGroupExploreService;
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.util.oConvertUtils;
-import org.jeecgframework.poi.excel.ExcelImportUtil;
-import org.jeecgframework.poi.excel.def.NormalExcelConstants;
-import org.jeecgframework.poi.excel.entity.ExportParams;
-import org.jeecgframework.poi.excel.entity.ImportParams;
-import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-import org.springframework.web.multipart.MultipartHttpServletRequest;
-import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
 import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
 
 /**
  * 广告组的加速探索报表
@@ -58,8 +40,6 @@ public class KuaishouGroupExploreController {
      * @param req
      * @return
      */
-    @AutoLog(value = "广告组的加速探索报表-分页列表查询")
-    @ApiOperation(value = "广告组的加速探索报表-分页列表查询", notes = "广告组的加速探索报表-分页列表查询")
     @GetMapping(value = "/list")
     public Result<IPage<KuaishouGroupExplore>> queryPageList(KuaishouGroupExplore kuaishouGroupExplore,
                                                              @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@@ -77,11 +57,9 @@ public class KuaishouGroupExploreController {
     /**
      * 查询加速探索信息接口
      *
-     * @param kuaishouGroupExplore
+     * @param data
      * @return
      */
-    @AutoLog(value = "查询加速探索信息接口")
-    @ApiOperation(value = "查询加速探索信息接口", notes = "查询加速探索信息接口")
     @PostMapping(value = "/unitExploreInfoGet")
     public Result<Object> unitExploreInfoGet(@RequestBody JSONObject data) {
         try {
@@ -95,11 +73,9 @@ public class KuaishouGroupExploreController {
     /**
      * 广告组的加速探索预算设置接口
      *
-     * @param kuaishouGroupExplore
+     * @param data
      * @return
      */
-    @AutoLog(value = "广告组的加速探索预算设置接口")
-    @ApiOperation(value = "广告组的加速探索预算设置接口", notes = "广告组的加速探索预算设置接口")
     @PostMapping(value = "/unitExploreBudgetUpdate")
     public Result<Object> unitExploreBudgetUpdate(@RequestBody JSONObject data) {
         try {
@@ -113,11 +89,9 @@ public class KuaishouGroupExploreController {
     /**
      * 暂停广告组的加速探索预算接口
      *
-     * @param kuaishouGroupExplore
+     * @param data
      * @return
      */
-    @AutoLog(value = "暂停广告组的加速探索预算接口")
-    @ApiOperation(value = "暂停广告组的加速探索预算接口", notes = "暂停广告组的加速探索预算接口")
     @PostMapping(value = "/unitExploreStatusPause")
     public Result<Object> unitExploreStatusPause(@RequestBody JSONObject data) {
         try {
@@ -131,11 +105,9 @@ public class KuaishouGroupExploreController {
     /**
      * 查询广告组的加速探索报表接口
      *
-     * @param kuaishouGroupExplore
+     * @param data
      * @return
      */
-    @AutoLog(value = "查询广告组的加速探索报表接口")
-    @ApiOperation(value = "查询广告组的加速探索报表接口", notes = "查询广告组的加速探索报表接口")
     @PostMapping(value = "/querySpeedExploreReport")
     public Result<Object> querySpeedExploreReport(@RequestBody JSONObject data) {
         try {
@@ -153,8 +125,6 @@ public class KuaishouGroupExploreController {
      * @param kuaishouGroupExplore
      * @return
      */
-    @AutoLog(value = "广告组的加速探索报表-添加")
-    @ApiOperation(value = "广告组的加速探索报表-添加", notes = "广告组的加速探索报表-添加")
     @PostMapping(value = "/add")
     public Result<KuaishouGroupExplore> add(@RequestBody KuaishouGroupExplore kuaishouGroupExplore) {
         Result<KuaishouGroupExplore> result = new Result<>();
@@ -174,8 +144,6 @@ public class KuaishouGroupExploreController {
      * @param kuaishouGroupExplore
      * @return
      */
-    @AutoLog(value = "广告组的加速探索报表-编辑")
-    @ApiOperation(value = "广告组的加速探索报表-编辑", notes = "广告组的加速探索报表-编辑")
     @PutMapping(value = "/edit")
     public Result<KuaishouGroupExplore> edit(@RequestBody KuaishouGroupExplore kuaishouGroupExplore) {
         Result<KuaishouGroupExplore> result = new Result<KuaishouGroupExplore>();
@@ -198,8 +166,6 @@ public class KuaishouGroupExploreController {
      * @param id
      * @return
      */
-    @AutoLog(value = "广告组的加速探索报表-通过id删除")
-    @ApiOperation(value = "广告组的加速探索报表-通过id删除", notes = "广告组的加速探索报表-通过id删除")
     @DeleteMapping(value = "/delete")
     public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
         try {
@@ -217,8 +183,6 @@ public class KuaishouGroupExploreController {
      * @param ids
      * @return
      */
-    @AutoLog(value = "广告组的加速探索报表-批量删除")
-    @ApiOperation(value = "广告组的加速探索报表-批量删除", notes = "广告组的加速探索报表-批量删除")
     @DeleteMapping(value = "/deleteBatch")
     public Result<KuaishouGroupExplore> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
         Result<KuaishouGroupExplore> result = new Result<>();
@@ -237,8 +201,6 @@ public class KuaishouGroupExploreController {
      * @param id
      * @return
      */
-    @AutoLog(value = "广告组的加速探索报表-通过id查询")
-    @ApiOperation(value = "广告组的加速探索报表-通过id查询", notes = "广告组的加速探索报表-通过id查询")
     @GetMapping(value = "/queryById")
     public Result<KuaishouGroupExplore> queryById(@RequestParam(name = "id", required = true) String id) {
         Result<KuaishouGroupExplore> result = new Result<>();
@@ -252,71 +214,5 @@ public class KuaishouGroupExploreController {
         return result;
     }
 
-    /**
-     * 导出excel
-     *
-     * @param request
-     * @param response
-     */
-    @RequestMapping(value = "/exportXls")
-    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
-        // Step.1 组装查询条件
-        QueryWrapper<KuaishouGroupExplore> queryWrapper = null;
-        try {
-            String paramsStr = request.getParameter("paramsStr");
-            if (oConvertUtils.isNotEmpty(paramsStr)) {
-                String deString = URLDecoder.decode(paramsStr, "UTF-8");
-                KuaishouGroupExplore kuaishouGroupExplore = JSON.parseObject(deString, KuaishouGroupExplore.class);
-                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouGroupExplore, request.getParameterMap());
-            }
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-        }
-
-        //Step.2 AutoPoi 导出Excel
-        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
-        List<KuaishouGroupExplore> pageList = kuaishouGroupExploreService.list(queryWrapper);
-        //导出文件名称
-        mv.addObject(NormalExcelConstants.FILE_NAME, "广告组的加速探索报表列表");
-        mv.addObject(NormalExcelConstants.CLASS, KuaishouGroupExplore.class);
-        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("广告组的加速探索报表列表数据", "导出人:Jeecg", "导出信息"));
-        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
-        return mv;
-    }
-
-    /**
-     * 通过excel导入数据
-     *
-     * @param request
-     * @param response
-     * @return
-     */
-    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
-    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
-        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
-        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
-        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
-            MultipartFile file = entity.getValue();
-            ImportParams params = new ImportParams();
-            params.setTitleRows(2);
-            params.setHeadRows(1);
-            params.setNeedSave(true);
-            try {
-                List<KuaishouGroupExplore> listKuaishouGroupExplores = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouGroupExplore.class, params);
-                kuaishouGroupExploreService.saveBatch(listKuaishouGroupExplores);
-                return Result.ok("文件导入成功!数据行数:" + listKuaishouGroupExplores.size());
-            } catch (Exception e) {
-                log.error(e.getMessage(), e);
-                return Result.error("文件导入失败:" + e.getMessage());
-            } finally {
-                try {
-                    file.getInputStream().close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-        return Result.ok("文件导入失败!");
-    }
 
 }

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

@@ -16,4 +16,6 @@ public interface KsVideoReportMapper {
     List<JSONObject> getKuaiShouVideoReportByMap(Map<String, Object> requestMap);
 
     List<JSONObject> getDesignList();
+
+    Long getTotalByMap(Map<String, Object> requestMap);
 }

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

@@ -53,6 +53,50 @@
     </select>
 
 
+    <select id="getTotalByMap" resultType="java.lang.Long">
+        SELECT
+        count(1)
+        FROM
+        (select
+        t1.signature
+        from ctop_etl_kuaishou_account_material_report_daily t1
+        where 1 = 1
+        <if test="accountIds !=null and accountIds != ''">
+            and t1.account_id in
+            <foreach item="item" index="index" collection="accountIds"
+                     open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="startDate !=null and startDate != ''">
+            AND t1.stat_date &gt;= #{startDate}
+        </if>
+        <if test="endDate !=null and endDate != ''">
+            AND t1.stat_date &lt;= #{endDate}
+        </if>
+        GROUP BY t1.signature
+        ) t1
+        LEFT JOIN ctop_etl_kuaishou_video_info t2
+        ON t1.signature = t2.video_code
+        WHERE
+        1 = 1
+        <if test="leaderId !=null and leaderId != ''">
+            AND t2.design_team_leader_id = #{leaderId}
+        </if>
+        <if test="clipId !=null and clipId != ''">
+            AND t2.clip_id = #{clipId}
+        </if>
+        <if test="planId !=null and planId != ''">
+            AND t2.plan_id = #{planId}
+        </if>
+        <if test="shotId !=null and shotId != ''">
+            AND t2.shot_id = #{shotId}
+        </if>
+
+
+    </select>
+
+
     <select id="queryVideoReportBy" resultType="com.alibaba.fastjson.JSONObject">
         SELECT * from (SELECT
         t1.signature,
@@ -150,4 +194,5 @@
 	)
     </select>
 
+
 </mapper>

+ 11 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouGroupExploreService.java

@@ -1,10 +1,13 @@
 package cn.com.ctop.kuaishou.modules.report.service;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouGroupExplore;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.common.api.vo.Result;
 
+import java.math.BigDecimal;
+
 /**
  * @Description: 广告组的加速探索报表
  * @Author: jeecg-boot
@@ -13,11 +16,15 @@ import org.jeecg.common.api.vo.Result;
  */
 public interface IKuaishouGroupExploreService extends IService<KuaishouGroupExplore> {
 
-    public Result<Object> unitExploreInfoGet(JSONObject data);
+    Result<Object> unitExploreInfoGet(JSONObject data);
+
+    Result<Object> unitExploreBudgetUpdate(JSONObject data);
+
+    Result<Object> unitExploreStatusPause(JSONObject data);
 
-    public Result<Object> unitExploreBudgetUpdate(JSONObject data);
+    Result<Object> querySpeedExploreReport(JSONObject data);
 
-    public Result<Object> unitExploreStatusPause(JSONObject data);
+    void unitOpenSpeedExplore(Long accountId, Long unitId, BigDecimal groupAccount,Long accountExploreId);
 
-    public Result<Object> querySpeedExploreReport(JSONObject data);
+    void getReportByAccount(CtopOauthToken token);
 }

+ 7 - 11
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/AccountReportServiceImpl.java

@@ -6,15 +6,12 @@ import cn.com.ctop.kuaishou.modules.report.service.IAccountReportService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import org.jeecg.common.util.DateUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @author yumeng
@@ -22,7 +19,7 @@ import java.util.Map;
  */
 @Service
 public class AccountReportServiceImpl implements IAccountReportService {
-    @Autowired
+    @Resource
     private AccountReportMapper accountReportMapper;
 
     /**
@@ -51,10 +48,8 @@ public class AccountReportServiceImpl implements IAccountReportService {
             String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
             if (type == 1) {
                 // 今日汇总
-                Integer maxHour = accountReportMapper.selectMaxHourByDate(nowDate);
-                if (Check.isNull(maxHour) || maxHour == 0) {
-                    return null;
-                }
+                Calendar calendar = Calendar.getInstance();
+                int maxHour = calendar.get(Calendar.HOUR_OF_DAY);
                 String maxHourStr = String.valueOf(maxHour - 1);
                 // 今日 小时汇总数据
                 accountJson = accountReportMapper.selectSumDayHourlyByHourAndDate(nowDate, maxHourStr, accountIds);
@@ -268,7 +263,8 @@ public class AccountReportServiceImpl implements IAccountReportService {
             if (type == 1) {
                 // 今日汇总
                 if (Check.isNull(statHour)) {
-                    Integer maxHour = accountReportMapper.selectMaxHourByDate(nowDate);
+                    Calendar calendar = Calendar.getInstance();
+                    int maxHour = calendar.get(Calendar.HOUR_OF_DAY);
                     hour = maxHour - 1;
                 } else {
                     hour = statHour;

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

@@ -37,9 +37,11 @@ public class KsVideoReportServiceImpl implements IKsVideoReportService {
 
     @Override
     public PageInfo<JSONObject> getKuaiShouVideoPageReportByMap(Map<String, Object> requestMap, int pageSize, int pageNo) {
-        PageHelper.startPage(pageNo, pageSize);
-        List<JSONObject> jsonObjectList = ksVideoReportMapper.getKuaiShouVideoReportByMap(requestMap);
-        return new PageInfo<>(jsonObjectList);
+        Long total = ksVideoReportMapper.getTotalByMap(requestMap);
+        PageHelper.startPage(pageNo, pageSize, false);
+        PageInfo pageInfo = new PageInfo(ksVideoReportMapper.getKuaiShouVideoReportByMap(requestMap));
+        pageInfo.setTotal(total);
+        return pageInfo;
 
     }
 

+ 45 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouGroupExploreServiceImpl.java

@@ -2,10 +2,9 @@ package cn.com.ctop.kuaishou.modules.report.service.impl;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.utils.Check;
-import cn.com.ctop.common.module.utils.HttpUtils;
-import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
-import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.common.module.utils.*;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouGroupSpeedExploreLog;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouGroupSpeedExploreLogService;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouGroupExplore;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouGroupExploreMapper;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouGroupExploreService;
@@ -17,6 +16,7 @@ import org.jeecg.common.api.vo.Result;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -32,7 +32,8 @@ import java.util.Map;
 public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupExploreMapper, KuaishouGroupExplore> implements IKuaishouGroupExploreService {
     @Autowired
     private ICtopOauthTokenService tokenService;
-
+    @Autowired
+    private IKuaishouGroupSpeedExploreLogService groupSpeedExploreLogService;
 
     /**
      * 查询加速探索信息
@@ -224,5 +225,44 @@ public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupEx
         return Result.error("查询广告组的加速探索报表失败");
     }
 
+    @Override
+    public void unitOpenSpeedExplore(Long accountId, Long unitId, BigDecimal groupAccount,Long accountExploreId) {
+        KuaishouGroupSpeedExploreLog groupSpeedExploreLog = new KuaishouGroupSpeedExploreLog();
+        groupSpeedExploreLog.setAccountExploreId(accountExploreId);
+        groupSpeedExploreLog.setAccountId(accountId);
+        try {
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UNIT_EXPLORE_BUDGET_UPDATE;
+            Map<String, String> header = new HashMap<>();
+            header.put("Access-Token", token.getAccessToken());
+            header.put("Content-Type", "application/json");
+            JSONObject params = new JSONObject();
+            params.put("advertiser_id", accountId);
+            params.put("unit_id", unitId);
+            params.put("explore_budget", groupAccount.longValue());
+            String result = HttpUtils.httpPostRequest(url, params, header);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                String message = resultJson.getString("message");
+                groupSpeedExploreLog.setStatus(code);
+                groupSpeedExploreLog.setMessage(message);
+            }else{
+                groupSpeedExploreLog.setStatus(StatusCode.KUAISHOU_SPEED_EXPLORE_FAIL.getCode());
+                groupSpeedExploreLog.setMessage(StatusCode.KUAISHOU_SPEED_EXPLORE_FAIL.getDesc());
+            }
+        } catch (Exception e) {
+            log.error("广告组的加速探索预算设置失败", e);
+            groupSpeedExploreLog.setStatus(StatusCode.COMMON_SERVER_ERROR.getCode());
+            groupSpeedExploreLog.setMessage(StatusCode.COMMON_SERVER_ERROR.getDesc());
+        }
+        groupSpeedExploreLogService.save(groupSpeedExploreLog);
+    }
+
+    @Override
+    public void getReportByAccount(CtopOauthToken token) {
+        //1:查询此账户下设置了加速探索的组
+    }
+
 
 }

+ 3 - 3
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/xml/ByteDanceVideoInfoMapper.xml

@@ -57,13 +57,13 @@
         update
             ctop_bytedance_video_info
         set type = 2
-        where height &gt; width
-        and (height between 1280 and 2560)  and (width between 720 and 1440);
+        where height &gt; width and type is null
+        and (height between 1280 and 2560)  and (width between 720 and 1440)
     </update>
     <update id="updateVideoHorizonType">
         update ctop_bytedance_video_info
             set type = 1
-        where height &lt; width
+        where height &lt; width and type is null
         and (width between 1280 and 2560)  and (height between 720 and 1440)
     </update>
 </mapper>

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

@@ -47,9 +47,9 @@ public interface BytedanceReportMaterialDailyMapper extends BaseMapper<Bytedance
 );
 
     void replaceImageBatch(@Param("infos")List<BytedanceReportMaterialDaily> bytedanceReportImageDailyList);
-    void updateImageReportCode();
-    void updateImageReportProjectId();
-    void updateImageReportProjectName();
+    void updateImageReportCode(@Param("accountId")Long accountId);
+    void updateImageReportProjectId(@Param("accountId")Long accountId);
+    void updateImageReportProjectName(@Param("accountId")Long accountId);
     void updateImageReportPlaneId();
     void updateImageReportPlaneName();
 

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

@@ -320,17 +320,17 @@
 
     <update id="updateImageReportCode">
         update ctop_bytedance_report_image_daily a inner join ctop_bytedance_image_info image on image.material_id =a.material_id  set a.code = image.signature,a.image_url = image.image_url
-        where a.material_id is not null and a.code is null
+        where a.material_id is not null and a.code is null and a.account_id = #{accountId}
     </update>
 
     <update id="updateImageReportProjectId">
         update ctop_bytedance_report_image_daily a inner join ctop_user_allocation allocation on allocation.account_id =a.account_id  set a.project_id = allocation.project_id
-        where a.account_id is not null and a.project_id is null
+        where a.account_id is not null and a.project_id is null and a.account_id = #{accountId}
     </update>
 
     <update id="updateImageReportProjectName">
         update ctop_bytedance_report_image_daily a inner join ctop_project p on p.id =a.project_id  set a.project_name = p.project_name
-        where a.project_id is not null and a.project_name is null
+        where a.project_id is not null and a.project_name is null and a.account_id = #{accountId}
     </update>
 
     <update id="updateImageReportPlaneId">

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

@@ -516,11 +516,9 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
             retry.setType(1);
             bytedanceReportMaterialDailyMapper.replaceMaterialRetry(retry);
         }
-        bytedanceReportMaterialDailyMapper.updateImageReportCode();
-        bytedanceReportMaterialDailyMapper.updateImageReportProjectId();
-        bytedanceReportMaterialDailyMapper.updateImageReportProjectName();
-        bytedanceReportMaterialDailyMapper.updateImageReportPlaneId();
-        bytedanceReportMaterialDailyMapper.updateImageReportPlaneName();
+        bytedanceReportMaterialDailyMapper.updateImageReportCode(token.getAccountId());
+        bytedanceReportMaterialDailyMapper.updateImageReportProjectId(token.getAccountId());
+        bytedanceReportMaterialDailyMapper.updateImageReportProjectName(token.getAccountId());
         log.info("头条素材报表结束 当前accountId为:{}  {}~{}" , accountId, startDate,endDate);
         return code;
     }