feat(organization): 获取职位信息接口

- 新增 getPositionInfo 接口,用于获取职位信息
- 实现职位信息的查询和分页功能
- 优化部门信息查询逻辑,使用缓存提高性能
- 调整数据库查询 SQL,提高查询效率
This commit is contained in:
dxfeng 2025-07-21 13:38:55 +08:00
parent 74cd850e2a
commit e2178f6fcd
4 changed files with 110 additions and 59 deletions

View File

@ -34,4 +34,14 @@ public class OrganizationInfoController {
params.put("oId", oId);
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);
}
}

View File

@ -3,7 +3,6 @@ package com.weaver.seconddev.organization.mapper;
import com.weaver.seconddev.portal.entity.param.BaseParam;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@ -16,14 +15,14 @@ import java.util.Map;
@Mapper
public interface OrganizationInfoMapper {
/**
* 根据oId获取部门Id
*
* @param param
* @param oId
* @return
*/
Long getDepartmentIdByOId(@Param("param") BaseParam param, @Param("oId") String oId);
///**
// * 根据oId获取部门Id
// *
// * @param param
// * @param oId
// * @return
// */
//Long getDepartmentIdByOId(@Param("param") BaseParam param, @Param("oId") String oId);
/**
* 获取部门列表
@ -31,7 +30,7 @@ public interface OrganizationInfoMapper {
* @param param
* @return
*/
@MapKey("departmentId")
@MapKey("id")
List<Map<String, Object>> getDepartmentList(BaseParam param);
/**
@ -48,20 +47,20 @@ public interface OrganizationInfoMapper {
* @param id
* @return
*/
String getDepartmentCodeById(@Param("param") BaseParam param, @Param("id") Long id);
//String getDepartmentCodeById(@Param("param") BaseParam param, @Param("id") Long id);
/**
* 查询部门自定义表数据
*
* @param param
* @param id
* @return
*/
@MapKey("departmentId")
Map<String, Object> getDepartmentCustomData(@Param("param") BaseParam param, @Param("id") Long id);
@MapKey("positionId")
Map<String, Object> getPosition(@Param("param") BaseParam param, @Param("oId") String oId, @Param("code") String code);
///**
// * 查询部门自定义表数据
// *
// * @param param
// * @param id
// * @return
// */
//@MapKey("departmentId")
//Map<String, Object> getDepartmentCustomData(@Param("param") BaseParam param, @Param("id") Long id);
//
//@MapKey("positionId")
//Map<String, Object> getPosition(@Param("param") BaseParam param, @Param("oId") String oId, @Param("code") String code);
/**
* 获取职位列表
@ -70,7 +69,7 @@ public interface OrganizationInfoMapper {
* @return
*/
@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
* @return
*/
int getPositionListSize(@Param("param") BaseParam param);
int getPositionListSize(BaseParam param);
}

View File

@ -6,7 +6,6 @@ import com.weaver.common.form.datasource.FormdataTemplateDetails;
import com.weaver.common.form.metadata.field.FormField;
import com.weaver.common.hr.util.Util;
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.manage.HrmComInfoCacheHandler;
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.portal.mapper.EbuilderBaseMapper;
import com.weaver.seconddev.portal.mapper.EteamsBaseMapper;
import com.weaver.teams.domain.department.SimpleDepartment;
import com.weaver.teams.domain.user.SimpleEmployee;
import com.weaver.workflow.common.cfg.org.service.DepartMentService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -37,11 +34,11 @@ import java.util.stream.Collectors;
@Service
public class OrganizationInfoServiceImpl implements OrganizationInfoService {
@Autowired
DepartMentService departMentService;
@Autowired
HrmCommonDepartmentDao hrmCommonDepartmentDao;
//@Autowired
//DepartMentService departMentService;
//
//@Autowired
//HrmCommonDepartmentDao hrmCommonDepartmentDao;
@Autowired
HrmCommonEmployeeDao hrmCommonEmployeeDao;
@ -112,7 +109,8 @@ public class OrganizationInfoServiceImpl implements OrganizationInfoService {
newMap.put("hrbpxm", hrbpxm);
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("name", department.getName());
@ -138,9 +136,36 @@ public class OrganizationInfoServiceImpl implements OrganizationInfoService {
@Override
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<>();
returnMap.put("data", orgList);
returnMap.put("current", current);
returnMap.put("total", total);
return WeaResult.success(returnMap);
}
@ -149,20 +174,22 @@ public class OrganizationInfoServiceImpl implements OrganizationInfoService {
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) {
parentDeptList.add(department);
parentDeptList.add(0, department);
if (department.getParent() != null) {
HrmDepartmentComInfo cacheById = hrmComInfoCacheHandler.getCacheById(HrmDepartmentComInfo.class, department.getParent());
if (null != cacheById) {
getParentDeptList(cacheById, parentDeptList);
}
}
}
}

View File

@ -45,12 +45,14 @@
<select id="getDepartmentList" resultType="java.util.Map">
select
t1.id as departmentid,
t1.code as departmentcode,
t1.name as departmentname,
t2.*
t1.id,
t2.poid,
t2.sqcj,
t2.bmfzr,
t2.hrbp,
t2.oid
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
and t2.tenant_key = #{tenantKey} and t2.delete_type = 0
<if test="code != null and code != ''">
@ -67,7 +69,7 @@
select
count(t1.id)
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
and t2.tenant_key = #{tenantKey} and t2.delete_type = 0
<if test="code != null and code != ''">
@ -79,12 +81,11 @@
</select>
<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
isCanceled
from ${param.eteams}.position t1
inner join ${param.eteams}.ft_1155455711525494797 t2 on t1.formdata = t2.ID
where t1.tenant_key = #{param.tenantKey} and t1.delete_type = 0
and t2.tenant_key = #{param.tenantKey} and t2.delete_type = 0
select t1.ID as positionId, t1.code as positionCode, t1.name as positionName, t2.odeptid, t1.is_canceled
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>
@ -94,5 +95,19 @@
<!--分页-->
limit #{offset},#{pageSize}
</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>