diff --git a/src/com/engine/salary/entity/datacollection/param/AddUpSituationDeleteParam.java b/src/com/engine/salary/entity/datacollection/param/AddUpSituationDeleteParam.java index ba8a81f7d..7bd5820c9 100644 --- a/src/com/engine/salary/entity/datacollection/param/AddUpSituationDeleteParam.java +++ b/src/com/engine/salary/entity/datacollection/param/AddUpSituationDeleteParam.java @@ -23,4 +23,7 @@ public class AddUpSituationDeleteParam { // 申报月份 private String taxYearMonth; + // 个税扣缴义务人 + private String taxAgentId; + } diff --git a/src/com/engine/salary/service/AddUpSituationService.java b/src/com/engine/salary/service/AddUpSituationService.java index eddaeece6..2406e16be 100644 --- a/src/com/engine/salary/service/AddUpSituationService.java +++ b/src/com/engine/salary/service/AddUpSituationService.java @@ -103,7 +103,7 @@ public interface AddUpSituationService { * @author Harryxzy * @date 2022/10/27 22:35 */ - void deleteAllAddUpSituation(AddUpDeductionRecordDeleteParam deleteParam); + void deleteAllAddUpSituation(AddUpSituationDeleteParam addUpSituationDeleteParam); /** * @description 获取往期累计情况 diff --git a/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java b/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java index 270a5b4b1..71f56c3f9 100644 --- a/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java +++ b/src/com/engine/salary/service/impl/AddUpSituationServiceImpl.java @@ -1006,57 +1006,57 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation @Override public void deleteSelectAddUpSituation(AddUpSituationDeleteParam deleteParam) { -// long currentEmployeeId = user.getUID(); -// // 获取所有个税扣缴义务人 -// Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); -// AddUpSituationBiz biz = new AddUpSituationBiz(); -// String declareMonthStr = deleteParam.getDeclareMonth(); -// List deleteIds = deleteParam.getIds(); -// // 已经核算过的不可操作 -// // 获取已经核算的数据 -// List salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeData(declareMonthStr); -// // 判断是否有核算过 -// List deleteList = new ArrayList<>(); -// for(int i=0; i first = taxAgentList.stream().filter(m -> m.getTaxAgentId() == byId.getTaxAgentId()).findFirst(); -// if(!first.isPresent()){ -// throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); -// } -// // 判断用户是否存在 -// if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { -// Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(byId.getEmployeeId()) && f.getTaxAgentId().equals(byId.getTaxAgentId())).findFirst(); -// if (optionalAcctEmp.isPresent()) { -// throw new SalaryRunTimeException("所选数据在该年月中已经核算过并归档,不可进行删除!"); -// } -// } -// deleteList.add(byId.getId()); -// } -// biz.batchDeleteByIDS(deleteList); + long currentEmployeeId = user.getUID(); + // 获取所有个税扣缴义务人 + Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); + AddUpSituationBiz biz = new AddUpSituationBiz(); + String declareMonthStr = deleteParam.getTaxYearMonth(); + List deleteIds = deleteParam.getIds(); + // 已经核算过的不可操作 + // 获取已经核算的数据 + List salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeData(declareMonthStr); + // 判断是否有核算过 + List deleteList = new ArrayList<>(); + for(int i=0; i first = taxAgentList.stream().filter(m -> m.getTaxAgentId() == byId.getTaxAgentId()).findFirst(); + if(!first.isPresent()){ + throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内"); + } + // 判断用户是否存在 + if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { + Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(byId.getEmployeeId()) && f.getTaxAgentId().equals(byId.getTaxAgentId())).findFirst(); + if (optionalAcctEmp.isPresent()) { + throw new SalaryRunTimeException("所选数据在该年月中已经核算过并归档,不可进行删除!"); + } + } + deleteList.add(byId.getId()); + } + biz.batchDeleteByIDS(deleteList); } @Override - public void deleteAllAddUpSituation(AddUpDeductionRecordDeleteParam deleteParam) { - String declareMonthStr = deleteParam.getDeclareMonth(); + public void deleteAllAddUpSituation(AddUpSituationDeleteParam deleteParam) { + String declareMonthStr = deleteParam.getTaxYearMonth(); long currentEmployeeId = user.getUID(); - LocalDate beginLocalDate = LocalDate.of(SalaryEntityUtil.string2Integer(declareMonthStr), 1, 1); - LocalDate endLocalDate = LocalDate.of(SalaryEntityUtil.string2Integer(declareMonthStr), 12, 1); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 获取所有个税扣缴义务人 Collection taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId); List taxAgentIds = taxAgentList.stream().map(TaxAgentManageRangeEmployeeDTO::getTaxAgentId).collect(Collectors.toList()); AddUpSituationBiz biz = new AddUpSituationBiz(); - Date beginDate = SalaryDateUtil.localDateToDate(beginLocalDate); - Date endDate = SalaryDateUtil.localDateToDate(endLocalDate); - ArrayList dateRange = new ArrayList<>(); - dateRange.add(beginDate); - dateRange.add(endDate); - + Date declareMonthDate = new Date(); + try { + declareMonthDate = (sdf.parse(declareMonthStr+"-01")); + }catch (Exception e){ + throw new SalaryRunTimeException("日期异常"); + } AddUpSituation queryParam = null; + if(deleteParam.getTaxAgentId() != null && (!deleteParam.getTaxAgentId().equals(""))){ // 设置了个税扣缴义务人 Long taxAgentId = SalaryEntityUtil.string2Long(deleteParam.getTaxAgentId()); @@ -1066,30 +1066,18 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation } ArrayList tai = new ArrayList<>(); tai.add(taxAgentId); - queryParam = AddUpSituation.builder().taxYearMonthRange(dateRange).taxAgentIds(tai).build(); + queryParam = AddUpSituation.builder().taxYearMonth(declareMonthDate).taxAgentIds(tai).build(); }else { - queryParam = AddUpSituation.builder().taxYearMonthRange(dateRange).taxAgentIds(taxAgentIds).build(); + queryParam = AddUpSituation.builder().taxYearMonth(declareMonthDate).taxAgentIds(taxAgentIds).build(); } // 获取所有想要删除的数据 List list = biz.listSome(queryParam); // 获取已经核算的数据 - List salaryAcctEmployees = new ArrayList<>(); - for(int i=1;i<=12;i++){ - String monthStr=""; - if(i<10){ - monthStr = declareMonthStr + "-0"+i; - }else { - monthStr = declareMonthStr + "-"+i; - } - - List employees = getAddUpDeductionService(user).getAccountedEmployeeData(monthStr); - salaryAcctEmployees.addAll(employees); - } - salaryAcctEmployees = salaryAcctEmployees.stream().distinct().collect(Collectors.toList()); + List employees = getAddUpDeductionService(user).getAccountedEmployeeData(declareMonthStr); for(AddUpSituation item : list){ - if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { - Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(item.getEmployeeId()) && f.getTaxAgentId().equals(item.getTaxAgentId())).findFirst(); + if (CollectionUtils.isNotEmpty(employees)) { + Optional optionalAcctEmp = employees.stream().filter(f -> f.getEmployeeId().equals(item.getEmployeeId()) && f.getTaxAgentId().equals(item.getTaxAgentId())).findFirst(); if (optionalAcctEmp.isPresent()) { throw new SalaryRunTimeException("有员工在该年月中已经完成核算并归档,不能进行一键清空!"); } diff --git a/src/com/engine/salary/web/AddUpSituationController.java b/src/com/engine/salary/web/AddUpSituationController.java index 4afca066f..7db7bafac 100644 --- a/src/com/engine/salary/web/AddUpSituationController.java +++ b/src/com/engine/salary/web/AddUpSituationController.java @@ -327,18 +327,18 @@ public class AddUpSituationController { } /** - * @description 一键清空 逻辑未确定 + * @description 一键清空 * @return String * @author Harryxzy * @date 2022/10/27 21:10 */ -// @POST -// @Path("/deleteAllAddUpSituation") -// @Produces(MediaType.APPLICATION_JSON) -// public String deleteAllAddUpSituation(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionRecordDeleteParam addUpSituationDeleteParam) { -// User user = HrmUserVarify.getUser(request, response); -// return new ResponseResult>(user).run(getAddUpSituationWrapper(user)::deleteAllAddUpSituation, addUpSituationDeleteParam); -// } + @POST + @Path("/deleteAllAddUpSituation") + @Produces(MediaType.APPLICATION_JSON) + public String deleteAllAddUpSituation(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpSituationDeleteParam addUpSituationDeleteParam) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult>(user).run(getAddUpSituationWrapper(user)::deleteAllAddUpSituation, addUpSituationDeleteParam); + } @POST @Path("/preview") diff --git a/src/com/engine/salary/wrapper/AddUpSituationWrapper.java b/src/com/engine/salary/wrapper/AddUpSituationWrapper.java index bee33ebc4..fbe8b90dc 100644 --- a/src/com/engine/salary/wrapper/AddUpSituationWrapper.java +++ b/src/com/engine/salary/wrapper/AddUpSituationWrapper.java @@ -163,8 +163,8 @@ public class AddUpSituationWrapper extends Service { * @author Harryxzy * @date 2022/10/27 22:34 */ - public void deleteAllAddUpSituation(AddUpDeductionRecordDeleteParam deleteParam) { - getAddUpSituationService(user).deleteAllAddUpSituation(deleteParam); + public void deleteAllAddUpSituation(AddUpSituationDeleteParam addUpSituationDeleteParam) { + getAddUpSituationService(user).deleteAllAddUpSituation(addUpSituationDeleteParam); } /**