Przeglądaj źródła

Merge branch 'master' of http://git.tjyourong.com.cn/ctop/adsp-cloud

yumeng 3 lat temu
rodzic
commit
c8862df42a
38 zmienionych plików z 362 dodań i 255 usunięć
  1. 6 0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
  2. 3 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCreativeMapper.java
  3. 4 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCreativeMapper.xml
  4. 2 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCreativeService.java
  5. 5 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCreativeServiceImpl.java
  6. 19 8
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelMapper.xml
  7. 20 3
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/impl/KuaishouChannelServiceImpl.java
  8. 13 7
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java
  9. 56 59
      jeecg-boot-report/src/main/java/cn/com/ctop/common/constant/AccountReportConstants.java
  10. 2 1
      jeecg-boot-report/src/main/java/cn/com/ctop/common/mapper/UserAllocationMapper.java
  11. 2 2
      jeecg-boot-report/src/main/java/cn/com/ctop/common/mapper/xml/ProjectMapper.xml
  12. 42 36
      jeecg-boot-report/src/main/java/cn/com/ctop/common/mapper/xml/ProjectMemberMapper.xml
  13. 1 1
      jeecg-boot-report/src/main/java/cn/com/ctop/common/mapper/xml/SysDepartMapper.xml
  14. 5 5
      jeecg-boot-report/src/main/java/cn/com/ctop/common/mapper/xml/SysRoleMapper.xml
  15. 1 1
      jeecg-boot-report/src/main/java/cn/com/ctop/common/mapper/xml/SysUserMapper.xml
  16. 6 5
      jeecg-boot-report/src/main/java/cn/com/ctop/common/mapper/xml/UserAllocationMapper.xml
  17. 1 1
      jeecg-boot-report/src/main/java/cn/com/ctop/common/service/IUserAllocationService.java
  18. 1 1
      jeecg-boot-report/src/main/java/cn/com/ctop/common/service/impl/ProjectMemberServiceImpl.java
  19. 2 2
      jeecg-boot-report/src/main/java/cn/com/ctop/common/service/impl/UserAllocationServiceImpl.java
  20. 10 5
      jeecg-boot-report/src/main/java/cn/com/ctop/report/controller/KuaishouAccountReportDailyDwController.java
  21. 13 13
      jeecg-boot-report/src/main/java/cn/com/ctop/report/controller/KuaishouMaterialReportDailyDwController.java
  22. 5 1
      jeecg-boot-report/src/main/java/cn/com/ctop/report/entity/AccountAttributionInfo.java
  23. 6 6
      jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/AccountAttributionInfoMapper.java
  24. 1 1
      jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/KuaishouAccountReportDailyDwMapper.java
  25. 1 1
      jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/KuaishouAccountReportHourlyDwMapper.java
  26. 1 1
      jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/KuaishouMaterialVideoReportDailyDwMapper.java
  27. 27 26
      jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/xml/AccountAttributionInfoMapper.xml
  28. 3 3
      jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/xml/KuaishouAccountReportDailyDwMapper.xml
  29. 6 5
      jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/xml/KuaishouAccountReportHourlyDwMapper.xml
  30. 22 25
      jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/xml/KuaishouMaterialVideoReportDailyDwMapper.xml
  31. 42 18
      jeecg-boot-report/src/main/java/cn/com/ctop/report/service/impl/AccountAttributionInfoServiceImpl.java
  32. 15 9
      jeecg-boot-report/src/main/java/cn/com/ctop/report/service/impl/KuaishouAccountReportDailyDwServiceImpl.java
  33. 2 2
      jeecg-boot-report/src/main/resources/application-dev.yml
  34. 2 3
      jeecg-boot-report/src/main/resources/application-prod.yml
  35. 2 2
      jeecg-boot-report/src/main/resources/application-test.yml
  36. 1 1
      jeecg-boot-report/src/main/resources/application.yml
  37. 6 0
      jeecg-cloud-module/jeecg-cloud-gateway/src/main/resources/application-dev.yml
  38. 6 0
      jeecg-cloud-module/jeecg-cloud-gateway/src/main/resources/application-prod.yml

+ 6 - 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java

@@ -114,6 +114,12 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/ctop/material/top/cost", "anon");
         filterChainDefinitionMap.put("/dimension/report/*", "anon");
         filterChainDefinitionMap.put("/userAllocation/updateAuthName", "anon");
+        filterChainDefinitionMap.put("/account/report/getProjectAccountByUserId", "anon");
+        filterChainDefinitionMap.put("/account/report/kuaishou/list", "anon");
+        filterChainDefinitionMap.put("/account/report/kuaishou/chart", "anon");
+        filterChainDefinitionMap.put("/material/report/getProjectAccountByUserId", "anon");
+        filterChainDefinitionMap.put("/material/report/kuaishou/list", "anon");
+        filterChainDefinitionMap.put("/material/report/kuaishou/detail", "anon");
 
         filterChainDefinitionMap.put("/v1/**", "anon");
 

+ 3 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCreativeMapper.java

@@ -35,9 +35,11 @@ public interface KuaiShouCreativeMapper extends BaseMapper<KuaiShouCreative> {
 
     String getClickTrackUrl(@Param("accountId") Long accountId, @Param("unitId") Long unitId);
 
-    Long queryCreativeByPhotoIdTotal(@Param("photoIds")  List<String> photoIds, @Param("accountId") Long accountId);
+    Long queryCreativeByPhotoIdTotal(@Param("photoIds") List<String> photoIds, @Param("accountId") Long accountId);
 
     List<JSONObject> queryCreativeByPhotoId(@Param("photoId") String photoId);
 
     List<JSONObject> queryCreativeByPhotoIds(@Param("photoIds") List<String> photoIds, @Param("accountId") Long accountId);
+
+    String querMaxCreateTime(@Param("unitId") Long unitId);
 }

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

@@ -221,4 +221,8 @@
         </if>
         and t1.status = 42
     </select>
+
+    <select id="querMaxCreateTime" resultType="java.lang.String">
+        SELECT MAX(create_time) FROM ctop_kuaishou_creative WHERE unit_id = #{unitId}
+    </select>
 </mapper>

+ 2 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCreativeService.java

@@ -74,4 +74,6 @@ public interface IKuaiShouCreativeService extends IService<KuaiShouCreative> {
 
 
     void getProgramCreative(CtopOauthToken oauthToken, int page);
+
+    String querMaxCreateTime(Long unitId);
 }

+ 5 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCreativeServiceImpl.java

@@ -379,5 +379,10 @@ public class KuaiShouCreativeServiceImpl extends ServiceImpl<KuaiShouCreativeMap
 
     }
 
+    @Override
+    public String querMaxCreateTime(Long unitId) {
+        return kuaiShouCreativeMapper.querMaxCreateTime(unitId);
+    }
+
 
 }

+ 19 - 8
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelMapper.xml

@@ -116,14 +116,25 @@
     </select>
 
     <select id="channelNumberUsageDetailsList" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT IFNULL((SELECT MAX(tt.create_time)
-                       FROM ctop_kuaishou_creative tt
-                       WHERE tt.unit_id = t3.unit_id),
-                      '-') as 'createTime', CASE t1.usage_range WHEN 1 THEN '账户' WHEN 2 THEN '项目' ELSE '' END as 'usageRange', IFNULL(t3.channel_code, '') as 'channelCode', IFNULL(t1.project_name, '') as 'projectName', IFNULL(t2.auth_name, '') as 'authName', IFNULL(t3.account_id, '') as 'accountId', IFNULL(t3.campaign_id, '') as 'campaignId', IFNULL(t3.unit_id, '') as 'unitId'
-        FROM ctop_kuaishou_channel_rel t3
-                 INNER JOIN ctop_kuaishou_channel t1
-                            ON t1.account_id = t3.account_id AND t1.channel_code = t3.channel_code
-                 LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        SELECT
+            CASE
+                t1.usage_range
+                WHEN 1 THEN
+                    '账户'
+                WHEN 2 THEN
+                    '项目' ELSE ''
+                END AS 'usageRange',
+            IFNULL( t3.channel_code, '' ) AS 'channelCode',
+            IFNULL( t1.project_name, '' ) AS 'projectName',
+            IFNULL( t2.auth_name, '' ) AS 'authName',
+            IFNULL( t3.account_id, '' ) AS 'accountId',
+            IFNULL( t3.campaign_id, '' ) AS 'campaignId',
+            IFNULL( t3.unit_id, '' ) AS 'unitId'
+        FROM
+            ctop_kuaishou_channel_rel t3
+                INNER JOIN ctop_kuaishou_channel t1 ON t1.account_id = t3.account_id
+                AND t1.channel_code = t3.channel_code
+                LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
         WHERE t3.account_id = #{accountId}
           AND t3.channel_code = #{channelCode}
           AND t3.unit_id is not null

+ 20 - 3
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/impl/KuaishouChannelServiceImpl.java

@@ -14,7 +14,9 @@ import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaiShouAppInfoService;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouAppListService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannel;
 import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannelAppInfo;
 import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannelCreateStrategy;
@@ -91,9 +93,15 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
     private IKuaishouChannelAppInfoService channelAppInfoService;
 
     @Autowired
+    private IKuaiShouCreativeService kuaiShouCreativeService;
+
+    @Autowired
     private IKuaiShouAppListService kuaiShouAppListService;
 
     @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    @Autowired
     private IAiKuaiShouAppInfoService appInfoService;
 
     @Autowired
@@ -141,7 +149,12 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
     public Result<Object> channelNumberUsageDetailsList(KuaishouChannel kuaishouChannel, Integer pageNo, Integer pageSize) {
         Long total = channelMapper.channelNumberUsageDetailsListTotal(kuaishouChannel);
         PageHelper.startPage(pageNo, pageSize, false);
-        PageInfo pageInfo = new PageInfo(channelMapper.channelNumberUsageDetailsList(kuaishouChannel));
+        List<JSONObject> list = channelMapper.channelNumberUsageDetailsList(kuaishouChannel);
+        for (JSONObject jsonObject : list) {
+            String time = kuaiShouCreativeService.querMaxCreateTime(jsonObject.getLong("unitId"));
+            jsonObject.put("createTime",time);
+        }
+        PageInfo pageInfo = new PageInfo(list);
         pageInfo.setTotal(total);
         return Result.ok(pageInfo);
     }
@@ -324,6 +337,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                             log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
                         }
                         //使用范围是账户时,查询旧app来做匹配
+                        kuaishouInterfaceService.getAppList(accountId, token.getAccessToken());
                         List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(accountId);
                         strategy.setImageToken(tokenJson.getString("imageToken"));
                         strategy.setAccountId(accountId);
@@ -360,6 +374,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                     log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
                 }
                 //使用范围是账户时,查询旧app来做匹配
+                kuaishouInterfaceService.getAppList(strategy.getAccountId(), token.getAccessToken());
                 List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(strategy.getAccountId());
                 strategy.setImageToken(tokenJson.getString("imageToken"));
                 if (url.contains(CHANNEL_STR)) {
@@ -425,9 +440,9 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                         KuaishouChannelAppInfo channelAppInfo = new KuaishouChannelAppInfo();
                         BeanUtils.copyProperties(app, channelAppInfo);
                         channelAppInfo.setState(1);
-                        channelAppInfo.setUrl((String)app.getUrl());
+                        channelAppInfo.setUrl((String) app.getUrl());
                         channelAppInfo.setUseSdk(0);
-                        channelAppInfo.setAppIconUrl((String)app.getAppIconUrl());
+                        channelAppInfo.setAppIconUrl((String) app.getAppIconUrl());
                         channelAppInfo.setId(null);
                         channelAppInfo.setType("copy");
                         channelAppInfo.setRemark("copy原有App");
@@ -906,6 +921,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                                 log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
                             }
                             //使用范围是账户时,查询旧app来做匹配
+                            kuaishouInterfaceService.getAppList(strategy.getAccountId(), token.getAccessToken());
                             List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(accountId);
                             strategy.setImageToken(tokenJson.getString("imageToken"));
                             strategy.setAccountId(accountId);
@@ -927,6 +943,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                         log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
                     }
                     //使用范围是账户时,查询旧app来做匹配
