IQVizyon - Aselsan İvme Projesi Entegrasyon Test Projesidir
  • TypeScript 99.6%
  • Dockerfile 0.3%
  • JavaScript 0.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
muhammedfatihercakir b095ff8486
All checks were successful
CI Quality / Quality Pipeline (push) Successful in 40s
Merge pull request 'ci: add Forgejo quality pipeline' (#1) from test/forge-runner-check into main
Reviewed-on: #1
2026-09-30 10:52:52 +03:00
.forgejo/workflows ci: configure ASELSAN test token 2026-09-30 10:39:32 +03:00
.idea API ENdpoint fixed 2026-06-16 15:56:59 +03:00
docs operator-performance fixed 2026-06-18 15:54:08 +03:00
examples API ENdpoint fixed 2026-06-16 15:56:59 +03:00
src Detaylı testler eklendi 2026-06-29 12:28:44 +03:00
tests Detaylı testler eklendi 2026-06-29 12:28:44 +03:00
.dockerignore Proje taslağı oluşturuldu 2026-06-16 10:37:34 +03:00
.env.example Detaylı testler eklendi 2026-06-29 12:28:44 +03:00
.gitignore Proje taslağı oluşturuldu 2026-06-16 10:37:34 +03:00
.prettierrc Proje taslağı oluşturuldu 2026-06-16 10:37:34 +03:00
docker-compose.yml Proje taslağı oluşturuldu 2026-06-16 10:37:34 +03:00
Dockerfile Proje taslağı oluşturuldu 2026-06-16 10:37:34 +03:00
eslint.config.js Proje taslağı oluşturuldu 2026-06-16 10:37:34 +03:00
package-lock.json Proje taslağı oluşturuldu 2026-06-16 10:37:34 +03:00
package.json Proje taslağı oluşturuldu 2026-06-16 10:37:34 +03:00
README.md operator-performance fixed 2026-06-18 15:54:08 +03:00
tsconfig.json Proje taslağı oluşturuldu 2026-06-16 10:37:34 +03:00
vitest.config.ts Tüm API endpointleri tamam-test1 2026-06-18 12:11:25 +03:00

ASELSAN IVME Integration Service

IQVizyon sistemindeki MongoDB ve InfluxDB verilerini ASELSAN IVME MES REST formatina donusturen, token tabanli ve production deployment'a hazir Fastify API servisidir.

Mimari Ozet

routes -> controllers -> send service -> mongo/influx services
                                  -> transformers
                                  -> validators
                                  -> aselsan client -> token service

ASELSAN'a HTTP istegi yalnizca aselsanClient.service.ts icinden atilir. Token secimi token.service.ts icinde, Authorization header uretimi ASELSAN client icinde yapilir.

Teknoloji Secimi

  • Node.js 20+ ve TypeScript
  • Fastify, Swagger/OpenAPI
  • MongoDB native driver
  • InfluxDB client
  • undici HTTP client
  • zod validation
  • pino logging ve secret redaction
  • Vitest, ESLint, Prettier
  • Docker multi-stage production image

Veri Kaynaklari

MongoDB collectionlari:

  • machines, products, projects, alarms
  • companies, organizations, stop_types
  • shift_plan, machine_shift_assignment
  • report_program, users, iqv_machine_datas

InfluxDB:

  • Bucket: INFLUX_BUCKET, varsayilan champion
  • Measurement: machines.machine_code
  • Field filtresi: machines.connection_details.selected_keys
  • Sorgular pivot edilmis, range ve limit kontrollu calisir.
  • Mes_ProcessParameters sadece onayli CNC/IoT alanlarini flat record olarak uretir; IP, MQTT, app metadata ve debug alanlari payload'a tasinmaz.

ASELSAN Veri Setleri

ASELSAN entegrasyonunda toplam 14 veri servisi vardir (13 resmi + 1 internal APS):

  • Mes_Machines
  • Mes_ProductionOrders
  • Mes_ProductionLogs
  • Mes_CycleTimes
  • Mes_ProcessParameters
  • Mes_ScrapProducts
  • Mes_ReworkLogs
  • Mes_KPIs
  • Mes_OEE
  • Mes_MachineOccupancy
  • Mes_ApsPredictionHistory
  • Mes_OEE_Occupancy_KPIS
  • Mes_OperatorPerformance
  • StandardDurations

Ana entegrasyon API sayisi 26'dir: 13 adet GET /api/mapping/* preview endpointi ve 13 adet POST /api/aselsan/send/* gonderim endpointi. Ek sistem/test endpointleriyle birlikte yaklasik 33 endpoint vardir: GET /health, GET /docs, auth testleri, Mongo testleri ve Influx test endpointi.

Mes_ProcessParameters whitelist

CNC alanlari: connection, time_cut_time_cumulative, time_cycle_time_cumulative, time_online_time_cumulative, status_status_code, status_alarm_code, status_alarm_message, spindle_feed, spindle_speed, servo_speed, servo_load, servo_max_current, position_x, position_y, position_z, program_name, program_sequence, part_counter.

IoT alanlari: Tem1, Hum, Noise, E_V1, E_V2, E_V3, E_A1, E_A2, E_A3, E_FQ, PAT, E_PRT, E_ETAC, E_ETGC.

Gonderilmeyen alanlar: LanIP, IP, ip, topic, Topic, MQTT, mqtt, app, source_app, mqtt-influx, connection_details, selected_keys, E_ETR1, E_ETR2, E_ETR3, E_ETR4.

Noktali CNC alanlari normalize edilir: spindle.speed -> spindle_speed, program.name -> program_name, part.counter -> part_counter gibi. Her field ayri bir Mes_ProcessParameters kaydidir; nested Parameters array'i uretilmez.

Detayli ASELSAN endpoint karsilastirmasi ve IQVizyon mapping karsiliklari icin: docs/aselsan-endpoint-mapping.md

Guvenlik Yaklasimi

  • Helmet, CORS, rate limit ve body limit aktif.
  • ENABLE_SWAGGER=false ile Swagger production'da kapatilabilir.
  • Token, cookie, x-api-key, Mongo URI, Influx token ve MQTT secret alanlari loglarda maskelenir.
  • Token yoksa ASELSAN'a request atilmaz.
  • Test/live token ayrimi ASELSAN_SEND_MODE ile yapilir.
  • Payloadlar ASELSAN'a gitmeden once validator hattindan gecer.
  • Payloadlar Excel ColumnName_EN sozlugundeki alanlarla sinirlidir; Excel disi alan varsa validation error doner.

Canli Oncesi ASELSAN Konfigurasyonu

Canli gonderim oncesi asagidaki env ayarlari kullanilir:

Env Varsayilan Aciklama
ASELSAN_ID_MODE intMap Mongo ObjectId string yerine deterministik integer ID mapping
ASELSAN_ID_MAP_COLLECTION iqv_aselsan_id_map ID mapping MongoDB collection adi
ASELSAN_AUTH_SCHEME raw Authorization: {token} (Bearer prefix yok)
ASELSAN_PAYLOAD_MODE dataOnly Body formati { "data": [] }
ASELSAN_NULL_FIELD_MODE include null alanlari payload'da tut (omit ile cikarilabilir)
ASELSAN_EMPTY_JSON_STRING_MODE null Bos JSON alanlari icin null, "[]", "{}" veya ""
ASELSAN_SAMPLING_FIELD_NAME SampingPeriodMs ProcessParameters outbound alan adi (ODG)

ID mapping: sourceType + sourceId her zaman ayni pozitif integer dondurur. Mapping MongoDB'de persistent saklanir; test ortaminda in-memory fallback kullanilir.

Outbound payload'dan ODG disi alanlar (or. MachineID, CycleTimeID, OrderID, RecordID) cikarilir. Mes_OperatorPerformance alarms tabanli hesaplanir.

Dokumandaki ornek proje/urun/makine/product_id/operator_id degerleri yalnizca test/fixture icindir; uygulama kodunda hardcoded kullanilmaz.

Kurulum

cd C:\Users\muham\Desktop\iqv-aselsan\aselsan-ivme-integration
npm.cmd install
Copy-Item .env.example .env

Linux:

npm install
cp .env.example .env

Detayli kurulum icin docs/INSTALLATION.md dosyasina bak.

Calistirma

Windows PowerShell:

npm.cmd run dev
npm.cmd run build
npm.cmd start
npm.cmd test
npm.cmd run lint

Linux bash:

npm run dev
npm run build
npm start
npm test
npm run lint

Docker:

docker compose up --build -d

Swagger

http://localhost:3000/docs

Production'da kapatmak icin:

ENABLE_SWAGGER=false

Endpointler

Health:

  • GET /health

Test:

  • GET /api/test/auth/status
  • GET /api/test/auth/headers
  • GET /api/test/mongo/machines
  • GET /api/test/mongo/projects
  • GET /api/test/influx/:machineCode

Toplam veri servisleri: 13. Ana mapping/send endpointleri: 26. Sistem/test endpointleri dahil toplam endpoint sayisi yaklasik 33'tur.

Mapping preview:

  • GET /api/mapping/mes-machines
  • GET /api/mapping/mes-production-orders
  • GET /api/mapping/mes-production-logs
  • GET /api/mapping/mes-cycle-times
  • GET /api/mapping/mes-process-parameters?machineCode=3dyazici&range=-1h
  • GET /api/mapping/mes-scrap-products
  • GET /api/mapping/mes-rework-logs
  • GET /api/mapping/mes-kpis
  • GET /api/mapping/mes-oee
  • GET /api/mapping/mes-machine-occupancy
  • GET /api/mapping/mes-aps-prediction-history
  • GET /api/mapping/mes-oee-occupancy-kpis
  • GET /api/mapping/mes-operator-performance
  • GET /api/mapping/standard-durations

Mes_OperatorPerformance operasyon baslangic/bitis araligi ve alarms collection start/stop kayitlari uzerinden hesaplanir. Alarms kaydi bulunamazsa operator iliskisi korunur; WorkingHours=0, EfficiencyPercentage=0, ErrorRate=100 olarak donebilir. Dokumandaki ornek proje/urun/makine/product_id/ operator_id degerleri yalnizca test/fixture icindir; uygulama kodunda hardcoded kullanilmaz.

ASELSAN send:

  • POST /api/aselsan/send/mes-machines
  • POST /api/aselsan/send/mes-production-orders
  • POST /api/aselsan/send/mes-production-logs
  • POST /api/aselsan/send/mes-cycle-times
  • POST /api/aselsan/send/mes-process-parameters
  • POST /api/aselsan/send/mes-scrap-products
  • POST /api/aselsan/send/mes-rework-logs
  • POST /api/aselsan/send/mes-kpis
  • POST /api/aselsan/send/mes-oee
  • POST /api/aselsan/send/mes-machine-occupancy
  • POST /api/aselsan/send/mes-aps-prediction-history
  • POST /api/aselsan/send/mes-oee-occupancy-kpis
  • POST /api/aselsan/send/mes-operator-performance
  • POST /api/aselsan/send/standard-durations
  • POST /api/aselsan/send/all

Mock ASELSAN receiver (local test):

  • POST /api/mock-aselsan/:dataset
  • GET /api/mock-aselsan/requests
  • GET /api/mock-aselsan/requests/:id
  • DELETE /api/mock-aselsan/requests

Local Mock ASELSAN Test Akisi

Gercek ASELSAN API'sine POST atilmadan once, send endpointlerinin local mock receiver'a POST attigini dogrulamak icin:

Adim 1 — .env icinde (.env.example ile ayni):

PORT=3042
ASELSAN_BASE_URL=http://localhost:3042/api/mock-aselsan/
ASELSAN_SEND_MODE=test
ASELSAN_TEST_TOKEN=mock-test-token
ASELSAN_AUTH_TYPE=bearer
ASELSAN_PAYLOAD_MODE=dataOnly
ASELSAN_ENDPOINT_MES_MACHINES=PostMachine
ASELSAN_ENDPOINT_MES_PRODUCTION_ORDERS=PostProductionOrders
ASELSAN_ENDPOINT_MES_PROCESS_PARAMETERS=PostProcessParameters

Gercek ASELSAN URL yalnizca yorum satirinda birakilir:

# REAL_ASELSAN_BASE_URL=https://api.ahtapot.xyz/api/IntegrationIqvizyon/

Adim 2:

npm.cmd run dev

Adim 3 — Postman veya curl ile send endpointlerini cagirin:

curl -X POST "http://localhost:3042/api/aselsan/send/mes-machines?limit=10"
curl -X POST "http://localhost:3042/api/aselsan/send/mes-production-orders?limit=10"
curl -X POST "http://localhost:3042/api/aselsan/send/mes-process-parameters?machineCode=3dyazici&limit=10"

Servis su adrese POST atar: http://localhost:3042/api/mock-aselsan/PostMachine

Adim 4 — Mock receiver'a gelen kayitlari gormek icin:

curl http://localhost:3042/api/mock-aselsan/requests

Adim 5 — Store temizlemek icin:

curl -X DELETE http://localhost:3042/api/mock-aselsan/requests

POST /api/aselsan/send/all resmi API kapsamindaki 13 veri setini gonderir; Mes_ApsPredictionHistory default olarak haric tutulur.

Local mock test (StandardDurations):

curl -X DELETE http://localhost:3042/api/mock-aselsan/requests
curl -X POST "http://localhost:3042/api/aselsan/send/standard-durations?limit=5"
curl http://localhost:3042/api/mock-aselsan/requests

Local mock test (DigitalMaturity / OEE Occupancy KPIs):

curl -X DELETE http://localhost:3042/api/mock-aselsan/requests
curl -X POST "http://localhost:3042/api/aselsan/send/mes-oee-occupancy-kpis?limit=2"
curl http://localhost:3042/api/mock-aselsan/requests

Beklenen mock kayit: endpoint=PostDigitalMaturityOEEOccupancyKPIs, dataset=mes-oee-occupancy-kpis, payloadMode=dataOnly, unknownFields=[], yeni tarih alanlari (WeeklyStartDate vb.), eski split tarih alanlari (WeeklyOEEStartDate vb.) yok.

Mes_ProductionLogs notu: BREAK/END kayitlarinda StartTime ve Duration, ayni stage icindeki ayni machine_id'ye ait onceki Operation_Start kaydina baglidir. Baslangic kaydi bulunamazsa null kalir — bu validasyon hatasi degildir. Duration dolu kayitlari gormek icin: GET /api/mapping/mes-production-logs?onlyWithDuration=true

TS02 Kontrollu Veri Dogrulama Senaryosu

Mapping preview ve send endpointleri ortak filtreleri destekler:

GET /api/mapping/mes-production-orders?projectCode=TS02&productCode=telefon_tutacağı&machineCodes=3dyazici,3dyazici_2&dateFrom=2026-03-06T00:00:00.000Z&dateTo=2026-05-09T00:00:00.000Z&limit=20
GET /api/mapping/mes-production-logs?projectCode=TS02&productCode=telefon_tutacağı&onlyWithDuration=true&limit=50
POST /api/aselsan/send/all?projectCode=TS02&productCode=telefon_tutacağı&machineCodes=3dyazici,3dyazici_2&limit=20

Desteklenen filtreler: projectCode, productCode, machineCode, machineCodes, dateFrom, dateTo, limit.

Ornek curl

curl http://localhost:3000/health
curl http://localhost:3000/api/test/auth/status
curl "http://localhost:3000/api/mapping/mes-process-parameters?machineCode=3dyazici&range=-1h&limit=10"
curl -X POST "http://localhost:3000/api/aselsan/send/mes-machines?limit=50"
curl -X POST http://localhost:3000/api/aselsan/send/all \
  -H "content-type: application/json" \
  -d "{\"machineCode\":\"3dyazici\",\"range\":\"-1h\",\"limit\":10}"

Komutlar

npm run typecheck
npm run build
npm run lint
npm test
npm audit

Production Notlari

  • .env dosyasini git'e ekleme.
  • NODE_ENV=production, LOG_LEVEL=info, ENABLE_SWAGGER=false kullan.
  • ASELSAN_SEND_MODE=live yapmadan once gercek siparis/is emri/stok alanlarini dogrula.
  • MongoDB ve InfluxDB connection string/token degerlerini secret manager veya deployment secret mekanizmasi ile ver.

Analytics Worker

Uzun donem 180 gunluk OEE/KPI ve agir InfluxDB hesaplari icin Python tabanli ayri bir analytics worker eklenebilir. Bu API, worker'in urettigi ozetleri yeni servis/transformer katmani ile ASELSAN'a gonderecek sekilde genisletilebilir.