From 414555cfbb72c02ebc07ca164a7ff0d0f592de13 Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Mon, 30 Jun 2025 18:52:33 +0800
Subject: [PATCH] 地址

---
 src/main/java/project/web/api/RealtimeController.java |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/main/java/project/web/api/RealtimeController.java b/src/main/java/project/web/api/RealtimeController.java
index 1eb5cc2..042ab1d 100644
--- a/src/main/java/project/web/api/RealtimeController.java
+++ b/src/main/java/project/web/api/RealtimeController.java
@@ -2,6 +2,7 @@
 
 import java.math.RoundingMode;
 import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -66,8 +67,17 @@
 					realtime.setOrder(order);
 					list_clone.add(realtime);
 				}
-				data = list_clone.stream().sorted(Comparator.comparing(Realtime::getClose).reversed()).collect(Collectors.toList());
+//				data = list_clone.stream().sorted(Comparator.comparing(Realtime::getClose).reversed()).collect(Collectors.toList());
+				// 自定义比较器,确保 BTC 排在第一,ETH 排在第二
+
 			}
+			data.sort((r1, r2) -> {
+				if (r1.getSymbol().equals("btc")) return -1;  // BTC 应该排在第一
+				if (r2.getSymbol().equals("btc")) return 1;
+				if (r1.getSymbol().equals("eth")) return -1;  // ETH 应该排在第二
+				if (r2.getSymbol().equals("eth")) return 1;
+				return 0;  // 如果都不是 BTC 或 ETH,则保持原始顺序
+			});
 			resultObject.setData(this.revise(data));
 			return JSONObject.toJSONString(resultObject);
 		} catch (BusinessException e) {
@@ -89,8 +99,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