weaver-hrm-salary/src/com/engine/salary/biz/EmployBiz.java

162 lines
5.6 KiB
Java
Raw Normal View History

2022-03-10 17:57:46 +08:00
package com.engine.salary.biz;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
2022-05-24 09:14:26 +08:00
import com.engine.salary.entity.hrm.DeptInfo;
2022-03-23 18:41:38 +08:00
import com.engine.salary.entity.hrm.PositionInfo;
2022-05-24 09:14:26 +08:00
import com.engine.salary.entity.hrm.SubCompanyInfo;
2022-04-07 16:54:10 +08:00
import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam;
2022-03-10 17:57:46 +08:00
import com.engine.salary.mapper.datacollection.EmployMapper;
2022-08-02 17:57:29 +08:00
import com.google.common.collect.Lists;
2022-08-02 10:59:12 +08:00
import org.apache.commons.collections4.CollectionUtils;
2022-03-10 17:57:46 +08:00
import org.apache.ibatis.session.SqlSession;
import weaver.conn.mybatis.MyBatisFactory;
import weaver.general.BaseBean;
2022-08-02 17:57:29 +08:00
import java.util.ArrayList;
2022-03-10 17:57:46 +08:00
import java.util.List;
public class EmployBiz extends BaseBean {
/**
* 查询人员列表
*
* @return
*/
public List<DataCollectionEmployee> listEmployee() {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
EmployMapper mapper = sqlSession.getMapper(EmployMapper.class);
return mapper.listEmployee();
} finally {
sqlSession.close();
}
}
public List<DataCollectionEmployee> getEmployeeByIds(List<Long> list) {
2022-08-02 10:59:12 +08:00
if (CollectionUtils.isEmpty(list)) {
return new ArrayList<>();
}
2022-03-10 17:57:46 +08:00
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
2022-08-02 17:57:29 +08:00
List<DataCollectionEmployee> dataList = new ArrayList<>();
2022-03-10 17:57:46 +08:00
EmployMapper mapper = sqlSession.getMapper(EmployMapper.class);
2022-08-02 17:57:29 +08:00
List<List<Long>> partition = Lists.partition(list, 1000);
for (List<Long> longs : partition) {
dataList.addAll(mapper.getEmployeeByIds(longs));
}
return dataList;
2022-03-10 17:57:46 +08:00
} finally {
sqlSession.close();
}
}
2022-03-15 17:39:19 +08:00
public List<DataCollectionEmployee> getEmployeeByIdsAll(List<Long> list) {
2022-08-02 10:59:12 +08:00
if (CollectionUtils.isEmpty(list)) {
return new ArrayList<>();
}
2022-03-15 17:39:19 +08:00
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
2022-08-02 17:57:29 +08:00
List<DataCollectionEmployee> employeeList = new ArrayList<>();
2022-03-15 17:39:19 +08:00
EmployMapper mapper = sqlSession.getMapper(EmployMapper.class);
2022-08-02 17:57:29 +08:00
List<List<Long>> partition = Lists.partition(list, 1000);
2022-08-02 10:59:12 +08:00
partition.forEach(e->{
List<DataCollectionEmployee> employeeByIdsAll = mapper.getEmployeeByIdsAll(e);
employeeList.addAll(employeeByIdsAll);
});
2022-08-02 17:57:29 +08:00
return employeeList;
2022-03-15 17:39:19 +08:00
} finally {
sqlSession.close();
}
}
2022-03-23 18:41:38 +08:00
2022-04-07 11:39:22 +08:00
public List<DataCollectionEmployee> getAdminEmployeeByIds(List<Long> list) {
2022-08-02 10:59:12 +08:00
if (CollectionUtils.isEmpty(list)) {
return new ArrayList<>();
}
2022-04-07 11:39:22 +08:00
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
EmployMapper mapper = sqlSession.getMapper(EmployMapper.class);
2022-08-02 17:57:29 +08:00
List<DataCollectionEmployee> employeeList = Lists.newArrayList();
List<List<Long>> partition = Lists.partition(list, 1000);
for (List<Long> longs : partition) {
employeeList.addAll(mapper.getAdminEmployeeByIds(longs));
}
return employeeList;
2022-04-07 11:39:22 +08:00
} finally {
sqlSession.close();
}
}
2022-03-23 18:41:38 +08:00
/**
* 岗位信息
2022-08-02 10:59:12 +08:00
*
2022-03-23 18:41:38 +08:00
* @param list
* @return
*/
public List<PositionInfo> listPositionInfo(List<Long> list) {
2022-08-02 10:59:12 +08:00
if (CollectionUtils.isEmpty(list)) {
return new ArrayList<>();
}
2022-03-23 18:41:38 +08:00
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
EmployMapper mapper = sqlSession.getMapper(EmployMapper.class);
return mapper.listPositionInfo(list);
} finally {
sqlSession.close();
}
}
2022-04-07 16:54:10 +08:00
public List<DataCollectionEmployee> listByParams(List<SalarySobRangeEmpQueryParam> includeQueryParams) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
EmployMapper mapper = sqlSession.getMapper(EmployMapper.class);
List<DataCollectionEmployee> emps = new ArrayList<>();
List<List<SalarySobRangeEmpQueryParam>> partition = Lists.partition(includeQueryParams, 100);
partition.forEach(list->{
emps.addAll(mapper.listByParams(list));
});
return emps;
2022-04-07 16:54:10 +08:00
} finally {
sqlSession.close();
}
}
2022-04-08 19:08:59 +08:00
public DataCollectionEmployee getEmployeeById(Long employeeId) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
EmployMapper mapper = sqlSession.getMapper(EmployMapper.class);
return mapper.getEmployeeById(employeeId);
} finally {
sqlSession.close();
}
}
2022-05-24 09:14:26 +08:00
2022-08-02 10:59:12 +08:00
public List<DeptInfo> getDeptInfoList(List<Long> list) {
if (CollectionUtils.isEmpty(list)) {
return new ArrayList<>();
}
2022-05-24 09:14:26 +08:00
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
EmployMapper mapper = sqlSession.getMapper(EmployMapper.class);
2022-08-02 10:59:12 +08:00
return mapper.getDeptInfoList(list);
2022-05-24 09:14:26 +08:00
} finally {
sqlSession.close();
}
}
2022-08-02 10:59:12 +08:00
public List<SubCompanyInfo> getSubCompanyInfoList(List<Long> list) {
if (CollectionUtils.isEmpty(list)) {
return new ArrayList<>();
}
2022-05-24 09:14:26 +08:00
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
EmployMapper mapper = sqlSession.getMapper(EmployMapper.class);
2022-08-02 10:59:12 +08:00
return mapper.getSubCompanyInfoList(list);
2022-05-24 09:14:26 +08:00
} finally {
sqlSession.close();
}
}
2022-03-10 17:57:46 +08:00
}