From 1409045b68be1f007914c4bb3c63dd257ff0ba5f Mon Sep 17 00:00:00 2001 From: sy Date: Wed, 27 Sep 2023 15:03:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-=E7=A6=8F?= =?UTF-8?q?=E5=88=A9=E6=A1=A3=E6=A1=88=EF=BC=8C=E8=89=BE=E5=BF=97=E4=BA=8C?= =?UTF-8?q?=E5=BC=80-=E8=96=AA=E8=B5=84=E6=A1=A3=E6=A1=88=E5=85=A8?= =?UTF-8?q?=E9=87=8F=E5=8F=91=E8=96=AA=E3=80=81=E5=85=A8=E9=87=8F=E5=81=9C?= =?UTF-8?q?=E8=96=AA=E3=80=81=E5=8F=96=E6=B6=88=E5=81=9C=E8=96=AA=E3=80=81?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=A1=A3=E6=A1=88=E3=80=81=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=BE=85=E5=8A=9E=E7=AD=89=E5=8A=9F=E8=83=BD=E6=94=B9=E9=80=A0?= =?UTF-8?q?=EF=BC=8C=E9=80=82=E9=85=8D=E7=99=BB=E5=BD=95=E4=BA=BA=E5=8F=AF?= =?UTF-8?q?=E6=9F=A5=E9=98=85=E9=83=A8=E9=97=A8=E7=9B=B8=E5=85=B3=E4=BA=BA?= =?UTF-8?q?=E5=91=98=E6=A1=A3=E6=A1=88=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SIArchivesServiceImpl.java | 6 +- .../impl/SalaryArchiveServiceImpl.java | 120 ++++++++++++++++-- 2 files changed, 112 insertions(+), 14 deletions(-) diff --git a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java index d7b5ba7df..90a998975 100644 --- a/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIArchivesServiceImpl.java @@ -1163,7 +1163,11 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService taxAgentManageRangeEmployees.stream().noneMatch(p -> p.getEmployeeId() != null && p.getEmployeeId().equals(te.getEmployeeId()) && p.getTaxAgentId().equals(te.getPaymentOrganization()))); - if (isNotExist) { + //艾志二开,登录人拥有查看部门权限下的人员 + List empListByDep = empIdsByAzDepAuth(); + boolean isNotDepAuthEmp = nowList.stream().anyMatch(te -> !empListByDep.contains(te.getEmployeeId())); + + if (isNotExist && isNotDepAuthEmp) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(116196, "个税扣缴义务人不存在或不在权限范围内,删除失败!")); } diff --git a/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java b/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java index 3dd830f7a..6c88e9fc8 100644 --- a/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryArchiveServiceImpl.java @@ -360,7 +360,10 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe List canDeleteTaxAgentIds = getTaxAgentService(user).listAllTaxAgentsAsAdmin((long) user.getUID()) .stream().map(TaxAgentPO::getId).collect(Collectors.toList()); boolean err = salaryArchiveList.stream().anyMatch(po -> !canDeleteTaxAgentIds.contains(po.getTaxAgentId())); - if(CollectionUtils.isEmpty(salaryArchiveList) || err){ + //艾志二开,登录人拥有查看部门权限下的人员 + List empListByDep = empIdsByAzDepAuth(); + boolean depAuthEmpErr = salaryArchiveList.stream().anyMatch(te -> !empListByDep.contains(te.getEmployeeId())); + if(CollectionUtils.isEmpty(salaryArchiveList) || (err && depAuthEmpErr)){ throw new SalaryRunTimeException("薪资档案不存在,或没有权限删除该薪资档案!"); } Optional fixedList = salaryArchiveList.stream().filter(archive -> !StringUtils.equals(archive.getRunStatus(), SalaryArchiveStatusEnum.PENDING.getValue()) @@ -389,22 +392,60 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe if (needAuth) { Boolean adminEnable = getTaxAgentService(user).isAdminEnable(currentEmployeeId); +// 不是管理员看不到数据,返回空 +// if (!adminEnable) { +// return new ArrayList<>(); +// } +// +// //获取管理的人员范围 +// List taxAgentEmployeeDTOS = getTaxAgentService(user).listTaxAgentAndEmployee(currentEmployeeId); +// Set employeeId = SalaryEntityUtil.properties(taxAgentEmployeeDTOS, TaxAgentEmployeeDTO::getEmployeeId); +// +// Collection taxAgentPOS = getTaxAgentService(user).listAllTaxAgentsAsAdmin(currentEmployeeId); +// Set taxAgentIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId); +// +// //获取所有薪资档案 +// List list = getSalaryArchiveList(queryParam); +// List finalAllArchive = list.stream().filter(dto -> employeeId.contains(dto.getEmployeeId()) && taxAgentIds.contains(dto.getTaxAgentId())).collect(Collectors.toList()); +// + //查询登录人拥有查看权限的部门 + List depList = getSalaryEmployeeService(user).listDepIdByEmpId((long) user.getUID()); //不是管理员看不到数据,返回空 - if (!adminEnable) { + if (!adminEnable && depList.size() == 0) { return new ArrayList<>(); } - - //获取管理的人员范围 - List taxAgentEmployeeDTOS = getTaxAgentService(user).listTaxAgentAndEmployee(currentEmployeeId); - Set employeeId = SalaryEntityUtil.properties(taxAgentEmployeeDTOS, TaxAgentEmployeeDTO::getEmployeeId); - - Collection taxAgentPOS = getTaxAgentService(user).listAllTaxAgentsAsAdmin(currentEmployeeId); - Set taxAgentIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId); - //获取所有薪资档案 List list = getSalaryArchiveList(queryParam); - List finalAllArchive = list.stream().filter(dto -> employeeId.contains(dto.getEmployeeId()) && taxAgentIds.contains(dto.getTaxAgentId())).collect(Collectors.toList()); + List finalAllArchive = new ArrayList<>(); + if (adminEnable) { + //获取管理的人员范围 + List taxAgentEmployeeDTOS = getTaxAgentService(user).listTaxAgentAndEmployee(currentEmployeeId); + Set employeeId = SalaryEntityUtil.properties(taxAgentEmployeeDTOS, TaxAgentEmployeeDTO::getEmployeeId); + Collection taxAgentPOS = getTaxAgentService(user).listAllTaxAgentsAsAdmin(currentEmployeeId); + Set taxAgentIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId); + finalAllArchive = list.stream().filter(dto -> employeeId.contains(dto.getEmployeeId()) && taxAgentIds.contains(dto.getTaxAgentId())).collect(Collectors.toList()); + } + //艾志二开,增加当前登录人拥有的的部门查看权限包含的人员档案列表 + if (depList.size() > 0) { + List depWithChildList = new ArrayList<>(); + for (Long depId : depList) { + try { + String depStr = DepartmentComInfo.getAllChildDepartId(depId.toString(), depId.toString()); + depWithChildList.addAll(Arrays.stream(depStr.split(",")).collect(Collectors.toList())); + } catch (Exception e) { + e.printStackTrace(); + } + } + + List depAuthPage = list.stream().filter(f -> + depWithChildList.contains(f.getDepartmentId().toString()) + ).collect(Collectors.toList()); + if (depAuthPage.size() > 0) { + finalAllArchive.addAll(depAuthPage); + finalAllArchive = finalAllArchive.stream().distinct().collect(Collectors.toList()); + } + } return finalAllArchive; } else { return getSalaryArchiveList(queryParam); @@ -1291,7 +1332,7 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe if (!canDelete) { throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内,删除失败!"); } - } else { + } else if (!azDepAuth(user.getUID(), dto.getEmployeeId())) { throw new SalaryRunTimeException("个税扣缴义务人不存在或不在权限范围内,删除失败!"); } } @@ -1323,7 +1364,12 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe List taxAgentManageRangeEmployees = getTaxAgentService(user).listTaxAgentAndEmployee((long) user.getUID()); List oldPendingList = oldList.stream().filter(f -> f.getRunStatus().equals(SalaryArchiveStatusEnum.STOP_FROM_PENDING.getValue())).collect(Collectors.toList()); boolean isNotExist = oldPendingList.stream().anyMatch(te -> taxAgentManageRangeEmployees.stream().noneMatch(p -> p.getEmployeeId() != null && p.getEmployeeId().equals(te.getEmployeeId()) && p.getTaxAgentId().equals(te.getTaxAgentId()))); - if (isNotExist) { + + //艾志二开,登录人拥有查看部门权限下的人员 + List empListByDep = empIdsByAzDepAuth(); + boolean isNotDepAuthEmp = oldPendingList.stream().anyMatch(te -> !empListByDep.contains(te.getEmployeeId())); + + if (isNotExist && isNotDepAuthEmp) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(116196, "不在当前个税扣缴义人的人员范围中,不可取消停薪")); } // 从停薪到待定薪 @@ -1396,4 +1442,52 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe public List listByRunStatus(List list) { return getSalaryArchiveMapper().listSome(SalaryArchivePO.builder().runStatusList(list).build()); } + + private List empIdsByAzDepAuth() { + //艾志二开,登录人拥有查看部门权限下的人员 + //查询登录人拥有查看权限的部门 + List depList = getSalaryEmployeeService(user).listDepIdByEmpId((long) user.getUID()); + List empListByDep = new ArrayList<>(); + if (depList.size() > 0) { + List depWithChildList = new ArrayList<>(); + for (Long depId : depList) { + try { + String depStr = DepartmentComInfo.getAllChildDepartId(depId.toString(), depId.toString()); + depWithChildList.addAll(Arrays.stream(depStr.split(",")).map(Long::parseLong).collect(Collectors.toList())); + } catch (Exception e) { + e.printStackTrace(); + } + } + //查询有权限部门包含的员工id + empListByDep = getSalaryEmployeeService(user).listEmpIdByDepId(depWithChildList); + } + return empListByDep; + } + + //艾志二开-判断当前登录人员是否拥有对应员工档案的查看权限 + private boolean azDepAuth(int uid, Long employeeId) { + + //查询登录人拥有查看权限的部门 + List depList = getSalaryEmployeeService(user).listDepIdByEmpId((long) uid); + if (depList.size() > 0) { + List depWithChildList = new ArrayList<>(); + for (Long depId : depList) { + try { + String depStr = DepartmentComInfo.getAllChildDepartId(depId.toString(), depId.toString()); + depWithChildList.addAll(Arrays.stream(depStr.split(",")).map(Long::parseLong).collect(Collectors.toList())); + } catch (Exception e) { + e.printStackTrace(); + } + } + //查询有权限部门包含的员工id + List empListByDep = getSalaryEmployeeService(user).listEmpIdByDepId(depWithChildList); + if (empListByDep.size() > 0) { + return empListByDep.contains(employeeId); + } else { + return false; + } + } else { + return false; + } + } }