Compare commits
2
Commits
34890faee6
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65f06344cb | ||
|
|
55a0898b1d |
@@ -5,14 +5,14 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.2.0</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>com.goeing</groupId>
|
<groupId>com.goeing.zipship</groupId>
|
||||||
<artifactId>printServer</artifactId>
|
<artifactId>zipshipPrintService</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<name>goeingPrintServer</name>
|
<name>zipshipPrintService</name>
|
||||||
<description>goeingPrintServer</description>
|
<description>zipshipPrintService</description>
|
||||||
<url/>
|
<url/>
|
||||||
<licenses>
|
<licenses>
|
||||||
<license/>
|
<license/>
|
||||||
@@ -87,6 +87,7 @@
|
|||||||
<path>
|
<path>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>${lombok.version}</version>
|
||||||
</path>
|
</path>
|
||||||
</annotationProcessorPaths>
|
</annotationProcessorPaths>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class PrintController implements PrintService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private PrintServerConfig config;
|
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);
|
log.info("正在从以下地址下载文件: {}", fileUrl);
|
||||||
HttpUtil.downloadFile(fileUrl, filePath);
|
HttpUtil.downloadFile(fileUrl, filePath);
|
||||||
|
|
||||||
|
log.info("文件下载地址为:",filePath);
|
||||||
|
|
||||||
if (!pdfFile.exists() || pdfFile.length() == 0) {
|
if (!pdfFile.exists() || pdfFile.length() == 0) {
|
||||||
throw new RuntimeException("Downloaded file is empty or does not exist");
|
throw new RuntimeException("Downloaded file is empty or does not exist");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.goeing.printserver.main.gui;
|
|||||||
import com.goeing.printserver.main.domain.request.PrintRequest;
|
import com.goeing.printserver.main.domain.request.PrintRequest;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -19,7 +20,7 @@ public class PrintNotificationService {
|
|||||||
private boolean headless = false;
|
private boolean headless = false;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public PrintNotificationService(PrintSettingsPanel settingsPanel) {
|
public PrintNotificationService(@Lazy PrintSettingsPanel settingsPanel) {
|
||||||
this.settingsPanel = settingsPanel;
|
this.settingsPanel = settingsPanel;
|
||||||
// 检查是否在无头模式下运行
|
// 检查是否在无头模式下运行
|
||||||
this.headless = GraphicsEnvironment.isHeadless() || Boolean.getBoolean("app.headless.mode");
|
this.headless = GraphicsEnvironment.isHeadless() || Boolean.getBoolean("app.headless.mode");
|
||||||
@@ -29,6 +30,7 @@ public class PrintNotificationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@Lazy
|
||||||
public void setPrintServerTray(PrintServerTray printServerTray) {
|
public void setPrintServerTray(PrintServerTray printServerTray) {
|
||||||
this.printServerTray = printServerTray;
|
this.printServerTray = printServerTray;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.goeing.printserver.main.utils.MessageUtils;
|
|||||||
import com.goeing.printserver.main.service.PrintQueueService;
|
import com.goeing.printserver.main.service.PrintQueueService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.context.event.EventListener;
|
import org.springframework.context.event.EventListener;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -52,7 +53,7 @@ public class PrintSettingsPanel extends JPanel implements LocaleChangeListener {
|
|||||||
private JButton resetButton;
|
private JButton resetButton;
|
||||||
|
|
||||||
@Autowired
|
@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.printQueueService = printQueueService;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.printController = printController;
|
this.printController = printController;
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class PrintTaskSearchPanel extends JPanel implements LocaleChangeListener
|
|||||||
|
|
||||||
gbc.gridx = 1;
|
gbc.gridx = 1;
|
||||||
gbc.weightx = 1.0;
|
gbc.weightx = 1.0;
|
||||||
printerComboBox = new JComboBox<>(new String[]{MessageUtils.getMessage("common.all"), "打印机1", "打印机2", "打印机3"});
|
printerComboBox = new JComboBox<>(new String[]{MessageUtils.getMessage("common.all")});
|
||||||
searchPanel.add(printerComboBox, gbc);
|
searchPanel.add(printerComboBox, gbc);
|
||||||
|
|
||||||
// 状态选择
|
// 状态选择
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import jakarta.websocket.Session;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import jakarta.annotation.PreDestroy;
|
import jakarta.annotation.PreDestroy;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -30,12 +31,15 @@ import java.time.LocalDateTime;
|
|||||||
public class PrintQueueService {
|
public class PrintQueueService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@Lazy
|
||||||
private PrintService printService;
|
private PrintService printService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@Lazy
|
||||||
private PrintNotificationService notificationService;
|
private PrintNotificationService notificationService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@Lazy
|
||||||
private PrintStatisticsPanel statisticsPanel;
|
private PrintStatisticsPanel statisticsPanel;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|||||||
@@ -1,18 +1,16 @@
|
|||||||
package com.goeing.printserver.main.sse;
|
package com.goeing.printserver.main.sse;
|
||||||
|
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.goeing.printserver.main.PrintController;
|
|
||||||
import com.goeing.printserver.main.config.PrintServerConfig;
|
import com.goeing.printserver.main.config.PrintServerConfig;
|
||||||
import com.goeing.printserver.main.domain.dto.WebSocketMessageDTO;
|
import com.goeing.printserver.main.domain.dto.WebSocketMessageDTO;
|
||||||
import com.goeing.printserver.main.domain.request.PrintRequest;
|
import com.goeing.printserver.main.domain.request.PrintRequest;
|
||||||
import com.goeing.printserver.main.service.PrintQueueService;
|
import com.goeing.printserver.main.service.PrintQueueService;
|
||||||
import jakarta.websocket.*;
|
import jakarta.websocket.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import jakarta.annotation.PreDestroy;
|
import jakarta.annotation.PreDestroy;
|
||||||
|
|
||||||
@@ -39,7 +37,7 @@ public class PrinterClient implements ApplicationRunner {
|
|||||||
private boolean isConnecting = false;
|
private boolean isConnecting = false;
|
||||||
|
|
||||||
// 构造函数,注入PrintQueueService和PrintServerConfig
|
// 构造函数,注入PrintQueueService和PrintServerConfig
|
||||||
public PrinterClient(PrintQueueService printQueueService, PrintServerConfig config) {
|
public PrinterClient(@Lazy PrintQueueService printQueueService, PrintServerConfig config) {
|
||||||
this.printQueueService = printQueueService;
|
this.printQueueService = printQueueService;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
// 构造函数不做连接操作,在run方法中进行连接
|
// 构造函数不做连接操作,在run方法中进行连接
|
||||||
@@ -70,12 +68,12 @@ public class PrinterClient implements ApplicationRunner {
|
|||||||
|
|
||||||
// 发送任务已接收的确认消息
|
// 发送任务已接收的确认消息
|
||||||
Map<String,String> map = new HashMap<>();
|
Map<String,String> map = new HashMap<>();
|
||||||
map.put("status", "queued");
|
map.put("status", "success");
|
||||||
map.put("msg", "打印任务已加入队列,等待处理");
|
map.put("msg", "打印任务已加入队列,等待处理");
|
||||||
map.put("queueSize", String.valueOf(printQueueService.getQueueSize()));
|
map.put("queueSize", String.valueOf(printQueueService.getQueueSize()));
|
||||||
|
|
||||||
WebSocketMessageDTO queuedResponse = new WebSocketMessageDTO();
|
WebSocketMessageDTO queuedResponse = new WebSocketMessageDTO();
|
||||||
queuedResponse.setType("QUEUED");
|
queuedResponse.setType("RESPONSE");
|
||||||
queuedResponse.setRequestId(webSocketMessageDTO.getRequestId());
|
queuedResponse.setRequestId(webSocketMessageDTO.getRequestId());
|
||||||
queuedResponse.setPayload(JSONUtil.toJsonStr(map));
|
queuedResponse.setPayload(JSONUtil.toJsonStr(map));
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
spring.application.name=goeingPrintServer
|
spring.application.name=goeingPrintServer
|
||||||
server.port=9090
|
server.port=9090
|
||||||
print.websocket.url=ws://127.0.0.1:8080/print-websocket
|
print.websocket.url=ws://zipship.goeing.com/prod-api/print-websocket
|
||||||
#print.websocket.url=ws://3.144.140.114:8080/print-websocket
|
#print.websocket.url=ws://127.0.0.1:8080/print-websocket
|
||||||
print.printer.id=123456
|
print.printer.id=123456
|
||||||
print.websocket.apiKey=519883ab-3677-ce4b-59ba-7263870d0a26
|
print.websocket.apiKey=519883ab-3677-ce4b-59ba-7263870d0a26
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
Reference in New Issue
Block a user