This commit is contained in:
default
2018-10-17 14:32:34 +08:00
parent ad5fcec365
commit 589f49d620
2 changed files with 4 additions and 4 deletions

View File

@@ -40,7 +40,7 @@ public class SyncSlaveToMasterThread implements Runnable{
+ syncDbInfo.get("database_name")+"?useUnicode=true&characterEncoding=utf-8&useOldAliasMetadataBehavior=true&rewriteBatchedStatements=true");
logger.info("当前分库数据库连接为"+url);
List<Record> find = Db.use(url.toString()).find("select * from table_sync_info");
logger.info("查询分库需要同步到主库的数据信息"+JSON.toJSONString(find));
//logger.info("查询分库需要同步到主库的数据信息"+JSON.toJSONString(find));
if (find != null && find.size() > 0) {
for (final Record record : find) {
// 循环同步数据标识
@@ -190,7 +190,7 @@ public class SyncSlaveToMasterThread implements Runnable{
if (updateDatas != null && updateDatas.size() > 0) {
if(record.getStr("table_name").equals("event_record_library")||record.getStr("table_name").equals("detection_info_new")) {
for(Record updateData:updateDatas) {
updateData.set("old_id",updateData.getLong("id"));
updateData.set("old_id",updateData.getLong(record.getStr("id_name")));
updateData.set("db_id", syncDbInfo.get("id"));
updateData.remove("id");
updateData.remove("sync_status");

View File

@@ -44,7 +44,7 @@ public class SyncThread implements Runnable {
logger.info("获取分库数据库连接信息"+url);
List<Record> find = Db.use("masterDataSource").find("select * from table_sync_info where db_id=? ",
syncDbInfo.get("id"));
logger.info("查询主库须向分库同步数据信息"+JSON.toJSONString(find));
//logger.info("查询主库须向分库同步数据信息"+JSON.toJSONString(find));
if (find != null && find.size() > 0) {
for (final Record record : find) {
// 循环同步数据标识
@@ -187,7 +187,7 @@ public class SyncThread implements Runnable {
if (updateDatas != null && updateDatas.size() > 0) {
if(record.getStr("table_name").equals("event_record_library")) {
for(Record updateData:updateDatas) {
updateData.set("old_id",updateData.getLong("id"));
updateData.set("old_id",updateData.getLong(record.getStr("id_name")));
updateData.set("db_id", -1);
updateData.remove("id");
updateData.remove("sync_status");