Przeglądaj źródła

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

yumeng 3 lat temu
rodzic
commit
acaf450d2b
22 zmienionych plików z 2766 dodań i 72 usunięć
  1. 121 0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java
  2. 2 0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
  3. 46 34
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/SettlementFileInfoMapper.xml
  4. 65 3
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/controller/BossDataExhibitionController.java
  5. 18 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/entity/AccountTrendPojo.java
  6. 138 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/BossDataExhibitionMapper.java
  7. 574 11
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/BossDataExhibitionMapper.xml
  8. 13 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/IBossDataExhibitionService.java
  9. 279 16
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/BossDataExhibitionServiceImpl.java
  10. 13 6
      jeecg-boot-material-view/src/main/resources/application-test.yml
  11. 5 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/TagInfoMapper.java
  12. 15 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/TagInfoMapper.xml
  13. 3 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/ITagInfoService.java
  14. 9 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/TagInfoServiceImpl.java
  15. 56 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/ExportExcelUtils.java
  16. 191 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/ExternalMaterialCollection.java
  17. 49 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/LoadFileUtil.java
  18. 407 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/controller/ExternalMaterialCollectionController.java
  19. 35 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/mapper/ExternalMaterialCollectionMapper.java
  20. 210 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/mapper/xml/ExternalMaterialCollectionMapper.xml
  21. 37 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/service/IExternalMaterialCollectionService.java
  22. 480 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/service/impl/ExternalMaterialCollectionServiceImpl.java

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

