refactor: 重构供应商文件类型枚举及相关服务
feat: 为多个服务添加缓存支持 fix: 修复WebSocket任务管理和远程调用异常处理 refactor: 重命名CompanyVendorFileType为VendorFileType refactor: 优化项目成本导入任务实现 fix: 修复ContractTabSkinBase中的空指针问题 refactor: 统一WebSocket客户端任务调用接口
This commit is contained in:
@@ -134,7 +134,7 @@ public class WebSocketClientService {
|
||||
|
||||
@Override
|
||||
public void onFailure(WebSocket webSocket, Throwable t, Response response) {
|
||||
logger.error("WebSocket连接失败: " + t.getMessage());
|
||||
logger.error("WebSocket连接失败: " + t.getMessage() + ", response=" + response, t);
|
||||
Platform.runLater(() -> {
|
||||
online.setValue(false);
|
||||
message.set("连接失败: " + t.getMessage());
|
||||
@@ -179,13 +179,19 @@ public class WebSocketClientService {
|
||||
if (webSocket == null) {
|
||||
throw new IllegalStateException("WebSocket is not initialized");
|
||||
}
|
||||
|
||||
if (!online.get()) {
|
||||
throw new IllegalStateException("WebSocket is not online");
|
||||
}
|
||||
String json = objectMapper.writeValueAsString(msg);
|
||||
callbacks.put(msg.getMessageId(), future);
|
||||
if (webSocket.send(json)) {
|
||||
logger.debug("send message success:{}", json);
|
||||
} else {
|
||||
future.completeExceptionally(new RuntimeException("Failed to send WebSocket message"));
|
||||
if (isActive) {
|
||||
future.completeExceptionally(new RuntimeException("Failed to send WebSocket message"));
|
||||
} else {
|
||||
future.completeExceptionally(new RuntimeException("WebSocket is not active"));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to send WebSocket message: {}", e.getMessage());
|
||||
@@ -321,14 +327,14 @@ public class WebSocketClientService {
|
||||
}
|
||||
}
|
||||
|
||||
private void closeSession(WebSocketClientSession session) {
|
||||
public void closeSession(WebSocketClientSession session) {
|
||||
if (session != null) {
|
||||
sessions.remove(session.getSessionId());
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
private WebSocketClientSession createSession() {
|
||||
public WebSocketClientSession createSession() {
|
||||
WebSocketClientSession session = new WebSocketClientSession(this);
|
||||
sessions.put(session.getSessionId(), session);
|
||||
return session;
|
||||
|
||||
Reference in New Issue
Block a user