소스 검색

快手图片消耗,头条图片消耗数据报表

syh 4 년 전
부모
커밋
3152c79a2f

+ 4 - 70
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ImageReportDailyServiceImpl.java

@@ -1,8 +1,5 @@
 package org.jeecg.modules.ctop.service.impl;
 
-import cn.com.ctop.common.module.entity.MaterialImageInfo;
-import cn.com.ctop.common.module.entity.SysUser;
-import cn.com.ctop.common.module.service.IMaterialImageInfoService;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.common.module.vo.*;
@@ -17,7 +14,6 @@ import org.jeecg.modules.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -25,8 +21,6 @@ import java.util.Map;
 @Service
 public class ImageReportDailyServiceImpl implements IImageReportDailyService {
     @Autowired
-    private IMaterialImageInfoService imageInfoService;
-    @Autowired
     private BytedanceReportMaterialDailyMapper bytedanceReportMaterialDailyMapper;
     @Autowired
     private KuaishouReportDailyImageMapper kuaishouReportDailyImageMapper;
@@ -62,23 +56,8 @@ public class ImageReportDailyServiceImpl implements IImageReportDailyService {
             pageSize = 10;
         }
         PageHelper.startPage(pageNumber,pageSize);
-        List<BytedanceImageCostVO> vos = bytedanceReportMaterialDailyMapper.bytedanceImageCost(startDate,endDate,accountList,code);
+        List<BytedanceImageCostVO> vos = bytedanceReportMaterialDailyMapper.bytedanceImageCost(startDate,endDate,accountList,code.trim());
         PageInfo<BytedanceImageCostVO> pageInfo = new PageInfo<>(vos);
-        if(null!=vos&&!vos.isEmpty()){
-            List<BytedanceImageCostVO>setVos = new ArrayList<>();
-            for(BytedanceImageCostVO vo:vos){
-                MaterialImageInfo imageInfo = imageInfoService.getByCode(vo.getSignature());
-                if(null!=imageInfo){
-                    vo.setUserId(imageInfo.getUserId());
-                    SysUser user = sysUserService.getById(imageInfo.getUserId());
-                    vo.setUserName(user.getUsername());
-                }else{
-                    vo.setUserName("-");
-                }
-                setVos.add(vo);
-            }
-            pageInfo.setList(setVos);
-        }
         result.put("data",pageInfo);
         ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
         return result;
@@ -103,22 +82,7 @@ public class ImageReportDailyServiceImpl implements IImageReportDailyService {
         if(null == code||code.trim().equals("")){
             code = null;
         }
-        List<BytedanceImageCostVO> vos = bytedanceReportMaterialDailyMapper.bytedanceImageCost(startDate,endDate,accountList,code);
-        List<BytedanceImageCostVOEntity>details = new ArrayList<>();
-        if(null!=vos&&!vos.isEmpty()){
-            for(BytedanceImageCostVO vo:vos){
-                BytedanceImageCostVOEntity entity = new BytedanceImageCostVOEntity(vo);
-                MaterialImageInfo imageInfo = imageInfoService.getByCode(vo.getSignature());
-                if(null!=imageInfo){
-                    entity.setUserId(imageInfo.getUserId());
-                    SysUser user = sysUserService.getById(imageInfo.getUserId());
-                    entity.setUserName(user.getUsername());
-                }else{
-                    entity.setUserName("-");
-                }
-                details.add(entity);
-            }
-        }
+        List<BytedanceImageCostVOEntity>details = bytedanceReportMaterialDailyMapper.bytedanceImageCostEntity(startDate,endDate,accountList,code.trim());
         sheetInfoVo.setDetails(details);
         return sheetInfoVo;
     }
@@ -151,23 +115,8 @@ public class ImageReportDailyServiceImpl implements IImageReportDailyService {
             pageSize = 10;
         }
         PageHelper.startPage(pageNumber,pageSize);
-        List<KuaishouImageCostVO> vos = kuaishouReportDailyImageMapper.imageCost(startDate,endDate,accountList,code);
+        List<KuaishouImageCostVO> vos = kuaishouReportDailyImageMapper.imageCost(startDate,endDate,accountList,code.trim());
         PageInfo<KuaishouImageCostVO> pageInfo = new PageInfo<>(vos);
-        if(null!=vos&&!vos.isEmpty()){
-            List<KuaishouImageCostVO>setVos = new ArrayList<>();
-            for(KuaishouImageCostVO vo:vos){
-                MaterialImageInfo imageInfo = imageInfoService.getByCode(vo.getSignature());
-                if(null!=imageInfo){
-                    vo.setUserId(imageInfo.getUserId());
-                    SysUser user = sysUserService.getById(imageInfo.getUserId());
-                    vo.setUserName(user.getUsername());
-                }else{
-                    vo.setUserName("-");
-                }
-                setVos.add(vo);
-            }
-            pageInfo.setList(setVos);
-        }
         result.put("data",pageInfo);
         ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
         return result;
@@ -193,22 +142,7 @@ public class ImageReportDailyServiceImpl implements IImageReportDailyService {
             code = null;
         }
         sheetInfoVo.setSheetName("快手图片消耗统计");
-        List<KuaishouImageCostVO> vos = kuaishouReportDailyImageMapper.imageCost(startDate,endDate,accountList,code);
-        List<KuaishouImageCostVOEntity> details = new ArrayList<>();
-        if(null!=vos&&!vos.isEmpty()){
-            for (KuaishouImageCostVO vo:vos) {
-                KuaishouImageCostVOEntity entity = new KuaishouImageCostVOEntity(vo);
-                MaterialImageInfo imageInfo = imageInfoService.getByCode(vo.getSignature());
-                if(null!=imageInfo){
-                    entity.setUserId(imageInfo.getUserId());
-                    SysUser user = sysUserService.getById(imageInfo.getUserId());
-                    entity.setUserName(user.getUsername());
-                }else{
-                    entity.setUserName("-");
-                }
-                details.add(entity);
-            }
-        }
+        List<KuaishouImageCostVOEntity> details = kuaishouReportDailyImageMapper.imageCostEntity(startDate,endDate,accountList,code.trim());
         sheetInfoVo.setDetails(details);
         return sheetInfoVo;
     }

