Browse Source

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

zhaoxian 4 years ago
parent
commit
8b2412f958
18 changed files with 873 additions and 382 deletions
  1. 19 13
      jeecg-boot-base-common/src/main/java/org/jeecg/common/constant/AccountReportConstants.java
  2. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  3. 3 3
      jeecg-boot-module-system/src/main/resources/application-dev.yml
  4. 2 12
      module-common/src/main/java/cn/com/ctop/common/module/utils/ExportExcelUtils.java
  5. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaiShouAppInfoServiceImpl.java
  6. 231 46
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsVideoReportCtrl.java
  7. 6 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KsVideoReportMapper.java
  8. 77 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KsVideoReportMapper.xml
  9. 46 36
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaiShouYiCheReportMapper.xml
  10. 7 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKsVideoReportService.java
  11. 25 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KsVideoReportServiceImpl.java
  12. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaiShouAccountReportServiceImpl.java
  13. 16 16
      module-kuaishou/src/main/resources/json_template/kuaishou_filed_mapping.json
  14. 221 0
      module-kuaishou/src/main/resources/json_template/kuaishou_video_report_filed_mapping.json
  15. 1 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/mapper/xml/ETLReportBytedanceVideoMapper.xml
  16. 196 229
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceHomepageMapper.xml
  17. 7 7
      module-toutiao/src/main/resources/json_template/bytedance_filed_mapping.json
  18. 8 8
      module-toutiao/src/main/resources/json_template/bytedance_video_report_mapping.json

+ 19 - 13
jeecg-boot-base-common/src/main/java/org/jeecg/common/constant/AccountReportConstants.java

