mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 11:35:12 +08:00
新增 宁夏平台 推送充换电站实时功率接口
This commit is contained in:
200
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupStationStatsInfo.java
vendored
Normal file
200
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupStationStatsInfo.java
vendored
Normal file
@@ -0,0 +1,200 @@
|
||||
package com.jsowell.thirdparty.platform.domain;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 充换电站用能统计信息
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2024/6/12 15:14:07
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SupStationStatsInfo {
|
||||
@JSONField(name = "StationID")
|
||||
private String stationId;
|
||||
|
||||
@JSONField(name = "OperatorID")
|
||||
private String operatorId;
|
||||
|
||||
@JSONField(name = "EquipmentOwnerID")
|
||||
private String equipmentOwnerId;
|
||||
|
||||
/**
|
||||
* 站点分类
|
||||
* 1:充电站
|
||||
* 2:换电站
|
||||
* 3:充换电一体站
|
||||
*/
|
||||
@JSONField(name = "StationClassification")
|
||||
private Integer stationClassification;
|
||||
|
||||
/**
|
||||
* 统计开始时间
|
||||
*/
|
||||
@JSONField(name = "StartTime")
|
||||
private String startTime;
|
||||
|
||||
/**
|
||||
* 统计结束时间
|
||||
*/
|
||||
@JSONField(name = "EndTime")
|
||||
private String endTime;
|
||||
|
||||
/**
|
||||
* 充换电站累计用电量
|
||||
*/
|
||||
@JSONField(name = "StationElectricity")
|
||||
private BigDecimal stationElectricity;
|
||||
|
||||
/**
|
||||
* 充换电站累计充电量
|
||||
*/
|
||||
@JSONField(name = "StationTotalChargeEnergy")
|
||||
private BigDecimal stationTotalChargeEnergy;
|
||||
|
||||
/**
|
||||
* 充换电站累计其他电量
|
||||
*/
|
||||
@JSONField(name = "StationTotalOtherEnergy")
|
||||
private BigDecimal stationTotalOtherEnergy;
|
||||
|
||||
/**
|
||||
* 充换电站累计换电次数
|
||||
*/
|
||||
@JSONField(name = "StationTotalSwapChargeNum")
|
||||
private Integer stationTotalSwapChargeNum;
|
||||
|
||||
/**
|
||||
* 充换电站累计充电次数
|
||||
*/
|
||||
@JSONField(name = "StationTotalChargeNum")
|
||||
private Integer stationTotalChargeNum;
|
||||
|
||||
/**
|
||||
* 充换电站累计充电时长
|
||||
*/
|
||||
@JSONField(name = "StationTotalChargeTime")
|
||||
private Integer stationTotalChargeTime;
|
||||
|
||||
/**
|
||||
* 充换电站累计换电时长
|
||||
*/
|
||||
@JSONField(name = "StationTotalSwapTime")
|
||||
private Integer stationTotalSwapTime;
|
||||
|
||||
/**
|
||||
* 充换电站累计告警数量
|
||||
*/
|
||||
@JSONField(name = "StationTotalWarningNum")
|
||||
private Integer stationTotalWarningNum;
|
||||
|
||||
/**
|
||||
* 充电设备运行统计信息列表
|
||||
*/
|
||||
@JSONField(name = "EquipmentStatsInfos")
|
||||
private List<EquipmentStatsInfo> equipmentStatsInfos;
|
||||
|
||||
|
||||
@Data
|
||||
public static class EquipmentStatsInfo{
|
||||
|
||||
/**
|
||||
* 充电设备编码
|
||||
*/
|
||||
@JSONField(name = "EquipmentID")
|
||||
private String equipmentId;
|
||||
|
||||
/**
|
||||
* 设备分类
|
||||
* 1:车辆充电设备
|
||||
* 2:换电站内的电池箱充电设备
|
||||
*/
|
||||
@JSONField(name = "EquipmentClassification")
|
||||
private Integer equipmentClassification;
|
||||
|
||||
/**
|
||||
* 充电设备累计电量
|
||||
*/
|
||||
@JSONField(name = "EquipmentElectricity")
|
||||
private BigDecimal equipmentElectricity;
|
||||
|
||||
/**
|
||||
* 充电设备累计充电时长
|
||||
*/
|
||||
@JSONField(name = "EquipmentTotalChargeTime")
|
||||
private Integer equipmentTotalChargeTime;
|
||||
|
||||
/**
|
||||
* 充电设备累计充电次数
|
||||
*/
|
||||
@JSONField(name = "EquipmentTotalChargeNum")
|
||||
private Integer equipmentTotalChargeNum;
|
||||
|
||||
/**
|
||||
* 充电设备累计告警数量
|
||||
*/
|
||||
@JSONField(name = "EquipmentTotalWarningNum")
|
||||
private Integer equipmentTotalWarningNum;
|
||||
|
||||
/**
|
||||
* 充电设备接口运行统计信息列表
|
||||
*/
|
||||
@JSONField(name = "ConnectorStatsInfos")
|
||||
private List<ConnectorStatsInfo> connectorStatsInfos;
|
||||
|
||||
@Data
|
||||
public static class ConnectorStatsInfo{
|
||||
|
||||
/**
|
||||
* 充电设备接口编码
|
||||
* 1:车辆充电设备
|
||||
* 2:换电站内的电池箱充电设备
|
||||
*/
|
||||
@JSONField(name = "ConnectorID")
|
||||
private String connectorId;
|
||||
|
||||
/**
|
||||
* 设备分类
|
||||
*/
|
||||
@JSONField(name = "EquipmentClassification")
|
||||
private Integer equipmentClassification;
|
||||
|
||||
/**
|
||||
* 充电设备接口累计电量
|
||||
*/
|
||||
@JSONField(name = "ConnectorElectricity")
|
||||
private BigDecimal connectorElectricity;
|
||||
|
||||
/**
|
||||
* 充电设备接口累计充电时长
|
||||
*/
|
||||
@JSONField(name = "ConnectorTotalChargeTime")
|
||||
private Integer connectorTotalChargeTime;
|
||||
|
||||
/**
|
||||
* 充电设备接口累计充电次数
|
||||
*/
|
||||
@JSONField(name = "ConnectorTotalChargeNum")
|
||||
private Integer connectorTotalChargeNum;
|
||||
|
||||
/**
|
||||
* 充电设备接口累计告警数量
|
||||
*/
|
||||
@JSONField(name = "ConnectorTotalWarningNum")
|
||||
private Integer connectorTotalWarningNum;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -28,11 +28,13 @@ import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
||||
import com.jsowell.pile.thirdparty.EquipmentInfo;
|
||||
import com.jsowell.pile.util.MerchantUtils;
|
||||
import com.jsowell.pile.vo.SupStationStatsVO;
|
||||
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
|
||||
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.base.MerchantInfoVO;
|
||||
import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.BillingPriceVO;
|
||||
import com.jsowell.pile.vo.uniapp.OrderVO;
|
||||
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
||||
import com.jsowell.thirdparty.lianlian.domain.ConnectorChargeStatusInfo;
|
||||
import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo;
|
||||
@@ -51,7 +53,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@@ -653,7 +657,130 @@ public class NinaXiaPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
*/
|
||||
@Override
|
||||
public String notificationOperationStatsInfo(String stationId) {
|
||||
return ThirdPartyPlatformService.super.notificationOperationStatsInfo(stationId);
|
||||
SupStationStatsInfo.
|
||||
EquipmentStatsInfo equipmentStatsInfo = new SupStationStatsInfo.EquipmentStatsInfo();
|
||||
List<SupStationStatsInfo.
|
||||
EquipmentStatsInfo> equipmentStatsInfoList = new ArrayList<>();
|
||||
|
||||
SupStationStatsInfo.
|
||||
EquipmentStatsInfo.
|
||||
ConnectorStatsInfo connectorStatsInfo = null;
|
||||
List<SupStationStatsInfo.
|
||||
EquipmentStatsInfo.
|
||||
ConnectorStatsInfo> connectorStatsInfoList = new ArrayList<>();
|
||||
|
||||
// 根据站点id查询订单记录 (新建Service方法)
|
||||
List<SupStationStatsVO> orderVOS = orderBasicInfoService.queryOrderListByStationId(stationId);
|
||||
// 根据订单信息汇总出站点充电数据
|
||||
BigDecimal stationTotalElectricity = BigDecimal.ZERO; // 充电站累计用电量
|
||||
int stationChargeTime = Constants.zero; // 充电站累计充电次数
|
||||
for (SupStationStatsVO orderVO : orderVOS) {
|
||||
// 充电站累计用电量
|
||||
BigDecimal totalPower = orderVO.getTotalPower();
|
||||
stationTotalElectricity = stationTotalElectricity.add(totalPower);
|
||||
// 充电站累计充电时长(分钟)
|
||||
stationChargeTime+= orderVO.getChargingTime();
|
||||
}
|
||||
|
||||
// 根据枪口排序,分组,将充电时长和充电量累加
|
||||
Map<String, SupStationStatsVO> collect = orderVOS.stream()
|
||||
.sorted(Comparator.comparing(SupStationStatsVO::getPileConnectorCode))
|
||||
.collect(Collectors.toMap(SupStationStatsVO::getPileConnectorCode, Function.identity(),
|
||||
(a, b) -> {
|
||||
a.setChargingTime(a.getChargingTime() + b.getChargingTime());
|
||||
a.setTotalPower(a.getTotalPower().add(b.getTotalPower()));
|
||||
return a;
|
||||
}));
|
||||
|
||||
// 初始化相关数据
|
||||
String pileSn = "";
|
||||
BigDecimal pileTotalPower = BigDecimal.ZERO;
|
||||
int pileChargeTime = Constants.zero;
|
||||
for (Map.Entry<String, SupStationStatsVO> entry: collect.entrySet()) {
|
||||
String pileConnectorCode = entry.getKey();
|
||||
SupStationStatsVO vo = entry.getValue();
|
||||
|
||||
connectorStatsInfo = new SupStationStatsInfo.EquipmentStatsInfo.ConnectorStatsInfo();
|
||||
|
||||
// 先封装枪口数据
|
||||
connectorStatsInfo.setConnectorId(pileConnectorCode);
|
||||
|
||||
connectorStatsInfo.setEquipmentClassification(1);
|
||||
connectorStatsInfo.setConnectorElectricity(vo.getTotalPower());
|
||||
connectorStatsInfo.setConnectorTotalChargeTime(vo.getChargingTime());
|
||||
// TODO connectorStatsInfo.setConnectorTotalChargeNum();
|
||||
connectorStatsInfo.setConnectorTotalWarningNum(0);
|
||||
|
||||
// 对比这次循环到的桩编号和上次的桩编号,如果是同一台桩,将数据进行汇总,如果不是,新建桩数据,并将之前的累计数据清0
|
||||
String newPileSn = vo.getPileSn();
|
||||
if (!StringUtils.equals(pileSn, newPileSn)) {
|
||||
pileSn = newPileSn;
|
||||
pileTotalPower = BigDecimal.ZERO;
|
||||
pileChargeTime = Constants.zero;
|
||||
|
||||
equipmentStatsInfo = new SupStationStatsInfo.EquipmentStatsInfo();
|
||||
equipmentStatsInfo.setEquipmentId(newPileSn);
|
||||
equipmentStatsInfo.setEquipmentClassification(1);
|
||||
equipmentStatsInfo.setEquipmentElectricity(vo.getTotalPower());
|
||||
equipmentStatsInfo.setEquipmentTotalChargeTime(vo.getChargingTime());
|
||||
// TODO equipmentStatsInfo.setEquipmentTotalChargeNum();
|
||||
|
||||
pileTotalPower = pileTotalPower.add(vo.getTotalPower());
|
||||
pileChargeTime += vo.getChargingTime();
|
||||
}else {
|
||||
// 同一台桩,累加数据
|
||||
pileTotalPower = pileTotalPower.add(vo.getTotalPower());
|
||||
pileChargeTime += vo.getChargingTime();
|
||||
|
||||
equipmentStatsInfo.setEquipmentElectricity(pileTotalPower); // 第一次判断时一定不会进入到这里,所以不用判断 equipmentStatsInfo 是否为 null
|
||||
equipmentStatsInfo.setEquipmentTotalChargeTime(pileChargeTime);
|
||||
|
||||
}
|
||||
equipmentStatsInfoList.add(equipmentStatsInfo);
|
||||
connectorStatsInfoList.add(connectorStatsInfo);
|
||||
}
|
||||
equipmentStatsInfo.setConnectorStatsInfos(connectorStatsInfoList);
|
||||
|
||||
// 创建对象
|
||||
String startTime = DateUtils.getYesterdayStr() + "00:00:00";
|
||||
String endTime = DateUtils.getYesterdayStr() + "23:59:59";
|
||||
SupStationStatsInfo supStationStatsInfo = SupStationStatsInfo.builder()
|
||||
.stationId(stationId)
|
||||
.operatorId(Constants.OPERATORID_JIANG_SU)
|
||||
// .equipmentOwnerId(orderVOS.get(0).getOrganizationCode())
|
||||
.stationClassification(1)
|
||||
.startTime(startTime)
|
||||
.endTime(endTime)
|
||||
.stationElectricity(stationTotalElectricity)
|
||||
.stationTotalChargeEnergy(stationTotalElectricity)
|
||||
.stationTotalChargeNum(orderVOS.size())
|
||||
.stationTotalChargeTime(stationChargeTime)
|
||||
.stationTotalWarningNum(0)
|
||||
.equipmentStatsInfos(equipmentStatsInfoList)
|
||||
|
||||
.build();
|
||||
// 发送推送请求
|
||||
ThirdPartySecretInfoVO ningXiaSecretInfo = getNingXiaPlatformSecretInfo();
|
||||
|
||||
String operatorId = ningXiaSecretInfo.getOurOperatorId();
|
||||
String operatorSecret = ningXiaSecretInfo.getTheirOperatorSecret();
|
||||
String signSecret = ningXiaSecretInfo.getTheirSigSecret();
|
||||
String dataSecret = ningXiaSecretInfo.getTheirDataSecret();
|
||||
String dataSecretIv = ningXiaSecretInfo.getTheirDataSecretIv();
|
||||
String urlAddress = ningXiaSecretInfo.getTheirUrlPrefix();
|
||||
String url = urlAddress + "supervise_notification_operation_stats_info";
|
||||
// 获取令牌
|
||||
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return null;
|
||||
}
|
||||
// 调用平台接口
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("StationStatsInfos", supStationStatsInfo);
|
||||
String jsonString = JSON.toJSONString(json);
|
||||
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user