Files
Starseed/src/Module/Logistique/Application/Service/DsdAllocatorInterface.php
T
Matthieu e455204bbd feat(logistique) : pesée pont bascule stub + allocateur DSD + endpoint (ERP-184)
- WeighbridgeReaderInterface (contrat) + RandomWeighbridgeReader (stub,
  poids aléatoire ∈ [10000,50000] kg, RG-5.06) + WeighbridgeUnavailableException
- DsdAllocator : compteur DSD par site (weighbridge_dsd_counter) incrémenté
  sous verrou ligne SELECT ... FOR UPDATE (RG-5.04, § 2.7)
- endpoint POST /api/weighbridge_readings : ressource virtuelle
  WeighbridgeReadingResource + WeighbridgeReadingProcessor (pas de controller)
  - AUTO -> {weight, dsd, mode} ; MANUAL -> {weight, dsd, manualNumber, mode}
  - WeighbridgeUnavailableException -> HTTP 503 explicite (RG-5.06)
  - site courant via CurrentSiteProviderInterface (contrat Sites)
  - is_granted('logistique.weighing_tickets.manage')
- dsd renvoyé prévisionnel : attribution autoritaire refaite à la création
  du ticket (ERP-185)
- tests : WeighbridgeReaderStubTest, DsdAllocatorTest, processor (503/400),
  WeighbridgeReadingApiTest (RBAC + AUTO/MANUAL + 422)
2026-06-17 18:09:54 +02:00

28 lines
877 B
PHP

<?php
declare(strict_types=1);
namespace App\Module\Logistique\Application\Service;
use App\Shared\Domain\Contract\SiteInterface;
/**
* Allocateur du compteur DSD du pont bascule (RG-5.04, § 2.7).
*
* Le DSD est un index sequentiel de pesee, propre a CHAQUE site (un pont par
* site). Chaque pesee — bascule (AUTO) ou manuelle (MANUAL) — consomme une
* valeur : la suivante = dernier DSD du site + 1.
*
* Port (interface en couche Application) ; l'implementation (DsdAllocator,
* Infrastructure) incremente le compteur sous verrou ligne `SELECT ... FOR
* UPDATE` pour garantir l'unicite en concurrence.
*/
interface DsdAllocatorInterface
{
/**
* Attribue et renvoie la prochaine valeur DSD pour le site (dernier + 1),
* en persistant l'increment de maniere atomique (verrou ligne).
*/
public function next(SiteInterface $site): int;
}