Browse Source

Merge branch 'master' into kuaishou-ai-advertising

liyuyi@c-top.com.cn 4 năm trước cách đây
mục cha
commit
7d2302ab36
44 tập tin đã thay đổi với 1432 bổ sung442 xóa
  1. 0 1
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  2. 3 3
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  3. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IMessageTemplate.java
  4. 16 3
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MessageTemplateImpl.java
  5. 25 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouCampaignCopyDateJob.java
  6. 267 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouCampaignCopyDataController.java
  7. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroup.java
  8. 159 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouCampaignCopyData.java
  9. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCreativeMapper.java
  10. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouGroupMapper.java
  11. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouGroupTargetMapper.java
  12. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouCampaignCopyDataMapper.java
  13. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCreativeMapper.xml
  14. 13 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupMapper.xml
  15. 16 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupTargetMapper.xml
  16. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouCampaignCopyDataMapper.xml
  17. 13 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCreativeService.java
  18. 14 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouGroupService.java
  19. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouGroupTargetService.java
  20. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouCampaignCopyDataService.java
  21. 16 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCreativeServiceImpl.java
  22. 23 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java
  23. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupTargetServiceImpl.java
  24. 497 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouCampaignCopyDataServiceImpl.java
  25. 10 9
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaishouAudienceReportDailyController.java
  26. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouAudienceReportDailyAccount.java
  27. 10 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyAccountMapper.java
  28. 0 7
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyAgeMapper.java
  29. 0 7
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyBusinessMapper.java
  30. 0 7
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyCityMapper.java
  31. 0 7
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyClientMapper.java
  32. 0 8
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyGenderMapper.java
  33. 0 7
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyProvinceMapper.java
  34. 166 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyAccountMapper.xml
  35. 0 47
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyAgeMapper.xml
  36. 0 46
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyBusinessMapper.xml
  37. 2 45
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyCityMapper.xml
  38. 0 45
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyClientMapper.xml
  39. 0 45
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyGenderMapper.xml
  40. 0 45
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyProvinceMapper.xml
  41. 22 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyAccountService.java
  42. 0 21
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyService.java
  43. 68 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyAccountServiceImpl.java
  44. 1 77
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyServiceImpl.java

+ 0 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -56,7 +56,6 @@ public class ShiroConfig {
         Map<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
         // 配置不会被拦截的链接 顺序判断
         //登录接口排除
-        filterChainDefinitionMap.put("/ctop/materialInfo/**", "anon");
         filterChainDefinitionMap.put("/sys/mLogin", "anon");
         filterChainDefinitionMap.put("/sys/login", "anon");
         filterChainDefinitionMap.put("/sys/wxlogin", "anon");

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

@@ -409,12 +409,12 @@ public class SampleTest {
     private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
     @Test
     public void etlBytedanceData(){
-        String dateString = "2020-08-30";
+        String dateString = "2020-07-01";
         Date startDate = DateUtils.parseDate(dateString,"yyyy-MM-dd");
         for(int i=0;i<=310;i++){
             Date getDate = DateUtils.addDay(startDate,i);
-//            bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
-            kuaishouVideoEtlInfoService.etlKuaishouVideoInfo(getDate);
+            bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
+//            kuaishouVideoEtlInfoService.etlKuaishouVideoInfo(getDate);
         }
     }
 

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

@@ -81,4 +81,6 @@ public interface IMessageTemplate {
      * @return
      */
     String getKuaiShouBidMessage(String projectName, Long advertiserId, Long unitId, String unit_name);
+
+    String getCopyCampaignMessage(String oldName, String state);
 }

+ 16 - 3
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MessageTemplateImpl.java

@@ -5,9 +5,6 @@ import cn.com.ctop.common.module.utils.Check;
 import com.alibaba.fastjson.JSONObject;
 import org.springframework.stereotype.Service;
 
-import java.util.Arrays;
-import java.util.List;
-
 @Service
 public class MessageTemplateImpl implements IMessageTemplate {
 
@@ -195,4 +192,20 @@ public class MessageTemplateImpl implements IMessageTemplate {
         return text.toString();
     }
 
+    @Override
+    public String getCopyCampaignMessage(String oldName, String state) {
+        StringBuilder text = new StringBuilder();
+        if ("2".equals(state)) {
+            text.append("广告计划复制成功通知").append("<br/>")
+                    .append("您复制的广告计划:").append(oldName).append("<br/>")
+                    .append("现已复制完成,请知悉");
+        } else {
+            text.append("广告计划复制失败预警").append("<br/>")
+                    .append("您复制的广告计划:").append(oldName).append("<br/>")
+                    .append("复制失败,请您联系管理员或重新执行复制操作!").append("<br/>");
+        }
+        return text.toString();
+    }
+
+
 }

+ 25 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouCampaignCopyDateJob.java

@@ -0,0 +1,25 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouCampaignCopyDataService;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * 定时复制广告计划下的组+创意
+ *
+ * @param
+ * @author ZHAOXA
+ * @return
+ * @throws
+ */
+@Component
+public class KuaishouCampaignCopyDateJob {
+    @Autowired
+    private IKuaishouCampaignCopyDataService kuaishouCampaignCopyDataService;
+
+    @XxlJob("kuaishouCampaignCopyDateJob")
+    public void execute() throws Exception {
+        kuaishouCampaignCopyDataService.batchCopyCampaign();
+    }
+}

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

@@ -0,0 +1,267 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouCampaignCopyData;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouCampaignCopyDataService;
+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.apache.shiro.SecurityUtils;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.system.vo.LoginUser;
+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.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 待复制广告计划数据
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-22
+ */
+@Slf4j
+@Api(tags = "待复制广告计划数据")
+@RestController
+@RequestMapping("/kuaishouCampaignCopyData")
+public class KuaishouCampaignCopyDataController {
+    @Autowired
+    private IKuaishouCampaignCopyDataService kuaishouCampaignCopyDataService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouCampaignCopyData
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "待复制广告计划数据-分页列表查询")
+    @ApiOperation(value = "待复制广告计划数据-分页列表查询", notes = "待复制广告计划数据-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouCampaignCopyData>> queryPageList(KuaishouCampaignCopyData kuaishouCampaignCopyData,
+                                                                 @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                 HttpServletRequest req) {
+        Result<IPage<KuaishouCampaignCopyData>> result = new Result<>();
+        QueryWrapper<KuaishouCampaignCopyData> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouCampaignCopyData, req.getParameterMap());
+        Page<KuaishouCampaignCopyData> page = new Page<KuaishouCampaignCopyData>(pageNo, pageSize);
+        IPage<KuaishouCampaignCopyData> pageList = kuaishouCampaignCopyDataService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaishouCampaignCopyData
+     * @return
+     */
+    @AutoLog(value = "待复制广告计划数据-添加")
+    @ApiOperation(value = "待复制广告计划数据-添加", notes = "待复制广告计划数据-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouCampaignCopyData> add(@RequestBody JSONObject data) {
+        Result<KuaishouCampaignCopyData> result = new Result<>();
+        try {
+            KuaishouCampaignCopyData kuaishouCampaignCopyData = JSONObject.toJavaObject(data, KuaishouCampaignCopyData.class);
+            if (Check.isNull(kuaishouCampaignCopyData.getCreaterId())) {
+                LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+                if (!Check.isNull(sysUser)) {
+                    kuaishouCampaignCopyData.setCreaterId(sysUser.getId());
+                }
+            }
+            kuaishouCampaignCopyDataService.save(kuaishouCampaignCopyData);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouCampaignCopyData
+     * @return
+     */
+    @AutoLog(value = "待复制广告计划数据-编辑")
+    @ApiOperation(value = "待复制广告计划数据-编辑", notes = "待复制广告计划数据-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaishouCampaignCopyData> edit(@RequestBody KuaishouCampaignCopyData kuaishouCampaignCopyData) {
+        Result<KuaishouCampaignCopyData> result = new Result<KuaishouCampaignCopyData>();
+        KuaishouCampaignCopyData kuaishouCampaignCopyDataEntity = kuaishouCampaignCopyDataService.getById(kuaishouCampaignCopyData.getId());
+        if (kuaishouCampaignCopyDataEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouCampaignCopyDataService.updateById(kuaishouCampaignCopyData);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "待复制广告计划数据-通过id删除")
+    @ApiOperation(value = "待复制广告计划数据-通过id删除", notes = "待复制广告计划数据-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            kuaishouCampaignCopyDataService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "待复制广告计划数据-批量删除")
+    @ApiOperation(value = "待复制广告计划数据-批量删除", notes = "待复制广告计划数据-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouCampaignCopyData> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouCampaignCopyData> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouCampaignCopyDataService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "待复制广告计划数据-通过id查询")
+    @ApiOperation(value = "待复制广告计划数据-通过id查询", notes = "待复制广告计划数据-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaishouCampaignCopyData> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouCampaignCopyData> result = new Result<>();
+        KuaishouCampaignCopyData kuaishouCampaignCopyData = kuaishouCampaignCopyDataService.getById(id);
+        if (kuaishouCampaignCopyData == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouCampaignCopyData);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouCampaignCopyData> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouCampaignCopyData kuaishouCampaignCopyData = JSON.parseObject(deString, KuaishouCampaignCopyData.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouCampaignCopyData, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouCampaignCopyData> pageList = kuaishouCampaignCopyDataService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "待复制广告计划数据列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouCampaignCopyData.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<KuaishouCampaignCopyData> listKuaishouCampaignCopyDatas = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouCampaignCopyData.class, params);
+                kuaishouCampaignCopyDataService.saveBatch(listKuaishouCampaignCopyDatas);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouCampaignCopyDatas.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("文件导入失败!");
+    }
+
+}

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

@@ -187,4 +187,8 @@ public class KuaiShouGroup {
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "修改时间")
     private Date updateTime;
+
+    @TableField(exist = false)
+    private KuaiShouGroupTarget target;
+
 }

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

@@ -0,0 +1,159 @@
+package cn.com.ctop.kuaishou.modules.batch.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 待复制广告计划数据
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-22
+ */
+@Data
+@TableName("ctop_kuaishou_campaign_copy_data")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_campaign_copy_data对象", description = "待复制广告计划数据")
+public class KuaishouCampaignCopyData {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 被复制的计划ID
+     */
+    @Excel(name = "被复制的计划ID", width = 15)
+    @ApiModelProperty(value = "被复制的计划ID")
+    private Long oldCampaignId;
+
+    /**
+     * 被复制的计划名称
+     */
+    private String oldCampaignName;
+
+    /**
+     * 创建者ID
+     */
+    private String createrId;
+    /**
+     * 新计划ID
+     */
+    @Excel(name = "新计划ID", width = 15)
+    @ApiModelProperty(value = "新计划ID")
+    private Long newCampaignId;
+    /**
+     * 投放方式  0:未知, 1:正常投
+     */
+    @Excel(name = "投放方式  0:未知, 1:正常投", width = 15)
+    @ApiModelProperty(value = "投放方式  0:未知, 1:正常投")
+    private Integer speed;
+    /**
+     * '状态:1待复制,2成功,3失败'
+     */
+    private String state;
+    /**
+     * 状态详情
+     */
+    private String stateDetail;
+    /**
+     * 单日预算
+     */
+    @Excel(name = "单日预算", width = 15)
+    @ApiModelProperty(value = "单日预算")
+    private Long dayBudget;
+    /**
+     * 定向模板id
+     */
+    @Excel(name = "定向模板id", width = 15)
+    @ApiModelProperty(value = "定向模板id")
+    private String templateId;
+    /**
+     * 投放开始时间
+     */
+    @Excel(name = "投放开始时间", width = 15)
+    @ApiModelProperty(value = "投放开始时间")
+    private String beginTime;
+    /**
+     * 投放结束时间
+     */
+    @Excel(name = "投放结束时间", width = 15)
+    @ApiModelProperty(value = "投放结束时间")
+    private String endTime;
+    /**
+     * 投放时段
+     */
+    @Excel(name = "投放时段", width = 15)
+    @ApiModelProperty(value = "投放时段")
+    private Object scheduleTime;
+    /**
+     * 出价类型(优化目标) 2点击数(CPC),10转化数(OCPM)
+     */
+    @Excel(name = "出价类型(优化目标) 2点击数(CPC),10转化数(OCPM)", width = 15)
+    @ApiModelProperty(value = "出价类型(优化目标) 2点击数(CPC),10转化数(OCPM)")
+    private Integer bidType;
+    /**
+     * 封面点击出价
+     */
+    @Excel(name = "封面点击出价", width = 15)
+    @ApiModelProperty(value = "封面点击出价")
+    private Long bid;
+    /**
+     * 转化目标,2:行为数,180:激活数,53:表单数,190: 付费,191:首日ROI 。。。
+     */
+    @Excel(name = "转化目标,2:行为数,180:激活数,53:表单数,190: 付费,191:首日ROI 。。。", width = 15)
+    @ApiModelProperty(value = "转化目标,2:行为数,180:激活数,53:表单数,190: 付费,191:首日ROI 。。。")
+    private Integer ocpxActionType;
+    /**
+     * 转化目标出价
+     */
+    @Excel(name = "转化目标出价", width = 15)
+    @ApiModelProperty(value = "转化目标出价")
+    private Long cpaBid;
+    /**
+     * 深度转化目标 3: 付费,7: 次日留存,10: 完件, 11: 授信 ,0:无
+     */
+    @Excel(name = "深度转化目标 3: 付费,7: 次日留存,10: 完件, 11: 授信 ,0:无", width = 15)
+    @ApiModelProperty(value = "深度转化目标 3: 付费,7: 次日留存,10: 完件, 11: 授信 ,0:无")
+    private Integer deepConversionType;
+    /**
+     * 深度转化目标出价
+     */
+    @Excel(name = "深度转化目标出价", width = 15)
+    @ApiModelProperty(value = "深度转化目标出价")
+    private Long deepConversionBid;
+    /**
+     * 广告位 1:优选广告位;
+     */
+    @Excel(name = "广告位 1:优选广告位;", width = 15)
+    @ApiModelProperty(value = "广告位 1:优选广告位;")
+    private String sceneId;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+}

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

@@ -22,4 +22,8 @@ public interface KuaiShouCreativeMapper extends BaseMapper<KuaiShouCreative> {
     Integer getCreateCount(Long accountId, String startTime);
 
     List<JSONObject> checkZombieProject(String date);
+
+    void delAllCreativesByCampaignId(@Param("accountId") Long accountId, @Param("campaignId") Long campaignId);
+
+    List<KuaiShouCreative> queryCreativeInfoByCampaignId(@Param("accountId") Long accountId, @Param("campaignId") Long campaignId);
 }

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

@@ -24,4 +24,8 @@ public interface KuaiShouGroupMapper extends BaseMapper<KuaiShouGroup> {
     List<KuaiShouGroup> queryByMap(Map<String, Object> map);
 
     List<KuaiShouGroup> queryUnitInfoByAccountId(Long accountId);
+
+    void delAllGroupByCampaignId(@Param("accountId") Long accountId, @Param("campaignId") Long campaignId);
+
+    List<KuaiShouGroup> queryUnitInfoByCampaignId(@Param("accountId") Long accountId, @Param("campaignId") Long campaignId);
 }

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

@@ -16,4 +16,8 @@ import java.util.List;
 public interface KuaiShouGroupTargetMapper extends BaseMapper<KuaiShouGroupTarget> {
 
     void replaceBatch(@Param("targets") List<KuaiShouGroupTarget> targets);
+
+    void deleteByUnitIds(@Param("unitIds") List<Long> unitIds);
+
+    KuaiShouGroupTarget queryTargetInfoByunitId(@Param("accountId") Long accountId, @Param("unitId") Long unitId);
 }

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouCampaignCopyData;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 待复制广告计划数据
+ *
+ * @author: jeecg-boot
+ * @date: 2020-12-22
+ * @cersion: V1.0
+ */
+public interface KuaishouCampaignCopyDataMapper extends BaseMapper<KuaishouCampaignCopyData> {
+
+}

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

@@ -127,4 +127,18 @@
         AND t1. STATUS = 42
         and t1.put_status = 1
     </select>
+
+    <delete id="delAllCreativesByCampaignId" parameterType="java.lang.Long">
+        delete from ctop_kuaishou_creative WHERE account_id = #{accountId}
+        AND campaign_id = #{campaignId}
+    </delete>
+
+    <select id="queryCreativeInfoByCampaignId" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative">
+        SELECT
+        *
+        FROM ctop_kuaishou_creative
+        WHERE account_id = #{accountId}
+         AND campaign_id = #{campaignId}
+    </select>
+
 </mapper>

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

@@ -118,4 +118,17 @@
         WHERE account_id = #{accountId}
     </select>
 
+    <select id="queryUnitInfoByCampaignId" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup">
+        SELECT
+        *
+        FROM ctop_kuaishou_group
+        WHERE account_id = #{accountId}
+         AND campaign_id = #{campaignId}
+    </select>
+
+    <delete id="delAllGroupByCampaignId" parameterType="java.lang.Long">
+       delete from ctop_kuaishou_group WHERE account_id = #{accountId}
+        AND campaign_id = #{campaignId}
+    </delete>
+
 </mapper>

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

@@ -67,4 +67,20 @@
         </foreach>
     </insert>
 
+    <delete id="deleteByUnitIds" parameterType="java.lang.Long">
+        delete from ctop_kuaishou_group_target WHERE account_id = #{accountId}
+        AND campaign_id in
+        <foreach item="id" collection="unitIds" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+
+
+    <select id="queryTargetInfoByunitId" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupTarget">
+        SELECT
+        *
+        FROM ctop_kuaishou_group_target
+        WHERE account_id = #{accountId}
+         AND unit_id = #{unitId}
+    </select>
 </mapper>

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

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

@@ -3,7 +3,6 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
 import com.baomidou.mybatisplus.extension.service.IService;
 
-import java.util.Date;
 import java.util.List;
 
 /**
@@ -37,10 +36,23 @@ public interface IKuaiShouCreativeService extends IService<KuaiShouCreative> {
 
     /**
      * 获取当前创意创建数
+     *
      * @param accountId
      * @param startTime
      * @return
      */
 
     Integer getCreateCount(Long accountId, String startTime);
+
+    /**
+     * 按广告系列ID删除所有广告素材
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    void delAllCreativesByCampaignId(Long accountId, Long campaignId);
+
+    List<KuaiShouCreative> queryCreativeInfoByCampaignId(Long accountId, Long campaignId);
 }

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

@@ -1,7 +1,6 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
-import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
@@ -21,4 +20,18 @@ public interface IKuaiShouGroupService extends IService<KuaiShouGroup> {
     void getCreativeByUnit(String accessToken, Long accountId, Long unitId);
 
     List<KuaiShouGroup> queryUnitInfoByAccountId(Long accountId);
+
+    /**
+     * 根据计划Id删除全部广告组
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    void delAllGroupByCampaignId(Long accountId, Long campaignId);
+
+    void getGroupListByPage(String accessToken, Long accountId, Long campaignId, int page);
+
+    List<KuaiShouGroup> queryUnitInfoByCampaignId(Long accountId, Long campaignId);
 }

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

@@ -3,6 +3,8 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupTarget;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * 快手-定向信息
  *
@@ -12,4 +14,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IKuaiShouGroupTargetService extends IService<KuaiShouGroupTarget> {
 
+    void deleteByUnitIds(List<Long> unitIds);
+
+    KuaiShouGroupTarget queryTargetInfoByunitId(Long accountId, Long unitId);
 }

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouCampaignCopyData;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 待复制广告计划数据
+ * @Author: jeecg-boot
+ * @Date: 2020-12-22
+ * @Version: V1.0
+ */
+public interface IKuaishouCampaignCopyDataService extends IService<KuaishouCampaignCopyData> {
+
+    void batchCopyCampaign();
+}

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

@@ -17,7 +17,10 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 快手-创意信息
@@ -75,8 +78,6 @@ public class KuaiShouCreativeServiceImpl extends ServiceImpl<KuaiShouCreativeMap
 
     @Override
     public void syncCreative(Long accountId, String accessToken, Long campaignId, Integer page) {
-
-
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
         Map<String, String> headers = new HashMap<>();
         headers.put("Content-Type", " application/json");
@@ -186,4 +187,16 @@ public class KuaiShouCreativeServiceImpl extends ServiceImpl<KuaiShouCreativeMap
     public Integer getCreateCount(Long accountId, String startTime) {
         return kuaiShouCreativeMapper.getCreateCount(accountId, startTime);
     }
+
+    @Override
+    public void delAllCreativesByCampaignId(Long accountId, Long campaignId) {
+        kuaiShouCreativeMapper.delAllCreativesByCampaignId(accountId, campaignId);
+    }
+
+    @Override
+    public List<KuaiShouCreative> queryCreativeInfoByCampaignId(Long accountId, Long campaignId) {
+        return kuaiShouCreativeMapper.queryCreativeInfoByCampaignId(accountId,campaignId);
+    }
+
+
 }

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

@@ -4,7 +4,12 @@ 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.kuaishou.modules.batch.entity.*;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppInfo;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupTarget;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouSchedule;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouAppInfoMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupTargetMapper;
@@ -21,7 +26,11 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
@@ -80,8 +89,8 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
 
     }
 
-
-    private void getGroupListByPage(String accessToken, Long accountId, Long campaignId, int page) {
+    @Override
+    public void getGroupListByPage(String accessToken, Long accountId, Long campaignId, int page) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
         JSONObject param = new JSONObject();
         param.put("advertiser_id", accountId);
@@ -112,6 +121,11 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
         getGroupListByPage(accessToken, accountId, campaignId, page + 1);
     }
 
+    @Override
+    public List<KuaiShouGroup> queryUnitInfoByCampaignId(Long accountId, Long campaignId) {
+        return groupMapper.queryUnitInfoByCampaignId(accountId, campaignId);
+    }
+
 
     @Override
     public void getGroupByUnitId(String accessToken, Long accountId, Long unitId) {
@@ -266,6 +280,11 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
         return groupMapper.queryUnitInfoByAccountId(accountId);
     }
 
+    @Override
+    public void delAllGroupByCampaignId(Long accountId, Long campaignId) {
+        groupMapper.delAllGroupByCampaignId(accountId, campaignId);
+    }
+
     static ExecutorService executorBidTypeService = Executors.newFixedThreadPool(20);
     static ExecutorService executorMaxBidService = Executors.newFixedThreadPool(5);
     @Autowired
@@ -335,7 +354,6 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
                         }
                     }
 
-
                     KuaiShouGroup group = new KuaiShouGroup();
                     group.setId("" + advertiserId + unitId);
                     group.setAccountId(advertiserId);

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

@@ -4,8 +4,11 @@ import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupTarget;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupTargetMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTargetService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * 快手-定向信息
  *
@@ -16,4 +19,16 @@ import org.springframework.stereotype.Service;
 @Service
 public class KuaiShouGroupTargetServiceImpl extends ServiceImpl<KuaiShouGroupTargetMapper, KuaiShouGroupTarget> implements IKuaiShouGroupTargetService {
 
+    @Autowired
+    private KuaiShouGroupTargetMapper kuaiShouGroupTargetMapper;
+
+    @Override
+    public void deleteByUnitIds(List<Long> unitIds) {
+        kuaiShouGroupTargetMapper.deleteByUnitIds(unitIds);
+    }
+
+    @Override
+    public KuaiShouGroupTarget queryTargetInfoByunitId(Long accountId, Long unitId) {
+        return kuaiShouGroupTargetMapper.queryTargetInfoByunitId(accountId, unitId);
+    }
 }

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

@@ -0,0 +1,497 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IMessageTemplate;
+import cn.com.ctop.common.module.service.ISendMessageService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouCampaignCopyData;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouCampaignCopyDataMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IBatchService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTargetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouCampaignCopyDataService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xxl.job.core.enums.NoEn;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static java.lang.Integer.valueOf;
+
+/**
+ * 待复制广告计划数据
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-22
+ */
+@Service
+public class KuaishouCampaignCopyDataServiceImpl extends ServiceImpl<KuaishouCampaignCopyDataMapper, KuaishouCampaignCopyData> implements IKuaishouCampaignCopyDataService {
+
+    @Autowired
+    private KuaishouCampaignCopyDataMapper kuaishouCampaignCopyDataMapper;
+    @Autowired
+    private IBatchService batchService;
+    @Autowired
+    private IKuaiShouGroupService kuaiShouGroupService;
+    @Autowired
+    private IKuaiShouGroupTargetService kuaiShouGroupTargetService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+    @Autowired
+    private IKuaiShouCreativeService kuaiShouCreativeService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private ISendMessageService sendMessageService;
+    @Autowired
+    private IMessageTemplate messageTemplate;
+
+    /**
+     * 批量复制计划
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    @Override
+    public void batchCopyCampaign() {
+        Map<String, Object> map = new HashMap<>();
+        //'状态:1待复制,2成功,3失败'
+        map.put("state", NoEn.NO1.valueInt());
+        List<KuaishouCampaignCopyData> kuaishouCampaignCopyData = kuaishouCampaignCopyDataMapper.selectByMap(map);
+        for (KuaishouCampaignCopyData copyData : kuaishouCampaignCopyData) {
+            try {
+                CtopOauthToken token = tokenService.getTokenByAccountId(copyData.getAccountId());
+                //执行删除被复制的计划组+创意
+                delOldCampaigns(copyData.getAccountId(), copyData.getOldCampaignId());
+                //获取当前最新广告计划组、创意数据并入库
+                JSONObject data = getNewCampaigns(token.getAccessToken(), copyData);
+                data.put("copyData", copyData);
+                //根据被复制的组数据和模板、预算和排期数据调用快手创建组接口
+                boolean isSuccess = createCopyUnits(token, data);
+                //更新成功,修改状态并发送通知
+                if (isSuccess) {
+                    sendNotification(copyData.getId(), copyData.getOldCampaignName(), copyData.getCreaterId(), NoEn.NO2.valueStr(), "复制成功");
+                }
+            } catch (Exception e) {
+                log.error("复制广告计划异常", e);
+                //复制过程中失败,更新状态并发送预警
+                sendNotification(copyData.getId(), copyData.getOldCampaignName(), copyData.getCreaterId(), NoEn.NO3.valueStr(), e.getMessage());
+            }
+
+
+        }
+    }
+
+    /**
+     * 执行删除计划
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    private void delOldCampaigns(Long accountId, Long campaignId) throws Exception {
+        try {
+            //删除组
+            kuaiShouGroupService.delAllGroupByCampaignId(accountId, campaignId);
+            //删除创意
+            kuaiShouCreativeService.delAllCreativesByCampaignId(accountId, campaignId);
+        } catch (Exception e) {
+            throw new Exception("删除待复制计划失败");
+        }
+    }
+
+    /**
+     * 获取当前最新广告计划组、创意数据并入库
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    private JSONObject getNewCampaigns(String accessToken, KuaishouCampaignCopyData copyData) throws Exception {
+        JSONObject data = new JSONObject();
+        try {
+            Long campaignId = copyData.getOldCampaignId();
+            //根据计划ID查询快手广告组并入库
+            kuaiShouGroupService.getGroupListByPage(accessToken, copyData.getAccountId(), campaignId, 1);
+            //查询已入库的广告组数据
+            List<KuaiShouGroup> kuaiShouGroups = kuaiShouGroupService.queryUnitInfoByCampaignId(copyData.getAccountId(), campaignId);
+            if (Check.isNull(kuaiShouGroups)) {
+                //获取广告组失败,更新状态并发送通知
+                sendNotification(copyData.getId(), copyData.getOldCampaignName(), copyData.getCreaterId(), NoEn.NO3.valueStr(), "被复制的计划更新广告组失败");
+            }
+            for (KuaiShouGroup kuaiShouGroup : kuaiShouGroups) {
+                kuaiShouGroup.setTarget(kuaiShouGroupTargetService.queryTargetInfoByunitId(copyData.getAccountId(), kuaiShouGroup.getUnitId()));
+                //根据广告组ID查询快手广告创意并入库
+                kuaiShouGroupService.getCreativeByUnit(accessToken, copyData.getAccountId(), kuaiShouGroup.getUnitId());
+            }
+            data.put("groups", kuaiShouGroups);
+        } catch (Exception e) {
+            log.error("获取计划最新广告计划组、创意数据并入库异常", e);
+            throw new Exception("获取计划最新广告计划组、创意并入库操作失败");
+        }
+        return data;
+    }
+
+    /**
+     * 根据已有的组数据和模板、预算和排期数据调用快手创建组接口
+     * detail
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    private boolean createCopyUnits(CtopOauthToken token, JSONObject data) throws Exception {
+        int count = 0;
+        String msg = "";
+        JSONArray groups = data.getJSONArray("groups");
+        JSONObject copyData = data.getJSONObject("copyData");
+        for (int i = 0; i < groups.size(); i++) {
+            try {
+                JSONObject group = groups.getJSONObject(i);
+                JSONObject unitJson = new JSONObject();
+                unitJson.put("campaign_id", copyData.getLong("newCampaignId"));
+                // 资源位置
+                JSONArray scene_id = copyData.getJSONArray("sceneId");
+                if (Check.isNull(scene_id) || scene_id.size() == 0) {
+                    scene_id = group.getJSONArray("sceneId");
+                }
+                unitJson.put("scene_id", scene_id);
+                // 资源创作方式
+                unitJson.put("unit_type", group.getInteger("unitType"));
+                // 转化目标id
+                if (!Check.isNull(group.getInteger("convertId"))) {
+                    unitJson.put("convert_id", group.getInteger("convertId"));
+                }
+                // 优先从系统应用商店下载
+                if (!Check.isNull(group.getInteger("useAppMarket"))) {
+                    unitJson.put("use_app_market", group.getInteger("useAppMarket"));
+                }
+                // 应用商店列表
+                if (!Check.isNull(group.getJSONArray("appStore"))) {
+                    unitJson.put("app_store", group.getJSONArray("appStore"));
+                }
+                //投放开始时间
+                String beginTime = copyData.getString("beginTime");
+                if (Check.isNull(beginTime)) {
+                    beginTime = group.getString("beginTime");
+                }
+                String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                boolean beginTimeBoolean = DateUtils.compare(beginTime, nowDate);
+                if (beginTimeBoolean) {
+                    unitJson.put("begin_time", nowDate);
+                } else {
+                    unitJson.put("begin_time", beginTime);
+                }
+                // 投放结束时间
+                String endTime = copyData.getString("endTime");
+                if (Check.isNull(endTime)) {
+                    endTime = group.getString("endTime");
+                }
+                if (!Check.isNull(endTime)) {
+                    unitJson.put("end_time", endTime);
+                }
+                // 投放时间段
+                String scheduleTime = copyData.getString("scheduleTime");
+                if (Check.isNull(scheduleTime)) {
+                    scheduleTime = group.getString("scheduleTime");
+                }
+                if (!Check.isNull(scheduleTime)) {
+                    unitJson.put("schedule_time", scheduleTime);
+                }
+                // 广告组单日预算
+                Long dayBudget = copyData.getLong("dayBudget");
+                if (Check.isNull(dayBudget)) {
+                    dayBudget = group.getLong("dayBudget");
+                }
+                if (!Check.isNull(dayBudget)) {
+                    unitJson.put("day_budget", dayBudget);
+                }
+                // url类型
+                if (!Check.isNull(group.getInteger("urlType"))) {
+                    unitJson.put("url_type", group.getInteger("urlType"));
+                }
+                // url
+                if (!Check.isNull(group.getString("url"))) {
+                    unitJson.put("url", group.getString("url"));
+                }
+                // appId
+                if (!Check.isNull(group.getLong("appId"))) {
+                    unitJson.put("app_id", group.getLong("appId"));
+                }
+                // 创意展现方式
+                if (!Check.isNull(group.getInteger("showMode"))) {
+                    unitJson.put("show_mode", group.getInteger("showMode"));
+                }
+                //投放方式
+                Integer speed = copyData.getInteger("speed");
+                if (Check.isNull(speed)) {
+                    speed = group.getInteger("speed");
+                }
+                if (!Check.isNull(speed)) {
+                    unitJson.put("speed", speed);
+                }
+
+                String templateId = copyData.getString("templateId");
+                if (!Check.isNull(templateId)) {
+                    unitJson.put("template_id", templateId);
+                } else {
+                    /*----------------用户定向-----------*/
+                    JSONObject target = group.getJSONObject("target");
+                    JSONObject targetJson = new JSONObject();
+                    // 地域
+                    if (!Check.isNull(target.getJSONArray("region"))) {
+                        targetJson.put("region", target.getJSONArray("region"));
+                    }
+                    // 自定义年龄段
+                    if (!Check.isNull(target.getInteger("ageMax")) && !Check.isNull(target.getInteger("ageMin"))) {
+                        JSONObject ageJson = new JSONObject();
+                        ageJson.put("min", target.getInteger("ageMin"));
+                        ageJson.put("max", target.getInteger("ageMax"));
+                        targetJson.put("age", ageJson);
+                    }
+                    // 固定年龄段
+                    if (!Check.isNull(target.getJSONArray("agesRange"))) {
+                        targetJson.put("ages_range", target.getJSONArray("agesRange"));
+                    }
+                    // 性别
+                    if (!Check.isNull(target.getInteger("gender"))) {
+                        targetJson.put("gender", target.getInteger("gender"));
+                    }
+                    //操作系统
+                    if (!Check.isNull(target.getInteger("platformOs"))) {
+                        targetJson.put("platform_os", target.getInteger("platformOs"));
+                    }
+                    //Android版本
+                    if (!Check.isNull(target.getInteger("androidOsv"))) {
+                        targetJson.put("android_osv", target.getInteger("androidOsv"));
+                    }
+                    // iOS版本
+                    if (!Check.isNull(target.getInteger("iosOsv"))) {
+                        targetJson.put("ios_osv", target.getInteger("iosOsv"));
+                    }
+                    //网络环境
+                    if (!Check.isNull(target.getInteger("network"))) {
+                        targetJson.put("network", target.getInteger("network"));
+                    }
+                    //设备品牌
+                    if (!Check.isNull(target.getJSONArray("deviceBrand"))) {
+                        targetJson.put("device_brand", target.getJSONArray("deviceBrand"));
+                    }
+                    //设备价格
+                    if (!Check.isNull(target.getJSONArray("devicePrice"))) {
+                        targetJson.put("device_price", target.getJSONArray("devicePrice"));
+                    }
+                    // APP行为-按分类
+                    if (!Check.isNull(target.getJSONArray("appInterest"))) {
+                        targetJson.put("app_interest", target.getJSONArray("appInterest"));
+                    }
+                    // APP行为-按APP名称
+                    if (!Check.isNull(target.getJSONArray("appIds"))) {
+                        targetJson.put("app_ids", target.getJSONArray("appIds"));
+                    }
+                    // 人群包定向
+                    if (!Check.isNull(target.getJSONArray("population"))) {
+                        targetJson.put("population", target.getJSONArray("population"));
+                    }
+                    // 人群包排除
+                    if (!Check.isNull(target.getJSONArray("excludePopulation"))) {
+                        targetJson.put("exclude_population", target.getJSONArray("excludePopulation"));
+                    }
+                    //三方付费人群
+                    if (!Check.isNull(target.getJSONArray("thirdPlatformCode"))) {
+                        targetJson.put("third_platform_code", target.getJSONArray("thirdPlatformCode"));
+                    }
+                    Integer sceneId = valueOf(scene_id.get(0).toString());
+                    if (sceneId != 5) {
+                        //过滤已转化人群纬度
+                        if (!Check.isNull(target.getInteger("filterConvertedLevel"))) {
+                            targetJson.put("filter_converted_level", target.getInteger("filterConvertedLevel"));
+                        }
+                        //商业兴趣类型
+                        if (!Check.isNull(target.getInteger("businessInterestType"))) {
+                            targetJson.put("business_interest_type", target.getInteger("businessInterestType"));
+                        }
+                        // 商业兴趣
+                        if (!Check.isNull(target.getJSONArray("businessInterest"))) {
+                            targetJson.put("business_interest", target.getJSONArray("businessInterest"));
+                        }
+                        //网红粉丝
+                        if (!Check.isNull(target.getJSONArray("fansStar"))) {
+                            targetJson.put("fans_star", target.getJSONArray("fansStar"));
+                        }
+                        //兴趣视频用户
+                        if (!Check.isNull(target.getJSONArray("interestVideo"))) {
+                            targetJson.put("interest_video", target.getJSONArray("interestVideo"));
+                        }
+                        /*----------------智能扩量----------------*/
+                        JSONObject intelliExtendJson = new JSONObject();
+                        // 开启智能扩量
+                        if (!Check.isNull(target.getInteger("isOpen"))) {
+                            intelliExtendJson.put("is_open", target.getInteger("isOpen"));
+                        }
+                        //不可突破年龄
+                        if (!Check.isNull(target.getInteger("noAgeBreak"))) {
+                            intelliExtendJson.put("no_age_break", target.getInteger("noAgeBreak"));
+                        }
+                        //不可突破性别
+                        if (!Check.isNull(target.getInteger("noGenderBreak"))) {
+                            intelliExtendJson.put("no_gender_break", target.getInteger("noGenderBreak"));
+                        }
+                        // 不可突破地域
+                        if (!Check.isNull(target.getInteger("noAreaBreak"))) {
+                            intelliExtendJson.put("no_area_break", target.getInteger("noAreaBreak"));
+                        }
+                        if (!Check.isNull(intelliExtendJson)) {
+                            targetJson.put("intelli_extend", intelliExtendJson);
+                        }
+                    }
+                    unitJson.put("target", targetJson);
+                }
+                // 出价
+                Long bid = copyData.getLong("bid");
+                if (Check.isNull(bid)) {
+                    bid = group.getLong("bid");
+                }
+                if (!Check.isNull(bid)) {
+                    unitJson.put("bid", bid);
+                }
+                // 出价类型
+                Integer bidType = copyData.getInteger("bidType");
+                if (Check.isNull(bidType)) {
+                    bidType = group.getInteger("bidType");
+                }
+                if (!Check.isNull(bidType)) {
+                    unitJson.put("bid_type", bidType);
+                }
+                // 深度转化出价
+                Long cpaBid = copyData.getLong("cpaBid");
+                if (Check.isNull(cpaBid)) {
+                    cpaBid = group.getLong("cpaBid");
+                }
+                if (!Check.isNull(cpaBid)) {
+                    unitJson.put("cpa_bid", cpaBid);
+                }
+                // 深度转化目标出价
+                Long deepConversionBid = copyData.getLong("deepConversionBid");
+                if (Check.isNull(deepConversionBid)) {
+                    deepConversionBid = group.getLong("deepConversionBid");
+                }
+                if (!Check.isNull(deepConversionBid)) {
+                    unitJson.put("deep_conversion_bid", deepConversionBid);
+                }
+                // 深度转化目标
+                Integer deepConversionType = copyData.getInteger("deepConversionType");
+                if (Check.isNull(deepConversionType)) {
+                    deepConversionType = group.getInteger("deepConversionType");
+                }
+                if (!Check.isNull(deepConversionType)) {
+                    unitJson.put("deep_conversion_type", deepConversionType);
+                }
+                // 优化目标
+                Integer ocpxActionType = copyData.getInteger("ocpxActionType");
+                if (Check.isNull(ocpxActionType)) {
+                    ocpxActionType = group.getInteger("ocpxActionType");
+                }
+                if (!Check.isNull(ocpxActionType)) {
+                    unitJson.put("ocpx_action_type", ocpxActionType);
+                }
+
+                //快手广告组名
+                String unitName = group.getString("unitName");
+                if (unitName.contains("CopyFrom")) {
+                    String format = "-".concat(DateUtils.yyyymmddhhmmss.get().format(new Date()));
+                    if (unitName.contains("(update)")) {
+                        int lastIndx = unitName.lastIndexOf("-");
+                        group.put("unit_name", unitName.substring(0, lastIndx).concat(format).concat("(update)"));
+                    } else {
+                        unitJson.put("unit_name", unitName.concat(format).concat("(update)"));
+                    }
+                } else {
+                    unitJson.put("unit_name", "CopyFrom-".concat(unitName));
+                }
+                Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitJson, 1);
+                if (!Check.isNullMap(returnUnitMap)) {
+                    Integer code = (Integer) returnUnitMap.get("code");
+                    if (code == 0) {
+                        Long unitId = (Long) returnUnitMap.get("unitId");
+                        Thread thread = new Thread() {
+                            @Override
+                            public void run() {
+                                try {
+                                    batchService.copyCreative(token.getAccountId(), unitId, group.getLong("unitId"), null);
+                                } catch (Exception e) {
+                                    log.error("复制创建广告创意异常", e);
+                                }
+                            }
+                        };
+                        thread.start();
+                    } else {
+                        count++;
+                        msg = (String) returnUnitMap.get("message");
+                    }
+                } else {
+                    count++;
+                }
+            } catch (Exception e) {
+                count++;
+                log.error("复制过程调用快手接口异常", e);
+            }
+        }
+        //全部失败
+
+        if (count == 0) {
+            return true;
+        } else {
+            sendNotification(copyData.getLong("id"), copyData.getString("oldCampaignName"), copyData.getString("createrId"), NoEn.NO3.valueStr(), msg);
+        }
+        return false;
+    }
+
+    /**
+     * 根据已有创意数据,匹配新计划、组数据调用快手创建创意接口
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    private void createCopyCreatives(CtopOauthToken token, JSONObject data, KuaishouCampaignCopyData
+            copyData) throws Exception {
+
+    }
+
+    /**
+     * 发送消息通知
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    private void sendNotification(Long id, String name, String userId, String state, String StateDetail) {
+        KuaishouCampaignCopyData copyData = new KuaishouCampaignCopyData();
+        copyData.setId(id);
+        copyData.setState(state);
+        copyData.setStateDetail(StateDetail);
+        this.updateById(copyData);
+        String msg = messageTemplate.getCopyCampaignMessage(name, state);
+        sendMessageService.sendMessage(userId, msg);
+    }
+}

+ 10 - 9
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaishouAudienceReportDailyController.java

@@ -2,11 +2,15 @@ package cn.com.ctop.kuaishou.modules.report.controller;
 
 import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAccount;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyAccountService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyService;
 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 com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -55,6 +59,8 @@ import java.util.Map;
 public class KuaishouAudienceReportDailyController {
     @Autowired
     private IKuaishouAudienceReportDailyService kuaishouAudienceReportDailyService;
+    @Autowired
+    private IKuaishouAudienceReportDailyAccountService kuaishouAudienceReportDailyAccountService;
 
     /**
      * 分页列表查询
@@ -93,13 +99,8 @@ public class KuaishouAudienceReportDailyController {
     @AutoLog(value = "人群分析报表-分页列表查询")
     @ApiOperation(value = "人群分析报表-分页列表查询", notes = "人群分析报表-分页列表查询")
     @GetMapping(value = "/queryPageList")
-    public Result<Object> queryPageLists(KuaishouAudienceReportDaily audienceReport, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, String type) {
-        try {
-            return kuaishouAudienceReportDailyService.queryPageLists(audienceReport, pageNo, pageSize, type);
-        } catch (Exception e) {
-            log.error("人群分析报表-分页列表查询异常", e);
-        }
-        return Result.error("查询人群分析报表失败");
+    public PageInfo<JSONObject> queryPageLists(KuaishouAudienceReportDailyAccount audienceReport, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        return kuaishouAudienceReportDailyAccountService.queryPageLists(audienceReport, pageNo, pageSize);
     }
 
     /**
@@ -113,9 +114,9 @@ public class KuaishouAudienceReportDailyController {
     @AutoLog(value = "首页报表数据接口")
     @ApiOperation(value = "首页报表数据接口", notes = "首页报表数据接口")
     @GetMapping(value = "/queryAllReportForm")
-    public Result<Object> queryAllReportForm(KuaishouAudienceReportDaily audienceReport) {
+    public Result<Object> queryAllReportForm(KuaishouAudienceReportDailyAccount audienceReport) {
         try {
-            return kuaishouAudienceReportDailyService.queryAllReportForm(audienceReport);
+            return kuaishouAudienceReportDailyAccountService.queryAllReportForm(audienceReport);
         } catch (Exception e) {
             log.error("首页报表数据接口", e);
         }

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

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.report.entity;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
 import lombok.Data;
@@ -23,4 +24,7 @@ public class KuaishouAudienceReportDailyAccount extends KuaishouAudienceReportDa
      * province: 省级地域分布,city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布,clientId: 系统分布,businessInterestTags: 商业兴趣分布
      */
     private java.lang.String audienceType;
