默认员工字段不可删除
This commit is contained in:
parent
2d68d686ca
commit
c899d370a9
|
|
@ -54,6 +54,11 @@ public class ExpressFormula {
|
|||
*/
|
||||
private String formulaRunScript;
|
||||
|
||||
/**
|
||||
* sql返回的列值
|
||||
*/
|
||||
private String sqlReturnKey;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ public class SalaryFormulaSaveParam {
|
|||
private String useFor;
|
||||
/**
|
||||
* 引用类型
|
||||
* @see com.engine.salary.enums.salaryformula.ReferenceTypeEnum
|
||||
*/
|
||||
private String referenceType;
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
package com.engine.salary.enums.salaryformula;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
public enum ReferenceTypeEnum {
|
||||
FORMULA("formula", "公式"),
|
||||
SQL("sql", "SQL");
|
||||
|
||||
private String value;
|
||||
|
||||
private String label;
|
||||
|
||||
ReferenceTypeEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
public static ReferenceTypeEnum parseByValue(String value) {
|
||||
return Arrays.stream(ReferenceTypeEnum.values()).filter(typeEnum -> Objects.equals(typeEnum.getValue(), value)).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.engine.salary.enums.salaryformula;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
public enum ReturnTypeEnum {
|
||||
NUMBER("number", "数值"),
|
||||
STRING("string", "字符");
|
||||
|
||||
private String value;
|
||||
|
||||
private String label;
|
||||
|
||||
ReturnTypeEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
public static ReturnTypeEnum parseByValue(String value) {
|
||||
return Arrays.stream(ReturnTypeEnum.values()).filter(typeEnum -> Objects.equals(typeEnum.getValue(), value)).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.engine.salary.enums.salaryformula;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
public enum ValidateTypeEnum {
|
||||
NUMBER("number", "数值"),
|
||||
STRING("string", "字符");
|
||||
|
||||
private String value;
|
||||
|
||||
private String label;
|
||||
|
||||
ValidateTypeEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
public static ValidateTypeEnum parseByValue(String value) {
|
||||
return Arrays.stream(ValidateTypeEnum.values()).filter(typeEnum -> Objects.equals(typeEnum.getValue(), value)).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
|
|
@ -231,7 +231,7 @@
|
|||
|
||||
<insert id="batchInsert">
|
||||
INSERT INTO
|
||||
hrsa_salary_sob_emp_field(salary_sob_id, field_code, sorted_index, creator, create_time, update_time,
|
||||
hrsa_salary_sob_emp_field(salary_sob_id, field_code, sorted_index,can_delete, creator, create_time, update_time,
|
||||
delete_type, tenant_key)
|
||||
VALUES
|
||||
<foreach collection="collection" item="item" separator=",">
|
||||
|
|
@ -239,6 +239,7 @@
|
|||
#{item.salarySobId},
|
||||
#{item.fieldCode},
|
||||
#{item.sortedIndex},
|
||||
#{item.canDelete},
|
||||
#{item.creator},
|
||||
#{item.createTime},
|
||||
#{item.updateTime},
|
||||
|
|
@ -249,7 +250,7 @@
|
|||
</insert>
|
||||
<insert id="batchInsert" databaseId="oracle">
|
||||
INSERT INTO
|
||||
hrsa_salary_sob_emp_field( salary_sob_id, field_code, sorted_index, creator, create_time, update_time,
|
||||
hrsa_salary_sob_emp_field( salary_sob_id, field_code, sorted_index,can_delete, creator, create_time, update_time,
|
||||
delete_type, tenant_key)
|
||||
|
||||
<foreach collection="collection" item="item" separator="union all">
|
||||
|
|
@ -257,6 +258,7 @@
|
|||
#{item.salarySobId},
|
||||
#{item.fieldCode},
|
||||
#{item.sortedIndex},
|
||||
#{item.canDelete},
|
||||
#{item.creator},
|
||||
#{item.createTime},
|
||||
#{item.updateTime},
|
||||
|
|
@ -268,13 +270,14 @@
|
|||
<insert id="batchInsert" databaseId="sqlserver">
|
||||
<foreach collection="collection" item="item" separator=";">
|
||||
INSERT INTO
|
||||
hrsa_salary_sob_emp_field(salary_sob_id, field_code, sorted_index, creator, create_time, update_time,
|
||||
hrsa_salary_sob_emp_field(salary_sob_id, field_code, sorted_index,can_delete, creator, create_time, update_time,
|
||||
delete_type, tenant_key)
|
||||
VALUES
|
||||
(
|
||||
#{item.salarySobId},
|
||||
#{item.fieldCode},
|
||||
#{item.sortedIndex},
|
||||
#{item.canDelete},
|
||||
#{item.creator},
|
||||
#{item.createTime},
|
||||
#{item.updateTime},
|
||||
|
|
|
|||
|
|
@ -4,11 +4,13 @@ import com.engine.core.impl.Service;
|
|||
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
||||
import com.engine.salary.entity.salaryformula.ExpressFormula;
|
||||
import com.engine.salary.entity.salaryformula.po.FormulaVar;
|
||||
import com.engine.salary.enums.salaryformula.ReferenceTypeEnum;
|
||||
import com.engine.salary.formlua.entity.parameter.DataType;
|
||||
import com.engine.salary.service.FormulaRunService;
|
||||
import com.ql.util.express.DefaultContext;
|
||||
import com.ql.util.express.ExpressRunner;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
|
@ -17,13 +19,23 @@ import java.util.List;
|
|||
public class FormulaRunServiceImpl extends Service implements FormulaRunService {
|
||||
|
||||
private static ExpressRunner runner;
|
||||
|
||||
static {
|
||||
runner = new ExpressRunner(true,false);
|
||||
runner = new ExpressRunner(true, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object run(ExpressFormula expressFormula, List<FormulaVar> formulaVars, DataCollectionEmployee simpleEmployee) {
|
||||
|
||||
if (ReferenceTypeEnum.parseByValue(expressFormula.getReferenceType()) == ReferenceTypeEnum.FORMULA) {
|
||||
return runFormula(expressFormula, formulaVars);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Object runFormula(ExpressFormula expressFormula, List<FormulaVar> formulaVars) {
|
||||
DefaultContext<String, Object> context = new DefaultContext<String, Object>();
|
||||
formulaVars.forEach(v -> {
|
||||
if (DataType.NUMBER.equals(v.getFieldType())) {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,10 @@ public class RemoteExcelServiceImpl extends Service implements RemoteExcelServic
|
|||
private static final Logger log = LoggerFactory.getLogger(RemoteExcelServiceImpl.class);
|
||||
|
||||
|
||||
// private SIAccountService siAccountService;
|
||||
private SIAccountService getSIAccountService(User user) {
|
||||
return (SIAccountService) ServiceUtil.getService(SIAccountServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
private AttendQuoteFieldMapper getAttendQuoteFieldMapper() {
|
||||
return MapperProxyFactory.getProxy(AttendQuoteFieldMapper.class);
|
||||
|
|
@ -277,19 +280,17 @@ public class RemoteExcelServiceImpl extends Service implements RemoteExcelServic
|
|||
}
|
||||
|
||||
private List<FormulaVar> welfare2FormulaVar(SalaryFormulaReferenceEnum referenceEnum) {
|
||||
Map<String, String> welfareColumns = null;//siAccountService.welfareColumns();
|
||||
Map<String, String> welfareColumns = getSIAccountService(user).welfareColumns();
|
||||
if (MapUtils.isEmpty(welfareColumns)) {
|
||||
return null;
|
||||
}
|
||||
List<FormulaVar> formulaVars = Lists.newArrayListWithExpectedSize(welfareColumns.size());
|
||||
welfareColumns.forEach((k, v) -> {
|
||||
FormulaVar formulaVar = new FormulaVar();
|
||||
// formulaVar.setFieldId(referenceEnum.getValue() + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + v);
|
||||
// formulaVar.setModule(SalaryFormulaFieldConstant.MODULE);
|
||||
// formulaVar.setTitle(k);
|
||||
// formulaVar.setFormId("" + referenceEnum.getValue());
|
||||
// formulaVar.setDataType(DataType.NUMBER);
|
||||
// formulaVar.setProperKey(DataType.NUMBER);
|
||||
formulaVar.setFieldId(referenceEnum.getValue() + SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR + v);
|
||||
formulaVar.setName(k);
|
||||
formulaVar.setSource("" + referenceEnum.getValue());
|
||||
formulaVar.setFieldType(DataType.NUMBER);
|
||||
formulaVars.add(formulaVar);
|
||||
});
|
||||
return formulaVars;
|
||||
|
|
|
|||
|
|
@ -79,8 +79,9 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
|
|||
return (OtherDeductionService) ServiceUtil.getService(OtherDeductionServiceImpl.class, user);
|
||||
}
|
||||
|
||||
// private SIAccountService siAccountService;
|
||||
|
||||
private SIAccountService getSIAccountService(User user) {
|
||||
return (SIAccountService) ServiceUtil.getService(SIAccountServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private AttendQuoteDataService getAttendQuoteDataService(User user) {
|
||||
return (AttendQuoteDataService) ServiceUtil.getService(AttendQuoteDataServiceImpl.class, user);
|
||||
|
|
@ -124,8 +125,8 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
|
|||
List<AddUpDeduction> addUpDeductionPOS = getAddUpDeductionService(user).getAddUpDeductionList(salarySobCycleDTO.getTaxCycle(), employeeIds);
|
||||
// 5、查询其他免税扣除
|
||||
List<OtherDeductionPO> otherDeductionPOS = getOtherDeductionService(user).getOtherDeductionList(salarySobCycleDTO.getTaxCycle(), employeeIds);
|
||||
//todo 6、查询社保福利
|
||||
List<Map<String, Object>> welfareData = Lists.newArrayList();//siAccountService.welfareData(salarySobCycleDTO.getSocialSecurityCycle().toString(), employeeIds);
|
||||
//6、查询社保福利
|
||||
List<Map<String, Object>> welfareData = getSIAccountService(user).welfareData(salarySobCycleDTO.getSocialSecurityCycle().toString(), employeeIds);
|
||||
// 7、查询考勤数据
|
||||
List<AttendQuoteDataDTO> attendQuoteDataDTOS = getAttendQuoteDataService(user).getAttendQuoteData(salarySobCycleDTO.getSalaryMonth(), salarySobCycleDTO.getSalarySobId(), employeeIds);
|
||||
// 8、查询薪资核算人员的薪资核算结果
|
||||
|
|
@ -268,41 +269,36 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
|
|||
}
|
||||
|
||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
private String runExpressSQL(ExpressFormula expressFormula, Map<String, String> formulaVarValueMap, DataCollectionEmployee simpleEmployee) {
|
||||
|
||||
// 给公式中的变量填入值
|
||||
List<FormulaVar> formulaVars = ExpressFormulaBO.buildFormulaVar4Accounting(expressFormula, formulaVarValueMap);
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
//select * from uf_test where epmid = {emp.id}
|
||||
String formulaRunScript = expressFormula.getFormulaRunScript();
|
||||
|
||||
|
||||
String extendParam = expressFormula.getExtendParam();
|
||||
String sqlReturnKey ="";
|
||||
String sqlReturnKey = "";
|
||||
try {
|
||||
JsonNode jsonNode = objectMapper.readTree(extendParam);
|
||||
JsonNode sqlReturnKeyNode = jsonNode.get("sqlReturnKey");
|
||||
if (sqlReturnKeyNode != null){
|
||||
if (sqlReturnKeyNode != null) {
|
||||
sqlReturnKey = sqlReturnKeyNode.asText();
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
// 给公式中的变量填入值
|
||||
List<FormulaVar> formulaVars = ExpressFormulaBO.buildFormulaVar4Accounting(expressFormula, formulaVarValueMap);
|
||||
String sql = formulaRunScript;
|
||||
for (int i = 0; i < formulaVars.size(); i++) {
|
||||
FormulaVar formulaVar = formulaVars.get(i);
|
||||
sql = formulaRunScript.replaceAll(formulaVar.getFieldId(), "'"+formulaVar.getContent()+"'");
|
||||
sql = formulaRunScript.replaceAll(formulaVar.getFieldId(), "'" + formulaVar.getContent() + "'");
|
||||
}
|
||||
|
||||
|
||||
rs.execute(sql);
|
||||
rs.next();
|
||||
String string = rs.getString(sqlReturnKey);
|
||||
return string;
|
||||
// Object run = getFormulaRunService(user).run(expressFormula, formulaVars, simpleEmployee);
|
||||
// return run.toString();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
package com.engine.salary.service.impl;
|
||||
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.constant.SalaryFormulaFieldConstant;
|
||||
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.enums.salaryformula.ReferenceTypeEnum;
|
||||
import com.engine.salary.enums.salaryformula.ReturnTypeEnum;
|
||||
import com.engine.salary.enums.salaryformula.ValidateTypeEnum;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import com.engine.salary.mapper.formula.FormulaMapper;
|
||||
import com.engine.salary.mapper.formula.FormulaVarMapper;
|
||||
|
|
@ -21,8 +23,6 @@ import org.apache.commons.lang3.math.NumberUtils;
|
|||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -95,18 +95,28 @@ public class SalaryFormulaServiceImpl extends Service implements SalaryFormulaSe
|
|||
@Override
|
||||
public FormulaPO save(SalaryFormulaSaveParam param) {
|
||||
ValidUtil.doValidator(param);
|
||||
|
||||
if ("sql".equals(param.getReferenceType())) {
|
||||
param.setFormula(param.getFormula().replaceAll("SELECT", "select"));
|
||||
if (ReferenceTypeEnum.parseByValue(param.getReferenceType()) == null) {
|
||||
throw new SalaryRunTimeException("引用类型异常");
|
||||
}
|
||||
|
||||
//公式参数与公式内容是否相符
|
||||
if (ReturnTypeEnum.parseByValue(param.getReturnType()) == null) {
|
||||
throw new SalaryRunTimeException("返回类型异常");
|
||||
}
|
||||
if (ValidateTypeEnum.parseByValue(param.getValidateType()) == null) {
|
||||
throw new SalaryRunTimeException("校验类型异常");
|
||||
}
|
||||
//todo 公式参数与公式内容是否相符
|
||||
// String paramFormula = param.getFormula();
|
||||
// int end = matchStr(paramFormula);
|
||||
// if(!Objects.equals(end,param.getParameters())){
|
||||
// throw new SalaryRunTimeException("参数不匹配");
|
||||
// }
|
||||
|
||||
|
||||
if (ReferenceTypeEnum.parseByValue(param.getReferenceType()) == ReferenceTypeEnum.SQL) {
|
||||
//将select因XSS过滤造成的异常字符转换回来
|
||||
param.setFormula(param.getFormula().replaceAll("select", "select"));
|
||||
}
|
||||
|
||||
FormulaPO formulaPO = new FormulaPO();
|
||||
String formula = param.getFormula();
|
||||
formulaPO.setId(IdGenerator.generate());
|
||||
|
|
@ -151,15 +161,6 @@ public class SalaryFormulaServiceImpl extends Service implements SalaryFormulaSe
|
|||
return formulaPO;
|
||||
}
|
||||
|
||||
private static int matchStr(String str) {
|
||||
Pattern salaryPattern = SalaryFormulaFieldConstant.SALARY_PATTERN;
|
||||
Matcher m = salaryPattern.matcher(str);
|
||||
int count = 0;
|
||||
while (m.find()) {
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FormulaPO update(SalaryFormulaSaveParam param) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue