13 files modified
4 files deleted
| | |
| | | </dependency> |
| | | |
| | | |
| | | <dependency> |
| | | <groupId>org.flywaydb</groupId> |
| | | <artifactId>flyway-core</artifactId> |
| | | </dependency> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>org.flywaydb</groupId>--> |
| | | <!-- <artifactId>flyway-core</artifactId>--> |
| | | <!-- </dependency>--> |
| | | |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>org.springframework.boot</groupId>--> |
| | |
| | | |
| | | |
| | | US("US","美国股票","5",PropertiesUtil.getProperty("US_HTTP_API"),PropertiesUtil.getProperty("US_KEY"),"USD","$"), |
| | | HK("HK","香港股票","39",PropertiesUtil.getProperty("HK_HTTP_API"),PropertiesUtil.getProperty("HK_KEY"),"HKD","HK$"), |
| | | MAS("MAS","马来西亚股票","42",PropertiesUtil.getProperty("MAS_HTTP_API"),PropertiesUtil.getProperty("MAS_KEY"),"MYR","RM"); |
| | | // HK("HK","香港股票","39",PropertiesUtil.getProperty("HK_HTTP_API"),PropertiesUtil.getProperty("HK_KEY"),"HKD","HK$"), |
| | | // MAS("MAS","马来西亚股票","42",PropertiesUtil.getProperty("MAS_HTTP_API"),PropertiesUtil.getProperty("MAS_KEY"),"MYR","RM"); |
| | | |
| | | // IN("IN","印度股票","14", PropertiesUtil.getProperty("IN_HTTP_API"),PropertiesUtil.getProperty("IN_KEY")), |
| | | IN("IN","印度股票","14", PropertiesUtil.getProperty("IN_HTTP_API"),PropertiesUtil.getProperty("IN_KEY"),"INR","₹"); |
| | | // TH("TH","泰国股票","41",PropertiesUtil.getProperty("TH_HTTP_API"),PropertiesUtil.getProperty("TH_KEY")), |
| | | // HG("HG","韩国股票","11",PropertiesUtil.getProperty("HG_HTTP_API"),PropertiesUtil.getProperty("HG_KEY")), |
| | | // SZHB("SZHB","数字货币","41",PropertiesUtil.getProperty("SZHB_HTTP_API"),PropertiesUtil.getProperty("SZHB_KEY")); |
| | |
| | | if(EStockType.US.getCode().equals(code)){ |
| | | return US; |
| | | |
| | | }else if(EStockType.HK.getCode().equals(code)){ |
| | | return HK; |
| | | }else if(EStockType.MAS.getCode().equals(code)){ |
| | | return MAS; |
| | | }else if(EStockType.IN.getCode().equals(code)){ |
| | | return IN; |
| | | }else{ |
| | | return MAS; |
| | | return US; |
| | | } |
| | | } |
| | | |
| | |
| | | BigDecimal rate = iSiteSettingService.getSiteSetting().getExchangeRate(); |
| | | BigDecimal rate1 = new BigDecimal(7.35); |
| | | if(fromStockType==EStockType.US){ |
| | | if(tofromStockType==EStockType.MAS){ |
| | | if(tofromStockType==EStockType.IN){ |
| | | return rate; |
| | | }else if(tofromStockType==EStockType.HK){ |
| | | return rate1; |
| | | } |
| | | }if(fromStockType==EStockType.HK){ |
| | | if(tofromStockType==EStockType.MAS){ |
| | | }if(fromStockType==EStockType.IN){ |
| | | if(tofromStockType==EStockType.US){ |
| | | return new BigDecimal(1).divide(rate1,18, RoundingMode.HALF_DOWN).multiply(rate); |
| | | }else if(tofromStockType==EStockType.US){ |
| | | return new BigDecimal(1).divide(rate1,18, RoundingMode.HALF_DOWN); |
| | |
| | | public int grabNews() { |
| | | int ret = 0; |
| | | addNews(1, EStockType.US.getStockUrl() +"stock-markets?key="+ EStockType.US.getStockKey() +"&type=4"); |
| | | addNews(2,EStockType.MAS.getStockUrl() +"stock-markets?key="+ EStockType.MAS.getStockKey() +"&type=5"); |
| | | addNews(2,EStockType.IN.getStockUrl() +"stock-markets?key="+ EStockType.IN.getStockKey() +"&type=5"); |
| | | return ret; |
| | | } |
| | | |
| | |
| | | if (user.getIsLogin().intValue() == 1) { |
| | | return ServerResponse.createByErrorMsg("登录失败。账户锁定",request); |
| | | } |
| | | userAssetsServices.assetsByTypeAndUserId(EStockType.MAS.getCode(),user.getId()); |
| | | userAssetsServices.assetsByTypeAndUserId(EStockType.US.getCode(),user.getId()); |
| | | userAssetsServices.assetsByTypeAndUserId(EStockType.HK.getCode(),user.getId()); |
| | | userAssetsServices.assetsByTypeAndUserId(EStockType.IN.getCode(),user.getId()); |
| | | this.iSiteLoginLogService.saveLog(user, request); |
| | | return ServerResponse.createBySuccess(user); |
| | | } |
| | |
| | | /** |
| | | * 同步系统所需要的股票 |
| | | * */ |
| | | @Scheduled(cron = "0 0/3 * * * ?") |
| | | @Scheduled(cron = "0 0/1 * * * ?") |
| | | public void syncINStockData() { |
| | | loadAllStock(EStockType.US); |
| | | loadAllStock(EStockType.MAS); |
| | | loadAllStock(EStockType.IN); |
| | | // loadAllStock(EStockType.HK); |
| | | } |
| | | |
| | |
| | | /** |
| | | * 同步美国股票 |
| | | * */ |
| | | @Scheduled(cron = "0 0/30 * * * ?") |
| | | public void loadStockCompanies(){ |
| | | loadAllCompanies(); |
| | | } |
| | | // @Scheduled(cron = "0 0/3 * * * ?") |
| | | // public void loadStockCompanies(){ |
| | | // loadAllCompanies(); |
| | | // } |
| | | |
| | | |
| | | |
| | |
| | | package com.nq.ws; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.nq.enums.EStockType; |
| | | import com.nq.pojo.StockRealTimeBean; |
| | | import com.nq.service.IMandatoryLiquidationService; |
| | | import com.nq.service.impl.MandatoryLiquidationService; |
| | | import com.nq.utils.ApplicationContextRegisterUtil; |
| | | import com.nq.utils.redis.RedisKeyUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.java_websocket.client.WebSocketClient; |
| | | import org.java_websocket.handshake.ServerHandshake; |
| | | import org.springframework.context.ApplicationContext; |
| | | |
| | | import java.net.URI; |
| | | |
| | | @Slf4j |
| | | public class HKWebsocketRunClient extends WebSocketClient { |
| | | |
| | | public HKWebsocketRunClient(URI serverUri) { |
| | | super(serverUri); |
| | | } |
| | | |
| | | @Override |
| | | public void onOpen(ServerHandshake serverHandshake) { |
| | | send(("key:"+ EStockType.HK.stockKey+":"+EStockType.HK.getContryId()).getBytes()); |
| | | } |
| | | |
| | | @Override |
| | | public void onMessage(String s) { |
| | | try { |
| | | StockRealTimeBean stockDetailBean = new Gson().fromJson(s, StockRealTimeBean.class); |
| | | RedisKeyUtil.setCacheRealTimeStock(EStockType.HK,stockDetailBean); |
| | | ApplicationContext act = ApplicationContextRegisterUtil.getApplicationContext(); |
| | | MandatoryLiquidationService liquidationService = (MandatoryLiquidationService) act.getBean(IMandatoryLiquidationService.class); |
| | | liquidationService.RealTimeDataProcess(EStockType.HK,stockDetailBean); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onClose(int i, String s, boolean b) { |
| | | log.info("websocket HK关闭关闭"+1); |
| | | } |
| | | |
| | | @Override |
| | | public void onError(Exception e) { |
| | | log.info("websocket 错误"); |
| | | } |
| | | } |
| | | //package com.nq.ws; |
| | | // |
| | | //import com.google.gson.Gson; |
| | | //import com.nq.enums.EStockType; |
| | | //import com.nq.pojo.StockRealTimeBean; |
| | | //import com.nq.service.IMandatoryLiquidationService; |
| | | //import com.nq.service.impl.MandatoryLiquidationService; |
| | | //import com.nq.utils.ApplicationContextRegisterUtil; |
| | | //import com.nq.utils.redis.RedisKeyUtil; |
| | | //import lombok.extern.slf4j.Slf4j; |
| | | //import org.java_websocket.client.WebSocketClient; |
| | | //import org.java_websocket.handshake.ServerHandshake; |
| | | //import org.springframework.context.ApplicationContext; |
| | | // |
| | | //import java.net.URI; |
| | | // |
| | | //@Slf4j |
| | | //public class HKWebsocketRunClient extends WebSocketClient { |
| | | // |
| | | // public HKWebsocketRunClient(URI serverUri) { |
| | | // super(serverUri); |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onOpen(ServerHandshake serverHandshake) { |
| | | // send(("key:"+ EStockType.IN.stockKey+":"+EStockType.IN.getContryId()).getBytes()); |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onMessage(String s) { |
| | | // try { |
| | | // StockRealTimeBean stockDetailBean = new Gson().fromJson(s, StockRealTimeBean.class); |
| | | // RedisKeyUtil.setCacheRealTimeStock(EStockType.IN,stockDetailBean); |
| | | // ApplicationContext act = ApplicationContextRegisterUtil.getApplicationContext(); |
| | | // MandatoryLiquidationService liquidationService = (MandatoryLiquidationService) act.getBean(IMandatoryLiquidationService.class); |
| | | // liquidationService.RealTimeDataProcess(EStockType.IN,stockDetailBean); |
| | | // }catch (Exception e){ |
| | | // |
| | | // } |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onClose(int i, String s, boolean b) { |
| | | // log.info("websocket HK关闭关闭"+1); |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onError(Exception e) { |
| | | // log.info("websocket 错误"); |
| | | // } |
| | | //} |
| | |
| | | |
| | | Map<String, WebSocketClient> retMap = new HashMap<>(2); |
| | | try { |
| | | WebsocketRunClient websocketRunClient = new WebsocketRunClient(new URI(PropertiesUtil.getProperty("MAS_WS_URL"))); |
| | | WebsocketRunClient websocketRunClient = new WebsocketRunClient(new URI(PropertiesUtil.getProperty("IN_WS_URL"))); |
| | | websocketRunClient.connect(); |
| | | websocketRunClient.setConnectionLostTimeout(0); |
| | | new Thread(() -> { |
| | |
| | | } |
| | | } |
| | | }).start(); |
| | | retMap.put(EStockType.MAS.getStockKey(), websocketRunClient); |
| | | retMap.put(EStockType.IN.getStockKey(), websocketRunClient); |
| | | } catch (Exception e) { |
| | | } |
| | | |
| | |
| | | retMap.put(EStockType.US.getStockKey(), usWebsocketRunClient); |
| | | } catch (Exception e) { |
| | | } |
| | | |
| | | |
| | | try { |
| | | HKWebsocketRunClient hkWebsocketRunClient = new HKWebsocketRunClient(new URI(PropertiesUtil.getProperty("HK_WS_URL"))); |
| | | hkWebsocketRunClient.connect(); |
| | | hkWebsocketRunClient.setConnectionLostTimeout(0); |
| | | new Thread(() -> { |
| | | while (true) { |
| | | try { |
| | | Thread.sleep(8000); |
| | | hkWebsocketRunClient.send("heartbeat".getBytes()); |
| | | } catch (Exception e) { |
| | | hkWebsocketRunClient.reconnect(); |
| | | hkWebsocketRunClient.setConnectionLostTimeout(0); |
| | | } |
| | | } |
| | | }).start(); |
| | | retMap.put(EStockType.HK.getStockKey(), hkWebsocketRunClient); |
| | | } catch (Exception e) { |
| | | } |
| | | |
| | | |
| | | return retMap; |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public void onOpen(ServerHandshake serverHandshake) { |
| | | send(("key:"+ EStockType.MAS.getStockKey()+":"+EStockType.MAS.getContryId()).getBytes()); |
| | | send(("key:"+ EStockType.IN.getStockKey()+":"+EStockType.IN.getContryId()).getBytes()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | ApplicationContext act = ApplicationContextRegisterUtil.getApplicationContext(); |
| | | MandatoryLiquidationService liquidationService = (MandatoryLiquidationService) act.getBean(IMandatoryLiquidationService.class); |
| | | StockRealTimeBean stockDetailBean = new Gson().fromJson(s, StockRealTimeBean.class); |
| | | liquidationService.RealTimeDataProcess(EStockType.MAS,stockDetailBean); |
| | | liquidationService.RealTimeDataProcess(EStockType.IN,stockDetailBean); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void onClose(int i, String s, boolean b) { |
| | | log.info("websocket 马来西亚 关闭"+1); |
| | | log.info("websocket 印股 关闭"+1); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | |
| | | #股票key的地址 |
| | | IN_HTTP_API = http://api-in.js-stock.top/ |
| | | IN_WS_URL = ws://api-in-ws.js-stock.top |
| | | IN_HTTP_API = https://data.is4vc.com/ |
| | | IN_WS_URL = ws://ws.is4vc.com:8001/websocket-server |
| | | IN_KEY = r3ZAgtcYzuBizmqge2hK |
| | | |
| | | US_HTTP_API = http://api-us.js-stock.top/ |
| | |
| | | time-zone: Asia/Kolkata |
| | | profiles: |
| | | active: druid |
| | | flyway: |
| | | enabled: true |
| | | # 禁止清理数据库表 |
| | | clean-disabled: false |
| | | # 如果数据库不是空表,需要设置成 true,否则启动报错 |
| | | baseline-on-migrate: true |
| | | # 与 baseline-on-migrate: true 搭配使用 |
| | | baseline-version: 0 |
| | | #数据库连接配置 |
| | | url: ${spring.datasource.url} |
| | | user: ${spring.datasource.username} |
| | | password: ${spring.datasource.password} |
| | | locations: classpath:db/migration/ #(根据个人情况设置,多个路径使用逗号分隔) |
| | | #版本控制日志表,默认flyway_schema_history |
| | | table: flyway_schema_history |
| | | |
| | | # 文件上传 |
| | | servlet: |
| | | multipart: |
| | |
| | | datasource: |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | driverClassName: com.mysql.cj.jdbc.Driver |
| | | url: jdbc:mysql://127.0.0.1:7306/stock?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 |
| | | url: jdbc:mysql://127.0.0.1:3306/stock?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 |
| | | # url: jdbc:mysql://127.0.0.1:3306/cgstock?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 |
| | | username: root |
| | | password: 123456 |
| | |
| | | |
| | | |
| | | #股票key的地址 |
| | | IN_HTTP_API = http://api-in.js-stock.top/ |
| | | IN_WS_URL = ws://api-in-ws.js-stock.top |
| | | IN_HTTP_API = https://data.is4vc.com/ |
| | | IN_WS_URL = ws://ws.is4vc.com:8001/websocket-server |
| | | IN_KEY = r3ZAgtcYzuBizmqge2hK |
| | | |
| | | US_HTTP_API = http://api-us.js-stock.top/ |
| | |
| | | time-zone: Asia/Kolkata |
| | | profiles: |
| | | active: druid |
| | | flyway: |
| | | enabled: true |
| | | # 禁止清理数据库表 |
| | | clean-disabled: false |
| | | # 如果数据库不是空表,需要设置成 true,否则启动报错 |
| | | baseline-on-migrate: true |
| | | # 与 baseline-on-migrate: true 搭配使用 |
| | | baseline-version: 0 |
| | | #数据库连接配置 |
| | | url: ${spring.datasource.url} |
| | | user: ${spring.datasource.username} |
| | | password: ${spring.datasource.password} |
| | | locations: classpath:db/migration/ #(根据个人情况设置,多个路径使用逗号分隔) |
| | | #版本控制日志表,默认flyway_schema_history |
| | | table: flyway_schema_history |
| | | |
| | | # 文件上传 |
| | | servlet: |
| | | multipart: |
| | |
| | | datasource: |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | driverClassName: com.mysql.cj.jdbc.Driver |
| | | url: jdbc:mysql://127.0.0.1:7306/stock?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 |
| | | url: jdbc:mysql://127.0.0.1:3306/stock?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 |
| | | # url: jdbc:mysql://127.0.0.1:3306/cgstock?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 |
| | | username: root |
| | | password: 123456 |