显示扣缴义务人的角色

This commit is contained in:
钱涛 2024-08-01 18:04:09 +08:00
parent a0d2db2702
commit 4d51b6e57c
4 changed files with 47 additions and 30 deletions

View File

@ -2,6 +2,7 @@ package com.engine.salary.entity.taxagent.bo;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.agency.po.PaymentAgencyPO;
import com.engine.salary.entity.auth.po.AuthRolePO;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.hrm.DeptInfo;
import com.engine.salary.entity.hrm.HrmStatus;
@ -83,21 +84,15 @@ public class TaxAgentBO {
// String paymentAgency = SalaryI18nUtil.getI18nLabel(112448, "社保福利代缴机构");
String description = SalaryI18nUtil.getI18nLabel(84961, "备注");
String sortedIndex = SalaryI18nUtil.getI18nLabel(84962, "显示顺序");
columns.add(new Column(name, "name", "name"));
columns.add(new Column(employeeRange, "employeeRange", "employeeRange"));
if (isOpenDevolution) {
columns.add(new Column(name, "name", "name%"));
columns.add(new Column(employeeRange, "employeeRange", "employeeRange"));
columns.add(new Column(admins, "admins", "admins%"));
// columns.add(new Column(subAdmins, "subAdmins", "20%"));
// columns.add(new Column(paymentAgency, "paymentAgency", "30%"));
columns.add(new Column(description, "description", "name"));
columns.add(new Column(sortedIndex, "sortedIndex", "sortedIndex"));
} else {
columns.add(new Column(name, "name", "name"));
columns.add(new Column(employeeRange, "employeeRange", "employeeRange"));
// columns.add(new WeaTableColumn(paymentAgency, "paymentAgency", "30%"));
columns.add(new Column(description, "description", "description"));
columns.add(new Column(sortedIndex, "sortedIndex", "sortedIndex"));
columns.add(new Column(admins, "admins", "admins"));
}
columns.add(new Column("角色", "role", "role"));
columns.add(new Column(description, "description", "description"));
columns.add(new Column(sortedIndex, "sortedIndex", "sortedIndex"));
listPage.setColumns(columns);
}
@ -146,8 +141,8 @@ public class TaxAgentBO {
* @param taxAgents
* @return
*/
public static List<Map<String, Object>> convertToTableListDTO(List<TaxAgentPO> taxAgents, List<PaymentAgencyPO> paymentAgencyPOS, String setLabel) {
return convertToTableListDTO(Boolean.FALSE, taxAgents, paymentAgencyPOS, null, null, setLabel);
public static List<Map<String, Object>> convertToTableListDTO(List<TaxAgentPO> taxAgents, List<PaymentAgencyPO> paymentAgencyPOS, Map<Long, List<AuthRolePO>> rolelistMap) {
return convertToTableListDTO(Boolean.FALSE, taxAgents, paymentAgencyPOS, null, null, rolelistMap);
}
/**
@ -158,8 +153,8 @@ public class TaxAgentBO {
*/
public static List<Map<String, Object>> convertToTableListDTO(List<TaxAgentPO> taxAgents, List<PaymentAgencyPO> paymentAgencyPOS, List<TaxAgentAdminPO> taxAgentAdmins,
List<DataCollectionEmployee> adminList,
String setLabel) {
return convertToTableListDTO(Boolean.TRUE, taxAgents, paymentAgencyPOS, taxAgentAdmins, adminList, setLabel);
Map<Long, List<AuthRolePO>> rolelistMap) {
return convertToTableListDTO(Boolean.TRUE, taxAgents, paymentAgencyPOS, taxAgentAdmins, adminList, rolelistMap);
}
/**
@ -171,7 +166,7 @@ public class TaxAgentBO {
*/
public static List<Map<String, Object>> convertToTableListDTO(Boolean isDevolution, List<TaxAgentPO> taxAgents, List<PaymentAgencyPO> paymentAgencyPOS,
List<TaxAgentAdminPO> taxAgentAdmins,
List<DataCollectionEmployee> adminList, String setLabel) {
List<DataCollectionEmployee> adminList, Map<Long, List<AuthRolePO>> rolelistMap) {
if (CollectionUtils.isEmpty(taxAgents)) {
return Collections.emptyList();
}
@ -180,12 +175,13 @@ public class TaxAgentBO {
Map<String, Object> map = new LinkedHashMap<>();
map.put("id", e.getId());
map.put("name", e.getName());
map.put("employeeRange", setLabel);
map.put("employeeRange", "设置");
map.put("role", rolelistMap.getOrDefault(e.getId(), Collections.emptyList()));
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", setLabel);
map.put("subAdmins", "设置");
}
map.put("paymentAgency", buildPaymentAgency(e.getPaymentAgency(), paymentAgencyPOS));
map.put("description", e.getDescription());
@ -380,9 +376,9 @@ public class TaxAgentBO {
String key = saveParam.getIncludeType() + "-" + targetParam.getTargetType().getValue() + "-" + targetParam.getTargetId() + "-" + rangeTypeEnum.getValue();
if (taxAgentManageRangeMap.containsKey(key)) {
TaxAgentManageRangePO taxAgentManageRange = taxAgentManageRangeMap.get(key);
if(isImport){
if (isImport) {
taxAgentManageRange.setEmployeeStatus(JsonUtil.toJsonString(targetParam.getEmployeeStatus()));
}else {
} else {
taxAgentManageRange.setEmployeeStatus(JsonUtil.toJsonString(saveParam.getEmployeeStatus()));
}
taxAgentManageRange.setUpdateTime(now);
@ -403,9 +399,9 @@ public class TaxAgentBO {
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.deleteType(0)
.build();
if(isImport){
if (isImport) {
taxAgentManageRange.setEmployeeStatus(JsonUtil.toJsonString(targetParam.getEmployeeStatus()));
}else {
} else {
taxAgentManageRange.setEmployeeStatus(JsonUtil.toJsonString(saveParam.getEmployeeStatus()));
}
handleResult.getNeedInsertTaxAgentManageRanges().add(taxAgentManageRange);

View File

@ -1,6 +1,9 @@
package com.engine.salary.service.auth;
import com.engine.salary.entity.auth.param.AuthRoleSaveParam;
import com.engine.salary.entity.auth.po.AuthRolePO;
import java.util.List;
/**
* 角色
@ -12,6 +15,8 @@ import com.engine.salary.entity.auth.param.AuthRoleSaveParam;
**/
public interface AuthRoleService {
List<AuthRolePO> roleList(Long taxAgentId);
/**
* 添加角色
* @param param

View File

@ -21,6 +21,7 @@ import weaver.hrm.User;
import java.util.Collections;
import java.util.Date;
import java.util.List;
public class AuthRoleServiceImpl extends Service implements AuthRoleService {
@ -37,6 +38,11 @@ public class AuthRoleServiceImpl extends Service implements AuthRoleService {
}
@Override
public List<AuthRolePO> roleList(Long taxAgentId) {
return getAuthRoleMapper().listSome(AuthRolePO.builder().taxAgentId(taxAgentId).build());
}
@Override
public Long saveRole(AuthRoleSaveParam param) {
Date now = new Date();

View File

@ -4,6 +4,7 @@ import com.cloudstore.dev.api.util.Util_DataCache;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.cache.SalaryCacheKey;
import com.engine.salary.entity.auth.po.AuthRolePO;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.hrm.HrmStatus;
import com.engine.salary.entity.taxagent.bo.TaxAgentBO;
@ -16,7 +17,10 @@ import com.engine.salary.enums.UserStatusEnum;
import com.engine.salary.enums.salarysob.TargetTypeEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.service.*;
import com.engine.salary.service.auth.AuthRoleService;
import com.engine.salary.service.auth.AuthRoleServiceImpl;
import com.engine.salary.service.impl.*;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
@ -66,6 +70,9 @@ public class TaxAgentWrapper extends Service {
return ServiceUtil.getService(TaxAgentExcelServiceImpl.class, user);
}
public AuthRoleService getAuthRoleService(User user) {
return ServiceUtil.getService(AuthRoleServiceImpl.class, user);
}
// private PaymentAgencyService paymentAgencyService;
//
@ -116,8 +123,6 @@ public class TaxAgentWrapper extends Service {
// 是否开启分权
boolean isOpenDevolution = getTaxAgentBaseService(user).isOpenDevolution();
// List<PaymentAgencyPO> paymentAgencyPOS = paymentAgencyService.listAll(currentTenantKey);
PageInfo<TaxAgentPO> page = null;
// 分权情况下根据自己作为管理员过滤列表
if (isOpenDevolution && !isChief) {
@ -138,24 +143,29 @@ public class TaxAgentWrapper extends Service {
} else {
page = getTaxAgentService(user).listPage(queryParam);
}
List<TaxAgentPO> taxAgentPOS = page.getList();
//获取角色信息
List<AuthRolePO> authRolePOS = getAuthRoleService(user).roleList(null);
Map<Long, List<AuthRolePO>> rolelistMap = SalaryEntityUtil.group2Map(authRolePOS, AuthRolePO::getTaxAgentId);
PageInfo<Map<String, Object>> listPage = new PageInfo<>();
String setLabel = SalaryI18nUtil.getI18nLabel(94614, "设置");
if (isOpenDevolution) {
List<TaxAgentPO> list = page.getList();
List<TaxAgentPO> list = taxAgentPOS;
List<Long> taxAgentIds = list.stream().map(TaxAgentPO::getId).collect(Collectors.toList());
List<TaxAgentAdminPO> taxAgentAdmins = getTaxAgentAdminService(user).listByTaxAgentIds(taxAgentIds);
List<DataCollectionEmployee> adminList = getSalaryEmployeeService(user).getEmployeeByIdsAll(taxAgentAdmins.stream().map(TaxAgentAdminPO::getEmployeeId).distinct().collect(Collectors.toList()));
listPage.setList(TaxAgentBO.convertToTableListDTO(page.getList(), null, taxAgentAdmins, adminList, setLabel));
listPage.setList(TaxAgentBO.convertToTableListDTO(taxAgentPOS, null, taxAgentAdmins, adminList, rolelistMap));
} else {
listPage.setList(TaxAgentBO.convertToTableListDTO(page.getList(), null, setLabel));
listPage.setList(TaxAgentBO.convertToTableListDTO(taxAgentPOS, null, rolelistMap));
}
listPage.setTotal(page.getTotal());
listPage.setPageNum(page.getPageNum());
listPage.setPageSize(page.getPageSize());
//构造表格
TaxAgentBO.buildTaxAgentTable(listPage, isOpenDevolution);