0918优化-电表报表-尖峰平谷日差值显示

This commit is contained in:
2025-10-10 16:10:37 +08:00
parent 636a2ab73b
commit b861ad7593
14 changed files with 766 additions and 34 deletions

View File

@ -72,4 +72,10 @@ 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_";
}

View File

@ -218,7 +218,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
}
/**
* 获取昨天的日期格式为yyyy-MM-dd
* 获取昨天的日期格式为yyyy-MM-dd 23:59:59
* @return 昨天的日期字符串
*/
public static String getYesterdayDate() {
@ -226,8 +226,10 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
LocalDate today = LocalDate.now();
// 减去一天得到昨天
LocalDate yesterday = today.minusDays(1);
// 将日期转换为LocalDateTime并设置时间为23:59:59
LocalDateTime yesterdayEndTime = yesterday.atTime(23, 59, 59);
// 定义日期格式化器
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(YYYYMMDD);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(YYYY_MM_DD_HH_MM_SS);
// 格式化并返回
return yesterday.format(formatter);
}
@ -372,4 +374,23 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
.toLocalDateTime();
return dateTime;
}
// 时间戳转时间
public static Date convertUpdateTime(Long updateTime) {
if (updateTime == null) {
return null;
}
// 兼容10位秒级和13位毫秒级
int length = String.valueOf(updateTime).length();
if (length == 10) { // 10位秒级 -> 转换为毫秒级
updateTime *= 1000;
} else if (length != 13) { // 既不是10位也不是13位视为非法
System.err.println("时间戳格式错误必须是10位(秒)或13位(毫秒)");
return null;
}
// 3. 转换为Date
return new Date(updateTime);
}
}