From c1c9f02d25ea862802f727a1f329be6c6f02f637 Mon Sep 17 00:00:00 2001
From: hmpc <hmpc>
Date: 星期日, 03 十一月 2024 15:32:18 +0800
Subject: [PATCH] *

---
 src/main/java/com/zy/asrs/utils/SortTheExecutionOfTheCarUtil.java |  106 ++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 89 insertions(+), 17 deletions(-)

diff --git a/src/main/java/com/zy/asrs/utils/SortTheExecutionOfTheCarUtil.java b/src/main/java/com/zy/asrs/utils/SortTheExecutionOfTheCarUtil.java
index a6ef2f4..93316ad 100644
--- a/src/main/java/com/zy/asrs/utils/SortTheExecutionOfTheCarUtil.java
+++ b/src/main/java/com/zy/asrs/utils/SortTheExecutionOfTheCarUtil.java
@@ -29,23 +29,74 @@
         return ints;
     }
 
-    //鑾峰彇鏈�杩戝苟鍦ㄥ綋鍓嶄綅缃墠杈圭殑浣嶇疆
-    public static Integer LatelyAndLessThan(List<BasDevpPosition> devpPosition, long nowPosition){
+//    //鑾峰彇鏈�杩戝苟鍦ㄥ綋鍓嶄綅缃墠杈圭殑浣嶇疆1000000===>10000==>0==>1000000
+//    public static Integer LatelyAndLessThan(List<BasDevpPosition> devpPosition, long nowPosition,long perimeter){
+//        Integer result = 0;
+//        long Difference = perimeter;
+//        for (BasDevpPosition positions : devpPosition){
+//            Long position = positions.getPlcPosition();
+//            if (position<=nowPosition){
+//                if ((nowPosition-position) < Difference){
+//                    Difference = nowPosition-position;
+//                    result = positions.getDevNo();
+//                }
+//            } else {
+//                if ((nowPosition-(position - perimeter)) < Difference){
+//                    Difference = nowPosition-(position - perimeter);
+//                    result = positions.getDevNo();
+//                }
+//            }
+//        }
+//        return result;
+//    }
+    //鑾峰彇鏈�杩戝苟鍦ㄥ綋鍓嶄綅缃墠杈圭殑浣嶇疆 0==>1000===>1000000==>0
+    public static Integer LatelyAndLessThan(List<BasDevpPosition> devpPosition, long nowPosition,long perimeter){
         Integer result = 0;
-        long Difference = 1737000L;
+        long Difference = perimeter;
         for (BasDevpPosition positions : devpPosition){
             Long position = positions.getPlcPosition();
-            if (position<=nowPosition){
-                if ((nowPosition-position) < Difference){
-                    Difference = nowPosition-position;
+            if (position >= nowPosition){
+                if ((position-nowPosition) < Difference){
+                    Difference = position-nowPosition;
                     result = positions.getDevNo();
                 }
             } else {
-                if ((nowPosition-(position - 1737000L)) < Difference){
-                    Difference = nowPosition-(position - 1737000L);
+                if (perimeter - (nowPosition - position) < Difference){
+                    Difference = perimeter - (nowPosition - position);
                     result = positions.getDevNo();
                 }
             }
+        }
+        return result;
+    }
+
+//    //鑾峰彇鏈�杩戝苟鍦ㄥ綋鍓嶄綅缃悗杈圭殑浣嶇疆 1000000===>10000==>0==>1000000
+//    public static Integer LatelyAndLessThanWcs(List<BasDevpPosition> devpPosition, long nowPosition,long perimeter){
+//        Integer result = 0;
+//        Integer integer = LatelyAndLessThan(devpPosition, nowPosition,perimeter);
+//        for (BasDevpPosition basDevpPosition:devpPosition){
+//            if (basDevpPosition.getDevNo().equals(integer)){
+//                if (basDevpPosition.getDevNo() == 101){
+//                    result = 133;
+//                }
+//                break;
+//            }
+//            result = basDevpPosition.getDevNo();
+//        }
+//        return result;
+//    }
+    //鑾峰彇鏈�杩戝苟鍦ㄥ綋鍓嶄綅缃悗杈圭殑浣嶇疆 0==>1000===>1000000==>0
+    public static Integer LatelyAndLessThanWcs(List<BasDevpPosition> devpPosition, long nowPosition,long perimeter){
+        Integer result = -1;
+        Integer integer = LatelyAndLessThan(devpPosition, nowPosition,perimeter);
+        for (BasDevpPosition basDevpPosition:devpPosition){
+            if (basDevpPosition.getDevNo().equals(integer)){
+                if (basDevpPosition.getDevNo() == 133){
+                    result = 101;
+                }
+                break;
+            }
+            result = basDevpPosition.getDevNo();
         }
         return result;
     }
@@ -69,20 +120,41 @@
 //        return result;
 //    }
 
-    //鑾峰彇鏈�杩戝苟鍦ㄥ綋鍓嶄綅缃悗杈圭殑浣嶇疆
-    public static Integer LatelyAndGreaterThan(List<List<Long>> sitePosition, long nowPosition){
-        int result = 0;
-        long Difference = 1737000L;
+//    //鑾峰彇鏈�杩戝苟鍦ㄥ綋鍓嶄綅缃悗杈圭殑浣嶇疆  1000000===>10000==>0==>1000000
+//    public static Integer LatelyAndGreaterThan(List<List<Long>> sitePosition, long nowPosition ,long perimeter){
+//        int result = 0;
+//        long Difference = perimeter;
+//        for (List<Long> rgvPositions: sitePosition){
+//            Long position = rgvPositions.get(1);
+//            if (position>nowPosition){
+//                if ((position - nowPosition) < Difference){
+//                    Difference = position - nowPosition;
+//                    result = rgvPositions.get(0).intValue();
+//                }
+//            } else {
+//                if ((perimeter - (nowPosition - position)) < Difference){
+//                    Difference = perimeter - (nowPosition - position);
+//                    result = rgvPositions.get(0).intValue();
+//                }
+//            }
+//        }
+//        return result;
+//    }
+
+    //鑾峰彇鏈�杩戝苟鍦ㄥ綋鍓嶄綅缃悗杈圭殑浣嶇疆   0==>1000===>1000000==>0
+    public static Integer LatelyAndGreaterThan(List<List<Long>> sitePosition, long nowPosition ,long perimeter){
+        int result = -1;
+        long Difference = perimeter;
         for (List<Long> rgvPositions: sitePosition){
             Long position = rgvPositions.get(1);
-            if (position>nowPosition){
-                if ((position - nowPosition) < Difference){
-                    Difference = position - nowPosition;
+            if (position <= nowPosition){
+                if ((nowPosition - position) < Difference){
+                    Difference = nowPosition - position;
                     result = rgvPositions.get(0).intValue();
                 }
             } else {
-                if ((1737000L - (nowPosition - position)) < Difference){
-                    Difference = 1737000L - (nowPosition - position);
+                if ((perimeter - (nowPosition - position)) < Difference){
+                    Difference = perimeter - (nowPosition - position);
                     result = rgvPositions.get(0).intValue();
                 }
             }

--
Gitblit v1.9.1