自定义

This commit is contained in:
钱涛 2023-12-11 09:52:47 +08:00
parent 32984afaeb
commit e495c1799f
2 changed files with 28 additions and 22 deletions

View File

@ -23,6 +23,7 @@ import com.engine.salary.enums.salaryaccounting.LockStatusEnum;
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.page.SalaryPageUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.collections4.CollectionUtils;
@ -85,7 +86,6 @@ public class SalaryAcctResultBO {
// }
/**
* 构建薪资核算结果列表的表头线下对比
*
@ -170,7 +170,7 @@ public class SalaryAcctResultBO {
List<WeaTableColumnGroup> columns = Lists.newArrayList();
// 员工信息字段
for (SalarySobEmpFieldDTO salarySobEmpFieldDTO : salarySobItemAggregateDTO.getEmpFields()) {
columns.add(new WeaTableColumnGroup("150", salarySobEmpFieldDTO.getFieldName(), salarySobEmpFieldDTO.getFieldId()));
columns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(salarySobEmpFieldDTO.getFieldName()), salarySobEmpFieldDTO.getFieldName(), salarySobEmpFieldDTO.getFieldId()));
}
// 薪资项目分组下的薪资项目
for (SalarySobItemGroupDTO salarySobItemGroupDTO : salarySobItemAggregateDTO.getItemGroups()) {
@ -180,29 +180,29 @@ public class SalaryAcctResultBO {
List<WeaTableColumnGroup> childrenColumns = Lists.newArrayList();
for (SalarySobItemDTO salarySobItemDTO : salarySobItemGroupDTO.getItems()) {
if (lockSalaryItemIds.contains(salarySobItemDTO.getSalaryItemId())) {
childrenColumns.add(new WeaTableColumnGroup("150", salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), LockStatusEnum.LOCK.getValue(), salarySobItemDTO.getPattern()));
childrenColumns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(salarySobItemDTO.getName()), salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), LockStatusEnum.LOCK.getValue(), salarySobItemDTO.getPattern()));
} else {
childrenColumns.add(new WeaTableColumnGroup("150", salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), LockStatusEnum.UNLOCK.getValue(), salarySobItemDTO.getPattern()));
childrenColumns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(salarySobItemDTO.getName()), salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), LockStatusEnum.UNLOCK.getValue(), salarySobItemDTO.getPattern()));
}
}
WeaTableColumnGroup weaTableColumnWapper = new WeaTableColumnGroup("150", salarySobItemGroupDTO.getName(), String.valueOf(salarySobItemGroupDTO.getId()), childrenColumns);
WeaTableColumnGroup weaTableColumnWapper = new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(salarySobItemGroupDTO.getName()), salarySobItemGroupDTO.getName(), String.valueOf(salarySobItemGroupDTO.getId()), childrenColumns);
columns.add(weaTableColumnWapper);
}
// 没有分类的薪资项目
for (SalarySobItemDTO salarySobItemDTO : salarySobItemAggregateDTO.getItems()) {
if (lockSalaryItemIds.contains(salarySobItemDTO.getSalaryItemId())) {
columns.add(new WeaTableColumnGroup("150", salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), LockStatusEnum.LOCK.getValue(), salarySobItemDTO.getPattern()));
columns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(salarySobItemDTO.getName()), salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), LockStatusEnum.LOCK.getValue(), salarySobItemDTO.getPattern()));
} else {
columns.add(new WeaTableColumnGroup("150", salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), LockStatusEnum.UNLOCK.getValue(), salarySobItemDTO.getPattern()));
columns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(salarySobItemDTO.getName()), salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), LockStatusEnum.UNLOCK.getValue(), salarySobItemDTO.getPattern()));
}
}
// 回算的薪资项目
for (SalarySobItemDTO salarySobItemDTO : salarySobItemAggregateDTO.getBackCalcItems()) {
if (lockSalaryItemIds.contains(salarySobItemDTO.getSalaryItemId())) {
columns.add(new WeaTableColumnGroup("150", salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), LockStatusEnum.LOCK.getValue(), salarySobItemDTO.getPattern()));
columns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(salarySobItemDTO.getName()), salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), LockStatusEnum.LOCK.getValue(), salarySobItemDTO.getPattern()));
} else {
columns.add(new WeaTableColumnGroup("150", salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), LockStatusEnum.UNLOCK.getValue(), salarySobItemDTO.getPattern()));
columns.add(new WeaTableColumnGroup(SalaryPageUtil.selfAdaption(salarySobItemDTO.getName()), salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), LockStatusEnum.UNLOCK.getValue(), salarySobItemDTO.getPattern()));
}
}
@ -442,9 +442,9 @@ public class SalaryAcctResultBO {
sortItem(salarySobItemPOMap);
// 根据账套分组封装薪资项目的值
List<SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemByGroupDTO> itemsByGroup = new ArrayList<>();
for(SalarySobItemGroupPO groupPO : salarySobItemGroupPOS){
List<SalarySobItemPO> groupItems = salarySobItemPOMap.getOrDefault(groupPO.getId(),Collections.emptyList());
if(CollectionUtils.isNotEmpty(groupItems)){
for (SalarySobItemGroupPO groupPO : salarySobItemGroupPOS) {
List<SalarySobItemPO> groupItems = salarySobItemPOMap.getOrDefault(groupPO.getId(), Collections.emptyList());
if (CollectionUtils.isNotEmpty(groupItems)) {
List<SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemDTO> items = groupItems.stream()
.map(salarySobItemPO -> convert2SalaryAcctResultDetailItemDTO(salarySobItemPO, salaryItemMap.get(salarySobItemPO.getSalaryItemId()), resultValueMap, formulaContentMap))
.collect(Collectors.toList());
@ -452,12 +452,12 @@ public class SalaryAcctResultBO {
.salarySobItemGroupId(groupPO.getId())
.salarySobItemGroupName(groupPO.getName())
.salaryItems(items)
.sortedIndex(groupPO.getSortedIndex()).build() );
.sortedIndex(groupPO.getSortedIndex()).build());
}
}
// 未分类
List<SalarySobItemPO> noGroupItems = salarySobItemPOMap.getOrDefault(0L, Collections.emptyList());
if(CollectionUtils.isNotEmpty(noGroupItems)){
if (CollectionUtils.isNotEmpty(noGroupItems)) {
List<SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemDTO> items = noGroupItems.stream()
.map(salarySobItemPO -> convert2SalaryAcctResultDetailItemDTO(salarySobItemPO, salaryItemMap.get(salarySobItemPO.getSalaryItemId()), resultValueMap, formulaContentMap))
.collect(Collectors.toList());
@ -469,7 +469,6 @@ public class SalaryAcctResultBO {
}
// // 公式项的值不根据salaryItemPO的valueType判断是因为薪资项目的valueType属性改变后并不会同步更新薪资账套中的薪资项目的formulaId字段
// List<SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemDTO> formulaItems = salarySobItemPOS.stream()
// .filter(salarySobItemPO -> salarySobItemPO.getFormulaId() > 0)
@ -500,7 +499,7 @@ public class SalaryAcctResultBO {
}
public static List<SalarySobItemGroupPO> sortGroup(List<SalarySobItemGroupPO> salarySobItemGroupPOS) {
if(CollectionUtils.isEmpty(salarySobItemGroupPOS)){
if (CollectionUtils.isEmpty(salarySobItemGroupPOS)) {
return Collections.emptyList();
}
return salarySobItemGroupPOS.stream().sorted(Comparator.comparingInt(SalarySobItemGroupPO::getSortedIndex)).collect(Collectors.toList());
@ -508,10 +507,9 @@ public class SalaryAcctResultBO {
/**
* 薪资账套的薪资项目按照sortedIndex排序
*
*/
public static void sortItem(Map<Long, List<SalarySobItemPO>> salarySobItemPOMap) {
for(Map.Entry<Long, List<SalarySobItemPO>> entry : salarySobItemPOMap.entrySet()){
for (Map.Entry<Long, List<SalarySobItemPO>> entry : salarySobItemPOMap.entrySet()) {
List<SalarySobItemPO> items = entry.getValue();
if (CollectionUtils.isNotEmpty(items)) {
List<SalarySobItemPO> sortedValue = items.stream().sorted(Comparator.comparingInt(SalarySobItemPO::getSortedIndex)).collect(Collectors.toList());
@ -535,9 +533,9 @@ public class SalaryAcctResultBO {
SalaryValueTypeEnum salaryValueTypeEnum = SalaryValueTypeEnum.parseByValue(Optional.ofNullable(salarySobItemPO).map(SalarySobItemPO::getValueType).orElse(0));
String itemFormulaContent;
if(Objects.equals(salaryValueTypeEnum.getValue(),SalaryValueTypeEnum.FORMULA.getValue())){
if (Objects.equals(salaryValueTypeEnum.getValue(), SalaryValueTypeEnum.FORMULA.getValue())) {
itemFormulaContent = Optional.ofNullable(formulaContentMap.get(salarySobItemPO.getSalaryItemId().toString())).map(SalaryAcctResultListColumnDTO::getFormulaContent).orElse("");
}else{
} else {
itemFormulaContent = salaryValueTypeEnum == null ? "" : salaryValueTypeEnum.getDefaultLabel();
}

View File

@ -2,6 +2,7 @@ package com.engine.salary.util.page;
import com.github.pagehelper.PageHelper;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Collections;
@ -37,8 +38,8 @@ public class SalaryPageUtil {
return pageInfo;
}
public static <T> PageInfo<T> buildPage(Integer pageNo, Integer pageSize,List<T> totalCollection) {
PageInfo<T> pageInfo = new 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);
@ -90,4 +91,11 @@ public class SalaryPageUtil {
return source.subList(startIndex > source.size() ? source.size() : startIndex,
endIndex > source.size() ? source.size() : endIndex);
}
public static String selfAdaption(String chars) {
if (StringUtils.isNotEmpty(chars)) {
return chars.length() * 12+40 + "";
}
return "150";
}
}