工资单支持跨扣缴义务人

This commit is contained in:
钱涛 2024-09-03 14:30:57 +08:00
parent 7f77f4cb12
commit 0b90f4890e
5 changed files with 54 additions and 49 deletions

View File

@ -44,6 +44,7 @@ public class SalarySendDetailListDTO {
// 个税扣缴义务人")
private String taxAgent;
private Long taxAgentId;
// 部门")
@I18n

View File

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

View File

@ -508,22 +508,11 @@
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 id="listByTaxAgentId" resultMap="BaseResultMap" 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}
WHERE t.delete_type = 0 and t.id = (select sob_id from hrsa_sob_tax_link where delete_type=0 and tax_agent_id=#{taxAgentId})
</select>
</mapper>

View File

@ -245,9 +245,9 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
List<SalaryAcctEmployeePO> salaryAcctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIds(Collections.singletonList(salaryAccountingId));
// 根据人员id去重
salaryAcctEmployees = salaryAcctEmployees.stream()
.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SalaryAcctEmployeePO::getEmployeeId))), ArrayList::new));
// // 根据人员id去重
// salaryAcctEmployees = salaryAcctEmployees.stream()
// .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SalaryAcctEmployeePO::getEmployeeId))), ArrayList::new));
// 1.回算如果是回算todo 要等原始核算发完或者上一个回算记录发完才行目前最多只有一个回算记录
if (Objects.equals(acctRecords.get(0).getBackCalcStatus(), (NumberUtils.INTEGER_ONE))) {
@ -555,7 +555,12 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
// 获取薪资项目数据
Long salaryAcctRecordId = salarySendInfo.getSalaryAcctRecordId();
List<SalaryAcctResultPO> salaryAcctResultPOS = getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctRecordId(salaryAcctRecordId).employeeId(currentEmployeeId).build());
SalaryAcctResultPO build = SalaryAcctResultPO.builder()
.salaryAcctRecordId(salaryAcctRecordId)
.taxAgentId(salarySendInfo.getTaxAgentId())
.employeeId(currentEmployeeId)
.build();
List<SalaryAcctResultPO> salaryAcctResultPOS = getSalaryAcctResultMapper().listSome(build);
if (CollUtil.isEmpty(salaryAcctResultPOS)) {
throw new SalaryRunTimeException("薪资核算结果不存在!");
}
@ -691,7 +696,6 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
}
private Date getLimitMonth() {
//工资单时效性
salaryBillViewingLimitSetting salaryBillViewingLimitSetting = getSalaryBillBaseSetService(user).getSalaryBillViewingLimitSetting();
@ -933,7 +937,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
.jobtitleName(simpleEmployee.getJobtitleName())
.jobtitleId(simpleEmployee.getJobtitleId())
.status(simpleEmployee.getStatus() == null ? "" : simpleEmployee.getStatus())
.statusName(simpleEmployee.getStatus() == null ? "" : UserStatusEnum.parseByValue(new Integer(Util.null2s(simpleEmployee.getStatus(),"1"))).getDefaultLabel())
.statusName(simpleEmployee.getStatus() == null ? "" : UserStatusEnum.parseByValue(new Integer(Util.null2s(simpleEmployee.getStatus(), "1"))).getDefaultLabel())
.telephone(StringUtils.isEmpty(simpleEmployee.getTelephone()) ? "" : simpleEmployee.getTelephone())
.username(StringUtils.isEmpty(simpleEmployee.getUsername()) ? "" : simpleEmployee.getUsername())
.workcode(StringUtils.isEmpty(simpleEmployee.getWorkcode()) ? "" : simpleEmployee.getWorkcode())
@ -974,16 +978,12 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
if (CollectionUtils.isEmpty(list)) {
return listMaps;
}
// 获取薪资项目数据
// List<SalaryAcctResultPO> salaryAccountingResults = new LambdaQueryChainWrapper<>(salaryAcctResultMapper)
// .eq(SalaryAcctResultPO::getDeleteType, 0)
// .eq(SalaryAcctResultPO::getSalaryAcctRecordId, salaryAccountingId).list();
SalaryAcctResultPO po = new SalaryAcctResultPO();
po.setDeleteType(0);
po.setSalaryAcctRecordId(salaryAccountingId);
po.setEmployeeIds(list.stream().map(SalarySendDetailListDTO::getEmployeeId).collect(Collectors.toList()));
List<SalaryAcctResultPO> salaryAccountingResults = getSalaryAcctResultMapper().listSome(po);
SalaryAcctResultPO build = SalaryAcctResultPO.builder()
.salaryAcctRecordId(salaryAccountingId)
.employeeIds(list.stream().map(SalarySendDetailListDTO::getEmployeeId).collect(Collectors.toList()))
.build();
List<SalaryAcctResultPO> salaryAccountingResults = getSalaryAcctResultMapper().listSome(build);
encryptUtil.decryptList(salaryAccountingResults, SalaryAcctResultPO.class);
// 动态列
List<DataCollectionEmployee> employeeList = getExtEmpService(user).listEmployee();
@ -1009,7 +1009,10 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
map.put("email", Objects.equals(employeeType, 1) ? extEmp.getEmail() : e.getEmail());
salaryItems.forEach(i -> {
Optional<SalaryAcctResultPO> optional = salaryAccountingResults.stream()
.filter(r -> r.getEmployeeId().equals(e.getEmployeeId()) && r.getSalaryItemId().equals(Long.valueOf(i.getSalaryItemId()))).findFirst();
.filter(r -> r.getTaxAgentId().equals(e.getTaxAgentId())
&& r.getEmployeeId().equals(e.getEmployeeId())
&& r.getSalaryItemId().equals(Long.valueOf(i.getSalaryItemId())))
.findFirst();
map.put(i.getSalaryItemId() + SalaryItemConstant.DYNAMIC_SUFFIX, optional.isPresent() ? optional.get().getResultValue() : "");
});
@ -1578,7 +1581,7 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
header.add(SalaryI18nUtil.getI18nLabel(86317, "工号"));
Map<String, SalaryTemplateSalaryItemListDTO> salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, dto -> dto.getSalaryItemId() + SalaryConstant.DYNAMIC_SUFFIX);
List<SalaryTemplateSalaryItemListDTO> sortedSalaryItems = new ArrayList<>();
for(String column : queryParam.getColumns()) {
for (String column : queryParam.getColumns()) {
if (column.contains(SalaryConstant.DYNAMIC_SUFFIX)) {
SalaryTemplateSalaryItemListDTO salaryTemplateSalaryItemListDTO = salaryItemMap.get(column);
if (salaryTemplateSalaryItemListDTO != null) {
@ -1660,13 +1663,6 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
mapper.batchHandleSalaryAcctTypeHistory();
}
//
// @BatchExportHandler("exportSalarySendDetail")
// public void salarySendDetailExportHandler() {
// BatchCallbackMessage message = BatchExportContext.getBatchCallbackMessage();
// System.out.println("接受到导出的结果" + JSONObject.toJSONString(message));
// }
@Override
public Map<String, Object> sumRow(SalarySendInfoQueryParam param) {
@ -1876,7 +1872,12 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
// 判断是否是补发
boolean isReplenish = NumberUtils.INTEGER_ONE.equals(salarySendInfo.getSalaryAcctType());
List<SalaryAcctResultPO> salaryAcctResultPOS = getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctRecordId(salarySendInfo.getSalaryAcctRecordId()).employeeId(recipient).build());
SalaryAcctResultPO build = SalaryAcctResultPO.builder()
.salaryAcctRecordId(salarySendInfo.getSalaryAcctRecordId())
.taxAgentId(salarySendInfo.getTaxAgentId())
.employeeId(recipient)
.build();
List<SalaryAcctResultPO> salaryAcctResultPOS = getSalaryAcctResultMapper().listSome(build);
if (CollUtil.isEmpty(salaryAcctResultPOS)) {
throw new SalaryRunTimeException("薪资核算结果不存在!");
}

View File

@ -183,7 +183,25 @@ public class SalarySobServiceImpl extends Service implements SalarySobService {
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()));
List<Long> taxAgentIds = sobTaxLinkPOS.stream().map(SobTaxLinkPO::getTaxAgentId).collect(Collectors.toList());
//处理历史数据
if (CollectionUtil.isEmpty(taxAgentIds)) {
SobTaxLinkPO taxLinkPO = SobTaxLinkPO.builder()
.id(IdGenerator.generate())
.taxAgentId(sobPO.getTaxAgentId())
.sobId(sobPO.getId())
.creator((long) user.getUID())
.createTime(new Date())
.updateTime(new Date())
.deleteType(0)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.build();
getSobTaxLinkMapper().insertIgnoreNull(taxLinkPO);
taxAgentIds.add(sobPO.getTaxAgentId());
}
sobPO.setTaxAgentIds(taxAgentIds);
return sobPO;
}
@ -197,13 +215,7 @@ public class SalarySobServiceImpl extends Service implements SalarySobService {
@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;
return ids.stream().map(this::getByIdWithTax).collect(Collectors.toList());
}
@Override
@ -257,7 +269,7 @@ public class SalarySobServiceImpl extends Service implements SalarySobService {
@Override
public List<SalarySobPO> listByTaxAgentId(Long taxAgentId) {
return salarySobMapper.listSome(SalarySobPO.builder().disable(NumberUtils.INTEGER_ZERO).taxAgentId(taxAgentId).build());
return getSalarySobMapper().listByTaxAgentId(taxAgentId);
}
@Override
@ -1077,7 +1089,8 @@ public class SalarySobServiceImpl extends Service implements SalarySobService {
}
if (param.getTaxAgentId() != null) {
sobPO.setTaxAgentId(param.getTaxAgentId());
List<SobTaxLinkPO> sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().taxAgentId(param.getTaxAgentId()).build());
sobPO.setIds(SalaryEntityUtil.properties(sobTaxLinkPOS, SobTaxLinkPO::getSobId));
}
return getSalarySobMapper().listSome(sobPO);
}