调整组织相关接口到独立jar包-organization

This commit is contained in:
dxfeng 2025-07-21 11:06:26 +08:00
parent a3262b0a65
commit 74cd850e2a
9 changed files with 465 additions and 23 deletions

33
.gitignore vendored
View File

@ -1,26 +1,19 @@
# ---> Java .iml
# Compiled class file /out/
*.class /.idea/
# Log file
*.log
# BlueJ files HELP.md
*.ctxt target/
# Mobile Tools for Java (J2ME) ### IntelliJ IDEA ###
.mtj.tmp/ .idea
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml /src/test
hs_err_pid* /src/rebel.xml
replay_pid* /src/META-INF
### IntelliJ IDEA ###
/log
/build/

View File

@ -1,3 +0,0 @@
# secondev-chapanda-feishu
secondev-chapanda-feishu

View File

@ -0,0 +1,6 @@
description = "子模块demo项目"
dependencies {
//
implementation project(':secondev-chapanda-portal')
}

View File

@ -0,0 +1,37 @@
package com.weaver.seconddev.organization.controller;
import com.weaver.common.authority.annotation.WeaPermission;
import com.weaver.seconddev.organization.service.OrganizationInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/**
* @author:dxfeng
* @createTime: 2025/07/17
* @version: 1.0
*/
@Slf4j
@RestController
@RequestMapping("/api/secondev/org/info")
@WeaPermission(publicPermission = true)
public class OrganizationInfoController {
@Autowired
OrganizationInfoService organizationInfoService;
@GetMapping("/getDepartmentInfo")
public Object getDepartmentInfo(@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.getDepartmentInfo(params);
}
}

View File

@ -0,0 +1,24 @@
package com.weaver.seconddev.organization.entity.param;
import com.weaver.seconddev.portal.entity.param.BaseParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author:dxfeng
* @createTime: 2025/07/21
* @version: 1.0
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class OrgSearchCondition extends BaseParam {
private String code;
private String oId;
private Integer current;
private Integer offset;
private Integer pageSize;
public Integer getOffset() {
return (current - 1) * pageSize;
}
}

View File

@ -0,0 +1,82 @@
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;
/**
* @author:dxfeng
* @createTime: 2025/07/17
* @version: 1.0
*/
@Mapper
public interface OrganizationInfoMapper {
/**
* 根据oId获取部门Id
*
* @param param
* @param oId
* @return
*/
Long getDepartmentIdByOId(@Param("param") BaseParam param, @Param("oId") String oId);
/**
* 获取部门列表
*
* @param param
* @return
*/
@MapKey("departmentId")
List<Map<String, Object>> getDepartmentList(BaseParam param);
/**
* 统计部门列表
* @param param
* @return
*/
int getDepartmentListSize(BaseParam param);
/**
* 根据oId获取部门Code
*
* @param param
* @param id
* @return
*/
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
* @return
*/
@MapKey("positionId")
List<Map<String, Object>> getPositionList(@Param("param") BaseParam param);
/**
* 统计职位列表
*
* @param param
* @return
*/
int getPositionListSize(@Param("param") BaseParam param);
}

View File

@ -0,0 +1,37 @@
package com.weaver.seconddev.organization.service;
import com.weaver.common.base.entity.result.WeaResult;
import java.util.Map;
/**
* @author:dxfeng
* @createTime: 2025/07/17
* @version: 1.0
*/
public interface OrganizationInfoService {
/**
* 获取部门信息
*
* @param params
* @return
*/
WeaResult<Map<String, Object>> getDepartmentInfo(Map<String, Object> params);
/**
* 获取岗位信息
*
* @param params
* @return
*/
WeaResult<Map<String, Object>> getPositionInfo(Map<String, Object> params);
/**
* 获取员工信息
*
* @param params
* @return
*/
WeaResult<Map<String, Object>> getEmployeeInfo(Map<String, Object> params);
}

View File

