|
|
package com.dsideal.base.Tools;
|
|
|
|
|
|
import com.dsideal.base.Tools.Util.LocalMysqlConnectUtil;
|
|
|
import com.dsideal.base.Util.CommonUtil;
|
|
|
import com.dsideal.base.Util.PkUtil;
|
|
|
import com.dsideal.base.Plugin.YamlProp;
|
|
|
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.hikaricp.HikariCpPlugin;
|
|
|
import com.jfinal.plugin.redis.RedisPlugin;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
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 {
|
|
|
LocalMysqlConnectUtil.Init();
|
|
|
|
|
|
// 用于缓存模块的redis服务
|
|
|
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 adminId = "9B28524B-7564-45BC-B1D4-156AC6306EC8";
|
|
|
generateUser(1, "系统管理员", "110000", "110101", 1, adminId, "00000000");
|
|
|
//遍历所有云南省的市
|
|
|
String province_id = "FD61813E-70A1-42AB-9A8E-141ED4D47B98";
|
|
|
sql = "select * from t_dm_area where province_id=? and LEVEL_id=4 order by sort_id,area_code";
|
|
|
List<Record> cityList = Db.find(sql, province_id);
|
|
|
for (Record city : cityList) {
|
|
|
String city_id = city.getStr("id");
|
|
|
String city_name = city.getStr("area_name");
|
|
|
generateUser(2, city_name+"管理员", city_id, "", 2, city_id, city_id);
|
|
|
System.out.println("正在生成:" + city_name + "的管理员账号!");
|
|
|
//遍历所有市下的县
|
|
|
sql = "select * from t_dm_area where parent_id=? order by sort_id,area_code";
|
|
|
List<Record> countyList = Db.find(sql, city_id);
|
|
|
for (Record county : countyList) {
|
|
|
String county_id = county.getStr("id");
|
|
|
String county_name = county.getStr("area_name");
|
|
|
generateUser(3, county_name+"管理员", city_id, county_id, 3, county_id, county_id);
|
|
|
System.out.println("正在生成:" + county_name + "的管理员账号!");
|
|
|
}
|
|
|
}
|
|
|
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();
|
|
|
//超级管理员的使用固定的密码
|
|
|
if (identity_id == 1) {
|
|
|
original_pwd = "DsideaL4r5t6y7u";
|
|
|
}
|
|
|
String pwd = CommonUtil.getLdapPassword(original_pwd);
|
|
|
record.set("pwd", pwd);
|
|
|
record.set("pwdmd5", CommonUtil.md5(original_pwd));
|
|
|
record.set("b_use", 1);
|
|
|
record.set("create_time", CommonUtil.GetCurrentTimeString());
|
|
|
record.set("sort_id", sort_id);
|
|
|
//String idcard_code = MysqlAesUtil.Encrypt("-1");
|
|
|
record.set("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", org_id);
|
|
|
record.set("org_id", org_id);
|
|
|
record.set("operator", operator);
|
|
|
record.set("ip_address", 2130706433); //127.0.0.1
|
|
|
Db.save("t_sys_loginperson", record);
|
|
|
}
|
|
|
}
|
|
|
|