|
|
@@ -1,6 +1,7 @@ |
|
|
|
package com.hz.pm.api.user.manage; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import cn.hutool.core.text.CharSequenceUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
@@ -43,6 +44,7 @@ import java.util.stream.Collectors; |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class MhUnitManage { |
|
|
|
|
|
|
|
|
|
|
|
@Value("${mh.unit.root-parent-id:0}") |
|
|
|
private Long unitRootParentId; |
|
|
|
|
|
|
@@ -50,6 +52,8 @@ public class MhUnitManage { |
|
|
|
private final MhUnitCache mhUnitCache; |
|
|
|
private final IUserInfoService userInfoService; |
|
|
|
|
|
|
|
private static final List<String> REGION_SORTS = Arrays.asList("市", "上城", "拱墅", "西湖", "滨江", "萧山", "余杭", "临平", "钱塘", "富阳", "临安", "桐庐", "淳安", "建德"); |
|
|
|
|
|
|
|
public List<MhUnitTreeDTO> getMhUnitTree(String name) { |
|
|
|
List<UnitDTO> retUnits; |
|
|
|
List<UnitDTO> allUnits = mhUnitCache.all(); |
|
|
@@ -84,12 +88,25 @@ public class MhUnitManage { |
|
|
|
&& w.getName().endsWith("信创办"))) |
|
|
|
.map(w -> BeanUtil.copyProperties(w, MhUnitTreeDTO.class)) |
|
|
|
.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; |
|
|
|
} |
|
|
|
|
|
|
|
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() { |
|
|
|
List<UnitDTO> allUnits = mhUnitCache.all(); |
|
|
|
List<MhUnitTreeDTO> nodes = allUnits.stream() |
|
|
@@ -112,9 +129,7 @@ public class MhUnitManage { |
|
|
|
} |
|
|
|
return unit; |
|
|
|
}).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; |
|
|
|
} |
|
|
|
|
|
|
|