yangzian 3 rokov pred
rodič
commit
46368332db

+ 21 - 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -1814,4 +1814,25 @@ public class DateUtils extends PropertyEditorSupport {
     }
 
 
+    /**
+     * 获取当前月份第一天
+     * @return 返回格式:20220119
+     * zian Y
+     */
+    public static Integer getFirstDayByMonth() {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar c = Calendar.getInstance();
+        c.add(Calendar.MONTH, 0);
+        c.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
+        String first = format.format(c.getTime());
+        return getDateInteger(first);
+    }
+
+
+    public static void main(String[] args) {
+        System.out.println(DateUtils.getFirstDayByMonth());
+    }
+
+
+
 }

+ 65 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/controller/BossDataExhibitionController.java

@@ -40,6 +40,71 @@ public class BossDataExhibitionController {
 
 
 
+    @ApiOperation(value="分公司素材消耗", notes="分公司素材消耗")
+    @GetMapping(value = "/getCompanyMeterialConsume")
+    public Result getCompanyMeterialConsume(
+            @RequestParam(name="mediaType",defaultValue = "2") String mediaType,
+            @RequestParam(name="startTime") String startTime,
+            @RequestParam(name="endTime") String endTime) {
+        return bossDataExhibitionServiceImpl.getCompanyMeterialConsume(mediaType,startTime,endTime);
+    }
+
+
+
+
+    @ApiOperation(value="素材相关-使用率;爆款率;创新率", notes="素材相关-使用率;爆款率;创新率")
+    @GetMapping(value = "/getMeterialRelevantInfo")
+    public Result getMeterialRelevantInfo(
+            @RequestParam(name="mediaType",defaultValue = "2") String mediaType,
+            @RequestParam(name="startTime") String startTime,
+            @RequestParam(name="endTime") String endTime) {
+        return bossDataExhibitionServiceImpl.getMeterialRelevantInfo(mediaType,startTime,endTime);
+    }
+
+
+
+    @ApiOperation(value="分公司投放数据", notes="分公司投放数据")
+    @GetMapping(value = "/getCompanyAccountDataInfo")
+    public Result getCompanyAccountDataInfo(
+            @RequestParam(name="mediaType",defaultValue = "2") String mediaType,
+            @RequestParam(name="startTime") String startTime,
+            @RequestParam(name="endTime") String endTime) {
+        return bossDataExhibitionServiceImpl.getCompanyAccountDataInfo(mediaType,startTime,endTime);
+    }
+
+
+
+    @ApiOperation(value="分媒体投放数据", notes="分媒体投放数据")
+    @GetMapping(value = "/getAccountDataByMediaType")
+    public Result getAccountDataByMediaType() {
+        return bossDataExhibitionServiceImpl.getAccountDataByMediaType();
+    }
+
+
+    @ApiOperation(value="分媒体公司消耗-账户维度-分日数据-折线图", notes="分媒体公司消耗-账户维度-分日数据-折线图")
+    @GetMapping(value = "/getAccountTrendByMediaType")
+    public Result getAccountTrendByMediaType(
+            @RequestParam(name="mediaType",defaultValue = "2") String mediaType,
+            @RequestParam(name="startTime") String startTime,
+            @RequestParam(name="endTime") String endTime) {
+        return bossDataExhibitionServiceImpl.getAccountTrendByMediaType(mediaType,startTime,endTime);
+    }
+
+
+    @ApiOperation(value="项目消耗排行top10", notes="项目消耗排行top10")
+    @GetMapping(value = "/getProjectCostTopTenByMediaType")
+    public Result getProjectCostTopTenByMediaType(
+            @RequestParam(name="mediaType",defaultValue = "2") String mediaType,
+            @RequestParam(name="startTime") String startTime,
+            @RequestParam(name="endTime") String endTime) {
+        return bossDataExhibitionServiceImpl.getProjectCostTopTenByMediaType(mediaType,startTime,endTime);
+    }
+
+
+
+
+
+
 
 
 

+ 18 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/entity/AccountTrendPojo.java

@@ -0,0 +1,18 @@
+package org.jeecg.ctop.material.entity;
+
+import lombok.Data;
+
+/**
+ * 数据看板 折线图
+ * zian Y
+ * 2022/1/19
+ **/
+
+@Data
+public class AccountTrendPojo {
+
+    private String time;
+    private String cost;
+    private String area;
+
+}

+ 120 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/BossDataExhibitionMapper.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
+import org.jeecg.ctop.material.entity.AccountTrendPojo;
 
 import java.math.BigDecimal;
 import java.util.List;
@@ -28,4 +29,123 @@ public interface BossDataExhibitionMapper {
      * @return
      */
     List<Map<String,Object>> getMeterialProduceRateBytedance(@Param("startTime") Integer startTime,@Param("endTime") Integer endTime);
+
+    /**
+     * 分公司素材消耗 头条
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<Map<String,Object>> getCompanyMeterialConsumeBytedance(@Param("startTime") Integer startTime,@Param("endTime") Integer endTime);
+
+    /**
+     * 分公司素材消耗 快手
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<Map<String,Object>> getCompanyMeterialConsumeKuaishou(@Param("startTime") Integer startTime,@Param("endTime") Integer endTime);
+
+    /**
+     * 素材相关===素材使用率===头条
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<Map<String,Object>> getMeterialUseRateBytedanc(@Param("startTime") Integer startTime,@Param("endTime") Integer endTime);
+
+    /**
+     * 素材相关===素材使用率===快手
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<Map<String,Object>> getMeterialUseRateKuaishou(@Param("startTime") Integer startTime,@Param("endTime") Integer endTime);
+
+    /**
+     * 素材相关===素材爆款率===头条
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<Map<String,Object>> getMeterialFaddishRateBytedance(@Param("startTime") Integer startTime,@Param("endTime") Integer endTime);
+
+    /**
+     * 素材相关===素材爆款率===快手
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<Map<String,Object>> getMeterialFaddishRateKuaishou(@Param("startTime") Integer startTime,@Param("endTime") Integer endTime);
+
+    /**
+     * 素材相关===素材创新率===头条
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<Map<String,Object>> getMeterialInnovateRateBytedance(@Param("startTime") Integer startTime,@Param("endTime") Integer endTime);
+
+    /**
+     * 素材相关===素材创新率===快手
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<Map<String,Object>> getMeterialInnovateRateKuaishou(@Param("startTime") Integer startTime,@Param("endTime") Integer endTime);
+
+    /**
+     * 分公司投放数据-账户-头条
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<Map<String,Object>> getCompanyAccountDataBytedance(@Param("startTime") Integer startTime,@Param("endTime") Integer endTime);
+
+    /**
+     * 分公司投放数据-账户-快手
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<Map<String,Object>> getCompanyAccountDataKuaishou(@Param("startTime") Integer startTime,@Param("endTime") Integer endTime);
+
+    /**
+     * 分媒体投放数据-账户维度
+     * @param firstDay 本月第一天
+     * @return
+     */
+    List<Map<String,Object>> getMediaTypeAccountData(@Param("firstDay") Integer firstDay);
+
+    /**
+     * 分媒体公司消耗-账户维度-分日数据 -折线图-头条
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<AccountTrendPojo> getMediaTypeAccountTrendBytedance(@Param("startTime") Integer startTime, @Param("endTime") Integer endTime);
+
+    /**
+     * 分媒体公司消耗-账户维度-分日数据 -折线图-快手
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<AccountTrendPojo> getMediaTypeAccountTrendKuaishou(@Param("startTime") Integer startTime,@Param("endTime") Integer endTime);
+
+    /**
+     * 项目消耗排行 top10 头条
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<Map<String,Object>> getMediaTypeProjectCostBytedance(@Param("startTime") Integer startTime,@Param("endTime") Integer endTime);
+
+    /**
+     * 项目消耗排行 top10 快手
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<Map<String,Object>> getMediaTypeProjectCostKuaishou(@Param("startTime") Integer startTime,@Param("endTime") Integer endTime);
 }

+ 526 - 5
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/BossDataExhibitionMapper.xml

@@ -5,7 +5,7 @@
     <!--  素材产出占比 快手 -->
     <select id="getMeterialProduceRateKuaiShou" resultType="java.util.LinkedHashMap">
         SELECT t.* ,
-        CONCAT(ROUND(t.meterialNum / t.total,2) ,'%')as rate
+        CONCAT(ROUND(t.meterialNum / t.total * 100,2) ,'%')as rate
         from (
         SELECT
         COUNT( material_id ) meterialNum ,
@@ -19,7 +19,7 @@
         end area,
         company_name as companyName,
         (SELECT COUNT(material_id) as num
-        FROM app_kuaishou_material_info
+        FROM application.app_kuaishou_material_info
             <where>
                 <if test="startTime !=null and startTime != ''">
                     AND media_time &gt;= #{startTime}
@@ -30,7 +30,7 @@
             </where>
             ) as total
         FROM
-        app_kuaishou_material_info
+        application.app_kuaishou_material_info
         <where>
             <if test="startTime !=null and startTime != ''">
                 AND media_time &gt;= #{startTime}
@@ -62,7 +62,7 @@
         end area,
         company_name as companyName,
         (SELECT COUNT(material_id) as num
-            FROM app_bytedance_material_info
+            FROM application.app_bytedance_material_info
             <where>
                 <if test="startTime !=null and startTime != ''">
                     AND media_time &gt;= #{startTime}
@@ -73,7 +73,7 @@
             </where>
             ) as total
         FROM
-        app_bytedance_material_info
+        application.app_bytedance_material_info
         <where>
             <if test="startTime !=null and startTime != ''">
                 AND media_time &gt;= #{startTime}
@@ -84,7 +84,528 @@
         </where>
         GROUP BY
         company_id) t
+    </select>
+
+    <!--  分公司素材消耗 头条 -->
+    <select id="getCompanyMeterialConsumeBytedance" resultType="java.util.LinkedHashMap">
+        SELECT
+        t.*,
+        SUM(t.cost) tcost
+        FROM
+        (
+        SELECT
+        company_id,
+        company_name,
+        SUM(cost) cost,
+        CASE
+        company_id
+        WHEN 'd57fecdcf7a94d009736d9c850731582' THEN '华北'
+        WHEN '6608ed13c0dd42de93c790dbdf124234' THEN '华南'
+        WHEN '4b10089775c040119e139087517aed88' THEN '华东'
+        WHEN '3321d5893bcd430cab1238a99bc7db11' THEN '石家庄'
+        WHEN '5e46b5dea3d740eeb8ff1a2895015a4b' THEN '骄阳'
+        WHEN '1648c7ceb4d449a9a13fbed7a8d9976c' THEN '杭州'
+        ELSE '其他'
+        END area,
+        ( SELECT SUM(cost) FROM application.bytedance_material_video_report_daily_dw
+        <where>
+            <if test="startTime !=null and startTime != ''">
+                AND stat_datetime &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND stat_datetime &lt;= #{endTime}
+            </if>
+        </where>
+            ) totalCost
+        FROM
+        application.bytedance_material_video_report_daily_dw
+        <where>
+            <if test="startTime !=null and startTime != ''">
+                AND stat_datetime &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND stat_datetime &lt;= #{endTime}
+            </if>
+        </where>
+        GROUP BY
+        company_id ) t
+        GROUP BY
+        t.area;
+    </select>
+
+    <!--  分公司素材消耗 快手 -->
+    <select id="getCompanyMeterialConsumeKuaishou" resultType="java.util.LinkedHashMap">
+        SELECT t.*,
+        SUM(t.cost) as tcost
+        from (
+        SELECT company_id,company_name,SUM(charge) cost,
+        CASE company_id
+        WHEN 'd57fecdcf7a94d009736d9c850731582' then '华北'
+        WHEN '6608ed13c0dd42de93c790dbdf124234' then '华南'
+        WHEN '4b10089775c040119e139087517aed88' then '华东'
+        WHEN '3321d5893bcd430cab1238a99bc7db11' then '石家庄'
+        WHEN '5e46b5dea3d740eeb8ff1a2895015a4b' then '骄阳'
+        WHEN '1648c7ceb4d449a9a13fbed7a8d9976c' then '杭州'
+        else '其他'
+        end area,
+        (SELECT SUM(charge) from application.kuaishou_material_video_report_daily_dw
+        <where>
+            <if test="startTime !=null and startTime != ''">
+                AND stat_date &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND stat_date &lt;= #{endTime}
+            </if>
+        </where>) totalCost
+        FROM
+        application.kuaishou_material_video_report_daily_dw
+        <where>
+            <if test="startTime !=null and startTime != ''">
+                AND stat_date &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND stat_date &lt;= #{endTime}
+            </if>
+        </where>
+        GROUP BY
+        company_id
+        ) t
+        GROUP BY t.area;
+    </select>
+
+    <!--  素材相关===素材使用率===头条 -->
+    <select id="getMeterialUseRateBytedanc" resultType="java.util.LinkedHashMap">
+        SELECT t.*,
+        CONCAT(ROUND(t.bytedanceTatol / t.total * 100,2) ,'%') as useRate
+        from (
+        SELECT COUNT(material_id) total,
+        (SELECT COUNT(material_id) tatol from application.app_bytedance_material_info
+        where sync_bytedance = 2
+            <if test="startTime !=null and startTime != ''">
+                AND help_time &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND help_time &lt;= #{endTime}
+            </if>
+            ) as bytedanceTatol
+        FROM
+        application.app_bytedance_material_info
+        <where>
+            <if test="startTime !=null and startTime != ''">
+                AND help_time &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND help_time &lt;= #{endTime}
+            </if>
+        </where>
+        ) t
+    </select>
+
+
+    <!--  素材相关===素材使用率===快手 -->
+    <select id="getMeterialUseRateKuaishou" resultType="java.util.LinkedHashMap">
+        SELECT t.*,
+        CONCAT(ROUND(t.kuaiShouTatol / t.total * 100,2) ,'%') as useRate
+        from (
+        SELECT COUNT(material_id) total,
+        (SELECT COUNT(material_id) tatol from application.app_kuaishou_material_info
+        where sync_kuaishou = 2
+            <if test="startTime !=null and startTime != ''">
+                AND help_time &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND help_time &lt;= #{endTime}
+            </if>
+            ) as kuaiShouTatol
+        FROM
+        application.app_kuaishou_material_info
+        <where>
+            <if test="startTime !=null and startTime != ''">
+                AND help_time &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND help_time &lt;= #{endTime}
+            </if>
+        </where>
+        ) t
+    </select>
+
+<!--  素材相关===素材爆款率===头条 -->
+    <select id="getMeterialFaddishRateBytedance" resultType="java.util.LinkedHashMap">
+        SELECT t.*,
+        CONCAT(ROUND(t.faddish / t.total * 100,2) ,'%') as faddishRate
+        FROM
+        (
+        SELECT COUNT(material_id) total,
+        (SELECT COUNT(material_id) tatol from application.app_bytedance_material_info
+            <where>
+                <if test="startTime !=null and startTime != ''">
+                    AND faddish_date &gt;= #{startTime}
+                </if>
+                <if test="endTime !=null and endTime != ''">
+                    AND faddish_date &lt;= #{endTime}
+                </if>
+            </where>
+            ) as faddish
+        FROM
+        application.app_bytedance_material_info
+        <where>
+            <if test="startTime !=null and startTime != ''">
+                AND help_time &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND help_time &lt;= #{endTime}
+            </if>
+        </where>
+        ) t
+    </select>
+
+
+<!--  素材相关===素材爆款率===快手 -->
+    <select id="getMeterialFaddishRateKuaishou" resultType="java.util.LinkedHashMap">
+        SELECT t.*,
+        CONCAT(ROUND(t.faddish / t.total * 100,2) ,'%') as faddishRate
+        FROM
+        (
+        SELECT COUNT(material_id) total,
+        (SELECT COUNT(material_id) tatol from application.app_kuaishou_material_info
+            <where>
+                <if test="startTime !=null and startTime != ''">
+                    AND faddish_date &gt;= #{startTime}
+                </if>
+                <if test="endTime !=null and endTime != ''">
+                    AND faddish_date &lt;= #{endTime}
+                </if>
+            </where>
+            ) as faddish
+        FROM
+        application.app_kuaishou_material_info
+        <where>
+            <if test="startTime !=null and startTime != ''">
+                AND help_time &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND help_time &lt;= #{endTime}
+            </if>
+        </where>
+        ) t
+    </select>
+
+<!--  素材相关===素材创新率===头条 -->
+    <select id="getMeterialInnovateRateBytedance" resultType="java.util.LinkedHashMap">
+        SELECT t.*,
+        CONCAT(ROUND(t.innovate / t.total * 100,2) ,'%') as innovateRate
+        FROM
+        (
+        SELECT COUNT(material_id) total,
+        (SELECT COUNT(material_id) tatol from application.app_bytedance_material_info
+        where material_innovate = 2
+            <if test="startTime !=null and startTime != ''">
+                AND help_time &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND help_time &lt;= #{endTime}
+            </if>
+            ) as innovate
+        FROM
+        application.app_bytedance_material_info
+        <where>
+            <if test="startTime !=null and startTime != ''">
+                AND help_time &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND help_time &lt;= #{endTime}
+            </if>
+        </where>
+        ) t
+    </select>
+
+<!--  素材相关===素材创新率===快手 -->
+    <select id="getMeterialInnovateRateKuaishou" resultType="java.util.LinkedHashMap">
+        SELECT t.*,
+        CONCAT(ROUND(t.innovate / t.total * 100,2) ,'%') as innovateRate
+        FROM
+        (
+        SELECT COUNT(material_id) total,
+        (SELECT COUNT(material_id) tatol from application.app_kuaishou_material_info
+        where material_innovate = 2
+            <if test="startTime !=null and startTime != ''">
+                AND help_time &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND help_time &lt;= #{endTime}
+            </if>
+            ) as innovate
+        FROM
+        application.app_kuaishou_material_info
+        <where>
+            <if test="startTime !=null and startTime != ''">
+                AND help_time &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND help_time &lt;= #{endTime}
+            </if>
+        </where>
+        ) t
+    </select>
+
+<!--  分公司投放数据-账户-头条 -->
+    <select id="getCompanyAccountDataBytedance" resultType="java.util.LinkedHashMap">
+        SELECT
+        t.*,
+        SUM(t.cost) tcost,
+        CONCAT(ROUND(SUM(t.cost) / t.totalCost * 100,2) ,'%')as rate
+        FROM
+        (
+        SELECT
+        company_id,
+        company_name,
+        SUM(cost) cost,
+        CASE
+        company_id
+        WHEN 'd57fecdcf7a94d009736d9c850731582' THEN '华北'
+        WHEN '6608ed13c0dd42de93c790dbdf124234' THEN '华南'
+        WHEN '4b10089775c040119e139087517aed88' THEN '华东'
+        WHEN '3321d5893bcd430cab1238a99bc7db11' THEN '石家庄'
+        WHEN '5e46b5dea3d740eeb8ff1a2895015a4b' THEN '骄阳'
+        WHEN '1648c7ceb4d449a9a13fbed7a8d9976c' THEN '杭州'
+        ELSE '其他'
+        END area,
+        ( SELECT SUM(cost) FROM application.bytedance_advertiser_report_daily_dw
+            <where>
+                <if test="startTime !=null and startTime != ''">
+                    AND stat_datetime &gt;= #{startTime}
+                </if>
+                <if test="endTime !=null and endTime != ''">
+                    AND stat_datetime &lt;= #{endTime}
+                </if>
+            </where>
+            ) totalCost
+        FROM
+        application.bytedance_advertiser_report_daily_dw
+        <where>
+            <if test="startTime !=null and startTime != ''">
+                AND stat_datetime &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND stat_datetime &lt;= #{endTime}
+            </if>
+        </where>
+        GROUP BY
+        company_id ) t
+        GROUP BY
+        t.area;
+    </select>
+
+
+<!--  分公司投放数据-账户-快手 -->
+    <select id="getCompanyAccountDataKuaishou" resultType="java.util.LinkedHashMap">
+        SELECT
+        t.*,
+        SUM(t.cost) tcost,
+        CONCAT(ROUND(SUM(t.cost) / t.totalCost * 100,2) ,'%')as rate
+        FROM
+        (
+        SELECT
+        company_id,
+        company_name,
+        SUM(charge) cost,
+        CASE
+        company_id
+        WHEN 'd57fecdcf7a94d009736d9c850731582' THEN '华北'
+        WHEN '6608ed13c0dd42de93c790dbdf124234' THEN '华南'
+        WHEN '4b10089775c040119e139087517aed88' THEN '华东'
+        WHEN '3321d5893bcd430cab1238a99bc7db11' THEN '石家庄'
+        WHEN '5e46b5dea3d740eeb8ff1a2895015a4b' THEN '骄阳'
+        WHEN '1648c7ceb4d449a9a13fbed7a8d9976c' THEN '杭州'
+        ELSE '其他'
+        END area,
+        ( SELECT SUM(charge) FROM application.kuaishou_account_report_daily_dw
+            <where>
+                <if test="startTime !=null and startTime != ''">
+                    AND stat_date &gt;= #{startTime}
+                </if>
+                <if test="endTime !=null and endTime != ''">
+                    AND stat_date &lt;= #{endTime}
+                </if>
+            </where>
+            ) totalCost
+        FROM
+        application.kuaishou_account_report_daily_dw
+        <where>
+            <if test="startTime !=null and startTime != ''">
+                AND stat_date &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND stat_date &lt;= #{endTime}
+            </if>
+        </where>
+        GROUP BY
+        company_id ) t
+        GROUP BY
+        t.area;
+    </select>
+
+
+
+
+<!--  分媒体投放数据-账户维度 -->
+    <select id="getMediaTypeAccountData" resultType="java.util.LinkedHashMap">
+        SELECT
+            t.stat_datetime as time,
+            t.bCost as bytedanceCost,
+            k.KCost as kuaishouCost
+        from
+            (
+                SELECT
+                stat_datetime,
+                SUM(cost) bCost
+                FROM
+                application.bytedance_advertiser_report_daily_dw
+                <where>
+                    <if test="firstDay !=null and firstDay != ''">
+                        AND stat_datetime &gt;= #{firstDay}
+                    </if>
+                </where>
+                GROUP BY stat_datetime
+                ORDER BY stat_datetime
+            ) t
+            LEFT JOIN
+            (
+                SELECT
+                stat_date,
+                SUM(charge) KCost
+                FROM
+                application.kuaishou_account_report_daily_dw
+                <where>
+                    <if test="firstDay !=null and firstDay != ''">
+                        AND stat_date &gt;= #{firstDay}
+                    </if>
+                </where>
+                GROUP BY stat_date
+                ORDER BY stat_date
+            ) k
+        on t.stat_datetime = k.stat_date
+    </select>
+
+
+
+
+
+<!--  分媒体公司消耗-账户维度-分日数据 -折线图-头条-->
+    <select id="getMediaTypeAccountTrendBytedance" resultType="org.jeecg.ctop.material.entity.AccountTrendPojo">
+        SELECT
+            stat_datetime as time,
+            SUM(cost) as cost,
+            CASE
+                company_id
+                WHEN 'd57fecdcf7a94d009736d9c850731582' THEN '华北'
+                WHEN '6608ed13c0dd42de93c790dbdf124234' THEN '华南'
+                WHEN '4b10089775c040119e139087517aed88' THEN '华东'
+                WHEN '5e46b5dea3d740eeb8ff1a2895015a4b' THEN '骄阳'
+                ELSE '其他'
+                END area
+        FROM
+            application.bytedance_advertiser_report_daily_dw
+        <where>
+            <if test="startTime !=null and startTime != ''">
+                AND stat_datetime &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND stat_datetime &lt;= #{endTime}
+            </if>
+        </where>
+        GROUP BY stat_datetime,company_id
+        ORDER BY stat_datetime
+    </select>
+
+<!--  分媒体公司消耗-账户维度-分日数据-折线图-快手 -->
+    <select id="getMediaTypeAccountTrendKuaishou" resultType="org.jeecg.ctop.material.entity.AccountTrendPojo">
+        SELECT
+        stat_date as time,
+        SUM(charge) as cost,
+        CASE
+            company_id
+            WHEN 'd57fecdcf7a94d009736d9c850731582' THEN '华北'
+            WHEN '6608ed13c0dd42de93c790dbdf124234' THEN '华南'
+            WHEN '4b10089775c040119e139087517aed88' THEN '华东'
+            WHEN '5e46b5dea3d740eeb8ff1a2895015a4b' THEN '骄阳'
+            ELSE '其他'
+            END area
+        FROM
+        application.kuaishou_account_report_daily_dw
+        <where>
+            <if test="startTime !=null and startTime != ''">
+                AND stat_date &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND stat_date &lt;= #{endTime}
+            </if>
+        </where>
+        GROUP BY stat_date,company_id
+        ORDER BY stat_date
+    </select>
+
+
+
+
+
+    <!--  项目消耗排行 top10 头条-->
+    <select id="getMediaTypeProjectCostBytedance" resultType="java.util.LinkedHashMap">
+        SELECT
+        a.project_id as projectId,
+        a.project_name as projectName,
+        SUM(a.cost) as totalCost,
+        IFNULL(SUM(b.new_ad_num),0) as baseNum
+        FROM
+        application.bytedance_advertiser_report_daily_dw a
+        LEFT JOIN application.app_bytedance_account_base_info_d b
+        on a.project_id = b.project_id
+        <where>
+            <if test="startTime !=null and startTime != ''">
+                AND a.stat_datetime &gt;= #{startTime}
+                AND b.stat_date &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND a.stat_datetime &lt;= #{endTime}
+                AND b.stat_date &lt;= #{endTime}
+            </if>
+        </where>
+        GROUP BY a.project_id
+        ORDER BY totalCost DESC
+        limit 10
+    </select>
+
+    <!--  项目消耗排行 top10 快手-->
+    <select id="getMediaTypeProjectCostKuaishou" resultType="java.util.LinkedHashMap">
+        SELECT
+        a.project_id as projectId,
+        a.project_name as projectName,
+        SUM(a.charge) as totalCost,
+        IFNULL(SUM(b.new_unit_num),0) as baseNum
+        FROM
+        application.kuaishou_account_report_daily_dw a
+        LEFT JOIN application.app_kuaishou_account_base_info_d b
+        on a.project_id = b.project_id
+        <where>
+            <if test="startTime !=null and startTime != ''">
+                AND a.stat_date &gt;= #{startTime}
+                AND b.stat_date &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND a.stat_date &lt;= #{endTime}
+                AND b.stat_date &lt;= #{endTime}
+            </if>
+        </where>
+        GROUP BY a.project_id
+        ORDER BY totalCost DESC
+        limit 10
 
     </select>
 
+
+
+
+
+
 </mapper>

+ 13 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/IBossDataExhibitionService.java

@@ -18,4 +18,17 @@ public interface IBossDataExhibitionService {
 
     Result getMeterialProduceRate(String mediaType,String startTime, String endTime);
 
+    Result getCompanyMeterialConsume(String mediaType,String startTime, String endTime);
+
+    Result getMeterialRelevantInfo(String mediaType,String startTime, String endTime);
+
+    Result getCompanyAccountDataInfo(String mediaType,String startTime, String endTime);
+
+    Result getAccountDataByMediaType();
+
+    Result getAccountTrendByMediaType(String mediaType,String startTime, String endTime);
+
+    Result getProjectCostTopTenByMediaType(String mediaType,String startTime, String endTime);
+
+
 }

+ 169 - 16
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/BossDataExhibitionServiceImpl.java

@@ -1,29 +1,18 @@
 package org.jeecg.ctop.material.service.impl;
 
 
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.github.pagehelper.PageHelper;
-import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.util.DateUtils;
-import org.jeecg.ctop.material.constants.*;
+import org.jeecg.ctop.material.constants.Check;
+import org.jeecg.ctop.material.entity.AccountTrendPojo;
 import org.jeecg.ctop.material.mapper.BossDataExhibitionMapper;
 import org.jeecg.ctop.material.service.IBossDataExhibitionService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
+
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -44,7 +33,6 @@ public class BossDataExhibitionServiceImpl implements IBossDataExhibitionService
      * @param endTime
      * @return: org.jeecg.common.api.vo.Result
      * @author: zianY
-     * @time: 2022/1/17
      */
     @Override
     public Result getMeterialProduceRate(String mediaType, String startTime, String endTime) {
@@ -57,6 +45,171 @@ public class BossDataExhibitionServiceImpl implements IBossDataExhibitionService
         }else if (StringUtils.equals("2",mediaType)){
             resultList = bossDataExhibitionMapper.getMeterialProduceRateKuaiShou(stat_tim,end_tim);
         }
-        return Result.successMsg("1".equals(mediaType) ? "【头条】" : "【快手】"+"===素材产出占比查询成功。",resultList);
+        return Result.successMsg(("1".equals(mediaType) ? "【头条】" : "【快手】")+"===素材产出占比查询成功。",resultList);
+    }
+
+    /**
+     *
+     * @description:分公司素材消耗
+     *
+     * @param mediaType 1-头条 2-快手
+     * @param startTime
+     * @param endTime
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     */
+    @Override
+    public Result getCompanyMeterialConsume(String mediaType, String startTime, String endTime) {
+        Integer stat_tim = DateUtils.getDateInteger(startTime);
+        Integer end_tim = DateUtils.getDateInteger(endTime);
+        List<Map<String,Object>> resultList = Arrays.asList();
+        // 1-头条 2-快手
+        if (StringUtils.equals("1",mediaType)){
+            resultList = bossDataExhibitionMapper.getCompanyMeterialConsumeBytedance(stat_tim,end_tim);
+        }else if (StringUtils.equals("2",mediaType)){
+            resultList = bossDataExhibitionMapper.getCompanyMeterialConsumeKuaishou(stat_tim,end_tim);
+        }
+        return Result.successMsg(("1".equals(mediaType) ? "【头条】" : "【快手】")+"===素材消耗查询成功。",resultList);
+    }
+
+
+    /**
+     *
+     * @description: 素材相关---使用率;爆款率;创新率
+     *
+     * @param mediaType 1-头条 2-快手
+     * @param startTime
+     * @param endTime
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     */
+    @Override
+    public Result getMeterialRelevantInfo(String mediaType, String startTime, String endTime) {
+        Map<String,Object> resultMap = new HashMap<>();
+        Integer stat_tim = DateUtils.getDateInteger(startTime);
+        Integer end_tim = DateUtils.getDateInteger(endTime);
+        List<Map<String,Object>> userList = Arrays.asList();
+        List<Map<String,Object>> faddishList = Arrays.asList();
+        List<Map<String,Object>> innovateList = Arrays.asList();
+        // 1-头条 2-快手
+        if (StringUtils.equals("1",mediaType)){
+            //素材使用率
+            userList = bossDataExhibitionMapper.getMeterialUseRateBytedanc(stat_tim,end_tim);
+            //素材爆款率
+            faddishList = bossDataExhibitionMapper.getMeterialFaddishRateBytedance(stat_tim,end_tim);
+            //素材创新率
+            innovateList = bossDataExhibitionMapper.getMeterialInnovateRateBytedance(stat_tim,end_tim);
+        }else if (StringUtils.equals("2",mediaType)){
+            //素材使用率
+            userList = bossDataExhibitionMapper.getMeterialUseRateKuaishou(stat_tim,end_tim);
+            //素材爆款率
+            faddishList = bossDataExhibitionMapper.getMeterialFaddishRateKuaishou(stat_tim,end_tim);
+            //素材创新率
+            innovateList = bossDataExhibitionMapper.getMeterialInnovateRateKuaishou(stat_tim,end_tim);
+        }
+
+        resultMap.put("useRate", Check.isNull(userList) ? "0" : userList.get(0).get("useRate"));
+        resultMap.put("faddishRate",Check.isNull(faddishList) ? "0" : faddishList.get(0).get("faddishRate"));
+        resultMap.put("innovateRate",Check.isNull(innovateList) ? "0" : innovateList.get(0).get("innovateRate"));
+        return Result.successMsg(("1".equals(mediaType) ? "【头条】" : "【快手】")+"===素材相关查询成功。",resultMap);
+    }
+
+
+    /**
+     *
+     * @description: 分公司投放数据
+     *
+     * @param mediaType 1-头条 2-快手
+     * @param startTime
+     * @param endTime
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     */
+    @Override
+    public Result getCompanyAccountDataInfo(String mediaType, String startTime, String endTime) {
+        Integer stat_tim = DateUtils.getDateInteger(startTime);
+        Integer end_tim = DateUtils.getDateInteger(endTime);
+        List<Map<String,Object>> resultList = Arrays.asList();
+        // 1-头条 2-快手
+        if (StringUtils.equals("1",mediaType)){
+            resultList = bossDataExhibitionMapper.getCompanyAccountDataBytedance(stat_tim,end_tim);
+        }else if (StringUtils.equals("2",mediaType)){
+            resultList = bossDataExhibitionMapper.getCompanyAccountDataKuaishou(stat_tim,end_tim);
+        }
+        return Result.successMsg(("1".equals(mediaType) ? "【头条】" : "【快手】")+"===分公司投放数据查询成功。",resultList);
+    }
+
+
+
+
+
+    /**
+     *
+     * @description:分媒投放数据
+     *
+     * @param
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     */
+    @Override
+    public Result getAccountDataByMediaType() {
+        //获取当前月份第一天
+        Integer firstDay = DateUtils.getFirstDayByMonth();
+        return Result.successMsg("分媒体投放数据查询成功。",bossDataExhibitionMapper.getMediaTypeAccountData(firstDay));
+    }
+
+    /**
+     *
+     * @description: 分媒体公司消耗-账户维度-分日数据 -折线图-
+     *
+     * @param mediaType
+     * @param startTime
+     * @param endTime
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     */
+    @Override
+    public Result getAccountTrendByMediaType(String mediaType, String startTime, String endTime) {
+        Integer stat_tim = DateUtils.getDateInteger(startTime);
+        Integer end_tim = DateUtils.getDateInteger(endTime);
+        List<AccountTrendPojo> resultList = Arrays.asList();
+        // 1-头条 2-快手
+        if (StringUtils.equals("1",mediaType)){
+            resultList = bossDataExhibitionMapper.getMediaTypeAccountTrendBytedance(stat_tim,end_tim);
+        }else if (StringUtils.equals("2",mediaType)){
+            resultList = bossDataExhibitionMapper.getMediaTypeAccountTrendKuaishou(stat_tim,end_tim);
+        }
+        if (!Check.isNull(resultList)){
+            Map<String,List<AccountTrendPojo>> resultMap = resultList.stream().collect(Collectors.groupingBy(AccountTrendPojo::getArea));
+            return Result.successMsg(("1".equals(mediaType) ? "【头条】" : "【快手】")+"===分公司-分日-账户消耗数据查询成功。",resultMap);
+        }
+        return Result.error("暂无数据。");
+    }
+
+
+    /**
+     *
+     * @description: 项目消耗排行top10
+     *
+     * @param mediaType
+     * @param startTime
+     * @param endTime
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     */
+    @Override
+    public Result getProjectCostTopTenByMediaType(String mediaType, String startTime, String endTime) {
+        Integer stat_tim = DateUtils.getDateInteger(startTime);
+        Integer end_tim = DateUtils.getDateInteger(endTime);
+        List<Map<String,Object>> resultList = Arrays.asList();
+        // 1-头条 2-快手
+        if (StringUtils.equals("1",mediaType)){
+            resultList = bossDataExhibitionMapper.getMediaTypeProjectCostBytedance(stat_tim,end_tim);
+        }else if (StringUtils.equals("2",mediaType)){
+            resultList = bossDataExhibitionMapper.getMediaTypeProjectCostKuaishou(stat_tim,end_tim);
+        }
+        return Result.successMsg(("1".equals(mediaType) ? "【头条】" : "【快手】")+"===项目消耗排行top10查询成功。",resultList);
     }
+
+
 }