Browse Source

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

lixing 3 years ago
parent
commit
ebf3429782

+ 2 - 1
src/main/java/com/persagy/apm/energy/report/manualfilling/service/IManualFilliingService.java

@@ -2,7 +2,8 @@ package com.persagy.apm.energy.report.manualfilling.service;
 
 import java.util.Date;
 
-public interface IManualFilliingService {
+
+public interface IManualFillingService {
 
     /**
      *

+ 2 - 2
src/main/java/com/persagy/apm/energy/report/manualfilling/service/impl/IManualFilliingServiceImpl.java

@@ -5,7 +5,7 @@ import com.persagy.apm.energy.report.common.utils.DateUtils;
 import com.persagy.apm.energy.report.manualfilling.client.ManualFillingWebClient;
 import com.persagy.apm.energy.report.manualfilling.model.dto.QueryIndicatorFillingDataDTO;
 import com.persagy.apm.energy.report.manualfilling.model.vo.IndicatorFillingDataVo;
-import com.persagy.apm.energy.report.manualfilling.service.IManualFilliingService;
+import com.persagy.apm.energy.report.manualfilling.service.IManualFillingService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -16,7 +16,7 @@ import java.util.List;
 
 @Service
 @Slf4j
-public class IManualFilliingServiceImpl implements IManualFilliingService {
+public class IManualFillingServiceImpl implements IManualFillingService {
     @Autowired
     ManualFillingWebClient ManualFillingWebClient;
 

+ 6 - 6
src/main/java/com/persagy/apm/energy/report/monthly/detail/hotel/project/model/vo/HotelProjectCostInfo.java

@@ -24,12 +24,12 @@ public class HotelProjectCostInfo {
     private Double costPerSquareMetre;
     @ApiModelProperty(value = "费用月同比涨幅")
     private Double costSameTimeRange;
-//    @ApiModelProperty(value = "入住率")
-//    private Double occupancy;
-//    @ApiModelProperty(value = "入住率同比涨幅")
-//    private Double occupancyYearRange;
-//    @ApiModelProperty(value = "入住率环比涨幅")
-//    private Double occupancyMonthRange;
+    @ApiModelProperty(value = "入住率")
+    private Double occupancy;
+    @ApiModelProperty(value = "入住率同比涨幅")
+    private Double occupancyYearRange;
+    @ApiModelProperty(value = "入住率环比涨幅")
+    private Double occupancyMonthRange;
     @ApiModelProperty(value = "条目费用信息")
     private List<CostItemVO> itemsCostInfo;
 }

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

@@ -1,18 +1,18 @@
 package com.persagy.apm.energy.report.monthly.detail.hotel.project.service.impl;
 
+import com.persagy.apm.energy.report.common.utils.DataUtils;
+import com.persagy.apm.energy.report.common.utils.DateUtils;
+import com.persagy.apm.energy.report.manualfilling.service.IManualFillingService;
 import com.persagy.apm.energy.report.monthly.config.function.constant.enums.FunctionTypeEnum;
 import com.persagy.apm.energy.report.monthly.config.function.model.Function;
 import com.persagy.apm.energy.report.monthly.config.function.model.dto.QueryFunctionDTO;
 import com.persagy.apm.energy.report.monthly.config.function.service.IFunctionService;
-import com.persagy.apm.energy.report.monthly.config.functiongroup.service.IFunctionGroupService;
 import com.persagy.apm.energy.report.monthly.detail.common.model.vo.CostItemVO;
 import com.persagy.apm.energy.report.monthly.detail.common.service.impl.ReportCostInfoServiceImpl;
 import com.persagy.apm.energy.report.monthly.detail.hotel.project.model.vo.HotelProjectCostInfo;
 import com.persagy.apm.energy.report.monthly.detail.hotel.project.service.IHotelProjectReportCostService;
-import com.persagy.apm.energy.report.monthly.functionvalue.service.IFunctionValueService;
 import com.persagy.apm.energy.report.monthly.outline.model.ReportOutline;
 import com.persagy.apm.energy.report.monthly.outline.service.IReportOutlineService;
-import com.persagy.apm.energy.report.saasweb.model.vo.ReportProjectVO;
 import com.persagy.apm.energy.report.saasweb.model.vo.SimpleProjectVO;
 import com.persagy.apm.energy.report.saasweb.service.ISaasWebService;
 import org.apache.commons.lang.StringUtils;
@@ -21,7 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
-import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -41,6 +40,8 @@ public class HotelProjectReportCostServiceImpl extends ReportCostInfoServiceImpl
     private ISaasWebService saasWebService;
     @Autowired
     private IReportOutlineService reportOutlineService;
+    @Autowired
+    private IManualFillingService manualFillingService;
 
     @Override
     public HotelProjectCostInfo getCost(ReportOutline reportOutline, List<String> functionIdList) {
@@ -63,6 +64,40 @@ public class HotelProjectReportCostServiceImpl extends ReportCostInfoServiceImpl
         }
         hotelProjectCostInfo.setProjectName(simpleProjectInfo.getProjectName());
 
+        // 获取入住率
+        String occupancyRateCurrentMonth = manualFillingService.getIndicatorFillingData(
+                simpleProjectInfo.getProjectLocalID(), "occupancyRate",
+                2, reportMonth, DateUtils.getMonthOff(reportMonth, 1));
+        // 去年同期入住率
+        Date lastYearSameTime = DateUtils.getSameMonthFirstDayOfLastYear(reportMonth);
+        String occupancyRateLastYearSameTime = manualFillingService.getIndicatorFillingData(
+                simpleProjectInfo.getProjectLocalID(), "occupancyRate",
+                2, lastYearSameTime, DateUtils.getMonthOff(lastYearSameTime, 1));
+        // 上个月入住率
+        String occupancyRateLastMonth = manualFillingService.getIndicatorFillingData(
+                simpleProjectInfo.getProjectLocalID(), "occupancyRate",
+                2, DateUtils.getFirstDayOfLastMonth(reportMonth), reportMonth);
+
+        if (StringUtils.isNotBlank(occupancyRateCurrentMonth)) {
+            double occupancy = Double.parseDouble(occupancyRateCurrentMonth);
+            hotelProjectCostInfo.setOccupancy(occupancy);
+            // 入住率同比增长
+            if (StringUtils.isNotBlank(occupancyRateLastYearSameTime)) {
+                double occupancyLastYearSameTime = Double.parseDouble(occupancyRateLastYearSameTime);
+                Double growth = DataUtils.doubleSubtract(occupancy, occupancyLastYearSameTime);
+                hotelProjectCostInfo.setOccupancyYearRange(DataUtils.doubleDivide(growth, occupancyLastYearSameTime));
+            }
+            // 入住率环比增长
+            if (StringUtils.isNotBlank(occupancyRateLastMonth)) {
+                double occupancyLastMonth = Double.parseDouble(occupancyRateLastMonth);
+                Double growth = DataUtils.doubleSubtract(occupancy, occupancyLastMonth);
+                hotelProjectCostInfo.setOccupancyMonthRange(DataUtils.doubleDivide(growth, occupancyLastMonth));
+            }
+        }
+
+
+
+        // 具体的费用条目
         List<CostItemVO> costItemInfos = getCostItemInfos(functionIdList, reportMonth, Lists.newArrayList(projectId));
         hotelProjectCostInfo.setItemsCostInfo(costItemInfos);
 

+ 4 - 2
src/main/java/com/persagy/apm/energy/report/monthly/outline/service/impl/ReportOutlineServiceImpl.java

@@ -359,6 +359,7 @@ public class ReportOutlineServiceImpl extends ServiceImpl<ReportOutlineMapper, R
     @Override
     public List<String> queryRelatedProjectIds(ReportOutline reportOutline) {
         String belongType = getBelongType(reportOutline);
+        String buildingType = getBuildingType(reportOutline);
 
         List<String> projectIds = new ArrayList<>();
         if (BelongTypeEnum.PROJECT.getType().equals(belongType)) {
@@ -366,7 +367,7 @@ public class ReportOutlineServiceImpl extends ServiceImpl<ReportOutlineMapper, R
         } else {
             String areaId = reportOutline.getBelong();
             // 获取区域下的项目
-            List<PoemsProjectVO> projectsByArea = saasWebService.getProjectsByArea(areaId);
+            List<PoemsProjectVO> projectsByArea = saasWebService.getProjectsByAreaAndBuildingType(areaId, buildingType);
             if (!CollectionUtils.isEmpty(projectsByArea)) {
                 projectIds.addAll(projectsByArea.stream().map(
                         PoemsProjectVO::getProjectId).collect(Collectors.toList()));
@@ -378,6 +379,7 @@ public class ReportOutlineServiceImpl extends ServiceImpl<ReportOutlineMapper, R
     @Override
     public List<SimpleProjectVO> queryRelatedProjects(ReportOutline reportOutline) {
         String belongType = getBelongType(reportOutline);
+        String buildingType = getBuildingType(reportOutline);
 
         List<SimpleProjectVO> projects = new ArrayList<>();
         if (BelongTypeEnum.PROJECT.getType().equals(belongType)) {
@@ -385,7 +387,7 @@ public class ReportOutlineServiceImpl extends ServiceImpl<ReportOutlineMapper, R
         } else {
             String areaId = reportOutline.getBelong();
             // 获取区域下的项目
-            List<PoemsProjectVO> projectsByArea = saasWebService.getProjectsByArea(areaId);
+            List<PoemsProjectVO> projectsByArea = saasWebService.getProjectsByAreaAndBuildingType(areaId, buildingType);
             if (!CollectionUtils.isEmpty(projectsByArea)) {
                 projects.addAll(projectsByArea.stream().map(
                         ConvertSaasWebTool.INSTANCE::convert2SimpleProjectVO

+ 13 - 0
src/main/java/com/persagy/apm/energy/report/saasweb/service/ISaasWebService.java

@@ -128,6 +128,8 @@ public interface ISaasWebService {
     /**
      * 根据气候带和建筑类型获取项目
      *
+     * @param climateZoneCode  气候区编码
+     * @param buildingTypeCode 业态编码
      * @return 项目列表
      * @author lixing
      * @version V1.0 2021/5/24 5:37 下午
@@ -135,6 +137,17 @@ public interface ISaasWebService {
     List<PoemsProjectVO> getProjectsByClimateAndBuildingType(String climateZoneCode, String buildingTypeCode);
 
     /**
+     * 根据区域和业态过滤项目
+     *
+     * @param areaCode     区域编码
+     * @param buildingType 业态
+     * @return 项目列表
+     * @author lixing
+     * @version V1.0 2021/5/24 6:01 下午
+     */
+    List<PoemsProjectVO> getProjectsByAreaAndBuildingType(String areaCode, String buildingType);
+
+    /**
      * 根据业态获取用户可选的项目
      *
      * @param buildingType 项目业态

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

@@ -211,17 +211,8 @@ public class SaasWebServiceImpl implements ISaasWebService {
                 ).collect(Collectors.toList());
     }
 
-
-    /**
-     * 根据区域和业态过滤项目
-     *
-     * @param areaCode     区域编码
-     * @param buildingType 业态
-     * @return 项目列表
-     * @author lixing
-     * @version V1.0 2021/5/24 6:01 下午
-     */
-    private List<PoemsProjectVO> getProjectsByAreaAndBuildingType(String areaCode, String buildingType) {
+    @Override
+    public List<PoemsProjectVO> getProjectsByAreaAndBuildingType(String areaCode, String buildingType) {
         if (StringUtils.isBlank(areaCode) || StringUtils.isBlank(areaCode)) {
             return Lists.newArrayList();
         }
@@ -588,12 +579,13 @@ public class SaasWebServiceImpl implements ISaasWebService {
             Set<String> projectIds = projects.stream().
                     map(SimpleProjectVO::getProjectId).collect(Collectors.toSet());
             // 取用户可选项目和分区下项目的交集,projectIds会被更新为两个集合的交集
-            availableProjectIds.retainAll(projectIds);
+            projectIds.retainAll(availableProjectIds);
             // 根据业态和分区过滤项目
             List<PoemsProjectVO> projectsByAreaAndBuildingType = getProjectsByAreaAndBuildingType(partition.getAreaId(), buildingType);
             Set<String> projectIdsByAreaAndBuildingType = projectsByAreaAndBuildingType.stream().
                     map(PoemsProjectVO::getProjectId).collect(Collectors.toSet());
-            availableProjectIds.retainAll(projectIdsByAreaAndBuildingType);
+            projectIdsByAreaAndBuildingType.retainAll(availableProjectIds);
+            // 如果用户拥有的项目数和分区下的项目数不一致,则用户没有该分区的权限
             if (CollectionUtils.isEmpty(projectIds) || projectIdsByAreaAndBuildingType.size() != projectIds.size()) {
                 continue;
             }