跨扣缴义务人核算

This commit is contained in:
钱涛 2024-09-02 17:36:41 +08:00
parent c72fa7fd7c
commit ecfa6a4604
17 changed files with 142 additions and 170 deletions

View File

@ -1 +1,2 @@
formulaRunOvertimeThreshold=
formulaRunOvertimeThreshold=100
threadNumber=10

View File

@ -273,65 +273,73 @@ public class SalaryAcctResultBO {
}
SalaryI18nUtil.i18nList(salaryAcctEmployees);
Map<Long, DataCollectionEmployee> employeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId);
Map<Long, List<SalaryAcctResultPO>> acctResultMap = SalaryEntityUtil.group2Map(salaryAccountingResults, SalaryAcctResultPO::getEmployeeId);
Map<Long, String> taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getId, TaxAgentPO::getName);
return salaryAcctEmployees.stream().map(e -> {
Map<Long, Object> resultValueMap = SalaryEntityUtil.convert2Map(acctResultMap.getOrDefault(e.getEmployeeId(), Collections.emptyList()),
SalaryAcctResultPO::getSalaryItemId, SalaryAcctResultPO::getResultValue);
// 薪资项目的值
Map<String, Object> map = SalaryEntityUtil.convert2Map(salaryItems, o -> "" + o.getId(), o -> resultValueMap.getOrDefault(o.getId(), StringUtils.EMPTY));
// 薪资项目的字段类型前端依据这个判断是否需要展示千分位
Map<String, String> dataTypeMap = SalaryEntityUtil.convert2Map(salaryItems, salaryItemPO -> salaryItemPO.getId() + DATA_TYPE_SUFFIX, SalaryItemPO::getDataType);
map.putAll(dataTypeMap);
// 人员信息字段的值
Map<String, String> fieldValueMap = SalaryAcctFormulaBO.convert2FormulaEmployee(employeeMap.get(e.getEmployeeId()), e, true);
for (SalarySobEmpFieldPO salarySobEmpField : salarySobEmpFields) {
// 员工信息字段的字段类型
if (dynamicEmpInfo) {
map.put(salarySobEmpField.getFieldCode(), fieldValueMap.get(salarySobEmpField.getFieldCode()));
} else {
if ("departmentName".equals(salarySobEmpField.getFieldCode())) {
map.put("departmentName", e.getDepartmentName());
} else if ("departmentId".equals(salarySobEmpField.getFieldCode())) {
map.put("departmentId", e.getDepartmentId());
} else if ("subcompanyName".equals(salarySobEmpField.getFieldCode())) {
map.put("subcompanyName", e.getSubcompanyName());
} else if ("jobcall".equals(salarySobEmpField.getFieldCode())) {
map.put("jobcall", e.getJobcall());
} else if ("jobcallId".equals(salarySobEmpField.getFieldCode())) {
map.put("jobcallId", e.getJobcallId());
} else if ("jobtitleName".equals(salarySobEmpField.getFieldCode())) {
map.put("jobtitleName", e.getJobtitleName());
} else if ("jobtitleId".equals(salarySobEmpField.getFieldCode())) {
map.put("jobtitleId", e.getJobtitleId());
} else if ("status".equals(salarySobEmpField.getFieldCode())) {
map.put("status", e.getStatus());
} else if ("statusName".equals(salarySobEmpField.getFieldCode())) {
map.put("statusName", UserStatusEnum.getDefaultLabelByValue(new Integer(Util.null2s(e.getStatus(), "1"))));
} else {
Map<Long, List<SalaryAcctEmployeePO>> taxAcctEmpsMap = SalaryEntityUtil.group2Map(salaryAcctEmployees, SalaryAcctEmployeePO::getTaxAgentId);
Map<Long, List<SalaryAcctResultPO>> taxAcctResultMap = SalaryEntityUtil.group2Map(salaryAccountingResults, SalaryAcctResultPO::getTaxAgentId);
List<Map<String, Object>> result = new ArrayList<>();
for (Long taxAgentId : taxAcctEmpsMap.keySet()) {
Map<Long, List<SalaryAcctResultPO>> acctResultMap = SalaryEntityUtil.group2Map(taxAcctResultMap.get(taxAgentId), SalaryAcctResultPO::getEmployeeId);
List<Map<String, Object>> collect = taxAcctEmpsMap.get(taxAgentId).stream().map(e -> {
Map<Long, Object> resultValueMap = SalaryEntityUtil.convert2Map(acctResultMap.getOrDefault(e.getEmployeeId(), Collections.emptyList()),
SalaryAcctResultPO::getSalaryItemId, SalaryAcctResultPO::getResultValue);
// 薪资项目的值
Map<String, Object> map = SalaryEntityUtil.convert2Map(salaryItems, o -> "" + o.getId(), o -> resultValueMap.getOrDefault(o.getId(), StringUtils.EMPTY));
// 薪资项目的字段类型前端依据这个判断是否需要展示千分位
Map<String, String> dataTypeMap = SalaryEntityUtil.convert2Map(salaryItems, salaryItemPO -> salaryItemPO.getId() + DATA_TYPE_SUFFIX, SalaryItemPO::getDataType);
map.putAll(dataTypeMap);
// 人员信息字段的值
Map<String, String> fieldValueMap = SalaryAcctFormulaBO.convert2FormulaEmployee(employeeMap.get(e.getEmployeeId()), e, true);
for (SalarySobEmpFieldPO salarySobEmpField : salarySobEmpFields) {
// 员工信息字段的字段类型
if (dynamicEmpInfo) {
map.put(salarySobEmpField.getFieldCode(), fieldValueMap.get(salarySobEmpField.getFieldCode()));
} else {
if ("departmentName".equals(salarySobEmpField.getFieldCode())) {
map.put("departmentName", e.getDepartmentName());
} else if ("departmentId".equals(salarySobEmpField.getFieldCode())) {
map.put("departmentId", e.getDepartmentId());
} else if ("subcompanyName".equals(salarySobEmpField.getFieldCode())) {
map.put("subcompanyName", e.getSubcompanyName());
} else if ("jobcall".equals(salarySobEmpField.getFieldCode())) {
map.put("jobcall", e.getJobcall());
} else if ("jobcallId".equals(salarySobEmpField.getFieldCode())) {
map.put("jobcallId", e.getJobcallId());
} else if ("jobtitleName".equals(salarySobEmpField.getFieldCode())) {
map.put("jobtitleName", e.getJobtitleName());
} else if ("jobtitleId".equals(salarySobEmpField.getFieldCode())) {
map.put("jobtitleId", e.getJobtitleId());
} else if ("status".equals(salarySobEmpField.getFieldCode())) {
map.put("status", e.getStatus());
} else if ("statusName".equals(salarySobEmpField.getFieldCode())) {
map.put("statusName", UserStatusEnum.getDefaultLabelByValue(new Integer(Util.null2s(e.getStatus(), "1"))));
} else {
map.put(salarySobEmpField.getFieldCode(), fieldValueMap.get(salarySobEmpField.getFieldCode()));
}
}
map.put(salarySobEmpField.getFieldCode() + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue());
}
map.put(salarySobEmpField.getFieldCode() + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue());
}
// 主键id
map.put("id", e.getId());
//锁定状态
map.put("lockStatus", LockStatusEnum.getByValue(e.getLockStatus()).getDefaultLabel());
//人员id
map.put("employeeId", e.getEmployeeId());
// 个税扣缴义务人
String taxAgentName = taxAgentNameMap.getOrDefault(e.getTaxAgentId(), StringUtils.EMPTY);
map.put("taxAgentName", taxAgentName);
// 是否属于"合并计税"的标记
map.put("consolidatedTaxation", StringUtils.isNotEmpty(taxAgentName) && consolidatedTaxSalaryAcctEmpIds.contains(e.getId()));
// 个税扣缴义务人的字段类型
map.put("taxAgentName" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue());
// 公式详情
customParameters.putAll(customBackCalcParameters);
map.put("customParameters", customParameters);
return map;
}).collect(Collectors.toList());
// 主键id
map.put("id", e.getId());
//锁定状态
map.put("lockStatus", LockStatusEnum.getByValue(e.getLockStatus()).getDefaultLabel());
//人员id
map.put("employeeId", e.getEmployeeId());
// 个税扣缴义务人
String taxAgentName = taxAgentNameMap.getOrDefault(e.getTaxAgentId(), StringUtils.EMPTY);
map.put("taxAgentName", taxAgentName);
// 是否属于"合并计税"的标记
map.put("consolidatedTaxation", StringUtils.isNotEmpty(taxAgentName) && consolidatedTaxSalaryAcctEmpIds.contains(e.getId()));
// 个税扣缴义务人的字段类型
map.put("taxAgentName" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue());
// 公式详情
customParameters.putAll(customBackCalcParameters);
map.put("customParameters", customParameters);
return map;
}).collect(Collectors.toList());
result.addAll(collect);
}
return result;
}
/**

View File

@ -106,75 +106,6 @@ public class SalaryArchiveBO {
LocalDateRange localDateRange,
List<Long> allEmployeeIds,
boolean isOnlyTaxAgent) {
// // 开始日期
// Date start = localDateRange.getFromDate();
// // 结束日期
// Date end = localDateRange.getEndDate();
//
// List<SalaryArchiveDataDTO> list = new ArrayList<>();
// allEmployeeIds.forEach(e -> {
// // 同一个人的档案数据
// List<SalaryArchivePO> salaryArchives = salaryArchiveList.stream().filter(f -> f.getEmployeeId().equals(e)).collect(Collectors.toList());
// List<Long> salaryArchiveIds = salaryArchives.stream().map(SalaryArchivePO::getId).collect(Collectors.toList());
// // 同一个人的薪资项目调整历史数据
// List<SalaryArchiveItemPO> salaryArchiveItems = salaryArchiveItemDataList.stream().filter(d -> salaryArchiveIds.contains(d.getSalaryArchiveId())).collect(Collectors.toList());
// List<Long> salaryArchiveItemIds = salaryArchiveItems.stream().map(SalaryArchiveItemPO::getSalaryItemId).distinct().collect(Collectors.toList());
//
// SalaryArchiveDataDTO salaryArchiveData = new SalaryArchiveDataDTO();
// salaryArchiveData.setEmployeeId(e);
// List<SalaryArchiveTaxAgentDataDTO> taxAgents = new ArrayList<>();
// // 按个税扣缴义务人生效日期时间段切割
// for (SalaryArchivePO salaryArchive : salaryArchives) {
// Date fromDate = salaryArchive.getPayStartDate();
// Date endDate = salaryArchive.getPayEndDate();
// // 起始发薪日不为空且不能比结束日期晚最后发薪日可空可不空但是如果不为空就不能比开始日期早且起始发薪日不能晚于最后发薪日
// boolean isEnable = fromDate != null && !fromDate.after(end) && (endDate == null || (!fromDate.after(endDate) && !endDate.before(start)));
// if (isEnable) {
// SalaryArchiveTaxAgentDataDTO taxAgent = new SalaryArchiveTaxAgentDataDTO();
// taxAgent.setTaxAgentId(salaryArchive.getTaxAgentId());
//// taxAgent.setIncomeCategory(salaryArchive.getIncomeCategory());
// taxAgent.setEffectiveDateRange(LocalDateRange.builder().fromDate((fromDate.before(start) ? start : fromDate)).endDate(endDate == null || endDate.after(end) ? end : endDate).build());
// // 薪资项目数据按个税扣缴义务人切割
// if (!isOnlyTaxAgent) {
// // 开始日期
// Date startItem = taxAgent.getEffectiveDateRange().getFromDate();
// // 结束日期
// Date endItem = taxAgent.getEffectiveDateRange().getEndDate();
// Date endTempItem = endItem;
// List<SalaryArchiveItemDataDTO> salaryItemValues = new ArrayList<>();
// for (Long salaryArchiveItemId : salaryArchiveItemIds) {
// for (SalaryArchiveItemPO salaryArchiveItem : salaryArchiveItems) {
// if (!salaryArchiveItemId.equals(salaryArchiveItem.getSalaryItemId()) || !salaryArchiveItem.getSalaryArchiveId().equals(salaryArchive.getId())) {
// continue;
// }
// Date fromDateItem = salaryArchiveItem.getEffectiveTime();
// if (fromDateItem.after(endTempItem) || (!endTempItem.after(startItem) && !endTempItem.equals(startItem))) {
// continue;
// }
// SalaryArchiveItemDataDTO salaryArchiveItemData = new SalaryArchiveItemDataDTO();
// salaryArchiveItemData.setEffectiveDateRange(LocalDateRange.builder().fromDate((fromDateItem.before(startItem) ? startItem : fromDateItem)).endDate(endTempItem).build());
// //fixme 排除1号调薪之前的历史周期为2022-01-01-2022-01-01这种情况
// if (!salaryArchiveItemData.getEffectiveDateRange().getFromDate().before(salaryArchiveItemData.getEffectiveDateRange().getEndDate())) {
// continue;
// }
// salaryArchiveItemData.setSalaryItemId(salaryArchiveItem.getSalaryItemId());
// salaryArchiveItemData.setValue(salaryArchiveItem.getItemValue());
// salaryItemValues.add(salaryArchiveItemData);
// endTempItem = fromDateItem;
// }
// endTempItem = endItem;
// }
// taxAgent.setSalaryItemValues(salaryItemValues);
// }
// taxAgents.add(taxAgent);
// }
// }
// salaryArchiveData.setTaxAgents(taxAgents);
// list.add(salaryArchiveData);
// });
//
// return list;
// 开始日期
Date start = localDateRange.getFromDate();

View File

@ -15,6 +15,7 @@ import lombok.experimental.Accessors;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Set;
/**
@ -54,8 +55,11 @@ public class SalarySobPO {
@ElogTransform( name="个税扣缴义务人id" )
@XStreamAlias("taxAgentId")
@XStreamAsAttribute
@Deprecated
private Long taxAgentId;
List<Long> taxAgentIds;
/**
* 应税项目1:正常工资薪金所得
*/
@ -176,7 +180,7 @@ public class SalarySobPO {
private String tenantKey;
Collection<Long> ids;
Collection<Long> taxAgentIds;
private Set<String> opts;

View File

@ -54,4 +54,5 @@ public interface SalarySobMapper {
List<SalarySobPO> listByName(SalarySobPO build);
SalarySobPO getByIdWithTax(Long id);
}

View File

@ -508,6 +508,22 @@
and name = #{name}
</select>
<resultMap id="getByIdWithTaxMap" type="com.engine.salary.entity.salarysob.po.SalarySobPO">
<result column="id" property="id"/>
<collection property="taxAgentIds" ofType="long" javaType="arraylist">
<constructor>
<arg column="tax_agent_id"/>
</constructor>
</collection>
</resultMap>
<select id="getByIdWithTax" resultMap="getByIdWithTaxMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
, l.tax_agent_id
FROM hrsa_salary_sob t
left join hrsa_sob_tax_link l on t.id=l.sob_id and t.delete_type=0 and l.delete_type=0
WHERE t.id = #{id}
</select>
</mapper>

View File

@ -98,7 +98,7 @@ public interface AddUpDeductionService {
* @param employeeIds
* @return
*/
List<AddUpDeduction> getAddUpDeductionList(YearMonth declareMonth, List<Long> employeeIds, Long taxAgentId);
List<AddUpDeduction> getAddUpDeductionList(YearMonth declareMonth, List<Long> employeeIds, List<Long> taxAgentIds);
/**
* 根据年月获取已核算数据

View File

@ -84,7 +84,7 @@ public interface OtherDeductionService {
* @param employeeIds
* @return
*/
List<OtherDeductionPO> getOtherDeductionList(YearMonth declareMonth, List<Long> employeeIds, Long taxAgentId);
List<OtherDeductionPO> getOtherDeductionList(YearMonth declareMonth, List<Long> employeeIds, List<Long> taxAgentIds);
/**
* 编辑数据

View File

@ -114,7 +114,7 @@ public interface SalaryArchiveService {
* @param employeeIds 为空则返回所有人的
* @return
*/
List<SalaryArchiveDataDTO> getSalaryArchiveData(LocalDateRange localDateRange, Collection<Long> employeeIds, Long taxAgentId);
List<SalaryArchiveDataDTO> getSalaryArchiveData(LocalDateRange localDateRange, Collection<Long> employeeIds, List<Long> taxAgentIds);
/**
* 根据日期范围与人员id获取薪资档案-个税扣缴义务人数据
@ -123,7 +123,7 @@ public interface SalaryArchiveService {
* @param employeeIds 为空则返回所有人的
* @return
*/
List<SalaryArchiveDataDTO> getSalaryArchiveTaxAgentData(LocalDateRange localDateRange, Collection<Long> employeeIds, Long taxAgentId);
List<SalaryArchiveDataDTO> getSalaryArchiveTaxAgentData(LocalDateRange localDateRange, Collection<Long> employeeIds, List<Long> taxAgentIds);
/**
* 预览

View File

@ -30,6 +30,8 @@ public interface SalarySobService {
*/
SalarySobPO getById(Long id);
SalarySobPO getByIdWithTax(Long id);
/**
* 根据主键id查询薪资账套
*
@ -154,7 +156,7 @@ public interface SalarySobService {
* @param taxAgentIds
* @return
*/
List<SalarySobPO> listByTaxAgentIds(Collection<Long> taxAgentIds);
List<SalarySobPO> listByTaxAgentIds(List<Long> taxAgentIds);
List<SalarySobConfig> getConfig(Long taxAgentId);

View File

@ -913,9 +913,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
}
private Map<Long, List<AddUpDeduction>> getEmpInfoByYearMonth(TaxAgentPO taxAgent, List<SpecialAddDeductionPO> employeePOs, YearMonth lastMonth) {
List<AddUpDeduction> addUpDeductionList = getAddUpDeductionList(lastMonth,
employeePOs.stream().map(SpecialAddDeductionPO::getEmployeeId).collect(Collectors.toList()),
taxAgent.getId());
List<AddUpDeduction> addUpDeductionList = getAddUpDeductionList(lastMonth, employeePOs.stream().map(SpecialAddDeductionPO::getEmployeeId).collect(Collectors.toList()), Collections.singletonList(taxAgent.getId()));
return addUpDeductionList.stream()
.filter(addUpDeduction -> taxAgent.getId().equals(addUpDeduction.getTaxAgentId()))
.collect(Collectors.groupingBy(AddUpDeduction::getEmployeeId));
@ -1127,12 +1125,12 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
@Override
public List<AddUpDeduction> getAddUpDeductionList(YearMonth declareMonth, List<Long> employeeIds, Long taxAgentId) {
public List<AddUpDeduction> getAddUpDeductionList(YearMonth declareMonth, List<Long> employeeIds, List<Long> taxAgentIds) {
AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz();
if (declareMonth == null) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100342, "参数有误申报月份、租户key必传"));
}
return addUpDeductionBiz.listSome(AddUpDeduction.builder().declareMonth(SalaryDateUtil.toDateStartOfMonth(declareMonth)).employeeIds(employeeIds).taxAgentId(taxAgentId).build());
return addUpDeductionBiz.listSome(AddUpDeduction.builder().declareMonth(SalaryDateUtil.toDateStartOfMonth(declareMonth)).employeeIds(employeeIds).taxAgentIds(taxAgentIds).build());
}
@Override

View File

@ -352,7 +352,7 @@ public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDa
for (Long salarySobId : salarySobIds) {
// 获取薪资账套
SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salarySobId, YearMonth.of(year, month));
SalarySobPO salarySobPO = getSalarySobService(user).getById(salarySobId);
SalarySobPO salarySobPO = getSalarySobService(user).getByIdWithTax(salarySobId);
// 根据薪资账套查询人员
List<DataCollectionEmployee> salaryEmployees = getSalaryEmployeeService(user).listBySalarySobId(salarySobId);
@ -360,17 +360,17 @@ public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDa
errorMsg = errorMsg + "" + salarySobPO.getName() + "】薪资账套没有人员; ";
} else {
// 根据薪资账套查询薪资周期
Long taxAgentId = salarySobPO.getTaxAgentId();
List<Long> taxAgentIds = salarySobPO.getTaxAgentIds();
// 查询薪资档案获取人员的个税扣缴义务人
List<Long> employeeIds = SalaryEntityUtil.properties(salaryEmployees, DataCollectionEmployee::getEmployeeId, Collectors.toList());
List<SalaryArchiveDataDTO> salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentId);
List<SalaryArchiveDataDTO> salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentIds);
// 转换成薪资核算人员po
Date salaryDate = SalaryDateUtil.dateStrToLocalTime(salaryYearMonth + "-01");
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2Employee(salaryEmployees, SalaryAcctRecordPO.builder().salarySobId(salarySobId).salaryMonth(salaryDate).build(), salaryArchiveDataDTOS, (long) user.getUID());
//过滤掉不属于当前账套扣缴义务人的人员
employeeIds = salaryAcctEmployeePOS.stream().filter(po -> Objects.equals(taxAgentId, po.getTaxAgentId())).map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toList());
employeeIds = salaryAcctEmployeePOS.stream().filter(po -> taxAgentIds.contains(po.getTaxAgentId())).map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toList());
// 4.获取考勤模块数据