+ 1 - 0
jeecg-boot-module-system/src/main/resources/application.yml

@@ -1,5 +1,6 @@
 spring:
   profiles:
+#    active: wps
     active: @activatedProperties@
 
 swagger:

+ 0 - 1
module-common/src/main/java/cn/com/ctop/common/module/vo/KuaishouImageCostVO.java

@@ -19,6 +19,5 @@ public class KuaishouImageCostVO implements Serializable {
     Long formCount;
     Long eventJinJianApp;
     Long eventCreditGrantApp;
-    String userId;
     String userName;
 }

+ 0 - 15
module-common/src/main/java/cn/com/ctop/common/module/vo/KuaishouImageCostVOEntity.java

@@ -35,21 +35,6 @@ public class KuaishouImageCostVOEntity extends BaseRowModel {
     @ExcelProperty(index = 14, value = "所属平面")
     String userName;
 
-    public KuaishouImageCostVOEntity(KuaishouImageCostVO vo) {
-        this.imageUrl = vo.getImageUrl();
-        this.signature = vo.getSignature();
-        this.projectName = vo.getProjectName();
-        this.charge = vo.getCharge();
-        this.photoClick = vo.getPhotoClick();
-        this.photoShow = vo.getPhotoShow();
-        this.activation = vo.getActivation();
-        this.eventRegister = vo.getEventRegister();
-        this.eventPay = vo.getEventPay();
-        this.formCount = vo.getFormCount();
-        this.eventJinJianApp = vo.getEventJinJianApp();
-        this.eventCreditGrantApp = vo.getEventCreditGrantApp();
-    }
-
     public KuaishouImageCostVOEntity() {
     }
 

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 3 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/douyin/service/impl/DouyinMusicServiceImpl.java


+ 4 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouDailyReportTaskServiceImpl.java

@@ -159,6 +159,10 @@ public class KuaiShouDailyReportTaskServiceImpl extends ServiceImpl<KuaiShouDail
                 }else if(task.getViewType() == 7){
                     //封面报表
                     kuaishouReportDailyImageMapper.loadImageDailyReport(task.getAccountId(),localPath);
+                    //清洗数据
+                    kuaishouReportDailyImageMapper.updateImageReportCode();
+                    kuaishouReportDailyImageMapper.updateImageReportUserId();
+                    kuaishouReportDailyImageMapper.updateImageReportRealname();
                 }
             }
 

