|
@@ -1,12 +1,14 @@
|
|
|
package com.lc.ibps.platform.plan.job;
|
|
package com.lc.ibps.platform.plan.job;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.lc.ibps.base.core.util.AppUtil;
|
|
import com.lc.ibps.base.core.util.AppUtil;
|
|
|
import com.lc.ibps.base.core.util.Collections;
|
|
import com.lc.ibps.base.core.util.Collections;
|
|
|
import com.lc.ibps.base.framework.id.UniqueIdUtil;
|
|
import com.lc.ibps.base.framework.id.UniqueIdUtil;
|
|
|
import com.lc.ibps.base.framework.table.ICommonDao;
|
|
import com.lc.ibps.base.framework.table.ICommonDao;
|
|
|
import com.lc.ibps.components.quartz.BaseJob2;
|
|
import com.lc.ibps.components.quartz.BaseJob2;
|
|
|
import org.apache.commons.lang3.BooleanUtils;
|
|
import org.apache.commons.lang3.BooleanUtils;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
+import org.apache.commons.lang3.RandomStringUtils;
|
|
|
import org.quartz.JobExecutionContext;
|
|
import org.quartz.JobExecutionContext;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -21,6 +23,22 @@ public class BasicDataInitializationJob extends BaseJob2 {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void executeJob(JobExecutionContext context) throws Exception {
|
|
public void executeJob(JobExecutionContext context) throws Exception {
|
|
|
|
|
+
|
|
|
|
|
+ //get admin position id.
|
|
|
|
|
+ String sql1 = "SELECT a.positions_ positions_,b.path_ path_ FROM ibps_party_employee a ,ibps_party_entity b WHERE a.id_=1 AND a.positions_=b.id_";
|
|
|
|
|
+ Map<String, Object> p = commonDao.queryOne(sql1);
|
|
|
|
|
+ if (p == null) return;
|
|
|
|
|
+ String posAdmin = (String) p.get("positions_");
|
|
|
|
|
+ String didianAdmin = ((String) p.get("path_")).split("\\.")[1];
|
|
|
|
|
+
|
|
|
|
|
+ //文件类型数据
|
|
|
|
|
+ executeWenJianStep(posAdmin,didianAdmin);
|
|
|
|
|
+
|
|
|
|
|
+ //其他的基础数据
|
|
|
|
|
+ executeBaseTablesStep(posAdmin);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void executeBaseTablesStep(String posAdmin) throws Exception {
|
|
|
//'Y' means just create one records. 注:所有字段均用大写
|
|
//'Y' means just create one records. 注:所有字段均用大写
|
|
|
// {"t_dyzzb", "", "N", "岗位职责配置列表"},
|
|
// {"t_dyzzb", "", "N", "岗位职责配置列表"},
|
|
|
String[][] tables = {
|
|
String[][] tables = {
|
|
@@ -42,11 +60,6 @@ public class BasicDataInitializationJob extends BaseJob2 {
|
|
|
{"t_txyxpzb", "t_txyxpzzb", "Y", "体系运行记录配置内容","PARENT_ID_", ""}
|
|
{"t_txyxpzb", "t_txyxpzzb", "Y", "体系运行记录配置内容","PARENT_ID_", ""}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- //get admin position id.
|
|
|
|
|
- String sql1 = "SELECT positions_ FROM ibps_party_employee WHERE id_=1";
|
|
|
|
|
- Map<String, Object> p = commonDao.queryOne(sql1);
|
|
|
|
|
- if (p == null) return;
|
|
|
|
|
- String posAdmin = (String) p.get("positions_");
|
|
|
|
|
|
|
|
|
|
for (String[] table : tables) {
|
|
for (String[] table : tables) {
|
|
|
String sql2 = "SELECT * FROM ibps_party_entity WHERE party_type_='position' AND depth_ IN (3,4) " +
|
|
String sql2 = "SELECT * FROM ibps_party_entity WHERE party_type_='position' AND depth_ IN (3,4) " +
|
|
@@ -99,10 +112,10 @@ public class BasicDataInitializationJob extends BaseJob2 {
|
|
|
String[] sublist = table[1].split(",");
|
|
String[] sublist = table[1].split(",");
|
|
|
if (sublist.length>1){
|
|
if (sublist.length>1){
|
|
|
for (String sub : sublist){
|
|
for (String sub : sublist){
|
|
|
- executeSub(table[0],sub,posAdmin,pId,newPID,deptId,didian,table[4]);
|
|
|
|
|
|
|
+ executeSub(table[0],sub, posAdmin,pId,newPID,deptId,didian,table[4]);
|
|
|
}
|
|
}
|
|
|
}else {
|
|
}else {
|
|
|
- executeSub(table[0],table[1],posAdmin,pId,newPID,deptId,didian,table[4]);
|
|
|
|
|
|
|
+ executeSub(table[0],table[1], posAdmin,pId,newPID,deptId,didian,table[4]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
logger.error(String.format("Done: %s: table:%s dept:%s",table[3],table[0],deptName));
|
|
logger.error(String.format("Done: %s: table:%s dept:%s",table[3],table[0],deptName));
|
|
@@ -111,6 +124,110 @@ public class BasicDataInitializationJob extends BaseJob2 {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void executeWenJianStep(String posAdmin, String didianAdmin) throws Exception {
|
|
|
|
|
+
|
|
|
|
|
+ String sql1 = "SELECT id_ FROM ibps_party_entity WHERE party_type_='position' AND depth_ = 2 AND path_ NOT LIKE '%%%s%%' " +
|
|
|
|
|
+ " AND NOT EXISTS (SELECT * FROM ibps_cat_type WHERE category_key_ ='FILE_TYPE' AND ibps_cat_type.AUTHORITY_NAME LIKE CONCAT('%%',ibps_party_entity.id_,'%%'))";
|
|
|
|
|
+ sql1 = String.format(sql1, posAdmin);
|
|
|
|
|
+ List<Map<String, Object>> l = (List<Map<String, Object>>) commonDao.query(sql1);
|
|
|
|
|
+ if (Collections.isEmpty(l)) return;
|
|
|
|
|
+ for (Map<String, Object> v : l) {
|
|
|
|
|
+ String id = (String) v.get("id_");
|
|
|
|
|
+ String sql2 = "SELECT * FROM ibps_party_entity WHERE party_type_='position' AND depth_ in (3, 4) AND path_ LIKE '%%%s%%' ORDER BY path_";
|
|
|
|
|
+ sql2 = String.format(sql2, id);
|
|
|
|
|
+ List<Map<String, Object>> list = (List<Map<String, Object>>) commonDao.query(sql2);
|
|
|
|
|
+
|
|
|
|
|
+ HashMap idPath = new HashMap<String,String>();
|
|
|
|
|
+ if (Collections.isEmpty(list)) return;
|
|
|
|
|
+ for (Map<String, Object> val1 : list) {
|
|
|
|
|
+ Map<String, Object> val = this.transformUpperCase(val1);
|
|
|
|
|
+
|
|
|
|
|
+ String deptName = (String) val.get("NAME_");
|
|
|
|
|
+ String[] path_s = ((String) val.get("PATH_")).split("\\.");
|
|
|
|
|
+ String didian = path_s[1];
|
|
|
|
|
+ int depth = (Integer) val.get("DEPTH_");
|
|
|
|
|
+
|
|
|
|
|
+ if(depth ==3){
|
|
|
|
|
+ createRootFileRecord(didian,path_s,idPath);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ createChildFileRecord(didian,path_s,idPath,deptName,didianAdmin);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void createChildFileRecord(String didian, String[] path_s, HashMap<String,String> idPath1, String deptName, String didianAdmin) throws Exception {
|
|
|
|
|
+ String sql2 = "SELECT * FROM ibps_cat_type WHERE category_key_ ='FILE_TYPE' AND depth_ =3 AND AUTHORITY_NAME LIKE '%%%s%%' ORDER BY path_";
|
|
|
|
|
+ List<Map<String, Object>> list = (List<Map<String, Object>>) commonDao.query(String.format(sql2, didianAdmin));
|
|
|
|
|
+ if (Collections.isEmpty(list)) return;
|
|
|
|
|
+ HashMap<String,String> idPath = new HashMap(idPath1);
|
|
|
|
|
+ for (Map<String, Object> val1 : list) {
|
|
|
|
|
+ Map<String, Object> val = this.transformUpperCase(val1);
|
|
|
|
|
+ String parentId = (String) val.get("PARENT_ID_");
|
|
|
|
|
+ if(!idPath.containsKey(parentId)){
|
|
|
|
|
+ Map root = new HashMap(val);
|
|
|
|
|
+ String path = (String) root.get("PATH_");
|
|
|
|
|
+
|
|
|
|
|
+ for (String key: idPath.keySet()) {
|
|
|
|
|
+ if(path.contains(key)){
|
|
|
|
|
+ root.put("NAME_",deptName);
|
|
|
|
|
+ root.put("DEPTH_",2);
|
|
|
|
|
+ idPath.put(parentId, idPath.get(key));
|
|
|
|
|
+
|
|
|
|
|
+ buildCatType(didian, idPath, root,path_s,true);
|
|
|
|
|
+ commonDao.execute(this.buildInsertSql(root, "ibps_cat_type"));
|
|
|
|
|
+ idPath.put(parentId, String.format("%s%s.", idPath.get(parentId), root.get("ID_")));
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ buildCatType(didian, idPath, val,path_s,true);
|
|
|
|
|
+ commonDao.execute(this.buildInsertSql(val, "ibps_cat_type"));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void createRootFileRecord(String didian, String[] path_s, HashMap<String,String> idPath) throws Exception {
|
|
|
|
|
+ String sql2 = "SELECT * FROM ibps_cat_type WHERE category_key_ ='FILE_TYPE' AND depth_ IN (1,2) AND name_ <>'专业组' ORDER BY path_";
|
|
|
|
|
+ List<Map<String, Object>> list = (List<Map<String, Object>>) commonDao.query(sql2);
|
|
|
|
|
+ if (Collections.isEmpty(list)) return;
|
|
|
|
|
+ for (Map<String, Object> val1 : list) {
|
|
|
|
|
+ Map<String, Object> val = this.transformUpperCase(val1);
|
|
|
|
|
+ buildCatType(didian, idPath, val, path_s, false);
|
|
|
|
|
+ commonDao.execute(this.buildInsertSql(val, "ibps_cat_type"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void buildCatType(String didian, HashMap<String, String> idPath, Map<String, Object> val, String[] path_s, boolean b) throws Exception {
|
|
|
|
|
+ String preId = (String) val.get("ID_");
|
|
|
|
|
+ String id = UniqueIdUtil.getId();
|
|
|
|
|
+ val.put("ID_", id);
|
|
|
|
|
+ val.put("CREATE_TIME_", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
|
|
+ val.put("UPDATE_TIME_", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
|
|
+ val.put("TYPE_KEY_",RandomStringUtils.randomAlphabetic(6));
|
|
|
|
|
+ String authorityName = (String) val.get("AUTHORITY_NAME");
|
|
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(authorityName);
|
|
|
|
|
+ jsonObject.set("diDian", didian);
|
|
|
|
|
+ if(b){
|
|
|
|
|
+ jsonObject.set("buMen",JSONUtil.createArray().set(path_s));
|
|
|
|
|
+ }
|
|
|
|
|
+ val.put("AUTHORITY_NAME",jsonObject.toString());
|
|
|
|
|
+ String parentId = (String) val.get("PARENT_ID_");
|
|
|
|
|
+ int depth = (Integer) val.get("DEPTH_");
|
|
|
|
|
+
|
|
|
|
|
+ if(depth == 1){
|
|
|
|
|
+ String s = String.format("%s.%s.", parentId, id);
|
|
|
|
|
+ val.put("PATH_", s);
|
|
|
|
|
+ idPath.put(preId, s);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ String p = idPath.get(parentId);
|
|
|
|
|
+ val.put("PARENT_ID_", p.split("\\.")[depth-1]);
|
|
|
|
|
+ val.put("PATH_", String.format("%s%s.", p, id));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void executeSub(String parentTbl,String subTbl,String posAdmin,String pId,String newPID,String deptId,String didian ,String foreignKey) throws Exception {
|
|
private void executeSub(String parentTbl,String subTbl,String posAdmin,String pId,String newPID,String deptId,String didian ,String foreignKey) throws Exception {
|
|
|
String sql4 = String.format("SELECT c.* FROM %s p , %s c WHERE c.%s = p.id_ AND p.bian_zhi_ren_=1 " +
|
|
String sql4 = String.format("SELECT c.* FROM %s p , %s c WHERE c.%s = p.id_ AND p.bian_zhi_ren_=1 " +
|
|
|
"AND p.bian_zhi_bu_men_='%s' AND c.%s='%s'", parentTbl, subTbl, foreignKey, posAdmin, foreignKey , pId);
|
|
"AND p.bian_zhi_bu_men_='%s' AND c.%s='%s'", parentTbl, subTbl, foreignKey, posAdmin, foreignKey , pId);
|