update 电池算法应用Service

This commit is contained in:
Lemon
2025-04-07 14:07:17 +08:00
parent cd42805c21
commit a885bdfbb0
2 changed files with 16 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
package com.jsowell.thirdparty.platform.domain; package com.jsowell.thirdparty.platform.domain;
import com.alibaba.fastjson2.annotation.JSONField;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
@@ -114,6 +115,7 @@ public class ChargeAlgorithmData {
*/ */
private String vin; private String vin;
@JSONField(name = "data")
private List<ChargingDetailInfo> chargingDetailInfo; private List<ChargingDetailInfo> chargingDetailInfo;
@Data @Data

View File

@@ -2,6 +2,7 @@ package com.jsowell.thirdparty.platform.service.impl;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.jsowell.common.constant.CacheConstants; import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.constant.Constants; import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.domain.ykc.*; import com.jsowell.common.core.domain.ykc.*;
@@ -132,13 +133,15 @@ public class ChargeAlgorithmService {
data.setChargingDetailInfo(chargingDetailInfos); data.setChargingDetailInfo(chargingDetailInfos);
JSONObject jsonObject = new JSONObject();
jsonObject.put("dataJason", data);
log.info("发送请求前封装数据 data:{}", JSON.toJSONString(data)); log.info("发送请求前封装数据 data:{}", JSON.toJSONString(jsonObject));
String url = "http://150.158.199.92:58910/gateway/api/user/battery/algorithm/json"; String url = "http://150.158.199.92:58910/gateway/api/user/battery/algorithm/json";
String clientId = "e488bac5f70b496fa2d82065089e5f81"; String clientId = "e488bac5f70b496fa2d82065089e5f81";
// 发送请求 // 发送请求
String response = HttpRequest.post(url).header("clientId", clientId).body(JSON.toJSONString(data)).execute().body(); String response = HttpRequest.post(url).header("clientId", clientId).body(JSON.toJSONString(jsonObject)).execute().body();
log.info("发送请求收到回复 response:{}", response); log.info("发送请求收到回复 response:{}", response);
return response; return response;
@@ -155,7 +158,7 @@ public class ChargeAlgorithmService {
Map<String, List<BMSChargeInfoData>> collect_0x25 = new LinkedHashMap<>(); Map<String, List<BMSChargeInfoData>> collect_0x25 = new LinkedHashMap<>();
Map<String, List<RealTimeMonitorData>> collect_0x13 = new LinkedHashMap<>(); Map<String, List<RealTimeMonitorData>> collect_0x13 = new LinkedHashMap<>();
if (bmsChargeInfoList != null && chargingRealTimeDataList != null) { if (bmsChargeInfoList != null) {
// 按照dateTime分组将key设置为 yyyy-MM-dd HH:mm:00 格式) // 按照dateTime分组将key设置为 yyyy-MM-dd HH:mm:00 格式)
collect_0x25 = bmsChargeInfoList.stream() collect_0x25 = bmsChargeInfoList.stream()
.map(x -> { .map(x -> {
@@ -164,6 +167,9 @@ public class ChargeAlgorithmService {
}) })
.collect(Collectors.groupingBy(BMSChargeInfoData::getDateTime)); .collect(Collectors.groupingBy(BMSChargeInfoData::getDateTime));
}
if (chargingRealTimeDataList != null) {
collect_0x13 = chargingRealTimeDataList.stream() collect_0x13 = chargingRealTimeDataList.stream()
.map(x -> { .map(x -> {
x.setDateTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:00", DateUtils.parseDate(x.getDateTime()))); x.setDateTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:00", DateUtils.parseDate(x.getDateTime())));
@@ -200,6 +206,9 @@ public class ChargeAlgorithmService {
detailInfo.setMaxAllowTotalVoltage(parameterConfigData.getBmsMaxChargingVoltage()); detailInfo.setMaxAllowTotalVoltage(parameterConfigData.getBmsMaxChargingVoltage());
detailInfo.setBeforeChargeTotalVoltage(parameterConfigData.getBmsRealTimeVoltage()); detailInfo.setBeforeChargeTotalVoltage(parameterConfigData.getBmsRealTimeVoltage());
detailInfo.setVentTemp("0");
detailInfo.setEnvironmentTemp("0");
// 获取该时间的0x25数据 // 获取该时间的0x25数据
List<BMSChargeInfoData> bmsChargeInfoDataList = collect_0x25.get(dateStr); List<BMSChargeInfoData> bmsChargeInfoDataList = collect_0x25.get(dateStr);
@@ -222,6 +231,8 @@ public class ChargeAlgorithmService {
RealTimeMonitorData realTimeData_0x13 = RealTimeDataList.get(0); RealTimeMonitorData realTimeData_0x13 = RealTimeDataList.get(0);
detailInfo.setGunTemp(realTimeData_0x13.getGunLineTemperature()); detailInfo.setGunTemp(realTimeData_0x13.getGunLineTemperature());
}else {
detailInfo.setGunTemp("0");
} }
resultList.add(detailInfo); resultList.add(detailInfo);