浏览代码

Merge branch 'V1.1.5' into material_report

yumeng 4 年之前
父节点
当前提交
0e5b3c6ffd
共有 25 个文件被更改,包括 809 次插入710 次删除
  1. 244 238
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysDepartController.java
  2. 33 7
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java
  3. 11 3
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  4. 9 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/SysDepart.java
  5. 18 1
      module-common/src/main/java/cn/com/ctop/common/module/entity/SysUser.java
  6. 3 1
      module-common/src/main/java/cn/com/ctop/common/module/mapper/SysUserMapper.java
  7. 42 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/SysUserMapper.xml
  8. 23 0
      module-common/src/main/java/cn/com/ctop/common/module/model/SysDepartTreeModel.java
  9. 3 1
      module-common/src/main/java/cn/com/ctop/common/module/service/ISysUserService.java
  10. 1 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/SysBaseApiImpl.java
  11. 10 1
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/SysDepartServiceImpl.java
  12. 7 2
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/SysUserServiceImpl.java
  13. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaiShouAppInfoServiceImpl.java
  14. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/mapper/EtlKuaishouVideoInfoMapper.java
  15. 38 94
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/mapper/xml/EtlKuaishouVideoInfoMapper.xml
  16. 82 61
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/service/impl/EtlKuaishouVideoInfoServiceImpl.java
  17. 46 36
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaiShouYiCheReportMapper.xml
  18. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaiShouAccountReportServiceImpl.java
  19. 2 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouVideoEtlInfoServiceImpl.java
  20. 16 16
      module-kuaishou/src/main/resources/json_template/kuaishou_filed_mapping.json
  21. 1 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/entity/ETLReportBytedanceVideo.java
  22. 1 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/mapper/xml/ETLReportBytedanceVideoMapper.xml
  23. 196 229
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceHomepageMapper.xml
  24. 7 7
      module-toutiao/src/main/resources/json_template/bytedance_filed_mapping.json
  25. 8 8
      module-toutiao/src/main/resources/json_template/bytedance_video_report_mapping.json

+ 244 - 238
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysDepartController.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.system.controller;
 import cn.com.ctop.common.module.entity.SysDepart;
 import cn.com.ctop.common.module.model.DepartIdModel;
 import cn.com.ctop.common.module.model.SysDepartTreeModel;
+import cn.com.ctop.common.module.service.ISysBaseApi;
 import cn.com.ctop.common.module.service.ISysDepartService;
 import cn.com.ctop.common.module.service.ISysUserDepartService;
 import cn.com.ctop.common.module.service.ISysUserService;
