Bladeren bron

生成酒店项目报告自测bug修复

lixing 3 jaren geleden
bovenliggende
commit
d2bd767b07

+ 11 - 5
src/main/java/com/persagy/apm/energy/report/monthly/detail/common/service/impl/ReportCostInfoServiceImpl.java

@@ -195,16 +195,20 @@ public abstract class ReportCostInfoServiceImpl implements IReportCostInfoServic
         // 环比
         if (currentMonth != null && lastMonth != null) {
             Double linkCount = DataUtils.doubleSubtract(currentMonth, lastMonth);
-            Double linkRange = DataUtils.doubleDivide(linkCount, lastMonth);
             costItemVO.setLinkCount(DataUtils.doubleDivide(linkCount, unit));
-            costItemVO.setLinkRange(linkRange);
+            if (!lastMonth.equals(zero)) {
+                Double linkRange = DataUtils.doubleDivide(linkCount, lastMonth);
+                costItemVO.setLinkRange(linkRange);
+            }
         }
 
         // 累计同比
         if (lastYearCount != null && yearCount != null) {
             double sameCount = DataUtils.doubleSubtract(yearCount, lastYearCount);
             costItemVO.setSameCount(DataUtils.doubleDivide(sameCount, unit));
-            costItemVO.setSameRange(DataUtils.doubleDivide(sameCount, lastYearCount));
+            if (!lastYearCount.equals(zero)) {
+                costItemVO.setSameRange(DataUtils.doubleDivide(sameCount, lastYearCount));
+            }
         }
 
         // 去年同期月
@@ -214,8 +218,10 @@ public abstract class ReportCostInfoServiceImpl implements IReportCostInfoServic
             double sameTimeGrowth = DataUtils.doubleSubtract(currentMonth, lastYearSameTimeValue);
             // 月同比增量
             costItemVO.setSameTimeGrowth(sameTimeGrowth);
-            // 月同比增幅
-            costItemVO.setSameTimeRange(DataUtils.doubleDivide(sameTimeGrowth, lastYearSameTimeValue));
+            if (!lastYearSameTimeValue.equals(zero)) {
+                // 月同比增幅
+                costItemVO.setSameTimeRange(DataUtils.doubleDivide(sameTimeGrowth, lastYearSameTimeValue));
+            }
         }
 
         return costItemVO;

+ 5 - 4
src/main/java/com/persagy/apm/energy/report/monthly/detail/hotel/project/service/impl/HotelProjectReportPublicPowerInfoServiceImpl.java

@@ -84,10 +84,11 @@ public class HotelProjectReportPublicPowerInfoServiceImpl extends ReportPowerInf
     private String getGuideValue(String projectId) {
         ConcurrentMap<String, String> guideValueMap = Maps.newConcurrentMap();
         // 严寒地区和寒冷地区:80 kWh/㎡;夏热冬冷地区:135 kWh/㎡;夏热冬暖地区:110 kWh/㎡;温和地区:60 kWh/㎡
-        guideValueMap.put("1", "80 kWh/㎡");
-        guideValueMap.put("2", "135 kWh/㎡");
-        guideValueMap.put("3", "110 kWh/㎡");
-        guideValueMap.put("4", "60 kWh/㎡");
+        guideValueMap.put("10", "80 kWh/㎡");
+        guideValueMap.put("20", "80 kWh/㎡");
+        guideValueMap.put("30", "135 kWh/㎡");
+        guideValueMap.put("40", "110 kWh/㎡");
+        guideValueMap.put("50", "60 kWh/㎡");
 
         // 获取项目所在的气候区
         SimpleProjectVO simpleProjectInfo = saasWebService.getSimpleProjectInfo(projectId);

+ 0 - 4
src/main/java/com/persagy/apm/energy/report/saasweb/model/vo/PoemsProjectVO.java

@@ -19,12 +19,8 @@ public class PoemsProjectVO {
     private String projectLocalID;
     @ApiModelProperty(value = "项目本地名称")
     private String projectLocalName;
-    @ApiModelProperty(value = "项目功能类型")
-    private String functionType;
     @ApiModelProperty(value = "项目功能类型名称")
     private String functionTypeName;
     @ApiModelProperty(value = "项目开业时间")
     private String businessOpeningTime;
-    @ApiModelProperty(value = "气候区")
-    private String climateZone;
 }

+ 42 - 9
src/main/java/com/persagy/apm/energy/report/saasweb/service/impl/SaasWebServiceImpl.java

@@ -206,9 +206,8 @@ public class SaasWebServiceImpl implements ISaasWebService {
         }
         return allProjects.stream().
                 filter(
-                        poemsProjectVO -> StringUtils.isNotBlank(poemsProjectVO.getFunctionType()) &&
-                                buildingTypeCodes.contains(poemsProjectVO.getFunctionType()) &&
-                                climateZoneCode.equals(poemsProjectVO.getClimateZone())
+                        poemsProjectVO -> satisfyBuildingTypeAndClimateZone(
+                                buildingTypeCodes, climateZoneCode, poemsProjectVO.getProjectId())
                 ).collect(Collectors.toList());
     }
 
