dev #2
@ -393,4 +393,19 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||
// 3. 转换为Date
|
||||
return new Date(updateTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取昨天的日期,格式为yyyy-MM-dd
|
||||
* @return 昨天的日期字符串
|
||||
*/
|
||||
public static String getYesterdayDayString() {
|
||||
// 获取今天的日期
|
||||
LocalDate today = LocalDate.now();
|
||||
// 减去一天得到昨天
|
||||
LocalDate yesterday = today.minusDays(1);
|
||||
// 定义日期格式化器
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(YYYYMMDD);
|
||||
// 格式化并返回
|
||||
return yesterday.format(formatter);
|
||||
}
|
||||
}
|
||||
|
||||
@ -954,13 +954,13 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
String yestDate = DateUtils.getYesterdayDate();
|
||||
String yestDateRedisKey = RedisKeyConstants.AMMETER + SITE_ID + "_" + deviceId + "_" + yestDate;
|
||||
EmsAmmeterData yestData = redisCache.getCacheObject(yestDateRedisKey);
|
||||
if (yestDate == null) {
|
||||
if (yestData == null) {
|
||||
// redis没有这查电表总数据表取截止到昨日最新第一条数据
|
||||
yestData = emsAmmeterDataMapper.getYestLatestDate(SITE_ID,deviceId,yestDate);
|
||||
// 数据存redis-有效期1天
|
||||
redisCache.setCacheObject(yestDateRedisKey, yestDate , Constants.DATE_VALID_TIME, TimeUnit.DAYS);
|
||||
redisCache.setCacheObject(yestDateRedisKey, yestData , Constants.DATE_VALID_TIME, TimeUnit.DAYS);
|
||||
}
|
||||
if (yestDate != null) {
|
||||
if (yestData != null) {
|
||||
// 今日总数据-昨日总数据=今日充放电
|
||||
BigDecimal yestTotalDisChargeDate = yestData.getCurrentReverseActiveTotal();
|
||||
BigDecimal yestTotalChargeDate = yestData.getCurrentForwardActiveTotal();
|
||||
@ -1046,14 +1046,15 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
|
||||
private BigDecimal getYestLastData(String siteId) {
|
||||
// dds存的是累计到昨日总收益
|
||||
String redisKey = RedisKeyConstants.DDS_TOTAL_REVENUE + siteId;
|
||||
String yestDate = DateUtils.getYesterdayDayString();
|
||||
String redisKey = RedisKeyConstants.DDS_TOTAL_REVENUE + siteId + "_" + yestDate;
|
||||
BigDecimal yestLastTotalRevenue = redisCache.getCacheObject(redisKey);
|
||||
if (yestLastTotalRevenue == null) {
|
||||
yestLastTotalRevenue = emsDailyEnergyDataMapper.getLastTotalRevenue(siteId);
|
||||
if (yestLastTotalRevenue == null) {
|
||||
yestLastTotalRevenue = BigDecimal.ZERO;
|
||||
}
|
||||
redisCache.setCacheObject(redisKey, yestLastTotalRevenue);
|
||||
redisCache.setCacheObject(redisKey, yestLastTotalRevenue, 1 , TimeUnit.DAYS);
|
||||
}
|
||||
return yestLastTotalRevenue;
|
||||
}
|
||||
|
||||
@ -910,7 +910,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
|
||||
private Map<String, BigDecimal> getLastData(String siteId) {
|
||||
// dds存的是累计到昨日总收益
|
||||
String redisKey = RedisKeyConstants.FXX_REALTIME_REVENUE + siteId;
|
||||
String yestDate = DateUtils.getYesterdayDayString();
|
||||
String redisKey = RedisKeyConstants.FXX_REALTIME_REVENUE + siteId + "_" + yestDate;
|
||||
Map<String, BigDecimal> realTimeRevenue = redisCache.getCacheObject(redisKey);
|
||||
if (realTimeRevenue == null) {
|
||||
realTimeRevenue = emsDailyEnergyDataMapper.getRealTimeRevenue(siteId);
|
||||
@ -919,7 +920,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
realTimeRevenue.put("totalRevenue", BigDecimal.ZERO);
|
||||
realTimeRevenue.put("dayRevenue", BigDecimal.ZERO);
|
||||
}
|
||||
redisCache.setCacheObject(redisKey, realTimeRevenue);
|
||||
redisCache.setCacheObject(redisKey, realTimeRevenue, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return realTimeRevenue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user