2023-08-11 14:20:14 +08:00
|
|
|
package com.engine.salary.service.impl;
|
|
|
|
|
|
2023-08-14 20:07:29 +08:00
|
|
|
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
2023-08-17 19:04:20 +08:00
|
|
|
import com.engine.common.util.ServiceUtil;
|
2023-08-11 14:20:14 +08:00
|
|
|
import com.engine.core.impl.Service;
|
2023-12-14 17:55:48 +08:00
|
|
|
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
2023-08-17 19:04:20 +08:00
|
|
|
import com.engine.salary.encrypt.EncryptUtil;
|
2023-08-14 20:07:29 +08:00
|
|
|
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
|
|
|
|
import com.engine.salary.entity.employeedeclare.po.EmployeeDeclarePO;
|
|
|
|
|
import com.engine.salary.entity.extemp.po.ExtEmpPO;
|
|
|
|
|
import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationValueList;
|
|
|
|
|
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationValueListDTO;
|
|
|
|
|
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationValueListQueryParam;
|
2023-12-14 17:55:48 +08:00
|
|
|
import com.engine.salary.entity.taxdeclaration.param.TaxDeclareRecordDetailSaveParam;
|
2023-08-14 20:07:29 +08:00
|
|
|
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO;
|
2023-08-11 14:20:14 +08:00
|
|
|
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationValuePO;
|
2023-12-27 17:33:53 +08:00
|
|
|
import com.engine.salary.entity.taxdeclaration.po.TaxDeclareRecordPO;
|
2023-08-14 20:07:29 +08:00
|
|
|
import com.engine.salary.entity.taxdeclaration.po.TaxReportColumnPO;
|
|
|
|
|
import com.engine.salary.enums.salaryaccounting.EmployeeTypeEnum;
|
2023-12-27 17:33:53 +08:00
|
|
|
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
|
2023-08-14 20:07:29 +08:00
|
|
|
import com.engine.salary.enums.salarysob.IncomeCategoryEnum;
|
2023-12-27 17:33:53 +08:00
|
|
|
import com.engine.salary.enums.sicategory.DeleteTypeEnum;
|
|
|
|
|
import com.engine.salary.enums.taxdeclaration.SourceEnum;
|
2023-12-14 17:55:48 +08:00
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
2023-08-14 20:07:29 +08:00
|
|
|
import com.engine.salary.mapper.taxdeclaration.TaxDeclarationValueMapper;
|
2023-12-28 15:36:27 +08:00
|
|
|
import com.engine.salary.mapper.taxdeclaration.TaxDeclareRecordMapper;
|
2023-08-14 20:07:29 +08:00
|
|
|
import com.engine.salary.service.*;
|
2023-08-17 19:04:20 +08:00
|
|
|
import com.engine.salary.util.JsonUtil;
|
2023-08-14 20:07:29 +08:00
|
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
|
|
|
|
import com.engine.salary.util.SalaryEnumUtil;
|
2023-08-17 19:04:20 +08:00
|
|
|
import com.engine.salary.util.db.MapperProxyFactory;
|
2023-08-11 14:20:14 +08:00
|
|
|
import com.engine.salary.util.page.PageInfo;
|
2023-08-14 20:07:29 +08:00
|
|
|
import com.engine.salary.util.page.SalaryPageUtil;
|
2023-08-17 19:04:20 +08:00
|
|
|
import com.google.common.collect.Lists;
|
2023-12-27 17:33:53 +08:00
|
|
|
import com.google.common.collect.Maps;
|
2023-12-14 17:55:48 +08:00
|
|
|
import dm.jdbc.util.IdGenerator;
|
2023-08-11 14:20:14 +08:00
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
2023-08-17 19:04:20 +08:00
|
|
|
import weaver.hrm.User;
|
2023-08-11 14:20:14 +08:00
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
2023-09-07 15:15:59 +08:00
|
|
|
* 个税申报表
|
2023-08-23 16:49:45 +08:00
|
|
|
* <p>Copyright: Copyright (c) 2023</p>
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
*
|
|
|
|
|
* @author qiantao
|
|
|
|
|
* @version 1.0
|
|
|
|
|
**/
|
2023-08-11 14:20:14 +08:00
|
|
|
@Slf4j
|
|
|
|
|
public class TaxDeclarationValueServiceImpl extends Service implements TaxDeclarationValueService {
|
2023-08-17 19:04:20 +08:00
|
|
|
public EncryptUtil encryptUtil = new EncryptUtil();
|
2023-08-11 14:20:14 +08:00
|
|
|
|
2023-08-17 19:04:20 +08:00
|
|
|
private TaxDeclarationValueMapper getTaxDeclarationValueMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(TaxDeclarationValueMapper.class);
|
|
|
|
|
}
|
2023-08-20 14:03:43 +08:00
|
|
|
|
2023-12-28 15:36:27 +08:00
|
|
|
private TaxDeclareRecordMapper getTaxDeclareRecordMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(TaxDeclareRecordMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-17 19:04:20 +08:00
|
|
|
private SalaryEmployeeService getSalaryEmployeeService(User user) {
|
|
|
|
|
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
|
|
|
|
|
}
|
2023-08-20 14:03:43 +08:00
|
|
|
|
2023-08-17 19:04:20 +08:00
|
|
|
private ExtEmpService getExtEmpService(User user) {
|
|
|
|
|
return ServiceUtil.getService(ExtEmpServiceImpl.class, user);
|
|
|
|
|
}
|
2023-08-20 14:03:43 +08:00
|
|
|
|
2023-08-17 19:04:20 +08:00
|
|
|
private EmployeeDeclareService getEmployeeDeclareService(User user) {
|
|
|
|
|
return ServiceUtil.getService(EmployeeDeclareServiceImpl.class, user);
|
|
|
|
|
}
|
2023-08-20 14:03:43 +08:00
|
|
|
|
2023-08-17 19:04:20 +08:00
|
|
|
private TaxReportColumnService getTaxReportColumnService(User user) {
|
|
|
|
|
return ServiceUtil.getService(TaxReportColumnServiceImpl.class, user);
|
|
|
|
|
}
|
2023-08-20 14:03:43 +08:00
|
|
|
|
2023-12-14 17:55:48 +08:00
|
|
|
private TaxDeclarationService getTaxDeclarationService(User user) {
|
|
|
|
|
return ServiceUtil.getService(TaxDeclarationServiceImpl.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 14:20:14 +08:00
|
|
|
@Override
|
2023-08-14 20:07:29 +08:00
|
|
|
public PageInfo<TaxDeclarationValuePO> listPageByTaxDeclarationIds(TaxDeclarationValueListQueryParam queryParam, Collection<Long> taxDeclarationIds) {
|
2023-08-17 19:04:20 +08:00
|
|
|
List<TaxDeclarationValuePO> taxDeclarationValuePOS = getTaxDeclarationValueMapper().listSome(TaxDeclarationValuePO.builder().taxDeclarationIds(taxDeclarationIds).build());
|
2023-08-20 14:03:43 +08:00
|
|
|
taxDeclarationValuePOS = decryptBatch(taxDeclarationValuePOS);
|
2023-08-14 20:07:29 +08:00
|
|
|
return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), taxDeclarationValuePOS, TaxDeclarationValuePO.class);
|
2023-08-11 14:20:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<TaxDeclarationValuePO> listByTaxDeclarationIds(Collection<Long> taxDeclarationIds) {
|
2023-08-17 19:04:20 +08:00
|
|
|
List<TaxDeclarationValuePO> taxDeclarationValues = getTaxDeclarationValueMapper().listSome(TaxDeclarationValuePO.builder().taxDeclarationIds(taxDeclarationIds).build());
|
2023-08-11 14:20:14 +08:00
|
|
|
return decryptBatch(taxDeclarationValues);
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-28 18:12:38 +08:00
|
|
|
@Override
|
|
|
|
|
public List<TaxDeclarationValuePO> listByTaxDeclarationId(Long taxDeclarationId) {
|
|
|
|
|
List<TaxDeclarationValuePO> taxDeclarationValues = getTaxDeclarationValueMapper().listSome(TaxDeclarationValuePO.builder().taxDeclarationId(taxDeclarationId).build());
|
|
|
|
|
return decryptBatch(taxDeclarationValues);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 14:20:14 +08:00
|
|
|
@Override
|
|
|
|
|
public List<TaxDeclarationValuePO> listByTaxDeclarationIdsNoDecrypt(Collection<Long> taxDeclarationIds) {
|
2023-08-17 19:04:20 +08:00
|
|
|
return getTaxDeclarationValueMapper().listSome(TaxDeclarationValuePO.builder().taxDeclarationIds(taxDeclarationIds).build());
|
2023-08-11 14:20:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public TaxDeclarationValueListDTO convert2List(TaxDeclarationPO taxDeclaration, List<TaxDeclarationValuePO> taxDeclarationValues) {
|
|
|
|
|
// 查询个税申报表表头
|
|
|
|
|
IncomeCategoryEnum incomeCategoryEnum = SalaryEnumUtil.enumMatchByValue(taxDeclaration.getIncomeCategory(), IncomeCategoryEnum.class);
|
2024-01-04 15:35:23 +08:00
|
|
|
List<TaxReportColumnPO> taxReportColumns = getTaxReportColumnService(user).listByIncomeCategory(incomeCategoryEnum, 0);
|
2023-08-11 14:20:14 +08:00
|
|
|
// 人员id
|
|
|
|
|
Set<Long> employeeIds = SalaryEntityUtil.properties(taxDeclarationValues, TaxDeclarationValuePO::getEmployeeId);
|
|
|
|
|
// 查询报送的人员
|
2023-08-17 19:04:20 +08:00
|
|
|
List<EmployeeDeclarePO> employeeDeclares = getEmployeeDeclareService(user).listByTaxCycleAndTaxAgentIdAndEmployeeIds(taxDeclaration.getTaxCycle(), taxDeclaration.getTaxAgentId(), employeeIds);
|
2023-08-11 14:20:14 +08:00
|
|
|
// 查询人员信息
|
|
|
|
|
List<Long> simpleEmployeeIds = taxDeclarationValues.stream()
|
2023-09-07 15:15:59 +08:00
|
|
|
.filter(taxDeclarationValue -> taxDeclarationValue.getEmployeeType() == null || Objects.equals(taxDeclarationValue.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue()))
|
2023-08-11 14:20:14 +08:00
|
|
|
.map(TaxDeclarationValuePO::getEmployeeId)
|
|
|
|
|
.distinct()
|
|
|
|
|
.collect(Collectors.toList());
|
2023-08-17 19:04:20 +08:00
|
|
|
List<DataCollectionEmployee> simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIds(simpleEmployeeIds);
|
2023-08-11 14:20:14 +08:00
|
|
|
// 查询人员薪资(身份证号码等)
|
2023-08-17 19:04:20 +08:00
|
|
|
List<DataCollectionEmployee> simpleUserInfos = getSalaryEmployeeService(user).getEmployeeByIds(simpleEmployeeIds);
|
2023-08-11 14:20:14 +08:00
|
|
|
// 查询外部人员
|
2023-08-14 20:07:29 +08:00
|
|
|
List<Long> extEmployeeIds = taxDeclarationValues.stream()
|
2023-08-11 14:20:14 +08:00
|
|
|
.filter(taxDeclarationValue -> Objects.equals(taxDeclarationValue.getEmployeeType(), EmployeeTypeEnum.EXT_EMPLOYEE.getValue()))
|
|
|
|
|
.map(TaxDeclarationValuePO::getEmployeeId)
|
2023-08-14 20:07:29 +08:00
|
|
|
.collect(Collectors.toList());
|
2023-08-17 19:04:20 +08:00
|
|
|
List<ExtEmpPO> extEmployees = getExtEmpService(user).getExtEmpByIds(extEmployeeIds);
|
2023-08-11 14:20:14 +08:00
|
|
|
|
|
|
|
|
// 列表表头
|
|
|
|
|
List<WeaTableColumn> weaTableColumns = TaxDeclarationValueList.buildTableColumns(taxReportColumns);
|
|
|
|
|
// 列表数据
|
|
|
|
|
List<Map<String, Object>> data = TaxDeclarationValueList.buildTableData(incomeCategoryEnum, taxReportColumns, taxDeclarationValues,
|
|
|
|
|
employeeDeclares, simpleEmployees, simpleUserInfos, extEmployees);
|
|
|
|
|
|
|
|
|
|
return new TaxDeclarationValueListDTO().setColumns(weaTableColumns).setData(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void batchSave(List<TaxDeclarationValuePO> taxDeclarationValues) {
|
|
|
|
|
if (CollectionUtils.isNotEmpty(taxDeclarationValues)) {
|
2023-08-17 19:04:20 +08:00
|
|
|
// 加密
|
|
|
|
|
taxDeclarationValues.forEach(taxDeclarationValue ->
|
|
|
|
|
taxDeclarationValue.setResultValueJson(JsonUtil.toJsonString(taxDeclarationValue.getResultValue())));
|
|
|
|
|
taxDeclarationValues = encryptUtil.encryptList(taxDeclarationValues, TaxDeclarationValuePO.class);
|
|
|
|
|
// 分批保存
|
|
|
|
|
List<List<TaxDeclarationValuePO>> partition = Lists.partition(taxDeclarationValues, 100);
|
|
|
|
|
for (List<TaxDeclarationValuePO> subTaxDeclarationValues : partition) {
|
2023-08-20 14:03:43 +08:00
|
|
|
subTaxDeclarationValues.forEach(getTaxDeclarationValueMapper()::insertIgnoreNull);
|
2023-12-28 18:12:38 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void batchEdit(List<TaxDeclarationValuePO> taxDeclarationValues) {
|
|
|
|
|
if (CollectionUtils.isNotEmpty(taxDeclarationValues)) {
|
|
|
|
|
// 加密
|
|
|
|
|
taxDeclarationValues.forEach(taxDeclarationValue ->
|
|
|
|
|
taxDeclarationValue.setResultValueJson(JsonUtil.toJsonString(taxDeclarationValue.getResultValue())));
|
|
|
|
|
taxDeclarationValues = encryptUtil.encryptList(taxDeclarationValues, TaxDeclarationValuePO.class);
|
|
|
|
|
// 分批保存
|
|
|
|
|
List<List<TaxDeclarationValuePO>> partition = Lists.partition(taxDeclarationValues, 100);
|
|
|
|
|
for (List<TaxDeclarationValuePO> subTaxDeclarationValues : partition) {
|
|
|
|
|
subTaxDeclarationValues.forEach(getTaxDeclarationValueMapper()::updateIgnoreNull);
|
2023-08-17 19:04:20 +08:00
|
|
|
}
|
2023-08-11 14:20:14 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-14 17:55:48 +08:00
|
|
|
@Override
|
|
|
|
|
public void save(TaxDeclareRecordDetailSaveParam param) {
|
|
|
|
|
TaxDeclarationPO taxDeclaration = getTaxDeclarationService(user).getById(param.getTaxDeclarationId());
|
2023-12-27 17:33:53 +08:00
|
|
|
if (taxDeclaration == null) {
|
2023-12-14 17:55:48 +08:00
|
|
|
throw new SalaryRunTimeException("个税申报表不存在!");
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-28 15:36:27 +08:00
|
|
|
Long taxDeclareRecordId = taxDeclaration.getTaxDeclareRecordId();
|
|
|
|
|
TaxDeclareRecordPO declareRecordPO = getTaxDeclareRecordMapper().getById(taxDeclareRecordId);
|
|
|
|
|
if (declareRecordPO == null) {
|
|
|
|
|
throw new SalaryRunTimeException("个税申报记录不存在!");
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-14 17:55:48 +08:00
|
|
|
TaxDeclarationValuePO po = TaxDeclarationValuePO.builder()
|
|
|
|
|
.id(IdGenerator.generate())
|
|
|
|
|
.taxDeclarationId(param.getTaxDeclarationId())
|
2023-12-28 15:36:27 +08:00
|
|
|
.taxDeclareRecordId(taxDeclareRecordId)
|
2023-12-14 17:55:48 +08:00
|
|
|
.employeeId(param.getEmployeeId())
|
|
|
|
|
.employeeType(param.getEmployeeType())
|
|
|
|
|
.resultValue(param.getTaxReportColumnValues())
|
|
|
|
|
.resultValueJson(JsonUtil.toJsonString(param.getTaxReportColumnValues()))
|
|
|
|
|
.createTime(new Date())
|
|
|
|
|
.updateTime(new Date())
|
2023-12-27 17:33:53 +08:00
|
|
|
.source(SourceEnum.ADD.getValue())
|
2023-12-14 17:55:48 +08:00
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
.deleteType(0)
|
|
|
|
|
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
|
|
|
|
.build();
|
|
|
|
|
encryptUtil.encrypt(po, TaxDeclarationValuePO.class);
|
|
|
|
|
getTaxDeclarationValueMapper().insertIgnoreNull(po);
|
|
|
|
|
|
2023-12-28 15:36:27 +08:00
|
|
|
//新增年终奖
|
|
|
|
|
if (IncomeCategoryEnum.ONETIME_ANNUAL_BONUS.getValue().equals(taxDeclaration.getIncomeCategory())) {
|
|
|
|
|
autoAddWagesDeclare(declareRecordPO);
|
|
|
|
|
}
|
2023-12-14 17:55:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void edit(TaxDeclareRecordDetailSaveParam param) {
|
|
|
|
|
TaxDeclarationValuePO po = getById(param.getId());
|
|
|
|
|
po.setResultValue(param.getTaxReportColumnValues());
|
|
|
|
|
po.setResultValueJson(JsonUtil.toJsonString(param.getTaxReportColumnValues()));
|
|
|
|
|
po.setUpdateTime(new Date());
|
2023-12-27 17:33:53 +08:00
|
|
|
po.setSource(SourceEnum.EDIT.getValue());
|
2023-12-14 17:55:48 +08:00
|
|
|
encryptUtil.encrypt(po, TaxDeclarationValuePO.class);
|
|
|
|
|
getTaxDeclarationValueMapper().updateIgnoreNull(po);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public TaxDeclarationValuePO getById(Long id) {
|
|
|
|
|
TaxDeclarationValuePO po = getTaxDeclarationValueMapper().getById(id);
|
2023-12-27 17:33:53 +08:00
|
|
|
if (po == null) {
|
2023-12-14 17:55:48 +08:00
|
|
|
throw new SalaryRunTimeException("个税申报明细不存在!");
|
|
|
|
|
}
|
2023-12-27 17:33:53 +08:00
|
|
|
encryptUtil.decrypt(po, TaxDeclarationValuePO.class);
|
2023-12-14 17:55:48 +08:00
|
|
|
po.setResultValue(JsonUtil.parseMap(po.getResultValueJson(), String.class));
|
|
|
|
|
|
|
|
|
|
return po;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 14:20:14 +08:00
|
|
|
@Override
|
|
|
|
|
public void deleteByTaxDeclareRecordIds(Collection<Long> taxDeclareRecordIds) {
|
|
|
|
|
if (CollectionUtils.isEmpty(taxDeclareRecordIds)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-08-17 19:04:20 +08:00
|
|
|
getTaxDeclarationValueMapper().deleteBytaxDeclareRecordIds(taxDeclareRecordIds);
|
2023-08-11 14:20:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<TaxDeclarationValuePO> decryptBatch(List<TaxDeclarationValuePO> taxDeclarationValues) {
|
|
|
|
|
if (CollectionUtils.isEmpty(taxDeclarationValues)) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
2023-08-17 19:04:20 +08:00
|
|
|
// 解密
|
|
|
|
|
taxDeclarationValues = encryptUtil.decryptList(taxDeclarationValues, TaxDeclarationValuePO.class);
|
|
|
|
|
taxDeclarationValues.forEach(salaryAcctResultValue -> {
|
|
|
|
|
salaryAcctResultValue.setResultValue(JsonUtil.parseMap(salaryAcctResultValue.getResultValueJson(), String.class));
|
|
|
|
|
});
|
2023-08-11 14:20:14 +08:00
|
|
|
return taxDeclarationValues;
|
|
|
|
|
}
|
2023-12-27 17:33:53 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void autoAddWagesDeclare(TaxDeclareRecordPO taxDeclareRecord) {
|
|
|
|
|
|
|
|
|
|
Long taxDeclareRecordId = taxDeclareRecord.getId();
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
|
|
|
|
//非正常薪资的人员
|
|
|
|
|
List<Long> notWagesEmpIds = getTaxDeclarationValueMapper().queryNotWagesEmpIds(taxDeclareRecordId);
|
|
|
|
|
if (CollectionUtils.isEmpty(notWagesEmpIds)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//正常薪资人员
|
|
|
|
|
List<Long> wagesEmpIds = getTaxDeclarationValueMapper().queryWagesEmpIds(taxDeclareRecordId);
|
|
|
|
|
|
|
|
|
|
//比较差异
|
|
|
|
|
List<Long> autoAddIds = notWagesEmpIds.stream().filter(id -> !wagesEmpIds.contains(id)).collect(Collectors.toList());
|
|
|
|
|
if (CollectionUtils.isEmpty(autoAddIds)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//正常薪资的表头
|
2024-01-04 15:35:23 +08:00
|
|
|
List<TaxReportColumnPO> taxReportColumns = getTaxReportColumnService(user).listByIncomeCategory(IncomeCategoryEnum.WAGES_AND_SALARIES, 0);
|
2023-12-27 17:33:53 +08:00
|
|
|
Map<String, String> valueMap = Maps.newHashMap();
|
|
|
|
|
for (TaxReportColumnPO taxReportColumn : taxReportColumns) {
|
|
|
|
|
String value = Objects.equals(taxReportColumn.getDataType(), SalaryDataTypeEnum.NUMBER.getValue()) ? "0.00" : "";
|
|
|
|
|
valueMap.put(taxReportColumn.getReportColumnDataIndex(), value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//当前申报表是否含正常申报
|
|
|
|
|
List<TaxDeclarationPO> list = getTaxDeclarationService(user).listByTaxDeclareRecordId(taxDeclareRecordId, IncomeCategoryEnum.WAGES_AND_SALARIES.getValue());
|
|
|
|
|
TaxDeclarationPO taxDeclarationPO;
|
|
|
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
|
|
|
if (list.size() > 1) {
|
|
|
|
|
throw new SalaryRunTimeException("存在多条正常工资薪金申报表数据");
|
|
|
|
|
}
|
|
|
|
|
taxDeclarationPO = list.get(0);
|
|
|
|
|
} else {
|
|
|
|
|
taxDeclarationPO = TaxDeclarationPO
|
|
|
|
|
.builder()
|
|
|
|
|
.id(IdGenerator.generate())
|
|
|
|
|
.taxDeclareRecordId(taxDeclareRecordId)
|
|
|
|
|
.incomeCategory(IncomeCategoryEnum.WAGES_AND_SALARIES.getValue())
|
|
|
|
|
.taxAgentId(taxDeclareRecord.getTaxAgentId())
|
|
|
|
|
.salaryMonth(taxDeclareRecord.getSalaryMonth())
|
|
|
|
|
.taxCycle(taxDeclareRecord.getTaxCycle())
|
|
|
|
|
.description(taxDeclareRecord.getRemark())
|
|
|
|
|
.controlView(0)
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
.createTime(now)
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
|
|
|
|
|
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
|
|
|
|
.build();
|
|
|
|
|
List<TaxDeclarationPO> taxList = new ArrayList<>();
|
|
|
|
|
getTaxDeclarationService(user).saveBatch(taxList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//组装数据,自动补足
|
|
|
|
|
List<TaxDeclarationValuePO> autoAddValuePOs = autoAddIds.stream().map((empId -> {
|
|
|
|
|
TaxDeclarationValuePO taxDeclarationValue = TaxDeclarationValuePO.builder()
|
|
|
|
|
.id(IdGenerator.generate())
|
|
|
|
|
.taxDeclareRecordId(taxDeclarationPO.getTaxDeclareRecordId())
|
|
|
|
|
.taxDeclarationId(taxDeclarationPO.getId())
|
|
|
|
|
.employeeType(0)
|
|
|
|
|
.employeeId(empId)
|
|
|
|
|
.resultValue(valueMap)
|
|
|
|
|
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
|
|
|
|
|
.createTime(now)
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
.source(SourceEnum.AUTO.getValue())
|
|
|
|
|
.build();
|
|
|
|
|
return taxDeclarationValue;
|
|
|
|
|
})).collect(Collectors.toList());
|
|
|
|
|
batchSave(autoAddValuePOs);
|
|
|
|
|
}
|
2024-01-04 15:35:23 +08:00
|
|
|
|
|
|
|
|
public void contrast(Long taxDeclarationId) {
|
2024-01-04 15:56:42 +08:00
|
|
|
TaxDeclarationPO taxDeclaration = getTaxDeclarationService(user).getById(taxDeclarationId);
|
|
|
|
|
if (taxDeclaration == null) {
|
2024-01-04 15:35:23 +08:00
|
|
|
throw new SalaryRunTimeException("无申报表");
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:56:42 +08:00
|
|
|
List<TaxDeclarationValuePO> taxDeclarationValues = listByTaxDeclarationId(taxDeclaration.getId());
|
|
|
|
|
|
|
|
|
|
// 查询个税申报表表头
|
|
|
|
|
IncomeCategoryEnum incomeCategoryEnum = SalaryEnumUtil.enumMatchByValue(taxDeclaration.getIncomeCategory(), IncomeCategoryEnum.class);
|
|
|
|
|
List<TaxReportColumnPO> taxReportColumns = getTaxReportColumnService(user).listByIncomeCategory(incomeCategoryEnum, 0);
|
|
|
|
|
// 人员id
|
|
|
|
|
Set<Long> employeeIds = SalaryEntityUtil.properties(taxDeclarationValues, TaxDeclarationValuePO::getEmployeeId);
|
|
|
|
|
// 查询报送的人员
|
|
|
|
|
List<EmployeeDeclarePO> employeeDeclares = getEmployeeDeclareService(user).listByTaxCycleAndTaxAgentIdAndEmployeeIds(taxDeclaration.getTaxCycle(), taxDeclaration.getTaxAgentId(), employeeIds);
|
|
|
|
|
// 查询人员信息
|
|
|
|
|
List<Long> simpleEmployeeIds = taxDeclarationValues.stream()
|
|
|
|
|
.filter(taxDeclarationValue -> taxDeclarationValue.getEmployeeType() == null || Objects.equals(taxDeclarationValue.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue()))
|
|
|
|
|
.map(TaxDeclarationValuePO::getEmployeeId)
|
|
|
|
|
.distinct()
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
List<DataCollectionEmployee> simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIds(simpleEmployeeIds);
|
|
|
|
|
// 查询人员薪资(身份证号码等)
|
|
|
|
|
List<DataCollectionEmployee> simpleUserInfos = getSalaryEmployeeService(user).getEmployeeByIds(simpleEmployeeIds);
|
|
|
|
|
// 查询外部人员
|
|
|
|
|
List<Long> extEmployeeIds = taxDeclarationValues.stream()
|
|
|
|
|
.filter(taxDeclarationValue -> Objects.equals(taxDeclarationValue.getEmployeeType(), EmployeeTypeEnum.EXT_EMPLOYEE.getValue()))
|
|
|
|
|
.map(TaxDeclarationValuePO::getEmployeeId)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
List<ExtEmpPO> extEmployees = getExtEmpService(user).getExtEmpByIds(extEmployeeIds);
|
|
|
|
|
|
|
|
|
|
// 列表表头
|
|
|
|
|
List<WeaTableColumn> weaTableColumns = TaxDeclarationValueList.buildTableColumns(taxReportColumns);
|
|
|
|
|
// 列表数据
|
|
|
|
|
List<Map<String, Object>> data = TaxDeclarationValueList.buildTableData(incomeCategoryEnum, taxReportColumns, taxDeclarationValues,
|
|
|
|
|
employeeDeclares, simpleEmployees, simpleUserInfos, extEmployees);
|
2024-01-04 15:35:23 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-08-11 14:20:14 +08:00
|
|
|
}
|