薪酬系统-福利档案,艾志二开-福利档案导入模板下载、导出、导入功能改造,页面权限增加部门查看权限

This commit is contained in:
sy 2023-09-26 11:27:34 +08:00
parent d8550d3040
commit b9ef568c05
5 changed files with 157 additions and 10 deletions

View File

@ -1182,7 +1182,7 @@ public class SIArchivesBiz {
// taxAgentIds.contains(f.getPaymentOrganization())
// ).collect(Collectors.toList());
//艾志二开增加当前登录人拥有的的部门查看权限包含的人员档案列表,todo
//艾志二开增加当前登录人拥有的的部门查看权限包含的人员档案列表
List<InsuranceArchivesEmployeePO> needAuthPage = page.stream().filter(f ->
taxAgentIds.contains(f.getPaymentOrganization())
).collect(Collectors.toList());

View File

@ -687,7 +687,7 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService
list = new ArrayList<>();
}
//艾志二开增加当前登录人拥有的的部门查看权限包含的人员档案列表,todo
//艾志二开增加当前登录人拥有的的部门查看权限包含的人员档案列表
List<InsuranceArchivesBaseInfoPO> needAuthList = archiveListDTOS.stream().filter(f ->
taxAgentIds.contains(f.getPaymentOrganization())
).collect(Collectors.toList());

View File

