获取账套关联扣缴义务人

This commit is contained in:
钱涛 2024-09-03 09:21:57 +08:00
parent ecfa6a4604
commit 7f77f4cb12
7 changed files with 142 additions and 151 deletions

View File

@ -80,10 +80,11 @@ public class SalaryAcctRecordBO {
btnList.add(new WeaTableOperate("查看", null, "3"));
btnList.add(new WeaTableOperate("重新核算", null, "4"));
}
String taxAgentName = salarySobPO.getTaxAgentIds().stream().map(id -> taxAgentMap.getOrDefault(id, "")).collect(Collectors.joining(","));
return SalaryAcctRecordListDTO.builder()
.id(salaryAcctRecordPO.getId())
.salarySobName(Optional.ofNullable(salarySobPO).map(SalarySobPO::getName).orElse(StringUtils.EMPTY))
.taxAgentName(taxAgentMap.get(Optional.ofNullable(salarySobPO).map(SalarySobPO::getTaxAgentId).orElse(0L)))
.taxAgentName(taxAgentName)
.salaryMonth(SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()).toString())
.taxCycle(SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getTaxCycle()).toString())
.status(Optional.ofNullable(salaryAcctRecordStatusEnum)

View File

@ -39,6 +39,7 @@ public interface SalarySobService {
* @return
*/
List<SalarySobPO> listByIds(Collection<Long> ids);
List<SalarySobPO> listByIdsWithTax(Collection<Long> ids);
/**
* 根据名称精确匹配查询薪资账套

View File

@ -338,141 +338,115 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
}
//获取账套所属个税扣缴义务人的核算记录
SalarySobPO salarySobPO = getSalarySobService(user).getById(saveParam.getSalarySobId());
Long taxAgentId = salarySobPO.getTaxAgentId();
//查询扣缴义务人下的所有账套
List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByTaxAgentId(taxAgentId);
Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId);
//获取账套下的所有核算结果
List<SalaryAcctRecordPO> salaryAcctRecords = listByTaxCycle(taxCycleYearRange, salarySobIds);
SalarySobPO salarySobPO = getSalarySobService(user).getByIdWithTax(saveParam.getSalarySobId());
List<Long> taxAgentIds = salarySobPO.getTaxAgentIds();
taxAgentIds.forEach(taxAgentId->{
//查询扣缴义务人下的所有账套
List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByTaxAgentId(taxAgentId);
Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId);
//获取账套下的所有核算结果
List<SalaryAcctRecordPO> salaryAcctRecords = listByTaxCycle(taxCycleYearRange, salarySobIds);
// 获取个税申报功能状态
TaxDeclarationFunctionEnum taxDeclarationFunctionEnum = getSalarySysConfService(user).getTaxDeclaration();
// 获取个税申报功能状态
TaxDeclarationFunctionEnum taxDeclarationFunctionEnum = getSalarySysConfService(user).getTaxDeclaration();
// if (taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.CLOSURE.getValue())) {
// // 关闭了个税申报功能
// // 如果某个月薪资所属期还未归档不可以新建之后月份的薪资核算
// SalaryAcctRecordPO notArchivedSalaryAcctRecordPO = salaryAcctRecords.stream()
// .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())
// && e.getSalaryMonth().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1))))
// .findAny()
// .orElse(null);
// if (Objects.nonNull(notArchivedSalaryAcctRecordPO)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98754, "薪资所属期{0}的薪资核算结果还未归档,不能新建薪资所属期{1}的薪资核算")
// .replace("{0}", SalaryDateUtil.localDate2YearMonth(notArchivedSalaryAcctRecordPO.getTaxCycle()).toString())
// .replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
// }
// // 如果有某个月薪资所属期已经归档了不可以新建之前月份的薪资核算
// SalaryAcctRecordPO havaSalaryAcctRecordPO = salaryAcctRecords.stream()
// .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue())
// && e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1))))
// .findAny()
// .orElse(null);
// if (Objects.nonNull(havaSalaryAcctRecordPO)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98755, "薪资所属期{0}的薪资核算结果已经归档,不能新建薪资所属期{1}的薪资核算")
// .replace("{0}", SalaryDateUtil.localDate2YearMonth(havaSalaryAcctRecordPO.getSalaryMonth()).toString())
// .replace("{1}", salarySobCycleDTO.getSalaryMonth().toString()));
// }
//
// }
if (taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.OPEN.getValue())) {
// 开启了个税申报功能
// 如果某个月税款所属期已经归档了不可以新建之前月份的薪资核算
SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream()
.filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue())
&& e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))))
.findAny()
.orElse(null);
if (Objects.nonNull(hasArchivedSalaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98752, "税款所属期{0}的薪资核算结果已经归档,不能新建税款所属期{1}的薪资核算")
.replace("{0}", SalaryDateUtil.localDate2YearMonth(hasArchivedSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
}
// 如果某个月税款所属期还未申报不可以新建之后月份的薪资核算
SalaryAcctRecordPO notDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream()
.filter(e -> !Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue())
&& e.getTaxCycle().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))))
.findAny()
.orElse(null);
if (Objects.nonNull(notDeclaredSalaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98751, "税款所属期{0}的薪资核算结果还未申报,不能新建税款所属期{1}的薪资核算")
.replace("{0}", SalaryDateUtil.localDate2YearMonth(notDeclaredSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
}
// 如果某个月税款所属期已经申报了不可以新建本月以及之前月份的薪资核算
SalaryAcctRecordPO hasDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream()
.filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue())
&& e.getTaxCycle().compareTo(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))) >= 0)
.findAny()
.orElse(null);
if (Objects.nonNull(hasDeclaredSalaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98753, "税款所属期{0}的薪资核算结果已经申报,不能新建税款所属期{1}的薪资核算")
.replace("{0}", SalaryDateUtil.localDate2YearMonth(hasDeclaredSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
}
}
if (taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.REBOOT.getValue())) {
// 重启了个税申报功能不去校验重启之前是否申报数据
// 如果某个月薪资所属期还未归档不可以新建之后月份的薪资核算
SalaryAcctRecordPO notArchivedSalaryAcctRecordPO = salaryAcctRecords.stream()
.filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())
&& e.getSalaryMonth().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1))))
.findAny()
.orElse(null);
if (Objects.nonNull(notArchivedSalaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98754, "薪资所属期{0}的薪资核算结果还未归档,不能新建薪资所属期{1}的薪资核算")
.replace("{0}", SalaryDateUtil.localDate2YearMonth(notArchivedSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
}
// 如果某个月税款所属期已经归档了不可以新建之前月份的薪资核算
SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream()
.filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue())
&& e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))))
.findAny()
.orElse(null);
if (Objects.nonNull(hasArchivedSalaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98752, "税款所属期{0}的薪资核算结果已经归档,不能新建税款所属期{1}的薪资核算")
.replace("{0}", SalaryDateUtil.localDate2YearMonth(hasArchivedSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
}
// 如果某个月税款所属期还未申报不可以新建之后月份的薪资核算
//获取账套下从重启月至所在年的最后一天的所有核算结果
Date taxDeclarationRebootDate = getSalarySysConfService(user).getTaxDeclarationRebootDate();
if (taxDeclarationRebootDate == null) {
throw new SalaryRunTimeException("个税申报功能异常");
if (taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.OPEN.getValue())) {
// 开启了个税申报功能
// 如果某个月税款所属期已经归档了不可以新建之前月份的薪资核算
SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream()
.filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue())
&& e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))))
.findAny()
.orElse(null);
if (Objects.nonNull(hasArchivedSalaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98752, "税款所属期{0}的薪资核算结果已经归档,不能新建税款所属期{1}的薪资核算")
.replace("{0}", SalaryDateUtil.localDate2YearMonth(hasArchivedSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
}
// 如果某个月税款所属期还未申报不可以新建之后月份的薪资核算
SalaryAcctRecordPO notDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream()
.filter(e -> !Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue())
&& e.getTaxCycle().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))))
.findAny()
.orElse(null);
if (Objects.nonNull(notDeclaredSalaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98751, "税款所属期{0}的薪资核算结果还未申报,不能新建税款所属期{1}的薪资核算")
.replace("{0}", SalaryDateUtil.localDate2YearMonth(notDeclaredSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
}
// 如果某个月税款所属期已经申报了不可以新建本月以及之前月份的薪资核算
SalaryAcctRecordPO hasDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream()
.filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue())
&& e.getTaxCycle().compareTo(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))) >= 0)
.findAny()
.orElse(null);
if (Objects.nonNull(hasDeclaredSalaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98753, "税款所属期{0}的薪资核算结果已经申报,不能新建税款所属期{1}的薪资核算")
.replace("{0}", SalaryDateUtil.localDate2YearMonth(hasDeclaredSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
}
}
if (taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.REBOOT.getValue())) {
// 重启了个税申报功能不去校验重启之前是否申报数据
// 如果某个月薪资所属期还未归档不可以新建之后月份的薪资核算
SalaryAcctRecordPO notArchivedSalaryAcctRecordPO = salaryAcctRecords.stream()
.filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())
&& e.getSalaryMonth().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1))))
.findAny()
.orElse(null);
if (Objects.nonNull(notArchivedSalaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98754, "薪资所属期{0}的薪资核算结果还未归档,不能新建薪资所属期{1}的薪资核算")
.replace("{0}", SalaryDateUtil.localDate2YearMonth(notArchivedSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
}
// 如果某个月税款所属期已经归档了不可以新建之前月份的薪资核算
SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream()
.filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue())
&& e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))))
.findAny()
.orElse(null);
if (Objects.nonNull(hasArchivedSalaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98752, "税款所属期{0}的薪资核算结果已经归档,不能新建税款所属期{1}的薪资核算")
.replace("{0}", SalaryDateUtil.localDate2YearMonth(hasArchivedSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
}
// 如果某个月税款所属期还未申报不可以新建之后月份的薪资核算
//获取账套下从重启月至所在年的最后一天的所有核算结果
Date taxDeclarationRebootDate = getSalarySysConfService(user).getTaxDeclarationRebootDate();
if (taxDeclarationRebootDate == null) {
throw new SalaryRunTimeException("个税申报功能异常");
}
LocalDateRange taxCycleRebootYearRange = LocalDateRange.builder()
.fromDate(taxDeclarationRebootDate)
.endDate(SalaryDateUtil.getLastDayOfYear(taxDeclarationRebootDate))
.build();
LocalDateRange taxCycleRebootYearRange = LocalDateRange.builder()
.fromDate(taxDeclarationRebootDate)
.endDate(SalaryDateUtil.getLastDayOfYear(taxDeclarationRebootDate))
.build();
// List<SalaryAcctRecordPO> salaryAcctRebootRecords = listByTaxCycle(taxCycleRebootYearRange,salarySobIds);
List<SalaryAcctRecordPO> salaryAcctRebootRecords = listByCreateDate(taxCycleRebootYearRange, salarySobIds);
SalaryAcctRecordPO notDeclaredSalaryAcctRecordPO = salaryAcctRebootRecords.stream()
.filter(e -> !Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue())
&& e.getTaxCycle().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))))
.findAny()
.orElse(null);
if (Objects.nonNull(notDeclaredSalaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98751, "税款所属期{0}的薪资核算结果还未申报,不能新建税款所属期{1}的薪资核算")
.replace("{0}", SalaryDateUtil.localDate2YearMonth(notDeclaredSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
List<SalaryAcctRecordPO> salaryAcctRebootRecords = listByCreateDate(taxCycleRebootYearRange, salarySobIds);
SalaryAcctRecordPO notDeclaredSalaryAcctRecordPO = salaryAcctRebootRecords.stream()
.filter(e -> !Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue())
&& e.getTaxCycle().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))))
.findAny()
.orElse(null);
if (Objects.nonNull(notDeclaredSalaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98751, "税款所属期{0}的薪资核算结果还未申报,不能新建税款所属期{1}的薪资核算")
.replace("{0}", SalaryDateUtil.localDate2YearMonth(notDeclaredSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
}
// 如果某个月税款所属期已经申报了不可以新建本月以及之前月份的薪资核算
SalaryAcctRecordPO hasDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream()
.filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue())
&& e.getTaxCycle().compareTo(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))) >= 0)
.findAny()
.orElse(null);
if (Objects.nonNull(hasDeclaredSalaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98753, "税款所属期{0}的薪资核算结果已经申报,不能新建税款所属期{1}的薪资核算")
.replace("{0}", SalaryDateUtil.localDate2YearMonth(hasDeclaredSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
}
}
// 如果某个月税款所属期已经申报了不可以新建本月以及之前月份的薪资核算
SalaryAcctRecordPO hasDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream()
.filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue())
&& e.getTaxCycle().compareTo(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))) >= 0)
.findAny()
.orElse(null);
if (Objects.nonNull(hasDeclaredSalaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98753, "税款所属期{0}的薪资核算结果已经申报,不能新建税款所属期{1}的薪资核算")
.replace("{0}", SalaryDateUtil.localDate2YearMonth(hasDeclaredSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
}
}
});
}
private List<SalaryAcctRecordPO> listByCreateDate(LocalDateRange taxCycleRebootYearRange, Set<Long> salarySobIds) {
@ -658,10 +632,10 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
}
// 查询税款所在年的该个税扣缴义务人所有薪资核算记录
// 获取账套所属个税扣缴义务人的核算记录
SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId());
Long taxAgentId = salarySobPO.getTaxAgentId();
SalarySobPO salarySobPO = getSalarySobService(user).getByIdWithTax(salaryAcctRecordPO.getSalarySobId());
List<Long> taxAgentIds = salarySobPO.getTaxAgentIds();
//查询扣缴义务人下的所有账套
List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByTaxAgentId(taxAgentId);
List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByTaxAgentIds(taxAgentIds);
Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId);
List<SalaryAcctRecordPO> salaryAcctRecordPOS = listByTaxCycle(yearRange, salarySobIds);
List<SalaryAcctRecordPO> selfSalaryAcctRecordPOS = filterByAuthority(salaryAcctRecordPOS);

View File

@ -195,6 +195,17 @@ public class SalarySobServiceImpl extends Service implements SalarySobService {
return salarySobMapper.listSome(SalarySobPO.builder().ids(ids).build());
}
@Override
public List<SalarySobPO> listByIdsWithTax(Collection<Long> ids) {
List<SalarySobPO> collect = ids.stream().map(id -> {
SalarySobPO sobPO = getSalarySobMapper().getById(id);
List<SobTaxLinkPO> sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().sobId(id).build());
sobPO.setTaxAgentIds(sobTaxLinkPOS.stream().map(SobTaxLinkPO::getTaxAgentId).collect(Collectors.toList()));
return sobPO;
}).collect(Collectors.toList());
return collect;
}
@Override
public List<SalarySobPO> listByName(String name) {
if (StringUtils.isEmpty(name)) {

View File

@ -14,7 +14,7 @@ import com.engine.salary.entity.datacollection.po.OtherDeductionPO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO;
import com.engine.salary.entity.salarysob.config.SalarySobConfig;
import com.engine.salary.entity.salarysob.po.SalarySobPO;
import com.engine.salary.entity.salarysob.po.SobTaxLinkPO;
import com.engine.salary.entity.siaccount.param.InsuranceAccountBatchParam;
import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO;
@ -39,6 +39,7 @@ import com.engine.salary.mapper.datacollection.AddUpDeductionMapper;
import com.engine.salary.mapper.datacollection.AddUpSituationMapper;
import com.engine.salary.mapper.datacollection.OtherDeductionMapper;
import com.engine.salary.mapper.salarysob.SalarySobMapper;
import com.engine.salary.mapper.salarysob.SobTaxLinkMapper;
import com.engine.salary.mapper.siaccount.InsuranceAccountBatchMapper;
import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper;
import com.engine.salary.mapper.taxagent.TaxAgentMapper;
@ -125,6 +126,10 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService {
return MapperProxyFactory.getProxy(SalarySobMapper.class);
}
private SobTaxLinkMapper getSobTaxLinkMapper() {
return MapperProxyFactory.getProxy(SobTaxLinkMapper.class);
}
private TaxAgentMapper getTaxAgentMapper() {
return MapperProxyFactory.getProxy(TaxAgentMapper.class);
}
@ -568,8 +573,8 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService {
}
//账套
List<SalarySobPO> salarySobPOS = getSalarySobMapper().listSome(SalarySobPO.builder().taxAgentId(id).build());
if (CollectionUtils.isNotEmpty(salarySobPOS)) {
List<SobTaxLinkPO> sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().taxAgentId(id).build());
if (CollectionUtils.isNotEmpty(sobTaxLinkPOS)) {
throw new SalaryRunTimeException("存在账套引用");
}
@ -821,7 +826,7 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService {
}
@Override
public List<UploadConfigResponse.Result> parseConfig(List<TaxAgentConfig> configs) {
public List<UploadConfigResponse.Result> parseConfig(List<TaxAgentConfig> configs) {
List<UploadConfigResponse.Result> results = new ArrayList<>();
List<TaxAgentPO> taxAgentPOS = listAll();

View File

@ -99,7 +99,7 @@ public class SalaryAcctRecordWrapper extends Service implements SalaryAcctRecord
if (CollectionUtils.isNotEmpty(list)) {
// 查询薪资账套
Set<Long> salarySobIds = SalaryEntityUtil.properties(list, SalaryAcctRecordPO::getSalarySobId);
List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByIds(salarySobIds);
List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByIdsWithTax(salarySobIds);
// 查询薪资核算记录的创建人员的人员信息
List<Long> employeeIds = SalaryEntityUtil.properties(list, SalaryAcctRecordPO::getCreator, Collectors.toList());
List<DataCollectionEmployee> employeeComInfos = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds);
@ -109,8 +109,7 @@ public class SalaryAcctRecordWrapper extends Service implements SalaryAcctRecord
// 查询工资单的查询情况
List<SalarySendCheckDTO> salarySendCheckResult = getSalarySendService(user).getSalarySendCheckResult(salaryAcctRecordIds);
Set<Long> taxAgentIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getTaxAgentId);
List<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listByIds(taxAgentIds);
List<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAll();
// 转换成列表dto
List<SalaryAcctRecordListDTO> salaryAcctRecordListDTOS = SalaryAcctRecordBO.convert2ListDTO(list, salarySobPOS, employeeComInfos, salaryAcctEmployeeCountDTOS, salarySendCheckResult, taxAgentPOS);

View File

@ -1,5 +1,6 @@
package com.engine.salary.wrapper;
import cn.hutool.core.collection.CollectionUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
@ -68,7 +69,6 @@ public class SalarySobWrapper extends Service {
}
/**
* 薪资账套列表
*
@ -85,7 +85,7 @@ public class SalarySobWrapper extends Service {
List<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAll();
Map<Long, String> taxAgentIdTONameMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId, TaxAgentPO::getName);
List<SalarySobListDTO> salarySobListDTOS = SalarySobBO.convert2ListDTO(page.getList(),taxAgentIdTONameMap);
List<SalarySobListDTO> salarySobListDTOS = SalarySobBO.convert2ListDTO(page.getList(), taxAgentIdTONameMap);
PageInfo<SalarySobListDTO> dtoPage = new PageInfo<>(salarySobListDTOS, SalarySobListDTO.class);
dtoPage.setTotal(page.getTotal());
dtoPage.setPageNum(page.getPageNum());
@ -118,10 +118,10 @@ public class SalarySobWrapper extends Service {
private void handleSalarySobBackItemHistory(SalarySobListQueryParam queryParam) {
queryParam.setPageSize(100000);
List<SalarySobPO> list = getSalarySobService(user).listPageByParam(queryParam).getList();
if(list != null && list.size()>0){
if (list != null && list.size() > 0) {
List<Long> salarySobIds = list.stream().map(SalarySobPO::getId).collect(Collectors.toList());
Long count = getSalarySobBackItemService(user).getCountBySalarySobIdIn(salarySobIds);
if(count.equals(0L)){
if (count.equals(0L)) {
// 薪资账套的默认的回算薪资项目
Set<Long> SalarySobBackItemIds = SalaryEntityUtil.properties(SalarySobBackItemBO.getDefault(), SalarySobDefaultBackItemPO::getSysSalaryItemId);
// 获取薪资项目中是否已经添加回算薪资项目
@ -139,7 +139,7 @@ public class SalarySobWrapper extends Service {
List<SalarySobBackItemPO> salarySobBackItems = new ArrayList<>();
// 获取默认添加后的回算薪资项目
List<SalaryItemPO> salaryBackItemPOS = getSalaryItemService(user).listBySysSalaryItemIds(SalarySobBackItemIds);
for(Long id : salarySobIds){
for (Long id : salarySobIds) {
for (SalarySobDefaultBackItemPO salarySobDefaultBackItemPO : SalarySobBackItemBO.getDefault()) {
Date now = new Date();
Map<Long, SalaryItemPO> sysSalaryItemMap = SalaryEntityUtil.convert2Map(salaryBackItemPOS, SalaryItemPO::getSysSalaryItemId);
@ -155,7 +155,7 @@ public class SalarySobWrapper extends Service {
.valueType(salaryItemPO.getValueType())
.formulaId(salarySobDefaultBackItemPO.getFormulaId())
.backCalcType(salarySobDefaultBackItemPO.getBackCalcType())
.creator((long)user.getUID())
.creator((long) user.getUID())
.createTime(now)
.updateTime(now)
.deleteType(DeleteTypeEnum.NOT_DELETED.getValue())
@ -195,7 +195,7 @@ public class SalarySobWrapper extends Service {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除"));
}
// 薪资装套po转换成薪资账套详情dto
basicForm = SalarySobBO.convert2FormDTO(basicForm,salarySobPO);
basicForm = SalarySobBO.convert2FormDTO(basicForm, salarySobPO);
}
// 转换成前端所需的数据格式
data.put("basicForm", basicForm);
@ -259,7 +259,7 @@ public class SalarySobWrapper extends Service {
*/
public boolean canEdit(Long id, Long employeeId) {
// 查询薪资账套
SalarySobPO salarySobPO = getSalarySobService(user).getById(id);
SalarySobPO salarySobPO = getSalarySobService(user).getByIdWithTax(id);
if (Objects.isNull(salarySobPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除"));
}
@ -271,11 +271,11 @@ public class SalarySobWrapper extends Service {
}
Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId);
Set<Long> taxAgentIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId);
return taxAgentIds.contains(salarySobPO.getTaxAgentId())||Objects.isNull(salarySobPO.getTaxAgentId());
Collection intersection = CollectionUtil.intersection(taxAgentIds, salarySobPO.getTaxAgentIds());
return intersection.size() > 0;
}
public List<SalarySobPO> listByTaxAgent(SalarySobQueryParam param) {
return getSalarySobService(user).list(param);
return getSalarySobService(user).list(param);
}
}