|
@ -1,5 +1,7 @@ |
|
|
package com.lzbi.report.service; |
|
|
package com.lzbi.report.service; |
|
|
|
|
|
|
|
|
|
|
|
import com.lzbi.asset.domain.DcBaseAssetInfo; |
|
|
|
|
|
import com.lzbi.asset.mapper.DcBaseAssetInfoMapper; |
|
|
import com.lzbi.common.constant.BizConstants; |
|
|
import com.lzbi.common.constant.BizConstants; |
|
|
import com.lzbi.common.constant.ParamsModelCodeConstants; |
|
|
import com.lzbi.common.constant.ParamsModelCodeConstants; |
|
|
import com.lzbi.common.constant.PartitionConstants; |
|
|
import com.lzbi.common.constant.PartitionConstants; |
|
@ -10,6 +12,7 @@ import com.lzbi.report.domain.query.ReportQuery; |
|
|
import com.lzbi.report.domain.req.ReportReq; |
|
|
import com.lzbi.report.domain.req.ReportReq; |
|
|
import com.lzbi.report.mapper.AjReportMapper; |
|
|
import com.lzbi.report.mapper.AjReportMapper; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
import org.springframework.util.CollectionUtils; |
|
@ -19,10 +22,7 @@ import java.math.BigDecimal; |
|
|
import java.math.RoundingMode; |
|
|
import java.math.RoundingMode; |
|
|
import java.time.LocalDate; |
|
|
import java.time.LocalDate; |
|
|
import java.time.format.DateTimeFormatter; |
|
|
import java.time.format.DateTimeFormatter; |
|
|
import java.util.ArrayList; |
|
|
import java.util.*; |
|
|
import java.util.HashMap; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
@Service |
|
|
@Service |
|
@ -34,8 +34,107 @@ public class AjReportService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private ParamsService paramsService; |
|
|
private ParamsService paramsService; |
|
|
|
|
|
|
|
|
public List<Map<String, Object>> getReportDataList(ReportReq reportReq) { |
|
|
@Resource |
|
|
|
|
|
private DcBaseAssetInfoMapper dcBaseAssetInfoMapper; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 获取大唐管井数据 |
|
|
|
|
|
* @param reportReq |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
public List<Map<String, Object>> getDatangDataList(ReportReq reportReq) { |
|
|
|
|
|
if (StringUtils.isBlank(reportReq.getCountDate())) { |
|
|
|
|
|
reportReq.setCountDate(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
|
|
|
|
|
} |
|
|
|
|
|
List<String> targetModelCodeList = new ArrayList<>(13); |
|
|
|
|
|
targetModelCodeList.add(ParamsModelCodeConstants.瞬时热量); |
|
|
|
|
|
targetModelCodeList.add(ParamsModelCodeConstants.累计热量); |
|
|
|
|
|
targetModelCodeList.add(ParamsModelCodeConstants.一次网供温); |
|
|
|
|
|
targetModelCodeList.add(ParamsModelCodeConstants.一次网回温); |
|
|
|
|
|
targetModelCodeList.add(ParamsModelCodeConstants.一次网供压); |
|
|
|
|
|
targetModelCodeList.add(ParamsModelCodeConstants.一次网回压); |
|
|
|
|
|
targetModelCodeList.add(ParamsModelCodeConstants.供水流量); |
|
|
|
|
|
targetModelCodeList.add(ParamsModelCodeConstants.回水流量); |
|
|
|
|
|
targetModelCodeList.add(ParamsModelCodeConstants.水表瞬时补水量); |
|
|
|
|
|
targetModelCodeList.add(ParamsModelCodeConstants.水表累计补水量); |
|
|
|
|
|
targetModelCodeList.add(ParamsModelCodeConstants.电调阀开度给定); |
|
|
|
|
|
targetModelCodeList.add(ParamsModelCodeConstants.电调阀开度反馈); |
|
|
|
|
|
ReportQuery reportQuery = new ReportQuery(); |
|
|
|
|
|
BeanUtils.copyProperties(reportReq, reportQuery); |
|
|
|
|
|
reportQuery.setAssetLevel(BizConstants.DcAssetLevel.HEAT_SOURCE); |
|
|
|
|
|
reportQuery.setAssetType(BizConstants.DcAssetType.COMPUTE); |
|
|
|
|
|
reportQuery.setColumnType(BizConstants.ColumnType.PARAM); |
|
|
|
|
|
reportQuery.setTargetModelCodeList(targetModelCodeList); |
|
|
|
|
|
List<String> assetAndPartitionList = ajReportMapper.getAssetAndPartitionList(reportQuery); |
|
|
|
|
|
if (CollectionUtils.isEmpty(assetAndPartitionList)) { |
|
|
|
|
|
throw new RuntimeException("未配置统计单元"); |
|
|
|
|
|
} |
|
|
|
|
|
List<ReportDTO> reportDataList = ajReportMapper.getReportDataList(reportQuery); |
|
|
|
|
|
if (CollectionUtils.isEmpty(reportDataList)) { |
|
|
|
|
|
throw new RuntimeException("无数据"); |
|
|
|
|
|
} |
|
|
List<Map<String, Object>> list = new ArrayList<>(); |
|
|
List<Map<String, Object>> list = new ArrayList<>(); |
|
|
|
|
|
Map<String, Object> reportVO = new HashMap<>(); |
|
|
|
|
|
String datangAssetAndPartition = assetAndPartitionList.get(0); |
|
|
|
|
|
Map<String, List<ReportDTO>> reportDataMap = reportDataList.stream().collect(Collectors.groupingBy(item -> StringUtils.join(item.getAssetCode(), "-", item.getPartition()))); |
|
|
|
|
|
List<ReportDTO> reportDTOList = reportDataMap.get(datangAssetAndPartition); |
|
|
|
|
|
String assetCode = reportDTOList.get(0).getAssetCode(); |
|
|
|
|
|
reportVO.put("assetCode", assetCode); |
|
|
|
|
|
reportVO.put("assetName", reportDTOList.get(0).getAssetName()); |
|
|
|
|
|
reportVO.put("partition", PartitionConstants.partition.get(reportDTOList.get(0).getPartition())); |
|
|
|
|
|
Map<String, ReportDTO> targetDataMap = reportDTOList.stream().collect(Collectors.toMap(ReportDTO::getTargetModelCode, item -> item, (v1, v2) -> v2)); |
|
|
|
|
|
targetModelCodeList.forEach(targetModelCode -> getValue(reportVO, targetDataMap.get(targetModelCode), targetModelCode)); |
|
|
|
|
|
// 获取合力热源下的所有换热站的供暖面积
|
|
|
|
|
|
DcBaseAssetInfo dcBaseAssetInfo = new DcBaseAssetInfo(); |
|
|
|
|
|
dcBaseAssetInfo.setOrgId(reportReq.getOrgId()); |
|
|
|
|
|
dcBaseAssetInfo.setAssetLevel(BizConstants.DcAssetLevel.HEAT_EXCHANGE_STATION); |
|
|
|
|
|
dcBaseAssetInfo.setAssetType(BizConstants.DcAssetType.COMPUTE); |
|
|
|
|
|
List<DcBaseAssetInfo> dcBaseAssetInfos = dcBaseAssetInfoMapper.selectDcBaseAssetInfoList(dcBaseAssetInfo); |
|
|
|
|
|
List<String> assetCodeList = dcBaseAssetInfos.stream().map(DcBaseAssetInfo::getAssetCode).collect(Collectors.toList()); |
|
|
|
|
|
Map<String, Double> multipleAssetSupplyArea = paramsService.getMultipleAssetSupplyArea(assetCodeList); |
|
|
|
|
|
if (!CollectionUtils.isEmpty(multipleAssetSupplyArea)) { |
|
|
|
|
|
Double supplyArea = 0D; |
|
|
|
|
|
Set<String> keys = multipleAssetSupplyArea.keySet(); |
|
|
|
|
|
Iterator<String> iterator = keys.iterator(); |
|
|
|
|
|
while (iterator.hasNext()) { |
|
|
|
|
|
supplyArea += multipleAssetSupplyArea.get(iterator.next()); |
|
|
|
|
|
} |
|
|
|
|
|
reportVO.put("supplyArea", NumberUtils.doubleScaleToDouble(supplyArea, 2)); |
|
|
|
|
|
} |
|
|
|
|
|
Object b = reportVO.get("supplyArea"); |
|
|
|
|
|
Object c = reportVO.get(ParamsModelCodeConstants.瞬时热量); |
|
|
|
|
|
Object e = reportVO.get(ParamsModelCodeConstants.一次网供温); |
|
|
|
|
|
Object f = reportVO.get(ParamsModelCodeConstants.一次网回温); |
|
|
|
|
|
Object g = reportVO.get(ParamsModelCodeConstants.一次网供压); |
|
|
|
|
|
Object h = reportVO.get(ParamsModelCodeConstants.一次网回压); |
|
|
|
|
|
Object i = reportVO.get(ParamsModelCodeConstants.供水流量); |
|
|
|
|
|
if (null != i && null != b && !b.equals(0D)) { |
|
|
|
|
|
BigDecimal i1 = BigDecimal.valueOf((Double) i * 1000D); |
|
|
|
|
|
BigDecimal b1 = BigDecimal.valueOf((Double) b); |
|
|
|
|
|
reportVO.put("c1", i1.divide(b1, 8, RoundingMode.HALF_EVEN)); |
|
|
|
|
|
} |
|
|
|
|
|
if (null != c && null != b && !b.equals(0D)) { |
|
|
|
|
|
BigDecimal c1 = BigDecimal.valueOf((Double) c); |
|
|
|
|
|
BigDecimal b1 = BigDecimal.valueOf((Double) b); |
|
|
|
|
|
reportVO.put("c2", c1.divide(b1, 8, RoundingMode.HALF_EVEN).toPlainString()); |
|
|
|
|
|
} |
|
|
|
|
|
if (null != g && null != h) { |
|
|
|
|
|
reportVO.put("c3", NumberUtils.doubleScaleToDouble((Double) g - (Double) h, 2)); |
|
|
|
|
|
} |
|
|
|
|
|
if (null != e && null != f) { |
|
|
|
|
|
reportVO.put("c4", NumberUtils.doubleScaleToDouble((Double) e - (Double) f, 2)); |
|
|
|
|
|
reportVO.put("c5", NumberUtils.doubleScaleToDouble(((Double) e + (Double) f) / 2, 2)); |
|
|
|
|
|
} |
|
|
|
|
|
list.add(reportVO); |
|
|
|
|
|
return list; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 获取换热站数据 |
|
|
|
|
|
* @param reportReq |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
public List<Map<String, Object>> getHeatExchangeStationDataList(ReportReq reportReq) { |
|
|
if (StringUtils.isBlank(reportReq.getCountDate())) { |
|
|
if (StringUtils.isBlank(reportReq.getCountDate())) { |
|
|
reportReq.setCountDate(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
|
|
reportReq.setCountDate(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
|
|
} |
|
|
} |
|
@ -55,12 +154,16 @@ public class AjReportService { |
|
|
targetModelCodeList.add(ParamsModelCodeConstants.电调阀开度反馈); |
|
|
targetModelCodeList.add(ParamsModelCodeConstants.电调阀开度反馈); |
|
|
targetModelCodeList.add(ParamsModelCodeConstants.水箱水位计); |
|
|
targetModelCodeList.add(ParamsModelCodeConstants.水箱水位计); |
|
|
ReportQuery reportQuery = new ReportQuery(); |
|
|
ReportQuery reportQuery = new ReportQuery(); |
|
|
reportQuery.setOrgId(reportReq.getOrgId()); |
|
|
BeanUtils.copyProperties(reportReq, reportQuery); |
|
|
reportQuery.setCountDate(reportReq.getCountDate()); |
|
|
|
|
|
reportQuery.setAssetLevel(BizConstants.DcAssetLevel.HEAT_EXCHANGE_STATION); |
|
|
reportQuery.setAssetLevel(BizConstants.DcAssetLevel.HEAT_EXCHANGE_STATION); |
|
|
reportQuery.setAssetType(BizConstants.DcAssetType.COMPUTE); |
|
|
reportQuery.setAssetType(BizConstants.DcAssetType.COMPUTE); |
|
|
reportQuery.setColumnType(BizConstants.ColumnType.PARAM); |
|
|
reportQuery.setColumnType(BizConstants.ColumnType.PARAM); |
|
|
reportQuery.setTargetModelCodeList(targetModelCodeList); |
|
|
reportQuery.setTargetModelCodeList(targetModelCodeList); |
|
|
|
|
|
return this.getData(reportQuery); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<Map<String, Object>> getData(ReportQuery reportQuery) { |
|
|
|
|
|
List<Map<String, Object>> list = new ArrayList<>(); |
|
|
List<String> assetAndPartitionList = ajReportMapper.getAssetAndPartitionList(reportQuery); |
|
|
List<String> assetAndPartitionList = ajReportMapper.getAssetAndPartitionList(reportQuery); |
|
|
if (CollectionUtils.isEmpty(assetAndPartitionList)) { |
|
|
if (CollectionUtils.isEmpty(assetAndPartitionList)) { |
|
|
throw new RuntimeException("未配置统计单元"); |
|
|
throw new RuntimeException("未配置统计单元"); |
|
@ -85,12 +188,12 @@ public class AjReportService { |
|
|
reportVO.put("supplyArea", multipleAssetSupplyArea.get(assetCode)); |
|
|
reportVO.put("supplyArea", multipleAssetSupplyArea.get(assetCode)); |
|
|
} |
|
|
} |
|
|
Map<String, ReportDTO> targetDataMap = reportDTOList.stream().collect(Collectors.toMap(ReportDTO::getTargetModelCode, item -> item, (v1, v2) -> v2)); |
|
|
Map<String, ReportDTO> targetDataMap = reportDTOList.stream().collect(Collectors.toMap(ReportDTO::getTargetModelCode, item -> item, (v1, v2) -> v2)); |
|
|
|
|
|
List<String> targetModelCodeList = reportQuery.getTargetModelCodeList(); |
|
|
targetModelCodeList.forEach(targetModelCode -> getValue(reportVO, targetDataMap.get(targetModelCode), targetModelCode)); |
|
|
targetModelCodeList.forEach(targetModelCode -> getValue(reportVO, targetDataMap.get(targetModelCode), targetModelCode)); |
|
|
this.calculateExtraCellValue(reportVO); |
|
|
this.calculateExtraCellValue(reportVO); |
|
|
list.add(reportVO); |
|
|
list.add(reportVO); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
return list; |
|
|
return list; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -113,29 +216,29 @@ public class AjReportService { |
|
|
Object l = reportVO.get(ParamsModelCodeConstants.二次网回水温); |
|
|
Object l = reportVO.get(ParamsModelCodeConstants.二次网回水温); |
|
|
Object m = reportVO.get(ParamsModelCodeConstants.二次网供水压力); |
|
|
Object m = reportVO.get(ParamsModelCodeConstants.二次网供水压力); |
|
|
Object n = reportVO.get(ParamsModelCodeConstants.二次网回水压力); |
|
|
Object n = reportVO.get(ParamsModelCodeConstants.二次网回水压力); |
|
|
if (null != d && null != e && !e.equals(0D)) { |
|
|
if (null != d && null != b && !b.equals(0D)) { |
|
|
BigDecimal d1 = BigDecimal.valueOf((Double) d * 1000D); |
|
|
BigDecimal d1 = BigDecimal.valueOf((Double) d * 1000D); |
|
|
BigDecimal e1 = BigDecimal.valueOf((Double) e); |
|
|
|
|
|
reportVO.put("c1", d1.divide(e1, 8, RoundingMode.HALF_EVEN)); |
|
|
|
|
|
} |
|
|
|
|
|
if (null != b && null != e && !e.equals(0D)) { |
|
|
|
|
|
BigDecimal b1 = BigDecimal.valueOf((Double) b); |
|
|
BigDecimal b1 = BigDecimal.valueOf((Double) b); |
|
|
|
|
|
reportVO.put("c1", d1.divide(b1, 8, RoundingMode.HALF_EVEN)); |
|
|
|
|
|
} |
|
|
|
|
|
if (null != e && null != b && !b.equals(0D)) { |
|
|
BigDecimal e1 = BigDecimal.valueOf((Double) e); |
|
|
BigDecimal e1 = BigDecimal.valueOf((Double) e); |
|
|
|
|
|
BigDecimal b1 = BigDecimal.valueOf((Double) b); |
|
|
reportVO.put("c2", e1.divide(b1, 8, RoundingMode.HALF_EVEN).toPlainString()); |
|
|
reportVO.put("c2", e1.divide(b1, 8, RoundingMode.HALF_EVEN).toPlainString()); |
|
|
} |
|
|
} |
|
|
if (null != i && null != j) { |
|
|
if (null != i && null != j) { |
|
|
reportVO.put("c3", NumberUtils.doubleScaleToBigDecimal((Double) i - (Double) j, 2)); |
|
|
reportVO.put("c3", NumberUtils.doubleScaleToDouble((Double) i - (Double) j, 2)); |
|
|
} |
|
|
} |
|
|
if (null != g && null != h) { |
|
|
if (null != g && null != h) { |
|
|
reportVO.put("c4", NumberUtils.doubleScaleToBigDecimal((Double) g - (Double) h, 2)); |
|
|
reportVO.put("c4", NumberUtils.doubleScaleToDouble((Double) g - (Double) h, 2)); |
|
|
reportVO.put("c5", NumberUtils.doubleScaleToBigDecimal(((Double) g + (Double) h) / 2, 2)); |
|
|
reportVO.put("c5", NumberUtils.doubleScaleToDouble(((Double) g + (Double) h) / 2, 2)); |
|
|
} |
|
|
} |
|
|
if (null != k && null != l) { |
|
|
if (null != k && null != l) { |
|
|
reportVO.put("c6", NumberUtils.doubleScaleToBigDecimal((Double) k - (Double) l, 2)); |
|
|
reportVO.put("c6", NumberUtils.doubleScaleToDouble((Double) k - (Double) l, 2)); |
|
|
reportVO.put("c7", NumberUtils.doubleScaleToBigDecimal(((Double) k + (Double) l) / 2, 2)); |
|
|
reportVO.put("c7", NumberUtils.doubleScaleToDouble(((Double) k + (Double) l) / 2, 2)); |
|
|
} |
|
|
} |
|
|
if (null != m && null != n) { |
|
|
if (null != m && null != n) { |
|
|
reportVO.put("c8", NumberUtils.doubleScaleToBigDecimal((Double) m - (Double) n, 2)); |
|
|
reportVO.put("c8", NumberUtils.doubleScaleToDouble((Double) m - (Double) n, 2)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|