@@ -47,205 +48,209 @@ import java.util.*;
 @RequestMapping("/sys/sysDepart")
 @Slf4j
 public class SysDepartController {
+    @Autowired
+    private ISysBaseApi sysBaseAPI;
+    @Autowired
+    private ISysDepartService sysDepartService;
+    @Autowired
+    private ISysUserService sysUserService;
+    @Autowired
+    private ISysUserDepartService sysUserDepartService;
+    public RedisTemplate<String, Object> redisTemplate;
 
-	@Autowired
-	private ISysDepartService sysDepartService;
-	@Autowired
-	private ISysUserService sysUserService;
-	@Autowired
-	private ISysUserDepartService sysUserDepartService;
-	public RedisTemplate<String, Object> redisTemplate;
-	/**
-	 * 查询数据 查出我的部门,并以树结构数据格式响应给前端
-	 *
-	 * @return
-	 */
-	@RequestMapping(value = "/queryMyDeptTreeList", method = RequestMethod.GET)
-	public Result<List<SysDepartTreeModel>> queryMyDeptTreeList() {
-		Result<List<SysDepartTreeModel>> result = new Result<>();
-		LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-		try {
-			if(oConvertUtils.isNotEmpty(user.getUserIdentity()) && user.getUserIdentity().equals( CommonConstant.USER_IDENTITY_2 )){
-				List<SysDepartTreeModel> list = sysDepartService.queryMyDeptTreeList(user.getDepartIds());
-				result.setResult(list);
-				result.setMessage(CommonConstant.USER_IDENTITY_2.toString());
-				result.setSuccess(true);
-			}else{
-				result.setMessage(CommonConstant.USER_IDENTITY_1.toString());
-				result.setSuccess(true);
-			}
-		} catch (Exception e) {
-			log.error(e.getMessage(),e);
-		}
-		return result;
-	}
+    /**
+     * 查询数据 查出我的部门,并以树结构数据格式响应给前端
+     *
+     * @return
+     */
+    @RequestMapping(value = "/queryMyDeptTreeList", method = RequestMethod.GET)
+    public Result<List<SysDepartTreeModel>> queryMyDeptTreeList() {
+        Result<List<SysDepartTreeModel>> result = new Result<>();
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        try {
+            if (oConvertUtils.isNotEmpty(user.getUserIdentity()) && user.getUserIdentity().equals(CommonConstant.USER_IDENTITY_2)) {
+                List<SysDepartTreeModel> list = sysDepartService.queryMyDeptTreeList(user.getDepartIds());
+                result.setResult(list);
+                result.setMessage(CommonConstant.USER_IDENTITY_2.toString());
+                result.setSuccess(true);
+            } else {
+                result.setMessage(CommonConstant.USER_IDENTITY_1.toString());
+                result.setSuccess(true);
+            }
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+        return result;
+    }
 
-	/**
-	 * 查询数据 查出所有部门,并以树结构数据格式响应给前端
-	 *
-	 * @return
-	 */
-	@RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
-	public Result<List<SysDepartTreeModel>> queryTreeList() {
-		Result<List<SysDepartTreeModel>> result = new Result<>();
-		try {
-			List<SysDepartTreeModel> list = sysDepartService.queryTreeList();
-			result.setResult(list);
-			result.setSuccess(true);
-		} catch (Exception e) {
-			log.error(e.getMessage(),e);
-		}
-		return result;
-	}
+    /**
+     * 查询数据 查出所有部门,并以树结构数据格式响应给前端
+     *
+     * @return
+     */
+    @RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
+    public Result<List<SysDepartTreeModel>> queryTreeList() {
+        Result<List<SysDepartTreeModel>> result = new Result<>();
+        try {
+            List<SysDepartTreeModel> list = sysDepartService.queryTreeList();
+            result.setResult(list);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+        return result;
+    }
 
-	/**
-	 * 添加新数据 添加用户新建的部门对象数据,并保存到数据库
-	 *
-	 * @param sysDepart
-	 * @return
-	 */
-	//@RequiresRoles({"admin"})
-	@RequestMapping(value = "/add", method = RequestMethod.POST)
-	@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
-	public Result<SysDepart> add(@RequestBody SysDepart sysDepart, HttpServletRequest request) {
-		Result<SysDepart> result = new Result<SysDepart>();
-		String username = JwtUtil.getUserNameByToken(request);
-		try {
-			sysDepart.setCreateBy(username);
-			sysDepartService.saveDepartData(sysDepart, username);
-			result.success("添加成功!");
-		} catch (Exception e) {
-			log.error(e.getMessage(),e);
-			result.error500("操作失败");
-		}
-		return result;
-	}
+    /**
+     * 添加新数据 添加用户新建的部门对象数据,并保存到数据库
+     *
+     * @param sysDepart
+     * @return
+     */
+    //@RequiresRoles({"admin"})
+    @RequestMapping(value = "/add", method = RequestMethod.POST)
+    @CacheEvict(value = {CacheConstant.SYS_DEPARTS_CACHE, CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries = true)
+    public Result<SysDepart> add(@RequestBody SysDepart sysDepart, HttpServletRequest request) {
+        Result<SysDepart> result = new Result<SysDepart>();
+        String username = JwtUtil.getUserNameByToken(request);
+        try {
+            sysDepart.setCreateBy(username);
+            sysDepartService.saveDepartData(sysDepart, username);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
 
-	/**
-	 * 编辑数据 编辑部门的部分数据,并保存到数据库
-	 *
-	 * @param sysDepart
-	 * @return
-	 */
-	//@RequiresRoles({"admin"})
-	@RequestMapping(value = "/edit", method = RequestMethod.PUT)
-	@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
-	public Result<SysDepart> edit(@RequestBody SysDepart sysDepart, HttpServletRequest request) {
-		String username = JwtUtil.getUserNameByToken(request);
-		sysDepart.setUpdateBy(username);
-		Result<SysDepart> result = new Result<SysDepart>();
-		SysDepart sysDepartEntity = sysDepartService.getById(sysDepart.getId());
-		if (sysDepartEntity == null) {
-			result.error500("未找到对应实体");
-		} else {
-			boolean ok = sysDepartService.updateDepartDataById(sysDepart, username);
-			// TODO 返回false说明什么?
-			if (ok) {
-				result.success("修改成功!");
-			}
-		}
-		return result;
-	}
+    /**
+     * 编辑数据 编辑部门的部分数据,并保存到数据库
+     *
+     * @param sysDepart
+     * @return
+     */
+    //@RequiresRoles({"admin"})
+    @RequestMapping(value = "/edit", method = RequestMethod.PUT)
+    @CacheEvict(value = {CacheConstant.SYS_DEPARTS_CACHE, CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries = true)
+    public Result<SysDepart> edit(@RequestBody SysDepart sysDepart, HttpServletRequest request) {
+        sysBaseAPI.addLog("编辑部门,id: " + sysDepart.getId(), 0, 2);
+        String username = JwtUtil.getUserNameByToken(request);
+        sysDepart.setUpdateBy(username);
+        Result<SysDepart> result = new Result<SysDepart>();
+        SysDepart sysDepartEntity = sysDepartService.getById(sysDepart.getId());
+        if (sysDepartEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = sysDepartService.updateDepartDataById(sysDepart, username);
+            // TODO 返回false说明什么?
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+        return result;
+    }
 
-	 /**
-     *   通过id删除
-    * @param id
-    * @return
-    */
-	//@RequiresRoles({"admin"})
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    //@RequiresRoles({"admin"})
     @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
-	@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
-   public Result<SysDepart> delete(@RequestParam(name="id",required=true) String id) {
-
-       Result<SysDepart> result = new Result<SysDepart>();
-       SysDepart sysDepart = sysDepartService.getById(id);
-       if(sysDepart==null) {
-           result.error500("未找到对应实体");
-       }else {
-           boolean ok = sysDepartService.delete(id);
-           if(ok) {
-               result.success("删除成功!");
-           }
-       }
-       return result;
-   }
-
+    @CacheEvict(value = {CacheConstant.SYS_DEPARTS_CACHE, CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries = true)
+    public Result<SysDepart> delete(@RequestParam(name = "id", required = true) String id) {
+        sysBaseAPI.addLog("删除部门,id: " + id, 0, 3);
+        Result<SysDepart> result = new Result<SysDepart>();
+        SysDepart sysDepart = sysDepartService.getById(id);
+        if (sysDepart == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = sysDepartService.delete(id);
+            if (ok) {
+                result.success("删除成功!");
+            }
+        }
+        return result;
+    }
 
-	/**
-	 * 批量删除 根据前端请求的多个ID,对数据库执行删除相关部门数据的操作
-	 *
-	 * @param ids
-	 * @return
-	 */
-	//@RequiresRoles({"admin"})
-	@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
-	@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
-	public Result<SysDepart> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
 
-		Result<SysDepart> result = new Result<SysDepart>();
-		if (ids == null || "".equals(ids.trim())) {
-			result.error500("参数不识别!");
-		} else {
-			this.sysDepartService.removeByIds(Arrays.asList(ids.split(",")));
-			result.success("删除成功!");
-		}
-		return result;
-	}
+    /**
+     * 批量删除 根据前端请求的多个ID,对数据库执行删除相关部门数据的操作
+     *
+     * @param ids
+     * @return
+     */
+    //@RequiresRoles({"admin"})
+    @RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
+    @CacheEvict(value = {CacheConstant.SYS_DEPARTS_CACHE, CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries = true)
+    public Result<SysDepart> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        sysBaseAPI.addLog("批量删除部门, ids: " + ids, 0, 3);
+        Result<SysDepart> result = new Result<SysDepart>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.sysDepartService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
 
-	/**
-	 * 查询数据 添加或编辑页面对该方法发起请求,以树结构形式加载所有部门的名称,方便用户的操作
-	 *
-	 * @return
-	 */
-	@RequestMapping(value = "/queryIdTree", method = RequestMethod.GET)
-	public Result<List<DepartIdModel>> queryIdTree() {
-		Result<List<DepartIdModel>> result = new Result<>();
-		try {
-			List<DepartIdModel> list = sysDepartService.queryDepartIdTreeList();
-			result.setResult(list);
-			result.setSuccess(true);
-		} catch (Exception e) {
-			log.error(e.getMessage(),e);
-		}
-		return result;
-	}
+    /**
+     * 查询数据 添加或编辑页面对该方法发起请求,以树结构形式加载所有部门的名称,方便用户的操作
+     *
+     * @return
+     */
+    @RequestMapping(value = "/queryIdTree", method = RequestMethod.GET)
+    public Result<List<DepartIdModel>> queryIdTree() {
+        Result<List<DepartIdModel>> result = new Result<>();
+        try {
+            List<DepartIdModel> list = sysDepartService.queryDepartIdTreeList();
+            result.setResult(list);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+        return result;
+    }
 
-	/**
-	 * <p>
-	 * 部门搜索功能方法,根据关键字模糊搜索相关部门
-	 * </p>
-	 *
-	 * @param keyWord
-	 * @return
-	 */
-	@RequestMapping(value = "/searchBy", method = RequestMethod.GET)
-	public Result<List<SysDepartTreeModel>> searchBy(@RequestParam(name = "keyWord", required = true) String keyWord,@RequestParam(name = "myDeptSearch", required = false) String myDeptSearch) {
-		Result<List<SysDepartTreeModel>> result = new Result<List<SysDepartTreeModel>>();
-		//部门查询,myDeptSearch为1时为我的部门查询,登录用户为上级时查只查负责部门下数据
-		LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-		String departIds = null;
-		if(oConvertUtils.isNotEmpty(user.getUserIdentity()) && user.getUserIdentity().equals( CommonConstant.USER_IDENTITY_2 )){
-			departIds = user.getDepartIds();
-		}
-		List<SysDepartTreeModel> treeList = this.sysDepartService.searhBy(keyWord,myDeptSearch,departIds);
-		if (treeList == null || treeList.size() == 0) {
-			result.setSuccess(false);
-			result.setMessage("未查询匹配数据!");
-			return result;
-		}
-		result.setResult(treeList);
-		return result;
-	}
+    /**
+     * <p>
+     * 部门搜索功能方法,根据关键字模糊搜索相关部门
+     * </p>
+     *
+     * @param keyWord
+     * @return
+     */
+    @RequestMapping(value = "/searchBy", method = RequestMethod.GET)
+    public Result<List<SysDepartTreeModel>> searchBy(@RequestParam(name = "keyWord", required = true) String keyWord, @RequestParam(name = "myDeptSearch", required = false) String myDeptSearch) {
+        Result<List<SysDepartTreeModel>> result = new Result<List<SysDepartTreeModel>>();
+        //部门查询,myDeptSearch为1时为我的部门查询,登录用户为上级时查只查负责部门下数据
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String departIds = null;
+        if (oConvertUtils.isNotEmpty(user.getUserIdentity()) && user.getUserIdentity().equals(CommonConstant.USER_IDENTITY_2)) {
+            departIds = user.getDepartIds();
+        }
+        List<SysDepartTreeModel> treeList = this.sysDepartService.searhBy(keyWord, myDeptSearch, departIds);
+        if (treeList == null || treeList.size() == 0) {
+            result.setSuccess(false);
+            result.setMessage("未查询匹配数据!");
+            return result;
+        }
+        result.setResult(treeList);
+        return result;
+    }
 
 
-	/**
+    /**
      * 导出excel
      *
      * @param request
      * @param sysDepart
      */
     @RequestMapping(value = "/exportXls")
-    public ModelAndView exportXls(SysDepart sysDepart,HttpServletRequest request) {
+    public ModelAndView exportXls(SysDepart sysDepart, HttpServletRequest request) {
         // Step.1 组装查询条件
         QueryWrapper<SysDepart> queryWrapper = QueryGenerator.initQueryWrapper(sysDepart, request.getParameterMap());
         //Step.2 AutoPoi 导出Excel
@@ -254,15 +259,15 @@ public class SysDepartController {
         //按字典排序
         Collections.sort(pageList, new Comparator<SysDepart>() {
             @Override
-			public int compare(SysDepart arg0, SysDepart arg1) {
-            	return arg0.getOrgCode().compareTo(arg1.getOrgCode());
+            public int compare(SysDepart arg0, SysDepart arg1) {
+                return arg0.getOrgCode().compareTo(arg1.getOrgCode());
             }
         });
         //导出文件名称
         mv.addObject(NormalExcelConstants.FILE_NAME, "部门列表");
         mv.addObject(NormalExcelConstants.CLASS, SysDepart.class);
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("部门列表数据", "导出人:"+user.getRealname(), "导出信息"));
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("部门列表数据", "导出人:" + user.getRealname(), "导出信息"));
         mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
         return mv;
     }
@@ -276,11 +281,11 @@ public class SysDepartController {
      */
     //@RequiresRoles({"admin"})
     @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
-	@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
+    @CacheEvict(value = {CacheConstant.SYS_DEPARTS_CACHE, CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries = true)
     public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
         MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
-		List<String> errorMessageList = new ArrayList<>();
-		List<SysDepart> listSysDeparts = null;
+        List<String> errorMessageList = new ArrayList<>();
+        List<SysDepart> listSysDeparts = null;
         Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
         for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
             MultipartFile file = entity.getValue();// 获取上传文件对象
@@ -289,50 +294,50 @@ public class SysDepartController {
             params.setHeadRows(1);
             params.setNeedSave(true);
             try {
-            	// orgCode编码长度
-            	int codeLength = 3;
+                // orgCode编码长度
+                int codeLength = 3;
                 listSysDeparts = ExcelImportUtil.importExcel(file.getInputStream(), SysDepart.class, params);
                 //按长度排序
                 Collections.sort(listSysDeparts, new Comparator<SysDepart>() {
                     @Override
-					public int compare(SysDepart arg0, SysDepart arg1) {
-                    	return arg0.getOrgCode().length() - arg1.getOrgCode().length();
+                    public int compare(SysDepart arg0, SysDepart arg1) {
+                        return arg0.getOrgCode().length() - arg1.getOrgCode().length();
                     }
                 });
 
                 int num = 0;
                 for (SysDepart sysDepart : listSysDeparts) {
-                	String orgCode = sysDepart.getOrgCode();
-                	if(orgCode.length() > codeLength) {
-                		String parentCode = orgCode.substring(0, orgCode.length()-codeLength);
-                		QueryWrapper<SysDepart> queryWrapper = new QueryWrapper<SysDepart>();
-                		queryWrapper.eq("org_code", parentCode);
-                		try {
-                		SysDepart parentDept = sysDepartService.getOne(queryWrapper);
-                		if(!parentDept.equals(null)) {
-							sysDepart.setParentId(parentDept.getId());
-						} else {
-							sysDepart.setParentId("");
-						}
-                		}catch (Exception e) {
-                			//没有查找到parentDept
-                		}
-                	}else{
-                		sysDepart.setParentId("");
-					}
-					sysDepart.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
-					ImportExcelUtil.importDateSaveOne(sysDepart, ISysDepartService.class, errorMessageList, num, CommonConstant.SQL_INDEX_UNIQ_DEPART_ORG_CODE);
-					num++;
+                    String orgCode = sysDepart.getOrgCode();
+                    if (orgCode.length() > codeLength) {
+                        String parentCode = orgCode.substring(0, orgCode.length() - codeLength);
+                        QueryWrapper<SysDepart> queryWrapper = new QueryWrapper<SysDepart>();
+                        queryWrapper.eq("org_code", parentCode);
+                        try {
+                            SysDepart parentDept = sysDepartService.getOne(queryWrapper);
+                            if (!parentDept.equals(null)) {
+                                sysDepart.setParentId(parentDept.getId());
+                            } else {
+                                sysDepart.setParentId("");
+                            }
+                        } catch (Exception e) {
+                            //没有查找到parentDept
+                        }
+                    } else {
+                        sysDepart.setParentId("");
+                    }
+                    sysDepart.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
+                    ImportExcelUtil.importDateSaveOne(sysDepart, ISysDepartService.class, errorMessageList, num, CommonConstant.SQL_INDEX_UNIQ_DEPART_ORG_CODE);
+                    num++;
                 }
-				//清空部门缓存
-				Set keys3 = redisTemplate.keys(CacheConstant.SYS_DEPARTS_CACHE + "*");
-				Set keys4 = redisTemplate.keys(CacheConstant.SYS_DEPART_IDS_CACHE + "*");
-				redisTemplate.delete(keys3);
-				redisTemplate.delete(keys4);
-				return ImportExcelUtil.imporReturnRes(errorMessageList.size(), listSysDeparts.size() - errorMessageList.size(), errorMessageList);
+                //清空部门缓存
+                Set keys3 = redisTemplate.keys(CacheConstant.SYS_DEPARTS_CACHE + "*");
+                Set keys4 = redisTemplate.keys(CacheConstant.SYS_DEPART_IDS_CACHE + "*");
+                redisTemplate.delete(keys3);
+                redisTemplate.delete(keys4);
+                return ImportExcelUtil.imporReturnRes(errorMessageList.size(), listSysDeparts.size() - errorMessageList.size(), errorMessageList);
             } catch (Exception e) {
-                log.error(e.getMessage(),e);
-                return Result.error("文件导入失败:"+e.getMessage());
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
             } finally {
                 try {
                     file.getInputStream().close();
@@ -345,22 +350,23 @@ public class SysDepartController {
     }
 
 
-	/**
-	 * 查询所有部门信息
-	 * @return
-	 */
-	@GetMapping("listAll")
-	public Result<List<SysDepart>> listAll(@RequestParam(name = "id", required = false) String id) {
-		Result<List<SysDepart>> result = new Result<>();
-		LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
-		query.orderByAsc(SysDepart::getOrgCode);
-		if(oConvertUtils.isNotEmpty(id)){
-			String arr[] = id.split(",");
-			query.in(SysDepart::getId,arr);
-		}
-		List<SysDepart> ls = this.sysDepartService.list(query);
-		result.setSuccess(true);
-		result.setResult(ls);
-		return result;
-	}
+    /**
+     * 查询所有部门信息
+     *
+     * @return
+     */
+    @GetMapping("listAll")
+    public Result<List<SysDepart>> listAll(@RequestParam(name = "id", required = false) String id) {
+        Result<List<SysDepart>> result = new Result<>();
+        LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
+        query.orderByAsc(SysDepart::getOrgCode);
+        if (oConvertUtils.isNotEmpty(id)) {
+            String arr[] = id.split(",");
+            query.in(SysDepart::getId, arr);
+        }
+        List<SysDepart> ls = this.sysDepartService.list(query);
+        result.setSuccess(true);
+        result.setResult(ls);
+        return result;
+    }
 }

+ 33 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java

@@ -103,6 +103,8 @@ public class SysUserController {
     @Autowired
     private ISysRoleService roleService;
 
+    @Resource
+    private UserCompanyMapper userCompanyMapper;
     @Autowired
     private RedisUtil redisUtil;
     @Value("${jeecg.path.upload}")
@@ -118,14 +120,22 @@ public class SysUserController {
     public Map<String, Object> getAllDesigner() {
         Map<String, Object> map = new HashMap<>();
         List<SysUser> userList = sysUserService.getAllDesigner();
-        map.put("data",userList);
+        map.put("data", userList);
         ResultMapUtils.setResultMap(map, StatusCode.COMMON_SUCCESS);
         return map;
     }
 
+    @RequestMapping(value = "/getAllUser", method = RequestMethod.GET)
+    public Result<Object> getAllUser(String status) {
+        try {
+            List<SysUserVo> allUser = sysUserService.getAllUser(null, status);
+            return Result.ok(allUser);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
 
-    @Resource
-    private UserCompanyMapper userCompanyMapper;
 
     /**
      * 获取用户列表数据
@@ -138,6 +148,21 @@ public class SysUserController {
      */
     @PermissionData(pageComponent = "system/UserList")
     @RequestMapping(value = "/list", method = RequestMethod.GET)
+    public Result<Object> queryPageList(SysUser user, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            PageHelper.startPage(pageNo, pageSize);
+            List<SysUser> list = sysUserService.queryPageList(user);
+            PageInfo<SysUser> pageInfo = new PageInfo<>(list);
+            return Result.ok(pageInfo);
+        } catch (Exception e) {
+            log.error("获取用户列表数据-分页列表查询异常", e);
+        }
+        return Result.error("查询失败");
+    }
+
+   /* @PermissionData(pageComponent = "system/UserList")
+    @RequestMapping(value = "/list", method = RequestMethod.GET)
     public Result<IPage<SysUser>> queryPageList(SysUser user, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
         Result<IPage<SysUser>> result = new Result<>();
@@ -161,7 +186,7 @@ public class SysUserController {
         result.setResult(pageList);
         log.info(pageList.toString());
         return result;
-    }
+    }*/
 
     @RequestMapping(value = "/getAllUserListByCompany", method = RequestMethod.GET)
     public Result<List<SysUserVo>> getAllUserListByCompany(String userName) {
@@ -176,7 +201,7 @@ public class SysUserController {
             String companyId = userCompany.getCompanyId();
             List<SysUserVo> userList;
             if ("4b10089775c040119e139087517aed88".equals(companyId) || "6608ed13c0dd42de93c790dbdf124234".equals(companyId) || "d57fecdcf7a94d009736d9c850731582".equals(companyId)) {
-                userList = sysUserService.getAllUser(userName);
+                userList = sysUserService.getAllUser(userName, null);
             } else {
                 userList = sysUserService.getUserListByCompany(companyId, userName);
             }
@@ -209,7 +234,7 @@ public class SysUserController {
 
             PageHelper.startPage(pageNo, pageSize);
             if ("4b10089775c040119e139087517aed88".equals(companyId) || "6608ed13c0dd42de93c790dbdf124234".equals(companyId) || "d57fecdcf7a94d009736d9c850731582".equals(companyId)) {
-                userList = sysUserService.getAllUser(userName);
+                userList = sysUserService.getAllUser(userName, null);
             } else {
                 userList = sysUserService.getUserListByCompany(companyId, userName);
             }
@@ -238,7 +263,7 @@ public class SysUserController {
             String companyId = userCompany.getCompanyId();
             List<SysUserVo> userList;
             if ("4b10089775c040119e139087517aed88".equals(companyId) || "6608ed13c0dd42de93c790dbdf124234".equals(companyId) || "d57fecdcf7a94d009736d9c850731582".equals(companyId)) {
-                userList = sysUserService.getAllUser(userName);
+                userList = sysUserService.getAllUser(userName, null);
             } else {
                 userList = sysUserService.getUserListByCompany(companyId, userName);
             }
@@ -307,6 +332,7 @@ public class SysUserController {
             sysUserService.addUserWithDepart(user, selectedDeparts);
             userCompanyService.addOrUpdateUserWithCompany(user);
             result.success("添加成功!");
+            sysBaseAPI.addLog("添加用户,id: " + user.getId(), CommonConstant.LOG_TYPE_2, 1);
         } catch (Exception e) {
             log.error(e.getMessage(), e);
             result.error500("操作失败");

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

@@ -7,11 +7,10 @@ import cn.com.ctop.common.module.service.IBindAccountLoginService;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
-import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountTargetTemplate;
-import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAccountTargetTemplateService;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouNewCreateCampaign;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
+import cn.com.ctop.kuaishou.modules.material.service.IEtlKuaishouVideoInfoService;
 import cn.com.ctop.kuaishou.modules.report.service.*;
 import cn.com.ctop.oa.modules.service.IWechatCheckinDataService;
 import cn.com.ctop.oa.modules.service.IWechatNoListService;
@@ -21,7 +20,6 @@ import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataServ
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceAccountReportTaskRecord;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
 import cn.com.ctop.toutiao.modules.report.service.*;
-import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.junit.Test;
@@ -585,5 +583,15 @@ public class SampleTest {
             dailyService.etlKuaishouAccountMaterialReportDailyData(DateUtils.formatDate(DateUtils.addDay(startDate,i)));
         }
     }
+    @Autowired
+    private IEtlKuaishouVideoInfoService videoEtlInfoService;
+    @Test
+    public void etlKuaishouVideoInfo(){
+        Date startDate = DateUtils.parseDate("2020-09-11","yyyy-MM-dd");
+        for(int i=0;i<365;i++){
+//            dailyService.etlKuaishouAccountMaterialReportDailyData(DateUtils.formatDate(DateUtils.addDay(startDate,i)));
+            videoEtlInfoService.etlKuaishouVideoInfo(DateUtils.formatDate(DateUtils.addDay(startDate,i)));
+        }
+    }
 
 }

+ 9 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/SysDepart.java

@@ -83,6 +83,15 @@ public class SysDepart implements Serializable {
 	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
     @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
 	private Date updateTime;
+	/**
+	 * 领导 ID
+	 */
+	private String leaderId;
+
+	/**
+	 * 领导姓名
+	 */
+	private String leaderName;
 
 	/**
 	 * 重写equals方法

+ 18 - 1
module-common/src/main/java/cn/com/ctop/common/module/entity/SysUser.java

@@ -199,8 +199,25 @@ public class SysUser implements Serializable {
     private String depart;
 
     /**
-     * 部门
+     * 角色
      */
     @TableField(exist = false)
     private String roleName;
+
+    /**
+     * 组织机构名称
+     */
+    @TableField(exist = false)
+    private String departName;
+
+    /**
+     * 领导 ID
+     */
+    private String leaderId;
+
+    /**
+     * 领导姓名
+     */
+    private String leaderName;
+
 }

+ 3 - 1
module-common/src/main/java/cn/com/ctop/common/module/mapper/SysUserMapper.java

@@ -161,7 +161,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
 
     Map<String, Object> queryRoleCode(@Param("userId") String userId);
 
-    List<SysUserVo> getAllUser(@Param("userName") String userName);
+    List<SysUserVo> getAllUser(@Param("userName") String userName,@Param("status") String status);
 
     List<SysUserVo> getUserListByCompany(@Param("companyId") String companyId, @Param("userName") String userName);
 
@@ -172,4 +172,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
     JSONObject selectUserByAccount(@Param("accountId") Long accountId);
 
     SysUser getDesignerTeamLeaderBy(@Param("orgCode")String orgCode);
+
+    List<SysUser> queryPageList(SysUser user);
 }

+ 42 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/SysUserMapper.xml

@@ -100,6 +100,10 @@ SELECT
         <if test="userName != null and userName != ''">
             and t1.realname like concat(concat('%',#{userName}),'%')
         </if>
+          <if test="status != null and status != ''">
+            and t1.status =#{status}
+            AND t1.del_flag = 0
+        </if>
     </select>
     <!-- SQL片段:getUserByOrgCode 的 FROM 和 WHERE 部分 -->
     <sql id="getUserByOrgCodeFromSql">
@@ -271,4 +275,42 @@ SELECT
         AND
             role.role_code = 'designTeamLeader'
     </select>
+
+    <select id="queryPageList" resultType="cn.com.ctop.common.module.entity.SysUser">
+        SELECT t1.*,t3.depart_name ,role.role_name
+        FROM sys_user t1
+        LEFT JOIN sys_user_depart t2 ON t1.id = t2.user_id
+        LEFT JOIN sys_depart t3 ON t2.dep_id = t3.id
+        LEFT JOIN sys_user_role userRole ON t1.id = userRole.user_id
+        LEFT JOIN sys_role role ON userRole.role_id = role.id
+        where t1.del_flag = 0
+        <if test="realname != null and realname != ''">
+            AND t1.realname LIKE CONCAT(CONCAT('%',#{realname}),'%')
+        </if>
+        <if test="username != null and username != ''">
+            AND t1.username LIKE CONCAT(CONCAT('%',#{username}),'%')
+        </if>
+        <if test="email != null and email != ''">
+            AND t1.email LIKE CONCAT(CONCAT('%',#{email}),'%')
+        </if>
+        <if test="phone != null and phone != ''">
+            AND t1.phone LIKE CONCAT(CONCAT('%',#{phone}),'%')
+        </if>
+        <if test="status != null and status != ''">
+            AND t1.`status` = #{status}
+        </if>
+        <if test="leaderName != null and leaderName != ''">
+            AND t1.leader_name LIKE CONCAT(CONCAT('%',#{leaderName}),'%')
+        </if>
+        <if test="departId != null and departId != ''">
+            AND t3.id =#{departId}
+        </if>
+        <if test="roleName != null and roleName != ''">
+            AND role.role_name LIKE CONCAT(CONCAT('%',#{roleName}),'%')
+        </if>
+        <if test="sex != null and sex != ''">
+            AND t1.sex =#{sex}
+        </if>
+    </select>
+
 </mapper>

+ 23 - 0
module-common/src/main/java/cn/com/ctop/common/module/model/SysDepartTreeModel.java

@@ -73,6 +73,11 @@ public class SysDepartTreeModel implements Serializable{
 
     private Date updateTime;
 
+    private String leaderId;
+    /**
+     * 领导姓名
+     */
+    private String leaderName;
     private List<SysDepartTreeModel> children = new ArrayList<>();
 
 
@@ -104,12 +109,30 @@ public class SysDepartTreeModel implements Serializable{
         this.createTime = sysDepart.getCreateTime();
         this.updateBy = sysDepart.getUpdateBy();
         this.updateTime = sysDepart.getUpdateTime();
+        this.leaderName = sysDepart.getLeaderName();
+        this.leaderId = sysDepart.getLeaderId();
     }
 
     public boolean getIsLeaf() {
         return isLeaf;
     }
 
+    public String getLeaderId() {
+        return leaderId;
+    }
+
+    public void setLeaderId(String leaderId) {
+        this.leaderId = leaderId;
+    }
+
+    public String getLeaderName() {
+        return leaderName;
+    }
+
+    public void setLeaderName(String leaderName) {
+        this.leaderName = leaderName;
+    }
+
     public void setIsLeaf(boolean isleaf) {
          this.isLeaf = isleaf;
     }

+ 3 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/ISysUserService.java

@@ -259,9 +259,11 @@ public interface ISysUserService extends IService<SysUser> {
      */
     List<SysUser> queryByDepIds(List<String> departIds, String username);
 
-    List<SysUserVo> getAllUser(String userName);
+    List<SysUserVo> getAllUser(String userName,String status);
 
     List<SysUser> getAllDesigner();
 
     SysUser getDesignerTeamLeaderBy(String orgCode);
+
+    List<SysUser> queryPageList(SysUser user);
 }

+ 1 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/SysBaseApiImpl.java

@@ -749,6 +749,7 @@ public class SysBaseApiImpl implements ISysBaseApi {
     }
 
     /**
+
      * 推送签到人员信息
      *
      * @param userId

+ 10 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/impl/SysDepartServiceImpl.java

@@ -4,6 +4,7 @@ import cn.com.ctop.common.module.entity.*;
 import cn.com.ctop.common.module.mapper.*;
 import cn.com.ctop.common.module.model.DepartIdModel;
 import cn.com.ctop.common.module.model.SysDepartTreeModel;
+import cn.com.ctop.common.module.service.ISysBaseApi;
 import cn.com.ctop.common.module.service.ISysDepartRoleService;
 import cn.com.ctop.common.module.service.ISysDepartService;
 import cn.com.ctop.common.module.utils.Check;
@@ -33,7 +34,8 @@ import java.util.*;
  */
 @Service
 public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart> implements ISysDepartService {
-
+    @Autowired
+    private ISysBaseApi sysBaseAPI;
     @Resource
     private SysUserDepartMapper userDepartMapper;
     @Autowired
@@ -81,6 +83,12 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
         query.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
         query.orderByAsc(SysDepart::getDepartOrder);
         List<SysDepart> list = this.list(query);
+        for (SysDepart sysDepart : list) {
+            if (!Check.isNull(sysDepart.getLeaderName())) {
+                sysDepart.setDepartName(sysDepart.getDepartName().concat("(").concat(sysDepart.getLeaderName()).concat(")"));
+            }
+        }
+
         // 调用wrapTreeDataToTreeList方法生成树状数据
         List<SysDepartTreeModel> listResult = FindsDepartsChildrenUtil.wrapTreeDataToTreeList(list);
         return listResult;
@@ -127,6 +135,7 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
             sysDepart.setCreateTime(new Date());
             sysDepart.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
             this.save(sysDepart);
+            sysBaseAPI.addLog("添加部门,id: " + sysDepart.getId(), 0, 1);
         }
 
     }

+ 7 - 2
module-common/src/main/java/cn/com/ctop/common/module/service/impl/SysUserServiceImpl.java

@@ -268,8 +268,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
     }
 
     @Override
-    public List<SysUserVo> getAllUser(String userName) {
-        return userMapper.getAllUser(userName);
+    public List<SysUserVo> getAllUser(String userName,String status) {
+        return userMapper.getAllUser(userName,status);
     }
 
     @Override
@@ -283,6 +283,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
     }
 
     @Override
+    public List<SysUser> queryPageList(SysUser user) {
+        return userMapper.queryPageList(user);
+    }
+
+    @Override
     public Map<String, String> getDepNamesByUserIds(List<String> userIds) {
         List<SysUserDepVo> list = this.baseMapper.getDepNamesByUserIds(userIds);
         Map<String, String> res = new HashMap<String, String>();

+ 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);

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/mapper/EtlKuaishouVideoInfoMapper.java

@@ -14,5 +14,5 @@ public interface EtlKuaishouVideoInfoMapper extends BaseMapper<EtlKuaishouVideoI
 
     String getVideoMinDate(@Param(value = "signature") String signature);
 
-    void replaceVideoInfo(@Param(value = "video")EtlKuaishouVideoInfo etlKuaishouVideoInfo);
+    void replaceVideoInfo(@Param(value = "etlKuaishouVideoInfo")EtlKuaishouVideoInfo etlKuaishouVideoInfo);
 }

+ 38 - 94
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/mapper/xml/EtlKuaishouVideoInfoMapper.xml

@@ -3,100 +3,44 @@
 <mapper namespace="cn.com.ctop.kuaishou.modules.material.mapper.EtlKuaishouVideoInfoMapper">
     <insert id="replaceVideoInfo" parameterType="cn.com.ctop.kuaishou.modules.material.entity.EtlKuaishouVideoInfo">
         replace into ctop_etl_kuaishou_video_info
-        <trim prefix="(" suffix=")" suffixOverrides="," >
-            <if test="id != null" >
-                id,
-            </if>
-            <if test="videoCode != null" >
-                video_code,
-            </if>
-            <if test="stateDate != null" >
-                state_date,
-            </if>
-            <if test="url != null" >
-                url,
-            </if>
-            <if test="coverUrl != null" >
-                cover_url,
-            </if>
-            <if test="channelType != null" >
-                channel_type,
-            </if>
-            <if test="companyName != null" >
-                company_name,
-            </if>
-            <if test="planId != null" >
-                plan_id,
-            </if>
-            <if test="planName != null" >
-                plan_name,
-            </if>
-            <if test="clipId != null" >
-                clip_id,
-            </if>
-            <if test="clipName != null" >
-                clip_name,
-            </if>
-            <if test="shotId != null" >
-                shot_id,
-            </if>
-            <if test="shotName != null" >
-                shot_name,
-            </if>
-            <if test="designTeamLeaderId != null" >
-                design_team_leader_id,
-            </if>
-            <if test="designTeamLeaderName != null" >
-                design_team_leader_name,
-            </if>
-        </trim>
-        <trim prefix="values (" suffix=")" suffixOverrides="," >
-            <if test="id != null" >
-                #{id},
-            </if>
-            <if test="videoCode != null" >
-                #{videoCode},
-            </if>
-            <if test="stateDate != null" >
-                #{stateDate},
-            </if>
-            <if test="url != null" >
-                #{url},
-            </if>
-            <if test="coverUrl != null" >
-                #{coverUrl},
-            </if>
-            <if test="channelType != null" >
-                #{channelType},
-            </if>
-            <if test="companyName != null" >
-                #{companyName},
-            </if>
-            <if test="planId != null" >
-                #{planId},
-            </if>
-            <if test="planName != null" >
-                #{planName},
-            </if>
-            <if test="clipId != null" >
-                #{clipId},
-            </if>
-            <if test="clipName != null" >
-                #{clipName},
-            </if>
-            <if test="shotId != null" >
-                #{shotId},
-            </if>
-            <if test="shotName != null" >
-                #{shotName},
-            </if>
-            <if test="designTeamLeaderId != null" >
-                #{designTeamLeaderId},
-            </if>
-            <if test="designTeamLeaderName != null" >
-                #{designTeamLeaderName},
-            </if>
-        </trim>
+            (
+            video_code,
+            video_name,
+            state_date,
+            url,
+            cover_url,
+            channel_type,
+            channel_name,
+            plan_id,
+            plan_name,
+            clip_id,
+            clip_name,
+            shot_id,
+            shot_name,
+            design_team_leader_id,
+            design_team_leader_name)
+            values
+            (
+           #{etlKuaishouVideoInfo.videoCode},
+           #{etlKuaishouVideoInfo.videoName},
+           #{etlKuaishouVideoInfo.stateDate},
+                #{etlKuaishouVideoInfo.url},
+                #{etlKuaishouVideoInfo.coverUrl},
+                #{etlKuaishouVideoInfo.channelType},
+                #{etlKuaishouVideoInfo.channelName},
+                #{etlKuaishouVideoInfo.planId},
+                #{etlKuaishouVideoInfo.planName},
+                #{etlKuaishouVideoInfo.clipId},
+                #{etlKuaishouVideoInfo.clipName},
+                #{etlKuaishouVideoInfo.shotId},
+                #{etlKuaishouVideoInfo.shotName},
+                #{etlKuaishouVideoInfo.designTeamLeaderId},
+                #{etlKuaishouVideoInfo.designTeamLeaderName}
+        )
+
+
+
+
     </insert>
 
     <select id="getVideoMinDate" resultType="java.lang.String">

+ 82 - 61
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/material/service/impl/EtlKuaishouVideoInfoServiceImpl.java

@@ -1,14 +1,10 @@
 package cn.com.ctop.kuaishou.modules.material.service.impl;
 
-import cn.com.ctop.common.module.entity.MaterialAscription;
 import cn.com.ctop.common.module.entity.MaterialInfo;
 import cn.com.ctop.common.module.entity.SysUser;
-import cn.com.ctop.common.module.entity.UserCompany;
-import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
 import cn.com.ctop.common.module.service.IMaterialAscriptionService;
 import cn.com.ctop.common.module.service.IMaterialInfoService;
 import cn.com.ctop.common.module.service.ISysUserService;
-import cn.com.ctop.common.module.service.IUserCompanyService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 import cn.com.ctop.kuaishou.modules.material.entity.EtlKuaishouVideoInfo;
@@ -17,6 +13,7 @@ import cn.com.ctop.kuaishou.modules.material.service.IEtlKuaishouVideoInfoServic
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -24,6 +21,9 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.util.Date;
 import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 /**
  * 快手视频报表信息
@@ -32,6 +32,7 @@ import java.util.List;
  * @version V1.0
  */
 @Service
+@Slf4j
 public class EtlKuaishouVideoInfoServiceImpl extends ServiceImpl<EtlKuaishouVideoInfoMapper, EtlKuaishouVideoInfo> implements IEtlKuaishouVideoInfoService {
     @Resource
     private EtlKuaishouVideoInfoMapper etlKuaishouVideoInfoMapper;
@@ -43,72 +44,92 @@ public class EtlKuaishouVideoInfoServiceImpl extends ServiceImpl<EtlKuaishouVide
     private ISysUserService sysUserService;
     @Autowired
     private IMaterialInfoService materialInfoService;
+
+    ExecutorService executorService = Executors.newFixedThreadPool(200);
+
     @Override
     public void etlKuaishouVideoInfo(String date) {
         //1:查询当前日期内的所有存在md5码信息的视频数据
         List<KuaiShouVideoGet> videoGets = videoGetService.getVideoInfoGroupBySignature(date);
         if(null!=videoGets&&!videoGets.isEmpty()){
+            CountDownLatch countDownLatch = new CountDownLatch(videoGets.size());
             videoGets.forEach(videoGet -> {
-                //1:查询素材名称
-                EtlKuaishouVideoInfo etlKuaishouVideoInfo = new EtlKuaishouVideoInfo();
-                MaterialInfo materialInfo = materialInfoService.getMaterialInfoByCode(videoGet.getSignature());
-                if(null == materialInfo){
-                    etlKuaishouVideoInfo.setVideoName(materialInfo.getMaterialName());
-                }else{
-                    etlKuaishouVideoInfo.setVideoName(videoGet.getPhotoName());
-                }
-                etlKuaishouVideoInfo.setVideoCode(videoGet.getSignature());
-                etlKuaishouVideoInfo.setUrl(videoGet.getUrl());
-                etlKuaishouVideoInfo.setCoverUrl(videoGet.getCoverUrl());
-                etlKuaishouVideoInfo.setChannelType(videoGet.getChannelType().toString());
-                if(videoGet.getChannelType() == 0){
-                    etlKuaishouVideoInfo.setChannelName("内部");
-                }else {
-                    etlKuaishouVideoInfo.setChannelName("素造");
-                }
-                //查询相关设计人员信息
-                JSONObject ascription = ascriptionService.getDetailByCode(videoGet.getSignature());
-                if(null!=ascription){
-                    String clipId = ascription.getString("clipId");
-                    if(null!=clipId&&!clipId.trim().equals("")){
-                        etlKuaishouVideoInfo.setClipId(clipId);
-                        //根据id查询剪辑所属的设计负责人
-                        SysUser user = sysUserService.getById(clipId);
-                        SysUser designTeamLeader = sysUserService.getDesignerTeamLeaderBy(user.getOrgCode());
-                        if(null!=designTeamLeader){
-                            etlKuaishouVideoInfo.setDesignTeamLeaderId(designTeamLeader.getId());
-                            etlKuaishouVideoInfo.setDesignTeamLeaderName(designTeamLeader.getRealname());
+                executorService.submit(()->{
+                    try {
+                        //1:查询素材名称
+                        EtlKuaishouVideoInfo etlKuaishouVideoInfo = new EtlKuaishouVideoInfo();
+                        MaterialInfo materialInfo = materialInfoService.getMaterialInfoByCode(videoGet.getSignature());
+                        if(null != materialInfo){
+                            etlKuaishouVideoInfo.setVideoName(materialInfo.getMaterialName());
+                        }else{
+                            etlKuaishouVideoInfo.setVideoName(videoGet.getPhotoName());
                         }
+                        etlKuaishouVideoInfo.setVideoCode(videoGet.getSignature());
+                        etlKuaishouVideoInfo.setUrl(videoGet.getUrl());
+                        etlKuaishouVideoInfo.setCoverUrl(videoGet.getCoverUrl());
+                        etlKuaishouVideoInfo.setChannelType(videoGet.getChannelType().toString());
+                        if(videoGet.getChannelType() == 0){
+                            etlKuaishouVideoInfo.setChannelName("内部");
+                        }else {
+                            etlKuaishouVideoInfo.setChannelName("素造");
+                        }
+                        //查询相关设计人员信息
+                        JSONObject ascription = ascriptionService.getDetailByCode(videoGet.getSignature());
+                        if(null!=ascription){
+                            String clipId = ascription.getString("clipId");
+                            if(null!=clipId&&!clipId.trim().equals("")){
+                                etlKuaishouVideoInfo.setClipId(clipId);
+                                //根据id查询剪辑所属的设计负责人
+                                SysUser user = sysUserService.getById(clipId);
+                                if(null!=user){
+                                    SysUser designTeamLeader = sysUserService.getDesignerTeamLeaderBy(user.getOrgCode());
+                                    if(null!=designTeamLeader){
+                                        etlKuaishouVideoInfo.setDesignTeamLeaderId(designTeamLeader.getId());
+                                        etlKuaishouVideoInfo.setDesignTeamLeaderName(designTeamLeader.getRealname());
+                                    }
+                                }
+                            }
+                            String clipName = ascription.getString("clipName");
+                            if(null!=clipName&&!clipName.trim().equals("")){
+                                etlKuaishouVideoInfo.setClipName(clipName);
+                            }
+                            String planId = ascription.getString("planId");
+                            if(null!=planId&&!planId.trim().equals("")){
+                                etlKuaishouVideoInfo.setPlanId(planId);
+                            }
+                            String planName = ascription.getString("planName");
+                            if(null!=planName&&!planName.trim().equals("")){
+                                etlKuaishouVideoInfo.setPlanName(planName);
+                            }
+                            String shotId = ascription.getString("shotId");
+                            if(null!=shotId&&!shotId.trim().equals("")){
+                                etlKuaishouVideoInfo.setShotId(shotId);
+                            }
+                            String shotName = ascription.getString("shotName");
+                            if(null!=shotName&&!shotName.trim().equals("")){
+                                etlKuaishouVideoInfo.setShotName(shotName);
+                            }
+                        }
+                        //查询视频初次消耗时间
+                        String minDate = etlKuaishouVideoInfoMapper.getVideoMinDate(videoGet.getSignature());
+                        if(null!=minDate&&!"".equals(minDate)){
+                            Date getDate = DateUtils.parseDate(minDate,"yyyy-MM-dd");
+                            etlKuaishouVideoInfo.setStateDate(getDate);
+                        }
+                        etlKuaishouVideoInfoMapper.replaceVideoInfo(etlKuaishouVideoInfo);
+                    }catch (Exception e){
+                        e.printStackTrace();
+                    }finally {
+                        countDownLatch.countDown();
                     }
-                    String clipName = ascription.getString("clipName");
-                    if(null!=clipName&&!clipName.trim().equals("")){
-                        etlKuaishouVideoInfo.setClipName(clipName);
-                    }
-                    String planId = ascription.getString("planId");
-                    if(null!=planId&&!planId.trim().equals("")){
-                        etlKuaishouVideoInfo.setPlanId(planId);
-                    }
-                    String planName = ascription.getString("planName");
-                    if(null!=planName&&!planName.trim().equals("")){
-                        etlKuaishouVideoInfo.setPlanName(planName);
-                    }
-                    String shotId = ascription.getString("shotId");
-                    if(null!=shotId&&!shotId.trim().equals("")){
-                        etlKuaishouVideoInfo.setShotId(shotId);
-                    }
-                    String shotName = ascription.getString("shotName");
-                    if(null!=shotName&&!shotName.trim().equals("")){
-                        etlKuaishouVideoInfo.setShotName(shotName);
-                    }
-                }
-                //查询视频初次消耗时间
-                String minDate = etlKuaishouVideoInfoMapper.getVideoMinDate(videoGet.getSignature());
-                if(null!=minDate&&!"".equals(minDate)){
-                    Date getDate = DateUtils.parseDate(minDate,"yyyy-MM-dd");
-                    etlKuaishouVideoInfo.setStateDate(getDate);
-                }
-                etlKuaishouVideoInfoMapper.replaceVideoInfo(etlKuaishouVideoInfo);
+                });
             });
+            try {
+                countDownLatch.await();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+            log.info("{}数据获取完成",date);
         }
     }
     @Override

+ 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

+ 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;

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

@@ -16,6 +16,7 @@ import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
@@ -32,7 +33,7 @@ import java.util.concurrent.Executors;
 @Slf4j
 @Service
 public class KuaishouVideoEtlInfoServiceImpl extends ServiceImpl<KuaishouVideoEtlInfoMapper, KuaishouVideoEtlInfo> implements IKuaishouVideoEtlInfoService {
-    @Autowired
+    @Resource
     private KuaishouVideoEtlInfoMapper kuaishouVideoEtlInfoMapper;
     @Autowired
     private IKuaiShouReportDailyMaterialService dailyMaterialService;

+ 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 concat(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": "下载完成激活率"
   }
 }

+ 1 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/entity/ETLReportBytedanceVideo.java

@@ -374,7 +374,7 @@ public class ETLReportBytedanceVideo {
 	/**materailShow*/
 	@Excel(name = "materailShow", width = 15)
     @ApiModelProperty(value = "materailShow")
-	private Long materailShow;
+	private Long materialShow;
 	/**转化数据-转化率*/
 	@Excel(name = "转化数据-转化率", width = 15)
     @ApiModelProperty(value = "转化数据-转化率")

+ 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": {