监听器和语音识别bug修改

This commit is contained in:
joylink_zhangsai 2020-11-20 13:04:27 +08:00
parent 132246ae49
commit 9114e56582
4 changed files with 106 additions and 3 deletions

View File

@ -0,0 +1,103 @@
package club.joylink.rtss.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import java.util.concurrent.ThreadPoolExecutor;
@Configuration
@EnableAsync
public class TaskExecutorConfiguration {
/***
* 创建仿真异步逻辑执行线程池
* @return
*/
@Bean("simulationExecutor")
public TaskExecutor simulationExecutor(Environment env) {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setThreadNamePrefix("simulation-executor-");
taskExecutor.setCorePoolSize(1);
taskExecutor.setMaxPoolSize(1);
taskExecutor.setQueueCapacity(10);
taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
taskExecutor.initialize();
return taskExecutor;
}
/***
* 创建新仿真异步逻辑执行线程池
* @return
*/
@Bean("nsExecutor")
public TaskExecutor nsExecutor(Environment env) {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setThreadNamePrefix("ns-executor-");
taskExecutor.setCorePoolSize(2);
taskExecutor.setMaxPoolSize(2);
taskExecutor.setQueueCapacity(100);
taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
taskExecutor.initialize();
return taskExecutor;
}
/***
* 创建新仿真异步逻辑执行线程池
* @return
*/
@Bean("realDeviceExecutor")
public TaskExecutor realDeviceExecutor(Environment env) {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setThreadNamePrefix("real-device-executor-");
taskExecutor.setCorePoolSize(1);
taskExecutor.setMaxPoolSize(1);
taskExecutor.setQueueCapacity(100);
taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
taskExecutor.initialize();
return taskExecutor;
}
/***
* 异步逻辑执行线程池
* @return
*/
@Bean("commonExecutor")
public TaskExecutor commonExecutor(Environment env) {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setThreadNamePrefix("common-executor-");
taskExecutor.setMaxPoolSize(20);
taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
taskExecutor.initialize();
return taskExecutor;
}
/**定时任务调度器*/
@Bean("scheduler")
public ThreadPoolTaskScheduler threadPoolTaskScheduler(){
return new ThreadPoolTaskScheduler();
}
/***
* 创建仿真UDP数据处理执行线程池
* @return
*/
@Bean("socketExecutor")
public TaskExecutor socketExecutor(Environment env) {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setThreadNamePrefix("socket-executor-");
taskExecutor.setCorePoolSize(1);
taskExecutor.setMaxPoolSize(1);
taskExecutor.setQueueCapacity(10);
taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
taskExecutor.initialize();
return taskExecutor;
}
}

View File

@ -148,6 +148,6 @@ public class TokenHolder {
throw new RuntimeException("scope not exist, " + scope + "," + result);
}
token = (String)map.get("access_token");
expiresAt = System.currentTimeMillis() + ((Long)map.get("expires_in")) * 1000;
expiresAt = System.currentTimeMillis() + (Long.parseLong(map.get("expires_in").toString())) * 1000;
}
}

View File

@ -600,7 +600,6 @@ public class SimulationMainThread {
this.stompMessageService.sendToUser(userIds, message);
}
@Order(1)
@EventListener(SimulationConversationChatEvent.class)
public void conversationChat(SimulationConversationChatEvent event) {
Simulation simulation = event.getSimulation();

View File

@ -1,8 +1,8 @@
package club.joylink.rtss.simulation.cbtc.competition;
import club.joylink.rtss.services.simulation.ScriptExecuteService;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.event.*;
import club.joylink.rtss.services.simulation.ScriptExecuteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
@ -36,6 +36,7 @@ public class CompetitionAndScriptListener {
}
}
@Async("nsExecutor")
@EventListener
public void handle(SimulationConversationMemberConnectEvent event) {
competitionAndScriptManager.try2FinishAcceptInvitationAction(event.getSimulation(), event.getMember());