diff --git a/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java b/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java index e5ae380b8..a2faf3ebe 100644 --- a/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java @@ -790,6 +790,15 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction @Override public String extendToLastMonth(OtherDeductionExtendLastParam param) { + //查询已经核算的数据 + List salaryAcctEmployees = + getAddUpDeductionService(user) + .getAccountedEmployeeData(param.getDeclareMonth()); + Map acctInfoMap = salaryAcctEmployees.stream().collect(Collectors.toMap( + i -> i.getTaxAgentId() + "" + i.getEmployeeId(), + SalaryAcctEmployeePO::getId + )); + // 查找到所有个税扣缴义务人 Boolean needAuth = getTaxAgentService(user).isNeedAuth((long) user.getUID()); Collection taxAgentPOS; @@ -815,7 +824,7 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction )); Map updateIdMap = getOtherDeductionMapper() .list(queryParam).stream() - .collect(Collectors.toMap(i -> i.getEmployeeId()+"" + i.getTaxAgentId(), OtherDeductionListDTO::getId)); + .collect(Collectors.toMap(i -> i.getEmployeeId() + "" + i.getTaxAgentId(), OtherDeductionListDTO::getId)); List insertInfo = new ArrayList<>(); List updatetInfo = new ArrayList<>(); @@ -827,20 +836,21 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction po.setId(null); po.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY); boolean hasOld = updateIdMap.containsKey(po.getEmployeeId() + "" + po.getTaxAgentId()); - if (hasOld) { + if (hasOld && acctInfoMap.containsKey(po.getTaxAgentId() + "" + po.getEmployeeId())) { + //核算过的数据直接跳过不做更改 po.setId(updateIdMap.get(po.getEmployeeId() + "" + po.getTaxAgentId())); updatetInfo.add(po); - } else { + } else if (!hasOld){ po.setCreator((long) user.getUID()); po.setCreateTime(new Date()); insertInfo.add(po); } } List> list = Lists.partition(insertInfo, 1000); - list.forEach(l->getOtherDeductionMapper().insertData(l)); + list.forEach(l -> getOtherDeductionMapper().insertData(l)); List> updateList = Lists.partition(updatetInfo, 1000); - list.forEach(l->getOtherDeductionMapper().updateData(l)); + list.forEach(l -> getOtherDeductionMapper().updateData(l)); return ""; } diff --git a/src/com/engine/salary/wrapper/OtherDeductionWrapper.java b/src/com/engine/salary/wrapper/OtherDeductionWrapper.java index 0c4cf132e..1589ac74b 100644 --- a/src/com/engine/salary/wrapper/OtherDeductionWrapper.java +++ b/src/com/engine/salary/wrapper/OtherDeductionWrapper.java @@ -25,6 +25,7 @@ import weaver.hrm.User; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.Month; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.HashMap; @@ -257,9 +258,12 @@ public class OtherDeductionWrapper extends Service { } catch (Exception e) { log.error("", e); } - if (null == param.getDeclareMonth() || null == param.getYearMonthTime()) { + if (null == param.getDeclareMonth() || null == localDate || null == param.getYearMonthTime()) { throw new SalaryRunTimeException("当前年月不合法"); } + if (Month.JANUARY.equals(localDate.getMonth())) { + throw new SalaryRunTimeException("失败,当前年度内第一个月无法沿用上月"); + } param.setYearMonthTime(localDate); return getOtherDeductionService(user).extendToLastMonth(param); }