diff --git a/src/com/api/browser/service/impl/JobBrowserService.java b/src/com/api/browser/service/impl/JobBrowserService.java index a5f7e59a..ccd216d1 100644 --- a/src/com/api/browser/service/impl/JobBrowserService.java +++ b/src/com/api/browser/service/impl/JobBrowserService.java @@ -78,10 +78,12 @@ public class JobBrowserService extends BrowserService { String q = Util.null2String(httpServletRequest.getParameter("q")); List sqlParams = new ArrayList<>(); String keyword = ""; - if (q.length() > 0) keyword = "%" + q + "%"; + if (q.length() > 0) { + keyword = "%" + q + "%"; + } RecordSet rs = new RecordSet(); 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 orderby = " order by t.id "; sqlwhere += " "; @@ -99,7 +101,7 @@ public class JobBrowserService extends BrowserService { rs.executeQuery(sql, sqlParams); List> datas = new ArrayList<>(); while (rs.next()) { - Map item = new HashMap<>(); + Map item = new HashMap<>(3); item.put("id", Util.null2String(rs.getString("id"))); String name = Util.null2String(rs.getString("name")); item.put("name", name); diff --git a/src/com/engine/organization/entity/job/bo/JobBO.java b/src/com/engine/organization/entity/job/bo/JobBO.java index 9b31a888..2f5a3212 100644 --- a/src/com/engine/organization/entity/job/bo/JobBO.java +++ b/src/com/engine/organization/entity/job/bo/JobBO.java @@ -85,13 +85,10 @@ public class JobBO { .jobTitleName(e.getJobTitleName()) .subCompanyName(e.getSubCompanyName()) .departmentName(e.getDepartmentName()) - //.sequenceName(e.getSequenceName()) - //.schemeName(e.getSchemeName()) - //.parentJob(e.getParentJob()) - //.parentJobName(null == poMaps.get(e.getParentJob()) ? "" : poMaps.get(e.getParentJob()).getJobName()) + .jobGroupName(e.getJobGroupName()) + .jobActivityName(e.getJobActivityName()) .isKey(JobTransMethod.getIsKeySpan(e.getIsKey())) .showOrder(e.getShowOrder()) - //.forbiddenTag(e.getForbiddenTag()) .isUsed(0) .build()).collect(Collectors.toList()); List usedIds = MapperProxyFactory.getProxy(JobMapper.class).listUsedId(); diff --git a/src/com/engine/organization/entity/job/dto/JobListDTO.java b/src/com/engine/organization/entity/job/dto/JobListDTO.java index 0404210b..0796000c 100644 --- a/src/com/engine/organization/entity/job/dto/JobListDTO.java +++ b/src/com/engine/organization/entity/job/dto/JobListDTO.java @@ -51,16 +51,18 @@ public class JobListDTO { */ @TableTitle(title = "所属部门", dataIndex = "departmentName", key = "departmentName") private String departmentName; + /** - * 岗位序列 + * 职务类别 */ - //@TableTitle(title = "岗位序列", dataIndex = "sequenceName", key = "sequenceName") - //private String sequenceName; + @TableTitle(title = "职务类别", dataIndex = "jobGroupName", key = "jobGroupName") + private String jobGroupName; + /** - * 等级方案 + * 所属职务 */ - //@TableTitle(title = "等级方案", dataIndex = "schemeName", key = "schemeName") - //private String schemeName; + @TableTitle(title = "所属职务", dataIndex = "jobActivityName", key = "jobActivityName") + private String jobActivityName; /** * 上级岗位 */ diff --git a/src/com/engine/organization/entity/job/vo/JobBrowserVO.java b/src/com/engine/organization/entity/job/vo/JobBrowserVO.java index 097850f3..9404f807 100644 --- a/src/com/engine/organization/entity/job/vo/JobBrowserVO.java +++ b/src/com/engine/organization/entity/job/vo/JobBrowserVO.java @@ -19,8 +19,11 @@ import lombok.NoArgsConstructor; @NoArgsConstructor @AllArgsConstructor @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", - fromSql = "FROM jcl_org_job t left join hrmjobtitles h on t.ec_jobTitle = h.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" + + " left join hrmjobactivities e on h.jobactivityid =e.id" + + " left join hrmjobgroups f on e.jobgroupid =f.id ", orderby = "id", sortway = "asc", primarykey = "id", @@ -41,6 +44,13 @@ public class JobBrowserVO { @OrganizationTableColumn(text = "岗位名称", width = "25%", column = "name") 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") //private String schemeName; //@OrganizationTableColumn(text = "职等", width = "25%", column = "level_id", transmethod = "com.engine.organization.transmethod.JobTransMethod.getLevelName") diff --git a/src/com/engine/organization/mapper/job/JobMapper.xml b/src/com/engine/organization/mapper/job/JobMapper.xml index 663ef720..91b79acd 100644 --- a/src/com/engine/organization/mapper/job/JobMapper.xml +++ b/src/com/engine/organization/mapper/job/JobMapper.xml @@ -374,6 +374,8 @@ b.departmentname , c.sequence_name, d.scheme_name, + e.jobactivityname, + f.jobgroupname, FROM jcl_org_job t left join hrmsubcompany a on @@ -385,6 +387,8 @@ left join jcl_org_scheme d on t.scheme_id = d.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} diff --git a/src/com/engine/organization/service/ChartService.java b/src/com/engine/organization/service/ChartService.java index 783040d6..bbb05649 100644 --- a/src/com/engine/organization/service/ChartService.java +++ b/src/com/engine/organization/service/ChartService.java @@ -47,4 +47,12 @@ public interface ChartService { * @return 数据集合 */ Map versionRecord(Map params, User user); + + /** + * 获取部门下拉框树结构 + * + * @param params 前端入参 + * @return 树结构 + */ + Map getDepartmentTree(Map params); } diff --git a/src/com/engine/organization/service/impl/ChartServiceImpl.java b/src/com/engine/organization/service/impl/ChartServiceImpl.java index becccc3e..e5d8a7b7 100644 --- a/src/com/engine/organization/service/impl/ChartServiceImpl.java +++ b/src/com/engine/organization/service/impl/ChartServiceImpl.java @@ -3,6 +3,7 @@ package com.engine.organization.service.impl; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; 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.jclorgmap.JclOrgMapper; 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.OrganizationAssert; import com.engine.organization.util.OrganizationDateUtil; +import com.engine.organization.util.db.DBType; import com.engine.organization.util.db.MapperProxyFactory; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -446,6 +448,29 @@ public class ChartServiceImpl extends Service implements ChartService { result.put("api_status", true); return result; } + + @Override + public Map getDepartmentTree(Map params) { + Map result = new HashMap<>(2); + + RecordSet rs = new RecordSet(); + List 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){ RecordSet rs = new RecordSet(); rs.execute("delete from jcl_chart_subcompany where versionid = "+versionId); @@ -1184,4 +1209,79 @@ public class ChartServiceImpl extends Service implements ChartService { } 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(); + } } diff --git a/src/com/engine/organization/service/impl/ManagerDetachServiceImpl.java b/src/com/engine/organization/service/impl/ManagerDetachServiceImpl.java index 717e9c8f..6d0f3808 100644 --- a/src/com/engine/organization/service/impl/ManagerDetachServiceImpl.java +++ b/src/com/engine/organization/service/impl/ManagerDetachServiceImpl.java @@ -25,6 +25,7 @@ import com.weaver.general.BaseBean; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import weaver.conn.RecordSet; +import weaver.general.Util; import java.util.*; import java.util.stream.Collectors; @@ -157,11 +158,11 @@ public class ManagerDetachServiceImpl extends Service implements ManagerDetachSe private String buildSqlWhere(Map params) { DBType dbType = DBType.get(new RecordSet().getDBType()); String sqlWhere = " where delete_type = 0"; - String lastName = (String) params.get("ecManager"); - List resourceIds = MapperProxyFactory.getProxy(EmployeeMapper.class).getResourceIds(lastName); - String ecManager = StringUtils.join(resourceIds,","); + String lastName = Util.null2String(params.get("ecManager")); if (StringUtils.isNotBlank(lastName)) { - sqlWhere += " AND ec_manager in ("+ecManager+") "; + List 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"); if (StringUtils.isNotBlank(ecRolelevel)) { diff --git a/src/com/engine/organization/service/impl/StaffServiceImpl.java b/src/com/engine/organization/service/impl/StaffServiceImpl.java index 4e31de95..0da7379d 100644 --- a/src/com/engine/organization/service/impl/StaffServiceImpl.java +++ b/src/com/engine/organization/service/impl/StaffServiceImpl.java @@ -132,8 +132,8 @@ public class StaffServiceImpl extends Service implements StaffService { checkRequired(staffPO); int ignoreNull = getStaffMapper().insertIgnoreNull(staffPO); - // 同步组织架构图编制信息 - //new StaffTriggerRunnable(staffPO).run(); + // 初始化编制在编数 + initStaffInfo(staffPO); 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); + } + + } + } diff --git a/src/com/engine/organization/util/db/DBOperateAdapter.java b/src/com/engine/organization/util/db/DBOperateAdapter.java index e9caa997..97fd62a9 100644 --- a/src/com/engine/organization/util/db/DBOperateAdapter.java +++ b/src/com/engine/organization/util/db/DBOperateAdapter.java @@ -5,6 +5,8 @@ public interface DBOperateAdapter { String concat(String some); + String concat(String concatStr, String fieldName); + String currentDate(); String ifNull(String some, String defaultValue); diff --git a/src/com/engine/organization/util/db/DBType.java b/src/com/engine/organization/util/db/DBType.java index 35fe3346..fa12c713 100644 --- a/src/com/engine/organization/util/db/DBType.java +++ b/src/com/engine/organization/util/db/DBType.java @@ -5,6 +5,9 @@ import com.engine.organization.exception.OrganizationRunTimeException; import weaver.conn.RecordSet; public enum DBType implements DBOperateAdapter { + /** + * 根据数据库类型,匹配不通的函数 + */ MYSQL("mysql") { @Override public String like(String some) { @@ -16,6 +19,11 @@ public enum DBType implements DBOperateAdapter { return " concat(','," + some + ",',') "; } + @Override + public String concat(String concatStr, String fieldName) { + return " concat('" + concatStr + "'," + fieldName + ") "; + } + @Override public String currentDate() { return "now()"; @@ -37,6 +45,11 @@ public enum DBType implements DBOperateAdapter { return " ','+" + some + "+',' "; } + @Override + public String concat(String concatStr, String fieldName) { + return " '" + concatStr + "' + " + fieldName; + } + @Override public String currentDate() { return "GETDATE()"; @@ -58,6 +71,11 @@ public enum DBType implements DBOperateAdapter { return " ',' ||" + some + "|| ',' "; } + @Override + public String concat(String concatStr, String fieldName) { + return " '" + concatStr + "' ||" + fieldName; + } + @Override public String currentDate() { return "SYSDATE"; @@ -79,6 +97,11 @@ public enum DBType implements DBOperateAdapter { return " ',' ||" + some + "|| ',' "; } + @Override + public String concat(String concatStr, String fieldName) { + return " '" + concatStr + "' ||" + fieldName; + } + @Override public String currentDate() { return "now()"; diff --git a/src/com/engine/organization/util/saveimport/StaffInfoImportUtil.java b/src/com/engine/organization/util/saveimport/StaffInfoImportUtil.java index 4fc78a89..aedc24fd 100644 --- a/src/com/engine/organization/util/saveimport/StaffInfoImportUtil.java +++ b/src/com/engine/organization/util/saveimport/StaffInfoImportUtil.java @@ -15,6 +15,7 @@ import com.engine.organization.mapper.department.DepartmentMapper; import com.engine.organization.mapper.job.JobMapper; import com.engine.organization.mapper.staff.StaffMapper; 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.db.MapperProxyFactory; import org.apache.commons.collections.CollectionUtils; @@ -296,6 +297,8 @@ public class StaffInfoImportUtil { staffPO.setControlPolicy(1); } MapperProxyFactory.getProxy(StaffMapper.class).insertIgnoreNull(staffPO); + // 初始化编制信息 + StaffServiceImpl.initStaffInfo(staffPO); historyDetailPO.setOperateDetail("添加成功"); historyDetailPO.setStatus("1"); diff --git a/src/com/engine/organization/web/OrgChartController.java b/src/com/engine/organization/web/OrgChartController.java index a8c2015c..514fffdf 100644 --- a/src/com/engine/organization/web/OrgChartController.java +++ b/src/com/engine/organization/web/OrgChartController.java @@ -118,6 +118,26 @@ public class OrgChartController { return JSONObject.toJSONString(apidatas); } + @GET + @Path("/getDepartmentTree") + @Produces(MediaType.APPLICATION_JSON) + public String getDepartmentTree(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map 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); + } + /** * 组织架构数据 */ diff --git a/src/com/engine/organization/wrapper/OrgChartWrapper.java b/src/com/engine/organization/wrapper/OrgChartWrapper.java index 8d6c59ea..2bbf5a67 100644 --- a/src/com/engine/organization/wrapper/OrgChartWrapper.java +++ b/src/com/engine/organization/wrapper/OrgChartWrapper.java @@ -68,4 +68,8 @@ public class OrgChartWrapper extends Service { public Map versionRecord(Map request2Map, User user) { return getChartService(user).versionRecord(request2Map,user); } + + public Map getDepartmentTree(Map request2Map, User user) { + return getChartService(user).getDepartmentTree(request2Map); + } }