From 33a69c65e1f6701bd29ef74d0681dbbe9a21cea7 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Fri, 29 Jan 2021 11:19:08 +0800
Subject: [PATCH] Merge branch 'whole_new' of https://gitee.com/chonggaoxiao/new_excoin.git into whole_new
---
src/main/java/com/xcong/excoin/rabbit/pricequeue/OrderOperatePriceService.java | 48 ++++++++++++++++++++++++++++++++++++++----------
1 files changed, 38 insertions(+), 10 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/rabbit/pricequeue/OrderOperatePriceService.java b/src/main/java/com/xcong/excoin/rabbit/pricequeue/OrderOperatePriceService.java
index 7685839..3609764 100644
--- a/src/main/java/com/xcong/excoin/rabbit/pricequeue/OrderOperatePriceService.java
+++ b/src/main/java/com/xcong/excoin/rabbit/pricequeue/OrderOperatePriceService.java
@@ -1,5 +1,12 @@
package com.xcong.excoin.rabbit.pricequeue;
+import com.alibaba.fastjson.JSONObject;
+import com.xcong.excoin.common.contants.AppContants;
+import com.xcong.excoin.rabbit.pricequeue.whole.WholeDataQueue;
+import com.xcong.excoin.rabbit.pricequeue.whole.WholePriceDataModel;
+import com.xcong.excoin.utils.RedisUtils;
+import com.xcong.excoin.utils.SpringContextHolder;
+import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
@@ -11,6 +18,7 @@
/**
* 处理消费者的订单止盈等价格信息
*/
+@Slf4j
public class OrderOperatePriceService {
/**
@@ -23,7 +31,7 @@
// 【1:买入委托2:开多3:开空4:平多5:平空6:爆仓平多7:爆仓平空8:撤单9:止盈平多10:止盈平空11:止损平多12:止损平空】
int type = orderModel.getType();
Map<String, List<OrderModel>> orderMap = PricePriorityQueue.getOrderMap(orderModel.getSymbol(), type);
- if (type == 12 || type == 9 || type == 7 || type == 3) {
+ if (type == 12 || type == 9 || type == 7 || type == 3 || type == 4) {
// 需要价格涨的
PriorityBlockingQueue<AscBigDecimal> queue = PricePriorityQueue.getQueueAsc(orderModel.getSymbol());
dealPriceAsc(orderModel, orderMap, queue);
@@ -48,22 +56,25 @@
Long orderId = order.getOrderId();
queue.add(new DescBigDecimal(price));
+// log.info("原有:{}", JSONObject.toJSONString(orderMap));
removeExistOrder(type, orderId, orderMap);
+// log.info("删除后:{}", JSONObject.toJSONString(orderMap));
if (orderMap.containsKey(price)) {
// 有这个价的key
List<OrderModel> list = orderMap.get(price);
// 判断这个单的这个类型是否有
- if (CollectionUtils.isNotEmpty(list)) {
+// if (CollectionUtils.isNotEmpty(list)) {
// 新增
- OrderModel orderModel = new OrderModel(orderId, type, price, null,order.getOperateNo());
+ OrderModel orderModel = new OrderModel(orderId, type, price, null,order.getOperateNo(), order.getMemberId());
list.add(orderModel);
- }
+// }
} else {
List<OrderModel> list = new ArrayList<OrderModel>();
- OrderModel orderModel = new OrderModel(orderId, type, price, null,order.getOperateNo());
+ OrderModel orderModel = new OrderModel(orderId, type, price, null,order.getOperateNo(), order.getMemberId());
list.add(orderModel);
orderMap.put(price, list);
}
+// log.info("调整后:{}", JSONObject.toJSONString(orderMap));
}
@@ -79,24 +90,26 @@
int type = order.getType();
Long orderId = order.getOrderId();
queue.add(new AscBigDecimal(price));
+// log.info("原有:{}", JSONObject.toJSONString(orderMap));
// 需要找到这个订单的原始的单进行处理
removeExistOrder(type, orderId, orderMap);
-
+// log.info("删除后:{}", JSONObject.toJSONString(orderMap));
if (orderMap.containsKey(price)) {
// 有这个价的key
List<OrderModel> list = orderMap.get(price);
// 判断这个单的这个类型是否有
- if (CollectionUtils.isNotEmpty(list)) {
+// if (CollectionUtils.isNotEmpty(list)) {
// 新增
- OrderModel orderModel = new OrderModel(orderId, type, price, null,order.getOperateNo());
+ OrderModel orderModel = new OrderModel(orderId, type, price, null,order.getOperateNo(), order.getMemberId());
list.add(orderModel);
- }
+// }
} else {
List<OrderModel> list = new ArrayList<OrderModel>();
- OrderModel orderModel = new OrderModel(orderId, type, price, null,order.getOperateNo());
+ OrderModel orderModel = new OrderModel(orderId, type, price, null,order.getOperateNo(), order.getMemberId());
list.add(orderModel);
orderMap.put(price, list);
}
+// log.info("调整后:{}", JSONObject.toJSONString(orderMap));
}
private static void removeExistOrder(Integer type, Long orderId, Map<String, List<OrderModel>> orderMap) {
@@ -121,4 +134,19 @@
}
}
+ public static void wholePriceDataOperation(WholePriceDataModel wholePriceData) {
+ RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class);
+
+ Map<String, WholePriceDataModel> dataModelMap = WholeDataQueue.MAP;
+
+ WholePriceDataModel isExistData = dataModelMap.get(wholePriceData.getMemberId().toString());
+ if (isExistData != null) {
+ dataModelMap.remove(wholePriceData.getMemberId().toString());
+ }
+
+ dataModelMap.put(wholePriceData.getMemberId().toString(), wholePriceData);
+
+ redisUtils.set(AppContants.WHOLE_BOMB_MAP, JSONObject.toJSONString(dataModelMap));
+ }
+
}
--
Gitblit v1.9.1