2022-03-23 18:41:38 +08:00
|
|
|
|
package com.engine.salary.wrapper;
|
|
|
|
|
|
|
2022-03-23 20:54:08 +08:00
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
2022-03-23 18:41:38 +08:00
|
|
|
|
import com.engine.core.impl.Service;
|
2022-04-13 11:03:27 +08:00
|
|
|
|
import com.engine.salary.annotation.SalaryFormulaVar;
|
2022-04-19 20:33:06 +08:00
|
|
|
|
import com.engine.salary.entity.salaryformula.ExpressFormula;
|
2022-04-29 14:17:31 +08:00
|
|
|
|
import com.engine.salary.entity.salaryformula.dto.SalaryFormulaEmployeeDTO;
|
2022-04-19 20:33:06 +08:00
|
|
|
|
import com.engine.salary.entity.salaryitem.bo.SalaryItemBO;
|
2023-06-01 17:52:31 +08:00
|
|
|
|
import com.engine.salary.entity.salaryitem.dto.SalaryItemSobListDTO;
|
2022-03-23 18:41:38 +08:00
|
|
|
|
import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam;
|
2022-04-19 20:33:06 +08:00
|
|
|
|
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
2022-07-27 16:56:13 +08:00
|
|
|
|
import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO;
|
2022-03-23 18:41:38 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO;
|
2023-07-24 17:11:19 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.dto.SalarySobItemFormDTO;
|
2022-03-23 18:41:38 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.param.SalarySobItemSaveParam;
|
|
|
|
|
|
import com.engine.salary.entity.salarysob.po.SalarySobItemGroupPO;
|
2023-07-24 17:11:19 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.po.SalarySobItemPO;
|
2025-02-14 14:50:54 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam;
|
2023-02-01 11:23:43 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
2025-02-14 14:50:54 +08:00
|
|
|
|
import com.engine.salary.enums.auth.AuthFilterTypeEnum;
|
2022-07-27 16:56:13 +08:00
|
|
|
|
import com.engine.salary.service.*;
|
|
|
|
|
|
import com.engine.salary.service.impl.*;
|
2022-04-19 20:33:06 +08:00
|
|
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
2022-04-13 11:03:27 +08:00
|
|
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
2022-04-19 20:33:06 +08:00
|
|
|
|
import com.engine.salary.util.page.PageInfo;
|
2023-06-01 17:52:31 +08:00
|
|
|
|
import com.engine.salary.util.page.SalaryPageUtil;
|
2022-04-13 11:03:27 +08:00
|
|
|
|
import com.google.common.collect.Maps;
|
2022-04-19 20:33:06 +08:00
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
2022-03-23 20:54:08 +08:00
|
|
|
|
import weaver.hrm.User;
|
2022-03-23 18:41:38 +08:00
|
|
|
|
|
2022-04-13 11:03:27 +08:00
|
|
|
|
import java.lang.reflect.Field;
|
2022-03-25 18:05:07 +08:00
|
|
|
|
import java.util.*;
|
2023-02-01 11:23:43 +08:00
|
|
|
|
import java.util.stream.Collectors;
|
2022-03-23 18:41:38 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 薪资账套的薪资项目
|
|
|
|
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author qiantao
|
|
|
|
|
|
* @version 1.0
|
|
|
|
|
|
**/
|
|
|
|
|
|
public class SalarySobItemWrapper extends Service {
|
|
|
|
|
|
|
2022-03-23 20:54:08 +08:00
|
|
|
|
private SalarySobItemService getSalarySobItemService(User user) {
|
2022-07-27 16:56:13 +08:00
|
|
|
|
return ServiceUtil.getService(SalarySobItemServiceImpl.class, user);
|
2022-03-23 20:54:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SalarySobItemGroupService getSalarySobItemGroupService(User user) {
|
2022-07-27 16:56:13 +08:00
|
|
|
|
return ServiceUtil.getService(SalarySobItemGroupServiceImpl.class, user);
|
2022-03-23 20:54:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-02-01 11:23:43 +08:00
|
|
|
|
private TaxAgentService getTaxAgentService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-23 20:54:08 +08:00
|
|
|
|
private SalaryItemService getSalaryItemService(User user) {
|
2022-07-27 16:56:13 +08:00
|
|
|
|
return ServiceUtil.getService(SalaryItemServiceImpl.class, user);
|
2022-03-23 20:54:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-04-19 20:33:06 +08:00
|
|
|
|
private SalaryFormulaService getSalaryFormulaService(User user) {
|
2022-07-27 16:56:13 +08:00
|
|
|
|
return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SysSalaryItemService getSysSalaryItemService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SysSalaryItemServiceImpl.class, user);
|
2022-04-19 20:33:06 +08:00
|
|
|
|
}
|
2022-03-23 18:41:38 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 薪资账套可选薪资项目列表
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param queryParam 列表查询条件
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2023-06-01 17:52:31 +08:00
|
|
|
|
public PageInfo<SalaryItemSobListDTO> listPage4SalaryItem(SalaryItemSearchParam queryParam) {
|
|
|
|
|
|
Integer searchPageSize = queryParam.getPageSize();
|
|
|
|
|
|
Integer searchCurrent = queryParam.getCurrent();
|
|
|
|
|
|
|
2024-12-09 17:13:45 +08:00
|
|
|
|
List<SalaryItemPO> salaryItemList = getSalaryItemService(user).listByParam(queryParam);
|
2022-04-19 20:33:06 +08:00
|
|
|
|
|
2025-02-14 14:50:54 +08:00
|
|
|
|
TaxAgentQueryParam param = TaxAgentQueryParam.builder().build();
|
|
|
|
|
|
param.setFilterType(AuthFilterTypeEnum.QUERY_DATA);
|
|
|
|
|
|
Set<Long> taxAgentIds = getTaxAgentService(user).listAuth(param).stream().map(TaxAgentPO::getId).collect(Collectors.toSet());
|
|
|
|
|
|
|
2023-02-01 11:23:43 +08:00
|
|
|
|
salaryItemList = salaryItemList.stream()
|
|
|
|
|
|
.filter(po -> getSalaryItemService(user).filterInRange(taxAgentIds, po))
|
|
|
|
|
|
.collect(Collectors.toList());
|
2023-06-01 17:52:31 +08:00
|
|
|
|
|
|
|
|
|
|
// 薪资项目排序:薪资项目放在前面(首先按照设置的排序,没有设置按照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());
|
2024-12-09 17:13:45 +08:00
|
|
|
|
|
2023-02-01 11:23:43 +08:00
|
|
|
|
|
2022-04-19 20:33:06 +08:00
|
|
|
|
//最终返回的分页对象
|
2023-06-01 17:52:31 +08:00
|
|
|
|
PageInfo<SalaryItemSobListDTO> dtoPage = new PageInfo<>(SalaryItemSobListDTO.class);
|
|
|
|
|
|
dtoPage.setPageSize(searchPageSize);
|
|
|
|
|
|
dtoPage.setPageNum(searchCurrent);
|
2024-12-09 17:13:45 +08:00
|
|
|
|
dtoPage.setTotal(salaryItemList.size());
|
|
|
|
|
|
List<SalaryItemPO> list = SalaryPageUtil.buildPage(searchCurrent, searchPageSize, salaryItemList).getList();
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
2022-04-19 20:33:06 +08:00
|
|
|
|
// 查询公式
|
2024-12-09 17:13:45 +08:00
|
|
|
|
Set<Long> formulaIds = SalaryEntityUtil.properties(list, SalaryItemPO::getFormulaId);
|
2022-04-19 20:33:06 +08:00
|
|
|
|
List<ExpressFormula> expressFormulas = getSalaryFormulaService(user).listExpressFormula(formulaIds);
|
2022-07-27 16:56:13 +08:00
|
|
|
|
// 查询系统薪资项目
|
2024-12-09 17:13:45 +08:00
|
|
|
|
Set<Long> sysSalaryItemIds = SalaryEntityUtil.properties(list, SalaryItemPO::getSysSalaryItemId);
|
2022-07-27 16:56:13 +08:00
|
|
|
|
List<SysSalaryItemPO> sysSalaryItemPOS = getSysSalaryItemService(user).listByIds(sysSalaryItemIds);
|
2022-04-19 20:33:06 +08:00
|
|
|
|
// 转换成薪资项目列表dto
|
2024-12-09 17:13:45 +08:00
|
|
|
|
dtoPage.setList(SalaryItemBO.convert2itemSobListDTO(list, expressFormulas, sysSalaryItemPOS));
|
2022-04-19 20:33:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
return dtoPage;
|
2022-03-23 18:41:38 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取薪资账套的薪资项目详情
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param salarySobItemGroupId 薪资账套的薪资项目的id
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public SalarySobItemGroupPO getGroupForm(Long salarySobItemGroupId) {
|
2022-03-23 20:54:08 +08:00
|
|
|
|
return getSalarySobItemGroupService(user).getById(salarySobItemGroupId);
|
2022-03-23 18:41:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取薪资账套的薪资项目详情
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param salarySobId 薪资账套的id
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public SalarySobItemAggregateDTO getForm(Long salarySobId) {
|
2022-03-23 20:54:08 +08:00
|
|
|
|
return getSalarySobItemService(user).getAggregateBySalarySobId(salarySobId);
|
2022-03-23 18:41:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 保存
|
|
|
|
|
|
*
|
2022-03-25 18:05:07 +08:00
|
|
|
|
* @param saveParam 保存参数
|
2022-03-23 18:41:38 +08:00
|
|
|
|
*/
|
|
|
|
|
|
public void save(SalarySobItemSaveParam saveParam) {
|
2022-03-23 20:54:08 +08:00
|
|
|
|
getSalarySobItemService(user).save(saveParam);
|
2022-03-23 18:41:38 +08:00
|
|
|
|
}
|
2022-03-25 18:05:07 +08:00
|
|
|
|
|
|
|
|
|
|
|
2022-04-13 11:03:27 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 基础信息浏览按钮(下拉框)
|
2022-07-27 16:56:13 +08:00
|
|
|
|
*
|
2022-04-13 11:03:27 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2022-03-25 18:05:07 +08:00
|
|
|
|
public Collection<Map<String, String>> empFieldList() {
|
2022-04-29 14:17:31 +08:00
|
|
|
|
Field[] declaredFields = SalaryFormulaEmployeeDTO.class.getDeclaredFields();
|
2022-04-13 11:03:27 +08:00
|
|
|
|
Map<String, String> empFieldMap = Maps.newHashMapWithExpectedSize(declaredFields.length);
|
2022-03-25 18:05:07 +08:00
|
|
|
|
List<Map<String, String>> list = new ArrayList();
|
2022-04-13 11:03:27 +08:00
|
|
|
|
for (Field declaredField : declaredFields) {
|
|
|
|
|
|
Map<String, String> item = new HashMap<>();
|
|
|
|
|
|
if (!declaredField.isAnnotationPresent(SalaryFormulaVar.class)) {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
SalaryFormulaVar annotation = declaredField.getAnnotation(SalaryFormulaVar.class);
|
|
|
|
|
|
empFieldMap.put(declaredField.getName(), SalaryI18nUtil.getI18nLabel(annotation.labelId(), annotation.defaultLabel()));
|
|
|
|
|
|
item.put("name", SalaryI18nUtil.getI18nLabel(annotation.labelId(), annotation.defaultLabel()));
|
|
|
|
|
|
item.put("id", declaredField.getName());
|
|
|
|
|
|
list.add(item);
|
|
|
|
|
|
}
|
2022-03-25 18:05:07 +08:00
|
|
|
|
return list;
|
|
|
|
|
|
}
|
2023-07-24 17:11:19 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 薪资项目的详情
|
|
|
|
|
|
*/
|
|
|
|
|
|
public SalarySobItemFormDTO getSalaryItemForm(SalarySobItemPO param) {
|
|
|
|
|
|
return getSalarySobItemService(user).getSalaryItemForm(param);
|
|
|
|
|
|
}
|
2024-04-24 15:55:41 +08:00
|
|
|
|
|
2022-03-23 18:41:38 +08:00
|
|
|
|
}
|