+
+    @TableField(exist = false)
+    private java.lang.Integer count;
 }

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

@@ -1,9 +1,11 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAccount;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
+import java.util.List;
+
 /**
  * 人群分析报表
  *
@@ -13,4 +15,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface KuaishouAudienceReportDailyAccountMapper extends BaseMapper<KuaishouAudienceReportDailyAccount> {
 
+    List<JSONObject> queryPageLists(KuaishouAudienceReportDailyAccount audienceReport);
+
+    List<JSONObject> queryAllReportForm(KuaishouAudienceReportDailyAccount audienceReport);
+
+    int querybusinessTypeCount(KuaishouAudienceReportDailyAccount audienceReport);
+
+    List<JSONObject> querybusinessTypeReportForm(KuaishouAudienceReportDailyAccount audienceReport);
 }

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

@@ -1,12 +1,8 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAge;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
-import java.util.List;
-
 /**
  * 人群分析报表
  *
@@ -16,7 +12,4 @@ import java.util.List;
  */
 public interface KuaishouAudienceReportDailyAgeMapper extends BaseMapper<KuaishouAudienceReportDailyAge> {
 
-    List<JSONObject> queryPageLists(KuaishouAudienceReportDaily audienceReport);
-
-    List<JSONObject> queryAllReportForm(KuaishouAudienceReportDaily audienceReport);
 }

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

@@ -1,12 +1,8 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyBusiness;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
-import java.util.List;
-
 /**
  * 人群分析报表
  *
@@ -16,7 +12,4 @@ import java.util.List;
  */
 public interface KuaishouAudienceReportDailyBusinessMapper extends BaseMapper<KuaishouAudienceReportDailyBusiness> {
 
-    List<JSONObject> queryPageLists(KuaishouAudienceReportDaily audienceReport);
-
-    List<JSONObject> queryAllReportForm(KuaishouAudienceReportDaily audienceReport);
 }

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

@@ -1,12 +1,8 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyCity;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
-import java.util.List;
-
 /**
  * 人群分析报表
  *
@@ -16,7 +12,4 @@ import java.util.List;
  */
 public interface KuaishouAudienceReportDailyCityMapper extends BaseMapper<KuaishouAudienceReportDailyCity> {
 
-    List<JSONObject> queryPageLists(KuaishouAudienceReportDaily audienceReport);
-
-    List<JSONObject> queryAllReportForm(KuaishouAudienceReportDaily audienceReport);
 }

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

@@ -1,12 +1,8 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyClient;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
-import java.util.List;
-
 /**
  * 人群分析报表
  *
@@ -16,7 +12,4 @@ import java.util.List;
  */
 public interface KuaishouAudienceReportDailyClientMapper extends BaseMapper<KuaishouAudienceReportDailyClient> {
 
-    List<JSONObject> queryPageLists(KuaishouAudienceReportDaily audienceReport);
-
-    List<JSONObject> queryAllReportForm(KuaishouAudienceReportDaily audienceReport);
 }

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

