feat: 智聪记账管理,期货同步功能修改。
This commit is contained in:
@@ -77,7 +77,7 @@ public interface RemoteInvestService
|
||||
public R appointmentResults();
|
||||
|
||||
/**
|
||||
* 更新未出信用卡分期账单入账数据
|
||||
* 同步当日股票日行情
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@@ -85,4 +85,13 @@ public interface RemoteInvestService
|
||||
public R synStocksDailyHistory();
|
||||
|
||||
|
||||
/**
|
||||
* 同步当日期货日行情
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@RequestMapping(value = "/job/synFuturesDailyHistory",method = RequestMethod.POST)
|
||||
public R synFuturesDailyHistory();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -69,6 +69,11 @@ public class RemoteInvestFallbackFactory implements FallbackFactory<RemoteInvest
|
||||
return R.fail("投资服务调用同步股票日行情数据失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public R synFuturesDailyHistory() {
|
||||
return R.fail("投资服务调用同步期货日行情数据失败");
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,30 +1,25 @@
|
||||
package com.intc.invest.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.intc.common.core.utils.poi.ExcelUtil;
|
||||
import com.intc.common.core.web.controller.BaseController;
|
||||
import com.intc.common.core.web.domain.AjaxResult;
|
||||
import com.intc.common.core.web.page.TableDataInfo;
|
||||
import com.intc.common.log.annotation.Log;
|
||||
import com.intc.common.log.enums.BusinessType;
|
||||
import com.intc.common.security.annotation.RequiresPermissions;
|
||||
import com.intc.invest.domain.FuturesDailyHistory;
|
||||
import com.intc.invest.domain.vo.FuturesDailyHistoryVo;
|
||||
import com.intc.invest.domain.TuShare;
|
||||
import com.intc.invest.domain.TuShareParams;
|
||||
import com.intc.invest.domain.dto.FuturesDailyHistoryDto;
|
||||
import com.intc.invest.domain.vo.FuturesDailyHistoryVo;
|
||||
import com.intc.invest.service.IFuturesDailyHistoryService;
|
||||
import com.intc.common.core.web.controller.BaseController;
|
||||
import com.intc.common.core.web.domain.AjaxResult;
|
||||
import com.intc.common.core.utils.poi.ExcelUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import com.intc.common.core.web.page.TableDataInfo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 期货日行情历史Controller
|
||||
@@ -113,4 +108,20 @@ public class FuturesDailyHistoryController extends BaseController
|
||||
{
|
||||
return toAjax(futuresDailyHistoryService.deleteFuturesDailyHistoryByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步期货日行情历史数据
|
||||
*/
|
||||
@ApiOperation(value="同步期货日行情历史数据",response = TuShareParams.class)
|
||||
// @RequiresPermissions("invest:stocksDailyHistory:list")
|
||||
@GetMapping("/synFuturesDailyHistory")
|
||||
public AjaxResult list(TuShareParams tuShareParams)
|
||||
{
|
||||
TuShare tuShare = new TuShare();
|
||||
tuShareParams.setEnd_date(tuShareParams.getEnd_date().replaceAll("-",""));
|
||||
tuShareParams.setStart_date(tuShareParams.getStart_date().replaceAll("-",""));
|
||||
tuShare.setParams(tuShareParams);
|
||||
futuresDailyHistoryService.synFuturesDailyHistory(tuShare);
|
||||
return success("同步成功!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.intc.invest.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.intc.common.core.annotation.Excel;
|
||||
import com.intc.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
@@ -7,6 +8,9 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 期货日行情历史对象 futures_daily_history
|
||||
*
|
||||
@@ -22,6 +26,9 @@ public class FuturesDailyHistory extends BaseEntity
|
||||
/** 主键 */
|
||||
private Long id;
|
||||
|
||||
/** 股票 */
|
||||
private Long futureId;
|
||||
|
||||
/** TS合约代码 */
|
||||
@ApiModelProperty(value="TS合约代码")
|
||||
@Excel(name = "TS合约代码")
|
||||
@@ -29,78 +36,79 @@ public class FuturesDailyHistory extends BaseEntity
|
||||
|
||||
/** 交易日期 */
|
||||
@ApiModelProperty(value="交易日期")
|
||||
@Excel(name = "交易日期")
|
||||
private String tradeDate;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "交易日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date tradeDate;
|
||||
|
||||
/** 昨收盘价 */
|
||||
@ApiModelProperty(value="昨收盘价")
|
||||
@Excel(name = "昨收盘价")
|
||||
private String preClose;
|
||||
private Double preClose;
|
||||
|
||||
/** 昨结算价 */
|
||||
@ApiModelProperty(value="昨结算价")
|
||||
@Excel(name = "昨结算价")
|
||||
private String preSettle;
|
||||
private Double preSettle;
|
||||
|
||||
/** 开盘价 */
|
||||
@ApiModelProperty(value="开盘价")
|
||||
@Excel(name = "开盘价")
|
||||
private String open;
|
||||
private Double open;
|
||||
|
||||
/** 最高价 */
|
||||
@ApiModelProperty(value="最高价")
|
||||
@Excel(name = "最高价")
|
||||
private String high;
|
||||
private Double high;
|
||||
|
||||
/** 最低价 */
|
||||
@ApiModelProperty(value="最低价")
|
||||
@Excel(name = "最低价")
|
||||
private String low;
|
||||
private Double low;
|
||||
|
||||
/** 收盘价 */
|
||||
@ApiModelProperty(value="收盘价")
|
||||
@Excel(name = "收盘价")
|
||||
private String close;
|
||||
private Double close;
|
||||
|
||||
/** 结算价 */
|
||||
@ApiModelProperty(value="结算价")
|
||||
@Excel(name = "结算价")
|
||||
private String settle;
|
||||
private Double settle;
|
||||
|
||||
/** 收盘价涨跌 */
|
||||
@ApiModelProperty(value="收盘价涨跌")
|
||||
@Excel(name = "收盘价涨跌")
|
||||
private String change1;
|
||||
private Double change1;
|
||||
|
||||
/** 成交量(手) */
|
||||
@ApiModelProperty(value="成交量(手)")
|
||||
@Excel(name = "成交量(手)")
|
||||
private String vol;
|
||||
private Double vol;
|
||||
|
||||
/** 成交金额(万元) */
|
||||
@ApiModelProperty(value="成交金额(万元)")
|
||||
@Excel(name = "成交金额(万元)")
|
||||
private String amount;
|
||||
private Double amount;
|
||||
|
||||
/** 结算价涨跌 */
|
||||
@ApiModelProperty(value="结算价涨跌")
|
||||
@Excel(name = "结算价涨跌")
|
||||
private String change2;
|
||||
private Double change2;
|
||||
|
||||
/** 持仓量(手) */
|
||||
@ApiModelProperty(value="持仓量(手)")
|
||||
@Excel(name = "持仓量(手)")
|
||||
private String oi;
|
||||
private Double oi;
|
||||
|
||||
/** 持仓量变化 */
|
||||
@ApiModelProperty(value="持仓量变化")
|
||||
@Excel(name = "持仓量变化")
|
||||
private String oiChg;
|
||||
private Double oiChg;
|
||||
|
||||
/** 交割结算价 */
|
||||
@ApiModelProperty(value="交割结算价")
|
||||
@Excel(name = "交割结算价")
|
||||
private String delvSettle;
|
||||
private Double delvSettle;
|
||||
|
||||
/** 删除标志(0代表存在 1代表删除) */
|
||||
private String delFlag;
|
||||
@@ -131,6 +139,7 @@ public class FuturesDailyHistory extends BaseEntity
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("futureId", getFutureId())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.intc.invest.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 期货日行情历史Dto对象 futures_daily_history
|
||||
*
|
||||
@@ -22,7 +25,7 @@ public class FuturesDailyHistoryDto implements Serializable
|
||||
|
||||
/** 交易日期 */
|
||||
@ApiModelProperty(value="交易日期")
|
||||
private String tradeDate;
|
||||
private Date tradeDate;
|
||||
|
||||
/** 昨收盘价 */
|
||||
@ApiModelProperty(value="昨收盘价")
|
||||
@@ -80,4 +83,13 @@ public class FuturesDailyHistoryDto implements Serializable
|
||||
@ApiModelProperty(value="交割结算价")
|
||||
private String delvSettle;
|
||||
|
||||
|
||||
/** 交易类别 */
|
||||
@ApiModelProperty(value="开始日期")
|
||||
private String startTime;
|
||||
|
||||
/** 交易类别 */
|
||||
@ApiModelProperty(value="结束日期")
|
||||
private String endTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -13,5 +13,9 @@ import io.swagger.annotations.ApiModel;
|
||||
@Data
|
||||
public class FuturesDailyHistoryVo extends FuturesDailyHistory
|
||||
{
|
||||
private String futureName;
|
||||
|
||||
private String pctChgName;
|
||||
|
||||
private String exchangeName;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.intc.invest.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.intc.invest.domain.FuturesDailyHistory;
|
||||
import com.intc.invest.domain.dto.FuturesDailyHistoryDto;
|
||||
import com.intc.invest.domain.vo.FuturesDailyHistoryVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 期货日行情历史Mapper接口
|
||||
*
|
||||
@@ -76,4 +77,12 @@ public interface FuturesDailyHistoryMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int removeFuturesDailyHistoryByIds(String[] ids);
|
||||
|
||||
/**
|
||||
* 批量插入信息
|
||||
*
|
||||
* @param futuresDailyHistory
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchInsertFuturesDailyHistory(List<FuturesDailyHistory> futuresDailyHistory);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.intc.invest.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.intc.invest.domain.FuturesDailyHistory;
|
||||
import com.intc.invest.domain.TuShare;
|
||||
import com.intc.invest.domain.dto.FuturesDailyHistoryDto;
|
||||
import com.intc.invest.domain.vo.FuturesDailyHistoryVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 期货日行情历史Service接口
|
||||
*
|
||||
@@ -60,4 +62,19 @@ public interface IFuturesDailyHistoryService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteFuturesDailyHistoryById(String id);
|
||||
|
||||
/**
|
||||
* 同步期货日行情历史信息
|
||||
*
|
||||
* @param tuShare 股票日行情历史
|
||||
* @return 结果
|
||||
*/
|
||||
public void synFuturesDailyHistory(TuShare tuShare);
|
||||
|
||||
/**
|
||||
* 同步当日期货日行情历史信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public void synTodayFuturesDailyHistory();
|
||||
}
|
||||
|
||||
@@ -1,17 +1,32 @@
|
||||
package com.intc.invest.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.JsonObject;
|
||||
import com.intc.common.core.utils.DateUtils;
|
||||
import com.intc.common.core.utils.IdWorker;
|
||||
import com.intc.common.core.utils.http.HttpUtils;
|
||||
import com.intc.common.security.utils.SecurityUtils;
|
||||
import com.intc.invest.domain.FuturesDailyHistory;
|
||||
import com.intc.invest.domain.TuShare;
|
||||
import com.intc.invest.domain.TuShareData;
|
||||
import com.intc.invest.domain.TuShareParams;
|
||||
import com.intc.invest.domain.dto.FutureBaseInforDto;
|
||||
import com.intc.invest.domain.dto.FuturesDailyHistoryDto;
|
||||
import com.intc.invest.domain.vo.FutureBaseInforVo;
|
||||
import com.intc.invest.domain.vo.FuturesDailyHistoryVo;
|
||||
import com.intc.invest.mapper.FutureBaseInforMapper;
|
||||
import com.intc.invest.mapper.FuturesDailyHistoryMapper;
|
||||
import com.intc.invest.service.IFuturesDailyHistoryService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 期货日行情历史Service业务层处理
|
||||
@@ -24,6 +39,14 @@ public class FuturesDailyHistoryServiceImpl implements IFuturesDailyHistoryServi
|
||||
{
|
||||
@Resource
|
||||
private FuturesDailyHistoryMapper futuresDailyHistoryMapper;
|
||||
@Resource
|
||||
private FutureBaseInforMapper futureBaseInforMapper;
|
||||
|
||||
@Value("${config.tushareUrl}")
|
||||
private String tushareUrl;
|
||||
|
||||
@Value("${config.tushareToken}")
|
||||
private String tushareToken;
|
||||
|
||||
/**
|
||||
* 查询期货日行情历史
|
||||
@@ -46,7 +69,13 @@ public class FuturesDailyHistoryServiceImpl implements IFuturesDailyHistoryServi
|
||||
@Override
|
||||
public List<FuturesDailyHistoryVo> selectFuturesDailyHistoryList(FuturesDailyHistoryDto futuresDailyHistoryDto)
|
||||
{
|
||||
return futuresDailyHistoryMapper.selectFuturesDailyHistoryList(futuresDailyHistoryDto);
|
||||
List<FuturesDailyHistoryVo> list = futuresDailyHistoryMapper.selectFuturesDailyHistoryList(futuresDailyHistoryDto);
|
||||
DecimalFormat decimalFormat = new DecimalFormat("#.##");
|
||||
for (FuturesDailyHistoryVo vo: list) {
|
||||
String pctChgName=decimalFormat.format(vo.getChange1()*100/vo.getPreSettle());
|
||||
vo.setPctChgName(pctChgName+"%");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +116,7 @@ public class FuturesDailyHistoryServiceImpl implements IFuturesDailyHistoryServi
|
||||
@Override
|
||||
public int deleteFuturesDailyHistoryByIds(String[] ids)
|
||||
{
|
||||
return futuresDailyHistoryMapper.removeFuturesDailyHistoryByIds(ids);
|
||||
return futuresDailyHistoryMapper.deleteFuturesDailyHistoryByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,4 +130,132 @@ public class FuturesDailyHistoryServiceImpl implements IFuturesDailyHistoryServi
|
||||
{
|
||||
return futuresDailyHistoryMapper.removeFuturesDailyHistoryById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步股票日行情历史
|
||||
*
|
||||
* @param tuShare 需要删除的股票日行情历史主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public void synFuturesDailyHistory(TuShare tuShare) {
|
||||
|
||||
tuShare.setToken(tushareToken);
|
||||
tuShare.setApi_name("fut_daily");
|
||||
Gson gson = new Gson();
|
||||
JsonObject json = gson.toJsonTree(tuShare).getAsJsonObject();
|
||||
Map<String, String> headers = new HashMap<String, String>();
|
||||
headers.put("X-Ca-Signature-Headers", "x-ca-key,x-ca-timestamp");
|
||||
String returnString = HttpUtils.sendSSLPost(tushareUrl, null, JSONObject.parseObject(json.toString()), headers);
|
||||
com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(returnString);
|
||||
TuShareData data = JSON.parseObject(jsonObject.getString("data"), TuShareData.class);
|
||||
List<List<String>> itemList = data.getItems();
|
||||
List<FuturesDailyHistory> futuresDailyHistoryList = new ArrayList<>();
|
||||
for (List<String> item : itemList) {
|
||||
FuturesDailyHistory futuresDailyHistory = getFuturesDailyHistory(item,tuShare.getParams());
|
||||
futuresDailyHistoryList.add(futuresDailyHistory);
|
||||
}
|
||||
//批量插入数据
|
||||
if(futuresDailyHistoryList.size()>0){
|
||||
futuresDailyHistoryMapper.batchInsertFuturesDailyHistory(futuresDailyHistoryList);
|
||||
}
|
||||
}
|
||||
|
||||
private static FuturesDailyHistory getFuturesDailyHistory(List<String> item, TuShareParams tuShareParams) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
|
||||
FuturesDailyHistory futuresDailyHistory = new FuturesDailyHistory();
|
||||
futuresDailyHistory.setId(IdWorker.getId());
|
||||
futuresDailyHistory.setFutureId(tuShareParams.getTs_id());
|
||||
futuresDailyHistory.setCreateBy(SecurityUtils.getUsername());
|
||||
futuresDailyHistory.setCreateTime(DateUtils.getNowDate());
|
||||
futuresDailyHistory.setTsCode(item.get(0));
|
||||
try {
|
||||
futuresDailyHistory.setTradeDate(dateFormat.parse(item.get(1)));
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if(item.get(2)!=null){
|
||||
futuresDailyHistory.setPreClose(Double.parseDouble(item.get(2)));
|
||||
}
|
||||
if(item.get(3)!=null){
|
||||
futuresDailyHistory.setPreSettle(Double.parseDouble(item.get(3)));
|
||||
}
|
||||
if(item.get(4)!=null){
|
||||
futuresDailyHistory.setOpen(Double.parseDouble(item.get(4)));
|
||||
}
|
||||
if(item.get(5)!=null){
|
||||
futuresDailyHistory.setHigh(Double.parseDouble(item.get(5)));
|
||||
}
|
||||
if(item.get(6)!=null){
|
||||
futuresDailyHistory.setLow(Double.parseDouble(item.get(6)));
|
||||
}
|
||||
if(item.get(7)!=null){
|
||||
futuresDailyHistory.setClose(Double.parseDouble(item.get(7)));
|
||||
}
|
||||
if(item.get(8)!=null){
|
||||
futuresDailyHistory.setSettle(Double.parseDouble(item.get(8)));
|
||||
}
|
||||
if(item.get(9)!=null){
|
||||
futuresDailyHistory.setChange1(Double.parseDouble(item.get(9)));
|
||||
}
|
||||
if(item.get(10)!=null){
|
||||
futuresDailyHistory.setChange2(Double.parseDouble(item.get(10)));
|
||||
}
|
||||
|
||||
if(item.get(11)!=null){
|
||||
futuresDailyHistory.setVol(Double.parseDouble(item.get(11)));
|
||||
}
|
||||
if(item.get(12)!=null){
|
||||
futuresDailyHistory.setAmount(Double.parseDouble(item.get(12)));
|
||||
}
|
||||
if(item.get(13)!=null){
|
||||
futuresDailyHistory.setOi(Double.parseDouble(item.get(13)));
|
||||
}
|
||||
if(item.get(14)!=null){
|
||||
futuresDailyHistory.setOiChg(Double.parseDouble(item.get(14)));
|
||||
}
|
||||
return futuresDailyHistory;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 同步当天股票日行情历史
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public void synTodayFuturesDailyHistory() {
|
||||
List<FutureBaseInforVo> futureBaseInforVos=futureBaseInforMapper.selectFutureBaseInforList(new FutureBaseInforDto());
|
||||
//
|
||||
for (FutureBaseInforVo base : futureBaseInforVos) {
|
||||
TuShare tuShare = new TuShare();
|
||||
tuShare.setToken(tushareToken);
|
||||
tuShare.setApi_name("fut_daily");
|
||||
TuShareParams tuShareParams = new TuShareParams();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
|
||||
tuShareParams.setTs_code(base.getTsCode());
|
||||
tuShareParams.setTs_id(base.getId());
|
||||
tuShareParams.setStart_date(dateFormat.format(new Date()));
|
||||
tuShareParams.setEnd_date(dateFormat.format(new Date()));
|
||||
tuShare.setParams(tuShareParams);
|
||||
Gson gson = new Gson();
|
||||
JsonObject json = gson.toJsonTree(tuShare).getAsJsonObject();
|
||||
Map<String, String> headers = new HashMap<String, String>();
|
||||
headers.put("X-Ca-Signature-Headers", "x-ca-key,x-ca-timestamp");
|
||||
String returnString = HttpUtils.sendSSLPost(tushareUrl, null, JSONObject.parseObject(json.toString()), headers);
|
||||
com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(returnString);
|
||||
TuShareData data = JSON.parseObject(jsonObject.getString("data"), TuShareData.class);
|
||||
List<List<String>> itemList = data.getItems();
|
||||
List<FuturesDailyHistory> futuresDailyHistoryList = new ArrayList<>();
|
||||
for (List<String> item : itemList) {
|
||||
FuturesDailyHistory futuresDailyHistory = getFuturesDailyHistory(item,tuShare.getParams());
|
||||
futuresDailyHistoryList.add(futuresDailyHistory);
|
||||
}
|
||||
//批量插入数据
|
||||
if(futuresDailyHistoryList.size()>0){
|
||||
futuresDailyHistoryMapper.batchInsertFuturesDailyHistory(futuresDailyHistoryList);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class StocksDailyHistoryServiceImpl implements IStocksDailyHistoryService
|
||||
*/
|
||||
@Override
|
||||
public int deleteStocksDailyHistoryByIds(Long[] ids) {
|
||||
return stocksDailyHistoryMapper.removeStocksDailyHistoryByIds(ids);
|
||||
return stocksDailyHistoryMapper.deleteStocksDailyHistoryByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.intc.job.controller;
|
||||
|
||||
import com.intc.common.core.utils.DateUtils;
|
||||
import com.intc.common.core.web.domain.AjaxResult;
|
||||
import com.intc.invest.service.IFuturesDailyHistoryService;
|
||||
import com.intc.invest.service.IMTService;
|
||||
import com.intc.invest.service.IStocksDailyHistoryService;
|
||||
import com.intc.invest.service.IUserService;
|
||||
@@ -34,6 +35,9 @@ public class InvestJob
|
||||
@Resource
|
||||
private IStocksDailyHistoryService stocksDailyHistoryService;
|
||||
|
||||
@Resource
|
||||
private IFuturesDailyHistoryService futuresDailyHistoryService;
|
||||
|
||||
@PostMapping("/generateUnpaidCreditBill")
|
||||
public AjaxResult generateUnpaidCreditBill()
|
||||
{
|
||||
@@ -134,6 +138,18 @@ public class InvestJob
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步当日期货日数据
|
||||
*/
|
||||
@PostMapping("/synFuturesDailyHistory")
|
||||
public AjaxResult synTodayFuturesDailyHistory()
|
||||
{
|
||||
System.out.println("================================开始同步当天期货日行情数据("+ DateUtils.getTime() +")=================================");
|
||||
futuresDailyHistoryService.synTodayFuturesDailyHistory();
|
||||
System.out.println("================================结束同步当天期货日行情数据("+ DateUtils.getTime() +")=================================");
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -28,17 +28,61 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="futureId" column="future_id" />
|
||||
<result property="futureName" column="future_name" />
|
||||
<result property="exchangeName" column="exchange_name" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectFuturesDailyHistoryVo">
|
||||
select a.id, a.ts_code, a.trade_date, a.pre_close, a.pre_settle, a.open, a.high, a.low, a.close, a.settle, a.change1, a.vol, a.amount, a.change2, a.oi, a.oi_chg, a.delv_settle, a.remark, a.create_by, a.create_time, a.update_by, a.update_time, a.del_flag from futures_daily_history a
|
||||
select
|
||||
a.id,
|
||||
a.ts_code,
|
||||
a.trade_date,
|
||||
a.future_id,
|
||||
a.pre_close,
|
||||
a.pre_settle,
|
||||
a.open,
|
||||
a.high,
|
||||
a.low,
|
||||
a.close,
|
||||
a.settle,
|
||||
a.change1,
|
||||
a.vol,
|
||||
a.amount,
|
||||
a.change2,
|
||||
a.oi,
|
||||
a.oi_chg,
|
||||
a.delv_settle,
|
||||
a.remark,
|
||||
a.create_by,
|
||||
a.create_time,
|
||||
a.update_by,
|
||||
a.update_time,
|
||||
a.del_flag,
|
||||
ifbi.name as future_name,
|
||||
ie.short_name as exchange_name
|
||||
from
|
||||
futures_daily_history a
|
||||
left join invest_future_base_infor ifbi on
|
||||
ifbi.id = a.future_id
|
||||
left join invest_future_standard_infor ifsi on
|
||||
ifsi.id = ifbi.standard_id
|
||||
left join invest_exchange ie on
|
||||
ie.id = ifsi.exchange_id
|
||||
</sql>
|
||||
|
||||
<select id="selectFuturesDailyHistoryList" parameterType="FuturesDailyHistoryDto" resultMap="FuturesDailyHistoryResult">
|
||||
<include refid="selectFuturesDailyHistoryVo"/>
|
||||
<where>
|
||||
a.del_flag='0'
|
||||
<if test="tsCode != null and tsCode != ''"> and a.ts_code = #{tsCode}</if>
|
||||
<if test="tsCode != null and tsCode != ''"> and (a.ts_code like '%'|| #{tsCode}||'%' or ifbi.name like '%'|| #{tsCode}||'%')</if>
|
||||
|
||||
<if test="endTime!=null and endTime !=''">
|
||||
and #{endTime}>=to_char(a.trade_date, 'yyyy-MM-dd')
|
||||
</if>
|
||||
<if test="startTime!=null and startTime !=''">
|
||||
and to_char(a.trade_date, 'yyyy-MM-dd')>=#{startTime}
|
||||
</if>
|
||||
<if test="tradeDate != null and tradeDate != ''"> and a.trade_date = #{tradeDate}</if>
|
||||
<if test="preClose != null and preClose != ''"> and a.pre_close = #{preClose}</if>
|
||||
<if test="preSettle != null and preSettle != ''"> and a.pre_settle = #{preSettle}</if>
|
||||
@@ -55,7 +99,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="oiChg != null and oiChg != ''"> and a.oi_chg = #{oiChg}</if>
|
||||
<if test="delvSettle != null and delvSettle != ''"> and a.delv_settle = #{delvSettle}</if>
|
||||
</where>
|
||||
order by a.create_time desc
|
||||
order by a.trade_date desc,a.ts_code
|
||||
</select>
|
||||
|
||||
<select id="selectFuturesDailyHistoryById" parameterType="String" resultMap="FuturesDailyHistoryResult">
|
||||
@@ -89,6 +133,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="futureId != null">future_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
@@ -114,6 +159,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="futureId != null">#{futureId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -142,6 +188,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="futureId != null">future_id = #{futureId},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
@@ -166,4 +213,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
<insert id="batchInsertFuturesDailyHistory">
|
||||
insert into futures_daily_history(id, future_id, ts_code, trade_date,pre_close,pre_settle, open, high, low, close, settle, change1, change2, vol, amount, oi, oi_chg, delv_settle, remark, create_by, create_time, update_by, update_time) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
(#{item.id},
|
||||
#{item.futureId},
|
||||
#{item.tsCode},
|
||||
#{item.tradeDate},
|
||||
#{item.preClose},
|
||||
#{item.preSettle},
|
||||
#{item.open},
|
||||
#{item.high},
|
||||
#{item.low},
|
||||
#{item.close},
|
||||
#{item.settle},
|
||||
#{item.change1},
|
||||
#{item.change2},
|
||||
#{item.vol},
|
||||
#{item.amount},
|
||||
#{item.oi},
|
||||
#{item.oiChg},
|
||||
#{item.delvSettle},
|
||||
#{item.remark},
|
||||
#{item.createBy},
|
||||
#{item.createTime},
|
||||
#{item.updateBy},
|
||||
#{item.updateTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
|
||||
@@ -81,5 +81,12 @@ public class InvestJobTask
|
||||
System.out.println("================================结束同步股票日行情数据("+ DateUtils.getTime() +")=================================");
|
||||
}
|
||||
|
||||
/**同步期货日数据*/
|
||||
public void synFuturesDailyHistory(){
|
||||
System.out.println("================================开始同步期货日行情数据("+ DateUtils.getTime() +")=================================");
|
||||
remoteInvestService.synFuturesDailyHistory();
|
||||
System.out.println("================================结束同步期货日行情数据("+ DateUtils.getTime() +")=================================");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user