90 lines
3.3 KiB
Java
90 lines
3.3 KiB
Java
|
|
package com.engine.salary.service.impl;
|
||
|
|
|
||
|
|
import com.engine.core.impl.Service;
|
||
|
|
import com.engine.salary.entity.formula.ExpressFormula;
|
||
|
|
import com.engine.salary.entity.formula.po.FormulaPO;
|
||
|
|
import com.engine.salary.entity.formula.po.FormulaVar;
|
||
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
||
|
|
import com.engine.salary.mapper.formula.FormulaMapper;
|
||
|
|
import com.engine.salary.mapper.formula.FormulaVarMapper;
|
||
|
|
import com.engine.salary.service.SalaryFormulaService;
|
||
|
|
import com.engine.salary.util.db.MapperProxyFactory;
|
||
|
|
import com.google.common.collect.Lists;
|
||
|
|
import lombok.extern.slf4j.Slf4j;
|
||
|
|
import org.apache.commons.collections4.CollectionUtils;
|
||
|
|
import org.springframework.beans.BeanUtils;
|
||
|
|
|
||
|
|
import java.util.Collection;
|
||
|
|
import java.util.Collections;
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Objects;
|
||
|
|
import java.util.stream.Collectors;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 薪酬管理公式编辑器
|
||
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
||
|
|
* <p>Company: 泛微软件</p>
|
||
|
|
*
|
||
|
|
* @author qiantao
|
||
|
|
* @version 1.0
|
||
|
|
**/
|
||
|
|
@Slf4j
|
||
|
|
public class SalaryFormulaServiceImpl extends Service implements SalaryFormulaService {
|
||
|
|
|
||
|
|
|
||
|
|
private FormulaMapper getFormulaMapper() {
|
||
|
|
return MapperProxyFactory.getProxy(FormulaMapper.class);
|
||
|
|
}
|
||
|
|
|
||
|
|
private FormulaVarMapper getFormulaVarMapper() {
|
||
|
|
return MapperProxyFactory.getProxy(FormulaVarMapper.class);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public List<ExpressFormula> listExpressFormula(Collection<Long> formulaIds) {
|
||
|
|
formulaIds = formulaIds.stream().filter(id -> id != null && id > 0).collect(Collectors.toList());
|
||
|
|
if (CollectionUtils.isEmpty(formulaIds)) {
|
||
|
|
return Collections.emptyList();
|
||
|
|
}
|
||
|
|
try {
|
||
|
|
// 当前租户自己新建的公式
|
||
|
|
List<FormulaPO> expressFormulas = getFormulaMapper().listByIds(Lists.newArrayList(formulaIds));
|
||
|
|
|
||
|
|
return expressFormulas.stream()
|
||
|
|
.filter(Objects::nonNull)
|
||
|
|
.map(m -> {
|
||
|
|
ExpressFormula expressFormula = new ExpressFormula();
|
||
|
|
BeanUtils.copyProperties(m, expressFormula);
|
||
|
|
List<FormulaVar> formulaVarPOS = getFormulaVarMapper().listSome(FormulaVar.builder().formulaId(m.getId()).build());
|
||
|
|
expressFormula.setParameters(formulaVarPOS);
|
||
|
|
return expressFormula;
|
||
|
|
})
|
||
|
|
.collect(Collectors.toList());
|
||
|
|
} catch (Exception e) {
|
||
|
|
log.info("获取公示详情失败", e);
|
||
|
|
throw new SalaryRunTimeException("获取公示详情失败");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public ExpressFormula getExpressFormula(Long formulaId) {
|
||
|
|
if (formulaId == null || formulaId <= 0) {
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
try {
|
||
|
|
// 当前租户自己新建的公式
|
||
|
|
FormulaPO formulaPO = getFormulaMapper().getById(formulaId);
|
||
|
|
ExpressFormula expressFormula = new ExpressFormula();
|
||
|
|
BeanUtils.copyProperties(formulaPO, expressFormula);
|
||
|
|
List<FormulaVar> formulaVarPOS = getFormulaVarMapper().listSome(FormulaVar.builder().formulaId(formulaId).build());
|
||
|
|
expressFormula.setParameters(formulaVarPOS);
|
||
|
|
|
||
|
|
return expressFormula;
|
||
|
|
} catch (Exception e) {
|
||
|
|
log.info("获取公示详情失败", e);
|
||
|
|
throw new SalaryRunTimeException("获取公示详情失败");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|