|
@@ -1,15 +1,18 @@
|
|
|
package com.winhc.bigdata.spark.ng.dynamic.handle
|
|
|
|
|
|
+import com.winhc.bigdata.spark.implicits.Bool._
|
|
|
+import com.winhc.bigdata.spark.ng.dynamic.NgCompanyRiskLevelType.NgCompanyRiskLevelType
|
|
|
import com.winhc.bigdata.spark.ng.dynamic._
|
|
|
+import com.winhc.bigdata.spark.ng.dynamic.utils._
|
|
|
import com.winhc.bigdata.spark.utils.RegCapitalAmount
|
|
|
-import com.winhc.bigdata.spark.implicits.MapHelper._
|
|
|
+
|
|
|
import scala.collection.mutable
|
|
|
|
|
|
/**
|
|
|
* @author: XuJiakai
|
|
|
* @date: 2021/6/22 16:04
|
|
|
*/
|
|
|
-case class company(is_inc:Boolean) extends NgCompanyDynamicHandle {
|
|
|
+case class company(is_inc: Boolean) extends NgCompanyDynamicHandle {
|
|
|
private def getCompanyDynamicRecord(change_extract: ChangeExtract, dynamic_code: String, dynamic_info: Map[String, String], update_field: String): CompanyDynamicRecord = {
|
|
|
val company_id = change_extract.company_id
|
|
|
val company_name = change_extract.company_name
|
|
@@ -27,92 +30,196 @@ case class company(is_inc:Boolean) extends NgCompanyDynamicHandle {
|
|
|
val biz_date = change_extract.biz_date
|
|
|
val rowkey = change_extract.rowkey
|
|
|
val update_time = change_extract.update_time
|
|
|
+
|
|
|
+
|
|
|
+ def getRecordPro(dynamicCode: String
|
|
|
+ , name: String
|
|
|
+ , keyno: String
|
|
|
+ , label: String
|
|
|
+ , risk_level: NgCompanyRiskLevelType
|
|
|
+ , content: Seq[ChangeContent]
|
|
|
+ ): CompanyDynamicRecord = {
|
|
|
+ val map = BusinessInfoDynamicInfoMap(label = label, content = content)
|
|
|
+
|
|
|
+ val date = if (is_inc) update_time else biz_date
|
|
|
+ CompanyDynamicRecord(
|
|
|
+ id = CompanyDynamicUtils.generateId(rowkey, date, tn, dynamicCode)
|
|
|
+ , association_entity_info = Seq(AssociationEntityInfo(keyno = keyno, name = name, risk_level = risk_level, rta_info = null))
|
|
|
+ , rowkey = rowkey
|
|
|
+ , tn = tn
|
|
|
+ , update_type = update_type
|
|
|
+ , dynamic_code = dynamicCode
|
|
|
+ , dynamic_info = map.toMap()
|
|
|
+ , agg_detail_text = null
|
|
|
+ , agg_detail_rowkey = null
|
|
|
+ , biz_time = biz_date
|
|
|
+ , dynamic_time = date
|
|
|
+ , update_time = update_time
|
|
|
+ , create_time = update_time
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ def getSingleRecordChange(code: String, label: String, keyno: String, name: String, before: String, after: String, riskLevel: NgCompanyRiskLevelType = NgCompanyRiskLevelType.Prompt, flag: String = null): CompanyDynamicRecord = {
|
|
|
+ getRecordPro(
|
|
|
+ dynamicCode = code
|
|
|
+ , keyno = keyno
|
|
|
+ , name = name
|
|
|
+ , label = label
|
|
|
+ , risk_level = riskLevel
|
|
|
+ , content = Seq(ChangeContent(code, before = Entity(info = before), after = Entity(info = after), Entity(name = name, keyno = keyno), flag = flag))
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
var list: mutable.Seq[CompanyDynamicRecord] = mutable.Seq.empty
|
|
|
|
|
|
+
|
|
|
+ def companyNameChange(beforeName: String, afterName: String): Seq[CompanyDynamicRecord] = {
|
|
|
+ val record = getSingleRecordChange("101001", "公司更名", company_id, company_name, beforeName, afterName)
|
|
|
+ Seq(record)
|
|
|
+ }
|
|
|
+
|
|
|
+ //注册资本
|
|
|
+ def registeredCapitalChange(before: String, after: String): Seq[CompanyDynamicRecord] = {
|
|
|
+ val bool = RegCapitalAmount.isAdditionalShare(before, after)
|
|
|
+ val flag = bool ? "1" | "0"
|
|
|
+ val r = bool ? NgCompanyRiskLevelType.Positive | NgCompanyRiskLevelType.Caution
|
|
|
+
|
|
|
+ val record = getSingleRecordChange("101002", "注册资本", company_id, company_name, before, after, riskLevel = r, flag = flag)
|
|
|
+ Seq(record)
|
|
|
+ }
|
|
|
+
|
|
|
+ def companyNew(afterName: String, afterKeyno: String): Seq[CompanyDynamicRecord] = {
|
|
|
+ val cdr = getRecordPro(
|
|
|
+ dynamicCode = "109001"
|
|
|
+ , keyno = afterKeyno
|
|
|
+ , name = afterName
|
|
|
+ , label = "任职变化"
|
|
|
+ , risk_level = NgCompanyRiskLevelType.Prompt
|
|
|
+ , content = Seq(ChangeContent("109001", before = null
|
|
|
+ , after = Entity(name = company_name, keyno = company_id)
|
|
|
+ , Entity(afterName, afterKeyno)))
|
|
|
+ )
|
|
|
+ Seq(cdr)
|
|
|
+ }
|
|
|
+
|
|
|
+ //法人变化
|
|
|
+ def legalRepresentativeChange(beforeName: String, beforeKeyno: String, afterName: String, afterKeyno: String): Seq[CompanyDynamicRecord] = {
|
|
|
+
|
|
|
+ val cdr = getRecordPro(
|
|
|
+ dynamicCode = "101003"
|
|
|
+ , keyno = company_id
|
|
|
+ , name = company_name
|
|
|
+ , label = "法定代表人变更"
|
|
|
+ , risk_level = NgCompanyRiskLevelType.Prompt
|
|
|
+ , content = Seq(ChangeContent("101003", before = Entity(beforeName, beforeKeyno)
|
|
|
+ , after = Entity(afterName, afterKeyno)
|
|
|
+ , Entity(name = company_name, keyno = company_id)))
|
|
|
+ )
|
|
|
+
|
|
|
+ val cdr2 = getRecordPro(
|
|
|
+ dynamicCode = "109001"
|
|
|
+ , keyno = afterKeyno
|
|
|
+ , name = afterName
|
|
|
+ , label = "任职变化"
|
|
|
+ , risk_level = NgCompanyRiskLevelType.Prompt
|
|
|
+ , content = Seq(ChangeContent("109001", before = null
|
|
|
+ , after = Entity(name = company_name, keyno = company_id)
|
|
|
+ , Entity(afterName, afterKeyno)))
|
|
|
+ )
|
|
|
+
|
|
|
+ val cdr3 = getRecordPro(
|
|
|
+ dynamicCode = "109002"
|
|
|
+ , keyno = beforeKeyno
|
|
|
+ , name = beforeName
|
|
|
+ , label = "任职变化"
|
|
|
+ , risk_level = NgCompanyRiskLevelType.Prompt
|
|
|
+ , content = Seq(ChangeContent("109002", before = Entity(name = company_name, keyno = company_id)
|
|
|
+ , after = null
|
|
|
+ , Entity(beforeName, beforeKeyno)))
|
|
|
+ )
|
|
|
+ Seq(cdr, cdr2, cdr3)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //注册地址变化
|
|
|
+ def registeredAddressChange(before: String, after: String): Seq[CompanyDynamicRecord] = {
|
|
|
+ val record = getSingleRecordChange("101004", "注册地址变化", company_id, company_name, before, after)
|
|
|
+ Seq(record)
|
|
|
+ }
|
|
|
+
|
|
|
+ //经营范围变化
|
|
|
+ def businessScopeChange(before: String, after: String): Seq[CompanyDynamicRecord] = {
|
|
|
+ val record = getSingleRecordChange("101005", "经营范围变化", company_id, company_name, before, after)
|
|
|
+ Seq(record)
|
|
|
+ }
|
|
|
+
|
|
|
+ //todo 公司状态变化
|
|
|
+ @deprecated
|
|
|
+ def companyStateChange(before: String, after: String): Seq[CompanyDynamicRecord] = {
|
|
|
+ val r = (after.contains("销")) ? NgCompanyRiskLevelType.Caution | NgCompanyRiskLevelType.Prompt
|
|
|
+ val record = getSingleRecordChange("101006", "公司状态变化", company_id, company_name, before, after, riskLevel = r)
|
|
|
+ Seq(record)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
update_type match {
|
|
|
case "insert" => {
|
|
|
- val legal_entity_id = new_data("legal_entity_id")
|
|
|
- val legal_entity_name = new_data("legal_entity_name")
|
|
|
- val code = "100100"
|
|
|
- val dynamic_info = Map(
|
|
|
- "code" -> code,
|
|
|
- "description" -> "公司新成立"
|
|
|
- )
|
|
|
- list = list :+ getCompanyDynamicRecord(change_extract = change_extract
|
|
|
- , code
|
|
|
- , dynamic_info = dynamic_info
|
|
|
- , update_field = null
|
|
|
- , association_entity_info = Seq(AssociationEntityInfo(keyno = legal_entity_id, name = legal_entity_name, risk_level = NgCompanyRiskLevelType.Prompt, rta_info = null))
|
|
|
- )
|
|
|
+ //公司新成立
|
|
|
+ val new_name = new_data("legal_entity_name")
|
|
|
+ val new_keyno = new_data("legal_entity_id")
|
|
|
+ list = list ++ companyNew(new_name, new_keyno)
|
|
|
}
|
|
|
case "update" => {
|
|
|
for (elem <- change_fields.intersect("name,reg_capital,legal_entity_name,reg_location,business_scope,reg_status_std".split(","))) {
|
|
|
elem match {
|
|
|
case "name" => {
|
|
|
- val code = "100101"
|
|
|
- val dynamic_info = Map(
|
|
|
- "code" -> code,
|
|
|
- "description" -> "公司名称发生变化"
|
|
|
- )
|
|
|
- list = list :+ getCompanyDynamicRecord(change_extract, code, dynamic_info, "name")
|
|
|
+ val old_name = old_data("name")
|
|
|
+ val new_name = new_data("name")
|
|
|
+ //公司名称变化
|
|
|
+ list = list ++ companyNameChange(old_name, new_name)
|
|
|
}
|
|
|
- case "reg_capital" => { //注册资本需发生实质性变化
|
|
|
+ case "reg_capital" => {
|
|
|
+ //注册资本变化
|
|
|
val old_reg_capital: String = RegCapitalAmount.getAmount(old_data("reg_capital"))
|
|
|
val new_reg_capital: String = RegCapitalAmount.getAmount(new_data("reg_capital"))
|
|
|
if (old_reg_capital != null && new_reg_capital != null) {
|
|
|
if (!old_reg_capital.equals(new_reg_capital)) {
|
|
|
- val code = "100102"
|
|
|
- val dynamic_info = Map(
|
|
|
- "code" -> code,
|
|
|
- "description" -> "注册资本发生变化"
|
|
|
- )
|
|
|
- list = list :+ getCompanyDynamicRecord(change_extract, code, dynamic_info, "reg_capital")
|
|
|
+ //注册资本发生实质性变化
|
|
|
+ list = list ++ registeredCapitalChange(old_data("reg_capital"), new_data("reg_capital"))
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
case "legal_entity_name" => {
|
|
|
- val code = "100103"
|
|
|
- val dynamic_info = Map(
|
|
|
- "code" -> code,
|
|
|
- "description" -> "法定代表人发生变化"
|
|
|
- )
|
|
|
- //todo 法人变化 单条记录两个实体
|
|
|
- list = list :+ getCompanyDynamicRecord(change_extract, code, dynamic_info, "legal_entity_name")
|
|
|
+ //法定代表人变化
|
|
|
+ val old_name = old_data("legal_entity_name")
|
|
|
+ val old_keyno = old_data("legal_entity_id")
|
|
|
+ val new_name = new_data("legal_entity_name")
|
|
|
+ val new_keyno = new_data("legal_entity_id")
|
|
|
+ list = list ++ legalRepresentativeChange(old_name, old_keyno, new_name, new_keyno)
|
|
|
}
|
|
|
|
|
|
case "reg_location" => {
|
|
|
- val code = "100104"
|
|
|
- val dynamic_info = Map(
|
|
|
- "code" -> code,
|
|
|
- "description" -> "公司注册地址发生变化"
|
|
|
- )
|
|
|
- list = list :+ getCompanyDynamicRecord(change_extract, code, dynamic_info, "reg_location")
|
|
|
+ //注册地址变化
|
|
|
+ val old_record = old_data("reg_location")
|
|
|
+ val new_record = new_data("reg_location")
|
|
|
+ list = list ++ registeredAddressChange(old_record, new_record)
|
|
|
}
|
|
|
|
|
|
case "business_scope" => {
|
|
|
- val code = "100105"
|
|
|
- val dynamic_info = Map(
|
|
|
- "code" -> code,
|
|
|
- "description" -> "公司经营范围发生变化"
|
|
|
- )
|
|
|
- list = list :+ getCompanyDynamicRecord(change_extract, code, dynamic_info, "business_scope")
|
|
|
+ //经营范围变化
|
|
|
+ val old_record = old_data("business_scope")
|
|
|
+ val new_record = new_data("business_scope")
|
|
|
+ list = list ++ businessScopeChange(old_record, new_record)
|
|
|
}
|
|
|
|
|
|
case "reg_status_std" => {
|
|
|
- val code = "100106"
|
|
|
- val dynamic_info = Map(
|
|
|
- "code" -> code,
|
|
|
- "description" -> "公司状态发生变化"
|
|
|
- )
|
|
|
- val reg_status_std = new_data.getOrEmptyStr("reg_status_std")
|
|
|
- if (reg_status_std.contains("销")) {
|
|
|
- list = list :+ getCompanyDynamicRecord(change_extract, code, dynamic_info, "reg_status_std",
|
|
|
- association_entity_info = Seq(AssociationEntityInfo(keyno = company_id, name = company_name, risk_level = NgCompanyRiskLevelType.Caution, rta_info = null))
|
|
|
- )
|
|
|
- } else {
|
|
|
- list = list :+ getCompanyDynamicRecord(change_extract, code, dynamic_info, "reg_status_std")
|
|
|
- }
|
|
|
+ //todo 公司状态变化
|
|
|
+ val old_record = old_data("reg_status_std")
|
|
|
+ val new_record = new_data("reg_status_std")
|
|
|
+ // list = list ++ companyStateChange(old_record, new_record)
|
|
|
+
|
|
|
}
|
|
|
case _ => null
|
|
|
}
|
|
@@ -121,7 +228,6 @@ case class company(is_inc:Boolean) extends NgCompanyDynamicHandle {
|
|
|
|
|
|
case _ => null
|
|
|
}
|
|
|
-
|
|
|
list
|
|
|
}
|
|
|
|