Commit 2e8593ae authored by 李秀明's avatar 李秀明

pref: 消防建筑建筑左侧公司建筑树查询接口性能优化

parent 4c68fcc1
...@@ -54,6 +54,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -54,6 +54,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.exception.BaseException; import org.typroject.tyboot.core.foundation.exception.BaseException;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
...@@ -1429,13 +1430,13 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i ...@@ -1429,13 +1430,13 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
//2.list to tree //2.list to tree
List<BuildingTreeVo> buildingTreeVos = companyBuildingList.parallelStream() List<BuildingTreeVo> buildingTreeVos = companyBuildingList.parallelStream()
.filter( .filter(
a -> companyBuildingList.stream().noneMatch(c -> c.getId().toString().equals(a.getParentId())) a -> companyBuildingList.parallelStream().noneMatch(c -> c.getId().toString().equals(a.getParentId()))
).peek( ).peek(
b -> b.setChildren(getCompanyBuildingChildrenTree(b.getId().toString(), companyBuildingList)) b -> b.setChildren(getCompanyBuildingChildrenTree(b.getId().toString(), companyBuildingList))
).collect(Collectors.toList()); ).collect(Collectors.toList());
// 任务 7481 // 任务 7481
if(buildingTreeVos.size() == 1 && !CollectionUtils.isEmpty(buildingTreeVos.get(0).getChildren())) { if(buildingTreeVos.size() == 1 && !CollectionUtils.isEmpty(buildingTreeVos.get(0).getChildren())) {
List<BuildingTreeVo> buildingTreeVosNew = buildingTreeVos.get(0).getChildren().stream().sorted((o1, o2) -> { List<BuildingTreeVo> buildingTreeVosNew = buildingTreeVos.get(0).getChildren().parallelStream().sorted((o1, o2) -> {
if(o1.getGroupType().equals(o2.getGroupType())) { if(o1.getGroupType().equals(o2.getGroupType())) {
return 0; return 0;
} }
...@@ -1491,9 +1492,24 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i ...@@ -1491,9 +1492,24 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
if (StringUtils.isEmpty(authKey)) { if (StringUtils.isEmpty(authKey)) {
authKey = this.authKey; authKey = this.authKey;
} }
List<BuildingTreeVo> buildingTreeVos = getBuildingTreeVos(false, null); // List<BuildingTreeVo> buildingTreeVos = getBuildingTreeVos(false, null);
// 1.获取公司list // 1.获取公司list
List<OrgUsrDto> orgUsrLists = jcsRemoteService.getCompanyDeptListWithAuth(authKey, "COMPANY", type); // List<OrgUsrDto> orgUsrLists = jcsRemoteService.getCompanyDeptListWithAuth(authKey, "COMPANY", type);
CompletableFuture<List<BuildingTreeVo>> companyListFuture = CompletableFuture.supplyAsync(() -> getBuildingTreeVos(false, null));
String finalAuthKey = authKey;
String appKey = RequestContext.getAppKey();
String product = RequestContext.getProduct();
String token = RequestContext.getToken();
CompletableFuture<List<OrgUsrDto>> orgUsrListFuture = CompletableFuture.supplyAsync(() -> {
RequestContext.setAppKey(appKey);
RequestContext.setProduct(product);
RequestContext.setToken(token);
return jcsRemoteService.getCompanyDeptListWithAuth(finalAuthKey, "COMPANY", type);
});
CompletableFuture.allOf(companyListFuture, orgUsrListFuture).join();
List<BuildingTreeVo> buildingTreeVos = companyListFuture.join();
List<OrgUsrDto> orgUsrLists = orgUsrListFuture.join();
if(orgUsrLists.isEmpty()){ if(orgUsrLists.isEmpty()){
return new ArrayList<>(); return new ArrayList<>();
} }
......
...@@ -451,7 +451,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste ...@@ -451,7 +451,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
// }); // });
// List<PointTreeVo> regionList = responses.stream().filter(r -> "TRUE".equals(r.getIsRegion())).collect(Collectors.toList()); // List<PointTreeVo> regionList = responses.stream().filter(r -> "TRUE".equals(r.getIsRegion())).collect(Collectors.toList());
if ("dl".equals(type)) { if ("dl".equals(type)) {
FeignClientResult<List<OrgUsrDto>> feignClientResult = jcsFeignClient.getCompanyDeptListWithAuth(authKey, "COMPANY", "dl"); FeignClientResult<List<OrgUsrDto>> feignClientResult = jcsFeignClient.getCompanyDeptListWithAuth(RequestContext.getAppKey(), RequestContext.getProduct(), RequestContext.getToken(), authKey, "COMPANY", "dl");
orgCode = feignClientResult.getResult().get(0).getBizOrgCode(); orgCode = feignClientResult.getResult().get(0).getBizOrgCode();
} }
List<PointTreeVo> buildList = buildingMapper.getBuildList(orgCode, null); List<PointTreeVo> buildList = buildingMapper.getBuildList(orgCode, null);
...@@ -2412,7 +2412,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste ...@@ -2412,7 +2412,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
@Override @Override
public List<OrgMenuDto> systemAndEquipmentTreeByBziOrgCode() { public List<OrgMenuDto> systemAndEquipmentTreeByBziOrgCode() {
FeignClientResult<List<OrgUsrDto>> feignClientResult = jcsFeignClient.getCompanyDeptListWithAuth(authKey, "COMPANY", "dl"); FeignClientResult<List<OrgUsrDto>> feignClientResult = jcsFeignClient.getCompanyDeptListWithAuth(RequestContext.getAppKey(), RequestContext.getProduct(), RequestContext.getToken(), authKey, "COMPANY", "dl");
String bizOrgCode = feignClientResult.getResult().get(0).getBizOrgCode(); String bizOrgCode = feignClientResult.getResult().get(0).getBizOrgCode();
List<Map<String, Object>> list = fireFightingSystemMapper.systemAndEquipment(bizOrgCode); List<Map<String, Object>> list = fireFightingSystemMapper.systemAndEquipment(bizOrgCode);
return systemAndEquipmentTree(list); return systemAndEquipmentTree(list);
......
...@@ -6,6 +6,7 @@ import com.yeejoin.equipmanage.common.dto.OrgUsrDto; ...@@ -6,6 +6,7 @@ import com.yeejoin.equipmanage.common.dto.OrgUsrDto;
import com.yeejoin.equipmanage.fegin.JcsFeign; import com.yeejoin.equipmanage.fegin.JcsFeign;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.util.List; import java.util.List;
...@@ -37,7 +38,7 @@ public class JCSRemoteService { ...@@ -37,7 +38,7 @@ public class JCSRemoteService {
* @return List<OrgUsrDto> * @return List<OrgUsrDto>
*/ */
public List<OrgUsrDto> getCompanyDeptListWithAuth(String authKey, String orgTypes,String type) { public List<OrgUsrDto> getCompanyDeptListWithAuth(String authKey, String orgTypes,String type) {
FeignClientResult<List<OrgUsrDto>> feignClientResult = jcsFeignClient.getCompanyDeptListWithAuth(authKey, orgTypes, type); FeignClientResult<List<OrgUsrDto>> feignClientResult = jcsFeignClient.getCompanyDeptListWithAuth(RequestContext.getAppKey(), RequestContext.getProduct(), RequestContext.getToken(), authKey, orgTypes, type);
return feignClientResult.getResult(); return feignClientResult.getResult();
} }
......
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