From dca3e301410be4aee5a7895a1c2c1bbf90f3d03b Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Wed, 16 Mar 2022 15:21:36 +0800
Subject: [PATCH] 20222223
---
src/main/java/com/xcong/excoin/utils/ThreadPoolUtils.java | 46 +++++++++++++++++-----------------------------
1 files changed, 17 insertions(+), 29 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/utils/ThreadPoolUtils.java b/src/main/java/com/xcong/excoin/utils/ThreadPoolUtils.java
index 3a1adff..166ff77 100644
--- a/src/main/java/com/xcong/excoin/utils/ThreadPoolUtils.java
+++ b/src/main/java/com/xcong/excoin/utils/ThreadPoolUtils.java
@@ -4,8 +4,10 @@
import com.alibaba.fastjson.JSONObject;
import com.xcong.excoin.common.contants.AppContants;
import com.xcong.excoin.common.enumerates.CoinTypeEnum;
+import com.xcong.excoin.modules.contract.dao.ContractEntrustOrderDao;
import com.xcong.excoin.modules.contract.dao.ContractHoldOrderDao;
import com.xcong.excoin.modules.contract.dao.ContractOrderDao;
+import com.xcong.excoin.modules.contract.entity.ContractEntrustOrderEntity;
import com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity;
import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
import com.xcong.excoin.modules.contract.mapper.ContractHoldOrderEntityMapper;
@@ -18,6 +20,7 @@
import com.xcong.excoin.rabbit.pricequeue.whole.WholePriceDataModel;
import com.xcong.excoin.rabbit.producer.OrderProducer;
import com.xcong.excoin.utils.dingtalk.DingTalkUtils;
+import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import javax.validation.constraints.NotNull;
@@ -106,39 +109,24 @@
* @param memberId
*/
public static void sendWholePrice(@NotNull Long memberId) {
- log.info("执行了这个方法");
+ EXECUTOR.execute(new Runnable() {
+ @SneakyThrows
+ @Override
+ public void run() {
+ Thread.sleep(500);
+ log.info("全仓操作价格");
+ OrderProducer orderProducer = SpringContextHolder.getBean(OrderProducer.class);
+ orderProducer.sendWholePrice(memberId.toString());
+ }
+ });
+ }
+
+ public static void sendOrderMsg() {
EXECUTOR.execute(new Runnable() {
@Override
public void run() {
- log.info("全仓操作价格");
- ContractHoldOrderDao contractHoldOrderDao = SpringContextHolder.getBean(ContractHoldOrderDao.class);
- RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class);
- MemberWalletContractDao memberWalletContractDao = SpringContextHolder.getBean(MemberWalletContractDao.class);
-
- List<ContractHoldOrderEntity> holdOrders = contractHoldOrderDao.selectHoldOrderListByMemberId(memberId);
- if (CollUtil.isEmpty(holdOrders)) {
- return;
- }
- MemberWalletContractEntity wallet = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, CoinTypeEnum.USDT.name());
-
- WholePriceDataModel wholePriceData = new WholePriceDataModel();
- List<HoldOrderDataModel> holdOrderDataModels = ContractHoldOrderEntityMapper.INSTANCE.entitiesToDataModels(holdOrders);
- wholePriceData.setList(holdOrderDataModels);
-
- BigDecimal totalHoldBond = BigDecimal.ZERO;
- for (ContractHoldOrderEntity holdOrder : holdOrders) {
- totalHoldBond = totalHoldBond.add(holdOrder.getHoldBond() == null ? BigDecimal.ZERO : holdOrder.getHoldBond());
- }
-
- wholePriceData.setHoldBond(totalHoldBond);
- wholePriceData.setBalance(wallet.getTotalBalance());
- wholePriceData.setMemberId(memberId);
-
- OrderProducer orderProducer = SpringContextHolder.getBean(OrderProducer.class);
-
- orderProducer.sendWholePrice(JSONObject.toJSONString(wholePriceData));
+ DingTalkUtils.sendOrderMsg();
}
});
-
}
}
--
Gitblit v1.9.1