feature/dxf #196

Merged
dxfeng merged 3 commits from feature/dxf into develop 2 years ago

@ -78,10 +78,12 @@ public class JobBrowserService extends BrowserService {
String q = Util.null2String(httpServletRequest.getParameter("q")); String q = Util.null2String(httpServletRequest.getParameter("q"));
List<String> sqlParams = new ArrayList<>(); List<String> sqlParams = new ArrayList<>();
String keyword = ""; String keyword = "";
if (q.length() > 0) keyword = "%" + q + "%"; if (q.length() > 0) {
keyword = "%" + q + "%";
}
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
String sqlwhere = " where t.delete_type = 0 "; String sqlwhere = " where t.delete_type = 0 ";
String backfields = "t.id, t.job_no, h.jobtitlename as name, t.sequence_id, t.scheme_id , t.grade_id , t.level_id "; String backfields = "t.id, t.job_no, h.jobtitlename as name ";
String fromSql = "FROM jcl_org_job t left join hrmjobtitles h on t.ec_jobTitle = h.id "; String fromSql = "FROM jcl_org_job t left join hrmjobtitles h on t.ec_jobTitle = h.id ";
String orderby = " order by t.id "; String orderby = " order by t.id ";
sqlwhere += " "; sqlwhere += " ";
@ -99,7 +101,7 @@ public class JobBrowserService extends BrowserService {
rs.executeQuery(sql, sqlParams); rs.executeQuery(sql, sqlParams);
List<Map<String, String>> datas = new ArrayList<>(); List<Map<String, String>> datas = new ArrayList<>();
while (rs.next()) { while (rs.next()) {
Map<String, String> item = new HashMap<>(); Map<String, String> item = new HashMap<>(3);
item.put("id", Util.null2String(rs.getString("id"))); item.put("id", Util.null2String(rs.getString("id")));
String name = Util.null2String(rs.getString("name")); String name = Util.null2String(rs.getString("name"));
item.put("name", name); item.put("name", name);

@ -85,13 +85,10 @@ public class JobBO {
.jobTitleName(e.getJobTitleName()) .jobTitleName(e.getJobTitleName())
.subCompanyName(e.getSubCompanyName()) .subCompanyName(e.getSubCompanyName())
.departmentName(e.getDepartmentName()) .departmentName(e.getDepartmentName())
//.sequenceName(e.getSequenceName()) .jobGroupName(e.getJobGroupName())
//.schemeName(e.getSchemeName()) .jobActivityName(e.getJobActivityName())
//.parentJob(e.getParentJob())
//.parentJobName(null == poMaps.get(e.getParentJob()) ? "" : poMaps.get(e.getParentJob()).getJobName())
.isKey(JobTransMethod.getIsKeySpan(e.getIsKey())) .isKey(JobTransMethod.getIsKeySpan(e.getIsKey()))
.showOrder(e.getShowOrder()) .showOrder(e.getShowOrder())
//.forbiddenTag(e.getForbiddenTag())
.isUsed(0) .isUsed(0)
.build()).collect(Collectors.toList()); .build()).collect(Collectors.toList());
List<String> usedIds = MapperProxyFactory.getProxy(JobMapper.class).listUsedId(); List<String> usedIds = MapperProxyFactory.getProxy(JobMapper.class).listUsedId();

@ -51,16 +51,18 @@ public class JobListDTO {
*/ */
@TableTitle(title = "所属部门", dataIndex = "departmentName", key = "departmentName") @TableTitle(title = "所属部门", dataIndex = "departmentName", key = "departmentName")
private String departmentName; private String departmentName;
/** /**
* *
*/ */
//@TableTitle(title = "岗位序列", dataIndex = "sequenceName", key = "sequenceName") @TableTitle(title = "职务类别", dataIndex = "jobGroupName", key = "jobGroupName")
//private String sequenceName; private String jobGroupName;
/** /**
* *
*/ */
//@TableTitle(title = "等级方案", dataIndex = "schemeName", key = "schemeName") @TableTitle(title = "所属职务", dataIndex = "jobActivityName", key = "jobActivityName")
//private String schemeName; private String jobActivityName;
/** /**
* *
*/ */

@ -19,8 +19,11 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@OrganizationTable(pageId = "98e9c62f-cd12-11ec-a15f-00ffcbed7123", @OrganizationTable(pageId = "98e9c62f-cd12-11ec-a15f-00ffcbed7123",
fields = "t.id, t.job_no, h.jobtitlename as name, t.sequence_id, t.scheme_id , t.grade_id , t.level_id", fields = "t.id, t.job_no, h.jobtitlename as name, t.sequence_id, t.scheme_id , t.grade_id , t.level_id , e.jobactivityname, f.jobgroupname ",
fromSql = "FROM jcl_org_job t left join hrmjobtitles h on t.ec_jobTitle = h.id ", fromSql = "FROM jcl_org_job t" +
" left join hrmjobtitles h on t.ec_jobTitle = h.id" +
" left join hrmjobactivities e on h.jobactivityid =e.id" +
" left join hrmjobgroups f on e.jobgroupid =f.id ",
orderby = "id", orderby = "id",
sortway = "asc", sortway = "asc",
primarykey = "id", primarykey = "id",
@ -41,6 +44,13 @@ public class JobBrowserVO {
@OrganizationTableColumn(text = "岗位名称", width = "25%", column = "name") @OrganizationTableColumn(text = "岗位名称", width = "25%", column = "name")
private String jobName; private String jobName;
@OrganizationTableColumn(text = "职务类别", width = "25%", column = "jobGroupName")
private String jobGroupName;
@OrganizationTableColumn(text = "所属职务", width = "25%", column = "jobActivityName")
private String jobActivityName;
//@OrganizationTableColumn(text = "等级方案", width = "25%", column = "scheme_id", transmethod = "com.engine.organization.transmethod.JobTransMethod.getSchemeName") //@OrganizationTableColumn(text = "等级方案", width = "25%", column = "scheme_id", transmethod = "com.engine.organization.transmethod.JobTransMethod.getSchemeName")
//private String schemeName; //private String schemeName;
//@OrganizationTableColumn(text = "职等", width = "25%", column = "level_id", transmethod = "com.engine.organization.transmethod.JobTransMethod.getLevelName") //@OrganizationTableColumn(text = "职等", width = "25%", column = "level_id", transmethod = "com.engine.organization.transmethod.JobTransMethod.getLevelName")

@ -374,6 +374,8 @@
b.departmentname , b.departmentname ,
c.sequence_name, c.sequence_name,
d.scheme_name, d.scheme_name,
e.jobactivityname,
f.jobgroupname,
<include refid="baseColumns"/> <include refid="baseColumns"/>
FROM jcl_org_job t FROM jcl_org_job t
left join hrmsubcompany a on left join hrmsubcompany a on
@ -385,6 +387,8 @@
left join jcl_org_scheme d on left join jcl_org_scheme d on
t.scheme_id = d.id t.scheme_id = d.id
left join hrmjobtitles h on t.ec_jobTitle = h.id left join hrmjobtitles h on t.ec_jobTitle = h.id
left join hrmjobactivities e on h.jobactivityid =e.id
left join hrmjobgroups f on e.jobgroupid =f.id
WHERE t.delete_type = 0 order by ${orderSql} WHERE t.delete_type = 0 order by ${orderSql}
</select> </select>

@ -47,4 +47,12 @@ public interface ChartService {
* @return * @return
*/ */
Map<String, Object> versionRecord(Map<String, Object> params, User user); Map<String, Object> versionRecord(Map<String, Object> params, User user);
/**
*
*
* @param params
* @return
*/
Map<String, Object> getDepartmentTree(Map<String, Object> params);
} }

@ -3,6 +3,7 @@ package com.engine.organization.service.impl;
import com.engine.common.util.ServiceUtil; import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service; import com.engine.core.impl.Service;
import com.engine.organization.entity.chart.ChartPO; import com.engine.organization.entity.chart.ChartPO;
import com.engine.organization.entity.chart.CompanyTreePO;
import com.engine.organization.mapper.hrmresource.SystemDataMapper; import com.engine.organization.mapper.hrmresource.SystemDataMapper;
import com.engine.organization.mapper.jclorgmap.JclOrgMapper; import com.engine.organization.mapper.jclorgmap.JclOrgMapper;
import com.engine.organization.service.ChartService; import com.engine.organization.service.ChartService;
@ -10,6 +11,7 @@ import com.engine.organization.service.OrgChartService;
import com.engine.organization.util.HasRightUtil; import com.engine.organization.util.HasRightUtil;
import com.engine.organization.util.OrganizationAssert; import com.engine.organization.util.OrganizationAssert;
import com.engine.organization.util.OrganizationDateUtil; import com.engine.organization.util.OrganizationDateUtil;
import com.engine.organization.util.db.DBType;
import com.engine.organization.util.db.MapperProxyFactory; import com.engine.organization.util.db.MapperProxyFactory;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -446,6 +448,29 @@ public class ChartServiceImpl extends Service implements ChartService {
result.put("api_status", true); result.put("api_status", true);
return result; return result;
} }
@Override
public Map<String, Object> getDepartmentTree(Map<String, Object> params) {
Map<String, Object> result = new HashMap<>(2);
RecordSet rs = new RecordSet();
List<CompanyTreePO> departmentTree = new ArrayList<>();
String subCompany = Util.null2String(params.get("subcompany"));
String dimension = Util.null2String(params.get("fclass"));
String versionId = Util.null2String(params.get("id"));
if (StringUtils.isBlank(subCompany)) {
subCompany = "0";
}
String sql = getDepartmentTreeSql(versionId, dimension, subCompany);
rs.executeQuery(sql);
while (rs.next()) {
departmentTree.add(CompanyTreePO.builder().id(rs.getString("id")).pId(rs.getString("pId")).value(rs.getString("value")).title(rs.getString("title")).isLeaf(judgeTreeLeaf(versionId, dimension, rs.getString("id"))).build());
}
result.put("companyTree", departmentTree);
result.put("api_status", true);
return result;
}
private void trueDimension(RecordSetTrans recordSetTrans,String versionId,String currentUser,String currentDate){ private void trueDimension(RecordSetTrans recordSetTrans,String versionId,String currentUser,String currentDate){
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
rs.execute("delete from jcl_chart_subcompany where versionid = "+versionId); rs.execute("delete from jcl_chart_subcompany where versionid = "+versionId);
@ -1184,4 +1209,79 @@ public class ChartServiceImpl extends Service implements ChartService {
} }
return 0; return 0;
} }
/**
* SQL
*
* @param versionId ID
* @param dimension
* @param subCompany Id
* @return SQL
*/
private String getDepartmentTreeSql(String versionId, String dimension, String subCompany) {
// 是否展示当前数据
boolean isSearchCurrent = StringUtils.isBlank(versionId) || "0".equals(versionId);
boolean isCurrentDimension = StringUtils.isNotBlank(dimension) && !"0".equals(dimension);
boolean isDepartment = subCompany.startsWith("d");
String sql;
DBType dbType = DBType.get(new RecordSet().getDBType());
if (isDepartment) {
subCompany = subCompany.replace("d", "");
if (isSearchCurrent) {
sql = "select " + dbType.concat("d", "id") + "as id, id as value, departmentname as title, " + dbType.concat("d", "supdepid") + " as pId from hrmdepartment where (canceled is null or canceled != '1') and " + dbType.ifNull("supdepid", "0") + " = " + subCompany;
if (isCurrentDimension) {
sql = "select " + dbType.concat("d", "id") + "as id, id as value, departmentname as title, " + dbType.concat("d", "supdepid") + " as pId from hrmdepartmentvirtual where (canceled is null or canceled != '1') and " + dbType.ifNull("supdepid", "0") + " = " + subCompany;
}
} else {
sql = "select " + dbType.concat("d", "departmentid") + "as id, departmentid as value, departmentname as title, " + dbType.concat("d", "supdepartmentid") + " as pId from jcl_chart_department where (canceled is null or canceled != '1') and " + dbType.ifNull("supdepartmentid", "0") + " = " + subCompany;
if (isCurrentDimension) {
sql = "select " + dbType.concat("d", "departmentvirtualid") + "as id, departmentvirtualid as value, departmentname as title, " + dbType.concat("d", "supdepid") + " as pId from jcl_chart_departmentvirtual where (canceled is null or canceled != '1') and " + dbType.ifNull("supdepid", "0") + " = " + subCompany;
}
// 添加时间轴条件
sql += " and versionid = " + versionId;
}
} else {
if (isSearchCurrent) {
sql = "select id as id, id as value, subcompanyname as title, supsubcomid as pId from hrmsubcompany where (canceled is null or canceled != '1') and " + dbType.ifNull("supsubcomid", "0") + " = " + subCompany +
" union select " + dbType.concat("d", "id") + "as id, id as value, departmentname as title, subcompanyid1 as pId from hrmdepartment where (canceled is null or canceled != '1') and " + dbType.ifNull("subcompanyid1", "0") + " = " + subCompany;
if (isCurrentDimension) {
sql = "select id as id, id as value, subcompanyname as title, supsubcomid as pId from hrmsubcompanyvirtual where (canceled is null or canceled != '1') and " + dbType.ifNull("supsubcomid", "0") + " = " + subCompany + " and companyid = '" + dimension + "' " +
" union select " + dbType.concat("d", "id") + "as id, id as value, departmentname as title, subcompanyid1 as pId from hrmdepartmentvirtual where (canceled is null or canceled != '1') and " + dbType.ifNull("subcompanyid1", "0") + " = " + subCompany;
}
} else {
sql = "select subcompanyid as id, subcompanyid as value, subcompanyname as title, supsubcompanyid as pId from jcl_chart_subcompany where (canceled is null or canceled != '1') and " + dbType.ifNull("supsubcompanyid", "0") + " = " + subCompany +
" union select " + dbType.concat("d", "subcompanyid") + "as id, subcompanyid as value, departmentname as title, subcompanyid as pId from jcl_chart_department where (canceled is null or canceled != '1') and " + dbType.ifNull("subcompanyid", "0") + " = " + subCompany;
if (isCurrentDimension) {
sql = "select subcompanyvirtualid as id, subcompanyvirtualid as value, subcompanyname as title, supsubcompanyid as pId from jcl_chart_subcompanyvirtual where (canceled is null or canceled != '1') and " + dbType.ifNull("supsubcompanyid", "0") + " = " + subCompany + " and companyid = '" + dimension + "' " +
" union select " + dbType.concat("d", "departmentvirtualid") + "as id, departmentvirtualid as value, departmentname as title, subcompanyid as pId from jcl_chart_departmentvirtual where (canceled is null or canceled != '1') and " + dbType.ifNull("subcompanyid", "0") + " = " + subCompany;
}
// 添加时间轴条件
sql += " and versionid = " + versionId;
}
}
return sql;
}
/**
*
*
* @param sql SQL
* @param treeId ID
* @return
*/
/**
*
* @param versionId ID
* @param dimension
* @param subCompany ID
* @return
*/
private boolean judgeTreeLeaf(String versionId, String dimension, String subCompany) {
RecordSet recordSet = new RecordSet();
String sql = getDepartmentTreeSql(versionId, dimension, subCompany);
recordSet.executeQuery(sql);
return !recordSet.next();
}
} }

@ -25,6 +25,7 @@ import com.weaver.general.BaseBean;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import weaver.general.Util;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -157,11 +158,11 @@ public class ManagerDetachServiceImpl extends Service implements ManagerDetachSe
private String buildSqlWhere(Map<String, Object> params) { private String buildSqlWhere(Map<String, Object> params) {
DBType dbType = DBType.get(new RecordSet().getDBType()); DBType dbType = DBType.get(new RecordSet().getDBType());
String sqlWhere = " where delete_type = 0"; String sqlWhere = " where delete_type = 0";
String lastName = (String) params.get("ecManager"); String lastName = Util.null2String(params.get("ecManager"));
List<Long> resourceIds = MapperProxyFactory.getProxy(EmployeeMapper.class).getResourceIds(lastName);
String ecManager = StringUtils.join(resourceIds,",");
if (StringUtils.isNotBlank(lastName)) { if (StringUtils.isNotBlank(lastName)) {
sqlWhere += " AND ec_manager in ("+ecManager+") "; List<Long> resourceIds = MapperProxyFactory.getProxy(EmployeeMapper.class).getResourceIds(lastName);
String ecManager = StringUtils.join(resourceIds, ",");
sqlWhere += " AND ec_manager in (" + (StringUtils.isBlank(ecManager) ? "''" : ecManager) + ") ";
} }
String ecRolelevel = (String) params.get("ecRolelevel"); String ecRolelevel = (String) params.get("ecRolelevel");
if (StringUtils.isNotBlank(ecRolelevel)) { if (StringUtils.isNotBlank(ecRolelevel)) {

@ -132,8 +132,8 @@ public class StaffServiceImpl extends Service implements StaffService {
checkRequired(staffPO); checkRequired(staffPO);
int ignoreNull = getStaffMapper().insertIgnoreNull(staffPO); int ignoreNull = getStaffMapper().insertIgnoreNull(staffPO);
// 同步组织架构图编制信息 // 初始化编制在编数
//new StaffTriggerRunnable(staffPO).run(); initStaffInfo(staffPO);
return ignoreNull; return ignoreNull;
} }
@ -458,4 +458,35 @@ public class StaffServiceImpl extends Service implements StaffService {
} }
} }
/**
*
*
* @param staffPO
*/
public static void initStaffInfo(StaffPO staffPO) {
RecordSet rs = new RecordSet();
String sql = "select count(1) as num from hrmresource where STATUS < 4";
if (null != staffPO.getEcCompany() && 0 != staffPO.getEcCompany()) {
sql += " and subcompanyid1 = " + staffPO.getEcCompany();
}
if (null != staffPO.getEcDepartment() && 0 != staffPO.getEcDepartment()) {
sql += " and departmentid = " + staffPO.getEcDepartment();
}
if (null != staffPO.getJobId() && 0 != staffPO.getJobId()) {
JobPO jobById = MapperProxyFactory.getProxy(JobMapper.class).getJobById(staffPO.getJobId());
if (null == jobById) {
return;
}
Integer ecJobTitle = jobById.getEcJobTitle();
sql += " and jobtitle = " + ecJobTitle;
}
rs.executeQuery(sql);
if (rs.next()) {
staffPO.setPermanentNum(-1 == rs.getInt("num") ? 0 : rs.getInt("num"));
StaffBO.buildStaffDesc(staffPO);
MapperProxyFactory.getProxy(StaffMapper.class).updateStaff(staffPO);
}
}
} }

