weaver-hrm-salary/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java

504 lines
27 KiB
Java
Raw Normal View History

2022-03-15 09:34:53 +08:00
package com.engine.salary.service.impl;
2022-04-19 17:46:24 +08:00
import com.cloudstore.eccom.pc.table.WeaTableColumn;
2022-06-06 16:55:02 +08:00
import com.engine.common.util.ServiceUtil;
2022-03-15 09:34:53 +08:00
import com.engine.core.impl.Service;
2022-03-15 17:39:19 +08:00
import com.engine.salary.biz.SIArchivesBiz;
import com.engine.salary.cmd.siarchives.SIArchivesTipsCmd;
import com.engine.salary.entity.siarchives.bo.InsuranceArchivesBaseInfoBO;
2022-03-18 18:00:51 +08:00
import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam;
import com.engine.salary.entity.siarchives.param.InsuranceArchivesSaveParam;
import com.engine.salary.entity.siarchives.po.*;
2022-06-06 16:55:02 +08:00
import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO;
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO;
import com.engine.salary.entity.taxagent.po.TaxAgentEmpChangePO;
2022-06-06 16:55:02 +08:00
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.enums.siaccount.EmployeeStatusEnum;
import com.engine.salary.enums.sicategory.DeleteTypeEnum;
import com.engine.salary.enums.sicategory.NonPaymentEnum;
2022-03-15 17:39:19 +08:00
import com.engine.salary.enums.sicategory.WelfareTypeEnum;
import com.engine.salary.enums.taxagent.TaxAgentEmpChangeModuleEnum;
import com.engine.salary.mapper.siarchives.FundSchemeMapper;
import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper;
import com.engine.salary.mapper.siarchives.OtherSchemeMapper;
2022-04-19 17:46:24 +08:00
import com.engine.salary.mapper.siarchives.SocialSchemeMapper;
2022-03-15 09:34:53 +08:00
import com.engine.salary.service.SIArchivesService;
import com.engine.salary.service.TaxAgentEmpChangeService;
2022-06-06 16:55:02 +08:00
import com.engine.salary.service.TaxAgentService;
2022-09-26 18:51:17 +08:00
import com.engine.salary.sys.entity.vo.OrderRuleVO;
import com.engine.salary.sys.service.SalarySysConfService;
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
2022-06-06 16:55:02 +08:00
import com.engine.salary.util.SalaryEntityUtil;
2022-04-19 17:46:24 +08:00
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.excel.ExcelUtil;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
2022-04-19 17:46:24 +08:00
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.transaction.annotation.Transactional;
2022-03-15 17:39:19 +08:00
import weaver.general.Util;
2022-06-06 16:55:02 +08:00
import weaver.hrm.User;
2022-03-15 09:34:53 +08:00
import java.text.SimpleDateFormat;
2022-04-19 17:46:24 +08:00
import java.util.*;
2022-06-06 16:55:02 +08:00
import java.util.stream.Collectors;
2022-03-15 09:34:53 +08:00
/**
* @Author weaver_cl
2022-07-13 11:45:16 +08:00
* @Description:
2022-03-15 09:34:53 +08:00
* @Date 2022/3/11
* @Version V1.0
**/
public class SIArchivesServiceImpl extends Service implements SIArchivesService {
2022-04-19 17:46:24 +08:00
private SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
2022-06-06 16:55:02 +08:00
private TaxAgentService getTaxAgentService(User user) {
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
2022-09-26 18:51:17 +08:00
private SalarySysConfService getSalarySysConfService(User user) {
return ServiceUtil.getService(SalarySysConfServiceImpl.class, user);
}
2022-06-06 16:55:02 +08:00
private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() {
return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class);
}
private TaxAgentEmpChangeService getTaxAgentEmpChangeService(User user) {
return ServiceUtil.getService(TaxAgentEmpChangeServiceImpl.class, user);
}
private SocialSchemeMapper getSocialSchemeMapper() {
return MapperProxyFactory.getProxy(SocialSchemeMapper.class);
}
private FundSchemeMapper getFundSchemeMapper() {
return MapperProxyFactory.getProxy(FundSchemeMapper.class);
}
private OtherSchemeMapper getOtherSchemeMapper() {
return MapperProxyFactory.getProxy(OtherSchemeMapper.class);
}
2022-03-15 09:34:53 +08:00
@Override
public Map<String, Object> getTips(Map<String, Object> params) {
2022-06-06 16:55:02 +08:00
return commandExecutor.execute(new SIArchivesTipsCmd(params, user));
2022-03-15 09:34:53 +08:00
}
@Override
public Map<String, Object> getBaseForm(Map<String, Object> params) {
2022-06-06 16:55:02 +08:00
long currentEmployeeId = user.getUID();
Boolean needAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId);
Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAllTaxAgentsAsAdmin(currentEmployeeId);
2022-03-15 17:39:19 +08:00
Map<String, Object> apidatas = new HashMap<>(16);
2022-06-06 16:55:02 +08:00
SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
siArchivesBiz.setNeedAuth(needAuth);
siArchivesBiz.setTaxAgentPOS(taxAgentPOS);
WelfareTypeEnum welfareTypeEnum = (WelfareTypeEnum) params.get("welfareTypeEnum");
2022-03-15 17:39:19 +08:00
Long employeeId = Long.valueOf(Util.null2String(params.get("employeeId")));
2022-06-06 16:55:02 +08:00
apidatas = siArchivesBiz.getBaseForm(welfareTypeEnum, employeeId, (long) user.getUID(), user);
2022-03-16 17:04:21 +08:00
return apidatas;
}
2022-03-15 17:39:19 +08:00
2022-03-16 17:04:21 +08:00
@Override
public Map<String, Object> getPaymentForm(Map<String, Object> params) {
Map<String, Object> apidatas = new HashMap<>(16);
2022-06-06 16:55:02 +08:00
SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
WelfareTypeEnum welfareTypeEnum = (WelfareTypeEnum) params.get("welfareTypeEnum");
2022-03-16 17:04:21 +08:00
Long employeeId = Long.valueOf(Util.null2String(params.get("employeeId")));
String schemeIdStr = Util.null2String(params.get("schemeId"));
Long schemeId = null;
if (StringUtils.isNotBlank(schemeIdStr)) {
schemeId = Long.valueOf(schemeIdStr);
}
2022-06-06 16:55:02 +08:00
apidatas = siArchivesBiz.getPaymentForm(user, welfareTypeEnum, employeeId, (long) user.getUID(), schemeId);
2022-03-15 17:39:19 +08:00
return apidatas;
2022-03-15 09:34:53 +08:00
}
@Override
public String insert(InsuranceArchivesSaveParam param) {
2022-06-06 16:55:02 +08:00
SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
siArchivesBiz.insert(param, (long) user.getUID());
return null;
}
2022-03-18 18:00:51 +08:00
@Override
public Map<String, Object> listPage(InsuranceArchivesListParam param) {
2022-06-06 16:55:02 +08:00
long currentEmployeeId = user.getUID();
// 2.待减员自动处理
handleStayDelData(currentEmployeeId);
// 3.增量数据处理
handleChangeData(currentEmployeeId);
2022-09-26 18:51:17 +08:00
//排序配置
OrderRuleVO orderRule = getSalarySysConfService(user).orderRule();
param.setOrderRule(orderRule);
2022-06-06 16:55:02 +08:00
Boolean needAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId);
param.setNeedAuth(needAuth);
if (needAuth) {
List<TaxAgentEmployeeDTO> taxAgentEmployeeDTOS = getTaxAgentService(user).listTaxAgentAndEmployee(currentEmployeeId);
Set<Long> employeeIds = SalaryEntityUtil.properties(taxAgentEmployeeDTOS, TaxAgentEmployeeDTO::getEmployeeId);
Set<Long> taxAgentIds = SalaryEntityUtil.properties(taxAgentEmployeeDTOS, TaxAgentEmployeeDTO::getTaxAgentId);
2022-06-06 16:55:02 +08:00
param.setTaxAgentEmployeeIds(employeeIds);
param.setTaxAgentIds(taxAgentIds);
2022-06-06 16:55:02 +08:00
}
2022-03-18 18:00:51 +08:00
Map<String, Object> apidatas = new HashMap<>(16);
2022-06-06 16:55:02 +08:00
SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
apidatas = siArchivesBiz.listPage(param, (long) user.getUID());
2022-03-18 18:00:51 +08:00
return apidatas;
}
/**
* 福利档案中待减员数据自动处理
* @param currentEmployeeId
*/
@Transactional(rollbackFor = Exception.class)
private void handleStayDelData(long currentEmployeeId) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
String today = simpleDateFormat.format(new Date());
//part1员工维护了社保/公积金/其他福利最后缴纳日,且任一类信息大于今天的,自动将待减员状态置为正在缴纳状态
List<InsuranceArchivesBaseInfoPO> rePayList = getInsuranceBaseInfoMapper().getRePayList(today);
updateInsuranceBaseInfoRunStatus(rePayList, EmployeeStatusEnum.PAYING.getValue());
//part2员工维护了社保/公积金/其他福利最后缴纳日,且三类信息都小于今天的,自动置为待减员状态
List<InsuranceArchivesBaseInfoPO> reStayDelList = getInsuranceBaseInfoMapper().getReStayDelList(today);
updateInsuranceBaseInfoRunStatus(reStayDelList, EmployeeStatusEnum.STAY_DEL.getValue());
//part3非在职员工且处于正常缴纳的福利档案置为待减员状态
//定义非在职的人事状态
List<String> personnelStatuses = new ArrayList<String>() {{
add("5");
add("6");
add("7");
}};
if (CollectionUtils.isNotEmpty(personnelStatuses)) {
//获取非在职员工的福利档案基础信息
InsuranceArchivesListParam insuranceArchivesListParam = new InsuranceArchivesListParam();
insuranceArchivesListParam.setPersonnelStatuses(personnelStatuses);
insuranceArchivesListParam.setRunStatuses(Collections.singletonList(EmployeeStatusEnum.PAYING.getValue()));
List<InsuranceArchivesBaseInfoPO> noNormalList = getInsuranceBaseInfoMapper().getAbnormalList(insuranceArchivesListParam);
updateInsuranceBaseInfoRunStatus(noNormalList, EmployeeStatusEnum.STAY_DEL.getValue());
}
}
/**
* 福利档案中增量数据处理
* @param currentEmployeeId
*/
private void handleChangeData(long currentEmployeeId) {
// 所有增量人员列表
List<TaxAgentEmpChangePO> taxAgentEmpChangeList = getTaxAgentEmpChangeService(user).listAllByModule(TaxAgentEmpChangeModuleEnum.INSURANCE_ARCHIVE);
if (CollectionUtils.isEmpty(taxAgentEmpChangeList)) {
return;
}
// 当前可以管辖的人员
Collection<TaxAgentPO> taxAgentList = getTaxAgentService(user).listAllTaxAgents(currentEmployeeId);
taxAgentEmpChangeList = taxAgentEmpChangeList.stream().filter(f -> taxAgentList.stream().anyMatch(e -> e.getId().equals(f.getTaxAgentId()))).collect(Collectors.toList());
if (CollectionUtils.isEmpty(taxAgentEmpChangeList)) {
return;
}
// 所有福利档案基础信息数据
List<InsuranceArchivesBaseInfoPO> baseInfoPOList = getInsuranceBaseInfoMapper().listAll();
InsuranceArchivesBaseInfoBO.ChangeData changeData = InsuranceArchivesBaseInfoBO.buildChangeData(taxAgentEmpChangeList, baseInfoPOList, currentEmployeeId);
// 批量修改福利档案
if (CollectionUtils.isNotEmpty(changeData.getBaseInfoUpdateTodoList())) {
//对于即将职位“待减员”的数据,更新社保、公积金、其他福利档案的停止缴纳时间
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
String today = simpleDateFormat.format(new Date());
List<InsuranceArchivesBaseInfoPO> toStayDelList = changeData.getBaseInfoUpdateTodoList().stream()
.filter(f -> f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue()))
.collect(Collectors.toList());
if (toStayDelList.size() > 0) {
List<List<InsuranceArchivesBaseInfoPO>> partitionUpdateEndTime = Lists.partition(toStayDelList, 100);
partitionUpdateEndTime.forEach(part->{
List<Long> socialIds = part.stream().map(InsuranceArchivesBaseInfoPO::getSocialArchivesId).collect(Collectors.toList());
List<Long> fundIds = part.stream().map(InsuranceArchivesBaseInfoPO::getFundArchivesId).collect(Collectors.toList());
List<Long> otherIds = part.stream().map(InsuranceArchivesBaseInfoPO::getOtherArchivesId).collect(Collectors.toList());
getSocialSchemeMapper().batchUpdateEndTime(socialIds, today);
getFundSchemeMapper().batchUpdateEndTime(fundIds, today);
getOtherSchemeMapper().batchUpdateEndTime(otherIds, today);
});
}
//修改福利档案基础信息
List<List<InsuranceArchivesBaseInfoPO>> partitionUpdateBase = Lists.partition(changeData.getBaseInfoUpdateTodoList(), 100);
partitionUpdateBase.forEach(part-> getInsuranceBaseInfoMapper().batchUpdate(part));
}
// 批量新增福利档案
if (CollectionUtils.isNotEmpty(changeData.getBaseInfoAddTodoList())) {
//新增社保、公积金、其他福利档案、福利档案基础信息
addNewInsuranceBaseInfo(changeData.getBaseInfoAddTodoList(), currentEmployeeId);
}
// 删除增量数据
if (CollectionUtils.isNotEmpty(changeData.getChangeIds())) {
getTaxAgentEmpChangeService(user).deleleByIds(changeData.getChangeIds());
}
}
//新增社保、公积金、其他福利档案、福利档案基础信息
private List<InsuranceArchivesBaseInfoPO> addNewInsuranceBaseInfo(List<InsuranceArchivesBaseInfoPO> baseInfoPOList, Long currentEmployeeId) {
List<InsuranceArchivesSocialSchemePO> socialList = new ArrayList<>();
List<InsuranceArchivesFundSchemePO> fundList = new ArrayList<>();
List<InsuranceArchivesOtherSchemePO> otherList = new ArrayList<>();
for (InsuranceArchivesBaseInfoPO baseInfoPO : baseInfoPOList) {
InsuranceArchivesSocialSchemePO insuranceArchivesSocialSchemePO = new InsuranceArchivesSocialSchemePO();
insuranceArchivesSocialSchemePO.setTenantKey("");
insuranceArchivesSocialSchemePO.setWelfareType(WelfareTypeEnum.SOCIAL_SECURITY.getValue());
insuranceArchivesSocialSchemePO.setPaymentOrganization(baseInfoPO.getPaymentOrganization());
insuranceArchivesSocialSchemePO.setNonPayment(NonPaymentEnum.YES.getValue());
insuranceArchivesSocialSchemePO.setCreator(currentEmployeeId);
insuranceArchivesSocialSchemePO.setCreateTime(new Date());
insuranceArchivesSocialSchemePO.setUpdateTime(new Date());
insuranceArchivesSocialSchemePO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue());
insuranceArchivesSocialSchemePO.setEmployeeId(baseInfoPO.getEmployeeId());
socialList.add(insuranceArchivesSocialSchemePO);
InsuranceArchivesFundSchemePO insuranceArchivesFundSchemePO = new InsuranceArchivesFundSchemePO();
insuranceArchivesFundSchemePO.setTenantKey("");
insuranceArchivesFundSchemePO.setWelfareType(WelfareTypeEnum.ACCUMULATION_FUND.getValue());
insuranceArchivesFundSchemePO.setPaymentOrganization(baseInfoPO.getPaymentOrganization());
insuranceArchivesFundSchemePO.setNonPayment(NonPaymentEnum.YES.getValue());
insuranceArchivesFundSchemePO.setCreator(currentEmployeeId);
insuranceArchivesFundSchemePO.setCreateTime(new Date());
insuranceArchivesFundSchemePO.setUpdateTime(new Date());
insuranceArchivesFundSchemePO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue());
insuranceArchivesFundSchemePO.setEmployeeId(baseInfoPO.getEmployeeId());
fundList.add(insuranceArchivesFundSchemePO);
InsuranceArchivesOtherSchemePO insuranceArchivesOtherSchemePO = new InsuranceArchivesOtherSchemePO();
insuranceArchivesOtherSchemePO.setTenantKey("");
insuranceArchivesOtherSchemePO.setWelfareType(WelfareTypeEnum.OTHER.getValue());
insuranceArchivesOtherSchemePO.setPaymentOrganization(baseInfoPO.getPaymentOrganization());
insuranceArchivesOtherSchemePO.setNonPayment(NonPaymentEnum.YES.getValue());
insuranceArchivesOtherSchemePO.setCreator(currentEmployeeId);
insuranceArchivesOtherSchemePO.setCreateTime(new Date());
insuranceArchivesOtherSchemePO.setUpdateTime(new Date());
insuranceArchivesOtherSchemePO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue());
insuranceArchivesOtherSchemePO.setEmployeeId(baseInfoPO.getEmployeeId());
otherList.add(insuranceArchivesOtherSchemePO);
//导入社保档案
if (CollectionUtils.isNotEmpty(socialList)) {
socialList = socialList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(InsuranceArchivesSocialSchemePO::getEmployeeId))), ArrayList::new));
List<Long> socialEmployeeIds = socialList.stream().map(InsuranceArchivesSocialSchemePO::getEmployeeId).collect(Collectors.toList());
List<List<Long>> socialEmployeeIdPartition = Lists.partition(socialEmployeeIds, 100);
socialEmployeeIdPartition.forEach(getSocialSchemeMapper()::batchDeleteByEmployeeIds);
List<List<InsuranceArchivesSocialSchemePO>> partition = Lists.partition(socialList, 100);
partition.forEach(getSocialSchemeMapper()::batchSave);
}
//导入公积金档案
if (CollectionUtils.isNotEmpty(fundList)) {
fundList = fundList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(InsuranceArchivesFundSchemePO::getEmployeeId))), ArrayList::new));
List<Long> fundEmployeeIds = fundList.stream().map(InsuranceArchivesFundSchemePO::getEmployeeId).collect(Collectors.toList());
List<List<Long>> fundEmployeeIdsPartition = Lists.partition(fundEmployeeIds, 100);
fundEmployeeIdsPartition.forEach(getFundSchemeMapper()::batchDeleteByEmployeeIds);
List<List<InsuranceArchivesFundSchemePO>> partition = Lists.partition(fundList, 100);
partition.forEach(getFundSchemeMapper()::batchSave);
}
//导入其他福利档案
if (CollectionUtils.isNotEmpty(otherList)) {
otherList = otherList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(InsuranceArchivesOtherSchemePO::getEmployeeId))), ArrayList::new));
List<Long> otherEmployeeIds = otherList.stream().map(InsuranceArchivesOtherSchemePO::getEmployeeId).collect(Collectors.toList());
List<List<Long>> otherEmployeeIdsPartition = Lists.partition(otherEmployeeIds, 100);
otherEmployeeIdsPartition.forEach(getOtherSchemeMapper()::batchDeleteByEmployeeIds);
List<List<InsuranceArchivesOtherSchemePO>> partition = Lists.partition(otherList, 100);
partition.forEach(getOtherSchemeMapper()::batchSave);
}
//导入福利档案基础信息
if (CollectionUtils.isNotEmpty(baseInfoPOList)) {
baseInfoPOList = baseInfoPOList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(InsuranceArchivesBaseInfoPO::getEmployeeId))), ArrayList::new));
//分批批量删除
List<Long> baseInfoEmployeeIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getEmployeeId).collect(Collectors.toList());
List<List<Long>> employeeIdPartition = Lists.partition(baseInfoEmployeeIds, 100);
employeeIdPartition.forEach(getInsuranceBaseInfoMapper()::batchDeleteByEmployeeIds);
//查询目标人员的剩余的福利档案基础信息社保、公积金、其他福利档案id
List<InsuranceArchivesBaseInfoPO> moreBaseInfoPOS = getInsuranceBaseInfoMapper().getInsuranceBaseInfoListByInsuranceDetail(baseInfoEmployeeIds);
List<InsuranceArchivesBaseInfoPO> newInsuranceArchivesBaseInfoList = new ArrayList<>();
//设置社保、公积金、其他福利档案id
for (InsuranceArchivesBaseInfoPO po : baseInfoPOList) {
InsuranceArchivesBaseInfoPO moreBaseInfo = moreBaseInfoPOS.stream().filter(s -> Objects.equals(s.getEmployeeId(), po.getEmployeeId())).findFirst().orElse(null);
po.setSocialArchivesId(moreBaseInfo.getSocialArchivesId());
po.setFundArchivesId(moreBaseInfo.getFundArchivesId());
po.setOtherArchivesId(moreBaseInfo.getOtherArchivesId());
newInsuranceArchivesBaseInfoList.add(po);
}
//分批批量入库
List<List<InsuranceArchivesBaseInfoPO>> partition = Lists.partition(newInsuranceArchivesBaseInfoList, 100);
partition.forEach(getInsuranceBaseInfoMapper()::batchSave);
}
}
return baseInfoPOList;
}
/**
* 分批更新福利档案基础信息的runStatus
* @param baseInfoPOList
* @param runStatus
*/
private void updateInsuranceBaseInfoRunStatus(List<InsuranceArchivesBaseInfoPO> baseInfoPOList, String runStatus) {
if (CollectionUtils.isNotEmpty(baseInfoPOList)) {
List<Long> idList = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList());
List<List<Long>> partition = Lists.partition(idList, 999);
partition.forEach(
part -> {
InsuranceArchivesBaseInfoPO baseInfoPO = new InsuranceArchivesBaseInfoPO();
baseInfoPO.setIds(part);
baseInfoPO.setRunStatus(runStatus);
getInsuranceBaseInfoMapper().updateRunStatusByIds(baseInfoPO);
}
);
}
}
2022-03-22 19:47:46 +08:00
@Override
public Map<String, Object> getSearchCondition(Map<String, Object> param) {
Map<String, Object> apidatas = new HashMap<>(16);
2022-06-06 16:55:02 +08:00
SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
2022-03-22 19:47:46 +08:00
apidatas = siArchivesBiz.getSearchCondition(user);
return apidatas;
}
2022-04-19 17:46:24 +08:00
@Override
public XSSFWorkbook export(InsuranceArchivesListParam param) {
InsuranceArchivesListParam request = InsuranceArchivesListParam.builder().build();
if (param.getHireDate() != null && param.getHireDate().length == 2) {
param.setHiredateStart(param.getHireDate()[0]);
param.setHiredateEnd(param.getHireDate()[1]);
}
if (param.getDimissionDate() != null && param.getDimissionDate().length == 2) {
param.setDimissionDateStart(param.getDimissionDate()[0]);
param.setDimissionDateEnd(param.getDimissionDate()[1]);
}
if (Objects.equals("fromQuickSearch", param.getDataSource())) {
request.setStatuses(param.getStatuses());
request.setKeyword(param.getUserName());
} else {
request = param;
}
request.setPageSize(null);
request.setStartNum(null);
List<InsuranceArchivesEmployeePO> insuranceArchivesEmployeePOS = listPageEmployeePOS(request);
if (insuranceArchivesEmployeePOS == null) {
insuranceArchivesEmployeePOS = new ArrayList<>();
}
List<Map<String, Object>> records = siArchivesBiz.buildTableData(insuranceArchivesEmployeePOS);
2022-06-06 16:55:02 +08:00
List<WeaTableColumn> columns = siArchivesBiz.buildWeaTableColumns(insuranceArchivesEmployeePOS, user.getUID());
2022-04-19 17:46:24 +08:00
//工作簿list
List<List<Object>> excelSheetData = new ArrayList<>();
//工作簿名称
String sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案"); //表头
//表头
2022-04-21 15:04:35 +08:00
excelSheetData.add(Arrays.asList(columns.stream().map(WeaTableColumn::getText).toArray(String[]::new)));
2022-04-19 17:46:24 +08:00
//工作簿数据
List<List<Object>> rows = new LinkedList<>();
for (Map<String, Object> recordData : records) {
List<Object> row = new LinkedList<>();
for (WeaTableColumn column : columns) {
row.add(recordData.get(column.getColumn()));
}
rows.add(row);
}
excelSheetData.addAll(rows);
return ExcelUtil.genWorkbookV2(excelSheetData, sheetName);
}
@Override
public List<InsuranceArchivesEmployeePO> listPageEmployeePOS(InsuranceArchivesListParam param) {
2022-06-06 16:55:02 +08:00
long currentEmployeeId = user.getUID();
Boolean needAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId);
if (needAuth) {
List<TaxAgentEmployeeDTO> taxAgentEmployeeDTOS = getTaxAgentService(user).listTaxAgentAndEmployee(currentEmployeeId);
Set<Long> employeeIds = SalaryEntityUtil.properties(taxAgentEmployeeDTOS, TaxAgentEmployeeDTO::getEmployeeId);
List<InsuranceArchivesEmployeePO> list = MapperProxyFactory.getProxy(SocialSchemeMapper.class).queryEmployeeList(param);
return list.stream().filter(f -> employeeIds.contains(f.getEmployeeId())).collect(Collectors.toList());
}
2022-05-09 16:40:14 +08:00
return MapperProxyFactory.getProxy(SocialSchemeMapper.class).queryEmployeeList(param);
2022-04-19 17:46:24 +08:00
}
/**
* 获取福利档案各tab总人数
*/
@Override
public Map<String, Long> queryInsuranceTabTotal() {
long currentEmployeeId = user.getUID();
// tab页签数量
Map<String, Long> result = new HashMap<>();
2022-03-18 18:00:51 +08:00
Boolean needAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId);
//获取管理的人员范围
List<TaxAgentManageRangeEmployeeDTO> taxAgentEmployeeDTOS = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
Map<Long, List<TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee>> taxAgentEmployeesMap = SalaryEntityUtil.convert2Map(taxAgentEmployeeDTOS, TaxAgentManageRangeEmployeeDTO::getTaxAgentId, TaxAgentManageRangeEmployeeDTO::getEmployeeList);
List<InsuranceArchivesBaseInfoPO> list = null;
if (needAuth) {
// 获取作为管理员的所有个税扣缴义务人列表
Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAllTaxAgentsAsAdmin(currentEmployeeId);
Set<Long> taxAgentIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId);
//获取所有福利档案基础信息
List<InsuranceArchivesBaseInfoPO> archiveListDTOS = getInsuranceBaseInfoMapper().listAll();
list = archiveListDTOS.stream().filter(dto -> taxAgentIds.contains(dto.getPaymentOrganization())).collect(Collectors.toList());
Boolean adminEnable = getTaxAgentService(user).isAdminEnable(currentEmployeeId);
//不是管理员看不到数据,返回空
if (!adminEnable) {
list = new ArrayList<>();
}
} else {
list = getInsuranceBaseInfoMapper().listAll();
}
long stayAddTotal = 0L;
long payTotal = 0L;
long stayDelTotal = 0L;
long stopTotal = 0L;
for (InsuranceArchivesBaseInfoPO baseInfoPO : list) {
if (baseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue())) {
stayAddTotal += 1;
} else if (baseInfoPO.getRunStatus().equals(EmployeeStatusEnum.PAYING.getValue()) || baseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())) {
payTotal += 1;
if (baseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())) {
stayDelTotal += 1;
}
} else if (baseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STOP_PAYMENT.getValue())) {
stopTotal += 1;
}
}
result.put(EmployeeStatusEnum.STAY_ADD.getValue(), stayAddTotal);
result.put(EmployeeStatusEnum.PAYING.getValue(), payTotal);
result.put(EmployeeStatusEnum.STAY_DEL.getValue(), stayDelTotal);
result.put(EmployeeStatusEnum.STOP_PAYMENT.getValue(), stopTotal);
return result;
}
2022-03-15 09:34:53 +08:00
}