Merge branch 'feature/salalryItemAndFieldSort' into release/2.8.3.2306.01

This commit is contained in:
Harryxzy 2023-06-05 09:52:57 +08:00
commit 30e2c489ea
18 changed files with 377 additions and 16 deletions

View File

@ -127,4 +127,31 @@ public class SalaryItemBiz {
}
}
public void batchUpdateSortedIndex(List<SalaryItemPO> list) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
SalaryItemMapper mapper = sqlSession.getMapper(SalaryItemMapper.class);
List<List<SalaryItemPO>> partition = (List<List<SalaryItemPO>>)Lists.partition(list, 100);
partition.forEach(mapper::batchUpdateSortedIndex);
sqlSession.commit();
} finally {
sqlSession.close();
}
}
public List<SalaryItemPO> listByParamOrderById(SalaryItemSearchParam searchParam) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
SalaryItemMapper mapper = sqlSession.getMapper(SalaryItemMapper.class);
return mapper.listByParamOrderById(searchParam);
} finally {
sqlSession.close();
}
}
}

View File

@ -5,6 +5,7 @@ import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.salaryformula.ExpressFormula;
import com.engine.salary.entity.salaryitem.dto.SalaryItemFormDTO;
import com.engine.salary.entity.salaryitem.dto.SalaryItemListDTO;
import com.engine.salary.entity.salaryitem.dto.SalaryItemSobListDTO;
import com.engine.salary.entity.salaryitem.param.SalaryItemSaveParam;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO;
@ -111,6 +112,7 @@ public class SalaryItemBO {
.formulaId(salaryItemPO.getFormulaId())
.formulaContent(formulaMap.getOrDefault(salaryItemPO.getFormulaId(), ""))
.taxDeclarationColumn(buildTaxDeclarationColumn(salaryItemPO.getCode()))
.sortedIndex(salaryItemPO.getSortedIndex())
.description(salaryItemPO.getDescription())
.canDelete(true)
.canEdit(openFormulaForcedEditing ||Objects.equals(salaryItemPO.getCanEdit(), NumberUtils.INTEGER_ONE))
@ -119,6 +121,50 @@ public class SalaryItemBO {
).collect(Collectors.toList());
}
/**
* 薪资项目po转换成薪资账套中薪资项目列表dto
*
* @param salaryItems 薪资项目po
* @param expressFormulas 公式详情
* @return
*/
public static List<SalaryItemSobListDTO> convert2itemSobListDTO(Collection<SalaryItemPO> salaryItems, List<ExpressFormula> expressFormulas, List<SysSalaryItemPO> sysSalaryItemPOS) {
if (CollectionUtils.isEmpty(salaryItems)) {
return Collections.emptyList();
}
Map<Long, String> formulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula);
Map<Long, String> sysSalaryItemNameMap = SalaryEntityUtil.convert2Map(sysSalaryItemPOS, SysSalaryItemPO::getId, SysSalaryItemPO::getName);
return salaryItems.stream().map(salaryItemPO -> {
SalaryRoundingModeEnum salaryRoundingModeEnum = SalaryRoundingModeEnum.parseByValue(salaryItemPO.getRoundingMode());
SalaryValueTypeEnum salaryValueTypeEnum = SalaryValueTypeEnum.parseByValue(salaryItemPO.getValueType());
SalaryDataTypeEnum salaryDataTypeEnum = SalaryDataTypeEnum.parseByValue(salaryItemPO.getDataType());
return SalaryItemSobListDTO.builder()
.id(salaryItemPO.getId())
.code(salaryItemPO.getCode())
.name(salaryItemPO.getName())
.systemName(sysSalaryItemNameMap.getOrDefault(salaryItemPO.getSysSalaryItemId(), StringUtils.EMPTY))
.useInEmployeeSalary(salaryItemPO.getUseInEmployeeSalary())
.useDefault(salaryItemPO.getUseDefault())
.roundingMode(Optional.ofNullable(salaryRoundingModeEnum)
.map(e -> SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel()))
.orElse(StringUtils.EMPTY))
.pattern(salaryItemPO.getPattern())
.valueType(Optional.ofNullable(salaryValueTypeEnum)
.map(e -> SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel()))
.orElse(StringUtils.EMPTY))
.dataType(Optional.ofNullable(salaryDataTypeEnum)
.map(e -> SalaryI18nUtil.getI18nLabel(e.getLabelId(), e.getDefaultLabel()))
.orElse(StringUtils.EMPTY))
.taxDeclarationColumn(buildTaxDeclarationColumn(salaryItemPO.getCode()))
.sortedIndex(salaryItemPO.getSortedIndex())
.description(salaryItemPO.getDescription())
.salaryItemType(salaryItemPO.getUseInEmployeeSalary() == 0 ? "薪资项目" : "档案字段")
.build();
}
).collect(Collectors.toList());
}
/**
* 转换成薪资项目详情dto
*
@ -141,7 +187,8 @@ public class SalaryItemBO {
.setDescription(salaryItemPO.getDescription())
.setCanEdit(salaryItemPO.getCanEdit())
.setTaxAgentIds(salaryItemPO.getTaxAgentIds())
.setSharedType(salaryItemPO.getSharedType());
.setSharedType(salaryItemPO.getSharedType())
.setSortedIndex(salaryItemPO.getSortedIndex());
}
/**
@ -219,6 +266,7 @@ public class SalaryItemBO {
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.sharedType(Optional.ofNullable(saveParam.getSharedType()).orElse(0))
.taxAgentIds(saveParam.getTaxAgentIds())
.sortedIndex(saveParam.getSortedIndex())
.build();
// 开启了"薪资档案引用"取值方式固定为输入
// if (Objects.equals(saveParam.getUseInEmployeeSalary(), NumberUtils.INTEGER_ONE)) {

View File

@ -73,6 +73,10 @@ public class SalaryFieldListDTO {
//是否可以删除
private Boolean canDelete;
@SalaryTableColumn(text = "显示顺序", width = "10%", column = "sortedIndex")
@TableTitle(title = "显示顺序",dataIndex = "sortedIndex",key = "sortedIndex")
private String sortedIndex;
@SalaryTableColumn(text = "操作", width = "20%", column = "operate")
private String operate;
}

View File

@ -85,4 +85,6 @@ public class SalaryItemFormDTO {
private Integer sharedType;
private String taxAgentIds;
private Integer sortedIndex;
}

View File

@ -95,6 +95,11 @@ public class SalaryItemListDTO {
//是否可以删除
private Boolean canDelete;
//排序
@SalaryTableColumn(text = "显示顺序", width = "10%", column = "sortedIndex")
@TableTitle(title = "显示顺序",dataIndex = "sortedIndex",key = "sortedIndex")
private Integer sortedIndex;
@SalaryTableColumn(text = "操作", width = "20%", column = "operate")
private String operate;
}

View File

@ -0,0 +1,103 @@
package com.engine.salary.entity.salaryitem.dto;
import com.engine.salary.annotation.SalaryTableColumn;
import com.engine.salary.annotation.TableTitle;
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author Harryxzy
* @date 2023/06/01 17:05
* @description 薪资账套薪资项目列表
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SalaryItemSobListDTO {
@JsonSerialize(using = ToStringSerializer.class)
@SalaryTableColumn(column = "id", display = false)
private Long id;
@SalaryTableColumn(text = "名称", width = "10%", column = "name")
@TableTitle(title = "名称",dataIndex = "name",key = "name")
private String name;
private String code;
@SalaryTableColumn(text = "系统名", width = "10%", column = "systemName")
@TableTitle(title = "系统名",dataIndex = "systemName",key = "systemName")
private String systemName;
//薪资档案引用
// @SalaryTableColumn(text = "薪资档案引用", width = "10%", column = "useInEmployeeSalary")
// @TableTitle(title = "薪资档案引用",dataIndex = "useInEmployeeSalary",key = "useInEmployeeSalary")
private Integer useInEmployeeSalary;
// 薪资项目类型
@SalaryTableColumn(text = "项目类型", width = "10%", column = "salaryItemType")
@TableTitle(title = "项目类型",dataIndex = "salaryItemType",key = "salaryItemType")
private String salaryItemType;
//默认使用
@SalaryTableColumn(text = "默认使用", width = "10%", column = "useDefault")
@TableTitle(title = "默认使用",dataIndex = "useDefault",key = "useDefault")
private Integer useDefault;
//进位规则
@SalaryTableColumn(text = "进位规则", width = "10%", column = "roundingMode",transmethod = "com.engine.salary.transmethod.TransMethod.roundingMode")
@TableTitle(title = "进位规则",dataIndex = "roundingMode",key = "roundingMode")
private String roundingMode;
//保留小数位
@SalaryTableColumn(text = "保留小数位", width = "10%", column = "pattern")
@TableTitle(title = "保留小数位",dataIndex = "pattern",key = "pattern")
private Integer pattern;
//取值方式
@SalaryTableColumn(text = "取值方式", width = "10%", column = "valueType",transmethod = "com.engine.salary.transmethod.TransMethod.datasource")
@TableTitle(title = "取值方式",dataIndex = "valueType",key = "valueType")
private String valueType;
/**
* @see SalaryDataTypeEnum
*/
@SalaryTableColumn(text = "字段类型", width = "10%", column = "dataType",transmethod = "com.engine.salary.transmethod.TransMethod.dataType")
@TableTitle(title = "字段类型",dataIndex = "dataType",key = "dataType")
private String dataType;
//公式id
private Long formulaId;
//公式内容
private String formulaContent;
@SalaryTableColumn(text = "个税申报表对应字段", width = "10%", column = "taxDeclarationColumn")
@TableTitle(title = "个税申报表对应字段",dataIndex = "taxDeclarationColumn",key = "taxDeclarationColumn")
private String taxDeclarationColumn;
//备注
@SalaryTableColumn(text = "备注", width = "10%", column = "description")
@TableTitle(title = "备注",dataIndex = "description",key = "description")
private String description;
//是否可以编辑
private Boolean canEdit;
//是否可以删除
private Boolean canDelete;
//排序
private Integer sortedIndex;
@SalaryTableColumn(text = "操作", width = "20%", column = "operate")
private String operate;
}

