Compare commits

..

10 Commits

Author SHA1 Message Date
mmm8955405 127d21b59e 请求睡眠
Some checks failed
/ build-image (push) Failing after 7m8s
2024-03-20 10:08:36 +08:00
mmm8955405 087016bc46 xg 2024-03-19 10:11:35 +08:00
mmm8955405 170264a09f xg 2024-03-16 04:13:12 +08:00
mmm8955405 365eb2476c xxxx 2024-03-16 01:05:15 +08:00
mmm8955405 1fb6e66f5b mm 2024-03-16 00:16:58 +08:00
mmm8955405 03b175c8a1 xgg 2024-03-15 23:24:18 +08:00
mmm8955405 5501717dad xg 2024-03-15 22:59:10 +08:00
mmm8955405 82c9c22d1e xg 2024-03-15 01:22:58 +08:00
mmm8955405 43e1cc6ec9 xg 2024-03-15 01:08:33 +08:00
mmm8955405 72fe79a7a4 gx 2024-03-06 14:53:32 +08:00
14 changed files with 317 additions and 357 deletions

View File

@ -345,7 +345,7 @@
<username>sa</username>
<password></password>
<driver>org.mariadb.jdbc.Driver</driver>
<url>jdbc:mariadb://173.249.203.214:3306/finance</url>
<url>jdbc:mariadb://119.45.61.64:3306/finance</url>
<username>root</username>
<password>open123</password>

View File

@ -284,7 +284,7 @@ public class ContractInfoController {
String symbol = StringUtils.substringBefore(contractInfo.getTs_code(), ".");
String url =
"http://173.249.203.214:8080/api/public/futures_zh_spot?"
"http://119.45.61.64:8080/api/public/futures_zh_spot?"
+ "symbol=" + symbol;
System.out.println(url);
InputStream stean = Request.Get(url)
@ -341,7 +341,7 @@ public class ContractInfoController {
// };
//
// String url =
// "http://173.249.203.214:8080/api/public/futures_zh_spot?"
// "http://119.45.61.64:8080/api/public/futures_zh_spot?"
// + "symbol=" + symbols;
// System.out.println(url);
// InputStream stean = Request.Get(url)

View File

@ -44,7 +44,7 @@ public class ContractInfoMinute {
}
try {
String url =
"http://173.249.203.214:8080/api/public/futures_zh_minute_sina?"
"http://119.45.61.64:8080/api/public/futures_zh_minute_sina?"
+ "symbol=" + symbol
+ "&period=" + parm.getPeriod();
System.out.println(url);

View File

@ -220,14 +220,16 @@ public class ContractInfoScribeController {
bean.setScribe_number(0);
bean.setScribe_update_time(LocalDateTime.now());
contractInfoStatusMapper.insertSelective(bean);
}else {
ContractInfoStatus bean = opStatu.get();
bean.setScribe_status(0);
bean.setScribe_update_time(LocalDateTime.now());
bean.setScribe_number(null);
bean.setContract_status(null);
bean.setTs_code(null);
contractInfoStatusMapper.updateByPrimaryKeySelective(bean);
}
ContractInfoStatus bean = opStatu.get();
bean.setScribe_status(0);
bean.setScribe_update_time(LocalDateTime.now());
bean.setScribe_number(null);
bean.setContract_status(null);
bean.setTs_code(null);
contractInfoStatusMapper.updateByPrimaryKeySelective(bean);
}
@ -270,13 +272,15 @@ public class ContractInfoScribeController {
bean.setScribe_status(1);
bean.setScribe_update_time(LocalDateTime.now());
contractInfoStatusMapper.insertSelective(bean);
}else {
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);
}
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);
}
@ -347,16 +351,18 @@ public class ContractInfoScribeController {
if(!opStatu.isPresent()) {
ContractInfoStatus bean = new ContractInfoStatus();
bean.setTs_code(info.getTs_code());
bean.setScribe_status(1);
bean.setContract_status(0);
bean.setScribe_status(0);
bean.setScribe_number(sum);
bean.setScribe_update_time(LocalDateTime.now());
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);
}

View File

