dingzhicheng 1 день назад
Родитель
Сommit
8e0a8e2c83

BIN
pack/dist/tuhan-client.exe


+ 4 - 4
src/main/java/com/mes/ui/BreathingLight.java

@@ -18,8 +18,8 @@ public class BreathingLight extends JComponent {
 
 	/** 在线亮绿 */
 	private static final Color GREEN = new Color(40, 220, 100);
-	/** 在线暗相(灰) */
-	private static final Color GRAY = new Color(120, 130, 140);
+	/** 在线暗相:仍偏绿,避免被看成「灭了」 */
+	private static final Color GREEN_DIM = new Color(30, 140, 70);
 	/** 断开红色 */
 	private static final Color RED = new Color(230, 60, 50);
 	/** 断开外圈描边 */
@@ -36,7 +36,7 @@ public class BreathingLight extends JComponent {
 		setPreferredSize(new Dimension(28, 28));
 		setMinimumSize(new Dimension(24, 24));
 		setOpaque(false);
-		setToolTipText("服务端心跳:绿/灰闪=已连接,红=断开");
+		setToolTipText("服务端心跳:绿灯闪=已连接,红=断开");
 		blinkTimer = new javax.swing.Timer(BLINK_MS, new ActionListener() {
 			@Override
 			public void actionPerformed(ActionEvent e) {
@@ -92,7 +92,7 @@ public class BreathingLight extends JComponent {
 			int cy = h / 2;
 
 			if (online) {
-				g2.setColor(showGreen ? GREEN : GRAY);
+				g2.setColor(showGreen ? GREEN : GREEN_DIM);
 				g2.fillOval(cx - r, cy - r, r * 2, r * 2);
 			} else {
 				g2.setColor(RED_RING);

+ 10 - 3
src/main/java/com/mes/ui/StationPanel.java

@@ -80,6 +80,9 @@ public class StationPanel extends JPanel {
 	/** 设备状态心跳间隔:2 分钟 */
 	private static final long DEVICE_HEARTBEAT_MS = 2L * 60L * 1000L;
 	private volatile long lastDeviceHeartbeatAtMs;
+	/** PLC 未连时重试间隔,避免 tick 被 connect 超时卡住导致服务端灯不刷新 */
+	private static final long PLC_RECONNECT_MS = 8_000L;
+	private volatile long lastPlcConnectAtMs;
 
 	/** 生产过程参数回显(对齐 RealHuHan:只展示采参量,不展示握手点位) */
 	private final JTextField txtWeld1Current;
@@ -365,10 +368,11 @@ public class StationPanel extends JPanel {
 	 * 有码 HOLD/RUN:等运行开始 → 运行结束按件上传。
 	 */
 	public void tick() {
+		// 先刷服务端灯:PLC 连超时会卡住后面逻辑,不能让灯跟着假红
+		uiServerHeartbeat();
 		if (busy.get()) {
 			uiPlcLabel();
 			uiDeviceStatusLight();
-			uiServerHeartbeat();
 			maybePushDeviceHeartbeat();
 			return;
 		}
@@ -380,7 +384,11 @@ public class StationPanel extends JPanel {
 			if (phase == Phase.IDLE) {
 				if (!sessionActive) {
 					if (!device.isConnected()) {
-						device.connect();
+						long now = System.currentTimeMillis();
+						if (now - lastPlcConnectAtMs >= PLC_RECONNECT_MS) {
+							lastPlcConnectAtMs = now;
+							device.connect();
+						}
 					}
 					if (device.isConnected()) {
 						requestOpenSessionIfCheckOk();
@@ -430,7 +438,6 @@ public class StationPanel extends JPanel {
 			}
 			uiPlcLabel();
 			uiDeviceStatusLight();
-			uiServerHeartbeat();
 			maybePushDeviceHeartbeat();
 		} catch (Exception e) {
 			log.warn("工位[{}] tick 异常: {}", cfg.getStationSn(), e.getMessage());

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

@@ -215,9 +215,15 @@ public class WorkRecordPanel extends JPanel {
 				String shiftTitle = nvl(stats.getString("shiftTitle"));
 				String shiftLabel = shiftTitle.isEmpty() ? "本班" : shiftTitle;
 				lblShiftStats.setText(shiftLabel + "完成: " + total);
-				String tip = snQ.isEmpty()
-						? ("本班列表 " + list.size() + " 条")
-						: ("查询「" + snQ + "」 " + list.size() + " 条");
+				String tip;
+				if (!snQ.isEmpty()) {
+					tip = "查询「" + snQ + "」 " + list.size() + " 条";
+				} else if (list.isEmpty()) {
+					// 空列表≠断网:接口已成功;本班尚无取码结案才进工作记录
+					tip = "已连接服务 · 本班暂无取码结案记录(未认领上传不进此列表)";
+				} else {
+					tip = "本班列表 " + list.size() + " 条";
+				}
 				lblStatus.setText(tip);
 				lblStatus.setForeground(UiTheme.OK_FG);
 				log.info("工作记录加载 list={} shiftTotal={}", list.size(), total);