浏览代码

因条目中只能给父级功能类型加条目,故在查询时需根据项目id获取对应功能类型父级类型逻辑

wangchenghong 3 年之前
父节点
当前提交
3f02c797d0

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

@@ -11,6 +11,7 @@ import com.persagy.apm.energy.report.manualfilling.service.IEnergyItemDataServic
 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.type.constant.enums.BuildingTypeEnum;
 import com.persagy.apm.energy.report.monthly.functionvalue.model.FunctionValue;
 import com.persagy.apm.energy.report.monthly.functionvalue.model.dto.BatchDeleteFunctionValueDTO;
 import com.persagy.apm.energy.report.monthly.functionvalue.model.dto.QueryFunctionValueDTO;
@@ -49,6 +50,10 @@ public class IEnergyItemDataServiceImpl implements IEnergyItemDataService {
             if (null == projectVO || StringUtils.isEmpty(projectVO.getFunctionType())) {
                 return new ArrayList<>();
             }
+            String buildingType = getParentFuncType(projectVO.getFunctionType());
+            if (null == buildingType) {
+                return new ArrayList<>();
+            }
             QueryFunctionDTO queryFunctionDTO = new QueryFunctionDTO();
             queryFunctionDTO.setGroupCode(groupCode);
             if (!StringUtils.isEmpty(queryEnergyItemDataDTO.getGroupCode())) {
@@ -56,7 +61,7 @@ public class IEnergyItemDataServiceImpl implements IEnergyItemDataService {
             }
             queryFunctionDTO.setEnergyType(queryEnergyItemDataDTO.getEnergyType());
             queryFunctionDTO.setFunctionType(queryEnergyItemDataDTO.getFunctionType());
-            queryFunctionDTO.setBuildingType(projectVO.getFunctionType());
+            queryFunctionDTO.setBuildingType(buildingType);
             // 查询配置的分项信息列表
             List<Function> functionList = functionService.queryFunctionList(queryFunctionDTO);
             if (CollectionUtils.isEmpty(functionList)) {
@@ -114,7 +119,11 @@ public class IEnergyItemDataServiceImpl implements IEnergyItemDataService {
             if (null == projectVO || StringUtils.isEmpty(projectVO.getFunctionType())) {
                 throw new Exception("获取不到项目信息");
             }
-            saveEnergyItemDataDTO.setBuildingType(projectVO.getFunctionType());
+            String buildingType = getParentFuncType(projectVO.getFunctionType());
+            if (null == buildingType) {
+                throw new Exception("获取不到项目功能类型信息");
+            }
+            saveEnergyItemDataDTO.setBuildingType(buildingType);
             List<EnergyItemInfoVo> energyItemInfoVoList = saveEnergyItemDataDTO.getDataList();
             Map<String, String> itemId_functionIdMap = getFunctionIdMap(saveEnergyItemDataDTO);
             for (EnergyItemInfoVo energyItemInfoVo : energyItemInfoVoList) {
@@ -160,4 +169,14 @@ public class IEnergyItemDataServiceImpl implements IEnergyItemDataService {
         return resultMap;
     }
 
+    private String getParentFuncType(String buildingType) {
+        for (BuildingTypeEnum typeEnum : BuildingTypeEnum.values()) {
+            List<String> buildingTypes = iSaasWebService.getRelatedBuildingTypes(typeEnum.getType());
+            if (buildingTypes.contains(buildingType)) {
+                return typeEnum.getType();
+            }
+        }
+        return null;
+    }
+
 }