mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-22 03:55:17 +08:00
update 计算用电量
This commit is contained in:
@@ -2,6 +2,7 @@ package com.jsowell.thirdparty.service.impl;
|
||||
|
||||
import cn.hutool.core.util.PageUtil;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
||||
import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
@@ -11,13 +12,27 @@ import com.jsowell.pile.domain.OrderBasicInfo;
|
||||
import com.jsowell.pile.domain.PileBasicInfo;
|
||||
import com.jsowell.pile.domain.PileConnectorInfo;
|
||||
import com.jsowell.pile.domain.PileStationInfo;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
||||
import com.jsowell.pile.service.IOrderBasicInfoService;
|
||||
import com.jsowell.pile.service.IPileBasicInfoService;
|
||||
import com.jsowell.pile.service.IPileConnectorInfoService;
|
||||
import com.jsowell.pile.service.IPileMerchantInfoService;
|
||||
import com.jsowell.pile.service.IPileModelInfoService;
|
||||
import com.jsowell.pile.service.IPileStationInfoService;
|
||||
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.base.MerchantInfoVO;
|
||||
import com.jsowell.pile.vo.lianlian.AccumulativeInfoVO;
|
||||
import com.jsowell.pile.vo.web.PileModelInfoVO;
|
||||
import com.jsowell.thirdparty.domain.*;
|
||||
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
||||
import com.jsowell.thirdparty.domain.ConnectorChargeStatusInfo;
|
||||
import com.jsowell.thirdparty.domain.ConnectorInfo;
|
||||
import com.jsowell.thirdparty.domain.ConnectorStatsInfo;
|
||||
import com.jsowell.thirdparty.domain.ConnectorStatusInfo;
|
||||
import com.jsowell.thirdparty.domain.EquipmentInfo;
|
||||
import com.jsowell.thirdparty.domain.EquipmentStatsInfo;
|
||||
import com.jsowell.thirdparty.domain.OperatorInfo;
|
||||
import com.jsowell.thirdparty.domain.StationInfo;
|
||||
import com.jsowell.thirdparty.domain.StationStatsInfo;
|
||||
import com.jsowell.thirdparty.domain.StationStatusInfo;
|
||||
import com.jsowell.thirdparty.service.LianLianService;
|
||||
import com.jsowell.thirdparty.vo.LianLianPageResponse;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@@ -212,41 +227,97 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
*/
|
||||
@Override
|
||||
public StationStatsInfo query_station_stats(QueryStationInfoDTO dto) {
|
||||
List<EquipmentStatsInfo> equipmentStatsInfoList = new ArrayList<>();
|
||||
List<ConnectorStatsInfo> connectorStatsInfos = new ArrayList<>();
|
||||
BigDecimal stationElectricity = new BigDecimal("0");
|
||||
|
||||
// 根据站点id 查出这段时间的充电量
|
||||
List<AccumulativeInfoVO> accumulativeInfoForLianLian = orderBasicInfoService.getAccumulativeInfoForLianLian(dto);
|
||||
List<AccumulativeInfoVO> list = orderBasicInfoService.getAccumulativeInfoForLianLian(dto);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 根据充电桩编号分组 key=充电桩编号
|
||||
Map<String, List<AccumulativeInfoVO>> pileMap = list.stream()
|
||||
.collect(Collectors.groupingBy(AccumulativeInfoVO::getPileSn));
|
||||
|
||||
// 存放所有充电桩设备
|
||||
List<EquipmentStatsInfo> equipmentStatsInfoList = Lists.newArrayList();
|
||||
// 站点用电量
|
||||
BigDecimal stationElectricity = BigDecimal.ZERO;
|
||||
// 用于记录枪口用电量 在循环每个枪口的时候初始化
|
||||
BigDecimal pileElec;
|
||||
for (String pileSn : pileMap.keySet()) {
|
||||
// 该充电桩下 所有枪口的用电数据
|
||||
List<AccumulativeInfoVO> accumulativeInfoVOS = pileMap.get(pileSn);
|
||||
if (CollectionUtils.isEmpty(accumulativeInfoVOS)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 存放充电桩用电量
|
||||
pileElec = BigDecimal.ZERO;
|
||||
|
||||
// key=枪口编号 value 该枪口的用电数据
|
||||
Map<String, List<AccumulativeInfoVO>> collect = accumulativeInfoVOS.stream()
|
||||
.collect(Collectors.groupingBy(AccumulativeInfoVO::getPileConnectorCode));
|
||||
|
||||
List<ConnectorStatsInfo> connectorStatsInfos = Lists.newArrayList();
|
||||
for (Map.Entry<String, List<AccumulativeInfoVO>> entry : collect.entrySet()) {
|
||||
String pileConnectorCode = entry.getKey();
|
||||
List<AccumulativeInfoVO> value = entry.getValue();
|
||||
// 枪口用电量求和
|
||||
BigDecimal connectorElec = value.stream()
|
||||
.map(AccumulativeInfoVO::getConnectorElectricity)
|
||||
.map(BigDecimal::new)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
connectorStatsInfos.add(
|
||||
ConnectorStatsInfo.builder()
|
||||
.ConnectorID(pileConnectorCode)
|
||||
.ConnectorElectricity(connectorElec)
|
||||
.build()
|
||||
);
|
||||
// 充电桩电量为枪口用电量累计
|
||||
pileElec = pileElec.add(connectorElec);
|
||||
}
|
||||
|
||||
EquipmentStatsInfo build = EquipmentStatsInfo.builder()
|
||||
.EquipmentID(pileSn)
|
||||
.EquipmentElectricity(pileElec)
|
||||
.ConnectorStatsInfos(connectorStatsInfos)
|
||||
.build();
|
||||
equipmentStatsInfoList.add(build);
|
||||
|
||||
// 所有充电桩用电量之和
|
||||
stationElectricity = stationElectricity.add(pileElec);
|
||||
}
|
||||
|
||||
|
||||
// 查出站点下所有枪口的充电量
|
||||
Map<String, String> connectorElectricityMap = accumulativeInfoForLianLian.stream()
|
||||
.collect(Collectors.toMap(AccumulativeInfoVO::getPileConnectorCode, AccumulativeInfoVO::getConnectorElectricity));
|
||||
|
||||
// 查出设备列表下所有设备列表的充电量
|
||||
Map<String, String> pileElectricityMap = accumulativeInfoForLianLian.stream()
|
||||
.collect(Collectors.toMap(AccumulativeInfoVO::getPileSn, AccumulativeInfoVO::getConnectorElectricity));
|
||||
// Map<String, String> connectorElectricityMap = list.stream()
|
||||
// .collect(Collectors.toMap(AccumulativeInfoVO::getPileConnectorCode, AccumulativeInfoVO::getConnectorElectricity));
|
||||
//
|
||||
// // 查出设备列表下所有设备列表的充电量
|
||||
// Map<String, String> pileElectricityMap = list.stream()
|
||||
// .collect(Collectors.toMap(AccumulativeInfoVO::getPileSn, AccumulativeInfoVO::getConnectorElectricity));
|
||||
|
||||
// 组装数据并返回
|
||||
// 枪口累计数据
|
||||
for (Map.Entry<String, String> entry : connectorElectricityMap.entrySet()) {
|
||||
ConnectorStatsInfo connectorStatsInfo = ConnectorStatsInfo.builder()
|
||||
.ConnectorID(entry.getKey())
|
||||
.ConnectorElectricity(new BigDecimal(entry.getValue()))
|
||||
.build();
|
||||
connectorStatsInfos.add(connectorStatsInfo);
|
||||
}
|
||||
// for (Map.Entry<String, String> entry : connectorElectricityMap.entrySet()) {
|
||||
// ConnectorStatsInfo connectorStatsInfo = ConnectorStatsInfo.builder()
|
||||
// .ConnectorID(entry.getKey())
|
||||
// .ConnectorElectricity(new BigDecimal(entry.getValue()))
|
||||
// .build();
|
||||
// connectorStatsInfos.add(connectorStatsInfo);
|
||||
// }
|
||||
|
||||
// 桩累计数据
|
||||
for (Map.Entry<String, String> pileEntry : pileElectricityMap.entrySet()) {
|
||||
BigDecimal pileElectricity = new BigDecimal(pileEntry.getValue());
|
||||
EquipmentStatsInfo equipmentStatsInfo = EquipmentStatsInfo.builder()
|
||||
.EquipmentID(pileEntry.getKey())
|
||||
.EquipmentElectricity(new BigDecimal(pileEntry.getValue()))
|
||||
.ConnectorStatsInfos(connectorStatsInfos)
|
||||
.build();
|
||||
equipmentStatsInfoList.add(equipmentStatsInfo);
|
||||
stationElectricity = stationElectricity.add(pileElectricity);
|
||||
}
|
||||
// for (Map.Entry<String, String> pileEntry : pileElectricityMap.entrySet()) {
|
||||
// BigDecimal pileElectricity = new BigDecimal(pileEntry.getValue());
|
||||
// EquipmentStatsInfo equipmentStatsInfo = EquipmentStatsInfo.builder()
|
||||
// .EquipmentID(pileEntry.getKey())
|
||||
// .EquipmentElectricity(new BigDecimal(pileEntry.getValue()))
|
||||
// .ConnectorStatsInfos(connectorStatsInfos)
|
||||
// .build();
|
||||
// equipmentStatsInfoList.add(equipmentStatsInfo);
|
||||
// stationElectricity = stationElectricity.add(pileElectricity);
|
||||
// }
|
||||
|
||||
StationStatsInfo stationStatsInfo = StationStatsInfo.builder()
|
||||
.StationID(dto.getStationID())
|
||||
|
||||
Reference in New Issue
Block a user