|
@@ -1,6 +1,11 @@
|
|
|
package com.persagy.apm.energy.report.monthly.outline.service.impl;
|
|
|
|
|
|
import cn.hutool.core.thread.ExecutorBuilder;
|
|
|
+import com.persagy.apm.energy.report.centermiddleware.constant.enums.TimeTypeEnum;
|
|
|
+import com.persagy.apm.energy.report.centermiddleware.model.dto.QueryEnergyDataDTO;
|
|
|
+import com.persagy.apm.energy.report.centermiddleware.model.dto.QueryItemInfoDTO;
|
|
|
+import com.persagy.apm.energy.report.centermiddleware.service.ICenterMiddlewareWebService;
|
|
|
+import com.persagy.apm.energy.report.common.utils.DateUtils;
|
|
|
import com.persagy.apm.energy.report.monthly.config.function.model.Function;
|
|
|
import com.persagy.apm.energy.report.monthly.config.function.service.IFunctionService;
|
|
|
import com.persagy.apm.energy.report.monthly.config.functiongroup.model.FunctionGroup;
|
|
@@ -11,6 +16,7 @@ import com.persagy.apm.energy.report.monthly.config.rel.typefunction.service.IRe
|
|
|
import com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model.ReportTypeFunctionGroupRel;
|
|
|
import com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model.dto.QueryReportTypeFunctionGroupRelDTO;
|
|
|
import com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.service.IReportTypeFunctionGroupRelService;
|
|
|
+import com.persagy.apm.energy.report.monthly.config.type.constant.enums.BelongTypeEnum;
|
|
|
import com.persagy.apm.energy.report.monthly.config.type.constant.enums.BuildingTypeEnum;
|
|
|
import com.persagy.apm.energy.report.monthly.config.type.model.ReportType;
|
|
|
import com.persagy.apm.energy.report.monthly.config.type.service.IReportTypeService;
|
|
@@ -20,17 +26,19 @@ import com.persagy.apm.energy.report.monthly.detail.business.model.vo.GroupInfo;
|
|
|
import com.persagy.apm.energy.report.monthly.detail.business.model.vo.PowerItemVO;
|
|
|
import com.persagy.apm.energy.report.monthly.detail.business.service.IReportBusinessDetailService;
|
|
|
import com.persagy.apm.energy.report.monthly.functionvalue.service.IFunctionValueService;
|
|
|
-import com.persagy.apm.energy.report.monthly.outline.constants.enums.BusinessReportParagraphs;
|
|
|
+import com.persagy.apm.energy.report.monthly.outline.constants.BusinessReportParagraphs;
|
|
|
import com.persagy.apm.energy.report.monthly.outline.constants.enums.ReportStateEnum;
|
|
|
import com.persagy.apm.energy.report.monthly.outline.model.ReportOutline;
|
|
|
+import com.persagy.apm.energy.report.saasweb.model.vo.PoemsProjectVO;
|
|
|
+import com.persagy.apm.energy.report.saasweb.model.vo.SimpleProjectVO;
|
|
|
+import com.persagy.apm.energy.report.saasweb.service.ISaasWebService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.assertj.core.util.Lists;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
@@ -60,7 +68,9 @@ public class GenerateReportThreadPool {
|
|
|
@Autowired
|
|
|
private IFunctionValueService functionValueService;
|
|
|
@Autowired
|
|
|
- private
|
|
|
+ private ICenterMiddlewareWebService centerMiddlewareWebService;
|
|
|
+ @Autowired
|
|
|
+ private ISaasWebService saasWebService;
|
|
|
|
|
|
private final ExecutorService es;
|
|
|
|
|
@@ -113,15 +123,31 @@ public class GenerateReportThreadPool {
|
|
|
String reportTypeId = reportOutline.getReportTypeId();
|
|
|
Date reportMonth = reportOutline.getReportMonth();
|
|
|
|
|
|
+ ReportType reportType = reportTypeService.queryReportTypeDetail(reportTypeId);
|
|
|
+ String belongType = reportType.getBelongType();
|
|
|
+
|
|
|
+ List<String> projectIds = new ArrayList<>();
|
|
|
+ if (BelongTypeEnum.PROJECT.getType().equals(belongType)) {
|
|
|
+ projectIds.add(reportOutline.getBelong());
|
|
|
+ } else {
|
|
|
+ String areaId = reportOutline.getBelong();
|
|
|
+ // 获取区域下的项目
|
|
|
+ List<PoemsProjectVO> projectsByArea = saasWebService.getProjectsByArea(areaId);
|
|
|
+ if (!CollectionUtils.isEmpty(projectsByArea)) {
|
|
|
+ projectIds.addAll(projectsByArea.stream().map(
|
|
|
+ PoemsProjectVO::getProjectId).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 获取在营项目用电量下拥有的信息点分组和信息点
|
|
|
List<String> groupIdList = getGroupsByParagraph(
|
|
|
reportTypeId, BusinessReportParagraphs.OPEN_POWER);
|
|
|
|
|
|
- openPower.setGroups(getPowerGroupInfos(groupIdList, reportMonth));
|
|
|
+ openPower.setGroups(getPowerGroupInfos(groupIdList, reportMonth, projectIds));
|
|
|
|
|
|
List<String> functionIdList = getFunctionsByParagraph(
|
|
|
reportTypeId, BusinessReportParagraphs.OPEN_POWER);
|
|
|
- openPower.setItems(getPowerItemInfos(functionIdList, reportMonth));
|
|
|
+ openPower.setItems(getPowerItemInfos(functionIdList, reportMonth, projectIds));
|
|
|
// TODO: 2021/5/24 计算统计值
|
|
|
// openPower.setSummary();
|
|
|
return openPower;
|
|
@@ -131,24 +157,42 @@ public class GenerateReportThreadPool {
|
|
|
* 获取用电量条目信息
|
|
|
*
|
|
|
* @param functionIdList 用电量条目列表
|
|
|
- * @param reportMonth 报告月份
|
|
|
+ * @param reportMonth 报告月份
|
|
|
* @return 用电量条目列表
|
|
|
* @author lixing
|
|
|
* @version V1.0 2021/5/24 7:15 下午
|
|
|
*/
|
|
|
- private List<PowerItemVO> getPowerItemInfos(List<String> functionIdList, Date reportMonth) {
|
|
|
+ private List<PowerItemVO> getPowerItemInfos(List<String> functionIdList, Date reportMonth, List<String> projectIds) {
|
|
|
List<PowerItemVO> powerItemVOList = Lists.newArrayList();
|
|
|
- if (CollectionUtils.isEmpty(functionIdList)) {
|
|
|
+ if (CollectionUtils.isEmpty(functionIdList) || CollectionUtils.isEmpty(projectIds)) {
|
|
|
return powerItemVOList;
|
|
|
}
|
|
|
+
|
|
|
for (String functionId : functionIdList) {
|
|
|
Function function = functionService.queryFunctionDetail(functionId);
|
|
|
- String itemId = function.getItemId();
|
|
|
- // TODO: 2021/5/24 获取条目名称
|
|
|
- String itemName = "";
|
|
|
+ String itemName = getItemName(function, projectIds.get(0));
|
|
|
PowerItemVO powerItemVO = new PowerItemVO();
|
|
|
powerItemVO.setName(itemName);
|
|
|
- // TODO: 2021/5/24 调用functionValueService获取值
|
|
|
+ for (String projectId : projectIds) {
|
|
|
+ QueryEnergyDataDTO queryEnergyDataDTO = new QueryEnergyDataDTO();
|
|
|
+ // 获取项目信息
|
|
|
+ SimpleProjectVO simpleProjectInfo = saasWebService.getSimpleProjectInfo(projectId);
|
|
|
+ if (simpleProjectInfo == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ queryEnergyDataDTO.setProjectId(simpleProjectInfo.getProjectLocalID());
|
|
|
+ queryEnergyDataDTO.setBuildingId(simpleProjectInfo.getProjectLocalID());
|
|
|
+ queryEnergyDataDTO.setModelCode(function.getModelCode());
|
|
|
+ // 去年一月
|
|
|
+ queryEnergyDataDTO.setStartDate();
|
|
|
+ queryEnergyDataDTO.setEndDate(DateUtils.date2Str(reportMonth, DateUtils.SDF_SECOND));
|
|
|
+ queryEnergyDataDTO.setItemIdList(Lists.newArrayList(function.getItemId()));
|
|
|
+ queryEnergyDataDTO.setTimeType(TimeTypeEnum.MONTH.getType());
|
|
|
+ Map<String, TreeMap<Date, Double>> itemEnergyDataMap = centerMiddlewareWebService.getItemEnergyDataMap(queryEnergyDataDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ // TODO: 2021/5/24 获取值
|
|
|
+
|
|
|
// powerItemVO.setCurrentMonth();
|
|
|
// ...
|
|
|
powerItemVOList.add(powerItemVO);
|
|
@@ -156,16 +200,48 @@ public class GenerateReportThreadPool {
|
|
|
return powerItemVOList;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取条目名称
|
|
|
+ *
|
|
|
+ * @param function 功能点信息
|
|
|
+ * @param projectId 项目id
|
|
|
+ * @return 条目名称
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021/5/28 7:22 下午
|
|
|
+ */
|
|
|
+ private String getItemName(Function function, String projectId) {
|
|
|
+ // 获取项目信息
|
|
|
+ SimpleProjectVO simpleProjectInfo = saasWebService.getSimpleProjectInfo(projectId);
|
|
|
+
|
|
|
+ if (simpleProjectInfo == null) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ QueryItemInfoDTO queryItemInfoDTO = new QueryItemInfoDTO();
|
|
|
+ // 注意这里应该传入项目本地编码
|
|
|
+ queryItemInfoDTO.setProjectId(simpleProjectInfo.getProjectLocalID());
|
|
|
+ queryItemInfoDTO.setBuildingId(simpleProjectInfo.getProjectLocalID());
|
|
|
+ queryItemInfoDTO.setModelCode(function.getModelCode());
|
|
|
+ queryItemInfoDTO.setItemIdList(Lists.newArrayList(function.getItemId()));
|
|
|
+ Map<String, String> itemNameMap = centerMiddlewareWebService.getItemNameMap(queryItemInfoDTO);
|
|
|
+ if (itemNameMap != null) {
|
|
|
+ return itemNameMap.get(function.getItemId());
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取用电量分组信息
|
|
|
*
|
|
|
* @param groupIdList 分组id列表
|
|
|
* @param reportMonth 报告月份
|
|
|
+ * @param projectIds 报告涉及的项目id列表
|
|
|
* @return 分组对象列表
|
|
|
* @author lixing
|
|
|
* @version V1.0 2021/5/24 7:12 下午
|
|
|
*/
|
|
|
- private List<GroupInfo<PowerItemVO>> getPowerGroupInfos(List<String> groupIdList, Date reportMonth) {
|
|
|
+ private List<GroupInfo<PowerItemVO>> getPowerGroupInfos(List<String> groupIdList, Date reportMonth, List<String> projectIds) {
|
|
|
List<GroupInfo<PowerItemVO>> groupInfoList = Lists.newArrayList();
|
|
|
if (CollectionUtils.isEmpty(groupIdList)) {
|
|
|
return groupInfoList;
|
|
@@ -178,7 +254,7 @@ public class GenerateReportThreadPool {
|
|
|
// 获取组下的分项
|
|
|
String functionIdStr = functionGroup.getFunctionIds();
|
|
|
List<String> functionIds = Lists.newArrayList(functionIdStr.split(","));
|
|
|
- List<PowerItemVO> powerItemInfos = getPowerItemInfos(functionIds, reportMonth);
|
|
|
+ List<PowerItemVO> powerItemInfos = getPowerItemInfos(functionIds, reportMonth, projectIds);
|
|
|
groupInfo.setItems(powerItemInfos);
|
|
|
// TODO: 2021/5/24 计算统计值
|
|
|
// groupInfo.setSummary();
|