*
L
2 天以前 7e68f81b38116bba40e70620c563168fcde66a37
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
package com.zy.asrs.utils;
 
import com.zy.core.cache.RgvStatusCache;
import com.zy.core.model.RgvSlave;
import com.zy.core.model.protocol.RgvProtocol;
 
import java.util.ArrayList;
import java.util.Collections;
 
/**
 * Created by Monkey D. Luffy on 2023/7/18
 */
public class LocFCSUtils {
 
    public static ArrayList<String[]> getLocS(ArrayList<String> locMastDemoListF) {
        ArrayList<String[]> locS = new ArrayList<>();
        // 提取数据
        int idx = 1;
        for (String locNo : locMastDemoListF) {
            if (locNo != null && locNo.length() >= 5) {
                String[] strings = new String[4];  // 增加一列用于排序序号
                String result = locNo.substring(2, 5);
 
                strings[0] = locNo;              // 原字符串
                strings[1] = result;              // 截取的部分
                strings[2] = String.valueOf(idx); // 原始序号
                strings[3] = "";                  // 排序序号(暂空)
 
                locS.add(strings);
            }
            idx++;
        }
 
// 排序
        Collections.sort(locS, (a, b) -> {
            int numA = Integer.parseInt(a[1]);
            int numB = Integer.parseInt(b[1]);
            return Integer.compare(numA, numB);
        });
 
// 设置排序序号
        for (int i = 0; i < locS.size(); i++) {
            locS.get(i)[3] = String.valueOf(i + 1);
        }
        return locS;
    }
 
    public static void updateLocSInPlace(ArrayList<String[]> locS) {
        if (locS == null || locS.isEmpty()) {
            return;
        }
 
        // 更新排序序号
        for (String[] row : locS) {
            int currentSort = Integer.parseInt(row[3]);
 
            if (currentSort == 1) {
                row[3] = String.valueOf(locS.size());
            } else {
                row[3] = String.valueOf(currentSort - 1);
            }
        }
    }
 
}