소스 검색

绩效周报接口调整

hcst_sunzhen 5 년 전
부모
커밋
be43aa29d5

+ 19 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/PerformanceController2.java

@@ -535,6 +535,25 @@ public class PerformanceController2 {
         return result;
         return result;
     }
     }
 
 
+    @AutoLog(value = "获取相关视频列表")
+    @ApiOperation(value = "获取相关视频列表", notes = "获取相关视频列表")
+    @PostMapping(value = "/getVideoList")
+    public Result<List<MaterialInfo>> getVideoList(@RequestBody PerformanceTimeDTO dto,
+                                                       HttpServletRequest req) {
+        Result<List<MaterialInfo>> result = new Result<>();
+        String userId = dto.getUserId();
+        String startDate = dto.getStartDate();
+        String endDate = dto.getEndDate();
+        if(userId==null || startDate == null || endDate == null){
+            result.setSuccess(false);
+            result.setMessage("userId和时间不能为空");
+        }
+        List<MaterialInfo> materialInfoList = performanceService.getVideoList(userId, startDate, endDate);
+        result.setSuccess(true);
+        result.setResult(materialInfoList);
+        return result;
+    }
+
     @AutoLog(value = "获取本周相关有效视频列表")
     @AutoLog(value = "获取本周相关有效视频列表")
     @ApiOperation(value = "获取本周相关有效视频列表", notes = "获取本周相关有效视频列表")
     @ApiOperation(value = "获取本周相关有效视频列表", notes = "获取本周相关有效视频列表")
     @PostMapping(value = "/getWeekEffiVideoList")
     @PostMapping(value = "/getWeekEffiVideoList")

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

@@ -90,6 +90,9 @@ public interface IPerformanceService2 extends IService<Performance> {
     //获取有效视频列表
     //获取有效视频列表
     List<MaterialInfo> effiVideoList(Integer appType, Integer year, Integer quarter, String userId);
     List<MaterialInfo> effiVideoList(Integer appType, Integer year, Integer quarter, String userId);
 
 
+    //获取有效视频列表
+    List<MaterialInfo> getVideoList(String userId, String startDate, String endDate);
+
     List<MaterialInfo> getEffiWeekVideoList(Integer appType, String startDate, String endDate, String userId);
     List<MaterialInfo> getEffiWeekVideoList(Integer appType, String startDate, String endDate, String userId);
 
 
     //获取快手优化师绩效实时数据
     //获取快手优化师绩效实时数据

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

@@ -505,9 +505,17 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //新总视频计算开始
     //新总视频计算开始
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-    public void kuaishouNewVideo(Date calcDate, int thisYear, int thisQuarter, int thisMonth,String friday, String thursday){
+    public void kuaishouNewVideo(Date calcDate, int thisYear, int thisQuarter, int thisMonth, String friday, String thursday){
+        log.info("设计师周总视频计算开始");
         List<String> videoMd5s = userEfficientVideoMapMapper.getVideoByDates(friday,thursday);
         List<String> videoMd5s = userEfficientVideoMapMapper.getVideoByDates(friday,thursday);
         for(String md5:videoMd5s){
         for(String md5:videoMd5s){
+            //去重
+            Integer signatureCount = userEfficientVideoMapMapper.getVideoCountByCode(md5);
+            if(signatureCount > 0){
+                continue;
+            }
+            //
+
             //获取该视频的编导、剪辑、拍摄、平面等信息
             //获取该视频的编导、剪辑、拍摄、平面等信息
             EffiVideoDTO effiVideoDTO = userEfficientVideoMapMapper.getDesignerInfoByCode(md5);
             EffiVideoDTO effiVideoDTO = userEfficientVideoMapMapper.getDesignerInfoByCode(md5);
             if(effiVideoDTO == null){
             if(effiVideoDTO == null){
@@ -584,6 +592,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             clip.setCompanyId(companyId);
             clip.setCompanyId(companyId);
             userVideoMapMapper.insert(clip);
             userVideoMapMapper.insert(clip);
         }
         }
+        log.info("设计师周总视频计算结束");
      }
      }
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //新总视频计算结束
     //新总视频计算结束
@@ -2178,24 +2187,22 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         List<UserDto2> userDto2List = userEfficientVideoMapMapper.getKuaishouDepartUserInfo();
         List<UserDto2> userDto2List = userEfficientVideoMapMapper.getKuaishouDepartUserInfo();
         //2 循环所有人,并查询出每个人的有效视频数、总视频数、总消耗
         //2 循环所有人,并查询出每个人的有效视频数、总视频数、总消耗
         for (UserDto2 userDto : userDto2List) {
         for (UserDto2 userDto : userDto2List) {
-            String roleCode = userDto.getRoleCode();
             //2.1 获取有效视频数量
             //2.1 获取有效视频数量
             Integer effiVideoCount = userEfficientVideoMapMapper.getEffiVideoCountByCalcDate(startDate, endDate, userDto.getRoleId(), userDto.getUserId(), 2);
             Integer effiVideoCount = userEfficientVideoMapMapper.getEffiVideoCountByCalcDate(startDate, endDate, userDto.getRoleId(), userDto.getUserId(), 2);
-            //2.2 获取有效视频总数
-            Integer videoCount = userEfficientVideoMapMapper.getQuarterMaterialCountByUserId(userDto.getRoleCode(), startDate, endDate, userDto.getUserId());
+            //2.2 获取视频总数
+            Integer videoCount = userEfficientVideoMapMapper.getVideoCountByUserId(userDto.getUserId(), startDate, endDate);
             //2.3 总消耗
             //2.3 总消耗
-            BigDecimal cost = null;
-            if ("clip".equals(roleCode)) {
-                cost = userEfficientVideoMapMapper.getTotalCostByClipId(userDto.getUserId(), startDate, endDate);
-            } else if ("plan".equals(roleCode)) {
-                cost = userEfficientVideoMapMapper.getTotalCostByPlanId(userDto.getUserId(), startDate, endDate);
-            } else if ("shot".equals(roleCode)) {
-                cost = userEfficientVideoMapMapper.getTotalCostByShotId(userDto.getUserId(), startDate, endDate);
+            BigDecimal totalCost = BigDecimal.ZERO;
+            List<String> md5s = userEfficientVideoMapMapper.getTotalSignatureByUserId(userDto.getUserId(), startDate, endDate);
+            for(String md5:md5s){
+                BigDecimal cost = userEfficientVideoMapMapper.getSumChargeBySignature(md5, startDate, endDate);
+                    if(cost== null){
+                        cost = BigDecimal.ZERO;
+                    }
+                totalCost = totalCost.add(cost);
             }
             }
-            if(cost == null){
-                cost = BigDecimal.ZERO;
-            }
-            userDto.setCost(cost);
+
+            userDto.setCost(totalCost);
             userDto.setVideoCount(videoCount);
             userDto.setVideoCount(videoCount);
             userDto.setEffiVideoCount(effiVideoCount);
             userDto.setEffiVideoCount(effiVideoCount);
         }
         }
@@ -2213,16 +2220,9 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             //2.1 获取有效视频数量
             //2.1 获取有效视频数量
             Integer effiVideoCount = userEfficientVideoMapMapper.getEffiVideoCountByCalcDate(startDate, endDate, userDto.getRoleId(), userDto.getUserId(), 1);
             Integer effiVideoCount = userEfficientVideoMapMapper.getEffiVideoCountByCalcDate(startDate, endDate, userDto.getRoleId(), userDto.getUserId(), 1);
             //2.2 获取视频总数
             //2.2 获取视频总数
-            Integer videoCount = userEfficientVideoMapMapper.getQuarterMaterialCountByUserId(userDto.getRoleCode(), startDate, endDate, userDto.getUserId());
+            Integer videoCount = userEfficientVideoMapMapper.getVideoCountByUserId(userDto.getUserId(), startDate, endDate);
             //2.3 总消耗
             //2.3 总消耗
-            BigDecimal cost = null;
-            if ("clip".equals(roleCode)) {
-                cost = userEfficientVideoMapMapper.toutiaoGetTotalCostByClipId(userDto.getUserId(), startDate, endDate);
-            } else if ("plan".equals(roleCode)) {
-                cost = userEfficientVideoMapMapper.toutiaoGetTotalCostByPlanId(userDto.getUserId(), startDate, endDate);
-            } else if ("shot".equals(roleCode)) {
-                cost = userEfficientVideoMapMapper.toutiaoGetTotalCostByShotId(userDto.getUserId(), startDate, endDate);
-            }
+            BigDecimal cost = userEfficientVideoMapMapper.getTotalCostByUserId(userDto.getUserId(), startDate, endDate);
 
 
             if(cost == null){
             if(cost == null){
                 cost = BigDecimal.ZERO;
                 cost = BigDecimal.ZERO;
@@ -2316,6 +2316,12 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
     }
     }
 
 
     //根据userid,appType,年度,季度查询有效视频列表
     //根据userid,appType,年度,季度查询有效视频列表
+    public List<MaterialInfo> getVideoList(String userId, String startDate, String endDate){
+        List<MaterialInfo> materialInfoList = userEfficientVideoMapMapper.getVideoList(userId, startDate, endDate);
+        return materialInfoList;
+    }
+
+    //根据userid,appType,年度,季度查询有效视频列表
     public List<MaterialInfo> getEffiWeekVideoList(Integer appType, String startDate, String endDate, String userId){
     public List<MaterialInfo> getEffiWeekVideoList(Integer appType, String startDate, String endDate, String userId){
         List<MaterialInfo> materialInfoList = userEfficientVideoMapMapper.getEffiWeekVideoList(appType, startDate, endDate, userId);
         List<MaterialInfo> materialInfoList = userEfficientVideoMapMapper.getEffiWeekVideoList(appType, startDate, endDate, userId);
         return materialInfoList;
         return materialInfoList;

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

@@ -26,6 +26,10 @@ public interface UserEfficientVideoMapMapper extends BaseMapper<UserEfficientVid
 
 
     int getQuarterMaterialCountByUserId(@Param("roleCode") String roleCode, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("userId") String userId);
     int getQuarterMaterialCountByUserId(@Param("roleCode") String roleCode, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("userId") String userId);
 
 
+    int getVideoCountByUserId(@Param("userId") String userId, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    BigDecimal getTotalCostByUserId(@Param("userId") String userId, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
     BigDecimal getTotalCostByClipId(@Param("userId") String userId, @Param("startDate") String startDate, @Param("endDate") String endDate);
     BigDecimal getTotalCostByClipId(@Param("userId") String userId, @Param("startDate") String startDate, @Param("endDate") String endDate);
 
 
     BigDecimal getTotalCostByShotId(@Param("userId") String userId, @Param("startDate") String startDate, @Param("endDate") String endDate);
     BigDecimal getTotalCostByShotId(@Param("userId") String userId, @Param("startDate") String startDate, @Param("endDate") String endDate);
@@ -160,4 +164,12 @@ public interface UserEfficientVideoMapMapper extends BaseMapper<UserEfficientVid
 
 
     List<String> getVideoByDates(@Param("startDate")String startDate, @Param("endDate")String endDate);
     List<String> getVideoByDates(@Param("startDate")String startDate, @Param("endDate")String endDate);
 
 
+    Integer getVideoCountByCode(@Param("signature")String signature);
+
+    List<String> getTotalSignatureByUserId(@Param("userId")String userId, @Param("startDate")String startDate, @Param("endDate")String endDate);
+
+    BigDecimal getSumChargeBySignature(@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);
 }
 }
+

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

@@ -75,6 +75,16 @@
         </choose>
         </choose>
     </select>
     </select>
 
 
+    <select id="getVideoCountByUserId" resultType="integer">
+            select
+            count(1)
+        from
+        ctop_user_video_map
+        where user_id = #{userId}
+            and DATE_FORMAT(calc_date,'%Y-%m-%d') &gt;= #{startDate}
+            and DATE_FORMAT(calc_date,'%Y-%m-%d') &lt;= #{endDate}
+    </select>
+
     <!-- 根据clip_id获取视频总消耗 -->
     <!-- 根据clip_id获取视频总消耗 -->
     <select id="getTotalCostByClipId" resultType="java.math.BigDecimal">
     <select id="getTotalCostByClipId" resultType="java.math.BigDecimal">
             select
             select
@@ -92,6 +102,50 @@
         and c.clip_id = #{userId}
         and c.clip_id = #{userId}
     </select>
     </select>
 
 
+    <select id="getTotalCostByUserId" resultType="java.math.BigDecimal">
+            select
+            sum(a.charge) as charge
+        from
+        ctop_kuaishou_report_daily_creative a
+        left join
+        (
+        select
+        video_signature as signature
+        from
+        ctop_user_video_map
+        where user_id = #{userId}
+        and DATE_FORMAT(calc_date,'%Y-%m-%d') &gt;= #{startDate}
+        and DATE_FORMAT(calc_date,'%Y-%m-%d') &lt;= #{endDate}
+        group by video_signature) b
+        on a.signature = b.signature
+        where
+        DATE_FORMAT(a.stat_date,'%Y-%m-%d') &gt;= #{startDate}
+        and DATE_FORMAT(a.stat_date,'%Y-%m-%d') &lt;= #{endDate}
+    </select>
+
+    <select id="getTotalSignatureByUserId" resultType="string">
+        select
+        video_signature as signature
+        from
+        ctop_user_video_map
+        where user_id = #{userId}
+        and DATE_FORMAT(calc_date,'%Y-%m-%d') &gt;= #{startDate}
+        and DATE_FORMAT(calc_date,'%Y-%m-%d') &lt;= #{endDate}
+        group by video_signature
+    </select>
+
+    <select id="getSumChargeBySignature" resultType="java.math.BigDecimal">
+        select
+            sum(a.charge) as charge
+        from
+        ctop_kuaishou_report_daily_creative a
+        where a.signature = #{signature}
+        and
+        DATE_FORMAT(a.stat_date,'%Y-%m-%d') &gt;= #{startDate}
+        and
+        DATE_FORMAT(a.stat_date,'%Y-%m-%d') &lt;= #{endDate}
+    </select>
+
     <!-- 根据shot_id获取视频总消耗 -->
     <!-- 根据shot_id获取视频总消耗 -->
     <select id="getTotalCostByShotId" resultType="java.math.BigDecimal">
     <select id="getTotalCostByShotId" resultType="java.math.BigDecimal">
             select
             select
@@ -931,7 +985,7 @@
             i.watermark_material_name as watermarkMaterialName
             i.watermark_material_name as watermarkMaterialName
         from
         from
         ctop_user_efficient_video_map m
         ctop_user_efficient_video_map m
-        left join ctop_material_info i on m.efficient_video_signature = i.code
+        left join (select id,code,url,material_name,watermark_material_name from ctop_material_info group by code) i on m.efficient_video_signature = i.code
         where
         where
         m.user_id = #{userId} and
         m.user_id = #{userId} and
         m.app_type =#{appType} and
         m.app_type =#{appType} and
@@ -1074,4 +1128,29 @@
         group by code
         group by code
     </select>
     </select>
 
 
+    <select id="getVideoCountByCode" resultType="integer">
+        select
+        count(1)
+        from
+        ctop_user_video_map
+        where video_signature = #{signature}
+    </select>
+
+    <!-- 视频素材 -->
+    <select id="getVideoList" resultType="cn.com.ctop.common.module.entity.MaterialInfo">
+            select
+            i.id as id,
+            i.code as code,
+            i.url as url,
+            i.material_name as materialName,
+            i.watermark_material_name as watermarkMaterialName
+        from
+        ctop_user_video_map m
+        left join ctop_material_info i on m.video_signature = i.code
+        where
+        m.user_id = #{userId} and
+        m.calc_date &gt;= #{startDate} and
+        m.calc_date &lt;= #{endDate}
+    </select>
+
 </mapper>
 </mapper>