@@ -1,12 +1,8 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyGender;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
-import java.util.List;
-
 /**
  * 人群分析报表
  *
@@ -15,8 +11,4 @@ import java.util.List;
  * @cersion: V1.0
  */
 public interface KuaishouAudienceReportDailyGenderMapper extends BaseMapper<KuaishouAudienceReportDailyGender> {
-
-    List<JSONObject> queryPageLists(KuaishouAudienceReportDaily audienceReport);
-
-    List<JSONObject> queryAllReportForm(KuaishouAudienceReportDaily audienceReport);
 }

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

@@ -1,12 +1,8 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyProvince;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
-import java.util.List;
-
 /**
  * 人群分析报表
  *
@@ -16,7 +12,4 @@ import java.util.List;
  */
 public interface KuaishouAudienceReportDailyProvinceMapper extends BaseMapper<KuaishouAudienceReportDailyProvince> {
 
-    List<JSONObject> queryPageLists(KuaishouAudienceReportDaily audienceReport);
-
-    List<JSONObject> queryAllReportForm(KuaishouAudienceReportDaily audienceReport);
 }

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

@@ -0,0 +1,166 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyAccountMapper">
+
+    <select id="queryPageLists" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        account_id as accountId,
+        province,
+        age_segment as ageSegment,
+        business_interest_tags as businessInterestTags ,
+        city,
+        client,
+        gender,
+        SUM(charge) as charge,
+        SUM(activation) as activation,
+        SUM(event_next_day_stay) as eventNextDayStay,
+        ROUND(SUM(event_next_day_stay)/SUM(activation)*100,2)as eventNextDayStayRatio
+        FROM ctop_kuaishou_audience_report_daily_account
+        where 1=1
+        <if test="accountId != null">
+            and account_id = #{accountId}
+        </if>
+        <if test="startTime != null">
+            AND stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime != null">
+            AND stat_date &lt;= #{endTime}
+        </if>
+        <if test="audienceType == 'province' ">
+            AND audience_type = #{audienceType}
+            GROUP BY province
+        </if>
+        <if test="audienceType == 'city' ">
+            AND audience_type = #{audienceType}
+            GROUP BY city
+        </if>
+        <if test="audienceType == 'gender' ">
+            AND audience_type = #{audienceType}
+            GROUP BY gender
+        </if>
+        <if test="audienceType == 'ageSegment' ">
+            AND audience_type = #{audienceType}
+            GROUP BY age_segment
+        </if>
+        <if test="audienceType == 'clientId' ">
+            AND audience_type = #{audienceType}
+            GROUP BY client
+        </if>
+        <if test="audienceType == 'businessInterestTags' ">
+            AND audience_type = #{audienceType}
+            GROUP BY business_interest_tags
+        </if>
+        <if test="orderType!= null">
+            ORDER BY #{orderType}
+        </if>
+        <if test="upOrDown == 'desc' || upOrDown == 'DESC'">
+            DESC
+        </if>
+    </select>
+
+
+    <select id="queryAllReportForm" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        stat_date as statDate,
+        account_id as accountId,
+        province,
+        age_segment as ageSegment,
+        business_interest_tags as businessInterestTags ,
+        city,
+        client,
+        gender,
+        SUM(photo_show) as photoShow,
+        SUM(photo_click) as photoClick,
+        SUM(aclick) as aclick,
+        SUM(bclick) as bclick,
+        ROUND(SUM(photo_click)/SUM(photo_show)*100,2) as photoClickRatio,
+        ROUND(SUM(bclick)/SUM(aclick)*100,2) as actionRatio
+        FROM ctop_kuaishou_audience_report_daily_account
+        where 1=1
+        <if test="accountId != null">
+            and account_id = #{accountId}
+        </if>
+        <if test="startTime != null">
+            AND stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime != null">
+            AND stat_date &lt;= #{endTime}
+        </if>
+        <if test="audienceType == 'province' ">
+            AND audience_type = #{audienceType}
+            GROUP BY province
+        </if>
+        <if test="audienceType == 'city' ">
+            AND audience_type = #{audienceType}
+            GROUP BY city
+        </if>
+        <if test="audienceType == 'gender' ">
+            AND audience_type = #{audienceType}
+            GROUP BY gender
+        </if>
+        <if test="audienceType == 'ageSegment' ">
+            AND audience_type = #{audienceType}
+            GROUP BY age_segment
+        </if>
+        <if test="audienceType == 'clientId' ">
+            AND audience_type = #{audienceType}
+            GROUP BY client
+        </if>
+        <if test="audienceType == 'businessInterestTags' ">
+            AND audience_type = #{audienceType}
+            GROUP BY business_interest_tags
+        </if>
+    </select>
+
+    <select id="querybusinessTypeReportForm" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        stat_date as statDate,
+        account_id as accountId,
+        business_interest_tags as businessInterestTags ,
+        SUM(photo_show) as photoShow,
+        SUM(photo_click) as photoClick,
+        sum(charge) as totalCost,
+        SUM(aclick) as aclick,
+        SUM(bclick) as bclick,
+        ROUND(SUM(photo_click)/SUM(photo_show)*100,2) as photoClickRatio,
+        ROUND(SUM(bclick)/SUM(aclick)*100,2) as actionRatio
+        FROM ctop_kuaishou_audience_report_daily_account
+        where 1=1
+        <if test="accountId != null">
+            and account_id = #{accountId}
+        </if>
+        <if test="startTime != null">
+            AND stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime != null">
+            AND stat_date &lt;= #{endTime}
+        </if>
+        AND audience_type = 'businessInterestTags'
+        GROUP BY business_interest_tags
+        ORDER BY totalCost  desc
+        limit 10
+    </select>
+
+
+    <select id="querybusinessTypeCount" resultType="java.lang.Integer">
+        SELECT count(1) FROM(
+        SELECT
+        1
+        FROM ctop_kuaishou_audience_report_daily_account
+        where 1=1
+        <if test="accountId != null">
+            and account_id = #{accountId}
+        </if>
+        <if test="startTime != null">
+            AND stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime != null">
+            AND stat_date &lt;= #{endTime}
+        </if>
+        <if test="audienceType == 'businessInterestTags' ">
+            AND audience_type = #{audienceType}
+            GROUP BY business_interest_tags
+        </if>
+        ) as tt
+    </select>
+</mapper>

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

