diff --git a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationSaveParam.java b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationSaveParam.java index 18b8c28c8..8e0f07d18 100644 --- a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationSaveParam.java +++ b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationSaveParam.java @@ -1,11 +1,13 @@ package com.engine.salary.entity.taxdeclaration.param; +import com.engine.salary.enums.taxdeclaration.TaxAgentRangeEnum; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.time.YearMonth; +import java.util.List; /** * 生成个税申报表参数 @@ -36,6 +38,16 @@ public class TaxDeclarationSaveParam { */ private Long taxAgentId; + /** + * 个税扣缴义务人范围 + */ + private TaxAgentRangeEnum taxAgentRange; + + /** + * 个税扣缴义务人id + */ + private List taxAgentIds; + /** * 备注 */ diff --git a/src/com/engine/salary/service/impl/TaxDeclareRecordServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclareRecordServiceImpl.java index 65e236f94..e7bc2f198 100644 --- a/src/com/engine/salary/service/impl/TaxDeclareRecordServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclareRecordServiceImpl.java @@ -1,6 +1,8 @@ package com.engine.salary.service.impl; +import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; +import com.engine.salary.common.LocalDateRange; import com.engine.salary.common.YearMonthRange; import com.engine.salary.constant.SalaryDefaultTenantConstant; import com.engine.salary.constant.SzyhApiConstant; @@ -41,16 +43,19 @@ import com.engine.salary.mapper.taxdeclaration.TaxDeclareRecordMapper; import com.engine.salary.service.*; import com.engine.salary.service.factory.TaxPaymentServiceFactory; import com.engine.salary.util.*; +import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.SalaryPageUtil; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import dm.jdbc.util.IdGenerator; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.transaction.annotation.Transactional; import weaver.general.Util; +import weaver.hrm.User; import java.math.BigDecimal; import java.time.YearMonth; @@ -68,42 +73,59 @@ import java.util.stream.Collectors; public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRecordService { - private TaxDeclareRecordMapper taxDeclareRecordMapper; - - private TaxDeclarationService taxDeclarationService; - - private TaxDeclarationValueService taxDeclarationValueService; - - private EmployeeDeclareService employeeDeclareService; - - private TaxAgentTaxReturnService taxAgentTaxReturnService; - - private TaxAgentService taxAgentService; - - private TaxDeclarationApiConfigService taxDeclarationApiConfigService; - - private AddUpSituationService addUpSituationService; - - private TaxDeclarationApiBillingService taxDeclarationApiBillingService; - - private TaxDeclareEmployeeService taxDeclareEmployeeService; - - private TaxDeclareFailService taxDeclareFailService; - - private SalaryAcctRecordService salaryAcctRecordService; + private TaxDeclareRecordMapper getTaxDeclareRecordMapper() { + return MapperProxyFactory.getProxy(TaxDeclareRecordMapper.class); + } + private TaxDeclarationService getTaxDeclarationService(User user) { + return ServiceUtil.getService(TaxDeclarationServiceImpl.class, user); + } + private TaxDeclarationValueService getTaxDeclarationValueService(User user) { + return ServiceUtil.getService(TaxDeclarationValueServiceImpl.class, user); + } + private EmployeeDeclareService getEmployeeDeclareService(User user) { + return ServiceUtil.getService(EmployeeDeclareServiceImpl.class, user); + } + private TaxAgentTaxReturnService getTaxAgentTaxReturnService(User user) { + return ServiceUtil.getService(TaxAgentTaxReturnServiceImpl.class, user); + } + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + private TaxDeclarationApiConfigService getTaxDeclarationApiConfigService(User user) { + return ServiceUtil.getService(TaxDeclarationApiConfigServiceImpl.class, user); + } + private AddUpSituationService getAddUpSituationService(User user) { + return ServiceUtil.getService(AddUpSituationServiceImpl.class, user); + } + private TaxDeclarationApiBillingService getTaxDeclarationApiBillingService(User user) { + return ServiceUtil.getService(TaxDeclarationApiBillingServiceImpl.class, user); + } + private TaxDeclareEmployeeService getTaxDeclareEmployeeService(User user) { + return ServiceUtil.getService(TaxDeclareEmployeeServiceImpl.class, user); + } + private TaxDeclareFailService getTaxDeclareFailService(User user) { + return ServiceUtil.getService(TaxDeclareFailServiceImpl.class, user); + } + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } private SalaryAcctTaxAgentService salaryAcctTaxAgentService; - private SalaryAcctEmployeeService salaryAcctEmployeeService; - - private SalaryAcctResultService salaryAcctResultValueService; - - private SalaryItemService salaryItemService; - + private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + } + private SalaryAcctResultService getSalaryAcctResultService(User user) { + return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); + } + private SalaryItemService getSalaryItemService(User user) { + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } private SalarySobTaxReportRuleService salarySobTaxReportRuleService; - private TaxReportColumnService taxReportColumnService; - + private TaxReportColumnService getTaxReportColumnService(User user) { + return ServiceUtil.getService(TaxReportColumnServiceImpl.class, user); + } private SalarySobAddUpRuleService salarySobAddUpRuleService; private TaxPaymentServiceFactory taxPaymentServiceFactory; @@ -112,12 +134,12 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe @Override public TaxDeclareRecordPO getById(Long id) { - return taxDeclareRecordMapper.getById(id); + return getTaxDeclareRecordMapper().getById(id); } @Override public List listByIds(Collection ids) { - return taxDeclareRecordMapper.listSome(TaxDeclareRecordPO.builder().ids(ids).build()); + return getTaxDeclareRecordMapper().listSome(TaxDeclareRecordPO.builder().ids(ids).build()); } @Override @@ -129,7 +151,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe if (Objects.nonNull(taxCycleRange.getEndMonth())) { build.setEndDate(taxCycleRange.getEndMonth()); } - return taxDeclareRecordMapper.listSome(build); + return getTaxDeclareRecordMapper().listSome(build); } @Override @@ -137,7 +159,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe if (Objects.isNull(taxCycle) || CollectionUtils.isEmpty(taxAgentIds)) { return Collections.emptyList(); } - return taxDeclareRecordMapper.listSome(TaxDeclareRecordPO.builder().taxAgentIds(taxAgentIds).taxCycle(taxCycle).build()); + return getTaxDeclareRecordMapper().listSome(TaxDeclareRecordPO.builder().taxAgentIds(taxAgentIds).taxCycle(taxCycle).build()); } @Override @@ -145,7 +167,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe if (Objects.isNull(salaryMonth) || CollectionUtils.isEmpty(taxAgentIds)) { return Collections.emptyList(); } - return taxDeclareRecordMapper.listSome(TaxDeclareRecordPO.builder().taxAgentIds(taxAgentIds).salaryMonth(salaryMonth).build()); + return getTaxDeclareRecordMapper().listSome(TaxDeclareRecordPO.builder().taxAgentIds(taxAgentIds).salaryMonth(salaryMonth).build()); } @Override @@ -161,20 +183,20 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe } List taxAgentIds = new ArrayList<>(); if (StringUtils.isNotEmpty(queryParam.getTaxAgentName())) { - List taxAgents = taxAgentService.list(TaxAgentQueryParam.builder().name(queryParam.getTaxAgentName()).build()); + List taxAgents = getTaxAgentService(user).list(TaxAgentQueryParam.builder().name(queryParam.getTaxAgentName()).build()); if (CollectionUtils.isEmpty(taxAgents)) { return pageInfo; } taxAgentIds = SalaryEntityUtil.properties(taxAgents, TaxAgentPO::getId, Collectors.toList()); } // 判断是否开启了分权 - Boolean openDevolution = taxAgentService.isOpenDevolution(); + Boolean openDevolution = getTaxAgentService(user).isOpenDevolution(); // 判断是否是总管理员 - Boolean isChief = taxAgentService.isChief((long) user.getUID()); + Boolean isChief = getTaxAgentService(user).isChief((long) user.getUID()); // 可见范围内的个税扣缴义务人 Collection taxAgents = Lists.newArrayList(); if (openDevolution && !isChief) { - taxAgents = taxAgentService.listAllTaxAgentsAsAdmin((long) user.getUID()); + taxAgents = getTaxAgentService(user).listAllTaxAgentsAsAdmin((long) user.getUID()); if (CollectionUtils.isEmpty(taxAgents)) { return pageInfo; } @@ -182,107 +204,83 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe taxAgentIds = taxAgentIds.stream().filter(taxAgentDevolution::contains).collect(Collectors.toList()); } build.setTaxAgentIds(taxAgentIds); - List taxDeclareRecordPOS = taxDeclareRecordMapper.listSome(build); - return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), - taxDeclareRecordPOS, TaxDeclareRecordPO.class); + List taxDeclareRecordPOS = getTaxDeclareRecordMapper().listSome(build); + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), taxDeclareRecordPOS, TaxDeclareRecordPO.class); } @Override public void save(TaxDeclarationSaveParam saveParam) { -// Date now = new Date(); -// Set needDeleteTaxDeclareRecordIds = Sets.newHashSet(); -// List newTaxDeclareRecords = Lists.newArrayList(); -// List newTaxDeclarations = Lists.newArrayList(); -// List newTaxDeclarationValues = Lists.newArrayList(); -// List newAddUpSituations = Lists.newArrayList(); -// // 根据个税扣缴义务人范围查询个税扣缴义务人 -// List taxAgents = queryByTaxAgentRange(saveParam); -// Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getId, TaxAgentPO::getName); -// // 查询薪资所属月下的薪资核算记录,并按照权限过滤 -// LocalDateRange salaryMonthRange = new LocalDateRange() -// .setFromDate(SalaryDateUtil.localDateToDate(saveParam.getSalaryMonth().atDay(1))) -// .setEndDate(SalaryDateUtil.localDateToDate(saveParam.getSalaryMonth().atDay(1))); -// List salaryAcctRecords = salaryAcctRecordService.listBySalaryMonth(salaryMonthRange); -// // 查询薪资核算记录关联的个税扣缴义务人 -// List salaryAcctTaxAgents = salaryAcctRecordService.listBySalaryAcctRecordIds( -// SalaryEntityUtil.properties(salaryAcctRecords, SalaryAcctRecordPO::getId)); -// // 按照saveParam中的个税扣缴义务人范围过滤 -// Set taxAgentIds = SalaryEntityUtil.properties(taxAgents, TaxAgentPO::getId); -// salaryAcctTaxAgents = salaryAcctTaxAgents.stream() -// .filter(e -> taxAgentIds.contains(e.getTaxAgentId())) -// .collect(Collectors.toList()); -// Set salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctTaxAgents, SalaryAcctTaxAgentPO::getSalaryAcctRecordId); -// salaryAcctRecords = salaryAcctRecords.stream() -// .filter(e -> salaryAcctRecordIds.contains(e.getId())) -// .collect(Collectors.toList()); -// // 校验是否可以生成个税申报表 -// // 返回目前已经生成的个税申报表 -// List taxDeclareRecords = checkBeforeSave(saveParam, taxAgentNameMap, salaryAcctRecords, salaryAcctTaxAgents); -// Map taxDeclareRecordMap = SalaryEntityUtil.convert2Map(taxDeclareRecords, e -> e.getTaxCycle() + "-" + e.getTaxAgentId()); -// // 查询薪资核算人员 -// List salaryAcctEmployees = salaryAcctEmployeeService.listByRecordIdsAndEmpIdAndTaxAgentId(salaryAcctRecordIds, null, taxAgents.get(0).getId()); -// // 薪资核算人员按照税款所属期聚合分类 -// Map> taxCycleKeyEmployeeMap = SalaryEntityUtil.group2Map( -// salaryAcctEmployees, SalaryAcctEmployeePO::getTaxCycle); -// for (Map.Entry> taxCycleEntry : taxCycleKeyEmployeeMap.entrySet()) { -// // 薪资核算人员按照个税扣缴义务人id聚合分类 -// Map> taxAgentIdKeyEmployeeMap = SalaryEntityUtil.group2Map( -// taxCycleEntry.getValue(), SalaryAcctEmployeePO::getTaxAgentId); -// for (Map.Entry> taxAgentIdEntry : taxAgentIdKeyEmployeeMap.entrySet()) { -// TaxDeclareRecordPO oldTaxDeclareRecord = taxDeclareRecordMap.get(taxCycleEntry.getKey() + "-" + taxAgentIdEntry.getKey()); -// // 如果已经生成了个税申报表,并且个税申报表已经申报过了,就跳过 -// if (oldTaxDeclareRecord != null) { -// if (!(Objects.equals(oldTaxDeclareRecord.getTaxDeclareType(), TaxDeclareTypeEnum.NORMAL_DECLARE.getValue()) -// && Objects.equals(oldTaxDeclareRecord.getTaxDeclareStatus(), TaxDeclareStatusEnum.NOT_DECLARE.getValue()))) { -// continue; -// } -// needDeleteTaxDeclareRecordIds.add(oldTaxDeclareRecord.getId()); -// } -// TaxDeclareRecordPO taxDeclareRecord = new TaxDeclareRecordPO() -// .setId(IdGenerator.generate()) -// .setTaxAgentId(taxAgentIdEntry.getKey()) -// .setSalaryMonth(SalaryDateUtil.localDateToDate(saveParam.getSalaryMonth().atDay(1))) -// .setTaxCycle(taxCycleEntry.getKey()) -// .setTaxDeclareType(TaxDeclareTypeEnum.NORMAL_DECLARE.getValue()) -// .setTaxDeclareStatus(TaxDeclareStatusEnum.NOT_DECLARE.getValue()) -// .setRemark(saveParam.getDescription()) -// .setCreator((long)user.getUID()) -// .setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) -// .setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()) -// .setCreateTime(now) -// .setUpdateTime(now); -// newTaxDeclareRecords.add(taxDeclareRecord); -// // 生成个税申报表 -// TaxDeclarationResult taxDeclarationResult = generateReportPerRecord(taxDeclareRecord, taxAgentIdEntry.getValue()); -// newTaxDeclarations.addAll(taxDeclarationResult.getTaxDeclarations()); -// newTaxDeclarationValues.addAll(taxDeclarationResult.getTaxDeclarationValues()); -// newAddUpSituations.addAll(taxDeclarationResult.getAddUpSituations()); -// } -// } -// -// // 删除原来生成的个税申报记录、个税申报表、个税申报表明细 -// deleteByIds(needDeleteTaxDeclareRecordIds); -// // 保存个税申报记录 -// if (CollectionUtils.isNotEmpty(newTaxDeclareRecords)) { -// saveBatch(newTaxDeclareRecords); -// } -// // 保存个税申报表 -// if (CollectionUtils.isNotEmpty(newTaxDeclarations)) { -// taxDeclarationService.saveBatch(newTaxDeclarations); -// } -// // 保存个税申报表明细 -// if (CollectionUtils.isNotEmpty(newTaxDeclarationValues)) { -// taxDeclarationValueService.batchSave(newTaxDeclarationValues); -// } -// // 保存累计情况 -// if (CollectionUtils.isNotEmpty(newAddUpSituations)) { -// Map> addUpSituationMap = SalaryEntityUtil.group2Map(newAddUpSituations, e -> SalaryDateUtil.getFormatYearMonth(e.getTaxYearMonth())); -// for (Map.Entry> entry : addUpSituationMap.entrySet()) { -// addUpSituationService.deleteByTaxYearMonthAndTaxAgentIds(YearMonth.parse(entry.getKey()), -// SalaryEntityUtil.properties(entry.getValue(), AddUpSituationPO::getTaxAgentId)); -// addUpSituationService.saveBatch(entry.getValue()); -// } -// } + Date now = new Date(); + Set needDeleteTaxDeclareRecordIds = Sets.newHashSet(); + List newTaxDeclareRecords = Lists.newArrayList(); + List newTaxDeclarations = Lists.newArrayList(); + List newTaxDeclarationValues = Lists.newArrayList(); + List newAddUpSituations = Lists.newArrayList(); + // 根据个税扣缴义务人范围查询个税扣缴义务人 + Collection taxAgents = queryByTaxAgentRange(saveParam); + Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getId, TaxAgentPO::getName); + // 查询薪资所属月下的薪资核算记录,并按照权限过滤 + LocalDateRange salaryMonthRange = new LocalDateRange().setFromDate(SalaryDateUtil.localDateToDate(saveParam.getSalaryMonth().atDay(1))).setEndDate(SalaryDateUtil.localDateToDate(saveParam.getSalaryMonth().atDay(1))); + List salaryAcctRecords = getSalaryAcctRecordService(user).listBySalaryMonth(salaryMonthRange); + // 查询薪资核算记录关联的个税扣缴义务人 + List salaryAcctTaxAgents = getSalaryAcctRecordService(user).listBySalaryAcctRecordIds(SalaryEntityUtil.properties(salaryAcctRecords, SalaryAcctRecordPO::getId)); + // 按照saveParam中的个税扣缴义务人范围过滤 + Set taxAgentIds = SalaryEntityUtil.properties(taxAgents, TaxAgentPO::getId); + salaryAcctTaxAgents = salaryAcctTaxAgents.stream().filter(e -> taxAgentIds.contains(e.getTaxAgentId())).collect(Collectors.toList()); + Set salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctTaxAgents, SalaryAcctTaxAgentPO::getSalaryAcctRecordId); + salaryAcctRecords = salaryAcctRecords.stream().filter(e -> salaryAcctRecordIds.contains(e.getId())).collect(Collectors.toList()); + // 校验是否可以生成个税申报表 + // 返回目前已经生成的个税申报表 + List taxDeclareRecords = checkBeforeSave(saveParam, taxAgentNameMap, salaryAcctRecords, salaryAcctTaxAgents); + Map taxDeclareRecordMap = SalaryEntityUtil.convert2Map(taxDeclareRecords, e -> e.getTaxCycle() + "-" + e.getTaxAgentId()); + // 查询薪资核算人员 + List salaryAcctEmployees = getSalaryAcctEmployeeService(user).listByRecordIdsAndEmpIdAndTaxAgentId(salaryAcctRecordIds, null, taxAgents.stream().findFirst().orElse(new TaxAgentPO()).getId()); + // 薪资核算人员按照税款所属期聚合分类 + Map> taxCycleKeyEmployeeMap = SalaryEntityUtil.group2Map(salaryAcctEmployees, SalaryAcctEmployeePO::getTaxCycle); + for (Map.Entry> taxCycleEntry : taxCycleKeyEmployeeMap.entrySet()) { + // 薪资核算人员按照个税扣缴义务人id聚合分类 + Map> taxAgentIdKeyEmployeeMap = SalaryEntityUtil.group2Map(taxCycleEntry.getValue(), SalaryAcctEmployeePO::getTaxAgentId); + for (Map.Entry> taxAgentIdEntry : taxAgentIdKeyEmployeeMap.entrySet()) { + TaxDeclareRecordPO oldTaxDeclareRecord = taxDeclareRecordMap.get(taxCycleEntry.getKey() + "-" + taxAgentIdEntry.getKey()); + // 如果已经生成了个税申报表,并且个税申报表已经申报过了,就跳过 + if (oldTaxDeclareRecord != null) { + if (!(Objects.equals(oldTaxDeclareRecord.getTaxDeclareType(), TaxDeclareTypeEnum.NORMAL_DECLARE.getValue()) && Objects.equals(oldTaxDeclareRecord.getTaxDeclareStatus(), TaxDeclareStatusEnum.NOT_DECLARE.getValue()))) { + continue; + } + needDeleteTaxDeclareRecordIds.add(oldTaxDeclareRecord.getId()); + } + TaxDeclareRecordPO taxDeclareRecord = new TaxDeclareRecordPO().setId(IdGenerator.generate()).setTaxAgentId(taxAgentIdEntry.getKey()).setSalaryMonth(SalaryDateUtil.localDateToDate(saveParam.getSalaryMonth().atDay(1))).setTaxCycle(taxCycleEntry.getKey()).setTaxDeclareType(TaxDeclareTypeEnum.NORMAL_DECLARE.getValue()).setTaxDeclareStatus(TaxDeclareStatusEnum.NOT_DECLARE.getValue()).setRemark(saveParam.getDescription()).setCreator((long) user.getUID()).setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()).setCreateTime(now).setUpdateTime(now); + newTaxDeclareRecords.add(taxDeclareRecord); + // 生成个税申报表 + TaxDeclarationResult taxDeclarationResult = generateReportPerRecord(taxDeclareRecord, taxAgentIdEntry.getValue()); + newTaxDeclarations.addAll(taxDeclarationResult.getTaxDeclarations()); + newTaxDeclarationValues.addAll(taxDeclarationResult.getTaxDeclarationValues()); + newAddUpSituations.addAll(taxDeclarationResult.getAddUpSituations()); + } + } + + // 删除原来生成的个税申报记录、个税申报表、个税申报表明细 + deleteByIds(needDeleteTaxDeclareRecordIds); + // 保存个税申报记录 + if (CollectionUtils.isNotEmpty(newTaxDeclareRecords)) { + getTaxDeclareRecordMapper().batchInsert(newTaxDeclareRecords); + } + // 保存个税申报表 + if (CollectionUtils.isNotEmpty(newTaxDeclarations)) { + getTaxDeclarationService(user).saveBatch(newTaxDeclarations); + } + // 保存个税申报表明细 + if (CollectionUtils.isNotEmpty(newTaxDeclarationValues)) { + getTaxDeclarationValueService(user).batchSave(newTaxDeclarationValues); + } + // 保存累计情况 + if (CollectionUtils.isNotEmpty(newAddUpSituations)) { + Map> addUpSituationMap = SalaryEntityUtil.group2Map(newAddUpSituations, e -> SalaryDateUtil.getFormatYearMonth(e.getTaxYearMonth())); + for (Map.Entry> entry : addUpSituationMap.entrySet()) { + getAddUpSituationService(user).deleteByTaxYearMonthAndTaxAgentIds(YearMonth.parse(entry.getKey()), SalaryEntityUtil.properties(entry.getValue(), AddUpSituation::getTaxAgentId)); + getAddUpSituationService(user).batchSave(entry.getValue()); + } + } // // 记录日志 // for (TaxDeclareRecordPO taxDeclareRecord : newTaxDeclareRecords) { // LoggerContext loggerContext = new LoggerContext<>(); @@ -307,49 +305,41 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe if (Objects.isNull(taxDeclareRecord)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156495, "参数异常,个税申报记录不存在或已被删除")); } - if (!Objects.equals(taxDeclareRecord.getTaxDeclareStatus(), TaxDeclareStatusEnum.NOT_DECLARE.getValue()) - && !Objects.equals(taxDeclareRecord.getTaxDeclareStatus(), TaxDeclareStatusEnum.DECLARE_FAIL.getValue())) { + if (!Objects.equals(taxDeclareRecord.getTaxDeclareStatus(), TaxDeclareStatusEnum.NOT_DECLARE.getValue()) && !Objects.equals(taxDeclareRecord.getTaxDeclareStatus(), TaxDeclareStatusEnum.DECLARE_FAIL.getValue())) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(182700, "对不起,只有未申报状态下可以刷新数据")); } // 查询税款所属期下的薪资核算人员 - SalaryAcctEmployeeQueryParam salaryAcctEmployeeQueryParam = SalaryAcctEmployeeQueryParam.builder() - .taxAgentIds(Collections.singletonList(taxDeclareRecord.getTaxAgentId())) - .taxCycle(taxDeclareRecord.getTaxCycle()) - .build(); - List salaryAcctEmployees = salaryAcctEmployeeService.listByParam(salaryAcctEmployeeQueryParam); + SalaryAcctEmployeeQueryParam salaryAcctEmployeeQueryParam = SalaryAcctEmployeeQueryParam.builder().taxAgentIds(Collections.singletonList(taxDeclareRecord.getTaxAgentId())).taxCycle(taxDeclareRecord.getTaxCycle()).build(); + List salaryAcctEmployees = getSalaryAcctEmployeeService(user).listByParam(salaryAcctEmployeeQueryParam); // 查询薪资核算记录 Set salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctEmployees, SalaryAcctEmployeePO::getSalaryAcctRecordId); - List salaryAcctRecords = salaryAcctRecordService.listByIds(salaryAcctRecordIds); + List salaryAcctRecords = getSalaryAcctRecordService(user).listByIds(salaryAcctRecordIds); // 如果存在未归档的薪资核算记录,不允许生成个税申报表 - boolean notArchived = salaryAcctRecords.stream() - .anyMatch(salaryAcctRecordPO -> Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())); + boolean notArchived = salaryAcctRecords.stream().anyMatch(salaryAcctRecordPO -> Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())); if (notArchived) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98875, "{0}有未归档数据,请全部归档后再申报") - .replace("{0}", SalaryDateUtil.getFormatYearMonth(taxDeclareRecord.getSalaryMonth()))); + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98875, "{0}有未归档数据,请全部归档后再申报").replace("{0}", SalaryDateUtil.getFormatYearMonth(taxDeclareRecord.getSalaryMonth()))); } TaxDeclarationResult taxDeclarationResult = generateReportPerRecord(taxDeclareRecord, salaryAcctEmployees); // 更新个税申报记录 taxDeclareRecord.setDisplayUpdateIcon(0).setUpdateTime(new Date()); - taxDeclareRecordMapper.updateIgnoreNull(taxDeclareRecord); + getTaxDeclareRecordMapper().updateIgnoreNull(taxDeclareRecord); // 删除原来的申报表,保存新生成的 - taxDeclarationService.deleteByTaxDeclareRecordIds(Collections.singleton(taxDeclareRecord.getId())); + getTaxDeclarationService(user).deleteByTaxDeclareRecordIds(Collections.singleton(taxDeclareRecord.getId())); if (CollectionUtils.isNotEmpty(taxDeclarationResult.getTaxDeclarations())) { - taxDeclarationService.saveBatch(taxDeclarationResult.getTaxDeclarations()); + getTaxDeclarationService(user).saveBatch(taxDeclarationResult.getTaxDeclarations()); } // 删除原来的申报表明细,保存新生成的 - taxDeclarationValueService.deleteByTaxDeclareRecordIds(Collections.singleton(taxDeclareRecord.getId())); + getTaxDeclarationValueService(user).deleteByTaxDeclareRecordIds(Collections.singleton(taxDeclareRecord.getId())); if (CollectionUtils.isNotEmpty(taxDeclarationResult.getTaxDeclarationValues())) { - taxDeclarationValueService.batchSave(taxDeclarationResult.getTaxDeclarationValues()); + getTaxDeclarationValueService(user).batchSave(taxDeclarationResult.getTaxDeclarationValues()); } // 保存累计情况 if (CollectionUtils.isNotEmpty(taxDeclarationResult.getAddUpSituations())) { - Map> addUpSituationMap = SalaryEntityUtil.group2Map(taxDeclarationResult.getAddUpSituations(), - e -> SalaryDateUtil.getFormatYearMonth(e.getTaxYearMonth())); + Map> addUpSituationMap = SalaryEntityUtil.group2Map(taxDeclarationResult.getAddUpSituations(), e -> SalaryDateUtil.getFormatYearMonth(e.getTaxYearMonth())); for (Map.Entry> entry : addUpSituationMap.entrySet()) { - addUpSituationService.deleteByTaxYearMonthAndTaxAgentIds(YearMonth.parse(entry.getKey()), - SalaryEntityUtil.properties(entry.getValue(), AddUpSituation::getTaxAgentId)); - addUpSituationService.batchSave(entry.getValue()); + getAddUpSituationService(user).deleteByTaxYearMonthAndTaxAgentIds(YearMonth.parse(entry.getKey()), SalaryEntityUtil.properties(entry.getValue(), AddUpSituation::getTaxAgentId)); + getAddUpSituationService(user).batchSave(entry.getValue()); } } } @@ -360,77 +350,42 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe List taxDeclarationValues = Lists.newArrayList(); List addUpSituations = Lists.newArrayList(); // 查询薪资项目 - List salaryItems = salaryItemService.listAll(); + List salaryItems = getSalaryItemService(user).listAll(); // 查询个税申报表列 - List taxReportColumns = taxReportColumnService.listAll(); + List taxReportColumns = getTaxReportColumnService(user).listAll(); Map> taxReportColumnMap = SalaryEntityUtil.group2Map(taxReportColumns, TaxReportColumnPO::getIncomeCategory); // 查询薪资核算记录 Set salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctEmployees, SalaryAcctEmployeePO::getSalaryAcctRecordId); - List salaryAcctRecords = salaryAcctRecordService.listByIds(salaryAcctRecordIds); + List salaryAcctRecords = getSalaryAcctRecordService(user).listByIds(salaryAcctRecordIds); Map salaryAcctRecordMap = SalaryEntityUtil.convert2Map(salaryAcctRecords, SalaryAcctRecordPO::getId); // 查询薪资核算结果 Set salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployees, SalaryAcctEmployeePO::getId); - List salaryAcctResultValues = salaryAcctResultValueService.listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds); + List salaryAcctResultValues = getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds); // 查询薪资账套的累计字段对应关系 Set salarySobIds = SalaryEntityUtil.properties(salaryAcctEmployees, SalaryAcctEmployeePO::getSalarySobId); List salarySobAddUpRules = salarySobAddUpRuleService.listBySalarySobIds(salarySobIds); - Map salarySobAddUpRuleMap = SalaryEntityUtil.convert2Map(salarySobAddUpRules, - e -> e.getSalarySobId() + "-" + e.getAddUpColumnDataIndex()); + Map salarySobAddUpRuleMap = SalaryEntityUtil.convert2Map(salarySobAddUpRules, e -> e.getSalarySobId() + "-" + e.getAddUpColumnDataIndex()); // 查询薪资账套的个税申报表对应规则 List salarySobTaxReportRules = salarySobTaxReportRuleService.listBySalarySobIds(salarySobIds); Map salarySobTaxReportRuleMap = SalaryEntityUtil.convert2Map(salarySobTaxReportRules, e -> e.getSalarySobId() + "-" + e.getReportColumnDataIndex()); // 薪资核算结果按照薪资核算人员id聚合分类 - Map> salaryAcctResultValueMap = SalaryEntityUtil.group2Map( - salaryAcctResultValues, SalaryAcctResultPO::getSalaryAcctEmpId); + Map> salaryAcctResultValueMap = SalaryEntityUtil.group2Map(salaryAcctResultValues, SalaryAcctResultPO::getSalaryAcctEmpId); // 薪资核算人员按照所得项目聚合分类 - Map> incomeCategoryKeyEmployeeMap = SalaryEntityUtil.group2Map( - salaryAcctEmployees, SalaryAcctEmployeePO::getIncomeCategory); + Map> incomeCategoryKeyEmployeeMap = SalaryEntityUtil.group2Map(salaryAcctEmployees, SalaryAcctEmployeePO::getIncomeCategory); for (Map.Entry> incomeCategoryEntry : incomeCategoryKeyEmployeeMap.entrySet()) { - List controlViewSalaryAcctRecords = incomeCategoryEntry.getValue().stream() - .map(e -> salaryAcctRecordMap.get(e.getSalaryAcctRecordId())) - .distinct() - .filter(e -> Objects.equals(e.getControlView(), 1)) - .collect(Collectors.toList()); - TaxDeclarationPO taxDeclaration = TaxDeclarationPO.builder() - .id(IdGenerator.generate()) - .taxDeclareRecordId(taxDeclareRecord.getId()) - .incomeCategory(Util.getIntValue(incomeCategoryEntry.getKey())) - .taxAgentId(taxDeclareRecord.getTaxAgentId()) - .salaryMonth(taxDeclareRecord.getSalaryMonth()) - .taxCycle(taxDeclareRecord.getTaxCycle()) - .description(taxDeclareRecord.getRemark()) - .controlView(CollectionUtils.isEmpty(controlViewSalaryAcctRecords) ? 0 : 1) - .creator((long) user.getUID()) - .createTime(now) - .updateTime(now) - .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) - .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) - .build(); + List controlViewSalaryAcctRecords = incomeCategoryEntry.getValue().stream().map(e -> salaryAcctRecordMap.get(e.getSalaryAcctRecordId())).distinct().filter(e -> Objects.equals(e.getControlView(), 1)).collect(Collectors.toList()); + TaxDeclarationPO taxDeclaration = TaxDeclarationPO.builder().id(IdGenerator.generate()).taxDeclareRecordId(taxDeclareRecord.getId()).incomeCategory(Util.getIntValue(incomeCategoryEntry.getKey())).taxAgentId(taxDeclareRecord.getTaxAgentId()).salaryMonth(taxDeclareRecord.getSalaryMonth()).taxCycle(taxDeclareRecord.getTaxCycle()).description(taxDeclareRecord.getRemark()).controlView(CollectionUtils.isEmpty(controlViewSalaryAcctRecords) ? 0 : 1).creator((long) user.getUID()).createTime(now).updateTime(now).deleteType(DeleteTypeEnum.NOT_DELETED.getValue()).tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).build(); taxDeclarations.add(taxDeclaration); // 薪资核算结果 Set salaryAcctEmployeeIdSet = SalaryEntityUtil.properties(incomeCategoryEntry.getValue(), SalaryAcctEmployeePO::getId); - List> resultValues = salaryAcctEmployeeIdSet.stream() - .map(salaryAcctResultValueMap::get) - .filter(Objects::nonNull) - .collect(Collectors.toList()); - TaxDeclareContext taxDeclareContext = new TaxDeclareContext() - .setSalaryAcctRecordMap(salaryAcctRecordMap) - .setSalaryAcctEmployees(incomeCategoryEntry.getValue()) - .setSalaryAcctResultValues(salaryAcctResultValues) - .setTaxDeclaration(taxDeclaration) - .setSalarySobTaxReportRuleMap(salarySobTaxReportRuleMap) - .setSalarySobAddUpRuleMap(salarySobAddUpRuleMap) - .setTaxReportColumns(taxReportColumnMap.get(incomeCategoryEntry.getKey())) - .setSalaryItems(salaryItems); + List> resultValues = salaryAcctEmployeeIdSet.stream().map(salaryAcctResultValueMap::get).filter(Objects::nonNull).collect(Collectors.toList()); + TaxDeclareContext taxDeclareContext = new TaxDeclareContext().setSalaryAcctRecordMap(salaryAcctRecordMap).setSalaryAcctEmployees(incomeCategoryEntry.getValue()).setSalaryAcctResultValues(salaryAcctResultValues).setTaxDeclaration(taxDeclaration).setSalarySobTaxReportRuleMap(salarySobTaxReportRuleMap).setSalarySobAddUpRuleMap(salarySobAddUpRuleMap).setTaxReportColumns(taxReportColumnMap.get(incomeCategoryEntry.getKey())).setSalaryItems(salaryItems); TaxDeclarationStrategy taxDeclarationStrategy = new TaxDeclarationCommon(); TaxDeclarationGenerateResult generateResult = taxDeclarationStrategy.generate(taxDeclareContext, (long) user.getUID()); taxDeclarationValues.addAll(generateResult.getTaxDeclarationValues()); addUpSituations.addAll(generateResult.getAddUpSituations()); } - return new TaxDeclarationResult() - .setTaxDeclarations(taxDeclarations) - .setTaxDeclarationValues(taxDeclarationValues) - .setAddUpSituations(addUpSituations); + return new TaxDeclarationResult().setTaxDeclarations(taxDeclarations).setTaxDeclarationValues(taxDeclarationValues).setAddUpSituations(addUpSituations); } /** @@ -441,73 +396,59 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe * @param salaryAcctRecords * @param salaryAcctTaxAgents */ - private List checkBeforeSave(TaxDeclarationSaveParam saveParam, - Map taxAgentNameMap, - List salaryAcctRecords, - List salaryAcctTaxAgents) { + private List checkBeforeSave(TaxDeclarationSaveParam saveParam, Map taxAgentNameMap, List salaryAcctRecords, List salaryAcctTaxAgents) { List resultList = Lists.newArrayList(); // 如果存在未归档的薪资核算记录,不允许生成个税申报表 - boolean notArchived = salaryAcctRecords.stream() - .anyMatch(salaryAcctRecordPO -> Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())); + boolean notArchived = salaryAcctRecords.stream().anyMatch(salaryAcctRecordPO -> Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())); if (notArchived) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98875, "{0}有未归档数据,请全部归档后再申报") - .replace("{0}", saveParam.getSalaryMonth().toString())); + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98875, "{0}有未归档数据,请全部归档后再申报").replace("{0}", saveParam.getSalaryMonth().toString())); } // 查询已归档的薪资核算记录 - List archivedSalaryAcctRecords = salaryAcctRecords.stream() - .filter(salaryAcctRecordPO -> Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue())) - .collect(Collectors.toList()); + List archivedSalaryAcctRecords = salaryAcctRecords.stream().filter(salaryAcctRecordPO -> Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue())).collect(Collectors.toList()); // 无已归档的薪资核算记录,不允许生成个税申报表 if (CollectionUtils.isEmpty(archivedSalaryAcctRecords)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(177860, "{0}无可申报数据") - .replace("{0}", saveParam.getSalaryMonth().toString())); + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(177860, "{0}无可申报数据").replace("{0}", saveParam.getSalaryMonth().toString())); } // 查询已归档的薪资核算记录是否已经生成过个税申报表 Map> taxCycleKeySalaryAcctTaxAgentMap = SalaryEntityUtil.group2Map(salaryAcctTaxAgents, SalaryAcctTaxAgentPO::getTaxCycle); for (Map.Entry> taxCycleEntry : taxCycleKeySalaryAcctTaxAgentMap.entrySet()) { Set archivedTaxAgentIds = SalaryEntityUtil.properties(taxCycleEntry.getValue(), SalaryAcctTaxAgentPO::getTaxAgentId); List taxDeclareRecords = listBySalaryMonthAndTaxAgentIds(SalaryDateUtil.localDateToDate(saveParam.getSalaryMonth().atDay(1)), archivedTaxAgentIds); - TaxDeclareRecordPO declareSuccessTaxDeclareRecord = taxDeclareRecords.stream() - .filter(taxDeclareRecordPO -> archivedTaxAgentIds.contains(taxDeclareRecordPO.getTaxAgentId()) - && !(Objects.equals(taxDeclareRecordPO.getTaxDeclareStatus(), TaxDeclareStatusEnum.NOT_DECLARE.getValue()) - || Objects.equals(taxDeclareRecordPO.getTaxDeclareStatus(), TaxDeclareStatusEnum.DECLARE_FAIL.getValue()))) - .findAny() - .orElse(null); + TaxDeclareRecordPO declareSuccessTaxDeclareRecord = taxDeclareRecords.stream().filter(taxDeclareRecordPO -> archivedTaxAgentIds.contains(taxDeclareRecordPO.getTaxAgentId()) && !(Objects.equals(taxDeclareRecordPO.getTaxDeclareStatus(), TaxDeclareStatusEnum.NOT_DECLARE.getValue()) || Objects.equals(taxDeclareRecordPO.getTaxDeclareStatus(), TaxDeclareStatusEnum.DECLARE_FAIL.getValue()))).findAny().orElse(null); // 已经申报成功了的个税申报表的个税扣缴义务人不允许重新生成 if (Objects.nonNull(declareSuccessTaxDeclareRecord)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(160522, "已开启智能算薪业务,个税扣缴义务人{0}的税款所属期{1}的个税申报表正在申报中或者已经申报成功,不可重复生成") - .replace("{0}", taxAgentNameMap.get(declareSuccessTaxDeclareRecord.getTaxAgentId())) - .replace("{1}", SalaryDateUtil.getFormatYearMonth(declareSuccessTaxDeclareRecord.getTaxCycle()))); + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(160522, "已开启智能算薪业务,个税扣缴义务人{0}的税款所属期{1}的个税申报表正在申报中或者已经申报成功,不可重复生成").replace("{0}", taxAgentNameMap.get(declareSuccessTaxDeclareRecord.getTaxAgentId())).replace("{1}", SalaryDateUtil.getFormatYearMonth(declareSuccessTaxDeclareRecord.getTaxCycle()))); } resultList.addAll(taxDeclareRecords); } return resultList; } - // /** -// * 根据个税扣缴义务人范围查询个税扣缴义务人 -// * -// * @param saveParam -// * @return -// */ -// private List queryByTaxAgentRange(TaxDeclarationSaveParam saveParam) { -// List taxAgents; -// if (saveParam.getTaxAgentRange() == TaxAgentRangeEnum.ALL_TAX_AGENT) { -// // 判断当前是否开启了分权 -// Boolean openDevolution = taxAgentService.isOpenDevolution(tenantKey); -// // 判断是否是总管理员 -// Boolean isChief = taxAgentService.isChief(employeeId); -// if (openDevolution && !isChief) { -// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(160523, "对不起,您不是薪酬模块的总管理员,不具备生成所有个税扣缴义务人的权限")); -// } -// taxAgents = taxAgentService.listAll(tenantKey); -// } else if (saveParam.getTaxAgentRange() == TaxAgentRangeEnum.ADMIN_TAX_AGENT) { -// taxAgents = taxAgentService.listAllTaxAgentsAsAdmin(employeeId); -// } else { -// taxAgents = taxAgentService.listByIds(saveParam.getTaxAgentIds()); -// } -// return taxAgents; -// } + /** + * 根据个税扣缴义务人范围查询个税扣缴义务人 + * + * @param saveParam + * @return + */ + private Collection queryByTaxAgentRange(TaxDeclarationSaveParam saveParam) { + Collection taxAgents; + if (saveParam.getTaxAgentRange() == TaxAgentRangeEnum.ALL_TAX_AGENT) { + // 判断当前是否开启了分权 + Boolean openDevolution = getTaxAgentService(user).isOpenDevolution(); + // 判断是否是总管理员 + Boolean isChief = getTaxAgentService(user).isChief((long) user.getUID()); + if (openDevolution && !isChief) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(160523, "对不起,您不是薪酬模块的总管理员,不具备生成所有个税扣缴义务人的权限")); + } + taxAgents = getTaxAgentService(user).listAll(); + } else if (saveParam.getTaxAgentRange() == TaxAgentRangeEnum.ADMIN_TAX_AGENT) { + taxAgents = getTaxAgentService(user).listAllTaxAgentsAsAdmin((long) user.getUID()); + } else { + taxAgents = getTaxAgentService(user).listByIds(saveParam.getTaxAgentIds()); + } + return taxAgents; + } + @Override public void updateIcon(Long id, Integer displayIcon) { TaxDeclareRecordPO taxDeclareRecord = getById(id); @@ -516,7 +457,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe } taxDeclareRecord.setDisplayUpdateIcon(displayIcon); taxDeclareRecord.setUpdateTime(new Date()); - taxDeclareRecordMapper.update(taxDeclareRecord); + getTaxDeclareRecordMapper().update(taxDeclareRecord); } @Override @@ -531,7 +472,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe Date now = new Date(); taxDeclareRecords.forEach(e -> { e.setDisplayUpdateIcon(1).setUpdateTime(now); - taxDeclareRecordMapper.update(e); + getTaxDeclareRecordMapper().update(e); }); } @@ -542,16 +483,16 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe // return false; // } // // 判断是否开启了分权 -// Boolean openDevolution = taxAgentService.isOpenDevolution(tenantKey); +// Boolean openDevolution = getTaxAgentService(user).isOpenDevolution(tenantKey); // // 判断是否是总管理员 -// Boolean isChief = taxAgentService.isChief(employeeId); +// Boolean isChief = getTaxAgentService(user).isChief(employeeId); // // 可见范围内的个税扣缴义务人 // List taxAgents = Lists.newArrayList(); // if (openDevolution) { // if (isChief) { -// taxAgents = taxAgentService.listAsChief(true, true); +// taxAgents = getTaxAgentService(user).listAsChief(true, true); // } else { -// taxAgents = taxAgentService.listAllTaxAgentsAsAdmin(employeeId); +// taxAgents = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId); // } // if (CollectionUtils.isEmpty(taxAgents)) { // return false; @@ -572,25 +513,22 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe if (CollectionUtils.isEmpty(taxDeclareRecords)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(160524, "个税申报表不存在或已被删除")); } - List cantDeleteTaxDeclareRecords = taxDeclareRecords.stream() - .filter(e -> !(Objects.equals(e.getTaxDeclareType(), TaxDeclareTypeEnum.NORMAL_DECLARE.getValue()) - && Objects.equals(e.getTaxDeclareStatus(), TaxDeclareStatusEnum.NOT_DECLARE.getValue()))) - .collect(Collectors.toList()); + List cantDeleteTaxDeclareRecords = taxDeclareRecords.stream().filter(e -> !(Objects.equals(e.getTaxDeclareType(), TaxDeclareTypeEnum.NORMAL_DECLARE.getValue()) && Objects.equals(e.getTaxDeclareStatus(), TaxDeclareStatusEnum.NOT_DECLARE.getValue()))).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(cantDeleteTaxDeclareRecords)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(177854, "个税申报表已经申报,无法删除")); } - taxDeclareRecordMapper.deleteByIds(ids); + getTaxDeclareRecordMapper().deleteByIds(ids); // 删除个税申报表 - taxDeclarationService.deleteByTaxDeclareRecordIds(ids); + getTaxDeclarationService(user).deleteByTaxDeclareRecordIds(ids); // 删除个税申报表明细 - taxDeclarationValueService.deleteByTaxDeclareRecordIds(ids); + getTaxDeclarationValueService(user).deleteByTaxDeclareRecordIds(ids); // 记录日志 // writeDeleteLog(taxDeclareRecords); } // private void writeDeleteLog(List taxDeclareRecords) { // // 记录日志 -// List taxAgents = taxAgentService.listByIds(SalaryEntityUtil.properties(taxDeclareRecords, TaxDeclareRecordPO::getTaxAgentId)); +// List taxAgents = getTaxAgentService(user).listByIds(SalaryEntityUtil.properties(taxDeclareRecords, TaxDeclareRecordPO::getTaxAgentId)); // Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getId, TaxAgentPO::getName); // for (TaxDeclareRecordPO taxDeclareRecord : taxDeclareRecords) { // LoggerContext loggerContext = new LoggerContext<>(); @@ -617,37 +555,31 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe } // 查询个税申报表 - List taxDeclarations = taxDeclarationService.listByTaxCycleAndTaxAgentIds(SalaryDateUtil.localDate2YearMonth(taxDeclareRecord.getTaxCycle()), Collections.singleton(taxDeclareRecord.getTaxAgentId())); + List taxDeclarations = getTaxDeclarationService(user).listByTaxCycleAndTaxAgentIds(SalaryDateUtil.localDate2YearMonth(taxDeclareRecord.getTaxCycle()), Collections.singleton(taxDeclareRecord.getTaxAgentId())); if (CollectionUtils.isEmpty(taxDeclarations)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156494, "当前无可申报的数据")); } - AbnormalEmployeeListQueryParam queryParam = new AbnormalEmployeeListQueryParam() - .setTaxDeclareRecordId(taxDeclareRecord.getId()) - .setTaxAgentId(taxDeclareRecord.getTaxAgentId()) - .setTaxCycle(taxDeclareRecord.getTaxCycle()); + AbnormalEmployeeListQueryParam queryParam = new AbnormalEmployeeListQueryParam().setTaxDeclareRecordId(taxDeclareRecord.getId()).setTaxAgentId(taxDeclareRecord.getTaxAgentId()).setTaxCycle(taxDeclareRecord.getTaxCycle()); // 查询是否存在有未报送的人 - List notDeclareTaxDeclareEmployees = taxDeclareEmployeeService.list4NotDeclareByParam(queryParam); + List notDeclareTaxDeclareEmployees = getTaxDeclareEmployeeService(user).list4NotDeclareByParam(queryParam); if (CollectionUtils.isNotEmpty(notDeclareTaxDeclareEmployees)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(162125, "存在有未报送的人,请先报送相关人员后再申报个税")); } // 查询是否存在没有申报数据的人 - List noValueTaxDeclareEmployees = taxDeclareEmployeeService.list4NoValueByParam(queryParam); + List noValueTaxDeclareEmployees = getTaxDeclareEmployeeService(user).list4NoValueByParam(queryParam); if (CollectionUtils.isNotEmpty(noValueTaxDeclareEmployees)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(160535, "存在没有申报数据的人,请重新核算这些人的薪资后再来申报个税")); } // 查询个税申报表的申报数据 Set taxDeclarationIds = SalaryEntityUtil.properties(taxDeclarations, TaxDeclarationPO::getId); - List taxDeclarationValues = taxDeclarationValueService.listByTaxDeclarationIds(taxDeclarationIds); + List taxDeclarationValues = getTaxDeclarationValueService(user).listByTaxDeclarationIds(taxDeclarationIds); // 查询本税款所属期内报送成功的人员 - List employeeDeclares = employeeDeclareService.listByTaxCycleAndTaxAgentId(taxDeclareRecord.getTaxCycle(), - taxDeclareRecord.getTaxAgentId()); - employeeDeclares = employeeDeclares.stream() - .filter(e -> Objects.equals(e.getDeclareStatus(), DeclareStatusEnum.DECLARE_SUCCESS.getValue())) - .collect(Collectors.toList()); + List employeeDeclares = getEmployeeDeclareService(user).listByTaxCycleAndTaxAgentId(taxDeclareRecord.getTaxCycle(), taxDeclareRecord.getTaxAgentId()); + employeeDeclares = employeeDeclares.stream().filter(e -> Objects.equals(e.getDeclareStatus(), DeclareStatusEnum.DECLARE_SUCCESS.getValue())).collect(Collectors.toList()); TaxDeclarationApiConfigPO apiConfig = taxDeclareRequest.getTaxDeclarationApiConfig(); // 查询个税申报表的表头 - List taxReportColumns = taxReportColumnService.listAll(); + List taxReportColumns = getTaxReportColumnService(user).listAll(); // 注册的企业信息-->请求参数 Map requestParam = taxDeclareRequest.getRequestParam(); // 税款所属期 @@ -675,9 +607,9 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe taxDeclareRecord.setTaxDeclareStatus(TaxDeclareStatusEnum.DECLARING.getValue()); taxDeclareRecord.setRequestId(declareTaxResponse.getBody().getRequestId()); taxDeclareRecord.setUpdateTime(new Date()); - taxDeclareRecordMapper.updateIgnoreNull(taxDeclareRecord); + getTaxDeclareRecordMapper().updateIgnoreNull(taxDeclareRecord); // 删除个税申报申报失败的数据 - taxDeclareFailService.deleteByTaxDeclareRecordIds(Collections.singleton(taxDeclareRecord.getId())); + getTaxDeclareFailService(user).deleteByTaxDeclareRecordIds(Collections.singleton(taxDeclareRecord.getId())); // 记录日志 // TaxAgentPO taxAgent = taxDeclareRequest.getTaxAgent(); @@ -721,14 +653,10 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156509, "服务异常,接口返回数据有误")); } // 查询报送的人员 - List employeeDeclares = employeeDeclareService.listByTaxCycleAndTaxAgentId( - taxDeclareRecord.getTaxCycle(), - taxDeclareRecord.getTaxAgentId()); - Map employeeInfoMap = SalaryEntityUtil.convert2Map(employeeDeclares, - e -> e.getEmployeeName() + "-" + e.getCardNum()); + List employeeDeclares = getEmployeeDeclareService(user).listByTaxCycleAndTaxAgentId(taxDeclareRecord.getTaxCycle(), taxDeclareRecord.getTaxAgentId()); + Map employeeInfoMap = SalaryEntityUtil.convert2Map(employeeDeclares, e -> e.getEmployeeName() + "-" + e.getCardNum()); // 流量统计 - TaxDeclarationApiBillingServiceImpl.ApiFlowUpdateWrapper apiFlowUpdateWrapper - = new TaxDeclarationApiBillingServiceImpl.ApiFlowUpdateWrapper(taxDeclareRecord.getTaxCycle(), apiConfig, EnumDeclareApiBusinessType.TAX_DECLARATION); + TaxDeclarationApiBillingServiceImpl.ApiFlowUpdateWrapper apiFlowUpdateWrapper = new TaxDeclarationApiBillingServiceImpl.ApiFlowUpdateWrapper(taxDeclareRecord.getTaxCycle(), apiConfig, EnumDeclareApiBusinessType.TAX_DECLARATION); Date now = new Date(); List errorMsg = Lists.newArrayList(); @@ -745,19 +673,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe String employeeName = Util.null2String(detail.get(0)); String cardNum = Util.null2String(detail.get(2)); String incomeCategoryCode = Util.null2String(detail.get(4)); - TaxDeclareFailPO taxDeclareFailPO = TaxDeclareFailPO.builder() - .id(IdGenerator.generate()) - .taxDeclareRecordId(taxDeclareRecord.getId()) - .employeeName(employeeName) - .cardNum(cardNum) - .incomeCategory(incomeCategoryCode) - .errorMsg(msg) - .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) - .creator((long) user.getUID()) - .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) - .createTime(now) - .updateTime(now) - .build(); + TaxDeclareFailPO taxDeclareFailPO = TaxDeclareFailPO.builder().id(IdGenerator.generate()).taxDeclareRecordId(taxDeclareRecord.getId()).employeeName(employeeName).cardNum(cardNum).incomeCategory(incomeCategoryCode).errorMsg(msg).tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).creator((long) user.getUID()).deleteType(DeleteTypeEnum.NOT_DELETED.getValue()).createTime(now).updateTime(now).build(); taxDeclareFails.add(taxDeclareFailPO); // 流量使用记录 EmployeeDeclarePO employeeDeclarePO = employeeInfoMap.get(employeeName + "-" + cardNum); @@ -790,8 +706,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe taxDeclareRecord.setUpdateTime(new Date()); BigDecimal purePaidAmount = SalaryEntityUtil.empty2Zero(taxDeclareRecord.getTaxPurePaidAmount()); BigDecimal payAmount = SalaryEntityUtil.empty2Zero(taxDeclareRecord.getTaxPayAmount()); - if (TaxDeclareStatusEnum.DECLARE_SUCCESS_PAID.equals(taxDeclareStatusEnum) - || TaxDeclareStatusEnum.DECLARE_SUCCESS_NO_PAY.equals(taxDeclareStatusEnum)) { + if (TaxDeclareStatusEnum.DECLARE_SUCCESS_PAID.equals(taxDeclareStatusEnum) || TaxDeclareStatusEnum.DECLARE_SUCCESS_NO_PAY.equals(taxDeclareStatusEnum)) { // 如果是已缴纳状态,则更新已缴纳金额,判断是否需要线下退税 if (purePaidAmount.compareTo(payAmount) > 0) { taxDeclareRecord.setTaxPayAmount(payAmount.subtract(purePaidAmount).toString()); @@ -808,10 +723,10 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe taxDeclareRecord.setTaxPayAmount(payAmount.subtract(purePaidAmount).toString()); } // 更新个税申报记录 - taxDeclareRecordMapper.updateIgnoreNull(taxDeclareRecord); + getTaxDeclareRecordMapper().updateIgnoreNull(taxDeclareRecord); // 如果申报失败 if (CollectionUtils.isNotEmpty(taxDeclareFails)) { - taxDeclareFailService.saveBatch(taxDeclareFails); + getTaxDeclareFailService(user).saveBatch(taxDeclareFails); } // 更新流量使用记录 employeeInfoMap.forEach((key, value) -> { @@ -819,7 +734,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe flowDetailPO.setResultStatus(TaxAgentTaxReturnStatusEnum.SUCCESS.getValue()); apiFlowUpdateWrapper.getApiFlowDetailPOList().add(flowDetailPO); }); - taxDeclarationApiBillingService.updateApiFlowInfo(apiFlowUpdateWrapper); + getTaxDeclarationApiBillingService(user).updateApiFlowInfo(apiFlowUpdateWrapper); // 记录日志 // TaxAgentPO taxAgent = taxDeclareRequest.getTaxAgent(); @@ -844,8 +759,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(182701, "更正申报后不允许作废")); } // 只有申报成功,无需缴款/申报成功,未缴款的状态才能作废 - if (!Objects.equals(taxDeclareRecord.getTaxDeclareStatus(), TaxDeclareStatusEnum.DECLARE_SUCCESS_NO_PAY.getValue()) - && !Objects.equals(taxDeclareRecord.getTaxDeclareStatus(), TaxDeclareStatusEnum.DECLARE_SUCCESS_UNPAID.getValue())) { + if (!Objects.equals(taxDeclareRecord.getTaxDeclareStatus(), TaxDeclareStatusEnum.DECLARE_SUCCESS_NO_PAY.getValue()) && !Objects.equals(taxDeclareRecord.getTaxDeclareStatus(), TaxDeclareStatusEnum.DECLARE_SUCCESS_UNPAID.getValue())) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156497, "只有申报成功,无需缴款/申报成功,未缴款的状态才能作废")); } // 供应商信息 @@ -878,7 +792,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe taxDeclareRecord.setTaxDeclareStatus(TaxDeclareStatusEnum.DECLARE_CANCELLING.getValue()); taxDeclareRecord.setRequestId(declareTaxResponse.getBody().getRequestId()); taxDeclareRecord.setUpdateTime(new Date()); - taxDeclareRecordMapper.updateIgnoreNull(taxDeclareRecord); + getTaxDeclareRecordMapper().updateIgnoreNull(taxDeclareRecord); // // 记录日志 // TaxAgentPO taxAgent = taxDeclareRequest.getTaxAgent(); @@ -898,8 +812,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe public void getCancelFeedback(Long id, TaxDeclarationRateDTO taxDeclarationRate) { TaxDeclareRequest taxDeclareRequest = buildTaxDeclareRequest(id); TaxDeclareRecordPO taxDeclareRecord = taxDeclareRequest.getTaxDeclareRecord(); - if (!Objects.equals(taxDeclareRecord.getTaxDeclareStatus(), TaxDeclareStatusEnum.DECLARE_CANCELLING.getValue()) - || StringUtils.isEmpty(taxDeclareRecord.getRequestId())) { + if (!Objects.equals(taxDeclareRecord.getTaxDeclareStatus(), TaxDeclareStatusEnum.DECLARE_CANCELLING.getValue()) || StringUtils.isEmpty(taxDeclareRecord.getRequestId())) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156500, "请先点击「作废申报」后再来点击「申报反馈」按钮获取结果")); } // 供应商信息 @@ -917,24 +830,20 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe throw new SalaryRunTimeException(cancelDeclareFeedbackResponse.getHead().getMsg()); } // 作废是否成功 - CancelDeclareStatusEnum cancelDeclareStatusEnum = SalaryEnumUtil.enumMatchByValue( - SalaryEntityUtil.getIntValue(cancelDeclareFeedbackResponse.getBody().get("fkztbj"), 10), CancelDeclareStatusEnum.class); + CancelDeclareStatusEnum cancelDeclareStatusEnum = SalaryEnumUtil.enumMatchByValue(SalaryEntityUtil.getIntValue(cancelDeclareFeedbackResponse.getBody().get("fkztbj"), 10), CancelDeclareStatusEnum.class); if (cancelDeclareStatusEnum == CancelDeclareStatusEnum.CANCEL_FAIL) { String feedbackBody = Util.null2String(cancelDeclareFeedbackResponse.getBody().get("fknr")).replace("\\", ""); - List errorMsgList = JsonUtil.parseList(feedbackBody, Map.class).stream() - .map(e -> Util.null2String(e.get("msg"))) - .collect(Collectors.toList()); + List errorMsgList = JsonUtil.parseList(feedbackBody, Map.class).stream().map(e -> Util.null2String(e.get("msg"))).collect(Collectors.toList()); taxDeclarationRate.setStatus(false).setMsg(SalaryI18nUtil.getI18nLabel(156508, "作废失败:") + StringUtils.join(errorMsgList, ",")); } - TaxDeclareStatusEnum taxDeclareStatusEnum = SalaryEnumUtil.enumMatchByValue( - SalaryEntityUtil.getIntValue(cancelDeclareFeedbackResponse.getBody().get("sbztbj"), 1), TaxDeclareStatusEnum.class); + TaxDeclareStatusEnum taxDeclareStatusEnum = SalaryEnumUtil.enumMatchByValue(SalaryEntityUtil.getIntValue(cancelDeclareFeedbackResponse.getBody().get("sbztbj"), 1), TaxDeclareStatusEnum.class); if (taxDeclareStatusEnum == null) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156509, "服务异常,接口返回数据有误")); } taxDeclareRecord.setTaxDeclareStatus(taxDeclareStatusEnum.getValue()); taxDeclareRecord.setRequestId(""); taxDeclareRecord.setUpdateTime(new Date()); - taxDeclareRecordMapper.updateIgnoreNull(taxDeclareRecord); + getTaxDeclareRecordMapper().updateIgnoreNull(taxDeclareRecord); // 记录日志 // TaxAgentPO taxAgent = taxDeclareRequest.getTaxAgent(); @@ -954,11 +863,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe public void updateDeclare(Long id) { TaxDeclareRequest taxDeclareRequest = buildTaxDeclareRequest(id); TaxDeclareRecordPO taxDeclareRecord = taxDeclareRequest.getTaxDeclareRecord(); - List taxDeclareStatusEnumValueList = Lists.newArrayList( - TaxDeclareStatusEnum.DECLARE_SUCCESS_UNPAID.getValue(), - TaxDeclareStatusEnum.DECLARE_SUCCESS_NO_PAY.getValue(), - TaxDeclareStatusEnum.DECLARE_SUCCESS_PAID.getValue(), - TaxDeclareStatusEnum.DECLARE_SUCCESS_PAYING.getValue()); + List taxDeclareStatusEnumValueList = Lists.newArrayList(TaxDeclareStatusEnum.DECLARE_SUCCESS_UNPAID.getValue(), TaxDeclareStatusEnum.DECLARE_SUCCESS_NO_PAY.getValue(), TaxDeclareStatusEnum.DECLARE_SUCCESS_PAID.getValue(), TaxDeclareStatusEnum.DECLARE_SUCCESS_PAYING.getValue()); if (!taxDeclareStatusEnumValueList.contains(taxDeclareRecord.getTaxDeclareStatus())) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(182702, "对不起,只有申报成功后才允许更正申报")); } @@ -989,7 +894,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe taxDeclareRecord.setTaxDeclareStatus(TaxDeclareStatusEnum.NOT_DECLARE.getValue()); taxDeclareRecord.setRequestId(""); taxDeclareRecord.setUpdateTime(new Date()); - taxDeclareRecordMapper.updateIgnoreNull(taxDeclareRecord); + getTaxDeclareRecordMapper().updateIgnoreNull(taxDeclareRecord); // 记录日志 // TaxAgentPO taxAgent = taxDeclareRequest.getTaxAgent(); @@ -1051,7 +956,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe private TaxDeclareRequest buildTaxDeclareRequest(Long id) { // 查询供应商信息 - TaxDeclarationApiConfigPO apiConfig = taxDeclarationApiConfigService.getConfig(true); + TaxDeclarationApiConfigPO apiConfig = getTaxDeclarationApiConfigService(user).getConfig(true); if (apiConfig == null) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(160525, "接口流量不足,暂无法使用该功能,请先购买智能算薪接口流量")); } @@ -1061,18 +966,15 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156495, "参数异常,个税申报记录不存在或已被删除")); } // 查询个税扣缴义务人 - TaxAgentPO taxAgent = taxAgentService.getById(taxDeclareRecord.getTaxAgentId()); + TaxAgentPO taxAgent = getTaxAgentService(user).getById(taxDeclareRecord.getTaxAgentId()); // 查询个税扣缴义务人关联的企业信息 - TaxAgentTaxReturnPO taxAgentTaxReturn = taxAgentTaxReturnService.getByTaxAgentId(taxDeclareRecord.getTaxAgentId()); + TaxAgentTaxReturnPO taxAgentTaxReturn = getTaxAgentTaxReturnService(user).getByTaxAgentId(taxDeclareRecord.getTaxAgentId()); if (Objects.isNull(taxAgentTaxReturn) || !Objects.equals(taxAgentTaxReturn.getCheckStatus(), TaxAgentTaxReturnStatusEnum.SUCCESS.getValue())) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156469, "个税扣缴义务人的报税信息验证未通过,请先维护好个税扣缴义务人的报税信息")); } // 注册的企业信息-->请求参数 Map requestParam = TaxAgentTaxReturnBO.convert2RequestMap(taxAgent, taxAgentTaxReturn); - return new TaxDeclareRequest().setTaxDeclarationApiConfig(apiConfig) - .setTaxAgent(taxAgent) - .setTaxDeclareRecord(taxDeclareRecord) - .setRequestParam(requestParam); + return new TaxDeclareRequest().setTaxDeclarationApiConfig(apiConfig).setTaxAgent(taxAgent).setTaxDeclareRecord(taxDeclareRecord).setRequestParam(requestParam); } } diff --git a/src/com/engine/salary/wrapper/TaxDeclareRecordWrapper.java b/src/com/engine/salary/wrapper/TaxDeclareRecordWrapper.java index f361c78cb..9cfe582fd 100644 --- a/src/com/engine/salary/wrapper/TaxDeclareRecordWrapper.java +++ b/src/com/engine/salary/wrapper/TaxDeclareRecordWrapper.java @@ -1,5 +1,6 @@ package com.engine.salary.wrapper; +import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.cache.SalaryCacheKey; import com.engine.salary.entity.datacollection.DataCollectionEmployee; @@ -15,6 +16,7 @@ import com.engine.salary.enums.taxdeclaration.TaxDeclareStatusEnum; import com.engine.salary.enums.taxdeclaration.TaxDeclareTypeEnum; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.service.*; +import com.engine.salary.service.impl.*; import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.SalaryEnumUtil; @@ -32,6 +34,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.springframework.stereotype.Component; import weaver.general.Util; +import weaver.hrm.User; import java.util.*; import java.util.stream.Collectors; @@ -48,24 +51,33 @@ import java.util.stream.Collectors; public class TaxDeclareRecordWrapper extends Service { - private TaxDeclareRecordService taxDeclareRecordService; - - private TaxAgentService taxAgentService; - - private SalaryEmployeeService hrmCommonEmployeeService; - - private SalaryCacheService salaryCacheService; - - private TaxDeclarationService taxDeclarationService; - - private TaxDeclarationValueService taxDeclarationValueService; - - private TaxDeclarationExcelService taxDeclarationExcelService; - - private TaxDeclareEmployeeService taxDeclareEmployeeService; - - private TaxDeclareFailService taxDeclareFailService; - + private TaxDeclareRecordService getTaxDeclareRecordService(User user) { + return ServiceUtil.getService(TaxDeclareRecordServiceImpl.class, user); + } + private TaxAgentService getTaxAgentService(User user) { + return ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + private SalaryCacheService getSalaryCacheService(User user) { + return ServiceUtil.getService(SalaryCacheServiceImpl.class, user); + } + private TaxDeclarationService getTaxDeclarationService(User user) { + return ServiceUtil.getService(TaxDeclarationServiceImpl.class, user); + } + private TaxDeclarationValueService getTaxDeclarationValueService(User user) { + return ServiceUtil.getService(TaxDeclarationValueServiceImpl.class, user); + } + private TaxDeclarationExcelService getTaxDeclarationExcelService(User user) { + return ServiceUtil.getService(TaxDeclarationExcelServiceImpl.class, user); + } + private TaxDeclareEmployeeService getTaxDeclareEmployeeService(User user) { + return ServiceUtil.getService(TaxDeclareEmployeeServiceImpl.class, user); + } + private TaxDeclareFailService getTaxDeclareFailService(User user) { + return ServiceUtil.getService(TaxDeclareFailServiceImpl.class, user); + } /** * 个税申报记录列表 * @@ -73,17 +85,17 @@ public class TaxDeclareRecordWrapper extends Service { * @return */ public PageInfo listPage(TaxDeclarationListQueryParam queryParam) { - PageInfo page = taxDeclareRecordService.listPageByParam(queryParam); + PageInfo page = getTaxDeclareRecordService(user).listPageByParam(queryParam); List list = page.getList(); PageInfo dtoPage = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), TaxDeclareRecordListDTO.class); if (CollectionUtils.isNotEmpty(list)) { // 查询个税扣缴义务人 Set taxAgentIds = SalaryEntityUtil.properties(list, TaxDeclareRecordPO::getTaxAgentId); - List taxAgents = taxAgentService.listByIds(taxAgentIds); + List taxAgents = getTaxAgentService(user).listByIds(taxAgentIds); // 查询人员姓名 List employeeIds = SalaryEntityUtil.properties(list, TaxDeclareRecordPO::getCreator, Collectors.toList()); - List simpleEmployees = hrmCommonEmployeeService.getEmployeeByIds(employeeIds); + List simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIds(employeeIds); List dtoList = Lists.newArrayList(); Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getId, TaxAgentPO::getName); @@ -122,15 +134,15 @@ public class TaxDeclareRecordWrapper extends Service { */ public PageInfo listValuePage(TaxDeclarationValueListQueryParam queryParam) { // 查询个税申报表 - TaxDeclarationPO taxDeclaration = taxDeclarationService.getById(queryParam.getTaxDeclarationId()); + TaxDeclarationPO taxDeclaration = getTaxDeclarationService(user).getById(queryParam.getTaxDeclarationId()); // 判断是否有权限查看 - boolean canSee = taxDeclareRecordService.checkByAuthority(taxDeclaration); + boolean canSee = getTaxDeclareRecordService(user).checkByAuthority(taxDeclaration); if (!canSee) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156515, "对不起,您暂时没有权限查看")); } // 查询个税申报表详情 - PageInfo page = taxDeclarationValueService.listPageByTaxDeclarationIds(queryParam,Collections.singleton(queryParam.getTaxDeclarationId())); - TaxDeclarationValueListDTO taxDeclarationValueListDTO = taxDeclarationValueService.convert2List(taxDeclaration, page.getList()); + PageInfo page = getTaxDeclarationValueService(user).listPageByTaxDeclarationIds(queryParam,Collections.singleton(queryParam.getTaxDeclarationId())); + TaxDeclarationValueListDTO taxDeclarationValueListDTO = getTaxDeclarationValueService(user).convert2List(taxDeclaration, page.getList()); PageInfo> dtoPage = new PageInfo(); dtoPage.setList(taxDeclarationValueListDTO.getData()); return dtoPage; @@ -164,41 +176,41 @@ public class TaxDeclareRecordWrapper extends Service { */ public PageInfo listEmployeePage4Fail(AbnormalEmployeeListQueryParam queryParam) { // 查询个税申报记录 - TaxDeclareRecordPO taxDeclareRecord = taxDeclareRecordService.getById(queryParam.getTaxDeclareRecordId()); + TaxDeclareRecordPO taxDeclareRecord = getTaxDeclareRecordService(user).getById(queryParam.getTaxDeclareRecordId()); // 查询申报失败的数据 - List taxDeclareFailPOPageInfo = taxDeclareFailService.listPageByTaxDeclareRecordIds(Collections.singleton(taxDeclareRecord.getId())); + List taxDeclareFailPOPageInfo = getTaxDeclareFailService(user).listPageByTaxDeclareRecordIds(Collections.singleton(taxDeclareRecord.getId())); // 转换成dto PageInfo dtoPage = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), FailEmployeeListDTO.class); - dtoPage.setList(taxDeclareFailService.convert2FailEmployeeList(taxDeclareRecord, taxDeclareFailPOPageInfo)); + dtoPage.setList(getTaxDeclareFailService(user).convert2FailEmployeeList(taxDeclareRecord, taxDeclareFailPOPageInfo)); // 转成前端所需的格式 return dtoPage; } private PageInfo listEmployeePage(String key, AbnormalEmployeeListQueryParam queryParam) { // 查询个税申报记录 - TaxDeclareRecordPO taxDeclareRecord = taxDeclareRecordService.getById(queryParam.getTaxDeclareRecordId()); + TaxDeclareRecordPO taxDeclareRecord = getTaxDeclareRecordService(user).getById(queryParam.getTaxDeclareRecordId()); queryParam.setTaxAgentId(taxDeclareRecord.getTaxAgentId()); queryParam.setTaxCycle(taxDeclareRecord.getTaxCycle()); if (StringUtils.isEmpty(queryParam.getKeyword())) { // 查询个税申报记录的人员 PageInfo page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), TaxDeclareEmployeePO.class); if (StringUtils.equals("NotDeclare", key)) { - page = taxDeclareEmployeeService.listPage4NotDeclareByParam(queryParam); + page = getTaxDeclareEmployeeService(user).listPage4NotDeclareByParam(queryParam); } else if (StringUtils.equals("NoValue", key)) { - page = taxDeclareEmployeeService.listPage4NoValueByParam(queryParam); + page = getTaxDeclareEmployeeService(user).listPage4NoValueByParam(queryParam); } PageInfo dtoPage = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), AbnormalEmployeeListDTO.class); - dtoPage.setList(taxDeclareEmployeeService.convert2AbnormalEmployeeList(taxDeclareRecord, page.getList())); + dtoPage.setList(getTaxDeclareEmployeeService(user).convert2AbnormalEmployeeList(taxDeclareRecord, page.getList())); return dtoPage; } else { // 查询条件中包含"keyword"时,不好通过SQL分页,所以在内存中分页 List taxDeclareEmployees = Collections.emptyList(); if (StringUtils.equals("NotDeclare", key)) { - taxDeclareEmployees = taxDeclareEmployeeService.list4NotDeclareByParam(queryParam); + taxDeclareEmployees = getTaxDeclareEmployeeService(user).list4NotDeclareByParam(queryParam); } else if (StringUtils.equals("NoValue", key)) { - taxDeclareEmployees = taxDeclareEmployeeService.list4NoValueByParam(queryParam); + taxDeclareEmployees = getTaxDeclareEmployeeService(user).list4NoValueByParam(queryParam); } - List dtos = taxDeclareEmployeeService.convert2AbnormalEmployeeList(taxDeclareRecord, taxDeclareEmployees) + List dtos = getTaxDeclareEmployeeService(user).convert2AbnormalEmployeeList(taxDeclareRecord, taxDeclareEmployees) .stream() .filter(e -> StringUtils.contains(e.getEmployeeName(), queryParam.getKeyword()) || StringUtils.contains(e.getJobNum(), queryParam.getKeyword()) @@ -219,8 +231,8 @@ public class TaxDeclareRecordWrapper extends Service { // TaxDeclareRecordFormDTO formDTO = new TaxDeclareRecordFormDTO(); // formDTO.setTaxAgentRange(TaxAgentRangeEnum.SELECT_TAX_AGENT); // // 判断当前是否开启了分权 -// Boolean openDevolution = taxAgentService.isOpenDevolution(); -// Boolean isChief = taxAgentService.isChief((long)user.getUID()); +// Boolean openDevolution = getTaxAgentService(user).isOpenDevolution(); +// Boolean isChief = getTaxAgentService(user).isChief((long)user.getUID()); // // 转换成前端所需的数据格式 // WeaForm weaForm = SalaryFormatUtil.getInstance().buildForm(TaxDeclareRecordFormDTO.class, formDTO); // weaForm.getItems().forEach((k, v) -> { @@ -249,9 +261,9 @@ public class TaxDeclareRecordWrapper extends Service { */ public List getTaxDeclarationTab(Long id) { // 查询个税申报记录 - TaxDeclareRecordPO taxDeclareRecord = taxDeclareRecordService.getById(id); + TaxDeclareRecordPO taxDeclareRecord = getTaxDeclareRecordService(user).getById(id); // 查询个税申报记录下的个税申报表 - List taxDeclarations = taxDeclarationService.listByTaxCycleAndTaxAgentIds(SalaryDateUtil.localDate2YearMonth(taxDeclareRecord.getTaxCycle()), + List taxDeclarations = getTaxDeclarationService(user).listByTaxCycleAndTaxAgentIds(SalaryDateUtil.localDate2YearMonth(taxDeclareRecord.getTaxCycle()), Collections.singleton(taxDeclareRecord.getTaxAgentId())); taxDeclarations = taxDeclarations.stream() .filter(e -> Objects.equals(e.getControlView(), 0) || Objects.equals(e.getCreator(), (long)user.getUID())) @@ -279,7 +291,7 @@ public class TaxDeclareRecordWrapper extends Service { */ public TaxDeclarationInfoDTO getTaxDeclarationInfoById(Long id) { // 查询个税申报表 - TaxDeclareRecordPO taxDeclareRecord = taxDeclareRecordService.getById(id); + TaxDeclareRecordPO taxDeclareRecord = getTaxDeclareRecordService(user).getById(id); if (Objects.isNull(taxDeclareRecord)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98877, "个税申报表不存在或已删除")); } @@ -288,13 +300,13 @@ public class TaxDeclareRecordWrapper extends Service { .setTaxAgentId(taxDeclareRecord.getTaxAgentId()) .setTaxCycle(taxDeclareRecord.getTaxCycle()); // 查询是否存在有未报送的人 - List notDeclareTaxDeclareEmployees = taxDeclareEmployeeService.list4NotDeclareByParam(queryParam); + List notDeclareTaxDeclareEmployees = getTaxDeclareEmployeeService(user).list4NotDeclareByParam(queryParam); // 查询是否存在没有申报数据的人 - List noValueTaxDeclareEmployees = taxDeclareEmployeeService.list4NoValueByParam(queryParam); + List noValueTaxDeclareEmployees = getTaxDeclareEmployeeService(user).list4NoValueByParam(queryParam); // 查询是否存在申报失败的人 - List taxDeclareFails = taxDeclareFailService.listByTaxDeclareRecordIds(Collections.singleton(taxDeclareRecord.getId())); + List taxDeclareFails = getTaxDeclareFailService(user).listByTaxDeclareRecordIds(Collections.singleton(taxDeclareRecord.getId())); // 查询个税扣缴义务人 - TaxAgentPO taxAgentPO = taxAgentService.getById(taxDeclareRecord.getTaxAgentId()); + TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(taxDeclareRecord.getTaxAgentId()); TaxDeclareTypeEnum taxDeclareTypeEnum = SalaryEnumUtil.enumMatchByValue(taxDeclareRecord.getTaxDeclareType(), TaxDeclareTypeEnum.class); TaxDeclareStatusEnum taxDeclareStatusEnum = SalaryEnumUtil.enumMatchByValue(taxDeclareRecord.getTaxDeclareStatus(), TaxDeclareStatusEnum.class); return TaxDeclarationInfoDTO.builder() @@ -323,12 +335,12 @@ public class TaxDeclareRecordWrapper extends Service { TaxDeclarationRateDTO taxDeclarationRate = new TaxDeclarationRateDTO().setStatus(true) .setIndex(Util.null2String(IdGenerator.generate())) .setMsg(SalaryI18nUtil.getI18nLabel(95836, "生成申报表")); - salaryCacheService.set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); + getSalaryCacheService(user).set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); LocalRunnable localRunnable = new LocalRunnable() { @Override public void execute() { try { - taxDeclareRecordService.save(saveParam); + getTaxDeclareRecordService(user).save(saveParam); taxDeclarationRate.setStatus(true).setFinish(true); } catch (SalaryRunTimeException e) { taxDeclarationRate.setStatus(false).setFinish(true).setMsg(e.getMessage()); @@ -336,7 +348,7 @@ public class TaxDeclareRecordWrapper extends Service { log.error("个税申报表生成报错:{}", e.getMessage(), e); taxDeclarationRate.setStatus(false).setFinish(true).setMsg(SalaryI18nUtil.getI18nLabel(187276, "个税申报表生成报错:") + e.getMessage()); } finally { - salaryCacheService.set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); + getSalaryCacheService(user).set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); } } }; @@ -350,7 +362,7 @@ public class TaxDeclareRecordWrapper extends Service { * @param id */ public void updateIcon(Long id) { - taxDeclareRecordService.updateIcon(id, NumberUtils.INTEGER_ZERO); + getTaxDeclareRecordService(user).updateIcon(id, NumberUtils.INTEGER_ZERO); } /** @@ -359,7 +371,7 @@ public class TaxDeclareRecordWrapper extends Service { * @param ids */ public void delete(Collection ids) { - taxDeclareRecordService.deleteByIds(ids); + getTaxDeclareRecordService(user).deleteByIds(ids); } /** @@ -369,7 +381,7 @@ public class TaxDeclareRecordWrapper extends Service { * @return */ public TaxDeclarationRateDTO getRate(String index) { - return salaryCacheService.get(SalaryCacheKey.TAX_DECLARATION + index); + return getSalaryCacheService(user).get(SalaryCacheKey.TAX_DECLARATION + index); } /** @@ -381,12 +393,12 @@ public class TaxDeclareRecordWrapper extends Service { checkBefore(id); TaxDeclarationRateDTO taxDeclarationRate = new TaxDeclarationRateDTO().setStatus(true).setIndex(Util.null2String(id)) .setMsg(SalaryI18nUtil.getI18nLabel(156454, "在线申报")); - salaryCacheService.set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); + getSalaryCacheService(user).set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); LocalRunnable localRunnable = new LocalRunnable() { @Override public void execute() { try { - taxDeclareRecordService.declare(id); + getTaxDeclareRecordService(user).declare(id); taxDeclarationRate.setFinish(true); } catch (SalaryRunTimeException e) { taxDeclarationRate.setStatus(false).setFinish(true).setMsg(e.getMessage()); @@ -394,7 +406,7 @@ public class TaxDeclareRecordWrapper extends Service { log.error("在线申报失败:{}", e.getMessage(), e); taxDeclarationRate.setStatus(false).setFinish(true).setMsg(SalaryI18nUtil.getI18nLabel(187274, "在线申报失败:") + e.getMessage()); } finally { - salaryCacheService.set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); + getSalaryCacheService(user).set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); } } }; @@ -411,12 +423,12 @@ public class TaxDeclareRecordWrapper extends Service { checkBefore(id); TaxDeclarationRateDTO taxDeclarationRate = new TaxDeclarationRateDTO().setStatus(true).setIndex(Util.null2String(id)) .setMsg(SalaryI18nUtil.getI18nLabel(182680, "获取申报反馈")); - salaryCacheService.set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); + getSalaryCacheService(user).set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); LocalRunnable localRunnable = new LocalRunnable() { @Override public void execute() { try { - taxDeclareRecordService.getDeclareFeedback(id, taxDeclarationRate); + getTaxDeclareRecordService(user).getDeclareFeedback(id, taxDeclarationRate); taxDeclarationRate.setFinish(true); } catch (SalaryRunTimeException e) { taxDeclarationRate.setStatus(false).setFinish(true).setMsg(e.getMessage()); @@ -424,7 +436,7 @@ public class TaxDeclareRecordWrapper extends Service { log.error("获取申报反馈失败:{}", e.getMessage(), e); taxDeclarationRate.setStatus(false).setFinish(true).setMsg(SalaryI18nUtil.getI18nLabel(187255, "获取申报反馈失败:") + e.getMessage()); } finally { - salaryCacheService.set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); + getSalaryCacheService(user).set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); } } }; @@ -441,12 +453,12 @@ public class TaxDeclareRecordWrapper extends Service { checkBefore(id); TaxDeclarationRateDTO taxDeclarationRate = new TaxDeclarationRateDTO().setStatus(true).setIndex(Util.null2String(id)) .setMsg(SalaryI18nUtil.getI18nLabel(158842, "作废申报")); - salaryCacheService.set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); + getSalaryCacheService(user).set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); LocalRunnable localRunnable = new LocalRunnable() { @Override public void execute() { try { - taxDeclareRecordService.cancelDeclare(id); + getTaxDeclareRecordService(user).cancelDeclare(id); taxDeclarationRate.setFinish(true); } catch (SalaryRunTimeException e) { taxDeclarationRate.setStatus(false).setFinish(true).setMsg(e.getMessage()); @@ -454,7 +466,7 @@ public class TaxDeclareRecordWrapper extends Service { log.error("作废申报失败:{}", e.getMessage(), e); taxDeclarationRate.setStatus(false).setFinish(true).setMsg(SalaryI18nUtil.getI18nLabel(187272, "作废申报失败:") + e.getMessage()); } finally { - salaryCacheService.set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); + getSalaryCacheService(user).set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); } } }; @@ -471,12 +483,12 @@ public class TaxDeclareRecordWrapper extends Service { checkBefore(id); TaxDeclarationRateDTO taxDeclarationRate = new TaxDeclarationRateDTO().setStatus(true).setIndex(Util.null2String(id)) .setMsg(SalaryI18nUtil.getI18nLabel(182681, "获取作废申报反馈")); - salaryCacheService.set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); + getSalaryCacheService(user).set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); LocalRunnable localRunnable = new LocalRunnable() { @Override public void execute() { try { - taxDeclareRecordService.getCancelFeedback(id, taxDeclarationRate); + getTaxDeclareRecordService(user).getCancelFeedback(id, taxDeclarationRate); taxDeclarationRate.setFinish(true); } catch (SalaryRunTimeException e) { taxDeclarationRate.setStatus(false).setFinish(true).setMsg(e.getMessage()); @@ -484,7 +496,7 @@ public class TaxDeclareRecordWrapper extends Service { log.error("获取作废反馈结果失败:{}", e.getMessage(), e); taxDeclarationRate.setStatus(false).setFinish(true).setMsg(SalaryI18nUtil.getI18nLabel(187270, "获取作废反馈结果失败:") + e.getMessage()); } finally { - salaryCacheService.set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); + getSalaryCacheService(user).set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); } } }; @@ -502,12 +514,12 @@ public class TaxDeclareRecordWrapper extends Service { checkBefore(id); TaxDeclarationRateDTO taxDeclarationRate = new TaxDeclarationRateDTO().setStatus(true).setIndex(Util.null2String(id)) .setMsg(SalaryI18nUtil.getI18nLabel(177637, "更正申报")); - salaryCacheService.set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); + getSalaryCacheService(user).set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); LocalRunnable localRunnable = new LocalRunnable() { @Override public void execute() { try { - taxDeclareRecordService.updateDeclare(id); + getTaxDeclareRecordService(user).updateDeclare(id); taxDeclarationRate.setFinish(true); } catch (SalaryRunTimeException e) { taxDeclarationRate.setStatus(false).setFinish(true).setMsg(e.getMessage()); @@ -515,7 +527,7 @@ public class TaxDeclareRecordWrapper extends Service { log.error("更正申报失败:{}", e.getMessage(), e); taxDeclarationRate.setStatus(false).setFinish(true).setMsg(SalaryI18nUtil.getI18nLabel(187269, "更正申报失败:") + e.getMessage()); } finally { - salaryCacheService.set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); + getSalaryCacheService(user).set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); } } }; @@ -530,7 +542,7 @@ public class TaxDeclareRecordWrapper extends Service { * @return */ public String queryDeclareStatus(Long id) { - return taxDeclareRecordService.queryDeclareStatus(id); + return getTaxDeclareRecordService(user).queryDeclareStatus(id); } /** @@ -540,7 +552,7 @@ public class TaxDeclareRecordWrapper extends Service { * @return */ public String queryCompanyIncomes(Long id) { - return taxDeclareRecordService.queryCompanyIncomes(id); + return getTaxDeclareRecordService(user).queryCompanyIncomes(id); } /** @@ -553,12 +565,12 @@ public class TaxDeclareRecordWrapper extends Service { checkBefore(id); TaxDeclarationRateDTO taxDeclarationRate = new TaxDeclarationRateDTO().setStatus(true).setIndex(Util.null2String(id)) .setMsg(SalaryI18nUtil.getI18nLabel(156447, "刷新数据")); - salaryCacheService.set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); + getSalaryCacheService(user).set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); LocalRunnable localRunnable = new LocalRunnable() { @Override public void execute() { try { - taxDeclareRecordService.refreshData(id); + getTaxDeclareRecordService(user).refreshData(id); taxDeclarationRate.setFinish(true); } catch (SalaryRunTimeException e) { taxDeclarationRate.setStatus(false).setFinish(true).setMsg(e.getMessage()); @@ -566,7 +578,7 @@ public class TaxDeclareRecordWrapper extends Service { log.error("刷新数据失败:{}", e.getMessage(), e); taxDeclarationRate.setStatus(false).setFinish(true).setMsg(SalaryI18nUtil.getI18nLabel(187268, "刷新数据失败:") + e.getMessage()); } finally { - salaryCacheService.set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); + getSalaryCacheService(user).set(SalaryCacheKey.TAX_DECLARATION + taxDeclarationRate.getIndex(), taxDeclarationRate); } } }; @@ -575,7 +587,7 @@ public class TaxDeclareRecordWrapper extends Service { } private void checkBefore(Long id) { - TaxDeclarationRateDTO taxDeclarationRate = salaryCacheService.get(SalaryCacheKey.TAX_DECLARATION + Util.null2String(id)); + TaxDeclarationRateDTO taxDeclarationRate = getSalaryCacheService(user).get(SalaryCacheKey.TAX_DECLARATION + Util.null2String(id)); if (taxDeclarationRate != null && !taxDeclarationRate.isFinish()) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(182691, "当前正处于「{0}」中,请稍后再试").replace("{0}", taxDeclarationRate.getMsg())); } @@ -595,7 +607,7 @@ public class TaxDeclareRecordWrapper extends Service { // LocalRunnable localRunnable = new LocalRunnable() { // @Override // public void execute() { -// taxDeclarationExcelService.exportTaxDeclarationValue(excelExportParam, queryParam, simpleEmployee); +// getTaxDeclarationExcelService(user).exportTaxDeclarationValue(excelExportParam, queryParam, simpleEmployee); // } // }; // ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "exportTaxDeclarationValue", localRunnable); @@ -617,7 +629,7 @@ public class TaxDeclareRecordWrapper extends Service { // LocalRunnable localRunnable = new LocalRunnable() { // @Override // public void execute() { -// taxDeclarationExcelService.exportEmployee4NotDeclare(excelExportParam, queryParam, simpleEmployee); +// getTaxDeclarationExcelService(user).exportEmployee4NotDeclare(excelExportParam, queryParam, simpleEmployee); // } // }; // ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "exportEmployee4NotDeclare", localRunnable); @@ -639,7 +651,7 @@ public class TaxDeclareRecordWrapper extends Service { // LocalRunnable localRunnable = new LocalRunnable() { // @Override // public void execute() { -// taxDeclarationExcelService.exportEmployee4NoValue(excelExportParam, queryParam, simpleEmployee); +// getTaxDeclarationExcelService(user).exportEmployee4NoValue(excelExportParam, queryParam, simpleEmployee); // } // }; // ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "exportEmployee4NoValue", localRunnable); @@ -661,7 +673,7 @@ public class TaxDeclareRecordWrapper extends Service { // LocalRunnable localRunnable = new LocalRunnable() { // @Override // public void execute() { -// taxDeclarationExcelService.exportEmployee4Fail(excelExportParam, queryParam, simpleEmployee); +// getTaxDeclarationExcelService(user).exportEmployee4Fail(excelExportParam, queryParam, simpleEmployee); // } // }; // ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "exportEmployee4Fail", localRunnable);