Ver código fonte

fix: 企业动态唯一id采用新md5

许家凯 4 anos atrás
pai
commit
77c242924a

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

@@ -5,7 +5,7 @@ import java.util.Date
 import com.winhc.bigdata.spark.config.EsConfig
 import com.winhc.bigdata.spark.utils.BaseUtil.isWindows
 import com.winhc.bigdata.spark.utils.ReflectUtils.getClazz
-import com.winhc.bigdata.spark.utils.{DateUtils, LoggingUtils, SparkUtils}
+import com.winhc.bigdata.spark.utils.{LoggingUtils, SparkUtils}
 import org.apache.commons.lang3.time.DateFormatUtils
 import org.apache.spark.internal.Logging
 import org.apache.spark.sql.types.StringType
@@ -21,6 +21,8 @@ import scala.collection.mutable
  * @Description: 企业动态
  */
 object CompanyDynamic {
+  val env = "dev"
+  val targetTab = "ads_company_dynamic"
 
   case class CompanyDynamicUtil(s: SparkSession,
                                 project: String, //表所在工程名
@@ -29,8 +31,6 @@ object CompanyDynamic {
                                ) extends LoggingUtils with Logging {
     @(transient@getter) val spark: SparkSession = s
 
-    private val env = "dev"
-    val targetTab = "ads_company_dynamic"
 
     def init(): Unit = {
       sql(
@@ -143,7 +143,7 @@ object CompanyDynamic {
           None
         }
         else {
-          result.map(res => Row(s"${res._1}-${res._8}-${DateUtils.toUnixTimestamp(date = res._6)}", res._1, res._2, res._3, res._4, res._5, res._6, res._7, res._8, res._9, res._10, DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss")))
+          result.map(res => Row(CompanyDynamicHandleUtils.getDynamicId(cid, res._4, res._7, res._8), res._1, res._2, res._3, res._4, res._5, res._6, res._7, res._8, res._9, res._10, DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss")))
         }
       })
 

+ 15 - 0
src/main/scala/com/winhc/bigdata/spark/jobs/dynamic/CompanyDynamicHandleUtils.scala

@@ -0,0 +1,15 @@
+package com.winhc.bigdata.spark.jobs.dynamic
+
+import cn.hutool.crypto.SecureUtil
+import com.winhc.bigdata.spark.utils.DateUtils
+
+/**
+ * @Author: XuJiakai
+ * @Date: 2020/8/11 14:15
+ * @Description:
+ */
+object CompanyDynamicHandleUtils {
+  def getDynamicId(cid: String, rta_desc: String, biz_id: String, change_time: String): String = {
+    s"$cid-${SecureUtil.md5(rta_desc + biz_id)}-${DateUtils.toUnixTimestamp(date = change_time)}"
+  }
+}