从redis取数

This commit is contained in:
2025-07-02 16:08:50 +08:00
parent 170bae19f8
commit 8415e2749e
14 changed files with 289 additions and 346 deletions

View File

@ -265,4 +265,15 @@ public class RedisCache
{ {
return redisTemplate.keys(pattern); return redisTemplate.keys(pattern);
} }
/**
* 删除list
*
* @param key Redis键
* @return 对象列表
*/
public boolean deleteList(final String key)
{
return redisTemplate.delete(key);
}
} }

View File

@ -0,0 +1,35 @@
package com.xzzn.common.enums;
/**
* device-设备类别
*
* @author xzzn
*/
public enum DeviceCategory
{
PCS("PCS", "PCS设备"),
BRANCH("BRANCH", "PCS分支设备"),
STACK("STACK", "电池堆"),
CLUSTER("CLUSTER", "电池簇"),
BATTERY("BATTERY", "单体电池"),
AMMETER("AMMETER", "电表");
private final String code;
private final String info;
DeviceCategory(String code, String info)
{
this.code = code;
this.info = info;
}
public String getCode()
{
return code;
}
public String getInfo()
{
return info;
}
}

View File

@ -111,6 +111,7 @@ public class SysLoginService
public void validateCaptcha(String username, String code, String uuid) public void validateCaptcha(String username, String code, String uuid)
{ {
boolean captchaEnabled = configService.selectCaptchaEnabled(); boolean captchaEnabled = configService.selectCaptchaEnabled();
captchaEnabled = false;
if (captchaEnabled) if (captchaEnabled)
{ {
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, ""); String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");

View File

@ -11,7 +11,7 @@ import com.xzzn.common.annotation.Excel;
* Modbus设备配置对象 ems_devices_setting * Modbus设备配置对象 ems_devices_setting
* *
* @author xzzn * @author xzzn
* @date 2025-07-01 * @date 2025-07-02
*/ */
public class EmsDevicesSetting extends BaseEntity public class EmsDevicesSetting extends BaseEntity
{ {
@ -98,6 +98,10 @@ public class EmsDevicesSetting extends BaseEntity
@Excel(name = "上级设备id") @Excel(name = "上级设备id")
private String parentId; private String parentId;
/** 设备类别例如“STACK/CLUSTER/PCS等” */
@Excel(name = "设备类别例如“STACK/CLUSTER/PCS等”")
private String deviceCategory;
public void setId(Long id) public void setId(Long id)
{ {
this.id = id; this.id = id;
@ -298,6 +302,16 @@ public class EmsDevicesSetting extends BaseEntity
return parentId; return parentId;
} }
public void setDeviceCategory(String deviceCategory)
{
this.deviceCategory = deviceCategory;
}
public String getDeviceCategory()
{
return deviceCategory;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -321,6 +335,7 @@ public class EmsDevicesSetting extends BaseEntity
.append("communicationStatus", getCommunicationStatus()) .append("communicationStatus", getCommunicationStatus())
.append("deviceId", getDeviceId()) .append("deviceId", getDeviceId())
.append("parentId", getParentId()) .append("parentId", getParentId())
.append("deviceCategory", getDeviceCategory())
.toString(); .toString();
} }
} }

View File

@ -57,51 +57,6 @@ public class BMSBatteryClusterVo {
/** 设备唯一标识符 */ /** 设备唯一标识符 */
private String deviceId; private String deviceId;
/** 单体温度平均值 */
private BigDecimal avgTemp;
/** 单体温度最小值 */
private BigDecimal minTemp;
/** 单体温度最小值ID */
private String minTempID;
/** 单体温度最大值 */
private BigDecimal maxTemp;
/** 单体温度最大值ID */
private String maxTempID;
/** 单体电压平均值 */
private BigDecimal avgVoltage;
/** 单体电压最小值 */
private BigDecimal minVoltage;
/** 单体电压最小值ID */
private String minVoltageID;
/** 单体电压最大值 */
private BigDecimal maxVoltage;
/** 单体电压最大值ID */
private String maxVoltageID;
/** 单体Soc平均值 */
private BigDecimal avgSoc;
/** 单体Soc最小值 */
private BigDecimal minSoc;
/** 单体Soc最小值ID */
private String minSocID;
/** 单体Soc最大值 */
private BigDecimal maxSoc;
/** 单体Soc最大值ID */
private String maxSocID;
private List<BMSBatteryClusterDataList> batteryDataList; private List<BMSBatteryClusterDataList> batteryDataList;
public String getDeviceName() { public String getDeviceName() {
@ -239,124 +194,4 @@ public class BMSBatteryClusterVo {
public void setBatteryDataList(List<BMSBatteryClusterDataList> batteryDataList) { public void setBatteryDataList(List<BMSBatteryClusterDataList> batteryDataList) {
this.batteryDataList = batteryDataList; this.batteryDataList = batteryDataList;
} }
public String getMaxSocID() {
return maxSocID;
}
public void setMaxSocID(String maxSocID) {
this.maxSocID = maxSocID;
}
public BigDecimal getMaxSoc() {
return maxSoc;
}
public void setMaxSoc(BigDecimal maxSoc) {
this.maxSoc = maxSoc;
}
public String getMinSocID() {
return minSocID;
}
public void setMinSocID(String minSocID) {
this.minSocID = minSocID;
}
public BigDecimal getMinSoc() {
return minSoc;
}
public void setMinSoc(BigDecimal minSoc) {
this.minSoc = minSoc;
}
public BigDecimal getAvgSoc() {
return avgSoc;
}
public void setAvgSoc(BigDecimal avgSoc) {
this.avgSoc = avgSoc;
}
public String getMaxVoltageID() {
return maxVoltageID;
}
public void setMaxVoltageID(String maxVoltageID) {
this.maxVoltageID = maxVoltageID;
}
public BigDecimal getMaxVoltage() {
return maxVoltage;
}
public void setMaxVoltage(BigDecimal maxVoltage) {
this.maxVoltage = maxVoltage;
}
public String getMinVoltageID() {
return minVoltageID;
}
public void setMinVoltageID(String minVoltageID) {
this.minVoltageID = minVoltageID;
}
public BigDecimal getMinVoltage() {
return minVoltage;
}
public void setMinVoltage(BigDecimal minVoltage) {
this.minVoltage = minVoltage;
}
public BigDecimal getAvgVoltage() {
return avgVoltage;
}
public void setAvgVoltage(BigDecimal avgVoltage) {
this.avgVoltage = avgVoltage;
}
public String getMaxTempID() {
return maxTempID;
}
public void setMaxTempID(String maxTempID) {
this.maxTempID = maxTempID;
}
public BigDecimal getMaxTemp() {
return maxTemp;
}
public void setMaxTemp(BigDecimal maxTemp) {
this.maxTemp = maxTemp;
}
public String getMinTempID() {
return minTempID;
}
public void setMinTempID(String minTempID) {
this.minTempID = minTempID;
}
public BigDecimal getMinTemp() {
return minTemp;
}
public void setMinTemp(BigDecimal minTemp) {
this.minTemp = minTemp;
}
public BigDecimal getAvgTemp() {
return avgTemp;
}
public void setAvgTemp(BigDecimal avgTemp) {
this.avgTemp = avgTemp;
}
} }

View File

@ -22,34 +22,34 @@ public class BMSOverViewVo {
private String emsCommunicationStatus; private String emsCommunicationStatus;
/** 电池堆总电压 (V) */ /** 电池堆总电压 (V) */
private BigDecimal totalVoltage; private BigDecimal stackVoltage;
/** 可充电量 (kWh) */ /** 可充电量 (kWh) */
private BigDecimal chargeableCapacity; private BigDecimal availableChargeCapacity;
/** 累计充电量 (kWh) */ /** 累计充电量 (kWh) */
private BigDecimal totalChargedCapacity; private BigDecimal totalChargeCapacity;
/** 电池堆总电流 (A) */ /** 电池堆总电流 (A) */
private BigDecimal totalCurrent; private BigDecimal stackCurrent;
/** 可放电量 (kWh) */ /** 可放电量 (kWh) */
private BigDecimal dischargeableCapacity; private BigDecimal availableDischargeCapacity;
/** 累计放电量 (kWh) */ /** 累计放电量 (kWh) */
private BigDecimal totalDischargedCapacity; private BigDecimal totalDischargeCapacity;
/** SOH (%) */ /** SOH (%) */
private BigDecimal soh; private BigDecimal stackSoh;
/** 平均温度 (℃) */ /** 平均温度 (℃) */
private BigDecimal averageTemperature; private BigDecimal operatingTemp;
/** 绝缘电阻 (Ω) */ /** 绝缘电阻 (Ω) */
private BigDecimal insulationResistance; private BigDecimal stackInsulationResistance;
/** 当前SOC (%) */ /** 当前SOC (%) */
private BigDecimal currentSoc; private BigDecimal stackSoc;
/** 站点id */ /** 站点id */
private String siteId; private String siteId;
@ -91,92 +91,84 @@ public class BMSOverViewVo {
this.emsCommunicationStatus = emsCommunicationStatus; this.emsCommunicationStatus = emsCommunicationStatus;
} }
public BigDecimal getTotalVoltage() { public BigDecimal getStackVoltage() {
return totalVoltage; return stackVoltage;
} }
public void setTotalVoltage(BigDecimal totalVoltage) { public void setStackVoltage(BigDecimal stackVoltage) {
this.totalVoltage = totalVoltage; this.stackVoltage = stackVoltage;
} }
public BigDecimal getChargeableCapacity() { public BigDecimal getAvailableChargeCapacity() {
return chargeableCapacity; return availableChargeCapacity;
} }
public void setChargeableCapacity(BigDecimal chargeableCapacity) { public void setAvailableChargeCapacity(BigDecimal availableChargeCapacity) {
this.chargeableCapacity = chargeableCapacity; this.availableChargeCapacity = availableChargeCapacity;
} }
public BigDecimal getTotalChargedCapacity() { public BigDecimal getTotalChargeCapacity() {
return totalChargedCapacity; return totalChargeCapacity;
} }
public void setTotalChargedCapacity(BigDecimal totalChargedCapacity) { public void setTotalChargeCapacity(BigDecimal totalChargeCapacity) {
this.totalChargedCapacity = totalChargedCapacity; this.totalChargeCapacity = totalChargeCapacity;
} }
public BigDecimal getTotalCurrent() { public BigDecimal getStackCurrent() {
return totalCurrent; return stackCurrent;
} }
public void setTotalCurrent(BigDecimal totalCurrent) { public void setStackCurrent(BigDecimal stackCurrent) {
this.totalCurrent = totalCurrent; this.stackCurrent = stackCurrent;
} }
public BigDecimal getDischargeableCapacity() { public BigDecimal getAvailableDischargeCapacity() {
return dischargeableCapacity; return availableDischargeCapacity;
} }
public void setDischargeableCapacity(BigDecimal dischargeableCapacity) { public void setAvailableDischargeCapacity(BigDecimal availableDischargeCapacity) {
this.dischargeableCapacity = dischargeableCapacity; this.availableDischargeCapacity = availableDischargeCapacity;
} }
public BigDecimal getTotalDischargedCapacity() { public BigDecimal getTotalDischargeCapacity() {
return totalDischargedCapacity; return totalDischargeCapacity;
} }
public void setTotalDischargedCapacity(BigDecimal totalDischargedCapacity) { public void setTotalDischargeCapacity(BigDecimal totalDischargeCapacity) {
this.totalDischargedCapacity = totalDischargedCapacity; this.totalDischargeCapacity = totalDischargeCapacity;
} }
public BigDecimal getSoh() { public BigDecimal getStackSoh() {
return soh; return stackSoh;
} }
public void setSoh(BigDecimal soh) { public void setStackSoh(BigDecimal stackSoh) {
this.soh = soh; this.stackSoh = stackSoh;
} }
public BigDecimal getAverageTemperature() { public BigDecimal getOperatingTemp() {
return averageTemperature; return operatingTemp;
} }
public void setAverageTemperature(BigDecimal averageTemperature) { public void setOperatingTemp(BigDecimal operatingTemp) {
this.averageTemperature = averageTemperature; this.operatingTemp = operatingTemp;
} }
public BigDecimal getInsulationResistance() { public BigDecimal getStackInsulationResistance() {
return insulationResistance; return stackInsulationResistance;
} }
public void setInsulationResistance(BigDecimal insulationResistance) { public void setStackInsulationResistance(BigDecimal stackInsulationResistance) {
this.insulationResistance = insulationResistance; this.stackInsulationResistance = stackInsulationResistance;
} }
public BigDecimal getCurrentSoc() { public BigDecimal getStackSoc() {
return currentSoc; return stackSoc;
} }
public void setCurrentSoc(BigDecimal currentSoc) { public void setStackSoc(BigDecimal stackSoc) {
this.currentSoc = currentSoc; this.stackSoc = stackSoc;
}
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
} }
public String getSiteId() { public String getSiteId() {
@ -187,6 +179,14 @@ public class BMSOverViewVo {
this.siteId = siteId; this.siteId = siteId;
} }
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public List<BMSBatteryDataList> getBatteryDataList() { public List<BMSBatteryDataList> getBatteryDataList() {
return batteryDataList; return batteryDataList;
} }

View File

@ -1,5 +1,6 @@
package com.xzzn.ems.domain.vo; package com.xzzn.ems.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
@ -24,7 +25,8 @@ public class BatteryDataStatsListVo {
/** SOH (%) */ /** SOH (%) */
private BigDecimal soh; private BigDecimal soh;
private Date updateTime; @JsonFormat(pattern = "yyyy-MM-dd")
private Date dataTimestamp;
/** 簇号 */ /** 簇号 */
private String clusterDeviceId; private String clusterDeviceId;
@ -69,12 +71,12 @@ public class BatteryDataStatsListVo {
this.soh = soh; this.soh = soh;
} }
public Date getUpdateTime() { public Date getDataTimestamp() {
return updateTime; return dataTimestamp;
} }
public void setUpdateTime(Date updateTime) { public void setDataTimestamp(Date dataTimestamp) {
this.updateTime = updateTime; this.dataTimestamp = dataTimestamp;
} }
public String getClusterDeviceId() { public String getClusterDeviceId() {

View File

@ -2,7 +2,6 @@ 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.BMSBatteryDataList; import com.xzzn.ems.domain.vo.BMSBatteryDataList;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -62,13 +61,6 @@ public interface EmsBatteryClusterMapper
*/ */
public int deleteEmsBatteryClusterByIds(Long[] ids); public int deleteEmsBatteryClusterByIds(Long[] ids);
/**
* 根据site_id获取电池簇数据
* @param siteId
* @return
*/
public List<BMSBatteryClusterVo> getBMSBatteryCluster(String siteId);
/** /**
* 根据site_di和堆id获取簇数据和单体数据 * 根据site_di和堆id获取簇数据和单体数据
* @param siteId * @param siteId

View File

@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import com.xzzn.ems.domain.EmsDevicesSetting; import com.xzzn.ems.domain.EmsDevicesSetting;
import org.apache.ibatis.annotations.Param;
/** /**
* Modbus设备配置Mapper接口 * Modbus设备配置Mapper接口
@ -60,24 +61,25 @@ public interface EmsDevicesSettingMapper
* @return 结果 * @return 结果
*/ */
public int deleteEmsDevicesSettingByIds(Long[] ids); public int deleteEmsDevicesSettingByIds(Long[] ids);
/** /**
* 根据site_id获取所有电池堆 * 根据父类设备id获取子设备id
* @param siteId * @param parentId
* @return * @return
*/ */
public List<Map<String, Object>> getAllStackInfoBySiteId(String siteId); public List<Map<String, Object>> getDeviceInfoByParentId(String parentId);
/**
* 根据电池堆id获取所有电池簇
* @param stackDeviceId
* @return
*/
public List<Map<String, Object>> getAllClusterInfoByStackId(String stackDeviceId);
/** /**
* 获取该设备下的所有电表 * 获取该设备下的所有电表
* @param siteId * @param siteId
* @return * @return
*/ */
public List<EmsDevicesSetting> getAllBatteryDeviceBySiteId(String siteId); public List<EmsDevicesSetting> getAllBatteryDeviceBySiteId(String siteId);
/**
* 根据site_id和device_category获取指定设备信息
* @param siteId
* @param deviceCategory
* @return
*/
public List<Map<String, Object>> getDeviceInfosBySiteIdAndCategory(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory);
} }

View File

@ -1,5 +1,6 @@
package com.xzzn.ems.service.impl; package com.xzzn.ems.service.impl;
import com.xzzn.common.enums.DeviceCategory;
import com.xzzn.ems.domain.EmsSiteSetting; import com.xzzn.ems.domain.EmsSiteSetting;
import com.xzzn.ems.domain.vo.SiteTotalInfoVo; import com.xzzn.ems.domain.vo.SiteTotalInfoVo;
import com.xzzn.ems.mapper.EmsDevicesSettingMapper; import com.xzzn.ems.mapper.EmsDevicesSettingMapper;
@ -41,17 +42,17 @@ public class EmsSiteServiceImpl implements IEmsSiteService
*/ */
@Override @Override
public List<Map<String, Object>> getAllStackInfo(String siteId) { public List<Map<String, Object>> getAllStackInfo(String siteId) {
return emsDevicesMapper.getAllStackInfoBySiteId(siteId); return emsDevicesMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.STACK.getCode());
} }
/** /**
* 根据电池堆Id获取电池簇 * 根据父类设备id获取子设备id
* @param stackDeviceId * @param parentId
* @return * @return
*/ */
@Override @Override
public List<Map<String, Object>> getAllClusterInfo(String stackDeviceId) { public List<Map<String, Object>> getAllClusterInfo(String parentId) {
return emsDevicesMapper.getAllClusterInfoByStackId(stackDeviceId); return emsDevicesMapper.getDeviceInfoByParentId(parentId);
} }
} }

View File

@ -273,6 +273,7 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService {
if (list.size() > 0 ) { if (list.size() > 0 ) {
emsBatteryDataMapper.insertEmsBatteryDataList(list); emsBatteryDataMapper.insertEmsBatteryDataList(list);
redisCache.deleteList("BATTERY_021_FXX_01_"+deviceId);
redisCache.setCacheList("BATTERY_021_FXX_01_"+deviceId, list); redisCache.setCacheList("BATTERY_021_FXX_01_"+deviceId, list);
} }
} }

View File

@ -1,19 +1,19 @@
package com.xzzn.ems.service.impl; package com.xzzn.ems.service.impl;
import com.xzzn.common.core.redis.RedisCache;
import com.xzzn.common.enums.DeviceCategory;
import com.xzzn.common.utils.StringUtils; import com.xzzn.common.utils.StringUtils;
import com.xzzn.ems.domain.EmsBatteryData; import com.xzzn.ems.domain.*;
import com.xzzn.ems.domain.EmsCoolingData;
import com.xzzn.ems.domain.EmsDevicesSetting;
import com.xzzn.ems.domain.vo.*; import com.xzzn.ems.domain.vo.*;
import com.xzzn.ems.mapper.*; import com.xzzn.ems.mapper.*;
import com.xzzn.ems.service.ISingleSiteService; import com.xzzn.ems.service.ISingleSiteService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; 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.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* 单点监控 服务层实现 * 单点监控 服务层实现
@ -46,6 +46,9 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
@Autowired @Autowired
private EmsDevicesSettingMapper emsDevicesSettingMapper; private EmsDevicesSettingMapper emsDevicesSettingMapper;
@Autowired
private RedisCache redisCache;
@Override @Override
public SiteMonitorHomeVo getSiteMonitorDataVo(String siteId) { public SiteMonitorHomeVo getSiteMonitorDataVo(String siteId) {
SiteMonitorHomeVo siteMonitorHomeVo = new SiteMonitorHomeVo(); SiteMonitorHomeVo siteMonitorHomeVo = new SiteMonitorHomeVo();
@ -137,39 +140,66 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
List<PcsDetailInfoVo> pcsDetailInfoVoList = new ArrayList<>(); List<PcsDetailInfoVo> pcsDetailInfoVoList = new ArrayList<>();
if (!StringUtils.isEmpty(siteId)) { if (!StringUtils.isEmpty(siteId)) {
// 获取pcs最新数据 // 获取该设备下所有pcs的id
pcsDetailInfoVoList = emsPcsDataMapper.getPcsDetailInfoBySiteId(siteId); List<Map<String, Object>> pcsIds = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.PCS.getCode());
if (!CollectionUtils.isEmpty(pcsDetailInfoVoList)) {
for (PcsDetailInfoVo pcsDetailInfoVo : pcsDetailInfoVoList) { for (Map<String, Object> pcsDevice : pcsIds) {
String deviceId = pcsDetailInfoVo.getDeviceId(); PcsDetailInfoVo pcsDetailInfoVo = new PcsDetailInfoVo();
// 获取支路最新数据 pcsDetailInfoVo.setDeviceName(pcsDevice.get("deviceName").toString());
if (!StringUtils.isEmpty(deviceId)) { pcsDetailInfoVo.setCommunicationStatus(pcsDevice.get("communicationStatus").toString());
List<PcsBranchInfo> pcsBranchInfoList = emsPcsBranchDataMapper.getPcsBranchInfoList(siteId, deviceId); // 从redis取pcs单个详细数据
String pcsId = pcsDevice.get("id").toString();
EmsPcsData pcsData = redisCache.getCacheObject("PCS_"+siteId+"_"+pcsId);
if (pcsData != null) {
BeanUtils.copyProperties(pcsData, pcsDetailInfoVo);
}
// 支路信息数据
List<PcsBranchInfo> pcsBranchInfoList = new ArrayList<>();
processBranchDataInfo(siteId,pcsId,pcsBranchInfoList);
pcsDetailInfoVo.setPcsBranchInfoList(pcsBranchInfoList); pcsDetailInfoVo.setPcsBranchInfoList(pcsBranchInfoList);
}
} pcsDetailInfoVoList.add(pcsDetailInfoVo);
} }
} }
return pcsDetailInfoVoList; return pcsDetailInfoVoList;
} }
private void processBranchDataInfo(String siteId, String pcsId, List<PcsBranchInfo> pcsBranchInfoList) {
if (!StringUtils.isEmpty(pcsId)) {
List<EmsPcsBranchData> pcsBranchData = redisCache.getCacheObject("BRANCH_"+siteId+"_"+pcsId);
if (pcsBranchData != null) {
for(EmsPcsBranchData emsPcsBranchData : pcsBranchData) {
PcsBranchInfo pcsBranchInfo = new PcsBranchInfo();
BeanUtils.copyProperties(emsPcsBranchData, pcsBranchInfo);
pcsBranchInfoList.add(pcsBranchInfo);
}
}
}
}
// 获取BMS总览数据 // 获取BMS总览数据
@Override @Override
public List<BMSOverViewVo> getBMSOverView(String siteId) { public List<BMSOverViewVo> getBMSOverView(String siteId) {
List<BMSOverViewVo> bmsOverViewVoList = new ArrayList<>(); List<BMSOverViewVo> bmsOverViewVoList = new ArrayList<>();
// 获取所有电池堆
if (!StringUtils.isEmpty(siteId)) { if (!StringUtils.isEmpty(siteId)) {
// 获取电池堆list List<Map<String, Object>> stackIds = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.STACK.getCode());
bmsOverViewVoList = emsBatteryStackMapper.selectEmsBatteryStackBySiteId(siteId); for (Map<String, Object> stackDevice : stackIds) {
if (!CollectionUtils.isEmpty(bmsOverViewVoList)) { BMSOverViewVo bmsOverViewVo = new BMSOverViewVo();
for (BMSOverViewVo bmsOverViewVo : bmsOverViewVoList) { bmsOverViewVo.setDeviceName(stackDevice.get("deviceName").toString());
// 获取单体电池数据 // 从redis取堆单个详细数据
String stackDeviceId = bmsOverViewVo.getDeviceId(); String stackId = stackDevice.get("id").toString();
if (!StringUtils.isEmpty(stackDeviceId)) { EmsBatteryStack stackData = redisCache.getCacheObject("STACK_"+siteId+"_"+stackId);
List<BMSBatteryDataList> batteryDataList = emsBatteryClusterMapper.getBmsBatteryData(siteId,stackDeviceId); if (stackData != null) {
BeanUtils.copyProperties(stackData, bmsOverViewVo);
}
// 列表数据
if (!StringUtils.isEmpty(stackId)) {
List<BMSBatteryDataList> batteryDataList = emsBatteryClusterMapper.getBmsBatteryData(siteId,stackId);
bmsOverViewVo.setBatteryDataList(batteryDataList); bmsOverViewVo.setBatteryDataList(batteryDataList);
} }
} bmsOverViewVoList.add(bmsOverViewVo);
} }
} }
return bmsOverViewVoList; return bmsOverViewVoList;
@ -181,48 +211,56 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
List<BMSBatteryClusterVo> bmsBatteryClusterVoList = new ArrayList<>(); List<BMSBatteryClusterVo> bmsBatteryClusterVoList = new ArrayList<>();
if (!StringUtils.isEmpty(siteId)) { if (!StringUtils.isEmpty(siteId)) {
bmsBatteryClusterVoList = emsBatteryClusterMapper.getBMSBatteryCluster(siteId); // 获取所有设备下的电池簇id
if (!CollectionUtils.isEmpty(bmsBatteryClusterVoList)) { List<Map<String, Object>> clusterIds = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.CLUSTER.getCode());
for (BMSBatteryClusterVo bmsBatteryClusterVo : bmsBatteryClusterVoList) { for (Map<String, Object> clusterDevice : clusterIds) {
BMSBatteryClusterVo bmsBatteryClusterVo = new BMSBatteryClusterVo();
String clusterDeviceId = bmsBatteryClusterVo.getDeviceId(); bmsBatteryClusterVo.setDeviceName(clusterDevice.get("deviceName").toString());
// 从redis取单个簇详细数据
String clusterId = clusterDevice.get("id").toString();
EmsBatteryCluster clusterData = redisCache.getCacheObject("CLUSTER_"+siteId+"_"+clusterId);
if (clusterData != null) {
BeanUtils.copyProperties(clusterData, bmsBatteryClusterVo);
// 处理单体电池数据-平均/最大/最小
List<BMSBatteryClusterDataList> clusterDataList = new ArrayList<>(); List<BMSBatteryClusterDataList> clusterDataList = new ArrayList<>();
if (!StringUtils.isEmpty(clusterDeviceId)) { dealWithBatteryClusterData(clusterData,clusterDataList);
// 获取单体电池数据-平均/最大/最小 bmsBatteryClusterVo.setBatteryDataList(clusterDataList);
//BatteryClusterDataDetailVo batteryClusterDataDetailVo = emsBatteryDataMapper.getBatteryDataByClusterId(siteId,clusterDeviceId); }
// 处理数据
bmsBatteryClusterVoList.add(bmsBatteryClusterVo);
}
}
return bmsBatteryClusterVoList;
}
private void dealWithBatteryClusterData(EmsBatteryCluster clusterData, List<BMSBatteryClusterDataList> clusterDataList) {
BMSBatteryClusterDataList voltageData = new BMSBatteryClusterDataList(); BMSBatteryClusterDataList voltageData = new BMSBatteryClusterDataList();
BMSBatteryClusterDataList tempData = new BMSBatteryClusterDataList(); BMSBatteryClusterDataList tempData = new BMSBatteryClusterDataList();
BMSBatteryClusterDataList socData = new BMSBatteryClusterDataList(); BMSBatteryClusterDataList socData = new BMSBatteryClusterDataList();
// 设值 // 设值
voltageData.setDataName(CLUSTER_DATA_VOLTAGE); voltageData.setDataName(CLUSTER_DATA_VOLTAGE);
voltageData.setAvgData(bmsBatteryClusterVo.getAvgVoltage()); voltageData.setAvgData(clusterData.getAvgCellVoltage());
voltageData.setMaxData(bmsBatteryClusterVo.getMaxVoltage()); voltageData.setMaxData(clusterData.getMaxCellVoltage());
voltageData.setMaxDataID(bmsBatteryClusterVo.getMaxVoltageID()); voltageData.setMaxDataID(clusterData.getMaxCellVoltageId().toString());
voltageData.setMinData(bmsBatteryClusterVo.getMinVoltage()); voltageData.setMinData(clusterData.getMinCellVoltage());
voltageData.setMinDataID(bmsBatteryClusterVo.getMinVoltageID()); voltageData.setMinDataID(clusterData.getMinCellVoltageId().toString());
tempData.setDataName(CLUSTER_DATA_TEP); tempData.setDataName(CLUSTER_DATA_TEP);
tempData.setAvgData(bmsBatteryClusterVo.getAvgTemp()); tempData.setAvgData(clusterData.getAvgCellTemp());
tempData.setMaxData(bmsBatteryClusterVo.getMaxTemp()); tempData.setMaxData(clusterData.getMaxCellTemp());
tempData.setMaxDataID(bmsBatteryClusterVo.getMaxTempID()); tempData.setMaxDataID(clusterData.getMaxCellTempId().toString());
tempData.setMinData(bmsBatteryClusterVo.getMinTemp()); tempData.setMinData(clusterData.getMinCellTemp());
tempData.setMinDataID(bmsBatteryClusterVo.getMinTempID()); tempData.setMinDataID(clusterData.getMinCellTempId().toString());
socData.setDataName(CLUSTER_DATA_SOC); socData.setDataName(CLUSTER_DATA_SOC);
socData.setAvgData(bmsBatteryClusterVo.getAvgSoc()); socData.setAvgData(clusterData.getCurrentSoc());
socData.setMaxData(bmsBatteryClusterVo.getMaxSoc()); socData.setMaxData(clusterData.getMaxCellSoc());
socData.setMaxDataID(bmsBatteryClusterVo.getMaxSocID()); socData.setMaxDataID(clusterData.getMaxCellSocId().toString());
socData.setMinData(bmsBatteryClusterVo.getMinSoc()); socData.setMinData(clusterData.getMinCellSoc());
socData.setMinDataID(bmsBatteryClusterVo.getMinSocID()); socData.setMinDataID(clusterData.getMinCellSocId().toString());
clusterDataList.add(voltageData); clusterDataList.add(voltageData);
clusterDataList.add(tempData); clusterDataList.add(tempData);
clusterDataList.add(socData); clusterDataList.add(socData);
bmsBatteryClusterVo.setBatteryDataList(clusterDataList);
}
}
}
}
return bmsBatteryClusterVoList;
} }
// 获取液冷设备参数 // 获取液冷设备参数
@ -244,7 +282,26 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
@Override @Override
public List<BatteryDataStatsListVo> getClusterDataInfoList(String clusterDeviceId,String siteId) { public List<BatteryDataStatsListVo> getClusterDataInfoList(String clusterDeviceId,String siteId) {
List<BatteryDataStatsListVo> batteryDataStatsListVo = new ArrayList<>(); List<BatteryDataStatsListVo> batteryDataStatsListVo = new ArrayList<>();
batteryDataStatsListVo = emsBatteryDataMapper.getAllBatteryDataByClusterId(clusterDeviceId,siteId); List<Map<String, Object>> clusterIds = new ArrayList<>();
if (StringUtils.isEmpty(clusterDeviceId)) {
clusterIds = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.CLUSTER.getCode());
} else {
Map<String, Object> map = new HashMap<>();
map.put("id", clusterDeviceId);
clusterIds.add(map);
}
for (Map<String, Object> clusterDevice : clusterIds) {
// 从redis取单个簇详细数据
String clusterId = clusterDevice.get("id").toString();
List<EmsBatteryData> batteryDataList = redisCache.getCacheList("BATTERY_"+siteId+"_"+clusterId);
if (batteryDataList != null) {
for (EmsBatteryData batteryData : batteryDataList) {
BatteryDataStatsListVo batteryDataStatsVo = new BatteryDataStatsListVo();
BeanUtils.copyProperties(batteryData, batteryDataStatsVo);
batteryDataStatsListVo.add(batteryDataStatsVo);
}
}
}
return batteryDataStatsListVo; return batteryDataStatsListVo;
} }

