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
FieldsModifier and TypeFieldDescriptionprivate final BarcodeGeneratorprivate final Stringprivate final LocationServiceprivate static final org.slf4j.Loggerprivate final TransportUnitMapperprivate final TransportUnitMoveApprovalprivate static final Stringprivate static final Stringprivate static final Stringprivate final org.springframework.context.ApplicationEventPublisherprivate final TransportUnitRepositoryprivate final TransportUnitStateChangeApprovalprivate final org.ameba.i18n.Translatorprivate final TransportUnitTypeRepositoryprivate final jakarta.validation.Validator -
Constructor Summary
ConstructorsConstructorDescriptionTransportUnitServiceImpl(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 TypeMethodDescriptionvoidAdd an error to aTransportUnit.private voidapproveMove(TransportUnit transportUnit, Location newLocation) private voidapproveStateChange(TransportUnit transportUnit, String newState) changeTarget(@NotNull Barcode barcode, @NotBlank String targetLocation) Change the target of theTransportUnitidentified with itsbarcodeto the Location identified by thetargetLocationId.@NotNull TransportUnitcreate(@NotBlank String transportUnitBK, @NotBlank String transportUnitType, @NotBlank String actualLocation, Boolean strict) @NotNull TransportUnitcreate(@NotBlank String transportUnitBK, @NotNull TransportUnitType transportUnitType, @NotNull LocationPK actualLocation, Boolean strict) private TransportUnitcreateInternal(Barcode barcode, String transportUnitType, Boolean strict, Supplier<Location> locationResolver) @NotNull TransportUnitvoidDelete aTransportUnitafter requesting all parties for removal.private voiddelete(TransportUnit transportUnit) private voiddeleteDefinitely(String pKey) voiddeleteTransportUnits(@NotNull List<TransportUnit> transportUnits) Delete already persistedTransportUnits from the persistent storage.@NotNull List<TransportUnit> findAll()Find and return all existingTransportUnits.@NotNull TransportUnitfindByBarcode(@NotBlank String transportUnitBK) Find and return aTransportUnitby it'stransportUnitBK.private TransportUnitfindByBarcodeInternal(Barcode barcode) @NotNull List<TransportUnit> findByBarcodes(@NotEmpty List<Barcode> barcodes) Find and return allTransportUnits identified by their particularBarcode.@NotNull TransportUnitfindByPKey(@NotBlank String pKey) Find and return aTransportUnitidentified by the givenpKey.private TransportUnitfindByPKeyInternal(String pKey) @NotNull List<TransportUnit> findOnLocation(@NotBlank String actualLocation) Find and return allTransportUnits that are located on theLocationidentified by the givenactualLocation.private TransportUnitmoveInternal(TransportUnit transportUnit, Location target) @NotNull TransportUnitmoveTransportUnit(@NotNull Barcode barcode, @NotBlank String targetLocation) Move aTransportUnitidentified by itsBarcodeto theLocationidentified by the giventargetLocationPK.voidvoidChange the state of aTransportUnit.voidTrigger a synchronization of TransportUnits.@NotNull TransportUnitupdate(@NotNull Barcode barcode, @Valid @NotNull TransportUnit tu) Take the TransportUnittuand 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 newTransportUnitwith the typeTransportUnitTypeplaced on an initialLocation. The newTransportUnithas the givenBarcodeas identifier.- Specified by:
createin 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 newTransportUnitwith theTransportUnitTypeplaced on the givenactualLocation. The newTransportUnithas the givenBarcodeas identifier.- Specified by:
createin 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 newTransportUnitwith theTransportUnitTypeplaced on the givenactualLocation. The newTransportUnithas aBarcodegenerated by the system.- Specified by:
createNewin 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 TransportUnittuand 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:
updatein 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 aTransportUnitidentified by itsBarcodeto theLocationidentified by the giventargetLocationPK.- Specified by:
moveTransportUnitin 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 persistedTransportUnits from the persistent storage. It is not allowed in every case to delete aTransportUnit, potentially an activeTransportOrdercould exist or Inventory is still linked with one of thetransportUnits.- Specified by:
deleteTransportUnitsin interfaceTransportUnitService- Parameters:
transportUnits- A collection ofTransportUnits to delete
-
delete
Delete aTransportUnitafter requesting all parties for removal.- Specified by:
deletein interfaceTransportUnitService- Parameters:
pKey- The persistent key
-
onEvent
-
deleteDefinitely
-
delete
-
findByBarcode
@Measured @NotNull public @NotNull TransportUnit findByBarcode(@NotBlank @NotBlank String transportUnitBK) Find and return aTransportUnitby it'stransportUnitBK.- Specified by:
findByBarcodein 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 allTransportUnits identified by their particularBarcode.- Specified by:
findByBarcodesin 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 allTransportUnits that are located on theLocationidentified by the givenactualLocation.- Specified by:
findOnLocationin interfaceTransportUnitService- Parameters:
actualLocation- The Location where the TransportUnits are placed on- Returns:
- All TransportUnits or an empty List, never null
-
findByPKey
Find and return aTransportUnitidentified by the givenpKey.- Specified by:
findByPKeyin 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:
addErrorin interfaceTransportUnitService- Parameters:
transportUnitBK- The business identifier of the TransportUnitunitError- The errorCode bitmap
-
findAll
Find and return all existingTransportUnits.- Specified by:
findAllin 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 theTransportUnitidentified with itsbarcodeto the Location identified by thetargetLocationId.- Specified by:
changeTargetin 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:
setStatein 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:
synchronizeTransportUnitsin interfaceTransportUnitService
-