|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package Tools.Init;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
import com.dsideal.dsBase.Start;
|
|
|
|
|
import com.dsideal.dsBase.Util.CommonUtil;
|
|
|
|
|
import com.dsideal.dsBase.Util.PkUtil;
|
|
|
|
|
import com.github.javafaker.DateAndTime;
|
|
|
|
@ -15,47 +16,48 @@ import com.jfinal.plugin.redis.RedisPlugin;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
public class clearDataBase {
|
|
|
|
|
|
|
|
|
|
//在独立的main函数中,使用下面的方式进行声明logback对象
|
|
|
|
|
private static Logger log = LoggerFactory.getLogger(clearDataBase.class);
|
|
|
|
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(clearDataBase.class);
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
|
//写死的一个系统管理员
|
|
|
|
|
String[] arrManager = new String[3];
|
|
|
|
|
arrManager[0] = "9B28524B-7564-45BC-B1D4-156AC6306EC8";
|
|
|
|
|
//告之配置文件位置
|
|
|
|
|
PropKit.use("application.properties");
|
|
|
|
|
//写死系统管理员
|
|
|
|
|
String arrManager = "9B28524B-7564-45BC-B1D4-156AC6306EC8";
|
|
|
|
|
|
|
|
|
|
//安装地区
|
|
|
|
|
String InstallCityId = "064BB3C9-E8DB-45ED-B0C1-6ABC5EA3B667";
|
|
|
|
|
String InstallCityId = "064BB3C9-E8DB-45ED-B0C1-6ABC5EA3B667";//长春市
|
|
|
|
|
//配置文件位置
|
|
|
|
|
PropKit.use("application.properties");
|
|
|
|
|
String user = PropKit.get("user");
|
|
|
|
|
String password = PropKit.get("password");
|
|
|
|
|
String jdbcUrl = PropKit.get("jdbcUrl");
|
|
|
|
|
DruidPlugin hp = new DruidPlugin(jdbcUrl, user, password);
|
|
|
|
|
hp.start();
|
|
|
|
|
DruidPlugin druidPlugin = new DruidPlugin(jdbcUrl, user, password);
|
|
|
|
|
druidPlugin.start();
|
|
|
|
|
|
|
|
|
|
// 配置ActiveRecord插件
|
|
|
|
|
ActiveRecordPlugin arp = new ActiveRecordPlugin(hp);
|
|
|
|
|
ActiveRecordPlugin arp = new ActiveRecordPlugin(druidPlugin);
|
|
|
|
|
//配置默认小写
|
|
|
|
|
arp.setContainerFactory(new CaseInsensitiveContainerFactory(true));
|
|
|
|
|
//方言
|
|
|
|
|
//方言,这个很重要,否则执行SQL会报错
|
|
|
|
|
arp.setDialect(new PostgreSqlDialect());
|
|
|
|
|
|
|
|
|
|
//应用系统
|
|
|
|
|
String basePath = "/Sql/";
|
|
|
|
|
arp.addSqlTemplate(basePath + "clearDataBase.sql");
|
|
|
|
|
arp.addSqlTemplate(basePath + "organization.sql");
|
|
|
|
|
arp.addSqlTemplate(basePath + "loginPerson.sql");
|
|
|
|
|
//应用系统Sql模板
|
|
|
|
|
String basePath = Start.class.getClassLoader().getResource(".").getPath();
|
|
|
|
|
File sqlDir = new File(basePath + "/Sql");
|
|
|
|
|
for (File sqlFile : Objects.requireNonNull(sqlDir.listFiles())) {
|
|
|
|
|
if (sqlFile.getName().indexOf(".sql") > 0) {
|
|
|
|
|
arp.addSqlTemplate("/Sql/" + sqlFile.getName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
arp.start();
|
|
|
|
|
|
|
|
|
|
// 用于缓存模块的redis服务
|
|
|
|
|
RedisPlugin redis = new RedisPlugin("myRedis", PropKit.get("redis_ip"), PropKit.getInt("redis_port"), 10 * 1000);
|
|
|
|
|
|
|
|
|
|
//启动redis组件
|
|
|
|
|
redis.start();
|
|
|
|
|
|
|
|
|
|
//清空组织机构表
|
|
|
|
@ -70,19 +72,17 @@ public class clearDataBase {
|
|
|
|
|
PkUtil.InitOrgNumPk();
|
|
|
|
|
PkUtil.InitPersonNumPk();
|
|
|
|
|
|
|
|
|
|
//修改global
|
|
|
|
|
//修改global中城市设置
|
|
|
|
|
String sql = Db.getSql("clearDataBase.set_install_area");
|
|
|
|
|
Db.update(sql, InstallCityId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("正在生成超级管理员帐号...");
|
|
|
|
|
//插入登录表的sql
|
|
|
|
|
for (int i = 0; i < arrManager.length; i++) {
|
|
|
|
|
generateUser(1, "系统管理员" + (i + 1), "-1", "-1", i + 1, arrManager[0],"-1");
|
|
|
|
|
}
|
|
|
|
|
generateUser(1, "系统管理员" , "-1", "-1", 1, arrManager, "-1");
|
|
|
|
|
//修正一下sys1的密码,配置开发用
|
|
|
|
|
sql = Db.getSql("clearDataBase.setPwd");
|
|
|
|
|
String original_pwd = "DsideaL4r5t6y7u";
|
|
|
|
|
String original_pwd = "DsideaL4r5t6y7u";//默认密码
|
|
|
|
|
String pwd = CommonUtil.getLdapPassword(original_pwd);
|
|
|
|
|
Db.update(sql, "******", pwd, CommonUtil.md5(original_pwd), "sys1");
|
|
|
|
|
|
|
|
|
@ -100,11 +100,11 @@ public class clearDataBase {
|
|
|
|
|
}
|
|
|
|
|
if (city_id.equals(area_id)) {
|
|
|
|
|
//存入市管理员
|
|
|
|
|
generateUser(2, area_name + "管理员", InstallCityId, "-1", 1, arrManager[0],"-1");
|
|
|
|
|
generateUser(2, area_name + "管理员", InstallCityId, "-1", 1, arrManager, "-1");
|
|
|
|
|
} else //如果是区县,需要找到对就的省和市
|
|
|
|
|
{
|
|
|
|
|
log.info("当前:" + area_name);
|
|
|
|
|
generateUser(3, area_name + "管理员", InstallCityId, area_id, i + 1, arrManager[0],"-1");
|
|
|
|
|
generateUser(3, area_name + "管理员", InstallCityId, area_id, i + 1, arrManager, "-1");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
log.info("恭喜,所有工作成功完成!");
|
|
|
|
@ -115,7 +115,7 @@ public class clearDataBase {
|
|
|
|
|
* 作者:黄海
|
|
|
|
|
* 时间:2018-12-21
|
|
|
|
|
*/
|
|
|
|
|
public static void generateUser(int identity_id, String person_name, String city_id, String area_id, int sort_id, String operator,String org_id) {
|
|
|
|
|
public static void generateUser(int identity_id, String person_name, String city_id, String area_id, int sort_id, String operator, String org_id) {
|
|
|
|
|
Record record = new Record();
|
|
|
|
|
String person_id = UUID.randomUUID().toString().toUpperCase();
|
|
|
|
|
record.set("person_id", person_id);
|
|
|
|
@ -143,7 +143,7 @@ public class clearDataBase {
|
|
|
|
|
record.set("org_id", org_id);
|
|
|
|
|
record.set("operator", operator);
|
|
|
|
|
record.set("ip_address", 2130706433); //127.0.0.1
|
|
|
|
|
Db.save("t_sys_loginperson","person_id", record);
|
|
|
|
|
Db.save("t_sys_loginperson", "person_id", record);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|