@@ -1,52 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyAgeMapper">
-    <select id="queryPageLists" resultType="com.alibaba.fastjson.JSONObject">
-        select
-        SELECT
-        account_id,
-        age_segment,
-        SUM(charge) as charge,
-        SUM(activation) as activation,
-        SUM(event_next_day_stay) as eventNextDayStay,
-        ROUND(SUM(event_next_day_stay)/SUM(activation)*100,2)as eventNextDayStayRatio
-        FROM ctop_kuaishou_audience_report_daily_age t1
-        where account_id = #{accountId}
-        <if test="startTime != null">
-            AND stat_date &gt;= #{startTime}
-        </if>
-        <if test="endTime != null">
-            AND stat_date &lt;= #{endTime}
-        </if>
-        GROUP BY age_segment
-        <if test="orderType!= null">
-            ORDER BY #{orderType}
-        </if>
-        <if test="upOrDown == 'desc' || upOrDown == 'DESC'">
-            DESC
-        </if>
-    </select>
 
-
-    <select id="queryAllReportForm" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-        stat_date,
-        account_id,
-        age_segment,
-        SUM(photo_show) as photoShow,
-        SUM(photo_click) as photoClick,
-        SUM(aclick) as aclick,
-        SUM(bclick) as bclick,
-        ROUND(SUM(photo_click)/SUM(photo_show)*100,2) as photoClickRatio,
-        ROUND(SUM(bclick)/SUM(aclick)*100,2) as actionRatio
-        FROM ctop_kuaishou_audience_report_daily_age t1
-        where account_id = #{accountId}
-        <if test="startTime != null">
-            AND stat_date &gt;= #{startTime}
-        </if>
-        <if test="endTime != null">
-            AND stat_date &lt;= #{endTime}
-        </if>
-        GROUP BY age_segment
-    </select>
 </mapper>

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

