|
@@ -40,59 +40,99 @@ case class JudicialCaseRelationPre10(s: SparkSession, project: String
|
|
spark.sparkContext.setJobDescription(s"处理zxr($lastDsIncAds)")
|
|
spark.sparkContext.setJobDescription(s"处理zxr($lastDsIncAds)")
|
|
sql(
|
|
sql(
|
|
s"""
|
|
s"""
|
|
- |insert ${if (isWindows) "INTO" else "OVERWRITE"} table $project.ads_judicial_case_relation_pre partition(ds='$lastDsIncAds',tn='zxr')
|
|
|
|
- |select
|
|
|
|
- | judicase_id
|
|
|
|
- | ,flag
|
|
|
|
- | ,title
|
|
|
|
- | ,case_type
|
|
|
|
- | ,case_reason
|
|
|
|
- | ,case_no
|
|
|
|
- | ,court_name
|
|
|
|
- | ,case_stage
|
|
|
|
- | ,yg_name
|
|
|
|
- | ,bg_name
|
|
|
|
- | ,date
|
|
|
|
- | ,detail_id
|
|
|
|
- | ,case_amt
|
|
|
|
- |from (
|
|
|
|
- | select
|
|
|
|
- | md5(cleanup(case_no)) as judicase_id
|
|
|
|
- | ,"7" as flag
|
|
|
|
- | ,concat_ws('',cname,'被执行人') as title
|
|
|
|
- | ,concat_ws('',case_type(case_no)) as case_type
|
|
|
|
- | ,null as case_reason
|
|
|
|
- | ,case_no
|
|
|
|
- | ,court as court_name
|
|
|
|
- | ,concat_ws('',case_stage(case_no)) as case_stage
|
|
|
|
- | ,null as yg_name
|
|
|
|
- | ,cname as bg_name
|
|
|
|
- | ,case_create_time as date
|
|
|
|
- | ,rowkey as detail_id
|
|
|
|
- | ,exec_money as case_amt
|
|
|
|
- | ,row_number() over(partition by rowkey order by update_time desc) num
|
|
|
|
- | from $project.inc_ads_company_zxr
|
|
|
|
- | where length(case_no) > 0 and ds > '0'
|
|
|
|
- | union all
|
|
|
|
- | select
|
|
|
|
- | md5(cleanup(case_no)) as judicase_id
|
|
|
|
- | ,"7" as flag
|
|
|
|
- | ,concat_ws('',cname,'被执行人') as title
|
|
|
|
- | ,concat_ws('',case_type(case_no)) as case_type
|
|
|
|
- | ,null as case_reason
|
|
|
|
- | ,case_no
|
|
|
|
- | ,court as court_name
|
|
|
|
- | ,concat_ws('',case_stage(case_no)) as case_stage
|
|
|
|
- | ,null as yg_name
|
|
|
|
- | ,cname as bg_name
|
|
|
|
- | ,case_create_time as date
|
|
|
|
- | ,rowkey as detail_id
|
|
|
|
- | ,exec_money as case_amt
|
|
|
|
- | ,row_number() over(partition by rowkey order by update_time desc) num
|
|
|
|
- | from $project.ads_company_zxr
|
|
|
|
- | where length(case_no) > 0 and ds > '0'
|
|
|
|
- | )
|
|
|
|
- |where num = 1
|
|
|
|
|
|
+ |INSERT ${if (isWindows) "INTO" else "OVERWRITE"} TABLE $project.ads_judicial_case_relation_pre PARTITION(ds='$lastDsIncAds',tn='zxr')
|
|
|
|
+ |SELECT
|
|
|
|
+ | judicase_id
|
|
|
|
+ | ,flag
|
|
|
|
+ | ,title
|
|
|
|
+ | ,case_type
|
|
|
|
+ | ,case_reason
|
|
|
|
+ | ,case_no
|
|
|
|
+ | ,court_name
|
|
|
|
+ | ,case_stage
|
|
|
|
+ | ,yg_name
|
|
|
|
+ | ,bg_name
|
|
|
|
+ | ,DATE
|
|
|
|
+ | ,detail_id
|
|
|
|
+ | ,case_amt
|
|
|
|
+ |FROM (
|
|
|
|
+ | SELECT
|
|
|
|
+ | A.*
|
|
|
|
+ | ,COALESCE(C.judicase_id,md5(cleanup(case_no))) AS judicase_id
|
|
|
|
+ | ,row_number() OVER(PARTITION BY detail_id,A.case_no ORDER BY DATE DESC ) num
|
|
|
|
+ | FROM (
|
|
|
|
+ | SELECT
|
|
|
|
+ | "7" AS flag
|
|
|
|
+ | ,concat_ws('',cname,'被执行人') AS title
|
|
|
|
+ | ,concat_ws('',case_type(case_no)) AS case_type
|
|
|
|
+ | ,NULL AS case_reason
|
|
|
|
+ | ,case_no
|
|
|
|
+ | ,court AS court_name
|
|
|
|
+ | ,concat_ws('',case_stage(case_no)) AS case_stage
|
|
|
|
+ | ,NULL AS yg_name
|
|
|
|
+ | ,cname AS bg_name
|
|
|
|
+ | ,case_create_time AS DATE
|
|
|
|
+ | ,rowkey AS detail_id
|
|
|
|
+ | ,exec_money AS case_amt
|
|
|
|
+ | FROM $project.inc_ads_company_zxr
|
|
|
|
+ | WHERE length(case_no) >0 AND ds> '0'
|
|
|
|
+ | UNION ALL
|
|
|
|
+ | SELECT
|
|
|
|
+ | "7" AS flag
|
|
|
|
+ | ,concat_ws('',cname,'被执行人') AS title
|
|
|
|
+ | ,concat_ws('',case_type(case_no)) AS case_type
|
|
|
|
+ | ,NULL AS case_reason
|
|
|
|
+ | ,case_no
|
|
|
|
+ | ,court AS court_name
|
|
|
|
+ | ,concat_ws('',case_stage(case_no)) AS case_stage
|
|
|
|
+ | ,NULL AS yg_name
|
|
|
|
+ | ,cname AS bg_name
|
|
|
|
+ | ,case_create_time AS DATE
|
|
|
|
+ | ,rowkey AS detail_id
|
|
|
|
+ | ,exec_money AS case_amt
|
|
|
|
+ | FROM $project.ads_company_zxr
|
|
|
|
+ | WHERE length(case_no) >0 AND ds> '0'
|
|
|
|
+ | UNION ALL
|
|
|
|
+ | SELECT
|
|
|
|
+ | "7" AS flag
|
|
|
|
+ | ,concat_ws('',cname,'被执行人') AS title
|
|
|
|
+ | ,concat_ws('',case_type(case_no)) AS case_type
|
|
|
|
+ | ,NULL AS case_reason
|
|
|
|
+ | ,gist_id as case_no
|
|
|
|
+ | ,court AS court_name
|
|
|
|
+ | ,concat_ws('',case_stage(case_no)) AS case_stage
|
|
|
|
+ | ,NULL AS yg_name
|
|
|
|
+ | ,cname AS bg_name
|
|
|
|
+ | ,case_create_time AS DATE
|
|
|
|
+ | ,rowkey AS detail_id
|
|
|
|
+ | ,exec_money AS case_amt
|
|
|
|
+ | FROM $project.inc_ads_company_zxr
|
|
|
|
+ | WHERE length(gist_id) >0 AND ds> '0'
|
|
|
|
+ | UNION ALL
|
|
|
|
+ | SELECT
|
|
|
|
+ | "7" AS flag
|
|
|
|
+ | ,concat_ws('',cname,'被执行人') AS title
|
|
|
|
+ | ,concat_ws('',case_type(case_no)) AS case_type
|
|
|
|
+ | ,NULL AS case_reason
|
|
|
|
+ | ,gist_id as case_no
|
|
|
|
+ | ,court AS court_name
|
|
|
|
+ | ,concat_ws('',case_stage(case_no)) AS case_stage
|
|
|
|
+ | ,NULL AS yg_name
|
|
|
|
+ | ,cname AS bg_name
|
|
|
|
+ | ,case_create_time AS DATE
|
|
|
|
+ | ,rowkey AS detail_id
|
|
|
|
+ | ,exec_money AS case_amt
|
|
|
|
+ | FROM $project.ads_company_zxr
|
|
|
|
+ | WHERE length(gist_id) >0 AND ds> '0'
|
|
|
|
+ | ) A
|
|
|
|
+ | LEFT JOIN (
|
|
|
|
+ | SELECT *
|
|
|
|
+ | FROM $project.ads_judicial_case_relation_graph
|
|
|
|
+ | WHERE flag = 'company_zxr'
|
|
|
|
+ | ) C
|
|
|
|
+ | ON A.detail_id = C.id
|
|
|
|
+ | )
|
|
|
|
+ |WHERE num =1
|
|
|""".stripMargin).show(10, false)
|
|
|""".stripMargin).show(10, false)
|
|
|
|
|
|
|
|
|
|
@@ -122,7 +162,7 @@ case class JudicialCaseRelationPre10(s: SparkSession, project: String
|
|
| ,case_amt
|
|
| ,case_amt
|
|
|from (
|
|
|from (
|
|
| select
|
|
| select
|
|
- | md5(cleanup(A.case_no)) as judicase_id
|
|
|
|
|
|
+ | COALESCE(C.judicase_id,md5(cleanup(A.case_no))) as judicase_id
|
|
| ,"10" as flag
|
|
| ,"10" as flag
|
|
| ,concat_ws('',A.cname,'被执行人') AS title
|
|
| ,concat_ws('',A.cname,'被执行人') AS title
|
|
| ,concat_ws('',case_type(A.case_no)) as case_type
|
|
| ,concat_ws('',case_type(A.case_no)) as case_type
|
|
@@ -135,7 +175,7 @@ case class JudicialCaseRelationPre10(s: SparkSession, project: String
|
|
| ,case_create_time as date--目前天眼查数据没有执行日期,先以此代替
|
|
| ,case_create_time as date--目前天眼查数据没有执行日期,先以此代替
|
|
| ,rowkey as detail_id
|
|
| ,rowkey as detail_id
|
|
| ,exec_money as case_amt
|
|
| ,exec_money as case_amt
|
|
- | ,row_number() over(partition by rowkey order by update_time desc) num
|
|
|
|
|
|
+ | ,row_number() over(partition by rowkey,A.case_no order by update_time desc) num
|
|
| from (
|
|
| from (
|
|
| select case_no,court,cname,case_create_time,rowkey,update_time,card,exec_money
|
|
| select case_no,court,cname,case_create_time,rowkey,update_time,card,exec_money
|
|
| from $project.ads_company_zxr_person
|
|
| from $project.ads_company_zxr_person
|
|
@@ -144,6 +184,14 @@ case class JudicialCaseRelationPre10(s: SparkSession, project: String
|
|
| select case_no,court,cname,case_create_time,rowkey,update_time,card,exec_money
|
|
| select case_no,court,cname,case_create_time,rowkey,update_time,card,exec_money
|
|
| from $project.inc_ads_company_zxr_person
|
|
| from $project.inc_ads_company_zxr_person
|
|
| where length(case_no) > 0 and ds>'0'
|
|
| where length(case_no) > 0 and ds>'0'
|
|
|
|
+ | union all
|
|
|
|
+ | select gist_id as case_no,court,cname,case_create_time,rowkey,update_time,card,exec_money
|
|
|
|
+ | from $project.ads_company_zxr_person
|
|
|
|
+ | where length(gist_id) > 0 and ds>'0'
|
|
|
|
+ | union all
|
|
|
|
+ | select gist_id as case_no,court,cname,case_create_time,rowkey,update_time,card,exec_money
|
|
|
|
+ | from $project.inc_ads_company_zxr_person
|
|
|
|
+ | where length(gist_id) > 0 and ds>'0'
|
|
| ) A
|
|
| ) A
|
|
| left join(
|
|
| left join(
|
|
| select name, identity_num, case_no
|
|
| select name, identity_num, case_no
|
|
@@ -151,6 +199,11 @@ case class JudicialCaseRelationPre10(s: SparkSession, project: String
|
|
| where ds=${personIdDs}
|
|
| where ds=${personIdDs}
|
|
| ) B
|
|
| ) B
|
|
| on A.cname=B.name AND A.case_no=B.case_no
|
|
| on A.cname=B.name AND A.case_no=B.case_no
|
|
|
|
+ | left join(
|
|
|
|
+ | SELECT *
|
|
|
|
+ | FROM $project.ads_judicial_case_relation_graph WHERE flag = 'company_zxr_person'
|
|
|
|
+ | ) C
|
|
|
|
+ | on A.rowkey=C.id
|
|
| where is_id_card(A.card) OR is_id_card(B.identity_num)
|
|
| where is_id_card(A.card) OR is_id_card(B.identity_num)
|
|
| )
|
|
| )
|
|
|where num = 1
|
|
|where num = 1
|