package com.gear.swx.task;
|
|
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSONArray;
|
import com.alibaba.fastjson2.JSONObject;
|
import com.gear.swx.vo.SyncKValueFromLdVo;
|
import org.apache.logging.log4j.util.Strings;
|
|
import java.io.BufferedReader;
|
import java.io.File;
|
import java.io.InputStreamReader;
|
import java.math.BigDecimal;
|
import java.net.HttpURLConnection;
|
import java.net.URL;
|
import java.sql.Connection;
|
import java.util.*;
|
|
public class test {
|
// public static void main(String[] args) throws InterruptedException {
|
// File file = new File("1.txt");
|
// List<Map<String,Object>> result= test.getInfo();
|
// for(Map<String,Object> item : result){
|
// String print = "{";
|
// for(Map.Entry<String,Object> res:item.entrySet()){
|
// String a=res.getKey();//获取当前map的键
|
// Object b = res.getValue();
|
// print = print + "\""+a+":\""+b+"\",";
|
// }
|
//
|
// System.out.print("}");
|
// System.out.println();
|
// }
|
// }
|
// public static List<Map<String,Object>> getInfo() throws InterruptedException {
|
// List<Map<String,Object>> result = new ArrayList<>();
|
// for (int i = 0;i < 10 ;i++){
|
// Thread.sleep(2000);
|
// List<Map<String,Object>> currentReuslt = new ArrayList<>();
|
// try {
|
// String urlStr = "https://data.mifengcha.com/api/v3/symbols?api_key=OQIYNHXPRLEA3GSP9JCVBMUHI614XOMXPJMROQGS&size=100&details=0&page="+i;
|
// URL url = new URL(urlStr);
|
// String ids = "";
|
// // 创建 HTTP 连接
|
// HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
// connection.setRequestMethod("GET");
|
//
|
// // 获取输入流
|
// BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
// // 读取 CSV 数据
|
// String line;
|
// StringBuilder response = new StringBuilder();
|
// while ((line = reader.readLine()) != null) { // 打印每一行数据
|
// response.append(line);
|
// }
|
// String reponseStr = response.toString();
|
// JSONArray jsonArray = JSON.parseArray(reponseStr);
|
// for(int j = 0; j < jsonArray.size(); j++){
|
// JSONObject jsonObject = jsonArray.getJSONObject(j);
|
// Map<String,Object> currentMap = new HashMap<>();
|
// currentMap.put("code",jsonObject.get("slug"));
|
// currentMap.put("name",jsonObject.get("symbol"));
|
// currentMap.put("logo",jsonObject.get("logoUrl"));
|
// ids = ids + "," + jsonObject.getString("slug");
|
// currentReuslt.add(currentMap);
|
// }
|
// System.out.println("最后结果:"+currentReuslt);
|
// System.out.println("总行数:"+currentReuslt.size());
|
// List<Map<String,Object>> res = getResultItem(currentReuslt,ids.substring(1,ids.length()));
|
// System.out.println("返回长度:"+res.size());
|
// result.addAll(res);
|
// // 关闭连接
|
// reader.close();
|
// connection.disconnect();
|
//
|
//
|
// }catch (Exception e){
|
// System.out.println(e.getMessage());
|
// }
|
// }
|
// return result;
|
// }
|
//
|
// public static List<Map<String,Object>> getResultItem(List<Map<String,Object>> oldItem,String ids){
|
// try {
|
// Thread.sleep(2000);
|
// String getNameUrl = "https://data.mifengcha.com/api/v3/tickers?api_key=OQIYNHXPRLEA3GSP9JCVBMUHI614XOMXPJMROQGS&market=Binance¤cy=USDT&size=100&slug="+ids;
|
// URL url = new URL(getNameUrl);
|
//
|
// // 创建 HTTP 连接
|
// HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
// connection.setRequestMethod("GET");
|
//
|
// // 获取输入流
|
// BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
// // 读取 CSV 数据
|
// String line1;
|
// StringBuilder response = new StringBuilder();
|
// while ((line1 = reader.readLine()) != null) { // 打印每一行数据
|
// response.append(line1);
|
// }
|
// String reponseStr = response.toString();
|
// System.out.println(reponseStr);
|
// JSONArray jsonArray = JSON.parseArray(reponseStr);
|
// if (jsonArray != null && jsonArray.size() > 0){
|
// List<Map<String,Object>> list = new ArrayList<>();
|
// for(int i = 0; i < jsonArray.size();i++){
|
// JSONObject object = jsonArray.getJSONObject(i);
|
// Map<String,Object> resultItem = setKCode(object,oldItem);
|
// if (resultItem != null){
|
// list.add(resultItem);
|
// }
|
// }
|
// return list;
|
// }
|
//
|
// }catch (Exception e){
|
// System.out.println(e.getMessage());
|
// }
|
// return null;
|
// }
|
//
|
//
|
// public static Map<String,Object> setKCode(JSONObject jsonObject,List<Map<String,Object>> list){
|
// for (Map<String,Object> item : list){
|
// if (item.get("code").equals(jsonObject.getString("bs"))){
|
// item.put("kCode",jsonObject.get("m"));
|
// return item;
|
// }
|
// }
|
// return null;
|
// }
|
}
|