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; + } + } }