|
|
@@ -73,4 +73,23 @@ public class Printer {
|
|
|
public static String getCurrentName() {
|
|
|
return com.mes.print.config.PrinterConfig.get("printer.name", "");
|
|
|
}
|
|
|
-}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 预热:初始化打印实现 + (HP 模式) 提前加载流转卡模板/字体
|
|
|
+ * 建议在主程序启动时异步调用一次,避免首单打印卡顿
|
|
|
+ */
|
|
|
+ public static void warmUp() {
|
|
|
+ long t0 = System.currentTimeMillis();
|
|
|
+ try {
|
|
|
+ PrinterFactory.get();
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.err.println("[Printer] 工厂预热失败: " + e.getMessage());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String type = getCurrentType();
|
|
|
+ if ("hp".equals(type)) {
|
|
|
+ com.mes.print.template.FlowCardRenderer.warmUp();
|
|
|
+ }
|
|
|
+ System.out.println("[Printer] 预热总耗时 " + (System.currentTimeMillis() - t0) + "ms");
|
|
|
+ }
|
|
|
+}
|