zxl hace 4 semanas
commit
ef75e4fe98
Se han modificado 77 ficheros con 2503 adiciones y 0 borrados
  1. 22 0
      .gitignore
  2. BIN
      lib/iot-communication-1.4.4.jar
  3. 5 0
      pack/build-exe.bat
  4. 6 0
      pack/build-exe.ps1
  5. BIN
      pack/icon.ico
  6. 64 0
      pom.xml
  7. 59 0
      src/main/java/com/mes/MesClientApplication.java
  8. 133 0
      src/main/java/com/mes/config/MesClientProperties.java
  9. 28 0
      src/main/java/com/mes/entity/DcRunSnapshot.java
  10. 29 0
      src/main/java/com/mes/entity/DcWorkRecord.java
  11. 113 0
      src/main/java/com/mes/service/DcBatchPrinter.java
  12. 24 0
      src/main/java/com/mes/service/DcPackCode.java
  13. 204 0
      src/main/java/com/mes/service/DcPlcClient.java
  14. 39 0
      src/main/java/com/mes/service/DcPlcPointMap.java
  15. 44 0
      src/main/java/com/mes/service/DcWorkRecordStore.java
  16. 87 0
      src/main/java/com/mes/service/MesApiClient.java
  17. 117 0
      src/main/java/com/mes/service/MesDcApiClient.java
  18. 318 0
      src/main/java/com/mes/ui/MainFrame.java
  19. 587 0
      src/main/java/com/mes/ui/StationPanel.java
  20. 72 0
      src/main/java/com/mes/ui/StatusLight.java
  21. 225 0
      src/main/java/com/mes/ui/UiTheme.java
  22. 117 0
      src/main/java/com/mes/ui/WorkRecordPanel.java
  23. 89 0
      src/main/java/com/mes/util/SingleInstanceLock.java
  24. 47 0
      src/main/java/com/mes/util/UiImages.java
  25. 30 0
      src/main/resources/config/application.yml
  26. BIN
      src/main/resources/images/background.png
  27. BIN
      src/main/resources/images/close_bt.png
  28. BIN
      src/main/resources/images/icon.ico
  29. BIN
      src/main/resources/images/icons/a_side.png
  30. BIN
      src/main/resources/images/icons/b_side.png
  31. BIN
      src/main/resources/images/icons/bar_add.png
  32. BIN
      src/main/resources/images/icons/bar_bookmark.png
  33. BIN
      src/main/resources/images/icons/bar_cmd_go.png
  34. BIN
      src/main/resources/images/icons/bar_edit.png
  35. BIN
      src/main/resources/images/icons/bar_pause.png
  36. BIN
      src/main/resources/images/icons/bar_sampling.png
  37. BIN
      src/main/resources/images/icons/bar_setting.png
  38. BIN
      src/main/resources/images/icons/bar_stop.png
  39. BIN
      src/main/resources/images/icons/close_bt.png
  40. BIN
      src/main/resources/images/icons/company_setting_logo.png
  41. BIN
      src/main/resources/images/icons/delete.png
  42. BIN
      src/main/resources/images/icons/department_setting_logo.png
  43. BIN
      src/main/resources/images/icons/download.png
  44. BIN
      src/main/resources/images/icons/equipment_setting_logo.png
  45. BIN
      src/main/resources/images/icons/gj_001_1_20.png
  46. BIN
      src/main/resources/images/icons/gj_001_21_40.png
  47. BIN
      src/main/resources/images/icons/gj_001_41_60.png
  48. BIN
      src/main/resources/images/icons/green_dot.png
  49. BIN
      src/main/resources/images/icons/grey_dot.png
  50. BIN
      src/main/resources/images/icons/icon.png
  51. BIN
      src/main/resources/images/icons/inductance_logo.png
  52. BIN
      src/main/resources/images/icons/insulation_logo.png
  53. BIN
      src/main/resources/images/icons/login.png
  54. BIN
      src/main/resources/images/icons/logo.png
  55. BIN
      src/main/resources/images/icons/logoff.png
  56. BIN
      src/main/resources/images/icons/menu_data_analysis.png
  57. BIN
      src/main/resources/images/icons/menu_data_preprocess.png
  58. BIN
      src/main/resources/images/icons/menu_file.png
  59. BIN
      src/main/resources/images/icons/menu_setting.png
  60. BIN
      src/main/resources/images/icons/min_bt.png
  61. BIN
      src/main/resources/images/icons/ng_bg.png
  62. BIN
      src/main/resources/images/icons/ok_bg.png
  63. BIN
      src/main/resources/images/icons/open_file.png
  64. BIN
      src/main/resources/images/icons/refresh.png
  65. BIN
      src/main/resources/images/icons/reset_logo.png
  66. BIN
      src/main/resources/images/icons/resistance_logo.png
  67. BIN
      src/main/resources/images/icons/save_bg.png
  68. BIN
      src/main/resources/images/icons/scan_barcode.png
  69. BIN
      src/main/resources/images/icons/tree_folder_icon.png
  70. BIN
      src/main/resources/images/icons/tree_leaf_icon.png
  71. BIN
      src/main/resources/images/icons/user.png
  72. BIN
      src/main/resources/images/icons/vertical_line.png
  73. BIN
      src/main/resources/images/icons/zoom_in.png
  74. BIN
      src/main/resources/images/icons/zoom_out.png
  75. BIN
      src/main/resources/images/info_bt.png
  76. BIN
      src/main/resources/images/min_bt.png
  77. 44 0
      src/main/resources/logback.xml

+ 22 - 0
.gitignore

@@ -0,0 +1,22 @@
+# IDE
+.idea
+*.iml
+.vscode
+
+# Eclipse(已弃用,禁止再提交)
+.classpath
+.project
+.settings
+bin
+classes
+
+# Maven / 构建
+target
+out
+
+# 运行时
+*.db
+.lock
+
+# 资源目录杂项(原 image/.gitignore)
+_system~.ini

BIN
lib/iot-communication-1.4.4.jar


+ 5 - 0
pack/build-exe.bat

@@ -0,0 +1,5 @@
+@echo off
+chcp 65001 >nul
+cd /d "%~dp0\.."
+powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0..\..\tools\mesclient-pack\build-exe.ps1" -ProjectDir "%cd%" %*
+if errorlevel 1 pause

+ 6 - 0
pack/build-exe.ps1

@@ -0,0 +1,6 @@
+# 转发到仓库通用打包脚本(封面/Launch4j 共用)
+$here = $PSScriptRoot
+$proj = Split-Path -Parent $here
+$shared = Join-Path (Split-Path -Parent $proj) 'tools\mesclient-pack\build-exe.ps1'
+if (-not (Test-Path $shared)) { throw "找不到通用脚本: $shared" }
+& $shared -ProjectDir $proj @args

BIN
pack/icon.ico


+ 64 - 0
pom.xml

@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.7.18</version>
+        <relativePath/>
+    </parent>
+
+    <groupId>com.mes</groupId>
+    <artifactId>mesclient-dachong</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <name>mesclient-dachong</name>
+    <description>MES 大冲工控机桌面客户端(Swing + Spring Boot 启动壳)</description>
+    <packaging>jar</packaging>
+
+    <properties>
+        <java.version>1.8</java.version>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <maven.compiler.target>1.8</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba.fastjson2</groupId>
+            <artifactId>fastjson2</artifactId>
+            <version>2.0.16</version>
+        </dependency>
+        <!-- S7 PLC:大冲 DcPlcClient -->
+        <dependency>
+            <groupId>com.github.xingshuangs</groupId>
+            <artifactId>iot-communication</artifactId>
+            <version>1.4.4</version>
+            <scope>system</scope>
+            <systemPath>${project.basedir}/lib/iot-communication-1.4.4.jar</systemPath>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <mainClass>com.mes.MesClientApplication</mainClass>
+                    <includeSystemScope>true</includeSystemScope>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 59 - 0
src/main/java/com/mes/MesClientApplication.java

@@ -0,0 +1,59 @@
+package com.mes;
+
+import java.util.concurrent.CountDownLatch;
+
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+import com.mes.config.MesClientProperties;
+import com.mes.ui.MainFrame;
+
+/**
+ * 大冲工控机启动入口(Swing 桌面,非 Web)。
+ * 配置读 {@code config/application.yml} 的 {@code mes.*}。
+ */
+@SpringBootApplication
+@EnableConfigurationProperties(MesClientProperties.class)
+public class MesClientApplication {
+
+	public static void main(String[] args) {
+		// Swing 必须非 headless,否则无法弹窗
+		System.setProperty("java.awt.headless", "false");
+		new SpringApplicationBuilder(MesClientApplication.class)
+				.web(WebApplicationType.NONE)
+				.headless(false)
+				.run(args);
+	}
+
+	/**
+	 * 容器就绪后:先应用 yml 配置,再拉起 Swing;闩锁防止无 Web 进程提前退出。
+	 */
+	@Component
+	public static class SwingBootstrap implements ApplicationRunner {
+
+		private final MesClientProperties mesClientProperties;
+
+		public SwingBootstrap(MesClientProperties mesClientProperties) {
+			this.mesClientProperties = mesClientProperties;
+		}
+
+		@Override
+		public void run(ApplicationArguments args) throws Exception {
+			// 将 yml 中的 mes.* 写入 MainFrame 静态字段
+			MainFrame.applyConfig(mesClientProperties);
+			boolean started = MainFrame.launch();
+			if (!started) {
+				// 单实例冲突:不能再 await,否则进程无窗口挂死
+				System.exit(0);
+				return;
+			}
+			// 无 Web 时挡住主线程,避免 Spring 结束过早;窗口 System.exit 时进程结束
+			new CountDownLatch(1).await();
+		}
+	}
+}

+ 133 - 0
src/main/java/com/mes/config/MesClientProperties.java

