From ff2d1f5acdadc466d7e199028ef385ae8ca277e7 Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Thu, 17 Apr 2025 21:48:42 +0800
Subject: [PATCH] 1
---
src/main/java/project/web/api/RealtimeController.java | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/main/java/project/web/api/RealtimeController.java b/src/main/java/project/web/api/RealtimeController.java
index f976152..3dff440 100644
--- a/src/main/java/project/web/api/RealtimeController.java
+++ b/src/main/java/project/web/api/RealtimeController.java
@@ -2,11 +2,9 @@
import java.math.RoundingMode;
import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
@@ -69,8 +67,7 @@
realtime.setOrder(order);
list_clone.add(realtime);
}
- Collections.sort(list_clone);
- data = list_clone;
+ data = list_clone.stream().sorted(Comparator.comparing(Realtime::getClose).reversed()).collect(Collectors.toList());
}
resultObject.setData(this.revise(data));
return JSONObject.toJSONString(resultObject);
@@ -93,8 +90,15 @@
Map<String, Object> map = new HashMap<String, Object>();
map.put("symbol", realtime.getSymbol());
map.put("ts", realtime.getTs());
- map.put("current_time", realtime.getCurrent_time());
- map.put("name", realtime.getName());
+ long currentTime = 1744341503535L; // 确保 currentTime 是 long 类型
+ TimeZone timeZone = TimeZone.getTimeZone("America/New_York");
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ sdf.setTimeZone(timeZone);
+ Date date = new Date(currentTime);
+ String formattedTime = sdf.format(date);
+ map.put("current_time", formattedTime);
+ Item item1 = this.itemService.cacheBySymbol(realtime.getSymbol(), false);
+ map.put("name", item1.getName());
map.put("change_ratio", realtime.getChange_ratio());
Item item = this.itemService.cacheBySymbol(realtime.getSymbol(), true);
if (item.getDecimals() == null || item.getDecimals() < 0) {
--
Gitblit v1.9.3