Просмотр исходного кода

feat:司法案件之送达公告、限制消费

晏永年 4 лет назад
Родитель
Сommit
d5dbd19a7c

+ 124 - 0
src/main/scala/com/winhc/bigdata/spark/jobs/judicial/JudicialCaseRelationPre45.scala

@@ -0,0 +1,124 @@
+package com.winhc.bigdata.spark.jobs.judicial
+
+import com.winhc.bigdata.spark.udf.{BaseFunc, CompanyMapping}
+import com.winhc.bigdata.spark.utils.BaseUtil.isWindows
+import com.winhc.bigdata.spark.utils.{LoggingUtils, SparkUtils}
+import org.apache.spark.sql.SparkSession
+
+import scala.collection.mutable
+
+/**
+ * @Description:司法案件预处理
+ * @author Yan Yongnian
+ * @date 2020/9/27
+ */
+object JudicialCaseRelationPre45 {
+  def main(args: Array[String]): Unit = {
+    val project = "winhc_eci_dev"
+    println(
+      s"""
+         |project: $project
+         |""".stripMargin)
+
+    val config = mutable.Map(
+      "spark.hadoop.odps.project.name" -> s"$project",
+      "spark.hadoop.odps.spark.local.partition.amt" -> "1000"
+    )
+    val spark: SparkSession = SparkUtils.InitEnv(this.getClass.getSimpleName, config)
+    JudicialCaseRelationPre45(spark, project).precalc()
+    spark.stop()
+  }
+}
+case class JudicialCaseRelationPre45(s: SparkSession, project: String
+                                   ) extends LoggingUtils with CompanyMapping with BaseFunc {
+  override protected val spark: SparkSession = s
+
+  def precalc(): Unit = {
+    prepareFunctions(spark)
+    //送达公告预处理
+    sql(
+      s"""
+         |insert ${if (isWindows) "INTO" else "OVERWRITE"} table $project.ads_judicial_case_relation_pre partition(ds='20200927',tn='send_announcement')
+         |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
+         |      ,"4" as flag
+         |      ,concat_ws('',plaintiff,'与',defendant,case_reason) as title
+         |      ,concat_ws('',case_type(case_no)) as case_type
+         |      ,case_reason
+         |      ,case_no
+         |      ,court as court_name
+         |      ,concat_ws('',case_stage(case_no)) as case_stage
+         |      ,plaintiff as yg_name
+         |      ,defendant as bg_name
+         |      ,start_date as date
+         |      ,rowkey as detail_id
+         |      ,0.0 as case_amt
+         |      ,row_number() over(partition by rowkey order by update_time desc) num
+         |      from $project.inc_ads_company_send_announcement
+         |      where length(case_no) > 0 and ds > '0'
+         |   )
+         |where num = 1
+         |""".stripMargin).show(10, false)
+
+    //限制高消费预处理
+    sql(
+      s"""
+         |insert ${if (isWindows) "INTO" else "OVERWRITE"} table $project.ads_judicial_case_relation_pre partition(ds='20200927',tn='zxr_restrict')
+         |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
+         |      ,"5" as flag
+         |      ,if(length(company_name)>3 OR length(company_info)>3, concat_ws('',coalesce(company_name,company_info),'及',name,'被采取限制消费措施'),concat_ws('',name,'被采取限制消费措施')) AS title
+         |      ,concat_ws('',case_type(case_no)) as case_type
+         |      ,NULL AS case_reason
+         |      ,case_no
+         |      ,court_name
+         |      ,concat_ws('',case_stage(case_no)) as case_stage
+         |      ,NULL as yg_name
+         |      ,if(length(company_name)>3 OR length(company_info)>3, coalesce(company_name,company_info),name) as bg_name
+         |      ,appro_time as date--目前天眼查数据没有执行日期,先以此代替
+         |      ,rowkey as detail_id
+         |      ,0.0 as case_amt
+         |      ,row_number() over(partition by rowkey order by update_time desc) num
+         |      from $project.inc_ads_company_zxr_restrict
+         |      where length(case_no) > 0 and ds > '0'
+         |   )
+         |where num = 1
+         |""".stripMargin).show(10, false)
+
+
+
+    //tmp_xf_judicial_case_relation_open_counrt
+    //tmp_xf_judicial_case_relation_wenshu
+
+  }
+}

+ 1 - 1
src/main/scala/com/winhc/bigdata/spark/utils/BaseUtil.scala

@@ -157,7 +157,7 @@ object BaseUtil {
         return "行政案件"
       } else if (caseNO.contains("刑")) {
         return "刑事案件"
-      } else if (caseNO.contains("")) {
+      } else if (caseNO.contains("")) {
         return "赔偿案件"
       }
     }