z 4 anos atrás
pai
commit
e85f2043e3

+ 0 - 5
src/main/java/com/zx/dataservice/config/DruidConfig.java

@@ -31,9 +31,4 @@ public class DruidConfig {
         return filterRegistrationBean ;
     }
 
-//    @Bean
-//    @ConfigurationProperties(prefix = "application-dev.properties")
-//    public DataSource druidDataSource() {
-//        return new DruidDataSource();
-//    }
 }

+ 19 - 4
src/main/java/com/zx/dataservice/service/impl/ChoiceBondServiceImpl.java

@@ -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();

+ 19 - 4
src/main/java/com/zx/dataservice/service/impl/ChoiceStockServiceImpl.java

@@ -7,6 +7,7 @@ import com.zx.dataservice.service.ChoiceStockService;
 import com.zx.dataservice.utils.FileStockUtil;
 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 ChoiceStockServiceImpl implements ChoiceStockService {
 
     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 ChoiceStockMapper choiceStockMapper;
 
@@ -41,8 +44,10 @@ public class ChoiceStockServiceImpl implements ChoiceStockService {
         }
         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.移动文件去另外一个文件夹
             FileStockUtil.moveFile(sourceFileUrl + File.separator + file.getName(), goalFileUrl);
@@ -167,6 +172,12 @@ public class ChoiceStockServiceImpl implements ChoiceStockService {
                     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);
                 }
@@ -174,23 +185,25 @@ public class ChoiceStockServiceImpl implements ChoiceStockService {
             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) {
             choiceStockMapper.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();
@@ -198,10 +211,12 @@ public class ChoiceStockServiceImpl implements ChoiceStockService {
         if (insertLength > 0) {
             choiceStockMapper.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();

+ 19 - 4
src/main/java/com/zx/dataservice/service/impl/ChoiceTempIndexServiceImpl.java

@@ -7,6 +7,7 @@ import com.zx.dataservice.service.ChoiceTempIndexService;
 import com.zx.dataservice.utils.FileTempIndexUtil;
 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 ChoiceTempIndexServiceImpl implements ChoiceTempIndexService {
 
     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 ChoiceStockMapper choiceStockMapper;
 
@@ -41,8 +44,10 @@ public class ChoiceTempIndexServiceImpl implements ChoiceTempIndexService {
         }
         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.移动文件去另外一个文件夹
             FileTempIndexUtil.moveFile(sourceFileUrl + File.separator + file.getName(), goalFileUrl);
@@ -167,6 +172,12 @@ public class ChoiceTempIndexServiceImpl implements ChoiceTempIndexService {
                     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);
                 }
@@ -174,23 +185,25 @@ public class ChoiceTempIndexServiceImpl implements ChoiceTempIndexService {
             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) {
             choiceStockMapper.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();
@@ -198,10 +211,12 @@ public class ChoiceTempIndexServiceImpl implements ChoiceTempIndexService {
         if (insertLength > 0) {
             choiceStockMapper.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();

+ 2 - 2
src/main/java/com/zx/dataservice/utils/FileBondUtil.java

@@ -128,7 +128,7 @@ public class FileBondUtil {
                 sbf.append(tempStr);
             }
             reader.close();
-//            deleteFile(fileName);
+            deleteFile(fileName);
             return sbf.toString();
         } catch (IOException e) {
             e.printStackTrace();
@@ -141,7 +141,7 @@ public class FileBondUtil {
                 }
             }
         }
-//        deleteFile(fileName);
+        deleteFile(fileName);
         return sbf.toString();
     }
 

+ 2 - 2
src/main/java/com/zx/dataservice/utils/FileStockUtil.java

@@ -128,7 +128,7 @@ public class FileStockUtil {
                 sbf.append(tempStr);
             }
             reader.close();
-//            deleteFile(fileName);
+            deleteFile(fileName);
             return sbf.toString();
         } catch (IOException e) {
             e.printStackTrace();
@@ -141,7 +141,7 @@ public class FileStockUtil {
                 }
             }
         }
-//        deleteFile(fileName);
+        deleteFile(fileName);
         return sbf.toString();
     }
 

+ 2 - 2
src/main/java/com/zx/dataservice/utils/FileTempIndexUtil.java

@@ -125,7 +125,7 @@ public class FileTempIndexUtil {
                 sbf.append(tempStr);
             }
             reader.close();
-//            deleteFile(fileName);
+            deleteFile(fileName);
             return sbf.toString();
         } catch (IOException e) {
             e.printStackTrace();
@@ -138,7 +138,7 @@ public class FileTempIndexUtil {
                 }
             }
         }
-//        deleteFile(fileName);
+        deleteFile(fileName);
         return sbf.toString();
     }
 

+ 11 - 0
src/main/java/com/zx/dataservice/vo/StockRestRedisVO.java

@@ -0,0 +1,11 @@
+package com.zx.dataservice.vo;
+
+import lombok.Data;
+
+@Data
+public class StockRestRedisVO {
+    private String code;
+    private String nowPrice;
+    private String hcrate;
+    private String change;
+}

+ 0 - 9
src/main/resources/application-dev.properties

@@ -17,16 +17,7 @@ spring.druid.removeAbandoned=true
 spring.druid.removeAbandonedTimeout=1800
 spring.druid.filters=stat
 
-# 云正式服务器 外网访问
-spring.datasource.test1.jdbc-Url=jdbc:mysql://hk-cdb-mw8z8p47.sql.tencentcdb.com:63791/stock_data?characterEncoding=utf-8&allowMultiQueries=true
-spring.datasource.test1.username=root
-spring.datasource.test1.password=TestBicon@123
-spring.datasource.test1.driver-class-name=com.mysql.cj.jdbc.Driver
 
-spring.datasource.test2.jdbc-Url=jdbc:mysql://hk-cdb-mw8z8p47.sql.tencentcdb.com:63791/stock_data_zhaiquan?characterEncoding=utf-8&allowMultiQueries=true
-spring.datasource.test2.username=root
-spring.datasource.test2.password=TestBicon@123
-spring.datasource.test2.driver-class-name=com.mysql.cj.jdbc.Driver
 
 #是否激活 swagger true or false
 swagger.enable=true