View File

@ -93,4 +93,9 @@ public class SalaryItemSaveParam {
* 绑定人员范围','分隔
*/
private String taxAgentIds;
/**
* 排序
*/
private Integer sortedIndex;
}

View File

@ -149,4 +149,9 @@ public class SalaryItemPO {
* 0不可删除1可删除
*/
private Integer canDelete;
/**
* 排序
*/
private Integer sortedIndex;
}

View File

@ -62,4 +62,10 @@ public interface SalaryItemMapper {
void deleteByIds(@Param("ids") Collection<Long> ids);
List<SalaryItemPO> listByParam(@Param("param") SalaryItemSearchParam param);
List<SalaryItemPO> listByParamOrderById(@Param("param") SalaryItemSearchParam param);
void batchUpdateSortedIndex(@Param("collection")List<SalaryItemPO> salaryItemPOS);
}

View File

@ -23,6 +23,7 @@
<result column="data_type" property="dataType"/>
<result column="shared_type" property="sharedType"/>
<result column="tax_agent_ids" property="taxAgentIds"/>
<result column="sorted_index" property="sortedIndex"/>
</resultMap>
<!-- 表字段 -->
@ -48,7 +49,8 @@
t.update_time,
t.data_type,
t.shared_type,
t.tax_agent_ids
t.tax_agent_ids,
t.sorted_index
</sql>
<!-- 查询全部 -->
@ -57,6 +59,7 @@
<include refid="baseColumns"/>
FROM hrsa_salary_item t
WHERE delete_type = 0
ORDER BY sorted_index DESC, id DESC
</select>
<!-- 根据主键获取单条记录 -->
@ -136,7 +139,7 @@
#{id}
</foreach>
</if>
ORDER BY id DESC
ORDER BY sorted_index DESC, id DESC
</select>
<!-- 插入不为NULL的字段 -->
@ -207,6 +210,9 @@
<if test="taxAgentIds != null">
tax_agent_ids,
</if>
<if test="sortedIndex != null">
sorted_index,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -272,6 +278,9 @@
<if test="taxAgentIds != null">
#{taxAgentIds},
</if>
<if test="sortedIndex != null">
#{sortedIndex},
</if>
</trim>
</insert>
@ -340,6 +349,7 @@
<if test="taxAgentIds != null">
tax_agent_ids=#{taxAgentIds},
</if>
sorted_index=#{sortedIndex},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
@ -426,8 +436,36 @@
#{id}
</foreach>
</update>
<update id="batchUpdateSortedIndex">
update hrsa_salary_item
<trim prefix="set" suffixOverrides=",">
<trim prefix="sorted_index =case" suffix="end,">
<foreach collection="collection" item="item" index="index">
<if test="item.sortedIndex!=null">
when id=#{item.id} then #{item.sortedIndex}
</if>
</foreach>
</trim>
</trim>
where
id in
<foreach collection="collection" item="item" index="index" separator="," open="(" close=")">
#{item.id}
</foreach>
</update>
<select id="listByParam" resultType="com.engine.salary.entity.salaryitem.po.SalaryItemPO">
SELECT
<include refid="baseColumns"/>
FROM
hrsa_salary_item t
WHERE
delete_type = 0
<include refid="paramSql"/>
ORDER BY sorted_index DESC, id DESC
</select>
<select id="listByParamOrderById" resultType="com.engine.salary.entity.salaryitem.po.SalaryItemPO">
SELECT
<include refid="baseColumns"/>
FROM
@ -438,6 +476,7 @@
ORDER BY id DESC
</select>
<sql id="paramSql">
<if test="param.name != null and param.name != ''">
AND name like CONCAT('%',#{param.name},'%')

View File

@ -85,6 +85,8 @@ public interface SalaryItemService {
*/
List<SalaryItemPO> listByParam(SalaryItemSearchParam searchParam);
List<SalaryItemPO> listByParamOrderById(SalaryItemSearchParam searchParam);
PageInfo<SalaryItemPO> listPageByParam(SalaryItemSearchParam searchParam);
@ -124,4 +126,12 @@ public interface SalaryItemService {
* @return
*/
SalaryItemServiceImpl.UsingItem getUsingItem();
/**
* 批量保存薪资项目顺序
* @param values
*/
void batchUpdateSortedIndex(List<SalaryItemPO> values);
}

View File

@ -120,6 +120,11 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
return salaryItemBiz.listByParam(searchParam);
}
@Override
public List<SalaryItemPO> listByParamOrderById(SalaryItemSearchParam searchParam) {
return salaryItemBiz.listByParamOrderById(searchParam);
}
@Override
public PageInfo<SalaryItemPO> listPageByParam(SalaryItemSearchParam searchParam) {
Boolean needAuth = getTaxAgentService(user).isNeedAuth((long) user.getUID());
@ -132,7 +137,34 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
.stream().map(TaxAgentPO::getId).collect(Collectors.toSet());
salaryItemPOS = salaryItemPOS.stream()
.filter(po -> filterInRange(userTaxAgentIds, po))
.sorted(Comparator.comparing(SalaryItemPO::getSystemType))
.sorted(new Comparator<SalaryItemPO>() {
@Override
public int compare(SalaryItemPO o1, SalaryItemPO o2) {
if(o1 == null)
return 1;
if(o2 == null)
return -1;
if(o1 == null && o2 == null)
return 0;
if(o1.getSortedIndex() == null && o2.getSortedIndex() == null){
Integer systemType1=o1.getSystemType();
Integer systemType2=o2.getSystemType();
if(systemType1 == null)
systemType1=0;
if(systemType2 == null)
systemType2=0;
return systemType1.compareTo(systemType2);
}else{
Integer sortedIndex1=o1.getSortedIndex();
Integer sortedIndex2=o2.getSortedIndex();
if(sortedIndex1 == null)
sortedIndex1=0;
if(sortedIndex2 == null)
sortedIndex2=0;
return sortedIndex2.compareTo(sortedIndex1);
}
}
})
.collect(Collectors.toList());
} else {
//普通用户
@ -142,6 +174,7 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
return SalaryPageUtil.buildPage(searchParam.getCurrent(), searchParam.getPageSize(), salaryItemPOS);
}
@Override
public boolean filterInRange(Set<Long> userTaxAgentIds, SalaryItemPO po) {
return null == po.getSharedType()
@ -174,7 +207,6 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
if (CollectionUtils.isNotEmpty(sysSalaryItemPOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98328, "自定义薪资项目的名称不能和系统薪资项目的名称重名"));
}
// 保存薪资项目
SalaryItemPO salaryItemPO = SalaryItemBO.convert2SalaryItemPO(saveParam, (long) user.getUID());
salaryItemBiz.insert(salaryItemPO);
// todo 记录日志
@ -227,6 +259,7 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
newSalaryItemPO.setUpdateTime(new Date());
newSalaryItemPO.setSharedType(saveParam.getSharedType());
newSalaryItemPO.setTaxAgentIds(saveParam.getTaxAgentIds());
newSalaryItemPO.setSortedIndex(saveParam.getSortedIndex());
salaryItemBiz.updateById(newSalaryItemPO);
//改名后更新公式
@ -366,6 +399,11 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
return UsingItem.builder().usingFormulaIds(usingFormulaIds).usingItemIds(usingItemIds).usingCodes(itemCode).build();
}
@Override
public void batchUpdateSortedIndex(List<SalaryItemPO> values) {
salaryItemBiz.batchUpdateSortedIndex(values);
}
@Data
@Builder

