|
|
|
@ -0,0 +1,84 @@
|
|
|
|
|
package com.dsideal.base.Tools;
|
|
|
|
|
|
|
|
|
|
import com.dsideal.base.DataEase.Model.DataEaseModel;
|
|
|
|
|
import com.dsideal.base.Plugin.YamlProp;
|
|
|
|
|
import com.dsideal.base.Util.ExcelCommonUtil;
|
|
|
|
|
import com.jfinal.kit.Prop;
|
|
|
|
|
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
import com.jfinal.plugin.activerecord.dialect.MysqlDialect;
|
|
|
|
|
import com.jfinal.plugin.hikaricp.HikariCpPlugin;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class SelectNoXzqh {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws IOException {
|
|
|
|
|
//加载配置文件
|
|
|
|
|
String configFile = "application_dev.yaml";
|
|
|
|
|
Prop 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"));
|
|
|
|
|
masterPlugin.start();
|
|
|
|
|
|
|
|
|
|
HikariCpPlugin dataEasePlugin = new HikariCpPlugin(PropKit.get("mysql.jdbcUrl").replace("ds_db", DataEaseModel.DB_NAME), PropKit.get("mysql.user"),
|
|
|
|
|
PropKit.get("mysql.password").trim(), PropKit.get("mysql.driverClassName"));
|
|
|
|
|
dataEasePlugin.start();
|
|
|
|
|
|
|
|
|
|
// 配置ActiveRecord插件
|
|
|
|
|
ActiveRecordPlugin arp = new ActiveRecordPlugin("master", masterPlugin);
|
|
|
|
|
arp.setDialect(new MysqlDialect());
|
|
|
|
|
|
|
|
|
|
ActiveRecordPlugin arpDataEase = new ActiveRecordPlugin(DataEaseModel.DB_NAME, dataEasePlugin);
|
|
|
|
|
arpDataEase.setDialect(new MysqlDialect());
|
|
|
|
|
|
|
|
|
|
//遍历sql目录下所有的sql文件
|
|
|
|
|
File sqlDir;
|
|
|
|
|
String basePath = SelectNoXzqh.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();
|
|
|
|
|
|
|
|
|
|
DataEaseModel dm = new DataEaseModel();
|
|
|
|
|
|
|
|
|
|
//遍历所有的非省级管理员的,以excel_开头的表,找出这些表中是不是存在行政区划的列名
|
|
|
|
|
List<Record> list2 = dm.getDataSetByIdentityId(2);
|
|
|
|
|
List<Record> list3 = dm.getDataSetByIdentityId(3);
|
|
|
|
|
//开始检查
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
for (Record record : list2) {
|
|
|
|
|
String tableName = record.getStr("table_name");
|
|
|
|
|
//这张表中存在行政区划的列名,就跳过,不处理
|
|
|
|
|
if (!dm.hasXzqhColumn(tableName)) {
|
|
|
|
|
System.out.println("表:" + tableName + "没有行政区划的列名,请手动添加");
|
|
|
|
|
cnt++;
|
|
|
|
|
}
|
|
|
|
|
//否则提醒出来:当前表没有行政区划的列名,需要手动添加
|
|
|
|
|
}
|
|
|
|
|
System.out.println("市州数据集中,没有行政区划的表有" + cnt + "个");
|
|
|
|
|
System.out.println("===================================================================");
|
|
|
|
|
cnt = 0;
|
|
|
|
|
for (Record record : list3) {
|
|
|
|
|
String tableName = record.getStr("table_name");
|
|
|
|
|
//这张表中存在行政区划的列名,就跳过,不处理
|
|
|
|
|
if (!dm.hasXzqhColumn(tableName)) {
|
|
|
|
|
System.out.println("表:" + tableName + "没有行政区划的列名,请手动添加");
|
|
|
|
|
cnt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
System.out.println("县区数据集中,没有行政区划的表有" + cnt + "个");
|
|
|
|
|
}
|
|
|
|
|
}
|