|
|
|
@ -22,6 +22,7 @@ public class InitOrgPerson {
|
|
|
|
|
//在独立的main函数中,使用下面的方式进行声明logback对象
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(InitOrgPerson.class);
|
|
|
|
|
public static Prop PropKit;
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
|
//告之配置文件位置
|
|
|
|
|
String configFile = "application_{?}.yaml".replace("{?}", getEnvPrefix());
|
|
|
|
@ -39,49 +40,47 @@ public class InitOrgPerson {
|
|
|
|
|
arp.start();
|
|
|
|
|
|
|
|
|
|
// 用于缓存模块的redis服务
|
|
|
|
|
RedisPlugin redis = new RedisPlugin("myRedis", PropKit.get("redis_ip"), PropKit.getInt("redis_port"), 10 * 1000);
|
|
|
|
|
RedisPlugin redis = new RedisPlugin("myRedis", PropKit.get("redis.ip"), PropKit.getInt("redis.port"), 10 * 1000);
|
|
|
|
|
|
|
|
|
|
//启动redis组件
|
|
|
|
|
redis.start();
|
|
|
|
|
|
|
|
|
|
// 清表
|
|
|
|
|
String sql = "truncate table t_base_class";
|
|
|
|
|
Db.update(sql);
|
|
|
|
|
|
|
|
|
|
sql = "truncate table t_base_organization";
|
|
|
|
|
Db.update(sql);
|
|
|
|
|
|
|
|
|
|
sql = "truncate table t_import_student_by_excel";
|
|
|
|
|
Db.update(sql);
|
|
|
|
|
|
|
|
|
|
sql = "truncate table t_import_teacher_by_excel";
|
|
|
|
|
Db.update(sql);
|
|
|
|
|
|
|
|
|
|
sql = "truncate table t_person_duty_charge";
|
|
|
|
|
Db.update(sql);
|
|
|
|
|
|
|
|
|
|
//人员表
|
|
|
|
|
sql = "truncate table t_sys_loginperson";
|
|
|
|
|
Db.update(sql);
|
|
|
|
|
|
|
|
|
|
//初始化主键生成
|
|
|
|
|
PkUtil.InitOrgNumPk();
|
|
|
|
|
PkUtil.InitPersonNumPk();
|
|
|
|
|
|
|
|
|
|
//找出所有单位
|
|
|
|
|
String sql = "select org_id,org_name,city_id,area_id,id_int from t_base_organization";
|
|
|
|
|
List<Record> list = Db.find(sql);
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
for (Record record : list) {
|
|
|
|
|
cnt++;
|
|
|
|
|
String uuid = UUID.randomUUID().toString().toUpperCase();
|
|
|
|
|
String sql2 = "update t_base_organization set org_id=?,bureau_id=? where id_int=?";
|
|
|
|
|
Db.update(sql2, uuid, record.getInt("id_int"),record.getInt("id_int"));
|
|
|
|
|
System.out.println("成功更新" + cnt + "个单位!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//写死的三个系统管理员
|
|
|
|
|
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";
|
|
|
|
|
|
|
|
|
|
//重新来过
|
|
|
|
|
list = Db.find(sql);
|
|
|
|
|
//插入登录表的sql
|
|
|
|
|
cnt = 0;
|
|
|
|
|
for (Record record : list) {
|
|
|
|
|
cnt++;
|
|
|
|
|
generateUser(4, record.getStr("org_name") + "管理员", record.getStr("city_id"), record.getStr("area_id"), cnt, arrManager[0], record.getStr("org_id"));
|
|
|
|
|
}
|
|
|
|
|
//写死的系统管理员
|
|
|
|
|
String adminId = "9B28524B-7564-45BC-B1D4-156AC6306EC8";
|
|
|
|
|
generateUser(1, "系统管理员", "110000", "110101", 1, adminId, "00000000");
|
|
|
|
|
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)
|
|
|
|
|
public static void generateUser(int identity_id, String person_name, String city_id, String area_id, int sort_id, String operator, String org_id)
|
|
|
|
|
throws Exception {
|
|
|
|
|
Record record = new Record();
|
|
|
|
|
String person_id = UUID.randomUUID().toString().toUpperCase();
|
|
|
|
@ -91,7 +90,12 @@ public class InitOrgPerson {
|
|
|
|
|
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();
|
|
|
|
|
//超级管理员的使用固定的密码
|
|
|
|
|
if (identity_id == 1) {
|
|
|
|
|
original_pwd = "DsideaL4r5t6y7u";
|
|
|
|
|
}
|
|
|
|
|
String pwd = CommonUtil.getLdapPassword(original_pwd);
|
|
|
|
|
record.set("pwd", pwd);
|
|
|
|
|
record.set("pwdmd5", CommonUtil.md5(original_pwd));
|
|
|
|
|