+                    kuaishouInterfaceService.getAppList(strategy.getAccountId(), token.getAccessToken());
                     List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(strategy.getAccountId());
                     strategy.setImageToken(tokenJson.getString("imageToken"));
                     try {

+ 13 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java

@@ -98,7 +98,7 @@ public class ProjectMemberController {
         try {
             QueryWrapper<ProjectMember> queryWrapper = new QueryWrapper<>();
             String roleCode = sysRoleService.getRoleCodeByUserId(userId);
-            if (!"admin".equals(roleCode) && !roleCode.contains("sale") && !"meidaManager".equals(roleCode)) {
+            if (!"admin".equals(roleCode) && !"sale".contains(roleCode) && !"meidaManager".equals(roleCode)) {
                 queryWrapper.eq("user_id", userId);
             }
             queryWrapper.groupBy("project_id");
@@ -169,7 +169,7 @@ public class ProjectMemberController {
             //查询用户角色
             String roleCode = sysRoleService.getRoleCodeByUserId(userId);
             //角色为 管理员 || 销售 || 媒介 查询全部
-            if ("admin".equals(roleCode) || roleCode.contains("sale") || "meidaManager".equals(roleCode)) {
+            if ("admin".equals(roleCode) || "sale".contains(roleCode) || "meidaManager".equals(roleCode)) {
                 userId = null;
             }
             //查询项目信息以及广告主
@@ -199,6 +199,9 @@ public class ProjectMemberController {
                 for (JSONObject object : list) {
                     List<JSONObject> proList = new ArrayList<>();
                     for (JSONObject have : haveList) {
+                        if(Check.isNull(have)){
+                            continue;
+                        }
                         if (Check.isNull(have.getLong("productId"))) {
                             continue;
                         }
@@ -237,7 +240,7 @@ public class ProjectMemberController {
             //查询用户角色
             String roleCode = sysRoleService.getRoleCodeByUserId(userId);
             //角色为 管理员 || 销售 || 媒介 查询全部
-            if ("admin".equals(roleCode) || roleCode.contains("sale") || "meidaManager".equals(roleCode)) {
+            if ("admin".equals(roleCode) || "sale".contains(roleCode) || "meidaManager".equals(roleCode)) {
                 userId = null;
             }
             //查询项目信息以及广告主
@@ -253,6 +256,9 @@ public class ProjectMemberController {
                 for (JSONObject object : list) {
                     List<JSONObject> proList = new ArrayList<>();
                     for (JSONObject have : projectList) {
+                        if(Check.isNull(have)){
+                            continue;
+                        }
                         if (Check.isNull(have.getLong("productId"))) {
                             continue;
                         }
@@ -302,7 +308,7 @@ public class ProjectMemberController {
             //查询用户角色
             String roleCode = sysRoleService.getRoleCodeByUserId(userId);
             //角色为 管理员 || 销售 || 媒介 查询全部
-            if ("admin".equals(roleCode) || roleCode.contains("sale") || "meidaManager".equals(roleCode)) {
+            if ("admin".equals(roleCode) || "sale".contains(roleCode) || "meidaManager".equals(roleCode)) {
                 userId = null;
             }
             //查询项目信息以及广告主
@@ -397,7 +403,7 @@ public class ProjectMemberController {
         try {
 
             String roleCode = sysRoleService.getRoleCodeByUserId(userId);
-            if ("admin".equals(roleCode) || roleCode.contains("sale") || "meidaManager".equals(roleCode)) {
+            if ("admin".equals(roleCode) || "sale".contains(roleCode) || "meidaManager".equals(roleCode)) {
                 List<Project> projects = projectService.list();
                 result.put("data", projects);
                 ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
@@ -434,7 +440,7 @@ public class ProjectMemberController {
         projectMember.setProductId(null);
         QueryWrapper<ProjectMember> queryWrapper = QueryGenerator.initQueryWrapper(projectMember, req.getParameterMap());
         String roleCode = sysRoleService.getRoleCodeByUserId(userId);
-        if (!"admin".equals(roleCode) && !roleCode.contains("sale") && !"meidaManager".equals(roleCode)) {
+        if (!"admin".equals(roleCode) && !"sale".contains(roleCode) && !"meidaManager".equals(roleCode)) {
             queryWrapper.eq("user_id", userId);
         }
         if (!Check.isNull(projectName)) {
@@ -675,7 +681,7 @@ public class ProjectMemberController {
         List<Integer> mediaIds = new ArrayList<>();
         mediaIds.add(1);
         mediaIds.add(3);
-        List<ProjectMember> projectMemberList = projectMemberService.getProjects(mediaIds,userId);
+        List<ProjectMember> projectMemberList = projectMemberService.getProjects(mediaIds, userId);
         if (projectMemberList == null) {
             result.error500("未找到对应实体");
         } else {

+ 56 - 59
jeecg-boot-report/src/main/java/cn/com/ctop/common/constant/AccountReportConstants.java

@@ -16,11 +16,11 @@ public class AccountReportConstants {
             "    \"comment\": \"消耗\"\n" +
             "  },\n" +
             "  \"showMaterial\": {\n" +
-            "    \"filed\": \"IFNULL(sum(t1.show_num),0) as showMaterial \",\n" +
+            "    \"filed\": \"IFNULL(sum(t1.`show`),0) as showMaterial \",\n" +
             "    \"comment\": \"展示数\"\n" +
             "  },\n" +
             "  \"cpm\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(t1.cost) / sum(t1.show_num) IS NULL THEN 0 ELSE ROUND((sum(t1.cost) / sum(t1.show_num)) * 1000, 2 ) END AS cpm \",\n" +
+            "    \"filed\": \"CASE WHEN sum(t1.cost) / sum(t1.`show`) IS NULL THEN 0 ELSE ROUND((sum(t1.cost) / sum(t1.`show`)) * 1000, 2 ) END AS cpm \",\n" +
             "    \"comment\": \"平均千次展现费用\"\n" +
             "  },\n" +
             "  \"clickMaterial\": {\n" +
@@ -28,7 +28,7 @@ public class AccountReportConstants {
             "    \"comment\": \"点击数\"\n" +
             "  },\n" +
             "  \"ctr\": {\n" +
-            "    \"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 \",\n" +
+            "    \"filed\": \"CASE WHEN sum(t1.`show`) != 0 THEN concat(CAST(round( sum(t1.click) /sum(t1.`show`)*100,2) AS CHAR),'%') ELSE '0%' end as ctr \",\n" +
             "    \"comment\": \"点击率\"\n" +
             "  },\n" +
             "  \"cpc\": {\n" +
@@ -154,11 +154,11 @@ public class AccountReportConstants {
             "}";
     public static final String KUAISHOU_FILED_MAPPING_JSON = "{\n" +
             "  \"cost\": {\n" +
-            "    \"filed\": \"IFNULL(sum(charge),0) as cost \",\n" +
+            "    \"filed\": \"IFNULL(sum(charge),3) as cost \",\n" +
             "    \"comment\": \"消耗\"\n" +
             "  },\n" +
             "  \"photoShow\": {\n" +
-            "    \"filed\": \"IFNULL(sum(show),0) as photoShow \",\n" +
+            "    \"filed\": \"IFNULL(sum(`show`),0) as photoShow \",\n" +
             "    \"comment\": \"封面曝光数\"\n" +
             "  },\n" +
             "  \"photoClick\": {\n" +
@@ -174,23 +174,23 @@ public class AccountReportConstants {
             "    \"comment\": \"行为数\"\n" +
             "  },\n" +
             "  \"clickRate\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(show) != 0    THEN CONCAT( CAST(ROUND((sum(photo_click) / sum(show)) * 100,2) AS CHAR) ,'%') else '0%' END AS clickRate \",\n" +
+            "    \"filed\": \"CASE WHEN sum(`show`) != 0  THEN ROUND(sum(photo_click)/sum(`show`),4)  else 0 END AS clickRate \",\n" +
             "    \"comment\": \"封面点击率\"\n" +
             "  },\n" +
             "  \"bClickRate\": {\n" +
-            "    \"filed\": \"CASE WHEN  sum(aclick) != 0 THEN CONCAT( CAST(ROUND((sum(bclick) / sum(aclick)) * 100,2) AS CHAR) ,'%') ELSE '0%' END AS bClickRate \",\n" +
+            "    \"filed\": \"CASE WHEN  sum(aclick) != 0 THEN ROUND(sum(bclick)/sum(aclick),4) ELSE 0 END AS bClickRate \",\n" +
             "    \"comment\": \"行为率\"\n" +
             "  },\n" +
             "  \"cpm\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / sum(show) IS NULL THEN 0 ELSE ROUND((sum(charge) / sum(show)) * 1000, 2 ) END AS cpm \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge)/sum(`show`) IS NULL THEN 0 ELSE ROUND(sum(charge)/sum(`show`)*1000, 3 ) END AS cpm \",\n" +
             "    \"comment\": \"平均千次封面曝光花费\"\n" +
             "  },\n" +
             "  \"cpc\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / sum(photo_click) IS NULL THEN 0 ELSE ROUND((sum(charge) / sum(photo_click)), 2) END AS cpc \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge)/sum(photo_click) IS NULL THEN 0 ELSE ROUND((sum(charge) / sum(photo_click)), 3) END AS cpc \",\n" +
             "    \"comment\": \"平均封面点击单价\"\n" +
             "  },\n" +
             "  \"cpb\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / sum(bclick) IS NULL THEN 0 ELSE ROUND((sum(charge) / sum(bclick)), 2) END AS cpb \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge) / sum(bclick) IS NULL THEN 0 ELSE ROUND((sum(charge) / sum(bclick)), 3) END AS cpb \",\n" +
             "    \"comment\": \"平均行为单价\"\n" +
             "  },\n" +
             "  \"downloadStart\": {\n" +
@@ -198,11 +198,11 @@ public class AccountReportConstants {
             "    \"comment\": \"安卓开始下载数\"\n" +
             "  },\n" +
             "  \"downloadStartCost\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / (download_started) IS NULL THEN 0 ELSE sum(charge) / sum(download_started) end AS downloadStartCost \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge) / (download_started) IS NULL THEN 0 ELSE round(sum(charge)/sum(download_started),3) end AS downloadStartCost \",\n" +
             "    \"comment\": \"安卓开始下载单价\"\n" +
             "  },\n" +
             "  \"downloadStartRate\": {\n" +
-            "    \"filed\": \"CASE WHEN  sum(bclick) != 0 THEN concat(CAST(round(sum(download_started) / sum(bclick)*100,2) AS CHAR) ,'%') else '0%' end AS downloadStartRate\",\n" +
+            "    \"filed\": \"CASE WHEN  sum(bclick) != 0 THEN round(sum(download_started)/sum(bclick),4) else 0 end AS downloadStartRate\",\n" +
             "    \"comment\": \"安卓开始下载率\"\n" +
             "  },\n" +
             "  \"downloadFinish\": {\n" +
@@ -210,11 +210,11 @@ public class AccountReportConstants {
             "    \"comment\": \"安卓下载完成数\"\n" +
             "  },\n" +
             "  \"downloadFinishCost\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / sum(download_completed) IS NULL THEN 0 ELSE  sum(charge) / sum(download_completed) end AS downloadFinishCost \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge) / sum(download_completed) IS NULL THEN 0 ELSE  round(sum(charge)/sum(download_completed),3) end AS downloadFinishCost \",\n" +
             "    \"comment\": \"安卓下载完成单价\"\n" +
             "  },\n" +
             "  \"downloadFinishRate\": {\n" +
-            "    \"filed\": \"CASE WHEN  sum(download_started) != 0 then  concat(CAST(round(sum(download_completed) / sum(download_started)*100,2) AS CHAR) ,'%') else '0%' end AS downloadFinishRate  \",\n" +
+            "    \"filed\": \"CASE WHEN  sum(download_started) != 0 then  round(sum(download_completed)/sum(download_started),4) else 0 end AS downloadFinishRate  \",\n" +
             "    \"comment\": \"安卓下载完成率\"\n" +
             "  },\n" +
             "  \"active\": {\n" +
@@ -222,7 +222,7 @@ public class AccountReportConstants {
             "    \"comment\": \"激活数\"\n" +
             "  },\n" +
             "  \"activeCost\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / sum(activation) IS NULL THEN 0 ELSE sum(charge) / sum(activation) end AS activeCost \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge) / sum(activation) IS NULL THEN 0 ELSE round(sum(charge)/sum(activation),3) end AS activeCost \",\n" +
             "    \"comment\": \"激活单价\"\n" +
             "  },\n" +
             "  \"firstDayPay\": {\n" +
@@ -234,11 +234,11 @@ public class AccountReportConstants {
             "    \"comment\": \"首日付费金额\"\n" +
             "  },\n" +
             "  \"firstDayPayCost\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / sum(event_pay_first_day) IS NULL THEN 0 ELSE sum(charge) / sum(event_pay_first_day) end AS firstDayPayCost \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge) / sum(event_pay_first_day) IS NULL THEN 0 ELSE round(sum(charge)/sum(event_pay_first_day),3) end AS firstDayPayCost \",\n" +
             "    \"comment\": \"首日付费成本\"\n" +
             "  },\n" +
             "  \"firstDayPayROI\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(event_pay_purchase_amount_first_day) / sum(charge) IS NULL THEN '0%' ELSE concat(CAST(round(sum(event_pay_purchase_amount_first_day) / sum(charge)*100,2) AS CHAR) ,'%') end AS firstDayPayROI \",\n" +
+            "    \"filed\": \"CASE WHEN sum(event_pay_purchase_amount_first_day) / sum(charge) IS NULL THEN 0 ELSE round(sum(event_pay_purchase_amount_first_day)/sum(charge)*100,2) end AS firstDayPayROI \",\n" +
             "    \"comment\": \"首日ROI\"\n" +
             "  },\n" +
             "  \"eventPay\": {\n" +
@@ -250,11 +250,11 @@ public class AccountReportConstants {
             "    \"comment\": \"付费金额\"\n" +
             "  },\n" +
             "  \"eventPayCost\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / sum(event_pay) IS NULL THEN 0 ELSE sum(charge) / sum(event_pay) end AS eventPayCost \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge)/sum(event_pay) IS NULL THEN 0 ELSE round(sum(charge)/sum(event_pay),3) end AS eventPayCost \",\n" +
             "    \"comment\": \"付费次数成本\"\n" +
             "  },\n" +
             "  \"ROI\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(event_pay_purchase_amount) / sum(charge) IS NULL THEN '0%' ELSE concat(CAST(round(sum(event_pay_purchase_amount) / sum(charge)*100,2) AS CHAR) ,'%') end AS ROI \",\n" +
+            "    \"filed\": \"CASE WHEN sum(event_pay_purchase_amount)/sum(charge) IS NULL THEN 0 ELSE round(sum(event_pay_purchase_amount)/sum(charge)*100,2) end AS ROI \",\n" +
             "    \"comment\": \"ROI\"\n" +
             "  },\n" +
             "  \"register\": {\n" +
@@ -266,7 +266,7 @@ public class AccountReportConstants {
             "    \"comment\": \"注册成本\"\n" +
             "  },\n" +
             "  \"activeRegisterRate\": {\n" +
-            "    \"filed\": \"CASE WHEN  sum(activation) !=0  THEN concat(CAST(round(sum(event_register) / sum(activation)*100,2) AS CHAR) ,'%') else '0%' end as activeRegisterRate \",\n" +
+            "    \"filed\": \"CASE WHEN  sum(activation) !=0  THEN round(sum(event_register)/sum(activation),4) else 0 end as activeRegisterRate \",\n" +
             "    \"comment\": \"注册率\"\n" +
             "  },\n" +
             "  \"eventJinJianApp\": {\n" +
@@ -286,7 +286,7 @@ public class AccountReportConstants {
             "    \"comment\": \"授信成本\"\n" +
             "  },\n" +
             "  \"eventCreditGrantAppRate\": {\n" +
-            "    \"filed\": \"CASE WHEN  sum(event_jin_jian_app) !=0 THEN concat(CAST(round(sum(event_credit_grant_app) / sum(event_jin_jian_app)*100,2) AS CHAR) ,'%') ELSE '0' end as eventCreditGrantAppRate\",\n" +
+            "    \"filed\": \"CASE WHEN  sum(event_jin_jian_app) !=0 THEN round(sum(event_credit_grant_app)/sum(event_jin_jian_app),4) ELSE 0 end as eventCreditGrantAppRate\",\n" +
             "    \"comment\": \"授信率\"\n" +
             "  },\n" +
             "  \"formCount\": {\n" +
@@ -294,11 +294,11 @@ public class AccountReportConstants {
             "    \"comment\": \"表单提交数\"\n" +
             "  },\n" +
             "  \"formCountRate\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(activation) != 0  THEN  concat(CAST(round(sum(form_count) / sum(activation)*100,2) AS CHAR) ,'%') else '0%' end as formCountRate \",\n" +
+            "    \"filed\": \"CASE WHEN sum(activation) != 0  THEN  round(sum(form_count)/sum(activation),4) else 0 end as formCountRate \",\n" +
             "    \"comment\": \"表单提交率\"\n" +
             "  },\n" +
             "  \"formCountCost\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / sum(form_count) IS NULL THEN 0 ELSE round(sum(charge)/sum(form_count),3) end as formCountCost \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge)/sum(form_count) IS NULL THEN 0 ELSE round(sum(charge)/sum(form_count),3) end as formCountCost \",\n" +
             "    \"comment\": \"表单提交成本\"\n" +
             "  },\n" +
             "  \"nextDayOpen\": {\n" +
@@ -306,11 +306,11 @@ public class AccountReportConstants {
             "    \"comment\": \"次留数\"\n" +
             "  },\n" +
             "  \"nextDayOpenCost\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / sum(event_next_day_stay) IS NULL THEN 0 ELSE round(sum(charge)/sum(event_next_day_stay),3) end as nextDayOpenCost \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge)/sum(event_next_day_stay) IS NULL THEN 0 ELSE round(sum(charge)/sum(event_next_day_stay),3) end as nextDayOpenCost \",\n" +
             "    \"comment\": \"次留成本\"\n" +
             "  },\n" +
             "  \"nextDayOpenRate\": {\n" +
-            "    \"filed\": \"CASE WHEN  sum(activation) != 0 THEN  concat(CAST(round(sum(event_next_day_stay) / sum(activation)*100,2) AS CHAR) ,'%') ELSE '0%' end as nextDayOpenRate\",\n" +
+            "    \"filed\": \"CASE WHEN  sum(activation) != 0 THEN  round(sum(event_next_day_stay)/sum(activation),4) ELSE 0 end as nextDayOpenRate\",\n" +
             "    \"comment\": \"次留率\"\n" +
             "  },\n" +
             "  \"eventJinJianLandingPage\": {\n" +
@@ -318,7 +318,7 @@ public class AccountReportConstants {
             "    \"comment\": \"落地页完件数\"\n" +
             "  },\n" +
             "  \"eventJinJianLandingPageCost\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / sum(event_jin_jian_landing_page) IS NULL THEN 0 ELSE round(sum(charge)/sum(event_jin_jian_landing_page),3) end as eventJinJianLandingPageCost \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge)/sum(event_jin_jian_landing_page) IS NULL THEN 0 ELSE round(sum(charge)/sum(event_jin_jian_landing_page),3) end as eventJinJianLandingPageCost \",\n" +
             "    \"comment\": \"落地页完件成本\"\n" +
             "  },\n" +
             "  \"eventCreditGrantLandingPage\": {\n" +
@@ -330,7 +330,7 @@ public class AccountReportConstants {
             "    \"comment\": \"落地页授信成本\"\n" +
             "  },\n" +
             "  \"eventCreditGrantLandingPageRate\": {\n" +
-            "    \"filed\": \"CASE WHEN  sum(event_jin_jian_landing_page)  != 0 THEN  concat( CAST(round(sum(event_credit_grant_landing_page) / sum(event_jin_jian_landing_page)*100,2) AS CHAR),'%') ELSE '0%' end as eventCreditGrantLandingPageRate \",\n" +
+            "    \"filed\": \"CASE WHEN  sum(event_jin_jian_landing_page)  != 0 THEN  round(sum(event_credit_grant_landing_page)/sum(event_jin_jian_landing_page),2) ELSE 0 end as eventCreditGrantLandingPageRate \",\n" +
             "    \"comment\": \"落地页授信率\"\n" +
             "  },\n" +
             "  \"submit\": {\n" +
@@ -338,19 +338,19 @@ public class AccountReportConstants {
             "    \"comment\": \"按钮点击数\"\n" +
             "  },\n" +
             "  \"submitCost\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / sum(submit) IS NULL THEN 0 ELSE round(sum(charge)/sum(submit),3) end as submitCost \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge)/sum(submit) IS NULL THEN 0 ELSE round(sum(charge)/sum(submit),3) end as submitCost \",\n" +
             "    \"comment\": \"按钮点击成本\"\n" +
             "  },\n" +
             "  \"submitRate\": {\n" +
-            "    \"filed\": \"CASE WHEN  sum(bclick) != 0 THEN concat(CAST(round(sum(submit) / sum(bclick)*100,2) AS CHAR) ,'%') else '0%' end as submitRate \",\n" +
+            "    \"filed\": \"CASE WHEN  sum(bclick) != 0 THEN round(sum(submit)/sum(bclick),4) else 0 end as submitRate \",\n" +
             "    \"comment\": \"按钮点击率\"\n" +
             "  },\n" +
             "  \"play3sRate\": {\n" +
-            "    \"filed\": \"(CASE WHEN  sum(aclick) != 0 THEN round( sum(play_3s_ratio * aclick) / sum(aclick) * 100,2) ELSE 0 END )AS play3sRate \",\n" +
+            "    \"filed\": \"(CASE WHEN  sum(aclick) != 0 THEN round(sum(play_3s_ratio*aclick)/sum(aclick),4) ELSE 0 END )AS play3sRate \",\n" +
             "    \"comment\": \"3s播放率\"\n" +
             "  },\n" +
             "  \"activeRate\": {\n" +
-            "    \"filed\": \"CASE WHEN  sum(download_completed) != 0 THEN concat(CAST(round(sum(activation) / sum(download_completed)*100,2) AS CHAR) ,'%') else '0%' end as activeRate \",\n" +
+            "    \"filed\": \"CASE WHEN  sum(download_completed) != 0 THEN round(sum(activation)/sum(download_completed),4) else 0 end as activeRate \",\n" +
             "    \"comment\": \"下载完成激活率\"\n" +
             "  }\n" +
             "}";
@@ -368,7 +368,7 @@ public class AccountReportConstants {
             "    \"comment\": \"消耗\"\n" +
             "  },\n" +
             "  \"photoShow\": {\n" +
-            "    \"filed\": \"IFNULL(sum(show),0) as photoShow \",\n" +
+            "    \"filed\": \"IFNULL(sum(`show`),0) as photoShow \",\n" +
             "    \"comment\": \"封面曝光数\"\n" +
             "  },\n" +
             "  \"photoClick\": {\n" +
@@ -384,23 +384,23 @@ public class AccountReportConstants {
             "    \"comment\": \"行为数\"\n" +
             "  },\n" +
             "  \"clickRate\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(show) != 0    THEN CONCAT( CAST(ROUND((sum(photo_click) / sum(show)) * 100,2) AS CHAR) ,'%') else '0%' END AS clickRate \",\n" +
+            "    \"filed\": \"CASE WHEN sum(`show`) != 0    THEN ROUND(sum(photo_click) / sum(`show`),4) else 0 END AS clickRate \",\n" +
             "    \"comment\": \"封面点击率\"\n" +
             "  },\n" +
             "  \"bClickRate\": {\n" +
-            "    \"filed\": \"CASE WHEN  sum(aclick) != 0 THEN CONCAT( CAST(ROUND((sum(bclick) / sum(aclick)) * 100,2) AS CHAR) ,'%') ELSE '0%' END AS bClickRate \",\n" +
+            "    \"filed\": \"CASE WHEN  sum(aclick) != 0 THEN ROUND(sum(bclick) / sum(aclick),4) ELSE 0 END AS bClickRate \",\n" +
             "    \"comment\": \"行为率\"\n" +
             "  },\n" +
             "  \"cpm\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / sum(show) IS NULL THEN 0 ELSE ROUND((sum(charge) / sum(show)) * 1000, 2 ) END AS cpm \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge)/sum(`show`) IS NULL THEN 0 ELSE ROUND(sum(charge)/sum(`show`)*1000,3) END AS cpm \",\n" +
             "    \"comment\": \"平均千次封面曝光花费\"\n" +
             "  },\n" +
             "  \"cpc\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / sum(photo_click) IS NULL THEN 0 ELSE ROUND((sum(charge) / sum(photo_click)), 2) END AS cpc \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge) / sum(photo_click) IS NULL THEN 0 ELSE ROUND(sum(charge)/sum(photo_click), 3) END AS cpc \",\n" +
             "    \"comment\": \"平均封面点击单价\"\n" +
             "  },\n" +
             "  \"cpb\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / sum(bclick) IS NULL THEN 0 ELSE ROUND((sum(charge) / sum(bclick)), 2) END AS cpb \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge) / sum(bclick) IS NULL THEN 0 ELSE ROUND(sum(charge)/sum(bclick), 3) END AS cpb \",\n" +
             "    \"comment\": \"平均行为单价\"\n" +
             "  },\n" +
             "  \"downloadStart\": {\n" +
@@ -408,11 +408,11 @@ public class AccountReportConstants {
             "    \"comment\": \"安卓开始下载数\"\n" +
             "  },\n" +
             "  \"downloadStartCost\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / (download_started) IS NULL THEN 0 ELSE sum(charge) / sum(download_started) end AS downloadStartCost \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge) / (download_started) IS NULL THEN 0 ELSE round(sum(charge)/sum(download_started),3) end AS downloadStartCost \",\n" +
             "    \"comment\": \"安卓开始下载单价\"\n" +
             "  },\n" +
             "  \"downloadStartRate\": {\n" +
-            "    \"filed\": \"CASE WHEN  sum(bclick) != 0 THEN concat(CAST(round(sum(download_started) / sum(bclick)*100,2) AS CHAR) ,'%') else '0%' end AS downloadStartRate\",\n" +
+            "    \"filed\": \"CASE WHEN  sum(bclick) != 0 THEN round(sum(download_started) / sum(bclick),4) else 0 end AS downloadStartRate\",\n" +
             "    \"comment\": \"安卓开始下载率\"\n" +
             "  },\n" +
             "  \"downloadFinish\": {\n" +
@@ -420,11 +420,11 @@ public class AccountReportConstants {
             "    \"comment\": \"安卓下载完成数\"\n" +
             "  },\n" +
             "  \"downloadFinishCost\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / sum(download_completed) IS NULL THEN 0 ELSE  sum(charge) / sum(download_completed) end AS downloadFinishCost \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge) / sum(download_completed) IS NULL THEN 0 ELSE  round(sum(charge)/sum(download_completed),3) end AS downloadFinishCost \",\n" +
             "    \"comment\": \"安卓下载完成单价\"\n" +
             "  },\n" +
             "  \"downloadFinishRate\": {\n" +
-            "    \"filed\": \"CASE WHEN  sum(download_started) != 0 then  concat(CAST(round(sum(download_completed) / sum(download_started)*100,2) AS CHAR) ,'%') else '0%' end AS downloadFinishRate  \",\n" +
+            "    \"filed\": \"CASE WHEN  sum(download_started) != 0 then round(sum(download_completed)/sum(download_started),4) else 0 end AS downloadFinishRate  \",\n" +
             "    \"comment\": \"安卓下载完成率\"\n" +
             "  },\n" +
             "  \"active\": {\n" +
@@ -432,7 +432,7 @@ public class AccountReportConstants {
             "    \"comment\": \"激活数\"\n" +
             "  },\n" +
             "  \"activeCost\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / sum(activation) IS NULL THEN 0 ELSE sum(charge) / sum(activation) end AS activeCost \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge) / sum(activation) IS NULL THEN 0 ELSE round(sum(charge)/sum(activation),3) end AS activeCost \",\n" +
             "    \"comment\": \"激活单价\"\n" +
             "  },\n" +
             "  \"firstDayPay\": {\n" +
@@ -440,11 +440,11 @@ public class AccountReportConstants {
             "    \"comment\": \"首日付费次数\"\n" +
             "  },\n" +
             "  \"firstDayPayAmount\": {\n" +
-            "    \"filed\": \"IFNULL(sum(event_pay_purchase_amount_first_day),0) as firstDayPayAmount  \",\n" +
+            "    \"filed\": \"IFNULL(sum(event_pay_purchase_amount_first_day),3) as firstDayPayAmount  \",\n" +
             "    \"comment\": \"首日付费金额\"\n" +
             "  },\n" +
             "  \"firstDayPayCost\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / sum(event_pay_first_day) IS NULL THEN 0 ELSE sum(charge) / sum(event_pay_first_day) end AS firstDayPayCost \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge)/sum(event_pay_first_day) IS NULL THEN 0 ELSE round(sum(charge)/sum(event_pay_first_day),3) end AS firstDayPayCost \",\n" +
             "    \"comment\": \"首日付费成本\"\n" +
             "  },\n" +
             "  \"firstDayPayROI\": {\n" +
@@ -460,7 +460,7 @@ public class AccountReportConstants {
             "    \"comment\": \"付费金额\"\n" +
             "  },\n" +
             "  \"eventPayCost\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / sum(event_pay) IS NULL THEN 0 ELSE sum(charge) / sum(event_pay) end AS eventPayCost \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge) / sum(event_pay) IS NULL THEN 0 ELSE round(sum(charge)/sum(event_pay),3) end AS eventPayCost \",\n" +
             "    \"comment\": \"付费次数成本\"\n" +
             "  },\n" +
             "  \"ROI\": {\n" +
@@ -476,7 +476,7 @@ public class AccountReportConstants {
             "    \"comment\": \"注册成本\"\n" +
             "  },\n" +
             "  \"activeRegisterRate\": {\n" +
-            "    \"filed\": \"CASE WHEN  sum(activation) !=0  THEN concat(CAST(round(sum(event_register) / sum(activation)*100,2) AS CHAR) ,'%') else '0%' end as activeRegisterRate \",\n" +
+            "    \"filed\": \"CASE WHEN  sum(activation) !=0  THEN round(sum(event_register)/sum(activation),4) else 0 end as activeRegisterRate \",\n" +
             "    \"comment\": \"注册率\"\n" +
             "  },\n" +
             "  \"eventJinJianApp\": {\n" +
@@ -496,7 +496,7 @@ public class AccountReportConstants {
             "    \"comment\": \"授信成本\"\n" +
             "  },\n" +
             "  \"eventCreditGrantAppRate\": {\n" +
-            "    \"filed\": \"CASE WHEN  sum(event_jin_jian_app) !=0 THEN concat(CAST(round(sum(event_credit_grant_app) / sum(event_jin_jian_app)*100,2) AS CHAR) ,'%') ELSE '0' end as eventCreditGrantAppRate\",\n" +
+            "    \"filed\": \"CASE WHEN  sum(event_jin_jian_app) !=0 THEN round(sum(event_credit_grant_app)/sum(event_jin_jian_app),4) ELSE 0 end as eventCreditGrantAppRate\",\n" +
             "    \"comment\": \"授信率\"\n" +
             "  },\n" +
             "  \"formCount\": {\n" +
@@ -504,7 +504,7 @@ public class AccountReportConstants {
             "    \"comment\": \"表单提交数\"\n" +
             "  },\n" +
             "  \"formCountRate\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(activation) != 0  THEN  concat(CAST(round(sum(form_count) / sum(activation)*100,2) AS CHAR) ,'%') else '0%' end as formCountRate \",\n" +
+            "    \"filed\": \"CASE WHEN sum(activation) != 0  THEN round(sum(form_count)/sum(activation),4) else 0 end as formCountRate \",\n" +
             "    \"comment\": \"表单提交率\"\n" +
             "  },\n" +
             "  \"formCountCost\": {\n" +
@@ -520,7 +520,7 @@ public class AccountReportConstants {
             "    \"comment\": \"次留成本\"\n" +
             "  },\n" +
             "  \"nextDayOpenRate\": {\n" +
-            "    \"filed\": \"CASE WHEN  sum(activation) != 0 THEN  concat(CAST(round(sum(event_next_day_stay) / sum(activation)*100,2) AS CHAR) ,'%') ELSE '0%' end as nextDayOpenRate\",\n" +
+            "    \"filed\": \"CASE WHEN  sum(activation) != 0 THEN round(sum(event_next_day_stay)/sum(activation),4) ELSE 0 end as nextDayOpenRate\",\n" +
             "    \"comment\": \"次留率\"\n" +
             "  },\n" +
             "  \"eventJinJianLandingPage\": {\n" +
@@ -540,7 +540,7 @@ public class AccountReportConstants {
             "    \"comment\": \"落地页授信成本\"\n" +
             "  },\n" +
             "  \"eventCreditGrantLandingPageRate\": {\n" +
-            "    \"filed\": \"CASE WHEN  sum(event_jin_jian_landing_page)  != 0 THEN  concat( CAST(round(sum(event_credit_grant_landing_page) / sum(event_jin_jian_landing_page)*100,2) AS CHAR),'%') ELSE '0%' end as eventCreditGrantLandingPageRate \",\n" +
+            "    \"filed\": \"CASE WHEN sum(event_jin_jian_landing_page)!=0 THEN round(sum(event_credit_grant_landing_page)/sum(event_jin_jian_landing_page),4) ELSE 0 end as eventCreditGrantLandingPageRate \",\n" +
             "    \"comment\": \"落地页授信率\"\n" +
             "  },\n" +
             "  \"submit\": {\n" +
@@ -548,23 +548,23 @@ public class AccountReportConstants {
             "    \"comment\": \"按钮点击数\"\n" +
             "  },\n" +
             "  \"submitCost\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge) / sum(submit) IS NULL THEN 0 ELSE round(sum(charge)/sum(submit),3) end as submitCost \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge)/sum(submit) IS NULL THEN 0 ELSE round(sum(charge)/sum(submit),3) end as submitCost \",\n" +
             "    \"comment\": \"按钮点击成本\"\n" +
             "  },\n" +
             "  \"submitRate\": {\n" +
-            "    \"filed\": \"CASE WHEN  sum(bclick) != 0 THEN concat(CAST(round(sum(submit) / sum(bclick)*100,2) AS CHAR) ,'%') else '0%' end as submitRate \",\n" +
+            "    \"filed\": \"CASE WHEN  sum(bclick) != 0 THEN round(sum(submit)/sum(bclick),4) else 0 end as submitRate \",\n" +
             "    \"comment\": \"按钮点击率\"\n" +
             "  },\n" +
             "  \"activeRate\": {\n" +
-            "    \"filed\": \"CASE WHEN  sum(download_completed) != 0 THEN concat(CAST(round(sum(activation) / sum(download_completed)*100,2) AS CHAR) ,'%') else '0%' end as activeRate \",\n" +
+            "    \"filed\": \"CASE WHEN  sum(download_completed) != 0 THEN round(sum(activation)/sum(download_completed),4) else 0 end as activeRate \",\n" +
             "    \"comment\": \"下载完成激活率\"\n" +
             "  },\n" +
             "  \"play3sCount\": {\n" +
-            "    \"filed\": \"sum(play_3s_count) as play3sCount\",\n" +
+            "    \"filed\": \"sum(play_3s_ratio*aclick) as play3sCount\",\n" +
             "    \"comment\": \"3s播放数\"\n" +
             "  },\n" +
             "  \"play3sRate\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(aclick) != 0 THEN CONCAT(CAST(ROUND( sum(play_3s_count) / sum(aclick),2 )  * 100 AS CHAR),'%') ELSE '-' END AS play3sRate\",\n" +
+            "    \"filed\": \"CASE WHEN sum(aclick) != 0 THEN ROUND(sum(play_3s_count)/sum(aclick),4 ) ELSE 0 END AS play3sRate\",\n" +
             "    \"comment\": \"3s播放率\"\n" +
             "  }\n" +
             "}";
@@ -760,16 +760,13 @@ public class AccountReportConstants {
             "  }\n" +
             "}";
 
-    public static void main(String[] args) {
-        System.out.println(BYTEDANCE_VIDEO_REPORT_MAPPING_JSON);
-    }
     public static final String BYTEDANCE_VIDEO_REPORT_MAPPING_JSON = "{\n" +
             "  \"cost\": {\n" +
             "    \"filed\": \"IFNULL(sum(t1.cost),0) as cost \",\n" +
             "    \"comment\": \"消耗\"\n" +
             "  },\n" +
             "  \"cpm\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(t1.cost) / sum(t1.material_show) IS NULL THEN 0 ELSE ROUND((sum(t1.cost) / sum(t1.material_show)) * 1000, 2 ) END AS cpm \",\n" +
+            "    \"filed\": \"CASE WHEN sum(t1.cost) / sum(t1.material_show) IS NULL THEN 0 ELSE ROUND(sum(t1.cost)/sum(t1.material_show)*1000,2) END AS cpm \",\n" +
             "    \"comment\": \"平均千次展现费用\"\n" +
             "  },\n" +
             "  \"clickMaterial\": {\n" +

+ 2 - 1
jeecg-boot-report/src/main/java/cn/com/ctop/common/mapper/UserAllocationMapper.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -17,5 +18,5 @@ import java.util.List;
 public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
     IPage<UserAllocation> queryListWithPermission(Page<UserAllocation> page, String sql);
 
-    List<JSONObject> getAccountListByProjectList(List list);
+    List<JSONObject> getAccountListByProjectList(@Param(value = "list")List list, @Param(value = "designUserId")String designUserId);
 }

+ 2 - 2
jeecg-boot-report/src/main/java/cn/com/ctop/common/mapper/xml/ProjectMapper.xml

@@ -3,9 +3,9 @@
 <mapper namespace="cn.com.ctop.common.mapper.ProjectMapper">
 
     <select id="getListByParams" resultType="cn.com.ctop.common.entity.Project">
-        select * from ctop_project where 1=1
+        select * from `jeecg-boot`.ctop_project where 1=1
         and media_id in
-        <foreach collection="mediaIds" item="item" separator=","
+        <foreach collection="mediaList" item="item" separator=","
                  open="(" close=")">
             #{item}
         </foreach>

+ 42 - 36
jeecg-boot-report/src/main/java/cn/com/ctop/common/mapper/xml/ProjectMemberMapper.xml

@@ -5,15 +5,15 @@
     <select id="selectProjectsByUserId" resultType="java.lang.Long">
         select
         DISTINCT(project_id)
-         from ctop_project_member
+         from `jeecg-boot`.ctop_project_member
         where user_id = #{userId}
     </select>
 
     <select id="selectProductsByUserId" resultType="java.lang.Long">
-        select  DISTINCT(product_id) from ctop_project where product_id is not NULL  and id in
+        select  DISTINCT(product_id) from `jeecg-boot`.ctop_project where product_id is not NULL  and id in
          (select
               DISTINCT(project_id)
-          from ctop_project_member where user_id = #{userId})
+          from `jeecg-boot`.ctop_project_member where user_id = #{userId})
     </select>
 
     <!-- 设计师展示所有自己的角色下制作的视频 -->
@@ -23,7 +23,7 @@
         t1.project_name as projectName,
         t1.advertiser_id as advertiserId,
         (
-        select name from ctop_advertiser where id = t1.advertiser_id
+        select name from `jeecg-boot`.ctop_advertiser where id = t1.advertiser_id
         )
         as advertiserName,
         t1.media_id as mediaId,
@@ -31,7 +31,7 @@
         t1.product_id as productId,
         t1.responsible_name as responsibleName
         from
-        ctop_project t1
+        `jeecg-boot`.ctop_project t1
         where
         media_id in
         <foreach collection="mediaIds" item="item" separator=","
@@ -51,7 +51,7 @@
         b.product_id as productId,
         b.media_id as mediaId
         from
-        ctop_project_member a
+        `jeecg-boot`.ctop_project_member a
         left join ctop_project b on a.project_id = b.id
         where
         b.company_id = #{companyId}
@@ -72,7 +72,7 @@
         b.media_id as mediaId,
         b.product_id as productId
         from
-        ctop_project_member a
+        `jeecg-boot`.ctop_project_member a
         left join ctop_project b on a.project_id = b.id
         where a.user_id = #{userId}
         and b.media_id in
@@ -91,7 +91,7 @@
         b.media_id as mediaId,
         b.product_id as productId
         from
-        ctop_project_member a
+        `jeecg-boot`.ctop_project_member a
         left join ctop_project b on a.project_id = b.id
         where b.product_id = #{productId}
         <if test="userId !=null and userId!=''">
@@ -116,8 +116,8 @@
         b.product_id as productId,
         b.media_id as mediaId
         from
-        ctop_user_allocation a
-        left join ctop_project b on a.project_id = b.id
+        `jeecg-boot`.ctop_user_allocation a
+        left join hcst_system.ctop_project b on a.project_id = b.id
         where a.user_id = #{userId}
         and b.media_id in
         <foreach collection="mediaIds" item="item" separator=","
@@ -130,7 +130,7 @@
         select
         role_code
         from
-        sys_user_role a
+            `jeecg-boot`.sys_user_role a
         left join sys_role b on a.role_id = b.id
         where a.user_id = #{userId}
     </select>
@@ -139,7 +139,7 @@
             select
             company_id
         from
-        user_company
+            `jeecg-boot`.user_company
         where user_id = #{userId}
     </select>
 
@@ -152,19 +152,19 @@
         SELECT
         NAME
         FROM
-        ctop_advertiser
+        `jeecg-boot`.ctop_advertiser
         WHERE
         id = t1.advertiser_id
         ) AS 'advertiserName',
         t1.media_id as 'mediaId'
         FROM
-        ctop_project t1
+        `jeecg-boot`.ctop_project t1
         WHERE
         t1.id IN (
         SELECT
         project_id
         FROM
-        ctop_project_member
+        `jeecg-boot`.ctop_project_member
         where user_id = #{userId}
         GROUP BY
         project_id
@@ -187,7 +187,7 @@
         a.sale_id as saleId,
         b.realname as saleName
         from
-        ctop_project a
+        `jeecg-boot`.ctop_project a
         left join sys_user b on a.sale_id = b.id
         where a.sale_id = #{userId}
         and a.media_id in
@@ -199,7 +199,7 @@
 
     <select id="getProjectByMap" resultType="java.lang.Long">
         select project_id
-        from ctop_project_member
+        from `jeecg-boot`.ctop_project_member
         where user_id = #{userId}
         group by project_id
     </select>
@@ -207,7 +207,8 @@
         select
             project.*
         from
-            ctop_project_member member left join ctop_project project on project.id = member.project_id
+            `jeecg-boot`.ctop_project_member member
+            left join `jeecg-boot`.ctop_project project on project.id = member.project_id
         where
             member.user_id = #{userId}
     </select>
@@ -216,7 +217,7 @@
         SELECT
         project_id
         FROM
-        ctop_user_allocation
+        `jeecg-boot`.ctop_user_allocation
         WHERE
         account_id IN
         <foreach collection="accountIds" item="item" separator=","
@@ -230,7 +231,7 @@
         (SELECT
         project_id
         FROM
-        ctop_user_allocation
+        `jeecg-boot`.ctop_user_allocation
         WHERE
         account_id IN
         <foreach collection="accountIds" item="item" separator=","
@@ -241,16 +242,16 @@
 
 
     <select id="getProjectByUserIdAndMediaIds" resultType="com.alibaba.fastjson.JSONObject">
-        select
-        t2.id as 'projectId',
-        t2.project_name as 'projectName',
-        t2.product_id as 'productId',
-        t2.product_name as 'productName',
+        select t2.id            as 'projectId',
+        t2.project_name  as 'projectName',
+        t2.product_id    as 'productId',
+        t3.product_name  as 'productName',
         t2.advertiser_id as 'advertiserId',
-        (select name from ctop_advertiser where id = t2.advertiser_id) as 'advertiserName'
-        from ctop_project_member t1
-        left join ctop_project t2
-        on t1.project_id = t2.id
+        t4.`name`        as 'advertiserName'
+        from `jeecg-boot`.ctop_project_member t1
+        left join `jeecg-boot`.ctop_project t2 on t1.project_id = t2.id
+        left join `jeecg-boot`.ctop_product t3 on t3.id = t2.product_id
+        left join `jeecg-boot`.ctop_advertiser t4 on t2.advertiser_id = t4.id
         where 1 = 1
         <if test="userId !=null and userId!=''">
             and t1.user_id = #{userId}
@@ -262,15 +263,20 @@
                 #{item}
             </foreach>
         </if>
-        group by t2.id
-        order by t2.create_time desc
+        group by t2.id,
+        t2.project_name,
+        t2.product_id,
+        t3.product_name,
+        t2.advertiser_id,
+        t4.`name`
+        order by t2.id desc
     </select>
     <select id="getProjectIdsByProductId" resultType="java.lang.Long">
         SELECT
         t1.id
         FROM
-        ctop_project t1
-        LEFT JOIN ctop_project_member t2 ON t1.id = t2.project_id
+        `jeecg-boot`.ctop_project t1
+        LEFT JOIN `jeecg-boot`.ctop_project_member t2 ON t1.id = t2.project_id
         WHERE
         t2.user_id = #{userId}
         <if test="productId != null and productId != ''">
@@ -281,9 +287,9 @@
     </select>
     <select id="getlistByUserId" resultType="cn.com.ctop.common.entity.ProjectMember">
         select cp.id as id, cp.project_name as project_name, cp.media_id as media_id, ca.name as advertiser_name
-        from ctop_project_member cpm
-                 left join ctop_project cp on cpm.project_id = cp.id
-                 left join ctop_advertiser ca on ca.id = cp.advertiser_id
+        from `jeecg-boot`.ctop_project_member cpm
+                 left join `jeecg-boot`.ctop_project cp on cpm.project_id = cp.id
+                 left join `jeecg-boot`.ctop_advertiser ca on ca.id = cp.advertiser_id
         where 1=1
         <if test="userId!=null">
             and cpm.user_id = #{userId}

+ 1 - 1
jeecg-boot-report/src/main/java/cn/com/ctop/common/mapper/xml/SysDepartMapper.xml

@@ -6,7 +6,7 @@
         select
                *
         from
-             sys_depart
+        `jeecg-boot`.sys_depart
         where
               1=1
               <if test="orgType!=null">

+ 5 - 5
jeecg-boot-report/src/main/java/cn/com/ctop/common/mapper/xml/SysRoleMapper.xml

@@ -5,23 +5,23 @@
     <!-- 根据roleCode获取roleId -->
     <select id="getRoleIdByRoleCode" resultType="java.lang.String">
         select id
-        from sys_role
+        from `jeecg-boot`.sys_role
         where role_code = #{roleCode}
     </select>
 
     <!-- 根据userId获取角色code -->
     <select id="getRoleCodeByUserId" resultType="java.lang.String">
         select c.role_code
-        from sys_user a
-                 left join sys_user_role b on a.id = b.user_id
-                 left join sys_role c on b.role_id = c.id
+        from `jeecg-boot`.sys_user a
+                 left join `jeecg-boot`.sys_user_role b on a.id = b.user_id
+                 left join `jeecg-boot`.sys_role c on b.role_id = c.id
         where a.id = #{userId}
     </select>
 
 
     <select id="queryRoleByUserId" resultType="cn.com.ctop.common.entity.SysRole">
         SELECT t2.role_name,t2.role_code
-        FROM sys_user_role t1
+        FROM `jeecg-boot`.sys_user_role t1
                  LEFT JOIN sys_role t2 ON t1.role_id = t2.id
         WHERE t1.user_id = #{userId} LIMIT 1
     </select>

+ 1 - 1
jeecg-boot-report/src/main/java/cn/com/ctop/common/mapper/xml/SysUserMapper.xml

@@ -3,6 +3,6 @@
 <mapper namespace="cn.com.ctop.common.mapper.SysUserMapper">
 
     <select id="selectAllUser" resultType="org.jeecg.common.system.entity.SysUser">
-        select * from sys_user where del_flag = 0 and status = 1
+        select * from `jeecg-boot`.sys_user where del_flag = 0 and status = 1
     </select>
 </mapper>

+ 6 - 5
jeecg-boot-report/src/main/java/cn/com/ctop/common/mapper/xml/UserAllocationMapper.xml

@@ -3,23 +3,24 @@
 <mapper namespace="cn.com.ctop.common.mapper.UserAllocationMapper">
 
     <select id="queryListWithPermission" resultType="cn.com.ctop.common.entity.UserAllocation">
-        select * from user_allocation where 1=1 ${permissionSql}
+        select * from `jeecg-boot`.user_allocation where 1=1 ${permissionSql}
     </select>
     <select id="getAccountListByProjectList" resultType="com.alibaba.fastjson.JSONObject">
         select
         t1.project_id as 'projectId',
         t1.account_id as 'accountId',
-        (select realname from sys_user where id = t1.user_id ) as 'userName',
+        (select realname from `jeecg-boot`.sys_user where id = t1.user_id ) as 'userName',
         t1.auth_name as 'authName',
         t1.account_status as 'accountStatus'
-        from ctop_user_allocation t1
+        from `jeecg-boot`.ctop_user_allocation t1
         where t1.project_id in
         <foreach collection="list" item="item" separator=","
                  open="(" close=")">
             #{item}
         </foreach>
-
-
+        <if test="designUserId!=null">
+            abd t1.user_id = #{designUserId}
+        </if>
         order by t1.create_time desc
     </select>
 </mapper>

+ 1 - 1
jeecg-boot-report/src/main/java/cn/com/ctop/common/service/IUserAllocationService.java

@@ -17,5 +17,5 @@ import java.util.Map;
 public interface IUserAllocationService extends IService<UserAllocation> {
     IPage<UserAllocation> queryListWithPermission(Integer pageSize, Integer pageNo);
 
-    Map<Long, List<JSONObject>> getAccountListByProjectList(List<JSONObject> projectList);
+    Map<Long, List<JSONObject>> getAccountListByProjectList(List<JSONObject> projectList,String designUserId);
 }

+ 1 - 1
jeecg-boot-report/src/main/java/cn/com/ctop/common/service/impl/ProjectMemberServiceImpl.java

@@ -135,7 +135,7 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
             map.put(member.getProjectId(), new ArrayList<>());
         }
 
-        List<JSONObject> jsonList = userAllocationMapper.getAccountListByProjectList(list);
+        List<JSONObject> jsonList = userAllocationMapper.getAccountListByProjectList(list,null);
         for (int i = 0; i < jsonList.size(); i++) {
             JSONObject jsonObject = jsonList.get(i);
             Long projectId = jsonObject.getLong("projectId");

+ 2 - 2
jeecg-boot-report/src/main/java/cn/com/ctop/common/service/impl/UserAllocationServiceImpl.java

@@ -38,7 +38,7 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
     }
 
     @Override
-    public Map<Long, List<JSONObject>> getAccountListByProjectList(List<JSONObject> projectList) {
+    public Map<Long, List<JSONObject>> getAccountListByProjectList(List<JSONObject> projectList,String designUserId) {
         Map<Long, List<JSONObject>> map = new HashMap<>();
         List list = new ArrayList();
         for (int i = 0; i < projectList.size(); i++) {
@@ -48,7 +48,7 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
                 map.put(jsonObject.getLong("projectId"), new ArrayList<>());
             }
         }
-        List<JSONObject> jsonList = userAllocationMapper.getAccountListByProjectList(list);
+        List<JSONObject> jsonList = userAllocationMapper.getAccountListByProjectList(list,designUserId);
         for (int i = 0; i < jsonList.size(); i++) {
             JSONObject jsonObject = jsonList.get(i);
             if (!Check.isNull(jsonObject)) {

+ 10 - 5
jeecg-boot-report/src/main/java/cn/com/ctop/report/controller/KuaishouAccountReportDailyDwController.java

@@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.math.BigDecimal;
+import java.text.ParseException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -41,7 +43,7 @@ public class KuaishouAccountReportDailyDwController {
         resultMap.put("message","获取数据成功");
         resultMap.put("code","0");
         resultMap.put("success",true);
-        resultMap.put("result",dataList);
+        resultMap.put("data",dataList);
         return resultMap;
     }
 
@@ -49,13 +51,13 @@ public class KuaishouAccountReportDailyDwController {
      * 查询账户报表数据
      */
     @PostMapping("/kuaishou/list")
-    public Result<List<JSONObject>> getListReport(@RequestBody JSONObject requestBody) {
+    public Result<List<JSONObject>> getListReport(@RequestBody JSONObject requestBody) throws ParseException {
         Result<List<JSONObject>> result = new Result<>();
         if (requestBody.isEmpty()) {
             log.error("request body is empty");
             result.setSuccess(false);
         }
-        BigDecimal discount = requestBody.getBigDecimal("discount");
+        BigDecimal discount = requestBody.getBigDecimal("disscount");
         JSONArray accounts = requestBody.getJSONArray("accountIds");
         String userId = requestBody.getString("userId");
         if (accounts.isEmpty()) {
@@ -67,7 +69,10 @@ public class KuaishouAccountReportDailyDwController {
         }
         String startDate = requestBody.getString("startDate");
         String endDate = requestBody.getString("endDate");
-        int hour = requestBody.getInteger("hour");
+        Integer hour = requestBody.getInteger("hour");
+        if(null == hour){
+            hour = DateUtils.getNowHour();
+        }
         String target = requestBody.getString("target");
         String order = requestBody.getString("order");
         try {
@@ -93,7 +98,7 @@ public class KuaishouAccountReportDailyDwController {
             resultBody.setSuccess(false);
         }
         String mediaId = requestBody.getString("mediaId");
-        BigDecimal discount = requestBody.getBigDecimal("discount");
+        BigDecimal discount = requestBody.getBigDecimal("disscount");
         JSONArray accounts = requestBody.getJSONArray("accountIds");
         if (accounts.isEmpty()) {
             return resultBody;

+ 13 - 13
jeecg-boot-report/src/main/java/cn/com/ctop/report/controller/KuaishouMaterialReportDailyDwController.java

@@ -8,16 +8,12 @@ import cn.com.ctop.common.utils.Check;
 import cn.com.ctop.common.utils.JsonResourceUtil;
 import cn.com.ctop.common.utils.ResultMapUtils;
 import cn.com.ctop.common.utils.StatusCode;
-import cn.com.ctop.report.entity.AccountAttributionInfo;
-import cn.com.ctop.report.service.AccountAttributionInfoService;
-import cn.com.ctop.report.service.IKuaishouAccountReportDailyDwService;
 import cn.com.ctop.report.service.IKuaishouMaterialVideoReportDailyDwService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.system.entity.SysUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -25,7 +21,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
-import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -53,9 +48,9 @@ public class KuaishouMaterialReportDailyDwController {
     @PostMapping(value = "/getProjectAccountByUserId")
     public Map<String, Object> getProjectAccount(@RequestBody JSONObject params) {
         Map<String, Object> resultMap = new HashMap<>();
-        String userId = params.getString("userId");
+        String getUserId = params.getString("userId");
         String type = params.getString("type");
-        if (null == userId || "".equals(userId.trim()) || null == type || "".equals(type.trim())) {
+        if (null == getUserId || "".equals(getUserId.trim()) || null == type || "".equals(type.trim())) {
             ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_PARAM_ERROR);
             return resultMap;
         }
@@ -68,17 +63,22 @@ public class KuaishouMaterialReportDailyDwController {
             mediaIds.add(3);
         }
         //查询用户角色
+        String userId = getUserId;
         String roleCode = sysRoleMapper.getRoleCodeByUserId(userId);
         //角色为 管理员 || 销售 || 媒介 查询全部
         if ("admin".equals(roleCode) || roleCode.contains("sale") || "meidaManager".equals(roleCode)) {
             userId = null;
         }
+        String operatorId = null;
+        if ("operator".equals(roleCode) || roleCode.contains("operationAssistant")) {
+            operatorId = getUserId;
+        }
         //查询项目信息以及广告主
         List<JSONObject> projectList = projectMemberService.getProjectByUserIdAndMediaIds(userId, mediaIds);
         List<JSONObject> haveList = new ArrayList<>();
         if (!Check.isNull(projectList)) {
             //项目id 查询账户人员信息
-            Map<Long, List<JSONObject>> accountMap = userAllocationService.getAccountListByProjectList(projectList);
+            Map<Long, List<JSONObject>> accountMap = userAllocationService.getAccountListByProjectList(projectList,operatorId);
             for (int i = 0; i < projectList.size(); i++) {
                 JSONObject project = projectList.get(i);
                 if (!Check.isNull(project)) {
@@ -120,8 +120,8 @@ public class KuaishouMaterialReportDailyDwController {
             }
             Map<String, Object> requestMap = new HashMap<>();
             requestMap.put("filed", filedAll);
-            requestMap.put("startDate", startDate);
-            requestMap.put("endDate", endDate);
+            requestMap.put("startDate", Long.parseLong(startDate.replace("-","")));
+            requestMap.put("endDate", Long.parseLong(endDate.replace("-","")));
 
             if (!Check.isNull(requestBody.getJSONArray("accountIds"))) {
                 requestMap.put("accountIds", requestBody.getJSONArray("accountIds"));
@@ -133,8 +133,8 @@ public class KuaishouMaterialReportDailyDwController {
             if (!Check.isNull(requestBody.getString("order"))) {
                 requestMap.put("order", requestBody.getString("order"));
             }
-            if (!Check.isNull(requestBody.getString("channelType"))) {
-                requestMap.put("channelType", requestBody.getString("channelType"));
+            if (!Check.isNull(requestBody.getInteger("channelType"))) {
+                requestMap.put("channelType", requestBody.getInteger("channelType"));
             }
             String roleCode = sysRoleMapper.getRoleCodeByUserId(userId);
             if ("admin".equals(roleCode)) {
@@ -178,7 +178,7 @@ public class KuaishouMaterialReportDailyDwController {
 
 
 
-    @PostMapping("/detail")
+    @PostMapping("/kuaishou/detail")
     public Result<List<JSONObject>> getReportDetail(@RequestBody JSONObject requestBody) {
         Result<List<JSONObject>> result = new Result<>();
         if (requestBody.isEmpty()) {

+ 5 - 1
jeecg-boot-report/src/main/java/cn/com/ctop/report/entity/AccountAttributionInfo.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.report.entity;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
@@ -19,11 +20,14 @@ public class AccountAttributionInfo {
     private Long productId;
     private String advertiserId;
     private String companyId;
-    private String accountName;
     private String projectName;
     private String advertiserName;
     private String companyName;
     private String saleId;
     private String userId;
     private String orgCode;
+    @TableField(exist = false)
+    private String userName;
+    @TableField(exist = false)
+    private String authName;
 }

+ 6 - 6
jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/AccountAttributionInfoMapper.java

@@ -16,20 +16,20 @@ public interface AccountAttributionInfoMapper extends BaseMapper<AccountAttribut
     List<AccountAttributionInfo> selectDesignAccuntsByParams(@Param(value = "mediaList")List<Integer> mediaList, @Param(value = "designUserId")String designUserId);
 
     //今日汇总数据
-    JSONObject queryTodaySumReportBy(@Param("statDate") String statDate, @Param("accountIds") JSONArray accountIds);
+    JSONObject queryTodaySumReportBy(@Param("statDate") Long statDate, @Param("accountIds") JSONArray accountIds);
 
     //根据小时区间查询今日汇总数据
-    JSONObject queryTodaySumByHour(@Param("statDate") String statDate, @Param("hour") int hour, @Param("accountIds") JSONArray accountIds);
+    JSONObject queryTodaySumByHour(@Param("statDate") Long statDate, @Param("hour") int hour, @Param("accountIds") JSONArray accountIds);
 
     //根据开始、结束时间 查询汇总数据
-    JSONObject querySumByStartEndDate(@Param("endDate") String endDate, @Param("startDate") String startDate, @Param("accountIds") JSONArray accountIds);
+    JSONObject querySumByStartEndDate(@Param("endDate") Long endDate, @Param("startDate") Long startDate, @Param("accountIds") JSONArray accountIds);
 
     //今日明细数据
-    List<JSONObject> queryTodayDetailReportBy(@Param("filed") String filed, @Param("statDate") String statDate, @Param("accountIds") JSONArray accountIds);
+    List<JSONObject> queryTodayDetailReportBy(@Param("filed") String filed, @Param("statDate") Long statDate, @Param("accountIds") JSONArray accountIds);
 
     //按月分组查询明细数据
-    List<JSONObject> queryDetailGroupMonthByDate(@Param("endDate") String endDate, @Param("startDate") String startDate, @Param("accountIds") JSONArray accountIds);
+    List<JSONObject> queryDetailGroupMonthByDate(@Param("endDate") Long endDate, @Param("startDate") Long startDate, @Param("accountIds") JSONArray accountIds);
 
     //根据开始、结束时间 查询明细数据
-    List<JSONObject> queryDetailByStartEndDate(@Param("endDate") String endDate, @Param("startDate") String startDate, @Param("accountIds") JSONArray accountIds);
+    List<JSONObject> queryDetailByStartEndDate(@Param("endDate") Long endDate, @Param("startDate") Long startDate, @Param("accountIds") JSONArray accountIds);
 }

+ 1 - 1
jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/KuaishouAccountReportDailyDwMapper.java

@@ -9,5 +9,5 @@ import org.apache.ibatis.annotations.Param;
 import java.util.List;
 
 public interface KuaishouAccountReportDailyDwMapper extends BaseMapper<KuaishouAccountReportDailyDw> {
-    List<JSONObject> getReportByParams(@Param(value = "filedAll") String filedAll, @Param(value = "endDate")String endDate, @Param(value = "startDate")String startDate, @Param(value = "accounts")JSONArray accounts, @Param(value = "target")String target, @Param(value = "order")String order, @Param(value = "hasGroupBy")int hasGroupBy,@Param(value = "groupBy")String groupBy);
+    List<JSONObject> getReportByParams(@Param(value = "filedAll") String filedAll, @Param(value = "endDate")Long endDate, @Param(value = "startDate")Long startDate, @Param(value = "accountIds")JSONArray accounts, @Param(value = "target")String target, @Param(value = "order")String order, @Param(value = "hasGroupBy")int hasGroupBy,@Param(value = "groupBy")String groupBy);
 }

+ 1 - 1
jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/KuaishouAccountReportHourlyDwMapper.java

@@ -9,5 +9,5 @@ import org.apache.ibatis.annotations.Param;
 import java.util.List;
 
 public interface KuaishouAccountReportHourlyDwMapper extends BaseMapper<KuaishouAccountReportHourlyDw> {
-    List<JSONObject> getReportByParams(@Param(value = "filedAll") String filedAll, @Param(value = "startDate")String startDate, @Param(value = "hour")int hour, @Param(value = "accounts")JSONArray accounts, @Param(value = "target")String target, @Param(value = "order")String order, @Param(value = "hasGroupBy")int hasGroupBy,@Param(value = "groupBy")String groupBy);
+    List<JSONObject> getReportByParams(@Param(value = "filedAll") String filedAll, @Param(value = "startDate")Long startDate, @Param(value = "hour")int hour, @Param(value = "accounts")JSONArray accounts, @Param(value = "target")String target, @Param(value = "order")String order, @Param(value = "hasGroupBy")int hasGroupBy,@Param(value = "groupBy")String groupBy);
 }

+ 1 - 1
jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/KuaishouMaterialVideoReportDailyDwMapper.java

@@ -12,7 +12,7 @@ import java.util.Map;
 public interface KuaishouMaterialVideoReportDailyDwMapper extends BaseMapper<KuaishouMaterialVideoReportDailyDw> {
     Long getTotalByMap(Map<String, Object> requestMap);
 
-    List getKuaiShouVideoReportByMap(Map<String, Object> requestMap);
+    List<JSONObject> getKuaiShouVideoReportByMap(Map<String, Object> requestMap);
 
     List<JSONObject> queryVideoDetailBy(@Param("accountIds") JSONArray accountIds, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("filed") String filed, @Param("signature") String signature);
 }

+ 27 - 26
jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/xml/AccountAttributionInfoMapper.xml

@@ -3,7 +3,7 @@
 <mapper namespace="cn.com.ctop.report.mapper.AccountAttributionInfoMapper">
 
     <insert id="reloadData">
-        replace into ctop_account_attribution_info(id, account_id, project_id, product_id, advertiser_id, company_id,
+        replace into `jeecg-boot`.ctop_account_attribution_info(id, account_id, project_id, product_id, advertiser_id, company_id,
                                           account_name, project_name, advertiser_name, company_name, sale_id, user_id,
                                           org_code)
         select cua.account_id,
@@ -19,20 +19,22 @@
                cp.sale_id,
                su.id,
                su.org_code
-        from ctop_user_allocation cua
-                 left join ctop_project cp on cua.project_id = cp.id
-                 left join ctop_advertiser ca on ca.id = cua.advertiser_id
-                 left join sys_user su on su.id = cua.user_id
-                 left join user_company uc on uc.user_id = cua.user_id
-                 left join ctop_product product on product.id = cp.product_id where cua.account_id is not null;
+        from `jeecg-boot`.ctop_user_allocation cua
+                 left join `jeecg-boot`.ctop_project cp on cua.project_id = cp.id
+                 left join `jeecg-boot`.ctop_advertiser ca on ca.id = cua.advertiser_id
+                 left join `jeecg-boot`.sys_user su on su.id = cua.user_id
+                 left join `jeecg-boot`.user_company uc on uc.user_id = cua.user_id
+                 left join `jeecg-boot`.ctop_product product on product.id = cp.product_id where cua.account_id is not null;
     </insert>
     <select id="selectByParams" resultType="cn.com.ctop.report.entity.AccountAttributionInfo">
         select
-               caai.*
-        from ctop_user_allocation cua
-        left join ctop_account_attribution_info caai on caai.account_id = cua.account_id
+               caai.*,
+               cua.auth_name,
+               cua.user_name
+        from `jeecg-boot`.ctop_user_allocation cua
+        left join `jeecg-boot`.ctop_account_attribution_info caai on caai.account_id = cua.account_id
         where cua.media_id in
-        <foreach collection="mediaIds" item="item" separator=","
+        <foreach collection="mediaList" item="item" separator=","
                  open="(" close=")">
             #{item}
         </foreach>
@@ -53,16 +55,15 @@
                 #{userId}
             </foreach>
         </if>
-        and cua.account_status = 0
     </select>
     <select id="selectDesignAccuntsByParams" resultType="cn.com.ctop.report.entity.AccountAttributionInfo">
         select caai.*
-        from ctop_user_allocation cua
-                 left join ctop_account_attribution_info caai on cua.account_id = caai.account_id
+        from `jeecg-boot`.ctop_user_allocation cua
+                 left join `jeecg-boot`.ctop_account_attribution_info caai on cua.account_id = caai.account_id
         where cua.account_status = 0
         <if test="mediaList != null">
             and cua.media_id in
-            <foreach collection="mediaIds" item="item" separator=","
+            <foreach collection="mediaList" item="item" separator=","
                      open="(" close=")">
                 #{item}
             </foreach>
@@ -73,10 +74,10 @@
         <select id="queryTodaySumReportBy" resultType="com.alibaba.fastjson.JSONObject">
             SELECT
             ROUND(sum(charge),3) cost,
-            sum(photo_show) photoShow,
+            sum(`show`) photoShow,
             sum(photo_click) photoClick,
             sum(aClick) as aClick,
-            max(stat_hour) maxHour
+            max(`hour`) maxHour
             FROM
             kuaishou_account_report_hourly_dw
             WHERE
@@ -91,14 +92,14 @@
         <select id="queryTodaySumByHour" resultType="com.alibaba.fastjson.JSONObject">
             SELECT
             ROUND(sum(charge),2) cost,
-            sum(photo_show) photoShow,
+            sum(`show`) photoShow,
             sum(photo_click) photoClick,
             sum(aClick) as aClick
             FROM
             kuaishou_account_report_hourly_dw
             WHERE
             stat_date = #{statDate}
-            AND stat_hour &lt;= #{hour}
+            AND `hour` &lt;= #{hour}
             AND account_id in
             <foreach item="item" index="index" collection="accountIds"
                      open="(" separator="," close=")">
@@ -110,10 +111,10 @@
         <select id="queryTodayDetailReportBy" resultType="com.alibaba.fastjson.JSONObject">
             SELECT
             ROUND(sum(charge),3) cost,
-            sum(photo_show) photoShow,
+            sum(`show`) photoShow,
             sum(photo_click) photoClick,
             sum(aClick) as aClick,
-            stat_hour as statHour
+            `hour` as statHour
             FROM
             kuaishou_account_report_hourly_dw
             WHERE
@@ -124,16 +125,16 @@
                 #{item}
             </foreach>
             GROUP BY
-            stat_hour
+            `hour`
             ORDER BY
-            stat_hour ASC
+            `hour` ASC
         </select>
 
 
         <select id="querySumByStartEndDate" resultType="com.alibaba.fastjson.JSONObject">
             SELECT
             ROUND(sum(charge),3) cost,
-            sum(photo_show) photoShow,
+            sum(`show`) photoShow,
             sum(photo_click) photoClick,
             sum(aClick) as aClick
             FROM kuaishou_account_report_daily_dw t1
@@ -151,7 +152,7 @@
         <select id="queryDetailByStartEndDate" resultType="com.alibaba.fastjson.JSONObject">
             SELECT
             ROUND(sum(charge),3) cost,
-            sum(photo_show) photoShow,
+            sum(`show`) photoShow,
             sum(photo_click) photoClick,
             sum(aClick) as aClick,
             stat_date as statDate
@@ -171,7 +172,7 @@
         <select id="queryDetailGroupMonthByDate" resultType="com.alibaba.fastjson.JSONObject">
             SELECT
             ROUND(sum(charge),3) cost,
-            sum(photo_show) photoShow,
+            sum(`show`) photoShow,
             sum(photo_click) photoClick,
             sum(aClick) as aClick,
             DATE_FORMAT(t1.stat_date, '%Y-%m') statDate

+ 3 - 3
jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/xml/KuaishouAccountReportDailyDwMapper.xml

@@ -6,10 +6,10 @@
         SELECT
         stat_date as statDate,
         account_id as accountId,
-        auth_name as authName,
-        ${filed}
+        account_name as authName,
+        ${filedAll}
         FROM
-        ctop_kuaishou_report_daily_account
+        kuaishou_account_report_daily_dw
         WHERE
         stat_date &lt;= #{endDate}
         AND stat_date &gt;= #{startDate}

+ 6 - 5
jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/xml/KuaishouAccountReportHourlyDwMapper.xml

@@ -8,15 +8,16 @@
         account_name as authName,
         ${filedAll}
         FROM ctop_kuaishou_report_hourly_account t1
-        WHERE stat_date = #{statDate}
-        and stat_hour &lt;= #{hour}
-        AND account_id in
+        WHERE t1.stat_date = #{statDate}
+        and t1.`hour` &lt;= #{hour}
+        AND t1.account_id in
         <foreach item="item" index="index" collection="accountIds"
                  open="(" separator="," close=")">
             #{item}
         </foreach>
-        <if test="hasGroupBy == 1"></if>
-        group by t1.account_id
+        <if test="hasGroupBy == 1">
+            group by t1.account_id
+        </if>
         order by ${target} ${order}
     </select>
 </mapper>

+ 22 - 25
jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/xml/KuaishouMaterialVideoReportDailyDwMapper.xml

@@ -8,7 +8,7 @@
         FROM
         (select
         t1.signature
-        from ctop_etl_kuaishou_account_material_report_daily t1
+        from kuaishou_material_video_report_daily_dw t1
         where 1 = 1
         <if test="accountIds !=null and accountIds != ''">
             and t1.account_id in
@@ -23,45 +23,42 @@
         <if test="endDate !=null and endDate != ''">
             AND t1.stat_date &lt;= #{endDate}
         </if>
-        GROUP BY t1.signature
-        ) t1
-        LEFT JOIN ctop_etl_kuaishou_video_info t2
-        ON t1.signature = t2.video_code
-        WHERE
-        1 = 1
         <if test="leaderId !=null and leaderId != ''">
-            AND t2.design_team_leader_id = #{leaderId}
+            AND t1.leader_id = #{leaderId}
         </if>
         <if test="channelType != null">
-            AND t2.channel_type = #{channelType}
+            AND t1.channel_type = #{channelType}
         </if>
         <if test="clipId !=null and clipId != ''">
-            AND t2.clip_id = #{clipId}
+            AND t1.clip_id = #{clipId}
         </if>
         <if test="planId !=null and planId != ''">
-            AND t2.plan_id = #{planId}
+            AND t1.plan_id = #{planId}
         </if>
         <if test="shotId !=null and shotId != ''">
-            AND t2.shot_id = #{shotId}
+            AND t1.shot_id = #{shotId}
         </if>
         <if test="companyId !=null and companyId != ''">
-            AND t2.company_id = #{companyId}
+            AND t1.company_id = #{companyId}
         </if>
+        GROUP BY t1.signature
+        ) t2
     </select>
-    <select id="getKuaiShouVideoReportByMap" resultType="java.util.List">
+    <select id="getKuaiShouVideoReportByMap" resultType="com.alibaba.fastjson.JSONObject" parameterType="map">
         SELECT
-        t1.*,
-        IFNULL(t1.clip_name,'-') as clip,
-        IFNULL(t1.plan_name,'-') as plan,
-        IFNULL(t1.shot_name,'-') as shot,
-        IFNULL(t1.design_team_leader_name,'-') as designLeader,
-        IFNULL(t1.video_name,'-') as materialName,
-        IFNULL(t1.cover_url,'-') as coverUrl,
-        IFNULL(t1.url,'-') as url ,
-        IFNULL(t1.channel_name,'-') AS channel,
-        IFNULL(t1.state_date,'-') as createTime
+        t1.*
         FROM
-        (select ${filed}
+        (select
+        IFNULL( clip_name, '-' ) AS clip,
+        IFNULL( plan_name, '-' ) AS plan,
+        IFNULL( shot_name, '-' ) AS shot,
+        IFNULL( leader_name, '-' ) AS designLeader,
+        IFNULL( video_name, '-' ) AS materialName,
+        IFNULL( cover_url, '-' ) AS coverUrl,
+        IFNULL( photo_url, '-' ) AS url,
+        IFNULL( channel_type, '-' ) AS channel,
+        IFNULL( stat_date, '-' ) AS createTime,
+                ${filed}
         from kuaishou_material_video_report_daily_dw
         where 1 = 1
         <if test="accountIds !=null and accountIds != ''">

+ 42 - 18
jeecg-boot-report/src/main/java/cn/com/ctop/report/service/impl/AccountAttributionInfoServiceImpl.java

@@ -94,25 +94,39 @@ public class AccountAttributionInfoServiceImpl extends ServiceImpl<AccountAttrib
         List<AccountAttributionInfo>accountAttributionInfos = getAccountInfoList(userId,mediaType);
         Map<Long,Long> projectIdMaps = new HashMap<>();
         for(AccountAttributionInfo attributionInfo:accountAttributionInfos){
-            projectIdMaps.putIfAbsent(attributionInfo.getProjectId(),attributionInfo.getProjectId());
+            if(null!=attributionInfo&&null!=attributionInfo.getProjectId()&&attributionInfo.getProjectId()!=0){
+                projectIdMaps.putIfAbsent(attributionInfo.getProjectId(),attributionInfo.getProjectId());
+            }
         }
         JSONArray projectInfos = new JSONArray();
         if(projectIdMaps.isEmpty()){
             return projectInfos;
         }
         for (Long key : projectIdMaps.keySet()) {
-            List<AccountAttributionInfo>accountInfos = accountAttributionInfos.stream().filter(a->a.getProjectId().equals(key)).collect(Collectors.toList());
+            List<AccountAttributionInfo>accountInfos = getAccountInfoListByProjectId(key,accountAttributionInfos);
             JSONObject projectInfo = new JSONObject();
-            projectInfo.put("projectId",accountInfos.get(0).getProjectId());
-            projectInfo.put("projectName",accountInfos.get(0).getProjectName());
-            projectInfo.put("advertiserName",accountInfos.get(0).getAdvertiserName());
-            projectInfo.put("advertiserId",accountInfos.get(0).getAdvertiserId());
-            projectInfo.put("accountList",accountInfos);
-            projectInfos.add(projectInfo);
+            if(!accountInfos.isEmpty()){
+                projectInfo.put("projectId",accountInfos.get(0).getProjectId());
+                projectInfo.put("projectName",accountInfos.get(0).getProjectName());
+                projectInfo.put("advertiserName",accountInfos.get(0).getAdvertiserName());
+                projectInfo.put("advertiserId",accountInfos.get(0).getAdvertiserId());
+                projectInfo.put("accountList",accountInfos);
+                projectInfos.add(projectInfo);
+            }
         }
         return projectInfos;
     }
 
+    private List<AccountAttributionInfo> getAccountInfoListByProjectId(Long projectId, List<AccountAttributionInfo> accountAttributionInfos) {
+        List<AccountAttributionInfo>result = new ArrayList<>();
+        for(AccountAttributionInfo attributionInfo:accountAttributionInfos){
+            if(null!=attributionInfo&&null!=attributionInfo.getProjectId()&&attributionInfo.getProjectId().equals(projectId)){
+                result.add(attributionInfo);
+            }
+        }
+        return result;
+    }
+
     @Override
     public JSONArray getMaterialProjectAccountByUserId(String userId, String mediaType) {
         List<AccountAttributionInfo>accountAttributionInfos = getAccountInfoList(userId,mediaType);
@@ -190,17 +204,22 @@ public class AccountAttributionInfoServiceImpl extends ServiceImpl<AccountAttrib
         Map<String, Object> result = new HashMap<>();
         JSONObject after;
         JSONObject before;
-        if (startDate.equals(endDate)) {
-            after = accountAttributionInfoMapper.queryTodaySumReportBy(startDate, accounts);
+        Long startDateNum = Long.parseLong(startDate.replace("-",""));
+        Long anotherStartDateNum = Long.parseLong(DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1).replace("-",""));
+
+        Long endDateNum = Long.parseLong(endDate.replace("-",""));
+        Long anotherEndDateNum = Long.parseLong(DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, endDate, -1).replace("-",""));
+        if (startDateNum.equals(endDateNum)) {
+            after = accountAttributionInfoMapper.queryTodaySumReportBy(startDateNum, accounts);
             if (after == null) {
                 return result;
             }
-            before = accountAttributionInfoMapper.queryTodaySumByHour(DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1), after.getInteger("maxHour"), accounts);
+            before = accountAttributionInfoMapper.queryTodaySumByHour(anotherStartDateNum, after.getInteger("maxHour"), accounts);
             if (before == null) {
                 before = after;
             }
         } else {
-            after = accountAttributionInfoMapper.querySumByStartEndDate(endDate, startDate, accounts);
+            after = accountAttributionInfoMapper.querySumByStartEndDate(endDateNum, startDateNum, accounts);
             if (after == null) {
                 return result;
             }
@@ -214,9 +233,14 @@ public class AccountAttributionInfoServiceImpl extends ServiceImpl<AccountAttrib
     public List<JSONObject> getChartDataBy(String mediaId, BigDecimal discount, JSONArray accounts, String startDate, String endDate) throws ParseException {
         List<JSONObject> result = new ArrayList<>();
         String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.getDicMapKs());
-        if (startDate.equals(endDate)) {
-            List<JSONObject> after = accountAttributionInfoMapper.queryTodayDetailReportBy(filedAll, startDate, accounts);
-            List<JSONObject> before = accountAttributionInfoMapper.queryTodayDetailReportBy(filedAll, DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1), accounts);
+        Long startDateNum = Long.parseLong(startDate.replace("-",""));
+        Long anotherStartDateNum = Long.parseLong(DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1).replace("-",""));
+
+        Long endDateNum = Long.parseLong(endDate.replace("-",""));
+        Long anotherEndDateNum = Long.parseLong(DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, endDate, -1).replace("-",""));
+        if (startDateNum.equals(endDateNum)) {
+            List<JSONObject> after = accountAttributionInfoMapper.queryTodayDetailReportBy(filedAll, startDateNum, accounts);
+            List<JSONObject> before = accountAttributionInfoMapper.queryTodayDetailReportBy(filedAll, anotherStartDateNum, accounts);
             if (after.size() == 0) {
                 return result;
             }
@@ -230,9 +254,9 @@ public class AccountAttributionInfoServiceImpl extends ServiceImpl<AccountAttrib
             List<JSONObject> after;
             //判断是不是日期间隔大于半年
             if (DateUtils.isMoreSixMonth(startDate, endDate)) {
-                after = accountAttributionInfoMapper.queryDetailGroupMonthByDate(endDate, startDate, accounts);
+                after = accountAttributionInfoMapper.queryDetailGroupMonthByDate(endDateNum, startDateNum, accounts);
             } else {
-                after = accountAttributionInfoMapper.queryDetailByStartEndDate(endDate, startDate, accounts);
+                after = accountAttributionInfoMapper.queryDetailByStartEndDate(endDateNum, startDateNum, accounts);
             }
             if (after == null) {
                 return result;
@@ -254,7 +278,7 @@ public class AccountAttributionInfoServiceImpl extends ServiceImpl<AccountAttrib
         JSONObject aClickLink = new JSONObject();
 
         costLink.put("cost", after.getBigDecimal("cost"));
-        costLink.put("CostSumLink", LinkUtils.countLink(after.getBigDecimal("cost"), before.getBigDecimal("cost")));
+        costLink.put("costSumLink", LinkUtils.countLink(after.getBigDecimal("cost"), before.getBigDecimal("cost")));
         if (mediaId.equals(CtopAdConstant.PLATFORM_TYPE_KUAISHOU)) {
             discountCostLink.put("discountCost", after.getBigDecimal("cost").divide(discount, 4, RoundingMode.HALF_UP));
             discountCostLink.put("discountCostLink", LinkUtils.countLink(after.getBigDecimal("cost").divide(discount, 4, RoundingMode.HALF_UP), before.getBigDecimal("cost").divide(discount, 4, RoundingMode.HALF_UP)));

+ 15 - 9
jeecg-boot-report/src/main/java/cn/com/ctop/report/service/impl/KuaishouAccountReportDailyDwServiceImpl.java

@@ -31,19 +31,25 @@ public class KuaishouAccountReportDailyDwServiceImpl extends ServiceImpl<Kuaisho
     public List<JSONObject> getListDataByParams(String mediaId, BigDecimal discount, JSONArray accounts, String startDate, String endDate, int hour, String target, String order) {
         List<JSONObject> result;
         String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.getDicMapKs());
-        if (startDate.equals(endDate)) {
+        Long startDateNum = Long.parseLong(startDate.replace("-",""));
+        Long anotherStartDateNum = Long.parseLong(DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1).replace("-",""));
+
+        Long endDateNum = Long.parseLong(endDate.replace("-",""));
+        Long anotherEndDateNum = Long.parseLong(DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, endDate, -1).replace("-",""));
+
+        if (startDateNum.equals(endDateNum)) {
             String groupBy = "account_id";
             if (startDate.equals(DateUtils.date2Str())) {
-                result = kuaishouAccountReportHourlyDwMapper.getReportByParams(filedAll, startDate, hour, accounts, target, order,1,groupBy);
-                JSONObject afterSum = kuaishouAccountReportHourlyDwMapper.getReportByParams(filedAll, startDate, hour, accounts,target,order,0,groupBy).get(0);
-                JSONObject beforeSum = kuaishouAccountReportHourlyDwMapper.getReportByParams(filedAll, DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1), hour, accounts,target,order,0,groupBy).get(0);
+                result = kuaishouAccountReportHourlyDwMapper.getReportByParams(filedAll, startDateNum, hour, accounts, target, order,1,groupBy);
+                JSONObject afterSum = kuaishouAccountReportHourlyDwMapper.getReportByParams(filedAll, startDateNum, hour, accounts,target,order,0,groupBy).get(0);
+                JSONObject beforeSum = kuaishouAccountReportHourlyDwMapper.getReportByParams(filedAll,anotherStartDateNum , hour, accounts,target,order,0,groupBy).get(0);
                 result.add(afterSum);
                 result.add(beforeSum);
                 result.add(countTotal(afterSum, beforeSum));
             } else {
-                result = kuaishouAccountReportDailyDwMapper.getReportByParams(filedAll, endDate, startDate, accounts, target, order,1,groupBy);
-                JSONObject afterSum = kuaishouAccountReportDailyDwMapper.getReportByParams(filedAll, endDate, startDate, accounts,target,order,0,groupBy).get(0);
-                JSONObject beforeSum = kuaishouAccountReportDailyDwMapper.getReportByParams(filedAll, DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, endDate, -1), DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1), accounts,target,order,0,groupBy).get(0);
+                result = kuaishouAccountReportDailyDwMapper.getReportByParams(filedAll, endDateNum, startDateNum, accounts, target, order,1,groupBy);
+                JSONObject afterSum = kuaishouAccountReportDailyDwMapper.getReportByParams(filedAll, endDateNum, startDateNum, accounts,target,order,0,groupBy).get(0);
+                JSONObject beforeSum = kuaishouAccountReportDailyDwMapper.getReportByParams(filedAll, anotherEndDateNum, anotherStartDateNum, accounts,target,order,0,groupBy).get(0);
                 result.add(afterSum);
                 result.add(beforeSum);
                 result.add(countTotal(afterSum, beforeSum));
@@ -53,8 +59,8 @@ public class KuaishouAccountReportDailyDwServiceImpl extends ServiceImpl<Kuaisho
             if (accounts.size() > 1) {
                 groupBy = "account_id";
             }
-            result = kuaishouAccountReportDailyDwMapper.getReportByParams(filedAll, endDate, startDate, accounts, target, order,1,groupBy);
-            List<JSONObject> totalList = kuaishouAccountReportDailyDwMapper.getReportByParams(filedAll, endDate, startDate, accounts,target,order,0,groupBy);
+            result = kuaishouAccountReportDailyDwMapper.getReportByParams(filedAll, endDateNum, startDateNum, accounts, target, order,1,groupBy);
+            List<JSONObject> totalList = kuaishouAccountReportDailyDwMapper.getReportByParams(filedAll, endDateNum, startDateNum, accounts,target,order,0,groupBy);
             if(null!=totalList&&!totalList.isEmpty()){
                 result.add(totalList.get(0));
             }

+ 2 - 2
jeecg-boot-report/src/main/resources/application-dev.yml

@@ -105,8 +105,8 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
-          url: jdbc:mysql://192.168.1.187:4000/application?characterEncoding=UTF-8&useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
-          username: root
+          url: jdbc:mysql://139.186.27.96:3390/application?characterEncoding=UTF-8&useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
+          username: data
           password: hcst@2021
           driver-class-name: com.mysql.jdbc.Driver
   #redis 配置

+ 2 - 3
jeecg-boot-report/src/main/resources/application-prod.yml

@@ -5,7 +5,6 @@ server:
     include-exception: true
     include-stacktrace: ALWAYS
     include-message: ALWAYS
-
   compression:
     enabled: true
     min-response-size: 1024
@@ -20,7 +19,7 @@ spring:
     nacos:
       discovery:
         server-addr: 172.30.0.7:8848
-        service: jeecg-cloud-finance
+        service: jeecg-cloud-report
   servlet:
      multipart:
         max-file-size: 10MB
@@ -106,7 +105,7 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
-          url: jdbc:mysql://139.186.27.96:3390/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
+          url: jdbc:mysql://139.186.27.96:3390/application?characterEncoding=UTF-8&useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
           username: data
           password: hcst@2021
           driver-class-name: com.mysql.jdbc.Driver

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

@@ -15,8 +15,8 @@ spring:
   cloud:
     nacos:
       discovery:
-        server-addr: 139.186.134.115:8848
-        service: jeecg-cloud-finance
+        server-addr: 172.30.0.14:8848
+        service: jeecg-cloud-report
   servlet:
     multipart:
       max-file-size: -1

+ 1 - 1
jeecg-boot-report/src/main/resources/application.yml

@@ -1,5 +1,5 @@
 server:
-  port: 7005
+  port: 7006
   servlet:
     context-path: /reportModule
 

+ 6 - 0
jeecg-cloud-module/jeecg-cloud-gateway/src/main/resources/application-dev.yml

@@ -38,6 +38,12 @@ spring:
           - Path=/bytedance/ad/**
         filters:
           - DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin
+      - id: jeecg-cloud-report
+        uri: lb://jeecg-cloud-report
+        predicates:
+          - Path=/reportModule/**
+        filters:
+          - DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin
 # hystrix 信号量隔离,3秒后自动超时
 hystrix:
   enabled: true

+ 6 - 0
jeecg-cloud-module/jeecg-cloud-gateway/src/main/resources/application-prod.yml

@@ -50,6 +50,12 @@ spring:
           - DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin
         predicates:
           - Path=/finance/**
+      - id: jeecg-cloud-report
+        uri: lb://jeecg-cloud-report
+        predicates:
+          - Path=/reportModule/**
+        filters:
+          - DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin
 # hystrix 信号量隔离,3秒后自动超时
 hystrix:
   enabled: true