2023-08-08 09:21:14 +08:00
|
|
|
|
package com.engine.salary.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-08 19:39:53 +08:00
|
|
|
|
import cn.hutool.core.map.MapUtil;
|
2023-08-08 09:21:14 +08:00
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
|
|
|
|
|
import com.engine.core.impl.Service;
|
2024-03-12 18:58:36 +08:00
|
|
|
|
import com.engine.hrmelog.entity.dto.LoggerContext;
|
2023-08-08 09:21:14 +08:00
|
|
|
|
import com.engine.salary.common.LocalDateRange;
|
2023-08-08 19:39:53 +08:00
|
|
|
|
import com.engine.salary.common.taxdeclare.AsyncRequestIdDTO;
|
2024-03-07 09:29:59 +08:00
|
|
|
|
import com.engine.salary.config.SalaryElogConfig;
|
2023-08-08 19:39:53 +08:00
|
|
|
|
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
|
|
|
|
|
import com.engine.salary.constant.SzyhApiConstant;
|
2023-08-08 09:21:14 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
|
|
|
|
|
import com.engine.salary.entity.employeedeclare.bo.EmployeeDeclareList;
|
|
|
|
|
|
import com.engine.salary.entity.employeedeclare.bo.EmployeeDeclareRefresh;
|
2023-08-08 19:39:53 +08:00
|
|
|
|
import com.engine.salary.entity.employeedeclare.bo.EmployeeDeclareRequest;
|
|
|
|
|
|
import com.engine.salary.entity.employeedeclare.dto.*;
|
2023-08-08 09:21:14 +08:00
|
|
|
|
import com.engine.salary.entity.employeedeclare.param.*;
|
|
|
|
|
|
import com.engine.salary.entity.employeedeclare.po.EmployeeDeclarePO;
|
2023-08-08 19:39:53 +08:00
|
|
|
|
import com.engine.salary.entity.employeedeclare.po.EmployeeDeclareRecordPO;
|
|
|
|
|
|
import com.engine.salary.entity.employeedeclare.response.DeclareEmployeeFeedbackResponse;
|
|
|
|
|
|
import com.engine.salary.entity.employeedeclare.response.DeclareEmployeeInfoResponse;
|
2024-06-06 13:51:33 +08:00
|
|
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctTaxAgentPO;
|
2023-08-08 09:21:14 +08:00
|
|
|
|
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO;
|
2023-08-08 19:39:53 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.bo.TaxAgentTaxReturnBO;
|
2023-08-08 09:21:14 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
2023-08-08 19:39:53 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.po.TaxAgentTaxReturnPO;
|
|
|
|
|
|
import com.engine.salary.entity.taxapiflow.bo.TaxApiFlowBO;
|
|
|
|
|
|
import com.engine.salary.entity.taxapiflow.po.TaxDeclarationApiFlowRecordPO;
|
|
|
|
|
|
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationApiConfigPO;
|
2024-03-07 09:29:59 +08:00
|
|
|
|
import com.engine.salary.enums.OperateTypeEnum;
|
2023-08-08 09:21:14 +08:00
|
|
|
|
import com.engine.salary.enums.SalaryCycleTypeEnum;
|
2023-08-09 18:35:09 +08:00
|
|
|
|
import com.engine.salary.enums.SalaryOnOffEnum;
|
2023-12-05 17:08:35 +08:00
|
|
|
|
import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum;
|
2023-08-08 19:39:53 +08:00
|
|
|
|
import com.engine.salary.enums.employeedeclare.CardTypeEnum;
|
2023-08-08 09:21:14 +08:00
|
|
|
|
import com.engine.salary.enums.employeedeclare.DeclareStatusEnum;
|
|
|
|
|
|
import com.engine.salary.enums.employeedeclare.EmploymentStatusEnum;
|
2023-08-09 18:35:09 +08:00
|
|
|
|
import com.engine.salary.enums.employeedeclare.EmploymentTypeEnum;
|
2023-08-08 09:21:14 +08:00
|
|
|
|
import com.engine.salary.enums.salaryaccounting.EmployeeTypeEnum;
|
2023-08-08 19:39:53 +08:00
|
|
|
|
import com.engine.salary.enums.sicategory.DeleteTypeEnum;
|
|
|
|
|
|
import com.engine.salary.enums.taxagent.TaxAgentTaxReturnStatusEnum;
|
|
|
|
|
|
import com.engine.salary.enums.taxdeclaration.EnumDeclareApiBusinessType;
|
2023-08-08 09:21:14 +08:00
|
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
|
|
|
|
|
import com.engine.salary.mapper.employeedeclare.EmployeeDeclareMapper;
|
2023-08-08 19:39:53 +08:00
|
|
|
|
import com.engine.salary.service.*;
|
|
|
|
|
|
import com.engine.salary.util.*;
|
2024-03-07 09:29:59 +08:00
|
|
|
|
import com.engine.salary.util.db.IdGenerator;
|
2023-08-08 09:21:14 +08:00
|
|
|
|
import com.engine.salary.util.db.MapperProxyFactory;
|
|
|
|
|
|
import com.engine.salary.util.page.PageInfo;
|
|
|
|
|
|
import com.engine.salary.util.page.SalaryPageUtil;
|
|
|
|
|
|
import com.engine.salary.util.valid.ValidUtil;
|
2023-08-08 19:39:53 +08:00
|
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
2023-08-08 09:21:14 +08:00
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
2023-08-08 19:39:53 +08:00
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
import weaver.general.Util;
|
2023-08-08 09:21:14 +08:00
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
|
2023-08-09 18:35:09 +08:00
|
|
|
|
import java.time.LocalDate;
|
2023-08-08 09:21:14 +08:00
|
|
|
|
import java.util.*;
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2023-08-23 16:49:45 +08:00
|
|
|
|
* 人员报送(人员)
|
|
|
|
|
|
* <p>Copyright: Copyright (c) 2023</p>
|
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author qiantao
|
|
|
|
|
|
* @version 1.0
|
|
|
|
|
|
**/
|
2023-08-08 09:21:14 +08:00
|
|
|
|
@Slf4j
|
|
|
|
|
|
public class EmployeeDeclareServiceImpl extends Service implements EmployeeDeclareService {
|
|
|
|
|
|
|
|
|
|
|
|
private EmployeeDeclareMapper getEmployeeDeclareMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(EmployeeDeclareMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private TaxAgentService getTaxAgentService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SalaryEmployeeService getSalaryEmployeeService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SalaryArchiveService getSalaryArchiveService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-08 19:39:53 +08:00
|
|
|
|
private TaxDeclarationApiConfigService getTaxDeclarationApiConfigService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(TaxDeclarationApiConfigServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private TaxAgentTaxReturnService getTaxAgentTaxReturnService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(TaxAgentTaxReturnServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private EmployeeDeclareRecordService getEmployeeDeclareRecordService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(EmployeeDeclareRecordServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-09 18:35:09 +08:00
|
|
|
|
private TaxDeclarationApiBillingService getTaxDeclarationApiBillingService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(TaxDeclarationApiBillingServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-08 09:21:14 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public EmployeeDeclarePO getById(Long id) {
|
|
|
|
|
|
return getEmployeeDeclareMapper().getById(id);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<EmployeeDeclarePO> listByIds(Collection<Long> ids) {
|
2023-08-08 19:39:53 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(ids)) {
|
2023-08-08 09:21:14 +08:00
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
|
}
|
|
|
|
|
|
return getEmployeeDeclareMapper().listSome(EmployeeDeclarePO.builder().ids(ids).build());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2023-08-14 20:07:29 +08:00
|
|
|
|
public List<EmployeeDeclarePO> listByTaxCycleAndTaxAgentId(Date taxCycle, Long taxAgentId) {
|
2023-08-08 09:21:14 +08:00
|
|
|
|
return getEmployeeDeclareMapper().listSome(EmployeeDeclarePO.builder()
|
2023-08-14 20:07:29 +08:00
|
|
|
|
.taxCycle(taxCycle)
|
2023-08-08 09:21:14 +08:00
|
|
|
|
.taxAgentId(taxAgentId)
|
|
|
|
|
|
.build());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2023-08-14 20:07:29 +08:00
|
|
|
|
public List<EmployeeDeclarePO> listByTaxCycleAndTaxAgentIdAndEmployeeIds(Date taxCycle, Long taxAgentId, Collection<Long> employeeIds) {
|
2023-08-08 09:21:14 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(employeeIds)) {
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
|
}
|
|
|
|
|
|
return getEmployeeDeclareMapper().listSome(EmployeeDeclarePO.builder()
|
2023-08-14 20:07:29 +08:00
|
|
|
|
.taxCycle(taxCycle)
|
2023-08-08 09:21:14 +08:00
|
|
|
|
.taxAgentId(taxAgentId)
|
|
|
|
|
|
.employeeIds(employeeIds)
|
|
|
|
|
|
.build());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<EmployeeDeclarePO> listByParam(EmployeeDeclareListQueryParam queryParam) {
|
|
|
|
|
|
return getEmployeeDeclareMapper().listByParam(queryParam);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<EmployeeDeclarePO> list4AddByParam(EmployeeDeclareAddListQueryParam queryParam) {
|
2023-08-21 19:35:14 +08:00
|
|
|
|
queryParam.setPreTaxCycle(SalaryDateUtil.plusMonths(queryParam.getTaxCycle(), -1));
|
2023-08-08 09:21:14 +08:00
|
|
|
|
return getEmployeeDeclareMapper().list4AddByParam(queryParam);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<EmployeeDeclarePO> list4UpdateByParam(EmployeeDeclareListQueryParam queryParam) {
|
|
|
|
|
|
return getEmployeeDeclareMapper().list4UpdateByParam(queryParam);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public PageInfo<EmployeeDeclarePO> listPage4UpdateByParam(EmployeeDeclareListQueryParam queryParam) {
|
|
|
|
|
|
List<EmployeeDeclarePO> list = getEmployeeDeclareMapper().list4UpdateByParam(queryParam);
|
|
|
|
|
|
return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), list, EmployeeDeclarePO.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public List<EmployeeDeclarePO> list4FailByParam(EmployeeDeclareFailListQueryParam queryParam) {
|
|
|
|
|
|
// return new LambdaQueryChainWrapper<>(employeeDeclareMapper)
|
2023-08-09 18:35:09 +08:00
|
|
|
|
// .eq(EmployeeDeclarePO::getTenantKey)
|
2023-08-08 09:21:14 +08:00
|
|
|
|
// .eq(EmployeeDeclarePO::getDeleteType, DeleteTypeEnum.NOT_DELETED.getValue())
|
|
|
|
|
|
// .eq(EmployeeDeclarePO::getTaxAgentId, queryParam.getTaxAgentId())
|
|
|
|
|
|
// .eq(EmployeeDeclarePO::getTaxCycle, queryParam.getTaxCycle().toString())
|
|
|
|
|
|
// .eq(EmployeeDeclarePO::getDeclareStatus, DeclareStatusEnum.DECLARE_FAIL.getValue())
|
|
|
|
|
|
// .list();
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public PageInfo<EmployeeDeclarePO> listPage4FailByParam(EmployeeDeclareFailListQueryParam queryParam) {
|
|
|
|
|
|
ValidUtil.doValidator(queryParam);
|
|
|
|
|
|
List<EmployeeDeclarePO> list = getEmployeeDeclareMapper().listSome(EmployeeDeclarePO.builder()
|
|
|
|
|
|
.taxAgentId(queryParam.getTaxAgentId())
|
2023-08-14 20:07:29 +08:00
|
|
|
|
.taxCycle(queryParam.getTaxCycle())
|
2023-08-08 09:21:14 +08:00
|
|
|
|
.declareStatus(DeclareStatusEnum.DECLARE_FAIL.getValue())
|
|
|
|
|
|
.build());
|
|
|
|
|
|
PageInfo<EmployeeDeclarePO> page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(),
|
|
|
|
|
|
list, EmployeeDeclarePO.class);
|
|
|
|
|
|
return page;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-06 13:51:33 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public List<EmployeeDeclarePO> listBySalaryAcctTaxAgent(List<SalaryAcctTaxAgentPO> salaryAcctTaxAgents) {
|
|
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctTaxAgents)) {
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
|
}
|
|
|
|
|
|
Map<String, SalaryAcctTaxAgentPO> employeeDeclareParamMap = new HashMap<>();
|
|
|
|
|
|
for (SalaryAcctTaxAgentPO po : salaryAcctTaxAgents) {
|
|
|
|
|
|
employeeDeclareParamMap.putIfAbsent(po.getTaxAgentId() + "-" + po.getTaxCycle(), po);
|
|
|
|
|
|
}
|
|
|
|
|
|
List<EmployeeDeclarePO> employeeDeclares = new ArrayList<>();
|
|
|
|
|
|
for (Map.Entry<String, SalaryAcctTaxAgentPO> entry : employeeDeclareParamMap.entrySet()) {
|
|
|
|
|
|
SalaryAcctTaxAgentPO salaryAcctTaxAgent = entry.getValue();
|
|
|
|
|
|
List<EmployeeDeclarePO> temp = listByTaxCycleAndTaxAgentId(salaryAcctTaxAgent.getTaxCycle(), salaryAcctTaxAgent.getTaxAgentId());
|
|
|
|
|
|
employeeDeclares.addAll(temp);
|
|
|
|
|
|
}
|
|
|
|
|
|
return employeeDeclares;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-08 19:39:53 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void save(EmployeeDeclareSaveParam saveParam) {
|
|
|
|
|
|
Date now = new Date();
|
2023-08-21 19:35:14 +08:00
|
|
|
|
EmployeeDeclarePO employeeDeclare = new EmployeeDeclarePO();
|
|
|
|
|
|
employeeDeclare.setTaxAgentId(saveParam.getTaxAgentId());
|
|
|
|
|
|
employeeDeclare.setTaxCycle(saveParam.getTaxCycle());
|
|
|
|
|
|
employeeDeclare.setEmployeeName(saveParam.getEmployeeName());
|
|
|
|
|
|
employeeDeclare.setJobNum(saveParam.getJobNum());
|
2024-03-29 10:44:55 +08:00
|
|
|
|
employeeDeclare.setNationality(saveParam.getNationality());
|
|
|
|
|
|
employeeDeclare.setCardType(saveParam.getCardType().getValue());
|
2023-12-13 19:34:10 +08:00
|
|
|
|
employeeDeclare.setCardNum(saveParam.getCardNum().toUpperCase());
|
2024-03-29 10:44:55 +08:00
|
|
|
|
employeeDeclare.setGender(saveParam.getGender().getValue());
|
|
|
|
|
|
employeeDeclare.setBirthday(SalaryDateUtil.localDateToDate(saveParam.getBirthday()));
|
2024-04-10 09:08:24 +08:00
|
|
|
|
employeeDeclare.setBirthplace(saveParam.getBirthplace());
|
|
|
|
|
|
employeeDeclare.setTaxReasons(saveParam.getTaxReasons());
|
2023-08-21 19:35:14 +08:00
|
|
|
|
employeeDeclare.setEmploymentStatus(saveParam.getEmploymentStatus().getValue());
|
|
|
|
|
|
employeeDeclare.setMobile(saveParam.getMobile());
|
|
|
|
|
|
employeeDeclare.setEmploymentType(saveParam.getEmploymentType().getValue());
|
|
|
|
|
|
employeeDeclare.setEmploymentFirstYear("");
|
|
|
|
|
|
employeeDeclare.setEmploymentDate(SalaryDateUtil.localDateToDate(saveParam.getEmploymentDate()));
|
|
|
|
|
|
employeeDeclare.setDismissDate(SalaryDateUtil.localDateToDate(saveParam.getDismissDate()));
|
2024-03-29 10:44:55 +08:00
|
|
|
|
employeeDeclare.setEntryDate(SalaryDateUtil.localDateToDate(saveParam.getEntryDate()));
|
|
|
|
|
|
employeeDeclare.setDepartureDate(SalaryDateUtil.localDateToDate(saveParam.getDepartureDate()));
|
2023-08-21 19:35:14 +08:00
|
|
|
|
employeeDeclare.setDisability(saveParam.getDisability().getValue());
|
|
|
|
|
|
employeeDeclare.setDisabilityCardNo(saveParam.getDisabilityCardNo());
|
|
|
|
|
|
employeeDeclare.setLonelyOld(saveParam.getLonelyOld().getValue());
|
|
|
|
|
|
employeeDeclare.setMartyrDependents(saveParam.getMartyrDependents().getValue());
|
|
|
|
|
|
employeeDeclare.setMartyrDependentsCardNo(saveParam.getMartyrDependentsCardNo());
|
|
|
|
|
|
employeeDeclare.setDeductExpenses(saveParam.getDeductExpenses().getValue());
|
|
|
|
|
|
employeeDeclare.setSuccessfullyDeclared(0);
|
|
|
|
|
|
employeeDeclare.setNewEmployeeInfo(0);
|
|
|
|
|
|
employeeDeclare.setDeclareStatus(DeclareStatusEnum.NOT_DECLARE.getValue());
|
|
|
|
|
|
employeeDeclare.setDeclareErrorMsg("");
|
2024-03-08 11:14:00 +08:00
|
|
|
|
TaxAgentPO taxAgent = getTaxAgentService(user).getById(saveParam.getTaxAgentId());
|
2023-08-08 19:39:53 +08:00
|
|
|
|
if (Objects.isNull(saveParam.getId())) {
|
2023-08-21 19:35:14 +08:00
|
|
|
|
employeeDeclare.setId(IdGenerator.generate());
|
|
|
|
|
|
employeeDeclare.setEmployeeId(saveParam.getEmployeeId());
|
|
|
|
|
|
employeeDeclare.setEmployeeType(saveParam.getEmployeeType().getValue());
|
|
|
|
|
|
employeeDeclare.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
|
|
|
|
|
|
employeeDeclare.setCreator((long) user.getUID());
|
|
|
|
|
|
employeeDeclare.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue());
|
|
|
|
|
|
employeeDeclare.setCreateTime(now);
|
|
|
|
|
|
employeeDeclare.setUpdateTime(now);
|
2023-08-08 19:39:53 +08:00
|
|
|
|
getEmployeeDeclareMapper().insertIgnoreNull(employeeDeclare);
|
|
|
|
|
|
// 记录日志
|
2024-03-08 11:14:00 +08:00
|
|
|
|
LoggerContext<EmployeeDeclarePO> loggerContext = new LoggerContext<>();
|
|
|
|
|
|
loggerContext.setUser(user);
|
|
|
|
|
|
loggerContext.setTargetId(Util.null2String(saveParam.getTaxAgentId()));
|
|
|
|
|
|
loggerContext.setTargetName((taxAgent == null ? "" : taxAgent.getName()) + "-" + employeeDeclare.getEmployeeName());
|
|
|
|
|
|
loggerContext.setOperateType(OperateTypeEnum.ADD.getValue());
|
|
|
|
|
|
loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新增报送人员"));
|
|
|
|
|
|
loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新增报送人员:") + employeeDeclare.getEmployeeName());
|
|
|
|
|
|
loggerContext.setNewValues(employeeDeclare);
|
|
|
|
|
|
SalaryElogConfig.employeeDeclareLoggerTemplate.write(loggerContext);
|
2023-08-08 19:39:53 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
EmployeeDeclarePO originEmployeeDeclare = getById(saveParam.getId());
|
|
|
|
|
|
if (Objects.isNull(originEmployeeDeclare)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156442, "人员不存在或已被删除"));
|
|
|
|
|
|
}
|
|
|
|
|
|
if (Objects.equals(originEmployeeDeclare.getSuccessfullyDeclared(), 1)
|
|
|
|
|
|
&& !Objects.equals(originEmployeeDeclare.getEmployeeName(), employeeDeclare.getEmployeeName())
|
|
|
|
|
|
&& !Objects.equals(originEmployeeDeclare.getCardNum(), employeeDeclare.getCardNum())) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156443, "成功报送过的人员,姓名和证件号码只能修改其一,同时需要修改的请前往办税服务厅"));
|
|
|
|
|
|
}
|
2023-08-21 19:35:14 +08:00
|
|
|
|
employeeDeclare.setId(originEmployeeDeclare.getId());
|
|
|
|
|
|
employeeDeclare.setEmployeeId(originEmployeeDeclare.getEmployeeId());
|
|
|
|
|
|
employeeDeclare.setEmployeeType(originEmployeeDeclare.getEmployeeType());
|
2023-12-06 16:37:42 +08:00
|
|
|
|
employeeDeclare.setTenantKey(originEmployeeDeclare.getTenantKey());
|
|
|
|
|
|
employeeDeclare.setCreator(originEmployeeDeclare.getCreator());
|
|
|
|
|
|
employeeDeclare.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue());
|
|
|
|
|
|
employeeDeclare.setCreateTime(originEmployeeDeclare.getCreateTime());
|
2023-08-21 19:35:14 +08:00
|
|
|
|
employeeDeclare.setUpdateTime(now);
|
2023-12-06 16:37:42 +08:00
|
|
|
|
employeeDeclare.setSuccessfullyDeclared(originEmployeeDeclare.getSuccessfullyDeclared());
|
2023-08-08 19:39:53 +08:00
|
|
|
|
// 判断本次编辑是否有修改人员信息
|
|
|
|
|
|
if (!StringUtils.equals(employeeDeclare.toCompareString(), originEmployeeDeclare.toCompareString())) {
|
|
|
|
|
|
employeeDeclare.setNewEmployeeInfo(1);
|
|
|
|
|
|
}
|
2023-12-05 17:17:11 +08:00
|
|
|
|
getEmployeeDeclareMapper().update(employeeDeclare);
|
2023-08-08 19:39:53 +08:00
|
|
|
|
// 记录日志
|
2024-03-08 15:09:42 +08:00
|
|
|
|
LoggerContext<EmployeeDeclarePO> loggerContext = new LoggerContext<>();
|
|
|
|
|
|
loggerContext.setUser(user);
|
|
|
|
|
|
loggerContext.setTargetId(Util.null2String(saveParam.getTaxAgentId()));
|
|
|
|
|
|
loggerContext.setTargetName((taxAgent == null ? "" : taxAgent.getName()) + "-" + employeeDeclare.getEmployeeName());
|
|
|
|
|
|
loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
|
|
|
|
|
|
loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "编辑报送人员"));
|
|
|
|
|
|
loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "编辑报送人员:") + employeeDeclare.getEmployeeName());
|
|
|
|
|
|
loggerContext.setOldValues(originEmployeeDeclare);
|
|
|
|
|
|
loggerContext.setNewValues(employeeDeclare);
|
2024-03-07 09:29:59 +08:00
|
|
|
|
SalaryElogConfig.employeeDeclareLoggerTemplate.write(loggerContext);
|
2023-08-08 19:39:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-09 18:35:09 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void batchUpdate(EmployeeDeclareBatchUpdateParam batchUpdateParam) {
|
|
|
|
|
|
// 查询报送人员
|
|
|
|
|
|
List<EmployeeDeclarePO> employeeDeclares;
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(batchUpdateParam.getIds())) {
|
|
|
|
|
|
employeeDeclares = listByIds(batchUpdateParam.getIds());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
employeeDeclares = listByParam(batchUpdateParam);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 人员为空时,不允许批量编辑
|
|
|
|
|
|
if (CollectionUtils.isEmpty(employeeDeclares)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(182693, "当前人员列表为空,请选择要批量编辑的人员"));
|
|
|
|
|
|
}
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
// 校验参数
|
|
|
|
|
|
if (Objects.equals(batchUpdateParam.getBatchUpdateItem(), "employmentStatus")) {
|
|
|
|
|
|
EmploymentStatusEnum employmentStatusEnum = null;
|
|
|
|
|
|
for (EmploymentStatusEnum value : EmploymentStatusEnum.values()) {
|
|
|
|
|
|
if (Objects.equals(value.name(), batchUpdateParam.getItemValue())) {
|
|
|
|
|
|
employmentStatusEnum = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (employmentStatusEnum == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
|
|
|
|
|
|
}
|
|
|
|
|
|
for (EmployeeDeclarePO employeeDeclare : employeeDeclares) {
|
|
|
|
|
|
if (!Objects.equals(employeeDeclare.getEmploymentStatus(), employmentStatusEnum.getValue())) {
|
|
|
|
|
|
employeeDeclare.setEmploymentStatus(employmentStatusEnum.getValue());
|
|
|
|
|
|
employeeDeclare.setNewEmployeeInfo(1);
|
|
|
|
|
|
employeeDeclare.setDeclareStatus(DeclareStatusEnum.NOT_DECLARE.getValue());
|
|
|
|
|
|
employeeDeclare.setDeclareErrorMsg("");
|
|
|
|
|
|
employeeDeclare.setUpdateTime(now);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (Objects.equals(batchUpdateParam.getBatchUpdateItem(), "employmentType")) {
|
|
|
|
|
|
EmploymentTypeEnum employmentTypeEnum = null;
|
|
|
|
|
|
for (EmploymentTypeEnum value : EmploymentTypeEnum.values()) {
|
|
|
|
|
|
if (Objects.equals(value.name(), batchUpdateParam.getItemValue())) {
|
|
|
|
|
|
employmentTypeEnum = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (employmentTypeEnum == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
|
|
|
|
|
|
}
|
|
|
|
|
|
for (EmployeeDeclarePO employeeDeclare : employeeDeclares) {
|
|
|
|
|
|
if (!Objects.equals(employeeDeclare.getEmploymentType(), employmentTypeEnum.getValue())) {
|
|
|
|
|
|
employeeDeclare.setEmploymentType(employmentTypeEnum.getValue());
|
|
|
|
|
|
employeeDeclare.setNewEmployeeInfo(1);
|
|
|
|
|
|
employeeDeclare.setDeclareStatus(DeclareStatusEnum.NOT_DECLARE.getValue());
|
|
|
|
|
|
employeeDeclare.setDeclareErrorMsg("");
|
|
|
|
|
|
employeeDeclare.setUpdateTime(now);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (Objects.equals(batchUpdateParam.getBatchUpdateItem(), "employmentDate")) {
|
|
|
|
|
|
if (!SalaryDateUtil.checkDay(batchUpdateParam.getItemValue())) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
|
|
|
|
|
|
}
|
|
|
|
|
|
Date employmentDate = SalaryDateUtil.localDateToDate(LocalDate.parse(batchUpdateParam.getItemValue()));
|
|
|
|
|
|
for (EmployeeDeclarePO employeeDeclare : employeeDeclares) {
|
|
|
|
|
|
if (!Objects.equals(employeeDeclare.getEmploymentDate(), employmentDate)) {
|
|
|
|
|
|
employeeDeclare.setEmploymentDate(employmentDate);
|
|
|
|
|
|
employeeDeclare.setNewEmployeeInfo(1);
|
|
|
|
|
|
employeeDeclare.setDeclareStatus(DeclareStatusEnum.NOT_DECLARE.getValue());
|
|
|
|
|
|
employeeDeclare.setDeclareErrorMsg("");
|
|
|
|
|
|
employeeDeclare.setUpdateTime(now);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (Objects.equals(batchUpdateParam.getBatchUpdateItem(), "dismissDate")) {
|
|
|
|
|
|
if (!SalaryDateUtil.checkDay(batchUpdateParam.getItemValue())) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
|
|
|
|
|
|
}
|
|
|
|
|
|
Date dismissDate = SalaryDateUtil.localDateToDate(LocalDate.parse(batchUpdateParam.getItemValue()));
|
|
|
|
|
|
for (EmployeeDeclarePO employeeDeclare : employeeDeclares) {
|
|
|
|
|
|
if (!Objects.equals(employeeDeclare.getDismissDate(), dismissDate)) {
|
|
|
|
|
|
employeeDeclare.setDismissDate(dismissDate);
|
|
|
|
|
|
employeeDeclare.setNewEmployeeInfo(1);
|
|
|
|
|
|
employeeDeclare.setDeclareStatus(DeclareStatusEnum.NOT_DECLARE.getValue());
|
|
|
|
|
|
employeeDeclare.setDeclareErrorMsg("");
|
|
|
|
|
|
employeeDeclare.setUpdateTime(now);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (Objects.equals(batchUpdateParam.getBatchUpdateItem(), "deductExpenses")) {
|
|
|
|
|
|
SalaryOnOffEnum salaryOnOffEnum = null;
|
|
|
|
|
|
for (SalaryOnOffEnum value : SalaryOnOffEnum.values()) {
|
|
|
|
|
|
if (Objects.equals(value.name(), batchUpdateParam.getItemValue())) {
|
|
|
|
|
|
salaryOnOffEnum = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (salaryOnOffEnum == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
|
|
|
|
|
|
}
|
|
|
|
|
|
for (EmployeeDeclarePO employeeDeclare : employeeDeclares) {
|
|
|
|
|
|
if (!Objects.equals(employeeDeclare.getDeductExpenses(), salaryOnOffEnum.getValue())) {
|
|
|
|
|
|
employeeDeclare.setDeductExpenses(salaryOnOffEnum.getValue());
|
|
|
|
|
|
employeeDeclare.setNewEmployeeInfo(1);
|
|
|
|
|
|
employeeDeclare.setDeclareStatus(DeclareStatusEnum.NOT_DECLARE.getValue());
|
|
|
|
|
|
employeeDeclare.setDeclareErrorMsg("");
|
|
|
|
|
|
employeeDeclare.setUpdateTime(now);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
employeeDeclares.forEach(getEmployeeDeclareMapper()::updateIgnoreNull);
|
2023-08-08 09:21:14 +08:00
|
|
|
|
// updateBatchById(employeeDeclares);
|
2023-08-09 18:35:09 +08:00
|
|
|
|
}
|
2023-08-08 09:21:14 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void deleteByIds(Collection<Long> ids) {
|
|
|
|
|
|
List<EmployeeDeclarePO> employeeDeclares = listByIds(ids);
|
|
|
|
|
|
if (CollectionUtils.isEmpty(employeeDeclares)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156466, "参数错误,人员不存在或已被删除"));
|
|
|
|
|
|
}
|
|
|
|
|
|
boolean declareSuccess = employeeDeclares.stream().anyMatch(e -> Objects.equals(e.getSuccessfullyDeclared(), 1));
|
|
|
|
|
|
if (declareSuccess) {
|
2024-04-10 09:08:24 +08:00
|
|
|
|
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156467, "报送成功过的人员不允许删除"));
|
2023-08-08 09:21:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
getEmployeeDeclareMapper().deleteByIds(ids, new Date());
|
|
|
|
|
|
// 记录日志
|
2024-03-08 11:14:00 +08:00
|
|
|
|
List<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAll();
|
|
|
|
|
|
Map<Long, TaxAgentPO> taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId);
|
|
|
|
|
|
for (EmployeeDeclarePO employeeDeclare : employeeDeclares) {
|
|
|
|
|
|
TaxAgentPO taxAgent = taxAgentMap.get(employeeDeclare.getTaxAgentId());
|
|
|
|
|
|
LoggerContext<EmployeeDeclarePO> loggerContext = new LoggerContext<>();
|
|
|
|
|
|
loggerContext.setUser(user);
|
|
|
|
|
|
loggerContext.setTargetId(Util.null2String(employeeDeclare.getTaxAgentId()));
|
2024-03-08 15:09:42 +08:00
|
|
|
|
loggerContext.setTargetName((taxAgent == null ? "" : taxAgent.getName()) + "-" + employeeDeclare.getEmployeeName());
|
2024-03-08 11:14:00 +08:00
|
|
|
|
loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue());
|
|
|
|
|
|
loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除报送人员"));
|
|
|
|
|
|
loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除报送人员:") + employeeDeclare.getEmployeeName());
|
|
|
|
|
|
loggerContext.setNewValues(employeeDeclare);
|
|
|
|
|
|
SalaryElogConfig.employeeDeclareLoggerTemplate.write(loggerContext);
|
2024-03-08 15:09:42 +08:00
|
|
|
|
}
|
2023-08-08 09:21:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<EmployeeDeclareListDTO> convert(List<EmployeeDeclarePO> employeeDeclares) {
|
|
|
|
|
|
if (CollectionUtils.isEmpty(employeeDeclares)) {
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 查询个税扣缴义务人
|
|
|
|
|
|
Set<Long> taxAgentIds = SalaryEntityUtil.properties(employeeDeclares, EmployeeDeclarePO::getTaxAgentId);
|
|
|
|
|
|
List<TaxAgentPO> taxAgents = getTaxAgentService(user).listByIds(taxAgentIds);
|
|
|
|
|
|
List<EmployeeDeclareListDTO> dtoList = EmployeeDeclareList.convert(employeeDeclares, taxAgents);
|
|
|
|
|
|
// 人员id集合
|
|
|
|
|
|
List<Long> employeeIds = employeeDeclares.stream().map(EmployeeDeclarePO::getEmployeeId).distinct().collect(Collectors.toList());
|
|
|
|
|
|
// 获取人员部门、分部详细信息
|
|
|
|
|
|
Map<String, DataCollectionEmployee> employeeInfoMap = SalaryEntityUtil.convert2Map(getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds), emp -> emp.getEmployeeId() + "-" + emp.isExtEmp());
|
|
|
|
|
|
// 补充分部,部门
|
|
|
|
|
|
dtoList.forEach(po -> {
|
|
|
|
|
|
boolean isExtEmp = EmployeeTypeEnum.EXT_EMPLOYEE.getValue().compareTo(po.getEmployeeType().getValue()) == 0;
|
|
|
|
|
|
DataCollectionEmployee employee = employeeInfoMap.get(po.getEmployeeId() + "-" + isExtEmp);
|
2023-08-08 19:39:53 +08:00
|
|
|
|
if (ObjectUtils.isNotEmpty(employee)) {
|
2023-08-08 09:21:14 +08:00
|
|
|
|
po.setSubCompanyName(Optional.ofNullable(employee.getSubcompanyName()).orElse(""));
|
|
|
|
|
|
po.setDepartmentName(Optional.ofNullable(employee.getDepartmentName()).orElse(""));
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
return dtoList;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<EmployeeDeclareFailListDTO> convert2FailListDTO(List<EmployeeDeclarePO> employeeDeclares) {
|
|
|
|
|
|
if (CollectionUtils.isEmpty(employeeDeclares)) {
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
|
}
|
|
|
|
|
|
// 查询人员信息
|
|
|
|
|
|
List<Long> employeeIds = SalaryEntityUtil.properties(employeeDeclares, EmployeeDeclarePO::getEmployeeId, Collectors.toList());
|
|
|
|
|
|
Map<String, DataCollectionEmployee> employeeInfoMap = SalaryEntityUtil.convert2Map(getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds), emp -> emp.getEmployeeId() + "-" + emp.isExtEmp());
|
|
|
|
|
|
return EmployeeDeclareList.convert2FailListDTO(employeeDeclares, employeeInfoMap);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void refresh(EmployeeDeclareRefreshParam refreshParam, Long employeeId) {
|
|
|
|
|
|
// 查询本月已有的需要报送的人员
|
|
|
|
|
|
List<EmployeeDeclarePO> employeeDeclares = listByTaxCycleAndTaxAgentId(refreshParam.getTaxCycle(), refreshParam.getTaxAgentId());
|
2024-03-07 21:12:09 +08:00
|
|
|
|
// 查询上月已有报送的人员
|
2024-03-08 15:09:42 +08:00
|
|
|
|
List<EmployeeDeclarePO> preTaxCycleEmployeeDeclares = listByTaxCycleAndTaxAgentId(SalaryDateUtil.plusMonths(refreshParam.getTaxCycle(), -1), refreshParam.getTaxAgentId())
|
|
|
|
|
|
//只需要正常的
|
|
|
|
|
|
.stream()
|
2024-08-08 11:52:10 +08:00
|
|
|
|
.filter(e -> Objects.equals(e.getDeclareStatus(), DeclareStatusEnum.DECLARE_SUCCESS.getValue()))
|
2024-03-08 15:09:42 +08:00
|
|
|
|
.collect(Collectors.toList());
|
2023-08-08 09:21:14 +08:00
|
|
|
|
// 查询个税扣缴义务人
|
|
|
|
|
|
TaxAgentPO taxAgent = getTaxAgentService(user).getById(refreshParam.getTaxAgentId());
|
|
|
|
|
|
// 根据税款所属期计算出薪资周期
|
2023-08-14 20:07:29 +08:00
|
|
|
|
Date salaryCycle;
|
|
|
|
|
|
Date taxCycle = refreshParam.getTaxCycle();
|
2023-08-08 09:21:14 +08:00
|
|
|
|
// TODO:先临时写死本月!!!!需先完成个税扣缴义务人的改造
|
|
|
|
|
|
// SalaryCycleTypeEnum salaryCycleTypeEnum = SalaryEnumUtil.enumMatchByValue(taxAgent.getTaxCycleType(), SalaryCycleTypeEnum.class);
|
|
|
|
|
|
SalaryCycleTypeEnum salaryCycleTypeEnum = SalaryCycleTypeEnum.THIS_MONTH;
|
|
|
|
|
|
if (salaryCycleTypeEnum == SalaryCycleTypeEnum.BEFORE_LAST_MONTH) {
|
2023-08-14 20:07:29 +08:00
|
|
|
|
salaryCycle = SalaryDateUtil.plusMonths(taxCycle, 2);
|
2023-08-08 09:21:14 +08:00
|
|
|
|
} else if (salaryCycleTypeEnum == SalaryCycleTypeEnum.LAST_MONTH) {
|
2023-08-14 20:07:29 +08:00
|
|
|
|
salaryCycle = SalaryDateUtil.plusMonths(taxCycle, 1);
|
2023-08-08 09:21:14 +08:00
|
|
|
|
} else if (salaryCycleTypeEnum == SalaryCycleTypeEnum.NEXT_MONTH) {
|
2023-08-14 20:07:29 +08:00
|
|
|
|
salaryCycle = SalaryDateUtil.plusMonths(taxCycle, -1);
|
2023-08-08 09:21:14 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
salaryCycle = taxCycle;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 查询薪资档案的发薪人员
|
2023-08-14 20:07:29 +08:00
|
|
|
|
LocalDateRange salaryCycleRange = LocalDateRange.builder().fromDate(salaryCycle).endDate(SalaryDateUtil.localDateToDate(SalaryDateUtil.localDate2YearMonth(salaryCycle).atEndOfMonth())).build();
|
2025-02-12 14:16:17 +08:00
|
|
|
|
List<SalaryArchiveDataDTO> salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salaryCycleRange, Collections.emptyList(), Collections.singletonList(refreshParam.getTaxAgentId()));
|
2023-08-08 09:21:14 +08:00
|
|
|
|
List<Long> employeeIds = salaryArchiveDataDTOS.stream().map(SalaryArchiveDataDTO::getEmployeeId).collect(Collectors.toList());
|
|
|
|
|
|
List<SalaryArchivePO> salaryArchivePOS = getSalaryArchiveService(user).listSome(SalaryArchivePO.builder().taxAgentId(refreshParam.getTaxAgentId()).employeeIds(employeeIds).build());
|
|
|
|
|
|
|
|
|
|
|
|
// 本月增加了哪些人员
|
2023-08-08 19:39:53 +08:00
|
|
|
|
Set<Long> orgEmployeeIds = ((List<EmployeeDeclarePO>) CollectionUtils.union(preTaxCycleEmployeeDeclares, employeeDeclares))
|
2023-08-08 09:21:14 +08:00
|
|
|
|
.stream()
|
|
|
|
|
|
.filter(e -> Objects.equals(e.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue()))
|
|
|
|
|
|
.map(EmployeeDeclarePO::getEmployeeId)
|
|
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
|
Set<Long> newOrgEmployeeIds = salaryArchiveDataDTOS.stream()
|
|
|
|
|
|
.map(SalaryArchiveDataDTO::getEmployeeId)
|
|
|
|
|
|
.filter(e -> !orgEmployeeIds.contains(e))
|
|
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
|
// 查询新增加的人员信息
|
|
|
|
|
|
List<DataCollectionEmployee> employeeInfos = getSalaryEmployeeService(user).getEmployeeByIdsAll(new ArrayList<>(newOrgEmployeeIds));
|
2023-08-09 18:35:09 +08:00
|
|
|
|
// List<SimpleUserInfo> newSimpleUserInfos = salaryEmployeeService.listByEmployeeIds(newOrgEmployeeIds);
|
2023-08-08 09:21:14 +08:00
|
|
|
|
// List<HrmEmployeeComInfo> newHrmEmployeeComInfos = comInfoCache.getCacheList(HrmEmployeeComInfo.class, Lists.newArrayList(newOrgEmployeeIds));
|
|
|
|
|
|
// 查询本月增加了哪些非系统人员
|
2023-08-08 19:39:53 +08:00
|
|
|
|
// List<ExtEmpPO> extEmployees = extEmployeeService.listBySalaryCycleAndTaxAgentId(salaryCycleRange, refreshParam.getTaxAgentId());
|
2023-08-08 09:21:14 +08:00
|
|
|
|
// Set<Long> extEmployeeIds = employeeDeclares.stream()
|
|
|
|
|
|
// .filter(e -> Objects.equals(e.getEmployeeType(), EmployeeTypeEnum.EXT_EMPLOYEE.getValue()))
|
|
|
|
|
|
// .map(EmployeeDeclarePO::getEmployeeId)
|
|
|
|
|
|
// .collect(Collectors.toSet());
|
2023-08-08 19:39:53 +08:00
|
|
|
|
// List<ExtEmpPO> newExtEmployees = extEmployees.stream()
|
2023-08-08 09:21:14 +08:00
|
|
|
|
// .filter(e -> !extEmployeeIds.contains(e.getId()))
|
|
|
|
|
|
// .collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
// 本次新增的需要报送的人员
|
|
|
|
|
|
EmployeeDeclareRefreshDTO dto = new EmployeeDeclareRefreshDTO()
|
|
|
|
|
|
.setTaxAgentId(taxAgent.getId())
|
|
|
|
|
|
.setTaxCycle(taxCycle)
|
|
|
|
|
|
.setEmployeeDeclares(employeeDeclares)
|
|
|
|
|
|
.setPreTaxCycleEmployeeDeclare(preTaxCycleEmployeeDeclares)
|
|
|
|
|
|
.setSalaryArchives(salaryArchivePOS)
|
2023-08-08 19:39:53 +08:00
|
|
|
|
.setHrmEmployeeComInfos(employeeInfos);
|
2023-08-08 09:21:14 +08:00
|
|
|
|
EmployeeDeclareRefresh.Result result = EmployeeDeclareRefresh.refresh(dto, employeeId);
|
2023-08-18 09:27:16 +08:00
|
|
|
|
// 保存新增的人员
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(result.getNewEmployeeDeclares())) {
|
|
|
|
|
|
result.getNewEmployeeDeclares().forEach(getEmployeeDeclareMapper()::insertIgnoreNull);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 更新已有人员
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(result.getEmployeeDeclares())) {
|
|
|
|
|
|
result.getEmployeeDeclares().forEach(getEmployeeDeclareMapper()::updateIgnoreNull);
|
|
|
|
|
|
}
|
2024-03-07 09:29:59 +08:00
|
|
|
|
|
2024-03-08 15:09:42 +08:00
|
|
|
|
// 记录日志
|
|
|
|
|
|
LoggerContext<EmployeeDeclarePO> loggerContext = new LoggerContext<>();
|
|
|
|
|
|
loggerContext.setUser(user);
|
|
|
|
|
|
loggerContext.setTargetId(refreshParam.getTaxAgentId().toString());
|
|
|
|
|
|
loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "个税扣缴义务人:「{0}」税款所属期:「{1}」").replace("{0}", taxAgent.getName()).replace("{1}", SalaryDateUtil.getFormatYearMonth(refreshParam.getTaxCycle())));
|
|
|
|
|
|
loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
|
|
|
|
|
|
loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "刷新数据"));
|
|
|
|
|
|
loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "刷新数据"));
|
|
|
|
|
|
SalaryElogConfig.employeeDeclareLoggerTemplate.write(loggerContext);
|
2023-08-08 09:21:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public EmployeeDeclareInfoDTO getDeclareInfo(EmployeeDeclareParam employeeDeclareParam) {
|
|
|
|
|
|
// 查询本月已有的需要报送的人员
|
|
|
|
|
|
List<EmployeeDeclarePO> employeeDeclares = listByTaxCycleAndTaxAgentId(employeeDeclareParam.getTaxCycle(), employeeDeclareParam.getTaxAgentId());
|
|
|
|
|
|
// 本月是否有修改过人员信息
|
|
|
|
|
|
boolean updateEmployeeInfo = employeeDeclares.stream().anyMatch(e -> Objects.equals(e.getNewEmployeeInfo(), 1) && Objects.equals(e.getDeclareStatus(), DeclareStatusEnum.NOT_DECLARE.getValue()));
|
|
|
|
|
|
// 本月报送失败的人数
|
|
|
|
|
|
Integer declareFailSize = (int) employeeDeclares.stream().filter(e -> Objects.equals(e.getDeclareStatus(), DeclareStatusEnum.DECLARE_FAIL.getValue())).count();
|
|
|
|
|
|
// 本月未报送的人数
|
|
|
|
|
|
Integer notDeclareSize = (int) employeeDeclares.stream().filter(e -> Objects.equals(e.getDeclareStatus(), DeclareStatusEnum.NOT_DECLARE.getValue())).count();
|
|
|
|
|
|
// 本月报送成功的人数
|
|
|
|
|
|
Integer declareSuccessSize = (int) employeeDeclares.stream().filter(e -> Objects.equals(e.getDeclareStatus(), DeclareStatusEnum.DECLARE_SUCCESS.getValue())).count();
|
|
|
|
|
|
return new EmployeeDeclareInfoDTO()
|
|
|
|
|
|
.setShowUpdate(updateEmployeeInfo)
|
|
|
|
|
|
.setDeclareFailSize(declareFailSize)
|
|
|
|
|
|
.setNotDeclareSize(notDeclareSize)
|
|
|
|
|
|
.setDeclareSuccessSize(declareSuccessSize);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-08 19:39:53 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void declare(EmployeeDeclareParam param) {
|
|
|
|
|
|
// 获取api配置信息
|
|
|
|
|
|
TaxDeclarationApiConfigPO apiConfig = getTaxDeclarationApiConfigService(user).getConfig(true);
|
|
|
|
|
|
// 查询个税扣缴义务人
|
|
|
|
|
|
TaxAgentPO taxAgent = getTaxAgentService(user).getById(param.getTaxAgentId());
|
|
|
|
|
|
// 查询个税扣缴义务人关联的企业信息
|
|
|
|
|
|
TaxAgentTaxReturnPO taxAgentTaxReturn = getTaxAgentTaxReturnService(user).getByTaxAgentId(param.getTaxAgentId());
|
|
|
|
|
|
if (Objects.isNull(taxAgentTaxReturn) || !Objects.equals(taxAgentTaxReturn.getCheckStatus(), TaxAgentTaxReturnStatusEnum.SUCCESS.getValue())) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156469, "个税扣缴义务人的报税信息验证未通过,请先维护好个税扣缴义务人的报税信息"));
|
|
|
|
|
|
}
|
|
|
|
|
|
// 查询需要报送的人员
|
|
|
|
|
|
List<EmployeeDeclarePO> employeeDeclares = listByTaxCycleAndTaxAgentId(param.getTaxCycle(), param.getTaxAgentId());
|
|
|
|
|
|
if (CollectionUtils.isEmpty(employeeDeclares)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156470, "当前报送人员列表暂无数据"));
|
|
|
|
|
|
}
|
|
|
|
|
|
EmployeeDeclareRecordPO employeeDeclareRecord = getEmployeeDeclareRecordService(user).getByTaxCycleAndTaxAgentId(param.getTaxCycle(), param.getTaxAgentId());
|
|
|
|
|
|
if (employeeDeclareRecord != null && StringUtils.isNotEmpty(employeeDeclareRecord.getRequestId())) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156471, "报送中,稍后请点击【获取报送结果】更新报送状态"));
|
|
|
|
|
|
}
|
|
|
|
|
|
// 人员列表
|
|
|
|
|
|
List<Map<String, Object>> employeeInfoMapList = EmployeeDeclareRequest.convert2RequestParam(employeeDeclares);
|
|
|
|
|
|
// 企业信息
|
|
|
|
|
|
Map<String, Object> requestParam = TaxAgentTaxReturnBO.convert2RequestMap(taxAgent, taxAgentTaxReturn);
|
|
|
|
|
|
// 税款所属期
|
2023-08-20 14:03:43 +08:00
|
|
|
|
requestParam.put("skssq", SalaryDateUtil.getFormatYearMonth(param.getTaxCycle()).replace("-", ""));
|
2023-08-08 19:39:53 +08:00
|
|
|
|
// 人员列表
|
|
|
|
|
|
requestParam.put("rylb", employeeInfoMapList);
|
|
|
|
|
|
|
|
|
|
|
|
String reqJson = JsonUtil.toJsonString(requestParam);
|
|
|
|
|
|
String url = apiConfig.getHost() + SzyhApiConstant.DECLARE_EMPLOYEE_INFO;
|
|
|
|
|
|
Map<String, String> params = new HashMap<>(1);
|
|
|
|
|
|
Map<String, String> header = SingnatureData.initHeader(params, apiConfig.getAppKey(), apiConfig.getAppSecret());
|
|
|
|
|
|
String res = HttpUtil.doPost(url, header, reqJson, HttpUtil.JSON_TYPE);
|
2024-08-08 11:52:10 +08:00
|
|
|
|
log.info("发起人员报送:{} 反馈{}", reqJson, res);
|
2023-08-08 19:39:53 +08:00
|
|
|
|
DeclareEmployeeInfoResponse declareEmployeeInfoResponse = JsonUtil.parseObject(res, DeclareEmployeeInfoResponse.class);
|
|
|
|
|
|
if (Objects.isNull(declareEmployeeInfoResponse) || Objects.isNull(declareEmployeeInfoResponse.getHead())) {
|
|
|
|
|
|
log.error("服务异常:" + res);
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156449, "服务异常"));
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!Objects.equals(declareEmployeeInfoResponse.getHead().getCode(), SzyhApiConstant.SUCCESS_CODE)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(declareEmployeeInfoResponse.getHead().getMsg());
|
|
|
|
|
|
}
|
|
|
|
|
|
// 删除原来的人员报送记录
|
|
|
|
|
|
getEmployeeDeclareRecordService(user).deleteByTaxCycleAndTaxAgentId(param.getTaxCycle(), param.getTaxAgentId());
|
|
|
|
|
|
// 保存新的人员报送记录
|
2023-08-09 18:35:09 +08:00
|
|
|
|
Date now = new Date();
|
2023-08-08 19:39:53 +08:00
|
|
|
|
AsyncRequestIdDTO asyncRequestIdDTO = declareEmployeeInfoResponse.getBody();
|
|
|
|
|
|
employeeDeclareRecord = new EmployeeDeclareRecordPO()
|
|
|
|
|
|
.setId(IdGenerator.generate())
|
|
|
|
|
|
.setTaxAgentId(param.getTaxAgentId())
|
2023-08-15 20:48:09 +08:00
|
|
|
|
.setTaxCycle(param.getTaxCycle())
|
2023-08-08 19:39:53 +08:00
|
|
|
|
.setRequestId(asyncRequestIdDTO.getRequestId())
|
|
|
|
|
|
.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
2023-08-09 18:35:09 +08:00
|
|
|
|
.setCreator((long) user.getUID())
|
2023-08-08 19:39:53 +08:00
|
|
|
|
.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue())
|
|
|
|
|
|
.setCreateTime(now)
|
|
|
|
|
|
.setUpdateTime(now);
|
|
|
|
|
|
getEmployeeDeclareRecordService(user).save(employeeDeclareRecord);
|
|
|
|
|
|
// 记录日志
|
2024-03-08 15:09:42 +08:00
|
|
|
|
LoggerContext<EmployeeDeclarePO> loggerContext = new LoggerContext<>();
|
|
|
|
|
|
loggerContext.setUser(user);
|
|
|
|
|
|
loggerContext.setTargetId(param.getTaxAgentId().toString());
|
|
|
|
|
|
loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "个税扣缴义务人:「{0}」税款所属期:「{1}」").replace("{0}", taxAgent.getName()).replace("{1}", SalaryDateUtil.getFormatYearMonth(param.getTaxCycle())));
|
|
|
|
|
|
loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
|
|
|
|
|
|
loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "全部报送"));
|
|
|
|
|
|
loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "全部报送"));
|
|
|
|
|
|
SalaryElogConfig.employeeDeclareLoggerTemplate.write(loggerContext);
|
2023-08-08 19:39:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void getDeclareFeedback(EmployeeDeclareParam param, EmployeeDeclareRateDTO employeeDeclareRate) {
|
|
|
|
|
|
// 获取api配置信息
|
|
|
|
|
|
TaxDeclarationApiConfigPO apiConfig = getTaxDeclarationApiConfigService(user).getConfig(true);
|
|
|
|
|
|
// 查询个税扣缴义务人
|
|
|
|
|
|
TaxAgentPO taxAgent = getTaxAgentService(user).getById(param.getTaxAgentId());
|
|
|
|
|
|
// 查询人员报送记录
|
|
|
|
|
|
EmployeeDeclareRecordPO employeeDeclareRecord = getEmployeeDeclareRecordService(user).getByTaxCycleAndTaxAgentId(param.getTaxCycle(), param.getTaxAgentId());
|
|
|
|
|
|
if (Objects.isNull(employeeDeclareRecord)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156451, "请先报送后再获取报送结果"));
|
|
|
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isEmpty(employeeDeclareRecord.getRequestId())) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156451, "请先报送后再获取报送结果"));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String url = apiConfig.getHost() + SzyhApiConstant.DECLARE_EMPLOYEE_INFO_FEEDBACK;
|
|
|
|
|
|
ImmutableMap<String, String> requestParam = ImmutableMap.of("requestId", employeeDeclareRecord.getRequestId());
|
|
|
|
|
|
Map<String, String> header = SingnatureData.initHeader(Collections.emptyMap(), apiConfig.getAppKey(), apiConfig.getAppSecret());
|
|
|
|
|
|
String res = HttpUtil.getRequest(url, header, requestParam);
|
2025-05-12 15:24:21 +08:00
|
|
|
|
log.info("人员报送反馈:{}", res);
|
2023-08-08 19:39:53 +08:00
|
|
|
|
DeclareEmployeeFeedbackResponse declareEmployeeFeedbackResponse = JsonUtil.parseObject(res, DeclareEmployeeFeedbackResponse.class);
|
|
|
|
|
|
if (Objects.isNull(declareEmployeeFeedbackResponse) || Objects.isNull(declareEmployeeFeedbackResponse.getHead())) {
|
|
|
|
|
|
log.error("服务异常:" + res);
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156449, "服务异常"));
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!Objects.equals(declareEmployeeFeedbackResponse.getHead().getCode(), SzyhApiConstant.SUCCESS_CODE)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(declareEmployeeFeedbackResponse.getHead().getMsg());
|
|
|
|
|
|
}
|
|
|
|
|
|
DeclareEmployeeFeedbackResponse.DeclareEmployeeFeedbackResponseBody declareEmployeeFeedbackResponseBody = declareEmployeeFeedbackResponse.getBody();
|
|
|
|
|
|
Map<String, Map<String, Object>> employeeFeedbackMap = SalaryEntityUtil.convert2Map(declareEmployeeFeedbackResponseBody.getBsjg(), e -> e.getOrDefault("xm", "")
|
|
|
|
|
|
+ "-" + e.getOrDefault("zzlx", "")
|
|
|
|
|
|
+ "-" + e.getOrDefault("zzhm", ""));
|
|
|
|
|
|
// 流量使用情况
|
2023-08-28 16:48:52 +08:00
|
|
|
|
TaxDeclarationApiBillingServiceImpl.ApiFlowUpdateWrapper apiFlowUpdateWrapper = new TaxDeclarationApiBillingServiceImpl.ApiFlowUpdateWrapper(param.getTaxCycle(), apiConfig, EnumDeclareApiBusinessType.EMPLOYEE_DECLARATION, (long) user.getUID());
|
2023-08-08 19:39:53 +08:00
|
|
|
|
// 查询申报的人员列表
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
List<EmployeeDeclarePO> needUpdateEmployeeDeclares = Lists.newArrayList();
|
|
|
|
|
|
List<EmployeeDeclarePO> employeeDeclares = listByTaxCycleAndTaxAgentId(param.getTaxCycle(), param.getTaxAgentId());
|
|
|
|
|
|
for (EmployeeDeclarePO employeeDeclare : employeeDeclares) {
|
|
|
|
|
|
CardTypeEnum cardTypeEnum = SalaryEnumUtil.enumMatchByValue(employeeDeclare.getCardType(), CardTypeEnum.class);
|
|
|
|
|
|
String key = employeeDeclare.getEmployeeName()
|
|
|
|
|
|
+ "-" + (cardTypeEnum == null ? CardTypeEnum.RESIDENT_IDENTITY_CARDS.getDefaultLabel() : cardTypeEnum.getDefaultLabel())
|
|
|
|
|
|
+ "-" + employeeDeclare.getCardNum();
|
|
|
|
|
|
Map<String, Object> employeeInfoMap = employeeFeedbackMap.get(key);
|
|
|
|
|
|
if (MapUtil.isEmpty(employeeInfoMap)) {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 报送状态
|
|
|
|
|
|
employeeDeclare.setDeclareStatus(SalaryEntityUtil.getIntValue(employeeInfoMap.get("sbzt"), DeclareStatusEnum.NOT_DECLARE.getValue()));
|
|
|
|
|
|
// 失败原因
|
|
|
|
|
|
employeeDeclare.setDeclareErrorMsg(SalaryEntityUtil.null2String(employeeInfoMap.get("sbyy")));
|
|
|
|
|
|
// 验证状态、银行卡验证状态
|
|
|
|
|
|
// 是否报送成功了
|
|
|
|
|
|
if (Objects.equals(employeeDeclare.getDeclareStatus(), DeclareStatusEnum.DECLARE_SUCCESS.getValue())) {
|
|
|
|
|
|
employeeDeclare.setSuccessfullyDeclared(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
employeeDeclare.setUpdateTime(now);
|
|
|
|
|
|
needUpdateEmployeeDeclares.add(employeeDeclare);
|
|
|
|
|
|
|
|
|
|
|
|
// 流量使用记录
|
|
|
|
|
|
TaxDeclarationApiFlowRecordPO flowDetailPO = TaxApiFlowBO.buildTaxDeclarationApiFlowRecordPO(apiFlowUpdateWrapper, param.getTaxAgentId(), employeeDeclare.getEmployeeId());
|
|
|
|
|
|
flowDetailPO.setResultStatus(DeclareStatusEnum.DECLARE_SUCCESS.getValue().equals(employeeDeclare.getDeclareStatus()) ? TaxAgentTaxReturnStatusEnum.SUCCESS.getValue() : TaxAgentTaxReturnStatusEnum.FAIL.getValue());
|
|
|
|
|
|
apiFlowUpdateWrapper.getApiFlowDetailPOList().add(flowDetailPO);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 更新员工的报送状态
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(needUpdateEmployeeDeclares)) {
|
2023-08-09 18:35:09 +08:00
|
|
|
|
needUpdateEmployeeDeclares.forEach(getEmployeeDeclareMapper()::updateIgnoreNull);
|
2023-08-08 19:39:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
// 删除原来的人员报送记录
|
|
|
|
|
|
getEmployeeDeclareRecordService(user).deleteByTaxCycleAndTaxAgentId(param.getTaxCycle(), param.getTaxAgentId());
|
|
|
|
|
|
// 记录日志
|
2024-03-07 09:29:59 +08:00
|
|
|
|
LoggerContext<EmployeeDeclarePO> loggerContext = new LoggerContext<>();
|
|
|
|
|
|
loggerContext.setUser(user);
|
2024-03-08 11:14:00 +08:00
|
|
|
|
loggerContext.setTargetId(param.getTaxAgentId().toString());
|
|
|
|
|
|
loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "个税扣缴义务人:「{0}」税款所属期:「{1}」").replace("{0}", taxAgent.getName()).replace("{1}", SalaryDateUtil.getFormatYearMonth(param.getTaxCycle())));
|
2024-03-07 09:29:59 +08:00
|
|
|
|
loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
|
|
|
|
|
|
loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "获取结果反馈"));
|
|
|
|
|
|
loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "获取结果反馈"));
|
|
|
|
|
|
SalaryElogConfig.employeeDeclareLoggerTemplate.write(loggerContext);
|
2023-08-08 19:39:53 +08:00
|
|
|
|
// 更新流量统计
|
2023-08-09 18:35:09 +08:00
|
|
|
|
getTaxDeclarationApiBillingService(user).updateApiFlowInfo(apiFlowUpdateWrapper);
|
2023-08-08 19:39:53 +08:00
|
|
|
|
// 报送失败的
|
|
|
|
|
|
int declareFailSize = (int) needUpdateEmployeeDeclares.stream()
|
|
|
|
|
|
.filter(e -> Objects.equals(e.getDeclareStatus(), DeclareStatusEnum.DECLARE_FAIL.getValue()))
|
|
|
|
|
|
.count();
|
|
|
|
|
|
employeeDeclareRate.setFinish(true);
|
|
|
|
|
|
if (declareFailSize > 0) {
|
|
|
|
|
|
employeeDeclareRate.setMsg(SalaryI18nUtil.getI18nLabel(156472, "报送成功{0}条,报送失败{1}条")
|
|
|
|
|
|
.replace("{0}", Util.null2String(needUpdateEmployeeDeclares.size() - declareFailSize))
|
|
|
|
|
|
.replace("{1}", Util.null2String(declareFailSize)));
|
|
|
|
|
|
} else {
|
|
|
|
|
|
employeeDeclareRate.setMsg(SalaryI18nUtil.getI18nLabel(187388, "报送成功{0}条").replace("{0}", Util.null2String(needUpdateEmployeeDeclares.size())));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-12-05 17:08:35 +08:00
|
|
|
|
|
2024-04-16 20:26:56 +08:00
|
|
|
|
|
2023-12-05 17:08:35 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public String syncEmploymentDate(EmployeeDeclareSyncStartDateParam param) {
|
|
|
|
|
|
List<DataCollectionEmployee> employeeList = getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ALL);
|
|
|
|
|
|
Map<Long, String> empPayStartDateMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getCompanystartdate);
|
|
|
|
|
|
|
|
|
|
|
|
List<EmployeeDeclarePO> employeeDeclarePOS = listByTaxCycleAndTaxAgentId(param.getTaxCycle(), param.getTaxAgentId());
|
|
|
|
|
|
employeeDeclarePOS.forEach(po -> {
|
|
|
|
|
|
String payStartDate = empPayStartDateMap.getOrDefault(po.getEmployeeId(), "");
|
|
|
|
|
|
if (SalaryDateUtil.checkDay(payStartDate)) {
|
|
|
|
|
|
po.setEmploymentDate(SalaryDateUtil.dateStrToLocalDate(payStartDate));
|
|
|
|
|
|
po.setNewEmployeeInfo(1);
|
|
|
|
|
|
po.setDeclareStatus(DeclareStatusEnum.NOT_DECLARE.getValue());
|
|
|
|
|
|
getEmployeeDeclareMapper().updateIgnoreNull(po);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return "执行完毕";
|
|
|
|
|
|
}
|
2023-12-26 17:45:06 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void batchInsert(List<EmployeeDeclarePO> insertList) {
|
|
|
|
|
|
if (CollectionUtils.isEmpty(insertList)) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-01-02 09:41:30 +08:00
|
|
|
|
List<List<EmployeeDeclarePO>> partition = Lists.partition(insertList, 50);
|
2023-12-26 17:45:06 +08:00
|
|
|
|
partition.forEach(getEmployeeDeclareMapper()::batchInsert);
|
|
|
|
|
|
}
|
2023-08-08 09:21:14 +08:00
|
|
|
|
}
|