This commit is contained in:
lifangliang 2025-07-16 13:49:18 +08:00
parent 55a0898b1d
commit 65f06344cb
8 changed files with 22 additions and 14 deletions

11
pom.xml
View File

@ -5,14 +5,14 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.0</version>
<version>3.2.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.goeing</groupId>
<artifactId>zipship</artifactId>
<groupId>com.goeing.zipship</groupId>
<artifactId>zipshipPrintService</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>goeingPrintService</name>
<description>goeingPrintService</description>
<name>zipshipPrintService</name>
<description>zipshipPrintService</description>
<url/>
<licenses>
<license/>
@ -87,6 +87,7 @@
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>

View File

@ -33,7 +33,7 @@ public class PrintController implements PrintService {
@Autowired
private PrintServerConfig config;
private final String rootPath = "/Users/fl0919/work_space/goeingPrintServer/pdf";
private final String rootPath = "pdfTemp";
/**
* 获取所有可用打印机列表
@ -140,6 +140,8 @@ public class PrintController implements PrintService {
log.info("正在从以下地址下载文件: {}", fileUrl);
HttpUtil.downloadFile(fileUrl, filePath);
log.info("文件下载地址为:",filePath);
if (!pdfFile.exists() || pdfFile.length() == 0) {
throw new RuntimeException("Downloaded file is empty or does not exist");
}

View File

@ -3,6 +3,7 @@ package com.goeing.printserver.main.gui;
import com.goeing.printserver.main.domain.request.PrintRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import java.awt.*;
@ -19,7 +20,7 @@ public class PrintNotificationService {
private boolean headless = false;
@Autowired
public PrintNotificationService(PrintSettingsPanel settingsPanel) {
public PrintNotificationService(@Lazy PrintSettingsPanel settingsPanel) {
this.settingsPanel = settingsPanel;
// 检查是否在无头模式下运行
this.headless = GraphicsEnvironment.isHeadless() || Boolean.getBoolean("app.headless.mode");
@ -29,6 +30,7 @@ public class PrintNotificationService {
}
@Autowired
@Lazy
public void setPrintServerTray(PrintServerTray printServerTray) {
this.printServerTray = printServerTray;
}

View File

@ -9,6 +9,7 @@ import com.goeing.printserver.main.utils.MessageUtils;
import com.goeing.printserver.main.service.PrintQueueService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
@ -52,7 +53,7 @@ public class PrintSettingsPanel extends JPanel implements LocaleChangeListener {
private JButton resetButton;
@Autowired
public PrintSettingsPanel(PrintQueueService printQueueService, PrintServerConfig config, PrintController printController, PrinterClient printerClient) {
public PrintSettingsPanel(@Lazy PrintQueueService printQueueService, PrintServerConfig config, @Lazy PrintController printController, @Lazy PrinterClient printerClient) {
this.printQueueService = printQueueService;
this.config = config;
this.printController = printController;

View File

@ -9,6 +9,7 @@ import jakarta.websocket.Session;
import lombok.extern.slf4j.Slf4j;
import jakarta.annotation.PreDestroy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import java.io.IOException;
@ -30,12 +31,15 @@ import java.time.LocalDateTime;
public class PrintQueueService {
@Autowired
@Lazy
private PrintService printService;
@Autowired
@Lazy
private PrintNotificationService notificationService;
@Autowired
@Lazy
private PrintStatisticsPanel statisticsPanel;
@Autowired

View File

@ -1,18 +1,16 @@
package com.goeing.printserver.main.sse;
import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.goeing.printserver.main.PrintController;
import com.goeing.printserver.main.config.PrintServerConfig;
import com.goeing.printserver.main.domain.dto.WebSocketMessageDTO;
import com.goeing.printserver.main.domain.request.PrintRequest;
import com.goeing.printserver.main.service.PrintQueueService;
import jakarta.websocket.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import jakarta.annotation.PreDestroy;
@ -39,7 +37,7 @@ public class PrinterClient implements ApplicationRunner {
private boolean isConnecting = false;
// 构造函数注入PrintQueueService和PrintServerConfig
public PrinterClient(PrintQueueService printQueueService, PrintServerConfig config) {
public PrinterClient(@Lazy PrintQueueService printQueueService, PrintServerConfig config) {
this.printQueueService = printQueueService;
this.config = config;
// 构造函数不做连接操作在run方法中进行连接

View File

@ -1,7 +1,7 @@
spring.application.name=goeingPrintServer
server.port=9090
print.websocket.url=ws://127.0.0.1:8080/print-websocket
#print.websocket.url=ws://3.144.140.114:8080/print-websocket
print.websocket.url=ws://zipship.goeing.com/prod-api/print-websocket
#print.websocket.url=ws://127.0.0.1:8080/print-websocket
print.printer.id=123456
print.websocket.apiKey=519883ab-3677-ce4b-59ba-7263870d0a26

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB