sql优化
This commit is contained in:
@ -57,6 +57,51 @@ 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() {
|
||||
@ -194,4 +239,124 @@ 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;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ public class BMSBatteryDataList {
|
||||
/**
|
||||
* 簇号
|
||||
*/
|
||||
private Long clusterId;
|
||||
private String clusterId;
|
||||
|
||||
/** 簇电压 (V) */
|
||||
private BigDecimal clusterVoltage;
|
||||
@ -38,11 +38,11 @@ public class BMSBatteryDataList {
|
||||
/** 堆id */
|
||||
private String stackDeviceId;
|
||||
|
||||
public Long getClusterId() {
|
||||
public String getClusterId() {
|
||||
return clusterId;
|
||||
}
|
||||
|
||||
public void setClusterId(Long clusterId) {
|
||||
public void setClusterId(String clusterId) {
|
||||
this.clusterId = clusterId;
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,11 @@ public class SiteMonitorRunningHeadInfoVo {
|
||||
*/
|
||||
private BigDecimal dayDisChargedCap;
|
||||
|
||||
/**
|
||||
* 站点id
|
||||
*/
|
||||
private String siteId;
|
||||
|
||||
public BigDecimal getTotalActivePower() {
|
||||
return totalActivePower;
|
||||
}
|
||||
@ -84,4 +89,12 @@ public class SiteMonitorRunningHeadInfoVo {
|
||||
public void setDayDisChargedCap(BigDecimal dayDisChargedCap) {
|
||||
this.dayDisChargedCap = dayDisChargedCap;
|
||||
}
|
||||
|
||||
public String getSiteId() {
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setSiteId(String siteId) {
|
||||
this.siteId = siteId;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.xzzn.ems.mapper;
|
||||
import java.util.List;
|
||||
import com.xzzn.ems.domain.EmsPcsBranchData;
|
||||
import com.xzzn.ems.domain.vo.PcsBranchInfo;
|
||||
import io.lettuce.core.dynamic.annotation.Param;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* pcs支路数据Mapper接口
|
||||
|
@ -9,6 +9,7 @@ import com.xzzn.ems.domain.vo.ElectricIndexList;
|
||||
import com.xzzn.ems.domain.vo.PcsDetailInfoVo;
|
||||
import com.xzzn.ems.domain.vo.SiteMonitorDataVo;
|
||||
import com.xzzn.ems.domain.vo.SiteMonitorRunningHeadInfoVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* PCS数据Mapper接口
|
||||
@ -71,14 +72,7 @@ public interface EmsPcsDataMapper
|
||||
* @param siteId
|
||||
* @return
|
||||
*/
|
||||
public List<SiteMonitorDataVo> getPcsDataBySiteId(String siteId);
|
||||
|
||||
/**
|
||||
* 根据站点获取电网实时功率=sum(总交流有功电率)
|
||||
* @param siteId
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal getGridNrtPower(String siteId);
|
||||
public List<SiteMonitorDataVo> getPcsDataBySiteId(@Param("siteId")String siteId, @Param("limitTime")int limitTime);
|
||||
|
||||
/**
|
||||
* 根据站点获取设备监控的实时运行头信息
|
||||
@ -104,5 +98,5 @@ public interface EmsPcsDataMapper
|
||||
* 获取总充+总放
|
||||
* @return
|
||||
*/
|
||||
public Map<String, BigDecimal> getPcsTotalChargeData();
|
||||
public Map<String, BigDecimal> getPcsTotalChargeData(String siteId);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import java.util.*;
|
||||
@Service
|
||||
public class HomePageServiceImpl implements IHomePageService
|
||||
{
|
||||
private static final int LIMIT_TIME = 6;
|
||||
|
||||
@Autowired
|
||||
private IEmsSiteService emsSiteService;
|
||||
@ -37,10 +38,11 @@ public class HomePageServiceImpl implements IHomePageService
|
||||
SiteTotalInfoVo siteTotalInfoVo = new SiteTotalInfoVo();
|
||||
siteTotalInfoVo = emsSiteService.getSiteTotalInfo();
|
||||
// 获取总充+总放
|
||||
Map<String,BigDecimal> pcsMap = new HashMap<>();
|
||||
pcsMap = emsPcsDataMapper.getPcsTotalChargeData();
|
||||
Map<String,BigDecimal> pcsMap = emsPcsDataMapper.getPcsTotalChargeData(null);
|
||||
if(pcsMap != null){
|
||||
siteTotalInfoVo.setTotalChargedCap(pcsMap.get("totalChargedCap"));
|
||||
siteTotalInfoVo.setTotalDischargedCap(pcsMap.get("totalDischargedCap"));
|
||||
}
|
||||
return siteTotalInfoVo;
|
||||
}
|
||||
|
||||
@ -52,7 +54,7 @@ public class HomePageServiceImpl implements IHomePageService
|
||||
if (!StringUtils.isEmpty(siteId)) {
|
||||
// 站点基本信息
|
||||
EmsSiteSetting emsSite = emsSiteMapper.selectEmsSiteSettingBySiteId(siteId);
|
||||
if (StringUtils.isNotEmpty(siteId)) {
|
||||
if (emsSite != null) {
|
||||
// 装机功率+装机容量
|
||||
singleSiteBaseInfo.setSiteName(emsSite.getSiteName());
|
||||
singleSiteBaseInfo.setInstalledCap(emsSite.getInstallCapacity());
|
||||
@ -64,8 +66,14 @@ public class HomePageServiceImpl implements IHomePageService
|
||||
singleSiteBaseInfo.setSiteAddress(emsSite.getSiteAddress());
|
||||
singleSiteBaseInfo.setRunningTime(emsSite.getRunningTime() == null ? null :
|
||||
DateUtils.parseDateToStr("yyyy-MM-dd",emsSite.getRunningTime()));//投运时间
|
||||
// 获取单站点的总充+总放
|
||||
Map<String,BigDecimal> pcsMap = emsPcsDataMapper.getPcsTotalChargeData(siteId);
|
||||
if (pcsMap != null) {
|
||||
singleSiteBaseInfo.setTotalChargedCap(pcsMap.get("totalChargedCap"));
|
||||
singleSiteBaseInfo.setTotalDisChargedCap(pcsMap.get("totalDischargedCap"));
|
||||
}
|
||||
// 七天放电数据统计
|
||||
List<SiteMonitorDataVo> siteMonitorDataVoList = emsPcsDataMapper.getPcsDataBySiteId(siteId);
|
||||
List<SiteMonitorDataVo> siteMonitorDataVoList = emsPcsDataMapper.getPcsDataBySiteId(siteId,LIMIT_TIME);
|
||||
singleSiteBaseInfo.setSevenDayDisChargeStats(siteMonitorDataVoList);
|
||||
// 充放电基本数据处理
|
||||
dealSitePCSDate(singleSiteBaseInfo,siteMonitorDataVoList);
|
||||
@ -77,27 +85,15 @@ public class HomePageServiceImpl implements IHomePageService
|
||||
|
||||
private void dealSitePCSDate(SingleSiteBaseInfo singleSiteBaseInfo, List<SiteMonitorDataVo> siteMonitorDataVoList) {
|
||||
if (siteMonitorDataVoList != null && !siteMonitorDataVoList.isEmpty()) {
|
||||
BigDecimal dayChargeCap = new BigDecimal(0);
|
||||
BigDecimal dayDisChargeCap = new BigDecimal(0);
|
||||
BigDecimal totalChargeCap = new BigDecimal(0);
|
||||
BigDecimal totalDisChargeCap = new BigDecimal(0);
|
||||
for (SiteMonitorDataVo sitePcsData : siteMonitorDataVoList) {
|
||||
// 总充电量
|
||||
totalChargeCap = totalChargeCap.add(sitePcsData.getChargedCap());
|
||||
// 总放电量
|
||||
totalDisChargeCap = totalDisChargeCap.add(sitePcsData.getDisChargedCap());
|
||||
// 获取当天的充电量+放电量
|
||||
String pcsDate = sitePcsData.getAmmeterDate();
|
||||
boolean isToday= checkIsToday(pcsDate);
|
||||
if(isToday){
|
||||
dayChargeCap = dayChargeCap.add(sitePcsData.getChargedCap());
|
||||
dayDisChargeCap = dayDisChargeCap.add(sitePcsData.getDisChargedCap());
|
||||
singleSiteBaseInfo.setDayChargedCap(sitePcsData.getChargedCap());
|
||||
singleSiteBaseInfo.setDayDisChargedCap(sitePcsData.getDisChargedCap());
|
||||
}
|
||||
}
|
||||
singleSiteBaseInfo.setDayChargedCap(dayChargeCap);
|
||||
singleSiteBaseInfo.setDayDisChargedCap(dayDisChargeCap);
|
||||
singleSiteBaseInfo.setTotalChargedCap(totalChargeCap);
|
||||
singleSiteBaseInfo.setTotalDisChargedCap(totalDisChargeCap);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,40 +50,33 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
SiteMonitorHomeVo siteMonitorHomeVo = new SiteMonitorHomeVo();
|
||||
|
||||
if (!StringUtils.isEmpty(siteId)) {
|
||||
// 获取单站点的总充+总放+电网实时功率
|
||||
Map<String,BigDecimal> pcsMap = emsPcsDataMapper.getPcsTotalChargeData(siteId);
|
||||
if (pcsMap != null) {
|
||||
siteMonitorHomeVo.setTotalChargedCap(pcsMap.get("totalChargedCap"));
|
||||
siteMonitorHomeVo.setTotalDischargedCap(pcsMap.get("totalDischargedCap"));
|
||||
siteMonitorHomeVo.setGridNrtPower(pcsMap.get("gridNrtPower"));
|
||||
}
|
||||
// 实时告警数据 名称+状态+告警内容
|
||||
List<SiteMonitorHomeAlarmVo> siteMonitorHomeAlarmVo = emsAlarmRecordsMapper.getAlarmRecordsBySiteId(siteId);
|
||||
siteMonitorHomeVo.setSiteMonitorHomeAlarmVo(siteMonitorHomeAlarmVo);
|
||||
// 能量数据
|
||||
List<SiteMonitorDataVo> siteMonitorDataVoList = emsPcsDataMapper.getPcsDataBySiteId(siteId);
|
||||
List<SiteMonitorDataVo> siteMonitorDataVoList = emsPcsDataMapper.getPcsDataBySiteId(siteId,6);
|
||||
if (!CollectionUtils.isEmpty(siteMonitorDataVoList)) {
|
||||
BigDecimal dayChargeCap = new BigDecimal(0);
|
||||
BigDecimal dayDisChargeCap = new BigDecimal(0);
|
||||
BigDecimal totalChargeCap = new BigDecimal(0);
|
||||
BigDecimal totalDisChargeCap = new BigDecimal(0);
|
||||
for (SiteMonitorDataVo sitePcsData : siteMonitorDataVoList) {
|
||||
// 总充电量
|
||||
totalChargeCap = totalChargeCap.add(sitePcsData.getChargedCap());
|
||||
// 总放电量
|
||||
totalDisChargeCap = totalDisChargeCap.add(sitePcsData.getDisChargedCap());
|
||||
// 获取当天的充电量+放电量
|
||||
String pcsDate = sitePcsData.getAmmeterDate();
|
||||
boolean isToday= checkIsToday(pcsDate);
|
||||
if(isToday){
|
||||
dayChargeCap = dayChargeCap.add(sitePcsData.getChargedCap());
|
||||
dayDisChargeCap = dayDisChargeCap.add(sitePcsData.getDisChargedCap());
|
||||
siteMonitorHomeVo.setDayChargedCap(sitePcsData.getChargedCap());
|
||||
siteMonitorHomeVo.setDayDisChargedCap(sitePcsData.getDisChargedCap());
|
||||
}
|
||||
}
|
||||
siteMonitorHomeVo.setDayChargedCap(dayChargeCap);
|
||||
siteMonitorHomeVo.setDayDisChargedCap(dayDisChargeCap);
|
||||
siteMonitorHomeVo.setTotalChargedCap(totalChargeCap);
|
||||
siteMonitorHomeVo.setTotalDischargedCap(totalDisChargeCap);
|
||||
// 储能可用电量
|
||||
BigDecimal energyStorageAvailElec = siteMonitorHomeVo.getTotalDischargedCap().subtract(siteMonitorHomeVo.getTotalChargedCap());
|
||||
siteMonitorHomeVo.setEnergyStorageAvailElec(energyStorageAvailElec);
|
||||
}
|
||||
siteMonitorHomeVo.setSiteMonitorDataVo(siteMonitorDataVoList);
|
||||
// 电网实时功率
|
||||
siteMonitorHomeVo.setGridNrtPower(emsPcsDataMapper.getGridNrtPower(siteId));
|
||||
}
|
||||
|
||||
return siteMonitorHomeVo;
|
||||
@ -172,8 +165,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
// 获取单体电池数据
|
||||
String stackDeviceId = bmsOverViewVo.getDeviceId();
|
||||
if (!StringUtils.isEmpty(stackDeviceId)) {
|
||||
List<BMSBatteryDataList> batteryDataList = new ArrayList<>();
|
||||
batteryDataList = emsBatteryClusterMapper.getBmsBatteryData(siteId,stackDeviceId);
|
||||
List<BMSBatteryDataList> batteryDataList = emsBatteryClusterMapper.getBmsBatteryData(siteId,stackDeviceId);
|
||||
bmsOverViewVo.setBatteryDataList(batteryDataList);
|
||||
}
|
||||
}
|
||||
@ -196,53 +188,34 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
List<BMSBatteryClusterDataList> clusterDataList = new ArrayList<>();
|
||||
if (!StringUtils.isEmpty(clusterDeviceId)) {
|
||||
// 获取单体电池数据-平均/最大/最小
|
||||
BatteryClusterDataDetailVo batteryClusterDataDetailVo = emsBatteryDataMapper.getBatteryDataByClusterId(siteId,clusterDeviceId);
|
||||
//BatteryClusterDataDetailVo batteryClusterDataDetailVo = emsBatteryDataMapper.getBatteryDataByClusterId(siteId,clusterDeviceId);
|
||||
// 处理数据
|
||||
if (batteryClusterDataDetailVo != null) {
|
||||
BMSBatteryClusterDataList voltageData = new BMSBatteryClusterDataList();
|
||||
BMSBatteryClusterDataList tempData = new BMSBatteryClusterDataList();
|
||||
BMSBatteryClusterDataList socData = new BMSBatteryClusterDataList();
|
||||
// 设值
|
||||
voltageData.setDataName(CLUSTER_DATA_VOLTAGE);
|
||||
voltageData.setAvgData(batteryClusterDataDetailVo.getAvgVoltage());
|
||||
voltageData.setMaxData(batteryClusterDataDetailVo.getMaxVoltage());
|
||||
voltageData.setMinData(batteryClusterDataDetailVo.getMinVoltage());
|
||||
voltageData.setAvgData(bmsBatteryClusterVo.getAvgVoltage());
|
||||
voltageData.setMaxData(bmsBatteryClusterVo.getMaxVoltage());
|
||||
voltageData.setMaxDataID(bmsBatteryClusterVo.getMaxVoltageID());
|
||||
voltageData.setMinData(bmsBatteryClusterVo.getMinVoltage());
|
||||
voltageData.setMinDataID(bmsBatteryClusterVo.getMinVoltageID());
|
||||
tempData.setDataName(CLUSTER_DATA_TEP);
|
||||
tempData.setAvgData(batteryClusterDataDetailVo.getAvgTemp());
|
||||
tempData.setMaxData(batteryClusterDataDetailVo.getMaxTemp());
|
||||
tempData.setMinData(batteryClusterDataDetailVo.getMinTemp());
|
||||
tempData.setAvgData(bmsBatteryClusterVo.getAvgTemp());
|
||||
tempData.setMaxData(bmsBatteryClusterVo.getMaxTemp());
|
||||
tempData.setMaxDataID(bmsBatteryClusterVo.getMaxTempID());
|
||||
tempData.setMinData(bmsBatteryClusterVo.getMinTemp());
|
||||
tempData.setMinDataID(bmsBatteryClusterVo.getMinTempID());
|
||||
socData.setDataName(CLUSTER_DATA_SOC);
|
||||
socData.setAvgData(batteryClusterDataDetailVo.getAvgSoc());
|
||||
socData.setMaxData(batteryClusterDataDetailVo.getMaxSoc());
|
||||
socData.setMinData(batteryClusterDataDetailVo.getMinSoc());
|
||||
socData.setAvgData(bmsBatteryClusterVo.getAvgSoc());
|
||||
socData.setMaxData(bmsBatteryClusterVo.getMaxSoc());
|
||||
socData.setMaxDataID(bmsBatteryClusterVo.getMaxSocID());
|
||||
socData.setMinData(bmsBatteryClusterVo.getMinSoc());
|
||||
socData.setMinDataID(bmsBatteryClusterVo.getMinSocID());
|
||||
|
||||
// 设置对应单体id
|
||||
List<Map<String,Object>> dataIdMapList = emsBatteryDataMapper.getDataIdsMap(batteryClusterDataDetailVo);
|
||||
Map<String,String> resultIdMap = new HashMap<>();
|
||||
if (!CollectionUtils.isEmpty(dataIdMapList)) {
|
||||
resultIdMap = dataIdMapList.stream()
|
||||
.filter(map -> map.containsKey("type") && map.containsKey("device_id")) // 过滤无效数据
|
||||
.filter(map -> map.get("type") instanceof String && map.get("device_id") instanceof Number) // 确保类型正确
|
||||
.collect(Collectors.toMap(
|
||||
map -> (String) map.get("type"), // 键:type 字段
|
||||
map -> (String) map.get("device_id"), // 值:device_id 转为 int
|
||||
(existing, replacement) -> existing // 处理键冲突的策略
|
||||
));
|
||||
|
||||
// 电压
|
||||
voltageData.setMaxDataID(resultIdMap.get("maxVoltageId"));
|
||||
voltageData.setMaxDataID(resultIdMap.get("maxVoltageId"));
|
||||
// 温度
|
||||
tempData.setMaxDataID(resultIdMap.get("maxTempId"));
|
||||
tempData.setMinDataID(resultIdMap.get("minTempId"));
|
||||
// soc
|
||||
socData.setMaxDataID(resultIdMap.get("maxSocId"));
|
||||
socData.setMinDataID(resultIdMap.get("minSocId"));
|
||||
}
|
||||
clusterDataList.add(voltageData);
|
||||
clusterDataList.add(tempData);
|
||||
clusterDataList.add(socData);
|
||||
}
|
||||
bmsBatteryClusterVo.setBatteryDataList(clusterDataList);
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +115,7 @@
|
||||
</delete>
|
||||
|
||||
<select id="getAmmeterDetailInfo" parameterType="String" resultType="com.xzzn.ems.domain.vo.AmmeterDataDetailInfo">
|
||||
select t.category as category,
|
||||
SELECT t.category as category,
|
||||
t.total_kwh as totalKwh,
|
||||
t.sharp_kwh as sharpKwh,
|
||||
t.flat_kwh as flatKwh,
|
||||
@ -123,10 +123,15 @@
|
||||
t.valley_kwh as valleyKwh,
|
||||
t.device_id as deviceId,
|
||||
Max(t.data_update_time) as updateTime
|
||||
from ems_ammeter_data t
|
||||
where t.site_id = #{siteId}
|
||||
and t.data_update_time = (select MAX(tmp.data_update_time) from ems_ammeter_data tmp where tmp.site_id = t.site_id and tmp.device_id = t.device_id)
|
||||
group by t.category,t.total_kwh,t.flat_kwh,t.peak_kwh,t.valley_kwh,t.device_id
|
||||
FROM ems_ammeter_data t
|
||||
INNER JOIN (
|
||||
SELECT p.site_id, p.device_id,p.category,MAX(p.data_update_time) AS max_update_time
|
||||
FROM ems_ammeter_data p
|
||||
WHERE p.site_id = #{siteId}
|
||||
GROUP BY p.site_id,p.device_id,p.category
|
||||
) latest on t.device_id = latest.device_id and t.data_update_time = latest.max_update_time
|
||||
WHERE t.site_id = #{siteId}
|
||||
group by t.category,t.total_kwh,t.sharp_kwh,t.flat_kwh,t.peak_kwh,t.valley_kwh,t.device_id
|
||||
order by updateTime desc
|
||||
</select>
|
||||
</mapper>
|
@ -312,26 +312,44 @@
|
||||
<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.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
|
||||
from ems_battery_cluster tmp left join ems_devices_setting td on tmp.device_id = td.id and tmp.site_id = td.site_id
|
||||
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}
|
||||
and tmp.update_time = (select MAX(t.update_time) FROM ems_battery_cluster t where t.site_id = tmp.site_id
|
||||
and t.device_id = tmp.device_id)
|
||||
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,MAX(tb.voltage) as maxVoltage,MIN(tb.voltage) as minVoltage,
|
||||
MAX(tb.temperature) as maxTemperature,MIN(tb.temperature) as minTemperature,
|
||||
tb.site_id as siteId,tb.cluster_device_id as clusterId,tb.device_id as stackDeviceId
|
||||
from ems_battery_cluster t left join ems_battery_data tb on t.device_id = tb.cluster_device_id
|
||||
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.max_cell_voltage as maxVoltage,t.min_cell_voltage as minVoltage,
|
||||
t.max_cell_temp as maxTemperature,t.min_cell_temp as minTemperature
|
||||
FROM ems_battery_cluster t
|
||||
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} and p.stack_device_id = #{stackDeviceId}
|
||||
GROUP BY p.site_id,p.device_id
|
||||
) latest on t.device_id = latest.device_id and t.update_time = latest.max_update_time
|
||||
where t.site_id = #{siteId} and t.stack_device_id = #{stackDeviceId}
|
||||
and t.update_time = (select MAX(update_time) FROM ems_battery_cluster where site_id = t.site_id
|
||||
and device_id = t.device_id and stack_device_id = t.stack_device_id)
|
||||
group by t.cluster_voltage,t.cluster_current,t.current_soc,tb.site_id,tb.cluster_device_id,tb.device_id
|
||||
group by t.cluster_voltage,t.cluster_current,t.current_soc,t.site_id,t.device_id,t.max_cell_voltage,t.min_cell_voltage,
|
||||
t.max_cell_temp,t.min_cell_temp
|
||||
</select>
|
||||
</mapper>
|
@ -126,8 +126,8 @@
|
||||
|
||||
<select id="getBatteryDataBySiteId" parameterType="String" resultMap="EmsBatteryDataResult">
|
||||
<include refid="selectEmsBatteryDataVo"/>
|
||||
where site_id = #{siteId}
|
||||
and DATE(data_timestamp) = DATE(NOW())
|
||||
WHERE site_id = #{siteId} AND data_timestamp >= CURDATE()
|
||||
ORDER BY data_timestamp desc limit 1
|
||||
</select>
|
||||
|
||||
<select id="getBatteryDataByClusterId" resultType="com.xzzn.ems.domain.vo.BatteryClusterDataDetailVo">
|
||||
|
@ -305,16 +305,23 @@
|
||||
</delete>
|
||||
|
||||
<select id="selectEmsBatteryStackBySiteId" parameterType="String" resultType="com.xzzn.ems.domain.vo.BMSOverViewVo">
|
||||
select td.device_name as deviceName,tmp.work_status as workStatus,
|
||||
SELECT td.device_name as deviceName,tmp.work_status as workStatus,
|
||||
tmp.pcs_communication_status as pcsCommunicationStatus,tmp.ems_communication_status as emsCommunicationStatus,
|
||||
tmp.total_voltage as totalVoltage,tmp.chargeable_capacity as chargeableCapacity,tmp.total_charged_capacity as totalChargedCapacity,
|
||||
tmp.total_current as totalCurrent,tmp.dischargeable_capacity as dischargeableCapacity,tmp.total_discharged_capacity as totalDischargedCapacity,
|
||||
tmp.total_voltage as totalVoltage,tmp.chargeable_capacity as chargeableCapacity,
|
||||
tmp.total_charged_capacity as totalChargedCapacity,
|
||||
tmp.total_current as totalCurrent,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
|
||||
from ems_battery_stack tmp left join ems_devices_setting td on tmp.device_id = td.device_id and tmp.site_id = td.site_id
|
||||
where tmp.site_id = #{siteId}
|
||||
and tmp.update_time = (select MAX(t.update_time) FROM ems_battery_stack t where t.site_id = tmp.site_id
|
||||
and t.device_id = tmp.device_id)
|
||||
FROM ems_battery_stack 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_stack 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>
|
||||
</mapper>
|
@ -214,7 +214,7 @@
|
||||
WHERE t.site_id = #{siteId} AND t.device_id = #{deviceId}
|
||||
) tmp
|
||||
WHERE rn = 1
|
||||
ORDER BY tmp.branch_id;
|
||||
ORDER BY tmp.branch_id
|
||||
</select>
|
||||
|
||||
<insert id="insertPcsBranchDataList" parameterType="java.util.List">
|
||||
|
@ -279,45 +279,57 @@
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="getPcsDataBySiteId" parameterType="String" resultType="com.xzzn.ems.domain.vo.SiteMonitorDataVo">
|
||||
select CONCAT(date_month,'/',date_day) as ammeterDate,
|
||||
sum(daily_ac_charge_energy) as chargedCap,
|
||||
sum(daily_ac_discharge_energy) as disChargedCap
|
||||
from ems_pcs_data
|
||||
where site_id = #{siteId}
|
||||
and date_sub(CURDATE(), interval 6 day) <= create_time
|
||||
group by date_month,date_day
|
||||
</select>
|
||||
|
||||
<select id="getGridNrtPower" parameterType="String" resultType="java.math.BigDecimal">
|
||||
select sum(total_active_power) as gridNrtPower
|
||||
from ems_pcs_data
|
||||
where site_id = #{siteId}
|
||||
<select id="getPcsDataBySiteId" resultType="com.xzzn.ems.domain.vo.SiteMonitorDataVo">
|
||||
select CONCAT(t.date_month,'/',t.date_day) as ammeterDate,
|
||||
sum(t.daily_ac_charge_energy) as chargedCap,
|
||||
sum(t.daily_ac_discharge_energy) as disChargedCap
|
||||
from (
|
||||
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.create_time >= CURDATE() - INTERVAL #{limitTime} DAY
|
||||
GROUP BY p.site_id,p.device_id,p.date_month,p.date_day
|
||||
) latest inner join ems_pcs_data t ON latest.site_id = t.site_id
|
||||
AND latest.device_id = t.device_id
|
||||
AND latest.max_update_time = t.data_update_time
|
||||
and latest.date_month = t.date_month
|
||||
and latest.date_day = t.date_day
|
||||
group by ammeterDate
|
||||
order by ammeterDate desc;
|
||||
</select>
|
||||
|
||||
<select id="getPcsTotalChargeData" resultType="map">
|
||||
select SUM(t.daily_ac_charge_energy) as totalChargedCap,
|
||||
SUM(t.daily_ac_discharge_energy) as totalDischargedCap
|
||||
from ems_pcs_data t
|
||||
where t.data_update_time = (select MAX(data_update_time) FROM ems_pcs_data
|
||||
where site_id = t.site_id and device_id = t.device_id and date_month = t.date_month and date_day = t.date_day)
|
||||
SELECT
|
||||
SUM(t.total_ac_charge_energy) AS totalChargedCap,
|
||||
SUM(t.total_ac_discharge_energy) AS totalDischargedCap,
|
||||
SUM(t.total_active_power) as gridNrtPower
|
||||
FROM (
|
||||
SELECT p.site_id, p.device_id, MAX(p.data_update_time) AS max_update_time
|
||||
FROM ems_pcs_data p inner join ems_site_setting s on p.site_id = s.site_id
|
||||
<if test="siteId != null and siteId != ''">
|
||||
where p.site_id = #{siteId}
|
||||
</if>
|
||||
GROUP BY p.site_id,p.device_id
|
||||
) latest inner join ems_pcs_data t ON latest.site_id = t.site_id
|
||||
AND latest.device_id = t.device_id
|
||||
AND latest.max_update_time = t.data_update_time
|
||||
</select>
|
||||
|
||||
<select id="getSiteRunningHeadInfo" parameterType="String" resultType="com.xzzn.ems.domain.vo.SiteMonitorRunningHeadInfoVo">
|
||||
select sum(a.total_active_power) as totalActivePower,
|
||||
sum(a.total_reactive_power) as totalReactivePower,
|
||||
sum(a.daily_ac_charge_energy) as dayChargedCap,
|
||||
sum(a.daily_ac_discharge_energy) as dayDisChargedCap
|
||||
from (
|
||||
select t.total_active_power,t.total_reactive_power,
|
||||
t.daily_ac_charge_energy,t.daily_ac_discharge_energy,
|
||||
t.device_id,t.site_id,t.create_time
|
||||
from ems_pcs_data t
|
||||
where t.site_id = #{siteId}
|
||||
and t.create_time = (select MAX(create_time) FROM ems_pcs_data where site_id = t.site_id and device_id = t.device_id)
|
||||
group by t.device_id,t.total_active_power, total_reactive_power,
|
||||
t.daily_ac_charge_energy,t.daily_ac_discharge_energy,t.site_id,t.create_time
|
||||
) a
|
||||
SELECT
|
||||
SUM(t.total_active_power) as totalActivePower,
|
||||
SUM(t.total_reactive_power) as totalReactivePower,
|
||||
sum(t.daily_ac_charge_energy) as dayChargedCap,
|
||||
sum(t.daily_ac_discharge_energy) as dayDisChargedCap,
|
||||
#{siteId} as siteId
|
||||
FROM (
|
||||
SELECT p.device_id, 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()
|
||||
GROUP BY p.device_id
|
||||
) latest inner join ems_pcs_data t ON latest.device_id = t.device_id
|
||||
AND latest.max_update_time = t.data_update_time
|
||||
AND t.site_id = #{siteId}
|
||||
</select>
|
||||
|
||||
<select id="getElectDataList" resultType="com.xzzn.ems.domain.vo.ElectricIndexList">
|
||||
@ -335,7 +347,7 @@
|
||||
</select>
|
||||
|
||||
<select id="getPcsDetailInfoBySiteId" parameterType="String" resultType="com.xzzn.ems.domain.vo.PcsDetailInfoVo">
|
||||
select td.device_name as deviceName,
|
||||
SELECT td.device_name as deviceName,
|
||||
td.communication_status as communicationStatus,
|
||||
tmp.site_id as siteId,
|
||||
tmp.device_id as deviceId,
|
||||
@ -349,10 +361,14 @@
|
||||
tmp.c_phase_current as cPhaseVoltage,tmp.c_phase_current as cPhaseCurrent,
|
||||
tmp.total_power_factor as totalPowerFactor,
|
||||
tmp.pcs_environment_temperature as pcsEnvironmentTemperature,tmp.ac_frequency as acFrequency
|
||||
from ems_pcs_data tmp left join ems_devices_setting td on tmp.device_id = td.device_id and tmp.site_id = td.site_id
|
||||
where tmp.site_id = #{siteId}
|
||||
and tmp.data_update_time = (select MAX(data_update_time) FROM ems_pcs_data where site_id = tmp.site_id
|
||||
and device_id = tmp.device_id)
|
||||
FROM ems_pcs_data 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.data_update_time) AS max_update_time
|
||||
FROM ems_pcs_data p
|
||||
WHERE p.site_id = #{siteId}
|
||||
GROUP BY p.site_id,p.device_id
|
||||
) latest on tmp.device_id = latest.device_id and tmp.data_update_time = latest.max_update_time
|
||||
WHERE tmp.site_id = #{siteId}
|
||||
order by tmp.device_id
|
||||
</select>
|
||||
</mapper>
|
Reference in New Issue
Block a user