@ -2,6 +2,7 @@ package jj.tech.finance.biz.webadmin.controller;
import static org.mybatis.dynamic.sql.SqlBuilder.*;
import java.io.IOException;
import java.io.InputStream;
import java.time.Instant;
import java.time.LocalDate;
@ -15,6 +16,7 @@ import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.fluent.Request;
import org.apache.http.entity.ContentType;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
@ -29,6 +31,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -59,9 +62,9 @@ public class GetFutDailyController {
@Autowired DailyService dailyService;
// @Operation(summary = "获取日线信息", description = "")
// @GetMapping("/getDate")
// public Object getDate() {
// @Operation(summary = "获取所有日线信息", description = "")
// @GetMapping("/getAll")
// public Object getAll() {
//
// var ts_codes = select(FutDailyDynamicSqlSupport.ts_code)
// .from(FutDailyDynamicSqlSupport.futDaily)
@ -149,7 +152,7 @@ public class GetFutDailyController {
@GetMapping("/getDateNow")
public Object getDateNow() {
LocalDate d = LocalDate.of(2024, 02, 20);
LocalDate d = LocalDate.now();
var from = select(ContractInfoMapper.selectList)
.from(ContractInfoDynamicSqlSupport.contractInfo)
.where(ContractInfoDynamicSqlSupport.contractInfo.delist_date, isGreaterThan(d))
@ -157,16 +160,16 @@ public class GetFutDailyController {
.build()
.render(RenderingStrategies.MYBATIS3);
DeleteStatementProvider delete = deleteFrom(FutDailyDynamicSqlSupport.futDaily)
.where(FutDailyDynamicSqlSupport.ts_code, isIn(select(ContractInfoDynamicSqlSupport.ts_code)
.from(ContractInfoDynamicSqlSupport.contractInfo)
.where(ContractInfoDynamicSqlSupport.contractInfo.delist_date, isGreaterThan(d))))
.build()
.render(RenderingStrategies.MYBATIS3);
futDailyMapper.delete(delete);
// 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);
@ -196,36 +199,38 @@ public class GetFutDailyController {
ArrayList<FutDaily> list = new ArrayList<FutDaily>();
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(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);
Thread.sleep(50);
} catch (Exception e) {
e.printStackTrace();
}
@ -310,7 +315,7 @@ public class GetFutDailyController {
dailyService.getCurr(i.getTs_code(), list);
}
//Thread.sleep(200);
Thread.sleep(50);
} catch (Exception e) {
e.printStackTrace();
}
@ -458,6 +463,169 @@ 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());
// }
}

View File

@ -128,6 +128,7 @@ public class DailyService {
DeleteStatementProvider delete = deleteFrom(FutDailyDynamicSqlSupport.futDaily)
.where(FutDailyDynamicSqlSupport.ts_code, isEqualTo(ts_code))
.limit(20000)
.build()
.render(RenderingStrategies.MYBATIS3);
futDailyMapper.delete(delete);

View File

@ -1,137 +1,27 @@
//package jj.tech.finance.biz.webadmin.task;
//
//import static org.mybatis.dynamic.sql.SqlBuilder.*;
//
//import java.io.InputStream;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//import java.util.stream.Collectors;
//
//import org.apache.http.client.fluent.Request;
//import org.apache.http.entity.ContentType;
//import org.mybatis.dynamic.sql.render.RenderingStrategies;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//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小时一次
// 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_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);
// }
//
//
// }
//
//
//}
package jj.tech.finance.biz.webadmin.task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import jj.tech.finance.biz.webadmin.controller.GetFutDailyController;
@Component
public class ContractInfoTime {
@Autowired GetFutDailyController getFutDailyController;
/**
* 同步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 01 * * ?") //每天早上1点
public void init() throws Exception {
getFutDailyController.init();
}
}

View File

@ -1,149 +1,25 @@
//package jj.tech.finance.biz.webadmin.task;
//
//import static org.mybatis.dynamic.sql.SqlBuilder.*;
//
//import java.io.IOException;
//import java.io.InputStream;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//import java.util.stream.Collectors;
//
//import org.apache.http.client.ClientProtocolException;
//import org.apache.http.client.fluent.Request;
//import org.apache.http.entity.ContentType;
//import org.mybatis.dynamic.sql.SqlBuilder;
//import org.mybatis.dynamic.sql.render.RenderingStrategies;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//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();
// }
//
//
//
//
// });
//
//
// }
//
//}
package jj.tech.finance.biz.webadmin.task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import jj.tech.finance.biz.webadmin.controller.GetFutDailyController;
@Component
public class FutDailyTime {
@Autowired GetFutDailyController getFutDailyController;
//@Scheduled(cron = "0 0/5 * * * ?") //5分钟
@Scheduled(cron = "0 30 15 * * ?") //每天中午3点半
public void getDateNow() throws Exception {
getFutDailyController.getDateNow();
}
@Scheduled(cron = "0 30 13 * * ?") //每天中午1点半
public void checkUser() throws Exception {
getFutDailyController.getDate();
}
}

View File

@ -9,7 +9,26 @@ public class ContractInfoStatuScribe extends ContractInfoStatu{
public Integer scribe_number;
public LocalDateTime scribe_update_time;
public FutDaily futDaily;
public FutDaily futDaily = new 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() {

View File

@ -60,7 +60,7 @@ spring:
logging:
level:
root: info
root: error
# org.jooq: debug
# org.springframework.amqp: debug
# org.mybatis: debug

View File

@ -15,7 +15,7 @@ spring:
# password:
# hikari:
# driver-class-name: org.h2.Driver
url: jdbc:mariadb://106.53.186.11:3306/finance
url: jdbc:mariadb://119.45.61.64:3306/finance
username: root
password: open123
hikari:

View File

@ -3,7 +3,7 @@
<jdbc>
<driver>org.mariadb.jdbc.Driver</driver>
<url>jdbc:mariadb://106.53.186.11:3306/finance</url>
<url>jdbc:mariadb://119.45.61.64:3306/finance</url>
<user>root</user>
<password>open123</password>
<!--<driver>org.h2.Driver</driver>

View File

@ -34,7 +34,7 @@
<!-- nullCatalogMeansCurrent对mariadb 不起作用,会查出所有的非表对象 -->
<jdbcConnection driverClass="org.mariadb.jdbc.Driver" connectionURL="jdbc:mariadb://106.53.186.11:3306/finance" userId="root" password="open123">
<jdbcConnection driverClass="org.mariadb.jdbc.Driver" connectionURL="jdbc:mariadb://119.45.61.64:3306/finance" userId="root" password="open123">
<property name="nullCatalogMeansCurrent" value="true" />
</jdbcConnection>

View File

@ -13,7 +13,7 @@ spring:
password:
hikari:
driver-class-name: org.h2.Driver
# url: jdbc:mariadb://173.249.203.214:3306/test
# url: jdbc:mariadb://119.45.61.64:3306/test
# username: root
# password: open123
# hikari: