From 6742ccb80562035ca680cf46438746ceb7cacbc8 Mon Sep 17 00:00:00 2001
From: LSH
Date: 星期二, 25 七月 2023 16:59:30 +0800
Subject: [PATCH] #码垛位自动补充空板:自动补空板任务,扫码实装
---
src/main/java/com/zy/asrs/utils/RouteUtils.java | 89 +++++++++++++++++++++++++++++++++-----------
1 files changed, 66 insertions(+), 23 deletions(-)
diff --git a/src/main/java/com/zy/asrs/utils/RouteUtils.java b/src/main/java/com/zy/asrs/utils/RouteUtils.java
index 22f35f5..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,20 +33,25 @@
}
}
- // 鑾峰彇褰撳墠灏忚溅鏈璧扮殑璺嚎
- public static List<Integer> getRoute(boolean sign,Integer drop){
+ // 鑾峰彇褰撳墠灏忚溅鏈璧扮殑璺嚎闆嗗悎
+ 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 {
groupRoute = TRACK_POSITION_REVERSE_SEQUENCE;
}
- if (groupRoute.contains(drop)) {
+ if (groupRoute.contains(groupStart) && groupRoute.contains(groupEnd)) {
sign = false;
for (Integer route : groupRoute) {
- if (route == drop){
+ if (route.equals(groupStart)){
sign=true;
+ }
+ if (route.equals(groupEnd)){
+ result.add(route);
+ break;
}
if (sign){
result.add(route);
@@ -60,20 +60,63 @@
}else {
return null;
}
-
-
-
- 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);
+ }
}
--
Gitblit v1.9.1