Browse Source

盯盘运营经理-项目维度列表-头条

yangzian 3 years ago
parent
commit
43ba19f442

+ 2 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/MaterialStareMapper.java

@@ -89,6 +89,8 @@ public interface MaterialStareMapper {
     List<KuaiShouOperateProjectVo> getBytedanceOperateProjectInfo(@Param("startDate")Long startDate, @Param("endDate")Long endDate, @Param("projectId")String projectId,@Param("list")Set<String> operatorUserIds);
     //快手-查询消费 时报
     List<KuaiShouOperateProjectVo> getKuaiShouOperateProjectInfoHour(@Param("startDate")Long startDate, @Param("endDate")Long endDate,@Param("hour")int hour, @Param("projectId")String projectId,@Param("list")Set<String> operatorUserIds);
+    //头条-查询消费 时报
+    List<KuaiShouOperateProjectVo> getBytedanceOperateProjectInfoHour(@Param("startDate")Long startDate, @Param("endDate")Long endDate,@Param("hour")int hour, @Param("projectId")String projectId,@Param("list")Set<String> operatorUserIds);
 
     //快手 -查询 账户 数据信息
     List<KuaiShouOperateAccountVo> getKuaiShouOperateAccountInfo(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("projectId") String projectId, @Param("accountId") Long accountId, @Param("list") Set<String> operatorUserIds);

+ 34 - 2
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/MaterialStareMapper.xml

@@ -698,13 +698,45 @@
                 #{item}
             </foreach>
         </if>
-
-
         GROUP BY
         d.project_id
         ORDER BY
         SUM( d.charge ) DESC
+    </select>
 
+    <!-- 头条 -查询项目数据信息 时报-->
+    <select id="getBytedanceOperateProjectInfoHour" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouOperateProjectVo">
+        SELECT
+        SUM( d.cost ) AS totalCost
+        FROM
+        application.bytedance_advertiser_report_hourly_dw d
+        LEFT JOIN `jeecg-boot`.ctop_user_allocation u ON d.account_id = u.account_id
+        WHERE
+        d.cost > 0
+        AND u.account_status = 0
+        <if test="startDate != null and startDate != '' ">
+            and d.stat_datetime &gt;= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != '' ">
+            and d.stat_datetime &lt;= #{endDate}
+        </if>
+        <if test="endDate != null and endDate != '' ">
+            AND d.`hour` &lt;= #{hour}
+        </if>
+        <if test="projectId != null and projectId != '' ">
+            and d.project_id = #{projectId}
+        </if>
+        <if test='list!=null'>
+            AND d.user_id IN
+            <foreach collection="list" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY
+        d.project_id
+        ORDER BY
+        SUM( d.cost ) DESC
     </select>
 
 

+ 43 - 16
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/MaterialStareServiceImpl.java

@@ -614,21 +614,60 @@ public class MaterialStareServiceImpl implements MaterialStareService {
 
             //头条
             if (mediaType.equals("1")){
-
                 PageHelper.startPage(pageNum,pageSize);
                 //查询运营数据-项目维度
                 listOperate = materialStareMapper.getBytedanceOperateProjectInfo(startDate,entDate,null,operatorUserIds);
                 for (KuaiShouOperateProjectVo projectInfo : listOperate) {
+                    String projectId = projectInfo.getProjectId();
+                    //环比 = (当前 - 上阶段 ) / 上阶段
+                    String yearOnYear = "0";
+                    //当天
+                    int newUnitNumNow = 0;
+                    int trustUnitNum = 0;
+                    if (startDate == now || entDate == now){
+
+                        //查询当天数据
+
+
+                        //时报 消费
+                        //环比 = (当前 - 上阶段 ) / 上阶段
+                        int hour = DateUtils.getNowHour();
+                        List<KuaiShouOperateProjectVo> projectYearOnYearInfoNow = materialStareMapper.getBytedanceOperateProjectInfoHour(startDate,entDate,hour,projectId,operatorUserIds);
+                        List<KuaiShouOperateProjectVo> projectYearOnYearInfoLast = materialStareMapper.getBytedanceOperateProjectInfoHour(lastTimeStart,lastTimeEnd,hour,projectId,operatorUserIds);
+                        if (!Check.isNull(projectYearOnYearInfoNow) && !Check.isNull(projectYearOnYearInfoLast)){
+                            Double yearOnYearD = (projectYearOnYearInfoNow.get(0).getTotalCost() - projectYearOnYearInfoLast.get(0).getTotalCost()) / projectYearOnYearInfoNow.get(0).getTotalCost();
+                            yearOnYear = decimalFormat.format(yearOnYearD);
+                        }
+                        projectInfo.setYearOnYear(yearOnYear);
+                    }else {
+                        //环比 日报
+                        List<KuaiShouOperateProjectVo> projectYearOnYearInfo = materialStareMapper.getBytedanceOperateProjectInfo(lastTimeStart,lastTimeEnd,projectId,operatorUserIds);
+                        if (!Check.isNull(projectYearOnYearInfo)){
+                            Double yearOnYearD = (projectInfo.getTotalCost() - projectYearOnYearInfo.get(0).getTotalCost()) / projectYearOnYearInfo.get(0).getTotalCost();
+                            yearOnYear = decimalFormat.format(yearOnYearD);
+                        }
+                        projectInfo.setYearOnYear(yearOnYear);
+                    }
 
                     //查询 有效 上新视频 爆款视频
-                    JSONObject newEffect = materialStareMapper.getBytedanceAccountBaseByUserId(null,projectInfo.getProjectId(),null,startDate,entDate);
+                   /* JSONObject newEffect = materialStareMapper.getKuaiShouAccountBaseByUserId(null,projectInfo.getProjectId(),null,startDate,entDate);
+                    projectInfo.setNewEffectNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newEffectNum"));//有效
+                    projectInfo.setNewVideoNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newVideoNum"));//上新
+                    projectInfo.setNewHotNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newHotNum"));//爆款
+                    projectInfo.setNewUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum")+newUnitNumNow);//基建数
+                    projectInfo.setTrustUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("trustUnitNum")+trustUnitNum);//智能托管
+*/
+                    //查询 有效 上新计划 上新组
+                    JSONObject newEffect = materialStareMapper.getBytedanceAccountBaseByUserId(null,projectInfo.getProjectId(),null,now,now);
                     projectInfo.setNewEffectNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newEffectNum"));//有效
                     projectInfo.setNewVideoNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newVideoNum"));//上新
                     projectInfo.setNewHotNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newHotNum"));//爆款
                     projectInfo.setNewUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum"));//基建数
                     projectInfo.setTrustUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("trustUnitNum"));//智能托管
 
+
                     /*
+
                     //查看 上传到助手、媒体的素材数量 分版位花费
                     List<JSONObject> materailUpload = materialStareMapper.getKuaiShouMaterailUploadType(projectInfo.getProjectId(),startDate,entDate);
                     projectInfo.setAdspNum(Check.isNull(materailUpload) ? 0L : JSONObject.parseObject(materailUpload.get(0)+"").getLong("num"));//上传到助手
@@ -636,20 +675,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                     //分版位
                     List<JSONObject> adSceneDate = materialStareMapper.getKuaiShouAdSceneData(projectInfo.getProjectId(),startDate,entDate);
                     projectInfo.setAdSceneDate(adSceneDate);
-
-                    */
-
-                    String projectId = projectInfo.getProjectId();
-                    //环比 = (当前 - 上阶段 ) / 上阶段
-                    String yearOnYear = "0";
-                    //环比 日报
-                    List<KuaiShouOperateProjectVo> projectYearOnYearInfo = materialStareMapper.getBytedanceOperateProjectInfo(lastTimeStart,lastTimeEnd,projectId,operatorUserIds);
-                    if (!Check.isNull(projectYearOnYearInfo)){
-                        Double yearOnYearD = (projectInfo.getTotalCost() - projectYearOnYearInfo.get(0).getTotalCost()) / projectYearOnYearInfo.get(0).getTotalCost();
-                        yearOnYear = decimalFormat.format(yearOnYearD);
-                    }
-                    projectInfo.setYearOnYear(yearOnYear);
-
+*/
 
                     //同比 日期超过 7 天 则不显示
                     String equallyRate = "-";
@@ -664,6 +690,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                 }
 
 
+
             }
             //快手
             if (mediaType.equals("2")){