processCimaLorryInoutReports
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 seconds |
| Source File | src/_cron/cron.service.ts |
Changelog
| Date | Author | Description |
|---|---|---|
| (original) | — | Initial implementation |
Current Logic
Schedule
EVERY_10_SECONDS
Processing Flow
Every 10 seconds
│
└─ Fetch ALL Pending tasks where code = 'Process CIMA Lorry In_Out Report'
└─ If none → return early
│
└─ Bulk mark all fetched tasks → Running
│
└─ For each task:
│
├─ Parse value: { cima_lorry_in_out_report_id }
├─ Find CimaLorryInOutReport by id
│ └─ If not found → skip (no status update, no error logged)
│
├─ Call cimaLorryInOutReportService.processCimaLorryInOutReport(inOutReport)
│ └─ Parses file → populates CimaDeliveryInfo records
│
├─ On success (result = true):
│ ├─ Mark task → 'Success'
│ └─ Creates MicroserviceTask:
│ code: 'Auto Update CIMA Supplier Data By Supplier Data'
│
└─ On failure (result = false or exception):
└─ Mark task → 'Fail'
Task Input
{
"cima_lorry_in_out_report_id": 123
}
Notes
- Tasks are bulk-marked
Runningbefore the loop — not per-task. If the server crashes mid-loop, remaining tasks stay asRunningand are never retried. - If
CimaLorryInOutReportrecord is not found, the task is silently skipped with no status update (staysRunningindefinitely). - On success, immediately chains to
autoUpdateCIMASupplierDataBySupplierDatavia a new microservice task.