2022-04-08 19:08:59 +08:00
|
|
|
|
package com.engine.salary.service.impl;
|
|
|
|
|
|
|
2022-04-12 19:25:19 +08:00
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
import com.engine.core.impl.Service;
|
2022-04-29 17:15:22 +08:00
|
|
|
|
import com.engine.salary.cache.SalaryCacheKey;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
import com.engine.salary.common.LocalDateRange;
|
2022-12-12 16:42:44 +08:00
|
|
|
|
import com.engine.salary.encrypt.EncryptUtil;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO;
|
2022-07-11 17:31:33 +08:00
|
|
|
|
import com.engine.salary.entity.report.bo.SalaryAcctResultReportBO;
|
|
|
|
|
|
import com.engine.salary.entity.report.po.SalaryAcctResultReportPO;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import com.engine.salary.entity.salaryacct.bo.SalaryAcctCalculateBO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryacct.bo.SalaryAcctCalculatePriorityBO;
|
2022-09-27 15:47:13 +08:00
|
|
|
|
import com.engine.salary.entity.salaryacct.bo.SalaryAcctFormulaBO;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
import com.engine.salary.entity.salaryacct.bo.SalaryAcctResultBO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryacct.dto.ConsolidatedTaxDetailDTO;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import com.engine.salary.entity.salaryacct.dto.SalaryAcctProgressDTO;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultDetailDTO;
|
2022-08-02 14:58:18 +08:00
|
|
|
|
import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultListColumnDTO;
|
2022-11-17 09:28:40 +08:00
|
|
|
|
import com.engine.salary.entity.salaryacct.param.*;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultTempPO;
|
2022-04-28 15:02:11 +08:00
|
|
|
|
import com.engine.salary.entity.salaryformula.ExpressFormula;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
2022-08-02 14:58:18 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.dto.*;
|
2022-08-24 10:31:42 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.po.*;
|
2022-05-31 16:41:11 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
2022-11-17 09:28:40 +08:00
|
|
|
|
import com.engine.salary.enums.SalaryValueTypeEnum;
|
|
|
|
|
|
import com.engine.salary.enums.salaryaccounting.LockStatusEnum;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum;
|
2022-09-27 15:47:13 +08:00
|
|
|
|
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
import com.engine.salary.enums.salarysob.IncomeCategoryEnum;
|
|
|
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
|
|
|
|
|
import com.engine.salary.mapper.salaryacct.SalaryAcctResultMapper;
|
|
|
|
|
|
import com.engine.salary.service.*;
|
|
|
|
|
|
import com.engine.salary.util.SalaryDateUtil;
|
|
|
|
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
|
|
|
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
2022-04-12 19:25:19 +08:00
|
|
|
|
import com.engine.salary.util.db.MapperProxyFactory;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
import com.engine.salary.util.page.PageInfo;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import com.google.common.collect.Lists;
|
2022-08-02 14:58:18 +08:00
|
|
|
|
import com.google.common.collect.Maps;
|
2022-11-17 09:28:40 +08:00
|
|
|
|
import com.google.common.collect.Sets;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import com.weaver.util.threadPool.ThreadPoolUtil;
|
|
|
|
|
|
import com.weaver.util.threadPool.constant.ModulePoolEnum;
|
|
|
|
|
|
import com.weaver.util.threadPool.entity.LocalRunnable;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import org.apache.commons.collections4.MapUtils;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2022-08-02 14:58:18 +08:00
|
|
|
|
import org.apache.commons.lang3.math.NumberUtils;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
2022-04-12 19:25:19 +08:00
|
|
|
|
import weaver.hrm.User;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import java.math.BigDecimal;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
import java.util.*;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import java.util.concurrent.BlockingDeque;
|
|
|
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
|
|
|
import java.util.concurrent.LinkedBlockingDeque;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 薪资核算结果
|
|
|
|
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author qiantao
|
|
|
|
|
|
* @version 1.0
|
|
|
|
|
|
**/
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
|
public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctResultService {
|
2022-12-12 16:42:44 +08:00
|
|
|
|
private EncryptUtil encryptUtil = new EncryptUtil();
|
2022-04-08 19:08:59 +08:00
|
|
|
|
|
2022-04-29 17:15:22 +08:00
|
|
|
|
private SalaryAcctResultMapper getSalaryAcctResultMapper() {
|
2022-04-12 19:25:19 +08:00
|
|
|
|
return MapperProxyFactory.getProxy(SalaryAcctResultMapper.class);
|
|
|
|
|
|
}
|
2022-04-29 17:15:22 +08:00
|
|
|
|
|
2022-04-12 19:25:19 +08:00
|
|
|
|
private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) {
|
2022-07-11 17:31:33 +08:00
|
|
|
|
return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user);
|
2022-04-12 19:25:19 +08:00
|
|
|
|
}
|
2022-04-29 17:15:22 +08:00
|
|
|
|
|
2022-04-12 19:25:19 +08:00
|
|
|
|
private SalarySobItemService getSalarySobItemService(User user) {
|
2022-07-11 17:31:33 +08:00
|
|
|
|
return ServiceUtil.getService(SalarySobItemServiceImpl.class, user);
|
2022-04-12 19:25:19 +08:00
|
|
|
|
}
|
2022-04-29 17:15:22 +08:00
|
|
|
|
|
2022-04-12 19:25:19 +08:00
|
|
|
|
private SalaryItemService getSalaryItemService(User user) {
|
2022-07-11 17:31:33 +08:00
|
|
|
|
return ServiceUtil.getService(SalaryItemServiceImpl.class, user);
|
2022-04-12 19:25:19 +08:00
|
|
|
|
}
|
2022-04-29 17:15:22 +08:00
|
|
|
|
|
2022-04-12 19:25:19 +08:00
|
|
|
|
private SalarySobEmpFieldService getSalarySobEmpFieldService(User user) {
|
2022-07-11 17:31:33 +08:00
|
|
|
|
return ServiceUtil.getService(SalarySobEmpFieldServiceImpl.class, user);
|
2022-04-12 19:25:19 +08:00
|
|
|
|
}
|
2022-04-29 17:15:22 +08:00
|
|
|
|
|
2022-04-12 19:25:19 +08:00
|
|
|
|
private SalarySobService getSalarySobService(User user) {
|
2022-07-11 17:31:33 +08:00
|
|
|
|
return ServiceUtil.getService(SalarySobServiceImpl.class, user);
|
2022-04-12 19:25:19 +08:00
|
|
|
|
}
|
2022-04-29 17:15:22 +08:00
|
|
|
|
|
2022-04-12 19:25:19 +08:00
|
|
|
|
private SalaryAcctRecordService getSalaryAcctRecordService(User user) {
|
2022-07-11 17:31:33 +08:00
|
|
|
|
return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user);
|
2022-04-12 19:25:19 +08:00
|
|
|
|
}
|
2022-04-29 17:15:22 +08:00
|
|
|
|
|
2022-05-31 21:05:59 +08:00
|
|
|
|
private TaxAgentService getTaxAgentService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
|
2022-05-31 16:41:11 +08:00
|
|
|
|
}
|
2022-04-08 19:08:59 +08:00
|
|
|
|
|
2022-04-12 19:25:19 +08:00
|
|
|
|
private SalaryEmployeeService getSalaryEmployeeService(User user) {
|
2022-07-11 17:31:33 +08:00
|
|
|
|
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
|
2022-04-12 19:25:19 +08:00
|
|
|
|
}
|
2022-04-29 17:15:22 +08:00
|
|
|
|
|
2022-04-12 19:25:19 +08:00
|
|
|
|
private SalaryFormulaService getSalaryFormulaService(User user) {
|
2022-07-11 17:31:33 +08:00
|
|
|
|
return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user);
|
2022-04-12 19:25:19 +08:00
|
|
|
|
}
|
2022-04-29 17:15:22 +08:00
|
|
|
|
|
2022-04-12 19:25:19 +08:00
|
|
|
|
private SalarySobAdjustRuleService getSalarySobAdjustRuleService(User user) {
|
2022-07-11 17:31:33 +08:00
|
|
|
|
return ServiceUtil.getService(SalarySobAdjustRuleServiceImpl.class, user);
|
2022-04-12 19:25:19 +08:00
|
|
|
|
}
|
2022-04-29 17:15:22 +08:00
|
|
|
|
|
2022-08-24 10:31:42 +08:00
|
|
|
|
private SalarySobItemHideService getSalarySobItemHideService(User user) {
|
|
|
|
|
|
return (SalarySobItemHideService) ServiceUtil.getService(SalarySobItemHideServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-04-12 19:25:19 +08:00
|
|
|
|
private SalaryAcctCalculateService getSalaryAcctCalculateService(User user) {
|
2022-07-11 17:31:33 +08:00
|
|
|
|
return ServiceUtil.getService(SalaryAcctCalculateServiceImpl.class, user);
|
2022-04-12 19:25:19 +08:00
|
|
|
|
}
|
2022-04-29 17:15:22 +08:00
|
|
|
|
|
|
|
|
|
|
private SalaryAcctProgressService getSalaryAcctProgressService(User user) {
|
2022-07-11 17:31:33 +08:00
|
|
|
|
return ServiceUtil.getService(SalaryAcctProgressServiceImpl.class, user);
|
2022-04-29 17:15:22 +08:00
|
|
|
|
}
|
2022-04-08 19:08:59 +08:00
|
|
|
|
|
|
|
|
|
|
private DataSourceTransactionManager dataSourceTransactionManager;
|
|
|
|
|
|
|
2022-04-12 19:25:19 +08:00
|
|
|
|
private SalaryAcctResultTempService getSalaryAcctResultTempService(User user) {
|
2022-07-11 17:31:33 +08:00
|
|
|
|
return ServiceUtil.getService(SalaryAcctResultTempServiceImpl.class, user);
|
2022-04-12 19:25:19 +08:00
|
|
|
|
}
|
2022-04-07 16:54:10 +08:00
|
|
|
|
// private LoggerTemplate salaryAcctRecordLoggerTemplate;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
|
2022-04-28 15:02:11 +08:00
|
|
|
|
private SIAccountService getSIAccountService(User user) {
|
2022-07-11 17:31:33 +08:00
|
|
|
|
return ServiceUtil.getService(SIAccountServiceImpl.class, user);
|
2022-04-28 15:02:11 +08:00
|
|
|
|
}
|
2022-04-08 19:08:59 +08:00
|
|
|
|
|
2022-04-12 19:25:19 +08:00
|
|
|
|
private AttendQuoteFieldService getAttendQuoteFieldService(User user) {
|
2022-07-11 17:31:33 +08:00
|
|
|
|
return ServiceUtil.getService(AttendQuoteFieldServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SalaryAcctReportService getSalaryAcctReportService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalaryAcctReportServiceImpl.class, user);
|
2022-04-12 19:25:19 +08:00
|
|
|
|
}
|
2022-04-29 17:15:22 +08:00
|
|
|
|
|
2022-08-24 10:31:42 +08:00
|
|
|
|
private SalarySobItemGroupService getSalarySobItemGroupService(User user) {
|
|
|
|
|
|
return (SalarySobItemGroupService) ServiceUtil.getService(SalarySobItemGroupServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-02 17:35:14 +08:00
|
|
|
|
private SalarySobBackItemService getSalarySobBackItemService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalarySobBackItemServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-08-24 10:31:42 +08:00
|
|
|
|
|
2022-04-12 19:25:19 +08:00
|
|
|
|
private SalaryCheckResultService salaryCheckResultService;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalaryAcctResultPO> listBySalaryAcctRecordIds(Collection<Long> salaryAcctRecordIds) {
|
|
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctRecordIds)) {
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
|
}
|
2022-07-11 17:31:33 +08:00
|
|
|
|
List<SalaryAcctResultPO> salaryAcctResultPOS = getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctRecordIds(salaryAcctRecordIds).build());
|
2022-12-12 16:42:44 +08:00
|
|
|
|
encryptUtil.decryptList(salaryAcctResultPOS, SalaryAcctResultPO.class);
|
2022-05-24 09:23:17 +08:00
|
|
|
|
return salaryAcctResultPOS;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalaryAcctResultPO> listBySalaryAcctEmployeeId(Long salaryAcctEmployeeId) {
|
2022-05-24 09:23:17 +08:00
|
|
|
|
List<SalaryAcctResultPO> salaryAcctResultPOS = getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctEmpId(salaryAcctEmployeeId).build());
|
2022-12-12 16:42:44 +08:00
|
|
|
|
encryptUtil.decryptList(salaryAcctResultPOS, SalaryAcctResultPO.class);
|
2022-05-24 09:23:17 +08:00
|
|
|
|
// 解密
|
|
|
|
|
|
return salaryAcctResultPOS;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalaryAcctResultPO> listBySalaryAcctEmployeeIds(Collection<Long> salaryAcctEmployeeIds) {
|
|
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctEmployeeIds)) {
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
|
}
|
2023-05-04 11:56:34 +08:00
|
|
|
|
List<List<Long>> partition = Lists.partition((List<Long>) salaryAcctEmployeeIds, 2000);
|
|
|
|
|
|
List<SalaryAcctResultPO> salaryAcctResultPOS = new ArrayList<>();
|
|
|
|
|
|
partition.forEach(empIds -> {
|
|
|
|
|
|
salaryAcctResultPOS.addAll(getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctEmpIds(empIds).build()));
|
|
|
|
|
|
});
|
2022-05-24 09:23:17 +08:00
|
|
|
|
// 解密
|
2022-12-12 16:42:44 +08:00
|
|
|
|
encryptUtil.decryptList(salaryAcctResultPOS, SalaryAcctResultPO.class);
|
2022-05-24 09:23:17 +08:00
|
|
|
|
return salaryAcctResultPOS;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalaryAcctResultPO> listBySalaryAcctRecordIdsAndEmployeeIds(Collection<Long> salaryAcctRecordIds, Collection<Long> employeeIds) {
|
|
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctRecordIds) || CollectionUtils.isEmpty(employeeIds)) {
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
|
}
|
2023-05-04 11:56:34 +08:00
|
|
|
|
List<List<Long>> partition = Lists.partition((List<Long>) employeeIds, 2000);
|
|
|
|
|
|
List<SalaryAcctResultPO> salaryAcctResultPOS = new ArrayList<>();
|
|
|
|
|
|
partition.forEach(empIds -> {
|
|
|
|
|
|
salaryAcctResultPOS.addAll(getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctRecordIds(salaryAcctRecordIds).employeeIds(empIds).build()));
|
|
|
|
|
|
});
|
2022-12-12 16:42:44 +08:00
|
|
|
|
encryptUtil.decryptList(salaryAcctResultPOS, SalaryAcctResultPO.class);
|
2022-05-24 09:23:17 +08:00
|
|
|
|
return salaryAcctResultPOS;
|
2022-04-08 19:08:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public SalaryAcctResultDetailDTO getBySalaryAcctEmployeeId(Long salaryAcctEmployeeId) {
|
|
|
|
|
|
// 查询薪资核算人员
|
2022-04-12 19:25:19 +08:00
|
|
|
|
SalaryAcctEmployeePO salaryAcctEmployeePO = getSalaryAcctEmployeeService(user).getById(salaryAcctEmployeeId);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
if (Objects.isNull(salaryAcctEmployeePO)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98831, "薪资核算人员不存在或已被删除"));
|
|
|
|
|
|
}
|
2022-12-02 17:35:14 +08:00
|
|
|
|
// 查询是否是回算
|
|
|
|
|
|
SalaryAcctRecordPO byId = getSalaryAcctRecordService(user).getById(salaryAcctEmployeePO.getSalaryAcctRecordId());
|
|
|
|
|
|
boolean isBackCal = Objects.equals(byId.getBackCalcStatus(), 1);
|
2022-08-24 10:31:42 +08:00
|
|
|
|
//----------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
// 查询薪资账套的薪资项目分类
|
|
|
|
|
|
List<SalarySobItemGroupPO> salarySobItemGroupPOS = getSalarySobItemGroupService(user).listBySalarySobIdWithItemHide(salaryAcctEmployeePO.getSalarySobId());
|
|
|
|
|
|
// 获取关闭显示的分类
|
|
|
|
|
|
List<Long> hideGroupIDs = getSalarySobItemHideService(user).listHideGroupBysalarySobId(SalarySobItemHidePO.builder().salarySobId(salaryAcctEmployeePO.getSalarySobId()).isGroup(1).build());
|
|
|
|
|
|
// 过滤关闭显示的薪资项目分类
|
|
|
|
|
|
salarySobItemGroupPOS = salarySobItemGroupPOS.stream().filter(group -> !(hideGroupIDs.contains(group.getId()))).collect(Collectors.toList());
|
|
|
|
|
|
// 获取薪资项目分类ID
|
|
|
|
|
|
List<Long> salarySobItemGroupIds = salarySobItemGroupPOS.stream().map(SalarySobItemGroupPO::getId).collect(Collectors.toList());
|
2023-03-02 11:25:25 +08:00
|
|
|
|
//加上未分类
|
|
|
|
|
|
salarySobItemGroupIds.add(0L);
|
2022-08-24 10:31:42 +08:00
|
|
|
|
|
|
|
|
|
|
// 查询薪资账套的薪资项目副本(已经过滤关闭分类显示按钮的薪资项目)
|
2022-09-27 15:47:13 +08:00
|
|
|
|
List<SalarySobItemPO> salarySobItemPOS = getSalarySobItemService(user).listBySalarySobIdAndGroupId(salaryAcctEmployeePO.getSalarySobId(), salarySobItemGroupIds);
|
2022-08-24 10:31:42 +08:00
|
|
|
|
//----------------------------------------------
|
|
|
|
|
|
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询薪资核算所用薪资账套的薪资项目副本
|
2022-08-24 10:31:42 +08:00
|
|
|
|
// List<SalarySobItemPO> salarySobItemPOS = getSalarySobItemService(user).listBySalarySobId(salaryAcctEmployeePO.getSalarySobId());
|
|
|
|
|
|
// 获取关闭显示的薪资项目
|
|
|
|
|
|
List<Long> hideItemIDs = getSalarySobItemHideService(user).listHideGroupBysalarySobId(SalarySobItemHidePO.builder().salarySobId(salaryAcctEmployeePO.getSalarySobId()).isGroup(0).build());
|
|
|
|
|
|
// 过滤薪资项目
|
2022-09-27 15:47:13 +08:00
|
|
|
|
salarySobItemPOS = salarySobItemPOS.stream().filter(item -> !(hideItemIDs.contains(item.getSalaryItemId()))).collect(Collectors.toList());
|
2022-08-24 10:31:42 +08:00
|
|
|
|
|
2022-12-02 17:35:14 +08:00
|
|
|
|
// 查询已发补发薪资项目
|
|
|
|
|
|
List<SalarySobBackItemPO> salarySobBackItemPOList = Collections.emptyList();
|
|
|
|
|
|
List<SalaryItemPO> salaryBackItemPOS = Collections.emptyList();
|
|
|
|
|
|
// key:账套中回算薪资项目的薪资项目id value:账套中回算薪资项目所对应的公式内容
|
|
|
|
|
|
Map<Long, String> salaryBackItemFormula = new HashMap<>();
|
2023-05-04 11:56:34 +08:00
|
|
|
|
if (isBackCal) {
|
2022-12-02 17:35:14 +08:00
|
|
|
|
salarySobBackItemPOList = getSalarySobBackItemService(user).listBySalarySobId(byId.getSalarySobId());
|
|
|
|
|
|
Set<Long> salarySobBackItemIds = SalaryEntityUtil.properties(salarySobBackItemPOList, SalarySobBackItemPO::getSalaryItemId);
|
|
|
|
|
|
salaryBackItemPOS = getSalaryItemService(user).listByIds(salarySobBackItemIds);
|
|
|
|
|
|
// 查询薪资账套中已发补发的公式内容
|
|
|
|
|
|
List<ExpressFormula> expressFormulas = getSalaryFormulaService(user).listExpressFormula(SalaryEntityUtil.properties(salarySobBackItemPOList, SalarySobBackItemPO::getFormulaId));
|
|
|
|
|
|
Map<Long, String> expressFormulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula);
|
2023-05-04 11:56:34 +08:00
|
|
|
|
for (SalarySobBackItemPO salarySobBackItemPO : salarySobBackItemPOList) {
|
2022-12-02 17:35:14 +08:00
|
|
|
|
String exp = Objects.equals(expressFormulaMap.get(salarySobBackItemPO.getFormulaId()), 0) ? "输入" : expressFormulaMap.get(salarySobBackItemPO.getFormulaId());
|
2023-05-04 11:56:34 +08:00
|
|
|
|
salaryBackItemFormula.put(salarySobBackItemPO.getSalaryItemId(), exp);
|
2022-12-02 17:35:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-08-24 10:31:42 +08:00
|
|
|
|
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询薪资项目
|
|
|
|
|
|
Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
|
2022-04-12 19:25:19 +08:00
|
|
|
|
List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询薪资核算所用薪资账套的人员信息字段
|
2022-04-12 19:25:19 +08:00
|
|
|
|
List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = getSalarySobEmpFieldService(user).listBySalarySobId(salaryAcctEmployeePO.getSalarySobId());
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询人员信息
|
2022-04-12 19:25:19 +08:00
|
|
|
|
DataCollectionEmployee simpleEmployee = getSalaryEmployeeService(user).getEmployeeById(salaryAcctEmployeePO.getEmployeeId());
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询薪资核算结果
|
|
|
|
|
|
List<SalaryAcctResultPO> salaryAcctResultPOS = listBySalaryAcctEmployeeId(salaryAcctEmployeeId);
|
|
|
|
|
|
// 查询个税扣缴义务人
|
2022-05-31 16:41:11 +08:00
|
|
|
|
TaxAgentPO taxAgent = getTaxAgentService(user).getById(salaryAcctEmployeePO.getTaxAgentId());
|
2022-08-24 10:31:42 +08:00
|
|
|
|
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 转换成薪资核算结果详情dto
|
2022-12-02 17:35:14 +08:00
|
|
|
|
return SalaryAcctResultBO.convert2DetailDTO(simpleEmployee, taxAgent, salaryAcctEmployeePO, salarySobEmpFieldPOS, salarySobItemPOS, salaryItemPOS, salaryAcctResultPOS, salarySobBackItemPOList, salaryBackItemPOS, salaryBackItemFormula);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public PageInfo<Map<String, Object>> listPageByParam(SalaryAcctResultQueryParam queryParam) {
|
|
|
|
|
|
// 查询薪资核算人员(分页)
|
2022-04-12 19:25:19 +08:00
|
|
|
|
PageInfo<SalaryAcctEmployeePO> page = getSalaryAcctEmployeeService(user).listPageByResultQueryParam(queryParam);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询薪资核算结果
|
|
|
|
|
|
List<Map<String, Object>> data = listBySalaryAcctEmployees(page.getList(), queryParam);
|
|
|
|
|
|
// 薪资核算结果的分页结果
|
|
|
|
|
|
PageInfo<Map<String, Object>> resultPage = new PageInfo<>();
|
|
|
|
|
|
resultPage.setList(data);
|
2022-04-19 19:32:09 +08:00
|
|
|
|
resultPage.setTotal(page.getTotal());
|
|
|
|
|
|
resultPage.setPageNum(page.getPageNum());
|
|
|
|
|
|
resultPage.setPageSize(page.getPageSize());
|
2022-04-08 19:08:59 +08:00
|
|
|
|
return resultPage;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-27 15:47:13 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public Map<String, Object> sumRow(SalaryAcctResultQueryParam queryParam) {
|
|
|
|
|
|
// 查询薪资核算人员
|
|
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listByResultQueryParam(queryParam);
|
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) {
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 查询薪资核算记录
|
|
|
|
|
|
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(queryParam.getSalaryAcctRecordId());
|
|
|
|
|
|
if (Objects.isNull(salaryAcctRecordPO)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
|
|
|
|
|
|
}
|
|
|
|
|
|
// 查询薪资核算所用薪资账套的薪资项目
|
|
|
|
|
|
List<SalarySobItemPO> salarySobItemPOS = getSalarySobItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
|
|
|
|
|
|
Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
|
|
|
|
|
|
List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds);
|
|
|
|
|
|
// 查询薪资核算结果
|
2023-05-04 11:56:34 +08:00
|
|
|
|
List<Long> salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId,Collectors.toList());
|
2022-09-27 15:47:13 +08:00
|
|
|
|
List<SalaryAcctResultPO> salaryAcctResultPOS = listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds);
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
|
Map<Long, List<SalaryAcctResultPO>> acctResultMap = SalaryEntityUtil.group2Map(salaryAcctResultPOS, SalaryAcctResultPO::getSalaryItemId);
|
|
|
|
|
|
salaryItemPOS.stream().filter(item -> SalaryDataTypeEnum.NUMBER.getValue().equals(item.getDataType())).forEach(item -> {
|
2022-09-29 15:34:21 +08:00
|
|
|
|
BigDecimal sum = Optional.ofNullable(acctResultMap.get(item.getId()))
|
|
|
|
|
|
.orElse(new ArrayList<>())
|
|
|
|
|
|
.stream()
|
2022-09-27 15:47:13 +08:00
|
|
|
|
.map(SalaryAcctResultPO::getResultValue)
|
|
|
|
|
|
.filter(NumberUtils::isCreatable)
|
|
|
|
|
|
.map(BigDecimal::new)
|
|
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
2022-12-13 16:39:39 +08:00
|
|
|
|
map.put(item.getId().toString(), SalaryAcctFormulaBO.roundResultValue(sum.toString(), item, Collections.emptyList(), Collections.emptyMap()));
|
2022-09-27 15:47:13 +08:00
|
|
|
|
});
|
|
|
|
|
|
return map;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-04-08 19:08:59 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public List<Map<String, Object>> listByParam(SalaryAcctResultQueryParam queryParam) {
|
|
|
|
|
|
// 查询薪资核算人员
|
2022-04-12 19:25:19 +08:00
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listByResultQueryParam(queryParam);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询薪资核算结果
|
|
|
|
|
|
return listBySalaryAcctEmployees(salaryAcctEmployeePOS, queryParam);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 根据薪资核算人员查询薪资核算结果
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param salaryAcctEmployeePOS 薪资核算人员
|
|
|
|
|
|
* @param queryParam 列表查询条件
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2022-07-11 17:31:33 +08:00
|
|
|
|
private List<Map<String, Object>> listBySalaryAcctEmployees(List<SalaryAcctEmployeePO> salaryAcctEmployeePOS, SalaryAcctResultQueryParam queryParam) {
|
2022-04-08 19:08:59 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) {
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
|
}
|
|
|
|
|
|
// 查询薪资核算记录
|
2022-04-12 19:25:19 +08:00
|
|
|
|
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(queryParam.getSalaryAcctRecordId());
|
2022-04-08 19:08:59 +08:00
|
|
|
|
if (Objects.isNull(salaryAcctRecordPO)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
|
|
|
|
|
|
}
|
2022-12-02 17:35:14 +08:00
|
|
|
|
boolean isBackCalc = Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), 1);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询薪资核算所用的薪资账套的员工信息字段
|
2022-04-12 19:25:19 +08:00
|
|
|
|
List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = getSalarySobEmpFieldService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询薪资核算所用薪资账套的薪资项目
|
2022-04-12 19:25:19 +08:00
|
|
|
|
List<SalarySobItemPO> salarySobItemPOS = getSalarySobItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
|
2022-04-08 19:08:59 +08:00
|
|
|
|
Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
|
2022-12-02 17:35:14 +08:00
|
|
|
|
// 是否是回算
|
|
|
|
|
|
List<SalarySobBackItemPO> salarySobBackItemPOList = Collections.emptyList();
|
|
|
|
|
|
if (isBackCalc) {
|
|
|
|
|
|
// 根据薪资账套获取回算信息项
|
|
|
|
|
|
salarySobBackItemPOList = getSalarySobBackItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
|
|
|
|
|
|
salaryItemIds.addAll(salarySobBackItemPOList.stream().map(SalarySobBackItemPO::getSalaryItemId).collect(Collectors.toList()));
|
|
|
|
|
|
}
|
2022-04-12 19:25:19 +08:00
|
|
|
|
List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询薪资核算结果
|
2023-05-04 11:56:34 +08:00
|
|
|
|
List<Long> salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId,Collectors.toList());
|
2022-04-08 19:08:59 +08:00
|
|
|
|
List<SalaryAcctResultPO> salaryAcctResultPOS = listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds);
|
|
|
|
|
|
// 查询人员信息
|
|
|
|
|
|
List<Long> employeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getEmployeeId, Collectors.toList());
|
2023-04-12 15:27:35 +08:00
|
|
|
|
List<DataCollectionEmployee> simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询个税扣缴义务人
|
|
|
|
|
|
Set<Long> taxAgentIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getTaxAgentId);
|
2022-05-31 16:41:11 +08:00
|
|
|
|
List<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listByIds(taxAgentIds);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 判断是否存在合并计税
|
|
|
|
|
|
Set<Long> salaryAcctEmployeeIds4ConsolidatedTax;
|
|
|
|
|
|
if (StringUtils.isNotEmpty(queryParam.getConsolidatedTaxation())) {
|
|
|
|
|
|
// 如果查询条件中含有"合并计税",那么在入参中的salaryAcctEmployeePOS就已经全部都是存在合并计税的人员了(前面已经过滤了),无需再次查询合并计税的人员
|
|
|
|
|
|
salaryAcctEmployeeIds4ConsolidatedTax = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 如果查询条件中没有包含"合并计税",那么就需要查询出存在合并计税的人,标记给前端
|
2022-07-11 17:31:33 +08:00
|
|
|
|
SalaryAcctEmployeeQueryParam accEmployeeQueryParam = SalaryAcctEmployeeQueryParam.builder().salaryAcctRecordId(queryParam.getSalaryAcctRecordId()).ids(SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId)).build();
|
2022-04-12 19:25:19 +08:00
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS4ConsolidatedTax = getSalaryAcctEmployeeService(user).listByParam4ConsolidatedTax(accEmployeeQueryParam);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
salaryAcctEmployeeIds4ConsolidatedTax = SalaryEntityUtil.properties(salaryAcctEmployeePOS4ConsolidatedTax, SalaryAcctEmployeePO::getId);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 查询公式详情
|
|
|
|
|
|
Set<Long> formulaIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getFormulaId);
|
2022-12-06 15:29:08 +08:00
|
|
|
|
// 获取回算公式
|
2022-12-02 17:35:14 +08:00
|
|
|
|
if (isBackCalc) {
|
2023-05-04 11:56:34 +08:00
|
|
|
|
formulaIds.addAll(salarySobBackItemPOList.stream().map(SalarySobBackItemPO::getFormulaId).collect(Collectors.toList()));
|
2022-12-02 17:35:14 +08:00
|
|
|
|
}
|
2022-04-12 19:25:19 +08:00
|
|
|
|
List<ExpressFormula> expressFormulas = getSalaryFormulaService(user).listExpressFormula(formulaIds);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
Map<Long, String> expressFormulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula);
|
|
|
|
|
|
Map<Long, String> customParameters = SalaryEntityUtil.convert2Map(salarySobItemPOS, SalarySobItemPO::getSalaryItemId, salarySobItemPO -> {
|
|
|
|
|
|
if (salarySobItemPO.getFormulaId() <= 0) {
|
|
|
|
|
|
return SalaryI18nUtil.getI18nLabel(92004, "输入/导入");
|
|
|
|
|
|
}
|
|
|
|
|
|
return expressFormulaMap.getOrDefault(salarySobItemPO.getFormulaId(), StringUtils.EMPTY);
|
|
|
|
|
|
});
|
2022-12-02 17:35:14 +08:00
|
|
|
|
// 回算公式内容转换
|
|
|
|
|
|
Map<Long, String> customBackCalcParameters = SalaryEntityUtil.convert2Map(salarySobBackItemPOList, SalarySobBackItemPO::getSalaryItemId, salarySobBackItemPO -> {
|
|
|
|
|
|
if (salarySobBackItemPO.getFormulaId() <= 0) {
|
|
|
|
|
|
return SalaryI18nUtil.getI18nLabel(92004, "输入/导入");
|
|
|
|
|
|
}
|
|
|
|
|
|
return expressFormulaMap.getOrDefault(salarySobBackItemPO.getFormulaId(), StringUtils.EMPTY);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 转换成薪资核算结果列表
|
2022-12-02 17:35:14 +08:00
|
|
|
|
return SalaryAcctResultBO.buildTableData(salaryItemPOS, salarySobEmpFieldPOS, simpleEmployees, salaryAcctEmployeePOS, salaryAcctResultPOS, taxAgentPOS,
|
|
|
|
|
|
salaryAcctEmployeeIds4ConsolidatedTax, customParameters, customBackCalcParameters, isBackCalc);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public ConsolidatedTaxDetailDTO getConsolidatedTaxDetail(Long salaryAcctEmployeeId) {
|
|
|
|
|
|
// 查询当前的薪资核算人员
|
2022-04-12 19:25:19 +08:00
|
|
|
|
SalaryAcctEmployeePO salaryAcctEmployeePO = getSalaryAcctEmployeeService(user).getById(salaryAcctEmployeeId);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
if (Objects.isNull(salaryAcctEmployeePO)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98831, "薪资核算人员不存在或已被删除"));
|
|
|
|
|
|
}
|
|
|
|
|
|
// 查询当前的薪资核算人员的个税扣缴义务人
|
2022-05-31 16:41:11 +08:00
|
|
|
|
TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(salaryAcctEmployeePO.getTaxAgentId());
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询当前的薪资核算人员的人员信息
|
2022-04-12 19:25:19 +08:00
|
|
|
|
DataCollectionEmployee simpleEmployee = getSalaryEmployeeService(user).getEmployeeById(salaryAcctEmployeePO.getEmployeeId());
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询当前的薪资核算记录
|
2022-04-12 19:25:19 +08:00
|
|
|
|
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctEmployeePO.getSalaryAcctRecordId());
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询当前薪资核算记录所用的薪资账套
|
2022-04-12 19:25:19 +08:00
|
|
|
|
SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId());
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 当前薪资核算记录所用的薪资账套的员工信息字段
|
2022-04-12 19:25:19 +08:00
|
|
|
|
List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = getSalarySobEmpFieldService(user).listBySalarySobId(salarySobPO.getId());
|
2022-04-08 19:08:59 +08:00
|
|
|
|
|
|
|
|
|
|
List<SalaryAcctRecordPO> salaryAcctRecordPOS = Collections.singletonList(salaryAcctRecordPO);
|
|
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = Collections.singletonList(salaryAcctEmployeePO);
|
|
|
|
|
|
|
|
|
|
|
|
// 如果当前薪资核算记录所用的薪资账套的薪资类型是工资薪金,代表可能存在合并计税
|
|
|
|
|
|
if (Objects.equals(salarySobPO.getIncomeCategory(), IncomeCategoryEnum.WAGES_AND_SALARIES.getValue())) {
|
|
|
|
|
|
// 查询所有薪资类型为工资薪金的账套
|
2022-04-12 19:25:19 +08:00
|
|
|
|
List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByIncomeCategory(IncomeCategoryEnum.WAGES_AND_SALARIES);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询相同税款所属期内的薪资类型为工资薪金的账套的所有核算记录
|
|
|
|
|
|
Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId);
|
|
|
|
|
|
LocalDateRange taxCycleDateRange = SalaryDateUtil.localDate2Range(salaryAcctRecordPO.getTaxCycle());
|
2022-09-13 16:03:55 +08:00
|
|
|
|
salaryAcctRecordPOS = getSalaryAcctRecordService(user).listBySalarySobIdsAndTaxCycle(salarySobIds, taxCycleDateRange);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询当前薪资核算人员所涉及的合并计税的所有薪资核算人员
|
|
|
|
|
|
Set<Long> salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId);
|
2022-07-11 17:31:33 +08:00
|
|
|
|
salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listByRecordIdsAndEmpIdAndTaxAgentId(salaryAcctRecordIds, salaryAcctEmployeePO.getEmployeeId(), salaryAcctEmployeePO.getTaxAgentId());
|
2022-04-08 19:08:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
// 查询薪资核算人员的薪资核算结果
|
2023-05-04 11:56:34 +08:00
|
|
|
|
List<Long> salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId,Collectors.toList());
|
2022-04-08 19:08:59 +08:00
|
|
|
|
List<SalaryAcctResultPO> salaryAcctResultPOS = listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds);
|
|
|
|
|
|
// 查询薪资核算人员所有合并计税的薪资核算记录所用的账套
|
|
|
|
|
|
Set<Long> salarySobIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getSalarySobId);
|
2022-04-12 19:25:19 +08:00
|
|
|
|
List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByIds(salarySobIds);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询薪资项目所引用的薪资项目
|
2022-04-12 19:25:19 +08:00
|
|
|
|
List<SalarySobItemPO> salarySobItemPOS = getSalarySobItemService(user).listBySalarySobIds(salarySobIds);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询薪资项目
|
|
|
|
|
|
Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
|
2022-04-12 19:25:19 +08:00
|
|
|
|
List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 转换成合并计税详情dto
|
2022-07-11 17:31:33 +08:00
|
|
|
|
return SalaryAcctResultBO.convert2ConsolidatedTaxDetailDTO(simpleEmployee, taxAgentPO, salarySobEmpFieldPOS, salaryItemPOS, salaryAcctEmployeePOS, salarySobPOS, salaryAcctRecordPOS, salaryAcctResultPOS);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-08-02 14:58:18 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public Map<String, SalaryAcctResultListColumnDTO> getColumnBySalaryAcctRecordId(Long salaryAcctRecordId) {
|
|
|
|
|
|
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId);
|
|
|
|
|
|
if (Objects.isNull(salaryAcctRecordPO)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
|
|
|
|
|
|
}
|
|
|
|
|
|
Map<String, SalaryAcctResultListColumnDTO> resultMap = Maps.newHashMap();
|
|
|
|
|
|
// 查询薪资核算使用的薪资账套下的薪资项目
|
2022-12-02 17:35:14 +08:00
|
|
|
|
List<SalarySobItemDTO> salarySobItems = Lists.newArrayList();
|
2022-08-02 14:58:18 +08:00
|
|
|
|
SalarySobItemAggregateDTO salarySobItemAggregateDTO = getSalarySobItemService(user).getAggregateBySalarySobId(salaryAcctRecordPO.getSalarySobId());
|
|
|
|
|
|
for (SalarySobItemIncomeCategoryDTO incomeCategoryDTO : salarySobItemAggregateDTO.getIncomeCategories()) {
|
|
|
|
|
|
for (SalarySobItemGroupDTO salarySobItemGroupDTO : incomeCategoryDTO.getItemGroups()) {
|
|
|
|
|
|
for (SalarySobItemDTO salarySobItemDTO : salarySobItemGroupDTO.getItems()) {
|
|
|
|
|
|
SalaryAcctResultListColumnDTO salaryAcctResultListColumnDTO = new SalaryAcctResultListColumnDTO()
|
|
|
|
|
|
.setColumnName(salarySobItemDTO.getName())
|
|
|
|
|
|
.setFormulaId(salarySobItemDTO.getFormulaId())
|
|
|
|
|
|
.setFormulaContent(salarySobItemDTO.getFormulaContent())
|
|
|
|
|
|
.setShowLock((!Objects.equals(salarySobItemDTO.getFormulaId(), NumberUtils.LONG_ZERO) && salarySobItemDTO.isCanEdit())
|
|
|
|
|
|
|| Objects.equals(salarySobItemDTO.getUseInEmployeeSalary(), NumberUtils.INTEGER_ONE));
|
|
|
|
|
|
resultMap.put("" + salarySobItemDTO.getSalaryItemId(), salaryAcctResultListColumnDTO);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
for (SalarySobItemDTO salarySobItemDTO : incomeCategoryDTO.getItems()) {
|
|
|
|
|
|
SalaryAcctResultListColumnDTO salaryAcctResultListColumnDTO = new SalaryAcctResultListColumnDTO()
|
|
|
|
|
|
.setColumnName(salarySobItemDTO.getName())
|
|
|
|
|
|
.setFormulaId(salarySobItemDTO.getFormulaId())
|
|
|
|
|
|
.setFormulaContent(salarySobItemDTO.getFormulaContent())
|
|
|
|
|
|
.setShowLock((!Objects.equals(salarySobItemDTO.getFormulaId(), NumberUtils.LONG_ZERO) && salarySobItemDTO.isCanEdit())
|
|
|
|
|
|
|| Objects.equals(salarySobItemDTO.getUseInEmployeeSalary(), NumberUtils.INTEGER_ONE));
|
|
|
|
|
|
resultMap.put("" + salarySobItemDTO.getSalaryItemId(), salaryAcctResultListColumnDTO);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-12-02 17:35:14 +08:00
|
|
|
|
// 查询回算薪资项目
|
|
|
|
|
|
if (Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), 1)) {
|
|
|
|
|
|
List<SalarySobItemDTO> backCalcItems = salarySobItemAggregateDTO.getBackCalcItems();
|
|
|
|
|
|
for (SalarySobItemDTO backCalcItem : backCalcItems) {
|
|
|
|
|
|
SalaryAcctResultListColumnDTO salaryAcctResultListColumnDTO = new SalaryAcctResultListColumnDTO()
|
|
|
|
|
|
.setColumnName(backCalcItem.getName())
|
|
|
|
|
|
.setFormulaId(backCalcItem.getFormulaId())
|
|
|
|
|
|
.setFormulaContent(backCalcItem.getFormulaContent())
|
|
|
|
|
|
.setShowLock(true);
|
|
|
|
|
|
resultMap.put("" + backCalcItem.getSalaryItemId(), salaryAcctResultListColumnDTO);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-08-02 14:58:18 +08:00
|
|
|
|
return resultMap;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-04-08 19:08:59 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void save(SalaryAcctResultSaveParam saveParam) {
|
2022-07-11 17:31:33 +08:00
|
|
|
|
|
|
|
|
|
|
List<DataCollectionEmployee> dataCollectionEmployees = getSalaryEmployeeService(user).listAllForReport();
|
|
|
|
|
|
Map<Long, DataCollectionEmployee> emps = SalaryEntityUtil.convert2Map(dataCollectionEmployees, DataCollectionEmployee::getEmployeeId);
|
|
|
|
|
|
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询薪资核算人员
|
2022-04-12 19:25:19 +08:00
|
|
|
|
SalaryAcctEmployeePO salaryAcctEmployeePO = getSalaryAcctEmployeeService(user).getById(saveParam.getSalaryAcctEmpId());
|
2022-04-08 19:08:59 +08:00
|
|
|
|
if (Objects.isNull(salaryAcctEmployeePO)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98831, "薪资核算人员不存在或已被删除"));
|
|
|
|
|
|
}
|
2022-12-02 17:35:14 +08:00
|
|
|
|
// 查询原来的薪资核算结果
|
|
|
|
|
|
List<SalaryAcctResultPO> salaryAcctResultPOSOld = getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctEmpId(saveParam.getSalaryAcctEmpId()).build());
|
|
|
|
|
|
// 解密
|
2023-05-04 11:56:34 +08:00
|
|
|
|
encryptUtil.decryptList(salaryAcctResultPOSOld, SalaryAcctResultPO.class);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 保存参数转换成薪资核算结果po
|
2022-12-02 17:35:14 +08:00
|
|
|
|
List<SalaryAcctResultPO> salaryAcctResultPOS = SalaryAcctResultBO.convert2PO(salaryAcctResultPOSOld, saveParam, salaryAcctEmployeePO, (long) user.getUID());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SalaryAcctRecordPO byId = getSalaryAcctRecordService(user).getById(salaryAcctEmployeePO.getSalaryAcctRecordId());
|
|
|
|
|
|
// 若保存编辑时一同传已发补发,则删除以下代码
|
|
|
|
|
|
// if(byId.getBackCalcStatus() != null && Objects.equals(byId.getBackCalcStatus(),1)){
|
|
|
|
|
|
// // 是回算
|
|
|
|
|
|
// List<Long> salarySobBackItemIds = getSalarySobBackItemService(user).listBySalarySobId(byId.getSalarySobId()).stream().map(SalarySobBackItemPO::getSalaryItemId).collect(Collectors.toList());
|
|
|
|
|
|
// // 获取已发待发的薪资核算结果
|
|
|
|
|
|
// List<SalaryAcctResultPO> salarySobBackItemResultPO = salaryAcctResultPOSOld.stream().filter(po -> salarySobBackItemIds.contains(po.getSalaryItemId())).collect(Collectors.toList());
|
|
|
|
|
|
// salaryAcctResultPOS.addAll(salarySobBackItemResultPO);
|
|
|
|
|
|
// }
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 删除原来的薪资核算结果
|
|
|
|
|
|
deleteBySalaryAcctEmployeeIds(Collections.singleton(saveParam.getSalaryAcctEmpId()));
|
|
|
|
|
|
// 保存薪资核算结果
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(salaryAcctResultPOS)) {
|
2022-06-02 17:01:26 +08:00
|
|
|
|
// 加密
|
2022-12-12 16:42:44 +08:00
|
|
|
|
encryptUtil.encryptList(salaryAcctResultPOS, SalaryAcctResultPO.class);
|
2022-06-16 17:55:26 +08:00
|
|
|
|
List<List<SalaryAcctResultPO>> partition = Lists.partition(salaryAcctResultPOS, 100);
|
|
|
|
|
|
partition.forEach(getSalaryAcctResultMapper()::batchInsert);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
}
|
2022-12-02 17:35:14 +08:00
|
|
|
|
//报表 todo
|
2022-07-11 17:31:33 +08:00
|
|
|
|
getSalaryAcctReportService(user).deleteBySalaryAcctEmpIds(Collections.singleton(saveParam.getSalaryAcctEmpId()));
|
|
|
|
|
|
List<SalaryAcctResultReportPO> salaryAcctResultReportPOS = SalaryAcctResultReportBO.convert2PO(saveParam, salaryAcctEmployeePO, (long) user.getUID(), emps);
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(salaryAcctResultReportPOS)) {
|
|
|
|
|
|
getSalaryAcctReportService(user).batchSave(salaryAcctResultReportPOS);
|
|
|
|
|
|
}
|
2022-07-04 18:58:49 +08:00
|
|
|
|
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询操作日志的targetName
|
2022-07-04 18:58:49 +08:00
|
|
|
|
// String targetName = getSalaryAcctRecordService(user).getLogTargetNameById(salaryAcctEmployeePO.getSalaryAcctRecordId());
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询人员信息
|
2022-07-04 18:58:49 +08:00
|
|
|
|
// DataCollectionEmployee simpleEmployee = getSalaryEmployeeService(user).getEmployeeById(salaryAcctEmployeePO.getEmployeeId());
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 查询个税扣缴义务人
|
2022-05-31 16:41:11 +08:00
|
|
|
|
// TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(salaryAcctEmployeePO.getTaxAgentId());
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// 记录日志
|
2022-04-07 16:54:10 +08:00
|
|
|
|
// String operateDesc = simpleEmployee.getUsername() + "(" + Optional.ofNullable(taxAgentPO).map(TaxAgentPO::getName).orElse(StringUtils.EMPTY) + ")";
|
|
|
|
|
|
// LoggerContext<SalaryCheckResultPO> loggerContext = new LoggerContext<>();
|
|
|
|
|
|
// loggerContext.setTargetId(String.valueOf(salaryAcctEmployeePO.getSalaryAcctRecordId()));
|
|
|
|
|
|
// loggerContext.setTargetName(targetName);
|
|
|
|
|
|
// loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
|
|
|
|
|
|
// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(95783, "编辑薪资核算结果") + ": " + operateDesc);
|
|
|
|
|
|
// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(95783, "编辑薪资核算结果") + ": " + operateDesc);
|
|
|
|
|
|
// loggerContext.setNewValueList(Lists.newArrayList(salaryAcctResultPOS));
|
|
|
|
|
|
// salaryAcctRecordLoggerTemplate.write(loggerContext);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-02 17:35:14 +08:00
|
|
|
|
|
2022-04-08 19:08:59 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void batchSave(Collection<SalaryAcctResultPO> salaryAcctResultPOS) {
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(salaryAcctResultPOS)) {
|
2022-07-11 17:31:33 +08:00
|
|
|
|
List<SalaryAcctResultPO> list = (List<SalaryAcctResultPO>) salaryAcctResultPOS;
|
2022-06-16 17:55:26 +08:00
|
|
|
|
// 数据加密
|
2022-12-12 16:42:44 +08:00
|
|
|
|
encryptUtil.encryptList(list, SalaryAcctResultPO.class);
|
2022-06-16 17:55:26 +08:00
|
|
|
|
List<List<SalaryAcctResultPO>> partition = Lists.partition(list, 100);
|
|
|
|
|
|
partition.forEach(getSalaryAcctResultMapper()::batchInsert);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-07-11 17:31:33 +08:00
|
|
|
|
|
2022-04-08 19:08:59 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void deleteBySalaryAcctEmployeeIds(Collection<Long> salaryAcctEmployeeIds) {
|
2022-04-12 19:25:19 +08:00
|
|
|
|
getSalaryAcctResultMapper().deleteBySalaryAcctEmpIds(salaryAcctEmployeeIds);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-02 17:35:14 +08:00
|
|
|
|
|
2022-04-08 19:08:59 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void deleteByAcctEmployeeIdsAndSalaryItemIds(Collection<Long> salaryAcctEmployeeIds, Collection<Long> salaryItemIds) {
|
2022-04-12 19:25:19 +08:00
|
|
|
|
getSalaryAcctResultMapper().deleteByAcctEmpIdsAndSalaryItemIds(salaryAcctEmployeeIds, salaryItemIds);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void deleteBySalaryAcctRecordIds(Collection<Long> salaryAcctRecordIds) {
|
2022-04-12 19:25:19 +08:00
|
|
|
|
getSalaryAcctResultMapper().deleteBySalaryAcctRecordIds(salaryAcctRecordIds);
|
2022-04-08 19:08:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-04-11 20:17:47 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void calculate(SalaryAcctCalculateParam calculateParam, DataCollectionEmployee simpleEmployee) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 1、查询薪资核算记录
|
2022-04-12 19:25:19 +08:00
|
|
|
|
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(calculateParam.getSalaryAcctRecordId());
|
2022-04-11 20:17:47 +08:00
|
|
|
|
if (Objects.isNull(salaryAcctRecordPO)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
|
|
|
|
|
|
}
|
2022-06-15 17:53:12 +08:00
|
|
|
|
//查询对应账套
|
|
|
|
|
|
SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId());
|
|
|
|
|
|
if (Objects.isNull(salarySobPO)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资账套不存在或已被删除"));
|
|
|
|
|
|
}
|
2022-04-11 20:17:47 +08:00
|
|
|
|
// 1.1、如果薪资核算记录已经归档了,就不能继续核算
|
|
|
|
|
|
if (!Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99148, "当前薪资核算记录已归档,请重新打开后再进行核算"));
|
|
|
|
|
|
}
|
|
|
|
|
|
// 2、查询薪资核算记录的薪资周期、考勤周期等
|
2022-04-12 19:25:19 +08:00
|
|
|
|
SalarySobCycleDTO salarySobCycleDTO = getSalaryAcctRecordService(user).getSalarySobCycleById(calculateParam.getSalaryAcctRecordId());
|
2022-04-11 20:17:47 +08:00
|
|
|
|
// 3、查询薪资核算记录所用薪资账套的薪资项目副本
|
2022-04-12 19:25:19 +08:00
|
|
|
|
List<SalarySobItemPO> salarySobItemPOS = getSalarySobItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
|
2022-04-11 20:17:47 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(salarySobItemPOS)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99151, "当前所用的薪资账套未选择任何薪资项目,无法核算"));
|
|
|
|
|
|
}
|
2022-12-02 17:35:14 +08:00
|
|
|
|
// 回算薪资项目
|
|
|
|
|
|
List<SalarySobBackItemPO> salarySobBackItems = Collections.emptyList();
|
2023-05-04 11:56:34 +08:00
|
|
|
|
if (Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), 1)) {
|
2022-12-02 17:35:14 +08:00
|
|
|
|
salarySobBackItems = getSalarySobBackItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
|
|
|
|
|
|
}
|
2022-04-11 20:17:47 +08:00
|
|
|
|
// 4、查询当前租户的所有薪资项目
|
2022-04-12 19:25:19 +08:00
|
|
|
|
List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listAll();
|
2022-04-11 20:17:47 +08:00
|
|
|
|
// 5、查询薪资核算记录所用薪资账套的调薪计薪规则
|
2022-04-12 19:25:19 +08:00
|
|
|
|
List<SalarySobAdjustRulePO> salarySobAdjustRulePOS = getSalarySobAdjustRuleService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
|
2022-04-28 15:02:11 +08:00
|
|
|
|
// 6、查询社保福利的所有字段
|
|
|
|
|
|
Map<String, String> welfareColumns = getSIAccountService(user).welfareColumns();
|
2022-04-11 20:17:47 +08:00
|
|
|
|
// 7、查询考勤引用的所有字段
|
2022-04-12 19:25:19 +08:00
|
|
|
|
List<AttendQuoteFieldListDTO> attendQuoteFieldListDTOS = getAttendQuoteFieldService(user).listAll();
|
2022-11-17 09:28:40 +08:00
|
|
|
|
|
|
|
|
|
|
//核算锁定值
|
|
|
|
|
|
List<Long> lockSalaryItemIds = salaryAcctRecordPO.getLockSalaryItemIds();
|
2022-11-17 18:53:22 +08:00
|
|
|
|
Map<String, SalaryAcctResultPO> acctResults = new HashMap<>();
|
2022-11-17 09:28:40 +08:00
|
|
|
|
if (CollectionUtils.isNotEmpty(lockSalaryItemIds)) {
|
|
|
|
|
|
List<SalaryAcctResultPO> acctResultPOS = listBySalaryAcctRecordIds(Collections.singleton(calculateParam.getSalaryAcctRecordId()));
|
|
|
|
|
|
acctResults = Optional.ofNullable(acctResultPOS)
|
|
|
|
|
|
.orElse(new ArrayList<>())
|
|
|
|
|
|
.stream()
|
|
|
|
|
|
.filter(po -> lockSalaryItemIds.contains(po.getSalaryItemId()))
|
2022-11-17 18:53:22 +08:00
|
|
|
|
.collect(Collectors.toMap(po -> po.getSalaryItemId() + "_" + po.getSalaryAcctEmpId(), a -> a, (a, b) -> a));
|
2022-11-17 09:28:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-04-11 20:17:47 +08:00
|
|
|
|
// 8、查询公式详情
|
|
|
|
|
|
Set<Long> formulaIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getFormulaId);
|
|
|
|
|
|
formulaIds.addAll(SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getFormulaId));
|
2023-05-04 11:56:34 +08:00
|
|
|
|
formulaIds.addAll(SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getFormulaId));
|
2022-04-14 10:03:49 +08:00
|
|
|
|
List<ExpressFormula> expressFormulas = getSalaryFormulaService(user).listExpressFormula(formulaIds);
|
2022-12-02 17:35:14 +08:00
|
|
|
|
// 本次运算的回算薪资项目所涉及的变量
|
|
|
|
|
|
Set<String> issuedFieldIds = new HashSet<>();
|
2022-04-11 20:17:47 +08:00
|
|
|
|
// 9、计算薪资项目的运算优先级
|
2022-12-02 17:35:14 +08:00
|
|
|
|
List<List<Long>> salarySobItemsWithPriority = SalaryAcctCalculatePriorityBO.calculatePriority(salarySobItemPOS, salaryItemPOS, expressFormulas, salarySobBackItems, issuedFieldIds);
|
2022-04-11 20:17:47 +08:00
|
|
|
|
// 10、根据id查询其他合并计税的薪资核算记录
|
2022-04-12 19:25:19 +08:00
|
|
|
|
List<SalaryAcctRecordPO> otherSalaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4OtherConsolidatedTax(salaryAcctRecordPO.getId());
|
2022-04-11 20:17:47 +08:00
|
|
|
|
// 11、查询本次核算人员
|
|
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS;
|
|
|
|
|
|
if (CollectionUtils.isEmpty(calculateParam.getIds())) {
|
2022-04-12 19:25:19 +08:00
|
|
|
|
salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salaryAcctRecordPO.getId());
|
2022-04-11 20:17:47 +08:00
|
|
|
|
} else {
|
2022-04-12 19:25:19 +08:00
|
|
|
|
salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listByIds(calculateParam.getIds());
|
2022-04-11 20:17:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(103378, "薪资核算人员不能为空"));
|
|
|
|
|
|
}
|
|
|
|
|
|
// 11.1、初始化进度
|
2022-07-11 17:31:33 +08:00
|
|
|
|
SalaryAcctProgressDTO initProgress = new SalaryAcctProgressDTO().setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中")).setTitleLabelId(97515L).setTotalQuantity(salaryAcctEmployeePOS.size() * 2 + 1).setCalculatedQuantity(0).setProgress(BigDecimal.ZERO).setStatus(true).setMessage(StringUtils.EMPTY);
|
2022-04-29 17:15:22 +08:00
|
|
|
|
getSalaryAcctProgressService(user).initProgress(SalaryCacheKey.ACCT_PROGRESS + calculateParam.getSalaryAcctRecordId(), initProgress);
|
2022-04-11 20:17:47 +08:00
|
|
|
|
// 12、对薪资核算人员进行拆分
|
2022-12-20 16:45:09 +08:00
|
|
|
|
List<List<SalaryAcctEmployeePO>> partition = Lists.partition(salaryAcctEmployeePOS, 5000);
|
2022-04-11 20:17:47 +08:00
|
|
|
|
// 12.1、监控子线程的任务执行
|
|
|
|
|
|
CountDownLatch childMonitor = new CountDownLatch(partition.size());
|
|
|
|
|
|
// 12.2、记录子线程的执行结果
|
|
|
|
|
|
BlockingDeque<SalaryAcctCalculateBO.Result> calculateResults = new LinkedBlockingDeque<>(partition.size());
|
|
|
|
|
|
// 12.3、生成本次运算的key
|
|
|
|
|
|
String calculateKey = UUID.randomUUID().toString();
|
|
|
|
|
|
// 12.4、多线程运算,运算结果存放在临时表中
|
|
|
|
|
|
for (List<SalaryAcctEmployeePO> acctEmployeePOS : partition) {
|
2022-11-17 09:28:40 +08:00
|
|
|
|
SalaryAcctCalculateBO salaryAcctCalculateBO = new SalaryAcctCalculateBO()
|
|
|
|
|
|
.setSalaryAcctRecordPO(salaryAcctRecordPO)
|
|
|
|
|
|
.setSalarySobPO(salarySobPO)
|
|
|
|
|
|
.setSalarySobCycleDTO(salarySobCycleDTO)
|
|
|
|
|
|
.setOtherSalaryAcctRecordPOS(otherSalaryAcctRecordPOS)
|
|
|
|
|
|
.setSalaryAcctLockResultPOS(MapUtils.emptyIfNull(acctResults))
|
2022-11-17 18:53:22 +08:00
|
|
|
|
.setLockSalaryItemIds(lockSalaryItemIds)
|
2022-11-17 09:28:40 +08:00
|
|
|
|
.setSalarySobItemPOS(salarySobItemPOS)
|
|
|
|
|
|
.setSalaryItemIdWithPriorityList(salarySobItemsWithPriority)
|
|
|
|
|
|
.setExpressFormulas(expressFormulas)
|
|
|
|
|
|
.setSalaryItemPOS(salaryItemPOS)
|
|
|
|
|
|
.setSalarySobAdjustRulePOS(salarySobAdjustRulePOS)
|
|
|
|
|
|
.setWelfareColumns(MapUtils.emptyIfNull(welfareColumns))
|
|
|
|
|
|
.setAttendQuoteFieldListDTOS(attendQuoteFieldListDTOS)
|
|
|
|
|
|
.setSalaryAcctEmployeePOS(acctEmployeePOS)
|
2022-12-02 17:35:14 +08:00
|
|
|
|
.setIssuedFieldIds(issuedFieldIds)
|
2022-11-17 09:28:40 +08:00
|
|
|
|
.setChildMonitor(childMonitor)
|
|
|
|
|
|
.setResults(calculateResults)
|
|
|
|
|
|
.setCalculateKey(calculateKey);
|
2022-12-02 17:35:14 +08:00
|
|
|
|
List<SalarySobBackItemPO> finalSalarySobBackItems = salarySobBackItems;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
LocalRunnable localRunnable = new LocalRunnable() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void execute() {
|
2022-12-02 17:35:14 +08:00
|
|
|
|
getSalaryAcctCalculateService(user).calculate(salaryAcctCalculateBO, simpleEmployee, finalSalarySobBackItems);
|
2022-04-11 20:17:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
};
|
2022-05-12 15:41:12 +08:00
|
|
|
|
ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.HRM, "salaryAcctCalculateV2", localRunnable);
|
2022-04-11 20:17:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
// 13、等待所有子线程执行完毕
|
|
|
|
|
|
childMonitor.await();
|
|
|
|
|
|
// 14、判断子线程执行结果
|
|
|
|
|
|
boolean allSuccess = calculateResults.stream().allMatch(SalaryAcctCalculateBO.Result::isStatus);
|
|
|
|
|
|
if (!allSuccess) {
|
|
|
|
|
|
// 薪资核算实现的线程的错误信息
|
2022-07-11 17:31:33 +08:00
|
|
|
|
String errorMsg = calculateResults.stream().filter(result -> !result.isStatus()).map(SalaryAcctCalculateBO.Result::getErrMsg).collect(Collectors.joining("|"));
|
2022-04-29 17:15:22 +08:00
|
|
|
|
getSalaryAcctProgressService(user).fail(SalaryCacheKey.ACCT_PROGRESS + calculateParam.getSalaryAcctRecordId(), errorMsg);
|
2022-04-11 20:17:47 +08:00
|
|
|
|
// 删除薪资核算临时存储表中的数据
|
2022-04-12 19:25:19 +08:00
|
|
|
|
getSalaryAcctResultTempService(user).deleteByCalculateKey(calculateKey);
|
2022-04-11 20:17:47 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 15、处理核算结果临时表数据
|
|
|
|
|
|
handleSalaryAcctResultTemp(calculateParam, calculateKey);
|
|
|
|
|
|
// 16、开始运行校验规则
|
2022-04-07 16:54:10 +08:00
|
|
|
|
// SalaryAcctCheckParam salaryAcctCheckParam = new SalaryAcctCheckParam()
|
|
|
|
|
|
// .setSalaryAcctRecordId(calculateParam.getSalaryAcctRecordId())
|
|
|
|
|
|
// .setIds(calculateParam.getIds());
|
2022-04-08 19:08:59 +08:00
|
|
|
|
// salaryCheckResultService.check(salaryAcctCheckParam, true, simpleEmployee);
|
2022-04-29 17:15:22 +08:00
|
|
|
|
// Thread.sleep(10);
|
|
|
|
|
|
getSalaryAcctProgressService(user).finish(SalaryCacheKey.ACCT_PROGRESS + calculateParam.getSalaryAcctRecordId(), true);
|
2022-04-11 20:17:47 +08:00
|
|
|
|
// 记录日志
|
|
|
|
|
|
// 查询操作日志的targetName
|
2022-04-12 19:25:19 +08:00
|
|
|
|
// String targetName = getSalaryAcctRecordService(user).getLogTargetNameById(calculateParam.getSalaryAcctRecordId());
|
2022-04-07 16:54:10 +08:00
|
|
|
|
// LoggerContext<SalaryCheckResultPO> loggerContext = new LoggerContext<>();
|
|
|
|
|
|
// loggerContext.setTargetId(String.valueOf(calculateParam.getSalaryAcctRecordId()));
|
|
|
|
|
|
// loggerContext.setTargetName(targetName);
|
|
|
|
|
|
// loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
|
|
|
|
|
|
// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(95783, "薪资核算"));
|
|
|
|
|
|
// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(95783, "薪资核算"));
|
|
|
|
|
|
// salaryAcctRecordLoggerTemplate.write(loggerContext);
|
2022-04-11 20:17:47 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.info("薪资核算出错:{}", e.getMessage(), e);
|
2022-04-29 17:15:22 +08:00
|
|
|
|
// throw new SalaryRunTimeException(e);
|
|
|
|
|
|
getSalaryAcctProgressService(user).fail(SalaryCacheKey.ACCT_PROGRESS + calculateParam.getSalaryAcctRecordId(), SalaryI18nUtil.getI18nLabel(99642, "薪资核算出错") + ": " + e.getMessage());
|
2022-04-11 20:17:47 +08:00
|
|
|
|
} finally {
|
|
|
|
|
|
// 数据库字段加密用
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-04-08 19:08:59 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 处理薪资核算临时存储表中的数据
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param calculateParam
|
|
|
|
|
|
* @param calculateKey
|
|
|
|
|
|
*/
|
2022-04-11 20:17:47 +08:00
|
|
|
|
private void handleSalaryAcctResultTemp(SalaryAcctCalculateParam calculateParam, String calculateKey) {
|
2022-04-12 19:25:19 +08:00
|
|
|
|
// TransactionStatus status = dataSourceTransactionManager.getTransaction(new DefaultTransactionDefinition());
|
|
|
|
|
|
// try {
|
2022-04-29 17:15:22 +08:00
|
|
|
|
// 查询薪资核算结果的临时存储
|
|
|
|
|
|
List<SalaryAcctResultTempPO> salaryAcctResultTempPOS = getSalaryAcctResultTempService(user).listByCalculateKey(calculateKey);
|
|
|
|
|
|
// 删除原来的薪资核算结果
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(calculateParam.getIds())) {
|
|
|
|
|
|
getSalaryAcctResultMapper().deleteBySalaryAcctEmpIds(calculateParam.getIds());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
getSalaryAcctResultMapper().deleteBySalaryAcctRecordIds(Collections.singleton(calculateParam.getSalaryAcctRecordId()));
|
2022-07-11 17:31:33 +08:00
|
|
|
|
getSalaryAcctReportService(user).deleteBySalaryAcctRecordId(calculateParam.getSalaryAcctRecordId());
|
2022-04-29 17:15:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
// 保存薪资的薪资核算结果
|
|
|
|
|
|
List<SalaryAcctResultPO> salaryAcctResultPOS = SalaryAcctResultBO.convert2ResultPO(salaryAcctResultTempPOS);
|
|
|
|
|
|
batchSave(salaryAcctResultPOS);
|
2022-07-11 17:31:33 +08:00
|
|
|
|
//保存核算报表数据
|
|
|
|
|
|
List<SalaryAcctResultReportPO> salaryAcctResultReportPOS = SalaryAcctResultReportBO.convert2ReportPO(salaryAcctResultTempPOS, calculateParam.getEmps());
|
|
|
|
|
|
getSalaryAcctReportService(user).batchSave(salaryAcctResultReportPOS);
|
2022-04-29 17:15:22 +08:00
|
|
|
|
// 删除薪资核算临时存储表中的数据
|
|
|
|
|
|
getSalaryAcctResultTempService(user).deleteByCalculateKey(calculateKey);
|
2022-04-12 19:25:19 +08:00
|
|
|
|
// // 提交事务
|
|
|
|
|
|
// dataSourceTransactionManager.commit(status);
|
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
|
// dataSourceTransactionManager.rollback(status);
|
|
|
|
|
|
// throw e;
|
|
|
|
|
|
// }
|
2022-04-11 20:17:47 +08:00
|
|
|
|
}
|
2022-06-07 19:10:40 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalaryAcctResultPO> listBySalaryAcctRecordIdsAndTaxAgentIds(Collection<Long> salaryAcctRecordIds, Collection<Long> taxAgentIds) {
|
|
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctRecordIds)) {
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
|
}
|
2022-12-12 16:42:44 +08:00
|
|
|
|
return encryptUtil.decryptList(getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctRecordIds(salaryAcctRecordIds).taxAgentIds(taxAgentIds).build()),
|
|
|
|
|
|
SalaryAcctResultPO.class);
|
2022-06-07 19:10:40 +08:00
|
|
|
|
}
|
2022-11-17 09:28:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
|
|
// * 查询薪资核算人员
|
|
|
|
|
|
// *
|
|
|
|
|
|
// * @param queryParam
|
|
|
|
|
|
// * @param salaryAcctRecord
|
|
|
|
|
|
// * @return
|
|
|
|
|
|
// */
|
|
|
|
|
|
// private List<SalaryAcctEmployeePO> querySalaryAcctEmployee(SalaryAcctResultListContext salaryAcctResultListContext, SalaryAcctResultQueryParam queryParam, SalaryAcctRecordPO salaryAcctRecord) {
|
|
|
|
|
|
// // 构建薪资核算人员的查询参数
|
|
|
|
|
|
// SalaryAcctEmployeeQueryParam salaryAcctEmployeeListQueryParam = new SalaryAcctEmployeeQueryParam();
|
|
|
|
|
|
// BeanUtils.copyProperties(queryParam, salaryAcctEmployeeListQueryParam);
|
|
|
|
|
|
// // 查询薪资核算人员
|
|
|
|
|
|
// List<SalaryAcctEmployeePO> salaryAcctEmployees = getSalaryAcctEmployeeService(user).listByParam(salaryAcctEmployeeListQueryParam);
|
|
|
|
|
|
// // 查询相同税款所属期内的薪资核算人员
|
|
|
|
|
|
// List<SalaryAcctEmployeePO> sameTaxCycleSalaryAcctEmployees = salaryAcctEmployeeService
|
|
|
|
|
|
// .listSameTaxCycle(salaryAcctEmployees, SalaryDateUtil.getFormatYearMonth(salaryAcctRecord.getTaxCycle()));
|
|
|
|
|
|
// Set<String> sameTaxCycleKeySet = SalaryEntityUtil.properties(sameTaxCycleSalaryAcctEmployees, o -> o.getEmployeeId() + "-" + o.getTaxAgentId());
|
|
|
|
|
|
// salaryAcctResultListContext.setSameTaxCycleKeySet(sameTaxCycleKeySet);
|
|
|
|
|
|
// // 过滤合并计税的人员
|
|
|
|
|
|
// if (StringUtils.isNotEmpty(queryParam.getConsolidatedTaxation())) {
|
|
|
|
|
|
// salaryAcctEmployees = salaryAcctEmployees.stream()
|
|
|
|
|
|
// .filter(salaryAcctEmployeePO -> sameTaxCycleKeySet.contains(salaryAcctEmployeePO.getEmployeeId() + "-" + salaryAcctEmployeePO.getTaxAgentId()))
|
|
|
|
|
|
// .collect(Collectors.toList());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 根据权限过滤
|
|
|
|
|
|
// return salaryAcctEmployeeService.filterByAuthority(salaryAcctEmployees, employeeId);
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void updateLockStatusByParam(SalaryAcctResultUpdateLockStatusParam updateParam) {
|
|
|
|
|
|
// 查询薪资核算记录
|
|
|
|
|
|
SalaryAcctRecordPO salaryAcctRecord = getSalaryAcctRecordService(user).getById(updateParam.getSalaryAcctRecordId());
|
2022-11-17 17:04:14 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctRecord.getLockSalaryItemIds())) {
|
2022-11-17 09:28:40 +08:00
|
|
|
|
salaryAcctRecord.setLockSalaryItemIds(new ArrayList<>());
|
|
|
|
|
|
}
|
|
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(updateParam.getSalaryAcctRecordId());
|
|
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctEmployees)) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 查询薪资核算结果
|
2023-05-04 11:56:34 +08:00
|
|
|
|
List<Long> salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployees, SalaryAcctEmployeePO::getId,Collectors.toList());
|
2022-11-17 09:28:40 +08:00
|
|
|
|
List<SalaryAcctResultPO> salaryAcctResultValues = this.listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds);
|
|
|
|
|
|
Map<Long, SalaryAcctResultPO> salaryAcctResultValueMap = SalaryEntityUtil.convert2Map(salaryAcctResultValues, SalaryAcctResultPO::getSalaryAcctEmpId);
|
|
|
|
|
|
// 值可以锁定的薪资项目
|
2022-11-17 18:53:22 +08:00
|
|
|
|
// Set<Long> salaryItemIds = canLockSalaryItemIds(salaryAcctRecord.getSalarySobId());
|
2022-11-17 09:28:40 +08:00
|
|
|
|
// if (Objects.nonNull(updateParam.getSalaryItemId())) {
|
|
|
|
|
|
// if (!salaryItemIds.contains(updateParam.getSalaryItemId())) {
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// salaryItemIds = Collections.singleton(updateParam.getSalaryItemId());
|
|
|
|
|
|
// }
|
2022-11-17 18:53:22 +08:00
|
|
|
|
Set<Long> salaryItemIds = Collections.singleton(updateParam.getSalaryItemId());
|
2022-11-17 09:28:40 +08:00
|
|
|
|
if (updateParam.getLockStatus() == LockStatusEnum.LOCK) {
|
|
|
|
|
|
salaryAcctRecord.getLockSalaryItemIds().addAll(salaryItemIds);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
salaryAcctRecord.getLockSalaryItemIds().removeAll(salaryItemIds);
|
|
|
|
|
|
}
|
|
|
|
|
|
getSalaryAcctRecordService(user).updateLockSalaryItemIds(salaryAcctRecord);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-02 17:35:14 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void reCalc(Long id) {
|
|
|
|
|
|
// 无需解密
|
|
|
|
|
|
SalaryAcctResultPO build = SalaryAcctResultPO.builder().salaryAcctRecordId(id).deleteType(0).build();
|
|
|
|
|
|
List<SalaryAcctResultPO> salaryAcctResultPOS = getSalaryAcctResultMapper().listSome(build);
|
|
|
|
|
|
// 回算前的薪资核算结果
|
|
|
|
|
|
salaryAcctResultPOS.forEach(salaryAcctResult ->
|
|
|
|
|
|
salaryAcctResult.setOriginResultValue(salaryAcctResult.getResultValue()));
|
|
|
|
|
|
// 批量更新
|
|
|
|
|
|
batchUpdateOriginResultValue(salaryAcctResultPOS);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-06 15:29:08 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalaryAcctResultPO> listBySalaryAcctRecordIdsAndSalaryItemIds(Collection<Long> salaryAcctRecordIds, Collection<Long> salaryItemIds) {
|
2023-05-04 11:56:34 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctRecordIds) || CollectionUtils.isEmpty(salaryItemIds)) {
|
2022-12-06 15:29:08 +08:00
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
|
}
|
2023-04-04 17:29:56 +08:00
|
|
|
|
List<SalaryAcctResultPO> list = getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctRecordIds(salaryAcctRecordIds).salaryItemIds(salaryItemIds).build());
|
2023-05-04 11:56:34 +08:00
|
|
|
|
return encryptUtil.decryptList(list, SalaryAcctResultPO.class);
|
2022-12-06 15:29:08 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-26 23:17:32 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalaryAcctResultPO> listByAcctEmployeeIdsAndSalaryItemIds(Set<Long> salaryAcctEmployeeIds, Set<Long> salaryItemIds) {
|
|
|
|
|
|
SalaryAcctResultPO build = SalaryAcctResultPO.builder().salaryAcctEmpIds(salaryAcctEmployeeIds).salaryItemIds(salaryItemIds).build();
|
|
|
|
|
|
List<SalaryAcctResultPO> list = getSalaryAcctResultMapper().listSome(build);
|
|
|
|
|
|
// 数据解密
|
|
|
|
|
|
encryptUtil.decryptList(list, SalaryAcctResultPO.class);
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-02 17:35:14 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void batchUpdateOriginResultValue(List<SalaryAcctResultPO> salaryAcctResultValues) {
|
2022-12-15 11:32:32 +08:00
|
|
|
|
int batchSize = 500;
|
2022-12-02 17:35:14 +08:00
|
|
|
|
List<List<SalaryAcctResultPO>> partition = Lists.partition(salaryAcctResultValues, batchSize);
|
|
|
|
|
|
for (List<SalaryAcctResultPO> subSalaryAcctResultValues : partition) {
|
|
|
|
|
|
getSalaryAcctResultMapper().batchUpdateOriginResultValue(subSalaryAcctResultValues);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-17 09:28:40 +08:00
|
|
|
|
private Set<Long> canLockSalaryItemIds(Long salarySobId) {
|
|
|
|
|
|
// 值可以锁定的薪资项目
|
|
|
|
|
|
Set<Long> salaryItemIds = Sets.newHashSet();
|
|
|
|
|
|
// 查询薪资核算记录所用的薪资账套的薪资项目
|
|
|
|
|
|
List<SalarySobItemDTO> salarySobItems = Lists.newArrayList();
|
|
|
|
|
|
SalarySobItemAggregateDTO salarySobItemAggregate = getSalarySobItemService(user).getAggregateBySalarySobId(salarySobId);
|
|
|
|
|
|
for (SalarySobItemIncomeCategoryDTO incomeCategory : salarySobItemAggregate.getIncomeCategories()) {
|
|
|
|
|
|
for (SalarySobItemGroupDTO itemGroup : incomeCategory.getItemGroups()) {
|
|
|
|
|
|
salarySobItems.addAll(itemGroup.getItems());
|
|
|
|
|
|
}
|
|
|
|
|
|
salarySobItems.addAll(incomeCategory.getItems());
|
|
|
|
|
|
}
|
|
|
|
|
|
for (SalarySobItemDTO salarySobItem : salarySobItems) {
|
|
|
|
|
|
if (Objects.equals(salarySobItem.getValueType(), SalaryValueTypeEnum.FORMULA.getValue()) && salarySobItem.isCanEdit()) {
|
|
|
|
|
|
salaryItemIds.add(salarySobItem.getSalaryItemId());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// for (SalarySobItemDTO backCalcItem : salarySobItemAggregate.getBackCalcItems()) {
|
|
|
|
|
|
// if (Objects.equals(backCalcItem.getValueType(), SalaryValueTypeEnum.FORMULA.getValue()) && backCalcItem.isCanEdit()) {
|
|
|
|
|
|
// salaryItemIds.add(backCalcItem.getSalaryItemId());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
return salaryItemIds;
|
|
|
|
|
|
}
|
2022-04-08 19:08:59 +08:00
|
|
|
|
}
|