| | |
| | | basCrnp.setWrkNo(count); |
| | | basCrnpList.add(basCrnp); |
| | | } |
| | | final String sortByType; |
| | | Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "inLocCrn1PriorityAssign").eq("status", 1)); |
| | | if (!Cools.isEmpty(config.getValue()) && config.getValue().equals("Y")) { |
| | | sortByType = "asc"; // 定义 1 → 2 → 3 的优先级 |
| | | } else { |
| | | sortByType = "other"; // 定义 2 → 3 → 1 的优先级 |
| | | } |
| | | |
| | | basCrnpList = basCrnpList.stream().sorted(Comparator.comparing(BasCrnp::getWrkNo).thenComparing(BasCrnp::getCrnNo,((o1, o2) -> { |
| | | // 定义 2 → 3 → 1 的优先级 |
| | | int order1 = getCustomOrder(o1); |
| | | int order2 = getCustomOrder(o2); |
| | | int order1 = getCustomOrder(o1,sortByType); |
| | | int order2 = getCustomOrder(o2,sortByType); |
| | | return Integer.compare(order1, order2); |
| | | }))).collect(Collectors.toList()); |
| | | |
| | |
| | | } |
| | | |
| | | // 辅助方法:定义 crn_no 的排序优先级 |
| | | private static int getCustomOrder(Integer crnNo) { |
| | | switch (crnNo) { |
| | | case 2: return 1; // 2 排第一 |
| | | case 3: return 2; // 3 排第二 |
| | | case 1: return 3; // 1 排第三 |
| | | default: return 4; // 其他值排最后(如果有) |
| | | private static int getCustomOrder(Integer crnNo, String sort) { |
| | | switch (sort) { |
| | | case "other": |
| | | switch (crnNo) { |
| | | case 2: |
| | | return 1; // 2 排第一 |
| | | case 3: |
| | | return 2; // 3 排第二 |
| | | case 1: |
| | | return 3; // 1 排第三 |
| | | default: |
| | | return 4; // 其他值排最后(如果有) |
| | | } |
| | | case "asc": |
| | | default: |
| | | return crnNo; |
| | | } |
| | | } |
| | | |