| package com.xcong.excoin.utils; | 
|   | 
| import cn.hutool.core.collection.CollUtil; | 
| 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; | 
| import com.xcong.excoin.modules.contract.service.impl.OrderWebsocketServiceImpl; | 
| import com.xcong.excoin.modules.documentary.service.FollowOrderOperationService; | 
| import com.xcong.excoin.modules.member.dao.MemberWalletContractDao; | 
| import com.xcong.excoin.modules.member.entity.MemberEntity; | 
| import com.xcong.excoin.modules.member.entity.MemberWalletContractEntity; | 
| import com.xcong.excoin.rabbit.pricequeue.whole.HoldOrderDataModel; | 
| 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; | 
| import java.math.BigDecimal; | 
| import java.util.List; | 
| import java.util.concurrent.ExecutorService; | 
| import java.util.concurrent.Executors; | 
|   | 
| /** | 
|  * @author wzy | 
|  * @date 2020-06-01 | 
|  **/ | 
| @Slf4j | 
| public class ThreadPoolUtils { | 
|   | 
|     public static final ExecutorService EXECUTOR = Executors.newFixedThreadPool(20); | 
|   | 
|     /** | 
|      * 计算佣金 | 
|      * | 
|      * @param id     用户ID | 
|      * @param price  手续费 | 
|      * @param entity 订单实体 | 
|      * @param type   订单类型 | 
|      */ | 
|     public static void calReturnMoney(Long id, BigDecimal price, ContractOrderEntity entity, int type) { | 
|         OrderWebsocketServiceImpl orderWebsocketService = SpringContextHolder.getBean(OrderWebsocketServiceImpl.class); | 
|         EXECUTOR.execute(new Runnable() { | 
|             @Override | 
|             public void run() { | 
|                 orderWebsocketService.calYj(id, price, entity, type); | 
|             } | 
|         }); | 
|     } | 
|   | 
|     /** | 
|      * 发送钉钉消息 | 
|      * | 
|      * @param type 类型 | 
|      */ | 
|     public static void sendDingTalk(int type) { | 
|         EXECUTOR.execute(new Runnable() { | 
|             @Override | 
|             public void run() { | 
|                 DingTalkUtils.sendActionCard(type); | 
|             } | 
|         }); | 
|     } | 
|   | 
|     public static void sendFollowOrderTask(Long id) { | 
|         FollowOrderOperationService followOrderOperationService = SpringContextHolder.getBean(FollowOrderOperationService.class); | 
|         EXECUTOR.execute(new Runnable() { | 
|             @Override | 
|             public void run() { | 
|                 try { | 
|                     followOrderOperationService.addFollowerOrder(id); | 
|                 } catch (Exception e) { | 
|                     log.error("产生跟单任务报错", e); | 
|                 } | 
|             } | 
|         }); | 
|     } | 
|   | 
|     /** | 
|      * 全仓模式 -- 预估强平价 | 
|      * | 
|      * @param symbol       币种 | 
|      * @param memberEntity 会员信息 | 
|      */ | 
|     public static void sendWholeForceClosingPrice(@NotNull String symbol, @NotNull MemberEntity memberEntity) { | 
|         EXECUTOR.execute(new Runnable() { | 
|             @Override | 
|             public void run() { | 
|                 try { | 
|                     CalculateUtil.getForceSetPriceForWhole(null, memberEntity); | 
|                 } catch (Exception e) { | 
|                     log.error("全仓模式预估强平价", e); | 
|                 } | 
|             } | 
|         }); | 
|     } | 
|   | 
|     /** | 
|      * 发送全仓价格操作 | 
|      * | 
|      * @param memberId | 
|      */ | 
|     public static void sendWholePrice(@NotNull Long memberId) { | 
|         EXECUTOR.execute(new Runnable() { | 
|             @SneakyThrows | 
|             @Override | 
|             public void run() { | 
|                 Thread.sleep(500); | 
|                 log.info("全仓操作价格"); | 
|                 OrderProducer orderProducer = SpringContextHolder.getBean(OrderProducer.class); | 
|                 orderProducer.sendWholePrice(memberId.toString()); | 
|             } | 
|         }); | 
|     } | 
| } |