2022-03-15 09:34:53 +08:00
|
|
|
|
package com.engine.salary.service.impl;
|
|
|
|
|
|
|
2022-11-03 16:17:03 +08:00
|
|
|
|
import com.cloudstore.dev.api.util.Util_DataCache;
|
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;
|
2022-03-16 18:26:49 +08:00
|
|
|
|
import com.engine.salary.cmd.siarchives.SIArchivesTipsCmd;
|
2022-10-13 14:45:18 +08:00
|
|
|
|
import com.engine.salary.entity.siarchives.bo.InsuranceArchivesBaseInfoBO;
|
2023-10-18 13:34:05 +08:00
|
|
|
|
import com.engine.salary.entity.siarchives.dto.InsuranceArchivesBaseHistoryDTO;
|
2022-03-18 18:00:51 +08:00
|
|
|
|
import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam;
|
2022-03-16 18:26:49 +08:00
|
|
|
|
import com.engine.salary.entity.siarchives.param.InsuranceArchivesSaveParam;
|
2023-10-18 13:34:05 +08:00
|
|
|
|
import com.engine.salary.entity.siarchives.param.SIArchiveBaseHistoryListParam;
|
2022-10-13 14:45:18 +08:00
|
|
|
|
import com.engine.salary.entity.siarchives.po.*;
|
2022-06-06 16:55:02 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO;
|
2022-10-12 10:38:41 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO;
|
2022-10-13 14:45:18 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.po.TaxAgentEmpChangePO;
|
2022-06-06 16:55:02 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
2023-08-30 15:10:25 +08:00
|
|
|
|
import com.engine.salary.enums.salaryaccounting.EmployeeTypeEnum;
|
2022-10-12 10:38:41 +08:00
|
|
|
|
import com.engine.salary.enums.siaccount.EmployeeStatusEnum;
|
2022-10-13 14:45:18 +08:00
|
|
|
|
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;
|
2022-10-13 14:45:18 +08:00
|
|
|
|
import com.engine.salary.enums.taxagent.TaxAgentEmpChangeModuleEnum;
|
2022-10-14 18:00:22 +08:00
|
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
2022-10-13 14:45:18 +08:00
|
|
|
|
import com.engine.salary.mapper.siarchives.FundSchemeMapper;
|
2022-10-12 10:38:41 +08:00
|
|
|
|
import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper;
|
2022-10-13 14:45:18 +08:00
|
|
|
|
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;
|
2022-10-13 14:45:18 +08:00
|
|
|
|
import com.engine.salary.service.TaxAgentEmpChangeService;
|
2022-06-06 16:55:02 +08:00
|
|
|
|
import com.engine.salary.service.TaxAgentService;
|
2023-06-29 10:35:55 +08:00
|
|
|
|
import com.engine.salary.sys.constant.SalarySysConstant;
|
|
|
|
|
|
import com.engine.salary.sys.entity.po.SalarySysConfPO;
|
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;
|
2023-10-18 13:34:05 +08:00
|
|
|
|
import com.engine.salary.util.page.PageInfo;
|
|
|
|
|
|
import com.engine.salary.util.page.SalaryPageUtil;
|
2022-10-12 17:17:06 +08:00
|
|
|
|
import com.google.common.collect.Lists;
|
2022-11-03 11:14:59 +08:00
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2022-10-12 17:17:06 +08:00
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
2022-07-07 18:29:52 +08:00
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2022-04-19 17:46:24 +08:00
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
2022-10-12 17:17:06 +08:00
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
2022-11-03 11:14:59 +08:00
|
|
|
|
import org.springframework.util.StopWatch;
|
2023-08-02 16:31:59 +08:00
|
|
|
|
import weaver.general.BaseBean;
|
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
|
|
|
|
|
2022-10-12 17:17:06 +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
|
|
|
|
|
|
**/
|
2022-11-03 11:14:59 +08:00
|
|
|
|
@Slf4j
|
2022-03-15 09:34:53 +08:00
|
|
|
|
public class SIArchivesServiceImpl extends Service implements SIArchivesService {
|
2023-08-02 16:31:59 +08:00
|
|
|
|
private final BaseBean baseBean = new BaseBean();
|
|
|
|
|
|
|
|
|
|
|
|
private final Boolean isLog = "true".equals(baseBean.getPropValue("hrmSalary", "log"));
|
2022-03-15 09:34:53 +08:00
|
|
|
|
|
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
|
|
|
|
|
2022-10-12 10:38:41 +08:00
|
|
|
|
private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-13 14:45:18 +08:00
|
|
|
|
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-10-27 16:23:54 +08:00
|
|
|
|
Long paymentOrganization = welfareTypeEnum != null ? Long.valueOf(Util.null2String(params.get("paymentOrganization"))) : null;
|
|
|
|
|
|
apidatas = siArchivesBiz.getBaseForm(welfareTypeEnum, employeeId, (long) user.getUID(), user, paymentOrganization);
|
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")));
|
2022-07-07 18:29:52 +08:00
|
|
|
|
String schemeIdStr = Util.null2String(params.get("schemeId"));
|
2022-10-27 16:23:54 +08:00
|
|
|
|
Long paymentOrganization = Long.valueOf(Util.null2String(params.get("paymentOrganization")));
|
2022-07-07 18:29:52 +08:00
|
|
|
|
Long schemeId = null;
|
|
|
|
|
|
if (StringUtils.isNotBlank(schemeIdStr)) {
|
|
|
|
|
|
schemeId = Long.valueOf(schemeIdStr);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-27 16:23:54 +08:00
|
|
|
|
apidatas = siArchivesBiz.getPaymentForm(user, welfareTypeEnum, employeeId, (long) user.getUID(), schemeId, paymentOrganization);
|
2022-03-15 17:39:19 +08:00
|
|
|
|
return apidatas;
|
2022-03-15 09:34:53 +08:00
|
|
|
|
}
|
2022-03-16 18:26:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String insert(InsuranceArchivesSaveParam param) {
|
2022-06-06 16:55:02 +08:00
|
|
|
|
SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
|
2023-12-06 14:04:12 +08:00
|
|
|
|
siArchivesBiz.insert(param, user);
|
2022-03-16 18:26:49 +08:00
|
|
|
|
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();
|
2022-11-03 11:14:59 +08:00
|
|
|
|
log.info("获取福利档案列表逻辑开始: {}", param);
|
|
|
|
|
|
StopWatch sw = new StopWatch();
|
|
|
|
|
|
sw.start("福利档案-历史数据处理");
|
2022-11-01 17:37:47 +08:00
|
|
|
|
// 1.历史数据处理
|
2022-11-03 19:03:41 +08:00
|
|
|
|
handleHistoryData(currentEmployeeId);
|
2022-11-03 11:14:59 +08:00
|
|
|
|
sw.stop();
|
|
|
|
|
|
|
|
|
|
|
|
sw.start("福利档案-待减员自动处理");
|
2022-10-12 17:17:06 +08:00
|
|
|
|
// 2.待减员自动处理
|
|
|
|
|
|
handleStayDelData(currentEmployeeId);
|
2022-11-03 11:14:59 +08:00
|
|
|
|
sw.stop();
|
|
|
|
|
|
|
2023-02-24 13:53:57 +08:00
|
|
|
|
// sw.start("福利档案-增量数据处理");
|
|
|
|
|
|
// // 3.增量数据处理
|
|
|
|
|
|
// String welSign = (String) Util_DataCache.getObjVal("welfareChangeSign");
|
|
|
|
|
|
// if (welSign == null || "0".equals(welSign)) {
|
|
|
|
|
|
// handleChangeData(currentEmployeeId);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// sw.stop();
|
2022-10-12 17:17:06 +08:00
|
|
|
|
|
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);
|
2022-08-03 17:02:03 +08:00
|
|
|
|
Set<Long> taxAgentIds = SalaryEntityUtil.properties(taxAgentEmployeeDTOS, TaxAgentEmployeeDTO::getTaxAgentId);
|
2022-06-06 16:55:02 +08:00
|
|
|
|
param.setTaxAgentEmployeeIds(employeeIds);
|
2022-08-03 17:02:03 +08:00
|
|
|
|
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-10-09 15:12:54 +08:00
|
|
|
|
|
2022-11-03 11:14:59 +08:00
|
|
|
|
log.info("各操作计时 {}", sw.prettyPrint());
|
2022-03-18 18:00:51 +08:00
|
|
|
|
return apidatas;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-03 19:03:41 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 福利档案中历史数据自动处理
|
|
|
|
|
|
* @param currentEmployeeId
|
|
|
|
|
|
*/
|
|
|
|
|
|
private void handleHistoryData(long currentEmployeeId) {
|
2022-11-04 09:17:49 +08:00
|
|
|
|
//如果触发历史数据处理,则进行一次全量增员
|
|
|
|
|
|
if (siArchivesBiz.createOldInsuranceBaseInfo(currentEmployeeId)) {
|
2022-11-07 17:15:42 +08:00
|
|
|
|
|
|
|
|
|
|
//批量增员
|
|
|
|
|
|
List<InsuranceArchivesBaseInfoPO> allBaseInfoList = getInsuranceBaseInfoMapper().listAll();
|
|
|
|
|
|
Collection<Long> stayAddIds = allBaseInfoList.stream().filter(f->f.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue()))
|
|
|
|
|
|
.map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
if (stayAddIds.size() > 0) {
|
|
|
|
|
|
stayAddToPay(stayAddIds);
|
|
|
|
|
|
}
|
2022-11-03 19:03:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-12 17:17:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 福利档案中待减员数据自动处理
|
|
|
|
|
|
* @param currentEmployeeId
|
|
|
|
|
|
*/
|
2023-09-08 16:57:09 +08:00
|
|
|
|
@Override
|
2022-10-12 17:17:06 +08:00
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
2023-09-08 16:57:09 +08:00
|
|
|
|
public void handleStayDelData(long currentEmployeeId) {
|
2022-11-03 11:14:59 +08:00
|
|
|
|
log.info("福利档案中待减员数据自动处理逻辑开始:");
|
2022-10-12 17:17:06 +08:00
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
|
|
|
|
|
|
String today = simpleDateFormat.format(new Date());
|
|
|
|
|
|
//part1,员工维护了社保/公积金/其他福利最后缴纳日,且任一类信息大于今天的,自动将待减员状态置为正在缴纳状态
|
|
|
|
|
|
List<InsuranceArchivesBaseInfoPO> rePayList = getInsuranceBaseInfoMapper().getRePayList(today);
|
|
|
|
|
|
updateInsuranceBaseInfoRunStatus(rePayList, EmployeeStatusEnum.PAYING.getValue());
|
2022-11-03 11:14:59 +08:00
|
|
|
|
log.info("自动将待减员状态置为正在缴纳状态的档案数量 {}:", rePayList.size());
|
2022-10-12 17:17:06 +08:00
|
|
|
|
//part2,员工维护了社保/公积金/其他福利最后缴纳日,且三类信息都小于今天的,自动置为待减员状态
|
|
|
|
|
|
List<InsuranceArchivesBaseInfoPO> reStayDelList = getInsuranceBaseInfoMapper().getReStayDelList(today);
|
|
|
|
|
|
updateInsuranceBaseInfoRunStatus(reStayDelList, EmployeeStatusEnum.STAY_DEL.getValue());
|
2022-11-03 11:14:59 +08:00
|
|
|
|
log.info("自动置为待减员状态的档案数量 {}:", reStayDelList.size());
|
2022-10-12 17:17:06 +08:00
|
|
|
|
//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());
|
2022-11-03 11:14:59 +08:00
|
|
|
|
log.info("自动处理非在职员工的档案数量 {}:", noNormalList.size());
|
2022-10-12 17:17:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 福利档案中增量数据处理
|
|
|
|
|
|
* @param currentEmployeeId
|
|
|
|
|
|
*/
|
2022-10-13 16:04:54 +08:00
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
2023-02-24 13:53:57 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void handleChangeData(long currentEmployeeId) {
|
2023-08-02 16:08:12 +08:00
|
|
|
|
try {
|
|
|
|
|
|
Util_DataCache.setObjVal("welfareChangeSign", "1");
|
|
|
|
|
|
log.info("福利档案中增量数据处理逻辑开始:");
|
|
|
|
|
|
// 所有增量人员列表
|
|
|
|
|
|
List<TaxAgentEmpChangePO> taxAgentEmpChangeList = getTaxAgentEmpChangeService(user).listAllByModule(TaxAgentEmpChangeModuleEnum.INSURANCE_ARCHIVE);
|
|
|
|
|
|
log.info("待处理的福利档案增量数据数量 {}:", taxAgentEmpChangeList.size());
|
2023-02-24 13:53:57 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(taxAgentEmpChangeList)) {
|
|
|
|
|
|
Util_DataCache.setObjVal("welfareChangeSign", "0");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-08-02 16:08:12 +08:00
|
|
|
|
// 当前可以管辖的人员
|
|
|
|
|
|
Collection<TaxAgentPO> taxAgentList = new ArrayList<>();
|
|
|
|
|
|
if (currentEmployeeId != 1L) {
|
|
|
|
|
|
taxAgentList = getTaxAgentService(user).listAllTaxAgents(currentEmployeeId);
|
|
|
|
|
|
Collection<TaxAgentPO> finalTaxAgentList = taxAgentList;
|
|
|
|
|
|
taxAgentEmpChangeList = taxAgentEmpChangeList.stream().filter(f -> finalTaxAgentList.stream().anyMatch(e -> e.getId().equals(f.getTaxAgentId()))).collect(Collectors.toList());
|
|
|
|
|
|
if (CollectionUtils.isEmpty(taxAgentEmpChangeList)) {
|
|
|
|
|
|
Util_DataCache.setObjVal("welfareChangeSign", "0");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-02-24 13:53:57 +08:00
|
|
|
|
// Collection<TaxAgentPO> taxAgentList = getTaxAgentService(user).listAllTaxAgents(currentEmployeeId);
|
|
|
|
|
|
// log.info("当前可以管辖的个税扣缴义务人数量 {}:", taxAgentList.size());
|
|
|
|
|
|
// taxAgentEmpChangeList = taxAgentEmpChangeList.stream().filter(f -> taxAgentList.stream().anyMatch(e -> e.getId().equals(f.getTaxAgentId()))).collect(Collectors.toList());
|
|
|
|
|
|
// if (CollectionUtils.isEmpty(taxAgentEmpChangeList)) {
|
|
|
|
|
|
// Util_DataCache.setObjVal("welfareChangeSign", "0");
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
2023-08-02 16:08:12 +08:00
|
|
|
|
log.info("根据当前可以管辖的个税扣缴义务人筛选出的可处理增量数据数量 {}:", taxAgentEmpChangeList.size());
|
|
|
|
|
|
// 所有福利档案基础信息数据
|
|
|
|
|
|
List<InsuranceArchivesBaseInfoPO> baseInfoPOList = getInsuranceBaseInfoMapper().listAll();
|
|
|
|
|
|
log.info("当前数据库中所有福利档案基础信息数据数量 {}:", baseInfoPOList.size());
|
|
|
|
|
|
StopWatch sw = new StopWatch();
|
|
|
|
|
|
sw.start("将增量数据进一步处理为新增、更新两类数据");
|
|
|
|
|
|
InsuranceArchivesBaseInfoBO.ChangeData changeData = InsuranceArchivesBaseInfoBO.buildChangeData(taxAgentEmpChangeList, baseInfoPOList, currentEmployeeId);
|
2022-11-03 11:14:59 +08:00
|
|
|
|
sw.stop();
|
2023-08-02 16:08:12 +08:00
|
|
|
|
// 批量修改福利档案
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(changeData.getBaseInfoUpdateTodoList())) {
|
|
|
|
|
|
log.info("增量数据中待更新的数据数量 {}:", changeData.getBaseInfoUpdateTodoList().size());
|
|
|
|
|
|
//对于即将调整为“待减员”的数据,更新社保、公积金、其他福利档案的停止缴纳时间
|
|
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
|
|
|
|
|
|
String today = simpleDateFormat.format(new Date());
|
|
|
|
|
|
sw.start("生成增量数据中即将置为“待减员”的数据");
|
|
|
|
|
|
List<InsuranceArchivesBaseInfoPO> toStayDelList = changeData.getBaseInfoUpdateTodoList().stream()
|
|
|
|
|
|
.filter(f -> f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue()))
|
|
|
|
|
|
.collect(Collectors.toList());
|
2023-08-02 16:31:59 +08:00
|
|
|
|
if (isLog) {
|
|
|
|
|
|
log.info("福利档案-待减员明细:{}", toStayDelList);
|
|
|
|
|
|
}
|
2023-08-02 16:08:12 +08:00
|
|
|
|
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);
|
|
|
|
|
|
});
|
2022-11-03 11:14:59 +08:00
|
|
|
|
|
2022-10-28 10:24:43 +08:00
|
|
|
|
}
|
2023-08-02 16:08:12 +08:00
|
|
|
|
sw.stop();
|
|
|
|
|
|
|
|
|
|
|
|
sw.start("生成增量数据中即将置为“逻辑删除”的数据");
|
|
|
|
|
|
//对于逻辑删除的数据,同样逻辑删除相关的社保、公积金、其他福利档案
|
|
|
|
|
|
List<InsuranceArchivesBaseInfoPO> delList = changeData.getBaseInfoUpdateTodoList().stream()
|
|
|
|
|
|
.filter(f -> f.getDeleteType().equals(DeleteTypeEnum.DELETED.getValue()))
|
|
|
|
|
|
.collect(Collectors.toList());
|
2023-08-02 16:31:59 +08:00
|
|
|
|
if (isLog) {
|
|
|
|
|
|
log.info("福利档案-逻辑删除明细:{}", delList);
|
|
|
|
|
|
}
|
2023-08-02 16:08:12 +08:00
|
|
|
|
if (delList.size() > 0) {
|
|
|
|
|
|
for (InsuranceArchivesBaseInfoPO po : delList) {
|
|
|
|
|
|
getSocialSchemeMapper().deleteByEmployeeIdAndPayOrg(InsuranceArchivesSocialSchemePO.builder()
|
|
|
|
|
|
.employeeId(po.getEmployeeId())
|
|
|
|
|
|
.paymentOrganization(po.getPaymentOrganization())
|
|
|
|
|
|
.build());
|
|
|
|
|
|
getFundSchemeMapper().deleteByEmployeeIdAndPayOrg(InsuranceArchivesFundSchemePO.builder()
|
|
|
|
|
|
.employeeId(po.getEmployeeId())
|
|
|
|
|
|
.paymentOrganization(po.getPaymentOrganization())
|
|
|
|
|
|
.build());
|
|
|
|
|
|
getOtherSchemeMapper().deleteByEmployeeIdAndPayOrg(InsuranceArchivesOtherSchemePO.builder()
|
|
|
|
|
|
.employeeId(po.getEmployeeId())
|
|
|
|
|
|
.paymentOrganization(po.getPaymentOrganization())
|
|
|
|
|
|
.build());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
sw.stop();
|
|
|
|
|
|
//修改福利档案基础信息
|
|
|
|
|
|
sw.start("增量数据中待更新数据入库");
|
2023-08-02 16:31:59 +08:00
|
|
|
|
if (isLog) {
|
|
|
|
|
|
log.info("福利档案-增量数据中待更新数据入库明细:{}", changeData.getBaseInfoUpdateTodoList());
|
|
|
|
|
|
}
|
2023-08-02 16:08:12 +08:00
|
|
|
|
List<List<InsuranceArchivesBaseInfoPO>> partitionUpdateBase = Lists.partition(changeData.getBaseInfoUpdateTodoList(), 100);
|
|
|
|
|
|
partitionUpdateBase.forEach(part-> getInsuranceBaseInfoMapper().batchUpdate(part));
|
|
|
|
|
|
sw.stop();
|
|
|
|
|
|
log.info("增量数据中待更新的数据处理完成!");
|
2022-10-28 10:24:43 +08:00
|
|
|
|
}
|
2022-11-03 11:14:59 +08:00
|
|
|
|
|
2023-08-02 16:08:12 +08:00
|
|
|
|
sw.start("处理增量数据中待新增的数据");
|
|
|
|
|
|
// 批量新增福利档案
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(changeData.getBaseInfoAddTodoList())) {
|
|
|
|
|
|
log.info("增量数据中待新增的数据数量 {}:", changeData.getBaseInfoAddTodoList().size());
|
|
|
|
|
|
//新增社保、公积金、其他福利档案、福利档案基础信息
|
|
|
|
|
|
addNewInsuranceBaseInfo(changeData.getBaseInfoAddTodoList(), currentEmployeeId);
|
|
|
|
|
|
log.info("增量数据中待新增的数据处理完成!");
|
|
|
|
|
|
}
|
|
|
|
|
|
sw.stop();
|
2022-10-13 14:45:18 +08:00
|
|
|
|
|
2023-08-02 16:08:12 +08:00
|
|
|
|
// 删除增量数据
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(changeData.getChangeIds())) {
|
|
|
|
|
|
getTaxAgentEmpChangeService(user).deleleByIds(changeData.getChangeIds());
|
|
|
|
|
|
}
|
|
|
|
|
|
log.info("各操作计时 {}", sw.prettyPrint());
|
|
|
|
|
|
Util_DataCache.setObjVal("welfareChangeSign", "0");
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.info("福利档案-增量数据处理出错:{}", e.getMessage(), e);
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "福利档案-增量数据处理出错"));
|
2022-10-13 14:45:18 +08:00
|
|
|
|
}
|
2022-10-12 17:17:06 +08:00
|
|
|
|
}
|
2023-06-29 10:35:55 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 删除档案
|
|
|
|
|
|
* @param archiveIds
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void deleteArchive(Collection<Long> archiveIds) {
|
|
|
|
|
|
if(CollectionUtils.isEmpty(archiveIds)){
|
|
|
|
|
|
throw new SalaryRunTimeException("社保福利档案参数为空!");
|
|
|
|
|
|
}
|
|
|
|
|
|
SalarySysConfPO canDelete = getSalarySysConfService(user).getOneByCode(SalarySysConstant.SALARY_ARCHIVE_DELETE);
|
|
|
|
|
|
if(Objects.isNull(canDelete) || StringUtils.equals(canDelete.getConfValue(),"0") ){
|
|
|
|
|
|
throw new SalaryRunTimeException("不允许删除社保福利档案,请先开启删除档案规则配置!");
|
|
|
|
|
|
}
|
|
|
|
|
|
List<InsuranceArchivesBaseInfoPO> insuranceArchivesList = getInsuranceBaseInfoMapper().listByIds(archiveIds);
|
|
|
|
|
|
|
|
|
|
|
|
//查询当前登录人员管理的个税扣缴义务人
|
|
|
|
|
|
List<Long> canDeleteTaxAgentIds = getTaxAgentService(user).listAllTaxAgentsAsAdmin((long) user.getUID())
|
|
|
|
|
|
.stream().map(TaxAgentPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
boolean err = insuranceArchivesList.stream().anyMatch(po -> !canDeleteTaxAgentIds.contains(po.getPaymentOrganization()));
|
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(insuranceArchivesList) || err) {
|
|
|
|
|
|
throw new SalaryRunTimeException("社保档案不存在,或没有权限删除该社保案!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Optional<InsuranceArchivesBaseInfoPO> fixedList = insuranceArchivesList.stream().filter(archive -> !StringUtils.equals(archive.getRunStatus(), EmployeeStatusEnum.STAY_ADD.getValue())
|
|
|
|
|
|
&& !StringUtils.equals(archive.getRunStatus(), EmployeeStatusEnum.STOP_PAYMENT_FROM_ADD.getValue())).findFirst();
|
|
|
|
|
|
if(fixedList.isPresent()){
|
|
|
|
|
|
throw new SalaryRunTimeException("在缴员工、待减员、停止缴纳-来自待减员,无法删除薪资档案!");
|
|
|
|
|
|
}
|
|
|
|
|
|
List<Long> archiveDelIds = insuranceArchivesList.stream().map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
List<Long> socialArchiveDelIds = insuranceArchivesList.stream().map(InsuranceArchivesBaseInfoPO::getSocialArchivesId).collect(Collectors.toList());
|
|
|
|
|
|
List<Long> fundArchiveDelIds = insuranceArchivesList.stream().map(InsuranceArchivesBaseInfoPO::getFundArchivesId).collect(Collectors.toList());
|
|
|
|
|
|
List<Long> otherArchiveDelIds = insuranceArchivesList.stream().map(InsuranceArchivesBaseInfoPO::getOtherArchivesId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
// 删除社保档案主表及3张明细表数据
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(archiveDelIds)){
|
|
|
|
|
|
getInsuranceBaseInfoMapper().deleteByIds(archiveDelIds);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(socialArchiveDelIds)){
|
|
|
|
|
|
getSocialSchemeMapper().deleteByIds(socialArchiveDelIds);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(fundArchiveDelIds)){
|
|
|
|
|
|
getFundSchemeMapper().deleteByIds(fundArchiveDelIds);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(otherArchiveDelIds)){
|
|
|
|
|
|
getOtherSchemeMapper().deleteByIds(otherArchiveDelIds);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-13 14:45:18 +08:00
|
|
|
|
//新增社保、公积金、其他福利档案、福利档案基础信息
|
|
|
|
|
|
private List<InsuranceArchivesBaseInfoPO> addNewInsuranceBaseInfo(List<InsuranceArchivesBaseInfoPO> baseInfoPOList, Long currentEmployeeId) {
|
2023-07-28 15:42:37 +08:00
|
|
|
|
try {
|
|
|
|
|
|
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);
|
2022-10-13 14:45:18 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
2023-07-28 15:42:37 +08:00
|
|
|
|
//导入社保档案
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(socialList)) {
|
|
|
|
|
|
log.info("新增社保档案数量:{}", socialList.size());
|
|
|
|
|
|
//根据人员id和个税扣缴义务人id删除对应档案
|
|
|
|
|
|
socialList.forEach(getSocialSchemeMapper()::deleteByEmployeeIdAndPayOrg);
|
|
|
|
|
|
log.info("删除历史社保档案");
|
2023-08-02 16:39:20 +08:00
|
|
|
|
if (isLog) {
|
|
|
|
|
|
log.info("新增社保档案明细:{}", socialList);
|
|
|
|
|
|
}
|
2023-07-28 15:42:37 +08:00
|
|
|
|
List<List<InsuranceArchivesSocialSchemePO>> partition = Lists.partition(socialList, 100);
|
|
|
|
|
|
partition.forEach(getSocialSchemeMapper()::batchSave);
|
|
|
|
|
|
log.info("新增社保档案成功");
|
|
|
|
|
|
}
|
|
|
|
|
|
//导入公积金档案
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(fundList)) {
|
|
|
|
|
|
log.info("新增公积金档案数量:{}", fundList.size());
|
|
|
|
|
|
//根据人员id和个税扣缴义务人id删除对应档案
|
|
|
|
|
|
fundList.forEach(getFundSchemeMapper()::deleteByEmployeeIdAndPayOrg);
|
|
|
|
|
|
log.info("删除历史公积金档案");
|
2023-08-02 16:39:20 +08:00
|
|
|
|
if (isLog) {
|
|
|
|
|
|
log.info("新增公积金档案明细:{}", fundList);
|
|
|
|
|
|
}
|
2023-07-28 15:42:37 +08:00
|
|
|
|
List<List<InsuranceArchivesFundSchemePO>> partition = Lists.partition(fundList, 100);
|
|
|
|
|
|
partition.forEach(getFundSchemeMapper()::batchSave);
|
|
|
|
|
|
log.info("新增公积金档案成功");
|
|
|
|
|
|
}
|
|
|
|
|
|
//导入其他福利档案
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(otherList)) {
|
|
|
|
|
|
log.info("新增其他福利档案数量:{}", otherList.size());
|
|
|
|
|
|
//根据人员id和个税扣缴义务人id删除对应档案
|
|
|
|
|
|
otherList.forEach(getOtherSchemeMapper()::deleteByEmployeeIdAndPayOrg);
|
|
|
|
|
|
log.info("删除历史其他福利档案");
|
2023-08-02 16:39:20 +08:00
|
|
|
|
if (isLog) {
|
|
|
|
|
|
log.info("新增其他福利档案明细:{}", otherList);
|
|
|
|
|
|
}
|
2023-07-28 15:42:37 +08:00
|
|
|
|
List<List<InsuranceArchivesOtherSchemePO>> partition = Lists.partition(otherList, 100);
|
|
|
|
|
|
partition.forEach(getOtherSchemeMapper()::batchSave);
|
|
|
|
|
|
log.info("新增其他福利档案成功");
|
|
|
|
|
|
}
|
|
|
|
|
|
//导入福利档案基础信息
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(baseInfoPOList)) {
|
|
|
|
|
|
//根据人员id和个税扣缴义务人id删除对应档案
|
|
|
|
|
|
baseInfoPOList.forEach(getInsuranceBaseInfoMapper()::deleteByEmployeeIdAndPayOrg);
|
|
|
|
|
|
log.info("删除历史福利档案基础信息");
|
|
|
|
|
|
// //分批批量删除
|
|
|
|
|
|
List<Long> baseInfoEmployeeIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getEmployeeId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
//查询目标人员的剩余的福利档案基础信息(社保、公积金、其他福利档案id)
|
|
|
|
|
|
List<InsuranceArchivesBaseInfoPO> moreBaseInfoPOS = new ArrayList<>();
|
|
|
|
|
|
log.info("查询目标人员的剩余的福利档案基础信息(社保、公积金、其他福利档案id)");
|
|
|
|
|
|
List<List<Long>> partitionInfo = Lists.partition((List<Long>) baseInfoEmployeeIds, 1000);
|
|
|
|
|
|
partitionInfo.forEach(part -> moreBaseInfoPOS.addAll(
|
|
|
|
|
|
getInsuranceBaseInfoMapper().getInsuranceBaseInfoListByInsuranceDetail(part)));
|
|
|
|
|
|
|
|
|
|
|
|
List<InsuranceArchivesBaseInfoPO> newInsuranceArchivesBaseInfoList = new ArrayList<>();
|
|
|
|
|
|
//设置社保、公积金、其他福利档案id
|
|
|
|
|
|
log.info("设置社保、公积金、其他福利档案id");
|
|
|
|
|
|
for (InsuranceArchivesBaseInfoPO po : baseInfoPOList) {
|
|
|
|
|
|
InsuranceArchivesBaseInfoPO moreBaseInfo = moreBaseInfoPOS.stream().filter(s -> Objects.equals(s.getEmployeeId(), po.getEmployeeId()) && Objects.equals(s.getPaymentOrganization(), po.getPaymentOrganization())).findFirst().orElse(null);
|
|
|
|
|
|
po.setSocialArchivesId(moreBaseInfo.getSocialArchivesId());
|
|
|
|
|
|
po.setFundArchivesId(moreBaseInfo.getFundArchivesId());
|
|
|
|
|
|
po.setOtherArchivesId(moreBaseInfo.getOtherArchivesId());
|
|
|
|
|
|
newInsuranceArchivesBaseInfoList.add(po);
|
|
|
|
|
|
}
|
|
|
|
|
|
log.info("福利档案基础信息分批批量入库,入库数量:{}", newInsuranceArchivesBaseInfoList.size());
|
|
|
|
|
|
//分批批量入库
|
2023-08-02 16:39:20 +08:00
|
|
|
|
if (isLog) {
|
|
|
|
|
|
log.info("新增福利档案基础信息明细:{}", newInsuranceArchivesBaseInfoList);
|
|
|
|
|
|
}
|
2023-07-28 15:42:37 +08:00
|
|
|
|
List<List<InsuranceArchivesBaseInfoPO>> partition = Lists.partition(newInsuranceArchivesBaseInfoList, 100);
|
|
|
|
|
|
partition.forEach(getInsuranceBaseInfoMapper()::batchSave);
|
|
|
|
|
|
}
|
2022-10-13 14:45:18 +08:00
|
|
|
|
|
2023-07-28 15:42:37 +08:00
|
|
|
|
return baseInfoPOList;
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.info("新增福利档案出错:{}", e.getMessage(), e);
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "福利档案新增失败"));
|
|
|
|
|
|
}
|
2022-10-13 14:45:18 +08:00
|
|
|
|
}
|
2022-10-12 17:17:06 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 分批更新福利档案基础信息的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())) {
|
2023-07-10 14:33:43 +08:00
|
|
|
|
// request.setStatuses(param.getStatuses());
|
|
|
|
|
|
if (StringUtils.isNotBlank(param.getStatusesStr())) {
|
|
|
|
|
|
request.setStatuses(Arrays.stream(param.getStatusesStr().split(",")).map(String::new).collect(Collectors.toList()));
|
|
|
|
|
|
}
|
2022-04-19 17:46:24 +08:00
|
|
|
|
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);
|
2023-03-07 14:21:01 +08:00
|
|
|
|
List<InsuranceArchivesEmployeePO> list = getSocialSchemeMapper().queryEmployeeList(param);
|
2022-06-06 16:55:02 +08:00
|
|
|
|
return list.stream().filter(f -> employeeIds.contains(f.getEmployeeId())).collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-07 14:21:01 +08:00
|
|
|
|
return getSocialSchemeMapper().queryEmployeeList(param);
|
2022-04-19 17:46:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-12 10:38:41 +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
|
|
|
|
|
2022-10-12 10:38:41 +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();
|
2023-09-06 10:04:58 +08:00
|
|
|
|
list = archiveListDTOS.stream().filter(dto -> taxAgentIds.contains(dto.getPaymentOrganization())).collect(Collectors.toList());
|
2022-10-12 10:38:41 +08:00
|
|
|
|
|
|
|
|
|
|
Boolean adminEnable = getTaxAgentService(user).isAdminEnable(currentEmployeeId);
|
|
|
|
|
|
//不是管理员看不到数据,返回空
|
|
|
|
|
|
if (!adminEnable) {
|
|
|
|
|
|
list = new ArrayList<>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
2023-09-06 10:04:58 +08:00
|
|
|
|
list = getInsuranceBaseInfoMapper().listAll();
|
2022-10-12 10:38:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long stayAddTotal = 0L;
|
|
|
|
|
|
long payTotal = 0L;
|
|
|
|
|
|
long stayDelTotal = 0L;
|
|
|
|
|
|
long stopTotal = 0L;
|
2023-09-06 10:04:58 +08:00
|
|
|
|
long extTotal = 0L;
|
2022-10-12 10:38:41 +08:00
|
|
|
|
|
|
|
|
|
|
for (InsuranceArchivesBaseInfoPO baseInfoPO : list) {
|
2023-09-06 10:04:58 +08:00
|
|
|
|
Integer employeeType = baseInfoPO.getEmployeeType();
|
|
|
|
|
|
if (employeeType == null || employeeType == 0) {
|
|
|
|
|
|
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_FROM_ADD.getValue()) || baseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue())) {
|
|
|
|
|
|
stopTotal += 1;
|
2022-10-12 10:38:41 +08:00
|
|
|
|
}
|
2023-09-06 10:04:58 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
extTotal += 1;
|
2022-10-12 10:38:41 +08:00
|
|
|
|
}
|
2023-09-06 10:04:58 +08:00
|
|
|
|
|
2022-10-12 10:38:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-14 16:34:10 +08:00
|
|
|
|
result.put("stayAdd", stayAddTotal);
|
|
|
|
|
|
result.put("paying", payTotal);
|
|
|
|
|
|
result.put("stayDel", stayDelTotal);
|
|
|
|
|
|
result.put("stopPay", stopTotal);
|
2023-09-06 10:04:58 +08:00
|
|
|
|
result.put("ext", extTotal);
|
2022-10-12 10:38:41 +08:00
|
|
|
|
return result;
|
|
|
|
|
|
}
|
2022-10-13 17:36:15 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 批量变更档案列表的runStatus
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void updateRunStatus(InsuranceArchivesBaseInfoPO po) {
|
|
|
|
|
|
|
|
|
|
|
|
getInsuranceBaseInfoMapper().updateRunStatusByIds(po);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-10-14 18:00:22 +08:00
|
|
|
|
public void cancelStopPayment(Collection<Long> ids) {
|
|
|
|
|
|
if (CollectionUtils.isEmpty(ids)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录"));
|
|
|
|
|
|
}
|
|
|
|
|
|
List<InsuranceArchivesBaseInfoPO> pos = getInsuranceBaseInfoMapper().listByIds(ids);
|
|
|
|
|
|
|
2022-10-13 17:36:15 +08:00
|
|
|
|
List<Long> stayAddIds = new ArrayList<>();
|
|
|
|
|
|
List<Long> stayDelIds = new ArrayList<>();
|
2022-12-19 10:01:32 +08:00
|
|
|
|
List<TaxAgentEmployeeDTO> taxAgentManageRangeEmployees = getTaxAgentService(user).listTaxAgentAndEmployee((long) user.getUID());
|
|
|
|
|
|
|
|
|
|
|
|
List<InsuranceArchivesBaseInfoPO> oldStayAddList = pos.stream().filter(f -> f.getRunStatus().equals(EmployeeStatusEnum.STOP_PAYMENT_FROM_ADD.getValue())).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
boolean isNotExist = oldStayAddList.stream().anyMatch(te -> taxAgentManageRangeEmployees.stream().noneMatch(p -> p.getEmployeeId() != null && p.getEmployeeId().equals(te.getEmployeeId()) && p.getTaxAgentId().equals(te.getPaymentOrganization())));
|
|
|
|
|
|
|
|
|
|
|
|
if (isNotExist) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(116196, "不在当前个税扣缴义人的人员范围中,不可取消停缴"));
|
|
|
|
|
|
}
|
2022-10-13 17:36:15 +08:00
|
|
|
|
|
|
|
|
|
|
for(InsuranceArchivesBaseInfoPO po : pos) {
|
|
|
|
|
|
if (po.getRunStatus().equals(EmployeeStatusEnum.STOP_PAYMENT_FROM_ADD.getValue())) {
|
|
|
|
|
|
//来自待增员的停缴->待增员
|
|
|
|
|
|
stayAddIds.add(po.getId());
|
|
|
|
|
|
} else if (po.getRunStatus().equals(EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue())) {
|
|
|
|
|
|
//来自待减员的停缴->待减员
|
|
|
|
|
|
stayDelIds.add(po.getId());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//更新调整为待增员的数据
|
|
|
|
|
|
InsuranceArchivesBaseInfoPO stayAddPO = InsuranceArchivesBaseInfoPO.builder().ids(stayAddIds).runStatus(EmployeeStatusEnum.STAY_ADD.getValue()).build();
|
2022-10-17 17:24:40 +08:00
|
|
|
|
if (stayAddPO.getIds().size() > 0) {
|
|
|
|
|
|
getInsuranceBaseInfoMapper().updateRunStatusByIds(stayAddPO);
|
|
|
|
|
|
}
|
2022-10-13 17:36:15 +08:00
|
|
|
|
//更新调整为待减员的数据
|
|
|
|
|
|
InsuranceArchivesBaseInfoPO stayDelPO = InsuranceArchivesBaseInfoPO.builder().ids(stayDelIds).runStatus(EmployeeStatusEnum.STAY_DEL.getValue()).build();
|
2022-10-17 17:24:40 +08:00
|
|
|
|
if (stayDelPO.getIds().size() > 0) {
|
|
|
|
|
|
getInsuranceBaseInfoMapper().updateRunStatusByIds(stayDelPO);
|
|
|
|
|
|
}
|
2022-10-13 17:36:15 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
2022-10-14 14:31:09 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 批量减员
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Override
|
2022-10-17 10:13:38 +08:00
|
|
|
|
public Map<String, Object> stayDelToStop(Collection<Long> ids) {
|
2022-10-14 18:00:22 +08:00
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(ids)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录"));
|
|
|
|
|
|
}
|
|
|
|
|
|
List<InsuranceArchivesBaseInfoPO> baseInfoPOList = getInsuranceBaseInfoMapper().listByIds(ids);
|
2022-10-14 14:31:09 +08:00
|
|
|
|
|
|
|
|
|
|
//分别新建福利档案基础信息相关的社保、公积金、其他福利档案列表
|
|
|
|
|
|
List<InsuranceArchivesSocialSchemePO> socialList = new ArrayList<>();
|
|
|
|
|
|
List<InsuranceArchivesFundSchemePO> fundList = new ArrayList<>();
|
|
|
|
|
|
List<InsuranceArchivesOtherSchemePO> otherList = new ArrayList<>();
|
2022-10-27 17:43:52 +08:00
|
|
|
|
|
|
|
|
|
|
//新建最终可以进行减员的福利档案基础信息id列表
|
|
|
|
|
|
List<Long> toStopBaseInfoIdList = new ArrayList<>();
|
|
|
|
|
|
//新建最终不可以进行减员的福利档案基础信息id列表
|
|
|
|
|
|
List<Long> noStopBaseInfoIds = new ArrayList<>();
|
|
|
|
|
|
//获取待处理的福利档案基础信息id列表
|
|
|
|
|
|
List<Long> baseInfoIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList());
|
2022-10-14 14:31:09 +08:00
|
|
|
|
//设置最后缴纳月的比较月份
|
|
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
|
|
|
|
|
|
String todayMonth = simpleDateFormat.format(new Date());
|
|
|
|
|
|
//分别获取福利档案基础信息相关的社保、公积金、其他福利档案id列表
|
|
|
|
|
|
List<Long> socialIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getSocialArchivesId).collect(Collectors.toList());
|
|
|
|
|
|
List<Long> fundIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getFundArchivesId).collect(Collectors.toList());
|
|
|
|
|
|
List<Long> otherIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getOtherArchivesId).collect(Collectors.toList());
|
2022-10-27 17:43:52 +08:00
|
|
|
|
|
|
|
|
|
|
List<Long> toStopSocialIds = new ArrayList<>();
|
|
|
|
|
|
List<Long> toStopFundIds = new ArrayList<>();
|
|
|
|
|
|
List<Long> toStopOtherIds = new ArrayList<>();
|
2022-10-14 14:31:09 +08:00
|
|
|
|
//获取可进行减员的社保档案相关人员数据
|
|
|
|
|
|
if (socialIds.size() > 0) {
|
|
|
|
|
|
//获取社保档案
|
|
|
|
|
|
socialList = getSocialSchemeMapper().getSocialById(socialIds);
|
2022-10-27 17:43:52 +08:00
|
|
|
|
//筛选可减员的社保档案相关信息
|
|
|
|
|
|
|
2022-12-12 17:53:05 +08:00
|
|
|
|
toStopSocialIds = socialList.stream().filter(f-> f.getSocialSchemeId() == null || (f.getSocialEndTime() != null && f.getSocialEndTime().length() > 0 && (f.getSocialEndTime().compareTo(todayMonth)) <= 0))
|
2022-10-27 17:43:52 +08:00
|
|
|
|
.map(InsuranceArchivesSocialSchemePO::getId).collect(Collectors.toList());
|
|
|
|
|
|
//
|
|
|
|
|
|
List<Long> finalToStopSocialIds = toStopSocialIds;
|
|
|
|
|
|
noStopBaseInfoIds = baseInfoPOList.stream().filter(f -> !finalToStopSocialIds.contains(f.getSocialArchivesId())).map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList());
|
2022-10-14 14:31:09 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if (fundIds.size() > 0) {
|
|
|
|
|
|
fundList = getFundSchemeMapper().getFundById(fundIds);
|
2022-10-27 17:43:52 +08:00
|
|
|
|
|
2022-12-12 17:53:05 +08:00
|
|
|
|
toStopFundIds = fundList.stream().filter(f->f.getFundSchemeId() == null || (f.getFundEndTime() != null && f.getFundEndTime().length() > 0 && (f.getFundEndTime().compareTo(todayMonth)) <= 0))
|
2022-10-27 17:43:52 +08:00
|
|
|
|
.map(InsuranceArchivesFundSchemePO::getId).collect(Collectors.toList());
|
|
|
|
|
|
List<Long> finalToStopFundIds = toStopFundIds;
|
|
|
|
|
|
noStopBaseInfoIds = (List<Long>) CollectionUtils.union(noStopBaseInfoIds, baseInfoPOList.stream().filter(f -> !finalToStopFundIds.contains(f.getFundArchivesId())).map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()));
|
|
|
|
|
|
|
2022-10-14 14:31:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (otherIds.size() > 0) {
|
|
|
|
|
|
otherList = getOtherSchemeMapper().getOtherById(otherIds);
|
2022-10-27 17:43:52 +08:00
|
|
|
|
|
2022-12-12 17:53:05 +08:00
|
|
|
|
toStopOtherIds= otherList.stream().filter(f->f.getOtherSchemeId() == null || (f.getOtherEndTime() != null && f.getOtherEndTime().length() > 0 && (f.getOtherEndTime().compareTo(todayMonth)) <= 0))
|
2022-10-27 17:43:52 +08:00
|
|
|
|
.map(InsuranceArchivesOtherSchemePO::getId).collect(Collectors.toList());
|
|
|
|
|
|
List<Long> finalToStopOtherIds = toStopOtherIds;
|
|
|
|
|
|
noStopBaseInfoIds = (List<Long>) CollectionUtils.union(noStopBaseInfoIds, baseInfoPOList.stream().filter(f -> !finalToStopOtherIds.contains(f.getOtherArchivesId())).map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()));
|
|
|
|
|
|
|
2022-10-14 14:31:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
//获取最终基础信息表中的可减员数据
|
2022-10-27 17:43:52 +08:00
|
|
|
|
if (noStopBaseInfoIds.size() == 0) {
|
2022-10-14 14:31:09 +08:00
|
|
|
|
//社保、公积金、其他福利档案的可减员的人员信息与入参中的人员信息一致时
|
2022-10-27 17:43:52 +08:00
|
|
|
|
toStopBaseInfoIdList = baseInfoIds;
|
2022-10-14 14:31:09 +08:00
|
|
|
|
} else {
|
2022-10-27 17:43:52 +08:00
|
|
|
|
|
|
|
|
|
|
//与最终不可减员的baseInfoId信息做差集
|
|
|
|
|
|
toStopBaseInfoIdList = (List<Long>) CollectionUtils.subtract(baseInfoIds, noStopBaseInfoIds);
|
2022-10-14 14:31:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
//进行减员操作
|
2022-10-27 17:43:52 +08:00
|
|
|
|
if (toStopBaseInfoIdList.size() > 0) {
|
|
|
|
|
|
getInsuranceBaseInfoMapper().updateRunStatusByIds(InsuranceArchivesBaseInfoPO.builder()
|
|
|
|
|
|
.ids(toStopBaseInfoIdList).runStatus(EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue()).build());
|
2022-10-14 14:31:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-17 10:13:38 +08:00
|
|
|
|
Map<String, Object> resultMap = new HashMap<>(2);
|
|
|
|
|
|
String resultMsg = "操作成功";
|
|
|
|
|
|
String resultType = "success";
|
|
|
|
|
|
// 批量设为定薪提示
|
|
|
|
|
|
|
2022-10-14 14:31:09 +08:00
|
|
|
|
//输出结果,此处需区分单一减员和批量减员
|
2022-10-27 17:43:52 +08:00
|
|
|
|
if (baseInfoPOList.size() == toStopBaseInfoIdList.size()) {
|
2022-10-14 14:31:09 +08:00
|
|
|
|
//减员成功
|
|
|
|
|
|
if (baseInfoPOList.size() == 1) {
|
2022-10-17 10:13:38 +08:00
|
|
|
|
resultMsg = "减员成功";
|
|
|
|
|
|
|
2022-10-14 14:31:09 +08:00
|
|
|
|
} else {
|
2022-10-17 10:13:38 +08:00
|
|
|
|
resultMsg = "批量减员成功";
|
|
|
|
|
|
|
2022-10-14 14:31:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//减员失败
|
2022-10-17 10:13:38 +08:00
|
|
|
|
resultType = "fail";
|
2022-10-14 14:31:09 +08:00
|
|
|
|
if (baseInfoPOList.size() == 1) {
|
2022-11-03 19:03:41 +08:00
|
|
|
|
resultMsg = "减员失败,失败原因:最后缴纳月数据未正常维护";
|
2022-10-17 10:13:38 +08:00
|
|
|
|
|
2022-10-14 14:31:09 +08:00
|
|
|
|
} else {
|
2022-10-17 10:13:38 +08:00
|
|
|
|
resultMsg = "部分或全部失败:【共提交减员数据"
|
2022-10-27 17:43:52 +08:00
|
|
|
|
+ baseInfoIds.size()
|
|
|
|
|
|
+"条,成功" + toStopBaseInfoIdList.size()
|
|
|
|
|
|
+"条,失败" + noStopBaseInfoIds.size()
|
2022-11-03 19:03:41 +08:00
|
|
|
|
+"条,失败原因:最后缴纳月数据未正常维护】";
|
2022-10-17 10:13:38 +08:00
|
|
|
|
|
2022-10-14 14:31:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-10-17 10:13:38 +08:00
|
|
|
|
resultMap.put("type", resultType);
|
|
|
|
|
|
resultMap.put("msg", resultMsg);
|
|
|
|
|
|
return resultMap;
|
2022-10-14 14:31:09 +08:00
|
|
|
|
}
|
2022-10-14 16:34:10 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 全量减员
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Override
|
2022-10-17 10:13:38 +08:00
|
|
|
|
public Map<String, Object> allStayDelToStop() {
|
2022-11-07 17:15:42 +08:00
|
|
|
|
long currentEmployeeId = user.getUID();
|
2022-10-14 16:34:10 +08:00
|
|
|
|
List<InsuranceArchivesBaseInfoPO> allBaseInfoList = getInsuranceBaseInfoMapper().listAll();
|
|
|
|
|
|
if (allBaseInfoList.size() > 0) {
|
2022-11-07 17:15:42 +08:00
|
|
|
|
//筛选当前人员可管辖(个税扣缴义务人)范围
|
|
|
|
|
|
Collection<TaxAgentPO> taxAgentList = getTaxAgentService(user).listAllTaxAgents(currentEmployeeId);
|
|
|
|
|
|
List<Long> paymentOrganizationList = taxAgentList.stream().map(TaxAgentPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
|
2023-08-30 15:10:25 +08:00
|
|
|
|
Collection<Long> stayDelIds = allBaseInfoList.stream().filter(f->f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())
|
|
|
|
|
|
&& paymentOrganizationList.contains(f.getPaymentOrganization())
|
|
|
|
|
|
&& (f.getEmployeeType() == null || Objects.equals(f.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue())))
|
2022-10-14 18:00:22 +08:00
|
|
|
|
.map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
if (stayDelIds.size() > 0) {
|
|
|
|
|
|
return stayDelToStop(stayDelIds);
|
2022-10-14 16:34:10 +08:00
|
|
|
|
} else {
|
2022-10-17 10:13:38 +08:00
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录"));
|
2022-10-14 16:34:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2022-10-17 10:13:38 +08:00
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录"));
|
2022-10-14 16:34:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 批量增员
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Override
|
2022-10-17 10:13:38 +08:00
|
|
|
|
public Map<String, Object> stayAddToPay(Collection<Long> ids) {
|
2022-10-14 18:00:22 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(ids)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录"));
|
|
|
|
|
|
}
|
2022-11-03 19:03:41 +08:00
|
|
|
|
//
|
|
|
|
|
|
List<InsuranceArchivesBaseInfoPO> baseInfoPOList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
List<List<Long>> partitionInfo = Lists.partition((List<Long>) ids, 100);
|
|
|
|
|
|
partitionInfo.forEach(part -> baseInfoPOList.addAll(
|
|
|
|
|
|
getInsuranceBaseInfoMapper().listByIds(part)));
|
|
|
|
|
|
//
|
2022-10-14 18:00:22 +08:00
|
|
|
|
|
2022-10-14 16:34:10 +08:00
|
|
|
|
//分别新建福利档案基础信息相关的社保、公积金、其他福利档案列表
|
|
|
|
|
|
List<InsuranceArchivesSocialSchemePO> socialList = new ArrayList<>();
|
|
|
|
|
|
List<InsuranceArchivesFundSchemePO> fundList = new ArrayList<>();
|
|
|
|
|
|
List<InsuranceArchivesOtherSchemePO> otherList = new ArrayList<>();
|
2022-10-27 18:00:05 +08:00
|
|
|
|
|
|
|
|
|
|
//新建最终可以进行增员的福利档案基础信息id列表
|
|
|
|
|
|
List<Long> toPayBaseInfoIdList = new ArrayList<>();
|
|
|
|
|
|
//新建最终不可以进行增员的福利档案基础信息id列表
|
|
|
|
|
|
List<Long> noPayBaseInfoIds = new ArrayList<>();
|
|
|
|
|
|
//获取待处理的福利档案基础信息id列表
|
|
|
|
|
|
List<Long> baseInfoIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList());
|
2022-10-14 16:34:10 +08:00
|
|
|
|
//设置最后缴纳月的比较月份
|
|
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
|
|
|
|
|
|
String todayMonth = simpleDateFormat.format(new Date());
|
|
|
|
|
|
//分别获取福利档案基础信息相关的社保、公积金、其他福利档案id列表
|
|
|
|
|
|
List<Long> socialIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getSocialArchivesId).collect(Collectors.toList());
|
|
|
|
|
|
List<Long> fundIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getFundArchivesId).collect(Collectors.toList());
|
|
|
|
|
|
List<Long> otherIds = baseInfoPOList.stream().map(InsuranceArchivesBaseInfoPO::getOtherArchivesId).collect(Collectors.toList());
|
2022-10-27 18:00:05 +08:00
|
|
|
|
|
|
|
|
|
|
List<Long> toStopSocialIds = new ArrayList<>();
|
|
|
|
|
|
List<Long> toStopFundIds = new ArrayList<>();
|
|
|
|
|
|
List<Long> toStopOtherIds = new ArrayList<>();
|
2022-10-14 16:34:10 +08:00
|
|
|
|
//获取可进行增员的社保档案相关人员数据
|
|
|
|
|
|
if (socialIds.size() > 0) {
|
|
|
|
|
|
//获取社保档案
|
2022-11-03 19:03:41 +08:00
|
|
|
|
List<List<Long>> partitionSocial = Lists.partition((List<Long>) socialIds, 100);
|
|
|
|
|
|
partitionSocial.forEach(part -> socialList.addAll(
|
|
|
|
|
|
getSocialSchemeMapper().getSocialById(part)));
|
|
|
|
|
|
|
2022-10-14 16:34:10 +08:00
|
|
|
|
//筛选可增员的社保档案相关人员信息
|
2022-10-27 18:00:05 +08:00
|
|
|
|
toStopSocialIds = socialList.stream().filter(f->
|
2022-10-14 16:34:10 +08:00
|
|
|
|
{
|
|
|
|
|
|
boolean flag = true;
|
|
|
|
|
|
if (f.getSocialStartTime() == null || f.getSocialStartTime().length() == 0 || f.getSocialSchemeId() == null) {
|
|
|
|
|
|
flag = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (f.getSocialEndTime() != null && f.getSocialEndTime().length() > 0 && (f.getSocialEndTime().compareTo(todayMonth)) <= 0) {
|
|
|
|
|
|
flag = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
return flag;
|
|
|
|
|
|
})
|
2022-10-27 18:00:05 +08:00
|
|
|
|
.map(InsuranceArchivesSocialSchemePO::getId).collect(Collectors.toList());
|
|
|
|
|
|
List<Long> finalToStopSocialIds = toStopSocialIds;
|
|
|
|
|
|
toPayBaseInfoIdList = baseInfoPOList.stream().filter(f -> finalToStopSocialIds.contains(f.getSocialArchivesId())).map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
|
2022-10-14 16:34:10 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if (fundIds.size() > 0) {
|
2022-11-03 19:03:41 +08:00
|
|
|
|
List<List<Long>> partitionFund = Lists.partition((List<Long>) fundIds, 100);
|
|
|
|
|
|
partitionFund.forEach(part -> fundList.addAll(
|
|
|
|
|
|
getFundSchemeMapper().getFundById(part)));
|
|
|
|
|
|
|
2022-10-27 18:00:05 +08:00
|
|
|
|
toStopFundIds = fundList.stream().filter(f->
|
2022-10-14 16:34:10 +08:00
|
|
|
|
{
|
|
|
|
|
|
boolean flag = true;
|
|
|
|
|
|
if (f.getFundStartTime() == null || f.getFundStartTime().length() == 0 || f.getFundSchemeId() == null) {
|
|
|
|
|
|
flag = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (f.getFundEndTime() != null && f.getFundEndTime().length() > 0 && (f.getFundEndTime().compareTo(todayMonth)) <= 0) {
|
|
|
|
|
|
flag = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
return flag;
|
|
|
|
|
|
})
|
2022-11-09 11:25:46 +08:00
|
|
|
|
.map(InsuranceArchivesFundSchemePO::getId).collect(Collectors.toList());
|
2022-10-27 18:00:05 +08:00
|
|
|
|
List<Long> finalToStopFundIds = toStopFundIds;
|
|
|
|
|
|
toPayBaseInfoIdList = (List<Long>) CollectionUtils.union(toPayBaseInfoIdList, baseInfoPOList.stream().filter(f -> finalToStopFundIds.contains(f.getFundArchivesId())).map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()));
|
|
|
|
|
|
|
2022-10-14 16:34:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (otherIds.size() > 0) {
|
2022-11-03 19:03:41 +08:00
|
|
|
|
List<List<Long>> partitionOther = Lists.partition((List<Long>) otherIds, 100);
|
|
|
|
|
|
partitionOther.forEach(part -> otherList.addAll(
|
|
|
|
|
|
getOtherSchemeMapper().getOtherById(part)));
|
|
|
|
|
|
|
2022-10-27 18:00:05 +08:00
|
|
|
|
toStopOtherIds = otherList.stream().filter(f->
|
2022-10-14 16:34:10 +08:00
|
|
|
|
{
|
|
|
|
|
|
boolean flag = true;
|
|
|
|
|
|
if (f.getOtherStartTime() == null || f.getOtherStartTime().length() == 0 || f.getOtherSchemeId() == null) {
|
|
|
|
|
|
flag = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (f.getOtherEndTime() != null && f.getOtherEndTime().length() > 0 && (f.getOtherEndTime().compareTo(todayMonth)) <= 0) {
|
|
|
|
|
|
flag = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
return flag;
|
|
|
|
|
|
})
|
2022-11-09 11:25:46 +08:00
|
|
|
|
.map(InsuranceArchivesOtherSchemePO::getId).collect(Collectors.toList());
|
2022-10-27 18:00:05 +08:00
|
|
|
|
List<Long> finalToStopOtherIds = toStopOtherIds;
|
|
|
|
|
|
toPayBaseInfoIdList = (List<Long>) CollectionUtils.union(toPayBaseInfoIdList, baseInfoPOList.stream().filter(f -> finalToStopOtherIds.contains(f.getOtherArchivesId())).map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList()));
|
|
|
|
|
|
|
2022-10-14 16:34:10 +08:00
|
|
|
|
}
|
2022-10-27 18:00:05 +08:00
|
|
|
|
//获取最终基础信息表中的不可增员数据
|
|
|
|
|
|
noPayBaseInfoIds = (List<Long>) CollectionUtils.subtract(baseInfoIds, toPayBaseInfoIdList);
|
|
|
|
|
|
|
2022-10-14 16:34:10 +08:00
|
|
|
|
//其他的个税扣缴义务人下的在缴员工中存在该员工,在缴员工未进入停缴员工时,不可进行增员
|
|
|
|
|
|
|
|
|
|
|
|
//进行增员操作
|
2022-10-27 18:00:05 +08:00
|
|
|
|
if (toPayBaseInfoIdList.size() > 0) {
|
2022-11-03 19:03:41 +08:00
|
|
|
|
List<List<Long>> partitionToPay = Lists.partition((List<Long>) toPayBaseInfoIdList, 100);
|
|
|
|
|
|
partitionToPay.forEach(part -> {
|
|
|
|
|
|
getInsuranceBaseInfoMapper().updateRunStatusByIds(InsuranceArchivesBaseInfoPO.builder()
|
|
|
|
|
|
.ids(part).runStatus(EmployeeStatusEnum.PAYING.getValue()).build());
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2022-10-14 16:34:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-17 10:13:38 +08:00
|
|
|
|
Map<String, Object> resultMap = new HashMap<>(2);
|
|
|
|
|
|
String resultMsg = "操作成功";
|
|
|
|
|
|
String resultType = "success";
|
|
|
|
|
|
// 批量设为定薪提示
|
|
|
|
|
|
|
2022-10-14 16:34:10 +08:00
|
|
|
|
//输出结果,此处需区分单一增员和批量增员
|
2022-10-27 18:00:05 +08:00
|
|
|
|
if (baseInfoPOList.size() == toPayBaseInfoIdList.size()) {
|
2022-10-14 16:34:10 +08:00
|
|
|
|
//增员成功
|
|
|
|
|
|
if (baseInfoPOList.size() == 1) {
|
2022-10-17 10:13:38 +08:00
|
|
|
|
resultMsg = "增员成功";
|
|
|
|
|
|
|
2022-10-14 16:34:10 +08:00
|
|
|
|
} else {
|
2022-10-17 10:13:38 +08:00
|
|
|
|
resultMsg = "批量增员成功";
|
2022-10-14 16:34:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//增员失败
|
2022-10-17 10:13:38 +08:00
|
|
|
|
resultType = "fail";
|
2022-10-14 16:34:10 +08:00
|
|
|
|
if (baseInfoPOList.size() == 1) {
|
2022-11-03 19:03:41 +08:00
|
|
|
|
resultMsg = "增员失败,失败原因:起始缴纳月/福利方案数据未正常维护";
|
2022-10-14 16:34:10 +08:00
|
|
|
|
} else {
|
2022-10-17 10:13:38 +08:00
|
|
|
|
resultMsg = "部分或全部失败:【共提交增员数据"
|
2022-10-27 18:00:05 +08:00
|
|
|
|
+ baseInfoIds.size()
|
|
|
|
|
|
+"条,成功" + toPayBaseInfoIdList.size()
|
|
|
|
|
|
+"条,失败" + noPayBaseInfoIds.size()
|
2022-11-03 19:03:41 +08:00
|
|
|
|
+"条,失败原因:起始缴纳月/福利方案数据未正常维护】";
|
2022-10-17 10:13:38 +08:00
|
|
|
|
|
2022-10-14 16:34:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-10-17 10:13:38 +08:00
|
|
|
|
resultMap.put("type", resultType);
|
|
|
|
|
|
resultMap.put("msg", resultMsg);
|
|
|
|
|
|
return resultMap;
|
2022-10-14 16:34:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 全量增员
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Override
|
2022-10-17 10:13:38 +08:00
|
|
|
|
public Map<String, Object> allStayAddToPay() {
|
2022-11-07 17:15:42 +08:00
|
|
|
|
long currentEmployeeId = user.getUID();
|
2022-10-14 16:34:10 +08:00
|
|
|
|
List<InsuranceArchivesBaseInfoPO> allBaseInfoList = getInsuranceBaseInfoMapper().listAll();
|
|
|
|
|
|
if (allBaseInfoList.size() > 0) {
|
2022-11-07 17:15:42 +08:00
|
|
|
|
//筛选当前人员可管辖(个税扣缴义务人)范围
|
|
|
|
|
|
Collection<TaxAgentPO> taxAgentList = getTaxAgentService(user).listAllTaxAgents(currentEmployeeId);
|
|
|
|
|
|
List<Long> paymentOrganizationList = taxAgentList.stream().map(TaxAgentPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
|
2023-08-30 15:10:25 +08:00
|
|
|
|
Collection<Long> stayAddIds = allBaseInfoList.stream().filter(f->f.getRunStatus().equals(EmployeeStatusEnum.STAY_ADD.getValue())
|
|
|
|
|
|
&& paymentOrganizationList.contains(f.getPaymentOrganization())
|
|
|
|
|
|
&& (f.getEmployeeType() == null || Objects.equals(f.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue())))
|
2022-10-14 18:00:22 +08:00
|
|
|
|
.map(InsuranceArchivesBaseInfoPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
if (stayAddIds.size() > 0) {
|
|
|
|
|
|
return stayAddToPay(stayAddIds);
|
2022-10-14 16:34:10 +08:00
|
|
|
|
} else {
|
2022-10-17 10:13:38 +08:00
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录"));
|
2022-10-14 16:34:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2022-10-17 10:13:38 +08:00
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(145969, "没有可以操作的记录"));
|
2022-10-14 16:34:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-12 15:43:12 +08:00
|
|
|
|
/**
|
2022-12-13 16:58:35 +08:00
|
|
|
|
* 待减员页面的删除待办
|
2022-12-12 15:43:12 +08:00
|
|
|
|
*/
|
|
|
|
|
|
@Override
|
2022-12-13 16:58:35 +08:00
|
|
|
|
public void cancelStayDel(InsuranceArchivesBaseInfoPO insuranceArchivesBaseInfoPO) {
|
2022-12-12 15:43:12 +08:00
|
|
|
|
|
|
|
|
|
|
if (insuranceArchivesBaseInfoPO.getIds() == null || StringUtils.isBlank(insuranceArchivesBaseInfoPO.getRunStatus())) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (insuranceArchivesBaseInfoPO.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())) {
|
2022-12-12 16:55:22 +08:00
|
|
|
|
List<List<Long>> baseInfoIdsPartition = Lists.partition((List<Long>) insuranceArchivesBaseInfoPO.getIds(), 100);
|
|
|
|
|
|
List<InsuranceArchivesBaseInfoPO> nowList = new ArrayList<>();
|
|
|
|
|
|
baseInfoIdsPartition.forEach(part -> {
|
|
|
|
|
|
nowList.addAll(getInsuranceBaseInfoMapper().listByIds(part));
|
|
|
|
|
|
});
|
2023-04-24 14:47:28 +08:00
|
|
|
|
//判断当前被操作人员是否都在对应的个税扣缴义务人下
|
|
|
|
|
|
List<TaxAgentEmployeeDTO> taxAgentManageRangeEmployees = getTaxAgentService(user).listTaxAgentAndEmployee((long) user.getUID());
|
|
|
|
|
|
|
|
|
|
|
|
boolean isNotExist = nowList.stream().anyMatch(te ->
|
|
|
|
|
|
taxAgentManageRangeEmployees.stream().noneMatch(p ->
|
|
|
|
|
|
p.getEmployeeId() != null && p.getEmployeeId().equals(te.getEmployeeId()) && p.getTaxAgentId().equals(te.getPaymentOrganization())));
|
|
|
|
|
|
|
|
|
|
|
|
if (isNotExist) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(116196, "个税扣缴义务人不存在或不在权限范围内,删除失败!"));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-12 15:43:12 +08:00
|
|
|
|
//置空社保、公积金、其他福利档案的最后缴纳月信息,并将福利档案基础信息表的状态置为“正在缴纳”
|
|
|
|
|
|
if (nowList.size() > 0) {
|
|
|
|
|
|
List<Long> socialIds = nowList.stream()
|
|
|
|
|
|
.map(InsuranceArchivesBaseInfoPO::getSocialArchivesId).collect(Collectors.toList());
|
|
|
|
|
|
List<Long> fundIds = nowList.stream()
|
|
|
|
|
|
.map(InsuranceArchivesBaseInfoPO::getFundArchivesId).collect(Collectors.toList());
|
|
|
|
|
|
List<Long> otherIds = nowList.stream()
|
|
|
|
|
|
.map(InsuranceArchivesBaseInfoPO::getOtherArchivesId).collect(Collectors.toList());
|
|
|
|
|
|
|
2022-12-12 16:55:22 +08:00
|
|
|
|
List<List<Long>> socialIdsPartition = Lists.partition(socialIds, 100);
|
|
|
|
|
|
socialIdsPartition.forEach(getSocialSchemeMapper()::batchUpdateEndTimeToNull);
|
|
|
|
|
|
|
|
|
|
|
|
List<List<Long>> fundIdsPartition = Lists.partition(fundIds, 100);
|
|
|
|
|
|
fundIdsPartition.forEach(getFundSchemeMapper()::batchUpdateEndTimeToNull);
|
|
|
|
|
|
|
|
|
|
|
|
List<List<Long>> otherIdsPartition = Lists.partition(otherIds, 100);
|
|
|
|
|
|
otherIdsPartition.forEach(getOtherSchemeMapper()::batchUpdateEndTimeToNull);
|
|
|
|
|
|
|
|
|
|
|
|
baseInfoIdsPartition.forEach(part -> {
|
|
|
|
|
|
getInsuranceBaseInfoMapper().updateRunStatusByIds(InsuranceArchivesBaseInfoPO.builder()
|
|
|
|
|
|
.ids(part)
|
|
|
|
|
|
.runStatus(EmployeeStatusEnum.PAYING.getValue())
|
|
|
|
|
|
.build());
|
|
|
|
|
|
});
|
2022-12-12 15:43:12 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-10-18 13:34:05 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public PageInfo<InsuranceArchivesBaseHistoryDTO> getAdjustHistoryList(SIArchiveBaseHistoryListParam param) {
|
|
|
|
|
|
|
|
|
|
|
|
if (param.getWelfareTypeEnum() == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "参数错误"));
|
|
|
|
|
|
}
|
|
|
|
|
|
List<InsuranceArchivesBaseHistoryDTO> adjustHistoryDTOS = siArchivesBiz.getAdjustHistoryList(param.getPaymentOrganization(), param.getEmployeeId());
|
|
|
|
|
|
|
|
|
|
|
|
List<InsuranceArchivesBaseHistoryDTO> targetHistory = adjustHistoryDTOS.stream()
|
|
|
|
|
|
.filter(f -> f.getWelfareType().equals(param.getWelfareTypeEnum().getValue())).collect(Collectors.toList());
|
|
|
|
|
|
|
2023-10-23 18:07:37 +08:00
|
|
|
|
PageInfo<InsuranceArchivesBaseHistoryDTO> listPage = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(),
|
2023-10-18 13:34:05 +08:00
|
|
|
|
targetHistory , InsuranceArchivesBaseHistoryDTO.class);
|
|
|
|
|
|
|
|
|
|
|
|
return listPage;
|
|
|
|
|
|
}
|
2022-10-14 16:34:10 +08:00
|
|
|
|
|
2023-10-18 15:13:08 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public PageInfo<InsuranceArchivesBaseHistoryDTO> historyListByEmployeeIdAndOperator(SIArchiveBaseHistoryListParam param) {
|
|
|
|
|
|
|
|
|
|
|
|
List<InsuranceArchivesBaseHistoryDTO> adjustHistoryDTOS = siArchivesBiz.getBaseHistoryByEmployeeIdAndOperator(param.getOperator(), param.getEmployeeId());
|
|
|
|
|
|
|
2023-10-23 18:07:37 +08:00
|
|
|
|
PageInfo<InsuranceArchivesBaseHistoryDTO> listPage = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(),
|
2023-10-18 15:13:08 +08:00
|
|
|
|
adjustHistoryDTOS , InsuranceArchivesBaseHistoryDTO.class);
|
|
|
|
|
|
|
|
|
|
|
|
return listPage;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-15 09:34:53 +08:00
|
|
|
|
}
|