dev #2
@ -73,9 +73,11 @@ public class RedisKeyConstants
|
||||
/** 现有的告警数据 */
|
||||
public static final String LATEST_ALARM_RECORD = "LATEST_ALARM_RECORD";
|
||||
|
||||
/** fx-电表电量差值起始数据 */
|
||||
public static final String DIFF_CHARGE_START = "diff_charge_start_";
|
||||
|
||||
/** 预存电价时间配置 */
|
||||
public static final String ENERGY_PRICE_TIME = "energy_price_time_";
|
||||
|
||||
/** dds昨日累计总收益 */
|
||||
public static final String DDS_TOTAL_REVENUE = "total_revenue_";
|
||||
/** fx实时总收益和当日实时收益 */
|
||||
public static final String FXX_REALTIME_REVENUE = "realtime_revenue_";
|
||||
}
|
||||
|
||||
@ -30,6 +30,14 @@ public class EmsDailyEnergyData extends BaseEntity
|
||||
@Excel(name = "数据日期:yyyy-MM-dd", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date dataDate;
|
||||
|
||||
/** 总收入 */
|
||||
@Excel(name = "总收入")
|
||||
private BigDecimal totalRevenue;
|
||||
|
||||
/** 当日实时收入 */
|
||||
@Excel(name = "当日实时收入")
|
||||
private BigDecimal dayRevenue;
|
||||
|
||||
/** 尖峰时段充电差值 */
|
||||
@Excel(name = "尖峰时段充电差值")
|
||||
private BigDecimal peakChargeDiff;
|
||||
@ -96,6 +104,26 @@ public class EmsDailyEnergyData extends BaseEntity
|
||||
return dataDate;
|
||||
}
|
||||
|
||||
public void setTotalRevenue(BigDecimal totalRevenue)
|
||||
{
|
||||
this.totalRevenue = totalRevenue;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalRevenue()
|
||||
{
|
||||
return totalRevenue;
|
||||
}
|
||||
|
||||
public void setDayRevenue(BigDecimal dayRevenue)
|
||||
{
|
||||
this.dayRevenue = dayRevenue;
|
||||
}
|
||||
|
||||
public BigDecimal getDayRevenue()
|
||||
{
|
||||
return dayRevenue;
|
||||
}
|
||||
|
||||
public void setPeakChargeDiff(BigDecimal peakChargeDiff)
|
||||
{
|
||||
this.peakChargeDiff = peakChargeDiff;
|
||||
@ -192,6 +220,8 @@ public class EmsDailyEnergyData extends BaseEntity
|
||||
.append("id", getId())
|
||||
.append("siteId", getSiteId())
|
||||
.append("dataDate", getDataDate())
|
||||
.append("totalRevenue", getTotalRevenue())
|
||||
.append("dayRevenue", getDayRevenue())
|
||||
.append("peakChargeDiff", getPeakChargeDiff())
|
||||
.append("peakDischargeDiff", getPeakDischargeDiff())
|
||||
.append("highChargeDiff", getHighChargeDiff())
|
||||
|
||||
@ -65,6 +65,32 @@ public class SiteMonitorHomeVo {
|
||||
*/
|
||||
private StrategyTempInfo strategyTempInfo;
|
||||
|
||||
/**
|
||||
* 总收入
|
||||
*/
|
||||
private BigDecimal totalRevenue;
|
||||
|
||||
/**
|
||||
* 当日实时收入
|
||||
*/
|
||||
private BigDecimal dayRevenue;
|
||||
|
||||
public BigDecimal getTotalRevenue() {
|
||||
return totalRevenue;
|
||||
}
|
||||
|
||||
public void setTotalRevenue(BigDecimal totalRevenue) {
|
||||
this.totalRevenue = totalRevenue;
|
||||
}
|
||||
|
||||
public BigDecimal getDayRevenue() {
|
||||
return dayRevenue;
|
||||
}
|
||||
|
||||
public void setDayRevenue(BigDecimal dayRevenue) {
|
||||
this.dayRevenue = dayRevenue;
|
||||
}
|
||||
|
||||
public BigDecimal getDayChargedCap() {
|
||||
return dayChargedCap;
|
||||
}
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
package com.xzzn.ems.mapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.xzzn.ems.domain.EmsDailyEnergyData;
|
||||
import com.xzzn.ems.domain.vo.AmmeterStatisListVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@ -67,4 +70,8 @@ public interface EmsDailyEnergyDataMapper
|
||||
public void insertOrUpdateData(EmsDailyEnergyData energyData);
|
||||
// 电表报表
|
||||
public List<AmmeterStatisListVo> getDataBySiteId(@Param("siteId")String siteId, @Param("startTime")String startTime, @Param("endTime")String endTime);
|
||||
// dds-获取今天之前最晚的总收入
|
||||
public BigDecimal getLastTotalRevenue(String siteId);
|
||||
// fx-获取实时总收益和当日实时收益
|
||||
public Map<String, BigDecimal> getRealTimeRevenue(String siteId);
|
||||
}
|
||||
|
||||
@ -73,4 +73,7 @@ public interface EmsEnergyPriceConfigMapper
|
||||
public List<EnergyPriceTimeRange> getTimeRangeByDate(@Param("siteId")String siteId,
|
||||
@Param("currentYear")int currentYear,
|
||||
@Param("currentMonth")int currentMonth);
|
||||
// 获取所有有效站点的电价配置
|
||||
public List<EmsEnergyPriceConfig> getAllSitePriceConfig( @Param("currentYear")int currentYear,
|
||||
@Param("currentMonth")int currentMonth);
|
||||
}
|
||||
|
||||
@ -61,4 +61,6 @@ public interface IEmsEnergyPriceConfigService
|
||||
|
||||
// 初始化当月电价
|
||||
public void initCurrentMonthPrice();
|
||||
// 获取指定站点的当月电价
|
||||
public EnergyPriceVo getCurrentMonthPrice(String siteId);
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ import com.xzzn.common.enums.*;
|
||||
import com.xzzn.common.utils.DateUtils;
|
||||
import com.xzzn.common.utils.StringUtils;
|
||||
import com.xzzn.ems.domain.*;
|
||||
import com.xzzn.ems.domain.vo.EnergyPriceVo;
|
||||
import com.xzzn.ems.mapper.*;
|
||||
import com.xzzn.ems.service.IDDSDataProcessService;
|
||||
import com.xzzn.ems.service.IEmsAlarmRecordsService;
|
||||
@ -25,6 +26,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
@ -949,19 +951,19 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
// 初始化当日数据-总的
|
||||
EmsDailyChargeData emsDailyChargeData = initDailyChargeData(deviceId,nowTotalChargeDate,nowTotalDisChargeDate);
|
||||
// 获取redis存放昨日最晚数据
|
||||
String yestData = DateUtils.getYesterdayDate();
|
||||
String yestDateRedisKey = RedisKeyConstants.AMMETER + SITE_ID + "_" + deviceId + "_" + yestData;
|
||||
EmsAmmeterData yestDate = redisCache.getCacheObject(yestDateRedisKey);
|
||||
String yestDate = DateUtils.getYesterdayDate();
|
||||
String yestDateRedisKey = RedisKeyConstants.AMMETER + SITE_ID + "_" + deviceId + "_" + yestDate;
|
||||
EmsAmmeterData yestData = redisCache.getCacheObject(yestDateRedisKey);
|
||||
if (yestDate == null) {
|
||||
// redis没有这查电表总数据表取截止到昨日最新第一条数据
|
||||
yestDate = emsAmmeterDataMapper.getYestLatestDate(SITE_ID,deviceId,yestData);
|
||||
yestData = emsAmmeterDataMapper.getYestLatestDate(SITE_ID,deviceId,yestDate);
|
||||
// 数据存redis-有效期1天
|
||||
redisCache.setCacheObject(yestDateRedisKey, yestDate , Constants.DATE_VALID_TIME, TimeUnit.DAYS);
|
||||
}
|
||||
if (yestDate != null) {
|
||||
// 今日总数据-昨日总数据=今日充放电
|
||||
BigDecimal yestTotalDisChargeDate = yestDate.getCurrentReverseActiveTotal();
|
||||
BigDecimal yestTotalChargeDate = yestDate.getCurrentForwardActiveTotal();
|
||||
BigDecimal yestTotalDisChargeDate = yestData.getCurrentReverseActiveTotal();
|
||||
BigDecimal yestTotalChargeDate = yestData.getCurrentForwardActiveTotal();
|
||||
|
||||
dailyChargeDate = nowTotalChargeDate.subtract(yestTotalChargeDate);
|
||||
dailyDisChargeDate = nowTotalDisChargeDate.subtract(yestTotalDisChargeDate);
|
||||
@ -974,28 +976,88 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
|
||||
// 初始化数据-尖峰平谷
|
||||
EmsDailyEnergyData energyData = initEnergyData();
|
||||
// 计算尖峰平谷差值
|
||||
energyData.setPeakChargeDiff(StringUtils.getBigDecimal(obj.get("DQZXYGJDN"))
|
||||
.subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentForwardActivePeak()));// 正向-尖
|
||||
energyData.setHighChargeDiff(StringUtils.getBigDecimal(obj.get("DQZXYGFDN"))
|
||||
.subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentForwardActiveHigh()));// 正向-峰
|
||||
energyData.setFlatChargeDiff(StringUtils.getBigDecimal(obj.get("DQZXYGPDN"))
|
||||
.subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentForwardActiveFlat()));// 正向-平
|
||||
energyData.setValleyChargeDiff(StringUtils.getBigDecimal(obj.get("DQZXYGGDN"))
|
||||
.subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentForwardActiveValley()));// 正向-谷
|
||||
energyData.setPeakDischargeDiff(StringUtils.getBigDecimal(obj.get("DQFXYGJDN"))
|
||||
.subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentReverseActivePeak()));// 反向-尖
|
||||
energyData.setHighDischargeDiff(StringUtils.getBigDecimal(obj.get("DQFXYGFDN"))
|
||||
.subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentReverseActiveHigh()));// 反向-峰
|
||||
energyData.setFlatDischargeDiff(StringUtils.getBigDecimal(obj.get("DQFXYGPDN"))
|
||||
.subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentReverseActiveFlat()));// 反向-平
|
||||
energyData.setValleyDischargeDiff(StringUtils.getBigDecimal(obj.get("DQFXYGGDN"))
|
||||
.subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentReverseActiveValley()));// 反向-谷
|
||||
// 计算尖峰平谷差值,更新表
|
||||
calcEnergyDiffAndRevenue(energyData,obj,yestData);
|
||||
energyData.setCalcTime(DateUtils.getNowDate());
|
||||
// 插入或更新电表每日差值数据表
|
||||
emsDailyEnergyDataMapper.insertOrUpdateData(energyData);
|
||||
}
|
||||
|
||||
private void calcEnergyDiffAndRevenue(EmsDailyEnergyData energyData, Map<String, Object> obj, EmsAmmeterData yestData) {
|
||||
|
||||
// 获取当月电价
|
||||
String key = RedisKeyConstants.ENERGY_PRICE_TIME + SITE_ID + "_" + LocalDate.now().getYear() + LocalDate.now().getMonthValue();
|
||||
EnergyPriceVo priceVo = redisCache.getCacheObject(key);
|
||||
|
||||
// 计算尖峰平谷差值
|
||||
// 正反向-尖
|
||||
BigDecimal peakChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGJDN"))
|
||||
.subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActivePeak());
|
||||
energyData.setPeakChargeDiff(peakChargeDiff);
|
||||
BigDecimal peakDischargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGJDN"))
|
||||
.subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActivePeak());
|
||||
energyData.setPeakDischargeDiff(peakDischargeDiff);
|
||||
// 正反向-峰
|
||||
BigDecimal highChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGFDN"))
|
||||
.subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveHigh());
|
||||
energyData.setHighChargeDiff(highChargeDiff);
|
||||
BigDecimal highDischargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGFDN"))
|
||||
.subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveHigh());
|
||||
energyData.setHighDischargeDiff(highDischargeDiff);
|
||||
// 正反向-平
|
||||
BigDecimal flatChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGPDN"))
|
||||
.subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveFlat());
|
||||
energyData.setFlatChargeDiff(flatChargeDiff);
|
||||
BigDecimal flatDisChargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGPDN"))
|
||||
.subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveFlat());
|
||||
energyData.setFlatDischargeDiff(flatDisChargeDiff);
|
||||
// 正反向-谷
|
||||
BigDecimal valleyChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGGDN"))
|
||||
.subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveValley());
|
||||
energyData.setValleyChargeDiff(valleyChargeDiff);
|
||||
BigDecimal valleyDisChargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGGDN"))
|
||||
.subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveValley());
|
||||
energyData.setValleyDischargeDiff(valleyDisChargeDiff);
|
||||
|
||||
|
||||
BigDecimal totalRevenue = getYestLastData(SITE_ID);
|
||||
BigDecimal dayRevenue = BigDecimal.ZERO;
|
||||
BigDecimal price = BigDecimal.ZERO;
|
||||
// 计算当日收益,尖峰平谷收益累加,(放电量-充电量)*电价
|
||||
if (priceVo != null) {
|
||||
price = priceVo.getPeak() == null ? BigDecimal.ZERO : priceVo.getPeak();
|
||||
BigDecimal peakRevenue = peakDischargeDiff.subtract(peakChargeDiff).multiply(price);
|
||||
dayRevenue = dayRevenue.add(peakRevenue);
|
||||
price = priceVo.getHigh() == null ? BigDecimal.ZERO : priceVo.getHigh();
|
||||
BigDecimal highRevenue = highDischargeDiff.subtract(highChargeDiff).multiply(price);
|
||||
dayRevenue = dayRevenue.add(highRevenue);
|
||||
price = priceVo.getFlat() == null ? BigDecimal.ZERO : priceVo.getFlat();
|
||||
BigDecimal flatRevenue = flatDisChargeDiff.subtract(flatChargeDiff).multiply(price);
|
||||
dayRevenue = dayRevenue.add(flatRevenue);
|
||||
price = priceVo.getValley() == null ? BigDecimal.ZERO : priceVo.getValley();
|
||||
BigDecimal valleyRevenue = valleyDisChargeDiff.subtract(valleyChargeDiff).multiply(price);
|
||||
dayRevenue = dayRevenue.add(valleyRevenue);
|
||||
energyData.setDayRevenue(dayRevenue);
|
||||
}
|
||||
// 总收益 = 昨日总收益+今日实时收益
|
||||
totalRevenue = totalRevenue.add(dayRevenue);
|
||||
energyData.setTotalRevenue(totalRevenue);
|
||||
}
|
||||
|
||||
private BigDecimal getYestLastData(String siteId) {
|
||||
// dds存的是累计到昨日总收益
|
||||
String redisKey = RedisKeyConstants.DDS_TOTAL_REVENUE + siteId;
|
||||
BigDecimal yestLastTotalRevenue = redisCache.getCacheObject(redisKey);
|
||||
if (yestLastTotalRevenue == null) {
|
||||
yestLastTotalRevenue = emsDailyEnergyDataMapper.getLastTotalRevenue(siteId);
|
||||
if (yestLastTotalRevenue == null) {
|
||||
yestLastTotalRevenue = BigDecimal.ZERO;
|
||||
}
|
||||
redisCache.setCacheObject(redisKey, yestLastTotalRevenue);
|
||||
}
|
||||
return yestLastTotalRevenue;
|
||||
}
|
||||
|
||||
private EmsDailyChargeData initDailyChargeData(String deviceId, BigDecimal nowTotalChargeDate,
|
||||
BigDecimal nowTotalDisChargeDate) {
|
||||
EmsDailyChargeData emsDailyChargeData = new EmsDailyChargeData();
|
||||
|
||||
@ -127,7 +127,15 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer
|
||||
priceConfig.setUpdateBy("system");
|
||||
emsEnergyPriceConfigMapper.insertOrUpdateEmsEnergyPriceConfig(priceConfig);
|
||||
|
||||
return batchInsetPriceTimeRange(priceVo,priceConfig.getId());
|
||||
batchInsetPriceTimeRange(priceVo,priceConfig.getId());
|
||||
|
||||
// 判断是否当月电价,是则更新当月电价缓存
|
||||
int currentMonth = LocalDate.now().getMonthValue();
|
||||
if (currentMonth == Integer.parseInt(month)) {
|
||||
initCurrentMonthPrice();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
private int batchInsetPriceTimeRange(EnergyPriceVo priceVo, Long priceId) {
|
||||
@ -176,7 +184,14 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer
|
||||
// 时间配置,全删,全插入
|
||||
Long[] priceIds = {priceVo.getId()};
|
||||
emsPriceTimeConfigMapper.deleteTimeRangeByPriceId(priceIds);
|
||||
return batchInsetPriceTimeRange(priceVo,priceConfig.getId());
|
||||
batchInsetPriceTimeRange(priceVo,priceConfig.getId());
|
||||
|
||||
// 判断是否当月电价,是则更新当月电价缓存
|
||||
int currentMonth = LocalDate.now().getMonthValue();
|
||||
if (currentMonth == Integer.parseInt(priceVo.getMonth())) {
|
||||
initCurrentMonthPrice();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -191,7 +206,10 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer
|
||||
// 先删时间配置
|
||||
emsPriceTimeConfigMapper.deleteTimeRangeByPriceId(ids);
|
||||
// 再删月电价
|
||||
return emsEnergyPriceConfigMapper.deleteEmsEnergyPriceConfigByIds(ids);
|
||||
emsEnergyPriceConfigMapper.deleteEmsEnergyPriceConfigByIds(ids);
|
||||
// 更新当月电价缓存
|
||||
initCurrentMonthPrice();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -207,7 +225,7 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化当月的电价
|
||||
* 初始化当月的电价存redis
|
||||
*/
|
||||
@Override
|
||||
public void initCurrentMonthPrice() {
|
||||
@ -215,15 +233,34 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer
|
||||
int currentMonth = LocalDate.now().getMonthValue();
|
||||
int currentYear = LocalDate.now().getYear();
|
||||
|
||||
List<String> siteIds = emsSiteSettingMapper.getAllSiteId();
|
||||
if (siteIds == null || siteIds.size() == 0) {
|
||||
List<EmsEnergyPriceConfig> siteIdConfig = emsEnergyPriceConfigMapper.getAllSitePriceConfig(currentYear,currentMonth);
|
||||
if (siteIdConfig == null || siteIdConfig.size() == 0) {
|
||||
return;
|
||||
}
|
||||
for (String siteId : siteIds) {
|
||||
for (EmsEnergyPriceConfig priceConfig : siteIdConfig) {
|
||||
EnergyPriceVo priceVo = new EnergyPriceVo();
|
||||
BeanUtils.copyProperties(priceConfig,priceVo);
|
||||
String siteId = priceConfig.getSiteId();
|
||||
List<EnergyPriceTimeRange> timeRanges = emsEnergyPriceConfigMapper.getTimeRangeByDate(siteId,currentYear,currentMonth);
|
||||
priceVo.setRange(timeRanges);
|
||||
String key = RedisKeyConstants.ENERGY_PRICE_TIME + siteId + "_" + currentYear + currentMonth;
|
||||
redisCache.setCacheObject(key,timeRanges, 31, TimeUnit.DAYS);
|
||||
redisCache.setCacheObject(key,priceVo, 31, TimeUnit.DAYS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public EnergyPriceVo getCurrentMonthPrice(String siteId) {
|
||||
EnergyPriceVo priceVo = new EnergyPriceVo();
|
||||
// 获取当年和当月的电价
|
||||
int currentMonth = LocalDate.now().getMonthValue();
|
||||
int currentYear = LocalDate.now().getYear();
|
||||
|
||||
EmsEnergyPriceConfig priceConfig = emsEnergyPriceConfigMapper.getConfigListByYearAndMonth(siteId,String.valueOf(currentYear),String.valueOf(currentMonth));
|
||||
if (priceConfig != null) {
|
||||
BeanUtils.copyProperties(priceConfig,priceVo);
|
||||
List<EnergyPriceTimeRange> timeRanges = emsPriceTimeConfigMapper.getTimeRangeByPriceId(priceConfig.getId());
|
||||
priceVo.setRange(timeRanges);
|
||||
}
|
||||
return priceVo;
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,8 +14,10 @@ import com.xzzn.common.utils.DateUtils;
|
||||
import com.xzzn.common.utils.StringUtils;
|
||||
import com.xzzn.ems.domain.*;
|
||||
import com.xzzn.ems.domain.vo.EnergyPriceTimeRange;
|
||||
import com.xzzn.ems.domain.vo.EnergyPriceVo;
|
||||
import com.xzzn.ems.mapper.*;
|
||||
import com.xzzn.ems.service.IEmsAlarmRecordsService;
|
||||
import com.xzzn.ems.service.IEmsEnergyPriceConfigService;
|
||||
import com.xzzn.ems.service.IFXXDataProcessService;
|
||||
import com.xzzn.ems.utils.AbstractBatteryDataProcessor;
|
||||
import org.apache.commons.logging.Log;
|
||||
@ -78,6 +80,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
private EmsDailyEnergyDataMapper emsDailyEnergyDataMapper;
|
||||
@Autowired
|
||||
private EmsEnergyPriceConfigMapper emsEnergyPriceConfigMapper;
|
||||
@Autowired
|
||||
private IEmsEnergyPriceConfigService emsEnergyPriceConfigService;
|
||||
|
||||
// 构造方法(调用父类构造)
|
||||
public FXXDataProcessServiceImpl(ObjectMapper objectMapper) {
|
||||
@ -772,7 +776,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, dataLoad);
|
||||
|
||||
// 处理电表每日充放电数据
|
||||
dealAmmeterDailyDate(obj, deviceId, dataUpdateTime, lastAmmeterData);
|
||||
dealAmmeterDailyDate(obj, dataUpdateTime, lastAmmeterData);
|
||||
}
|
||||
|
||||
private EmsAmmeterData getLastAmmeterData(String deviceId) {
|
||||
@ -791,16 +795,20 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
return lastData;
|
||||
}
|
||||
|
||||
private void dealAmmeterDailyDate(Map<String, Object> obj, String deviceId, Date dataUpdateTime, EmsAmmeterData lastData) {
|
||||
private void dealAmmeterDailyDate(Map<String, Object> obj, Date dataUpdateTime, EmsAmmeterData lastData) {
|
||||
// 先获取当月电价配置,redis没有这查数据库,都没有则返回
|
||||
String priceKey = RedisKeyConstants.ENERGY_PRICE_TIME + SITE_ID + "_" + LocalDate.now().getYear() + LocalDate.now().getMonthValue();
|
||||
List<EnergyPriceTimeRange> timeRanges = redisCache.getCacheObject(priceKey);
|
||||
if (timeRanges == null) {
|
||||
timeRanges = emsEnergyPriceConfigMapper.getTimeRangeByDate(SITE_ID, LocalDate.now().getYear(),LocalDate.now().getMonthValue());
|
||||
if (timeRanges == null) {
|
||||
EnergyPriceVo priceVo = redisCache.getCacheObject(priceKey);
|
||||
if (priceVo == null) {
|
||||
priceVo = emsEnergyPriceConfigService.getCurrentMonthPrice(SITE_ID);
|
||||
redisCache.setCacheObject(priceKey, priceVo, 31, TimeUnit.DAYS);
|
||||
if (priceVo == null) {
|
||||
return;
|
||||
}
|
||||
redisCache.setCacheObject(priceKey,timeRanges, 31, TimeUnit.DAYS);
|
||||
}
|
||||
List<EnergyPriceTimeRange> timeRanges = priceVo.getRange();
|
||||
if (timeRanges == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据时间范围判断数据类型(尖峰平谷),无法确定数据类型则不处理
|
||||
@ -808,7 +816,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
String startTime = "";
|
||||
for (EnergyPriceTimeRange timeRange : timeRanges) {
|
||||
startTime = timeRange.getStartTime();
|
||||
if (isInPriceTimeRange(startTime,timeRange.getEndTime(),dataUpdateTime)) {
|
||||
if (isInPriceTimeRange(startTime, timeRange.getEndTime(), dataUpdateTime)) {
|
||||
costType = timeRange.getCostType();
|
||||
break;
|
||||
}
|
||||
@ -821,19 +829,26 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
EmsDailyEnergyData energyData = initEnergyData();
|
||||
|
||||
// 根据 costType,计算本次与上次数据差值,累加到对应的数据类型里面
|
||||
setDiffByCostType(costType,energyData,lastData,obj);
|
||||
setDiffByCostType(costType,energyData,lastData,obj,priceVo);
|
||||
|
||||
// 插入或更新电表每日差值数据表
|
||||
emsDailyEnergyDataMapper.insertOrUpdateData(energyData);
|
||||
}
|
||||
|
||||
private void setDiffByCostType(String costType, EmsDailyEnergyData energyData, EmsAmmeterData lastData, Map<String, Object> obj) {
|
||||
private void setDiffByCostType(String costType, EmsDailyEnergyData energyData, EmsAmmeterData lastData,
|
||||
Map<String, Object> obj, EnergyPriceVo priceVo) {
|
||||
BigDecimal currentChargeData = StringUtils.getBigDecimal(obj.get("ZXYGDN"));
|
||||
BigDecimal currentDischargeData = StringUtils.getBigDecimal(obj.get("FXYGDN"));
|
||||
currentChargeData = currentChargeData != null ? currentChargeData : BigDecimal.ZERO;
|
||||
currentDischargeData = currentDischargeData != null ? currentDischargeData : BigDecimal.ZERO;
|
||||
|
||||
// 获取上次实时总收益+当日实时总收益,初始化电价
|
||||
Map<String, BigDecimal> revenueMap = getLastData(SITE_ID);
|
||||
BigDecimal totalRevenue = revenueMap.get("totalRevenue") == null ? BigDecimal.ZERO : revenueMap.get("totalRevenue");
|
||||
BigDecimal dayRevenue = revenueMap.get("dayRevenue") == null ? BigDecimal.ZERO : revenueMap.get("dayRevenue");
|
||||
BigDecimal price = BigDecimal.ZERO;
|
||||
// 计算时段差值,按照数据类型累加
|
||||
// 计算当日累加收益,尖峰平谷收益在当日原基础累加,(放电量-充电量)*电价
|
||||
BigDecimal chargeDiffData = currentChargeData.subtract(
|
||||
lastData.getCurrentForwardActiveTotal() == null ? BigDecimal.ZERO : lastData.getCurrentForwardActiveTotal());
|
||||
BigDecimal disChargeDiffData = currentDischargeData.subtract(
|
||||
@ -841,40 +856,72 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
);
|
||||
switch (costType) {
|
||||
case "peak":
|
||||
BigDecimal peakCharge = energyData.getPeakChargeDiff();
|
||||
energyData.setPeakChargeDiff((peakCharge == null ? BigDecimal.ZERO : peakCharge)
|
||||
.add(chargeDiffData));
|
||||
BigDecimal peakDischarge = energyData.getPeakDischargeDiff();
|
||||
energyData.setPeakDischargeDiff((peakDischarge == null ? BigDecimal.ZERO : peakDischarge)
|
||||
.add(disChargeDiffData));
|
||||
// 增加电量
|
||||
BigDecimal peakCharge = energyData.getPeakChargeDiff() == null ? BigDecimal.ZERO : energyData.getPeakChargeDiff();
|
||||
energyData.setPeakChargeDiff(peakCharge.add(chargeDiffData));
|
||||
BigDecimal peakDischarge = energyData.getPeakDischargeDiff() == null ? BigDecimal.ZERO : energyData.getPeakDischargeDiff();
|
||||
energyData.setPeakDischargeDiff(peakDischarge.add(disChargeDiffData));
|
||||
|
||||
// 电价
|
||||
price = priceVo.getPeak() == null ? BigDecimal.ZERO : priceVo.getPeak();
|
||||
break;
|
||||
case "high":
|
||||
BigDecimal highCharge = energyData.getHighChargeDiff();
|
||||
energyData.setHighChargeDiff((highCharge == null ? BigDecimal.ZERO : highCharge)
|
||||
.add(chargeDiffData));
|
||||
BigDecimal highDischarge = energyData.getHighDischargeDiff();
|
||||
energyData.setHighDischargeDiff((highDischarge == null ? BigDecimal.ZERO : highDischarge)
|
||||
.add(disChargeDiffData));
|
||||
// 增加电量
|
||||
BigDecimal highCharge = energyData.getHighChargeDiff() == null ? BigDecimal.ZERO : energyData.getHighChargeDiff();
|
||||
energyData.setHighChargeDiff(highCharge.add(chargeDiffData));
|
||||
BigDecimal highDischarge = energyData.getHighDischargeDiff() == null ? BigDecimal.ZERO : energyData.getHighDischargeDiff();
|
||||
energyData.setHighDischargeDiff(highDischarge.add(disChargeDiffData));
|
||||
|
||||
// 电价
|
||||
price = priceVo.getHigh() == null ? BigDecimal.ZERO : priceVo.getHigh();
|
||||
break;
|
||||
case "flat":
|
||||
BigDecimal flatCharge = energyData.getFlatChargeDiff();
|
||||
energyData.setFlatChargeDiff((flatCharge == null ? BigDecimal.ZERO : flatCharge)
|
||||
.add(chargeDiffData));
|
||||
BigDecimal flatDischarge = energyData.getFlatDischargeDiff();
|
||||
energyData.setFlatDischargeDiff((flatDischarge == null ? BigDecimal.ZERO : flatDischarge)
|
||||
.add(disChargeDiffData));
|
||||
// 增加电量
|
||||
BigDecimal flatCharge = energyData.getFlatChargeDiff() == null ? BigDecimal.ZERO : energyData.getFlatChargeDiff();
|
||||
energyData.setFlatChargeDiff(flatCharge.add(chargeDiffData));
|
||||
BigDecimal flatDischarge = energyData.getFlatDischargeDiff() == null ? BigDecimal.ZERO : energyData.getFlatDischargeDiff();
|
||||
energyData.setFlatDischargeDiff(flatDischarge.add(disChargeDiffData));
|
||||
|
||||
// 电价
|
||||
price = priceVo.getFlat() == null ? BigDecimal.ZERO : priceVo.getFlat();
|
||||
break;
|
||||
case "valley":
|
||||
BigDecimal valleyCharge = energyData.getValleyChargeDiff();
|
||||
energyData.setValleyChargeDiff((valleyCharge == null ? BigDecimal.ZERO : valleyCharge)
|
||||
.add(chargeDiffData));
|
||||
BigDecimal valleyDischarge = energyData.getValleyDischargeDiff();
|
||||
energyData.setValleyDischargeDiff((valleyDischarge == null ? BigDecimal.ZERO : valleyDischarge)
|
||||
.add(disChargeDiffData));
|
||||
// 增加电量
|
||||
BigDecimal valleyCharge = energyData.getValleyChargeDiff() == null ? BigDecimal.ZERO : energyData.getValleyChargeDiff();
|
||||
energyData.setValleyChargeDiff(valleyCharge.add(chargeDiffData));
|
||||
BigDecimal valleyDischarge = energyData.getValleyDischargeDiff() == null ? BigDecimal.ZERO : energyData.getValleyDischargeDiff();
|
||||
energyData.setValleyDischargeDiff(valleyDischarge.add(disChargeDiffData));
|
||||
|
||||
// 电价
|
||||
price = priceVo.getValley() == null ? BigDecimal.ZERO : priceVo.getValley();
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
// 计算本次累加收益
|
||||
BigDecimal addRevenue = disChargeDiffData.subtract(chargeDiffData).multiply(price);
|
||||
dayRevenue = dayRevenue.add(addRevenue);
|
||||
energyData.setDayRevenue(dayRevenue);
|
||||
// 总收益 = 上次实时总收益+今日实时增加的收益
|
||||
totalRevenue = totalRevenue.add(addRevenue);
|
||||
energyData.setTotalRevenue(totalRevenue);
|
||||
}
|
||||
|
||||
private Map<String, BigDecimal> getLastData(String siteId) {
|
||||
// dds存的是累计到昨日总收益
|
||||
String redisKey = RedisKeyConstants.FXX_REALTIME_REVENUE + siteId;
|
||||
Map<String, BigDecimal> realTimeRevenue = redisCache.getCacheObject(redisKey);
|
||||
if (realTimeRevenue == null) {
|
||||
realTimeRevenue = emsDailyEnergyDataMapper.getRealTimeRevenue(siteId);
|
||||
if (realTimeRevenue == null) {
|
||||
realTimeRevenue = new HashMap<>();
|
||||
realTimeRevenue.put("totalRevenue", BigDecimal.ZERO);
|
||||
realTimeRevenue.put("dayRevenue", BigDecimal.ZERO);
|
||||
}
|
||||
redisCache.setCacheObject(redisKey, realTimeRevenue);
|
||||
}
|
||||
return realTimeRevenue;
|
||||
}
|
||||
|
||||
private boolean isInPriceTimeRange(String startTime, String endTime, Date dataUpdateTime) {
|
||||
@ -907,6 +954,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
energyData = new EmsDailyEnergyData();
|
||||
energyData.setSiteId(SITE_ID);
|
||||
energyData.setDataDate(DateUtils.getNowDate());
|
||||
energyData.setTotalRevenue(BigDecimal.ZERO);
|
||||
energyData.setDayRevenue(BigDecimal.ZERO);
|
||||
energyData.setCreateBy("system");
|
||||
energyData.setCreateTime(DateUtils.getNowDate());
|
||||
}
|
||||
|
||||
@ -37,18 +37,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
|
||||
private static final String CLUSTER_DATA_SOC = "SOC";
|
||||
|
||||
private static Map<String, BigDecimal> storageFactor = new HashMap<>();
|
||||
static {
|
||||
storageFactor.put("021_DDS_01", new BigDecimal("0.1"));
|
||||
storageFactor.put("default", BigDecimal.ONE); // 默认1
|
||||
}
|
||||
|
||||
private static Map<String, BigDecimal> pvFactor = new HashMap<>();
|
||||
static {
|
||||
pvFactor.put("021_DDS_01", new BigDecimal("-0.001"));
|
||||
pvFactor.put("default", BigDecimal.ONE); // Convert to Basic Latin
|
||||
}
|
||||
|
||||
// 初始化List,存储指定的电表deviceId
|
||||
List<String> ammeterDeviceIds = Arrays.asList(
|
||||
"LOAD", "METE", "METEGF"
|
||||
@ -62,8 +50,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
@Autowired
|
||||
private EmsBatteryClusterMapper emsBatteryClusterMapper;
|
||||
@Autowired
|
||||
private EmsCoolingDataMapper emsCoolingDataMapper;
|
||||
@Autowired
|
||||
private EmsAmmeterDataMapper emsAmmeterDataMapper;
|
||||
@Autowired
|
||||
private EmsDevicesSettingMapper emsDevicesSettingMapper;
|
||||
@ -76,6 +62,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
private EmsStrategyTempMapper emsStrategyTempMapper;
|
||||
@Autowired
|
||||
private EmsDailyChargeDataMapper emsDailyChargeDataMapper;
|
||||
@Autowired
|
||||
private EmsDailyEnergyDataMapper emsDailyEnergyDataMapper;
|
||||
|
||||
@Override
|
||||
public SiteMonitorHomeVo getSiteMonitorDataVo(String siteId) {
|
||||
@ -90,9 +78,14 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
siteMonitorHomeVo.setTotalDischargedCap(dataMap.get("totalDischargedCap"));
|
||||
//siteMonitorHomeVo.setGridNrtPower(dataMap.get("gridNrtPower"));
|
||||
}
|
||||
|
||||
// 总收入+当日实时收入
|
||||
setRevenueInfo(siteMonitorHomeVo,siteId);
|
||||
|
||||
// 实时告警数据 名称+状态+告警内容
|
||||
List<SiteMonitorHomeAlarmVo> siteMonitorHomeAlarmVo = emsAlarmRecordsMapper.getAlarmRecordsBySiteId(siteId);
|
||||
siteMonitorHomeVo.setSiteMonitorHomeAlarmVo(siteMonitorHomeAlarmVo);
|
||||
|
||||
// 策略运行-主策略模板数据
|
||||
List<StrategyRunningVo> runningVo = emsStrategyRunningMapper.getRunningList(siteId);
|
||||
if (runningVo != null && runningVo.size() > 0) {
|
||||
@ -103,6 +96,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
siteTempInfo.setSiteMonitorDataVo(tempList);
|
||||
siteMonitorHomeVo.setStrategyTempInfo(siteTempInfo);
|
||||
}
|
||||
|
||||
// 能量数据
|
||||
LocalDate sevenDaysAgo = LocalDate.now().minusDays(6);
|
||||
Date startDate = DateUtils.toDate(sevenDaysAgo);
|
||||
@ -122,12 +116,25 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
BigDecimal energyStorageAvailElec = siteMonitorHomeVo.getTotalDischargedCap().subtract(siteMonitorHomeVo.getTotalChargedCap());
|
||||
siteMonitorHomeVo.setEnergyStorageAvailElec(energyStorageAvailElec);
|
||||
}
|
||||
|
||||
siteMonitorHomeVo.setSiteMonitorDataVo(siteMonitorDataVoList);
|
||||
}
|
||||
|
||||
return siteMonitorHomeVo;
|
||||
}
|
||||
|
||||
private void setRevenueInfo(SiteMonitorHomeVo siteMonitorHomeVo, String siteId) {
|
||||
BigDecimal totalRevenue = BigDecimal.ZERO;
|
||||
BigDecimal dayRevenue = BigDecimal.ZERO;
|
||||
Map<String,BigDecimal> realTimeRevenue = emsDailyEnergyDataMapper.getRealTimeRevenue(siteId);
|
||||
if (realTimeRevenue != null) {
|
||||
totalRevenue = realTimeRevenue.get("totalRevenue") == null ? BigDecimal.ZERO : realTimeRevenue.get("totalRevenue");
|
||||
dayRevenue = realTimeRevenue.get("dayRevenue") == null ? BigDecimal.ZERO : realTimeRevenue.get("dayRevenue");
|
||||
}
|
||||
siteMonitorHomeVo.setTotalRevenue(totalRevenue);
|
||||
siteMonitorHomeVo.setDayRevenue(dayRevenue);
|
||||
}
|
||||
|
||||
// 获取单站监控实时运行头部数据
|
||||
@Override
|
||||
public SiteMonitorRunningHeadInfoVo getSiteRunningHeadInfo(String siteId) {
|
||||
|
||||
@ -8,6 +8,8 @@
|
||||
<result property="id" column="id" />
|
||||
<result property="siteId" column="site_id" />
|
||||
<result property="dataDate" column="data_date" />
|
||||
<result property="totalRevenue" column="total_revenue" />
|
||||
<result property="dayRevenue" column="day_revenue" />
|
||||
<result property="peakChargeDiff" column="peak_charge_diff" />
|
||||
<result property="peakDischargeDiff" column="peak_discharge_diff" />
|
||||
<result property="highChargeDiff" column="high_charge_diff" />
|
||||
@ -25,7 +27,7 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEmsDailyEnergyDataVo">
|
||||
select id, site_id, data_date, peak_charge_diff, peak_discharge_diff, high_charge_diff, high_discharge_diff, flat_charge_diff, flat_discharge_diff, valley_charge_diff, valley_discharge_diff, calc_time, create_by, create_time, update_by, update_time, remark from ems_daily_energy_data
|
||||
select id, site_id, data_date, total_revenue, day_revenue, peak_charge_diff, peak_discharge_diff, high_charge_diff, high_discharge_diff, flat_charge_diff, flat_discharge_diff, valley_charge_diff, valley_discharge_diff, calc_time, create_by, create_time, update_by, update_time, remark from ems_daily_energy_data
|
||||
</sql>
|
||||
|
||||
<select id="selectEmsDailyEnergyDataList" parameterType="EmsDailyEnergyData" resultMap="EmsDailyEnergyDataResult">
|
||||
@ -33,6 +35,8 @@
|
||||
<where>
|
||||
<if test="siteId != null and siteId != ''"> and site_id = #{siteId}</if>
|
||||
<if test="dataDate != null "> and data_date = #{dataDate}</if>
|
||||
<if test="totalRevenue != null "> and total_revenue = #{totalRevenue}</if>
|
||||
<if test="dayRevenue != null "> and day_revenue = #{dayRevenue}</if>
|
||||
<if test="peakChargeDiff != null "> and peak_charge_diff = #{peakChargeDiff}</if>
|
||||
<if test="peakDischargeDiff != null "> and peak_discharge_diff = #{peakDischargeDiff}</if>
|
||||
<if test="highChargeDiff != null "> and high_charge_diff = #{highChargeDiff}</if>
|
||||
@ -55,6 +59,8 @@
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="siteId != null">site_id,</if>
|
||||
<if test="dataDate != null">data_date,</if>
|
||||
<if test="totalRevenue != null">total_revenue,</if>
|
||||
<if test="dayRevenue != null">day_revenue,</if>
|
||||
<if test="peakChargeDiff != null">peak_charge_diff,</if>
|
||||
<if test="peakDischargeDiff != null">peak_discharge_diff,</if>
|
||||
<if test="highChargeDiff != null">high_charge_diff,</if>
|
||||
@ -73,6 +79,8 @@
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="siteId != null">#{siteId},</if>
|
||||
<if test="dataDate != null">#{dataDate},</if>
|
||||
<if test="totalRevenue != null">#{totalRevenue},</if>
|
||||
<if test="dayRevenue != null">#{dayRevenue},</if>
|
||||
<if test="peakChargeDiff != null">#{peakChargeDiff},</if>
|
||||
<if test="peakDischargeDiff != null">#{peakDischargeDiff},</if>
|
||||
<if test="highChargeDiff != null">#{highChargeDiff},</if>
|
||||
@ -95,6 +103,8 @@
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="siteId != null">site_id = #{siteId},</if>
|
||||
<if test="dataDate != null">data_date = #{dataDate},</if>
|
||||
<if test="totalRevenue != null">total_revenue = #{totalRevenue},</if>
|
||||
<if test="dayRevenue != null">day_revenue = #{dayRevenue},</if>
|
||||
<if test="peakChargeDiff != null">peak_charge_diff = #{peakChargeDiff},</if>
|
||||
<if test="peakDischargeDiff != null">peak_discharge_diff = #{peakDischargeDiff},</if>
|
||||
<if test="highChargeDiff != null">high_charge_diff = #{highChargeDiff},</if>
|
||||
@ -134,6 +144,8 @@
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO ems_daily_energy_data (
|
||||
id, site_id, data_date,
|
||||
<if test="totalRevenue != null">total_revenue,</if>
|
||||
<if test="dayRevenue != null">day_revenue,</if>
|
||||
<if test="peakChargeDiff != null">peak_charge_diff,</if>
|
||||
<if test="peakDischargeDiff != null">peak_discharge_diff,</if>
|
||||
<if test="highChargeDiff != null">high_charge_diff,</if>
|
||||
@ -152,6 +164,8 @@
|
||||
#{id},
|
||||
#{siteId},
|
||||
#{dataDate},
|
||||
<if test="totalRevenue != null">#{totalRevenue},</if>
|
||||
<if test="dayRevenue != null">#{dayRevenue},</if>
|
||||
<if test="peakChargeDiff != null">#{peakChargeDiff},</if>
|
||||
<if test="peakDischargeDiff != null">#{peakDischargeDiff},</if>
|
||||
<if test="highChargeDiff != null">#{highChargeDiff},</if>
|
||||
@ -167,6 +181,8 @@
|
||||
NOW(),
|
||||
#{remark}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
<if test="totalRevenue != null">total_revenue = #{totalRevenue},</if>
|
||||
<if test="dayRevenue != null">day_revenue = #{dayRevenue},</if>
|
||||
<if test="peakChargeDiff != null">peak_charge_diff = #{peakChargeDiff},</if>
|
||||
<if test="peakDischargeDiff != null">peak_discharge_diff = #{peakDischargeDiff},</if>
|
||||
<if test="highChargeDiff != null">high_charge_diff = #{highChargeDiff},</if>
|
||||
@ -198,7 +214,22 @@
|
||||
and t.data_date >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
and t.data_date >= #{endTime}
|
||||
and t.data_date <= #{endTime}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getLastTotalRevenue" resultType="java.math.BigDecimal">
|
||||
select t.total_revenue
|
||||
from ems_daily_energy_data t
|
||||
where t.site_id = #{siteId}
|
||||
and t.data_date < CURDATE()
|
||||
order by t.data_date desc limit 1
|
||||
</select>
|
||||
|
||||
<select id="getRealTimeRevenue" resultType="java.util.Map">
|
||||
select t.total_revenue as totalRevenue, t.day_revenue as dayRevenue
|
||||
from ems_daily_energy_data t
|
||||
where t.site_id = #{siteId}
|
||||
order by t.data_date desc limit 1
|
||||
</select>
|
||||
</mapper>
|
||||
@ -169,4 +169,12 @@
|
||||
and t.`year` = #{currentYear}
|
||||
and t.`month` = #{currentMonth}
|
||||
</select>
|
||||
|
||||
<select id="getAllSitePriceConfig" resultMap="EmsEnergyPriceConfigResult">
|
||||
select t.*
|
||||
from ems_energy_price_config t
|
||||
LEFT JOIN ems_site_setting t2 on t.site_id = t2.site_id
|
||||
where t.`year` = #{currentYear}
|
||||
and t.`month` = #{currentMonth}
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user