Browse Source

添加字段

wudianlong 2 năm trước cách đây
mục cha
commit
4f4ff6416e
2 tập tin đã thay đổi với 12 bổ sung3 xóa
  1. 1 0
      energy/dayTask/energy_hive.sql
  2. 11 3
      energy/dayTask/ods_to_dwd.sh

+ 1 - 0
energy/dayTask/energy_hive.sql

@@ -72,6 +72,7 @@ create table saga_dw.dwd_energy_15_min_hour
     func_id          string,
     branch_type      string,
     branch_type_name string,
+    use_range_type string,
     value_sum        decimal(30, 15),
     current_hour     string comment '小时',
     current_year     integer comment '年份',

+ 11 - 3
energy/dayTask/ods_to_dwd.sh

@@ -22,24 +22,30 @@ select building,
        func_id,
        branch_type,
        branch_type_name,
+       use_range_type,
        cast(value_sum as decimal(30, 15)) as value_sum ,
        hour_ as current_hour,
        current_year,
        year_mouth,
-       week_of_year
+       week_of_year,
+       dt
 from (
     select building,
            func_id,
+           parent_code,
            branch_type,
            branch_type_name,
+           use_range_type,
            dt,
            t1.hour_,
            (ap_sum - al_sum) value_sum
     from (
       select building,
              func_id,
+             'AP1' parent_code,
              'ALU' as branch_type,
              '其他' as branch_type_name,
+             'OTHER' use_range_type,
              sum(if((branch_type == 'AP' and use_range_type == '1'), data_value, 0)) ap_sum,
              sum(if((branch_type == 'AL' and use_range_type in (2, 3, 4, 6, 7)), data_value, 0)) al_sum,
              dt,
@@ -61,8 +67,10 @@ from (
     union
     select building,
            func_id,
-           concat_ws('-', branch_type, use_range_type),
+           parent_code,
+           branch_type,
            branch_type_name,
+           use_range_type,
            dt,
            o15mh.hour_,
            sum(data_value) value_sum
@@ -78,7 +86,7 @@ from (
         where dt = '$do_date'
          ) o15mh
         left join dim_office_meter dom2 on o15mh.meter = dom2.meter
-    group by building, func_id, branch_type, branch_type_name, use_range_type, dt, o15mh.hour_
+    group by building, func_id, parent_code, branch_type, branch_type_name, use_range_type, dt, o15mh.hour_
      ) teh
     left join dim_date_day ddd on dt = date_id
 order by current_hour;"