Browse Source

1、aj-report报表

develop
bobol 5 months ago
parent
commit
a391fa4aa1
  1. 12
      lzbi-module/src/main/java/com/lzbi/external/service/ParamsService.java
  2. 11
      lzbi-module/src/main/java/com/lzbi/report/controller/AjReportController.java
  3. 4
      lzbi-module/src/main/java/com/lzbi/report/domain/query/ReportQuery.java
  4. 7
      lzbi-module/src/main/java/com/lzbi/report/domain/req/ReportReq.java
  5. 141
      lzbi-module/src/main/java/com/lzbi/report/service/AjReportService.java
  6. 6
      lzbi-module/src/main/resources/mapper/report/AjReportMapper.xml

12
lzbi-module/src/main/java/com/lzbi/external/service/ParamsService.java

@ -3,15 +3,15 @@ package com.lzbi.external.service;
import com.lzbi.common.constant.ParamsModelCodeConstants;
import com.lzbi.draft.domain.DcBusiParamDraftDay;
import com.lzbi.draft.mapper.DcBusiParamDraftDayMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service
public class ParamsService {
@ -29,9 +29,9 @@ public class ParamsService {
}
List<DcBusiParamDraftDay> list = dcBusiParamDraftDayMapper.selectLastDataByAssetCodeListAndParamsModelCode(assetCodeList, ParamsModelCodeConstants.供暖面积);
if (CollectionUtils.isEmpty(list)) {
throw new RuntimeException("暂无数据");
log.warn("暂无数据");
return new HashMap<>();
}
Map<String, Double> map = list.stream().collect(Collectors.toMap(DcBusiParamDraftDay::getAssetCode, DcBusiParamDraftDay::getValLast));
return map;
return list.stream().collect(Collectors.toMap(DcBusiParamDraftDay::getAssetCode, DcBusiParamDraftDay::getValLast));
}
}

11
lzbi-module/src/main/java/com/lzbi/report/controller/AjReportController.java

@ -1,9 +1,9 @@
package com.lzbi.report.controller;
import com.lzbi.report.domain.req.ReportReq;
import com.lzbi.report.domain.vo.ReportVO;
import com.lzbi.report.service.AjReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -18,8 +18,13 @@ public class AjReportController {
@Autowired
private AjReportService ajReportService;
@GetMapping("/datang/data")
public List<Map<String, Object>> getDatangDataList(@Validated ReportReq reportReq) {
return ajReportService.getDatangDataList(reportReq);
}
@GetMapping("/heatExchangeStation/data")
public List<Map<String, Object>> getReportDataList(ReportReq reportReq) {
return ajReportService.getReportDataList(reportReq);
public List<Map<String, Object>> getHeatExchangeStationDataList(@Validated ReportReq reportReq) {
return ajReportService.getHeatExchangeStationDataList(reportReq);
}
}

4
lzbi-module/src/main/java/com/lzbi/report/domain/query/ReportQuery.java

@ -11,6 +11,10 @@ public class ReportQuery {
* 组织id
*/
private Long orgId;
/**
* 统计单元编码
*/
private String assetCode;
/**
* 查询日期
*/

7
lzbi-module/src/main/java/com/lzbi/report/domain/req/ReportReq.java

@ -2,6 +2,8 @@ package com.lzbi.report.domain.req;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* 报表查询参数
*/
@ -11,7 +13,12 @@ public class ReportReq {
/**
* 组织id
*/
@NotNull(message = "请输入热源ID")
private Long orgId;
/**
* 统计单元编码
*/
private String assetCode;
/**
* 查询日期
*/

141
lzbi-module/src/main/java/com/lzbi/report/service/AjReportService.java

@ -1,5 +1,7 @@
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.ParamsModelCodeConstants;
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.mapper.AjReportMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@ -19,10 +22,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@Service
@ -34,8 +34,107 @@ public class AjReportService {
@Autowired
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<>();
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())) {
reportReq.setCountDate(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
}
@ -55,12 +154,16 @@ public class AjReportService {
targetModelCodeList.add(ParamsModelCodeConstants.电调阀开度反馈);
targetModelCodeList.add(ParamsModelCodeConstants.水箱水位计);
ReportQuery reportQuery = new ReportQuery();
reportQuery.setOrgId(reportReq.getOrgId());
reportQuery.setCountDate(reportReq.getCountDate());
BeanUtils.copyProperties(reportReq, reportQuery);
reportQuery.setAssetLevel(BizConstants.DcAssetLevel.HEAT_EXCHANGE_STATION);
reportQuery.setAssetType(BizConstants.DcAssetType.COMPUTE);
reportQuery.setColumnType(BizConstants.ColumnType.PARAM);
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);
if (CollectionUtils.isEmpty(assetAndPartitionList)) {
throw new RuntimeException("未配置统计单元");
@ -85,12 +188,12 @@ public class AjReportService {
reportVO.put("supplyArea", multipleAssetSupplyArea.get(assetCode));
}
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));
this.calculateExtraCellValue(reportVO);
list.add(reportVO);
}
});
return list;
}
@ -113,29 +216,29 @@ public class AjReportService {
Object l = reportVO.get(ParamsModelCodeConstants.二次网回水温);
Object m = 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 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);
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 b1 = BigDecimal.valueOf((Double) b);
reportVO.put("c2", e1.divide(b1, 8, RoundingMode.HALF_EVEN).toPlainString());
}
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) {
reportVO.put("c4", NumberUtils.doubleScaleToBigDecimal((Double) g - (Double) h, 2));
reportVO.put("c5", NumberUtils.doubleScaleToBigDecimal(((Double) g + (Double) h) / 2, 2));
reportVO.put("c4", NumberUtils.doubleScaleToDouble((Double) g - (Double) h, 2));
reportVO.put("c5", NumberUtils.doubleScaleToDouble(((Double) g + (Double) h) / 2, 2));
}
if (null != k && null != l) {
reportVO.put("c6", NumberUtils.doubleScaleToBigDecimal((Double) k - (Double) l, 2));
reportVO.put("c7", NumberUtils.doubleScaleToBigDecimal(((Double) k + (Double) l) / 2, 2));
reportVO.put("c6", NumberUtils.doubleScaleToDouble((Double) k - (Double) l, 2));
reportVO.put("c7", NumberUtils.doubleScaleToDouble(((Double) k + (Double) l) / 2, 2));
}
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));
}
}

6
lzbi-module/src/main/resources/mapper/report/AjReportMapper.xml

@ -22,6 +22,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
t1.org_id = #{orgId}
and t1.asset_type = #{assetType}
and t1.asset_level = #{assetLevel}
<if test="assetCode != null and assetCode != ''">
and t1.asset_code = #{assetCode}
</if>
order by
t1.asset_code asc,
t2.goal_param_ext2 asc
@ -53,6 +56,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
t1.org_id = #{orgId}
and t1.asset_type = #{assetType}
and t1.asset_level = #{assetLevel}
<if test="assetCode != null and assetCode != ''">
and t1.asset_code = #{assetCode}
</if>
order by
t1.asset_code asc,
t3.goal_param_ext2 asc

Loading…
Cancel
Save