| | |
| | | } |
| | | } |
| | | // 比较位置 |
| | | return Integer.compare(index1, index2); |
| | | int compareResult = Integer.compare(index1, index2); |
| | | // 如果是环境试验,且两个对象在主检验项目上排序相同,则用次级检验项目排序 |
| | | if (compareResult == 0 && order[index1].equals("环境试验")) { |
| | | String[] subOrder = {"冲水试验", "振动试验"}; |
| | | int subIndex1 = -1; |
| | | int subIndex2 = -1; |
| | | for (int i = 0; i < subOrder.length; i++) { |
| | | if (o1.getInspectionItemSubclass().equals(subOrder[i])) { |
| | | subIndex1 = i; |
| | | } |
| | | if (o2.getInspectionItemSubclass().equals(subOrder[i])) { |
| | | subIndex2 = i; |
| | | } |
| | | if (subIndex1 != -1 && subIndex2 != -1) { |
| | | break; // 两个次级位置都找到了,可以退出循环 |
| | | } |
| | | } |
| | | compareResult = Integer.compare(subIndex1, subIndex2); |
| | | } |
| | | // 比较位置 |
| | | return compareResult; |
| | | }; |
| | | // 对列表进行排序 |
| | | Collections.sort(list, testTypeComparator); |