20250808优化-单体电池优化
This commit is contained in:
@ -3,14 +3,17 @@ package com.xzzn.web.controller.ems;
|
|||||||
import com.xzzn.common.core.controller.BaseController;
|
import com.xzzn.common.core.controller.BaseController;
|
||||||
import com.xzzn.common.core.domain.AjaxResult;
|
import com.xzzn.common.core.domain.AjaxResult;
|
||||||
import com.xzzn.common.core.page.TableDataInfo;
|
import com.xzzn.common.core.page.TableDataInfo;
|
||||||
|
import com.xzzn.ems.domain.vo.BMSBatteryDataList;
|
||||||
import com.xzzn.ems.domain.vo.BatteryDataStatsListVo;
|
import com.xzzn.ems.domain.vo.BatteryDataStatsListVo;
|
||||||
import com.xzzn.ems.domain.vo.DateSearchRequest;
|
import com.xzzn.ems.domain.vo.DateSearchRequest;
|
||||||
|
import com.xzzn.ems.domain.vo.SiteBatteryDataList;
|
||||||
import com.xzzn.ems.service.IEmsSiteService;
|
import com.xzzn.ems.service.IEmsSiteService;
|
||||||
import com.xzzn.ems.service.IEmsStatsReportService;
|
import com.xzzn.ems.service.IEmsStatsReportService;
|
||||||
import com.xzzn.ems.service.ISingleSiteService;
|
import com.xzzn.ems.service.ISingleSiteService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -141,11 +144,26 @@ public class EmsSiteMonitorController extends BaseController{
|
|||||||
* 获取电池簇下面的单体电池数据
|
* 获取电池簇下面的单体电池数据
|
||||||
*/
|
*/
|
||||||
@GetMapping("/getClusterDataInfoList")
|
@GetMapping("/getClusterDataInfoList")
|
||||||
public TableDataInfo getClusterDataInfoList(@RequestParam String clusterDeviceId,@RequestParam String siteId)
|
public TableDataInfo getClusterDataInfoList(@RequestParam String clusterDeviceId,@RequestParam String siteId,@RequestParam String stackDeviceId)
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<BatteryDataStatsListVo> list = iSingleSiteService.getClusterDataInfoList(clusterDeviceId,siteId);
|
SiteBatteryDataList siteBatteryDataList = new SiteBatteryDataList();
|
||||||
return getDataTable2(list);
|
// 簇最大最小单体id数据
|
||||||
|
List<BMSBatteryDataList> clusterBatteryDataList = iSingleSiteService.getClusterBatteryList(siteId,stackDeviceId,clusterDeviceId);
|
||||||
|
siteBatteryDataList.setClusterList(clusterBatteryDataList);
|
||||||
|
// 单体电池数据
|
||||||
|
List<BatteryDataStatsListVo> List = iSingleSiteService.getClusterDataInfoList(clusterDeviceId,siteId,stackDeviceId);
|
||||||
|
// 对batteryList进行分页处理
|
||||||
|
List<BatteryDataStatsListVo> batteryList = paginateList(List);
|
||||||
|
siteBatteryDataList.setBatteryList(batteryList);
|
||||||
|
|
||||||
|
// 封装分页信息
|
||||||
|
TableDataInfo pageInfo = new TableDataInfo();
|
||||||
|
pageInfo.setTotal(List.size());
|
||||||
|
pageInfo.setRows(Arrays.asList(siteBatteryDataList));
|
||||||
|
pageInfo.setCode(0);
|
||||||
|
pageInfo.setMsg("查询成功");
|
||||||
|
return pageInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -232,4 +232,27 @@ public class BaseController
|
|||||||
rspData.setTotal(list.size());
|
rspData.setTotal(list.size());
|
||||||
return rspData;
|
return rspData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用分页工具方法
|
||||||
|
*/
|
||||||
|
protected <T> List<T> paginateList(List<T> sourceList) {
|
||||||
|
if (sourceList == null || sourceList.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
// 分页梳理
|
||||||
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
|
int pageNum = pageDomain.getPageNum();
|
||||||
|
int pageSize = pageDomain.getPageSize();
|
||||||
|
int startIndex = 0;
|
||||||
|
int endIndex = sourceList.size();
|
||||||
|
if (pageNum > 0 && pageSize > 0) {
|
||||||
|
// 计算起始索引(处理页码小于1的情况)
|
||||||
|
startIndex = Math.max((pageNum - 1) * pageSize, 0);
|
||||||
|
// 计算结束索引(处理超出列表长度的情况)
|
||||||
|
endIndex = Math.min(startIndex + pageSize, sourceList.size());
|
||||||
|
}
|
||||||
|
// 截取分页数据
|
||||||
|
return sourceList.subList(startIndex, endIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,36 @@
|
|||||||
|
package com.xzzn.ems.domain.vo;
|
||||||
|
|
||||||
|
import com.xzzn.common.annotation.Excel;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单站监控-单体电池返回数据
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SiteBatteryDataList {
|
||||||
|
|
||||||
|
// 簇相关单体最大最小值list
|
||||||
|
@Excel(name = "簇单体最大最小值list")
|
||||||
|
List<BMSBatteryDataList> clusterList;
|
||||||
|
|
||||||
|
// 单体电池list
|
||||||
|
@Excel(name = "单体电池list")
|
||||||
|
List<BatteryDataStatsListVo> batteryList;
|
||||||
|
|
||||||
|
public List<BMSBatteryDataList> getClusterList() {
|
||||||
|
return clusterList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClusterList(List<BMSBatteryDataList> clusterList) {
|
||||||
|
this.clusterList = clusterList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<BatteryDataStatsListVo> getBatteryList() {
|
||||||
|
return batteryList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBatteryList(List<BatteryDataStatsListVo> batteryList) {
|
||||||
|
this.batteryList = batteryList;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -84,4 +84,7 @@ public interface EmsDevicesSettingMapper
|
|||||||
public List<Map<String, Object>> getLoadNameList(String siteId);
|
public List<Map<String, Object>> getLoadNameList(String siteId);
|
||||||
|
|
||||||
public EmsDevicesSetting getDeviceBySiteAndDeviceId(@Param("deviceId")String deviceId, @Param("siteId")String siteId);
|
public EmsDevicesSetting getDeviceBySiteAndDeviceId(@Param("deviceId")String deviceId, @Param("siteId")String siteId);
|
||||||
|
|
||||||
|
public List<Map<String, Object>> getClusterIdsByFuzzyQuery(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory,
|
||||||
|
@Param("parentId")String parentId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,7 @@ public interface ISingleSiteService
|
|||||||
|
|
||||||
public List<EmsCoolingData> getCoolingDataList(String siteId);
|
public List<EmsCoolingData> getCoolingDataList(String siteId);
|
||||||
|
|
||||||
public List<BatteryDataStatsListVo> getClusterDataInfoList(String clusterDeviceId,String siteId);
|
public List<BatteryDataStatsListVo> getClusterDataInfoList(String clusterDeviceId,String siteId,String stackDeviceId);
|
||||||
|
|
||||||
public AmmeterDataResponse getAmmeterDataList(String siteId);
|
public AmmeterDataResponse getAmmeterDataList(String siteId);
|
||||||
|
|
||||||
@ -36,4 +36,6 @@ public interface ISingleSiteService
|
|||||||
public SiteMonitorRuningInfoVo getRunningGraphBatterySoc(String siteId);
|
public SiteMonitorRuningInfoVo getRunningGraphBatterySoc(String siteId);
|
||||||
|
|
||||||
public SiteMonitorRuningInfoVo getRunningGraphBatteryTemp(String siteId);
|
public SiteMonitorRuningInfoVo getRunningGraphBatteryTemp(String siteId);
|
||||||
|
|
||||||
|
public List<BMSBatteryDataList> getClusterBatteryList(String siteId, String stackDeviceId, String clusterDeviceId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -270,8 +270,10 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
|||||||
BeanUtils.copyProperties(stackData, bmsOverViewVo);
|
BeanUtils.copyProperties(stackData, bmsOverViewVo);
|
||||||
}
|
}
|
||||||
// 下面簇列表数据
|
// 下面簇列表数据
|
||||||
|
List<BMSBatteryDataList> batteryDataLists = new ArrayList<>();
|
||||||
if (!StringUtils.isEmpty(stackId)) {
|
if (!StringUtils.isEmpty(stackId)) {
|
||||||
getBMSClusterListInfo(siteId,stackId,bmsOverViewVo);
|
batteryDataLists = getBMSClusterListInfo(siteId,stackId,null);
|
||||||
|
bmsOverViewVo.setBatteryDataList(batteryDataLists);
|
||||||
}
|
}
|
||||||
bmsOverViewVoList.add(bmsOverViewVo);
|
bmsOverViewVoList.add(bmsOverViewVo);
|
||||||
}
|
}
|
||||||
@ -279,10 +281,18 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
|||||||
return bmsOverViewVoList;
|
return bmsOverViewVoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getBMSClusterListInfo(String siteId, String stackId, BMSOverViewVo bmsOverViewVo) {
|
private List<BMSBatteryDataList> getBMSClusterListInfo(String siteId, String stackId, String clusterDeviceId) {
|
||||||
List<BMSBatteryDataList> batteryDataList = new ArrayList();
|
List<BMSBatteryDataList> batteryDataList = new ArrayList();
|
||||||
|
|
||||||
List<Map<String, Object>> clusterIds = emsDevicesSettingMapper.getDeviceInfoByParentId(siteId, stackId);
|
List<Map<String, Object>> clusterIds = new ArrayList<>();
|
||||||
|
if (StringUtils.isEmpty(clusterDeviceId)) {
|
||||||
|
clusterIds = emsDevicesSettingMapper.getClusterIdsByFuzzyQuery(siteId, DeviceCategory.CLUSTER.getCode(),stackId);
|
||||||
|
} else {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("id", clusterDeviceId);
|
||||||
|
clusterIds.add(map);
|
||||||
|
}
|
||||||
|
|
||||||
for (Map<String, Object> clusterDevice : clusterIds) {
|
for (Map<String, Object> clusterDevice : clusterIds) {
|
||||||
BMSBatteryDataList bmsBatteryDataList= new BMSBatteryDataList();
|
BMSBatteryDataList bmsBatteryDataList= new BMSBatteryDataList();
|
||||||
// 从redis取单个簇的详细数据
|
// 从redis取单个簇的详细数据
|
||||||
@ -295,7 +305,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
|||||||
batteryDataList.add(bmsBatteryDataList);
|
batteryDataList.add(bmsBatteryDataList);
|
||||||
}
|
}
|
||||||
|
|
||||||
bmsOverViewVo.setBatteryDataList(batteryDataList);
|
return batteryDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取BMS电池簇数据
|
// 获取BMS电池簇数据
|
||||||
@ -373,11 +383,11 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<BatteryDataStatsListVo> getClusterDataInfoList(String clusterDeviceId,String siteId) {
|
public List<BatteryDataStatsListVo> getClusterDataInfoList(String clusterDeviceId,String siteId,String stackDeviceId) {
|
||||||
List<BatteryDataStatsListVo> batteryDataStatsListVo = new ArrayList<>();
|
List<BatteryDataStatsListVo> batteryDataStatsListVo = new ArrayList<>();
|
||||||
List<Map<String, Object>> clusterIds = new ArrayList<>();
|
List<Map<String, Object>> clusterIds = new ArrayList<>();
|
||||||
if (StringUtils.isEmpty(clusterDeviceId)) {
|
if (StringUtils.isEmpty(clusterDeviceId)) {
|
||||||
clusterIds = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.CLUSTER.getCode());
|
clusterIds = emsDevicesSettingMapper.getClusterIdsByFuzzyQuery(siteId, DeviceCategory.CLUSTER.getCode(),stackDeviceId);
|
||||||
} else {
|
} else {
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("id", clusterDeviceId);
|
map.put("id", clusterDeviceId);
|
||||||
@ -402,6 +412,12 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
|||||||
return sortedList;
|
return sortedList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取单站的最大最小温度和电压单体数据id
|
||||||
|
@Override
|
||||||
|
public List<BMSBatteryDataList> getClusterBatteryList(String siteId, String stackDeviceId, String clusterDeviceId) {
|
||||||
|
return getBMSClusterListInfo(siteId, stackDeviceId,clusterDeviceId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 电表数据信息
|
* 电表数据信息
|
||||||
* @param siteId
|
* @param siteId
|
||||||
|
|||||||
@ -198,4 +198,16 @@
|
|||||||
<select id="getLoadNameList" parameterType="String" resultType="java.util.Map">
|
<select id="getLoadNameList" parameterType="String" resultType="java.util.Map">
|
||||||
select distinct device_id as id,device_name as deviceName from ems_devices_setting where site_id = #{siteId} and device_id like '%LOAD%'
|
select distinct device_id as id,device_name as deviceName from ems_devices_setting where site_id = #{siteId} and device_id like '%LOAD%'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getClusterIdsByFuzzyQuery" 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}
|
||||||
|
<if test="parentId !=null and parentId !=''">
|
||||||
|
and parent_id = #{parentId}
|
||||||
|
</if>
|
||||||
|
and device_category = #{deviceCategory}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user