Browse Source

modify:

1. 单位排序修改;
tags/24082603^0
WendyYang 4 months ago
parent
commit
1f1993dc87
1 changed files with 21 additions and 6 deletions
  1. +21
    -6
      hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java

+ 21
- 6
hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java View File

@@ -1,6 +1,7 @@
package com.hz.pm.api.user.manage; package com.hz.pm.api.user.manage;


import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -43,6 +44,7 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor @RequiredArgsConstructor
public class MhUnitManage { public class MhUnitManage {



@Value("${mh.unit.root-parent-id:0}") @Value("${mh.unit.root-parent-id:0}")
private Long unitRootParentId; private Long unitRootParentId;


@@ -50,6 +52,8 @@ public class MhUnitManage {
private final MhUnitCache mhUnitCache; private final MhUnitCache mhUnitCache;
private final IUserInfoService userInfoService; private final IUserInfoService userInfoService;


private static final List<String> REGION_SORTS = Arrays.asList("市", "上城", "拱墅", "西湖", "滨江", "萧山", "余杭", "临平", "钱塘", "富阳", "临安", "桐庐", "淳安", "建德");

public List<MhUnitTreeDTO> getMhUnitTree(String name) { public List<MhUnitTreeDTO> getMhUnitTree(String name) {
List<UnitDTO> retUnits; List<UnitDTO> retUnits;
List<UnitDTO> allUnits = mhUnitCache.all(); List<UnitDTO> allUnits = mhUnitCache.all();
@@ -84,12 +88,25 @@ public class MhUnitManage {
&& w.getName().endsWith("信创办"))) && w.getName().endsWith("信创办")))
.map(w -> BeanUtil.copyProperties(w, MhUnitTreeDTO.class)) .map(w -> BeanUtil.copyProperties(w, MhUnitTreeDTO.class))
.collect(Collectors.toList()); .collect(Collectors.toList());
Function<MhUnitTreeDTO, Integer> function = w -> w.getType().getStrip().getCode();
nodes.sort(Comparator.comparing(MhUnitTreeDTO::getName)
.thenComparing(function, Comparator.reverseOrder()));
mhUnitOptionSort(nodes);
return nodes; return nodes;
} }


private static void mhUnitOptionSort(List<MhUnitTreeDTO> nodes) {
Function<MhUnitTreeDTO, Integer> firstSortFunc = w -> CollUtil.indexOf(REGION_SORTS, x -> w.getName().startsWith(x));
Function<MhUnitTreeDTO, Integer> secondSortFunc = w -> {
if (w.getName().contains("信创办")) {
return 1;
} else if (w.getName().contains("国有企业")) {
return 3;
} else {
return 2;
}
};
nodes.sort(Comparator.comparing(firstSortFunc, Comparator.naturalOrder())
.thenComparing(secondSortFunc, Comparator.naturalOrder()));
}

public List<MhUnitTreeDTO> getMhUnitDashboardOption() { public List<MhUnitTreeDTO> getMhUnitDashboardOption() {
List<UnitDTO> allUnits = mhUnitCache.all(); List<UnitDTO> allUnits = mhUnitCache.all();
List<MhUnitTreeDTO> nodes = allUnits.stream() List<MhUnitTreeDTO> nodes = allUnits.stream()
@@ -112,9 +129,7 @@ public class MhUnitManage {
} }
return unit; return unit;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
Function<MhUnitTreeDTO, Integer> function = w -> w.getType().getStrip().getCode();
nodes.sort(Comparator.comparing(MhUnitTreeDTO::getName)
.thenComparing(function, Comparator.reverseOrder()));
mhUnitOptionSort(nodes);
return nodes; return nodes;
} }




Loading…
Cancel
Save