BMS总览+电池簇列表取数逻辑
This commit is contained in:
@ -12,7 +12,7 @@ import com.xzzn.common.annotation.Excel;
|
|||||||
* 单体电池实时数据对象 ems_battery_data
|
* 单体电池实时数据对象 ems_battery_data
|
||||||
*
|
*
|
||||||
* @author xzzn
|
* @author xzzn
|
||||||
* @date 2025-06-19
|
* @date 2025-06-25
|
||||||
*/
|
*/
|
||||||
public class EmsBatteryData extends BaseEntity
|
public class EmsBatteryData extends BaseEntity
|
||||||
{
|
{
|
||||||
@ -62,6 +62,10 @@ public class EmsBatteryData extends BaseEntity
|
|||||||
@Excel(name = "设备唯一标识符")
|
@Excel(name = "设备唯一标识符")
|
||||||
private Long deviceId;
|
private Long deviceId;
|
||||||
|
|
||||||
|
/** 簇设备id */
|
||||||
|
@Excel(name = "簇设备id")
|
||||||
|
private Long clusterDeviceId;
|
||||||
|
|
||||||
public void setId(Long id)
|
public void setId(Long id)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@ -172,6 +176,16 @@ public class EmsBatteryData extends BaseEntity
|
|||||||
return deviceId;
|
return deviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setClusterDeviceId(Long clusterDeviceId)
|
||||||
|
{
|
||||||
|
this.clusterDeviceId = clusterDeviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getClusterDeviceId()
|
||||||
|
{
|
||||||
|
return clusterDeviceId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
@ -191,6 +205,7 @@ public class EmsBatteryData extends BaseEntity
|
|||||||
.append("remark", getRemark())
|
.append("remark", getRemark())
|
||||||
.append("siteId", getSiteId())
|
.append("siteId", getSiteId())
|
||||||
.append("deviceId", getDeviceId())
|
.append("deviceId", getDeviceId())
|
||||||
|
.append("clusterDeviceId", getClusterDeviceId())
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,13 +18,13 @@ public class BMSBatteryClusterDataList {
|
|||||||
private BigDecimal minData;
|
private BigDecimal minData;
|
||||||
|
|
||||||
/** 单体最小值ID */
|
/** 单体最小值ID */
|
||||||
private BigDecimal minDataID;
|
private Long minDataID;
|
||||||
|
|
||||||
/** 单体最大值 */
|
/** 单体最大值 */
|
||||||
private BigDecimal maxData;
|
private BigDecimal maxData;
|
||||||
|
|
||||||
/** 单体最大值ID */
|
/** 单体最大值ID */
|
||||||
private BigDecimal maxDataID;
|
private Long maxDataID;
|
||||||
|
|
||||||
public String getDataName() {
|
public String getDataName() {
|
||||||
return dataName;
|
return dataName;
|
||||||
@ -50,11 +50,11 @@ public class BMSBatteryClusterDataList {
|
|||||||
this.minData = minData;
|
this.minData = minData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getMinDataID() {
|
public Long getMinDataID() {
|
||||||
return minDataID;
|
return minDataID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMinDataID(BigDecimal minDataID) {
|
public void setMinDataID(Long minDataID) {
|
||||||
this.minDataID = minDataID;
|
this.minDataID = minDataID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,11 +66,11 @@ public class BMSBatteryClusterDataList {
|
|||||||
this.maxData = maxData;
|
this.maxData = maxData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getMaxDataID() {
|
public Long getMaxDataID() {
|
||||||
return maxDataID;
|
return maxDataID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxDataID(BigDecimal maxDataID) {
|
public void setMaxDataID(Long maxDataID) {
|
||||||
this.maxDataID = maxDataID;
|
this.maxDataID = maxDataID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,12 @@ public class BMSBatteryDataList {
|
|||||||
/** 单体最低温度 (℃) */
|
/** 单体最低温度 (℃) */
|
||||||
private BigDecimal minTemperature;
|
private BigDecimal minTemperature;
|
||||||
|
|
||||||
|
/** 换电站id */
|
||||||
|
private Long siteId;
|
||||||
|
|
||||||
|
/** 堆id */
|
||||||
|
private Long stackDeviceId;
|
||||||
|
|
||||||
public Long getClusterId() {
|
public Long getClusterId() {
|
||||||
return clusterId;
|
return clusterId;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,130 @@
|
|||||||
|
package com.xzzn.ems.domain.vo;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BMS电池簇-电池单体数据
|
||||||
|
*/
|
||||||
|
public class BatteryClusterDataDetailVo {
|
||||||
|
|
||||||
|
/** 设备id */
|
||||||
|
private Long siteId;
|
||||||
|
|
||||||
|
/** 电池簇id */
|
||||||
|
private Long clusterId;
|
||||||
|
|
||||||
|
/** 电压平均值 */
|
||||||
|
private BigDecimal avgVoltage;
|
||||||
|
|
||||||
|
/** 电压最大值 */
|
||||||
|
private BigDecimal maxVoltage;
|
||||||
|
|
||||||
|
/** 电压最小值 */
|
||||||
|
private BigDecimal minVoltage;
|
||||||
|
|
||||||
|
/** 温度平均值 */
|
||||||
|
private BigDecimal avgTemp;
|
||||||
|
|
||||||
|
/** 温度最大值 */
|
||||||
|
private BigDecimal maxTemp;
|
||||||
|
|
||||||
|
/** 温度最小值 */
|
||||||
|
private BigDecimal minTemp;
|
||||||
|
|
||||||
|
/** soc平均值 */
|
||||||
|
private BigDecimal avgSoc;
|
||||||
|
|
||||||
|
/** soc最大值 */
|
||||||
|
private BigDecimal maxSoc;
|
||||||
|
|
||||||
|
/** soc最小值 */
|
||||||
|
private BigDecimal minSoc;
|
||||||
|
|
||||||
|
public Long getSiteId() {
|
||||||
|
return siteId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSiteId(Long siteId) {
|
||||||
|
this.siteId = siteId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getClusterId() {
|
||||||
|
return clusterId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClusterId(Long clusterId) {
|
||||||
|
this.clusterId = clusterId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getAvgVoltage() {
|
||||||
|
return avgVoltage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvgVoltage(BigDecimal avgVoltage) {
|
||||||
|
this.avgVoltage = avgVoltage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getMaxVoltage() {
|
||||||
|
return maxVoltage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxVoltage(BigDecimal maxVoltage) {
|
||||||
|
this.maxVoltage = maxVoltage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getMinVoltage() {
|
||||||
|
return minVoltage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinVoltage(BigDecimal minVoltage) {
|
||||||
|
this.minVoltage = minVoltage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getAvgTemp() {
|
||||||
|
return avgTemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvgTemp(BigDecimal avgTemp) {
|
||||||
|
this.avgTemp = avgTemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getMaxTemp() {
|
||||||
|
return maxTemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxTemp(BigDecimal maxTemp) {
|
||||||
|
this.maxTemp = maxTemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getMinTemp() {
|
||||||
|
return minTemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinTemp(BigDecimal minTemp) {
|
||||||
|
this.minTemp = minTemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getAvgSoc() {
|
||||||
|
return avgSoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvgSoc(BigDecimal avgSoc) {
|
||||||
|
this.avgSoc = avgSoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getMaxSoc() {
|
||||||
|
return maxSoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxSoc(BigDecimal maxSoc) {
|
||||||
|
this.maxSoc = maxSoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getMinSoc() {
|
||||||
|
return minSoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinSoc(BigDecimal minSoc) {
|
||||||
|
this.minSoc = minSoc;
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,8 @@ package com.xzzn.ems.mapper;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.xzzn.ems.domain.EmsBatteryCluster;
|
import com.xzzn.ems.domain.EmsBatteryCluster;
|
||||||
import com.xzzn.ems.domain.vo.BMSBatteryClusterVo;
|
import com.xzzn.ems.domain.vo.BMSBatteryClusterVo;
|
||||||
|
import com.xzzn.ems.domain.vo.BMSBatteryDataList;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 电池簇数据Mapper接口
|
* 电池簇数据Mapper接口
|
||||||
@ -66,4 +68,12 @@ public interface EmsBatteryClusterMapper
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<BMSBatteryClusterVo> getBMSBatteryCluster(Long siteId);
|
public List<BMSBatteryClusterVo> getBMSBatteryCluster(Long siteId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据site_di和堆id获取簇数据和单体数据
|
||||||
|
* @param siteId
|
||||||
|
* @param stackDeviceId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<BMSBatteryDataList> getBmsBatteryData(@Param("siteId")Long siteId, @Param("stackDeviceId")Long stackDeviceId);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
package com.xzzn.ems.mapper;
|
package com.xzzn.ems.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.xzzn.ems.domain.EmsBatteryData;
|
import com.xzzn.ems.domain.EmsBatteryData;
|
||||||
|
import com.xzzn.ems.domain.vo.BMSBatteryClusterDataList;
|
||||||
|
import com.xzzn.ems.domain.vo.BatteryClusterDataDetailVo;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 单体电池实时数据Mapper接口
|
* 单体电池实时数据Mapper接口
|
||||||
@ -66,4 +71,19 @@ public interface EmsBatteryDataMapper
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public EmsBatteryData getBatteryDataBySiteId(Long siteId);
|
public EmsBatteryData getBatteryDataBySiteId(Long siteId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据siteId和簇id获取单体数据
|
||||||
|
* @param siteId
|
||||||
|
* @param clusterDeviceId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public BatteryClusterDataDetailVo getBatteryDataByClusterId(@Param("siteId")Long siteId, @Param("clusterDeviceId")Long clusterDeviceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最大最小的单体id
|
||||||
|
* @param dataVo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<Map<String, Object>> getDataIdsMap(BatteryClusterDataDetailVo dataVo);
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,9 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.math.RoundingMode;
|
||||||
import java.util.Calendar;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 单点监控 服务层实现
|
* 单点监控 服务层实现
|
||||||
@ -21,6 +21,12 @@ import java.util.List;
|
|||||||
@Service
|
@Service
|
||||||
public class SingleSiteServiceImpl implements ISingleSiteService {
|
public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||||
|
|
||||||
|
private static final String CLUSTER_DATA_TEP = "温度";
|
||||||
|
|
||||||
|
private static final String CLUSTER_DATA_VOLTAGE = "电压";
|
||||||
|
|
||||||
|
private static final String CLUSTER_DATA_SOC = "SOC";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EmsPcsDataMapper emsPcsDataMapper;
|
private EmsPcsDataMapper emsPcsDataMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -161,9 +167,10 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
|||||||
if (!CollectionUtils.isEmpty(bmsOverViewVoList)) {
|
if (!CollectionUtils.isEmpty(bmsOverViewVoList)) {
|
||||||
for (BMSOverViewVo bmsOverViewVo : bmsOverViewVoList) {
|
for (BMSOverViewVo bmsOverViewVo : bmsOverViewVoList) {
|
||||||
// 获取单体电池数据-待确认
|
// 获取单体电池数据-待确认
|
||||||
Long deviceId = bmsOverViewVo.getDeviceId();
|
Long stackDeviceId = bmsOverViewVo.getDeviceId();
|
||||||
if (deviceId != null) {
|
if (stackDeviceId != null) {
|
||||||
List<BMSBatteryDataList> batteryDataList = new ArrayList();
|
List<BMSBatteryDataList> batteryDataList = new ArrayList<>();
|
||||||
|
batteryDataList = emsBatteryClusterMapper.getBmsBatteryData(siteId,stackDeviceId);
|
||||||
bmsOverViewVo.setBatteryDataList(batteryDataList);
|
bmsOverViewVo.setBatteryDataList(batteryDataList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,12 +188,63 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
|||||||
bmsBatteryClusterVoList = emsBatteryClusterMapper.getBMSBatteryCluster(siteId);
|
bmsBatteryClusterVoList = emsBatteryClusterMapper.getBMSBatteryCluster(siteId);
|
||||||
if (!CollectionUtils.isEmpty(bmsBatteryClusterVoList)) {
|
if (!CollectionUtils.isEmpty(bmsBatteryClusterVoList)) {
|
||||||
for (BMSBatteryClusterVo bmsBatteryClusterVo : bmsBatteryClusterVoList) {
|
for (BMSBatteryClusterVo bmsBatteryClusterVo : bmsBatteryClusterVoList) {
|
||||||
// 获取单体电池数据
|
|
||||||
Long deviceId = bmsBatteryClusterVo.getDeviceId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Long clusterDeviceId = bmsBatteryClusterVo.getDeviceId();
|
||||||
|
List<BMSBatteryClusterDataList> clusterDataList = new ArrayList<>();
|
||||||
|
if (clusterDeviceId != null) {
|
||||||
|
// 获取单体电池数据-平均/最大/最小
|
||||||
|
BatteryClusterDataDetailVo batteryClusterDataDetailVo = emsBatteryDataMapper.getBatteryDataByClusterId(siteId,clusterDeviceId);
|
||||||
|
// 处理数据
|
||||||
|
if (batteryClusterDataDetailVo != null) {
|
||||||
|
BMSBatteryClusterDataList voltageData = new BMSBatteryClusterDataList();
|
||||||
|
BMSBatteryClusterDataList tempData = new BMSBatteryClusterDataList();
|
||||||
|
BMSBatteryClusterDataList socData = new BMSBatteryClusterDataList();
|
||||||
|
// 设值
|
||||||
|
voltageData.setDataName(CLUSTER_DATA_VOLTAGE);
|
||||||
|
voltageData.setAvgData(batteryClusterDataDetailVo.getAvgVoltage());
|
||||||
|
voltageData.setMaxData(batteryClusterDataDetailVo.getMaxVoltage());
|
||||||
|
voltageData.setMinData(batteryClusterDataDetailVo.getMinVoltage());
|
||||||
|
tempData.setDataName(CLUSTER_DATA_TEP);
|
||||||
|
tempData.setAvgData(batteryClusterDataDetailVo.getAvgTemp());
|
||||||
|
tempData.setMaxData(batteryClusterDataDetailVo.getMaxTemp());
|
||||||
|
tempData.setMinData(batteryClusterDataDetailVo.getMinTemp());
|
||||||
|
socData.setDataName(CLUSTER_DATA_SOC);
|
||||||
|
socData.setAvgData(batteryClusterDataDetailVo.getAvgSoc());
|
||||||
|
socData.setMaxData(batteryClusterDataDetailVo.getMaxSoc());
|
||||||
|
socData.setMinData(batteryClusterDataDetailVo.getMinSoc());
|
||||||
|
|
||||||
|
// 设置对应单体id
|
||||||
|
List<Map<String,Object>> dataIdMapList = emsBatteryDataMapper.getDataIdsMap(batteryClusterDataDetailVo);
|
||||||
|
Map<String,Long> resultIdMap = new HashMap<>();
|
||||||
|
if (!CollectionUtils.isEmpty(dataIdMapList)) {
|
||||||
|
resultIdMap = dataIdMapList.stream()
|
||||||
|
.filter(map -> map.containsKey("type") && map.containsKey("device_id")) // 过滤无效数据
|
||||||
|
.filter(map -> map.get("type") instanceof String && map.get("device_id") instanceof Number) // 确保类型正确
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
map -> (String) map.get("type"), // 键:type 字段
|
||||||
|
map -> ((Number) map.get("device_id")).longValue(), // 值:device_id 转为 int
|
||||||
|
(existing, replacement) -> existing // 处理键冲突的策略
|
||||||
|
));
|
||||||
|
|
||||||
|
// 电压
|
||||||
|
voltageData.setMaxDataID(resultIdMap.get("maxVoltageId"));
|
||||||
|
voltageData.setMaxDataID(resultIdMap.get("maxVoltageId"));
|
||||||
|
// 温度
|
||||||
|
tempData.setMaxDataID(resultIdMap.get("maxTempId"));
|
||||||
|
tempData.setMinDataID(resultIdMap.get("minTempId"));
|
||||||
|
// soc
|
||||||
|
socData.setMaxDataID(resultIdMap.get("maxSocId"));
|
||||||
|
socData.setMinDataID(resultIdMap.get("minSocId"));
|
||||||
|
}
|
||||||
|
clusterDataList.add(voltageData);
|
||||||
|
clusterDataList.add(tempData);
|
||||||
|
clusterDataList.add(socData);
|
||||||
|
}
|
||||||
|
bmsBatteryClusterVo.setBatteryDataList(clusterDataList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return bmsBatteryClusterVoList;
|
return bmsBatteryClusterVoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user