|
@@ -1,5 +1,6 @@
|
|
package com.winhc.bigdata.spark.ng.credit_punishment
|
|
package com.winhc.bigdata.spark.ng.credit_punishment
|
|
|
|
|
|
|
|
+import com.winhc.bigdata.spark.implicits.BaseHelper._
|
|
import com.winhc.bigdata.spark.implicits.CaseClass2JsonHelper._
|
|
import com.winhc.bigdata.spark.implicits.CaseClass2JsonHelper._
|
|
import com.winhc.bigdata.spark.ng.credit_punishment.udf.DeletedMergeUDF
|
|
import com.winhc.bigdata.spark.ng.credit_punishment.udf.DeletedMergeUDF
|
|
import com.winhc.bigdata.spark.udf.BaseFunc
|
|
import com.winhc.bigdata.spark.udf.BaseFunc
|
|
@@ -39,6 +40,18 @@ case class CreditPunishmentEntityAgg(s: SparkSession
|
|
|
|
|
|
spark.udf.register("to_millis_timestamp", toTime _)
|
|
spark.udf.register("to_millis_timestamp", toTime _)
|
|
|
|
|
|
|
|
+
|
|
|
|
+ def get_rowkey_by_prefix(rs: String, prefix: String): String = {
|
|
|
|
+ if (StringUtils.isEmpty(rs)) {
|
|
|
|
+ null
|
|
|
|
+ } else {
|
|
|
|
+ rs.split(",").filter(r => r.split("@@")(0).equals(prefix))
|
|
|
|
+ .map(_.split("@@")(2))
|
|
|
|
+ .toSeq.mkStringOrNull()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ spark.udf.register("get_rowkey_by_prefix", get_rowkey_by_prefix _)
|
|
|
|
+
|
|
def get_gender(card_num: String): Int = {
|
|
def get_gender(card_num: String): Int = {
|
|
if (StringUtils.isEmpty(card_num)) {
|
|
if (StringUtils.isEmpty(card_num)) {
|
|
return -1
|
|
return -1
|
|
@@ -96,6 +109,11 @@ case class CreditPunishmentEntityAgg(s: SparkSession
|
|
| ,company_zxr_restrict_num_1 BIGINT COMMENT '限高条数-历史'
|
|
| ,company_zxr_restrict_num_1 BIGINT COMMENT '限高条数-历史'
|
|
|
|
|
|
|
|
| ,deleted BIGINT COMMENT '0:未删除,1:删除'
|
|
| ,deleted BIGINT COMMENT '0:未删除,1:删除'
|
|
|
|
+ |
|
|
|
|
+ | ,company_dishonest_info_rowkey String COMMENT '对应维度rowkey'
|
|
|
|
+ | ,company_zxr_rowkey String COMMENT '对应维度rowkey'
|
|
|
|
+ | ,company_zxr_final_case_rowkey String COMMENT '对应维度rowkey'
|
|
|
|
+ | ,company_zxr_restrict_rowkey String COMMENT '对应维度rowkey'
|
|
|)
|
|
|)
|
|
|COMMENT '信用惩戒查询-惩戒主体表'
|
|
|COMMENT '信用惩戒查询-惩戒主体表'
|
|
|PARTITIONED BY
|
|
|PARTITIONED BY
|
|
@@ -183,12 +201,40 @@ case class CreditPunishmentEntityAgg(s: SparkSession
|
|
|
|
|
|
sql(
|
|
sql(
|
|
s"""
|
|
s"""
|
|
|
|
+ |select credit_punishment_entity_id
|
|
|
|
+ | ,keyno
|
|
|
|
+ | ,name
|
|
|
|
+ | ,card_num
|
|
|
|
+ | ,label
|
|
|
|
+ | ,record_num
|
|
|
|
+ | ,case_create_time_year
|
|
|
|
+ | ,total_exec_amount
|
|
|
|
+ | ,total_no_exec_amount
|
|
|
|
+ | ,zxr_total_exec_amount
|
|
|
|
+ | ,final_case_exec_amount
|
|
|
|
+ | ,final_case_no_exec_amount
|
|
|
|
+ |
|
|
|
|
+ | ,company_dishonest_info_num_0
|
|
|
|
+ | ,company_zxr_num_0
|
|
|
|
+ | ,company_zxr_final_case_num_0
|
|
|
|
+ | ,company_zxr_restrict_num_0
|
|
|
|
+ |
|
|
|
|
+ | ,company_dishonest_info_num_1
|
|
|
|
+ | ,company_zxr_num_1
|
|
|
|
+ | ,company_zxr_final_case_num_1
|
|
|
|
+ | ,company_zxr_restrict_num_1
|
|
|
|
+ |
|
|
|
|
+ | ,deleted
|
|
|
|
+ | ,get_rowkey_by_prefix(all_rowkey,'company_dishonest_info') as company_dishonest_info_rowkey
|
|
|
|
+ | ,get_rowkey_by_prefix(all_rowkey,'company_zxr') as company_zxr_rowkey
|
|
|
|
+ | ,get_rowkey_by_prefix(all_rowkey,'company_zxr_final_case') as company_zxr_final_case_rowkey
|
|
|
|
+ | ,get_rowkey_by_prefix(all_rowkey,'company_zxr_restrict') as company_zxr_restrict_rowkey
|
|
|
|
+ |from (
|
|
|SELECT credit_punishment_entity_id
|
|
|SELECT credit_punishment_entity_id
|
|
| ,collect_set(keyno)[0] AS keyno
|
|
| ,collect_set(keyno)[0] AS keyno
|
|
| ,collect_set(name)[0] AS name
|
|
| ,collect_set(name)[0] AS name
|
|
| ,collect_set(card_num)[0] AS card_num
|
|
| ,collect_set(card_num)[0] AS card_num
|
|
| ,array_distinct(split(CONCAT_WS(',',collect_set(label)),',')) AS label
|
|
| ,array_distinct(split(CONCAT_WS(',',collect_set(label)),',')) AS label
|
|
- | --- ,sum(record_num) as record_num
|
|
|
|
| ,count(1) as record_num
|
|
| ,count(1) as record_num
|
|
| ,array_distinct(collect_set(split(case_create_time,'-')[0])) AS case_create_time_year
|
|
| ,array_distinct(collect_set(split(case_create_time,'-')[0])) AS case_create_time_year
|
|
| ,double_2_str(sum(CAST(total_exec_amount AS DOUBLE) )) AS total_exec_amount
|
|
| ,double_2_str(sum(CAST(total_exec_amount AS DOUBLE) )) AS total_exec_amount
|
|
@@ -208,8 +254,11 @@ case class CreditPunishmentEntityAgg(s: SparkSession
|
|
| ,sum(company_zxr_restrict_num_1) as company_zxr_restrict_num_1
|
|
| ,sum(company_zxr_restrict_num_1) as company_zxr_restrict_num_1
|
|
|
|
|
|
|
|
| ,deleted_merge(deleted) AS deleted
|
|
| ,deleted_merge(deleted) AS deleted
|
|
|
|
+ | ,array_distinct(split(CONCAT_WS(',',collect_set(all_rowkey)),',')) AS all_rowkey
|
|
|FROM $org_tab
|
|
|FROM $org_tab
|
|
|GROUP BY credit_punishment_entity_id
|
|
|GROUP BY credit_punishment_entity_id
|
|
|
|
+ |)
|
|
|
|
+ |
|
|
|""".stripMargin)
|
|
|""".stripMargin)
|
|
.cache()
|
|
.cache()
|
|
.createTempView("all_data")
|
|
.createTempView("all_data")
|
|
@@ -247,6 +296,10 @@ case class CreditPunishmentEntityAgg(s: SparkSession
|
|
| ,t1.company_zxr_restrict_num_1
|
|
| ,t1.company_zxr_restrict_num_1
|
|
|
|
|
|
|
|
| ,t1.deleted
|
|
| ,t1.deleted
|
|
|
|
+ | ,t1.company_dishonest_info_rowkey
|
|
|
|
+ | ,t1.company_zxr_rowkey
|
|
|
|
+ | ,t1.company_zxr_final_case_rowkey
|
|
|
|
+ | ,t1.company_zxr_restrict_rowkey
|
|
|FROM (
|
|
|FROM (
|
|
| SELECT *
|
|
| SELECT *
|
|
| FROM all_data
|
|
| FROM all_data
|
|
@@ -285,6 +338,10 @@ case class CreditPunishmentEntityAgg(s: SparkSession
|
|
| ,company_zxr_restrict_num_1
|
|
| ,company_zxr_restrict_num_1
|
|
|
|
|
|
|
|
| ,deleted
|
|
| ,deleted
|
|
|
|
+ | ,company_dishonest_info_rowkey
|
|
|
|
+ | ,company_zxr_rowkey
|
|
|
|
+ | ,company_zxr_final_case_rowkey
|
|
|
|
+ | ,company_zxr_restrict_rowkey
|
|
|FROM all_data
|
|
|FROM all_data
|
|
|WHERE not (keyno is not null and length(keyno) = 32) and card_num is not null
|
|
|WHERE not (keyno is not null and length(keyno) = 32) and card_num is not null
|
|
|
|
|
|
|
|
@@ -319,6 +376,10 @@ case class CreditPunishmentEntityAgg(s: SparkSession
|
|
| ,company_zxr_restrict_num_1
|
|
| ,company_zxr_restrict_num_1
|
|
|
|
|
|
|
|
| ,deleted
|
|
| ,deleted
|
|
|
|
+ | ,company_dishonest_info_rowkey
|
|
|
|
+ | ,company_zxr_rowkey
|
|
|
|
+ | ,company_zxr_final_case_rowkey
|
|
|
|
+ | ,company_zxr_restrict_rowkey
|
|
|FROM all_data
|
|
|FROM all_data
|
|
|WHERE not (keyno is not null and length(keyno) = 32) and card_num is null
|
|
|WHERE not (keyno is not null and length(keyno) = 32) and card_num is null
|
|
|
|
|
|
|