|
|
@@ -65,6 +65,8 @@ public class StationPanel extends JPanel {
|
|
|
|
|
|
private volatile Phase phase = Phase.IDLE;
|
|
|
private volatile String batchCode = "";
|
|
|
+ /** 本件结案工号:优先 nextBatch 带回的入队 userCode */
|
|
|
+ private volatile String currentUserCode = "";
|
|
|
private volatile int targetQty;
|
|
|
/** 开批时冲次起点;中途复位后按已产重定 */
|
|
|
private volatile long baseStrokeCount;
|
|
|
@@ -113,8 +115,9 @@ public class StationPanel extends JPanel {
|
|
|
this.cfg = cfg;
|
|
|
this.profile = cfg.resolveProfile();
|
|
|
this.serverIp = serverIp == null ? "" : serverIp.trim();
|
|
|
+ // mes-allow-enabled=false 时开批/结案/清码都不写 PLC 允许点
|
|
|
this.plc = new DcPlcClient(cfg.getStationSn(), cfg.getPlcIp(), cfg.getPlcPort(),
|
|
|
- this.profile, cfg.getMesAllowAddr());
|
|
|
+ this.profile, cfg.getMesAllowAddr(), MainFrame.mes_allow_enabled);
|
|
|
|
|
|
setLayout(new BorderLayout(0, 0));
|
|
|
setBackground(UiTheme.BG);
|
|
|
@@ -489,7 +492,13 @@ public class StationPanel extends JPanel {
|
|
|
log.warn("工位[{}] nextBatch 成功但缺 batchCode/targetQty: {}", cfg.getStationSn(), ret);
|
|
|
return;
|
|
|
}
|
|
|
- startBatchFromPda(code, target);
|
|
|
+ String queueUser = MesDcApiClient.dataStr(ret, "userCode");
|
|
|
+ if (queueUser.isEmpty()) {
|
|
|
+ queueUser = MesDcApiClient.dataStr(ret, "ucode");
|
|
|
+ }
|
|
|
+ log.info("工位[{}] nextBatch 成功 batch={} target={} userCode={}",
|
|
|
+ cfg.getStationSn(), code, Integer.valueOf(target), queueUser);
|
|
|
+ startBatchFromPda(code, target, queueUser);
|
|
|
} finally {
|
|
|
nextBusy.set(false);
|
|
|
}
|
|
|
@@ -497,7 +506,10 @@ public class StationPanel extends JPanel {
|
|
|
}, "dc-yt-next-" + cfg.getStationSn()).start();
|
|
|
}
|
|
|
|
|
|
- private void startBatchFromPda(String code, int target) {
|
|
|
+ /**
|
|
|
+ * @param queueUserCode PDA 入队工号(可空)
|
|
|
+ */
|
|
|
+ private void startBatchFromPda(String code, int target, String queueUserCode) {
|
|
|
if (phase == Phase.RUN || phase == Phase.DONE) {
|
|
|
return;
|
|
|
}
|
|
|
@@ -517,6 +529,7 @@ public class StationPanel extends JPanel {
|
|
|
return;
|
|
|
}
|
|
|
batchCode = code;
|
|
|
+ currentUserCode = queueUserCode == null ? "" : queueUserCode.trim();
|
|
|
targetQty = target;
|
|
|
baseStrokeCount = base.longValue();
|
|
|
lastStrokeCount = baseStrokeCount;
|
|
|
@@ -525,8 +538,16 @@ public class StationPanel extends JPanel {
|
|
|
boolean wrote = plc.setMesAllow(true);
|
|
|
mesAllowOn = wrote;
|
|
|
phase = Phase.RUN;
|
|
|
- final String tip = (wrote ? "批次已开,MES允许已写" : "批次已开(允许点未配/写失败,本地仍盯冲次)")
|
|
|
- + " 起始冲次=" + baseStrokeCount;
|
|
|
+ // 开批提示:区分开关关 / 点未配或写失败
|
|
|
+ String tipCore;
|
|
|
+ if (wrote) {
|
|
|
+ tipCore = "批次已开,MES允许已写";
|
|
|
+ } else if (!plc.isMesAllowEnabled()) {
|
|
|
+ tipCore = "批次已开(MES允许开关已关,未写PLC)";
|
|
|
+ } else {
|
|
|
+ tipCore = "批次已开(允许点未配/写失败,本地仍盯冲次)";
|
|
|
+ }
|
|
|
+ final String tip = tipCore + " 起始冲次=" + baseStrokeCount;
|
|
|
final String codeUi = batchCode;
|
|
|
final int targetUi = targetQty;
|
|
|
SwingUtilities.invokeLater(new Runnable() {
|
|
|
@@ -676,6 +697,9 @@ public class StationPanel extends JPanel {
|
|
|
fields.put("aborted", aborted ? "1" : "0");
|
|
|
fields.put("manual", manual ? "1" : "0");
|
|
|
fields.put("result", passResult);
|
|
|
+ // 结案工号:取批时队列带回的入队工号;空则 system
|
|
|
+ String jobUser = currentUserCode == null ? "" : currentUserCode.trim();
|
|
|
+ fields.put("userCode", jobUser.isEmpty() ? "system" : jobUser);
|
|
|
fields.put("pressProfile", profile.name());
|
|
|
fields.put("dieHeight", nvl(snap.dieHeight));
|
|
|
fields.put("strokeCount", nvl(snap.strokeCountText));
|
|
|
@@ -963,6 +987,7 @@ public class StationPanel extends JPanel {
|
|
|
private void resetToIdle(String msg) {
|
|
|
phase = Phase.IDLE;
|
|
|
batchCode = "";
|
|
|
+ currentUserCode = "";
|
|
|
targetQty = 0;
|
|
|
baseStrokeCount = 0L;
|
|
|
synchronized (sampleBuf) {
|