|
@@ -125,13 +125,14 @@ public class ObjectRelationMigration extends MigrationAbstractServiceImpl<Object
|
|
@Override
|
|
@Override
|
|
public String migrateForSql(InstanceUrlParam context) {
|
|
public String migrateForSql(InstanceUrlParam context) {
|
|
StringBuffer sqls = new StringBuffer(" \n -- 数据迁移 dt_relation ------ \n");
|
|
StringBuffer sqls = new StringBuffer(" \n -- 数据迁移 dt_relation ------ \n");
|
|
|
|
+ sqls.append(" delete from dt_relation where project_id='"+context.getProjectId()+"' and group_code='"+context.getGroupCode()+"'; \n ");
|
|
//获取已经采集的数据
|
|
//获取已经采集的数据
|
|
String sqls_temp = "";
|
|
String sqls_temp = "";
|
|
ExecutorService service = getExcecutor();
|
|
ExecutorService service = getExcecutor();
|
|
- List<Future<StringBuffer>> futureList = new ArrayList<>();
|
|
|
|
|
|
+ List<Future<String>> futureList = new ArrayList<>();
|
|
for (MiGrationRelCode miGrationRelCode: MiGrationRelCode.values()){
|
|
for (MiGrationRelCode miGrationRelCode: MiGrationRelCode.values()){
|
|
QueryCriteria queryCriteria = getQueryCriteria(miGrationRelCode.getCode());
|
|
QueryCriteria queryCriteria = getQueryCriteria(miGrationRelCode.getCode());
|
|
- queryCriteria.setSize(10000L);
|
|
|
|
|
|
+ queryCriteria.setSize(MigrationConstant.BATCH_SQL_DATA_COUNT);
|
|
CommonResult<List<ObjectRelation>> admDatas = getAdmDataPage(context,queryCriteria);
|
|
CommonResult<List<ObjectRelation>> admDatas = getAdmDataPage(context,queryCriteria);
|
|
if (admDatas.getResult().equals(DmpResult.SUCCESS) && admDatas.getCount() > queryCriteria.getSize()) {
|
|
if (admDatas.getResult().equals(DmpResult.SUCCESS) && admDatas.getCount() > queryCriteria.getSize()) {
|
|
long pages = admDatas.getCount() / queryCriteria.getSize() + 1;
|
|
long pages = admDatas.getCount() / queryCriteria.getSize() + 1;
|
|
@@ -146,11 +147,11 @@ public class ObjectRelationMigration extends MigrationAbstractServiceImpl<Object
|
|
}
|
|
}
|
|
}
|
|
}
|
|
service.shutdown();
|
|
service.shutdown();
|
|
- for (Future<StringBuffer> future : futureList) {
|
|
|
|
|
|
+ for (Future<String> future : futureList) {
|
|
try {
|
|
try {
|
|
- StringBuffer stringBuffer = future.get();
|
|
|
|
- if(StrUtil.isNotEmpty(stringBuffer)){
|
|
|
|
- sqls_temp += stringBuffer.toString();
|
|
|
|
|
|
+ String string = future.get();
|
|
|
|
+ if(StrUtil.isNotEmpty(string)){
|
|
|
|
+ sqls_temp += string;
|
|
}
|
|
}
|
|
} catch (InterruptedException e) {
|
|
} catch (InterruptedException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -164,22 +165,18 @@ public class ObjectRelationMigration extends MigrationAbstractServiceImpl<Object
|
|
if(sqls_temp.length() == 0){
|
|
if(sqls_temp.length() == 0){
|
|
return "";
|
|
return "";
|
|
}
|
|
}
|
|
- sqls.append(MigrationConstant.DT_RELATION_SQL_PRE);
|
|
|
|
sqls.append(sqls_temp);
|
|
sqls.append(sqls_temp);
|
|
- String sql = sqls.toString();
|
|
|
|
- sql = sql.substring(0, sql.lastIndexOf(","));
|
|
|
|
- sql +=";";
|
|
|
|
- return sql;
|
|
|
|
|
|
+ return sqls.toString();
|
|
}
|
|
}
|
|
|
|
|
|
- private void appendValuesBefore(ExecutorService service, List<ObjectRelation> admData, List<Future<StringBuffer>> futureList){
|
|
|
|
|
|
+ private void appendValuesBefore(ExecutorService service, List<ObjectRelation> admData, List<Future<String>> futureList){
|
|
if(CollUtil.isEmpty(admData)){
|
|
if(CollUtil.isEmpty(admData)){
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
StringBuffer sqls_temp = new StringBuffer();
|
|
StringBuffer sqls_temp = new StringBuffer();
|
|
- Future<StringBuffer> future = service.submit(new Callable<StringBuffer>(){
|
|
|
|
|
|
+ Future<String> future = service.submit(new Callable<String>(){
|
|
@Override
|
|
@Override
|
|
- public StringBuffer call() throws Exception {
|
|
|
|
|
|
+ public String call() throws Exception {
|
|
return appendValues(admData, sqls_temp);
|
|
return appendValues(admData, sqls_temp);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -192,7 +189,7 @@ public class ObjectRelationMigration extends MigrationAbstractServiceImpl<Object
|
|
* @param sqls
|
|
* @param sqls
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private StringBuffer appendValues(List<ObjectRelation> admData, StringBuffer sqls){
|
|
|
|
|
|
+ private String appendValues(List<ObjectRelation> admData, StringBuffer sqls){
|
|
admData.forEach(relation -> {
|
|
admData.forEach(relation -> {
|
|
sqls.append("(");
|
|
sqls.append("(");
|
|
sqls.append("'").append(relation.getId()).append("',");
|
|
sqls.append("'").append(relation.getId()).append("',");
|
|
@@ -241,7 +238,11 @@ public class ObjectRelationMigration extends MigrationAbstractServiceImpl<Object
|
|
sqls.append(relation.getValid());
|
|
sqls.append(relation.getValid());
|
|
sqls.append(")\n ,");
|
|
sqls.append(")\n ,");
|
|
});
|
|
});
|
|
- return sqls;
|
|
|
|
|
|
+ String sql = "";
|
|
|
|
+ if(sqls.length() > 0){
|
|
|
|
+ sql = MigrationConstant.DT_RELATION_SQL_PRE + StrUtil.sub(sqls.toString(), 0 , -1) + "; \n ";
|
|
|
|
+ }
|
|
|
|
+ return sql;
|
|
}
|
|
}
|
|
private ExecutorService getExcecutor(){
|
|
private ExecutorService getExcecutor(){
|
|
ExecutorService service = new ThreadPoolExecutor(10, 15, 0L, TimeUnit.MILLISECONDS,
|
|
ExecutorService service = new ThreadPoolExecutor(10, 15, 0L, TimeUnit.MILLISECONDS,
|