feat: 新增默认打印机设置

This commit is contained in:
lifangliang 2025-08-29 17:23:48 +08:00
parent 478f8c4549
commit 191c6dfce7
2 changed files with 11 additions and 3 deletions

View File

@ -231,7 +231,7 @@ public class PrintQueueService {
try {
// 执行打印
Thread.sleep(20000L);
// Thread.sleep(20000L);
printService.print(printRequest);
log.info("打印任务完成: {}", printRequest.getFileUrl());

View File

@ -95,10 +95,18 @@ public class PrinterClient implements ApplicationRunner {
PrintService[] printServices = PrinterJob.lookupPrintServices();
Set<String> collect = Arrays.stream(printServices).map(PrintService::getName).collect(Collectors.toSet());
List<String> collect1 = collect.stream().sorted().collect(Collectors.toList());
List<String> printerList = collect.stream().sorted().collect(Collectors.toList());
// 获取设置中的默认打印机
String defaultPrinter = config.getDefaultPrinter();
// 构建响应对象
Map<String, Object> response = new HashMap<>();
response.put("printerList", printerList);
response.put("defaultPrinter", defaultPrinter);
webSocketMessageDTO.setType("RESPONSE");
webSocketMessageDTO.setPayload(JSONUtil.toJsonStr(collect1));
webSocketMessageDTO.setPayload(JSONUtil.toJsonStr(response));
session.getBasicRemote().sendText(JSONUtil.toJsonStr(webSocketMessageDTO));
} else if ("queueStatus".equals(type)) {
// 返回当前打印队列状态