|
@@ -3,8 +3,10 @@ package com.persagy.apm.energy.report.saasweb.service.impl;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.persagy.apm.common.model.dto.PoemsFeignBaseDTO;
|
|
|
import com.persagy.apm.common.response.PoemsFeignResponse;
|
|
|
+import com.persagy.apm.energy.report.common.utils.DataUtils;
|
|
|
import com.persagy.apm.energy.report.common.utils.DateUtils;
|
|
|
import com.persagy.apm.energy.report.saasweb.constants.SaaswebConstants;
|
|
|
+import com.persagy.apm.energy.report.saasweb.constants.enums.AreaTypeEnum;
|
|
|
import com.persagy.apm.energy.report.saasweb.model.ConvertSaasWebTool;
|
|
|
import com.persagy.apm.energy.report.saasweb.model.dto.QueryByProjectIdDTO;
|
|
|
import com.persagy.apm.energy.report.saasweb.model.dto.QueryPartitionDTO;
|
|
@@ -91,34 +93,22 @@ public class SaasWebServiceImpl implements ISaasWebService {
|
|
|
PoemsFeignResponse<BuildingInfoVO> buildsResponse = saasWebClientWrapper.listBuildingsByProjectId(queryByProjectIdDTO);
|
|
|
List<BuildingInfoVO> buildingInfoVOList = buildsResponse.getContent();
|
|
|
// 统计项目下建筑总的商业面积,地下停车场面积,总面积,公区面积
|
|
|
- BigDecimal totalCommercialArea = new BigDecimal("0");
|
|
|
- BigDecimal totalUndergroundGarageArea = new BigDecimal("0");
|
|
|
- BigDecimal totalBuildingArea = new BigDecimal("0");
|
|
|
- BigDecimal totalPublicArea = new BigDecimal("0");
|
|
|
if (!CollectionUtils.isEmpty(buildingInfoVOList)) {
|
|
|
- for (BuildingInfoVO buildingInfoVO : buildingInfoVOList) {
|
|
|
- String commercialArea = buildingInfoVO.getCommercialArea();
|
|
|
- String undergroundGarageArea = buildingInfoVO.getUndergroundGarageArea();
|
|
|
- String totalArea = buildingInfoVO.getTotalArea();
|
|
|
- String publicArea = buildingInfoVO.getPublicArea();
|
|
|
- if (StringUtils.isNotBlank(commercialArea)) {
|
|
|
- totalCommercialArea = totalCommercialArea.add(new BigDecimal(commercialArea));
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(undergroundGarageArea)) {
|
|
|
- totalUndergroundGarageArea = totalUndergroundGarageArea.add(new BigDecimal(undergroundGarageArea));
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(totalArea)) {
|
|
|
- totalBuildingArea = totalBuildingArea.add(new BigDecimal(totalArea));
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(publicArea)) {
|
|
|
- totalPublicArea = totalPublicArea.add(new BigDecimal(publicArea));
|
|
|
- }
|
|
|
- }
|
|
|
+ List<String> commercialAreaList = buildingInfoVOList.stream().map(
|
|
|
+ BuildingInfoVO::getCommercialArea).collect(Collectors.toList());
|
|
|
+ List<String> undergroundGarageAreaList = buildingInfoVOList.stream().map(
|
|
|
+ BuildingInfoVO::getUndergroundGarageArea).collect(Collectors.toList());
|
|
|
+ List<String> totalAreaList = buildingInfoVOList.stream().map(
|
|
|
+ BuildingInfoVO::getTotalArea).collect(Collectors.toList());
|
|
|
+ List<String> publicAreaAreaList = buildingInfoVOList.stream().map(
|
|
|
+ BuildingInfoVO::getPublicArea).collect(Collectors.toList());
|
|
|
+
|
|
|
+ reportProjectVO.setCommercialArea(DataUtils.getSum(commercialAreaList));
|
|
|
+ reportProjectVO.setUndergroundGarageArea(DataUtils.getSum(undergroundGarageAreaList));
|
|
|
+ reportProjectVO.setTotalBuildingArea(DataUtils.getSum(totalAreaList));
|
|
|
+ reportProjectVO.setPublicArea(DataUtils.getSum(publicAreaAreaList));
|
|
|
}
|
|
|
- reportProjectVO.setCommercialArea(totalCommercialArea.toString());
|
|
|
- reportProjectVO.setUndergroundGarageArea(totalUndergroundGarageArea.toString());
|
|
|
- reportProjectVO.setTotalBuildingArea(totalBuildingArea.toString());
|
|
|
- reportProjectVO.setPublicArea(totalPublicArea.toString());
|
|
|
+
|
|
|
return reportProjectVO;
|
|
|
}
|
|
|
|
|
@@ -214,7 +204,7 @@ public class SaasWebServiceImpl implements ISaasWebService {
|
|
|
|
|
|
@Override
|
|
|
public List<PoemsProjectVO> getProjectsByAreaAndBuildingType(String areaCode, String buildingType) {
|
|
|
- if (StringUtils.isBlank(areaCode) || StringUtils.isBlank(areaCode)) {
|
|
|
+ if (StringUtils.isBlank(areaCode) || StringUtils.isBlank(buildingType)) {
|
|
|
return Lists.newArrayList();
|
|
|
}
|
|
|
List<PoemsProjectVO> projectsByArea = getProjectsByArea(areaCode);
|
|
@@ -233,12 +223,27 @@ public class SaasWebServiceImpl implements ISaasWebService {
|
|
|
).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<PoemsProjectVO> getProjectsByBuildingType(String buildingType) {
|
|
|
+ List<PoemsProjectVO> allProjects = getAllProjects();
|
|
|
+ List<String> buildingTypeCodes = getRelatedBuildingTypes(buildingType);
|
|
|
+
|
|
|
+ if (CollectionUtils.isEmpty(buildingTypeCodes)) {
|
|
|
+ return Lists.newArrayList();
|
|
|
+ }
|
|
|
+ return allProjects.stream().
|
|
|
+ filter(
|
|
|
+ poemsProjectVO -> satisfyBuildingTypeAndClimateZone(
|
|
|
+ buildingTypeCodes, null, poemsProjectVO)
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 判断项目是否满足业态和气候区筛选条件
|
|
|
*
|
|
|
* @param allBuildingTypes 所有用来筛选的业态
|
|
|
- * @param climateZoneCode 用来筛选的气候区
|
|
|
- * @param projectVO PoemsProjectVO对象
|
|
|
+ * @param climateZoneCode 用来筛选的气候区
|
|
|
+ * @param projectVO PoemsProjectVO对象
|
|
|
* @return 是否满足条件
|
|
|
* @author lixing
|
|
|
* @version V1.0 2021/6/15 5:12 下午
|
|
@@ -378,6 +383,7 @@ public class SaasWebServiceImpl implements ISaasWebService {
|
|
|
return filterPartitionMap2Tree(filterPartitionMap);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public List<PartitionProjectVO> getAvailableProjectTree(String buildingType) {
|
|
|
// 查询用户权限范围内的分区和项目
|
|
@@ -407,9 +413,9 @@ public class SaasWebServiceImpl implements ISaasWebService {
|
|
|
/**
|
|
|
* 递归过滤用户可用的分区和项目
|
|
|
*
|
|
|
- * @param treeBeforeFilter 需要过滤的树
|
|
|
+ * @param treeBeforeFilter 需要过滤的树
|
|
|
* @param availablePartitionMap 可用分区map
|
|
|
- * @param availableProjectMap 可用项目map
|
|
|
+ * @param availableProjectMap 可用项目map
|
|
|
* @return 用户可用的分区项目树
|
|
|
* @author lixing
|
|
|
* @version V1.0 2021/6/18 11:12 上午
|
|
@@ -666,49 +672,53 @@ public class SaasWebServiceImpl implements ISaasWebService {
|
|
|
|
|
|
@Override
|
|
|
public Double getTotalCommercialArea(List<String> projectIds) {
|
|
|
- if (CollectionUtils.isEmpty(projectIds)) {
|
|
|
- return 0d;
|
|
|
- }
|
|
|
-
|
|
|
- BigDecimal result = new BigDecimal("0");
|
|
|
- for (String projectId : projectIds) {
|
|
|
- ReportProjectVO projectAreas = getProjectAreas(projectId);
|
|
|
- String commercialArea = projectAreas.getCommercialArea();
|
|
|
- result = result.add(new BigDecimal(commercialArea));
|
|
|
- }
|
|
|
- return result.doubleValue();
|
|
|
+ return calculateProjectsArea(projectIds, AreaTypeEnum.COMMERCIAL);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Double getTotalPublicArea(List<String> projectIds) {
|
|
|
- if (CollectionUtils.isEmpty(projectIds)) {
|
|
|
- return 0d;
|
|
|
- }
|
|
|
-
|
|
|
- BigDecimal result = new BigDecimal("0");
|
|
|
- for (String projectId : projectIds) {
|
|
|
- ReportProjectVO projectAreas = getProjectAreas(projectId);
|
|
|
- String publicArea = projectAreas.getPublicArea();
|
|
|
- result = result.add(new BigDecimal(publicArea));
|
|
|
- }
|
|
|
- return result.doubleValue();
|
|
|
+ return calculateProjectsArea(projectIds, AreaTypeEnum.PUBLIC_AREA);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Double getTotalBuildingArea(List<String> projectIds) {
|
|
|
- BigDecimal totalBuildingArea = new BigDecimal("0");
|
|
|
- for (String projectId : projectIds) {
|
|
|
- // 获取项目总的建筑面积
|
|
|
+ return calculateProjectsArea(projectIds, AreaTypeEnum.TOTAL);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算项目的面积总和
|
|
|
+ *
|
|
|
+ * @param projectIds 要计算的项目id列表
|
|
|
+ * @param areaType 面积类型
|
|
|
+ * @return 计算结果
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021/6/23 2:58 下午
|
|
|
+ */
|
|
|
+ private Double calculateProjectsArea(List<String> projectIds, AreaTypeEnum areaType) {
|
|
|
+ if (CollectionUtils.isEmpty(projectIds)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<String> areaList = projectIds.stream().map(projectId -> {
|
|
|
ReportProjectVO reportProjectInfo = getReportProjectInfo(projectId);
|
|
|
if (reportProjectInfo == null) {
|
|
|
return null;
|
|
|
}
|
|
|
- if (StringUtils.isNotBlank(reportProjectInfo.getTotalBuildingArea())) {
|
|
|
- totalBuildingArea = totalBuildingArea.add(new BigDecimal(reportProjectInfo.getTotalBuildingArea()));
|
|
|
+ switch (areaType) {
|
|
|
+ case TOTAL:
|
|
|
+ return reportProjectInfo.getTotalBuildingArea();
|
|
|
+ case PUBLIC_AREA:
|
|
|
+ return reportProjectInfo.getPublicArea();
|
|
|
+ case UNDERGROUND_GARAGE:
|
|
|
+ return reportProjectInfo.getUndergroundGarageArea();
|
|
|
+ case COMMERCIAL:
|
|
|
+ return reportProjectInfo.getCommercialArea();
|
|
|
+ default:
|
|
|
+ return null;
|
|
|
}
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
|
- }
|
|
|
- return totalBuildingArea.doubleValue();
|
|
|
+ String resultStr = DataUtils.getSum(areaList);
|
|
|
+ return StringUtils.isBlank(resultStr)? null: Double.parseDouble(resultStr);
|
|
|
}
|
|
|
|
|
|
@Override
|