feat(production): 修改删除订单问题

This commit is contained in:
lidg
2026-11-09 09:22:03 +08:00
parent 81313e61b0
commit 6a70f1943f
7 changed files with 138 additions and 144 deletions
+46 -68
View File
@@ -582,91 +582,69 @@ void DeviceService::beginProductionAction(
}
m_productionActionBusy = true;
inspectProductionAction(
action,
[this, action, trayNo, slotNo, addresses, callback, beforeSend](
bool success, const ProductionActionStatus &status,
const QString &error) {
if (!success) {
m_productionActionBusy = false;
if (callback) {
callback(VisionWriteOutcome::NotSent, error);
}
return;
}
if (status.command || status.feedback) {
m_productionActionBusy = false;
if (callback) {
callback(VisionWriteOutcome::NotSent,
"PLC command or feedback is still active before a new action");
}
return;
auto sendCommand =
[this, callback](VisionWriteOutcome outcome, const QString &error) {
// An unacknowledged command may already be running. Do not
// permit another action until it has been reconciled.
m_productionActionActive = outcome != VisionWriteOutcome::NotSent;
m_productionActionBusy = false;
if (callback) {
callback(outcome, error);
}
};
auto sendCommand =
[this, callback](VisionWriteOutcome outcome, const QString &error) {
// An unacknowledged command may already be running. Do not
// permit another action until it has been reconciled.
m_productionActionActive = outcome != VisionWriteOutcome::NotSent;
m_productionActionBusy = false;
if (callback) {
callback(outcome, error);
}
};
auto writeCommand = [this, sendCommand, beforeSend](bool success,
const QString &error) {
if (!success) {
sendCommand(VisionWriteOutcome::NotSent, error);
return;
}
// Action commands must never use the legacy automatic retry
// path, even when no persistence hook is supplied.
m_modbus->writeVisionCoil(m_productionCommandAddress, true,
sendCommand, beforeSend);
};
auto writeCommand = [this, sendCommand, beforeSend](bool success,
const QString &error) {
if (!success) {
sendCommand(VisionWriteOutcome::NotSent, error);
if (action == PhotoMoveAction || action == RackPick
|| action == RackPlace) {
m_modbus->writeHoldingRegister(
addresses.trayNumber,
static_cast<quint16>(trayNo),
[this, addresses, slotNo, writeCommand](
bool traySuccess, const QString &trayError) {
if (!traySuccess) {
writeCommand(false, trayError);
return;
}
// Action commands must never use the legacy automatic retry
// path, even when no persistence hook is supplied.
m_modbus->writeVisionCoil(m_productionCommandAddress, true,
sendCommand, beforeSend);
};
if (action == PhotoMoveAction || action == RackPick
|| action == RackPlace) {
m_modbus->writeHoldingRegister(
addresses.trayNumber,
static_cast<quint16>(trayNo),
addresses.slotNumber,
static_cast<quint16>(slotNo),
[this, addresses, slotNo, writeCommand](
bool traySuccess, const QString &trayError) {
if (!traySuccess) {
writeCommand(false, trayError);
bool slotSuccess, const QString &slotError) {
if (!slotSuccess) {
writeCommand(false, slotError);
return;
}
m_modbus->writeHoldingRegister(
addresses.slotNumber,
static_cast<quint16>(slotNo),
addresses.slotRowNumber,
static_cast<quint16>((slotNo - 1) / 7 + 1),
[this, addresses, slotNo, writeCommand](
bool slotSuccess, const QString &slotError) {
if (!slotSuccess) {
writeCommand(false, slotError);
bool rowSuccess, const QString &rowError) {
if (!rowSuccess) {
writeCommand(false, rowError);
return;
}
m_modbus->writeHoldingRegister(
addresses.slotRowNumber,
static_cast<quint16>((slotNo - 1) / 7 + 1),
[this, addresses, slotNo, writeCommand](
bool rowSuccess, const QString &rowError) {
if (!rowSuccess) {
writeCommand(false, rowError);
return;
}
m_modbus->writeHoldingRegister(
addresses.slotColumNumber,
static_cast<quint16>((slotNo - 1) % 7 + 1),
writeCommand);
});
addresses.slotColumNumber,
static_cast<quint16>((slotNo - 1) % 7 + 1),
writeCommand);
});
});
return;
}
});
return;
}
writeCommand(true, QString());
});
writeCommand(true, QString());
}
void DeviceService::inspectProductionAction(