This commit is contained in:
parent
a2102a49b4
commit
a4547db7ff
|
|
@ -1,10 +1,6 @@
|
|||
package com.engine.salary.entity.formula;
|
||||
|
||||
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.weaver.excel.formula.api.entity.ExpressFormulaSourceLink;
|
||||
import com.weaver.excel.formula.api.entity.FormulaVar;
|
||||
import com.engine.salary.entity.formula.po.FormulaVar;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
@ -12,35 +8,63 @@ import java.util.List;
|
|||
|
||||
@Data
|
||||
public class ExpressFormula {
|
||||
@JsonSerialize(
|
||||
using = ToStringSerializer.class
|
||||
)
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
//名称
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 模块
|
||||
*/
|
||||
private String module;
|
||||
private String parameter;
|
||||
private Long userId;
|
||||
private Integer status;
|
||||
private String msgFormula;
|
||||
private String msgParameter;
|
||||
private Date addTime;
|
||||
private Date lastUpdate;
|
||||
private Integer isDelete;
|
||||
private Long formId;
|
||||
private int type;
|
||||
private String tenantKey;
|
||||
private DataCollectionEmployee creator;
|
||||
private List<ExpressFormulaSourceLink> sourceLinks;
|
||||
//引用类型
|
||||
/**
|
||||
* 用途
|
||||
*/
|
||||
private String use;
|
||||
/**
|
||||
* 引用类型
|
||||
*/
|
||||
private String referenceType;
|
||||
//返回类型
|
||||
/**
|
||||
* 返回类型
|
||||
*/
|
||||
private String returnType;
|
||||
//公式内容
|
||||
/**
|
||||
* 校验类型
|
||||
*/
|
||||
private String validateType;
|
||||
/**
|
||||
* 扩展参数
|
||||
*/
|
||||
private String extendParam;
|
||||
/**
|
||||
* 公式内容
|
||||
*/
|
||||
private String formula;
|
||||
private boolean showInLibrary;
|
||||
private String codeFormula;
|
||||
private String msgCodeFormula;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long creator;
|
||||
/**
|
||||
* 是否删除0否1是
|
||||
*/
|
||||
private Integer deleteType;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
private List<FormulaVar> parameters;
|
||||
private List<FormulaVar> msgParameters;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,75 @@
|
|||
package com.engine.salary.entity.formula.po;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FormulaPO {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 模块
|
||||
*/
|
||||
private String module;
|
||||
/**
|
||||
* 用途
|
||||
*/
|
||||
private String use;
|
||||
/**
|
||||
* 引用类型
|
||||
*/
|
||||
private String referenceType;
|
||||
/**
|
||||
* 返回类型
|
||||
*/
|
||||
private String returnType;
|
||||
/**
|
||||
* 校验类型
|
||||
*/
|
||||
private String validateType;
|
||||
/**
|
||||
* 扩展参数
|
||||
*/
|
||||
private String extendParam;
|
||||
/**
|
||||
* 公式内容
|
||||
*/
|
||||
private String formula;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long creator;
|
||||
/**
|
||||
* 是否删除0否1是
|
||||
*/
|
||||
private Integer deleteType;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
//主键id集合
|
||||
private Collection<Long> ids;
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
package com.engine.salary.entity.formula.po;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FormulaVar {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 公式id
|
||||
*/
|
||||
private Long formulaId;
|
||||
/**
|
||||
* 字段id
|
||||
*/
|
||||
private String fieldId;
|
||||
/**
|
||||
* 字段名称
|
||||
*/
|
||||
private String fieldName;
|
||||
/**
|
||||
* 字段类型,number,string
|
||||
*/
|
||||
private String fieldType;
|
||||
/**
|
||||
* 来源
|
||||
*/
|
||||
private String source;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer order;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long creator;
|
||||
/**
|
||||
* 是否删除,0否1是
|
||||
*/
|
||||
private Integer deleteType;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
//值
|
||||
private String content;
|
||||
}
|
||||
|
|
@ -1,16 +1,13 @@
|
|||
package com.engine.salary.entity.salaryacct.bo;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.salary.constant.SalaryFormulaFieldConstant;
|
||||
import com.engine.salary.entity.formula.ExpressFormula;
|
||||
import com.engine.salary.entity.formula.po.FormulaVar;
|
||||
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
|
||||
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
||||
import com.engine.salary.enums.SalaryFormulaReferenceEnum;
|
||||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.weaver.excel.formula.api.entity.ExpressFormula;
|
||||
import com.weaver.excel.formula.api.entity.FormulaVar;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
|
|
@ -18,17 +15,17 @@ import java.math.BigDecimal;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @description: 薪资核算公式
|
||||
* @author: xiajun
|
||||
* @modified By: xiajun
|
||||
* @date: Created in 6/2/22 10:33 PM
|
||||
* @version:v1.0
|
||||
*/
|
||||
* 薪资核算公式
|
||||
* <p>Copyright: Copyright (c) 2022</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
public class ExpressFormulaBO {
|
||||
|
||||
/**
|
||||
|
|
@ -53,17 +50,7 @@ public class ExpressFormulaBO {
|
|||
}
|
||||
Map<Long, List<FormulaVar>> resultMap = Maps.newHashMapWithExpectedSize(expressFormulas.size());
|
||||
for (ExpressFormula expressFormula : expressFormulas) {
|
||||
if (StringUtils.isEmpty(expressFormula.getParameter())) {
|
||||
continue;
|
||||
}
|
||||
JSONObject paramJson = JSON.parseObject(expressFormula.getParameter());
|
||||
if (paramJson != null) {
|
||||
JSONArray paramArray = paramJson.getJSONArray("formulavars");
|
||||
if (paramArray != null) {
|
||||
List<FormulaVar> formulaVars = paramArray.toJavaList(FormulaVar.class);
|
||||
resultMap.put(expressFormula.getId(), formulaVars);
|
||||
}
|
||||
}
|
||||
resultMap.put(expressFormula.getId(), expressFormula.getParameters());
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
|
@ -106,25 +93,15 @@ public class ExpressFormulaBO {
|
|||
*/
|
||||
public static List<FormulaVar> buildFormulaVar4Accounting(ExpressFormula expressFormula, Map<String, String> formulaVarValueMap) {
|
||||
List<FormulaVar> formulaVars = Collections.emptyList();
|
||||
// 公式异常
|
||||
if (Objects.isNull(expressFormula) || StringUtils.isEmpty(expressFormula.getParameter())) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
JSONObject paramJson = JSON.parseObject(expressFormula.getParameter());
|
||||
if (paramJson != null) {
|
||||
JSONArray paramArray = paramJson.getJSONArray("formulavars");
|
||||
if (paramArray != null) {
|
||||
formulaVars = paramArray.toJavaList(FormulaVar.class);
|
||||
for (FormulaVar formulaVar : formulaVars) {
|
||||
// 公式变量的值
|
||||
String formulaVarValue = formulaVarValueMap.getOrDefault(formulaVar.getFieldId(), StringUtils.EMPTY);
|
||||
// 如果公式的返回值类型为number,公式中的变量的值如果为空,公式运行的时候会报错,所以需要替换成0
|
||||
if (StringUtils.isEmpty(formulaVarValue) && "number".equals(expressFormula.getReturnType())) {
|
||||
formulaVarValue = BigDecimal.ZERO.toPlainString();
|
||||
}
|
||||
formulaVar.setContent(formulaVarValue);
|
||||
}
|
||||
formulaVars = expressFormula.getParameters();
|
||||
for (FormulaVar formulaVar : formulaVars) {
|
||||
// 公式变量的值
|
||||
String formulaVarValue = formulaVarValueMap.getOrDefault(formulaVar.getFieldId(), StringUtils.EMPTY);
|
||||
// 如果公式的返回值类型为number,公式中的变量的值如果为空,公式运行的时候会报错,所以需要替换成0
|
||||
if (StringUtils.isEmpty(formulaVarValue) && "number".equals(expressFormula.getReturnType())) {
|
||||
formulaVarValue = BigDecimal.ZERO.toPlainString();
|
||||
}
|
||||
formulaVar.setContent(formulaVarValue);
|
||||
}
|
||||
return formulaVars;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
package com.engine.salary.entity.salaryacct.bo;
|
||||
|
||||
import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO;
|
||||
import com.engine.salary.entity.formula.ExpressFormula;
|
||||
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
|
||||
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
|
||||
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
||||
import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobAdjustRulePO;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobItemPO;
|
||||
import com.weaver.excel.formula.api.entity.ExpressFormula;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.engine.salary.entity.salaryacct.bo;
|
||||
|
||||
import com.engine.salary.constant.SalaryFormulaFieldConstant;
|
||||
import com.engine.salary.entity.formula.ExpressFormula;
|
||||
import com.engine.salary.entity.formula.po.FormulaVar;
|
||||
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobItemPO;
|
||||
import com.engine.salary.enums.SalaryFormulaReferenceEnum;
|
||||
|
|
@ -9,8 +11,6 @@ import com.engine.salary.util.SalaryEntityUtil;
|
|||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.weaver.excel.formula.api.entity.ExpressFormula;
|
||||
import com.weaver.excel.formula.api.entity.FormulaVar;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.engine.salary.entity.salarysob.bo;
|
||||
|
||||
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
||||
import com.engine.salary.entity.formula.ExpressFormula;
|
||||
import com.engine.salary.entity.salarysob.dto.SalarySobCheckRuleFormDTO;
|
||||
import com.engine.salary.entity.salarysob.dto.SalarySobCheckRuleListDTO;
|
||||
import com.engine.salary.entity.salarysob.param.SalarySobCheckRuleSaveParam;
|
||||
|
|
@ -8,7 +9,6 @@ import com.engine.salary.entity.salarysob.po.SalarySobCheckRulePO;
|
|||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import com.weaver.excel.formula.api.entity.ExpressFormula;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
package com.engine.salary.mapper.formula;
|
||||
|
||||
import com.engine.salary.entity.formula.po.FormulaPO;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface FormulaMapper {
|
||||
|
||||
/**
|
||||
* 查询所有记录
|
||||
*
|
||||
* @return 返回集合,没有返回空List
|
||||
*/
|
||||
List<FormulaPO> listAll();
|
||||
|
||||
/**
|
||||
* 条件查询
|
||||
*
|
||||
* @return 返回集合,没有返回空List
|
||||
*/
|
||||
List<FormulaPO> listSome(FormulaPO formula);
|
||||
|
||||
|
||||
/**
|
||||
* 根据主键查询
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 返回记录,没有返回null
|
||||
*/
|
||||
FormulaPO getById(Long id);
|
||||
|
||||
/**
|
||||
* 新增,忽略null字段
|
||||
*
|
||||
* @param formula 新增的记录
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
int insertIgnoreNull(FormulaPO formula);
|
||||
|
||||
|
||||
/**
|
||||
* 修改,忽略null字段
|
||||
*
|
||||
* @param formula 修改的记录
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
int updateIgnoreNull(FormulaPO formula);
|
||||
|
||||
/**
|
||||
* 删除记录
|
||||
*
|
||||
* @param formula 待删除的记录
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
int delete(FormulaPO formula);
|
||||
|
||||
List<FormulaPO> listByIds(Collection<Long> ids);
|
||||
}
|
||||
|
|
@ -0,0 +1,281 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.engine.salary.mapper.formula.FormulaMapper">
|
||||
<resultMap id="BaseResultMap" type="com.engine.salary.entity.formula.po.FormulaPO">
|
||||
<result column="id" property="id"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="description" property="description"/>
|
||||
<result column="module" property="module"/>
|
||||
<result column="use" property="use"/>
|
||||
<result column="reference_type" property="referenceType"/>
|
||||
<result column="return_type" property="returnType"/>
|
||||
<result column="validate_type" property="validateType"/>
|
||||
<result column="extend_param" property="extendParam"/>
|
||||
<result column="formula" property="formula"/>
|
||||
<result column="creator" property="creator"/>
|
||||
<result column="delete_type" property="deleteType"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 表字段 -->
|
||||
<sql id="baseColumns">
|
||||
t
|
||||
.
|
||||
id
|
||||
, t.name
|
||||
, t.description
|
||||
, t.module
|
||||
, t.use
|
||||
, t.reference_type
|
||||
, t.return_type
|
||||
, t.validate_type
|
||||
, t.extend_param
|
||||
, t.formula
|
||||
, t.creator
|
||||
, t.delete_type
|
||||
, t.create_time
|
||||
, t.update_time
|
||||
</sql>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="listAll" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="baseColumns"/>
|
||||
FROM hrsa_formula t
|
||||
WHERE delete_type = 0
|
||||
</select>
|
||||
|
||||
<!-- 根据主键获取单条记录 -->
|
||||
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
|
||||
SELECT
|
||||
<include refid="baseColumns"/>
|
||||
FROM hrsa_formula t
|
||||
WHERE id = #{id} AND delete_type = 0
|
||||
</select>
|
||||
|
||||
<!-- 条件查询 -->
|
||||
<select id="listSome" resultMap="BaseResultMap" parameterType="com.engine.salary.entity.formula.po.FormulaPO">
|
||||
SELECT
|
||||
<include refid="baseColumns"/>
|
||||
FROM hrsa_formula t
|
||||
WHERE delete_type = 0
|
||||
<if test="id != null">
|
||||
AND id = #{id}
|
||||
</if>
|
||||
<if test="name != null">
|
||||
AND name = #{name}
|
||||
</if>
|
||||
<if test="description != null">
|
||||
AND description = #{description}
|
||||
</if>
|
||||
<if test="module != null">
|
||||
AND module = #{module}
|
||||
</if>
|
||||
<if test="use != null">
|
||||
AND use = #{use}
|
||||
</if>
|
||||
<if test="referenceType != null">
|
||||
AND reference_type = #{referenceType}
|
||||
</if>
|
||||
<if test="returnType != null">
|
||||
AND return_type = #{returnType}
|
||||
</if>
|
||||
<if test="validateType != null">
|
||||
AND validate_type = #{validateType}
|
||||
</if>
|
||||
<if test="extendParam != null">
|
||||
AND extend_param = #{extendParam}
|
||||
</if>
|
||||
<if test="formula != null">
|
||||
AND formula = #{formula}
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
AND creator = #{creator}
|
||||
</if>
|
||||
<if test="deleteType != null">
|
||||
AND delete_type = #{deleteType}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
AND create_time = #{createTime}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
AND update_time = #{updateTime}
|
||||
</if>
|
||||
<if test="ids != null and ids.size()>0">
|
||||
AND id IN
|
||||
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
ORDER BY id DESC
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 插入不为NULL的字段 -->
|
||||
<insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.formula.po.FormulaPO"
|
||||
keyProperty="id" keyColumn="id" useGeneratedKeys="true"
|
||||
>
|
||||
INSERT INTO hrsa_formula
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="name != null">
|
||||
name,
|
||||
</if>
|
||||
<if test="description != null">
|
||||
description,
|
||||
</if>
|
||||
<if test="module != null">
|
||||
module,
|
||||
</if>
|
||||
<if test="use != null">
|
||||
use,
|
||||
</if>
|
||||
<if test="referenceType != null">
|
||||
reference_type,
|
||||
</if>
|
||||
<if test="returnType != null">
|
||||
return_type,
|
||||
</if>
|
||||
<if test="validateType != null">
|
||||
validate_type,
|
||||
</if>
|
||||
<if test="extendParam != null">
|
||||
extend_param,
|
||||
</if>
|
||||
<if test="formula != null">
|
||||
formula,
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
creator,
|
||||
</if>
|
||||
<if test="deleteType != null">
|
||||
delete_type,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
#{name},
|
||||
</if>
|
||||
<if test="description != null">
|
||||
#{description},
|
||||
</if>
|
||||
<if test="module != null">
|
||||
#{module},
|
||||
</if>
|
||||
<if test="use != null">
|
||||
#{use},
|
||||
</if>
|
||||
<if test="referenceType != null">
|
||||
#{referenceType},
|
||||
</if>
|
||||
<if test="returnType != null">
|
||||
#{returnType},
|
||||
</if>
|
||||
<if test="validateType != null">
|
||||
#{validateType},
|
||||
</if>
|
||||
<if test="extendParam != null">
|
||||
#{extendParam},
|
||||
</if>
|
||||
<if test="formula != null">
|
||||
#{formula},
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
#{creator},
|
||||
</if>
|
||||
<if test="deleteType != null">
|
||||
#{deleteType},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
||||
<!-- 更新不为NULL的字段 -->
|
||||
<update id="updateIgnoreNull" parameterType="com.engine.salary.entity.formula.po.FormulaPO">
|
||||
UPDATE hrsa_formula
|
||||
<set>
|
||||
<if test="name != null">
|
||||
name=#{name},
|
||||
</if>
|
||||
<if test="description != null">
|
||||
description=#{description},
|
||||
</if>
|
||||
<if test="module != null">
|
||||
module=#{module},
|
||||
</if>
|
||||
<if test="use != null">
|
||||
use=#{use},
|
||||
</if>
|
||||
<if test="referenceType != null">
|
||||
reference_type=#{referenceType},
|
||||
</if>
|
||||
<if test="returnType != null">
|
||||
return_type=#{returnType},
|
||||
</if>
|
||||
<if test="validateType != null">
|
||||
validate_type=#{validateType},
|
||||
</if>
|
||||
<if test="extendParam != null">
|
||||
extend_param=#{extendParam},
|
||||
</if>
|
||||
<if test="formula != null">
|
||||
formula=#{formula},
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
creator=#{creator},
|
||||
</if>
|
||||
<if test="deleteType != null">
|
||||
delete_type=#{deleteType},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time=#{createTime},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time=#{updateTime},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id} AND delete_type = 0
|
||||
</update>
|
||||
|
||||
|
||||
<!-- 根据主键删除记录 -->
|
||||
<delete id="delete" parameterType="com.engine.salary.entity.formula.po.FormulaPO">
|
||||
UPDATE hrsa_formula
|
||||
SET delete_type=1
|
||||
WHERE id = #{id}
|
||||
AND delete_type = 0
|
||||
</delete>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="listByIds" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="baseColumns"/>
|
||||
FROM hrsa_formula t
|
||||
WHERE delete_type = 0
|
||||
AND id IN
|
||||
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.engine.salary.mapper.formula;
|
||||
|
||||
import com.engine.salary.entity.formula.po.FormulaVar;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface FormulaVarMapper {
|
||||
|
||||
/**
|
||||
* 查询所有记录
|
||||
*
|
||||
* @return 返回集合,没有返回空List
|
||||
*/
|
||||
List<FormulaVar> listAll();
|
||||
|
||||
/**
|
||||
* 条件查询
|
||||
*
|
||||
* @return 返回集合,没有返回空List
|
||||
*/
|
||||
List<FormulaVar> listSome(FormulaVar formulaVar);
|
||||
|
||||
|
||||
/**
|
||||
* 根据主键查询
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 返回记录,没有返回null
|
||||
*/
|
||||
FormulaVar getById(Long id);
|
||||
|
||||
/**
|
||||
* 新增,忽略null字段
|
||||
*
|
||||
* @param formulaVar 新增的记录
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
int insertIgnoreNull(FormulaVar formulaVar);
|
||||
|
||||
/**
|
||||
* 修改,忽略null字段
|
||||
*
|
||||
* @param formulaVar 修改的记录
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
int updateIgnoreNull(FormulaVar formulaVar);
|
||||
|
||||
/**
|
||||
* 删除记录
|
||||
*
|
||||
* @param formulaVar 待删除的记录
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
int delete(FormulaVar formulaVar);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,241 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.engine.salary.mapper.formula.FormulaVarMapper">
|
||||
<resultMap id="BaseResultMap" type="com.engine.salary.entity.formula.po.FormulaVar">
|
||||
<result column="id" property="id"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="formula_id" property="formulaId"/>
|
||||
<result column="field_id" property="fieldId"/>
|
||||
<result column="field_name" property="fieldName"/>
|
||||
<result column="field_type" property="fieldType"/>
|
||||
<result column="source" property="source"/>
|
||||
<result column="order" property="order"/>
|
||||
<result column="creator" property="creator"/>
|
||||
<result column="delete_type" property="deleteType"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 表字段 -->
|
||||
<sql id="baseColumns">
|
||||
t
|
||||
.
|
||||
id
|
||||
, t.name
|
||||
, t.formula_id
|
||||
, t.field_id
|
||||
, t.field_name
|
||||
, t.field_type
|
||||
, t.source
|
||||
, t.order
|
||||
, t.creator
|
||||
, t.delete_type
|
||||
, t.create_time
|
||||
, t.update_time
|
||||
</sql>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="listAll" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="baseColumns"/>
|
||||
FROM hrsa_formula_var t
|
||||
WHERE delete_type = 0
|
||||
</select>
|
||||
|
||||
<!-- 根据主键获取单条记录 -->
|
||||
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
|
||||
SELECT
|
||||
<include refid="baseColumns"/>
|
||||
FROM hrsa_formula_var t
|
||||
WHERE id = #{id} AND delete_type = 0
|
||||
</select>
|
||||
|
||||
<!-- 条件查询 -->
|
||||
<select id="listSome" resultMap="BaseResultMap" parameterType="com.engine.salary.entity.formula.po.FormulaVar">
|
||||
SELECT
|
||||
<include refid="baseColumns"/>
|
||||
FROM hrsa_formula_var t
|
||||
WHERE delete_type = 0
|
||||
<if test="id != null">
|
||||
AND id = #{id}
|
||||
</if>
|
||||
<if test="name != null">
|
||||
AND name = #{name}
|
||||
</if>
|
||||
<if test="formulaId != null">
|
||||
AND formula_id = #{formulaId}
|
||||
</if>
|
||||
<if test="fieldId != null">
|
||||
AND field_id = #{fieldId}
|
||||
</if>
|
||||
<if test="fieldName != null">
|
||||
AND field_name = #{fieldName}
|
||||
</if>
|
||||
<if test="fieldType != null">
|
||||
AND field_type = #{fieldType}
|
||||
</if>
|
||||
<if test="source != null">
|
||||
AND source = #{source}
|
||||
</if>
|
||||
<if test="order != null">
|
||||
AND order = #{order}
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
AND creator = #{creator}
|
||||
</if>
|
||||
<if test="deleteType != null">
|
||||
AND delete_type = #{deleteType}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
AND create_time = #{createTime}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
AND update_time = #{updateTime}
|
||||
</if>
|
||||
<if test="ids != null and ids.size()>0">
|
||||
AND id IN
|
||||
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
ORDER BY id DESC
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 插入不为NULL的字段 -->
|
||||
<insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.formula.po.FormulaVar"
|
||||
keyProperty="id" keyColumn="id" useGeneratedKeys="true"
|
||||
>
|
||||
INSERT INTO hrsa_formula_var
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="name != null">
|
||||
name,
|
||||
</if>
|
||||
<if test="formulaId != null">
|
||||
formula_id,
|
||||
</if>
|
||||
<if test="fieldId != null">
|
||||
field_id,
|
||||
</if>
|
||||
<if test="fieldName != null">
|
||||
field_name,
|
||||
</if>
|
||||
<if test="fieldType != null">
|
||||
field_type,
|
||||
</if>
|
||||
<if test="source != null">
|
||||
source,
|
||||
</if>
|
||||
<if test="order != null">
|
||||
order,
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
creator,
|
||||
</if>
|
||||
<if test="deleteType != null">
|
||||
delete_type,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
#{name},
|
||||
</if>
|
||||
<if test="formulaId != null">
|
||||
#{formulaId},
|
||||
</if>
|
||||
<if test="fieldId != null">
|
||||
#{fieldId},
|
||||
</if>
|
||||
<if test="fieldName != null">
|
||||
#{fieldName},
|
||||
</if>
|
||||
<if test="fieldType != null">
|
||||
#{fieldType},
|
||||
</if>
|
||||
<if test="source != null">
|
||||
#{source},
|
||||
</if>
|
||||
<if test="order != null">
|
||||
#{order},
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
#{creator},
|
||||
</if>
|
||||
<if test="deleteType != null">
|
||||
#{deleteType},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
||||
<!-- 更新不为NULL的字段 -->
|
||||
<update id="updateIgnoreNull" parameterType="com.engine.salary.entity.formula.po.FormulaVar">
|
||||
UPDATE hrsa_formula_var
|
||||
<set>
|
||||
<if test="name != null">
|
||||
name=#{name},
|
||||
</if>
|
||||
<if test="formulaId != null">
|
||||
formula_id=#{formulaId},
|
||||
</if>
|
||||
<if test="fieldId != null">
|
||||
field_id=#{fieldId},
|
||||
</if>
|
||||
<if test="fieldName != null">
|
||||
field_name=#{fieldName},
|
||||
</if>
|
||||
<if test="fieldType != null">
|
||||
field_type=#{fieldType},
|
||||
</if>
|
||||
<if test="source != null">
|
||||
source=#{source},
|
||||
</if>
|
||||
<if test="order != null">
|
||||
order=#{order},
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
creator=#{creator},
|
||||
</if>
|
||||
<if test="deleteType != null">
|
||||
delete_type=#{deleteType},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time=#{createTime},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time=#{updateTime},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id} AND delete_type = 0
|
||||
</update>
|
||||
|
||||
|
||||
<!-- 根据主键删除记录 -->
|
||||
<delete id="delete" parameterType="com.engine.salary.entity.formula.po.FormulaVar">
|
||||
UPDATE hrsa_formula_var
|
||||
SET delete_type=1
|
||||
WHERE id = #{id}
|
||||
AND delete_type = 0
|
||||
</delete>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -1,17 +1,18 @@
|
|||
package com.engine.salary.service;
|
||||
|
||||
import com.weaver.excel.formula.api.entity.ExpressFormula;
|
||||
import com.engine.salary.entity.formula.ExpressFormula;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description: 薪酬管理公式编辑器
|
||||
* @author: xiajun
|
||||
* @modified By: xiajun
|
||||
* @date: Created in 12/7/21 5:38 PM
|
||||
* @version:v1.0
|
||||
*/
|
||||
* 薪酬管理公式编辑器
|
||||
* <p>Copyright: Copyright (c) 2022</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
public interface SalaryFormulaService {
|
||||
|
||||
/**
|
||||
|
|
@ -26,7 +27,6 @@ public interface SalaryFormulaService {
|
|||
* 根据公式id获取公式内容
|
||||
*
|
||||
* @param formulaId
|
||||
* @param tenantKey
|
||||
* @return
|
||||
*/
|
||||
ExpressFormula getExpressFormula(Long formulaId);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import com.engine.salary.entity.datacollection.AddUpSituation;
|
|||
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
||||
import com.engine.salary.entity.datacollection.dto.AttendQuoteDataDTO;
|
||||
import com.engine.salary.entity.datacollection.po.OtherDeductionPO;
|
||||
import com.engine.salary.entity.formula.ExpressFormula;
|
||||
import com.engine.salary.entity.formula.po.FormulaVar;
|
||||
import com.engine.salary.entity.salaryacct.bo.*;
|
||||
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
|
||||
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
|
||||
|
|
@ -22,8 +24,6 @@ import com.engine.salary.enums.SalaryFormulaReferenceEnum;
|
|||
import com.engine.salary.service.*;
|
||||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.weaver.excel.formula.api.entity.ExpressFormula;
|
||||
import com.weaver.excel.formula.api.entity.FormulaVar;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.engine.salary.biz.TaxAgentBiz;
|
|||
import com.engine.salary.common.LocalDateRange;
|
||||
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
||||
import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO;
|
||||
import com.engine.salary.entity.formula.ExpressFormula;
|
||||
import com.engine.salary.entity.salaryacct.bo.SalaryAcctCalculateBO;
|
||||
import com.engine.salary.entity.salaryacct.bo.SalaryAcctCalculatePriorityBO;
|
||||
import com.engine.salary.entity.salaryacct.bo.SalaryAcctResultBO;
|
||||
|
|
@ -39,7 +40,6 @@ import com.engine.salary.util.db.MapperProxyFactory;
|
|||
import com.engine.salary.util.page.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.weaver.excel.formula.api.entity.ExpressFormula;
|
||||
import com.weaver.util.threadPool.ThreadPoolUtil;
|
||||
import com.weaver.util.threadPool.constant.ModulePoolEnum;
|
||||
import com.weaver.util.threadPool.entity.LocalRunnable;
|
||||
|
|
@ -95,8 +95,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
|
|||
return (SalaryEmployeeService) ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
|
||||
}
|
||||
private SalaryFormulaService getSalaryFormulaService(User user) {
|
||||
// return (SalaryFormulaService) ServiceUtil.getService(SalaryFormulaServiceImpl.class, user);
|
||||
return null;
|
||||
return (SalaryFormulaService) ServiceUtil.getService(SalaryFormulaServiceImpl.class, user);
|
||||
}
|
||||
private SalarySobAdjustRuleService getSalarySobAdjustRuleService(User user) {
|
||||
return (SalarySobAdjustRuleService) ServiceUtil.getService(SalarySobAdjustRuleServiceImpl.class, user);
|
||||
|
|
@ -390,7 +389,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
|
|||
// 8、查询公式详情
|
||||
Set<Long> formulaIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getFormulaId);
|
||||
formulaIds.addAll(SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getFormulaId));
|
||||
List<ExpressFormula> expressFormulas = Lists.newArrayList();//getSalaryFormulaService(user).listExpressFormula(formulaIds);
|
||||
List<ExpressFormula> expressFormulas = getSalaryFormulaService(user).listExpressFormula(formulaIds);
|
||||
// 9、计算薪资项目的运算优先级
|
||||
List<List<Long>> salarySobItemsWithPriority = SalaryAcctCalculatePriorityBO.calculatePriority(salarySobItemPOS, salaryItemPOS, expressFormulas);
|
||||
// 10、根据id查询其他合并计税的薪资核算记录
|
||||
|
|
|
|||
|
|
@ -0,0 +1,89 @@
|
|||
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("获取公示详情失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.engine.salary.wrapper;
|
|||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.entity.formula.ExpressFormula;
|
||||
import com.engine.salary.entity.salarysob.bo.SalarySobCheckRuleBO;
|
||||
import com.engine.salary.entity.salarysob.dto.SalarySobCheckRuleFormDTO;
|
||||
import com.engine.salary.entity.salarysob.dto.SalarySobCheckRuleListDTO;
|
||||
|
|
@ -15,7 +16,6 @@ import com.engine.salary.service.SalarySobCheckRuleService;
|
|||
import com.engine.salary.service.impl.SalarySobCheckRuleServiceImpl;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
import com.weaver.excel.formula.api.entity.ExpressFormula;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
|
|||
Loading…
Reference in New Issue