|
|
|
@ -0,0 +1,414 @@
|
|
|
|
|
package com.engine.junchuang.service;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateField;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
import com.engine.junchuang.entity.JclOrgMap;
|
|
|
|
|
import com.engine.junchuang.util.HasRightUtil;
|
|
|
|
|
import com.engine.junchuang.util.OrganizationDateUtil;
|
|
|
|
|
import com.engine.junchuang.util.db.DBType;
|
|
|
|
|
import com.engine.junchuang.util.db.MapperProxyFactory;
|
|
|
|
|
import com.engine.junchuang.util.detach.DetachUtil;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.xpath.operations.Bool;
|
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
public class OrgChartServiceImpl extends Service implements OrgChartService {
|
|
|
|
|
private RecordSet grs = new RecordSet();
|
|
|
|
|
private static final String COMPANY_RIGHT = "OrgChart:All";
|
|
|
|
|
private static final String USER_RIGHT = "OrgPerspective:All";
|
|
|
|
|
private final String level = getFieldName("职等");
|
|
|
|
|
private final String grade = getFieldName("职级");
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getOptionCondition(Map<String, Object> request2Map, User user) {
|
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
rs.executeQuery("select id, companyname from HrmCompanyVirtual order by id");
|
|
|
|
|
List<Map<String, Object>> fclasslist = new ArrayList<>();
|
|
|
|
|
Map<String, Object> defaultItem = new HashMap<>();
|
|
|
|
|
defaultItem.put("id", "0");
|
|
|
|
|
defaultItem.put("companyname", "行政维度");
|
|
|
|
|
fclasslist.add(defaultItem);
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
Map<String, Object> item = new HashMap<>();
|
|
|
|
|
item.put("id", rs.getString("id"));
|
|
|
|
|
item.put("companyname", rs.getString("companyname"));
|
|
|
|
|
fclasslist.add(item);
|
|
|
|
|
}
|
|
|
|
|
String sql = "select id, fnumber, fname, ftype from jcl_org_map where ftype in (0, 1) ";
|
|
|
|
|
|
|
|
|
|
// 分部分权过滤
|
|
|
|
|
DetachUtil detachUtil = new DetachUtil(user.getUID());
|
|
|
|
|
if (detachUtil.isDETACH()) {
|
|
|
|
|
String jclRoleLevels = detachUtil.getJclRoleLevels();
|
|
|
|
|
if (StringUtils.isNotBlank(jclRoleLevels)) {
|
|
|
|
|
sql = "select id, fnumber, fname, ftype from jcl_org_map where (ftype = 0 or (ftype = 1 and fobjid in(" + jclRoleLevels + "))) ";
|
|
|
|
|
} else {
|
|
|
|
|
sql = "select id, fnumber, fname, ftype from jcl_org_map where ftype = 0 ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
rs.executeQuery(sql + " and fdateend > " + DBType.get(new RecordSet().getDBType()).currentDate() + " order by ftype , id,fdateend desc ");
|
|
|
|
|
Set<OrgSelectItem> companySet = new HashSet<>();
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
OrgSelectItem item = new OrgSelectItem();
|
|
|
|
|
item.setId(rs.getString("id"));
|
|
|
|
|
item.setFnumber(rs.getString("fnumber"));
|
|
|
|
|
item.setFname(rs.getString("fname"));
|
|
|
|
|
companySet.add(item);
|
|
|
|
|
}
|
|
|
|
|
result.put("api_status", true);
|
|
|
|
|
result.put("fclasslist", fclasslist);
|
|
|
|
|
result.put("companylist", companySet);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getUserData(Map<String, Object> request2Map, User user) {
|
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
|
|
boolean hasRight = HasRightUtil.hasRight(user, USER_RIGHT, true);
|
|
|
|
|
result.put("hasRight", hasRight);
|
|
|
|
|
if (!hasRight) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
String root = (String) request2Map.get("root"); // 根节点
|
|
|
|
|
String level = (String) request2Map.get("level"); // 显示层级
|
|
|
|
|
if (StringUtils.isBlank(level)) {
|
|
|
|
|
level = "3";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String whereSql = userWhereSql(request2Map);
|
|
|
|
|
|
|
|
|
|
String whereItemSql = " ";
|
|
|
|
|
if ("0".equals(root)) { // 集团的情况
|
|
|
|
|
whereItemSql += " and t.ftype = 0 ";
|
|
|
|
|
} else {
|
|
|
|
|
whereItemSql += " and t.id = '" + root + "' ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取根节点
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
rs.executeQuery("select t.id, t.fname, t.ftype, t.fparentid, t.fleadername,t.fobjid,t.fecid, t.fleaderimg, t.fleaderjob, t.fplan, t.fonjob, t.fnumber, t.fleader, t.fleaderlv, t.fleaderst, t.fecid, t.fisvitual,this_dept from jcl_org_map t " + whereSql + whereItemSql);
|
|
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
|
|
|
String id = null;
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
Map<String, Object> item = new HashMap<>();
|
|
|
|
|
id = rs.getString("id");
|
|
|
|
|
item.put("id", rs.getString("id"));
|
|
|
|
|
item.put("fname", rs.getString("fname"));
|
|
|
|
|
item.put("ftype", rs.getString("ftype"));
|
|
|
|
|
item.put("parentId", null);
|
|
|
|
|
if ("0".equals(id)) {
|
|
|
|
|
item.put("fleadername", "");
|
|
|
|
|
item.put("fleaderimg", "");
|
|
|
|
|
item.put("fleaderjob", "");
|
|
|
|
|
item.put("fleader", "");
|
|
|
|
|
} else {
|
|
|
|
|
item.put("fleadername", rs.getString("fleadername"));
|
|
|
|
|
item.put("fleaderimg", rs.getString("fleaderimg"));
|
|
|
|
|
item.put("fleaderjob", rs.getString("fleaderjob"));
|
|
|
|
|
item.put("fleader", rs.getString("fleader"));
|
|
|
|
|
}
|
|
|
|
|
item.put("fplan", rs.getString("fplan"));
|
|
|
|
|
item.put("fonjob", rs.getString("fonjob"));
|
|
|
|
|
item.put("hasChildren", hasChildren(rs.getString("id"), false));
|
|
|
|
|
item.put("expand", "1");
|
|
|
|
|
item.put("fnumber", rs.getString("fnumber"));
|
|
|
|
|
item.put("fobjid", rs.getString("fobjid"));
|
|
|
|
|
//职等职级丢弃
|
|
|
|
|
// item.put("fleaderlv", convertLevel(rs.getString("fleaderlv")));
|
|
|
|
|
// item.put("fleaderst", convertGrade(rs.getString("fleaderst")));
|
|
|
|
|
item.put("fecid", rs.getString("fecid"));
|
|
|
|
|
item.put("fisvitual", rs.getString("fisvitual"));
|
|
|
|
|
item.put("this_dept",rs.getString("this_dept"));
|
|
|
|
|
list.add(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int currentLevel = 1;
|
|
|
|
|
findUserItemByParantId(id, currentLevel + 1, level, rs, list, whereSql, currentLevel + 1 <= Integer.parseInt(level));
|
|
|
|
|
|
|
|
|
|
// 分部数据,构建层级关系
|
|
|
|
|
reBuildTreeList(list, root);
|
|
|
|
|
|
|
|
|
|
result.put("api_status", true);
|
|
|
|
|
result.put("data", list);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> asyncUserData(Map<String, Object> request2Map, User user) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String syncOrgMapData(Map<String, Object> request2Map, User user) {
|
|
|
|
|
String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date());
|
|
|
|
|
java.sql.Date date = new java.sql.Date(OrganizationDateUtil.stringToDate(currentDate).getTime());
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
|
cal.setTime(date);
|
|
|
|
|
Calendar calendar = weaver.common.DateUtil.addDay(cal, -1);
|
|
|
|
|
java.sql.Date yesterday = new java.sql.Date(calendar.getTime().getTime());
|
|
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
// 1、清空当天所有数据
|
|
|
|
|
rs.execute("delete from jcl_org_map where fdatebegin = '"+date+"'");
|
|
|
|
|
// 2、修改所有失效数据
|
|
|
|
|
rs.execute("update jcl_org_map set fdateend='"+yesterday+"' where fdateend > '"+date+"'");
|
|
|
|
|
// 3、同步集团数据
|
|
|
|
|
String jtSql = "INSERT INTO jcl_org_map ( id, ftype, fobjid, uuid,fclass, fclassname, fnumber, fname,\n" +
|
|
|
|
|
" fleader, fleaderimg, fleadername, fleaderjobid, fleaderjob, fparentid,fobjparentid,\n" +
|
|
|
|
|
" fplan, fonjob, fisvitual, fdatebegin, fdateend)\n" +
|
|
|
|
|
" SELECT 0, 0, 0, uuid, 0, '行政维度', '00', companyname,\n" +
|
|
|
|
|
" 0, NULL, NULL, 0, NULL, -1, 0,\n" +
|
|
|
|
|
" 0, 0, 0, TO_DATE(to_char(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd'), TO_DATE('2099-12-31','yyyy-MM-dd') FROM hrmcompany";
|
|
|
|
|
rs.execute(jtSql);
|
|
|
|
|
// 4、同步分部数据
|
|
|
|
|
String fbSql = "insert into jcl_org_map\n" +
|
|
|
|
|
" (id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg,\n" +
|
|
|
|
|
" fleadername,fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid,\n" +
|
|
|
|
|
" fplan,fonjob,fisvitual,fdatebegin,fdateend)\n" +
|
|
|
|
|
" select a.id,1,a.id,a.uuid,0,'行政维度', '',a.subcompanyname,null,'',\n" +
|
|
|
|
|
" '',NULL,'','','',nvl(a.supsubcomid,0),nvl(a.supsubcomid,0),\n" +
|
|
|
|
|
" 0,0,0,TO_DATE(to_char(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd'), TO_DATE('2099-12-31','yyyy-MM-dd') from hrmsubcompany a\n" +
|
|
|
|
|
" where nvl(a.canceled,0) <> 1";
|
|
|
|
|
rs.execute(fbSql);
|
|
|
|
|
// 5、同步部门数据
|
|
|
|
|
String bmSql = "insert into jcl_org_map\n" +
|
|
|
|
|
"(id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg,\n" +
|
|
|
|
|
" fleadername,fleaderjobid,fleaderjob,fparentid,fobjparentid,\n" +
|
|
|
|
|
" fplan,fonjob,fisvitual,fdatebegin,fdateend)\n" +
|
|
|
|
|
"select a.id+100000000,2,a.id,a.uuid,0,'行政维度',a.DEPARTMENTCODE,a.departmentname,to_char(b.BMFZR),c.messagerurl,\n" +
|
|
|
|
|
" c.lastname,c.jobtitle,d.jobtitlemark,\n" +
|
|
|
|
|
" (case nvl(a.supdepid,0) when 0 then a.subcompanyid1 else a.supdepid+100000000 end),\n" +
|
|
|
|
|
" (case nvl(a.supdepid,0) when 0 then a.subcompanyid1 else a.supdepid end),\n" +
|
|
|
|
|
" 0,0,0,TO_DATE(to_char(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd'), TO_DATE('2099-12-31','yyyy-MM-dd')\n" +
|
|
|
|
|
"from HrmDepartment a\n" +
|
|
|
|
|
"left join hrmdepartmentdefined b on a.id=b.deptid\n" +
|
|
|
|
|
"left join hrmresource c on to_char(b.BMFZR)=to_char(c.ID)\n" +
|
|
|
|
|
"left join hrmjobtitles d on c.JOBTITLE=d.id\n" +
|
|
|
|
|
"where nvl(a.canceled,0) <> 1";
|
|
|
|
|
rs.execute(bmSql);
|
|
|
|
|
// 6、同步人员数据
|
|
|
|
|
String queryDept = "select id from hrmdepartment a where nvl(a.canceled,0)='0' ";
|
|
|
|
|
RecordSet recordSet = new RecordSet();
|
|
|
|
|
recordSet.execute(queryDept);
|
|
|
|
|
while (recordSet.next()){
|
|
|
|
|
String deptId = Util.null2String(recordSet.getString("id"));
|
|
|
|
|
// 找出没有下级的人员
|
|
|
|
|
String noHaveChildSql = "select a.id,a.managerid from hrmresource a\n" +
|
|
|
|
|
"inner join (select id from hrmresource\n" +
|
|
|
|
|
"MINUS \n" +
|
|
|
|
|
"select distinct(managerid) id from hrmresource) b on a.id=b.id\n" +
|
|
|
|
|
"and a.departmentid='"+deptId+"'";
|
|
|
|
|
rs.execute(noHaveChildSql);
|
|
|
|
|
while (rs.next()){
|
|
|
|
|
String id = Util.null2String(rs.getString("id"));
|
|
|
|
|
String managerid = Util.null2String(rs.getString("managerid"));
|
|
|
|
|
handleSuperior(id,managerid,deptId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return "同步成功";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Author ml
|
|
|
|
|
* @Date 2023/3/7 15:47
|
|
|
|
|
* @Description 处理上级
|
|
|
|
|
*/
|
|
|
|
|
private void handleSuperior(String id,String managerid,String deptId){
|
|
|
|
|
// 校验当前人员的直接上级是否在同一部门,如不在当前部门,map表中的上级应为部门id+
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
Boolean flag = checkManager(rs,managerid,deptId);
|
|
|
|
|
if (flag) {
|
|
|
|
|
rs.execute("insert into jcl_org_map\n" +
|
|
|
|
|
" (id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleaderimg,\n" +
|
|
|
|
|
" fleaderjobid,fleaderjob,fparentid,fobjparentid,\n" +
|
|
|
|
|
" fisvitual,fdatebegin,fdateend)\n" +
|
|
|
|
|
"select a.id+200000000,4,a.id,a.uuid,0,'行政维度',a.workcode,a.LASTNAME,a.messagerurl,\n" +
|
|
|
|
|
" b.id,b.jobtitlename, nvl( a.managerid, '' ) +200000000,a.managerid,\n" +
|
|
|
|
|
" 0,TO_DATE(to_char(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd'), TO_DATE('2099-12-31','yyyy-MM-dd')\n" +
|
|
|
|
|
"from hrmresource a\n" +
|
|
|
|
|
"left join hrmjobtitles b on a.jobtitle=b.id\n" +
|
|
|
|
|
"where a.status < 4 and a.id='"+id+"'");
|
|
|
|
|
// 找上级的上级
|
|
|
|
|
rs.execute("select id,managerid,departmentid from hrmresource where id='"+managerid+"'");
|
|
|
|
|
if (rs.next()){
|
|
|
|
|
String supId = Util.null2String(rs.getString("id"));
|
|
|
|
|
String supManagerId = Util.null2String(rs.getString("managerid"));
|
|
|
|
|
String departmentid = Util.null2String(rs.getString("departmentid"));
|
|
|
|
|
handleSuperior(supId,supManagerId,departmentid);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
rs.execute("insert into jcl_org_map\n" +
|
|
|
|
|
" (id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleaderimg,\n" +
|
|
|
|
|
" fleaderjobid,fleaderjob,fparentid,fobjparentid,\n" +
|
|
|
|
|
" fisvitual,fdatebegin,fdateend)\n" +
|
|
|
|
|
"select a.id+200000000,4,a.id,a.uuid,0,'行政维度',a.workcode,a.LASTNAME,a.messagerurl,\n" +
|
|
|
|
|
" b.id,b.jobtitlename, nvl( a.departmentid, '' ) +100000000,a.departmentid,\n" +
|
|
|
|
|
" 0,TO_DATE(to_char(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd'), TO_DATE('2099-12-31','yyyy-MM-dd')\n" +
|
|
|
|
|
"from hrmresource a\n" +
|
|
|
|
|
"left join hrmjobtitles b on a.jobtitle=b.id\n" +
|
|
|
|
|
"where a.status < 4 and a.id='"+id+"'");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Author ml
|
|
|
|
|
* @Date 2023/3/7 17:14
|
|
|
|
|
* @Description 校验上级是不在当前部门
|
|
|
|
|
*/
|
|
|
|
|
private Boolean checkManager(RecordSet recordSet,String managerid,String deptId){
|
|
|
|
|
Boolean flag = false;
|
|
|
|
|
recordSet.execute("select departmentid from hrmresource where id='"+managerid+"'");
|
|
|
|
|
if (recordSet.next()){
|
|
|
|
|
if (deptId.equals(Util.null2String(recordSet.getString("departmentid")))) {
|
|
|
|
|
flag = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String userWhereSql(Map<String, Object> request2Map) {
|
|
|
|
|
// 数据日期
|
|
|
|
|
String date = (String) request2Map.get("date");
|
|
|
|
|
if (StringUtils.isBlank(date)) {
|
|
|
|
|
date = DateUtil.format(DateUtil.offset(new Date(), DateField.DAY_OF_MONTH, 1), "yyyy-MM-dd");
|
|
|
|
|
}
|
|
|
|
|
// 维度
|
|
|
|
|
String fclass = (String) request2Map.get("fclass");
|
|
|
|
|
// 是否显示虚拟组织
|
|
|
|
|
String fisvitual = (String) request2Map.get("fisvitual");
|
|
|
|
|
if (StringUtils.isBlank(fisvitual)) {
|
|
|
|
|
fisvitual = "0";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String whereSql = " where 1 = 1 ";
|
|
|
|
|
if (DBType.isOracle()) {
|
|
|
|
|
whereSql += " and ((t.fdatebegin <= to_date('" + date + "','yyyy-MM-DD') and t.fdateend >= to_date('" + date + "','yyyy-MM-DD')) or (t.fdatebegin <= to_date('" + date + "','yyyy-MM-DD') and t.fdateend is null )) ";
|
|
|
|
|
} else {
|
|
|
|
|
whereSql += " and ((t.fdatebegin <= '" + date + "' and t.fdateend >= '" + date + "') or (t.fdatebegin <= '" + date + "' and t.fdateend is null )) ";
|
|
|
|
|
}
|
|
|
|
|
whereSql += " and t.fclass = " + fclass + " ";
|
|
|
|
|
|
|
|
|
|
if ("0".equals(fisvitual)) {
|
|
|
|
|
whereSql += " and t.fisvitual = 0 ";
|
|
|
|
|
} else {
|
|
|
|
|
whereSql += " and t.fisvitual in (0, 1) ";
|
|
|
|
|
}
|
|
|
|
|
return whereSql;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean hasChildren(String id, boolean isCompany) {
|
|
|
|
|
String whereSql = " where fparentid = " + id + " ";
|
|
|
|
|
if (isCompany) {
|
|
|
|
|
whereSql += " and ftype in (0, 1, 2) ";
|
|
|
|
|
}
|
|
|
|
|
grs.executeQuery("select count(1) as count from jcl_org_map " + whereSql);
|
|
|
|
|
String count = "0";
|
|
|
|
|
if (grs.next()) {
|
|
|
|
|
count = grs.getString("count");
|
|
|
|
|
}
|
|
|
|
|
return !"0".equals(count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getFieldName(String fieldabel) {
|
|
|
|
|
RecordSet recordSet = new RecordSet();
|
|
|
|
|
String fieldname = null;
|
|
|
|
|
recordSet.executeQuery("select fieldname from jcl_org_field where fieldlabel='" + fieldabel+"'");
|
|
|
|
|
if (recordSet.next()) {
|
|
|
|
|
fieldname = recordSet.getString("fieldname");
|
|
|
|
|
}
|
|
|
|
|
return fieldname;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void findUserItemByParantId(String id, int currentLevel, String level, RecordSet rs, List<Map<String, Object>> list, String whereSql, boolean expand) {
|
|
|
|
|
String sql = "select t.id, t.fname, t.ftype, t.fparentid, t.fobjparentid, t.fleader, t.fleadername, t.fleaderimg, t.fleaderjob, t.fplan, t.fonjob, t.fnumber, t.fobjid, t.fecid, t.fleaderlv, t.fleaderst, t.fisvitual, t.this_dept from jcl_org_map t " + whereSql;
|
|
|
|
|
DetachUtil detachUtil = new DetachUtil(user.getUID());
|
|
|
|
|
if (detachUtil.isDETACH()) {
|
|
|
|
|
if ("0".equals(id)) {
|
|
|
|
|
sql += " and t.ftype = 1 and t.fobjid in(" + detachUtil.getJclRoleLevels() + ")";
|
|
|
|
|
} else {
|
|
|
|
|
sql += " and t.fparentid = " + id + " and t.ftype !=1";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
sql += " and t.fparentid = " + id;
|
|
|
|
|
}
|
|
|
|
|
rs.executeQuery(sql);
|
|
|
|
|
List<Map<String, Object>> currentList = new ArrayList<>();
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
Map<String, Object> item = new HashMap<>();
|
|
|
|
|
item.put("id", rs.getString("id"));
|
|
|
|
|
item.put("fname", rs.getString("fname"));
|
|
|
|
|
item.put("ftype", rs.getString("ftype"));
|
|
|
|
|
item.put("parentId", rs.getString("fparentid"));
|
|
|
|
|
item.put("fobjparentId", rs.getString("fobjparentid"));
|
|
|
|
|
item.put("fplan", rs.getString("fplan"));
|
|
|
|
|
item.put("fonjob", rs.getString("fonjob"));
|
|
|
|
|
item.put("fnumber", rs.getString("fnumber"));
|
|
|
|
|
item.put("expand", expand ? "1" : "0");
|
|
|
|
|
item.put("fobjid", rs.getString("fobjid"));
|
|
|
|
|
item.put("fecid", rs.getString("fecid"));
|
|
|
|
|
if (rs.getString("ftype").equals("2")) {
|
|
|
|
|
//多个部门负责人
|
|
|
|
|
// JclOrgMap jclOrgMap = getBmfzrInfo(rs.getString("fleader"));
|
|
|
|
|
// item.put("fleader", jclOrgMap.getFLeader() == null ? "" : String.valueOf(jclOrgMap.getFLeader()));
|
|
|
|
|
// item.put("fleaderimg", jclOrgMap.getFLeaderImg());
|
|
|
|
|
// item.put("fleadername", jclOrgMap.getFLeaderName() == null ? "" : jclOrgMap.getFLeaderName());
|
|
|
|
|
// item.put("fleaderjob", jclOrgMap.getFLeaderJob());
|
|
|
|
|
// item.put("fleaderlv", convertLevel(rs.getString("fleaderlv")));
|
|
|
|
|
// item.put("fleaderst", convertGrade(rs.getString("fleaderst")));
|
|
|
|
|
} else {
|
|
|
|
|
item.put("fleader", rs.getString("fleader"));
|
|
|
|
|
item.put("fleaderimg", rs.getString("fleaderimg"));
|
|
|
|
|
item.put("fleadername", rs.getString("fleadername"));
|
|
|
|
|
item.put("fleaderjob", rs.getString("fleaderjob"));
|
|
|
|
|
// item.put("fleaderlv", convertLevel(rs.getString("fleaderlv")));
|
|
|
|
|
// item.put("fleaderst", convertGrade(rs.getString("fleaderst")));
|
|
|
|
|
}
|
|
|
|
|
item.put("fisvitual", rs.getString("fisvitual"));
|
|
|
|
|
item.put("this_dept", rs.getString("this_dept"));
|
|
|
|
|
item.put("hasChildren", hasChildren(rs.getString("id"), false));
|
|
|
|
|
currentList.add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void reBuildTreeList(List<Map<String, Object>> list, String root) {
|
|
|
|
|
// 分部数据,构建层级关系
|
|
|
|
|
Set<String> idSet = list.stream().filter(item -> "1".equals(Util.null2String(item.get("ftype")))).map(item -> Util.null2String(item.get("id"))).collect(Collectors.toSet());
|
|
|
|
|
list.forEach(item -> {
|
|
|
|
|
if (!root.equals(Util.null2String(item.get("id"))) && "1".equals(Util.null2String(item.get("ftype"))) && !idSet.contains(Util.null2String(item.get("parentId")))) {
|
|
|
|
|
item.put("parentId", root);
|
|
|
|
|
item.put("fobjparentId", root);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
static class OrgSelectItem {
|
|
|
|
|
private String id;
|
|
|
|
|
private String fnumber;
|
|
|
|
|
private String fname;
|
|
|
|
|
public String getId() {
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
public void setId(String id) {
|
|
|
|
|
this.id = id;
|
|
|
|
|
}
|
|
|
|
|
public String getFnumber() {
|
|
|
|
|
return fnumber;
|
|
|
|
|
}
|
|
|
|
|
public void setFnumber(String fnumber) {
|
|
|
|
|
this.fnumber = fnumber;
|
|
|
|
|
}
|
|
|
|
|
public String getFname() {
|
|
|
|
|
return fname;
|
|
|
|
|
}
|
|
|
|
|
public void setFname(String fname) {
|
|
|
|
|
this.fname = fname;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|