Compare commits
12 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
ed2c23e48f | |
|
|
fb38ba271b | |
|
|
2b8e3dbb85 | |
|
|
0bbde26f6f | |
|
|
877fb368a8 | |
|
|
abb3d04953 | |
|
|
e20d1d57ce | |
|
|
3191564961 | |
|
|
8a2b024de7 | |
|
|
41218ebed0 | |
|
|
1cf8d42e75 | |
|
|
0d9e03507b |
|
|
@ -130,7 +130,7 @@ public class JobBrowserService extends BrowserService {
|
|||
// 分权
|
||||
DetachUtil detachUtil = new DetachUtil(user);
|
||||
if (detachUtil.isDETACH()) {
|
||||
sqlWhere += " AND t.parent_comp in (" + detachUtil.getJclRoleLevels() + ")";
|
||||
sqlWhere += " AND t.ec_company in (" + detachUtil.getJclRoleLevels() + ")";
|
||||
}
|
||||
return sqlWhere;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package com.api.organization.web;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/01/28
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Path("/bs/hrmorganization/danikorresource")
|
||||
public class DanikorResourceBackController extends com.engine.organization.web.DanikorResourceBackController {
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package com.engine.organization.entity.column;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/01/16
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class TableColumnPO {
|
||||
private String tableName;
|
||||
private String columnName;
|
||||
private String columnType;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
TableColumnPO that = (TableColumnPO) o;
|
||||
return Objects.equals(columnName, that.columnName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(columnName);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.engine.organization.entity.danikor.param;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/01/31
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ChartParam {
|
||||
private String id;
|
||||
private String pid;
|
||||
private String type;
|
||||
private String name;
|
||||
private String title;
|
||||
private String num;
|
||||
private String nTitle;
|
||||
private String oDisplay;
|
||||
private String subRCount;
|
||||
private String subTitle;
|
||||
private String hasChild;
|
||||
private String needPlus;
|
||||
private String cOnclick;
|
||||
private String sOnclick;
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.engine.organization.entity.danikor.vo;
|
||||
|
||||
import com.engine.organization.annotation.OrganizationTable;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/01/17
|
||||
* @version: 1.0
|
||||
*/
|
||||
@OrganizationTable(pageId = "e1b72792-9f71-11ed-aa42-00e04c680716",
|
||||
orderby = " t.dsporder ",
|
||||
sortway = " asc",
|
||||
primarykey = "id"
|
||||
)
|
||||
public class ResourceBackVO {
|
||||
}
|
||||
|
|
@ -143,7 +143,7 @@ public class DepartmentBO {
|
|||
tree.setPid(null == item.getSupDepId() ? "0" : item.getSupDepId().toString());
|
||||
tree.setSelected(false);
|
||||
tree.setType("2");
|
||||
tree.setParentComp(item.getSubCompanyId1().toString());
|
||||
tree.setParentComp(null == item.getSubCompanyId1() ? "" : item.getSubCompanyId1().toString());
|
||||
tree.setOrderNum(null == item.getShowOrder() ? 0 : item.getShowOrder().intValue());
|
||||
return tree;
|
||||
}).collect(Collectors.toList());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,125 @@
|
|||
package com.engine.organization.job;
|
||||
|
||||
import com.engine.organization.entity.column.TableColumnPO;
|
||||
import com.engine.organization.mapper.danikor.DanikorResourceMapper;
|
||||
import com.engine.organization.mapper.extend.ExtendInfoMapper;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 同步用户数据定时服务
|
||||
*
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/01/16
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class DanikorSyncUserJob extends BaseCronJob {
|
||||
|
||||
//select * into hrmresource_back FROM hrmresource where 1=2;
|
||||
//alter table hrmresource_back add sync_date date null;
|
||||
//alter table hrmresource_back add default getdate() for sync_date;
|
||||
//alter table hrmresource_back add sync_id int identity(1,1);
|
||||
private static final String RESOURCE_MAIN = "hrmresource";
|
||||
private static final String RESOURCE_BACK = "hrmresource_back";
|
||||
|
||||
//CREATE TABLE cus_fielddata_back (
|
||||
//seqorder int NOT NULL,
|
||||
//[scope] varchar(1000) NULL,
|
||||
//scopeid int NOT NULL,
|
||||
//id int NOT NULL,
|
||||
//sync_date date null,
|
||||
//sync_id int identity(1,1)
|
||||
//);
|
||||
//alter table cus_fielddata_back add default getdate() for sync_date;
|
||||
private static final String CUS_MAIN = "cus_fielddata";
|
||||
private static final String CUS_BACK = "cus_fielddata_back";
|
||||
|
||||
//select * into hrmsubcompany_back FROM hrmsubcompany where 1=2;
|
||||
//alter table hrmsubcompany_back add sync_date date null;
|
||||
//alter table hrmsubcompany_back add default getdate() for sync_date;
|
||||
//alter table hrmsubcompany_back drop column id;
|
||||
//alter table hrmsubcompany_back add id int not null;
|
||||
//alter table hrmsubcompany_back add sync_id int identity(1,1);
|
||||
private static final String COMPANY_MAIN = "hrmsubcompany";
|
||||
private static final String COMPANY_BACK = "hrmsubcompany_back";
|
||||
|
||||
//CREATE TABLE hrmsubcompanydefined_back (
|
||||
//id int NOT NULL,
|
||||
//subcomid int NOT NULL,
|
||||
//sync_date date null,
|
||||
//sync_id int identity(1,1)
|
||||
//);
|
||||
//alter table hrmsubcompanydefined_back add default getdate() for sync_date;
|
||||
private static final String COMPANY_DEFINED_MAIN = "hrmsubcompanydefined";
|
||||
private static final String COMPANY_DEFINED_BACK = "hrmsubcompanydefined_back";
|
||||
|
||||
//select * into hrmdepartment_back FROM hrmdepartment where 1=2;
|
||||
//alter table hrmdepartment_back add sync_date date null;
|
||||
//alter table hrmdepartment_back add default getdate() for sync_date;
|
||||
//alter table hrmdepartment_back drop column id;
|
||||
//alter table hrmdepartment_back add id int not null;
|
||||
//alter table hrmdepartment_back add sync_id int identity(1,1);
|
||||
private static final String DEPARTMENT_MAIN = "hrmdepartment";
|
||||
private static final String DEPARTMENT_BACK = "hrmdepartment_back";
|
||||
|
||||
//CREATE TABLE hrmdepartmentdefined_back (
|
||||
//id int NOT NULL,
|
||||
//deptid int NOT NULL,
|
||||
//sync_date date null,
|
||||
//sync_id int identity(1,1)
|
||||
//);
|
||||
//alter table hrmdepartmentdefined_back add default getdate() for sync_date;
|
||||
private static final String DEPARTMENT_DEFINED_MAIN = "hrmdepartmentdefined";
|
||||
private static final String DEPARTMENT_DEFINED_BACK = "hrmdepartmentdefined_back";
|
||||
|
||||
private DanikorResourceMapper getDanikorResourceMapper() {
|
||||
return MapperProxyFactory.getProxy(DanikorResourceMapper.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
// 比较两张表的表结构,同步表结构、表数据
|
||||
syncTableFields(RESOURCE_MAIN, RESOURCE_BACK);
|
||||
syncTableFields(CUS_MAIN, CUS_BACK);
|
||||
|
||||
syncTableFields(COMPANY_MAIN, COMPANY_BACK);
|
||||
syncTableFields(COMPANY_DEFINED_MAIN, COMPANY_DEFINED_BACK);
|
||||
|
||||
syncTableFields(DEPARTMENT_MAIN, DEPARTMENT_BACK);
|
||||
syncTableFields(DEPARTMENT_DEFINED_MAIN, DEPARTMENT_DEFINED_BACK);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 同步表字段
|
||||
*
|
||||
* @param mainTableName
|
||||
* @param backTableName
|
||||
*/
|
||||
private void syncTableFields(String mainTableName, String backTableName) {
|
||||
List<TableColumnPO> mainTableFields;
|
||||
List<TableColumnPO> backTableFields;
|
||||
if (CUS_MAIN.equals(mainTableName)) {
|
||||
mainTableFields = getDanikorResourceMapper().getCusColumnByTableName(mainTableName);
|
||||
backTableFields = getDanikorResourceMapper().getCusColumnByTableName(backTableName);
|
||||
} else {
|
||||
mainTableFields = getDanikorResourceMapper().getHrmColumnByTableName(mainTableName);
|
||||
backTableFields = getDanikorResourceMapper().getHrmColumnByTableName(backTableName);
|
||||
}
|
||||
for (TableColumnPO tableColumnPO : mainTableFields) {
|
||||
if (!backTableFields.contains(tableColumnPO)) {
|
||||
// 为回溯表创建字段
|
||||
MapperProxyFactory.getProxy(ExtendInfoMapper.class).addTableColumn(backTableName, tableColumnPO.getColumnName(), tableColumnPO.getColumnType());
|
||||
}
|
||||
}
|
||||
RecordSet rs = new RecordSet();
|
||||
String mainTableColumns = mainTableFields.stream().map(TableColumnPO::getColumnName).collect(Collectors.joining(","));
|
||||
// 同步主表数据
|
||||
String sql = "insert into " + backTableName + "(" + mainTableColumns + ") select " + mainTableColumns + " from " + mainTableName;
|
||||
rs.execute(sql);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,478 @@
|
|||
package com.engine.organization.manager;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.common.StringUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.appdetach.AppDetachComInfo;
|
||||
import weaver.hrm.chart.domain.HrmCompanyVirtual;
|
||||
import weaver.hrm.chart.domain.MOrgChart;
|
||||
import weaver.hrm.common.database.dialect.DbDialectFactory;
|
||||
import weaver.hrm.common.database.dialect.DialectUtil;
|
||||
import weaver.hrm.common.database.dialect.constract.TableSelfRelationStyle;
|
||||
import weaver.hrm.common.database.dialect.pojo.TableSelfRelationBean;
|
||||
import weaver.hrm.company.OrgOperationUtil;
|
||||
import weaver.systeminfo.SystemEnv;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/01/30
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class DanikorOrgChartManager {
|
||||
|
||||
|
||||
private String sql = "";
|
||||
private String status = "";
|
||||
private HttpServletRequest request = null;
|
||||
private String cmd = "";
|
||||
private int labelIndex = -1;
|
||||
private Map<String, Object> params = null;
|
||||
private String[] cg;
|
||||
private boolean isPOrg = false;
|
||||
private boolean isShow = false;
|
||||
private HrmCompanyVirtual cvBean = null;
|
||||
private String companyCountSql = "";
|
||||
private String subCompanyCountSql = "";
|
||||
private String departmentCountSql = "";
|
||||
private final RecordSet rs;
|
||||
private String defaultHref = "";
|
||||
private final List<MOrgChart> list;
|
||||
private User user;
|
||||
private String subCompanyTabName = "";
|
||||
private String departmentTableName = "";
|
||||
private int showNum = 1;
|
||||
OrgOperationUtil OrgOperationUtil;
|
||||
AppDetachComInfo adci = null;
|
||||
private Boolean useAppDetach;
|
||||
private List<String> allowsubcompany = null;//能查看的分部
|
||||
private List<String> allowdepartment = null;//能查看的部门
|
||||
private List<String> allowsubcompanyview = null;//能查看的分部含必要的上级
|
||||
private List<String> allowdepartmentview = null;//能查看的部门含必要的上级
|
||||
|
||||
boolean isCurrentDate = true;
|
||||
String syncSearchSql = "";
|
||||
|
||||
|
||||
public DanikorOrgChartManager() {
|
||||
this.useAppDetach = Boolean.FALSE;
|
||||
this.rs = new RecordSet();
|
||||
this.list = new ArrayList<>();
|
||||
OrgOperationUtil = new OrgOperationUtil();
|
||||
}
|
||||
|
||||
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;
|
||||
this.adci = new AppDetachComInfo(user);
|
||||
|
||||
this.cmd = StringUtil.vString(this.request.getParameter("cmd"));
|
||||
String sorgid = StringUtil.vString(this.request.getParameter("sorgid"));
|
||||
String syncDate = Util.null2String(this.request.getParameter("date"));
|
||||
if (StringUtils.isNotBlank(syncDate) && !DateUtil.getDate(new Date()).equals(syncDate)) {
|
||||
isCurrentDate = false;
|
||||
syncSearchSql = " and sync_date ='" + syncDate + "'";
|
||||
}
|
||||
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();
|
||||
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 = DialectUtil.isMySql(rs.getDBType());
|
||||
String hasnextsql = this.getHasNextBySubCompanySql(isMysql);
|
||||
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.execute(this.sql);
|
||||
rs.writeLog("init:" + this.sql);
|
||||
MOrgChart bean;
|
||||
while (this.rs.next()) {
|
||||
int subHasNext = this.rs.getInt(6);
|
||||
int deptHasNext = this.rs.getInt(7);
|
||||
bean = new MOrgChart();
|
||||
bean.setId(this.rs.getString(1));
|
||||
bean.setName(this.rs.getString(2));
|
||||
bean.setSubId(this.rs.getString(3));
|
||||
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)));
|
||||
this.list.add(bean);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private String getDetachSql(String type) {
|
||||
String detachSql = "";
|
||||
if (useAppDetach) {
|
||||
try {
|
||||
detachSql = adci.getScopeSqlByHrmResourceSearch(user.getUID() + "", false, type);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return detachSql;
|
||||
}
|
||||
|
||||
private void checkAppInfo() {
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.execute("select appdetachable from SystemSet");
|
||||
if (rs.next() && rs.getString("appdetachable") != null && "1".equals(rs.getString("appdetachable"))) {
|
||||
useAppDetach = Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
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"));
|
||||
String tmpdefaultHref = weaver.general.GCONST.getContextPath() + "/spa/hrm/index_mobx.html#/main/hrm/orgStaff?_fromURL=HrmResourceSearchResult&from=hrmorg&virtualtype=" + sorgid + "&subcompanyid1={param}";
|
||||
if (useAppDetach) {
|
||||
try {
|
||||
this.allowsubcompany = adci.getAlllowsubcompany();//能查看的分部
|
||||
this.allowsubcompanyview = adci.getAlllowsubcompanyview();//能查看的分部含必要的上级
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
rs.writeLog("getData:list:" + list);
|
||||
for (MOrgChart mOrgChart : this.list) {
|
||||
bean = mOrgChart;
|
||||
|
||||
boolean flag = true;
|
||||
if (!adci.isNotCheckUserAppDetach()) {
|
||||
flag = allowsubcompany.contains(bean.getId());
|
||||
|
||||
if (!flag && allowsubcompanyview.contains(bean.getId())) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if (!flag) continue;
|
||||
int showCount = bean.getCount();
|
||||
|
||||
if (bean.getSubCount() != 0 && isShow) {
|
||||
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) {
|
||||
showCount = StringUtil.parseToInt(idCount, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String showTitle = bean.getName() + cTitle + showCount;
|
||||
boolean hasNext = bean.isHasNext();
|
||||
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());
|
||||
return data.toString();
|
||||
}
|
||||
|
||||
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;
|
||||
boolean isMysql = false;
|
||||
//对于supdepid为空的情况 增加判断
|
||||
if ("oracle".equalsIgnoreCase(this.rs.getDBType())) {
|
||||
checkSupdepid = " t.id != nvl(t.supdepid,0) ";
|
||||
} else if (DialectUtil.isMySql(rs.getDBType())) {
|
||||
isMysql = true;
|
||||
checkSupdepid = " t.id !=" + DbDialectFactory.get(rs.getDBType()).isNull("t.supdepid", 0);
|
||||
} else {
|
||||
checkSupdepid = " t.id != ISNULL(t.supdepid,0) ";
|
||||
}
|
||||
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 " + 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') " + syncSearchSql + " order by t.subcompanyid1 asc , t.supdepid asc , t.showorder asc, t.departmentname asc";
|
||||
this.rs.execute(this.sql);
|
||||
rs.writeLog("appendDepartment:this.sql:" + this.sql);
|
||||
List<MOrgChart> dList = new ArrayList<>();
|
||||
MOrgChart bean;
|
||||
if (useAppDetach) {
|
||||
try {
|
||||
this.allowsubcompany = adci.getAlllowsubcompany();//能查看的分部
|
||||
this.allowdepartment = adci.getAlllowdepartment();//能查看的部门
|
||||
this.allowsubcompanyview = adci.getAlllowsubcompanyview();//能查看的分部含必要的上级
|
||||
this.allowdepartmentview = adci.getAlllowdepartmentview();//能查看的部门含必要的上级
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
while (this.rs.next()) {
|
||||
bean = new MOrgChart();
|
||||
bean.setId(this.rs.getString(1));
|
||||
|
||||
String id = bean.getId();
|
||||
String subcompanyid1 = this.rs.getString(3);
|
||||
boolean flag = true;
|
||||
if (!adci.isNotCheckUserAppDetach()) {
|
||||
flag = allowdepartment.contains(id);
|
||||
|
||||
if (!flag && allowdepartmentview.contains(id)) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!flag && allowsubcompany.contains(subcompanyid1)) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if (!flag) continue;
|
||||
|
||||
bean.setName(this.rs.getString(2));
|
||||
bean.setSubId((this.rs.getString(5).equals("0") || StringUtil.isNull(this.rs.getString(5))) ? this.rs.getString(3) : ("d" + this.rs.getString(5)));
|
||||
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);
|
||||
if (this.rs.getInt(7) == 0) {
|
||||
continue;
|
||||
}
|
||||
dList.add(bean);
|
||||
}
|
||||
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 allSubId = "";
|
||||
boolean isShowSubCount = false;
|
||||
int subRCount = m.getCount();
|
||||
|
||||
showTitle = cTitle + m.getCount();
|
||||
if (m.getSubCount() != 0 && isShow) {
|
||||
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"));
|
||||
isShowSubCount = allSubId.length() > 0;
|
||||
if (idCount.length() > 0) {
|
||||
subRCount = StringUtil.parseToInt(idCount, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
String subTitle = sTitle + subRCount;
|
||||
boolean hasNext = m.isHasNext();
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查分部是否存在下级分部或者部门
|
||||
*
|
||||
* @param isMysql
|
||||
* @return
|
||||
*/
|
||||
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";
|
||||
if (isMysql) {
|
||||
//8.0版本的mysql distinct 1 的时候会出现多条数据
|
||||
subsql = ",(select distinct if(s.supsubcomid is null,null,1) as hasnext from " + subCompanyTabName + " s where (s.supsubcomid=t.id and (s.CANCELED IS NULL OR s.CANCELED !='1')) ) as hassubnext";
|
||||
deptsql = ",(select distinct if(d.subcompanyid1 is null,null,1) as hasnext from " + departmentTableName + " d where (d.subcompanyid1=t.id and (d.CANCELED IS NULL OR d.CANCELED !='1')) ) as hasdeptnext";
|
||||
}
|
||||
return subsql + deptsql;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否存在下级部门
|
||||
*
|
||||
* @param isMysql
|
||||
* @return
|
||||
*/
|
||||
private String getHasNextBySubDeptSql(boolean isMysql) {
|
||||
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 " + whereSql + ") as hasnext";
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
private Map<String, String> getAllSubCompanyId(String arg0, String arg1) {
|
||||
return getSubId(arg0, this.subCompanyTabName, "SUPSUBCOMID", arg1);
|
||||
}
|
||||
|
||||
private Map<String, String> getAllSubDepartId(String arg0, String arg1) {
|
||||
return getSubId(arg0, this.departmentTableName, "SUPDEPID", arg1);
|
||||
}
|
||||
|
||||
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')");
|
||||
|
||||
StringBuilder ids = new StringBuilder();
|
||||
|
||||
StringBuilder sql = new StringBuilder();
|
||||
if ("oracle".equals(rs.getDBType())) {
|
||||
sql.append(" WITH allSub AS ( SELECT ID FROM ");
|
||||
sql.append(arg1).append(" start with id=").append(arg0).append(" connect by PRIOR id=").append(arg2);
|
||||
sql.append(")");
|
||||
} else if (DialectUtil.isMySql(rs.getDBType())) {
|
||||
TableSelfRelationBean bean = new TableSelfRelationBean(TableSelfRelationStyle.findByTableName(arg1.trim()));
|
||||
bean.setLastSqlWhere(" and (CANCELED IS NULL OR CANCELED !='1') ");
|
||||
bean.setOutFiled("id");
|
||||
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)
|
||||
.append(" a, allSub b WHERE a.").append(arg2).append("= b.ID ");
|
||||
sql.append(")");
|
||||
} else {
|
||||
sql.append(" WITH allSub AS ( SELECT ID FROM ");
|
||||
sql.append(arg1).append(" WHERE ID = ").append(arg0).append(" UNION ALL SELECT a.ID FROM ").append(arg1)
|
||||
.append(" a, allSub b WHERE a.").append(arg2).append("= b.ID ");
|
||||
sql.append(")");
|
||||
}
|
||||
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<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.execute(sql.toString());
|
||||
String idCount = "";
|
||||
while (rs.next()) {
|
||||
if (idCount.length() == 0) idCount = StringUtil.vString(rs.getString(1));
|
||||
ids.append(StringUtil.isNull(ids.toString()) ? "" : ",").append(StringUtil.vString(rs.getString(2)));
|
||||
}
|
||||
map.put("idCount", idCount);
|
||||
map.put("ids", ids.toString());
|
||||
return map;
|
||||
}
|
||||
|
||||
private void initParams() {
|
||||
if (this.params == null || this.params.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
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() {
|
||||
if (StringUtil.isNull(this.cmd)) {
|
||||
this.labelIndex = 179;
|
||||
} else if (this.cmd.equals("doc")) {
|
||||
this.labelIndex = 58;
|
||||
} else if (this.cmd.equals("customer")) {
|
||||
this.labelIndex = 136;
|
||||
} else if (this.cmd.equals("project")) {
|
||||
this.labelIndex = 101;
|
||||
}
|
||||
isShow = this.cg.length >= 3 && "P".equalsIgnoreCase(this.cg[2]);
|
||||
}
|
||||
|
||||
public int getLabelIndex() {
|
||||
return this.labelIndex;
|
||||
}
|
||||
|
||||
private void initCountSql() {
|
||||
String asNamefora = useAppDetach ? "hrmresource" : "a";
|
||||
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 {
|
||||
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;
|
||||
if (this.isCurrentDate) {
|
||||
sql = ("select COUNT(id)as idCount from HrmResource where departmentid in ({ids}) " + this.status);
|
||||
} else {
|
||||
sql = ("select COUNT(id)as idCount from HrmResource_back where departmentid in ({ids}) " + this.status + syncSearchSql);
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
private String initSubCompanyCountSql() {
|
||||
String sql;
|
||||
if (isCurrentDate) {
|
||||
sql = ("select COUNT(id) as idCount from HrmResource where subcompanyid1 in ({ids}) " + status);
|
||||
} else {
|
||||
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.execute(this.companyCountSql + ((getDetachSql("").equals("")) ? " and 1=1" : (" and " + getDetachSql(""))));
|
||||
return this.rs.next() ? this.rs.getInt(1) : 0;
|
||||
}
|
||||
|
||||
private String getSyncSearchSql(String tableName) {
|
||||
return syncSearchSql.replace("sync_date", tableName + ".sync_date");
|
||||
}
|
||||
|
||||
public void setShowNum(int showNum) {
|
||||
this.showNum = showNum;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package com.engine.organization.mapper.danikor;
|
||||
|
||||
import com.engine.organization.entity.column.TableColumnPO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/01/16
|
||||
* @version: 1.0
|
||||
*/
|
||||
public interface DanikorResourceMapper {
|
||||
/**
|
||||
* 查询人员自定义表结构信息
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
List<TableColumnPO> getCusColumnByTableName(@Param("tableName") String tableName);
|
||||
|
||||
/**
|
||||
* 查询组织架构表结构信息
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
List<TableColumnPO> getHrmColumnByTableName(@Param("tableName") String tableName);
|
||||
|
||||
/**
|
||||
* 汇总人员数
|
||||
*
|
||||
* @param tableName
|
||||
* @param syncDate
|
||||
* @return
|
||||
*/
|
||||
Integer summaryResourceData(@Param("tableName") String tableName, @Param("syncDate") String syncDate);
|
||||
|
||||
/**
|
||||
* 汇总分部数
|
||||
*
|
||||
* @param tableName
|
||||
* @param syncDate
|
||||
* @return
|
||||
*/
|
||||
Integer summaryCompanyData(@Param("tableName") String tableName, @Param("syncDate") String syncDate);
|
||||
|
||||
/**
|
||||
* 汇总部门数
|
||||
*
|
||||
* @param tableName
|
||||
* @param syncDate
|
||||
* @return
|
||||
*/
|
||||
Integer summaryDepartmentData(@Param("tableName") String tableName, @Param("syncDate") String syncDate);
|
||||
|
||||
/**
|
||||
* 获取字段对应名称
|
||||
*
|
||||
* @param fieldName
|
||||
* @param scopeId
|
||||
* @return
|
||||
*/
|
||||
String getFieldLabel(@Param("fieldName") String fieldName, @Param("scopeId") String scopeId);
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.engine.organization.mapper.danikor.DanikorResourceMapper">
|
||||
|
||||
|
||||
<select id="getCusColumnByTableName" resultType="com.engine.organization.entity.column.TableColumnPO">
|
||||
select a.name as tableName, b.name as columnName, c.fielddbtype as columnType
|
||||
from sysobjects a
|
||||
inner join syscolumns b on a.id = b.id and a.xtype = 'U'
|
||||
left join cus_formdict c on b.name = c.fieldname
|
||||
where a.name = #{tableName}
|
||||
</select>
|
||||
|
||||
<select id="getHrmColumnByTableName" resultType="com.engine.organization.entity.column.TableColumnPO">
|
||||
select a.name as tableName, b.name as columnName, d.fielddbtype as columnType
|
||||
from sysobjects a
|
||||
inner join syscolumns b on a.id = b.id and a.xtype = 'U'
|
||||
left join hrm_formfield d on b.name = d.fieldname
|
||||
<if test="tableName=='hrmsubcompany' ">
|
||||
and d.groupid = 6
|
||||
</if>
|
||||
<if test="tableName=='hrmsubcompanydefined' ">
|
||||
and d.groupid = 6
|
||||
</if>
|
||||
<if test="tableName=='hrmdepartment'">
|
||||
and d.groupid = 7
|
||||
</if>
|
||||
<if test="tableName=='hrmdepartmentdefined'">
|
||||
and d.groupid = 7
|
||||
</if>
|
||||
<if test="tableName=='hrmresource'">
|
||||
and d.groupid < 6
|
||||
</if>
|
||||
where a.name = #{tableName}
|
||||
</select>
|
||||
<select id="summaryData" resultType="java.lang.Integer">
|
||||
select count(id)
|
||||
from ${tableName}
|
||||
where 1 = 1
|
||||
<if test="tableName == 'hrmresource'">
|
||||
and status < 4
|
||||
</if>
|
||||
<if test="tableName != 'hrmresource'">
|
||||
|
||||
</if>
|
||||
<if test="syncDate != null and syncDate !=''">
|
||||
and sync_date = #{syncDate}
|
||||
</if>
|
||||
</select>
|
||||
<select id="summaryResourceData" resultType="java.lang.Integer">
|
||||
select count(id)
|
||||
from ${tableName}
|
||||
where status < 4
|
||||
<if test="syncDate != null and syncDate !=''">
|
||||
and sync_date = #{syncDate}
|
||||
</if>
|
||||
</select>
|
||||
<select id="summaryCompanyData" resultType="java.lang.Integer">
|
||||
select count(id)
|
||||
from ${tableName}
|
||||
where isnull(canceled, '0') = '0'
|
||||
<if test="syncDate != null and syncDate !=''">
|
||||
and sync_date = #{syncDate}
|
||||
</if>
|
||||
</select>
|
||||
<select id="summaryDepartmentData" resultType="java.lang.Integer">
|
||||
select count(id)
|
||||
from ${tableName}
|
||||
where isnull(canceled, '0') = '0'
|
||||
<if test="syncDate != null and syncDate !=''">
|
||||
and sync_date = #{syncDate}
|
||||
</if>
|
||||
</select>
|
||||
<select id="getFieldLabel" resultType="java.lang.String">
|
||||
select a.fieldlabel
|
||||
from hrm_formfield a
|
||||
where a.FIELDNAME = #{fieldName}
|
||||
union all
|
||||
SELECT t1.fieldlable
|
||||
FROM cus_formfield t1,
|
||||
cus_formdict t2
|
||||
WHERE t1.fieldid = t2.id
|
||||
AND t1.scope = 'HrmCustomFieldByInfoType'
|
||||
and t1.SCOPEID = #{scopeId}
|
||||
and t2.fieldname = #{fieldName}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
package com.engine.organization.service;
|
||||
|
||||
import com.engine.organization.entity.danikor.param.ChartParam;
|
||||
import com.engine.organization.util.MenuBtn;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/01/17
|
||||
* @version: 1.0
|
||||
*/
|
||||
public interface DanikorResourceBackService {
|
||||
|
||||
/**
|
||||
* 人员回溯列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> listPage(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 获取搜索条件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getSearchCondition();
|
||||
|
||||
/**
|
||||
* 获取列表页面按钮信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Map<String, List<MenuBtn>> getHasRight();
|
||||
|
||||
/**
|
||||
* 获取汇总数据
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getSummaryData(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 组织架构图
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
String getOrgChartData(HttpServletRequest request, Map<String, Object> params);
|
||||
|
||||
List<ChartParam> getOrgChartData(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 人员架构图
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<ChartParam> getResourceChartData(Map<String, Object> params);
|
||||
}
|
||||
|
|
@ -0,0 +1,362 @@
|
|||
package com.engine.organization.service.impl;
|
||||
|
||||
import com.api.browser.bean.SearchConditionGroup;
|
||||
import com.api.browser.bean.SearchConditionItem;
|
||||
import com.cloudstore.eccom.constant.WeaBoolAttr;
|
||||
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
||||
import com.cloudstore.eccom.pc.table.WeaTableOperates;
|
||||
import com.cloudstore.eccom.result.WeaResultMsg;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.organization.component.OrganizationWeaTable;
|
||||
import com.engine.organization.entity.column.TableColumnPO;
|
||||
import com.engine.organization.entity.danikor.param.ChartParam;
|
||||
import com.engine.organization.entity.danikor.vo.ResourceBackVO;
|
||||
import com.engine.organization.manager.DanikorOrgChartManager;
|
||||
import com.engine.organization.mapper.danikor.DanikorResourceMapper;
|
||||
import com.engine.organization.service.DanikorResourceBackService;
|
||||
import com.engine.organization.util.MenuBtn;
|
||||
import com.engine.organization.util.OrganizationFormItemUtil;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.common.StringUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.appdetach.AppDetachComInfo;
|
||||
import weaver.hrm.chart.domain.HrmChartSet;
|
||||
import weaver.hrm.chart.domain.HrmCompanyVirtual;
|
||||
import weaver.hrm.chart.manager.HrmChartSetManager;
|
||||
import weaver.hrm.chart.manager.HrmCompanyVirtualManager;
|
||||
import weaver.hrm.company.CompanyComInfo;
|
||||
import weaver.hrm.companyvirtual.CompanyVirtualComInfo;
|
||||
import weaver.systeminfo.SystemEnv;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/01/17
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class DanikorResourceBackServiceImpl extends Service implements DanikorResourceBackService {
|
||||
|
||||
private DanikorResourceMapper getDanikorResourceMapper() {
|
||||
return MapperProxyFactory.getProxy(DanikorResourceMapper.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> listPage(Map<String, Object> params) {
|
||||
HrmResourceServiceImpl resourceService = ServiceUtil.getService(HrmResourceServiceImpl.class, user);
|
||||
OrganizationWeaTable<ResourceBackVO> table = new OrganizationWeaTable<>(user, ResourceBackVO.class);
|
||||
String syncDate = Util.null2String(params.get("syncDate"));
|
||||
String sqlForm = "from hrmresource t left join cus_fielddata t0 on t.id = t0.id and t0.scopeid ='-1' left join cus_fielddata t1 on t.id = t1.id and t1.scopeid ='1' left join cus_fielddata t2 on t.id = t2.id and t2.scopeid ='3' left join hrmjobtitles t3 on t.jobtitle=t3.id left join hrmjobactivities t4 on t3.jobactivityid=t4.id left join hrmjobgroups t5 on t4.jobgroupid=t5.id ";
|
||||
String sqlWhere = "where t.status < 4 ";
|
||||
String cusTableName = "cus_fielddata";
|
||||
if (StringUtils.isNotBlank(syncDate) && !DateUtil.getDate(new Date()).equals(syncDate)) {
|
||||
sqlWhere += " and t.sync_date = '" + syncDate + "'";
|
||||
sqlForm = "from hrmresource_back t left join cus_fielddata_back t0 on t.id = t0.id and t0.scopeid = '-1' and t.sync_date = t0.sync_date left join cus_fielddata_back t1 on t.id = t1.id and t1.scopeid = '1' and t.sync_date = t1.sync_date left join cus_fielddata_back t2 on t.id = t2.id and t2.scopeid = '3' and t.sync_date = t2.sync_date left join hrmjobtitles t3 on t.jobtitle = t3.id left join hrmjobactivities t4 on t3.jobactivityid = t4.id left join hrmjobgroups t5 on t4.jobgroupid = t5.id ";
|
||||
cusTableName = "cus_fielddata_back";
|
||||
}
|
||||
table.setSqlform(sqlForm);
|
||||
table.setSqlwhere(sqlWhere);
|
||||
table.setOperates(new WeaTableOperates());
|
||||
List<WeaTableColumn> weaTableColumnList = new ArrayList<>();
|
||||
List<String> fields = new ArrayList<>();
|
||||
List<SearchConditionGroup> allConditions = resourceService.getAllConditions();
|
||||
|
||||
//初次使用,无模板初始值
|
||||
String columns = "-1_hrm_lastname,-1_hrm_departmentid,-1_hrm_subcompanyid1,-1_hrm_jobtitle,-1_hrm_mobile,-1_hrm_telephone,-1_hrm_managerid,-1_hrm_dsporder";
|
||||
|
||||
List<String> cusFieldNames = getDanikorResourceMapper().getCusColumnByTableName(cusTableName).stream().map(TableColumnPO::getColumnName).collect(Collectors.toList());
|
||||
List<String> columnList = Arrays.asList(columns.split(","));
|
||||
BigDecimal decimal = new BigDecimal(100 / columnList.size());
|
||||
for (SearchConditionGroup allCondition : allConditions) {
|
||||
List<SearchConditionItem> items = allCondition.getItems();
|
||||
for (SearchConditionItem item : items) {
|
||||
String columnName = item.getDomkey()[0];
|
||||
String scopeId = columnName.split("_")[0];
|
||||
String fieldName = columnName.substring(columnName.lastIndexOf("_") + 1);
|
||||
if (columnName.contains("_cus_") && !cusFieldNames.contains(fieldName)) {
|
||||
continue;
|
||||
}
|
||||
fields.add(resourceService.buildTableSql(columnName) + " as " + resourceService.buildTableSql(columnName).replace(".", "_"));
|
||||
|
||||
WeaTableColumn weaTableColumn = new WeaTableColumn();
|
||||
String fieldLabel = getDanikorResourceMapper().getFieldLabel(fieldName, scopeId);
|
||||
try {
|
||||
fieldLabel = Util.toScreen(SystemEnv.getHtmlLabelName(Integer.parseInt(fieldLabel), user.getLanguage()), user.getLanguage());
|
||||
} catch (Exception e) {
|
||||
new BaseBean().errorLog("数据转换异常", e);
|
||||
}
|
||||
weaTableColumn.setText(fieldLabel);
|
||||
weaTableColumn.setColumn(resourceService.buildTableSql(columnName).replace(".", "_"));
|
||||
|
||||
weaTableColumn.setDisplay(columnList.contains(columnName) ? WeaBoolAttr.TRUE : WeaBoolAttr.FALSE);
|
||||
if ("-1_hrm_subcompanyid1".equals(columnName)) {
|
||||
weaTableColumn.setTransmethod("com.engine.organization.transmethod.HrmResourceTransMethod.getCompanyName");
|
||||
} else {
|
||||
weaTableColumn.setTransmethod("com.engine.organization.transmethod.HrmResourceTransMethod.getFieldTrueValue");
|
||||
}
|
||||
weaTableColumn.setOtherpara(columnName);
|
||||
weaTableColumn.setWidth(decimal.setScale(2, RoundingMode.HALF_UP).doubleValue() + "%");
|
||||
weaTableColumnList.add(weaTableColumn);
|
||||
}
|
||||
}
|
||||
|
||||
// 增加id字段,跳转人员卡片
|
||||
WeaTableColumn weaTableColumn = new WeaTableColumn();
|
||||
weaTableColumn.setColumn("id");
|
||||
weaTableColumn.setDisplay(WeaBoolAttr.FALSE);
|
||||
|
||||
weaTableColumnList.add(weaTableColumn);
|
||||
fields.add("t.id");
|
||||
table.setBackfields(StringUtils.join(fields, ","));
|
||||
table.setColumns(weaTableColumnList);
|
||||
WeaResultMsg result = new WeaResultMsg(false);
|
||||
result.putAll(table.makeDataResult());
|
||||
result.success();
|
||||
return new HashMap<>(result.getResultMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getSearchCondition() {
|
||||
Map<String, Object> apiDatas = new HashMap<>();
|
||||
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
||||
List<SearchConditionItem> conditionItems = new ArrayList<>();
|
||||
SearchConditionItem syncDate = OrganizationFormItemUtil.datePickerItem(user, 2, 16, false, 2, "查询时间", "syncDate");
|
||||
conditionItems.add(syncDate);
|
||||
addGroups.add(new SearchConditionGroup("高级搜索条件", true, conditionItems));
|
||||
apiDatas.put("conditions", addGroups);
|
||||
return apiDatas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<MenuBtn>> getHasRight() {
|
||||
Map<String, List<MenuBtn>> btnDatas = new HashMap<>();
|
||||
ArrayList<MenuBtn> rightMenuList = new ArrayList<>();
|
||||
// 显示列定制
|
||||
rightMenuList.add(MenuBtn.rightMenu_btnColumn());
|
||||
btnDatas.put("rightMenu", rightMenuList);
|
||||
return btnDatas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getSummaryData(Map<String, Object> params) {
|
||||
HashMap<String, Object> returnMap = new HashMap<>();
|
||||
String companyTable = "hrmsubcompany";
|
||||
String departmentTable = "hrmdepartment";
|
||||
String resourceTable = "hrmresource";
|
||||
String syncDate = Util.null2String(params.get("syncDate"));
|
||||
if (StringUtils.isNotBlank(syncDate) && !DateUtil.getDate(new Date()).equals(syncDate)) {
|
||||
companyTable += "_back";
|
||||
departmentTable += "_back";
|
||||
resourceTable += "_back";
|
||||
} else {
|
||||
syncDate = null;
|
||||
}
|
||||
returnMap.put("subcompany", getDanikorResourceMapper().summaryCompanyData(companyTable, syncDate));
|
||||
returnMap.put("department", getDanikorResourceMapper().summaryDepartmentData(departmentTable, syncDate));
|
||||
returnMap.put("person", getDanikorResourceMapper().summaryResourceData(resourceTable, syncDate));
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOrgChartData(HttpServletRequest request, Map<String, Object> params) {
|
||||
CompanyVirtualComInfo CompanyVirtualComInfo = new CompanyVirtualComInfo();
|
||||
CompanyComInfo CompanyComInfo = new CompanyComInfo();
|
||||
AppDetachComInfo AppDetachComInfo = new AppDetachComInfo();
|
||||
boolean isOutCustomer = AppDetachComInfo.isOutCustomer("" + user.getUID());//是否为外部用户
|
||||
String sorgid = Util.null2String((params.get("arg0")));
|
||||
int shownum = StringUtil.parseToInt(Util.null2String(params.get("arg1")), 1);
|
||||
String showName = Util.null2String(params.get("arg2"));
|
||||
|
||||
int showtype = Util.getIntValue(Util.null2String(params.get("showtype")), 0);
|
||||
Map beanMap = new HashMap<>();
|
||||
HrmChartSetManager HrmChartSetManager = new HrmChartSetManager();
|
||||
beanMap.put("is_sys", 1);
|
||||
HrmChartSet bean = HrmChartSetManager.get(beanMap);
|
||||
if (bean != null) {
|
||||
showtype = bean.getShowType();
|
||||
shownum = bean.getShowNum();
|
||||
}
|
||||
shownum = shownum <= 0 ? 1 : shownum;
|
||||
if (0 == showtype) shownum = 10000;
|
||||
|
||||
if (CompanyComInfo.next()) {
|
||||
showName = CompanyComInfo.getCompanyname();
|
||||
}
|
||||
if (isOutCustomer) {
|
||||
sorgid = "-10000";
|
||||
showName = CompanyVirtualComInfo.getVirtualType(sorgid);
|
||||
}
|
||||
|
||||
boolean isPOrg = Boolean.parseBoolean(Util.null2s(Util.null2String(params.get("arg3")), "true"));
|
||||
String arg4 = Util.null2s(Util.null2String(params.get("arg4")), "8");
|
||||
String arg5 = Util.null2String(params.get("arg5"));
|
||||
String arg6 = Util.null2String(params.get("arg6"));
|
||||
String arg7 = Util.null2String(params.get("arg7"));
|
||||
String arg8 = Util.null2String(params.get("arg8"));
|
||||
String arg9 = Util.null2String(params.get("arg9"));
|
||||
String arg10 = Util.null2String(params.get("arg10"));
|
||||
String arg11 = Util.null2s(Util.null2String(params.get("arg11")), ";;P");
|
||||
|
||||
HrmCompanyVirtualManager manager = new HrmCompanyVirtualManager();
|
||||
|
||||
HrmCompanyVirtual cvBean = null;
|
||||
if (!isPOrg) {
|
||||
cvBean = manager.get(sorgid);
|
||||
showName = cvBean != null ? cvBean.getVirtualtype() : "";
|
||||
}
|
||||
|
||||
//初始化tlevel
|
||||
new com.api.hrm.util.ServiceUtil().initOrgLevel();
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("status", arg4);
|
||||
map.put("docStatus", arg5);
|
||||
map.put("customerType", arg6);
|
||||
map.put("customerStatus", arg7);
|
||||
map.put("workType", arg8);
|
||||
map.put("projectStatus", arg9);
|
||||
|
||||
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.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;
|
||||
return "[" + "{\"id\":\"0\", \"pid\":\"\", \"type\":\"company\", \"name\":\"" + StringUtil.vString(showName, 12) + "\", \"title\":\"" + showName +
|
||||
"\", \"num\":\"" + showCount + "\", \"nTitle\":\"" + showTitle + "\", \"oDisplay\":\"none\", \"subRCount\":\"0\", \"subTitle\":\"\", \"cOnclick\":\"" + defaultHref + "\", \"sOnclick\":\"\"}" + chartManager.getData() +
|
||||
"]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ChartParam> getOrgChartData(Map<String, Object> params) {
|
||||
String syncDate = Util.null2String(params.get("date"));
|
||||
List<ChartParam> chartParamList = new ArrayList<>();
|
||||
String sorgid = Util.null2String((params.get("arg0")));
|
||||
String defaultHref = weaver.general.GCONST.getContextPath() + "/spa/hrm/index_mobx.html#/main/hrm/orgStaff?_fromURL=HrmResourceSearchResult&from=hrmorg&virtualtype=" + sorgid;
|
||||
CompanyComInfo CompanyComInfo = new CompanyComInfo();
|
||||
|
||||
if (CompanyComInfo.next()) {
|
||||
chartParamList.add(ChartParam.builder().id("0").pid("").type("company").name(CompanyComInfo.getCompanyname()).title(CompanyComInfo.getCompanyname()).num("0").nTitle("").oDisplay("none").subRCount("0").subTitle("").cOnclick(defaultHref).sOnclick("").build());
|
||||
}
|
||||
|
||||
String subCompanySql;
|
||||
String departmentSql;
|
||||
if (StringUtils.isNotBlank(syncDate) && !DateUtil.getDate(new Date()).equals(syncDate)) {
|
||||
subCompanySql = "select t.id, t.subcompanyname, t.supsubcomid, ( select distinct 1 as hasnext from hrmsubcompany_back s where (s.supsubcomid = t.id and (s.CANCELED IS NULL OR s.CANCELED != '1') and s.sync_date = '" + syncDate + "') ) as hassubnext, ( select distinct 1 as hasnext from HrmDepartment_back d where (d.subcompanyid1 = t.id and (d.CANCELED IS NULL OR d.CANCELED != '1') and d.sync_date = '" + syncDate + "')) as hasdeptnext, t.tlevel from hrmsubcompany_back t where (t.canceled IS NULL OR t.canceled != '1') and t.id != t.supsubcomid and tlevel <= 10000 and sync_date = '" + syncDate + "' order by t.supsubcomid, t.showorder, t.subcompanyname";
|
||||
departmentSql = "select t.id, t.departmentname, t.subcompanyid1, isnull(t.supdepid,0) as supdepid, (case when t.supdepid != 0 and ( select COUNT(id) from hrmdepartment_back where id = t.supdepid and sync_date = '" + syncDate + "')= 0 then 0 else 1 end) as isExist, ( select distinct 1 as hasnext from hrmdepartment_back d where d.supdepid = t.id and (CANCELED IS NULL OR CANCELED != '1') and sync_date = '" + syncDate + "') as hasnext, t.tlevel from hrmdepartment_back t where t.id != ISNULL(t.supdepid, 0) and SNULL(t.tlevel,0) <= 10000 and (t.canceled IS NULL OR t.canceled != '1') and (t.canceled IS NULL OR t.canceled != '1') and sync_date = '" + syncDate + "' order by t.subcompanyid1 asc , t.supdepid asc , t.showorder asc, t.departmentname asc";
|
||||
} else {
|
||||
subCompanySql = "select t.id,t.subcompanyname,t.supsubcomid,(select distinct 1 as hasnext from hrmsubcompany s where (s.supsubcomid=t.id and (s.CANCELED IS NULL OR s.CANCELED !='1')) ) as hassubnext,(select distinct 1 as hasnext from HrmDepartment d where (d.subcompanyid1=t.id and (d.CANCELED IS NULL OR d.CANCELED !='1')) ) as hasdeptnext,t.tlevel from hrmsubcompany t where (t.canceled IS NULL OR t.canceled !='1') and t.id != t.supsubcomid and tlevel <= 10000 order by t.supsubcomid,t.showorder,t.subcompanyname";
|
||||
departmentSql = "select t.id,t.departmentname,t.subcompanyid1,isnull(t.supdepid,0) as supdepid,(case when t.supdepid != 0 and (select COUNT(id) from hrmdepartment where id = t.supdepid)=0 then 0 else 1 end) as isExist,(select distinct 1 as hasnext from hrmdepartment d where d.supdepid=t.id and (CANCELED IS NULL OR CANCELED !='1')) as hasnext,t.tlevel from hrmdepartment t where t.id != ISNULL(t.supdepid,0) and ISNULL(t.tlevel,0) <= 10000 and (t.canceled IS NULL OR t.canceled !='1') order by t.subcompanyid1 asc , t.supdepid asc , t.showorder asc, t.departmentname asc";
|
||||
}
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
//rs.execute(subCompanySql);
|
||||
//while (rs.next()) {
|
||||
// int subHasNext = rs.getInt("hassubnext");
|
||||
// int deptHasNext = rs.getInt("hasdeptnext");
|
||||
// ChartParam chartParam = new ChartParam();
|
||||
// chartParam.setId(rs.getString("id"));
|
||||
// chartParam.setPid(rs.getString("supsubcomid"));
|
||||
// chartParam.setType("subcompany");
|
||||
// chartParam.setName(rs.getString("subcompanyname"));
|
||||
// chartParam.setTitle(chartParam.getName());
|
||||
// chartParam.setNum("0");
|
||||
// chartParam.setNTitle("");
|
||||
// chartParam.setODisplay("none");
|
||||
// chartParam.setSubRCount("0");
|
||||
// chartParam.setSubTitle("");
|
||||
// chartParam.setHasChild(subHasNext == 1 || deptHasNext == 1 ? "true" : "false");
|
||||
// chartParam.setNeedPlus("false");
|
||||
// chartParam.setCOnclick("");
|
||||
// chartParam.setSOnclick("");
|
||||
// chartParamList.add(chartParam);
|
||||
//}
|
||||
|
||||
// 处理部门数据
|
||||
rs.execute(departmentSql);
|
||||
while (rs.next()) {
|
||||
int hasNext = rs.getInt("hasnext");
|
||||
ChartParam chartParam = new ChartParam();
|
||||
chartParam.setId(rs.getString("id"));
|
||||
chartParam.setPid(rs.getString("supdepid"));
|
||||
chartParam.setType("dept");
|
||||
chartParam.setName(rs.getString("departmentname"));
|
||||
chartParam.setTitle(chartParam.getName());
|
||||
chartParam.setNum("0");
|
||||
chartParam.setNTitle("");
|
||||
chartParam.setODisplay("none");
|
||||
chartParam.setSubRCount("0");
|
||||
chartParam.setSubTitle("");
|
||||
chartParam.setHasChild(hasNext == 1 ? "true" : "false");
|
||||
chartParam.setNeedPlus("false");
|
||||
chartParam.setCOnclick("");
|
||||
chartParam.setSOnclick("");
|
||||
chartParamList.add(chartParam);
|
||||
}
|
||||
|
||||
return chartParamList;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ChartParam> getResourceChartData(Map<String, Object> params) {
|
||||
String syncDate = Util.null2String(params.get("date"));
|
||||
String secLevel = Util.null2String(params.get("secLevel"));
|
||||
if (StringUtils.isBlank(secLevel)) {
|
||||
secLevel = "40";
|
||||
}
|
||||
List<ChartParam> chartParamList = new ArrayList<>();
|
||||
// 查询安全级别大于等于40的人员
|
||||
String sql;
|
||||
if (StringUtils.isNotBlank(syncDate) && !DateUtil.getDate(new Date()).equals(syncDate)) {
|
||||
sql = "select a.id, a.managerid , a.lastname , b.jobtitlename, ( select count(1) from HrmResource_back where managerid = a.id and and seclevel >= " + secLevel + " and sync_date = '" + syncDate + "') subordinate from HrmResource_back a left join HrmJobTitles b on a.jobtitle = b.id where a.status < 4 and seclevel >= " + secLevel + " and sync_date = '" + syncDate + "'";
|
||||
} else {
|
||||
sql = "select a.id, a.managerid , a.lastname , b.jobtitlename, ( select count(1) from HrmResource where managerid = a.id and seclevel >= " + secLevel + ") subordinate from HrmResource a left join HrmJobTitles b on a.jobtitle = b.id where a.status < 4 and seclevel >= " + secLevel;
|
||||
}
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
String lastName = rs.getString("lastname");
|
||||
String jobTitleName = rs.getString("jobtitlename");
|
||||
int subordinate = rs.getInt("subordinate");
|
||||
String managerId = rs.getString("managerid");
|
||||
ChartParam chartParam = new ChartParam();
|
||||
chartParam.setId(rs.getString("id"));
|
||||
chartParam.setPid(managerId);
|
||||
chartParam.setType((StringUtils.isBlank(managerId) || "0".equals(managerId)) ? "company" : "dept");
|
||||
chartParam.setName(StringUtils.isBlank(jobTitleName) ? lastName : lastName + "<br/><span style=\"line-height: 20px!important;\">" + jobTitleName + "</span>");
|
||||
chartParam.setTitle(lastName);
|
||||
chartParam.setNum("0");
|
||||
chartParam.setNTitle("");
|
||||
chartParam.setODisplay("none");
|
||||
chartParam.setSubRCount("0");
|
||||
chartParam.setSubTitle("");
|
||||
chartParam.setHasChild(subordinate > 0 ? "true" : "false");
|
||||
chartParam.setNeedPlus("false");
|
||||
chartParam.setCOnclick("");
|
||||
chartParam.setSOnclick("");
|
||||
chartParamList.add(chartParam);
|
||||
}
|
||||
|
||||
return chartParamList;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -86,8 +86,8 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
|
|||
|
||||
private static final String RIGHT_NAME = "Roster:All";
|
||||
|
||||
private static final String level = getFieldName("职等");
|
||||
private static final String grade = getFieldName("职级");
|
||||
//private static final String level = getFieldName("职等");
|
||||
//private static final String grade = getFieldName("职级");
|
||||
|
||||
private HrmRelationMapper getHrmRelationMapper() {
|
||||
return MapperProxyFactory.getProxy(HrmRelationMapper.class);
|
||||
|
|
@ -155,7 +155,7 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
|
|||
}
|
||||
} else {
|
||||
//初次使用,无模板初始值
|
||||
columns = "-1_hrm_lastname,-1_hrm_departmentid,-1_hrm_subcompanyid1,-1_hrm_jobtitle,-1_hrm_mobile,-1_hrm_telephone,-1_hrm_managerid,-1_hrm_sporder";
|
||||
columns = "-1_hrm_lastname,-1_hrm_departmentid,-1_hrm_subcompanyid1,-1_hrm_jobtitle,-1_hrm_mobile,-1_hrm_telephone,-1_hrm_managerid,-1_hrm_dsporder";
|
||||
}
|
||||
|
||||
List<String> columnList = Arrays.asList(columns.split(","));
|
||||
|
|
@ -173,30 +173,19 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
|
|||
weaTableColumn.setColumn(buildTableSql(columnName).replace(".", "_"));
|
||||
|
||||
weaTableColumn.setDisplay(columnList.contains(columnName) ? WeaBoolAttr.TRUE : WeaBoolAttr.FALSE);
|
||||
weaTableColumn.setTransmethod("com.engine.organization.transmethod.HrmResourceTransMethod.getFieldTrueValue");
|
||||
if ("-1_hrm_subcompanyid1".equals(columnName)) {
|
||||
weaTableColumn.setTransmethod("com.engine.organization.transmethod.HrmResourceTransMethod.getCompanyName");
|
||||
} else {
|
||||
weaTableColumn.setTransmethod("com.engine.organization.transmethod.HrmResourceTransMethod.getFieldTrueValue");
|
||||
}
|
||||
weaTableColumn.setOtherpara(columnName);
|
||||
weaTableColumn.setWidth(decimal.setScale(2, RoundingMode.HALF_UP).doubleValue() + "%");
|
||||
weaTableColumnList.add(weaTableColumn);
|
||||
}
|
||||
}
|
||||
// if (StringUtils.isNotBlank(columns)) {
|
||||
// String[] tmp = columns.split(",");
|
||||
// for (int i = 0; i < tmp.length; i++) {
|
||||
// String scopeId = tmp[i].split("_")[0];
|
||||
// String fieldName = tmp[i].substring(tmp[i].lastIndexOf("_") + 1);
|
||||
// WeaTableColumn weaTableColumn = new WeaTableColumn();
|
||||
// weaTableColumn.setText(getHrmResourceMapper().queryLabelName(fieldName, scopeId));
|
||||
// weaTableColumn.setColumn(buildTableSql(tmp[i]).replace(".", "_"));
|
||||
// weaTableColumn.setDisplay(WeaBoolAttr.TRUE);
|
||||
// weaTableColumn.setTransmethod("com.engine.organization.transmethod.HrmResourceTransMethod.getFieldTrueValue");
|
||||
// String param = tmp[i];
|
||||
// weaTableColumn.setOtherpara(param);
|
||||
// weaTableColumnList.add(weaTableColumn);
|
||||
// }
|
||||
// }
|
||||
|
||||
// 增加id字段,跳转人员卡片
|
||||
WeaTableColumn weaTableColumn = new WeaTableColumn();
|
||||
// weaTableColumn.setText("id");
|
||||
weaTableColumn.setColumn("id");
|
||||
weaTableColumn.setDisplay(WeaBoolAttr.FALSE);
|
||||
|
||||
|
|
@ -875,6 +864,20 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
|
|||
List<CusFormFieldPO> hrmFieldsByScopeId = getSystemDataMapper().getHrmFieldsByScopeId(HrmGroupEnum.HRM_BASIC.getGroupType().toString());
|
||||
createConditionItems(hrmFieldSearchConditionComInfo, hrmFieldsByScopeId, basicConditionItems);
|
||||
if (CollectionUtils.isNotEmpty(basicConditionItems)) {
|
||||
|
||||
HrmFieldBean hrmFieldBean = new HrmFieldBean();
|
||||
//hrmFieldBean.setFieldid(Util.null2String(cusFormFieldPO.getFieldId()));
|
||||
hrmFieldBean.setFieldname("-1_hrm_subcompanyid1");
|
||||
hrmFieldBean.setFieldlabel("-2458");
|
||||
hrmFieldBean.setFieldhtmltype("3");
|
||||
hrmFieldBean.setType("164");
|
||||
hrmFieldBean.setIsQuickSearch(false);
|
||||
hrmFieldBean.setIsScope(false);
|
||||
hrmFieldBean.setDmlurl("");
|
||||
hrmFieldBean.setIssystem("1");
|
||||
hrmFieldBean.setIsFormField(true);
|
||||
SearchConditionItem searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
|
||||
basicConditionItems.add(searchConditionItem);
|
||||
addGroups.add(new SearchConditionGroup("基本信息", true, basicConditionItems));
|
||||
}
|
||||
|
||||
|
|
@ -1113,7 +1116,7 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
|
|||
* @param key
|
||||
* @return
|
||||
*/
|
||||
private String buildTableSql(String key) {
|
||||
public String buildTableSql(String key) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String[] s = key.split("_");
|
||||
if (s.length < 3) {
|
||||
|
|
@ -1194,13 +1197,13 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
|
|||
return selectKeys;
|
||||
}
|
||||
|
||||
private static 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 static 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;
|
||||
//}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import com.engine.organization.mapper.department.DepartmentMapper;
|
|||
import com.engine.organization.mapper.hrmresource.SystemDataMapper;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import org.json.JSONObject;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.definedfield.HrmFieldManager;
|
||||
|
||||
|
|
@ -40,6 +39,9 @@ public class HrmResourceTransMethod {
|
|||
public static String getCompanyName(String companyId) {
|
||||
return MapperProxyFactory.getProxy(CompMapper.class).listById(Integer.parseInt(companyId)).getSubCompanyName();
|
||||
}
|
||||
public static String getCompanyName(String companyId, String para) {
|
||||
return MapperProxyFactory.getProxy(CompMapper.class).listById(Integer.parseInt(companyId)).getSubCompanyName();
|
||||
}
|
||||
|
||||
public static String getJobName(String jobTitle) {
|
||||
return JobBO.getJobTitleNameByEcJobTitle(jobTitle);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,128 @@
|
|||
package com.engine.organization.web;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.engine.common.util.ParamUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.organization.entity.danikor.param.ChartParam;
|
||||
import com.engine.organization.util.response.ReturnResult;
|
||||
import com.engine.organization.wrapper.DanikorResourceBackWrapper;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/01/28
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class DanikorResourceBackController {
|
||||
|
||||
public DanikorResourceBackWrapper getDanikorResourceBackWrapper(User user) {
|
||||
return ServiceUtil.getService(DanikorResourceBackWrapper.class, user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取list列表
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@GET
|
||||
@Path("/listPage")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ReturnResult listPage(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
Map<String, Object> map = ParamUtil.request2Map(request);
|
||||
return ReturnResult.successed(getDanikorResourceBackWrapper(user).listPage(map));
|
||||
} catch (Exception e) {
|
||||
return ReturnResult.exceptionHandle(e);
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/getSearchCondition")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ReturnResult getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ReturnResult.successed(getDanikorResourceBackWrapper(user).getSearchCondition());
|
||||
} catch (Exception e) {
|
||||
return ReturnResult.exceptionHandle(e);
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/getHasRight")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ReturnResult getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ReturnResult.successed(getDanikorResourceBackWrapper(user).getHasRight());
|
||||
} catch (Exception e) {
|
||||
return ReturnResult.exceptionHandle(e);
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/getSummaryData")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ReturnResult getSummaryData(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
Map<String, Object> map = ParamUtil.request2Map(request);
|
||||
return ReturnResult.successed(getDanikorResourceBackWrapper(user).getSummaryData(map));
|
||||
} catch (Exception e) {
|
||||
return ReturnResult.exceptionHandle(e);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/getOrgChartData")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Map<String, Object> getOrgChartData(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
Map<String, Object> returnMap = new HashMap<>();
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
Map<String, Object> map = ParamUtil.request2Map(request);
|
||||
String orgChartData = getDanikorResourceBackWrapper(user).getOrgChartData(map);
|
||||
returnMap.put("data", orgChartData);
|
||||
returnMap.put("status", "1");
|
||||
} catch (Exception e) {
|
||||
returnMap.put("status", "-1");
|
||||
returnMap.put("message", "发生未知错误,请与管理员联系");
|
||||
}
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/getResourceChartData")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Map<String, Object> getResourceChartData(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
Map<String, Object> returnMap = new HashMap<>();
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
Map<String, Object> map = ParamUtil.request2Map(request);
|
||||
List<ChartParam> resourceChartData = getDanikorResourceBackWrapper(user).getResourceChartData(map);
|
||||
returnMap.put("data", CollectionUtils.isEmpty(resourceChartData) ? null : JSON.toJSONString(resourceChartData));
|
||||
returnMap.put("status", "1");
|
||||
} catch (Exception e) {
|
||||
returnMap.put("status", "-1");
|
||||
returnMap.put("message", "发生未知错误,请与管理员联系");
|
||||
}
|
||||
return returnMap;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package com.engine.organization.wrapper;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.organization.entity.danikor.param.ChartParam;
|
||||
import com.engine.organization.service.DanikorResourceBackService;
|
||||
import com.engine.organization.service.impl.DanikorResourceBackServiceImpl;
|
||||
import com.engine.organization.util.MenuBtn;
|
||||
import com.engine.organization.util.OrganizationWrapper;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/01/28
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class DanikorResourceBackWrapper extends OrganizationWrapper {
|
||||
|
||||
private DanikorResourceBackService getDanikorResourceBackService(User user) {
|
||||
return ServiceUtil.getService(DanikorResourceBackServiceImpl.class, user);
|
||||
}
|
||||
|
||||
public Map<String, Object> listPage(Map<String, Object> params) {
|
||||
return getDanikorResourceBackService(user).listPage(params);
|
||||
}
|
||||
|
||||
public Map<String, Object> getSearchCondition() {
|
||||
return getDanikorResourceBackService(user).getSearchCondition();
|
||||
}
|
||||
|
||||
public Map<String, List<MenuBtn>> getHasRight() {
|
||||
return getDanikorResourceBackService(user).getHasRight();
|
||||
}
|
||||
|
||||
public Map<String, Object> getSummaryData(Map<String, Object> params) {
|
||||
return getDanikorResourceBackService(user).getSummaryData(params);
|
||||
}
|
||||
|
||||
public String getOrgChartData(Map<String, Object> params) {
|
||||
return JSON.toJSONString(getDanikorResourceBackService(user).getOrgChartData(params));
|
||||
}
|
||||
|
||||
public List<ChartParam> getResourceChartData(Map<String, Object> params) {
|
||||
return getDanikorResourceBackService(user).getResourceChartData(params);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue