|
|
@@ -48,6 +48,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;
|
|
|
/** 开批时 PLC 实际产量起点;中途复位后会按已产重定 */
|
|
|
private volatile int baseActualQty;
|
|
|
@@ -106,8 +108,9 @@ public class StationPanel extends JPanel {
|
|
|
public StationPanel(MesClientProperties.StationConfig cfg, String serverIp) {
|
|
|
this.cfg = cfg;
|
|
|
this.serverIp = serverIp == null ? "" : serverIp.trim();
|
|
|
+ // mes-allow-enabled=false 时开批/结案/清码都不写 PLC 允许点
|
|
|
this.plc = new DcPlcClient(cfg.getStationSn(), cfg.getPlcIp(), cfg.getPlcPort(),
|
|
|
- cfg.getMesAllowAddr());
|
|
|
+ cfg.getMesAllowAddr(), MainFrame.mes_allow_enabled);
|
|
|
|
|
|
setLayout(new BorderLayout(0, 0));
|
|
|
setBackground(UiTheme.BG);
|
|
|
@@ -430,9 +433,13 @@ public class StationPanel extends JPanel {
|
|
|
log.warn("工位[{}] nextBatch 成功但缺 batchCode/targetQty: {}", cfg.getStationSn(), ret);
|
|
|
return;
|
|
|
}
|
|
|
- log.info("工位[{}] nextBatch 成功 batch={} target={}",
|
|
|
- cfg.getStationSn(), code, Integer.valueOf(target));
|
|
|
- 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);
|
|
|
}
|
|
|
@@ -442,8 +449,10 @@ public class StationPanel extends JPanel {
|
|
|
|
|
|
/**
|
|
|
* 批次到位:记起点产量 → MES允许=true → 进入 RUN;本批做完再写 false。
|
|
|
+ *
|
|
|
+ * @param queueUserCode PDA 入队工号(可空)
|
|
|
*/
|
|
|
- private void startBatchFromPda(String code, int target) {
|
|
|
+ private void startBatchFromPda(String code, int target, String queueUserCode) {
|
|
|
// DONE 挂起续传中禁止再开批,避免冲掉待上传结案
|
|
|
if (phase == Phase.RUN || phase == Phase.DONE) {
|
|
|
return;
|
|
|
@@ -465,6 +474,7 @@ public class StationPanel extends JPanel {
|
|
|
baseQty = base.intValue();
|
|
|
}
|
|
|
batchCode = code;
|
|
|
+ currentUserCode = queueUserCode == null ? "" : queueUserCode.trim();
|
|
|
targetQty = target;
|
|
|
baseActualQty = baseQty;
|
|
|
lastActualQty = baseActualQty;
|
|
|
@@ -479,7 +489,15 @@ public class StationPanel extends JPanel {
|
|
|
setText(txtTarget, String.valueOf(targetQty));
|
|
|
setText(txtProduced, "0");
|
|
|
setMesAllowLamp(wrote);
|
|
|
- String tip = wrote ? "批次已开,MES允许已写" : "批次已开(允许点未配/写失败)";
|
|
|
+ // 开批提示:区分开关关 / 点未配或写失败
|
|
|
+ String tip;
|
|
|
+ if (wrote) {
|
|
|
+ tip = "批次已开,MES允许已写";
|
|
|
+ } else if (!plc.isMesAllowEnabled()) {
|
|
|
+ tip = "批次已开(MES允许开关已关,未写PLC)";
|
|
|
+ } else {
|
|
|
+ tip = "批次已开(允许点未配/写失败)";
|
|
|
+ }
|
|
|
if (base == null) {
|
|
|
tip = tip + " PLC产量未读到,起点=0";
|
|
|
} else {
|
|
|
@@ -657,6 +675,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("currentPart", nvl(snap.currentPart));
|
|
|
fields.put("nextPart", nvl(snap.nextPart));
|
|
|
fields.put("actualQty", String.valueOf(snap.actualQty));
|
|
|
@@ -800,6 +821,7 @@ public class StationPanel extends JPanel {
|
|
|
private void resetToIdle(String msg) {
|
|
|
phase = Phase.IDLE;
|
|
|
batchCode = "";
|
|
|
+ currentUserCode = "";
|
|
|
targetQty = 0;
|
|
|
baseActualQty = 0;
|
|
|
producedQty = 0;
|