|
|
|
@ -1,131 +0,0 @@
|
|
|
|
|
package Tools.Init;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import com.dsideal.dsBase.Util.CommonUtil;
|
|
|
|
|
import com.dsideal.dsBase.Util.PkUtil;
|
|
|
|
|
import com.jfinal.kit.PropKit;
|
|
|
|
|
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
|
|
|
|
import com.jfinal.plugin.activerecord.CaseInsensitiveContainerFactory;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
import com.jfinal.plugin.activerecord.dialect.PostgreSqlDialect;
|
|
|
|
|
import com.jfinal.plugin.hikaricp.HikariCpPlugin;
|
|
|
|
|
import com.jfinal.plugin.redis.RedisPlugin;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
public class addShiZhou {
|
|
|
|
|
|
|
|
|
|
//在独立的main函数中,使用下面的方式进行声明logback对象
|
|
|
|
|
private static Logger log = LoggerFactory.getLogger(addShiZhou.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
|
//写死的三个系统管理员
|
|
|
|
|
String[] arrManager = new String[3];
|
|
|
|
|
arrManager[0] = "9B28524B-7564-45BC-B1D4-156AC6306EC8";
|
|
|
|
|
arrManager[1] = "B6013DFC-5C95-4FD7-86CA-8B15D0CDFACF";
|
|
|
|
|
arrManager[2] = "101343CB-A6EA-452E-9A02-F0776288A912";
|
|
|
|
|
|
|
|
|
|
//告之配置文件位置
|
|
|
|
|
PropKit.use("application.properties");
|
|
|
|
|
//启动数据库
|
|
|
|
|
String user = PropKit.get("user");
|
|
|
|
|
String password = PropKit.get("password");
|
|
|
|
|
String jdbcUrl = PropKit.get("jdbcUrl");
|
|
|
|
|
HikariCpPlugin hp = new HikariCpPlugin(jdbcUrl, user, password);
|
|
|
|
|
hp.start();
|
|
|
|
|
// 配置ActiveRecord插件
|
|
|
|
|
ActiveRecordPlugin arp = new ActiveRecordPlugin(hp);
|
|
|
|
|
//配置默认小写
|
|
|
|
|
arp.setContainerFactory(new CaseInsensitiveContainerFactory(true));
|
|
|
|
|
//方言
|
|
|
|
|
arp.setDialect(new PostgreSqlDialect());
|
|
|
|
|
//应用系统
|
|
|
|
|
String basePath = "/Sql/";
|
|
|
|
|
arp.addSqlTemplate(basePath + "clearDataBase.sql");
|
|
|
|
|
arp.addSqlTemplate(basePath + "organization.sql");
|
|
|
|
|
arp.addSqlTemplate(basePath + "loginPerson.sql");
|
|
|
|
|
arp.start();
|
|
|
|
|
|
|
|
|
|
//安装地区
|
|
|
|
|
String sql = "select global_value from t_base_global where global_code='install_area'";
|
|
|
|
|
String InstallCityId = Db.findFirst(sql).getStr("global_value");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 用于缓存模块的redis服务
|
|
|
|
|
RedisPlugin redis = new RedisPlugin("myRedis", PropKit.get("redis_ip"), PropKit.getInt("redis_port"), 10 * 1000);
|
|
|
|
|
|
|
|
|
|
//启动redis组件
|
|
|
|
|
redis.start();
|
|
|
|
|
|
|
|
|
|
//初始化主键生成
|
|
|
|
|
PkUtil.InitOrgNumPk();
|
|
|
|
|
PkUtil.InitPersonNumPk();
|
|
|
|
|
|
|
|
|
|
//目标:根据行政区划,并且生成市管理员帐号
|
|
|
|
|
sql = Db.getSql("clearDataBase.getAreaByCityId");
|
|
|
|
|
List<Record> dt = Db.find(sql, InstallCityId);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < dt.size(); i++) {
|
|
|
|
|
String area_id = dt.get(i).getStr("id");
|
|
|
|
|
String city_id = dt.get(i).getStr("city_id");
|
|
|
|
|
String area_code = dt.get(i).getStr("area_code");
|
|
|
|
|
String area_name = dt.get(i).getStr("area_name");
|
|
|
|
|
if (area_code.equals("0")) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (city_id.equals(area_id)) {
|
|
|
|
|
//存入市管理员
|
|
|
|
|
generateUser(2, area_name + "管理员", InstallCityId, "-1", 1, arrManager[0], "-1");
|
|
|
|
|
} else //如果是区县,需要找到对就的省和市
|
|
|
|
|
{
|
|
|
|
|
log.info("当前:" + area_name);
|
|
|
|
|
generateUser(3, area_name + "管理员", InstallCityId, area_id, i + 1, arrManager[0], "-1");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
log.info("恭喜,所有工作成功完成!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:产生用户
|
|
|
|
|
* 作者:黄海
|
|
|
|
|
* 时间: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) {
|
|
|
|
|
Record record = new Record();
|
|
|
|
|
String person_id = UUID.randomUUID().toString().toUpperCase();
|
|
|
|
|
record.set("person_id", person_id);
|
|
|
|
|
record.set("identity_id", identity_id);
|
|
|
|
|
record.set("person_name", person_name);
|
|
|
|
|
long dentity_pk_num = PkUtil.GetPersonNumPk(identity_id, 1);
|
|
|
|
|
record.set("identity_pk_num", dentity_pk_num);
|
|
|
|
|
record.set("login_name", PkUtil.identityMap.get(identity_id) + dentity_pk_num);
|
|
|
|
|
String original_pwd = CommonUtil.getSixRandom();
|
|
|
|
|
String pwd = CommonUtil.getLdapPassword(original_pwd);
|
|
|
|
|
record.set("pwd", pwd);
|
|
|
|
|
record.set("pwdmd5", CommonUtil.md5(original_pwd));
|
|
|
|
|
record.set("b_use", 1);
|
|
|
|
|
Date now = DateUtil.date();
|
|
|
|
|
record.set("create_time", now);
|
|
|
|
|
record.set("sort_id", sort_id);
|
|
|
|
|
String idcard_code = "-1";
|
|
|
|
|
record.set("idcard_code", idcard_code);
|
|
|
|
|
record.set("original_pwd", original_pwd);
|
|
|
|
|
record.set("xb", 1);
|
|
|
|
|
record.set("mz", "01");
|
|
|
|
|
record.set("city_id", city_id);
|
|
|
|
|
record.set("area_id", area_id);
|
|
|
|
|
record.set("main_school_id", "-1");
|
|
|
|
|
record.set("bureau_id", "-1");
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|