20250808优化-设备监控
This commit is contained in:
@ -2,7 +2,7 @@ package com.xzzn.web.controller.ems;
|
||||
|
||||
import com.xzzn.common.core.controller.BaseController;
|
||||
import com.xzzn.common.core.domain.AjaxResult;
|
||||
import com.xzzn.ems.service.IEmsSiteService;
|
||||
import com.xzzn.ems.domain.vo.DateSearchRequest;
|
||||
import com.xzzn.ems.service.IHomePageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
*
|
||||
// * 站点地图
|
||||
* 站点地图
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@ -31,4 +31,17 @@ public class EmsSiteMapController extends BaseController{
|
||||
return success(homePageService.getSingleSiteBaseInfo(siteId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某个站点7天充放电数据
|
||||
*/
|
||||
@GetMapping("/getSevenChargeData")
|
||||
public AjaxResult getSevenChargeData(DateSearchRequest request)
|
||||
{
|
||||
String siteId = request.getSiteId();
|
||||
if(siteId == null || siteId.isEmpty()) {
|
||||
return error("站点必传");
|
||||
}
|
||||
return success(homePageService.getSevenChargeData(request));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -23,15 +23,27 @@ public class BMSBatteryDataList {
|
||||
/** 单体最高电压 (V) */
|
||||
private BigDecimal maxCellVoltage;
|
||||
|
||||
/** 最高单体电压对应点号 */
|
||||
private Long maxCellVoltageId;
|
||||
|
||||
/** 单体最低电压 (V) */
|
||||
private BigDecimal minCellVoltage;
|
||||
|
||||
/** 最低单体电压对应点号 */
|
||||
private Long minCellVoltageId;
|
||||
|
||||
/** 单体最高温度 (℃) */
|
||||
private BigDecimal maxCellTemp;
|
||||
|
||||
/** 最高单体温度对应点号 */
|
||||
private Long maxCellTempId;
|
||||
|
||||
/** 单体最低温度 (℃) */
|
||||
private BigDecimal minCellTemp;
|
||||
|
||||
/** 最低单体温度对应点号 */
|
||||
private Long minCellTempId;
|
||||
|
||||
/** 换电站id */
|
||||
private String siteId;
|
||||
|
||||
@ -117,4 +129,36 @@ public class BMSBatteryDataList {
|
||||
public void setClusterVoltage(BigDecimal clusterVoltage) {
|
||||
this.clusterVoltage = clusterVoltage;
|
||||
}
|
||||
|
||||
public Long getMaxCellVoltageId() {
|
||||
return maxCellVoltageId;
|
||||
}
|
||||
|
||||
public void setMaxCellVoltageId(Long maxCellVoltageId) {
|
||||
this.maxCellVoltageId = maxCellVoltageId;
|
||||
}
|
||||
|
||||
public Long getMinCellTempId() {
|
||||
return minCellTempId;
|
||||
}
|
||||
|
||||
public void setMinCellTempId(Long minCellTempId) {
|
||||
this.minCellTempId = minCellTempId;
|
||||
}
|
||||
|
||||
public Long getMaxCellTempId() {
|
||||
return maxCellTempId;
|
||||
}
|
||||
|
||||
public void setMaxCellTempId(Long maxCellTempId) {
|
||||
this.maxCellTempId = maxCellTempId;
|
||||
}
|
||||
|
||||
public Long getMinCellVoltageId() {
|
||||
return minCellVoltageId;
|
||||
}
|
||||
|
||||
public void setMinCellVoltageId(Long minCellVoltageId) {
|
||||
this.minCellVoltageId = minCellVoltageId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,6 +89,9 @@ public class PcsDetailInfoVo {
|
||||
/** 设备名称 */
|
||||
private String deviceName;
|
||||
|
||||
/** 报警个数 */
|
||||
private int alarmNum;
|
||||
|
||||
private List<PcsBranchInfo> pcsBranchInfoList;
|
||||
|
||||
public String getDeviceId() {
|
||||
@ -290,4 +293,12 @@ public class PcsDetailInfoVo {
|
||||
public void setDeviceName(String deviceName) {
|
||||
this.deviceName = deviceName;
|
||||
}
|
||||
|
||||
public int getAlarmNum() {
|
||||
return alarmNum;
|
||||
}
|
||||
|
||||
public void setAlarmNum(int alarmNum) {
|
||||
this.alarmNum = alarmNum;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.xzzn.ems.mapper;
|
||||
import java.util.List;
|
||||
import com.xzzn.ems.domain.EmsAlarmRecords;
|
||||
import com.xzzn.ems.domain.vo.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 告警记录Mapper接口
|
||||
@ -86,4 +87,7 @@ public interface EmsAlarmRecordsMapper
|
||||
|
||||
|
||||
public List<AlarmRecordListResponseVo> getAlarmRecordDetailList(AlarmRecordListRequestVo requestVo);
|
||||
|
||||
// 获取站点设备告警数量
|
||||
public int getDeviceAlarmNum(@Param("siteId") String siteId, @Param("deviceId") String deviceId);
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ public interface EmsPcsDataMapper
|
||||
* @param siteId
|
||||
* @return
|
||||
*/
|
||||
public List<SiteMonitorDataVo> getPcsDataBySiteId(@Param("siteId")String siteId, @Param("limitTime")int limitTime);
|
||||
public List<SiteMonitorDataVo> getPcsDataBySiteId(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate);
|
||||
|
||||
/**
|
||||
* 根据站点获取设备监控的实时运行头信息
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package com.xzzn.ems.service;
|
||||
|
||||
import com.xzzn.ems.domain.vo.HomePageDataViewVo;
|
||||
import com.xzzn.ems.domain.vo.SingleSiteBaseInfo;
|
||||
import com.xzzn.ems.domain.vo.SiteTotalInfoVo;
|
||||
import com.xzzn.ems.domain.vo.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 站点信息 服务层
|
||||
@ -16,4 +16,6 @@ public interface IHomePageService
|
||||
public SingleSiteBaseInfo getSingleSiteBaseInfo(String siteId);
|
||||
|
||||
public HomePageDataViewVo getHomePageDataList();
|
||||
|
||||
public List<SiteMonitorDataVo> getSevenChargeData(DateSearchRequest request);
|
||||
}
|
||||
|
||||
@ -3,6 +3,9 @@ package com.xzzn.ems.service.impl;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.TypeReference;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xzzn.common.constant.RedisKeyConstants;
|
||||
import com.xzzn.common.core.redis.RedisCache;
|
||||
import com.xzzn.common.enums.*;
|
||||
@ -31,7 +34,8 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService {
|
||||
private static final Pattern PATTERN = Pattern.compile("(BMSD\\d{2})(ZT|SOC|SOH|DL|DY|BDSC)");
|
||||
// 匹配DTDC+数字格式的正则(提取序号)
|
||||
private static final Pattern DTDC_PATTERN = Pattern.compile("DTDC(\\d+)([A-Za-z]*)");
|
||||
|
||||
// 初始化ObjectMapper(可以作为全局变量)
|
||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||
@Autowired
|
||||
private EmsBatteryClusterMapper emsBatteryClusterMapper;
|
||||
|
||||
@ -70,9 +74,12 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService {
|
||||
String jsonData = obj.get("Data").toString();
|
||||
|
||||
log.info("deviceId:" + deviceId);
|
||||
if (StringUtils.isEmpty(jsonData)) {
|
||||
boolean isEmpty = checkJsonDataEmpty(jsonData);
|
||||
if (isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 处理相关数据
|
||||
if (deviceId.contains("BMSD")) {
|
||||
batteryStackDataProcess(deviceId, jsonData);
|
||||
batteryGroupDataProcess(deviceId, jsonData);
|
||||
@ -904,4 +911,22 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService {
|
||||
return records;
|
||||
}
|
||||
|
||||
// 空数据不处理
|
||||
private boolean checkJsonDataEmpty(String jsonData) {
|
||||
boolean flag = false;
|
||||
try {
|
||||
if (StringUtils.isEmpty(jsonData)) {
|
||||
flag = true;
|
||||
}
|
||||
JsonNode jsonNode = objectMapper.readTree(jsonData);
|
||||
// 判断是否为空对象({})
|
||||
if (jsonNode.isObject() && jsonNode.isEmpty()) {
|
||||
flag = true ;
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,6 +4,9 @@ import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.TypeReference;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xzzn.common.constant.RedisKeyConstants;
|
||||
import com.xzzn.common.core.redis.RedisCache;
|
||||
import com.xzzn.common.enums.*;
|
||||
@ -24,6 +27,9 @@ import java.util.*;
|
||||
public class FXXDataProcessServiceImpl implements IFXXDataProcessService {
|
||||
private static final Log log = LogFactory.getLog(FXXDataProcessServiceImpl.class);
|
||||
private static final String SITE_ID = "021_FXX_01";
|
||||
// 初始化ObjectMapper(可以作为全局变量)
|
||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
@Autowired
|
||||
private EmsBatteryClusterMapper emsBatteryClusterMapper;
|
||||
|
||||
@ -61,6 +67,11 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService {
|
||||
String jsonData = obj.get("Data").toString();
|
||||
|
||||
log.info("deviceId:" + deviceId);
|
||||
boolean isEmpty = checkJsonDataEmpty(jsonData);
|
||||
if (isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (deviceId.contains("BMSD")) {
|
||||
batteryStackDataProcess(deviceId, jsonData);
|
||||
|
||||
@ -657,4 +668,21 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService {
|
||||
return records;
|
||||
}
|
||||
|
||||
// 空数据不处理
|
||||
private boolean checkJsonDataEmpty(String jsonData) {
|
||||
boolean flag = false;
|
||||
try {
|
||||
if (StringUtils.isEmpty(jsonData)) {
|
||||
flag = true;
|
||||
}
|
||||
JsonNode jsonNode = objectMapper.readTree(jsonData);
|
||||
// 判断是否为空对象({})
|
||||
if (jsonNode.isObject() && jsonNode.isEmpty()) {
|
||||
flag = true ;
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@ -73,8 +74,11 @@ public class HomePageServiceImpl implements IHomePageService
|
||||
singleSiteBaseInfo.setTotalChargedCap(pcsMap.get("totalChargedCap"));
|
||||
singleSiteBaseInfo.setTotalDisChargedCap(pcsMap.get("totalDischargedCap"));
|
||||
}
|
||||
// 七天放电数据统计
|
||||
List<SiteMonitorDataVo> siteMonitorDataVoList = emsPcsDataMapper.getPcsDataBySiteId(siteId,LIMIT_TIME);
|
||||
// 七天放电数据统计 默认从今天往前7天
|
||||
LocalDate sevenDaysAgo = LocalDate.now().minusDays(LIMIT_TIME);
|
||||
Date startDate = DateUtils.toDate(sevenDaysAgo);
|
||||
Date endDate = new Date();
|
||||
List<SiteMonitorDataVo> siteMonitorDataVoList = emsPcsDataMapper.getPcsDataBySiteId(siteId,startDate,endDate);
|
||||
singleSiteBaseInfo.setSevenDayDisChargeStats(siteMonitorDataVoList);
|
||||
// 充放电基本数据处理
|
||||
dealSitePCSDate(singleSiteBaseInfo,siteMonitorDataVoList);
|
||||
@ -166,4 +170,34 @@ public class HomePageServiceImpl implements IHomePageService
|
||||
return homePageDataViewVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SiteMonitorDataVo> getSevenChargeData(DateSearchRequest requestVo) {
|
||||
String siteId = requestVo.getSiteId();
|
||||
|
||||
// 默认时间-7天
|
||||
dealRequestTime(requestVo);
|
||||
Date startDate = requestVo.getStartDate();
|
||||
Date endDate = requestVo.getEndDate();
|
||||
// 七天放电数据统计
|
||||
List<SiteMonitorDataVo> siteMonitorDataVoList = emsPcsDataMapper.getPcsDataBySiteId(siteId,startDate,endDate);
|
||||
return siteMonitorDataVoList;
|
||||
}
|
||||
|
||||
// 统计入参时间处理
|
||||
public void dealRequestTime(DateSearchRequest requestVo){
|
||||
|
||||
Date startDate = requestVo.getStartDate();
|
||||
Date endDate = requestVo.getEndDate();
|
||||
if (startDate == null && endDate == null) {
|
||||
// 如果没有传时间,默认从今天往前7天
|
||||
LocalDate sevenDaysAgo = LocalDate.now().minusDays(6);
|
||||
startDate = DateUtils.toDate(sevenDaysAgo);
|
||||
endDate = new Date();
|
||||
requestVo.setStartDate(startDate);
|
||||
requestVo.setEndDate(endDate);
|
||||
} else if (endDate != null) {
|
||||
endDate = DateUtils.addDays(endDate, 1);
|
||||
requestVo.setEndDate(endDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -73,7 +74,10 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
List<SiteMonitorHomeAlarmVo> siteMonitorHomeAlarmVo = emsAlarmRecordsMapper.getAlarmRecordsBySiteId(siteId);
|
||||
siteMonitorHomeVo.setSiteMonitorHomeAlarmVo(siteMonitorHomeAlarmVo);
|
||||
// 能量数据
|
||||
List<SiteMonitorDataVo> siteMonitorDataVoList = emsPcsDataMapper.getPcsDataBySiteId(siteId,6);
|
||||
LocalDate sevenDaysAgo = LocalDate.now().minusDays(6);
|
||||
Date startDate = DateUtils.toDate(sevenDaysAgo);
|
||||
Date endDate = new Date();
|
||||
List<SiteMonitorDataVo> siteMonitorDataVoList = emsPcsDataMapper.getPcsDataBySiteId(siteId,startDate,endDate);
|
||||
if (!CollectionUtils.isEmpty(siteMonitorDataVoList)) {
|
||||
for (SiteMonitorDataVo sitePcsData : siteMonitorDataVoList) {
|
||||
// 获取当天的充电量+放电量
|
||||
@ -144,6 +148,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
return siteMonitorRuningInfoVo;
|
||||
}
|
||||
// 获取单站监控实时运行-stack平均温度
|
||||
// 20250811 按小时
|
||||
@Override
|
||||
public SiteMonitorRuningInfoVo getRunningGraphStackTemp(String siteId) {
|
||||
SiteMonitorRuningInfoVo siteMonitorRuningInfoVo = new SiteMonitorRuningInfoVo();
|
||||
@ -210,6 +215,9 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
List<PcsBranchInfo> pcsBranchInfoList = new ArrayList<>();
|
||||
processBranchDataInfo(siteId,pcsId,pcsBranchInfoList);
|
||||
pcsDetailInfoVo.setPcsBranchInfoList(pcsBranchInfoList);
|
||||
// 报警个数
|
||||
int alarmNum = emsAlarmRecordsMapper.getDeviceAlarmNum(siteId,pcsId);
|
||||
pcsDetailInfoVo.setAlarmNum(alarmNum);
|
||||
|
||||
pcsDetailInfoVoList.add(pcsDetailInfoVo);
|
||||
}
|
||||
|
||||
@ -164,4 +164,9 @@
|
||||
or date_format(t.alarm_end_time,'%Y%m%d') BETWEEN date_format(#{alarmStartTime},'%Y%m%d') and date_format(#{alarmEndTime},'%Y%m%d') )
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getDeviceAlarmNum" resultType="java.lang.Integer">
|
||||
select COUNT(*) as alarmNum from ems_alarm_records
|
||||
where site_id = #{siteId} and device_id = #{deviceId}
|
||||
</select>
|
||||
</mapper>
|
||||
@ -348,7 +348,7 @@
|
||||
<select id="getStackAveTempList" resultType="com.xzzn.ems.domain.vo.StackAveTempVo">
|
||||
select t.site_id,
|
||||
avg(t.operating_temp) as temp,
|
||||
DATE_FORMAT(t.create_time, '%Y-%m-%d %H:%i:00') AS createDate
|
||||
DATE_FORMAT(t.create_time, '%Y-%m-%d %H:00:00') AS createDate
|
||||
from ems_battery_stack t
|
||||
where t.site_id = #{siteId}
|
||||
AND t.create_time >= Date(#{startDate})
|
||||
|
||||
@ -306,8 +306,7 @@
|
||||
from ems_pcs_data t
|
||||
inner join( SELECT p.site_id, p.device_id, p.date_month,p.date_day, MAX(p.data_update_time) AS max_update_time
|
||||
FROM ems_pcs_data p
|
||||
where p.site_id = #{siteId}
|
||||
and p.data_update_time >= CURDATE() - INTERVAL #{limitTime} DAY
|
||||
<include refid="commonFilter"/>
|
||||
GROUP BY p.site_id,p.device_id,p.date_month,p.date_day
|
||||
) latest ON t.site_id = latest.site_id
|
||||
AND t.device_id = latest.device_id
|
||||
|
||||
Reference in New Issue
Block a user