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

2629 lines
165 KiB
Java
Raw Normal View History

2022-04-11 19:07:35 +08:00
package com.engine.salary.biz;
2022-04-14 11:54:16 +08:00
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.api.formmode.mybatis.util.SqlProxyHandle;
2022-06-08 17:52:10 +08:00
import com.engine.common.util.ServiceUtil;
2022-06-06 19:08:39 +08:00
import com.engine.core.impl.Service;
import com.engine.salary.cache.SalaryCacheKey;
2022-04-14 11:54:16 +08:00
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.encrypt.EncryptUtil;
2023-06-06 10:30:49 +08:00
import com.engine.salary.entity.progress.ProgressDTO;
2022-04-18 20:24:43 +08:00
import com.engine.salary.entity.siaccount.dto.InsuranceAccountViewListDTO;
2022-07-28 16:28:53 +08:00
import com.engine.salary.entity.siaccount.dto.SIAccountUtilDTO;
2022-04-15 13:17:25 +08:00
import com.engine.salary.entity.siaccount.param.*;
import com.engine.salary.entity.siaccount.po.*;
import com.engine.salary.entity.siarchives.po.*;
2022-04-15 13:17:25 +08:00
import com.engine.salary.entity.sicategory.po.ICategoryPO;
2022-04-14 11:54:16 +08:00
import com.engine.salary.entity.sischeme.po.InsuranceSchemeDetailPO;
2022-08-09 16:54:29 +08:00
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
2022-04-15 13:17:25 +08:00
import com.engine.salary.enums.siaccount.*;
import com.engine.salary.enums.sicategory.*;
import com.engine.salary.exception.SalaryRunTimeException;
2022-07-20 15:40:51 +08:00
import com.engine.salary.mapper.siaccount.*;
import com.engine.salary.mapper.siarchives.FundSchemeMapper;
import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper;
import com.engine.salary.mapper.siarchives.OtherSchemeMapper;
import com.engine.salary.mapper.siarchives.SocialSchemeMapper;
2022-04-15 13:17:25 +08:00
import com.engine.salary.mapper.sicategory.ICategoryMapper;
2022-04-14 11:54:16 +08:00
import com.engine.salary.mapper.sischeme.InsuranceSchemeDetailMapper;
2022-08-09 16:54:29 +08:00
import com.engine.salary.mapper.taxagent.TaxAgentMapper;
2023-06-06 10:30:49 +08:00
import com.engine.salary.service.ProgressService;
import com.engine.salary.service.SalaryEmployeeService;
2022-06-08 17:52:10 +08:00
import com.engine.salary.service.TaxAgentService;
2023-06-06 10:30:49 +08:00
import com.engine.salary.service.impl.ProgressServiceImpl;
import com.engine.salary.service.impl.SalaryEmployeeServiceImpl;
2022-06-08 17:52:10 +08:00
import com.engine.salary.service.impl.TaxAgentServiceImpl;
import com.engine.salary.sys.constant.SalarySysConstant;
import com.engine.salary.sys.entity.po.SalarySysConfPO;
2022-09-27 10:19:09 +08:00
import com.engine.salary.sys.entity.vo.OrderRuleVO;
import com.engine.salary.sys.enums.SalaryAcctEmployeeRuleEnum;
2022-09-27 10:19:09 +08:00
import com.engine.salary.sys.service.SalarySysConfService;
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
2022-04-14 11:54:16 +08:00
import com.engine.salary.util.SalaryAssert;
import com.engine.salary.util.SalaryDateUtil;
2022-04-14 11:54:16 +08:00
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
2022-04-11 19:07:35 +08:00
import com.engine.salary.util.page.PageInfo;
2022-05-25 13:10:03 +08:00
import com.engine.salary.util.page.SalaryPageUtil;
2022-06-06 19:08:39 +08:00
import com.engine.salary.util.valid.ValidUtil;
2022-04-20 19:12:01 +08:00
import com.google.common.collect.Lists;
2022-06-10 18:01:55 +08:00
import com.wbi.util.StringUtil;
2022-04-14 11:54:16 +08:00
import dm.jdbc.util.IdGenerator;
2022-05-25 13:23:02 +08:00
import lombok.extern.slf4j.Slf4j;
2022-04-14 11:54:16 +08:00
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.lang3.ObjectUtils;
2022-04-14 11:54:16 +08:00
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
2022-09-27 10:19:09 +08:00
import weaver.hrm.User;
2022-04-11 19:07:35 +08:00
2022-04-14 11:54:16 +08:00
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
2022-04-14 11:54:16 +08:00
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
2022-04-11 19:07:35 +08:00
/**
* @Author weaver_cl
2022-07-08 11:30:10 +08:00
* @Description:
2022-04-11 19:07:35 +08:00
* @Date 2022/4/11
* @Version V1.0
**/
2022-05-25 13:23:02 +08:00
@Slf4j
2022-06-06 19:08:39 +08:00
public class SIAccountBiz extends Service {
2022-04-11 19:07:35 +08:00
2022-04-15 13:17:25 +08:00
private SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
2022-04-11 19:07:35 +08:00
private EncryptUtil encryptUtil = new EncryptUtil();
2022-06-08 17:52:10 +08:00
private TaxAgentService getTaxAgentService() {
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
private SalaryEmployeeService getSalaryEmployeeService() {
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
private InsuranceAccountBatchMapper getInsuranceAccountBatchMapper() {
return SqlProxyHandle.getProxy(InsuranceAccountBatchMapper.class);
}
2022-04-22 15:17:31 +08:00
private InsuranceAccountDetailMapper getInsuranceAccountDetailMapper() {
return SqlProxyHandle.getProxy(InsuranceAccountDetailMapper.class);
}
2022-07-21 17:28:47 +08:00
2022-07-20 15:40:51 +08:00
private SIAccountUtilMapper getSIAccountUtilMapper() {
return MapperProxyFactory.getProxy(SIAccountUtilMapper.class);
}
private InsuranceAccountInspectMapper getInsuranceAccountInspectMapper() {
return MapperProxyFactory.getProxy(InsuranceAccountInspectMapper.class);
}
private InsuranceBaseInfoMapper getInsuranceBaseInfoMapper() {
return MapperProxyFactory.getProxy(InsuranceBaseInfoMapper.class);
}
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-09-27 10:19:09 +08:00
private SalarySysConfService getSalarySysConfService(User user) {
return ServiceUtil.getService(SalarySysConfServiceImpl.class, user);
}
private InsuranceCompensationMapper getInsuranceCompensationMapper() {
return MapperProxyFactory.getProxy(InsuranceCompensationMapper.class);
}
2023-06-06 10:30:49 +08:00
private ProgressService getSalaryAcctProgressService(User user) {
return (ProgressService) ServiceUtil.getService(ProgressServiceImpl.class, user);
}
2023-03-06 17:57:20 +08:00
private SalaryEmployeeService getSalaryEmployeeService(User user) {
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
private SIAccountDetailTempMapper getSIAccountDetailTempMapper() {
return MapperProxyFactory.getProxy(SIAccountDetailTempMapper.class);
}
private InsuranceSchemeDetailMapper getInsuranceSchemeDetailMapper() {
return MapperProxyFactory.getProxy(InsuranceSchemeDetailMapper.class);
}
private ICategoryMapper getICategoryMapper() {
return MapperProxyFactory.getProxy(ICategoryMapper.class);
}
private TaxAgentMapper getTaxAgentMapper() {
return MapperProxyFactory.getProxy(TaxAgentMapper.class);
}
public PageInfo<InsuranceAccountBatchPO> listPage(InsuranceAccountBatchParam queryParam) {
List<InsuranceAccountBatchPO> list = getInsuranceAccountBatchMapper().list(queryParam);
2022-12-12 10:25:55 +08:00
PageInfo<InsuranceAccountBatchPO> page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(),
list, InsuranceAccountBatchPO.class);
2022-12-14 11:03:33 +08:00
encryptUtil.decryptList(page.getList(), InsuranceAccountBatchPO.class);
2022-12-12 10:25:55 +08:00
return page;
2022-04-11 19:07:35 +08:00
}
2022-04-12 10:24:21 +08:00
public PageInfo<InsuranceAccountDetailPO> listCommonPage(InsuranceAccountDetailParam queryParam) {
queryParam.setPaymentStatus(PaymentStatusEnum.COMMON.getValue());
2022-09-27 10:19:09 +08:00
// //过滤出需要核算的人员即福利档案基础信息表中runStatus为正在缴纳和待减员的人员
// List<InsuranceArchivesBaseInfoPO> baseInfoPOList = getInsuranceBaseInfoMapper().listAll();
// List<Long> canAccountIds = baseInfoPOList.stream()
// .filter(f->f.getPaymentOrganization().toString().equals(queryParam.getPaymentOrganization())
// && (f.getRunStatus().equals(EmployeeStatusEnum.PAYING.getValue()) || f.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue())))
// .map(InsuranceArchivesBaseInfoPO::getEmployeeId)
// .collect(Collectors.toList());
// queryParam.setEmployeeIds(canAccountIds);
2022-09-27 10:19:09 +08:00
//排序配置
OrderRuleVO orderRule = getSalarySysConfService(user).orderRule();
queryParam.setOrderRule(orderRule);
//系统人员福利台账明细
List<InsuranceAccountDetailPO> list = getInsuranceAccountDetailMapper().list(queryParam);
//非系统各人员台账明细
List<InsuranceAccountDetailPO> extList = getInsuranceAccountDetailMapper().extList(queryParam);
list.addAll(extList);
2022-12-12 10:25:55 +08:00
PageInfo<InsuranceAccountDetailPO> pageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(),
list, InsuranceAccountDetailPO.class);
encryptUtil.decryptList(pageInfo.getList(), InsuranceAccountDetailPO.class);
return pageInfo;
2022-04-12 10:24:21 +08:00
}
2022-04-14 11:54:16 +08:00
public String save(boolean flag, AccountParam param, Long employeeId, String currentUserName) {
2022-04-14 11:54:16 +08:00
if (flag) {
InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), param.getPaymentOrganization());
insuranceAccountBatchPO = encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class);
SalaryAssert.isNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel(100461, "所属月份存在核算数据"));
2022-06-10 17:03:25 +08:00
2022-04-14 11:54:16 +08:00
InsuranceAccountBatchPO build = InsuranceAccountBatchPO.builder()
2022-06-06 19:08:39 +08:00
.paymentOrganization(param.getPaymentOrganization())
2022-04-22 15:17:31 +08:00
.accountant(currentUserName)
2022-04-14 11:54:16 +08:00
.billMonth(param.getBillMonth())
.billStatus(BillStatusEnum.NOT_ARCHIVED.getValue())
.remarks(param.getRemarks())
.creator(employeeId)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.createTime(new Date())
.updateTime(new Date())
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
2022-06-08 17:52:10 +08:00
.paymentOrganization(param.getPaymentOrganization())
.socialPay("0")
.fundPay("0")
.otherPay("0")
2022-04-14 11:54:16 +08:00
.build();
encryptUtil.encrypt(build, InsuranceAccountBatchPO.class);
getInsuranceAccountBatchMapper().insert(build);
2022-04-14 11:54:16 +08:00
// LoggerContext insuranceSchemeContext = new LoggerContext();
// insuranceSchemeContext.setTargetId(String.valueOf(build.getId()));
// insuranceSchemeContext.setTargetName(build.getBillMonth());
// insuranceSchemeContext.setOperateType(OperateTypeEnum.ADD.getValue());
// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100462, "新增台账"));
// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100462, "新增台账"));
// insuranceSchemeContext.setNewValues(build);
// siAccountLoggerTemplate.write(insuranceSchemeContext);
}
2022-06-14 16:05:23 +08:00
try {
account(param, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, currentUserName);
} catch (Exception e) {
2022-06-14 16:05:23 +08:00
// 回滚
List<InsuranceAccountBatchPO> list = Lists.newArrayList(getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), param.getPaymentOrganization()));
list = encryptUtil.decryptList(list, InsuranceAccountBatchPO.class);
2022-06-14 16:05:23 +08:00
if (CollectionUtils.isNotEmpty(list)) {
list.stream().forEach(f -> {
getInsuranceAccountBatchMapper().deleteById(f.getId());
2022-06-14 16:05:23 +08:00
});
}
throw new SalaryRunTimeException(e.getMessage());
}
return employeeId.toString();
2022-04-14 11:54:16 +08:00
}
2022-06-06 19:08:39 +08:00
public void account(AccountParam param, Long employeeId, String tenantKey, String currentUserName) {
2022-08-04 09:55:10 +08:00
// Collection<Long> employeeIdsInTaxAgent = getTaxAgentService().listEmployeeIdsInTaxAgent(param.getPaymentOrganization());
Long paymentOrganization = param.getPaymentOrganization();
// List<Long> employeeIds = getInsuranceAccountDetailMapper().selectAccountIds(SalaryDateUtil.getMonthBegin(param.getBillMonth()), paymentOrganization);
List<Long> employeeIds = getInsuranceAccountDetailMapper().selectEmpByPaymentOrg(paymentOrganization);
2022-08-04 09:55:10 +08:00
// employeeIds = employeeIds.stream().filter(employeeIdsInTaxAgent::contains).collect(Collectors.toList());
2022-04-14 11:54:16 +08:00
if (CollectionUtils.isEmpty(employeeIds)) {
List<InsuranceAccountDetailPO> list = Lists.newArrayList(getInsuranceAccountDetailMapper().queryNormalListByBillMonth(param.getBillMonth(), paymentOrganization));
encryptUtil.decryptList(list, InsuranceAccountDetailPO.class);
2022-04-14 11:54:16 +08:00
if (CollectionUtils.isNotEmpty(list)) {
list.stream().forEach(f -> {
getInsuranceAccountDetailMapper().deleteById(f.getId());
2022-04-14 11:54:16 +08:00
});
}
}
2022-06-14 16:05:23 +08:00
SalaryAssert.notEmpty(employeeIds, "没有需要核算的人员");
2022-06-06 19:08:39 +08:00
AccountParam selectParam = new AccountParam();
selectParam.setBillMonth(param.getBillMonth());
selectParam.setPaymentOrganization(paymentOrganization);
2022-04-14 11:54:16 +08:00
ExecutorService taskExecutor = Executors.newCachedThreadPool();
taskExecutor.execute(() -> {
try {
DSTenantKeyThreadVar.tenantKey.set(tenantKey);
2022-06-06 19:08:39 +08:00
accounting(selectParam, employeeId, tenantKey, currentUserName);
2022-04-14 11:54:16 +08:00
} finally {
DSTenantKeyThreadVar.tenantKey.remove();
}
});
}
2022-06-06 19:08:39 +08:00
public void accounting(AccountParam param, Long employeeId, String tenantKey, String currentUserName) {
2022-04-14 11:54:16 +08:00
//薪资核算进度暂未实现
2023-06-06 10:30:49 +08:00
ProgressDTO salaryAcctProgressDTO = getSalaryAcctProgressService(user).getProgress(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth());
if (salaryAcctProgressDTO != null && salaryAcctProgressDTO.isStatus() && salaryAcctProgressDTO.getProgress().compareTo(BigDecimal.ONE) < 0) {
return;
}
// 初始化进度
2023-06-06 10:30:49 +08:00
ProgressDTO initProgress = new ProgressDTO()
.setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中"))
.setTitleLabelId(97515L)
.setTotalQuantity(NumberUtils.INTEGER_ONE)
.setCalculatedQuantity(NumberUtils.INTEGER_ZERO)
.setProgress(BigDecimal.ZERO)
.setStatus(true)
.setMessage(StringUtils.EMPTY);
getSalaryAcctProgressService(user).initProgress(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth(), initProgress);
log.info("开始核算,当前操作人为:{}", currentUserName);
2022-06-06 19:08:39 +08:00
doAccounting(param, employeeId, tenantKey, currentUserName);
2022-04-14 11:54:16 +08:00
}
2022-06-06 19:08:39 +08:00
public void doAccounting(AccountParam param, Long employeeId, String tenantKey, String currentUserName) {
log.info("核算时间:{}, 核算月份:{}, 个税扣缴义务人:{}, 是否首次核算:{}", new Date(), param.getBillMonth(), param.getPaymentOrganization(), param.isFlag());
2022-04-14 11:54:16 +08:00
try {
List<Long> ids;
List<Long> validIds = new ArrayList<>();
2022-04-14 11:54:16 +08:00
if (CollectionUtils.isEmpty(param.getIds())) {
2022-06-08 17:52:10 +08:00
// 需要分权的情况
// if(getTaxAgentService().isOpenDevolution()) {
List<Long> empIds = getInsuranceAccountDetailMapper().selectEmpByPaymentOrg(param.getPaymentOrganization());
// 获取薪资核算人员规则
SalarySysConfPO salaryAcctEmployeeRule = getSalarySysConfService(user).getOneByCode(SalarySysConstant.SALARY_ACCT_EMPLOYEE_RULE);
List<String> status = new ArrayList<>();
if(Objects.isNull(salaryAcctEmployeeRule) || StringUtils.equals(salaryAcctEmployeeRule.getConfValue(), SalaryAcctEmployeeRuleEnum.BYPAYENDTIME.getValue()) ){
// 包含停缴
status = Arrays.asList(EmployeeStatusEnum.PAYING.getValue(),EmployeeStatusEnum.STAY_DEL.getValue(),
EmployeeStatusEnum.STOP_PAYMENT_FROM_DEL.getValue());
}else{
status = Arrays.asList(EmployeeStatusEnum.PAYING.getValue(),EmployeeStatusEnum.STAY_DEL.getValue());
}
List<String> finalStatus = status;
//过滤出需要核算的人员即福利档案基础信息表中runStatus为正在缴纳和待减员的人员
List<InsuranceArchivesBaseInfoPO> baseInfoPOList = getInsuranceBaseInfoMapper().listAll();
List<Long> canAccountIds = baseInfoPOList.stream()
.filter(f->f.getPaymentOrganization().equals(param.getPaymentOrganization())
&& (finalStatus.contains(f.getRunStatus()) ))
.map(InsuranceArchivesBaseInfoPO::getEmployeeId)
.collect(Collectors.toList());
//20231122逻辑优化过滤出不在起始缴纳月和最后缴纳月区间的人员
List<Long> empIdsInPayMonthRange = listCanPayEmpIds(param.getPaymentOrganization(), param.getBillMonth());
empIds = empIds.stream().filter(f->canAccountIds.contains(f) && empIdsInPayMonthRange.contains(f)).collect(Collectors.toList());
//过滤不在扣缴义务人下的数据
2022-08-04 09:55:10 +08:00
// Collection<Long> employeeIdsInTaxAgent = getTaxAgentService().listEmployeeIdsInTaxAgent(param.getPaymentOrganization());
// empIds = empIds.stream().filter(employeeIdsInTaxAgent::contains).collect(Collectors.toList());
List<InsuranceArchivesSocialSchemePO> socials = siArchivesBiz.getSocialByEmployeeIds(empIds);
//过滤出目标个税扣缴义务人相关信息
socials = socials.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList());
2022-07-21 17:28:47 +08:00
List<Long> emp1 = socials.stream()
.filter(s -> !(StringUtils.isBlank(s.getSocialEndTime()) && StringUtils.isBlank(s.getSocialStartTime())) &&
(StringUtils.isBlank(s.getSocialEndTime()) || (SalaryDateUtil.stringToDate(s.getSocialEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getSocialEndTime() + "-01")))) )
.map(InsuranceArchivesSocialSchemePO::getEmployeeId)
.collect(Collectors.toList());
List<InsuranceArchivesFundSchemePO> funds = siArchivesBiz.getFundByEmployeeIds(empIds);
//过滤出目标个税扣缴义务人相关信息
funds = funds.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList());
2022-07-21 17:28:47 +08:00
List<Long> emp2 = funds.stream()
.filter(s -> !(StringUtils.isBlank(s.getFundStartTime()) && StringUtils.isBlank(s.getFundEndTime())) &&
(StringUtils.isBlank(s.getFundEndTime()) || (SalaryDateUtil.stringToDate(s.getFundEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getFundEndTime() + "-01")))))
.map(InsuranceArchivesFundSchemePO::getEmployeeId)
.collect(Collectors.toList());
List<InsuranceArchivesOtherSchemePO> others = siArchivesBiz.getOtherByEmployeeIds(empIds);
//过滤出目标个税扣缴义务人相关信息
others = others.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList());
2022-07-21 17:28:47 +08:00
List<Long> emp3 = others.stream()
.filter(s -> !(StringUtils.isBlank(s.getOtherStartTime()) && StringUtils.isBlank(s.getOtherEndTime())) &&
(StringUtils.isBlank(s.getOtherEndTime()) || (SalaryDateUtil.stringToDate(s.getOtherEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getOtherEndTime() + "-01")))))
.map(InsuranceArchivesOtherSchemePO::getEmployeeId)
.collect(Collectors.toList());
validIds.addAll(emp1);
validIds.addAll(emp2);
validIds.addAll(emp3);
List<Long> finalValidIds = validIds.stream().distinct().collect(Collectors.toList());
ids = empIds.stream().filter(finalValidIds::contains).collect(Collectors.toList());
// } else {
// ids = getInsuranceAccountDetailMapper().selectAccountIds(SalaryDateUtil.getMonthBegin(param.getBillMonth()), null);
// }
2022-04-14 11:54:16 +08:00
} else {
ids = param.getIds();
}
if (CollectionUtils.isEmpty(ids)) {
getSalaryAcctProgressService(user).finish(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth(), true);
// getSalaryAcctProgressService(user).fail(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth(), SalaryI18nUtil.getI18nLabel( 100468, "无需要核算的人员"));
2022-04-14 11:54:16 +08:00
return;
}
// SalaryAcctProgressDTO salaryAcctProgressDTO = new SalaryAcctProgressDTO(SalaryI18nUtil.getI18nLabel(97515, "核算中"), 97515L, ids.size(), 0,
// BigDecimal.ZERO, true, "", true);
2022-04-14 11:54:16 +08:00
//salaryAcctProgressService.initProgress(tenantKey + param.getBillMonth(), salaryAcctProgressDTO, employeeId, tenantKey);
// 初始化进度
2023-06-06 10:30:49 +08:00
ProgressDTO initProgress = new ProgressDTO()
.setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中"))
.setTitleLabelId(97515L)
.setTotalQuantity(ids.size())
.setCalculatedQuantity(NumberUtils.INTEGER_ZERO)
.setProgress(BigDecimal.ZERO)
.setStatus(true)
.setMessage(StringUtils.EMPTY);
getSalaryAcctProgressService(user).initProgress(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth(), initProgress);
2022-04-14 11:54:16 +08:00
/* List<List<Long>> partition = Lists.partition(ids, 100);
CountDownLatch countDownLatch = new CountDownLatch(partition.size());
BlockingDeque<Boolean> results = new LinkedBlockingDeque<>(partition.size());*/
log.info("开始生成福利核算数据,待处理人员数量:{}", ids.size());
2022-06-08 17:52:10 +08:00
commonAccount(/*countDownLatch, results, */param.getBillMonth(), ids, employeeId, tenantKey, param.getPaymentOrganization());
log.info("福利核算数据生成完毕,开始数据处理");
2022-04-14 11:54:16 +08:00
/* for (List<Long> batchIds : partition) {
taskExecutor.execute(() -> {
commonAccount(countDownLatch, results, param.getBillMonth(), batchIds, simpleEmployee);
});
}
countDownLatch.await();
boolean allSuccess = results.stream().allMatch(Boolean::booleanValue);*/
/* if (allSuccess) {*/
2022-06-06 19:08:39 +08:00
handleData(ids, param, employeeId, tenantKey, currentUserName);
log.info("福利核算数据处理完毕!");
2022-04-14 11:54:16 +08:00
/*}*/
List<List<Long>> partition = Lists.partition((List<Long>) ids, 100);
partition.forEach(part -> {
getSIAccountDetailTempMapper().batchDelByEmpIdsAndMonthAndPayOrg(part, param.getBillMonth(), param.getPaymentOrganization());
});
log.info("更新福利核算进度······");
getSalaryAcctProgressService(user).finish(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth(), true);
log.info("福利核算进度完成!");
2022-04-14 11:54:16 +08:00
} catch (Exception e) {
2022-05-25 13:23:02 +08:00
log.error("account run fail", e);
getSalaryAcctProgressService(user).fail(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth(), SalaryI18nUtil.getI18nLabel(99642, "福利核算出错") + ": " + e.getMessage());
List<InsuranceAccountBatchPO> list = Lists.newArrayList(getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), param.getPaymentOrganization()));
2022-04-14 11:54:16 +08:00
if (CollectionUtils.isNotEmpty(list)) {
list.stream().forEach(f -> {
getInsuranceAccountBatchMapper().deleteById(f.getId());
2022-04-14 11:54:16 +08:00
});
}
//薪资核算进度暂未实现
//salaryAcctProgressService.del(tenantKey + param.getBillMonth(), employeeId, tenantKey);
//logger.error("welfare account error:{}", e.getMessage(), e);
}
}
/**
* 根据个税扣缴义务人和账单月获取三类福利档案中符合缴纳开始结束月区间的人员id
* @param paymentOrganization
* @param billMonth
* @return
*/
public List<Long> listCanPayEmpIds(Long paymentOrganization, String billMonth) {
List<Long> listCanPayEmpIds = new ArrayList<>();
//社保档案中可进行缴纳的人员
List<Long> socialCanPayEmpIds = getSocialSchemeMapper().listCanPayEmpIds(paymentOrganization, billMonth);
//公积金档案中可进行缴纳的人员
List<Long> fundCanPayEmpIds = getFundSchemeMapper().listCanPayEmpIds(paymentOrganization, billMonth);
//其他福利档案中可进行缴纳的人员
List<Long> otherCanPayEmpIds = getOtherSchemeMapper().listCanPayEmpIds(paymentOrganization, billMonth);
if (socialCanPayEmpIds != null && socialCanPayEmpIds.size() > 0) {
listCanPayEmpIds.addAll(socialCanPayEmpIds);
}
if (fundCanPayEmpIds != null && fundCanPayEmpIds.size() > 0) {
listCanPayEmpIds.addAll(fundCanPayEmpIds);
}
if (otherCanPayEmpIds != null && otherCanPayEmpIds.size() > 0) {
listCanPayEmpIds.addAll(otherCanPayEmpIds);
}
//去重
listCanPayEmpIds = listCanPayEmpIds.stream().distinct().collect(Collectors.toList());
return listCanPayEmpIds;
}
2022-04-14 11:54:16 +08:00
2022-06-08 17:52:10 +08:00
public void commonAccount(/*CountDownLatch countDownLatch, BlockingDeque<Boolean> results,*/ String billMonth, List<Long> ids, Long employeeId, String tenantKey, Long paymentOrganization) {
2022-04-14 11:54:16 +08:00
/* try {*/
SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
Map<Long, InsuranceArchivesAccountPO> insuranceArchivesAccountPOS = siArchivesBiz.buildBatchAccount(ids, paymentOrganization);
2022-04-14 11:54:16 +08:00
List<InsuranceAccountDetailTempPO> list = new ArrayList<>();
int count = 0;
for (Map.Entry<Long, InsuranceArchivesAccountPO> entry : insuranceArchivesAccountPOS.entrySet()) {
Long k = entry.getKey();
InsuranceArchivesAccountPO v = entry.getValue();
InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO();
insuranceAccountDetailPO.setBillMonth(billMonth);
insuranceAccountDetailPO.setBillStatus(BillStatusEnum.NOT_ARCHIVED.getValue());
insuranceAccountDetailPO.setCreator(employeeId);
insuranceAccountDetailPO.setCreateTime(new Date());
insuranceAccountDetailPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue());
insuranceAccountDetailPO.setEmployeeId(k);
insuranceAccountDetailPO.setUpdateTime(new Date());
insuranceAccountDetailPO.setPaymentStatus(PaymentStatusEnum.COMMON.getValue());
insuranceAccountDetailPO.setResourceFrom(ResourceFromEnum.SYSTEM.getValue());
insuranceAccountDetailPO.setTenantKey(tenantKey);
2022-06-08 17:52:10 +08:00
insuranceAccountDetailPO.setPaymentOrganization(paymentOrganization);
2022-04-14 11:54:16 +08:00
//核算社保
accountSocial(insuranceAccountDetailPO, v, billMonth, tenantKey);
2022-04-14 11:54:16 +08:00
//核算公积金
accountFund(insuranceAccountDetailPO, v, billMonth, tenantKey);
2022-04-14 11:54:16 +08:00
//核算其他福利
accountOther(insuranceAccountDetailPO, v, billMonth, tenantKey);
2022-04-14 11:54:16 +08:00
//计算合计
account(insuranceAccountDetailPO);
//临时表PO
InsuranceAccountDetailTempPO insuranceAccountDetailTempPO = new InsuranceAccountDetailTempPO();
BeanUtils.copyProperties(insuranceAccountDetailPO, insuranceAccountDetailTempPO);
list.add(insuranceAccountDetailTempPO);
count++;
2022-04-14 11:54:16 +08:00
if (count % 50 == 0 || count >= ids.size()) {
//salaryAcctProgressService.getAndAddCalculatedQty(tenantKey + billMonth, count >= ids.size() ? count % 50 : 50);
if (count >= ids.size()) {
getSalaryAcctProgressService(user).updateProgress(SalaryCacheKey.ACCT_PROGRESS + billMonth, BigDecimal.valueOf(0.99), false);
log.info("更新福利核算进度,当前进度为:{}", getSalaryAcctProgressService(user).getProgress(SalaryCacheKey.ACCT_PROGRESS + billMonth));
} else {
getSalaryAcctProgressService(user).getAndAddCalculatedQty(SalaryCacheKey.ACCT_PROGRESS + billMonth, count >= ids.size() ? count % 50 : 50);
log.info("更新福利核算进度,当前进度为:{}", getSalaryAcctProgressService(user).getProgress(SalaryCacheKey.ACCT_PROGRESS + billMonth));
}
2022-04-14 11:54:16 +08:00
}
2022-04-14 11:54:16 +08:00
}
//临时表入库前先对(可能存在的)历史数据进行删除
List<List<Long>> partition = Lists.partition((List<Long>) ids, 100);
partition.forEach(part -> {
getSIAccountDetailTempMapper().batchDelByEmpIdsAndMonthAndPayOrg(part, billMonth, paymentOrganization);
});
//临时表数据入库
2022-04-14 11:54:16 +08:00
if (CollectionUtils.isNotEmpty(list)) {
encryptUtil.encryptList(list, InsuranceAccountDetailTempPO.class);
2022-05-25 13:23:02 +08:00
List<List<InsuranceAccountDetailTempPO>> lists = splitList(list, 40);
lists.forEach(subList -> {
getSIAccountDetailTempMapper().batchSaveAccountTempDetails(subList);
2022-05-25 13:23:02 +08:00
});
2022-04-14 11:54:16 +08:00
}
/* } catch (Exception e) {
logger.error("福利核算失败:{}", e.getMessage(), e);
results.add(false);
} finally {
countDownLatch.countDown();
}*/
}
2022-06-06 19:08:39 +08:00
private List<List<InsuranceAccountDetailTempPO>> splitList(List<InsuranceAccountDetailTempPO> list, int groupSize) {
2022-05-25 13:23:02 +08:00
int length = list.size();
// 计算可以分成多少组
2022-06-06 19:08:39 +08:00
int num = (length + groupSize - 1) / groupSize;
2022-05-25 13:23:02 +08:00
List<List<InsuranceAccountDetailTempPO>> newList = new ArrayList<>(num);
for (int i = 0; i < num; i++) {
// 开始位置
int fromIndex = i * groupSize;
// 结束位置
2022-06-06 19:08:39 +08:00
int toIndex = (i + 1) * groupSize < length ? (i + 1) * groupSize : length;
newList.add(list.subList(fromIndex, toIndex));
2022-05-25 13:23:02 +08:00
}
2022-06-06 19:08:39 +08:00
return newList;
2022-05-25 13:23:02 +08:00
}
2022-04-14 11:54:16 +08:00
2022-06-06 19:08:39 +08:00
private void handleData(List<Long> ids, AccountParam param, Long employeeId, String tenantKey, String currentUserName) {
2022-04-14 11:54:16 +08:00
//事务后续处理
//TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
2022-06-10 17:15:19 +08:00
String billMonth = param.getBillMonth();
2022-04-14 11:54:16 +08:00
try {
// List<InsuranceAccountDetailTempPO> list = getSIAccountDetailTempMapper().getListByEmployeeIdsAndBillMonth(ids, billMonth, param.getPaymentOrganization());
List<InsuranceAccountDetailTempPO> list = new ArrayList<>();
List<List<Long>> partitionDetailTempInfo = Lists.partition((List<Long>) ids, 100);
partitionDetailTempInfo.forEach(part -> list.addAll(
getSIAccountDetailTempMapper().getListByEmployeeIdsAndBillMonth(part, billMonth, param.getPaymentOrganization())));
encryptUtil.decryptList(list, InsuranceAccountDetailTempPO.class);
Integer paymentStatus = 0;
log.info("核算明细临时表 hrsa_bill_detail_temp待处理数量{}", list.size());
List<List<Long>> partitionIds = Lists.partition((List<Long>) ids, 100);
log.info("bill_detail入库前删除数据数量{}", ids.size());
for (List<Long> part : partitionIds) {
getInsuranceAccountDetailMapper().batchDelAccountDetails(part, billMonth, param.getPaymentOrganization(), paymentStatus);
//删除账单月份+个税扣缴义务人+人员id下的调差数据
getInsuranceCompensationMapper().deleteByBillMonthPayOrgEmpIds(InsuranceCompensationPO.builder()
.billMonth(billMonth)
.paymentOrganization(param.getPaymentOrganization())
.employeeIds(part)
.build());
}
//生成bill_detail入库数据
2022-04-14 11:54:16 +08:00
List<InsuranceAccountDetailPO> collect = list.stream().map(item -> {
InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO();
BeanUtils.copyProperties(item, insuranceAccountDetailPO);
return insuranceAccountDetailPO;
}).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
log.info("bill_detail入库数据数量{}", collect.size());
2022-04-14 11:54:16 +08:00
batchSaveAccountInspectDetail(collect, billMonth, tenantKey);
encryptUtil.encryptList(collect, InsuranceAccountDetailPO.class);
2022-05-25 13:23:02 +08:00
List<List<InsuranceAccountDetailPO>> lists = splitDetailList(collect, 20);
lists.forEach(subList -> {
getInsuranceAccountDetailMapper().batchSaveAccountDetails(subList);
2022-05-25 13:23:02 +08:00
});
2022-06-06 19:08:39 +08:00
updateBatchAccount(param, employeeId, tenantKey, currentUserName);
2022-04-14 11:54:16 +08:00
}
//transactionManager.commit(status);
} catch (Exception e) {
log.error("福利核算数据处理失败", e);
getSalaryAcctProgressService(user).fail(SalaryCacheKey.ACCT_PROGRESS + param.getBillMonth(), SalaryI18nUtil.getI18nLabel(99642, "福利核算出错") + ": " + e.getMessage());
2022-04-14 11:54:16 +08:00
//transactionManager.rollback(status);
throw e;
}
}
2022-05-25 13:23:02 +08:00
2022-04-14 11:54:16 +08:00
public InsuranceAccountDetailPO account(InsuranceAccountDetailPO insuranceAccountDetailPO) {
//个人合计
BigDecimal socialPerson =
StringUtils.isBlank(insuranceAccountDetailPO.getSocialPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getSocialPerSum());
BigDecimal fundPerson =
StringUtils.isBlank(insuranceAccountDetailPO.getFundPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getFundPerSum());
BigDecimal otherPerson =
StringUtils.isBlank(insuranceAccountDetailPO.getOtherPerSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getOtherPerSum());
BigDecimal perSum = socialPerson.add(fundPerson).add(otherPerson);
insuranceAccountDetailPO.setPerSum(perSum.toPlainString());
//单位合计
BigDecimal socialCom =
StringUtils.isBlank(insuranceAccountDetailPO.getSocialComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getSocialComSum());
BigDecimal fundCom = StringUtils.isBlank(insuranceAccountDetailPO.getFundComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getFundComSum());
BigDecimal otherCom =
StringUtils.isBlank(insuranceAccountDetailPO.getOtherComSum()) ? new BigDecimal("0") : new BigDecimal(insuranceAccountDetailPO.getOtherComSum());
BigDecimal comSum = socialCom.add(fundCom).add(otherCom);
insuranceAccountDetailPO.setComSum(comSum.toPlainString());
//社保合计
insuranceAccountDetailPO.setSocialSum(socialPerson.add(socialCom).toPlainString());
//公积金合计
insuranceAccountDetailPO.setFundSum(fundPerson.add(fundCom).toPlainString());
//其他福利合计
insuranceAccountDetailPO.setOtherSum(otherPerson.add(otherCom).toPlainString());
//合计
insuranceAccountDetailPO.setTotal(perSum.add(comSum).toPlainString());
return insuranceAccountDetailPO;
}
public InsuranceAccountDetailPO accountOther(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String billMonth, String tenantKey) {
2022-04-14 11:54:16 +08:00
if (accountPO.getOther() != null) {
InsuranceArchivesOtherSchemePO otherPO = accountPO.getOther();
insuranceAccountDetailPO.setOtherPayOrg(otherPO.getPaymentOrganization());
insuranceAccountDetailPO.setOtherSchemeId(otherPO.getOtherSchemeId());
insuranceAccountDetailPO.setOtherPaymentBaseString(otherPO.getOtherPaymentBaseString());
//判断是否在起始缴纳月和最后缴纳月之间
Boolean inDataRange = SalaryDateUtil.monthInRange(insuranceAccountDetailPO.getBillMonth(), otherPO.getOtherStartTime(), otherPO.getOtherEndTime());
if ((Objects.equals(NonPaymentEnum.YES.getValue(), otherPO.getNonPayment()) || otherPO.getNonPayment() == null) && otherPO.getOtherSchemeId() != null && inDataRange) {
List<InsuranceSchemeDetailPO> detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(otherPO.getOtherSchemeId());
encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class);
2022-04-14 11:54:16 +08:00
//方案中包含的需要缴纳其他的个人福利
int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1;
2022-04-14 11:54:16 +08:00
Map<Long, InsuranceSchemeDetailPO> otherPerson = detailPOS.stream()
.filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue())
&& (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1"))))
2022-04-14 11:54:16 +08:00
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesPerson = JSON.parseObject(otherPO.getOtherPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算其他的福利id 个人
List<Long> needArchivesPerson = new ArrayList<>();
if (archivesPerson != null) {
2022-07-21 17:28:47 +08:00
archivesPerson.forEach((id, value) -> {
if (otherPerson.containsKey(Long.valueOf(id))) {
needArchivesPerson.add(Long.valueOf(id));
}
});
}
//避免福利档案的方案未设置基数导致核算时遗漏这些福利项的核算遍历下方案相关福利项并将遗漏的福利项id添加
if(otherPerson.size() > 0) {
otherPerson.forEach((id, object) -> {
if (!needArchivesPerson.contains(id)) {
needArchivesPerson.add(id);
}
});
}
//判断核算周期、核算月、福利起始缴纳月的关系
checkCycleSettingWithStartMonth(otherPerson, billMonth, otherPO.getOtherStartTime());
2022-07-21 17:28:47 +08:00
2022-04-14 11:54:16 +08:00
List<BigDecimal> otherPer = new ArrayList<>();
Map<String, String> otherPerJsonMap = new HashMap<>();
needArchivesPerson.stream().forEach(e -> {
InsuranceSchemeDetailPO po = otherPerson.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal((ObjectUtils.isEmpty(archivesPerson) || StringUtils.isBlank(archivesPerson.get(String.valueOf(e)))) ? "0" : archivesPerson.get(String.valueOf(e)));
2022-04-14 11:54:16 +08:00
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
BigDecimal result = new BigDecimal("0");
if (po.getPaymentCycle() != null && po.getPaymentCycle() == 1) {
int monthValue = 1;
for (int i = monthIndex - 1; i >= 0; i--) {
String cycleValue = po.getCycleSetting().charAt(i) + "";
if (Integer.parseInt(cycleValue) == 1) {
break;
}
monthValue++;
}
if (po.getAccountType() == 1) {
paymentNum = paymentNum.multiply(new BigDecimal(monthValue));
fixedCost = fixedCost.multiply(new BigDecimal(monthValue));
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
} else {
for (int i = 0; i < monthValue; i++) {
result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)));
}
}
} else {
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
}
2022-04-14 11:54:16 +08:00
otherPerJsonMap.put(String.valueOf(e), result.toPlainString());
otherPer.add(result);
});
insuranceAccountDetailPO.setOtherPerJson(JSON.toJSONString(otherPerJsonMap));
BigDecimal otherPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : otherPer) {
otherPerSum = otherPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setOtherPerSum(otherPerSum.toPlainString());
//方案中包含的需要缴纳公积金的单位福利
Map<Long, InsuranceSchemeDetailPO> otherCom = detailPOS.stream()
.filter(
item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue())
&& (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1"))))
2022-04-14 11:54:16 +08:00
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesCom = JSON.parseObject(otherPO.getOtherPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算其他的福利id 单位
List<Long> needArchivesCom = new ArrayList<>();
if (archivesCom != null) {
2022-07-21 17:28:47 +08:00
archivesCom.forEach((id, value) -> {
if (otherCom.containsKey(Long.valueOf(id))) {
needArchivesCom.add(Long.valueOf(id));
}
});
}
//避免福利档案的方案未设置基数导致核算时遗漏这些福利项的核算遍历下方案相关福利项并将遗漏的福利项id添加
if(otherCom.size() > 0) {
otherCom.forEach((id, object) -> {
if (!needArchivesCom.contains(id)) {
needArchivesCom.add(id);
}
});
}
//判断核算周期、核算月、福利起始缴纳月的关系
checkCycleSettingWithStartMonth(otherCom, billMonth, otherPO.getOtherStartTime());
2022-07-21 17:28:47 +08:00
2022-04-14 11:54:16 +08:00
List<BigDecimal> otherComList = new ArrayList<>();
Map<String, String> otherComJsonMap = new HashMap<>();
needArchivesCom.stream().forEach(e -> {
InsuranceSchemeDetailPO po = otherCom.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal((ObjectUtils.isEmpty(archivesCom) || StringUtils.isBlank(archivesCom.get(String.valueOf(e)))) ? "0" : archivesCom.get(String.valueOf(e)));
2022-04-14 11:54:16 +08:00
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
BigDecimal result = new BigDecimal("0");
if (Objects.equals(po.getPaymentCycle(), 1)) {
int monthValue = 1;
for (int i = monthIndex - 1; i >= 0; i--) {
String cycleValue = po.getCycleSetting().charAt(i) + "";
if (Integer.parseInt(cycleValue) == 1) {
break;
}
monthValue++;
}
if (po.getAccountType() == 1) {
paymentNum = paymentNum.multiply(new BigDecimal(monthValue));
fixedCost = fixedCost.multiply(new BigDecimal(monthValue));
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
} else {
for (int i = 0; i < monthValue; i++) {
result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)));
}
}
} else {
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
}
2022-04-14 11:54:16 +08:00
otherComJsonMap.put(String.valueOf(e), result.toPlainString());
otherComList.add(result);
});
insuranceAccountDetailPO.setOtherComJson(JSON.toJSONString(otherComJsonMap));
BigDecimal otherComSum = new BigDecimal("0");
for (BigDecimal bigDecimal : otherComList) {
otherComSum = otherComSum.add(bigDecimal);
}
insuranceAccountDetailPO.setOtherComSum(otherComSum.toPlainString());
}
}
return insuranceAccountDetailPO;
}
public InsuranceAccountDetailPO accountFund(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String billMonth, String tenantKey) {
2022-04-14 11:54:16 +08:00
if (accountPO.getFund() != null) {
InsuranceArchivesFundSchemePO fundPO = accountPO.getFund();
insuranceAccountDetailPO.setFundPayOrg(fundPO.getPaymentOrganization());
insuranceAccountDetailPO.setFundAccount(fundPO.getFundAccount());
insuranceAccountDetailPO.setSupplementFundAccount(fundPO.getSupplementFundAccount());
insuranceAccountDetailPO.setFundSchemeId(fundPO.getFundSchemeId());
insuranceAccountDetailPO.setFundPaymentBaseString(fundPO.getFundPaymentBaseString());
//判断是否在起始缴纳月和最后缴纳月之间
Boolean inDataRange = SalaryDateUtil.monthInRange(insuranceAccountDetailPO.getBillMonth(), fundPO.getFundStartTime(), fundPO.getFundEndTime());
if ((NonPaymentEnum.YES.getValue() == fundPO.getNonPayment() || fundPO.getNonPayment() == null) && fundPO.getFundSchemeId() != null && inDataRange) {
List<InsuranceSchemeDetailPO> detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(fundPO.getFundSchemeId());
encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class);
2022-04-14 11:54:16 +08:00
//方案中包含的需要缴纳社保的个人福利
int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1;
2022-04-14 11:54:16 +08:00
Map<Long, InsuranceSchemeDetailPO> fundperson = detailPOS.stream()
.filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue())
&& (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1"))))
2022-04-14 11:54:16 +08:00
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesPerson = JSON.parseObject(fundPO.getFundPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算公积金的福利id 个人
List<Long> needArchivesPerson = new ArrayList<>();
if (archivesPerson != null) {
2022-07-21 17:28:47 +08:00
archivesPerson.forEach((id, value) -> {
if (fundperson.containsKey(Long.valueOf(id))) {
needArchivesPerson.add(Long.valueOf(id));
}
});
}
//避免福利档案的方案未设置基数导致核算时遗漏这些福利项的核算遍历下方案相关福利项并将遗漏的福利项id添加
if(fundperson.size() > 0) {
fundperson.forEach((id, object) -> {
if (!needArchivesPerson.contains(id)) {
needArchivesPerson.add(id);
}
});
}
//判断核算周期、核算月、福利起始缴纳月的关系
checkCycleSettingWithStartMonth(fundperson, billMonth, fundPO.getFundStartTime());
2022-07-21 17:28:47 +08:00
2022-04-14 11:54:16 +08:00
List<BigDecimal> fundPer = new ArrayList<>();
Map<String, String> fundPerJsonMap = new HashMap<>();
needArchivesPerson.stream().forEach(e -> {
InsuranceSchemeDetailPO po = fundperson.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal((ObjectUtils.isEmpty(archivesPerson) || StringUtils.isBlank(archivesPerson.get(String.valueOf(e)))) ? "0" : archivesPerson.get(String.valueOf(e)));
2022-04-14 11:54:16 +08:00
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
BigDecimal result = new BigDecimal("0");
if (Objects.equals(po.getPaymentCycle(), 1)) {
int monthValue = 1;
for (int i = monthIndex - 1; i >= 0; i--) {
String cycleValue = po.getCycleSetting().charAt(i) + "";
if (Integer.parseInt(cycleValue) == 1) {
break;
}
monthValue++;
}
if (po.getAccountType() == 1) {
paymentNum = paymentNum.multiply(new BigDecimal(monthValue));
fixedCost = fixedCost.multiply(new BigDecimal(monthValue));
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
} else {
for (int i = 0; i < monthValue; i++) {
result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)));
}
}
} else {
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
}
2022-04-14 11:54:16 +08:00
fundPerJsonMap.put(String.valueOf(e), result.toPlainString());
fundPer.add(result);
});
insuranceAccountDetailPO.setFundPerJson(JSON.toJSONString(fundPerJsonMap));
BigDecimal funPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : fundPer) {
funPerSum = funPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setFundPerSum(funPerSum.toPlainString());
//方案中包含的需要缴纳公积金的单位福利
Map<Long, InsuranceSchemeDetailPO> fundCom = detailPOS.stream()
.filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue())
&& (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1"))))
2022-04-14 11:54:16 +08:00
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesCom = JSON.parseObject(fundPO.getFundPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算公积金的福利id 单位
List<Long> needArchivesCom = new ArrayList<>();
if (archivesCom != null) {
2022-07-21 17:28:47 +08:00
archivesCom.forEach((id, value) -> {
if (fundCom.containsKey(Long.valueOf(id))) {
needArchivesCom.add(Long.valueOf(id));
}
});
}
//避免福利档案的方案未设置基数导致核算时遗漏这些福利项的核算遍历下方案相关福利项并将遗漏的福利项id添加
if(fundCom.size() > 0) {
fundCom.forEach((id, object) -> {
if (!needArchivesCom.contains(id)) {
needArchivesCom.add(id);
}
});
}
//判断核算周期、核算月、福利起始缴纳月的关系
checkCycleSettingWithStartMonth(fundCom, billMonth, fundPO.getFundStartTime());
2022-07-21 17:28:47 +08:00
2022-04-14 11:54:16 +08:00
List<BigDecimal> fundComList = new ArrayList<>();
Map<String, String> fundComJsonMap = new HashMap<>();
needArchivesCom.stream().forEach(e -> {
InsuranceSchemeDetailPO po = fundCom.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal((ObjectUtils.isEmpty(archivesCom) || StringUtils.isBlank(archivesCom.get(String.valueOf(e)))) ? "0" : archivesCom.get(String.valueOf(e)));
2022-04-14 11:54:16 +08:00
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
BigDecimal result = new BigDecimal("0");
if (Objects.equals(po.getPaymentCycle(), 1)) {
int monthValue = 1;
for (int i = monthIndex - 1; i >= 0; i--) {
String cycleValue = po.getCycleSetting().charAt(i) + "";
if (Integer.parseInt(cycleValue) == 1) {
break;
}
monthValue++;
}
if (po.getAccountType() == 1) {
paymentNum = paymentNum.multiply(new BigDecimal(monthValue));
fixedCost = fixedCost.multiply(new BigDecimal(monthValue));
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
} else {
for (int i = 0; i < monthValue; i++) {
result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)));
}
}
} else {
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
}
2022-04-14 11:54:16 +08:00
fundComJsonMap.put(String.valueOf(e), result.toPlainString());
fundComList.add(result);
});
insuranceAccountDetailPO.setFundComJson(JSON.toJSONString(fundComJsonMap));
BigDecimal fundComSum = new BigDecimal("0");
for (BigDecimal bigDecimal : fundComList) {
fundComSum = fundComSum.add(bigDecimal);
}
insuranceAccountDetailPO.setFundComSum(fundComSum.toPlainString());
}
}
return insuranceAccountDetailPO;
}
public InsuranceAccountDetailPO accountSocial(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String billMonth, String tenantKey) {
2022-04-14 11:54:16 +08:00
if (accountPO.getSocial() != null) {
InsuranceArchivesSocialSchemePO socialPO = accountPO.getSocial();
insuranceAccountDetailPO.setSocialPayOrg(socialPO.getPaymentOrganization());
insuranceAccountDetailPO.setSocialAccount(socialPO.getSocialAccount());
insuranceAccountDetailPO.setSocialSchemeId(socialPO.getSocialSchemeId());
insuranceAccountDetailPO.setSocialPaymentBaseString(socialPO.getSocialPaymentBaseString());
//判断是否在起始缴纳月和最后缴纳月之间
Boolean inDataRange = SalaryDateUtil.monthInRange(insuranceAccountDetailPO.getBillMonth(), socialPO.getSocialStartTime(), socialPO.getSocialEndTime());
if ((NonPaymentEnum.YES.getValue().equals(socialPO.getNonPayment()) || socialPO.getNonPayment() == null) && socialPO.getSocialSchemeId() != null && inDataRange) {
List<InsuranceSchemeDetailPO> detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(socialPO.getSocialSchemeId());
encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class);
2022-04-14 11:54:16 +08:00
//方案中包含的需要缴纳社保的个人福利
int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1;
2022-04-14 11:54:16 +08:00
Map<Long, InsuranceSchemeDetailPO> schemeperson = detailPOS.stream()
.filter(item ->
Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) &&
Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue()) &&
(item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))
)
2022-04-14 11:54:16 +08:00
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesPerson = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算社保的福利id 个人
List<Long> needArchivesPerson = new ArrayList<>();
if (archivesPerson != null) {
2022-07-21 17:28:47 +08:00
archivesPerson.forEach((id, value) -> {
if (schemeperson.containsKey(Long.valueOf(id))) {
needArchivesPerson.add(Long.valueOf(id));
}
});
}
//避免福利档案的方案未设置基数导致核算时遗漏这些福利项的核算遍历下方案相关福利项并将遗漏的福利项id添加
if(schemeperson.size() > 0) {
schemeperson.forEach((id, object) -> {
if (!needArchivesPerson.contains(id)) {
needArchivesPerson.add(id);
}
});
}
//判断核算周期、核算月、福利起始缴纳月的关系
checkCycleSettingWithStartMonth(schemeperson, billMonth, socialPO.getSocialStartTime());
2022-07-21 17:28:47 +08:00
2022-04-14 11:54:16 +08:00
List<BigDecimal> socialPer = new ArrayList<>();
Map<String, String> socialPerJsonMap = new HashMap<>();
needArchivesPerson.forEach(e -> {
2022-04-14 11:54:16 +08:00
InsuranceSchemeDetailPO po = schemeperson.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal((ObjectUtils.isEmpty(archivesPerson) || StringUtils.isBlank(archivesPerson.get(String.valueOf(e)))) ? "0" : archivesPerson.get(String.valueOf(e)));
2022-04-14 11:54:16 +08:00
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
BigDecimal result = new BigDecimal("0");
if (Objects.equals(po.getPaymentCycle(), 1)) {
int monthValue = 1;
for (int i = monthIndex - 1; i >= 0; i--) {
String cycleValue = po.getCycleSetting().charAt(i) + "";
if (Integer.parseInt(cycleValue) == 1) {
break;
}
monthValue++;
}
if (po.getAccountType() == 1) {
paymentNum = paymentNum.multiply(new BigDecimal(monthValue));
fixedCost = fixedCost.multiply(new BigDecimal(monthValue));
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
} else {
for (int i = 0; i < monthValue; i++) {
result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)));
}
}
} else {
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
}
2022-04-14 11:54:16 +08:00
socialPerJsonMap.put(String.valueOf(e), result.toPlainString());
socialPer.add(result);
});
insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerJsonMap));
BigDecimal socialPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : socialPer) {
socialPerSum = socialPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString());
//方案中包含的需要缴纳社保的单位福利
Map<Long, InsuranceSchemeDetailPO> schemeCom = detailPOS.stream()
.filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue()) &&
(item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1"))))
2022-04-14 11:54:16 +08:00
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesCom = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算社保的福利id 单位
List<Long> needArchivesCom = new ArrayList<>();
if (archivesCom != null) {
2022-07-21 17:28:47 +08:00
archivesCom.forEach((id, value) -> {
if (schemeCom.containsKey(Long.valueOf(id))) {
needArchivesCom.add(Long.valueOf(id));
}
});
}
//避免福利档案的方案未设置基数导致核算时遗漏这些福利项的核算遍历下方案相关福利项并将遗漏的福利项id添加
if(schemeCom.size() > 0) {
schemeCom.forEach((id, object) -> {
if (!needArchivesCom.contains(id)) {
needArchivesCom.add(id);
}
});
2022-07-21 17:28:47 +08:00
}
//判断核算周期、核算月、福利起始缴纳月的关系
checkCycleSettingWithStartMonth(schemeCom, billMonth, socialPO.getSocialStartTime());
2022-07-21 17:28:47 +08:00
2022-04-14 11:54:16 +08:00
List<BigDecimal> socialCom = new ArrayList<>();
Map<String, String> sociaComJsonMap = new HashMap<>();
needArchivesCom.stream().forEach(e -> {
InsuranceSchemeDetailPO po = schemeCom.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal((ObjectUtils.isEmpty(archivesCom) || StringUtils.isBlank(archivesCom.get(String.valueOf(e)))) ? "0" : archivesCom.get(String.valueOf(e)));
2022-04-14 11:54:16 +08:00
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
BigDecimal result = new BigDecimal("0");
if (Objects.equals(po.getPaymentCycle(), 1)) {
int monthValue = 1;
for (int i = monthIndex - 1; i >= 0; i--) {
String cycleValue = po.getCycleSetting().charAt(i) + "";
if (Integer.parseInt(cycleValue) == 1) {
break;
}
monthValue++;
}
if (po.getAccountType() == 1) {
paymentNum = paymentNum.multiply(new BigDecimal(monthValue));
fixedCost = fixedCost.multiply(new BigDecimal(monthValue));
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
} else {
for (int i = 0; i < monthValue; i++) {
result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)));
}
}
} else {
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
}
2022-04-14 11:54:16 +08:00
sociaComJsonMap.put(String.valueOf(e), result.toPlainString());
socialCom.add(result);
});
insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(sociaComJsonMap));
BigDecimal socialComSum = new BigDecimal("0");
for (BigDecimal decimal : socialCom) {
socialComSum = socialComSum.add(decimal);
}
insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString());
}
}
return insuranceAccountDetailPO;
}
/**
* 对于核算月和福利起始缴纳月处于同年时要避免根据周期缴纳福利费用时可能出现的多余费用缴纳情况
* @param schemeDetail 福利方案明细
* @param billMonth 核算月
* @param startMonth 福利起始缴纳月
* @return
*/
public Map<Long, InsuranceSchemeDetailPO> checkCycleSettingWithStartMonth(Map<Long, InsuranceSchemeDetailPO> schemeDetail, String billMonth, String startMonth) {
String billYear = billMonth.substring(0,4);
if (StringUtils.isNotBlank(startMonth) && billYear.equals(startMonth.substring(0,4))) {
int startMonthIndex = Integer.parseInt(startMonth.split("-")[1]) - 1;
schemeDetail.forEach((k, v) -> {
if (v.getPaymentCycle() != null && v.getPaymentCycle().equals(1) && startMonthIndex != 0) {
StringBuilder newCycleSetting = new StringBuilder(v.getCycleSetting());
newCycleSetting.setCharAt(startMonthIndex - 1, '1');
v.setCycleSetting(newCycleSetting.toString());
}
});
}
return schemeDetail;
}
2022-04-14 11:54:16 +08:00
public void batchSaveAccountInspectDetail(List<InsuranceAccountDetailPO> list, String billMonth, String tenantKey) {
List<InsuranceAccountInspectPO> insuranceAccountInspectAllPOS = accountInspect(list, true);
batchDelInspectDetail(insuranceAccountInspectAllPOS);
List<InsuranceAccountInspectPO> insuranceAccountInspectPOS = accountInspect(list, false);
if (CollectionUtils.isNotEmpty(insuranceAccountInspectPOS)) {
batchSaveInspectDetail(insuranceAccountInspectPOS);
}
}
public List<InsuranceAccountInspectPO> accountInspect(List<InsuranceAccountDetailPO> list, boolean isAll) {
List<InsuranceAccountInspectPO> insuranceAccountInspectPOS = new ArrayList<>();
for (InsuranceAccountDetailPO e : list) {
if (isAll || detailCheck(e.getSocialPerJson()) || detailCheck(e.getSocialComJson())
|| detailCheck(e.getFundPerJson()) || detailCheck(e.getFundComJson())
|| detailCheck(e.getOtherPerJson()) || detailCheck(e.getOtherComJson())) {
InsuranceAccountInspectPO insuranceAccountInspectPO = InsuranceAccountInspectPO.builder().build();
insuranceAccountInspectPO.setSupplementaryProjects(e.getSupplementaryProjects());
insuranceAccountInspectPO.setInspectStatus(InspectStatusEnum.IGNORE.getValue());
insuranceAccountInspectPO.setBillMonth(e.getBillMonth());
insuranceAccountInspectPO.setCreator(e.getCreator());
insuranceAccountInspectPO.setCreateTime(new Date());
insuranceAccountInspectPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue());
insuranceAccountInspectPO.setEmployeeId(e.getEmployeeId());
insuranceAccountInspectPO.setPaymentStatus(e.getPaymentStatus());
insuranceAccountInspectPO.setSupplementaryMonth(e.getSupplementaryMonth());
insuranceAccountInspectPO.setTenantKey(e.getTenantKey());
insuranceAccountInspectPO.setUpdateTime(new Date());
insuranceAccountInspectPOS.add(insuranceAccountInspectPO);
}
}
return insuranceAccountInspectPOS;
}
public boolean detailCheck(String baseString) {
if (StringUtils.isEmpty(baseString)) {
return false;
}
Map<String, String> baseStringMap = JSON.parseObject(baseString, new TypeReference<Map<String, String>>() {
});
if (baseStringMap == null || baseStringMap.size() == 0) {
return false;
}
return baseStringMap.values().stream().anyMatch(item -> StringUtils.isEmpty(item) || Pattern.matches("^([0].?[0]*)$", item));
}
public void batchDelInspectDetail(List<InsuranceAccountInspectPO> list) {
List<List<InsuranceAccountInspectPO>> lists = Lists.partition(list, 100);
lists.forEach(getInsuranceAccountInspectMapper()::batchDelInspectDetails);
2022-04-14 11:54:16 +08:00
}
public void batchSaveInspectDetail(List<InsuranceAccountInspectPO> list) {
List<List<InsuranceAccountInspectPO>> lists = Lists.partition(list, 100);
lists.forEach(getInsuranceAccountInspectMapper()::batchSaveInspectDetails);
2022-04-14 11:54:16 +08:00
}
/**
* 跟新台账接口
*
* @param tenantKey 租户key
*/
2022-06-06 19:08:39 +08:00
public void updateBatchAccount(AccountParam param, Long employeeId, String tenantKey, String currentUserName) {
String billMonth = param.getBillMonth();
2022-04-14 11:54:16 +08:00
List<InsuranceAccountDetailPO> insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().selectList(billMonth, param.getPaymentOrganization());
2022-04-14 11:54:16 +08:00
Map<Long, List<InsuranceAccountDetailPO>> map = insuranceAccountDetailPOS.stream().filter(item -> item.getEmployeeId() != null)
.collect(Collectors.groupingBy(InsuranceAccountDetailPO::getEmployeeId));
int socialAccountPerson = 0;
int funcAccountPerson = 0;
int otherAccountPerson = 0;
BigDecimal socialSum = new BigDecimal("0");
BigDecimal fundSum = new BigDecimal("0");
BigDecimal otherSum = new BigDecimal("0");
for (Map.Entry<Long, List<InsuranceAccountDetailPO>> entry : map.entrySet()) {
List<InsuranceAccountDetailPO> v = entry.getValue();
BigDecimal socialTemp = new BigDecimal("0");
BigDecimal fundTemp = new BigDecimal("0");
BigDecimal otherTemp = new BigDecimal("0");
encryptUtil.decryptList(v, InsuranceAccountDetailPO.class);
2022-06-06 18:17:34 +08:00
boolean socialPersonFlag = false;
boolean fundPersonFlag = false;
boolean otherPersonFlag = false;
2022-04-14 11:54:16 +08:00
for (InsuranceAccountDetailPO item : v) {
2022-08-30 09:19:29 +08:00
// 判断社保是否为0
2022-09-22 17:01:21 +08:00
socialPersonFlag = (StringUtils.isBlank(item.getSocialSum()) || SalaryEntityUtil.StringEqZERO(item.getSocialSum()));
2022-06-06 18:17:34 +08:00
BigDecimal socialPerson = socialPersonFlag ? new BigDecimal("0") : new BigDecimal(item.getSocialSum());
2022-09-22 17:01:21 +08:00
fundPersonFlag = (StringUtils.isBlank(item.getFundSum()) || SalaryEntityUtil.StringEqZERO(item.getFundSum()));
2022-06-06 18:17:34 +08:00
BigDecimal fundPerson = fundPersonFlag ? new BigDecimal("0") : new BigDecimal(item.getFundSum());
2022-09-22 17:01:21 +08:00
otherPersonFlag = (StringUtils.isBlank(item.getOtherSum()) || SalaryEntityUtil.StringEqZERO(item.getOtherSum()));
2022-06-06 18:17:34 +08:00
BigDecimal otherPerson = otherPersonFlag ? new BigDecimal("0") : new BigDecimal(item.getOtherSum());
2022-04-14 11:54:16 +08:00
socialTemp = socialTemp.add(socialPerson);
fundTemp = fundTemp.add(fundPerson);
otherTemp = otherTemp.add(otherPerson);
if (!socialPersonFlag && !item.getPaymentStatus().equals(PaymentStatusEnum.BALANCE.getValue())) {
socialAccountPerson += 1;
}
if (!fundPersonFlag && !item.getPaymentStatus().equals(PaymentStatusEnum.BALANCE.getValue())) {
funcAccountPerson += 1;
}
if (!otherPersonFlag && !item.getPaymentStatus().equals(PaymentStatusEnum.BALANCE.getValue())) {
otherAccountPerson += 1;
}
2022-04-14 11:54:16 +08:00
}
// if (!socialPersonFlag) {
// socialSum = socialSum.add(socialTemp);
// }
// if (!fundPersonFlag) {
// fundSum = fundSum.add(fundTemp);
// }
// if (!otherPersonFlag) {
// otherSum = otherSum.add(otherTemp);
// }
if (!"0".equals(socialTemp.toPlainString())) {
2022-04-14 11:54:16 +08:00
socialSum = socialSum.add(socialTemp);
}
if (!"0".equals(fundTemp.toPlainString())) {
2022-04-14 11:54:16 +08:00
fundSum = fundSum.add(fundTemp);
}
if (!"0".equals(otherTemp.toPlainString())) {
2022-04-14 11:54:16 +08:00
otherSum = otherSum.add(otherTemp);
}
}
InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(billMonth, param.getPaymentOrganization());
encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class);
2022-04-22 18:05:19 +08:00
2022-04-22 15:17:31 +08:00
insuranceAccountBatchPO.setAccountant(currentUserName);
2022-04-14 11:54:16 +08:00
insuranceAccountBatchPO.setUpdateTime(new Date());
insuranceAccountBatchPO.setSocialPay(socialSum.toPlainString());
insuranceAccountBatchPO.setSocialNum(socialAccountPerson);
insuranceAccountBatchPO.setFundNum(funcAccountPerson);
insuranceAccountBatchPO.setFundPay(fundSum.toPlainString());
insuranceAccountBatchPO.setOtherNum(otherAccountPerson);
insuranceAccountBatchPO.setOtherPay(otherSum.toPlainString());
encryptUtil.encrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class);
getInsuranceAccountBatchMapper().updateById(insuranceAccountBatchPO);
2022-04-14 11:54:16 +08:00
// LoggerContext insuranceSchemeContext = new LoggerContext();
// insuranceSchemeContext.setTargetId(String.valueOf(insuranceAccountBatchPO.getId()));
// insuranceSchemeContext.setTargetName(insuranceAccountBatchPO.getBillMonth());
// insuranceSchemeContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100491, "更新台账"));
// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100491, "更新台账"));
// insuranceSchemeContext.setNewValues(insuranceAccountBatchPO);
// siAccountLoggerTemplate.write(insuranceSchemeContext);
}
2022-06-06 19:08:39 +08:00
public void saveCommonAccount(SaveCommonAccountParam param, Long employeeId, String currentUserName) {
2022-04-15 13:17:25 +08:00
List<Long> collect;
2022-06-06 19:08:39 +08:00
SalaryAssert.notEmpty(param.getIncludes(), SalaryI18nUtil.getI18nLabel(100466, "参数为空"));
SalaryAssert.notNull(param.getBillMonth(), SalaryI18nUtil.getI18nLabel(100467, "账单月为空"));
2022-04-15 13:17:25 +08:00
if (CollectionUtils.isNotEmpty(param.getExcludes())) {
collect = param.getIncludes().stream().filter(item -> !param.getExcludes().contains(item)).collect(Collectors.toList());
} else {
collect = param.getIncludes();
}
2022-06-06 19:08:39 +08:00
SalaryAssert.notEmpty(collect, SalaryI18nUtil.getI18nLabel(99920, "无核算人员"));
2022-04-15 13:17:25 +08:00
AccountParam accountParam = new AccountParam();
accountParam.setBillMonth(param.getBillMonth());
accountParam.setIds(collect);
2022-06-06 19:08:39 +08:00
accounting(accountParam, employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, currentUserName);
2022-04-15 13:17:25 +08:00
}
public void delete(AccountParam param, Long employeeId) {
InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), param.getPaymentOrganization());
encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class);
SalaryAssert.notNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
// if (insuranceAccountBatchPO.getBillStatus().equals(BillStatusEnum.ARCHIVED.getValue())) {
// int num = checkIfBusinessaccounting(insuranceAccountBatchPO);
// //表示已经被核算过不能重新核算
// if (num > 0) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "已被薪酬核算给核算过,无法删除!"));
// }
// }
2022-06-08 17:52:10 +08:00
// if(param.getPaymentOrganization()==null){
// throw new SalaryRunTimeException("个税扣缴义务人为空");
// }
getInsuranceAccountBatchMapper().deleteById(insuranceAccountBatchPO.getId());
getInsuranceAccountDetailMapper().batchDeleteNotFile(param.getBillMonth(), param.getPaymentOrganization());
//删除账单月份+个税扣缴义务人下的调差数据
getInsuranceCompensationMapper().deleteByBillMonthAndPayOrg(param.getBillMonth(), param.getPaymentOrganization());
2022-04-15 13:17:25 +08:00
// LoggerContext insuranceSchemeContext = new LoggerContext();
// insuranceSchemeContext.setTargetId(String.valueOf(insuranceAccountBatchPO.getId()));
// insuranceSchemeContext.setTargetName(insuranceAccountBatchPO.getBillMonth());
// insuranceSchemeContext.setOperateType(OperateTypeEnum.DELETE.getValue());
// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(tenantkey, employeeId, 100464, "删除台账"));
// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantkey, employeeId, 100464, "删除台账"));
// insuranceSchemeContext.setNewValues(insuranceAccountBatchPO);
// siAccountLoggerTemplate.write(insuranceSchemeContext);
}
2022-06-06 19:08:39 +08:00
public void saveSupplementaryAccount(SaveSupplementaryAccountParam param, Long employeeId, String currentUserName) {
2022-04-15 13:17:25 +08:00
if (StringUtils.isBlank(param.getBillMonth()) || CollectionUtils.isEmpty(param.getBillMonthList()) || CollectionUtils.isEmpty(param.getProjects())
|| CollectionUtils.isEmpty(param.getIncludes())) {
2022-06-06 19:08:39 +08:00
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
2022-04-15 13:17:25 +08:00
}
//需要补缴的月份
if (param.getBillMonthList().contains(param.getBillMonth())) {
2022-06-06 19:08:39 +08:00
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100481, "当前月走正常缴纳"));
2022-04-15 13:17:25 +08:00
}
//需要补缴的员工id
List<Long> employeeIds = param.getIncludes();
if (CollectionUtils.isNotEmpty(param.getExcludes())) {
employeeIds = employeeIds.stream().filter(item -> !param.getExcludes().contains(item)).collect(Collectors.toList());
}
//校验补缴人员是否存在福利档案基础信息并且runStatus处于正在缴纳或者待减员
List<InsuranceArchivesBaseInfoPO> insuranceBaseInfoList = getInsuranceBaseInfoMapper().getSocialByPaymentOrganization(param.getPaymentOrganization());
List<Long> finalEmployeeIds = employeeIds;
List<InsuranceArchivesBaseInfoPO> filterList = insuranceBaseInfoList.stream().filter(e -> {
for (Long uId : finalEmployeeIds) {
if (e.getEmployeeId().equals(uId) && (e.getRunStatus().equals(EmployeeStatusEnum.STAY_DEL.getValue()) || e.getRunStatus().equals(EmployeeStatusEnum.PAYING.getValue()))) {
return true;
}
}
return false;
}).collect(Collectors.toList());
if (filterList.size() != employeeIds.size()) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "补缴人员中存在未设置福利档案人员或相关人员不在福利在缴人员中,不可新建补缴信息!"));
}
//20231122逻辑优化过滤出不在起始缴纳月和最后缴纳月区间的人员
List<Long> empIdsInPayMonthRange = listCanPayEmpIds(param.getPaymentOrganization(), param.getBillMonth());
employeeIds = employeeIds.stream().filter(f -> empIdsInPayMonthRange.contains(f)).collect(Collectors.toList());
2022-06-06 19:08:39 +08:00
SalaryAssert.notEmpty(employeeIds, SalaryI18nUtil.getI18nLabel(99920, "无核算人员"));
2022-04-15 13:17:25 +08:00
List<SupplementAccountBaseParam> baseList = new ArrayList<>();
employeeIds.stream().forEach(id -> {
param.getBillMonthList().stream().forEach(month -> {
SupplementAccountBaseParam supplementAccountBaseParam = SupplementAccountBaseParam.builder()
.supplementaryMonth(month)
.employeeId(id)
2022-06-29 14:13:23 +08:00
.paymentOrganization(param.getPaymentOrganization())
2022-04-15 13:17:25 +08:00
.projects(param.getProjects())
.billMonth(param.getBillMonth())
.supplementType(param.getSupplementType())
2022-04-15 13:17:25 +08:00
.build();
if ("2".equals(param.getSupplementType())) {
supplementAccountBaseParam.setSocialPaymentBaseString(param.getSocialPaymentBaseString());
supplementAccountBaseParam.setFundPaymentBaseString(param.getFundPaymentBaseString());
supplementAccountBaseParam.setOtherPaymentBaseString(param.getOtherPaymentBaseString());
} else if("3".equals(param.getSupplementType())) {
supplementAccountBaseParam.setSocialPaymentPerString(param.getSocialPaymentPerString());
supplementAccountBaseParam.setSocialPaymentComString(param.getSocialPaymentComString());
supplementAccountBaseParam.setFundPaymentPerString(param.getFundPaymentPerString());
supplementAccountBaseParam.setFundPaymentComString(param.getFundPaymentComString());
supplementAccountBaseParam.setOtherPaymentPerString(param.getOtherPaymentPerString());
supplementAccountBaseParam.setOtherPaymentComString(param.getOtherPaymentComString());
}
2022-04-15 13:17:25 +08:00
baseList.add(supplementAccountBaseParam);
});
});
//核算开始
accountSupplement(baseList, employeeIds, param.getBillMonth(), employeeId, param.getPaymentOrganization());
2022-06-06 19:08:39 +08:00
updateBatchAccount(AccountParam.builder().billMonth(param.getBillMonth()).paymentOrganization(param.getPaymentOrganization()).build(), employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, currentUserName);
2022-04-15 13:17:25 +08:00
}
/**
* @param baseList 员工id-账单月份-补缴月份单挑-补缴项 集合
* @param employeeIds 需要补缴的员工id
* @return
*/
public String accountSupplement(List<SupplementAccountBaseParam> baseList, List<Long> employeeIds, String billMonth, Long employeeId, Long paymentOrganization) {
2022-04-15 13:17:25 +08:00
//(k,v) k-员工id v-员工对应的福利档案数据
Map<Long, InsuranceArchivesAccountPO> longInsuranceArchivesAccountPOMap = siArchivesBiz.buildBatchAccount(employeeIds, paymentOrganization);
2022-04-15 13:17:25 +08:00
//核算结果集
List<InsuranceAccountDetailPO> pos = new ArrayList<>();
baseList.forEach(baseParam -> {
//判断人员id+账单月份+补缴月份在表中的唯一性
List<InsuranceAccountDetailPO> supplementList = getInsuranceAccountDetailMapper().querySupplementList(baseParam.getBillMonth(), baseParam.getPaymentOrganization(), baseParam.getEmployeeId(), baseParam.getSupplementaryMonth());
if (supplementList.size() > 0) {
throw new SalaryRunTimeException("当前人员和账单月份已存在该补缴月份的数据!无法再次创建!");
}
2022-06-06 19:08:39 +08:00
InsuranceAccountDetailPO insuranceAccountDetailPO = accountSingleEmployeeBill(baseParam, longInsuranceArchivesAccountPOMap.get(baseParam.getEmployeeId()), employeeId);
2022-04-15 13:17:25 +08:00
pos.add(insuranceAccountDetailPO);
});
2022-06-06 19:08:39 +08:00
batchSaveSupplementAccount(pos, billMonth, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
2022-04-15 13:17:25 +08:00
return SalaryI18nUtil.getI18nLabel(100492, "核算完成,数据保存成功");
}
2022-06-06 19:08:39 +08:00
public InsuranceAccountDetailPO accountSingleEmployeeBill(SupplementAccountBaseParam baseParam, InsuranceArchivesAccountPO accountPO, Long employeeId) {
2022-04-15 13:17:25 +08:00
InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO();
List<Integer> projects = baseParam.getProjects();
insuranceAccountDetailPO.setBillMonth(baseParam.getBillMonth());
insuranceAccountDetailPO.setBillStatus(BillStatusEnum.NOT_ARCHIVED.getValue());
insuranceAccountDetailPO.setCreator(employeeId);
insuranceAccountDetailPO.setCreateTime(new Date());
insuranceAccountDetailPO.setUpdateTime(new Date());
insuranceAccountDetailPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue());
insuranceAccountDetailPO.setId(IdGenerator.generate());
insuranceAccountDetailPO.setEmployeeId(baseParam.getEmployeeId());
insuranceAccountDetailPO.setPaymentStatus(PaymentStatusEnum.REPAIR.getValue());
insuranceAccountDetailPO.setSupplementaryMonth(baseParam.getSupplementaryMonth());
2022-06-29 14:13:23 +08:00
insuranceAccountDetailPO.setPaymentOrganization(baseParam.getPaymentOrganization());
2022-04-15 13:17:25 +08:00
insuranceAccountDetailPO.setSupplementaryProjects(
String.join(",",
baseParam.getProjects() == null ? new ArrayList<>() : baseParam.getProjects().stream().map(String::valueOf).collect(Collectors.toList())));
insuranceAccountDetailPO.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
insuranceAccountDetailPO.setResourceFrom(ResourceFromEnum.SYSTEM.getValue());
//缴纳组织=个税扣缴义务人
insuranceAccountDetailPO.setSocialPayOrg(baseParam.getPaymentOrganization());
2022-04-15 13:17:25 +08:00
if (projects.contains(ProjectTypeEnum.ALL.getValue())) {
if ("2".equals(baseParam.getSupplementType())) {
if (accountPO.getSocial() != null) {
accountPO.getSocial().setSocialPaymentBaseString(baseParam.getSocialPaymentBaseString());
}
if (accountPO.getFund() != null) {
accountPO.getFund().setFundPaymentBaseString(baseParam.getFundPaymentBaseString());
}
if (accountPO.getOther() != null) {
accountPO.getOther().setOtherPaymentBaseString(baseParam.getOtherPaymentBaseString());
}
accountSocial(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth());
accountFund(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth());
accountOther(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth());
} else if ("3".equals(baseParam.getSupplementType())) {
accountSocialByData(insuranceAccountDetailPO, baseParam);
accountFundByData(insuranceAccountDetailPO, baseParam);
accountOtherByData(insuranceAccountDetailPO, baseParam);
} else {
accountSocial(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth());
accountFund(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth());
accountOther(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth());
}
2022-04-15 13:17:25 +08:00
return account(insuranceAccountDetailPO);
}
if (projects.contains(ProjectTypeEnum.SOCIAL.getValue())) {
if ("2".equals(baseParam.getSupplementType())) {
if (accountPO.getSocial() != null) {
accountPO.getSocial().setSocialPaymentBaseString(baseParam.getSocialPaymentBaseString());
}
accountSocial(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth());
} else if ("3".equals(baseParam.getSupplementType())) {
accountSocialByData(insuranceAccountDetailPO, baseParam);
} else {
accountSocial(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth());
}
2022-04-15 13:17:25 +08:00
}
if (!projects.contains(ProjectTypeEnum.SOCIAL.getValue())) {
List<Long> ids = new ArrayList<>();
List<ICategoryPO> list = getICategoryMapper().listByDataType(DataTypeEnum.SYSTEM.getValue());
2022-04-15 13:17:25 +08:00
if (projects.contains(ProjectTypeEnum.ENDOWMENT_INSURANCE.getValue())) {
ICategoryPO insuranceCategoryPO = list.stream().filter(item -> SalaryI18nUtil.getI18nLabel(93113, "养老保险").equals(item.getInsuranceName())).findFirst()
.get();
ids.add(insuranceCategoryPO.getId());
}
if (projects.contains(ProjectTypeEnum.MEDICAL_INSURANCE.getValue())) {
ICategoryPO insuranceCategoryPO = list.stream().filter(item -> SalaryI18nUtil.getI18nLabel(93114, "医疗保险").equals(item.getInsuranceName())).findFirst()
.get();
ids.add(insuranceCategoryPO.getId());
}
if ("2".equals(baseParam.getSupplementType())) {
if (accountPO.getSocial() != null) {
accountPO.getSocial().setSocialPaymentBaseString(baseParam.getSocialPaymentBaseString());
}
accountEndowmentInsurance(insuranceAccountDetailPO, accountPO, ids, baseParam.getSupplementaryMonth());
} else if ("3".equals(baseParam.getSupplementType())) {
accountEndowmentInsuranceByData(insuranceAccountDetailPO, baseParam, ids);
} else {
accountEndowmentInsurance(insuranceAccountDetailPO, accountPO, ids, baseParam.getSupplementaryMonth());
}
2022-04-15 13:17:25 +08:00
}
if (projects.contains(ProjectTypeEnum.FUND.getValue())) {
if ("2".equals(baseParam.getSupplementType())) {
if (accountPO.getFund() != null) {
accountPO.getFund().setFundPaymentBaseString(baseParam.getFundPaymentBaseString());
}
accountFund(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth());
} else if ("3".equals(baseParam.getSupplementType())) {
accountFundByData(insuranceAccountDetailPO, baseParam);
} else {
accountFund(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth());
}
2022-04-15 13:17:25 +08:00
}
if (projects.contains(ProjectTypeEnum.OTHER.getValue())) {
if ("2".equals(baseParam.getSupplementType())) {
if (accountPO.getOther() != null) {
accountPO.getOther().setOtherPaymentBaseString(baseParam.getOtherPaymentBaseString());
}
accountOther(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth());
} else if ("3".equals(baseParam.getSupplementType())) {
accountOtherByData(insuranceAccountDetailPO, baseParam);
} else {
accountOther(insuranceAccountDetailPO, accountPO, baseParam.getSupplementaryMonth());
}
2022-04-15 13:17:25 +08:00
}
return account(insuranceAccountDetailPO);
}
public InsuranceAccountDetailPO accountOther(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String billMonth) {
2022-04-15 13:17:25 +08:00
if (accountPO.getOther() != null) {
InsuranceArchivesOtherSchemePO otherPO = accountPO.getOther();
insuranceAccountDetailPO.setOtherPayOrg(otherPO.getPaymentOrganization());
insuranceAccountDetailPO.setOtherSchemeId(otherPO.getOtherSchemeId());
insuranceAccountDetailPO.setOtherPaymentBaseString(otherPO.getOtherPaymentBaseString());
//判断是否在起始缴纳月和最后缴纳月之间
Boolean inDataRange = SalaryDateUtil.monthInRange(billMonth, otherPO.getOtherStartTime(), otherPO.getOtherEndTime());
if ((Objects.equals(NonPaymentEnum.YES.getValue(), otherPO.getNonPayment()) || otherPO.getNonPayment() == null) && otherPO.getOtherSchemeId() != null && inDataRange) {
List<InsuranceSchemeDetailPO> detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(otherPO.getOtherSchemeId());
encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class);
2022-04-15 13:17:25 +08:00
//方案中包含的需要缴纳其他的个人福利
int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1;
2022-04-15 13:17:25 +08:00
Map<Long, InsuranceSchemeDetailPO> otherPerson = detailPOS.stream()
.filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue()) && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1"))))
2022-04-15 13:17:25 +08:00
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesPerson = JSON.parseObject(otherPO.getOtherPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算其他的福利id 个人
List<Long> needArchivesPerson = new ArrayList<>();
if (archivesPerson != null) {
2022-07-21 17:28:47 +08:00
archivesPerson.forEach((id, value) -> {
if (otherPerson.containsKey(Long.valueOf(id))) {
needArchivesPerson.add(Long.valueOf(id));
}
});
}
//判断核算周期、核算月、福利起始缴纳月的关系
checkCycleSettingWithStartMonth(otherPerson, billMonth, otherPO.getOtherStartTime());
2022-07-21 17:28:47 +08:00
2022-04-15 13:17:25 +08:00
List<BigDecimal> otherPer = new ArrayList<>();
Map<String, String> otherPerJsonMap = new HashMap<>();
needArchivesPerson.stream().forEach(e -> {
InsuranceSchemeDetailPO po = otherPerson.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal((ObjectUtils.isEmpty(archivesPerson) || StringUtils.isBlank(archivesPerson.get(String.valueOf(e)))) ? "0" : archivesPerson.get(String.valueOf(e)));
2022-04-15 13:17:25 +08:00
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
BigDecimal result = new BigDecimal("0");
if (po.getPaymentCycle() != null && po.getPaymentCycle() == 1) {
int monthValue = 1;
for (int i = monthIndex - 1; i >= 0; i--) {
String cycleValue = po.getCycleSetting().charAt(i) + "";
if (Integer.parseInt(cycleValue) == 1) {
break;
}
monthValue++;
}
if (po.getAccountType() == 1) {
paymentNum = paymentNum.multiply(new BigDecimal(monthValue));
fixedCost = fixedCost.multiply(new BigDecimal(monthValue));
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
} else {
for (int i = 0; i < monthValue; i++) {
result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)));
}
}
} else {
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
}
2022-04-15 13:17:25 +08:00
otherPerJsonMap.put(String.valueOf(e), result.toPlainString());
otherPer.add(result);
});
insuranceAccountDetailPO.setOtherPerJson(JSON.toJSONString(otherPerJsonMap));
BigDecimal otherPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : otherPer) {
otherPerSum = otherPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setOtherPerSum(otherPerSum.toPlainString());
//方案中包含的需要缴纳公积金的单位福利
Map<Long, InsuranceSchemeDetailPO> otherCom = detailPOS.stream()
.filter(
item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue()) && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1"))))
2022-04-15 13:17:25 +08:00
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesCom = JSON.parseObject(otherPO.getOtherPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算其他的福利id 单位
List<Long> needArchivesCom = new ArrayList<>();
if (archivesCom != null) {
2022-07-21 17:28:47 +08:00
archivesCom.forEach((id, value) -> {
if (otherCom.containsKey(Long.valueOf(id))) {
needArchivesCom.add(Long.valueOf(id));
}
});
}
//判断核算周期、核算月、福利起始缴纳月的关系
checkCycleSettingWithStartMonth(otherCom, billMonth, otherPO.getOtherStartTime());
2022-07-21 17:28:47 +08:00
2022-04-15 13:17:25 +08:00
List<BigDecimal> otherComList = new ArrayList<>();
Map<String, String> otherComJsonMap = new HashMap<>();
needArchivesCom.stream().forEach(e -> {
InsuranceSchemeDetailPO po = otherCom.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal((ObjectUtils.isEmpty(archivesCom) || StringUtils.isBlank(archivesCom.get(String.valueOf(e)))) ? "0" : archivesCom.get(String.valueOf(e)));
2022-04-15 13:17:25 +08:00
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
BigDecimal result = new BigDecimal("0");
if (Objects.equals(po.getPaymentCycle(), 1)) {
int monthValue = 1;
for (int i = monthIndex - 1; i >= 0; i--) {
String cycleValue = po.getCycleSetting().charAt(i) + "";
if (Integer.parseInt(cycleValue) == 1) {
break;
}
monthValue++;
}
if (po.getAccountType() == 1) {
paymentNum = paymentNum.multiply(new BigDecimal(monthValue));
fixedCost = fixedCost.multiply(new BigDecimal(monthValue));
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
} else {
for (int i = 0; i < monthValue; i++) {
result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)));
}
}
} else {
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
}
2022-04-15 13:17:25 +08:00
otherComJsonMap.put(String.valueOf(e), result.toPlainString());
otherComList.add(result);
});
insuranceAccountDetailPO.setOtherComJson(JSON.toJSONString(otherComJsonMap));
BigDecimal otherComSum = new BigDecimal("0");
for (BigDecimal bigDecimal : otherComList) {
otherComSum = otherComSum.add(bigDecimal);
}
insuranceAccountDetailPO.setOtherComSum(otherComSum.toPlainString());
}
}
return insuranceAccountDetailPO;
}
2022-04-14 11:54:16 +08:00
public InsuranceAccountDetailPO accountFund(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String billMonth) {
2022-04-15 13:17:25 +08:00
if (accountPO.getFund() != null) {
InsuranceArchivesFundSchemePO fundPO = accountPO.getFund();
insuranceAccountDetailPO.setFundPayOrg(fundPO.getPaymentOrganization());
insuranceAccountDetailPO.setFundAccount(fundPO.getFundAccount());
insuranceAccountDetailPO.setSupplementFundAccount(fundPO.getSupplementFundAccount());
insuranceAccountDetailPO.setFundSchemeId(fundPO.getFundSchemeId());
insuranceAccountDetailPO.setFundPaymentBaseString(fundPO.getFundPaymentBaseString());
//判断是否在起始缴纳月和最后缴纳月之间
Boolean inDataRange = SalaryDateUtil.monthInRange(billMonth, fundPO.getFundStartTime(), fundPO.getFundEndTime());
if ((Objects.equals(NonPaymentEnum.YES.getValue(), fundPO.getNonPayment()) || fundPO.getNonPayment() == null) && fundPO.getFundSchemeId() != null && inDataRange) {
List<InsuranceSchemeDetailPO> detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(fundPO.getFundSchemeId());
encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class);
2022-04-15 13:17:25 +08:00
//方案中包含的需要缴纳社保的个人福利
int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1;
2022-04-15 13:17:25 +08:00
Map<Long, InsuranceSchemeDetailPO> fundperson = detailPOS.stream()
.filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue()) && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1"))))
2022-04-15 13:17:25 +08:00
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesPerson = JSON.parseObject(fundPO.getFundPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算公积金的福利id 个人
List<Long> needArchivesPerson = new ArrayList<>();
if (archivesPerson != null) {
2022-07-21 17:28:47 +08:00
archivesPerson.forEach((id, value) -> {
if (fundperson.containsKey(Long.valueOf(id))) {
needArchivesPerson.add(Long.valueOf(id));
}
});
}
//判断核算周期、核算月、福利起始缴纳月的关系
checkCycleSettingWithStartMonth(fundperson, billMonth, fundPO.getFundStartTime());
2022-07-21 17:28:47 +08:00
2022-04-15 13:17:25 +08:00
List<BigDecimal> fundPer = new ArrayList<>();
Map<String, String> fundPerJsonMap = new HashMap<>();
needArchivesPerson.stream().forEach(e -> {
InsuranceSchemeDetailPO po = fundperson.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal((ObjectUtils.isEmpty(archivesPerson) || StringUtils.isBlank(archivesPerson.get(String.valueOf(e)))) ? "0" : archivesPerson.get(String.valueOf(e)));
2022-04-15 13:17:25 +08:00
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
BigDecimal result = new BigDecimal("0");
if (Objects.equals(po.getPaymentCycle(), 1)) {
int monthValue = 1;
for (int i = monthIndex - 1; i >= 0; i--) {
String cycleValue = po.getCycleSetting().charAt(i) + "";
if (Integer.parseInt(cycleValue) == 1) {
break;
}
monthValue++;
}
if (po.getAccountType() == 1) {
paymentNum = paymentNum.multiply(new BigDecimal(monthValue));
fixedCost = fixedCost.multiply(new BigDecimal(monthValue));
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
} else {
for (int i = 0; i < monthValue; i++) {
result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)));
}
}
} else {
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
}
2022-04-15 13:17:25 +08:00
fundPerJsonMap.put(String.valueOf(e), result.toPlainString());
fundPer.add(result);
});
insuranceAccountDetailPO.setFundPerJson(JSON.toJSONString(fundPerJsonMap));
BigDecimal funPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : fundPer) {
funPerSum = funPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setFundPerSum(funPerSum.toPlainString());
2022-04-14 11:54:16 +08:00
2022-04-15 13:17:25 +08:00
//方案中包含的需要缴纳公积金的单位福利
Map<Long, InsuranceSchemeDetailPO> fundCom = detailPOS.stream()
.filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue()) && (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1"))))
2022-04-15 13:17:25 +08:00
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesCom = JSON.parseObject(fundPO.getFundPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算公积金的福利id 单位
List<Long> needArchivesCom = new ArrayList<>();
if (archivesCom != null) {
2022-07-21 17:28:47 +08:00
archivesCom.forEach((id, value) -> {
if (fundCom.containsKey(Long.valueOf(id))) {
needArchivesCom.add(Long.valueOf(id));
}
});
}
//判断核算周期、核算月、福利起始缴纳月的关系
checkCycleSettingWithStartMonth(fundCom, billMonth, fundPO.getFundStartTime());
2022-07-21 17:28:47 +08:00
2022-04-15 13:17:25 +08:00
List<BigDecimal> fundComList = new ArrayList<>();
Map<String, String> fundComJsonMap = new HashMap<>();
needArchivesCom.stream().forEach(e -> {
InsuranceSchemeDetailPO po = fundCom.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal((ObjectUtils.isEmpty(archivesCom) || StringUtils.isBlank(archivesCom.get(String.valueOf(e)))) ? "0" : archivesCom.get(String.valueOf(e)));
2022-04-15 13:17:25 +08:00
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
BigDecimal result = new BigDecimal("0");
if (Objects.equals(po.getPaymentCycle(), 1)) {
int monthValue = 1;
for (int i = monthIndex - 1; i >= 0; i--) {
String cycleValue = po.getCycleSetting().charAt(i) + "";
if (Integer.parseInt(cycleValue) == 1) {
break;
}
monthValue++;
}
if (po.getAccountType() == 1) {
paymentNum = paymentNum.multiply(new BigDecimal(monthValue));
fixedCost = fixedCost.multiply(new BigDecimal(monthValue));
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
} else {
for (int i = 0; i < monthValue; i++) {
result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)));
}
}
} else {
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
}
2022-04-15 13:17:25 +08:00
fundComJsonMap.put(String.valueOf(e), result.toPlainString());
fundComList.add(result);
});
insuranceAccountDetailPO.setFundComJson(JSON.toJSONString(fundComJsonMap));
BigDecimal fundComSum = new BigDecimal("0");
for (BigDecimal bigDecimal : fundComList) {
fundComSum = fundComSum.add(bigDecimal);
}
insuranceAccountDetailPO.setFundComSum(fundComSum.toPlainString());
2022-04-14 11:54:16 +08:00
2022-04-15 13:17:25 +08:00
}
}
return insuranceAccountDetailPO;
}
2022-04-14 11:54:16 +08:00
public InsuranceAccountDetailPO accountSocial(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, String billMonth) {
2022-04-15 13:17:25 +08:00
if (accountPO.getSocial() != null) {
InsuranceArchivesSocialSchemePO socialPO = accountPO.getSocial();
insuranceAccountDetailPO.setSocialPayOrg(socialPO.getPaymentOrganization());
insuranceAccountDetailPO.setSocialAccount(socialPO.getSocialAccount());
insuranceAccountDetailPO.setSocialSchemeId(socialPO.getSocialSchemeId());
insuranceAccountDetailPO.setSocialPaymentBaseString(socialPO.getSocialPaymentBaseString());
//判断是否在起始缴纳月和最后缴纳月之间
Boolean inDataRange = SalaryDateUtil.monthInRange(billMonth, socialPO.getSocialStartTime(), socialPO.getSocialEndTime());
if ((Objects.equals(NonPaymentEnum.YES.getValue(), socialPO.getNonPayment()) || socialPO.getNonPayment() == null) && socialPO.getSocialSchemeId() != null && inDataRange) {
List<InsuranceSchemeDetailPO> detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(socialPO.getSocialSchemeId());
encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class);
2022-04-15 13:17:25 +08:00
//方案中包含的需要缴纳社保的个人福利
int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1;
2022-04-15 13:17:25 +08:00
Map<Long, InsuranceSchemeDetailPO> schemeperson = detailPOS.stream()
.filter(item ->
Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) &&
Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue()) &&
(item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1")))
)
2022-04-15 13:17:25 +08:00
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesPerson = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算社保的福利id 个人
List<Long> needArchivesPerson = new ArrayList<>();
if (archivesPerson != null) {
2022-07-21 17:28:47 +08:00
archivesPerson.forEach((id, value) -> {
if (schemeperson.containsKey(Long.valueOf(id))) {
needArchivesPerson.add(Long.valueOf(id));
}
});
}
//判断核算周期、核算月、福利起始缴纳月的关系
checkCycleSettingWithStartMonth(schemeperson, billMonth, socialPO.getSocialStartTime());
2022-04-15 13:17:25 +08:00
List<BigDecimal> socialPer = new ArrayList<>();
Map<String, String> socialPerJsonMap = new HashMap<>();
needArchivesPerson.forEach(e -> {
2022-04-15 13:17:25 +08:00
InsuranceSchemeDetailPO po = schemeperson.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal((ObjectUtils.isEmpty(archivesPerson) || StringUtils.isBlank(archivesPerson.get(String.valueOf(e)))) ? "0" : archivesPerson.get(String.valueOf(e)));
2022-04-15 13:17:25 +08:00
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
BigDecimal result = new BigDecimal("0");
if (Objects.equals(po.getPaymentCycle(), 1)) {
int monthValue = 1;
for (int i = monthIndex - 1; i >= 0; i--) {
String cycleValue = po.getCycleSetting().charAt(i) + "";
if (Integer.parseInt(cycleValue) == 1) {
break;
}
monthValue++;
}
if (po.getAccountType() == 1) {
paymentNum = paymentNum.multiply(new BigDecimal(monthValue));
fixedCost = fixedCost.multiply(new BigDecimal(monthValue));
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
} else {
for (int i = 0; i < monthValue; i++) {
result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)));
}
}
} else {
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
}
2022-04-15 13:17:25 +08:00
socialPerJsonMap.put(String.valueOf(e), result.toPlainString());
socialPer.add(result);
});
insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerJsonMap));
BigDecimal socialPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : socialPer) {
socialPerSum = socialPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString());
//方案中包含的需要缴纳社保的单位福利
Map<Long, InsuranceSchemeDetailPO> schemeCom = detailPOS.stream()
.filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue()) &&
(item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1"))))
2022-04-15 13:17:25 +08:00
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesCom = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算社保的福利id 单位
List<Long> needArchivesCom = new ArrayList<>();
if (archivesCom != null) {
2022-07-21 17:28:47 +08:00
archivesCom.forEach((id, value) -> {
if (schemeCom.containsKey(Long.valueOf(id))) {
needArchivesCom.add(Long.valueOf(id));
}
});
}
//判断核算周期、核算月、福利起始缴纳月的关系
checkCycleSettingWithStartMonth(schemeCom, billMonth, socialPO.getSocialStartTime());
2022-07-21 17:28:47 +08:00
2022-04-15 13:17:25 +08:00
List<BigDecimal> socialCom = new ArrayList<>();
Map<String, String> sociaComJsonMap = new HashMap<>();
needArchivesCom.stream().forEach(e -> {
InsuranceSchemeDetailPO po = schemeCom.get(e);
BigDecimal paymentProportion = new BigDecimal(StringUtils.isBlank(po.getPaymentProportion()) ? "0" : po.getPaymentProportion()).divide(new BigDecimal("100"));
BigDecimal paymentNum = new BigDecimal((ObjectUtils.isEmpty(archivesCom) || StringUtils.isBlank(archivesCom.get(String.valueOf(e)))) ? "0" : archivesCom.get(String.valueOf(e)));
2022-04-15 13:17:25 +08:00
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
BigDecimal result = new BigDecimal("0");
if (Objects.equals(po.getPaymentCycle(), 1)) {
int monthValue = 1;
for (int i = monthIndex - 1; i >= 0; i--) {
String cycleValue = po.getCycleSetting().charAt(i) + "";
if (Integer.parseInt(cycleValue) == 1) {
break;
}
monthValue++;
}
if (po.getAccountType() == 1) {
paymentNum = paymentNum.multiply(new BigDecimal(monthValue));
fixedCost = fixedCost.multiply(new BigDecimal(monthValue));
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
} else {
for (int i = 0; i < monthValue; i++) {
result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)));
}
}
} else {
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
}
2022-04-15 13:17:25 +08:00
sociaComJsonMap.put(String.valueOf(e), result.toPlainString());
socialCom.add(result);
});
insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(sociaComJsonMap));
BigDecimal socialComSum = new BigDecimal("0");
for (BigDecimal decimal : socialCom) {
socialComSum = socialComSum.add(decimal);
}
insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString());
}
}
return insuranceAccountDetailPO;
}
public InsuranceAccountDetailPO accountEndowmentInsurance(InsuranceAccountDetailPO insuranceAccountDetailPO, InsuranceArchivesAccountPO accountPO, List<Long> categoryIds, String billMonth) {
2022-04-15 13:17:25 +08:00
if (accountPO.getSocial() != null) {
InsuranceArchivesSocialSchemePO socialPO = accountPO.getSocial();
insuranceAccountDetailPO.setSocialPayOrg(socialPO.getPaymentOrganization());
insuranceAccountDetailPO.setSocialAccount(socialPO.getSocialAccount());
insuranceAccountDetailPO.setSocialSchemeId(socialPO.getSocialSchemeId());
insuranceAccountDetailPO.setSocialPaymentBaseString(socialPO.getSocialPaymentBaseString());
//判断是否在起始缴纳月和最后缴纳月之间
Boolean inDataRange = SalaryDateUtil.monthInRange(billMonth, socialPO.getSocialStartTime(), socialPO.getSocialEndTime());
if ((Objects.equals(NonPaymentEnum.YES.getValue(), socialPO.getNonPayment()) || socialPO.getNonPayment() == null) && socialPO.getSocialSchemeId() != null && inDataRange) {
List<InsuranceSchemeDetailPO> detailPOS = getInsuranceSchemeDetailMapper().queryListBySchemeId(socialPO.getSocialSchemeId());
encryptUtil.decryptList(detailPOS, InsuranceSchemeDetailPO.class);
2022-04-15 13:17:25 +08:00
//方案中包含的需要缴纳社保的个人福利
int monthIndex = Integer.parseInt(billMonth.split("-")[1]) - 1;
2022-04-15 13:17:25 +08:00
Map<Long, InsuranceSchemeDetailPO> schemeperson = detailPOS.stream()
.filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment())
&& Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_PERSON.getValue())
&& (item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1"))))
2022-04-15 13:17:25 +08:00
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesPerson = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算社保的福利id 个人
List<Long> needArchivesPerson = new ArrayList<>();
if (archivesPerson != null) {
2022-07-21 17:28:47 +08:00
categoryIds.forEach(item -> {
if (archivesPerson.containsKey(String.valueOf(item)) && schemeperson.containsKey(item)) {
if (StringUtils.isNotBlank(archivesPerson.get(String.valueOf(item)))) {
needArchivesPerson.add(item);
}
2022-07-21 17:28:47 +08:00
}
});
}
//判断核算周期、核算月、福利起始缴纳月的关系
checkCycleSettingWithStartMonth(schemeperson, billMonth, socialPO.getSocialStartTime());
2022-07-21 17:28:47 +08:00
2022-04-15 13:17:25 +08:00
List<BigDecimal> socialPer = new ArrayList<>();
Map<String, String> socialPerJsonMap = new HashMap<>();
needArchivesPerson.forEach(e -> {
2022-04-15 13:17:25 +08:00
InsuranceSchemeDetailPO po = schemeperson.get(e);
BigDecimal paymentProportion = new BigDecimal(po.getPaymentProportion()).divide(new BigDecimal("100"));
// BigDecimal paymentNum = new BigDecimal(archivesPerson.get(String.valueOf(e)));
BigDecimal paymentNum = new BigDecimal((ObjectUtils.isEmpty(archivesPerson) || StringUtils.isBlank(archivesPerson.get(String.valueOf(e)))) ? "0" : archivesPerson.get(String.valueOf(e)));
2022-04-15 13:17:25 +08:00
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
BigDecimal result = new BigDecimal("0");
if (Objects.equals(po.getPaymentCycle(), 1)) {
int monthValue = 1;
for (int i = monthIndex - 1; i >= 0; i--) {
String cycleValue = po.getCycleSetting().charAt(i) + "";
if (Integer.parseInt(cycleValue) == 1) {
break;
}
monthValue++;
}
if (po.getAccountType() == 1) {
paymentNum = paymentNum.multiply(new BigDecimal(monthValue));
fixedCost = fixedCost.multiply(new BigDecimal(monthValue));
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
} else {
for (int i = 0; i < monthValue; i++) {
result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)));
}
}
} else {
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
}
2022-04-15 13:17:25 +08:00
socialPerJsonMap.put(String.valueOf(e), result.toPlainString());
socialPer.add(result);
});
insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerJsonMap));
BigDecimal socialPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : socialPer) {
socialPerSum = socialPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString());
//方案中包含的需要缴纳社保的单位福利
Map<Long, InsuranceSchemeDetailPO> schemeCom = detailPOS.stream()
.filter(item -> Objects.equals(IsPaymentEnum.YES.getValue(), item.getIsPayment()) && Objects.equals(item.getPaymentScope(), PaymentScopeEnum.SCOPE_COMPANY.getValue()) &&
(item.getPaymentCycle() == null || item.getPaymentCycle() == 0 || (item.getPaymentCycle() == 1 && String.valueOf(item.getCycleSetting().charAt(monthIndex)).equals("1"))))
2022-04-15 13:17:25 +08:00
.collect(
Collectors.toMap(InsuranceSchemeDetailPO::getInsuranceId, Function.identity()));
//档案中包含的基数信息
HashMap<String, String> archivesCom = JSON.parseObject(socialPO.getSocialPaymentBaseString(), new HashMap<String, String>().getClass());
//需要核算社保的福利id 单位
List<Long> needArchivesCom = new ArrayList<>();
if (archivesCom != null) {
categoryIds.forEach(item -> {
if (archivesCom.containsKey(String.valueOf(item)) && schemeCom.containsKey(item)) {
if (StringUtils.isNotBlank(archivesCom.get(String.valueOf(item)))) {
needArchivesCom.add(item);
}
2022-07-21 17:28:47 +08:00
}
});
//判断核算周期、核算月、福利起始缴纳月的关系
checkCycleSettingWithStartMonth(schemeCom, billMonth, socialPO.getSocialStartTime());
// archivesCom.forEach((id, value) -> {
// if (schemeCom.containsKey(Long.valueOf(id))) {
// needArchivesCom.add(Long.valueOf(id));
// }
// });
2022-07-21 17:28:47 +08:00
}
2022-04-15 13:17:25 +08:00
List<BigDecimal> socialCom = new ArrayList<>();
Map<String, String> sociaComJsonMap = new HashMap<>();
needArchivesCom.forEach(e -> {
2022-04-15 13:17:25 +08:00
InsuranceSchemeDetailPO po = schemeCom.get(e);
BigDecimal paymentProportion = new BigDecimal(po.getPaymentProportion()).divide(new BigDecimal("100"));
// BigDecimal paymentNum = SalaryEntityUtil.string2BigDecimalDefault0(archivesCom.get(String.valueOf(e)));
BigDecimal paymentNum = new BigDecimal((ObjectUtils.isEmpty(archivesCom) || StringUtils.isBlank(archivesCom.get(String.valueOf(e)))) ? "0" : archivesCom.get(String.valueOf(e)));
2022-04-15 13:17:25 +08:00
BigDecimal fixedCost = StringUtils.isBlank(po.getFixedCost()) ? new BigDecimal("0") : new BigDecimal(po.getFixedCost());
Integer newScale = po.getValidNum() == null ? 0 : po.getValidNum();
// BigDecimal result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
BigDecimal result = new BigDecimal("0");
if (Objects.equals(po.getPaymentCycle(), 1)) {
int monthValue = 1;
for (int i = monthIndex - 1; i >= 0; i--) {
String cycleValue = po.getCycleSetting().charAt(i) + "";
if (Integer.parseInt(cycleValue) == 1) {
break;
}
monthValue++;
}
if (po.getAccountType() == 1) {
paymentNum = paymentNum.multiply(new BigDecimal(monthValue));
fixedCost = fixedCost.multiply(new BigDecimal(monthValue));
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
} else {
for (int i = 0; i < monthValue; i++) {
result = result.add(SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost)));
}
}
} else {
result = SalaryEntityUtil.carryRule(newScale, po.getRententionRule(), paymentNum.multiply(paymentProportion).add(fixedCost));
}
2022-04-15 13:17:25 +08:00
sociaComJsonMap.put(String.valueOf(e), result.toPlainString());
socialCom.add(result);
});
insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(sociaComJsonMap));
BigDecimal socialComSum = new BigDecimal("0");
for (BigDecimal decimal : socialCom) {
socialComSum = socialComSum.add(decimal);
}
insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString());
}
}
return insuranceAccountDetailPO;
}
2022-05-25 13:23:02 +08:00
2022-06-06 19:08:39 +08:00
private List<List<InsuranceAccountDetailPO>> splitDetailList(List<InsuranceAccountDetailPO> list, int groupSize) {
2022-05-25 13:23:02 +08:00
int length = list.size();
// 计算可以分成多少组
int num = (length + groupSize - 1) / groupSize;
2022-05-25 13:23:02 +08:00
List<List<InsuranceAccountDetailPO>> newList = new ArrayList<>(num);
for (int i = 0; i < num; i++) {
// 开始位置
int fromIndex = i * groupSize;
// 结束位置
2022-06-06 19:08:39 +08:00
int toIndex = (i + 1) * groupSize < length ? (i + 1) * groupSize : length;
newList.add(list.subList(fromIndex, toIndex));
2022-05-25 13:23:02 +08:00
}
2022-06-06 19:08:39 +08:00
return newList;
2022-05-25 13:23:02 +08:00
}
2022-04-15 13:17:25 +08:00
public void batchSaveSupplementAccount(List<InsuranceAccountDetailPO> pos, String billMonth, String tenantKey) {
if (CollectionUtils.isEmpty(pos)) {
return;
}
batchSaveAccountInspectDetail(pos, billMonth, tenantKey);
getInsuranceAccountDetailMapper().batchDelSupplementAccountDetails(pos);
encryptUtil.encryptList(pos, InsuranceAccountDetailPO.class);
2022-05-25 13:23:02 +08:00
List<List<InsuranceAccountDetailPO>> lists = splitDetailList(pos, 20);
lists.forEach(subList -> {
getInsuranceAccountDetailMapper().batchSaveAccountDetails(subList);
2022-05-25 13:23:02 +08:00
});
2022-04-15 13:17:25 +08:00
//删除日志
// pos.stream().forEach(item -> {
// LoggerContext insuranceSchemeContext = new LoggerContext();
// insuranceSchemeContext.setTargetId(String.valueOf(item.getId()));
// insuranceSchemeContext.setTargetName(String.valueOf(item.getEmployeeId()));
// insuranceSchemeContext.setOperateType(OperateTypeEnum.DELETE.getValue());
// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(100448, "删除核算记录"));
// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(100448, "删除核算记录"));
// insuranceSchemeContext.setNewValues(item);
// siAccountLoggerTemplate.write(insuranceSchemeContext);
// });
//插入日志
// pos.stream().forEach(item -> {
// LoggerContext insuranceSchemeContext = new LoggerContext();
// insuranceSchemeContext.setTargetId(String.valueOf(item.getId()));
// insuranceSchemeContext.setTargetName(String.valueOf(item.getEmployeeId()));
// insuranceSchemeContext.setOperateType(OperateTypeEnum.ADD.getValue());
// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(100494, "新建核算记录"));
// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(100494, "新建核算记录"));
// insuranceSchemeContext.setNewValues(item);
// siAccountLoggerTemplate.write(insuranceSchemeContext);
// });
}
2022-06-06 19:08:39 +08:00
public void deleteCommonAccount(SaveCommonAccountParam param, Long employeeId, String currentUserName) {
ValidUtil.doValidator(param);
SalaryAssert.notEmpty(param.getIncludes(), SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
//根据id批量删除
if (param.getIds().size() > 0) {
getInsuranceAccountDetailMapper().batchDelAccountDetailsByIds(param.getIds());
} else {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "请勾选需要删除的数据项!"));
}
2022-06-06 19:08:39 +08:00
//记录日志
2022-04-15 13:17:25 +08:00
// LoggerContext insuranceSchemeContext = new LoggerContext();
// insuranceSchemeContext.setTargetId(String.join(",", param.getIncludes().stream().map(item -> String.valueOf(item)).collect(Collectors.toList())));
// insuranceSchemeContext.setTargetName(param.getBillMonth());
// insuranceSchemeContext.setOperateType(OperateTypeEnum.ADD.getValue());
// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100462, "新增台账"));
// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100462, "新增台账"));
// insuranceSchemeContext.setNewValues(param);
// siAccountLoggerTemplate.write(insuranceSchemeContext);
2022-06-06 19:08:39 +08:00
updateBatchAccount(AccountParam.builder().billMonth(param.getBillMonth()).paymentOrganization(param.getPaymentOrganization()).build(), employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, currentUserName);
2022-04-15 13:17:25 +08:00
}
2022-06-06 19:08:39 +08:00
public void deleteSupplementaryAccount(List<SupplementAccountBaseParam> param, Long employeeId, String currentUserName) {
2022-04-15 13:17:25 +08:00
SalaryAssert.notEmpty(param, SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
boolean valid = param.stream().anyMatch(item -> item.getEmployeeId() == null
|| StringUtils.isBlank(item.getSupplementaryMonth())
|| StringUtils.isBlank(item.getBillMonth()));
if (valid) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
}
getInsuranceAccountDetailMapper().batchDelSupplementDetailsByIds(param);
2022-04-15 13:17:25 +08:00
// param.stream().forEach(item -> {
// LoggerContext insuranceSchemeContext = new LoggerContext();
// insuranceSchemeContext.setTargetName(item.getBillMonth());
// insuranceSchemeContext.setOperateType(OperateTypeEnum.DELETE.getValue());
// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100490, "删除补缴核算记录"));
// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100490, "删除补缴核算记录"));
// insuranceSchemeContext.setNewValues(item);
// siAccountLoggerTemplate.write(insuranceSchemeContext);
// });
2022-06-06 19:08:39 +08:00
updateBatchAccount(AccountParam.builder().billMonth(param.get(0).getBillMonth()).paymentOrganization(param.get(0).getPaymentOrganization()).build(), employeeId, SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY, currentUserName);
2022-04-15 13:17:25 +08:00
}
2022-06-10 10:56:09 +08:00
public void file(String billMonth, Long employeeId, Long paymentOrganization) {
// 归档前检查是否有核算异常
// List<InsuranceAccountInspectPO> insuranceAccountInspectPOS = getInsuranceAccountInspectMapper().getByInspectStatusAndBillMonth(InspectStatusEnum.IGNORE.getValue(),billMonth);
2022-04-15 13:17:25 +08:00
// SalaryAssert.isEmpty(insuranceAccountInspectPOS, SalaryI18nUtil.getI18nLabel( 100500, "当前核算月存在核算异常数据"));
2022-04-15 13:17:25 +08:00
//开始归档数据
InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillStatus(billMonth, BillStatusEnum.NOT_ARCHIVED.getValue(), paymentOrganization);
encryptUtil.decrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class);
SalaryAssert.notNull(insuranceAccountBatchPO, SalaryI18nUtil.getI18nLabel(100503, "月份账单不存在"));
SalaryAssert.isFalse(Objects.equals(insuranceAccountBatchPO.getBillStatus(), BillStatusEnum.ARCHIVED.getValue()), SalaryI18nUtil.getI18nLabel(100504, "月份账单已归档"));
2022-04-15 13:17:25 +08:00
insuranceAccountBatchPO.setBillStatus(BillStatusEnum.ARCHIVED.getValue());
encryptUtil.encrypt(insuranceAccountBatchPO, InsuranceAccountBatchPO.class);
getInsuranceAccountBatchMapper().updateById(insuranceAccountBatchPO);
2022-06-06 19:08:39 +08:00
//日志记录
2022-04-15 13:17:25 +08:00
// LoggerContext insuranceSchemeContext = new LoggerContext();
// insuranceSchemeContext.setTargetId(String.valueOf(insuranceAccountBatchPO.getId()));
// insuranceSchemeContext.setTargetName(insuranceAccountBatchPO.getBillMonth());
// insuranceSchemeContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
// insuranceSchemeContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100506, "台账归档"));
// insuranceSchemeContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100506, "台账归档"));
// insuranceSchemeContext.setNewValues(insuranceAccountBatchPO);
// siAccountLoggerTemplate.write(insuranceSchemeContext);
2022-04-16 16:43:33 +08:00
}
public void accountInspect(Collection<Long> ids, String billMonth, Long employeeId, String currentUserName, Long paymentOrganization) {
2022-04-16 16:43:33 +08:00
List<InsuranceAccountInspectPO> insuranceAccountInspectPOS = allInspects(ids, billMonth);
2022-06-06 19:08:39 +08:00
SalaryAssert.notEmpty(insuranceAccountInspectPOS, SalaryI18nUtil.getI18nLabel(100515, "无核算数据"));
2022-04-16 16:43:33 +08:00
List<InsuranceAccountInspectPO> commonInspects = insuranceAccountInspectPOS.stream()
.filter(e -> Objects.equals(e.getPaymentStatus(), PaymentStatusEnum.COMMON.getValue()))
.collect(Collectors.toList());
List<InsuranceAccountInspectPO> supplementInspects = insuranceAccountInspectPOS.stream()
.filter(e -> Objects.equals(e.getPaymentStatus(), PaymentStatusEnum.REPAIR.getValue()))
.collect(Collectors.toList());
//核算正常缴纳
if (CollectionUtils.isNotEmpty(commonInspects)) {
SaveCommonAccountParam param = new SaveCommonAccountParam();
param.setBillMonth(billMonth);
param.setIncludes(commonInspects.stream().map(InsuranceAccountInspectPO::getEmployeeId).collect(Collectors.toList()));
2022-06-06 19:08:39 +08:00
saveCommonAccount(param, employeeId, currentUserName);
2022-04-16 16:43:33 +08:00
}
//核算补缴
if (CollectionUtils.isNotEmpty(supplementInspects)) {
List<SupplementAccountBaseParam> baseList = new ArrayList<>();
supplementInspects.forEach(e -> {
SupplementAccountBaseParam base = new SupplementAccountBaseParam();
base.setBillMonth(billMonth);
base.setProjects(
e.getSupplementaryProjects() == null ? null : Arrays.stream(e.getSupplementaryProjects().split(",")).map(Integer::valueOf).collect(Collectors.toList()));
base.setEmployeeId(e.getEmployeeId());
base.setSupplementaryMonth(e.getSupplementaryMonth());
baseList.add(base);
});
accountSupplement(baseList, baseList.stream().map(SupplementAccountBaseParam::getEmployeeId).collect(Collectors.toList()), billMonth, employeeId, paymentOrganization);
2022-04-16 16:43:33 +08:00
}
}
2022-04-15 13:17:25 +08:00
2022-04-16 16:43:33 +08:00
public List<InsuranceAccountInspectPO> allInspects(Collection<Long> ids, String billMonth) {
List<InsuranceAccountInspectPO> list = getInsuranceAccountInspectMapper().getList(billMonth, InspectStatusEnum.IGNORE.getValue(), ids);
2022-04-16 16:43:33 +08:00
if (CollectionUtils.isNotEmpty(list)) {
return list;
}
return Collections.emptyList();
2022-04-15 13:17:25 +08:00
}
2022-04-16 16:43:33 +08:00
2022-04-18 20:24:43 +08:00
public PageInfo<InsuranceAccountViewListDTO> overView(InsuranceAccountDetailParam queryParam) {
2022-04-16 16:43:33 +08:00
// SalaryPageUtil.start(queryParam.getCurrent(),queryParam.getPageSize());
List<InsuranceAccountDetailPO> insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().selectList(queryParam.getBillMonth(), StringUtil.isBlank(queryParam.getPaymentOrganization()) ? null : Long.valueOf(queryParam.getPaymentOrganization()));
encryptUtil.decryptList(insuranceAccountDetailPOS, InsuranceAccountDetailPO.class);
2022-04-18 20:24:43 +08:00
//获取扣缴义务人信息
List<TaxAgentPO> paymentList = getTaxAgentMapper().listAll();
2022-06-06 19:08:39 +08:00
SalaryAssert.notEmpty(paymentList, SalaryI18nUtil.getI18nLabel(100341, "该租户无扣缴义务人"));
2022-08-09 16:54:29 +08:00
Map<Long, TaxAgentPO> paymentMap = paymentList.stream().collect(Collectors.toMap(TaxAgentPO::getId, Function.identity()));
2022-04-18 20:24:43 +08:00
List<InsuranceAccountViewListDTO> insuranceAccountViewListDTOS = buildRecords(insuranceAccountDetailPOS, paymentMap);
// List<ICategoryPO> iCategoryPOS = getICategoryMapper().listAll();
2022-04-18 20:24:43 +08:00
// Page<InsuranceCategoryPO> page = FormatManager.getTablePage();
// Page<InsuranceAccountViewListDTO> insuranceAccountViewListDTOPage = new Page<>(page.getCurrent(), insuranceAccountViewListDTOS.size(), insuranceAccountViewListDTOS.size(),
// page.isSearchCount());
2022-06-06 19:08:39 +08:00
PageInfo<InsuranceAccountViewListDTO> insuranceAccountViewListDTOPage = new PageInfo<>(insuranceAccountViewListDTOS, InsuranceAccountViewListDTO.class);
2022-04-18 20:24:43 +08:00
insuranceAccountViewListDTOPage.setTotal(insuranceAccountViewListDTOS.size());
return insuranceAccountViewListDTOPage;
}
2022-08-09 16:54:29 +08:00
public List<InsuranceAccountViewListDTO> buildRecords(List<InsuranceAccountDetailPO> list, Map<Long, TaxAgentPO> paymentMap) {
2022-04-18 20:24:43 +08:00
Map<Long, InsuranceAccountViewListDTO> result = new HashMap<>();
//根据组织分组,对社保进行统计
Map<Long, List<InsuranceAccountDetailPO>> socialCollect = list.stream().filter(item -> item.getSocialPayOrg() != null)
.collect(Collectors.groupingBy(InsuranceAccountDetailPO::getSocialPayOrg));
socialCollect.forEach((k, v) -> {
if (result.get(k) == null) {
InsuranceAccountViewListDTO temp = new InsuranceAccountViewListDTO();
temp.setPayOrg(paymentMap.get(k).getName());
result.put(k, temp);
}
InsuranceAccountViewListDTO insuranceAccountViewListDTO = result.get(k);
accountSocialView(insuranceAccountViewListDTO, v);
});
//根据组织分组,对公积金进行统计
2022-06-28 18:21:44 +08:00
Map<Long, List<InsuranceAccountDetailPO>> fundCollect = list.stream().filter(item -> item.getSocialPayOrg() != null)
.collect(Collectors.groupingBy(InsuranceAccountDetailPO::getSocialPayOrg));
2022-04-18 20:24:43 +08:00
fundCollect.forEach((k, v) -> {
if (result.get(k) == null) {
InsuranceAccountViewListDTO temp = new InsuranceAccountViewListDTO();
temp.setPayOrg(paymentMap.get(k).getName());
result.put(k, temp);
}
InsuranceAccountViewListDTO insuranceAccountViewListDTO = result.get(k);
accountFundView(insuranceAccountViewListDTO, v);
});
//根据组织分组,对其他福利进行统计
2022-06-28 18:21:44 +08:00
Map<Long, List<InsuranceAccountDetailPO>> otherCollect = list.stream().filter(item -> item.getSocialPayOrg() != null)
.collect(Collectors.groupingBy(InsuranceAccountDetailPO::getSocialPayOrg));
2022-04-18 20:24:43 +08:00
otherCollect.forEach((k, v) -> {
if (result.get(k) == null) {
InsuranceAccountViewListDTO temp = new InsuranceAccountViewListDTO();
temp.setPayOrg(paymentMap.get(k).getName());
result.put(k, temp);
}
InsuranceAccountViewListDTO insuranceAccountViewListDTO = result.get(k);
accountOtherView(insuranceAccountViewListDTO, v);
});
//对各组织进行金额合计
List<InsuranceAccountViewListDTO> viewDTOS = new ArrayList<>();
result.forEach((k, v) -> {
BigDecimal socialPaySum = StringUtils.isBlank(v.getSocialPaySum()) ? new BigDecimal("0") : new BigDecimal(v.getSocialPaySum());
BigDecimal fundPaySum = StringUtils.isBlank(v.getFundPaySum()) ? new BigDecimal("0") : new BigDecimal(v.getFundPaySum());
BigDecimal otherPaySum = StringUtils.isBlank(v.getOtherPaySum()) ? new BigDecimal("0") : new BigDecimal(v.getOtherPaySum());
v.setIndex(k);
BigDecimal sum = socialPaySum.add(fundPaySum).add(otherPaySum);
v.setSum(sum.toPlainString());
viewDTOS.add(v);
});
//合计
InsuranceAccountViewListDTO insuranceAccountViewListDTO = new InsuranceAccountViewListDTO();
int socialNum = 0;
int fundNum = 0;
int otherNum = 0;
BigDecimal socialSum = new BigDecimal("0");
BigDecimal fundSum = new BigDecimal("0");
BigDecimal otherSum = new BigDecimal("0");
BigDecimal sum = new BigDecimal("0");
for (InsuranceAccountViewListDTO item : viewDTOS) {
if (item.getSocialNum() != null) {
socialNum += item.getSocialNum();
}
if (item.getFundNum() != null) {
fundNum += item.getFundNum();
}
if (item.getOtherNum() != null) {
otherNum += item.getOtherNum();
}
if (StringUtils.isNotBlank(item.getSocialPaySum())) {
socialSum = socialSum.add(new BigDecimal(item.getSocialPaySum()));
}
if (StringUtils.isNotBlank(item.getFundPaySum())) {
fundSum = fundSum.add(new BigDecimal(item.getFundPaySum()));
}
if (StringUtils.isNotBlank(item.getOtherPaySum())) {
otherSum = otherSum.add(new BigDecimal(item.getOtherPaySum()));
}
if (StringUtils.isNotBlank(item.getSum())) {
sum = sum.add(new BigDecimal(item.getSum()));
}
}
insuranceAccountViewListDTO.setSum(sum.toPlainString());
insuranceAccountViewListDTO.setSocialPaySum(socialSum.toPlainString());
insuranceAccountViewListDTO.setPayOrg(SalaryI18nUtil.getI18nLabel(93278, "合计"));
insuranceAccountViewListDTO.setFundPaySum(fundSum.toPlainString());
insuranceAccountViewListDTO.setOtherPaySum(otherSum.toPlainString());
insuranceAccountViewListDTO.setSocialNum(socialNum);
insuranceAccountViewListDTO.setFundNum(fundNum);
insuranceAccountViewListDTO.setOtherNum(otherNum);
viewDTOS.add(insuranceAccountViewListDTO);
viewDTOS.forEach(e -> {
e.setSocialPaySum(StringUtils.isBlank(e.getSocialPaySum()) ? "0" : e.getSocialPaySum());
e.setSocialNum(e.getSocialNum() == null ? 0 : e.getSocialNum());
e.setFundNum(e.getFundNum() == null ? 0 : e.getFundNum());
e.setFundPaySum(StringUtils.isBlank(e.getFundPaySum()) ? "0" : e.getFundPaySum());
e.setOtherPaySum(StringUtils.isBlank(e.getOtherPaySum()) ? "0" : e.getOtherPaySum());
e.setOtherNum(e.getOtherNum() == null ? 0 : e.getOtherNum());
e.setSum(SalaryEntityUtil.thousandthConvert(e.getSum()));
e.setSocialPaySum(SalaryEntityUtil.thousandthConvert(e.getSocialPaySum()));
e.setOtherPaySum(SalaryEntityUtil.thousandthConvert(e.getOtherPaySum()));
e.setFundPaySum(SalaryEntityUtil.thousandthConvert(e.getFundPaySum()));
});
return viewDTOS;
}
public void accountOtherView(InsuranceAccountViewListDTO dto, List<InsuranceAccountDetailPO> pos) {
int otherNum = 0;
BigDecimal otherPaySum = new BigDecimal("0");
for (InsuranceAccountDetailPO item : pos) {
if (StringUtils.isNotBlank(item.getOtherSum()) && SalaryEntityUtil.string2DoubleDefault0(item.getOtherSum()) != 0.0) {
if (!PaymentStatusEnum.BALANCE.getValue().equals(item.getPaymentStatus())) {
otherNum += 1;
}
2022-04-18 20:24:43 +08:00
otherPaySum = otherPaySum.add(new BigDecimal(item.getOtherSum()));
}
}
dto.setOtherNum(otherNum);
dto.setOtherPaySum(otherPaySum.toPlainString());
}
public void accountFundView(InsuranceAccountViewListDTO dto, List<InsuranceAccountDetailPO> pos) {
int fundNum = 0;
BigDecimal fundPaySum = new BigDecimal("0");
for (InsuranceAccountDetailPO item : pos) {
if (StringUtils.isNotBlank(item.getFundSum()) && SalaryEntityUtil.string2DoubleDefault0(item.getFundSum()) != 0.0) {
if (!PaymentStatusEnum.BALANCE.getValue().equals(item.getPaymentStatus())) {
fundNum += 1;
}
2022-04-18 20:24:43 +08:00
fundPaySum = fundPaySum.add(new BigDecimal(item.getFundSum()));
}
}
dto.setFundNum(fundNum);
dto.setFundPaySum(fundPaySum.toPlainString());
}
public void accountSocialView(InsuranceAccountViewListDTO dto, List<InsuranceAccountDetailPO> pos) {
int socialNum = 0;
BigDecimal socialPaySum = new BigDecimal("0");
for (InsuranceAccountDetailPO item : pos) {
if (StringUtils.isNotBlank(item.getSocialSum()) && SalaryEntityUtil.string2DoubleDefault0(item.getSocialSum()) != 0.0 ) {
if (!PaymentStatusEnum.BALANCE.getValue().equals(item.getPaymentStatus())) {
socialNum += 1;
}
2022-04-18 20:24:43 +08:00
socialPaySum = socialPaySum.add(new BigDecimal(item.getSocialSum()));
}
}
dto.setSocialNum(socialNum);
dto.setSocialPaySum(socialPaySum.toPlainString());
}
2022-04-16 16:43:33 +08:00
2022-05-24 09:23:17 +08:00
2022-07-20 15:40:51 +08:00
/**
* 查询台账id是否已经薪资核算核算过
2022-07-21 17:28:47 +08:00
*
2022-07-20 15:40:51 +08:00
* @param param
* @return
*/
2022-07-21 17:28:47 +08:00
public int checkIfBusinessaccounting(InsuranceAccountBatchPO param) {
2022-07-28 16:28:53 +08:00
List<SIAccountUtilDTO> list = getSIAccountUtilMapper().checkIfBusinessaccounting(param.getId());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
return (int) list.stream().filter( f -> {
String billMonthBySob = sdf.format(convertSalaryMonthToBillMonth(f.getSalaryMonth(), f.getSocialSecurityCycleType()));
return f.getBillmonth().equals(billMonthBySob.substring(0, 7));
}).count();
2022-07-20 15:40:51 +08:00
}
public Date convertSalaryMonthToBillMonth(Date salaryMonth, Integer socialSecurityCycleType) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(salaryMonth);
calendar.add(Calendar.MONTH, socialSecurityCycleType - 3);
return calendar.getTime();
}
2022-07-20 15:40:51 +08:00
/**
* 更新薪资台账
2022-07-21 17:28:47 +08:00
*
2022-07-20 15:40:51 +08:00
* @param param
* @return
*/
2022-07-21 17:28:47 +08:00
public void updateById(InsuranceAccountBatchPO param) {
2022-07-20 15:40:51 +08:00
getInsuranceAccountBatchMapper().updateById(param);
}
2022-04-16 16:43:33 +08:00
/**
* 更新福利台账
*/
public void updateByEmployeeIdAndBillMonth(InsuranceAccountDetailPO insuranceAccountDetailPO) {
getInsuranceAccountDetailMapper().updateByEmployeeIdAndBillMonth(insuranceAccountDetailPO);
}
public void accountFundByData(InsuranceAccountDetailPO insuranceAccountDetailPO, SupplementAccountBaseParam baseParam) {
//公积金个人
if (StringUtils.isNotBlank(baseParam.getFundPaymentPerString())) {
List<BigDecimal> fundPer = new ArrayList<>();
HashMap<String, String> fundPerson = JSON.parseObject(baseParam.getFundPaymentPerString(), new HashMap<String, String>().getClass());
fundPerson.forEach((k, v) -> {
BigDecimal result = new BigDecimal(v);
fundPer.add(result);
});
insuranceAccountDetailPO.setFundPerJson(baseParam.getFundPaymentPerString());
BigDecimal fundPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : fundPer) {
fundPerSum = fundPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setFundPerSum(fundPerSum.toPlainString());
}
//公积金单位
if (StringUtils.isNotBlank(baseParam.getFundPaymentComString())) {
List<BigDecimal> fundCom = new ArrayList<>();
HashMap<String, String> fundComMap = JSON.parseObject(baseParam.getFundPaymentComString(), new HashMap<String, String>().getClass());
fundComMap.forEach((k, v) -> {
BigDecimal result = new BigDecimal(v);
fundCom.add(result);
});
insuranceAccountDetailPO.setFundComJson(baseParam.getFundPaymentComString());
BigDecimal fundComSum = new BigDecimal("0");
for (BigDecimal bigDecimal : fundCom) {
fundComSum = fundComSum.add(bigDecimal);
}
insuranceAccountDetailPO.setFundComSum(fundComSum.toPlainString());
}
}
public void accountOtherByData(InsuranceAccountDetailPO insuranceAccountDetailPO, SupplementAccountBaseParam baseParam) {
//其他福利个人
if (StringUtils.isNotBlank(baseParam.getOtherPaymentPerString())) {
List<BigDecimal> otherPer = new ArrayList<>();
HashMap<String, String> otherPerMap = JSON.parseObject(baseParam.getOtherPaymentPerString(), new HashMap<String, String>().getClass());
otherPerMap.forEach((k, v) -> {
BigDecimal result = new BigDecimal(v);
otherPer.add(result);
});
insuranceAccountDetailPO.setOtherPerJson(baseParam.getOtherPaymentPerString());
BigDecimal otherPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : otherPer) {
otherPerSum = otherPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setOtherPerSum(otherPerSum.toPlainString());
}
//其他福利单位
if (StringUtils.isNotBlank(baseParam.getOtherPaymentComString())) {
List<BigDecimal> otherCom = new ArrayList<>();
HashMap<String, String> otherComMap = JSON.parseObject(baseParam.getOtherPaymentComString(), new HashMap<String, String>().getClass());
otherComMap.forEach((k, v) -> {
BigDecimal result = new BigDecimal(v);
otherCom.add(result);
});
insuranceAccountDetailPO.setOtherComJson(baseParam.getOtherPaymentComString());
BigDecimal otherComSum = new BigDecimal("0");
for (BigDecimal bigDecimal : otherCom) {
otherComSum = otherComSum.add(bigDecimal);
}
insuranceAccountDetailPO.setOtherComSum(otherComSum.toPlainString());
}
}
public void accountSocialByData(InsuranceAccountDetailPO insuranceAccountDetailPO, SupplementAccountBaseParam baseParam) {
//社保个人
if (StringUtils.isNotBlank(baseParam.getSocialPaymentPerString())) {
List<BigDecimal> socialPer = new ArrayList<>();
HashMap<String, String> archivesPerson = JSON.parseObject(baseParam.getSocialPaymentPerString(), new HashMap<String, String>().getClass());
archivesPerson.forEach((k, v) -> {
BigDecimal result = new BigDecimal(v);
socialPer.add(result);
});
insuranceAccountDetailPO.setSocialPerJson(baseParam.getSocialPaymentPerString());
BigDecimal socialPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : socialPer) {
socialPerSum = socialPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString());
}
//社保单位
if (StringUtils.isNotBlank(baseParam.getSocialPaymentComString())) {
List<BigDecimal> socialCom = new ArrayList<>();
HashMap<String, String> archivesCom = JSON.parseObject(baseParam.getSocialPaymentComString(), new HashMap<String, String>().getClass());
archivesCom.forEach((k, v) -> {
BigDecimal result = new BigDecimal(v);
socialCom.add(result);
});
insuranceAccountDetailPO.setSocialComJson(baseParam.getSocialPaymentComString());
BigDecimal socialComSum = new BigDecimal("0");
for (BigDecimal bigDecimal : socialCom) {
socialComSum = socialComSum.add(bigDecimal);
}
insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString());
}
}
public void accountEndowmentInsuranceByData(InsuranceAccountDetailPO insuranceAccountDetailPO, SupplementAccountBaseParam baseParam, List<Long> ids) {
//社保个人
if (StringUtils.isNotBlank(baseParam.getSocialPaymentPerString())) {
List<BigDecimal> socialPer = new ArrayList<>();
HashMap<String, String> archivesPerson = JSON.parseObject(baseParam.getSocialPaymentPerString(), new HashMap<String, String>().getClass());
HashMap<String, String> socialPerson = new HashMap<>();
archivesPerson.forEach((k, v) -> {
if (ids.contains(Long.valueOf(k))) {
socialPerson.put(k, v);
BigDecimal result = new BigDecimal(v);
socialPer.add(result);
}
});
insuranceAccountDetailPO.setSocialPerJson(JSON.toJSONString(socialPerson));
BigDecimal socialPerSum = new BigDecimal("0");
for (BigDecimal bigDecimal : socialPer) {
socialPerSum = socialPerSum.add(bigDecimal);
}
insuranceAccountDetailPO.setSocialPerSum(socialPerSum.toPlainString());
}
//社保单位
if (StringUtils.isNotBlank(baseParam.getSocialPaymentComString())) {
List<BigDecimal> socialCom = new ArrayList<>();
HashMap<String, String> archivesCom = JSON.parseObject(baseParam.getSocialPaymentComString(), new HashMap<String, String>().getClass());
HashMap<String, String> socialComMap = new HashMap<>();
archivesCom.forEach((k, v) -> {
if (ids.contains(Long.valueOf(k))) {
socialComMap.put(k, v);
BigDecimal result = new BigDecimal(v);
socialCom.add(result);
}
});
insuranceAccountDetailPO.setSocialComJson(JSON.toJSONString(socialComMap));
BigDecimal socialComSum = new BigDecimal("0");
for (BigDecimal bigDecimal : socialCom) {
socialComSum = socialComSum.add(bigDecimal);
}
insuranceAccountDetailPO.setSocialComSum(socialComSum.toPlainString());
}
}
2022-04-11 19:07:35 +08:00
}