|
|
@@ -11,6 +11,7 @@ import com.jfireel.expression.node.impl.VariableNode;
|
|
|
import com.jfireel.expression.token.Token;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
import org.springblade.common.utils.BaseUtils;
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.redis.cache.BladeRedis;
|
|
|
import org.springblade.core.tool.utils.*;
|
|
|
import org.springblade.manager.dto.ParamElements;
|
|
|
@@ -23,6 +24,7 @@ import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneOffset;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
@@ -1187,7 +1189,7 @@ public class CustomFunction {
|
|
|
}else{
|
|
|
localDateTime= LocalDateTime.now();
|
|
|
}
|
|
|
- return localDateTime.atZone(java.time.ZoneOffset.UTC)
|
|
|
+ return localDateTime.atZone(ZoneOffset.UTC)
|
|
|
.toInstant()
|
|
|
.toEpochMilli();
|
|
|
}
|
|
|
@@ -3062,7 +3064,37 @@ public class CustomFunction {
|
|
|
toDay(list).forEach(System.out::println);
|
|
|
}*/
|
|
|
|
|
|
+ /**
|
|
|
+ * 特征值计算
|
|
|
+ */
|
|
|
+ public static Object eigenvalue(Object data){
|
|
|
|
|
|
+ //默认只有10组数据
|
|
|
+ if (data != null ) {
|
|
|
+ List<Object> datas = obj2ListNe(data);
|
|
|
+ datas = datas.size() > 10 ? datas.subList(0, datas.size()/2) : datas;
|
|
|
+ int total = datas.size();
|
|
|
+ //换算系数
|
|
|
+ double conversionFactor;
|
|
|
+ //获取换算系数
|
|
|
+ if(total >= 10 && total <= 15){
|
|
|
+ conversionFactor = 1.695;
|
|
|
+ }else if(total >= 16 && total <= 24){
|
|
|
+ conversionFactor = 1.645;
|
|
|
+ }else if(total>=25){
|
|
|
+ conversionFactor = 1.595;
|
|
|
+ }else{
|
|
|
+ throw new ServiceException("数据组数小于10");
|
|
|
+ }
|
|
|
+ List<String> _datas = datas.stream().map(StringUtils::handleNull).collect(Collectors.toList());
|
|
|
+ //获取平均值
|
|
|
+ double avgVal = _datas.stream().mapToDouble(Double::parseDouble).average().orElse(0D);
|
|
|
+ //获取标准差
|
|
|
+ double sqrt = Math.sqrt(_datas.stream().mapToDouble(Double::parseDouble).map(e -> Math.pow(e - avgVal, 2)).sum() / (total-1));
|
|
|
+ return avgVal - (conversionFactor * sqrt);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|