瀏覽代碼

账户维度-盯盘日、时数据清洗

zhaoxian 4 年之前
父節點
當前提交
7be2dbfffe
共有 18 個文件被更改,包括 1047 次插入114 次删除
  1. 312 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/EtlKuaishouAudienceAccountDailyController.java
  2. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/EtlKuaishouReportAccountDailyController.java
  3. 21 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/EtlKuaishouReportAccountHourlyController.java
  4. 139 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/EtlKuaishouAudienceAccountDaily.java
  5. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/EtlKuaishouReportAccountHourly.java
  6. 78 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/enums/CheckParametersEnum.java
  7. 24 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/EtlKuaishouAudienceAccountDailyMapper.java
  8. 4 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/EtlKuaishouReportAccountDailyMapper.java
  9. 2 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/EtlKuaishouReportAccountHourlyMapper.java
  10. 3 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyAccountMapper.java
  11. 100 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouAudienceAccountDailyMapper.xml
  12. 106 68
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouReportAccountDailyMapper.xml
  13. 96 33
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouReportAccountHourlyMapper.xml
  14. 23 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyAccountMapper.xml
  15. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IEtlKuaishouAudienceAccountDailyService.java
  16. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IEtlKuaishouReportAccountHourlyService.java
  17. 92 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/EtlKuaishouAudienceAccountDailyServiceImpl.java
  18. 22 8
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/EtlKuaishouReportAccountHourlyServiceImpl.java

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

