Compare commits
No commits in common. "27dc183f8e88a8d49bdd0852ce96ae2c43738385" and "9c93dc1e109773dfdf193f07df78dc4c4b70e62e" have entirely different histories.
27dc183f8e
...
9c93dc1e10
|
@ -67,7 +67,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<version>2.5.6</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
|
|
@ -307,22 +307,4 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||||
return DateUtils.parseDate(format);
|
return DateUtils.parseDate(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当天零点零时零分 时间
|
|
||||||
* @return Date
|
|
||||||
*/
|
|
||||||
public static Date getZeroTimeOfToday() {
|
|
||||||
// 获取 Calendar 实例
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
// 将小时、分钟、秒和毫秒都设置为 0
|
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
||||||
calendar.set(Calendar.MINUTE, 0);
|
|
||||||
calendar.set(Calendar.SECOND, 0);
|
|
||||||
calendar.set(Calendar.MILLISECOND, 0);
|
|
||||||
// 返回 Date 对象
|
|
||||||
return calendar.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<version>2.5.6</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
|
|
@ -125,7 +125,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<version>2.5.6</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
|
|
@ -69,7 +69,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<version>2.5.6</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
|
|
@ -147,7 +147,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<version>2.5.6</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
|
|
@ -20,11 +20,8 @@ import java.math.BigDecimal;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.Proxy;
|
import java.net.Proxy;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static com.jxy.common.core.utils.DateUtils.getZeroTimeOfToday;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description 稳定币流通量
|
* @Description 稳定币流通量
|
||||||
|
@ -108,23 +105,20 @@ public class CSupplyTask {
|
||||||
JSONObject jsonObject = JSONObject.parseObject(s);
|
JSONObject jsonObject = JSONObject.parseObject(s);
|
||||||
//币种流通量字段
|
//币种流通量字段
|
||||||
JSONObject marketData = jsonObject.getJSONObject("market_data");
|
JSONObject marketData = jsonObject.getJSONObject("market_data");
|
||||||
//String dateString;
|
Date date;
|
||||||
//try {
|
try {
|
||||||
// //币种流通量最后更新时间
|
//币种流通量最后更新时间
|
||||||
// dateString = (String) marketData.get("last_updated");
|
date = (Date) marketData.get("last_updated");
|
||||||
//}catch (Exception e){
|
}catch (Exception e){
|
||||||
// return null;
|
return null;
|
||||||
//}
|
}
|
||||||
//Instant instant = Instant.parse(dateString);
|
|
||||||
//Date date = Date.from(instant);
|
|
||||||
Date zeroTimeOfToday = getZeroTimeOfToday();
|
|
||||||
double doubleValue = marketData.getDoubleValue("circulating_supply");
|
double doubleValue = marketData.getDoubleValue("circulating_supply");
|
||||||
List<CirculatingSupplyDataDto> circulatingSupplyDataDtos = new ArrayList<>();
|
List<CirculatingSupplyDataDto> circulatingSupplyDataDtos = new ArrayList<>();
|
||||||
CirculatingSupplyDataDto circulatingSupplyDataDto = new CirculatingSupplyDataDto();
|
CirculatingSupplyDataDto circulatingSupplyDataDto = new CirculatingSupplyDataDto();
|
||||||
circulatingSupplyDataDto.setValue(BigDecimal.valueOf(doubleValue));
|
circulatingSupplyDataDto.setValue(BigDecimal.valueOf(doubleValue));
|
||||||
circulatingSupplyDataDto.setDate(zeroTimeOfToday);
|
circulatingSupplyDataDto.setDate(date);
|
||||||
circulatingSupplyDataDtos.add(circulatingSupplyDataDto);
|
circulatingSupplyDataDtos.add(circulatingSupplyDataDto);
|
||||||
log.info("获取{}币流通量数据成功,最新时间{},流通量{}", coinId, zeroTimeOfToday, doubleValue);
|
log.info("获取{}币流通量数据成功,最新时间{},流通量{}", coinId, date, doubleValue);
|
||||||
return circulatingSupplyDataDtos;
|
return circulatingSupplyDataDtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,107 +0,0 @@
|
||||||
package com.jxy.marketall.utils;
|
|
||||||
|
|
||||||
import cn.hutool.http.HttpUtil;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.jxy.common.core.utils.DateUtils;
|
|
||||||
import com.jxy.marketall.dto.CirculatingSupplyDataDto;
|
|
||||||
import com.jxy.marketall.task.CSupplyTask;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpEntity;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.net.Proxy;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static com.jxy.common.core.utils.DateUtils.getZeroTimeOfToday;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description TODO
|
|
||||||
* @Date 2025/5/16 09:42
|
|
||||||
* @Author yyb
|
|
||||||
*/
|
|
||||||
public class TestCoingckoApi {
|
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(CSupplyTask.class);
|
|
||||||
public static void main(String[] args) {
|
|
||||||
//String id = "binance-usd";
|
|
||||||
//HttpHeaders headers = new HttpHeaders();
|
|
||||||
//headers.add("Content-Type","application/json");
|
|
||||||
//headers.add("x-cg-demo-api-key","CG-kNuNBTKBcQREBSQKqgj2uua4");
|
|
||||||
//headers.add("User-Agent", "Mozilla/5.0");
|
|
||||||
//HttpEntity<String> httpEntity = new HttpEntity<String>(null, headers);
|
|
||||||
//StringBuffer paramsURL = new StringBuffer(API_URL+id);
|
|
||||||
//String s = HttpUtil.get(paramsURL.toString());
|
|
||||||
//
|
|
||||||
//JSONObject jsonObject = JSONObject.parseObject(s);
|
|
||||||
////币种流通量字段
|
|
||||||
//JSONObject marketData = jsonObject.getJSONObject("market_data");
|
|
||||||
//Date date = null;
|
|
||||||
//try {
|
|
||||||
// //币种流通量最后更新时间
|
|
||||||
// date = (Date) marketData.get("last_updated");
|
|
||||||
//}catch (Exception e){
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
//double doubleValue = marketData.getDoubleValue("circulating_supply");
|
|
||||||
//List<CirculatingSupplyDataDto> circulatingSupplyDataDtos = new ArrayList<>();
|
|
||||||
//CirculatingSupplyDataDto circulatingSupplyDataDto = new CirculatingSupplyDataDto();
|
|
||||||
//circulatingSupplyDataDto.setValue(BigDecimal.valueOf(doubleValue));
|
|
||||||
//circulatingSupplyDataDto.setDate(date);
|
|
||||||
//circulatingSupplyDataDtos.add(circulatingSupplyDataDto);
|
|
||||||
//log.info("获取{}币流通量数据成功,最新时间{},流通量{}", id, date, doubleValue);
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 配置 HTTP 代理
|
|
||||||
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 7897));
|
|
||||||
|
|
||||||
// 创建 URL 对象
|
|
||||||
URL url = new URL("https://api.coingecko.com/api/v3/coins/binance-usd");
|
|
||||||
|
|
||||||
// 打开连接并设置代理
|
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxy);
|
|
||||||
|
|
||||||
// 设置请求方法
|
|
||||||
connection.setRequestMethod("GET");
|
|
||||||
|
|
||||||
// 获取响应码
|
|
||||||
int responseCode = connection.getResponseCode();
|
|
||||||
System.out.println("Response Code: " + responseCode);
|
|
||||||
|
|
||||||
// 读取响应内容
|
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
|
||||||
String line;
|
|
||||||
StringBuilder response = new StringBuilder();
|
|
||||||
while ((line = reader.readLine()) != null) {
|
|
||||||
response.append(line);
|
|
||||||
}
|
|
||||||
reader.close();
|
|
||||||
JSONObject jsonObject = JSONObject.parseObject(response.toString());
|
|
||||||
JSONObject marketData = jsonObject.getJSONObject("market_data");
|
|
||||||
double doubleValue = marketData.getDoubleValue("circulating_supply");
|
|
||||||
//String dateString = (String) marketData.get("last_updated");
|
|
||||||
// 输出响应内容
|
|
||||||
System.out.println("doubleValue: " + doubleValue + "date:"+getZeroTimeOfToday());
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String[] COINS = {"tether", "usd-coin", "binance-usd"};
|
|
||||||
private static final String[] SYMBOLS = {"USDT", "USDC", "BUSD"};
|
|
||||||
private static final String API_URL = "https://api.coingecko.com/api/v3/coins/";
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -131,7 +131,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<version>2.5.6</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
|
|
@ -95,7 +95,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<version>2.5.6</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
|
|
@ -95,7 +95,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<version>2.5.6</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
|
|
@ -96,7 +96,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<version>2.5.6</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
|
Loading…
Reference in New Issue