employeeService查询外部

This commit is contained in:
Harryxzy 2023-03-13 15:53:56 +08:00
parent d8c13b70d2
commit 32b1a2db48
5 changed files with 244 additions and 8 deletions

View File

@ -1,7 +1,11 @@
package com.engine.salary.mapper.extemp;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.extemp.po.ExtEmpPO;
import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
public interface ExternalEmployeeMapper {
@ -55,4 +59,31 @@ public interface ExternalEmployeeMapper {
*/
int delete(Long id);
/**
* 根据薪资账套的人员范围转换而成的查询参数查询人员
*
* @param queryParams 薪资账套的人员范围转换而成的查询参数
* @return
*/
Collection<DataCollectionEmployee> listByParams( @Param("params") List<SalarySobRangeEmpQueryParam> queryParams);
/**
* 获取所有员工关联部门
*
* @return
*/
List<DataCollectionEmployee> listEmployee();
/**
* 多表联查
* @param ids
* @return
*/
List<DataCollectionEmployee> getEmployeeByIdsAll(@Param("collection")List<Long> ids);
/**
* 报表专用
* @return
*/
Collection<DataCollectionEmployee> listAllForReport();
}

View File

@ -170,6 +170,132 @@
</if>
ORDER BY id DESC
</select>
<select id="listByParams" resultType="com.engine.salary.entity.datacollection.DataCollectionEmployee">
select e.id as employeeId,
e.lastname as username,
e.status as status,
e.certificatenum as idNo,
e.workcode as workcode,
d.departmentname as departmentName,
d.id as departmentId,
c.jobtitlename as jobtitleName,
c.id as jobtitleId,
e.companystartdate as companystartdate,
e.mobile as mobile
from hrsa_external_employee e
left join hrmdepartment d on e.departmentid = d.id
left join hrmjobtitles c on e.jobtitle = c.id
WHERE e.status not in (7) and (e.accounttype is null or e.accounttype = 0)
<if test="params != null and params.size() > 0">
AND ( 1=2
<foreach collection="params" item="param">
OR
(
<if test="param.targetType == 'EMPLOYEE'">
e.id IN
<foreach collection="param.targetIds" open="(" item="targetId" separator="," close=")">
#{targetId}
</foreach>
</if>
<if test="param.targetType == 'DEPT'">
d.id IN
<foreach collection="param.targetIds" open="(" item="targetId" separator="," close=")">
#{targetId}
</foreach>
</if>
<if test="param.targetType == 'POSITION'">
c.id IN
<foreach collection="param.targetIds" open="(" item="targetId" separator="," close=")">
#{targetId}
</foreach>
</if>
<if test="param.targetType == 'SUBCOMPANY'">
e.subcompanyid1 IN
<foreach collection="param.targetIds" open="(" item="targetId" separator="," close=")">
#{targetId}
</foreach>
</if>
<if test="param.employeeStatus != null and param.employeeStatus.size() > 0">
AND e.status IN
<foreach collection="param.employeeStatus" open="(" item="status" separator="," close=")">
#{status}
</foreach>
</if>
<!-- &#45;&#45; 在职-->
<!-- <if test="param.employeeStatus != null and param.employeeStatus == 'normal'">-->
<!-- AND em.status in (0,1,2,3)-->
<!-- </if>-->
<!-- &#45;&#45; 离职-->
<!-- <if test="param.employeeStatus != null and param.employeeStatus == 'unavailable'">-->
<!-- AND em.status in (4,5,6)-->
<!-- </if>-->
)
</foreach>
)
</if>
</select>
<select id="listEmployee" resultType="com.engine.salary.entity.datacollection.DataCollectionEmployee">
select e.ID as employeeId,
e.LASTNAME as username,
d.DEPARTMENTNAME as departmentName,
e.status,
e.mobile,
e.workcode
from hrsa_external_employee e
left join hrmdepartment d on e.departmentid = d.id
</select>
<select id="getEmployeeByIdsAll"
resultType="com.engine.salary.entity.datacollection.DataCollectionEmployee">
select e.id as employeeId,
e.lastname as username,
d.departmentname as departmentName,
d.id as departmentId,
sc.SUBCOMPANYNAME as subcompanyName,
c.jobtitlename as jobtitleName,
c.id as jobtitleId,
e.companystartdate as companystartdate,
e.mobile as mobile,
e.status as status,
e.workcode as workcode,
e.sex as sex,
e.email as email,
e.telephone as telephone,
e.jobcall as jobcall,
e.birthday as birthday,
e.certificatenum as idNo,
c.id as jobtitleId,
e.enddate as dismissdate
from hrsa_external_employee e
left join hrmdepartment d on e.departmentid = d.id
left join hrmjobtitles c on e.jobtitle = c.id
left join HrmSubCompany sc on e.SUBCOMPANYID1=sc.id
where 1 = 1
<if test="collection != null and collection.size()>0">
AND e.id IN
<foreach collection="collection" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
</select>
<select id="listAllForReport" resultType="com.engine.salary.entity.datacollection.DataCollectionEmployee">
select e.id as employeeId,
e.lastname as username,
e.status as status,
e.workcode as workcode,
e.certificatenum as idNo,
e.companystartdate as companystartdate,
e.mobile as mobile,
e.departmentid as departmentId,
e.subcompanyid1 as subcompanyid,
e.costcenterid as costcenterId,
e.locationid as locationId,
e.jobtitle as jobtitleId,
d.departmentname as departmentName,
d.id as departmentId
from hrsa_external_employee e
left join hrmdepartment d on e.departmentid = d.id
</select>
<!-- 插入不为NULL的字段 -->

View File

@ -4,6 +4,7 @@ import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.extemp.param.ExtEmpQueryParam;
import com.engine.salary.entity.extemp.param.ExtEmpSaveParam;
import com.engine.salary.entity.extemp.po.ExtEmpPO;
import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam;
import com.engine.salary.util.page.PageInfo;
import java.util.Collection;
@ -30,4 +31,16 @@ public interface ExtEmpService {
*/
List<DataCollectionEmployee> getEmployeeByIds(List<Long> ids);
List<DataCollectionEmployee> listByParams(List<SalarySobRangeEmpQueryParam> includeQueryParams);
/**
* 查询人员列表
*
* @return
*/
List<DataCollectionEmployee> listEmployee();
Collection<DataCollectionEmployee> getEmployeeByIdsAll(List<Long> ids);
Collection<DataCollectionEmployee> listAllForReport();
}

View File

@ -5,11 +5,13 @@ import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.extemp.param.ExtEmpQueryParam;
import com.engine.salary.entity.extemp.param.ExtEmpSaveParam;
import com.engine.salary.entity.extemp.po.ExtEmpPO;
import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam;
import com.engine.salary.mapper.extemp.ExternalEmployeeMapper;
import com.engine.salary.service.ExtEmpService;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
import com.google.common.collect.Lists;
import dm.jdbc.util.IdGenerator;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
@ -100,6 +102,37 @@ public class ExtEmpServiceImpl extends Service implements ExtEmpService {
}
@Override
public List<DataCollectionEmployee> listByParams(List<SalarySobRangeEmpQueryParam> includeQueryParams) {
List<DataCollectionEmployee> emps = new ArrayList<>();
List<List<SalarySobRangeEmpQueryParam>> partition = Lists.partition(includeQueryParams, 100);
partition.forEach(list->{
emps.addAll(getExternalEmployeeMapper().listByParams(list));
});
return emps;
}
@Override
public List<DataCollectionEmployee> listEmployee() {
return getExternalEmployeeMapper().listEmployee();
}
@Override
public Collection<DataCollectionEmployee> getEmployeeByIdsAll(List<Long> ids) {
List<DataCollectionEmployee> employeeList = new ArrayList<>();
List<List<Long>> partition = Lists.partition(ids, 1000);
partition.forEach(e->{
List<DataCollectionEmployee> employeeByIdsAll = getExternalEmployeeMapper().getEmployeeByIdsAll(e);
employeeList.addAll(employeeByIdsAll);
});
return employeeList;
}
@Override
public Collection<DataCollectionEmployee> listAllForReport() {
return getExternalEmployeeMapper().listAllForReport();
}
public DataCollectionEmployee cover(ExtEmpPO extPo) {
if (extPo == null) {

View File

@ -13,6 +13,7 @@ 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.sys.SalarySysConfMapper;
import com.engine.salary.service.ExtEmpService;
import com.engine.salary.service.SalaryEmployeeService;
import com.engine.salary.service.SalarySobRangeService;
import com.engine.salary.sys.entity.po.SalarySysConfPO;
@ -46,20 +47,29 @@ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployee
return SqlProxyHandle.getProxy(SalarySysConfMapper.class);
}
private SalaryEmployeeService getSalaryEmployeeService(User user) {
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
private ExtEmpService getExtEmpService(User user) {
return ServiceUtil.getService(ExtEmpServiceImpl.class, user);
}
boolean openExtEmp = true;
@Override
public List<DataCollectionEmployee> listAll() {
return employBiz.listEmployee();
List<DataCollectionEmployee> result = employBiz.listEmployee();
if(openExtEmp){
result.addAll(getExtEmpService(user).listEmployee());
}
return result;
}
@Override
public List<DataCollectionEmployee> listAllForReport() {
return employBiz.listAllForReport();
List<DataCollectionEmployee> result = employBiz.listAllForReport();
if(openExtEmp){
result.addAll(getExtEmpService(user).listAllForReport());
}
return result;
}
@Override
@ -72,7 +82,7 @@ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployee
// 将薪资账套的人员范围转换成人员查询参数
List<SalarySobRangeEmpQueryParam> includeQueryParams = SalarySobRangeBO.convert2EmployeeQueryParam(includeSalarySobRangePOS);
// 根据上一步的查询参数查询人员
List<DataCollectionEmployee> includeSalaryEmployees = getSalaryEmployeeService(user).listByParams(includeQueryParams);
List<DataCollectionEmployee> includeSalaryEmployees = listByParams(includeQueryParams);
if (CollectionUtils.isEmpty(includeSalaryEmployees)) {
return Collections.emptyList();
}
@ -84,7 +94,7 @@ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployee
// 将薪资账套的人员范围转换成人员查询参数
List<SalarySobRangeEmpQueryParam> excludeQueryParams = SalarySobRangeBO.convert2EmployeeQueryParam(excludeSalarySobRangePOS);
// 根据上一步的查询参数查询人员
List<DataCollectionEmployee> excludeSalaryEmployees = getSalaryEmployeeService(user).listByParams(excludeQueryParams);
List<DataCollectionEmployee> excludeSalaryEmployees = listByParams(excludeQueryParams);
// 需要排除的人员范围
Set<Long> excludeEmployeeIds = SalaryEntityUtil.properties(excludeSalaryEmployees, DataCollectionEmployee::getEmployeeId);
// 过滤人员
@ -97,12 +107,23 @@ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployee
@Override
public List<DataCollectionEmployee> getEmployeeByIdsAll(List<Long> ids) {
return employBiz.getEmployeeByIdsAll(ids);
List<DataCollectionEmployee> result = employBiz.getEmployeeByIdsAll(ids);
if(openExtEmp){
result.addAll(getExtEmpService(user).getEmployeeByIdsAll(ids));
}
return result;
}
@Override
public DataCollectionEmployee getEmployeeById(Long employeeId) {
if(openExtEmp){
DataCollectionEmployee employeeById = getExtEmpService(user).getEmployeeById(employeeId);
if(Objects.nonNull(employeeById)){
return employeeById;
}
}
return employBiz.getEmployeeById(employeeId);
}
@Override
@ -114,7 +135,11 @@ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployee
List<List<Long>> partition = Lists.partition(simpleEmployeeIds, 1000);
for (List<Long> longs : partition) {
employeeList.addAll(employBiz.getEmployeeByIds(longs));
if(openExtEmp){
employeeList.addAll(getExtEmpService(user).getEmployeeByIds(longs));
}
}
return employeeList;
}
@ -177,11 +202,19 @@ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployee
@Override
public List<DataCollectionEmployee> listEmployee() {
return employBiz.listEmployee();
List<DataCollectionEmployee> result = employBiz.listEmployee();
if(openExtEmp){
result.addAll(getExtEmpService(user).listEmployee());
}
return result;
}
@Override
public List<DataCollectionEmployee> listByParams(List<SalarySobRangeEmpQueryParam> includeQueryParams) {
List<DataCollectionEmployee> result = employBiz.listByParams(includeQueryParams);
if(openExtEmp){
result.addAll(getExtEmpService(user).listByParams(includeQueryParams));
}
return employBiz.listByParams(includeQueryParams);
}
}