数据合并-湖分
管理端-湖分管理 通用模块-湖分
This commit is contained in:
@@ -15,11 +15,13 @@ public class DataMigrationUtil extends Thread {
|
||||
|
||||
Map map;
|
||||
int i;
|
||||
Connection yljkconn;
|
||||
Connection fzdsconn;
|
||||
|
||||
public DataMigrationUtil(Map map,int i,Connection fzdsconn){
|
||||
public DataMigrationUtil(Map map,int i,Connection yljkconn,Connection fzdsconn){
|
||||
this.map = map;
|
||||
this.i = i;
|
||||
this.yljkconn = yljkconn;
|
||||
this.fzdsconn = fzdsconn;
|
||||
}
|
||||
|
||||
@@ -29,8 +31,8 @@ public class DataMigrationUtil extends Thread {
|
||||
// courseCatalogue();
|
||||
// courseCatalogueChapter();
|
||||
// courseCatalogueChapterVideo();
|
||||
// user();//用的都是copy表里的数据
|
||||
//TRUNCATE
|
||||
user();//用的都是copy表里的数据
|
||||
// truncate();
|
||||
}
|
||||
|
||||
|
||||
@@ -337,7 +339,27 @@ public class DataMigrationUtil extends Thread {
|
||||
}
|
||||
}
|
||||
|
||||
public static void truncate(){
|
||||
try {
|
||||
Connection fzdsconn = DriverManager.getConnection(
|
||||
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/e_book_test?rewriteBatchedStatements=true",
|
||||
"nuttyreading", "Wu751019!");
|
||||
PreparedStatement statement = fzdsconn.prepareStatement("TRUNCATE table user_copy1;");
|
||||
statement.execute();
|
||||
PreparedStatement statement2 = fzdsconn.prepareStatement("TRUNCATE table user_vip_copy1;");
|
||||
statement2.execute();
|
||||
PreparedStatement statement3 = fzdsconn.prepareStatement("TRUNCATE table transaction_details_copy1;");
|
||||
statement3.execute();
|
||||
PreparedStatement statement4 = fzdsconn.prepareStatement("TRUNCATE table user_contribution;");
|
||||
statement4.execute();
|
||||
System.out.println("清空完成");
|
||||
}catch (SQLException e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void user(){
|
||||
truncate();
|
||||
try {
|
||||
long startTime = System.currentTimeMillis();
|
||||
Connection yljkconn = DriverManager.getConnection(
|
||||
@@ -362,15 +384,13 @@ public class DataMigrationUtil extends Thread {
|
||||
list.add(map);
|
||||
}
|
||||
resultSet.close();
|
||||
statement.close();
|
||||
yljkconn.close();
|
||||
Connection fzdsconn = DriverManager.getConnection(
|
||||
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/e_book_test?rewriteBatchedStatements=true",
|
||||
"nuttyreading", "Wu751019!");
|
||||
// 1、创建服务,创建线程池
|
||||
ExecutorService service = Executors.newFixedThreadPool(50);
|
||||
for (int i=0;i<list.size(); i++){
|
||||
DataMigrationUtil d1 = new DataMigrationUtil(list.get(i),i+1,fzdsconn);
|
||||
DataMigrationUtil d1 = new DataMigrationUtil(list.get(i),i+1,yljkconn,fzdsconn);
|
||||
service.execute(d1);
|
||||
}
|
||||
System.out.println("---开始");
|
||||
@@ -424,7 +444,7 @@ public class DataMigrationUtil extends Thread {
|
||||
//没有关联,直接导入
|
||||
PreparedStatement telInsertStatement = fzdsconn.prepareStatement(
|
||||
"INSERT ignore INTO user_copy1 (name,avatar,nickname,tel,vip,peanut_coin,jf,yljk_oid) " +
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)",PreparedStatement.RETURN_GENERATED_KEYS);
|
||||
telInsertStatement.setString(1,map.get("nameCN")==null?"":map.get("nameCN").toString());
|
||||
telInsertStatement.setString(2,map.get("icons")==null?"":map.get("icons").toString());
|
||||
telInsertStatement.setString(3,map.get("nickName")==null?"":map.get("nickName").toString());
|
||||
@@ -488,19 +508,32 @@ public class DataMigrationUtil extends Thread {
|
||||
jfTransactionDetailStatement.execute();
|
||||
jfTransactionDetailStatement.close();
|
||||
}
|
||||
|
||||
//湖分明细
|
||||
PreparedStatement contributionStatements = yljkconn.prepareStatement("" +
|
||||
"select * from t_customer_contribution where valid = 1 and customerOid = '"+map.get("oid")+"' ");
|
||||
ResultSet contributionResultSet = contributionStatements.executeQuery();
|
||||
if (contributionResultSet.next()){
|
||||
//添加湖分记录
|
||||
PreparedStatement contributionStatement = fzdsconn.prepareStatement(
|
||||
"INSERT ignore INTO user_contribution (user_id,score,detail,type,conversion_flag,create_time) " +
|
||||
"VALUES (?, ?, ?, ?, ?, ?)");
|
||||
contributionStatement.setString(1,userId);
|
||||
contributionStatement.setDouble(2,contributionResultSet.getDouble("score"));
|
||||
contributionStatement.setString(3,contributionResultSet.getString("detail"));
|
||||
contributionStatement.setString(4,contributionResultSet.getString("type"));
|
||||
contributionStatement.setInt(5,contributionResultSet.getInt("conversionFlg"));
|
||||
contributionStatement.setTimestamp(6,contributionResultSet.getTimestamp("createDate"));
|
||||
contributionStatement.execute();
|
||||
contributionStatement.close();
|
||||
}
|
||||
|
||||
}catch (Exception ee){
|
||||
|
||||
System.out.println(map.get("nameCN")+"--"+ee.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user