|
|
|
@ -2,13 +2,18 @@ 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.hrNew_mapper.UserMapper; |
|
|
|
import com.dreamchaser.depository_manage.pojo.UserByPortP; |
|
|
|
import com.dreamchaser.depository_manage.service.AdministrativeService; |
|
|
|
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.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class UserServiceImpl implements UserService { |
|
|
|
@ -16,24 +21,30 @@ public class UserServiceImpl implements UserService { |
|
|
|
@Autowired |
|
|
|
private UserMapper userMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private AdministrativeService administrativeService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 通过id获取用户信息 |
|
|
|
* |
|
|
|
* @param id 待获取用户id |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public UserByPort findUserById(Long id) { |
|
|
|
return userMapper.findUserById(id); |
|
|
|
return packForOne(userMapper.findUserById(id)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 通过工号获取用户信息 |
|
|
|
* |
|
|
|
* @param number 待获取用户工号 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public UserByPort findUserByNumber(String number) { |
|
|
|
return userMapper.findUserByNumber(number); |
|
|
|
return packForOne(userMapper.findUserByNumber(number)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -44,7 +55,6 @@ public class UserServiceImpl implements UserService { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public List<UserByPort> getDepartmentHeaderById(Administration administration) { |
|
|
|
|
|
|
|
// 用于存储结果集
|
|
|
|
List<UserByPort> userByPortList = new ArrayList<>(); |
|
|
|
// 查询数据库中当前部门的负责人
|
|
|
|
@ -52,14 +62,69 @@ public class UserServiceImpl implements UserService { |
|
|
|
for (UserByPort departmentHeader : departmentHeaders) { |
|
|
|
// 获取当前人员的雇佣关系
|
|
|
|
Integer emptype = departmentHeader.getEmptype(); |
|
|
|
if(emptype > 10){ |
|
|
|
if (emptype > 10) { |
|
|
|
// 如果是离职状态,则不加入
|
|
|
|
continue; |
|
|
|
} |
|
|
|
userByPortList.add(departmentHeader); |
|
|
|
} |
|
|
|
return userByPortList; |
|
|
|
return packForMoreOne(userByPortList); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据条件查询用户信息 |
|
|
|
* @param map 待查询条件 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<UserByPort> findUserByCondition(Map<String, Object> map) { |
|
|
|
return packForMoreOne(userMapper.findUserByCondition(map)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据条件查询用户数量 |
|
|
|
* @param map 待查询条件 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public Integer findUserCountByCondition(Map<String, Object> map){ |
|
|
|
return userMapper.findUserCountByCondition(map); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据企业微信或微信id获取用户信息 |
|
|
|
* |
|
|
|
* @param workWechat 企业微信id |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public UserByPort findUserByWorkWechat(String workWechat) { |
|
|
|
return packForOne(userMapper.findUserByWorkWechat(workWechat)); |
|
|
|
} |
|
|
|
|
|
|
|
public UserByPort packForOne(UserByPort userByPort) { |
|
|
|
// 获取当前用户所处部门
|
|
|
|
Administration departmentByUser = administrativeService.getDepartmentByUser(userByPort); |
|
|
|
userByPort.setMaindeparmentname(departmentByUser.getName()); |
|
|
|
userByPort.setMaindeparment(departmentByUser.getId()); |
|
|
|
return userByPort; |
|
|
|
} |
|
|
|
|
|
|
|
public List<UserByPort> packForMoreOne(List<UserByPort> userByPortList) { |
|
|
|
Map<Long, Administration> administrationMap = new HashMap<>(); |
|
|
|
for (UserByPort userByPort : userByPortList) { |
|
|
|
Long maindeparment = userByPort.getMaindeparment(); |
|
|
|
Administration departmentByUser = null; |
|
|
|
if (administrationMap.containsKey(maindeparment)) { |
|
|
|
departmentByUser = administrationMap.get(maindeparment); |
|
|
|
} else { |
|
|
|
departmentByUser = administrativeService.getDepartmentByUser(userByPort); |
|
|
|
administrationMap.put(maindeparment, departmentByUser); |
|
|
|
} |
|
|
|
// 获取当前用户所处部门
|
|
|
|
userByPort.setMaindeparmentname(departmentByUser.getName()); |
|
|
|
userByPort.setMaindeparment(departmentByUser.getId()); |
|
|
|
} |
|
|
|
return userByPortList; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|