Browse Source

feat: 严重违法动态

- 严重违法企业变更
- 严重违法企业动态
- 通用程序如果描述信息(rta_desc)为空则忽略该行
许家凯 4 years ago
parent
commit
f9c191cc60

+ 1 - 0
src/main/scala/com/winhc/bigdata/spark/jobs/chance/ChangeExtract.scala

@@ -310,6 +310,7 @@ object ChangeExtract {
     , Args(tableName = "company_staff", primaryFields = "staff_type")
     //公司名称,法人ID:人标识或公司标识,公司类型,注册地址,营业期限终止日期,经营范围,登记机关,企业状态                 ,注册资本,实收资本金额(单位:分),注销日期,注销原因
     , Args(tableName = "company", primaryKey = "cid", primaryFields = "name,legal_entity_id,company_org_type,reg_location,to_time,business_scope,reg_institute,reg_status,reg_capital,actual_capital_amount,cancel_date,cancel_reason")
+    , Args(tableName = "company_illegal_info",  primaryFields = "remove_reason")
   )
 
   private case class Args(project: String = "winhc_eci_dev"

+ 19 - 0
src/main/scala/com/winhc/bigdata/spark/jobs/chance/table/company_illegal_info.scala

@@ -0,0 +1,19 @@
+package com.winhc.bigdata.spark.jobs.chance.table
+
+import com.winhc.bigdata.spark.jobs.chance.CompanyChangeHandle
+import com.winhc.bigdata.spark.utils.{ChangeExtractUtils, DateUtils}
+
+/**
+ * @Author: XuJiakai
+ * @Date: 2020/8/11 17:26
+ * @Description: 严重违法
+ */
+case class company_illegal_info(equCols: Seq[String]) extends CompanyChangeHandle with Serializable {
+  override def getUpdateTitle(newMap: Map[String, String]): String = "严重违法发生变化"
+
+  override def getInsertTitle(newMap: Map[String, String]): String = "新增一条严重违法"
+
+  override def getLabel(oldMap: Map[String, String], newMap: Map[String, String]): String =  ChangeExtractUtils.getTags(newMap, "严重违法", Array("put_reason", "put_date", "put_department", "remove_reason", "remove_date", "remove_department", "type"))
+
+  override def getBizTime(newMap: Map[String, String]): String = DateUtils.getMaxDate(newMap.getOrElse("put_date", ""), newMap.getOrElse("remove_date", ""))
+}

+ 1 - 0
src/main/scala/com/winhc/bigdata/spark/jobs/dynamic/CompanyDynamic.scala

@@ -182,6 +182,7 @@ object CompanyDynamic {
     , Args(tableName = "company_staff", bName = 0)
     , Args(tableName = "company", bName = 0)
     , Args(tableName = "bankruptcy_open_case", bName = 1)
+    , Args(tableName = "company_illegal_info", bName = 0)
   )
 
   private case class Args(project: String = "winhc_eci_dev"

+ 5 - 1
src/main/scala/com/winhc/bigdata/spark/jobs/dynamic/CompanyDynamicHandle.scala

@@ -171,10 +171,14 @@ trait CompanyDynamicHandle {
    *         winhc_suggest
    */
   def handle(rowkey: String, bizDate: String, cid: String, change_fields: Seq[String], old_map: Map[String, String], new_map: Map[String, String], cname: String = null, suggestion: String = null): Seq[(String, String, String, String, String, String, String, String, String, String)] = {
+    val rta_desc = get_rta_desc(old_map, new_map)
+    if (rta_desc == null) {
+      return Seq.empty
+    }
     Seq((cid
       , cname
       , get_info_type()
-      , get_rta_desc(old_map, new_map)
+      , rta_desc
       , get_change_content(old_map, new_map)
       , get_change_time(bizDate, new_map)
       , get_biz_id(rowkey)

+ 1 - 1
src/main/scala/com/winhc/bigdata/spark/jobs/dynamic/tables/company_equity_info.scala

@@ -84,5 +84,5 @@ case class company_equity_info() extends CompanyDynamicHandle {
    * @param new_map
    * @return
    */
-  override protected def get_info_risk_level(old_map: Map[String, String], new_map: Map[String, String]): String = "1"
+  override protected def get_info_risk_level(old_map: Map[String, String], new_map: Map[String, String]): String = null
 }

+ 54 - 0
src/main/scala/com/winhc/bigdata/spark/jobs/dynamic/tables/company_illegal_info.scala

@@ -0,0 +1,54 @@
+package com.winhc.bigdata.spark.jobs.dynamic.tables
+
+import com.winhc.bigdata.spark.jobs.dynamic.CompanyDynamicHandle
+import com.winhc.bigdata.spark.implicits.MapHelper._
+
+/**
+ * @Author: XuJiakai
+ * @Date: 2020/8/11 17:39
+ * @Description: 严重违法
+ */
+case class company_illegal_info() extends CompanyDynamicHandle {
+
+
+  /**
+   * 来源表的变更类型,insert or update
+   *
+   * @return
+   */
+  override def org_type(): Seq[String] = Seq("insert", "update")
+
+  /**
+   * 信息描述
+   *
+   * @param old_map
+   * @param new_map
+   * @return
+   */
+  override protected def get_rta_desc(old_map: Map[String, String], new_map: Map[String, String]): String = {
+    if (old_map == null)
+      return s"新增严重违法记录:${new_map.getOrElse("put_reason", "")}"
+
+    if (old_map.get("remove_date") == null && new_map("remove_date") != null)
+      return s"移除严重违法记录:${new_map.getOrElse("remove_reason", "")}"
+
+    null
+  }
+
+  /**
+   * 变更内容
+   *
+   * @param old_map
+   * @param new_map
+   * @return
+   */
+  override protected def get_change_content(old_map: Map[String, String], new_map: Map[String, String], cname: String): String = new_map.toJson(Seq(
+    "put_reason->列入原因"
+    , "put_date->列入时间"
+    , "remove_date->移除时间"
+    , "put_department->列入决定机关"
+    , "remove_reason->移除原因"
+    , "remove_department->移除决定机关"
+    , "type->类型"
+  ))
+}

+ 24 - 2
src/main/scala/com/winhc/bigdata/spark/utils/DateUtils.scala

@@ -11,11 +11,33 @@ object DateUtils {
 
   def toUnixTimestamp(date: String, pattern: String = "yyyy-MM-dd HH:mm:ss"): Long = {
     val fm = new SimpleDateFormat(pattern)
-    fm.parse(date).getTime/1000
+    fm.parse(date).getTime / 1000
+  }
+
+
+  /**
+   * 获取最大的一个日期,如果有异常情况则反回第一个日期
+   *
+   * @param date1
+   * @param date2
+   */
+  def getMaxDate(date1: String, date2: String): String = {
+    try {
+      if (date1.length != date2.length) {
+        return date1
+      }
+      date1.compareTo(date2) match {
+        case -1 => date2
+        case 1 => date1
+        case _ => date1
+      }
+    } catch {
+      case e: Exception => date1
+    }
   }
 
   def main(args: Array[String]): Unit = {
-    println(toUnixTimestamp(date = "2020-08-10 11:22:08"))
+    println(getMaxDate("2003-10-12 10:00:00", "2003-11-12 00:00:01"))
   }
 
 }