工资单、数据采集权限功能

This commit is contained in:
钱涛 2024-09-12 11:50:18 +08:00
parent 87d601c65b
commit 383562c9cf
14 changed files with 68 additions and 133 deletions

View File

@ -1,15 +1,15 @@
package com.engine.salary.entity.salaryBill.dto;
import com.engine.salary.annotation.SalaryTable;
import com.engine.salary.annotation.SalaryTableColumn;
import com.engine.salary.annotation.SalaryTableOperate;
import com.engine.salary.annotation.TableTitle;
import com.engine.hrmelog.annotation.ElogTransform;
import com.engine.salary.annotation.*;
import com.engine.salary.enums.auth.AuthCheckTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Set;
/**
* @Description: 工资单模板
*/
@ -24,6 +24,7 @@ import lombok.NoArgsConstructor;
@SalaryTableOperate(index = "3", text = "操作日志" )
})
@ElogTransform(name = "工资单模板")
@Auth(page = "salaryBill", checkType = AuthCheckTypeEnum.SOB)
public class SalaryTemplateListDTO {
//主键id
@ -65,4 +66,7 @@ public class SalaryTemplateListDTO {
// 薪资账套id
private Long salarySobId;
private Set<String> opts;
}

View File

@ -5,6 +5,8 @@ import com.engine.salary.enums.auth.AuthFilterTypeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = true)
@ -20,6 +22,8 @@ public class SalarySobQueryParam extends BaseQueryParam {
*/
private Long taxAgentId;
private List<Long> taxAgentIds;
/**
* 数据过滤级别
*/

View File

@ -1,6 +1,8 @@
package com.engine.salary.entity.taxagent.po;
import com.engine.hrmelog.annotation.ElogTransform;
import com.engine.salary.annotation.Auth;
import com.engine.salary.enums.auth.AuthCheckTypeEnum;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import com.thoughtworks.xstream.annotations.XStreamOmitField;
@ -11,6 +13,7 @@ import lombok.NoArgsConstructor;
import java.util.Collection;
import java.util.Date;
import java.util.Set;
/**
* 个税扣缴义务人 hrsa_tax_agent
@ -26,6 +29,7 @@ import java.util.Date;
@AllArgsConstructor
@ElogTransform(name = "个税扣缴义务人")
@XStreamAlias("TaxAgent")
@Auth(page = "", checkType = AuthCheckTypeEnum.TAX,taxAgentIdField = "id")
public class TaxAgentPO {
/**
@ -107,4 +111,6 @@ public class TaxAgentPO {
private Collection<Long> ids;
Set<String> opts;
}

View File

@ -37,13 +37,14 @@
<select id="getTaxOptAuth" resultMap="getTaxOptAuthMap">
select resource.target as tax_agent_id, o.opt
from hrsa_auth_role_emp emp
left join hrsa_auth_role role on emp.role_id = role.id and emp.delete_type = 0 and role.delete_type = 0
left join hrsa_auth_resource resource
on resource.role_id = role.id and resource.target_type = 1 and resource.delete_type = 0
left join hrsa_auth_opt o on role.id = o.role_id and o.delete_type = 0
from hrsa_auth_role role
left join hrsa_auth_role_emp emp on emp.role_id = role.id and emp.delete_type = 0 and role.delete_type = 0
left join hrsa_auth_resource resource on resource.role_id = role.id and resource.target_type = 1 and resource.delete_type = 0
left join hrsa_auth_opt o on role.id = o.role_id and o.delete_type = 0
where emp.employee_id = #{uid}
and o.page = #{page}
<if test="page != null and page != ''">
AND o.page = #{page}
</if>
</select>
@ -58,13 +59,14 @@
<select id="getSobOptAuth" resultMap="getSobOptAuthMap">
select resource.target as sob_id, o.opt
from hrsa_auth_role_emp emp
left join hrsa_auth_role role on emp.role_id = role.id and emp.delete_type = 0 and role.delete_type = 0
left join hrsa_auth_resource resource
on resource.role_id = role.id and resource.target_type = 2 and resource.delete_type = 0
left join hrsa_auth_opt o on role.id = o.role_id and o.delete_type = 0
from hrsa_auth_role role
left join hrsa_auth_role_emp emp on emp.role_id = role.id and emp.delete_type = 0 and role.delete_type = 0
left join hrsa_auth_resource resource on resource.role_id = role.id and resource.target_type = 2 and resource.delete_type = 0
left join hrsa_auth_opt o on role.id = o.role_id and o.delete_type = 0
where emp.employee_id = #{uid}
and o.page = #{page}
<if test="page != null and page != ''">
AND o.page = #{page}
</if>
</select>

View File

@ -369,6 +369,7 @@
t.name,
t.replenish_name as replenishName,
s.name as salarysob,
s.id as salarySobId,
t.use_type as useType,
t.description,
t.salary_sob_id
@ -402,6 +403,7 @@
t.name,
t.replenish_name as replenishName,
s.name as salarysob,
s.id as salarySobId,
t.use_type as useType,
t.description,
t.salary_sob_id
@ -435,6 +437,7 @@
t.name,
t.replenish_name as replenishName,
s.name as salarysob,
s.id as salarySobId,
t.use_type as useType,
t.description,
t.salary_sob_id

View File

@ -83,18 +83,21 @@ public class AuthRoleServiceImpl extends Service implements AuthRoleService {
@Override
public AuthRoleDTO getRole(Long id) {
AuthRolePO po = getAuthRoleMapper().getById(id);
if (po == null){
throw new SalaryRunTimeException("业务线不存在");
}
Long roleId = po.getId();
List<AuthResourcePO> authResources = getAuthResourceMapper().listSome(AuthResourcePO.builder().roleId(roleId).build());
List<TaxAgentPO> taxAgentIds = new ArrayList<>();
List<SalarySobPO> sobIds = new ArrayList<>();
authResources.forEach(resource -> {
if (ResourceTargetTypeEnum.TAX_AGENT.getValue().equals(resource.getTargetType())) {
taxAgentIds.add(TaxAgentPO.builder().id(resource.getTarget()).name(resource.getTargetName()).build());
} else if (ResourceTargetTypeEnum.SOB.getValue().equals(resource.getTargetType())) {
sobIds.add(SalarySobPO.builder().id(resource.getTarget()).name(resource.getTargetName()).build());
}
});
// authResources.forEach(resource -> {
// if (ResourceTargetTypeEnum.TAX_AGENT.getValue().equals(resource.getTargetType())) {
// taxAgentIds.add(TaxAgentPO.builder().id(resource.getTarget()).name(resource.getTargetName()).build());
// } else if (ResourceTargetTypeEnum.SOB.getValue().equals(resource.getTargetType())) {
// sobIds.add(SalarySobPO.builder().id(resource.getTarget()).name(resource.getTargetName()).build());
// }
// });
return AuthRoleDTO.builder()
.id(roleId)

View File

@ -67,7 +67,6 @@ public class AuthServiceImpl extends Service implements AuthService {
//给总管理员赋值最大权限
Boolean isChief = getTaxAgentService(user).isChief((long) user.getUID());
// Boolean isChief = false;
if (isChief) {
if (filterType == AuthFilterTypeEnum.DATA_OPT) {
list.forEach(t -> {
@ -97,7 +96,6 @@ public class AuthServiceImpl extends Service implements AuthService {
//给各管理员赋值对应的扣缴义务人权限
List<Long> adminTaxAgentIds = getTaxAgentService(user).getAdminTaxAgentIds((long) user.getUID());
// List<Long> adminTaxAgentIds = new ArrayList<>();
if (CollectionUtil.isNotEmpty(adminTaxAgentIds)) {
Iterator<T> iterator = list.iterator();
if (checkType == AuthCheckTypeEnum.TAX || checkType == AuthCheckTypeEnum.TAX_EMP) {

View File

@ -709,10 +709,6 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
@Override
public AddUpDeductionRecordDTO getAddUpDeduction(AddUpDeductionQueryParam param) {
long uid = user.getUID();
// 获取所有个税扣缴义务人
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(uid);
List<String> taxAgentNames = taxAgentList.stream().map(TaxAgentManageRangeEmployeeDTO::getTaxAgentName).collect(Collectors.toList());
ArrayList<Long> ids = new ArrayList<>();
ids.add(param.getId());
AddUpDeductionQueryParam build = AddUpDeductionQueryParam.builder().ids(ids).build();
@ -720,10 +716,6 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
if (addUpDeductionRecordDTOS == null || addUpDeductionRecordDTOS.size() == 0) {
throw new SalaryRunTimeException("该数据不存在!");
}
String taxAgentName = addUpDeductionRecordDTOS.get(0).getTaxAgentName();
if (!taxAgentNames.contains(taxAgentName)) {
throw new SalaryRunTimeException("您无权查看该数据!");
}
return addUpDeductionRecordDTOS.get(0);
}

View File

@ -1181,10 +1181,6 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
@Override
public AddUpSituationRecordDTO getAddUpSituation(AddUpSituationParam addUpSituationParam) {
long uid = user.getUID();
// 获取所有个税扣缴义务人
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(uid);
List<String> taxAgentNames = taxAgentList.stream().map(TaxAgentManageRangeEmployeeDTO::getTaxAgentName).collect(Collectors.toList());
ArrayList<Long> ids = new ArrayList<>();
ids.add(addUpSituationParam.getId());
AddUpSituationQueryParam build = AddUpSituationQueryParam.builder().ids(ids).build();
@ -1192,10 +1188,6 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
if (list == null || list.size() == 0) {
throw new SalaryRunTimeException("该数据不存在!");
}
String taxAgentName = list.get(0).getTaxAgentName();
if (!taxAgentNames.contains(taxAgentName)) {
throw new SalaryRunTimeException("您无权查看该数据!");
}
return list.get(0);
}

View File

@ -890,10 +890,6 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction
@Override
public OtherDeductionRecordDTO getOtherDeduction(OtherDeductionParam otherDeductionParam) {
long uid = user.getUID();
// 获取所有个税扣缴义务人
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(uid);
List<String> taxAgentNames = taxAgentList.stream().map(TaxAgentManageRangeEmployeeDTO::getTaxAgentName).collect(Collectors.toList());
ArrayList<Long> ids = new ArrayList<>();
ids.add(otherDeductionParam.getId());
OtherDeductionQueryParam build = OtherDeductionQueryParam.builder().ids(ids).build();
@ -903,10 +899,6 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction
if (list == null || list.size() == 0) {
throw new SalaryRunTimeException("该数据不存在!");
}
String taxAgentName = list.get(0).getTaxAgentName();
if (!taxAgentNames.contains(taxAgentName)) {
throw new SalaryRunTimeException("您无权查看该数据!");
}
return list.get(0);
}

View File

@ -227,6 +227,11 @@ public class SalarySobServiceImpl extends Service implements SalarySobService {
build.setIds(sobTaxLinkPOS.stream().map(SobTaxLinkPO::getTaxAgentId).collect(Collectors.toList()));
}
if(CollectionUtil.isNotEmpty(param.getTaxAgentIds())){
List<SobTaxLinkPO> sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().taxAgentIds(param.getTaxAgentIds()).build());
build.setIds(sobTaxLinkPOS.stream().map(SobTaxLinkPO::getTaxAgentId).collect(Collectors.toList()));
}
List<SalarySobPO> list = getSalarySobMapper().listSome(build);
return getAuthService(user).auth(list, param.getFilterType(), SalarySobPO.class);
}

View File

@ -27,11 +27,14 @@ import com.engine.salary.entity.salarysob.po.SalarySobEmpFieldPO;
import com.engine.salary.entity.salarysob.po.SalarySobItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobPO;
import com.engine.salary.enums.OperateTypeEnum;
import com.engine.salary.enums.auth.AuthFilterTypeEnum;
import com.engine.salary.enums.salarybill.SalaryTemplateWhetherEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.salarysob.SalarySobEmpFieldMapper;
import com.engine.salary.report.entity.po.SalaryStatisticsReportPO;
import com.engine.salary.service.*;
import com.engine.salary.service.auth.AuthService;
import com.engine.salary.service.auth.AuthServiceImpl;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.IdGenerator;
@ -86,6 +89,10 @@ public class SalaryTemplateServiceImpl extends Service implements SalaryTemplate
return MapperProxyFactory.getProxy(SalarySobEmpFieldMapper.class);
}
public AuthService getAuthService(User user) {
return ServiceUtil.getService(AuthServiceImpl.class, user);
}
@Override
public SalaryTemplatePO getById(Long id) {
return mapper.getById(id);
@ -492,30 +499,10 @@ public class SalaryTemplateServiceImpl extends Service implements SalaryTemplate
@Override
public PageInfo<SalaryTemplateListDTO> listPage(SalaryTemplateQueryParam queryParam) {
List<SalaryTemplateListDTO> salaryTemplateDTOList = Collections.emptyList();
// 分权
long currentEmployeeId = user.getUID();
Boolean needAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId);
if (needAuth) {
List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByDisable(NumberUtils.INTEGER_ZERO);
Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId);
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(salarySobIds)) {
// 查询
salaryTemplateDTOList = mapper.listDTO(SalaryTemplatePO.builder()
.salarySobId(queryParam.getSalarySobId())
.name(queryParam.getName())
.salarySobIds(salarySobIds).build());
} else {
return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), salaryTemplateDTOList, SalaryTemplateListDTO.class);
}
} else {
// 查询
salaryTemplateDTOList = mapper.listDTO(SalaryTemplatePO.builder().salarySobId(queryParam.getSalarySobId()).name(queryParam.getName()).build());
}
List<SalaryTemplateListDTO> salaryTemplateDTOList = mapper.listDTO(SalaryTemplatePO.builder().salarySobId(queryParam.getSalarySobId()).name(queryParam.getName()).build());
salaryTemplateDTOList = getAuthService(user).auth(salaryTemplateDTOList, AuthFilterTypeEnum.DATA_OPT, SalaryTemplateListDTO.class);
// 分页参数
PageInfo<SalaryTemplateListDTO> page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), salaryTemplateDTOList, SalaryTemplateListDTO.class);
return page;
return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), salaryTemplateDTOList, SalaryTemplateListDTO.class);
}
@Override

View File

@ -45,6 +45,8 @@ import com.engine.salary.mapper.siaccount.InsuranceAccountBatchMapper;
import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper;
import com.engine.salary.mapper.taxagent.TaxAgentMapper;
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.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
@ -147,6 +149,10 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService {
return MapperProxyFactory.getProxy(InsuranceAccountBatchMapper.class);
}
public AuthService getAuthService(User user) {
return ServiceUtil.getService(AuthServiceImpl.class, user);
}
// private PaymentAgencyMapper paymentAgencyMapper;
@ -284,7 +290,7 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService {
public List<TaxAgentPO> listAuth(TaxAgentQueryParam queryParam) {
List<TaxAgentPO> taxAgents = getTaxAgentMapper().listBySome(queryParam);
AuthFilterTypeEnum filterType = queryParam.getFilterType();
return handleForDevolution(taxAgents, (long) user.getUID(), filterType == AuthFilterTypeEnum.QUERY_DATA);
return getAuthService(user).auth(taxAgents, filterType, TaxAgentPO.class);
}
@Override

View File

@ -86,67 +86,8 @@ public class SalaryTemplateWrapper extends Service {
public PageInfo<SalaryTemplateListDTO> list(SalaryTemplateQueryParam queryParam) {
PageInfo<SalaryTemplateListDTO> listPage = getSalaryTemplateService(user).listPage(queryParam);
return listPage;
// SalaryWeaTable<SalaryTemplateListDTO> table = new SalaryWeaTable<SalaryTemplateListDTO>(user, SalaryTemplateListDTO.class);
//
// String fields = " t.id" +
// " , t.name" +
// " , t.replenish_name as replenishName" +
// " , s.name as salarySob" +
// " , t.use_type as useType" +
// " , t.description";
//
// String from = " from hrsa_salary_template t left join hrsa_salary_sob s on t.salary_sob_id = s.id ";
//
// table.setBackfields(fields);
// table.setSqlform(from);
// table.setSqlwhere(makeSqlWhere(queryParam));
// table.setSqlorderby("t.id DESC");
// table.setSqlprimarykey("t.id");
// table.setSqlisdistinct("false");
//
// WeaResultMsg result = new WeaResultMsg(false);
// result.putAll(table.makeDataResult());
// result.success();
// return result.getResultMap();
}
// private String makeSqlWhere(SalaryTemplateQueryParam queryParam) {
// DBType dbType = DBType.get(new RecordSet().getDBType());
//
// String sqlWhere = " t.delete_type = 0 ";
//
// String name = queryParam.getName();
// if (StringUtils.isNotBlank(name)) {
// sqlWhere += " AND t.name " + dbType.like(name);
// }
//
// Collection<Long> ids = queryParam.getIds();
//
// if (ids != null && ids.size() > 0) {
// sqlWhere += " AND t.id in (" + ids.stream().map(Object::toString).collect(Collectors.joining(",")) + ") ";
// }
//
// Long salarySobId = queryParam.getSalarySobId();
//
// if (salarySobId != null) {
// sqlWhere += " AND t.salary_sob_id = " + salarySobId;
// }
//
// long currentEmployeeId = user.getUID();
// Boolean needAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId);
// if (needAuth) {
// List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByDisable(NumberUtils.INTEGER_ZERO);
// Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId);
// if (CollectionUtils.isNotEmpty(salarySobIds)) {
// sqlWhere += " AND t.salary_sob_id in (" + salarySobIds.stream().map(Object::toString).collect(Collectors.joining(",")) + ") ";
// } else {
// sqlWhere += " AND 1=2 ";
// }
// }
//
//
// return sqlWhere;
// }
}
/**
* 获取工资单模板基础设置表单