|
@@ -325,25 +325,41 @@ public class FormulaController {
|
|
|
}
|
|
|
}
|
|
|
String[] dw2 = keymap.get(info.getKey()).split(StringPool.SEMICOLON);
|
|
|
- // 排序
|
|
|
- String dw[] = new String[dw2.length];
|
|
|
+ //排序
|
|
|
+ String[] dw = new String[dw2.length];
|
|
|
int start=0;
|
|
|
List<String> list = Arrays.asList(dw2);
|
|
|
- // 横向排序
|
|
|
+ //横向排序
|
|
|
int yindex;
|
|
|
int xindex;
|
|
|
if(info.getDirection().equals("2")){ //纵向
|
|
|
yindex = 1;
|
|
|
xindex = 0;
|
|
|
- } else { //横向
|
|
|
+ } else {//横向
|
|
|
xindex = 1;
|
|
|
yindex = 0;
|
|
|
}
|
|
|
- Map<Integer, List<String>> collect = list.stream().filter(s -> s.indexOf("_")>=0).collect(Collectors.groupingBy(s -> Integer.parseInt(s.split("_")[yindex])));
|
|
|
+
|
|
|
+ //Map<Integer, List<String>> collect = list.stream().filter(s -> s.contains("_")).collect(Collectors.groupingBy(s -> Integer.parseInt(s.split("_")[yindex])));
|
|
|
+
|
|
|
+ //转为LinkedHashMap并保持List<String>顺序
|
|
|
+ Map<Integer, List<String>> collect = list.stream()
|
|
|
+ .filter(s -> s.contains("_"))
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ s -> Integer.parseInt(s.split("_")[yindex]),
|
|
|
+ Collections::singletonList,
|
|
|
+ (obj1, obj2) -> {
|
|
|
+ List<String> mergedList = new ArrayList<>(obj1);
|
|
|
+ mergedList.addAll(obj2);
|
|
|
+ return mergedList;
|
|
|
+ },
|
|
|
+ LinkedHashMap::new
|
|
|
+ ));
|
|
|
+
|
|
|
int j=0;
|
|
|
for(Integer key: collect.keySet()){
|
|
|
List<String> datakey = collect.get(key);
|
|
|
- List<String> ordList = datakey.stream().filter(s -> s.indexOf("_")>=0).sorted(Comparator.comparing(s -> Integer.parseInt(s.split("_")[xindex]))).collect(Collectors.toList());
|
|
|
+ List<String> ordList = datakey.stream().filter(s -> s.contains("_")).sorted(Comparator.comparing(s -> Integer.parseInt(s.split("_")[xindex]))).collect(Collectors.toList());
|
|
|
for (String ord:ordList){
|
|
|
dw[j]=ord;
|
|
|
j++;
|