zxl 3 недель назад
Родитель
Сommit
ca5355f967

+ 3 - 0
.gitignore

@@ -20,3 +20,6 @@ out
 
 # 资源目录杂项(原 image/.gitignore)
 _system~.ini
+
+/docs/*
+/doc/*

+ 11 - 0
pom.xml

@@ -39,6 +39,17 @@
             <artifactId>fastjson2</artifactId>
             <version>2.0.16</version>
         </dependency>
+        <!-- 结案小票:批次码二维码 -->
+        <dependency>
+            <groupId>com.google.zxing</groupId>
+            <artifactId>core</artifactId>
+            <version>3.5.3</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.zxing</groupId>
+            <artifactId>javase</artifactId>
+            <version>3.5.3</version>
+        </dependency>
         <!-- S7 PLC:大冲 DcPlcClient -->
         <dependency>
             <groupId>com.github.xingshuangs</groupId>

+ 214 - 8
src/main/java/com/mes/config/MesClientProperties.java

@@ -7,37 +7,46 @@ import java.util.List;
 
 /**
  * 自动化大冲工控机配置,对应 application.yml 中 {@code mes.*}。
+ * 含线体主站(DB260)与五台压机过程采集站。
  */
 @ConfigurationProperties(prefix = "mes")
 public class MesClientProperties {
 
 	/** 窗口标题 */
 	private String appTitle = "MES 自动化大冲";
-	/** MES 服务器 IP(上传接口后续再接) */
+	/** MES 服务器 IP */
 	private String serverIp = "";
-	/** 刷新周期毫秒 */
+	/** 线体/压机刷新周期毫秒 */
 	private int tickMs = 500;
 	/**
+	 * 压机采样上报周期毫秒(有批次且连通时按此节流采点)。
+	 */
+	private int pressSampleMs = 1000;
+	/**
+	 * 压机采样缓冲满多少点就上报一次。
+	 */
+	private int pressUploadMax = 20;
+	/**
 	 * 结案小票连接的系统打印机名称;空则用 Windows 默认打印机。
 	 */
 	private String printerName = "";
-	/** 工位列表(一般一条线体一个站) */
+	/** 线体工位列表(一般一条:DB260 主界面) */
 	private List<StationConfig> stations = new ArrayList<StationConfig>();
+	/** 五台压机过程采集配置(IP/点位后补) */
+	private List<PressConfig> presses = new ArrayList<PressConfig>();
 
 	/**
-	 * 单线体/工位:批次 → MES允许=true → 轮询读 DB260 → 本批做完允许=false → 打印。
+	 * 线体主站:取批次 → MES允许 → 展示 DB260;结案由压机5达标触发。
 	 */
 	public static class StationConfig {
 		private int id = 1;
-		/** 工位编码 */
+		/** 工位编码(与 PDA/取码队列一致) */
 		private String stationSn = "DC01";
 		/** PLC IP */
 		private String plcIp = "";
 		/** S7 端口,默认 102 */
 		private int plcPort = 102;
-		/**
-		 * MES 允许运行 BOOL 地址(点表暂缺;有了再填)。
-		 */
+		/** MES 允许运行 BOOL 地址 */
 		private String mesAllowAddr = "";
 		/** Tab 显示名 */
 		private String title = "自动化大冲";
@@ -91,6 +100,179 @@ public class MesClientProperties {
 		}
 	}
 
+	/**
+	 * 单台压机:只采过程参数并挂主界面批次;不取码。
+	 * 五台与线体共用同一工位号(自动化设备占用),机台靠 pressNo 区分。
+	 * 压机5(press-no=5)冲次达标后触发主界面打印结案。
+	 */
+	public static class PressConfig {
+		/** 压机编号 1~5(客户端上报,管理端按此区分机台) */
+		private int pressNo = 1;
+		/** 导航/页签标题 */
+		private String title = "压机";
+		/**
+		 * 已废弃:五台不单独占工位号。上报时用工位 = 线体 stations.station-sn。
+		 */
+		private String stationSn = "";
+		/** 机型名,如 LS4-1300R */
+		private String pressModel = "";
+		/** PLC IP;空则本机不连,不影响其它站 */
+		private String plcIp = "";
+		/** S7 端口,默认 102 */
+		private int plcPort = 102;
+		/**
+		 * 冲次数量地址(UDINT)。
+		 * 压机5 用此点累计达标后触发主界面打印结案。
+		 */
+		private String strokeCountAddr = "";
+		/** 生产高度地址(REAL) */
+		private String dieHeightAddr = "";
+		/** 顶缸压力地址(REAL) */
+		private String cylinderPressureAddr = "";
+		/** 生产吨位地址(类型见 tonnageDint) */
+		private String tonnageAddr = "";
+		/** 生产吨位数据类型:true=DINT,false=REAL */
+		private boolean tonnageDint = false;
+		/** 压机行程次数地址(REAL) */
+		private String pressSpmAddr = "";
+		/** 气垫风压地址(REAL);无机型则留空 */
+		private String airCushionAddr = "";
+		/** 顶杆行程地址(REAL);无机型则留空 */
+		private String ejectorStrokeAddr = "";
+		/** 能耗地址(DINT);无机型则留空 */
+		private String energyAddr = "";
+		/** 设备运行 BOOL;空则界面不亮运行灯 */
+		private String deviceRunAddr = "";
+
+		public int getPressNo() {
+			return pressNo;
+		}
+
+		public void setPressNo(int pressNo) {
+			this.pressNo = pressNo;
+		}
+
+		public String getTitle() {
+			return title;
+		}
+
+		public void setTitle(String title) {
+			this.title = title;
+		}
+
+		public String getStationSn() {
+			return stationSn;
+		}
+
+		public void setStationSn(String stationSn) {
+			this.stationSn = stationSn;
+		}
+
+		public String getPressModel() {
+			return pressModel;
+		}
+
+		public void setPressModel(String pressModel) {
+			this.pressModel = pressModel;
+		}
+
+		public String getPlcIp() {
+			return plcIp;
+		}
+
+		public void setPlcIp(String plcIp) {
+			this.plcIp = plcIp;
+		}
+
+		public int getPlcPort() {
+			return plcPort;
+		}
+
+		public void setPlcPort(int plcPort) {
+			this.plcPort = plcPort;
+		}
+
+		public String getStrokeCountAddr() {
+			return strokeCountAddr;
+		}
+
+		public void setStrokeCountAddr(String strokeCountAddr) {
+			this.strokeCountAddr = strokeCountAddr;
+		}
+
+		public String getDieHeightAddr() {
+			return dieHeightAddr;
+		}
+
+		public void setDieHeightAddr(String dieHeightAddr) {
+			this.dieHeightAddr = dieHeightAddr;
+		}
+
+		public String getCylinderPressureAddr() {
+			return cylinderPressureAddr;
+		}
+
+		public void setCylinderPressureAddr(String cylinderPressureAddr) {
+			this.cylinderPressureAddr = cylinderPressureAddr;
+		}
+
+		public String getTonnageAddr() {
+			return tonnageAddr;
+		}
+
+		public void setTonnageAddr(String tonnageAddr) {
+			this.tonnageAddr = tonnageAddr;
+		}
+
+		public boolean isTonnageDint() {
+			return tonnageDint;
+		}
+
+		public void setTonnageDint(boolean tonnageDint) {
+			this.tonnageDint = tonnageDint;
+		}
+
+		public String getPressSpmAddr() {
+			return pressSpmAddr;
+		}
+
+		public void setPressSpmAddr(String pressSpmAddr) {
+			this.pressSpmAddr = pressSpmAddr;
+		}
+
+		public String getAirCushionAddr() {
+			return airCushionAddr;
+		}
+
+		public void setAirCushionAddr(String airCushionAddr) {
+			this.airCushionAddr = airCushionAddr;
+		}
+
+		public String getEjectorStrokeAddr() {
+			return ejectorStrokeAddr;
+		}
+
+		public void setEjectorStrokeAddr(String ejectorStrokeAddr) {
+			this.ejectorStrokeAddr = ejectorStrokeAddr;
+		}
+
+		public String getEnergyAddr() {
+			return energyAddr;
+		}
+
+		public void setEnergyAddr(String energyAddr) {
+			this.energyAddr = energyAddr;
+		}
+
+		public String getDeviceRunAddr() {
+			return deviceRunAddr;
+		}
+
+		public void setDeviceRunAddr(String deviceRunAddr) {
+			this.deviceRunAddr = deviceRunAddr;
+		}
+	}
+
 	public String getAppTitle() {
 		return appTitle;
 	}
@@ -115,6 +297,22 @@ public class MesClientProperties {
 		this.tickMs = tickMs;
 	}
 
+	public int getPressSampleMs() {
+		return pressSampleMs;
+	}
+
+	public void setPressSampleMs(int pressSampleMs) {
+		this.pressSampleMs = pressSampleMs;
+	}
+
+	public int getPressUploadMax() {
+		return pressUploadMax;
+	}
+
+	public void setPressUploadMax(int pressUploadMax) {
+		this.pressUploadMax = pressUploadMax;
+	}
+
 	public String getPrinterName() {
 		return printerName;
 	}
@@ -130,4 +328,12 @@ public class MesClientProperties {
 	public void setStations(List<StationConfig> stations) {
 		this.stations = stations;
 	}
+
+	public List<PressConfig> getPresses() {
+		return presses;
+	}
+
+	public void setPresses(List<PressConfig> presses) {
+		this.presses = presses;
+	}
 }

+ 36 - 0
src/main/java/com/mes/entity/DcPressSnapshot.java

@@ -0,0 +1,36 @@
+package com.mes.entity;
+
+/**
+ * 单台压机过程参数快照(按机台点表轮询),供界面刷新与采样上报。
+ */
+public class DcPressSnapshot {
+
+	/** 生产高度示值 */
+	public String dieHeight = "";
+	/** 冲次数量累计 */
+	public long strokeCount;
+	/** 冲次数量原串 */
+	public String strokeCountText = "";
+	/** 顶缸压力示值 */
+	public String cylinderPressure = "";
+	/** 生产吨位示值 */
+	public String tonnage = "";
+	/** 压机行程次数示值 */
+	public String pressSpm = "";
+	/** 气垫风压示值(仅部分机型) */
+	public String airCushion = "";
+	/** 顶杆行程示值(仅部分机型) */
+	public String ejectorStroke = "";
+	/** 能耗示值(仅部分机型) */
+	public String energyKwh = "";
+	/** 设备运行 */
+	public boolean deviceRunning;
+	/** 设备状态文案 */
+	public String deviceStateText = "";
+
+	@Override
+	public String toString() {
+		return "stroke=" + strokeCount + ", die=" + dieHeight + ", press=" + cylinderPressure
+				+ ", ton=" + tonnage + ", spm=" + pressSpm + ", energy=" + energyKwh;
+	}
+}

+ 6 - 5
src/main/java/com/mes/entity/DcRunSnapshot.java

@@ -1,7 +1,8 @@
 package com.mes.entity;
 
 /**
- * 自动化大冲线体实时快照(DB260 轮询读),供界面刷新与结案打印/后续上传。
+ * 自动化大冲线体实时快照(DB260 轮询读),供界面刷新与结案上传。
+ * 示值全称:当前零件名称、下一零件名称、实际产量、停机时间、生产节拍、产线状态。
  */
 public class DcRunSnapshot {
 
@@ -9,11 +10,11 @@ public class DcRunSnapshot {
 	public String currentPart = "";
 	/** 下一零件名称 */
 	public String nextPart = "";
-	/** 实际产量(累计) */
+	/** 实际产量 */
 	public int actualQty;
 	/** 停机时间 */
 	public int downtime;
-	/** 生产节拍(秒等,按 PLC REAL→double) */
+	/** 生产节拍 */
 	public double takt;
 	/** 产线状态原始值 */
 	public int lineState;
@@ -22,7 +23,7 @@ public class DcRunSnapshot {
 
 	@Override
 	public String toString() {
-		return "part=" + currentPart + ", qty=" + actualQty + ", takt=" + takt
-				+ ", state=" + lineStateText;
+		return "当前零件名称=" + currentPart + ", 实际产量=" + actualQty + ", 生产节拍=" + takt
+				+ ", 产线状态=" + lineStateText;
 	}
 }

+ 2 - 5
src/main/java/com/mes/entity/DcWorkRecord.java

@@ -1,12 +1,10 @@
 package com.mes.entity;
 
 /**
- * 大冲本机工作记录一行:批次结案后写入,供工作记录页展示。
+ * 大冲本机工作记录一行:批次结案后写入,供工作记录页展示(按批次码追溯)。
  */
 public class DcWorkRecord {
 
-	/** 包装码(年月日+6位随机,批量追溯) */
-	public String packCode = "";
 	/** 批次码 */
 	public String batchCode = "";
 	/** 记录时间 yyyy-MM-dd HH:mm:ss */
@@ -19,8 +17,7 @@ public class DcWorkRecord {
 	public DcWorkRecord() {
 	}
 
-	public DcWorkRecord(String packCode, String batchCode, String recordTime, int qty, String result) {
-		this.packCode = packCode == null ? "" : packCode.trim();
+	public DcWorkRecord(String batchCode, String recordTime, int qty, String result) {
 		this.batchCode = batchCode == null ? "" : batchCode.trim();
 		this.recordTime = recordTime == null ? "" : recordTime.trim();
 		this.qty = qty;

+ 66 - 25
src/main/java/com/mes/service/DcBatchPrinter.java

@@ -1,26 +1,41 @@
 package com.mes.service;
 
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.EncodeHintType;
+import com.google.zxing.WriterException;
+import com.google.zxing.client.j2se.MatrixToImageWriter;
+import com.google.zxing.common.BitMatrix;
+import com.google.zxing.qrcode.QRCodeWriter;
+import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.print.PrintService;
 import javax.print.PrintServiceLookup;
 import java.awt.Font;
+import java.awt.FontMetrics;
 import java.awt.Graphics;
 import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.image.BufferedImage;
 import java.awt.print.PageFormat;
 import java.awt.print.Printable;
 import java.awt.print.PrinterException;
 import java.awt.print.PrinterJob;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
- * 批次结案小票:连接系统打印机,打印包装码、生产时间、本批数量。
+ * 批次结案小票:上方居中批次码二维码,下方居中批次码文字。
  * 打印机名由 yml {@code mes.printer-name} 指定;空则用系统默认打印机。
  */
 public final class DcBatchPrinter {
 
 	private static final Logger log = LoggerFactory.getLogger(DcBatchPrinter.class);
 
+	/** 二维码边长(像素,按可打印宽度再裁) */
+	private static final int QR_PREF_PX = 200;
+
 	/** 目标打印机名称(空=默认打印机) */
 	private static volatile String printerName = "";
 
@@ -33,25 +48,29 @@ public final class DcBatchPrinter {
 	}
 
 	/**
-	 * 连接打印机并送打包装码小票。
+	 * 连接打印机并送打批次码小票(上二维码、下批次码,均居中)。
 	 *
-	 * @param packCode 包装码(年月日+6位随机)
-	 * @param produceTime 生产时间文案 yyyy-MM-dd HH:mm:ss
-	 * @param qty 本批实际增产数量
+	 * @param batchCode 批次码(二维码内容与下方文字)
+	 * @param produceTime 保留入参兼容调用方(本版小票不印)
+	 * @param qty 保留入参兼容调用方(本版小票不印)
 	 * @return 是否送打印成功
 	 */
-	public static boolean printPack(final String packCode, final String produceTime, final int qty) {
-		final String code = packCode == null ? "" : packCode.trim();
-		final String time = produceTime == null ? "" : produceTime.trim();
+	public static boolean printBatch(final String batchCode, final String produceTime, final int qty) {
+		final String code = batchCode == null ? "" : batchCode.trim();
+		if (code.isEmpty()) {
+			log.warn("批次码为空,跳过打印");
+			return false;
+		}
 		try {
+			final BufferedImage qrImg = createQrImage(code, QR_PREF_PX);
 			PrintService service = resolvePrinter();
 			if (service == null) {
-				log.warn("未找到可用打印机(printer-name={}),跳过打印 pack={}", printerName, code);
+				log.warn("未找到可用打印机(printer-name={}),跳过打印 batch={}", printerName, code);
 				return false;
 			}
 			PrinterJob job = PrinterJob.getPrinterJob();
 			job.setPrintService(service);
-			job.setJobName("DC-PACK-" + code);
+			job.setJobName("DC-BATCH-" + code);
 			job.setPrintable(new Printable() {
 				@Override
 				public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) {
@@ -60,35 +79,57 @@ public final class DcBatchPrinter {
 					}
 					Graphics2D g = (Graphics2D) graphics;
 					g.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
-					g.setFont(new Font("Microsoft YaHei", Font.BOLD, 14));
-					int y = 24;
-					g.drawString("自动化大冲 · 包装小票", 10, y);
-					y += 28;
-					g.setFont(new Font("Microsoft YaHei", Font.PLAIN, 12));
-					g.drawString("包装码:" + code, 10, y);
-					y += 22;
-					g.drawString("生产时间:" + time, 10, y);
-					y += 22;
-					g.drawString("生产数量:" + qty, 10, y);
+					g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+					g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+
+					int pageW = (int) pageFormat.getImageableWidth();
+					// 二维码不超过可打印宽度,左右留白
+					int qrSize = Math.min(QR_PREF_PX, Math.max(80, pageW - 20));
+					int qrX = (pageW - qrSize) / 2;
+					int qrY = 16;
+					g.drawImage(qrImg, qrX, qrY, qrSize, qrSize, null);
+
+					// 下方居中批次码
+					g.setFont(new Font("Microsoft YaHei", Font.BOLD, 16));
+					FontMetrics fm = g.getFontMetrics();
+					int textW = fm.stringWidth(code);
+					int textX = Math.max(0, (pageW - textW) / 2);
+					int textY = qrY + qrSize + 28;
+					g.drawString(code, textX, textY);
 					return PAGE_EXISTS;
 				}
 			});
 			job.print();
-			log.info("已连接打印机[{}] 送打 pack={} qty={} time={}",
-					service.getName(), code, Integer.valueOf(qty), time);
+			log.info("已连接打印机[{}] 送打 batch={}(二维码+文字)", service.getName(), code);
 			return true;
+		} catch (WriterException e) {
+			log.warn("生成批次码二维码失败 batch={}: {}", code, e.getMessage());
+			return false;
 		} catch (PrinterException e) {
-			log.warn("连接/打印失败 pack={}: {}", code, e.getMessage());
+			log.warn("连接/打印失败 batch={}: {}", code, e.getMessage());
 			return false;
 		} catch (Exception e) {
-			log.warn("打印异常 pack={}: {}", code, e.getMessage());
+			log.warn("打印异常 batch={}: {}", code, e.getMessage());
 			return false;
 		}
 	}
 
 	/**
-	 * 按配置名查找打印机;未配名则用系统默认;都没有则返回 null。
+	 * 把批次码编成二维码图。
+	 *
+	 * @param content 批次码
+	 * @param size 边长像素
 	 */
+	private static BufferedImage createQrImage(String content, int size) throws WriterException {
+		Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>();
+		hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
+		hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
+		hints.put(EncodeHintType.MARGIN, Integer.valueOf(1));
+		BitMatrix matrix = new QRCodeWriter().encode(content, BarcodeFormat.QR_CODE, size, size, hints);
+		return MatrixToImageWriter.toBufferedImage(matrix);
+	}
+
+	/** 按配置名查找打印机;未配名则用系统默认;都没有则返回 null */
 	private static PrintService resolvePrinter() {
 		if (!printerName.isEmpty()) {
 			PrintService[] all = PrintServiceLookup.lookupPrintServices(null, null);

+ 85 - 0
src/main/java/com/mes/service/DcLineBatchContext.java

@@ -0,0 +1,85 @@
+package com.mes.service;
+
+/**
+ * 线体主界面与五台压机页共享的当前批次上下文。
+ * 仅主界面开批/结案会改批次码;压机页只读并上报明细,压机5达标触发结案。
+ */
+public final class DcLineBatchContext {
+
+	/** 压机编号 1~5 的本批已产(冲次差) */
+	private static final int PRESS_MAX = 5;
+
+	private static volatile String batchCode = "";
+	private static volatile int targetQty;
+	private static volatile boolean running;
+	private static volatile String startTime = "";
+	private static final int[] pressProduced = new int[PRESS_MAX + 1];
+
+	private DcLineBatchContext() {
+	}
+
+	/**
+	 * 主界面开批:写入共享批次,清空各压机进度。
+	 *
+	 * @param code 批次码
+	 * @param target 本批目标数量
+	 * @param time 开批时间文案
+	 */
+	public static synchronized void open(String code, int target, String time) {
+		batchCode = code == null ? "" : code.trim();
+		targetQty = target < 0 ? 0 : target;
+		startTime = time == null ? "" : time.trim();
+		running = !batchCode.isEmpty() && targetQty > 0;
+		for (int i = 0; i < pressProduced.length; i++) {
+			pressProduced[i] = 0;
+		}
+	}
+
+	/** 主界面结案/清码后清空共享批次 */
+	public static synchronized void close() {
+		batchCode = "";
+		targetQty = 0;
+		startTime = "";
+		running = false;
+		for (int i = 0; i < pressProduced.length; i++) {
+			pressProduced[i] = 0;
+		}
+	}
+
+	public static String getBatchCode() {
+		return batchCode;
+	}
+
+	public static int getTargetQty() {
+		return targetQty;
+	}
+
+	public static boolean isRunning() {
+		return running;
+	}
+
+	public static String getStartTime() {
+		return startTime;
+	}
+
+	/**
+	 * 压机页回写本机本批已产,供主界面进度条展示。
+	 *
+	 * @param pressNo 压机编号 1~5
+	 * @param produced 本批已产件数
+	 */
+	public static synchronized void setPressProduced(int pressNo, int produced) {
+		if (pressNo < 1 || pressNo > PRESS_MAX) {
+			return;
+		}
+		pressProduced[pressNo] = produced < 0 ? 0 : produced;
+	}
+
+	/** 读某台压机本批已产;非法编号返回 0 */
+	public static synchronized int getPressProduced(int pressNo) {
+		if (pressNo < 1 || pressNo > PRESS_MAX) {
+			return 0;
+		}
+		return pressProduced[pressNo];
+	}
+}

+ 0 - 24
src/main/java/com/mes/service/DcPackCode.java

@@ -1,24 +0,0 @@
-package com.mes.service;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.concurrent.ThreadLocalRandom;
-
-/**
- * 包装码:一批次结案时生成,用于打印与服务端批量追溯。
- * 规则:年月日(yyyyMMdd) + 随机 6 位数字。
- */
-public final class DcPackCode {
-
-	private DcPackCode() {
-	}
-
-	/**
-	 * 生成包装码,如 20261106123456。
-	 */
-	public static String next() {
-		String day = new SimpleDateFormat("yyyyMMdd").format(new Date());
-		int rnd = ThreadLocalRandom.current().nextInt(0, 1000000);
-		return day + String.format("%06d", Integer.valueOf(rnd));
-	}
-}

+ 2 - 2
src/main/java/com/mes/service/DcPlcClient.java

@@ -111,7 +111,7 @@ public class DcPlcClient {
 	}
 
 	/**
-	 * 轮询读一整包 DB260 参数码:当前/下一零件、产量、状态、节拍、停机。
+	 * 轮询读一整包 DB260:当前零件名称、下一零件名称、实际产量、产线状态、生产节拍、停机时间。
 	 */
 	public DcRunSnapshot readSnapshot() {
 		DcRunSnapshot s = new DcRunSnapshot();
@@ -133,7 +133,7 @@ public class DcPlcClient {
 		return s;
 	}
 
-	/** 仅读累计实际产量;失败返回 null */
+	/** 仅读实际产量;失败返回 null */
 	public Integer readActualQty() {
 		if (!ensurePlc()) {
 			return null;

+ 3 - 2
src/main/java/com/mes/service/DcPlcPointMap.java

@@ -1,7 +1,8 @@
 package com.mes.service;
 
 /**
- * 自动化大冲线体点表(S7,DB260):当前/下一零件名、实际产量、停机、产线状态、节拍。
+ * 自动化大冲线体点表(S7,DB260)。
+ * 示值全称:当前零件名称、下一零件名称、实际产量、停机时间、生产节拍、产线状态。
  * MES 允许运行偏移由 yml {@code mes-allow-addr} 配置。
  */
 public final class DcPlcPointMap {
@@ -14,7 +15,7 @@ public final class DcPlcPointMap {
 	public static final String ACTUAL_QTY = "DB260.26";
 	/** 产线状态 INT:0/1 待机,2 正常,3 故障 */
 	public static final String LINE_STATE = "DB260.30";
-	/** 生产节拍 REAL(界面/上传按 double) */
+	/** 生产节拍 REAL */
 	public static final String TAKT = "DB260.32";
 	/** 停机时间 INT */
 	public static final String DOWNTIME = "DB260.68";

+ 212 - 0
src/main/java/com/mes/service/DcPressPlcClient.java

@@ -0,0 +1,212 @@
+package com.mes.service;
+
+import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType;
+import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;
+import com.mes.config.MesClientProperties;
+import com.mes.entity.DcPressSnapshot;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 单台压机 S7 客户端:按 yml 点表读过程参数。
+ * IP 或冲次地址未配则不连,避免拖死其它站。
+ */
+public class DcPressPlcClient {
+
+	private static final Logger log = LoggerFactory.getLogger(DcPressPlcClient.class);
+
+	private static final long RETRY_INITIAL_MS = 2L * 1000L;
+	private static final long RETRY_MAX_MS = 30L * 1000L;
+
+	private final MesClientProperties.PressConfig cfg;
+
+	private S7PLC plc;
+	private volatile boolean connected;
+	private volatile long nextRetryAtMs;
+	private volatile long currentRetryDelayMs = RETRY_INITIAL_MS;
+
+	public DcPressPlcClient(MesClientProperties.PressConfig cfg) {
+		this.cfg = cfg;
+	}
+
+	public MesClientProperties.PressConfig getCfg() {
+		return cfg;
+	}
+
+	public String getStationSn() {
+		return nvl(cfg.getStationSn());
+	}
+
+	public int getPressNo() {
+		return cfg.getPressNo();
+	}
+
+	public boolean isConnected() {
+		return connected && plc != null;
+	}
+
+	/** tick:未连接按退避重连 */
+	public void maintainConnection() {
+		if (isConnected()) {
+			return;
+		}
+		connect();
+	}
+
+	/** 连接并用冲次探活;IP/冲次地址空则跳过 */
+	public synchronized void connect() {
+		if (isConnected()) {
+			return;
+		}
+		long now = System.currentTimeMillis();
+		if (now < nextRetryAtMs) {
+			return;
+		}
+		String ip = nvl(cfg.getPlcIp());
+		String strokeAddr = nvl(cfg.getStrokeCountAddr());
+		if (ip.isEmpty() || strokeAddr.isEmpty()) {
+			connected = false;
+			long waitSec = scheduleRetryAfterFailure() / 1000L;
+			log.warn("压机[{}] PLC IP 或冲次地址未配置,跳过连接({}s 后再试)",
+					cfg.getPressNo(), Long.valueOf(waitSec));
+			return;
+		}
+		try {
+			int port = cfg.getPlcPort() <= 0 ? 102 : cfg.getPlcPort();
+			plc = new S7PLC(EPlcType.S1200, ip, port);
+			plc.readUInt32(strokeAddr);
+			connected = true;
+			resetRetryBackoff();
+			log.info("压机[{}] {} PLC 已连接 {}:{}",
+					Integer.valueOf(cfg.getPressNo()), nvl(cfg.getTitle()), ip, Integer.valueOf(port));
+		} catch (Exception e) {
+			connected = false;
+			plc = null;
+			long waitSec = scheduleRetryAfterFailure() / 1000L;
+			log.warn("压机[{}] PLC 连接失败 — {}({}s 后再试)",
+					Integer.valueOf(cfg.getPressNo()), e.getMessage(), Long.valueOf(waitSec));
+		}
+	}
+
+	/** 轮询读本机过程参数;地址空则对应字段留空 */
+	public DcPressSnapshot readSnapshot() {
+		DcPressSnapshot s = new DcPressSnapshot();
+		if (!ensurePlc()) {
+			return s;
+		}
+		try {
+			String strokeAddr = nvl(cfg.getStrokeCountAddr());
+			if (!strokeAddr.isEmpty()) {
+				long stroke = plc.readUInt32(strokeAddr);
+				s.strokeCount = stroke;
+				s.strokeCountText = String.valueOf(stroke);
+			}
+			s.dieHeight = readFloatText(cfg.getDieHeightAddr());
+			s.cylinderPressure = readFloatText(cfg.getCylinderPressureAddr());
+			String tonAddr = nvl(cfg.getTonnageAddr());
+			if (!tonAddr.isEmpty()) {
+				if (cfg.isTonnageDint()) {
+					s.tonnage = String.valueOf(plc.readInt32(tonAddr));
+				} else {
+					s.tonnage = fmtFloat(plc.readFloat32(tonAddr));
+				}
+			}
+			s.pressSpm = readFloatText(cfg.getPressSpmAddr());
+			s.airCushion = readFloatText(cfg.getAirCushionAddr());
+			s.ejectorStroke = readFloatText(cfg.getEjectorStrokeAddr());
+			// 能耗 DINT
+			String energyAddr = nvl(cfg.getEnergyAddr());
+			if (!energyAddr.isEmpty()) {
+				s.energyKwh = String.valueOf(plc.readInt32(energyAddr));
+			}
+			String runAddr = nvl(cfg.getDeviceRunAddr());
+			if (!runAddr.isEmpty()) {
+				s.deviceRunning = plc.readBoolean(runAddr);
+				s.deviceStateText = s.deviceRunning ? "运行" : "停止";
+			}
+		} catch (Exception e) {
+			log.warn("压机[{}] 读过程参数失败: {}", Integer.valueOf(cfg.getPressNo()), e.getMessage());
+			markDisconnectedAndResetBackoff();
+		}
+		return s;
+	}
+
+	/** 仅读冲次;失败返回 null */
+	public Long readStrokeCount() {
+		String strokeAddr = nvl(cfg.getStrokeCountAddr());
+		if (strokeAddr.isEmpty() || !ensurePlc()) {
+			return null;
+		}
+		try {
+			return Long.valueOf(plc.readUInt32(strokeAddr));
+		} catch (Exception e) {
+			markDisconnectedAndResetBackoff();
+			return null;
+		}
+	}
+
+	private String readFloatText(String addr) {
+		if (isBlank(addr) || plc == null) {
+			return "";
+		}
+		return fmtFloat(plc.readFloat32(addr.trim()));
+	}
+
+	private boolean ensurePlc() {
+		if (isConnected()) {
+			return true;
+		}
+		connect();
+		return isConnected();
+	}
+
+	private void markDisconnectedAndResetBackoff() {
+		connected = false;
+		currentRetryDelayMs = RETRY_INITIAL_MS;
+		nextRetryAtMs = System.currentTimeMillis() + currentRetryDelayMs;
+	}
+
+	private long scheduleRetryAfterFailure() {
+		connected = false;
+		long used = currentRetryDelayMs;
+		if (used < RETRY_INITIAL_MS) {
+			used = RETRY_INITIAL_MS;
+		}
+		if (used > RETRY_MAX_MS) {
+			used = RETRY_MAX_MS;
+		}
+		nextRetryAtMs = System.currentTimeMillis() + used;
+		long next = used * 2L;
+		currentRetryDelayMs = next > RETRY_MAX_MS ? RETRY_MAX_MS : next;
+		return used;
+	}
+
+	private void resetRetryBackoff() {
+		currentRetryDelayMs = RETRY_INITIAL_MS;
+		nextRetryAtMs = 0L;
+	}
+
+	private static boolean isBlank(String s) {
+		return s == null || s.trim().isEmpty();
+	}
+
+	private static String nvl(String s) {
+		return s == null ? "" : s.trim();
+	}
+
+	private static String fmtFloat(float v) {
+		if (Float.isNaN(v) || Float.isInfinite(v)) {
+			return "";
+		}
+		String s = String.valueOf(v);
+		if (s.indexOf('.') > 0) {
+			while (s.endsWith("0")) {
+				s = s.substring(0, s.length() - 1);
+			}
+			if (s.endsWith(".")) {
+				s = s.substring(0, s.length() - 1);
+			}
+		}
+		return s;
+	}
+}

+ 2 - 4
src/main/java/com/mes/service/DcWorkRecordStore.java

@@ -8,7 +8,6 @@ import java.util.List;
 
 /**
  * 大冲本机工作记录内存库:结案写入,工作记录页读取。
- * 服务端查询接口后续再接。
  */
 public final class DcWorkRecordStore {
 
@@ -21,14 +20,13 @@ public final class DcWorkRecordStore {
 	/**
 	 * 追加一条结案记录(插到最前,新记录在上)。
 	 *
-	 * @param packCode 包装码
 	 * @param batchCode 批次码
 	 * @param recordTime 记录时间
 	 * @param qty 本批产量
 	 * @param result 过站结果 OK/NG
 	 */
-	public static void add(String packCode, String batchCode, String recordTime, int qty, String result) {
-		RECORDS.add(0, new DcWorkRecord(packCode, batchCode, recordTime, qty, result));
+	public static void add(String batchCode, String recordTime, int qty, String result) {
+		RECORDS.add(0, new DcWorkRecord(batchCode, recordTime, qty, result));
 	}
 
 	/** 当前全部记录快照(新→旧) */

+ 85 - 5
src/main/java/com/mes/service/MesDcApiClient.java

@@ -4,13 +4,20 @@ import com.alibaba.fastjson2.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
+import java.net.HttpURLConnection;
+import java.net.URL;
 import java.net.URLEncoder;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
 /**
- * 自动化大冲工控机 HTTP:取批次 / 结案一次上传(包装码+过程参数,非弧焊采样堆)。
+ * 自动化大冲工控机 HTTP:取批次 / 结案 / 压机过程参数批量上传。
  */
 public final class MesDcApiClient {
 
@@ -26,15 +33,25 @@ public final class MesDcApiClient {
 	public static JSONObject nextBatch(String serverIp, String stationSn) {
 		Map<String, String> p = new LinkedHashMap<String, String>();
 		p.put("stationSn", nvl(stationSn));
-		return post(serverIp, "/js/a/mes/mesFlexDc/nextBatch", p);
+		return postForm(serverIp, "/js/a/mes/mesFlexDc/nextBatch", p);
 	}
 
 	/**
-	 * 批次结案一次上报:包装码 + 过程参数(落 mes_flex_dc 单表)。
+	 * 批次结案一次上报:按批次码追溯 + 过程参数(落 mes_flex_dc 单表)。
 	 * 路径:{@code /js/a/mes/mesFlexDc/completeBatch}。
 	 */
 	public static JSONObject completeBatch(String serverIp, Map<String, String> fields) {
-		return post(serverIp, "/js/a/mes/mesFlexDc/completeBatch", fields);
+		return postForm(serverIp, "/js/a/mes/mesFlexDc/completeBatch", fields);
+	}
+
+	/**
+	 * 压机过程参数批量上报(JSON):落 mes_flex_dc_press_param。
+	 * 路径:{@code /js/a/mes/mesFlexDc/uploadPressParam}。
+	 *
+	 * @param body 含 batchCode、stationSn、pressNo、pressModel、samples[]
+	 */
+	public static JSONObject uploadPressParam(String serverIp, JSONObject body) {
+		return postJson(serverIp, "/js/a/mes/mesFlexDc/uploadPressParam", body);
 	}
 
 	public static boolean isSuccess(JSONObject result) {
@@ -80,7 +97,7 @@ public final class MesDcApiClient {
 		}
 	}
 
-	private static JSONObject post(String serverIp, String path, Map<String, String> fields) {
+	private static JSONObject postForm(String serverIp, String path, Map<String, String> fields) {
 		try {
 			String url = "http://" + nvl(serverIp) + ":8980" + path;
 			String body = toForm(fields);
@@ -96,6 +113,69 @@ public final class MesDcApiClient {
 		}
 	}
 
+	/** JSON POST(新上传接口) */
+	private static JSONObject postJson(String serverIp, String path, JSONObject body) {
+		HttpURLConnection connection = null;
+		InputStream is = null;
+		OutputStream os = null;
+		BufferedReader br = null;
+		try {
+			String url = "http://" + nvl(serverIp) + ":8980" + path;
+			String json = body == null ? "{}" : body.toJSONString();
+			log.debug("dc JSON POST {} body={}", path, json);
+			connection = (HttpURLConnection) new URL(url).openConnection();
+			connection.setRequestMethod("POST");
+			connection.setConnectTimeout(15000);
+			connection.setReadTimeout(60000);
+			connection.setDoOutput(true);
+			connection.setDoInput(true);
+			connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
+			os = connection.getOutputStream();
+			os.write(json.getBytes("UTF-8"));
+			if (connection.getResponseCode() != 200) {
+				log.warn("HTTP {} => {}", url, Integer.valueOf(connection.getResponseCode()));
+				return null;
+			}
+			is = connection.getInputStream();
+			br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+			StringBuilder sbf = new StringBuilder();
+			String temp;
+			while ((temp = br.readLine()) != null) {
+				sbf.append(temp);
+			}
+			String raw = sbf.toString();
+			if (raw.isEmpty()) {
+				return null;
+			}
+			return JSONObject.parseObject(raw);
+		} catch (Exception e) {
+			log.debug("dc JSON 请求异常 path={} err={}", path, e.getMessage());
+			return null;
+		} finally {
+			if (br != null) {
+				try {
+					br.close();
+				} catch (IOException ignored) {
+				}
+			}
+			if (os != null) {
+				try {
+					os.close();
+				} catch (IOException ignored) {
+				}
+			}
+			if (is != null) {
+				try {
+					is.close();
+				} catch (IOException ignored) {
+				}
+			}
+			if (connection != null) {
+				connection.disconnect();
+			}
+		}
+	}
+
 	private static String toForm(Map<String, String> fields) throws UnsupportedEncodingException {
 		StringBuilder sb = new StringBuilder();
 		sb.append("__ajax=json");

+ 200 - 42
src/main/java/com/mes/ui/MainFrame.java

@@ -22,7 +22,8 @@ import java.util.TimerTask;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
- * 自动化大冲工控机主窗:SSE 门铃取批 → MES允许 → 产量差达标 → 关允许 → 打印。
+ * 自动化大冲主窗:工作面板(DB260 取批)+ 五台压机过程页 + 工作记录。
+ * 结案打印由压机5冲次达标触发;各页独立调度,一台 PLC 挂死不影响其它页。
  */
 public class MainFrame extends JFrame {
 
@@ -35,15 +36,20 @@ public class MainFrame extends JFrame {
 
 	private static MesClientProperties props;
 	private static final List<StationPanel> stationPanels = new ArrayList<StationPanel>();
+	private static final List<PressPanel> pressPanels = new ArrayList<PressPanel>();
 	/** 工作记录页(结案后刷新) */
 	private static WorkRecordPanel workRecordPanel;
-	private static Timer tickTimer;
+	private static Timer lineTickTimer;
+	private static final List<Timer> pressTickTimers = new ArrayList<Timer>();
 	/** 取码队列 SSE */
 	private static MesFlexQueuePushClient pushClient;
 	/** SSE 断线慢轮询兜底 */
 	private static Timer fallbackNextTimer;
 	private static final AtomicBoolean exiting = new AtomicBoolean(false);
+	private static final AtomicBoolean finishFromPress5Busy = new AtomicBoolean(false);
 	private static JLabel menuStatus;
+	/** 导航按钮(切换选中样式) */
+	private static final List<JButton> navButtons = new ArrayList<JButton>();
 
 	public static boolean launch() {
 		if (SingleInstanceLock.getInstance().isAppActive()) {
@@ -57,21 +63,39 @@ public class MainFrame extends JFrame {
 					UiTheme.applyLookAndFeel();
 					mesClientFrame = new MainFrame();
 					mesClientFrame.setVisible(true);
-					// 先串行连 PLC,再开 tick,避免抢连
 					new Thread(new Runnable() {
 						@Override
 						public void run() {
-							for (StationPanel p : stationPanels) {
-								try {
-									p.initPlc();
-								} catch (Exception ex) {
-									log.warn("PLC 初始化异常: {}", ex.getMessage());
-								}
+							// 线体 + 五台并行初始化,互不等待
+							for (final StationPanel p : stationPanels) {
+								new Thread(new Runnable() {
+									@Override
+									public void run() {
+										try {
+											p.initPlc();
+										} catch (Exception ex) {
+											log.warn("线体 PLC 初始化异常: {}", ex.getMessage());
+										}
+									}
+								}, "dc-line-plc-init").start();
 							}
-							startTickTimer();
+							for (final PressPanel p : pressPanels) {
+								new Thread(new Runnable() {
+									@Override
+									public void run() {
+										try {
+											p.initPlc();
+										} catch (Exception ex) {
+											log.warn("压机 PLC 初始化异常 sn={}: {}",
+													p.getStationSn(), ex.getMessage());
+										}
+									}
+								}, "dc-press-plc-init-" + p.getPressNo()).start();
+							}
+							startTickTimers();
 							startPush();
 						}
-					}, "dc-plc-init").start();
+					}, "dc-boot").start();
 				} catch (Exception e) {
 					log.error("启动主界面失败", e);
 				}
@@ -90,20 +114,30 @@ public class MainFrame extends JFrame {
 		if (mes_app_title.isEmpty()) {
 			mes_app_title = "MES 自动化大冲";
 		}
-		// 结案小票走系统打印机(可配名,空=默认)
 		DcBatchPrinter.setPrinterName(p.getPrinterName());
 		log.info("打印机配置 name={}", trim(p.getPrinterName()).isEmpty() ? "(系统默认)" : trim(p.getPrinterName()));
 		List<MesClientProperties.StationConfig> list = p.getStations();
 		if (list == null || list.isEmpty()) {
 			log.warn("mes.stations 为空");
 		} else {
-			log.info("加载工位数={}", list.size());
+			log.info("加载线体工位数={}", list.size());
 			for (MesClientProperties.StationConfig s : list) {
-				log.info("工位 sn={} plc={}:{} allow={}",
+				log.info("线体 sn={} plc={}:{} allow={}",
 						s.getStationSn(), s.getPlcIp(), Integer.valueOf(s.getPlcPort()),
 						s.getMesAllowAddr());
 			}
 		}
+		List<MesClientProperties.PressConfig> presses = p.getPresses();
+		if (presses == null || presses.isEmpty()) {
+			log.warn("mes.presses 为空(五台过程页未配)");
+		} else {
+			log.info("加载压机数={}", presses.size());
+			for (MesClientProperties.PressConfig c : presses) {
+				log.info("压机#{} sn={} model={} plc={}",
+						Integer.valueOf(c.getPressNo()), c.getStationSn(),
+						c.getPressModel(), c.getPlcIp());
+			}
+		}
 	}
 
 	/** 服务端是否在线:以取码队列 SSE 为准 */
@@ -129,11 +163,64 @@ public class MainFrame extends JFrame {
 		});
 	}
 
+	/**
+	 * 压机5达标:请求线体主面板结案打印(防重入)。
+	 *
+	 * @param press5Qty 压机5本批已产
+	 */
+	public static void requestFinishFromPress5(final int press5Qty) {
+		if (!finishFromPress5Busy.compareAndSet(false, true)) {
+			return;
+		}
+		new Thread(new Runnable() {
+			@Override
+			public void run() {
+				try {
+					if (stationPanels.isEmpty()) {
+						return;
+					}
+					stationPanels.get(0).finishFromPress5(press5Qty);
+				} finally {
+					// 稍后再放行,避免压机5 tick 连打
+					try {
+						Thread.sleep(2000L);
+					} catch (InterruptedException ie) {
+						Thread.currentThread().interrupt();
+					}
+					finishFromPress5Busy.set(false);
+				}
+			}
+		}, "dc-finish-from-p5").start();
+	}
+
+	/** 主界面开批后通知各压机页复位本机进度 */
+	public static void notifyPressesBatchOpened() {
+		for (PressPanel p : pressPanels) {
+			try {
+				p.onLineBatchOpened();
+			} catch (Exception ex) {
+				log.debug("notify open skip: {}", ex.getMessage());
+			}
+		}
+	}
+
+	/** 主界面结案/清码后通知各压机冲刷采样并清进度 */
+	public static void notifyPressesBatchClosed() {
+		for (PressPanel p : pressPanels) {
+			try {
+				p.onLineBatchClosed();
+			} catch (Exception ex) {
+				log.debug("notify close skip: {}", ex.getMessage());
+			}
+		}
+	}
+
 	public MainFrame() {
 		setIconImage(Toolkit.getDefaultToolkit().getImage(UiImages.icon("logo.png")));
 		setTitle(mes_app_title);
-		// 设计 1920×1020,按 150% 等比缩小(不做系统 DPI 自适应)→ 1280×680
-		setBounds(40, 40, 1280, 680);
+		// 设计约 1920×1020 的 150% 逻辑窗;略抬高避免线体过程格被压扁
+		setBounds(40, 40, 1280, 800);
+		setMinimumSize(new Dimension(1100, 720));
 		setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
 		addWindowListener(new WindowAdapter() {
 			@Override
@@ -156,7 +243,7 @@ public class MainFrame extends JFrame {
 					public void run() {
 						try {
 							stopPush();
-							stopTickTimer();
+							stopTickTimers();
 						} catch (Throwable t) {
 							log.warn("退出清理异常: {}", t.getMessage());
 						} finally {
@@ -167,7 +254,6 @@ public class MainFrame extends JFrame {
 			}
 		});
 
-		// 去掉系统菜单栏(Nimbus 渐变很丑);退出走窗口关闭;状态条隐藏仅给 setMenuStatus 用
 		menuStatus = new JLabel("就绪");
 		menuStatus.setVisible(false);
 
@@ -177,6 +263,9 @@ public class MainFrame extends JFrame {
 		setContentPane(content);
 
 		stationPanels.clear();
+		pressPanels.clear();
+		navButtons.clear();
+
 		List<MesClientProperties.StationConfig> stations =
 				props == null ? null : props.getStations();
 		if (stations == null || stations.isEmpty()) {
@@ -194,17 +283,42 @@ public class MainFrame extends JFrame {
 		}
 		workRecordPanel = new WorkRecordPanel();
 
-		// CardLayout 切换页面;顶栏自绘导航,避免 Nimbus 页签 + 外挂按钮错位难看
+		int sampleMs = props != null && props.getPressSampleMs() > 0 ? props.getPressSampleMs() : 1000;
+		int uploadMax = props != null && props.getPressUploadMax() > 0 ? props.getPressUploadMax() : 20;
+		// 五台压机与线体同一工位号(自动化设备占用),只靠 pressNo 区分
+		String lineStationSn = workPanel != null ? workPanel.getStationSn() : "";
+		List<MesClientProperties.PressConfig> presses =
+				props == null ? null : props.getPresses();
+		if (presses != null) {
+			for (MesClientProperties.PressConfig pc : presses) {
+				pressPanels.add(new PressPanel(pc, mes_server_ip, lineStationSn, sampleMs, uploadMax));
+			}
+		}
+
 		final JPanel cards = new JPanel(new CardLayout());
 		cards.setOpaque(false);
 		cards.add(workPanel, "work");
+		for (PressPanel pp : pressPanels) {
+			cards.add(pp, "press-" + pp.getPressNo());
+		}
 		cards.add(workRecordPanel, "record");
 
 		final JButton btnSettings = navBtn("设置", false);
 		final JButton btnWork = navBtn("工作面板", true);
+		final List<JButton> btnPresses = new ArrayList<JButton>();
+		for (final PressPanel pp : pressPanels) {
+			btnPresses.add(navBtn(pp.tabTitle(), false));
+		}
 		final JButton btnRecord = navBtn("工作记录", false);
 
+		navButtons.add(btnSettings);
+		navButtons.add(btnWork);
+		navButtons.addAll(btnPresses);
+		navButtons.add(btnRecord);
+
+		// 重量级弹出,避免被卡片层盖住像点了没反应
 		final JPopupMenu settingsMenu = new JPopupMenu();
+		settingsMenu.setLightWeightPopupEnabled(false);
 		JMenuItem miNext = new JMenuItem("手动取批次");
 		miNext.setFont(new Font("微软雅黑", Font.PLAIN, 14));
 		miNext.addActionListener(new ActionListener() {
@@ -233,20 +347,27 @@ public class MainFrame extends JFrame {
 				settingsMenu.show(btnSettings, 0, btnSettings.getHeight());
 			}
 		});
+
 		btnWork.addActionListener(new ActionListener() {
 			@Override
 			public void actionPerformed(ActionEvent e) {
-				((CardLayout) cards.getLayout()).show(cards, "work");
-				styleNavSelected(btnWork, true);
-				styleNavSelected(btnRecord, false);
+				showCard(cards, "work", btnWork);
 			}
 		});
+		for (int i = 0; i < pressPanels.size(); i++) {
+			final PressPanel pp = pressPanels.get(i);
+			final JButton btn = btnPresses.get(i);
+			btn.addActionListener(new ActionListener() {
+				@Override
+				public void actionPerformed(ActionEvent e) {
+					showCard(cards, "press-" + pp.getPressNo(), btn);
+				}
+			});
+		}
 		btnRecord.addActionListener(new ActionListener() {
 			@Override
 			public void actionPerformed(ActionEvent e) {
-				((CardLayout) cards.getLayout()).show(cards, "record");
-				styleNavSelected(btnWork, false);
-				styleNavSelected(btnRecord, true);
+				showCard(cards, "record", btnRecord);
 			}
 		});
 
@@ -256,6 +377,9 @@ public class MainFrame extends JFrame {
 		nav.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UiTheme.LINE));
 		nav.add(btnSettings);
 		nav.add(btnWork);
+		for (JButton b : btnPresses) {
+			nav.add(b);
+		}
 		nav.add(btnRecord);
 
 		JPanel page = new JPanel(new BorderLayout(0, 0));
@@ -266,12 +390,24 @@ public class MainFrame extends JFrame {
 		content.add(page, BorderLayout.CENTER);
 	}
 
-	/** 顶栏导航按钮(设置 / 工作面板 / 工作记录 统一样式) */
+	/** 切换卡片并刷新导航选中态 */
+	private static void showCard(JPanel cards, String name, JButton selected) {
+		((CardLayout) cards.getLayout()).show(cards, name);
+		for (JButton b : navButtons) {
+			if ("设置".equals(b.getText())) {
+				styleNavSelected(b, false);
+				continue;
+			}
+			styleNavSelected(b, b == selected);
+		}
+	}
+
+	/** 顶栏导航按钮 */
 	private static JButton navBtn(String text, boolean selected) {
 		JButton b = new JButton(text);
 		b.setFont(new Font("微软雅黑", Font.PLAIN, 14));
 		b.setFocusPainted(false);
-		b.setMargin(new Insets(8, 18, 8, 18));
+		b.setMargin(new Insets(8, 14, 8, 14));
 		b.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
 		b.setOpaque(true);
 		styleNavSelected(b, selected);
@@ -285,13 +421,13 @@ public class MainFrame extends JFrame {
 			b.setForeground(UiTheme.ACCENT);
 			b.setBorder(BorderFactory.createCompoundBorder(
 					BorderFactory.createMatteBorder(0, 0, 2, 0, UiTheme.ACCENT),
-					new EmptyBorder(8, 18, 6, 18)));
+					new EmptyBorder(8, 14, 6, 14)));
 		} else {
 			b.setBackground(UiTheme.BG);
 			b.setForeground(UiTheme.TEXT);
 			b.setBorder(BorderFactory.createCompoundBorder(
 					BorderFactory.createMatteBorder(0, 0, 2, 0, UiTheme.BG),
-					new EmptyBorder(8, 18, 6, 18)));
+					new EmptyBorder(8, 14, 6, 14)));
 		}
 	}
 
@@ -307,36 +443,60 @@ public class MainFrame extends JFrame {
 		});
 	}
 
-	private static void startTickTimer() {
-		stopTickTimer();
+	/** 线体与各压机各自 Timer,互不阻塞 */
+	private static void startTickTimers() {
+		stopTickTimers();
 		int period = 500;
 		if (props != null && props.getTickMs() > 0) {
 			period = props.getTickMs();
 		}
-		tickTimer = new Timer("dc-station-tick", true);
-		tickTimer.scheduleAtFixedRate(new TimerTask() {
+		lineTickTimer = new Timer("dc-line-tick", true);
+		lineTickTimer.scheduleAtFixedRate(new TimerTask() {
 			@Override
 			public void run() {
 				for (StationPanel p : stationPanels) {
 					try {
 						p.tick();
 					} catch (Exception ex) {
-						log.debug("tick skip: {}", ex.getMessage());
+						log.debug("line tick skip: {}", ex.getMessage());
 					}
 				}
 			}
 		}, 800L, period);
+
+		for (final PressPanel pp : pressPanels) {
+			Timer t = new Timer("dc-press-tick-" + pp.getPressNo(), true);
+			t.scheduleAtFixedRate(new TimerTask() {
+				@Override
+				public void run() {
+					try {
+						pp.tick();
+					} catch (Exception ex) {
+						log.debug("press tick skip #{}: {}",
+								Integer.valueOf(pp.getPressNo()), ex.getMessage());
+					}
+				}
+			}, 900L, period);
+			pressTickTimers.add(t);
+		}
 	}
 
-	private static void stopTickTimer() {
-		if (tickTimer != null) {
-			tickTimer.cancel();
-			tickTimer = null;
+	private static void stopTickTimers() {
+		if (lineTickTimer != null) {
+			lineTickTimer.cancel();
+			lineTickTimer = null;
+		}
+		for (Timer t : pressTickTimers) {
+			try {
+				t.cancel();
+			} catch (Exception ignored) {
+			}
 		}
+		pressTickTimers.clear();
 	}
 
 	/**
-	 * SSE 入队门铃 + 断线 15s 慢轮询;真正取批仍 nextBatch。
+	 * SSE 入队门铃 + 断线 15s 慢轮询;真正取批仍 nextBatch(仅线体工位)。
 	 */
 	private static void startPush() {
 		stopPush();
@@ -383,7 +543,6 @@ public class MainFrame extends JFrame {
 			}
 		});
 		pushClient.start();
-		// 首拉:启动前已入队没有 ENQUEUED 事件
 		new Timer("dc-first-next", true).schedule(new TimerTask() {
 			@Override
 			public void run() {
@@ -396,7 +555,6 @@ public class MainFrame extends JFrame {
 				}
 			}
 		}, 1500L);
-		// 安全网:SSE 在线也 15s 慢轮询,兜住漏推送 / 开批失败后已取未开
 		fallbackNextTimer = new Timer("dc-fallback-next", true);
 		fallbackNextTimer.scheduleAtFixedRate(new TimerTask() {
 			@Override
@@ -410,7 +568,7 @@ public class MainFrame extends JFrame {
 				}
 			}
 		}, 15000L, 15000L);
-		log.info("已启动取码推送订阅 + 首拉 + 15s 安全轮询");
+		log.info("已启动取码推送订阅 + 首拉 + 15s 安全轮询(仅线体)");
 	}
 
 	private static void stopPush() {

+ 487 - 0
src/main/java/com/mes/ui/PressPanel.java

@@ -0,0 +1,487 @@
+package com.mes.ui;
+
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
+import com.mes.config.MesClientProperties;
+import com.mes.entity.DcPressSnapshot;
+import com.mes.service.DcLineBatchContext;
+import com.mes.service.DcPressPlcClient;
+import com.mes.service.MesDcApiClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.*;
+import javax.swing.border.EmptyBorder;
+import java.awt.*;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * 单台压机过程页:不取码、不打印;跟随主界面共享批次采点上报。
+ * 五台与线体共用同一工位号,机台靠 pressNo 区分;压机5达标触发结案打印。
+ */
+public class PressPanel extends JPanel {
+
+	private static final Logger log = LoggerFactory.getLogger(PressPanel.class);
+
+	private final MesClientProperties.PressConfig cfg;
+	private final String serverIp;
+	/** 线体工位号(与自动化设备/取码工位相同,五台共用) */
+	private final String lineStationSn;
+	private final int sampleMs;
+	private final int uploadMax;
+	private final DcPressPlcClient plc;
+	private final AtomicBoolean uploading = new AtomicBoolean(false);
+
+	/** 本批冲次起点;中途复位后按已产重定 */
+	private volatile long baseStrokeCount;
+	private volatile long lastStrokeCount;
+	private volatile int producedQty;
+	/** 是否已对本批触发过结案(防重复) */
+	private volatile boolean finishTriggered;
+	/** 当前已绑定的共享批次码;变化时重定冲次起点 */
+	private volatile String boundBatchCode = "";
+	private volatile long lastSampleAtMs;
+	private volatile DcPressSnapshot lastSnap = new DcPressSnapshot();
+	/** 待上报采样点(内存缓冲,满则批量上传) */
+	private final List<Map<String, String>> sampleBuf = new ArrayList<Map<String, String>>();
+
+	private final StatusLight lampPlc;
+	private final JLabel lblPlcState;
+	private final StatusLight lampRun;
+	private final JLabel lblRunState;
+	private final JTextField txtBatch;
+	private final JTextField txtTarget;
+	private final JTextField txtProduced;
+	private final JTextField txtStroke;
+	private final JTextField txtDieHeight;
+	private final JTextField txtCylinder;
+	private final JTextField txtTonnage;
+	private final JTextField txtSpm;
+	private final JTextField txtAir;
+	private final JTextField txtEjector;
+	private final JTextField txtEnergy;
+
+	/**
+	 * @param lineStationSn 线体工位号(与取码工位一致,五台共用)
+	 */
+	public PressPanel(MesClientProperties.PressConfig cfg, String serverIp, String lineStationSn,
+			int sampleMs, int uploadMax) {
+		this.cfg = cfg;
+		this.serverIp = serverIp == null ? "" : serverIp.trim();
+		this.lineStationSn = lineStationSn == null ? "" : lineStationSn.trim();
+		this.sampleMs = sampleMs > 0 ? sampleMs : 1000;
+		this.uploadMax = uploadMax > 0 ? uploadMax : 20;
+		this.plc = new DcPressPlcClient(cfg);
+
+		setLayout(new BorderLayout(0, 0));
+		setBackground(UiTheme.BG);
+
+		String titleText = nvl(cfg.getTitle());
+		if (titleText.isEmpty()) {
+			titleText = "压机" + cfg.getPressNo();
+		}
+
+		JPanel header = UiTheme.gradientHeader();
+		header.setBorder(new EmptyBorder(16, 20, 16, 20));
+		JLabel lblTitle = new JLabel(titleText);
+		lblTitle.setFont(UiTheme.FONT_TITLE);
+		lblTitle.setForeground(Color.WHITE);
+		// Consolas 不支持中文;副标题只写工位编码 + 压机编号,避免乱码方框
+		JLabel lblCode = new JLabel(nvl(this.lineStationSn) + "  #" + cfg.getPressNo());
+		lblCode.setFont(new Font("Consolas", Font.BOLD, 13));
+		lblCode.setForeground(new Color(140, 210, 220));
+		JPanel titleCol = new JPanel();
+		titleCol.setOpaque(false);
+		titleCol.setLayout(new BoxLayout(titleCol, BoxLayout.Y_AXIS));
+		titleCol.add(lblTitle);
+		titleCol.add(Box.createVerticalStrut(3));
+		titleCol.add(lblCode);
+
+		lampPlc = new StatusLight();
+		lblPlcState = headerStateLabel("未连接");
+		lampRun = new StatusLight();
+		lblRunState = headerStateLabel("停止");
+		JPanel east = new JPanel(new FlowLayout(FlowLayout.RIGHT, 14, 0));
+		east.setOpaque(false);
+		east.add(headerLampItem("PLC", lampPlc, lblPlcState));
+		east.add(headerLampItem("设备", lampRun, lblRunState));
+		header.add(titleCol, BorderLayout.WEST);
+		header.add(east, BorderLayout.EAST);
+		add(header, BorderLayout.NORTH);
+
+		// 跟随批次 : 过程参数 按 1:2 等比分高;格子有最小高度,再矮则滚动
+		JPanel main = new JPanel(new GridBagLayout());
+		main.setOpaque(false);
+		main.setBorder(new EmptyBorder(16, 20, 16, 20));
+
+		JPanel batchCard = UiTheme.card();
+		batchCard.setLayout(new BorderLayout(0, 10));
+		batchCard.add(UiTheme.sectionTitle("跟随批次(主界面)"), BorderLayout.NORTH);
+		JPanel batchGrid = new JPanel(new GridLayout(1, 3, 14, 0));
+		batchGrid.setOpaque(false);
+		batchGrid.setPreferredSize(new Dimension(10, UiTheme.TILE_PREF_H));
+		batchGrid.setMinimumSize(new Dimension(10, UiTheme.TILE_MIN_H));
+		txtBatch = roField();
+		txtTarget = roField();
+		txtProduced = roField();
+		batchGrid.add(UiTheme.paramTile("批次码", txtBatch, UiTheme.STRIPE_SIDE));
+		batchGrid.add(UiTheme.paramTile("目标数量", txtTarget, UiTheme.STRIPE_SIDE));
+		batchGrid.add(UiTheme.paramTile("本机已产", txtProduced, UiTheme.STRIPE_SIDE));
+		UiTheme.markTileValueBase(txtProduced, UiTheme.FONT_SN.getSize2D());
+		batchCard.add(batchGrid, BorderLayout.CENTER);
+
+		JPanel runCard = UiTheme.card();
+		runCard.setLayout(new BorderLayout(0, 10));
+		runCard.add(UiTheme.sectionTitle("过程参数"), BorderLayout.NORTH);
+		JPanel grid = new JPanel(new GridLayout(2, 4, 14, 14));
+		grid.setOpaque(false);
+		grid.setMinimumSize(new Dimension(10, UiTheme.TILE_MIN_H * 2 + 14));
+		grid.setPreferredSize(new Dimension(10, UiTheme.TILE_PREF_H * 2 + 14));
+		txtStroke = roField();
+		txtDieHeight = roField();
+		txtCylinder = roField();
+		txtTonnage = roField();
+		txtSpm = roField();
+		txtAir = roField();
+		txtEjector = roField();
+		txtEnergy = roField();
+		grid.add(UiTheme.paramTile("冲次数量", txtStroke, UiTheme.STRIPE_SIDE));
+		grid.add(UiTheme.paramTile("生产高度", txtDieHeight, UiTheme.STRIPE_SIDE));
+		grid.add(UiTheme.paramTile("顶缸压力", txtCylinder, UiTheme.STRIPE_SIDE));
+		grid.add(UiTheme.paramTile("生产吨位", txtTonnage, UiTheme.STRIPE_SIDE));
+		grid.add(UiTheme.paramTile("压机行程次数", txtSpm, UiTheme.STRIPE_SIDE));
+		grid.add(UiTheme.paramTile("气垫风压", txtAir, UiTheme.STRIPE_SIDE));
+		grid.add(UiTheme.paramTile("顶杆行程", txtEjector, UiTheme.STRIPE_SIDE));
+		grid.add(UiTheme.paramTile("能耗", txtEnergy, UiTheme.STRIPE_SIDE));
+		runCard.add(grid, BorderLayout.CENTER);
+
+		GridBagConstraints gc = new GridBagConstraints();
+		gc.gridx = 0;
+		gc.fill = GridBagConstraints.BOTH;
+		gc.weightx = 1;
+		gc.gridy = 0;
+		gc.weighty = 1;
+		main.add(batchCard, gc);
+		gc.gridy = 1;
+		gc.weighty = 2;
+		gc.insets = new Insets(14, 0, 0, 0);
+		main.add(runCard, gc);
+
+		JScrollPane scroll = new JScrollPane(main);
+		scroll.setBorder(BorderFactory.createEmptyBorder());
+		scroll.setOpaque(false);
+		scroll.getViewport().setOpaque(false);
+		scroll.getVerticalScrollBar().setUnitIncrement(16);
+		add(scroll, BorderLayout.CENTER);
+	}
+
+	public int getPressNo() {
+		return cfg.getPressNo();
+	}
+
+	/** 上报/展示用工位:线体工位号(五台相同) */
+	public String getStationSn() {
+		return lineStationSn;
+	}
+
+	public String tabTitle() {
+		String t = nvl(cfg.getTitle());
+		return t.isEmpty() ? ("压机" + cfg.getPressNo()) : t;
+	}
+
+	public void initPlc() {
+		plc.connect();
+		uiPlcLabel();
+		refreshSnapshotUi(plc.readSnapshot());
+	}
+
+	/**
+	 * 周期:重连、刷示值;有共享批次则累计冲次、采样上报;压机5达标通知结案。
+	 */
+	public void tick() {
+		try {
+			plc.maintainConnection();
+			uiPlcLabel();
+			DcPressSnapshot snap = plc.readSnapshot();
+			if (snap != null) {
+				lastSnap = snap;
+			}
+			refreshSnapshotUi(snap);
+
+			boolean lineRun = DcLineBatchContext.isRunning();
+			String batch = DcLineBatchContext.getBatchCode();
+			int target = DcLineBatchContext.getTargetQty();
+			setText(txtBatch, batch);
+			setText(txtTarget, target > 0 ? String.valueOf(target) : "");
+
+			if (!lineRun) {
+				// 线体空闲:清本机批内状态,冲刷残留采样
+				if (!boundBatchCode.isEmpty() || producedQty > 0 || !sampleBuf.isEmpty() || finishTriggered) {
+					flushSamplesAsync();
+					resetLocalBatchProgress();
+				}
+				setText(txtProduced, "");
+				return;
+			}
+
+			// 批次码变化:重定冲次起点
+			if (!batch.equalsIgnoreCase(boundBatchCode)) {
+				boundBatchCode = batch;
+				finishTriggered = false;
+				producedQty = 0;
+				baseStrokeCount = 0L;
+				lastStrokeCount = 0L;
+				if (plc.isConnected() && snap != null && !nvl(snap.strokeCountText).isEmpty()) {
+					baseStrokeCount = snap.strokeCount;
+					lastStrokeCount = snap.strokeCount;
+					log.info("压机[{}] 跟随开批 batch={} baseStroke={}",
+							Integer.valueOf(cfg.getPressNo()), batch, Long.valueOf(baseStrokeCount));
+				}
+			} else if (baseStrokeCount == 0L && lastStrokeCount == 0L
+					&& plc.isConnected() && snap != null && !nvl(snap.strokeCountText).isEmpty()) {
+				// 开批时 PLC 未连上,稍后补记起点
+				baseStrokeCount = snap.strokeCount;
+				lastStrokeCount = snap.strokeCount;
+			}
+
+			if (plc.isConnected() && snap != null && !nvl(snap.strokeCountText).isEmpty()) {
+				updateProducedAgainstStroke(snap.strokeCount);
+			}
+			DcLineBatchContext.setPressProduced(cfg.getPressNo(), producedQty);
+			setText(txtProduced, String.valueOf(producedQty));
+
+			maybeSample(snap, batch);
+
+			// 压机5:冲次达标 → 主界面打印结案
+			if (cfg.getPressNo() == 5 && !finishTriggered && target > 0 && producedQty >= target) {
+				finishTriggered = true;
+				log.info("压机5 达标 produced={} target={} batch={},触发主界面结案",
+						Integer.valueOf(producedQty), Integer.valueOf(target), batch);
+				flushSamplesAsync();
+				MainFrame.requestFinishFromPress5(producedQty);
+			}
+		} catch (Exception e) {
+			log.warn("压机[{}] tick 异常: {}", Integer.valueOf(cfg.getPressNo()), e.getMessage());
+		}
+	}
+
+	/** 线体结案瞬间冲刷缓冲(主界面调用) */
+	public void onLineBatchClosed() {
+		flushSamplesAsync();
+		resetLocalBatchProgress();
+	}
+
+	/** 线体开批瞬间复位本机进度(主界面调用) */
+	public void onLineBatchOpened() {
+		resetLocalBatchProgress();
+		finishTriggered = false;
+	}
+
+	private void resetLocalBatchProgress() {
+		baseStrokeCount = 0L;
+		lastStrokeCount = 0L;
+		producedQty = 0;
+		finishTriggered = false;
+		boundBatchCode = "";
+		DcLineBatchContext.setPressProduced(cfg.getPressNo(), 0);
+	}
+
+	/**
+	 * 有批次时按 sampleMs 采一点进缓冲,满 uploadMax 则上报。
+	 */
+	private void maybeSample(DcPressSnapshot snap, String batch) {
+		if (snap == null || batch == null || batch.isEmpty()) {
+			return;
+		}
+		long now = System.currentTimeMillis();
+		if (now - lastSampleAtMs < sampleMs) {
+			return;
+		}
+		lastSampleAtMs = now;
+		Map<String, String> pt = new LinkedHashMap<String, String>();
+		pt.put("sampleTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+		pt.put("dieHeight", nvl(snap.dieHeight));
+		pt.put("strokeCount", nvl(snap.strokeCountText));
+		pt.put("cylinderPressure", nvl(snap.cylinderPressure));
+		pt.put("tonnage", nvl(snap.tonnage));
+		pt.put("pressSpm", nvl(snap.pressSpm));
+		pt.put("airCushion", nvl(snap.airCushion));
+		pt.put("ejectorStroke", nvl(snap.ejectorStroke));
+		pt.put("energyKwh", nvl(snap.energyKwh));
+		pt.put("deviceRunning", snap.deviceRunning ? "1" : "0");
+		pt.put("deviceStateText", nvl(snap.deviceStateText));
+		synchronized (sampleBuf) {
+			sampleBuf.add(pt);
+			if (sampleBuf.size() >= uploadMax) {
+				flushSamplesAsync();
+			}
+		}
+	}
+
+	/** 异步批量上报采样;不堵 tick */
+	private void flushSamplesAsync() {
+		final List<Map<String, String>> chunk;
+		synchronized (sampleBuf) {
+			if (sampleBuf.isEmpty()) {
+				return;
+			}
+			chunk = new ArrayList<Map<String, String>>(sampleBuf);
+			sampleBuf.clear();
+		}
+		if (serverIp.isEmpty()) {
+			return;
+		}
+		if (!uploading.compareAndSet(false, true)) {
+			// 上传进行中:把点塞回缓冲头,下轮再试
+			synchronized (sampleBuf) {
+				sampleBuf.addAll(0, chunk);
+			}
+			return;
+		}
+		final String batch = DcLineBatchContext.getBatchCode();
+		new Thread(new Runnable() {
+			@Override
+			public void run() {
+				try {
+					if (batch == null || batch.isEmpty()) {
+						return;
+					}
+					JSONObject body = new JSONObject();
+					body.put("batchCode", batch);
+					// 五台共用线体工位号;机台区分靠 pressNo
+					body.put("stationSn", lineStationSn);
+					body.put("pressNo", Integer.valueOf(cfg.getPressNo()));
+					body.put("pressModel", nvl(cfg.getPressModel()));
+					body.put("stationTitle", nvl(cfg.getTitle()));
+					JSONArray arr = new JSONArray();
+					for (Map<String, String> pt : chunk) {
+						arr.add(new JSONObject(pt));
+					}
+					body.put("samples", arr);
+					JSONObject ret = MesDcApiClient.uploadPressParam(serverIp, body);
+					if (!MesDcApiClient.isSuccess(ret)) {
+						log.warn("压机[{}] 采样上报失败: {}", Integer.valueOf(cfg.getPressNo()),
+								MesDcApiClient.messageOf(ret));
+						synchronized (sampleBuf) {
+							sampleBuf.addAll(0, chunk);
+						}
+					} else {
+						log.info("压机[{}] 采样上报成功 points={} batch={}",
+								Integer.valueOf(cfg.getPressNo()),
+								Integer.valueOf(chunk.size()), batch);
+					}
+				} catch (Exception ex) {
+					log.warn("压机[{}] 采样上报异常: {}", Integer.valueOf(cfg.getPressNo()), ex.getMessage());
+					synchronized (sampleBuf) {
+						sampleBuf.addAll(0, chunk);
+					}
+				} finally {
+					uploading.set(false);
+				}
+			}
+		}, "dc-press-upload-" + cfg.getPressNo()).start();
+	}
+
+	/** 按冲次累计本批已产;冲次变小则保留已产并重定起点 */
+	private void updateProducedAgainstStroke(long strokeCount) {
+		if (strokeCount < lastStrokeCount) {
+			int kept = producedQty;
+			baseStrokeCount = strokeCount - kept;
+			log.warn("压机[{}] 冲次复位:上次={} 本次={} 保留已产={} 重定起点={}",
+					Integer.valueOf(cfg.getPressNo()),
+					Long.valueOf(lastStrokeCount), Long.valueOf(strokeCount),
+					Integer.valueOf(kept), Long.valueOf(baseStrokeCount));
+		}
+		long producedLong = strokeCount - baseStrokeCount;
+		if (producedLong < 0L) {
+			producedLong = 0L;
+		}
+		int produced = producedLong > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) producedLong;
+		if (produced > producedQty) {
+			producedQty = produced;
+		}
+		lastStrokeCount = strokeCount;
+	}
+
+	private void refreshSnapshotUi(final DcPressSnapshot s) {
+		if (s == null) {
+			return;
+		}
+		SwingUtilities.invokeLater(new Runnable() {
+			@Override
+			public void run() {
+				setText(txtStroke, s.strokeCountText);
+				setText(txtDieHeight, s.dieHeight);
+				setText(txtCylinder, s.cylinderPressure);
+				setText(txtTonnage, s.tonnage);
+				setText(txtSpm, s.pressSpm);
+				setText(txtAir, s.airCushion);
+				setText(txtEjector, s.ejectorStroke);
+				setText(txtEnergy, s.energyKwh);
+				lampRun.setOn(s.deviceRunning);
+				lblRunState.setText(nvl(s.deviceStateText).isEmpty()
+						? (s.deviceRunning ? "运行" : "停止") : s.deviceStateText);
+			}
+		});
+	}
+
+	private void uiPlcLabel() {
+		final boolean ok = plc.isConnected();
+		SwingUtilities.invokeLater(new Runnable() {
+			@Override
+			public void run() {
+				lampPlc.setLevel(ok ? StatusLight.Level.ON : StatusLight.Level.FAULT);
+				lblPlcState.setText(ok ? "已连接" : "未连接");
+			}
+		});
+	}
+
+	private static JLabel headerStateLabel(String text) {
+		JLabel lb = new JLabel(text, SwingConstants.CENTER);
+		lb.setFont(new Font("微软雅黑", Font.PLAIN, 11));
+		lb.setForeground(new Color(200, 230, 235));
+		lb.setAlignmentX(Component.CENTER_ALIGNMENT);
+		return lb;
+	}
+
+	private static JPanel headerLampItem(String name, StatusLight lamp, JLabel stateLbl) {
+		JPanel p = new JPanel();
+		p.setOpaque(false);
+		p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
+		JLabel lb = new JLabel(name, SwingConstants.CENTER);
+		lb.setFont(new Font("微软雅黑", Font.PLAIN, 12));
+		lb.setForeground(new Color(160, 210, 220));
+		lb.setAlignmentX(Component.CENTER_ALIGNMENT);
+		lamp.setAlignmentX(Component.CENTER_ALIGNMENT);
+		stateLbl.setAlignmentX(Component.CENTER_ALIGNMENT);
+		p.add(lb);
+		p.add(Box.createVerticalStrut(2));
+		p.add(lamp);
+		p.add(Box.createVerticalStrut(2));
+		p.add(stateLbl);
+		return p;
+	}
+
+	private static JTextField roField() {
+		JTextField t = new JTextField();
+		t.setEditable(false);
+		t.setFont(UiTheme.FONT_VALUE);
+		return t;
+	}
+
+	private static void setText(JTextField t, String v) {
+		if (t != null) {
+			t.setText(v == null ? "" : v);
+		}
+	}
+
+	private static String nvl(String s) {
+		return s == null ? "" : s.trim();
+	}
+}

+ 344 - 112
src/main/java/com/mes/ui/StationPanel.java

@@ -4,7 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
 import com.mes.config.MesClientProperties;
 import com.mes.entity.DcRunSnapshot;
 import com.mes.service.DcBatchPrinter;
-import com.mes.service.DcPackCode;
+import com.mes.service.DcLineBatchContext;
 import com.mes.service.DcPlcClient;
 import com.mes.service.DcWorkRecordStore;
 import com.mes.service.MesDcApiClient;
@@ -24,7 +24,8 @@ import java.util.Map;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
- * 自动化大冲单线面板:轮询取批次 → MES允许=true → 读 DB260 盯产量 → 结案再允许=false → 打印。
+ * 自动化大冲线体主面板:取批次 → MES允许 → 读 DB260 展示;
+ * 结案打印由压机5冲次达标触发(本页不再按 DB260 产量自动结案)。
  */
 public class StationPanel extends JPanel {
 
@@ -58,10 +59,20 @@ public class StationPanel extends JPanel {
 	private volatile long lastPollBatchAtMs;
 	/** 最近一次 DB260 快照,结案时一并上传(只传一次,不采样堆) */
 	private volatile DcRunSnapshot lastSnap = new DcRunSnapshot();
+	/** 结案上传未成功时的待重试报文(DONE 态由 tick 续传,避免热队列卡「已取」) */
+	private volatile Map<String, String> pendingCompleteFields;
+	/** 挂起结案说明文案(达标/手动/强制) */
+	private volatile String pendingHow = "";
+	/** 挂起结案对应批次码(续传提示用) */
+	private volatile String pendingBatchCode = "";
+	/** 挂起结案数量 */
+	private volatile int pendingQty;
+	/** 异步打印是否已成功送出(仅提示,不挡结案) */
+	private volatile boolean pendingPrinted;
+	/** 结案上传重试互斥,避免 finish 线程与 tick 同时打 completeBatch */
+	private final AtomicBoolean completeRetryBusy = new AtomicBoolean(false);
 
 	private final JLabel lblStation;
-	/** 顶栏 PLC 地址文案(不含连接状态) */
-	private final JLabel lblPlc;
 	private final JLabel lblStatus;
 	private final JTextField txtBatch;
 	private final JTextField txtTarget;
@@ -71,6 +82,10 @@ public class StationPanel extends JPanel {
 	private final JTextField txtProduced;
 	private final JTextField txtDowntime;
 	private final JTextField txtTakt;
+	/** 产线状态文案示值 */
+	private final JTextField txtLineState;
+	/** 五台压机本批进度(主界面汇总,结案看压机5) */
+	private final JTextField txtPressProgress;
 	/** 服务端 SSE 呼吸灯 */
 	private final BreathingLight serverHeartbeat;
 	/** PLC 连接指示灯:绿=已连,红=未连 */
@@ -127,9 +142,6 @@ public class StationPanel extends JPanel {
 		lblLineState = headerStateLabel("待机");
 		lampMesAllow = new StatusLight();
 		lblMesAllowState = headerStateLabel("关");
-		lblPlc = new JLabel(plcAddrText());
-		lblPlc.setFont(new Font("Consolas", Font.PLAIN, 12));
-		lblPlc.setForeground(new Color(160, 210, 220));
 
 		JPanel east = new JPanel(new FlowLayout(FlowLayout.RIGHT, 14, 0));
 		east.setOpaque(false);
@@ -137,10 +149,6 @@ public class StationPanel extends JPanel {
 		east.add(headerLampItem("PLC", lampPlc, lblPlcState));
 		east.add(headerLampItem("产线", lampLineState, lblLineState));
 		east.add(headerLampItem("MES允许", lampMesAllow, lblMesAllowState));
-		// 有 IP 时才跟地址
-		if (!plcAddrText().isEmpty()) {
-			east.add(lblPlc);
-		}
 		header.add(titleCol, BorderLayout.WEST);
 		header.add(east, BorderLayout.EAST);
 
@@ -158,52 +166,75 @@ public class StationPanel extends JPanel {
 		north.add(lblStatus, BorderLayout.SOUTH);
 		add(north, BorderLayout.NORTH);
 
-		JPanel main = new JPanel(new BorderLayout(0, 14));
+		// 本批 : 线体过程 按 1:3 等比分高;格子有最小高度,再矮则滚动
+		JPanel main = new JPanel(new GridBagLayout());
 		main.setOpaque(false);
 		main.setBorder(new EmptyBorder(16, 20, 16, 20));
 
-		// —— 本批:上方两格,固定偏好高度 ——
 		JPanel batchCard = UiTheme.card();
 		batchCard.setLayout(new BorderLayout(0, 10));
 		batchCard.add(UiTheme.sectionTitle("本批"), BorderLayout.NORTH);
 		JPanel batchGrid = new JPanel(new GridLayout(1, 2, 14, 0));
 		batchGrid.setOpaque(false);
 		batchGrid.setPreferredSize(new Dimension(10, UiTheme.TILE_PREF_H));
+		batchGrid.setMinimumSize(new Dimension(10, UiTheme.TILE_MIN_H));
 		txtBatch = roField();
 		txtTarget = roField();
 		batchGrid.add(UiTheme.paramTile("批次码", txtBatch, UiTheme.STRIPE_SIDE));
 		batchGrid.add(UiTheme.paramTile("本批目标数量", txtTarget, UiTheme.STRIPE_SIDE));
 		batchCard.add(batchGrid, BorderLayout.CENTER);
 
-		// —— 线体过程:占满剩余高度,大字示值填空 ——
 		JPanel runCard = UiTheme.card();
 		runCard.setLayout(new BorderLayout(0, 10));
 		runCard.add(UiTheme.sectionTitle("线体过程"), BorderLayout.NORTH);
-		JPanel grid = new JPanel(new GridLayout(2, 3, 14, 14));
+		JPanel grid = new JPanel(new GridLayout(3, 3, 14, 14));
 		grid.setOpaque(false);
+		// 3 行格子最小总高,防止被压成一条线
+		grid.setMinimumSize(new Dimension(10, UiTheme.TILE_MIN_H * 3 + 28));
+		grid.setPreferredSize(new Dimension(10, UiTheme.TILE_PREF_H * 3 + 28));
 		txtCurrentPart = roField();
 		txtNextPart = roField();
 		txtActualQty = roField();
 		txtProduced = roField();
-		txtProduced.setFont(UiTheme.FONT_SN);
 		txtDowntime = roField();
 		txtTakt = roField();
-		grid.add(UiTheme.paramTile("当前零件", txtCurrentPart, UiTheme.STRIPE_SIDE));
-		grid.add(UiTheme.paramTile("下一零件", txtNextPart, UiTheme.STRIPE_SIDE));
-		grid.add(UiTheme.paramTile("累计实际产量", txtActualQty, UiTheme.STRIPE_SIDE));
-		grid.add(UiTheme.paramTile("本批已产", txtProduced, UiTheme.STRIPE_SIDE));
+		txtPressProgress = roField();
+		txtLineState = roField();
+		grid.add(UiTheme.paramTile("当前零件名称", txtCurrentPart, UiTheme.STRIPE_SIDE));
+		grid.add(UiTheme.paramTile("下一零件名称", txtNextPart, UiTheme.STRIPE_SIDE));
+		grid.add(UiTheme.paramTile("实际产量", txtActualQty, UiTheme.STRIPE_SIDE));
 		grid.add(UiTheme.paramTile("停机时间", txtDowntime, UiTheme.STRIPE_SIDE));
 		grid.add(UiTheme.paramTile("生产节拍", txtTakt, UiTheme.STRIPE_SIDE));
+		grid.add(UiTheme.paramTile("产线状态", txtLineState, UiTheme.STRIPE_SIDE));
+		grid.add(UiTheme.paramTile("本批已产", txtProduced, UiTheme.STRIPE_SIDE));
+		UiTheme.markTileValueBase(txtProduced, UiTheme.FONT_SN.getSize2D());
+		grid.add(UiTheme.paramTile("五台冲次数量进度", txtPressProgress, UiTheme.STRIPE_SIDE));
+		UiTheme.markTileValueBase(txtPressProgress, UiTheme.FONT_BODY.getSize2D());
 		runCard.add(grid, BorderLayout.CENTER);
 
-		main.add(batchCard, BorderLayout.NORTH);
-		main.add(runCard, BorderLayout.CENTER);
-		add(main, BorderLayout.CENTER);
-
-		JPanel actions = new JPanel(new BorderLayout(0, 0));
+		GridBagConstraints gc = new GridBagConstraints();
+		gc.gridx = 0;
+		gc.fill = GridBagConstraints.BOTH;
+		gc.weightx = 1;
+		gc.gridy = 0;
+		gc.weighty = 1; // 本批约 1 行
+		main.add(batchCard, gc);
+		gc.gridy = 1;
+		gc.weighty = 3; // 线体过程约 3 行,与本批等比分高
+		gc.insets = new Insets(14, 0, 0, 0);
+		main.add(runCard, gc);
+
+		JScrollPane scroll = new JScrollPane(main);
+		scroll.setBorder(BorderFactory.createEmptyBorder());
+		scroll.setOpaque(false);
+		scroll.getViewport().setOpaque(false);
+		scroll.getVerticalScrollBar().setUnitIncrement(16);
+		add(scroll, BorderLayout.CENTER);
+
+		// 底部操作区:只保留「取批次」按钮
+		JPanel actions = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 0));
 		actions.setOpaque(false);
 		actions.setBorder(new EmptyBorder(0, 20, 16, 20));
-		JLabel tip = UiTheme.mutedLabel("正常靠 SSE 自动取批;未收到推送可点「取批次」,或等约 15 秒安全轮询");
 		btnNext = UiTheme.primaryBtn("取批次");
 		btnNext.addActionListener(new ActionListener() {
 			@Override
@@ -211,11 +242,7 @@ public class StationPanel extends JPanel {
 				onManualNextClick();
 			}
 		});
-		JPanel btns = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 0));
-		btns.setOpaque(false);
-		btns.add(btnNext);
-		actions.add(tip, BorderLayout.WEST);
-		actions.add(btns, BorderLayout.EAST);
+		actions.add(btnNext);
 		add(actions, BorderLayout.SOUTH);
 	}
 
@@ -235,8 +262,8 @@ public class StationPanel extends JPanel {
 	}
 
 	/**
-	 * 周期:重连、刷 DB260;RUN 算产量差达标结案。
-	 * 取批由 SSE 门铃 / 断线兜底触发,不在 tick 里狂轮询。
+	 * 周期:重连、刷 DB260;RUN 只展示线体产量差,不按 DB260 自动结案。
+	 * 结案由压机5冲次达标触发 {@link #finishFromPress5(int)}。
 	 */
 	public void tick() {
 		if (busy.get()) {
@@ -251,6 +278,7 @@ public class StationPanel extends JPanel {
 				lastSnap = snap;
 			}
 			refreshSnapshotUi(snap);
+			refreshPressProgressUi();
 			if (phase == Phase.IDLE) {
 				if (!MainFrame.isMesServerOnline()) {
 					setStatusUi("空闲:MES/SSE 未连接,等待服务端…");
@@ -259,14 +287,19 @@ public class StationPanel extends JPanel {
 				}
 				return;
 			}
+			if (phase == Phase.DONE) {
+				// 上传曾失败:用挂起报文续传,成功前不重新开批、不回空闲
+				retryPendingCompleteIfAny();
+				return;
+			}
 			if (phase == Phase.RUN) {
-				// 产量差达标;若中途实际产量被复位变小,保留已产并重定起点
+				// 线体产量差仅展示;结案看压机5
 				updateProducedAgainstActual(snap.actualQty);
 				setText(txtProduced, String.valueOf(producedQty));
-				setStatusUi("生产中 批次=" + batchCode + "  已产 " + producedQty + " / 目标 " + targetQty);
-				if (producedQty >= targetQty) {
-					finishBatch(producedQty, false);
-				}
+				int p5 = DcLineBatchContext.getPressProduced(5);
+				setStatusUi("生产中 批次=" + batchCode
+						+ "  压机5 " + p5 + " / " + targetQty
+						+ "  (达标后打印结案)");
 			}
 		} catch (Exception e) {
 			log.warn("工位[{}] tick 异常: {}", cfg.getStationSn(), e.getMessage());
@@ -288,14 +321,21 @@ public class StationPanel extends JPanel {
 		tryAutoNextFromPush();
 	}
 
-	/** SSE 清码:占用同一批次则复位 */
+	/**
+	 * SSE 清码:本机正占用同一批次码则关允许并回空闲。
+	 * 结案上传中(DONE+挂起报文)不打断,避免丢续传导致热队列卡「已取」。
+	 */
 	public void applyClearedFromPush(String clearedSn) {
 		String local = nvl(batchCode);
 		String remote = nvl(clearedSn);
 		if (local.isEmpty() || remote.isEmpty() || !local.equalsIgnoreCase(remote)) {
 			return;
 		}
-		if (phase == Phase.IDLE || phase == Phase.DONE) {
+		if (phase == Phase.IDLE) {
+			return;
+		}
+		if (phase == Phase.DONE && pendingCompleteFields != null) {
+			log.info("工位[{}] 结案上传中收到清码 sn={},不打断", cfg.getStationSn(), local);
 			return;
 		}
 		if (!busy.compareAndSet(false, true)) {
@@ -304,6 +344,8 @@ public class StationPanel extends JPanel {
 		try {
 			log.info("工位[{}] 收到清码推送,复位本地 batch={}", cfg.getStationSn(), local);
 			plc.setMesAllow(false);
+			pendingCompleteFields = null;
+			// resetToIdle 内会关闭共享批次并通知压机页冲刷
 			resetToIdle("服务端已清码 " + local);
 			MainFrame.setMenuStatus(cfg.getStationSn() + " 已清码 " + local, 0);
 		} finally {
@@ -311,51 +353,60 @@ public class StationPanel extends JPanel {
 		}
 	}
 
-	/** 开批失败后延迟再 next */
-	private void scheduleNextRetry(long delayMs) {
-		final long wait = delayMs > 0L ? delayMs : 3000L;
-		new Thread(new Runnable() {
-			@Override
-			public void run() {
-				try {
-					Thread.sleep(wait);
-				} catch (InterruptedException ie) {
-					Thread.currentThread().interrupt();
-					return;
-				}
-				lastPollBatchAtMs = 0L;
-				tryAutoNextFromPush();
-			}
-		}, "dc-next-retry-" + cfg.getStationSn()).start();
+	/** 异步 nextBatch,不堵 PLC tick(自动门铃/兜底,带 2s 节流) */
+	public void requestNextAsync() {
+		requestNextAsync(false);
 	}
 
-	/** 异步 nextBatch,不堵 PLC tick */
-	public void requestNextAsync() {
+	/**
+	 * 异步 nextBatch。
+	 *
+	 * @param forceManual true=手动按钮:跳过节流,必打日志,失败把服务端文案顶到状态条
+	 */
+	public void requestNextAsync(final boolean forceManual) {
 		if (phase != Phase.IDLE) {
+			if (forceManual) {
+				log.info("工位[{}] 手动取批次忽略:当前 phase={}", cfg.getStationSn(), phase);
+			}
 			return;
 		}
 		long now = System.currentTimeMillis();
-		if (now - lastPollBatchAtMs < POLL_BATCH_INTERVAL_MS) {
+		if (!forceManual && now - lastPollBatchAtMs < POLL_BATCH_INTERVAL_MS) {
 			return;
 		}
 		lastPollBatchAtMs = now;
 		if (serverIp.isEmpty()) {
 			setStatusUi("空闲:等待扫码(server-ip 未配,仅可联调模拟)");
+			log.warn("工位[{}] 取批次中止:server-ip 未配置", cfg.getStationSn());
 			return;
 		}
 		if (!nextBusy.compareAndSet(false, true)) {
+			if (forceManual) {
+				setStatusUi("取批次进行中,请稍候…");
+				log.info("工位[{}] 手动取批次:已有请求在飞,跳过重复点击", cfg.getStationSn());
+			}
 			return;
 		}
+		log.info("工位[{}] 开始 nextBatch{}", cfg.getStationSn(), forceManual ? "(手动)" : "");
 		new Thread(new Runnable() {
 			@Override
 			public void run() {
 				try {
 					JSONObject ret = MesDcApiClient.nextBatch(serverIp, cfg.getStationSn());
 					if (phase != Phase.IDLE) {
+						log.info("工位[{}] nextBatch 返回时已非空闲 phase={},丢弃结果",
+								cfg.getStationSn(), phase);
+						return;
+					}
+					if (ret == null) {
+						setStatusUi("取批次无响应(检查服务端/网络)");
+						log.warn("工位[{}] nextBatch 无响应 server={}", cfg.getStationSn(), serverIp);
 						return;
 					}
 					if (!MesDcApiClient.isSuccess(ret)) {
-						setStatusUi("空闲:等待扫码下发批次…");
+						String msg = MesDcApiClient.messageOf(ret);
+						setStatusUi("取批次:" + msg);
+						log.info("工位[{}] nextBatch 未取到:{}", cfg.getStationSn(), msg);
 						return;
 					}
 					String code = MesDcApiClient.dataStr(ret, "batchCode");
@@ -367,9 +418,12 @@ public class StationPanel extends JPanel {
 						target = MesDcApiClient.dataInt(ret, "qty", 0);
 					}
 					if (code.isEmpty() || target <= 0) {
+						setStatusUi("取批次成功但缺批次码/目标数量");
 						log.warn("工位[{}] nextBatch 成功但缺 batchCode/targetQty: {}", cfg.getStationSn(), ret);
 						return;
 					}
+					log.info("工位[{}] nextBatch 成功 batch={} target={}",
+							cfg.getStationSn(), code, Integer.valueOf(target));
 					startBatchFromPda(code, target);
 				} finally {
 					nextBusy.set(false);
@@ -382,7 +436,8 @@ public class StationPanel extends JPanel {
 	 * 批次到位:记起点产量 → MES允许=true → 进入 RUN;本批做完再写 false。
 	 */
 	private void startBatchFromPda(String code, int target) {
-		if (phase == Phase.RUN) {
+		// DONE 挂起续传中禁止再开批,避免冲掉待上传结案
+		if (phase == Phase.RUN || phase == Phase.DONE) {
 			return;
 		}
 		if (!busy.compareAndSet(false, true)) {
@@ -392,63 +447,127 @@ public class StationPanel extends JPanel {
 			if (!plc.isConnected()) {
 				plc.connect();
 			}
+			// 服务端 next 后队列已是「已取」:PLC 读不到也不能丢弃,否则热表卡住、界面像没反应
 			Integer base = plc.readActualQty();
+			int baseQty = 0;
 			if (base == null) {
-				// 队列已是已取:必须重试 nextBatch,否则等不到下一次 SSE
-				setStatusUi("收到批次,但读实际产量失败,将自动重试…");
-				MainFrame.setMenuStatus(cfg.getStationSn() + " 开批失败:读产量", -1);
-				scheduleNextRetry(3000L);
-				return;
+				log.warn("工位[{}] 开批时读实际产量失败(PLC 未连/点位异常),起点按 0,batch={}",
+						cfg.getStationSn(), code);
+			} else {
+				baseQty = base.intValue();
 			}
 			batchCode = code;
 			targetQty = target;
-			baseActualQty = base.intValue();
+			baseActualQty = baseQty;
 			lastActualQty = baseActualQty;
 			producedQty = 0;
 			batchStartTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
+			// 共享给五台压机页:只主界面持有批次码
+			DcLineBatchContext.open(batchCode, targetQty, batchStartTime);
+			MainFrame.notifyPressesBatchOpened();
 			boolean wrote = plc.setMesAllow(true);
 			phase = Phase.RUN;
 			setText(txtBatch, batchCode);
 			setText(txtTarget, String.valueOf(targetQty));
 			setText(txtProduced, "0");
 			setMesAllowLamp(wrote);
-			setStatusUi((wrote ? "批次已开,MES允许已写" : "批次已开(允许点未配/写失败,本地仍盯产量)")
-					+ "  起始产量=" + baseActualQty);
+			String tip = wrote ? "批次已开,MES允许已写" : "批次已开(允许点未配/写失败)";
+			if (base == null) {
+				tip = tip + "  PLC产量未读到,起点=0";
+			} else {
+				tip = tip + "  起始产量=" + baseActualQty;
+			}
+			tip = tip + "  结案看压机5";
+			setStatusUi(tip);
 			MainFrame.setMenuStatus(cfg.getStationSn() + " 开批 " + batchCode + " 目标" + targetQty, 0);
-			log.info("工位[{}] 开批 batch={} target={} baseQty={}",
-					cfg.getStationSn(), batchCode, Integer.valueOf(targetQty), Integer.valueOf(baseActualQty));
+			log.info("工位[{}] 开批 batch={} target={} baseQty={} plcOk={}(结案条件=压机5达标)",
+					cfg.getStationSn(), batchCode, Integer.valueOf(targetQty),
+					Integer.valueOf(baseActualQty), Boolean.valueOf(base != null));
 		} finally {
 			busy.set(false);
 		}
 	}
 
 	/**
-	 * 手动取批次:SSE 漏推时立刻 nextBatch(清空节流)。
+	 * 手动取批次:SSE 漏推时立刻 nextBatch(跳过节流,必打日志)。
 	 * 仅空闲可用。
 	 */
 	public void onManualNextClick() {
+		log.info("工位[{}] 点击「取批次」 phase={}", cfg.getStationSn(), phase);
 		if (phase != Phase.IDLE) {
 			setStatusUi("当前非空闲,无法取批次(进行中请用手动提交结案)");
 			return;
 		}
-		lastPollBatchAtMs = 0L;
 		setStatusUi("正在手动取批次…");
-		requestNextAsync();
+		requestNextAsync(true);
 	}
 
 	/**
-	 * 手动提交:校验密码 mes 后,按当前已产数量结案(过站结果 OK)。
-	 * 由主窗页签左侧「设置」菜单调用。
+	 * 手动提交:设置菜单入口。
+	 * RUN:密码 mes → 确认批次/数量 → 结案(走挂起续传)。
+	 * DONE+挂起:可立即再打一次上传;其它态弹窗说明。
 	 */
 	public void onManualSubmitClick() {
+		log.info("工位[{}] 点击「手动提交」 phase={} batch={}",
+				cfg.getStationSn(), phase, batchCode);
+		if (phase == Phase.DONE && pendingCompleteFields != null) {
+			int opt = JOptionPane.showConfirmDialog(dialogParent(),
+					"批次 " + pendingBatchCode + " 结案上传未成功,是否立即重试?",
+					"手动提交", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
+			if (opt == JOptionPane.YES_OPTION) {
+				setStatusUi("手动触发结案续传…");
+				new Thread(new Runnable() {
+					@Override
+					public void run() {
+						uploadPendingComplete(false);
+					}
+				}, "dc-manual-retry-" + cfg.getStationSn()).start();
+			}
+			return;
+		}
 		if (phase != Phase.RUN) {
-			setStatusUi("当前无进行中的批次,无法手动提交");
+			JOptionPane.showMessageDialog(dialogParent(),
+					"当前无进行中的批次,无法手动提交。\n请先取批次并开批后再试。",
+					"手动提交", JOptionPane.INFORMATION_MESSAGE);
 			return;
 		}
 		if (!askMesPassword()) {
 			return;
 		}
-		finishBatch(producedQty, false, true);
+		int qty = DcLineBatchContext.getPressProduced(5);
+		if (qty <= 0) {
+			qty = producedQty;
+		}
+		String confirm = "确认手动结案?\n"
+				+ "批次码:" + batchCode + "\n"
+				+ "压机5已产:" + DcLineBatchContext.getPressProduced(5) + "\n"
+				+ "线体已产:" + producedQty + "\n"
+				+ "计划产量:" + targetQty + "\n"
+				+ "本次上报数量:" + qty;
+		int ok = JOptionPane.showConfirmDialog(dialogParent(), confirm, "手动提交",
+				JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
+		if (ok != JOptionPane.OK_OPTION) {
+			return;
+		}
+		finishBatch(qty, false, true);
+	}
+
+	/**
+	 * 压机5冲次达标回调:按压机5已产数量结案并打印。
+	 *
+	 * @param press5Qty 压机5本批已产
+	 */
+	public void finishFromPress5(int press5Qty) {
+		if (phase != Phase.RUN) {
+			return;
+		}
+		int qty = press5Qty > 0 ? press5Qty : DcLineBatchContext.getPressProduced(5);
+		if (qty <= 0) {
+			qty = producedQty;
+		}
+		log.info("工位[{}] 收到压机5达标结案 qty={} batch={}",
+				cfg.getStationSn(), Integer.valueOf(qty), batchCode);
+		finishBatch(qty, false, false);
 	}
 
 	/**
@@ -461,7 +580,7 @@ public class StationPanel extends JPanel {
 		JPanel box = new JPanel(new BorderLayout(8, 8));
 		box.add(new JLabel("请输入密码"), BorderLayout.NORTH);
 		box.add(pf, BorderLayout.CENTER);
-		int opt = JOptionPane.showConfirmDialog(this, box, "手动提交",
+		int opt = JOptionPane.showConfirmDialog(dialogParent(), box, "手动提交",
 				JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
 		if (opt != JOptionPane.OK_OPTION) {
 			return false;
@@ -470,19 +589,26 @@ public class StationPanel extends JPanel {
 		boolean ok = Arrays.equals(input, "mes".toCharArray());
 		Arrays.fill(input, '\0');
 		if (!ok) {
-			JOptionPane.showMessageDialog(this, "密码错误", "手动提交", JOptionPane.WARNING_MESSAGE);
+			JOptionPane.showMessageDialog(dialogParent(), "密码错误", "手动提交", JOptionPane.WARNING_MESSAGE);
 			return false;
 		}
 		return true;
 	}
 
+	/** 弹窗挂到主窗,避免工作面板未显示时对话框位置异常 */
+	private Component dialogParent() {
+		Window w = SwingUtilities.getWindowAncestor(this);
+		return w != null ? w : this;
+	}
+
 	/** 产量达标结案 */
 	private void finishBatch(final int qty, final boolean aborted) {
 		finishBatch(qty, aborted, false);
 	}
 
 	/**
-	 * 结案。
+	 * 结案:关 MES允许 → 本机记录 → 异步打印 → 挂起报文上传;
+	 * 仅 completeBatch 成功才回空闲,失败留 DONE 由 tick 续传。
 	 *
 	 * @param qty 本批数量
 	 * @param aborted 是否强制中断(结果 NG)
@@ -498,26 +624,26 @@ public class StationPanel extends JPanel {
 		new Thread(new Runnable() {
 			@Override
 			public void run() {
+				boolean fieldsReady = false;
 				try {
 					// 本批做完:MES允许改回 false
 					plc.setMesAllow(false);
+					SwingUtilities.invokeLater(new Runnable() {
+						@Override
+						public void run() {
+							setMesAllowLamp(false);
+						}
+					});
 					String time = timeSnap;
 					if (time == null || time.isEmpty()) {
 						time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
 					}
-					// 包装码:年月日 + 随机6位,打印与上传都用它做批量追溯
-					final String packCode = DcPackCode.next();
-					boolean printed = DcBatchPrinter.printPack(packCode, time, qty);
 					// 过站结果:中断 NG,否则 OK(含手动提交)
 					String passResult = aborted ? "NG" : "OK";
-					DcWorkRecordStore.add(packCode, codeSnap, time, qty, passResult);
-					MainFrame.refreshWorkRecords();
-					// 结案只上传一次:包装码 + 批次码 + 本批数量 + DB260 过程参数
 					DcRunSnapshot snap = lastSnap == null ? new DcRunSnapshot() : lastSnap;
-					Map<String, String> fields = new LinkedHashMap<String, String>();
+					final Map<String, String> fields = new LinkedHashMap<String, String>();
 					fields.put("stationSn", cfg.getStationSn());
 					fields.put("batchCode", codeSnap);
-					fields.put("packCode", packCode);
 					fields.put("qty", String.valueOf(qty));
 					fields.put("produceTime", time);
 					fields.put("aborted", aborted ? "1" : "0");
@@ -530,21 +656,39 @@ public class StationPanel extends JPanel {
 					fields.put("takt", String.valueOf(snap.takt));
 					fields.put("lineState", String.valueOf(snap.lineState));
 					fields.put("lineStateText", nvl(snap.lineStateText));
-					MesDcApiClient.completeBatch(serverIp, fields);
-
-					String how = aborted ? "已强制结束" : (manual ? "手动提交" : "本批达标");
-					final String tip = how + "  包装码=" + packCode + "  数量=" + qty
-							+ (printed ? "  已送打印" : "  打印失败/无打印机");
-					SwingUtilities.invokeLater(new Runnable() {
+					// 本机记录先落;挂起报文供 DONE 续传(按批次码幂等)
+					DcWorkRecordStore.add(codeSnap, time, qty, passResult);
+					MainFrame.refreshWorkRecords();
+					String how = aborted ? "已强制结束" : (manual ? "手动提交" : "压机5达标");
+					pendingCompleteFields = fields;
+					pendingHow = how;
+					pendingBatchCode = codeSnap;
+					pendingQty = qty;
+					pendingPrinted = false;
+					fieldsReady = true;
+					// 打印异步:打印机卡死不能挡 MES 结案;小票打批次码
+					final String printTime = time;
+					final String printBatch = codeSnap;
+					new Thread(new Runnable() {
 						@Override
 						public void run() {
-							resetToIdle(tip);
-							MainFrame.setMenuStatus(cfg.getStationSn() + " 结案 " + packCode + " x" + qty, 0);
+							boolean ok = DcBatchPrinter.printBatch(printBatch, printTime, qty);
+							pendingPrinted = ok;
+							if (!ok) {
+								log.warn("工位[{}] 异步打印失败/无打印机 batch={}", cfg.getStationSn(), printBatch);
+							}
 						}
-					});
-					log.info("工位[{}] 结案 batch={} pack={} qty={} aborted={} manual={} printed={}",
-							cfg.getStationSn(), codeSnap, packCode, Integer.valueOf(qty),
-							Boolean.valueOf(aborted), Boolean.valueOf(manual), Boolean.valueOf(printed));
+					}, "dc-print-" + cfg.getStationSn()).start();
+					// 先放 busy:phase=DONE,tick 可刷灯并可走续传
+					busy.set(false);
+					uploadPendingComplete(true);
+				} catch (Exception ex) {
+					log.error("工位[{}] 结案异常: {}", cfg.getStationSn(), ex.getMessage(), ex);
+					setStatusUi("结案异常:" + ex.getMessage());
+					if (!fieldsReady) {
+						// 报文未备好:回到 RUN,可手动再提交
+						phase = Phase.RUN;
+					}
 				} finally {
 					busy.set(false);
 				}
@@ -552,6 +696,69 @@ public class StationPanel extends JPanel {
 		}, "dc-finish-" + cfg.getStationSn()).start();
 	}
 
+	/** DONE 态 tick 触发:有挂起结案则续传 */
+	private void retryPendingCompleteIfAny() {
+		if (pendingCompleteFields == null) {
+			return;
+		}
+		uploadPendingComplete(false);
+	}
+
+	/**
+	 * 上传挂起的结案报文;成功才回空闲(关共享批次、通知压机)。
+	 *
+	 * @param fromFinishThread true=结案线程内首轮(可多等几轮);false=tick 续传单次
+	 */
+	private void uploadPendingComplete(boolean fromFinishThread) {
+		final Map<String, String> fields = pendingCompleteFields;
+		if (fields == null) {
+			return;
+		}
+		if (!completeRetryBusy.compareAndSet(false, true)) {
+			return;
+		}
+		final String how = pendingHow;
+		final String batch = pendingBatchCode;
+		final int qty = pendingQty;
+		try {
+			int maxAttempts = fromFinishThread ? 12 : 1;
+			boolean uploaded = false;
+			for (int attempt = 1; attempt <= maxAttempts; attempt++) {
+				JSONObject ret = MesDcApiClient.completeBatch(serverIp, fields);
+				uploaded = MesDcApiClient.isSuccess(ret);
+				if (uploaded) {
+					break;
+				}
+				setStatusUi(how + "  批次码=" + batch + "  上传失败,重试中…(#" + attempt + ")");
+				MainFrame.setMenuStatus(cfg.getStationSn() + " 上传失败重试 #" + attempt, -1);
+				log.warn("工位[{}] 结案上传失败 batch={} attempt={} msg={}",
+						cfg.getStationSn(), batch, Integer.valueOf(attempt),
+						MesDcApiClient.messageOf(ret));
+				if (attempt < maxAttempts) {
+					try {
+						Thread.sleep(5000L);
+					} catch (InterruptedException ie) {
+						Thread.currentThread().interrupt();
+						break;
+					}
+				}
+			}
+			if (uploaded) {
+				pendingCompleteFields = null;
+				final String tip = how + "  批次码=" + batch + "  数量=" + qty
+						+ (pendingPrinted ? "  已送打印" : "  打印已提交/待确认")
+						+ "  已上传";
+				resetToIdle(tip);
+				MainFrame.setMenuStatus(cfg.getStationSn() + " 结案 " + batch + " x" + qty, 0);
+				log.info("工位[{}] 结案成功 batch={} qty={}", cfg.getStationSn(), batch, Integer.valueOf(qty));
+			} else {
+				setStatusUi(how + "  批次码=" + batch + "  等待续传…");
+			}
+		} finally {
+			completeRetryBusy.set(false);
+		}
+	}
+
 	/**
 	 * 按 PLC 实际产量累计本批已产。
 	 * 若实际产量比上一拍变小(人为复位/清零),保留已产件数,把起点挪到「当前值 − 已产」,
@@ -590,12 +797,21 @@ public class StationPanel extends JPanel {
 		producedQty = 0;
 		lastActualQty = 0;
 		batchStartTime = "";
+		pendingCompleteFields = null;
+		pendingHow = "";
+		pendingBatchCode = "";
+		pendingQty = 0;
+		pendingPrinted = false;
+		// 上传成功或清码后才关共享批次,挂起续传期间压机仍能看见本批
+		DcLineBatchContext.close();
+		MainFrame.notifyPressesBatchClosed();
 		SwingUtilities.invokeLater(new Runnable() {
 			@Override
 			public void run() {
 				setText(txtBatch, "");
 				setText(txtTarget, "");
 				setText(txtProduced, "");
+				setText(txtPressProgress, "");
 				setMesAllowLamp(false);
 				setStatusUi(msg == null || msg.isEmpty()
 						? "空闲:等待扫码下发批次…" : msg + "  → 等待下一笔");
@@ -603,6 +819,30 @@ public class StationPanel extends JPanel {
 		});
 	}
 
+	/** 刷新主界面「五台冲次进度」汇总 */
+	private void refreshPressProgressUi() {
+		if (phase != Phase.RUN) {
+			return;
+		}
+		final int target = targetQty;
+		final StringBuilder sb = new StringBuilder();
+		for (int i = 1; i <= 5; i++) {
+			if (i > 1) {
+				sb.append("  ");
+			}
+			sb.append(i).append('#').append(DcLineBatchContext.getPressProduced(i));
+			if (target > 0) {
+				sb.append('/').append(target);
+			}
+		}
+		SwingUtilities.invokeLater(new Runnable() {
+			@Override
+			public void run() {
+				setText(txtPressProgress, sb.toString());
+			}
+		});
+	}
+
 	private void refreshSnapshotUi(final DcRunSnapshot s) {
 		if (s == null) {
 			return;
@@ -615,6 +855,8 @@ public class StationPanel extends JPanel {
 				setText(txtActualQty, String.valueOf(s.actualQty));
 				setText(txtDowntime, String.valueOf(s.downtime));
 				setText(txtTakt, String.valueOf(s.takt));
+				setText(txtLineState, nvl(s.lineStateText).isEmpty()
+						? String.valueOf(s.lineState) : s.lineStateText);
 				setLineStateLamp(s.lineState);
 				setMesAllowLamp(phase == Phase.RUN);
 			}
@@ -654,13 +896,12 @@ public class StationPanel extends JPanel {
 		});
 	}
 
-	/** 顶栏刷新:连接灯 + 状态说明 + 地址 */
+	/** 顶栏刷新:连接灯 + 状态说明 */
 	private void uiPlcLabel() {
 		final boolean ok = plc.isConnected();
 		SwingUtilities.invokeLater(new Runnable() {
 			@Override
 			public void run() {
-				lblPlc.setText(plcAddrText());
 				lampPlc.setLevel(ok ? StatusLight.Level.ON : StatusLight.Level.FAULT);
 				lblPlcState.setText(ok ? "已连接" : "未连接");
 			}
@@ -681,15 +922,6 @@ public class StationPanel extends JPanel {
 		});
 	}
 
-	/** PLC 地址;IP 未配返回空 */
-	private String plcAddrText() {
-		String ip = nvl(cfg.getPlcIp());
-		if (ip.isEmpty()) {
-			return "";
-		}
-		return ip + ":" + cfg.getPlcPort();
-	}
-
 	/** 顶栏状态说明(灯正下方) */
 	private static JLabel headerStateLabel(String text) {
 		JLabel lb = new JLabel(text, SwingConstants.CENTER);

+ 59 - 5
src/main/java/com/mes/ui/UiTheme.java

@@ -4,6 +4,8 @@ import javax.swing.*;
 import javax.swing.border.Border;
 import javax.swing.border.EmptyBorder;
 import java.awt.*;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
 
 /**
  * 大冲客户端视觉主题:浅灰底 + 深蓝顶栏,字号偏大适合工控屏。
@@ -55,8 +57,14 @@ public final class UiTheme {
 	public static final Font FONT_VALUE = new Font("微软雅黑", Font.BOLD, 36);
 	public static final Font FONT_BTN = new Font("微软雅黑", Font.BOLD, 16);
 
-	/** 参数格偏好高度(可随布局拉伸) */
+	/** 参数格偏好高度(设计态) */
 	public static final int TILE_PREF_H = 120;
+	/** 参数格最小高度:再矮就出滚动条,避免压成一条线 */
+	public static final int TILE_MIN_H = 84;
+	/** 字号/内边距等比缩放下限(相对 TILE_PREF_H) */
+	public static final float TILE_SCALE_MIN = 0.70f;
+	/** 字号/内边距等比缩放上限 */
+	public static final float TILE_SCALE_MAX = 1.15f;
 
 	public static void applyLookAndFeel() {
 		try {
@@ -114,24 +122,29 @@ public final class UiTheme {
 	}
 
 	/**
-	 * 带左侧色条的参数格:标签在上、大字示值居中,格子可随布局拉伸填满空白。
+	 * 带左侧色条的参数格:标签在上、大字示值居中;
+	 * 高度随布局伸缩时,字号与内边距按 TILE_PREF_H 等比缩放,且不低于 TILE_MIN_H / TILE_SCALE_MIN。
 	 */
 	public static JPanel paramTile(String label, JComponent field, Color stripe) {
-		JPanel outer = new JPanel(new BorderLayout(0, 0));
+		final JPanel outer = new JPanel(new BorderLayout(0, 0));
 		outer.setOpaque(false);
 		outer.setPreferredSize(new Dimension(240, TILE_PREF_H));
+		outer.setMinimumSize(new Dimension(140, TILE_MIN_H));
 		JPanel stripeBar = new JPanel();
 		stripeBar.setPreferredSize(new Dimension(6, 10));
+		stripeBar.setMinimumSize(new Dimension(4, 4));
 		stripeBar.setBackground(stripe == null ? STRIPE_SIDE : stripe);
 		stripeBar.setOpaque(true);
-		JPanel inner = new JPanel(new BorderLayout(0, 8));
+		final JPanel inner = new JPanel(new BorderLayout(0, 8));
 		inner.setBackground(new Color(248, 250, 252));
 		inner.setBorder(new EmptyBorder(14, 16, 14, 16));
-		JLabel lb = mutedLabel(label);
+		final JLabel lb = mutedLabel(label);
 		inner.add(lb, BorderLayout.NORTH);
 		field.setBackground(new Color(248, 250, 252));
 		field.setFont(FONT_VALUE);
 		field.setForeground(TEXT);
+		// 记录示值基准字号,缩放时按此等比(避免被二次 setFont 冲掉后无法还原)
+		field.putClientProperty("tile.basePt", Float.valueOf(FONT_VALUE.getSize2D()));
 		if (field instanceof JTextField) {
 			JTextField tf = (JTextField) field;
 			tf.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));
@@ -141,9 +154,50 @@ public final class UiTheme {
 		outer.add(stripeBar, BorderLayout.WEST);
 		outer.add(inner, BorderLayout.CENTER);
 		outer.setBorder(BorderFactory.createLineBorder(LINE));
+		bindTileScale(outer, lb, field, inner);
 		return outer;
 	}
 
+	/**
+	 * 把示值控件的缩放基准字号改成指定字号(如本批已产用更大字)。
+	 */
+	public static void markTileValueBase(JComponent field, float basePt) {
+		if (field == null) {
+			return;
+		}
+		field.putClientProperty("tile.basePt", Float.valueOf(basePt));
+		field.setFont(FONT_VALUE.deriveFont(basePt));
+	}
+
+	/**
+	 * 格子高度变化时:标签字 / 示值字 / 内边距按同一比例缩放。
+	 */
+	private static void bindTileScale(final JPanel outer, final JLabel lb,
+			final JComponent field, final JPanel inner) {
+		outer.addComponentListener(new ComponentAdapter() {
+			@Override
+			public void componentResized(ComponentEvent e) {
+				int h = outer.getHeight();
+				if (h <= 0) {
+					return;
+				}
+				float scale = h / (float) TILE_PREF_H;
+				if (scale < TILE_SCALE_MIN) {
+					scale = TILE_SCALE_MIN;
+				} else if (scale > TILE_SCALE_MAX) {
+					scale = TILE_SCALE_MAX;
+				}
+				lb.setFont(FONT_LABEL.deriveFont(Math.max(11f, FONT_LABEL.getSize2D() * scale)));
+				Float basePt = (Float) field.getClientProperty("tile.basePt");
+				float base = basePt == null ? FONT_VALUE.getSize2D() : basePt.floatValue();
+				field.setFont(FONT_VALUE.deriveFont(Math.max(14f, base * scale)));
+				int padV = Math.max(4, Math.round(14 * scale));
+				int padH = Math.max(6, Math.round(16 * scale));
+				inner.setBorder(new EmptyBorder(padV, padH, padV, padH));
+			}
+		});
+	}
+
 	public static JLabel mutedLabel(String text) {
 		JLabel l = new JLabel(text);
 		l.setFont(FONT_LABEL);

+ 3 - 5
src/main/java/com/mes/ui/WorkRecordPanel.java

@@ -54,7 +54,7 @@ public class WorkRecordPanel extends JPanel {
 		header.add(btnRefresh, BorderLayout.EAST);
 		add(header, BorderLayout.NORTH);
 
-		String[] cols = new String[] { "包装码", "批次码", "记录时间", "数量", "结果" };
+		String[] cols = new String[] { "批次码", "记录时间", "数量", "结果" };
 		model = new DefaultTableModel(cols, 0) {
 			private static final long serialVersionUID = 1L;
 
@@ -74,11 +74,10 @@ public class WorkRecordPanel extends JPanel {
 		for (int i = 0; i < table.getColumnCount(); i++) {
 			table.getColumnModel().getColumn(i).setCellRenderer(center);
 		}
-		table.getColumnModel().getColumn(0).setPreferredWidth(160);
+		table.getColumnModel().getColumn(0).setPreferredWidth(200);
 		table.getColumnModel().getColumn(1).setPreferredWidth(160);
-		table.getColumnModel().getColumn(2).setPreferredWidth(150);
+		table.getColumnModel().getColumn(2).setPreferredWidth(70);
 		table.getColumnModel().getColumn(3).setPreferredWidth(70);
-		table.getColumnModel().getColumn(4).setPreferredWidth(70);
 
 		JScrollPane scroll = new JScrollPane(table);
 		scroll.setBorder(BorderFactory.createEmptyBorder(12, 16, 8, 16));
@@ -104,7 +103,6 @@ public class WorkRecordPanel extends JPanel {
 				continue;
 			}
 			model.addRow(new Object[] {
-					r.packCode,
 					r.batchCode,
 					r.recordTime,
 					Integer.valueOf(r.qty),

+ 108 - 3
src/main/resources/config/application.yml

@@ -1,5 +1,6 @@
-# 自动化大冲:取批次 → MES允许=true → 轮询读 DB260 → 本批做完允许=false → 打印包装码
-# 结案 completeBatch 只上传一次(包装码+过程参数)
+# 自动化大冲:主界面 DB260 取批;五台压机跟批次采点;压机5冲次数量达标 → 打印结案
+# 五台与线体共用同一工位号(stations.station-sn),机台靠 press-no 区分
+# 结案 completeBatch 落 mes_flex_dc;压机采样 uploadPressParam 落 mes_flex_dc_press_param
 spring:
   main:
     web-application-type: none
@@ -16,15 +17,119 @@ mes:
   app-title: MES 自动化大冲
   server-ip: 127.0.0.1
   tick-ms: 500
+  # 压机采样周期(毫秒) / 缓冲满多少点上报一次
+  press-sample-ms: 1000
+  press-upload-max: 20
   # 结案小票连接的系统打印机名;空=用 Windows 默认打印机
   printer-name:
+
+  # 线体主站(唯一取码工位;五台压机共用此工位号)
   stations:
     - id: 1
       title: 自动化大冲
       station-sn: DC01
       plc-ip: 192.168.17.1
       plc-port: 102
-      # MES允许运行 BOOL:点表暂缺偏移,有了再填,如 DB260.200.0
+      # MES允许运行 BOOL(例:DB260.200.0);空则只本地开批不写 PLC
       mes-allow-addr:
 
+  # =====================================================================
+  # 五台压机过程页:不取码、不单独占工位;压机5「冲次数量」达标触发主界面打印结案
+  # 点表全称 ↔ yml 配置项(地址按 S7 写法,例 DB3.168):
+  #   冲次数量     → stroke-count-addr       (UDINT;本批进度差;压机5结案看此点)
+  #   生产高度     → die-height-addr         (REAL)
+  #   顶缸压力     → cylinder-pressure-addr  (REAL)
+  #   生产吨位     → tonnage-addr            (REAL 或 DINT,由 tonnage-dint 决定)
+  #   压机行程次数 → press-spm-addr          (REAL)
+  #   气垫风压     → air-cushion-addr        (REAL;无机型则留空)
+  #   顶杆行程     → ejector-stroke-addr     (REAL;无机型则留空)
+  #   能耗         → energy-addr             (DINT;无机型则留空)
+  # 另:device-run-addr = 设备运行 BOOL;空则界面不亮运行灯
+  #     tonnage-dint=true 按 DINT 读生产吨位,false 按 REAL 读
+  # plc-ip 空:本机不连 PLC,不影响其它压机
+  # =====================================================================
+  presses:
+    # ---------- 压机1 LS4-1300R ----------
+    - press-no: 1
+      title: 压机1 LS4-1300R
+      press-model: LS4-1300R
+      plc-ip:                          # 本机 PLC IP,例 192.168.1.10
+      plc-port: 102
+      stroke-count-addr:               # 冲次数量
+      die-height-addr:                 # 生产高度
+      cylinder-pressure-addr:          # 顶缸压力
+      tonnage-addr:                    # 生产吨位
+      tonnage-dint: false              # 生产吨位数据类型:false=REAL,true=DINT
+      press-spm-addr:                  # 压机行程次数
+      air-cushion-addr:                # 气垫风压(无则留空)
+      ejector-stroke-addr:             # 顶杆行程(无则留空)
+      energy-addr:                     # 能耗(无则留空)
+      device-run-addr:                 # 设备运行 BOOL
 
+    # ---------- 压机2 JD36-800R ----------
+    - press-no: 2
+      title: 压机2 JD36-800R
+      press-model: JD36-800R
+      plc-ip:
+      plc-port: 102
+      stroke-count-addr:               # 冲次数量
+      die-height-addr:                 # 生产高度
+      cylinder-pressure-addr:          # 顶缸压力
+      tonnage-addr:                    # 生产吨位
+      tonnage-dint: false
+      press-spm-addr:                  # 压机行程次数
+      air-cushion-addr:                # 气垫风压(无则留空)
+      ejector-stroke-addr:             # 顶杆行程(无则留空)
+      energy-addr:                     # 能耗(无则留空)
+      device-run-addr:                 # 设备运行 BOOL
+
+    # ---------- 压机3 JD36-500R ----------
+    - press-no: 3
+      title: 压机3 JD36-500R
+      press-model: JD36-500R
+      plc-ip:
+      plc-port: 102
+      stroke-count-addr:               # 冲次数量
+      die-height-addr:                 # 生产高度
+      cylinder-pressure-addr:          # 顶缸压力
+      tonnage-addr:                    # 生产吨位
+      tonnage-dint: false
+      press-spm-addr:                  # 压机行程次数(点表无则留空)
+      air-cushion-addr:                # 气垫风压(无则留空)
+      ejector-stroke-addr:             # 顶杆行程(无则留空)
+      energy-addr:                     # 能耗(无则留空)
+      device-run-addr:                 # 设备运行 BOOL
+
+    # ---------- 压机4 JD36-500R ----------
+    - press-no: 4
+      title: 压机4 JD36-500R
+      press-model: JD36-500R
+      plc-ip:
+      plc-port: 102
+      stroke-count-addr:               # 冲次数量
+      die-height-addr:                 # 生产高度
+      cylinder-pressure-addr:          # 顶缸压力
+      tonnage-addr:                    # 生产吨位
+      tonnage-dint: false
+      press-spm-addr:                  # 压机行程次数(点表无则留空)
+      air-cushion-addr:                # 气垫风压(无则留空)
+      ejector-stroke-addr:             # 顶杆行程(无则留空)
+      energy-addr:                     # 能耗(无则留空)
+      device-run-addr:                 # 设备运行 BOOL
+
+    # ---------- 压机5 JD36-500R(冲次数量达标 → 主界面打印结案) ----------
+    - press-no: 5
+      title: 压机5 JD36-500R
+      press-model: JD36-500R
+      plc-ip:
+      plc-port: 102
+      stroke-count-addr:               # 冲次数量(本机达标后触发主界面打印结案,必填)
+      die-height-addr:                 # 生产高度
+      cylinder-pressure-addr:          # 顶缸压力
+      tonnage-addr:                    # 生产吨位
+      tonnage-dint: false
+      press-spm-addr:                  # 压机行程次数(点表无则留空)
+      air-cushion-addr:                # 气垫风压(无则留空)
+      ejector-stroke-addr:             # 顶杆行程(无则留空)
+      energy-addr:                     # 能耗(无则留空)
+      device-run-addr:                 # 设备运行 BOOL