| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.rabbitmq.client.Channel; |
| | | import com.xcong.excoin.configurations.RabbitMqConfig; |
| | | import com.xcong.excoin.modules.contract.service.RabbitOrderService; |
| | | import com.xcong.excoin.modules.contract.service.impl.OrderWebsocketServiceImpl; |
| | | import com.xcong.excoin.rabbit.pricequeue.OrderModel; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * APP和后台打包都开启 |
| | | * |
| | | * @author helius |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | @ConditionalOnProperty(name="useRabbit",havingValue="true") |
| | | @ConditionalOnProperty(prefix = "app", name = "rabbit-consumer", havingValue = "true") |
| | | public class WebsocketPriceConsumer { |
| | | |
| | | //@Autowired |
| | | //OrderWebsocketService orderWebsocketService; |
| | | @Resource |
| | | OrderWebsocketServiceImpl orderWebsocketService; |
| | | |
| | | //@Autowired |
| | | //OrderService orderService; |
| | | @Resource |
| | | RabbitOrderService orderService; |
| | | |
| | | |
| | | /** |
| | | * 开多止盈 |
| | | * |
| | | * @param message 消息体 |
| | | * @param channel 信道 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 开空止盈 |
| | | * |
| | | * @param message |
| | | * @param channel |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 开多止损 |
| | | * |
| | | * @param message |
| | | * @param channel |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 开空止损 |
| | | * |
| | | * @param message |
| | | * @param channel |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 限价委托 |
| | | * |
| | | * @param message |
| | | * @param channel |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 爆仓消费者 |
| | | * |
| | | * @param message |
| | | * @param channel |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 平仓 |
| | | * |
| | | * @param message |
| | | * @param channel |
| | | */ |
| | | @RabbitListener(queues = RabbitMqConfig.QUEUE_CLOSETRADE) |
| | | public void onMessageCloseTrade(Message message, Channel channel) { |
| | | String content = new String(message.getBody()); |
| | | System.out.println("我收到消息了平仓:"+content); |
| | | log.info("我收到消息了平仓: {}", content); |
| | | // 订单 |
| | | List<Long> ids = JSONArray.parseArray(content, Long.class); |
| | | //orderService.closeTradeForMq(ids); |
| | | orderService.cancelHoldOrder(ids); |
| | | } |
| | | } |