2022-03-10 17:57:46 +08:00
|
|
|
|
package com.engine.salary.service.impl;
|
|
|
|
|
|
|
2024-03-18 14:01:08 +08:00
|
|
|
|
import cn.hutool.core.util.NumberUtil;
|
2022-11-16 11:08:45 +08:00
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
2022-09-21 13:38:06 +08:00
|
|
|
|
import com.api.formmode.mybatis.util.SqlProxyHandle;
|
2022-05-31 11:21:51 +08:00
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
2022-03-10 17:57:46 +08:00
|
|
|
|
import com.engine.core.impl.Service;
|
2024-03-18 14:01:08 +08:00
|
|
|
|
import com.engine.hrmelog.entity.dto.LoggerContext;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import com.engine.salary.biz.OtherDeductionBiz;
|
2024-01-30 09:58:13 +08:00
|
|
|
|
import com.engine.salary.config.SalaryElogConfig;
|
2022-11-16 11:08:45 +08:00
|
|
|
|
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
2022-12-13 13:34:22 +08:00
|
|
|
|
import com.engine.salary.encrypt.EncryptUtil;
|
2024-02-21 18:19:02 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.AddUpDeduction;
|
2022-05-09 14:11:07 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
2024-12-19 10:57:21 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.dto.*;
|
2022-10-28 16:35:51 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.param.*;
|
2024-12-19 11:23:59 +08:00
|
|
|
|
import com.engine.salary.entity.datacollection.po.*;
|
2022-05-31 09:58:35 +08:00
|
|
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
|
|
|
|
|
|
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO;
|
|
|
|
|
|
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
2024-01-30 09:58:13 +08:00
|
|
|
|
import com.engine.salary.enums.OperateTypeEnum;
|
2022-05-31 09:58:35 +08:00
|
|
|
|
import com.engine.salary.enums.UserStatusEnum;
|
2024-12-19 09:53:56 +08:00
|
|
|
|
import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum;
|
2025-01-14 14:56:36 +08:00
|
|
|
|
import com.engine.salary.enums.datacollection.TaxFreeTypeEnum;
|
2025-07-01 18:37:50 +08:00
|
|
|
|
import com.engine.salary.enums.salarysob.IncomeCategoryEnum;
|
2024-12-23 16:41:42 +08:00
|
|
|
|
import com.engine.salary.enums.sicategory.DeleteTypeEnum;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
2024-12-19 09:53:56 +08:00
|
|
|
|
import com.engine.salary.mapper.datacollection.*;
|
2022-09-21 13:38:06 +08:00
|
|
|
|
import com.engine.salary.mapper.sys.SalarySysConfMapper;
|
2022-10-26 18:35:23 +08:00
|
|
|
|
import com.engine.salary.service.AddUpDeductionService;
|
|
|
|
|
|
import com.engine.salary.service.OtherDeductionService;
|
|
|
|
|
|
import com.engine.salary.service.SalaryEmployeeService;
|
|
|
|
|
|
import com.engine.salary.service.TaxAgentService;
|
2022-09-21 13:38:06 +08:00
|
|
|
|
import com.engine.salary.sys.entity.po.SalarySysConfPO;
|
2022-09-26 18:51:17 +08:00
|
|
|
|
import com.engine.salary.sys.entity.vo.OrderRuleVO;
|
|
|
|
|
|
import com.engine.salary.sys.service.SalarySysConfService;
|
|
|
|
|
|
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import com.engine.salary.util.SalaryDateUtil;
|
2022-10-28 16:35:51 +08:00
|
|
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
2024-12-25 10:36:37 +08:00
|
|
|
|
import com.engine.salary.util.db.IdGenerator;
|
2022-04-28 17:44:26 +08:00
|
|
|
|
import com.engine.salary.util.db.MapperProxyFactory;
|
|
|
|
|
|
import com.engine.salary.util.excel.ExcelComment;
|
2022-05-31 09:58:35 +08:00
|
|
|
|
import com.engine.salary.util.excel.ExcelParseHelper;
|
2024-03-14 18:16:20 +08:00
|
|
|
|
import com.engine.salary.util.excel.ExcelSupport;
|
2022-04-28 17:44:26 +08:00
|
|
|
|
import com.engine.salary.util.excel.ExcelUtil;
|
2022-05-31 09:58:35 +08:00
|
|
|
|
import com.engine.salary.util.page.PageInfo;
|
|
|
|
|
|
import com.engine.salary.util.page.SalaryPageUtil;
|
2024-12-26 15:16:24 +08:00
|
|
|
|
import com.engine.salary.util.valid.ValidUtil;
|
2022-04-28 17:44:26 +08:00
|
|
|
|
import com.google.common.collect.Lists;
|
2022-05-31 09:58:35 +08:00
|
|
|
|
import com.google.common.collect.Maps;
|
2022-05-09 14:11:07 +08:00
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
2022-05-31 09:58:35 +08:00
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
import org.apache.commons.lang3.Validate;
|
2024-03-14 18:16:20 +08:00
|
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
2022-05-31 09:58:35 +08:00
|
|
|
|
import org.apache.poi.util.IOUtils;
|
2022-03-10 17:57:46 +08:00
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
2025-01-16 13:41:17 +08:00
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
2024-12-24 10:54:57 +08:00
|
|
|
|
import org.springframework.beans.BeanUtils;
|
2022-05-31 09:58:35 +08:00
|
|
|
|
import weaver.file.ImageFileManager;
|
2022-05-20 14:41:42 +08:00
|
|
|
|
import weaver.general.Util;
|
2022-05-31 11:21:51 +08:00
|
|
|
|
import weaver.hrm.User;
|
2022-03-10 17:57:46 +08:00
|
|
|
|
|
2022-05-31 09:58:35 +08:00
|
|
|
|
import java.io.InputStream;
|
2024-03-18 14:01:08 +08:00
|
|
|
|
import java.math.BigDecimal;
|
2022-05-31 09:58:35 +08:00
|
|
|
|
import java.text.SimpleDateFormat;
|
2022-11-16 11:08:45 +08:00
|
|
|
|
import java.time.LocalDateTime;
|
2022-04-11 20:17:47 +08:00
|
|
|
|
import java.time.YearMonth;
|
2022-05-09 14:11:07 +08:00
|
|
|
|
import java.util.*;
|
2022-04-28 17:44:26 +08:00
|
|
|
|
import java.util.stream.Collectors;
|
2022-03-10 17:57:46 +08:00
|
|
|
|
|
2022-05-31 09:58:35 +08:00
|
|
|
|
import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY;
|
2024-03-14 18:16:20 +08:00
|
|
|
|
import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX;
|
2022-05-31 09:58:35 +08:00
|
|
|
|
|
2022-03-10 17:57:46 +08:00
|
|
|
|
public class OtherDeductionServiceImpl extends Service implements OtherDeductionService {
|
2022-12-13 13:34:22 +08:00
|
|
|
|
private EncryptUtil encryptUtil = new EncryptUtil();
|
2022-03-10 17:57:46 +08:00
|
|
|
|
|
2022-04-28 17:44:26 +08:00
|
|
|
|
private OtherDeductionMapper getOtherDeductionMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(OtherDeductionMapper.class);
|
|
|
|
|
|
}
|
2022-06-09 17:45:28 +08:00
|
|
|
|
|
2022-11-17 15:39:16 +08:00
|
|
|
|
private OtherDeductionBiz getOtherDeductionBiz() {
|
|
|
|
|
|
return new OtherDeductionBiz();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-06-09 17:45:28 +08:00
|
|
|
|
private TaxAgentService getTaxAgentService(User user) {
|
2022-05-31 21:05:59 +08:00
|
|
|
|
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
|
2022-05-31 11:21:51 +08:00
|
|
|
|
}
|
2022-06-09 17:45:28 +08:00
|
|
|
|
|
2022-05-31 11:21:51 +08:00
|
|
|
|
private AddUpDeductionService getAddUpDeductionService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(AddUpDeductionServiceImpl.class, user);
|
|
|
|
|
|
}
|
2022-06-09 17:45:28 +08:00
|
|
|
|
|
2022-05-31 11:21:51 +08:00
|
|
|
|
private SalaryEmployeeService getSalaryEmployeeService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
|
|
|
|
|
|
}
|
2022-05-31 09:58:35 +08:00
|
|
|
|
|
2022-09-21 13:38:06 +08:00
|
|
|
|
private SalarySysConfMapper getSalarySysConfMapper() {
|
|
|
|
|
|
return SqlProxyHandle.getProxy(SalarySysConfMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-26 18:51:17 +08:00
|
|
|
|
private SalarySysConfService getSalarySysConfService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalarySysConfServiceImpl.class, user);
|
|
|
|
|
|
}
|
2022-09-21 13:38:06 +08:00
|
|
|
|
|
2024-12-19 09:53:56 +08:00
|
|
|
|
|
|
|
|
|
|
private FreeIncomeMapper getFreeIncomeMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(FreeIncomeMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private HealthInsuranceMapper getHealthInsuranceMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(HealthInsuranceMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private EndowmentInsuranceMapper getEndowmentInsuranceMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(EndowmentInsuranceMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private GrantDonationMapper getGrantDonationMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(GrantDonationMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private DerateDeductionMapper getDerateDeductionMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(DerateDeductionMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private OtherDerateDeductionMapper getOtherDerateDeductionMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(OtherDerateDeductionMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-24 15:52:36 +08:00
|
|
|
|
private PersonalPensionMapper getPersonalPensionMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(PersonalPensionMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-19 09:53:56 +08:00
|
|
|
|
|
2022-03-10 17:57:46 +08:00
|
|
|
|
@Override
|
2022-05-31 09:58:35 +08:00
|
|
|
|
public OtherDeductionPO getById(Long id) {
|
|
|
|
|
|
return getOtherDeductionMapper().getById(id);
|
2022-03-10 17:57:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-31 09:58:35 +08:00
|
|
|
|
|
2022-03-10 17:57:46 +08:00
|
|
|
|
@Override
|
2022-05-31 09:58:35 +08:00
|
|
|
|
public PageInfo<OtherDeductionListDTO> listPage(OtherDeductionQueryParam queryParam) {
|
2022-06-07 19:10:40 +08:00
|
|
|
|
//申报月份
|
|
|
|
|
|
List<String> declareMonth = queryParam.getDeclareMonth();
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(declareMonth)) {
|
2023-04-04 14:21:25 +08:00
|
|
|
|
queryParam.setDeclareMonth(declareMonth.stream().filter(StringUtils::isNotBlank).map(e -> e + "-01 00:00:00").collect(Collectors.toList()));
|
|
|
|
|
|
queryParam.setDeclareMonthDate(declareMonth.stream().filter(StringUtils::isNotBlank).map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList()));
|
2022-06-07 19:10:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-26 18:51:17 +08:00
|
|
|
|
//排序配置
|
|
|
|
|
|
OrderRuleVO orderRule = getSalarySysConfService(user).orderRule();
|
|
|
|
|
|
queryParam.setOrderRule(orderRule);
|
|
|
|
|
|
|
2022-05-31 09:58:35 +08:00
|
|
|
|
long employeeId = user.getUID();
|
|
|
|
|
|
|
2022-06-09 17:45:28 +08:00
|
|
|
|
Boolean needAuth = getTaxAgentService(user).isNeedAuth(employeeId);
|
|
|
|
|
|
if (needAuth) {
|
|
|
|
|
|
List<Long> taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
if (CollectionUtils.isEmpty(taxAgentIdsAsAdmin)) {
|
|
|
|
|
|
return new PageInfo<>(OtherDeductionListDTO.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
queryParam.setTaxAgentIds(taxAgentIdsAsAdmin);
|
2022-05-31 09:58:35 +08:00
|
|
|
|
}
|
2022-06-09 17:45:28 +08:00
|
|
|
|
List<OtherDeductionListDTO> list = getOtherDeductionMapper().list(queryParam);
|
2022-12-12 10:25:55 +08:00
|
|
|
|
PageInfo<OtherDeductionListDTO> page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(),
|
|
|
|
|
|
list, OtherDeductionListDTO.class);
|
2022-12-13 13:34:22 +08:00
|
|
|
|
encryptUtil.decryptList(page.getList(), OtherDeductionListDTO.class);
|
|
|
|
|
|
return page;
|
2022-03-10 17:57:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-05-31 09:58:35 +08:00
|
|
|
|
public PageInfo<OtherDeductionRecordDTO> recordListPage(OtherDeductionQueryParam queryParam) {
|
|
|
|
|
|
long employeeId = user.getUID();
|
|
|
|
|
|
|
2022-06-24 18:05:08 +08:00
|
|
|
|
//申报月份
|
|
|
|
|
|
List<String> declareMonth = queryParam.getDeclareMonth();
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(declareMonth)) {
|
|
|
|
|
|
queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList()));
|
|
|
|
|
|
queryParam.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList()));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-06-09 17:45:28 +08:00
|
|
|
|
Boolean needAuth = getTaxAgentService(user).isNeedAuth(employeeId);
|
|
|
|
|
|
if (needAuth) {
|
|
|
|
|
|
List<Long> taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
if (CollectionUtils.isEmpty(taxAgentIdsAsAdmin)) {
|
|
|
|
|
|
return new PageInfo<>(OtherDeductionRecordDTO.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
queryParam.setTaxAgentIds(taxAgentIdsAsAdmin);
|
2022-05-31 09:58:35 +08:00
|
|
|
|
}
|
2022-06-09 17:45:28 +08:00
|
|
|
|
List<OtherDeductionRecordDTO> list = getOtherDeductionMapper().recordList(queryParam);
|
2022-12-12 10:25:55 +08:00
|
|
|
|
PageInfo<OtherDeductionRecordDTO> page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(),
|
|
|
|
|
|
list, OtherDeductionRecordDTO.class);
|
2022-12-14 10:57:41 +08:00
|
|
|
|
encryptUtil.decryptList(page.getList(), OtherDeductionRecordDTO.class);
|
2022-12-12 10:25:55 +08:00
|
|
|
|
return page;
|
2022-03-10 17:57:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-31 09:58:35 +08:00
|
|
|
|
|
2022-03-10 17:57:46 +08:00
|
|
|
|
@Override
|
2022-05-31 11:21:51 +08:00
|
|
|
|
public Map<String, Object> preview(OtherDeductionImportParam importParam) {
|
2022-05-31 09:58:35 +08:00
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
|
|
|
|
//excel文件id
|
|
|
|
|
|
String imageId = Util.null2String(importParam.getImageId());
|
|
|
|
|
|
Validate.notBlank(imageId, "imageId为空");
|
|
|
|
|
|
|
|
|
|
|
|
InputStream fileInputStream = null;
|
|
|
|
|
|
try {
|
|
|
|
|
|
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId));
|
2024-03-14 18:16:20 +08:00
|
|
|
|
Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX);
|
|
|
|
|
|
apidatas.put("headers", ExcelSupport.getSheetHeader(sheet, 0));
|
|
|
|
|
|
apidatas.put("list", ExcelParseHelper.parse2List(sheet, 1, 0));
|
|
|
|
|
|
return apidatas;
|
2022-05-31 09:58:35 +08:00
|
|
|
|
} finally {
|
|
|
|
|
|
IOUtils.closeQuietly(fileInputStream);
|
|
|
|
|
|
}
|
2022-03-10 17:57:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-09 14:11:07 +08:00
|
|
|
|
|
2022-05-31 09:58:35 +08:00
|
|
|
|
public Map<String, Object> importData(OtherDeductionImportParam importParam) {
|
2022-06-09 17:45:28 +08:00
|
|
|
|
|
|
|
|
|
|
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
|
|
|
|
|
|
|
2022-05-31 09:58:35 +08:00
|
|
|
|
long currentEmployeeId = user.getUID();
|
|
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
2022-05-09 14:11:07 +08:00
|
|
|
|
OtherDeductionBiz OtherDeductionBiz = new OtherDeductionBiz();
|
|
|
|
|
|
|
2022-09-21 13:38:06 +08:00
|
|
|
|
//查询对于人员信息导入筛选的全局配置
|
|
|
|
|
|
SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode");
|
|
|
|
|
|
String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0";
|
|
|
|
|
|
|
2022-05-31 09:58:35 +08:00
|
|
|
|
//检验参数
|
|
|
|
|
|
checkImportParam(importParam);
|
|
|
|
|
|
|
|
|
|
|
|
//excel文件id
|
|
|
|
|
|
String imageId = Util.null2String(importParam.getImageId());
|
|
|
|
|
|
Validate.notBlank(imageId, "imageId为空");
|
|
|
|
|
|
//税款所属期
|
|
|
|
|
|
String declareMonthStr = Util.null2String(importParam.getDeclareMonth());
|
|
|
|
|
|
|
|
|
|
|
|
InputStream fileInputStream = null;
|
|
|
|
|
|
try {
|
|
|
|
|
|
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId));
|
2024-12-19 09:53:56 +08:00
|
|
|
|
List<OtherDeductionListDTO> OtherDeductions = ExcelParseHelper.parse2Map(fileInputStream, OtherDeductionListDTO.class, 0, 1, 14, "OtherDeductionTemplate.xlsx");
|
2022-05-31 09:58:35 +08:00
|
|
|
|
|
|
|
|
|
|
int total = OtherDeductions.size();
|
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
int successCount = 0;
|
|
|
|
|
|
int errorCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
//人员信息
|
2023-03-06 17:57:20 +08:00
|
|
|
|
List<DataCollectionEmployee> employees = getSalaryEmployeeService(user).listEmployee();
|
2022-05-31 09:58:35 +08:00
|
|
|
|
// 获取所有个税扣缴义务人
|
2022-06-09 17:45:28 +08:00
|
|
|
|
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
|
2022-05-31 09:58:35 +08:00
|
|
|
|
//税款所属期
|
|
|
|
|
|
Date declareMonth = SalaryDateUtil.stringToDate(declareMonthStr + "-01");
|
|
|
|
|
|
// 获取已经核算的数据
|
2025-01-21 15:03:36 +08:00
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(declareMonthStr);
|
2022-05-31 09:58:35 +08:00
|
|
|
|
// 查询已有数据
|
2022-05-31 11:21:51 +08:00
|
|
|
|
List<OtherDeductionPO> list = getOtherDeductionMapper().listSome(OtherDeductionPO.builder().declareMonth(declareMonth).build());
|
2022-05-31 09:58:35 +08:00
|
|
|
|
|
|
|
|
|
|
// 错误excel内容
|
|
|
|
|
|
List<Map> errorData = new ArrayList<>();
|
|
|
|
|
|
//合规数据
|
|
|
|
|
|
List<OtherDeductionPO> eligibleData = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
List<TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee> taxAgentEmployees = Lists.newArrayList();
|
|
|
|
|
|
for (int i = 0; i < OtherDeductions.size(); i++) {
|
|
|
|
|
|
OtherDeductionListDTO dto = OtherDeductions.get(i);
|
|
|
|
|
|
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
//待插入数据库对象
|
|
|
|
|
|
OtherDeductionPO po = OtherDeductionPO.builder()
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.declareMonth(declareMonth).build();
|
|
|
|
|
|
|
|
|
|
|
|
//异常点数量
|
|
|
|
|
|
int errorSum = 0;
|
|
|
|
|
|
|
|
|
|
|
|
//行号
|
|
|
|
|
|
String rowIndex = String.format("第%s行", i + 2);
|
|
|
|
|
|
|
|
|
|
|
|
//相同的姓名
|
|
|
|
|
|
String userName = dto.getUsername();
|
|
|
|
|
|
String deparmentName = dto.getDepartmentName();
|
2022-08-25 11:43:52 +08:00
|
|
|
|
String mobile = dto.getMobile();
|
2022-09-21 13:38:06 +08:00
|
|
|
|
String workcode = dto.getJobNum();
|
2024-05-23 09:16:28 +08:00
|
|
|
|
String idNo = dto.getIdNo();
|
2022-05-31 09:58:35 +08:00
|
|
|
|
List<Long> employeeSameIds = new ArrayList<>();
|
|
|
|
|
|
|
2022-09-21 13:38:06 +08:00
|
|
|
|
//筛选导入人员信息可以在人力资源池中匹配到的人员信息
|
2024-12-17 14:05:05 +08:00
|
|
|
|
List<DataCollectionEmployee> emps = getSalaryEmployeeService(user).matchImportEmployee(confValue, employees, userName, deparmentName, mobile, workcode, idNo, null);
|
2022-05-31 09:58:35 +08:00
|
|
|
|
//含在职和离职,选在职数据
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) {
|
|
|
|
|
|
employeeSameIds = emps.stream()
|
|
|
|
|
|
.filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus()))
|
|
|
|
|
|
.map(DataCollectionEmployee::getEmployeeId)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) {
|
|
|
|
|
|
employeeSameIds = emps.stream()
|
|
|
|
|
|
.map(DataCollectionEmployee::getEmployeeId)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-21 13:57:58 +08:00
|
|
|
|
//当人员信息导入筛选的全局配置为"0"时,姓名才是必填项
|
2022-09-21 13:38:06 +08:00
|
|
|
|
if (StringUtils.isBlank(userName) && "0".equals(confValue)) {
|
2022-05-31 09:58:35 +08:00
|
|
|
|
//姓名 不能为空
|
|
|
|
|
|
//错误消息对象
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "姓名不能为空");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
2022-09-16 15:03:48 +08:00
|
|
|
|
errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工");
|
2022-05-31 09:58:35 +08:00
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0) : null;
|
|
|
|
|
|
if (employeeId != null && employeeId > 0) {
|
|
|
|
|
|
po.setEmployeeId(employeeId);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//姓名错误,系统内不存在该姓名
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String taxAgentName = dto.getTaxAgentName();
|
|
|
|
|
|
if (StringUtils.isBlank(taxAgentName)) {
|
|
|
|
|
|
//个税扣缴义务人不能为空
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "个税扣缴义务人不能为空");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Optional<TaxAgentManageRangeEmployeeDTO> optionalTemp = taxAgentList.stream().filter(m -> m.getTaxAgentName().equals(taxAgentName)).findFirst();
|
|
|
|
|
|
if (optionalTemp.isPresent()) {
|
2024-12-19 09:53:56 +08:00
|
|
|
|
po.setTaxAgentId(optionalTemp.get().getTaxAgentId());
|
|
|
|
|
|
taxAgentEmployees = optionalTemp.get().getEmployeeList();
|
2022-05-31 09:58:35 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
//个税扣缴义务人不存在
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
2022-06-21 22:37:22 +08:00
|
|
|
|
errorMessageMap.put("message", rowIndex + "个税扣缴义务人不存在或不在权限范围内");
|
2022-05-31 09:58:35 +08:00
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-17 14:05:05 +08:00
|
|
|
|
//免税收入
|
|
|
|
|
|
String freeIncome = dto.getFreeIncome();
|
|
|
|
|
|
po.setFreeIncome(freeIncome);
|
|
|
|
|
|
//减免税额
|
|
|
|
|
|
String derateDeduction = dto.getDerateDeduction();
|
|
|
|
|
|
po.setDerateDeduction(derateDeduction);
|
2022-05-31 09:58:35 +08:00
|
|
|
|
//商业健康保险
|
|
|
|
|
|
String businessHealthyInsurance = dto.getBusinessHealthyInsurance();
|
|
|
|
|
|
po.setBusinessHealthyInsurance(businessHealthyInsurance);
|
|
|
|
|
|
//税延养老保险
|
|
|
|
|
|
String taxDelayEndowmentInsurance = dto.getTaxDelayEndowmentInsurance();
|
|
|
|
|
|
po.setTaxDelayEndowmentInsurance(taxDelayEndowmentInsurance);
|
|
|
|
|
|
//其他
|
|
|
|
|
|
String otherDeduction = dto.getOtherDeduction();
|
|
|
|
|
|
po.setOtherDeduction(otherDeduction);
|
|
|
|
|
|
//准予扣除的捐赠额
|
|
|
|
|
|
String deductionAllowedDonation = dto.getDeductionAllowedDonation();
|
|
|
|
|
|
po.setDeductionAllowedDonation(deductionAllowedDonation);
|
2023-04-04 14:21:25 +08:00
|
|
|
|
//个人养老金
|
|
|
|
|
|
String privatePension = dto.getPrivatePension();
|
|
|
|
|
|
po.setPrivatePension(privatePension);
|
2022-05-31 09:58:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否有核算过
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) {
|
|
|
|
|
|
OtherDeductionPO finalPo = po;
|
|
|
|
|
|
Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(finalPo.getEmployeeId()) && f.getTaxAgentId().equals(finalPo.getTaxAgentId())).findFirst();
|
|
|
|
|
|
boolean isExist = list.stream().anyMatch(f -> f.getEmployeeId().equals(finalPo.getEmployeeId()) && f.getTaxAgentId().equals(finalPo.getTaxAgentId()));
|
|
|
|
|
|
if (optionalAcctEmp.isPresent() && isExist) {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "该年月这条数据已经核算过,不可导入");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (errorSum == 0) {
|
|
|
|
|
|
successCount += 1;
|
|
|
|
|
|
// 合格数据
|
|
|
|
|
|
eligibleData.add(po);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
errorCount += 1;
|
|
|
|
|
|
// 添加错误数据
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//入库
|
2024-02-21 18:19:02 +08:00
|
|
|
|
OtherDeductionBiz.handleImportData(eligibleData, user);
|
2022-05-31 09:58:35 +08:00
|
|
|
|
|
|
|
|
|
|
apidatas.put("successCount", successCount);
|
|
|
|
|
|
apidatas.put("errorCount", errorCount);
|
|
|
|
|
|
apidatas.put("errorData", errorData);
|
|
|
|
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
IOUtils.closeQuietly(fileInputStream);
|
|
|
|
|
|
}
|
|
|
|
|
|
return apidatas;
|
2022-03-10 17:57:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-19 09:53:56 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public Map<String, Object> importDetailData(OtherDeductionImportParam importParam) {
|
|
|
|
|
|
|
|
|
|
|
|
long currentEmployeeId = user.getUID();
|
|
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
|
|
|
|
|
OtherDeductionBiz OtherDeductionBiz = new OtherDeductionBiz();
|
|
|
|
|
|
|
|
|
|
|
|
//查询对于人员信息导入筛选的全局配置
|
|
|
|
|
|
SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode");
|
|
|
|
|
|
String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0";
|
|
|
|
|
|
|
|
|
|
|
|
//检验参数
|
|
|
|
|
|
checkImportParam(importParam);
|
|
|
|
|
|
|
|
|
|
|
|
//excel文件id
|
|
|
|
|
|
String imageId = Util.null2String(importParam.getImageId());
|
|
|
|
|
|
Validate.notBlank(imageId, "imageId为空");
|
|
|
|
|
|
//税款所属期
|
|
|
|
|
|
String declareMonthStr = Util.null2String(importParam.getDeclareMonth());
|
|
|
|
|
|
|
2024-12-19 10:46:04 +08:00
|
|
|
|
//人员信息
|
|
|
|
|
|
List<DataCollectionEmployee> employees = getSalaryEmployeeService(user).listEmployee();
|
|
|
|
|
|
// 获取所有个税扣缴义务人
|
|
|
|
|
|
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
|
|
|
|
|
|
//税款所属期
|
|
|
|
|
|
Date declareMonth = SalaryDateUtil.stringToDate(declareMonthStr + "-01");
|
|
|
|
|
|
// 获取已经核算的数据
|
2025-01-22 14:41:00 +08:00
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(declareMonthStr);
|
2024-12-19 10:46:04 +08:00
|
|
|
|
// 查询已有数据
|
|
|
|
|
|
List<OtherDeductionPO> list = getOtherDeductionMapper().listSome(OtherDeductionPO.builder().declareMonth(declareMonth).build());
|
|
|
|
|
|
|
2024-12-19 09:53:56 +08:00
|
|
|
|
InputStream fileInputStream = null;
|
|
|
|
|
|
|
2024-12-19 10:46:04 +08:00
|
|
|
|
List<OtherDeductionPO> eligibleData = new ArrayList<>();
|
|
|
|
|
|
|
2024-12-19 09:53:56 +08:00
|
|
|
|
try {
|
|
|
|
|
|
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId));
|
|
|
|
|
|
|
|
|
|
|
|
int successCount = 0;
|
|
|
|
|
|
int errorCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 错误excel内容
|
|
|
|
|
|
List<Map> errorData = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
//免税收入
|
2025-07-02 15:46:32 +08:00
|
|
|
|
List<FreeIncomeListDTO> freeIncomeList = ExcelParseHelper.parse2Map(fileInputStream, FreeIncomeListDTO.class, 0, 1, 10, "OtherDeductionTemplate.xlsx");
|
2024-12-19 09:53:56 +08:00
|
|
|
|
for (int i = 0; i < freeIncomeList.size(); i++) {
|
|
|
|
|
|
FreeIncomeListDTO dto = freeIncomeList.get(i);
|
|
|
|
|
|
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
//待插入数据库对象
|
|
|
|
|
|
OtherDeductionPO po = OtherDeductionPO.builder()
|
|
|
|
|
|
.declareMonth(declareMonth)
|
|
|
|
|
|
.freeIncomeList(new ArrayList<>())
|
2024-12-19 10:46:04 +08:00
|
|
|
|
.derateDeductionList(new ArrayList<>())
|
|
|
|
|
|
.endowmentInsuranceList(new ArrayList<>())
|
|
|
|
|
|
.grantDonationList(new ArrayList<>())
|
|
|
|
|
|
.healthInsuranceList(new ArrayList<>())
|
|
|
|
|
|
.otherDerateDeductionList(new ArrayList<>())
|
2024-12-25 16:28:21 +08:00
|
|
|
|
.personalPensionList(new ArrayList<>())
|
2024-12-19 09:53:56 +08:00
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
FreeIncomePO freeIncomePO = FreeIncomePO.builder()
|
|
|
|
|
|
.taxYearMonth(declareMonth)
|
|
|
|
|
|
.fileStatus(1)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
//异常点数量
|
|
|
|
|
|
int errorSum = 0;
|
|
|
|
|
|
|
|
|
|
|
|
//行号
|
|
|
|
|
|
String rowIndex = String.format("第%s行", i + 2);
|
|
|
|
|
|
|
|
|
|
|
|
//相同的姓名
|
|
|
|
|
|
String userName = dto.getUsername();
|
|
|
|
|
|
String deparmentName = dto.getDepartmentName();
|
|
|
|
|
|
String mobile = dto.getMobile();
|
|
|
|
|
|
String workcode = dto.getJobNum();
|
|
|
|
|
|
String idNo = dto.getIdNo();
|
|
|
|
|
|
List<Long> employeeSameIds = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
//筛选导入人员信息可以在人力资源池中匹配到的人员信息
|
|
|
|
|
|
List<DataCollectionEmployee> emps = getSalaryEmployeeService(user).matchImportEmployee(confValue, employees, userName, deparmentName, mobile, workcode, idNo, null);
|
|
|
|
|
|
//含在职和离职,选在职数据
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) {
|
|
|
|
|
|
employeeSameIds = emps.stream()
|
|
|
|
|
|
.filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus()))
|
|
|
|
|
|
.map(DataCollectionEmployee::getEmployeeId)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) {
|
|
|
|
|
|
employeeSameIds = emps.stream()
|
|
|
|
|
|
.map(DataCollectionEmployee::getEmployeeId)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//当人员信息导入筛选的全局配置为"0"时,姓名才是必填项
|
|
|
|
|
|
if (StringUtils.isBlank(userName) && "0".equals(confValue)) {
|
|
|
|
|
|
//姓名 不能为空
|
|
|
|
|
|
//错误消息对象
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "姓名不能为空");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0) : null;
|
|
|
|
|
|
if (employeeId != null && employeeId > 0) {
|
|
|
|
|
|
po.setEmployeeId(employeeId);
|
|
|
|
|
|
freeIncomePO.setEmployeeId(employeeId);
|
|
|
|
|
|
freeIncomePO.setEmployeeType(DataCollectionEmployeeTypeEnum.ORGANIZATION.getValue());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//姓名错误,系统内不存在该姓名
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String taxAgentName = dto.getTaxAgentName();
|
|
|
|
|
|
if (StringUtils.isBlank(taxAgentName)) {
|
|
|
|
|
|
//个税扣缴义务人不能为空
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "个税扣缴义务人不能为空");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Optional<TaxAgentManageRangeEmployeeDTO> optionalTemp = taxAgentList.stream().filter(m -> m.getTaxAgentName().equals(taxAgentName)).findFirst();
|
|
|
|
|
|
if (optionalTemp.isPresent()) {
|
|
|
|
|
|
po.setTaxAgentId(optionalTemp.get().getTaxAgentId());
|
|
|
|
|
|
freeIncomePO.setTaxAgentId(optionalTemp.get().getTaxAgentId());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//个税扣缴义务人不存在
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "个税扣缴义务人不存在或不在权限范围内");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-02 15:46:32 +08:00
|
|
|
|
IncomeCategoryEnum incomeCategoryEnum = IncomeCategoryEnum.parseByDefaultLabel(dto.getIncomeCategoryName());
|
|
|
|
|
|
if (incomeCategoryEnum == null) {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "所得项目不存在!");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
freeIncomePO.setIncomeCategory(incomeCategoryEnum.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-19 09:53:56 +08:00
|
|
|
|
//免税收入
|
|
|
|
|
|
String freeIncome = dto.getFreeItem();
|
|
|
|
|
|
String freeProperty = dto.getFreeProperty();
|
|
|
|
|
|
String freeAmount = dto.getFreeAmount();
|
|
|
|
|
|
freeIncomePO.setFreeItem(freeIncome);
|
|
|
|
|
|
freeIncomePO.setFreeProperty(freeProperty);
|
|
|
|
|
|
freeIncomePO.setFreeAmount(freeAmount);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (errorSum == 0) {
|
|
|
|
|
|
successCount += 1;
|
2024-12-19 10:46:04 +08:00
|
|
|
|
String key = po.getTaxAgentId() + "-" + po.getEmployeeId();
|
2024-12-19 09:53:56 +08:00
|
|
|
|
Map<String, OtherDeductionPO> deductionPOMap = SalaryEntityUtil.convert2Map(eligibleData, e -> e.getTaxAgentId() + "-" + e.getEmployeeId());
|
|
|
|
|
|
if (deductionPOMap.containsKey(key)) {
|
|
|
|
|
|
deductionPOMap.get(key).getFreeIncomeList().add(freeIncomePO);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
po.getFreeIncomeList().add(freeIncomePO);
|
|
|
|
|
|
eligibleData.add(po);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
errorCount += 1;
|
|
|
|
|
|
// 添加错误数据
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-19 10:46:04 +08:00
|
|
|
|
HashMap<Object, Object> dataMap = new HashMap<>();
|
|
|
|
|
|
dataMap.put("successCount", successCount);
|
|
|
|
|
|
dataMap.put("errorCount", errorCount);
|
|
|
|
|
|
dataMap.put("errorData", errorData);
|
|
|
|
|
|
apidatas.put("freeIncome", dataMap);
|
2024-12-19 09:53:56 +08:00
|
|
|
|
|
2024-12-19 10:46:04 +08:00
|
|
|
|
} finally {
|
|
|
|
|
|
IOUtils.closeQuietly(fileInputStream);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-19 11:23:59 +08:00
|
|
|
|
try {
|
|
|
|
|
|
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId));
|
|
|
|
|
|
|
|
|
|
|
|
int successCount = 0;
|
|
|
|
|
|
int errorCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 错误excel内容
|
|
|
|
|
|
List<Map> errorData = new ArrayList<>();
|
|
|
|
|
|
|
2025-07-02 15:46:32 +08:00
|
|
|
|
List<HealthInsuranceListDTO> dtoList = ExcelParseHelper.parse2Map(fileInputStream, HealthInsuranceListDTO.class, 1, 1, 12, "OtherDeductionTemplate.xlsx");
|
2024-12-19 11:23:59 +08:00
|
|
|
|
for (int i = 0; i < dtoList.size(); i++) {
|
|
|
|
|
|
HealthInsuranceListDTO dto = dtoList.get(i);
|
|
|
|
|
|
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
//待插入数据库对象
|
|
|
|
|
|
OtherDeductionPO mainPo = OtherDeductionPO.builder()
|
|
|
|
|
|
.declareMonth(declareMonth)
|
|
|
|
|
|
.freeIncomeList(new ArrayList<>())
|
|
|
|
|
|
.derateDeductionList(new ArrayList<>())
|
|
|
|
|
|
.endowmentInsuranceList(new ArrayList<>())
|
|
|
|
|
|
.grantDonationList(new ArrayList<>())
|
|
|
|
|
|
.healthInsuranceList(new ArrayList<>())
|
|
|
|
|
|
.otherDerateDeductionList(new ArrayList<>())
|
2024-12-25 16:28:21 +08:00
|
|
|
|
.personalPensionList(new ArrayList<>())
|
2024-12-19 11:23:59 +08:00
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
HealthInsurancePO po = HealthInsurancePO.builder()
|
|
|
|
|
|
.taxYearMonth(declareMonth)
|
|
|
|
|
|
.fileStatus(1)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
//异常点数量
|
|
|
|
|
|
int errorSum = 0;
|
|
|
|
|
|
|
|
|
|
|
|
//行号
|
|
|
|
|
|
String rowIndex = String.format("第%s行", i + 2);
|
|
|
|
|
|
|
|
|
|
|
|
//相同的姓名
|
|
|
|
|
|
String userName = dto.getUsername();
|
|
|
|
|
|
String deparmentName = dto.getDepartmentName();
|
|
|
|
|
|
String mobile = dto.getMobile();
|
|
|
|
|
|
String workcode = dto.getJobNum();
|
|
|
|
|
|
String idNo = dto.getIdNo();
|
|
|
|
|
|
List<Long> employeeSameIds = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
//筛选导入人员信息可以在人力资源池中匹配到的人员信息
|
|
|
|
|
|
List<DataCollectionEmployee> emps = getSalaryEmployeeService(user).matchImportEmployee(confValue, employees, userName, deparmentName, mobile, workcode, idNo, null);
|
|
|
|
|
|
//含在职和离职,选在职数据
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) {
|
|
|
|
|
|
employeeSameIds = emps.stream()
|
|
|
|
|
|
.filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus()))
|
|
|
|
|
|
.map(DataCollectionEmployee::getEmployeeId)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) {
|
|
|
|
|
|
employeeSameIds = emps.stream()
|
|
|
|
|
|
.map(DataCollectionEmployee::getEmployeeId)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//当人员信息导入筛选的全局配置为"0"时,姓名才是必填项
|
|
|
|
|
|
if (StringUtils.isBlank(userName) && "0".equals(confValue)) {
|
|
|
|
|
|
//姓名 不能为空
|
|
|
|
|
|
//错误消息对象
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "姓名不能为空");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0) : null;
|
|
|
|
|
|
if (employeeId != null && employeeId > 0) {
|
|
|
|
|
|
mainPo.setEmployeeId(employeeId);
|
|
|
|
|
|
po.setEmployeeId(employeeId);
|
|
|
|
|
|
po.setEmployeeType(DataCollectionEmployeeTypeEnum.ORGANIZATION.getValue());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//姓名错误,系统内不存在该姓名
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String taxAgentName = dto.getTaxAgentName();
|
|
|
|
|
|
if (StringUtils.isBlank(taxAgentName)) {
|
|
|
|
|
|
//个税扣缴义务人不能为空
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "个税扣缴义务人不能为空");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Optional<TaxAgentManageRangeEmployeeDTO> optionalTemp = taxAgentList.stream().filter(m -> m.getTaxAgentName().equals(taxAgentName)).findFirst();
|
|
|
|
|
|
if (optionalTemp.isPresent()) {
|
|
|
|
|
|
mainPo.setTaxAgentId(optionalTemp.get().getTaxAgentId());
|
|
|
|
|
|
po.setTaxAgentId(optionalTemp.get().getTaxAgentId());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//个税扣缴义务人不存在
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "个税扣缴义务人不存在或不在权限范围内");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-02 15:46:32 +08:00
|
|
|
|
IncomeCategoryEnum incomeCategoryEnum = IncomeCategoryEnum.parseByDefaultLabel(dto.getIncomeCategoryName());
|
|
|
|
|
|
if (incomeCategoryEnum == null) {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "所得项目不存在!");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
po.setIncomeCategory(incomeCategoryEnum.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-19 11:23:59 +08:00
|
|
|
|
po.setIdentificationNumber(dto.getIdentificationNumber());
|
|
|
|
|
|
po.setEffectiveDate(dto.getEffectiveDate());
|
|
|
|
|
|
po.setYearPremium(dto.getYearPremium());
|
|
|
|
|
|
po.setMonthPremium(dto.getMonthPremium());
|
|
|
|
|
|
po.setCurrentDeduction(dto.getCurrentDeduction());
|
|
|
|
|
|
|
|
|
|
|
|
if (errorSum == 0) {
|
|
|
|
|
|
successCount += 1;
|
|
|
|
|
|
String key = mainPo.getTaxAgentId() + "-" + mainPo.getEmployeeId();
|
|
|
|
|
|
Map<String, OtherDeductionPO> deductionPOMap = SalaryEntityUtil.convert2Map(eligibleData, e -> e.getTaxAgentId() + "-" + e.getEmployeeId());
|
|
|
|
|
|
if (deductionPOMap.containsKey(key)) {
|
|
|
|
|
|
deductionPOMap.get(key).getHealthInsuranceList().add(po);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
mainPo.getHealthInsuranceList().add(po);
|
|
|
|
|
|
eligibleData.add(mainPo);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
errorCount += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HashMap<Object, Object> dataMap = new HashMap<>();
|
|
|
|
|
|
dataMap.put("successCount", successCount);
|
|
|
|
|
|
dataMap.put("errorCount", errorCount);
|
|
|
|
|
|
dataMap.put("errorData", errorData);
|
|
|
|
|
|
apidatas.put("derateDeduction", dataMap);
|
|
|
|
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
IOUtils.closeQuietly(fileInputStream);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId));
|
|
|
|
|
|
|
|
|
|
|
|
int successCount = 0;
|
|
|
|
|
|
int errorCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 错误excel内容
|
|
|
|
|
|
List<Map> errorData = new ArrayList<>();
|
|
|
|
|
|
|
2025-07-02 15:46:32 +08:00
|
|
|
|
List<EndowmentInsuranceListDTO> derateDeductionList = ExcelParseHelper.parse2Map(fileInputStream, EndowmentInsuranceListDTO.class, 2, 1, 13, "OtherDeductionTemplate.xlsx");
|
2024-12-19 11:23:59 +08:00
|
|
|
|
for (int i = 0; i < derateDeductionList.size(); i++) {
|
|
|
|
|
|
EndowmentInsuranceListDTO dto = derateDeductionList.get(i);
|
|
|
|
|
|
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
//待插入数据库对象
|
|
|
|
|
|
OtherDeductionPO mainPo = OtherDeductionPO.builder()
|
|
|
|
|
|
.declareMonth(declareMonth)
|
|
|
|
|
|
.freeIncomeList(new ArrayList<>())
|
|
|
|
|
|
.derateDeductionList(new ArrayList<>())
|
|
|
|
|
|
.endowmentInsuranceList(new ArrayList<>())
|
|
|
|
|
|
.grantDonationList(new ArrayList<>())
|
|
|
|
|
|
.healthInsuranceList(new ArrayList<>())
|
|
|
|
|
|
.otherDerateDeductionList(new ArrayList<>())
|
2024-12-25 16:28:21 +08:00
|
|
|
|
.personalPensionList(new ArrayList<>())
|
2024-12-19 11:23:59 +08:00
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
EndowmentInsurancePO po = EndowmentInsurancePO.builder()
|
|
|
|
|
|
.taxYearMonth(declareMonth)
|
|
|
|
|
|
.fileStatus(1)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
//异常点数量
|
|
|
|
|
|
int errorSum = 0;
|
|
|
|
|
|
|
|
|
|
|
|
//行号
|
|
|
|
|
|
String rowIndex = String.format("第%s行", i + 2);
|
|
|
|
|
|
|
|
|
|
|
|
//相同的姓名
|
|
|
|
|
|
String userName = dto.getUsername();
|
|
|
|
|
|
String deparmentName = dto.getDepartmentName();
|
|
|
|
|
|
String mobile = dto.getMobile();
|
|
|
|
|
|
String workcode = dto.getJobNum();
|
|
|
|
|
|
String idNo = dto.getIdNo();
|
|
|
|
|
|
List<Long> employeeSameIds = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
//筛选导入人员信息可以在人力资源池中匹配到的人员信息
|
|
|
|
|
|
List<DataCollectionEmployee> emps = getSalaryEmployeeService(user).matchImportEmployee(confValue, employees, userName, deparmentName, mobile, workcode, idNo, null);
|
|
|
|
|
|
//含在职和离职,选在职数据
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) {
|
|
|
|
|
|
employeeSameIds = emps.stream()
|
|
|
|
|
|
.filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus()))
|
|
|
|
|
|
.map(DataCollectionEmployee::getEmployeeId)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) {
|
|
|
|
|
|
employeeSameIds = emps.stream()
|
|
|
|
|
|
.map(DataCollectionEmployee::getEmployeeId)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//当人员信息导入筛选的全局配置为"0"时,姓名才是必填项
|
|
|
|
|
|
if (StringUtils.isBlank(userName) && "0".equals(confValue)) {
|
|
|
|
|
|
//姓名 不能为空
|
|
|
|
|
|
//错误消息对象
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "姓名不能为空");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0) : null;
|
|
|
|
|
|
if (employeeId != null && employeeId > 0) {
|
|
|
|
|
|
mainPo.setEmployeeId(employeeId);
|
|
|
|
|
|
po.setEmployeeId(employeeId);
|
|
|
|
|
|
po.setEmployeeType(DataCollectionEmployeeTypeEnum.ORGANIZATION.getValue());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//姓名错误,系统内不存在该姓名
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String taxAgentName = dto.getTaxAgentName();
|
|
|
|
|
|
if (StringUtils.isBlank(taxAgentName)) {
|
|
|
|
|
|
//个税扣缴义务人不能为空
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "个税扣缴义务人不能为空");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Optional<TaxAgentManageRangeEmployeeDTO> optionalTemp = taxAgentList.stream().filter(m -> m.getTaxAgentName().equals(taxAgentName)).findFirst();
|
|
|
|
|
|
if (optionalTemp.isPresent()) {
|
|
|
|
|
|
mainPo.setTaxAgentId(optionalTemp.get().getTaxAgentId());
|
|
|
|
|
|
po.setTaxAgentId(optionalTemp.get().getTaxAgentId());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//个税扣缴义务人不存在
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "个税扣缴义务人不存在或不在权限范围内");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-02 15:46:32 +08:00
|
|
|
|
IncomeCategoryEnum incomeCategoryEnum = IncomeCategoryEnum.parseByDefaultLabel(dto.getIncomeCategoryName());
|
|
|
|
|
|
if (incomeCategoryEnum == null) {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "所得项目不存在!");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
po.setIncomeCategory(incomeCategoryEnum.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-19 11:23:59 +08:00
|
|
|
|
po.setAccountNumber(dto.getAccountNumber());
|
|
|
|
|
|
po.setCheckCode(dto.getCheckCode());
|
|
|
|
|
|
po.setYearPremium(dto.getYearPremium());
|
|
|
|
|
|
po.setMonthPremium(dto.getMonthPremium());
|
|
|
|
|
|
po.setCurrentDeduction(dto.getCurrentDeduction());
|
|
|
|
|
|
|
|
|
|
|
|
if (errorSum == 0) {
|
|
|
|
|
|
successCount += 1;
|
|
|
|
|
|
String key = mainPo.getTaxAgentId() + "-" + mainPo.getEmployeeId();
|
|
|
|
|
|
Map<String, OtherDeductionPO> deductionPOMap = SalaryEntityUtil.convert2Map(eligibleData, e -> e.getTaxAgentId() + "-" + e.getEmployeeId());
|
|
|
|
|
|
if (deductionPOMap.containsKey(key)) {
|
|
|
|
|
|
deductionPOMap.get(key).getEndowmentInsuranceList().add(po);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
mainPo.getEndowmentInsuranceList().add(po);
|
|
|
|
|
|
eligibleData.add(mainPo);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
errorCount += 1;
|
|
|
|
|
|
// 添加错误数据
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HashMap<Object, Object> dataMap = new HashMap<>();
|
|
|
|
|
|
dataMap.put("successCount", successCount);
|
|
|
|
|
|
dataMap.put("errorCount", errorCount);
|
|
|
|
|
|
dataMap.put("errorData", errorData);
|
|
|
|
|
|
apidatas.put("derateDeduction", dataMap);
|
|
|
|
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
IOUtils.closeQuietly(fileInputStream);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId));
|
|
|
|
|
|
|
|
|
|
|
|
int successCount = 0;
|
|
|
|
|
|
int errorCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 错误excel内容
|
|
|
|
|
|
List<Map> errorData = new ArrayList<>();
|
|
|
|
|
|
|
2025-07-02 15:46:32 +08:00
|
|
|
|
List<GrantDonationListDTO> dtoList = ExcelParseHelper.parse2Map(fileInputStream, GrantDonationListDTO.class, 3, 1, 14, "OtherDeductionTemplate.xlsx");
|
2024-12-19 11:23:59 +08:00
|
|
|
|
for (int i = 0; i < dtoList.size(); i++) {
|
|
|
|
|
|
GrantDonationListDTO dto = dtoList.get(i);
|
|
|
|
|
|
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
//待插入数据库对象
|
|
|
|
|
|
OtherDeductionPO mainPo = OtherDeductionPO.builder()
|
|
|
|
|
|
.declareMonth(declareMonth)
|
|
|
|
|
|
.freeIncomeList(new ArrayList<>())
|
|
|
|
|
|
.derateDeductionList(new ArrayList<>())
|
|
|
|
|
|
.endowmentInsuranceList(new ArrayList<>())
|
|
|
|
|
|
.grantDonationList(new ArrayList<>())
|
|
|
|
|
|
.healthInsuranceList(new ArrayList<>())
|
|
|
|
|
|
.otherDerateDeductionList(new ArrayList<>())
|
2024-12-25 16:28:21 +08:00
|
|
|
|
.personalPensionList(new ArrayList<>())
|
2024-12-19 11:23:59 +08:00
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
GrantDonationPO po = GrantDonationPO.builder()
|
|
|
|
|
|
.taxYearMonth(declareMonth)
|
|
|
|
|
|
.fileStatus(1)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
//异常点数量
|
|
|
|
|
|
int errorSum = 0;
|
|
|
|
|
|
|
|
|
|
|
|
//行号
|
|
|
|
|
|
String rowIndex = String.format("第%s行", i + 2);
|
|
|
|
|
|
|
|
|
|
|
|
//相同的姓名
|
|
|
|
|
|
String userName = dto.getUsername();
|
|
|
|
|
|
String deparmentName = dto.getDepartmentName();
|
|
|
|
|
|
String mobile = dto.getMobile();
|
|
|
|
|
|
String workcode = dto.getJobNum();
|
|
|
|
|
|
String idNo = dto.getIdNo();
|
|
|
|
|
|
List<Long> employeeSameIds = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
//筛选导入人员信息可以在人力资源池中匹配到的人员信息
|
|
|
|
|
|
List<DataCollectionEmployee> emps = getSalaryEmployeeService(user).matchImportEmployee(confValue, employees, userName, deparmentName, mobile, workcode, idNo, null);
|
|
|
|
|
|
//含在职和离职,选在职数据
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) {
|
|
|
|
|
|
employeeSameIds = emps.stream()
|
|
|
|
|
|
.filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus()))
|
|
|
|
|
|
.map(DataCollectionEmployee::getEmployeeId)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) {
|
|
|
|
|
|
employeeSameIds = emps.stream()
|
|
|
|
|
|
.map(DataCollectionEmployee::getEmployeeId)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//当人员信息导入筛选的全局配置为"0"时,姓名才是必填项
|
|
|
|
|
|
if (StringUtils.isBlank(userName) && "0".equals(confValue)) {
|
|
|
|
|
|
//姓名 不能为空
|
|
|
|
|
|
//错误消息对象
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "姓名不能为空");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0) : null;
|
|
|
|
|
|
if (employeeId != null && employeeId > 0) {
|
|
|
|
|
|
mainPo.setEmployeeId(employeeId);
|
|
|
|
|
|
po.setEmployeeId(employeeId);
|
|
|
|
|
|
po.setEmployeeType(DataCollectionEmployeeTypeEnum.ORGANIZATION.getValue());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//姓名错误,系统内不存在该姓名
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String taxAgentName = dto.getTaxAgentName();
|
|
|
|
|
|
if (StringUtils.isBlank(taxAgentName)) {
|
|
|
|
|
|
//个税扣缴义务人不能为空
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "个税扣缴义务人不能为空");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Optional<TaxAgentManageRangeEmployeeDTO> optionalTemp = taxAgentList.stream().filter(m -> m.getTaxAgentName().equals(taxAgentName)).findFirst();
|
|
|
|
|
|
if (optionalTemp.isPresent()) {
|
|
|
|
|
|
mainPo.setTaxAgentId(optionalTemp.get().getTaxAgentId());
|
|
|
|
|
|
po.setTaxAgentId(optionalTemp.get().getTaxAgentId());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//个税扣缴义务人不存在
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "个税扣缴义务人不存在或不在权限范围内");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-02 15:46:32 +08:00
|
|
|
|
IncomeCategoryEnum incomeCategoryEnum = IncomeCategoryEnum.parseByDefaultLabel(dto.getIncomeCategoryName());
|
|
|
|
|
|
if (incomeCategoryEnum == null) {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "所得项目不存在!");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
po.setIncomeCategory(incomeCategoryEnum.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-19 11:23:59 +08:00
|
|
|
|
po.setRecipientName(dto.getRecipientName());
|
|
|
|
|
|
po.setTaxCode(dto.getTaxCode());
|
|
|
|
|
|
po.setDonationNumber(dto.getDonationNumber());
|
|
|
|
|
|
po.setDonateDate(dto.getDonateDate());
|
|
|
|
|
|
po.setDonateAmount(dto.getDonateAmount());
|
|
|
|
|
|
po.setDeductionProportion(dto.getDeductionProportion());
|
|
|
|
|
|
po.setActualDeduction(dto.getActualDeduction());
|
|
|
|
|
|
|
|
|
|
|
|
if (errorSum == 0) {
|
|
|
|
|
|
successCount += 1;
|
|
|
|
|
|
String key = mainPo.getTaxAgentId() + "-" + mainPo.getEmployeeId();
|
|
|
|
|
|
Map<String, OtherDeductionPO> deductionPOMap = SalaryEntityUtil.convert2Map(eligibleData, e -> e.getTaxAgentId() + "-" + e.getEmployeeId());
|
|
|
|
|
|
if (deductionPOMap.containsKey(key)) {
|
|
|
|
|
|
deductionPOMap.get(key).getGrantDonationList().add(po);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
mainPo.getGrantDonationList().add(po);
|
|
|
|
|
|
eligibleData.add(mainPo);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
errorCount += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HashMap<Object, Object> dataMap = new HashMap<>();
|
|
|
|
|
|
dataMap.put("successCount", successCount);
|
|
|
|
|
|
dataMap.put("errorCount", errorCount);
|
|
|
|
|
|
dataMap.put("errorData", errorData);
|
|
|
|
|
|
apidatas.put("derateDeduction", dataMap);
|
|
|
|
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
IOUtils.closeQuietly(fileInputStream);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-19 10:46:04 +08:00
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId));
|
|
|
|
|
|
|
|
|
|
|
|
int successCount = 0;
|
|
|
|
|
|
int errorCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 错误excel内容
|
|
|
|
|
|
List<Map> errorData = new ArrayList<>();
|
|
|
|
|
|
|
2025-07-02 15:46:32 +08:00
|
|
|
|
List<DerateDeductionListDTO> derateDeductionList = ExcelParseHelper.parse2Map(fileInputStream, DerateDeductionListDTO.class, 4, 1, 10, "OtherDeductionTemplate.xlsx");
|
2024-12-19 10:46:04 +08:00
|
|
|
|
for (int i = 0; i < derateDeductionList.size(); i++) {
|
|
|
|
|
|
DerateDeductionListDTO dto = derateDeductionList.get(i);
|
|
|
|
|
|
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
//待插入数据库对象
|
|
|
|
|
|
OtherDeductionPO mainPo = OtherDeductionPO.builder()
|
|
|
|
|
|
.declareMonth(declareMonth)
|
|
|
|
|
|
.freeIncomeList(new ArrayList<>())
|
|
|
|
|
|
.derateDeductionList(new ArrayList<>())
|
|
|
|
|
|
.endowmentInsuranceList(new ArrayList<>())
|
|
|
|
|
|
.grantDonationList(new ArrayList<>())
|
|
|
|
|
|
.healthInsuranceList(new ArrayList<>())
|
|
|
|
|
|
.otherDerateDeductionList(new ArrayList<>())
|
2024-12-25 16:28:21 +08:00
|
|
|
|
.personalPensionList(new ArrayList<>())
|
2024-12-19 10:46:04 +08:00
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
DerateDeductionPO po = DerateDeductionPO.builder()
|
|
|
|
|
|
.taxYearMonth(declareMonth)
|
|
|
|
|
|
.fileStatus(1)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
//异常点数量
|
|
|
|
|
|
int errorSum = 0;
|
|
|
|
|
|
|
|
|
|
|
|
//行号
|
|
|
|
|
|
String rowIndex = String.format("第%s行", i + 2);
|
|
|
|
|
|
|
|
|
|
|
|
//相同的姓名
|
|
|
|
|
|
String userName = dto.getUsername();
|
|
|
|
|
|
String deparmentName = dto.getDepartmentName();
|
|
|
|
|
|
String mobile = dto.getMobile();
|
|
|
|
|
|
String workcode = dto.getJobNum();
|
|
|
|
|
|
String idNo = dto.getIdNo();
|
|
|
|
|
|
List<Long> employeeSameIds = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
//筛选导入人员信息可以在人力资源池中匹配到的人员信息
|
|
|
|
|
|
List<DataCollectionEmployee> emps = getSalaryEmployeeService(user).matchImportEmployee(confValue, employees, userName, deparmentName, mobile, workcode, idNo, null);
|
|
|
|
|
|
//含在职和离职,选在职数据
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) {
|
|
|
|
|
|
employeeSameIds = emps.stream()
|
|
|
|
|
|
.filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus()))
|
|
|
|
|
|
.map(DataCollectionEmployee::getEmployeeId)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) {
|
|
|
|
|
|
employeeSameIds = emps.stream()
|
|
|
|
|
|
.map(DataCollectionEmployee::getEmployeeId)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//当人员信息导入筛选的全局配置为"0"时,姓名才是必填项
|
|
|
|
|
|
if (StringUtils.isBlank(userName) && "0".equals(confValue)) {
|
|
|
|
|
|
//姓名 不能为空
|
|
|
|
|
|
//错误消息对象
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "姓名不能为空");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0) : null;
|
|
|
|
|
|
if (employeeId != null && employeeId > 0) {
|
|
|
|
|
|
mainPo.setEmployeeId(employeeId);
|
|
|
|
|
|
po.setEmployeeId(employeeId);
|
|
|
|
|
|
po.setEmployeeType(DataCollectionEmployeeTypeEnum.ORGANIZATION.getValue());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//姓名错误,系统内不存在该姓名
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String taxAgentName = dto.getTaxAgentName();
|
|
|
|
|
|
if (StringUtils.isBlank(taxAgentName)) {
|
|
|
|
|
|
//个税扣缴义务人不能为空
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "个税扣缴义务人不能为空");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Optional<TaxAgentManageRangeEmployeeDTO> optionalTemp = taxAgentList.stream().filter(m -> m.getTaxAgentName().equals(taxAgentName)).findFirst();
|
|
|
|
|
|
if (optionalTemp.isPresent()) {
|
|
|
|
|
|
mainPo.setTaxAgentId(optionalTemp.get().getTaxAgentId());
|
|
|
|
|
|
po.setTaxAgentId(optionalTemp.get().getTaxAgentId());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//个税扣缴义务人不存在
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "个税扣缴义务人不存在或不在权限范围内");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-02 15:46:32 +08:00
|
|
|
|
IncomeCategoryEnum incomeCategoryEnum = IncomeCategoryEnum.parseByDefaultLabel(dto.getIncomeCategoryName());
|
|
|
|
|
|
if (incomeCategoryEnum == null) {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "所得项目不存在!");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
po.setIncomeCategory(incomeCategoryEnum.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-24 15:52:36 +08:00
|
|
|
|
po.setDerateAmount(dto.getDerateAmount());
|
|
|
|
|
|
po.setDerateItem(dto.getDerateItem());
|
|
|
|
|
|
po.setDerateProperty(dto.getDerateProperty());
|
2024-12-19 10:46:04 +08:00
|
|
|
|
|
|
|
|
|
|
if (errorSum == 0) {
|
|
|
|
|
|
successCount += 1;
|
|
|
|
|
|
String key = mainPo.getTaxAgentId() + "-" + mainPo.getEmployeeId();
|
|
|
|
|
|
Map<String, OtherDeductionPO> deductionPOMap = SalaryEntityUtil.convert2Map(eligibleData, e -> e.getTaxAgentId() + "-" + e.getEmployeeId());
|
|
|
|
|
|
if (deductionPOMap.containsKey(key)) {
|
|
|
|
|
|
deductionPOMap.get(key).getDerateDeductionList().add(po);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
mainPo.getDerateDeductionList().add(po);
|
|
|
|
|
|
eligibleData.add(mainPo);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
errorCount += 1;
|
|
|
|
|
|
// 添加错误数据
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HashMap<Object, Object> dataMap = new HashMap<>();
|
|
|
|
|
|
dataMap.put("successCount", successCount);
|
|
|
|
|
|
dataMap.put("errorCount", errorCount);
|
|
|
|
|
|
dataMap.put("errorData", errorData);
|
|
|
|
|
|
apidatas.put("derateDeduction", dataMap);
|
2024-12-19 09:53:56 +08:00
|
|
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
IOUtils.closeQuietly(fileInputStream);
|
|
|
|
|
|
}
|
2024-12-19 10:46:04 +08:00
|
|
|
|
|
2024-12-19 10:57:21 +08:00
|
|
|
|
try {
|
|
|
|
|
|
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId));
|
|
|
|
|
|
|
|
|
|
|
|
int successCount = 0;
|
|
|
|
|
|
int errorCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 错误excel内容
|
|
|
|
|
|
List<Map> errorData = new ArrayList<>();
|
|
|
|
|
|
|
2025-07-02 15:46:32 +08:00
|
|
|
|
List<OtherDerateDeductionListDTO> dtoList = ExcelParseHelper.parse2Map(fileInputStream, OtherDerateDeductionListDTO.class, 5, 1, 9, "OtherDeductionTemplate.xlsx");
|
2024-12-19 11:23:59 +08:00
|
|
|
|
for (int i = 0; i < dtoList.size(); i++) {
|
|
|
|
|
|
OtherDerateDeductionListDTO dto = dtoList.get(i);
|
2024-12-19 10:57:21 +08:00
|
|
|
|
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
//待插入数据库对象
|
|
|
|
|
|
OtherDeductionPO mainPo = OtherDeductionPO.builder()
|
|
|
|
|
|
.declareMonth(declareMonth)
|
|
|
|
|
|
.freeIncomeList(new ArrayList<>())
|
|
|
|
|
|
.derateDeductionList(new ArrayList<>())
|
|
|
|
|
|
.endowmentInsuranceList(new ArrayList<>())
|
|
|
|
|
|
.grantDonationList(new ArrayList<>())
|
|
|
|
|
|
.healthInsuranceList(new ArrayList<>())
|
|
|
|
|
|
.otherDerateDeductionList(new ArrayList<>())
|
2024-12-25 16:28:21 +08:00
|
|
|
|
.personalPensionList(new ArrayList<>())
|
2024-12-19 10:57:21 +08:00
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
2024-12-19 11:23:59 +08:00
|
|
|
|
OtherDerateDeductionPO po = OtherDerateDeductionPO.builder()
|
2024-12-19 10:57:21 +08:00
|
|
|
|
.taxYearMonth(declareMonth)
|
|
|
|
|
|
.fileStatus(1)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
//异常点数量
|
|
|
|
|
|
int errorSum = 0;
|
|
|
|
|
|
|
|
|
|
|
|
//行号
|
|
|
|
|
|
String rowIndex = String.format("第%s行", i + 2);
|
|
|
|
|
|
|
|
|
|
|
|
//相同的姓名
|
|
|
|
|
|
String userName = dto.getUsername();
|
|
|
|
|
|
String deparmentName = dto.getDepartmentName();
|
|
|
|
|
|
String mobile = dto.getMobile();
|
|
|
|
|
|
String workcode = dto.getJobNum();
|
|
|
|
|
|
String idNo = dto.getIdNo();
|
|
|
|
|
|
List<Long> employeeSameIds = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
//筛选导入人员信息可以在人力资源池中匹配到的人员信息
|
|
|
|
|
|
List<DataCollectionEmployee> emps = getSalaryEmployeeService(user).matchImportEmployee(confValue, employees, userName, deparmentName, mobile, workcode, idNo, null);
|
|
|
|
|
|
//含在职和离职,选在职数据
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) {
|
|
|
|
|
|
employeeSameIds = emps.stream()
|
|
|
|
|
|
.filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus()))
|
|
|
|
|
|
.map(DataCollectionEmployee::getEmployeeId)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) {
|
|
|
|
|
|
employeeSameIds = emps.stream()
|
|
|
|
|
|
.map(DataCollectionEmployee::getEmployeeId)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//当人员信息导入筛选的全局配置为"0"时,姓名才是必填项
|
|
|
|
|
|
if (StringUtils.isBlank(userName) && "0".equals(confValue)) {
|
|
|
|
|
|
//姓名 不能为空
|
|
|
|
|
|
//错误消息对象
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "姓名不能为空");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0) : null;
|
|
|
|
|
|
if (employeeId != null && employeeId > 0) {
|
|
|
|
|
|
mainPo.setEmployeeId(employeeId);
|
|
|
|
|
|
po.setEmployeeId(employeeId);
|
|
|
|
|
|
po.setEmployeeType(DataCollectionEmployeeTypeEnum.ORGANIZATION.getValue());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//姓名错误,系统内不存在该姓名
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-19 10:46:04 +08:00
|
|
|
|
|
2024-12-19 10:57:21 +08:00
|
|
|
|
String taxAgentName = dto.getTaxAgentName();
|
|
|
|
|
|
if (StringUtils.isBlank(taxAgentName)) {
|
|
|
|
|
|
//个税扣缴义务人不能为空
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "个税扣缴义务人不能为空");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Optional<TaxAgentManageRangeEmployeeDTO> optionalTemp = taxAgentList.stream().filter(m -> m.getTaxAgentName().equals(taxAgentName)).findFirst();
|
|
|
|
|
|
if (optionalTemp.isPresent()) {
|
|
|
|
|
|
mainPo.setTaxAgentId(optionalTemp.get().getTaxAgentId());
|
|
|
|
|
|
po.setTaxAgentId(optionalTemp.get().getTaxAgentId());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//个税扣缴义务人不存在
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "个税扣缴义务人不存在或不在权限范围内");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-02 15:46:32 +08:00
|
|
|
|
IncomeCategoryEnum incomeCategoryEnum = IncomeCategoryEnum.parseByDefaultLabel(dto.getIncomeCategoryName());
|
|
|
|
|
|
if (incomeCategoryEnum == null) {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "所得项目不存在!");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
po.setIncomeCategory(incomeCategoryEnum.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-19 11:23:59 +08:00
|
|
|
|
po.setOtherDeduction(dto.getOtherDeduction());
|
|
|
|
|
|
po.setRemark(dto.getRemark());
|
|
|
|
|
|
|
2024-12-19 10:57:21 +08:00
|
|
|
|
|
|
|
|
|
|
if (errorSum == 0) {
|
|
|
|
|
|
successCount += 1;
|
|
|
|
|
|
String key = mainPo.getTaxAgentId() + "-" + mainPo.getEmployeeId();
|
|
|
|
|
|
Map<String, OtherDeductionPO> deductionPOMap = SalaryEntityUtil.convert2Map(eligibleData, e -> e.getTaxAgentId() + "-" + e.getEmployeeId());
|
|
|
|
|
|
if (deductionPOMap.containsKey(key)) {
|
2024-12-19 11:23:59 +08:00
|
|
|
|
deductionPOMap.get(key).getOtherDerateDeductionList().add(po);
|
2024-12-19 10:57:21 +08:00
|
|
|
|
} else {
|
2024-12-19 11:23:59 +08:00
|
|
|
|
mainPo.getOtherDerateDeductionList().add(po);
|
2024-12-19 10:57:21 +08:00
|
|
|
|
eligibleData.add(mainPo);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
errorCount += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HashMap<Object, Object> dataMap = new HashMap<>();
|
|
|
|
|
|
dataMap.put("successCount", successCount);
|
|
|
|
|
|
dataMap.put("errorCount", errorCount);
|
|
|
|
|
|
dataMap.put("errorData", errorData);
|
|
|
|
|
|
apidatas.put("derateDeduction", dataMap);
|
|
|
|
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
IOUtils.closeQuietly(fileInputStream);
|
|
|
|
|
|
}
|
2024-12-19 10:46:04 +08:00
|
|
|
|
|
2024-12-23 16:41:42 +08:00
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId));
|
|
|
|
|
|
|
|
|
|
|
|
int successCount = 0;
|
|
|
|
|
|
int errorCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 错误excel内容
|
|
|
|
|
|
List<Map> errorData = new ArrayList<>();
|
|
|
|
|
|
|
2025-07-02 15:46:32 +08:00
|
|
|
|
List<PersonalPensionListDTO> dtoList = ExcelParseHelper.parse2Map(fileInputStream, PersonalPensionListDTO.class, 6, 1, 10, "OtherDeductionTemplate.xlsx");
|
2024-12-23 16:41:42 +08:00
|
|
|
|
for (int i = 0; i < dtoList.size(); i++) {
|
|
|
|
|
|
PersonalPensionListDTO dto = dtoList.get(i);
|
|
|
|
|
|
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
//待插入数据库对象
|
|
|
|
|
|
OtherDeductionPO mainPo = OtherDeductionPO.builder()
|
|
|
|
|
|
.declareMonth(declareMonth)
|
|
|
|
|
|
.freeIncomeList(new ArrayList<>())
|
|
|
|
|
|
.derateDeductionList(new ArrayList<>())
|
|
|
|
|
|
.endowmentInsuranceList(new ArrayList<>())
|
|
|
|
|
|
.grantDonationList(new ArrayList<>())
|
|
|
|
|
|
.healthInsuranceList(new ArrayList<>())
|
|
|
|
|
|
.otherDerateDeductionList(new ArrayList<>())
|
2024-12-25 16:28:21 +08:00
|
|
|
|
.personalPensionList(new ArrayList<>())
|
2024-12-23 16:41:42 +08:00
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
PersonalPensionPO po = PersonalPensionPO.builder()
|
|
|
|
|
|
.taxYearMonth(declareMonth)
|
|
|
|
|
|
.fileStatus(1)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
//异常点数量
|
|
|
|
|
|
int errorSum = 0;
|
|
|
|
|
|
|
|
|
|
|
|
//行号
|
|
|
|
|
|
String rowIndex = String.format("第%s行", i + 2);
|
|
|
|
|
|
|
|
|
|
|
|
//相同的姓名
|
|
|
|
|
|
String userName = dto.getUsername();
|
|
|
|
|
|
String deparmentName = dto.getDepartmentName();
|
|
|
|
|
|
String mobile = dto.getMobile();
|
|
|
|
|
|
String workcode = dto.getJobNum();
|
|
|
|
|
|
String idNo = dto.getIdNo();
|
|
|
|
|
|
List<Long> employeeSameIds = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
//筛选导入人员信息可以在人力资源池中匹配到的人员信息
|
|
|
|
|
|
List<DataCollectionEmployee> emps = getSalaryEmployeeService(user).matchImportEmployee(confValue, employees, userName, deparmentName, mobile, workcode, idNo, null);
|
|
|
|
|
|
//含在职和离职,选在职数据
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) {
|
|
|
|
|
|
employeeSameIds = emps.stream()
|
|
|
|
|
|
.filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus()))
|
|
|
|
|
|
.map(DataCollectionEmployee::getEmployeeId)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) {
|
|
|
|
|
|
employeeSameIds = emps.stream()
|
|
|
|
|
|
.map(DataCollectionEmployee::getEmployeeId)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//当人员信息导入筛选的全局配置为"0"时,姓名才是必填项
|
|
|
|
|
|
if (StringUtils.isBlank(userName) && "0".equals(confValue)) {
|
|
|
|
|
|
//姓名 不能为空
|
|
|
|
|
|
//错误消息对象
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "姓名不能为空");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0) : null;
|
|
|
|
|
|
if (employeeId != null && employeeId > 0) {
|
|
|
|
|
|
mainPo.setEmployeeId(employeeId);
|
|
|
|
|
|
po.setEmployeeId(employeeId);
|
|
|
|
|
|
po.setEmployeeType(DataCollectionEmployeeTypeEnum.ORGANIZATION.getValue());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//姓名错误,系统内不存在该姓名
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String taxAgentName = dto.getTaxAgentName();
|
|
|
|
|
|
if (StringUtils.isBlank(taxAgentName)) {
|
|
|
|
|
|
//个税扣缴义务人不能为空
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "个税扣缴义务人不能为空");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Optional<TaxAgentManageRangeEmployeeDTO> optionalTemp = taxAgentList.stream().filter(m -> m.getTaxAgentName().equals(taxAgentName)).findFirst();
|
|
|
|
|
|
if (optionalTemp.isPresent()) {
|
|
|
|
|
|
mainPo.setTaxAgentId(optionalTemp.get().getTaxAgentId());
|
|
|
|
|
|
po.setTaxAgentId(optionalTemp.get().getTaxAgentId());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//个税扣缴义务人不存在
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "个税扣缴义务人不存在或不在权限范围内");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-02 15:46:32 +08:00
|
|
|
|
IncomeCategoryEnum incomeCategoryEnum = IncomeCategoryEnum.parseByDefaultLabel(dto.getIncomeCategoryName());
|
|
|
|
|
|
if (incomeCategoryEnum == null) {
|
|
|
|
|
|
Map<String, String> errorMessageMap = Maps.newHashMap();
|
|
|
|
|
|
errorMessageMap.put("message", rowIndex + "所得项目不存在!");
|
|
|
|
|
|
errorData.add(errorMessageMap);
|
|
|
|
|
|
errorSum += 1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
po.setIncomeCategory(incomeCategoryEnum.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-23 16:41:42 +08:00
|
|
|
|
po.setVoucherTypeName(dto.getVoucherTypeName());
|
|
|
|
|
|
po.setVoucherNo(dto.getVoucherNo());
|
|
|
|
|
|
po.setPayAmount(dto.getPayAmount());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (errorSum == 0) {
|
|
|
|
|
|
successCount += 1;
|
|
|
|
|
|
String key = mainPo.getTaxAgentId() + "-" + mainPo.getEmployeeId();
|
|
|
|
|
|
Map<String, OtherDeductionPO> deductionPOMap = SalaryEntityUtil.convert2Map(eligibleData, e -> e.getTaxAgentId() + "-" + e.getEmployeeId());
|
|
|
|
|
|
if (deductionPOMap.containsKey(key)) {
|
|
|
|
|
|
deductionPOMap.get(key).getPersonalPensionList().add(po);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
mainPo.getPersonalPensionList().add(po);
|
|
|
|
|
|
eligibleData.add(mainPo);
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
errorCount += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HashMap<Object, Object> dataMap = new HashMap<>();
|
|
|
|
|
|
dataMap.put("successCount", successCount);
|
|
|
|
|
|
dataMap.put("errorCount", errorCount);
|
|
|
|
|
|
dataMap.put("errorData", errorData);
|
|
|
|
|
|
apidatas.put("derateDeduction", dataMap);
|
|
|
|
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
IOUtils.closeQuietly(fileInputStream);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-25 16:28:21 +08:00
|
|
|
|
eligibleData.forEach(po -> {
|
2024-12-25 16:42:27 +08:00
|
|
|
|
//列表转为属性数据
|
2024-12-25 16:28:21 +08:00
|
|
|
|
po.handleList();
|
|
|
|
|
|
|
|
|
|
|
|
//清除旧数据
|
2025-03-05 15:06:01 +08:00
|
|
|
|
OtherDeductionPO otherDeductionPO = getOtherDeductionMapper().getByTaxAgentIdAndEmployeeIdAndDeclareMonth(po.getTaxAgentId(), po.getEmployeeId(), po.getDeclareMonth());
|
2024-12-26 15:16:24 +08:00
|
|
|
|
if (otherDeductionPO != null) {
|
2024-12-25 16:42:27 +08:00
|
|
|
|
getOtherDeductionMapper().delete(otherDeductionPO);
|
|
|
|
|
|
getFreeIncomeMapper().deleteByMainId(otherDeductionPO.getId());
|
|
|
|
|
|
getHealthInsuranceMapper().deleteByMainId(otherDeductionPO.getId());
|
|
|
|
|
|
getEndowmentInsuranceMapper().deleteByMainId(otherDeductionPO.getId());
|
|
|
|
|
|
getGrantDonationMapper().deleteByMainId(otherDeductionPO.getId());
|
|
|
|
|
|
getDerateDeductionMapper().deleteByMainId(otherDeductionPO.getId());
|
|
|
|
|
|
getOtherDerateDeductionMapper().deleteByMainId(otherDeductionPO.getId());
|
|
|
|
|
|
getPersonalPensionMapper().deleteByMainId(otherDeductionPO.getId());
|
|
|
|
|
|
}
|
2024-12-25 16:28:21 +08:00
|
|
|
|
|
|
|
|
|
|
//更新主表
|
|
|
|
|
|
getOtherDeductionMapper().insertIgnoreNull(po);
|
|
|
|
|
|
|
|
|
|
|
|
//更新各项明细
|
|
|
|
|
|
po.getFreeIncomeList().forEach(l -> {
|
|
|
|
|
|
l.setId(IdGenerator.generate());
|
|
|
|
|
|
l.setMainId(po.getId());
|
|
|
|
|
|
getFreeIncomeMapper().insertIgnoreNull(l);
|
|
|
|
|
|
});
|
|
|
|
|
|
po.getHealthInsuranceList().forEach(l -> {
|
|
|
|
|
|
l.setId(IdGenerator.generate());
|
|
|
|
|
|
l.setMainId(po.getId());
|
|
|
|
|
|
getHealthInsuranceMapper().insertIgnoreNull(l);
|
|
|
|
|
|
});
|
|
|
|
|
|
po.getEndowmentInsuranceList().forEach(l -> {
|
|
|
|
|
|
l.setId(IdGenerator.generate());
|
|
|
|
|
|
l.setMainId(po.getId());
|
|
|
|
|
|
getEndowmentInsuranceMapper().insertIgnoreNull(l);
|
|
|
|
|
|
});
|
|
|
|
|
|
po.getGrantDonationList().forEach(l -> {
|
|
|
|
|
|
l.setId(IdGenerator.generate());
|
|
|
|
|
|
l.setMainId(po.getId());
|
|
|
|
|
|
getGrantDonationMapper().insertIgnoreNull(l);
|
|
|
|
|
|
});
|
|
|
|
|
|
po.getDerateDeductionList().forEach(l -> {
|
|
|
|
|
|
l.setId(IdGenerator.generate());
|
|
|
|
|
|
l.setMainId(po.getId());
|
|
|
|
|
|
getDerateDeductionMapper().insertIgnoreNull(l);
|
|
|
|
|
|
});
|
|
|
|
|
|
po.getOtherDerateDeductionList().forEach(l -> {
|
|
|
|
|
|
l.setId(IdGenerator.generate());
|
|
|
|
|
|
l.setMainId(po.getId());
|
|
|
|
|
|
getOtherDerateDeductionMapper().insertIgnoreNull(l);
|
|
|
|
|
|
});
|
|
|
|
|
|
po.getPersonalPensionList().forEach(l -> {
|
|
|
|
|
|
l.setId(IdGenerator.generate());
|
|
|
|
|
|
l.setMainId(po.getId());
|
|
|
|
|
|
getPersonalPensionMapper().insertIgnoreNull(l);
|
|
|
|
|
|
});
|
2025-01-14 17:05:31 +08:00
|
|
|
|
|
|
|
|
|
|
syncMain(po.getId(), Arrays.asList(TaxFreeTypeEnum.FREE_INCOME,
|
|
|
|
|
|
TaxFreeTypeEnum.HEALTH_INSURANCE,
|
|
|
|
|
|
TaxFreeTypeEnum.ENDOWMENT_INSURANCE,
|
|
|
|
|
|
TaxFreeTypeEnum.GRANT_DONATION,
|
|
|
|
|
|
TaxFreeTypeEnum.DERATE_DEDUCTION,
|
|
|
|
|
|
TaxFreeTypeEnum.OTHER_DERATE_DEDUCTION,
|
|
|
|
|
|
TaxFreeTypeEnum.PERSONAL_PENSION));
|
2024-12-25 16:28:21 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2024-12-19 09:53:56 +08:00
|
|
|
|
return apidatas;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-30 09:58:13 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 处理导入数据
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param pos
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void handleImportData(List<OtherDeductionPO> pos) {
|
|
|
|
|
|
if (CollectionUtils.isEmpty(pos)) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
OtherDeductionBiz otherDeductionBiz = new OtherDeductionBiz();
|
|
|
|
|
|
OtherDeductionPO po = pos.get(0);
|
|
|
|
|
|
// 多条相同人的则以第一条为准,如果逆序排列(用于重复的则以最后一条为准)Collections.reverse(pos);
|
|
|
|
|
|
// 去重(通过记录的唯一条件(申报月份,人员id,个税扣缴义务人id)拼接)
|
|
|
|
|
|
List<OtherDeductionPO> finalPos = pos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getEmployeeId() + "-" + f.getTaxAgentId()))), ArrayList::new));
|
|
|
|
|
|
// 查询已有数据
|
|
|
|
|
|
List<OtherDeductionPO> list = otherDeductionBiz.listSome(OtherDeductionPO.builder().declareMonth(po.getDeclareMonth()).build());
|
|
|
|
|
|
// 待修改的 本地已存在则更新【交集】
|
|
|
|
|
|
List<OtherDeductionPO> updateList = list.stream().map(m -> {
|
|
|
|
|
|
Optional<OtherDeductionPO> optional = finalPos.stream().filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())).findFirst();
|
|
|
|
|
|
OtherDeductionPO temp = null;
|
|
|
|
|
|
if (optional.isPresent()) {
|
|
|
|
|
|
temp = optional.get();
|
|
|
|
|
|
// 换成本地库的id
|
|
|
|
|
|
temp.setId(m.getId());
|
|
|
|
|
|
}
|
|
|
|
|
|
return temp;
|
|
|
|
|
|
}).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
|
|
|
// 待新增的 导入比本地多,则新增【差集(导入 - local)】
|
|
|
|
|
|
List<OtherDeductionPO> saveList = finalPos.stream().map(m -> {
|
|
|
|
|
|
Optional<OtherDeductionPO> optional = list.stream().filter(p -> (p.getEmployeeId() + "-" + p.getTaxAgentId()).equals(m.getEmployeeId() + "-" + m.getTaxAgentId())).findFirst();
|
|
|
|
|
|
OtherDeductionPO temp = null;
|
|
|
|
|
|
if (!optional.isPresent()) {
|
|
|
|
|
|
temp = m;
|
|
|
|
|
|
}
|
|
|
|
|
|
return temp;
|
|
|
|
|
|
}).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
// 修改
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(updateList)) {
|
|
|
|
|
|
otherDeductionBiz.batchUpdate(updateList);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 保存
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(saveList)) {
|
|
|
|
|
|
otherDeductionBiz.batchSave(saveList);
|
|
|
|
|
|
}
|
2024-02-21 18:19:02 +08:00
|
|
|
|
// 记录日志
|
|
|
|
|
|
// 根据月份、人员id查出保存的数据
|
|
|
|
|
|
List<Long> empIds = saveList.stream().map(OtherDeductionPO::getEmployeeId).collect(Collectors.toList());
|
|
|
|
|
|
List<OtherDeductionPO> insertList = otherDeductionBiz.listSome(OtherDeductionPO.builder().declareMonth(po.getDeclareMonth()).employeeIds(empIds).build());
|
|
|
|
|
|
Map<String, OtherDeductionPO> insertMap = SalaryEntityUtil.convert2Map(insertList, p -> p.getTaxAgentId() + "-" + SalaryDateUtil.getFormatYearMonth(p.getDeclareMonth()) + "-" + p.getEmployeeId());
|
|
|
|
|
|
saveList.forEach(save -> {
|
|
|
|
|
|
OtherDeductionPO otherDeductionPO = insertMap.get(save.getTaxAgentId() + "-" + SalaryDateUtil.getFormatYearMonth(save.getDeclareMonth()) + "-" + save.getEmployeeId());
|
|
|
|
|
|
if (otherDeductionPO != null) {
|
|
|
|
|
|
updateList.add(otherDeductionPO);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2024-01-30 09:58:13 +08:00
|
|
|
|
|
2024-02-21 18:19:02 +08:00
|
|
|
|
if (CollectionUtils.isNotEmpty(updateList)) {
|
|
|
|
|
|
LoggerContext loggerContext = new LoggerContext<>();
|
2024-01-30 09:58:13 +08:00
|
|
|
|
loggerContext.setUser(user);
|
2024-03-14 15:28:14 +08:00
|
|
|
|
if (updateList.size() == 1) {
|
2024-02-23 15:11:56 +08:00
|
|
|
|
loggerContext.setTargetId(updateList.get(0).getId().toString());
|
|
|
|
|
|
}
|
2024-03-14 15:28:14 +08:00
|
|
|
|
loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "其他免税扣除"));
|
2024-01-30 09:58:13 +08:00
|
|
|
|
loggerContext.setOperateType(OperateTypeEnum.ADD.getValue());
|
2024-03-14 15:28:14 +08:00
|
|
|
|
loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新增"));
|
|
|
|
|
|
loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新增其他免税扣除"));
|
2024-02-21 18:19:02 +08:00
|
|
|
|
loggerContext.setNewValueList(updateList);
|
|
|
|
|
|
SalaryElogConfig.otherDeductionLoggerTemplate.write(loggerContext);
|
2024-01-30 09:58:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-31 09:58:35 +08:00
|
|
|
|
private void checkImportParam(OtherDeductionImportParam importParam) {
|
|
|
|
|
|
//excel文件id
|
|
|
|
|
|
String imageId = Util.null2String(importParam.getImageId());
|
|
|
|
|
|
//税款所属期
|
|
|
|
|
|
String declareMonthStr = Util.null2String(importParam.getDeclareMonth());
|
2022-03-10 17:57:46 +08:00
|
|
|
|
|
2022-05-31 09:58:35 +08:00
|
|
|
|
if (StringUtils.isBlank(imageId)) {
|
|
|
|
|
|
throw new SalaryRunTimeException("文件不存在");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isBlank(declareMonthStr)) {
|
|
|
|
|
|
throw new SalaryRunTimeException("税款所属期为空");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-31 11:21:51 +08:00
|
|
|
|
|
2022-05-31 09:58:35 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 导出
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param param
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public XSSFWorkbook export(OtherDeductionQueryParam param) {
|
|
|
|
|
|
|
|
|
|
|
|
//获取操作按钮资源
|
2024-03-14 18:16:20 +08:00
|
|
|
|
List<List<Object>> rowList = getExcelRowList(param, true);
|
2022-05-31 09:58:35 +08:00
|
|
|
|
|
2024-02-21 18:19:02 +08:00
|
|
|
|
// 记录日志
|
|
|
|
|
|
String name = SalaryI18nUtil.getI18nLabel(0, "导出");
|
|
|
|
|
|
LoggerContext<OtherDeductionPO> loggerContext = new LoggerContext<>();
|
|
|
|
|
|
loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "其他免税扣除"));
|
|
|
|
|
|
loggerContext.setOperateType(OperateTypeEnum.EXCEL_EXPORT.getValue());
|
|
|
|
|
|
loggerContext.setOperateTypeName(name);
|
|
|
|
|
|
loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "其他免税扣除") + "-" + name);
|
|
|
|
|
|
loggerContext.setUser(user);
|
|
|
|
|
|
SalaryElogConfig.otherDeductionLoggerTemplate.write(loggerContext);
|
|
|
|
|
|
|
2022-05-31 09:58:35 +08:00
|
|
|
|
//获取excel
|
2024-03-18 14:01:08 +08:00
|
|
|
|
return ExcelUtil.genWorkbookV2WithDefaultPattern(rowList, "其他免税扣除", 2);
|
2022-05-31 09:58:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取excel数据行
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return 导出数据行集合
|
|
|
|
|
|
*/
|
2024-03-14 15:28:14 +08:00
|
|
|
|
private List<List<Object>> getExcelRowList(OtherDeductionQueryParam param, boolean hasData) {
|
2022-05-31 09:58:35 +08:00
|
|
|
|
long employeeId = user.getUID();
|
|
|
|
|
|
//excel标题
|
2024-12-19 09:53:56 +08:00
|
|
|
|
List<Object> title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "免税收入", "商业健康保险", "税延养老保险", "准予扣除的捐赠额", "减免税额", "其他", "个人养老金");
|
2024-03-14 15:28:14 +08:00
|
|
|
|
List<List<Object>> rowList = new ArrayList<>();
|
|
|
|
|
|
rowList.add(title);
|
2022-05-31 09:58:35 +08:00
|
|
|
|
|
2024-03-14 15:28:14 +08:00
|
|
|
|
if (hasData) {
|
|
|
|
|
|
//排序配置
|
|
|
|
|
|
OrderRuleVO orderRule = getSalarySysConfService(user).orderRule();
|
|
|
|
|
|
param.setOrderRule(orderRule);
|
|
|
|
|
|
|
|
|
|
|
|
List<OtherDeductionListDTO> list = getOtherDeductionMapper().list(param);
|
|
|
|
|
|
encryptUtil.decryptList(list, OtherDeductionListDTO.class);
|
|
|
|
|
|
SalaryI18nUtil.i18nList(list);
|
|
|
|
|
|
// 开启分权并且不是薪酬模块总管理员
|
|
|
|
|
|
if (getTaxAgentService(user).isOpenDevolution() && !getTaxAgentService(user).isChief(employeeId)) {
|
|
|
|
|
|
List<Long> taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
list = list.stream().filter(f ->
|
|
|
|
|
|
// 作为管理员
|
|
|
|
|
|
taxAgentIdsAsAdmin.contains(f.getTaxAgentId())
|
|
|
|
|
|
).collect(Collectors.toList());
|
|
|
|
|
|
}
|
2022-09-23 16:08:41 +08:00
|
|
|
|
|
2024-03-14 15:28:14 +08:00
|
|
|
|
final List<List<Object>> dataRowList = Optional.ofNullable(list)
|
|
|
|
|
|
.map(List::stream)
|
|
|
|
|
|
.map(operatorStream -> operatorStream.map(dto -> {
|
|
|
|
|
|
List<Object> cellList = new ArrayList<>();
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getUsername()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getTaxAgentName()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getDepartmentName()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getMobile()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getJobNum()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getIdNo()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getHiredate()));
|
2024-12-17 14:05:05 +08:00
|
|
|
|
cellList.add(NumberUtil.isNumber(dto.getFreeIncome()) ? new BigDecimal(dto.getFreeIncome()) : Util.null2String(dto.getFreeIncome()));
|
|
|
|
|
|
cellList.add(NumberUtil.isNumber(dto.getDerateDeduction()) ? new BigDecimal(dto.getDerateDeduction()) : Util.null2String(dto.getDerateDeduction()));
|
2024-03-18 14:01:08 +08:00
|
|
|
|
cellList.add(NumberUtil.isNumber(dto.getBusinessHealthyInsurance()) ? new BigDecimal(dto.getBusinessHealthyInsurance()) : Util.null2String(dto.getBusinessHealthyInsurance()));
|
|
|
|
|
|
cellList.add(NumberUtil.isNumber(dto.getTaxDelayEndowmentInsurance()) ? new BigDecimal(dto.getTaxDelayEndowmentInsurance()) : Util.null2String(dto.getTaxDelayEndowmentInsurance()));
|
|
|
|
|
|
cellList.add(NumberUtil.isNumber(dto.getOtherDeduction()) ? new BigDecimal(dto.getOtherDeduction()) : Util.null2String(dto.getOtherDeduction()));
|
|
|
|
|
|
cellList.add(NumberUtil.isNumber(dto.getDeductionAllowedDonation()) ? new BigDecimal(dto.getDeductionAllowedDonation()) : Util.null2String(dto.getDeductionAllowedDonation()));
|
|
|
|
|
|
cellList.add(NumberUtil.isNumber(dto.getPrivatePension()) ? new BigDecimal(dto.getPrivatePension()) : Util.null2String(dto.getPrivatePension()));
|
2024-03-14 15:28:14 +08:00
|
|
|
|
return cellList;
|
|
|
|
|
|
}).collect(Collectors.toList()))
|
|
|
|
|
|
.orElse(Collections.emptyList());
|
|
|
|
|
|
|
|
|
|
|
|
rowList.addAll(dataRowList);
|
2022-05-31 09:58:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return rowList;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 导出详情列表
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param param
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public XSSFWorkbook exportDetail(OtherDeductionQueryParam param) {
|
2022-05-09 14:11:07 +08:00
|
|
|
|
|
|
|
|
|
|
OtherDeductionBiz biz = new OtherDeductionBiz();
|
|
|
|
|
|
|
2022-05-31 09:58:35 +08:00
|
|
|
|
Long id = param.getOtherTaxExemptDeductionId();
|
2022-05-09 14:11:07 +08:00
|
|
|
|
if (id == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException("id不能为空");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OtherDeductionPO po = biz.getById(id);
|
|
|
|
|
|
if (po == null) {
|
2022-05-31 09:58:35 +08:00
|
|
|
|
throw new SalaryRunTimeException(String.format("其他免税扣除不存在" + "[id:%s]", id));
|
2022-05-09 14:11:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-06 17:57:20 +08:00
|
|
|
|
List<DataCollectionEmployee> employeeList = getSalaryEmployeeService(user).getEmployeeByIds(Collections.singletonList(po.getEmployeeId()));
|
2022-05-09 14:11:07 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(employeeList)) {
|
|
|
|
|
|
throw new SalaryRunTimeException("员工信息不存在");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//构建参数
|
2022-05-31 09:58:35 +08:00
|
|
|
|
param.setEmployeeId(po.getEmployeeId());
|
2022-05-09 14:11:07 +08:00
|
|
|
|
//申报月份
|
2022-05-31 09:58:35 +08:00
|
|
|
|
List<String> declareMonth = param.getDeclareMonth();
|
2022-05-09 14:11:07 +08:00
|
|
|
|
if (CollectionUtils.isNotEmpty(declareMonth)) {
|
2022-05-31 09:58:35 +08:00
|
|
|
|
param.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList()));
|
2022-06-24 18:05:08 +08:00
|
|
|
|
param.setDeclareMonthDate(declareMonth.stream().map(e -> e + "-01 00:00:00").map(SalaryDateUtil::dateStrToLocalTime).collect(Collectors.toList()));
|
2022-05-09 14:11:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 09:58:35 +08:00
|
|
|
|
//获取操作按钮资源
|
2024-03-18 14:01:08 +08:00
|
|
|
|
List<List<Object>> rowList = getExcelRowDetailList(param);
|
2022-05-09 14:11:07 +08:00
|
|
|
|
|
2022-05-31 09:58:35 +08:00
|
|
|
|
//获取excel
|
2024-03-18 14:01:08 +08:00
|
|
|
|
return ExcelUtil.genWorkbookWithDefaultPattern(rowList, "其他免税扣除明细", 2);
|
2022-03-10 17:57:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 09:58:35 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 导出详情
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param param
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2024-03-18 14:01:08 +08:00
|
|
|
|
private List<List<Object>> getExcelRowDetailList(OtherDeductionQueryParam param) {
|
2022-05-31 09:58:35 +08:00
|
|
|
|
//excel标题
|
2024-12-19 09:53:56 +08:00
|
|
|
|
List<Object> title = Arrays.asList("姓名", "申报月份", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "免税收入", "商业健康保险", "税延养老保险", "准予扣除的捐赠额", "减免税额", "其他", "个人养老金");
|
2022-03-10 17:57:46 +08:00
|
|
|
|
|
2022-05-31 09:58:35 +08:00
|
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM");
|
|
|
|
|
|
//查询详细信息
|
|
|
|
|
|
List<OtherDeductionRecordDTO> list = getOtherDeductionMapper().recordList(param);
|
2022-12-13 13:34:22 +08:00
|
|
|
|
encryptUtil.decryptList(list, OtherDeductionRecordDTO.class);
|
2024-03-18 14:01:08 +08:00
|
|
|
|
final List<List<Object>> dataRowList = Optional.ofNullable(list)
|
2022-05-31 09:58:35 +08:00
|
|
|
|
.map(List::stream)
|
|
|
|
|
|
.map(operatorStream -> operatorStream.map(dto -> {
|
2024-03-18 14:01:08 +08:00
|
|
|
|
List<Object> cellList = new ArrayList<>();
|
2022-05-31 09:58:35 +08:00
|
|
|
|
cellList.add(Util.null2String(dto.getUsername()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getDeclareMonth() == null ? "" : formatter.format(dto.getDeclareMonth())));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getTaxAgentName()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getDepartmentName()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getMobile()));
|
|
|
|
|
|
cellList.add(Util.null2String(dto.getJobNum()));
|
2024-12-17 14:05:05 +08:00
|
|
|
|
cellList.add(NumberUtil.isNumber(dto.getFreeIncome()) ? new BigDecimal(dto.getFreeIncome()) : Util.null2String(dto.getFreeIncome()));
|
|
|
|
|
|
cellList.add(NumberUtil.isNumber(dto.getDerateDeduction()) ? new BigDecimal(dto.getDerateDeduction()) : Util.null2String(dto.getDerateDeduction()));
|
2024-03-18 14:01:08 +08:00
|
|
|
|
cellList.add(NumberUtil.isNumber(dto.getBusinessHealthyInsurance()) ? new BigDecimal(dto.getBusinessHealthyInsurance()) : Util.null2String(dto.getBusinessHealthyInsurance()));
|
|
|
|
|
|
cellList.add(NumberUtil.isNumber(dto.getTaxDelayEndowmentInsurance()) ? new BigDecimal(dto.getTaxDelayEndowmentInsurance()) : Util.null2String(dto.getTaxDelayEndowmentInsurance()));
|
|
|
|
|
|
cellList.add(NumberUtil.isNumber(dto.getOtherDeduction()) ? new BigDecimal(dto.getOtherDeduction()) : Util.null2String(dto.getOtherDeduction()));
|
|
|
|
|
|
cellList.add(NumberUtil.isNumber(dto.getDeductionAllowedDonation()) ? new BigDecimal(dto.getDeductionAllowedDonation()) : Util.null2String(dto.getDeductionAllowedDonation()));
|
|
|
|
|
|
cellList.add(NumberUtil.isNumber(dto.getPrivatePension()) ? new BigDecimal(dto.getPrivatePension()) : Util.null2String(dto.getPrivatePension()));
|
2022-05-31 09:58:35 +08:00
|
|
|
|
return cellList;
|
|
|
|
|
|
}).collect(Collectors.toList()))
|
|
|
|
|
|
.orElse(Collections.emptyList());
|
|
|
|
|
|
|
2024-03-18 14:01:08 +08:00
|
|
|
|
List<List<Object>> rowList = new ArrayList<>();
|
2022-05-31 09:58:35 +08:00
|
|
|
|
rowList.add(title);
|
|
|
|
|
|
rowList.addAll(dataRowList);
|
|
|
|
|
|
return rowList;
|
2022-03-10 17:57:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-31 09:58:35 +08:00
|
|
|
|
|
2022-04-11 20:17:47 +08:00
|
|
|
|
@Override
|
2022-06-29 17:38:00 +08:00
|
|
|
|
public List<OtherDeductionPO> getOtherDeductionList(YearMonth declareMonth, List<Long> employeeIds, Long taxAgentId) {
|
2022-04-11 20:17:47 +08:00
|
|
|
|
if (declareMonth == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100342, "参数有误:申报月份必传"));
|
|
|
|
|
|
}
|
|
|
|
|
|
OtherDeductionBiz OtherDeductionBiz = new OtherDeductionBiz();
|
2022-06-29 17:38:00 +08:00
|
|
|
|
return OtherDeductionBiz.listSome(OtherDeductionPO.builder().declareMonth(SalaryDateUtil.toDateStartOfMonth(declareMonth)).employeeIds(employeeIds).taxAgentId(taxAgentId).build());
|
2022-04-11 20:17:47 +08:00
|
|
|
|
}
|
2022-04-28 17:44:26 +08:00
|
|
|
|
|
2022-10-26 18:35:23 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void editData(OtherDeductionParam otherDeductionParam) {
|
|
|
|
|
|
String declareMonthStr = otherDeductionParam.getDeclareMonth();
|
|
|
|
|
|
OtherDeductionBiz OtherDeductionBiz = new OtherDeductionBiz();
|
2022-10-28 14:08:27 +08:00
|
|
|
|
|
|
|
|
|
|
Long currentEmployeeId = (long) user.getUID();
|
|
|
|
|
|
// 获取所有个税扣缴义务人
|
|
|
|
|
|
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
|
|
|
|
|
|
OtherDeductionPO byId = OtherDeductionBiz.getById(otherDeductionParam.getId());
|
2022-11-16 11:08:45 +08:00
|
|
|
|
if (byId == null) {
|
2022-10-28 14:08:27 +08:00
|
|
|
|
throw new SalaryRunTimeException("该数据不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
Long taxAgentId = byId.getTaxAgentId();
|
2022-11-16 11:08:45 +08:00
|
|
|
|
boolean canEdit = taxAgentList.stream().anyMatch(t -> Objects.equals(t.getTaxAgentId(), taxAgentId));
|
|
|
|
|
|
if (!canEdit) {
|
2022-10-28 14:08:27 +08:00
|
|
|
|
//没有编辑权限
|
|
|
|
|
|
throw new SalaryRunTimeException("该个税扣缴义务人无权限编辑此数据!");
|
|
|
|
|
|
}
|
2022-10-26 18:35:23 +08:00
|
|
|
|
// 获取已经核算的数据
|
2025-01-21 15:03:36 +08:00
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(declareMonthStr);
|
2022-10-26 18:35:23 +08:00
|
|
|
|
// 判断是否有核算过
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) {
|
|
|
|
|
|
Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(otherDeductionParam.getEmployeeId()) && f.getTaxAgentId().equals(otherDeductionParam.getTaxAgentId())).findFirst();
|
2022-11-16 11:08:45 +08:00
|
|
|
|
if (optionalAcctEmp.isPresent()) {
|
|
|
|
|
|
throw new SalaryRunTimeException("该年月这条数据已经核算过,不可进行编辑!");
|
2022-10-28 14:08:27 +08:00
|
|
|
|
}
|
2022-10-26 18:35:23 +08:00
|
|
|
|
}
|
2022-10-28 14:08:27 +08:00
|
|
|
|
ArrayList<OtherDeductionPO> updateList = new ArrayList<>();
|
2023-04-04 17:29:56 +08:00
|
|
|
|
OtherDeductionPO build = OtherDeductionPO.builder()
|
|
|
|
|
|
.id(otherDeductionParam.getId())
|
2024-12-17 14:05:05 +08:00
|
|
|
|
.freeIncome(otherDeductionParam.getFreeIncome())
|
|
|
|
|
|
.derateDeduction(otherDeductionParam.getDerateDeduction())
|
2023-04-04 17:29:56 +08:00
|
|
|
|
.businessHealthyInsurance(otherDeductionParam.getBusinessHealthyInsurance())
|
|
|
|
|
|
.taxDelayEndowmentInsurance(otherDeductionParam.getTaxDelayEndowmentInsurance())
|
|
|
|
|
|
.otherDeduction(otherDeductionParam.getOtherDeduction())
|
|
|
|
|
|
.deductionAllowedDonation(otherDeductionParam.getDeductionAllowedDonation())
|
|
|
|
|
|
.privatePension(otherDeductionParam.getPrivatePension())
|
2024-02-23 15:11:56 +08:00
|
|
|
|
.updateTime(new Date())
|
2023-04-04 17:29:56 +08:00
|
|
|
|
.build();
|
2022-10-28 14:08:27 +08:00
|
|
|
|
updateList.add(build);
|
|
|
|
|
|
OtherDeductionBiz.batchUpdate(updateList);
|
2024-02-21 18:19:02 +08:00
|
|
|
|
|
|
|
|
|
|
// 记录日志
|
|
|
|
|
|
OtherDeductionPO newValue = OtherDeductionBiz.getById(build.getId());
|
|
|
|
|
|
String name = SalaryI18nUtil.getI18nLabel(0, "编辑");
|
|
|
|
|
|
LoggerContext<AddUpDeduction> loggerContext = new LoggerContext<>();
|
|
|
|
|
|
loggerContext.setTargetId(newValue.getId().toString());
|
|
|
|
|
|
loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "其他免税扣除") + "-" + newValue.getId());
|
|
|
|
|
|
loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
|
|
|
|
|
|
loggerContext.setOperateTypeName(name);
|
|
|
|
|
|
loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "其他免税扣除") + "-" + SalaryI18nUtil
|
|
|
|
|
|
.getI18nLabel(0, "编辑"));
|
|
|
|
|
|
loggerContext.setOldValues(byId);
|
|
|
|
|
|
loggerContext.setNewValues(newValue);
|
|
|
|
|
|
loggerContext.setUser(user);
|
|
|
|
|
|
SalaryElogConfig.otherDeductionLoggerTemplate.write(loggerContext);
|
2022-10-26 18:35:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-27 18:02:05 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void createData(OtherDeductionParam otherDeductionParam) {
|
|
|
|
|
|
long currentEmployeeId = user.getUID();
|
|
|
|
|
|
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
|
|
|
|
|
|
OtherDeductionBiz OtherDeductionBiz = new OtherDeductionBiz();
|
|
|
|
|
|
//查询对于人员信息导入筛选的全局配置
|
|
|
|
|
|
SalarySysConfPO salarySysConfPO = getSalarySysConfMapper().getOneByCode("matchEmployeeMode");
|
|
|
|
|
|
String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0";
|
|
|
|
|
|
|
|
|
|
|
|
//税款所属期
|
|
|
|
|
|
String declareMonthStr = Util.null2String(otherDeductionParam.getDeclareMonth());
|
|
|
|
|
|
//人员信息
|
2023-03-06 17:57:20 +08:00
|
|
|
|
List<DataCollectionEmployee> employees = getSalaryEmployeeService(user).listEmployee();
|
2022-10-27 18:02:05 +08:00
|
|
|
|
// 获取所有个税扣缴义务人
|
|
|
|
|
|
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
|
|
|
|
|
|
//税款所属期
|
|
|
|
|
|
Date declareMonth = SalaryDateUtil.stringToDate(declareMonthStr + "-01");
|
|
|
|
|
|
// 获取已经核算的数据
|
2025-01-21 15:03:36 +08:00
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(declareMonthStr);
|
2022-10-27 18:02:05 +08:00
|
|
|
|
// 查询已有数据
|
|
|
|
|
|
List<OtherDeductionPO> list = getOtherDeductionMapper().listSome(OtherDeductionPO.builder().declareMonth(declareMonth).build());
|
|
|
|
|
|
//合规数据
|
|
|
|
|
|
List<OtherDeductionPO> insertData = new ArrayList<>();
|
|
|
|
|
|
List<TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee> taxAgentEmployees = Lists.newArrayList();
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
//待插入数据库对象
|
|
|
|
|
|
OtherDeductionPO po = OtherDeductionPO.builder()
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.declareMonth(declareMonth).build();
|
|
|
|
|
|
|
|
|
|
|
|
//筛选导入人员信息可以在人力资源池中匹配到的人员信息
|
2022-11-16 11:08:45 +08:00
|
|
|
|
boolean employeeSameId = employees.stream().anyMatch(e -> Objects.equals(e.getEmployeeId(), otherDeductionParam.getEmployeeId()));
|
|
|
|
|
|
if (!employeeSameId) {
|
2022-10-27 18:02:05 +08:00
|
|
|
|
throw new SalaryRunTimeException("员工信息不存在");
|
|
|
|
|
|
}
|
|
|
|
|
|
po.setEmployeeId(otherDeductionParam.getEmployeeId());
|
|
|
|
|
|
String taxAgentName = otherDeductionParam.getTaxAgentName();
|
|
|
|
|
|
if (StringUtils.isBlank(taxAgentName)) {
|
|
|
|
|
|
//个税扣缴义务人不能为空
|
|
|
|
|
|
throw new SalaryRunTimeException("个税扣缴义务人不能为空");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Optional<TaxAgentManageRangeEmployeeDTO> optionalTemp = taxAgentList.stream().filter(m -> m.getTaxAgentName().equals(taxAgentName)).findFirst();
|
|
|
|
|
|
if (optionalTemp.isPresent()) {
|
|
|
|
|
|
po.setTaxAgentId(optionalTemp.get().getTaxAgentId());
|
|
|
|
|
|
taxAgentEmployees = optionalTemp.get().getEmployeeList();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//个税扣缴义务人不存在或不在权限范围内
|
|
|
|
|
|
throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-12-17 14:05:05 +08:00
|
|
|
|
//免税收入
|
|
|
|
|
|
String freeIncome = otherDeductionParam.getFreeIncome();
|
|
|
|
|
|
po.setFreeIncome(freeIncome);
|
|
|
|
|
|
//减免税额
|
|
|
|
|
|
String derateDeduction = otherDeductionParam.getDerateDeduction();
|
|
|
|
|
|
po.setDerateDeduction(derateDeduction);
|
2022-10-27 18:02:05 +08:00
|
|
|
|
//商业健康保险
|
|
|
|
|
|
String businessHealthyInsurance = otherDeductionParam.getBusinessHealthyInsurance();
|
|
|
|
|
|
po.setBusinessHealthyInsurance(businessHealthyInsurance);
|
|
|
|
|
|
//税延养老保险
|
|
|
|
|
|
String taxDelayEndowmentInsurance = otherDeductionParam.getTaxDelayEndowmentInsurance();
|
|
|
|
|
|
po.setTaxDelayEndowmentInsurance(taxDelayEndowmentInsurance);
|
|
|
|
|
|
//其他
|
|
|
|
|
|
String otherDeduction = otherDeductionParam.getOtherDeduction();
|
|
|
|
|
|
po.setOtherDeduction(otherDeduction);
|
|
|
|
|
|
//准予扣除的捐赠额
|
|
|
|
|
|
String deductionAllowedDonation = otherDeductionParam.getDeductionAllowedDonation();
|
|
|
|
|
|
po.setDeductionAllowedDonation(deductionAllowedDonation);
|
2023-04-04 14:21:25 +08:00
|
|
|
|
//个人养老金
|
|
|
|
|
|
String privatePension = otherDeductionParam.getPrivatePension();
|
|
|
|
|
|
po.setPrivatePension(privatePension);
|
2022-10-27 18:02:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否有核算过
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) {
|
|
|
|
|
|
OtherDeductionPO finalPo = po;
|
|
|
|
|
|
Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(finalPo.getEmployeeId()) && f.getTaxAgentId().equals(finalPo.getTaxAgentId())).findFirst();
|
|
|
|
|
|
boolean isExist = list.stream().anyMatch(f -> f.getEmployeeId().equals(finalPo.getEmployeeId()) && f.getTaxAgentId().equals(finalPo.getTaxAgentId()));
|
|
|
|
|
|
if (optionalAcctEmp.isPresent() && isExist) {
|
|
|
|
|
|
throw new SalaryRunTimeException("该年月这条数据已经核算过,不可导入");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
insertData.add(po);
|
|
|
|
|
|
//入库
|
2024-01-30 09:58:13 +08:00
|
|
|
|
handleImportData(insertData);
|
2022-10-27 18:02:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void deleteSelectData(AddUpDeductionRecordDeleteParam deleteParam) {
|
|
|
|
|
|
long currentEmployeeId = user.getUID();
|
|
|
|
|
|
// 获取所有个税扣缴义务人
|
|
|
|
|
|
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
|
2022-10-28 14:08:27 +08:00
|
|
|
|
OtherDeductionBiz otherDeductionBiz = new OtherDeductionBiz();
|
2022-10-27 18:02:05 +08:00
|
|
|
|
String declareMonthStr = deleteParam.getDeclareMonth();
|
|
|
|
|
|
List<Long> deleteIds = deleteParam.getIds();
|
|
|
|
|
|
// 已经核算过的不可操作
|
|
|
|
|
|
// 获取已经核算的数据
|
2025-01-21 15:03:36 +08:00
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(declareMonthStr);
|
2022-10-27 18:02:05 +08:00
|
|
|
|
// 判断是否有核算过
|
|
|
|
|
|
List<Long> deleteList = new ArrayList<>();
|
2024-02-21 18:19:02 +08:00
|
|
|
|
List<OtherDeductionPO> resultList = new ArrayList<>();
|
2022-11-16 11:08:45 +08:00
|
|
|
|
for (int i = 0; i < deleteIds.size(); i++) {
|
2022-10-27 18:02:05 +08:00
|
|
|
|
Long id = deleteIds.get(i);
|
2022-10-28 14:08:27 +08:00
|
|
|
|
OtherDeductionPO byId = otherDeductionBiz.getById(id);
|
2022-11-16 11:08:45 +08:00
|
|
|
|
if (byId == null) {
|
2022-10-28 14:08:27 +08:00
|
|
|
|
throw new SalaryRunTimeException("数据不存在或已被删除!");
|
|
|
|
|
|
}
|
2022-10-27 18:02:05 +08:00
|
|
|
|
// 判断是否在个税扣缴义务人范围内
|
2022-11-16 11:08:45 +08:00
|
|
|
|
Optional<TaxAgentManageRangeEmployeeDTO> first = taxAgentList.stream().filter(m -> Objects.equals(m.getTaxAgentId(), byId.getTaxAgentId())).findFirst();
|
|
|
|
|
|
if (!first.isPresent()) {
|
2022-10-27 18:02:05 +08:00
|
|
|
|
throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内");
|
|
|
|
|
|
}
|
|
|
|
|
|
// 判断用户是否存在
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) {
|
|
|
|
|
|
Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(byId.getEmployeeId()) && f.getTaxAgentId().equals(byId.getTaxAgentId())).findFirst();
|
|
|
|
|
|
if (optionalAcctEmp.isPresent()) {
|
|
|
|
|
|
throw new SalaryRunTimeException("所选数据在该年月中已经核算过并归档,不可进行删除!");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
deleteList.add(byId.getId());
|
2024-02-21 18:19:02 +08:00
|
|
|
|
resultList.add(byId);
|
2022-10-27 18:02:05 +08:00
|
|
|
|
}
|
2022-10-28 14:08:27 +08:00
|
|
|
|
otherDeductionBiz.batchDeleteByIDS(deleteList);
|
2024-02-21 18:19:02 +08:00
|
|
|
|
// 记录日志
|
|
|
|
|
|
resultList.stream().forEach(r -> {
|
|
|
|
|
|
LoggerContext loggerContext = new LoggerContext<>();
|
|
|
|
|
|
loggerContext.setTargetId(r.getId().toString());
|
|
|
|
|
|
loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "其他免税扣除") + "-" + r.getId());
|
|
|
|
|
|
loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue());
|
|
|
|
|
|
loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除"));
|
|
|
|
|
|
loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "其他免税扣除") + "-" + SalaryI18nUtil
|
|
|
|
|
|
.getI18nLabel(0, "删除"));
|
|
|
|
|
|
loggerContext.setOldValues(r);
|
|
|
|
|
|
loggerContext.setUser(user);
|
|
|
|
|
|
SalaryElogConfig.otherDeductionLoggerTemplate.write(loggerContext);
|
|
|
|
|
|
});
|
2022-10-27 18:02:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void deleteAllData(AddUpDeductionRecordDeleteParam deleteParam) {
|
|
|
|
|
|
String declareMonthStr = deleteParam.getDeclareMonth();
|
|
|
|
|
|
long currentEmployeeId = user.getUID();
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
// 获取所有个税扣缴义务人
|
|
|
|
|
|
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
|
|
|
|
|
|
List<Long> taxAgentIds = taxAgentList.stream().map(TaxAgentManageRangeEmployeeDTO::getTaxAgentId).collect(Collectors.toList());
|
|
|
|
|
|
OtherDeductionBiz otherDeductionBiz = new OtherDeductionBiz();
|
2022-11-16 11:08:45 +08:00
|
|
|
|
Date declareMonthDate = null;
|
2022-10-27 18:02:05 +08:00
|
|
|
|
try {
|
2022-11-16 11:08:45 +08:00
|
|
|
|
declareMonthDate = sdf.parse(declareMonthStr + "-01");
|
|
|
|
|
|
} catch (Exception e) {
|
2022-10-27 18:02:05 +08:00
|
|
|
|
throw new SalaryRunTimeException("日期异常");
|
|
|
|
|
|
}
|
2022-10-28 16:35:51 +08:00
|
|
|
|
|
|
|
|
|
|
OtherDeductionPO queryParam = null;
|
2022-11-16 11:08:45 +08:00
|
|
|
|
if (deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))) {
|
2022-10-28 16:35:51 +08:00
|
|
|
|
// 设置了个税扣缴义务人
|
|
|
|
|
|
Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId());
|
2022-11-16 11:08:45 +08:00
|
|
|
|
boolean canDelete = taxAgentIds.stream().anyMatch(t -> Objects.equals(t, taxAgentId));
|
|
|
|
|
|
if (!canDelete) {
|
2022-10-28 16:35:51 +08:00
|
|
|
|
throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内!");
|
|
|
|
|
|
}
|
|
|
|
|
|
ArrayList<Long> tai = new ArrayList<>();
|
|
|
|
|
|
tai.add(taxAgentId);
|
2022-11-16 11:08:45 +08:00
|
|
|
|
queryParam = OtherDeductionPO.builder().declareMonth(declareMonthDate).taxAgentIds(tai).build();
|
|
|
|
|
|
} else {
|
2022-10-28 16:35:51 +08:00
|
|
|
|
queryParam = OtherDeductionPO.builder().declareMonth(declareMonthDate).taxAgentIds(taxAgentIds).build();
|
|
|
|
|
|
}
|
2022-10-27 18:02:05 +08:00
|
|
|
|
// 获取所有想要删除的数据
|
|
|
|
|
|
List<OtherDeductionPO> list = otherDeductionBiz.listSome(queryParam);
|
|
|
|
|
|
// 获取已经核算的数据
|
2025-01-21 15:03:36 +08:00
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(declareMonthStr);
|
2022-11-16 11:08:45 +08:00
|
|
|
|
for (OtherDeductionPO item : list) {
|
2022-10-27 18:02:05 +08:00
|
|
|
|
if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) {
|
|
|
|
|
|
Optional<SalaryAcctEmployeePO> optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(item.getEmployeeId()) && f.getTaxAgentId().equals(item.getTaxAgentId())).findFirst();
|
|
|
|
|
|
if (optionalAcctEmp.isPresent()) {
|
|
|
|
|
|
throw new SalaryRunTimeException("有员工在该年月中已经完成核算并归档,不能进行一键清空!");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
List<Long> deleteIds = list.stream().map(OtherDeductionPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
otherDeductionBiz.batchDeleteByIDS(deleteIds);
|
2024-02-21 18:19:02 +08:00
|
|
|
|
|
|
|
|
|
|
// 记录日志
|
|
|
|
|
|
Collection<Long> finalTaxAgentIds = queryParam.getTaxAgentIds();
|
|
|
|
|
|
List<String> taxAgentNames = taxAgentList.stream().filter(t -> finalTaxAgentIds.contains(t.getTaxAgentId()))
|
|
|
|
|
|
.map(TaxAgentManageRangeEmployeeDTO::getTaxAgentName).collect(Collectors.toList());
|
|
|
|
|
|
String name = declareMonthStr + " " + StringUtils.join(taxAgentNames, ",");
|
|
|
|
|
|
LoggerContext<OtherDeductionPO> loggerContext = new LoggerContext<>();
|
|
|
|
|
|
loggerContext.setTargetName(name);
|
|
|
|
|
|
loggerContext.setOperateType(OperateTypeEnum.CLEAR.getValue());
|
|
|
|
|
|
loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "一键清空"));
|
|
|
|
|
|
loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "其他免税扣除") + "-" + SalaryI18nUtil
|
|
|
|
|
|
.getI18nLabel(0, "一键清空:") + name);
|
|
|
|
|
|
loggerContext.setUser(user);
|
|
|
|
|
|
SalaryElogConfig.otherDeductionLoggerTemplate.write(loggerContext);
|
2022-10-27 18:02:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-31 14:50:54 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public OtherDeductionRecordDTO getOtherDeduction(OtherDeductionParam otherDeductionParam) {
|
|
|
|
|
|
long uid = user.getUID();
|
|
|
|
|
|
// 获取所有个税扣缴义务人
|
|
|
|
|
|
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(uid);
|
|
|
|
|
|
List<String> taxAgentNames = taxAgentList.stream().map(TaxAgentManageRangeEmployeeDTO::getTaxAgentName).collect(Collectors.toList());
|
|
|
|
|
|
ArrayList<Long> ids = new ArrayList<>();
|
|
|
|
|
|
ids.add(otherDeductionParam.getId());
|
|
|
|
|
|
OtherDeductionQueryParam build = OtherDeductionQueryParam.builder().ids(ids).build();
|
|
|
|
|
|
List<OtherDeductionRecordDTO> list = getOtherDeductionMapper().recordList(build);
|
2022-12-13 13:34:22 +08:00
|
|
|
|
encryptUtil.decryptList(list, OtherDeductionRecordDTO.class);
|
2022-10-31 14:50:54 +08:00
|
|
|
|
|
2022-11-16 11:08:45 +08:00
|
|
|
|
if (list == null || list.size() == 0) {
|
2022-10-31 14:50:54 +08:00
|
|
|
|
throw new SalaryRunTimeException("该数据不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
String taxAgentName = list.get(0).getTaxAgentName();
|
2022-11-16 11:08:45 +08:00
|
|
|
|
if (!taxAgentNames.contains(taxAgentName)) {
|
2022-10-31 14:50:54 +08:00
|
|
|
|
throw new SalaryRunTimeException("您无权查看该数据!");
|
|
|
|
|
|
}
|
|
|
|
|
|
return list.get(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-16 11:08:45 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public String extendToLastMonth(OtherDeductionExtendLastParam param) {
|
2022-11-17 14:54:13 +08:00
|
|
|
|
//查询已经核算的数据
|
2025-01-21 15:03:36 +08:00
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeDataByTaxYearMonth(param.getDeclareMonth());
|
2022-11-17 15:13:24 +08:00
|
|
|
|
Map<String, List<SalaryAcctEmployeePO>> acctInfoMap = salaryAcctEmployees.stream()
|
|
|
|
|
|
.distinct().collect(Collectors.groupingBy(
|
|
|
|
|
|
i -> i.getTaxAgentId() + "" + i.getEmployeeId()));
|
2022-11-17 14:54:13 +08:00
|
|
|
|
|
2022-11-16 11:08:45 +08:00
|
|
|
|
// 查找到所有个税扣缴义务人
|
|
|
|
|
|
Boolean needAuth = getTaxAgentService(user).isNeedAuth((long) user.getUID());
|
|
|
|
|
|
Collection<TaxAgentPO> taxAgentPOS;
|
|
|
|
|
|
if (needAuth) {
|
|
|
|
|
|
taxAgentPOS = getTaxAgentService(user).listAllTaxAgentsAsAdmin((long) user.getUID());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
taxAgentPOS = getTaxAgentService(user).listAll();
|
|
|
|
|
|
}
|
|
|
|
|
|
List<Long> taxAgentIds = taxAgentPOS.stream().map(TaxAgentPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
//查询上月数据
|
|
|
|
|
|
LocalDateTime lastMonth = param.getYearMonthTime().minusMonths(1);
|
|
|
|
|
|
OtherDeductionQueryParam queryParam = OtherDeductionQueryParam.builder()
|
|
|
|
|
|
.taxAgentIds(taxAgentIds)
|
|
|
|
|
|
.declareMonthDate(Collections.singletonList(
|
|
|
|
|
|
SalaryDateUtil.toDate(lastMonth))
|
|
|
|
|
|
).build();
|
|
|
|
|
|
List<OtherDeductionListDTO> lastMonthInfo = getOtherDeductionMapper().list(queryParam);
|
|
|
|
|
|
|
|
|
|
|
|
// 查询当前月id
|
|
|
|
|
|
queryParam.setDeclareMonthDate(Collections.singletonList(
|
|
|
|
|
|
SalaryDateUtil.toDate(param.getYearMonthTime())
|
|
|
|
|
|
));
|
|
|
|
|
|
Map<String, Long> updateIdMap = getOtherDeductionMapper()
|
|
|
|
|
|
.list(queryParam).stream()
|
2022-11-17 14:54:13 +08:00
|
|
|
|
.collect(Collectors.toMap(i -> i.getEmployeeId() + "" + i.getTaxAgentId(), OtherDeductionListDTO::getId));
|
2022-11-16 11:08:45 +08:00
|
|
|
|
|
|
|
|
|
|
List<OtherDeductionPO> insertInfo = new ArrayList<>();
|
|
|
|
|
|
List<OtherDeductionPO> updatetInfo = new ArrayList<>();
|
|
|
|
|
|
for (OtherDeductionListDTO dto : lastMonthInfo) {
|
|
|
|
|
|
OtherDeductionPO po
|
|
|
|
|
|
= JSONObject.parseObject(JSONObject.toJSONString(dto), OtherDeductionPO.class);
|
|
|
|
|
|
po.setDeclareMonth(SalaryDateUtil.toDate(param.getYearMonthTime()));
|
|
|
|
|
|
po.setUpdateTime(new Date());
|
|
|
|
|
|
po.setId(null);
|
|
|
|
|
|
po.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
|
|
|
|
|
|
boolean hasOld = updateIdMap.containsKey(po.getEmployeeId() + "" + po.getTaxAgentId());
|
2022-11-17 15:39:16 +08:00
|
|
|
|
if (hasOld && !acctInfoMap.containsKey(po.getTaxAgentId() + "" + po.getEmployeeId())) {
|
2022-11-17 14:54:13 +08:00
|
|
|
|
//核算过的数据直接跳过不做更改
|
2022-11-16 11:08:45 +08:00
|
|
|
|
po.setId(updateIdMap.get(po.getEmployeeId() + "" + po.getTaxAgentId()));
|
|
|
|
|
|
updatetInfo.add(po);
|
2022-11-17 15:13:24 +08:00
|
|
|
|
} else if (!hasOld) {
|
2022-11-16 11:08:45 +08:00
|
|
|
|
po.setCreator((long) user.getUID());
|
|
|
|
|
|
po.setCreateTime(new Date());
|
|
|
|
|
|
insertInfo.add(po);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-17 15:39:16 +08:00
|
|
|
|
getOtherDeductionBiz().batchSave(insertInfo);
|
|
|
|
|
|
getOtherDeductionBiz().batchUpdate(updatetInfo);
|
2024-02-21 18:19:02 +08:00
|
|
|
|
|
|
|
|
|
|
//记录日志
|
|
|
|
|
|
// 根据月份、人员id查出保存的数据
|
|
|
|
|
|
List<Long> empIds = insertInfo.stream().map(OtherDeductionPO::getEmployeeId).collect(Collectors.toList());
|
|
|
|
|
|
List<OtherDeductionPO> insertList = getOtherDeductionBiz().listSome(OtherDeductionPO.builder().declareMonth(SalaryDateUtil.stringToDate(param.getDeclareMonth())).employeeIds(empIds).build());
|
|
|
|
|
|
Map<String, OtherDeductionPO> insertMap = SalaryEntityUtil.convert2Map(insertList, p -> p.getTaxAgentId() + "-" + SalaryDateUtil.getFormatYearMonth(p.getDeclareMonth()) + "-" + p.getEmployeeId());
|
|
|
|
|
|
insertList.forEach(save -> {
|
|
|
|
|
|
OtherDeductionPO otherDeductionPO = insertMap.get(save.getTaxAgentId() + "-" + SalaryDateUtil.getFormatYearMonth(save.getDeclareMonth()) + "-" + save.getEmployeeId());
|
|
|
|
|
|
if (otherDeductionPO != null) {
|
|
|
|
|
|
updatetInfo.add(otherDeductionPO);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(updatetInfo)) {
|
2024-03-14 15:28:14 +08:00
|
|
|
|
String yearMonthStr = SalaryDateUtil.getFormatYearMonth(lastMonth.toLocalDate());
|
2024-02-21 18:19:02 +08:00
|
|
|
|
LoggerContext loggerContext = new LoggerContext();
|
|
|
|
|
|
loggerContext.setUser(user);
|
2024-03-14 15:28:14 +08:00
|
|
|
|
loggerContext.setTargetName(SalaryI18nUtil.getI18nLabel(0, "沿用上月 " + yearMonthStr));
|
2024-02-21 18:19:02 +08:00
|
|
|
|
loggerContext.setOperateType(OperateTypeEnum.ADD.getValue());
|
|
|
|
|
|
loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "沿用上月其他免税扣除"));
|
2024-03-14 15:28:14 +08:00
|
|
|
|
loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "沿用上月 " + yearMonthStr + " 其他免税扣除"));
|
2024-02-21 18:19:02 +08:00
|
|
|
|
loggerContext.setNewValueList(updatetInfo);
|
|
|
|
|
|
SalaryElogConfig.otherDeductionLoggerTemplate.write(loggerContext);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-16 11:08:45 +08:00
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-04-28 17:44:26 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public XSSFWorkbook downloadTemplate(OtherDeductionQueryParam param) {
|
|
|
|
|
|
// 1.工作簿名称
|
2022-05-31 09:58:35 +08:00
|
|
|
|
String sheetName = SalaryI18nUtil.getI18nLabel(101604, "其他免税扣除导入模板");
|
2024-03-14 15:28:14 +08:00
|
|
|
|
//获取操作按钮资源
|
2024-03-14 18:16:20 +08:00
|
|
|
|
List<List<Object>> rowList = getExcelRowList(param, param.isHasData());
|
2022-04-28 17:44:26 +08:00
|
|
|
|
|
|
|
|
|
|
// 4.注释
|
|
|
|
|
|
List<ExcelComment> excelComments = Lists.newArrayList();
|
|
|
|
|
|
excelComments.add(new ExcelComment(0, 0, 3, 2, SalaryI18nUtil.getI18nLabel(100344, "必填")));
|
|
|
|
|
|
excelComments.add(new ExcelComment(1, 0, 4, 2, SalaryI18nUtil.getI18nLabel(100344, "必填")));
|
|
|
|
|
|
excelComments.add(new ExcelComment(7, 0, 10, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字")));
|
|
|
|
|
|
excelComments.add(new ExcelComment(8, 0, 11, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字")));
|
|
|
|
|
|
excelComments.add(new ExcelComment(9, 0, 12, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字")));
|
|
|
|
|
|
excelComments.add(new ExcelComment(10, 0, 13, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字")));
|
2024-03-14 15:28:14 +08:00
|
|
|
|
excelComments.add(new ExcelComment(11, 0, 14, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字")));
|
2022-04-28 17:44:26 +08:00
|
|
|
|
|
2024-03-14 15:28:14 +08:00
|
|
|
|
XSSFWorkbook book = ExcelUtil.genWorkbookV2(rowList, sheetName, excelComments);
|
2022-04-28 17:44:26 +08:00
|
|
|
|
return book;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-19 09:53:56 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public XSSFWorkbook downloadDetailTemplate(OtherDeductionQueryParam param) {
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-16 13:41:17 +08:00
|
|
|
|
List<FreeIncomeListDTO> freeIncomeList = new ArrayList<>();
|
|
|
|
|
|
List<HealthInsuranceListDTO> healthInsuranceList = new ArrayList<>();
|
|
|
|
|
|
List<EndowmentInsuranceListDTO> endowmentInsuranceList = new ArrayList<>();
|
|
|
|
|
|
List<GrantDonationListDTO> grantDonationList = new ArrayList<>();
|
|
|
|
|
|
List<DerateDeductionListDTO> derateDeductionList = new ArrayList<>();
|
|
|
|
|
|
List<OtherDerateDeductionListDTO> otherDerateDeductionList = new ArrayList<>();
|
|
|
|
|
|
List<PersonalPensionListDTO> personalPensionList = new ArrayList<>();
|
2025-01-15 16:11:34 +08:00
|
|
|
|
if (param.isHasData()) {
|
2025-01-16 13:41:17 +08:00
|
|
|
|
long employeeId = user.getUID();
|
2025-01-15 16:11:34 +08:00
|
|
|
|
//排序配置
|
|
|
|
|
|
OrderRuleVO orderRule = getSalarySysConfService(user).orderRule();
|
|
|
|
|
|
param.setOrderRule(orderRule);
|
|
|
|
|
|
|
|
|
|
|
|
List<OtherDeductionListDTO> list = getOtherDeductionMapper().list(param);
|
|
|
|
|
|
encryptUtil.decryptList(list, OtherDeductionListDTO.class);
|
|
|
|
|
|
SalaryI18nUtil.i18nList(list);
|
|
|
|
|
|
// 开启分权并且不是薪酬模块总管理员
|
|
|
|
|
|
if (getTaxAgentService(user).isOpenDevolution() && !getTaxAgentService(user).isChief(employeeId)) {
|
|
|
|
|
|
List<Long> taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
list = list.stream().filter(f ->
|
|
|
|
|
|
// 作为管理员
|
|
|
|
|
|
taxAgentIdsAsAdmin.contains(f.getTaxAgentId())
|
|
|
|
|
|
).collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
list.forEach(dto -> {
|
2025-01-16 13:41:17 +08:00
|
|
|
|
List<FreeIncomeListDTO> freeIncomeListDTOS = freeIncomePO2DTO(getFreeIncomeMapper().listSome(FreeIncomePO.builder().mainId(dto.getId()).build()));
|
|
|
|
|
|
freeIncomeList.addAll(freeIncomeListDTOS);
|
|
|
|
|
|
List<EndowmentInsuranceListDTO> endowmentInsuranceListDTOS = endowmentInsurancePO2DTO(getEndowmentInsuranceMapper().listSome(EndowmentInsurancePO.builder().mainId(dto.getId()).build()));
|
|
|
|
|
|
endowmentInsuranceList.addAll(endowmentInsuranceListDTOS);
|
|
|
|
|
|
List<GrantDonationListDTO> grantDonationListDTOS = grantDonationPO2DTO(getGrantDonationMapper().listSome(GrantDonationPO.builder().mainId(dto.getId()).build()));
|
|
|
|
|
|
grantDonationList.addAll(grantDonationListDTOS);
|
|
|
|
|
|
List<HealthInsuranceListDTO> healthInsuranceListDTOS = healthInsurancePO2DTO(getHealthInsuranceMapper().listSome(HealthInsurancePO.builder().mainId(dto.getId()).build()));
|
|
|
|
|
|
healthInsuranceList.addAll(healthInsuranceListDTOS);
|
|
|
|
|
|
List<OtherDerateDeductionListDTO> otherDerateDeductionListDTOS = otherDerateDeductionPO2DTO(getOtherDerateDeductionMapper().listSome(OtherDerateDeductionPO.builder().mainId(dto.getId()).build()));
|
|
|
|
|
|
otherDerateDeductionList.addAll(otherDerateDeductionListDTOS);
|
|
|
|
|
|
List<DerateDeductionListDTO> derateDeductionListDTOS = derateDeductionPO2DTO(getDerateDeductionMapper().listSome(DerateDeductionPO.builder().mainId(dto.getId()).build()));
|
|
|
|
|
|
derateDeductionList.addAll(derateDeductionListDTOS);
|
|
|
|
|
|
List<PersonalPensionListDTO> personalPensionListDTOS = personalPensionPO2DTO(getPersonalPensionMapper().listSome(PersonalPensionPO.builder().mainId(dto.getId()).build()));
|
|
|
|
|
|
personalPensionList.addAll(personalPensionListDTOS);
|
2025-01-15 16:11:34 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-19 09:53:56 +08:00
|
|
|
|
Map<String, List<List<Object>>> map = new LinkedHashMap<>();
|
|
|
|
|
|
|
2025-01-15 16:11:34 +08:00
|
|
|
|
List<List<Object>> freeIncomeRowList = new ArrayList<>();
|
2025-07-02 15:46:32 +08:00
|
|
|
|
List<Object> freeIncomeTitle = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "所得项目", "免税事项", "免税性质", "免税金额");
|
2025-01-16 13:41:17 +08:00
|
|
|
|
freeIncomeRowList.add(freeIncomeTitle);
|
|
|
|
|
|
freeIncomeList.forEach(dto -> {
|
2025-01-15 16:11:34 +08:00
|
|
|
|
List<Object> row = new ArrayList<>();
|
2025-01-16 13:41:17 +08:00
|
|
|
|
row.add(dto.getUsername());
|
|
|
|
|
|
row.add(dto.getTaxAgentName());
|
|
|
|
|
|
row.add(dto.getDepartmentName());
|
|
|
|
|
|
row.add(dto.getMobile());
|
|
|
|
|
|
row.add(dto.getJobNum());
|
|
|
|
|
|
row.add(dto.getIdNo());
|
2025-07-02 15:46:32 +08:00
|
|
|
|
row.add(dto.getIncomeCategoryName());
|
2025-01-16 13:41:17 +08:00
|
|
|
|
row.add(dto.getFreeItem());
|
|
|
|
|
|
row.add(dto.getFreeProperty());
|
|
|
|
|
|
row.add(dto.getFreeAmount());
|
|
|
|
|
|
freeIncomeRowList.add(row);
|
2025-01-15 16:11:34 +08:00
|
|
|
|
});
|
2025-01-16 13:41:17 +08:00
|
|
|
|
map.put("免税收入", freeIncomeRowList);
|
|
|
|
|
|
|
|
|
|
|
|
List<List<Object>> healthInsuranceRowList = new ArrayList<>();
|
2025-07-02 15:46:32 +08:00
|
|
|
|
List<Object> healthInsuranceTitle = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "所得项目", "税优识别码", "保单生效日期", "年度保费", "月度保费", "本期扣除金额");
|
2025-01-16 13:41:17 +08:00
|
|
|
|
healthInsuranceRowList.add(healthInsuranceTitle);
|
|
|
|
|
|
healthInsuranceList.forEach(dto -> {
|
|
|
|
|
|
List<Object> row = new ArrayList<>();
|
|
|
|
|
|
row.add(dto.getUsername());
|
|
|
|
|
|
row.add(dto.getTaxAgentName());
|
|
|
|
|
|
row.add(dto.getDepartmentName());
|
|
|
|
|
|
row.add(dto.getMobile());
|
|
|
|
|
|
row.add(dto.getJobNum());
|
|
|
|
|
|
row.add(dto.getIdNo());
|
2025-07-02 15:46:32 +08:00
|
|
|
|
row.add(dto.getIncomeCategoryName());
|
2025-01-16 13:41:17 +08:00
|
|
|
|
row.add(dto.getIdentificationNumber());
|
|
|
|
|
|
row.add(dto.getEffectiveDate());
|
|
|
|
|
|
row.add(dto.getYearPremium());
|
|
|
|
|
|
row.add(dto.getMonthPremium());
|
|
|
|
|
|
row.add(dto.getCurrentDeduction());
|
|
|
|
|
|
healthInsuranceRowList.add(row);
|
|
|
|
|
|
});
|
|
|
|
|
|
map.put("商业健康保险", healthInsuranceRowList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<List<Object>> endowmentInsuranceRowList = new ArrayList<>();
|
2025-07-02 15:46:32 +08:00
|
|
|
|
List<Object> endowmentInsuranceTitle = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "所得项目","申报扣除月份", "税延养老账户编号", "报税校验码", "年度保费", "月度保费", "本期扣除金额");
|
2025-01-16 13:41:17 +08:00
|
|
|
|
endowmentInsuranceRowList.add(endowmentInsuranceTitle);
|
|
|
|
|
|
endowmentInsuranceList.forEach(dto -> {
|
|
|
|
|
|
List<Object> row = new ArrayList<>();
|
|
|
|
|
|
row.add(dto.getUsername());
|
|
|
|
|
|
row.add(dto.getTaxAgentName());
|
|
|
|
|
|
row.add(dto.getDepartmentName());
|
|
|
|
|
|
row.add(dto.getMobile());
|
|
|
|
|
|
row.add(dto.getJobNum());
|
|
|
|
|
|
row.add(dto.getIdNo());
|
2025-07-02 15:46:32 +08:00
|
|
|
|
row.add(dto.getIncomeCategoryName());
|
|
|
|
|
|
row.add(dto.getDeductionMonth());
|
2025-01-16 13:41:17 +08:00
|
|
|
|
row.add(dto.getAccountNumber());
|
|
|
|
|
|
row.add(dto.getCheckCode());
|
|
|
|
|
|
row.add(dto.getYearPremium());
|
|
|
|
|
|
row.add(dto.getMonthPremium());
|
|
|
|
|
|
row.add(dto.getCurrentDeduction());
|
|
|
|
|
|
endowmentInsuranceRowList.add(row);
|
|
|
|
|
|
});
|
|
|
|
|
|
map.put("税延养老保险", endowmentInsuranceRowList);
|
|
|
|
|
|
|
|
|
|
|
|
List<List<Object>> grantDonationRowList = new ArrayList<>();
|
2025-07-02 15:46:32 +08:00
|
|
|
|
List<Object> grantDonationTitle = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "所得项目", "受赠单位名称", "受赠单位纳税人识别号", "凭证号", "捐赠日期", "捐赠金额", "扣除比例", "实际扣除金额");
|
2025-01-16 13:41:17 +08:00
|
|
|
|
grantDonationRowList.add(grantDonationTitle);
|
|
|
|
|
|
grantDonationList.forEach(dto -> {
|
|
|
|
|
|
List<Object> row = new ArrayList<>();
|
|
|
|
|
|
row.add(dto.getUsername());
|
|
|
|
|
|
row.add(dto.getTaxAgentName());
|
|
|
|
|
|
row.add(dto.getDepartmentName());
|
|
|
|
|
|
row.add(dto.getMobile());
|
|
|
|
|
|
row.add(dto.getJobNum());
|
|
|
|
|
|
row.add(dto.getIdNo());
|
2025-07-02 15:46:32 +08:00
|
|
|
|
row.add(dto.getIncomeCategoryName());
|
2025-01-16 13:41:17 +08:00
|
|
|
|
row.add(dto.getRecipientName());
|
|
|
|
|
|
row.add(dto.getTaxCode());
|
|
|
|
|
|
row.add(dto.getDonationNumber());
|
|
|
|
|
|
row.add(dto.getDonateDate());
|
|
|
|
|
|
row.add(dto.getDonateAmount());
|
|
|
|
|
|
row.add(dto.getDeductionProportion());
|
|
|
|
|
|
row.add(dto.getActualDeduction());
|
|
|
|
|
|
grantDonationRowList.add(row);
|
|
|
|
|
|
});
|
|
|
|
|
|
map.put("准予扣除的捐赠额", grantDonationRowList);
|
|
|
|
|
|
|
|
|
|
|
|
List<List<Object>> derateDeductionRowList = new ArrayList<>();
|
2025-07-02 15:46:32 +08:00
|
|
|
|
List<Object> derateDeductionTitle = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "所得项目", "减免事项", "减免性质", "减免金额");
|
2025-01-16 13:41:17 +08:00
|
|
|
|
derateDeductionRowList.add(derateDeductionTitle);
|
|
|
|
|
|
derateDeductionList.forEach(dto -> {
|
|
|
|
|
|
List<Object> row = new ArrayList<>();
|
|
|
|
|
|
row.add(dto.getUsername());
|
|
|
|
|
|
row.add(dto.getTaxAgentName());
|
|
|
|
|
|
row.add(dto.getDepartmentName());
|
|
|
|
|
|
row.add(dto.getMobile());
|
|
|
|
|
|
row.add(dto.getJobNum());
|
|
|
|
|
|
row.add(dto.getIdNo());
|
2025-07-02 15:46:32 +08:00
|
|
|
|
row.add(dto.getIncomeCategoryName());
|
2025-01-16 13:41:17 +08:00
|
|
|
|
row.add(dto.getDerateItem());
|
|
|
|
|
|
row.add(dto.getDerateProperty());
|
|
|
|
|
|
row.add(dto.getDerateAmount());
|
|
|
|
|
|
derateDeductionRowList.add(row);
|
|
|
|
|
|
});
|
|
|
|
|
|
map.put("减免税额", derateDeductionRowList);
|
|
|
|
|
|
|
|
|
|
|
|
List<List<Object>> otherDerateDeductionRowList = new ArrayList<>();
|
2025-07-02 15:46:32 +08:00
|
|
|
|
List<Object> otherDerateDeductionTitle = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "所得项目", "其他免税扣除金额", "备注");
|
2025-01-16 13:41:17 +08:00
|
|
|
|
otherDerateDeductionRowList.add(otherDerateDeductionTitle);
|
|
|
|
|
|
otherDerateDeductionList.forEach(dto -> {
|
|
|
|
|
|
List<Object> row = new ArrayList<>();
|
|
|
|
|
|
row.add(dto.getUsername());
|
|
|
|
|
|
row.add(dto.getTaxAgentName());
|
|
|
|
|
|
row.add(dto.getDepartmentName());
|
|
|
|
|
|
row.add(dto.getMobile());
|
|
|
|
|
|
row.add(dto.getJobNum());
|
|
|
|
|
|
row.add(dto.getIdNo());
|
2025-07-02 15:46:32 +08:00
|
|
|
|
row.add(dto.getIncomeCategoryName());
|
2025-01-16 13:41:17 +08:00
|
|
|
|
row.add(dto.getOtherDeduction());
|
|
|
|
|
|
row.add(dto.getRemark());
|
|
|
|
|
|
otherDerateDeductionRowList.add(row);
|
|
|
|
|
|
});
|
|
|
|
|
|
map.put("其他", otherDerateDeductionRowList);
|
2024-12-19 09:53:56 +08:00
|
|
|
|
|
2025-01-16 13:41:17 +08:00
|
|
|
|
List<List<Object>> personalPensionRowList = new ArrayList<>();
|
2025-07-02 15:46:32 +08:00
|
|
|
|
List<Object> personalPensionTitle = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "所得项目", "凭证类型", "凭证编码", "缴费金额");
|
2025-01-16 13:41:17 +08:00
|
|
|
|
personalPensionRowList.add(personalPensionTitle);
|
|
|
|
|
|
personalPensionList.forEach(dto -> {
|
|
|
|
|
|
List<Object> row = new ArrayList<>();
|
|
|
|
|
|
row.add(dto.getUsername());
|
|
|
|
|
|
row.add(dto.getTaxAgentName());
|
|
|
|
|
|
row.add(dto.getDepartmentName());
|
|
|
|
|
|
row.add(dto.getMobile());
|
|
|
|
|
|
row.add(dto.getJobNum());
|
|
|
|
|
|
row.add(dto.getIdNo());
|
2025-07-02 15:46:32 +08:00
|
|
|
|
row.add(dto.getIncomeCategoryName());
|
2025-01-16 13:41:17 +08:00
|
|
|
|
row.add(dto.getVoucherTypeName());
|
|
|
|
|
|
row.add(dto.getVoucherNo());
|
|
|
|
|
|
row.add(dto.getPayAmount());
|
|
|
|
|
|
personalPensionRowList.add(row);
|
|
|
|
|
|
});
|
|
|
|
|
|
map.put("个人养老金", personalPensionRowList);
|
2024-12-19 09:53:56 +08:00
|
|
|
|
|
|
|
|
|
|
XSSFWorkbook book = ExcelUtil.genWorkbookV2(map);
|
|
|
|
|
|
return book;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-24 15:52:36 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public PageInfo<FreeIncomeListDTO> freeIncomeList(OtherDeductionDetailQueryParam param) {
|
|
|
|
|
|
|
2025-01-03 17:38:47 +08:00
|
|
|
|
FreeIncomePO build;
|
|
|
|
|
|
if (param.getId() != null) {
|
|
|
|
|
|
build = FreeIncomePO.builder().mainId(param.getId()).build();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
build = FreeIncomePO.builder().taxAgentId(param.getTaxAgentId()).taxYearMonth(param.getTaxCycle()).employeeId(param.getEmployeeId()).build();
|
|
|
|
|
|
}
|
|
|
|
|
|
List<FreeIncomePO> pos = getFreeIncomeMapper().listSome(build);
|
|
|
|
|
|
|
2025-01-16 13:41:17 +08:00
|
|
|
|
List<FreeIncomeListDTO> listDTOS = freeIncomePO2DTO(pos);
|
|
|
|
|
|
return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), listDTOS, FreeIncomeListDTO.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@NotNull
|
|
|
|
|
|
private List<FreeIncomeListDTO> freeIncomePO2DTO(List<FreeIncomePO> pos) {
|
2024-12-25 10:36:37 +08:00
|
|
|
|
List<Long> empIds = SalaryEntityUtil.properties(pos, FreeIncomePO::getEmployeeId, Collectors.toList());
|
|
|
|
|
|
List<DataCollectionEmployee> employeeList = getSalaryEmployeeService(user).listByIds(empIds);
|
|
|
|
|
|
Map<Long, DataCollectionEmployee> employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId);
|
|
|
|
|
|
List<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAll();
|
|
|
|
|
|
Map<Long, TaxAgentPO> taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId);
|
|
|
|
|
|
List<FreeIncomeListDTO> listDTOS = pos.stream().map(po -> {
|
|
|
|
|
|
FreeIncomeListDTO dto = new FreeIncomeListDTO();
|
|
|
|
|
|
BeanUtils.copyProperties(po, dto);
|
|
|
|
|
|
DataCollectionEmployee employee = employeeMap.getOrDefault(po.getEmployeeId(), new DataCollectionEmployee());
|
|
|
|
|
|
TaxAgentPO taxAgent = taxAgentMap.getOrDefault(po.getTaxAgentId(), new TaxAgentPO());
|
|
|
|
|
|
dto.setUsername(employee.getUsername());
|
|
|
|
|
|
dto.setTaxAgentName(taxAgent.getName());
|
|
|
|
|
|
dto.setDepartmentName(employee.getDepartmentName());
|
|
|
|
|
|
dto.setMobile(employee.getMobile());
|
|
|
|
|
|
dto.setJobNum(employee.getWorkcode());
|
|
|
|
|
|
dto.setIdNo(employee.getIdNo());
|
2025-07-01 18:37:50 +08:00
|
|
|
|
dto.setIncomeCategoryName(IncomeCategoryEnum.parseByValue(po.getIncomeCategory()).getDefaultLabel());
|
2024-12-25 10:36:37 +08:00
|
|
|
|
return dto;
|
2024-12-24 15:52:36 +08:00
|
|
|
|
}).collect(Collectors.toList());
|
2025-01-16 13:41:17 +08:00
|
|
|
|
return listDTOS;
|
2024-12-24 15:52:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2024-12-25 10:36:37 +08:00
|
|
|
|
public PageInfo<DerateDeductionListDTO> derateDeductionList(OtherDeductionDetailQueryParam param) {
|
2025-01-03 17:38:47 +08:00
|
|
|
|
DerateDeductionPO build;
|
|
|
|
|
|
if (param.getId() != null) {
|
|
|
|
|
|
build = DerateDeductionPO.builder().mainId(param.getId()).build();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
build = DerateDeductionPO.builder().taxAgentId(param.getTaxAgentId()).taxYearMonth(param.getTaxCycle()).employeeId(param.getEmployeeId()).build();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<DerateDeductionPO> pos = getDerateDeductionMapper().listSome(build);
|
2025-01-16 13:41:17 +08:00
|
|
|
|
List<DerateDeductionListDTO> listDTOS = derateDeductionPO2DTO(pos);
|
|
|
|
|
|
return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), listDTOS, DerateDeductionListDTO.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<DerateDeductionListDTO> derateDeductionPO2DTO(List<DerateDeductionPO> pos) {
|
2024-12-25 10:36:37 +08:00
|
|
|
|
List<Long> empIds = SalaryEntityUtil.properties(pos, DerateDeductionPO::getEmployeeId, Collectors.toList());
|
|
|
|
|
|
List<DataCollectionEmployee> employeeList = getSalaryEmployeeService(user).listByIds(empIds);
|
|
|
|
|
|
Map<Long, DataCollectionEmployee> employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId);
|
|
|
|
|
|
List<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAll();
|
|
|
|
|
|
Map<Long, TaxAgentPO> taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId);
|
2024-12-24 15:52:36 +08:00
|
|
|
|
List<DerateDeductionListDTO> listDTOS = pos.stream().map(po -> {
|
2024-12-25 10:36:37 +08:00
|
|
|
|
DerateDeductionListDTO dto = new DerateDeductionListDTO();
|
|
|
|
|
|
BeanUtils.copyProperties(po, dto);
|
|
|
|
|
|
DataCollectionEmployee employee = employeeMap.getOrDefault(po.getEmployeeId(), new DataCollectionEmployee());
|
|
|
|
|
|
TaxAgentPO taxAgent = taxAgentMap.getOrDefault(po.getTaxAgentId(), new TaxAgentPO());
|
|
|
|
|
|
dto.setUsername(employee.getUsername());
|
|
|
|
|
|
dto.setTaxAgentName(taxAgent.getName());
|
|
|
|
|
|
dto.setDepartmentName(employee.getDepartmentName());
|
|
|
|
|
|
dto.setMobile(employee.getMobile());
|
|
|
|
|
|
dto.setJobNum(employee.getWorkcode());
|
|
|
|
|
|
dto.setIdNo(employee.getIdNo());
|
|
|
|
|
|
return dto;
|
2024-12-24 15:52:36 +08:00
|
|
|
|
}).collect(Collectors.toList());
|
2025-01-16 13:41:17 +08:00
|
|
|
|
return listDTOS;
|
2024-12-24 15:52:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2024-12-25 10:36:37 +08:00
|
|
|
|
public PageInfo<EndowmentInsuranceListDTO> endowmentInsuranceList(OtherDeductionDetailQueryParam param) {
|
2025-01-03 17:38:47 +08:00
|
|
|
|
EndowmentInsurancePO build;
|
|
|
|
|
|
if (param.getId() != null) {
|
|
|
|
|
|
build = EndowmentInsurancePO.builder().mainId(param.getId()).build();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
build = EndowmentInsurancePO.builder().taxAgentId(param.getTaxAgentId()).taxYearMonth(param.getTaxCycle()).employeeId(param.getEmployeeId()).build();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<EndowmentInsurancePO> pos = getEndowmentInsuranceMapper().listSome(build);
|
2025-01-16 13:41:17 +08:00
|
|
|
|
|
|
|
|
|
|
List<EndowmentInsuranceListDTO> listDTOS = endowmentInsurancePO2DTO(pos);
|
|
|
|
|
|
return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), listDTOS, EndowmentInsuranceListDTO.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@NotNull
|
|
|
|
|
|
private List<EndowmentInsuranceListDTO> endowmentInsurancePO2DTO(List<EndowmentInsurancePO> pos) {
|
2024-12-25 10:36:37 +08:00
|
|
|
|
List<Long> empIds = SalaryEntityUtil.properties(pos, EndowmentInsurancePO::getEmployeeId, Collectors.toList());
|
|
|
|
|
|
List<DataCollectionEmployee> employeeList = getSalaryEmployeeService(user).listByIds(empIds);
|
|
|
|
|
|
Map<Long, DataCollectionEmployee> employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId);
|
|
|
|
|
|
List<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAll();
|
|
|
|
|
|
Map<Long, TaxAgentPO> taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId);
|
2024-12-24 15:52:36 +08:00
|
|
|
|
List<EndowmentInsuranceListDTO> listDTOS = pos.stream().map(po -> {
|
2024-12-25 10:36:37 +08:00
|
|
|
|
EndowmentInsuranceListDTO dto = new EndowmentInsuranceListDTO();
|
|
|
|
|
|
BeanUtils.copyProperties(po, dto);
|
|
|
|
|
|
DataCollectionEmployee employee = employeeMap.getOrDefault(po.getEmployeeId(), new DataCollectionEmployee());
|
|
|
|
|
|
TaxAgentPO taxAgent = taxAgentMap.getOrDefault(po.getTaxAgentId(), new TaxAgentPO());
|
|
|
|
|
|
dto.setUsername(employee.getUsername());
|
|
|
|
|
|
dto.setTaxAgentName(taxAgent.getName());
|
|
|
|
|
|
dto.setDepartmentName(employee.getDepartmentName());
|
|
|
|
|
|
dto.setMobile(employee.getMobile());
|
|
|
|
|
|
dto.setJobNum(employee.getWorkcode());
|
|
|
|
|
|
dto.setIdNo(employee.getIdNo());
|
|
|
|
|
|
return dto;
|
2024-12-24 15:52:36 +08:00
|
|
|
|
}).collect(Collectors.toList());
|
2025-01-16 13:41:17 +08:00
|
|
|
|
return listDTOS;
|
2024-12-24 15:52:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2024-12-25 10:36:37 +08:00
|
|
|
|
public PageInfo<GrantDonationListDTO> grantDonationList(OtherDeductionDetailQueryParam param) {
|
2025-01-03 17:38:47 +08:00
|
|
|
|
GrantDonationPO build;
|
|
|
|
|
|
if (param.getId() != null) {
|
|
|
|
|
|
build = GrantDonationPO.builder().mainId(param.getId()).build();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
build = GrantDonationPO.builder().taxAgentId(param.getTaxAgentId()).taxYearMonth(param.getTaxCycle()).employeeId(param.getEmployeeId()).build();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<GrantDonationPO> pos = getGrantDonationMapper().listSome(build);
|
2025-01-16 13:41:17 +08:00
|
|
|
|
List<GrantDonationListDTO> listDTOS = grantDonationPO2DTO(pos);
|
|
|
|
|
|
return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), listDTOS, GrantDonationListDTO.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@NotNull
|
|
|
|
|
|
private List<GrantDonationListDTO> grantDonationPO2DTO(List<GrantDonationPO> pos) {
|
2024-12-25 10:36:37 +08:00
|
|
|
|
List<Long> empIds = SalaryEntityUtil.properties(pos, GrantDonationPO::getEmployeeId, Collectors.toList());
|
|
|
|
|
|
List<DataCollectionEmployee> employeeList = getSalaryEmployeeService(user).listByIds(empIds);
|
|
|
|
|
|
Map<Long, DataCollectionEmployee> employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId);
|
|
|
|
|
|
List<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAll();
|
|
|
|
|
|
Map<Long, TaxAgentPO> taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId);
|
2024-12-24 15:52:36 +08:00
|
|
|
|
List<GrantDonationListDTO> listDTOS = pos.stream().map(po -> {
|
2024-12-25 10:36:37 +08:00
|
|
|
|
GrantDonationListDTO dto = new GrantDonationListDTO();
|
|
|
|
|
|
BeanUtils.copyProperties(po, dto);
|
|
|
|
|
|
DataCollectionEmployee employee = employeeMap.getOrDefault(po.getEmployeeId(), new DataCollectionEmployee());
|
|
|
|
|
|
TaxAgentPO taxAgent = taxAgentMap.getOrDefault(po.getTaxAgentId(), new TaxAgentPO());
|
|
|
|
|
|
dto.setUsername(employee.getUsername());
|
|
|
|
|
|
dto.setTaxAgentName(taxAgent.getName());
|
|
|
|
|
|
dto.setDepartmentName(employee.getDepartmentName());
|
|
|
|
|
|
dto.setMobile(employee.getMobile());
|
|
|
|
|
|
dto.setJobNum(employee.getWorkcode());
|
|
|
|
|
|
dto.setIdNo(employee.getIdNo());
|
|
|
|
|
|
return dto;
|
2024-12-24 15:52:36 +08:00
|
|
|
|
}).collect(Collectors.toList());
|
2025-01-16 13:41:17 +08:00
|
|
|
|
return listDTOS;
|
2024-12-24 15:52:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2024-12-25 10:36:37 +08:00
|
|
|
|
public PageInfo<HealthInsuranceListDTO> healthInsuranceList(OtherDeductionDetailQueryParam param) {
|
2025-01-03 17:38:47 +08:00
|
|
|
|
HealthInsurancePO build;
|
|
|
|
|
|
if (param.getId() != null) {
|
|
|
|
|
|
build = HealthInsurancePO.builder().mainId(param.getId()).build();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
build = HealthInsurancePO.builder().taxAgentId(param.getTaxAgentId()).taxYearMonth(param.getTaxCycle()).employeeId(param.getEmployeeId()).build();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<HealthInsurancePO> pos = getHealthInsuranceMapper().listSome(build);
|
2025-01-16 13:41:17 +08:00
|
|
|
|
List<HealthInsuranceListDTO> listDTOS = healthInsurancePO2DTO(pos);
|
|
|
|
|
|
return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), listDTOS, HealthInsuranceListDTO.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@NotNull
|
|
|
|
|
|
private List<HealthInsuranceListDTO> healthInsurancePO2DTO(List<HealthInsurancePO> pos) {
|
2024-12-25 10:36:37 +08:00
|
|
|
|
List<Long> empIds = SalaryEntityUtil.properties(pos, HealthInsurancePO::getEmployeeId, Collectors.toList());
|
|
|
|
|
|
List<DataCollectionEmployee> employeeList = getSalaryEmployeeService(user).listByIds(empIds);
|
|
|
|
|
|
Map<Long, DataCollectionEmployee> employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId);
|
|
|
|
|
|
List<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAll();
|
|
|
|
|
|
Map<Long, TaxAgentPO> taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId);
|
2024-12-24 15:52:36 +08:00
|
|
|
|
List<HealthInsuranceListDTO> listDTOS = pos.stream().map(po -> {
|
2024-12-25 10:36:37 +08:00
|
|
|
|
HealthInsuranceListDTO dto = new HealthInsuranceListDTO();
|
|
|
|
|
|
BeanUtils.copyProperties(po, dto);
|
|
|
|
|
|
DataCollectionEmployee employee = employeeMap.getOrDefault(po.getEmployeeId(), new DataCollectionEmployee());
|
|
|
|
|
|
TaxAgentPO taxAgent = taxAgentMap.getOrDefault(po.getTaxAgentId(), new TaxAgentPO());
|
|
|
|
|
|
dto.setUsername(employee.getUsername());
|
|
|
|
|
|
dto.setTaxAgentName(taxAgent.getName());
|
|
|
|
|
|
dto.setDepartmentName(employee.getDepartmentName());
|
|
|
|
|
|
dto.setMobile(employee.getMobile());
|
|
|
|
|
|
dto.setJobNum(employee.getWorkcode());
|
|
|
|
|
|
dto.setIdNo(employee.getIdNo());
|
|
|
|
|
|
return dto;
|
2024-12-24 15:52:36 +08:00
|
|
|
|
}).collect(Collectors.toList());
|
2025-01-16 13:41:17 +08:00
|
|
|
|
return listDTOS;
|
2024-12-24 15:52:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2024-12-25 10:36:37 +08:00
|
|
|
|
public PageInfo<OtherDerateDeductionListDTO> otherDerateDeductionList(OtherDeductionDetailQueryParam param) {
|
2025-01-03 17:38:47 +08:00
|
|
|
|
OtherDerateDeductionPO build;
|
|
|
|
|
|
if (param.getId() != null) {
|
|
|
|
|
|
build = OtherDerateDeductionPO.builder().mainId(param.getId()).build();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
build = OtherDerateDeductionPO.builder().taxAgentId(param.getTaxAgentId()).taxYearMonth(param.getTaxCycle()).employeeId(param.getEmployeeId()).build();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<OtherDerateDeductionPO> pos = getOtherDerateDeductionMapper().listSome(build);
|
2025-01-16 13:41:17 +08:00
|
|
|
|
List<OtherDerateDeductionListDTO> listDTOS = otherDerateDeductionPO2DTO(pos);
|
|
|
|
|
|
return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), listDTOS, OtherDerateDeductionListDTO.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@NotNull
|
|
|
|
|
|
private List<OtherDerateDeductionListDTO> otherDerateDeductionPO2DTO(List<OtherDerateDeductionPO> pos) {
|
2024-12-25 10:36:37 +08:00
|
|
|
|
List<Long> empIds = SalaryEntityUtil.properties(pos, OtherDerateDeductionPO::getEmployeeId, Collectors.toList());
|
|
|
|
|
|
List<DataCollectionEmployee> employeeList = getSalaryEmployeeService(user).listByIds(empIds);
|
|
|
|
|
|
Map<Long, DataCollectionEmployee> employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId);
|
|
|
|
|
|
List<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAll();
|
|
|
|
|
|
Map<Long, TaxAgentPO> taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId);
|
2024-12-24 15:52:36 +08:00
|
|
|
|
List<OtherDerateDeductionListDTO> listDTOS = pos.stream().map(po -> {
|
2024-12-25 10:36:37 +08:00
|
|
|
|
OtherDerateDeductionListDTO dto = new OtherDerateDeductionListDTO();
|
|
|
|
|
|
BeanUtils.copyProperties(po, dto);
|
|
|
|
|
|
DataCollectionEmployee employee = employeeMap.getOrDefault(po.getEmployeeId(), new DataCollectionEmployee());
|
|
|
|
|
|
TaxAgentPO taxAgent = taxAgentMap.getOrDefault(po.getTaxAgentId(), new TaxAgentPO());
|
|
|
|
|
|
dto.setUsername(employee.getUsername());
|
|
|
|
|
|
dto.setTaxAgentName(taxAgent.getName());
|
|
|
|
|
|
dto.setDepartmentName(employee.getDepartmentName());
|
|
|
|
|
|
dto.setMobile(employee.getMobile());
|
|
|
|
|
|
dto.setJobNum(employee.getWorkcode());
|
|
|
|
|
|
dto.setIdNo(employee.getIdNo());
|
|
|
|
|
|
return dto;
|
2024-12-24 15:52:36 +08:00
|
|
|
|
}).collect(Collectors.toList());
|
2025-01-16 13:41:17 +08:00
|
|
|
|
return listDTOS;
|
2024-12-24 15:52:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2024-12-25 10:36:37 +08:00
|
|
|
|
public PageInfo<PersonalPensionListDTO> personalPensionList(OtherDeductionDetailQueryParam param) {
|
2025-01-03 17:38:47 +08:00
|
|
|
|
PersonalPensionPO build;
|
|
|
|
|
|
if (param.getId() != null) {
|
|
|
|
|
|
build = PersonalPensionPO.builder().mainId(param.getId()).build();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
build = PersonalPensionPO.builder().taxAgentId(param.getTaxAgentId()).taxYearMonth(param.getTaxCycle()).employeeId(param.getEmployeeId()).build();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<PersonalPensionPO> pos = getPersonalPensionMapper().listSome(build);
|
2025-01-16 13:41:17 +08:00
|
|
|
|
List<PersonalPensionListDTO> listDTOS = personalPensionPO2DTO(pos);
|
|
|
|
|
|
return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), listDTOS, PersonalPensionListDTO.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@NotNull
|
|
|
|
|
|
private List<PersonalPensionListDTO> personalPensionPO2DTO(List<PersonalPensionPO> pos) {
|
2024-12-25 10:36:37 +08:00
|
|
|
|
List<Long> empIds = SalaryEntityUtil.properties(pos, PersonalPensionPO::getEmployeeId, Collectors.toList());
|
|
|
|
|
|
List<DataCollectionEmployee> employeeList = getSalaryEmployeeService(user).listByIds(empIds);
|
|
|
|
|
|
Map<Long, DataCollectionEmployee> employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId);
|
|
|
|
|
|
List<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAll();
|
|
|
|
|
|
Map<Long, TaxAgentPO> taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId);
|
2024-12-24 15:52:36 +08:00
|
|
|
|
List<PersonalPensionListDTO> listDTOS = pos.stream().map(po -> {
|
2024-12-25 10:36:37 +08:00
|
|
|
|
PersonalPensionListDTO dto = new PersonalPensionListDTO();
|
|
|
|
|
|
BeanUtils.copyProperties(po, dto);
|
|
|
|
|
|
DataCollectionEmployee employee = employeeMap.getOrDefault(po.getEmployeeId(), new DataCollectionEmployee());
|
|
|
|
|
|
TaxAgentPO taxAgent = taxAgentMap.getOrDefault(po.getTaxAgentId(), new TaxAgentPO());
|
|
|
|
|
|
dto.setUsername(employee.getUsername());
|
|
|
|
|
|
dto.setTaxAgentName(taxAgent.getName());
|
|
|
|
|
|
dto.setDepartmentName(employee.getDepartmentName());
|
|
|
|
|
|
dto.setMobile(employee.getMobile());
|
|
|
|
|
|
dto.setJobNum(employee.getWorkcode());
|
|
|
|
|
|
dto.setIdNo(employee.getIdNo());
|
|
|
|
|
|
return dto;
|
2024-12-24 15:52:36 +08:00
|
|
|
|
}).collect(Collectors.toList());
|
2025-01-16 13:41:17 +08:00
|
|
|
|
return listDTOS;
|
2024-12-24 15:52:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-26 15:16:24 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public List<FreeIncomePO> queryFreeIncomes(OtherDeductionFreeListQueryParam param) {
|
|
|
|
|
|
ValidUtil.doValidator(param);
|
|
|
|
|
|
return getFreeIncomeMapper().listSome(FreeIncomePO.builder().taxYearMonth(param.getTaxCycle()).taxAgentId(param.getTaxAgentId()).build());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<DerateDeductionPO> queryDerateDeductions(OtherDeductionFreeListQueryParam param) {
|
|
|
|
|
|
ValidUtil.doValidator(param);
|
|
|
|
|
|
return getDerateDeductionMapper().listSome(DerateDeductionPO.builder().taxYearMonth(param.getTaxCycle()).taxAgentId(param.getTaxAgentId()).build());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<EndowmentInsurancePO> queryEndowmentInsurances(OtherDeductionFreeListQueryParam param) {
|
|
|
|
|
|
ValidUtil.doValidator(param);
|
|
|
|
|
|
return getEndowmentInsuranceMapper().listSome(EndowmentInsurancePO.builder().taxYearMonth(param.getTaxCycle()).taxAgentId(param.getTaxAgentId()).build());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<GrantDonationPO> queryGrantDonations(OtherDeductionFreeListQueryParam param) {
|
|
|
|
|
|
ValidUtil.doValidator(param);
|
|
|
|
|
|
return getGrantDonationMapper().listSome(GrantDonationPO.builder().taxYearMonth(param.getTaxCycle()).taxAgentId(param.getTaxAgentId()).build());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<HealthInsurancePO> queryHealthInsurances(OtherDeductionFreeListQueryParam param) {
|
|
|
|
|
|
ValidUtil.doValidator(param);
|
|
|
|
|
|
return getHealthInsuranceMapper().listSome(HealthInsurancePO.builder().taxYearMonth(param.getTaxCycle()).taxAgentId(param.getTaxAgentId()).build());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<OtherDerateDeductionPO> queryOtherDerateDeductions(OtherDeductionFreeListQueryParam param) {
|
|
|
|
|
|
ValidUtil.doValidator(param);
|
|
|
|
|
|
return getOtherDerateDeductionMapper().listSome(OtherDerateDeductionPO.builder().taxYearMonth(param.getTaxCycle()).taxAgentId(param.getTaxAgentId()).build());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<PersonalPensionPO> queryPersonalPensions(OtherDeductionFreeListQueryParam param) {
|
|
|
|
|
|
ValidUtil.doValidator(param);
|
|
|
|
|
|
return getPersonalPensionMapper().listSome(PersonalPensionPO.builder().taxYearMonth(param.getTaxCycle()).taxAgentId(param.getTaxAgentId()).build());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-23 16:41:42 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void saveFreeIncome(FreeIncomeSaveParam param) {
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
|
2024-12-24 10:54:57 +08:00
|
|
|
|
Long mainId = param.getMainId();
|
2024-12-24 15:52:36 +08:00
|
|
|
|
OtherDeductionPO deductionPO = getById(mainId);
|
|
|
|
|
|
if (deductionPO == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException("主表不存在!");
|
|
|
|
|
|
}
|
2024-12-24 10:54:57 +08:00
|
|
|
|
|
2024-12-23 16:41:42 +08:00
|
|
|
|
Long id = param.getId();
|
|
|
|
|
|
if (id == null) {
|
|
|
|
|
|
FreeIncomePO po = FreeIncomePO.builder()
|
2024-12-25 10:36:37 +08:00
|
|
|
|
.id(IdGenerator.generate())
|
2024-12-24 10:54:57 +08:00
|
|
|
|
.mainId(mainId)
|
|
|
|
|
|
.taxYearMonth(deductionPO.getDeclareMonth())
|
|
|
|
|
|
.employeeId(deductionPO.getEmployeeId())
|
|
|
|
|
|
.taxAgentId(deductionPO.getTaxAgentId())
|
2025-07-01 18:37:50 +08:00
|
|
|
|
.incomeCategory(param.getIncomeCategory())
|
2024-12-23 16:41:42 +08:00
|
|
|
|
.freeItem(param.getFreeItem())
|
|
|
|
|
|
.freeProperty(param.getFreeProperty())
|
|
|
|
|
|
.freeAmount(param.getFreeAmount())
|
|
|
|
|
|
.fileStatus(1)
|
|
|
|
|
|
.employeeType(0)
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
getFreeIncomeMapper().insertIgnoreNull(po);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
FreeIncomePO po = getFreeIncomeMapper().getById(id);
|
2024-12-25 10:36:37 +08:00
|
|
|
|
if (po == null) {
|
2024-12-24 15:52:36 +08:00
|
|
|
|
throw new SalaryRunTimeException("记录不存在!");
|
|
|
|
|
|
}
|
2024-12-23 16:41:42 +08:00
|
|
|
|
|
2024-12-24 15:52:36 +08:00
|
|
|
|
po.setUpdateTime(now);
|
2025-07-01 18:37:50 +08:00
|
|
|
|
po.setIncomeCategory(param.getIncomeCategory());
|
2024-12-23 16:41:42 +08:00
|
|
|
|
po.setFreeItem(param.getFreeItem());
|
|
|
|
|
|
po.setFreeProperty(param.getFreeProperty());
|
|
|
|
|
|
po.setFreeAmount(param.getFreeAmount());
|
|
|
|
|
|
|
|
|
|
|
|
getFreeIncomeMapper().updateIgnoreNull(po);
|
|
|
|
|
|
}
|
2025-01-14 09:15:09 +08:00
|
|
|
|
|
2025-01-14 14:56:36 +08:00
|
|
|
|
syncMain(mainId, Collections.singletonList(TaxFreeTypeEnum.FREE_INCOME));
|
2024-12-23 16:41:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-24 10:54:57 +08:00
|
|
|
|
@Override
|
2024-12-24 15:52:36 +08:00
|
|
|
|
public void saveEndowmentInsurance(EndowmentInsuranceSaveParam param) {
|
|
|
|
|
|
Date now = new Date();
|
2024-12-24 10:54:57 +08:00
|
|
|
|
|
2024-12-24 15:52:36 +08:00
|
|
|
|
Long mainId = param.getMainId();
|
|
|
|
|
|
OtherDeductionPO deductionPO = getById(mainId);
|
|
|
|
|
|
if (deductionPO == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException("主表不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Long id = param.getId();
|
|
|
|
|
|
if (id == null) {
|
|
|
|
|
|
EndowmentInsurancePO po = EndowmentInsurancePO.builder()
|
2024-12-25 10:36:37 +08:00
|
|
|
|
.id(IdGenerator.generate())
|
2024-12-24 15:52:36 +08:00
|
|
|
|
.mainId(mainId)
|
|
|
|
|
|
.taxYearMonth(deductionPO.getDeclareMonth())
|
|
|
|
|
|
.employeeId(deductionPO.getEmployeeId())
|
|
|
|
|
|
.taxAgentId(deductionPO.getTaxAgentId())
|
2025-07-01 18:37:50 +08:00
|
|
|
|
.incomeCategory(param.getIncomeCategory())
|
2024-12-27 15:38:00 +08:00
|
|
|
|
.deductionMonth(param.getDeductionMonth())
|
2024-12-24 15:52:36 +08:00
|
|
|
|
.accountNumber(param.getAccountNumber())
|
|
|
|
|
|
.checkCode(param.getCheckCode())
|
|
|
|
|
|
.yearPremium(param.getYearPremium())
|
|
|
|
|
|
.monthPremium(param.getMonthPremium())
|
|
|
|
|
|
.currentDeduction(param.getCurrentDeduction())
|
|
|
|
|
|
.fileStatus(1)
|
|
|
|
|
|
.employeeType(0)
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
getEndowmentInsuranceMapper().insertIgnoreNull(po);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
EndowmentInsurancePO po = getEndowmentInsuranceMapper().getById(id);
|
2024-12-25 10:36:37 +08:00
|
|
|
|
if (po == null) {
|
2024-12-24 15:52:36 +08:00
|
|
|
|
throw new SalaryRunTimeException("记录不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
po.setUpdateTime(now);
|
2025-07-01 18:37:50 +08:00
|
|
|
|
po.setIncomeCategory(param.getIncomeCategory());
|
2024-12-27 15:38:00 +08:00
|
|
|
|
po.setDeductionMonth(param.getDeductionMonth());
|
2024-12-24 15:52:36 +08:00
|
|
|
|
po.setAccountNumber(param.getAccountNumber());
|
|
|
|
|
|
po.setCheckCode(param.getCheckCode());
|
|
|
|
|
|
po.setYearPremium(param.getYearPremium());
|
|
|
|
|
|
po.setMonthPremium(param.getMonthPremium());
|
|
|
|
|
|
po.setCurrentDeduction(param.getCurrentDeduction());
|
|
|
|
|
|
|
|
|
|
|
|
getEndowmentInsuranceMapper().updateIgnoreNull(po);
|
|
|
|
|
|
}
|
2025-01-14 14:56:36 +08:00
|
|
|
|
|
|
|
|
|
|
syncMain(mainId, Collections.singletonList(TaxFreeTypeEnum.ENDOWMENT_INSURANCE));
|
2024-12-24 15:52:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void saveGrantDonation(GrantDonationSaveParam param) {
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
|
|
|
|
|
|
Long mainId = param.getMainId();
|
|
|
|
|
|
OtherDeductionPO deductionPO = getById(mainId);
|
|
|
|
|
|
if (deductionPO == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException("主表不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Long id = param.getId();
|
|
|
|
|
|
if (id == null) {
|
|
|
|
|
|
GrantDonationPO po = GrantDonationPO.builder()
|
2024-12-25 10:36:37 +08:00
|
|
|
|
.id(IdGenerator.generate())
|
2024-12-24 15:52:36 +08:00
|
|
|
|
.mainId(mainId)
|
|
|
|
|
|
.taxYearMonth(deductionPO.getDeclareMonth())
|
|
|
|
|
|
.employeeId(deductionPO.getEmployeeId())
|
|
|
|
|
|
.taxAgentId(deductionPO.getTaxAgentId())
|
2025-07-01 18:37:50 +08:00
|
|
|
|
.incomeCategory(param.getIncomeCategory())
|
2024-12-24 15:52:36 +08:00
|
|
|
|
.recipientName(param.getRecipientName())
|
|
|
|
|
|
.taxCode(param.getTaxCode())
|
|
|
|
|
|
.donationNumber(param.getDonationNumber())
|
|
|
|
|
|
.donateDate(param.getDonateDate())
|
|
|
|
|
|
.donateAmount(param.getDonateAmount())
|
|
|
|
|
|
.deductionProportion(param.getDeductionProportion())
|
|
|
|
|
|
.actualDeduction(param.getActualDeduction())
|
|
|
|
|
|
.fileStatus(1)
|
|
|
|
|
|
.employeeType(0)
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
getGrantDonationMapper().insertIgnoreNull(po);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
GrantDonationPO po = getGrantDonationMapper().getById(id);
|
2024-12-25 10:36:37 +08:00
|
|
|
|
if (po == null) {
|
2024-12-24 15:52:36 +08:00
|
|
|
|
throw new SalaryRunTimeException("记录不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
po.setUpdateTime(now);
|
2025-07-01 18:37:50 +08:00
|
|
|
|
po.setIncomeCategory(param.getIncomeCategory());
|
2024-12-24 15:52:36 +08:00
|
|
|
|
po.setRecipientName(param.getRecipientName());
|
|
|
|
|
|
po.setTaxCode(param.getTaxCode());
|
|
|
|
|
|
po.setDonationNumber(param.getDonationNumber());
|
|
|
|
|
|
po.setDonateDate(param.getDonateDate());
|
|
|
|
|
|
po.setDonateAmount(param.getDonateAmount());
|
|
|
|
|
|
po.setDeductionProportion(param.getDeductionProportion());
|
|
|
|
|
|
po.setActualDeduction(param.getActualDeduction());
|
|
|
|
|
|
|
|
|
|
|
|
getGrantDonationMapper().updateIgnoreNull(po);
|
|
|
|
|
|
}
|
2025-01-14 14:56:36 +08:00
|
|
|
|
|
|
|
|
|
|
syncMain(mainId, Collections.singletonList(TaxFreeTypeEnum.GRANT_DONATION));
|
2024-12-24 15:52:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void saveHealthInsurance(HealthInsuranceSaveParam param) {
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
|
|
|
|
|
|
Long mainId = param.getMainId();
|
|
|
|
|
|
OtherDeductionPO deductionPO = getById(mainId);
|
|
|
|
|
|
if (deductionPO == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException("主表不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Long id = param.getId();
|
|
|
|
|
|
if (id == null) {
|
|
|
|
|
|
HealthInsurancePO po = HealthInsurancePO.builder()
|
2024-12-25 10:36:37 +08:00
|
|
|
|
.id(IdGenerator.generate())
|
2024-12-24 15:52:36 +08:00
|
|
|
|
.mainId(mainId)
|
|
|
|
|
|
.taxYearMonth(deductionPO.getDeclareMonth())
|
|
|
|
|
|
.employeeId(deductionPO.getEmployeeId())
|
|
|
|
|
|
.taxAgentId(deductionPO.getTaxAgentId())
|
2025-07-01 18:37:50 +08:00
|
|
|
|
.incomeCategory(param.getIncomeCategory())
|
2024-12-24 15:52:36 +08:00
|
|
|
|
.identificationNumber(param.getIdentificationNumber())
|
|
|
|
|
|
.effectiveDate(param.getEffectiveDate())
|
|
|
|
|
|
.yearPremium(param.getYearPremium())
|
|
|
|
|
|
.monthPremium(param.getMonthPremium())
|
|
|
|
|
|
.currentDeduction(param.getCurrentDeduction())
|
|
|
|
|
|
.fileStatus(1)
|
|
|
|
|
|
.employeeType(0)
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
getHealthInsuranceMapper().insertIgnoreNull(po);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
HealthInsurancePO po = getHealthInsuranceMapper().getById(id);
|
2024-12-25 10:36:37 +08:00
|
|
|
|
if (po == null) {
|
2024-12-24 15:52:36 +08:00
|
|
|
|
throw new SalaryRunTimeException("记录不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
po.setUpdateTime(now);
|
2025-07-01 18:37:50 +08:00
|
|
|
|
po.setIncomeCategory(param.getIncomeCategory());
|
2024-12-24 15:52:36 +08:00
|
|
|
|
po.setIdentificationNumber(param.getIdentificationNumber());
|
|
|
|
|
|
po.setEffectiveDate(param.getEffectiveDate());
|
|
|
|
|
|
po.setYearPremium(param.getYearPremium());
|
|
|
|
|
|
po.setMonthPremium(param.getMonthPremium());
|
|
|
|
|
|
po.setCurrentDeduction(param.getCurrentDeduction());
|
|
|
|
|
|
|
|
|
|
|
|
getHealthInsuranceMapper().updateIgnoreNull(po);
|
|
|
|
|
|
}
|
2025-01-14 14:56:36 +08:00
|
|
|
|
|
|
|
|
|
|
syncMain(mainId, Collections.singletonList(TaxFreeTypeEnum.HEALTH_INSURANCE));
|
2024-12-24 15:52:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void saveOtherDerateDeduction(OtherDerateDeductionSaveParam param) {
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
|
|
|
|
|
|
Long mainId = param.getMainId();
|
|
|
|
|
|
OtherDeductionPO deductionPO = getById(mainId);
|
|
|
|
|
|
if (deductionPO == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException("主表不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Long id = param.getId();
|
|
|
|
|
|
if (id == null) {
|
|
|
|
|
|
OtherDerateDeductionPO po = OtherDerateDeductionPO.builder()
|
2024-12-25 10:36:37 +08:00
|
|
|
|
.id(IdGenerator.generate())
|
2024-12-24 15:52:36 +08:00
|
|
|
|
.mainId(mainId)
|
|
|
|
|
|
.taxYearMonth(deductionPO.getDeclareMonth())
|
|
|
|
|
|
.employeeId(deductionPO.getEmployeeId())
|
|
|
|
|
|
.taxAgentId(deductionPO.getTaxAgentId())
|
2025-07-01 18:37:50 +08:00
|
|
|
|
.incomeCategory(param.getIncomeCategory())
|
2024-12-24 15:52:36 +08:00
|
|
|
|
.otherDeduction(param.getOtherDeduction())
|
|
|
|
|
|
.remark(param.getRemark())
|
|
|
|
|
|
.fileStatus(1)
|
|
|
|
|
|
.employeeType(0)
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
getOtherDerateDeductionMapper().insertIgnoreNull(po);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
OtherDerateDeductionPO po = getOtherDerateDeductionMapper().getById(id);
|
2024-12-25 10:36:37 +08:00
|
|
|
|
if (po == null) {
|
2024-12-24 15:52:36 +08:00
|
|
|
|
throw new SalaryRunTimeException("记录不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
po.setUpdateTime(now);
|
2025-07-01 18:37:50 +08:00
|
|
|
|
po.setIncomeCategory(param.getIncomeCategory());
|
2024-12-24 15:52:36 +08:00
|
|
|
|
po.setOtherDeduction(param.getOtherDeduction());
|
|
|
|
|
|
po.setRemark(param.getRemark());
|
|
|
|
|
|
|
|
|
|
|
|
getOtherDerateDeductionMapper().updateIgnoreNull(po);
|
|
|
|
|
|
}
|
2025-01-14 14:56:36 +08:00
|
|
|
|
|
|
|
|
|
|
syncMain(mainId, Collections.singletonList(TaxFreeTypeEnum.OTHER_DERATE_DEDUCTION));
|
2024-12-24 15:52:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void saveDerateDeduction(DerateDeductionSaveParam param) {
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
|
|
|
|
|
|
Long mainId = param.getMainId();
|
|
|
|
|
|
OtherDeductionPO deductionPO = getById(mainId);
|
|
|
|
|
|
if (deductionPO == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException("主表不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Long id = param.getId();
|
|
|
|
|
|
if (id == null) {
|
|
|
|
|
|
DerateDeductionPO po = DerateDeductionPO.builder()
|
2024-12-25 10:36:37 +08:00
|
|
|
|
.id(IdGenerator.generate())
|
2024-12-24 15:52:36 +08:00
|
|
|
|
.mainId(mainId)
|
|
|
|
|
|
.taxYearMonth(deductionPO.getDeclareMonth())
|
|
|
|
|
|
.employeeId(deductionPO.getEmployeeId())
|
|
|
|
|
|
.taxAgentId(deductionPO.getTaxAgentId())
|
2025-07-01 18:37:50 +08:00
|
|
|
|
.incomeCategory(param.getIncomeCategory())
|
2024-12-24 15:52:36 +08:00
|
|
|
|
.derateAmount(param.getDerateAmount())
|
|
|
|
|
|
.derateItem(param.getDerateItem())
|
|
|
|
|
|
.derateProperty(param.getDerateProperty())
|
|
|
|
|
|
.fileStatus(1)
|
|
|
|
|
|
.employeeType(0)
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
getDerateDeductionMapper().insertIgnoreNull(po);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
DerateDeductionPO po = getDerateDeductionMapper().getById(id);
|
2024-12-25 10:36:37 +08:00
|
|
|
|
if (po == null) {
|
2024-12-24 15:52:36 +08:00
|
|
|
|
throw new SalaryRunTimeException("记录不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
po.setUpdateTime(now);
|
2025-07-01 18:37:50 +08:00
|
|
|
|
po.setIncomeCategory(param.getIncomeCategory());
|
2024-12-24 15:52:36 +08:00
|
|
|
|
po.setDerateAmount(param.getDerateAmount());
|
|
|
|
|
|
po.setDerateItem(param.getDerateItem());
|
|
|
|
|
|
po.setDerateProperty(param.getDerateProperty());
|
|
|
|
|
|
|
|
|
|
|
|
getDerateDeductionMapper().updateIgnoreNull(po);
|
|
|
|
|
|
}
|
2025-01-14 14:56:36 +08:00
|
|
|
|
|
|
|
|
|
|
syncMain(mainId, Collections.singletonList(TaxFreeTypeEnum.DERATE_DEDUCTION));
|
2024-12-24 15:52:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void savePersonalPension(PersonalPensionSaveParam param) {
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
|
|
|
|
|
|
Long mainId = param.getMainId();
|
|
|
|
|
|
OtherDeductionPO deductionPO = getById(mainId);
|
|
|
|
|
|
if (deductionPO == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException("主表不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Long id = param.getId();
|
|
|
|
|
|
if (id == null) {
|
|
|
|
|
|
PersonalPensionPO po = PersonalPensionPO.builder()
|
2024-12-25 10:36:37 +08:00
|
|
|
|
.id(IdGenerator.generate())
|
2024-12-24 15:52:36 +08:00
|
|
|
|
.mainId(mainId)
|
|
|
|
|
|
.taxYearMonth(deductionPO.getDeclareMonth())
|
|
|
|
|
|
.employeeId(deductionPO.getEmployeeId())
|
|
|
|
|
|
.taxAgentId(deductionPO.getTaxAgentId())
|
2025-07-01 18:37:50 +08:00
|
|
|
|
.incomeCategory(param.getIncomeCategory())
|
2024-12-24 15:52:36 +08:00
|
|
|
|
.voucherTypeName(param.getVoucherTypeName())
|
|
|
|
|
|
.voucherNo(param.getVoucherNo())
|
|
|
|
|
|
.payAmount(param.getPayAmount())
|
|
|
|
|
|
.fileStatus(1)
|
|
|
|
|
|
.employeeType(0)
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
|
|
|
|
|
|
.tenantKey(DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
getPersonalPensionMapper().insertIgnoreNull(po);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
PersonalPensionPO po = getPersonalPensionMapper().getById(id);
|
2024-12-25 10:36:37 +08:00
|
|
|
|
if (po == null) {
|
2024-12-24 15:52:36 +08:00
|
|
|
|
throw new SalaryRunTimeException("记录不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
po.setUpdateTime(now);
|
2025-07-01 18:37:50 +08:00
|
|
|
|
po.setIncomeCategory(param.getIncomeCategory());
|
2024-12-24 15:52:36 +08:00
|
|
|
|
po.setVoucherTypeName(param.getVoucherTypeName());
|
|
|
|
|
|
po.setVoucherNo(param.getVoucherNo());
|
|
|
|
|
|
po.setPayAmount(param.getPayAmount());
|
|
|
|
|
|
|
|
|
|
|
|
getPersonalPensionMapper().updateIgnoreNull(po);
|
|
|
|
|
|
}
|
2025-01-14 14:56:36 +08:00
|
|
|
|
|
|
|
|
|
|
syncMain(mainId, Collections.singletonList(TaxFreeTypeEnum.PERSONAL_PENSION));
|
2024-12-24 10:54:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-25 10:36:37 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void deleteFreeIncome(OtherDeductionDetailDeleteParam param) {
|
|
|
|
|
|
getFreeIncomeMapper().deleteByIds(param.getIds());
|
2025-01-14 14:56:36 +08:00
|
|
|
|
syncMain(param.getMainId(), Collections.singletonList(TaxFreeTypeEnum.FREE_INCOME));
|
2024-12-25 10:36:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void deleteEndowmentInsurance(OtherDeductionDetailDeleteParam param) {
|
|
|
|
|
|
getEndowmentInsuranceMapper().deleteByIds(param.getIds());
|
2025-01-14 14:56:36 +08:00
|
|
|
|
syncMain(param.getMainId(), Collections.singletonList(TaxFreeTypeEnum.ENDOWMENT_INSURANCE));
|
2024-12-25 10:36:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void deleteGrantDonation(OtherDeductionDetailDeleteParam param) {
|
|
|
|
|
|
getGrantDonationMapper().deleteByIds(param.getIds());
|
2025-01-14 14:56:36 +08:00
|
|
|
|
syncMain(param.getMainId(), Collections.singletonList(TaxFreeTypeEnum.GRANT_DONATION));
|
2024-12-25 10:36:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void deleteHealthInsurance(OtherDeductionDetailDeleteParam param) {
|
|
|
|
|
|
getHealthInsuranceMapper().deleteByIds(param.getIds());
|
2025-01-14 14:56:36 +08:00
|
|
|
|
syncMain(param.getMainId(), Collections.singletonList(TaxFreeTypeEnum.HEALTH_INSURANCE));
|
2024-12-25 10:36:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void deleteOtherDerateDeduction(OtherDeductionDetailDeleteParam param) {
|
|
|
|
|
|
getOtherDerateDeductionMapper().deleteByIds(param.getIds());
|
2025-01-14 14:56:36 +08:00
|
|
|
|
syncMain(param.getMainId(), Collections.singletonList(TaxFreeTypeEnum.OTHER_DERATE_DEDUCTION));
|
2024-12-25 10:36:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void deleteDerateDeduction(OtherDeductionDetailDeleteParam param) {
|
|
|
|
|
|
getDerateDeductionMapper().deleteByIds(param.getIds());
|
2025-01-14 14:56:36 +08:00
|
|
|
|
syncMain(param.getMainId(), Collections.singletonList(TaxFreeTypeEnum.DERATE_DEDUCTION));
|
2024-12-25 10:36:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void deletePersonalPension(OtherDeductionDetailDeleteParam param) {
|
|
|
|
|
|
getPersonalPensionMapper().deleteByIds(param.getIds());
|
2025-01-14 14:56:36 +08:00
|
|
|
|
syncMain(param.getMainId(), Collections.singletonList(TaxFreeTypeEnum.PERSONAL_PENSION));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2025-01-14 17:05:31 +08:00
|
|
|
|
public void syncMain(Long mainId, List<TaxFreeTypeEnum> taxFreeTypes) {
|
2025-01-14 14:56:36 +08:00
|
|
|
|
OtherDeductionPO deductionPO = getById(mainId);
|
|
|
|
|
|
if (deductionPO == null) {
|
|
|
|
|
|
throw new SalaryRunTimeException("主表不存在!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-14 17:05:31 +08:00
|
|
|
|
if (taxFreeTypes.contains(TaxFreeTypeEnum.FREE_INCOME)) {
|
2025-01-14 14:56:36 +08:00
|
|
|
|
syncFreeIncome(deductionPO);
|
|
|
|
|
|
}
|
2025-01-14 17:05:31 +08:00
|
|
|
|
if (taxFreeTypes.contains(TaxFreeTypeEnum.HEALTH_INSURANCE)) {
|
2025-01-16 13:41:17 +08:00
|
|
|
|
syncHealthInsurance(deductionPO);
|
2025-01-14 14:56:36 +08:00
|
|
|
|
}
|
2025-01-14 17:05:31 +08:00
|
|
|
|
if (taxFreeTypes.contains(TaxFreeTypeEnum.ENDOWMENT_INSURANCE)) {
|
2025-01-16 13:41:17 +08:00
|
|
|
|
syncEndowmentInsurance(deductionPO);
|
2025-01-14 14:56:36 +08:00
|
|
|
|
}
|
2025-01-14 17:05:31 +08:00
|
|
|
|
if (taxFreeTypes.contains(TaxFreeTypeEnum.GRANT_DONATION)) {
|
2025-01-16 13:41:17 +08:00
|
|
|
|
syncGrantDonation(deductionPO);
|
2025-01-14 14:56:36 +08:00
|
|
|
|
}
|
2025-01-14 17:05:31 +08:00
|
|
|
|
if (taxFreeTypes.contains(TaxFreeTypeEnum.DERATE_DEDUCTION)) {
|
2025-01-14 14:56:36 +08:00
|
|
|
|
syncDerateDeduction(deductionPO);
|
|
|
|
|
|
}
|
2025-01-14 17:05:31 +08:00
|
|
|
|
if (taxFreeTypes.contains(TaxFreeTypeEnum.OTHER_DERATE_DEDUCTION)) {
|
2025-01-14 14:56:36 +08:00
|
|
|
|
syncOtherDerateDeduction(deductionPO);
|
|
|
|
|
|
}
|
2025-01-14 17:05:31 +08:00
|
|
|
|
if (taxFreeTypes.contains(TaxFreeTypeEnum.PERSONAL_PENSION)) {
|
2025-01-14 14:56:36 +08:00
|
|
|
|
syncPersonalPension(deductionPO);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void syncFreeIncome(OtherDeductionPO mainPO) {
|
|
|
|
|
|
List<FreeIncomePO> freeIncomePOS = getFreeIncomeMapper().listSome(FreeIncomePO.builder().mainId(mainPO.getId()).build());
|
|
|
|
|
|
String sum = freeIncomePOS.stream().filter(po -> NumberUtil.isNumber(po.getFreeAmount())).map(po -> new BigDecimal(po.getFreeAmount())).reduce(BigDecimal.ZERO, BigDecimal::add).toPlainString();
|
|
|
|
|
|
mainPO.setFreeIncome(sum);
|
|
|
|
|
|
getOtherDeductionMapper().updateData(Collections.singletonList(mainPO));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void syncEndowmentInsurance(OtherDeductionPO mainPO) {
|
|
|
|
|
|
List<EndowmentInsurancePO> endowmentInsurancePOS = getEndowmentInsuranceMapper().listSome(EndowmentInsurancePO.builder().mainId(mainPO.getId()).build());
|
|
|
|
|
|
String sum = endowmentInsurancePOS.stream().filter(po -> NumberUtil.isNumber(po.getCurrentDeduction())).map(po -> new BigDecimal(po.getCurrentDeduction())).reduce(BigDecimal.ZERO, BigDecimal::add).toPlainString();
|
|
|
|
|
|
mainPO.setTaxDelayEndowmentInsurance(sum);
|
|
|
|
|
|
getOtherDeductionMapper().updateData(Collections.singletonList(mainPO));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void syncGrantDonation(OtherDeductionPO mainPO) {
|
|
|
|
|
|
List<GrantDonationPO> grantDonationPOS = getGrantDonationMapper().listSome(GrantDonationPO.builder().mainId(mainPO.getId()).build());
|
|
|
|
|
|
String sum = grantDonationPOS.stream().filter(po -> NumberUtil.isNumber(po.getActualDeduction())).map(po -> new BigDecimal(po.getActualDeduction())).reduce(BigDecimal.ZERO, BigDecimal::add).toPlainString();
|
|
|
|
|
|
mainPO.setDeductionAllowedDonation(sum);
|
|
|
|
|
|
getOtherDeductionMapper().updateData(Collections.singletonList(mainPO));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void syncHealthInsurance(OtherDeductionPO mainPO) {
|
|
|
|
|
|
List<HealthInsurancePO> healthInsurancePOS = getHealthInsuranceMapper().listSome(HealthInsurancePO.builder().mainId(mainPO.getId()).build());
|
|
|
|
|
|
String sum = healthInsurancePOS.stream().filter(po -> NumberUtil.isNumber(po.getCurrentDeduction())).map(po -> new BigDecimal(po.getCurrentDeduction())).reduce(BigDecimal.ZERO, BigDecimal::add).toPlainString();
|
|
|
|
|
|
mainPO.setBusinessHealthyInsurance(sum);
|
|
|
|
|
|
getOtherDeductionMapper().updateData(Collections.singletonList(mainPO));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void syncOtherDerateDeduction(OtherDeductionPO mainPO) {
|
|
|
|
|
|
List<OtherDerateDeductionPO> otherDerateDeductionPOS = getOtherDerateDeductionMapper().listSome(OtherDerateDeductionPO.builder().mainId(mainPO.getId()).build());
|
|
|
|
|
|
String sum = otherDerateDeductionPOS.stream().filter(po -> NumberUtil.isNumber(po.getOtherDeduction())).map(po -> new BigDecimal(po.getOtherDeduction())).reduce(BigDecimal.ZERO, BigDecimal::add).toPlainString();
|
|
|
|
|
|
mainPO.setOtherDeduction(sum);
|
|
|
|
|
|
getOtherDeductionMapper().updateData(Collections.singletonList(mainPO));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void syncDerateDeduction(OtherDeductionPO mainPO) {
|
|
|
|
|
|
List<DerateDeductionPO> derateDeductionPOS = getDerateDeductionMapper().listSome(DerateDeductionPO.builder().mainId(mainPO.getId()).build());
|
|
|
|
|
|
String sum = derateDeductionPOS.stream().filter(po -> NumberUtil.isNumber(po.getDerateAmount())).map(po -> new BigDecimal(po.getDerateAmount())).reduce(BigDecimal.ZERO, BigDecimal::add).toPlainString();
|
|
|
|
|
|
mainPO.setDerateDeduction(sum);
|
|
|
|
|
|
getOtherDeductionMapper().updateData(Collections.singletonList(mainPO));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void syncPersonalPension(OtherDeductionPO mainPO) {
|
|
|
|
|
|
List<PersonalPensionPO> personalPensionPOS = getPersonalPensionMapper().listSome(PersonalPensionPO.builder().mainId(mainPO.getId()).build());
|
|
|
|
|
|
String sum = personalPensionPOS.stream().filter(po -> NumberUtil.isNumber(po.getPayAmount())).map(po -> new BigDecimal(po.getPayAmount())).reduce(BigDecimal.ZERO, BigDecimal::add).toPlainString();
|
|
|
|
|
|
mainPO.setPrivatePension(sum);
|
|
|
|
|
|
getOtherDeductionMapper().updateData(Collections.singletonList(mainPO));
|
2024-12-25 10:36:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-10 17:57:46 +08:00
|
|
|
|
}
|