薪酬系统-福利档案,艾志二开-薪资档案全量发薪、全量停薪、取消停薪、删除档案、删除待办等功能改造,适配登录人可查阅部门相关人员档案逻辑

This commit is contained in:
sy 2023-09-27 15:03:24 +08:00
parent a753a0fb0a
commit 1409045b68
2 changed files with 112 additions and 14 deletions

View File

@ -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<Long> empListByDep = empIdsByAzDepAuth();
boolean isNotDepAuthEmp = nowList.stream().anyMatch(te -> !empListByDep.contains(te.getEmployeeId()));
if (isNotExist && isNotDepAuthEmp) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(116196, "个税扣缴义务人不存在或不在权限范围内,删除失败!"));
}

View File

@ -360,7 +360,10 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
List<Long> 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<Long> empListByDep = empIdsByAzDepAuth();
boolean depAuthEmpErr = salaryArchiveList.stream().anyMatch(te -> !empListByDep.contains(te.getEmployeeId()));
if(CollectionUtils.isEmpty(salaryArchiveList) || (err && depAuthEmpErr)){
throw new SalaryRunTimeException("薪资档案不存在,或没有权限删除该薪资档案!");
}
Optional<SalaryArchivePO> 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<TaxAgentEmployeeDTO> taxAgentEmployeeDTOS = getTaxAgentService(user).listTaxAgentAndEmployee(currentEmployeeId);
// Set<Long> employeeId = SalaryEntityUtil.properties(taxAgentEmployeeDTOS, TaxAgentEmployeeDTO::getEmployeeId);
//
// Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAllTaxAgentsAsAdmin(currentEmployeeId);
// Set<Long> taxAgentIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId);
//
// //获取所有薪资档案
// List<SalaryArchiveListDTO> list = getSalaryArchiveList(queryParam);
// List<SalaryArchiveListDTO> finalAllArchive = list.stream().filter(dto -> employeeId.contains(dto.getEmployeeId()) && taxAgentIds.contains(dto.getTaxAgentId())).collect(Collectors.toList());
//
//查询登录人拥有查看权限的部门
List<Long> depList = getSalaryEmployeeService(user).listDepIdByEmpId((long) user.getUID());
//不是管理员看不到数据返回空
if (!adminEnable) {
if (!adminEnable && depList.size() == 0) {
return new ArrayList<>();
}
//获取管理的人员范围
List<TaxAgentEmployeeDTO> taxAgentEmployeeDTOS = getTaxAgentService(user).listTaxAgentAndEmployee(currentEmployeeId);
Set<Long> employeeId = SalaryEntityUtil.properties(taxAgentEmployeeDTOS, TaxAgentEmployeeDTO::getEmployeeId);
Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAllTaxAgentsAsAdmin(currentEmployeeId);
Set<Long> taxAgentIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId);
//获取所有薪资档案
List<SalaryArchiveListDTO> list = getSalaryArchiveList(queryParam);
List<SalaryArchiveListDTO> finalAllArchive = list.stream().filter(dto -> employeeId.contains(dto.getEmployeeId()) && taxAgentIds.contains(dto.getTaxAgentId())).collect(Collectors.toList());
List<SalaryArchiveListDTO> finalAllArchive = new ArrayList<>();
if (adminEnable) {
//获取管理的人员范围
List<TaxAgentEmployeeDTO> taxAgentEmployeeDTOS = getTaxAgentService(user).listTaxAgentAndEmployee(currentEmployeeId);
Set<Long> employeeId = SalaryEntityUtil.properties(taxAgentEmployeeDTOS, TaxAgentEmployeeDTO::getEmployeeId);
Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAllTaxAgentsAsAdmin(currentEmployeeId);
Set<Long> 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<String> 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<SalaryArchiveListDTO> 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<TaxAgentEmployeeDTO> taxAgentManageRangeEmployees = getTaxAgentService(user).listTaxAgentAndEmployee((long) user.getUID());
List<SalaryArchivePO> 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<Long> 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<SalaryArchivePO> listByRunStatus(List<String> list) {
return getSalaryArchiveMapper().listSome(SalaryArchivePO.builder().runStatusList(list).build());
}
private List<Long> empIdsByAzDepAuth() {
//艾志二开登录人拥有查看部门权限下的人员
//查询登录人拥有查看权限的部门
List<Long> depList = getSalaryEmployeeService(user).listDepIdByEmpId((long) user.getUID());
List<Long> empListByDep = new ArrayList<>();
if (depList.size() > 0) {
List<Long> 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<Long> depList = getSalaryEmployeeService(user).listDepIdByEmpId((long) uid);
if (depList.size() > 0) {
List<Long> 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<Long> empListByDep = getSalaryEmployeeService(user).listEmpIdByDepId(depWithChildList);
if (empListByDep.size() > 0) {
return empListByDep.contains(employeeId);
} else {
return false;
}
} else {
return false;
}
}
}