@ -5,6 +5,8 @@ public interface DBOperateAdapter {
String concat(String some); String concat(String some);
String concat(String concatStr, String fieldName);
String currentDate(); String currentDate();
String ifNull(String some, String defaultValue); String ifNull(String some, String defaultValue);

@ -5,6 +5,9 @@ import com.engine.organization.exception.OrganizationRunTimeException;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
public enum DBType implements DBOperateAdapter { public enum DBType implements DBOperateAdapter {
/**
*
*/
MYSQL("mysql") { MYSQL("mysql") {
@Override @Override
public String like(String some) { public String like(String some) {
@ -16,6 +19,11 @@ public enum DBType implements DBOperateAdapter {
return " concat(','," + some + ",',') "; return " concat(','," + some + ",',') ";
} }
@Override
public String concat(String concatStr, String fieldName) {
return " concat('" + concatStr + "'," + fieldName + ") ";
}
@Override @Override
public String currentDate() { public String currentDate() {
return "now()"; return "now()";
@ -37,6 +45,11 @@ public enum DBType implements DBOperateAdapter {
return " ','+" + some + "+',' "; return " ','+" + some + "+',' ";
} }
@Override
public String concat(String concatStr, String fieldName) {
return " '" + concatStr + "' + " + fieldName;
}
@Override @Override
public String currentDate() { public String currentDate() {
return "GETDATE()"; return "GETDATE()";
@ -58,6 +71,11 @@ public enum DBType implements DBOperateAdapter {
return " ',' ||" + some + "|| ',' "; return " ',' ||" + some + "|| ',' ";
} }
@Override
public String concat(String concatStr, String fieldName) {
return " '" + concatStr + "' ||" + fieldName;
}
@Override @Override
public String currentDate() { public String currentDate() {
return "SYSDATE"; return "SYSDATE";
@ -79,6 +97,11 @@ public enum DBType implements DBOperateAdapter {
return " ',' ||" + some + "|| ',' "; return " ',' ||" + some + "|| ',' ";
} }
@Override
public String concat(String concatStr, String fieldName) {
return " '" + concatStr + "' ||" + fieldName;
}
@Override @Override
public String currentDate() { public String currentDate() {
return "now()"; return "now()";

@ -15,6 +15,7 @@ import com.engine.organization.mapper.department.DepartmentMapper;
import com.engine.organization.mapper.job.JobMapper; import com.engine.organization.mapper.job.JobMapper;
import com.engine.organization.mapper.staff.StaffMapper; import com.engine.organization.mapper.staff.StaffMapper;
import com.engine.organization.mapper.staff.StaffPlanMapper; import com.engine.organization.mapper.staff.StaffPlanMapper;
import com.engine.organization.service.impl.StaffServiceImpl;
import com.engine.organization.util.OrganizationAssert; import com.engine.organization.util.OrganizationAssert;
import com.engine.organization.util.db.MapperProxyFactory; import com.engine.organization.util.db.MapperProxyFactory;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
@ -296,6 +297,8 @@ public class StaffInfoImportUtil {
staffPO.setControlPolicy(1); staffPO.setControlPolicy(1);
} }
MapperProxyFactory.getProxy(StaffMapper.class).insertIgnoreNull(staffPO); MapperProxyFactory.getProxy(StaffMapper.class).insertIgnoreNull(staffPO);
// 初始化编制信息
StaffServiceImpl.initStaffInfo(staffPO);
historyDetailPO.setOperateDetail("添加成功"); historyDetailPO.setOperateDetail("添加成功");
historyDetailPO.setStatus("1"); historyDetailPO.setStatus("1");

@ -118,6 +118,26 @@ public class OrgChartController {
return JSONObject.toJSONString(apidatas); return JSONObject.toJSONString(apidatas);
} }
@GET
@Path("/getDepartmentTree")
@Produces(MediaType.APPLICATION_JSON)
public String getDepartmentTree(@Context HttpServletRequest request, @Context HttpServletResponse response) {
Map<String, Object> apidatas = new HashMap<>();
try {
User user = HrmUserVarify.getUser(request, response);
//实例化Service 并调用业务类处理
apidatas = getOrgChartWrapper(user).getDepartmentTree(ParamUtil.request2Map(request), user);
apidatas.put("api_status", true);
} catch (Exception e) {
//异常处理
e.printStackTrace();
apidatas.put("api_status", false);
apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
}
//数据转换
return JSONObject.toJSONString(apidatas);
}
/** /**
* *
*/ */

@ -68,4 +68,8 @@ public class OrgChartWrapper extends Service {
public Map<String, Object> versionRecord(Map<String, Object> request2Map, User user) { public Map<String, Object> versionRecord(Map<String, Object> request2Map, User user) {
return getChartService(user).versionRecord(request2Map,user); return getChartService(user).versionRecord(request2Map,user);
} }
public Map<String, Object> getDepartmentTree(Map<String, Object> request2Map, User user) {
return getChartService(user).getDepartmentTree(request2Map);
}
} }

Loading…
Cancel
Save