|
|
@@ -17,6 +17,7 @@ import org.springblade.core.tool.utils.*;
|
|
|
import org.springblade.manager.bean.SpringContextHolder;
|
|
|
import org.springblade.manager.dto.ParamElements;
|
|
|
import org.springblade.manager.entity.WbsTreeContract;
|
|
|
+import org.springblade.manager.utils.NumberStringSubtraction;
|
|
|
import org.springblade.manager.utils.RandomNumberHolder;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
|
|
@@ -2274,6 +2275,7 @@ public class CustomFunction {
|
|
|
List<Object> list = obj2List(obj);
|
|
|
return list.parallelStream().filter(StringUtils::isNotEmpty).collect(Collectors.toList());
|
|
|
}
|
|
|
+ //obj转数组,不做任何额外的处理
|
|
|
public static List<Object> obj3ListNe(Object obj) {
|
|
|
List<Object> list = obj3List(obj);
|
|
|
return list.parallelStream().filter(StringUtils::isNotEmpty).collect(Collectors.toList());
|
|
|
@@ -3205,7 +3207,7 @@ public class CustomFunction {
|
|
|
* @param surveyDepth 测区深度
|
|
|
* @param Pumping 是否泵送 1-是,2-否
|
|
|
*/
|
|
|
- public static Object concreteStrength(Object data, Object angle, Object pouringSurface, Object type, Object surveyDepth, Object Pumping){
|
|
|
+ public static Object concreteStrength(Object data, Object angle, Object pouringSurface, Object type, Object surveyDepth, Object Pumping) {
|
|
|
List<Object> datas = obj2ListNe(data);
|
|
|
List<Object> data1 = obj2ListNe(angle);
|
|
|
List<Object> data2 = obj2ListNe(pouringSurface);
|
|
|
@@ -3222,41 +3224,43 @@ public class CustomFunction {
|
|
|
List<Double> list = datas.stream().filter(StringUtils::isNumber).map(m -> Double.valueOf(m.toString())).collect(Collectors.toList());
|
|
|
list = removeThreeMinAndMaxEfficient(list);
|
|
|
//计算平均值
|
|
|
- double asDouble = list.stream().filter(StringUtils::isNumber).map(StringUtils::handleNull).mapToDouble(Double::parseDouble).average().orElse(0.0);
|
|
|
+ BigDecimal asDouble = BigDecimal.valueOf(list.stream().filter(StringUtils::isNumber).map(StringUtils::handleNull).mapToDouble(Double::parseDouble).average().orElse(0.0));
|
|
|
if (StringUtils.isNotEmpty(angle) && StringUtils.isNotEmpty(pouringSurface)) {
|
|
|
//角度 根据平均值从数据库中查询对应的映射值
|
|
|
List<Map<String, Object>> angleList = jdbcTemplateStatic.queryForList("select data_value from coordinate_angle where r_value = " + asDouble + " and h_value = " + angle);
|
|
|
if (CollectionUtil.isNotEmpty(angleList)) {
|
|
|
Map<String, Object> stringObjectMap = angleList.get(0);
|
|
|
- asDouble += Double.parseDouble(stringObjectMap.get("data_value").toString());
|
|
|
+ asDouble = asDouble.add(new BigDecimal(stringObjectMap.get("data_value").toString()));
|
|
|
}
|
|
|
//角度 根据平均值从数据库中查询对应的映射值
|
|
|
List<Map<String, Object>> pouringSurfaceList = jdbcTemplateStatic.queryForList("select data_value from coordinate_pouring_urface where r_value = " + asDouble + " and h_value = '" + pouringSurface + "'");
|
|
|
if (CollectionUtil.isNotEmpty(pouringSurfaceList)) {
|
|
|
Map<String, Object> stringObjectMap = pouringSurfaceList.get(0);
|
|
|
- asDouble += Double.parseDouble(stringObjectMap.get("data_value").toString());
|
|
|
+ asDouble = asDouble.add(new BigDecimal(stringObjectMap.get("data_value").toString()));
|
|
|
}
|
|
|
|
|
|
//最终值 R H
|
|
|
- double r = asDouble;
|
|
|
+ double r = asDouble.doubleValue();
|
|
|
double h = 0;
|
|
|
|
|
|
//测区深度 第一种只取第一条数据
|
|
|
- if(type == null || "1".equals(type.toString())){
|
|
|
+ if (type == null || "1".equals(type.toString())) {
|
|
|
String surveyDepthStr;
|
|
|
- if(surveyDepth instanceof List){
|
|
|
+ if (surveyDepth instanceof List) {
|
|
|
List<Object> surveyDepthList = obj3ListNe(surveyDepth);
|
|
|
surveyDepthStr = surveyDepthList.get(0).toString();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
surveyDepthStr = surveyDepth.toString();
|
|
|
}
|
|
|
//分割字符串
|
|
|
String[] split = surveyDepthStr.split(surveyDepthStr.contains(",") ? "," : "、");
|
|
|
//计算平均值
|
|
|
- h = Arrays.stream(split).filter(StringUtils::isNumber).map(StringUtils::handleNull).mapToDouble(Double::parseDouble).average().orElse(0.0);
|
|
|
+ h = Arrays.stream(split).filter(StringUtils::isNumber).map(StringUtils::handleNull).map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(split.length), 10, RoundingMode.HALF_UP).doubleValue();
|
|
|
+ h = h * 2;
|
|
|
//进行0.5修正
|
|
|
- h = roundHalfEven(new BigDecimal(h).setScale(1, RoundingMode.HALF_UP).doubleValue(),1);
|
|
|
- }else{
|
|
|
+ h = roundHalfEven(new BigDecimal(h).setScale(1, RoundingMode.HALF_UP).doubleValue(), 1);
|
|
|
+ h = h / 2;
|
|
|
+ } else {
|
|
|
List<Object> surveyDepthList = obj3ListNe(surveyDepth);
|
|
|
List<Double> doubleArrList = new ArrayList<>();
|
|
|
surveyDepthList.forEach(f -> {
|
|
|
@@ -3264,13 +3268,18 @@ public class CustomFunction {
|
|
|
//分割字符串
|
|
|
String[] split = string.split(string.contains(",") ? "," : "、");
|
|
|
//计算平均值
|
|
|
- double avg = Arrays.stream(split).filter(StringUtils::isNumber).map(StringUtils::handleNull).mapToDouble(Double::parseDouble).average().orElse(0.0);
|
|
|
- doubleArrList.add(roundHalfEven(new BigDecimal(avg).setScale(1, RoundingMode.HALF_UP).doubleValue(),1));
|
|
|
+ double avg = Arrays.stream(split).filter(StringUtils::isNumber).map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(split.length), 10, RoundingMode.HALF_UP).doubleValue();
|
|
|
+ avg = avg * 2;
|
|
|
+ avg = roundHalfEven(new BigDecimal(avg).setScale(1, RoundingMode.HALF_UP).doubleValue(), 1);
|
|
|
+ avg = avg / 2;
|
|
|
+ doubleArrList.add(avg);
|
|
|
});
|
|
|
//结果再计算平均值
|
|
|
h = doubleArrList.stream().mapToDouble(Double::doubleValue).average().orElse(0.0);
|
|
|
- //在进行修正
|
|
|
- h = roundHalfEven(new BigDecimal(h).setScale(1, RoundingMode.HALF_UP).doubleValue(),1);
|
|
|
+ h = h * 2;
|
|
|
+ //进行0.5修正
|
|
|
+ h = roundHalfEven(new BigDecimal(h).setScale(1, RoundingMode.HALF_UP).doubleValue(), 1);
|
|
|
+ h = h / 2;
|
|
|
}
|
|
|
|
|
|
//是否泵送
|
|
|
@@ -3342,4 +3351,27 @@ public class CustomFunction {
|
|
|
return number;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public static boolean isEven(BigDecimal number) {
|
|
|
+ // 检查是否为整数
|
|
|
+ if (number.scale() > 0 && number.stripTrailingZeros().scale() > 0) {
|
|
|
+ throw new IllegalArgumentException("只能判断整数的奇偶性");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 使用 remainder() 方法计算除以2的余数
|
|
|
+ BigDecimal remainder = number.remainder(BigDecimal.valueOf(2));
|
|
|
+ return remainder.compareTo(BigDecimal.ZERO) == 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 字符串拆分计算
|
|
|
+ * @param s
|
|
|
+ * @param s1
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static List<Integer> strSplitDiff(Object s,Object s1){
|
|
|
+ List<Object> datas = obj3ListNe(s);
|
|
|
+ List<Object> data1 = obj3ListNe(s1);
|
|
|
+ return NumberStringSubtraction.calculateDifference(datas.get(0).toString(), data1.get(0).toString());
|
|
|
+ }
|
|
|
}
|