| | |
| | | package com.nq.ws; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.nq.constant.StockConstant; |
| | | 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 com.nq.utils.redis.RedisShardedPoolUtils; |
| | | 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; |
| | | |
| | |
| | | |
| | | @Override |
| | | public void onOpen(ServerHandshake serverHandshake) { |
| | | log.info("webSocket 客服端链接成功"); |
| | | send(("key:"+ StockConstant.KEY+":"+EStockType.IN.getContryId()).getBytes()); |
| | | send(("key:"+ EStockType.MAS.getStockKey()+":"+EStockType.MAS.getContryId()).getBytes()); |
| | | } |
| | | |
| | | @Override |
| | | public void onMessage(String s) { |
| | | try { |
| | | |
| | | |
| | | ApplicationContext act = ApplicationContextRegisterUtil.getApplicationContext(); |
| | | MandatoryLiquidationService liquidationService = (MandatoryLiquidationService) act.getBean(IMandatoryLiquidationService.class); |
| | | StockRealTimeBean stockDetailBean = new Gson().fromJson(s, StockRealTimeBean.class); |
| | | RedisKeyUtil.setCacheRealTimeStock(EStockType.IN,stockDetailBean); |
| | | liquidationService.RealTimeDataProcess(EStockType.MAS,stockDetailBean); |
| | | }catch (Exception e){ |
| | | |
| | | } |