diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.java b/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.java index 2ee45f10d..fe0caa3f3 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.java +++ b/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.java @@ -16,5 +16,7 @@ public interface InsuranceCompensationMapper { List queryByBillMonthAndPayOrg(String billMonth, Long paymentOrganization); + InsuranceCompensationPO getOneByBillMonthPayOrgEmpId(InsuranceCompensationPO insuranceCompensationPO); + void deleteById(Long id); } diff --git a/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.xml b/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.xml index 2a62fcc5e..8cdd6992f 100644 --- a/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.xml +++ b/src/com/engine/salary/mapper/siaccount/InsuranceCompensationMapper.xml @@ -210,6 +210,17 @@ AND t.delete_type = 0 + + + UPDATE hrsa_compensation_log SET delete_type = 1 diff --git a/src/com/engine/salary/service/impl/SICompensationServiceImpl.java b/src/com/engine/salary/service/impl/SICompensationServiceImpl.java index 4f8e34e60..ac2d22b84 100644 --- a/src/com/engine/salary/service/impl/SICompensationServiceImpl.java +++ b/src/com/engine/salary/service/impl/SICompensationServiceImpl.java @@ -163,23 +163,37 @@ public class SICompensationServiceImpl extends Service implements SICompensation InsuranceAccountDetailPO insuranceAccountDetailPO = getInsuranceAccountDetailMapper().getById(compensation.getTarget()); if (insuranceAccountDetailPO == null) { temp.put("error", SalaryI18nUtil.getI18nLabel(121038, "当前月在该缴纳组织下没有核算记录")); - } - InsuranceAccountDetailPOEncrypt.decryptItem(insuranceAccountDetailPO); - BigDecimal total = new BigDecimal("0"); - List categoryTypeList = Arrays.asList(compensation.getCategoryType().split(",")); + temp.put("totalNum", "0"); + } else { + InsuranceAccountDetailPOEncrypt.decryptItem(insuranceAccountDetailPO); + //判断是否已有调差数据(个税扣缴义务人+账单月份+人员id) + InsuranceCompensationPO nowCompensation = getInsuranceCompensationMapper().getOneByBillMonthPayOrgEmpId(InsuranceCompensationPO.builder() + .billMonth(insuranceAccountDetailPO.getBillMonth()) + .paymentOrganization(insuranceAccountDetailPO.getPaymentOrganization()) + .employeeId(insuranceAccountDetailPO.getEmployeeId()) + .build()); + if (nowCompensation != null) { + temp.put("error", SalaryI18nUtil.getI18nLabel(121039, "当前月在该缴纳组织下已存在调差数据")); + } - if (StringUtils.isNotBlank(insuranceAccountDetailPO.getSocialComJson())) { - Map socialJson = JSON.parseObject(insuranceAccountDetailPO.getSocialComJson(), new HashMap().getClass()); - for (Map.Entry entry : socialJson.entrySet()) { - String insuranceId = entry.getKey(); - String num = entry.getValue(); - if (categoryTypeList.contains(insuranceId)) { - total = total.add(new BigDecimal(num)); + //处理调差数据 + BigDecimal total = new BigDecimal("0"); + List categoryTypeList = Arrays.asList(compensation.getCategoryType().split(",")); + + if (nowCompensation == null && StringUtils.isNotBlank(insuranceAccountDetailPO.getSocialComJson())) { + Map socialJson = JSON.parseObject(insuranceAccountDetailPO.getSocialComJson(), new HashMap().getClass()); + for (Map.Entry entry : socialJson.entrySet()) { + String insuranceId = entry.getKey(); + String num = entry.getValue(); + if (categoryTypeList.contains(insuranceId)) { + total = total.add(new BigDecimal(num)); + } } } + + temp.put("totalNum", total.toPlainString()); } - temp.put("totalNum", total.toPlainString()); } resultList.add(temp); }); @@ -263,6 +277,7 @@ public class SICompensationServiceImpl extends Service implements SICompensation totalSum = totalSum.add(adjustmentTo); insuranceAccountDetailPO.setTotal(totalSum.toPlainString()); //更新社保调差后的明细 + InsuranceAccountDetailPOEncrypt.encryptItem(insuranceAccountDetailPO); getInsuranceAccountDetailMapper().updateById(insuranceAccountDetailPO); //新建调差记录 InsuranceCompensationPO insuranceCompensationPO = new InsuranceCompensationPO();