|
@@ -1,8 +1,6 @@
|
|
|
package services
|
|
|
|
|
|
import (
|
|
|
- "github.com/yidane/formula"
|
|
|
- "hongze/hongze_edb_lib/models"
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
@@ -29,23 +27,3 @@ func CheckFormula(formula string) map[string]string {
|
|
|
}
|
|
|
return byteMap
|
|
|
}
|
|
|
-
|
|
|
-// CheckFormula2 校验公式是否正常(比如说除法的分母不能为0之类的,实际上就是用预设的字段数据做一次计算)
|
|
|
-func CheckFormula2(edbInfoArr []*models.EdbInfo, formulaMap map[string]string, formulaStr string, edbInfoIdBytes []string) (ok bool, err error) {
|
|
|
- valArr := make(map[int]float64)
|
|
|
- for _, v := range edbInfoArr {
|
|
|
- valArr[v.EdbInfoId] = 100
|
|
|
- }
|
|
|
- formulaStr = strings.ToUpper(formulaStr)
|
|
|
- formulaFormStr := models.ReplaceFormula(edbInfoArr, valArr, formulaMap, formulaStr, edbInfoIdBytes)
|
|
|
- if formulaFormStr == "" {
|
|
|
- return
|
|
|
- }
|
|
|
- expression := formula.NewExpression(formulaFormStr)
|
|
|
- _, err = expression.Evaluate()
|
|
|
- if err != nil {
|
|
|
- } else {
|
|
|
- ok = true
|
|
|
- }
|
|
|
- return
|
|
|
-}
|