回溯组织架构图接口开发
This commit is contained in:
parent
8a2b024de7
commit
3191564961
|
|
@ -29,15 +29,10 @@ public class DanikorOrgChartManager {
|
|||
|
||||
private String sql = "";
|
||||
private String status = "";
|
||||
private String docStatus = "";
|
||||
private String customerType = "";
|
||||
private String customerStatus = "";
|
||||
private String workType = "";
|
||||
private String projectStatus = "";
|
||||
private HttpServletRequest request = null;
|
||||
private String cmd = "";
|
||||
private int labelIndex = -1;
|
||||
private Map params = null;
|
||||
private Map<String, Object> params = null;
|
||||
private String[] cg;
|
||||
private boolean isPOrg = false;
|
||||
private boolean isShow = false;
|
||||
|
|
@ -45,13 +40,13 @@ public class DanikorOrgChartManager {
|
|||
private String companyCountSql = "";
|
||||
private String subCompanyCountSql = "";
|
||||
private String departmentCountSql = "";
|
||||
private RecordSet rs = null;
|
||||
private final RecordSet rs;
|
||||
private String defaultHref = "";
|
||||
private List<MOrgChart> list = null;
|
||||
private final List<MOrgChart> list;
|
||||
private User user;
|
||||
private String subCompanyTabName = "";
|
||||
private String departmentTableName = "";
|
||||
private int shownum = 1;
|
||||
private int showNum = 1;
|
||||
OrgOperationUtil OrgOperationUtil;
|
||||
AppDetachComInfo adci = null;
|
||||
private Boolean useAppDetach;
|
||||
|
|
@ -71,7 +66,7 @@ public class DanikorOrgChartManager {
|
|||
OrgOperationUtil = new OrgOperationUtil();
|
||||
}
|
||||
|
||||
public void init(User user, HttpServletRequest request, Map map, String cg, boolean isPOrg, HrmCompanyVirtual cvBean, Map reqeustMap) {
|
||||
public void init(User user, HttpServletRequest request, Map<String, Object> map, String cg, boolean isPOrg, HrmCompanyVirtual cvBean, Map<String, Object> requestMap) {
|
||||
this.user = user;
|
||||
this.request = request;
|
||||
this.params = map;
|
||||
|
|
@ -84,34 +79,31 @@ public class DanikorOrgChartManager {
|
|||
isCurrentDate = false;
|
||||
syncSearchSql = " and sync_date ='" + syncDate + "'";
|
||||
}
|
||||
if (reqeustMap != null) {
|
||||
this.cmd = reqeustMap.containsKey("cmd") ? StringUtil.vString(reqeustMap.get("cmd")) : "";
|
||||
sorgid = reqeustMap.containsKey("sorgid") ? StringUtil.vString(reqeustMap.get("sorgid")) : "1";
|
||||
if (requestMap != null) {
|
||||
this.cmd = requestMap.containsKey("cmd") ? StringUtil.vString(requestMap.get("cmd")) : "";
|
||||
sorgid = requestMap.containsKey("sorgid") ? StringUtil.vString(requestMap.get("sorgid")) : "1";
|
||||
}
|
||||
this.cg = StringUtil.vString(cg).split(";");
|
||||
this.isPOrg = isPOrg;
|
||||
this.defaultHref = weaver.general.GCONST.getContextPath() + "/spa/hrm/index_mobx.html#/main/hrm/orgStaff?_fromURL=HrmResourceSearchResult&from=hrmorg&virtualtype=" + sorgid + "&departmentid={param}";
|
||||
this.cvBean = cvBean;
|
||||
|
||||
checkAppInfo(user);
|
||||
checkAppInfo();
|
||||
initParams();
|
||||
initLabelIndex();
|
||||
initCountSql();
|
||||
|
||||
this.subCompanyTabName = this.isCurrentDate ? "hrmsubcompany" : "hrmsubcompany_back";
|
||||
String appointCompanySql = this.isPOrg ? "" : ("t.companyid = " + cvBean.getId() + " and ");
|
||||
String supcompanyConditionSql = " and tlevel <= " + this.shownum;
|
||||
boolean isMysql = false;
|
||||
if (DialectUtil.isMySql(rs.getDBType())) {
|
||||
isMysql = true;
|
||||
}
|
||||
String supcompanyConditionSql = " and tlevel <= " + this.showNum;
|
||||
boolean isMysql = DialectUtil.isMySql(rs.getDBType());
|
||||
String hasnextsql = this.getHasNextBySubCompanySql(isMysql);
|
||||
this.sql = "select t.id,t.subcompanyname,t.supsubcomid,(" + this.subCompanyCountSql + (getDetachSql("").equals("") ? "" : " and " + getDetachSql("")) + syncSearchSql + ")," +
|
||||
this.sql = "select t.id,t.subcompanyname,t.supsubcomid,(" + this.subCompanyCountSql + (getDetachSql("").equals("") ? "" : " and " + getDetachSql("")) + ")," +
|
||||
"(select COUNT(id) from " + subCompanyTabName + " where supsubcomid = t.id " + syncSearchSql + ") as supCount" +
|
||||
hasnextsql + ",t.tlevel from " + subCompanyTabName + " t where " + appointCompanySql + "(t.canceled IS NULL OR t.canceled !='1') and t.id != t.supsubcomid " + (this.cg.length > 0 ? StringUtil.vString(this.cg[0]) : "") + supcompanyConditionSql + syncSearchSql + " order by t.supsubcomid,t.showorder,t.subcompanyname";
|
||||
this.rs.executeSql(this.sql);
|
||||
this.rs.execute(this.sql);
|
||||
rs.writeLog("init:" + this.sql);
|
||||
MOrgChart bean = null;
|
||||
MOrgChart bean;
|
||||
while (this.rs.next()) {
|
||||
int subHasNext = this.rs.getInt(6);
|
||||
int deptHasNext = this.rs.getInt(7);
|
||||
|
|
@ -122,7 +114,7 @@ public class DanikorOrgChartManager {
|
|||
bean.setCount(this.rs.getInt(4));
|
||||
bean.setSubCount(this.rs.getInt(5));
|
||||
bean.setHasNext((subHasNext == 1) || (deptHasNext == 1));
|
||||
bean.setNeedPlus((this.rs.getInt(8) == this.shownum) && ((subHasNext == 1) || (deptHasNext == 1)));
|
||||
bean.setNeedPlus((this.rs.getInt(8) == this.showNum) && ((subHasNext == 1) || (deptHasNext == 1)));
|
||||
this.list.add(bean);
|
||||
|
||||
}
|
||||
|
|
@ -140,17 +132,17 @@ public class DanikorOrgChartManager {
|
|||
return detachSql;
|
||||
}
|
||||
|
||||
private void checkAppInfo(User user) {
|
||||
private void checkAppInfo() {
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeSql("select appdetachable from SystemSet");
|
||||
rs.execute("select appdetachable from SystemSet");
|
||||
if (rs.next() && rs.getString("appdetachable") != null && "1".equals(rs.getString("appdetachable"))) {
|
||||
useAppDetach = Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
public String getData(String pid) {
|
||||
StringBuffer data = new StringBuffer("");
|
||||
MOrgChart bean = null;
|
||||
public String getData() {
|
||||
StringBuilder data = new StringBuilder();
|
||||
MOrgChart bean;
|
||||
String cTitle = SystemEnv.getHtmlLabelNames(this.labelIndex + ",523", user.getLanguage());
|
||||
String initSubSql = initSubCompanyCountSql();
|
||||
String sorgid = StringUtil.vString(this.request.getParameter("sorgid"));
|
||||
|
|
@ -164,15 +156,12 @@ public class DanikorOrgChartManager {
|
|||
}
|
||||
}
|
||||
rs.writeLog("getData:list:" + list);
|
||||
for (int i = 0; i < this.list.size(); i++) {
|
||||
bean = (MOrgChart) this.list.get(i);
|
||||
for (MOrgChart mOrgChart : this.list) {
|
||||
bean = mOrgChart;
|
||||
|
||||
boolean flag = true;
|
||||
if (!adci.isNotCheckUserAppDetach()) {
|
||||
flag = false;
|
||||
if (allowsubcompany.contains(bean.getId())) {
|
||||
flag = true;
|
||||
}
|
||||
flag = allowsubcompany.contains(bean.getId());
|
||||
|
||||
if (!flag && allowsubcompanyview.contains(bean.getId())) {
|
||||
flag = true;
|
||||
|
|
@ -180,10 +169,9 @@ public class DanikorOrgChartManager {
|
|||
}
|
||||
if (!flag) continue;
|
||||
int showCount = bean.getCount();
|
||||
String showTitle = "";
|
||||
|
||||
if (bean.getSubCount() != 0 && isShow) {
|
||||
Map map = getAllSubCompanyId(bean.getId(), initSubSql + (getDetachSql("").equals("") ? "" : " and " + getDetachSql("")));
|
||||
Map<String, String> map = getAllSubCompanyId(bean.getId(), initSubSql + (getDetachSql("").equals("") ? "" : " and " + getDetachSql("")));
|
||||
if (map.containsKey("idCount")) {
|
||||
String idCount = StringUtil.vString(map.get("idCount"));
|
||||
if (idCount.length() > 0) {
|
||||
|
|
@ -192,21 +180,20 @@ public class DanikorOrgChartManager {
|
|||
}
|
||||
}
|
||||
|
||||
showTitle = bean.getName() + cTitle + showCount;
|
||||
String showTitle = bean.getName() + cTitle + showCount;
|
||||
boolean hasNext = bean.isHasNext();
|
||||
StringBuffer str = new StringBuffer();
|
||||
str.append(",")
|
||||
.append("{\"id\":\"").append(bean.getId())
|
||||
.append("\", \"pid\":\"").append(bean.getSubId())
|
||||
.append("\", \"type\":\"subcompany\", \"name\":\"")
|
||||
.append(StringUtil.vString(StringUtil.toScreen(Util.formatMultiLang(bean.getName(), "" + user.getLanguage())), 12))
|
||||
.append("\", \"title\":\"").append(bean.getName())
|
||||
.append("\", \"num\":\"").append(showCount)
|
||||
.append("\", \"nTitle\":\"").append(showTitle)
|
||||
.append("\", \"hasChild\":\"").append("" + hasNext)
|
||||
.append("\", \"needPlus\":\"").append("" + bean.isNeedPlus())
|
||||
.append("\", \"cOnclick\":\"").append(StringUtil.replace(tmpdefaultHref, "{param}", bean.getId()))
|
||||
.append("\", \"oDisplay\":\"none\", \"subRCount\":\"0\", \"subTitle\":\"\"}");
|
||||
String str = "," +
|
||||
"{\"id\":\"" + bean.getId() +
|
||||
"\", \"pid\":\"" + bean.getSubId() +
|
||||
"\", \"type\":\"subcompany\", \"name\":\"" +
|
||||
StringUtil.vString(StringUtil.toScreen(Util.formatMultiLang(bean.getName(), "" + user.getLanguage())), 12) +
|
||||
"\", \"title\":\"" + bean.getName() +
|
||||
"\", \"num\":\"" + showCount +
|
||||
"\", \"nTitle\":\"" + showTitle +
|
||||
"\", \"hasChild\":\"" + hasNext +
|
||||
"\", \"needPlus\":\"" + bean.isNeedPlus() +
|
||||
"\", \"cOnclick\":\"" + StringUtil.replace(tmpdefaultHref, "{param}", bean.getId()) +
|
||||
"\", \"oDisplay\":\"none\", \"subRCount\":\"0\", \"subTitle\":\"\"}";
|
||||
data.append(str);
|
||||
}
|
||||
data.append(appendDepartment());
|
||||
|
|
@ -216,8 +203,8 @@ public class DanikorOrgChartManager {
|
|||
private String appendDepartment() {
|
||||
this.departmentTableName = this.isCurrentDate ? "hrmdepartment" : "hrmdepartment_back";
|
||||
String appendSql = this.isPOrg ? "" : ("and subcompanyid1 in (select id from hrmsubcompanyVirtual t where t.companyid = " + this.cvBean.getId() + ")");
|
||||
appendSql += " and tlevel <= " + this.shownum;
|
||||
String checkSupdepid = " t.id != t.supdepid ";
|
||||
appendSql += " and tlevel <= " + this.showNum;
|
||||
String checkSupdepid;
|
||||
boolean isMysql = false;
|
||||
//对于supdepid为空的情况 增加判断
|
||||
if ("oracle".equalsIgnoreCase(this.rs.getDBType())) {
|
||||
|
|
@ -230,13 +217,14 @@ public class DanikorOrgChartManager {
|
|||
}
|
||||
String hasNextSql = this.getHasNextBySubDeptSql(isMysql);
|
||||
this.sql = "select t.id,t.departmentname,t.subcompanyid1," +
|
||||
"(" + this.departmentCountSql + (getDetachSql("").equals("") ? "" : " and" + getDetachSql("")) + "),t.supdepid,(select COUNT(id) from " + departmentTableName + " where supdepid = t.id) as supCount," +
|
||||
"(" + this.departmentCountSql + (getDetachSql("").equals("") ? "" : " and" + getDetachSql("")) + "),t.supdepid,(select COUNT(id) from " + departmentTableName + " where supdepid = t.id " + syncSearchSql + ") as supCount," +
|
||||
"(case when t.supdepid != 0 and (select COUNT(id) from " + departmentTableName + " where id = t.supdepid)=0 then 0 else 1 end) as isExist" +
|
||||
hasNextSql + ",t.tlevel from " + departmentTableName + " t where " + checkSupdepid + appendSql + " and (t.canceled IS NULL OR t.canceled !='1') and (t.canceled IS NULL OR t.canceled !='1') order by t.subcompanyid1 asc , t.supdepid asc , t.showorder asc, t.departmentname asc";
|
||||
this.rs.executeSql(this.sql);
|
||||
hasNextSql + ",t.tlevel from " + departmentTableName + " t where " + checkSupdepid + appendSql + " and (t.canceled IS NULL OR t.canceled !='1') and (t.canceled IS NULL OR t.canceled !='1') " + syncSearchSql + " order by t.subcompanyid1 asc , t.supdepid asc , t.showorder asc, t.departmentname asc";
|
||||
this.rs.execute(this.sql);
|
||||
System.err.println(sql);
|
||||
rs.writeLog("appendDepartment:this.sql:" + this.sql);
|
||||
List<MOrgChart> dList = new ArrayList<MOrgChart>();
|
||||
MOrgChart bean = null;
|
||||
List<MOrgChart> dList = new ArrayList<>();
|
||||
MOrgChart bean;
|
||||
if (useAppDetach) {
|
||||
try {
|
||||
this.allowsubcompany = adci.getAlllowsubcompany();//能查看的分部
|
||||
|
|
@ -255,10 +243,7 @@ public class DanikorOrgChartManager {
|
|||
String subcompanyid1 = this.rs.getString(3);
|
||||
boolean flag = true;
|
||||
if (!adci.isNotCheckUserAppDetach()) {
|
||||
flag = false;
|
||||
if (allowdepartment.contains(id)) {
|
||||
flag = true;
|
||||
}
|
||||
flag = allowdepartment.contains(id);
|
||||
|
||||
if (!flag && allowdepartmentview.contains(id)) {
|
||||
flag = true;
|
||||
|
|
@ -275,25 +260,25 @@ public class DanikorOrgChartManager {
|
|||
bean.setCount(this.rs.getInt(4));
|
||||
bean.setSubCount(this.rs.getInt(6));
|
||||
bean.setHasNext(this.rs.getInt(8) == 1);
|
||||
bean.setNeedPlus((this.rs.getInt(9) == this.shownum) && this.rs.getInt(8) == 1);
|
||||
bean.setNeedPlus((this.rs.getInt(9) == this.showNum) && this.rs.getInt(8) == 1);
|
||||
if (this.rs.getInt(7) == 0) {
|
||||
continue;
|
||||
}
|
||||
dList.add(bean);
|
||||
}
|
||||
StringBuffer data = new StringBuffer();
|
||||
StringBuilder data = new StringBuilder();
|
||||
String cTitle = SystemEnv.getHtmlLabelNames("21837," + (this.labelIndex == 179 ? 1867 : this.labelIndex), user.getLanguage());
|
||||
String sTitle = SystemEnv.getHtmlLabelNames("33864,17587," + (this.labelIndex == 179 ? 1867 : this.labelIndex), user.getLanguage());
|
||||
String initSubSql = initSubDepartmentCountSql();
|
||||
for (MOrgChart m : dList) {
|
||||
String showTitle = "";
|
||||
String showTitle;
|
||||
String allSubId = "";
|
||||
boolean isShowSubCount = false;
|
||||
int subRCount = m.getCount();
|
||||
|
||||
showTitle = cTitle + m.getCount();
|
||||
if (m.getSubCount() != 0 && isShow) {
|
||||
Map map = getAllSubDepartId(m.getId(), initSubSql + (getDetachSql("").equals("") ? "" : " and " + getDetachSql("")));
|
||||
Map<String, String> map = getAllSubDepartId(m.getId(), initSubSql + (getDetachSql("").equals("") ? "" : " and " + getDetachSql("")));
|
||||
if (map.containsKey("idCount") && map.containsKey("ids")) {
|
||||
String idCount = StringUtil.vString(map.get("idCount"));
|
||||
allSubId = StringUtil.vString(map.get("ids"));
|
||||
|
|
@ -305,24 +290,22 @@ public class DanikorOrgChartManager {
|
|||
}
|
||||
String subTitle = sTitle + subRCount;
|
||||
boolean hasNext = m.isHasNext();
|
||||
StringBuffer str = new StringBuffer();
|
||||
str.append(",")
|
||||
.append("{\"id\":\"d").append(m.getId())
|
||||
.append("\", \"pid\":\"").append(m.getSubId())
|
||||
.append("\", \"type\":\"dept\", \"name\":\"")
|
||||
.append(StringUtil.vString(StringUtil.toScreen(Util.formatMultiLang(m.getName(), "" + user.getLanguage())), 12))
|
||||
.append("\", \"title\":\"").append(m.getName())
|
||||
.append("\", \"num\":\"").append(m.getCount())
|
||||
.append("\", \"nTitle\":\"").append(showTitle)
|
||||
.append("\", \"oDisplay\":\"").append(isShowSubCount ? "" : "none")
|
||||
.append("\", \"subRCount\":\"").append(subRCount)
|
||||
.append("\", \"subTitle\":\"").append(subTitle)
|
||||
.append("\", \"hasChild\":\"").append("" + hasNext)
|
||||
.append("\", \"needPlus\":\"").append("" + m.isNeedPlus())
|
||||
.append("\", \"cOnclick\":\"").append(StringUtil.replace(this.defaultHref, "{param}", m.getId()))
|
||||
.append("\", \"sOnclick\":\"").append(isShowSubCount ? StringUtil.replace(this.defaultHref, "{param}", m.getId() + "," + allSubId) : "").append("\"}");
|
||||
// .append("\"}");
|
||||
data.append(str.toString());
|
||||
String str = "," +
|
||||
"{\"id\":\"d" + m.getId() +
|
||||
"\", \"pid\":\"" + m.getSubId() +
|
||||
"\", \"type\":\"dept\", \"name\":\"" +
|
||||
StringUtil.vString(StringUtil.toScreen(Util.formatMultiLang(m.getName(), "" + user.getLanguage())), 12) +
|
||||
"\", \"title\":\"" + m.getName() +
|
||||
"\", \"num\":\"" + m.getCount() +
|
||||
"\", \"nTitle\":\"" + showTitle +
|
||||
"\", \"oDisplay\":\"" + (isShowSubCount ? "" : "none") +
|
||||
"\", \"subRCount\":\"" + subRCount +
|
||||
"\", \"subTitle\":\"" + subTitle +
|
||||
"\", \"hasChild\":\"" + "" + hasNext +
|
||||
"\", \"needPlus\":\"" + "" + m.isNeedPlus() +
|
||||
"\", \"cOnclick\":\"" + StringUtil.replace(this.defaultHref, "{param}", m.getId()) +
|
||||
"\", \"sOnclick\":\"" + (isShowSubCount ? StringUtil.replace(this.defaultHref, "{param}", m.getId() + "," + allSubId) : "") + "\"}";
|
||||
data.append(str);
|
||||
}
|
||||
return data.toString();
|
||||
}
|
||||
|
|
@ -336,7 +319,6 @@ public class DanikorOrgChartManager {
|
|||
*/
|
||||
private String getHasNextBySubCompanySql(boolean isMysql) {
|
||||
this.subCompanyTabName = this.isCurrentDate ? "hrmsubcompany" : "hrmsubcompany_back";
|
||||
;
|
||||
this.departmentTableName = this.isCurrentDate ? "HrmDepartment" : "HrmDepartment_back";
|
||||
String subsql = ",(select distinct 1 as hasnext from " + subCompanyTabName + " s where (s.supsubcomid=t.id and (s.CANCELED IS NULL OR s.CANCELED !='1')) ) as hassubnext";
|
||||
String deptsql = ",(select distinct 1 as hasnext from " + departmentTableName + " d where (d.subcompanyid1=t.id and (d.CANCELED IS NULL OR d.CANCELED !='1')) ) as hasdeptnext";
|
||||
|
|
@ -355,28 +337,35 @@ public class DanikorOrgChartManager {
|
|||
* @return
|
||||
*/
|
||||
private String getHasNextBySubDeptSql(boolean isMysql) {
|
||||
this.departmentTableName = this.isPOrg ? "HrmDepartment" : "HrmDepartmentVirtual";
|
||||
String sql = ",(select distinct 1 as hasnext from " + departmentTableName + " d where d.supdepid=t.id and (CANCELED IS NULL OR CANCELED !='1')) as hasnext";
|
||||
String whereSql;
|
||||
if (isCurrentDate) {
|
||||
departmentTableName = "hrmdepartment";
|
||||
whereSql = "where d.supdepid=t.id and (CANCELED IS NULL OR CANCELED !='1')";
|
||||
} else {
|
||||
departmentTableName = "hrmdepartment_back";
|
||||
whereSql = "where d.supdepid=t.id and (CANCELED IS NULL OR CANCELED !='1')" + syncSearchSql;
|
||||
}
|
||||
String sql = ",(select distinct 1 as hasnext from " + departmentTableName + " d " + whereSql + ") as hasnext";
|
||||
if (isMysql) {
|
||||
//8.0版本的mysql distinct 1 的时候会出现多条数据
|
||||
sql = ",(select distinct if(d.supdepid is null,null,1) as hasnext from " + departmentTableName + " d where d.supdepid=t.id and (CANCELED IS NULL OR CANCELED !='1')) as hasnext";
|
||||
sql = ",(select distinct if(d.supdepid is null,null,1) as hasnext from " + departmentTableName + " d " + whereSql + ") as hasnext";
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
private Map getAllSubCompanyId(String arg0, String arg1) {
|
||||
private Map<String, String> getAllSubCompanyId(String arg0, String arg1) {
|
||||
return getSubId(arg0, this.subCompanyTabName, "SUPSUBCOMID", arg1);
|
||||
}
|
||||
|
||||
private Map getAllSubDepartId(String arg0, String arg1) {
|
||||
private Map<String, String> getAllSubDepartId(String arg0, String arg1) {
|
||||
return getSubId(arg0, this.departmentTableName, "SUPDEPID", arg1);
|
||||
}
|
||||
|
||||
private Map getSubId(String arg0, String arg1, String arg2, String arg4) {
|
||||
StringBuffer arg5 = new StringBuffer("SELECT a.ID FROM allSub a LEFT JOIN ")
|
||||
private Map<String, String> getSubId(String arg0, String arg1, String arg2, String arg4) {
|
||||
StringBuilder arg5 = new StringBuilder("SELECT a.ID FROM allSub a LEFT JOIN ")
|
||||
.append(arg1).append(" b ON a.ID = b.ID WHERE (b.CANCELED IS NULL OR b.CANCELED !='1')");
|
||||
|
||||
StringBuffer ids = new StringBuffer();
|
||||
StringBuilder ids = new StringBuilder();
|
||||
|
||||
StringBuffer sql = new StringBuffer();
|
||||
if ("oracle".equals(rs.getDBType())) {
|
||||
|
|
@ -387,7 +376,7 @@ public class DanikorOrgChartManager {
|
|||
TableSelfRelationBean bean = new TableSelfRelationBean(TableSelfRelationStyle.findByTableName(arg1.trim()));
|
||||
bean.setLastSqlWhere(" and (CANCELED IS NULL OR CANCELED !='1') ");
|
||||
bean.setOutFiled("id");
|
||||
arg5 = new StringBuffer(arg5.toString().replace("allSub", "( " + DbDialectFactory.get(rs.getDBType()).getSelfRelactionSql(bean, arg0) + " )"));
|
||||
arg5 = new StringBuilder(arg5.toString().replace("allSub", "( " + DbDialectFactory.get(rs.getDBType()).getSelfRelactionSql(bean, arg0) + " )"));
|
||||
} else if ("postgresql".equals(rs.getDBType())) {
|
||||
sql.append(" WITH RECURSIVE allSub AS ( SELECT ID FROM ");
|
||||
sql.append(arg1).append(" WHERE ID = ").append(arg0).append(" UNION ALL SELECT a.ID FROM ").append(arg1)
|
||||
|
|
@ -401,9 +390,9 @@ public class DanikorOrgChartManager {
|
|||
}
|
||||
sql.append("select a.idCount,b.id from (").append(StringUtil.replace(arg4, "{ids}", arg5.toString())).append(") a, (").append(arg5.toString()).append(") b ");
|
||||
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeSql(sql.toString());
|
||||
rs.execute(sql.toString());
|
||||
String idCount = "";
|
||||
while (rs.next()) {
|
||||
if (idCount.length() == 0) idCount = StringUtil.vString(rs.getString(1));
|
||||
|
|
@ -418,24 +407,9 @@ public class DanikorOrgChartManager {
|
|||
if (this.params == null || this.params.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (StringUtil.isNull(this.cmd)) {
|
||||
this.status = StringUtil.vString(params.get("status"));
|
||||
this.status = (StringUtil.isNull(status) || status.equals("8")) ? "0,1,2,3" : status;
|
||||
this.status = this.status.equals("9") ? "" : (" and status in (" + this.status + ") ");
|
||||
} else if (this.cmd.equals("doc")) {
|
||||
this.docStatus = StringUtil.vString(params.get("docStatus"));
|
||||
this.docStatus = StringUtil.isNull(this.docStatus) ? "" : (" and docstatus = " + this.docStatus);
|
||||
} else if (this.cmd.equals("customer")) {
|
||||
this.customerType = StringUtil.vString(params.get("customerType"));
|
||||
this.customerType = StringUtil.isNull(customerType) ? "" : (" and type = " + this.customerType);
|
||||
this.customerStatus = StringUtil.vString(params.get("customerStatus"));
|
||||
this.customerStatus = StringUtil.isNull(customerStatus) ? "" : (" and status = " + this.customerStatus);
|
||||
} else if (this.cmd.equals("project")) {
|
||||
this.workType = StringUtil.vString(params.get("workType"));
|
||||
this.workType = StringUtil.isNull(workType) ? "" : (" and worktype = " + this.workType);
|
||||
this.projectStatus = StringUtil.vString(params.get("projectStatus"));
|
||||
this.projectStatus = StringUtil.isNull(projectStatus) ? "" : (" and status = " + this.projectStatus);
|
||||
}
|
||||
this.status = StringUtil.vString(params.get("status"));
|
||||
this.status = (StringUtil.isNull(status) || status.equals("8")) ? "0,1,2,3" : status;
|
||||
this.status = this.status.equals("9") ? "" : (" and status in (" + this.status + ") ");
|
||||
}
|
||||
|
||||
private void initLabelIndex() {
|
||||
|
|
@ -448,7 +422,7 @@ public class DanikorOrgChartManager {
|
|||
} else if (this.cmd.equals("project")) {
|
||||
this.labelIndex = 101;
|
||||
}
|
||||
isShow = this.cg.length >= 3 ? "P".equalsIgnoreCase(this.cg[2]) : false;
|
||||
isShow = this.cg.length >= 3 && "P".equalsIgnoreCase(this.cg[2]);
|
||||
}
|
||||
|
||||
public int getLabelIndex() {
|
||||
|
|
@ -457,123 +431,49 @@ public class DanikorOrgChartManager {
|
|||
|
||||
private void initCountSql() {
|
||||
String asNamefora = useAppDetach ? "hrmresource" : "a";
|
||||
String asNameforb = useAppDetach ? "hrmresource" : "b";
|
||||
String asNameforc = useAppDetach ? "hrmresource" : "c";
|
||||
if (this.isPOrg) {
|
||||
if (StringUtil.isNull(this.cmd)) {
|
||||
this.companyCountSql = "select COUNT(id) from HrmResource where 1=1 " + this.status;
|
||||
this.subCompanyCountSql = "select COUNT(" + asNamefora + ".id) from HrmResource " + asNamefora + " right join HrmDepartment b on " + asNamefora + ".departmentid = b.id where " + asNamefora + ".subcompanyid1=t.id and (b.canceled IS NULL OR b.canceled !='1') " + this.status;
|
||||
this.departmentCountSql = "select COUNT(id) from HrmResource where departmentid=t.id " + this.status;
|
||||
} else if (this.cmd.equals("doc")) {
|
||||
this.companyCountSql = "select COUNT(id) from DocDetail where (maincategory >= 1 or maincategory <= -1) and (subcategory >= 1 or subcategory <= -1) and (seccategory >= 1 or seccategory <= -1) " + this.docStatus;
|
||||
this.subCompanyCountSql = "select COUNT(a.id) from DocDetail a where a.ownerid in (select id from HrmResource where subcompanyid1 = t.id) and (a.maincategory >= 1 or a.maincategory <= -1) and (a.subcategory >= 1 or a.subcategory <= -1) and (a.seccategory >= 1 or a.seccategory <= -1) " + this.docStatus;
|
||||
this.departmentCountSql = "select COUNT(a.id) from DocDetail a where a.ownerid in (select id from HrmResource where departmentid = t.id) and (a.maincategory >= 1 or a.maincategory <= -1) and (a.subcategory >= 1 or a.subcategory <= -1) and (a.seccategory >= 1 or a.seccategory <= -1) " + this.docStatus;
|
||||
} else if (this.cmd.equals("customer")) {
|
||||
this.companyCountSql = "select COUNT(id) from CRM_CustomerInfo where (deleted is null or deleted!=1) " + this.customerType + this.customerStatus;
|
||||
this.subCompanyCountSql = "select COUNT(id) from CRM_CustomerInfo where manager in (select id from HrmResource where subcompanyid1 = t.id) and (deleted is null or deleted!=1) " + this.customerType + this.customerStatus;
|
||||
this.departmentCountSql = "select COUNT(id) from CRM_CustomerInfo where manager in (select id from HrmResource where departmentid = t.id) and (deleted is null or deleted!=1) " + this.customerType + this.customerStatus;
|
||||
} else if (this.cmd.equals("project")) {
|
||||
this.companyCountSql = "select COUNT(id) from Prj_ProjectInfo where 1=1 " + this.workType + this.projectStatus;
|
||||
this.subCompanyCountSql = "select COUNT(id) from Prj_ProjectInfo where manager in (select id from HrmResource where subcompanyid1 = t.id) " + this.workType + this.projectStatus;
|
||||
this.departmentCountSql = "select COUNT(id) from Prj_ProjectInfo where manager in (select id from HrmResource where departmentid = t.id) " + this.workType + this.projectStatus;
|
||||
}
|
||||
if (this.isCurrentDate) {
|
||||
this.companyCountSql = "select COUNT(id) from HrmResource where 1=1 " + this.status;
|
||||
this.subCompanyCountSql = "select COUNT(" + asNamefora + ".id) from HrmResource " + asNamefora + " right join HrmDepartment b on " + asNamefora + ".departmentid = b.id where " + asNamefora + ".subcompanyid1=t.id and (b.canceled IS NULL OR b.canceled !='1') " + this.status;
|
||||
this.departmentCountSql = "select COUNT(id) from HrmResource where departmentid=t.id " + this.status;
|
||||
} else {
|
||||
if (StringUtil.isNull(this.cmd)) {
|
||||
this.companyCountSql = "select COUNT(a.id) from HrmResourceVirtual a right join HrmResource " + asNameforb + " on a.resourceid = " + asNameforb + ".id where a.subcompanyid in ( select id from hrmsubcompanyVirtual where companyid = " + this.cvBean.getId() + " ) " + this.status;
|
||||
this.subCompanyCountSql = "select COUNT(a.id) from HrmResourceVirtual a right join HrmDepartmentVirtual b on a.departmentid = b.id right join HrmResource " + asNameforc + " on a.resourceid = " + asNameforc + ".id where a.subcompanyid = t.id and (b.canceled IS NULL OR b.canceled !='1') " + this.status;
|
||||
this.departmentCountSql = "select COUNT(a.id) from HrmResourceVirtual a right join HrmResource " + asNameforc + " on a.resourceid = " + asNameforc + ".id where a.departmentid=t.id " + this.status;
|
||||
} else if (this.cmd.equals("doc")) {
|
||||
this.companyCountSql = "select COUNT(id) from DocDetail where ownerid in (select resourceid from HrmResourceVirtual where subcompanyid in (select id from hrmsubcompanyVirtual where companyid = " + this.cvBean.getId() + ")) and (maincategory >= 1 or maincategory <= -1) and (subcategory >= 1 or subcategory <= -1) and (seccategory >= 1 or seccategory <= -1) " + this.docStatus;
|
||||
this.subCompanyCountSql = "select COUNT(a.id) from DocDetail a where a.ownerid in (select id from HrmResourceVirtual where subcompanyid = t.id) and (a.maincategory >= 1 or a.maincategory <= -1) and (a.subcategory >= 1 or a.subcategory <= -1) and (a.seccategory >= 1 or a.seccategory <= -1) " + this.docStatus;
|
||||
this.departmentCountSql = "select COUNT(a.id) from DocDetail a where a.ownerid in (select id from HrmResourceVirtual where departmentid = t.id) and (a.maincategory >= 1 or a.maincategory <= -1) and (a.subcategory >= 1 or a.subcategory <= -1) and (a.seccategory >= 1 or a.seccategory <= -1) " + this.docStatus;
|
||||
} else if (this.cmd.equals("customer")) {
|
||||
this.companyCountSql = "select COUNT(id) from CRM_CustomerInfo where (deleted is null or deleted!=1) and manager in (select resourceid from HrmResourceVirtual where subcompanyid in (select id from hrmsubcompanyVirtual where companyid = " + this.cvBean.getId() + ")) " + this.customerType + this.customerStatus;
|
||||
this.subCompanyCountSql = "select COUNT(id) from CRM_CustomerInfo where manager in (select id from HrmResourceVirtual where subcompanyid = t.id) and (deleted is null or deleted!=1) " + this.customerType + this.customerStatus;
|
||||
this.departmentCountSql = "select COUNT(id) from CRM_CustomerInfo where manager in (select id from HrmResourceVirtual where departmentid = t.id) and (deleted is null or deleted!=1) " + this.customerType + this.customerStatus;
|
||||
} else if (this.cmd.equals("project")) {
|
||||
this.companyCountSql = "select COUNT(id) from Prj_ProjectInfo where manager in (select resourceid from HrmResourceVirtual where subcompanyid in (select id from hrmsubcompanyVirtual where companyid = " + this.cvBean.getId() + ")) " + this.workType + this.projectStatus;
|
||||
this.subCompanyCountSql = "select COUNT(id) from Prj_ProjectInfo where manager in (select id from HrmResourceVirtual where subcompanyid = t.id) " + this.workType + this.projectStatus;
|
||||
this.departmentCountSql = "select COUNT(id) from Prj_ProjectInfo where manager in (select id from HrmResourceVirtual where departmentid = t.id) " + this.workType + this.projectStatus;
|
||||
}
|
||||
this.companyCountSql = "select COUNT(id) from HrmResource_back where 1=1 " + this.status + syncSearchSql;
|
||||
this.subCompanyCountSql = "select COUNT(" + asNamefora + ".id) from HrmResource_back " + asNamefora + " right join HrmDepartment_back b on " + asNamefora + ".departmentid = b.id and " + asNamefora + ".sync_date = b.sync_date where " + asNamefora + ".subcompanyid1=t.id and (b.canceled IS NULL OR b.canceled !='1') " + this.status + getSyncSearchSql("b");
|
||||
this.departmentCountSql = "select COUNT(id) from HrmResource_back where departmentid=t.id " + this.status + syncSearchSql;
|
||||
}
|
||||
}
|
||||
|
||||
private String initSubDepartmentCountSql() {
|
||||
String sql = "";
|
||||
String asNameforb = useAppDetach ? "hrmresource" : "b";
|
||||
String asNameforc = useAppDetach ? "hrmresource" : "c";
|
||||
if (this.isPOrg) {
|
||||
if (StringUtil.isNull(this.cmd)) {
|
||||
sql = ("select COUNT(id)as idCount from HrmResource where departmentid in ({ids}) " + this.status);
|
||||
} else if (this.cmd.equals("doc")) {
|
||||
sql = ("select COUNT(a.id)as idCount from DocDetail a where a.ownerid in (select id from HrmResource where departmentid in ({ids})) and (a.maincategory >= 1 or a.maincategory <= -1) and (a.subcategory >= 1 or a.subcategory <= -1) and (a.seccategory >= 1 or a.seccategory <= -1) " + this.docStatus);
|
||||
} else if (this.cmd.equals("customer")) {
|
||||
sql = ("select COUNT(id)as idCount from CRM_CustomerInfo where manager in (select id from HrmResource where departmentid in ({ids})) and (deleted is null or deleted!=1) " + this.customerType + this.customerStatus);
|
||||
} else if (this.cmd.equals("project")) {
|
||||
sql = ("select COUNT(id)as idCount from Prj_ProjectInfo where manager in (select id from HrmResource where departmentid in ({ids})) " + this.workType + this.projectStatus);
|
||||
}
|
||||
String sql;
|
||||
if (this.isCurrentDate) {
|
||||
sql = ("select COUNT(id)as idCount from HrmResource where departmentid in ({ids}) " + this.status);
|
||||
} else {
|
||||
if (StringUtil.isNull(this.cmd)) {
|
||||
sql = ("select COUNT(a.id)as idCount from HrmResourceVirtual a right join HrmResource " + asNameforc + " on a.resourceid = " + asNameforc + ".id where a.departmentid in ({ids}) " + this.status);
|
||||
} else if (this.cmd.equals("doc")) {
|
||||
sql = ("select COUNT(a.id)as idCount from DocDetail a where a.ownerid in (select a.resourceid from HrmResourceVirtual a right join HrmResource b on a.resourceid = b.id where a.departmentid in ({ids})) and (a.maincategory >= 1 or a.maincategory <= -1) and (a.subcategory >= 1 or a.subcategory <= -1) and (a.seccategory >= 1 or a.seccategory <= -1) " + this.docStatus);
|
||||
} else if (this.cmd.equals("customer")) {
|
||||
sql = ("select COUNT(id)as idCount from CRM_CustomerInfo where manager in (select a.resourceid from HrmResourceVirtual a right join HrmResource b on a.resourceid = b.id where a.departmentid in ({ids})) and (deleted is null or deleted!=1) " + this.customerType + this.customerStatus);
|
||||
} else if (this.cmd.equals("project")) {
|
||||
sql = ("select COUNT(id)as idCount from Prj_ProjectInfo where manager in (select a.resourceid from HrmResourceVirtual a right join HrmResource b on a.resourceid = b.id where a.departmentid in ({ids})) " + this.workType + this.projectStatus);
|
||||
}
|
||||
sql = ("select COUNT(id)as idCount from HrmResource_back where departmentid in ({ids}) " + this.status + syncSearchSql);
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
private String initSubCompanyCountSql() {
|
||||
String sql = "";
|
||||
String asNameforb = useAppDetach ? "hrmresource" : "b";
|
||||
String asNameforc = useAppDetach ? "hrmresource" : "c";
|
||||
if (this.isPOrg) {
|
||||
if (StringUtil.isNull(this.cmd)) {
|
||||
sql = ("select COUNT(id) as idCount from HrmResource where subcompanyid1 in ({ids}) " + this.status);
|
||||
} else if (this.cmd.equals("doc")) {
|
||||
sql = ("select COUNT(a.id)as idCount from DocDetail a where a.ownerid in (select id from HrmResource where subcompanyid1 in ({ids})) and (a.maincategory >= 1 or a.maincategory <= -1) and (a.subcategory >= 1 or a.subcategory <= -1) and (a.seccategory >= 1 or a.seccategory <= -1) " + this.docStatus);
|
||||
} else if (this.cmd.equals("customer")) {
|
||||
sql = ("select COUNT(id)as idCount from CRM_CustomerInfo where manager in (select id from HrmResource where subcompanyid1 in ({ids})) and (deleted is null or deleted!=1) " + this.customerType + this.customerStatus);
|
||||
} else if (this.cmd.equals("project")) {
|
||||
sql = ("select COUNT(id)as idCount from Prj_ProjectInfo where manager in (select id from HrmResource where subcompanyid1 in ({ids})) " + this.workType + this.projectStatus);
|
||||
}
|
||||
String sql;
|
||||
if (isCurrentDate) {
|
||||
sql = ("select COUNT(id) as idCount from HrmResource where subcompanyid1 in ({ids}) " + status);
|
||||
} else {
|
||||
if (StringUtil.isNull(this.cmd)) {
|
||||
sql = ("select COUNT(a.id)as idCount from HrmResourceVirtual a right join HrmResource " + asNameforc + " on a.resourceid = " + asNameforc + ".id where a.subcompanyid in ({ids}) " + this.status);
|
||||
} else if (this.cmd.equals("doc")) {
|
||||
sql = ("select COUNT(a.id)as idCount from DocDetail a where a.ownerid in (select a.resourceid from HrmResourceVirtual a right join HrmResource b on a.resourceid = b.id where a.subcompanyid in ({ids})) and (a.maincategory >= 1 or a.maincategory <= -1) and (a.subcategory >= 1 or a.subcategory <= -1) and (a.seccategory >= 1 or a.seccategory <= -1) " + this.docStatus);
|
||||
} else if (this.cmd.equals("customer")) {
|
||||
sql = ("select COUNT(id)as idCount from CRM_CustomerInfo where manager in (select a.resourceid from HrmResourceVirtual a right join HrmResource b on a.resourceid = b.id where a.subcompanyid in ({ids})) and (deleted is null or deleted!=1) " + this.customerType + this.customerStatus);
|
||||
} else if (this.cmd.equals("project")) {
|
||||
sql = ("select COUNT(id)as idCount from Prj_ProjectInfo where manager in (select a.resourceid from HrmResourceVirtual a right join HrmResource b on a.resourceid = b.id where a.subcompanyid in ({ids})) " + this.workType + this.projectStatus);
|
||||
}
|
||||
sql = ("select COUNT(a.id)as idCount from HrmResource_back a where a.subcompanyid in ({ids}) " + status + syncSearchSql);
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
public int getCompanyResourceCount() {
|
||||
this.rs.executeSql(this.companyCountSql + ((getDetachSql("").equals("")) ? " and 1=1" : (" and " + getDetachSql(""))));
|
||||
this.rs.execute(this.companyCountSql + ((getDetachSql("").equals("")) ? " and 1=1" : (" and " + getDetachSql(""))));
|
||||
return this.rs.next() ? this.rs.getInt(1) : 0;
|
||||
}
|
||||
|
||||
public int getShownum() {
|
||||
shownum = shownum <= 0 ? 1 : shownum;
|
||||
return shownum;
|
||||
private String getSyncSearchSql(String tableName) {
|
||||
return syncSearchSql.replace("sync_date", tableName + ".sync_date");
|
||||
}
|
||||
|
||||
public void setShownum(int shownum) {
|
||||
this.shownum = shownum;
|
||||
public void setShowNum(int showNum) {
|
||||
this.showNum = showNum;
|
||||
}
|
||||
|
||||
public boolean isPOrg() {
|
||||
return isPOrg;
|
||||
}
|
||||
|
||||
public void setPOrg(boolean isPOrg) {
|
||||
this.isPOrg = isPOrg;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ public class DanikorResourceBackServiceImpl extends Service implements DanikorRe
|
|||
String showName = Util.null2String(params.get("arg2"));
|
||||
|
||||
int showtype = Util.getIntValue(Util.null2String(params.get("showtype")), 0);
|
||||
Map beanMap = new HashMap();
|
||||
Map beanMap = new HashMap<>();
|
||||
HrmChartSetManager HrmChartSetManager = new HrmChartSetManager();
|
||||
beanMap.put("is_sys", 1);
|
||||
HrmChartSet bean = HrmChartSetManager.get(beanMap);
|
||||
|
|
@ -213,7 +213,7 @@ public class DanikorResourceBackServiceImpl extends Service implements DanikorRe
|
|||
//初始化tlevel
|
||||
new com.api.hrm.util.ServiceUtil().initOrgLevel();
|
||||
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("status", arg4);
|
||||
map.put("docStatus", arg5);
|
||||
map.put("customerType", arg6);
|
||||
|
|
@ -221,21 +221,21 @@ public class DanikorResourceBackServiceImpl extends Service implements DanikorRe
|
|||
map.put("workType", arg8);
|
||||
map.put("projectStatus", arg9);
|
||||
|
||||
Map<String, String> requestMap = new HashMap<String, String>();
|
||||
Map<String, Object> requestMap = new HashMap<>();
|
||||
requestMap.put("cmd", arg10);
|
||||
requestMap.put("sorgid", sorgid);
|
||||
|
||||
showName = StringUtil.vString(StringUtil.toScreen(Util.formatMultiLang(showName, "" + user.getLanguage())));
|
||||
|
||||
DanikorOrgChartManager chartManager = new DanikorOrgChartManager();
|
||||
chartManager.setShownum(shownum);
|
||||
chartManager.setShowNum(shownum);
|
||||
chartManager.init(user, request, map, arg11, isPOrg, cvBean, requestMap);
|
||||
String showCount = String.valueOf(chartManager.getCompanyResourceCount());
|
||||
String showTitle = showName + SystemEnv.getHtmlLabelNames(chartManager.getLabelIndex() + ",523", user.getLanguage()) + showCount;
|
||||
|
||||
String defaultHref = weaver.general.GCONST.getContextPath() + "/spa/hrm/index_mobx.html#/main/hrm/orgStaff?_fromURL=HrmResourceSearchResult&from=hrmorg&virtualtype=" + sorgid;
|
||||
StringBuffer data = new StringBuffer("[");
|
||||
data.append("{\"id\":\"0\", \"pid\":\"\", \"type\":\"company\", \"name\":\"").append(StringUtil.vString(showName, 12)).append("\", \"title\":\"").append(showName).append("\", \"num\":\"" + showCount + "\", \"nTitle\":\"" + showTitle + "\", \"oDisplay\":\"none\", \"subRCount\":\"0\", \"subTitle\":\"\", \"cOnclick\":\"" + defaultHref + "\", \"sOnclick\":\"\"}").append(chartManager.getData("0"));
|
||||
data.append("{\"id\":\"0\", \"pid\":\"\", \"type\":\"company\", \"name\":\"").append(StringUtil.vString(showName, 12)).append("\", \"title\":\"").append(showName).append("\", \"num\":\"" + showCount + "\", \"nTitle\":\"" + showTitle + "\", \"oDisplay\":\"none\", \"subRCount\":\"0\", \"subTitle\":\"\", \"cOnclick\":\"" + defaultHref + "\", \"sOnclick\":\"\"}").append(chartManager.getData());
|
||||
data.append("]");
|
||||
return data.toString();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue