mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 11:35:12 +08:00
使用自定义线程池
This commit is contained in:
@@ -11,6 +11,7 @@ import com.jsowell.common.enums.DelFlagEnum;
|
||||
import com.jsowell.common.enums.ykc.*;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.*;
|
||||
import com.jsowell.common.util.spring.SpringUtils;
|
||||
import com.jsowell.pile.domain.*;
|
||||
import com.jsowell.pile.dto.*;
|
||||
import com.jsowell.pile.service.*;
|
||||
@@ -27,6 +28,7 @@ import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -41,6 +43,9 @@ import java.util.stream.Collectors;
|
||||
public class PileService {
|
||||
private final Logger log = LoggerFactory.getLogger(PileService.class);
|
||||
|
||||
// 引入线程池
|
||||
private ThreadPoolTaskExecutor executor = SpringUtils.getBean("threadPoolTaskExecutor");
|
||||
|
||||
@Autowired
|
||||
private TransactionService pileTransactionService;
|
||||
|
||||
@@ -156,7 +161,7 @@ public class PileService {
|
||||
/**
|
||||
* 前端扫码跳转接口
|
||||
*/
|
||||
public AppletPileDetailVO getPileDetailByPileSn(String param) throws Exception {
|
||||
public AppletPileDetailVO getPileDetailByPileSnV2(String param) throws Exception {
|
||||
AppletPileDetailVO vo = null;
|
||||
log.info("查询充电枪口详情-getPileDetailByPileSn, param:{}", param);
|
||||
if (StringUtils.isBlank(param)) {
|
||||
@@ -200,7 +205,7 @@ public class PileService {
|
||||
return vo;
|
||||
}
|
||||
|
||||
public AppletPileDetailVO getPileDetailByPileSnOld(String param) throws Exception {
|
||||
public AppletPileDetailVO getPileDetailByPileSn(String param) throws Exception {
|
||||
AppletPileDetailVO vo = null;
|
||||
log.info("查询充电枪口详情-getPileDetailByPileSn, param:{}", param);
|
||||
if (StringUtils.isBlank(param)) {
|
||||
@@ -231,16 +236,16 @@ public class PileService {
|
||||
}
|
||||
|
||||
// 查询充电桩下枪口信息
|
||||
CompletableFuture<List<ConnectorInfoVO>> connectorInfoListFuture = FutureUtil.supplyAsync(() -> pileConnectorInfoService.selectConnectorInfoList(pileSn));
|
||||
log.info("查询充电枪口详情-supplyAsync-selectConnectorInfoList:{}", connectorInfoListFuture);
|
||||
CompletableFuture<List<ConnectorInfoVO>> connectorInfoListFuture = CompletableFuture.supplyAsync(() -> pileConnectorInfoService.selectConnectorInfoList(pileSn), executor);
|
||||
// log.info("查询充电枪口详情-supplyAsync-selectConnectorInfoList:{}", connectorInfoListFuture);
|
||||
|
||||
// 查计费模板信息
|
||||
CompletableFuture<List<BillingPriceVO>> billingPriceFuture = FutureUtil.supplyAsync(() -> pileBillingTemplateService.queryBillingPrice(pileInfoVO.getStationId()));
|
||||
log.info("查询充电枪口详情-supplyAsync-queryBillingPrice:{}", billingPriceFuture);
|
||||
CompletableFuture<List<BillingPriceVO>> billingPriceFuture = CompletableFuture.supplyAsync(() -> pileBillingTemplateService.queryBillingPrice(pileInfoVO.getStationId()), executor);
|
||||
// log.info("查询充电枪口详情-supplyAsync-queryBillingPrice:{}", billingPriceFuture);
|
||||
|
||||
// 查询运营商信息
|
||||
CompletableFuture<MerchantInfoVO> merchantInfoVOFuture = FutureUtil.supplyAsync(() -> pileMerchantInfoService.getMerchantInfoVO(pileInfoVO.getMerchantId()));
|
||||
log.info("查询充电枪口详情-supplyAsync-getMerchantInfoVO:{}", merchantInfoVOFuture);
|
||||
CompletableFuture<MerchantInfoVO> merchantInfoVOFuture = CompletableFuture.supplyAsync(() -> pileMerchantInfoService.getMerchantInfoVO(pileInfoVO.getMerchantId()), executor);
|
||||
// log.info("查询充电枪口详情-supplyAsync-getMerchantInfoVO:{}", merchantInfoVOFuture);
|
||||
|
||||
CompletableFuture all = FutureUtil.allOf(connectorInfoListFuture, merchantInfoVOFuture, billingPriceFuture);
|
||||
// .join()和.get()都会阻塞并获取线程的执行情况
|
||||
|
||||
Reference in New Issue
Block a user