From f7bcd87b19bf265d0fa157f110632d6b661ec22d Mon Sep 17 00:00:00 2001 From: LSH Date: 星期一, 25 九月 2023 15:25:03 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/utils/RouteUtils.java | 91 ++++++++++++++++++++++++++++++++++++--------- 1 files changed, 73 insertions(+), 18 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..2816909 100644 --- a/src/main/java/com/zy/asrs/utils/RouteUtils.java +++ b/src/main/java/com/zy/asrs/utils/RouteUtils.java @@ -1,27 +1,22 @@ 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 { // 姝e簭 public static final List<Integer> TRACK_POSITION_POSITIVE_SEQUENCE = new ArrayList<Integer>() {{ - add(1);add(2);add(3);add(4);add(5);add(6);add(7);add(8);add(9);add(10);add(11);add(12); + add(101);add(102);add(104);add(105);add(107);add(118);add(108);add(119);add(110);add(120);add(111);add(121);add(113);add(114);add(116);add(117); }}; // 鍙嶅簭 public static final List<Integer> TRACK_POSITION_REVERSE_SEQUENCE = new ArrayList<Integer>() {{ - add(12);add(11);add(10);add(9);add(8);add(7);add(6);add(5);add(4);add(3);add(2);add(1); + add(117);add(116);add(114);add(113);add(121);add(111);add(120);add(110);add(119);add(108);add(118);add(107);add(105);add(104);add(102);add(101); }}; public static String zerofill(String msg, Integer count){ @@ -38,11 +33,11 @@ } } - // 鑾峰彇褰撳墠灏忚溅鏈璧扮殑璺嚎 + // 鑾峰彇褰撳墠灏忚溅鏈璧扮殑璺嚎闆嗗悎 public static List<Integer> getRoute(Integer groupStart,Integer groupEnd){ - boolean sign = groupStart < groupEnd; + boolean sign = TRACK_POSITION_POSITIVE_SEQUENCE.indexOf(groupStart) < TRACK_POSITION_POSITIVE_SEQUENCE.indexOf(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,75 @@ } 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; + } + } + /* + * a 灏忚溅褰撳墠浣嶇疆 + * b 灏忚溅浠诲姟寮�濮嬩綅缃� + * c 灏忚溅浠诲姟缁撴潫浣嶇疆 + * sign 鍙︿竴涓皬杞︾┖闂叉爣璁� + * */ + public static boolean RouteAutoBoolean(Integer a,Integer b,Integer c,Integer aa,Integer bb,Integer cc,boolean idleOther){ + List<Integer> routeCurrent = getRouteIntersection(getRoute(a, c), getRoute(b, c), RouteCollectCountType.DEDUPLICATIONUNION);//骞堕泦 + List<Integer> routeOther = getRouteIntersection(getRoute(aa, cc), getRoute(bb, cc), RouteCollectCountType.DEDUPLICATIONUNION);// + return !getRouteBoolean(routeCurrent, routeOther); //鏄惁鏈変氦闆� + } + public static void main(String[] arge){ + List<Integer> routeCurrent = getRoute(104, 119); //鑾峰彇褰撳墠灏忚溅璺緞 + List<Integer> routeOther = getRoute(117, 118); //鑾峰彇鍏跺畠灏忚溅璺緞 + 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); + + System.out.println(RouteAutoBoolean(101,104,119,114,116,120,true)); + } } -- Gitblit v1.9.1