processCimaLorryInoutReports
Version: Draft — Changes pending production deployment.
Overview
A cron job that picks up queued tasks to parse uploaded CIMA Lorry In/Out Report files.
On success, it triggers the next step in Flow A by creating an
Auto Update CIMA Supplier Data By Supplier Data task.
| Function | processCimaLorryInoutReports |
| Task Code | Process CIMA Lorry In_Out Report |
| Schedule | Every 10 minutes |
| Source File | src/_cron/cron.service.ts |
Changelog
| Date | Author | Description |
|---|---|---|
| 2026-02-25 | sf | Changed schedule from every 2 hours to every 10 minutes; changed from bulk pickup (all Pending at once) to 1 task per run via pessimistic lock (getTaskToProcess); task status update moved to finally block |
| 2026-02-25 | sf | Changed schedule from EVERY_10_SECONDS to every 2 hours (0 */2 * * *) |
Previous versions are preserved in Page Revisions (top-right menu → Revisions).
Current Logic
Schedule
EVERY_10_MINUTES (every 10 minutes)
Processing Flow
Every 10 minutes
│
└─ getTaskToProcess('Process CIMA Lorry In_Out Report') ← pessimistic lock, 1 task per run
└─ If no task → return early
│
└─ Parse value: { cima_lorry_in_out_report_id }
│
└─ Find CimaLorryInOutReport by id
└─ If found:
├─ Call cimaLorryInOutReportService.processCimaLorryInOutReport(inOutReport)
│ └─ Parses file → populates CimaDeliveryInfo records
│
├─ On success (result = true):
│ └─ Creates MicroserviceTask:
│ code: 'Auto Update CIMA Supplier Data By Supplier Data'
│ (picked up by autoUpdateCIMASupplierDataBySupplierData on next 10-min run)
│
└─ On failure (result = false):
└─ status → 'Fail'
│
└─ finally: update task status → 'Success' or 'Fail'
Task Input
{ "cima_lorry_in_out_report_id": 123 }
Notes
- Uses
getTaskToProcess(pessimistic lock,SKIP LOCKED) — safe to run concurrently. - Exactly 1 task is processed per cron run. Remaining pending tasks are picked up on the next tick.
- On success, immediately chains to
autoUpdateCIMASupplierDataBySupplierDatavia a new microservice task.