Commit 49e012e1 authored by liaowenwu's avatar liaowenwu

修改bug

parent 61728f63
...@@ -109,7 +109,7 @@ public class AsyncMysqlDataTransferFunctionNew extends RichAsyncFunction<JSONObj ...@@ -109,7 +109,7 @@ public class AsyncMysqlDataTransferFunctionNew extends RichAsyncFunction<JSONObj
resultList.add(Tuple3.of(excueteSql,groupKey,ts)); resultList.add(Tuple3.of(excueteSql,groupKey,ts));
Boolean logEnable = MapUtil.getBool(dbInfoMap, "log_enable", false); Boolean logEnable = MapUtil.getBool(dbInfoMap, "log_enable", false);
if (logEnable){ if (logEnable){
String logSql = buildLogData(type, table, pkNameSet, dataObj, ts); String logSql = buildLogData(type, table, pkNameSet, dataObj, ts, value.toJSONString());
resultList.add(Tuple3.of(logSql,"dsc_cdc_log",ts)); resultList.add(Tuple3.of(logSql,"dsc_cdc_log",ts));
} }
resultFuture.complete(resultList); resultFuture.complete(resultList);
...@@ -121,16 +121,16 @@ public class AsyncMysqlDataTransferFunctionNew extends RichAsyncFunction<JSONObj ...@@ -121,16 +121,16 @@ public class AsyncMysqlDataTransferFunctionNew extends RichAsyncFunction<JSONObj
}); });
} }
private static String logSqlFormat = "INSERT INTO dsc_cdc_log (`table`,op_type,pk_columns,pk_values,cdc_ts) values ('%s','%s','%s','%s', %d)"; private static String logSqlFormat = "INSERT INTO dsc_cdc_log (`table`,op_type,pk_columns,pk_values,data_json,cdc_ts) values ('%s','%s','%s','%s','%s', %d)";
private String buildLogData(String type, String table, Set<String> pkNameSet, JSONObject dataObj, long ts) { private String buildLogData(String type, String table, Set<String> pkNameSet, JSONObject dataObj, long ts, String dataJsonStr) {
List<String> pkValueList = new ArrayList<>(); List<String> pkValueList = new ArrayList<>();
for (String pk : pkNameSet) { for (String pk : pkNameSet) {
pkValueList.add(dataObj.getString(pk)); pkValueList.add(dataObj.getString(pk));
} }
String pkColumns = String.join(",",pkNameSet); String pkColumns = String.join(",",pkNameSet);
String pkValues = String.join("-",pkValueList); String pkValues = String.join("-",pkValueList);
return String.format(logSqlFormat, table, type, pkColumns, pkValues, ts); return String.format(logSqlFormat, table, type, pkColumns, pkValues, dataJsonStr, ts);
} }
......
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