Browse Source

添加hr_new数据库的查询

lwx_dev
erdanergou 2 years ago
parent
commit
d09455601d
  1. 10
      src/main/java/com/dreamchaser/depository_manage/config/PublicConfig.java
  2. 69
      src/main/java/com/dreamchaser/depository_manage/entity/EncryptionAlgorithm.java
  3. 65
      src/main/java/com/dreamchaser/depository_manage/entity/Md5Encryption.java
  4. 5
      src/main/java/com/dreamchaser/depository_manage/entity/Post.java
  5. 2
      src/main/java/com/dreamchaser/depository_manage/entity/UserByPort.java
  6. 13
      src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/AdministrativeMapper.java
  7. 57
      src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/AdministrativeMapper.xml
  8. 16
      src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/PostMapper.java
  9. 38
      src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/PostMapper.xml
  10. 35
      src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/UserMapper.java
  11. 118
      src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/UserMapper.xml
  12. 39
      src/main/java/com/dreamchaser/depository_manage/service/AdministrativeService.java
  13. 12
      src/main/java/com/dreamchaser/depository_manage/service/UserService.java
  14. 86
      src/main/java/com/dreamchaser/depository_manage/service/impl/AdministrativeServiceImpl.java
  15. 30
      src/main/java/com/dreamchaser/depository_manage/service/impl/UserServiceImpl.java
  16. 95
      src/test/java/com/dreamchaser/depository_manage/MoreDatasourceTest.java

10
src/main/java/com/dreamchaser/depository_manage/config/PublicConfig.java

