|
@@ -941,11 +941,18 @@ public class CoinServiceImpl implements CoinService {
|
|
|
} else if (params.getString("nameEn").equals("monitorCurrency")) {
|
|
} else if (params.getString("nameEn").equals("monitorCurrency")) {
|
|
|
List<CoinMonitorCurrency> monitorCurrencyList = coinMapper.findMonitorCurrencyList();
|
|
List<CoinMonitorCurrency> monitorCurrencyList = coinMapper.findMonitorCurrencyList();
|
|
|
|
|
|
|
|
- String requestUrl = mainUrl + params.getString("url");
|
|
|
|
|
- Connection.Response response = JsoupUtil.requestBody(requestUrl, JsoupUtil.HTTP_GET, InitRunner.proxy, null, null);
|
|
|
|
|
- result = JSONObject.parseObject(response.body()).getJSONArray("data");
|
|
|
|
|
|
|
+ Map<String, JSONArray> resultMulti = new ConcurrentHashMap<>();
|
|
|
|
|
+ Arrays.stream(params.getString("url").split(",")).parallel().forEach(e -> {
|
|
|
|
|
+ String requestUrl = mainUrl + e;
|
|
|
|
|
+ try {
|
|
|
|
|
+ Connection.Response response = JsoupUtil.requestBody(requestUrl, JsoupUtil.HTTP_GET, InitRunner.proxy, null, null);
|
|
|
|
|
+ resultMulti.put(e, JSONObject.parseObject(response.body()).getJSONArray("data"));
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ throw new RuntimeException(ex);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- result = renderMainSearch4MonitorCurrency(result, monitorCurrencyList, params.getInteger("changeUtcSort"));
|
|
|
|
|
|
|
+ result = renderMainSearch4MonitorCurrency(resultMulti, monitorCurrencyList, params.getInteger("changeUtcSort"));
|
|
|
} else if (params.getString("nameEn").equals("currentPlan")) {
|
|
} else if (params.getString("nameEn").equals("currentPlan")) {
|
|
|
Map<String, String> paramMap = new LinkedHashMap<>();
|
|
Map<String, String> paramMap = new LinkedHashMap<>();
|
|
|
paramMap.put("productType", "umcbl");
|
|
paramMap.put("productType", "umcbl");
|
|
@@ -1037,21 +1044,27 @@ public class CoinServiceImpl implements CoinService {
|
|
|
*
|
|
*
|
|
|
* @param monitorCurrencyList
|
|
* @param monitorCurrencyList
|
|
|
*/
|
|
*/
|
|
|
- private JSONArray renderMainSearch4MonitorCurrency(JSONArray result, List<CoinMonitorCurrency> monitorCurrencyList, Integer changeUtcSort) {
|
|
|
|
|
- Map<String, CoinMonitorCurrency> monitorCurrencyMap = monitorCurrencyList.stream().collect(Collectors.toMap(CoinMonitorCurrency::getSymbol, Function.identity(), (key1, key2) -> key1));
|
|
|
|
|
- Set<String> symbolSet = monitorCurrencyMap.keySet();
|
|
|
|
|
|
|
+ private JSONArray renderMainSearch4MonitorCurrency(Map<String, JSONArray> resultMulti, List<CoinMonitorCurrency> monitorCurrencyList, Integer changeUtcSort) {
|
|
|
|
|
+ Map<String, CoinMonitorCurrency> monitorCurrencyMap4Mix = monitorCurrencyList.stream().filter(e -> e.getType().equals("2")).collect(Collectors.toMap(CoinMonitorCurrency::getSymbol, Function.identity(), (key1, key2) -> key1));
|
|
|
|
|
+ Set<String> symbolSet4Mix = monitorCurrencyMap4Mix.keySet();
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, CoinMonitorCurrency> monitorCurrencyMap4Spot = monitorCurrencyList.stream().filter(e -> e.getType().contains("1")).collect(Collectors.toMap(CoinMonitorCurrency::getSymbol, Function.identity(), (key1, key2) -> key1));
|
|
|
|
|
+ Set<String> symbolSet4Spot = monitorCurrencyMap4Spot.keySet();
|
|
|
|
|
|
|
|
- JSONArray array = result.stream()
|
|
|
|
|
- .filter(iter -> symbolSet.contains(((JSONObject) iter).getString("symbol")))
|
|
|
|
|
|
|
+ JSONArray array4Spot = resultMulti.get("/api/spot/v1/market/tickers").stream()
|
|
|
|
|
+ .filter(iter -> symbolSet4Spot.contains(((JSONObject) iter).getString("symbol")))
|
|
|
|
|
+ .collect(Collectors.toCollection(JSONArray::new));
|
|
|
|
|
+ JSONArray array4Mix = resultMulti.get("/api/mix/v1/market/tickers?productType=umcbl").stream()
|
|
|
|
|
+ .filter(iter -> symbolSet4Mix.contains(((JSONObject) iter).getString("symbol")))
|
|
|
.collect(Collectors.toCollection(JSONArray::new));
|
|
.collect(Collectors.toCollection(JSONArray::new));
|
|
|
|
|
|
|
|
- forkJoinPool.submit(() -> array.parallelStream().forEach(e -> {
|
|
|
|
|
|
|
+ forkJoinPool.submit(() -> array4Spot.parallelStream().forEach(e -> {
|
|
|
JSONObject jsonObject = (JSONObject) e;
|
|
JSONObject jsonObject = (JSONObject) e;
|
|
|
jsonObject.put("changeUtc", jsonObject.getBigDecimal("changeUtc").multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP));
|
|
jsonObject.put("changeUtc", jsonObject.getBigDecimal("changeUtc").multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP));
|
|
|
jsonObject.put("change", jsonObject.getBigDecimal("change").multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP));
|
|
jsonObject.put("change", jsonObject.getBigDecimal("change").multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP));
|
|
|
jsonObject.put("ts", DateUtils.longToString(jsonObject.getLong("ts")));
|
|
jsonObject.put("ts", DateUtils.longToString(jsonObject.getLong("ts")));
|
|
|
|
|
|
|
|
- jsonObject.put("category", monitorCurrencyMap.get(jsonObject.getString("symbol")).getCategory());
|
|
|
|
|
|
|
+ jsonObject.put("category", monitorCurrencyMap4Spot.get(jsonObject.getString("symbol")).getCategory());
|
|
|
|
|
|
|
|
// UTC0时涨跌幅
|
|
// UTC0时涨跌幅
|
|
|
if (jsonObject.getBigDecimal("changeUtc").compareTo(BigDecimal.ZERO) < 0) {
|
|
if (jsonObject.getBigDecimal("changeUtc").compareTo(BigDecimal.ZERO) < 0) {
|
|
@@ -1067,7 +1080,11 @@ public class CoinServiceImpl implements CoinService {
|
|
|
}
|
|
}
|
|
|
// 币对名称
|
|
// 币对名称
|
|
|
String symbol = jsonObject.getString("symbol").replace("USDT", "");
|
|
String symbol = jsonObject.getString("symbol").replace("USDT", "");
|
|
|
- jsonObject.put("symbol", "<strong style=\"background-color:#F1B90d;\"><font color=\"#242A30\">" + symbol + "</font></strong>USDT");
|
|
|
|
|
|
|
+ if ("BTC".equals(symbol) || "ETH".equals(symbol)) {
|
|
|
|
|
+ jsonObject.put("symbol", "<strong style=\"background-color:#FF6EB4;\"><font color=\"#242A30\">" + symbol + "</font></strong>USDT");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ jsonObject.put("symbol", "<strong style=\"background-color:#F1B90d;\"><font color=\"#242A30\">" + symbol + "</font></strong>USDT");
|
|
|
|
|
+ }
|
|
|
// 标记价格
|
|
// 标记价格
|
|
|
jsonObject.put("closeStyle", " style=\"color:#252B31;background-color:#C4ADE9;font-weight:bold;\"");
|
|
jsonObject.put("closeStyle", " style=\"color:#252B31;background-color:#C4ADE9;font-weight:bold;\"");
|
|
|
// 基础币量 计价币量 usdt币量
|
|
// 基础币量 计价币量 usdt币量
|
|
@@ -1076,11 +1093,46 @@ public class CoinServiceImpl implements CoinService {
|
|
|
jsonObject.put("usdtVol", readableFileSize(jsonObject.getDouble("usdtVol")));
|
|
jsonObject.put("usdtVol", readableFileSize(jsonObject.getDouble("usdtVol")));
|
|
|
})).join();
|
|
})).join();
|
|
|
|
|
|
|
|
|
|
+ forkJoinPool.submit(() -> array4Mix.parallelStream().forEach(e -> {
|
|
|
|
|
+ JSONObject jsonObject = (JSONObject) e;
|
|
|
|
|
+ jsonObject.put("changeUtc", jsonObject.getBigDecimal("chgUtc").multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP));
|
|
|
|
|
+ jsonObject.put("change", jsonObject.getBigDecimal("priceChangePercent").multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP));
|
|
|
|
|
+ jsonObject.put("ts", DateUtils.longToString(jsonObject.getLong("timestamp")));
|
|
|
|
|
+
|
|
|
|
|
+ jsonObject.put("category", monitorCurrencyMap4Mix.get(jsonObject.getString("symbol")).getCategory());
|
|
|
|
|
+
|
|
|
|
|
+ // UTC0时涨跌幅
|
|
|
|
|
+ if (jsonObject.getBigDecimal("changeUtc").compareTo(BigDecimal.ZERO) < 0) {
|
|
|
|
|
+ jsonObject.put("changeUtcStyle", " style=\"color:#FFFFFF;background-color:#F1493F;\"");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ jsonObject.put("changeUtcStyle", " style=\"color:#FFFFFF;background-color:#1DA2B4;\"");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 24小时涨跌幅
|
|
|
|
|
+ if (jsonObject.getBigDecimal("change").compareTo(BigDecimal.ZERO) < 0) {
|
|
|
|
|
+ jsonObject.put("changeStyle", " style=\"color:#FFFFFF;background-color:#F1493F;\"");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ jsonObject.put("changeStyle", " style=\"color:#FFFFFF;background-color:#1DA2B4;\"");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 币对名称
|
|
|
|
|
+ String symbol = jsonObject.getString("symbol").replace("USDT_UMCBL", "");
|
|
|
|
|
+ jsonObject.put("symbol", "<strong style=\"background-color:#F1B90d;\"><font color=\"#242A30\">" + symbol + "</font></strong>USDT_UMCBL");
|
|
|
|
|
+ // 标记价格
|
|
|
|
|
+ jsonObject.put("close",jsonObject.getString("last"));
|
|
|
|
|
+ jsonObject.put("closeStyle", " style=\"color:#252B31;background-color:#C4ADE9;font-weight:bold;\"");
|
|
|
|
|
+ // 基础币量 计价币量 usdt币量
|
|
|
|
|
+ jsonObject.put("baseVol", readableFileSize(jsonObject.getDouble("baseVolume")));
|
|
|
|
|
+ jsonObject.put("quoteVol", readableFileSize(jsonObject.getDouble("quoteVolume")));
|
|
|
|
|
+ jsonObject.put("usdtVol", readableFileSize(jsonObject.getDouble("quoteVolume")));
|
|
|
|
|
+ // 其他字段兼容
|
|
|
|
|
+ jsonObject.put("openUtc0",jsonObject.getString("openUtc"));
|
|
|
|
|
+ })).join();
|
|
|
|
|
+
|
|
|
|
|
+ array4Spot.addAll(array4Mix);
|
|
|
if (changeUtcSort != 0) {
|
|
if (changeUtcSort != 0) {
|
|
|
- Collections.sort(array, (o1, o2) -> changeUtcSort * (((JSONObject) o1).getBigDecimal("changeUtc").compareTo(((JSONObject) o2).getBigDecimal("changeUtc"))));
|
|
|
|
|
|
|
+ Collections.sort(array4Spot, (o1, o2) -> changeUtcSort * (((JSONObject) o1).getBigDecimal("changeUtc").compareTo(((JSONObject) o2).getBigDecimal("changeUtc"))));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return array;
|
|
|
|
|
|
|
+ return array4Spot;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|