소스 검색

接口调整

hcst_sunzhen 5 년 전
부모
커밋
56009c4854

+ 2 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/PerformanceController2.java

@@ -544,11 +544,12 @@ public class PerformanceController2 {
         String userId = dto.getUserId();
         String startDate = dto.getStartDate();
         String endDate = dto.getEndDate();
+        Integer appType = dto.getAppType();
         if(userId==null || startDate == null || endDate == null){
             result.setSuccess(false);
             result.setMessage("userId和时间不能为空");
         }
-        List<MaterialInfo> materialInfoList = performanceService.getVideoList(userId, startDate, endDate);
+        List<MaterialInfo> materialInfoList = performanceService.getVideoList(appType, userId, startDate, endDate);
         result.setSuccess(true);
         result.setResult(materialInfoList);
         return result;

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/IPerformanceService2.java

@@ -91,7 +91,7 @@ public interface IPerformanceService2 extends IService<Performance> {
     List<MaterialInfo> effiVideoList(Integer appType, Integer year, Integer quarter, String userId);
 
     //获取有效视频列表
-    List<MaterialInfo> getVideoList(String userId, String startDate, String endDate);
+    List<MaterialInfo> getVideoList(Integer appType, String userId, String startDate, String endDate);
 
     List<MaterialInfo> getEffiWeekVideoList(Integer appType, String startDate, String endDate, String userId);
 

+ 148 - 9
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/PerformanceServiceImpl2.java

@@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.security.Signature;
 import java.text.ParseException;
 import java.util.*;
 
@@ -98,12 +99,14 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         log.info("统计时间所在年" + thisYear + "月" + thisMonth + "季" + thisQuarter);
 
         //快手有效视频(新)
-        kuaishouNewEffiVideo(calcDate, effiCalcStart, effiFirstWeekCalcEnd, thisYear, thisMonth, thisQuarter, DateUtils.formatDate(friday), DateUtils.formatDate(thursday));
+        //kuaishouNewEffiVideo(calcDate, effiCalcStart, effiFirstWeekCalcEnd, thisYear, thisMonth, thisQuarter, DateUtils.formatDate(friday), DateUtils.formatDate(thursday));
         //头条有效视频(新)
-        toutiaoNewEffiVideo(calcDate, effiCalcStart, effiFirstWeekCalcEnd, thisYear, thisMonth, thisQuarter, DateUtils.formatDate(friday), DateUtils.formatDate(thursday));
+        //toutiaoNewEffiVideo(calcDate, effiCalcStart, effiFirstWeekCalcEnd, thisYear, thisMonth, thisQuarter, DateUtils.formatDate(friday), DateUtils.formatDate(thursday));
 
-        //总视频
-        kuaishouNewVideo( calcDate,  thisYear,  thisQuarter,  thisMonth, DateUtils.formatDate(friday),  DateUtils.formatDate(thursday));
+        //快手总视频
+        //newKuaishouVideo( calcDate,  thisYear,  thisQuarter,  thisMonth, DateUtils.formatDate(friday),  DateUtils.formatDate(thursday));
+        //头条总视频
+        newToutiaoVideo( calcDate,  thisYear,  thisQuarter,  thisMonth, DateUtils.formatDate(friday),  DateUtils.formatDate(thursday));
     }
 
     //快手有效视频统计
@@ -327,6 +330,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             shot.setWeekStart(friday);
             shot.setWeekEnd(thursday);
             shot.setCompanyId(companyId);
+            shot.setCost(effiVideoDTO.getCharge());
             userEfficientVideoMapMapper.insert(shot);
 
             //平面
@@ -341,6 +345,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             plane.setWeekStart(friday);
             plane.setWeekEnd(thursday);
             plane.setCompanyId(companyId);
+            plane.setCost(effiVideoDTO.getCharge());
             userEfficientVideoMapMapper.insert(plane);
 
             //编导
@@ -355,6 +360,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             plan.setWeekStart(friday);
             plan.setWeekEnd(thursday);
             plan.setCompanyId(companyId);
+            plan.setCost(effiVideoDTO.getCharge());
             userEfficientVideoMapMapper.insert(plan);
 
             //剪辑
@@ -369,6 +375,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             clip.setWeekStart(friday);
             clip.setWeekEnd(thursday);
             clip.setCompanyId(companyId);
+            clip.setCost(effiVideoDTO.getCharge());
             userEfficientVideoMapMapper.insert(clip);
 
             //有效视频同步到有效视频素材库--测试的时候不打开,生产打开
@@ -449,6 +456,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             shot.setWeekStart(friday);
             shot.setWeekEnd(thursday);
             shot.setCompanyId(companyId);
+            shot.setCost(effiVideoDTO.getCharge());
             userEfficientVideoMapMapper.insert(shot);
 
             //平面
@@ -463,6 +471,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             plane.setWeekStart(friday);
             plane.setWeekEnd(thursday);
             plane.setCompanyId(companyId);
+            plane.setCost(effiVideoDTO.getCharge());
             userEfficientVideoMapMapper.insert(plane);
 
             //编导
@@ -477,6 +486,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             plan.setWeekStart(friday);
             plan.setWeekEnd(thursday);
             plan.setCompanyId(companyId);
+            plan.setCost(effiVideoDTO.getCharge());
             userEfficientVideoMapMapper.insert(plan);
 
             //剪辑
@@ -491,6 +501,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             clip.setWeekStart(friday);
             clip.setWeekEnd(thursday);
             clip.setCompanyId(companyId);
+            clip.setCost(effiVideoDTO.getCharge());
             userEfficientVideoMapMapper.insert(clip);
 
             //有效视频同步到有效视频素材库--测试的时候不打开,生产打开
@@ -505,16 +516,24 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //新总视频计算开始
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-    public void kuaishouNewVideo(Date calcDate, int thisYear, int thisQuarter, int thisMonth, String friday, String thursday){
+    public void newKuaishouVideo(Date calcDate, int thisYear, int thisQuarter, int thisMonth, String friday, String thursday){
         log.info("设计师周总视频计算开始");
+        Integer appType = 2;
+        //获取创建时间在计算周时间范围内的创意
         List<String> videoMd5s = userEfficientVideoMapMapper.getVideoByDates(friday,thursday);
         for(String md5:videoMd5s){
             //去重
-            Integer signatureCount = userEfficientVideoMapMapper.getVideoCountByCode(md5);
+            Integer signatureCount = userEfficientVideoMapMapper.getVideoCountByCode(md5, appType);
             if(signatureCount > 0){
                 continue;
             }
             //
+            //去除其中的视频的最早创建时间早于创建周的创意
+            Integer count = userEfficientVideoMapMapper.kuaishouCreativeLtCount(md5,friday);
+            if (count >0){
+                continue;
+            }
+            //
 
             //获取该视频的编导、剪辑、拍摄、平面等信息
             EffiVideoDTO effiVideoDTO = userEfficientVideoMapMapper.getDesignerInfoByCode(md5);
@@ -535,6 +554,8 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
                 companyId = userEfficientVideoMapMapper.getCompanyInfoByUserId( effiVideoDTO.getPlaneId() );
             }
 
+            String creativeDate = userEfficientVideoMapMapper.kuaishouCreativeEarlistDate(md5);
+
             UserVideoMap shot = new UserVideoMap();
             UserVideoMap plane = new UserVideoMap();
             UserVideoMap plan = new UserVideoMap();
@@ -551,6 +572,8 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             shot.setWeekStart(friday);
             shot.setWeekEnd(thursday);
             shot.setCompanyId(companyId);
+            shot.setAppType(appType);
+            shot.setCreativeDate(creativeDate);
             userVideoMapMapper.insert(shot);
 
             //平面
@@ -564,6 +587,8 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             plane.setWeekStart(friday);
             plane.setWeekEnd(thursday);
             plane.setCompanyId(companyId);
+            plane.setAppType(appType);
+            plane.setCreativeDate(creativeDate);
             userVideoMapMapper.insert(plane);
 
             //编导
@@ -577,6 +602,8 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             plan.setWeekStart(friday);
             plan.setWeekEnd(thursday);
             plan.setCompanyId(companyId);
+            plan.setAppType(appType);
+            plan.setCreativeDate(creativeDate);
             userVideoMapMapper.insert(plan);
 
             //剪辑
@@ -590,10 +617,121 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             clip.setWeekStart(friday);
             clip.setWeekEnd(thursday);
             clip.setCompanyId(companyId);
+            clip.setAppType(appType);
+            clip.setCreativeDate(creativeDate);
             userVideoMapMapper.insert(clip);
         }
-        log.info("设计师周总视频计算结束");
+        log.info("快手设计师周总视频计算结束");
      }
+
+
+    public void newToutiaoVideo(Date calcDate, int thisYear, int thisQuarter, int thisMonth, String friday, String thursday){
+        log.info("设计师周总视频计算开始");
+        Integer appType = 1;
+        //获取创建时间在计算周时间范围内的创意
+        List<String> videoMd5s = userEfficientVideoMapMapper.getToutiaoVideoByDates(friday,thursday);
+        for(String md5:videoMd5s){
+            //去重
+            Integer signatureCount = userEfficientVideoMapMapper.getVideoCountByCode(md5, appType);
+            if(signatureCount > 0){
+                continue;
+            }
+            //
+            //去除其中的视频的最早创建时间早于创建周的创意
+            Integer count = userEfficientVideoMapMapper.toutiaoCreativeLtCount(md5,friday);
+            if (count >0){
+                continue;
+            }
+            //
+
+            //获取该视频的编导、剪辑、拍摄、平面等信息
+            EffiVideoDTO effiVideoDTO = userEfficientVideoMapMapper.getDesignerInfoByCode(md5);
+            if(effiVideoDTO == null){
+                effiVideoDTO = new EffiVideoDTO();
+            }
+            effiVideoDTO.setSignature(md5);
+
+            String companyId = null;
+            //根据编导id获取视频所属分公司
+            if( StringUtils.isNotBlank(effiVideoDTO.getPlanId()) ) {
+                companyId = userEfficientVideoMapMapper.getCompanyInfoByUserId(effiVideoDTO.getPlanId());
+            }else if( StringUtils.isNotBlank(effiVideoDTO.getClipId()) ){
+                companyId = userEfficientVideoMapMapper.getCompanyInfoByUserId( effiVideoDTO.getClipId() );
+            }else if( StringUtils.isNotBlank(effiVideoDTO.getShotId()) ){
+                companyId = userEfficientVideoMapMapper.getCompanyInfoByUserId( effiVideoDTO.getShotId() );
+            }else if ( StringUtils.isNotBlank(effiVideoDTO.getPlaneId()) ){
+                companyId = userEfficientVideoMapMapper.getCompanyInfoByUserId( effiVideoDTO.getPlaneId() );
+            }
+
+            String creativeDate = userEfficientVideoMapMapper.toutiaoCreativeEarlistDate(md5);
+
+            UserVideoMap shot = new UserVideoMap();
+            UserVideoMap plane = new UserVideoMap();
+            UserVideoMap plan = new UserVideoMap();
+            UserVideoMap clip = new UserVideoMap();
+
+            //拍摄
+            shot.setUserId(effiVideoDTO.getShotId());
+            shot.setVideoSignature(effiVideoDTO.getSignature());
+            shot.setQuarter(thisQuarter);
+            shot.setYear(thisYear);
+            shot.setMonth(thisMonth);
+            shot.setCalcDate(calcDate);
+            shot.setRoleId("shot");
+            shot.setWeekStart(friday);
+            shot.setWeekEnd(thursday);
+            shot.setCompanyId(companyId);
+            shot.setAppType(appType);
+            shot.setCreativeDate(creativeDate);
+            userVideoMapMapper.insert(shot);
+
+            //平面
+            plane.setUserId(effiVideoDTO.getPlaneId());
+            plane.setVideoSignature(effiVideoDTO.getSignature());
+            plane.setQuarter(thisQuarter);
+            plane.setYear(thisYear);
+            plane.setMonth(thisMonth);
+            plane.setCalcDate(calcDate);
+            plane.setRoleId("plane");
+            plane.setWeekStart(friday);
+            plane.setWeekEnd(thursday);
+            plane.setCompanyId(companyId);
+            plane.setAppType(appType);
+            plane.setCreativeDate(creativeDate);
+            userVideoMapMapper.insert(plane);
+
+            //编导
+            plan.setUserId(effiVideoDTO.getPlanId());
+            plan.setVideoSignature(effiVideoDTO.getSignature());
+            plan.setQuarter(thisQuarter);
+            plan.setYear(thisYear);
+            plan.setMonth(thisMonth);
+            plan.setCalcDate(calcDate);
+            plan.setRoleId("plan");
+            plan.setWeekStart(friday);
+            plan.setWeekEnd(thursday);
+            plan.setCompanyId(companyId);
+            plan.setAppType(appType);
+            plan.setCreativeDate(creativeDate);
+            userVideoMapMapper.insert(plan);
+
+            //剪辑
+            clip.setUserId(effiVideoDTO.getClipId());
+            clip.setVideoSignature(effiVideoDTO.getSignature());
+            clip.setQuarter(thisQuarter);
+            clip.setYear(thisYear);
+            clip.setMonth(thisMonth);
+            clip.setCalcDate(calcDate);
+            clip.setRoleId("clip");
+            clip.setWeekStart(friday);
+            clip.setWeekEnd(thursday);
+            clip.setCompanyId(companyId);
+            clip.setAppType(appType);
+            clip.setCreativeDate(creativeDate);
+            userVideoMapMapper.insert(clip);
+        }
+        log.info("快手设计师周总视频计算结束");
+    }
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //新总视频计算结束
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -2227,6 +2365,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             for(String md5:md5s){
                 BigDecimal cost = userEfficientVideoMapMapper.getToutiaoSumChargeBySignature(md5, startDate, endDate);
                 if(cost== null){
+
                     cost = BigDecimal.ZERO;
                 }
                 totalCost = totalCost.add(cost);
@@ -2320,8 +2459,8 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
     }
 
     //根据userid,appType,年度,季度查询有效视频列表
-    public List<MaterialInfo> getVideoList(String userId, String startDate, String endDate){
-        List<MaterialInfo> materialInfoList = userEfficientVideoMapMapper.getVideoList(userId, startDate, endDate);
+    public List<MaterialInfo> getVideoList(Integer appType, String userId, String startDate, String endDate){
+        List<MaterialInfo> materialInfoList = userEfficientVideoMapMapper.getVideoList(appType, userId, startDate, endDate);
         return materialInfoList;
     }
 

+ 3 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/entity/UserEfficientVideoMap.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.userefficientvideomap.entity;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 import java.util.Date;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
@@ -83,5 +84,7 @@ public class UserEfficientVideoMap {
 
     private String companyId;
 
+    private BigDecimal cost;
+
 
 }

+ 12 - 2
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/UserEfficientVideoMapMapper.java

@@ -164,7 +164,7 @@ public interface UserEfficientVideoMapMapper extends BaseMapper<UserEfficientVid
 
     List<String> getVideoByDates(@Param("startDate")String startDate, @Param("endDate")String endDate);
 
-    Integer getVideoCountByCode(@Param("signature")String signature);
+    Integer getVideoCountByCode(@Param("signature")String signature, @Param("appType")Integer appType);
 
     List<String> getTotalSignatureByUserId(@Param("userId")String userId, @Param("startDate")String startDate, @Param("endDate")String endDate);
 
@@ -172,6 +172,16 @@ public interface UserEfficientVideoMapMapper extends BaseMapper<UserEfficientVid
 
     BigDecimal getToutiaoSumChargeBySignature(@Param("signature")String signature, @Param("startDate")String startDate, @Param("endDate")String endDate);
 
-    List<MaterialInfo> getVideoList(@Param("userId")String userId, @Param("startDate")String startDate, @Param("endDate")String endDate);
+    List<MaterialInfo> getVideoList(@Param("appType")Integer appType, @Param("userId")String userId, @Param("startDate")String startDate, @Param("endDate")String endDate);
+
+    Integer kuaishouCreativeLtCount(@Param("signature")String signature, @Param("date")String date);
+
+    String kuaishouCreativeEarlistDate(@Param("signature")String singature);
+
+    List<String> getToutiaoVideoByDates(@Param("startDate")String startDate, @Param("endDate")String endDate);
+
+    Integer toutiaoCreativeLtCount(@Param("signature")String signature, @Param("date")String date);
+
+    String toutiaoCreativeEarlistDate(@Param("signature")String singature);
 }
 

+ 73 - 3
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/xml/UserEfficientVideoMapMapper.xml

@@ -1135,7 +1135,7 @@
 
     <!-- 按时间段获取视频总量 -->
     <select id="getVideoByDates" resultType="string">
-        select
+       <!-- select
         code
         from (
             select
@@ -1148,7 +1148,40 @@
             date_format(create_time, '%Y-%m-%d') &lt;= #{endDate}
             order by create_time
             ) a
-        group by code
+        group by code -->
+
+            select
+            b.signature
+        from ctop_kuaishou_creative a
+        left join ctop_kuaishou_video_get b on  a.photo_id = b.photo_id
+        where
+        date_format(a.creative_create_time, '%Y-%m-%d') &gt;= #{startDate}
+        and
+        date_format(a.creative_create_time, '%Y-%m-%d') &lt;= #{endDate}
+        and b.signature is not null
+        group by b.signature
+    </select>
+
+    <select id="kuaishouCreativeLtCount" resultType="integer">
+            select
+            count(1)
+        from ctop_kuaishou_creative a
+        left join ctop_kuaishou_video_get b on a.photo_id = b.photo_id
+        where
+        b.signature = #{signature}
+        and
+        date_format(a.creative_create_time, '%Y-%m-%d') &lt; #{date}
+    </select>
+
+    <select id="kuaishouCreativeEarlistDate" resultType="string">
+            select
+            date_format(creative_create_time, '%Y-%m-%d') as date
+        from ctop_kuaishou_creative a
+        left join ctop_kuaishou_video_get b on a.photo_id = b.photo_id
+        where
+        b.signature = #{signature}
+        order by a.creative_create_time
+        limit 1
     </select>
 
     <select id="getVideoCountByCode" resultType="integer">
@@ -1157,6 +1190,42 @@
         from
         ctop_user_video_map
         where video_signature = #{signature}
+        and app_type = #{appType}
+    </select>
+
+    <select id="toutiaoCreativeEarlistDate" resultType="string">
+            select
+            date_format(creative_create_time, '%Y-%m-%d') as date
+        from ctop_bytedance_creative a
+        left join ctop_bytedance_video_info b on a.video_id = b.id
+        where
+        b.signature = #{signature}
+        order by a.creative_create_time
+        limit 1
+    </select>
+
+    <select id="toutiaoCreativeLtCount" resultType="integer">
+            select
+            count(1)
+        from ctop_bytedance_creative a
+        left join ctop_bytedance_video_info b on a.video_id = b.id
+        where
+        b.signature = #{signature}
+        and
+        date_format(a.creative_create_time, '%Y-%m-%d') &lt; #{date}
+    </select>
+
+    <select id="getToutiaoVideoByDates" resultType="string">
+        select
+        b.signature
+        from ctop_bytedance_creative a
+        left join ctop_bytedance_video_info b on a.video_id = b.id
+        where
+        date_format(a.creative_create_time, '%Y-%m-%d') &gt;= #{startDate}
+        and
+        date_format(a.creative_create_time, '%Y-%m-%d') &lt;= #{endDate}
+        and b.signature is not null
+        group by b.signature
     </select>
 
     <!-- 视频素材 -->
@@ -1182,7 +1251,8 @@
         where
         m.user_id = #{userId} and
         m.calc_date &gt;= #{startDate} and
-        m.calc_date &lt;= #{endDate}
+        m.calc_date &lt;= #{endDate} and
+        m.app_type = #{appType}
     </select>
 
 </mapper>

+ 4 - 0
performance-appraisal/src/main/java/cn/com/ctop/uservideomap/entity/UserVideoMap.java

@@ -84,4 +84,8 @@ public class UserVideoMap {
 	/**updateTime*/
     @ApiModelProperty(value = "updateTime")
 	private Date updateTime;
+
+    private String creativeDate;
+
+    private Integer appType;
 }