晏永年 4 years ago
parent
commit
45e3dd8714

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

@@ -96,11 +96,11 @@ object CompanyDynamic {
 //既需根据cid补全cname字段数据;还需在data字段中根据其中的cid添加对应cname数据
           case 2 =>
             s"""
-               |SELECT cid, ${colsExclusiveSome.mkString(",")},old_data, cname, str_to_map(replace(concat_ws(',',data),'},{',',')) AS data
+               |SELECT cid, ${colsExclusiveSome.mkString(",")},old_data, cname, STR_TO_MAP(regexp_replace(concat_ws(',',data),'[{"}]',''),',',':') AS data
                |FROM(
                |  SELECT new_cid AS cid, ${colsExclusiveSome.mkString(",")},to_json(old_data) AS old_data, COLLECT_SET(cname)[0] AS cname, COLLECT_SET(to_json(data)) AS data
                |  FROM(
-               |    SELECT new_cid, ${colsExclusiveSome.map("A." + _).mkString(",")}, A.cid, IF(A.data IS NULL, STR_TO_MAP(CONCAT('cname:',cname),',',':'), A.data) AS data, old_data, IF(A.new_cid=A.cid,B.cname,null) AS cname
+               |    SELECT new_cid, ${colsExclusiveSome.map("A." + _).mkString(",")}, A.cid, IF(A.data IS NULL, STR_TO_MAP(CONCAT('cname:',IF(cname IS NULL, '',cname)),',',':'), A.data) AS data, old_data, IF(A.new_cid=A.cid,B.cname,null) AS cname
                |    FROM(
                |      SELECT cid AS new_cid, cid, ${colsExclusiveSome.mkString(",")},data, old_data
                |      FROM(

+ 2 - 1
src/main/scala/com/winhc/bigdata/spark/jobs/dynamic/tables/company_bid_list.scala

@@ -63,7 +63,8 @@ case class company_bid_list() extends CompanyDynamicHandle {
    */
   override def handle(rowkey: String, bizDate: String, cid: String, change_fields: Seq[String], old_map: Map[String, String], new_map: Map[String, String], cname: String, suggestion: String): Seq[(String, String, String, String, String, String, String, String, String, String)] = {
     val proxyName = new_map("proxy")
-    if (proxyName != null && !proxyName.isEmpty && proxyName.equals(cname)) {
+    val oldCName = new_map("cname")
+    if (proxyName != null && !proxyName.isEmpty && proxyName.equals(oldCName)) {
       null
     }
     else {