From d23645e976981bc9b670eea1d469fe8a36be309c Mon Sep 17 00:00:00 2001 From: KKSU <15274802129@163.com> Date: Wed, 17 Apr 2024 17:19:53 +0800 Subject: [PATCH] 55测试环境 --- src/main/java/com/xcong/excoin/rabbit/init/OrderProducerInit.java | 36 ++++++++++++++++-------------------- 1 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/xcong/excoin/rabbit/init/OrderProducerInit.java b/src/main/java/com/xcong/excoin/rabbit/init/OrderProducerInit.java index 94d6e76..529878d 100644 --- a/src/main/java/com/xcong/excoin/rabbit/init/OrderProducerInit.java +++ b/src/main/java/com/xcong/excoin/rabbit/init/OrderProducerInit.java @@ -12,10 +12,12 @@ import com.xcong.excoin.rabbit.pricequeue.OrderModel; import com.xcong.excoin.rabbit.producer.OrderProducer; import com.xcong.excoin.utils.CalculateUtil; +import com.xcong.excoin.utils.ThreadPoolUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.DependsOn; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; @@ -31,6 +33,7 @@ * @author helius */ @Slf4j +@DependsOn("springContextHolder") @Component @ConditionalOnProperty(prefix = "app", name = "newest-price-update-job", havingValue = "true") public class OrderProducerInit { @@ -69,7 +72,7 @@ if (forceSetPrice != null) { if (forceSetPrice.compareTo(BigDecimal.ZERO) >= 0) { OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_MORE_BOMB.getValue(), forceSetPrice.toPlainString(), - order.getSymbol(), order.getOperateNo()); + order.getSymbol(), order.getOperateNo(), order.getMemberId()); producer.sendPriceOperate(JSONObject.toJSONString(model)); } } @@ -79,7 +82,7 @@ if (stopLossPrice != null && stopLossPrice.compareTo(BigDecimal.ZERO) > 0) { OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_MORE_STOP_LESS.getValue(), stopLossPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), - order.getSymbol()); + order.getSymbol(), order.getMemberId()); producer.sendPriceOperate(JSONObject.toJSONString(model)); } // 止盈 @@ -87,7 +90,7 @@ if (stopProfitPrice != null && stopProfitPrice.compareTo(BigDecimal.ZERO) > 0) { OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_MORE_STOP_PROFIT.getValue(), stopProfitPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), - order.getSymbol()); + order.getSymbol(), order.getMemberId()); producer.sendPriceOperate(JSONObject.toJSONString(model)); } @@ -99,7 +102,7 @@ if (forceSetPrice != null) { if (forceSetPrice.compareTo(BigDecimal.ZERO) >= 0) { OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_LESS_BOMB.getValue(), forceSetPrice.toPlainString(), - order.getSymbol(), order.getOperateNo()); + order.getSymbol(), order.getOperateNo(), order.getMemberId()); producer.sendPriceOperate(JSONObject.toJSONString(model)); } } @@ -109,7 +112,7 @@ if (stopLossPrice != null && stopLossPrice.compareTo(BigDecimal.ZERO) > 0) { OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_LESS_STOP_LESS.getValue(), stopLossPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), - order.getSymbol()); + order.getSymbol(), order.getMemberId()); producer.sendPriceOperate(JSONObject.toJSONString(model)); } // 止盈 @@ -117,7 +120,7 @@ if (stopProfitPrice != null && stopProfitPrice.compareTo(BigDecimal.ZERO) > 0) { OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_LESS_STOP_PROFIT.getValue(), stopProfitPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), - order.getSymbol()); + order.getSymbol(), order.getMemberId()); producer.sendPriceOperate(JSONObject.toJSONString(model)); } } @@ -126,17 +129,10 @@ } // 全仓持仓 - List<HashMap<String, Object>> wholeHoldOrders = contractHoldOrderDao.selectAllWholeOrderMemberIdAndSymbol(); + List<Long> wholeHoldOrders = contractHoldOrderDao.selectAllWholeOrderMemberId(); if (CollUtil.isNotEmpty(wholeHoldOrders)) { - MemberEntity memberEntity = null; - for (HashMap<String, Object> wholeHoldOrder : wholeHoldOrders) { - Long memberId = (Long) wholeHoldOrder.get("member_id"); - String symbol = (String) wholeHoldOrder.get("symbol"); - if (memberEntity == null || !memberId.equals(memberEntity.getId())) { - memberEntity = memberDao.selectById(memberId); - } - - CalculateUtil.getForceSetPriceForWhole(symbol, memberEntity); + for (Long memberId : wholeHoldOrders) { + ThreadPoolUtils.sendWholePrice(memberId); } } @@ -151,20 +147,20 @@ // 开多委托 model = new OrderModel(order.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_MORE.getValue(), entrustPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), - order.getSymbol()); + order.getSymbol(), order.getMemberId()); } else if (ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_LESS == entrustType){ model = new OrderModel(order.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_LESS.getValue(), entrustPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), - order.getSymbol()); + order.getSymbol(), order.getMemberId()); } else if (ContractEntrustOrderEntity.ENTRUST_TYPE_CLOSE_MORE == entrustType) { model = new OrderModel(order.getId(), RabbitPriceTypeEnum.ENTRUST_CLOSE_MORE.getValue(), entrustPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), - order.getSymbol()); + order.getSymbol(), order.getMemberId()); } else { model = new OrderModel(order.getId(), RabbitPriceTypeEnum.ENTRUST_CLOSE_LESS.getValue(), entrustPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), - order.getSymbol()); + order.getSymbol(), order.getMemberId()); } producer.sendPriceOperate(JSONObject.toJSONString(model)); } -- Gitblit v1.9.1