Procházet zdrojové kódy

公式相关:转点优化,倒尺判断

yangyj před 2 roky
rodič
revize
a909905387

+ 26 - 9
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/ITurnPointCalculator.java

@@ -355,28 +355,45 @@ public interface ITurnPointCalculator {
     }
     static void tpHandlerCe(List<TurnPoint> result,LevelInfo info ,TurnPoint tp){
         if(!finalizeCe(tp)) {
+            /*负前视,用于判断是否使用倒尺计算*/
+            boolean negative = tp.isNegativeQ();
             if (StringUtils.isNotEmpty(tp.getSc())) {
                 if (StringUtils.isNotEmpty(tp.getSj())) {
                     tp.setDx(tp.getSc0L() - tp.getSj0L());
                 }
-                tp.setQ(info.getSightHeight() - tp.getSc0L());
+                if (StringUtils.isEmpty(tp.getQ())) {
+                    tp.setQ(info.getSightHeight() - tp.getSc0L());
+                }
             } else if (StringUtils.isNotEmpty(tp.getSj())) {
-                String dx = rangeList(1, 0, info.getDx(), 1, 0, 1).get(0).toString();
-                tp.setDx(dx);
-                tp.setSc(tp.getSj0L() + tp.getDx0L());
-                tp.setQ(info.getSightHeight() - tp.getSc0L());
+                if(StringUtils.isEmpty(tp.getDx())) {
+                    String dx = rangeList(1, 0, info.getDx(), 1, 0, 1).get(0).toString();
+                    tp.setDx(dx);
+                }
+                if(StringUtils.isNotEmpty(tp.getQ())){
+                    tp.setSc(info.getSightHeight()-tp.getQ0L());
+                    tp.setDx(tp.getSj0L()-tp.getSj0L());
+                }else{
+                    tp.setSc(tp.getSj0L() + tp.getDx0L());
+                    tp.setQ(info.getSightHeight() - tp.getSc0L());
+                }
             } else if (StringUtils.isNotEmpty(tp.getQ())) {
                 tp.setSc(info.getSightHeight() - tp.getQ0L());
                 if (tp.getSj() != null) {
                     tp.setDx(tp.getSj0L() - tp.getSj0L());
+                }else if(StringUtils.isNotEmpty(tp.getDx())){
+                    tp.setSj(tp.getSc0L()-tp.getDx0L());
                 }
             }
+            if (!tp.isVisible(negative)) {
+                result.addAll(tp.limit(negative));
+            }
         }
-        if (!tp.isVisible()) {
-            result.addAll(tp.limit());
-        }
+
     }
 
+
+
+
     /**验证当前测点数据的合理性*/
     static boolean finalizeCe(TurnPoint tp){
         if(Func.isNotBlank(tp.getSc())&&Func.isNotBlank(tp.getSj())&&Func.isNotBlank(tp.getQ())&&Func.isNotBlank(tp.getDx())){
@@ -384,7 +401,7 @@ public interface ITurnPointCalculator {
             boolean f1= tp.getSc0L()==tp.getLevelInfo().getSightHeight()-tp.getQ0L();
             /*实测高程-设计值高程=偏差值*/
             boolean f2=tp.getSc0L()-tp.getSj0L()==tp.getDx0L();
-            return f1&&f2;
+            return f1&&f2&&tp.isVisible(tp.isNegativeQ());
         }
         return false;
     }

+ 31 - 13
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/TurnPoint.java

@@ -1,5 +1,6 @@
 package org.springblade.manager.formula;
 
+import com.alibaba.fastjson.JSON;
 import com.mixsmart.utils.CustomFunction;
 import com.mixsmart.utils.StringUtils;
 import org.springframework.beans.BeanUtils;
@@ -228,13 +229,16 @@ public class TurnPoint {
         return levelInfo.getSightHeight() >= getBmd0L();
     }
 
-    public Boolean isVisible() {
+    public Boolean isVisible(Boolean negative) {
         /*只有测点落在0.5到step之间才有效,负数前视取绝对值*/
+        if(!StringUtils.isNumber(q)){
+            return false;
+        }
         double d = getQ0L();
-        if(d<0){
+        if(negative){
             d=  Math.abs(d);
         }
-        return d >= levelInfo.getMin() && d <= levelInfo.getStep();
+        return d >= levelInfo.getMin() && d <= levelInfo.getStep()&&levelInfo.getSightHeight()-getQ0L()==getSc0L();
     }
 
     public Boolean needClose() {
@@ -242,29 +246,43 @@ public class TurnPoint {
     }
 
     public static void test() {
-        for (int i = 0; i < 5; i++) {
+        for (int i = 0; i < 3; i++) {
             LevelInfo info = new LevelInfo();
-            info.setSightHeight(100.228);
+            info.setSightHeight(401.817+0.454);
             TurnPoint tp = new TurnPoint(info, new HashMap<>());
-            tp.setQ(-2.119);
-            tp.setSc(106.981);
-            System.out.println("第" + (i + 1) + "次");
-            System.out.println(tp.limit().stream().map(TurnPoint::getBmd0L).collect(Collectors.toList()));
+            tp.setQ(0.619);
+            tp.setSc(405.546);
+            if(!tp.isVisible(false)) {
+                System.out.println("第" + (i + 1) + "次");
+                System.out.println(tp.limit(false).stream().map(e -> "{" + e.getQ() + "," + e.getBmd() + "," + e.getH() + "}").collect(Collectors.toList()) + "{" + tp.getQ() + "," + tp.getSc() + "," + tp.getSj() + "}");
+            }else{
+                System.out.println( "{" + tp.getQ() + "," + tp.getSc() + "," + tp.getSj() + "}");
+            }
+
         }
     }
 
+    public Boolean isNegativeQ(){
+        return StringUtils.isNumber(q)&&getQ0L()<0;
+    }
+
 /*    public static void main(String[] args) {
         test();
     }*/
 
     public static Random r = new Random();
     /*转点的核心处理算法,当测点不在测量范围会触发*/
-    public List<TurnPoint> limit() {
+    public List<TurnPoint> limit(Boolean negative) {
         List<TurnPoint> result = new ArrayList<>();
         double step = levelInfo.getStep();
-        double q = (double) (r.nextInt(30) + 5) / 10;
-        setQ(q);
-        double target = q + getSc0L();
+        /*负前视必须是表单传入,而非自动生成*/
+        /*boolean fake=(!negative&&getQ0L()<0);*/
+        boolean overRange=(!negative&&getQ0L()<levelInfo.getMin()) || getQ0L() > levelInfo.getStep();
+        if(StringUtils.isEmpty(getQ())||overRange){
+            double q = (double) (r.nextInt(3000) + 500) / 1000;
+            setQ(q);
+        }
+        double target = getQ0L() + getSc0L();
         double hd = Math.abs(target - levelInfo.getSightHeight());
         boolean higher = target > levelInfo.getSightHeight();
         int loop = 0;

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java

@@ -778,7 +778,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                                                 em.put(se.getKey(),StringUtils.handleObj2Integer(value));
                                             }
                                         }else{
-                                            em.put(se.getKey(),value);
+                                            em.put(se.getKey(),StringUtils.handleNull(value).replaceAll("[ ]+","").trim());
                                         }
 
                                     }