ソースを参照

MOD:添加前三小时字段

cxyu 3 年 前
コミット
f20d1d6fb7

+ 3 - 3
flink-ad-monitoring/src/main/java/flink/zanxiangnet/ad/monitoring/dao/mapper/CostHourDMMapper.xml

@@ -8,7 +8,7 @@
         adgroup_id, adcreative_id, account_id, campaign_id,
         cost_total, cost_day, cost_hour, cost_diff,
         cost_last_hour, cost_last_hour_diff, cost_last_two_hour, cost_last_two_hour_diff,
-        cost_last_three_trend, cost_speed, view_count_total, view_count_day,
+        cost_last_three_hour,cost_last_three_trend, cost_speed, view_count_total, view_count_day,
         view_count_hour, thousand_display_price_all, thousand_display_price_day, thousand_display_price_hour,
         valid_click_count_total, valid_click_count_day, valid_click_count_hour, ctr_all,
         ctr_day, ctr_hour, cpc_all, cpc_day,
@@ -35,7 +35,7 @@
         #{item.adgroupId}, #{item.accountId}, #{item.adcreativeId}, #{item.campaignId},
         #{item.costTotal}, #{item.costDay}, #{item.costHour}, #{item.costDiff},
         #{item.costLastHour}, #{item.costLastHourDiff}, #{item.costLastTwoHour}, #{item.costLastTwoHourDiff},
-        #{item.costLastThreeTrend}, #{item.costSpeed}, #{item.viewCountTotal}, #{item.viewCountDay},
+        #{item.costLastThreeHour},#{item.costLastThreeTrend}, #{item.costSpeed}, #{item.viewCountTotal}, #{item.viewCountDay},
         #{item.viewCountHour}, #{item.thousandDisplayPriceAll}, #{item.thousandDisplayPriceDay}, #{item.thousandDisplayPriceHour},
         #{item.validClickCountTotal}, #{item.validClickCountDay}, #{item.validClickCountHour}, #{item.ctrAll},
         #{item.ctrDay}, #{item.ctrHour}, #{item.cpcAll}, #{item.cpcDay},
@@ -64,7 +64,7 @@
             #{item.adgroupId}, #{item.accountId}, #{item.adcreativeId}, #{item.campaignId},
             #{item.costTotal}, #{item.costDay}, #{item.costHour}, #{item.costDiff},
             #{item.costLastHour}, #{item.costLastHourDiff}, #{item.costLastTwoHour}, #{item.costLastTwoHourDiff},
-            #{item.costLastThreeTrend}, #{item.costSpeed}, #{item.viewCountTotal}, #{item.viewCountDay},
+            #{item.costLastThreeHour},#{item.costLastThreeTrend}, #{item.costSpeed}, #{item.viewCountTotal}, #{item.viewCountDay},
             #{item.viewCountHour}, #{item.thousandDisplayPriceAll}, #{item.thousandDisplayPriceDay}, #{item.thousandDisplayPriceHour},
             #{item.validClickCountTotal}, #{item.validClickCountDay}, #{item.validClickCountHour}, #{item.ctrAll},
             #{item.ctrDay}, #{item.ctrHour}, #{item.cpcAll}, #{item.cpcDay},

+ 2 - 0
flink-ad-monitoring/src/main/java/flink/zanxiangnet/ad/monitoring/pojo/entity/CostHourDM.java

@@ -36,6 +36,8 @@ public class CostHourDM {
     private long costLastTwoHour;
     //前二小时与前三小时消耗差额
     private long costLastTwoHourDiff;
+    //前三小时消耗金额
+    private long costLastThreeHour;
     //前三小时消耗趋势
     private long costLastThreeTrend;
     //消耗速度

+ 4 - 1
flink-ad-monitoring/src/main/java/flink/zanxiangnet/ad/monitoring/process/CostHourProcess.java

@@ -68,12 +68,13 @@ public class CostHourProcess extends KeyedProcessFunction<Long, AdStatOfHourDWD,
                 costLastHourDiff = costLastHour - lastTwoHourDWD.getCostHour();
             }
         }
-        long costLastTwoHourDiff = 0, costLastThreeTrend = 0;
+        long costLastTwoHourDiff = 0, costLastThreeTrend = 0, costLastThreeHour = 0;
         Map<Integer, AdStatOfHourDWD> lastThreeHourMapping = historyReduceState.get(DateUtil.formatLocalDate(lastThreeHourDay));
         if (lastThreeHourMapping != null && !lastThreeHourMapping.isEmpty()) {
             AdStatOfHourDWD lastThreeHourDWD = lastThreeHourMapping.get(lastThreeHour);
             if (lastThreeHourDWD != null) {
                 costLastThreeTrend = costLastHourDiff > 0 && costDiff > 0 ? 1 : 0;
+                costLastThreeHour = lastThreeHourDWD.getCostHour();
                 costLastTwoHourDiff = costLastTwoHour - lastThreeHourDWD.getCostHour();
             }
         }
@@ -93,6 +94,8 @@ public class CostHourProcess extends KeyedProcessFunction<Long, AdStatOfHourDWD,
         costHourDM.setCostLastTwoHour(costLastTwoHour);
         costHourDM.setCostLastTwoHourDiff(costLastTwoHourDiff);
         costHourDM.setCostLastThreeTrend(costLastThreeTrend);
+        costHourDM.setCostLastThreeHour(costLastThreeHour);
+
 
         collector.collect(costHourDM);
         historyReduceState.remove(DateUtil.formatLocalDate(day.minusDays(2L)));