个税扣缴义务人 增加角色

This commit is contained in:
dxfeng 2025-12-25 15:47:20 +08:00
parent 4f0e9597a4
commit a3a7d773a8
18 changed files with 161 additions and 8 deletions

View File

@ -0,0 +1,3 @@
alter table hrsa_tax_agent add role_id varchar2(200) null;
/

View File

@ -0,0 +1,3 @@
alter table hrsa_tax_agent add role_id varchar2(200) null;
/

View File

@ -0,0 +1,3 @@
alter table hrsa_tax_agent add role_id varchar2(200) null;
/

View File

@ -0,0 +1 @@
alter table hrsa_tax_agent add role_id varchar(200) null;

View File

@ -0,0 +1,2 @@
alter table hrsa_tax_agent add role_id varchar2(200) null
/

View File

@ -0,0 +1 @@
alter table hrsa_tax_agent add role_id varchar(200) null;

View File

@ -0,0 +1,2 @@
alter table hrsa_tax_agent add role_id varchar(200) null
GO

View File

@ -0,0 +1,3 @@
alter table hrsa_tax_agent add role_id varchar2(200) null;
/

View File

@ -1,5 +1,6 @@
package com.engine.salary.entity.taxagent.bo;
import com.engine.salary.biz.EmployBiz;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.agency.po.PaymentAgencyPO;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
@ -75,6 +76,7 @@ public class TaxAgentBO {
List<Column> columns = new ArrayList<>();
String name = SalaryI18nUtil.getI18nLabel(91558, "个税扣缴义务人名称");
String employeeRange = SalaryI18nUtil.getI18nLabel(86125, "人员范围");
String roles = SalaryI18nUtil.getI18nLabel(87626, "角色");
String admins = SalaryI18nUtil.getI18nLabel(106259, "管理员");
String subAdmins = SalaryI18nUtil.getI18nLabel(106283, "分管理员");
// String paymentAgency = SalaryI18nUtil.getI18nLabel(112448, "社保福利代缴机构");
@ -84,6 +86,7 @@ public class TaxAgentBO {
columns.add(new Column(name, "name", "name"));
columns.add(new Column(employeeRange, "employeeRange", "employeeRange"));
if (isOpenDevolution) {
columns.add(new Column(roles, "roles", "roles"));
columns.add(new Column(admins, "admins", "admins"));
}
columns.add(new Column(description, "description", "description"));
@ -150,12 +153,17 @@ public class TaxAgentBO {
map.put("id", e.getId());
map.put("name", e.getName());
map.put("employeeRange", "设置");
// map.put("role", rolelistMap.getOrDefault(e.getId(), Collections.emptyList()).stream().map(AuthRolePO::getName).collect(Collectors.joining(",")));
if (isDevolution) {
List<Long> empIds = taxAgentAdmins.stream().filter(t -> t.getTaxAgentId().equals(e.getId())).map(TaxAgentAdminPO::getEmployeeId).collect(Collectors.toList());
List<String> admins = adminList.stream().filter(a -> empIds.contains(a.getEmployeeId())).map(DataCollectionEmployee::getUsername).collect(Collectors.toList());
map.put("admins", CollectionUtils.isEmpty(admins) ? "" : Joiner.on(",").join((Iterable<?>) admins));
map.put("subAdmins", "设置");
String roleId = e.getRoleId();
if(StringUtils.isNotBlank(roleId)){
List<Long> roleIdList = Arrays.stream(roleId.split(",")).filter(StringUtils::isNotBlank).map(Long::parseLong).collect(Collectors.toList());
List<RoleInfo> roleInfos = new EmployBiz().listRoleInfo(roleIdList);
map.put("roles", roleInfos.stream().map(RoleInfo::getName).collect(Collectors.joining(",")));
}
}
map.put("paymentAgency", buildPaymentAgency(e.getPaymentAgency(), paymentAgencyPOS));
map.put("description", e.getDescription());
@ -204,6 +212,7 @@ public class TaxAgentBO {
.updateTime(now)
.creator(employeeId)
.deleteType(0)
.roleId(saveParam.getRoleId())
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.sortedIndex(saveParam.getSortedIndex())
.build();

View File

@ -29,6 +29,8 @@ public class TaxAgentFormDTO {
//管理员
private List<TaxAgentEmployeeOptionDTO> adminUserIds;
private List<TaxAgentEmployeeOptionDTO> roleId;
//排序
private Integer sortedIndex;

View File

@ -34,6 +34,9 @@ public class TaxAgentSaveParam {
//管理员主键id
private List<Long> adminUserIds;
//角色主键id
private String roleId;
//代缴机构
private String paymentAgency;

View File

@ -78,6 +78,13 @@ public class TaxAgentPO {
@XStreamAsAttribute
private String tenantKey;
/**
* 角色Id
*/
@XStreamAlias("roleId")
@XStreamAsAttribute
private String roleId;
/**
* 创建人id
*/

View File

@ -724,7 +724,7 @@
<select id="listRoleInfo" resultType="com.engine.salary.entity.hrm.RoleInfo">
select t.id,
t.rolesname as name
t.rolesmark as name
from hrmroles t
where 1=1
<if test="collection != null and collection.size()>0">

View File

@ -22,6 +22,7 @@
, t.id
, t.name
, t.tenant_key
, t.role_id
, t.update_time
, t.sorted_index
</sql>
@ -119,6 +120,9 @@
<if test="tenantKey != null">
tenant_key,
</if>
<if test="roleId != null">
role_id,
</if>
<if test="updateTime != null">
update_time,
</if>
@ -148,6 +152,9 @@
<if test="tenantKey != null">
#{tenantKey},
</if>
<if test="roleId != null">
#{roleId},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
@ -187,6 +194,9 @@
<if test="tenantKey != null">
tenant_key,
</if>
<if test="roleId != null">
role_id,
</if>
<if test="updateTime != null">
update_time,
</if>
@ -216,6 +226,9 @@
<if test="tenantKey != null">
#{tenantKey},
</if>
<if test="roleId != null">
#{roleId},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
@ -234,6 +247,7 @@
description=#{description},
name=#{name},
tenant_key=#{tenantKey},
role_id=#{roleId},
update_time=#{updateTime},
sorted_index=#{sortedIndex}
</set>

View File

@ -281,4 +281,11 @@ public interface TaxAgentService {
* @return
*/
List<TaxAgentPO> listByIdsIncludeDel(Collection<Long> taxAgentIds);
/**
* 同步管理员角色
* @param ids
* @return
*/
String syncAdminRoles(String ids);
}

View File

@ -352,8 +352,16 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService {
// 是否开启分权
boolean isOpenDevolution = getTaxAgentBaseService(user).isOpenDevolution();
if (isOpenDevolution && CollectionUtils.isEmpty(saveParam.getAdminUserIds())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(106271, "请选择管理员"));
if (isOpenDevolution) {
if (StringUtils.isBlank(saveParam.getRoleId())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(106271, "请选择管理角色"));
}
List<Long> adminUserIds = getAdminUserIdsByRole(saveParam.getRoleId());
saveParam.setAdminUserIds(adminUserIds);
// 根据角色获取对应的人员
if (CollectionUtils.isEmpty(saveParam.getAdminUserIds())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(106271, "请选择管理员"));
}
}
List<TaxAgentPO> taxAgents = getTaxAgentMapper().listByName(saveParam.getName());
if (CollectionUtils.isNotEmpty(taxAgents)) {
@ -403,8 +411,16 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService {
}
// 是否开启分权
boolean isOpenDevolution = getTaxAgentBaseService(user).isOpenDevolution();
if (isOpenDevolution && CollectionUtils.isEmpty(saveParam.getAdminUserIds())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(106271, "请选择管理员"));
if (isOpenDevolution) {
if (StringUtils.isBlank(saveParam.getRoleId())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(106271, "请选择管理角色"));
}
List<Long> adminUserIds = getAdminUserIdsByRole(saveParam.getRoleId());
saveParam.setAdminUserIds(adminUserIds);
// 根据角色获取对应的人员
if (CollectionUtils.isEmpty(saveParam.getAdminUserIds())) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(106271, "请选择管理员"));
}
}
List<TaxAgentPO> individualTaxWithholdingAgents = getTaxAgentMapper().listByName(saveParam.getName());
@ -858,5 +874,45 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService {
return getTaxAgentMapper().listByIdsIncludeDel(taxAgentIds);
}
@Override
public String syncAdminRoles(String ids) {
List<TaxAgentPO> taxAgentList;
if (StringUtils.isBlank(ids)) {
taxAgentList = listAll();
} else {
taxAgentList = listByIds(Arrays.stream(ids.split(",")).filter(StringUtils::isNotBlank).map(Long::valueOf).collect(Collectors.toList()));
}
taxAgentList.forEach(taxAgent -> {
// 新增管理员
List<Long> adminUserIds = getAdminUserIdsByRole(taxAgent.getRoleId());
if (CollectionUtils.isEmpty(adminUserIds)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(106271, "[" + taxAgent.getName() + "]根据角色未获取到管理员"));
}
// 删除人员
getTaxAgentAdminService(user).deleteByTaxAgentIds(Collections.singletonList(taxAgent.getId()));
getTaxAgentAdminService(user).batchInsert(taxAgent.getId(), adminUserIds);
});
return null;
}
/**
* 根据角色获取管理员
* @param roleIds
* @return
*/
private static List<Long> getAdminUserIdsByRole(String roleIds) {
if(StringUtils.isBlank(roleIds)){
return Collections.emptyList();
}
Set<Long> adminUserIds = new HashSet<>();
HrmCommonService hrmCommonService = new HrmCommonServiceImpl();
String[] roleSplit = roleIds.split(",");
// 遍历角色 获取所有的人员
for (String roleId : roleSplit) {
String hrmIds = hrmCommonService.getRoleMemberIds(roleId, "0");
adminUserIds.addAll(Arrays.stream(hrmIds.split(",")).filter(StringUtils::isNotBlank).map(Long::parseLong).collect(Collectors.toList()));
}
return new ArrayList<>(adminUserIds);
}
}

View File

@ -1,5 +1,7 @@
package com.engine.salary.web;
import cn.hutool.core.convert.Convert;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.taxagent.dto.TaxAgentFormDTO;
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeEmployeeDTO;
@ -410,6 +412,21 @@ public class TaxAgentController {
return new ResponseResult<Long, String>(user).run(getTaxAgentWrapper(user)::syncRange);
}
/**
* 同步管理员角色
* @param request
* @param response
* @return
*/
@POST
@Path("/syncAdminRoles")
@Produces(MediaType.APPLICATION_JSON)
public String syncAdminRoles(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> param = ParamUtil.request2Map(request);
return new ResponseResult<String, String>(user).run(getTaxAgentWrapper(user)::syncAdminRoles, Convert.toStr(param.get("id"),""));
}
/* ******* 个税扣缴义务人 end ***********************************************************************************************/
/* ******* 分管理员 start ***********************************************************************************************/

View File

@ -4,9 +4,11 @@ import cn.hutool.core.util.StrUtil;
import com.cloudstore.dev.api.util.Util_DataCache;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.biz.EmployBiz;
import com.engine.salary.cache.SalaryCacheKey;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.hrm.HrmStatus;
import com.engine.salary.entity.hrm.RoleInfo;
import com.engine.salary.entity.taxagent.bo.TaxAgentBO;
import com.engine.salary.entity.taxagent.dto.*;
import com.engine.salary.entity.taxagent.param.*;
@ -213,7 +215,18 @@ public class TaxAgentWrapper extends Service {
if (taxAgent == null) {
throw new SalaryRunTimeException(String.format(SalaryI18nUtil.getI18nLabel(100543, "个税扣缴人不存在") + "[id:%s]", id));
}
BeanUtils.copyProperties(taxAgent, taxAgentFromDTO);
BeanUtils.copyProperties(taxAgent, taxAgentFromDTO, new String[]{"roleId"});
String roleId = taxAgent.getRoleId();
if(StringUtils.isNotBlank(roleId)){
List<Long> roleIdList = Arrays.stream(roleId.split(",")).filter(StringUtils::isNotBlank).map(Long::parseLong).collect(Collectors.toList());
List<RoleInfo> roleInfos = new EmployBiz().listRoleInfo(roleIdList);
List<TaxAgentEmployeeOptionDTO> roleList = new ArrayList<>();
for (RoleInfo roleInfo : roleInfos) {
roleList.add(TaxAgentEmployeeOptionDTO.builder().id(roleInfo.getId()).content(roleInfo.getName()).build());
}
taxAgentFromDTO.setRoleId(roleList);
}
}
// 是否开启分权
boolean isOpenDevolution = getTaxAgentBaseService(user).isOpenDevolution();
@ -232,7 +245,6 @@ public class TaxAgentWrapper extends Service {
}
taxAgentFromDTO.setAdminUserIds(list);
return taxAgentFromDTO;
}
@ -510,5 +522,13 @@ public class TaxAgentWrapper extends Service {
return getTaxAgentManageRangeService(user).importData(taxAgentImportParam);
}
/**
* 同步管理员角色
* @param ids
* @return
*/
public String syncAdminRoles(String ids) {
return getTaxAgentService(user).syncAdminRoles(ids);
}
}