|
@@ -1,17 +1,19 @@
|
|
-package com.persagy.apm.energy.report.monthly.outline.service.impl;
|
|
|
|
|
|
+package com.persagy.apm.energy.report.monthly.detail.common.service.impl;
|
|
|
|
|
|
import com.persagy.apm.energy.report.common.utils.DataUtils;
|
|
import com.persagy.apm.energy.report.common.utils.DataUtils;
|
|
import com.persagy.apm.energy.report.common.utils.DateUtils;
|
|
import com.persagy.apm.energy.report.common.utils.DateUtils;
|
|
|
|
+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.Function;
|
|
import com.persagy.apm.energy.report.monthly.config.function.service.IFunctionService;
|
|
import com.persagy.apm.energy.report.monthly.config.function.service.IFunctionService;
|
|
import com.persagy.apm.energy.report.monthly.config.functiongroup.model.FunctionGroup;
|
|
import com.persagy.apm.energy.report.monthly.config.functiongroup.model.FunctionGroup;
|
|
import com.persagy.apm.energy.report.monthly.config.functiongroup.service.IFunctionGroupService;
|
|
import com.persagy.apm.energy.report.monthly.config.functiongroup.service.IFunctionGroupService;
|
|
|
|
+import com.persagy.apm.energy.report.monthly.detail.business.service.IBusinessReportCostInfoService;
|
|
import com.persagy.apm.energy.report.monthly.detail.common.model.vo.CostItemVO;
|
|
import com.persagy.apm.energy.report.monthly.detail.common.model.vo.CostItemVO;
|
|
import com.persagy.apm.energy.report.monthly.detail.common.model.vo.CostVO;
|
|
import com.persagy.apm.energy.report.monthly.detail.common.model.vo.CostVO;
|
|
import com.persagy.apm.energy.report.monthly.detail.common.model.vo.GroupInfo;
|
|
import com.persagy.apm.energy.report.monthly.detail.common.model.vo.GroupInfo;
|
|
|
|
+import com.persagy.apm.energy.report.monthly.detail.common.service.IReportCostInfoService;
|
|
import com.persagy.apm.energy.report.monthly.functionvalue.service.IFunctionValueService;
|
|
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.model.ReportOutline;
|
|
-import com.persagy.apm.energy.report.monthly.outline.service.IBusinessReportCostInfoService;
|
|
|
|
import com.persagy.apm.energy.report.monthly.outline.service.IReportOutlineService;
|
|
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.ReportProjectVO;
|
|
import com.persagy.apm.energy.report.saasweb.service.ISaasWebService;
|
|
import com.persagy.apm.energy.report.saasweb.service.ISaasWebService;
|
|
@@ -33,7 +35,7 @@ import java.util.stream.Collectors;
|
|
* @version V1.0 2021/5/30 7:30 下午
|
|
* @version V1.0 2021/5/30 7:30 下午
|
|
**/
|
|
**/
|
|
@Service
|
|
@Service
|
|
-public class BusinessReportCostInfoServiceImpl implements IBusinessReportCostInfoService {
|
|
|
|
|
|
+public class ReportCostInfoServiceImpl implements IReportCostInfoService {
|
|
@Autowired
|
|
@Autowired
|
|
private IFunctionGroupService functionGroupService;
|
|
private IFunctionGroupService functionGroupService;
|
|
@Autowired
|
|
@Autowired
|
|
@@ -42,63 +44,6 @@ public class BusinessReportCostInfoServiceImpl implements IBusinessReportCostInf
|
|
private IFunctionValueService functionValueService;
|
|
private IFunctionValueService functionValueService;
|
|
@Autowired
|
|
@Autowired
|
|
private ISaasWebService saasWebService;
|
|
private ISaasWebService saasWebService;
|
|
- @Autowired
|
|
|
|
- private IReportOutlineService reportOutlineService;
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public CostVO getOpenCost(ReportOutline reportOutline, List<String> groupIdList, List<String> functionIdList) {
|
|
|
|
-
|
|
|
|
- Date reportMonth = reportOutline.getReportMonth();
|
|
|
|
-
|
|
|
|
- List<String> projectIds = reportOutlineService.queryRelatedProjectIds(reportOutline);
|
|
|
|
-
|
|
|
|
- return getCostInfoByProjectIds(groupIdList, functionIdList, reportMonth, projectIds);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public CostVO getCompareCost(ReportOutline reportOutline, List<String> groupIdList, List<String> functionIdList) {
|
|
|
|
-
|
|
|
|
- Date reportMonth = reportOutline.getReportMonth();
|
|
|
|
-
|
|
|
|
- List<String> projectIds = reportOutlineService.queryRelatedProjectIds(reportOutline);
|
|
|
|
-
|
|
|
|
- List<String> comparableProjects = saasWebService.getComparableProjects(projectIds, reportMonth);
|
|
|
|
-
|
|
|
|
- return getCostInfoByProjectIds(groupIdList, functionIdList, reportMonth, comparableProjects);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 根据项目id获取费用信息
|
|
|
|
- *
|
|
|
|
- * @param groupIdList 费用信息点分组列表
|
|
|
|
- * @param functionIdList 费用信息点列表
|
|
|
|
- * @param reportMonth 报告月份
|
|
|
|
- * @param projectIds 项目id列表
|
|
|
|
- * @return 费用信息
|
|
|
|
- * @author lixing
|
|
|
|
- * @version V1.0 2021/5/30 11:41 下午
|
|
|
|
- */
|
|
|
|
- private CostVO getCostInfoByProjectIds(List<String> groupIdList, List<String> functionIdList, Date reportMonth, List<String> projectIds) {
|
|
|
|
- CostVO costVO = new CostVO();
|
|
|
|
- List<GroupInfo<CostItemVO>> costGroupInfos = getCostGroupInfos(groupIdList, reportMonth, projectIds);
|
|
|
|
- costVO.setGroups(costGroupInfos);
|
|
|
|
-
|
|
|
|
- List<CostItemVO> costItemInfos = getCostItemInfos(functionIdList, reportMonth, projectIds);
|
|
|
|
- costVO.setItems(costItemInfos);
|
|
|
|
-
|
|
|
|
- List<CostItemVO> paragraphSums = new ArrayList<>();
|
|
|
|
-
|
|
|
|
- if (!CollectionUtils.isEmpty(costGroupInfos)) {
|
|
|
|
- paragraphSums.addAll(
|
|
|
|
- costGroupInfos.stream().map(GroupInfo::getSummary).collect(Collectors.toList()));
|
|
|
|
- }
|
|
|
|
- if (!CollectionUtils.isEmpty(costItemInfos)) {
|
|
|
|
- paragraphSums.addAll(costItemInfos);
|
|
|
|
- }
|
|
|
|
- costVO.setSummary(getCostSum(paragraphSums));
|
|
|
|
- return costVO;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<CostItemVO> getCostItemInfos(List<String> functionIdList, Date reportMonth, List<String> projectIds) {
|
|
public List<CostItemVO> getCostItemInfos(List<String> functionIdList, Date reportMonth, List<String> projectIds) {
|
|
@@ -125,8 +70,9 @@ public class BusinessReportCostInfoServiceImpl implements IBusinessReportCostInf
|
|
if (CollectionUtils.isEmpty(projectIds)) {
|
|
if (CollectionUtils.isEmpty(projectIds)) {
|
|
return projectCostItems;
|
|
return projectCostItems;
|
|
}
|
|
}
|
|
|
|
+
|
|
// 统计项目总的商业面积
|
|
// 统计项目总的商业面积
|
|
- Double totalCommercialArea = saasWebService.getTotalCommercialArea(projectIds);
|
|
|
|
|
|
+ Double projectCostBuildingArea = getProjectCostBuildingArea(projectIds);
|
|
|
|
|
|
for (String projectId : projectIds) {
|
|
for (String projectId : projectIds) {
|
|
// 获取项目信息
|
|
// 获取项目信息
|
|
@@ -134,33 +80,47 @@ public class BusinessReportCostInfoServiceImpl implements IBusinessReportCostInf
|
|
if (reportProjectInfo == null) {
|
|
if (reportProjectInfo == null) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- CostItemVO costItemVO = getCostItemInfo(reportMonth, reportProjectInfo, totalCommercialArea, function.getId());
|
|
|
|
|
|
+ CostItemVO costItemVO = getCostItemInfo(reportMonth, projectId, projectCostBuildingArea, function);
|
|
projectCostItems.add(costItemVO);
|
|
projectCostItems.add(costItemVO);
|
|
}
|
|
}
|
|
return projectCostItems;
|
|
return projectCostItems;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ public Double getProjectCostBuildingArea(List<String> projectIds) {
|
|
|
|
+ return saasWebService.getTotalCommercialArea(projectIds);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
public CostItemVO getCostItemInfo(
|
|
public CostItemVO getCostItemInfo(
|
|
- Date reportMonth, ReportProjectVO reportProjectInfo,
|
|
|
|
- Double totalCommercialArea, String functionId) {
|
|
|
|
- // 费用展示为万元,定义一万元变量
|
|
|
|
- Double tenThousand = 10000d;
|
|
|
|
- String projectId = reportProjectInfo.getProjectId();
|
|
|
|
|
|
+ Date reportMonth, String projectId,
|
|
|
|
+ Double costBuildingArea, Function function) {
|
|
|
|
+ if (function == null) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ String functionId = function.getId();
|
|
|
|
+ String functionType = function.getFunctionType();
|
|
|
|
+ // 单位
|
|
|
|
+ double unit = 1d;
|
|
|
|
+ // 费用展示为万元
|
|
|
|
+ if (FunctionTypeEnum.COST.getType().equals(functionType)) {
|
|
|
|
+ unit = 10000d;
|
|
|
|
+ }
|
|
|
|
+
|
|
CostItemVO costItemVO = new CostItemVO();
|
|
CostItemVO costItemVO = new CostItemVO();
|
|
String currentMonthStr = functionValueService.getFunctionValue(functionId, reportMonth, projectId);
|
|
String currentMonthStr = functionValueService.getFunctionValue(functionId, reportMonth, projectId);
|
|
Double currentMonth = null;
|
|
Double currentMonth = null;
|
|
|
|
|
|
if (StringUtils.isNotBlank(currentMonthStr)) {
|
|
if (StringUtils.isNotBlank(currentMonthStr)) {
|
|
currentMonth = Double.valueOf(currentMonthStr);
|
|
currentMonth = Double.valueOf(currentMonthStr);
|
|
- costItemVO.setCurrentMonth(DataUtils.doubleDivide(currentMonth, tenThousand));
|
|
|
|
|
|
+ costItemVO.setCurrentMonth(DataUtils.doubleDivide(currentMonth, unit));
|
|
}
|
|
}
|
|
String lastMonthStr = functionValueService.getFunctionValue(
|
|
String lastMonthStr = functionValueService.getFunctionValue(
|
|
functionId, DateUtils.getFirstDayOfLastMonth(reportMonth), projectId);
|
|
functionId, DateUtils.getFirstDayOfLastMonth(reportMonth), projectId);
|
|
Double lastMonth = null;
|
|
Double lastMonth = null;
|
|
if (StringUtils.isNotBlank(lastMonthStr)) {
|
|
if (StringUtils.isNotBlank(lastMonthStr)) {
|
|
lastMonth = Double.valueOf(lastMonthStr);
|
|
lastMonth = Double.valueOf(lastMonthStr);
|
|
- costItemVO.setLastMonth(DataUtils.doubleDivide(lastMonth, tenThousand));
|
|
|
|
|
|
+ costItemVO.setLastMonth(DataUtils.doubleDivide(lastMonth, unit));
|
|
}
|
|
}
|
|
|
|
|
|
// 统计去年同期的费用
|
|
// 统计去年同期的费用
|
|
@@ -182,10 +142,10 @@ public class BusinessReportCostInfoServiceImpl implements IBusinessReportCostInf
|
|
if (lastYearSumItem != null) {
|
|
if (lastYearSumItem != null) {
|
|
lastYearCount = lastYearSumItem.getLastYearCount();
|
|
lastYearCount = lastYearSumItem.getLastYearCount();
|
|
if (lastYearCount != null) {
|
|
if (lastYearCount != null) {
|
|
- costItemVO.setLastYearCount(DataUtils.doubleDivide(lastYearCount, tenThousand));
|
|
|
|
|
|
+ costItemVO.setLastYearCount(DataUtils.doubleDivide(lastYearCount, unit));
|
|
}
|
|
}
|
|
- if (totalCommercialArea != null && !totalCommercialArea.equals(zero) && lastYearCount != null) {
|
|
|
|
- costItemVO.setLastYearPerCount(DataUtils.doubleDivide(lastYearCount, totalCommercialArea));
|
|
|
|
|
|
+ if (costBuildingArea != null && !costBuildingArea.equals(zero) && lastYearCount != null) {
|
|
|
|
+ costItemVO.setLastYearPerCount(DataUtils.doubleDivide(lastYearCount, costBuildingArea));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -208,23 +168,23 @@ public class BusinessReportCostInfoServiceImpl implements IBusinessReportCostInf
|
|
if (yearSumItem != null) {
|
|
if (yearSumItem != null) {
|
|
yearCount = yearSumItem.getYearCount();
|
|
yearCount = yearSumItem.getYearCount();
|
|
if (yearCount != null) {
|
|
if (yearCount != null) {
|
|
- costItemVO.setYearCount(DataUtils.doubleDivide(yearCount, tenThousand));
|
|
|
|
|
|
+ costItemVO.setYearCount(DataUtils.doubleDivide(yearCount, unit));
|
|
}
|
|
}
|
|
- if (totalCommercialArea != null && !totalCommercialArea.equals(zero) && yearCount != null) {
|
|
|
|
- costItemVO.setYearPerCount(DataUtils.doubleDivide(yearCount, totalCommercialArea));
|
|
|
|
|
|
+ if (costBuildingArea != null && !costBuildingArea.equals(zero) && yearCount != null) {
|
|
|
|
+ costItemVO.setYearPerCount(DataUtils.doubleDivide(yearCount, costBuildingArea));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (currentMonth != null && lastMonth != null) {
|
|
if (currentMonth != null && lastMonth != null) {
|
|
Double linkCount = DataUtils.doubleSubtract(currentMonth, lastMonth);
|
|
Double linkCount = DataUtils.doubleSubtract(currentMonth, lastMonth);
|
|
Double linkRange = DataUtils.doubleDivide(linkCount, lastMonth);
|
|
Double linkRange = DataUtils.doubleDivide(linkCount, lastMonth);
|
|
- costItemVO.setLinkCount(DataUtils.doubleDivide(linkCount, tenThousand));
|
|
|
|
|
|
+ costItemVO.setLinkCount(DataUtils.doubleDivide(linkCount, unit));
|
|
costItemVO.setLinkRange(linkRange);
|
|
costItemVO.setLinkRange(linkRange);
|
|
}
|
|
}
|
|
|
|
|
|
if (lastYearCount != null && yearCount != null) {
|
|
if (lastYearCount != null && yearCount != null) {
|
|
double sameCount = DataUtils.doubleSubtract(yearCount, lastYearCount);
|
|
double sameCount = DataUtils.doubleSubtract(yearCount, lastYearCount);
|
|
- costItemVO.setSameCount(DataUtils.doubleDivide(sameCount, tenThousand));
|
|
|
|
|
|
+ costItemVO.setSameCount(DataUtils.doubleDivide(sameCount, unit));
|
|
costItemVO.setSameRange(DataUtils.doubleDivide(sameCount, lastYearCount));
|
|
costItemVO.setSameRange(DataUtils.doubleDivide(sameCount, lastYearCount));
|
|
}
|
|
}
|
|
return costItemVO;
|
|
return costItemVO;
|