Helius
2020-06-01 4b844113469b203adc40f1e540de98612321f26e
src/main/java/com/xcong/excoin/rabbit/consumer/WebsocketPriceConsumer.java
@@ -3,33 +3,40 @@
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 信道
    */
@@ -45,6 +52,7 @@
   /**
    * 开空止盈
     *
    * @param message
    * @param channel
    */
@@ -61,6 +69,7 @@
   /**
    * 开多止损
     *
    * @param message
    * @param channel
    */
@@ -76,6 +85,7 @@
   /**
    * 开空止损
     *
    * @param message
    * @param channel
    */
@@ -91,6 +101,7 @@
   /**
    * 限价委托
     *
    * @param message
    * @param channel
    */
@@ -106,6 +117,7 @@
   /**
    * 爆仓消费者
     *
    * @param message
    * @param channel
    */
@@ -121,15 +133,16 @@
   /**
    * 平仓
     *
    * @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);
   }
}