+ 4 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouHistoryReportTaskServiceImpl.java

@@ -251,6 +251,10 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
                 }else if (task.getViewType() == 7){
                     //封面报表
                     kuaishouReportDailyImageMapper.loadImageDailyReport(task.getAccountId(),localPath);
+                    //清洗数据
+                    kuaishouReportDailyImageMapper.updateImageReportCode();
+                    kuaishouReportDailyImageMapper.updateImageReportUserId();
+                    kuaishouReportDailyImageMapper.updateImageReportRealname();
                 }
 
 

+ 7 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyImageMapper.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
 import cn.com.ctop.common.module.vo.KuaishouImageCostVO;
+import cn.com.ctop.common.module.vo.KuaishouImageCostVOEntity;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyImage;
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -20,4 +21,10 @@ public interface KuaishouReportDailyImageMapper extends BaseMapper<KuaishouRepor
     List<KuaishouImageCostVO> imageCost(String startDate, String endDate, JSONArray accountList, String code);
 
     void updateImageReportCode();
+
+    List<KuaishouImageCostVOEntity> imageCostEntity(String startDate, String endDate, JSONArray accountList, String code);
+
+    void updateImageReportUserId();
+
+    void updateImageReportRealname();
 }

+ 51 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyImageMapper.xml

@@ -117,7 +117,8 @@
         sum(report.event_pay) AS 'event_pay',
         sum(report.form_count) AS 'form_count',
         sum(report.event_jin_jian_app) AS 'event_jin_jian_app',
-        sum(report.event_credit_grant_app) AS 'event_credit_grant_app'
+        sum(report.event_credit_grant_app) AS 'event_credit_grant_app',
+        report.realname as 'user_name'
         from ctop_kuaishou_report_daily_image report
         left join ctop_user_allocation allocation on allocation.account_id = report.account_id
         left join ctop_project p on p.id = allocation.project_id
@@ -143,9 +144,57 @@
         group by report.code
         order by sum(report.charge) desc
     </select>
+    <select id="imageCostEntity" resultType="cn.com.ctop.common.module.vo.KuaishouImageCostVOEntity">
+        select
+        report.cover_url as 'image_url' ,
+        report.code as 'signature',
+        group_concat(distinct p.project_name) AS 'project_name',
+        sum(report.charge) AS 'charge',
+        sum(report.photo_click) AS 'photo_click',
+        sum(report.photo_show) AS 'photo_show',
+        sum(report.activation) AS 'activation',
+        sum(report.event_register) AS 'event_register',
+        sum(report.event_pay) AS 'event_pay',
+        sum(report.form_count) AS 'form_count',
+        sum(report.event_jin_jian_app) AS 'event_jin_jian_app',
+        sum(report.event_credit_grant_app) AS 'event_credit_grant_app',
+        report.realname as 'user_name'
+        from ctop_kuaishou_report_daily_image report
+        left join ctop_user_allocation allocation on allocation.account_id = report.account_id
+        left join ctop_project p on p.id = allocation.project_id
+        where
+        1=1
+        and
+        report.code is not null
+        <if test="startDate!=null">
+            and report.stat_date &gt;= #{startDate}
+        </if>
+        <if test="endDate!=null">
+            and report.stat_date &lt;= #{endDate}
+        </if>
+        <if test="accountList!=null">
+            and report.account_id in
+            <foreach item="accountId" collection="accountList" open="(" separator="," close=")">
+                #{accountId}
+            </foreach>
+        </if>
+        <if test="code!=null">
+            and report.code = #{code}
+        </if>
+        group by report.code
+        order by sum(report.charge) desc
+    </select>
 
     <update id="updateImageReportCode">
         update ctop_kuaishou_report_daily_image a inner join  ctop_kuaishou_image_get  image on image.image_token =a.image_token  set a.code = image.signature
