dev #2

Merged
dashixiong merged 349 commits from dev into main 2026-02-11 01:55:46 +00:00
260 changed files with 30988 additions and 1038 deletions
Showing only changes of commit eed6f839f6 - Show all commits

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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;
}