@@ -1,51 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyBusinessMapper">
-    <select id="queryPageLists" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-        account_id,
-        business_interest_tags,
-        SUM(charge) as charge,
-        SUM(activation) as activation,
-        SUM(event_next_day_stay) as eventNextDayStay,
-        ROUND(SUM(event_next_day_stay)/SUM(activation)*100,2)as eventNextDayStayRatio
-        FROM ctop_kuaishou_audience_report_daily_business t1
-        where account_id = #{accountId}
-        <if test="startTime != null">
-            AND stat_date &gt;= #{startTime}
-        </if>
-        <if test="endTime != null">
-            AND stat_date &lt;= #{endTime}
-        </if>
-        GROUP BY business_interest_tags
-        <if test="orderType!= null">
-            ORDER BY #{orderType}
-        </if>
-        <if test="upOrDown == 'desc' || upOrDown == 'DESC'">
-            DESC
-        </if>
-    </select>
 
-
-    <select id="queryAllReportForm" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-        stat_date,
-        account_id,
-        business_interest_tags,
-        SUM(photo_show) as photoShow,
-        SUM(photo_click) as photoClick,
-        SUM(aclick) as aclick,
-        SUM(bclick) as bclick,
-        ROUND(SUM(photo_click)/SUM(photo_show)*100,2) as photoClickRatio,
-        ROUND(SUM(bclick)/SUM(aclick)*100,2) as actionRatio
-        FROM ctop_kuaishou_audience_report_daily_business t1
-        where account_id = #{accountId}
-        <if test="startTime != null">
-            AND stat_date &gt;= #{startTime}
-        </if>
-        <if test="endTime != null">
-            AND stat_date &lt;= #{endTime}
-        </if>
-        GROUP BY business_interest_tags
-    </select>
 </mapper>

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

@@ -1,50 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyCityMapper">
-    <select id="queryPageLists" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-        account_id,
-        city,
-        SUM(charge) as charge,
-        SUM(activation) as activation,
-        SUM(event_next_day_stay) as eventNextDayStay,
-        ROUND(SUM(event_next_day_stay)/SUM(activation)*100,2)as eventNextDayStayRatio
-        FROM ctop_kuaishou_audience_report_daily_city t1
-        where account_id = #{accountId}
-        <if test="startTime != null">
-            AND stat_date &gt;= #{startTime}
-        </if>
-        <if test="endTime != null">
-            AND stat_date &lt;= #{endTime}
-        </if>
-        GROUP BY city
-        <if test="orderType!= null">
-            ORDER BY #{orderType}
-        </if>
-        <if test="upOrDown == 'desc' || upOrDown == 'DESC'">
-            DESC
-        </if>
-    </select>
 
-    <select id="queryAllReportForm" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-        stat_date,
-        account_id,
-        city,
-        SUM(photo_show) as photoShow,
-        SUM(photo_click) as photoClick,
-        SUM(aclick) as aclick,
-        SUM(bclick) as bclick,
-        ROUND(SUM(photo_click)/SUM(photo_show)*100,2) as photoClickRatio,
-        ROUND(SUM(bclick)/SUM(aclick)*100,2) as actionRatio
-        FROM ctop_kuaishou_audience_report_daily_city t1
-        where account_id = #{accountId}
-        <if test="startTime != null">
-            AND stat_date &gt;= #{startTime}
-        </if>
-        <if test="endTime != null">
-            AND stat_date &lt;= #{endTime}
-        </if>
-        GROUP BY city
-    </select>
+
+
 </mapper>

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

@@ -1,50 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyClientMapper">
-    <select id="queryPageLists" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-        account_id,
-        client,
-        SUM(charge) as charge,
-        SUM(activation) as activation,
-        SUM(event_next_day_stay) as eventNextDayStay,
-        ROUND(SUM(event_next_day_stay)/SUM(activation)*100,2)as eventNextDayStayRatio
-        FROM ctop_kuaishou_audience_report_daily_client t1
-        where account_id = #{accountId}
-        <if test="startTime != null">
-            AND stat_date &gt;= #{startTime}
-        </if>
-        <if test="endTime != null">
-            AND stat_date &lt;= #{endTime}
-        </if>
-        GROUP BY client
-        <if test="orderType!= null">
-            ORDER BY #{orderType}
-        </if>
-        <if test="upOrDown == 'desc' || upOrDown == 'DESC'">
-            DESC
-        </if>
-    </select>
 
-    <select id="queryAllReportForm" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-        stat_date,
-        account_id,
-        client,
-        SUM(photo_show) as photoShow,
-        SUM(photo_click) as photoClick,
-        SUM(aclick) as aclick,
-        SUM(bclick) as bclick,
-        ROUND(SUM(photo_click)/SUM(photo_show)*100,2) as photoClickRatio,
-        ROUND(SUM(bclick)/SUM(aclick)*100,2) as actionRatio
-        FROM ctop_kuaishou_audience_report_daily_client t1
-        where account_id = #{accountId}
-        <if test="startTime != null">
-            AND stat_date &gt;= #{startTime}
-        </if>
-        <if test="endTime != null">
-            AND stat_date &lt;= #{endTime}
-        </if>
-        GROUP BY client
-    </select>
 </mapper>

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

@@ -1,50 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyGenderMapper">
-    <select id="queryPageLists" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-        account_id,
-        gender,
-        SUM(charge) as charge,
-        SUM(activation) as activation,
-        SUM(event_next_day_stay) as eventNextDayStay,
-        ROUND(SUM(event_next_day_stay)/SUM(activation)*100,2)as eventNextDayStayRatio
-        FROM ctop_kuaishou_audience_report_daily_gender t1
-        where account_id = #{accountId}
-        <if test="startTime != null">
-            AND stat_date &gt;= #{startTime}
-        </if>
-        <if test="endTime != null">
-            AND stat_date &lt;= #{endTime}
-        </if>
-        GROUP BY gender
-        <if test="orderType!= null">
-            ORDER BY #{orderType}
-        </if>
-        <if test="upOrDown == 'desc' || upOrDown == 'DESC'">
-            DESC
-        </if>
-    </select>
 
-    <select id="queryAllReportForm" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-        stat_date,
-        account_id,
-        gender,
-        SUM(photo_show) as photoShow,
-        SUM(photo_click) as photoClick,
-        SUM(aclick) as aclick,
-        SUM(bclick) as bclick,
-        ROUND(SUM(photo_click)/SUM(photo_show)*100,2) as photoClickRatio,
-        ROUND(SUM(bclick)/SUM(aclick)*100,2) as actionRatio
-        FROM ctop_kuaishou_audience_report_daily_gender t1
-        where account_id = #{accountId}
-        <if test="startTime != null">
-            AND stat_date &gt;= #{startTime}
-        </if>
-        <if test="endTime != null">
-            AND stat_date &lt;= #{endTime}
-        </if>
-        GROUP BY gender
-    </select>
 </mapper>

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

@@ -2,50 +2,5 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyProvinceMapper">
 
