|
@@ -1,7 +1,9 @@
|
|
|
package com.winhc.bigdata.spark.jobs.chance
|
|
|
|
|
|
-import com.winhc.bigdata.spark.utils.BaseUtil
|
|
|
import com.winhc.bigdata.spark.utils.BaseUtil.cleanup
|
|
|
+import com.winhc.bigdata.spark.utils.ChangeExtractUtils
|
|
|
+import org.apache.commons.lang3.StringUtils
|
|
|
+import org.apache.spark.internal.Logging
|
|
|
|
|
|
import scala.annotation.meta.{getter, setter}
|
|
|
|
|
@@ -11,7 +13,7 @@ import scala.annotation.meta.{getter, setter}
|
|
|
* @Description:
|
|
|
*/
|
|
|
|
|
|
-trait CompanyChangeHandle extends Serializable {
|
|
|
+trait CompanyChangeHandle extends Serializable with Logging {
|
|
|
@getter
|
|
|
@setter
|
|
|
protected val equCols: Seq[String]
|
|
@@ -21,9 +23,33 @@ trait CompanyChangeHandle extends Serializable {
|
|
|
* @param rowkey
|
|
|
* @param oldMap
|
|
|
* @param newMap
|
|
|
- * @return rowkey,类型【insert or update】,新数据,更新字段,更新标题,变更标签【1.一般变更,2.风险变更 ...】,业务时间
|
|
|
+ * @return rowkey,cid,类型【insert or update】,新数据,更新字段,更新标题,变更标签【1.一般变更,2.风险变更 ...】,业务时间
|
|
|
*/
|
|
|
- def handle(rowkey: String, oldMap: Map[String, String], newMap: Map[String, String]): (String, String, Map[String, String], String, String, String, String)
|
|
|
+ def handle(rowkey: String, oldMap: Map[String, String], newMap: Map[String, String]): (String, String, String, Map[String, String], String, String, String, String) = {
|
|
|
+ if (oldMap == null) {
|
|
|
+ (rowkey, getCid(rowkey, newMap), "insert", newMap, null, getInsertTitle(newMap), getLabel(oldMap, newMap), getBizTime(newMap))
|
|
|
+ } else {
|
|
|
+ val t = getEquAndFields(oldMap, newMap)
|
|
|
+ if (t._1) {
|
|
|
+ null
|
|
|
+ } else {
|
|
|
+ (rowkey, getCid(rowkey, newMap), "update", newMap,
|
|
|
+ t._2
|
|
|
+ , getUpdateTitle(newMap), getLabel(oldMap, newMap), getBizTime(newMap))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ def getCid(rowkey: String, newMap: Map[String, String]): String = rowkey.split("_")(0)
|
|
|
+
|
|
|
+ def getUpdateTitle(newMap: Map[String, String]): String
|
|
|
+
|
|
|
+ def getInsertTitle(newMap: Map[String, String]): String
|
|
|
+
|
|
|
+ def getLabel(oldMap: Map[String, String], newMap: Map[String, String]): String
|
|
|
+
|
|
|
+ def getBizTime(newMap: Map[String, String]): String
|
|
|
|
|
|
def getEquAndFields(oldMap: Map[String, String], newMap: Map[String, String]): (Boolean, String) = {
|
|
|
val tmp = equCols.map(f => {
|
|
@@ -36,40 +62,59 @@ trait CompanyChangeHandle extends Serializable {
|
|
|
(eq, tmp.filter(!_._2).map(_._1).mkString(","))
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
|
|
|
-//土地公示
|
|
|
-case class company_land_publicity(equCols: Seq[String]) extends CompanyChangeHandle with Serializable {
|
|
|
- override def handle(rowkey: String, oldMap: Map[String, String], newMap: Map[String, String]): (String, String, Map[String, String], String, String, String, String) = {
|
|
|
- if (oldMap == null) {
|
|
|
- (rowkey, "insert", newMap, "", s"新增某地块公示", "1", "业务时间")
|
|
|
+
|
|
|
+ protected def getValueOrNull(value: String, callBack: String): String = {
|
|
|
+ if (StringUtils.isNotBlank(value)) {
|
|
|
+ callBack
|
|
|
} else {
|
|
|
- val t = getEquAndFields(oldMap, newMap)
|
|
|
- if (t._1) {
|
|
|
- null
|
|
|
- } else {
|
|
|
- (rowkey, "update", newMap,
|
|
|
- t._2
|
|
|
- , s"更新某地块公示", "1", "业务时间")
|
|
|
- }
|
|
|
+ null
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+//土地公示
|
|
|
+case class company_land_publicity(equCols: Seq[String]) extends CompanyChangeHandle with Serializable {
|
|
|
+
|
|
|
+ override def getLabel(oldMap: Map[String, String], newMap: Map[String, String]): String = "1"
|
|
|
+
|
|
|
+ override def getBizTime(newMap: Map[String, String]): String = "业务时间"
|
|
|
+
|
|
|
+ override def getUpdateTitle(newMap: Map[String, String]): String = "更新某地块公示"
|
|
|
+
|
|
|
+ override def getInsertTitle(newMap: Map[String, String]): String = "新增某地块公示"
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
case class company(equCols: Seq[String]) extends CompanyChangeHandle with Serializable {
|
|
|
- override def handle(rowkey: String, oldMap: Map[String, String], newMap: Map[String, String]): (String, String, Map[String, String], String, String, String, String) = {
|
|
|
- if (oldMap == null) {
|
|
|
- (rowkey, "insert", newMap, "", s"新增一家公司", "1", "业务时间")
|
|
|
- } else {
|
|
|
- val t = getEquAndFields(oldMap, newMap)
|
|
|
- if (t._1) {
|
|
|
- null
|
|
|
- } else {
|
|
|
- (rowkey, "update", newMap,
|
|
|
- t._2
|
|
|
- , s"更新一家公司", "1", "业务时间")
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ override def getCid(rowkey: String, newMap: Map[String, String]): String = rowkey
|
|
|
+
|
|
|
+ override def getLabel(oldMap: Map[String, String], newMap: Map[String, String]): String = "1"
|
|
|
+
|
|
|
+ override def getBizTime(newMap: Map[String, String]): String = "业务时间"
|
|
|
+
|
|
|
+ override def getUpdateTitle(newMap: Map[String, String]): String = "更新一家公司"
|
|
|
+
|
|
|
+ override def getInsertTitle(newMap: Map[String, String]): String = "新增一家公司"
|
|
|
+}
|
|
|
+
|
|
|
+case class company_tm(equCols: Seq[String]) extends CompanyChangeHandle {
|
|
|
+ override def getUpdateTitle(newMap: Map[String, String]): String = getValueOrNull(newMap("tm_name"), s"${newMap("tm_name")}商标发生变更")
|
|
|
+
|
|
|
+ override def getInsertTitle(newMap: Map[String, String]): String = getValueOrNull(newMap("tm_name"), s"新增${newMap("tm_name")}商标")
|
|
|
+
|
|
|
+ override def getLabel(oldMap: Map[String, String], newMap: Map[String, String]): String = ChangeExtractUtils.get_ip_tags("商标", newMap("tm_name"), newMap("app_date"), newMap("reg_no"))
|
|
|
+
|
|
|
+ override def getBizTime(newMap: Map[String, String]): String = newMap("app_date")
|
|
|
+}
|
|
|
+
|
|
|
+//专利
|
|
|
+case class company_patent_list(equCols:Seq[String])extends CompanyChangeHandle{
|
|
|
+ override def getUpdateTitle(newMap: Map[String, String]): String = getValueOrNull(newMap("title"), s"${newMap("title")}专利发生变更")
|
|
|
+
|
|
|
+ override def getInsertTitle(newMap: Map[String, String]): String = getValueOrNull(newMap("title"), s"新增${newMap("title")}专利")
|
|
|
+
|
|
|
+ override def getLabel(oldMap: Map[String, String], newMap: Map[String, String]): String = ChangeExtractUtils.get_ip_tags("专利", newMap("title"), newMap("app_date"), newMap("app_number"))
|
|
|
+
|
|
|
+ override def getBizTime(newMap: Map[String, String]): String = newMap("app_date")
|
|
|
}
|