e455204bbd
- 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)
35 lines
1.2 KiB
PHP
35 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Module\Logistique\Infrastructure\Weighbridge;
|
|
|
|
use App\Module\Logistique\Application\Service\DsdAllocatorInterface;
|
|
use App\Module\Logistique\Domain\Contract\WeighbridgeReaderInterface;
|
|
use App\Module\Logistique\Domain\Weighbridge\WeighbridgeReading;
|
|
use App\Shared\Domain\Contract\SiteInterface;
|
|
|
|
/**
|
|
* Stub du pont bascule livre au M5 (DECISION Matthieu 17/06, § 2.6 / RG-5.06).
|
|
*
|
|
* Aucune liaison materielle : la pesee « bascule » est simulee par un poids
|
|
* aleatoire ∈ [10000, 50000] kg, et le DSD est attribue par l'allocateur de
|
|
* site (DsdAllocator, RG-5.04). Le driver materiel reel (HP-M5-02) remplacera
|
|
* cette classe derriere WeighbridgeReaderInterface sans impact sur l'API.
|
|
*
|
|
* Ce stub ne leve jamais WeighbridgeUnavailableException ; le chemin d'erreur
|
|
* (→ 503) reste implemente et teste cote Processor.
|
|
*/
|
|
final class RandomWeighbridgeReader implements WeighbridgeReaderInterface
|
|
{
|
|
public function __construct(private readonly DsdAllocatorInterface $dsdAllocator) {}
|
|
|
|
public function read(SiteInterface $site): WeighbridgeReading
|
|
{
|
|
return new WeighbridgeReading(
|
|
weight: random_int(10000, 50000),
|
|
dsd: $this->dsdAllocator->next($site),
|
|
);
|
|
}
|
|
}
|