---
suivi: 1356
date: 2026-08-14
sujet: lot_f_depot_documentaire_interface
chantier: marches_reprise
type: feat
statut: poussé
hash: 211d0eae
fichiers:
  - database/migrations/2026_08_14_160000_add_depot_sharepoint_to_siwi_documents_table.php
  - app/Support/SharePointArborescenceStructures.php
  - app/Support/SiwiDocumentBrancheRouter.php
  - app/Support/SiwiDocumentPdfResolver.php
  - app/Services/SharePointService.php
  - app/Services/SiwiDocumentDepotService.php
  - app/Services/SiwiImportPageService.php
  - app/Http/Controllers/SiwiImportController.php
  - app/Models/SiwiMarche.php
  - app/Models/SiwiDocument.php
  - routes/web.php
  - resources/js/Pages/SiwiImport/Index.vue
  - tests/Unit/SiwiDocumentDepot1356Test.php
  - database/data/journal_mises_a_jour_post_2026_06_12.php
  - public/build/
  - docs/suivi/SUIVI_1356_lot_f_depot_documentaire_interface.md
---

## PROMPT ENVOYÉ

SUIVI #1356 — dépôt documentaire SIWI depuis l’interface (WEB), par programme.
Bascule arb HECTARE CDC pour nouveaux marchés. Pas CLI/queue (token app
bloqué en CLI OVH, #1355). Idempotence id_doc. Ne pas renommer existant.
Ne pas toucher ENVOL.

## FICHES LUES

- `#1355` LEÇON : arb #1098 ≠ CDC ; CLI token NON sur OVH ; intention
  `etat_depot_docs` ≠ file.
- `#1353` : jeton app pour écritures marché.
- `#1326` : pose `en_attente` à la création.
- `#1338`/`#1340` : résolution PDF casse-insensible.

## SYNTHÈSE

### Jeton / CLI (rappel #1355)

Dépôt **uniquement WEB** (`POST …/depot-documents`). Aucune commande artisan
de dépôt. `getAppAccessToken` en PHP-FPM.

### Arborescence HECTARE (nouveaux)

`creerDossierMarcheLotissement` → CDC :
`TRAVAUX/{POSTE}--{ENTREPRISE}--{REF}/CONTRACTUEL|FACTURES|TECHNIQUE|SOUS_TRAITANCE`
Collision via référence complète. Early-return si `sharepoint_folder_id` déjà
posé → **aucun renommage** des 5 programmes existants. ENVOL VEFA inchangé.

### Dépôt

- Bouton programme « Déposer documents » + tag `Docs N sur M`.
- Service `SiwiDocumentDepotService` : lots jusqu’à 80 % de `max_execution_time`
  (fallback 180 s) ; relance auto UI si `interrupted`.
- Routage `SiwiDocumentBrancheRouter` ; PDF `SiwiDocumentPdfResolver` ;
  upload `uploadFichierApp` ; `sharepoint_item_id` écrit à chaque succès.
- Migration TRAVAIL `siwi_documents` (item_id, statut, erreur) — pas de FK.

### Tests unitaires (Cursor)

5 tests verts : routage 4 branches, nom fichier, structure CDC, anti-collision
REF, idempotence logique. **Dépôt Graph réel = procédure Robin OVH** (pas
accessible depuis Cursor).

## DÉPLOIEMENT-TEST

```bash
git pull origin main
php artisan migrate --force
php artisan route:clear
php artisan optimize:clear && php artisan view:clear
php artisan journal:sync
```

Procédure Robin (preuve prod) :
1. Ouvrir `/siwi-import` (GS_GROUPE), programme HECTARE lié + SP ok.
2. Cliquer « Déposer documents » ; noter progression et chemins toast/logs.
3. Relancer → 0 nouveau dépôt (idempotence).
4. Vérifier SharePoint : feuille `--MCH-…` + 4 dossiers ; programmes existants
   (ex. HEC34-003) non renommés.

## LEÇON

1. Token app Microsoft Login bloqué en CLI OVH → dépôt = endpoint web.
2. Bascule CDC sans renommer : early-return sur `sharepoint_folder_id` existant
   + ensure CDC parallèle pour dépôt si besoin.
3. Idempotence `sharepoint_item_id` rend la relance après timeout sûre.