@ -31,6 +31,11 @@ public class PublicConfig {
// public static String external_url = "http://127.0.0.1:39168";
public static String external_url_6666 = "http://kpi.hxgk.group/kpiapi";
// 外网地址,用于接收验证
public static String external_url_extranet = "";
// 高权限部门列表
public static List<Long> roleAdminorgList = Arrays.asList(361L, 102L, 268L);
@ -41,7 +46,7 @@ public class PublicConfig {
// 定义redis加锁的名称
public static String redis_Lock_name = "Wms_redis_lock";
public static int availableVirtualMachine = Runtime.getRuntime().availableProcessors();
public static int availableVirtualMachine = Runtime.getRuntime().availableProcessors();
/**
* 获取相应部门的部门负责人
@ -615,10 +620,11 @@ public class PublicConfig {
/**
* 绩效考核系统的登录接口
*
* @param map
* @return
*/
public static JSONObject baseLogin(Map<String, String> map){
public static JSONObject baseLogin(Map<String, String> map) {
String url = PublicConfig.external_url_6666 + "/base/login";
String jsonString = JSONObject.toJSONString(map);
JSONObject paramObject = JSONObject.parseObject(jsonString);

69
src/main/java/com/dreamchaser/depository_manage/entity/EncryptionAlgorithm.java

@ -0,0 +1,69 @@
package com.dreamchaser.depository_manage.entity;
import lombok.Data;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.codec.digest.DigestUtils;
import java.util.HashMap;
import java.util.Map;
/**
* 加密算法
* <p>
* 1分解步骤
* one = md5(CodeString)+md5(AppKey)
* two = md5(one)+AppKey
* therr = md5(two)
* 2合并
* md5(md5(md5(CodeString)+md5(AppKey))+AppKey)
*/
@Log4j2
@Data
public class EncryptionAlgorithm {
private static String CONSTANT_CONFIG_AppKey = "heng_xin_gao_ke_AppKey"; //应用程序密钥
private String code;
private String appkey;
public EncryptionAlgorithm(String code) {
this.code = code;
this.appkey = CONSTANT_CONFIG_AppKey;
}
public String Algorithm() {
String keyMd5 = DigestUtils.md5Hex(this.appkey);
String codeMd51 = DigestUtils.md5Hex(this.code);
String one = codeMd51 + keyMd5;
String oneMd5 = DigestUtils.md5Hex(one);
String two = oneMd5 + this.appkey;
return DigestUtils.md5Hex(two);
}
/**
* 用于获取当前用户的key与token
* @param userByPort 待获取用户
* @return
*/
public Map<String, String> getUserKeyAndUserToken(UserByPort userByPort) {
Map<String, String> result = new HashMap<>();
if(userByPort == null){
return null;
}
EncryptionAlgorithm md5EncryptionForNumber = new EncryptionAlgorithm(userByPort.getNumber());
String userKey = md5EncryptionForNumber.Algorithm();
EncryptionAlgorithm md5Encryption = new EncryptionAlgorithm(CONSTANT_CONFIG_AppKey);
String sha1Str = userKey + userByPort.getNumber() + userByPort.getPassword() + md5Encryption.Algorithm();
String userToken = DigestUtils.sha1Hex(sha1Str);
result.put("userKey", userKey);
result.put("userToken", userToken);
return result;
}
}

65
src/main/java/com/dreamchaser/depository_manage/entity/Md5Encryption.java

@ -1,65 +0,0 @@
package com.dreamchaser.depository_manage.entity;
import lombok.Data;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.codec.digest.DigestUtils;
import java.util.Map;
/**
* 加密算法
*/
@Log4j2
@Data
public class Md5Encryption {
private static String CONSTANT_CONFIG_AppKey = "heng_xin_gao_ke_AppKey"; //应用程序密钥
private String code;
private String appkey;
public String Md5EncryptionAlgorithm(){
if(this.appkey == ""){
Md5EncryptionInit(this.code);
}
String keyMd5 = DigestUtils.md5Hex(this.appkey);
String codeMd1 = DigestUtils.md5Hex(this.code);
String yiCeng = codeMd1 + keyMd5;
String yiCengMd5 = DigestUtils.md5Hex(yiCeng);
String erCeng = yiCengMd5 + this.appkey;
String md5Val = DigestUtils.md5Hex(erCeng);
return md5Val;
}
public String Md5EncryptionAlgorithmFj(){
if(this.appkey == ""){
Md5EncryptionInit(this.code);
}
log.info("Code ===> "+this.code);
log.info("AppKey ===> "+this.appkey);
String keyMd5 = DigestUtils.md5Hex(this.appkey);
log.info("Step1:--AppKey-加密->"+keyMd5);
String codeMd1 = DigestUtils.md5Hex(this.code);
log.info("Step2:--CodeString-加密->"+codeMd1);
String yiCeng = codeMd1 + keyMd5;
log.info("Step3:--CodeString+AppKey-->"+yiCeng);
String yiCengMd5 = DigestUtils.md5Hex(yiCeng);
log.info("Step4:--one-加密->"+yiCengMd5);
String erCeng = yiCengMd5 + this.appkey;
log.info("Step5:--one + AppKey->"+erCeng);
String erCengMd5 = DigestUtils.md5Hex(erCeng);
log.info("Step6:--therr--加密-->\n",erCengMd5);
return erCengMd5;
}
/**
* 初始化程序
* @param code
*/
public void Md5EncryptionInit(String code){
this.code = code;
this.appkey = CONSTANT_CONFIG_AppKey;
}
}

5
src/main/java/com/dreamchaser/depository_manage/entity/Post.java

@ -57,6 +57,11 @@ public class Post {
*/
private Long department;
/**
* 部门
*/
private Long adminorg;
/**
* 名称
*/

2
src/main/java/com/dreamchaser/depository_manage/entity/UserByPort.java

@ -133,7 +133,7 @@ public class UserByPort {
/**
* 角色
*/
private Integer role;
private String role;
/**
* 身份证号

13
src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/AdministrativeMapper.java

@ -2,9 +2,13 @@ package com.dreamchaser.depository_manage.hrNew_mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.dreamchaser.depository_manage.entity.Administration;
import com.dreamchaser.depository_manage.pojo.AdministrationP;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
@Mapper
@Repository
@DS("hr_new")
@ -15,4 +19,13 @@ public interface AdministrativeMapper {
* @return
*/
Administration findAdministrationById(Long id);
/**
* 获取所有行政组织
* @return
*/
List<Administration> findAdministrationsAll();
List<AdministrationP> findAdministrationPByCondition(Map<String,Object> map);
}

57
src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/AdministrativeMapper.xml

@ -13,14 +13,69 @@
<id column="wechat_organization_id" property="wechatorganizationid" jdbcType="BIGINT"/>
</resultMap>
<resultMap id="AdministrativePMap" type="com.dreamchaser.depository_manage.pojo.AdministrationP">
<id column="id" property="id" jdbcType="BIGINT"/>
<id column="number" property="number" jdbcType="VARCHAR"/>
<id column="name" property="name" jdbcType="VARCHAR"/>
<id column="superior" property="superior" jdbcType="BIGINT"/>
<id column="typename" property="classname" jdbcType="VARCHAR"/>
<id column="level" property="level" jdbcType="INTEGER"/>
<id column="state" property="state" jdbcType="INTEGER"/>
</resultMap>
<sql id="allColumns">
id,number,name,superior,organization_type,abbreviation,state,time,wechat_organization_id
</sql>
<sql id="allColumnsForView">
id,number,name,superior,type,level,state,typename
</sql>
<select id="findAdministrationById" resultMap="AdministrativeMap" parameterType="long">
select
<include refid="allColumns"/>
from administrative_organization
where id = #{id}
where id = #{id} and state = 1
</select>
<select id="findAdministrationsAll" resultMap="AdministrativeMap">
select
<include refid="allColumns"/>
from administrative_organization
where state = 1
</select>
<select id="findAdministrationPByCondition" resultMap="AdministrativePMap" parameterType="map">
select
<include refid="allColumnsForView"/>
from orglist
where 1 = 1
<if test="id != null and id != ''">
and id = #{id}
</if>
<if test="number != null and number!= ''">
and number = #{number}
</if>
<if test="superior != null and superior!= ''">
and superior = #{superior}
</if>
<if test="typename != null and typename!= ''">
and typename = #{typename}
</if>
<if test="level != null and level!= ''">
and level = #{level}
</if>
<if test="state != null and state!= ''">
and state = #{state}
</if>
<if test="name != null and name!= ''">
and name like CONCAT('%',#{typename},'%')
</if>
</select>
</mapper>

16
src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/PostMapper.java

@ -0,0 +1,16 @@
package com.dreamchaser.depository_manage.hrNew_mapper;
import com.dreamchaser.depository_manage.entity.Post;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
@Repository
@Mapper
public interface PostMapper {
/**
* 根据岗位id获取岗位信息
* @param postId
* @return
*/
Post findPostById(Long postId);
}

38
src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/PostMapper.xml

@ -0,0 +1,38 @@
<?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.dreamchaser.depository_manage.hrNew_mapper.PostMapper">
<resultMap id="postMap" type="com.dreamchaser.depository_manage.entity.Post">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="number" column="number" jdbcType="VARCHAR"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="duties" column="duties" jdbcType="BIGINT"/>
<result property="time" column="time" jdbcType="BIGINT"/>
<result property="state" column="state" jdbcType="INTEGER"/>
<result property="superior" column="superior" jdbcType="BIGINT"/>
<result property="personincharge" column="perincha" jdbcType="INTEGER"/>
<result property="department" column="department" jdbcType="BIGINT"/>
<result property="adminorg" column="adm_org" jdbcType="BIGINT"/>
<result property="dutiesname" column="duties_name" jdbcType="VARCHAR"/>
<result property="dutiesnumber" column="duties_number" jdbcType="VARCHAR"/>
<result property="aoname" column="aoname" jdbcType="VARCHAR"/>
<result property="aonumber" column="aonumber" jdbcType="VARCHAR"/>
<result property="aonumber" column="aonumber" jdbcType="VARCHAR"/>
<result property="jobname" column="job_name" jdbcType="VARCHAR"/>
<result property="superiorname" column="superiorname" jdbcType="VARCHAR"/>
<result property="superiornumber" column="superiornumber" jdbcType="VARCHAR"/>
<result property="departmentname" column="departmentname" jdbcType="VARCHAR"/>
</resultMap>
<sql id="allColumnView">
id,number,name,duties,time,state,superior,perincha,department,adm_org,duties_name,duties_number,job_name
</sql>
<select id="findPostById" parameterType="long" resultMap="postMap">
select
<include refid="allColumnView"/>
from post_duties_job
where id = #{postId}
</select>
</mapper>

35
src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/UserMapper.java

@ -11,6 +11,7 @@ import java.util.Map;
/**
* 关于用户的mapper接口
*
* @author Dreamchaser
*/
@Repository
@ -19,6 +20,7 @@ import java.util.Map;
public interface UserMapper {
/**
* 通过id获取用户信息
*
* @param id 待获取用户id
* @return
*/
@ -26,8 +28,41 @@ public interface UserMapper {
/**
* 通过工号获取用户信息
*
* @param number 待获取用户工号
* @return
*/
UserByPort findUserByNumber(String number);
/**
* 获取当前部门的部门负责人
*
* @param departmentId 待获取部门Id
* @return
*/
List<UserByPort> findDepartmentHeaders(Long departmentId);
/**
* 根据企业微信或微信id获取用户信息
*
* @param workWechat 企业微信id
* @return
*/
UserByPort findUserByWorkWechat(String workWechat);
/**
* 根据条件查询用户信息
* @param map 待查询条件
* @return
*/
List<UserByPort> findUserByCondition(Map<String, Object> map);
/**
* 根据条件查询用户数量
* @param map 待查询条件
* @return
*/
Integer findUserCountByCondition(Map<String, Object> map);
}

118
src/main/java/com/dreamchaser/depository_manage/hrNew_mapper/UserMapper.xml

@ -78,4 +78,122 @@
from man_cont
where number = #{number}
</select>
<select id="findDepartmentHeaders" parameterType="long" resultMap="userMap">
select
<include refid="manContAllColumn"/>
from man_cont
where FIND_IN_SET(#{departmentId},responsible_department)
</select>
<select id="findUserByWorkWechat" parameterType="String" resultMap="userMap">
select
<include refid="manContAllColumn"/>
from man_cont
where work_wechat = #{workWechat} or wechat = #{workWechat}
</select>
<select id="findUserByCondition" parameterType="map" resultMap="userMap">
select
<include refid="manContAllColumn"/>
from man_cont
where 1 = 1
<if test="name != null and name != ''">
and name like CONCAT('%',#{name},'%')
</if>
<if test="empType != null and empType != ''">
and emp_type = #{empType}
</if>
<if test="company != null and company != ''">
and company = #{company}
</if>
<if test="maindepartment != null and maindepartment != ''">
and maindepartment = #{maindepartment}
</if>
<if test="department != null and department != ''">
and department = #{department}
</if>
<if test="adminorg != null and adminorg != ''">
and admin_org = #{adminorg}
</if>
<if test="position != null and position != ''">
and position = #{position}
</if>
<if test="jobClass != null and jobClass != ''">
and job_class = #{jobClass}
</if>
<if test="jobId != null and jobId != ''">
and job_id = #{jobId}
</if>
<if test="jobLevel != null and jobLevel != ''">
and job_level = #{jobLevel}
</if>
<if test="isAdmin != null and isAdmin != ''">
and isAdmin = #{isAdmin}
</if>
<if test="role != null and role != ''">
and role = #{role}
</if>
<if test="gender != null and gender != ''">
and gender = #{gender}
</if>
<if test="personInCharge != null and personInCharge != ''">
and person_in_charge = #{personInCharge}
</if>
<if test="begin != null and size != null">
LIMIT #{begin},#{size}
</if>
</select>
<select id="findUserCountByCondition" parameterType="map" resultType="int">
select
COUNT(*)
from man_cont
where 1 = 1
<if test="name != null and name != ''">
and name like CONCAT('%',#{name},'%')
</if>
<if test="empType != null and empType != ''">
and emp_type = #{empType}
</if>
<if test="company != null and company != ''">
and company = #{company}
</if>
<if test="maindepartment != null and maindepartment != ''">
and maindepartment = #{maindepartment}
</if>
<if test="department != null and department != ''">
and department = #{department}
</if>
<if test="adminorg != null and adminorg != ''">
and admin_org = #{adminorg}
</if>
<if test="position != null and position != ''">
and position = #{position}
</if>
<if test="jobClass != null and jobClass != ''">
and job_class = #{jobClass}
</if>
<if test="jobId != null and jobId != ''">
and job_id = #{jobId}
</if>
<if test="jobLevel != null and jobLevel != ''">
and job_level = #{jobLevel}
</if>
<if test="isAdmin != null and isAdmin != ''">
and isAdmin = #{isAdmin}
</if>
<if test="role != null and role != ''">
and role = #{role}
</if>
<if test="gender != null and gender != ''">
and gender = #{gender}
</if>
<if test="personInCharge != null and personInCharge != ''">
and person_in_charge = #{personInCharge}
</if>
</select>
</mapper>

39
src/main/java/com/dreamchaser/depository_manage/service/AdministrativeService.java

@ -0,0 +1,39 @@
package com.dreamchaser.depository_manage.service;
import com.dreamchaser.depository_manage.entity.Administration;
import com.dreamchaser.depository_manage.entity.UserByPort;
import java.util.List;
public interface AdministrativeService {
/**
* 根据id获取行政组织
* @param id 待获取行政组织id
* @return
*/
Administration findAdministrationById(Long id);
/**
* 获取所有行政组织
* @return
*/
List<Administration> findAdministrationsAll();
/**
* 获取当前用户所处部门
*
* @param userByPort 待获取用户
* @return
*/
public Administration getDepartmentByUser(UserByPort userByPort);
/**
* 获取当前用户所处的部门id高科_
* @param departmentId 待获取部门id
* @return
*/
public Administration getDepartmentForHXGK(Long departmentId);
}

12
src/main/java/com/dreamchaser/depository_manage/service/UserService.java

@ -1,7 +1,10 @@
package com.dreamchaser.depository_manage.service;
import com.dreamchaser.depository_manage.entity.Administration;
import com.dreamchaser.depository_manage.entity.UserByPort;
import java.util.List;
/**
* user的service层
*/
@ -21,4 +24,13 @@ public interface UserService {
*/
UserByPort findUserByNumber(String number);
/**
* 获取当前部门的部门负责人
*
* @param administration 待获取部门
* @return
*/
public List<UserByPort> getDepartmentHeaderById(Administration administration);
}

86
src/main/java/com/dreamchaser/depository_manage/service/impl/AdministrativeServiceImpl.java

@ -0,0 +1,86 @@
package com.dreamchaser.depository_manage.service.impl;
import com.dreamchaser.depository_manage.entity.Administration;
import com.dreamchaser.depository_manage.entity.UserByPort;
import com.dreamchaser.depository_manage.hrNew_mapper.AdministrativeMapper;
import com.dreamchaser.depository_manage.service.AdministrativeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class AdministrativeServiceImpl implements AdministrativeService {
@Autowired
private AdministrativeMapper administrativeMapper;
/**
* 根据id获取行政组织
* @param id 待获取行政组织id
* @return
*/
@Override
public Administration findAdministrationById(Long id) {
return administrativeMapper.findAdministrationById(id);
}
/**
* 获取所有行政组织
* @return
*/
@Override
public List<Administration> findAdministrationsAll() {
return administrativeMapper.findAdministrationsAll();
}
/**
* 获取当前用户所处部门
*
* @param userByPort 待获取用户
* @return
*/
public Administration getDepartmentByUser(UserByPort userByPort) {
Long maindeparment = userByPort.getMaindeparment();
if (Long.compare(309, maindeparment) == 0) {
// 如果是顶级
return getDepartmentForHXGK(userByPort.getAdminorg());
}
return administrativeMapper.findAdministrationById(maindeparment);
}
/**
* 获取当前用户所处的部门id高科_
* @param departmentId 待获取部门id
* @return
*/
public Administration getDepartmentForHXGK(Long departmentId) {
List<Administration> administrationsAll = administrativeMapper.findAdministrationsAll();
return getDepartmentForRecursion(departmentId, administrationsAll);
}
/**
* 用于递归获取高科部门级行政组织
* @param departmentId 当前行政组织id
* @param administrationList 行政组织列表
* @return
*/
public Administration getDepartmentForRecursion(Long departmentId,List<Administration> administrationList){
for (Administration administration : administrationList) {
Long administrationId = administration.getId();
if(Long.compare(administrationId,departmentId) == 0){
Long superior = administration.getSuperior();
if(Long.compare(superior,309) == 0){
return administration;
}else{
return getDepartmentForRecursion(superior,administrationList);
}
}
}
return null;
}
}

30
src/main/java/com/dreamchaser/depository_manage/service/impl/UserServiceImpl.java

@ -1,10 +1,16 @@
package com.dreamchaser.depository_manage.service.impl;
import com.dreamchaser.depository_manage.entity.Administration;
import com.dreamchaser.depository_manage.entity.UserByPort;
import com.dreamchaser.depository_manage.hrNew_mapper.UserMapper;
import com.dreamchaser.depository_manage.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class UserServiceImpl implements UserService {
@Autowired
@ -31,5 +37,29 @@ public class UserServiceImpl implements UserService {
}
/**
* 获取当前部门的部门负责人
*
* @param administration 待获取部门
* @return
*/
public List<UserByPort> getDepartmentHeaderById(Administration administration) {
// 用于存储结果集
List<UserByPort> userByPortList = new ArrayList<>();
// 查询数据库中当前部门的负责人
List<UserByPort> departmentHeaders = userMapper.findDepartmentHeaders(administration.getId());
for (UserByPort departmentHeader : departmentHeaders) {
// 获取当前人员的雇佣关系
Integer emptype = departmentHeader.getEmptype();
if(emptype > 10){
// 如果是离职状态,则不加入
continue;
}
userByPortList.add(departmentHeader);
}
return userByPortList;
}
}

95
src/test/java/com/dreamchaser/depository_manage/MoreDatasourceTest.java

@ -2,6 +2,7 @@ package com.dreamchaser.depository_manage;
import com.dreamchaser.depository_manage.entity.Administration;
import com.dreamchaser.depository_manage.entity.UserByPort;
import com.dreamchaser.depository_manage.hrNew_mapper.AdministrativeMapper;
import com.dreamchaser.depository_manage.hrNew_mapper.UserMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -9,8 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@RunWith(SpringRunner.class)
@ -18,27 +18,108 @@ public class MoreDatasourceTest {
@Autowired
UserMapper userMapper;
@Autowired
AdministrativeMapper administrativeMapper;
@Test
public void test() {
UserByPort userById = userMapper.findUserById(6235L);
System.out.println(userById);
}
/**
* 获取当前部门的部门负责人
* 获取当前用户所处部门
*
* @param userByPort 待获取用户
* @return
*/
public Administration getUserDepartmentId(UserByPort userByPort) {
Long maindeparment = userByPort.getMaindeparment();
if (Long.compare(309, maindeparment) == 0) {
// 如果是顶级
return getDepartmentId(userByPort.getAdminorg());
}
return administrativeMapper.findAdministrationById(maindeparment);
}
/**
* 获取当前用户所处的部门id
*
* @param departmentId 待获取部门id
* @return
*/
public List<UserByPort> findDepartmentHeaderById(Integer departmentId) {
public Administration getDepartmentId(Long departmentId) {
List<Administration> administrationsAll = administrativeMapper.findAdministrationsAll();
return getDepartmentForRecursion(departmentId, administrationsAll);
}
List<UserByPort> userByPortList = new ArrayList<>();
/**
* 用于递归获取高科部门级行政组织
*
* @param departmentId 当前行政组织id
* @param administrationList 行政组织列表
* @return
*/
public Administration getDepartmentForRecursion(Long departmentId, List<Administration> administrationList) {
for (Administration administration : administrationList) {
Long administrationId = administration.getId();
if (Long.compare(administrationId, departmentId) == 0) {
Long superior = administration.getSuperior();
if (Long.compare(superior, 309) == 0) {
return administration;
} else {
return getDepartmentForRecursion(superior, administrationList);
}
}
}
return null;
}
/**
* 获取当前部门的部门负责人
*
* @param administration 待获取部门
* @return
*/
public List<UserByPort> getDepartmentHeaderById(Administration administration) {
// 用于存储结果集
List<UserByPort> userByPortList = new ArrayList<>();
// 查询数据库中当前部门的负责人
List<UserByPort> departmentHeaders = userMapper.findDepartmentHeaders(administration.getId());
for (UserByPort departmentHeader : departmentHeaders) {
// 获取当前人员的雇佣关系
Integer emptype = departmentHeader.getEmptype();
if (emptype > 10) {
// 如果是离职状态,则不加入
continue;
}
userByPortList.add(departmentHeader);
}
return userByPortList;
}
public Administration findTopAdministrationById(Long id){
/**
* 根据id获取行政组织
*
* @param id 待获取id
* @return
*/
public Administration findTopAdministrationById(Long id) {
return administrativeMapper.findAdministrationById(id);
}
public UserByPort getUserByWorkWechat(String workWechat) {
return null;
}
}

Loading…
Cancel
Save