Pārlūkot izejas kodu

素材池功能修改

zhaoxian 4 gadi atpakaļ
vecāks
revīzija
782edc31b2

+ 4 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouProjectVideoGetController.java

@@ -7,6 +7,7 @@ import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouProjectVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouProjectVideoGetService;
 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;
@@ -87,7 +88,7 @@ public class KuaishouProjectVideoGetController {
             if (Check.isNull(signature) || Check.isNull(projectId)) {
                 return Result.error("缺失参数");
             }
-            List<String> photoIds = videoGetService.queryPhotoIdsByProjectAndMd5(projectId, signature);
+            List<String> photoIds = videoGetService.queryPhotoIdsByProjectAndMd5(projectId, signature,null);
             if (!Check.isNull(photoIds)) {
                 return kuaishouProjectVideoGetService.queryCreativeBySignature(photoIds,accountId, pageNo, pageSize);
             }
@@ -148,7 +149,7 @@ public class KuaishouProjectVideoGetController {
             if (Check.isNull(projectId)) {
                 return Result.error("请选择项目");
             }
-            Long accountId = data.getLong("accountId");
+            JSONArray accountId = data.getJSONArray("accountId");
             if (Check.isNull(accountId)) {
                 return Result.error("请选择账户");
             }
@@ -162,7 +163,7 @@ public class KuaishouProjectVideoGetController {
             queryWrapper.eq("project_id", projectId);
             queryWrapper.eq("signature", signature);
             kuaishouProjectVideoGetService.update(videoGet, queryWrapper);
-            List<String> photoIds = videoGetService.queryPhotoIdsByProjectAndMd5(projectId, signature);
+            List<String> photoIds = videoGetService.queryPhotoIdsByProjectAndMd5(projectId, signature,accountId);
             for (Object photoId : photoIds) {
                 kuaishouProjectVideoGetService.deleteCreativesByPhotoId(photoId);
             }

+ 2 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouVideoGetMapper.java

@@ -3,6 +3,7 @@ package cn.com.ctop.kuaishou.modules.batch.mapper;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouProjectVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
@@ -52,5 +53,5 @@ public interface KuaiShouVideoGetMapper extends BaseMapper<KuaiShouVideoGet> {
 
     List<JSONObject> getAccountIds();
 
-    List<String> queryPhotoIdsByProjectAndMd5(@Param("projectId") Long projectId, @Param("signature") String signature);
+    List<String> queryPhotoIdsByProjectAndMd5(@Param("projectId") Long projectId, @Param("signature") String signature, @Param("accountId") JSONArray accountId);
 }

+ 110 - 121
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml

@@ -60,10 +60,10 @@
         </if>
         <if test="signatureList != null and signatureList != '' ">
             and signature in
-              <foreach collection="signatureList" item="item" separator=","
-                             open="(" close=")">
-                    #{item}
-                </foreach>
+            <foreach collection="signatureList" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
         </if>
         group by signature
         order by stat_date desc
@@ -72,31 +72,32 @@
 
     <select id="getHighQualityVideo" parameterType="java.util.Map"
             resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet">
-        select * from ctop_kuaishou_video_get
+        select *
+        from ctop_kuaishou_video_get
         where account_id = #{accountId}
-        and signature in
-        (
-        select
-            daily_material.signature
-        from
-        ctop_kuaishou_report_daily_material daily_material
-        inner join
-        ctop_user_allocation allocation
-        on daily_material.account_id = allocation.account_id
-        where  allocation.project_id in (select project_id from ctop_user_allocation where account_id = #{accountId})
-        and  to_days(now()) - to_days(daily_material.stat_date) &lt;= #{days}
-        and daily_material.signature is not null
-        GROUP BY daily_material.signature
-        order by sum(daily_material.charge) desc
-        limit #{num}
-        )
+          and signature in
+              (
+                  select daily_material.signature
+                  from ctop_kuaishou_report_daily_material daily_material
+                           inner join
+                       ctop_user_allocation allocation
+                       on daily_material.account_id = allocation.account_id
+                  where allocation.project_id in
+                        (select project_id from ctop_user_allocation where account_id = #{accountId})
+                    and to_days(now()) - to_days(daily_material.stat_date) &lt;= #{days}
+                    and daily_material.signature is not null
+                  GROUP BY daily_material.signature
+                  order by sum(daily_material.charge) desc
+            limit #{num}
+            )
     </select>
 
     <select id="selectPhotoIdsByAccountId" parameterType="java.lang.Long"
             resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet">
-        select * from ctop_kuaishou_video_get
+        select *
+        from ctop_kuaishou_video_get
         where account_id = #{accountId}
-        and status = 0
+          and status = 0
     </select>
 
     <select id="getVideoListByMap" resultType="com.alibaba.fastjson.JSONObject">
@@ -131,32 +132,32 @@
         order by stat_date desc
     </select>
     <select id="getPhotoIdsByParams" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet">
-        select distinct photo_id from ctop_kuaishou_video_get
+        select distinct photo_id
+        from ctop_kuaishou_video_get
         where account_id = #{accountId}
-        and signature = #{signature}
-        and status = 0
+          and signature = #{signature}
+          and status = 0
     </select>
 
     <insert id="etlVideoBaseInfoByStaDate">
-    replace INTO ctop_etl_kuaishou_video_base_info (
-	signature,
-	channel_type,
-	photo_id,
-    photo_name,
-    material_type
-    ) SELECT
+        replace
+        INTO ctop_etl_kuaishou_video_base_info (
 	signature,
 	channel_type,
 	photo_id,
     photo_name,
     material_type
-  FROM
-	ctop_kuaishou_video_get
-	where  stat_date &gt;= #{statDate}
-	and signature is not null
-   GROUP BY
-	photo_id
- </insert>
+    )
+        SELECT signature,
+               channel_type,
+               photo_id,
+               photo_name,
+               material_type
+        FROM ctop_kuaishou_video_get
+        where stat_date &gt;= #{statDate}
+          and signature is not null
+        GROUP BY photo_id
+    </insert>
 
     <select id="getVideoInfoByPhotoIds" resultType="com.alibaba.fastjson.JSONObject">
         select
@@ -175,49 +176,39 @@
         group by photo_id
     </select>
     <select id="getTotalCountByAccount" resultType="java.lang.Integer">
-        select
-        count(distinct signature)
+        select count(distinct signature)
         from ctop_kuaishou_video_get
-        where  account_id = #{accountId}
+        where account_id = #{accountId}
     </select>
     <select id="getTotalCountByAccountAndStatDate" resultType="java.lang.Integer">
-        SELECT
-    	count(DISTINCT signature)
-        FROM
-	    ctop_kuaishou_video_get
-        WHERE
-	    account_id = #{accountId}
-        AND DATE_FORMAT(stat_date, '%Y-%m-%d') = #{statDate}
+        SELECT count(DISTINCT signature)
+        FROM ctop_kuaishou_video_get
+        WHERE account_id = #{accountId}
+          AND DATE_FORMAT(stat_date, '%Y-%m-%d') = #{statDate}
     </select>
     <select id="getEffectiveCountByAccountId" resultType="java.lang.Integer">
-        SELECT
-        count(1)
-        FROM
-        (
-        SELECT
-        signature
-        FROM
-        ctop_kuaishou_video_get
-        WHERE
-        account_id = #{accountId}
-        GROUP BY
-        signature
-        ) t1
-        LEFT JOIN ctop_kuaishou_video_etl_info t2 ON t1.signature = t2.video_code
-        WHERE
-        t2.effect_date IS NOT NULL
-        AND t2.effect_day_num &lt;= 7
+        SELECT count(1)
+        FROM (
+                 SELECT signature
+                 FROM ctop_kuaishou_video_get
+                 WHERE account_id = #{accountId}
+                 GROUP BY signature
+             ) t1
+                 LEFT JOIN ctop_kuaishou_video_etl_info t2 ON t1.signature = t2.video_code
+        WHERE t2.effect_date IS NOT NULL
+          AND t2.effect_day_num &lt;= 7
 
     </select>
     <select id="getZeroVideoByParams" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet">
         select
         video.*
         from
-        ctop_kuaishou_video_get video left join ctop_kuaishou_video_relate_creatives creative on video.photo_id = creative.photo_id and video.account_id = creative.account_id
+        ctop_kuaishou_video_get video left join ctop_kuaishou_video_relate_creatives creative on video.photo_id =
+        creative.photo_id and video.account_id = creative.account_id
         where
-              1=1
+        1=1
         <if test="relativeCnt!=null">
-           and creative.creative_count &lt;= #{relativeCnt}
+            and creative.creative_count &lt;= #{relativeCnt}
         </if>
 
         <if test="accountId!=null">
@@ -244,36 +235,29 @@
     </select>
 
     <select id="getHotMoneyCountByAccountId" resultType="java.lang.Integer">
-        SELECT
-        count(1)
-        FROM
-        (
-        SELECT
-        signature
-        FROM
-        ctop_kuaishou_video_get
-        WHERE
-        account_id = #{accountId}
-        GROUP BY
-        signature
-        ) t1
-        LEFT JOIN ctop_kuaishou_video_etl_info t2 ON t1.signature = t2.video_code
-        WHERE
-        t2.faddish_date is not null
-        and faddish_day_num &lt;=14
+        SELECT count(1)
+        FROM (
+                 SELECT signature
+                 FROM ctop_kuaishou_video_get
+                 WHERE account_id = #{accountId}
+                 GROUP BY signature
+             ) t1
+                 LEFT JOIN ctop_kuaishou_video_etl_info t2 ON t1.signature = t2.video_code
+        WHERE t2.faddish_date is not null
+          and faddish_day_num &lt;= 14
     </select>
     <select id="getHistoryTopVideoByParams"
             resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet">
         select
-            video.*
+        video.*
         from
-            ctop_kuaishou_report_daily_material report
+        ctop_kuaishou_report_daily_material report
         left join (select * from ctop_kuaishou_video_get
-                where
-                    status = 0
-                and signature is not null
+        where
+        status = 0
+        and signature is not null
         <if test="accountId!=null">
-                 and account_id = #{accountId}
+            and account_id = #{accountId}
         </if>
         <if test="channelType!=null">
             and channel_type = #{channelType}
@@ -288,11 +272,11 @@
             and photo_name like concat(#{appVersion},'%')
         </if>
         group by signature) video
-                  on video.signature = report.signature
+        on video.signature = report.signature
         left join (SELECT id, photo_id from ctop_ai_creative_limit WHERE account_id = #{accountId}) t2
-            on video.photo_id = t2.photo_id
-            where video.id is not null
-            group by video.signature
+        on video.photo_id = t2.photo_id
+        where video.id is not null
+        group by video.signature
         order by sum(report.charge) desc
         <if test="videoCnt!=null">
             limit #{videoCnt}
@@ -301,46 +285,51 @@
 
     <select id="selectProjectVideo" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaishouProjectVideoGet">
         SELECT
-            t1.id,
-            t2.project_id,
-            t1.status,
-            t1.photo_id,
-            t1.width,
-            t1.height,
-            t1.url,
-            t1.cover_url,
-            t1.material_type,
-            t1.channel_type,
-            t1.stat_date,
-            t1.signature,
-            t1.photo_name,
-            t1.update_time
+        t1.id,
+        t2.project_id,
+        t1.status,
+        t1.photo_id,
+        t1.width,
+        t1.height,
+        t1.url,
+        t1.cover_url,
+        t1.material_type,
+        t1.channel_type,
+        t1.stat_date,
+        t1.signature,
+        t1.photo_name,
+        t1.update_time
         FROM ctop_kuaishou_video_get t1
-                 INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        INNER JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
         WHERE t1.`status` =0
-          AND t2.project_id=#{projectId}
+        AND t2.project_id=#{projectId}
         <if test="updateTime!=null">
-          AND t1.update_time >=#{updateTime}
+            AND t1.update_time >=#{updateTime}
         </if>
 
     </select>
 
     <select id="getAccountIds" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-            account_id 'accountId',DATE_FORMAT(MAX(create_time),'%Y-%m-%d %H:%i:%s') 'startDate'
+        SELECT account_id 'accountId',DATE_FORMAT(MAX(create_time), '%Y-%m-%d %H:%i:%s') 'startDate'
         FROM ctop_kuaishou_video_get
         where channel_type = 1
-          and  status = 0
+          and status = 0
         GROUP BY account_id
     </select>
 
     <select id="queryPhotoIdsByProjectAndMd5" resultType="java.lang.String">
         SELECT t1.photo_id
         FROM ctop_kuaishou_video_get t1
-                 LEFT JOIN  ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
         where t1.status = 0
-          AND t2.project_id = #{projectId}
-          AND t1.signature =#{signature}
+        AND t2.project_id = #{projectId}
+        AND t1.signature =#{signature}
+        <if test="accountId !=null">
+            AND t1.account_id IN
+            <foreach collection="accountId" item="id" separator="," open="(" close=")">
+                #{id}
+            </foreach>
+        </if>
         GROUP BY photo_id
     </select>
 
@@ -363,7 +352,7 @@
         END
         WHERE id IN
         <foreach item="videoGet" index="index" collection="videoGetList" open="(" separator="," close=")">
-             #{videoGet.id}
+            #{videoGet.id}
         </foreach>
     </update>
 </mapper>

+ 5 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoGetService.java

@@ -2,6 +2,7 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
@@ -27,7 +28,7 @@ public interface IKuaiShouVideoGetService extends IService<KuaiShouVideoGet> {
 
     List<KuaiShouVideoGet> getNewVideoDescDate(Long accountId, Integer newVideoCnt);
 
-    List<KuaiShouVideoGet> getNewVideoBetweenTime(Long accountId, String startTime, String endTime,Integer channelType,String appVersion,Integer videoCnt);
+    List<KuaiShouVideoGet> getNewVideoBetweenTime(Long accountId, String startTime, String endTime, Integer channelType, String appVersion, Integer videoCnt);
 
     List<JSONObject> getVideoListByMap(Map<String, Object> requestMap);
 
@@ -49,13 +50,13 @@ public interface IKuaiShouVideoGetService extends IService<KuaiShouVideoGet> {
 
     Integer getHotMoneyCountByAccountId(Long accountId);
 
-    List<KuaiShouVideoGet> getZeroVideoByParams(Long accountId, String startTime, String endTime, Long videoCnt,String appVersion,Integer channelType,Integer relativeCnt);
+    List<KuaiShouVideoGet> getZeroVideoByParams(Long accountId, String startTime, String endTime, Long videoCnt, String appVersion, Integer channelType, Integer relativeCnt);
 
     List<KuaiShouVideoGet> getHistoryTopVideoByParams(Long accountId, String startTime, String endTime, Long videoCnt, String appVersion, Integer channelType);
 
-    void getSuZaoList(String token, Long accountId, int page,String startDate);
+    void getSuZaoList(String token, Long accountId, int page, String startDate);
 
     List<JSONObject> getAccountIds();
 
-    List<String> queryPhotoIdsByProjectAndMd5(Long projectId, String signature);
+    List<String> queryPhotoIdsByProjectAndMd5(Long projectId, String signature, JSONArray accountId);
 }

+ 2 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java

@@ -350,7 +350,7 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
     }
 
     @Override
-    public List<String> queryPhotoIdsByProjectAndMd5(Long projectId, String signature) {
-        return videoGetMapper.queryPhotoIdsByProjectAndMd5(projectId, signature);
+    public List<String> queryPhotoIdsByProjectAndMd5(Long projectId, String signature,JSONArray accountId) {
+        return videoGetMapper.queryPhotoIdsByProjectAndMd5(projectId, signature,accountId);
     }
 }