package com.engine.salary.service.impl;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.config.SalaryElogConfig;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.hrmelog.entity.dto.LoggerContext;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.employeedeclare.bo.EmployeeDeclareBO;
import com.engine.salary.entity.employeedeclare.dto.EmployeeDeclareExcelDTO;
import com.engine.salary.entity.employeedeclare.dto.EmployeeDeclareListDTO;
import com.engine.salary.entity.employeedeclare.param.EmployeeDeclareImportParam;
import com.engine.salary.entity.employeedeclare.param.EmployeeDeclareListQueryParam;
import com.engine.salary.entity.employeedeclare.po.EmployeeDeclarePO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.enums.OperateTypeEnum;
import com.engine.salary.enums.SalaryOnOffEnum;
import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum;
import com.engine.salary.enums.employeedeclare.*;
import com.engine.salary.enums.salaryaccounting.EmployeeTypeEnum;
import com.engine.salary.enums.sicategory.DeleteTypeEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.employeedeclare.EmployeeDeclareMapper;
import com.engine.salary.service.EmployeeDeclareExcelService;
import com.engine.salary.service.EmployeeDeclareService;
import com.engine.salary.service.SalaryEmployeeService;
import com.engine.salary.service.TaxAgentService;
import com.engine.salary.util.*;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.excel.*;
import com.engine.salary.util.valid.SalaryCardUtil;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.engine.salary.util.db.IdGenerator;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import weaver.file.ExcelSheet;
import weaver.file.ImageFileManager;
import weaver.general.Util;
import weaver.hrm.User;
import java.beans.PropertyDescriptor;
import java.io.InputStream;
import java.util.*;
import java.util.stream.Collectors;
import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX;
/**
* 人员报送(人员)导入导出
*
Copyright: Copyright (c) 2023
* Company: 泛微软件
*
* @author qiantao
* @version 1.0
**/
@Slf4j
public class EmployeeDeclareExcelServiceImpl extends Service implements EmployeeDeclareExcelService {
private EmployeeDeclareService getEmployeeDeclareService(User user) {
return ServiceUtil.getService(EmployeeDeclareServiceImpl.class, user);
}
private SalaryEmployeeService getSalaryEmployeeService(User user) {
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
// private ExtEmployeeService extEmployeeService;
private TaxAgentService getTaxAgentService(User user) {
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
private EmployeeDeclareMapper getEmployeeDeclareMapper() {
return MapperProxyFactory.getProxy(EmployeeDeclareMapper.class);
}
@Override
public XSSFWorkbook exportTemplate(EmployeeDeclareImportParam importParam) {
// 查询人员
List employeeDeclares = Collections.emptyList();
if (StringUtils.equalsIgnoreCase(importParam.getExportData(), "true")) {
employeeDeclares = getEmployeeDeclareService(user).listByParam(importParam);
}
String yesI18 = SalaryI18nUtil.getI18nLabel(111111, "是");
String noI18 = SalaryI18nUtil.getI18nLabel(111111, "否");
List> rows = Lists.newArrayList();
for (EmployeeDeclarePO employeeDeclare : employeeDeclares) {
EmploymentStatusEnum employmentStatusEnum = SalaryEnumUtil.enumMatchByValue(employeeDeclare.getEmploymentStatus(), EmploymentStatusEnum.class);
EmploymentTypeEnum employmentTypeEnum = SalaryEnumUtil.enumMatchByValue(employeeDeclare.getEmploymentType(), EmploymentTypeEnum.class);
List