Quellcode durchsuchen

盯盘-素材占比

yangzian vor 3 Jahren
Ursprung
Commit
102ff5266d

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

@@ -1798,4 +1798,20 @@ public class DateUtils extends PropertyEditorSupport {
             return false;
         }
     }
+
+    /**
+     * 日期转int
+     * 2022-01-18 ====>>>> 20220118
+     * @param date
+     * @return
+     */
+    public static Integer getDateInteger(String date) {
+        if (!date.isEmpty()) {
+            String replace = date.replace("-", "");
+            return Integer.valueOf(replace);
+        }
+        return null;
+    }
+
+
 }

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

@@ -243,6 +243,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/task/kuaishouHostingTask/**", "anon");
         filterChainDefinitionMap.put("/audienceReport/**", "anon");
         filterChainDefinitionMap.put("/stare/**", "anon");
+        filterChainDefinitionMap.put("/boss/**", "anon");
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);
         filterMap.put("jwt", new JwtFilter());

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

@@ -0,0 +1,47 @@
+package org.jeecg.ctop.material.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.ctop.material.service.IBossDataExhibitionService;
+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;
+
+/**
+ * Administrator
+ * 2022/1/17
+ **/
+@Slf4j
+@Api(tags="boss数据看板")
+@RestController
+@RequestMapping("/boss/bossDataExhibitionController")
+public class BossDataExhibitionController {
+
+    @Autowired
+    private IBossDataExhibitionService bossDataExhibitionServiceImpl;
+
+
+
+
+
+    @ApiOperation(value="素材产出占比", notes="素材产出占比")
+    @GetMapping(value = "/getMeterialProduceRate")
+    public Result getMeterialProduceRate(
+            @RequestParam(name="mediaType",defaultValue = "2") String mediaType,
+            @RequestParam(name="startTime") String startTime,
+            @RequestParam(name="endTime") String endTime) {
+        return bossDataExhibitionServiceImpl.getMeterialProduceRate(mediaType,startTime,endTime);
+    }
+
+
+
+
+
+
+
+}

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

@@ -0,0 +1,31 @@
+package org.jeecg.ctop.material.mapper;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+@Mapper
+public interface BossDataExhibitionMapper {
+
+    /**
+     * 素材产出占比 快手
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<Map<String,Object>> getMeterialProduceRateKuaiShou(@Param("startTime") Integer startTime,@Param("endTime") Integer endTime);
+
+    /**
+     * 素材产出占比 头条
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<Map<String,Object>> getMeterialProduceRateBytedance(@Param("startTime") Integer startTime,@Param("endTime") Integer endTime);
+}

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

@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.ctop.material.mapper.BossDataExhibitionMapper">
+
+    <!--  素材产出占比 快手 -->
+    <select id="getMeterialProduceRateKuaiShou" resultType="java.util.LinkedHashMap">
+        SELECT t.* ,
+        CONCAT(ROUND(t.meterialNum / t.total,2) ,'%')as rate
+        from (
+        SELECT
+        COUNT( material_id ) meterialNum ,
+        CASE company_name
+        WHEN '北京汇创思拓数字科技有限公司' then '华北'
+        WHEN '广州汇创思拓数字科技有限公司' then '华南'
+        WHEN '上海汇创思拓数字科技有限公司' then '华东'
+        WHEN '杭州妙构思数字科技有限公司' then '杭州'
+        WHEN '北京骄阳数字科技有限公司' then '骄阳'
+        else '其他'
+        end area,
+        company_name as companyName,
+        (SELECT COUNT(material_id) as num
+        FROM app_kuaishou_material_info
+            <where>
+                <if test="startTime !=null and startTime != ''">
+                    AND media_time &gt;= #{startTime}
+                </if>
+                <if test="endTime !=null and endTime != ''">
+                    AND media_time &lt;= #{endTime}
+                </if>
+            </where>
+            ) as total
+        FROM
+        app_kuaishou_material_info
+        <where>
+            <if test="startTime !=null and startTime != ''">
+                AND media_time &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND media_time &lt;= #{endTime}
+            </if>
+        </where>
+        GROUP BY
+        company_id
+        ) t
+    </select>
+
+
+    <!--  素材产出占比 头条 -->
+    <select id="getMeterialProduceRateBytedance" resultType="java.util.LinkedHashMap">
+        SELECT t.* ,
+        CONCAT(ROUND(t.meterialNum / t.total * 100,2) ,'%')as rate
+        from (
+        SELECT
+        COUNT( material_id ) meterialNum,
+        CASE company_name
+        WHEN '北京汇创思拓数字科技有限公司' then '华北'
+        WHEN '广州汇创思拓数字科技有限公司' then '华南'
+        WHEN '上海汇创思拓数字科技有限公司' then '华东'
+        WHEN '北京次元像素' then '石家庄'
+        WHEN '杭州妙构思数字科技有限公司' then '杭州'
+        else '其他'
+        end area,
+        company_name as companyName,
+        (SELECT COUNT(material_id) as num
+            FROM app_bytedance_material_info
+            <where>
+                <if test="startTime !=null and startTime != ''">
+                    AND media_time &gt;= #{startTime}
+                </if>
+                <if test="endTime !=null and endTime != ''">
+                    AND media_time &lt;= #{endTime}
+                </if>
+            </where>
+            ) as total
+        FROM
+        app_bytedance_material_info
+        <where>
+            <if test="startTime !=null and startTime != ''">
+                AND media_time &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND media_time &lt;= #{endTime}
+            </if>
+        </where>
+        GROUP BY
+        company_id) t
+
+    </select>
+
+</mapper>

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

@@ -0,0 +1,21 @@
+package org.jeecg.ctop.material.service;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.sql.ResultSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public interface IBossDataExhibitionService {
+
+
+    Result getMeterialProduceRate(String mediaType,String startTime, String endTime);
+
+}

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

@@ -0,0 +1,62 @@
+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.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;
+
+@Slf4j
+@Service
+public class BossDataExhibitionServiceImpl implements IBossDataExhibitionService {
+
+    @Autowired
+    private BossDataExhibitionMapper bossDataExhibitionMapper;
+
+
+    /**
+     *
+     * @description: 素材产出占比
+     *
+     * @param mediaType 1-头条 2-快手
+     * @param startTime
+     * @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) {
+        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.getMeterialProduceRateBytedance(stat_tim,end_tim);
+        }else if (StringUtils.equals("2",mediaType)){
+            resultList = bossDataExhibitionMapper.getMeterialProduceRateKuaiShou(stat_tim,end_tim);
+        }
+        return Result.successMsg("1".equals(mediaType) ? "【头条】" : "【快手】"+"===素材产出占比查询成功。",resultList);
+    }
+}