2022-04-07 16:54:10 +08:00
|
|
|
package com.engine.salary.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
|
|
|
|
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
|
|
|
|
import com.engine.salary.entity.salaryacct.bo.SalaryAcctEmployeeBO;
|
|
|
|
|
import com.engine.salary.entity.salaryacct.dto.SalaryAcctEmployeeCountDTO;
|
|
|
|
|
import com.engine.salary.entity.salaryacct.param.*;
|
|
|
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
|
|
|
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
|
|
|
|
|
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO;
|
|
|
|
|
import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO;
|
|
|
|
|
import com.engine.salary.entity.salarysob.po.SalarySobPO;
|
|
|
|
|
import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum;
|
|
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
|
|
|
|
import com.engine.salary.mapper.salaryacct.SalaryAcctEmployeeMapper;
|
|
|
|
|
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-11 20:46:25 +08:00
|
|
|
import com.engine.salary.util.db.MapperProxyFactory;
|
2022-04-07 16:54:10 +08:00
|
|
|
import com.engine.salary.util.page.PageInfo;
|
|
|
|
|
import com.engine.salary.util.page.PageUtil;
|
|
|
|
|
import com.engine.salary.util.valid.ValidUtil;
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 薪资核算人员
|
|
|
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
*
|
|
|
|
|
* @author qiantao
|
|
|
|
|
* @version 1.0
|
|
|
|
|
**/
|
|
|
|
|
public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcctEmployeeService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private SalaryAcctEmployeeMapper salaryAcctEmployeeMapper;
|
|
|
|
|
|
|
|
|
|
private SalaryAcctEmployeeMapper getSalaryAcctEmployeeMapper() {
|
2022-04-11 20:46:25 +08:00
|
|
|
return MapperProxyFactory.getProxy(SalaryAcctEmployeeMapper.class);
|
2022-04-07 16:54:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private SalaryAcctRecordService getSalaryAcctRecordService(User user) {
|
|
|
|
|
return (SalaryAcctRecordService) ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-12 19:25:19 +08:00
|
|
|
private SalaryAcctResultService getSalaryAcctResultService(User user) {
|
|
|
|
|
return (SalaryAcctResultService) ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user);
|
|
|
|
|
}
|
2022-04-07 16:54:10 +08:00
|
|
|
|
|
|
|
|
// private SalaryAcctResultService getSalaryAcctResultService(User user) {
|
|
|
|
|
// return (SalaryAcctResultService) ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// private SalaryCheckResultDetailService salaryCheckResultDetailService;
|
|
|
|
|
|
|
|
|
|
// private SalaryComparisonResultService salaryComparisonResultService;
|
|
|
|
|
|
2022-04-08 16:30:10 +08:00
|
|
|
private SalarySobService getSalarySobService(User user) {
|
|
|
|
|
return (SalarySobService) ServiceUtil.getService(SalarySobServiceImpl.class, user);
|
|
|
|
|
}
|
2022-04-07 16:54:10 +08:00
|
|
|
|
2022-04-08 16:30:10 +08:00
|
|
|
private SalaryEmployeeService getSalaryEmployeeService(User user) {
|
|
|
|
|
return (SalaryEmployeeService) ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
|
|
|
|
|
}
|
2022-04-07 16:54:10 +08:00
|
|
|
|
2022-04-08 16:30:10 +08:00
|
|
|
private SalaryArchiveService getSalaryArchiveService(User user) {
|
|
|
|
|
return (SalaryArchiveService) ServiceUtil.getService(SalaryArchiveServiceImpl.class, user);
|
|
|
|
|
}
|
2022-04-07 16:54:10 +08:00
|
|
|
|
|
|
|
|
// private LoggerTemplate salaryAcctRecordLoggerTemplate;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SalaryAcctEmployeeCountDTO> countBySalaryAcctRecordId(Collection<Long> salaryAcctRecordIds) {
|
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctRecordIds)) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
return getSalaryAcctEmployeeMapper().countGroupBySalaryAcctRecordId(salaryAcctRecordIds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public SalaryAcctEmployeePO getById(Long id) {
|
|
|
|
|
return getSalaryAcctEmployeeMapper().getById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SalaryAcctEmployeePO> listByIds(Collection<Long> ids) {
|
|
|
|
|
return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().ids(ids).build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SalaryAcctEmployeePO> listBySalaryAcctRecordId(Long salaryAcctRecordId) {
|
|
|
|
|
return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordId(salaryAcctRecordId).build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SalaryAcctEmployeePO> listBySalaryAcctRecordIds(Collection<Long> salaryAcctRecordIds) {
|
|
|
|
|
return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordIds(salaryAcctRecordIds).build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SalaryAcctEmployeePO> listBySalaryAcctRecordIdAndTaxAgentId(Long salaryAcctRecordId, Long taxAgentId) {
|
|
|
|
|
return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordId(salaryAcctRecordId).taxAgentId(taxAgentId).build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void addFromReduce(SalaryAcctEmployeeAddParam addParam) {
|
|
|
|
|
ValidUtil.doValidator(addParam);
|
|
|
|
|
// 查询薪资核算记录
|
|
|
|
|
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(addParam.getSalaryAcctRecordId());
|
|
|
|
|
if (Objects.isNull(salaryAcctRecordPO)) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
|
|
|
|
|
}
|
|
|
|
|
// 查询环比减少的薪资核算人员
|
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = listByIds(addParam.getIds());
|
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98830, "薪资核算人员不存在或已被删除"));
|
|
|
|
|
}
|
|
|
|
|
// 添加薪资核算人员
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
List<SalaryAcctEmployeePO> newSalaryAcctEmployeePOS = salaryAcctEmployeePOS.stream()
|
|
|
|
|
.map(salaryAcctEmployeePO -> new SalaryAcctEmployeePO()
|
|
|
|
|
// .setId(IdGenerator.generate())
|
|
|
|
|
.setSalaryAcctRecordId(salaryAcctRecordPO.getId())
|
|
|
|
|
.setSalarySobId(salaryAcctRecordPO.getSalarySobId())
|
|
|
|
|
.setSalaryMonth(salaryAcctRecordPO.getSalaryMonth())
|
|
|
|
|
.setEmployeeId(salaryAcctEmployeePO.getEmployeeId())
|
|
|
|
|
.setTaxAgentId(salaryAcctEmployeePO.getTaxAgentId())
|
|
|
|
|
.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
|
|
|
|
.setCreateTime(now)
|
|
|
|
|
.setUpdateTime(now)
|
|
|
|
|
.setCreator((long) user.getUID())
|
|
|
|
|
.setDeleteType(0))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
if (CollectionUtils.isNotEmpty(newSalaryAcctEmployeePOS)) {
|
|
|
|
|
getSalaryAcctEmployeeMapper().batchInsert(newSalaryAcctEmployeePOS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SalaryAcctEmployeePO> listBySalaryAcctRecordIdAndIds(Long salaryAcctRecordId, Collection<Long> ids) {
|
|
|
|
|
return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordId(salaryAcctRecordId).ids(ids).build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SalaryAcctEmployeePO> listBySalaryAcctRecordIdAndEmployeeIds(Long salaryAcctRecordId, Collection<Long> employeeIds) {
|
|
|
|
|
if (CollectionUtils.isEmpty(employeeIds)) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordId(salaryAcctRecordId).employeeIds(employeeIds).build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SalaryAcctEmployeePO> listBySalaryAcctRecordIdsAndEmployeeIds(Collection<Long> salaryAcctRecordIds, Collection<Long> employeeIds) {
|
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctRecordIds) || CollectionUtils.isEmpty(employeeIds)) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordIds(salaryAcctRecordIds).employeeIds(employeeIds).build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SalaryAcctEmployeePO> listByRecordIdsAndEmpIdAndTaxAgentId(Collection<Long> salaryAcctRecordIds, Long employeeId, Long taxAgentId) {
|
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctRecordIds)) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
return getSalaryAcctEmployeeMapper().listSome(SalaryAcctEmployeePO.builder().salaryAcctRecordIds(salaryAcctRecordIds).employeeId(employeeId).taxAgentId(taxAgentId).build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PageInfo<SalaryAcctEmployeePO> listPageByParam(SalaryAcctEmployeeQueryParam queryParam) {
|
|
|
|
|
ValidUtil.doValidator(queryParam);
|
|
|
|
|
// 分页参数
|
|
|
|
|
PageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
|
|
|
|
|
// 查询薪资核算人员
|
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = getSalaryAcctEmployeeMapper().listPage(queryParam);
|
|
|
|
|
return new PageInfo<>(salaryAcctEmployeePOS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SalaryAcctEmployeePO> listByParam(SalaryAcctEmployeeQueryParam queryParam) {
|
|
|
|
|
ValidUtil.doValidator(queryParam);
|
|
|
|
|
return getSalaryAcctEmployeeMapper().list(queryParam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PageInfo<SalaryAcctEmployeePO> listPageByResultQueryParam(SalaryAcctResultQueryParam queryParam) {
|
|
|
|
|
ValidUtil.doValidator(queryParam);
|
|
|
|
|
// 薪资核算人员的查询参数
|
|
|
|
|
SalaryAcctEmployeeQueryParam salaryAcctEmployeeQueryParam = new SalaryAcctEmployeeQueryParam();
|
|
|
|
|
BeanUtils.copyProperties(queryParam, salaryAcctEmployeeQueryParam);
|
|
|
|
|
// 查询薪资核算人员(分页)
|
|
|
|
|
// 如果需要筛选是否合并计税
|
|
|
|
|
if (StringUtils.isNotEmpty(queryParam.getConsolidatedTaxation())) {
|
|
|
|
|
return listPageByParam4ConsolidatedTax(salaryAcctEmployeeQueryParam);
|
|
|
|
|
} else {
|
|
|
|
|
return listPageByParam(salaryAcctEmployeeQueryParam);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SalaryAcctEmployeePO> listByResultQueryParam(SalaryAcctResultQueryParam queryParam) {
|
|
|
|
|
// 薪资核算人员的查询参数
|
|
|
|
|
SalaryAcctEmployeeQueryParam salaryAcctEmployeeQueryParam = new SalaryAcctEmployeeQueryParam();
|
|
|
|
|
BeanUtils.copyProperties(queryParam, salaryAcctEmployeeQueryParam);
|
|
|
|
|
// 查询薪资核算人员
|
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS;
|
|
|
|
|
// 如果需要筛选是否合并计税
|
|
|
|
|
if (StringUtils.isNotEmpty(queryParam.getConsolidatedTaxation())) {
|
|
|
|
|
salaryAcctEmployeePOS = listByParam4ConsolidatedTax(salaryAcctEmployeeQueryParam);
|
|
|
|
|
} else {
|
|
|
|
|
salaryAcctEmployeePOS = listByParam(salaryAcctEmployeeQueryParam);
|
|
|
|
|
}
|
|
|
|
|
return salaryAcctEmployeePOS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PageInfo<SalaryAcctEmployeePO> listPageByParam4Reduce(SalaryAcctEmployeeQueryParam queryParam) {
|
|
|
|
|
// 查询上个月的薪资核算记录(同一个薪资账套)
|
|
|
|
|
List<SalaryAcctRecordPO> salaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4LastSalaryMonth(queryParam.getSalaryAcctRecordId());
|
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) {
|
|
|
|
|
return new PageInfo<>();
|
|
|
|
|
}
|
|
|
|
|
Set<Long> lastMonthSalaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId);
|
|
|
|
|
// 查询环比减少人员
|
|
|
|
|
// 分页参数
|
|
|
|
|
PageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
|
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = getSalaryAcctEmployeeMapper().listPage4Reduce(lastMonthSalaryAcctRecordIds, queryParam);
|
|
|
|
|
PageInfo<SalaryAcctEmployeePO> salaryAcctEmployeePOPageInfo = new PageInfo<>(salaryAcctEmployeePOS);
|
|
|
|
|
return salaryAcctEmployeePOPageInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SalaryAcctEmployeePO> listByParam4Reduce(SalaryAcctEmployeeQueryParam queryParam) {
|
|
|
|
|
// 查询上个月的薪资核算记录(同一个薪资账套)
|
|
|
|
|
List<SalaryAcctRecordPO> salaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4LastSalaryMonth(queryParam.getSalaryAcctRecordId());
|
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
Set<Long> lastMonthSalaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId);
|
|
|
|
|
// 查询环比减少人员
|
|
|
|
|
return getSalaryAcctEmployeeMapper().list4Reduce(lastMonthSalaryAcctRecordIds, queryParam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PageInfo<SalaryAcctEmployeePO> listPageByParam4ConsolidatedTax(SalaryAcctEmployeeQueryParam queryParam) {
|
|
|
|
|
|
|
|
|
|
// 查询合并计税的其他薪资核算记录
|
|
|
|
|
List<SalaryAcctRecordPO> otherSalaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4OtherConsolidatedTax(queryParam.getSalaryAcctRecordId());
|
|
|
|
|
if (CollectionUtils.isEmpty(otherSalaryAcctRecordPOS)) {
|
|
|
|
|
return new PageInfo<>();
|
|
|
|
|
}
|
|
|
|
|
// 查询合并计税的薪资核算人员
|
|
|
|
|
Set<Long> otherSalaryAcctRecordIds = SalaryEntityUtil.properties(otherSalaryAcctRecordPOS, SalaryAcctRecordPO::getId);
|
|
|
|
|
// 分页参数
|
|
|
|
|
PageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
|
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = getSalaryAcctEmployeeMapper().listPage4ConsolidatedTax(otherSalaryAcctRecordIds, queryParam);
|
|
|
|
|
PageInfo<SalaryAcctEmployeePO> salaryAcctEmployeePOPageInfo = new PageInfo<>(salaryAcctEmployeePOS);
|
|
|
|
|
return salaryAcctEmployeePOPageInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SalaryAcctEmployeePO> listByParam4ConsolidatedTax(SalaryAcctEmployeeQueryParam queryParam) {
|
|
|
|
|
// 查询合并计税的其他薪资核算记录
|
|
|
|
|
List<SalaryAcctRecordPO> otherSalaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4OtherConsolidatedTax(queryParam.getSalaryAcctRecordId());
|
|
|
|
|
if (CollectionUtils.isEmpty(otherSalaryAcctRecordPOS)) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
// 查询合并计税的薪资核算人员
|
|
|
|
|
Set<Long> otherSalaryAcctRecordIds = SalaryEntityUtil.properties(otherSalaryAcctRecordPOS, SalaryAcctRecordPO::getId);
|
|
|
|
|
return getSalaryAcctEmployeeMapper().list4ConsolidatedTax(otherSalaryAcctRecordIds, queryParam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void save(SalaryAcctEmployeeSaveParam saveParam) {
|
2022-04-08 16:30:10 +08:00
|
|
|
ValidUtil.doValidator(saveParam);
|
|
|
|
|
|
2022-04-07 16:54:10 +08:00
|
|
|
// 查询薪资核算记录
|
|
|
|
|
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(saveParam.getSalaryAcctRecordId());
|
|
|
|
|
if (Objects.isNull(salaryAcctRecordPO)) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
|
|
|
|
|
}
|
|
|
|
|
// 查询薪资核算人员
|
|
|
|
|
List<SalaryAcctEmployeePO> existSalaryAcctEmployeePOS = listBySalaryAcctRecordIdAndEmployeeIds(saveParam.getSalaryAcctRecordId(), saveParam.getEmployeeIds());
|
|
|
|
|
if (CollectionUtils.isNotEmpty(existSalaryAcctEmployeePOS)) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(101581, "人员已存在,请勿重复添加"));
|
|
|
|
|
}
|
|
|
|
|
// 根据薪资账套查询薪资周期
|
2022-04-08 16:30:10 +08:00
|
|
|
SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(), SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()));
|
2022-04-07 16:54:10 +08:00
|
|
|
// 查询薪资档案,获取人员的个税扣缴义务人
|
2022-04-08 16:30:10 +08:00
|
|
|
List<SalaryArchiveDataDTO> salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), saveParam.getEmployeeIds());
|
2022-04-07 16:54:10 +08:00
|
|
|
// 转换成薪资核算人员po
|
2022-04-12 19:25:19 +08:00
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2EmployeePO(saveParam.getEmployeeIds(), salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID());
|
2022-04-07 16:54:10 +08:00
|
|
|
// 保存薪资核算人员
|
|
|
|
|
if (CollectionUtils.isNotEmpty(salaryAcctEmployeePOS)) {
|
|
|
|
|
getSalaryAcctEmployeeMapper().batchInsert(salaryAcctEmployeePOS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查询薪资账套(记录日志用)
|
2022-04-08 16:30:10 +08:00
|
|
|
SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId());
|
2022-04-07 16:54:10 +08:00
|
|
|
if (Objects.isNull(salarySobPO)) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98769, "薪资账套不存在或已被删除"));
|
|
|
|
|
}
|
|
|
|
|
// 记录日志
|
|
|
|
|
// String targetName = salarySobPO.getName() + ":" + SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth());
|
|
|
|
|
// LoggerContext loggerContext = new LoggerContext<>();
|
|
|
|
|
// loggerContext.setTargetId("" + salaryAcctRecordPO.getId());
|
|
|
|
|
// loggerContext.setTargetName(targetName);
|
|
|
|
|
// loggerContext.setOperateType(OperateTypeEnum.ADD.getValue());
|
|
|
|
|
// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98837, "添加薪资核算人员"));
|
|
|
|
|
// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(98837, "添加薪资核算人员") + ":" + targetName);
|
|
|
|
|
// loggerContext.setNewValueList(salaryAcctEmployeePOS);
|
|
|
|
|
// salaryAcctRecordLoggerTemplate.write(loggerContext);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void batchSave(Collection<SalaryAcctEmployeePO> salaryAcctEmployeePOS) {
|
|
|
|
|
getSalaryAcctEmployeeMapper().batchInsert(salaryAcctEmployeePOS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void deleteByIds(Collection<Long> ids) {
|
|
|
|
|
// 删除薪资核算人员
|
|
|
|
|
getSalaryAcctEmployeeMapper().deleteByIds(ids);
|
2022-04-12 19:25:19 +08:00
|
|
|
// 删除薪资核算人员对应的薪资核算结果
|
|
|
|
|
getSalaryAcctResultService(user).deleteBySalaryAcctEmployeeIds(ids);
|
|
|
|
|
// 删除薪资核算人员对应的校验异常明细
|
2022-04-07 16:54:10 +08:00
|
|
|
// salaryCheckResultDetailService.deleteBySalaryAcctEmployeeIds(ids);
|
2022-04-12 19:25:19 +08:00
|
|
|
// 删除薪资核算人员对应的线下对比结果
|
2022-04-07 16:54:10 +08:00
|
|
|
// salaryComparisonResultService.deleteBySalaryAcctRecordIds(ids);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void deleteByParam(SalaryAcctEmployeeDeleteParam deleteParam) {
|
2022-04-08 16:30:10 +08:00
|
|
|
ValidUtil.doValidator(deleteParam);
|
2022-04-07 16:54:10 +08:00
|
|
|
// 查询薪资核算记录
|
|
|
|
|
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(deleteParam.getSalaryAcctRecordId());
|
|
|
|
|
if (Objects.isNull(salaryAcctRecordPO)) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
|
|
|
|
|
}
|
|
|
|
|
// 只有未归档时才能删除薪资核算人员
|
|
|
|
|
if (!Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98830, "薪资核算已归档或已申报,不允许再删除薪资核算人员"));
|
|
|
|
|
}
|
|
|
|
|
// 查询薪资核算人员
|
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = listBySalaryAcctRecordIdAndIds(deleteParam.getSalaryAcctRecordId(), deleteParam.getIds());
|
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98830, "薪资核算人员不存在或已被删除"));
|
|
|
|
|
}
|
|
|
|
|
// 删除薪资核算人员
|
|
|
|
|
Set<Long> ids = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId);
|
|
|
|
|
deleteByIds(ids);
|
|
|
|
|
|
|
|
|
|
// 查询薪资账套(记录日志用)
|
2022-04-08 16:30:10 +08:00
|
|
|
SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId());
|
2022-04-07 16:54:10 +08:00
|
|
|
if (Objects.isNull(salarySobPO)) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98769, "薪资账套不存在或已被删除"));
|
|
|
|
|
}
|
|
|
|
|
// 记录日志
|
|
|
|
|
// String targetName = salarySobPO.getName() + ":" + SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth());
|
|
|
|
|
// LoggerContext loggerContext = new LoggerContext<>();
|
|
|
|
|
// loggerContext.setTargetId("" + salaryAcctRecordPO.getId());
|
|
|
|
|
// loggerContext.setTargetName(targetName);
|
|
|
|
|
// loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue());
|
|
|
|
|
// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98835, "删除薪资核算人员"));
|
|
|
|
|
// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(98835, "删除薪资核算人员") + ":" + targetName);
|
|
|
|
|
// loggerContext.setOldValueList(salaryAcctEmployeePOS);
|
|
|
|
|
// salaryAcctRecordLoggerTemplate.write(loggerContext);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void deleteBySalaryAcctRecordIds(Collection<Long> salaryAcctRecordIds) {
|
|
|
|
|
getSalaryAcctEmployeeMapper().deleteBySalaryAcctRecordIds(salaryAcctRecordIds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void initBySalaryAcctRecord(SalaryAcctRecordPO salaryAcctRecordPO) {
|
|
|
|
|
// 根据薪资账套查询人员
|
2022-04-08 16:30:10 +08:00
|
|
|
List<DataCollectionEmployee> salaryEmployees = getSalaryEmployeeService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
|
2022-04-07 16:54:10 +08:00
|
|
|
if (CollectionUtils.isEmpty(salaryEmployees)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 根据薪资账套查询薪资周期
|
2022-04-08 16:30:10 +08:00
|
|
|
SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(), SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()));
|
2022-04-07 16:54:10 +08:00
|
|
|
// 根据薪资账套的"核算人员范围"过滤入职日期大于薪资周期止的人员
|
|
|
|
|
salaryEmployees = salaryEmployees.stream()
|
2022-05-12 14:36:16 +08:00
|
|
|
.filter(salaryEmployee -> StringUtils.isBlank(salaryEmployee.getCompanystartdate())
|
2022-04-28 10:05:27 +08:00
|
|
|
|| SalaryDateUtil.stringToDate(salaryEmployee.getCompanystartdate()).compareTo(salarySobCycleDTO.getSalaryCycle().getEndDate()) <= 0)
|
2022-04-07 16:54:10 +08:00
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
// 根据薪资账套的"核算人员范围"过滤离职日期小于薪资周期起的人员
|
2022-05-12 14:36:16 +08:00
|
|
|
salaryEmployees = salaryEmployees.stream()
|
|
|
|
|
.filter(salaryEmployee -> StringUtils.isBlank(salaryEmployee.getDismissdate())
|
|
|
|
|
|| SalaryDateUtil.stringToDate(salaryEmployee.getDismissdate()).compareTo(salarySobCycleDTO.getSalaryCycle().getEndDate()) >= 0)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
2022-04-07 16:54:10 +08:00
|
|
|
// TODO: 2/9/22 过滤离职人员
|
|
|
|
|
// 查询薪资档案,获取人员的个税扣缴义务人
|
|
|
|
|
Set<Long> employeeIds = SalaryEntityUtil.properties(salaryEmployees, DataCollectionEmployee::getEmployeeId);
|
2022-04-08 16:30:10 +08:00
|
|
|
List<SalaryArchiveDataDTO> salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds);
|
2022-04-07 16:54:10 +08:00
|
|
|
// 转换成薪资核算人员po
|
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2EmployeePO(employeeIds, salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID());
|
|
|
|
|
// 保存薪资核算人员
|
|
|
|
|
if (CollectionUtils.isNotEmpty(salaryAcctEmployeePOS)) {
|
|
|
|
|
getSalaryAcctEmployeeMapper().batchInsert(salaryAcctEmployeePOS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void refresh(Long salaryAcctRecordId) {
|
|
|
|
|
// 查询薪资核算人员
|
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = listBySalaryAcctRecordId(salaryAcctRecordId);
|
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Set<Long> employeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getEmployeeId);
|
|
|
|
|
// 查询薪资核算记录
|
|
|
|
|
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId);
|
|
|
|
|
if (Objects.isNull(salaryAcctRecordPO)) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
|
|
|
|
|
}
|
|
|
|
|
// 查询薪资核算记录所用的帐套的薪资周期
|
2022-04-08 16:30:10 +08:00
|
|
|
SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(),
|
2022-04-07 16:54:10 +08:00
|
|
|
SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()));
|
|
|
|
|
// 查询薪资档案,获取人员的个税扣缴义务人
|
2022-04-08 16:30:10 +08:00
|
|
|
List<SalaryArchiveDataDTO> salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds);
|
2022-04-07 16:54:10 +08:00
|
|
|
// 转换成薪资核算人员po
|
|
|
|
|
List<SalaryAcctEmployeePO> newSalaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2EmployeePO(employeeIds, salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID());
|
|
|
|
|
// 删除以前的薪资核算人员
|
|
|
|
|
getSalaryAcctEmployeeMapper().deleteBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId));
|
|
|
|
|
// 插入新的薪资核算人员
|
|
|
|
|
if (CollectionUtils.isNotEmpty(newSalaryAcctEmployeePOS)) {
|
|
|
|
|
getSalaryAcctEmployeeMapper().batchInsert(newSalaryAcctEmployeePOS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|