@@ -0,0 +1,133 @@
+package com.mes.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 自动化大冲工控机配置,对应 application.yml 中 {@code mes.*}。
+ */
+@ConfigurationProperties(prefix = "mes")
+public class MesClientProperties {
+
+	/** 窗口标题 */
+	private String appTitle = "MES 自动化大冲";
+	/** MES 服务器 IP(上传接口后续再接) */
+	private String serverIp = "";
+	/** 刷新周期毫秒 */
+	private int tickMs = 500;
+	/**
+	 * 结案小票连接的系统打印机名称;空则用 Windows 默认打印机。
+	 */
+	private String printerName = "";
+	/** 工位列表(一般一条线体一个站) */
+	private List<StationConfig> stations = new ArrayList<StationConfig>();
+
+	/**
+	 * 单线体/工位:批次 → MES允许=true → 轮询读 DB260 → 本批做完允许=false → 打印。
+	 */
+	public static class StationConfig {
+		private int id = 1;
+		/** 工位编码 */
+		private String stationSn = "DC01";
+		/** PLC IP */
+		private String plcIp = "";
+		/** S7 端口,默认 102 */
+		private int plcPort = 102;
+		/**
+		 * MES 允许运行 BOOL 地址(点表暂缺;有了再填)。
+		 */
+		private String mesAllowAddr = "";
+		/** Tab 显示名 */
+		private String title = "自动化大冲";
+
+		public int getId() {
+			return id;
+		}
+
+		public void setId(int id) {
+			this.id = id;
+		}
+
+		public String getStationSn() {
+			return stationSn;
+		}
+
+		public void setStationSn(String stationSn) {
+			this.stationSn = stationSn;
+		}
+
+		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 getMesAllowAddr() {
+			return mesAllowAddr;
+		}
+
+		public void setMesAllowAddr(String mesAllowAddr) {
+			this.mesAllowAddr = mesAllowAddr;
+		}
+
+		public String getTitle() {
+			return title;
+		}
+
+		public void setTitle(String title) {
+			this.title = title;
+		}
+	}
+
+	public String getAppTitle() {
+		return appTitle;
+	}
+
+	public void setAppTitle(String appTitle) {
+		this.appTitle = appTitle;
+	}
+
+	public String getServerIp() {
+		return serverIp;
+	}
+
+	public void setServerIp(String serverIp) {
+		this.serverIp = serverIp;
+	}
+
+	public int getTickMs() {
+		return tickMs;
+	}
+
+	public void setTickMs(int tickMs) {
+		this.tickMs = tickMs;
+	}
+
+	public String getPrinterName() {
+		return printerName;
+	}
+
+	public void setPrinterName(String printerName) {
+		this.printerName = printerName;
+	}
+
+	public List<StationConfig> getStations() {
+		return stations;
+	}
+
+	public void setStations(List<StationConfig> stations) {
+		this.stations = stations;
+	}
+}

+ 28 - 0
src/main/java/com/mes/entity/DcRunSnapshot.java

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

+ 29 - 0
src/main/java/com/mes/entity/DcWorkRecord.java

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

+ 113 - 0
src/main/java/com/mes/service/DcBatchPrinter.java

@@ -0,0 +1,113 @@
+package com.mes.service;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.print.PrintService;
+import javax.print.PrintServiceLookup;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.print.PageFormat;
+import java.awt.print.Printable;
+import java.awt.print.PrinterException;
+import java.awt.print.PrinterJob;
+
+/**
+ * 批次结案小票:连接系统打印机,打印包装码、生产时间、本批数量。
+ * 打印机名由 yml {@code mes.printer-name} 指定;空则用系统默认打印机。
+ */
+public final class DcBatchPrinter {
+
+	private static final Logger log = LoggerFactory.getLogger(DcBatchPrinter.class);
+
+	/** 目标打印机名称(空=默认打印机) */
+	private static volatile String printerName = "";
+
+	private DcBatchPrinter() {
+	}
+
+	/** 启动时注入配置的打印机名 */
+	public static void setPrinterName(String name) {
+		printerName = name == null ? "" : name.trim();
+	}
+
+	/**
+	 * 连接打印机并送打包装码小票。
+	 *
+	 * @param packCode 包装码(年月日+6位随机)
+	 * @param produceTime 生产时间文案 yyyy-MM-dd HH:mm:ss
+	 * @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();
+		try {
+			PrintService service = resolvePrinter();
+			if (service == null) {
+				log.warn("未找到可用打印机(printer-name={}),跳过打印 pack={}", printerName, code);
+				return false;
+			}
+			PrinterJob job = PrinterJob.getPrinterJob();
+			job.setPrintService(service);
+			job.setJobName("DC-PACK-" + code);
+			job.setPrintable(new Printable() {
+				@Override
+				public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) {
+					if (pageIndex > 0) {
+						return NO_SUCH_PAGE;
+					}
+					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);
+					return PAGE_EXISTS;
+				}
+			});
+			job.print();
+			log.info("已连接打印机[{}] 送打 pack={} qty={} time={}",
+					service.getName(), code, Integer.valueOf(qty), time);
+			return true;
+		} catch (PrinterException e) {
+			log.warn("连接/打印失败 pack={}: {}", code, e.getMessage());
+			return false;
+		} catch (Exception e) {
+			log.warn("打印异常 pack={}: {}", code, e.getMessage());
+			return false;
+		}
+	}
+
+	/**
+	 * 按配置名查找打印机;未配名则用系统默认;都没有则返回 null。
+	 */
+	private static PrintService resolvePrinter() {
+		if (!printerName.isEmpty()) {
+			PrintService[] all = PrintServiceLookup.lookupPrintServices(null, null);
+			if (all != null) {
+				for (int i = 0; i < all.length; i++) {
+					PrintService ps = all[i];
+					if (ps != null && printerName.equalsIgnoreCase(ps.getName())) {
+						return ps;
+					}
+				}
+			}
+			log.warn("配置的打印机名未找到: {},已枚举系统打印机数={}",
+					printerName, Integer.valueOf(all == null ? 0 : all.length));
+			return null;
+		}
+		PrintService def = PrintServiceLookup.lookupDefaultPrintService();
+		if (def == null) {
+			log.warn("系统无默认打印机");
+		}
+		return def;
+	}
+}

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

@@ -0,0 +1,24 @@
+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));
+	}
+}

+ 204 - 0
src/main/java/com/mes/service/DcPlcClient.java

@@ -0,0 +1,204 @@
+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.entity.DcRunSnapshot;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 自动化大冲 S7 客户端:写 MES 允许运行;轮询读 DB260 过程参数码。
+ * 断线后指数退避重连:2s→4s→8s→16s→30s。
+ */
+public class DcPlcClient {
+
+	private static final Logger log = LoggerFactory.getLogger(DcPlcClient.class);
+
+	private static final long RETRY_INITIAL_MS = 2L * 1000L;
+	private static final long RETRY_MAX_MS = 30L * 1000L;
+
+	private final String stationSn;
+	private final String plcIp;
+	private final int plcPort;
+	/** MES 允许运行 BOOL,空则只打日志不写 PLC */
+	private final String mesAllowAddr;
+
+	private S7PLC plc;
+	private volatile boolean connected;
+	private volatile long nextRetryAtMs;
+	private volatile long currentRetryDelayMs = RETRY_INITIAL_MS;
+
+	public DcPlcClient(String stationSn, String plcIp, int plcPort, String mesAllowAddr) {
+		this.stationSn = stationSn == null ? "" : stationSn.trim();
+		this.plcIp = plcIp == null ? "" : plcIp.trim();
+		this.plcPort = plcPort <= 0 ? 102 : plcPort;
+		this.mesAllowAddr = mesAllowAddr == null ? "" : mesAllowAddr.trim();
+	}
+
+	public String getStationSn() {
+		return stationSn;
+	}
+
+	public String getPlcIp() {
+		return plcIp;
+	}
+
+	public int getPlcPort() {
+		return plcPort;
+	}
+
+	public String getMesAllowAddr() {
+		return mesAllowAddr;
+	}
+
+	public boolean isConnected() {
+		return connected && plc != null;
+	}
+
+	/**
+	 * tick 调用:未连接时按指数退避自动重连(2s→4s→8s→16s→30s)。
+	 * 已连接则直接返回,不探活。
+	 */
+	public void maintainConnection() {
+		if (isConnected()) {
+			return;
+		}
+		connect();
+	}
+
+	/**
+	 * 连接并轻量读实际产量探活。
+	 * 失败 / IP 未配只记日志并指数退避,避免 500ms tick 狂刷 WARN。
+	 */
+	public synchronized void connect() {
+		if (isConnected()) {
+			return;
+		}
+		long now = System.currentTimeMillis();
+		if (now < nextRetryAtMs) {
+			return;
+		}
+		if (plcIp.isEmpty()) {
+			connected = false;
+			long waitSec = scheduleRetryAfterFailure() / 1000L;
+			log.warn("工位[{}] PLC IP 未配置,跳过连接({}s 后再试)", stationSn, Long.valueOf(waitSec));
+			return;
+		}
+		try {
+			plc = new S7PLC(EPlcType.S1200, plcIp, plcPort);
+			plc.readInt16(DcPlcPointMap.ACTUAL_QTY);
+			connected = true;
+			resetRetryBackoff();
+			log.info("工位[{}] 大冲 PLC 已连接 {}:{}(DB260)", stationSn, plcIp, Integer.valueOf(plcPort));
+		} catch (Exception e) {
+			connected = false;
+			plc = null;
+			long waitSec = scheduleRetryAfterFailure() / 1000L;
+			log.warn("工位[{}] PLC 连接失败 {}:{} — {}({}s 后再试)",
+					stationSn, plcIp, Integer.valueOf(plcPort), e.getMessage(), Long.valueOf(waitSec));
+		}
+	}
+
+	/**
+	 * 写 MES 允许运行。点未配置时返回 false(业务仍可本地走完,便于联调)。
+	 */
+	public boolean setMesAllow(boolean allow) {
+		if (mesAllowAddr.isEmpty()) {
+			log.warn("工位[{}] mes-allow-addr 未配置,跳过写 PLC allow={}", stationSn, Boolean.valueOf(allow));
+			return false;
+		}
+		return writeBoolean(mesAllowAddr, allow);
+	}
+
+	/**
+	 * 轮询读一整包 DB260 参数码:当前/下一零件、产量、状态、节拍、停机。
+	 */
+	public DcRunSnapshot readSnapshot() {
+		DcRunSnapshot s = new DcRunSnapshot();
+		if (!ensurePlc()) {
+			return s;
+		}
+		try {
+			s.currentPart = nvl(plc.readString(DcPlcPointMap.CURRENT_PART));
+			s.nextPart = nvl(plc.readString(DcPlcPointMap.NEXT_PART));
+			s.actualQty = plc.readInt16(DcPlcPointMap.ACTUAL_QTY);
+			s.lineState = plc.readInt16(DcPlcPointMap.LINE_STATE);
+			s.lineStateText = DcPlcPointMap.lineStateText(s.lineState);
+			s.takt = plc.readFloat32(DcPlcPointMap.TAKT);
+			s.downtime = plc.readInt16(DcPlcPointMap.DOWNTIME);
+		} catch (Exception e) {
+			log.warn("工位[{}] 读 DB260 失败: {}", stationSn, e.getMessage());
+			markDisconnectedAndResetBackoff();
+		}
+		return s;
+	}
+
+	/** 仅读累计实际产量;失败返回 null */
+	public Integer readActualQty() {
+		if (!ensurePlc()) {
+			return null;
+		}
+		try {
+			return Integer.valueOf(plc.readInt16(DcPlcPointMap.ACTUAL_QTY));
+		} catch (Exception e) {
+			markDisconnectedAndResetBackoff();
+			return null;
+		}
+	}
+
+	private boolean ensurePlc() {
+		if (isConnected()) {
+			return true;
+		}
+		connect();
+		return isConnected();
+	}
+
+	private boolean writeBoolean(String addr, boolean value) {
+		if (isBlank(addr) || !ensurePlc() || plc == null) {
+			return false;
+		}
+		try {
+			plc.writeBoolean(addr, value);
+			return true;
+		} catch (Exception e) {
+			log.warn("工位[{}] 写 {}={} 失败: {}", stationSn, addr, Boolean.valueOf(value), e.getMessage());
+			markDisconnectedAndResetBackoff();
+			return false;
+		}
+	}
+
+	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();
+	}
+}

+ 39 - 0
src/main/java/com/mes/service/DcPlcPointMap.java

@@ -0,0 +1,39 @@
+package com.mes.service;
+
+/**
+ * 自动化大冲线体点表(S7,DB260):当前/下一零件名、实际产量、停机、产线状态、节拍。
+ * MES 允许运行偏移由 yml {@code mes-allow-addr} 配置。
+ */
+public final class DcPlcPointMap {
+
+	/** 当前零件名称 STRING,字节偏移 0 */
+	public static final String CURRENT_PART = "DB260.0";
+	/** 下一零件名称 STRING,字节偏移 120 */
+	public static final String NEXT_PART = "DB260.120";
+	/** 实际产量 INT */
+	public static final String ACTUAL_QTY = "DB260.26";
+	/** 产线状态 INT:0/1 待机,2 正常,3 故障 */
+	public static final String LINE_STATE = "DB260.30";
+	/** 生产节拍 REAL(界面/上传按 double) */
+	public static final String TAKT = "DB260.32";
+	/** 停机时间 INT */
+	public static final String DOWNTIME = "DB260.68";
+
+	private DcPlcPointMap() {
+	}
+
+	/** 产线状态文案 */
+	public static String lineStateText(int state) {
+		switch (state) {
+		case 2:
+			return "正常";
+		case 3:
+			return "故障";
+		case 0:
+		case 1:
+			return "待机";
+		default:
+			return "未知(" + state + ")";
+		}
+	}
+}

+ 44 - 0
src/main/java/com/mes/service/DcWorkRecordStore.java

@@ -0,0 +1,44 @@
+package com.mes.service;
+
+import com.mes.entity.DcWorkRecord;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * 大冲本机工作记录内存库:结案写入,工作记录页读取。
+ * 服务端查询接口后续再接。
+ */
+public final class DcWorkRecordStore {
+
+	private static final List<DcWorkRecord> RECORDS =
+			Collections.synchronizedList(new ArrayList<DcWorkRecord>());
+
+	private 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 List<DcWorkRecord> list() {
+		synchronized (RECORDS) {
+			return new ArrayList<DcWorkRecord>(RECORDS);
+		}
+	}
+
+	public static int size() {
+		return RECORDS.size();
+	}
+}

+ 87 - 0
src/main/java/com/mes/service/MesApiClient.java

@@ -0,0 +1,87 @@
+package com.mes.service;
+
+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.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * 通用 form-urlencoded POST;大冲业务请求走 {@link MesDcApiClient}。
+ */
+public final class MesApiClient {
+
+	private static final Logger log = LoggerFactory.getLogger(MesApiClient.class);
+
+	private MesApiClient() {
+	}
+
+	/**
+	 * form-urlencoded POST;显式 UTF-8,避免打包 exe 后默认 GBK 导致中文乱码。
+	 */
+	public static String doPost(String httpUrl, String param) {
+		HttpURLConnection connection = null;
+		InputStream is = null;
+		OutputStream os = null;
+		BufferedReader br = null;
+		String result = null;
+		try {
+			URL url = new URL(httpUrl);
+			connection = (HttpURLConnection) url.openConnection();
+			connection.setRequestMethod("POST");
+			connection.setConnectTimeout(15000);
+			connection.setReadTimeout(60000);
+			connection.setDoOutput(true);
+			connection.setDoInput(true);
+			connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
+			os = connection.getOutputStream();
+			os.write(param.getBytes("UTF-8"));
+			if (connection.getResponseCode() == 200) {
+				is = connection.getInputStream();
+				br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+				StringBuffer sbf = new StringBuffer();
+				String temp;
+				while ((temp = br.readLine()) != null) {
+					sbf.append(temp);
+					sbf.append("\r\n");
+				}
+				result = sbf.toString();
+			} else {
+				log.warn("HTTP {} => {}", httpUrl, connection.getResponseCode());
+			}
+		} catch (MalformedURLException e) {
+			log.error("URL 非法: {}", httpUrl, e);
+		} catch (IOException e) {
+			log.error("POST 失败: {}", httpUrl, e);
+		} 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();
+			}
+		}
+		return result;
+	}
+}

+ 117 - 0
src/main/java/com/mes/service/MesDcApiClient.java

