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

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

parent 4c68fcc1
......@@ -54,6 +54,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
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.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
......@@ -1429,13 +1430,13 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
//2.list to tree
List<BuildingTreeVo> buildingTreeVos = companyBuildingList.parallelStream()
.filter(
a -> companyBuildingList.stream().noneMatch(c -> c.getId().toString().equals(a.getParentId()))
a -> companyBuildingList.parallelStream().noneMatch(c -> c.getId().toString().equals(a.getParentId()))
).peek(
b -> b.setChildren(getCompanyBuildingChildrenTree(b.getId().toString(), companyBuildingList))
).collect(Collectors.toList());
// 任务 7481
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())) {
return 0;
}
......@@ -1491,9 +1492,24 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
if (StringUtils.isEmpty(authKey)) {
authKey = this.authKey;
}
List<BuildingTreeVo> buildingTreeVos = getBuildingTreeVos(false, null);
// List<BuildingTreeVo> buildingTreeVos = getBuildingTreeVos(false, null);
// 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()){
return new ArrayList<>();
}
......
......@@ -451,7 +451,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
// });
// List<PointTreeVo> regionList = responses.stream().filter(r -> "TRUE".equals(r.getIsRegion())).collect(Collectors.toList());
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();
}
List<PointTreeVo> buildList = buildingMapper.getBuildList(orgCode, null);
......@@ -2412,7 +2412,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
@Override
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();
List<Map<String, Object>> list = fireFightingSystemMapper.systemAndEquipment(bizOrgCode);
return systemAndEquipmentTree(list);
......
......@@ -6,6 +6,7 @@ import com.yeejoin.equipmanage.common.dto.OrgUsrDto;
import com.yeejoin.equipmanage.fegin.JcsFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.util.List;
......@@ -37,7 +38,7 @@ public class JCSRemoteService {
* @return List<OrgUsrDto>
*/
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();
}
......
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