Commit 9a78b109 authored by 李秀明's avatar 李秀明

换流站树按照类型调顺序,特高压站在前面

parent de7b2493
......@@ -56,6 +56,7 @@ import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.Resource;
......@@ -3013,7 +3014,11 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
PermissionInterceptorContext.setDataAuthRule(authKey);
param.put("bizOrgCode",bizOrgCode);
List<OrgUsr> list = orgUsrMapper.companyListWithPersonCount(param);
return buildTreeParallel2(list);
List<OrgMenuDto> orgMenuDtos = buildTreeParallel2(list);
// 重新排序: 特高压换流站 -> 常规换流站
List<Map<String, Object>> onlineStations = stationInfoMapper.selectStationInfoList();
return this.reOrder(orgMenuDtos, onlineStations);
}
public List<OrgMenuDto> companyTreeByUserNumberNew(ReginParams reginParams) {
......@@ -3939,4 +3944,49 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
.eq(OrgUsr::getIsDelete, false)
);
}
private List<OrgMenuDto> reOrder(List<OrgMenuDto> orgMenus, List<Map<String, Object>> onlineStations) {
for (OrgMenuDto orgMenu : orgMenus) {
if (orgMenu.getBizOrgCode().length() < 12) {
this.reOrder(orgMenu.getChildren(), onlineStations);
} else {
if (Objects.nonNull(orgMenu.getChildren())) {
List<OrgMenuDto> children = this.doReOrder(orgMenu.getChildren(), onlineStations);
orgMenu.setChildren(children);
}
}
}
return orgMenus;
}
/**
* 场站排序: 特高压换流站 -> 常规换流站
*/
private List<OrgMenuDto> doReOrder(List<OrgMenuDto> orgMenus, List<Map<String, Object>> onlineStations) {
List<OrgMenuDto> orderedOrgMenus = new ArrayList<>(orgMenus.size());
onlineStations = onlineStations.stream().filter(map -> orgMenus.stream().anyMatch(orgMenu -> orgMenu.getBizOrgCode().equals(map.get("biz_org_code")))).collect(Collectors.toList());
List<String> tgyStationOrgCodes= new ArrayList<>(), cgStationOrgCodes= new ArrayList<>();
for (Map<String, Object> onlineStation : onlineStations) {
Object bizOrgCode = onlineStation.get("biz_org_code");
if (Objects.isNull(bizOrgCode)) {
throw new BadRequest("场站信息配置错误!!!");
}
if ("特高压".equals(onlineStation.get("station_type"))) {
tgyStationOrgCodes.add(bizOrgCode.toString());
} else {
cgStationOrgCodes.add(bizOrgCode.toString());
}
}
for (OrgMenuDto orgMenu : orgMenus) {
if (tgyStationOrgCodes.contains(orgMenu.getBizOrgCode())) {
orderedOrgMenus.add(orgMenu);
}
}
for (OrgMenuDto orgMenu : orgMenus) {
if (cgStationOrgCodes.contains(orgMenu.getBizOrgCode())) {
orderedOrgMenus.add(orgMenu);
}
}
return orderedOrgMenus;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment