|
@@ -3,6 +3,7 @@ package com.zx.dataservice.service.impl;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.zx.dataservice.controller.WebSocketController;
|
|
|
import com.zx.dataservice.mapper1.ChoiceStockMapper;
|
|
|
+import com.zx.dataservice.options.DataOptions;
|
|
|
import com.zx.dataservice.pojo.StockRestPojo;
|
|
|
import com.zx.dataservice.service.ChoiceTempIndexService;
|
|
|
import com.zx.dataservice.utils.*;
|
|
@@ -49,9 +50,15 @@ public class ChoiceTempIndexServiceImpl implements ChoiceTempIndexService {
|
|
|
List<StockRestPojo> stockRestPojoList = new ArrayList<>();
|
|
|
List<StockRestVO> stockRestVOList = new ArrayList<>();
|
|
|
List<StockRestRedisVO> stockRestRedisVOList = new ArrayList<>();
|
|
|
+ Map<String,List<StockRestRedisVO>>mapws = new HashMap<>();
|
|
|
+ mapws.put("stockRestRedisVO",new ArrayList<>()); // 无风控数据
|
|
|
+ for(String key: DataOptions.keySet()){ // 所有的需要风控的 客户
|
|
|
+ mapws.put("stockRestRedisVO_"+key,new ArrayList<>());
|
|
|
+ }
|
|
|
StockRestPojo stockRestPojo;
|
|
|
StockRestVO stockRestVO;
|
|
|
StockRestRedisVO stockRestRedisVO;
|
|
|
+
|
|
|
for (File file : files){
|
|
|
// 2.移动文件去另外一个文件夹
|
|
|
FileTempIndexUtil.moveFile(sourceFileUrl + File.separator + file.getName(), goalFileUrl);
|
|
@@ -186,7 +193,25 @@ public class ChoiceTempIndexServiceImpl implements ChoiceTempIndexService {
|
|
|
stockRestRedisVO.setHcrate(stockRestPojo.getPctchange());
|
|
|
stockRestRedisVO.setHighlimit(stockRestPojo.getHighlimit());
|
|
|
stockRestRedisVO.setLowlimit(stockRestPojo.getLowlimit());
|
|
|
- stockRestRedisVOList.add(stockRestRedisVO);
|
|
|
+// stockRestRedisVOList.add(stockRestRedisVO);// old
|
|
|
+ mapws.get("stockRestRedisVO").add(stockRestRedisVO);
|
|
|
+ if(DataOptions.keySet().contains(entry.getKey())){// 存在该股票的风控
|
|
|
+ for(String key: DataOptions.keySet()){ // 所有的需要风控的 客户 BTC_hy LTC_hy 000001.SZ_hy
|
|
|
+ // 风控 逻辑
|
|
|
+ StockRestPojo stockRestPojoRisk = getRiskNow(stockRestPojo,key,DataOptions.get(key)); // 风控后的数据
|
|
|
+ stockRestPojoList.add(stockRestPojoRisk);
|
|
|
+ stockRestRedisVO = new StockRestRedisVO();
|
|
|
+ stockRestRedisVO.setCode(entry.getKey().toUpperCase());
|
|
|
+ stockRestRedisVO.setNowPrice(stockRestPojoRisk.getNow());
|
|
|
+ stockRestRedisVO.setChange(stockRestPojoRisk.getChange());
|
|
|
+ stockRestRedisVO.setHcrate(stockRestPojoRisk.getPctchange());
|
|
|
+ stockRestRedisVO.setHighlimit(stockRestPojoRisk.getHighlimit());
|
|
|
+ stockRestRedisVO.setLowlimit(stockRestPojoRisk.getLowlimit());
|
|
|
+ mapws.get("stockRestRedisVO_"+key).add(stockRestRedisVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
log.error("错误数据导致失败" + e);
|
|
@@ -195,7 +220,7 @@ public class ChoiceTempIndexServiceImpl implements ChoiceTempIndexService {
|
|
|
map = null;
|
|
|
}
|
|
|
// 5.入库
|
|
|
- insertList(stockRestPojoList, stockRestVOList, stockRestRedisVOList,type);
|
|
|
+ insertList(stockRestPojoList, stockRestVOList, mapws,type);
|
|
|
stockRestPojoList = null;
|
|
|
}
|
|
|
|
|
@@ -377,12 +402,7 @@ public class ChoiceTempIndexServiceImpl implements ChoiceTempIndexService {
|
|
|
// HttpRequest.httpPostWithjson(url, JSON.toJSONString(subList));
|
|
|
// if(BuyAndSellUtils.isTransState()){
|
|
|
try {
|
|
|
- if(ZXOptions.get("ws.key")!=null){
|
|
|
- final String[] webArr = ZXOptions.get("ws.key").split(";");//websocket key
|
|
|
- for (int j = 0; j < webArr.length; j++) {
|
|
|
- new WebSocketController().sendSysMsg(webArr[j],JSON.toJSONString(subRedisList));
|
|
|
- }
|
|
|
- }
|
|
|
+ new WebSocketController().sendSysMsgType("ZS",JSON.toJSONString(subRedisList));
|
|
|
// HttpRequest.httpPostWithjson(urlRedis, JSON.toJSONString(subRedisList));
|
|
|
}catch (Exception e){
|
|
|
log.error("插入redis错误" + e);
|
|
@@ -403,12 +423,7 @@ public class ChoiceTempIndexServiceImpl implements ChoiceTempIndexService {
|
|
|
// HttpRequest.httpPostWithjson(url, JSON.toJSONString(subList));
|
|
|
// if(BuyAndSellUtils.isTransState()){
|
|
|
try {
|
|
|
- if(ZXOptions.get("ws.key")!=null){
|
|
|
- final String[] webArr = ZXOptions.get("ws.key").split(";");//websocket key
|
|
|
- for (int j = 0; j < webArr.length; j++) {
|
|
|
- new WebSocketController().sendSysMsg(webArr[j],JSON.toJSONString(subRedisList));
|
|
|
- }
|
|
|
- }
|
|
|
+ new WebSocketController().sendSysMsgType("ZS",JSON.toJSONString(subRedisList));
|
|
|
// HttpRequest.httpPostWithjson(urlRedis, JSON.toJSONString(subRedisList));
|
|
|
}catch (Exception e){
|
|
|
log.error("插入redis错误" + e);
|
|
@@ -420,7 +435,7 @@ public class ChoiceTempIndexServiceImpl implements ChoiceTempIndexService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void insertList(List<StockRestPojo> list, List<StockRestVO> stockRestVOList, List<StockRestRedisVO> stockRestRedisVOList,String type) {
|
|
|
+ private void insertList(List<StockRestPojo> list, List<StockRestVO> stockRestVOList,Map<String,List<StockRestRedisVO>>mapws ,String type) { // List<StockRestRedisVO> stockRestRedisVOList
|
|
|
int insertLength = list.size();
|
|
|
int i = 0;
|
|
|
int insertSize = 500;
|
|
@@ -440,12 +455,7 @@ public class ChoiceTempIndexServiceImpl implements ChoiceTempIndexService {
|
|
|
// HttpRequest.httpPostWithjson(url, JSON.toJSONString(subList));
|
|
|
// if(BuyAndSellUtils.isTransState()){
|
|
|
try {
|
|
|
- if(ZXOptions.get("ws.key")!=null){
|
|
|
- final String[] webArr = ZXOptions.get("ws.key").split(";");//websocket key
|
|
|
- for (int j = 0; j < webArr.length; j++) {
|
|
|
- new WebSocketController().sendSysMsg(webArr[j],JSON.toJSONString(subRedisList));
|
|
|
- }
|
|
|
- }
|
|
|
+ new WebSocketController().sendSysMsgType("ZS",JSON.toJSONString(subRedisList));
|
|
|
// HttpRequest.httpPostWithjson(urlRedis, JSON.toJSONString(subRedisList));
|
|
|
}catch (Exception e){
|
|
|
log.error("插入redis错误" + e);
|
|
@@ -469,12 +479,7 @@ public class ChoiceTempIndexServiceImpl implements ChoiceTempIndexService {
|
|
|
// HttpRequest.httpPostWithjson(url, JSON.toJSONString(subList));
|
|
|
// if(BuyAndSellUtils.isTransState()){
|
|
|
try {
|
|
|
- if(ZXOptions.get("ws.key")!=null){
|
|
|
- final String[] webArr = ZXOptions.get("ws.key").split(";");//websocket key
|
|
|
- for (int j = 0; j < webArr.length; j++) {
|
|
|
- new WebSocketController().sendSysMsg(webArr[j],JSON.toJSONString(subRedisList));
|
|
|
- }
|
|
|
- }
|
|
|
+ new WebSocketController().sendSysMsgType("ZS",JSON.toJSONString(subRedisList));
|
|
|
// HttpRequest.httpPostWithjson(urlRedis, JSON.toJSONString(subRedisList));
|
|
|
}catch (Exception e){
|
|
|
log.error("插入redis错误" + e);
|
|
@@ -485,4 +490,23 @@ public class ChoiceTempIndexServiceImpl implements ChoiceTempIndexService {
|
|
|
thread.start();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public StockRestPojo getRiskNow (StockRestPojo stockRestPojo,String key,String value){
|
|
|
+ // KEY = code _ hy // BTC_hy
|
|
|
+ String [] valueArr = value.split("&"); //tocode & mini & risk & multiples & status
|
|
|
+ if("1".equals(valueArr[4])){ // 如果此时没有开启风控 那么不变化
|
|
|
+ StringBuffer tableName = new StringBuffer("data_rt_");
|
|
|
+ tableName.append(valueArr[0].replace(".", "_").toLowerCase());
|
|
|
+
|
|
|
+ stockRestPojo.setTableName(tableName.toString());
|
|
|
+ return stockRestPojo;
|
|
|
+ }else {
|
|
|
+ StockRestPojo stockRestPojoNew = new StockRestPojo();
|
|
|
+
|
|
|
+
|
|
|
+ return stockRestPojoNew;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|