View File

@ -309,33 +309,6 @@
</foreach> </foreach>
</delete> </delete>
<select id="getBMSBatteryCluster" parameterType="String" resultType="com.xzzn.ems.domain.vo.BMSBatteryClusterVo">
select td.device_name as deviceName, tmp.work_status as workStatus,
tmp.pcs_communication_status as pcsCommunicationStatus, tmp.ems_communication_status as emsCommunicationStatus,
tmp.cluster_voltage as clusterVoltage,tmp.chargeable_capacity as chargeableCapacity,
tmp.total_charged_capacity as totalChargedCapacity,
tmp.cluster_current as clusterCurrent,tmp.dischargeable_capacity as dischargeableCapacity,
tmp.total_discharged_capacity as totalDischargedCapacity,
tmp.soh as soh,tmp.average_temperature as averageTemperature,tmp.insulation_resistance as insulationResistance,
tmp.current_soc as currentSoc,tmp.site_id as siteId,tmp.device_id as deviceId,
tmp.avg_cell_voltage as avgVoltage,tmp.avg_cell_temp as avgTemp,tmp.avg_cell_temp as avgSoc,
tmp.max_cell_voltage as maxVoltage,tmp.max_cell_voltage_id as maxVoltageId,
tmp.min_cell_voltage as minVolatage,tmp.min_cell_voltage_id as minVoltageId,
tmp.max_cell_temp as maxTem,tmp.max_cell_temp_id as maxTempId,
tmp.min_cell_temp as minTemp,tmp.min_cell_temp_id as minTempId,
tmp.max_cell_soc as maxSoc,tmp.max_cell_soc_id as maxSocId,
tmp.min_cell_soc as minSoc,tmp.min_cell_soc_id as minSocId
from ems_battery_cluster tmp left join ems_devices_setting td on tmp.device_id = td.device_id and tmp.site_id = td.site_id
INNER JOIN (
SELECT p.site_id, p.device_id, MAX(p.update_time) AS max_update_time
FROM ems_battery_cluster p
WHERE p.site_id = #{siteId}
GROUP BY p.site_id,p.device_id
) latest on tmp.device_id = latest.device_id and tmp.update_time = latest.max_update_time
where tmp.site_id = #{siteId}
order by tmp.device_id
</select>
<select id="getBmsBatteryData" resultType="com.xzzn.ems.domain.vo.BMSBatteryDataList"> <select id="getBmsBatteryData" resultType="com.xzzn.ems.domain.vo.BMSBatteryDataList">
SELECT t.cluster_voltage as clusterVoltage,t.cluster_current as clusterCurrent, SELECT t.cluster_voltage as clusterVoltage,t.cluster_current as clusterCurrent,
t.current_soc as currentSoc,t.site_id as siteId,t.device_id as clusterId, t.current_soc as currentSoc,t.site_id as siteId,t.device_id as clusterId,

