|
@@ -0,0 +1,422 @@
|
|
|
|
+package com.zx.dataservice.service.impl;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.zx.dataservice.mapper1.ChoiceStockMapper;
|
|
|
|
+import com.zx.dataservice.mapper2.StockMapper;
|
|
|
|
+import com.zx.dataservice.mapper3.ChoiceBondMapper;
|
|
|
|
+import com.zx.dataservice.pojo.StockPojo;
|
|
|
|
+import com.zx.dataservice.pojo.StockRestPojo;
|
|
|
|
+import com.zx.dataservice.service.ChoService;
|
|
|
|
+import com.zx.dataservice.utils.HttpRequest;
|
|
|
|
+import com.zx.dataservice.utils.TimeUtil;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
+@Service
|
|
|
|
+public class ChoServiceImpl implements ChoService {
|
|
|
|
+
|
|
|
|
+ private static final String url = "http://huarongjgb.com/lucene/updateInfo.do";
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private StockMapper stockMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ChoiceStockMapper choiceStockMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ChoiceBondMapper choiceBondMapper;
|
|
|
|
+
|
|
|
|
+ private BigDecimal random(){
|
|
|
|
+ Random rd = new Random();
|
|
|
|
+ BigDecimal returnNum = new BigDecimal((rd.nextDouble() * 100) / 100);
|
|
|
|
+ int i = ((int)(10 * Math.random())) % 2;
|
|
|
|
+ if(0 == i){
|
|
|
|
+ return BigDecimal.ZERO.subtract(returnNum).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ }
|
|
|
|
+ return returnNum.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private int randomInt(){
|
|
|
|
+ Random r = new Random(1);
|
|
|
|
+ int max = 10, min1 = 5;
|
|
|
|
+ int ran1 = (int) (Math.random() * (max - min1) + min1);
|
|
|
|
+ return ran1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void insertRtStock() {
|
|
|
|
+ String code = "897689.SH";
|
|
|
|
+ String gid = "sh897689";
|
|
|
|
+ String now = "8.66";
|
|
|
|
+ String tableName = "data_rt_897689_sh";
|
|
|
|
+ Integer stockCount = stockMapper.selectStockByStockCode(code);
|
|
|
|
+ if(0 == stockCount || null == stockCount){
|
|
|
|
+ StockPojo stockPojo = new StockPojo();
|
|
|
|
+ stockPojo.setStockName("测试新股4");
|
|
|
|
+ stockPojo.setStockCode(code);
|
|
|
|
+ stockPojo.setStockSpell("csxg4");
|
|
|
|
+ stockPojo.setStockType("sh");
|
|
|
|
+ stockPojo.setStockGid(gid);
|
|
|
|
+ stockPojo.setStockPlate("普通");
|
|
|
|
+ stockPojo.setIsLock(0);
|
|
|
|
+ stockPojo.setIsShow(0);
|
|
|
|
+ stockPojo.setBuyLimit(1);
|
|
|
|
+ stockPojo.setStockOrBond(0);
|
|
|
|
+ stockMapper.insertStock(stockPojo);
|
|
|
|
+ }
|
|
|
|
+ Date d = new Date();
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
+ SimpleDateFormat sdf1 = new SimpleDateFormat("HHmmss");
|
|
|
|
+ String dateNowStr = sdf.format(d);
|
|
|
|
+ String dateNowStr1 = sdf1.format(d);
|
|
|
|
+ StockRestPojo entry = choiceStockMapper.selectRtLimitOne(tableName);
|
|
|
|
+ if(null == entry){
|
|
|
|
+ entry = new StockRestPojo();
|
|
|
|
+ entry.setCode(code);
|
|
|
|
+ entry.setNow(now);
|
|
|
|
+ entry.setHigh(now);
|
|
|
|
+ entry.setLow(now);
|
|
|
|
+ entry.setOpen(now);
|
|
|
|
+ entry.setPreclose(now);
|
|
|
|
+ entry.setRoundlot("0");
|
|
|
|
+ entry.setChange("0");
|
|
|
|
+ entry.setPctchange("0");
|
|
|
|
+ entry.setVolume("1000");
|
|
|
|
+ entry.setAmount("1000");
|
|
|
|
+ entry.setVolumeratio("0");
|
|
|
|
+ entry.setCommissionratio("0");
|
|
|
|
+ entry.setCommissiondiff("0");
|
|
|
|
+ entry.setTradestatus("0");
|
|
|
|
+ entry.setOutvolume("0");
|
|
|
|
+ entry.setInvolume("0");
|
|
|
|
+ entry.setHighlimit("0");
|
|
|
|
+ entry.setLowlimit("0");
|
|
|
|
+ entry.setSpeed("0");
|
|
|
|
+ entry.setAverageprice("0");
|
|
|
|
+ entry.setBuyprice1(now);
|
|
|
|
+ entry.setBuyprice2(now);
|
|
|
|
+ entry.setBuyprice3(now);
|
|
|
|
+ entry.setBuyprice4(now);
|
|
|
|
+ entry.setBuyprice5(now);
|
|
|
|
+ entry.setBuyvolume1("1000");
|
|
|
|
+ entry.setBuyvolume2("1000");
|
|
|
|
+ entry.setBuyvolume3("1000");
|
|
|
|
+ entry.setBuyvolume4("1000");
|
|
|
|
+ entry.setBuyvolume5("1000");
|
|
|
|
+ entry.setSellprice1(now);
|
|
|
|
+ entry.setSellprice2(now);
|
|
|
|
+ entry.setSellprice3(now);
|
|
|
|
+ entry.setSellprice4(now);
|
|
|
|
+ entry.setSellprice5(now);
|
|
|
|
+ entry.setSellvolume1("1000");
|
|
|
|
+ entry.setSellvolume2("1000");
|
|
|
|
+ entry.setSellvolume3("1000");
|
|
|
|
+ entry.setSellvolume4("1000");
|
|
|
|
+ entry.setSellvolume5("1000");
|
|
|
|
+ entry.setClosedtime("0");
|
|
|
|
+ entry.setClosedvolume("0");
|
|
|
|
+ entry.setClosedamount("0");
|
|
|
|
+ }
|
|
|
|
+ StockRestPojo stockRestPojo = new StockRestPojo();
|
|
|
|
+ stockRestPojo.setDate(dateNowStr);
|
|
|
|
+ stockRestPojo.setTime(dateNowStr1);
|
|
|
|
+ stockRestPojo.setNow(String.valueOf(new BigDecimal(entry.getNow()).add(random())));
|
|
|
|
+ stockRestPojo.setHigh(String.valueOf(new BigDecimal(entry.getHigh()).add(random())));
|
|
|
|
+ stockRestPojo.setLow(String.valueOf(new BigDecimal(entry.getLow()).add(random())));
|
|
|
|
+ stockRestPojo.setOpen(String.valueOf(new BigDecimal(entry.getOpen()).add(random())));
|
|
|
|
+ stockRestPojo.setPreclose(String.valueOf(new BigDecimal(entry.getPctchange()).add(random())));
|
|
|
|
+ stockRestPojo.setRoundlot(String.valueOf(new BigDecimal(entry.getRoundlot()).add(random())));
|
|
|
|
+ stockRestPojo.setChange(String.valueOf(new BigDecimal(entry.getChange()).add(random())));
|
|
|
|
+ stockRestPojo.setPctchange(String.valueOf(new BigDecimal(entry.getPctchange()).add(random())));
|
|
|
|
+ stockRestPojo.setVolume(String.valueOf(new BigDecimal(entry.getVolume()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setAmount(String.valueOf(new BigDecimal(entry.getAmount()).add(random())));
|
|
|
|
+ stockRestPojo.setVolumeratio(String.valueOf(new BigDecimal(entry.getVolumeratio()).add(random())));
|
|
|
|
+ stockRestPojo.setCommissionratio(String.valueOf(new BigDecimal(entry.getCommissionratio()).add(random())));
|
|
|
|
+ stockRestPojo.setCommissiondiff(String.valueOf(new BigDecimal(entry.getCommissiondiff()).add(random())));
|
|
|
|
+ stockRestPojo.setTradestatus(String.valueOf(new BigDecimal(entry.getTradestatus()).add(random())));
|
|
|
|
+ stockRestPojo.setOutvolume(String.valueOf(new BigDecimal(entry.getOutvolume()).add(random())));
|
|
|
|
+ stockRestPojo.setInvolume(String.valueOf(new BigDecimal(entry.getInvolume()).add(random())));
|
|
|
|
+ stockRestPojo.setHighlimit(String.valueOf(new BigDecimal(entry.getHighlimit()).add(random())));
|
|
|
|
+ stockRestPojo.setLowlimit(String.valueOf(new BigDecimal(entry.getLowlimit()).add(random())));
|
|
|
|
+ stockRestPojo.setSpeed(String.valueOf(new BigDecimal(entry.getSpeed()).add(random())));
|
|
|
|
+ stockRestPojo.setAverageprice(String.valueOf(new BigDecimal(entry.getAverageprice()).add(random())));
|
|
|
|
+ stockRestPojo.setBuyprice1(String.valueOf(new BigDecimal(entry.getBuyprice1()).add(random())));
|
|
|
|
+ stockRestPojo.setBuyprice2(String.valueOf(new BigDecimal(entry.getBuyprice2()).add(random())));
|
|
|
|
+ stockRestPojo.setBuyprice3(String.valueOf(new BigDecimal(entry.getBuyprice3()).add(random())));
|
|
|
|
+ stockRestPojo.setBuyprice4(String.valueOf(new BigDecimal(entry.getBuyprice4()).add(random())));
|
|
|
|
+ stockRestPojo.setBuyprice5(String.valueOf(new BigDecimal(entry.getBuyprice5()).add(random())));
|
|
|
|
+ stockRestPojo.setBuyvolume1(String.valueOf(new BigDecimal(entry.getBuyvolume1()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setBuyvolume2(String.valueOf(new BigDecimal(entry.getBuyvolume2()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setBuyvolume3(String.valueOf(new BigDecimal(entry.getBuyvolume3()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setBuyvolume4(String.valueOf(new BigDecimal(entry.getBuyvolume4()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setBuyvolume5(String.valueOf(new BigDecimal(entry.getBuyvolume5()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setSellprice1(String.valueOf(new BigDecimal(entry.getSellprice1()).add(random())));
|
|
|
|
+ stockRestPojo.setSellprice2(String.valueOf(new BigDecimal(entry.getSellprice2()).add(random())));
|
|
|
|
+ stockRestPojo.setSellprice3(String.valueOf(new BigDecimal(entry.getSellprice3()).add(random())));
|
|
|
|
+ stockRestPojo.setSellprice4(String.valueOf(new BigDecimal(entry.getSellprice4()).add(random())));
|
|
|
|
+ stockRestPojo.setSellprice5(String.valueOf(new BigDecimal(entry.getSellprice5()).add(random())));
|
|
|
|
+ stockRestPojo.setSellvolume1(String.valueOf(new BigDecimal(entry.getBuyvolume1()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setSellvolume2(String.valueOf(new BigDecimal(entry.getBuyvolume2()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setSellvolume3(String.valueOf(new BigDecimal(entry.getBuyvolume3()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setSellvolume4(String.valueOf(new BigDecimal(entry.getBuyvolume4()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setSellvolume5(String.valueOf(new BigDecimal(entry.getBuyvolume5()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setClosedtime(String.valueOf(new BigDecimal(entry.getClosedtime()).add(random())));
|
|
|
|
+ stockRestPojo.setClosedvolume(String.valueOf(new BigDecimal(entry.getClosedvolume()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setClosedamount(String.valueOf(new BigDecimal(entry.getClosedamount()).add(random())));
|
|
|
|
+ StringBuffer dateStr = new StringBuffer(stockRestPojo.getDate());
|
|
|
|
+ if (StringUtils.isEmpty(stockRestPojo.getTime())) {
|
|
|
|
+ dateStr = dateStr.append(000000);
|
|
|
|
+ } else {
|
|
|
|
+ if (5 == stockRestPojo.getTime().length()) {
|
|
|
|
+ // 长度为5表示 小时前面需要补0
|
|
|
|
+ dateStr = dateStr.append(0).append(stockRestPojo.getTime());
|
|
|
|
+ } else {
|
|
|
|
+ dateStr = dateStr.append(stockRestPojo.getTime());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Date date = TimeUtil.strToDate(dateStr.toString());
|
|
|
|
+ // 毫秒转成秒
|
|
|
|
+ stockRestPojo.setRealTime(date.getTime() / 1000);
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
+ calendar.setTime(date);
|
|
|
|
+ int min = calendar.get(Calendar.MINUTE); // 获取分钟
|
|
|
|
+ int sec = calendar.get(Calendar.SECOND); // 获取秒数
|
|
|
|
+
|
|
|
|
+ // 1分钟数据
|
|
|
|
+ if (sec != 0) {
|
|
|
|
+ stockRestPojo.setDateOne(stockRestPojo.getRealTime() + 60 - sec);
|
|
|
|
+ } else {
|
|
|
|
+ stockRestPojo.setDateOne(stockRestPojo.getRealTime());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 5分钟数据
|
|
|
|
+ if (sec != 0 || min % 5 != 0) {
|
|
|
|
+ stockRestPojo.setDateFive(stockRestPojo.getRealTime() + (5 * 60) - sec - (min % 5 * 60));
|
|
|
|
+ } else {
|
|
|
|
+ stockRestPojo.setDateFive(stockRestPojo.getRealTime());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 15分钟数据
|
|
|
|
+ if (sec != 0 || min % 15 != 0) {
|
|
|
|
+ stockRestPojo.setDateFifteen(stockRestPojo.getRealTime() + (15 * 60) - sec - (min % 15 * 60));
|
|
|
|
+ } else {
|
|
|
|
+ stockRestPojo.setDateFifteen(stockRestPojo.getRealTime());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 30分钟数据
|
|
|
|
+ if (sec != 0 || min % 30 != 0) {
|
|
|
|
+ stockRestPojo.setDateThirty(stockRestPojo.getRealTime() + (30 * 60) - sec - (min % 30 * 60));
|
|
|
|
+ } else {
|
|
|
|
+ stockRestPojo.setDateThirty(stockRestPojo.getRealTime());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 60分钟数据
|
|
|
|
+ if (sec != 0 || min % 60 != 0) {
|
|
|
|
+ stockRestPojo.setDateSixty(stockRestPojo.getRealTime() + (60 * 60) - sec - (min % 60 * 60));
|
|
|
|
+ } else {
|
|
|
|
+ stockRestPojo.setDateSixty(stockRestPojo.getRealTime());
|
|
|
|
+ }
|
|
|
|
+ stockRestPojo.setCode(code);
|
|
|
|
+ insertStock(stockRestPojo, tableName);
|
|
|
|
+ List<StockRestPojo> list = new ArrayList<>();
|
|
|
|
+ list.add(stockRestPojo);
|
|
|
|
+ stockMapper.updateBatchStockInfo(list);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void insertStock(StockRestPojo stockRestPojo, String tableName) {
|
|
|
|
+ choiceStockMapper.insertRt(stockRestPojo, tableName);
|
|
|
|
+ List<StockRestPojo> list = new ArrayList<>();
|
|
|
|
+ list.add(stockRestPojo);
|
|
|
|
+ Thread thread=new Thread(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ HttpRequest.httpPostWithjson(url, JSON.toJSONString(list));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+// thread.start();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void insertRtBood() {
|
|
|
|
+ String code = "989589.SH";
|
|
|
|
+ String gid = "sh989589";
|
|
|
|
+ String now = "108.66";
|
|
|
|
+ String tableName = "data_rt_989589_sh";
|
|
|
|
+ Integer stockCount = stockMapper.selectStockByStockCode(code);
|
|
|
|
+ if(0 == stockCount || null == stockCount){
|
|
|
|
+ StockPojo stockPojo = new StockPojo();
|
|
|
|
+ stockPojo.setStockName("测试新债4");
|
|
|
|
+ stockPojo.setStockCode(code);
|
|
|
|
+ stockPojo.setStockSpell("csxz4");
|
|
|
|
+ stockPojo.setStockType("sh");
|
|
|
|
+ stockPojo.setStockGid(gid);
|
|
|
|
+ stockPojo.setStockPlate("普通");
|
|
|
|
+ stockPojo.setIsLock(0);
|
|
|
|
+ stockPojo.setIsShow(0);
|
|
|
|
+ stockPojo.setBuyLimit(1);
|
|
|
|
+ stockPojo.setStockOrBond(1);
|
|
|
|
+ stockMapper.insertStock(stockPojo);
|
|
|
|
+ }
|
|
|
|
+ Date d = new Date();
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
+ SimpleDateFormat sdf1 = new SimpleDateFormat("HHmmss");
|
|
|
|
+ String dateNowStr = sdf.format(d);
|
|
|
|
+ String dateNowStr1 = sdf1.format(d);
|
|
|
|
+ StockRestPojo entry = choiceBondMapper.selectRtLimitOne(tableName);
|
|
|
|
+ if(null == entry){
|
|
|
|
+ entry = new StockRestPojo();
|
|
|
|
+ entry.setCode(code);
|
|
|
|
+ entry.setNow(now);
|
|
|
|
+ entry.setHigh(now);
|
|
|
|
+ entry.setLow(now);
|
|
|
|
+ entry.setOpen(now);
|
|
|
|
+ entry.setPreclose(now);
|
|
|
|
+ entry.setRoundlot("0");
|
|
|
|
+ entry.setChange("0");
|
|
|
|
+ entry.setPctchange("0");
|
|
|
|
+ entry.setVolume("1000");
|
|
|
|
+ entry.setAmount("1000");
|
|
|
|
+ entry.setBuyprice1(now);
|
|
|
|
+ entry.setBuyprice2(now);
|
|
|
|
+ entry.setBuyprice3(now);
|
|
|
|
+ entry.setBuyprice4(now);
|
|
|
|
+ entry.setBuyprice5(now);
|
|
|
|
+ entry.setBuyvolume1("1000");
|
|
|
|
+ entry.setBuyvolume2("1000");
|
|
|
|
+ entry.setBuyvolume3("1000");
|
|
|
|
+ entry.setBuyvolume4("1000");
|
|
|
|
+ entry.setBuyvolume5("1000");
|
|
|
|
+ entry.setSellprice1(now);
|
|
|
|
+ entry.setSellprice2(now);
|
|
|
|
+ entry.setSellprice3(now);
|
|
|
|
+ entry.setSellprice4(now);
|
|
|
|
+ entry.setSellprice5(now);
|
|
|
|
+ entry.setSellvolume1("1000");
|
|
|
|
+ entry.setSellvolume2("1000");
|
|
|
|
+ entry.setSellvolume3("1000");
|
|
|
|
+ entry.setSellvolume4("1000");
|
|
|
|
+ entry.setSellvolume5("1000");
|
|
|
|
+ }
|
|
|
|
+ StockRestPojo stockRestPojo = new StockRestPojo();
|
|
|
|
+ stockRestPojo.setDate(dateNowStr);
|
|
|
|
+ stockRestPojo.setTime(dateNowStr1);
|
|
|
|
+ stockRestPojo.setNow(String.valueOf(new BigDecimal(entry.getNow()).add(random())));
|
|
|
|
+ stockRestPojo.setHigh(String.valueOf(new BigDecimal(entry.getHigh()).add(random())));
|
|
|
|
+ stockRestPojo.setLow(String.valueOf(new BigDecimal(entry.getLow()).add(random())));
|
|
|
|
+ stockRestPojo.setOpen(String.valueOf(new BigDecimal(entry.getOpen()).add(random())));
|
|
|
|
+ stockRestPojo.setPreclose(String.valueOf(new BigDecimal(entry.getPctchange()).add(random())));
|
|
|
|
+ stockRestPojo.setRoundlot(String.valueOf(new BigDecimal(entry.getRoundlot()).add(random())));
|
|
|
|
+ stockRestPojo.setChange(String.valueOf(new BigDecimal(entry.getChange()).add(random())));
|
|
|
|
+ stockRestPojo.setPctchange(String.valueOf(new BigDecimal(entry.getPctchange()).add(random())));
|
|
|
|
+ stockRestPojo.setVolume(String.valueOf(new BigDecimal(entry.getVolume()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setAmount(String.valueOf(new BigDecimal(entry.getAmount()).add(random())));
|
|
|
|
+ stockRestPojo.setVolumeratio("");
|
|
|
|
+ stockRestPojo.setCommissionratio("");
|
|
|
|
+ stockRestPojo.setCommissiondiff("");
|
|
|
|
+ stockRestPojo.setTradestatus("");
|
|
|
|
+ stockRestPojo.setOutvolume("");
|
|
|
|
+ stockRestPojo.setInvolume("");
|
|
|
|
+ stockRestPojo.setHighlimit("");
|
|
|
|
+ stockRestPojo.setLowlimit("");
|
|
|
|
+ stockRestPojo.setSpeed("");
|
|
|
|
+ stockRestPojo.setAverageprice("");
|
|
|
|
+ stockRestPojo.setBuyprice1(String.valueOf(new BigDecimal(entry.getBuyprice1()).add(random())));
|
|
|
|
+ stockRestPojo.setBuyprice2(String.valueOf(new BigDecimal(entry.getBuyprice2()).add(random())));
|
|
|
|
+ stockRestPojo.setBuyprice3(String.valueOf(new BigDecimal(entry.getBuyprice3()).add(random())));
|
|
|
|
+ stockRestPojo.setBuyprice4(String.valueOf(new BigDecimal(entry.getBuyprice4()).add(random())));
|
|
|
|
+ stockRestPojo.setBuyprice5(String.valueOf(new BigDecimal(entry.getBuyprice5()).add(random())));
|
|
|
|
+ stockRestPojo.setBuyvolume1(String.valueOf(new BigDecimal(entry.getBuyvolume1()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setBuyvolume2(String.valueOf(new BigDecimal(entry.getBuyvolume2()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setBuyvolume3(String.valueOf(new BigDecimal(entry.getBuyvolume3()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setBuyvolume4(String.valueOf(new BigDecimal(entry.getBuyvolume4()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setBuyvolume5(String.valueOf(new BigDecimal(entry.getBuyvolume5()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setSellprice1(String.valueOf(new BigDecimal(entry.getSellprice1()).add(random())));
|
|
|
|
+ stockRestPojo.setSellprice2(String.valueOf(new BigDecimal(entry.getSellprice2()).add(random())));
|
|
|
|
+ stockRestPojo.setSellprice3(String.valueOf(new BigDecimal(entry.getSellprice3()).add(random())));
|
|
|
|
+ stockRestPojo.setSellprice4(String.valueOf(new BigDecimal(entry.getSellprice4()).add(random())));
|
|
|
|
+ stockRestPojo.setSellprice5(String.valueOf(new BigDecimal(entry.getSellprice5()).add(random())));
|
|
|
|
+ stockRestPojo.setSellvolume1(String.valueOf(new BigDecimal(entry.getBuyvolume1()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setSellvolume2(String.valueOf(new BigDecimal(entry.getBuyvolume2()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setSellvolume3(String.valueOf(new BigDecimal(entry.getBuyvolume3()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setSellvolume4(String.valueOf(new BigDecimal(entry.getBuyvolume4()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setSellvolume5(String.valueOf(new BigDecimal(entry.getBuyvolume5()).add(new BigDecimal(randomInt()))));
|
|
|
|
+ stockRestPojo.setClosedtime("");
|
|
|
|
+ stockRestPojo.setClosedvolume("");
|
|
|
|
+ stockRestPojo.setClosedamount("");
|
|
|
|
+ StringBuffer dateStr = new StringBuffer(stockRestPojo.getDate());
|
|
|
|
+ if (StringUtils.isEmpty(stockRestPojo.getTime())) {
|
|
|
|
+ dateStr = dateStr.append(000000);
|
|
|
|
+ } else {
|
|
|
|
+ if (5 == stockRestPojo.getTime().length()) {
|
|
|
|
+ // 长度为5表示 小时前面需要补0
|
|
|
|
+ dateStr = dateStr.append(0).append(stockRestPojo.getTime());
|
|
|
|
+ } else {
|
|
|
|
+ dateStr = dateStr.append(stockRestPojo.getTime());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Date date = TimeUtil.strToDate(dateStr.toString());
|
|
|
|
+ // 毫秒转成秒
|
|
|
|
+ stockRestPojo.setRealTime(date.getTime() / 1000);
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
+ calendar.setTime(date);
|
|
|
|
+ int min = calendar.get(Calendar.MINUTE); // 获取分钟
|
|
|
|
+ int sec = calendar.get(Calendar.SECOND); // 获取秒数
|
|
|
|
+
|
|
|
|
+ // 1分钟数据
|
|
|
|
+ if (sec != 0) {
|
|
|
|
+ stockRestPojo.setDateOne(stockRestPojo.getRealTime() + 60 - sec);
|
|
|
|
+ } else {
|
|
|
|
+ stockRestPojo.setDateOne(stockRestPojo.getRealTime());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 5分钟数据
|
|
|
|
+ if (sec != 0 || min % 5 != 0) {
|
|
|
|
+ stockRestPojo.setDateFive(stockRestPojo.getRealTime() + (5 * 60) - sec - (min % 5 * 60));
|
|
|
|
+ } else {
|
|
|
|
+ stockRestPojo.setDateFive(stockRestPojo.getRealTime());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 15分钟数据
|
|
|
|
+ if (sec != 0 || min % 15 != 0) {
|
|
|
|
+ stockRestPojo.setDateFifteen(stockRestPojo.getRealTime() + (15 * 60) - sec - (min % 15 * 60));
|
|
|
|
+ } else {
|
|
|
|
+ stockRestPojo.setDateFifteen(stockRestPojo.getRealTime());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 30分钟数据
|
|
|
|
+ if (sec != 0 || min % 30 != 0) {
|
|
|
|
+ stockRestPojo.setDateThirty(stockRestPojo.getRealTime() + (30 * 60) - sec - (min % 30 * 60));
|
|
|
|
+ } else {
|
|
|
|
+ stockRestPojo.setDateThirty(stockRestPojo.getRealTime());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 60分钟数据
|
|
|
|
+ if (sec != 0 || min % 60 != 0) {
|
|
|
|
+ stockRestPojo.setDateSixty(stockRestPojo.getRealTime() + (60 * 60) - sec - (min % 60 * 60));
|
|
|
|
+ } else {
|
|
|
|
+ stockRestPojo.setDateSixty(stockRestPojo.getRealTime());
|
|
|
|
+ }
|
|
|
|
+ stockRestPojo.setCode(code);
|
|
|
|
+ insertListBood(stockRestPojo, tableName);
|
|
|
|
+ List<StockRestPojo> list = new ArrayList<>();
|
|
|
|
+ list.add(stockRestPojo);
|
|
|
|
+ stockMapper.updateBatchStockInfo(list);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void insertListBood(StockRestPojo stockRestPojo, String tableName) {
|
|
|
|
+ choiceBondMapper.insertRt(stockRestPojo, tableName);
|
|
|
|
+ List<StockRestPojo> list = new ArrayList<>();
|
|
|
|
+ list.add(stockRestPojo);
|
|
|
|
+ Thread thread=new Thread(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ HttpRequest.httpPostWithjson(url, JSON.toJSONString(list));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+// thread.start();
|
|
|
|
+ }
|
|
|
|
+}
|