@@ -0,0 +1,117 @@
+package com.mes.service;
+
+import com.alibaba.fastjson2.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * 自动化大冲工控机 HTTP:取批次 / 结案一次上传(包装码+过程参数,非弧焊采样堆)。
+ */
+public final class MesDcApiClient {
+
+	private static final Logger log = LoggerFactory.getLogger(MesDcApiClient.class);
+
+	private MesDcApiClient() {
+	}
+
+	/**
+	 * 取本工位待开批次(PDA 已扫码入通用队列)。
+	 * 路径:{@code /js/a/mes/mesFlexDc/nextBatch};期望 data:batchCode、targetQty。
+	 */
+	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);
+	}
+
+	/**
+	 * 批次结案一次上报:包装码 + 过程参数(落 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);
+	}
+
+	public static boolean isSuccess(JSONObject result) {
+		if (result == null) {
+			return false;
+		}
+		Object r = result.get("result");
+		return r != null && "true".equalsIgnoreCase(String.valueOf(r).trim());
+	}
+
+	public static String messageOf(JSONObject result) {
+		if (result == null) {
+			return "请求失败或无响应(服务端接口可能未上线)";
+		}
+		String m = result.getString("message");
+		return m == null || m.isEmpty() ? "失败" : m;
+	}
+
+	public static String dataStr(JSONObject result, String key) {
+		if (result == null || key == null) {
+			return "";
+		}
+		JSONObject data = result.getJSONObject("data");
+		if (data == null) {
+			return nvl(result.getString(key));
+		}
+		return nvl(data.getString(key));
+	}
+
+	public static int dataInt(JSONObject result, String key, int def) {
+		if (result == null || key == null) {
+			return def;
+		}
+		JSONObject data = result.getJSONObject("data");
+		Object raw = data != null ? data.get(key) : result.get(key);
+		if (raw == null) {
+			return def;
+		}
+		try {
+			return Integer.parseInt(String.valueOf(raw).trim());
+		} catch (Exception e) {
+			return def;
+		}
+	}
+
+	private static JSONObject post(String serverIp, String path, Map<String, String> fields) {
+		try {
+			String url = "http://" + nvl(serverIp) + ":8980" + path;
+			String body = toForm(fields);
+			log.debug("dc POST {} body={}", path, body);
+			String raw = MesApiClient.doPost(url, body);
+			if (raw == null || raw.isEmpty() || "false".equalsIgnoreCase(raw.trim())) {
+				return null;
+			}
+			return JSONObject.parseObject(raw);
+		} catch (Exception e) {
+			log.debug("dc 请求异常 path={} err={}", path, e.getMessage());
+			return null;
+		}
+	}
+
+	private static String toForm(Map<String, String> fields) throws UnsupportedEncodingException {
+		StringBuilder sb = new StringBuilder();
+		sb.append("__ajax=json");
+		if (fields != null) {
+			for (Map.Entry<String, String> e : fields.entrySet()) {
+				if (e.getKey() == null) {
+					continue;
+				}
+				sb.append('&').append(URLEncoder.encode(e.getKey(), "UTF-8"));
+				sb.append('=').append(URLEncoder.encode(nvl(e.getValue()), "UTF-8"));
+			}
+		}
+		return sb.toString();
+	}
+
+	private static String nvl(String s) {
+		return s == null ? "" : s.trim();
+	}
+}

+ 318 - 0
src/main/java/com/mes/ui/MainFrame.java

@@ -0,0 +1,318 @@
+package com.mes.ui;
+
+import com.mes.config.MesClientProperties;
+import com.mes.service.DcBatchPrinter;
+import com.mes.util.SingleInstanceLock;
+import com.mes.util.UiImages;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.*;
+import javax.swing.border.EmptyBorder;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * 自动化大冲工控机主窗:扫批次 → MES允许 → 产量差达标 → 关允许 → 打印。
+ */
+public class MainFrame extends JFrame {
+
+	public static final Logger log = LoggerFactory.getLogger(MainFrame.class);
+
+	public static MainFrame mesClientFrame;
+
+	public static String mes_server_ip = "";
+	public static String mes_app_title = "MES 自动化大冲";
+
+	private static MesClientProperties props;
+	private static final List<StationPanel> stationPanels = new ArrayList<StationPanel>();
+	/** 工作记录页(结案后刷新) */
+	private static WorkRecordPanel workRecordPanel;
+	private static Timer tickTimer;
+	private static final AtomicBoolean exiting = new AtomicBoolean(false);
+	private static JLabel menuStatus;
+
+	public static boolean launch() {
+		if (SingleInstanceLock.getInstance().isAppActive()) {
+			log.warn("已有客户端实例在运行,本次启动取消");
+			return false;
+		}
+		EventQueue.invokeLater(new Runnable() {
+			@Override
+			public void run() {
+				try {
+					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());
+								}
+							}
+							startTickTimer();
+						}
+					}, "dc-plc-init").start();
+				} catch (Exception e) {
+					log.error("启动主界面失败", e);
+				}
+			}
+		});
+		return true;
+	}
+
+	public static void applyConfig(MesClientProperties p) {
+		if (p == null) {
+			throw new IllegalStateException("MesClientProperties 为空,请检查 application.yml 中 mes 配置");
+		}
+		props = p;
+		mes_server_ip = trim(p.getServerIp());
+		mes_app_title = trim(p.getAppTitle());
+		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());
+			for (MesClientProperties.StationConfig s : list) {
+				log.info("工位 sn={} plc={}:{} allow={}",
+						s.getStationSn(), s.getPlcIp(), Integer.valueOf(s.getPlcPort()),
+						s.getMesAllowAddr());
+			}
+		}
+	}
+
+	/** 状态栏文案:level&lt;0 偏红提示 */
+	public static void setMenuStatus(final String text, final int level) {
+		SwingUtilities.invokeLater(new Runnable() {
+			@Override
+			public void run() {
+				if (menuStatus == null) {
+					return;
+				}
+				menuStatus.setText(text == null ? "" : text);
+				if (level < 0) {
+					menuStatus.setForeground(new Color(220, 80, 80));
+				} else {
+					menuStatus.setForeground(new Color(180, 220, 230));
+				}
+			}
+		});
+	}
+
+	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);
+		setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
+		addWindowListener(new WindowAdapter() {
+			@Override
+			public void windowClosing(WindowEvent e) {
+				if (exiting.get()) {
+					return;
+				}
+				int choice = JOptionPane.showConfirmDialog(MainFrame.this, "确定退出?", "关闭确认",
+						JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
+				if (choice != JOptionPane.YES_OPTION) {
+					return;
+				}
+				if (!exiting.compareAndSet(false, true)) {
+					return;
+				}
+				setVisible(false);
+				dispose();
+				new Thread(new Runnable() {
+					@Override
+					public void run() {
+						try {
+							stopTickTimer();
+						} catch (Throwable t) {
+							log.warn("退出清理异常: {}", t.getMessage());
+						} finally {
+							System.exit(0);
+						}
+					}
+				}, "mes-client-exit").start();
+			}
+		});
+
+		// 去掉系统菜单栏(Nimbus 渐变很丑);退出走窗口关闭;状态条隐藏仅给 setMenuStatus 用
+		menuStatus = new JLabel("就绪");
+		menuStatus.setVisible(false);
+
+		JPanel content = new JPanel(new BorderLayout(0, 0));
+		content.setBorder(new EmptyBorder(0, 0, 0, 0));
+		content.setBackground(UiTheme.BG);
+		setContentPane(content);
+
+		stationPanels.clear();
+		List<MesClientProperties.StationConfig> stations =
+				props == null ? null : props.getStations();
+		if (stations == null || stations.isEmpty()) {
+			JLabel empty = new JLabel("请在 application.yml 配置 mes.stations", SwingConstants.CENTER);
+			empty.setFont(new Font("微软雅黑", Font.PLAIN, 18));
+			content.add(empty, BorderLayout.CENTER);
+			return;
+		}
+
+		StationPanel workPanel = null;
+		for (MesClientProperties.StationConfig sc : stations) {
+			workPanel = new StationPanel(sc, mes_server_ip);
+			stationPanels.add(workPanel);
+			break;
+		}
+		workRecordPanel = new WorkRecordPanel();
+
+		// CardLayout 切换页面;顶栏自绘导航,避免 Nimbus 页签 + 外挂按钮错位难看
+		final JPanel cards = new JPanel(new CardLayout());
+		cards.setOpaque(false);
+		cards.add(workPanel, "work");
+		cards.add(workRecordPanel, "record");
+
+		final JButton btnSettings = navBtn("设置", false);
+		final JButton btnWork = navBtn("工作面板", true);
+		final JButton btnRecord = navBtn("工作记录", false);
+
+		final JPopupMenu settingsMenu = new JPopupMenu();
+		JMenuItem miManual = new JMenuItem("手动提交");
+		miManual.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+		miManual.addActionListener(new ActionListener() {
+			@Override
+			public void actionPerformed(ActionEvent e) {
+				if (!stationPanels.isEmpty()) {
+					stationPanels.get(0).onManualSubmitClick();
+				}
+			}
+		});
+		settingsMenu.add(miManual);
+		btnSettings.addActionListener(new ActionListener() {
+			@Override
+			public void actionPerformed(ActionEvent e) {
+				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);
+			}
+		});
+		btnRecord.addActionListener(new ActionListener() {
+			@Override
+			public void actionPerformed(ActionEvent e) {
+				((CardLayout) cards.getLayout()).show(cards, "record");
+				styleNavSelected(btnWork, false);
+				styleNavSelected(btnRecord, true);
+			}
+		});
+
+		JPanel nav = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
+		nav.setOpaque(true);
+		nav.setBackground(UiTheme.BG);
+		nav.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UiTheme.LINE));
+		nav.add(btnSettings);
+		nav.add(btnWork);
+		nav.add(btnRecord);
+
+		JPanel page = new JPanel(new BorderLayout(0, 0));
+		page.setOpaque(false);
+		page.setBorder(new EmptyBorder(10, 12, 12, 12));
+		page.add(nav, BorderLayout.NORTH);
+		page.add(cards, BorderLayout.CENTER);
+		content.add(page, BorderLayout.CENTER);
+	}
+
+	/** 顶栏导航按钮(设置 / 工作面板 / 工作记录 统一样式) */
+	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.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+		b.setOpaque(true);
+		styleNavSelected(b, selected);
+		return b;
+	}
+
+	/** 选中:白底蓝底边;未选:浅灰 */
+	private static void styleNavSelected(JButton b, boolean selected) {
+		if (selected) {
+			b.setBackground(Color.WHITE);
+			b.setForeground(UiTheme.ACCENT);
+			b.setBorder(BorderFactory.createCompoundBorder(
+					BorderFactory.createMatteBorder(0, 0, 2, 0, UiTheme.ACCENT),
+					new EmptyBorder(8, 18, 6, 18)));
+		} 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)));
+		}
+	}
+
+	/** 结案后刷新工作记录表 */
+	public static void refreshWorkRecords() {
+		SwingUtilities.invokeLater(new Runnable() {
+			@Override
+			public void run() {
+				if (workRecordPanel != null) {
+					workRecordPanel.reload();
+				}
+			}
+		});
+	}
+
+	private static void startTickTimer() {
+		stopTickTimer();
+		int period = 500;
+		if (props != null && props.getTickMs() > 0) {
+			period = props.getTickMs();
+		}
+		tickTimer = new Timer("dc-station-tick", true);
+		tickTimer.scheduleAtFixedRate(new TimerTask() {
+			@Override
+			public void run() {
+				for (StationPanel p : stationPanels) {
+					try {
+						p.tick();
+					} catch (Exception ex) {
+						log.debug("tick skip: {}", ex.getMessage());
+					}
+				}
+			}
+		}, 800L, period);
+	}
+
+	private static void stopTickTimer() {
+		if (tickTimer != null) {
+			tickTimer.cancel();
+			tickTimer = null;
+		}
+	}
+
+	private static String trim(String s) {
+		return s == null ? "" : s.trim();
+	}
+}

+ 587 - 0
src/main/java/com/mes/ui/StationPanel.java

@@ -0,0 +1,587 @@
+package com.mes.ui;
+
+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.DcPlcClient;
+import com.mes.service.DcWorkRecordStore;
+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.Arrays;
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * 自动化大冲单线面板:轮询取批次 → MES允许=true → 读 DB260 盯产量 → 结案再允许=false → 打印。
+ */
+public class StationPanel extends JPanel {
+
+	private static final Logger log = LoggerFactory.getLogger(StationPanel.class);
+
+	/** 空闲时拉取 PDA 批次的最小间隔 */
+	private static final long POLL_BATCH_INTERVAL_MS = 2000L;
+
+	/** IDLE 等 PDA;RUN 允许运行盯产量;DONE 结案过渡 */
+	public enum Phase {
+		IDLE, RUN, DONE
+	}
+
+	private final MesClientProperties.StationConfig cfg;
+	private final String serverIp;
+	private final DcPlcClient plc;
+	private final AtomicBoolean busy = new AtomicBoolean(false);
+
+	private volatile Phase phase = Phase.IDLE;
+	private volatile String batchCode = "";
+	private volatile int targetQty;
+	private volatile int baseActualQty;
+	private volatile int producedQty;
+	private volatile String batchStartTime = "";
+	private volatile long lastPollBatchAtMs;
+	/** 最近一次 DB260 快照,结案时一并上传(只传一次,不采样堆) */
+	private volatile DcRunSnapshot lastSnap = new DcRunSnapshot();
+
+	private final JLabel lblStation;
+	/** 顶栏 PLC 地址文案(不含连接状态) */
+	private final JLabel lblPlc;
+	private final JLabel lblStatus;
+	private final JTextField txtBatch;
+	private final JTextField txtTarget;
+	private final JTextField txtCurrentPart;
+	private final JTextField txtNextPart;
+	private final JTextField txtActualQty;
+	private final JTextField txtProduced;
+	private final JTextField txtDowntime;
+	private final JTextField txtTakt;
+	/** PLC 连接指示灯:绿=已连,红=未连 */
+	private final StatusLight lampPlc;
+	/** PLC 连接状态说明 */
+	private final JLabel lblPlcState;
+	/** 产线状态指示灯:绿=正常,灰=待机,红=故障 */
+	private final StatusLight lampLineState;
+	/** 产线状态说明 */
+	private final JLabel lblLineState;
+	/** MES 允许运行指示灯:绿=已开,灰=关 */
+	private final StatusLight lampMesAllow;
+	/** MES 允许状态说明 */
+	private final JLabel lblMesAllowState;
+
+	public StationPanel(MesClientProperties.StationConfig cfg, String serverIp) {
+		this.cfg = cfg;
+		this.serverIp = serverIp == null ? "" : serverIp.trim();
+		this.plc = new DcPlcClient(cfg.getStationSn(), cfg.getPlcIp(), cfg.getPlcPort(),
+				cfg.getMesAllowAddr());
+
+		setLayout(new BorderLayout(0, 0));
+		setBackground(UiTheme.BG);
+		setBorder(new EmptyBorder(0, 0, 0, 0));
+
+		String titleText = nvl(cfg.getTitle());
+		if (titleText.isEmpty()) {
+			titleText = "自动化大冲";
+		}
+
+		JPanel header = UiTheme.gradientHeader();
+		header.setBorder(new EmptyBorder(16, 20, 16, 20));
+		lblStation = new JLabel(titleText);
+		lblStation.setFont(UiTheme.FONT_TITLE);
+		lblStation.setForeground(Color.WHITE);
+		// Consolas 不支持中文,副标题只用工位编码,避免乱码方框
+		JLabel lblCode = new JLabel(nvl(cfg.getStationSn()));
+		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(lblStation);
+		titleCol.add(Box.createVerticalStrut(3));
+		titleCol.add(lblCode);
+
+		lampPlc = new StatusLight();
+		lblPlcState = headerStateLabel("未连接");
+		lampLineState = new StatusLight();
+		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);
+		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);
+
+		// 状态条紧贴顶栏下方,一眼能看到当前阶段
+		lblStatus = new JLabel("空闲:等待扫码下发批次…");
+		lblStatus.setFont(UiTheme.FONT_BODY);
+		lblStatus.setOpaque(true);
+		lblStatus.setBackground(UiTheme.OK_BG);
+		lblStatus.setForeground(UiTheme.OK_FG);
+		lblStatus.setBorder(new EmptyBorder(9, 16, 9, 16));
+
+		JPanel north = new JPanel(new BorderLayout(0, 0));
+		north.setOpaque(false);
+		north.add(header, BorderLayout.NORTH);
+		north.add(lblStatus, BorderLayout.SOUTH);
+		add(north, BorderLayout.NORTH);
+
+		JPanel main = new JPanel(new BorderLayout(0, 14));
+		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));
+		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));
+		grid.setOpaque(false);
+		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));
+		grid.add(UiTheme.paramTile("停机时间", txtDowntime, UiTheme.STRIPE_SIDE));
+		grid.add(UiTheme.paramTile("生产节拍", txtTakt, UiTheme.STRIPE_SIDE));
+		runCard.add(grid, BorderLayout.CENTER);
+
+		main.add(batchCard, BorderLayout.NORTH);
+		main.add(runCard, BorderLayout.CENTER);
+		add(main, BorderLayout.CENTER);
+	}
+
+	public String getStationSn() {
+		return nvl(cfg.getStationSn());
+	}
+
+	/** 单设备客户端:页签名固定为工作面板 */
+	public String tabTitle() {
+		return "工作面板";
+	}
+
+	public void initPlc() {
+		plc.connect();
+		uiPlcLabel();
+		refreshSnapshotUi(plc.readSnapshot());
+	}
+
+	/**
+	 * 周期:重连、刷 DB260;空闲拉 PDA 批次;RUN 算产量差达标结案。
+	 */
+	public void tick() {
+		if (busy.get()) {
+			return;
+		}
+		try {
+			plc.maintainConnection();
+			uiPlcLabel();
+			DcRunSnapshot snap = plc.readSnapshot();
+			if (snap != null) {
+				lastSnap = snap;
+			}
+			refreshSnapshotUi(snap);
+			if (phase == Phase.IDLE) {
+				pollPdaBatchIfDue();
+				return;
+			}
+			if (phase == Phase.RUN) {
+				int produced = snap.actualQty - baseActualQty;
+				if (produced < 0) {
+					produced = 0;
+				}
+				producedQty = produced;
+				setText(txtProduced, String.valueOf(producedQty));
+				setStatusUi("生产中 批次=" + batchCode + "  已产 " + producedQty + " / 目标 " + targetQty);
+				if (producedQty >= targetQty) {
+					finishBatch(producedQty, false);
+				}
+			}
+		} catch (Exception e) {
+			log.warn("工位[{}] tick 异常: {}", cfg.getStationSn(), e.getMessage());
+		}
+	}
+
+	/** 空闲:向服务端要 PDA 已扫的待开批次 */
+	private void pollPdaBatchIfDue() {
+		long now = System.currentTimeMillis();
+		if (now - lastPollBatchAtMs < POLL_BATCH_INTERVAL_MS) {
+			return;
+		}
+		lastPollBatchAtMs = now;
+		if (serverIp.isEmpty()) {
+			setStatusUi("空闲:等待扫码(server-ip 未配,仅可联调模拟)");
+			return;
+		}
+		JSONObject ret = MesDcApiClient.nextBatch(serverIp, cfg.getStationSn());
+		if (!MesDcApiClient.isSuccess(ret)) {
+			setStatusUi("空闲:等待扫码下发批次…");
+			return;
+		}
+		String code = MesDcApiClient.dataStr(ret, "batchCode");
+		if (code.isEmpty()) {
+			code = MesDcApiClient.dataStr(ret, "sn");
+		}
+		int target = MesDcApiClient.dataInt(ret, "targetQty", 0);
+		if (target <= 0) {
+			target = MesDcApiClient.dataInt(ret, "qty", 0);
+		}
+		if (code.isEmpty() || target <= 0) {
+			log.warn("工位[{}] nextBatch 成功但缺 batchCode/targetQty: {}", cfg.getStationSn(), ret);
+			return;
+		}
+		startBatchFromPda(code, target);
+	}
+
+	/**
+	 * 批次到位:记起点产量 → MES允许=true → 进入 RUN;本批做完再写 false。
+	 */
+	private void startBatchFromPda(String code, int target) {
+		if (phase == Phase.RUN) {
+			return;
+		}
+		if (!busy.compareAndSet(false, true)) {
+			return;
+		}
+		try {
+			if (!plc.isConnected()) {
+				plc.connect();
+			}
+			Integer base = plc.readActualQty();
+			if (base == null) {
+				setStatusUi("收到批次,但读实际产量失败,请检查 PLC");
+				MainFrame.setMenuStatus(cfg.getStationSn() + " 开批失败:读产量", -1);
+				return;
+			}
+			batchCode = code;
+			targetQty = target;
+			baseActualQty = base.intValue();
+			producedQty = 0;
+			batchStartTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
+			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);
+			MainFrame.setMenuStatus(cfg.getStationSn() + " 开批 " + batchCode + " 目标" + targetQty, 0);
+			log.info("工位[{}] 开批 batch={} target={} baseQty={}",
+					cfg.getStationSn(), batchCode, Integer.valueOf(targetQty), Integer.valueOf(baseActualQty));
+		} finally {
+			busy.set(false);
+		}
+	}
+
+	/**
+	 * 手动提交:校验密码 mes 后,按当前已产数量结案(过站结果 OK)。
+	 * 由主窗页签左侧「设置」菜单调用。
+	 */
+	public void onManualSubmitClick() {
+		if (phase != Phase.RUN) {
+			setStatusUi("当前无进行中的批次,无法手动提交");
+			return;
+		}
+		if (!askMesPassword()) {
+			return;
+		}
+		finishBatch(producedQty, false, true);
+	}
+
+	/**
+	 * 弹出密码框;正确密码为 mes。
+	 *
+	 * @return true=校验通过
+	 */
+	private boolean askMesPassword() {
+		JPasswordField pf = new JPasswordField(12);
+		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, "手动提交",
+				JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
+		if (opt != JOptionPane.OK_OPTION) {
+			return false;
+		}
+		char[] input = pf.getPassword();
+		boolean ok = Arrays.equals(input, "mes".toCharArray());
+		Arrays.fill(input, '\0');
+		if (!ok) {
+			JOptionPane.showMessageDialog(this, "密码错误", "手动提交", JOptionPane.WARNING_MESSAGE);
+			return false;
+		}
+		return true;
+	}
+
+	/** 产量达标结案 */
+	private void finishBatch(final int qty, final boolean aborted) {
+		finishBatch(qty, aborted, false);
+	}
+
+	/**
+	 * 结案。
+	 *
+	 * @param qty 本批数量
+	 * @param aborted 是否强制中断(结果 NG)
+	 * @param manual 是否手动提交
+	 */
+	private void finishBatch(final int qty, final boolean aborted, final boolean manual) {
+		if (!busy.compareAndSet(false, true)) {
+			return;
+		}
+		phase = Phase.DONE;
+		final String codeSnap = batchCode;
+		final String timeSnap = batchStartTime;
+		new Thread(new Runnable() {
+			@Override
+			public void run() {
+				try {
+					// 本批做完:MES允许改回 false
+					plc.setMesAllow(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>();
+					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");
+					fields.put("manual", manual ? "1" : "0");
+					fields.put("result", passResult);
+					fields.put("currentPart", nvl(snap.currentPart));
+					fields.put("nextPart", nvl(snap.nextPart));
+					fields.put("actualQty", String.valueOf(snap.actualQty));
+					fields.put("downtime", String.valueOf(snap.downtime));
+					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() {
+						@Override
+						public void run() {
+							resetToIdle(tip);
+							MainFrame.setMenuStatus(cfg.getStationSn() + " 结案 " + packCode + " x" + qty, 0);
+						}
+					});
+					log.info("工位[{}] 结案 batch={} pack={} qty={} aborted={} manual={} printed={}",
+							cfg.getStationSn(), codeSnap, packCode, Integer.valueOf(qty),
+							Boolean.valueOf(aborted), Boolean.valueOf(manual), Boolean.valueOf(printed));
+				} finally {
+					busy.set(false);
+				}
+			}
+		}, "dc-finish-" + cfg.getStationSn()).start();
+	}
+
+	private void resetToIdle(String msg) {
+		phase = Phase.IDLE;
+		batchCode = "";
+		targetQty = 0;
+		baseActualQty = 0;
+		producedQty = 0;
+		batchStartTime = "";
+		SwingUtilities.invokeLater(new Runnable() {
+			@Override
+			public void run() {
+				setText(txtBatch, "");
+				setText(txtTarget, "");
+				setText(txtProduced, "");
+				setMesAllowLamp(false);
+				setStatusUi(msg == null || msg.isEmpty()
+						? "空闲:等待扫码下发批次…" : msg + "  → 等待下一笔");
+			}
+		});
+	}
+
+	private void refreshSnapshotUi(final DcRunSnapshot s) {
+		if (s == null) {
+			return;
+		}
+		SwingUtilities.invokeLater(new Runnable() {
+			@Override
+			public void run() {
+				setText(txtCurrentPart, s.currentPart);
+				setText(txtNextPart, s.nextPart);
+				setText(txtActualQty, String.valueOf(s.actualQty));
+				setText(txtDowntime, String.valueOf(s.downtime));
+				setText(txtTakt, String.valueOf(s.takt));
+				setLineStateLamp(s.lineState);
+				setMesAllowLamp(phase == Phase.RUN);
+			}
+		});
+	}
+
+	/**
+	 * 产线状态灯 + 说明:2 正常;3 故障;0/1 待机。
+	 */
+	private void setLineStateLamp(final int lineState) {
+		SwingUtilities.invokeLater(new Runnable() {
+			@Override
+			public void run() {
+				StatusLight.Level lv = StatusLight.Level.OFF;
+				String tip = "待机";
+				if (lineState == 2) {
+					lv = StatusLight.Level.ON;
+					tip = "正常";
+				} else if (lineState == 3) {
+					lv = StatusLight.Level.FAULT;
+					tip = "故障";
+				}
+				lampLineState.setLevel(lv);
+				lblLineState.setText(tip);
+			}
+		});
+	}
+
+	/** 刷新 MES 允许指示灯 + 说明 */
+	private void setMesAllowLamp(final boolean on) {
+		SwingUtilities.invokeLater(new Runnable() {
+			@Override
+			public void run() {
+				lampMesAllow.setOn(on);
+				lblMesAllowState.setText(on ? "开" : "关");
+			}
+		});
+	}
+
+	/** 顶栏刷新:连接灯 + 状态说明 + 地址 */
+	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 ? "已连接" : "未连接");
+			}
+		});
+	}
+
+	/** 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);
+		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 void setStatusUi(final String text) {
+		SwingUtilities.invokeLater(new Runnable() {
+			@Override
+			public void run() {
+				lblStatus.setText(text == null ? "" : text);
+				String t = text == null ? "" : text;
+				if (t.contains("失败") || t.contains("故障")) {
+					lblStatus.setBackground(UiTheme.ERR_BG);
+					lblStatus.setForeground(UiTheme.ERR_FG);
+				} else if (t.contains("生产中") || t.contains("已开") || t.contains("开批")) {
+					lblStatus.setBackground(UiTheme.RUN_BG);
+					lblStatus.setForeground(UiTheme.RUN_FG);
+				} else {
+					lblStatus.setBackground(UiTheme.OK_BG);
+					lblStatus.setForeground(UiTheme.OK_FG);
+				}
+			}
+		});
+	}
+
+	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();
+	}
+}

+ 72 - 0
src/main/java/com/mes/ui/StatusLight.java

@@ -0,0 +1,72 @@
+package com.mes.ui;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+ * 指示灯:灰 / 绿 / 红。
+ */
+public class StatusLight extends JComponent {
+
+	private static final long serialVersionUID = 1L;
+
+	private static final Color GRAY = new Color(120, 130, 140);
+	private static final Color GREEN = new Color(40, 220, 100);
+	private static final Color RED = new Color(230, 60, 50);
+
+	/** 灯色档:灭灰 / 亮绿 / 故障红 */
+	public enum Level {
+		OFF, ON, FAULT
+	}
+
+	private volatile Level level = Level.OFF;
+
+	public StatusLight() {
+		setPreferredSize(new Dimension(36, 28));
+		setMinimumSize(new Dimension(28, 24));
+		setOpaque(false);
+	}
+
+	/** 开关:true=绿,false=灰 */
+	public void setOn(boolean on) {
+		setLevel(on ? Level.ON : Level.OFF);
+	}
+
+	public boolean isOn() {
+		return level == Level.ON;
+	}
+
+	/** 设灯色档 */
+	public void setLevel(Level level) {
+		this.level = level == null ? Level.OFF : level;
+		repaint();
+	}
+
+	public Level getLevel() {
+		return level;
+	}
+
+	@Override
+	protected void paintComponent(Graphics g) {
+		super.paintComponent(g);
+		Graphics2D g2 = (Graphics2D) g.create();
+		try {
+			g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+			int w = getWidth();
+			int h = getHeight();
+			int r = Math.min(w, h) / 2 - 2;
+			int cx = w / 2;
+			int cy = h / 2;
+			Color c = GRAY;
+			if (level == Level.ON) {
+				c = GREEN;
+			} else if (level == Level.FAULT) {
+				c = RED;
+			}
+			g2.setColor(c);
+			g2.fillOval(cx - r, cy - r, r * 2, r * 2);
+		} finally {
+			g2.dispose();
+		}
+	}
+}

