[improvement][project]Optimize certain code structures.

This commit is contained in:
jerryjzhang
2024-09-21 18:13:31 +08:00
parent 4193b84e83
commit ae889bb0ae
8 changed files with 26 additions and 68 deletions

View File

@@ -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)) {