-        where a.code is not null;
+        where a.code is null
+    </update>
+    <update id="updateImageReportUserId">
+        update ctop_kuaishou_report_daily_image a inner join  ctop_material_image_info  image on image.code =a.code  set a.user_id = image.user_id
+        where a.code is not null and a.user_id is null
+    </update>
+    <update id="updateImageReportRealname">
+        update ctop_kuaishou_report_daily_image a inner join  sys_user  user on user.id =a.user_id  set a.realname = user.realname
+        where a.user_id is not null and a.realname is null
     </update>
 </mapper>

+ 11 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceReportMaterialDailyMapper.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.toutiao.modules.report.mapper;
 
 import cn.com.ctop.common.module.vo.BytedanceImageCostVO;
+import cn.com.ctop.common.module.vo.BytedanceImageCostVOEntity;
 import cn.com.ctop.toutiao.modules.material.vo.BytedanceVideoVo;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialDaily;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialRetry;
@@ -37,4 +38,14 @@ public interface BytedanceReportMaterialDailyMapper extends BaseMapper<Bytedance
                                                   @Param("code")String code);
 
     void replaceImageBatch(@Param("infos")List<BytedanceReportMaterialDaily> bytedanceReportImageDailyList);
+    void updateImageReportCode();
+    void updateImageReportProjectId();
+    void updateImageReportProjectName();
+    void updateImageReportPlaneId();
+    void updateImageReportPlaneName();
+
+    List<BytedanceImageCostVOEntity> bytedanceImageCostEntity(@Param("startDate")String startDate,
+                                                              @Param("endDate")String endDate,
+                                                              @Param("accountList")JSONArray accountList,
+                                                              @Param("code")String code);
 }

+ 72 - 7
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceReportMaterialDailyMapper.xml

@@ -241,16 +241,19 @@
     <select id="bytedanceImageCost" resultType="cn.com.ctop.common.module.vo.BytedanceImageCostVO">
         select round(sum(report.cost),2)                              as 'cost',
         sum(report.click)                                             as 'click',
-        sum(report.show_material)                                     as 'showNum',
+        sum(report.show_material)                                     as 'show_num',
         sum(report.convert_material)                                  as 'convert',
-        imageInfo.image_url                                           as 'imageUrl',
-        imageInfo.signature                                           as 'signature',
-        group_concat(distinct report.project_name)                    as 'projectName',
-        report.stat_datetime                                          as 'statDate'
+        report.image_url                                           as 'image_url',
+        report.code                                           as 'signature',
+        group_concat(distinct report.project_name)                    as 'project_name',
+        report.stat_datetime                                          as 'stat_date',
+        report.plane_id as 'user_id',
+        report.plane_name as 'user_name'
             from ctop_bytedance_report_image_daily report
             left join ctop_bytedance_image_info imageInfo on imageInfo.material_id = report.material_id
         where
         1=1
+        and report.code is not null
         <if test="startDate!=null">
             and report.stat_datetime &gt;= #{startDate}
         </if>
@@ -264,11 +267,40 @@
             </foreach>
         </if>
         <if test="code!=null">
-            and imageInfo.signature = #{code}
+            and report.code = #{code}
         </if>
-        group by imageInfo.signature
+        group by report.code
         order by sum(report.cost) desc
     </select>
