平台修改意见20251120-统计报表-收益报表
This commit is contained in:
42
ems-common/src/main/java/com/xzzn/common/enums/CostType.java
Normal file
42
ems-common/src/main/java/com/xzzn/common/enums/CostType.java
Normal file
@ -0,0 +1,42 @@
|
||||
package com.xzzn.common.enums;
|
||||
|
||||
/**
|
||||
* 电量类型
|
||||
*/
|
||||
public enum CostType
|
||||
{
|
||||
PEAK("peak", "尖"),
|
||||
HIGH("high", "峰"),
|
||||
FLAT("flat", "平"),
|
||||
VALLEY("valley", "谷"),
|
||||
;
|
||||
|
||||
private final String code;
|
||||
private final String info;
|
||||
|
||||
CostType(String code, String info)
|
||||
{
|
||||
this.code = code;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public String getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getInfo()
|
||||
{
|
||||
return info;
|
||||
}
|
||||
|
||||
public static CostType getEnumByCode(String code)
|
||||
{
|
||||
for (CostType costType : CostType.values()) {
|
||||
if (costType.code.equals(code)) {
|
||||
return costType;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
package com.xzzn.common.utils;
|
||||
|
||||
import com.xzzn.common.annotation.Log;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -9,11 +11,13 @@ import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* 时间工具类
|
||||
@ -22,6 +26,8 @@ import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
*/
|
||||
public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||
{
|
||||
private static final org.apache.commons.logging.Log log = LogFactory.getLog(DateUtils.class);
|
||||
|
||||
public static String YYYY = "yyyy";
|
||||
|
||||
public static String YYYY_MM = "yyyy-MM";
|
||||
@ -408,4 +414,49 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||
// 格式化并返回
|
||||
return yesterday.format(formatter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日期的开始时间
|
||||
* @param dateString 格式为yyyy-MM-dd的日期字符串
|
||||
* @return 日期的开始时间字符串
|
||||
*/
|
||||
public static String getDayBeginString(String dateString) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
try {
|
||||
// 解析日期字符串
|
||||
LocalDate date = LocalDate.parse(dateString, formatter);
|
||||
|
||||
// 创建时间段的开始时间 00:00:00
|
||||
LocalDateTime startTime = date.atTime(LocalTime.MIN);
|
||||
|
||||
return convertToString(startTime);
|
||||
} catch (DateTimeParseException e) {
|
||||
log.info("Error parsing date: " + e.getMessage());
|
||||
}
|
||||
|
||||
return dateString + " 00:00:00";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日期的结束时间
|
||||
* @param dateString 格式为yyyy-MM-dd的日期字符串
|
||||
* @return 日期的结束时间字符串
|
||||
*/
|
||||
public static String getDayEndString(String dateString) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
try {
|
||||
// 解析日期字符串
|
||||
LocalDate date = LocalDate.parse(dateString, formatter);
|
||||
|
||||
// 创建时间段的结束时间 23:59:59
|
||||
LocalDateTime endTime = date.atTime(LocalTime.MAX);
|
||||
|
||||
return convertToString(endTime);
|
||||
} catch (DateTimeParseException e) {
|
||||
log.info("Error parsing date: " + e.getMessage());
|
||||
}
|
||||
|
||||
return dateString + " 23:59:59";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user