opt:修复获取不到调试信息。
This commit is contained in:
@@ -9,6 +9,8 @@ import java.util.Map;
|
||||
* @date 2021-09-02
|
||||
**/
|
||||
public interface HomeService {
|
||||
|
||||
|
||||
/**
|
||||
* 查询头部
|
||||
*
|
||||
@@ -31,4 +33,8 @@ public interface HomeService {
|
||||
*/
|
||||
Map<String, Object> clickSave(Map<String, String> jsonObject);
|
||||
|
||||
|
||||
void qeryDebuggerInfo();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -100,10 +100,10 @@ public class DevelopServiceImpl implements DevelopService {
|
||||
@Override
|
||||
public Map<String, Object> debugInfo(Map<String, String> jsonObject) {
|
||||
//先执行这个方法确保debugger有数据
|
||||
HomeServiceImpl impl = new HomeServiceImpl();
|
||||
do {
|
||||
impl.QueryDebuggerInfo();
|
||||
} while (ObjectUtil.isEmpty(HomeServiceImpl.debugInfoJson));
|
||||
// HomeServiceImpl impl = new HomeServiceImpl();
|
||||
// do {
|
||||
// impl.queryDebuggerInfo();
|
||||
// } while (ObjectUtil.isEmpty(HomeServiceImpl.debugInfoJson));
|
||||
JSONObject returnjo = new JSONObject();
|
||||
JSONObject map = HomeServiceImpl.debugInfoJson;
|
||||
Iterator iter = map.entrySet().iterator();
|
||||
|
||||
@@ -169,8 +169,8 @@ public class ErrorServiceImpl implements ErrorService{
|
||||
return returnjo;
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.error("获取调试信息失败:" + e.getMessage());
|
||||
throw new BadRequestException( e.getMessage()==null?"Ros通信失败,请检查网络连接":e.getMessage());
|
||||
Log.error("通信失败:" + e.getMessage());
|
||||
throw new BadRequestException( e.getMessage()==null?"通信失败,请检查系统参数中的Ros连接信息":e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,8 @@ public class HomeServiceImpl implements HomeService{
|
||||
//定时器查询调试信息,放入json其他地方直接调用;
|
||||
public static JSONObject debugInfoJson = new JSONObject();
|
||||
|
||||
public void QueryDebuggerInfo() {
|
||||
@Override
|
||||
public void qeryDebuggerInfo() {
|
||||
try {
|
||||
Map<String,String> urlInfo = RosUtil.getRosHostInfo();
|
||||
String result1 = HttpUtil.get(urlInfo.get("javaUrl"));
|
||||
@@ -123,8 +124,8 @@ public class HomeServiceImpl implements HomeService{
|
||||
debugInfoJson.put("PathFollow_Enable", PathFollow_Enable);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.error("获取调试信息失败:" + e.getMessage());
|
||||
throw new BadRequestException(e.getMessage());
|
||||
Log.error("通信失败:" + e.getMessage());
|
||||
throw new BadRequestException("通信失败,请检查系统参数中的java端口信息");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,7 +245,7 @@ public class HomeServiceImpl implements HomeService{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryHomePage(Map<String,String> jsonObject) {
|
||||
public Map<String,Object>queryHomePage(Map<String,String> jsonObject) {
|
||||
String button_code = "";
|
||||
String button_name = "";
|
||||
Integer electric = 0;
|
||||
@@ -359,8 +360,8 @@ public class HomeServiceImpl implements HomeService{
|
||||
return returnjo;
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.error("获取调试信息失败:" + e.getMessage());
|
||||
throw new BadRequestException( e.getMessage()==null?"Ros通信失败,请检查网络连接":e.getMessage());
|
||||
Log.error("通信失败:" + e.getMessage());
|
||||
throw new BadRequestException( e.getMessage()==null?"通信失败,请检查系统参数中的Ros连接信息":e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -88,8 +88,8 @@ public class TaskServiceServiceImpl implements TaskService{
|
||||
return returnjo;
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.error("获取调试信息失败:" + e.getMessage());
|
||||
throw new BadRequestException( e.getMessage()==null?"Ros通信失败,请检查网络连接":e.getMessage());
|
||||
Log.error("通信失败:" + e.getMessage());
|
||||
throw new BadRequestException( e.getMessage()==null?"通信失败,请检查系统参数中的Ros连接信息":e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -205,8 +205,8 @@ public class VehicleInfoServiceImpl implements VehicleInfoService{
|
||||
returnjo.put("result", row);
|
||||
return returnjo;
|
||||
} catch(Exception e) {
|
||||
Log.error("获取调试信息失败:" + e.getMessage());
|
||||
throw new BadRequestException( e.getMessage()==null?"Ros通信失败,请检查网络连接":e.getMessage());
|
||||
Log.error("通信失败:" + e.getMessage());
|
||||
throw new BadRequestException( e.getMessage()==null?"通信失败,请检查系统参数中的Ros连接信息":e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,8 +287,8 @@ public class VehicleInfoServiceImpl implements VehicleInfoService{
|
||||
returnjo.put("result", row);
|
||||
return returnjo;
|
||||
} catch(Exception e) {
|
||||
Log.error("获取调试信息失败:" + e.getMessage());
|
||||
throw new BadRequestException( e.getMessage()==null?"Ros通信失败,请检查网络连接":e.getMessage());
|
||||
Log.error("通信失败:" + e.getMessage());
|
||||
throw new BadRequestException( e.getMessage()==null?"通信失败,请检查系统参数中的Ros连接信息":e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,11 +35,11 @@ public class RosUtil{
|
||||
public static Map<String,String> getRosHostInfo() {
|
||||
Map<String,String> map = new HashMap<>();
|
||||
try {
|
||||
String ros_host = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("ros_host").getValue();
|
||||
String ros_port = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("ros_port").getValue();
|
||||
String rosHost = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("ros_host").getValue();
|
||||
String rosPort = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("ros_port").getValue();
|
||||
String javaPort = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("java_port").getValue();
|
||||
map.put("hostName", ros_host);
|
||||
map.put("port", ros_port);
|
||||
map.put("hostName", rosHost);
|
||||
map.put("port", rosPort);
|
||||
map.put("javaPort", javaPort);
|
||||
map.put("url", map.get("hostName") + ":" + map.get("port"));
|
||||
map.put("javaUrl", "http://"+map.get("hostName") + ":" + map.get("javaPort"));
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.nl.config.thread.AsyncTaskExecutePool;
|
||||
import org.nl.config.thread.ThreadPoolExecutorUtil;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.system.service.ql.IPdmQlOptionService;
|
||||
|
||||
@@ -17,8 +17,10 @@ package org.nl.config.thread;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
@@ -26,14 +28,17 @@ import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* 异步任务线程池装配类
|
||||
*
|
||||
* @author https://juejin.im/entry/5abb8f6951882555677e9da2
|
||||
* @date 2019年10月31日15:06:18
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class AsyncTaskExecutePool implements AsyncConfigurer {
|
||||
|
||||
/** 注入配置类 */
|
||||
@EnableAsync
|
||||
public class AsyncTaskExecutePool implements AsyncConfigurer{
|
||||
/**
|
||||
* 注入配置类
|
||||
*/
|
||||
private final AsyncTaskProperties config;
|
||||
|
||||
public AsyncTaskExecutePool(AsyncTaskProperties config) {
|
||||
@@ -60,11 +65,41 @@ public class AsyncTaskExecutePool implements AsyncConfigurer {
|
||||
return executor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 线程池配置
|
||||
* @return java.util.concurrent.Executor
|
||||
* @author gbx
|
||||
* @since 2023-06-16
|
||||
*/
|
||||
@Bean(name = "taskExecutor")
|
||||
public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
|
||||
ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
|
||||
// 核心线程池大小
|
||||
threadPoolTaskExecutor.setCorePoolSize(config.getCorePoolSize());
|
||||
// 最大线程数
|
||||
threadPoolTaskExecutor.setMaxPoolSize(config.getMaxPoolSize());
|
||||
// 队列容量
|
||||
threadPoolTaskExecutor.setQueueCapacity(config.getQueueCapacity());
|
||||
// 活跃时间
|
||||
threadPoolTaskExecutor.setKeepAliveSeconds(config.getKeepAliveSeconds());
|
||||
// 主线程等待子线程执行时间
|
||||
threadPoolTaskExecutor.setAwaitTerminationSeconds(config.getAwaitTerminationSeconds());
|
||||
// threadPoolTaskExecutor.setAwaitTerminationSeconds(30);
|
||||
// 线程名字前缀
|
||||
threadPoolTaskExecutor.setThreadNamePrefix("test-thread-");
|
||||
// RejectedExecutionHandler:当pool已经达到max-size的时候,如何处理新任务
|
||||
// CallerRunsPolicy:不在新线程中执行任务,而是由调用者所在的线程来执行
|
||||
threadPoolTaskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
// 初始化
|
||||
threadPoolTaskExecutor.initialize();
|
||||
return threadPoolTaskExecutor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
||||
return (throwable, method, objects) -> {
|
||||
log.error("===="+throwable.getMessage()+"====", throwable);
|
||||
log.error("exception method:"+method.getName());
|
||||
log.error("====" + throwable.getMessage() + "====", throwable);
|
||||
log.error("exception method:" + method.getName());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
package org.nl.config.thread;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -38,4 +36,7 @@ public class AsyncTaskProperties {
|
||||
private int keepAliveSeconds;
|
||||
|
||||
private int queueCapacity;
|
||||
|
||||
private int awaitTerminationSeconds;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
*/
|
||||
package org.nl.config.thread;
|
||||
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
@@ -26,16 +27,17 @@ import java.util.concurrent.TimeUnit;
|
||||
* @author Zheng Jie
|
||||
* @date 2019年10月31日18:16:47
|
||||
*/
|
||||
@Configuration
|
||||
public class ThreadPoolExecutorUtil {
|
||||
|
||||
public static ThreadPoolExecutor getPoll(){
|
||||
AsyncTaskProperties properties = SpringContextHolder.getBean(AsyncTaskProperties.class);
|
||||
@Bean(name = "threadPool")
|
||||
public static ThreadPoolExecutor getPoll(){
|
||||
return new ThreadPoolExecutor(
|
||||
properties.getCorePoolSize(),
|
||||
properties.getMaxPoolSize(),
|
||||
properties.getKeepAliveSeconds(),
|
||||
8,
|
||||
32,
|
||||
30,
|
||||
TimeUnit.SECONDS,
|
||||
new ArrayBlockingQueue<>(properties.getQueueCapacity()),
|
||||
new ArrayBlockingQueue<>(128),
|
||||
new TheadFactoryName()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.nl.system.service.quartz.utils;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.config.thread.AsyncTaskExecutePool;
|
||||
import org.nl.config.thread.ThreadPoolExecutorUtil;
|
||||
import org.nl.modules.common.utils.RedisUtils;
|
||||
import org.nl.modules.common.utils.ThrowableUtil;
|
||||
|
||||
@@ -18,12 +18,15 @@ package org.nl.system.service.secutiry.impl;
|
||||
import cn.dev33.satoken.secure.SaSecureUtil;
|
||||
import cn.dev33.satoken.stp.SaLoginModel;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.agv.service.HomeService;
|
||||
import org.nl.agv.service.impl.HomeServiceImpl;
|
||||
import org.nl.modules.common.config.RsaProperties;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.*;
|
||||
@@ -35,15 +38,19 @@ import org.nl.system.service.user.dto.CurrentUser;
|
||||
import org.nl.system.service.user.dto.OnlineUserDto;
|
||||
import org.nl.system.service.user.dto.UserDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
@@ -52,10 +59,17 @@ import java.util.*;
|
||||
@Service
|
||||
@Slf4j
|
||||
public class OnlineUserService{
|
||||
|
||||
@Resource
|
||||
@Qualifier("threadPool")
|
||||
private ThreadPoolExecutor pool;
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
@Autowired
|
||||
private ISysRoleService roleService;
|
||||
@Autowired
|
||||
private HomeService homeService;
|
||||
|
||||
private final RedisUtils redisUtils;
|
||||
@Value("${sa-token.cookie.domain}")
|
||||
private String domain;
|
||||
@@ -225,6 +239,8 @@ public class OnlineUserService{
|
||||
|
||||
@SneakyThrows
|
||||
public Map<String,Object> login(Map paramMap) {
|
||||
//查询调试信息
|
||||
CompletableFuture.runAsync(this::queryDebugInfo, pool);
|
||||
// 密码解密 - 前端的加密规则: encrypt
|
||||
AuthUserDto authUser = JSON.toJavaObject((JSON) JSON.toJSON(paramMap), AuthUserDto.class);
|
||||
String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, authUser.getPassword());
|
||||
@@ -271,4 +287,8 @@ public class OnlineUserService{
|
||||
//onlineUserService.save(userDto, StpUtil.getTokenValue(), request);
|
||||
return authInfo;
|
||||
}
|
||||
|
||||
public void queryDebugInfo() {
|
||||
homeService.qeryDebuggerInfo();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user