Merge branch 'main' of http://10.10.14.176:3000/huanghai/YunNanDsBase
commit
d35ef7c496
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,47 @@
|
||||
package com.dsideal.base.DataEase.Model;
|
||||
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ExcelReader {
|
||||
public List<ExcelRow> readXlsxFile(String filePath, List<String> cols) {
|
||||
List<ExcelRow> rows = new ArrayList<>();
|
||||
try (FileInputStream fis = new FileInputStream(filePath);
|
||||
Workbook workbook = new XSSFWorkbook(fis)) {
|
||||
|
||||
Sheet sheet = workbook.getSheetAt(0); // 读取第一个工作表
|
||||
int rowNum = 0;
|
||||
for (Row row : sheet) {
|
||||
List<String> rowData = new ArrayList<>();
|
||||
for (Cell cell : row) {
|
||||
rowData.add(getCellValue(cell));
|
||||
}
|
||||
if (rowNum == 0) {
|
||||
// 如果文件中没有列名,可以在这里手动指定
|
||||
rows.add(new ExcelRow(cols)); // 根据您的实际列名进行修改
|
||||
rowNum++;
|
||||
continue;
|
||||
}
|
||||
rows.add(new ExcelRow(rowData));
|
||||
rowNum++;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
private String getCellValue(Cell cell) {
|
||||
return switch (cell.getCellType()) {
|
||||
case STRING -> cell.getStringCellValue();
|
||||
case NUMERIC -> String.valueOf(cell.getNumericCellValue());
|
||||
case BOOLEAN -> String.valueOf(cell.getBooleanCellValue());
|
||||
case FORMULA -> cell.getCellFormula();
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.dsideal.base.DataEase.Model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class ExcelRow {
|
||||
private List<String> data;
|
||||
|
||||
public ExcelRow(List<String> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.dsideal.base.Tools;
|
||||
|
||||
import com.dsideal.base.DataEase.Model.DataEaseModel;
|
||||
import com.dsideal.base.Tools.Util.LocalMysqlConnectUtil;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import com.jfinal.kit.StrKit;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.Record;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class ChangUrlLink {
|
||||
|
||||
public static DataEaseModel dm = new DataEaseModel();
|
||||
|
||||
public static void main(String[] args) throws IOException, JSchException {
|
||||
LocalMysqlConnectUtil.Init();
|
||||
//原地址
|
||||
String sourceHost = "http://10.10.21.20:9000/dsBase/";
|
||||
//目标地址
|
||||
String targetHost = "https://www.edusoa.com/dsBase/";
|
||||
|
||||
String sql = "select * from visualization_link_jump_info";
|
||||
List<Record> list = Db.use(DataEaseModel.DB_NAME).find(sql);
|
||||
String prefix = "http://";
|
||||
for (Record record : list) {
|
||||
String content = record.getStr("content");
|
||||
long id = record.getLong("id");
|
||||
if (!StrKit.isBlank(content)
|
||||
//只有http的不要
|
||||
&& content.startsWith(prefix) && content.length() > prefix.length()) {
|
||||
System.out.println(content);
|
||||
//sql="update visualization_link_jump_info set content=? where id=?";
|
||||
//Db.use(DataEaseModel.DB_NAME).update(sql, content.replace(sourceHost, targetHost), id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package com.dsideal.base.Tools;
|
||||
|
||||
import com.dsideal.base.DataEase.Model.DataEaseModel;
|
||||
import com.dsideal.base.Tools.Util.SshConnectUtil;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import com.jcraft.jsch.Session;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.Record;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLOutput;
|
||||
import java.util.List;
|
||||
|
||||
public class ChangeUrlLink {
|
||||
public static DataEaseModel dm = new DataEaseModel();
|
||||
|
||||
public static void main(String[] args) throws IOException, JSchException {
|
||||
//通过ssh链接到Mysql数据库
|
||||
Session session = SshConnectUtil.Init();
|
||||
|
||||
String sql="select * from core_chart_view";
|
||||
List<Record> list = Db.use(DataEaseModel.DB_NAME).find(sql);
|
||||
for (Record record : list) {
|
||||
String custom_attr=record.getStr("custom_attr");
|
||||
if(custom_attr.contains("http://")){
|
||||
System.out.println("Found");
|
||||
}
|
||||
}
|
||||
//关闭Ssh链接
|
||||
session.disconnect();
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.dsideal.base.Tools;
|
||||
|
||||
import com.dsideal.base.DataEase.Model.DataEaseModel;
|
||||
import com.dsideal.base.Tools.Util.LocalMysqlConnectUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class DataSetInit {
|
||||
public static DataEaseModel dm = new DataEaseModel();
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
LocalMysqlConnectUtil.Init();
|
||||
//1、添加到数据集表中
|
||||
dm.collectDataSet();
|
||||
//2、加上主键
|
||||
dm.addPrimaryKey();
|
||||
//3、将所有非空列去掉不允许为空的限制
|
||||
dm.updateNotNullColumns();
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package com.dsideal.base.Tools;
|
||||
|
||||
import com.dsideal.base.DataEase.Model.DataEaseModel;
|
||||
import com.dsideal.base.Tools.Util.SshConnectUtil;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import com.jcraft.jsch.Session;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class InitDataEaseDataSet {
|
||||
public static DataEaseModel dm = new DataEaseModel();
|
||||
|
||||
public static void main(String[] args) throws IOException, JSchException {
|
||||
//通过ssh链接到Mysql数据库
|
||||
Session session = SshConnectUtil.Init();
|
||||
|
||||
//1、添加到数据集表中
|
||||
dm.collectDataSet();
|
||||
//2、加上主键
|
||||
dm.addPrimaryKey();
|
||||
//3、将所有非空列去掉不允许为空的限制
|
||||
dm.updateNotNullColumns();
|
||||
|
||||
//关闭数据库
|
||||
session.disconnect();
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.dsideal.base.Tools;
|
||||
package com.dsideal.base.Tools.Test;
|
||||
|
||||
import com.dsideal.base.DataEase.Model.DataEaseModel;
|
||||
import com.dsideal.base.Plugin.YamlProp;
|
@ -0,0 +1,52 @@
|
||||
package com.dsideal.base.Tools.Util;
|
||||
|
||||
import com.dsideal.base.DataEase.Model.DataEaseModel;
|
||||
import com.dsideal.base.Plugin.YamlProp;
|
||||
import com.dsideal.base.Tools.DataSetInit;
|
||||
import com.jfinal.kit.Prop;
|
||||
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
||||
import com.jfinal.plugin.activerecord.dialect.MysqlDialect;
|
||||
import com.jfinal.plugin.hikaricp.HikariCpPlugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class LocalMysqlConnectUtil {
|
||||
public static Prop PropKit;
|
||||
|
||||
public static void Init() {
|
||||
//加载配置文件
|
||||
String configFile = "application.yaml";
|
||||
PropKit = new YamlProp(configFile);
|
||||
|
||||
HikariCpPlugin masterPlugin = new HikariCpPlugin(PropKit.get("mysql.jdbcUrl"), PropKit.get("mysql.user"),
|
||||
PropKit.get("mysql.password").trim(), PropKit.get("mysql.driverClassName"));
|
||||
HikariCpPlugin dataEasePlugin = new HikariCpPlugin(PropKit.get("mysql.jdbcUrl").replace("ds_db", "dataease"), PropKit.get("mysql.user"),
|
||||
PropKit.get("mysql.password").trim(), PropKit.get("mysql.driverClassName"));
|
||||
|
||||
masterPlugin.start();
|
||||
|
||||
dataEasePlugin.start();
|
||||
|
||||
// 配置ActiveRecord插件
|
||||
ActiveRecordPlugin arp = new ActiveRecordPlugin(masterPlugin);
|
||||
arp.setDialect(new MysqlDialect());
|
||||
|
||||
ActiveRecordPlugin arpDataEase = new ActiveRecordPlugin(DataEaseModel.DB_NAME, dataEasePlugin);
|
||||
arpDataEase.setDialect(new MysqlDialect());
|
||||
|
||||
//遍历sql目录下所有的sql文件
|
||||
File sqlDir;
|
||||
String basePath = DataSetInit.class.getResource("/").getPath();
|
||||
sqlDir = new File(basePath + "/Sql");
|
||||
File[] sqlFiles = sqlDir.listFiles();
|
||||
for (File sqlFile : sqlFiles != null ? sqlFiles : new File[0]) {
|
||||
//只加载.sql文件
|
||||
if (sqlFile.getName().indexOf(".sql") > 0) {
|
||||
arp.addSqlTemplate("/Sql/" + sqlFile.getName());
|
||||
arpDataEase.addSqlTemplate("/Sql/" + sqlFile.getName());
|
||||
}
|
||||
}
|
||||
arp.start();
|
||||
arpDataEase.start();
|
||||
}
|
||||
}
|
Loading…
Reference in new issue