@@ -1814,4 +1814,125 @@ 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);
+    }
+
+
+    /**
+     * 整形 年月日 转 String 月-日
+     * 20220120 时间格式 转换为 01-20
+     * @param dateString
+     * @return
+     */
+    public static String intDateToString(String dateString) {
+        String newDate = null;
+        try {
+            SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
+            df.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+            Date date = df.parse(dateString);
+            SimpleDateFormat dfStr = new SimpleDateFormat("MM-dd");
+            newDate = dfStr.format(date);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return newDate;
+    }
+
+
+
+    /**
+     * 获取 两个日期之间的所有 日期
+     *
+     * @param startDate
+     * @param endDate
+     * @return
+     */
+    public static List<String> getAllDatesOfTwoTimes(String startDate, String endDate) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        List<String> dateList = new ArrayList<String>();
+        try {
+            Date dateOne = sdf.parse(startDate);
+            Date dateTwo = sdf.parse(endDate);
+
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(dateOne);
+
+            dateList.add(startDate);
+            while (calendar.getTime().before(dateTwo)) { //倒序时间,顺序after改before其他相应的改动。
+                calendar.add(Calendar.DAY_OF_MONTH, 1);
+                dateList.add(sdf.format(calendar.getTime()));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return dateList;
+    }
+
+
+    /**
+     * 时间 去重 排序
+     * @param list
+     * @return
+     */
+    public static List<String> sortlistTest(List<String> list) {
+        //去重
+        List<String> newlist = new ArrayList<String>();
+        for (int i = 0; i < list.size(); i++) {
+            if (!newlist.contains(list.get(i))) {
+                newlist.add(list.get(i));
+            }
+        }
+        String tmp;
+        for (int i = 1; i < newlist.size(); i++) {
+            tmp = newlist.get(i);
+            int j = i - 1;
+            for (; j >= 0 && (DateCompare(tmp, newlist.get(j)) < 0); j--) {
+                newlist.set(j + 1, newlist.get(j));
+            }
+            newlist.set(j + 1, tmp);
+        }
+        return newlist;
+    }
+
+
+    public static long DateCompare(String s1, String s2) {
+        try {
+
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            Date d1 = simpleDateFormat.parse(s1);
+            Date d2 = simpleDateFormat.parse(s2);
+            // LocalDateTime d1 = LocalDateTime.parse(s1, DateTimeFormatter.ISO_LOCAL_DATE);
+            //LocalDateTime d2 = LocalDateTime.parse(s2, DateTimeFormatter.ISO_LOCAL_DATE);
+            //排序规则
+            return ((d1.getTime()) - (d2.getTime()));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return 0;
+    }
+
+
+
+
+
+    public static void main(String[] args) {
+        //System.out.println(DateUtils.getFirstDayByMonth());
+        System.out.println(intDateToString("20210101"));
+
+
+    }
+
+
+
 }

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

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

+ 46 - 34
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/SettlementFileInfoMapper.xml

@@ -90,67 +90,79 @@
 
     <!-- 查询 财务结算-结算单列表-->
     <select id="getSettlementSheetList" resultType="java.util.LinkedHashMap">
-        SELECT * FROM
+        SELECT t.*
+        FROM
         (
         SELECT
         f.id,
-        f.upload_years as uploadYears,
-        f.media_id as mediaId,
-        f.advertiser_id as advertiserId,
-        ( SELECT ad.NAME FROM ctop_advertiser ad WHERE ad.id = f.advertiser_id LIMIT 1 ) advertiserName,
-        f.product_id as productId,
-        ( SELECT cp.product_name FROM ctop_product cp WHERE cp.id = f.product_id LIMIT 1 ) productName,
-        IFNULL((SELECT u.project_id from ctop_user_allocation u where u.account_id  = f.account_id),cwjs.project_id) as projectId,
-        IFNULL((SELECT project.project_name from ctop_user_allocation u,ctop_project project where u.account_id  = f.account_id and project.id = u.project_id),
-            (SELECT project.project_name FROM ctop_project project WHERE project.id = cwjs.project_id LIMIT 1 )) as projectName,
-        IFNULL(cwjs.account_id,f.account_id) as accountId,
-        IFNULL((SELECT u.auth_name from ctop_user_allocation u where u.account_id  = f.account_id),cwjs.account_name) as accountName,
+        f.upload_years AS uploadYears,
+        f.media_id AS mediaId,
+        f.advertiser_id AS advertiserId,
+        ad.NAME as advertiserName,
+        f.product_id AS productId,
+        cp.product_name as productName,
+        IFNULL(u.project_id, cwjs.project_id ) AS projectId,
+        IFNULL((SELECT project.project_name FROM ctop_user_allocation u,ctop_project project WHERE u.account_id = f.account_id AND project.id = u.project_id),
+        (SELECT project.project_name FROM ctop_project project WHERE project.id = cwjs.project_id LIMIT 1 )
+        ) AS projectName,
+        IFNULL(cwjs.account_id, f.account_id) AS accountId,
+        IFNULL(u.auth_name,cwjs.account_name) AS accountName,
         f.del_flag,
-        IFNULL((SELECT cp.sale_id from ctop_user_allocation ua, ctop_project cp where f.account_id = ua.account_id and ua.project_id = cp.id),cwjs.create_user_id) as saleUserId,
-        IFNULL((SELECT su.realname from ctop_user_allocation ua, ctop_project cp,sys_user su where f.account_id = ua.account_id and ua.project_id = cp.id and cp.sale_id = su.id), (SELECT su.realname FROM sys_user su WHERE su.id = cwjs.create_user_id LIMIT 1 )) as saleUserName,
-        f.create_user_id as operateUserId,
-        ( SELECT su.realname FROM sys_user su WHERE su.id = f.create_user_id LIMIT 1 ) operateUserName,
-        cwjs.create_time,
-        cwjs.update_time
-        FROM ctop_cwjs_settlement_file_info f
-        LEFT JOIN ctop_cwjs_settlement_info cwjs on f.account_id = cwjs.account_id
-        where f.del_flag = 0
-        GROUP BY f.account_id,f.upload_years,f.create_user_id
-        ORDER BY f.upload_years DESC
+        IFNULL(project.sale_id,cwjs.create_user_id) AS saleUserId,
+        IFNULL((SELECT su.realname FROM sys_user su WHERE f.account_id = u.account_id AND u.project_id = project.id AND project.sale_id = su.id),
+        (SELECT su.realname FROM sys_user su  LEFT JOIN ctop_cwjs_settlement_info cwjs1  on su.id = cwjs1.create_user_id LIMIT 1 )
+        ) as saleUserName,
+        f.create_user_id AS operateUserId,
+        (SELECT su.realname FROM sys_user su  LEFT JOIN ctop_cwjs_settlement_file_info f1  on su.id = f1.create_user_id LIMIT 1 ) as operateUserName,
+        MAX(f.create_time) create_time,
+        MAX(f.update_time) update_time
+        FROM
+        ctop_cwjs_settlement_file_info f
+        LEFT JOIN ctop_cwjs_settlement_info cwjs ON f.account_id = cwjs.account_id
+        LEFT JOIN ctop_user_allocation u on u.account_id = f.account_id
+        LEFT JOIN ctop_advertiser ad on ad.id = f.advertiser_id
+        LEFT JOIN ctop_product cp on cp.id = f.product_id
+        LEFT JOIN ctop_project project  on project.id = u.project_id
+        WHERE
+            f.del_flag = 0
+        GROUP BY
+            f.account_id,
+            f.upload_years,
+            f.create_user_id
         ) t
         <where>
             <if test="advertiserName !=null and advertiserName != ''">
-                AND advertiserName like concat ('%',#{advertiserName},'%')
+                AND t.advertiserName like concat ('%',#{advertiserName},'%')
             </if>
             <if test="productName !=null and productName != ''">
-                AND productName like concat ('%',#{productName},'%')
+                AND t.productName like concat ('%',#{productName},'%')
             </if>
             <if test="projectName !=null and projectName != ''">
-                AND projectName like concat ('%',#{projectName},'%')
+                AND t.projectName like concat ('%',#{projectName},'%')
             </if>
             <if test="accountName !=null and accountName != ''">
-                AND accountName like concat ('%',#{accountName},'%')
+                AND t.accountName like concat ('%',#{accountName},'%')
             </if>
             <if test="mediaId !=null and mediaId != ''">
-                AND mediaId = #{mediaId}
+                AND t.mediaId = #{mediaId}
             </if>
             <if test="startTime !=null and startTime != ''">
-                AND uploadYears &gt;= #{startTime}
+                AND t.uploadYears &gt;= #{startTime}
             </if>
             <if test="endTime !=null and endTime != ''">
-                AND uploadYears &lt;= #{endTime}
+                AND t.uploadYears &lt;= #{endTime}
             </if>
             <if test="createUserName !=null and createUserName != ''">
-                AND operateUserId like concat ('%',#{createUserName},'%')
+                AND t.operateUserId like concat ('%',#{createUserName},'%')
             </if>
 
             <if test="saleUserIds !=null and saleUserIds.size() >0 ">
-                AND (operateUserId in
+                AND (t.operateUserId in
                 <foreach collection="saleUserIds" item="item" separator=","
                          open="(" close=")">
                     #{item}
                 </foreach>
-                or saleUserId in
+                or t.saleUserId in
                 <foreach collection="saleUserIds" item="item" separator=","
                          open="(" close=")">
                     #{item}
@@ -161,7 +173,7 @@
                 AND (operateUserId = #{createUserId} or saleUserId = #{createUserId})
             </if>-->
         </where>
-        ORDER BY t.update_time DESC,t.projectId
+        ORDER BY t.update_time DESC,t.projectId,t.accountId
     </select>
 
 

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

@@ -26,9 +26,6 @@ public class BossDataExhibitionController {
     private IBossDataExhibitionService bossDataExhibitionServiceImpl;
 
 
-    //--test---
-
-
 
     @ApiOperation(value="素材产出占比", notes="素材产出占比")
     @GetMapping(value = "/getMeterialProduceRate")
@@ -41,6 +38,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;
+
+}

+ 138 - 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,141 @@ 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 projectId
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    Map<String,Object> getMediaTypeProjectCostBytedanceBase(@Param("projectId") String projectId,@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);
+
+    /**
+     * 项目消耗排行 top10 快手 基建数
+     * @param projectId
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    Map<String,Object> getMediaTypeProjectCostKuaishouBase(@Param("projectId") String projectId,@Param("startTime") Integer startTime,@Param("endTime") Integer endTime);
 }

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

@@ -4,11 +4,14 @@
 
     <!--  素材产出占比 快手 -->
     <select id="getMeterialProduceRateKuaiShou" resultType="java.util.LinkedHashMap">
-        SELECT t.* ,
-        CONCAT(ROUND(t.meterialNum / t.total,2) ,'%')as rate
+        SELECT a.*,
+        sum(a.meterial) meterialNum,
+        CONCAT(ROUND(sum(a.meterial) / a.total * 100,2) ,'%')as rate
+        from (
+        SELECT t.*
         from (
         SELECT
-        COUNT( material_id ) meterialNum ,
+        COUNT( material_id ) meterial ,
         CASE company_name
         WHEN '北京汇创思拓数字科技有限公司' then '华北'
         WHEN '广州汇创思拓数字科技有限公司' then '华南'
@@ -19,7 +22,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 +33,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}
@@ -42,27 +45,33 @@
         GROUP BY
         company_id
         ) t
+        )a
+        GROUP BY a.area
+        ORDER BY a.area DESC
     </select>
 
 
     <!--  素材产出占比 头条 -->
     <select id="getMeterialProduceRateBytedance" resultType="java.util.LinkedHashMap">
-        SELECT t.* ,
-        CONCAT(ROUND(t.meterialNum / t.total * 100,2) ,'%')as rate
+        SELECT a.*,
+        sum(a.meterial) meterialNum,
+        CONCAT(ROUND(sum(a.meterial) / a.total * 100,2) ,'%')as rate
+        from (
+        SELECT t.*
         from (
         SELECT
-        COUNT( material_id ) meterialNum,
+        COUNT( material_id ) meterial,
         CASE company_name
         WHEN '北京汇创思拓数字科技有限公司' then '华北'
         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
+            FROM application.app_bytedance_material_info
             <where>
                 <if test="startTime !=null and startTime != ''">
                     AND media_time &gt;= #{startTime}
@@ -73,7 +82,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 +93,561 @@
         </where>
         GROUP BY
         company_id) t
+        )a
+        GROUP BY a.area
+        ORDER BY a.area DESC
+    </select>
+
+    <!--  分公司素材消耗 头条 -->
+    <select id="getCompanyMeterialConsumeBytedance" resultType="java.util.LinkedHashMap">
+        SELECT
+        t.*,
+        SUM(t.tcost) cost
+        FROM
+        (
+        SELECT
+        company_id,
+        company_name,
+        SUM(cost) tcost,
+        CASE
+        company_id
+        WHEN 'd57fecdcf7a94d009736d9c850731582' THEN '华北'
+        WHEN '6608ed13c0dd42de93c790dbdf124234' THEN '华南'
+        WHEN '4b10089775c040119e139087517aed88' 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
+        WHERE t.tcost > 0
+        GROUP BY t.area
+        ORDER BY t.area DESC;
+    </select>
+
+    <!--  分公司素材消耗 快手 -->
+    <select id="getCompanyMeterialConsumeKuaishou" resultType="java.util.LinkedHashMap">
+        SELECT t.*,
+        SUM(t.tcost) as cost
+        from (
+        SELECT company_id,company_name,SUM(charge) tcost,
+        CASE company_id
+        WHEN 'd57fecdcf7a94d009736d9c850731582' then '华北'
+        WHEN '6608ed13c0dd42de93c790dbdf124234' then '华南'
+        WHEN '4b10089775c040119e139087517aed88' 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
+        where t.tcost > 0
+        GROUP BY t.area
+        ORDER BY t.area DESC;
+    </select>
+
+    <!--  素材相关===素材使用率===头条 -->
+    <select id="getMeterialUseRateBytedanc" resultType="java.util.LinkedHashMap">
+        SELECT t.*,
+        ROUND(t.bytedanceTotal / t.total * 100,2) as useRate
+        from (
+        SELECT COUNT(material_id) total,
+        (SELECT COUNT(material_id) total 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 bytedanceTotal
+        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.*,
+        ROUND(t.kuaiShouTotal / t.total * 100,2) as useRate
+        from (
+        SELECT COUNT(material_id) total,
+        (SELECT COUNT(material_id) total 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 kuaiShouTotal
+        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.*,
+        ROUND(t.faddish / t.total * 100,2) as faddishRate
+        FROM
+        (
+        SELECT COUNT(material_id) total,
+        (SELECT COUNT(material_id) total 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 media_time &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND media_time &lt;= #{endTime}
+            </if>
+        </where>
+        ) t
+    </select>
+
+
+<!--  素材相关===素材爆款率===快手 -->
+    <select id="getMeterialFaddishRateKuaishou" resultType="java.util.LinkedHashMap">
+        SELECT t.*,
+        ROUND(t.faddish / t.total * 100,2) as faddishRate
+        FROM
+        (
+        SELECT COUNT(material_id) total,
+        (SELECT COUNT(material_id) total 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 media_time &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND media_time &lt;= #{endTime}
+            </if>
+        </where>
+        ) t
+    </select>
+
+<!--  素材相关===素材创新率===头条 -->
+    <select id="getMeterialInnovateRateBytedance" resultType="java.util.LinkedHashMap">
+        SELECT t.*,
+        ROUND(t.innovate / t.total * 100,2) as innovateRate
+        FROM
+        (
+        SELECT COUNT(material_id) total,
+        (SELECT COUNT(material_id) total 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.*,
+        ROUND(t.innovate / t.total * 100,2) as innovateRate
+        FROM
+        (
+        SELECT COUNT(material_id) total,
+        (SELECT COUNT(material_id) total 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.tcost) cost,
+        CONCAT(ROUND(SUM(t.tcost) / t.totalCost * 100,2) ,'%')as rate
+        FROM
+        (
+        SELECT
+        company_id,
+        company_name,
+        SUM(cost) tcost,
+        CASE
+        company_id
+        WHEN 'd57fecdcf7a94d009736d9c850731582' THEN '华北'
+        WHEN '6608ed13c0dd42de93c790dbdf124234' THEN '华南'
+        WHEN '4b10089775c040119e139087517aed88' 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
+        where t.tcost > 0
+        GROUP BY
+        t.area;
     </select>
 
+
+<!--  分公司投放数据-账户-快手 -->
+    <select id="getCompanyAccountDataKuaishou" resultType="java.util.LinkedHashMap">
+        SELECT
+        t.*,
+        SUM(t.tcost) cost,
+        CONCAT(ROUND(SUM(t.tcost) / t.totalCost * 100,2) ,'%')as rate
+        FROM
+        (
+        SELECT
+        company_id,
+        company_name,
+        SUM(charge) tcost,
+        CASE
+        company_id
+        WHEN 'd57fecdcf7a94d009736d9c850731582' THEN '华北'
+        WHEN '6608ed13c0dd42de93c790dbdf124234' THEN '华南'
+        WHEN '4b10089775c040119e139087517aed88' 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
+        where t.tcost > 0
+        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
+            DATE_FORMAT(stat_datetime,'%Y-%m-%d') 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
+        DATE_FORMAT(stat_date,'%Y-%m-%d') 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
+        FROM
+        application.bytedance_advertiser_report_daily_dw a
+        <where>
+            <if test="startTime !=null and startTime != ''">
+                AND a.stat_datetime &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND a.stat_datetime &lt;= #{endTime}
+            </if>
+        </where>
+        GROUP BY a.project_id
+        ORDER BY totalCost DESC
+        limit 10
+    </select>
+    <!--  项目消耗排行 top10 头条-基建数-->
+    <select id="getMediaTypeProjectCostBytedanceBase" resultType="java.util.LinkedHashMap">
+        SELECT
+        b.project_id as projectId,
+        IFNULL(SUM(b.new_ad_num),0) as baseNum
+        FROM
+        application.app_bytedance_account_base_info_d b
+        <where>
+            <if test="projectId !=null and projectId != ''">
+                AND b.project_id &gt;= #{projectId}
+            </if>
+            <if test="startTime !=null and startTime != ''">
+                AND b.stat_date &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND b.stat_date &lt;= #{endTime}
+            </if>
+        </where>
+
+    </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
+        FROM
+        application.kuaishou_account_report_daily_dw a
+        <where>
+            <if test="startTime !=null and startTime != ''">
+                AND a.stat_date &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND a.stat_date &lt;= #{endTime}
+            </if>
+        </where>
+        GROUP BY a.project_id
+        ORDER BY totalCost DESC
+        limit 10
+    </select>
+    <!--  项目消耗排行 top10 快手 基建数-->
+    <select id="getMediaTypeProjectCostKuaishouBase" resultType="java.util.LinkedHashMap">
+        SELECT
+        b.project_id projectId,
+        IFNULL(SUM(b.new_unit_num),0) as baseNum
+        FROM
+        application.app_kuaishou_account_base_info_d b
+        <where>
+            <if test="projectId !=null and projectId != ''">
+                AND b.project_id = #{projectId}
+            </if>
+            <if test="startTime !=null and startTime != ''">
+                AND b.stat_date &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND b.stat_date &lt;= #{endTime}
+            </if>
+        </where>
+
+    </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);
+
+
 }

+ 279 - 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,281 @@ 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() {
+        Map<String,Object> resultMap = new HashMap<>();
+        //获取当前月份第一天
+        Integer firstDay = DateUtils.getFirstDayByMonth();
+        List<Map<String,Object>>  resultList = bossDataExhibitionMapper.getMediaTypeAccountData(firstDay);
+        if (Check.isNull(resultList)){
+            return Result.error("分媒体投放数据暂无");
+        }
+
+        //图表数据组装
+        List<Object> timeList = resultList.stream().map(map -> map.get("time")).collect(Collectors.toList());
+        //时间格式转换 20220120 -->>> 01-20
+        List<Object> resultTimeList = new ArrayList<>();
+        if (!Check.isNull(timeList)){
+            timeList.forEach(obj -> {
+                resultTimeList.add(DateUtils.intDateToString(obj.toString()));
+            });
+        }
+        //头条数据 坐标轴左侧 加 “-” 变为负数
+        List<Object> bytedanceList = resultList.stream().map(map -> map.get("bytedanceCost")).collect(Collectors.toList());
+        List<Object> resultBytedanceList = new ArrayList<>();
+        if (!Check.isNull(bytedanceList)){
+            bytedanceList.forEach(obj ->{
+                resultBytedanceList.add(new StringBuilder().append("-").append(obj));
+            });
+        }
+        //快手数据 坐标轴右侧  正数
+        List<Object> kuaishouList = resultList.stream().map(map -> map.get("kuaishouCost")).collect(Collectors.toList());
+
+        resultMap.put("time",resultTimeList);
+        resultMap.put("bytedance",resultBytedanceList);
+        resultMap.put("kuaishou",kuaishouList);
+        return Result.successMsg("分媒体投放数据查询成功。",resultMap);
+    }
+
+    /**
+     *
+     * @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) {
+        Map<String,Object> resultMap = new HashMap();
+        // 获取两个日期之间 所有的 时间 年-月-日
+        List<String> betweenDaysList = DateUtils.getAllDatesOfTwoTimes(startTime,endTime);
+        resultMap.put("time",betweenDaysList);
+
+        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)) {
+            return Result.error("账户消耗数据查询为空");
+        }
+
+        /**
+         * 数据组装
+         */
+        //根据 区域分组
+        Map<String,List<AccountTrendPojo>> map = resultList.stream().collect(Collectors.groupingBy(AccountTrendPojo::getArea));
+
+        //1-华北
+        List<AccountTrendPojo> huaBeiList = !map.containsKey("华北") ? new ArrayList<>() : map.get("华北");
+        //获取数据 时间 集合
+        List<String> huabeiTime = huaBeiList.stream().map(AccountTrendPojo::getTime).collect(Collectors.toList());
+        // 补充数据
+        huaBeiList = getDateSupplement(betweenDaysList,huabeiTime,huaBeiList);
+        // 获取属性 cost 返回数组
+        List<String> huaBeiCostList = huaBeiList.stream().map(AccountTrendPojo::getCost).collect(Collectors.toList());
+        resultMap.put("huaBei",huaBeiCostList);
+
+        //2-华南
+        List<AccountTrendPojo> huaNanList = !map.containsKey("华南") ? new ArrayList<>() : map.get("华南");
+        List<String> huaNanTime = huaNanList.stream().map(AccountTrendPojo::getTime).collect(Collectors.toList());
+        huaNanList = getDateSupplement(betweenDaysList,huaNanTime,huaNanList);
+        List<String> huaNanCostList = huaNanList.stream().map(AccountTrendPojo::getCost).collect(Collectors.toList());
+        resultMap.put("huaNan",huaNanCostList);
+
+        //3-华东
+        List<AccountTrendPojo> huaDongList = !map.containsKey("华东") ? new ArrayList<>() : map.get("华东");
+        List<String> huaDongTime = huaDongList.stream().map(AccountTrendPojo::getTime).collect(Collectors.toList());
+        huaDongList = getDateSupplement(betweenDaysList,huaDongTime,huaDongList);
+        List<String> huaDongCostList = huaDongList.stream().map(AccountTrendPojo::getCost).collect(Collectors.toList());
+        resultMap.put("huaDong",huaDongCostList);
+
+        //4-骄阳
+        List<AccountTrendPojo> jiaoYangList = !map.containsKey("骄阳") ? new ArrayList<>() : map.get("骄阳");
+        List<String> jiaoYangTime = jiaoYangList.stream().map(AccountTrendPojo::getTime).collect(Collectors.toList());
+        jiaoYangList = getDateSupplement(betweenDaysList,jiaoYangTime,jiaoYangList);
+        List<String> jiaoYangCostList = jiaoYangList.stream().map(AccountTrendPojo::getCost).collect(Collectors.toList());
+        resultMap.put("jiaoYang",jiaoYangCostList);
+
+        return Result.successMsg(("1".equals(mediaType) ? "【头条】" : "【快手】")+"===分公司-分日-账户消耗数据查询成功。",resultMap);
+
+    }
+
+
+    /**
+     * 补充数据 没有时间的补充时间并添加数据为0
+     * @param betweenDaysList  两个日期中间的所有日期集合
+     * @param nowList 现有日期的集合
+     * @param accountTrendPojoList 数据集合
+     * @return
+     */
+    public List<AccountTrendPojo> getDateSupplement(List<String> betweenDaysList,List<String> nowList,List<AccountTrendPojo> accountTrendPojoList){
+        // 时间差集(所有时间段 - 已有的时间段)
+        List<String>  reduceList = betweenDaysList.stream().filter(item -> !nowList.contains(item)).collect(Collectors.toList());
+        reduceList.forEach(str ->{
+                    AccountTrendPojo pojo = new AccountTrendPojo();
+                    pojo.setTime(str);
+                    pojo.setCost("0");
+                    accountTrendPojoList.add(pojo);
+                }
+        );
+        //时间排序
+        accountTrendPojoList.sort(Comparator.comparing(AccountTrendPojo::getTime));
+        return accountTrendPojoList;
+    }
+
+
+
+    /**
+     *
+     * @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);
+            //基建数
+            if (!Check.isNull(resultList)){
+                for (Map<String, Object> dateMap : resultList) {
+                    Map<String, Object> baseMap = bossDataExhibitionMapper.getMediaTypeProjectCostBytedanceBase(dateMap.get("projectId").toString(),stat_tim,end_tim);
+                    dateMap.put("baseNum", Check.isNull(baseMap) ? "0" : baseMap.get("baseNum"));
+                }
+            }
+        }else if (StringUtils.equals("2",mediaType)){
+            resultList = bossDataExhibitionMapper.getMediaTypeProjectCostKuaishou(stat_tim,end_tim);
+            //基建数
+            if (!Check.isNull(resultList)){
+                for (Map<String, Object> dateMap : resultList) {
+                    Map<String, Object> baseMap = bossDataExhibitionMapper.getMediaTypeProjectCostKuaishouBase(dateMap.get("projectId").toString(),stat_tim,end_tim);
+                    dateMap.put("baseNum", Check.isNull(baseMap) ? "0" : baseMap.get("baseNum"));
+                }
+            }
+        }
+        return Result.successMsg(("1".equals(mediaType) ? "【头条】" : "【快手】")+"===项目消耗排行top10查询成功。",resultList);
+    }
+
+
 }

+ 13 - 6
jeecg-boot-material-view/src/main/resources/application-test.yml

@@ -106,15 +106,15 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
-          url: jdbc:mysql://111.206.86.186:3390/application?characterEncoding=UTF-8&useUnicode=true&allowMultiQueries=true&serverTimezone=GMT%2B8
-          username: hcst
-          password: hcst@2021
+#          url: jdbc:mysql://111.206.86.186:3390/application?characterEncoding=UTF-8&useUnicode=true&allowMultiQueries=true&serverTimezone=GMT%2B8
+#          username: hcst
+#          password: hcst@2021
           driver-class-name: com.mysql.jdbc.Driver
           # 多数据源配置
           #multi-datasource1:
-          #url: jdbc:mysql://localhost:3306/jeecg-boot2?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
-          #username: root
-          #password: root
+          url: jdbc:mysql://192.168.0.184:3390/jeecg-boot?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
+          username: hcst
+          password: hcst@2021
           #driver-class-name: com.mysql.cj.jdbc.Driver
   #redis 配置
   redis:
@@ -147,6 +147,13 @@ mybatis-plus:
     call-setters-on-nulls: true
 #jeecg专用配置
 jeecg :
+  oss:
+    secretKey:
+    accessKey:
+  path:
+    webapp:
+    upload:
+
   elasticsearch:
     cluster-name: jeecg-ES
     cluster-nodes: 127.0.0.1:9200

+ 5 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/TagInfoMapper.java

@@ -1,7 +1,11 @@
 package cn.com.ctop.common.module.mapper;
 
 import cn.com.ctop.common.module.entity.TagInfo;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 标签信息
@@ -11,4 +15,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface TagInfoMapper extends BaseMapper<TagInfo> {
 
+    List<TagInfo> getListByCode(@Param("array")  JSONArray array);
 }

+ 15 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/TagInfoMapper.xml

@@ -2,4 +2,19 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.common.module.mapper.TagInfoMapper">
 
+    <select id="getListByCode" resultType="cn.com.ctop.common.module.entity.TagInfo">
+        SELECT
+        id,
+        tag_name,
+        parent_id,
+        tag_code,
+        description
+        FROM  ctop_tag_info
+        WHERE tag_code IN
+        <foreach collection="array" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
+
 </mapper>

+ 3 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/ITagInfoService.java

@@ -2,6 +2,7 @@ package cn.com.ctop.common.module.service;
 
 import cn.com.ctop.common.module.entity.TagInfo;
 import cn.com.ctop.common.module.model.TagInfoTreeModel;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
@@ -19,4 +20,6 @@ public interface ITagInfoService extends IService<TagInfo> {
     TagInfo getByTagCode(String tagCode);
 
     List<TagInfo> getByParentId(Long id);
+
+    List<TagInfo> getListByCode(JSONArray array);
 }

+ 9 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/TagInfoServiceImpl.java

@@ -5,8 +5,10 @@ import cn.com.ctop.common.module.mapper.TagInfoMapper;
 import cn.com.ctop.common.module.model.TagInfoTreeModel;
 import cn.com.ctop.common.module.service.ITagInfoService;
 import cn.com.ctop.common.module.utils.FindstagInfosChildrenUtil;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -20,6 +22,8 @@ import java.util.List;
 @Service
 public class TagInfoServiceImpl extends ServiceImpl<TagInfoMapper, TagInfo> implements ITagInfoService {
 
+    @Autowired
+    private TagInfoMapper mapper;
     /**
      * queryTreeList 对应 queryTreeList 查询所有的部门数据,以树结构形式响应给前端
      */
@@ -54,4 +58,9 @@ public class TagInfoServiceImpl extends ServiceImpl<TagInfoMapper, TagInfo> impl
         queryWrapper.orderByAsc("tag_order");
         return this.list(queryWrapper);
     }
+
+    @Override
+    public List<TagInfo> getListByCode(JSONArray array) {
+        return mapper.getListByCode(array);
+    }
 }

+ 56 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/ExportExcelUtils.java

@@ -3,8 +3,19 @@ package cn.com.ctop.common.module.utils;
 
 import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.hssf.usermodel.HSSFDateUtil;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.xssf.usermodel.*;
+import org.apache.poi.ss.usermodel.BorderStyle;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.FillPatternType;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
+import org.apache.poi.xssf.usermodel.XSSFCell;
+import org.apache.poi.xssf.usermodel.XSSFCellStyle;
+import org.apache.poi.xssf.usermodel.XSSFFont;
+import org.apache.poi.xssf.usermodel.XSSFRichTextString;
+import org.apache.poi.xssf.usermodel.XSSFRow;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.UnsupportedEncodingException;
@@ -328,4 +339,47 @@ public class ExportExcelUtils {
         }
         return value.trim();
     }
+
+    public void putHeaders(XSSFWorkbook workbook, int sheetNum, String sheetTitle, String[] headers) {
+        // 生成一个表格
+        XSSFSheet sheet = workbook.createSheet();
+        workbook.setSheetName(sheetNum, sheetTitle);
+        // 设置表格默认列宽度为20个字节
+        sheet.setDefaultColumnWidth((short) 30);
+        // 生成一个样式
+        XSSFCellStyle style = workbook.createCellStyle();
+        // 设置这些样式
+        style.setFillForegroundColor(IndexedColors.PALE_BLUE.index);
+        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        style.setBorderBottom(BorderStyle.THIN);
+        style.setBorderLeft(BorderStyle.THIN);
+        style.setBorderRight(BorderStyle.THIN);
+        style.setBorderTop(BorderStyle.THIN);
+        // style.setAlignment(HorizontalAlignment.CENTER);
+        style.setAlignment(HorizontalAlignment.CENTER);
+        style.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
+        // 生成一个字体
+        XSSFFont font = workbook.createFont();
+        font.setColor(IndexedColors.BLACK.index);
+        font.setFontHeightInPoints((short) 12);
+        //加粗
+        font.setBold(true);
+        // 把字体应用到当前的样式
+        style.setFont(font);
+
+        // 指定当单元格内容显示不下时自动换行
+        style.setWrapText(true);
+        //记录样式(标黄)
+//        style.setFillForegroundColor(IndexedColors.LIGHT_YELLOW.index);
+
+        // 产生表格标题行
+        XSSFRow row = sheet.createRow(0);
+        for (int i = 0; i < headers.length; i++) {
+            XSSFCell cell = row.createCell((short) i);
+            cell.setCellStyle(style);
+            XSSFRichTextString text = new XSSFRichTextString(headers[i]);
+            cell.setCellValue(text.toString());
+        }
+    }
+
 }

+ 191 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/ExternalMaterialCollection.java

@@ -0,0 +1,191 @@
+package cn.com.ctop.common.module.utils;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 外部素材集信息表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2022-01-12
+ */
+@Data
+@TableName("ctop_external_material_collection")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_external_material_collection对象", description = "外部素材集信息表")
+public class ExternalMaterialCollection {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 创建人id
+     */
+    @Excel(name = "创建人id", width = 15)
+    @ApiModelProperty(value = "创建人id")
+    private String userId;
+    /**
+     * 媒体类型 1头条,2快手
+     */
+    @Excel(name = "媒体类型 1头条,2快手", width = 15)
+    @ApiModelProperty(value = "媒体类型 1头条,2快手")
+    private Integer mediaType;
+    /**
+     * 创建形式:1视频、2链接
+     */
+    @Excel(name = "创建形式:1视频、2链接,3导入,4同步内部", width = 15)
+    @ApiModelProperty(value = "创建形式:1视频、2链接,3导入,4同步内部")
+    private Integer createType;
+    /**
+     * 素材唯一标识
+     */
+    @Excel(name = "素材唯一标识", width = 15)
+    @ApiModelProperty(value = "素材唯一标识")
+    private String md5;
+    /**
+     * url
+     */
+    @Excel(name = "url", width = 15)
+    @ApiModelProperty(value = "url")
+    private String url;
+
+    /**
+     * 外部 url
+     */
+    @Excel(name = "externalUrl", width = 15)
+    @ApiModelProperty(value = "externalUrl")
+    private String externalUrl;
+    /**
+     * coverUrl
+     */
+    @Excel(name = "coverUrl", width = 15)
+    @ApiModelProperty(value = "coverUrl")
+    private String coverUrl;
+    /**
+     * 创建时间
+     */
+    private String statDate;
+    /**
+     * 素材来源
+     */
+    @Excel(name = "素材来源", width = 15)
+    @ApiModelProperty(value = "素材来源")
+    private String materialSource;
+    /**
+     * 行业标签
+     */
+    @Excel(name = "行业", width = 15)
+    @ApiModelProperty(value = "行业")
+    private String industry;
+
+    /**
+     * 产品
+     */
+    @Excel(name = "产品", width = 15)
+    @ApiModelProperty(value = "产品")
+    private String product;
+    /**
+     * 形式标签 modalityTagList::1
+     */
+    @Excel(name = "形式标签", width = 15)
+    @ApiModelProperty(value = "形式标签")
+    private String modalityTag;
+    /**
+     * 场景标签 senceTagList 4
+     */
+    @Excel(name = "场景标签", width = 15)
+    @ApiModelProperty(value = "场景标签")
+    private String sceneTag;
+    /**
+     * 基调标签 daTagList:2
+     */
+    @Excel(name = "基调标签", width = 15)
+    @ApiModelProperty(value = "基调标签")
+    private String daTag;
+    /**
+     * 版位
+     */
+    @Excel(name = "版位", width = 15)
+    @ApiModelProperty(value = "版位")
+    private String platePosition;
+    /**
+     * 素材描述
+     */
+    @Excel(name = "素材描述", width = 15)
+    @ApiModelProperty(value = "素材描述")
+    private String materialDescribe;
+    /**
+     * 素材名称
+     */
+    @Excel(name = "素材名称", width = 15)
+    @ApiModelProperty(value = "素材名称")
+    private String materialName;
+    /**
+     * 视频秒数
+     */
+    @Excel(name = "视频秒数", width = 15)
+    @ApiModelProperty(value = "视频秒数")
+    private Long second;
+    /**
+     * 格式
+     */
+    @Excel(name = "格式", width = 15)
+    @ApiModelProperty(value = "格式")
+    private String format;
+    /**
+     * 宽度
+     */
+    @Excel(name = "宽度", width = 15)
+    @ApiModelProperty(value = "宽度")
+    private String width;
+    /**
+     * 高度
+     */
+    @Excel(name = "高度", width = 15)
+    @ApiModelProperty(value = "高度")
+    private String height;
+    /**
+     * 大小
+     */
+    @Excel(name = "大小", width = 15)
+    @ApiModelProperty(value = "大小")
+    private String size;
+    /**
+     * createTime
+     */
+    @Excel(name = "createTime", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "createTime")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @Excel(name = "updateTime", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+
+    @TableField(exist = false)
+    private String startTime;
+    @TableField(exist = false)
+    private String endTime;
+}

+ 49 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/LoadFileUtil.java

@@ -60,6 +60,55 @@ public class LoadFileUtil {
 
     }
 
+    /**
+     * 上传文件
+     *
+     * @param urlStr
+     * @param savePath
+     * @return
+     * @throws IOException
+     */
+    public static String downLoadFromUrlAndName(String urlStr, String savePath,String fileName) {
+        try {
+            URL url = new URL(urlStr);
+
+            System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2,SSLv3");
+            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+            //设置超时间为3秒
+            conn.setConnectTimeout(60 * 1000);
+            //防止屏蔽程序抓取而返回403错误
+            conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
+            //得到输入流
+            InputStream inputStream = conn.getInputStream();
+            //获取自己数组
+            byte[] getData = readInputStream(inputStream);
+
+            //文件保存位置
+            File saveDir = new File(savePath);
+            if (!saveDir.exists()) {
+                saveDir.mkdirs();
+            }
+            String localPath = saveDir + File.separator + fileName;
+            File file = new File(localPath);
+            if (!file.exists()) {
+                file.getParentFile().mkdirs();
+            }
+            FileOutputStream fos = new FileOutputStream(file);
+            fos.write(getData);
+            if (fos != null) {
+                fos.close();
+            }
+            if (inputStream != null) {
+                inputStream.close();
+            }
+            return localPath;
+        } catch (Exception e) {
+            return null;
+        }
+
+
+    }
+
     public static byte[] readInputStream(InputStream inputStream) throws IOException {
         byte[] buffer = new byte[1024];
         int len = 0;

+ 407 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/controller/ExternalMaterialCollectionController.java

@@ -0,0 +1,407 @@
+package org.jeecg.modules.fileupload.controller;
+
+import cn.com.ctop.common.module.entity.MaterialTagInfo;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.ExportExcelUtils;
+import cn.com.ctop.common.module.utils.ExternalMaterialCollection;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.fileupload.service.IExternalMaterialCollectionService;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 外部素材集信息表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2022-01-12
+ */
+@Slf4j
+@Api(tags = "外部素材集信息表")
+@RestController
+@RequestMapping("/external/materialCollection")
+public class ExternalMaterialCollectionController {
+    @Autowired
+    private IExternalMaterialCollectionService externalMaterialCollectionService;
+
+    /**
+     * 分页列表查询
+     */
+    @GetMapping(value = "/list")
+    public Result<Object> queryPageList(ExternalMaterialCollection externalMaterialCollection,
+                                        @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                        HttpServletRequest req) {
+        try {
+            return externalMaterialCollectionService.queryPageList(externalMaterialCollection, pageNo, pageSize);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 上传单素材——视频
+     */
+    @PostMapping(value = "/addByVideo")
+    public Result<ExternalMaterialCollection> addByVideo(@RequestBody JSONObject json) {
+        Result<ExternalMaterialCollection> result = new Result<>();
+        try {
+            ExternalMaterialCollection materialCollection = JSONObject.parseObject(json.toJSONString(), ExternalMaterialCollection.class);
+            if (Check.isNull(materialCollection)) {
+                throw new Exception("数据格式异常");
+            }
+            externalMaterialCollectionService.addByVideo(materialCollection);
+            result.success("素材异步上传中");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 上传单素材——链接
+     */
+    @PostMapping(value = "/addByUrl")
+    public Result<ExternalMaterialCollection> addByUrl(@RequestBody JSONObject json) {
+        Result<ExternalMaterialCollection> result = new Result<>();
+        try {
+            ExternalMaterialCollection materialCollection = JSONObject.parseObject(json.toJSONString(), ExternalMaterialCollection.class);
+            if (Check.isNull(materialCollection)) {
+                throw new Exception("数据格式异常");
+            }
+            externalMaterialCollectionService.addByUrl(materialCollection);
+            result.success("素材异步上传中!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 上传批量素材——视频
+     */
+    @PostMapping(value = "/addMoreVideos")
+    public Result<ExternalMaterialCollection> addMoreVideos(@RequestBody JSONArray array) {
+        Result<ExternalMaterialCollection> result = new Result<>();
+        try {
+            if (array.size() < 1) {
+                return result.error500("缺少参数");
+            }
+            externalMaterialCollectionService.addMoreVideos(array);
+            result.success("素材异步上传中!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+
+    /**
+     * 上传批量素材——链接
+     */
+    @PostMapping(value = "/addMoreVideosByUrl")
+    public Result<ExternalMaterialCollection> addMoreVideosByUrl(@RequestBody JSONArray array) {
+        Result<ExternalMaterialCollection> result = new Result<>();
+        try {
+            if (array.size() < 1) {
+                return result.error500("缺少参数");
+            }
+            externalMaterialCollectionService.addMoreVideosByUrl(array);
+            result.success("素材异步上传中!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 上传批量素材——excel
+     */
+    @PostMapping(value = "/addMoreVideosByExcel")
+    @ResponseBody
+    public Result<Object> addMoreVideosByExcel(HttpServletResponse response, @RequestParam("file") MultipartFile file, @RequestParam("materialSource") String materialSource, @RequestParam("userId") String userId, @RequestParam("mediaType") Integer mediaType) {
+        response.setHeader("Access-Control-Allow-Origin", "*");
+        try {
+            if (Check.isNull(file) || Check.isNull(materialSource) || Check.isNull(userId) || Check.isNull(mediaType)) {
+                return Result.error("缺少参数");
+            }
+            return externalMaterialCollectionService.addMoreVideosByExcel(file, materialSource, userId, mediaType);
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("excel批量导入链接异常", e);
+            return Result.error("excel批量导入链接失败," + e.getMessage());
+        }
+    }
+
+    /**
+     * 校验素材是否已存在
+     */
+    @GetMapping(value = "/checkMaterialByMd5")
+    public Result<ExternalMaterialCollection> checkMaterialByMd5(String md5) {
+        Result<ExternalMaterialCollection> result = new Result<>();
+        try {
+            if (Check.isNull(md5)) {
+                return result.error500("缺少参数");
+            }
+            boolean f = externalMaterialCollectionService.checkMaterialByMd5(md5);
+            if (f) {
+                result.success("success");
+            } else {
+                result.error500("fail");
+            }
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 行业标签
+     */
+    @GetMapping(value = "/getIndustry")
+    public Result<Object> getIndustry() {
+        try {
+            return externalMaterialCollectionService.getIndustryLabel();
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            return Result.error("操作失败");
+        }
+    }
+
+    /**
+     * 标签回显
+     */
+    @GetMapping(value = "/getTagDetail")
+    public Result<Object> getTagDetail(String md5, Integer mediaType) {
+        return externalMaterialCollectionService.getTagDetail(md5, mediaType);
+    }
+
+
+    /**
+     * 同步内部素材
+     */
+    @GetMapping(value = "/createInternalMaterial")
+    public Result<Object> createInternalMaterial() {
+        try {
+            return externalMaterialCollectionService.createInternalMaterial();
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            return Result.error("操作失败");
+        }
+    }
+
+    /**
+     * 编辑
+     */
+    @PostMapping(value = "/edit")
+    public Result<ExternalMaterialCollection> edit(@RequestBody ExternalMaterialCollection externalMaterialCollection) {
+        Result<ExternalMaterialCollection> result = new Result<ExternalMaterialCollection>();
+        ExternalMaterialCollection externalMaterialCollectionEntity = externalMaterialCollectionService.getById(externalMaterialCollection.getId());
+        if (externalMaterialCollectionEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = externalMaterialCollectionService.updateById(externalMaterialCollection);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "外部素材集信息表-通过id删除", notes = "外部素材集信息表-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id") String id) {
+        try {
+            externalMaterialCollectionService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @ApiOperation(value = "外部素材集信息表-批量删除", notes = "外部素材集信息表-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<ExternalMaterialCollection> deleteBatch(@RequestParam(name = "ids") String ids) {
+        Result<ExternalMaterialCollection> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.externalMaterialCollectionService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "外部素材集信息表-通过id查询", notes = "外部素材集信息表-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<ExternalMaterialCollection> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<ExternalMaterialCollection> result = new Result<>();
+        ExternalMaterialCollection externalMaterialCollection = externalMaterialCollectionService.getById(id);
+        if (externalMaterialCollection == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(externalMaterialCollection);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<ExternalMaterialCollection> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                ExternalMaterialCollection externalMaterialCollection = JSON.parseObject(deString, ExternalMaterialCollection.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(externalMaterialCollection, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<ExternalMaterialCollection> pageList = externalMaterialCollectionService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "外部素材集信息表列表");
+        mv.addObject(NormalExcelConstants.CLASS, ExternalMaterialCollection.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("外部素材集信息表列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<ExternalMaterialCollection> listExternalMaterialCollections = ExcelImportUtil.importExcel(file.getInputStream(), ExternalMaterialCollection.class, params);
+                externalMaterialCollectionService.saveBatch(listExternalMaterialCollections);
+                return Result.ok("文件导入成功!数据行数:" + listExternalMaterialCollections.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+    /**
+     * 导出excel模板
+     */
+    @GetMapping("/exportTemplate")
+    public Result<Object> exportTemplate(HttpServletResponse response) {
+        try {
+
+            OutputStream os = response.getOutputStream();
+            ExportExcelUtils eeu = new ExportExcelUtils();
+            XSSFWorkbook workbook = new XSSFWorkbook();
+            String[] titles = {
+                    "行业(如:综合游戏、休闲益智、动作射击、棋牌桌游、综合服务、小额贷款、第三方支付、金融综合线上平台、综合电商、电商商家、跨境、其他电商零售类、服饰、美妆日化、快消、工具、影音娱乐、婚恋/交友、生活/健康)请严格按照以上的行业填写,否则无法识别",
+                    "产品",
+                    "素材链接",
+                    "版位",
+                    "素材描述"
+            };
+            eeu.putHeaders(workbook, 0, "Sheet1", titles);
+            eeu.putResponseHeader(response, "exportTemplate.xlsx");
+            workbook.write(os);
+            os.flush();
+            os.close();
+        } catch (IOException e) {
+            log.error(e.getMessage());
+        }
+        return Result.ok("success");
+    }
+}

+ 35 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/mapper/ExternalMaterialCollectionMapper.java

@@ -0,0 +1,35 @@
+package org.jeecg.modules.fileupload.mapper;
+
+import java.util.List;
+import java.util.Map;
+
+import cn.com.ctop.common.module.utils.ExternalMaterialCollection;
+import cn.com.ctop.crawler.modules.kuaishoucce.entity.KuaishouHotPhotoInfo;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 外部素材集信息表
+ * @author jeecg-boot
+ * 2022-01-12
+ * @version V1.0
+ */
+public interface ExternalMaterialCollectionMapper extends BaseMapper<ExternalMaterialCollection> {
+
+    void replaceBatch(List<ExternalMaterialCollection> list);
+
+    Long getListTotal(ExternalMaterialCollection externalMaterialCollection);
+
+    List<ExternalMaterialCollection> queryPageList(ExternalMaterialCollection externalMaterialCollection);
+
+    List<Map<String,String>> getIndustryLabel();
+
+    List<JSONObject> getParentIndustryLabel();
+
+    List<JSONObject> getMd5ByMediaType(@Param("mediaType") Integer mediaType);
+
+    List<ExternalMaterialCollection> getKuaiShouInternalMaterial(@Param("md5List")  List<JSONObject> md5List);
+
+    List<ExternalMaterialCollection> getBytedanceInternalMaterial(@Param("md5List")  List<JSONObject> md5List);
+}

+ 210 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/mapper/xml/ExternalMaterialCollectionMapper.xml

@@ -0,0 +1,210 @@
+<?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.modules.fileupload.mapper.ExternalMaterialCollectionMapper">
+
+
+    <insert id="replaceBatch">
+        replace into ctop_external_material_collection (
+        user_id,
+        media_type,
+        create_type,
+        stat_date,
+        md5,
+        url,
+        external_url,
+        cover_url,
+        material_source,
+        industry,
+        product,
+        modality_tag,
+        scene_tag,
+        da_tag,
+        plate_position,
+        material_describe,
+        material_name,
+        `second`,
+        format,
+        width,
+        height,
+        `size`
+        )
+        values
+        <foreach collection="list" item="item" separator=",">
+            (
+            #{item.userId},
+            #{item.mediaType},
+            #{item.createType},
+            #{item.statDate},
+            #{item.md5},
+            #{item.url},
+            #{item.externalUrl},
+            #{item.coverUrl},
+            #{item.materialSource},
+            #{item.industry},
+            #{item.product},
+            #{item.modalityTag},
+            #{item.sceneTag},
+            #{item.daTag},
+            #{item.platePosition},
+            #{item.materialDescribe},
+            #{item.materialName},
+            #{item.second},
+            #{item.format},
+            #{item.width},
+            #{item.height},
+            #{item.size}
+            )
+        </foreach>
+    </insert>
+
+    <select id="getListTotal" resultType="java.lang.Long">
+        SELECT
+        IFNULL( SUM( 1 ), 0 )
+        FROM
+        ctop_external_material_collection
+        <where>
+            <if test="materialName != null">
+                AND material_name like CONCAT('%',#{materialName}, '%')
+            </if>
+            <if test="mediaType != null">
+                AND media_type =#{mediaType}
+            </if>
+            <if test="startTime != null">
+                AND stat_date &gt;= #{startTime}
+            </if>
+            <if test="endTime != null">
+                AND stat_date &lt;=#{endTime}
+            </if>
+            <if test="daTag != null">
+                AND da_tag like CONCAT('%"', #{daTag}, '"%')
+            </if>
+            <if test="sceneTag != null">
+                AND scene_tag like CONCAT('%"', #{sceneTag}, '"%')
+            </if>
+            <if test="modalityTag != null">
+                AND modality_tag like CONCAT('%"', #{modalityTag}, '"%')
+            </if>
+            <if test="industry != null">
+                AND industry = #{industry}
+            </if>
+            <if test="materialSource != null">
+                AND material_source = #{materialSource}
+            </if>
+            <if test="platePosition != null">
+                AND plate_position LIKE CONCAT('%',#{platePosition}, '%')
+            </if>
+        </where>
+    </select>
+
+    <select id="queryPageList" resultType="cn.com.ctop.common.module.utils.ExternalMaterialCollection">
+        SELECT
+        *
+        FROM
+        ctop_external_material_collection
+        <where>
+            <if test="materialName != null">
+                AND material_name like CONCAT('%',#{materialName}, '%')
+            </if>
+            <if test="mediaType != null">
+                AND media_type =#{mediaType}
+            </if>
+            <if test="startTime != null">
+                AND stat_date &gt;= #{startTime}
+            </if>
+            <if test="endTime != null">
+                AND stat_date &lt;=#{endTime}
+            </if>
+            <if test="daTag != null">
+                AND da_tag like CONCAT('%"', #{daTag}, '"%')
+            </if>
+            <if test="sceneTag != null">
+                AND scene_tag like CONCAT('%"', #{sceneTag}, '"%')
+            </if>
+            <if test="modalityTag != null">
+                AND modality_tag like CONCAT('%"', #{modalityTag}, '"%')
+            </if>
+            <if test="industry != null">
+                AND industry = #{industry}
+            </if>
+            <if test="materialSource != null">
+                AND material_source = #{materialSource}
+            </if>
+            <if test="platePosition != null">
+                AND plate_position LIKE CONCAT('%',#{platePosition}, '%')
+            </if>
+        </where>
+        ORDER BY create_time DESC
+    </select>
+
+
+    <select id="getIndustryLabel" resultType="Map">
+        select parent_id as 'parentId',name
+        from ctop_external_material_industry
+        where parent_id != 0
+    </select>
+
+    <select id="getParentIndustryLabel" resultType="com.alibaba.fastjson.JSONObject">
+        select id, name
+        from ctop_external_material_industry
+        where parent_id = 0
+    </select>
+
+
+    <select id="getMd5ByMediaType" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT user_id as 'userId', signature as 'md5', form_tag_list as 'formTagList', mood_tag_list as 'moodTagList', scene_tag_list as 'sceneTagList', industry_id as 'industry', DATE_FORMAT(hot_date, '%Y-%m-%d') as 'statDate'
+        FROM application.hot_material_tag_info
+        where media_id = #{mediaType};
+    </select>
+
+
+    <select id="getKuaiShouInternalMaterial" resultType="cn.com.ctop.common.module.utils.ExternalMaterialCollection">
+        SELECT
+        t2.signature as 'md5',
+        t2.photo_name as 'materialName',
+        t2.url,
+        t2.cover_url,
+        6 as 'materialSource',
+        t3.second,
+        t3.format,
+        IFNULL(t3.width,t2.width) as 'width',
+        IFNULL(t3.height,t2.height) as 'height',
+        t3.size,
+        4 as 'createType',
+        2 as 'mediaType'
+        FROM ctop_kuaishou_video_get t2
+        LEFT JOIN ctop_material_parameter t3 ON t2.signature= t3.material_id
+        WHERE t2.signature IN
+        <foreach collection="md5List" item="item" separator=","
+                 open="(" close=")">
+            #{item.md5}
+        </foreach>
+        group by t2.signature
+    </select>
+
+    <select id="getBytedanceInternalMaterial" resultType="cn.com.ctop.common.module.utils.ExternalMaterialCollection">
+        SELECT
+        t1.signature AS 'md5',
+        t1.filename AS 'materialName',
+        t1.video_url as 'url',
+        if(t1.poster_url='素材所属主体与开发者主体不一致无法获取URL',t2.cover_url,t1.poster_url) as 'coverUrl',
+        5 AS 'materialSource',
+        ROUND(t1.duration) as 'second',
+        t1.format,
+        t1.width AS 'width',
+        t1.height,
+        t1.size,
+        4 AS 'createType',
+        1 AS 'mediaType'
+        FROM
+        ctop_bytedance_video_info t1
+        LEFT JOIN ctop_material_info t2 ON t1.signature = t2.code
+        WHERE
+        signature IN
+        <foreach collection="md5List" item="item" separator=","
+                 open="(" close=")">
+            #{item.md5}
+        </foreach>
+        group by signature
+    </select>
+
+</mapper>

+ 37 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/service/IExternalMaterialCollectionService.java

@@ -0,0 +1,37 @@
+package org.jeecg.modules.fileupload.service;
+
+import cn.com.ctop.common.module.utils.ExternalMaterialCollection;
+import com.alibaba.fastjson.JSONArray;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * 外部素材集信息表
+ *
+ * @author jeecg-boot
+ * 2022-01-12
+ * @version V1.0
+ */
+public interface IExternalMaterialCollectionService extends IService<ExternalMaterialCollection> {
+
+    Result<Object> queryPageList(ExternalMaterialCollection externalMaterialCollection, Integer pageNo, Integer pageSize);
+
+    void addByVideo(ExternalMaterialCollection materialCollection) throws Exception;
+
+    void addByUrl(ExternalMaterialCollection materialCollection) throws Exception;
+
+    void addMoreVideos(JSONArray array) throws Exception;
+
+    void addMoreVideosByUrl(JSONArray array) throws Exception;
+
+    boolean checkMaterialByMd5(String md5) throws Exception;
+
+    Result<Object> addMoreVideosByExcel(MultipartFile file, String materialSource, String userId, Integer mediaType) throws Exception;
+
+    Result<Object> getIndustryLabel();
+
+    Result<Object> createInternalMaterial();
+
+    Result<Object> getTagDetail(String md5, Integer mediaType);
+}

+ 480 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/service/impl/ExternalMaterialCollectionServiceImpl.java

@@ -0,0 +1,480 @@
+package org.jeecg.modules.fileupload.service.impl;
+
+import cn.com.ctop.common.module.entity.MaterialCutFrame;
+import cn.com.ctop.common.module.entity.TagInfo;
+import cn.com.ctop.common.module.service.IMaterialCutFrameService;
+import cn.com.ctop.common.module.service.ITagInfoService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CloudVideoProcessUtil;
+import cn.com.ctop.common.module.utils.CosUtils;
+import cn.com.ctop.common.module.utils.ExportExcelUtils;
+import cn.com.ctop.common.module.utils.ExternalMaterialCollection;
+import cn.com.ctop.common.module.utils.LoadFileUtil;
+import cn.com.ctop.common.module.vo.ResFileDTO;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import it.sauronsoftware.jave.Encoder;
+import it.sauronsoftware.jave.MultimediaInfo;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.fileupload.mapper.ExternalMaterialCollectionMapper;
+import org.jeecg.modules.fileupload.service.IExternalMaterialCollectionService;
+import org.jeecg.modules.system.entity.SysCategory;
+import org.jeecg.modules.system.service.ISysCategoryService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.net.URLDecoder;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 外部素材集信息表
+ *
+ * @author jeecg-boot
+ * 2022-01-12
+ * @version V1.0
+ */
+@Service
+public class ExternalMaterialCollectionServiceImpl extends ServiceImpl<ExternalMaterialCollectionMapper, ExternalMaterialCollection> implements IExternalMaterialCollectionService {
+
+    @Autowired
+    private ExternalMaterialCollectionMapper mapper;
+
+    @Resource
+    private IMaterialCutFrameService materialCutFrameService;
+
+    @Autowired
+    private ITagInfoService tagInfoService;
+
+    @Autowired
+    private ISysCategoryService sysCategoryService;
+
+    @Value("${oss.replace.download}")
+    private String downloadUrl;
+
+    private static ExecutorService uploadExecutorService = Executors.newFixedThreadPool(5);
+
+    @Override
+    public Result<Object> queryPageList(ExternalMaterialCollection externalMaterialCollection, Integer pageNo, Integer pageSize) {
+        Long total = mapper.getListTotal(externalMaterialCollection);
+        PageHelper.startPage(pageNo, pageSize, false);
+        PageInfo pageInfo = new PageInfo(mapper.queryPageList(externalMaterialCollection));
+        pageInfo.setTotal(total);
+        return Result.ok(pageInfo);
+    }
+
+    @Override
+    public void addByVideo(ExternalMaterialCollection materialCollection) throws Exception {
+        uploadExecutorService.submit(new Runnable() {
+            @Override
+            public void run() {
+                materialCollection.setCreateType(1);// 1视频、2链接
+                String url = materialCollection.getUrl();
+                if (!Check.isNull(url)) {
+                    url = "https:" + url;
+                }
+                materialCollection.setUrl(url);
+                String localUrl = null;
+                FileInputStream fis = null;
+                try {
+                    String videoName = null;
+                    String industryName = materialCollection.getIndustry();
+                    SysCategory category = sysCategoryService.getById(materialCollection.getIndustry());
+                    if (!Check.isNull(category)) {
+                        industryName = category.getName();
+                    }
+                    if (Check.isNull(materialCollection.getProduct())) {
+                        videoName = industryName + "-" + UUID.randomUUID().toString().replace("-", "").substring(0, 8) + ".mp4";
+                    } else {
+                        videoName = industryName + "-" + materialCollection.getProduct() + "-" + UUID.randomUUID().toString().replace("-", "").substring(0, 8) + ".mp4";
+                    }
+                    localUrl = LoadFileUtil.downLoadFromUrlAndName(url, downloadUrl, videoName);
+                    String md5 = LoadFileUtil.getMD5(localUrl);
+                    materialCollection.setMd5(md5);
+                    MaterialCutFrame cutFrame = materialCutFrameService.getCutFrameByCode(materialCollection.getMd5());
+                    if (Check.isNull(cutFrame)) {
+                        String videoUrl = URLDecoder.decode(url).replace("https://media-1301855440.cos.ap-chongqing.myqcloud.com/", "");
+                        String loadImage = "cutFrame/" + md5 + "/zero.jpg";
+                        String coverUrl = CloudVideoProcessUtil.videoCutPictureHandle(videoUrl, loadImage);
+                        materialCollection.setCoverUrl(coverUrl);
+                    } else {
+                        materialCollection.setCoverUrl(cutFrame.getUrl());
+                    }
+                    File file = new File(localUrl);
+                    it.sauronsoftware.jave.Encoder encoder = new Encoder();
+                    MultimediaInfo m = encoder.getInfo(file);
+                    long duration = m.getDuration();
+                    long secondDuration = duration / 1000;
+                    // 视频秒数
+                    materialCollection.setSecond(secondDuration);
+                    // 视频格式
+                    materialCollection.setFormat(m.getFormat());
+                    // 视频宽
+                    String width = String.valueOf(m.getVideo().getSize().getWidth());
+                    materialCollection.setWidth(width);
+                    // 视频高
+                    String height = String.valueOf(m.getVideo().getSize().getHeight());
+                    materialCollection.setHeight(height);
+                    fis = new FileInputStream(file);
+                    FileChannel fc = fis.getChannel();
+                    BigDecimal fileSize = new BigDecimal(fc.size());
+                    String size = fileSize.divide(new BigDecimal(1048576), 2, RoundingMode.HALF_UP) + "MB";
+                    materialCollection.setSize(size);
+                    materialCollection.setStatDate(DateUtils.formatDate(new Date()));
+                    materialCollection.setMaterialName(videoName);
+                    List<ExternalMaterialCollection> list = new ArrayList<>();
+                    list.add(materialCollection);
+                    mapper.replaceBatch(list);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                } finally {
+                    try {
+                        if (fis != null) {
+                            fis.close();
+                        }
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                    LoadFileUtil.delFile(localUrl);
+                }
+            }
+        });
+    }
+
+    @Override
+    public void addByUrl(ExternalMaterialCollection materialCollection) throws Exception {
+        uploadExecutorService.submit(new Runnable() {
+            @Override
+            public void run() {
+                materialCollection.setCreateType(2);// 1视频、2链接
+                String externalUrl = materialCollection.getExternalUrl();
+                String localUrl = null;
+                FileInputStream fis = null;
+                try {
+                    String videoName = null;
+                    String industryName = materialCollection.getIndustry();
+                    SysCategory category = sysCategoryService.getById(materialCollection.getIndustry());
+                    if (!Check.isNull(category)) {
+                        industryName = category.getName();
+                    }
+                    if (Check.isNull(materialCollection.getProduct())) {
+                        videoName = industryName + "-" + UUID.randomUUID().toString().replace("-", "").substring(0, 8) + ".mp4";
+                    } else {
+                        videoName = industryName + "-" + materialCollection.getProduct() + "-" + UUID.randomUUID().toString().replace("-", "").substring(0, 8) + ".mp4";
+                    }
+                    localUrl = LoadFileUtil.downLoadFromUrlAndName(externalUrl, downloadUrl, videoName);
+                    File file = new File(localUrl);
+                    it.sauronsoftware.jave.Encoder encoder = new Encoder();
+                    MultimediaInfo m = encoder.getInfo(file);
+                    long duration = m.getDuration();
+                    long secondDuration = duration / 1000;
+                    // 视频秒数
+                    materialCollection.setSecond(secondDuration);
+                    // 视频格式
+                    materialCollection.setFormat(m.getFormat());
+                    // 视频宽
+                    String width = String.valueOf(m.getVideo().getSize().getWidth());
+                    materialCollection.setWidth(width);
+                    // 视频高
+                    String height = String.valueOf(m.getVideo().getSize().getHeight());
+                    materialCollection.setHeight(height);
+                    fis = new FileInputStream(file);
+                    FileChannel fc = fis.getChannel();
+                    BigDecimal fileSize = new BigDecimal(fc.size());
+                    String size = fileSize.divide(new BigDecimal(1048576), 2, RoundingMode.HALF_UP) + "MB";
+                    //大小
+                    materialCollection.setSize(size);
+                    String url = null;
+                    try {
+                        String path = "external-videos/" + DateUtils.formatDate(new Date(), DateUtils.SHORT_FORMAT) + "/";
+                        materialCollection.setMaterialName(videoName);
+                        ResFileDTO resultFile = CosUtils.uploadDetailInputStreamV2(fis, videoName, "mp4", fc.size(), path);
+                        url = resultFile.getFileUrl();
+                        materialCollection.setUrl(url);
+                    } catch (IOException e) {
+                        log.error("上传COS异常", e);
+                        throw new Exception("上传COS失败");
+                    }
+                    String md5 = LoadFileUtil.getMD5(localUrl);
+                    materialCollection.setMd5(md5);
+                    MaterialCutFrame cutFrame = materialCutFrameService.getCutFrameByCode(materialCollection.getMd5());
+                    if (Check.isNull(cutFrame)) {
+                        String videoUrl = URLDecoder.decode(url).replace("https://media-1301855440.cos.ap-chongqing.myqcloud.com/", "");
+                        String loadImage = "cutFrame/" + md5 + "/zero.jpg";
+                        String coverUrl = CloudVideoProcessUtil.videoCutPictureHandle(videoUrl, loadImage);
+                        materialCollection.setCoverUrl(coverUrl);
+                    } else {
+                        materialCollection.setCoverUrl(cutFrame.getUrl());
+                    }
+                    materialCollection.setStatDate(DateUtils.formatDate(new Date()));
+                    List<ExternalMaterialCollection> list = new ArrayList<>();
+                    list.add(materialCollection);
+                    mapper.replaceBatch(list);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                } finally {
+                    try {
+                        if (fis != null) {
+                            fis.close();
+                        }
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                    LoadFileUtil.delFile(localUrl);
+                }
+            }
+        });
+    }
+
+    @Override
+    public void addMoreVideos(JSONArray array) throws Exception {
+        for (int i = 0; i < array.size(); i++) {
+            ExternalMaterialCollection materialCollection = JSONObject.parseObject(array.getJSONObject(i).toJSONString(), ExternalMaterialCollection.class);
+            if (materialCollection == null) {
+                continue;
+            }
+            this.addByVideo(materialCollection);
+        }
+    }
+
+    @Override
+    public void addMoreVideosByUrl(JSONArray array) throws Exception {
+        for (int i = 0; i < array.size(); i++) {
+            ExternalMaterialCollection materialCollection = JSONObject.parseObject(array.getJSONObject(i).toJSONString(), ExternalMaterialCollection.class);
+            if (materialCollection == null) {
+                continue;
+            }
+            this.addByUrl(materialCollection);
+        }
+    }
+
+    @Override
+    public Result<Object> addMoreVideosByExcel(MultipartFile file, String materialSource, String userId, Integer mediaType) throws Exception {
+        JSONObject returnJson = new JSONObject();
+        Workbook workbook = null;
+        String fileName = file.getOriginalFilename();
+        String substring = fileName.substring(fileName.lastIndexOf(".") + 1).toUpperCase();
+        if ("XLS".equals(substring)) {
+            workbook = new HSSFWorkbook(file.getInputStream());
+        } else if ("XLSX".equals(substring)) {
+            workbook = new XSSFWorkbook(file.getInputStream());
+        } else {
+            throw new Exception("文件不是Excel文件");
+        }
+        Sheet sheet = workbook.getSheet("Sheet1");
+        if (Check.isNull(sheet)) {
+            throw new Exception("Sheet标题不是默认的Sheet1");
+        }
+        int rows = sheet.getLastRowNum();// 指的行数,一共有多少行+
+        if (rows == 0) {
+            throw new Exception("请填写数据");
+        }
+        List<ExternalMaterialCollection> list = new ArrayList<>();
+        ExportExcelUtils eeu = new ExportExcelUtils();
+        for (int i = 1; i <= rows + 1; i++) {
+            Row row = sheet.getRow(i);
+            if (row != null) {
+                //行业
+                String industryLabel = eeu.getCellValue(row.getCell(0));
+                if (Check.isNull(industryLabel)) {
+                    return Result.error("解析数据失败,文档中第" + (i + 1) + "行,行业列缺失数据");
+                }
+                //产品
+                String product = eeu.getCellValue(row.getCell(1));
+                //链接
+                String externalUrl = eeu.getCellValue(row.getCell(2));
+                if (Check.isNull(externalUrl)) {
+                    return Result.error("解析数据失败,文档中第" + (i + 1) + "行,素材链接列缺失数据");
+                }
+                if (!externalUrl.contains("http")) {
+                    externalUrl = "https:" + externalUrl;
+                }
+                //板位
+                String platePosition = eeu.getCellValue(row.getCell(3));
+                //描述
+                String materialDescribe = eeu.getCellValue(row.getCell(4));
+                if(!Check.isNull(materialDescribe)){
+                    materialDescribe = materialDescribe.substring(0,10);
+                }
+                ExternalMaterialCollection materialCollection = new ExternalMaterialCollection();
+                QueryWrapper<SysCategory> queryWrapper = new QueryWrapper<>();
+                queryWrapper.eq("name", industryLabel).last("limit 1");
+                SysCategory one = sysCategoryService.getOne(queryWrapper);
+                if (!Check.isNull(one)) {
+                    materialCollection.setIndustry(one.getId());
+                }
+                materialCollection.setProduct(product);
+                materialCollection.setExternalUrl(externalUrl);
+                materialCollection.setPlatePosition(platePosition);
+                materialCollection.setMaterialDescribe(materialDescribe);
+                materialCollection.setMaterialSource(materialSource);
+                materialCollection.setStatDate(DateUtils.formatDate(new Date()));
+                materialCollection.setUserId(userId);
+                materialCollection.setCreateType(3);
+                materialCollection.setMediaType(mediaType);
+                list.add(materialCollection);
+            }
+        }
+        if (!list.isEmpty()) {
+            for (ExternalMaterialCollection materialCollection : list) {
+                this.addByUrl(materialCollection);
+            }
+        }
+        return Result.ok("素材异步上传中");
+    }
+
+    @Override
+    public boolean checkMaterialByMd5(String md5) throws Exception {
+        QueryWrapper<ExternalMaterialCollection> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("md5", md5).last("limit 1");
+        ExternalMaterialCollection one = this.getOne(queryWrapper);
+        if (Check.isNull(one)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+
+    @Override
+    public Result<Object> getIndustryLabel() {
+        List<JSONObject> json = mapper.getParentIndustryLabel();
+        List<Map<String, String>> industryLabels = mapper.getIndustryLabel();
+        for (JSONObject obj : json) {
+            JSONArray children = new JSONArray();
+            String id = obj.getString("id");
+            for (Map map : industryLabels) {
+                if (id.equals(map.get("parentId"))) {
+                    children.add(map.get("name"));
+                }
+            }
+            obj.put("child", children);
+        }
+        return Result.ok(json);
+    }
+
+    @Override
+    public Result<Object> createInternalMaterial() {
+        List<JSONObject> md5List = mapper.getMd5ByMediaType(2);// 1头条,2快手
+        Map<String, JSONObject> map = new HashMap<>();
+        for (JSONObject object : md5List) {
+            map.put(object.getString("md5"), object);
+        }
+        List<ExternalMaterialCollection> list = new ArrayList<>();
+        if (!Check.isNull(md5List) && !md5List.isEmpty()) {
+            list = mapper.getKuaiShouInternalMaterial(md5List);
+            for (ExternalMaterialCollection materialCollection : list) {
+                JSONObject entity2 = map.get(materialCollection.getMd5());
+                if (!Check.isNull(entity2)) {
+                    materialCollection.setUserId(entity2.getString("userId"));
+                    materialCollection.setModalityTag(getList(entity2.getString("formTagList")));
+                    materialCollection.setDaTag(getList(entity2.getString("moodTagList")));
+                    materialCollection.setSceneTag(getList(entity2.getString("sceneTagList")));
+                    materialCollection.setIndustry(entity2.getString("industry"));
+                    materialCollection.setStatDate(entity2.getString("statDate"));
+                }
+            }
+        }
+        if (!Check.isNull(list)) {
+            mapper.replaceBatch(list);
+        }
+
+        md5List = mapper.getMd5ByMediaType(1);// 1头条,2快手
+        Map<String, JSONObject> map1 = new HashMap<>();
+        for (JSONObject object : md5List) {
+            map1.put(object.getString("md5"), object);
+        }
+        if (!Check.isNull(md5List) && !md5List.isEmpty()) {
+            list = mapper.getBytedanceInternalMaterial(md5List);
+            for (ExternalMaterialCollection materialCollection : list) {
+                JSONObject entity1 = map1.get(materialCollection.getMd5());
+                if (!Check.isNull(entity1)) {
+                    materialCollection.setUserId(entity1.getString("userId"));
+                    materialCollection.setModalityTag(getList(entity1.getString("formTagList")));
+                    materialCollection.setDaTag(getList(entity1.getString("moodTagList")));
+                    materialCollection.setSceneTag(getList(entity1.getString("sceneTagList")));
+                    materialCollection.setIndustry(entity1.getString("industry"));
+                    materialCollection.setStatDate(entity1.getString("statDate"));
+                }
+            }
+        }
+        if (!Check.isNull(list)) {
+            mapper.replaceBatch(list);
+        }
+        return Result.ok("success");
+    }
+
+    private String getList(String str) {
+        try {
+            if (Check.isNull(str)) {
+                return null;
+            }
+            String[] split = str.split(",");
+            List<String> list = Arrays.asList(split);
+            return JSONObject.toJSONString(list);
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    @Override
+    public Result<Object> getTagDetail(String md5, Integer mediaType) {
+        QueryWrapper<ExternalMaterialCollection> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("media_type", mediaType);
+        queryWrapper.eq("md5", md5).last("limit 1");
+        ExternalMaterialCollection one = this.getOne(queryWrapper);
+        if (Check.isNull(one)) {
+            return Result.error("未查询到素材");
+        }
+        List<TagInfo> modTagList = new ArrayList<>();
+        List<TagInfo> modalityTagList = new ArrayList<>();
+        List<TagInfo> sceneTagList = new ArrayList<>();
+        JSONArray modTagArr = JSONArray.parseArray(one.getDaTag());
+        if (!Check.isNull(modTagArr) && !modTagArr.isEmpty()) {
+            modTagList = tagInfoService.getListByCode(modTagArr);
+        }
+
+        JSONArray ModalityTagArr = JSONArray.parseArray(one.getModalityTag());
+        if (!Check.isNull(ModalityTagArr) && !ModalityTagArr.isEmpty()) {
+            modalityTagList = tagInfoService.getListByCode(ModalityTagArr);
+        }
+        JSONArray sceneTagArr = JSONArray.parseArray(one.getSceneTag());
+        if (!Check.isNull(sceneTagArr) && !sceneTagArr.isEmpty()) {
+            sceneTagList = tagInfoService.getListByCode(sceneTagArr);
+        }
+
+        JSONObject result = new JSONObject();
+        result.put("modTagList", modTagList);
+        result.put("modalityTagList", modalityTagList);
+        result.put("sceneTagList", sceneTagList);
+        return Result.ok(result);
+    }
+}
+
+