+ 225 - 0
src/main/java/com/mes/ui/UiTheme.java

@@ -0,0 +1,225 @@
+package com.mes.ui;
+
+import javax.swing.*;
+import javax.swing.border.Border;
+import javax.swing.border.EmptyBorder;
+import java.awt.*;
+
+/**
+ * 大冲客户端视觉主题:浅灰底 + 深蓝顶栏,字号偏大适合工控屏。
+ */
+public final class UiTheme {
+
+	private UiTheme() {
+	}
+
+	/** 页面底 */
+	public static final Color BG = new Color(236, 240, 245);
+	public static final Color CARD = Color.WHITE;
+	public static final Color LINE = new Color(210, 218, 228);
+	public static final Color TEXT = new Color(30, 41, 59);
+	public static final Color MUTED = new Color(100, 116, 139);
+
+	/** 顶栏:深蓝灰,不用发绿发紫的旧渐变 */
+	public static final Color HEADER_TOP = new Color(30, 41, 59);
+	public static final Color HEADER_BOTTOM = new Color(51, 65, 85);
+	/** 主强调:钢蓝 */
+	public static final Color ACCENT = new Color(37, 99, 235);
+	public static final Color ACCENT_DARK = new Color(29, 78, 216);
+	/** 次强调 */
+	public static final Color AMBER = new Color(217, 119, 6);
+	public static final Color AMBER_DARK = new Color(180, 95, 6);
+
+	public static final Color OK_BG = new Color(220, 252, 231);
+	public static final Color OK_FG = new Color(22, 101, 52);
+	public static final Color RUN_BG = new Color(219, 234, 254);
+	public static final Color RUN_FG = new Color(30, 64, 175);
+	public static final Color ERR_BG = new Color(254, 226, 226);
+	public static final Color ERR_FG = new Color(185, 28, 28);
+	public static final Color WARN_FG = new Color(217, 119, 6);
+
+	/** 参数格左侧色条(统一钢蓝,减少杂色) */
+	public static final Color STRIPE_SIDE = new Color(37, 99, 235);
+	public static final Color STRIPE_VOLT = STRIPE_SIDE;
+	public static final Color STRIPE_AMP = STRIPE_SIDE;
+	public static final Color STRIPE_WIRE = STRIPE_SIDE;
+	public static final Color STRIPE_JOB = STRIPE_SIDE;
+	public static final Color STRIPE_ERR = new Color(220, 38, 38);
+	public static final Color STRIPE_DEV = STRIPE_SIDE;
+
+	public static final Font FONT_TITLE = new Font("微软雅黑", Font.BOLD, 26);
+	public static final Font FONT_BODY = new Font("微软雅黑", Font.PLAIN, 18);
+	public static final Font FONT_LABEL = new Font("微软雅黑", Font.PLAIN, 16);
+	public static final Font FONT_SN = new Font("微软雅黑", Font.BOLD, 40);
+	/** 示值:工控大屏可读,铺满格子时不显空 */
+	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 void applyLookAndFeel() {
+		try {
+			for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
+				if ("Nimbus".equals(info.getName())) {
+					UIManager.setLookAndFeel(info.getClassName());
+					UIManager.put("nimbusBase", HEADER_BOTTOM);
+					UIManager.put("nimbusBlueGrey", new Color(71, 85, 105));
+					UIManager.put("control", BG);
+					UIManager.put("nimbusSelectionBackground", ACCENT);
+					UIManager.put("TabbedPane:TabbedPaneTab[Enabled].backgroundPainter", null);
+					return;
+				}
+			}
+			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+		} catch (Exception ignored) {
+		}
+	}
+
+	/** 顶栏渐变面板 */
+	public static JPanel gradientHeader() {
+		return new JPanel(new BorderLayout(16, 0)) {
+			private static final long serialVersionUID = 1L;
+
+			@Override
+			protected void paintComponent(Graphics g) {
+				Graphics2D g2 = (Graphics2D) g.create();
+				g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+				GradientPaint gp = new GradientPaint(0, 0, HEADER_TOP, 0, getHeight(), HEADER_BOTTOM);
+				g2.setPaint(gp);
+				g2.fillRect(0, 0, getWidth(), getHeight());
+				g2.setColor(ACCENT);
+				g2.fillRect(0, getHeight() - 3, getWidth(), 3);
+				g2.dispose();
+			}
+		};
+	}
+
+	public static Border cardBorder() {
+		return BorderFactory.createCompoundBorder(
+				BorderFactory.createLineBorder(LINE),
+				new EmptyBorder(12, 14, 12, 14));
+	}
+
+	public static JPanel card() {
+		JPanel p = new JPanel();
+		p.setBackground(CARD);
+		p.setBorder(cardBorder());
+		return p;
+	}
+
+	/** 带左侧色条的参数格(输入框) */
+	public static JPanel paramTile(String label, JTextField field, Color stripe) {
+		return paramTile(label, (JComponent) field, stripe);
+	}
+
+	/**
+	 * 带左侧色条的参数格:标签在上、大字示值居中,格子可随布局拉伸填满空白。
+	 */
+	public static JPanel paramTile(String label, JComponent field, Color stripe) {
+		JPanel outer = new JPanel(new BorderLayout(0, 0));
+		outer.setOpaque(false);
+		outer.setPreferredSize(new Dimension(240, TILE_PREF_H));
+		JPanel stripeBar = new JPanel();
+		stripeBar.setPreferredSize(new Dimension(6, 10));
+		stripeBar.setBackground(stripe == null ? STRIPE_SIDE : stripe);
+		stripeBar.setOpaque(true);
+		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);
+		inner.add(lb, BorderLayout.NORTH);
+		field.setBackground(new Color(248, 250, 252));
+		field.setFont(FONT_VALUE);
+		field.setForeground(TEXT);
+		if (field instanceof JTextField) {
+			JTextField tf = (JTextField) field;
+			tf.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));
+			tf.setHorizontalAlignment(SwingConstants.LEFT);
+		}
+		inner.add(field, BorderLayout.CENTER);
+		outer.add(stripeBar, BorderLayout.WEST);
+		outer.add(inner, BorderLayout.CENTER);
+		outer.setBorder(BorderFactory.createLineBorder(LINE));
+		return outer;
+	}
+
+	public static JLabel mutedLabel(String text) {
+		JLabel l = new JLabel(text);
+		l.setFont(FONT_LABEL);
+		l.setForeground(MUTED);
+		return l;
+	}
+
+	public static JLabel sectionTitle(String text) {
+		JLabel l = new JLabel(text);
+		l.setFont(new Font("微软雅黑", Font.BOLD, 18));
+		l.setForeground(TEXT);
+		return l;
+	}
+
+	public static JTextField valueField() {
+		JTextField f = new JTextField();
+		f.setEditable(false);
+		f.setFont(FONT_VALUE);
+		f.setForeground(TEXT);
+		f.setBackground(Color.WHITE);
+		f.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
+		return f;
+	}
+
+	public static JButton primaryBtn(String text) {
+		JButton b = new JButton(text) {
+			private static final long serialVersionUID = 1L;
+
+			@Override
+			protected void paintComponent(Graphics g) {
+				Graphics2D g2 = (Graphics2D) g.create();
+				g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+				GradientPaint gp = new GradientPaint(0, 0, ACCENT, 0, getHeight(), ACCENT_DARK);
+				g2.setPaint(gp);
+				g2.fillRoundRect(0, 0, getWidth(), getHeight(), 8, 8);
+				g2.dispose();
+				super.paintComponent(g);
+			}
+		};
+		b.setFont(FONT_BTN);
+		b.setPreferredSize(new Dimension(132, 44));
+		b.setFocusPainted(false);
+		b.setContentAreaFilled(false);
+		b.setBorderPainted(false);
+		b.setForeground(Color.WHITE);
+		b.setOpaque(false);
+		b.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+		return b;
+	}
+
+	public static JButton ghostBtn(String text) {
+		JButton b = new JButton(text);
+		b.setFont(new Font("微软雅黑", Font.PLAIN, 15));
+		int w = Math.max(100, (text == null ? 0 : text.length()) * 18 + 28);
+		b.setPreferredSize(new Dimension(w, 44));
+		b.setFocusPainted(false);
+		b.setBackground(CARD);
+		b.setForeground(TEXT);
+		b.setOpaque(true);
+		b.setBorder(BorderFactory.createCompoundBorder(
+				BorderFactory.createLineBorder(LINE),
+				new EmptyBorder(6, 14, 6, 14)));
+		b.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+		return b;
+	}
+
+	/** PLC 状态小胶囊底色 */
+	public static void stylePlcPill(JLabel label, boolean ok) {
+		label.setOpaque(true);
+		label.setBorder(new EmptyBorder(6, 12, 6, 12));
+		if (ok) {
+			label.setBackground(new Color(30, 64, 175));
+			label.setForeground(new Color(191, 219, 254));
+		} else {
+			label.setBackground(new Color(69, 40, 30));
+			label.setForeground(WARN_FG);
+		}
+	}
+}

