Commit caacb65f authored by 王志伟's avatar 王志伟

修复bug

parent 73217b30
......@@ -718,107 +718,4 @@ object Recommendation_stra233tegy_all {
}
//以下内容统计信息熵基尼系数
object Gini_coefficient {
Logger.getLogger("org.apache.spark").setLevel(Level.WARN)
Logger.getLogger("org.apache.eclipse.jetty.server").setLevel(Level.OFF)
case class Params(env: String = "dev",
date: String = "2018-08-01"
) extends AbstractParams[Params] with Serializable
val defaultParams = Params()
val parser = new OptionParser[Params]("Feed_EDA") {
head("Gini_coefficient")
opt[String]("env")
.text(s"the databases environment you used")
.action((x, c) => c.copy(env = x))
opt[String] ("date")
.text(s"the date you used")
.action((x,c) => c.copy(date = x))
note(
"""
|For example, the following command runs this app on a tidb dataset:
|
| spark-submit --class com.gmei.WeafareStat ./target/scala-2.11/feededa-assembly-0.1.jar \
""".stripMargin +
s"| --env ${defaultParams.env}"
)
}
def main(args: Array[String]): Unit = {
parser.parse(args, defaultParams).map { param =>
GmeiConfig.setup(param.env)
val spark_env = GmeiConfig.getSparkSession()
val sc = spark_env._2
val ti = new TiContext(sc)
ti.tidbMapTable(dbName = "eagle", tableName = "src_mimas_prod_api_diary")
ti.tidbMapTable(dbName = "jerry_prod", tableName = "data_feed_click")
ti.tidbMapTable(dbName = "jerry_prod", tableName = "blacklist")
ti.tidbMapTable(dbName = "jerry_prod", tableName = "data_feed_exposure")
import sc.implicits._
val stat_date = GmeiConfig.getMinusNDate(1)
//println(param.date)
val partition_date = stat_date.replace("-","")
//获取3.5星及以上日记本id
val diary_id = sc.sql(
s"""
|select id as diary_id
|from src_mimas_prod_api_diary
|where content_level >=3.5
|and doctor_id is not null
""".stripMargin
)
diary_id.createOrReplaceTempView("temp1")
//机构id
val agency_id = sc.sql(
s"""
|SELECT DISTINCT(cl_id) as device_id
|FROM online.ml_hospital_spam_pv_day
|WHERE partition_date >= '20180402'
|AND partition_date <= '20181203'
|AND pv_ratio >= 0.95
|UNION ALL
|SELECT DISTINCT(cl_id) as device_id
|FROM online.ml_hospital_spam_pv_month
|WHERE partition_date >= '20171101'
|AND partition_date <= '20181203'
|AND pv_ratio >= 0.95
""".stripMargin
)
agency_id.createOrReplaceTempView("agency_id")
//统计次数
val diary_clk_num = sc.sql(
s"""
|select temp1.diary_id as diary_id,count(ov.cl_id) as diary_clk_num
|from online.tl_hdfs_maidian_view ov left join temp1
|on params["business_id"]= temp1.diary_id
|where ov.action="page_view"
|and ov.params["page_name"]="diary_detail"
|and temp1.diary_id is not null
|and (ov.params["out"]-ov.params["in"])<7200
|and ov.partition_date ='${partition_date}'
|and ov.cl_id not in (select device_id from blacklist)
|group by temp1.diary_id
""".stripMargin
)
GmeiConfig.writeToJDBCTable(diary_clk_num, "Gini_coefficient", SaveMode.Overwrite)
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment