Compare commits
No commits in common. "127d21b59eb8255756f34330e648bda53ddd80d6" and "6d7061585ad1ffff497e66d54f8643d8a5791e85" have entirely different histories.
127d21b59e
...
6d7061585a
2
pom.xml
2
pom.xml
|
|
@ -345,7 +345,7 @@
|
||||||
<username>sa</username>
|
<username>sa</username>
|
||||||
<password></password>
|
<password></password>
|
||||||
<driver>org.mariadb.jdbc.Driver</driver>
|
<driver>org.mariadb.jdbc.Driver</driver>
|
||||||
<url>jdbc:mariadb://119.45.61.64:3306/finance</url>
|
<url>jdbc:mariadb://173.249.203.214:3306/finance</url>
|
||||||
<username>root</username>
|
<username>root</username>
|
||||||
<password>open123</password>
|
<password>open123</password>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -284,7 +284,7 @@ public class ContractInfoController {
|
||||||
|
|
||||||
String symbol = StringUtils.substringBefore(contractInfo.getTs_code(), ".");
|
String symbol = StringUtils.substringBefore(contractInfo.getTs_code(), ".");
|
||||||
String url =
|
String url =
|
||||||
"http://119.45.61.64:8080/api/public/futures_zh_spot?"
|
"http://173.249.203.214:8080/api/public/futures_zh_spot?"
|
||||||
+ "symbol=" + symbol;
|
+ "symbol=" + symbol;
|
||||||
System.out.println(url);
|
System.out.println(url);
|
||||||
InputStream stean = Request.Get(url)
|
InputStream stean = Request.Get(url)
|
||||||
|
|
@ -341,7 +341,7 @@ public class ContractInfoController {
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// String url =
|
// String url =
|
||||||
// "http://119.45.61.64:8080/api/public/futures_zh_spot?"
|
// "http://173.249.203.214:8080/api/public/futures_zh_spot?"
|
||||||
// + "symbol=" + symbols;
|
// + "symbol=" + symbols;
|
||||||
// System.out.println(url);
|
// System.out.println(url);
|
||||||
// InputStream stean = Request.Get(url)
|
// InputStream stean = Request.Get(url)
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ public class ContractInfoMinute {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String url =
|
String url =
|
||||||
"http://119.45.61.64:8080/api/public/futures_zh_minute_sina?"
|
"http://173.249.203.214:8080/api/public/futures_zh_minute_sina?"
|
||||||
+ "symbol=" + symbol
|
+ "symbol=" + symbol
|
||||||
+ "&period=" + parm.getPeriod();
|
+ "&period=" + parm.getPeriod();
|
||||||
System.out.println(url);
|
System.out.println(url);
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,7 @@ public class ContractInfoScribeController {
|
||||||
bean.setScribe_number(0);
|
bean.setScribe_number(0);
|
||||||
bean.setScribe_update_time(LocalDateTime.now());
|
bean.setScribe_update_time(LocalDateTime.now());
|
||||||
contractInfoStatusMapper.insertSelective(bean);
|
contractInfoStatusMapper.insertSelective(bean);
|
||||||
}else {
|
}
|
||||||
ContractInfoStatus bean = opStatu.get();
|
ContractInfoStatus bean = opStatu.get();
|
||||||
bean.setScribe_status(0);
|
bean.setScribe_status(0);
|
||||||
bean.setScribe_update_time(LocalDateTime.now());
|
bean.setScribe_update_time(LocalDateTime.now());
|
||||||
|
|
@ -230,8 +230,6 @@ public class ContractInfoScribeController {
|
||||||
contractInfoStatusMapper.updateByPrimaryKeySelective(bean);
|
contractInfoStatusMapper.updateByPrimaryKeySelective(bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return R.SUCCESS("ok");
|
return R.SUCCESS("ok");
|
||||||
}
|
}
|
||||||
|
|
@ -272,7 +270,7 @@ public class ContractInfoScribeController {
|
||||||
bean.setScribe_status(1);
|
bean.setScribe_status(1);
|
||||||
bean.setScribe_update_time(LocalDateTime.now());
|
bean.setScribe_update_time(LocalDateTime.now());
|
||||||
contractInfoStatusMapper.insertSelective(bean);
|
contractInfoStatusMapper.insertSelective(bean);
|
||||||
}else {
|
}
|
||||||
ContractInfoStatus bean = opStatu.get();
|
ContractInfoStatus bean = opStatu.get();
|
||||||
bean.setScribe_status(1);
|
bean.setScribe_status(1);
|
||||||
bean.setScribe_update_time(LocalDateTime.now());
|
bean.setScribe_update_time(LocalDateTime.now());
|
||||||
|
|
@ -281,8 +279,6 @@ public class ContractInfoScribeController {
|
||||||
contractInfoStatusMapper.updateByPrimaryKeySelective(bean);
|
contractInfoStatusMapper.updateByPrimaryKeySelective(bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return R.SUCCESS("ok");
|
return R.SUCCESS("ok");
|
||||||
|
|
@ -351,18 +347,16 @@ public class ContractInfoScribeController {
|
||||||
if(!opStatu.isPresent()) {
|
if(!opStatu.isPresent()) {
|
||||||
ContractInfoStatus bean = new ContractInfoStatus();
|
ContractInfoStatus bean = new ContractInfoStatus();
|
||||||
bean.setTs_code(info.getTs_code());
|
bean.setTs_code(info.getTs_code());
|
||||||
bean.setContract_status(0);
|
bean.setScribe_status(1);
|
||||||
bean.setScribe_status(0);
|
|
||||||
bean.setScribe_number(sum);
|
|
||||||
bean.setScribe_update_time(LocalDateTime.now());
|
bean.setScribe_update_time(LocalDateTime.now());
|
||||||
contractInfoStatusMapper.insertSelective(bean);
|
contractInfoStatusMapper.insertSelective(bean);
|
||||||
}else {
|
|
||||||
ContractInfoStatus bean = new ContractInfoStatus();
|
|
||||||
bean.setId(opStatu.get().getId());
|
|
||||||
bean.setScribe_update_time(LocalDateTime.now());
|
|
||||||
contractInfoStatusMapper.updateByPrimaryKeySelective(bean);
|
|
||||||
}
|
}
|
||||||
|
ContractInfoStatus bean = opStatu.get();
|
||||||
|
bean.setScribe_status(1);
|
||||||
|
bean.setScribe_update_time(LocalDateTime.now());
|
||||||
|
bean.setContract_status(null);
|
||||||
|
bean.setTs_code(null);
|
||||||
|
contractInfoStatusMapper.updateByPrimaryKeySelective(bean);
|
||||||
|
|
||||||
return R.SUCCESS("add:"+sum);
|
return R.SUCCESS("add:"+sum);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package jj.tech.finance.biz.webadmin.controller;
|
||||||
|
|
||||||
import static org.mybatis.dynamic.sql.SqlBuilder.*;
|
import static org.mybatis.dynamic.sql.SqlBuilder.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
@ -16,7 +15,6 @@ import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.http.client.ClientProtocolException;
|
|
||||||
import org.apache.http.client.fluent.Request;
|
import org.apache.http.client.fluent.Request;
|
||||||
import org.apache.http.entity.ContentType;
|
import org.apache.http.entity.ContentType;
|
||||||
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
|
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
|
||||||
|
|
@ -31,7 +29,6 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
|
@ -62,9 +59,9 @@ public class GetFutDailyController {
|
||||||
@Autowired DailyService dailyService;
|
@Autowired DailyService dailyService;
|
||||||
|
|
||||||
|
|
||||||
// @Operation(summary = "获取所有日线信息", description = "")
|
// @Operation(summary = "获取日线信息", description = "")
|
||||||
// @GetMapping("/getAll")
|
// @GetMapping("/getDate")
|
||||||
// public Object getAll() {
|
// public Object getDate() {
|
||||||
//
|
//
|
||||||
// var ts_codes = select(FutDailyDynamicSqlSupport.ts_code)
|
// var ts_codes = select(FutDailyDynamicSqlSupport.ts_code)
|
||||||
// .from(FutDailyDynamicSqlSupport.futDaily)
|
// .from(FutDailyDynamicSqlSupport.futDaily)
|
||||||
|
|
@ -152,7 +149,7 @@ public class GetFutDailyController {
|
||||||
@GetMapping("/getDateNow")
|
@GetMapping("/getDateNow")
|
||||||
public Object getDateNow() {
|
public Object getDateNow() {
|
||||||
|
|
||||||
LocalDate d = LocalDate.now();
|
LocalDate d = LocalDate.of(2024, 02, 20);
|
||||||
var from = select(ContractInfoMapper.selectList)
|
var from = select(ContractInfoMapper.selectList)
|
||||||
.from(ContractInfoDynamicSqlSupport.contractInfo)
|
.from(ContractInfoDynamicSqlSupport.contractInfo)
|
||||||
.where(ContractInfoDynamicSqlSupport.contractInfo.delist_date, isGreaterThan(d))
|
.where(ContractInfoDynamicSqlSupport.contractInfo.delist_date, isGreaterThan(d))
|
||||||
|
|
@ -160,16 +157,16 @@ public class GetFutDailyController {
|
||||||
.build()
|
.build()
|
||||||
.render(RenderingStrategies.MYBATIS3);
|
.render(RenderingStrategies.MYBATIS3);
|
||||||
|
|
||||||
// var from = select(ContractInfoMapper.selectList)
|
|
||||||
// .from(select(ContractInfoMapper.selectList)
|
|
||||||
// .from(ContractInfoDynamicSqlSupport.contractInfo)
|
|
||||||
// .orderBy(ContractInfoDynamicSqlSupport.delist_date.descending())
|
DeleteStatementProvider delete = deleteFrom(FutDailyDynamicSqlSupport.futDaily)
|
||||||
// .limit(20000),
|
.where(FutDailyDynamicSqlSupport.ts_code, isIn(select(ContractInfoDynamicSqlSupport.ts_code)
|
||||||
// "t1"
|
.from(ContractInfoDynamicSqlSupport.contractInfo)
|
||||||
// )
|
.where(ContractInfoDynamicSqlSupport.contractInfo.delist_date, isGreaterThan(d))))
|
||||||
// .groupBy(ContractInfoDynamicSqlSupport.fut_code)
|
.build()
|
||||||
// .build()
|
.render(RenderingStrategies.MYBATIS3);
|
||||||
// .render(RenderingStrategies.MYBATIS3);
|
futDailyMapper.delete(delete);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -199,7 +196,6 @@ public class GetFutDailyController {
|
||||||
|
|
||||||
ArrayList<FutDaily> list = new ArrayList<FutDaily>();
|
ArrayList<FutDaily> list = new ArrayList<FutDaily>();
|
||||||
|
|
||||||
if(items!=null) {
|
|
||||||
for(JsonNode jsonNode : items) {
|
for(JsonNode jsonNode : items) {
|
||||||
FutDaily bean = new FutDaily();
|
FutDaily bean = new FutDaily();
|
||||||
bean.setTs_code(jsonNode.get(0).asText());
|
bean.setTs_code(jsonNode.get(0).asText());
|
||||||
|
|
@ -225,12 +221,11 @@ public class GetFutDailyController {
|
||||||
bean.setOi_chg(jsonNode.get(14).asDouble());
|
bean.setOi_chg(jsonNode.get(14).asDouble());
|
||||||
list.add(bean);
|
list.add(bean);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(!list.isEmpty()) {
|
if(!list.isEmpty()) {
|
||||||
dailyService.getCurr(i.getTs_code(), list);
|
dailyService.getCurr(i.getTs_code(), list);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.sleep(50);
|
//Thread.sleep(200);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
@ -315,7 +310,7 @@ public class GetFutDailyController {
|
||||||
dailyService.getCurr(i.getTs_code(), list);
|
dailyService.getCurr(i.getTs_code(), list);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.sleep(50);
|
//Thread.sleep(200);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
@ -464,168 +459,5 @@ public class GetFutDailyController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/test")
|
|
||||||
public Object test() throws Exception{
|
|
||||||
|
|
||||||
// LocalDate d = LocalDate.now();
|
|
||||||
// var from = select(ContractInfoMapper.selectList)
|
|
||||||
// .from(ContractInfoDynamicSqlSupport.contractInfo)
|
|
||||||
// .where(ContractInfoDynamicSqlSupport.contractInfo.delist_date, isGreaterThan(d))
|
|
||||||
// //.and(ContractInfoDynamicSqlSupport.ts_code, )
|
|
||||||
// .build()
|
|
||||||
// .render(RenderingStrategies.MYBATIS3);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// List<ContractInfo> contractInfos = contractInfoMapper.selectMany(from);
|
|
||||||
//
|
|
||||||
// contractInfos.forEach(i->{
|
|
||||||
//
|
|
||||||
// if(i.getTs_code().equals("HC2405.SHF")) {
|
|
||||||
//
|
|
||||||
// try {
|
|
||||||
// HashMap<Object,Object> h = new HashMap<Object,Object>();
|
|
||||||
// h.put("api_name", "fut_daily");
|
|
||||||
// h.put("token", TushareConfig.TOKEN);
|
|
||||||
// HashMap<Object,Object> params = new HashMap<Object,Object>();
|
|
||||||
// params.put("ts_code", i.getTs_code());
|
|
||||||
// params.put("limit", 10000);
|
|
||||||
// h.put("params", params);
|
|
||||||
// logger.debug("tushare:" + objectMapper.writeValueAsString(h));
|
|
||||||
//
|
|
||||||
// InputStream stean =
|
|
||||||
// Request.Post(TushareConfig.URL)
|
|
||||||
// .connectTimeout(15000)
|
|
||||||
// .socketTimeout(15000)
|
|
||||||
// .bodyString(objectMapper.writeValueAsString(h), ContentType.APPLICATION_JSON)
|
|
||||||
// .execute()
|
|
||||||
// .returnContent()
|
|
||||||
// .asStream();
|
|
||||||
// JsonNode root = objectMapper.readTree(stean);
|
|
||||||
// JsonNode items = root.get("data").get("items");
|
|
||||||
//
|
|
||||||
// ArrayList<FutDaily> list = new ArrayList<FutDaily>();
|
|
||||||
//
|
|
||||||
// if(items!=null) {
|
|
||||||
// for(JsonNode jsonNode : items) {
|
|
||||||
// FutDaily bean = new FutDaily();
|
|
||||||
// bean.setTs_code(jsonNode.get(0).asText());
|
|
||||||
//
|
|
||||||
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
||||||
// LocalDate localDate = LocalDate.parse(jsonNode.get(1).asText(), formatter);
|
|
||||||
//
|
|
||||||
// bean.setTrade_date(localDate);
|
|
||||||
// bean.setPre_close(jsonNode.get(2).asDouble());
|
|
||||||
// bean.setPre_settle(jsonNode.get(3).asDouble());
|
|
||||||
// bean.setOpen(jsonNode.get(4).asDouble());
|
|
||||||
// bean.setHigh(jsonNode.get(5).asDouble());
|
|
||||||
//
|
|
||||||
// bean.setLow(jsonNode.get(6).asDouble());
|
|
||||||
// bean.setClose(jsonNode.get(7).asDouble());
|
|
||||||
// bean.setSettle(jsonNode.get(8).asDouble());
|
|
||||||
// bean.setChange1(jsonNode.get(9).asDouble());
|
|
||||||
// bean.setChange2(jsonNode.get(10).asDouble());
|
|
||||||
//
|
|
||||||
// bean.setVol(jsonNode.get(11).asDouble());
|
|
||||||
// bean.setAmount(jsonNode.get(12).asDouble());
|
|
||||||
// bean.setOi(jsonNode.get(13).asDouble());
|
|
||||||
// bean.setOi_chg(jsonNode.get(14).asDouble());
|
|
||||||
// list.add(bean);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if(!list.isEmpty()) {
|
|
||||||
// dailyService.getCurr(i.getTs_code(), list);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //Thread.sleep(200);
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// return R.SUCCESS("getDate is ok");
|
|
||||||
|
|
||||||
var from = select(ContractInfoMapper.selectList)
|
|
||||||
.from(select(ContractInfoMapper.selectList)
|
|
||||||
.from(ContractInfoDynamicSqlSupport.contractInfo)
|
|
||||||
.orderBy(ContractInfoDynamicSqlSupport.delist_date.descending())
|
|
||||||
.limit(20000),
|
|
||||||
"t1"
|
|
||||||
)
|
|
||||||
.groupBy(ContractInfoDynamicSqlSupport.fut_code)
|
|
||||||
.build()
|
|
||||||
.render(RenderingStrategies.MYBATIS3);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<ContractInfo> contractInfos = contractInfoMapper.selectMany(from);
|
|
||||||
System.out.println(contractInfos.size());
|
|
||||||
return R.SUCCESS(contractInfos);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// public static void main(String[] args) throws Exception {
|
|
||||||
//
|
|
||||||
// ObjectMapper objectMapper =new ObjectMapper();
|
|
||||||
// HashMap<Object,Object> h = new HashMap<Object,Object>();
|
|
||||||
// h.put("api_name", "fut_daily");
|
|
||||||
// h.put("token", TushareConfig.TOKEN);
|
|
||||||
// HashMap<Object,Object> params = new HashMap<Object,Object>();
|
|
||||||
// params.put("ts_code", "HC2405.SHF");
|
|
||||||
// params.put("limit", 10000);
|
|
||||||
// h.put("params", params);
|
|
||||||
// logger.debug("tushare:" + objectMapper.writeValueAsString(h));
|
|
||||||
//
|
|
||||||
// InputStream stean =
|
|
||||||
// Request.Post(TushareConfig.URL)
|
|
||||||
// .connectTimeout(15000)
|
|
||||||
// .socketTimeout(15000)
|
|
||||||
// .bodyString(objectMapper.writeValueAsString(h), ContentType.APPLICATION_JSON)
|
|
||||||
// .execute()
|
|
||||||
// .returnContent()
|
|
||||||
// .asStream();
|
|
||||||
// JsonNode root = objectMapper.readTree(stean);
|
|
||||||
// JsonNode items = root.get("data").get("items");
|
|
||||||
// //System.out.println(items);
|
|
||||||
// ArrayList<FutDaily> list = new ArrayList<FutDaily>();
|
|
||||||
//
|
|
||||||
// if(items!=null) {
|
|
||||||
// for(JsonNode jsonNode : items) {
|
|
||||||
// FutDaily bean = new FutDaily();
|
|
||||||
// bean.setTs_code(jsonNode.get(0).asText());
|
|
||||||
//
|
|
||||||
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
||||||
// LocalDate localDate = LocalDate.parse(jsonNode.get(1).asText(), formatter);
|
|
||||||
//
|
|
||||||
// bean.setTrade_date(localDate);
|
|
||||||
// bean.setPre_close(jsonNode.get(2).asDouble());
|
|
||||||
// bean.setPre_settle(jsonNode.get(3).asDouble());
|
|
||||||
// bean.setOpen(jsonNode.get(4).asDouble());
|
|
||||||
// bean.setHigh(jsonNode.get(5).asDouble());
|
|
||||||
//
|
|
||||||
// bean.setLow(jsonNode.get(6).asDouble());
|
|
||||||
// bean.setClose(jsonNode.get(7).asDouble());
|
|
||||||
// bean.setSettle(jsonNode.get(8).asDouble());
|
|
||||||
// bean.setChange1(jsonNode.get(9).asDouble());
|
|
||||||
// bean.setChange2(jsonNode.get(10).asDouble());
|
|
||||||
//
|
|
||||||
// bean.setVol(jsonNode.get(11).asDouble());
|
|
||||||
// bean.setAmount(jsonNode.get(12).asDouble());
|
|
||||||
// bean.setOi(jsonNode.get(13).asDouble());
|
|
||||||
// bean.setOi_chg(jsonNode.get(14).asDouble());
|
|
||||||
// list.add(bean);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// System.out.println(list.size());
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,6 @@ public class DailyService {
|
||||||
|
|
||||||
DeleteStatementProvider delete = deleteFrom(FutDailyDynamicSqlSupport.futDaily)
|
DeleteStatementProvider delete = deleteFrom(FutDailyDynamicSqlSupport.futDaily)
|
||||||
.where(FutDailyDynamicSqlSupport.ts_code, isEqualTo(ts_code))
|
.where(FutDailyDynamicSqlSupport.ts_code, isEqualTo(ts_code))
|
||||||
.limit(20000)
|
|
||||||
.build()
|
.build()
|
||||||
.render(RenderingStrategies.MYBATIS3);
|
.render(RenderingStrategies.MYBATIS3);
|
||||||
futDailyMapper.delete(delete);
|
futDailyMapper.delete(delete);
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,137 @@
|
||||||
package jj.tech.finance.biz.webadmin.task;
|
//package jj.tech.finance.biz.webadmin.task;
|
||||||
|
//
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import static org.mybatis.dynamic.sql.SqlBuilder.*;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
//
|
||||||
import org.springframework.stereotype.Component;
|
//import java.io.InputStream;
|
||||||
|
//import java.util.ArrayList;
|
||||||
import jj.tech.finance.biz.webadmin.controller.GetFutDailyController;
|
//import java.util.Arrays;
|
||||||
|
//import java.util.HashMap;
|
||||||
|
//import java.util.List;
|
||||||
@Component
|
//import java.util.Map;
|
||||||
public class ContractInfoTime {
|
//import java.util.stream.Collectors;
|
||||||
@Autowired GetFutDailyController getFutDailyController;
|
//
|
||||||
|
//import org.apache.http.client.fluent.Request;
|
||||||
/**
|
//import org.apache.http.entity.ContentType;
|
||||||
* 同步tushare的合约信息
|
//import org.mybatis.dynamic.sql.render.RenderingStrategies;
|
||||||
*/
|
//import org.slf4j.Logger;
|
||||||
// @Scheduled(cron = "0 0 0/4 * * ?") //4小时一次
|
//import org.slf4j.LoggerFactory;
|
||||||
// @Scheduled(cron = "0/50 * * * * ?") //50秒一次
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
//import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
//import org.springframework.stereotype.Component;
|
||||||
|
//import org.springframework.web.service.annotation.GetExchange;
|
||||||
|
//
|
||||||
|
//import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
//import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
//
|
||||||
|
//import jj.tech.finance.config.enums.Exchange;
|
||||||
|
//import jj.tech.finance.repository.mybatis.dao.ContractInfoMapper;
|
||||||
|
//import jj.tech.finance.repository.mybatis.dao.support.ContractInfoDynamicSqlSupport;
|
||||||
|
//import jj.tech.finance.repository.mybatis.entity.ContractInfo;
|
||||||
|
//import jj.tech.finance.utils.tushare.TushareConfig;
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//@Component
|
||||||
|
//public class ContractInfoTime {
|
||||||
|
// private static Logger logger = LoggerFactory.getLogger(ContractInfoTime.class);
|
||||||
|
//
|
||||||
|
// @Autowired ObjectMapper objectMapper;
|
||||||
|
// @Autowired ContractInfoMapper contractInfoMapper;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 同步tushare的合约信息
|
||||||
|
// */
|
||||||
|
//// @Scheduled(cron = "0 0 0/4 * * ?") //4小时一次
|
||||||
|
//// @Scheduled(cron = "0/50 * * * * ?") //50秒一次
|
||||||
// @Scheduled(cron = "0 0 8-17/4 * * ?") //8点到15点之间,4小时一次
|
// @Scheduled(cron = "0 0 8-17/4 * * ?") //8点到15点之间,4小时一次
|
||||||
|
// public void checkUser() throws Exception {
|
||||||
@Scheduled(cron = "0 0 01 * * ?") //每天早上1点
|
//
|
||||||
public void init() throws Exception {
|
// List<Exchange> exchanges = Arrays.asList(Exchange.values());
|
||||||
getFutDailyController.init();
|
//
|
||||||
}
|
// exchanges.forEach(i->{
|
||||||
|
// HashMap<Object,Object> h = new HashMap<Object,Object>();
|
||||||
|
// h.put("api_name", "fut_basic");
|
||||||
}
|
// h.put("token", TushareConfig.TOKEN);
|
||||||
|
// HashMap<Object,Object> params = new HashMap<Object,Object>();
|
||||||
|
// params.put("exchange", i);
|
||||||
|
// h.put("params", params);
|
||||||
|
// try {
|
||||||
|
// this.getExchangeDate(i, h);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void getExchangeDate(Exchange exchange, HashMap<Object,Object> parm) throws Exception{
|
||||||
|
// logger.debug("tushare:" + objectMapper.writeValueAsString(parm));
|
||||||
|
//
|
||||||
|
// InputStream stean =
|
||||||
|
// Request.Post(TushareConfig.URL)
|
||||||
|
// .connectTimeout(3000)
|
||||||
|
// .socketTimeout(3000)
|
||||||
|
// .bodyString(objectMapper.writeValueAsString(parm), ContentType.APPLICATION_JSON)
|
||||||
|
// .execute()
|
||||||
|
// .returnContent()
|
||||||
|
// .asStream();
|
||||||
|
//// .asString(StandardCharsets.UTF_8);
|
||||||
|
//
|
||||||
|
// JsonNode root = objectMapper.readTree(stean);
|
||||||
|
// JsonNode items = root.get("data").get("items");
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// ArrayList<ContractInfo> list = new ArrayList<ContractInfo>();
|
||||||
|
// for(JsonNode jsonNode : items) {
|
||||||
|
// ContractInfo bean = new ContractInfo();
|
||||||
|
// bean.setTs_code(jsonNode.get(0).asText());
|
||||||
|
// bean.setSymbol(jsonNode.get(1).asText());
|
||||||
|
// bean.setExchange(jsonNode.get(2).asText());
|
||||||
|
// bean.setName(jsonNode.get(3).asText());
|
||||||
|
// bean.setFut_code(jsonNode.get(4).asText());
|
||||||
|
// bean.setMultiplier(jsonNode.get(5).asDouble());
|
||||||
|
//
|
||||||
|
// bean.setTrade_unit(jsonNode.get(6).asText());
|
||||||
|
// bean.setPer_unit(jsonNode.get(7).asDouble());
|
||||||
|
// bean.setQuote_unit(jsonNode.get(8).asText());
|
||||||
|
// bean.setQuote_unit_desc(jsonNode.get(9).asText());
|
||||||
|
// bean.setD_mode_desc(jsonNode.get(10).asText());
|
||||||
|
//
|
||||||
|
// bean.setList_date(jsonNode.get(11).asText());
|
||||||
|
// bean.setDelist_date(jsonNode.get(12).asText());
|
||||||
|
// bean.setD_month(jsonNode.get(13).asText());
|
||||||
|
// bean.setLast_ddate(jsonNode.get(14).asText());
|
||||||
|
// list.add(bean);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// var from = select(ContractInfoMapper.selectList)
|
||||||
|
// .from(ContractInfoDynamicSqlSupport.contractInfo)
|
||||||
|
// .where(ContractInfoDynamicSqlSupport.exchange, isEqualTo(exchange.toString()))
|
||||||
|
// .limit(8888)
|
||||||
|
// .build()
|
||||||
|
// .render(RenderingStrategies.MYBATIS3);
|
||||||
|
//
|
||||||
|
// List<ContractInfo> contractInfos = contractInfoMapper.selectMany(from);
|
||||||
|
// Map<String, Object> local =
|
||||||
|
// contractInfos.stream().collect(
|
||||||
|
// Collectors.toMap(ContractInfo::getTs_code, i->i)
|
||||||
|
// );
|
||||||
|
// //System.out.println(local);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// List<ContractInfo> bath = new ArrayList<ContractInfo>();
|
||||||
|
// list.forEach(i->{
|
||||||
|
// if(local.get(i.getTs_code()) == null) {
|
||||||
|
// bath.add(i);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// if(!bath.isEmpty()) {
|
||||||
|
// contractInfoMapper.insertMultiple(bath);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,149 @@
|
||||||
package jj.tech.finance.biz.webadmin.task;
|
//package jj.tech.finance.biz.webadmin.task;
|
||||||
|
//
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import static org.mybatis.dynamic.sql.SqlBuilder.*;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
//
|
||||||
import org.springframework.stereotype.Component;
|
//import java.io.IOException;
|
||||||
|
//import java.io.InputStream;
|
||||||
import jj.tech.finance.biz.webadmin.controller.GetFutDailyController;
|
//import java.util.ArrayList;
|
||||||
|
//import java.util.Arrays;
|
||||||
@Component
|
//import java.util.HashMap;
|
||||||
public class FutDailyTime {
|
//import java.util.List;
|
||||||
@Autowired GetFutDailyController getFutDailyController;
|
//import java.util.Map;
|
||||||
|
//import java.util.stream.Collectors;
|
||||||
//@Scheduled(cron = "0 0/5 * * * ?") //5分钟
|
//
|
||||||
@Scheduled(cron = "0 30 15 * * ?") //每天中午3点半
|
//import org.apache.http.client.ClientProtocolException;
|
||||||
public void getDateNow() throws Exception {
|
//import org.apache.http.client.fluent.Request;
|
||||||
getFutDailyController.getDateNow();
|
//import org.apache.http.entity.ContentType;
|
||||||
}
|
//import org.mybatis.dynamic.sql.SqlBuilder;
|
||||||
|
//import org.mybatis.dynamic.sql.render.RenderingStrategies;
|
||||||
@Scheduled(cron = "0 30 13 * * ?") //每天中午1点半
|
//import org.slf4j.Logger;
|
||||||
public void checkUser() throws Exception {
|
//import org.slf4j.LoggerFactory;
|
||||||
getFutDailyController.getDate();
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
}
|
//import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
//import org.springframework.stereotype.Component;
|
||||||
|
//
|
||||||
}
|
//import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
//import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
//import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
//
|
||||||
|
//import jj.tech.finance.config.enums.Exchange;
|
||||||
|
//import jj.tech.finance.repository.mybatis.dao.ContractInfoMapper;
|
||||||
|
//import jj.tech.finance.repository.mybatis.dao.FutDailyMapper;
|
||||||
|
//import jj.tech.finance.repository.mybatis.dao.support.ContractInfoDynamicSqlSupport;
|
||||||
|
//import jj.tech.finance.repository.mybatis.dao.support.FutDailyDynamicSqlSupport;
|
||||||
|
//import jj.tech.finance.repository.mybatis.entity.ContractInfo;
|
||||||
|
//import jj.tech.finance.utils.tushare.TushareConfig;
|
||||||
|
//
|
||||||
|
//@Component
|
||||||
|
//public class FutDailyTime {
|
||||||
|
// private static Logger logger = LoggerFactory.getLogger(FutDailyTime.class);
|
||||||
|
//
|
||||||
|
// @Autowired ObjectMapper objectMapper;
|
||||||
|
// @Autowired ContractInfoMapper contractInfoMapper;
|
||||||
|
// @Autowired FutDailyMapper futDailyMapper;
|
||||||
|
//
|
||||||
|
// //@Scheduled(cron = "0 0/5 * * * ?") //5分钟
|
||||||
|
// @Scheduled(cron = "0/50 * * * * ?")
|
||||||
|
// public void checkUser() throws Exception {
|
||||||
|
//
|
||||||
|
// List<Exchange> exchanges = Arrays.asList(Exchange.values());
|
||||||
|
//
|
||||||
|
// exchanges.forEach(i->{
|
||||||
|
// HashMap<Object,Object> h = new HashMap<Object,Object>();
|
||||||
|
// h.put("api_name", "fut_daily");
|
||||||
|
// h.put("token", TushareConfig.TOKEN);
|
||||||
|
// HashMap<Object,Object> params = new HashMap<Object,Object>();
|
||||||
|
// params.put("ts_code", "RU2310.SHF");
|
||||||
|
// h.put("params", params);
|
||||||
|
// try {
|
||||||
|
// this.getExchangeDate(i, h);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void getExchangeDate(Exchange exchange, HashMap<Object,Object> parm) throws Exception{
|
||||||
|
// logger.debug("tushare:" + objectMapper.writeValueAsString(parm));
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// var ts_codes = select(FutDailyDynamicSqlSupport.ts_code)
|
||||||
|
// .from(FutDailyDynamicSqlSupport.futDaily)
|
||||||
|
// .groupBy(FutDailyDynamicSqlSupport.futDaily.ts_code);
|
||||||
|
//
|
||||||
|
// var from = select(ContractInfoMapper.selectList)
|
||||||
|
// .from(ContractInfoDynamicSqlSupport.contractInfo)
|
||||||
|
// .where(ContractInfoDynamicSqlSupport.contractInfo.ts_code, isNotIn(ts_codes))
|
||||||
|
// .groupBy(ContractInfoDynamicSqlSupport.contractInfo.ts_code)
|
||||||
|
// .build()
|
||||||
|
// .render(RenderingStrategies.MYBATIS3);
|
||||||
|
//
|
||||||
|
// List<ContractInfo> contractInfos = contractInfoMapper.selectMany(from);
|
||||||
|
//
|
||||||
|
// contractInfos.forEach(i->{
|
||||||
|
// try {
|
||||||
|
// HashMap<Object,Object> h = new HashMap<Object,Object>();
|
||||||
|
// h.put("api_name", "fut_daily");
|
||||||
|
// h.put("token", TushareConfig.TOKEN);
|
||||||
|
// HashMap<Object,Object> params = new HashMap<Object,Object>();
|
||||||
|
// params.put("ts_code", i.getTs_code());
|
||||||
|
// h.put("params", params);
|
||||||
|
// logger.debug("tushare:" + objectMapper.writeValueAsString(h));
|
||||||
|
//
|
||||||
|
// InputStream stean =
|
||||||
|
// Request.Post(TushareConfig.URL)
|
||||||
|
// .connectTimeout(3000)
|
||||||
|
// .socketTimeout(3000)
|
||||||
|
// .bodyString(objectMapper.writeValueAsString(h), ContentType.APPLICATION_JSON)
|
||||||
|
// .execute()
|
||||||
|
// .returnContent()
|
||||||
|
// .asStream();
|
||||||
|
// JsonNode root = objectMapper.readTree(stean);
|
||||||
|
// JsonNode items = root.get("data").get("items");
|
||||||
|
//
|
||||||
|
// ArrayList<ContractInfo> list = new ArrayList<ContractInfo>();
|
||||||
|
// for(JsonNode jsonNode : items) {
|
||||||
|
// ContractInfo bean = new ContractInfo();
|
||||||
|
// bean.setTs_code(jsonNode.get(0).asText());
|
||||||
|
// bean.setSymbol(jsonNode.get(1).asText());
|
||||||
|
// bean.setExchange(jsonNode.get(2).asText());
|
||||||
|
// bean.setName(jsonNode.get(3).asText());
|
||||||
|
// bean.setFut_code(jsonNode.get(4).asText());
|
||||||
|
// bean.setMultiplier(jsonNode.get(5).asDouble());
|
||||||
|
//
|
||||||
|
// bean.setTrade_unit(jsonNode.get(6).asText());
|
||||||
|
// bean.setPer_unit(jsonNode.get(7).asDouble());
|
||||||
|
// bean.setQuote_unit(jsonNode.get(8).asText());
|
||||||
|
// bean.setQuote_unit_desc(jsonNode.get(9).asText());
|
||||||
|
// bean.setD_mode_desc(jsonNode.get(10).asText());
|
||||||
|
//
|
||||||
|
// bean.setList_date(jsonNode.get(11).asText());
|
||||||
|
// bean.setDelist_date(jsonNode.get(12).asText());
|
||||||
|
// bean.setD_month(jsonNode.get(13).asText());
|
||||||
|
// bean.setLast_ddate(jsonNode.get(14).asText());
|
||||||
|
// list.add(bean);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Thread.sleep(300);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
|
||||||
|
|
@ -9,26 +9,7 @@ public class ContractInfoStatuScribe extends ContractInfoStatu{
|
||||||
public Integer scribe_number;
|
public Integer scribe_number;
|
||||||
public LocalDateTime scribe_update_time;
|
public LocalDateTime scribe_update_time;
|
||||||
|
|
||||||
public FutDaily futDaily = new FutDaily();
|
public FutDaily futDaily;
|
||||||
{
|
|
||||||
double d = 0;
|
|
||||||
futDaily.setAmount(d);
|
|
||||||
futDaily.setChange1(d);
|
|
||||||
futDaily.setChange2(d);
|
|
||||||
futDaily.setClose(d);
|
|
||||||
futDaily.setHigh(d);
|
|
||||||
futDaily.setId(0);
|
|
||||||
futDaily.setLow(d);
|
|
||||||
futDaily.setOi(d);
|
|
||||||
futDaily.setOi_chg(d);
|
|
||||||
futDaily.setOpen(d);
|
|
||||||
futDaily.setPre_close(d);
|
|
||||||
futDaily.setPre_settle(d);
|
|
||||||
futDaily.setSettle(d);
|
|
||||||
futDaily.setTrade_date(null);
|
|
||||||
futDaily.setTs_code("");
|
|
||||||
futDaily.setVol(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Integer getScribe_status() {
|
public Integer getScribe_status() {
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ spring:
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
root: error
|
root: info
|
||||||
# org.jooq: debug
|
# org.jooq: debug
|
||||||
# org.springframework.amqp: debug
|
# org.springframework.amqp: debug
|
||||||
# org.mybatis: debug
|
# org.mybatis: debug
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ spring:
|
||||||
# password:
|
# password:
|
||||||
# hikari:
|
# hikari:
|
||||||
# driver-class-name: org.h2.Driver
|
# driver-class-name: org.h2.Driver
|
||||||
url: jdbc:mariadb://119.45.61.64:3306/finance
|
url: jdbc:mariadb://106.53.186.11:3306/finance
|
||||||
username: root
|
username: root
|
||||||
password: open123
|
password: open123
|
||||||
hikari:
|
hikari:
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
<jdbc>
|
<jdbc>
|
||||||
<driver>org.mariadb.jdbc.Driver</driver>
|
<driver>org.mariadb.jdbc.Driver</driver>
|
||||||
<url>jdbc:mariadb://119.45.61.64:3306/finance</url>
|
<url>jdbc:mariadb://106.53.186.11:3306/finance</url>
|
||||||
<user>root</user>
|
<user>root</user>
|
||||||
<password>open123</password>
|
<password>open123</password>
|
||||||
<!--<driver>org.h2.Driver</driver>
|
<!--<driver>org.h2.Driver</driver>
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
|
|
||||||
<!-- nullCatalogMeansCurrent对mariadb 不起作用,会查出所有的非表对象 -->
|
<!-- nullCatalogMeansCurrent对mariadb 不起作用,会查出所有的非表对象 -->
|
||||||
<jdbcConnection driverClass="org.mariadb.jdbc.Driver" connectionURL="jdbc:mariadb://119.45.61.64:3306/finance" userId="root" password="open123">
|
<jdbcConnection driverClass="org.mariadb.jdbc.Driver" connectionURL="jdbc:mariadb://106.53.186.11:3306/finance" userId="root" password="open123">
|
||||||
<property name="nullCatalogMeansCurrent" value="true" />
|
<property name="nullCatalogMeansCurrent" value="true" />
|
||||||
</jdbcConnection>
|
</jdbcConnection>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ spring:
|
||||||
password:
|
password:
|
||||||
hikari:
|
hikari:
|
||||||
driver-class-name: org.h2.Driver
|
driver-class-name: org.h2.Driver
|
||||||
# url: jdbc:mariadb://119.45.61.64:3306/test
|
# url: jdbc:mariadb://173.249.203.214:3306/test
|
||||||
# username: root
|
# username: root
|
||||||
# password: open123
|
# password: open123
|
||||||
# hikari:
|
# hikari:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user