2022-04-07 16:54:10 +08:00
|
|
|
|
package com.engine.salary.service.impl;
|
|
|
|
|
|
|
2022-09-21 11:52:06 +08:00
|
|
|
|
import com.api.formmode.mybatis.util.SqlProxyHandle;
|
2022-04-07 16:54:10 +08:00
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
|
import com.engine.salary.biz.EmployBiz;
|
|
|
|
|
|
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
2023-03-06 17:57:20 +08:00
|
|
|
|
import com.engine.salary.entity.hrm.DeptInfo;
|
|
|
|
|
|
import com.engine.salary.entity.hrm.PositionInfo;
|
|
|
|
|
|
import com.engine.salary.entity.hrm.SubCompanyInfo;
|
2022-04-07 16:54:10 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.bo.SalarySobRangeBO;
|
|
|
|
|
|
import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam;
|
|
|
|
|
|
import com.engine.salary.entity.salarysob.po.SalarySobRangePO;
|
2022-08-26 14:06:21 +08:00
|
|
|
|
import com.engine.salary.enums.UserStatusEnum;
|
2022-09-21 11:52:06 +08:00
|
|
|
|
import com.engine.salary.mapper.sys.SalarySysConfMapper;
|
2023-03-13 15:53:56 +08:00
|
|
|
|
import com.engine.salary.service.ExtEmpService;
|
2022-04-07 16:54:10 +08:00
|
|
|
|
import com.engine.salary.service.SalaryEmployeeService;
|
|
|
|
|
|
import com.engine.salary.service.SalarySobRangeService;
|
2022-09-21 11:52:06 +08:00
|
|
|
|
import com.engine.salary.sys.entity.po.SalarySysConfPO;
|
2022-04-07 16:54:10 +08:00
|
|
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
2022-08-02 17:57:29 +08:00
|
|
|
|
import com.google.common.collect.Lists;
|
2022-04-07 16:54:10 +08:00
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
2022-08-26 14:06:21 +08:00
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2022-04-07 16:54:10 +08:00
|
|
|
|
import org.apache.commons.lang3.math.NumberUtils;
|
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
|
2022-08-26 14:06:21 +08:00
|
|
|
|
import java.util.*;
|
2022-04-07 16:54:10 +08:00
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 人员信息
|
|
|
|
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author qiantao
|
|
|
|
|
|
* @version 1.0
|
|
|
|
|
|
**/
|
|
|
|
|
|
public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployeeService {
|
|
|
|
|
|
|
|
|
|
|
|
private EmployBiz employBiz = new EmployBiz();
|
|
|
|
|
|
|
|
|
|
|
|
private SalarySobRangeService getSalarySobRangeService(User user) {
|
2022-08-03 10:08:43 +08:00
|
|
|
|
return ServiceUtil.getService(SalarySobRangeServiceImpl.class, user);
|
2022-04-07 16:54:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-21 11:52:06 +08:00
|
|
|
|
private SalarySysConfMapper getSalarySysConfMapper() {
|
|
|
|
|
|
return SqlProxyHandle.getProxy(SalarySysConfMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-13 15:53:56 +08:00
|
|
|
|
|
|
|
|
|
|
private ExtEmpService getExtEmpService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(ExtEmpServiceImpl.class, user);
|
2023-03-07 17:14:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-08 18:01:19 +08:00
|
|
|
|
boolean openExtEmp = true;
|
|
|
|
|
|
|
2022-04-07 16:54:10 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public List<DataCollectionEmployee> listAll() {
|
2023-03-13 15:53:56 +08:00
|
|
|
|
List<DataCollectionEmployee> result = employBiz.listEmployee();
|
|
|
|
|
|
if(openExtEmp){
|
|
|
|
|
|
result.addAll(getExtEmpService(user).listEmployee());
|
|
|
|
|
|
}
|
|
|
|
|
|
return result;
|
2022-04-07 16:54:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-07-11 17:31:33 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public List<DataCollectionEmployee> listAllForReport() {
|
2023-03-13 15:53:56 +08:00
|
|
|
|
List<DataCollectionEmployee> result = employBiz.listAllForReport();
|
|
|
|
|
|
if(openExtEmp){
|
|
|
|
|
|
result.addAll(getExtEmpService(user).listAllForReport());
|
|
|
|
|
|
}
|
|
|
|
|
|
return result;
|
2022-07-11 17:31:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-04-07 16:54:10 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public List<DataCollectionEmployee> listBySalarySobId(Long salarySobId) {
|
|
|
|
|
|
// 查询薪资账套的人员范围
|
|
|
|
|
|
List<SalarySobRangePO> includeSalarySobRangePOS = getSalarySobRangeService(user).listBySalarySobIdAndIncludeType(salarySobId, NumberUtils.INTEGER_ONE);
|
|
|
|
|
|
if (CollectionUtils.isEmpty(includeSalarySobRangePOS)) {
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
|
}
|
|
|
|
|
|
// 将薪资账套的人员范围转换成人员查询参数
|
|
|
|
|
|
List<SalarySobRangeEmpQueryParam> includeQueryParams = SalarySobRangeBO.convert2EmployeeQueryParam(includeSalarySobRangePOS);
|
|
|
|
|
|
// 根据上一步的查询参数查询人员
|
2023-03-13 15:53:56 +08:00
|
|
|
|
List<DataCollectionEmployee> includeSalaryEmployees = listByParams(includeQueryParams);
|
2022-04-07 16:54:10 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(includeSalaryEmployees)) {
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
|
}
|
2022-12-15 16:59:00 +08:00
|
|
|
|
//去重
|
|
|
|
|
|
includeSalaryEmployees = includeSalaryEmployees.stream().distinct().collect(Collectors.toList());
|
2022-04-07 16:54:10 +08:00
|
|
|
|
// 查询薪资账套的人员范围(从范围中排除)
|
|
|
|
|
|
List<SalarySobRangePO> excludeSalarySobRangePOS = getSalarySobRangeService(user).listBySalarySobIdAndIncludeType(salarySobId, NumberUtils.INTEGER_ZERO);
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(excludeSalarySobRangePOS)) {
|
|
|
|
|
|
// 将薪资账套的人员范围转换成人员查询参数
|
|
|
|
|
|
List<SalarySobRangeEmpQueryParam> excludeQueryParams = SalarySobRangeBO.convert2EmployeeQueryParam(excludeSalarySobRangePOS);
|
|
|
|
|
|
// 根据上一步的查询参数查询人员
|
2023-03-13 15:53:56 +08:00
|
|
|
|
List<DataCollectionEmployee> excludeSalaryEmployees = listByParams(excludeQueryParams);
|
2022-04-07 16:54:10 +08:00
|
|
|
|
// 需要排除的人员范围
|
|
|
|
|
|
Set<Long> excludeEmployeeIds = SalaryEntityUtil.properties(excludeSalaryEmployees, DataCollectionEmployee::getEmployeeId);
|
|
|
|
|
|
// 过滤人员
|
|
|
|
|
|
includeSalaryEmployees = includeSalaryEmployees.stream()
|
|
|
|
|
|
.filter(salaryEmployee -> !excludeEmployeeIds.contains(salaryEmployee.getEmployeeId()))
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
return includeSalaryEmployees;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2023-03-06 17:57:20 +08:00
|
|
|
|
public List<DataCollectionEmployee> getEmployeeByIdsAll(List<Long> ids) {
|
2023-03-13 15:53:56 +08:00
|
|
|
|
List<DataCollectionEmployee> result = employBiz.getEmployeeByIdsAll(ids);
|
|
|
|
|
|
if(openExtEmp){
|
|
|
|
|
|
result.addAll(getExtEmpService(user).getEmployeeByIdsAll(ids));
|
|
|
|
|
|
}
|
|
|
|
|
|
return result;
|
2022-04-07 16:54:10 +08:00
|
|
|
|
}
|
2022-04-08 19:08:59 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public DataCollectionEmployee getEmployeeById(Long employeeId) {
|
2023-03-13 15:53:56 +08:00
|
|
|
|
if(openExtEmp){
|
|
|
|
|
|
DataCollectionEmployee employeeById = getExtEmpService(user).getEmployeeById(employeeId);
|
|
|
|
|
|
if(Objects.nonNull(employeeById)){
|
|
|
|
|
|
return employeeById;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-04-08 19:08:59 +08:00
|
|
|
|
return employBiz.getEmployeeById(employeeId);
|
|
|
|
|
|
}
|
2022-06-10 13:33:48 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<DataCollectionEmployee> getEmployeeByIds(List<Long> simpleEmployeeIds) {
|
2022-08-03 10:08:43 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(simpleEmployeeIds)) {
|
|
|
|
|
|
return new ArrayList<>();
|
2022-06-10 13:33:48 +08:00
|
|
|
|
}
|
2022-08-02 17:57:29 +08:00
|
|
|
|
List<DataCollectionEmployee> employeeList = new ArrayList<>();
|
|
|
|
|
|
List<List<Long>> partition = Lists.partition(simpleEmployeeIds, 1000);
|
|
|
|
|
|
for (List<Long> longs : partition) {
|
2023-03-06 17:57:20 +08:00
|
|
|
|
employeeList.addAll(employBiz.getEmployeeByIds(longs));
|
2023-03-13 15:53:56 +08:00
|
|
|
|
if(openExtEmp){
|
|
|
|
|
|
employeeList.addAll(getExtEmpService(user).getEmployeeByIds(longs));
|
|
|
|
|
|
}
|
2022-08-02 17:57:29 +08:00
|
|
|
|
}
|
2023-03-13 15:53:56 +08:00
|
|
|
|
|
2022-08-26 14:06:21 +08:00
|
|
|
|
return employeeList;
|
2022-06-10 13:33:48 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
2022-08-26 14:06:21 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<DataCollectionEmployee> filterEmployees(List<DataCollectionEmployee> employees, String userName, String deparmentName, String mobile) {
|
|
|
|
|
|
List<DataCollectionEmployee> employeeSameIds = employees.stream().filter(e -> (StringUtils.isBlank(userName) || Objects.equals(e.getUsername(), userName))
|
|
|
|
|
|
&& (StringUtils.isBlank(deparmentName) || Objects.equals(e.getDepartmentName(), deparmentName))
|
|
|
|
|
|
&& (StringUtils.isBlank(mobile) || Objects.equals(e.getMobile(), mobile)))
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
//存在离职和在职状态取在职状态
|
|
|
|
|
|
employeeSameIds = employeeSameIds.stream()
|
|
|
|
|
|
.filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus()))
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
return employeeSameIds;
|
|
|
|
|
|
}
|
2022-09-21 11:52:06 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<DataCollectionEmployee> matchImportEmployee(List<DataCollectionEmployee> employeeList, String userName, String deparmentName, String mobile, String workcode, Long uid) {
|
|
|
|
|
|
if (uid != null) {
|
2022-09-21 13:40:43 +08:00
|
|
|
|
return employeeList.stream()
|
|
|
|
|
|
.filter(e -> Objects.equals(e.getEmployeeId(), uid))
|
|
|
|
|
|
.collect(Collectors.toList());
|
2022-09-21 11:52:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//查询对于人员信息导入筛选的全局配置
|
|
|
|
|
|
SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode");
|
|
|
|
|
|
String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0";
|
|
|
|
|
|
List<DataCollectionEmployee> employees = new ArrayList<>();
|
|
|
|
|
|
//“0”代表姓名+部门+手机号的匹配原则,“1”代表工号为唯一匹配原则
|
|
|
|
|
|
if ("0".equals(confValue)) {
|
|
|
|
|
|
employees = employeeList.stream().filter(e -> (StringUtils.isBlank(userName) || Objects.equals(e.getUsername(), userName))
|
|
|
|
|
|
&& (StringUtils.isBlank(deparmentName) || Objects.equals(e.getDepartmentName(), deparmentName))
|
|
|
|
|
|
&& (StringUtils.isBlank(mobile) || Objects.equals(e.getMobile(), mobile)))
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
} else if ("1".equals(confValue)) {
|
|
|
|
|
|
employees = employeeList.stream().filter(e -> (StringUtils.isBlank(workcode) || Objects.equals(e.getWorkcode(), workcode)))
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return employees;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-03-06 17:57:20 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<DeptInfo> getDeptInfoList(List<Long> departmentIds) {
|
|
|
|
|
|
return employBiz.getDeptInfoList(departmentIds);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<SubCompanyInfo> getSubCompanyInfoList(List<Long> subDepartmentIds) {
|
|
|
|
|
|
return employBiz.getSubCompanyInfoList(subDepartmentIds);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<PositionInfo> listPositionInfo(List<Long> positionIds) {
|
|
|
|
|
|
return employBiz.listPositionInfo(positionIds);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<DataCollectionEmployee> listEmployee() {
|
2023-03-13 15:53:56 +08:00
|
|
|
|
List<DataCollectionEmployee> result = employBiz.listEmployee();
|
|
|
|
|
|
if(openExtEmp){
|
|
|
|
|
|
result.addAll(getExtEmpService(user).listEmployee());
|
|
|
|
|
|
}
|
|
|
|
|
|
return result;
|
2023-03-06 17:57:20 +08:00
|
|
|
|
}
|
2023-03-07 17:14:25 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<DataCollectionEmployee> listByParams(List<SalarySobRangeEmpQueryParam> includeQueryParams) {
|
2023-03-13 15:53:56 +08:00
|
|
|
|
List<DataCollectionEmployee> result = employBiz.listByParams(includeQueryParams);
|
|
|
|
|
|
if(openExtEmp){
|
|
|
|
|
|
result.addAll(getExtEmpService(user).listByParams(includeQueryParams));
|
|
|
|
|
|
}
|
2023-03-13 15:57:12 +08:00
|
|
|
|
return result;
|
2023-03-07 17:14:25 +08:00
|
|
|
|
}
|
2022-04-07 16:54:10 +08:00
|
|
|
|
}
|