feat(production): 持久化动作检查点并完善恢复重试流程
- production_runs 新增动作阶段、尝试次数、版本及人工确认字段 - 提供兼容 PostgreSQL 9.5 的幂等升级脚本和数据库结构检查 - 工序推进、动作完成检查点和审计记录使用同一事务 - 机器人命令单次发送,完成反馈先持久化再清握手 - 已完成动作恢复仅补握手或数据库记录,避免重复执行 - 恢复/重试按钮固定显示在清除报警前,加入明确人工处理选项 - 记录人工决定、操作人及现场核对信息,拒绝过期确认 - 区分普通暂停继续、故障恢复与终止后的视觉锁解除 - 补齐视觉目标跨重启校验、异步失败及迟到回调防护 - 检测结果关联动作和尝试次数,重试清除旧结果缓存
This commit is contained in:
@@ -280,7 +280,7 @@ bool WorkpieceService::updateState(int id, const QString &state,
|
||||
bool WorkpieceService::updateProcessStepWithRecord(
|
||||
int id, const QString &processStep, const QString &inspectionMode,
|
||||
int plcStep, const QString &source, int durationMs, QString *error,
|
||||
bool forceRestart)
|
||||
bool forceRestart, const std::function<bool(QString *)> &beforeCommit)
|
||||
{
|
||||
if (id <= 0 || processStep.trimmed().isEmpty()) {
|
||||
if (error) {
|
||||
@@ -344,6 +344,7 @@ bool WorkpieceService::updateProcessStepWithRecord(
|
||||
QString("工件 %1 工序更新为 %2")
|
||||
.arg(workpiece.barcode, processStep),
|
||||
&transactionError)
|
||||
|| (beforeCommit && !beforeCommit(&transactionError))
|
||||
|| !database.commit(&transactionError)) {
|
||||
database.rollback();
|
||||
if (error) {
|
||||
@@ -358,7 +359,8 @@ bool WorkpieceService::completeWithInspection(
|
||||
int id, const QString &state, const QString &processStep,
|
||||
const QString &previousProcessStep, int durationMs, int rawResult,
|
||||
const QString &resultState, int plcStep, const QString &inspectionMode,
|
||||
const QString &source, QString *error)
|
||||
const QString &source, QString *error,
|
||||
const std::function<bool(QString *)> &beforeCommit)
|
||||
{
|
||||
if (id <= 0) {
|
||||
if (error) {
|
||||
@@ -408,6 +410,7 @@ bool WorkpieceService::completeWithInspection(
|
||||
QString("工件 %1 检测结果为 %2")
|
||||
.arg(workpiece.barcode, resultState),
|
||||
&transactionError)
|
||||
|| (beforeCommit && !beforeCommit(&transactionError))
|
||||
|| !database.commit(&transactionError)) {
|
||||
database.rollback();
|
||||
if (error) {
|
||||
|
||||
Reference in New Issue
Block a user