mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-22 12:05:05 +08:00
使用自定义线程池
This commit is contained in:
@@ -36,6 +36,7 @@ import com.jsowell.common.util.YKCUtils;
|
||||
import com.jsowell.common.util.bean.BeanUtils;
|
||||
import com.jsowell.common.util.id.IdUtils;
|
||||
import com.jsowell.common.util.id.SnowflakeIdWorker;
|
||||
import com.jsowell.common.util.spring.SpringUtils;
|
||||
import com.jsowell.pile.domain.*;
|
||||
import com.jsowell.pile.dto.*;
|
||||
import com.jsowell.pile.dto.nanrui.NRQueryOrderDTO;
|
||||
@@ -67,6 +68,7 @@ import org.apache.commons.collections4.CollectionUtils;
|
||||
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 org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -91,6 +93,9 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
// 引入线程池
|
||||
private ThreadPoolTaskExecutor executor = SpringUtils.getBean("threadPoolTaskExecutor");
|
||||
|
||||
@Autowired
|
||||
private OrderBasicInfoMapper orderBasicInfoMapper;
|
||||
|
||||
@@ -599,7 +604,7 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
// 清缓存
|
||||
this.cleanCacheByOrderCode(orderBasicInfo.getOrderCode(), orderBasicInfo.getTransactionCode());
|
||||
int i = orderBasicInfoMapper.updateOrderBasicInfo(orderBasicInfo);
|
||||
CompletableFuture.runAsync(() -> this.cleanCacheByOrderCode(orderBasicInfo.getOrderCode(), orderBasicInfo.getTransactionCode()));
|
||||
CompletableFuture.runAsync(() -> this.cleanCacheByOrderCode(orderBasicInfo.getOrderCode(), orderBasicInfo.getTransactionCode()), executor);
|
||||
logger.info("修改订单updateOrderBasicInfo:{}", JSON.toJSONString(orderBasicInfo));
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.spring.SpringUtils;
|
||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||
import com.jsowell.pile.domain.PileBasicInfo;
|
||||
import com.jsowell.pile.domain.PileConnectorInfo;
|
||||
@@ -39,6 +40,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
@@ -60,6 +62,10 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
@Service
|
||||
public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
|
||||
|
||||
// 引入线程池
|
||||
private ThreadPoolTaskExecutor executor = SpringUtils.getBean("threadPoolTaskExecutor");
|
||||
|
||||
@Autowired
|
||||
private PileConnectorInfoMapper pileConnectorInfoMapper;
|
||||
|
||||
@@ -619,7 +625,7 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
|
||||
redisCache.setCacheObject(redisKey, status, CacheConstants.cache_expire_time_5m);
|
||||
|
||||
// 异步放缓存
|
||||
CompletableFuture.runAsync(() -> statusChange(pileConnectorCode));
|
||||
CompletableFuture.runAsync(() -> statusChange(pileConnectorCode), executor);
|
||||
}
|
||||
return num;
|
||||
}
|
||||
@@ -678,7 +684,7 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
|
||||
// 异步将此桩正在进行充电的订单状态改为 异常
|
||||
CompletableFuture.runAsync(() -> {
|
||||
orderBasicInfoService.updateOrderStatusAsAbnormal(pileSn);
|
||||
});
|
||||
}, executor);
|
||||
}
|
||||
|
||||
// 没有故障或者离线,就是在线状态
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.DictUtils;
|
||||
import com.jsowell.common.util.PageUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.spring.SpringUtils;
|
||||
import com.jsowell.pile.domain.PileMerchantInfo;
|
||||
import com.jsowell.pile.dto.CreateMerchantDTO;
|
||||
import com.jsowell.pile.dto.QueryMerchantInfoDTO;
|
||||
@@ -27,6 +28,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -45,6 +47,9 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
@Service
|
||||
public class PileMerchantInfoServiceImpl implements PileMerchantInfoService {
|
||||
// 引入线程池
|
||||
private ThreadPoolTaskExecutor executor = SpringUtils.getBean("threadPoolTaskExecutor");
|
||||
|
||||
@Autowired
|
||||
private PileMerchantInfoMapper pileMerchantInfoMapper;
|
||||
|
||||
@@ -480,7 +485,7 @@ public class PileMerchantInfoServiceImpl implements PileMerchantInfoService {
|
||||
update.setId(Long.parseLong(merchantId));
|
||||
update.setAppId(finalAppId);
|
||||
updatePileMerchantInfo(update);
|
||||
});
|
||||
}, executor);
|
||||
return appId;
|
||||
}
|
||||
return appId;
|
||||
|
||||
Reference in New Issue
Block a user