Class TransportUnitServiceImpl
java.lang.Object
org.openwms.common.transport.impl.TransportUnitServiceImpl
- All Implemented Interfaces:
TransportUnitService
A TransportUnitServiceImpl is a Spring managed bean that deals with TransportUnits.
- Author:
- Heiko Scherrer
-
Field Summary
Modifier and TypeFieldDescriptionprivate final BarcodeGenerator
private final String
private final LocationService
private static final org.slf4j.Logger
private final TransportUnitMapper
private final TransportUnitMoveApproval
private static final String
private static final String
private static final String
private final org.springframework.context.ApplicationEventPublisher
private final TransportUnitRepository
private final TransportUnitStateChangeApproval
private final org.ameba.i18n.Translator
private final TransportUnitTypeRepository
private final jakarta.validation.Validator
-
Constructor Summary
ConstructorDescriptionTransportUnitServiceImpl
(org.springframework.context.ApplicationEventPublisher publisher, jakarta.validation.Validator validator, org.ameba.i18n.Translator translator, BarcodeGenerator barcodeGenerator, TransportUnitMapper mapper, TransportUnitRepository repository, TransportUnitTypeRepository transportUnitTypeRepository, TransportUnitStateChangeApproval stateChangeApproval, TransportUnitMoveApproval moveApproval, LocationService locationService, String deleteTransportUnitMode) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add an error to aTransportUnit
.private void
approveMove
(TransportUnit transportUnit, Location newLocation) private void
approveStateChange
(TransportUnit transportUnit, String newState) changeTarget
(@NotNull Barcode barcode, @NotBlank String targetLocation) Change the target of theTransportUnit
identified with itsbarcode
to the Location identified by thetargetLocationId
.@NotNull TransportUnit
create
(@NotBlank String transportUnitBK, @NotBlank String transportUnitType, @NotBlank String actualLocation, Boolean strict) @NotNull TransportUnit
create
(@NotBlank String transportUnitBK, @NotNull TransportUnitType transportUnitType, @NotNull LocationPK actualLocation, Boolean strict) private TransportUnit
createInternal
(Barcode barcode, String transportUnitType, Boolean strict, Supplier<Location> locationResolver) @NotNull TransportUnit
void
Delete aTransportUnit
after requesting all parties for removal.private void
delete
(TransportUnit transportUnit) private void
deleteDefinitely
(String pKey) void
deleteTransportUnits
(@NotNull List<TransportUnit> transportUnits) Delete already persistedTransportUnit
s from the persistent storage.@NotNull List
<TransportUnit> findAll()
Find and return all existingTransportUnit
s.@NotNull TransportUnit
findByBarcode
(@NotBlank String transportUnitBK) Find and return aTransportUnit
by it'stransportUnitBK
.private TransportUnit
findByBarcodeInternal
(Barcode barcode) @NotNull List
<TransportUnit> findByBarcodes
(@NotEmpty List<Barcode> barcodes) Find and return allTransportUnit
s identified by their particularBarcode
.@NotNull TransportUnit
findByPKey
(@NotBlank String pKey) Find and return aTransportUnit
identified by the givenpKey
.private TransportUnit
findByPKeyInternal
(String pKey) @NotNull List
<TransportUnit> findOnLocation
(@NotBlank String actualLocation) Find and return allTransportUnit
s that are located on theLocation
identified by the givenactualLocation
.private TransportUnit
moveInternal
(TransportUnit transportUnit, Location target) @NotNull TransportUnit
moveTransportUnit
(@NotNull Barcode barcode, @NotBlank String targetLocation) Move aTransportUnit
identified by itsBarcode
to theLocation
identified by the giventargetLocationPK
.void
void
Change the state of aTransportUnit
.void
Trigger a synchronization of TransportUnits.@NotNull TransportUnit
update
(@NotNull Barcode barcode, @Valid @NotNull TransportUnit tu) Take the TransportUnittu
and try to update it as-is in the persistent storage.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
NO_LOCATION_SET
- See Also:
-
NO_BARCODE
- See Also:
-
NO_TRANSPORT_UNIT_TYPE
- See Also:
-
publisher
private final org.springframework.context.ApplicationEventPublisher publisher -
validator
private final jakarta.validation.Validator validator -
translator
private final org.ameba.i18n.Translator translator -
barcodeGenerator
-
mapper
-
repository
-
transportUnitTypeRepository
-
stateChangeApproval
-
moveApproval
-
locationService
-
deleteTransportUnitMode
-
-
Constructor Details
-
TransportUnitServiceImpl
TransportUnitServiceImpl(org.springframework.context.ApplicationEventPublisher publisher, jakarta.validation.Validator validator, org.ameba.i18n.Translator translator, BarcodeGenerator barcodeGenerator, TransportUnitMapper mapper, TransportUnitRepository repository, TransportUnitTypeRepository transportUnitTypeRepository, @Autowired(required=false) TransportUnitStateChangeApproval stateChangeApproval, @Autowired(required=false) TransportUnitMoveApproval moveApproval, LocationService locationService, @Value("${owms.common.delete-transport-unit-mode}") String deleteTransportUnitMode)
-
-
Method Details
-
create
@Measured @NotNull public @NotNull TransportUnit create(@NotBlank @NotBlank String transportUnitBK, @NotNull @NotNull TransportUnitType transportUnitType, @NotNull @NotNull LocationPK actualLocation, Boolean strict) Create a newTransportUnit
with the typeTransportUnitType
placed on an initialLocation
. The newTransportUnit
has the givenBarcode
as identifier.- Specified by:
create
in interfaceTransportUnitService
- Parameters:
transportUnitBK
- The business identifier of the TransportUnittransportUnitType
- The type of the TransportUnitactualLocation
- The Location where the TransportUnit is placed onstrict
- Whether the implementation shall throw an exception when a TransportUnit already exists (true) or not (false- Returns:
- The newly created instance
-
create
@Measured @NotNull public @NotNull TransportUnit create(@NotBlank @NotBlank String transportUnitBK, @NotBlank @NotBlank String transportUnitType, @NotBlank @NotBlank String actualLocation, Boolean strict) Create a newTransportUnit
with theTransportUnitType
placed on the givenactualLocation
. The newTransportUnit
has the givenBarcode
as identifier.- Specified by:
create
in interfaceTransportUnitService
- Parameters:
transportUnitBK
- The business identifier of the TransportUnit, must not be nulltransportUnitType
- The type of the TransportUnit, must not be nullactualLocation
- The Location where the TransportUnit is placed on, must not be nullstrict
- Whether the implementation shall throw an exception when a TransportUnit already exists (true) or not (false- Returns:
- The newly created instance
-
createNew
@Measured @NotNull public @NotNull TransportUnit createNew(@NotBlank @NotBlank String transportUnitType, @NotBlank @NotBlank String actualLocation) Create a newTransportUnit
with theTransportUnitType
placed on the givenactualLocation
. The newTransportUnit
has aBarcode
generated by the system.- Specified by:
createNew
in interfaceTransportUnitService
- Parameters:
transportUnitType
- The type of the TransportUnit, must not be nullactualLocation
- The Location where the TransportUnit is placed on, must not be null- Returns:
- The newly created instance
-
createInternal
-
update
@Validated(Update.class) @Measured @NotNull public @NotNull TransportUnit update(@NotNull @NotNull Barcode barcode, @Valid @NotNull @Valid @NotNull TransportUnit tu) Take the TransportUnittu
and try to update it as-is in the persistent storage.The implementation does not require any further checks. Assume that it tries to detach the entity class with the persistence context and save the given state.
- Specified by:
update
in interfaceTransportUnitService
- Parameters:
barcode
- The business identifier of the TransportUnittu
- The TransportUnit instance to save- Returns:
- The updated instance
-
approveMove
-
moveInternal
-
moveTransportUnit
@Measured @NotNull public @NotNull TransportUnit moveTransportUnit(@NotNull @NotNull Barcode barcode, @NotBlank @NotBlank String targetLocation) Move aTransportUnit
identified by itsBarcode
to theLocation
identified by the giventargetLocationPK
.- Specified by:
moveTransportUnit
in interfaceTransportUnitService
- Parameters:
barcode
- The business identifier of the TransportUnittargetLocation
- Unique identifier of the target Location, either the LocationID, ERPCode or PLCCode- Returns:
- The moved instance
-
deleteTransportUnits
Delete already persistedTransportUnit
s from the persistent storage. It is not allowed in every case to delete aTransportUnit
, potentially an activeTransportOrder
could exist or Inventory is still linked with one of thetransportUnit
s.- Specified by:
deleteTransportUnits
in interfaceTransportUnitService
- Parameters:
transportUnits
- A collection ofTransportUnit
s to delete
-
delete
Delete aTransportUnit
after requesting all parties for removal.- Specified by:
delete
in interfaceTransportUnitService
- Parameters:
pKey
- The persistent key
-
onEvent
-
deleteDefinitely
-
delete
-
findByBarcode
@Measured @NotNull public @NotNull TransportUnit findByBarcode(@NotBlank @NotBlank String transportUnitBK) Find and return aTransportUnit
by it'stransportUnitBK
.- Specified by:
findByBarcode
in interfaceTransportUnitService
- Parameters:
transportUnitBK
- The business identifier of the TransportUnit- Returns:
- The TransportUnit
-
findByBarcodeInternal
-
findByBarcodes
@Measured @NotNull public @NotNull List<TransportUnit> findByBarcodes(@NotEmpty @NotEmpty List<Barcode> barcodes) Find and return allTransportUnit
s identified by their particularBarcode
.- Specified by:
findByBarcodes
in interfaceTransportUnitService
- Parameters:
barcodes
- A list of business identifiers of the TransportUnits- Returns:
- A List of TransportUnits or an empty List, never null
-
findOnLocation
@Measured @NotNull public @NotNull List<TransportUnit> findOnLocation(@NotBlank @NotBlank String actualLocation) Find and return allTransportUnit
s that are located on theLocation
identified by the givenactualLocation
.- Specified by:
findOnLocation
in interfaceTransportUnitService
- Parameters:
actualLocation
- The Location where the TransportUnits are placed on- Returns:
- All TransportUnits or an empty List, never null
-
findByPKey
Find and return aTransportUnit
identified by the givenpKey
.- Specified by:
findByPKey
in interfaceTransportUnitService
- Parameters:
pKey
- The persistent key- Returns:
- The instance, never null
-
findByPKeyInternal
-
addError
@Measured public void addError(@NotBlank @NotBlank String transportUnitBK, @NotNull @NotNull UnitError unitError) Add an error to aTransportUnit
.- Specified by:
addError
in interfaceTransportUnitService
- Parameters:
transportUnitBK
- The business identifier of the TransportUnitunitError
- The errorCode bitmap
-
findAll
Find and return all existingTransportUnit
s.- Specified by:
findAll
in interfaceTransportUnitService
- Returns:
- a List of all existing or an empty List but never null
-
changeTarget
@Measured public TransportUnit changeTarget(@NotNull @NotNull Barcode barcode, @NotBlank @NotBlank String targetLocation) Change the target of theTransportUnit
identified with itsbarcode
to the Location identified by thetargetLocationId
.- Specified by:
changeTarget
in interfaceTransportUnitService
- Parameters:
barcode
- The business identifier of the TransportUnittargetLocation
- The LocationPK or null to reset the current target
-
setState
@Measured public void setState(@NotBlank @NotBlank String transportUnitBK, @NotBlank @NotBlank String newState) Change the state of aTransportUnit
.- Specified by:
setState
in interfaceTransportUnitService
- Parameters:
transportUnitBK
- The business identifier of the TransportUnitnewState
- The desired state
-
approveStateChange
-
synchronizeTransportUnits
@Measured public void synchronizeTransportUnits()Trigger a synchronization of TransportUnits.- Specified by:
synchronizeTransportUnits
in interfaceTransportUnitService
-