|
|
@@ -0,0 +1,903 @@
|
|
|
+package com.mes.ui;
|
|
|
+
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.mes.config.DcPressProfiles;
|
|
|
+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.awt.event.ActionEvent;
|
|
|
+import java.awt.event.ActionListener;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
+import java.util.concurrent.ScheduledExecutorService;
|
|
|
+import java.util.concurrent.ThreadFactory;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 一拖二单机面板:轮询取批次 → MES允许(可预留) → 盯冲次差 → 结案关允许 → 打印。
|
|
|
+ * 每台压机独立调度线程,一台 PLC/HTTP 卡死不影响另一台。
|
|
|
+ */
|
|
|
+public class StationPanel extends JPanel {
|
|
|
+
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(StationPanel.class);
|
|
|
+
|
|
|
+ /** 兜底轮询最小间隔(SSE 正常时不走 tick 取批) */
|
|
|
+ private static final long POLL_BATCH_INTERVAL_MS = 2000L;
|
|
|
+
|
|
|
+ public enum Phase {
|
|
|
+ IDLE, RUN, DONE
|
|
|
+ }
|
|
|
+
|
|
|
+ private final MesClientProperties.StationConfig cfg;
|
|
|
+ private final DcPressProfiles profile;
|
|
|
+ private final String serverIp;
|
|
|
+ private final DcPlcClient plc;
|
|
|
+ private final AtomicBoolean busy = new AtomicBoolean(false);
|
|
|
+ /** 后台取码进行中,与开批/结案 busy 分开,避免互踩 */
|
|
|
+ private final AtomicBoolean nextBusy = new AtomicBoolean(false);
|
|
|
+ /** 本工位 tick 进行中:PLC 连不上时丢弃重叠调度 */
|
|
|
+ private final AtomicBoolean tickInFlight = new AtomicBoolean(false);
|
|
|
+ /** 本工位专属周期线程(与另一台完全隔离) */
|
|
|
+ private ScheduledExecutorService stationScheduler;
|
|
|
+
|
|
|
+ private volatile Phase phase = Phase.IDLE;
|
|
|
+ private volatile String batchCode = "";
|
|
|
+ private volatile int targetQty;
|
|
|
+ /** 开批时冲次起点;中途复位后按已产重定 */
|
|
|
+ private volatile long baseStrokeCount;
|
|
|
+ private volatile int producedQty;
|
|
|
+ private volatile long lastStrokeCount;
|
|
|
+ private volatile String batchStartTime = "";
|
|
|
+ private volatile long lastPollBatchAtMs;
|
|
|
+ private volatile DcRunSnapshot lastSnap = new DcRunSnapshot();
|
|
|
+ /** 本批是否已成功写下 MES 允许(灯只跟这个,不跟 phase 瞎亮) */
|
|
|
+ private volatile boolean mesAllowOn;
|
|
|
+ /** 结案上传未成功时的待重试报文(DONE 态由 tick 续传,避免卡死) */
|
|
|
+ private volatile Map<String, String> pendingCompleteFields;
|
|
|
+ private volatile String pendingHow = "";
|
|
|
+ private volatile String pendingPackCode = "";
|
|
|
+ private volatile int pendingQty;
|
|
|
+ private volatile boolean pendingPrinted;
|
|
|
+ private final AtomicBoolean completeRetryBusy = new AtomicBoolean(false);
|
|
|
+
|
|
|
+ private final JLabel lblStation;
|
|
|
+ private final JLabel lblStatus;
|
|
|
+ private final JTextField txtBatch;
|
|
|
+ private final JTextField txtTarget;
|
|
|
+ private final JTextField txtDieHeight;
|
|
|
+ private final JTextField txtStrokeCount;
|
|
|
+ private final JTextField txtProduced;
|
|
|
+ private final JTextField txtCylinderPressure;
|
|
|
+ private final JTextField txtTonnage;
|
|
|
+ private final JTextField txtPressSpm;
|
|
|
+ /** 服务端心跳:绿/灰闪=已连,红=断开(与弧焊同款) */
|
|
|
+ private final BreathingLight serverHeartbeat;
|
|
|
+ private final StatusLight lampPlc;
|
|
|
+ private final JLabel lblPlcState;
|
|
|
+ private final StatusLight lampMesAllow;
|
|
|
+ private final JLabel lblMesAllowState;
|
|
|
+ /** 漏推送时现场可点:强制 nextBatch */
|
|
|
+ private final JButton btnNext;
|
|
|
+
|
|
|
+ public StationPanel(MesClientProperties.StationConfig cfg, String serverIp) {
|
|
|
+ this.cfg = cfg;
|
|
|
+ this.profile = cfg.resolveProfile();
|
|
|
+ this.serverIp = serverIp == null ? "" : serverIp.trim();
|
|
|
+ this.plc = new DcPlcClient(cfg.getStationSn(), cfg.getPlcIp(), cfg.getPlcPort(),
|
|
|
+ this.profile, 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 = profile.getTitle();
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+ JLabel lblCode = new JLabel(nvl(cfg.getStationSn()) + " · " + profile.name());
|
|
|
+ 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);
|
|
|
+
|
|
|
+ serverHeartbeat = new BreathingLight();
|
|
|
+ serverHeartbeat.setOnline(false);
|
|
|
+ lampPlc = new StatusLight();
|
|
|
+ lblPlcState = headerStateLabel("未连接");
|
|
|
+ lampMesAllow = new StatusLight();
|
|
|
+ lblMesAllowState = headerStateLabel("关");
|
|
|
+
|
|
|
+ JPanel east = new JPanel(new FlowLayout(FlowLayout.RIGHT, 14, 0));
|
|
|
+ east.setOpaque(false);
|
|
|
+ // 每台压机一套:MES 服务端呼吸灯 + PLC + MES允许
|
|
|
+ east.add(headerBreathingItem("MES", serverHeartbeat));
|
|
|
+ east.add(headerLampItem("PLC", lampPlc, lblPlcState));
|
|
|
+ east.add(headerLampItem("MES允许", lampMesAllow, lblMesAllowState));
|
|
|
+ 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);
|
|
|
+ txtDieHeight = roField();
|
|
|
+ txtStrokeCount = roField();
|
|
|
+ txtProduced = roField();
|
|
|
+ txtProduced.setFont(UiTheme.FONT_SN);
|
|
|
+ txtCylinderPressure = roField();
|
|
|
+ txtTonnage = roField();
|
|
|
+ txtPressSpm = roField();
|
|
|
+ grid.add(UiTheme.paramTile("生产高度", txtDieHeight, UiTheme.STRIPE_SIDE));
|
|
|
+ grid.add(UiTheme.paramTile("冲次数量", txtStrokeCount, UiTheme.STRIPE_SIDE));
|
|
|
+ grid.add(UiTheme.paramTile("本批已产", txtProduced, UiTheme.STRIPE_SIDE));
|
|
|
+ grid.add(UiTheme.paramTile("顶缸压力", txtCylinderPressure, UiTheme.STRIPE_SIDE));
|
|
|
+ grid.add(UiTheme.paramTile("生产吨位", txtTonnage, UiTheme.STRIPE_SIDE));
|
|
|
+ grid.add(UiTheme.paramTile("压机行程次数", txtPressSpm, UiTheme.STRIPE_SIDE));
|
|
|
+ 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));
|
|
|
+ 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
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
+ 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);
|
|
|
+ add(actions, BorderLayout.SOUTH);
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getStationSn() {
|
|
|
+ return nvl(cfg.getStationSn());
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 页签/导航名:机型标题 */
|
|
|
+ public String tabTitle() {
|
|
|
+ String t = nvl(cfg.getTitle());
|
|
|
+ return t.isEmpty() ? profile.getTitle() : t;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void initPlc() {
|
|
|
+ plc.connect();
|
|
|
+ uiPlcLabel();
|
|
|
+ refreshSnapshotUi(plc.readSnapshot());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 启动本工位独立周期任务;与另一台互不影响。
|
|
|
+ *
|
|
|
+ * @param periodMs 轮询间隔
|
|
|
+ */
|
|
|
+ public void startStationLoop(int periodMs) {
|
|
|
+ stopStationLoop();
|
|
|
+ final int period = periodMs > 0 ? periodMs : 500;
|
|
|
+ final String sn = nvl(cfg.getStationSn());
|
|
|
+ stationScheduler = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
|
|
|
+ @Override
|
|
|
+ public Thread newThread(Runnable r) {
|
|
|
+ Thread t = new Thread(r, "dc-yt-tick-" + sn);
|
|
|
+ t.setDaemon(true);
|
|
|
+ return t;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ stationScheduler.scheduleWithFixedDelay(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ try {
|
|
|
+ tick();
|
|
|
+ } catch (Throwable t) {
|
|
|
+ log.warn("工位[{}] 周期异常(已隔离,不影响其他压机): {}", sn, t.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 800L, period, TimeUnit.MILLISECONDS);
|
|
|
+ log.info("工位[{}] 独立周期已启动 periodMs={}", sn, Integer.valueOf(period));
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 停止本工位周期;退出时由 MainFrame 逐台调用 */
|
|
|
+ public void stopStationLoop() {
|
|
|
+ if (stationScheduler != null) {
|
|
|
+ stationScheduler.shutdownNow();
|
|
|
+ stationScheduler = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 周期:重连、刷过程参数;空闲拉 PDA 批次;RUN 按冲次差结案。
|
|
|
+ */
|
|
|
+ public void tick() {
|
|
|
+ if (busy.get()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 上一拍还在连 PLC / 读点,直接跳过本拍,防止死机拖垮线程池
|
|
|
+ if (!tickInFlight.compareAndSet(false, true)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ plc.maintainConnection();
|
|
|
+ uiPlcLabel();
|
|
|
+ // 只刷灯,探活由 MainFrame 后台线程做,避免 HTTP 超时堵住 tick
|
|
|
+ uiServerHeartbeat();
|
|
|
+ DcRunSnapshot snap = plc.readSnapshot();
|
|
|
+ if (snap != null) {
|
|
|
+ lastSnap = snap;
|
|
|
+ }
|
|
|
+ refreshSnapshotUi(snap);
|
|
|
+ if (phase == Phase.IDLE) {
|
|
|
+ // 取批改由 SSE 门铃 / 断线兜底触发,tick 只刷灯与状态
|
|
|
+ if (!MainFrame.isMesServerOnline()) {
|
|
|
+ setStatusUi("空闲:MES/SSE 未连接,等待服务端…");
|
|
|
+ } else {
|
|
|
+ setStatusUi("空闲:等待扫码下发批次…");
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (phase == Phase.DONE) {
|
|
|
+ // 上传曾中断:用挂起报文续传,不重新开批
|
|
|
+ retryPendingCompleteIfAny();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (phase == Phase.RUN) {
|
|
|
+ // PLC 断线时 snap.strokeCount 默认为 0,不能当冲次复位,否则已产会被搅乱
|
|
|
+ if (plc.isConnected() && snap != null && !nvl(snap.strokeCountText).isEmpty()) {
|
|
|
+ updateProducedAgainstStroke(snap.strokeCount);
|
|
|
+ }
|
|
|
+ final int producedUi = producedQty;
|
|
|
+ final String batchUi = batchCode;
|
|
|
+ final int targetUi = targetQty;
|
|
|
+ final boolean plcOk = plc.isConnected();
|
|
|
+ SwingUtilities.invokeLater(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ setText(txtProduced, String.valueOf(producedUi));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (plcOk) {
|
|
|
+ setStatusUi("生产中 批次=" + batchUi + " 已产 " + producedUi + " / 目标 " + targetUi);
|
|
|
+ } else {
|
|
|
+ setStatusUi("生产中 批次=" + batchUi + " 已产 " + producedUi + " / 目标 " + targetUi
|
|
|
+ + "(PLC 断开,已产保持)");
|
|
|
+ }
|
|
|
+ if (producedQty >= targetQty && targetQty > 0) {
|
|
|
+ finishBatch(producedQty, false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("工位[{}] tick 异常: {}", cfg.getStationSn(), e.getMessage());
|
|
|
+ } finally {
|
|
|
+ tickInFlight.set(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /** SSE / 兜底:空闲则 nextBatch */
|
|
|
+ public void tryAutoNextFromPush() {
|
|
|
+ if (phase != Phase.IDLE) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ requestNextAsync();
|
|
|
+ }
|
|
|
+
|
|
|
+ /** SSE 门铃带工位校验 */
|
|
|
+ public void tryAutoNextFromPush(String enqueueStationSn) {
|
|
|
+ if (enqueueStationSn == null || !enqueueStationSn.trim().equalsIgnoreCase(getStationSn())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ tryAutoNextFromPush();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 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) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (phase == Phase.DONE && pendingCompleteFields != null) {
|
|
|
+ log.info("工位[{}] 结案上传中收到清码 sn={},不打断", cfg.getStationSn(), local);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!busy.compareAndSet(false, true)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ log.info("工位[{}] 收到清码推送,复位本地 batch={}", cfg.getStationSn(), local);
|
|
|
+ plc.setMesAllow(false);
|
|
|
+ mesAllowOn = false;
|
|
|
+ pendingCompleteFields = null;
|
|
|
+ resetToIdle("服务端已清码 " + local);
|
|
|
+ MainFrame.setMenuStatus(cfg.getStationSn() + " 已清码 " + local, 0);
|
|
|
+ } finally {
|
|
|
+ busy.set(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 开批失败等场景:延迟再 next(清空节流,避免被 2s 间隔挡掉) */
|
|
|
+ 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-yt-next-retry-" + cfg.getStationSn()).start();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 异步 nextBatch(SSE 门铃或断线兜底调用)。
|
|
|
+ * HTTP 放后台,不堵本工位 PLC tick。
|
|
|
+ */
|
|
|
+ public void requestNextAsync() {
|
|
|
+ if (phase != Phase.IDLE) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ long now = System.currentTimeMillis();
|
|
|
+ if (now - lastPollBatchAtMs < POLL_BATCH_INTERVAL_MS) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ lastPollBatchAtMs = now;
|
|
|
+ if (serverIp.isEmpty()) {
|
|
|
+ setStatusUi("空闲:等待扫码(server-ip 未配,仅可联调模拟)");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!nextBusy.compareAndSet(false, true)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ new Thread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ try {
|
|
|
+ JSONObject ret = MesDcApiClient.nextBatch(serverIp, cfg.getStationSn());
|
|
|
+ if (ret == null) {
|
|
|
+ setStatusUi("空闲:取批次无响应,稍后重试…");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (phase != Phase.IDLE) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ } finally {
|
|
|
+ nextBusy.set(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, "dc-yt-next-" + cfg.getStationSn()).start();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void startBatchFromPda(String code, int target) {
|
|
|
+ if (phase == Phase.RUN || phase == Phase.DONE) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!busy.compareAndSet(false, true)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (!plc.isConnected()) {
|
|
|
+ plc.connect();
|
|
|
+ }
|
|
|
+ Long base = plc.readStrokeCount();
|
|
|
+ if (base == null) {
|
|
|
+ // 服务端队列已是已取:必须稍后重试 nextBatch,否则 SSE 不会再响铃
|
|
|
+ setStatusUi("收到批次,但读冲次数量失败,将自动重试…");
|
|
|
+ MainFrame.setMenuStatus(cfg.getStationSn() + " 开批失败:读冲次", -1);
|
|
|
+ scheduleNextRetry(3000L);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ batchCode = code;
|
|
|
+ targetQty = target;
|
|
|
+ baseStrokeCount = base.longValue();
|
|
|
+ lastStrokeCount = baseStrokeCount;
|
|
|
+ producedQty = 0;
|
|
|
+ batchStartTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
|
|
+ boolean wrote = plc.setMesAllow(true);
|
|
|
+ mesAllowOn = wrote;
|
|
|
+ phase = Phase.RUN;
|
|
|
+ final String tip = (wrote ? "批次已开,MES允许已写" : "批次已开(允许点未配/写失败,本地仍盯冲次)")
|
|
|
+ + " 起始冲次=" + baseStrokeCount;
|
|
|
+ final String codeUi = batchCode;
|
|
|
+ final int targetUi = targetQty;
|
|
|
+ SwingUtilities.invokeLater(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ setText(txtBatch, codeUi);
|
|
|
+ setText(txtTarget, String.valueOf(targetUi));
|
|
|
+ setText(txtProduced, "0");
|
|
|
+ setMesAllowLamp(mesAllowOn);
|
|
|
+ setStatusUi(tip);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ MainFrame.setMenuStatus(cfg.getStationSn() + " 开批 " + batchCode + " 目标" + targetQty, 0);
|
|
|
+ log.info("工位[{}] 开批 batch={} target={} baseStroke={}",
|
|
|
+ cfg.getStationSn(), batchCode, Integer.valueOf(targetQty), Long.valueOf(baseStrokeCount));
|
|
|
+ } finally {
|
|
|
+ busy.set(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 手动取批次:SSE 漏推 / 网络抖时立刻 nextBatch(不受 2s 节流)。
|
|
|
+ * 仅空闲可用。
|
|
|
+ */
|
|
|
+ public void onManualNextClick() {
|
|
|
+ if (phase != Phase.IDLE) {
|
|
|
+ setStatusUi("当前非空闲,无法取批次(进行中请用手动提交结案)");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ lastPollBatchAtMs = 0L;
|
|
|
+ setStatusUi("正在手动取批次…");
|
|
|
+ requestNextAsync();
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 手动提交:密码 mes */
|
|
|
+ public void onManualSubmitClick() {
|
|
|
+ if (phase != Phase.RUN) {
|
|
|
+ setStatusUi("当前无进行中的批次,无法手动提交");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!askMesPassword()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ finishBatch(producedQty, false, 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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;
|
|
|
+ final int targetSnap = targetQty;
|
|
|
+ new Thread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ boolean fieldsReady = false;
|
|
|
+ try {
|
|
|
+ plc.setMesAllow(false);
|
|
|
+ mesAllowOn = 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());
|
|
|
+ }
|
|
|
+ final String packCode = DcPackCode.next();
|
|
|
+ String passResult = aborted ? "NG" : "OK";
|
|
|
+ DcRunSnapshot snap = lastSnap == null ? new DcRunSnapshot() : lastSnap;
|
|
|
+ final Map<String, String> fields = new LinkedHashMap<String, String>();
|
|
|
+ fields.put("stationSn", cfg.getStationSn());
|
|
|
+ fields.put("stationTitle", tabTitle());
|
|
|
+ fields.put("batchCode", codeSnap);
|
|
|
+ fields.put("packCode", packCode);
|
|
|
+ fields.put("qty", String.valueOf(qty));
|
|
|
+ fields.put("targetQty", String.valueOf(targetSnap));
|
|
|
+ fields.put("produceTime", time);
|
|
|
+ fields.put("aborted", aborted ? "1" : "0");
|
|
|
+ fields.put("manual", manual ? "1" : "0");
|
|
|
+ fields.put("result", passResult);
|
|
|
+ fields.put("pressProfile", profile.name());
|
|
|
+ fields.put("dieHeight", nvl(snap.dieHeight));
|
|
|
+ fields.put("strokeCount", nvl(snap.strokeCountText));
|
|
|
+ fields.put("cylinderPressure", nvl(snap.cylinderPressure));
|
|
|
+ fields.put("tonnage", nvl(snap.tonnage));
|
|
|
+ fields.put("pressSpm", nvl(snap.pressSpm));
|
|
|
+ fields.put("deviceRunning", snap.deviceRunning ? "1" : "0");
|
|
|
+ fields.put("deviceStateText", nvl(snap.deviceStateText));
|
|
|
+ // 本机记录先落;挂起报文供 DONE 续传
|
|
|
+ DcWorkRecordStore.add(packCode, codeSnap, time, qty, passResult);
|
|
|
+ MainFrame.refreshWorkRecords();
|
|
|
+ String how = aborted ? "已强制结束" : (manual ? "手动提交" : "本批达标");
|
|
|
+ pendingCompleteFields = fields;
|
|
|
+ pendingHow = how;
|
|
|
+ pendingPackCode = packCode;
|
|
|
+ pendingQty = qty;
|
|
|
+ pendingPrinted = false;
|
|
|
+ fieldsReady = true;
|
|
|
+ // 打印异步:打印机卡死不能挡 MES 结案
|
|
|
+ final String printTime = time;
|
|
|
+ new Thread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ boolean ok = DcBatchPrinter.printPack(packCode, printTime, qty);
|
|
|
+ pendingPrinted = ok;
|
|
|
+ if (!ok) {
|
|
|
+ log.warn("工位[{}] 异步打印失败/无打印机 pack={}", cfg.getStationSn(), packCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, "dc-yt-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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, "dc-yt-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 packCode = pendingPackCode;
|
|
|
+ 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) {
|
|
|
+ MainFrame.setMesServerOnline(true);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ setStatusUi(how + " 包装码=" + packCode + " 上传失败,重试中…(#" + attempt + ")");
|
|
|
+ MainFrame.setMenuStatus(cfg.getStationSn() + " 上传失败重试 #" + attempt, -1);
|
|
|
+ log.warn("工位[{}] 结案上传失败 pack={} attempt={}",
|
|
|
+ cfg.getStationSn(), packCode, Integer.valueOf(attempt));
|
|
|
+ if (attempt < maxAttempts) {
|
|
|
+ try {
|
|
|
+ Thread.sleep(5000L);
|
|
|
+ } catch (InterruptedException ie) {
|
|
|
+ Thread.currentThread().interrupt();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (uploaded) {
|
|
|
+ pendingCompleteFields = null;
|
|
|
+ final String tip = how + " 包装码=" + packCode + " 数量=" + qty
|
|
|
+ + (pendingPrinted ? " 已送打印" : " 打印已提交/待确认")
|
|
|
+ + " 已上传";
|
|
|
+ resetToIdle(tip);
|
|
|
+ MainFrame.setMenuStatus(cfg.getStationSn() + " 结案 " + packCode + " x" + qty, 0);
|
|
|
+ log.info("工位[{}] 结案成功 pack={} qty={}", cfg.getStationSn(), packCode, Integer.valueOf(qty));
|
|
|
+ } else {
|
|
|
+ setStatusUi(how + " 包装码=" + packCode + " 等待续传…");
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ completeRetryBusy.set(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按冲次累计本批已产;冲次变小则保留已产并重定起点。
|
|
|
+ */
|
|
|
+ private void updateProducedAgainstStroke(long strokeCount) {
|
|
|
+ if (strokeCount < lastStrokeCount) {
|
|
|
+ int kept = producedQty;
|
|
|
+ baseStrokeCount = strokeCount - kept;
|
|
|
+ log.warn("工位[{}] 检测到冲次复位/变小:上次={} 本次={},保留已产={},重定起点={}",
|
|
|
+ cfg.getStationSn(),
|
|
|
+ Long.valueOf(lastStrokeCount),
|
|
|
+ Long.valueOf(strokeCount),
|
|
|
+ Integer.valueOf(kept),
|
|
|
+ Long.valueOf(baseStrokeCount));
|
|
|
+ setStatusUi("检测到冲次复位,已保留本批进度 " + kept + " / " + targetQty);
|
|
|
+ }
|
|
|
+ long producedLong = strokeCount - baseStrokeCount;
|
|
|
+ int produced = producedLong > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) producedLong;
|
|
|
+ if (produced < 0) {
|
|
|
+ produced = 0;
|
|
|
+ }
|
|
|
+ if (produced > producedQty) {
|
|
|
+ producedQty = produced;
|
|
|
+ }
|
|
|
+ lastStrokeCount = strokeCount;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void resetToIdle(String msg) {
|
|
|
+ phase = Phase.IDLE;
|
|
|
+ batchCode = "";
|
|
|
+ targetQty = 0;
|
|
|
+ baseStrokeCount = 0L;
|
|
|
+ producedQty = 0;
|
|
|
+ lastStrokeCount = 0L;
|
|
|
+ batchStartTime = "";
|
|
|
+ mesAllowOn = false;
|
|
|
+ pendingCompleteFields = null;
|
|
|
+ pendingHow = "";
|
|
|
+ pendingPackCode = "";
|
|
|
+ pendingQty = 0;
|
|
|
+ pendingPrinted = false;
|
|
|
+ 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(txtDieHeight, s.dieHeight);
|
|
|
+ setText(txtStrokeCount, s.strokeCountText);
|
|
|
+ setText(txtCylinderPressure, s.cylinderPressure);
|
|
|
+ setText(txtTonnage, s.tonnage);
|
|
|
+ setText(txtPressSpm, s.pressSpm);
|
|
|
+ // 允许灯跟真实写点结果,不因 phase=RUN 就常绿
|
|
|
+ setMesAllowLamp(mesAllowOn);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 刷新 MES 允许灯;已在 EDT 时可直接调 */
|
|
|
+ private void setMesAllowLamp(final boolean on) {
|
|
|
+ Runnable r = new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ if (plc.getMesAllowAddr().isEmpty()) {
|
|
|
+ lampMesAllow.setOn(false);
|
|
|
+ lblMesAllowState.setText("预留");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ lampMesAllow.setOn(on);
|
|
|
+ lblMesAllowState.setText(on ? "开" : "关");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ if (SwingUtilities.isEventDispatchThread()) {
|
|
|
+ r.run();
|
|
|
+ } else {
|
|
|
+ SwingUtilities.invokeLater(r);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 ? "已连接" : "未连接");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 按 SSE 连接态刷新 MES 呼吸灯 */
|
|
|
+ private void uiServerHeartbeat() {
|
|
|
+ final boolean online = MainFrame.isMesServerOnline();
|
|
|
+ SwingUtilities.invokeLater(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ serverHeartbeat.setOnline(online);
|
|
|
+ serverHeartbeat.setToolTipText(online
|
|
|
+ ? "服务端已连接(SSE 正常)"
|
|
|
+ : "服务端已断开(SSE 未连)");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 顶栏 MES 呼吸灯一组:名称在上、灯居中 */
|
|
|
+ private static JPanel headerBreathingItem(String name, BreathingLight lamp) {
|
|
|
+ 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);
|
|
|
+ p.add(lb);
|
|
|
+ p.add(Box.createVerticalStrut(4));
|
|
|
+ p.add(lamp);
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+}
|