fix社保福利台账核算人员bug

This commit is contained in:
Harryxzy 2025-02-08 11:28:36 +08:00
parent c77ecf8d69
commit be59482fc8
3 changed files with 45 additions and 29 deletions

View File

@ -28,6 +28,8 @@ public interface SIAccountDetailTempMapper {
*/
void batchDelByEmpIdsAndMonthAndPayOrg(@Param("employeeIds") Collection<Long> employeeIds, @Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization);
void batchDelByMonthAndPayOrg(@Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization);
/**
* 批量保存
* @param accounts

View File

@ -139,6 +139,14 @@
</foreach>
</delete>
<update id="batchDelByMonthAndPayOrg">
UPDATE hrsa_bill_detail_temp
SET delete_type = 1
WHERE delete_type = 0
AND bill_month = #{billMonth}
AND payment_organization = #{paymentOrganization}
</update>
<insert id="batchSaveAccountTempDetails">
INSERT INTO hrsa_bill_detail_temp

View File

@ -5073,7 +5073,7 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
// Map<Long, InsuranceArchivesAccountPO> insuranceArchivesAccountPOS = siArchivesBiz.buildBatchAccount(ids, paymentOrganization);
Map<Long, InsuranceArchivesAccountPO> insuranceArchivesAccountPOS = getSIArchivesService(user).buildBatchAccount(ids, paymentOrganization);
List<InsuranceAccountDetailPO> historyDetailData = new ArrayList<>();
List<DataCollectionEmployee> employeeList = new ArrayList<>();
List<DataCollectionEmployee> employeeList = getSalaryEmployeeService(user).listByIds(ids);
if (!isFirstFlag) {
// 不是首次核算需要把社保历史数据取出
List<List<Long>> partition = Lists.partition(ids, 100);
@ -5081,8 +5081,6 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
historyDetailData.addAll(getInsuranceAccountDetailMapper().list(InsuranceAccountDetailParam.builder().billMonth(billMonth).paymentOrganization(paymentOrganization.toString()).employeeIds(part).build()));
historyDetailData.addAll(getInsuranceAccountDetailMapper().extList(InsuranceAccountDetailParam.builder().billMonth(billMonth).paymentOrganization(paymentOrganization.toString()).employeeIds(part).build()));
});
} else {
employeeList = getSalaryEmployeeService(user).listByIds(ids);
}
Map<Long, InsuranceAccountDetailPO> historyDetailDataMap = SalaryEntityUtil.convert2Map(historyDetailData, InsuranceAccountDetailPO::getEmployeeId);
Map<Long, DataCollectionEmployee> employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId);
@ -5104,7 +5102,9 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
insuranceAccountDetailPO.setResourceFrom(ResourceFromEnum.SYSTEM.getValue());
insuranceAccountDetailPO.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
insuranceAccountDetailPO.setPaymentOrganization(paymentOrganization);
if (isFirstFlag) {
InsuranceAccountDetailPO historyDetail = historyDetailDataMap.get(k);
if (isFirstFlag || historyDetail == null) {
// 初次核算
DataCollectionEmployee employee = employeeMap.get(k);
if (employee != null) {
@ -5119,8 +5119,6 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
insuranceAccountDetailPO.setStatus(employee.getStatus());
}
} else {
InsuranceAccountDetailPO historyDetail = historyDetailDataMap.get(k);
if (historyDetail != null) {
insuranceAccountDetailPO.setSubcompanyName(historyDetail.getSubcompanyName());
insuranceAccountDetailPO.setSubcompanyId(historyDetail.getSubcompanyId());
insuranceAccountDetailPO.setDepartmentName(historyDetail.getDepartmentName());
@ -5131,7 +5129,6 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
insuranceAccountDetailPO.setJobcallId(historyDetail.getJobcallId());
insuranceAccountDetailPO.setStatus(historyDetail.getStatus());
}
}
//核算社保
accountSocial(insuranceAccountDetailPO, v, billMonth);
@ -5160,10 +5157,12 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
}
//临时表入库前先对可能存在的历史数据进行删除
List<List<Long>> partition = Lists.partition((List<Long>) ids, 100);
partition.forEach(part -> {
getSIAccountDetailTempMapper().batchDelByEmpIdsAndMonthAndPayOrg(part, billMonth, paymentOrganization);
});
// List<List<Long>> partition = Lists.partition((List<Long>) ids, 100);
// partition.forEach(part -> {
// getSIAccountDetailTempMapper().batchDelByEmpIdsAndMonthAndPayOrg(part, billMonth, paymentOrganization);
// });
// 根据人员id删会少删不再参与社保核算的人
getSIAccountDetailTempMapper().batchDelByMonthAndPayOrg(billMonth, paymentOrganization);
//临时表数据入库
if (CollectionUtils.isNotEmpty(list)) {
encryptUtil.encryptList(list, InsuranceAccountDetailTempPO.class);
@ -5747,16 +5746,23 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
log.info("核算明细临时表 hrsa_bill_detail_temp待处理数量{}", list.size());
List<List<Long>> partitionIds = Lists.partition((List<Long>) ids, 100);
log.info("bill_detail入库前删除数据数量{}", ids.size());
for (List<Long> part : partitionIds) {
getInsuranceAccountDetailMapper().batchDelAccountDetails(part, billMonth, param.getPaymentOrganization(), paymentStatus);
getInsuranceAccountDetailMapper().batchDelAccountDetails(Collections.emptyList(), billMonth, param.getPaymentOrganization(), paymentStatus);
//删除账单月份+个税扣缴义务人+人员id下的调差数据
getInsuranceCompensationMapper().deleteByBillMonthPayOrgEmpIds(InsuranceCompensationPO.builder()
.billMonth(billMonth)
.paymentOrganization(param.getPaymentOrganization())
.employeeIds(part)
.build());
}
// for (List<Long> part : partitionIds) {
// getInsuranceAccountDetailMapper().batchDelAccountDetails(part, billMonth, param.getPaymentOrganization(), paymentStatus);
//
// //删除账单月份+个税扣缴义务人+人员id下的调差数据
// getInsuranceCompensationMapper().deleteByBillMonthPayOrgEmpIds(InsuranceCompensationPO.builder()
// .billMonth(billMonth)
// .paymentOrganization(param.getPaymentOrganization())
// .employeeIds(part)
// .build());
// }
//生成bill_detail入库数据
List<InsuranceAccountDetailPO> collect = list.stream().map(item -> {