feat: 薪资项目分权代码合并

This commit is contained in:
fcli 2022-11-11 13:59:37 +08:00
parent 4726b9560c
commit 90b2edb96c
9 changed files with 122 additions and 39 deletions

View File

@ -201,6 +201,8 @@ public class SalaryItemBO {
.createTime(now)
.updateTime(now)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.sharedType(Optional.ofNullable(saveParam.getSharedType()).orElse(0))
.taxAgentIds(saveParam.getTaxAgentIds())
.build();
// 开启了"薪资档案引用"取值方式固定为输入
if (Objects.equals(saveParam.getUseInEmployeeSalary(), NumberUtils.INTEGER_ONE)) {

View File

@ -84,4 +84,13 @@ public class SalaryItemSaveParam {
//备注
private String description;
/**
* 可见范围0公共1私有
*/
private Integer sharedType;
/**
* 绑定人员范围','分隔
*/
private String taxAgentIds;
}

View File

@ -134,4 +134,14 @@ public class SalaryItemPO {
Collection<Long> ids;
Collection<Long> sysSalaryItemIds;
/**
* 可见性
*/
private Integer sharedType;
/**
* 可见范围
*/
private String taxAgentIds;
}

View File

@ -101,22 +101,24 @@ public class SalarySobItemAggregateBO {
for (int i = 0; i < v.size(); i++) {
SalarySobItemPO salarySobItemPO = v.get(i);
SalaryItemPO salaryItemPO = salaryItemMap.get(salarySobItemPO.getSalaryItemId());
items.add(SalarySobItemDTO.builder()
.id(salarySobItemPO.getId())
.salarySobId(salarySob.getId())
.salaryItemGroupId(k)
.salaryItemId(salaryItemPO.getId())
.dateType(salaryItemPO.getDataType())
.valueType(salaryItemPO.getValueType())
if (salaryItemPO != null) {
items.add(SalarySobItemDTO.builder()
.id(salarySobItemPO.getId())
.salarySobId(salarySob.getId())
.salaryItemGroupId(k)
.salaryItemId(salaryItemPO.getId())
.dateType(salaryItemPO.getDataType())
.valueType(salaryItemPO.getValueType())
.name(salaryItemPO.getName())
.itemHide(salarySobItemPO.getItemHide())
.formulaId(salarySobItemPO.getFormulaId())
.formulaContent(formulaMap.getOrDefault(salarySobItemPO.getFormulaId(), ""))
.taxDeclarationColumn(SalaryItemBO.buildTaxDeclarationColumn(salaryItemPO.getCode()))
.sortedIndex(salarySobItemPO.getSortedIndex())
.canEdit(openFormulaForcedEditing || Objects.equals(salaryItemPO.getCanEdit(), 1))
.canDelete(salarySobItemPO.getCanDelete() == null || Objects.equals(salarySobItemPO.getCanDelete(), 1))
.build());
.itemHide(salarySobItemPO.getItemHide())
.formulaId(salarySobItemPO.getFormulaId())
.formulaContent(formulaMap.getOrDefault(salarySobItemPO.getFormulaId(), ""))
.taxDeclarationColumn(SalaryItemBO.buildTaxDeclarationColumn(salaryItemPO.getCode()))
.sortedIndex(salarySobItemPO.getSortedIndex())
.canEdit(openFormulaForcedEditing || Objects.equals(salaryItemPO.getCanEdit(), 1))
.canDelete(salarySobItemPO.getCanDelete() == null || Objects.equals(salarySobItemPO.getCanDelete(), 1))
.build());
}
}
if (!salarySobItemGroupDTOMap.containsKey(k)) {
itemsWithoutGroup.addAll(items);

View File

@ -21,32 +21,34 @@
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="data_type" property="dataType"/>
<result column="shared_type" property="sharedType"/>
<result column="tax_agent_ids" property="taxAgentIds"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t
.
id
, t.name
, t.code
, t.system_type
, t.sys_salary_item_id
, t.use_default
, t.use_in_employee_salary
, t.rounding_mode
, t.pattern
, t.value_type
, t.formula_id
, t.description
, t.can_edit
, t.can_delete
, t.creator
, t.delete_type
, t.tenant_key
, t.create_time
, t.update_time
, t.data_type
t.id,
t.name,
t.code,
t.system_type,
t.sys_salary_item_id,
t.use_default,
t.use_in_employee_salary,
t.rounding_mode,
t.pattern,
t.value_type,
t.formula_id,
t.description,
t.can_edit,
t.can_delete,
t.creator,
t.delete_type,
t.tenant_key,
t.create_time,
t.update_time,
t.data_type,
t.shared_type,
t.tax_agent_ids
</sql>
<!-- 查询全部 -->

View File

@ -8,6 +8,7 @@ import com.engine.salary.util.page.PageInfo;
import java.util.Collection;
import java.util.List;
import java.util.Set;
/**
* 薪资项目
@ -86,6 +87,8 @@ public interface SalaryItemService {
PageInfo<SalaryItemPO> listPageByParam(SalaryItemSearchParam searchParam);
boolean filterInRange(Set<Long> userTaxAgentIds, SalaryItemPO po);
/**
* 保存
*

View File

@ -10,19 +10,24 @@ import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobItemPO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.enums.SalarySystemTypeEnum;
import com.engine.salary.enums.SalaryValueTypeEnum;
import com.engine.salary.enums.sicategory.SharedTypeEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.service.SalaryItemService;
import com.engine.salary.service.SalarySobItemService;
import com.engine.salary.service.TaxAgentService;
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;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import weaver.hrm.User;
import java.util.*;
import java.util.stream.Collectors;
/**
* 薪资项目
@ -40,6 +45,10 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
return (SalarySobItemService) ServiceUtil.getService(SalarySobItemServiceImpl.class, user);
}
private TaxAgentService getTaxAgentService(User user) {
return (TaxAgentServiceImpl) ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
private SysSalaryItemBiz sysSalaryItemBiz = new SysSalaryItemBiz();
// @Autowired
@ -93,7 +102,26 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
@Override
public PageInfo<SalaryItemPO> listPageByParam(SalaryItemSearchParam searchParam) {
return salaryItemBiz.listPageByParam(searchParam);
Boolean needAuth = getTaxAgentService(user).isNeedAuth((long) user.getUID());
List<SalaryItemPO> salaryItemPOS = salaryItemBiz.listByParam(searchParam);
if (needAuth) {
Set<Long> userTaxAgentIds = getTaxAgentService(user).listAllTaxAgents((long) user.getUID())
.stream().map(TaxAgentPO::getId).collect(Collectors.toSet());
salaryItemPOS = salaryItemPOS.stream()
.filter(po -> filterInRange(userTaxAgentIds, po)
).collect(Collectors.toList());
}
return SalaryPageUtil.buildPage(searchParam.getCurrent(), searchParam.getPageSize(), salaryItemPOS);
}
@Override
public boolean filterInRange(Set<Long> userTaxAgentIds, SalaryItemPO po) {
return null == po.getSharedType()
|| SharedTypeEnum.PUBLIC.getValue().equals(po.getSharedType().toString())
|| (po.getTaxAgentIds() != null
&& Arrays.stream(po.getTaxAgentIds().split(","))
.map(Long::valueOf)
.anyMatch(userTaxAgentIds::contains));
}
// @Override

View File

@ -12,6 +12,7 @@ import com.engine.salary.entity.salarysob.bo.SalarySobItemAggregateBO;
import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO;
import com.engine.salary.entity.salarysob.param.SalarySobItemSaveParam;
import com.engine.salary.entity.salarysob.po.*;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.service.*;
import com.engine.salary.util.SalaryEntityUtil;
@ -45,6 +46,10 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe
return (SalarySobEmpFieldService) ServiceUtil.getService(SalarySobEmpFieldServiceImpl.class, user);
}
private TaxAgentService getTaxAgentService(User user) {
return (TaxAgentService) ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
private SalarySobItemGroupService getSalarySobItemGroupService(User user) {
return (SalarySobItemGroupService) ServiceUtil.getService(SalarySobItemGroupServiceImpl.class, user);
}
@ -141,13 +146,25 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe
Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
Set<Long> backCalcItemIds = SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getSalaryItemId);
salaryItemIds.addAll(backCalcItemIds);
List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listByIds(salaryItemIds);
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());
// 转换成聚合dto
SalarySobItemAggregateBO salarySobItemAggregateBO = new SalarySobItemAggregateBO(salarySobPO, salarySobEmpFieldPOS,
salarySobItemGroupPOS, salarySobItemPOS, expressFormulas, salaryItemPOS, salarySobBackItems);
return salarySobItemAggregateBO.convert2AggregateDTO();
}
@Override
public SalarySobItemAggregateDTO getAggregateWithItemHideBySalarySobId(Long salarySobId, boolean isBackCalc) {
// 查询薪资账套

View File

@ -37,6 +37,16 @@ public class SalaryPageUtil {
return pageInfo;
}
public static <T> PageInfo<T> buildPage(Integer pageNo, Integer pageSize,List<T> totalCollection) {
PageInfo<T> pageInfo = new PageInfo<>();
pageInfo.setTotal(totalCollection.size());
totalCollection = subList(pageNo, pageSize, totalCollection);
pageInfo.setPageNum(pageNo);
pageInfo.setPageSize(pageSize);
pageInfo.setList(totalCollection);
return pageInfo;
}
/**
* 内存分页
*