Selaa lähdekoodia

fix: 计算公司权重使用自有amount

许家凯 3 vuotta sitten
vanhempi
commit
cea6f42ac8

+ 45 - 13
src/main/scala/com/winhc/bigdata/spark/ng/jobs/CompanyIndexJob.scala

@@ -303,37 +303,69 @@ case class CompanyIndexJob(s: SparkSession,
     val alias_tab = "alias_base_" + company_tab
     sql(
       s"""
-         |SELECT  company_id AS id
-         |        ,get_company(name) AS name
+         |SELECT  id
+         |        ,name
          |        ,new_cid
          |        ,name_alias
-         |        ,get_history_name(name,history_names) AS history_name
-         |        ,cast(legal_entity_id as string) as legal_entity_id
-         |        ,cast(legal_entity_type as string) as legal_entity_type
+         |        ,history_name
+         |        ,legal_entity_id
+         |        ,legal_entity_type
          |        ,legal_entity_name
          |        ,province_code
          |        ,city_code
          |        ,county_code
-         |        ,to_millis_timestamp(estiblish_time) AS estiblish_time
+         |        ,estiblish_time
          |        ,cate_first_code
          |        ,cate_second_code
          |        ,cate_third_code
          |        ,reg_status
          |        ,reg_status_std
-         |        ,get_company_org_type_std(name,company_org_type) as company_org_type_std
+         |        ,company_org_type_std
          |        ,company_type
          |        ,credit_code
          |        ,reg_capital
-         |        ,get_amount(reg_capital) as reg_capital_amount
+         |        ,reg_capital_amount
          |        ,reg_location
-         |        ,get_phones_emails(phones) AS phones
-         |        ,get_phones_emails(emails) AS emails
-         |        ,get_geo(lat,lng) AS geo
+         |        ,phones
+         |        ,emails
+         |        ,geo
          |        ,logo
          |        ,reg_number
-         |        ,get_company_score_weight(reg_status,name,reg_capital_amount,company_type) as company_score_weight
+         |        ,get_company_score_weight(reg_status,xjk_name,reg_capital_amount,company_type) AS company_score_weight
          |        ,deleted
-         |FROM    $company_tab
+         |FROM    (
+         |        SELECT  company_id AS id
+         |                ,name as xjk_name
+         |                ,get_company(name) AS name
+         |                ,new_cid
+         |                ,name_alias
+         |                ,get_history_name(name,history_names) AS history_name
+         |                ,CAST (legal_entity_id  AS STRING ) AS legal_entity_id
+         |                ,CAST (legal_entity_type AS STRING ) AS legal_entity_type
+         |                ,legal_entity_name
+         |                ,province_code
+         |                ,city_code
+         |                ,county_code
+         |                ,to_millis_timestamp(estiblish_time) AS estiblish_time
+         |                ,cate_first_code
+         |                ,cate_second_code
+         |                ,cate_third_code
+         |                ,reg_status
+         |                ,reg_status_std
+         |                ,get_company_org_type_std(name,company_org_type) AS company_org_type_std
+         |                ,company_type
+         |                ,credit_code
+         |                ,reg_capital
+         |                ,get_amount(reg_capital) AS reg_capital_amount
+         |                ,reg_location
+         |                ,get_phones_emails(phones) AS phones
+         |                ,get_phones_emails(emails) AS emails
+         |                ,get_geo(lat,lng) AS geo
+         |                ,logo
+         |                ,reg_number
+         |                ,deleted
+         |        FROM    $company_tab
+         |        )
          |""".stripMargin)
       .createTempView(alias_tab)
     alias_tab

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

@@ -55,7 +55,7 @@ object CompanyIndexUtils {
       return "1"
     val amount = reg_capital_amount == null match {
       case true => 0L
-      case false => reg_capital_amount.toLong
+      case false => reg_capital_amount.toDouble
     }
     var w = Math.log(amount / 10000000 + 1) + 1
     if ("1".equals(company_type))
@@ -70,4 +70,10 @@ object CompanyIndexUtils {
       Seq.empty[String]
     }
   }
+
+  def main(args: Array[String]): Unit = {
+    println(company_score_weight("存续(在营、开业、在册)","新疆现代特油科技股份有限公司","200309577000000","1"))
+  }
+  //200309577000000
+  //20030957700.00
 }