flowchart TD
A([管理员调用 restoreCoil]) --> B[SELECT FOR UPDATE 行锁查 item]
B --> C{itemStatus\n= cancelled?}
C -->|否| D[拒绝: 仅已取消的卷可恢复]
C -->|是| E{receivingPushStatus\n= success?}
E -->|是| F[拒绝: 已推送WMS不可恢复]
E -->|否| G[清除全部操作字段\n与resetCoilStatus一致\n但保留coilReview数据]
G --> H[excludedDriverId = null]
H --> I["restoreSoftDeletedCargo\n@Update原生SQL\nWHERE del_flag=1\n绕过@TableLogic"]
I --> J{restored > 0?}
J -->|是| K[cargo delFlag=0 恢复成功]
J -->|否| L[警告日志: 参数可能不匹配\ncargo可能已被物理删除]
K --> M[写 ACTION_RESTORE 日志]
L --> M
M --> N[发布 RefreshEvent]
N --> O([恢复完成\n卷回到pending态\ndriverId=null需重新指定])
style D fill:#fee,stroke:#e33
style F fill:#fee,stroke:#e33
style I fill:#dcfce7,stroke:#10b981
style K fill:#d1fae5,stroke:#10b981
style L fill:#fef3c7,stroke:#f59e0b
style O fill:#d1fae5,stroke:#10b981