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

style

parent e9703698
package cn.com.poc.data_analyze.constants; 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; ...@@ -7,9 +9,9 @@ package cn.com.poc.data_analyze.constants;
* @date 2024/12/11 * @date 2024/12/11
*/ */
public enum DataAnalyzeTimeRangeEnum { public enum DataAnalyzeTimeRangeEnum {
CUSTOMIZE("customize"), customize("customize"),
WEEK("week"), week("week"),
MONTH("month"), month("month"),
; ;
private String type; private String type;
...@@ -25,4 +27,14 @@ public enum DataAnalyzeTimeRangeEnum { ...@@ -25,4 +27,14 @@ public enum DataAnalyzeTimeRangeEnum {
public String getType() { public String getType() {
return type; 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; package cn.com.poc.expose.aggregate.impl;
import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService; 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.BlContext;
import cn.com.poc.common.utils.DateUtils; import cn.com.poc.common.utils.DateUtils;
import cn.com.poc.data_analyze.constants.DataAnalyzeTimeDimensionEnum; import cn.com.poc.data_analyze.constants.DataAnalyzeTimeDimensionEnum;
...@@ -116,21 +117,32 @@ public class AgentDataAnalyzeServiceImpl implements AgentDataAnalyzeService { ...@@ -116,21 +117,32 @@ public class AgentDataAnalyzeServiceImpl implements AgentDataAnalyzeService {
String rangType = timeRange.getRangType(); String rangType = timeRange.getRangType();
String startTime = ""; String startTime = "";
String endTime = ""; String endTime = "";
if (DataAnalyzeTimeRangeEnum.WEEK.getType().equals(rangType)) { Date endDate;
Date endDate = DateUtils.getTodayEnd(); Date startDate;
Date startDate = DateUtils.getDayStartTime(DateUtils.addDays(endDate, -6)); switch (DataAnalyzeTimeRangeEnum.getByType(rangType)) {
case week:
endDate = DateUtils.getTodayEnd();
startDate = DateUtils.getDayStartTime(DateUtils.addDays(endDate, -6));
startTime = DateUtils.formatDate(startDate, DateUtils.yyyy_MM_dd); startTime = DateUtils.formatDate(startDate, DateUtils.yyyy_MM_dd);
endTime = DateUtils.formatDate(endDate, DateUtils.yyyy_MM_dd_HH_mm_ss); endTime = DateUtils.formatDate(endDate, DateUtils.yyyy_MM_dd_HH_mm_ss);
} else if (DataAnalyzeTimeRangeEnum.MONTH.getType().equals(rangType)) { break;
Date endDate = DateUtils.getTodayEnd(); case month:
Date startDate = DateUtils.getDayStartTime(DateUtils.addDays(endDate, -29)); endDate = DateUtils.getTodayEnd();
startDate = DateUtils.getDayStartTime(DateUtils.addMonth(endDate, -1));
startTime = DateUtils.formatDate(startDate, DateUtils.yyyy_MM_dd); startTime = DateUtils.formatDate(startDate, DateUtils.yyyy_MM_dd);
endTime = DateUtils.formatDate(endDate, DateUtils.yyyy_MM_dd_HH_mm_ss); endTime = DateUtils.formatDate(endDate, DateUtils.yyyy_MM_dd_HH_mm_ss);
} else if (DataAnalyzeTimeRangeEnum.CUSTOMIZE.getType().equals(rangType)) { break;
case customize:
Assert.notBlank(timeRange.getStartTime());
Assert.notBlank(timeRange.getEndTime());
startTime = timeRange.getStartTime(); startTime = timeRange.getStartTime();
Date endDate = DateUtils.getDayEnd(DateUtils.stringToDateShort(timeRange.getEndTime())); endDate = DateUtils.getDayEnd(DateUtils.stringToDateShort(timeRange.getEndTime()));
endTime = DateUtils.formatDate(endDate, DateUtils.yyyy_MM_dd_HH_mm_ss); 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 agentDataTrendQueryCondition = new AgentDataTrendQueryCondition();
agentDataTrendQueryCondition.setStartDate(startTime); agentDataTrendQueryCondition.setStartDate(startTime);
agentDataTrendQueryCondition.setEndDate(endTime); 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