weaver-hrm-salary/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java

706 lines
32 KiB
Java
Raw Normal View History

2022-04-07 16:54:10 +08:00
package com.engine.salary.service.impl;
2024-12-06 16:00:05 +08:00
import cn.hutool.core.util.NumberUtil;
2023-11-06 11:19:00 +08:00
import com.alibaba.fastjson.JSON;
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;
2023-11-06 11:19:00 +08:00
import com.engine.salary.constant.SalaryDefaultTenantConstant;
2023-03-15 18:03:46 +08:00
import com.engine.salary.entity.SalarySobExtRangePO;
2022-04-07 16:54:10 +08:00
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
2023-03-06 17:57:20 +08:00
import com.engine.salary.entity.hrm.DeptInfo;
2024-07-25 14:04:14 +08:00
import com.engine.salary.entity.hrm.JobCallInfo;
2023-03-06 17:57:20 +08:00
import com.engine.salary.entity.hrm.PositionInfo;
import com.engine.salary.entity.hrm.SubCompanyInfo;
2023-11-06 11:19:00 +08:00
import com.engine.salary.entity.hrm.dto.EmployeeInfoExpandDTO;
import com.engine.salary.entity.hrm.dto.FieldSetting;
import com.engine.salary.entity.hrm.po.ExpandFieldSettingsPO;
2024-12-04 15:41:11 +08:00
import com.engine.salary.entity.hrm.po.HrmSnapshotPO;
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;
2024-12-06 16:00:05 +08:00
import com.engine.salary.enums.AccountTypeEnum;
2022-08-26 14:06:21 +08:00
import com.engine.salary.enums.UserStatusEnum;
2023-03-16 16:10:29 +08:00
import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum;
2024-03-22 15:23:03 +08:00
import com.engine.salary.enums.salarysob.TargetTypeEnum;
import com.engine.salary.mapper.datacollection.EmployMapper;
2023-11-06 11:19:00 +08:00
import com.engine.salary.mapper.hrm.ExpandFieldSettingsMapper;
2024-12-04 15:41:11 +08:00
import com.engine.salary.mapper.hrm.HrmSnapshotMapper;
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;
2023-03-15 18:03:46 +08:00
import com.engine.salary.service.SalarySobExtRangeService;
2022-04-07 16:54:10 +08:00
import com.engine.salary.service.SalarySobRangeService;
2022-09-21 11:52:06 +08:00
import com.engine.salary.sys.entity.po.SalarySysConfPO;
2024-10-16 15:25:48 +08:00
import com.engine.salary.sys.service.SalarySysConfService;
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
2022-04-07 16:54:10 +08:00
import com.engine.salary.util.SalaryEntityUtil;
2024-03-11 16:50:47 +08:00
import com.engine.salary.util.SalaryI18nUtil;
2024-01-25 11:38:38 +08:00
import com.engine.salary.util.db.IdGenerator;
2024-12-04 15:41:11 +08:00
import com.engine.salary.util.db.MapperProxyFactory;
2024-02-27 15:16:13 +08:00
import com.google.common.collect.Lists;
2023-11-09 11:34:00 +08:00
import lombok.extern.slf4j.Slf4j;
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;
2023-11-02 18:41:58 +08:00
import weaver.conn.RecordSet;
2024-10-23 17:41:28 +08:00
import weaver.general.Util;
2022-04-07 16:54:10 +08:00
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;
2024-10-16 15:25:48 +08:00
import static com.engine.salary.sys.constant.SalarySysConstant.OPEN_SECONDARY_ACCOUNT;
2022-04-07 16:54:10 +08:00
/**
* 人员信息
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
2023-11-09 11:34:00 +08:00
@Slf4j
2022-04-07 16:54:10 +08:00
public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployeeService {
private EmployBiz employBiz = new EmployBiz();
2024-12-04 15:41:11 +08:00
private HrmSnapshotMapper getHrmSnapshotMapper() {
return MapperProxyFactory.getProxy(HrmSnapshotMapper.class);
}
2024-03-25 16:08:34 +08:00
private EmployMapper getEmployMapper() {
return SqlProxyHandle.getProxy(EmployMapper.class);
}
2022-04-07 16:54:10 +08:00
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
}
2024-08-15 10:37:41 +08:00
private SalaryEmployeeService getSalaryEmployeeService(User user) {
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
2024-10-16 15:25:48 +08:00
private SalarySysConfService getSalarySysConfService(User user) {
return ServiceUtil.getService(SalarySysConfServiceImpl.class, user);
2022-09-21 11:52:06 +08:00
}
2023-03-13 15:53:56 +08:00
2023-11-06 11:19:00 +08:00
private ExpandFieldSettingsMapper getExpandFieldSettingsMapper() {
return SqlProxyHandle.getProxy(ExpandFieldSettingsMapper.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-07-12 09:45:00 +08:00
private SalarySobExtRangeService getSalarySobExtRangeService(User user) {
return ServiceUtil.getService(SalarySobExtRangeServiceImpl.class, user);
}
2023-03-08 18:01:19 +08:00
boolean openExtEmp = true;
2024-10-16 15:25:48 +08:00
//主次账号是否开启
boolean openSecondaryAccount = "1".equals(getSalarySysConfService(user).getValueByCode(OPEN_SECONDARY_ACCOUNT));
2022-04-07 16:54:10 +08:00
@Override
2023-03-16 16:10:29 +08:00
public List<DataCollectionEmployee> listAll(UseEmployeeTypeEnum empType) {
List<DataCollectionEmployee> result = new ArrayList<>();
if (empType == UseEmployeeTypeEnum.ORG) {
2023-08-08 09:21:14 +08:00
result = employBiz.listAll();
2023-03-16 16:10:29 +08:00
}
if (empType == UseEmployeeTypeEnum.EXT) {
result = getExtEmpService(user).listEmployee();
}
if (empType == UseEmployeeTypeEnum.ALL) {
2023-08-08 09:21:14 +08:00
result.addAll(employBiz.listAll());
2023-03-13 15:53:56 +08:00
result.addAll(getExtEmpService(user).listEmployee());
}
2024-10-16 15:25:48 +08:00
if (!openSecondaryAccount) {
result = result.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList());
}
2024-03-11 16:50:47 +08:00
SalaryI18nUtil.i18nList(result);
2023-03-13 15:53:56 +08:00
return result;
2022-04-07 16:54:10 +08:00
}
@Override
public List<DataCollectionEmployee> listAllForReport() {
2023-03-13 15:53:56 +08:00
List<DataCollectionEmployee> result = employBiz.listAllForReport();
2023-03-16 16:10:29 +08:00
if (openExtEmp) {
2023-03-13 15:53:56 +08:00
result.addAll(getExtEmpService(user).listAllForReport());
}
2024-10-16 15:25:48 +08:00
if (!openSecondaryAccount) {
result = result.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList());
}
2024-03-11 16:50:47 +08:00
SalaryI18nUtil.i18nList(result);
2023-03-13 15:53:56 +08:00
return result;
}
2022-04-07 16:54:10 +08:00
@Override
2025-01-20 15:05:04 +08:00
public List<DataCollectionEmployee> listBySalarySobId(Long salarySobId, boolean hasExtEmp) {
2023-03-15 18:03:46 +08:00
List<DataCollectionEmployee> includeSalaryEmployees = new ArrayList<>();
2022-04-07 16:54:10 +08:00
// 查询薪资账套的人员范围
List<SalarySobRangePO> includeSalarySobRangePOS = getSalarySobRangeService(user).listBySalarySobIdAndIncludeType(salarySobId, NumberUtils.INTEGER_ONE);
2023-03-15 18:03:46 +08:00
if (CollectionUtils.isNotEmpty(includeSalarySobRangePOS)) {
2022-04-07 16:54:10 +08:00
// 将薪资账套的人员范围转换成人员查询参数
2023-03-15 18:03:46 +08:00
List<SalarySobRangeEmpQueryParam> includeQueryParams = SalarySobRangeBO.convert2EmployeeQueryParam(includeSalarySobRangePOS);
2022-04-07 16:54:10 +08:00
// 根据上一步的查询参数查询人员
2023-03-15 18:03:46 +08:00
includeSalaryEmployees = listByParams(includeQueryParams);
if (CollectionUtils.isEmpty(includeSalaryEmployees)) {
return Collections.emptyList();
}
//去重
includeSalaryEmployees = includeSalaryEmployees.stream().distinct().collect(Collectors.toList());
// 查询薪资账套的人员范围(从范围中排除)
List<SalarySobRangePO> excludeSalarySobRangePOS = getSalarySobRangeService(user).listBySalarySobIdAndIncludeType(salarySobId, NumberUtils.INTEGER_ZERO);
if (CollectionUtils.isNotEmpty(excludeSalarySobRangePOS)) {
// 将薪资账套的人员范围转换成人员查询参数
List<SalarySobRangeEmpQueryParam> excludeQueryParams = SalarySobRangeBO.convert2EmployeeQueryParam(excludeSalarySobRangePOS);
// 根据上一步的查询参数查询人员
List<DataCollectionEmployee> excludeSalaryEmployees = listByParams(excludeQueryParams);
// 需要排除的人员范围
Set<Long> excludeEmployeeIds = SalaryEntityUtil.properties(excludeSalaryEmployees, DataCollectionEmployee::getEmployeeId);
// 过滤人员
includeSalaryEmployees = includeSalaryEmployees.stream()
.filter(salaryEmployee -> !excludeEmployeeIds.contains(salaryEmployee.getEmployeeId()))
.collect(Collectors.toList());
}
2022-04-07 16:54:10 +08:00
}
2023-03-15 18:03:46 +08:00
//外部人员
2025-01-20 15:05:04 +08:00
if(hasExtEmp){
List<SalarySobExtRangePO> salarySobExtRangePOS = getSalarySobExtRangeService(user).listBySalarySobId(salarySobId);
if (CollectionUtils.isNotEmpty(salarySobExtRangePOS)) {
List<Long> ids = SalaryEntityUtil.properties(salarySobExtRangePOS, SalarySobExtRangePO::getTargetId, Collectors.toList());
List<DataCollectionEmployee> extEmps = getExtEmpService(user).getEmployeeByIds(ids);
extEmps = extEmps.stream().distinct().collect(Collectors.toList());
includeSalaryEmployees.addAll(extEmps);
}
2023-03-15 18:03:46 +08:00
}
2024-10-16 15:25:48 +08:00
if (!openSecondaryAccount) {
includeSalaryEmployees = includeSalaryEmployees.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList());
}
2024-03-11 16:50:47 +08:00
SalaryI18nUtil.i18nList(includeSalaryEmployees);
2022-04-07 16:54:10 +08:00
return includeSalaryEmployees;
}
@Override
2023-03-06 17:57:20 +08:00
public List<DataCollectionEmployee> getEmployeeByIdsAll(List<Long> ids) {
2023-07-13 14:11:32 +08:00
if (CollectionUtils.isEmpty(ids)) {
return new ArrayList<>();
}
List<DataCollectionEmployee> employeeList = employBiz.getEmployeeByIdsAll(ids);
if (openExtEmp) {
employeeList.addAll(getExtEmpService(user).getEmployeeByIds(ids));
}
2024-10-16 15:25:48 +08:00
if (!openSecondaryAccount) {
employeeList = employeeList.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList());
}
2024-03-11 16:50:47 +08:00
SalaryI18nUtil.i18nList(employeeList);
2023-07-13 14:11:32 +08:00
return employeeList;
2022-04-07 16:54:10 +08:00
}
2022-04-08 19:08:59 +08:00
2023-04-14 15:18:18 +08:00
@Override
public List<DataCollectionEmployee> listByIds(List<Long> ids) {
2024-02-28 16:44:52 +08:00
if (CollectionUtils.isEmpty(ids)) {
return Collections.emptyList();
}
List<DataCollectionEmployee> result = new ArrayList<>();
if (openExtEmp) {
result.addAll(getExtEmpService(user).getEmployeeByIds(ids));
}
result.addAll(employBiz.getEmployeeByIdsAll(ids));
2024-10-16 15:25:48 +08:00
if (!openSecondaryAccount) {
result = result.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList());
}
2024-03-11 16:50:47 +08:00
SalaryI18nUtil.i18nList(result);
2024-02-28 16:44:52 +08:00
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-16 16:10:29 +08:00
if (openExtEmp) {
2024-03-11 16:50:47 +08:00
DataCollectionEmployee employee = getExtEmpService(user).getEmployeeById(employeeId);
if (Objects.nonNull(employee)) {
return SalaryI18nUtil.i18n(employee);
2023-03-13 15:53:56 +08:00
}
}
2024-03-11 16:50:47 +08:00
DataCollectionEmployee employee = employBiz.getEmployeeById(employeeId);
return SalaryI18nUtil.i18n(employee);
2022-04-08 19:08:59 +08:00
}
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-16 16:10:29 +08:00
if (openExtEmp) {
2023-03-13 15:53:56 +08:00
employeeList.addAll(getExtEmpService(user).getEmployeeByIds(longs));
}
2022-08-02 17:57:29 +08:00
}
2024-10-16 15:25:48 +08:00
if (!openSecondaryAccount) {
employeeList = employeeList.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList());
}
2024-03-11 16:50:47 +08:00
return SalaryI18nUtil.i18nList(employeeList);
2022-06-10 13:33:48 +08:00
}
2022-08-26 14:06:21 +08:00
2024-06-26 11:33:12 +08:00
@Override
public List<DataCollectionEmployee> getEmployeeByIdsIncludeAccountType(List<Long> simpleEmployeeIds) {
if (CollectionUtils.isEmpty(simpleEmployeeIds)) {
return new ArrayList<>();
}
List<DataCollectionEmployee> employeeList = new ArrayList<>();
List<List<Long>> partition = Lists.partition(simpleEmployeeIds, 1000);
for (List<Long> longs : partition) {
employeeList.addAll(employBiz.getEmployeeByIdsIncludeAccountType(longs));
if (openExtEmp) {
employeeList.addAll(getExtEmpService(user).getEmployeeByIds(longs));
}
}
2024-10-16 15:25:48 +08:00
if (!openSecondaryAccount) {
employeeList = employeeList.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList());
}
2024-06-26 11:33:12 +08:00
return SalaryI18nUtil.i18nList(employeeList);
}
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());
2024-10-16 15:25:48 +08:00
if (!openSecondaryAccount) {
employeeSameIds = employeeSameIds.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList());
}
2024-03-11 16:50:47 +08:00
return SalaryI18nUtil.i18nList(employeeSameIds);
2022-08-26 14:06:21 +08:00
}
2022-09-21 11:52:06 +08:00
@Override
2024-05-23 09:16:28 +08:00
public List<DataCollectionEmployee> matchImportEmployee(String confValue, List<DataCollectionEmployee> employeeList, String userName, String deparmentName, String mobile, String workcode, String idNo, Long uid) {
2022-09-21 11:52:06 +08:00
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
}
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());
2024-05-23 09:16:28 +08:00
} else if ("2".equals(confValue)) {
employees = employeeList.stream().filter(e -> (StringUtils.isBlank(idNo) || Objects.equals(e.getIdNo(), idNo)))
.collect(Collectors.toList());
2022-09-21 11:52:06 +08:00
}
2024-10-16 15:25:48 +08:00
if (!openSecondaryAccount) {
employees = employees.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList());
}
2024-03-11 16:50:47 +08:00
return SalaryI18nUtil.i18nList(employees);
2022-09-21 11:52:06 +08:00
}
2023-03-06 17:57:20 +08:00
2023-03-15 18:03:46 +08:00
/**
* 人员定位方式
* 0代表姓名+部门+手机号的匹配原则1代表工号为唯一匹配原则
2023-03-16 16:10:29 +08:00
*
2023-03-15 18:03:46 +08:00
* @return
*/
@Override
public String empValidType() {
2024-10-16 15:25:48 +08:00
SalarySysConfPO salarySysConfPO = getSalarySysConfService(user).getOneByCode("matchEmployeeMode");
2023-03-15 18:03:46 +08:00
return (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0";
}
2023-03-06 17:57:20 +08:00
@Override
public List<DeptInfo> getDeptInfoList(List<Long> departmentIds) {
2024-03-22 15:23:03 +08:00
return SalaryI18nUtil.i18nList(employBiz.getDeptInfoList(departmentIds));
}
2024-07-25 14:04:14 +08:00
@Override
public DeptInfo getDeptInfoById(Long departmentId) {
if (departmentId == null) {
return null;
}
return SalaryI18nUtil.i18n(employBiz.getDeptInfoById(departmentId));
}
2024-03-22 15:23:03 +08:00
@Override
public List<DeptInfo> getVirtualDeptInfoList(List<Long> virtualDepartmentIds) {
if (CollectionUtils.isEmpty(virtualDepartmentIds)) {
return Collections.emptyList();
}
2024-05-23 09:16:28 +08:00
return SalaryI18nUtil.i18nList(getEmployMapper().getVirtualDeptInfoList(virtualDepartmentIds));
2023-03-06 17:57:20 +08:00
}
2024-03-22 15:23:03 +08:00
2023-03-06 17:57:20 +08:00
@Override
public List<SubCompanyInfo> getSubCompanyInfoList(List<Long> subDepartmentIds) {
2024-03-11 16:50:47 +08:00
return SalaryI18nUtil.i18nList(employBiz.getSubCompanyInfoList(subDepartmentIds));
2023-03-06 17:57:20 +08:00
}
2024-07-25 14:04:14 +08:00
@Override
public SubCompanyInfo getSubCompanyInfoById(Long subDepartmentId) {
return SalaryI18nUtil.i18n(employBiz.getSubCompanyInfoById(subDepartmentId));
}
2024-03-22 15:23:03 +08:00
@Override
public List<SubCompanyInfo> getVirtualSubCompanyInfoList(List<Long> virtualSubDepartmentIds) {
if (CollectionUtils.isEmpty(virtualSubDepartmentIds)) {
return Collections.emptyList();
}
return SalaryI18nUtil.i18nList(getEmployMapper().getVirtualSubCompanyInfoList(virtualSubDepartmentIds));
}
2023-03-06 17:57:20 +08:00
@Override
public List<PositionInfo> listPositionInfo(List<Long> positionIds) {
2024-03-11 16:50:47 +08:00
return SalaryI18nUtil.i18nList(employBiz.listPositionInfo(positionIds));
2023-03-06 17:57:20 +08:00
}
2024-07-25 14:04:14 +08:00
@Override
public PositionInfo getPositionInfoById(Long positionId) {
return SalaryI18nUtil.i18n(employBiz.getPositionInfoById(positionId));
}
2023-03-06 17:57:20 +08:00
@Override
public List<DataCollectionEmployee> listEmployee() {
2023-03-13 15:53:56 +08:00
List<DataCollectionEmployee> result = employBiz.listEmployee();
2023-03-16 16:10:29 +08:00
if (openExtEmp) {
2023-03-13 15:53:56 +08:00
result.addAll(getExtEmpService(user).listEmployee());
}
2024-10-16 15:25:48 +08:00
if (!openSecondaryAccount) {
result = result.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList());
}
2024-03-11 16:50:47 +08:00
return SalaryI18nUtil.i18nList(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) {
2024-03-22 15:23:03 +08:00
if (CollectionUtils.isEmpty(includeQueryParams)) {
return Collections.emptyList();
}
2024-08-15 10:37:41 +08:00
List<SalarySobRangeEmpQueryParam> queryParams = includeQueryParams.stream().filter(param -> !param.getTargetType().equals(TargetTypeEnum.SQL.name())).collect(Collectors.toList());
List<DataCollectionEmployee> result = employBiz.listByParams(queryParams);
2023-03-16 16:10:29 +08:00
if (openExtEmp) {
2024-08-15 10:37:41 +08:00
result.addAll(getExtEmpService(user).listByParams(queryParams));
2023-03-13 15:53:56 +08:00
}
2024-03-22 15:23:03 +08:00
// 查询虚拟部门、分部人员信息
2024-08-15 10:37:41 +08:00
List<SalarySobRangeEmpQueryParam> virtualParams = queryParams.stream().filter(param ->
2024-03-22 15:23:03 +08:00
(param.getTargetType().equals(TargetTypeEnum.SUBCOMPANY.name()) || param.getTargetType().equals(TargetTypeEnum.DEPT.name())) && ((List<Long>) param.getTargetIds()).get(0).compareTo(0L) < 0
).collect(Collectors.toList());
result.addAll(employBiz.listByVirtualParams(virtualParams));
2024-08-15 10:37:41 +08:00
List<Long> empIds = new ArrayList<>();
includeQueryParams.stream()
.filter(param -> param.getTargetType().equals(TargetTypeEnum.SQL.name()))
.forEach(param -> {
String sql = param.getTarget();
RecordSet rs = new RecordSet();
if (rs.execute(sql)) {
while (rs.next()) {
empIds.add((long) rs.getInt("id"));
}
}
});
List<DataCollectionEmployee> employees = getSalaryEmployeeService(user).getEmployeeByIdsAll(empIds);
2024-08-15 10:37:41 +08:00
result.addAll(employees);
2024-03-22 15:23:03 +08:00
// 从hrmresource和hrmresourcevirtual可能获取到重复人员数据需要根据人员id去重
result = result.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparingLong(DataCollectionEmployee::getEmployeeId))), ArrayList::new));
2024-10-16 15:25:48 +08:00
if (!openSecondaryAccount) {
result = result.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList());
}
2024-06-18 11:01:58 +08:00
return result;
2023-03-07 17:14:25 +08:00
}
2023-08-28 13:31:11 +08:00
2023-08-30 10:41:00 +08:00
/**
* 根据离职日期获取离职信息
2023-11-02 18:41:58 +08:00
*
2023-08-30 10:41:00 +08:00
* @param dismissDate
* @return
*/
@Override
public Map<Long, String> getResignationMapByDate(String dismissDate) {
if (StringUtils.isBlank(dismissDate)) {
return Collections.emptyMap();
}
List<DataCollectionEmployee> employeeList = employBiz.listByDismissDate(dismissDate);
return SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getDismissdate);
}
2023-11-02 18:41:58 +08:00
@Override
2023-11-06 11:19:00 +08:00
public List<DataCollectionEmployee> expandEmployeeInfo(List<Long> ids, EmployeeInfoExpandDTO param) {
2023-11-02 18:41:58 +08:00
List<DataCollectionEmployee> employees = getEmployeeByIdsAll(ids);
2023-11-06 11:19:00 +08:00
if (param != null) {
RecordSet rs = new RecordSet();
String sql = param.getExpandSql().replace("=$人员id$", "in (" + StringUtils.join(ids, ",") + ")")
.replace("in($人员id$)", "in (" + StringUtils.join(ids, ",") + ")");
2023-11-07 11:00:00 +08:00
String primaryKey = param.getPk();
2023-11-06 11:19:00 +08:00
rs.executeQuery(sql);
while (rs.next()) {
Map<String, String> extendData = new HashMap<>();
param.getFieldSettings().forEach(setting -> {
String field = setting.getField();
String value = rs.getString(field);
setting.setValue(value);
extendData.put(field, value);
});
String id = rs.getString(primaryKey);
employees.stream()
.filter(e -> id.equals(e.getEmployeeId().toString()))
.forEach(e -> e.setExtendData(extendData));
}
2023-11-02 18:41:58 +08:00
}
2024-10-16 15:25:48 +08:00
if (!openSecondaryAccount) {
employees = employees.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList());
}
2024-03-11 16:50:47 +08:00
return SalaryI18nUtil.i18nList(employees);
2023-11-02 18:41:58 +08:00
}
2023-11-06 11:19:00 +08:00
2023-11-09 11:34:00 +08:00
@Override
public Map<Long, Map<String, String>> expandEmployeeMap(List<Long> ids, EmployeeInfoExpandDTO param) {
if (CollectionUtils.isNotEmpty(ids) && param != null) {
Map<Long, Map<String, String>> map = new HashMap<>();
List<List<Long>> partition = Lists.partition(ids, 5);
for (int i = 0; i < partition.size(); i++) {
List<Long> idList = partition.get(i);
RecordSet rs = new RecordSet();
String sql = param.getExpandSql().replace("=$人员id$", " in (" + StringUtils.join(idList, ",") + ")")
.replace("in($人员id$)", " in (" + StringUtils.join(idList, ",") + ")");
String primaryKey = param.getPk();
rs.executeQuery(sql);
log.info("扩展属性sql" + sql);
while (rs.next()) {
Map<String, String> extendData = new HashMap<>();
param.getFieldSettings().forEach(setting -> {
String field = setting.getField();
String value = rs.getString(field);
setting.setValue(value);
2024-10-23 17:41:28 +08:00
extendData.put(field, Util.formatMultiLang(value));
2023-11-09 11:34:00 +08:00
});
String id = rs.getString(primaryKey);
map.put(Long.valueOf(id), extendData);
}
}
return map;
}
return new HashMap<>();
}
2023-11-06 11:19:00 +08:00
@Override
public void saveEmployeeExpandFieldSettings(EmployeeInfoExpandDTO param) {
String settings = JSON.toJSONString(param.getFieldSettings());
Date now = new Date();
if (Objects.nonNull(param.getId())) {
ExpandFieldSettingsPO po = getExpandFieldSettingsMapper().getById(param.getId());
if (po == null) {
throw new RuntimeException("配置不存在!");
}
2023-11-07 11:00:00 +08:00
po.setPk(param.getPk());
2023-11-06 11:19:00 +08:00
po.setExpandSql(param.getExpandSql());
po.setFieldSetting(settings);
po.setCreator((long) user.getUID());
po.setUpdateTime(now);
getExpandFieldSettingsMapper().update(po);
} else {
ExpandFieldSettingsPO po = ExpandFieldSettingsPO.builder()
.id(IdGenerator.generate())
.module(param.getModule())
.moduleInfo(param.getModuleInfo())
2023-11-07 11:00:00 +08:00
.pk(param.getPk())
2023-11-06 11:19:00 +08:00
.fieldSetting(settings)
.expandSql(param.getExpandSql())
.deleteType(0)
.creator((long) user.getUID())
.createTime(now)
.updateTime(now)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.build();
getExpandFieldSettingsMapper().insertIgnoreNull(po);
}
}
@Override
public EmployeeInfoExpandDTO getExpandFieldSettings(String module) {
ExpandFieldSettingsPO po = getExpandFieldSettingsMapper().getByModule(module);
if (po != null) {
List<FieldSetting> list = JSON.parseArray(po.getFieldSetting(), FieldSetting.class);
return EmployeeInfoExpandDTO.builder()
.id(po.getId())
.module(po.getModule())
.moduleInfo(po.getModuleInfo())
2023-11-07 11:00:00 +08:00
.pk(po.getPk())
2023-11-06 11:19:00 +08:00
.expandSql(po.getExpandSql())
.fieldSettings(list)
.build();
}
return null;
}
2024-03-22 15:23:03 +08:00
@Override
public List<DataCollectionEmployee> getVirtualEmpByVirtualDepIds(List<Long> virtualDepartmentIds) {
if (CollectionUtils.isEmpty(virtualDepartmentIds)) {
return Collections.emptyList();
}
2024-10-16 15:25:48 +08:00
List<DataCollectionEmployee> employees = getEmployMapper().listVirtualEmpByVirtualDepIds(virtualDepartmentIds);
if (!openSecondaryAccount) {
employees = employees.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList());
}
return employees;
2024-03-22 15:23:03 +08:00
}
@Override
public List<DataCollectionEmployee> getVirtualEmpByVirtualSubCompanyIds(List<Long> virtualSubCompanyIds) {
if (CollectionUtils.isEmpty(virtualSubCompanyIds)) {
return Collections.emptyList();
}
return getEmployMapper().listVirtualEmpByVirtualSubCompanyIds(virtualSubCompanyIds);
}
2024-03-25 16:08:34 +08:00
@Override
public List<DataCollectionEmployee> listBySubCompanyOrDepartment(List<Long> subCompanyIds, List<Long> departmentIds) {
List<DataCollectionEmployee> employeeList = new ArrayList<>();
employeeList.addAll(getEmployMapper().listBySubCompanyOrDepartment(subCompanyIds, departmentIds));
if (openExtEmp) {
employeeList.addAll(getExtEmpService(user).listBySubCompanyOrDepartment(subCompanyIds, departmentIds));
}
2024-10-16 15:25:48 +08:00
if (!openSecondaryAccount) {
employeeList = employeeList.stream().filter(e -> e.getAccountType() == null || e.getAccountType() == 0).collect(Collectors.toList());
}
2024-03-25 16:08:34 +08:00
return SalaryI18nUtil.i18nList(employeeList);
}
2024-07-26 16:35:51 +08:00
@Override
public List<Long> listBySubCompany(List<Long> subCompanyIds) {
return getEmployMapper().listBySubCompany(subCompanyIds);
}
@Override
public List<Long> listByDepartment(List<Long> departmentIds) {
return getEmployMapper().listByDepartment(departmentIds);
}
@Override
public List<Long> listByJob(List<Long> jobIds) {
return getEmployMapper().listByJob(jobIds);
}
2023-08-28 13:31:11 +08:00
@Override
public Map<Long, String> mapByEmployeeIds(Collection<Long> employeeIds) {
2023-08-29 13:55:36 +08:00
List<DataCollectionEmployee> simpleUserInfos = getEmployeeByIdsAll(new ArrayList<>(employeeIds));
2023-08-28 13:31:11 +08:00
Map<Long, String> result = new HashMap<>();
simpleUserInfos.forEach(e -> {
result.put(e.getEmployeeId(), e.getIdNo());
});
return result;
}
2024-02-27 15:16:13 +08:00
@Override
public List<DataCollectionEmployee> listByKeyword(String keyword) {
if (StringUtils.isBlank(keyword)) {
return Collections.emptyList();
}
List<DataCollectionEmployee> result = getEmployMapper().listByKeyword(keyword);
if (openExtEmp) {
result.addAll(getExtEmpService(user).listByKeyword(keyword));
}
return result;
}
2024-07-25 14:04:14 +08:00
@Override
public JobCallInfo getJobCallInfoById(Long jobCallId) {
if (jobCallId == null) {
return null;
}
return SalaryI18nUtil.i18n(getEmployMapper().getJobCallInfoById(jobCallId));
}
2024-12-04 15:41:11 +08:00
2024-12-06 16:00:05 +08:00
public List<DataCollectionEmployee> snapshot(List<Long> employeeIds, Date snapshotTime) {
List<DataCollectionEmployee> currentEmployees = getEmployeeByIdsAll(employeeIds);
Map<Long, DataCollectionEmployee> currentEmployeeMap = SalaryEntityUtil.convert2Map(currentEmployees, DataCollectionEmployee::getEmployeeId);
List<DataCollectionEmployee> employees = employeeIds.stream()
.map(employeeId -> {
List<HrmSnapshotPO> snapshot = getHrmSnapshotMapper().snapshot(employeeId, snapshotTime);
return snapshot.stream().findFirst().map(hrmSnapshotPO -> DataCollectionEmployee.
builder()
.employeeId(employeeId)
.username(hrmSnapshotPO.getLastname())
.departmentName(hrmSnapshotPO.getDepartmentname())
2024-12-06 16:05:51 +08:00
.departmentId(hrmSnapshotPO.getDepartmentid() == null ? null : NumberUtil.parseLong(Util.null2String(hrmSnapshotPO.getDepartmentid())))
2024-12-06 16:00:05 +08:00
.subcompanyName(hrmSnapshotPO.getSubcompanyname())
2025-01-20 15:05:04 +08:00
.subcompanyid(hrmSnapshotPO.getSubcompanyid1() == null ? null : NumberUtil.parseLong(Util.null2String(hrmSnapshotPO.getSubcompanyid1())))
.costcenterId(hrmSnapshotPO.getCostcenterid() == null ? null : NumberUtil.parseLong(Util.null2String(hrmSnapshotPO.getCostcenterid())))
.locationId(hrmSnapshotPO.getLocationid() == null ? null : NumberUtil.parseLong(Util.null2String(hrmSnapshotPO.getLocationid())))
2024-12-06 16:00:05 +08:00
.jobtitleName(hrmSnapshotPO.getJobtitlename())
2025-01-20 15:05:04 +08:00
.jobtitleId(hrmSnapshotPO.getJobtitle() == null ? null : NumberUtil.parseLong(Util.null2String(hrmSnapshotPO.getJobtitle())))
2024-12-06 16:00:05 +08:00
.companystartdate(hrmSnapshotPO.getCompanystartdate())
.mobile(hrmSnapshotPO.getMobile())
// .dismissdate()
.status(Util.null2String(hrmSnapshotPO.getStatus()))
.statusName(UserStatusEnum.getDefaultLabelByValue(NumberUtils.toInt(Util.null2String(hrmSnapshotPO.getStatus()), 1)))
.workcode(hrmSnapshotPO.getWorkcode())
.sex(hrmSnapshotPO.getSex())
.email(hrmSnapshotPO.getEmail())
.telephone(hrmSnapshotPO.getTelephone())
.jobcall(hrmSnapshotPO.getJobcallname())
2025-01-20 15:05:04 +08:00
.jobcallId(hrmSnapshotPO.getJobcall() == null ? null : NumberUtil.parseLong(Util.null2String(hrmSnapshotPO.getJobcall())))
2024-12-06 16:00:05 +08:00
.birthday(hrmSnapshotPO.getBirthday())
2024-12-06 16:05:51 +08:00
.workYear(hrmSnapshotPO.getWorkyear() == null ? null : hrmSnapshotPO.getWorkyear().doubleValue())
.companyWorkYear(hrmSnapshotPO.getCompanyworkyear() == null ? null : hrmSnapshotPO.getCompanyworkyear().doubleValue())
2024-12-06 16:00:05 +08:00
.idNo(hrmSnapshotPO.getCertificatenum())
.accountTypeName(AccountTypeEnum.getDefaultLabelByValue(hrmSnapshotPO.getAccounttype()))
.accountType(hrmSnapshotPO.getAccounttype())
.build())
.orElse(currentEmployeeMap.get(employeeId));
}).collect(Collectors.toList());
return SalaryI18nUtil.i18nList(employees);
2024-12-04 15:41:11 +08:00
}
2022-04-07 16:54:10 +08:00
}