Kaynağa Gözat

丢失人员补充

xufei 4 yıl önce
ebeveyn
işleme
28404fc490

+ 47 - 7
src/main/scala/com/winhc/bigdata/spark/ng/relation/inc_company_relation_v2.scala

@@ -262,6 +262,32 @@ case class inc_company_relation_v2(s: SparkSession,
          |WHERE   num = 1
          |""".stripMargin).createOrReplaceTempView("company_human_relation_all")
 
+    //新增人员rowkey
+    sql(
+      s"""
+        |SELECT  rowkey
+        |FROM    (
+        |            SELECT  a.rowkey
+        |            FROM    (
+        |                        SELECT  rowkey,company_id,staff_name AS human_name
+        |                        FROM    $inc_ads_company_staff
+        |                        WHERE   ds = '$ds'
+        |                        UNION ALL
+        |                        SELECT  rowkey,company_id,holder_name AS human_name
+        |                        FROM    $inc_ads_company_holder
+        |                        WHERE   ds = '$ds'
+        |                        AND     holder_type = 1
+        |                    ) a
+        |            JOIN    (
+        |                        SELECT  company_id,human_name
+        |                        FROM    $inc_ads_company_human_relation
+        |                        WHERE   ds = '$ds'
+        |                    ) b
+        |            ON      a.company_id = b.company_id AND name_cleanup(a.human_name) = name_cleanup(b.human_name)
+        |        )
+        |GROUP BY rowkey
+        |""".stripMargin).createOrReplaceTempView("incr_human_rowkey")
+
     //股东关系
     sql(
       s"""
@@ -284,10 +310,17 @@ case class inc_company_relation_v2(s: SparkSession,
          |ON a.company_id = c.company_id and name_cleanup(a.holder_name) = name_cleanup(c.human_name)
          |JOIN
          |  (
-         |    SELECT rowkey
-         |    FROM $ads_change_extract
-         |    WHERE   ds = '$ds' AND tn = 'company_holder'
-         |    AND    (change_fields LIKE '%percent%' OR change_fields is null OR change_fields LIKE '%deleted%')
+         |     SELECT rowkey
+         |     FROM (
+         |         SELECT rowkey
+         |         FROM $ads_change_extract
+         |         WHERE   ds = '$ds' AND tn = 'company_holder'
+         |         AND    (change_fields LIKE '%percent%' OR change_fields is null OR change_fields LIKE '%deleted%')
+         |         UNION ALL
+         |         SELECT rowkey
+         |         FROM incr_human_rowkey
+         |        )
+         |     GROUP BY rowkey
          |   ) b
          |ON    a.rowkey = b.rowkey
          |UNION ALL
@@ -334,9 +367,16 @@ case class inc_company_relation_v2(s: SparkSession,
          |JOIN
          |  (
          |    SELECT rowkey
-         |    FROM $ads_change_extract
-         |    WHERE   ds = '$ds' AND tn = 'company_staff'
-         |    AND    (change_fields LIKE '%staff_type%' OR change_fields is null OR change_fields LIKE '%deleted%')
+         |     FROM (
+         |       SELECT rowkey
+         |         FROM $ads_change_extract
+         |         WHERE   ds = '$ds' AND tn = 'company_staff'
+         |       AND    (change_fields LIKE '%staff_type%' OR change_fields is null OR change_fields LIKE '%deleted%')
+         |       UNION ALL
+         |       SELECT rowkey
+         |         FROM incr_human_rowkey
+         |       )
+         |       GROUP BY rowkey
          |   ) b
          |ON    a.rowkey = b.rowkey
          |)