//package org.springblade.dataextraction.kit;
//
//import java.io.IOException;
//import java.sql.Connection;
//import java.sql.DatabaseMetaData;
//import java.sql.DriverManager;
//import java.sql.ResultSet;
//import java.sql.SQLException;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Properties;
//
//import org.springblade.cube.enums.DbCreateTableEnum;
//import org.springblade.cube.enums.ViewColumnTypeEnum;
//import org.springblade.cube.model.FileStructure;
//
///**
// * 
// * @Desc 获取表结构生成sql语句
// * @Author William
// * @DateTime 2022 下午4:09:41
// */
//public class TableSqlGen {
//
//	private static Connection connection = null;
//	static {
//		try {
////			Class.forName("oracle.jdbc.OracleDriver");
////			String url = "jdbc:mysql://39.103.207.159:3306/digital_operation";
//			String url = "jdbc:oracle:thin:@10.0.17.108:8093/cs1747";
////			String url = "jdbc:clickhouse://39.103.133.74:8123/ads";
//			Properties prop = new Properties();
//			prop.put("user", "YYOS");
//			prop.put("password", "Mldsi3_hsyE9_8ekV_234dsLP");
//
////			prop.put("user", "digital");
////			prop.put("password", "Dgb6inMBYtsMT#rS");
//
////			prop.put("user", "default");
////			prop.put("password", "LiantongbiYidonghao66");
//
//			prop.put("serverTimezone", "GMT+8");
//			prop.put("remarks", "true");
//			prop.put("useInformationSchema", "true");
//			prop.put("remarksReporting", "true");
//			connection = DriverManager.getConnection(url, prop);
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//	}
//
//	/**
//	 * @param args
//	 * @throws IOException
//	 * @throws Exception
//	 */
//	public static void main(String[] args) throws IOException, Exception {
//		DatabaseMetaData metaData = connection.getMetaData();
////		ResultSet tables = metaData.getTables(null, "YYOS", "V_FCT_DATA_SLICE_L2", null);
////		while(tables.next()) {
////			System.out.println("表名:"+tables.getString("TABLE_NAME")+";表类型="+tables.getString("TABLE_TYPE")+";表注释="+tables.getString("REMARKS")+";EXT="+tables.getString("TABLE_SCHEM"));
////		}
//		ResultSet columns = metaData.getColumns(null, "YYOS", "FIN_ORDER_FETCH_TASK", null);
//		selectTable(columns);
//		// Statement statement = connection.createStatement();
////		ResultSet resultSet = statement.executeQuery("DESCRIBE TABLE ads.user_event");
////		while(resultSet.next()) {
////			System.out.println(resultSet.getString(1) +";"+resultSet.getString(2) +";"+resultSet.getString(5));
////		}
//	}
//
//	public static void selectTable(ResultSet columns) throws SQLException {
//		StringBuilder strBuilder = new StringBuilder("select ");
//		while (columns.next()) {
//			if ("varchar2".equalsIgnoreCase(columns.getString("TYPE_NAME"))) {
//				strBuilder.append("nvl(" + columns.getString("COLUMN_NAME") + ",''),\n");
//			} else {
//				strBuilder.append(columns.getString("COLUMN_NAME") + ",\n");
//			}
//		}
//		strBuilder.append("FROM FIN_ORDER_FETCH_TASK");
//		System.out.println(strBuilder.toString());
//	}
//
//	public static void createTable(ResultSet columns) throws SQLException {
//		List<FileStructure> structureList = new ArrayList<FileStructure>();
//		while (columns.next()) {
////			columnDto.setColumnSize(rs.getInt("COLUMN_SIZE"));
////			columnDto.setDecimalDigits(rs.getInt("DECIMAL_DIGITS"));
//			ViewColumnTypeEnum columnTypeEnum = ViewColumnTypeEnum.resolve(columns.getInt("DATA_TYPE"));
//			if ("NUMBER".equalsIgnoreCase(columns.getString("TYPE_NAME"))) { // && columns.getInt("DECIMAL_DIGITS") == 0
//				System.out.println("列名：" + columns.getString("COLUMN_NAME") + "；列注释：" + columns.getString("REMARKS")
//						+ "；列类型：" + columns.getString("TYPE_NAME") + "；列类型ID：" + columns.getInt("DATA_TYPE") + "；列宽度："
//						+ columns.getInt("COLUMN_SIZE") + "；列精度：" + columns.getInt("DECIMAL_DIGITS"));
//				columnTypeEnum = null;
//			}
//			structureList.add(new FileStructure(columns.getString("COLUMN_NAME"), columnTypeEnum,
//					columns.getString("REMARKS"), 1));
//		}
//		System.out.println("========================================================================");
//		List<String> sqlList = DbCreateTableEnum.Clickhouse.createTableSql("FCT_DATA_SLICE_L2", "视图-基础数据切片（二级）",
//				structureList);
//		System.out.println("SqlList: \n" + String.join("\n", sqlList));
//	}
//
//}
