mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
update 算法应用平台Service
This commit is contained in:
@@ -4,9 +4,7 @@ import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.jsowell.common.constant.CacheConstants;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.ykc.BMSDemandAndChargerOutputData;
|
||||
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
||||
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
||||
import com.jsowell.common.core.domain.ykc.*;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||
@@ -14,6 +12,8 @@ import com.jsowell.pile.service.PileBasicInfoService;
|
||||
import com.jsowell.pile.thirdparty.ParameterConfigData;
|
||||
import com.jsowell.pile.vo.uniapp.customer.OrderVO;
|
||||
import com.jsowell.thirdparty.platform.domain.ChargeAlgorithmData;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -38,6 +38,8 @@ public class ChargeAlgorithmService {
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* 推送充电订单数据
|
||||
* @param orderCode
|
||||
@@ -49,7 +51,12 @@ public class ChargeAlgorithmService {
|
||||
return;
|
||||
}
|
||||
String transactionCode = orderVO.getTransactionCode();
|
||||
// 获取0x17缓存中的信息
|
||||
|
||||
// 获取0x15
|
||||
String chargingHandshakeKey = CacheConstants.CHARGING_HANDSHAKE_DATA_BY_TRANSACTION_CODE + transactionCode;
|
||||
ChargingHandshakeData chargingHandshakeData = redisCache.getCacheObject(chargingHandshakeKey);
|
||||
|
||||
// 获取0x17
|
||||
String redisKey = CacheConstants.PARAMETER_CONFIGURATION_BY_TRANSACTION_CODE + transactionCode;
|
||||
ParameterConfigData parameterConfigData = redisCache.getCacheObject(redisKey);
|
||||
if (parameterConfigData == null) {
|
||||
@@ -59,12 +66,12 @@ public class ChargeAlgorithmService {
|
||||
String transactionDataKey = CacheConstants.TRANSACTION_RECORD_BY_TRANSACTION_CODE + transactionCode;
|
||||
TransactionRecordsData transactionRecordsData = redisCache.getCacheObject(transactionDataKey);
|
||||
|
||||
// 获取最近一条的0x23数据
|
||||
List<BMSDemandAndChargerOutputData> bmsChargeInfoList = pileBasicInfoService.getBMSDemandAndChargerOutputInfoList(transactionCode);
|
||||
if (CollectionUtils.isEmpty(bmsChargeInfoList)) {
|
||||
// 获取最后一条0x23
|
||||
List<BMSDemandAndChargerOutputData> chargerOutputInfoList = pileBasicInfoService.getBMSDemandAndChargerOutputInfoList(transactionCode);
|
||||
if (CollectionUtils.isEmpty(chargerOutputInfoList)) {
|
||||
return;
|
||||
}
|
||||
BMSDemandAndChargerOutputData bmsDemandAndChargerOutputData = bmsChargeInfoList.get(0);
|
||||
BMSDemandAndChargerOutputData bmsDemandAndChargerOutputData = chargerOutputInfoList.get(0);
|
||||
|
||||
// 获取最后一条0x13
|
||||
List<RealTimeMonitorData> chargingRealTimeDataList = orderBasicInfoService.getChargingRealTimeData(transactionCode);
|
||||
@@ -74,12 +81,16 @@ public class ChargeAlgorithmService {
|
||||
RealTimeMonitorData realTimeMonitorData = chargingRealTimeDataList.get(0);
|
||||
|
||||
// 获取最后一条0x25
|
||||
|
||||
List<BMSChargeInfoData> bmsChargeInfoList = pileBasicInfoService.getBMSChargeInfoList(transactionCode);
|
||||
if (CollectionUtils.isEmpty(bmsChargeInfoList)) {
|
||||
return;
|
||||
}
|
||||
BMSChargeInfoData bmsChargeInfoData = bmsChargeInfoList.get(0);
|
||||
|
||||
ChargeAlgorithmData data = ChargeAlgorithmData.builder()
|
||||
.orderCode(orderCode)
|
||||
.initSoc(Constants.zero)
|
||||
.currentSoc(Constants.zero)
|
||||
.initSoc(Integer.parseInt(orderVO.getStartSoc()))
|
||||
.currentSoc(Integer.parseInt(orderVO.getEndSoc()))
|
||||
.alarmCode(Constants.ZERO)
|
||||
.currentServiceFee(String.valueOf(orderVO.getTotalServiceAmount()))
|
||||
.currentTotalFee(String.valueOf(orderVO.getOrderAmount()))
|
||||
@@ -100,11 +111,11 @@ public class ChargeAlgorithmService {
|
||||
.chargePower(bmsDemandAndChargerOutputData.getOutputPower()) // 充电功率
|
||||
.ratedCapacity(parameterConfigData.getBmsSumEnergy()) // 电池额定容量
|
||||
.nominalEnergy(parameterConfigData.getBmsSumEnergy())
|
||||
// .ratedVoltage() // 电池额定总电压
|
||||
.ratedVoltage(chargingHandshakeData.getBmsBatteryVoltage()) // 电池额定总电压
|
||||
.singleMaxVoltage(parameterConfigData.getPileMaxOutputVoltage())
|
||||
.singleMinVoltage(parameterConfigData.getPileMinOutputVoltage())
|
||||
// .singleMaxTemp(realTimeMonitorData.getBatteryMaxTemperature()) // 单体最高温度
|
||||
// .singleMinTemp() // 单体最低温度
|
||||
.singleMaxTemp(bmsChargeInfoData.getBmsMaxBatteryTemperature()) // 单体最高温度
|
||||
.singleMinTemp(bmsChargeInfoData.getMinBatteryTemperature()) // 单体最低温度
|
||||
// .ventTemp() // 出风口温度
|
||||
// .environmentTemp() // 环境温度
|
||||
.gunTemp(realTimeMonitorData.getGunLineCode()) // 充电枪温度
|
||||
@@ -112,14 +123,14 @@ public class ChargeAlgorithmService {
|
||||
.bmsVersion("V1.1") // BMS版本
|
||||
.measuringChargeVoltage(bmsDemandAndChargerOutputData.getBmsChargingVoltage()) // 车辆测量充电电压
|
||||
.measuringChargeElectricity(bmsDemandAndChargerOutputData.getBmsChargingCurrent()) // 车辆测量充电电流
|
||||
// .maxSingleVoltageGroupNum() // 最高单体电压组号
|
||||
// .maxSingleVoltageNum() // 最高单体电压编号
|
||||
// .maxTempPointNum() // 最高温度点编号
|
||||
// .minTempPointNum() // 最低温度点编号
|
||||
// .batteryType() // 电池类型
|
||||
// .batteryInsulation() // 电池绝缘状态
|
||||
.maxSingleVoltageGroupNum(Integer.parseInt(bmsDemandAndChargerOutputData.getBmsMaxVoltageAndGroup())) // 最高单体电压组号
|
||||
.maxSingleVoltageNum(Integer.parseInt(bmsChargeInfoData.getBmsMaxVoltageNum())) // 最高单体电压编号
|
||||
.maxTempPointNum(Integer.parseInt(bmsChargeInfoData.getMaxTemperatureDetectionNum())) // 最高温度点编号
|
||||
.minTempPointNum(Integer.parseInt(bmsChargeInfoData.getMinTemperatureDetectionNum())) // 最低温度点编号
|
||||
.batteryType(chargingHandshakeData.getBmsBatteryType()) // 电池类型
|
||||
.batteryInsulation(Integer.parseInt(bmsChargeInfoData.getBmsBatteryInsulationStatus())) // 电池绝缘状态
|
||||
.maxAllowTotalVoltage(parameterConfigData.getBmsMaxChargingVoltage())
|
||||
// .beforeChargeTotalVoltage() // 充电前总电压
|
||||
.beforeChargeTotalVoltage(parameterConfigData.getBmsRealTimeVoltage()) // 充电前总电压
|
||||
|
||||
.build();
|
||||
|
||||
@@ -130,11 +141,13 @@ public class ChargeAlgorithmService {
|
||||
data.setCurrentSoc(Integer.parseInt(orderVO.getEndSoc()));
|
||||
}
|
||||
|
||||
log.info("发送请求前封装数据 data:{}", JSON.toJSONString(data));
|
||||
|
||||
String url = "http://150.158.199.92:58910/gateway/api/user/battery/algorithm/json";
|
||||
String clientId = "";
|
||||
// 发送请求
|
||||
String response = HttpRequest.post(url).header("clientId", clientId).body(JSON.toJSONString(data)).execute().body();
|
||||
|
||||
|
||||
log.info("发送请求收到回复 response:{}", response);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user