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);
|
}
|
}
|
}
|
|
}
|