@ -14,6 +14,7 @@ import com.engine.salary.entity.siarchives.po.InsuranceArchivesOtherSchemePO;
import com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO;
import com.engine.salary.entity.sicategory.po.ICategoryPO;
import com.engine.salary.entity.sischeme.po.InsuranceSchemePO;
import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.enums.siaccount.EmployeeStatusEnum;
import com.engine.salary.enums.sicategory.WelfareTypeEnum;
@ -23,6 +24,9 @@ import com.engine.salary.mapper.sischeme.InsuranceSchemeMapper;
import com.engine.salary.mapper.taxagent.TaxAgentMapper;
import com.engine.salary.service.SIArchivesService;
import com.engine.salary.service.SIImportService;
import com.engine.salary.service.SalaryEmployeeService;
import com.engine.salary.service.TaxAgentService;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.excel.ExcelComment;
@ -36,6 +40,7 @@ import org.apache.ibatis.session.SqlSession;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.conn.mybatis.MyBatisFactory;
import weaver.hrm.User;
import weaver.hrm.company.DepartmentComInfo;
import java.util.*;
import java.util.function.Function;
@ -68,6 +73,18 @@ public class SIImportServiceImpl extends Service implements SIImportService {
return MapperProxyFactory.getProxy(InsuranceSchemeMapper.class);
}
private TaxAgentService getTaxAgentService() {
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
private SocialSchemeMapper getSocialSchemeMapper() {
return MapperProxyFactory.getProxy(SocialSchemeMapper.class);
}
private SalaryEmployeeService getSalaryEmployeeService(User user) {
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
@Override
public XSSFWorkbook exportTemplate(InsuranceArchivesListParam param) {
//工作簿list
@ -133,11 +150,51 @@ public class SIImportServiceImpl extends Service implements SIImportService {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
SocialSchemeMapper socialSchemeMapper = sqlSession.getMapper(SocialSchemeMapper.class);
List<InsuranceArchivesEmployeePO> page = new ArrayList<>();
if (param.isExtWelArchiveList()) {
page = socialSchemeMapper.queryExtEmployeeList(param);
Long currentEmployeeId = Long.valueOf(user.getUID());
Boolean needAuth = getTaxAgentService().isNeedAuth(currentEmployeeId);
if (needAuth) {
List<TaxAgentEmployeeDTO> taxAgentEmployeeDTOS = getTaxAgentService().listTaxAgentAndEmployee(currentEmployeeId);
Set<Long> taxAgentIds = SalaryEntityUtil.properties(taxAgentEmployeeDTOS, TaxAgentEmployeeDTO::getTaxAgentId);
if (param.isExtWelArchiveList()) {
page = socialSchemeMapper.queryExtEmployeeList(param);
} else {
page = socialSchemeMapper.queryEmployeeList(param);
}
//艾志二开增加当前登录人拥有的的部门查看权限包含的人员档案列表
List<InsuranceArchivesEmployeePO> needAuthPage = page.stream().filter(f -> taxAgentIds.contains(f.getPaymentOrganization())).collect(Collectors.toList());
//查询登录人拥有查看权限的部门
List<Long> depList = getSalaryEmployeeService(user).listDepIdByEmpId(currentEmployeeId);
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<InsuranceArchivesEmployeePO> depAuthPage = page.stream().filter(f ->
depWithChildList.contains(f.getDepartmentId().toString())
).collect(Collectors.toList());
if (depAuthPage.size() > 0) {
needAuthPage.addAll(depAuthPage);
needAuthPage = needAuthPage.stream().distinct().collect(Collectors.toList());
}
}
page = needAuthPage;
} else {
page = socialSchemeMapper.queryEmployeeList(param);
if (param.isExtWelArchiveList()) {
page = socialSchemeMapper.queryExtEmployeeList(param);
} else {
page = socialSchemeMapper.queryEmployeeList(param);
}
}
PageInfo<InsuranceArchivesEmployeePO> pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(),
page, InsuranceArchivesEmployeePO.class);
int total = (int)pageInfo.getTotal();

View File

@ -67,6 +67,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.BeanUtils;
import weaver.file.ImageFileManager;
import weaver.hrm.User;
import weaver.hrm.company.DepartmentComInfo;
import java.io.InputStream;
import java.util.*;
@ -257,7 +258,32 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
// Set<Long> employeeIds = SalaryEntityUtil.properties(taxAgentEmployeeDTOS, TaxAgentEmployeeDTO::getEmployeeId);
Set<Long> taxAgentIds = SalaryEntityUtil.properties(taxAgentEmployeeDTOS, TaxAgentEmployeeDTO::getTaxAgentId);
List<InsuranceArchivesEmployeePO> list = getSocialSchemeMapper().queryEmployeeList(param);
return list.stream().filter(f -> taxAgentIds.contains(f.getPaymentOrganization())).collect(Collectors.toList());
// return list.stream().filter(f -> taxAgentIds.contains(f.getPaymentOrganization())).collect(Collectors.toList());
//艾志二开增加当前登录人拥有的的部门查看权限包含的人员档案列表
List<InsuranceArchivesEmployeePO> needAuthPage = list.stream().filter(f -> taxAgentIds.contains(f.getPaymentOrganization())).collect(Collectors.toList());
//查询登录人拥有查看权限的部门
List<Long> depList = getSalaryEmployeeService(user).listDepIdByEmpId(currentEmployeeId);
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<InsuranceArchivesEmployeePO> depAuthPage = list.stream().filter(f ->
depWithChildList.contains(f.getDepartmentId().toString())
).collect(Collectors.toList());
if (depAuthPage.size() > 0) {
needAuthPage.addAll(depAuthPage);
needAuthPage = needAuthPage.stream().distinct().collect(Collectors.toList());
}
}
return needAuthPage;
}
return getSocialSchemeMapper().queryEmployeeList(param);
@ -895,14 +921,20 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100579, "个税扣缴义务人不允许为空"));
excelComments.add(errorMessageMap);
isError = true;
} else if (!paymentNameIdMap.containsKey(paymentOrg)) {
} else if (!paymentNameIdMap.containsKey(paymentOrg) && !azDepAuth(user.getUID(), employeeId)) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(100312, "社保缴纳组织应和个税扣缴义务人名称一致,社保缴纳组织不存在或不在权限范围内"));
excelComments.add(errorMessageMap);
isError = true;
} else if (getTaxAgentMapper().listByName(paymentOrg).size() == 0) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowIndex + SalaryI18nUtil.getI18nLabel(0, "个税扣缴义务人不存在"));
excelComments.add(errorMessageMap);
isError = true;
}
if (!isError) {
//艾志二开-判断当前登录人员是否拥有对应员工档案的查看权限
if (!isError && !azDepAuth(user.getUID(), employeeId)) {
Long paymentOrgId = paymentNameIdMap.get(paymentOrg);
TaxAgentManageRangeEmployeeDTO taxAgentManageRangeEmployeeDTO = taxAgentManageRangeEmployeeTree.stream().filter(tax -> tax.getTaxAgentId().equals(paymentOrgId)).findFirst().get();
Optional<Long> o = taxAgentManageRangeEmployeeDTO.getEmployeeList().stream().map(TaxAgentManageRangeEmployeeDTO.TaxAgentEmployee::getEmployeeId).filter(e -> e.equals(employeeId)).findFirst();
@ -1112,6 +1144,33 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
return isError;
}
//艾志二开-判断当前登录人员是否拥有对应员工档案的查看权限
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;
}
}
public Map<String, Object> findElement(List<Map<String, Object>> singleAccount, String target) {
for (Map<String, Object> e : singleAccount) {
@ -1129,6 +1188,11 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
return null;
}
Long paymentOrg = paymentNameIdMap.get((String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")).get(SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")));
//艾志二开增加登录人员的部门人员档案查看权限此处为导入个税扣缴义务人权限外的人员时的逻辑处理
if (paymentOrg == null && azDepAuth(user.getUID(), employeeId)) {
List<TaxAgentPO> taxAgentPOS = getTaxAgentMapper().listByName((String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")).get(SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")));
paymentOrg = Long.valueOf( taxAgentPOS.get(0).getId() );
}
List<InsuranceArchivesSocialSchemePO> oldSocialSchemeInfos = getSocialSchemeMapper().getSocialByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO
.builder()
.employeeId(employeeId)
@ -1209,6 +1273,11 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
return null;
}
Long paymentOrg = paymentNameIdMap.get((String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")).get(SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")));
//艾志二开增加登录人员的部门人员档案查看权限此处为导入个税扣缴义务人权限外的人员时的逻辑处理
if (paymentOrg == null && azDepAuth(user.getUID(), employeeId)) {
List<TaxAgentPO> taxAgentPOS = getTaxAgentMapper().listByName((String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")).get(SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")));
paymentOrg = Long.valueOf( taxAgentPOS.get(0).getId() );
}
List<InsuranceArchivesFundSchemePO> oldFundSchemeInfos = getFundSchemeMapper().getFundByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO
.builder()
.employeeId(employeeId)
@ -1292,7 +1361,13 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
if (employeeId == null) {
return null;
}Long paymentOrg = paymentNameIdMap.get((String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")).get(SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")));
}
Long paymentOrg = paymentNameIdMap.get((String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")).get(SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")));
//艾志二开增加登录人员的部门人员档案查看权限此处为导入个税扣缴义务人权限外的人员时的逻辑处理
if (paymentOrg == null && azDepAuth(user.getUID(), employeeId)) {
List<TaxAgentPO> taxAgentPOS = getTaxAgentMapper().listByName((String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")).get(SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")));
paymentOrg = Long.valueOf( taxAgentPOS.get(0).getId() );
}
List<InsuranceArchivesOtherSchemePO> oldOtherSchemeInfos = getOtherSchemeMapper().getOtherByEmployeeIdAndPayOrg(InsuranceArchivesEmployeePO
.builder()
.employeeId(employeeId)
@ -1366,6 +1441,13 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
if (employeeId == null) {
return null;
}
Long paymentOrg = paymentNameIdMap.get((String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")).get(SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")));
//艾志二开增加登录人员的部门人员档案查看权限此处为导入个税扣缴义务人权限外的人员时的逻辑处理
if (paymentOrg == null && azDepAuth(user.getUID(), employeeId)) {
List<TaxAgentPO> taxAgentPOS = getTaxAgentMapper().listByName((String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")).get(SalaryI18nUtil.getI18nLabel(91325, "个税扣缴义务人")));
paymentOrg = Long.valueOf( taxAgentPOS.get(0).getId() );
}
InsuranceArchivesBaseInfoPO insuranceArchivesBaseInfoPO = new InsuranceArchivesBaseInfoPO();
insuranceArchivesBaseInfoPO.setEmployeeId(employeeId);
insuranceArchivesBaseInfoPO.setId(IdGenerator.generate());
@ -1375,7 +1457,7 @@ public class SISchemeServiceImpl extends Service implements SISchemeService {
insuranceArchivesBaseInfoPO.setRunStatus(runStatus);
insuranceArchivesBaseInfoPO.setUpdateTime(new Date());
insuranceArchivesBaseInfoPO.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
insuranceArchivesBaseInfoPO.setPaymentOrganization(paymentNameIdMap.get((String) findElement(singleAccount, SalaryI18nUtil.getI18nLabel(91497, "个税扣缴义务人")).get(SalaryI18nUtil.getI18nLabel(91497, "个税扣缴义务人"))));
insuranceArchivesBaseInfoPO.setPaymentOrganization(paymentOrg);
if (isExtEmp) {
insuranceArchivesBaseInfoPO.setEmployeeType(1);
}

View File

@ -97,10 +97,18 @@ public class TaxAgentWrapper extends Service {
Boolean isDefaultOpen = getTaxAgentService(user).isDefaultOpen(currentEmployeeId);
Boolean isAdminEnable = getTaxAgentService(user).isAdminEnable(currentEmployeeId);
Boolean isOpenDevolution = getTaxAgentService(user).isOpenDevolution();
//艾志二开登录人拥有部分部门查看权限则临时赋予管理员权限仅在薪资福利档案菜单中校验前端控制
Boolean isDepAuth = false;
//查询登录人拥有查看权限的部门
List<Long> depList = getSalaryEmployeeService(user).listDepIdByEmpId(currentEmployeeId);
if (depList.size() > 0) {
isDepAuth = true;
}
resultMap.put("isChief", isChief);
resultMap.put("isDefaultOpen", isDefaultOpen);
resultMap.put("isAdminEnable", isAdminEnable);
resultMap.put("isOpenDevolution", isOpenDevolution);
resultMap.put("isDepAuth", isDepAuth);
return resultMap;
}