package com.engine.salary.service.impl; 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; import com.engine.salary.entity.salarysob.bo.SalarySobRangeBO; import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam; import com.engine.salary.entity.salarysob.po.SalarySobRangePO; import com.engine.salary.enums.UserStatusEnum; import com.engine.salary.mapper.datacollection.EmployMapper; import com.engine.salary.service.SalaryEmployeeService; import com.engine.salary.service.SalarySobRangeService; import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.db.MapperProxyFactory; import com.google.common.collect.Lists; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import weaver.hrm.User; import java.util.*; import java.util.stream.Collectors; /** * 人员信息 *

Copyright: Copyright (c) 2022

*

Company: 泛微软件

* * @author qiantao * @version 1.0 **/ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployeeService { private EmployBiz employBiz = new EmployBiz(); private SalarySobRangeService getSalarySobRangeService(User user) { return ServiceUtil.getService(SalarySobRangeServiceImpl.class, user); } private EmployMapper getEmployMapper() { return MapperProxyFactory.getProxy(EmployMapper.class); } @Override public List listAll() { return employBiz.listEmployee(); } @Override public List listAllForReport() { return getEmployMapper().listAllForReport(); } @Override public List listBySalarySobId(Long salarySobId) { // 查询薪资账套的人员范围 List includeSalarySobRangePOS = getSalarySobRangeService(user).listBySalarySobIdAndIncludeType(salarySobId, NumberUtils.INTEGER_ONE); if (CollectionUtils.isEmpty(includeSalarySobRangePOS)) { return Collections.emptyList(); } // 将薪资账套的人员范围转换成人员查询参数 List includeQueryParams = SalarySobRangeBO.convert2EmployeeQueryParam(includeSalarySobRangePOS); // 根据上一步的查询参数查询人员 List includeSalaryEmployees = employBiz.listByParams(includeQueryParams); if (CollectionUtils.isEmpty(includeSalaryEmployees)) { return Collections.emptyList(); } // 查询薪资账套的人员范围(从范围中排除) List excludeSalarySobRangePOS = getSalarySobRangeService(user).listBySalarySobIdAndIncludeType(salarySobId, NumberUtils.INTEGER_ZERO); if (CollectionUtils.isNotEmpty(excludeSalarySobRangePOS)) { // 将薪资账套的人员范围转换成人员查询参数 List excludeQueryParams = SalarySobRangeBO.convert2EmployeeQueryParam(excludeSalarySobRangePOS); // 根据上一步的查询参数查询人员 List excludeSalaryEmployees = employBiz.listByParams(excludeQueryParams); // 需要排除的人员范围 Set excludeEmployeeIds = SalaryEntityUtil.properties(excludeSalaryEmployees, DataCollectionEmployee::getEmployeeId); // 过滤人员 includeSalaryEmployees = includeSalaryEmployees.stream() .filter(salaryEmployee -> !excludeEmployeeIds.contains(salaryEmployee.getEmployeeId())) .collect(Collectors.toList()); } return includeSalaryEmployees; } @Override public List listByIds(List ids) { return employBiz.getEmployeeByIdsAll(ids); } @Override public DataCollectionEmployee getEmployeeById(Long employeeId) { return employBiz.getEmployeeById(employeeId); } @Override public List getEmployeeByIds(List simpleEmployeeIds) { if (CollectionUtils.isEmpty(simpleEmployeeIds)) { return new ArrayList<>(); } List employeeList = new ArrayList<>(); List> partition = Lists.partition(simpleEmployeeIds, 1000); for (List longs : partition) { employeeList.addAll(getEmployMapper().getEmployeeByIds(longs)); } return employeeList; } public List filterEmployees(List employees, String userName, String deparmentName, String mobile) { List 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; } }