From 71ea4b8609e37b831fad8dbdf4fb64216b18e5af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Fri, 27 May 2022 15:43:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/AddUpDeductionServiceImpl.java | 56 ++++++++++++------- .../salary/web/AddUpDeductionController.java | 4 +- .../salary/wrapper/AddUpDeductionWrapper.java | 4 +- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java index 24753d30b..6e446045e 100644 --- a/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/AddUpDeductionServiceImpl.java @@ -21,6 +21,7 @@ import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; import com.engine.salary.entity.taxagent.bo.TaxAgentBO; import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO; +import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO; import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.entity.taxrate.TaxAgent; import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; @@ -164,6 +165,8 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction @Override public Map importAddUpDeduction(AddUpDeductionImportParam importParam) { + long currentEmployeeId = user.getUID(); + Map apidatas = new HashMap(); EmployBiz employBiz = new EmployBiz(); AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz(); @@ -171,24 +174,23 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction //检验参数 checkImportParam(importParam); + //税款所属期 + String declareMonthStr = importParam.getDeclareMonth(); //excel文件id String imageId = Util.null2String(importParam.getImageId()); Validate.notBlank(imageId, "imageId为空"); - //税款所属期 - String declareMonthStr = Util.null2String(importParam.getDeclareMonth()); + // 获取所有个税扣缴义务人 + Collection taxAgentList = getTaxAgentV2Service(user).listTaxAgentAndEmployeeTree(currentEmployeeId); //个税扣缴义务人 String taxAgentId = Util.null2String(importParam.getTaxAgentId()); // 获取租户下所有的人员 - List employees = addUpDeductionMapper.listEmployee(tenantKey); + List employees = employBiz.listEmployee(); // 已经核算过的不可操作 // 获取已经核算的数据 - List salaryAcctEmployees = getAccountedEmployeeData(declareMonth, tenantKey); + List salaryAcctEmployees = getAccountedEmployeeData(declareMonthStr); // 查询已有数据 - List list = new LambdaQueryChainWrapper<>(addUpDeductionMapper) - .eq(AddUpDeductionPO::getDeleteType, 0) - .eq(AddUpDeductionPO::getTenantKey, tenantKey) - .eq(AddUpDeductionPO::getDeclareMonth, LocalDate.parse(declareMonth+"-01", SalaryDateUtil.DATE_FORMATTER)) - .list(); + Date declareMonth = SalaryDateUtil.localDateToDate(LocalDate.parse(declareMonthStr + "-01", SalaryDateUtil.DATE_FORMATTER)); + List list = getAddUpDeductionMapper().listSome(AddUpDeduction.builder().declareMonth(declareMonth).build()); InputStream fileInputStream = null; try { @@ -201,20 +203,14 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction int errorCount = 0; //人员信息 - List employees = employBiz.listEmployee(); List taxAgents = new TaxAgentBiz().listAll(); - //税款所属期 - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); - Date declareMonth = SalaryDateUtil.stringToDate(declareMonthStr + "-01"); - - // 错误excel内容 List errorData = new ArrayList<>(); //合规数据 List eligibleData = new ArrayList<>(); - + List taxAgentEmployees = Lists.newArrayList(); for (int i = 0; i < addUpDeductions.size(); i++) { AddUpDeductionDTO dto = addUpDeductions.get(i); @@ -276,16 +272,17 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction errorData.add(errorMessageMap); errorSum += 1; } else { - Optional optionalTemp = taxAgents.stream().filter(m -> m.getName().equals(taxAgentName)).findFirst(); + Optional optionalTemp = taxAgentList.stream().filter(m -> m.getTaxAgentName().equals(taxAgentName)).findFirst(); if (optionalTemp.isPresent()) { - if (StringUtils.isNotEmpty(taxAgentId) && !optionalTemp.get().getId().equals(Long.valueOf(taxAgentId))) { + if (StringUtils.isNotEmpty(taxAgentId) && !optionalTemp.get().getTaxAgentId().equals(Long.valueOf(taxAgentId))) { //个税扣缴义务人与导入时选择的不一致 Map errorMessageMap = Maps.newHashMap(); errorMessageMap.put("message", rowIndex + "个税扣缴义务人与导入时选择的不一致"); errorData.add(errorMessageMap); errorSum += 1; } else { - addUpDeduction.setTaxAgentId(optionalTemp.get().getId()); + addUpDeduction.setTaxAgentId(optionalTemp.get().getTaxAgentId()); + taxAgentEmployees = optionalTemp.get().getEmployeeList(); } } else { //个税扣缴义务人不存在 @@ -297,8 +294,25 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction } - - + // 分权判断 + Optional optionalTaxAgentEmp = taxAgentEmployees.stream().filter(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId())).findFirst(); + if (!optionalTaxAgentEmp.isPresent()) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "该条数据不在数据权限范围内,不可导入"); + errorData.add(errorMessageMap); + errorSum += 1; + } + // 判断是否有核算过 + if (CollectionUtils.isNotEmpty(salaryAcctEmployees)) { + Optional optionalAcctEmp = salaryAcctEmployees.stream().filter(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId()) && f.getTaxAgentId().equals(addUpDeduction.getTaxAgentId())).findFirst(); + boolean isExist = list.stream().anyMatch(f -> f.getEmployeeId().equals(addUpDeduction.getEmployeeId()) && f.getTaxAgentId().equals(addUpDeduction.getTaxAgentId())); + if (optionalAcctEmp.isPresent() && isExist) { + Map errorMessageMap = Maps.newHashMap(); + errorMessageMap.put("message", rowIndex + "该年月这条数据已经核算过,不可导入"); + errorData.add(errorMessageMap); + errorSum += 1; + } + } //累计子女教育 diff --git a/src/com/engine/salary/web/AddUpDeductionController.java b/src/com/engine/salary/web/AddUpDeductionController.java index 181bf7183..b7a69f627 100644 --- a/src/com/engine/salary/web/AddUpDeductionController.java +++ b/src/com/engine/salary/web/AddUpDeductionController.java @@ -254,9 +254,7 @@ public class AddUpDeductionController { @Produces(MediaType.APPLICATION_JSON) public String importAddUpDeduction(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AddUpDeductionImportParam importParam) { User user = HrmUserVarify.getUser(request, response); - Map map = ParamUtil.request2Map(request); - map.put("importParam", importParam); - return new ResponseResult, Map>(user).run(getAddUpDeductionWrapper(user)::importAddUpDeduction, map); + return new ResponseResult>(user).run(getAddUpDeductionWrapper(user)::importAddUpDeduction, importParam); } @POST diff --git a/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java b/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java index 20d17900d..a67f3257f 100644 --- a/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java +++ b/src/com/engine/salary/wrapper/AddUpDeductionWrapper.java @@ -140,8 +140,8 @@ public class AddUpDeductionWrapper extends Service { } - public Map importAddUpDeduction(Map params) { - return getAddUpDeductionService(user).importAddUpDeduction(params); + public Map importAddUpDeduction(AddUpDeductionImportParam importParam) { + return getAddUpDeductionService(user).importAddUpDeduction(importParam); }