@@ -0,0 +1,312 @@
+package cn.com.ctop.kuaishou.modules.report.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.QueryGenerator;
+import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouAudienceAccountDaily;
+import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaishouAudienceAccountDailyService;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.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 2021-03-09
+ */
+@Slf4j
+@Api(tags = "人群分析报表——年龄、性别数据")
+@RestController
+@RequestMapping("/etl/audienceAccountDaily")
+public class EtlKuaishouAudienceAccountDailyController {
+    @Autowired
+    private IEtlKuaishouAudienceAccountDailyService etlKuaishouAudienceAccountDailyService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param etlKuaishouAudienceAccountDaily
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "人群分析报表——年龄、性别数据-分页列表查询")
+    @ApiOperation(value = "人群分析报表——年龄、性别数据-分页列表查询", notes = "人群分析报表——年龄、性别数据-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<EtlKuaishouAudienceAccountDaily>> queryPageList(EtlKuaishouAudienceAccountDaily etlKuaishouAudienceAccountDaily,
+                                                                        @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                        HttpServletRequest req) {
+        Result<IPage<EtlKuaishouAudienceAccountDaily>> result = new Result<>();
+        QueryWrapper<EtlKuaishouAudienceAccountDaily> queryWrapper = QueryGenerator.initQueryWrapper(etlKuaishouAudienceAccountDaily, req.getParameterMap());
+        Page<EtlKuaishouAudienceAccountDaily> page = new Page<EtlKuaishouAudienceAccountDaily>(pageNo, pageSize);
+        IPage<EtlKuaishouAudienceAccountDaily> pageList = etlKuaishouAudienceAccountDailyService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param etlKuaishouAudienceAccountDaily
+     * @return
+     */
+    @AutoLog(value = "人群分析报表——年龄、性别数据-添加")
+    @ApiOperation(value = "人群分析报表——年龄、性别数据-添加", notes = "人群分析报表——年龄、性别数据-添加")
+    @PostMapping(value = "/add")
+    public Result<EtlKuaishouAudienceAccountDaily> add(@RequestBody EtlKuaishouAudienceAccountDaily etlKuaishouAudienceAccountDaily) {
+        Result<EtlKuaishouAudienceAccountDaily> result = new Result<>();
+        try {
+            etlKuaishouAudienceAccountDailyService.save(etlKuaishouAudienceAccountDaily);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    @GetMapping(value = "/createDate")
+    public Result<Object> createDate() {
+        try {
+            etlKuaishouAudienceAccountDailyService.queryEveryDayAudienceInfo();
+            return Result.ok("success");
+        } catch (Exception e) {
+            log.error("error:", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("error");
+    }
+
+
+    /**
+     * (饼状图)按照年龄查询数据
+     *
+     * @param
+     * @return
+     * @throws
+     * @author ZHAOXA
+     */
+    @AutoLog(value = "按照年龄查询数据")
+    @ApiOperation(value = "按照年龄查询数据", notes = "按照年龄查询数据")
+    @PostMapping(value = "/getAgeInfo")
+    public Result<Object> getAgeInfo(@RequestBody JSONObject request) {
+        try {
+            return etlKuaishouAudienceAccountDailyService.getAgeInfo(request);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * (饼状图)按照性别查询数据
+     *
+     * @param
+     * @return
+     * @throws
+     * @author ZHAOXA
+     */
+    @AutoLog(value = "按照性别查询数据")
+    @ApiOperation(value = "按照性别查询数据", notes = "按照性别查询数据")
+    @PostMapping(value = "/getSexInfo")
+    public Result<Object> getSexInfo(@RequestBody JSONObject request) {
+        try {
+            return etlKuaishouAudienceAccountDailyService.getSexInfo(request);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 编辑
+     *
+     * @param etlKuaishouAudienceAccountDaily
+     * @return
+     */
+    @AutoLog(value = "人群分析报表——年龄、性别数据-编辑")
+    @ApiOperation(value = "人群分析报表——年龄、性别数据-编辑", notes = "人群分析报表——年龄、性别数据-编辑")
+    @PutMapping(value = "/edit")
+    public Result<EtlKuaishouAudienceAccountDaily> edit(@RequestBody EtlKuaishouAudienceAccountDaily etlKuaishouAudienceAccountDaily) {
+        Result<EtlKuaishouAudienceAccountDaily> result = new Result<EtlKuaishouAudienceAccountDaily>();
+        EtlKuaishouAudienceAccountDaily etlKuaishouAudienceAccountDailyEntity = etlKuaishouAudienceAccountDailyService.getById(etlKuaishouAudienceAccountDaily.getId());
+        if (etlKuaishouAudienceAccountDailyEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = etlKuaishouAudienceAccountDailyService.updateById(etlKuaishouAudienceAccountDaily);
+            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 {
+            etlKuaishouAudienceAccountDailyService.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<EtlKuaishouAudienceAccountDaily> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<EtlKuaishouAudienceAccountDaily> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.etlKuaishouAudienceAccountDailyService.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<EtlKuaishouAudienceAccountDaily> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<EtlKuaishouAudienceAccountDaily> result = new Result<>();
+        EtlKuaishouAudienceAccountDaily etlKuaishouAudienceAccountDaily = etlKuaishouAudienceAccountDailyService.getById(id);
+        if (etlKuaishouAudienceAccountDaily == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(etlKuaishouAudienceAccountDaily);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<EtlKuaishouAudienceAccountDaily> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                EtlKuaishouAudienceAccountDaily etlKuaishouAudienceAccountDaily = JSON.parseObject(deString, EtlKuaishouAudienceAccountDaily.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(etlKuaishouAudienceAccountDaily, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<EtlKuaishouAudienceAccountDaily> pageList = etlKuaishouAudienceAccountDailyService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "人群分析报表——年龄、性别数据列表");
+        mv.addObject(NormalExcelConstants.CLASS, EtlKuaishouAudienceAccountDaily.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<EtlKuaishouAudienceAccountDaily> listEtlKuaishouAudienceAccountDailys = ExcelImportUtil.importExcel(file.getInputStream(), EtlKuaishouAudienceAccountDaily.class, params);
+                etlKuaishouAudienceAccountDailyService.saveBatch(listEtlKuaishouAudienceAccountDailys);
+                return Result.ok("文件导入成功!数据行数:" + listEtlKuaishouAudienceAccountDailys.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("文件导入失败!");
+    }
+
+}

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/EtlKuaishouReportAccountDailyController.java

@@ -48,7 +48,7 @@ import io.swagger.annotations.ApiOperation;
 @Slf4j
 @Api(tags = "盯盘日数据")
 @RestController
-@RequestMapping("/etlReportAccountDaily")
+@RequestMapping("/etl/reportAccountDaily")
 public class EtlKuaishouReportAccountDailyController {
     @Autowired
     private IEtlKuaishouReportAccountDailyService etlKuaishouReportAccountDailyService;

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

@@ -52,7 +52,7 @@ import java.util.Map;
 @Slf4j
 @Api(tags = "账户维度-每小时盯盘数据")
 @RestController
-@RequestMapping("/etlReportAccountHourly")
+@RequestMapping("/etl/reportAccountHourly")
 public class EtlKuaishouReportAccountHourlyController {
     @Autowired
     private IEtlKuaishouReportAccountHourlyService etlKuaishouReportAccountHourlyService;
@@ -103,6 +103,26 @@ public class EtlKuaishouReportAccountHourlyController {
      * @throws
      * @author ZHAOXA
      */
+    @AutoLog(value = "获取当日花费最大的账户")
+    @ApiOperation(value = "获取当日花费最大的账户", notes = "获取当日花费最大的账户")
+    @PostMapping(value = "/getMaxChargeAccountId")
+    public Result<Object> getMaxChargeAccountId() {
+        try {
+            return etlKuaishouReportAccountHourlyService.getMaxChargeAccountId();
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+    /**
+     * 获取时间趋势汇总投放数据
+     *
+     * @param
+     * @return
+     * @throws
+     * @author ZHAOXA
+     */
     @AutoLog(value = "获取时间趋势汇总投放数据")
     @ApiOperation(value = "获取时间趋势汇总投放数据", notes = "获取时间趋势汇总投放数据")
     @PostMapping(value = "/getAggregateByHour")

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

@@ -0,0 +1,139 @@
+package cn.com.ctop.kuaishou.modules.report.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 人群分析报表——年龄、性别数据
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-03-09
+ */
+@Data
+@TableName("ctop_etl_kuaishou_audience_account_daily")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_etl_kuaishou_audience_account_daily对象", description = "人群分析报表——年龄、性别数据")
+public class EtlKuaishouAudienceAccountDaily {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.INPUT)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 日期
+     */
+    @Excel(name = "日期", width = 15)
+    @ApiModelProperty(value = "日期")
+    private String statDate;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * province: 省级地域分布,city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布,clientId: 系统分布,businessInterestTags: 商业兴趣分布
+     */
+    @Excel(name = "province: 省级地域分布,city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布,clientId: 系统分布,businessInterestTags: 商业兴趣分布", width = 15)
+    @ApiModelProperty(value = "province: 省级地域分布,city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布,clientId: 系统分布,businessInterestTags: 商业兴趣分布")
+    private String audienceType;
+    /**
+     * 花费
+     */
+    @Excel(name = "花费", width = 15)
+    @ApiModelProperty(value = "花费")
+    private Double charge;
+    /**
+     * 应用下载数据-激活数
+     */
+    @Excel(name = "应用下载数据-激活数", width = 15)
+    @ApiModelProperty(value = "应用下载数据-激活数")
+    private Long activation;
+    /**
+     * 应用下载数据-付费次数
+     */
+    @Excel(name = "应用下载数据-付费次数", width = 15)
+    @ApiModelProperty(value = "应用下载数据-付费次数")
+    private Long eventPay;
+    /**
+     * 应用下载数据-付费金额
+     */
+    @Excel(name = "应用下载数据-付费金额", width = 15)
+    @ApiModelProperty(value = "应用下载数据-付费金额")
+    private java.math.BigDecimal eventPayPurchaseAmount;
+    /**
+     * 应用下载数据-次留数(仅支持分日查询)
+     */
+    @Excel(name = "应用下载数据-次留数(仅支持分日查询)", width = 15)
+    @ApiModelProperty(value = "应用下载数据-次留数(仅支持分日查询)")
+    private Long eventNextDayStay;
+    /**
+     * 素材曝光数
+     */
+    @Excel(name = "素材曝光数", width = 15)
+    @ApiModelProperty(value = "素材曝光数")
+    private Long aclick;
+    /**
+     * 行为数
+     */
+    @Excel(name = "行为数", width = 15)
+    @ApiModelProperty(value = "行为数")
+    private Long bclick;
+    /**
+     * 封面点击数
+     */
+    @Excel(name = "封面点击数", width = 15)
+    @ApiModelProperty(value = "封面点击数")
+    private Long photoClick;
+    /**
+     * 封面曝光数
+     */
+    @Excel(name = "封面曝光数", width = 15)
+    @ApiModelProperty(value = "封面曝光数")
+    private Long photoShow;
+    /**
+     * 性别
+     */
+    @Excel(name = "性别", width = 15)
+    @ApiModelProperty(value = "性别")
+    private String gender;
+    /**
+     * 年龄
+     */
+    @Excel(name = "年龄", width = 15)
+    @ApiModelProperty(value = "年龄")
+    private String ageSegment;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

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

@@ -223,7 +223,7 @@ public class EtlKuaishouReportAccountHourly {
     @Excel(name = "落地页数据-落地页授信数", width = 15)
     @ApiModelProperty(value = "落地页数据-落地页授信数")
     private Long eventCreditGrantLandingPage;
-    /**
+    /**Save pv the next day
      * 应用下载数据-次留数(仅支持分日查询)
      */
     @Excel(name = "应用下载数据-次留数(仅支持分日查询)", width = 15)

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

@@ -0,0 +1,78 @@
+package cn.com.ctop.kuaishou.modules.report.enums;
+
+public enum CheckParametersEnum {
+    PARAMETER1("charge", "charge"),
+    PARAMETER2("photoShow", "photo_show"),
+    PARAMETER3("photoClick", "photo_click"),
+    PARAMETER4("aclick", "aclick"),
+    PARAMETER5("bclick", "bclick"),
+    PARAMETER6("photoShare", "photo_share"),
+    PARAMETER7("photoComment", "photo_comment"),
+    PARAMETER8("photoLike", "photo_like"),
+    PARAMETER9("follow", "follow"),
+    PARAMETER10("cancelFollow", "cancel_follow"),
+    PARAMETER11("report", "report"),
+    PARAMETER12("block", "block"),
+    PARAMETER13("negative", "negative"),
+    PARAMETER14("downloadStarted", "download_started"),
+    PARAMETER15("downloadCompleted", "download_completed"),
+    PARAMETER16("activation", "activation"),
+    PARAMETER17("submit", "submit"),
+    PARAMETER18("eventPayFirstDay", "event_pay_first_day"),
+    PARAMETER19("eventPayPurchaseAmountFirstDay", "event_pay_purchase_amount_first_day"),
+    PARAMETER20("eventPay", "event_pay"),
+    PARAMETER21("eventPayPurchaseAmount", "event_pay_purchase_amount"),
+    PARAMETER22("eventRegister", "event_register"),
+    PARAMETER23("eventJinJianApp", "event_jin_jian_app"),
+    PARAMETER24("eventCreditGrantApp", "event_credit_grant_app"),
+    PARAMETER25("eventOrderPaid", "event_order_paid"),
+    PARAMETER26("eventOrderPaidPurchaseAmount", "event_order_paid_purchase_amount"),
+    PARAMETER27("eventJinJianLandingPage", "event_jin_jian_landing_page"),
+    PARAMETER28("eventCreditGrantLandingPage", "event_credit_grant_landing_page"),
+    PARAMETER29("eventNextDayStay", "event_next_day_stay"),
+    PARAMETER30("formCount", "form_count");
+
+    private String sqlName;
+    private String value;
+
+    CheckParametersEnum(String value, String sqlName) {
+        this.value = value;
+        this.sqlName = sqlName;
+    }
+
+    public static String getSqlName(String value) {
+        for (CheckParametersEnum campaignType : CheckParametersEnum.values()) {
+            if (campaignType.getValue().equals(value)) {
+                return campaignType.getSqlName();
+            }
+        }
+        return "";
+    }
+
+    public static boolean isInclude(String key) {
+        boolean include = false;
+        for (CheckParametersEnum e : CheckParametersEnum.values()) {
+            if (e.getValue().equals(key)) {
+                include = true;
+                break;
+            }
+        }
+        return include;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public String getSqlName() {
+        return sqlName;
+    }
+
+    public void setSqlName(String sqlName) {
+        this.sqlName = sqlName;
+    }
+}

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

@@ -0,0 +1,24 @@
+package cn.com.ctop.kuaishou.modules.report.mapper;
+
+import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouAudienceAccountDaily;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 人群分析报表——年龄、性别数据
+ *
+ * @author: jeecg-boot
+ * @date: 2021-03-09
+ * @cersion: V1.0
+ */
+public interface EtlKuaishouAudienceAccountDailyMapper extends BaseMapper<EtlKuaishouAudienceAccountDaily> {
+
+    void replaceBatch(@Param("list") List<EtlKuaishouAudienceAccountDaily> list);
+
+    List<JSONObject> queryAudienceTypeInfo(@Param("value") String value, @Param("type") String type, @Param("accountId") Long accountId, @Param("audienceType") String audienceType, @Param("parType") String parType);
+
+    List<JSONObject> queryEveryDayInfo(@Param("value") String value, @Param("type") String type, @Param("accountId") Long accountId, @Param("audienceType") String audienceType, @Param("parType") String parType);
+}

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

@@ -3,6 +3,7 @@ package cn.com.ctop.kuaishou.modules.report.mapper;
 import java.util.List;
 
 import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountHourly;
+import com.alibaba.fastjson.JSONObject;
 import org.apache.ibatis.annotations.Param;
 import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountDaily;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -20,5 +21,7 @@ public interface EtlKuaishouReportAccountDailyMapper extends BaseMapper<EtlKuais
 
     EtlKuaishouReportAccountHourly getOnedayAggregatebyDaily(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("accountId") Long accountId);
 
-    List<EtlKuaishouReportAccountHourly> getOnedayEtlReportList(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("accountId") Long accountId);
+    List<JSONObject> getOnedayEtlReportList(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("accountId") Long accountId, @Param("value") String value, @Param("type") String type);
+
+    Long getMaxChargeAccountId();
 }

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

@@ -5,6 +5,7 @@ import java.util.List;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
 import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountHourly;
+import com.alibaba.fastjson.JSONObject;
 import org.apache.ibatis.annotations.Param;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
@@ -21,6 +22,6 @@ public interface EtlKuaishouReportAccountHourlyMapper extends BaseMapper<EtlKuai
 
     EtlKuaishouReportAccountHourly getOnedayAggregateByHour(@Param("startTime") String startTime, @Param("accountId") Long accountId, @Param("hour") Integer hour);
 
-    List<EtlKuaishouReportAccountHourly> getOnedayEtlReportList(@Param("startTime") String startTime,@Param("accountId") Long accountId);
+    List<JSONObject> getOnedayEtlReportList(@Param("startTime") String startTime, @Param("accountId") Long accountId,@Param("value") String value,@Param("type") String type);
 
 }

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

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
+import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouAudienceAccountDaily;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAccount;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -22,4 +23,6 @@ public interface KuaishouAudienceReportDailyAccountMapper extends BaseMapper<Kua
     List<String> querybusinessTypeCount(KuaishouAudienceReportDailyAccount audienceReport);
 
     List<JSONObject> querybusinessTypeReportForm(KuaishouAudienceReportDailyAccount audienceReport);
+
+    List<EtlKuaishouAudienceAccountDaily> queryEveryDayAudienceInfo();
 }

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

@@ -0,0 +1,100 @@
+<?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.EtlKuaishouAudienceAccountDailyMapper">
+    <insert id="replaceBatch">
+        replace into ctop_etl_kuaishou_audience_account_daily(
+        stat_date,
+        account_id,
+        audience_type,
+        charge,
+        activation,
+        event_pay,
+        event_pay_purchase_amount,
+        event_next_day_stay,
+        aclick,
+        bclick,
+        photo_click,
+        photo_show,
+        gender,
+        age_segment
+        )
+        values
+        <foreach collection="list" item="appInfo" separator=",">
+            (
+            #{appInfo.statDate},
+            #{appInfo.accountId},
+            #{appInfo.audienceType},
+            #{appInfo.charge},
+            #{appInfo.activation},
+            #{appInfo.eventPay},
+            #{appInfo.eventPayPurchaseAmount},
+            #{appInfo.eventNextDayStay},
+            #{appInfo.aclick},
+            #{appInfo.bclick},
+            #{appInfo.photoClick},
+            #{appInfo.photoShow},
+            #{appInfo.gender},
+            #{appInfo.ageSegment}
+            )
+        </foreach>
+    </insert>
+
+    <select id="queryAudienceTypeInfo" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        account_id as 'accountId',
+        <if test="parType == 'alone'">
+            SUM(${value}) as 'value',
+        </if>
+        <if test="parType == 'more'">
+            <if test="value == 'activationCost'">
+                IFNULL(ROUND( SUM(charge)/ SUM(activation),2),0) as 'value',
+            </if>
+            <if test="value == 'eventPayRoi'">
+                IFNULL(ROUND( SUM(event_pay_purchase_amount)/ SUM(charge)*100,2),0) as 'value',
+            </if>
+            <if test="value == 'eventPayCost'">
+                IFNULL(ROUND( SUM(charge)/ SUM(event_pay),2),0) as 'value',
+            </if>
+            <if test="value == 'eventNextDayStayCost'">
+                IFNULL(ROUND(SUM(charge)/SUM(event_next_day_stay),2),0) as 'value',
+            </if>
+        </if>
+        ${type} as 'type'
+        FROM ctop_etl_kuaishou_audience_account_daily
+        where stat_date &gt;= DATE_FORMAT(date_sub(now(), interval 8 day), '%Y-%m-%d')
+        AND stat_date &lt;= DATE_FORMAT(date_sub(now(), interval 2 day), '%Y-%m-%d')
+        AND audience_type = #{audienceType}
+        AND account_id = #{accountId}
+        group by ${type}
+    </select>
+
+    <select id="queryEveryDayInfo" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        account_id as 'accountId',
+        stat_date as 'statDate',
+        <if test="parType == 'alone'">
+            ${value} as 'value',
+        </if>
+        <if test="parType == 'more'">
+            <if test="value == 'activationCost'">
+                IFNULL(ROUND( charge/ activation,2),0) as 'value',
+            </if>
+            <if test="value == 'eventPayRoi'">
+                IFNULL(ROUND(event_pay_purchase_amount/charge*100,2),0) as 'value',
+            </if>
+            <if test="value == 'eventPayCost'">
+                IFNULL(ROUND(charge / event_pay,2),0) as 'value',
+            </if>
+            <if test="value == 'eventNextDayStayCost'">
+                IFNULL(ROUND(charge/ event_next_day_stay,2),0) as 'value',
+            </if>
+        </if>
+        ${type} as 'type'
+        FROM ctop_etl_kuaishou_audience_account_daily
+        where stat_date &gt;= DATE_FORMAT(date_sub(now(), interval 8 day), '%Y-%m-%d')
+        AND stat_date &lt;= DATE_FORMAT(date_sub(now(), interval 2 day), '%Y-%m-%d')
+        AND audience_type = #{audienceType}
+        AND account_id = #{accountId}
+        group by stat_date,${type}
+    </select>
+</mapper>

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

@@ -81,7 +81,7 @@
     <select id="getOnedayAggregatebyDaily"
             resultType="cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountHourly">
         SELECT stat_date,
-               IFNULL(SUM(charge),0) as 'charge',
+               IFNULL(SUM(charge), 0) as 'charge',
                SUM(photo_show) as 'photoShow',
                SUM(photo_click) as 'photoClick',
                SUM(aclick) as 'aclick',
@@ -149,75 +149,113 @@
     </select>
 
 
-
-    <select id="getOnedayEtlReportList"
-            resultType="cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountHourly">
-        SELECT stat_date,
-               IFNULL(SUM(charge),0) as 'charge',
-               SUM(photo_show) as 'photoShow',
-               SUM(photo_click) as 'photoClick',
-               SUM(aclick) as 'aclick',
-               SUM(bclick) as 'bclick',
-               SUM(photo_share) as 'photoShare',
-               SUM(photo_comment) as 'photoComment',
-               SUM(photo_like) as 'photoLike',
-               SUM(follow) as 'follow',
-               SUM(cancel_follow) as 'cancelFollow',
-               SUM(report) as 'report',
-               SUM(block) as 'block',
-               SUM(negative) as 'negative',
-               SUM(download_started) as 'downloadStarted',
-               SUM(download_completed) as 'downloadCompleted',
-               SUM(activation) as 'activation',
-               SUM(submit) as 'submit',
-               SUM(event_pay_first_day) as 'eventPayFirstDay',
-               SUM(event_pay_purchase_amount_first_day) as 'eventPayPurchaseAmountFirstDay',
-               SUM(event_pay) as 'eventPay',
-               SUM(event_pay_purchase_amount) as 'eventPayPurchaseAmount',
-               SUM(event_register) as 'eventRegister',
-               SUM(event_jin_jian_app) as 'eventJinJianApp',
-               SUM(event_credit_grant_app) as 'eventCreditGrantApp',
-               SUM(event_order_paid) as 'eventOrderPaid',
-               SUM(event_order_paid_purchase_amount) as 'eventOrderPaidPurchaseAmount',
-               SUM(event_jin_jian_landing_page) as 'eventJinJianLandingPage',
-               SUM(event_credit_grant_landing_page) as 'eventCreditGrantLandingPage',
-               SUM(event_next_day_stay) as 'eventNextDayStay',
-               SUM(form_count) as 'formCount',
-               IFNULL(ROUND(SUM(charge) / SUM(activation), 2), 0) as 'activationCost',
-               IFNULL(ROUND(SUM(charge) / SUM(activation) * 1000, 2), 0) as 'impression1kCost',
-               IFNULL(ROUND(SUM(charge) / SUM(photo_click), 2), 0) as 'photoClickCost',
-               IFNULL(ROUND(SUM(charge) / SUM(bclick), 2), 0) as 'actionCost',
-               IFNULL(ROUND(SUM(charge) / SUM(download_started), 2), 0) as 'downloadStartedCost',
-               IFNULL(ROUND(SUM(charge) / SUM(download_completed), 2), 0) as 'downloadCompletedCost',
-               IFNULL(ROUND(SUM(charge) / SUM(form_count), 2), 0) as 'formCost',
-               IFNULL(ROUND(SUM(charge) / SUM(event_pay_first_day), 2), 0) as 'eventPayFirstDayCost',
-               IFNULL(ROUND(SUM(charge) / SUM(event_pay), 2), 0) as 'eventPayCost',
-               IFNULL(ROUND(SUM(charge) / SUM(event_register), 2), 0) as 'eventRegisterCost',
-               IFNULL(ROUND(SUM(charge) / SUM(event_next_day_stay), 2), 0) as 'eventNextDayStayCost',
-               IFNULL(ROUND(SUM(charge) / SUM(event_jin_jian_app), 2), 0) as 'eventJinJianAppCost',
-               IFNULL(ROUND(SUM(charge) / SUM(event_credit_grant_app), 2), 0) as 'eventCreditGrantAppCost',
-               IFNULL(ROUND(SUM(charge) / SUM(event_jin_jian_landing_page), 2), 0) as 'eventJinJianLandingPageCost',
-               IFNULL(ROUND(SUM(charge) / SUM(event_credit_grant_landing_page), 2),
-                      0) as 'eventCreditGrantLandingPageCost',
-               IFNULL(ROUND(SUM(charge) / SUM(submit), 2), 0) as 'submitCost',
-               IFNULL(ROUND(SUM(event_pay_purchase_amount_first_day) / SUM(charge) * 100, 2),
-                      0) as 'eventPayFirstDayRoi',
-               IFNULL(ROUND(SUM(event_pay_purchase_amount) / SUM(charge) * 100, 2), 0) as 'eventPayRoi',
-               IFNULL(ROUND(SUM(bclick) / SUM(activation) * 100, 2), 0) as 'actionRatio',
-               IFNULL(ROUND(SUM(photo_click) / SUM(photo_show) * 100, 2), 0) as 'photoClickRatio',
-               IFNULL(ROUND(SUM(download_started) / SUM(bclick) * 100, 2), 0) as 'downloadStartedRatio',
-               IFNULL(ROUND(SUM(download_completed) / SUM(download_started) * 100, 2), 0) as 'downloadCompletedRatio',
-               IFNULL(ROUND(SUM(activation) / SUM(download_completed) * 100, 2), 0) as 'activationRatio',
-               IFNULL(ROUND(SUM(event_register) / SUM(activation) * 100, 2), 0) as 'eventRegisterRatio',
-               IFNULL(ROUND(SUM(event_next_day_stay) / SUM(activation) * 100, 2), 0) as 'eventNextDayStayRatio',
-               IFNULL(ROUND(SUM(event_credit_grant_app) / SUM(event_jin_jian_app) * 100, 2),
-                      0) as 'eventCreditGrantAppRatio',
-               IFNULL(ROUND(SUM(form_count) / SUM(bclick) * 100, 2), 0) as 'formActionRatio',
-               IFNULL(ROUND(SUM(submit) / SUM(bclick) * 100, 2), 0) as 'submitRatio'
+    <select id="getOnedayEtlReportList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        <if test="type == 'alone'">
+            ${value} as 'value',
+        </if>
+        <if test="type == 'more'">
+            <if test="value == 'activationCost'">
+                IFNULL(ROUND(SUM(charge) / SUM(activation), 2), 0) as 'value',
+            </if>
+            <if test="value == 'impression1kCost'">
+                IFNULL(ROUND(SUM(charge) / SUM(aclick) * 1000, 2), 0) as 'value',
+            </if>
+            <if test="value == 'photoClickCost'">
+                IFNULL(ROUND(SUM(charge) / SUM(photo_click), 2), 0) as 'value',
+            </if>
+            <if test="value == 'actionCost'">
+                IFNULL(ROUND(SUM(charge) / SUM(bclick), 2), 0) as 'value',
+            </if>
+            <if test="value == 'play3sRatio'">
+                IFNULL(ROUND(SUM(play_3s_count) / SUM(photo_show) * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'downloadStartedCost'">
+                IFNULL(ROUND(SUM(charge) / SUM(download_started), 2), 0) as 'value',
+            </if>
+            <if test="value == 'downloadCompletedCost'">
+                IFNULL(ROUND(SUM(charge) / SUM(download_completed), 2), 0) as 'value',
+            </if>
+            <if test="value == 'formCost'">
+                IFNULL(ROUND(SUM(charge) / SUM(form_count), 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventPayFirstDayCost'">
+                IFNULL(ROUND(SUM(charge) / SUM(event_pay_first_day), 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventPayCost'">
+                IFNULL(ROUND(SUM(charge) / SUM(event_pay), 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventRegisterCost'">
+                IFNULL(ROUND(SUM(charge) / SUM(event_register), 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventNextDayStayCost'">
+                IFNULL(ROUND(SUM(charge) / SUM(event_next_day_stay), 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventJinJianAppCost'">
+                IFNULL(ROUND(SUM(charge) / SUM(event_jin_jian_app), 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventCreditGrantAppCost'">
+                IFNULL(ROUND(SUM(charge) / SUM(event_credit_grant_app), 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventJinJianLandingPageCost'">
+                IFNULL(ROUND(SUM(charge) / SUM(event_jin_jian_landing_page), 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventCreditGrantLandingPageCost'">
+                IFNULL(ROUND(SUM(charge) / SUM(event_credit_grant_landing_page), 2), 0) as 'value',
+            </if>
+            <if test="value == 'submitCost'">
+                IFNULL(ROUND(SUM(charge) / SUM(submit), 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventPayFirstDayRoi'">
+                IFNULL(ROUND(SUM(event_pay_purchase_amount_first_day) / SUM(charge) * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventPayRoi'">
+                IFNULL(ROUND(SUM(event_pay_purchase_amount) / SUM(charge) * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'actionRatio'">
+                IFNULL(ROUND(SUM(bclick) / SUM(aclick) * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'photoClickRatio'">
+                IFNULL(ROUND(SUM(photo_click) / SUM(photo_show) * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'downloadStartedRatio'">
+                IFNULL(ROUND(SUM(download_started) / SUM(bclick) * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'downloadCompletedRatio'">
+                IFNULL(ROUND(SUM(download_completed) / SUM(download_started) * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'activationRatio'">
+                IFNULL(ROUND(SUM(activation) / SUM(download_completed) * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventRegisterRatio'">
+                IFNULL(ROUND(SUM(event_register) / SUM(activation) * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventNextDayStayRatio'">
+                IFNULL(ROUND(SUM(event_next_day_stay) / SUM(activation) * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventCreditGrantAppRatio'">
+                IFNULL(ROUND(SUM(event_credit_grant_app) / SUM(event_jin_jian_app) * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'formActionRatio'">
+                IFNULL(ROUND(SUM(form_count) / SUM(bclick) * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'submitRatio'">
+                IFNULL(ROUND(SUM(submit) / SUM(bclick) * 100, 2), 0) as 'value',
+            </if>
+        </if>
+        stat_date
         FROM ctop_etl_kuaishou_report_account_daily
         WHERE account_id = #{accountId}
-          AND stat_date &gt;= #{startTime}
-          AND stat_date &lt;= #{endTime}
+        AND stat_date &gt;= #{startTime}
+        AND stat_date &lt;= #{endTime}
         group by stat_date
     </select>
+
+
+    <select id="getMaxChargeAccountId" resultType="java.lang.Long">
+        select account_id
+        from ctop_etl_kuaishou_report_account_hourly
+        where stat_date = DATE_FORMAT(now(), '%Y-%m-%d')
+        order by charge desc limit 1
+    </select>
 </mapper>

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

@@ -118,41 +118,104 @@
           AND stat_hour = #{hour}
     </select>
 
-    <select id="getOnedayEtlReportList"
-            resultType="cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountHourly">
-        SELECT *,
-               IFNULL(ROUND(charge / activation, 2), 0) as 'activationCost',
-               IFNULL(ROUND(charge / aclick * 1000, 2), 0) as 'impression1kCost',
-               IFNULL(ROUND(charge / photo_click, 2), 0) as 'photoClickCost',
-               IFNULL(ROUND(charge / bclick, 2), 0) as 'actionCost',
-               IFNULL(ROUND(play_3s_count / photo_show * 100, 2), 0) as 'play3sRatio',
-               IFNULL(ROUND(charge / download_started, 2), 0) as 'downloadStartedCost',
-               IFNULL(ROUND(charge / download_completed, 2), 0) as 'downloadCompletedCost',
-               IFNULL(ROUND(charge / form_count, 2), 0) as 'formCost',
-               IFNULL(ROUND(charge / event_pay_first_day, 2), 0) as 'eventPayFirstDayCost',
-               IFNULL(ROUND(charge / event_pay, 2), 0) as 'eventPayCost',
-               IFNULL(ROUND(charge / event_register, 2), 0) as 'eventRegisterCost',
-               IFNULL(ROUND(charge / event_next_day_stay, 2), 0) as 'eventNextDayStayCost',
-               IFNULL(ROUND(charge / event_jin_jian_app, 2), 0) as 'eventJinJianAppCost',
-               IFNULL(ROUND(charge / event_credit_grant_app, 2), 0) as 'eventCreditGrantAppCost',
-               IFNULL(ROUND(charge / event_jin_jian_landing_page, 2), 0) as 'eventJinJianLandingPageCost',
-               IFNULL(ROUND(charge / event_credit_grant_landing_page, 2), 0) as 'eventCreditGrantLandingPageCost',
-               IFNULL(ROUND(charge / submit, 2), 0) as 'submitCost',
-               IFNULL(ROUND(event_pay_purchase_amount_first_day / charge * 100, 2), 0) as 'eventPayFirstDayRoi',
-               IFNULL(ROUND(event_pay_purchase_amount / charge * 100, 2), 0) as 'eventPayRoi',
-               IFNULL(ROUND(bclick / aclick * 100, 2), 0) as 'actionRatio',
-               IFNULL(ROUND(photo_click / photo_show * 100, 2), 0) as 'photoClickRatio',
-               IFNULL(ROUND(download_started / bclick * 100, 2), 0) as 'downloadStartedRatio',
-               IFNULL(ROUND(download_completed / download_started * 100, 2), 0) as 'downloadCompletedRatio',
-               IFNULL(ROUND(activation / download_completed * 100, 2), 0) as 'activationRatio',
-               IFNULL(ROUND(event_register / activation * 100, 2), 0) as 'eventRegisterRatio',
-               IFNULL(ROUND(event_next_day_stay / activation * 100, 2), 0) as 'eventNextDayStayRatio',
-               IFNULL(ROUND(event_credit_grant_app / event_jin_jian_app * 100, 2), 0) as 'eventCreditGrantAppRatio',
-               IFNULL(ROUND(form_count / bclick * 100, 2), 0) as 'formActionRatio',
-               IFNULL(ROUND(submit / bclick * 100, 2), 0) as 'submitRatio'
+    <select id="getOnedayEtlReportList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT stat_date as 'statDate',
+        <if test="type == 'alone'">
+            ${value} as 'value',
+        </if>
+        <if test="type == 'more'">
+            <if test="value == 'activationCost'">
+                IFNULL(ROUND(charge / activation, 2), 0) as 'value',
+            </if>
+            <if test="value == 'impression1kCost'">
+                IFNULL(ROUND(charge / aclick * 1000, 2), 0) as 'value',
+            </if>
+            <if test="value == 'photoClickCost'">
+                IFNULL(ROUND(charge / photo_click, 2), 0) as 'value',
+            </if>
+            <if test="value == 'actionCost'">
+                IFNULL(ROUND(charge / bclick, 2), 0) as 'value',
+            </if>
+            <if test="value == 'play3sRatio'">
+                IFNULL(ROUND(play_3s_count / photo_show * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'downloadStartedCost'">
+                IFNULL(ROUND(charge / download_started, 2), 0) as 'value',
+            </if>
+            <if test="value == 'downloadCompletedCost'">
+                IFNULL(ROUND(charge / download_completed, 2), 0) as 'value',
+            </if>
+            <if test="value == 'formCost'">
+                IFNULL(ROUND(charge / form_count, 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventPayFirstDayCost'">
+                IFNULL(ROUND(charge / event_pay_first_day, 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventPayCost'">
+                IFNULL(ROUND(charge / event_pay, 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventRegisterCost'">
+                IFNULL(ROUND(charge / event_register, 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventNextDayStayCost'">
+                IFNULL(ROUND(charge / event_next_day_stay, 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventJinJianAppCost'">
+                IFNULL(ROUND(charge / event_jin_jian_app, 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventCreditGrantAppCost'">
+                IFNULL(ROUND(charge / event_credit_grant_app, 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventJinJianLandingPageCost'">
+                IFNULL(ROUND(charge / event_jin_jian_landing_page, 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventCreditGrantLandingPageCost'">
+                IFNULL(ROUND(charge / event_credit_grant_landing_page, 2), 0) as 'value',
+            </if>
+            <if test="value == 'submitCost'">
+                IFNULL(ROUND(charge / submit, 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventPayFirstDayRoi'">
+                IFNULL(ROUND(event_pay_purchase_amount_first_day / charge * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventPayRoi'">
+                IFNULL(ROUND(event_pay_purchase_amount / charge * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'actionRatio'">
+                IFNULL(ROUND(bclick / aclick * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'photoClickRatio'">
+                IFNULL(ROUND(photo_click / photo_show * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'downloadStartedRatio'">
+                IFNULL(ROUND(download_started / bclick * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'downloadCompletedRatio'">
+                IFNULL(ROUND(download_completed / download_started * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'activationRatio'">
+                IFNULL(ROUND(activation / download_completed * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventRegisterRatio'">
+                IFNULL(ROUND(event_register / activation * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventNextDayStayRatio'">
+                IFNULL(ROUND(event_next_day_stay / activation * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'eventCreditGrantAppRatio'">
+                IFNULL(ROUND(event_credit_grant_app / event_jin_jian_app * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'formActionRatio'">
+                IFNULL(ROUND(form_count / bclick * 100, 2), 0) as 'value',
+            </if>
+            <if test="value == 'submitRatio'">
+                IFNULL(ROUND(submit / bclick * 100, 2), 0) as 'value',
+            </if>
+        </if>
+        stat_hour as 'statHour'
         FROM ctop_etl_kuaishou_report_account_hourly
         WHERE account_id = #{accountId}
-          AND stat_date = #{startTime}
+        AND stat_date = #{startTime}
         GROUP BY stat_hour
     </select>
 

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

@@ -234,4 +234,27 @@
         limit 9
         ) t1
     </select>
+
+    <select id="queryEveryDayAudienceInfo"
+            resultType="cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouAudienceAccountDaily">
+        SELECT stat_date,
+               account_id,
+               audience_type,
+               charge,
+               activation,
+               event_pay,
+               event_pay_purchase_amount,
+               event_next_day_stay,
+               aclick,
+               bclick,
+               photo_click,
+               photo_show,
+               gender,
+               age_segment
+        FROM ctop_kuaishou_audience_report_daily_account
+        where stat_date = DATE_FORMAT(date_sub(now(), interval 2 day), '%Y-%m-%d')
+          AND audience_type in ('ageSegment', 'gender')
+    </select>
+
+
 </mapper>

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

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouAudienceAccountDaily;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+/**
+ * @Description: 人群分析报表——年龄、性别数据
+ * @Author: jeecg-boot
+ * @Date:   2021-03-09
+ * @Version: V1.0
+ */
+public interface IEtlKuaishouAudienceAccountDailyService extends IService<EtlKuaishouAudienceAccountDaily> {
+
+    void queryEveryDayAudienceInfo();
+
+    Result<Object> getSexInfo(JSONObject request);
+
+    Result<Object> getAgeInfo(JSONObject request);
+}

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

@@ -21,4 +21,6 @@ public interface IEtlKuaishouReportAccountHourlyService extends IService<EtlKuai
     Result<Object> getAggregateByHour(JSONObject request) throws ParseException;
 
     Result<Object> getEtlReportList(JSONObject request);
+
+    Result<Object> getMaxChargeAccountId();
 }

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

@@ -0,0 +1,92 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl.service.impl;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouAudienceAccountDaily;
+import cn.com.ctop.kuaishou.modules.report.enums.CheckParametersEnum;
+import cn.com.ctop.kuaishou.modules.report.mapper.EtlKuaishouAudienceAccountDailyMapper;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyAccountMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaishouAudienceAccountDailyService;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 人群分析报表——年龄、性别数据
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-03-09
+ */
+@Service
+public class EtlKuaishouAudienceAccountDailyServiceImpl extends ServiceImpl<EtlKuaishouAudienceAccountDailyMapper, EtlKuaishouAudienceAccountDaily> implements IEtlKuaishouAudienceAccountDailyService {
+    @Autowired
+    private KuaishouAudienceReportDailyAccountMapper accountMapper;
+    @Autowired
+    private EtlKuaishouAudienceAccountDailyMapper accountDailyMapper;
+
+    @Override
+    public void queryEveryDayAudienceInfo() {
+        List<EtlKuaishouAudienceAccountDaily> list = accountMapper.queryEveryDayAudienceInfo();
+        if (!Check.isNull(list)) {
+            accountDailyMapper.replaceBatch(list);
+        }
+    }
+
+    @Override
+    public Result<Object> getSexInfo(JSONObject request) {
+        Long accountId = request.getLong("accountId");
+        String value = request.getString("value");
+        String dataType = request.getString("dataType");
+        if (Check.isNull(accountId) || Check.isNull(value)) {
+            return Result.error("必填参数为空");
+        }
+        String parType = "more";
+        if (CheckParametersEnum.isInclude(value)) {
+            value = CheckParametersEnum.getSqlName(value);
+            parType = "alone";
+        }
+        String audienceType = "gender";
+        String type = "gender";
+        List<JSONObject> list = null;
+        if ("pie".equals(dataType)) {
+            list = accountDailyMapper.queryAudienceTypeInfo(value, type, accountId, audienceType, parType);
+        } else if ("line".equals(dataType)) {
+            list = accountDailyMapper.queryEveryDayInfo(value, type, accountId, audienceType, parType);
+        }
+        if (Check.isNull(list)) {
+            return Result.error("未查询到数据");
+        }
+        return Result.ok(list);
+    }
+
+    @Override
+    public Result<Object> getAgeInfo(JSONObject request) {
+        Long accountId = request.getLong("accountId");
+        String value = request.getString("value");
+        String dataType = request.getString("dataType");
+        if (Check.isNull(accountId) || Check.isNull(value) || Check.isNull(dataType)) {
+            return Result.error("必填参数为空");
+        }
+        String parType = "more";
+        if (CheckParametersEnum.isInclude(value)) {
+            value = CheckParametersEnum.getSqlName(value);
+            parType = "alone";
+        }
+        String audienceType = "ageSegment";
+        String type = "age_segment";
+        List<JSONObject> list = null;
+        if ("pie".equals(dataType)) {
+            list = accountDailyMapper.queryAudienceTypeInfo(value, type, accountId, audienceType, parType);
+        } else if ("line".equals(dataType)) {
+            list = accountDailyMapper.queryEveryDayInfo(value, type, accountId, audienceType, parType);
+        }
+        if (Check.isNull(list)) {
+            return Result.error("未查询到数据");
+        }
+        return Result.ok(list);
+    }
+}

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

@@ -3,6 +3,7 @@ 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.EtlKuaishouReportAccountHourly;
+import cn.com.ctop.kuaishou.modules.report.enums.CheckParametersEnum;
 import cn.com.ctop.kuaishou.modules.report.mapper.EtlKuaishouReportAccountDailyMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.EtlKuaishouReportAccountHourlyMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportHourlyAccountMapper;
@@ -89,26 +90,39 @@ public class EtlKuaishouReportAccountHourlyServiceImpl extends ServiceImpl<EtlKu
     public Result<Object> getEtlReportList(JSONObject request) {
         Long accountId = request.getLong("accountId");
         String startTime = request.getString("startTime");
-        if (Check.isNull(accountId) || Check.isNull(startTime)) {
-            return Result.error("请选择账户和时间");
+        String value = request.getString("value");
+        if (Check.isNull(accountId) || Check.isNull(startTime) || Check.isNull(value)) {
+            return Result.error("必填参数为空");
+        }
+        //type alone 是独立字段例如:charge,activation,more是复杂字段
+        String type = "more";
+        if (CheckParametersEnum.isInclude(value)) {
+            type = "alone";
+            value = CheckParametersEnum.getSqlName(value);
         }
         String endTime = request.getString("endTime");
         JSONObject obj = new JSONObject();
-        List<EtlKuaishouReportAccountHourly> todayList = null;
-        List<EtlKuaishouReportAccountHourly> yesterdayList = null;
+        List<JSONObject> todayList = null;
+        List<JSONObject> yesterdayList = null;
         if (Check.isNull(endTime)) {
-            todayList = etlHourlyAccountMapper.getOnedayEtlReportList(startTime, accountId);
+            todayList = etlHourlyAccountMapper.getOnedayEtlReportList(startTime, accountId, value, type);
             String lastDay = DateUtils.getLastDay(startTime, 1);
-            yesterdayList = etlHourlyAccountMapper.getOnedayEtlReportList(lastDay, accountId);
+            yesterdayList = etlHourlyAccountMapper.getOnedayEtlReportList(lastDay, accountId, value, type);
         } else {
-            todayList = etlDailyAccountMapper.getOnedayEtlReportList(startTime, endTime, accountId);
+            todayList = etlDailyAccountMapper.getOnedayEtlReportList(startTime, endTime, accountId, value, type);
             int days = DateUtils.dateDiff(startTime, endTime);
             String endTime2 = DateUtils.getLastDay(startTime, 1);
             String startTime2 = DateUtils.getLastDay(endTime2, days);
-            yesterdayList = etlDailyAccountMapper.getOnedayEtlReportList(startTime2, endTime2, accountId);
+            yesterdayList = etlDailyAccountMapper.getOnedayEtlReportList(startTime2, endTime2, accountId, value, type);
         }
         obj.put("today", todayList);
         obj.put("yesterday", yesterdayList);
         return Result.ok(obj);
     }
+
+    @Override
+    public Result<Object> getMaxChargeAccountId() {
+        Long accountId = etlDailyAccountMapper.getMaxChargeAccountId();
+        return Result.ok(accountId);
+    }
 }