From 48020b340d4bce51660fa5b412085e4d4cd769f1 Mon Sep 17 00:00:00 2001
From: LSH
Date: 星期二, 18 七月 2023 17:03:32 +0800
Subject: [PATCH] #完善路径工具类
---
src/main/java/com/zy/asrs/utils/RouteUtils.java | 71 ++++++++++++++++++++++++++++-------
src/main/java/com/zy/core/enums/RouteCollectCountType.java | 42 +++++++++++++++++++++
2 files changed, 98 insertions(+), 15 deletions(-)
diff --git a/src/main/java/com/zy/asrs/utils/RouteUtils.java b/src/main/java/com/zy/asrs/utils/RouteUtils.java
index 50713ad..90cbf42 100644
--- a/src/main/java/com/zy/asrs/utils/RouteUtils.java
+++ b/src/main/java/com/zy/asrs/utils/RouteUtils.java
@@ -1,17 +1,12 @@
package com.zy.asrs.utils;
-import com.core.common.Arith;
-import com.core.common.Cools;
-import com.zy.core.properties.SlaveProperties;
-
-import java.text.DecimalFormat;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
+import static java.util.stream.Collectors.toList;
+import com.zy.core.enums.RouteCollectCountType;
/**
- * Created by vincent on 2020/8/27
+ * Created by Monkey D. Luffy on 2023/7/18
*/
public class RouteUtils {
@@ -38,11 +33,11 @@
}
}
- // 鑾峰彇褰撳墠灏忚溅鏈璧扮殑璺嚎
+ // 鑾峰彇褰撳墠灏忚溅鏈璧扮殑璺嚎闆嗗悎
public static List<Integer> getRoute(Integer groupStart,Integer groupEnd){
boolean sign = groupStart < groupEnd;
List<Integer> result = new ArrayList<>();
- List<Integer> groupRoute = new ArrayList<>();
+ List<Integer> groupRoute = null;
if (sign){
groupRoute = TRACK_POSITION_POSITIVE_SEQUENCE;
}else {
@@ -67,15 +62,61 @@
}
return result;
}
- // 澶栦晶鏂瑰悜鐨勮揣浣� 浼樺厛鍏ュ簱鏂瑰悜/浼樺厛鍑哄簱鏂瑰悜 ===>> 鍙嶄箣
- public static List<String> getGroupOutsideLoc(String locNo,Integer crnNo){
- List<String> result = new ArrayList<>();
-
- return result;
+ //鏄惁鏈変氦闆�
+ public static boolean getRouteBoolean(List<Integer> groupCurrent,List<Integer> groupOther){
+ for (Integer positionCurrent : groupCurrent){
+ for (Integer positionOther : groupOther){
+ if (positionCurrent.equals(positionOther)){
+ return true;
+ }
+ }
+ }
+ return false;
}
+ //闆嗗悎杩愮畻
+ public static List<Integer> getRouteIntersection(List<Integer> groupCurrent, List<Integer> groupOther, RouteCollectCountType routeCollectCountType){
+ switch (routeCollectCountType){
+ case INTERSECTION:
+ //浜ら泦
+ return groupCurrent.stream().filter(item -> groupOther.contains(item)).collect(toList());
+ case DIFFERENCESET:
+ //宸泦
+ return groupCurrent.stream().filter(item -> !groupOther.contains(item)).collect(toList());
+ case UNION:
+ //骞堕泦
+ groupCurrent.addAll(groupOther);
+ return groupCurrent;
+ case DEDUPLICATIONUNION:
+ //鍘婚噸骞堕泦
+ groupCurrent.addAll(groupOther);
+ return groupCurrent.stream().distinct().collect(toList());
+ default:
+ return null;
+ }
+ }
+ public static void main(String[] arge){
+ List<Integer> routeCurrent = getRoute(2, 9); //鑾峰彇褰撳墠灏忚溅璺緞
+ List<Integer> routeOther = getRoute(12, 5); //鑾峰彇鍏跺畠灏忚溅璺緞
+ System.out.println("褰撳墠灏忚溅璺緞:\t"+routeCurrent);
+ System.out.println("鍏跺畠灏忚溅璺緞:\t"+routeOther);
+ boolean routeBoolean = getRouteBoolean(routeCurrent, routeOther); //鏄惁鏈変氦闆�
+ System.out.println("鏄惁鏈変氦闆�:\t"+routeBoolean);
+
+ List<Integer> routeIntersection = getRouteIntersection(routeCurrent, routeOther, RouteCollectCountType.INTERSECTION);//浜ら泦
+ System.out.println("璺緞浜ら泦锛歕t"+routeIntersection);
+
+ List<Integer> routeIntersection1 = getRouteIntersection(routeCurrent, routeOther, RouteCollectCountType.DIFFERENCESET);//宸泦
+ System.out.println("璺緞宸泦锛歕t"+routeIntersection1);
+
+ List<Integer> routeIntersection2 = getRouteIntersection(routeCurrent, routeOther, RouteCollectCountType.UNION);//骞堕泦
+ System.out.println("璺緞骞堕泦锛歕t"+routeIntersection2);
+
+ List<Integer> routeIntersection3 = getRouteIntersection(routeCurrent, routeOther, RouteCollectCountType.DEDUPLICATIONUNION);//鍘婚噸骞堕泦
+ System.out.println("璺緞鍘婚噸骞堕泦锛歕t"+routeIntersection3);
+ }
}
diff --git a/src/main/java/com/zy/core/enums/RouteCollectCountType.java b/src/main/java/com/zy/core/enums/RouteCollectCountType.java
new file mode 100644
index 0000000..518b771
--- /dev/null
+++ b/src/main/java/com/zy/core/enums/RouteCollectCountType.java
@@ -0,0 +1,42 @@
+package com.zy.core.enums;
+
+public enum RouteCollectCountType {
+
+ INTERSECTION(0, "浜ら泦"), // 浜ら泦
+ DIFFERENCESET(1, "宸泦"), // 宸泦
+ UNION(2, "骞堕泦"), //骞堕泦
+ DEDUPLICATIONUNION(3, "鍘婚噸骞堕泦"), //鍘婚噸骞堕泦
+ ;
+
+ public Integer id;
+ public String desc;
+ RouteCollectCountType(Integer id, String desc) {
+ this.id = id;
+ this.desc = desc;
+ }
+
+ public static RouteCollectCountType get(Short id) {
+ if (null == id) {
+ return null;
+ }
+ for (RouteCollectCountType type : RouteCollectCountType.values()) {
+ if (type.id.equals(id.intValue())) {
+ return type;
+ }
+ }
+ return null;
+ }
+
+ public static RouteCollectCountType get(RouteCollectCountType type) {
+ if (null == type) {
+ return null;
+ }
+ for (RouteCollectCountType crnLiftPosType : RouteCollectCountType.values()) {
+ if (crnLiftPosType == type) {
+ return crnLiftPosType;
+ }
+ }
+ return null;
+ }
+
+}
--
Gitblit v1.9.1