| | |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.pojo.User; |
| | | import com.nq.service.IEchoServices; |
| | | import com.nq.service.IUserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | |
| | | @Autowired |
| | | IEchoServices iEchoServices; |
| | | |
| | | @Autowired |
| | | IUserService iUserService; |
| | | |
| | | @PostMapping("queryEcho.do") |
| | | @ResponseBody |
| | | public ServerResponse queryEcho() { |
| | |
| | | @PostMapping("buyEcho.do") |
| | | @ResponseBody |
| | | public ServerResponse buyEcho(@RequestParam("eId") String eid, @RequestParam("money") Integer money, HttpServletRequest request) { |
| | | User user = this.iUserService.getCurrentRefreshUser(request); |
| | | if(user == null){ |
| | | return ServerResponse.createByErrorMsg("Please Login"); |
| | | } |
| | | if (iEchoServices.buyECho(eid, money,request)) { |
| | | return ServerResponse.createBySuccess("Buy Successed"); |
| | | } else { |
| | |
| | | |
| | | log.info("用户{}登陆成功, 登陆状态{} ,交易状态{}", new Object[]{user.getId(), user.getIsLogin(), user.getIsLock()}); |
| | | |
| | | userAssetsServices.assetsByTypeAndUserId(EStockType.HG.getCode(),user.getId()); |
| | | userAssetsServices.assetsByTypeAndUserId(EStockType.MAS.getCode(),user.getId()); |
| | | userAssetsServices.assetsByTypeAndUserId(EStockType.US.getCode(),user.getId()); |
| | | this.iSiteLoginLogService.saveLog(user, request); |
| | | return ServerResponse.createBySuccess(user); |
| | | } |
| | |
| | | Stock stock = stocks.get(i); |
| | | StockRealTimeBean realTimeStock = RedisKeyUtil.getCacheRealTimeStock(stock); |
| | | StockListVO stockListVO = new StockListVO(); |
| | | |
| | | if(realTimeStock.getPcp().contains("%")){ |
| | | realTimeStock.setPcp(realTimeStock.getPcp()+"%"); |
| | | } |
| | | |
| | | stockListVO.setHcrate(new BigDecimal(realTimeStock.getPcp())); |
| | | if(realTimeStock.getPcp().contains("-")){ |
| | | stockListVO.setColor(0); |
| | |
| | | * */ |
| | | @Scheduled(cron = "0 0/3 * * * ?") |
| | | public void syncINStockData() { |
| | | // loadAllStock(EStockType.US); |
| | | loadAllStock(EStockType.HG); |
| | | loadAllStock(EStockType.US); |
| | | loadAllStock(EStockType.MAS); |
| | | } |
| | | |
| | | |
| | |
| | | retMap.put(EStockType.IN.getStockKey(), websocketRunClient); |
| | | } catch (Exception e) { |
| | | } |
| | | // |
| | | // try { |
| | | // USWebsocketRunClient usWebsocketRunClient = new USWebsocketRunClient(new URI(PropertiesUtil.getProperty("IN_WS_URL"))); |
| | | // usWebsocketRunClient.connect(); |
| | | // usWebsocketRunClient.setConnectionLostTimeout(0); |
| | | // new Thread(() -> { |
| | | // while (true) { |
| | | // try { |
| | | // Thread.sleep(8000); |
| | | // usWebsocketRunClient.send("heartbeat".getBytes()); |
| | | // } catch (Exception e) { |
| | | // usWebsocketRunClient.reconnect(); |
| | | // usWebsocketRunClient.setConnectionLostTimeout(0); |
| | | // } |
| | | // } |
| | | // }).start(); |
| | | // retMap.put(EStockType.US.getStockKey(), usWebsocketRunClient); |
| | | // } catch (Exception e) { |
| | | // } |
| | | |
| | | try { |
| | | USWebsocketRunClient usWebsocketRunClient = new USWebsocketRunClient(new URI(PropertiesUtil.getProperty("MAS_WS_URL"))); |
| | | usWebsocketRunClient.connect(); |
| | | usWebsocketRunClient.setConnectionLostTimeout(0); |
| | | new Thread(() -> { |
| | | while (true) { |
| | | try { |
| | | Thread.sleep(8000); |
| | | usWebsocketRunClient.send("heartbeat".getBytes()); |
| | | } catch (Exception e) { |
| | | usWebsocketRunClient.reconnect(); |
| | | usWebsocketRunClient.setConnectionLostTimeout(0); |
| | | } |
| | | } |
| | | }).start(); |
| | | retMap.put(EStockType.US.getStockKey(), usWebsocketRunClient); |
| | | } catch (Exception e) { |
| | | } |
| | | |
| | | return retMap; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void onOpen(ServerHandshake serverHandshake) { |
| | | send(("key:"+ EStockType.IN.getStockKey()+":"+EStockType.IN.getContryId()).getBytes()); |
| | | send(("key:"+ EStockType.MAS.getStockKey()+":"+EStockType.MAS.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.IN,stockDetailBean); |
| | | liquidationService.RealTimeDataProcess(EStockType.MAS,stockDetailBean); |
| | | }catch (Exception e){ |
| | | |
| | | } |