业务线分权

This commit is contained in:
钱涛 2025-02-13 11:27:13 +08:00
parent c17a566443
commit c0dbce4786
11 changed files with 39 additions and 135 deletions

View File

@ -10,6 +10,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.Set;
@Data
@ -18,6 +19,7 @@ import java.util.Date;
@AllArgsConstructor
//数据采集-累计专项附加扣除记录
@SalaryTable(pageId = "a4f85287-3354-4275-adn9-7d06e54y6rj8", tableType = WeaTableType.CHECKBOX)
@Auth(page = "addUpDeduction")
public class AddUpDeductionRecordDTO {
//主键id
@ -124,4 +126,6 @@ public class AddUpDeductionRecordDTO {
@Encrypt
private String addUpInfantCare;
private Set<String> opts;
}

View File

@ -1,10 +1,7 @@
package com.engine.salary.entity.datacollection.dto;
import com.cloudstore.eccom.pc.table.WeaTableType;
import com.engine.salary.annotation.Encrypt;
import com.engine.salary.annotation.SalaryTable;
import com.engine.salary.annotation.SalaryTableColumn;
import com.engine.salary.annotation.TableTitle;
import com.engine.salary.annotation.*;
import com.engine.salary.util.excel.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
@ -28,6 +25,7 @@ import java.util.Date;
@NoArgsConstructor
@AllArgsConstructor
@SalaryTable(pageId = "a5f85287-3354-4275-adn9-7d06e54y6rj8",tableType = WeaTableType.CHECKBOX)
@Auth(page = "addUpSituation")
public class AddUpSituationRecordDTO {
@SalaryTableColumn(column = "id", display = false)

View File

@ -44,11 +44,10 @@ public interface AddUpDeductionService {
/**
* 下载模板
* @param isChief
* @param queryParam
* @return
*/
XSSFWorkbook downloadTemplate(boolean isChief,AddUpDeductionQueryParam queryParam);
XSSFWorkbook downloadTemplate(AddUpDeductionQueryParam queryParam);
/**

View File

@ -26,8 +26,6 @@ import com.engine.salary.entity.datacollection.po.SpecialAddDeductionPO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
import com.engine.salary.entity.salarysob.po.SalarySobPO;
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.param.TaxAgentQueryParam;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
@ -947,18 +945,8 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
@Override
public PageInfo<AddUpDeductionRecordDTO> recordListPage(AddUpDeductionQueryParam queryParam) {
long employeeId = (long) user.getUID();
Boolean needAuth = getTaxAgentService(user).isNeedAuth(employeeId);
if (needAuth) {
List<Long> taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(taxAgentIdsAsAdmin)) {
return new PageInfo<>(AddUpDeductionRecordDTO.class);
}
queryParam.setTaxAgentIds(taxAgentIdsAsAdmin);
}
List<AddUpDeductionRecordDTO> list = getAddUpDeductionMapper().recordList(queryParam);
list = getAuthService(user).auth(list, AuthFilterTypeEnum.DATA_OPT, AddUpDeductionRecordDTO.class);
PageInfo<AddUpDeductionRecordDTO> page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), list, AddUpDeductionRecordDTO.class);
encryptUtil.decryptList(page.getList(), AddUpDeductionRecordDTO.class);
return page;
@ -1060,7 +1048,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
}
@Override
public XSSFWorkbook downloadTemplate(boolean isChief, AddUpDeductionQueryParam queryParam) {
public XSSFWorkbook downloadTemplate(AddUpDeductionQueryParam queryParam) {
String sheetName = SalaryI18nUtil.getI18nLabel(101603, "累计专项附加扣除导入模板");
String[] header = {SalaryI18nUtil.getI18nLabel(85429, "姓名"), SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), SalaryI18nUtil.getI18nLabel(86185, "部门"), SalaryI18nUtil.getI18nLabel(86186, "手机号"), SalaryI18nUtil.getI18nLabel(86317, "工号"), SalaryI18nUtil.getI18nLabel(86318, "证件号码"), SalaryI18nUtil.getI18nLabel(86319, "入职日期"), SalaryI18nUtil.getI18nLabel(86321, "累计子女教育"), SalaryI18nUtil.getI18nLabel(86323, "累计继续教育"), SalaryI18nUtil.getI18nLabel(86324, "累计住房贷款利息"), SalaryI18nUtil.getI18nLabel(86325, "累计住房租金"), SalaryI18nUtil.getI18nLabel(86326, "累计赡养老人"), SalaryI18nUtil.getI18nLabel(105142, "累计大病医疗"), SalaryI18nUtil.getI18nLabel(105142, "累计婴幼儿照护")};

View File

@ -349,7 +349,6 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
* @return
*/
private List<List<Object>> getExcelRowDetailList(AddUpSituationQueryParam param) {
long employeeId = user.getUID();
//excel标题
List<Object> title = Arrays.asList("姓名", "税款所属期", "个税扣缴义务人", "部门", "手机号", "工号", "累计收入额", "累计减除费用", "累计社保个人合计",
"累计公积金个人合计", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人", "累计大病医疗", "累计企业(职业)年金及其他福利",
@ -358,15 +357,8 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM");
//查询详细信息
List<AddUpSituationRecordDTO> list = biz.recordList(param);
list = getAuthService(user).auth(list, AuthFilterTypeEnum.QUERY_DATA, AddUpSituationRecordDTO.class);
// 开启了分权
if (getTaxAgentService(user).isOpenDevolution() || !getTaxAgentService(user).isChief(employeeId)) {
List<Long> taxAgentIdsAsAdmin = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList());
list = list.stream().filter(f ->
// 作为管理员
taxAgentIdsAsAdmin.contains(f.getTaxAgentId())
).collect(Collectors.toList());
}
final List<List<Object>> dataRowList = Optional.ofNullable(list)
.map(List::stream)
.map(operatorStream -> operatorStream.map(dto -> {

View File

@ -1,6 +1,5 @@
package com.engine.salary.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.api.formmode.mybatis.util.SqlProxyHandle;
@ -20,6 +19,7 @@ import com.engine.salary.entity.salaryitem.config.SalaryItemExcelConfig;
import com.engine.salary.entity.salaryitem.param.*;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO;
import com.engine.salary.entity.salarysob.param.SalarySobQueryParam;
import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobPO;
@ -34,6 +34,8 @@ import com.engine.salary.enums.sicategory.SharedTypeEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.salaryitem.SalaryItemMapper;
import com.engine.salary.service.*;
import com.engine.salary.service.auth.AuthService;
import com.engine.salary.service.auth.AuthServiceImpl;
import com.engine.salary.sys.entity.vo.UploadConfigResponse;
import com.engine.salary.util.JsonUtil;
import com.engine.salary.util.SalaryEntityUtil;
@ -112,6 +114,10 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
return SqlProxyHandle.getProxy(SalaryItemMapper.class);
}
public AuthService getAuthService(User user) {
return ServiceUtil.getService(AuthServiceImpl.class, user);
}
@Override
public SalaryItemPO getById(Long id) {
return salaryItemBiz.getById(id);
@ -448,16 +454,10 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
@Override
public List<Map<String, Object>> getSalarySobBySalaryItem(Long salaryItemId) {
// 查询所有启用的薪资账套
List<SalarySobItemPO> salarySobItemList = getSalarySobItemService(user).listBySalaryItemIds(Collections.singleton(salaryItemId));
Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobItemList, SalarySobItemPO::getSalarySobId);
List<SalarySobPO> salarySobs = getSalarySobService(user).listByIds(salarySobIds);
// 获取能够管理的义务人
Boolean isChief = getTaxAgentService(user).isChief((long) user.getUID());
if (!isChief) {
Set<Long> taxAgentIds = SalaryEntityUtil.properties(getTaxAgentService(user).listAllTaxAgentsAsAdmin((long) user.getUID()), TaxAgentPO::getId);
salarySobs = salarySobs.stream().filter(sob -> CollectionUtil.intersection(taxAgentIds, sob.getTaxAgentIds()).size() > 0).collect(Collectors.toList());
}
// 查询所有管理的薪资账套
SalarySobQueryParam salarySobQueryParam = new SalarySobQueryParam();
salarySobQueryParam.setFilterType(AuthFilterTypeEnum.ADMIN_DATA);
List<SalarySobPO> salarySobs = getSalarySobService(user).listAuth(salarySobQueryParam);
return salarySobs.stream().map(m -> {
Map<String, Object> map = new HashMap<>();
map.put("id", String.valueOf(m.getId()));

View File

@ -2,30 +2,29 @@ package com.engine.salary.service.impl;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.hrmelog.entity.dto.LoggerContext;
import com.engine.salary.biz.SalarySobBiz;
import com.engine.salary.biz.SalarySobItemBiz;
import com.engine.salary.biz.SalarySobItemGroupBiz;
import com.engine.salary.biz.SalarySobItemHideBiz;
import com.engine.salary.config.SalaryElogConfig;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.hrmelog.entity.dto.LoggerContext;
import com.engine.salary.entity.salaryacct.bo.SalaryAcctConfig;
import com.engine.salary.entity.salaryarchive.config.ArchiveFieldConfig;
import com.engine.salary.entity.salaryformula.ExpressFormula;
import com.engine.salary.entity.salaryformula.config.FormluaConfig;
import com.engine.salary.entity.salaryformula.po.FormulaPO;
import com.engine.salary.entity.salaryformula.po.FormulaVar;
import com.engine.salary.entity.salaryitem.config.SalaryItemAllConfig;
import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salarysob.bo.SalarySobItemAggregateBO;
import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO;
import com.engine.salary.entity.salarysob.dto.SalarySobItemFormDTO;
import com.engine.salary.entity.salarysob.param.SalarySobItemSaveParam;
import com.engine.salary.entity.salarysob.po.*;
import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.enums.OperateTypeEnum;
import com.engine.salary.enums.SalaryValueTypeEnum;
import com.engine.salary.enums.auth.AuthFilterTypeEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.salarysob.SalarySobDefaultItemMapper;
import com.engine.salary.mapper.salarysob.SalarySobEmpFieldMapper;
@ -234,13 +233,10 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe
Set<Long> backCalcItemIds = SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getSalaryItemId);
salaryItemIds.addAll(backCalcItemIds);
Boolean needAuth = getTaxAgentService(user).isNeedAuth((long) user.getUID());
final Set<Long> ids = new HashSet<Long>();
if (needAuth) {
Set<Long> collect = getTaxAgentService(user).listAllTaxAgents((long) user.getUID()).stream().map(TaxAgentPO::getId).collect(Collectors.toSet());
ids.addAll(collect);
}
List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds).stream().filter(po -> Boolean.FALSE.equals(needAuth) || getSalaryItemService(user).filterInRange(ids, po)).collect(Collectors.toList());
TaxAgentQueryParam param = TaxAgentQueryParam.builder().build();
param.setFilterType(AuthFilterTypeEnum.QUERY_DATA);
Set<Long> ids = getTaxAgentService(user).listAuth(param).stream().map(TaxAgentPO::getId).collect(Collectors.toSet());
List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds).stream().filter(po -> getSalaryItemService(user).filterInRange(ids, po)).collect(Collectors.toList());
//获取系统值
List<SalarySobDefaultItemPO> salarySobDefaultItemPOS = getSalarySobDefaultItemMapper().listAll();

View File

@ -4,7 +4,6 @@ import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.encrypt.EncryptUtil;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO;
import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationBO;
import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationDetailBO;
import com.engine.salary.entity.taxdeclaration.dto.*;
@ -27,7 +26,6 @@ import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils;
import weaver.hrm.User;
import java.util.*;
@ -204,66 +202,13 @@ public class TaxDeclarationDetailServiceImpl extends Service implements TaxDecla
return TaxDeclarationDetailBO.convert2ListDTO4Annual(taxDeclarationDetailPOS, taxDeclarationEmployees, simpleEmployees);
}
/**
* 根据权限范围过滤
*
* @param taxDeclarationPO
* @param taxDeclarationEmployeeDTOS
* @return
*/
private List<TaxDeclarationEmployeeDTO> filterByAuthority(TaxDeclarationPO taxDeclarationPO, List<TaxDeclarationEmployeeDTO> taxDeclarationEmployeeDTOS) {
long employeeId = user.getUID();
if (CollectionUtils.isEmpty(taxDeclarationEmployeeDTOS)) {
return Collections.emptyList();
}
// 判断是否开启了分权
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
// 是否是总管理员
Boolean isChief = getTaxAgentService(user).isChief(employeeId);
if (BooleanUtils.isFalse(openDevolution) || isChief) {
return taxDeclarationEmployeeDTOS;
}
// 查询权限范围内的人员
List<TaxAgentEmployeeDTO> taxAgentEmployeeDTOS = getTaxAgentService(user).listTaxAgentAndEmployee(employeeId);
Set<String> simpleEmployeeKeySet = SalaryEntityUtil.properties(taxAgentEmployeeDTOS, taxAgentEmployeeDTO -> taxAgentEmployeeDTO.getEmployeeId() + "-" + taxAgentEmployeeDTO.getTaxAgentId());
// 查询权限范围内的外部人员
// List<ExtEmployeePO> extEmployeePOS = extEmployeeService.listCanUseByEmployeeId(employeeId, tenantKey);
// Set<String> extEmployeeKeySet = SalaryEntityUtil.properties(extEmployeePOS, extEmployeePO -> extEmployeePO.getId() + "-" + extEmployeePO.getTaxAgentId());
// 根据权限范围过滤
return taxDeclarationEmployeeDTOS.stream().filter(taxDeclarationEmployeeDTO -> {
if (taxDeclarationEmployeeDTO.getEmployeeType() == null || Objects.equals(taxDeclarationEmployeeDTO.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue())
&& simpleEmployeeKeySet.contains(taxDeclarationEmployeeDTO.getEmployeeId() + "-" + taxDeclarationPO.getTaxAgentId())) {
return true;
}
// if (Objects.equals(taxDeclarationEmployeeDTO.getEmployeeType(), EmployeeTypeEnum.EXT_EMPLOYEE.getValue())
// && extEmployeeKeySet.contains(taxDeclarationEmployeeDTO.getEmployeeId() + "-" + taxDeclarationPO.getTaxAgentId())) {
// return true;
// }
return false;
}).collect(Collectors.toList());
}
@Override
public PageInfo<TaxDeclarationWageListDTO> listDtoPageByParam4Wage(TaxDeclarationDetailListQueryParam queryParam) {
// 查询个税申报主表
TaxDeclarationPO taxDeclarationPO = getTaxDeclarationService(user).getById(queryParam.getTaxDeclarationId());
// 查询个税申报表明细的人员
PageInfo<TaxDeclarationEmployeeDTO> employeeIdPage = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize());
// 判断是否开启了分权
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
// 是否是总管理员
Boolean isChief = getTaxAgentService(user).isChief((long) user.getUID());
// if (BooleanUtils.isTrue(openDevolution) && !isChief) {
// List<TaxDeclarationEmployeeDTO> taxDeclarationEmployeeDTOS = getTaxDeclarationDetailMapper().list4EmployeeId(queryParam.getTaxDeclarationId());
// // 根据权限过滤
// taxDeclarationEmployeeDTOS = filterByAuthority(taxDeclarationPO, taxDeclarationEmployeeDTOS);
// employeeIdPage.setTotal(taxDeclarationEmployeeDTOS.size());
// employeeIdPage.setList(SalaryPageUtil.subList((int) employeeIdPage.getPageNum(), (int) employeeIdPage.getPageSize(), taxDeclarationEmployeeDTOS));
// } else {
employeeIdPage = listPage4EmployeeIdByParam(queryParam);
// }
PageInfo<TaxDeclarationEmployeeDTO> employeeIdPage = listPage4EmployeeIdByParam(queryParam);
PageInfo<TaxDeclarationWageListDTO> dtoPage = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), TaxDeclarationWageListDTO.class);
dtoPage.setTotal(employeeIdPage.getTotal());
if (CollectionUtils.isNotEmpty(employeeIdPage.getList())) {
@ -279,15 +224,6 @@ public class TaxDeclarationDetailServiceImpl extends Service implements TaxDecla
.map(TaxDeclarationEmployeeDTO::getEmployeeId)
.collect(Collectors.toList());
List<DataCollectionEmployee> simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIds(simpleEmployeeIds);
// 查询人员薪资身份证号码等
// List<SimpleUserInfo> simpleUserInfos = salaryEmployeeService.listByEmployeeIds(simpleEmployeeIds, tenantKey);
// 查询外部人员
// Set<Long> extEmployeeIds = employeeIdPage.getRecords().stream()
// .filter(taxDeclarationEmployeeDTO -> Objects.equals(taxDeclarationEmployeeDTO.getEmployeeType(), EmployeeTypeEnum.EXT_EMPLOYEE.getValue()))
// .map(TaxDeclarationEmployeeDTO::getEmployeeId)
// .collect(Collectors.toSet());
// List<ExtEmployeePO> extEmployees = extEmployeeService.listByIds(extEmployeeIds, tenantKey);
// 转换成列表dto
List<TaxDeclarationWageListDTO> taxDeclarationWageListDTOS = TaxDeclarationDetailBO.convert2ListDTO4Wage(taxDeclarationDetailPOS,
employeeIdPage.getList(), simpleEmployees);
dtoPage.setList(taxDeclarationWageListDTOS);

View File

@ -9,6 +9,7 @@ import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobPO;
import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationBO;
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam;
@ -366,19 +367,13 @@ public class TaxDeclarationServiceImpl extends Service implements TaxDeclaration
public boolean checkByAuthority(TaxDeclarationPO taxDeclarationPO, Long employeeId) {
// 判断是否开启了分权
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
// 判断是否是总管理员
Boolean isChief = getTaxAgentService(user).isChief(employeeId);
if (openDevolution && !isChief) {
// 查询负责管理的个税扣缴义务人
Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId);
if (CollectionUtils.isEmpty(taxAgentPOS)) {
return false;
}
Set<Long> taxAgentIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId);
return taxAgentIds.contains(taxDeclarationPO.getTaxAgentId());
}
// 查询个税申报表
return true;
// 获取所有个税扣缴义务人
TaxAgentQueryParam param = TaxAgentQueryParam.builder().build();
param.setFilterType(AuthFilterTypeEnum.ADMIN_DATA);
Collection<TaxAgentPO> taxAgentList = getTaxAgentService(user).listAuth(param);
Set<Long> taxAgentIds = SalaryEntityUtil.properties(taxAgentList, TaxAgentPO::getId);
return taxAgentIds.contains(taxDeclarationPO.getTaxAgentId());
}
@Override

View File

@ -126,9 +126,7 @@ public class AddUpDeductionWrapper extends Service {
* @return
*/
public XSSFWorkbook downloadTemplate(AddUpDeductionQueryParam queryParam) {
// 构建异步导出参数
boolean isChief = getTaxAgentService(user).isChief((long) user.getUID());
return getAddUpDeductionService(user).downloadTemplate(isChief, queryParam);
return getAddUpDeductionService(user).downloadTemplate(queryParam);
}

View File

@ -116,8 +116,6 @@ public class TaxAgentWrapper extends Service {
* @return
*/
public PageInfo<Map<String, Object>> list(TaxAgentQueryParam queryParam) {
// 是否是总管理员
Boolean isChief = getTaxAgentService(user).isChief((long) user.getUID());
// 是否开启分权
boolean isOpenDevolution = getTaxAgentBaseService(user).isOpenDevolution();