@ -0,0 +1,168 @@
package com.weaver.seconddev.organization.service.impl;
import cn.hutool.core.convert.Convert;
import com.weaver.common.base.entity.result.WeaResult;
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;
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;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author:dxfeng
* @createTime: 2025/07/17
* @version: 1.0
*/
@Slf4j
@Service
public class OrganizationInfoServiceImpl implements OrganizationInfoService {
@Autowired
DepartMentService departMentService;
@Autowired
HrmCommonDepartmentDao hrmCommonDepartmentDao;
@Autowired
HrmCommonEmployeeDao hrmCommonEmployeeDao;
@Autowired
OrganizationInfoMapper organizationInfoMapper;
@Autowired
EteamsBaseMapper eteamsBaseMapper;
@Autowired
EbuilderBaseMapper ebuilderBaseMapper;
@Autowired
HrmComInfoCacheHandler hrmComInfoCacheHandler;
@Override
public WeaResult<Map<String, Object>> getDepartmentInfo(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>> departmentList = organizationInfoMapper.getDepartmentList(param);
int total = organizationInfoMapper.getDepartmentListSize(param);
// 遍历departmentList集合处理数据
long formId = eteamsBaseMapper.getFormIdByTableName(param, param.getTable_dept_cus());
FormField formField = eteamsBaseMapper.getFormFieldByFieldName(param, formId, "sqcj");
List<FormdataTemplateDetails> templateDetails = ebuilderBaseMapper.getFormdataTemplateDetails(param, formField.getDataTemplateId());
Map<String, String> sqcjMap = templateDetails.stream().collect(Collectors.toMap(FormdataTemplateDetails::getValueKey, FormdataTemplateDetails::getName));
List<Map<String, Object>> orgList = new ArrayList<>();
for (Map<String, Object> map : departmentList) {
Map<String, Object> newMap = new HashMap<>();
newMap.put("oId", map.get("oid"));
newMap.put("poId", map.get("poid"));
newMap.put("sqcj", sqcjMap.get(Util.null2String(map.get("sqcj"))));
String jobNum = "";
String bmfzr = Util.null2String(map.get("bmfzr"));
if (StringUtils.isNotBlank(bmfzr)) {
SimpleEmployee byId = hrmCommonEmployeeDao.getById(Long.parseLong(bmfzr));
if (null != byId) {
jobNum = byId.getJobNum();
}
}
newMap.put("bmfzr", jobNum);
String hrbp = Util.null2String(map.get("hrbp"));
String hrbpxm = "";
String hrbpgh = "";
if (StringUtils.isNotBlank(hrbp)) {
SimpleEmployee byId = hrmCommonEmployeeDao.getById(Long.parseLong(hrbp));
if (null != byId) {
hrbpxm = byId.getUsername();
hrbpgh = byId.getJobNum();
}
}
newMap.put("hrbpxm", hrbpxm);
newMap.put("hrbpgh", hrbpgh);
HrmDepartmentComInfo department = hrmComInfoCacheHandler.getCacheById(HrmDepartmentComInfo.class, 1560052731319352218L);
newMap.put("code", department.getCode());
newMap.put("name", department.getName());
newMap.put("dataRank", department.getDatarank());
newMap.put("status", department.getStatus());
List<HrmDepartmentComInfo> allDepartmentList = new ArrayList<>();
getParentDeptList(department, allDepartmentList);
String pathCode = allDepartmentList.stream().map(HrmDepartmentComInfo::getCode).collect(Collectors.joining("/"));
String pathName = allDepartmentList.stream().map(HrmDepartmentComInfo::getName).collect(Collectors.joining("/"));
newMap.put("pathCode", pathCode);
newMap.put("pathName", pathName);
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);
}
@Override
public WeaResult<Map<String, Object>> getPositionInfo(Map<String, Object> params) {
Map<String, Object> returnMap = new HashMap<>();
return WeaResult.success(returnMap);
}
@Override
public WeaResult<Map<String, Object>> getEmployeeInfo(Map<String, Object> params) {
return null;
}
private void getParentDeptList(SimpleDepartment department, List<SimpleDepartment> parentDeptList) {
parentDeptList.add(department);
if (department.getParent() != null) {
getParentDeptList(department.getParent(), parentDeptList);
}
}
private void getParentDeptList(HrmDepartmentComInfo department, List<HrmDepartmentComInfo> parentDeptList) {
parentDeptList.add(department);
if (department.getParent() != null) {
HrmDepartmentComInfo cacheById = hrmComInfoCacheHandler.getCacheById(HrmDepartmentComInfo.class, department.getParent());
getParentDeptList(cacheById, parentDeptList);
}
}
}

View File

@ -0,0 +1,98 @@
<?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.weaver.seconddev.organization.mapper.OrganizationInfoMapper">
<select id="getDepartmentIdByOId" resultType="java.lang.Long">
select t1.id from ${param.eteams}.${param.table_dept_cus} t1
where t1.tenant_key = #{param.tenantKey} and t1.delete_type = 0
and t1.oid = #{oId}
</select>
<select id="getDepartmentCodeById" resultType="java.lang.String">
select t1.code from ${param.eteams}.department t1
where t1.tenant_key = #{param.tenantKey} and t1.delete_type = 0
and t1.id = #{id}
</select>
<select id="getDepartmentCustomData" resultType="java.util.Map">
select t2.id as departmentId,t1.* from ${param.eteams}.${param.table_dept_cus} t1
inner join ${param.eteams}.department t2 on t1.ID =t2.formdata
where t1.tenant_key = #{param.tenantKey} and t1.delete_type = 0
and t2.tenant_key = #{param.tenantKey} and t2.delete_type = 0
and t2.id = #{id}
</select>
<select id="getPositionIdByOId" resultType="java.lang.Long">
select t1.id from ${param.eteams}.${param.table_job_cus} t1
where t1.tenant_key = #{param.tenantKey} and t1.delete_type = 0
and t1.oid = #{oId}
</select>
<select id="getPosition" 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
<if test="code != null and code != ''">
AND t1.code = #{code}
</if>
<if test="oId != null and oId != ''">
AND t2.oid = #{oId}
</if>
</select>
<select id="getDepartmentList" resultType="java.util.Map">
select
t1.id as departmentid,
t1.code as departmentcode,
t1.name as departmentname,
t2.*
from ${eteams}.department t1
inner join ${eteams}.ft_1154218872715993098 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>
<!--分页-->
limit #{offset},#{pageSize}
</select>
<select id="getDepartmentListSize" resultType="java.lang.Integer">
select
count(t1.id)
from ${eteams}.department t1
inner join ${eteams}.ft_1154218872715993098 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>
<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
<if test="code != null and code != ''">
AND t1.code = #{code}
</if>
<if test="oId != null and oId != ''">
AND t2.oid = #{oId}
</if>
<!--分页-->
limit #{offset},#{pageSize}
</select>
</mapper>