View File

@ -5,6 +5,7 @@ import com.engine.salary.entity.salaryitem.dto.SalaryItemFormDTO;
import com.engine.salary.entity.salaryitem.dto.SalaryItemListDTO;
import com.engine.salary.entity.salaryitem.param.SalaryItemSaveParam;
import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.util.ResponseResult;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.wrapper.SalaryFieldWrapper;
@ -18,6 +19,7 @@ import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.Collection;
import java.util.List;
/**
* 薪资字段管理
@ -45,6 +47,18 @@ public class SalaryFieldController {
return new ResponseResult<SalaryItemSearchParam, PageInfo<SalaryItemListDTO>>(user).run(getSalaryFieldWrapper(user)::listPage, searchParam);
}
/**
* 字段管理列表保存顺序
* @see
*/
@POST
@Path("/saveSortedIndex")
@Produces(MediaType.APPLICATION_JSON)
public String saveSortedIndex(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody List<SalaryItemPO> saveList) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<List<SalaryItemPO>, String>(user).run(getSalaryFieldWrapper(user)::saveSortedIndex, saveList);
}
/**
* 字段管理详情

View File

@ -1,7 +1,7 @@
package com.engine.salary.web;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.salaryitem.dto.SalaryItemListDTO;
import com.engine.salary.entity.salaryitem.dto.SalaryItemSobListDTO;
import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam;
import com.engine.salary.entity.salarysob.dto.*;
import com.engine.salary.entity.salarysob.param.*;
@ -281,7 +281,7 @@ public class SalarySobController {
@Produces(MediaType.APPLICATION_JSON)
public String listSalaryItem(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryItemSearchParam queryParam) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<SalaryItemSearchParam, PageInfo<SalaryItemListDTO> >(user).run(getSalarySobItemWrapper(user)::listPage4SalaryItem, queryParam);
return new ResponseResult<SalaryItemSearchParam, PageInfo<SalaryItemSobListDTO> >(user).run(getSalarySobItemWrapper(user)::listPage4SalaryItem, queryParam);
}

View File

@ -2,7 +2,6 @@ package com.engine.salary.wrapper;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.biz.EmployBiz;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryBill.dto.SalarySendCheckDTO;
import com.engine.salary.entity.salaryacct.bo.SalaryAcctRecordBO;
@ -60,6 +59,10 @@ public class SalaryAcctRecordWrapper extends Service implements SalaryAcctRecord
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
}
private SalaryItemService getSalaryItemService(User user) {
return ServiceUtil.getService(SalaryItemServiceImpl.class, user);
}
// private ComInfoCache comInfoCache;
public PageInfo<SalaryAcctRecordListDTO> listPage(SalaryAcctRecordQueryParam queryParam) {
@ -113,6 +116,35 @@ public class SalaryAcctRecordWrapper extends Service implements SalaryAcctRecord
return dtoPage;
}
/**
* @description 处理历史数据给薪资项目都增加个默认排序
* @return null
* @author Harryxzy
* @date 2023/5/29 14:37
*/
// private void generateSalaryItemSortedIndex() {
// // 查询所有薪资项目
// List<SalaryItemPO> salaryItemList = getSalaryItemService(user).listByParamOrderById(SalaryItemSearchParam.builder().build());
// Optional<SalaryItemPO> needGenerate = salaryItemList.stream().filter(item -> item.getSortedIndex() == null).findFirst();
// if(needGenerate.isPresent()){
// Map<Integer, List<SalaryItemPO>> salaryItemMap = SalaryEntityUtil.group2Map(salaryItemList, SalaryItemPO::getUseInEmployeeSalary);
// for(Map.Entry<Integer, List<SalaryItemPO>> entry : salaryItemMap.entrySet()){
// List<SalaryItemPO> values = entry.getValue();
// if(CollectionUtils.isNotEmpty(values)){
// // 将系统薪资项目放到最后
// values = values.stream()
// .sorted(Comparator.comparing(SalaryItemPO::getSystemType))
// .collect(Collectors.toList());
// // 添加默认sortedIndex
// AtomicInteger index = new AtomicInteger(values.size());
// values.stream().forEach(value -> value.setSortedIndex(index.getAndDecrement()));
// // 保存排序
// getSalaryItemService(user).batchUpdateSortedIndex(values);
// }
// }
// }
// }
/**
* 薪资核算记录详情
*

View File

@ -138,7 +138,6 @@ public class SalaryArchiveWrapper extends Service {
.stream().map(TaxAgentPO::getId).collect(Collectors.toSet());
salaryItems = salaryItems.stream()
.filter(po -> getSalaryItemService(user).filterInRange(userTaxAgentIds, po))
.sorted((Comparator.comparing(SalaryItemPO::getId)))
.collect(Collectors.toList());

View File

@ -204,4 +204,12 @@ public class SalaryFieldWrapper extends Service {
public void delete(Collection<Long> ids) {
getSalaryItemService(user).deleteByIds(ids);
}
/**
* 保存字段排序信息
* @param salaryItemPOS
*/
public void saveSortedIndex(List<SalaryItemPO> salaryItemPOS) {
getSalaryItemService(user).batchUpdateSortedIndex(salaryItemPOS);
}
}

View File

@ -6,7 +6,7 @@ import com.engine.salary.annotation.SalaryFormulaVar;
import com.engine.salary.entity.salaryformula.ExpressFormula;
import com.engine.salary.entity.salaryformula.dto.SalaryFormulaEmployeeDTO;
import com.engine.salary.entity.salaryitem.bo.SalaryItemBO;
import com.engine.salary.entity.salaryitem.dto.SalaryItemListDTO;
import com.engine.salary.entity.salaryitem.dto.SalaryItemSobListDTO;
import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO;
@ -19,6 +19,7 @@ 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;
import com.google.common.collect.Maps;
import org.apache.commons.collections4.CollectionUtils;
import weaver.hrm.User;
@ -68,8 +69,13 @@ public class SalarySobItemWrapper extends Service {
* @param queryParam 列表查询条件
* @return
*/
public PageInfo<SalaryItemListDTO> listPage4SalaryItem(SalaryItemSearchParam queryParam) {
public PageInfo<SalaryItemSobListDTO> listPage4SalaryItem(SalaryItemSearchParam queryParam) {
Integer searchPageSize = queryParam.getPageSize();
Integer searchCurrent = queryParam.getCurrent();
// 分页查询薪资项目
queryParam.setPageSize(10000000);
queryParam.setCurrent(1);
PageInfo<SalaryItemPO> page = getSalaryItemService(user).listPageByParam(queryParam);
List<SalaryItemPO> salaryItemList = page.getList();
@ -80,11 +86,22 @@ public class SalarySobItemWrapper extends Service {
salaryItemList = salaryItemList.stream()
.filter(po -> getSalaryItemService(user).filterInRange(taxAgentIds, po))
.collect(Collectors.toList());
// 薪资项目排序薪资项目放在前面首先按照设置的排序没有设置按照id倒序系统薪资项目放在最后档案字段放在后面
salaryItemList = salaryItemList.stream()
.sorted(new Comparator<SalaryItemPO>() {
@Override
public int compare(SalaryItemPO o1, SalaryItemPO o2) {
return Integer.compare(o1.getUseInEmployeeSalary(),o2.getUseInEmployeeSalary());
}
})
.collect(Collectors.toList());
SalaryPageUtil.buildPage(searchCurrent, searchPageSize, salaryItemList);
//最终返回的分页对象
PageInfo<SalaryItemListDTO> dtoPage = new PageInfo<>(SalaryItemListDTO.class);
dtoPage.setPageSize(page.getPageSize());
dtoPage.setPageNum(page.getPageNum());
PageInfo<SalaryItemSobListDTO> dtoPage = new PageInfo<>(SalaryItemSobListDTO.class);
dtoPage.setPageSize(searchPageSize);
dtoPage.setPageNum(searchCurrent);
dtoPage.setTotal(page.getTotal());
if (CollectionUtils.isNotEmpty(salaryItemList)) {
// 查询公式
@ -94,12 +111,11 @@ public class SalarySobItemWrapper extends Service {
Set<Long> sysSalaryItemIds = SalaryEntityUtil.properties(salaryItemList, SalaryItemPO::getSysSalaryItemId);
List<SysSalaryItemPO> sysSalaryItemPOS = getSysSalaryItemService(user).listByIds(sysSalaryItemIds);
// 转换成薪资项目列表dto
dtoPage.setList(SalaryItemBO.convert2ListDTO(salaryItemList, expressFormulas, sysSalaryItemPOS));
dtoPage.setList(SalaryItemBO.convert2itemSobListDTO(salaryItemList, expressFormulas, sysSalaryItemPOS));
}
return dtoPage;
}
/**
* 获取薪资账套的薪资项目详情
*