View File

@ -636,12 +636,12 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction
@Override
public List<OtherDeductionPO> getOtherDeductionList(YearMonth declareMonth, List<Long> employeeIds, Long taxAgentId) {
public List<OtherDeductionPO> getOtherDeductionList(YearMonth declareMonth, List<Long> employeeIds, List<Long> taxAgentIds) {
if (declareMonth == null) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100342, "参数有误:申报月份必传"));
}
OtherDeductionBiz OtherDeductionBiz = new OtherDeductionBiz();
return OtherDeductionBiz.listSome(OtherDeductionPO.builder().declareMonth(SalaryDateUtil.toDateStartOfMonth(declareMonth)).employeeIds(employeeIds).taxAgentId(taxAgentId).build());
return OtherDeductionBiz.listSome(OtherDeductionPO.builder().declareMonth(SalaryDateUtil.toDateStartOfMonth(declareMonth)).employeeIds(employeeIds).taxAgentIds(taxAgentIds).build());
}
@Override

View File

@ -121,11 +121,11 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
List<Long> employeeIds = SalaryEntityUtil.properties(salaryAcctCalculateBO.getSalaryAcctEmployeePOS(), SalaryAcctEmployeePO::getEmployeeId, Collectors.toList());
List<DataCollectionEmployee> simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds);
SalarySobCycleDTO salarySobCycleDTO = salaryAcctCalculateBO.getSalarySobCycleDTO();
Long taxAgentId = salaryAcctCalculateBO.getSalarySobPO().getTaxAgentId();
List<Long> taxAgentIds = salaryAcctCalculateBO.getSalarySobPO().getTaxAgentIds();
sw.stop();
// 2查询薪资档案的数据
sw.start("查询薪资档案的数据");
List<SalaryArchiveDataDTO> salaryArchiveData = getSalaryArchiveService(user).getSalaryArchiveData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentId);
List<SalaryArchiveDataDTO> salaryArchiveData = getSalaryArchiveService(user).getSalaryArchiveData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentIds);
sw.stop();
// 3查询往期累计情况(查询的是上个税款所属期的的累计情况)
sw.start("查询往期累计情况");
@ -139,15 +139,16 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
sw.stop();
// 4查询累计专项附加扣除
sw.start("查询累计专项附加扣除");
List<AddUpDeduction> addUpDeductionPOS = getAddUpDeductionService(user).getAddUpDeductionList(salarySobCycleDTO.getTaxCycle(), employeeIds, taxAgentId);
List<AddUpDeduction> addUpDeductionPOS = getAddUpDeductionService(user).getAddUpDeductionList(salarySobCycleDTO.getTaxCycle(), employeeIds, taxAgentIds);
sw.stop();
// 5查询其他免税扣除
sw.start("查询其他免税扣除");
List<OtherDeductionPO> otherDeductionPOS = getOtherDeductionService(user).getOtherDeductionList(salarySobCycleDTO.getTaxCycle(), employeeIds, taxAgentId);
List<OtherDeductionPO> otherDeductionPOS = getOtherDeductionService(user).getOtherDeductionList(salarySobCycleDTO.getTaxCycle(), employeeIds, taxAgentIds);
sw.stop();
//6查询社保福利
sw.start("查询社保福利");
List<Map<String, Object>> welfareData = getSIAccountService(user).welfareData(salarySobCycleDTO.getSocialSecurityCycle().toString(), employeeIds, taxAgentId);
//getSIAccountService(user).welfareData(salarySobCycleDTO.getSocialSecurityCycle().toString(), employeeIds, taxAgentIds)
List<Map<String, Object>> welfareData = new ArrayList<>();
sw.stop();
// 7查询考勤数据
sw.start("查询考勤数据");

