generated from dxfeng/secondev-chapanda-feishu
feat(organization): 获取职位信息接口
- 新增 getPositionInfo 接口,用于获取职位信息 - 实现职位信息的查询和分页功能 - 优化部门信息查询逻辑,使用缓存提高性能 - 调整数据库查询 SQL,提高查询效率
This commit is contained in:
parent
74cd850e2a
commit
e2178f6fcd
|
|
@ -34,4 +34,14 @@ public class OrganizationInfoController {
|
||||||
params.put("oId", oId);
|
params.put("oId", oId);
|
||||||
return organizationInfoService.getDepartmentInfo(params);
|
return organizationInfoService.getDepartmentInfo(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getPositionInfo")
|
||||||
|
public Object getPositionInfo(@RequestParam(name = "code", required = false) String code,
|
||||||
|
@RequestParam(name = "oId", required = false) String oId) {
|
||||||
|
log.error("code=={},oId=={}", code, oId);
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("code", code);
|
||||||
|
params.put("oId", oId);
|
||||||
|
return organizationInfoService.getPositionInfo(params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package com.weaver.seconddev.organization.mapper;
|
||||||
import com.weaver.seconddev.portal.entity.param.BaseParam;
|
import com.weaver.seconddev.portal.entity.param.BaseParam;
|
||||||
import org.apache.ibatis.annotations.MapKey;
|
import org.apache.ibatis.annotations.MapKey;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -16,14 +15,14 @@ import java.util.Map;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface OrganizationInfoMapper {
|
public interface OrganizationInfoMapper {
|
||||||
|
|
||||||
/**
|
///**
|
||||||
* 根据oId获取部门Id
|
// * 根据oId获取部门Id
|
||||||
*
|
// *
|
||||||
* @param param
|
// * @param param
|
||||||
* @param oId
|
// * @param oId
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
Long getDepartmentIdByOId(@Param("param") BaseParam param, @Param("oId") String oId);
|
//Long getDepartmentIdByOId(@Param("param") BaseParam param, @Param("oId") String oId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取部门列表
|
* 获取部门列表
|
||||||
|
|
@ -31,7 +30,7 @@ public interface OrganizationInfoMapper {
|
||||||
* @param param
|
* @param param
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@MapKey("departmentId")
|
@MapKey("id")
|
||||||
List<Map<String, Object>> getDepartmentList(BaseParam param);
|
List<Map<String, Object>> getDepartmentList(BaseParam param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -48,20 +47,20 @@ public interface OrganizationInfoMapper {
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String getDepartmentCodeById(@Param("param") BaseParam param, @Param("id") Long id);
|
//String getDepartmentCodeById(@Param("param") BaseParam param, @Param("id") Long id);
|
||||||
|
|
||||||
/**
|
///**
|
||||||
* 查询部门自定义表数据
|
// * 查询部门自定义表数据
|
||||||
*
|
// *
|
||||||
* @param param
|
// * @param param
|
||||||
* @param id
|
// * @param id
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
@MapKey("departmentId")
|
//@MapKey("departmentId")
|
||||||
Map<String, Object> getDepartmentCustomData(@Param("param") BaseParam param, @Param("id") Long id);
|
//Map<String, Object> getDepartmentCustomData(@Param("param") BaseParam param, @Param("id") Long id);
|
||||||
|
//
|
||||||
@MapKey("positionId")
|
//@MapKey("positionId")
|
||||||
Map<String, Object> getPosition(@Param("param") BaseParam param, @Param("oId") String oId, @Param("code") String code);
|
//Map<String, Object> getPosition(@Param("param") BaseParam param, @Param("oId") String oId, @Param("code") String code);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取职位列表
|
* 获取职位列表
|
||||||
|
|
@ -70,7 +69,7 @@ public interface OrganizationInfoMapper {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@MapKey("positionId")
|
@MapKey("positionId")
|
||||||
List<Map<String, Object>> getPositionList(@Param("param") BaseParam param);
|
List<Map<String, Object>> getPositionList(BaseParam param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计职位列表
|
* 统计职位列表
|
||||||
|
|
@ -78,5 +77,5 @@ public interface OrganizationInfoMapper {
|
||||||
* @param param
|
* @param param
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int getPositionListSize(@Param("param") BaseParam param);
|
int getPositionListSize(BaseParam param);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import com.weaver.common.form.datasource.FormdataTemplateDetails;
|
||||||
import com.weaver.common.form.metadata.field.FormField;
|
import com.weaver.common.form.metadata.field.FormField;
|
||||||
import com.weaver.common.hr.util.Util;
|
import com.weaver.common.hr.util.Util;
|
||||||
import com.weaver.common.hrm.cache.HrmDepartmentComInfo;
|
import com.weaver.common.hrm.cache.HrmDepartmentComInfo;
|
||||||
import com.weaver.common.hrm.dao.HrmCommonDepartmentDao;
|
|
||||||
import com.weaver.common.hrm.dao.HrmCommonEmployeeDao;
|
import com.weaver.common.hrm.dao.HrmCommonEmployeeDao;
|
||||||
import com.weaver.common.hrm.manage.HrmComInfoCacheHandler;
|
import com.weaver.common.hrm.manage.HrmComInfoCacheHandler;
|
||||||
import com.weaver.seconddev.organization.entity.param.OrgSearchCondition;
|
import com.weaver.seconddev.organization.entity.param.OrgSearchCondition;
|
||||||
|
|
@ -14,9 +13,7 @@ import com.weaver.seconddev.organization.mapper.OrganizationInfoMapper;
|
||||||
import com.weaver.seconddev.organization.service.OrganizationInfoService;
|
import com.weaver.seconddev.organization.service.OrganizationInfoService;
|
||||||
import com.weaver.seconddev.portal.mapper.EbuilderBaseMapper;
|
import com.weaver.seconddev.portal.mapper.EbuilderBaseMapper;
|
||||||
import com.weaver.seconddev.portal.mapper.EteamsBaseMapper;
|
import com.weaver.seconddev.portal.mapper.EteamsBaseMapper;
|
||||||
import com.weaver.teams.domain.department.SimpleDepartment;
|
|
||||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||||
import com.weaver.workflow.common.cfg.org.service.DepartMentService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -37,11 +34,11 @@ import java.util.stream.Collectors;
|
||||||
@Service
|
@Service
|
||||||
public class OrganizationInfoServiceImpl implements OrganizationInfoService {
|
public class OrganizationInfoServiceImpl implements OrganizationInfoService {
|
||||||
|
|
||||||
@Autowired
|
//@Autowired
|
||||||
DepartMentService departMentService;
|
//DepartMentService departMentService;
|
||||||
|
//
|
||||||
@Autowired
|
//@Autowired
|
||||||
HrmCommonDepartmentDao hrmCommonDepartmentDao;
|
//HrmCommonDepartmentDao hrmCommonDepartmentDao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
HrmCommonEmployeeDao hrmCommonEmployeeDao;
|
HrmCommonEmployeeDao hrmCommonEmployeeDao;
|
||||||
|
|
@ -112,7 +109,8 @@ public class OrganizationInfoServiceImpl implements OrganizationInfoService {
|
||||||
newMap.put("hrbpxm", hrbpxm);
|
newMap.put("hrbpxm", hrbpxm);
|
||||||
newMap.put("hrbpgh", hrbpgh);
|
newMap.put("hrbpgh", hrbpgh);
|
||||||
|
|
||||||
HrmDepartmentComInfo department = hrmComInfoCacheHandler.getCacheById(HrmDepartmentComInfo.class, 1560052731319352218L);
|
Long departmentid = Convert.toLong(map.get("id"));
|
||||||
|
HrmDepartmentComInfo department = hrmComInfoCacheHandler.getCacheById(HrmDepartmentComInfo.class, departmentid);
|
||||||
|
|
||||||
newMap.put("code", department.getCode());
|
newMap.put("code", department.getCode());
|
||||||
newMap.put("name", department.getName());
|
newMap.put("name", department.getName());
|
||||||
|
|
@ -138,9 +136,36 @@ public class OrganizationInfoServiceImpl implements OrganizationInfoService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WeaResult<Map<String, Object>> getPositionInfo(Map<String, Object> params) {
|
public WeaResult<Map<String, Object>> getPositionInfo(Map<String, Object> params) {
|
||||||
|
OrgSearchCondition param = new OrgSearchCondition();
|
||||||
|
String code = Util.null2String(params.get("code"));
|
||||||
|
String oId = Util.null2String(params.get("oId"));
|
||||||
|
int pageSize = Convert.toInt(params.get("pageSize"), 10);
|
||||||
|
int current = Convert.toInt(params.get("current"), 1);
|
||||||
|
|
||||||
|
param.setCode(code);
|
||||||
|
param.setOId(oId);
|
||||||
|
param.setPageSize(pageSize);
|
||||||
|
param.setCurrent(current);
|
||||||
|
List<Map<String, Object>> positionList = organizationInfoMapper.getPositionList(param);
|
||||||
|
int total = organizationInfoMapper.getPositionListSize(param);
|
||||||
|
List<Map<String, Object>> orgList = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Map<String, Object> map : positionList) {
|
||||||
|
Map<String, Object> newMap = new HashMap<>();
|
||||||
|
newMap.put("oId", map.get("oid"));
|
||||||
|
newMap.put("code", map.get("positionCode"));
|
||||||
|
newMap.put("name", map.get("positionName"));
|
||||||
|
newMap.put("odeptid", map.get("odeptid"));
|
||||||
|
newMap.put("is_canceled", map.get("is_canceled"));
|
||||||
|
|
||||||
|
orgList.add(newMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Map<String, Object> returnMap = new HashMap<>();
|
Map<String, Object> returnMap = new HashMap<>();
|
||||||
|
returnMap.put("data", orgList);
|
||||||
|
returnMap.put("current", current);
|
||||||
|
returnMap.put("total", total);
|
||||||
return WeaResult.success(returnMap);
|
return WeaResult.success(returnMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -149,20 +174,22 @@ public class OrganizationInfoServiceImpl implements OrganizationInfoService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getParentDeptList(SimpleDepartment department, List<SimpleDepartment> parentDeptList) {
|
|
||||||
parentDeptList.add(department);
|
|
||||||
if (department.getParent() != null) {
|
|
||||||
getParentDeptList(department.getParent(), parentDeptList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取部门的所有上级部门
|
||||||
|
*
|
||||||
|
* @param department
|
||||||
|
* @param parentDeptList
|
||||||
|
*/
|
||||||
private void getParentDeptList(HrmDepartmentComInfo department, List<HrmDepartmentComInfo> parentDeptList) {
|
private void getParentDeptList(HrmDepartmentComInfo department, List<HrmDepartmentComInfo> parentDeptList) {
|
||||||
parentDeptList.add(department);
|
parentDeptList.add(0, department);
|
||||||
if (department.getParent() != null) {
|
if (department.getParent() != null) {
|
||||||
HrmDepartmentComInfo cacheById = hrmComInfoCacheHandler.getCacheById(HrmDepartmentComInfo.class, department.getParent());
|
HrmDepartmentComInfo cacheById = hrmComInfoCacheHandler.getCacheById(HrmDepartmentComInfo.class, department.getParent());
|
||||||
|
if (null != cacheById) {
|
||||||
getParentDeptList(cacheById, parentDeptList);
|
getParentDeptList(cacheById, parentDeptList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,12 +45,14 @@
|
||||||
|
|
||||||
<select id="getDepartmentList" resultType="java.util.Map">
|
<select id="getDepartmentList" resultType="java.util.Map">
|
||||||
select
|
select
|
||||||
t1.id as departmentid,
|
t1.id,
|
||||||
t1.code as departmentcode,
|
t2.poid,
|
||||||
t1.name as departmentname,
|
t2.sqcj,
|
||||||
t2.*
|
t2.bmfzr,
|
||||||
|
t2.hrbp,
|
||||||
|
t2.oid
|
||||||
from ${eteams}.department t1
|
from ${eteams}.department t1
|
||||||
inner join ${eteams}.ft_1154218872715993098 t2 on t1.formdata = t2.ID
|
inner join ${eteams}.${table_dept_cus} t2 on t1.formdata = t2.ID
|
||||||
where t1.tenant_key = #{tenantKey} and t1.delete_type = 0
|
where t1.tenant_key = #{tenantKey} and t1.delete_type = 0
|
||||||
and t2.tenant_key = #{tenantKey} and t2.delete_type = 0
|
and t2.tenant_key = #{tenantKey} and t2.delete_type = 0
|
||||||
<if test="code != null and code != ''">
|
<if test="code != null and code != ''">
|
||||||
|
|
@ -67,7 +69,7 @@
|
||||||
select
|
select
|
||||||
count(t1.id)
|
count(t1.id)
|
||||||
from ${eteams}.department t1
|
from ${eteams}.department t1
|
||||||
inner join ${eteams}.ft_1154218872715993098 t2 on t1.formdata = t2.ID
|
inner join ${eteams}.${table_dept_cus} t2 on t1.formdata = t2.ID
|
||||||
where t1.tenant_key = #{tenantKey} and t1.delete_type = 0
|
where t1.tenant_key = #{tenantKey} and t1.delete_type = 0
|
||||||
and t2.tenant_key = #{tenantKey} and t2.delete_type = 0
|
and t2.tenant_key = #{tenantKey} and t2.delete_type = 0
|
||||||
<if test="code != null and code != ''">
|
<if test="code != null and code != ''">
|
||||||
|
|
@ -79,12 +81,11 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getPositionList" resultType="java.util.Map">
|
<select id="getPositionList" resultType="java.util.Map">
|
||||||
select t1.ID as positionId, t1.code as positionCode, t1.name as positionName, t2.odeptid, t1.is_canceled as
|
select t1.ID as positionId, t1.code as positionCode, t1.name as positionName, t2.odeptid, t1.is_canceled
|
||||||
isCanceled
|
from ${eteams}.position t1
|
||||||
from ${param.eteams}.position t1
|
inner join ${eteams}.${table_job_cus} t2 on t1.formdata = t2.ID
|
||||||
inner join ${param.eteams}.ft_1155455711525494797 t2 on t1.formdata = t2.ID
|
where t1.tenant_key = #{tenantKey} and t1.delete_type = 0
|
||||||
where t1.tenant_key = #{param.tenantKey} and t1.delete_type = 0
|
and t2.tenant_key = #{tenantKey} and t2.delete_type = 0
|
||||||
and t2.tenant_key = #{param.tenantKey} and t2.delete_type = 0
|
|
||||||
<if test="code != null and code != ''">
|
<if test="code != null and code != ''">
|
||||||
AND t1.code = #{code}
|
AND t1.code = #{code}
|
||||||
</if>
|
</if>
|
||||||
|
|
@ -94,5 +95,19 @@
|
||||||
<!--分页-->
|
<!--分页-->
|
||||||
limit #{offset},#{pageSize}
|
limit #{offset},#{pageSize}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getPositionListSize" resultType="java.lang.Integer">
|
||||||
|
select
|
||||||
|
count(t1.id)
|
||||||
|
from ${eteams}.position t1
|
||||||
|
inner join ${eteams}.${table_job_cus} t2 on t1.formdata = t2.ID
|
||||||
|
where t1.tenant_key = #{tenantKey} and t1.delete_type = 0
|
||||||
|
and t2.tenant_key = #{tenantKey} and t2.delete_type = 0
|
||||||
|
<if test="code != null and code != ''">
|
||||||
|
AND t1.code = #{code}
|
||||||
|
</if>
|
||||||
|
<if test="oId != null and oId != ''">
|
||||||
|
AND t2.oid = #{oId}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue