from app import create_app from extensions import db from models import Device app = create_app() with app.app_context(): # 查找状态异常但 offset 被判定为当天的假数据 fake_devices = Device.query.filter( Device.status.in_(['离线', '异常', '已离线', 'offline', '未知']), Device.offset == '当天' ).all() count = 0 for dev in fake_devices: dev.latest_time = None dev.offset = '从未同步' count += 1 db.session.commit() print(f"✅ 成功清洗了 {count} 台处于离线但伪造了时间的设备!")