Browse Source

统计报表——新上监控,头条添加2.0广告数

zhaoxian 2 years ago
parent
commit
da46e7356a

+ 7 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/NewMonitorMapper.java

@@ -58,4 +58,11 @@ public interface NewMonitorMapper {
     List<JSONObject> getPlanMessageGroup(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("group") String group, @Param("project") String project);
 
     List<NewMonitorInfo> getOperator(@Param("userId") String userId);
+
+    JSONObject getPlanSumBytedance(@Param("userId") String userId, @Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("project") String project);
+
+    List<JSONObject> getPlanMessageGroupBytedance(@Param("userId") String userId,@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("group") String group, @Param("project") String project);
+
+    List<JSONObject> getPlanMessageBytedance(@Param("userId") String userId, @Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("project") String project);
+
 }

+ 126 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/NewMonitorMapper.xml

@@ -228,6 +228,132 @@
         order by t.create_time asc
     </select>
 
+    <select id="getPlanSumBytedance" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT COUNT(IF(t.effective ='1', TRUE, NULL)) as 'valid',COUNT(t.effective) + t2.promotionNum  as 'new'
+        from ctop_new_monitor_campaign t
+        LEFT JOIN (
+        SELECT user_id,
+        IFNULL(SUM(promotion_num),0)  as 'promotionNum'
+        FROM application.app_bytedance_account_base_info_d
+        WHERE stat_date >= DATE_FORMAT(#{startDate},'%Y%m%d')
+        AND stat_date &lt;=DATE_FORMAT(#{endDate},'%Y%m%d')
+        AND user_id = #{userId}
+        ) t2 on 1=1
+        where  (create_time between #{startDate}  and #{endDate}) and project_type=#{project}
+        and t.account_id in
+        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+            #{item}
+        </foreach>
+    </select>
+
 
+    <select id="getPlanMessageGroupBytedance" resultType="com.alibaba.fastjson.JSONObject" >
+        SELECT t1.statDate,
+        t1.promotionNum +IFNULL(t2.new,0) as 'new',
+        IFNULL(t2.valid,0) as 'valid'
+        FROM
+        (
+        SELECT
+        <choose>
+            <when test='group=="1"'>
+                DATE_FORMAT(stat_date,'%Y-%m') as 'statDate',
+            </when>
+            <otherwise>
+                DATE_FORMAT(stat_date,'%Y-%m-%d') as 'statDate',
+            </otherwise>
+        </choose>
+        IFNULL(SUM(promotion_num),0) as 'promotionNum'
+        FROM application.app_bytedance_account_base_info_d
+        WHERE stat_date >= DATE_FORMAT(#{startDate},'%Y%m%d')
+        AND stat_date &lt;=DATE_FORMAT(#{endDate},'%Y%m%d')
+        AND user_id = #{userId}
+        <choose>
+            <when test='group=="1"'>
+                GROUP BY  DATE_FORMAT(stat_date,'%Y-%m')
+            </when>
+            <otherwise>
+                GROUP BY  stat_date
+            </otherwise>
+        </choose>
+        ) t1
+        LEFT JOIN (
+        SELECT
+        <choose>
+            <when test='group=="1"'>
+                DATE_FORMAT(t.create_time,'%Y-%m') as 'statDate',
+            </when>
+            <otherwise>
+                DATE_FORMAT(t.create_time,'%Y-%m-%d') as 'statDate',
+            </otherwise>
+        </choose>
+        COUNT(t.effective) as 'new',COUNT(IF(t.effective ='1', TRUE, NULL))  as 'valid' from ctop_new_monitor_campaign t
+        where project_type=#{project} and  (create_time between #{startDate}  and #{endDate}) and t.account_id in
+        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+            #{item}
+        </foreach>
+        <choose>
+            <when test='group=="1"'>
+                GROUP BY  DATE_FORMAT(t.create_time,'%Y-%m')
+            </when>
+            <otherwise>
+                GROUP BY  DATE_FORMAT(t.create_time,'%Y-%m-%d')
+            </otherwise>
+        </choose>
+        ) t2 ON  t1.statDate = t2.statDate
+        WHERE t1.promotionNum +IFNULL(t2.new,0) >0
+        ORDER BY `statDate`
+    </select>
+
+
+    <select id="getPlanMessageBytedance" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT * FROM (
+        SELECT
+        IFNULL(t2.account_id,t1.account_id) as 'accountId',
+        IFNULL(t2.authName,t1.account_name) as 'authName',
+        IFNULL(t2.maxCreateTime,statDate) as 'maxCreateTime',
+        t1.promotionNum+IFNULL(t2.new,0)  as 'new',
+        IFNULL(t2.userName,t1.user_name) as 'userName',
+        IFNULL(t2.valid ,0) as 'valid'
+        FROM
+        (
+        SELECT
+        account_id,
+        account_name,
+        user_name,
+        DATE_FORMAT(stat_date,'%Y-%m-%d') as 'statDate',
+        IFNULL(SUM(promotion_num),0) as 'promotionNum'
+        FROM application.app_bytedance_account_base_info_d
+        WHERE stat_date >= DATE_FORMAT(#{startDate},'%Y%m%d')
+        AND stat_date &lt;=DATE_FORMAT(#{endDate},'%Y%m%d')
+        AND user_id = #{userId}
+        GROUP BY account_id
+        ) t1
+        LEFT JOIN (
+        SELECT
+        account_id,
+        account_name AS 'authName',
+        MAX( create_time ) AS 'maxCreateTime',
+        COUNT(
+        IF
+        ( effective = '1', TRUE, NULL )) AS 'valid',
+        count( effective ) AS 'new',
+        operating_name AS 'userName',
+        '' AS 'projectName'
+        FROM
+        ctop_new_monitor_campaign
+        WHERE
+        (create_time between #{startDate}  and #{endDate})
+        and project_type=#{project}
+        AND account_id IN
+        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+            #{item}
+        </foreach>
+        GROUP BY
+        account_id
+        ) t2 ON t1.account_id = t2.account_id
+        ) t
+        WHERE new >0
+        ORDER BY maxCreateTime desc
+    </select>
 
 </mapper>

+ 6 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/NewMonitorService.java

@@ -24,4 +24,10 @@ public interface NewMonitorService {
     List<JSONObject> getPlanMessageGroup(JSONArray array, String startDate, String endDate, String project);
 
     List<JSONObject> getOperator(String userId, String userName);
+
+    JSONObject getPlanSumBytedance(String userId, JSONArray accountIds, String startDate, String endDate, String s);
+
+    List<JSONObject> getPlanMessageGroupBytedance(String userId, JSONArray accountIds, String startDate, String endDate, String s);
+
+    List<JSONObject> getPlanMessageBytedance(String userId, JSONArray accountIds, String startDate, String endDate, String target, String s);
 }

+ 25 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/NewMonitorServiceImpl.java

@@ -297,6 +297,31 @@ public class NewMonitorServiceImpl implements NewMonitorService {
         return list;
     }
 
+    @Override
+    public JSONObject getPlanSumBytedance(String userId, JSONArray accountIds, String startDate, String endDate, String project) {
+        return newMonitorMapper.getPlanSumBytedance(userId,accountIds, startDate, endDate, project);
+    }
+
+    @Override
+    public List<JSONObject> getPlanMessageGroupBytedance(String userId, JSONArray array, String startDate, String endDate, String project) {
+        String group = "0";
+        List<JSONObject> planGroupMessageGroup = new ArrayList<>();
+        try {
+            if (DateUtils.isMoreSixMonth(startDate, endDate)) {
+                group = "1";
+            }
+            planGroupMessageGroup = newMonitorMapper.getPlanMessageGroupBytedance(userId,array, startDate, endDate, group, project);
+        } catch (Exception e) {
+            log.info("查询数据错误:{}", e.toString());
+        }
+        return planGroupMessageGroup;
+    }
+
+    @Override
+    public List<JSONObject> getPlanMessageBytedance(String userId, JSONArray array, String startDate, String endDate, String target, String project) {
+        return newMonitorMapper.getPlanMessageBytedance(userId,array, startDate, endDate, project);
+    }
+
     List<JSONObject> getAllNode(List<NewMonitorInfo> operator) {
         List<JSONObject> objects = new ArrayList<>();
         if (!operator.isEmpty()) {

+ 5 - 5
jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceNewPlanReportCtrl.java

@@ -61,7 +61,7 @@ public class BytedanceNewPlanReportCtrl {
         String startDate = requestBody.getString("startDate");
         String endDate = requestBody.getString("endDate");
         startDate=startDate+" 00:00:00";
-        endDate=endDate+" 59:59:59";
+        endDate=endDate+" 23:59:59";
         String target = requestBody.getString("target");
         String order = requestBody.getString("order");
         try {
@@ -69,9 +69,9 @@ public class BytedanceNewPlanReportCtrl {
             List<JSONObject> chartData = newPlanReportService.getBytedanceNewPlanGroupByStatDate(accountIds, startDate, endDate);
             List<JSONObject> listData = newPlanReportService.getBytedanceNewPlanGroupByAccount(accountIds, startDate, endDate, target, order);
 */
-            JSONObject sumData = newMonitorService.getPlanSum(accountIds, startDate, endDate, "0");
-            List<JSONObject> chartData = newMonitorService.getPlanMessageGroup(accountIds, startDate, endDate, "0");
-            List<JSONObject> listData = newMonitorService.getPlanMessage(accountIds, startDate, endDate, target, "0");
+            JSONObject sumData = newMonitorService.getPlanSumBytedance(userId,accountIds, startDate, endDate, "0");
+            List<JSONObject> chartData = newMonitorService.getPlanMessageGroupBytedance(userId,accountIds, startDate, endDate, "0");
+            List<JSONObject> listData = newMonitorService.getPlanMessageBytedance(userId,accountIds, startDate, endDate, target, "0");
             result.put("sumData", sumData);
             result.put("chartData", chartData);
             result.put("listData", listData);
@@ -108,7 +108,7 @@ public class BytedanceNewPlanReportCtrl {
         endDate=endDate+" 59:59:59";
         String target = requestBody.getString("target");
         String order = requestBody.getString("order");
-        List<JSONObject> listData = newMonitorService.getPlanMessage(accountIds, startDate, endDate, target, "0");
+        List<JSONObject> listData = newMonitorService.getPlanMessageBytedance(userId,accountIds, startDate, endDate, target, "0");
 
         List<List<Object>> excelList = new ArrayList<>();
         listData.forEach(data -> {