mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 12:07:42 +00:00
[improvement][project]Optimize certain code structures.
This commit is contained in:
@@ -55,7 +55,7 @@ public class S2SqlDateHelper {
|
||||
private static String reformatDate(String dateStr, String format) {
|
||||
try {
|
||||
// Assuming the input date format is "yyyy-MM-dd"
|
||||
SimpleDateFormat inputFormat = new SimpleDateFormat(DateUtils.DATE_FORMAT);
|
||||
SimpleDateFormat inputFormat = new SimpleDateFormat(DateUtils.DEFAULT_DATE_FORMAT);
|
||||
Date date = inputFormat.parse(dateStr);
|
||||
SimpleDateFormat outputFormat = new SimpleDateFormat(format);
|
||||
return outputFormat.format(date);
|
||||
|
||||
@@ -155,10 +155,10 @@ public class SqlUtils {
|
||||
private Object getValue(Object value) {
|
||||
if (value instanceof LocalDate) {
|
||||
LocalDate localDate = (LocalDate) value;
|
||||
return localDate.format(DateTimeFormatter.ofPattern(DateUtils.DATE_FORMAT));
|
||||
return localDate.format(DateTimeFormatter.ofPattern(DateUtils.DEFAULT_DATE_FORMAT));
|
||||
} else if (value instanceof LocalDateTime) {
|
||||
LocalDateTime localDateTime = (LocalDateTime) value;
|
||||
return localDateTime.format(DateTimeFormatter.ofPattern(DateUtils.TIME_FORMAT));
|
||||
return localDateTime.format(DateTimeFormatter.ofPattern(DateUtils.DEFAULT_TIME_FORMAT));
|
||||
} else if (value instanceof Date) {
|
||||
Date date = (Date) value;
|
||||
return DateUtils.format(date);
|
||||
|
||||
@@ -60,6 +60,8 @@ public class DownloadServiceImpl implements DownloadService {
|
||||
|
||||
private static final long downloadSize = 10000;
|
||||
|
||||
private static final String dateFormat = "yyyyMMddHHmmss";
|
||||
|
||||
private MetricService metricService;
|
||||
|
||||
private DimensionService dimensionService;
|
||||
@@ -80,8 +82,7 @@ public class DownloadServiceImpl implements DownloadService {
|
||||
DownloadMetricReq downloadMetricReq, User user, HttpServletResponse response)
|
||||
throws Exception {
|
||||
String fileName =
|
||||
String.format(
|
||||
"%s_%s.xlsx", "supersonic", DateUtils.format(new Date(), DateUtils.FORMAT));
|
||||
String.format("%s_%s.xlsx", "supersonic", DateUtils.format(new Date(), dateFormat));
|
||||
File file = FileUtils.createTmpFile(fileName);
|
||||
try {
|
||||
QueryStructReq queryStructReq = metricService.convert(downloadMetricReq);
|
||||
@@ -108,8 +109,7 @@ public class DownloadServiceImpl implements DownloadService {
|
||||
BatchDownloadReq batchDownloadReq, User user, HttpServletResponse response)
|
||||
throws Exception {
|
||||
String fileName =
|
||||
String.format(
|
||||
"%s_%s.xlsx", "supersonic", DateUtils.format(new Date(), DateUtils.FORMAT));
|
||||
String.format("%s_%s.xlsx", "supersonic", DateUtils.format(new Date(), dateFormat));
|
||||
File file = FileUtils.createTmpFile(fileName);
|
||||
List<Long> metricIds = batchDownloadReq.getMetricIds();
|
||||
if (CollectionUtils.isEmpty(metricIds)) {
|
||||
|
||||
Reference in New Issue
Block a user