+
+    <update id="updateImageReportCode">
+        update ctop_bytedance_report_image_daily a inner join ctop_bytedance_image_info image on image.material_id =a.material_id  set a.code = image.signature,a.image_url = image.image_url
+        where a.material_id is not null and a.code is null
+    </update>
+
+    <update id="updateImageReportProjectId">
+        update ctop_bytedance_report_image_daily a inner join ctop_user_allocation allocation on allocation.account_id =a.account_id  set a.project_id = allocation.project_id
+        where a.account_id is not null and a.project_id is null
+    </update>
+
+    <update id="updateImageReportProjectName">
+        update ctop_bytedance_report_image_daily a inner join ctop_project p on p.id =a.project_id  set a.project_name = p.project_name
+        where a.project_id is not null and a.project_name is null
+    </update>
+
+    <update id="updateImageReportPlaneId">
+        update ctop_bytedance_report_image_daily a inner join ctop_material_image_info image on image.code =a.code  set a.plane_id = image.user_id
+where a.code is not null and a.plane_id is null
+    </update>
+
+    <update id="updateImageReportPlaneName">
+        update ctop_bytedance_report_image_daily a inner join sys_user u on u.id =a.plane_id  set a.plane_name = u.realname
+where a.plane_id is not null and a.plane_name is null
+    </update>
+
+
+
+
     <select id="getVideoVoByDate" resultType="cn.com.ctop.toutiao.modules.material.vo.BytedanceVideoVo">
         select
             distinct video.signature as 'code',video.video_url as 'url',report.stat_datetime as 'initial_cost_date'
@@ -295,6 +327,39 @@
         and start_date = #{retry.startDate}
         and end_date = #{retry.endDate}
     </update>
+    <select id="bytedanceImageCostEntity" resultType="cn.com.ctop.common.module.vo.BytedanceImageCostVOEntity">
+        select round(sum(report.cost),2)                              as 'cost',
+        sum(report.click)                                             as 'click',
+        sum(report.show_material)                                     as 'show_num',
+        sum(report.convert_material)                                  as 'convert',
+        report.image_url                                           as 'image_url',
+        report.code                                           as 'signature',
+        group_concat(distinct report.project_name)                    as 'project_name',
+        report.stat_datetime                                          as 'stat_date',
+        report.plane_id as 'user_id',
+        report.plane_name as 'user_name'
+        from ctop_bytedance_report_image_daily report
+        where
+        1=1
+        and report.code is not null
+        <if test="startDate!=null">
+            and report.stat_datetime &gt;= #{startDate}
+        </if>
+        <if test="endDate!=null">
+            and report.stat_datetime &lt;= #{endDate}
+        </if>
+        <if test="accountList!=null">
+            and report.account_id in
+            <foreach item="accountId" collection="accountList" open="(" separator="," close=")">
+                #{accountId}
+            </foreach>
+        </if>
+        <if test="code!=null">
+            and report.code = #{code}
+        </if>
+        group by report.code
+        order by sum(report.cost) desc
+    </select>
 
     <insert id="replaceIntoVideoMaterialBatch">
         REPLACE INTO ctop_bytedance_report_video_material_daily

+ 5 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceReportServiceImpl.java

@@ -740,7 +740,6 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
         log.info("头条素材报表重试结束 当前accountId:{}  {}~{},type:{},code:{}" , accountId, startDate,endDate,type,code);
         return code;
     }
-
     @Override
     public int bytedanceMaterialReport(CtopOauthToken token, String startDate, String endDate) {
         Long accountId = token.getAccountId();
@@ -758,6 +757,11 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
             retry.setType(1);
             bytedanceReportMaterialDailyMapper.replaceMaterialRetry(retry);
         }
+        bytedanceReportMaterialDailyMapper.updateImageReportCode();
+        bytedanceReportMaterialDailyMapper.updateImageReportProjectId();
+        bytedanceReportMaterialDailyMapper.updateImageReportProjectName();
+        bytedanceReportMaterialDailyMapper.updateImageReportPlaneId();
+        bytedanceReportMaterialDailyMapper.updateImageReportPlaneName();
         log.info("头条素材报表结束 当前accountId为:{}  {}~{}" , accountId, startDate,endDate);
         return code;
     }