自动化立体仓库 - WCS系统
*
hmpc
2024-10-22 2752662df7213c0432cc276cc3b5948faffe6ddd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package com.zy.asrs.utils;
 
import com.zy.asrs.entity.BasDevpPosition;
import com.zy.core.enums.RouteCollectCountType;
 
import java.util.Arrays;
import java.util.List;
 
public class SortTheExecutionOfTheCarUtil {
    //排序
    public static int[][] ReorderSteId(int[][] steList,int steNoStart){
        int[][] ints = new int[steList.length][2];
        int Difference = 0;
        for (int[] steNo : steList){
            if (steNo[0] == steNoStart){
                Difference = steNo[1] - 1;
                break;
            }
        }
        for (int[] steNo : steList){
            int i = steNo[1];
            if (i > Difference){
                steNo[1] = i - Difference;
            } else {
                steNo[1] = steList.length + i-Difference;
            }
            ints[steNo[0]-1] = steNo;
        }
        return ints;
    }
 
    //获取最近并在当前位置前边的位置
    public static Integer LatelyAndLessThan(List<BasDevpPosition> devpPosition, long nowPosition){
        Integer result = 0;
        long Difference = 1737000L;
        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 - 1737000L)) < Difference){
                    Difference = nowPosition-(position - 1737000L);
                    result = positions.getDevNo();
                }
            }
        }
        return result;
    }
    //获取最近并在当前位置前边的位置
    public static Long LatelyAndLessThan(long[] devpPosition,long nowPosition){
        long result = 0L;
        long Difference = 1737000L;
        for (long position : devpPosition){
            if (position<=nowPosition){
                if ((nowPosition-position) < Difference){
                    Difference = nowPosition-position;
                    result = position;
                }
            } else {
                if ((nowPosition-(position - 1737000L)) < Difference){
                    Difference = nowPosition-(position - 1737000L);
                    result = position;
                }
            }
        }
        return result;
    }
 
    //id初始化
    public static List<BasDevpPosition> devpNoInit(List<BasDevpPosition> devpPosition){
        long i = 0;
        for (BasDevpPosition basDevpPosition : devpPosition){
            i++;
            basDevpPosition.setId(i);
        }
        return devpPosition;
    }
 
 
    //站点排序
    public static BasDevpPosition[] devpNoSort(List<BasDevpPosition> devpPosition1,Integer devpNo){
        List<BasDevpPosition> devpPosition = devpNoInit(devpPosition1);
        BasDevpPosition[] basDevpPositions = new BasDevpPosition[devpPosition.size()];
        long Difference = 0L;
        for (BasDevpPosition basDevpPosition : devpPosition){
            if (basDevpPosition.getDevNo().equals(devpNo)){
                Difference = basDevpPosition.getId() - 1L;
                break;
            }
        }
        for (BasDevpPosition basDevpPosition : devpPosition){
            long i = basDevpPosition.getId();
            if (i > Difference){
                basDevpPosition.setId(i - Difference);
            } else {
                basDevpPosition.setId(devpPosition.size() + i - Difference);
            }
            basDevpPositions[basDevpPosition.getId().intValue()-1] = basDevpPosition;
        }
        return basDevpPositions;
    }
 
    //逆序排列
    public static BasDevpPosition[] devpNoSortUN(BasDevpPosition[] devpPosition){
        BasDevpPosition[] basDevpPositions = new BasDevpPosition[devpPosition.length];
        for (BasDevpPosition basDevpPosition : devpPosition){
            basDevpPositions[devpPosition.length - basDevpPosition.getId().intValue()] = basDevpPosition;
        }
        return basDevpPositions;
    }
 
    //逆序排列
    public static boolean devpNoSortbj(BasDevpPosition[] devpPosition,Integer souDevpNo,Integer endDevpNo){
        int sou = 0;
        int end = 0;
        for (int i = 0;i<devpPosition.length;i++){
            if (devpPosition[i].getDevNo().equals(souDevpNo)){
                sou = i;
            }
            if (devpPosition[i].getDevNo().equals(endDevpNo)){
                end = i;
            }
        }
 
        return sou>end;
    }
 
    public static void main(String[] args) {
        int[][] ints = new int[][]{{1,1},{3,3},{2,2},{4,4},{5,5},{6,6},{7,7},{8,8},{9,9},{10,10}};
 
        int[][] reorderSteId = ReorderSteId(ints, 2);
        for (int[] ste : reorderSteId){
            System.out.println(Arrays.toString(ste));
        }
 
        long[] longs = new long[]{1L,1000L,200000L,1100000L,1600000L};
        long l = LatelyAndLessThan(longs, 1100000L);
        System.out.println("l:"+l);
    }
}