+ 117 - 0
src/main/java/com/mes/ui/WorkRecordPanel.java

@@ -0,0 +1,117 @@
+package com.mes.ui;
+
+import com.mes.entity.DcWorkRecord;
+import com.mes.service.DcWorkRecordStore;
+
+import javax.swing.*;
+import javax.swing.border.EmptyBorder;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.DefaultTableModel;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.List;
+
+/**
+ * 工作记录页:批次码、记录时间、数量、过站结果。
+ */
+public class WorkRecordPanel extends JPanel {
+
+	private static final long serialVersionUID = 1L;
+
+	private final DefaultTableModel model;
+	private final JLabel lblStatus;
+	private final JButton btnRefresh;
+
+	public WorkRecordPanel() {
+		setLayout(new BorderLayout(0, 0));
+		setBackground(UiTheme.BG);
+		setBorder(new EmptyBorder(0, 0, 0, 0));
+
+		JPanel header = UiTheme.gradientHeader();
+		header.setBorder(new EmptyBorder(12, 16, 12, 16));
+		JLabel title = new JLabel("工作记录");
+		title.setFont(UiTheme.FONT_TITLE);
+		title.setForeground(Color.WHITE);
+		// 顶栏深绿底:按钮用半透明描边,避免 ghost 白底 + 白字变成空白块
+		btnRefresh = new JButton("刷新");
+		btnRefresh.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+		btnRefresh.setForeground(Color.WHITE);
+		btnRefresh.setFocusPainted(false);
+		btnRefresh.setContentAreaFilled(false);
+		btnRefresh.setOpaque(false);
+		btnRefresh.setBorder(BorderFactory.createCompoundBorder(
+				BorderFactory.createLineBorder(new Color(140, 210, 220)),
+				new EmptyBorder(6, 14, 6, 14)));
+		btnRefresh.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+		btnRefresh.addActionListener(new ActionListener() {
+			@Override
+			public void actionPerformed(ActionEvent e) {
+				reload();
+			}
+		});
+		header.add(title, BorderLayout.WEST);
+		header.add(btnRefresh, BorderLayout.EAST);
+		add(header, BorderLayout.NORTH);
+
+		String[] cols = new String[] { "包装码", "批次码", "记录时间", "数量", "结果" };
+		model = new DefaultTableModel(cols, 0) {
+			private static final long serialVersionUID = 1L;
+
+			@Override
+			public boolean isCellEditable(int row, int column) {
+				return false;
+			}
+		};
+		JTable table = new JTable(model);
+		table.setFont(UiTheme.FONT_BODY);
+		table.setRowHeight(28);
+		table.getTableHeader().setFont(new Font("微软雅黑", Font.BOLD, 13));
+		table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+		table.setAutoCreateRowSorter(true);
+		DefaultTableCellRenderer center = new DefaultTableCellRenderer();
+		center.setHorizontalAlignment(SwingConstants.CENTER);
+		for (int i = 0; i < table.getColumnCount(); i++) {
+			table.getColumnModel().getColumn(i).setCellRenderer(center);
+		}
+		table.getColumnModel().getColumn(0).setPreferredWidth(160);
+		table.getColumnModel().getColumn(1).setPreferredWidth(160);
+		table.getColumnModel().getColumn(2).setPreferredWidth(150);
+		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));
+		scroll.getViewport().setBackground(UiTheme.CARD);
+		add(scroll, BorderLayout.CENTER);
+
+		lblStatus = new JLabel(" ");
+		lblStatus.setFont(UiTheme.FONT_BODY);
+		lblStatus.setBorder(new EmptyBorder(8, 16, 12, 16));
+		lblStatus.setForeground(UiTheme.MUTED);
+		add(lblStatus, BorderLayout.SOUTH);
+
+		reload();
+	}
+
+	/** 从本机记录库刷新表格 */
+	public void reload() {
+		List<DcWorkRecord> list = DcWorkRecordStore.list();
+		model.setRowCount(0);
+		for (int i = 0; i < list.size(); i++) {
+			DcWorkRecord r = list.get(i);
+			if (r == null) {
+				continue;
+			}
+			model.addRow(new Object[] {
+					r.packCode,
+					r.batchCode,
+					r.recordTime,
+					Integer.valueOf(r.qty),
+					r.result
+			});
+		}
+		lblStatus.setText("共 " + list.size() + " 条");
+		lblStatus.setForeground(UiTheme.MUTED);
+	}
+}

