|
@@ -4,27 +4,21 @@ package com.mixsmart.utils;
|
|
|
import cn.hutool.core.date.*;
|
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.jfireel.expression.Expression;
|
|
|
import com.jfireel.expression.node.CalculateNode;
|
|
|
import com.jfireel.expression.node.impl.OperatorResultNode;
|
|
|
import com.jfireel.expression.node.impl.StaticObjectMethodNode;
|
|
|
import com.jfireel.expression.node.impl.VariableNode;
|
|
|
import com.jfireel.expression.token.Token;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
-import org.jsoup.Jsoup;
|
|
|
import org.springblade.core.tool.utils.*;
|
|
|
-import org.springblade.manager.formula.ElementBlock;
|
|
|
-import org.springblade.manager.formula.ItemBlock;
|
|
|
-import org.springblade.manager.formula.KeyMapper;
|
|
|
|
|
|
-import java.io.FileInputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -2432,33 +2426,6 @@ public class CustomFunction {
|
|
|
* @Author yangyj
|
|
|
* @Date 2021.12.31 15:10
|
|
|
**/
|
|
|
- public static Object mergeList(Object l1, Object l2) {
|
|
|
- return _mergeList(l1, l2);
|
|
|
- }
|
|
|
-
|
|
|
- public static Object mergeList(Object l1, Object l2, Object l3) {
|
|
|
- return _mergeList(l1, l2, l3);
|
|
|
- }
|
|
|
-
|
|
|
- public static Object mergeList(Object l1, Object l2, Object l3, Object l4) {
|
|
|
- return _mergeList(l1, l2, l3, l4);
|
|
|
- }
|
|
|
-
|
|
|
- public static Object mergeList(Object l1, Object l2, Object l3, Object l4, Object l5) {
|
|
|
- return _mergeList(l1, l2, l3, l4, l5);
|
|
|
- }
|
|
|
-
|
|
|
- public static Object mergeList(Object l1, Object l2, Object l3, Object l4, Object l5, Object l6) {
|
|
|
- return _mergeList(l1, l2, l3, l4, l5, l6);
|
|
|
- }
|
|
|
-
|
|
|
- public static Object mergeList(Object l1, Object l2, Object l3, Object l4, Object l5, Object l6, Object l7) {
|
|
|
- return _mergeList(l1, l2, l3, l4, l5, l6, l7);
|
|
|
- }
|
|
|
-
|
|
|
- public static Object mergeList(Object l1, Object l2, Object l3, Object l4, Object l5, Object l6, Object l7, Object l8) {
|
|
|
- return _mergeList(l1, l2, l3, l4, l5, l6, l7, l8);
|
|
|
- }
|
|
|
|
|
|
public static Object _mergeList(Object... listArr) {
|
|
|
List<Object> result = new ArrayList<>();
|
|
@@ -2658,19 +2625,29 @@ public class CustomFunction {
|
|
|
* @Author yangyj
|
|
|
* @Date 2022.04.14 11:32
|
|
|
**/
|
|
|
- public static Object sd(Object data, Object scale) {
|
|
|
- if (data != null && StringUtils.isNumber(scale)) {
|
|
|
- data = removeEmpty(data);
|
|
|
- List<Object> datas = obj2List(data);
|
|
|
+ public static Object sd(Object data) {
|
|
|
+ if (data != null ) {
|
|
|
+ List<Object> datas = obj2ListNe(data);
|
|
|
int total = datas.size();
|
|
|
List<String> _datas = datas.stream().map(StringUtils::handleNull).collect(Collectors.toList());
|
|
|
double avgVal = _datas.stream().mapToDouble(Double::parseDouble).average().orElse(0D);
|
|
|
- double result = Math.sqrt(_datas.stream().mapToDouble(Double::parseDouble).map(e -> Math.pow(e - avgVal, 2)).sum() / total);
|
|
|
- return StringUtils.number2String(result, scale);
|
|
|
+ return Math.sqrt(_datas.stream().mapToDouble(Double::parseDouble).map(e -> Math.pow(e - avgVal, 2)).sum() / total);
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ /*递进求和*/
|
|
|
+ public static Object stepSum(List<Object> list){
|
|
|
+ if(list!=null&&list.size()>0){
|
|
|
+ AtomicReference<Double> acc = new AtomicReference<>((double) 0);
|
|
|
+ return list.stream().map(d-> StringUtils.isNumber(d)?acc.updateAndGet(s->s+Func.toDouble(d)):StringPool.EMPTY).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ return StringPool.EMPTY;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|