Merge branch 'feature/acctV2' into develop
This commit is contained in:
commit
7fbe29b36a
|
|
@ -37,12 +37,13 @@ import java.util.*;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @description: 薪资核算-将数据转换成公式中的变量
|
||||
* @author: xiajun
|
||||
* @modified By: xiajun
|
||||
* @date: Created in 1/25/22 7:29 PM
|
||||
* @version:v1.0
|
||||
*/
|
||||
* 薪资核算-将数据转换成公式中的变量
|
||||
* <p>Copyright: Copyright (c) 2022</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class CalculateFormulaVarBO {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.engine.salary.service;
|
|||
|
||||
import com.engine.salary.entity.salaryformula.ExpressFormula;
|
||||
import com.engine.salary.entity.salaryformula.param.SalaryFormulaSaveParam;
|
||||
import com.engine.salary.entity.salaryformula.po.FormulaPO;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
|
@ -32,7 +33,7 @@ public interface SalaryFormulaService {
|
|||
*/
|
||||
ExpressFormula getExpressFormula(Long formulaId);
|
||||
|
||||
void save(SalaryFormulaSaveParam salaryFormulaSaveParam);
|
||||
FormulaPO save(SalaryFormulaSaveParam salaryFormulaSaveParam);
|
||||
|
||||
void update(SalaryFormulaSaveParam salaryFormulaSaveParam);
|
||||
FormulaPO update(SalaryFormulaSaveParam salaryFormulaSaveParam);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,13 @@ public class FormulaRunServiceImpl extends Service implements FormulaRunService
|
|||
@Override
|
||||
public Object run(ExpressFormula expressFormula, List<FormulaVar> formulaVars, DataCollectionEmployee simpleEmployee) {
|
||||
|
||||
|
||||
/*
|
||||
公式内容以如下显示方式存储
|
||||
{薪资项目.输入项1}+{薪资项目.输入项2}
|
||||
*/
|
||||
String formula = expressFormula.getFormula();
|
||||
|
||||
|
||||
JexlBuilder jexlBuilder = new JexlBuilder();
|
||||
// 创建Jexl表达式引擎
|
||||
JexlEngine jexlEngine = jexlBuilder.create();
|
||||
|
|
@ -23,8 +27,8 @@ public class FormulaRunServiceImpl extends Service implements FormulaRunService
|
|||
JexlScript jexlScript = jexlEngine.createScript(formula);
|
||||
// 创建Jexl表达式变量上下文
|
||||
JexlContext jexlContext = new MapContext();
|
||||
formulaVars.forEach(v->{
|
||||
jexlContext.set(v.getFieldId(),v.getContent());
|
||||
formulaVars.forEach(v -> {
|
||||
jexlContext.set(v.getFieldId(), v.getContent());
|
||||
});
|
||||
// 执行Jexl表达式,得到结果
|
||||
Object execute = jexlScript.execute(jexlContext);
|
||||
|
|
|
|||
|
|
@ -247,9 +247,6 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
|
|||
// 给公式中的变量填入值
|
||||
List<FormulaVar> formulaVars = ExpressFormulaBO.buildFormulaVar4Accounting(expressFormula, formulaVarValueMap);
|
||||
|
||||
String formula = expressFormula.getFormula();
|
||||
|
||||
|
||||
// todo 运行公式
|
||||
Object run = getFormulaRunService(user).run(expressFormula, formulaVars, simpleEmployee);
|
||||
// if (excelResult.isStatus()) {
|
||||
|
|
|
|||
|
|
@ -89,10 +89,12 @@ public class SalaryFormulaServiceImpl extends Service implements SalaryFormulaSe
|
|||
}
|
||||
|
||||
@Override
|
||||
public void save(SalaryFormulaSaveParam param) {
|
||||
public FormulaPO save(SalaryFormulaSaveParam param) {
|
||||
|
||||
FormulaPO formulaPO = new FormulaPO();
|
||||
|
||||
String formula = param.getFormula();
|
||||
|
||||
formulaPO.setName(param.getName());
|
||||
formulaPO.setDescription(param.getDescription());
|
||||
formulaPO.setModule(param.getModule());
|
||||
|
|
@ -101,7 +103,7 @@ public class SalaryFormulaServiceImpl extends Service implements SalaryFormulaSe
|
|||
formulaPO.setReturnType(param.getReturnType());
|
||||
formulaPO.setValidateType(param.getValidateType());
|
||||
formulaPO.setExtendParam(param.getExtendParam());
|
||||
formulaPO.setFormula(param.getFormula());
|
||||
formulaPO.setFormula(formula);
|
||||
formulaPO.setDeleteType(NumberUtils.INTEGER_ZERO);
|
||||
|
||||
Date now = new Date();
|
||||
|
|
@ -112,6 +114,10 @@ public class SalaryFormulaServiceImpl extends Service implements SalaryFormulaSe
|
|||
|
||||
List<FormulaVar> parameters = param.getParameters();
|
||||
parameters.forEach(po -> {
|
||||
|
||||
formula.replace(po.getFieldName(), po.getFieldId());
|
||||
|
||||
|
||||
po.setFormulaId(formulaPO.getId());
|
||||
po.setDeleteType(NumberUtils.INTEGER_ZERO);
|
||||
po.setCreator((long) user.getUID());
|
||||
|
|
@ -120,11 +126,13 @@ public class SalaryFormulaServiceImpl extends Service implements SalaryFormulaSe
|
|||
getFormulaVarMapper().insertIgnoreNull(po);
|
||||
});
|
||||
|
||||
|
||||
return formulaPO;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void update(SalaryFormulaSaveParam param) {
|
||||
public FormulaPO update(SalaryFormulaSaveParam param) {
|
||||
|
||||
ValidUtil.doValidator(param, RuntimeTypeEnum.UPDATE);
|
||||
|
||||
|
|
@ -159,7 +167,7 @@ public class SalaryFormulaServiceImpl extends Service implements SalaryFormulaSe
|
|||
po.setUpdateTime(now);
|
||||
getFormulaVarMapper().insertIgnoreNull(po);
|
||||
});
|
||||
|
||||
return formulaPO;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.engine.common.util.ServiceUtil;
|
|||
import com.engine.salary.entity.salaryformula.dto.ExpressFormulaDTO;
|
||||
import com.engine.salary.entity.salaryformula.param.SalaryFormulaFieldQueryParam;
|
||||
import com.engine.salary.entity.salaryformula.param.SalaryFormulaSaveParam;
|
||||
import com.engine.salary.entity.salaryformula.po.FormulaPO;
|
||||
import com.engine.salary.entity.salaryformula.po.FormulaVar;
|
||||
import com.engine.salary.util.ResponseResult;
|
||||
import com.engine.salary.wrapper.SalaryFormulaWrapper;
|
||||
|
|
@ -58,7 +59,7 @@ public class SalaryFormulaController {
|
|||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryFormulaSaveParam param) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<SalaryFormulaSaveParam, String>().run(getSalaryFormulaWrapper(user)::save, param);
|
||||
return new ResponseResult<SalaryFormulaSaveParam, FormulaPO>().run(getSalaryFormulaWrapper(user)::save, param);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.engine.common.util.ServiceUtil;
|
|||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.entity.salaryformula.ExpressFormula;
|
||||
import com.engine.salary.entity.salaryformula.param.SalaryFormulaSaveParam;
|
||||
import com.engine.salary.entity.salaryformula.po.FormulaPO;
|
||||
import com.engine.salary.entity.salaryformula.po.FormulaVar;
|
||||
import com.engine.salary.entity.salaryformula.bo.SalaryFormulaBO;
|
||||
import com.engine.salary.entity.salaryformula.dto.ExpressFormulaDTO;
|
||||
|
|
@ -68,7 +69,7 @@ public class SalaryFormulaWrapper extends Service {
|
|||
return SalaryFormulaBO.convert2DTO(expressFormulas).get(0);
|
||||
}
|
||||
|
||||
public void save(SalaryFormulaSaveParam salaryFormulaSaveParam) {
|
||||
getSalaryFormulaService(user).save(salaryFormulaSaveParam);
|
||||
public FormulaPO save(SalaryFormulaSaveParam salaryFormulaSaveParam) {
|
||||
return getSalaryFormulaService(user).save(salaryFormulaSaveParam);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue