调整组织相关接口到独立jar包-organization
This commit is contained in:
parent
0500c65db2
commit
b0557ec16d
|
|
@ -1,37 +0,0 @@
|
||||||
package com.weaver.seconddev.feishu.controller;
|
|
||||||
|
|
||||||
import com.weaver.common.authority.annotation.WeaPermission;
|
|
||||||
import com.weaver.seconddev.feishu.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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
package com.weaver.seconddev.feishu.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.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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据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);
|
|
||||||
}
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
package com.weaver.seconddev.feishu.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);
|
|
||||||
}
|
|
||||||
|
|
@ -1,150 +0,0 @@
|
||||||
package com.weaver.seconddev.feishu.service.impl;
|
|
||||||
|
|
||||||
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.dao.HrmCommonDepartmentDao;
|
|
||||||
import com.weaver.common.hrm.dao.HrmCommonEmployeeDao;
|
|
||||||
import com.weaver.seconddev.feishu.mapper.OrganizationInfoMapper;
|
|
||||||
import com.weaver.seconddev.feishu.service.OrganizationInfoService;
|
|
||||||
import com.weaver.seconddev.portal.entity.param.BaseParam;
|
|
||||||
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;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WeaResult<Map<String, Object>> getDepartmentInfo(Map<String, Object> params) {
|
|
||||||
BaseParam param = new BaseParam();
|
|
||||||
String code = Util.null2String(params.get("code"));
|
|
||||||
String oId = Util.null2String(params.get("oId"));
|
|
||||||
SimpleDepartment department = null;
|
|
||||||
if (StringUtils.isNotBlank(oId)) {
|
|
||||||
Long departmentId = organizationInfoMapper.getDepartmentIdByOId(param, oId);
|
|
||||||
if (null != departmentId) {
|
|
||||||
code = organizationInfoMapper.getDepartmentCodeById(param, departmentId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询部门信息
|
|
||||||
if (StringUtils.isNotBlank(code)) {
|
|
||||||
department = hrmCommonDepartmentDao.getByCode(code, param.getTenantKey());
|
|
||||||
}
|
|
||||||
if (null == department) {
|
|
||||||
return WeaResult.fail("部门不存在", true);
|
|
||||||
}
|
|
||||||
// 查询部门自定义表数据
|
|
||||||
Map<String, Object> departmentCustomData = organizationInfoMapper.getDepartmentCustomData(param, department.getId());
|
|
||||||
Map<String, Object> returnMap = new HashMap<>();
|
|
||||||
|
|
||||||
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));
|
|
||||||
|
|
||||||
|
|
||||||
if (departmentCustomData != null && !departmentCustomData.isEmpty()) {
|
|
||||||
returnMap.put("oId", departmentCustomData.get("oid"));
|
|
||||||
returnMap.put("poId", departmentCustomData.get("poid"));
|
|
||||||
returnMap.put("sqcj", sqcjMap.get(Util.null2String(departmentCustomData.get("sqcj"))));
|
|
||||||
|
|
||||||
String jobNum = "";
|
|
||||||
String bmfzr = Util.null2String(departmentCustomData.get("bmfzr"));
|
|
||||||
if (StringUtils.isNotBlank(bmfzr)) {
|
|
||||||
SimpleEmployee byId = hrmCommonEmployeeDao.getById(Long.parseLong(bmfzr));
|
|
||||||
if (null != byId) {
|
|
||||||
jobNum = byId.getJobNum();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
returnMap.put("bmfzr", jobNum);
|
|
||||||
|
|
||||||
String hrbp = Util.null2String(departmentCustomData.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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
returnMap.put("hrbpxm", hrbpxm);
|
|
||||||
returnMap.put("hrbpgh", hrbpgh);
|
|
||||||
}
|
|
||||||
|
|
||||||
returnMap.put("code", department.getCode());
|
|
||||||
returnMap.put("name", department.getName());
|
|
||||||
returnMap.put("dataRank", department.getDatarank());
|
|
||||||
returnMap.put("status", department.isStatus() ? "1" : "0");
|
|
||||||
List<SimpleDepartment> allDepartmentList = new ArrayList<>();
|
|
||||||
getParentDeptList(department, allDepartmentList);
|
|
||||||
|
|
||||||
String pathCode = allDepartmentList.stream().map(SimpleDepartment::getCode).collect(Collectors.joining("/"));
|
|
||||||
String pathName = allDepartmentList.stream().map(SimpleDepartment::getName).collect(Collectors.joining("/"));
|
|
||||||
|
|
||||||
returnMap.put("pathCode", pathCode);
|
|
||||||
returnMap.put("pathName", pathName);
|
|
||||||
|
|
||||||
|
|
||||||
return WeaResult.success(returnMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WeaResult<Map<String, Object>> getPositionInfo(Map<String, Object> params) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
<?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.feishu.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>
|
|
||||||
</mapper>
|
|
||||||
Loading…
Reference in New Issue