-    <select id="queryPageLists" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-        account_id,
-        province,
-        SUM(charge) as charge,
-        SUM(activation) as activation,
-        SUM(event_next_day_stay) as eventNextDayStay,
-        ROUND(SUM(event_next_day_stay)/SUM(activation)*100,2)as eventNextDayStayRatio
-        FROM ctop_kuaishou_audience_report_daily_province t1
-        where account_id = #{accountId}
-        <if test="startTime != null">
-            AND stat_date &gt;= #{startTime}
-        </if>
-        <if test="endTime != null">
-            AND stat_date &lt;= #{endTime}
-        </if>
-        GROUP BY province
-        <if test="orderType!= null">
-            ORDER BY #{orderType}
-        </if>
-        <if test="upOrDown == 'desc' || upOrDown == 'DESC'">
-            DESC
-        </if>
-    </select>
 
-    <select id="queryAllReportForm" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-        stat_date,
-        account_id,
-        province,
-        SUM(photo_show) as photoShow,
-        SUM(photo_click) as photoClick,
-        SUM(aclick) as aclick,
-        SUM(bclick) as bclick,
-        ROUND(SUM(photo_click)/SUM(photo_show)*100,2) as photoClickRatio,
-        ROUND(SUM(bclick)/SUM(aclick)*100,2) as actionRatio
-        FROM ctop_kuaishou_audience_report_daily_province t1
-        where account_id = #{accountId}
-        <if test="startTime != null">
-            AND stat_date &gt;= #{startTime}
-        </if>
-        <if test="endTime != null">
-            AND stat_date &lt;= #{endTime}
-        </if>
-        GROUP BY province
-    </select>
 </mapper>

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

@@ -1,9 +1,10 @@
 package cn.com.ctop.kuaishou.modules.report.service;
 
-import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAccount;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.github.pagehelper.PageInfo;
 import org.jeecg.common.api.vo.Result;
 
 /**
@@ -14,4 +15,24 @@ import org.jeecg.common.api.vo.Result;
  */
 public interface IKuaishouAudienceReportDailyAccountService extends IService<KuaishouAudienceReportDailyAccount> {
 
+
+    /**
+     * 人群报表接口:
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    PageInfo<JSONObject> queryPageLists(KuaishouAudienceReportDailyAccount audienceReport, Integer pageNo, Integer pageSize);
+
+    /**
+     * 首页报表数据
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    Result<Object> queryAllReportForm(KuaishouAudienceReportDailyAccount audienceReport);
 }

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

@@ -22,25 +22,4 @@ public interface IKuaishouAudienceReportDailyService extends IService<KuaishouAu
      */
     void crowdAnalysisReport(CtopOauthToken token, String date, String type, Long plan, Long unit, Integer page, Integer pageSize);
 
-    /**
-     * 查询人群分析报表
-     *
-     * @param
-     * @param no
-     * @param type
-     * @return java.lang.Long
-     * @throws
-     * @author ZHAOXA
-     */
-    Result<Object> queryPageLists(KuaishouAudienceReportDaily audienceReport, Integer pageNo, Integer pageSize, String type);
-
-    /**
-     * 首页报表数据
-     *
-     * @param
-     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
-     * @throws
-     * @author ZHAOXA
-     */
-    Result<Object> queryAllReportForm(KuaishouAudienceReportDaily audienceReport);
 }

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

@@ -1,12 +1,20 @@
 package cn.com.ctop.kuaishou.modules.report.service.impl;
 
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAccount;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyAccountMapper;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyAccountService;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * 人群分析报表
  *
@@ -18,4 +26,64 @@ import org.springframework.stereotype.Service;
 @Service
 public class KuaishouAudienceReportDailyAccountServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyAccountMapper, KuaishouAudienceReportDailyAccount> implements IKuaishouAudienceReportDailyAccountService {
 
+    @Autowired
+    private KuaishouAudienceReportDailyAccountMapper accountMapper;
+
+
+    @Override
+    public PageInfo<JSONObject> queryPageLists(KuaishouAudienceReportDailyAccount audienceReport, Integer pageNo, Integer pageSize) {
+        if (null == pageNo || pageNo == 0) {
+            pageNo = 1;
+        }
+        if (null == pageSize || pageSize == 0) {
+            pageSize = 10;
+        }
+        PageHelper.startPage(pageNo, pageSize);
+        List<JSONObject>jsonObjects = accountMapper.queryPageLists(audienceReport);
+        return new PageInfo<>(jsonObjects);
+    }
+
+    /**
+     * 首页报表数据
+     *
+     * @param type province: 省级地域分布, city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布clientId: 系统分布 businessInterestTags: 商业兴趣分布
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @Override
+    public Result<Object> queryAllReportForm(KuaishouAudienceReportDailyAccount audienceReport) {
+        JSONObject data = new JSONObject();
+        audienceReport.setAudienceType("province");
+        List<JSONObject> provinces = accountMapper.queryAllReportForm(audienceReport);
+        if (!Check.isNull(provinces)) {
+            data.put("province", provinces);
+        }
+        audienceReport.setAudienceType("gender");
+        List<JSONObject> genders = accountMapper.queryAllReportForm(audienceReport);
+        if (!Check.isNull(genders)) {
+            data.put("gender", genders);
+        }
+        audienceReport.setAudienceType("ageSegment");
+        List<JSONObject> ages = accountMapper.queryAllReportForm(audienceReport);
+        if (!Check.isNull(ages)) {
+            data.put("ageSegment", ages);
+        }
+        audienceReport.setAudienceType("clientId");
+        List<JSONObject> clients = accountMapper.queryAllReportForm(audienceReport);
+        if (!Check.isNull(clients)) {
+            data.put("client", clients);
+        }
+        audienceReport.setAudienceType("businessInterestTags");
+        List<JSONObject> bussiness = accountMapper.querybusinessTypeReportForm(audienceReport);
+        if (!Check.isNull(bussiness)) {
+            data.put("businessInterestTags", bussiness);
+        }
+        if (data.size() == 0) {
+            return Result.error("未查询到数据");
+        }
+        return Result.ok(data);
+    }
+
+
 }

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

@@ -89,83 +89,6 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
     private String urlPath = PropertiesUtils.getConfig("kuaishou_api_url");
 
     /**
-     * 报表分页分页查询
-     *
-     * @param type province: 省级地域分布, city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布clientId: 系统分布 businessInterestTags: 商业兴趣分布
-     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
-     * @throws
-     * @author ZHAOXA
-     */
-    @Override
-    public Result<Object> queryPageLists(KuaishouAudienceReportDaily audienceReport, Integer pageNo, Integer pageSize, String type) {
-        if (null == pageNo || pageNo == 0) {
-            pageNo = 1;
-        }
-        if (null == pageSize || pageSize == 0) {
-            pageSize = 10;
-        }
-        List<JSONObject> list = null;
-        PageHelper.startPage(pageNo, pageSize);
-        if ("province".equals(type)) {
-            list = provinceMapper.queryPageLists(audienceReport);
-        } else if ("city".equals(type)) {
-            list = cityMapper.queryPageLists(audienceReport);
-        } else if ("gender".equals(type)) {
-            list = genderMapper.queryPageLists(audienceReport);
-        } else if ("ageSegment".equals(type)) {
-            list = ageMapper.queryPageLists(audienceReport);
-        } else if ("client".equals(type)) {
-            list = clientMapper.queryPageLists(audienceReport);
-        } else if ("businessInterestTags".equals(type)) {
-            list = bussinessMapper.queryPageLists(audienceReport);
-        } else {
-            return Result.error("请选择人群报表类型");
-        }
-        if (Check.isNull(list)) {
-            return Result.error("只能获取到两天前的数据,请正确选择时间");
-        }
-        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
-        return Result.ok(pageInfo);
-    }
-
-    /**
-     * 首页报表数据
-     *
-     * @param type province: 省级地域分布, city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布clientId: 系统分布 businessInterestTags: 商业兴趣分布
-     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
-     * @throws
-     * @author ZHAOXA
-     */
-    @Override
-    public Result<Object> queryAllReportForm(KuaishouAudienceReportDaily audienceReport) {
-        JSONObject data = new JSONObject();
-        List<JSONObject> provinces = provinceMapper.queryAllReportForm(audienceReport);
-        if (!Check.isNull(provinces)) {
-            data.put("province", provinces);
-        }
-        List<JSONObject> genders = genderMapper.queryAllReportForm(audienceReport);
-        if (!Check.isNull(genders)) {
-            data.put("gender", genders);
-        }
-        List<JSONObject> ages = ageMapper.queryAllReportForm(audienceReport);
-        if (!Check.isNull(ages)) {
-            data.put("ageSegment", ages);
-        }
-        List<JSONObject> clients = clientMapper.queryAllReportForm(audienceReport);
-        if (!Check.isNull(clients)) {
-            data.put("client", clients);
-        }
-        List<JSONObject> bussiness = bussinessMapper.queryAllReportForm(audienceReport);
-        if (!Check.isNull(bussiness)) {
-            data.put("businessInterestTags", bussiness);
-        }
-        if (data.size() == 0) {
-            return Result.error("只能获取到两天前的数据,请正确选择时间");
-        }
-        return Result.ok(data);
-    }
-
-    /**
      * 人群分析报表入库
      *
      * @param type      province: 省级地域分布, city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布clientId: 系统分布 businessInterestTags: 商业兴趣分布
@@ -290,3 +213,4 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
         }
     }
 }
+