@@ -237,9 +236,43 @@ public class SaasWebServiceImpl implements ISaasWebService {
         }
         return projectsByArea.stream().
                 filter(
-                        poemsProjectVO -> StringUtils.isNotBlank(poemsProjectVO.getFunctionType()) &&
-                                buildingTypes.contains(poemsProjectVO.getFunctionType())).
-                collect(Collectors.toList());
+                        poemsProjectVO -> satisfyBuildingTypeAndClimateZone(
+                                buildingTypes, null, poemsProjectVO.getProjectId())
+                ).collect(Collectors.toList());
+    }
+
+    /**
+     * 判断项目是否满足业态和气候区筛选条件
+     *
+     * @param allBuildingTypes 所有用来筛选的业态
+     * @param climateZoneCode 用来筛选的气候区
+     * @param projectId 项目id
+     * @return 是否满足条件
+     * @author lixing
+     * @version V1.0 2021/6/15 5:12 下午
+     */
+    private boolean satisfyBuildingTypeAndClimateZone(
+            List<String> allBuildingTypes, String climateZoneCode, String projectId) {
+
+
+        if (StringUtils.isBlank(projectId)) {
+            return false;
+        }
+
+        SimpleProjectVO simpleProjectInfo = getSimpleProjectInfo(projectId);
+        boolean result = true;
+        // 如果要过滤的建筑类型不为空,根据建筑类型过滤
+        if (!CollectionUtils.isEmpty(allBuildingTypes)) {
+            result = result && StringUtils.isNotBlank(simpleProjectInfo.getFunctionType()) &&
+                    allBuildingTypes.contains(simpleProjectInfo.getFunctionType());
+        }
+
+        // 如果要过滤的气候区不为空,根据气候区过滤
+        if (StringUtils.isNotBlank(climateZoneCode)) {
+            result = result && climateZoneCode.equals(simpleProjectInfo.getClimateZone());
+        }
+
+        return result;
     }
 
     @Override
@@ -258,8 +291,8 @@ public class SaasWebServiceImpl implements ISaasWebService {
             if (userProjectsInfoVO != null) {
                 List<PoemsProjectVO> projects = userProjectsInfoVO.getProjects();
                 projects = projects.stream().filter(
-                        poemsProjectVO -> StringUtils.isNotBlank(poemsProjectVO.getFunctionType()) &&
-                                buildingTypes.contains(poemsProjectVO.getFunctionType())
+                        poemsProjectVO -> satisfyBuildingTypeAndClimateZone(
+                                buildingTypes, null, poemsProjectVO.getProjectId())
                 ).collect(Collectors.toList());
                 List<SimpleProjectVO> simpleProjectVOList = ConvertSaasWebTool.INSTANCE.convert2SimpleProjectVOList(projects);
                 result.addAll(simpleProjectVOList);
@@ -666,7 +699,7 @@ public class SaasWebServiceImpl implements ISaasWebService {
     /**
      * 如果开业时间早于报告月份上一年一月一日,项目为可同比项目
      *
-     * @param reportMonth 报告月份
+     * @param reportMonth         报告月份
      * @param businessOpeningTime 开业时间
      * @return 是否是可同比项目
      * @author lixing

+ 1 - 3
src/main/resources/bootstrap.yml

@@ -2,10 +2,8 @@ spring:
   application:
     name: energy-report
 
-#EUREKA_CLIENT_DEFAULT_ZONE: http://frame:123456@develop.persagy.com/integrated-eureka/eureka/
-EUREKA_CLIENT_DEFAULT_ZONE: http://pbsage:123456@192.168.100.107:9931/eureka/
+EUREKA_CLIENT_DEFAULT_ZONE: http://frame:123456@develop.persagy.com/integrated-eureka/eureka/
 #EUREKA_CLIENT_DEFAULT_ZONE: http://pbsage:123456@hr.persagy.com/poems-eureka/eureka/
-CONFIG_SERVER_ID: poems-config