电价-实时收入实时计算
This commit is contained in:
@ -426,8 +426,6 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
|||||||
});
|
});
|
||||||
EmsDevicesSetting joken = new EmsDevicesSetting();
|
EmsDevicesSetting joken = new EmsDevicesSetting();
|
||||||
|
|
||||||
// 获取redis获取最新的BMSD01数据
|
|
||||||
Map<String, Object> stackObj = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_BMSD +SITE_ID+"_BMSD01");
|
|
||||||
|
|
||||||
//BMSC 电池簇
|
//BMSC 电池簇
|
||||||
EmsBatteryCluster data = new EmsBatteryCluster();
|
EmsBatteryCluster data = new EmsBatteryCluster();
|
||||||
@ -448,6 +446,8 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
|||||||
} else {
|
} else {
|
||||||
data.setStackDeviceId("1");
|
data.setStackDeviceId("1");
|
||||||
}
|
}
|
||||||
|
// 获取redis获取最新的BMSD数据
|
||||||
|
Map<String, Object> stackObj = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_BMSD +SITE_ID+"_"+stackDeviceId);
|
||||||
data.setDeviceId(deviceId);
|
data.setDeviceId(deviceId);
|
||||||
data.setClusterVoltage(StringUtils.getBigDecimal(obj.get("BMSC02ZLDY")));
|
data.setClusterVoltage(StringUtils.getBigDecimal(obj.get("BMSC02ZLDY")));
|
||||||
data.setClusterCurrent(StringUtils.getBigDecimal(obj.get("BMSC02ZLDL")));
|
data.setClusterCurrent(StringUtils.getBigDecimal(obj.get("BMSC02ZLDL")));
|
||||||
@ -459,6 +459,16 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
|||||||
data.setBatteryPackCurrent(StringUtils.getBigDecimal(stackObj.get("BMSD02DL")));
|
data.setBatteryPackCurrent(StringUtils.getBigDecimal(stackObj.get("BMSD02DL")));
|
||||||
data.setBatteryPackSoc(StringUtils.getBigDecimal(stackObj.get("BMSD02SOC")));
|
data.setBatteryPackSoc(StringUtils.getBigDecimal(stackObj.get("BMSD02SOC")));
|
||||||
data.setBatteryPackSoh(StringUtils.getBigDecimal(stackObj.get("BMSD02SOH")));
|
data.setBatteryPackSoh(StringUtils.getBigDecimal(stackObj.get("BMSD02SOH")));
|
||||||
|
data.setAvgCellTemp(StringUtils.getBigDecimal(stackObj.get("DTPJWD")));
|
||||||
|
data.setMaxCellVoltage(StringUtils.getBigDecimal(stackObj.get("DTZDDY")));
|
||||||
|
data.setMaxCellVoltageId(StringUtils.getString(stackObj.get("DTZDDYXH")));
|
||||||
|
data.setMinCellVoltage(StringUtils.getBigDecimal(stackObj.get("DTZXDY")));
|
||||||
|
data.setMinCellVoltageId(StringUtils.getString(stackObj.get("DTZXDYXH")));
|
||||||
|
data.setMaxCellTemp(StringUtils.getBigDecimal(stackObj.get("DTZGWD")));
|
||||||
|
data.setMaxCellTempId(StringUtils.getString(stackObj.get("DTZGWDXH")));
|
||||||
|
data.setMinCellTemp(StringUtils.getBigDecimal(stackObj.get("DTZDWD")));
|
||||||
|
data.setMinCellTempId(StringUtils.getString(stackObj.get("DTZDWDXH")));
|
||||||
|
|
||||||
emsBatteryClusterMapper.insertEmsBatteryCluster(data);
|
emsBatteryClusterMapper.insertEmsBatteryCluster(data);
|
||||||
redisCache.setCacheObject(RedisKeyConstants.CLUSTER + SITE_ID + "_" +deviceId, data);
|
redisCache.setCacheObject(RedisKeyConstants.CLUSTER + SITE_ID + "_" +deviceId, data);
|
||||||
|
|
||||||
@ -470,6 +480,8 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
|||||||
} else {
|
} else {
|
||||||
data.setStackDeviceId("1");
|
data.setStackDeviceId("1");
|
||||||
}
|
}
|
||||||
|
// 获取redis获取最新的BMSD数据
|
||||||
|
stackObj = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_BMSD +SITE_ID+"_"+stackDeviceId);
|
||||||
data.setDeviceId(deviceId);
|
data.setDeviceId(deviceId);
|
||||||
data.setClusterVoltage(StringUtils.getBigDecimal(obj.get("BMSC01ZLDY")));
|
data.setClusterVoltage(StringUtils.getBigDecimal(obj.get("BMSC01ZLDY")));
|
||||||
data.setClusterCurrent(StringUtils.getBigDecimal(obj.get("BMSC01ZLDL")));
|
data.setClusterCurrent(StringUtils.getBigDecimal(obj.get("BMSC01ZLDL")));
|
||||||
|
|||||||
@ -64,6 +64,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
|||||||
private EmsDailyChargeDataMapper emsDailyChargeDataMapper;
|
private EmsDailyChargeDataMapper emsDailyChargeDataMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private EmsDailyEnergyDataMapper emsDailyEnergyDataMapper;
|
private EmsDailyEnergyDataMapper emsDailyEnergyDataMapper;
|
||||||
|
@Autowired
|
||||||
|
private EmsEnergyPriceConfigMapper emsEnergyPriceConfigMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SiteMonitorHomeVo getSiteMonitorDataVo(String siteId) {
|
public SiteMonitorHomeVo getSiteMonitorDataVo(String siteId) {
|
||||||
@ -124,12 +126,36 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setRevenueInfo(SiteMonitorHomeVo siteMonitorHomeVo, String siteId) {
|
private void setRevenueInfo(SiteMonitorHomeVo siteMonitorHomeVo, String siteId) {
|
||||||
|
// 默认0
|
||||||
BigDecimal totalRevenue = BigDecimal.ZERO;
|
BigDecimal totalRevenue = BigDecimal.ZERO;
|
||||||
BigDecimal dayRevenue = BigDecimal.ZERO;
|
BigDecimal dayRevenue = BigDecimal.ZERO;
|
||||||
Map<String,BigDecimal> realTimeRevenue = emsDailyEnergyDataMapper.getRealTimeRevenue(siteId);
|
// 当日实时数据
|
||||||
if (realTimeRevenue != null) {
|
String today = DateUtils.getDate();
|
||||||
totalRevenue = realTimeRevenue.get("totalRevenue") == null ? BigDecimal.ZERO : realTimeRevenue.get("totalRevenue");
|
EmsDailyEnergyData todayData = emsDailyEnergyDataMapper.getDataByDate(siteId,today);
|
||||||
dayRevenue = realTimeRevenue.get("dayRevenue") == null ? BigDecimal.ZERO : realTimeRevenue.get("dayRevenue");
|
if (todayData == null) {
|
||||||
|
Map<String, BigDecimal> lastData = emsDailyEnergyDataMapper.getRealTimeRevenue(siteId);
|
||||||
|
if (lastData != null) {
|
||||||
|
totalRevenue = lastData.get("totalRevenue") == null ? BigDecimal.ZERO : lastData.get("totalRevenue");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
totalRevenue = todayData.getTotalRevenue() == null ? BigDecimal.ZERO : todayData.getTotalRevenue();
|
||||||
|
// 获取当月电价
|
||||||
|
int currentMonth = LocalDate.now().getMonthValue();
|
||||||
|
int currentYear = LocalDate.now().getYear();
|
||||||
|
EmsEnergyPriceConfig priceConfig = emsEnergyPriceConfigMapper.getConfigListByYearAndMonth(siteId, String.valueOf(currentYear), String.valueOf(currentMonth));
|
||||||
|
if (priceConfig != null) {
|
||||||
|
// 计算各个时段单独收益=(放电量-充电量)*电价,累加即当日实时收益
|
||||||
|
BigDecimal peakRevenue = todayData.getPeakDischargeDiff().subtract(todayData.getPeakChargeDiff())
|
||||||
|
.multiply(priceConfig.getPeak() == null ? BigDecimal.ZERO : priceConfig.getPeak());
|
||||||
|
BigDecimal highRevenue = todayData.getHighDischargeDiff().subtract(todayData.getHighChargeDiff())
|
||||||
|
.multiply(priceConfig.getHigh() == null ? BigDecimal.ZERO : priceConfig.getHigh());
|
||||||
|
BigDecimal flatRevenue = todayData.getFlatDischargeDiff().subtract(todayData.getFlatChargeDiff())
|
||||||
|
.multiply(priceConfig.getFlat() == null ? BigDecimal.ZERO : priceConfig.getFlat());
|
||||||
|
BigDecimal valleyRevenue = todayData.getValleyDischargeDiff().subtract(todayData.getValleyChargeDiff())
|
||||||
|
.multiply(priceConfig.getValley() == null ? BigDecimal.ZERO : priceConfig.getValley());
|
||||||
|
dayRevenue = dayRevenue.add(peakRevenue).add(highRevenue).add(flatRevenue).add(valleyRevenue)
|
||||||
|
.setScale(4, RoundingMode.HALF_UP);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
siteMonitorHomeVo.setTotalRevenue(totalRevenue);
|
siteMonitorHomeVo.setTotalRevenue(totalRevenue);
|
||||||
siteMonitorHomeVo.setDayRevenue(dayRevenue);
|
siteMonitorHomeVo.setDayRevenue(dayRevenue);
|
||||||
|
|||||||
Reference in New Issue
Block a user