|
@@ -82,6 +82,8 @@ import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.BigInteger;
|
|
|
+import java.math.MathContext;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.function.Function;
|
|
@@ -1676,7 +1678,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
//负值+0/1 正值-0/1
|
|
|
String difference = "差值";
|
|
|
//差值X + 差值Y 的开平方
|
|
|
- String deviation = "偏差";
|
|
|
+ String deviation = "偏位";
|
|
|
//指定表单和指定字段
|
|
|
Map<String, Map<String, String>> dataMaps = new HashMap<>();
|
|
|
|
|
@@ -1914,7 +1916,83 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
values.set(keys.indexOf(actualElevationNew), String.join("☆",list));
|
|
|
}else if(planePositionTableName.equals(initTabName)){
|
|
|
//CL10平面位置检测记录表(监理)
|
|
|
+ //差值
|
|
|
+ String differenceNewX = stringStringMap.get(difference + "X");
|
|
|
+ HashMap<Integer, BigDecimal> differenceNewXMap = new HashMap<>();
|
|
|
+
|
|
|
+ String differenceNewY = stringStringMap.get(difference + "Y");
|
|
|
+ HashMap<Integer, BigDecimal> differenceNewYMap = new HashMap<>();
|
|
|
+
|
|
|
+
|
|
|
+ String deviationNew = stringStringMap.get(deviation);
|
|
|
+ //记录数量
|
|
|
+ Integer rowMin = null;
|
|
|
+ Integer rowMax = null;
|
|
|
+ for (int i = 0; i < keys.size(); i++) {
|
|
|
+ if(!Objects.equals(keys.get(i),differenceNewX) && !Objects.equals(keys.get(i),differenceNewY)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ String value = values.get(i);
|
|
|
+ //拆分数据
|
|
|
+ String[] split1 = value.split("☆");
|
|
|
+
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+
|
|
|
+ for (String s : split1) {
|
|
|
+ String[] split2 = s.split("_\\^_");
|
|
|
+ int rowNum = Integer.parseInt(split2[1].split("_")[0]);
|
|
|
+ //获取最大行数
|
|
|
+ if(rowMax == null){
|
|
|
+ rowMax = rowNum;
|
|
|
+ }else if(rowMax < rowNum){
|
|
|
+ rowMax = rowNum;
|
|
|
+ }
|
|
|
+ //获取最小行数
|
|
|
+ if(rowMin == null){
|
|
|
+ rowMin = rowNum;
|
|
|
+ }else if(rowMin > rowNum){
|
|
|
+ rowMin = rowNum;
|
|
|
+ }
|
|
|
+ Integer v = Integer.parseInt(split2[0]);
|
|
|
+ //随机+ - 0/1
|
|
|
+ Random random = new Random();
|
|
|
+ int adjustment = random.nextInt(2);
|
|
|
+ if(v > 0){
|
|
|
+ v = v - adjustment;
|
|
|
+ }else{
|
|
|
+ v = v + adjustment;
|
|
|
+ }
|
|
|
+ if (keys.get(i).equals(differenceNewX)) {
|
|
|
+ //偏差X
|
|
|
+ differenceNewXMap.put(rowNum, new BigDecimal(split2[0]));
|
|
|
+ } else if (keys.get(i).equals(differenceNewY)){
|
|
|
+ //偏差Y
|
|
|
+ differenceNewYMap.put(rowNum, BigDecimal.valueOf(v));
|
|
|
+ }
|
|
|
+ list.add(v + "_^_"+ split2[1]);
|
|
|
+ }
|
|
|
+ values.set(i, String.join("☆",list));
|
|
|
+ }
|
|
|
+ if(rowMin==null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ //按照最小行数来计算
|
|
|
+ for (int i = rowMin; i <= rowMax; i++) {
|
|
|
+ BigDecimal x = differenceNewXMap.get(i);
|
|
|
+ BigDecimal y = differenceNewYMap.get(i);
|
|
|
|
|
|
+ if(x == null || y == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ BigDecimal sqrt = sqrt(x.multiply(x).add(y.multiply(y)), 0);
|
|
|
+
|
|
|
+ //第5列,索引为4
|
|
|
+ list.add(sqrt.intValue() + "_^_"+ i + "_8");
|
|
|
+ }
|
|
|
+ //设置实际标高的值
|
|
|
+ values.set(keys.indexOf(deviationNew), String.join("☆",list));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -2024,6 +2102,32 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 牛顿迭代法实现开平方
|
|
|
+ public BigDecimal sqrt(BigDecimal value, int precision) {
|
|
|
+ // 检查负数输入
|
|
|
+ if (value.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ throw new ArithmeticException("不能对负数开平方");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 精度设置(保留小数位 + 额外2位保证精度)
|
|
|
+ MathContext mc = new MathContext(precision + 2, RoundingMode.HALF_EVEN);
|
|
|
+
|
|
|
+ // 初始值 = value / 2
|
|
|
+ BigDecimal guess = value.divide(BigDecimal.valueOf(2), mc);
|
|
|
+ BigDecimal lastGuess;
|
|
|
+
|
|
|
+ // 牛顿迭代公式:xₙ₊₁ = (xₙ + value/xₙ)/2
|
|
|
+ do {
|
|
|
+ lastGuess = guess;
|
|
|
+ guess = value.divide(guess, mc).add(guess)
|
|
|
+ .divide(BigDecimal.valueOf(2), mc);
|
|
|
+ } while (guess.subtract(lastGuess).abs().compareTo(
|
|
|
+ BigDecimal.valueOf(1, precision + 1)) > 0); // 精度控制
|
|
|
+
|
|
|
+ // 返回最终结果(精确到指定小数位)
|
|
|
+ return guess.setScale(precision, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 构造数据
|
|
|
*
|