从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);
}
/**
* 删除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)
{
boolean captchaEnabled = configService.selectCaptchaEnabled();
captchaEnabled = false;
if (captchaEnabled)
{
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
*
* @author xzzn
* @date 2025-07-01
* @date 2025-07-02
*/
public class EmsDevicesSetting extends BaseEntity
{
@ -98,6 +98,10 @@ public class EmsDevicesSetting extends BaseEntity
@Excel(name = "上级设备id")
private String parentId;
/** 设备类别例如“STACK/CLUSTER/PCS等” */
@Excel(name = "设备类别例如“STACK/CLUSTER/PCS等”")
private String deviceCategory;
public void setId(Long id)
{
this.id = id;
@ -298,6 +302,16 @@ public class EmsDevicesSetting extends BaseEntity
return parentId;
}
public void setDeviceCategory(String deviceCategory)
{
this.deviceCategory = deviceCategory;
}
public String getDeviceCategory()
{
return deviceCategory;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -321,6 +335,7 @@ public class EmsDevicesSetting extends BaseEntity
.append("communicationStatus", getCommunicationStatus())
.append("deviceId", getDeviceId())
.append("parentId", getParentId())
.append("deviceCategory", getDeviceCategory())
.toString();
}
}

View File

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

View File

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

View File

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

View File

@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map;
import com.xzzn.ems.domain.EmsDevicesSetting;
import org.apache.ibatis.annotations.Param;
/**
* Modbus设备配置Mapper接口
@ -60,24 +61,25 @@ public interface EmsDevicesSettingMapper
* @return 结果
*/
public int deleteEmsDevicesSettingByIds(Long[] ids);
/**
* 根据site_id获取所有电池堆
* @param siteId
* 根据父类设备id获取子设备id
* @param parentId
* @return
*/
public List<Map<String, Object>> getAllStackInfoBySiteId(String siteId);
/**
* 根据电池堆id获取所有电池簇
* @param stackDeviceId
* @return
*/
public List<Map<String, Object>> getAllClusterInfoByStackId(String stackDeviceId);
public List<Map<String, Object>> getDeviceInfoByParentId(String parentId);
/**
* 获取该设备下的所有电表
* @param siteId
* @return
*/
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;
import com.xzzn.common.enums.DeviceCategory;
import com.xzzn.ems.domain.EmsSiteSetting;
import com.xzzn.ems.domain.vo.SiteTotalInfoVo;
import com.xzzn.ems.mapper.EmsDevicesSettingMapper;
@ -41,17 +42,17 @@ public class EmsSiteServiceImpl implements IEmsSiteService
*/
@Override
public List<Map<String, Object>> getAllStackInfo(String siteId) {
return emsDevicesMapper.getAllStackInfoBySiteId(siteId);
return emsDevicesMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.STACK.getCode());
}
/**
* 根据电池堆Id获取电池簇
* @param stackDeviceId
* 根据父类设备id获取子设备id
* @param parentId
* @return
*/
@Override
public List<Map<String, Object>> getAllClusterInfo(String stackDeviceId) {
return emsDevicesMapper.getAllClusterInfoByStackId(stackDeviceId);
public List<Map<String, Object>> getAllClusterInfo(String parentId) {
return emsDevicesMapper.getDeviceInfoByParentId(parentId);
}
}

View File

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

View File

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

View File

@ -309,33 +309,6 @@
</foreach>
</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 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,

View File

@ -25,10 +25,11 @@
<result property="communicationStatus" column="communication_status" />
<result property="deviceId" column="device_id" />
<result property="parentId" column="parent_id" />
<result property="deviceCategory" column="device_category" />
</resultMap>
<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>
<select id="selectEmsDevicesSettingList" parameterType="EmsDevicesSetting" resultMap="EmsDevicesSettingResult">
@ -53,6 +54,7 @@
<if test="communicationStatus != null and communicationStatus != ''"> and communication_status = #{communicationStatus}</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="deviceCategory != null and deviceCategory != ''"> and device_category = #{deviceCategory}</if>
</where>
</select>
@ -83,6 +85,7 @@
<if test="communicationStatus != null">communication_status,</if>
<if test="deviceId != null and deviceId != ''">device_id,</if>
<if test="parentId != null">parent_id,</if>
<if test="deviceCategory != null">device_category,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
@ -104,6 +107,7 @@
<if test="communicationStatus != null">#{communicationStatus},</if>
<if test="deviceId != null and deviceId != ''">#{deviceId},</if>
<if test="parentId != null">#{parentId},</if>
<if test="deviceCategory != null">#{deviceCategory},</if>
</trim>
</insert>
@ -129,6 +133,7 @@
<if test="communicationStatus != null">communication_status = #{communicationStatus},</if>
<if test="deviceId != null and deviceId != ''">device_id = #{deviceId},</if>
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="deviceCategory != null">device_category = #{deviceCategory},</if>
</trim>
where id = #{id}
</update>
@ -150,8 +155,8 @@
select distinct eb.device_id from ems_battery_stack eb where eb.site_id = #{siteId})
</select>
<select id="getAllClusterInfoByStackId" 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 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 = #{parentId}
</select>
<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
where t.site_id = #{siteId}
</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>