|
@@ -101,36 +101,18 @@ public class ObjectRelationMigration extends MigrationAbstractServiceImpl<Object
|
|
|
log.info("######################### dt_relation 同步开始 #########################");
|
|
|
long start = System.currentTimeMillis();
|
|
|
ExecutorService service = getExcecutor();
|
|
|
- List<SyncData> syncDataList = new ArrayList<>();
|
|
|
- List<Future<List<SyncData>>> list = new ArrayList<>();
|
|
|
|
|
|
for (MiGrationRelCode miGrationRelCode: MiGrationRelCode.values()){
|
|
|
log.info("######################### dt_relation "+miGrationRelCode.getCode()+"数据迁移开始 #########################");
|
|
|
|
|
|
- Future<List<SyncData>> future = service.submit(new Callable<List<SyncData>>(){
|
|
|
+ service.submit(new Runnable() {
|
|
|
@Override
|
|
|
- public List<SyncData> call() throws Exception {
|
|
|
- return startMigrateForLog(context, migrationInfo, miGrationRelCode.getCode());
|
|
|
+ public void run() {
|
|
|
+ startMigrateForLog(context, migrationInfo, miGrationRelCode.getCode());
|
|
|
}
|
|
|
});
|
|
|
- list.add(future);
|
|
|
}
|
|
|
service.shutdown();
|
|
|
- for (Future<List<SyncData>> future : list) {
|
|
|
- try {
|
|
|
- List<SyncData> syncDatas = future.get();
|
|
|
- if(CollUtil.isNotEmpty(syncDatas)){
|
|
|
- syncDataList.addAll(syncDatas);
|
|
|
- }
|
|
|
-
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- log.error("######################### dt_relation 数据迁移失败"+e.getMessage());
|
|
|
- } catch (ExecutionException e) {
|
|
|
- e.printStackTrace();
|
|
|
- log.error("######################### dt_relation 数据迁移失败"+e.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
long end = System.currentTimeMillis();
|
|
|
log.info("######################### dt_relation 同步结束 "+(end-start)+"#########################");
|
|
|
return AdmResponse.success();
|
|
@@ -146,15 +128,6 @@ public class ObjectRelationMigration extends MigrationAbstractServiceImpl<Object
|
|
|
public String migrateForSql(InstanceUrlParam context) {
|
|
|
StringBuffer sqls = new StringBuffer(" \n -- 数据迁移 dt_relation ------ \n");
|
|
|
//获取已经采集的数据
|
|
|
- /* StringBuffer sqls_temp = new StringBuffer();
|
|
|
- for (MiGrationRelCode miGrationRelCode: MiGrationRelCode.values()){
|
|
|
- QueryCriteria queryCriteria = getQueryCriteria(miGrationRelCode.getCode());
|
|
|
- List<ObjectRelation> admData = getAdmData(context,queryCriteria);
|
|
|
- if(CollUtil.isEmpty(admData)){
|
|
|
- continue;
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
String sqls_temp = "";
|
|
|
ExecutorService service = getExcecutor();
|
|
|
List<Future<StringBuffer>> futureList = new ArrayList<>();
|
|
@@ -345,9 +318,8 @@ public class ObjectRelationMigration extends MigrationAbstractServiceImpl<Object
|
|
|
return dataMigrationExcels;
|
|
|
}
|
|
|
|
|
|
- private List<SyncData> startMigrateForLog(InstanceUrlParam context, MigrationInfo migrationInfo, String code){
|
|
|
+ private void startMigrateForLog(InstanceUrlParam context, MigrationInfo migrationInfo, String code){
|
|
|
QueryCriteria queryCriteria = getQueryCriteria(code);
|
|
|
- List<SyncData> syncDataList = new ArrayList<>();
|
|
|
List<ObjectRelation> admRelations = getAdmData(context, queryCriteria);
|
|
|
|
|
|
String queryUrl = requestUrl(context, migrationInfo, MigrationType.QUERY.getCode());
|
|
@@ -359,7 +331,9 @@ public class ObjectRelationMigration extends MigrationAbstractServiceImpl<Object
|
|
|
String insertUrl = requestUrl(context, migrationInfo, MigrationType.CREATE.getCode());
|
|
|
if(CollUtil.isEmpty(projectRelations)){
|
|
|
DataMigrationResponse dataMigrationResponse = insertBatch(admRelations, ObjectRelation.class, insertUrl);
|
|
|
- syncDataList = processDataForLog(dataMigrationResponse, MigrationType.CREATE.getCode());
|
|
|
+ List<SyncData> syncDataList = processDataForLog(dataMigrationResponse, MigrationType.CREATE.getCode());
|
|
|
+ //处理并保存日志
|
|
|
+ super.addSynLog(context,syncDataList);
|
|
|
}
|
|
|
List<ObjectNode> objectNodeListPro = JsonNodeUtils.toListNode(projectRelations, null, null);
|
|
|
Map<String,Object> projectDefineMap = toEntityMap(objectNodeListPro, ObjectRelation.class);
|
|
@@ -371,7 +345,8 @@ public class ObjectRelationMigration extends MigrationAbstractServiceImpl<Object
|
|
|
if(!CollUtil.isEmpty(doSubtractFromInsert)){
|
|
|
List<ObjectRelation> insertData = toList(doSubtractFromInsert, admRelations);
|
|
|
DataMigrationResponse dataMigrationResponse = insertBatch(insertData, ObjectRelation.class, insertUrl);
|
|
|
- syncDataList.addAll(processDataForLog(dataMigrationResponse, MigrationType.CREATE.getCode()));
|
|
|
+ //处理并保存日志
|
|
|
+ super.addSynLog(context,processDataForLog(dataMigrationResponse, MigrationType.CREATE.getCode()));
|
|
|
}
|
|
|
|
|
|
//差集 删除
|
|
@@ -381,7 +356,8 @@ public class ObjectRelationMigration extends MigrationAbstractServiceImpl<Object
|
|
|
String delUrl = requestUrl(context, migrationInfo, MigrationType.DELETE.getCode());
|
|
|
//处理删除的数据
|
|
|
DataMigrationResponse dataMigrationResponse = deleteBatch(deleteIds, delUrl);
|
|
|
- syncDataList.addAll(processDataForLog(dataMigrationResponse, MigrationType.DELETE.getCode()));
|
|
|
+ //处理并保存日志
|
|
|
+ super.addSynLog(context,processDataForLog(dataMigrationResponse, MigrationType.DELETE.getCode()));
|
|
|
}
|
|
|
|
|
|
//交集更新
|
|
@@ -393,10 +369,10 @@ public class ObjectRelationMigration extends MigrationAbstractServiceImpl<Object
|
|
|
List<ObjectRelation> updateData = toList(compareData, admRelations);
|
|
|
String updateUrl = requestUrl(context, migrationInfo, MigrationType.UPDATE.getCode());
|
|
|
DataMigrationResponse dataMigrationResponse = updateBatch(updateData, ObjectRelation.class, updateUrl);
|
|
|
- syncDataList.addAll(processDataForLog(dataMigrationResponse, MigrationType.UPDATE.getCode()));
|
|
|
+ //处理并保存日志
|
|
|
+ super.addSynLog(context,processDataForLog(dataMigrationResponse, MigrationType.UPDATE.getCode()));
|
|
|
}
|
|
|
}
|
|
|
- return super.addSynLog(context, syncDataList);
|
|
|
}
|
|
|
|
|
|
|