redis key常量
This commit is contained in:
@ -114,7 +114,7 @@ public class EmsSiteMonitorController extends BaseController{
|
|||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<BatteryDataStatsListVo> list = iSingleSiteService.getClusterDataInfoList(clusterDeviceId,siteId);
|
List<BatteryDataStatsListVo> list = iSingleSiteService.getClusterDataInfoList(clusterDeviceId,siteId);
|
||||||
return getDataTable(list);
|
return getDataTable2(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.xzzn.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据存储 Redis key 常量
|
||||||
|
*
|
||||||
|
* @author xzzn
|
||||||
|
*/
|
||||||
|
public class RedisKeyConstants
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* pcs数据 redis key
|
||||||
|
*/
|
||||||
|
public static final String PCS = "PCS_";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pcs branch数据 redis key
|
||||||
|
*/
|
||||||
|
public static final String BRANCH = "BRANCH_";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* stack电池堆数据 redis key
|
||||||
|
*/
|
||||||
|
public static final String STACK = "STACK_";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cluster电池簇数据 redis key
|
||||||
|
*/
|
||||||
|
public static final String CLUSTER = "CLUSTER_";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* battery单体电池数据 redis key
|
||||||
|
*/
|
||||||
|
public static final String BATTERY = "BATTERY_";
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
package com.xzzn.common.core.controller;
|
package com.xzzn.common.core.controller;
|
||||||
|
|
||||||
import java.beans.PropertyEditorSupport;
|
import java.beans.PropertyEditorSupport;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -199,4 +201,35 @@ public class BaseController
|
|||||||
{
|
{
|
||||||
return getLoginUser().getUsername();
|
return getLoginUser().getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手动处理分页
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
|
protected TableDataInfo getDataTable2(List<?> list)
|
||||||
|
{
|
||||||
|
List<?> subList = new ArrayList<>();
|
||||||
|
// 分页梳理
|
||||||
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
|
int pageNum = pageDomain.getPageNum();
|
||||||
|
int pageSize = pageDomain.getPageSize();
|
||||||
|
if (pageNum > 0 && pageSize > 0) {
|
||||||
|
// 计算分页起始和结束索引
|
||||||
|
int startIndex = (pageNum - 1) * pageSize;
|
||||||
|
int endIndex = Math.min(startIndex + pageSize, list.size());
|
||||||
|
// 防止越界
|
||||||
|
if (startIndex >= list.size()) {
|
||||||
|
subList = Collections.emptyList();
|
||||||
|
}
|
||||||
|
// 截取当前页数据
|
||||||
|
subList = list.subList(startIndex, endIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
TableDataInfo rspData = new TableDataInfo();
|
||||||
|
rspData.setCode(HttpStatus.SUCCESS);
|
||||||
|
rspData.setMsg("查询成功");
|
||||||
|
rspData.setRows(subList);
|
||||||
|
rspData.setTotal(list.size());
|
||||||
|
return rspData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.xzzn.ems.service.impl;
|
package com.xzzn.ems.service.impl;
|
||||||
|
|
||||||
|
import com.xzzn.common.constant.RedisKeyConstants;
|
||||||
import com.xzzn.common.core.redis.RedisCache;
|
import com.xzzn.common.core.redis.RedisCache;
|
||||||
import com.xzzn.common.enums.DeviceCategory;
|
import com.xzzn.common.enums.DeviceCategory;
|
||||||
import com.xzzn.common.utils.StringUtils;
|
import com.xzzn.common.utils.StringUtils;
|
||||||
@ -149,7 +150,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
|||||||
pcsDetailInfoVo.setCommunicationStatus(pcsDevice.get("communicationStatus").toString());
|
pcsDetailInfoVo.setCommunicationStatus(pcsDevice.get("communicationStatus").toString());
|
||||||
// 从redis取pcs单个详细数据
|
// 从redis取pcs单个详细数据
|
||||||
String pcsId = pcsDevice.get("id").toString();
|
String pcsId = pcsDevice.get("id").toString();
|
||||||
EmsPcsData pcsData = redisCache.getCacheObject("PCS_"+siteId+"_"+pcsId);
|
EmsPcsData pcsData = redisCache.getCacheObject(RedisKeyConstants.PCS +siteId+"_"+pcsId);
|
||||||
if (pcsData != null) {
|
if (pcsData != null) {
|
||||||
BeanUtils.copyProperties(pcsData, pcsDetailInfoVo);
|
BeanUtils.copyProperties(pcsData, pcsDetailInfoVo);
|
||||||
}
|
}
|
||||||
@ -166,7 +167,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
|||||||
|
|
||||||
private void processBranchDataInfo(String siteId, String pcsId, List<PcsBranchInfo> pcsBranchInfoList) {
|
private void processBranchDataInfo(String siteId, String pcsId, List<PcsBranchInfo> pcsBranchInfoList) {
|
||||||
if (!StringUtils.isEmpty(pcsId)) {
|
if (!StringUtils.isEmpty(pcsId)) {
|
||||||
List<EmsPcsBranchData> pcsBranchData = redisCache.getCacheObject("BRANCH_"+siteId+"_"+pcsId);
|
List<EmsPcsBranchData> pcsBranchData = redisCache.getCacheObject(RedisKeyConstants.BRANCH +siteId+"_"+pcsId);
|
||||||
if (pcsBranchData != null) {
|
if (pcsBranchData != null) {
|
||||||
for(EmsPcsBranchData emsPcsBranchData : pcsBranchData) {
|
for(EmsPcsBranchData emsPcsBranchData : pcsBranchData) {
|
||||||
PcsBranchInfo pcsBranchInfo = new PcsBranchInfo();
|
PcsBranchInfo pcsBranchInfo = new PcsBranchInfo();
|
||||||
@ -190,7 +191,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
|||||||
bmsOverViewVo.setDeviceName(stackDevice.get("deviceName").toString());
|
bmsOverViewVo.setDeviceName(stackDevice.get("deviceName").toString());
|
||||||
// 从redis取堆单个详细数据
|
// 从redis取堆单个详细数据
|
||||||
String stackId = stackDevice.get("id").toString();
|
String stackId = stackDevice.get("id").toString();
|
||||||
EmsBatteryStack stackData = redisCache.getCacheObject("STACK_"+siteId+"_"+stackId);
|
EmsBatteryStack stackData = redisCache.getCacheObject(RedisKeyConstants.STACK +siteId+"_"+stackId);
|
||||||
if (stackData != null) {
|
if (stackData != null) {
|
||||||
BeanUtils.copyProperties(stackData, bmsOverViewVo);
|
BeanUtils.copyProperties(stackData, bmsOverViewVo);
|
||||||
}
|
}
|
||||||
@ -218,7 +219,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
|||||||
bmsBatteryClusterVo.setDeviceName(clusterDevice.get("deviceName").toString());
|
bmsBatteryClusterVo.setDeviceName(clusterDevice.get("deviceName").toString());
|
||||||
// 从redis取单个簇详细数据
|
// 从redis取单个簇详细数据
|
||||||
String clusterId = clusterDevice.get("id").toString();
|
String clusterId = clusterDevice.get("id").toString();
|
||||||
EmsBatteryCluster clusterData = redisCache.getCacheObject("CLUSTER_"+siteId+"_"+clusterId);
|
EmsBatteryCluster clusterData = redisCache.getCacheObject(RedisKeyConstants.CLUSTER +siteId+"_"+clusterId);
|
||||||
if (clusterData != null) {
|
if (clusterData != null) {
|
||||||
BeanUtils.copyProperties(clusterData, bmsBatteryClusterVo);
|
BeanUtils.copyProperties(clusterData, bmsBatteryClusterVo);
|
||||||
// 处理单体电池数据-平均/最大/最小
|
// 处理单体电池数据-平均/最大/最小
|
||||||
@ -275,7 +276,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据电池堆获取单体柱状数据
|
* 根据电池堆获取单体电池数据
|
||||||
* @param clusterDeviceId
|
* @param clusterDeviceId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -293,7 +294,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
|||||||
for (Map<String, Object> clusterDevice : clusterIds) {
|
for (Map<String, Object> clusterDevice : clusterIds) {
|
||||||
// 从redis取单个簇详细数据
|
// 从redis取单个簇详细数据
|
||||||
String clusterId = clusterDevice.get("id").toString();
|
String clusterId = clusterDevice.get("id").toString();
|
||||||
List<EmsBatteryData> batteryDataList = redisCache.getCacheList("BATTERY_"+siteId+"_"+clusterId);
|
List<EmsBatteryData> batteryDataList = redisCache.getCacheList(RedisKeyConstants.BATTERY + siteId + "_" + clusterId);
|
||||||
if (batteryDataList != null) {
|
if (batteryDataList != null) {
|
||||||
for (EmsBatteryData batteryData : batteryDataList) {
|
for (EmsBatteryData batteryData : batteryDataList) {
|
||||||
BatteryDataStatsListVo batteryDataStatsVo = new BatteryDataStatsListVo();
|
BatteryDataStatsListVo batteryDataStatsVo = new BatteryDataStatsListVo();
|
||||||
|
Reference in New Issue
Block a user