View File

@ -25,10 +25,11 @@
<result property="communicationStatus" column="communication_status" /> <result property="communicationStatus" column="communication_status" />
<result property="deviceId" column="device_id" /> <result property="deviceId" column="device_id" />
<result property="parentId" column="parent_id" /> <result property="parentId" column="parent_id" />
<result property="deviceCategory" column="device_category" />
</resultMap> </resultMap>
<sql id="selectEmsDevicesSettingVo"> <sql id="selectEmsDevicesSettingVo">
select id, device_name, device_type, slave_id, timeout_ms, retries, ip_address, ip_port, serial_port, baud_rate, data_bits, stop_bits, parity, description, created_at, updated_at, site_id, communication_status, device_id, parent_id from ems_devices_setting select id, device_name, device_type, slave_id, timeout_ms, retries, ip_address, ip_port, serial_port, baud_rate, data_bits, stop_bits, parity, description, created_at, updated_at, site_id, communication_status, device_id, parent_id, device_category from ems_devices_setting
</sql> </sql>
<select id="selectEmsDevicesSettingList" parameterType="EmsDevicesSetting" resultMap="EmsDevicesSettingResult"> <select id="selectEmsDevicesSettingList" parameterType="EmsDevicesSetting" resultMap="EmsDevicesSettingResult">
@ -53,6 +54,7 @@
<if test="communicationStatus != null and communicationStatus != ''"> and communication_status = #{communicationStatus}</if> <if test="communicationStatus != null and communicationStatus != ''"> and communication_status = #{communicationStatus}</if>
<if test="deviceId != null and deviceId != ''"> and device_id = #{deviceId}</if> <if test="deviceId != null and deviceId != ''"> and device_id = #{deviceId}</if>
<if test="parentId != null and parentId != ''"> and parent_id = #{parentId}</if> <if test="parentId != null and parentId != ''"> and parent_id = #{parentId}</if>
<if test="deviceCategory != null and deviceCategory != ''"> and device_category = #{deviceCategory}</if>
</where> </where>
</select> </select>
@ -83,6 +85,7 @@
<if test="communicationStatus != null">communication_status,</if> <if test="communicationStatus != null">communication_status,</if>
<if test="deviceId != null and deviceId != ''">device_id,</if> <if test="deviceId != null and deviceId != ''">device_id,</if>
<if test="parentId != null">parent_id,</if> <if test="parentId != null">parent_id,</if>
<if test="deviceCategory != null">device_category,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceName != null and deviceName != ''">#{deviceName},</if> <if test="deviceName != null and deviceName != ''">#{deviceName},</if>
@ -104,6 +107,7 @@
<if test="communicationStatus != null">#{communicationStatus},</if> <if test="communicationStatus != null">#{communicationStatus},</if>
<if test="deviceId != null and deviceId != ''">#{deviceId},</if> <if test="deviceId != null and deviceId != ''">#{deviceId},</if>
<if test="parentId != null">#{parentId},</if> <if test="parentId != null">#{parentId},</if>
<if test="deviceCategory != null">#{deviceCategory},</if>
</trim> </trim>
</insert> </insert>
@ -129,6 +133,7 @@
<if test="communicationStatus != null">communication_status = #{communicationStatus},</if> <if test="communicationStatus != null">communication_status = #{communicationStatus},</if>
<if test="deviceId != null and deviceId != ''">device_id = #{deviceId},</if> <if test="deviceId != null and deviceId != ''">device_id = #{deviceId},</if>
<if test="parentId != null">parent_id = #{parentId},</if> <if test="parentId != null">parent_id = #{parentId},</if>
<if test="deviceCategory != null">device_category = #{deviceCategory},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
@ -150,8 +155,8 @@
select distinct eb.device_id from ems_battery_stack eb where eb.site_id = #{siteId}) select distinct eb.device_id from ems_battery_stack eb where eb.site_id = #{siteId})
</select> </select>
<select id="getAllClusterInfoByStackId" parameterType="String" resultType="java.util.Map"> <select id="getDeviceInfoByParentId" parameterType="String" resultType="java.util.Map">
select distinct t.device_id as id,t.device_name as deviceName from ems_devices_setting t where t.parent_id = #{stackDeviceId} select distinct t.device_id as id,t.device_name as deviceName from ems_devices_setting t where t.parent_id = #{parentId}
</select> </select>
<select id="getAllBatteryDeviceBySiteId" parameterType="String" resultType="com.xzzn.ems.domain.EmsDevicesSetting"> <select id="getAllBatteryDeviceBySiteId" parameterType="String" resultType="com.xzzn.ems.domain.EmsDevicesSetting">
@ -161,4 +166,17 @@
from ems_devices_setting t INNER JOIN ems_ammeter_data e on t.site_id = e.site_id and t.device_id = e.device_id from ems_devices_setting t INNER JOIN ems_ammeter_data e on t.site_id = e.site_id and t.device_id = e.device_id
where t.site_id = #{siteId} where t.site_id = #{siteId}
</select> </select>
<select id="getAllClusterInfoBySiteId" parameterType="String" resultType="java.util.Map">
select device_id as id,device_name as deviceName from ems_devices_setting
where device_id in (
select distinct eb.device_id from ems_battery_cluster eb where eb.site_id = #{siteId})
</select>
<select id="getDeviceInfosBySiteIdAndCategory" resultType="java.util.Map">
select DISTINCT device_id as id,
device_name as deviceName,
communication_status as communicationStatus
from ems_devices_setting where site_id = #{siteId} and device_category = #{deviceCategory}
</select>
</mapper> </mapper>