|
@@ -7,6 +7,7 @@ import com.zx.dataservice.service.ChoiceBondService;
|
|
|
import com.zx.dataservice.utils.FileBondUtil;
|
|
|
import com.zx.dataservice.utils.HttpRequest;
|
|
|
import com.zx.dataservice.utils.TimeUtil;
|
|
|
+import com.zx.dataservice.vo.StockRestRedisVO;
|
|
|
import com.zx.dataservice.vo.StockRestVO;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@@ -29,6 +30,8 @@ public class ChoiceBondServiceImpl implements ChoiceBondService {
|
|
|
|
|
|
private static final String url = "http://taifooksec.com/api/stock/updateBatchStockInfo.do";
|
|
|
|
|
|
+ private static final String urlRedis = "http://qwer16888.vip/init/redis/updateInfo.do";
|
|
|
+
|
|
|
@Autowired
|
|
|
private ChoiceBondMapper choiceBondMapper;
|
|
|
|
|
@@ -41,8 +44,10 @@ public class ChoiceBondServiceImpl implements ChoiceBondService {
|
|
|
}
|
|
|
List<StockRestPojo> stockRestPojoList = new ArrayList<>();
|
|
|
List<StockRestVO> stockRestVOList = new ArrayList<>();
|
|
|
+ List<StockRestRedisVO> stockRestRedisVOList = new ArrayList<>();
|
|
|
StockRestPojo stockRestPojo;
|
|
|
StockRestVO stockRestVO;
|
|
|
+ StockRestRedisVO stockRestRedisVO;
|
|
|
for (File file : files) {
|
|
|
// 2.移动文件去另外一个文件夹
|
|
|
FileBondUtil.moveFile(sourceFileUrl + File.separator + file.getName(), goalFileUrl);
|
|
@@ -168,6 +173,12 @@ public class ChoiceBondServiceImpl implements ChoiceBondService {
|
|
|
stockRestVO = new StockRestVO();
|
|
|
BeanUtils.copyProperties(stockRestPojo, stockRestVO);
|
|
|
stockRestVOList.add(stockRestVO);
|
|
|
+ stockRestRedisVO = new StockRestRedisVO();
|
|
|
+ stockRestRedisVO.setCode(entry.getKey().toUpperCase());
|
|
|
+ stockRestRedisVO.setNowPrice(stockRestPojo.getNow());
|
|
|
+ stockRestRedisVO.setChange(stockRestPojo.getChange());
|
|
|
+ stockRestRedisVO.setHcrate(stockRestPojo.getPctchange());
|
|
|
+ stockRestRedisVOList.add(stockRestRedisVO);
|
|
|
}catch (Exception e){
|
|
|
log.error("错误数据导致失败" + e);
|
|
|
}
|
|
@@ -175,23 +186,25 @@ public class ChoiceBondServiceImpl implements ChoiceBondService {
|
|
|
map = null;
|
|
|
}
|
|
|
// 5.入库
|
|
|
- insertList(stockRestPojoList, stockRestVOList);
|
|
|
+ insertList(stockRestPojoList, stockRestVOList, stockRestRedisVOList);
|
|
|
stockRestPojoList = null;
|
|
|
}
|
|
|
|
|
|
- private void insertList(List<StockRestPojo> list, List<StockRestVO> stockRestVOList) {
|
|
|
+ private void insertList(List<StockRestPojo> list, List<StockRestVO> stockRestVOList, List<StockRestRedisVO> stockRestRedisVOList) {
|
|
|
int insertLength = list.size();
|
|
|
int i = 0;
|
|
|
int insertSize = 500;
|
|
|
while (insertLength > insertSize) {
|
|
|
choiceBondMapper.insertBatch(list.subList(i, i + insertSize));
|
|
|
List<StockRestVO> subList = stockRestVOList.subList(i, i + insertSize);
|
|
|
+ List<StockRestRedisVO> subRedisList = stockRestRedisVOList.subList(i, i + insertSize);
|
|
|
i = i + insertSize;
|
|
|
insertLength = insertLength - insertSize;
|
|
|
Thread thread=new Thread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- HttpRequest.httpPostWithjson(url, JSON.toJSONString(subList));
|
|
|
+// HttpRequest.httpPostWithjson(url, JSON.toJSONString(subList));
|
|
|
+ HttpRequest.httpPostWithjson(urlRedis, JSON.toJSONString(subRedisList));
|
|
|
}
|
|
|
});
|
|
|
thread.start();
|
|
@@ -199,10 +212,12 @@ public class ChoiceBondServiceImpl implements ChoiceBondService {
|
|
|
if (insertLength > 0) {
|
|
|
choiceBondMapper.insertBatch(list.subList(i, i + insertLength));
|
|
|
List<StockRestVO> subList = stockRestVOList.subList(i, i + insertLength);
|
|
|
+ List<StockRestRedisVO> subRedisList = stockRestRedisVOList.subList(i, i + insertLength);
|
|
|
Thread thread=new Thread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- HttpRequest.httpPostWithjson(url, JSON.toJSONString(subList));
|
|
|
+// HttpRequest.httpPostWithjson(url, JSON.toJSONString(subList));
|
|
|
+ HttpRequest.httpPostWithjson(urlRedis, JSON.toJSONString(subRedisList));
|
|
|
}
|
|
|
});
|
|
|
thread.start();
|