mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
update 电池算法应用Service
This commit is contained in:
@@ -5,6 +5,8 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 充电订单算法Data
|
||||
*
|
||||
@@ -26,10 +28,6 @@ public class ChargeAlgorithmData {
|
||||
*/
|
||||
private Integer initSoc;
|
||||
|
||||
/**
|
||||
* 当前soc
|
||||
*/
|
||||
private Integer currentSoc;
|
||||
|
||||
/**
|
||||
* 告警编码
|
||||
@@ -61,36 +59,6 @@ public class ChargeAlgorithmData {
|
||||
*/
|
||||
private Integer remainChargeTime;
|
||||
|
||||
/**
|
||||
* 最高允许电流
|
||||
*/
|
||||
private String maxAllowElectricity;
|
||||
|
||||
/**
|
||||
* 单体最高允许电压
|
||||
*/
|
||||
private String singleMaxAllowVoltage;
|
||||
|
||||
/**
|
||||
* 直流充电电压
|
||||
*/
|
||||
private String dcv;
|
||||
|
||||
/**
|
||||
* 直流充电电流
|
||||
*/
|
||||
private String dca;
|
||||
|
||||
/**
|
||||
* BMS需求电压
|
||||
*/
|
||||
private String bmsDemandVoltage;
|
||||
|
||||
/**
|
||||
* BMS需求电流
|
||||
*/
|
||||
private String bmsDemandElectricity;
|
||||
|
||||
/**
|
||||
* BMS充电模式
|
||||
*/
|
||||
@@ -101,11 +69,6 @@ public class ChargeAlgorithmData {
|
||||
*/
|
||||
private String readBeforeCharge;
|
||||
|
||||
/**
|
||||
* 当前电表读数
|
||||
*/
|
||||
private String readCurrentCharge;
|
||||
|
||||
/**
|
||||
* 开始充电时间
|
||||
*/
|
||||
@@ -116,11 +79,6 @@ public class ChargeAlgorithmData {
|
||||
*/
|
||||
private String maxAllowTemp;
|
||||
|
||||
/**
|
||||
* 充电功率
|
||||
*/
|
||||
private String chargePower;
|
||||
|
||||
/**
|
||||
* 电池额定容量
|
||||
*/
|
||||
@@ -136,41 +94,6 @@ public class ChargeAlgorithmData {
|
||||
*/
|
||||
private String ratedVoltage;
|
||||
|
||||
/**
|
||||
* 单体最高电压
|
||||
*/
|
||||
private String singleMaxVoltage;
|
||||
|
||||
/**
|
||||
* 单体最低电压
|
||||
*/
|
||||
private String singleMinVoltage;
|
||||
|
||||
/**
|
||||
* 单体最高温度
|
||||
*/
|
||||
private String singleMaxTemp;
|
||||
|
||||
/**
|
||||
* 单体最低温度
|
||||
*/
|
||||
private String singleMinTemp;
|
||||
|
||||
/**
|
||||
* 出风口温度
|
||||
*/
|
||||
private String ventTemp;
|
||||
|
||||
/**
|
||||
* 环境温度
|
||||
*/
|
||||
private String environmentTemp;
|
||||
|
||||
/**
|
||||
* 充电枪温度
|
||||
*/
|
||||
private String gunTemp;
|
||||
|
||||
/**
|
||||
* 舱门状态
|
||||
*/
|
||||
@@ -181,54 +104,152 @@ public class ChargeAlgorithmData {
|
||||
*/
|
||||
private String bmsVersion;
|
||||
|
||||
/**
|
||||
* 车辆测量充电电压
|
||||
*/
|
||||
private String measuringChargeVoltage;
|
||||
|
||||
/**
|
||||
* 车辆测量充电电流
|
||||
*/
|
||||
private String measuringChargeElectricity;
|
||||
|
||||
/**
|
||||
* 最高单体电压组号
|
||||
*/
|
||||
private Integer maxSingleVoltageGroupNum;
|
||||
|
||||
/**
|
||||
* 最高单体电压编号
|
||||
*/
|
||||
private Integer maxSingleVoltageNum;
|
||||
|
||||
/**
|
||||
* 最高温度点编号
|
||||
*/
|
||||
private Integer maxTempPointNum;
|
||||
|
||||
/**
|
||||
* 最低温度点编号
|
||||
*/
|
||||
private Integer minTempPointNum;
|
||||
|
||||
/**
|
||||
* 电池类型
|
||||
*/
|
||||
private String batteryType;
|
||||
|
||||
/**
|
||||
* 电池绝缘状态
|
||||
* 车辆vin码
|
||||
*/
|
||||
private Integer batteryInsulation;
|
||||
private String vin;
|
||||
|
||||
/**
|
||||
* 最高允许充电总电压
|
||||
*/
|
||||
private String maxAllowTotalVoltage;
|
||||
private List<ChargingDetailInfo> chargingDetailInfo;
|
||||
|
||||
/**
|
||||
* 充电前总电压
|
||||
*/
|
||||
private String beforeChargeTotalVoltage;
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public static class ChargingDetailInfo {
|
||||
/**
|
||||
* 当前电表读数
|
||||
*/
|
||||
private String readCurrentCharge;
|
||||
|
||||
/**
|
||||
* 当前soc
|
||||
*/
|
||||
private Integer currentSoc;
|
||||
|
||||
/**
|
||||
* 上报时间
|
||||
*/
|
||||
private String reportTime;
|
||||
|
||||
/**
|
||||
* 最高允许电流
|
||||
*/
|
||||
private String maxAllowElectricity;
|
||||
|
||||
/**
|
||||
* 单体最高允许电压
|
||||
*/
|
||||
private String singleMaxAllowVoltage;
|
||||
|
||||
/**
|
||||
* 直流充电电压
|
||||
*/
|
||||
private String dcv;
|
||||
|
||||
/**
|
||||
* 直流充电电流
|
||||
*/
|
||||
private String dca;
|
||||
|
||||
/**
|
||||
* BMS需求电压
|
||||
*/
|
||||
private String bmsDemandVoltage;
|
||||
|
||||
/**
|
||||
* BMS需求电流
|
||||
*/
|
||||
private String bmsDemandElectricity;
|
||||
|
||||
/**
|
||||
* 充电功率
|
||||
*/
|
||||
private String chargePower;
|
||||
|
||||
/**
|
||||
* 单体最高电压
|
||||
*/
|
||||
private String singleMaxVoltage;
|
||||
|
||||
/**
|
||||
* 单体最低电压
|
||||
*/
|
||||
private String singleMinVoltage;
|
||||
|
||||
/**
|
||||
* 单体最高温度
|
||||
*/
|
||||
private String singleMaxTemp;
|
||||
|
||||
/**
|
||||
* 单体最低温度
|
||||
*/
|
||||
private String singleMinTemp;
|
||||
|
||||
/**
|
||||
* 出风口温度
|
||||
*/
|
||||
private String ventTemp;
|
||||
|
||||
/**
|
||||
* 环境温度
|
||||
*/
|
||||
private String environmentTemp;
|
||||
|
||||
/**
|
||||
* 充电枪温度
|
||||
*/
|
||||
private String gunTemp;
|
||||
|
||||
/**
|
||||
* 车辆测量充电电压
|
||||
*/
|
||||
private String measuringChargeVoltage;
|
||||
|
||||
/**
|
||||
* 车辆测量充电电流
|
||||
*/
|
||||
private String measuringChargeElectricity;
|
||||
|
||||
/**
|
||||
* 最高单体电压组号
|
||||
*/
|
||||
private Integer maxSingleVoltageGroupNum;
|
||||
|
||||
/**
|
||||
* 最高单体电压编号
|
||||
*/
|
||||
private Integer maxSingleVoltageNum;
|
||||
|
||||
/**
|
||||
* 最高温度点编号
|
||||
*/
|
||||
private Integer maxTempPointNum;
|
||||
|
||||
/**
|
||||
* 最低温度点编号
|
||||
*/
|
||||
private Integer minTempPointNum;
|
||||
|
||||
/**
|
||||
* 电池绝缘状态
|
||||
*/
|
||||
private Integer batteryInsulation;
|
||||
|
||||
/**
|
||||
* 最高允许充电总电压
|
||||
*/
|
||||
private String maxAllowTotalVoltage;
|
||||
|
||||
/**
|
||||
* 充电前总电压
|
||||
*/
|
||||
private String beforeChargeTotalVoltage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.jsowell.common.core.domain.ykc.*;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.domain.OrderSplitRecord;
|
||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||
import com.jsowell.pile.service.PileBasicInfoService;
|
||||
import com.jsowell.pile.thirdparty.ParameterConfigData;
|
||||
@@ -20,7 +21,11 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 订单算法平台Service
|
||||
@@ -89,60 +94,45 @@ public class ChargeAlgorithmService {
|
||||
// RealTimeMonitorData realTimeMonitorData = chargingRealTimeDataList.get(0);
|
||||
|
||||
// 获取最后一条0x25
|
||||
List<BMSChargeInfoData> bmsChargeInfoList = pileBasicInfoService.getBMSChargeInfoList(transactionCode);
|
||||
if (CollectionUtils.isEmpty(bmsChargeInfoList)) {
|
||||
return "0x25信息为空";
|
||||
}
|
||||
BMSChargeInfoData bmsChargeInfoData = bmsChargeInfoList.get(0);
|
||||
// List<BMSChargeInfoData> bmsChargeInfoList = pileBasicInfoService.getBMSChargeInfoList(transactionCode);
|
||||
// if (CollectionUtils.isEmpty(bmsChargeInfoList)) {
|
||||
// return "0x25信息为空";
|
||||
// }
|
||||
// BMSChargeInfoData bmsChargeInfoData = bmsChargeInfoList.get(0);
|
||||
|
||||
ChargeAlgorithmData data = ChargeAlgorithmData.builder()
|
||||
.vin(chargingHandshakeData.getVinCode())
|
||||
.orderCode(orderCode)
|
||||
.beginTime(orderVO.getStartTime())
|
||||
.initSoc(new BigDecimal(orderVO.getStartSoc()).intValue())
|
||||
.currentSoc(new BigDecimal(orderVO.getEndSoc()).intValue())
|
||||
.alarmCode(Constants.ZERO)
|
||||
.currentServiceFee(String.valueOf(orderVO.getTotalServiceAmount()))
|
||||
.currentTotalFee(String.valueOf(orderVO.getOrderAmount()))
|
||||
.totalCharge(orderVO.getTotalPower())
|
||||
.totalChargeTime(Math.toIntExact(chargingTime))
|
||||
.remainChargeTime(Constants.zero)
|
||||
.maxAllowElectricity(parameterConfigData.getBmsMaxCurrent())
|
||||
.singleMaxAllowVoltage(parameterConfigData.getBmsMaxVoltage())
|
||||
.dcv(bmsDemandAndChargerOutputData.getPileVoltageOutput()) // 直流充电电压
|
||||
.dca(bmsDemandAndChargerOutputData.getPileCurrentOutput()) // 直流充电电流
|
||||
.bmsDemandVoltage(bmsDemandAndChargerOutputData.getBmsVoltageDemand()) // BMS需求电压
|
||||
.bmsDemandElectricity(bmsDemandAndChargerOutputData.getBmsCurrentDemand()) // BMS需求电流
|
||||
.bmsChargeMode(Integer.parseInt(bmsDemandAndChargerOutputData.getBmsChargingModel())) // BMS充电模式
|
||||
.readBeforeCharge(transactionRecordsData.getAmmeterTotalStart())
|
||||
.readCurrentCharge(transactionRecordsData.getAmmeterTotalEnd())
|
||||
.beginTime(orderVO.getStartTime())
|
||||
.bmsVersion("V1.1") // BMS版本
|
||||
.batteryType(chargingHandshakeData.getBmsBatteryType()) // 电池类型
|
||||
.maxAllowTemp(parameterConfigData.getBmsMaxTemperature())
|
||||
.chargePower(bmsDemandAndChargerOutputData.getOutputPower()) // 充电功率
|
||||
.ratedCapacity(parameterConfigData.getBmsSumEnergy()) // 电池额定容量
|
||||
.nominalEnergy(parameterConfigData.getBmsSumEnergy())
|
||||
.ratedVoltage(chargingHandshakeData.getBmsBatteryVoltage()) // 电池额定总电压
|
||||
.singleMaxVoltage(parameterConfigData.getPileMaxOutputVoltage())
|
||||
.singleMinVoltage(parameterConfigData.getPileMinOutputVoltage())
|
||||
.singleMaxTemp(bmsChargeInfoData.getBmsMaxBatteryTemperature()) // 单体最高温度
|
||||
.singleMinTemp(bmsChargeInfoData.getMinBatteryTemperature()) // 单体最低温度
|
||||
// .ventTemp() // 出风口温度
|
||||
// .environmentTemp() // 环境温度
|
||||
// .gunTemp(realTimeMonitorData.getGunLineTemperature()) // 充电枪温度
|
||||
.gunTemp("0") // 充电枪温度
|
||||
|
||||
.bmsChargeMode(Integer.parseInt(bmsDemandAndChargerOutputData.getBmsChargingModel())) // BMS充电模式
|
||||
|
||||
// .gunTemp("0") // 充电枪温度
|
||||
.doorStatus(Constants.zero) // 舱门状态
|
||||
.bmsVersion("V1.1") // BMS版本
|
||||
.measuringChargeVoltage(bmsDemandAndChargerOutputData.getBmsChargingVoltage()) // 车辆测量充电电压
|
||||
.measuringChargeElectricity(bmsDemandAndChargerOutputData.getBmsChargingCurrent()) // 车辆测量充电电流
|
||||
.maxSingleVoltageGroupNum(new BigDecimal(bmsDemandAndChargerOutputData.getBmsMaxVoltageAndGroup()).intValue()) // 最高单体电压组号
|
||||
.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(parameterConfigData.getBmsRealTimeVoltage()) // 充电前总电压
|
||||
|
||||
|
||||
.build();
|
||||
|
||||
List<ChargeAlgorithmData
|
||||
.ChargingDetailInfo> chargingDetailInfos = transformData(transactionCode, chargerOutputInfoList, parameterConfigData, transactionRecordsData);
|
||||
|
||||
data.setChargingDetailInfo(chargingDetailInfos);
|
||||
|
||||
|
||||
log.info("发送请求前封装数据 data:{}", JSON.toJSONString(data));
|
||||
|
||||
String url = "http://150.158.199.92:58910/gateway/api/user/battery/algorithm/json";
|
||||
@@ -153,4 +143,89 @@ public class ChargeAlgorithmService {
|
||||
log.info("发送请求收到回复 response:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
private List<ChargeAlgorithmData.ChargingDetailInfo> transformData(String transactionCode, List<BMSDemandAndChargerOutputData> chargerOutputInfoList,
|
||||
ParameterConfigData parameterConfigData, TransactionRecordsData transactionRecordsData) {
|
||||
List<ChargeAlgorithmData.ChargingDetailInfo> resultList = new ArrayList<>();
|
||||
ChargeAlgorithmData.ChargingDetailInfo detailInfo;
|
||||
// 获取0x25
|
||||
List<BMSChargeInfoData> bmsChargeInfoList = pileBasicInfoService.getBMSChargeInfoList(transactionCode);
|
||||
// 0x13
|
||||
List<RealTimeMonitorData> chargingRealTimeDataList = orderBasicInfoService.getChargingRealTimeData(transactionCode);
|
||||
|
||||
Map<String, List<BMSChargeInfoData>> collect_0x25 = new LinkedHashMap<>();
|
||||
Map<String, List<RealTimeMonitorData>> collect_0x13 = new LinkedHashMap<>();
|
||||
if (bmsChargeInfoList != null && chargingRealTimeDataList != null) {
|
||||
// 按照dateTime分组(将key设置为 yyyy-MM-dd HH:mm:00 格式)
|
||||
collect_0x25 = bmsChargeInfoList.stream()
|
||||
.map(x -> {
|
||||
x.setDateTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:00", DateUtils.parseDate(x.getDateTime())));
|
||||
return x;
|
||||
})
|
||||
.collect(Collectors.groupingBy(BMSChargeInfoData::getDateTime));
|
||||
|
||||
collect_0x13 = chargingRealTimeDataList.stream()
|
||||
.map(x -> {
|
||||
x.setDateTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:00", DateUtils.parseDate(x.getDateTime())));
|
||||
return x;
|
||||
})
|
||||
.collect(Collectors.groupingBy(RealTimeMonitorData::getDateTime));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(chargerOutputInfoList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
for (BMSDemandAndChargerOutputData realTimeData_0x23 : chargerOutputInfoList) {
|
||||
detailInfo = new ChargeAlgorithmData.ChargingDetailInfo();
|
||||
String dateStr = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:00", DateUtils.parseDate(realTimeData_0x23.getDateTime()));
|
||||
|
||||
// 获取0x13数据
|
||||
detailInfo.setReadCurrentCharge(transactionRecordsData.getAmmeterTotalEnd());
|
||||
detailInfo.setCurrentSoc(new BigDecimal(realTimeData_0x23.getSoc()).intValue());
|
||||
detailInfo.setReportTime(realTimeData_0x23.getDateTime());
|
||||
detailInfo.setMaxAllowElectricity(parameterConfigData.getBmsMaxCurrent());
|
||||
detailInfo.setSingleMaxAllowVoltage(parameterConfigData.getBmsMaxVoltage());
|
||||
detailInfo.setDcv(realTimeData_0x23.getPileVoltageOutput());
|
||||
detailInfo.setDca(realTimeData_0x23.getPileCurrentOutput());
|
||||
detailInfo.setBmsDemandVoltage(realTimeData_0x23.getBmsVoltageDemand());
|
||||
detailInfo.setBmsDemandElectricity(realTimeData_0x23.getBmsCurrentDemand());
|
||||
detailInfo.setChargePower(realTimeData_0x23.getOutputPower());
|
||||
detailInfo.setSingleMaxVoltage(parameterConfigData.getPileMaxOutputVoltage());
|
||||
detailInfo.setSingleMinVoltage(parameterConfigData.getPileMinOutputVoltage());
|
||||
|
||||
detailInfo.setMeasuringChargeVoltage(realTimeData_0x23.getBmsChargingVoltage());
|
||||
detailInfo.setMeasuringChargeElectricity(realTimeData_0x23.getBmsChargingCurrent());
|
||||
detailInfo.setMaxSingleVoltageGroupNum(new BigDecimal(realTimeData_0x23.getBmsMaxVoltageAndGroup()).intValue());
|
||||
|
||||
detailInfo.setMaxAllowTotalVoltage(parameterConfigData.getBmsMaxChargingVoltage());
|
||||
detailInfo.setBeforeChargeTotalVoltage(parameterConfigData.getBmsRealTimeVoltage());
|
||||
|
||||
// 获取该时间的0x25数据
|
||||
List<BMSChargeInfoData> bmsChargeInfoDataList = collect_0x25.get(dateStr);
|
||||
|
||||
if (bmsChargeInfoDataList != null) {
|
||||
BMSChargeInfoData realTimeData_0x25 = bmsChargeInfoDataList.get(0);
|
||||
|
||||
detailInfo.setSingleMaxTemp(realTimeData_0x25.getBmsMaxBatteryTemperature());
|
||||
detailInfo.setSingleMinTemp(realTimeData_0x25.getMinBatteryTemperature());
|
||||
detailInfo.setMaxSingleVoltageNum(Integer.parseInt(realTimeData_0x25.getBmsMaxVoltageNum()));
|
||||
detailInfo.setMaxTempPointNum(Integer.parseInt(realTimeData_0x25.getMaxTemperatureDetectionNum()));
|
||||
detailInfo.setMinTempPointNum(Integer.parseInt(realTimeData_0x25.getMinTemperatureDetectionNum()));
|
||||
detailInfo.setBatteryInsulation(Integer.parseInt(realTimeData_0x25.getBmsBatteryInsulationStatus()));
|
||||
|
||||
// detailInfo.setVentTemp();
|
||||
// detailInfo.setEnvironmentTemp();
|
||||
}
|
||||
// 获取该时间的0x13数据
|
||||
List<RealTimeMonitorData> RealTimeDataList = collect_0x13.get(dateStr);
|
||||
if (RealTimeDataList != null) {
|
||||
RealTimeMonitorData realTimeData_0x13 = RealTimeDataList.get(0);
|
||||
|
||||
detailInfo.setGunTemp(realTimeData_0x13.getGunLineTemperature());
|
||||
}
|
||||
resultList.add(detailInfo);
|
||||
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user