@@ -6,18 +6,20 @@ import java.util.HashMap;
 import java.util.Map;
 
 /**
- *  Created by JQ.bi on 2020.5.30
+ * Created by JQ.bi on 2020.5.30
  */
 public class AccountReportConstants {
 
     /**
      * 私有构造器
      */
-    private AccountReportConstants(){
+    private AccountReportConstants() {
 
     }
 
-    /** 单体实例 */
+    /**
+     * 单体实例
+     */
     private static AccountReportConstants instance;
 
     /**
@@ -34,22 +36,26 @@ public class AccountReportConstants {
      * 字典数据
      */
     //头条字段映射
-    public static Map<String, Map<String,Object>> dicMapBy = new HashMap<>();
+    public static Map<String, Map<String, Object>> dicMapBy = new HashMap<>();
     //快手字段映射
-    public static Map<String, Map<String,Object>> dicMapKs = new HashMap<>();
+    public static Map<String, Map<String, Object>> dicMapKs = new HashMap<>();
     //头条视频报表字段映射
-    public static Map<String, Map<String,Object>> dicMapByVideo= new HashMap<>();
+    public static Map<String, Map<String, Object>> dicMapByVideo = new HashMap<>();
+    public static Map<String, Map<String, Object>> kuaishouVideoReportMap = new HashMap<>();
+
     /**
      * 初始化字典
      */
-    public void init(){
+    public void init() {
         //加载json文件
-        Object jsonBy=JsonResourceUtil.getJsonObjFromResource("/json_template/bytedance_filed_mapping.json");
-        Object jsonKs=JsonResourceUtil.getJsonObjFromResource("/json_template/kuaishou_filed_mapping.json");
-        Object jsonByVideo=JsonResourceUtil.getJsonObjFromResource("/json_template/bytedance_video_report_mapping.json");
+        Object jsonBy = JsonResourceUtil.getJsonObjFromResource("/json_template/bytedance_filed_mapping.json");
+        Object jsonKs = JsonResourceUtil.getJsonObjFromResource("/json_template/kuaishou_filed_mapping.json");
+        Object KuaiShouVideoJson = JsonResourceUtil.getJsonObjFromResource("/json_template/kuaishou_video_report_filed_mapping.json");
+        Object jsonByVideo = JsonResourceUtil.getJsonObjFromResource("/json_template/bytedance_video_report_mapping.json");
         //json 转为map存为静态常量
-        dicMapBy=JsonResourceUtil.jsonToMap(jsonBy);
-        dicMapKs=JsonResourceUtil.jsonToMap(jsonKs);
-        dicMapByVideo=JsonResourceUtil.jsonToMap(jsonByVideo);
+        dicMapBy = JsonResourceUtil.jsonToMap(jsonBy);
+        dicMapKs = JsonResourceUtil.jsonToMap(jsonKs);
+        dicMapByVideo = JsonResourceUtil.jsonToMap(jsonByVideo);
+        kuaishouVideoReportMap = JsonResourceUtil.jsonToMap(KuaiShouVideoJson);
     }
 }

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

@@ -190,6 +190,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/ai/aiKuaiShouAppInfo/*", "anon");
         filterChainDefinitionMap.put("/explore/*", "anon");
         filterChainDefinitionMap.put("/ai/batchUpdate/*", "anon");
+        filterChainDefinitionMap.put("/ctop/kuaishou/videoReport/*", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

+ 3 - 3
jeecg-boot-module-system/src/main/resources/application-dev.yml

@@ -135,9 +135,9 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
-          url: jdbc:mysql://139.186.151.174:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&allowMultiQueries=true
-          username: hcst
-          password: hcst@2020
+          url: jdbc:mysql://139.186.27.96:4000/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&allowMultiQueries=true
+          username: data
+          password: hcst@2021
           driver-class-name: com.mysql.jdbc.Driver
           # 多数据源配置
           #multi-datasource1:

+ 2 - 12
module-common/src/main/java/cn/com/ctop/common/module/utils/ExportExcelUtils.java

@@ -1,18 +1,8 @@
 package cn.com.ctop.common.module.utils;
 
 
-import org.apache.poi.ss.usermodel.BorderStyle;
-import org.apache.poi.ss.usermodel.FillPatternType;
-import org.apache.poi.ss.usermodel.HorizontalAlignment;
-import org.apache.poi.ss.usermodel.IndexedColors;
-import org.apache.poi.ss.usermodel.VerticalAlignment;
-import org.apache.poi.xssf.usermodel.XSSFCell;
-import org.apache.poi.xssf.usermodel.XSSFCellStyle;
-import org.apache.poi.xssf.usermodel.XSSFFont;
-import org.apache.poi.xssf.usermodel.XSSFRichTextString;
-import org.apache.poi.xssf.usermodel.XSSFRow;
-import org.apache.poi.xssf.usermodel.XSSFSheet;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.*;
 
 import java.math.BigDecimal;
 import java.util.List;

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

@@ -126,6 +126,12 @@ public class AiKuaiShouAppInfoServiceImpl extends ServiceImpl<AiKuaiShouAppInfoM
         for (AiKuaiShouAppInfo appInfo : appListByStatus) {
             AiKuaiShouAppInfo updateAppInfo = new AiKuaiShouAppInfo();
             updateAppInfo.setId(appInfo.getId());
+            if (Check.isNull(appInfo.getUrl())) {
+                updateAppInfo.setStatus(3);
+                updateAppInfo.setRemark("下载链接为空");
+                this.updateById(updateAppInfo);
+                continue;
+            }
             String md5 = MD5Util.getMd5(appInfo.getUrl());
             if (Check.isNull(md5)) {
                 updateAppInfo.setStatus(3);

+ 231 - 46
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsVideoReportCtrl.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.report.controller;
 
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.ExportExcelUtils;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.kuaishou.modules.report.service.IKsVideoReportService;
@@ -22,7 +23,9 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Created by JQ.bi on 2020.09.27
@@ -35,38 +38,86 @@ public class KsVideoReportCtrl {
     @Autowired
     IKsVideoReportService ksVideoReportService;
 
+
+    @PostMapping("/getDesignList")
+    public Result<List<JSONObject>> getDesignList() {
+        Result<List<JSONObject>> result = new Result<>();
+        try {
+            List<JSONObject> designList = ksVideoReportService.getDesignList();
+            result.setSuccess(true);
+            result.setResult(designList);
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage(), e);
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
     @PostMapping("/list")
     public Result<PageInfo<JSONObject>> getListReport(@RequestBody JSONObject requestBody) {
-
         Result<PageInfo<JSONObject>> result = new Result<>();
-        if (requestBody.isEmpty()) {
-            log.error("request body is empty");
-            result.setSuccess(false);
-        } else {
-            JSONArray accountIds = requestBody.getJSONArray("accountIds");
-            String startDate = requestBody.getString("startDate");
-            String endDate = requestBody.getString("endDate");
-            String clip = requestBody.getString("clip");
-            String shot = requestBody.getString("shot");
-            String plan = requestBody.getString("plan");
-            String target = requestBody.getString("target");
-            String order = requestBody.getString("order");
+        try {
+            if (Check.isNull(requestBody)) {
+                new Exception("入参不能为空");
+            }
             int pageSize = requestBody.getInteger("pageSize");
+            if (Check.isNull(pageSize)) {
+                throw new Exception("请输入查询每页条数");
+            }
             int pageNo = requestBody.getInteger("pageNo");
-
-            String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.dicMapKs);
-
-            try {
-                if(accountIds.isEmpty()){
-                    accountIds=null;
-                }
-                PageInfo<JSONObject> listData = ksVideoReportService.getVideoReportBy(accountIds, startDate, endDate, filedAll, target, order, clip, shot,plan,pageSize, pageNo);
-                result.setResult(listData);
-                result.setSuccess(true);
-            } catch (Exception e) {
-                log.error(e.getMessage(), e);
-                result.setSuccess(false);
+            if (Check.isNull(pageNo)) {
+                throw new Exception("请输入查询页数");
+            }
+            String startDate = requestBody.getString("startDate");
+            if (Check.isNull(startDate)) {
+                throw new Exception("请输入查询开始时间");
+            }
+            String endDate = requestBody.getString("endDate");
+            if (Check.isNull(endDate)) {
+                throw new Exception("请输入查询结束时间");
             }
+            String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.kuaishouVideoReportMap);
+            //   System.err.println(filedAll);
+            if (Check.isNull(filedAll)) {
+                throw new Exception("初始化查询 字段返回为空");
+            }
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("filed", filedAll);
+            requestMap.put("startDate", startDate);
+            requestMap.put("endDate", endDate);
+            if (!Check.isNull(requestBody.getJSONArray("accountIds"))) {
+                requestMap.put("accountIds", requestBody.getJSONArray("accountIds"));
+            }
+            if (!Check.isNull(requestBody.getString("clipId"))) {
+                requestMap.put("clipId", requestBody.getString("clipId"));
+            }
+            if (!Check.isNull(requestBody.getString("shotId"))) {
+                requestMap.put("shotId", requestBody.getString("shotId"));
+            }
+            if (!Check.isNull(requestBody.getString("planId"))) {
+                requestMap.put("planId", requestBody.getString("planId"));
+            }
+            if (!Check.isNull(requestBody.getString("leaderId"))) {
+                requestMap.put("leaderId", requestBody.getString("leaderId"));
+            }
+            if (!Check.isNull(requestBody.getString("target"))) {
+                requestMap.put("target", requestBody.getString("target"));
+            }
+            if (!Check.isNull(requestBody.getString("order"))) {
+                requestMap.put("order", requestBody.getString("order"));
+            }
+            PageInfo<JSONObject> listData = ksVideoReportService.getKuaiShouVideoPageReportByMap(requestMap, pageSize, pageNo);
+            if (Check.isNull(listData)) {
+                throw new Exception("暂无素材相关信息,请检查账户");
+            }
+            result.setSuccess(true);
+            result.setResult(listData);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.setSuccess(false);
+            result.setMessage(e.toString());
         }
         return result;
     }
@@ -90,7 +141,7 @@ public class KsVideoReportCtrl {
                 if (accountIds.isEmpty()) {
                     accountIds = null;
                 }
-                List<JSONObject> listData = ksVideoReportService.getVideoDetailBy(accountIds, startDate, endDate, filedAll,signature);
+                List<JSONObject> listData = ksVideoReportService.getVideoDetailBy(accountIds, startDate, endDate, filedAll, signature);
                 result.setResult(listData);
                 result.setSuccess(true);
             } catch (Exception e) {
@@ -106,8 +157,8 @@ public class KsVideoReportCtrl {
                                HttpServletRequest request,
                                HttpServletResponse response) {
         //加一个参数区分是table页,还是详情页。
-        String exportType= requestBody.getString("exportType");
-        if(exportType.isEmpty()){
+        String exportType = requestBody.getString("exportType");
+        if (exportType.isEmpty()) {
             return;
         }
         JSONArray columns = requestBody.getJSONArray("columns");
@@ -118,20 +169,20 @@ public class KsVideoReportCtrl {
         String filed = JsonResourceUtil.joinFiled(AccountReportConstants.dicMapKs, columns);
         List<String> titles = new ArrayList<>(JsonResourceUtil.joinTitle(AccountReportConstants.dicMapKs, columns));
         //此处增加两个元素是为了保证数据顺序
-        if("exportDetail".equals(exportType)){
-            titles.add(0,"客户");
-            titles.add(1,"项目名称");
-            titles.add(2,"时间");
-            titles.add(3,"消耗");
+        if ("exportDetail".equals(exportType)) {
+            titles.add(0, "客户");
+            titles.add(1, "项目名称");
+            titles.add(2, "时间");
+            titles.add(3, "消耗");
             columns.add(0, "advertiserName");
             columns.add(1, "projectName");
             columns.add(2, "statDate");
-        }else{
-            titles.add(0,"唯一标识");
-            titles.add(1,"视频");
-            titles.add(2,"视频名称");
-            titles.add(3,"项目名称");
-            titles.add(4,"上传时间");
+        } else {
+            titles.add(0, "唯一标识");
+            titles.add(1, "视频");
+            titles.add(2, "视频名称");
+            titles.add(3, "项目名称");
+            titles.add(4, "上传时间");
             titles.addAll(JsonResourceUtil.joinTitle(AccountReportConstants.dicMapKs, columns));
             columns.add(0, "signature");
             columns.add(1, "url");
@@ -152,13 +203,13 @@ public class KsVideoReportCtrl {
         String plan = requestBody.getString("plan");
         String target = requestBody.getString("target");
         String order = requestBody.getString("order");
-        List<JSONObject> excelData=null;
-        if("exportTable".equals(exportType)){
-            excelData = ksVideoReportService.exportExcelReportBy(accountIds, startDate, endDate, filed, target, order,clip,shot,plan);
-        }else if("exportDetail".equals(exportType)){
-            excelData = ksVideoReportService.getVideoDetailBy(accountIds,startDate,endDate,filed,signature);
+        List<JSONObject> excelData = null;
+        if ("exportTable".equals(exportType)) {
+            excelData = ksVideoReportService.exportExcelReportBy(accountIds, startDate, endDate, filed, target, order, clip, shot, plan);
+        } else if ("exportDetail".equals(exportType)) {
+            excelData = ksVideoReportService.getVideoDetailBy(accountIds, startDate, endDate, filed, signature);
         }
-        if (null!=excelData&&excelData.isEmpty()) {
+        if (null != excelData && excelData.isEmpty()) {
             return;
         }
         List<List<Object>> excelList = new ArrayList<>();
@@ -183,4 +234,138 @@ public class KsVideoReportCtrl {
             log.error(e.getMessage());
         }
     }
+
+
+    @PostMapping("/excelV2")
+    public void excelV2(@RequestBody JSONObject requestBody,
+                        HttpServletRequest request,
+                        HttpServletResponse response) {
+        Result<PageInfo<JSONObject>> result = new Result<>();
+        try {
+
+
+            if (Check.isNull(requestBody)) {
+                throw new Exception("入参不能为空");
+            }
+            JSONArray columns = requestBody.getJSONArray("columns");
+            if (Check.isNull(columns)) {
+                throw new Exception("请传入表头");
+            }
+
+            String startDate = requestBody.getString("startDate");
+            if (Check.isNull(startDate)) {
+                throw new Exception("请输入查询开始时间");
+            }
+            String endDate = requestBody.getString("endDate");
+            if (Check.isNull(endDate)) {
+                throw new Exception("请输入查询结束时间");
+            }
+            String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.kuaishouVideoReportMap);
+            //   System.err.println(filedAll);
+            if (Check.isNull(filedAll)) {
+                throw new Exception("初始化查询 字段返回为空");
+            }
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("filed", filedAll);
+            requestMap.put("startDate", startDate);
+            requestMap.put("endDate", endDate);
+            if (!Check.isNull(requestBody.getJSONArray("accountIds"))) {
+                requestMap.put("accountIds", requestBody.getJSONArray("accountIds"));
+            }
+            if (!Check.isNull(requestBody.getString("clipId"))) {
+                requestMap.put("clipId", requestBody.getString("clipId"));
+            }
+            if (!Check.isNull(requestBody.getString("shotId"))) {
+                requestMap.put("shotId", requestBody.getString("shotId"));
+            }
+            if (!Check.isNull(requestBody.getString("planId"))) {
+                requestMap.put("planId", requestBody.getString("planId"));
+            }
+            if (!Check.isNull(requestBody.getString("leaderId"))) {
+                requestMap.put("leaderId", requestBody.getString("leaderId"));
+            }
+            if (!Check.isNull(requestBody.getString("target"))) {
+                requestMap.put("target", requestBody.getString("target"));
+            }
+            if (!Check.isNull(requestBody.getString("order"))) {
+                requestMap.put("order", requestBody.getString("order"));
+            }
+            List<JSONObject> listData = ksVideoReportService.getKuaiShouVideoReportByMap(requestMap);
+            if (Check.isNull(listData)) {
+                throw new Exception("暂无素材相关信息,请检查账户");
+            }
+            columns.add(0, "materialName");
+            columns.add(1, "channel");
+            columns.add(2, "designLeader");
+            columns.add(4, "clip");
+            columns.add(4, "plan");
+            columns.add(5, "shot");
+            columns.add(columns.size(), "url");
+
+            List<String> titles = new ArrayList<>();
+            titles.add(0, "素材名称");
+            titles.add(1, "渠道");
+            titles.add(2, "设计负责人");
+            titles.add(3, "剪辑");
+            titles.add(4, "编导");
+            titles.add(5, "拍摄");
+
+
+            //  ArrayList<String> fileIds = JsonResourceUtil.joinTitle(AccountReportConstants.kuaishouVideoReportMap, columns);
+            titles = getfileIds(AccountReportConstants.kuaishouVideoReportMap, columns, titles);
+            titles.add(columns.size(), "素材链接");
+            List<List<Object>> excelList = new ArrayList<>();
+            for (int i = 0; i < listData.size(); i++) {
+                List<Object> temp = new ArrayList<>();
+                JSONObject jsonObject = listData.get(i);
+                for (int j = 0; j < columns.size(); j++) {
+                    String key = columns.getString(j);
+                    String value = jsonObject.getString(key);
+                    temp.add(value);
+                }
+                excelList.add(temp);
+            }
+
+
+            try {
+                //  String[] headers = {"视频", "视频md5", "花费", "安卓下载完成数", "封面曝光数", "封面点击数", "素材曝光数", "行为数", "封面点击率", "行为率", "均千次封面曝光花费(元)", "平均封面点击单价(元)", "平均行为单价(元)", "转化数", "转化单价(元)"};
+                String[] strings = titles.toArray(new String[]{});
+                OutputStream os = response.getOutputStream();
+                ExportExcelUtils eeu = new ExportExcelUtils();
+                XSSFWorkbook workbook = new XSSFWorkbook();
+                eeu.exportExcel(workbook, 0, "快手素材报表", strings, excelList);
+                HttpUtils.setResponseHeader(response, "快手素材.xlsx");
+                workbook.write(os);
+                os.flush();
+                os.close();
+            } catch (IOException e) {
+                log.error(e.getMessage());
+            }
+
+
+            result.setSuccess(true);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage(), e);
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+
+    }
+
+    private List<String> getfileIds(Map<String, Map<String, Object>> kuaishouVideoReportMap, JSONArray columns, List<String> titles) {
+        for (int i = 0; i < columns.size(); i++) {
+            String string = columns.getString(i);
+            Map<String, Object> stringObjectMap = kuaishouVideoReportMap.get(string);
+            if (Check.isNull(stringObjectMap)) {
+                continue;
+            }
+            Object comment = stringObjectMap.get("comment");
+            titles.add(String.valueOf(comment));
+
+        }
+        return titles;
+    }
 }

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

@@ -5,11 +5,15 @@ import com.alibaba.fastjson.JSONObject;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 public interface KsVideoReportMapper {
 
-    List<JSONObject> queryVideoReportBy(@Param("accountIds") JSONArray accountIds,@Param("startDate") String startDate,@Param("endDate") String endDate,@Param("filed") String filed,@Param("target") String target,@Param("order") String order,@Param("clip") String clip,@Param("shot") String shot,@Param("plan") String plan);
+    List<JSONObject> queryVideoReportBy(@Param("accountIds") JSONArray accountIds, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("filed") String filed, @Param("target") String target, @Param("order") String order, @Param("clip") String clip, @Param("shot") String shot, @Param("plan") String plan);
 
-    List<JSONObject> queryVideoDetailBy(@Param("accountIds") JSONArray accountIds,@Param("startDate") String startDate,@Param("endDate") String endDate,@Param("filed") String filed,@Param("signature") String signature);
+    List<JSONObject> queryVideoDetailBy(@Param("accountIds") JSONArray accountIds, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("filed") String filed, @Param("signature") String signature);
 
+    List<JSONObject> getKuaiShouVideoReportByMap(Map<String, Object> requestMap);
+
+    List<JSONObject> getDesignList();
 }

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

@@ -2,13 +2,67 @@
 <!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.KsVideoReportMapper">
 
+    <select id="getKuaiShouVideoReportByMap" resultType="com.alibaba.fastjson.JSONObject" parameterType="map">
+        SELECT
+        t1.*,
+        t2.clip_name as clip,
+        t2.plan_name as plan,
+        t2.shot_name as shot,
+        t2.design_team_leader_name as designLeader,
+        t2.video_name as materialName,
+        t2.cover_url as coverUrl,
+        t2.url as url ,
+        t2.channel_name AS channel,
+        t2.state_date as createTime
+        FROM
+        (select ${filed}
+        from ctop_etl_kuaishou_account_material_report_daily t1
+        where 1 = 1
+        <if test="accountIds !=null and accountIds != ''">
+            and t1.account_id in
+            <foreach item="item" index="index" collection="accountIds"
+                     open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="startDate !=null and startDate != ''">
+            AND t1.stat_date &gt;= #{startDate}
+        </if>
+        <if test="endDate !=null and endDate != ''">
+            AND t1.stat_date &lt;= #{endDate}
+        </if>
+        GROUP BY t1.signature
+        ORDER BY ${target} ${order}
+        ) t1
+        LEFT JOIN ctop_etl_kuaishou_video_info t2
+        ON t1.signature = t2.video_code
+        WHERE
+        1 = 1
+        <if test="leaderId !=null and leaderId != ''">
+            AND t2.design_team_leader_id = #{leaderId}
+        </if>
+        <if test="clipId !=null and clipId != ''">
+            AND t2.clip_id = #{clipId}
+        </if>
+        <if test="planId !=null and planId != ''">
+            AND t2.plan_id = #{planId}
+        </if>
+        <if test="shotId !=null and shotId != ''">
+            AND t2.shot_id = #{shotId}
+        </if>
+    </select>
+
+
     <select id="queryVideoReportBy" resultType="com.alibaba.fastjson.JSONObject">
         SELECT * from (SELECT
         t1.signature,
         t1.photo_url as url,
-        IFNULL((SELECT u.realname FROM ctop_material_ascription t3 LEFT JOIN sys_user u on t3.clip_id=u.id where t3.material_id=t1.signature limit 1),'') AS clip,
-        IFNULL((SELECT u.realname FROM ctop_material_ascription t3 LEFT JOIN sys_user u on t3.shot_id=u.id where t3.material_id=t1.signature limit 1),'') AS shot,
-        IFNULL((SELECT u.realname FROM ctop_material_ascription t3 LEFT JOIN sys_user u on t3.plan_id=u.id where t3.material_id=t1.signature limit 1),'') AS plan,
+        IFNULL((SELECT u.realname FROM ctop_material_ascription t3 LEFT JOIN sys_user u on t3.clip_id=u.id where
+        t3.material_id=t1.signature limit 1),'') AS clip,
+        IFNULL((SELECT u.realname FROM ctop_material_ascription t3 LEFT JOIN sys_user u on t3.shot_id=u.id where
+        t3.material_id=t1.signature limit 1),'') AS shot,
+        IFNULL((SELECT u.realname FROM ctop_material_ascription t3 LEFT JOIN sys_user u on t3.plan_id=u.id where
+        t3.material_id=t1.signature limit 1),'') AS plan,
         t1.cover_url as converUrl,
         (select t2.material_name from ctop_material_info t2 where t2.code=t1.signature limit 1) AS materialName,
         (SELECT project_name FROM ctop_project t4 WHERE t4.id = t3.project_id) AS projectName,
@@ -76,4 +130,24 @@
         GROUP BY t1.signature,t1.stat_date
         order by t1.stat_date desc
     </select>
+
+    <select id="getDesignList" resultType="com.alibaba.fastjson.JSONObject">
+    SELECT
+	t1.user_id AS 'userId',
+	LEFT (t1.company_name, 2) AS 'companyName',
+	t3.role_name AS 'ruleName',
+	t1.user_name AS 'userName'
+    FROM
+	user_company t1
+    LEFT JOIN sys_user_role t2 ON t1.user_id = t2.user_id
+    LEFT JOIN sys_role t3 ON t2.role_id = t3.id
+    WHERE
+	t3.role_code IN (
+		'plan',
+		'shot',
+		'clip',
+		'designTeamLeader'
+	)
+    </select>
+
 </mapper>

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

@@ -131,16 +131,17 @@
         CASE
         WHEN sum(t2.photo_show) != 0 THEN
         CONCAT(
-        ROUND(
+        CAST(ROUND(
         (
         sum(t2.photo_click) / sum(t2.photo_show)
         ) * 100,
         3
-        ),
+        ) AS CHAR)
+        ,
         '%'
         )
         ELSE
-        0
+        '0%'
         END
         ) clickRate,
         (
@@ -210,42 +211,43 @@
         CASE
         WHEN sum(t2.photo_click) != 0 THEN
         CONCAT(
-        ROUND(
+        CAST(ROUND(
         sum(t2.bclick) / sum(t2.photo_click),
         3
-        ) * 100,
+        ) * 100 AS CHAR),
         '%'
         )
         ELSE
-        CONCAT(0, '%')
+        '0%'
         END
         ) actionRatio,
         (
         CASE
         WHEN sum(t2.bclick) != 0 THEN
         CONCAT(
-        ROUND(
+        CAST( ROUND(
         sum(t2.download_completed) / sum(t2.bclick),
         3
-        ) * 100,
+        ) * 100 AS CHAR)
+        ,
         '%'
         )
         ELSE
-        CONCAT(0, '%')
+        '0%'
         END
         ) eventJinJianAppRatio,
         (
         CASE
         WHEN sum(t2.download_completed) != 0 THEN
         CONCAT(
-        ROUND(
+        CAST(ROUND(
         sum(t2.activation) / sum(t2.download_completed),
         3
-        ) * 100,
+        ) * 100 AS CHAR) ,
         '%'
         )
         ELSE
-        CONCAT(0, '%')
+        '0%'
         END
         ) activationRatio
         FROM
@@ -289,16 +291,17 @@
         CASE
         WHEN sum(t2.photo_show) != 0 THEN
         CONCAT(
-        ROUND(
+        CAST( ROUND(
         (
         sum(t2.photo_click) / sum(t2.photo_show)
         ) * 100,
         3
-        ),
+        ) AS CHAR)
+        ,
         '%'
         )
         ELSE
-        0
+        '0%'
         END
         ) clickRate,
         (
@@ -368,42 +371,45 @@
         CASE
         WHEN sum(t2.photo_click) != 0 THEN
         CONCAT(
-        ROUND(
+        CAST( ROUND(
         sum(t2.bclick) / sum(t2.photo_click),
         3
-        ) * 100,
+        ) * 100 AS CHAR)
+        ,
         '%'
         )
         ELSE
-        CONCAT(0, '%')
+        '0%'
         END
         ) actionRatio,
         (
         CASE
         WHEN sum(t2.bclick) != 0 THEN
         CONCAT(
-        ROUND(
+        CAST( ROUND(
         sum(t2.download_completed) / sum(t2.bclick),
         3
-        ) * 100,
+        ) * 100 AS CHAR)
+        ,
         '%'
         )
         ELSE
-        CONCAT(0, '%')
+        '0%'
         END
         ) eventJinJianAppRatio,
         (
         CASE
         WHEN sum(t2.download_completed) != 0 THEN
         CONCAT(
-        ROUND(
+        CAST( ROUND(
         sum(t2.activation) / sum(t2.download_completed),
         3
-        ) * 100,
+        ) * 100 AS CHAR)
+        ,
         '%'
         )
         ELSE
-        CONCAT(0, '%')
+        '0%'
         END
         ) activationRatio
         FROM
@@ -444,7 +450,8 @@
             and t1.stat_date = #{statDate}
         </if>
         ) t2
-        WHERE t2.campaignName in(68,441,469,470,481,581,582,583,584,552,553,554,680,681,845,846,847,848,849,850,1070,1071,1072,1066,1069,1063,1064)
+        WHERE t2.campaignName
+        in(68,441,469,470,481,581,582,583,584,552,553,554,680,681,845,846,847,848,849,850,1070,1071,1072,1066,1069,1063,1064)
 
     </select>
 
@@ -475,12 +482,13 @@
         CASE
         WHEN sum(t2.photo_show) != 0 THEN
         CONCAT(
-        ROUND(
+        CAST( ROUND(
         (
         sum(t2.photo_click) / sum(t2.photo_show)
         ) * 100,
         3
-        ),
+        ) AS CHAR)
+        ,
         '%'
         )
         ELSE
@@ -554,42 +562,44 @@
         CASE
         WHEN sum(t2.photo_click) != 0 THEN
         CONCAT(
-        ROUND(
+        CAST( ROUND(
         sum(t2.bclick) / sum(t2.photo_click),
         3
-        ) * 100,
+        ) * 100 AS CHAR),
         '%'
         )
         ELSE
-        CONCAT(0, '%')
+        '0%'
         END
         ) actionRatio,
         (
         CASE
         WHEN sum(t2.bclick) != 0 THEN
         CONCAT(
-        ROUND(
+        CAST(ROUND(
         sum(t2.download_completed) / sum(t2.bclick),
         3
-        ) * 100,
+        ) * 100 AS CHAR)
+        ,
         '%'
         )
         ELSE
-        CONCAT(0, '%')
+        '0%'
         END
         ) eventJinJianAppRatio,
         (
         CASE
         WHEN sum(t2.download_completed) != 0 THEN
         CONCAT(
-        ROUND(
+        CAST( ROUND(
         sum(t2.activation) / sum(t2.download_completed),
         3
-        ) * 100,
+        ) * 100 AS CHAR)
+        ,
         '%'
         )
         ELSE
-        CONCAT(0, '%')
+        '0%'
         END
         ) activationRatio
         FROM

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

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageInfo;
 
 import java.util.List;
+import java.util.Map;
 
 public interface IKsVideoReportService {
 
@@ -13,4 +14,10 @@ public interface IKsVideoReportService {
     List<JSONObject> getVideoDetailBy(JSONArray accountIds, String startDate, String endDate, String filed, String signature);
 
     List<JSONObject> exportExcelReportBy(JSONArray accountIds, String startDate, String endDate, String filed, String target, String order, String clip, String shot, String plan);
+
+    PageInfo<JSONObject> getKuaiShouVideoPageReportByMap(Map<String, Object> requestMap, int pageSize, int pageNo);
+
+    List<JSONObject> getDesignList();
+
+    List<JSONObject> getKuaiShouVideoReportByMap(Map<String, Object> requestMap);
 }

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

@@ -1,7 +1,7 @@
 package cn.com.ctop.kuaishou.modules.report.service.impl;
 
-import cn.com.ctop.kuaishou.modules.report.service.IKsVideoReportService;
 import cn.com.ctop.kuaishou.modules.report.mapper.KsVideoReportMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKsVideoReportService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
+import java.util.Map;
 
 @Service
 public class KsVideoReportServiceImpl implements IKsVideoReportService {
@@ -19,19 +20,38 @@ public class KsVideoReportServiceImpl implements IKsVideoReportService {
 
     @Override
     public PageInfo<JSONObject> getVideoReportBy(JSONArray accountIds, String startDate, String endDate, String filed, String target, String order, String clip, String shot, String plan, int pageSize, int pageNo) {
-        PageHelper.startPage(pageNo,pageSize);
-        List<JSONObject> jsonObjectList=ksVideoReportMapper.queryVideoReportBy(accountIds,startDate,endDate,filed,target,order,clip,shot,plan);
+        PageHelper.startPage(pageNo, pageSize);
+        List<JSONObject> jsonObjectList = ksVideoReportMapper.queryVideoReportBy(accountIds, startDate, endDate, filed, target, order, clip, shot, plan);
         return new PageInfo<>(jsonObjectList);
     }
 
     @Override
     public List<JSONObject> getVideoDetailBy(JSONArray accountIds, String startDate, String endDate, String filed, String signature) {
-        return ksVideoReportMapper.queryVideoDetailBy(accountIds,startDate,endDate,filed,signature);
+        return ksVideoReportMapper.queryVideoDetailBy(accountIds, startDate, endDate, filed, signature);
     }
 
     @Override
     public List<JSONObject> exportExcelReportBy(JSONArray accountIds, String startDate, String endDate, String filed, String target, String order, String clip, String shot, String plan) {
-        return ksVideoReportMapper.queryVideoReportBy(accountIds,startDate,endDate,filed,target,order,clip,shot,plan);
+        return ksVideoReportMapper.queryVideoReportBy(accountIds, startDate, endDate, filed, target, order, clip, shot, plan);
+    }
+
+    @Override
+    public PageInfo<JSONObject> getKuaiShouVideoPageReportByMap(Map<String, Object> requestMap, int pageSize, int pageNo) {
+        PageHelper.startPage(pageNo, pageSize);
+        List<JSONObject> jsonObjectList = ksVideoReportMapper.getKuaiShouVideoReportByMap(requestMap);
+        return new PageInfo<>(jsonObjectList);
+
+    }
+
+    @Override
+    public List<JSONObject> getDesignList() {
+        return ksVideoReportMapper.getDesignList();
+    }
+
+    @Override
+    public List<JSONObject> getKuaiShouVideoReportByMap(Map<String, Object> requestMap) {
+        List<JSONObject> jsonObjectList = ksVideoReportMapper.getKuaiShouVideoReportByMap(requestMap);
+        return jsonObjectList;
     }
 
 }

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

@@ -194,7 +194,7 @@ public class KuaiShouAccountReportServiceImpl implements IKuaiShouAccountReportS
             if ("accountId".equals(k) || "authName".equals(k) || v.toString().contains("%") || before.getString(k).contains("%")) {
                 jsonObject.put(k, "-");
             } else {
-                jsonObject.put(k, (LinkUtils.countLink(after.getBigDecimal(k) == null ? zero : after.getBigDecimal(k), before.getBigDecimal(k) == null ? zero : before.getBigDecimal(k))).multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP)+"%");
+                jsonObject.put(k, (LinkUtils.countLink(after.getBigDecimal(k) == null ? zero : after.getBigDecimal(k), before.getBigDecimal(k) == null ? zero : before.getBigDecimal(k))).multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP) + "%");
             }
         });
         return jsonObject;

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

@@ -20,11 +20,11 @@
     "comment": "行为数"
   },
   "clickRate": {
-    "filed": "CASE WHEN sum(t1.photo_click) / sum(t1.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.photo_click) / sum(t1.photo_show)) * 100,2),'%') END AS clickRate ",
+    "filed": "CASE WHEN sum(t1.photo_show) != 0    THEN CONCAT( CAST(ROUND((sum(t1.photo_click) / sum(t1.photo_show)) * 100,2) AS CHAR) ,'%') else '0%' END AS clickRate ",
     "comment": "封面点击率"
   },
   "bClickRate": {
-    "filed": "CASE WHEN sum(t1.bclick) / sum(t1.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.bclick) / sum(t1.aclick)) * 100,2),'%') END AS bClickRate ",
+    "filed": "CASE WHEN  sum(t1.aclick) != 0 THEN CONCAT( CAST(ROUND((sum(t1.bclick) / sum(t1.aclick)) * 100,2) AS CHAR) ,'%') ELSE '0%' END AS bClickRate ",
     "comment": "行为率"
   },
   "cpm": {
@@ -48,7 +48,7 @@
     "comment": "安卓开始下载单价"
   },
   "downloadStartRate": {
-    "filed": "CASE WHEN sum(t1.download_started) / sum(t1.bclick) IS NULL THEN 0 ELSE concat(round(sum(t1.download_started) / sum(t1.bclick)*100,2),'%') end AS downloadStartRate ",
+    "filed": "CASE WHEN  sum(t1.bclick) != 0 THEN concat(CAST(round(sum(t1.download_started) / sum(t1.bclick)*100,2) AS CHAR) ,'%') else '0%' end AS downloadStartRate",
     "comment": "安卓开始下载率"
   },
   "downloadFinish": {
@@ -60,7 +60,7 @@
     "comment": "安卓下载完成单价"
   },
   "downloadFinishRate": {
-    "filed": "CASE WHEN sum(t1.download_completed) / sum(t1.download_started) IS NULL THEN 0 ELSE  concat(round(sum(t1.download_completed) / sum(t1.download_started)*100,2),'%') end AS downloadFinishRate ",
+    "filed": "CASE WHEN  sum(t1.download_started) != 0 then  concat(CAST(round(sum(t1.download_completed) / sum(t1.download_started)*100,2) AS CHAR) ,'%') else '0%' end AS downloadFinishRate  ",
     "comment": "安卓下载完成率"
   },
   "active": {
@@ -71,12 +71,8 @@
     "filed": "CASE WHEN sum(t1.charge) / sum(t1.activation) IS NULL THEN 0 ELSE sum(t1.charge) / sum(t1.activation) end AS activeCost ",
     "comment": "激活单价"
   },
-  "activeRate": {
-    "filed": "CASE WHEN sum(t1.activation) / sum(t1.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t1.activation) / sum(t1.download_completed)*100,2),'%') end as activeRate ",
-    "comment": "下载完成激活率"
-  },
   "firstDayPay": {
-    "filed": "IFNULL(sum(t1.event_pay_first_day),0) as firstDayPay  ",
+    "filed": "CASE WHEN sum(t1.event_pay_first_day) != 0 THEN sum(t1.event_pay_first_day) ELSE 0  end as firstDayPay ",
     "comment": "首日付费次数"
   },
   "firstDayPayAmount": {
@@ -116,7 +112,7 @@
     "comment": "注册成本"
   },
   "activeRegisterRate": {
-    "filed": " CASE WHEN sum(t1.event_register) / sum(t1.activation) IS NULL THEN 0 ELSE concat(round(sum(t1.event_register) / sum(t1.activation)*100,2),'%') end as activeRegisterRate ",
+    "filed": "CASE WHEN  sum(t1.activation) !=0  THEN concat(CAST(round(sum(t1.event_register) / sum(t1.activation)*100,2) AS CHAR) ,'%') else '0%' end as activeRegisterRate ",
     "comment": "注册率"
   },
   "eventJinJianApp": {
@@ -136,7 +132,7 @@
     "comment": "授信成本"
   },
   "eventCreditGrantAppRate": {
-    "filed": "CASE WHEN sum(t1.event_credit_grant_app) / sum(t1.event_jin_jian_app) IS NULL THEN 0 ELSE concat(round(sum(t1.event_credit_grant_app) / sum(t1.event_jin_jian_app)*100,2),'%') end as eventCreditGrantAppRate ",
+    "filed": "CASE WHEN  sum(t1.event_jin_jian_app) !=0 THEN concat(CAST(round(sum(t1.event_credit_grant_app) / sum(t1.event_jin_jian_app)*100,2) AS CHAR) ,'%') ELSE '0' end as eventCreditGrantAppRate",
     "comment": "授信率"
   },
   "formCount": {
@@ -144,7 +140,7 @@
     "comment": "表单提交数"
   },
   "formCountRate": {
-    "filed": "CASE WHEN sum(t1.form_count) / sum(t1.activation) IS NULL THEN 0 ELSE concat(round(sum(t1.form_count) / sum(t1.activation)*100,2),'%') end as formCountRate ",
+    "filed": "CASE WHEN sum(t1.activation) != 0  THEN  concat(CAST(round(sum(t1.form_count) / sum(t1.activation)*100,2) AS CHAR) ,'%') else '0%' end as formCountRate ",
     "comment": "表单提交率"
   },
   "formCountCost": {
@@ -160,7 +156,7 @@
     "comment": "次留成本"
   },
   "nextDayOpenRate": {
-    "filed": "CASE WHEN sum(t1.event_next_day_stay) / sum(t1.activation) IS NULL THEN 0 ELSE concat(round(sum(t1.event_next_day_stay) / sum(t1.activation)*100,2),'%') end as nextDayOpenRate ",
+    "filed": "CASE WHEN  sum(t1.activation) != 0 THEN  concat(CAST(round(sum(t1.event_next_day_stay) / sum(t1.activation)*100,2) AS CHAR) ,'%') ELSE '0%' end as nextDayOpenRate",
     "comment": "次留率"
   },
   "eventJinJianLandingPage": {
@@ -180,7 +176,7 @@
     "comment": "落地页授信成本"
   },
   "eventCreditGrantLandingPageRate": {
-    "filed": "CASE WHEN sum(t1.event_credit_grant_landing_page) / sum(t1.event_jin_jian_landing_page) IS NULL THEN 0 ELSE concat(round(sum(t1.event_credit_grant_landing_page) / sum(t1.event_jin_jian_landing_page)*100,2),'%') end as eventCreditGrantLandingPageRate ",
+    "filed": "CASE WHEN  sum(t1.event_jin_jian_landing_page)  != 0 THEN  concat( CAST(round(sum(t1.event_credit_grant_landing_page) / sum(t1.event_jin_jian_landing_page)*100,2) AS CHAR),'%') ELSE '0%' end as eventCreditGrantLandingPageRate ",
     "comment": "落地页授信率"
   },
   "submit": {
@@ -192,11 +188,15 @@
     "comment": "按钮点击成本"
   },
   "submitRate": {
-    "filed": "CASE WHEN sum(t1.submit) / sum(t1.bclick) IS NULL THEN 0 ELSE concat(round(sum(t1.submit) / sum(t1.bclick)*100,2),'%') end as submitRate ",
+    "filed": "CASE WHEN  sum(t1.bclick) != 0 THEN concat(CAST(round(sum(t1.submit) / sum(t1.bclick)*100,2) AS CHAR) ,'%') else '0%' end as submitRate ",
     "comment": "按钮点击率"
   },
   "play3sRate": {
-    "filed": "CASE WHEN sum(CEIL(t1.play_3s_ratio*t1.photo_show)) / sum(t1.photo_show) IS NULL THEN 0 ELSE round(sum(CEIL(t1.play_3s_ratio*t1.photo_show)) / sum(t1.photo_show)*100,2)end as play3sRate ",
+    "filed": "CASE WHEN sum(CEIL(t1.play_3s_ratio * t1.photo_show)) / sum(t1.photo_show) IS NULL THEN 0 ELSE round(sum(CEIL(t1.play_3s_ratio * t1.photo_show)) / sum(t1.photo_show)*100,2)end as play3sRate ",
     "comment": "3s播放率"
+  },
+  "activeRate": {
+    "filed": "CASE WHEN  sum(t1.download_completed) != 0 THEN concat(CAST(round(sum(t1.activation) / sum(t1.download_completed)*100,2) AS CHAR) ,'%') else '0%' end as activeRate ",
+    "comment": "下载完成激活率"
   }
 }

+ 221 - 0
module-kuaishou/src/main/resources/json_template/kuaishou_video_report_filed_mapping.json

@@ -0,0 +1,221 @@
+{
+
+
+  "signature": {
+    "filed": "t1.signature as signature ",
+    "comment": "素材标识"
+  },
+  "projectName": {
+    "filed": "t1.project_name as projectName ",
+    "comment": "项目名称"
+  },
+
+  "cost": {
+    "filed": "IFNULL(sum(t1.charge),0) as cost ",
+    "comment": "消耗"
+  },
+  "photoShow": {
+    "filed": "IFNULL(sum(t1.photo_show),0) as photoShow ",
+    "comment": "封面曝光数"
+  },
+  "photoClick": {
+    "filed": "IFNULL(sum(t1.photo_click),0) as photoClick ",
+    "comment": "封面点击数"
+  },
+  "aClick": {
+    "filed": "IFNULL(sum(t1.aclick),0) as aClick ",
+    "comment": "素材曝光数"
+  },
+  "bClick": {
+    "filed": "IFNULL(sum(t1.bclick),0) as bClick ",
+    "comment": "行为数"
+  },
+  "clickRate": {
+    "filed": "CASE WHEN sum(t1.photo_show) != 0    THEN CONCAT( CAST(ROUND((sum(t1.photo_click) / sum(t1.photo_show)) * 100,2) AS CHAR) ,'%') else '0%' END AS clickRate ",
+    "comment": "封面点击率"
+  },
+  "bClickRate": {
+    "filed": "CASE WHEN  sum(t1.aclick) != 0 THEN CONCAT( CAST(ROUND((sum(t1.bclick) / sum(t1.aclick)) * 100,2) AS CHAR) ,'%') ELSE '0%' END AS bClickRate ",
+    "comment": "行为率"
+  },
+  "cpm": {
+    "filed": "CASE WHEN sum(t1.charge) / sum(t1.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t1.charge) / sum(t1.photo_show)) * 1000, 2 ) END AS cpm ",
+    "comment": "平均千次封面曝光花费"
+  },
+  "cpc": {
+    "filed": "CASE WHEN sum(t1.charge) / sum(t1.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t1.charge) / sum(t1.photo_click)), 2) END AS cpc ",
+    "comment": "平均封面点击单价"
+  },
+  "cpb": {
+    "filed": "CASE WHEN sum(t1.charge) / sum(t1.bclick) IS NULL THEN 0 ELSE ROUND((sum(t1.charge) / sum(t1.bclick)), 2) END AS cpb ",
+    "comment": "平均行为单价"
+  },
+  "downloadStart": {
+    "filed": "IFNULL(sum(download_started),0) as downloadStart ",
+    "comment": "安卓开始下载数"
+  },
+  "downloadStartCost": {
+    "filed": "CASE WHEN sum(t1.charge) / (t1.download_started) IS NULL THEN 0 ELSE sum(t1.charge) / sum(t1.download_started) end AS downloadStartCost ",
+    "comment": "安卓开始下载单价"
+  },
+  "downloadStartRate": {
+    "filed": "CASE WHEN  sum(t1.bclick) != 0 THEN concat(CAST(round(sum(t1.download_started) / sum(t1.bclick)*100,2) AS CHAR) ,'%') else '0%' end AS downloadStartRate",
+    "comment": "安卓开始下载率"
+  },
+  "downloadFinish": {
+    "filed": "IFNULL(sum(download_completed),0) as downloadFinish ",
+    "comment": "安卓下载完成数"
+  },
+  "downloadFinishCost": {
+    "filed": "CASE WHEN sum(t1.charge) / sum(t1.download_completed) IS NULL THEN 0 ELSE  sum(t1.charge) / sum(t1.download_completed) end AS downloadFinishCost ",
+    "comment": "安卓下载完成单价"
+  },
+  "downloadFinishRate": {
+    "filed": "CASE WHEN  sum(t1.download_started) != 0 then  concat(CAST(round(sum(t1.download_completed) / sum(t1.download_started)*100,2) AS CHAR) ,'%') else '0%' end AS downloadFinishRate  ",
+    "comment": "安卓下载完成率"
+  },
+  "active": {
+    "filed": "IFNULL(sum(activation),0) as active ",
+    "comment": "激活数"
+  },
+  "activeCost": {
+    "filed": "CASE WHEN sum(t1.charge) / sum(t1.activation) IS NULL THEN 0 ELSE sum(t1.charge) / sum(t1.activation) end AS activeCost ",
+    "comment": "激活单价"
+  },
+  "firstDayPay": {
+    "filed": "CASE WHEN sum(t1.event_pay_first_day) != 0 THEN sum(t1.event_pay_first_day) ELSE 0  end as firstDayPay ",
+    "comment": "首日付费次数"
+  },
+  "firstDayPayAmount": {
+    "filed": "IFNULL(sum(t1.event_pay_purchase_amount_first_day),0) as firstDayPayAmount  ",
+    "comment": "首日付费金额"
+  },
+  "firstDayPayCost": {
+    "filed": "CASE WHEN sum(t1.charge) / sum(t1.event_pay_first_day) IS NULL THEN 0 ELSE sum(t1.charge) / sum(t1.event_pay_first_day) end AS firstDayPayCost ",
+    "comment": "首日付费成本"
+  },
+  "firstDayPayROI": {
+    "filed": "CASE WHEN sum(t1.event_pay_purchase_amount_first_day) / sum(t1.charge) IS NULL THEN 0 ELSE sum(t1.event_pay_purchase_amount_first_day) / sum(t1.charge) end AS firstDayPayROI ",
+    "comment": "首日ROI"
+  },
+  "eventPay": {
+    "filed": "IFNULL(sum(t1.event_pay),0) as eventPay  ",
+    "comment": "付费次数"
+  },
+  "eventPayPurchaseAmount": {
+    "filed": "IFNULL(sum(t1.event_pay_purchase_amount),0) as eventPayPurchaseAmount  ",
+    "comment": "付费金额"
+  },
+  "eventPayCost": {
+    "filed": "CASE WHEN sum(t1.charge) / sum(t1.event_pay) IS NULL THEN 0 ELSE sum(t1.charge) / sum(t1.event_pay) end AS eventPayCost ",
+    "comment": "付费次数成本"
+  },
+  "ROI": {
+    "filed": "CASE WHEN sum(t1.event_pay_purchase_amount) / sum(t1.charge) IS NULL THEN 0 ELSE sum(t1.event_pay_purchase_amount) / sum(t1.charge) end AS ROI ",
+    "comment": "ROI"
+  },
+  "register": {
+    "filed": "IFNULL(sum(t1.event_register),0) as register ",
+    "comment": "注册数"
+  },
+  "activeRegisterCost": {
+    "filed": "CASE WHEN sum(t1.charge) / sum(t1.event_register) IS NULL THEN 0 ELSE round(sum(t1.charge)/sum(t1.event_register),3) end as activeRegisterCost ",
+    "comment": "注册成本"
+  },
+  "activeRegisterRate": {
+    "filed": "CASE WHEN  sum(t1.activation) !=0  THEN concat(CAST(round(sum(t1.event_register) / sum(t1.activation)*100,2) AS CHAR) ,'%') else '0%' end as activeRegisterRate ",
+    "comment": "注册率"
+  },
+  "eventJinJianApp": {
+    "filed": "IFNULL(sum(event_jin_jian_app),0) as eventJinJianApp ",
+    "comment": "完件数"
+  },
+  "eventJinJianAppCost": {
+    "filed": "CASE WHEN sum(t1.charge) / sum(t1.event_jin_jian_app) IS NULL THEN 0 ELSE round(sum(t1.charge)/sum(t1.event_jin_jian_app),3) end as eventJinJianAppCost ",
+    "comment": "完件成本"
+  },
+  "eventCreditGrantApp": {
+    "filed": "IFNULL(sum(event_credit_grant_app),0) as eventCreditGrantApp ",
+    "comment": "授信数"
+  },
+  "eventCreditGrantAppCost": {
+    "filed": "CASE WHEN sum(t1.charge) / sum(t1.event_credit_grant_app) IS NULL THEN 0 ELSE round(sum(t1.charge)/sum(t1.event_credit_grant_app),3) end as eventCreditGrantAppCost ",
+    "comment": "授信成本"
+  },
+  "eventCreditGrantAppRate": {
+    "filed": "CASE WHEN  sum(t1.event_jin_jian_app) !=0 THEN concat(CAST(round(sum(t1.event_credit_grant_app) / sum(t1.event_jin_jian_app)*100,2) AS CHAR) ,'%') ELSE '0' end as eventCreditGrantAppRate",
+    "comment": "授信率"
+  },
+  "formCount": {
+    "filed": "IFNULL(sum(t1.form_count),0) as formCount ",
+    "comment": "表单提交数"
+  },
+  "formCountRate": {
+    "filed": "CASE WHEN sum(t1.activation) != 0  THEN  concat(CAST(round(sum(t1.form_count) / sum(t1.activation)*100,2) AS CHAR) ,'%') else '0%' end as formCountRate ",
+    "comment": "表单提交率"
+  },
+  "formCountCost": {
+    "filed": "CASE WHEN sum(t1.charge) / sum(t1.form_count) IS NULL THEN 0 ELSE round(sum(t1.charge)/sum(t1.form_count),3) end as formCountCost ",
+    "comment": "表单提交成本"
+  },
+  "nextDayOpen": {
+    "filed": "IFNULL(sum(t1.event_next_day_stay),0) as nextDayOpen ",
+    "comment": "次留数"
+  },
+  "nextDayOpenCost": {
+    "filed": "CASE WHEN sum(t1.charge) / sum(t1.event_next_day_stay) IS NULL THEN 0 ELSE round(sum(t1.charge)/sum(t1.event_next_day_stay),3) end as nextDayOpenCost ",
+    "comment": "次留成本"
+  },
+  "nextDayOpenRate": {
+    "filed": "CASE WHEN  sum(t1.activation) != 0 THEN  concat(CAST(round(sum(t1.event_next_day_stay) / sum(t1.activation)*100,2) AS CHAR) ,'%') ELSE '0%' end as nextDayOpenRate",
+    "comment": "次留率"
+  },
+  "eventJinJianLandingPage": {
+    "filed": "IFNULL(sum(t1.event_jin_jian_landing_page),0) as eventJinJianLandingPage ",
+    "comment": "落地页完件数"
+  },
+  "eventJinJianLandingPageCost": {
+    "filed": "CASE WHEN sum(t1.charge) / sum(t1.event_jin_jian_landing_page) IS NULL THEN 0 ELSE round(sum(t1.charge)/sum(t1.event_jin_jian_landing_page),3) end as eventJinJianLandingPageCost ",
+    "comment": "落地页完件成本"
+  },
+  "eventCreditGrantLandingPage": {
+    "filed": "IFNULL(sum(t1.event_credit_grant_landing_page),0) as eventCreditGrantLandingPage ",
+    "comment": "落地页授信数"
+  },
+  "eventCreditGrantLandingPageCost": {
+    "filed": "CASE WHEN sum(t1.charge) / sum(t1.event_credit_grant_landing_page) IS NULL THEN 0 ELSE round(sum(t1.charge)/sum(t1.event_credit_grant_landing_page),3) end as eventCreditGrantLandingPageCost ",
+    "comment": "落地页授信成本"
+  },
+  "eventCreditGrantLandingPageRate": {
+    "filed": "CASE WHEN  sum(t1.event_jin_jian_landing_page)  != 0 THEN  concat( CAST(round(sum(t1.event_credit_grant_landing_page) / sum(t1.event_jin_jian_landing_page)*100,2) AS CHAR),'%') ELSE '0%' end as eventCreditGrantLandingPageRate ",
+    "comment": "落地页授信率"
+  },
+  "submit": {
+    "filed": "IFNULL(sum(t1.submit),0) as submit ",
+    "comment": "按钮点击数"
+  },
+  "submitCost": {
+    "filed": "CASE WHEN sum(t1.charge) / sum(t1.submit) IS NULL THEN 0 ELSE round(sum(t1.charge)/sum(t1.submit),3) end as submitCost ",
+    "comment": "按钮点击成本"
+  },
+  "submitRate": {
+    "filed": "CASE WHEN  sum(t1.bclick) != 0 THEN concat(CAST(round(sum(t1.submit) / sum(t1.bclick)*100,2) AS CHAR) ,'%') else '0%' end as submitRate ",
+    "comment": "按钮点击率"
+  },
+  "play3sRate": {
+    "filed": "CASE WHEN sum(CEIL(t1.play_3s_ratio * t1.photo_show)) / sum(t1.photo_show) IS NULL THEN 0 ELSE round(sum(CEIL(t1.play_3s_ratio * t1.photo_show)) / sum(t1.photo_show)*100,2)end as play3sRate ",
+    "comment": "3s播放率"
+  },
+  "activeRate": {
+    "filed": "CASE WHEN  sum(t1.download_completed) != 0 THEN concat(CAST(round(sum(t1.activation) / sum(t1.download_completed)*100,2) AS CHAR) ,'%') else '0%' end as activeRate ",
+    "comment": "下载完成激活率"
+  },
+  "play3sCount": {
+    "filed": "sum(t1.play_3s_count) as play3sCount",
+    "comment": "3s播放数"
+  },
+  "play3sRate": {
+    "filed": "CASE WHEN sum(photo_show) != 0 THEN CONCAT(CAST(ROUND( sum(t1.play_3s_count) / sum(t1.photo_show),2 )  * 100 AS CHAR),'%') ELSE '-' END AS play3sRate",
+    "comment": "3s播放率"
+  }
+}

+ 1 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/mapper/xml/ETLReportBytedanceVideoMapper.xml

@@ -301,7 +301,7 @@
             (SELECT * from base_report_bytedance_video_daily where stat_datetime=#{statDate}) t1
                 LEFT JOIN (select material_id,signature,video_url from ctop_bytedance_video_info where material_id in (SELECT DISTINCT material_id from base_report_bytedance_video_daily where stat_datetime=#{statDate})
             ) t2 ON t1.material_id = t2.material_id
-                LEFT JOIN ctop_material_ascription t3 on t2.signature=t3.code
+                LEFT JOIN ctop_material_ascription t3 on t2.signature=t3.material_id
                 LEFT JOIN ctop_material_info t4 on t4.code=t2.signature
                 LEFT JOIN (SELECT account_id, advertiser_id,project_id,auth_name from ctop_user_allocation where account_id in (SELECT DISTINCT account_id from base_report_bytedance_video_daily where stat_datetime=#{statDate})) t5 on t1.account_id=t5.account_id
         GROUP BY t1.id

+ 196 - 229
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceHomepageMapper.xml

@@ -4,262 +4,229 @@
 
 
     <select id="queryTodaySumReportBy" resultType="com.alibaba.fastjson.JSONObject">
-       SELECT
-	     ROUND(sum(cost),2) cost,
-	     sum(show_num) showNum,
-	     sum(click) click,
-	     max(stat_hour) maxHour
-       FROM
-	      ctop_bytedance_report_advertiser_hourly
-       WHERE
-	      stat_datetime = #{statDate}
-      </select>
+        SELECT ROUND(sum(cost), 2) cost,
+               sum(show_num)       showNum,
+               sum(click)          click,
+               max(stat_hour)      maxHour
+        FROM ctop_bytedance_report_advertiser_hourly
+        WHERE stat_datetime = #{statDate}
+    </select>
 
     <select id="queryTodaySumByHour" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-            ROUND(sum(cost),2) cost,
-            sum(show_num) showNum,
-            sum(click) click
-        FROM
-            ctop_bytedance_report_advertiser_hourly
-        WHERE
-            stat_hour &lt;= #{hour}
+        SELECT ROUND(sum(cost), 2) cost,
+               sum(show_num)       showNum,
+               sum(click)          click
+        FROM ctop_bytedance_report_advertiser_hourly
+        WHERE stat_hour &lt;= #{hour}
     </select>
 
     <select id="queryTodayDetailReportBy" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-            stat_datetime statDate,
-            stat_hour statHour,
-            ROUND(sum(cost), 2) cost,
-            sum(show_num) showNum,
-            sum(click) click,
-            CASE
-                WHEN (click / show_num) IS NULL THEN
-                    0
-                ELSE
-                    CONCAT(
-                            ROUND(
-                                    (click / show_num) * 100,
-                                    2
-                                ),
-                            '%'
-                        )
-                END AS 'clickRate',
-            CASE
-                WHEN (cost / show_num) IS NULL THEN
-                    0
-                ELSE
-                    ROUND(
-                            (cost / show_num) * 1000,
-                            2
-                        )
-                END AS 'cpm',
-            CASE
-                WHEN (click / cost) IS NULL THEN
-                    0
-                ELSE
-                    ROUND((cost / click), 2)
-                END AS 'cp'
-        FROM
-            ctop_bytedance_report_advertiser_hourly
-        WHERE
-            stat_datetime = #{statDate}
-        GROUP BY
-            stat_hour
-        ORDER BY
-            stat_hour ASC
+        SELECT stat_datetime       statDate,
+               stat_hour           statHour,
+               ROUND(sum(cost), 2) cost,
+               sum(show_num)       showNum,
+               sum(click)          click,
+               CASE
+                   WHEN (click / show_num) IS NULL THEN
+                       0
+                   ELSE
+                       CONCAT(
+                               cast(
+                                       ROUND(
+                                               (click / show_num) * 100,
+                                               2
+                                           ) as char),
+                               '%'
+                           )
+                   END AS          'clickRate',
+               CASE
+                   WHEN (cost / show_num) IS NULL THEN
+                       0
+                   ELSE
+                       ROUND(
+                               (cost / show_num) * 1000,
+                               2
+                           )
+                   END AS          'cpm',
+               CASE
+                   WHEN (click / cost) IS NULL THEN
+                       0
+                   ELSE
+                       ROUND((cost / click), 2)
+                   END AS          'cp'
+        FROM ctop_bytedance_report_advertiser_hourly
+        WHERE stat_datetime = #{statDate}
+        GROUP BY stat_hour
+        ORDER BY stat_hour ASC
 
     </select>
 
     <select id="querySumByStartEndDate" resultType="com.alibaba.fastjson.JSONObject">
-       SELECT
-         ROUND(sum(cost), 2) cost,
-         sum(show_num) showNum,
-         sum(click) click
-       FROM
-         ctop_bytedance_report_advertiser_daily
-       WHERE
-         stat_datetime &lt;= #{endDate} '00:00:00'
-       AND
-         stat_datetime &gt;= #{startDate}
+        SELECT ROUND(sum(cost), 2) cost,
+               sum(show_num)       showNum,
+               sum(click)          click
+        FROM ctop_bytedance_report_advertiser_daily
+        WHERE stat_datetime &lt;= #{endDate} '00:00:00'
+          AND stat_datetime &gt;= #{startDate}
     </select>
 
     <select id="queryDetailByStartEndDate" resultType="com.alibaba.fastjson.JSONObject">
-       SELECT
-           ROUND(sum(cost), 2) cost,
-           sum(show_num) showNum,
-           sum(click) click,
-           CASE
-               WHEN (sum(click) / sum(show_num)) IS NULL THEN
-                   0
-               ELSE
-                   CONCAT(
-                           ROUND(
-                                   (sum(click) / sum(show_num)) * 100,
-                                   2
-                               ),
-                           '%'
-                       )
-               END AS 'clickRate',
-           CASE
-               WHEN (sum(cost) / sum(show_num)) IS NULL THEN
-                   0
-               ELSE
-                   ROUND(
-                           (sum(cost) / sum(show_num)) * 1000,
-                           2
-                       )
-               END AS 'cpm',
-           CASE
-               WHEN (sum(click) / sum(cost)) IS NULL THEN
-                   0
-               ELSE
-                   ROUND((sum(cost) / sum(click)), 2)
-               END AS 'cp',
-         DATE_FORMAT(stat_datetime,'%Y-%m-%d') statDate
-       FROM
-         ctop_bytedance_report_advertiser_daily
-       WHERE
-            stat_datetime &lt;= #{endDate} '00:00:00'
-       AND  stat_datetime &gt;= #{startDate}
-       group by stat_datetime
-       order by stat_datetime asc
+        SELECT ROUND(sum(cost), 2)                    cost,
+               sum(show_num)                          showNum,
+               sum(click)                             click,
+               CASE
+                   WHEN (sum(click) / sum(show_num)) IS NULL THEN
+                       0
+                   ELSE
+                       CONCAT(
+                               cast(
+                                       ROUND(
+                                               (sum(click) / sum(show_num)) * 100,
+                                               2
+                                           ) as char),
+                               '%'
+                           )
+                   END AS                             'clickRate',
+               CASE
+                   WHEN (sum(cost) / sum(show_num)) IS NULL THEN
+                       0
+                   ELSE
+                       ROUND(
+                               (sum(cost) / sum(show_num)) * 1000,
+                               2
+                           )
+                   END AS                             'cpm',
+               CASE
+                   WHEN (sum(click) / sum(cost)) IS NULL THEN
+                       0
+                   ELSE
+                       ROUND((sum(cost) / sum(click)), 2)
+                   END AS                             'cp',
+               DATE_FORMAT(stat_datetime, '%Y-%m-%d') statDate
+        FROM ctop_bytedance_report_advertiser_daily
+        WHERE stat_datetime &lt;= #{endDate} '00:00:00'
+          AND stat_datetime &gt;= #{startDate}
+        group by stat_datetime
+        order by stat_datetime asc
     </select>
 
     <select id="queryDetailGroupMonthByDate" resultType="com.alibaba.fastjson.JSONObject">
-       SELECT
-           ROUND(sum(cost), 2) cost,
-           sum(show_num) showNum,
-           sum(click) click,
-           CASE
-               WHEN (sum(click) / sum(show_num)) IS NULL THEN
-                   0
-               ELSE
-                   CONCAT(
-                           ROUND(
-                                   (sum(click) / sum(show_num)) * 100,
-                                   2
-                               ),
-                           '%'
-                       )
-               END AS 'clickRate',
-           CASE
-               WHEN (sum(cost) / sum(show_num)) IS NULL THEN
-                   0
-               ELSE
-                   ROUND(
-                           (sum(cost) / sum(show_num)) * 1000,
-                           2
-                       )
-               END AS 'cpm',
-           CASE
-               WHEN (sum(click) / sum(cost)) IS NULL THEN
-                   0
-               ELSE
-                   ROUND((sum(cost) / sum(click)), 2)
-               END AS 'cp',
-         DATE_FORMAT(stat_datetime,'%Y-%m') statDate
-       FROM
-         ctop_bytedance_report_advertiser_daily
-       WHERE
-         stat_datetime &lt;= #{endDate} '00:00:00'
-       AND
-         stat_datetime &gt;= #{startDate}
-      group by DATE_FORMAT(stat_datetime,'%Y-%m')
-      order by stat_datetime asc
+        SELECT ROUND(sum(cost), 2)                 cost,
+               sum(show_num)                       showNum,
+               sum(click)                          click,
+               CASE
+                   WHEN (sum(click) / sum(show_num)) IS NULL THEN
+                       0
+                   ELSE
+                       CONCAT(
+                               cast(
+                                       ROUND(
+                                               (sum(click) / sum(show_num)) * 100,
+                                               2
+                                           ) as char),
+                               '%'
+                           )
+                   END AS                          'clickRate',
+               CASE
+                   WHEN (sum(cost) / sum(show_num)) IS NULL THEN
+                       0
+                   ELSE
+                       ROUND(
+                               (sum(cost) / sum(show_num)) * 1000,
+                               2
+                           )
+                   END AS                          'cpm',
+               CASE
+                   WHEN (sum(click) / sum(cost)) IS NULL THEN
+                       0
+                   ELSE
+                       ROUND((sum(cost) / sum(click)), 2)
+                   END AS                          'cp',
+               DATE_FORMAT(stat_datetime, '%Y-%m') statDate
+        FROM ctop_bytedance_report_advertiser_daily
+        WHERE stat_datetime &lt;= #{endDate} '00:00:00'
+          AND stat_datetime &gt;= #{startDate}
+        group by DATE_FORMAT(stat_datetime, '%Y-%m')
+        order by stat_datetime asc
     </select>
 
     <select id="queryDetailGroupDayByMonth" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-            ROUND(sum(cost), 2) cost,
-            sum(show_num) showNum,
-            sum(click) click,
-            CASE
-                WHEN (sum(click) / sum(show_num)) IS NULL THEN
-                    0
-                ELSE
-                    CONCAT(
-                            ROUND(
-                                    (sum(click) / sum(show_num)) * 100,
-                                    2
-                                ),
-                            '%'
-                        )
-                END AS 'clickRate',
-            CASE
-                WHEN (sum(cost) / sum(show_num)) IS NULL THEN
-                    0
-                ELSE
-                    ROUND(
-                            (sum(cost) / sum(show_num)) * 1000,
-                            2
-                        )
-                END AS 'cpm',
-            CASE
-                WHEN (sum(click) / sum(cost)) IS NULL THEN
-                    0
-                ELSE
-                    ROUND((sum(cost) / sum(click)), 2)
-                END AS 'cp',
-         DATE_FORMAT(stat_datetime,'%Y-%m-%d') statDate,
-         SUBSTR(DATE_FORMAT(stat_datetime,'%Y-%m-%d') FROM 9 FOR 2) day
-       FROM
-         ctop_bytedance_report_advertiser_daily
-       WHERE
-         stat_datetime like '${month}%'
-      group by DATE_FORMAT(stat_datetime,'%Y-%m-%d')
-      order by stat_datetime asc
+        SELECT ROUND(sum(cost), 2)                                         cost,
+               sum(show_num)                                               showNum,
+               sum(click)                                                  click,
+               CASE
+                   WHEN (sum(click) / sum(show_num)) IS NULL THEN
+                       0
+                   ELSE
+                       CONCAT(
+                               cast(
+                                       ROUND(
+                                               (sum(click) / sum(show_num)) * 100,
+                                               2
+                                           ) as char),
+                               '%'
+                           )
+                   END AS                                                  'clickRate',
+               CASE
+                   WHEN (sum(cost) / sum(show_num)) IS NULL THEN
+                       0
+                   ELSE
+                       ROUND(
+                               (sum(cost) / sum(show_num)) * 1000,
+                               2
+                           )
+                   END AS                                                  'cpm',
+               CASE
+                   WHEN (sum(click) / sum(cost)) IS NULL THEN
+                       0
+                   ELSE
+                       ROUND((sum(cost) / sum(click)), 2)
+                   END AS                                                  'cp',
+               DATE_FORMAT(stat_datetime, '%Y-%m-%d')                      statDate,
+               SUBSTR(DATE_FORMAT(stat_datetime, '%Y-%m-%d') FROM 9 FOR 2) day
+        FROM ctop_bytedance_report_advertiser_daily
+        WHERE stat_datetime like '${month}%'
+        group by DATE_FORMAT(stat_datetime, '%Y-%m-%d')
+        order by stat_datetime asc
     </select>
 
     <select id="queryTopCost" resultType="com.alibaba.fastjson.JSONObject">
-       SELECT
-         t2.auth_name as authName,
-         ROUND(sum(t1.cost), 2) cost
-       FROM
-         ctop_bytedance_report_advertiser_daily t1
-       LEFT JOIN
-         ctop_user_allocation t2 ON t1.advertiser_id=t2.account_id
-       WHERE
-         stat_datetime &lt;= #{endDate} '00:00:00'
-       AND
-         stat_datetime &gt;= #{startDate}
-       GROUP BY t1.advertiser_id
-       ORDER BY sum(t1.cost) DESC
-       limit #{rank}
+        SELECT t2.auth_name as        authName,
+               ROUND(sum(t1.cost), 2) cost
+        FROM ctop_bytedance_report_advertiser_daily t1
+                 LEFT JOIN
+             ctop_user_allocation t2 ON t1.advertiser_id = t2.account_id
+        WHERE stat_datetime &lt;= #{endDate} '00:00:00'
+          AND stat_datetime &gt;= #{startDate}
+        GROUP BY t1.advertiser_id
+        ORDER BY sum(t1.cost) DESC
+        limit #{rank}
     </select>
 
     <select id="queryTopClick" resultType="com.alibaba.fastjson.JSONObject">
-       SELECT
-         t2.auth_name as authName,
-         ROUND(sum(t1.click), 2) click
-       FROM
-         ctop_bytedance_report_advertiser_daily t1
-       LEFT JOIN
-         ctop_user_allocation t2 ON t1.advertiser_id=t2.account_id
-       WHERE
-         stat_datetime &lt;= #{endDate} '00:00:00'
-       AND
-         stat_datetime &gt;= #{startDate}
-       GROUP BY t1.advertiser_id
-       ORDER BY sum(t1.click) DESC
-       limit #{rank}
+        SELECT t2.auth_name as         authName,
+               ROUND(sum(t1.click), 2) click
+        FROM ctop_bytedance_report_advertiser_daily t1
+                 LEFT JOIN
+             ctop_user_allocation t2 ON t1.advertiser_id = t2.account_id
+        WHERE stat_datetime &lt;= #{endDate} '00:00:00'
+          AND stat_datetime &gt;= #{startDate}
+        GROUP BY t1.advertiser_id
+        ORDER BY sum(t1.click) DESC
+        limit #{rank}
     </select>
 
     <select id="queryTopShowNum" resultType="com.alibaba.fastjson.JSONObject">
-       SELECT
-         t2.auth_name as authName,
-         ROUND(sum(t1.show_num), 2) showNum
-       FROM
-         ctop_bytedance_report_advertiser_daily t1
-       LEFT JOIN
-         ctop_user_allocation t2 ON t1.advertiser_id=t2.account_id
-       WHERE
-         stat_datetime &lt;= #{endDate} '00:00:00'
-       AND
-         stat_datetime &gt;= #{startDate}
-       GROUP BY t1.advertiser_id
-       ORDER BY sum(t1.show_num) DESC
-       limit #{rank}
+        SELECT t2.auth_name as            authName,
+               ROUND(sum(t1.show_num), 2) showNum
+        FROM ctop_bytedance_report_advertiser_daily t1
+                 LEFT JOIN
+             ctop_user_allocation t2 ON t1.advertiser_id = t2.account_id
+        WHERE stat_datetime &lt;= #{endDate} '00:00:00'
+          AND stat_datetime &gt;= #{startDate}
+        GROUP BY t1.advertiser_id
+        ORDER BY sum(t1.show_num) DESC
+        limit #{rank}
     </select>
 
 </mapper>

+ 7 - 7
module-toutiao/src/main/resources/json_template/bytedance_filed_mapping.json

@@ -16,7 +16,7 @@
     "comment": "点击数"
   },
   "ctr": {
-    "filed": "CASE WHEN sum(t1.click) / sum(t1.show_num) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.click) / sum(t1.show_num)) * 100,2),'%') END AS ctr ",
+    "filed": "CASE WHEN sum(t1.show_num) != 0 THEN concat(CAST(round( sum(t1.click) /sum(t1.show_num)*100,2) AS CHAR),'%') ELSE '0%' end as ctr ",
     "comment": "点击率"
   },
   "cpc": {
@@ -32,7 +32,7 @@
     "comment": "转化成本"
   },
   "convertRate": {
-    "filed": "CASE WHEN sum(t1.convert_num) / sum(t1.cost) IS NULL THEN 0 ELSE concat(round(sum(t1.convert_num) / sum(t1.cost)*100,2),'%') end AS convertRate ",
+    "filed": "CASE WHEN sum(t1.cost) != 0 THEN concat(CAST(round(sum(t1.convert_num) / sum(t1.cost)*100,2) AS CHAR) ,'%') ELSE '0%' end AS convertRate",
     "comment": "转化率"
   },
   "downloadStart": {
@@ -44,7 +44,7 @@
     "comment": "安卓开始下载成本"
   },
   "downloadStartRate": {
-    "filed": "CASE WHEN sum(t1.download_start) / sum(t1.click) IS NULL THEN 0 ELSE concat(round(sum(t1.download_start) / sum(t1.click)*100,2),'%') end AS downloadStartRate ",
+    "filed": "CASE WHEN sum(t1.click) != 0 THEN concat(CAST(round(sum(t1.download_start) / sum(t1.click)*100,2) AS CHAR),'%') ELSE '0%' end AS downloadStartRate ",
     "comment": "安卓开始下载率"
   },
   "downloadFinish": {
@@ -56,7 +56,7 @@
     "comment": "安卓下载完成成本"
   },
   "downloadFinishRate": {
-    "filed": "CASE WHEN sum(t1.install_finish) / sum(t1.download_finish) IS NULL THEN 0 ELSE  concat(round(sum(t1.install_finish) / sum(t1.download_finish)*100,2),'%') end AS downloadFinishRate ",
+    "filed": "CASE WHEN sum(t1.download_finish) != 0 THEN  concat(CAST(round(sum(t1.install_finish) / sum(t1.download_finish)*100,2) AS CHAR) ,'%') ELSE '0%' end  AS downloadFinishRate ",
     "comment": "安卓下载完成率"
   },
   "active": {
@@ -68,7 +68,7 @@
     "comment": "激活成本"
   },
   "activeRate": {
-    "filed": "CASE WHEN sum(t1.active) / sum(t1.click) IS NULL THEN 0 ELSE concat(round(sum(t1.active) / sum(t1.click)*100,2),'%') end as activeRate ",
+    "filed": "CASE WHEN sum(t1.click) != 0 THEN concat(CAST(round(sum(t1.active) / sum(t1.click)*100,2) AS CHAR) ,'%') ELSE '0%' end as activeRate ",
     "comment": "激活率"
   },
   "register": {
@@ -80,7 +80,7 @@
     "comment": "注册成本"
   },
   "activeRegisterRate": {
-    "filed": " CASE WHEN sum(t1.register) / sum(t1.active) IS NULL THEN 0 ELSE concat(round(sum(t1.register) / sum(t1.active)*100,2),'%') end as activeRegisterRate ",
+    "filed": " CASE WHEN sum(t1.active) != 0 THEN concat(CAST(round(sum(t1.register) / sum(t1.active)*100,2) AS CHAR) ,'%') ELSE '0%' end as activeRegisterRate ",
     "comment": "注册率"
   },
   "nextDayOpen": {
@@ -92,7 +92,7 @@
     "comment": "次留成本"
   },
   "nextDayOpenRate": {
-    "filed": "CASE WHEN sum(t1.next_day_open) / sum(t1.active) IS NULL THEN 0 ELSE concat(round(sum(t1.next_day_open) / sum(t1.active)*100,2),'%') end as nextDayOpenRate ",
+    "filed": "CASE WHEN sum(t1.active) != 0 THEN concat(CAST(round(sum(t1.next_day_open) / sum(t1.active)*100,2) AS CHAR) ,'%') ELSE '0%' end as nextDayOpenRate ",
     "comment": "次留率"
   },
   "activePayAmount": {

+ 8 - 8
module-toutiao/src/main/resources/json_template/bytedance_video_report_mapping.json

@@ -16,7 +16,7 @@
     "comment": "点击数"
   },
   "ctr": {
-    "filed": "CASE WHEN sum(t1.click) / sum(t1.material_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.click) / sum(t1.material_show)) * 100,2),'%') END AS ctr ",
+    "filed": "CASE WHEN sum(t1.material_show) != 0 THEN CONCAT(CAST(ROUND((sum(t1.click) / sum(t1.material_show)) * 100,2) AS CHAR) ,'%') ELSE '0%' end  AS ctr",
     "comment": "点击率"
   },
   "cpc": {
@@ -32,7 +32,7 @@
     "comment": "转化成本"
   },
   "convertRate": {
-    "filed": "CASE WHEN sum(t1.convert_material) / sum(t1.material_show) IS NULL THEN 0 ELSE concat(round(sum(t1.convert_material) / sum(t1.material_show)*100,2),'%') end AS convertRate ",
+    "filed": "CASE WHEN sum(t1.material_show)!= 0 THEN concat(CAST(round(sum(t1.convert_material) / sum(t1.material_show)*100,2) AS CHAR) ,'%') ELSE '0%' end  AS convertRate ",
     "comment": "转化率"
   },
   "downloadStart": {
@@ -44,7 +44,7 @@
     "comment": "安卓开始下载成本"
   },
   "downloadStartRate": {
-    "filed": "CASE WHEN sum(t1.download_start) / sum(t1.click) IS NULL THEN 0 ELSE concat(round(sum(t1.download_start) / sum(t1.click)*100,2),'%') end AS downloadStartRate ",
+    "filed": "CASE WHEN sum(t1.click) != 0 THEN concat(CAST(round(sum(t1.download_start) / sum(t1.click)*100,2) AS CHAR) ,'%') ELSE '0%' end  AS downloadStartRate ",
     "comment": "安卓开始下载率"
   },
   "downloadFinish": {
@@ -56,7 +56,7 @@
     "comment": "安卓下载完成成本"
   },
   "downloadFinishRate": {
-    "filed": "CASE WHEN sum(t1.install_finish) / sum(t1.download_finish) IS NULL THEN 0 ELSE  concat(round(sum(t1.install_finish) / sum(t1.download_finish)*100,2),'%') end AS downloadFinishRate ",
+    "filed": "CASE WHEN sum(t1.download_finish) != 0 THEN concat(CAST(round(sum(t1.install_finish) / sum(t1.download_finish)*100,2) AS CHAR),'%') ELSE '0%' end  AS downloadFinishRate ",
     "comment": "安卓下载完成率"
   },
   "active": {
@@ -68,7 +68,7 @@
     "comment": "激活成本"
   },
   "activeRate": {
-    "filed": "CASE WHEN sum(t1.active) / sum(t1.click) IS NULL THEN 0 ELSE concat(round(sum(t1.active) / sum(t1.click)*100,2),'%') end as activeRate ",
+    "filed": "CASE WHEN sum(t1.click)!= 0 THEN concat( CAST(round(sum(t1.active) / sum(t1.click)*100,2) AS CHAR),'%') ELSE '0%' end  as activeRate",
     "comment": "激活率"
   },
   "register": {
@@ -80,7 +80,7 @@
     "comment": "注册成本"
   },
   "activeRegisterRate": {
-    "filed": " CASE WHEN sum(t1.register) / sum(t1.active) IS NULL THEN 0 ELSE concat(round(sum(t1.register) / sum(t1.active)*100,2),'%') end as activeRegisterRate ",
+    "filed": " CASE WHEN sum(t1.active) != 0 THEN concat(CAST(round(sum(t1.register) / sum(t1.active)*100,2) AS CHAR) ,'%') ELSE '0%' end  as activeRegisterRate ",
     "comment": "注册率"
   },
   "gameAddiction": {
@@ -92,7 +92,7 @@
     "comment": "关键行为成本"
   },
   "gameAddictionRate": {
-    "filed": " CASE WHEN sum(t1.game_addiction) / sum(t1.active) IS NULL THEN 0 ELSE concat(round(sum(t1.game_addiction) / sum(t1.active)*100,2),'%') end as gameAddictionRate ",
+    "filed": "CASE WHEN sum(t1.active)!= 0 THEN concat(CAST(round(sum(t1.game_addiction) / sum(t1.active)*100,2) AS CHAR),'%') ELSE '0%' end  as gameAddictionRate",
     "comment": "关键行为率"
   },
   "nextDayOpen": {
@@ -104,7 +104,7 @@
     "comment": "次留成本"
   },
   "nextDayOpenRate": {
-    "filed": "CASE WHEN sum(t1.next_day_open) / sum(t1.active) IS NULL THEN 0 ELSE concat(round(sum(t1.next_day_open) / sum(t1.active)*100,2),'%') end as nextDayOpenRate ",
+    "filed": "CASE WHEN  sum(t1.active)!= 0 THEN concat(CAST(round(sum(t1.next_day_open) / sum(t1.active)*100,2) AS CHAR) ,'%') ELSE '0%' end  as nextDayOpenRate ",
     "comment": "次留率"
   },
   "activePayAmount": {