ソースを参照

账户级总报表

zhaoxian 2 年 前
コミット
333216d045

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

@@ -250,6 +250,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/liveData/**", "anon");
         filterChainDefinitionMap.put("/product/material/**", "anon");
         filterChainDefinitionMap.put("/ctop/materialInfo/**", "anon");
+        filterChainDefinitionMap.put("/summary/report/**", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

+ 15 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java

@@ -116,6 +116,20 @@ public class ProjectController {
     }
 
 
+    @GetMapping("/getProjectListByMediaId")
+    public Result<Object> getProjectListByMediaId(String mediaId) {
+        try {
+            QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("media_id", mediaId);
+            List<Project> projects = projectMapper.selectList(queryWrapper);
+            return Result.ok(projects);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.error("fail");
+    }
+
+
     /**
      * 我管理的
      *
@@ -276,7 +290,7 @@ public class ProjectController {
 
         } else if ("plane".equals(roleCode) || "plan".equals(roleCode) || "shot".equals(roleCode) || "clip".equals(roleCode) || "designTeamLeader".equals(roleCode) || "planeLeader".equals(roleCode)) {
             queryWrapper.eq("design_responsible_id", userId);
-        } else if (roleCode.contains("sale")||"CompanyManager".equals(roleCode)) {
+        } else if (roleCode.contains("sale") || "CompanyManager".equals(roleCode)) {
             QueryWrapper<UserCompany> userCompanyQueryWrapper = new QueryWrapper<>();
             userCompanyQueryWrapper.eq("user_id", userId);
             userCompanyQueryWrapper.orderByDesc("create_time");

+ 116 - 0
jeecg-boot-report/src/main/java/cn/com/ctop/report/controller/ReportController.java

@@ -0,0 +1,116 @@
+package cn.com.ctop.report.controller;
+
+import cn.com.ctop.report.service.IBytedanceAccountReportDailyDwService;
+import cn.com.ctop.report.service.IKuaishouAccountReportDailyDwService;
+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.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 汇总数据
+ */
+@RestController
+@RequestMapping("summary/report")
+@Slf4j
+public class ReportController {
+
+    @Autowired
+    private IKuaishouAccountReportDailyDwService kuaishouReportService;
+
+    @Resource
+    private IBytedanceAccountReportDailyDwService bytedanceReportService;
+
+
+    /**
+     * 获取快手&&头条当日消耗、自然周同比、日环比
+     */
+    @GetMapping("/getTotalCharge")
+    public Result<Object> getTotalCharge() {
+        try {
+            Integer nowHour = DateUtils.getNowHour();
+            //本周一
+            String monday = DateUtils.getdateFromWeek(1);
+            //当天日期
+            String today = DateUtils.formatDate(new Date());
+            //昨天日期
+            String yesterday = DateUtils.getLastDay(today, 1);
+            //上周一日期
+            String lastStartDate = DateUtils.getLastDay(monday, 7);
+            //上周当天日期
+            String lastEndDate = DateUtils.getLastDay(today, 7);
+            Map<String, Object> paramsMap = new HashMap<>();
+            paramsMap.put("lastStartDate", DateUtils.getDateInteger(lastStartDate));
+            paramsMap.put("lastEndDate", DateUtils.getDateInteger(lastEndDate));
+            paramsMap.put("monday", DateUtils.getDateInteger(monday));
+            paramsMap.put("today", DateUtils.getDateInteger(today));
+            paramsMap.put("yesterday", DateUtils.getDateInteger(yesterday));
+            paramsMap.put("hour", nowHour);
+            JSONObject kuaishou = kuaishouReportService.getTotalCharge(paramsMap);
+            JSONObject bytedance = bytedanceReportService.getTotalCharge(paramsMap);
+            JSONObject data = new JSONObject();
+            data.put("kuaishou", kuaishou);
+            data.put("bytedance", bytedance);
+            return Result.OK(data);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+
+    /**
+     * 项目数据折线趋势图
+     *
+     * @param endTime
+     * @param startTime
+     * @param mediaId
+     */
+    @GetMapping("/getTrendCharge")
+    public Result<Object> getTrendCharge(String mediaId, Long projectId, String startTime, String endTime) {
+        try {
+            JSONObject data = null;
+            if ("1".equals(mediaId)) {
+                data = bytedanceReportService.getTrendCharge(projectId, startTime, endTime);
+            } else {
+                data = kuaishouReportService.getTrendCharge(projectId, startTime, endTime);
+            }
+            return Result.OK(data);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 获取项目报表
+     *
+     * @param endTime
+     * @param startTime
+     * @param mediaId
+     */
+    @GetMapping("/getProjectReport")
+    public Result<Object> getProjectReport(String mediaId, Long projectId, String startTime, String endTime, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if ("1".equals(mediaId)) {
+                return bytedanceReportService.getProjectReport(projectId, startTime, endTime, pageSize, pageNo);
+            } else {
+                return kuaishouReportService.getProjectReport(projectId, startTime, endTime, pageSize, pageNo);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+}

+ 18 - 3
jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/BytedanceAccountReportDailyDwMapper.java

@@ -1,13 +1,28 @@
 package cn.com.ctop.report.mapper;
 
-import cn.com.ctop.report.entity.KuaishouAccountReportDailyDw;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
-public interface BytedanceAccountReportDailyDwMapper  {
+public interface BytedanceAccountReportDailyDwMapper {
     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);
+
+    JSONObject getTotalCharge(Map<String, Object> paramsMap);
+
+    Long getYesterdayUploadNewMaterialCount(Map<String, Object> paramsMap);
+
+    List<JSONObject> getHourCost(@Param("projectId") Long projectId, @Param("startTime") Integer startTime);
+
+    List<JSONObject> getDataCost(@Param("projectId") Long projectId, @Param("startTime") Integer startTime, @Param("endTime") Integer endTime);
+
+    Long getProjectToDayReportTotal(@Param("projectId") Long projectId, @Param("startTime") Integer startTime, @Param("hour") Integer hour);
+
+    List<JSONObject> getProjectToDayReport(@Param("projectId") Long projectId, @Param("startTime") Integer startTime, @Param("hour") Integer hour);
+
+    Long getProjectMoreDaysReportTotal(@Param("projectId") Long projectId, @Param("startTime") Integer startTime, @Param("endTime") Integer endTime, @Param("hour") Integer hour);
+
+    List<JSONObject> getProjectMoreDaysReport(@Param("projectId") Long projectId, @Param("startTime") Integer startTime, @Param("endTime") Integer endTime, @Param("hour") Integer hour);
 }

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

@@ -7,7 +7,25 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 public interface KuaishouAccountReportDailyDwMapper extends BaseMapper<KuaishouAccountReportDailyDw> {
-    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);
+    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);
+
+    JSONObject getTotalCharge(Map<String, Object> paramsMap);
+
+    Long getYesterdayUploadNewMaterialCount(Map<String, Object> paramsMap);
+
+    List<JSONObject> getHourcharge(@Param("projectId") Long projectId, @Param("startTime") Integer startTime);
+
+    List<JSONObject> getDatacharge(@Param("projectId") Long projectId, @Param("startTime") Integer startTime, @Param("endTime") Integer endTime);
+
+    Long getProjectToDayReportTotal(@Param("projectId") Long projectId, @Param("startTime") Integer startTime, @Param("hour") Integer hour);
+
+    List<JSONObject> getProjectToDayReport(@Param("projectId") Long projectId, @Param("startTime") Integer startTime, @Param("hour") Integer hour);
+
+    Long getProjectMoreDaysReportTotal(@Param("projectId") Long projectId, @Param("startTime") Integer startTime, @Param("endTime") Integer endTime, @Param("hour") Integer hour);
+
+    List<JSONObject> getProjectMoreDaysReport(@Param("projectId") Long projectId, @Param("startTime") Integer startTime, @Param("endTime") Integer endTime, @Param("hour") Integer hour);
+
 }

+ 201 - 0
jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/xml/BytedanceAccountReportDailyDwMapper.xml

@@ -23,4 +23,205 @@
             order by ${target} ${order}
         </if>
     </select>
+
+    <select id="getYesterdayUploadNewMaterialCount" resultType="Long">
+        SELECT IFNULL(sum(1), 0)
+        FROM `app_bytedance_material_info`
+        WHERE media_time = DATE_FORMAT(DATE_SUB(#{lastEndDate}, INTERVAL 1 DAY ), '%Y%m%d')
+          AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b', 'd57fecdcf7a94d009736d9c850731582')
+    </select>
+
+
+    <select id="getTotalCharge" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t1.todaycost, t2.yesterdaycost, t3.thisWeekcost, t4.lastWeek1 + t5.lastWeek2 as 'lastWeekcost'
+        FROM (
+                 SELECT IFNULL(sum(cost), 0.00) as 'todaycost'
+                 FROM bytedance_advertiser_report_hourly_dw
+                 WHERE stat_datetime = #{today}
+                   AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b', 'd57fecdcf7a94d009736d9c850731582')
+             ) t1
+                 LEFT JOIN
+             (
+                 SELECT IFNULL(sum(cost), 0.00) as 'yesterdaycost'
+                 FROM bytedance_advertiser_report_hourly_dw
+                 WHERE stat_datetime = #{yesterday}
+                           AND hour &lt;= #{hour}
+                   AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b', 'd57fecdcf7a94d009736d9c850731582')
+             ) t2 ON 1 = 1
+                 LEFT JOIN
+             (
+                 SELECT IFNULL(sum(cost), 0.00) as 'thisWeekcost'
+                 FROM bytedance_advertiser_report_hourly_dw
+                 WHERE stat_datetime >= #{monday}
+                   AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b', 'd57fecdcf7a94d009736d9c850731582')
+                   AND stat_datetime &lt;= #{today}
+             ) t3 ON 1 = 1
+                 LEFT JOIN
+             (
+                 SELECT IF(#{lastStartDate} - #{lastEndDate} = 0, 0.00, sum(cost)) as 'lastWeek1'
+                 FROM bytedance_advertiser_report_daily_dw
+                 WHERE stat_datetime >= #{lastStartDate}
+                   AND stat_datetime &lt;= DATE_FORMAT(DATE_SUB(#{lastEndDate}, INTERVAL 1 DAY ), '%Y%m%d')
+                   AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b', 'd57fecdcf7a94d009736d9c850731582')
+             ) t4 ON 1 = 1
+                 LEFT JOIN
+             (
+                 SELECT IFNULL(sum(cost), 0.00) as 'lastWeek2'
+                 FROM bytedance_advertiser_report_hourly_dw
+                 WHERE stat_datetime = #{lastEndDate}
+                           AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b', 'd57fecdcf7a94d009736d9c850731582')
+                           AND hour &lt;= #{hour}
+             ) t5 ON 1 = 1
+    </select>
+
+    <select id="getHourCost" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT hour as 'time', IFNULL(SUM(cost), 0.00) as 'cost'
+        FROM bytedance_advertiser_report_hourly_dw
+        WHERE stat_datetime = #{startTime}
+        AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b' , 'd57fecdcf7a94d009736d9c850731582')
+        <if test="projectId != null and projectId != ''">
+            AND project_id = #{projectId}
+        </if>
+        GROUP BY hour
+        ORDER BY hour
+    </select>
+
+    <select id="getDataCost" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT DATE_FORMAT(stat_datetime, '%Y-%m-%d') as 'time', IFNULL(sum(cost), 0.00) as 'cost'
+        FROM bytedance_advertiser_report_hourly_dw
+        WHERE stat_datetime &lt;= #{endTime}
+        AND stat_datetime >= #{startTime}
+        AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b', 'd57fecdcf7a94d009736d9c850731582')
+        <if test="projectId != null and projectId != ''">
+            AND project_id = #{projectId}
+        </if>
+        GROUP BY stat_datetime
+        ORDER BY stat_datetime
+    </select>
+
+
+    <select id="getProjectToDayReportTotal" resultType="Long">
+        SELECT IFNULL(sum(1), 0)
+        FROM (
+        SELECT 1
+        FROM bytedance_advertiser_report_hourly_dw
+        WHERE stat_datetime = #{startTime}
+        <if test="projectId != null and projectId != ''">
+            AND project_id = #{projectId}
+        </if>
+        GROUP BY project_id
+        ) t
+    </select>
+
+
+    <select id="getProjectToDayReport" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        project_name AS 'projectName',
+        t2.product_name AS 'productName',
+        company_name AS 'companyName',
+        t3.realname AS 'saler',
+        t4.realname AS 'operater',
+        sum( cost ) AS 'cost',
+        SUM( `show` ) AS 'aclick',
+        SUM( click ) AS 'bclick',
+        IFNULL( t5.num, 0 ) AS 'num',
+        IFNULL(concat(round((sum(cost) - t6.costs) / t6.costs * 100, 2), '%'), '-') as 'rio'
+        FROM bytedance_advertiser_report_hourly_dw t1
+        LEFT JOIN `jeecg-boot`.ctop_product t2 ON t2.id = t1.product_id
+        LEFT JOIN `jeecg-boot`.sys_user t3 ON t1.sale_id = t3.id
+        LEFT JOIN `jeecg-boot`.sys_user t4 ON t1.user_id = t4.id
+        LEFT JOIN (
+        SELECT tt2.project_id, sum(1) as 'num'
+        FROM app_bytedance_material_info tt1
+        LEFT JOIN bytedance_project_material_relation tt2 ON tt1.material_id = tt2.signature
+        WHERE media_time = DATE_FORMAT(DATE_SUB(#{startTime}, INTERVAL 1 DAY ), '%Y%m%d')
+        AND tt1.company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b' , 'd57fecdcf7a94d009736d9c850731582')
+        <if test="projectId != null and projectId != ''">
+            AND project_id = #{projectId}
+        </if>
+        <if test="projectId == null">
+            GROUP BY project_id
+        </if>
+        ) t5 ON t1.project_id = t5.project_id
+        LEFT JOIN (
+        SELECT project_id, SUM(cost) as 'costs'
+        FROM bytedance_advertiser_report_hourly_dw
+        WHERE stat_datetime = DATE_FORMAT(DATE_SUB(20220804, INTERVAL 1 DAY ), '%Y%m%d')
+        AND hour &lt;= #{hour}
+        AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b' , 'd57fecdcf7a94d009736d9c850731582')
+        <if test="projectId != null and projectId != ''">
+            AND project_id = #{projectId}
+        </if>
+        <if test="projectId == null">
+            GROUP BY project_id
+        </if>
+        ) t6 ON t1.project_id = t6.project_id
+        WHERE stat_datetime = #{startTime}
+        AND t1.company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b' , 'd57fecdcf7a94d009736d9c850731582')
+        <if test="projectId != null and projectId != ''">
+            AND t1.project_id = #{projectId}
+        </if>
+        <if test="projectId == null">
+            GROUP BY t1.project_id
+            ORDER BY sum(cost) desc
+        </if>
+    </select>
+
+
+    <select id="getProjectMoreDaysReportTotal" resultType="Long">
+        SELECT IFNULL(sum(1), 0)
+        FROM (
+        SELECT 1
+        FROM bytedance_advertiser_report_daily_dw
+        WHERE stat_datetime >= #{startTime}
+        AND stat_datetime &lt;= #{endTime}
+        <if test="projectId != null and projectId != ''">
+            AND project_id = #{projectId}
+        </if>
+        GROUP BY project_id
+        ) t
+    </select>
+
+    <select id="getProjectMoreDaysReport" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        project_name AS 'projectName',
+        t2.product_name AS 'productName',
+        company_name AS 'companyName',
+        t3.realname AS 'saler',
+        t4.realname AS 'operater',
+        sum( cost ) AS 'cost',
+        SUM( `show` ) AS 'aclick',
+        SUM( click ) AS 'bclick',
+        IFNULL( t5.num, 0 ) AS 'num',
+        '-' as 'rio'
+        FROM bytedance_advertiser_report_daily_dw t1
+        LEFT JOIN `jeecg-boot`.ctop_product t2 ON t2.id = t1.product_id
+        LEFT JOIN `jeecg-boot`.sys_user t3 ON t1.sale_id = t3.id
+        LEFT JOIN `jeecg-boot`.sys_user t4 ON t1.user_id = t4.id
+        LEFT JOIN (
+        SELECT tt2.project_id, sum(1) as 'num'
+        FROM app_bytedance_material_info tt1
+        LEFT JOIN bytedance_project_material_relation tt2 ON tt1.material_id = tt2.signature
+        WHERE media_time >= #{startTime}
+        AND media_time &lt;= #{endTime}
+        AND tt1.company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b' , 'd57fecdcf7a94d009736d9c850731582')
+        <if test="projectId != null and projectId != ''">
+            AND project_id = #{projectId}
+        </if>
+        <if test="projectId == null">
+            GROUP BY project_id
+        </if>
+        ) t5 ON t1.project_id = t5.project_id
+        WHERE stat_datetime = #{startTime}
+        AND t1.company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b' , 'd57fecdcf7a94d009736d9c850731582')
+        <if test="projectId != null and projectId != ''">
+            AND t1.project_id = #{projectId}
+        </if>
+        <if test="projectId == null">
+            GROUP BY t1.project_id
+            ORDER BY sum(cost) desc
+        </if>
+    </select>
+
+
 </mapper>

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

@@ -23,4 +23,205 @@
             order by ${target} ${order}
         </if>
     </select>
+
+
+    <select id="getTotalCharge" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t1.todayCharge, t2.yesterdayCharge, t3.thisWeekCharge, t4.lastWeek1 + t5.lastWeek2 as 'lastWeekCharge'
+        FROM (
+                 SELECT IFNULL(sum(charge), 0.00) as 'todayCharge'
+                 FROM kuaishou_account_report_hourly_dw
+                 WHERE stat_date = #{today}
+                   AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b', 'd57fecdcf7a94d009736d9c850731582')
+             ) t1
+                 LEFT JOIN
+             (
+                 SELECT IFNULL(sum(charge), 0.00) as 'yesterdayCharge'
+                 FROM kuaishou_account_report_hourly_dw
+                 WHERE stat_date = #{yesterday}
+                   AND `hour` &lt;= #{hour}
+                   AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b', 'd57fecdcf7a94d009736d9c850731582')
+             ) t2
+             ON 1 = 1
+                 LEFT JOIN
+             (
+                 SELECT IFNULL(sum(charge), 0.00) as 'thisWeekCharge'
+                 FROM kuaishou_account_report_hourly_dw
+                 WHERE stat_date >= #{monday}
+                   AND stat_date &lt;= #{today}
+                   AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b', 'd57fecdcf7a94d009736d9c850731582')
+             ) t3
+             ON 1 = 1
+                 LEFT JOIN
+             (
+                 SELECT IF(#{lastStartDate} - #{lastEndDate} = 0, 0.00, sum(charge)) as 'lastWeek1'
+                 FROM kuaishou_account_report_daily_dw
+                 WHERE stat_date >= #{lastStartDate}
+                   AND stat_date &lt;= DATE_FORMAT(DATE_SUB(#{lastEndDate}
+                                                       , INTERVAL 1 DAY )
+                     , '%Y%m%d')
+                   AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b', 'd57fecdcf7a94d009736d9c850731582')
+             ) t4
+             ON 1 = 1
+                 LEFT JOIN
+             (
+                 SELECT IFNULL(sum(charge), 0.00) as 'lastWeek2'
+                 FROM kuaishou_account_report_hourly_dw
+                 WHERE stat_date = #{lastEndDate}
+                   AND `hour` &lt;= #{hour}
+                   AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b', 'd57fecdcf7a94d009736d9c850731582')
+             ) t5 ON 1 = 1
+    </select>
+
+    <select id="getYesterdayUploadNewMaterialCount" resultType="Long">
+        SELECT IFNULL(sum(1), 0)
+        FROM `app_kuaishou_material_info`
+        WHERE media_time = DATE_FORMAT(DATE_SUB(#{lastEndDate}, INTERVAL 1 DAY ), '%Y%m%d')
+          AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b', 'd57fecdcf7a94d009736d9c850731582')
+    </select>
+
+    <select id="getHourcharge" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT hour as 'time', IFNULL(SUM(charge), 0.00) as 'charge'
+        FROM kuaishou_account_report_hourly_dw
+        WHERE stat_date = #{startTime}
+        AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b' , 'd57fecdcf7a94d009736d9c850731582')
+        <if test="projectId != null and projectId != ''">
+            AND project_id = #{projectId}
+        </if>
+        GROUP BY hour
+        ORDER BY hour
+    </select>
+
+    <select id="getDatacharge" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT DATE_FORMAT(stat_date, '%Y-%m-%d') as 'time', IFNULL(sum(charge), 0.00) as 'charge'
+        FROM kuaishou_account_report_hourly_dw
+        WHERE stat_date &lt;= #{endTime}
+        AND stat_date >= #{startTime}
+        AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b', 'd57fecdcf7a94d009736d9c850731582')
+        <if test="projectId != null and projectId != ''">
+            AND project_id = #{projectId}
+        </if>
+        GROUP BY stat_date
+        ORDER BY stat_date
+    </select>
+
+
+    <select id="getProjectToDayReportTotal" resultType="Long">
+        SELECT IFNULL(sum(1), 0)
+        FROM (
+        SELECT 1
+        FROM kuaishou_account_report_hourly_dw
+        WHERE stat_date = #{startTime}
+        AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b' , 'd57fecdcf7a94d009736d9c850731582')
+        <if test="projectId != null and projectId != ''">
+            AND project_id = #{projectId}
+        </if>
+        GROUP BY project_id
+        ) t
+    </select>
+
+    <select id="getProjectToDayReport" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT project_name as 'projectName', t2.product_name as 'productName', company_name as 'companyName',
+        t3.realname as 'saler', t4.realname as 'operater', sum(charge) as 'charge', SUM(aclick) as 'aclick', SUM(bclick)
+        as 'bclick', IFNULL(t5.num, 0) as 'num', IFNULL(
+        concat(round((sum(charge) - t6.charges) / t6.charges * 100, 2), '%'), '-') as 'rio'
+        FROM kuaishou_account_report_hourly_dw t1
+        LEFT JOIN `jeecg-boot`.ctop_product t2 ON t2.id = t1.product_id
+        LEFT JOIN `jeecg-boot`.sys_user t3 ON t1.sale_id = t3.id
+        LEFT JOIN `jeecg-boot`.sys_user t4 ON t1.user_id = t4.id
+        LEFT JOIN (
+        SELECT tt2.project_id, sum(1) as 'num'
+        FROM app_kuaishou_material_info tt1
+        LEFT JOIN kuaishou_project_material_relation tt2 ON tt1.material_id = tt2.signature
+        WHERE media_time = DATE_FORMAT(DATE_SUB(#{startTime}, INTERVAL 1 DAY ), '%Y%m%d')
+        AND tt1.company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b' , 'd57fecdcf7a94d009736d9c850731582')
+        <if test="projectId != null and projectId != ''">
+            AND project_id = #{projectId}
+        </if>
+        <if test="projectId == null">
+            GROUP BY project_id
+        </if>
+        ) t5 ON t1.project_id = t5.project_id
+        LEFT JOIN (
+        SELECT project_id, SUM(charge) as 'charges'
+        FROM kuaishou_account_report_hourly_dw
+        WHERE stat_date = DATE_FORMAT(DATE_SUB(#{startTime}, INTERVAL 1 DAY ), '%Y%m%d')
+        AND hour &lt;= #{hour}
+        AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b' , 'd57fecdcf7a94d009736d9c850731582')
+        <if test="projectId != null and projectId != ''">
+            AND project_id = #{projectId}
+        </if>
+        <if test="projectId == null">
+            GROUP BY project_id
+        </if>
+        ) t6 ON t1.project_id = t6.project_id
+        WHERE stat_date = #{startTime}
+        AND t1.company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b' , 'd57fecdcf7a94d009736d9c850731582')
+        <if test="projectId != null and projectId != ''">
+            AND t1.project_id = #{projectId}
+        </if>
+        <if test="projectId == null">
+            GROUP BY t1.project_id
+            ORDER BY sum(charge) desc
+        </if>
+    </select>
+
+
+    <select id="getProjectMoreDaysReportTotal" resultType="Long">
+        SELECT IFNULL(sum(1), 0)
+        FROM (
+        SELECT 1
+        FROM kuaishou_account_report_daily_dw
+        WHERE stat_date >= #{startTime}
+        AND stat_date &lt;= #{endTime}
+        AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b' , 'd57fecdcf7a94d009736d9c850731582')
+        <if test="projectId != null and projectId != ''">
+            AND project_id = #{projectId}
+        </if>
+        GROUP BY project_id
+        ) t
+    </select>
+
+
+    <select id="getProjectMoreDaysReport" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.project_id as 'projectId',
+        project_name as 'projectName',
+        t2.product_name as 'productName',
+        company_name as 'companyName',
+        t3.realname as 'saler',
+        t4.realname as 'operater',
+        sum(charge) as 'charge',
+        SUM(aclick) as 'aclick',
+        SUM(bclick) as 'bclick',
+        IFNULL(t5.num,0) as 'num',
+        '-' as 'rio'
+        FROM kuaishou_account_report_daily_dw t1
+        LEFT JOIN `jeecg-boot`.ctop_product t2 ON t2.id = t1.product_id
+        LEFT JOIN `jeecg-boot`.sys_user t3 ON t1.sale_id = t3.id
+        LEFT JOIN `jeecg-boot`.sys_user t4 ON t1.user_id = t4.id
+        LEFT JOIN (
+        SELECT tt2.project_id,sum(1) as 'num' FROM app_kuaishou_material_info tt1
+        LEFT JOIN kuaishou_project_material_relation tt2 ON tt1.material_id = tt2.signature
+        WHERE media_time >= #{startTime}
+        AND media_time &lt;= #{endTime}
+        AND company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b' , 'd57fecdcf7a94d009736d9c850731582')
+        <if test="projectId != null and projectId != ''">
+            AND project_id = #{projectId}
+        </if>
+        <if test="projectId == null">
+            GROUP BY project_id
+        </if>
+        ) t5 ON t1.project_id = t5.project_id
+        WHERE stat_date >= #{startTime}
+        AND stat_date &lt;= #{endTime}
+        AND t1.company_id in ('5e46b5dea3d740eeb8ff1a2895015a4b' , 'd57fecdcf7a94d009736d9c850731582')
+        <if test="projectId != null and projectId != ''">
+            AND t1.project_id = #{projectId}
+        </if>
+        <if test="projectId == null">
+            GROUP BY t1.project_id
+            ORDER BY sum(charge) desc
+        </if>
+    </select>
+
 </mapper>

+ 10 - 3
jeecg-boot-report/src/main/java/cn/com/ctop/report/service/IBytedanceAccountReportDailyDwService.java

@@ -1,14 +1,21 @@
 package cn.com.ctop.report.service;
 
-import cn.com.ctop.report.entity.KuaishouAccountReportDailyDw;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
 
 import java.math.BigDecimal;
+import java.text.ParseException;
 import java.util.List;
+import java.util.Map;
 
-public interface IBytedanceAccountReportDailyDwService  {
+public interface IBytedanceAccountReportDailyDwService {
 
     List<JSONObject> getListDataByParams(String mediaId, BigDecimal discount, JSONArray accounts, String startDate, String endDate, int hour, String target, String order);
+
+    JSONObject getTotalCharge(Map<String, Object> paramsMap);
+
+    JSONObject getTrendCharge(Long projectId,String startTime, String endTime);
+
+    Result<Object> getProjectReport(Long projectId, String startTime, String endTime, Integer pageSize, Integer pageNo) throws Exception;
 }

+ 9 - 0
jeecg-boot-report/src/main/java/cn/com/ctop/report/service/IKuaishouAccountReportDailyDwService.java

@@ -4,11 +4,20 @@ import cn.com.ctop.report.entity.KuaishouAccountReportDailyDw;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
 
 import java.math.BigDecimal;
+import java.text.ParseException;
 import java.util.List;
+import java.util.Map;
 
 public interface IKuaishouAccountReportDailyDwService extends IService<KuaishouAccountReportDailyDw> {
 
     List<JSONObject> getListDataByParams(String mediaId, BigDecimal discount, JSONArray accounts, String startDate, String endDate, int hour, String target, String order);
+
+    JSONObject getTotalCharge(Map<String, Object> paramsMap);
+
+    JSONObject getTrendCharge(Long projectId, String startTime, String endTime);
+
+    Result<Object> getProjectReport(Long projectId, String startTime, String endTime, Integer pageSize, Integer pageNo) throws Exception;
 }

+ 82 - 19
jeecg-boot-report/src/main/java/cn/com/ctop/report/service/impl/BytedanceAccountReportDailyDwServiceImpl.java

@@ -8,6 +8,9 @@ import cn.com.ctop.report.mapper.BytedanceAccountReportHourlyDwMapper;
 import cn.com.ctop.report.service.IBytedanceAccountReportDailyDwService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.constant.SystemDateConstant;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.stereotype.Service;
@@ -15,7 +18,9 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 @Service
 public class BytedanceAccountReportDailyDwServiceImpl implements IBytedanceAccountReportDailyDwService {
@@ -41,14 +46,14 @@ public class BytedanceAccountReportDailyDwServiceImpl implements IBytedanceAccou
                 result = bytedanceAccountReportHourlyDwMapper.getReportByParams(filedAll, startDateNum, hour, accounts, target, order, 1, groupBy);
                 JSONObject afterSum = bytedanceAccountReportHourlyDwMapper.getReportByParams(filedAll, startDateNum, hour, accounts, target, order, 0, groupBy).get(0);
                 JSONObject beforeSum = bytedanceAccountReportHourlyDwMapper.getReportByParams(filedAll, anotherStartDateNum, hour, accounts, target, order, 0, groupBy).get(0);
-                if(result.size()>0){
-                    afterSum.put("statDate","总计");
-                    afterSum.put("accountId","-");
-                    afterSum.put("authName","-");
-
-                    beforeSum.put("statDate","昨日总计-(相-对)");
-                    beforeSum.put("accountId","-");
-                    beforeSum.put("authName","-");
+                if (result.size() > 0) {
+                    afterSum.put("statDate", "总计");
+                    afterSum.put("accountId", "-");
+                    afterSum.put("authName", "-");
+
+                    beforeSum.put("statDate", "昨日总计-(相-对)");
+                    beforeSum.put("accountId", "-");
+                    beforeSum.put("authName", "-");
                     result.add(afterSum);
                     result.add(beforeSum);
                 }
@@ -57,14 +62,14 @@ public class BytedanceAccountReportDailyDwServiceImpl implements IBytedanceAccou
                 result = bytedanceAccountReportDailyDwMapper.getReportByParams(filedAll, endDateNum, startDateNum, accounts, target, order, 1, groupBy);
                 JSONObject afterSum = bytedanceAccountReportDailyDwMapper.getReportByParams(filedAll, endDateNum, startDateNum, accounts, target, order, 0, groupBy).get(0);
                 JSONObject beforeSum = bytedanceAccountReportDailyDwMapper.getReportByParams(filedAll, anotherEndDateNum, anotherStartDateNum, accounts, target, order, 0, groupBy).get(0);
-                if(result.size()>0){
-                    afterSum.put("statDate","总计");
-                    afterSum.put("accountId","-");
-                    afterSum.put("authName","-");
+                if (result.size() > 0) {
+                    afterSum.put("statDate", "总计");
+                    afterSum.put("accountId", "-");
+                    afterSum.put("authName", "-");
 
-                    beforeSum.put("statDate","昨日总计-(相-对)");
-                    beforeSum.put("accountId","-");
-                    beforeSum.put("authName","-");
+                    beforeSum.put("statDate", "昨日总计-(相-对)");
+                    beforeSum.put("accountId", "-");
+                    beforeSum.put("authName", "-");
 
                     result.add(afterSum);
                     result.add(beforeSum);
@@ -78,10 +83,10 @@ public class BytedanceAccountReportDailyDwServiceImpl implements IBytedanceAccou
             result = bytedanceAccountReportDailyDwMapper.getReportByParams(filedAll, endDateNum, startDateNum, accounts, target, order, 1, groupBy);
             List<JSONObject> totalList = bytedanceAccountReportDailyDwMapper.getReportByParams(filedAll, endDateNum, startDateNum, accounts, target, order, 0, groupBy);
             if (result.size() > 0 && null != totalList && !totalList.isEmpty()) {
-                JSONObject jsonObject= totalList.get(0);
-                jsonObject.put("statDate","总计");
-                jsonObject.put("accountId","-");
-                jsonObject.put("authName","-");
+                JSONObject jsonObject = totalList.get(0);
+                jsonObject.put("statDate", "总计");
+                jsonObject.put("accountId", "-");
+                jsonObject.put("authName", "-");
                 result.add(jsonObject);
             }
         }
@@ -101,4 +106,62 @@ public class BytedanceAccountReportDailyDwServiceImpl implements IBytedanceAccou
         });
         return jsonObject;
     }
+
+
+    @Override
+    public JSONObject getTotalCharge(Map<String, Object> paramsMap) {
+        JSONObject by = bytedanceAccountReportDailyDwMapper.getTotalCharge(paramsMap);
+        Long count = bytedanceAccountReportDailyDwMapper.getYesterdayUploadNewMaterialCount(paramsMap);
+        by.put("bytedanceCount", count);
+        return by;
+    }
+
+    @Override
+    public JSONObject getTrendCharge(Long projectId, String startTime, String endTime) {
+        Integer startTimeInt = DateUtils.getDateInteger(startTime);
+        Integer endTimeInt = DateUtils.getDateInteger(endTime);
+
+        List<JSONObject> today = null;
+        List<JSONObject> yesterday = null;
+        if (startTime.equals(endTime)) {
+            today = bytedanceAccountReportDailyDwMapper.getHourCost(projectId, startTimeInt);
+            yesterday = bytedanceAccountReportDailyDwMapper.getHourCost(projectId, DateUtils.getDateInteger(DateUtils.getLastDay(startTime, 1)));
+        } else {
+            today = bytedanceAccountReportDailyDwMapper.getDataCost(projectId, startTimeInt, endTimeInt);
+            int days = DateUtils.dateDiff(startTime, endTime);
+            String endTime2 = DateUtils.getLastDay(startTime, 1);
+            String startTime2 = DateUtils.getLastDay(endTime2, days);
+            yesterday = bytedanceAccountReportDailyDwMapper.getDataCost(projectId, DateUtils.getDateInteger(startTime2), DateUtils.getDateInteger(endTime2));
+        }
+        JSONObject data = new JSONObject();
+        data.put("today", today);
+        data.put("yesterday", yesterday);
+        return data;
+    }
+
+    @Override
+    public Result<Object> getProjectReport(Long projectId, String startTime, String endTime, Integer pageSize, Integer pageNo) throws Exception {
+        Integer startTimeInt = DateUtils.getDateInteger(startTime);
+        Integer endTimeInt = DateUtils.getDateInteger(endTime);
+        //当前小时
+        Integer nowHour = DateUtils.getNowHour();
+        //当天日期
+        String today = DateUtils.formatDate(new Date());
+        List<JSONObject> data = null;
+        Long total = null;
+        if (startTime.equals(endTime) && today.equals(startTime)) {
+            total = bytedanceAccountReportDailyDwMapper.getProjectToDayReportTotal(projectId, startTimeInt, nowHour);
+            PageHelper.startPage(pageNo, pageSize, false);
+            data = bytedanceAccountReportDailyDwMapper.getProjectToDayReport(projectId, startTimeInt, nowHour);
+        } else {
+            total = bytedanceAccountReportDailyDwMapper.getProjectMoreDaysReportTotal(projectId, startTimeInt, endTimeInt, nowHour);
+            PageHelper.startPage(pageNo, pageSize, false);
+            data = bytedanceAccountReportDailyDwMapper.getProjectMoreDaysReport(projectId, startTimeInt, endTimeInt, nowHour);
+        }
+        PageInfo<JSONObject> page = new PageInfo<>();
+        page.setList(data);
+        page.setTotal(total);
+        return Result.OK(page);
+    }
+
 }

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

@@ -4,13 +4,15 @@ import cn.com.ctop.common.constant.AccountReportConstants;
 import cn.com.ctop.common.utils.JsonResourceUtil;
 import cn.com.ctop.common.utils.LinkUtils;
 import cn.com.ctop.report.entity.KuaishouAccountReportDailyDw;
-import cn.com.ctop.report.entity.KuaishouAccountReportHourlyDw;
 import cn.com.ctop.report.mapper.KuaishouAccountReportDailyDwMapper;
 import cn.com.ctop.report.mapper.KuaishouAccountReportHourlyDwMapper;
 import cn.com.ctop.report.service.IKuaishouAccountReportDailyDwService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.constant.SystemDateConstant;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.stereotype.Service;
@@ -18,7 +20,9 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 @Service
 public class KuaishouAccountReportDailyDwServiceImpl extends ServiceImpl<KuaishouAccountReportDailyDwMapper, KuaishouAccountReportDailyDw> implements IKuaishouAccountReportDailyDwService {
@@ -31,25 +35,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());
-        Long startDateNum = Long.parseLong(startDate.replace("-",""));
-        Long anotherStartDateNum = Long.parseLong(DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1).replace("-",""));
+        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("-",""));
+        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, 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 = 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, 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 = 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));
@@ -59,9 +63,9 @@ public class KuaishouAccountReportDailyDwServiceImpl extends ServiceImpl<Kuaisho
             if (accounts.size() > 1) {
                 groupBy = "account_id";
             }
-            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 = 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));
             }
         }
@@ -81,4 +85,63 @@ public class KuaishouAccountReportDailyDwServiceImpl extends ServiceImpl<Kuaisho
         });
         return jsonObject;
     }
+
+
+    @Override
+    public JSONObject getTotalCharge(Map<String, Object> paramsMap) {
+        JSONObject ks = kuaishouAccountReportDailyDwMapper.getTotalCharge(paramsMap);
+        Long count = kuaishouAccountReportDailyDwMapper.getYesterdayUploadNewMaterialCount(paramsMap);
+        ks.put("kuaishouCount", count);
+        return ks;
+    }
+
+    @Override
+    public JSONObject getTrendCharge(Long projectId, String startTime, String endTime) {
+        Integer startTimeInt = DateUtils.getDateInteger(startTime);
+        Integer endTimeInt = DateUtils.getDateInteger(endTime);
+
+        List<JSONObject> today = null;
+        List<JSONObject> yesterday = null;
+        if (startTime.equals(endTime)) {
+            today = kuaishouAccountReportDailyDwMapper.getHourcharge(projectId, startTimeInt);
+            yesterday = kuaishouAccountReportDailyDwMapper.getHourcharge(projectId, DateUtils.getDateInteger(DateUtils.getLastDay(startTime, 1)));
+        } else {
+            today = kuaishouAccountReportDailyDwMapper.getDatacharge(projectId, startTimeInt, endTimeInt);
+            int days = DateUtils.dateDiff(startTime, endTime);
+            String endTime2 = DateUtils.getLastDay(startTime, 1);
+            String startTime2 = DateUtils.getLastDay(endTime2, days);
+            yesterday = kuaishouAccountReportDailyDwMapper.getDatacharge(projectId, DateUtils.getDateInteger(startTime2), DateUtils.getDateInteger(endTime2));
+        }
+        JSONObject data = new JSONObject();
+        data.put("today", today);
+        data.put("yesterday", yesterday);
+        return data;
+    }
+
+    @Override
+    public Result<Object> getProjectReport(Long projectId, String startTime, String endTime, Integer pageSize, Integer pageNo) throws Exception {
+        Integer startTimeInt = DateUtils.getDateInteger(startTime);
+        Integer endTimeInt = DateUtils.getDateInteger(endTime);
+        //当前小时
+        Integer nowHour = DateUtils.getNowHour();
+        //当天日期
+        String today = DateUtils.formatDate(new Date());
+        List<JSONObject> data = null;
+        Long total = null;
+        if (startTime.equals(endTime) && today.equals(startTime)) {
+            total = kuaishouAccountReportDailyDwMapper.getProjectToDayReportTotal(projectId, startTimeInt, nowHour);
+            PageHelper.startPage(pageNo, pageSize, false);
+            data = kuaishouAccountReportDailyDwMapper.getProjectToDayReport(projectId, startTimeInt, nowHour);
+        } else {
+            total = kuaishouAccountReportDailyDwMapper.getProjectMoreDaysReportTotal(projectId, startTimeInt, endTimeInt, nowHour);
+            PageHelper.startPage(pageNo, pageSize, false);
+            data = kuaishouAccountReportDailyDwMapper.getProjectMoreDaysReport(projectId, startTimeInt, endTimeInt, nowHour);
+        }
+        PageInfo<JSONObject> page = new PageInfo<>();
+        page.setList(data);
+        page.setTotal(total);
+        return Result.OK(page);
+    }
+
+
 }