+ 89 - 0
src/main/java/com/mes/util/SingleInstanceLock.java

@@ -0,0 +1,89 @@
+package com.mes.util;
+
+/**
+ * 单实例文件锁:防止同一客户端重复启动。
+ */
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileLock;
+import java.nio.channels.OverlappingFileLockException;
+
+public class SingleInstanceLock {
+    private FileChannel channel;
+
+    private FileLock lock;
+
+    private File file;
+
+    private static SingleInstanceLock instance = null;
+
+    /**
+     * 获取唯一进程限制的实例
+     * @Title: getInstance
+     * @return  唯一进程实例
+     */
+    public static SingleInstanceLock getInstance(){
+        if(instance == null){
+            instance = new SingleInstanceLock();
+        }
+        return instance;
+    }
+
+    /**
+     * 进程是否正在运行
+     * @Title: isAppActive
+     * @return  运行与否
+     */
+    public boolean isAppActive() {
+        // 必须赋给成员变量,shutdown 时才能删掉 .lock
+        this.file = new File(".lock");
+        try {
+            channel = new RandomAccessFile(this.file, "rw").getChannel();
+            try {
+                lock = channel.tryLock();
+            } catch (OverlappingFileLockException e) {
+                closeLock();
+                return true;
+            }
+            if (lock == null) {
+                closeLock();
+                return true;
+            }
+            Runtime.getRuntime().addShutdownHook(new Thread() {
+                public void run() {
+                    closeLock();
+                    deleteFile();
+                }
+            });
+            return false;
+        } catch (Exception e) {
+            closeLock();
+            return true;
+        }
+    }
+
+    protected void deleteFile() {
+        try {
+            if (file != null) {
+                file.delete();
+            }
+        } catch (Exception e) {
+            // ignore
+        }
+    }
+
+    private void closeLock() {
+        try {
+            lock.release();
+        } catch (Exception e) {
+
+        }
+
+        try {
+            channel.close();
+        } catch (Exception e) {
+
+        }
+    }
+}

+ 47 - 0
src/main/java/com/mes/util/UiImages.java

@@ -0,0 +1,47 @@
+package com.mes.util;
+
+import java.net.URL;
+
+import javax.swing.ImageIcon;
+
+
+/**
+ * 界面图片资源统一入口。
+ * <p>
+ * 资源目录:{@code classpath:/images/}
+ * <ul>
+ *   <li>{@code images/} — 登录背景、窗口图标等</li>
+ *   <li>{@code images/icons/} — 按钮/菜单/状态图标</li>
+ * </ul>
+ * </p>
+ */
+public final class UiImages {
+
+	/** 图片根路径 */
+	public static final String ROOT = "/images/";
+	/** 图标子目录 */
+	public static final String ICONS = ROOT + "icons/";
+
+	private UiImages() {
+	}
+
+	/** 取 images/ 下资源 URL,例如 background.png */
+	public static URL of(String fileName) {
+		return UiImages.class.getResource(ROOT + fileName);
+	}
+
+	/** 取 images/icons/ 下图标 URL,例如 logo.png */
+	public static URL icon(String fileName) {
+		return UiImages.class.getResource(ICONS + fileName);
+	}
+
+	/** 图标 ImageIcon */
+	public static ImageIcon iconImage(String fileName) {
+		return new ImageIcon(icon(fileName));
+	}
+
+	/** images/ 下 ImageIcon */
+	public static ImageIcon image(String fileName) {
+		return new ImageIcon(of(fileName));
+	}
+}

+ 30 - 0
src/main/resources/config/application.yml

@@ -0,0 +1,30 @@
+# 自动化大冲:取批次 → MES允许=true → 轮询读 DB260 → 本批做完允许=false → 打印包装码
+# 结案 completeBatch 只上传一次(包装码+过程参数)
+spring:
+  main:
+    web-application-type: none
+    banner-mode: off
+  application:
+    name: mesclient-dachong
+
+logging:
+  level:
+    root: INFO
+    com.mes: INFO
+
+mes:
+  app-title: MES 自动化大冲
+  server-ip: 127.0.0.1
+  tick-ms: 500
+  # 结案小票连接的系统打印机名;空=用 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-allow-addr:
+
+

BIN
src/main/resources/images/background.png


BIN
src/main/resources/images/close_bt.png


BIN
src/main/resources/images/icon.ico


BIN
src/main/resources/images/icons/a_side.png


BIN
src/main/resources/images/icons/b_side.png


BIN
src/main/resources/images/icons/bar_add.png


BIN
src/main/resources/images/icons/bar_bookmark.png


BIN
src/main/resources/images/icons/bar_cmd_go.png


BIN
src/main/resources/images/icons/bar_edit.png


BIN
src/main/resources/images/icons/bar_pause.png


BIN
src/main/resources/images/icons/bar_sampling.png


BIN
src/main/resources/images/icons/bar_setting.png


BIN
src/main/resources/images/icons/bar_stop.png


BIN
src/main/resources/images/icons/close_bt.png


BIN
src/main/resources/images/icons/company_setting_logo.png


BIN
src/main/resources/images/icons/delete.png


BIN
src/main/resources/images/icons/department_setting_logo.png


BIN
src/main/resources/images/icons/download.png


BIN
src/main/resources/images/icons/equipment_setting_logo.png


BIN
src/main/resources/images/icons/gj_001_1_20.png


BIN
src/main/resources/images/icons/gj_001_21_40.png


BIN
src/main/resources/images/icons/gj_001_41_60.png


BIN
src/main/resources/images/icons/green_dot.png


BIN
src/main/resources/images/icons/grey_dot.png


BIN
src/main/resources/images/icons/icon.png


BIN
src/main/resources/images/icons/inductance_logo.png


BIN
src/main/resources/images/icons/insulation_logo.png


BIN
src/main/resources/images/icons/login.png


BIN
src/main/resources/images/icons/logo.png


BIN
src/main/resources/images/icons/logoff.png


BIN
src/main/resources/images/icons/menu_data_analysis.png


BIN
src/main/resources/images/icons/menu_data_preprocess.png


BIN
src/main/resources/images/icons/menu_file.png


BIN
src/main/resources/images/icons/menu_setting.png


BIN
src/main/resources/images/icons/min_bt.png


BIN
src/main/resources/images/icons/ng_bg.png


BIN
src/main/resources/images/icons/ok_bg.png


BIN
src/main/resources/images/icons/open_file.png


BIN
src/main/resources/images/icons/refresh.png


BIN
src/main/resources/images/icons/reset_logo.png


BIN
src/main/resources/images/icons/resistance_logo.png


BIN
src/main/resources/images/icons/save_bg.png


BIN
src/main/resources/images/icons/scan_barcode.png


BIN
src/main/resources/images/icons/tree_folder_icon.png


BIN
src/main/resources/images/icons/tree_leaf_icon.png


BIN
src/main/resources/images/icons/user.png


BIN
src/main/resources/images/icons/vertical_line.png


BIN
src/main/resources/images/icons/zoom_in.png


BIN
src/main/resources/images/icons/zoom_out.png


BIN
src/main/resources/images/info_bt.png


BIN
src/main/resources/images/min_bt.png


+ 44 - 0
src/main/resources/logback.xml

@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<configuration>
+
+    <!-- 定义日志文件的存储位置及文件名 -->
+    <property name="LOG_HOME" value="D:/Logs"/>
+    <property name="PROJECT_NAME" value="log"/>
+
+    <!-- 控制台输出 -->
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss} %-5level  %logger{36} - %msg%n</pattern>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+            <level>INFO</level>
+        </filter>
+    </appender>
+
+    <!-- 文件输出 -->
+    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${LOG_HOME}/${PROJECT_NAME}/${PROJECT_NAME}.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>${LOG_HOME}/${PROJECT_NAME}/archived/${PROJECT_NAME}_%d{yyyy-MM-dd}.log</fileNamePattern>
+            <!-- 保留最近 1个月内的日志-->
+            <maxHistory>30</maxHistory>  <!-- 如果删除该项配置,则logback无法自动删除旧日志, 导致totalSizeCap也将失去作用-->
+            <!-- 滚动文件总大小不超过1GB-->
+            <totalSizeCap>1GB</totalSizeCap>
+        </rollingPolicy>
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss} %-5level  %logger{36} - %msg%n</pattern>
+        </encoder>
+    </appender>
+
+    <!-- 根Logger -->
+    <root level="info">
+        <appender-ref ref="STDOUT" />
+        <appender-ref ref="FILE" />
+    </root>
+
+    <logger name="org.slf4j" level="ERROR"/>
+    <logger name="ch.qos.logback" level="ERROR"/>
+    <logger name="ch.qos.logback.classic.joran.action.ConfigurationAction" level="OFF"/>
+
+</configuration>