扩大线程池

This commit is contained in:
fengyarnom 2025-02-21 13:33:56 +08:00
parent 66c2b5c73a
commit 1a7634b9a6

View File

@ -47,7 +47,7 @@ public class SimStatusChecker {
@Resource(name = "local") @Resource(name = "local")
private DeviceService deviceService; private DeviceService deviceService;
private static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); private static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(3);
@Autowired @Autowired
private SimCardQueryServiceImpl simCardQueryServiceImpl; private SimCardQueryServiceImpl simCardQueryServiceImpl;
@ -56,12 +56,12 @@ public class SimStatusChecker {
@Scheduled(cron = "0 */10 * * * ?") @Scheduled(cron = "0 */10 * * * ?")
private void scheduleSimCardStatusCheck() { private void scheduleSimCardStatusCheck() {
List<GnssStatusJoin> onlineDevices = gnssStatusMapper.queryOnline(); List<GnssStatusJoin> onlineDevices = gnssStatusMapper.queryOnline();
logger.debug("当前在线设备数量: {}", onlineDevices.size()); logger.info("当前在线设备数量: {}", onlineDevices.size());
for (GnssStatusJoin onlineDevice : onlineDevices) { for (GnssStatusJoin onlineDevice : onlineDevices) {
//int delay = Math.abs(onlineDevice.getDeviceid().hashCode() % 3600 ); //int delay = Math.abs(onlineDevice.getDeviceid().hashCode() % 3600 );
int delay = Math.abs(onlineDevice.getDeviceid().hashCode() % 600 ); int delay = Math.abs(onlineDevice.getDeviceid().hashCode() % 600 );
logger.debug("设备: {}, SIM状态查询延迟执行: {}秒", onlineDevice.getDeviceid(), delay); logger.info("- 设备: {}, SIM状态查询延迟执行: {}秒", onlineDevice.getDeviceid(), delay);
scheduler.schedule(() -> checkDeviceSimCardStatus(onlineDevice.getDeviceid()), scheduler.schedule(() -> checkDeviceSimCardStatus(onlineDevice.getDeviceid()),
delay, TimeUnit.SECONDS); delay, TimeUnit.SECONDS);
@ -73,11 +73,11 @@ public class SimStatusChecker {
@Scheduled(cron = "0 */20 * * * ?") @Scheduled(cron = "0 */20 * * * ?")
private void scheduleSimCardTrafficCheck() { private void scheduleSimCardTrafficCheck() {
List<GnssStatusJoin> onlineDevices = gnssStatusMapper.queryOnline(); List<GnssStatusJoin> onlineDevices = gnssStatusMapper.queryOnline();
logger.debug("当前在线设备数量: {}", onlineDevices.size()); logger.info("当前在线设备数量: {}", onlineDevices.size());
for (GnssStatusJoin onlineDevice : onlineDevices) { for (GnssStatusJoin onlineDevice : onlineDevices) {
int delay = Math.abs(onlineDevice.getDeviceid().hashCode() % 1200); int delay = Math.abs(onlineDevice.getDeviceid().hashCode() % 1200);
logger.debug("设备: {}, SIM流量查询延迟执行: {}秒", onlineDevice.getDeviceid(), delay); logger.debug("- 设备: {}, SIM流量查询延迟执行: {}秒", onlineDevice.getDeviceid(), delay);
scheduler.schedule(() -> checkDeviceSimCardTraffic(onlineDevice.getDeviceid()), scheduler.schedule(() -> checkDeviceSimCardTraffic(onlineDevice.getDeviceid()),
delay, TimeUnit.SECONDS); delay, TimeUnit.SECONDS);