Commit 1e89de7a authored by alex yao's avatar alex yao

style

parent e9703698
package cn.com.poc.data_analyze.constants;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
/**
* 应用数据分析-时间范围枚举
*
......@@ -7,9 +9,9 @@ package cn.com.poc.data_analyze.constants;
* @date 2024/12/11
*/
public enum DataAnalyzeTimeRangeEnum {
CUSTOMIZE("customize"),
WEEK("week"),
MONTH("month"),
customize("customize"),
week("week"),
month("month"),
;
private String type;
......@@ -25,4 +27,14 @@ public enum DataAnalyzeTimeRangeEnum {
public String getType() {
return type;
}
public static DataAnalyzeTimeRangeEnum getByType(String type) {
for (DataAnalyzeTimeRangeEnum item : values()){
if (item.getType().equals(type)) {
return item;
}
}
throw new I18nMessageException("data-analyze/not.support.rang.type");
}
}
package cn.com.poc.expose.aggregate.impl;
import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService;
import cn.com.poc.common.utils.Assert;
import cn.com.poc.common.utils.BlContext;
import cn.com.poc.common.utils.DateUtils;
import cn.com.poc.data_analyze.constants.DataAnalyzeTimeDimensionEnum;
......@@ -116,21 +117,32 @@ public class AgentDataAnalyzeServiceImpl implements AgentDataAnalyzeService {
String rangType = timeRange.getRangType();
String startTime = "";
String endTime = "";
if (DataAnalyzeTimeRangeEnum.WEEK.getType().equals(rangType)) {
Date endDate = DateUtils.getTodayEnd();
Date startDate = DateUtils.getDayStartTime(DateUtils.addDays(endDate, -6));
startTime = DateUtils.formatDate(startDate, DateUtils.yyyy_MM_dd);
endTime = DateUtils.formatDate(endDate, DateUtils.yyyy_MM_dd_HH_mm_ss);
} else if (DataAnalyzeTimeRangeEnum.MONTH.getType().equals(rangType)) {
Date endDate = DateUtils.getTodayEnd();
Date startDate = DateUtils.getDayStartTime(DateUtils.addDays(endDate, -29));
startTime = DateUtils.formatDate(startDate, DateUtils.yyyy_MM_dd);
endTime = DateUtils.formatDate(endDate, DateUtils.yyyy_MM_dd_HH_mm_ss);
} else if (DataAnalyzeTimeRangeEnum.CUSTOMIZE.getType().equals(rangType)) {
startTime = timeRange.getStartTime();
Date endDate = DateUtils.getDayEnd(DateUtils.stringToDateShort(timeRange.getEndTime()));
endTime = DateUtils.formatDate(endDate, DateUtils.yyyy_MM_dd_HH_mm_ss);
Date endDate;
Date startDate;
switch (DataAnalyzeTimeRangeEnum.getByType(rangType)) {
case week:
endDate = DateUtils.getTodayEnd();
startDate = DateUtils.getDayStartTime(DateUtils.addDays(endDate, -6));
startTime = DateUtils.formatDate(startDate, DateUtils.yyyy_MM_dd);
endTime = DateUtils.formatDate(endDate, DateUtils.yyyy_MM_dd_HH_mm_ss);
break;
case month:
endDate = DateUtils.getTodayEnd();
startDate = DateUtils.getDayStartTime(DateUtils.addMonth(endDate, -1));
startTime = DateUtils.formatDate(startDate, DateUtils.yyyy_MM_dd);
endTime = DateUtils.formatDate(endDate, DateUtils.yyyy_MM_dd_HH_mm_ss);
break;
case customize:
Assert.notBlank(timeRange.getStartTime());
Assert.notBlank(timeRange.getEndTime());
startTime = timeRange.getStartTime();
endDate = DateUtils.getDayEnd(DateUtils.stringToDateShort(timeRange.getEndTime()));
endTime = DateUtils.formatDate(endDate, DateUtils.yyyy_MM_dd_HH_mm_ss);
break;
default:
throw new I18nMessageException("data-analyze/not.support.rang.type");
}
AgentDataTrendQueryCondition agentDataTrendQueryCondition = new AgentDataTrendQueryCondition();
agentDataTrendQueryCondition.setStartDate(startTime);
agentDataTrendQueryCondition.setEndDate(endTime);
......
not.support.rang.type=Unsupported time range type
\ No newline at end of file
not.support.rang.type=\u4E0D\u652F\u6301\u7684\u65F6\u95F4\u8303\u56F4\u7C7B\u578B
\ No newline at end of file
not.support.rang.type=\u4E0D\u652F\u6301\u8A72\u6642\u9593\u985E\u578B
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment