2023-03-01 09:05:03 +08:00
|
|
|
package com.engine.salary.service.impl;
|
|
|
|
|
|
2023-03-15 18:21:04 +08:00
|
|
|
import com.engine.common.util.ServiceUtil;
|
2023-03-01 09:05:03 +08:00
|
|
|
import com.engine.core.impl.Service;
|
2023-03-06 17:57:20 +08:00
|
|
|
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
2023-07-27 09:39:03 +08:00
|
|
|
import com.engine.salary.entity.extemp.param.ExtEmpImportParam;
|
2023-03-01 09:05:03 +08:00
|
|
|
import com.engine.salary.entity.extemp.param.ExtEmpQueryParam;
|
2023-03-03 16:57:52 +08:00
|
|
|
import com.engine.salary.entity.extemp.param.ExtEmpSaveParam;
|
2023-03-01 09:05:03 +08:00
|
|
|
import com.engine.salary.entity.extemp.po.ExtEmpPO;
|
2023-03-15 18:21:04 +08:00
|
|
|
import com.engine.salary.entity.hrm.DeptInfo;
|
|
|
|
|
import com.engine.salary.entity.hrm.SubCompanyInfo;
|
2023-03-13 15:53:56 +08:00
|
|
|
import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam;
|
2023-07-19 09:58:42 +08:00
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
2023-03-01 09:05:03 +08:00
|
|
|
import com.engine.salary.mapper.extemp.ExternalEmployeeMapper;
|
|
|
|
|
import com.engine.salary.service.ExtEmpService;
|
2023-03-15 18:21:04 +08:00
|
|
|
import com.engine.salary.service.SalaryEmployeeService;
|
2023-07-27 09:39:03 +08:00
|
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
2023-03-01 09:05:03 +08:00
|
|
|
import com.engine.salary.util.db.MapperProxyFactory;
|
2023-07-27 09:39:03 +08:00
|
|
|
import com.engine.salary.util.excel.ExcelComment;
|
2023-07-27 10:07:00 +08:00
|
|
|
import com.engine.salary.util.excel.ExcelParseHelper;
|
|
|
|
|
import com.engine.salary.util.excel.ExcelSupport;
|
2023-07-27 09:39:03 +08:00
|
|
|
import com.engine.salary.util.excel.ExcelUtilPlus;
|
2023-03-03 16:57:52 +08:00
|
|
|
import com.engine.salary.util.page.PageInfo;
|
|
|
|
|
import com.engine.salary.util.page.SalaryPageUtil;
|
2023-07-27 10:07:00 +08:00
|
|
|
import com.engine.salary.util.valid.ValidUtil;
|
2023-03-13 15:53:56 +08:00
|
|
|
import com.google.common.collect.Lists;
|
2023-03-03 16:57:52 +08:00
|
|
|
import dm.jdbc.util.IdGenerator;
|
2023-03-01 09:05:03 +08:00
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
2023-07-19 09:58:42 +08:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2023-07-27 10:07:00 +08:00
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
|
import org.apache.poi.util.IOUtils;
|
2023-07-27 09:39:03 +08:00
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
2023-03-03 16:57:52 +08:00
|
|
|
import org.springframework.beans.BeanUtils;
|
2023-07-27 10:07:00 +08:00
|
|
|
import weaver.file.ImageFileManager;
|
2023-03-15 18:21:04 +08:00
|
|
|
import weaver.hrm.User;
|
2023-03-01 09:05:03 +08:00
|
|
|
|
2023-07-27 10:07:00 +08:00
|
|
|
import java.io.InputStream;
|
2023-03-15 18:21:04 +08:00
|
|
|
import java.util.*;
|
2023-03-06 17:57:20 +08:00
|
|
|
import java.util.stream.Collectors;
|
2023-03-01 09:05:03 +08:00
|
|
|
|
2023-07-27 10:07:00 +08:00
|
|
|
import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX;
|
|
|
|
|
|
2023-03-01 09:05:03 +08:00
|
|
|
/**
|
|
|
|
|
* 累计专项
|
|
|
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
*
|
|
|
|
|
* @author qiantao
|
|
|
|
|
* @version 1.0
|
|
|
|
|
**/
|
|
|
|
|
public class ExtEmpServiceImpl extends Service implements ExtEmpService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ExternalEmployeeMapper getExternalEmployeeMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(ExternalEmployeeMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-15 18:21:04 +08:00
|
|
|
private SalaryEmployeeService getSalaryEmployeeService(User user) {
|
|
|
|
|
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-01 09:05:03 +08:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<ExtEmpPO> list(ExtEmpQueryParam param) {
|
2023-03-03 16:57:52 +08:00
|
|
|
return getExternalEmployeeMapper().listSome(ExtEmpPO.builder().username(param.getUsername()).build());
|
2023-03-01 09:05:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2023-03-03 16:57:52 +08:00
|
|
|
public PageInfo<ExtEmpPO> listPage(ExtEmpQueryParam param) {
|
|
|
|
|
List<ExtEmpPO> extEmpPOS = list(param);
|
|
|
|
|
return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), extEmpPOS, ExtEmpPO.class);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void save(ExtEmpSaveParam param) {
|
2023-07-19 09:58:42 +08:00
|
|
|
|
|
|
|
|
List<ExtEmpPO> extEmpPOS = getExternalEmployeeMapper().listSome(ExtEmpPO.builder().username(param.getUsername()).build());
|
|
|
|
|
if (CollectionUtils.isNotEmpty(extEmpPOS)) {
|
|
|
|
|
throw new SalaryRunTimeException("姓名已存在!");
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 16:57:52 +08:00
|
|
|
ExtEmpPO po = new ExtEmpPO();
|
|
|
|
|
BeanUtils.copyProperties(param, po);
|
|
|
|
|
|
|
|
|
|
po.setId(IdGenerator.generate());
|
2023-07-19 17:07:38 +08:00
|
|
|
po.setStatus("2");
|
2023-03-03 16:57:52 +08:00
|
|
|
po.setCreator((long) user.getUID());
|
|
|
|
|
po.setModifier((long) user.getUID());
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
po.setCreateTime(now);
|
|
|
|
|
po.setUpdateTime(now);
|
|
|
|
|
po.setDeleteType(0);
|
|
|
|
|
|
2023-03-01 09:05:03 +08:00
|
|
|
getExternalEmployeeMapper().insertIgnoreNull(po);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2023-03-03 16:57:52 +08:00
|
|
|
public void update(ExtEmpSaveParam param) {
|
2023-07-19 09:58:42 +08:00
|
|
|
|
|
|
|
|
ExtEmpPO oldPO = getExternalEmployeeMapper().getById(param.getId());
|
|
|
|
|
if (!StringUtils.equals(oldPO.getUsername(), param.getUsername())) {
|
|
|
|
|
List<ExtEmpPO> extEmpPOS = getExternalEmployeeMapper().listSome(ExtEmpPO.builder().username(param.getUsername()).build());
|
|
|
|
|
if (CollectionUtils.isNotEmpty(extEmpPOS)) {
|
|
|
|
|
throw new SalaryRunTimeException("姓名已存在!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 16:57:52 +08:00
|
|
|
ExtEmpPO po = new ExtEmpPO();
|
|
|
|
|
BeanUtils.copyProperties(param, po);
|
|
|
|
|
|
|
|
|
|
po.setModifier((long) user.getUID());
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
po.setUpdateTime(now);
|
|
|
|
|
|
2023-03-01 09:05:03 +08:00
|
|
|
getExternalEmployeeMapper().updateIgnoreNull(po);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void delete(Collection<Long> ids) {
|
|
|
|
|
if (CollectionUtils.isNotEmpty(ids)) {
|
|
|
|
|
ids.forEach(getExternalEmployeeMapper()::delete);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-06 17:57:20 +08:00
|
|
|
|
2023-03-08 16:36:47 +08:00
|
|
|
@Override
|
|
|
|
|
public DataCollectionEmployee getEmployeeById(Long id) {
|
|
|
|
|
ExtEmpPO po = getExternalEmployeeMapper().getById(id);
|
|
|
|
|
return cover(po);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<DataCollectionEmployee> getEmployeeByIds(List<Long> ids) {
|
|
|
|
|
if (CollectionUtils.isEmpty(ids)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
}
|
2023-07-13 14:11:32 +08:00
|
|
|
List<ExtEmpPO> extEmpPOS = new ArrayList<>();
|
|
|
|
|
List<List<Long>> partition = Lists.partition(ids, 500);
|
2023-07-19 09:58:42 +08:00
|
|
|
partition.forEach(list -> extEmpPOS.addAll(getExternalEmployeeMapper().listSome(ExtEmpPO.builder().ids(list).build())));
|
2023-03-08 16:36:47 +08:00
|
|
|
return coverList(extEmpPOS);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-13 15:53:56 +08:00
|
|
|
@Override
|
|
|
|
|
public List<DataCollectionEmployee> listByParams(List<SalarySobRangeEmpQueryParam> includeQueryParams) {
|
|
|
|
|
List<DataCollectionEmployee> emps = new ArrayList<>();
|
|
|
|
|
List<List<SalarySobRangeEmpQueryParam>> partition = Lists.partition(includeQueryParams, 100);
|
2023-03-15 18:21:04 +08:00
|
|
|
partition.forEach(list -> {
|
2023-03-13 15:53:56 +08:00
|
|
|
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);
|
2023-03-15 18:21:04 +08:00
|
|
|
partition.forEach(e -> {
|
2023-03-13 15:53:56 +08:00
|
|
|
List<DataCollectionEmployee> employeeByIdsAll = getExternalEmployeeMapper().getEmployeeByIdsAll(e);
|
|
|
|
|
employeeList.addAll(employeeByIdsAll);
|
|
|
|
|
});
|
|
|
|
|
return employeeList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Collection<DataCollectionEmployee> listAllForReport() {
|
|
|
|
|
return getExternalEmployeeMapper().listAllForReport();
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-13 16:04:19 +08:00
|
|
|
@Override
|
|
|
|
|
public ExtEmpPO getById(Long id) {
|
2023-03-15 18:21:04 +08:00
|
|
|
ExtEmpPO po = getExternalEmployeeMapper().getById(id);
|
|
|
|
|
if (po != null) {
|
|
|
|
|
if (po.getDepartmentId() != null) {
|
|
|
|
|
List<DeptInfo> deptInfoList = getSalaryEmployeeService(user).getDeptInfoList(Collections.singletonList(po.getDepartmentId()));
|
|
|
|
|
if (CollectionUtils.isNotEmpty(deptInfoList)) {
|
|
|
|
|
po.setDepartmentOrgName(deptInfoList.get(0).getName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (po.getSubcompanyId() != null) {
|
|
|
|
|
List<SubCompanyInfo> subInfoList = getSalaryEmployeeService(user).getSubCompanyInfoList(Collections.singletonList(po.getSubcompanyId()));
|
|
|
|
|
if (CollectionUtils.isNotEmpty(subInfoList)) {
|
|
|
|
|
po.setSubcompanyOrgName(subInfoList.get(0).getName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-15 22:48:01 +08:00
|
|
|
return po;
|
2023-03-13 16:04:19 +08:00
|
|
|
}
|
|
|
|
|
|
2023-03-08 16:36:47 +08:00
|
|
|
|
|
|
|
|
public DataCollectionEmployee cover(ExtEmpPO extPo) {
|
|
|
|
|
if (extPo == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
DataCollectionEmployee employee = new DataCollectionEmployee();
|
|
|
|
|
BeanUtils.copyProperties(extPo, employee);
|
|
|
|
|
employee.setEmployeeId(extPo.getId());
|
2023-03-15 18:03:46 +08:00
|
|
|
employee.setExtEmp(true);
|
2023-03-08 16:36:47 +08:00
|
|
|
return employee;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<DataCollectionEmployee> coverList(List<ExtEmpPO> extEmps) {
|
|
|
|
|
if (CollectionUtils.isEmpty(extEmps)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-06 17:57:20 +08:00
|
|
|
return extEmps.stream().map(emp -> {
|
|
|
|
|
DataCollectionEmployee employee = new DataCollectionEmployee();
|
|
|
|
|
BeanUtils.copyProperties(emp, employee);
|
2023-03-08 16:36:47 +08:00
|
|
|
employee.setEmployeeId(emp.getId());
|
2023-03-15 18:03:46 +08:00
|
|
|
employee.setExtEmp(true);
|
2023-03-06 17:57:20 +08:00
|
|
|
return employee;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
}
|
2023-07-27 09:39:03 +08:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public XSSFWorkbook exportImportTemplate() {
|
|
|
|
|
|
|
|
|
|
// 模板表头
|
|
|
|
|
List<Object> headerList = Lists.newArrayList(
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(25034, "姓名"),
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(27511, "部门"),
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(33553, "分部"),
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(1516, "入职日期"),
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(125238, "手机号"),
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(1933, "工号"),
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(1887, "身份证号码"),
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(0, "本人开户的银行卡卡号"),
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(0, "本人开户的银行卡开户支行全称"));
|
|
|
|
|
List<String> dataIndexList = Lists.newArrayList("username", "departmentName", "subcompanyName", "companystartdate", "mobile", "workcode", "idNo", "bankCardNum", "bankName");
|
|
|
|
|
|
|
|
|
|
// excel导出的数据
|
|
|
|
|
List<List<Object>> rows = new ArrayList<>();
|
|
|
|
|
rows.add(headerList);
|
|
|
|
|
|
|
|
|
|
// 注释
|
|
|
|
|
List<ExcelComment> excelComments = Lists.newArrayList();
|
|
|
|
|
excelComments.add(new ExcelComment(0, 0, 1, 2, SalaryI18nUtil.getI18nLabel(30036, "必填")));
|
|
|
|
|
excelComments.add(new ExcelComment(3, 0, 4, 2, SalaryI18nUtil.getI18nLabel(542348, "格式样例为'2022-01-01'、'2022/1/1'")));
|
|
|
|
|
|
|
|
|
|
String sheetName = "非系统人员导入模板";
|
|
|
|
|
return ExcelUtilPlus.genWorkbookV2(rows, sheetName, excelComments);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> previewImportExtEmp(ExtEmpImportParam param) {
|
2023-07-27 10:07:00 +08:00
|
|
|
//参数校验
|
|
|
|
|
ValidUtil.doValidator(param);
|
|
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
InputStream fileInputStream = null;
|
|
|
|
|
try {
|
|
|
|
|
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId()));
|
|
|
|
|
Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX);
|
|
|
|
|
map.put("headers", ExcelSupport.getSheetHeader(sheet, 0));
|
|
|
|
|
map.put("list", ExcelParseHelper.parse2List(sheet, 1));
|
|
|
|
|
return map;
|
|
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
IOUtils.closeQuietly(fileInputStream);
|
|
|
|
|
}
|
2023-07-27 09:39:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> importExtEmp(ExtEmpImportParam param) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2023-03-01 09:05:03 +08:00
|
|
|
}
|