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-11 14:20:14 +08:00
|
|
|
import com.engine.core.impl.Service;
|
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;
|
|
|
|
|
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-08-14 20:07:29 +08:00
|
|
|
import com.engine.salary.entity.taxdeclaration.po.TaxReportColumnPO;
|
|
|
|
|
import com.engine.salary.enums.salaryaccounting.EmployeeTypeEnum;
|
|
|
|
|
import com.engine.salary.enums.salarysob.IncomeCategoryEnum;
|
|
|
|
|
import com.engine.salary.mapper.taxdeclaration.TaxDeclarationValueMapper;
|
|
|
|
|
import com.engine.salary.service.*;
|
|
|
|
|
import com.engine.salary.util.SalaryDateUtil;
|
|
|
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
|
|
|
|
import com.engine.salary.util.SalaryEnumUtil;
|
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-11 14:20:14 +08:00
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description: 个税申报表
|
|
|
|
|
* @author: xiajun
|
|
|
|
|
* @modified By: xiajun
|
|
|
|
|
* @date: Created in 9/28/22 9:41 AM
|
|
|
|
|
* @version:v1.0
|
|
|
|
|
*/
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class TaxDeclarationValueServiceImpl extends Service implements TaxDeclarationValueService {
|
|
|
|
|
|
2023-08-14 20:07:29 +08:00
|
|
|
private TaxDeclarationValueMapper taxDeclarationValueMapper;
|
|
|
|
|
// private DataSecurityService dataSecurityService;
|
|
|
|
|
|
2023-08-11 14:20:14 +08:00
|
|
|
private SalaryEmployeeService salaryEmployeeService;
|
2023-08-14 20:07:29 +08:00
|
|
|
|
2023-08-11 14:20:14 +08:00
|
|
|
private ExtEmpService extEmployeeService;
|
2023-08-14 20:07:29 +08:00
|
|
|
|
2023-08-11 14:20:14 +08:00
|
|
|
private EmployeeDeclareService employeeDeclareService;
|
2023-08-14 20:07:29 +08:00
|
|
|
|
|
|
|
|
private TaxReportColumnService taxReportColumnService;
|
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) {
|
|
|
|
|
List<TaxDeclarationValuePO> taxDeclarationValuePOS = taxDeclarationValueMapper.listSome(TaxDeclarationValuePO.builder().taxDeclarationIds(taxDeclarationIds).build());
|
|
|
|
|
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-14 20:07:29 +08:00
|
|
|
List<TaxDeclarationValuePO> taxDeclarationValues = taxDeclarationValueMapper.listSome(TaxDeclarationValuePO.builder().taxDeclarationIds(taxDeclarationIds).build());
|
2023-08-11 14:20:14 +08:00
|
|
|
return decryptBatch(taxDeclarationValues);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<TaxDeclarationValuePO> listByTaxDeclarationIdsNoDecrypt(Collection<Long> taxDeclarationIds) {
|
2023-08-14 20:07:29 +08:00
|
|
|
return taxDeclarationValueMapper.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);
|
2023-08-14 20:07:29 +08:00
|
|
|
List<TaxReportColumnPO> taxReportColumns = taxReportColumnService.listByIncomeCategory(incomeCategoryEnum);
|
2023-08-11 14:20:14 +08:00
|
|
|
// 人员id
|
|
|
|
|
Set<Long> employeeIds = SalaryEntityUtil.properties(taxDeclarationValues, TaxDeclarationValuePO::getEmployeeId);
|
|
|
|
|
// 查询报送的人员
|
2023-08-14 20:07:29 +08:00
|
|
|
List<EmployeeDeclarePO> employeeDeclares = employeeDeclareService.listByTaxCycleAndTaxAgentIdAndEmployeeIds(taxDeclaration.getTaxCycle(), taxDeclaration.getTaxAgentId(), employeeIds);
|
2023-08-11 14:20:14 +08:00
|
|
|
// 查询人员信息
|
|
|
|
|
List<Long> simpleEmployeeIds = taxDeclarationValues.stream()
|
|
|
|
|
.filter(taxDeclarationValue -> Objects.equals(taxDeclarationValue.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue()))
|
|
|
|
|
.map(TaxDeclarationValuePO::getEmployeeId)
|
|
|
|
|
.distinct()
|
|
|
|
|
.collect(Collectors.toList());
|
2023-08-14 20:07:29 +08:00
|
|
|
List<DataCollectionEmployee> simpleEmployees = salaryEmployeeService.getEmployeeByIds(simpleEmployeeIds);
|
2023-08-11 14:20:14 +08:00
|
|
|
// 查询人员薪资(身份证号码等)
|
2023-08-14 20:07:29 +08:00
|
|
|
List<DataCollectionEmployee> simpleUserInfos = salaryEmployeeService.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());
|
|
|
|
|
List<ExtEmpPO> extEmployees = extEmployeeService.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-14 20:07:29 +08:00
|
|
|
throw new RuntimeException("todo");
|
|
|
|
|
// // 加密
|
|
|
|
|
// taxDeclarationValues.forEach(taxDeclarationValue ->
|
|
|
|
|
// taxDeclarationValue.setResultValueJson(JsonUtil.toJsonString(taxDeclarationValue.getResultValue())));
|
|
|
|
|
// taxDeclarationValues = dataSecurityService.encryptBatch(taxDeclarationValues, TaxDeclarationValuePO.class, tenantKey);
|
|
|
|
|
// // 分批保存
|
|
|
|
|
// int batchSize = SalaryPageUtil.getBatchSize();
|
|
|
|
|
// List<List<TaxDeclarationValuePO>> partition = Lists.partition(taxDeclarationValues, batchSize);
|
|
|
|
|
// for (List<TaxDeclarationValuePO> subTaxDeclarationValues : partition) {
|
|
|
|
|
// baseMapper.batchInsert(subTaxDeclarationValues);
|
|
|
|
|
// }
|
2023-08-11 14:20:14 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void deleteByTaxDeclareRecordIds(Collection<Long> taxDeclareRecordIds) {
|
|
|
|
|
if (CollectionUtils.isEmpty(taxDeclareRecordIds)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-08-14 20:07:29 +08:00
|
|
|
taxDeclarationValueMapper.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-14 20:07:29 +08:00
|
|
|
// // 解密
|
|
|
|
|
// taxDeclarationValues = dataSecurityService.decryptBatch(taxDeclarationValues, TaxDeclarationValuePO.class, tenantKey);
|
|
|
|
|
// taxDeclarationValues.forEach(salaryAcctResultValue -> {
|
|
|
|
|
// salaryAcctResultValue.setResultValue(JsonUtil.parseMap(salaryAcctResultValue.getResultValueJson(), String.class));
|
|
|
|
|
// });
|
2023-08-11 14:20:14 +08:00
|
|
|
return taxDeclarationValues;
|
|
|
|
|
}
|
|
|
|
|
}
|