الانتقال إلى المحتوى
دراسات الحالةالأتمتة

أتمتة البيانات

كيف يوثق بتقرير يصل آليا كل صباح؟

  • n8n
  • PostgreSQL
  • Python
  • Next.js
  • Telegram API

مسار البيانات

  1. 01

    الاستقبال

    رفع الملف وقراءة الأعمدة بأسمائها.

  2. 02

    التحقق

    فحص الأنواع والتواريخ والمفاتيح.

  3. 03

    المطابقة

    مقارنة اللقطة بالقاعدة وأرشفة ما غاب.

  4. 04

    الحماية

    قيود في القاعدة تمنع فقد البيانات.

  5. 05

    الفحص الليلي

    مقارنة الصفحات بجداولها.

  6. 06

    التسليم

    تقرير يومي بالبريد وتيليجرام.

مطابقة المصدر

-- The file is a full snapshot, so what is missing from it no longer exists.-- An upsert alone keeps those rows alive forever.with bounds as (    select min(reported_at) lo, max(reported_at) hi from incoming), gone as (    select r.* from reports r, bounds b    where r.reported_at between b.lo and b.hi      and not exists (select 1 from incoming i where i.id = r.id))select count(*) as gone_rows,       (select count(*) from reports r, bounds b         where r.reported_at between b.lo and b.hi) as in_rangefrom gone;-- Guard: more than 3% missing means a bad file, not a clean-up. Stop.-- Otherwise move the rows to reports_archive with their full copy. Never drop them.

حماية البيانات

-- A later file arrives with blank columns. Blank must never erase work already done.create trigger keep_enrichment before update on reportsfor each row execute function keep_non_blank('reason', 'station', 'feeder');-- A database guard, not an app guard: there are several write paths today,-- and there will be one more tomorrow.

قبل وبعد

قبل

  • إعداد يدوي كل صباح
  • الخطأ يكتشفه القارئ
  • الملف لا يحفظ

بعد

  • تقرير آلي يومي
  • الخطأ يكتشفه الفحص الليلي
  • كل ملف مؤرشف

النتيجة

  • إلغاء الإعداد اليدوي للتقرير.
  • كشف الخطأ قبل وصوله إلى الإدارة.
  • إمكان إعادة بناء أي رقم من مصدره.

الأرقام والأمثلة توضيحية.