View File

@ -5,9 +5,9 @@ import cn.hutool.core.date.DateUtil;
import com.api.formmode.mybatis.util.SqlProxyHandle;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.hrmelog.entity.dto.LoggerContext;
import com.engine.salary.config.SalaryElogConfig;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.hrmelog.entity.dto.LoggerContext;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryacct.bo.SalaryAcctEmployeeBO;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctEmployeeCountDTO;
@ -23,6 +23,7 @@ import com.engine.salary.enums.salaryaccounting.LockStatusEnum;
import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.salaryacct.SalaryAcctEmployeeMapper;
import com.engine.salary.mapper.salarysob.SobTaxLinkMapper;
import com.engine.salary.mapper.sys.SalarySysConfMapper;
import com.engine.salary.report.entity.param.SalaryStatisticsReportDataQueryParam;
import com.engine.salary.service.*;
@ -62,6 +63,10 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
return MapperProxyFactory.getProxy(SalaryAcctEmployeeMapper.class);
}
private SobTaxLinkMapper getSobTaxLinkMapper() {
return MapperProxyFactory.getProxy(SobTaxLinkMapper.class);
}
private SalaryAcctRecordService getSalaryAcctRecordService(User user) {
return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user);
}
@ -397,22 +402,22 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
// 根据薪资账套查询薪资周期
SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(), SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()));
//获取核算的扣缴义务人
SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId());
SalarySobPO salarySobPO = getSalarySobService(user).getByIdWithTax(salaryAcctRecordPO.getSalarySobId());
if (Objects.isNull(salarySobPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98769, "薪资账套不存在或已被删除"));
}
Long taxAgentId = salarySobPO.getTaxAgentId();
List<Long> taxAgentIds = salarySobPO.getTaxAgentIds();
List<DataCollectionEmployee> employees = getSalaryEmployeeService(user).getEmployeeByIdsAll((List) saveParam.getEmployeeIds());
// 查询薪资档案
List<SalaryArchiveDataDTO> salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), saveParam.getEmployeeIds(), taxAgentId);
List<SalaryArchiveDataDTO> salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), saveParam.getEmployeeIds(), taxAgentIds);
// 转换成薪资核算人员po
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2Employee(employees, salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID());
//过滤不是扣缴义务人下的人员
salaryAcctEmployeePOS = salaryAcctEmployeePOS.stream().filter(ps -> Objects.equals(taxAgentId, ps.getTaxAgentId())).collect(Collectors.toList());
salaryAcctEmployeePOS = salaryAcctEmployeePOS.stream().filter(ps -> taxAgentIds.contains(ps.getTaxAgentId())).collect(Collectors.toList());
// 保存薪资核算人员
if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98769, "个税扣缴义务人下无该人员档案信息或薪资缴纳日期不在薪资周期内"));
@ -524,20 +529,17 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
//查询账套对应的扣缴义务人
SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId());
Long taxAgentId = salarySobPO.getTaxAgentId();
// //过滤扣税扣缴义务人不包含的人员
// Collection<Long> employeeIdsInTaxAgent = getTaxAgentService(user).listEmployeeIdsInTaxAgent(taxAgentId);
// salaryEmployees = salaryEmployees.stream().filter(salaryEmployee -> employeeIdsInTaxAgent.contains(salaryEmployee.getEmployeeId())).collect(Collectors.toList());
SalarySobPO salarySobPO = getSalarySobService(user).getByIdWithTax(salaryAcctRecordPO.getSalarySobId());
List<Long> taxAgentIds = salarySobPO.getTaxAgentIds();
// 查询薪资档案获取人员的个税扣缴义务人
List<Long> employeeIds = SalaryEntityUtil.properties(salaryEmployees, DataCollectionEmployee::getEmployeeId, Collectors.toList());
List<SalaryArchiveDataDTO> salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentId);
List<SalaryArchiveDataDTO> salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentIds);
// 转换成薪资核算人员po
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2Employee(salaryEmployees, salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID());
//过滤掉不属于当前账套扣缴义务人的人员
salaryAcctEmployeePOS = salaryAcctEmployeePOS.stream().filter(po -> Objects.equals(taxAgentId, po.getTaxAgentId())).collect(Collectors.toList());
salaryAcctEmployeePOS = salaryAcctEmployeePOS.stream().filter(po -> taxAgentIds.contains(po.getTaxAgentId())).collect(Collectors.toList());
// 保存薪资核算人员
if (CollectionUtils.isNotEmpty(salaryAcctEmployeePOS)) {
@ -559,18 +561,18 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
}
//查询账套对应的扣缴义务人
SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId());
SalarySobPO salarySobPO = getSalarySobService(user).getByIdWithTax(salaryAcctRecordPO.getSalarySobId());
//过滤掉不属于当前账套扣缴义务人的人员
Long taxAgentId = salarySobPO.getTaxAgentId();
List<Long> taxAgentIds = salarySobPO.getTaxAgentIds();
// 查询薪资核算记录所用的帐套的薪资周期
SalarySobCycleDTO salarySobCycleDTO = getSalarySobService(user).getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(), SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()));
// 查询薪资档案获取人员的个税扣缴义务人
List<SalaryArchiveDataDTO> salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentId);
List<SalaryArchiveDataDTO> salaryArchiveDataDTOS = getSalaryArchiveService(user).getSalaryArchiveTaxAgentData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentIds);
List<DataCollectionEmployee> employees = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds);
// 转换成薪资核算人员po
List<SalaryAcctEmployeePO> newSalaryAcctEmployeePOS = SalaryAcctEmployeeBO.convert2Employee(employees, salaryAcctRecordPO, salaryArchiveDataDTOS, (long) user.getUID());
newSalaryAcctEmployeePOS = newSalaryAcctEmployeePOS.stream().filter(po -> Objects.equals(taxAgentId, po.getTaxAgentId())).collect(Collectors.toList());
newSalaryAcctEmployeePOS = newSalaryAcctEmployeePOS.stream().filter(po ->taxAgentIds.contains(po.getTaxAgentId())).collect(Collectors.toList());
// 删除以前的薪资核算人员
getSalaryAcctEmployeeMapper().deleteBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId));
// 插入新的薪资核算人员

