|
|
|
@ -0,0 +1,116 @@
|
|
|
|
|
package com.dsideal.base.Tools;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
import static com.dsideal.base.BaseApplication.getEnvPrefix;
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
PropKit = new YamlProp(configFile);
|
|
|
|
|
|
|
|
|
|
HikariCpPlugin druid = new HikariCpPlugin(PropKit.get("mysql.jdbcUrl"), PropKit.get("mysql.user"),
|
|
|
|
|
PropKit.get("mysql.password").trim(), PropKit.get("mysql.driverClassName"));
|
|
|
|
|
druid.start();
|
|
|
|
|
// 配置ActiveRecord插件
|
|
|
|
|
ActiveRecordPlugin arp = new ActiveRecordPlugin(druid);
|
|
|
|
|
//应用系统
|
|
|
|
|
String basePath = "/Sql/";
|
|
|
|
|
arp.addSqlTemplate(basePath + "organization.sql");
|
|
|
|
|
arp.addSqlTemplate(basePath + "loginPerson.sql");
|
|
|
|
|
arp.start();
|
|
|
|
|
|
|
|
|
|
// 用于缓存模块的redis服务
|
|
|
|
|
RedisPlugin redis = new RedisPlugin("myRedis", PropKit.get("redis_ip"), PropKit.getInt("redis_port"), 10 * 1000);
|
|
|
|
|
|
|
|
|
|
//启动redis组件
|
|
|
|
|
redis.start();
|
|
|
|
|
|
|
|
|
|
//初始化主键生成
|
|
|
|
|
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"));
|
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
throws Exception {
|
|
|
|
|
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);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|