View File

@ -818,13 +818,13 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
}
@Override
public List<SalaryArchiveDataDTO> getSalaryArchiveData(LocalDateRange localDateRange, Collection<Long> employeeIds, Long taxAgentId) {
return getSalaryArchiveData(localDateRange, employeeIds, taxAgentId, Boolean.FALSE);
public List<SalaryArchiveDataDTO> getSalaryArchiveData(LocalDateRange localDateRange, Collection<Long> employeeIds, List<Long> taxAgentIds) {
return getSalaryArchiveData(localDateRange, employeeIds, taxAgentIds, Boolean.FALSE);
}
@Override
public List<SalaryArchiveDataDTO> getSalaryArchiveTaxAgentData(LocalDateRange localDateRange, Collection<Long> employeeIds, Long taxAgentId) {
return getSalaryArchiveData(localDateRange, employeeIds, taxAgentId, Boolean.TRUE);
public List<SalaryArchiveDataDTO> getSalaryArchiveTaxAgentData(LocalDateRange localDateRange, Collection<Long> employeeIds, List<Long> taxAgentIds) {
return getSalaryArchiveData(localDateRange, employeeIds, taxAgentIds, Boolean.TRUE);
}
/**
@ -835,7 +835,7 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
* @param isOnlyTaxAgent
* @return
*/
private List<SalaryArchiveDataDTO> getSalaryArchiveData(LocalDateRange localDateRange, Collection<Long> employeeIds, Long taxAgentId, boolean isOnlyTaxAgent) {
private List<SalaryArchiveDataDTO> getSalaryArchiveData(LocalDateRange localDateRange, Collection<Long> employeeIds, List<Long> taxAgentIds, boolean isOnlyTaxAgent) {
// 获取核算人员规则
List<String> statusList = Collections.emptyList();
SalarySysConfPO employeeRule = getSalarySysConfService(user).getOneByCode(SalarySysConstant.SALARY_ACCT_EMPLOYEE_RULE);
@ -848,7 +848,7 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
statusList = Arrays.asList(SalaryArchiveStatusEnum.FIXED.getValue(), SalaryArchiveStatusEnum.SUSPEND.getValue());
}
// 获取薪资档案数据
List<SalaryArchivePO> salaryArchiveList = listSome(SalaryArchivePO.builder().runStatusList(statusList).employeeIds(employeeIds).taxAgentId(taxAgentId).build());
List<SalaryArchivePO> salaryArchiveList = listSome(SalaryArchivePO.builder().runStatusList(statusList).employeeIds(employeeIds).taxAgentIds(taxAgentIds).build());
List<Long> allEmployeeIds = salaryArchiveList.stream().map(SalaryArchivePO::getEmployeeId).distinct().collect(Collectors.toList());
// 获取所有可被引用的薪资项目

View File

@ -179,6 +179,14 @@ public class SalarySobServiceImpl extends Service implements SalarySobService {
return salarySobMapper.getById(id);
}
@Override
public SalarySobPO getByIdWithTax(Long 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;
}
@Override
public List<SalarySobPO> listByIds(Collection<Long> ids) {
if (CollectionUtils.isEmpty(ids)) {
@ -861,7 +869,7 @@ public class SalarySobServiceImpl extends Service implements SalarySobService {
}
@Override
public List<SalarySobPO> listByTaxAgentIds(Collection<Long> taxAgentIds) {
public List<SalarySobPO> listByTaxAgentIds(List<Long> taxAgentIds) {
if (CollectionUtils.isEmpty(taxAgentIds)) {
return new ArrayList<>();
}